Module src.olaaaf.formula
Representation of logical formulas and multiple tools to use them, abstracted depending on the operator's formula.
Declaration of a new olaaaf.formula.formula.Formula
To declare a new olaaaf.formula.formula.Formula, you have multiple options:
-
Use the usual class constructors. Depending on the operator's arity, the arguments that are expected might change (namely, those represents the arguments of the operators and, as such, a different number of them could be expected). Please note that they have an optional argument
namethat we'll talk about in the point after next. -
Use Python's built-in (but restrictive) operators between two existing formulas, namely:
-
&for the and operator, represented byolaaaf.formula.naryFormula.andOperator.And -
|for the or operator, represented byolaaaf.formula.naryFormula.orOperator.Or -
~for the not operator, represented byolaaaf.formula.unaryFormula.notOperator.Not -
>>for the implication operator, represented byolaaaf.formula.binaryFormula.implicationOperator.Implication -
//for the equivalence operator, represented byolaaaf.formula.binaryFormula.equivalenceOperator.Equivalence -
!=for the xor operator, represented byolaaaf.formula.binaryFormula.xorOperator.Xor
-
-
Use
olaaaf.formula.formulaManager.FormulaManager.parserto declare a formula using a parser with customizable operators. While more intuitive due to the less restrictive scope of usable operators, this method of declaring formulas assume you previously named them, either via thefmNameattribute in their constructor or thanks toolaaaf.formula.formulaManager.FormulaManager.declare. The operators could be customized inolaaaf.constants.Constantsbut are by default:-
&for the and operator, represented byolaaaf.formula.naryFormula.andOperator.And -
|for the or operator, represented byolaaaf.formula.naryFormula.orOperator.Or -
~for the not operator, represented byolaaaf.formula.unaryFormula.notOperator.Not -
->for the implication operator, represented byolaaaf.formula.binaryFormula.implicationOperator.Implication -
<->for the equivalence operator, represented byolaaaf.formula.binaryFormula.equivalenceOperator.Equivalence -
<+>for the xor operator, represented byolaaaf.formula.binaryFormula.xorOperator.Xor
-
Exemple of declaration
IntegerVariable.declare("x")
a = Not(LinearConstraint("x <= 7/9"))
b = LinearConstraint("2.4*x >= 4")
And(formulaName = "phi", a, b)
Implication(formulaName = "psi", ~(a | b), ~b)
Sub-modules
src.olaaaf.formula.binaryFormula-
Representation of binary formulas, meaning formulas with 2 arguments.
src.olaaaf.formula.formula-
Abstract Formula class, representing a Formula in PCMLC as a syntax tree.
src.olaaaf.formula.formulaDisplay-
Utility class, allowing the user to get a visualisation of a
olaaaf.formula.formula.Formula. src.olaaaf.formula.formulaManager-
This class allows the user to easily declare a new
olaaaf.formula.formula.Formulathanks toolaaaf.formula.formulaManager.FormulaManager.parser… src.olaaaf.formula.naryFormula-
Representation of n-ary formulas, meaning formulas with n arguments.
src.olaaaf.formula.nullaryFormula-
Representation of nullary formulas, meaning formulas with no arguments.
src.olaaaf.formula.unaryFormula-
Representation of unary formulas, meaning formulas with only one argument.