AUTHORS:
EXAMPLES:
We can assign values to the variables and evaluate a formula:
sage: import sage.logic.booleval as booleval
sage: t = ['|', ['&', 'a', 'b'], ['&', 'a', 'c']]
sage: d = {'a' : True, 'b' : False, 'c' : True}
sage: booleval.eval_formula(t, d)
True
We can change our assignment of values by modifying the dictionary:
sage: d['a'] = False
sage: booleval.eval_formula(t, d)
False
Evaluate the tree.
INPUT:
OUTPUT:
The result of the evaluation as a boolean value.
EXAMPLES:
This example illustrates how to evaluate a parse tree:
sage: import sage.logic.booleval as booleval
sage: booleval.eval_f(['&', True, False])
False
sage: booleval.eval_f(['^', True, True])
False
sage: booleval.eval_f(['|', False, True])
True
Evaluate the tree and return a boolean value.
INPUT:
OUTPUT:
The result of the evaluation as a boolean value.
EXAMPLES:
This example illustrates evaluating a boolean formula:
sage: import sage.logic.booleval as booleval
sage: t = ['|', ['&', 'a', 'b'], ['&', 'a', 'c']]
sage: d = {'a' : True, 'b' : False, 'c' : True}
sage: booleval.eval_formula(t, d)
True
sage: d['a'] = False
sage: booleval.eval_formula(t, d)
False
Evaluate lv and rv according to the operator op.
INPUT:
OUTPUT:
The evaluation of lv op rv as a boolean value.
EXAMPLES:
We can evaluate an operator given the values on either side:
sage: import sage.logic.booleval as booleval
sage: booleval.eval_op('&', True, False)
False
sage: booleval.eval_op('^', True, True)
False
sage: booleval.eval_op('|', False, True)
True