-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdln.py
More file actions
40 lines (34 loc) · 1.07 KB
/
cmdln.py
File metadata and controls
40 lines (34 loc) · 1.07 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
import sys
import parser
import cnf
import res
import dpll
import time
args = sys.argv
def get_time():
return time.time() * 1000
def satcheck():
if len(args) != 3:
print("Wrong arg length! Usage: python3 cmdln <expression>")
return
flag = args[1]
expr = args[2]
if flag == "cnf":
return cnf.clause_nf(parser.parse(expr))
if flag == "res":
return res.res(expr)
if flag == "dpll":
return dpll.DPLL(cnf.clause_nf(parser.parse(expr)))
if flag == "cmp":
start_time = get_time()
print("========================= RES =========================")
res.res(expr)
timestep = get_time() - start_time
print("=============== TIME TAKEN : " + str(timestep) + " ===============")
start_time = get_time()
print("========================= DPLL =========================")
dpll.DPLL(cnf.clause_nf(parser.parse(expr)))
timestep = get_time() - start_time
print("=============== TIME TAKEN : " + str(timestep) + " ===============")
return True
satcheck()