-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsat_solver.py
43 lines (35 loc) · 1.08 KB
/
sat_solver.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
'''
Written by Paola Accioly in June/2019.
'''
def readInputs():
inputs = []
return inputs
def readClauses(inputs):
clauses = []
return clauses
def readVariables(clauses):
variables = []
return variables
def readFormula():
inputs = readInputs()
clauses = readClauses(inputs)
variables = readVariables(clauses)
result = {'clauses':clauses, 'variables':variables}
return result
def nextAssignment(currentAssignment):
nextAssignment = []
return nextAssignment
def doSolve(clauses, assignment):
isSat = False
while ((not isSat) and '''must check whether this is the last assignment or not'''):
'''does this assignment satisfy the formula? If so, make isSat true.
if not, get the next assignment and try again.'''
assignment = nextAssignment(assignment)
result = {'isSat': isSat, 'satisfyingAssignment': None}
if (isSat):
result['satisfyingAssignment'] = assignment
return result
def solve():
formula = readFormula()
result = doSolve(formula['clauses'], formula['variables'])
return result