Class LogicTreeToolBox


  • public class LogicTreeToolBox
    extends Object
    A tool box to convert logical expressions into CNF.
    Since:
    23 nov. 2010
    Author:
    Charles Prud'homme, Xavier Lorca
    • Constructor Detail

      • LogicTreeToolBox

        protected LogicTreeToolBox()
        This class is a factory, no need to create it.
    • Method Detail

      • toCNF

        public static ILogical toCNF​(LogOp logOp,
                                     Model model)
        Warning: if there is a bug, please check the CNF build is like: - lit OR lit ... OR lit - (lit OR lit ... OR lit) AND (lit OR lit ... OR lit) ... AND (lit OR lit ... OR lit)
        Parameters:
        logOp - logical operator
        model - the model in which the logical expression will be added, useful since the expression may only be made of TRUE and FALSE.
        Returns:
        a CNF logical expression
      • expandNot

        public static void expandNot​(LogOp n)
        Erases 'NOT' operand from the logical expression n by flipping the right children
        Parameters:
        n - a logical expression
      • merge

        public static void merge​(LogOp.Operator op,
                                 LogOp n)
        Flattens a logical expression n based on operator op. Transform from undefined depth expression to comb expression
        Parameters:
        op - reference operator
        n - the lofical expression
      • developOr

        public static LogOp developOr​(LogOp n)
        Moves down 'OR' operand in the logical expression n.
        Parameters:
        n - a logical expression
        Returns:
        the modified logical expression
      • distribute

        public static LogOp distribute​(LogOp n)
        Distributes 'OR's inwards over 'AND's in n
        Parameters:
        n - a logical expression
        Returns:
        the modified logical expression