-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskeleton.py
More file actions
80 lines (56 loc) · 2.26 KB
/
skeleton.py
File metadata and controls
80 lines (56 loc) · 2.26 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
74
75
76
77
78
79
80
MAX_CONSTANTS = 10
# Parse a formula, consult parseOutputs for return values.
def parse(fmla):
return 0
# Return the LHS of a binary connective formula
def lhs(fmla):
return ''
# Return the connective symbol of a binary connective formula
def con(fmla):
return ''
# Return the RHS symbol of a binary connective formula
def rhs(fmla):
return ''
# You may choose to represent a theory as a set or a list
def theory(fmla):#initialise a theory with a single formula in it
return None
#check for satisfiability
def sat(tableau):
#output 0 if not satisfiable, output 1 if satisfiable, output 2 if number of constants exceeds MAX_CONSTANTS
return 0
#------------------------------------------------------------------------------------------------------------------------------:
# DO NOT MODIFY THE CODE BELOW THIS LINE! :
#------------------------------------------------------------------------------------------------------------------------------:
f = open('input.txt')
parseOutputs = ['not a formula',
'an atom',
'a negation of a first order logic formula',
'a universally quantified formula',
'an existentially quantified formula',
'a binary connective first order formula',
'a proposition',
'a negation of a propositional formula',
'a binary connective propositional formula']
satOutput = ['is not satisfiable', 'is satisfiable', 'may or may not be satisfiable']
firstline = f.readline()
PARSE = False
if 'PARSE' in firstline:
PARSE = True
SAT = False
if 'SAT' in firstline:
SAT = True
for line in f:
if line[-1] == '\n':
line = line[:-1]
parsed = parse(line)
if PARSE:
output = "%s is %s." % (line, parseOutputs[parsed])
if parsed in [5,8]:
output += " Its left hand side is %s, its connective is %s, and its right hand side is %s." % (lhs(line), con(line) ,rhs(line))
print(output)
if SAT:
if parsed:
tableau = [theory(line)]
print('%s %s.' % (line, satOutput[sat(tableau)]))
else:
print('%s is not a formula.' % line)