-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
73 lines (50 loc) · 1.76 KB
/
main.py
File metadata and controls
73 lines (50 loc) · 1.76 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import propositional
#driver code
if __name__ =="__main__":
f = open("LogicFile.txt")
# print("hi")
kb = []
li_statements=[]
TMS=propositional.TMS(kb)
# print(TMS.kb)
final_state=[]
index=0
for line in f:
print(line)
# print(line.strip('\n'))
index+=1
state=[]
if "ASSERT" in line:
# print("assert")
state.append(index)
statement=line[9:].strip('\n').strip(' ').strip(' ').strip('(').strip(')')
state.extend(statement.split(', '))
final_state=[]
# final_state.append(index)
for i in range(len(state)):
final_state.append(state[i]) #idea is to append final_state[i+1]=state[i]
#debugging print statement commented out
# print("final state is", final_state)
# if not kb:
ret_val=TMS.assert_s(final_state)
#conflict has occurred, do not continue
if ret_val==-1:
break
# elif kb:
# TMS.resolution(kb, state)
# print(statement)
elif "RETRACT" in line:
index+=1
# state.append(index)
# print("retract")
statement = line[10:].strip('\n').strip(' ').strip('(').strip(')')
# print(statement)
state.extend(statement)
#debugging print statements commented out
# print("retract state is", state)
# print("retract statement is",state)
TMS.retract_s(state)
# print("I've returned from retract")
print("The kb is:")
for i in range(len(TMS.kb)):
print(TMS.kb[i])