# Untitled

a guest
Sep 13th, 2021
27
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def test_evaluate(debug=True):
2.     infix1 = "~(p&q7)"
3.     models_values1 = [
4.         ({"p": True, "q7": False}, True),
5.         ({"p": False, "q7": False}, True),
6.         ({"p": True, "q7": True}, False),
7.     ]
8.     infix2 = "~~~x"
9.     models_values2 = [({"x": True}, False), ({"x": False}, True)]
10.     infix3 = "((x->y)&(~x->z))"
11.     models_values3 = [
12.         ({"x": True, "y": False, "z": True}, False),
13.         ({"x": False, "y": False, "z": True}, True),
14.         ({"x": True, "y": True, "z": False}, True),
15.     ]
16.     infix4 = "(T&p)"
17.     models_values4 = [({"p": True}, True), ({"p": False}, False)]
18.     infix5 = "(F|p)"
19.     models_values5 = [({"p": True}, True), ({"p": False}, False)]
20.     for infix, models_values in [
21.         [infix1, models_values1],
22.         [infix2, models_values2],
23.         [infix3, models_values3],
24.         [infix4, models_values4],
25.         [infix5, models_values5],
26.     ]:
27.         formula = Formula.parse(infix)
28.         for model, value in models_values:
29.             if debug:
30.                 print(
31.                     "Testing evaluation of formula", formula, "in model", model
32.                 )
33.             assert evaluate(formula, frozendict(model)) == value
RAW Paste Data