Perform boolean evaluation of boolean formulas.
AUTHORS:
EXAMPLES:
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
This function can be applied to a parse tree to evaluate it.
INPUT:
OUTPUT:
EXAMPLES:
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
Evaluates the tree using the boolean values contained in dictionary and returns a single boolean value.
INPUT:
OUTPUT:
EXAMPLES:
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
This function evaluates lv and rv according to the operator op.
INPUT:
OUTPUT:
EXAMPLES:
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