-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproplogic_example.py
50 lines (44 loc) · 1.43 KB
/
proplogic_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sat_interface
def tt1():
'''
Example of how to interact with sat_interface module
Propositions:
A: Amy is a truth-teller
B: Bob is a truth-teller
C: Cal is a truth-teller
return a list containing all entailed propositions or negated propositions
'''
print("Truth-tellers and liars I")
print("-------------------------")
ttprob = sat_interface.KB(["~A ~B",
"B A",
"~B ~C",
"C B",
"~C ~A",
"~C ~B",
"A B C"])
entailed = []
if ttprob.test_literal("A") == False:
entailed.append(False)
print("Amy is a liar")
if ttprob.test_literal("~A") == False:
entailed.append(True)
print("Amy is a truth-teller")
if ttprob.test_literal("B") == False:
entailed.append(False)
print("Bob is a liar")
if ttprob.test_literal("~B") == False:
entailed.append(True)
print("Bob is a truth-teller")
if ttprob.test_literal("C") == False:
entailed.append(False)
print("Cal is a liar")
if ttprob.test_literal("~C") == False:
entailed.append(True)
print("Cal is a truth-teller")
print("-------------------------")
return entailed
def main():
print(tt1())
if __name__ == '__main__':
main()