-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprove.py
74 lines (58 loc) · 1.99 KB
/
prove.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from LIPS import parse_args
from LIPS import Prover
import datetime
from pprint import pprint
def print_separator(message: str):
print("=" * 50 + f" {message} " + "=" * 50)
def generate(prover: Prover, problem: str):
"""
Generate and process proof states for a given problem.
Args:
prover (Prover): The prover instance to use
problem (str): The problem to prove
"""
MAX_ITERATIONS = 200
# Initialize problem
print_separator("Prover Configs")
print(f"{prover}\n")
prover.set_problem(problem)
# Main proof iteration loop
for idx in range(MAX_ITERATIONS):
# Prepare for new iteration
prover.clean()
prover.save_json()
proof_state = prover.get_next()
# Print iteration status
print_separator(f"Iteration {idx}")
print(f"Start time: {datetime.datetime.now()}")
# Check if we've exhausted all states
if proof_state == -1:
print("No more proof states available")
break
# Probe the current state
if idx > 0:
smt_res, msg = prover.probe_state(proof_state)
else:
smt_res, msg = 1, ""
# Process the state based on SMT result
if smt_res <= 0:
print(f"Failed to solve the problem: {msg}")
states = []
else:
steps = prover.get_steps(proof_state)
states = prover.get_state(proof_state, steps)
# Check if proof is complete
if states is None:
return # Proof completed successfully
# Update and rank states
prover.update_state(states)
prover.rank_state()
# Final symbolic check
if not prover.close_by_sym():
print("Failed to prove the problem")
if __name__ == "__main__":
args = parse_args()
pprint(vars(args), width=160)
prover = Prover(args)
problem = args.problem
generate(prover, problem)