author | Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de> |
Tue, 14 Jun 2022 16:14:28 +0200 | |
changeset 75561 | b6239ed66b94 |
parent 75274 | e89709b80b6e |
permissions | -rw-r--r-- |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
1 |
(* Title: HOL/Tools/SMT/Verit_Proof.ML |
57704 | 2 |
Author: Mathias Fleury, ENS Rennes |
3 |
Author: Sascha Boehme, TU Muenchen |
|
4 |
||
5 |
VeriT proofs: parsing and abstract syntax tree. |
|
6 |
*) |
|
7 |
||
8 |
signature VERIT_PROOF = |
|
9 |
sig |
|
10 |
(*proofs*) |
|
11 |
datatype veriT_step = VeriT_Step of { |
|
57712
3c4e6bc7455f
Simplifying the labels in the proof of the SMT solver veriT.
fleury
parents:
57710
diff
changeset
|
12 |
id: string, |
57704 | 13 |
rule: string, |
14 |
prems: string list, |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
15 |
proof_ctxt: term list, |
57704 | 16 |
concl: term, |
17 |
fixes: string list} |
|
18 |
||
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
19 |
datatype veriT_replay_node = VeriT_Replay_Node of { |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
20 |
id: string, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
21 |
rule: string, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
22 |
args: term list, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
23 |
prems: string list, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
24 |
proof_ctxt: term list, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
25 |
concl: term, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
26 |
bounds: (string * typ) list, |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
27 |
declarations: (string * term) list, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
28 |
insts: term Symtab.table, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
29 |
subproof: (string * typ) list * term list * term list * veriT_replay_node list} |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
30 |
|
57704 | 31 |
(*proof parser*) |
32 |
val parse: typ Symtab.table -> term Symtab.table -> string list -> |
|
33 |
Proof.context -> veriT_step list * Proof.context |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
34 |
val parse_replay: typ Symtab.table -> term Symtab.table -> string list -> |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
35 |
Proof.context -> veriT_replay_node list * Proof.context |
57704 | 36 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
37 |
val step_prefix : string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
38 |
val input_rule: string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
39 |
val keep_app_symbols: string -> bool |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
40 |
val keep_raw_lifting: string -> bool |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
41 |
val normalized_input_rule: string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
42 |
val la_generic_rule : string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
43 |
val rewrite_rule : string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
44 |
val simp_arith_rule : string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
45 |
val veriT_deep_skolemize_rule : string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
46 |
val veriT_def : string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
47 |
val subproof_rule : string |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
48 |
val local_input_rule : string |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
49 |
val not_not_rule : string |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
50 |
val contract_rule : string |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
51 |
val ite_intro_rule : string |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
52 |
val eq_congruent_rule : string |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
53 |
val eq_congruent_pred_rule : string |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
54 |
val skolemization_steps : string list |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
55 |
val theory_resolution2_rule: string |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
56 |
val equiv_pos2_rule: string |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
57 |
val th_resolution_rule: string |
75561
b6239ed66b94
fix veriT reconstruction for and_pos and lambda-lifting
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
75274
diff
changeset
|
58 |
val and_pos_rule: string |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
59 |
|
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
60 |
val is_skolemization: string -> bool |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
61 |
val is_skolemization_step: veriT_replay_node -> bool |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
62 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
63 |
val number_of_steps: veriT_replay_node list -> int |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
64 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
65 |
(*Strategy related*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
66 |
val veriT_strategy : string Config.T |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
67 |
val veriT_current_strategy : Context.generic -> string list |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
68 |
val all_veriT_stgies: Context.generic -> string list; |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
69 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
70 |
val select_veriT_stgy: string -> Context.generic -> Context.generic; |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
71 |
val valid_veriT_stgy: string -> Context.generic -> bool; |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
72 |
val verit_add_stgy: string * string list -> Context.generic -> Context.generic |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
73 |
val verit_rm_stgy: string -> Context.generic -> Context.generic |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
74 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
75 |
(*Global tactic*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
76 |
val verit_tac: Proof.context -> thm list -> int -> tactic |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
77 |
val verit_tac_stgy: string -> Proof.context -> thm list -> int -> tactic |
57704 | 78 |
end; |
79 |
||
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
80 |
structure Verit_Proof: VERIT_PROOF = |
57704 | 81 |
struct |
82 |
||
58061 | 83 |
open SMTLIB_Proof |
57704 | 84 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
85 |
val veriT_strategy_default_name = "default"; (*FUDGE*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
86 |
val veriT_strategy_del_insts_name = "del_insts"; (*FUDGE*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
87 |
val veriT_strategy_rm_insts_name = "ccfv_SIG"; (*FUDGE*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
88 |
val veriT_strategy_ccfv_insts_name = "ccfv_threshold"; (*FUDGE*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
89 |
val veriT_strategy_best_name = "best"; (*FUDGE*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
90 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
91 |
val veriT_strategy_best = ["--index-sorts", "--index-fresh-sorts", "--triggers-new", |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
92 |
"--triggers-sel-rm-specific"]; |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
93 |
val veriT_strategy_del_insts = ["--index-sorts", "--index-fresh-sorts", "--ccfv-breadth", |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
94 |
"--inst-deletion", "--index-SAT-triggers", "--inst-deletion-loops", "--inst-deletion-track-vars", |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
95 |
"--inst-deletion", "--index-SAT-triggers"]; |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
96 |
val veriT_strategy_rm_insts = ["--index-SIG", "--triggers-new", "--triggers-sel-rm-specific"]; |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
97 |
val veriT_strategy_ccfv_insts = ["--index-sorts", "--index-fresh-sorts", "--triggers-new", |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
98 |
"--triggers-sel-rm-specific", "--triggers-restrict-combine", "--inst-deletion", |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
99 |
"--index-SAT-triggers", "--inst-deletion-loops", "--inst-deletion-track-vars", "--inst-deletion", |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
100 |
"--index-SAT-triggers", "--inst-sorts-threshold=100000", "--ematch-exp=10000000", |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
101 |
"--ccfv-index=100000", "--ccfv-index-full=1000"] |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
102 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
103 |
val veriT_strategy_default = []; |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
104 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
105 |
type verit_strategy = {default_strategy: string, strategies: (string * string list) list} |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
106 |
fun mk_verit_strategy default_strategy strategies : verit_strategy = {default_strategy=default_strategy,strategies=strategies} |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
107 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
108 |
val empty_data = mk_verit_strategy veriT_strategy_best_name |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
109 |
[(veriT_strategy_default_name, veriT_strategy_default), |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
110 |
(veriT_strategy_del_insts_name, veriT_strategy_del_insts), |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
111 |
(veriT_strategy_rm_insts_name, veriT_strategy_rm_insts), |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
112 |
(veriT_strategy_ccfv_insts_name, veriT_strategy_ccfv_insts), |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
113 |
(veriT_strategy_best_name, veriT_strategy_best)] |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
114 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
115 |
fun merge_data ({strategies=strategies1,...}:verit_strategy, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
116 |
{default_strategy,strategies=strategies2}:verit_strategy) : verit_strategy = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
117 |
mk_verit_strategy default_strategy (AList.merge (op =) (op =) (strategies1, strategies2)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
118 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
119 |
structure Data = Generic_Data |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
120 |
( |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
121 |
type T = verit_strategy |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
122 |
val empty = empty_data |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
123 |
val merge = merge_data |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
124 |
) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
125 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
126 |
fun veriT_current_strategy ctxt = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
127 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
128 |
val {default_strategy,strategies} = (Data.get ctxt) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
129 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
130 |
AList.lookup (op=) strategies default_strategy |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
131 |
|> the |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
132 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
133 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
134 |
val veriT_strategy = Attrib.setup_config_string \<^binding>\<open>smt_verit_strategy\<close> (K veriT_strategy_best_name); |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
135 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
136 |
fun valid_veriT_stgy stgy context = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
137 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
138 |
val {strategies,...} = Data.get context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
139 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
140 |
AList.defined (op =) strategies stgy |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
141 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
142 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
143 |
fun select_veriT_stgy stgy context = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
144 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
145 |
val {strategies,...} = Data.get context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
146 |
val upd = Data.map (K (mk_verit_strategy stgy strategies)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
147 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
148 |
if not (AList.defined (op =) strategies stgy) then |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
149 |
error ("Trying to select unknown veriT strategy: " ^ quote stgy) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
150 |
else upd context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
151 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
152 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
153 |
fun verit_add_stgy stgy context = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
154 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
155 |
val {default_strategy,strategies} = Data.get context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
156 |
in |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
157 |
Data.map |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
158 |
(K (mk_verit_strategy default_strategy (AList.update (op =) stgy strategies))) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
159 |
context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
160 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
161 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
162 |
fun verit_rm_stgy stgy context = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
163 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
164 |
val {default_strategy,strategies} = Data.get context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
165 |
in |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
166 |
Data.map |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
167 |
(K (mk_verit_strategy default_strategy (AList.delete (op =) stgy strategies))) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
168 |
context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
169 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
170 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
171 |
fun all_veriT_stgies context = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
172 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
173 |
val {strategies,...} = Data.get context |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
174 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
175 |
map fst strategies |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
176 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
177 |
|
74817
1fd8705503b4
generate problems with correct logic for veriT
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74561
diff
changeset
|
178 |
val select_verit = SMT_Config.select_solver "verit" |
1fd8705503b4
generate problems with correct logic for veriT
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74561
diff
changeset
|
179 |
fun verit_tac ctxt = SMT_Solver.smt_tac (Config.put SMT_Config.native_bv false ((Context.proof_map select_verit ctxt))) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
180 |
fun verit_tac_stgy stgy ctxt = verit_tac (Context.proof_of (select_veriT_stgy stgy (Context.Proof ctxt))) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
181 |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
182 |
datatype raw_veriT_node = Raw_VeriT_Node of { |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
183 |
id: string, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
184 |
rule: string, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
185 |
args: SMTLIB.tree, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
186 |
prems: string list, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
187 |
concl: SMTLIB.tree, |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
188 |
declarations: (string * SMTLIB.tree) list, |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
189 |
subproof: raw_veriT_node list} |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
190 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
191 |
fun mk_raw_node id rule args prems declarations concl subproof = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
192 |
Raw_VeriT_Node {id = id, rule = rule, args = args, prems = prems, declarations = declarations, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
193 |
concl = concl, subproof = subproof} |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
194 |
|
57704 | 195 |
datatype veriT_node = VeriT_Node of { |
57712
3c4e6bc7455f
Simplifying the labels in the proof of the SMT solver veriT.
fleury
parents:
57710
diff
changeset
|
196 |
id: string, |
57704 | 197 |
rule: string, |
198 |
prems: string list, |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
199 |
proof_ctxt: term list, |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
200 |
concl: term} |
57704 | 201 |
|
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
202 |
fun mk_node id rule prems proof_ctxt concl = |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
203 |
VeriT_Node {id = id, rule = rule, prems = prems, proof_ctxt = proof_ctxt, concl = concl} |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
204 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
205 |
datatype veriT_replay_node = VeriT_Replay_Node of { |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
206 |
id: string, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
207 |
rule: string, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
208 |
args: term list, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
209 |
prems: string list, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
210 |
proof_ctxt: term list, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
211 |
concl: term, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
212 |
bounds: (string * typ) list, |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
213 |
insts: term Symtab.table, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
214 |
declarations: (string * term) list, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
215 |
subproof: (string * typ) list * term list * term list * veriT_replay_node list} |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
216 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
217 |
fun mk_replay_node id rule args prems proof_ctxt concl bounds insts declarations subproof = |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
218 |
VeriT_Replay_Node {id = id, rule = rule, args = args, prems = prems, proof_ctxt = proof_ctxt, |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
219 |
concl = concl, bounds = bounds, insts = insts, declarations = declarations, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
220 |
subproof = subproof} |
57704 | 221 |
|
222 |
datatype veriT_step = VeriT_Step of { |
|
57712
3c4e6bc7455f
Simplifying the labels in the proof of the SMT solver veriT.
fleury
parents:
57710
diff
changeset
|
223 |
id: string, |
57704 | 224 |
rule: string, |
225 |
prems: string list, |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
226 |
proof_ctxt: term list, |
57704 | 227 |
concl: term, |
228 |
fixes: string list} |
|
229 |
||
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
230 |
fun mk_step id rule prems proof_ctxt concl fixes = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
231 |
VeriT_Step {id = id, rule = rule, prems = prems, proof_ctxt = proof_ctxt, concl = concl, |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
232 |
fixes = fixes} |
57704 | 233 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
234 |
val step_prefix = ".c" |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
235 |
val input_rule = "input" |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
236 |
val la_generic_rule = "la_generic" |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
237 |
val normalized_input_rule = "__normalized_input" (*arbitrary*) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
238 |
val rewrite_rule = "__rewrite" (*arbitrary*) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
239 |
val subproof_rule = "subproof" |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
240 |
val local_input_rule = "__local_input" (*arbitrary*) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
241 |
val simp_arith_rule = "simp_arith" |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
242 |
val veriT_def = "__skolem_definition" (*arbitrary*) |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
243 |
val not_not_rule = "not_not" |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
244 |
val contract_rule = "contraction" |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
245 |
val eq_congruent_pred_rule = "eq_congruent_pred" |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
246 |
val eq_congruent_rule = "eq_congruent" |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
247 |
val ite_intro_rule = "ite_intro" |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
248 |
val default_skolem_rule = "sko_forall" (*arbitrary, but must be one of the skolems*) |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
249 |
val theory_resolution2_rule = "__theory_resolution2" (*arbitrary*) |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
250 |
val equiv_pos2_rule = "equiv_pos2" |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
251 |
val th_resolution_rule = "th_resolution" |
75561
b6239ed66b94
fix veriT reconstruction for and_pos and lambda-lifting
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
75274
diff
changeset
|
252 |
val and_pos_rule = "and_pos" |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
253 |
|
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
254 |
val skolemization_steps = ["sko_forall", "sko_ex"] |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
255 |
val is_skolemization = member (op =) skolemization_steps |
75561
b6239ed66b94
fix veriT reconstruction for and_pos and lambda-lifting
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
75274
diff
changeset
|
256 |
val keep_app_symbols = member (op =) [eq_congruent_pred_rule, eq_congruent_rule, ite_intro_rule, and_pos_rule] |
b6239ed66b94
fix veriT reconstruction for and_pos and lambda-lifting
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
75274
diff
changeset
|
257 |
val keep_raw_lifting = member (op =) [eq_congruent_pred_rule, eq_congruent_rule, ite_intro_rule, and_pos_rule] |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
258 |
val is_SH_trivial = member (op =) [not_not_rule, contract_rule] |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
259 |
|
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
260 |
fun is_skolemization_step (VeriT_Replay_Node {id, ...}) = is_skolemization id |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
261 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
262 |
(* Even the veriT developers do not know if the following rule can still appear in proofs: *) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
263 |
val veriT_deep_skolemize_rule = "deep_skolemize" |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
264 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
265 |
fun number_of_steps [] = 0 |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
266 |
| number_of_steps ((VeriT_Replay_Node {subproof = (_, _, _, subproof), ...}) :: pf) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
267 |
1 + number_of_steps subproof + number_of_steps pf |
57708
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
268 |
|
57704 | 269 |
(* proof parser *) |
270 |
||
271 |
fun node_of p cx = |
|
272 |
([], cx) |
|
57747 | 273 |
||>> `(with_fresh_names (term_of p)) |
57716 | 274 |
|>> snd |
57704 | 275 |
|
58490 | 276 |
fun find_type_in_formula (Abs (v, T, u)) var_name = |
277 |
if String.isPrefix var_name v then SOME T else find_type_in_formula u var_name |
|
57705 | 278 |
| find_type_in_formula (u $ v) var_name = |
279 |
(case find_type_in_formula u var_name of |
|
280 |
NONE => find_type_in_formula v var_name |
|
58490 | 281 |
| some_T => some_T) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
282 |
| find_type_in_formula (Free(v, T)) var_name = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
283 |
if String.isPrefix var_name v then SOME T else NONE |
57705 | 284 |
| find_type_in_formula _ _ = NONE |
285 |
||
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
286 |
fun synctactic_var_subst old_name new_name (u $ v) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
287 |
(synctactic_var_subst old_name new_name u $ synctactic_var_subst old_name new_name v) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
288 |
| synctactic_var_subst old_name new_name (Abs (v, T, u)) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
289 |
Abs (if String.isPrefix old_name v then new_name else v, T, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
290 |
synctactic_var_subst old_name new_name u) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
291 |
| synctactic_var_subst old_name new_name (Free (v, T)) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
292 |
if String.isPrefix old_name v then Free (new_name, T) else Free (v, T) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
293 |
| synctactic_var_subst _ _ t = t |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
294 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
295 |
fun synctatic_rew_in_lhs_subst old_name new_name (Const(\<^const_name>\<open>HOL.eq\<close>, T) $ t1 $ t2) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
296 |
Const(\<^const_name>\<open>HOL.eq\<close>, T) $ synctactic_var_subst old_name new_name t1 $ t2 |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
297 |
| synctatic_rew_in_lhs_subst old_name new_name (Const(\<^const_name>\<open>Trueprop\<close>, T) $ t1) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
298 |
Const(\<^const_name>\<open>Trueprop\<close>, T) $ (synctatic_rew_in_lhs_subst old_name new_name t1) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
299 |
| synctatic_rew_in_lhs_subst _ _ t = t |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
300 |
|
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
301 |
fun add_bound_variables_to_ctxt cx = |
58490 | 302 |
fold (update_binding o |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
303 |
(fn (s, SOME typ) => (s, Term (Free (s, type_of cx typ))))) |
57705 | 304 |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
305 |
local |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
306 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
307 |
fun extract_symbols bds = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
308 |
bds |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
309 |
|> map (fn (SMTLIB.S [SMTLIB.Sym "=", SMTLIB.Sym x, SMTLIB.Sym y], typ) => [([x, y], typ)] |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
310 |
| t => raise (Fail ("match error " ^ @{make_string} t))) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
311 |
|> flat |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
312 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
313 |
(* onepoint can bind a variable to another variable or to a constant *) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
314 |
fun extract_qnt_symbols cx bds = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
315 |
bds |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
316 |
|> map (fn (SMTLIB.S [SMTLIB.Sym "=", SMTLIB.Sym x, SMTLIB.Sym y], typ) => |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
317 |
(case node_of (SMTLIB.Sym y) cx of |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
318 |
((_, []), _) => [([x], typ)] |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
319 |
| _ => [([x, y], typ)]) |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
320 |
| (SMTLIB.S (SMTLIB.Sym "=" :: SMTLIB.Sym x :: _), typ) => [([x], typ)] |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
321 |
| t => raise (Fail ("match error " ^ @{make_string} t))) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
322 |
|> flat |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
323 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
324 |
fun extract_symbols_map bds = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
325 |
bds |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
326 |
|> map (fn (SMTLIB.S [SMTLIB.Sym "=", SMTLIB.Sym x, _], typ) => [([x], typ)]) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
327 |
|> flat |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
328 |
in |
57705 | 329 |
|
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
330 |
fun declared_csts _ "__skolem_definition" [(SMTLIB.S [SMTLIB.Sym x, typ, _], _)] = [(x, typ)] |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
331 |
| declared_csts _ "__skolem_definition" t = raise (Fail ("unrecognized skolem_definition " ^ @{make_string} t)) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
332 |
| declared_csts _ _ _ = [] |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
333 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
334 |
fun skolems_introduced_by_rule (SMTLIB.S bds) = |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
335 |
fold (fn (SMTLIB.S [SMTLIB.Sym "=", _, SMTLIB.Sym y]) => curry (op ::) y) bds [] |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
336 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
337 |
(*FIXME there is probably a way to use the information given by onepoint*) |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
338 |
fun bound_vars_by_rule _ "bind" (bds) = extract_symbols bds |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
339 |
| bound_vars_by_rule cx "onepoint" bds = extract_qnt_symbols cx bds |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
340 |
| bound_vars_by_rule _ "sko_forall" bds = extract_symbols_map bds |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
341 |
| bound_vars_by_rule _ "sko_ex" bds = extract_symbols_map bds |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
342 |
| bound_vars_by_rule _ "__skolem_definition" [(SMTLIB.S [SMTLIB.Sym x, typ, _], _)] = [([x], SOME typ)] |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
343 |
| bound_vars_by_rule _ "__skolem_definition" [(SMTLIB.S [_, SMTLIB.Sym x, _], _)] = [([x], NONE)] |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
344 |
| bound_vars_by_rule _ _ _ = [] |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
345 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
346 |
(* VeriT adds "?" before some variables. *) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
347 |
fun remove_all_qm (SMTLIB.Sym v :: l) = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
348 |
SMTLIB.Sym (perhaps (try (unprefix "?")) v) :: remove_all_qm l |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
349 |
| remove_all_qm (SMTLIB.S l :: l') = SMTLIB.S (remove_all_qm l) :: remove_all_qm l' |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
350 |
| remove_all_qm (SMTLIB.Key v :: l) = SMTLIB.Key v :: remove_all_qm l |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
351 |
| remove_all_qm (v :: l) = v :: remove_all_qm l |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
352 |
| remove_all_qm [] = [] |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
353 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
354 |
fun remove_all_qm2 (SMTLIB.Sym v) = SMTLIB.Sym (perhaps (try (unprefix "?")) v) |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
355 |
| remove_all_qm2 (SMTLIB.S l) = SMTLIB.S (remove_all_qm l) |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
356 |
| remove_all_qm2 (SMTLIB.Key v) = SMTLIB.Key v |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
357 |
| remove_all_qm2 v = v |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
358 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
359 |
end |
57705 | 360 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
361 |
datatype step_kind = ASSUME | ANCHOR | NO_STEP | NORMAL_STEP | SKOLEM |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
362 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
363 |
fun parse_raw_proof_steps (limit : string option) (ls : SMTLIB.tree list) (cx : name_bindings) : |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
364 |
(raw_veriT_node list * SMTLIB.tree list * name_bindings) = |
57704 | 365 |
let |
366 |
fun rotate_pair (a, (b, c)) = ((a, b), c) |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
367 |
fun step_kind [] = (NO_STEP, SMTLIB.S [], []) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
368 |
| step_kind ((p as SMTLIB.S (SMTLIB.Sym "anchor" :: _)) :: l) = (ANCHOR, p, l) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
369 |
| step_kind ((p as SMTLIB.S (SMTLIB.Sym "assume" :: _)) :: l) = (ASSUME, p, l) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
370 |
| step_kind ((p as SMTLIB.S (SMTLIB.Sym "step" :: _)) :: l) = (NORMAL_STEP, p, l) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
371 |
| step_kind ((p as SMTLIB.S (SMTLIB.Sym "define-fun" :: _)) :: l) = (SKOLEM, p, l) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
372 |
fun parse_skolem (SMTLIB.S [SMTLIB.Sym "define-fun", SMTLIB.Sym id, _, typ, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
373 |
SMTLIB.S (SMTLIB.Sym "!" :: t :: [SMTLIB.Key _, SMTLIB.Sym name])]) cx = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
374 |
(*replace the name binding by the constant instead of the full term in order to reduce |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
375 |
the size of the generated terms and therefore the reconstruction time*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
376 |
let val (l, cx) = (fst oo SMTLIB_Proof.extract_and_update_name_bindings) t cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
377 |
|> apsnd (SMTLIB_Proof.update_name_binding (name, SMTLIB.Sym id)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
378 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
379 |
(mk_raw_node (id ^ veriT_def) veriT_def (SMTLIB.S [SMTLIB.Sym id, typ, l]) [] [] |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
380 |
(SMTLIB.S [SMTLIB.Sym "=", SMTLIB.Sym id, l]) [], cx) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
381 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
382 |
| parse_skolem (SMTLIB.S [SMTLIB.Sym "define-fun", SMTLIB.Sym id, _, typ, SMTLIB.S l]) cx = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
383 |
let val (l, cx) = (fst oo SMTLIB_Proof.extract_and_update_name_bindings) (SMTLIB.S l ) cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
384 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
385 |
(mk_raw_node (id ^ veriT_def) veriT_def (SMTLIB.S [SMTLIB.Sym id, typ, l]) [] [] |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
386 |
(SMTLIB.S [SMTLIB.Sym "=", SMTLIB.Sym id, l]) [], cx) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
387 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
388 |
| parse_skolem t _ = raise Fail ("unrecognized VeriT proof " ^ \<^make_string> t) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
389 |
fun get_id_cx (SMTLIB.S ((SMTLIB.Sym _) :: (SMTLIB.Sym id) :: l), cx) = (id, (l, cx)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
390 |
| get_id_cx t = raise Fail ("unrecognized VeriT proof " ^ \<^make_string> t) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
391 |
fun get_id (SMTLIB.S ((SMTLIB.Sym _) :: (SMTLIB.Sym id) :: l)) = (id, l) |
69593 | 392 |
| get_id t = raise Fail ("unrecognized VeriT proof " ^ \<^make_string> t) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
393 |
fun parse_source (SMTLIB.Key "premises" :: SMTLIB.S source ::l, cx) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
394 |
(SOME (map (fn (SMTLIB.Sym id) => id) source), (l, cx)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
395 |
| parse_source (l, cx) = (NONE, (l, cx)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
396 |
fun parse_rule (SMTLIB.Key "rule" :: SMTLIB.Sym r :: l, cx) = (r, (l, cx)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
397 |
| parse_rule t = raise Fail ("unrecognized VeriT proof " ^ \<^make_string> t) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
398 |
fun parse_anchor_step (SMTLIB.S (SMTLIB.Sym "anchor" :: SMTLIB.Key "step" :: SMTLIB.Sym r :: l), cx) = (r, (l, cx)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
399 |
| parse_anchor_step t = raise Fail ("unrecognized VeriT proof " ^ \<^make_string> t) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
400 |
fun parse_args (SMTLIB.Key "args" :: args :: l, cx) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
401 |
let val ((args, cx), _) = SMTLIB_Proof.extract_and_update_name_bindings args cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
402 |
in (args, (l, cx)) end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
403 |
| parse_args (l, cx) = (SMTLIB.S [], (l, cx)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
404 |
fun parse_and_clausify_conclusion (SMTLIB.S (SMTLIB.Sym "cl" :: []) :: l, cx) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
405 |
(SMTLIB.Sym "false", (l, cx)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
406 |
| parse_and_clausify_conclusion (SMTLIB.S (SMTLIB.Sym "cl" :: concl) :: l, cx) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
407 |
let val (concl, cx) = fold_map (fst oo SMTLIB_Proof.extract_and_update_name_bindings) concl cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
408 |
in (SMTLIB.S (SMTLIB.Sym "or" :: concl), (l, cx)) end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
409 |
| parse_and_clausify_conclusion t = raise Fail ("unrecognized VeriT proof " ^ \<^make_string> t) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
410 |
val parse_normal_step = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
411 |
get_id_cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
412 |
##> parse_and_clausify_conclusion |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
413 |
#> rotate_pair |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
414 |
##> parse_rule |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
415 |
#> rotate_pair |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
416 |
##> parse_source |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
417 |
#> rotate_pair |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
418 |
##> parse_args |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
419 |
#> rotate_pair |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
420 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
421 |
fun to_raw_node subproof ((((id, concl), rule), prems), args) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
422 |
mk_raw_node id rule args (the_default [] prems) [] concl subproof |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
423 |
fun at_discharge NONE _ = false |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
424 |
| at_discharge (SOME id) p = p |> get_id |> fst |> (fn id2 => id = id2) |
57704 | 425 |
in |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
426 |
case step_kind ls of |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
427 |
(NO_STEP, _, _) => ([],[], cx) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
428 |
| (NORMAL_STEP, p, l) => |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
429 |
if at_discharge limit p then ([], ls, cx) else |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
430 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
431 |
val (s, (_, cx)) = (p, cx) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
432 |
|> parse_normal_step |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
433 |
||> (fn i => i) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
434 |
|>> (to_raw_node []) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
435 |
val (rp, rl, cx) = parse_raw_proof_steps limit l cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
436 |
in (s :: rp, rl, cx) end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
437 |
| (ASSUME, p, l) => |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
438 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
439 |
val (id, t :: []) = p |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
440 |
|> get_id |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
441 |
val ((t, cx), _) = SMTLIB_Proof.extract_and_update_name_bindings t cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
442 |
val s = mk_raw_node id input_rule (SMTLIB.S []) [] [] t [] |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
443 |
val (rp, rl, cx) = parse_raw_proof_steps limit l cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
444 |
in (s :: rp, rl, cx) end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
445 |
| (ANCHOR, p, l) => |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
446 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
447 |
val (anchor_id, (anchor_args, (_, cx))) = (p, cx) |> (parse_anchor_step ##> parse_args) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
448 |
val (subproof, discharge_step :: remaining_proof, cx) = parse_raw_proof_steps (SOME anchor_id) l cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
449 |
val (curss, (_, cx)) = parse_normal_step (discharge_step, cx) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
450 |
val s = to_raw_node subproof (fst curss, anchor_args) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
451 |
val (rp, rl, cx) = parse_raw_proof_steps limit remaining_proof cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
452 |
in (s :: rp, rl, cx) end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
453 |
| (SKOLEM, p, l) => |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
454 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
455 |
val (s, cx) = parse_skolem p cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
456 |
val (rp, rl, cx) = parse_raw_proof_steps limit l cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
457 |
in (s :: rp, rl, cx) end |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
458 |
end |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
459 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
460 |
fun proof_ctxt_of_rule "bind" t = t |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
461 |
| proof_ctxt_of_rule "sko_forall" t = t |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
462 |
| proof_ctxt_of_rule "sko_ex" t = t |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
463 |
| proof_ctxt_of_rule "let" t = t |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
464 |
| proof_ctxt_of_rule "onepoint" t = t |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
465 |
| proof_ctxt_of_rule _ _ = [] |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
466 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
467 |
fun args_of_rule "bind" t = t |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
468 |
| args_of_rule "la_generic" t = t |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
469 |
| args_of_rule "lia_generic" t = t |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
470 |
| args_of_rule _ _ = [] |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
471 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
472 |
fun insts_of_forall_inst "forall_inst" t = map (fn SMTLIB.S [_, SMTLIB.Sym x, a] => (x, a)) t |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
473 |
| insts_of_forall_inst _ _ = [] |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
474 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
475 |
fun id_of_last_step prems = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
476 |
if null prems then [] |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
477 |
else |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
478 |
let val VeriT_Replay_Node {id, ...} = List.last prems in [id] end |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
479 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
480 |
fun extract_assumptions_from_subproof subproof = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
481 |
let fun extract_assumptions_from_subproof (VeriT_Replay_Node {rule, concl, ...}) assms = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
482 |
if rule = local_input_rule then concl :: assms else assms |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
483 |
in |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
484 |
fold extract_assumptions_from_subproof subproof [] |
57705 | 485 |
end |
486 |
||
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
487 |
fun normalized_rule_name id rule = |
75274
e89709b80b6e
used more descriptive assert names in SMT-Lib output
desharna
parents:
74817
diff
changeset
|
488 |
(case (rule = input_rule, can SMTLIB_Interface.role_and_index_of_assert_name id) of |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
489 |
(true, true) => normalized_input_rule |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
490 |
| (true, _) => local_input_rule |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
491 |
| _ => rule) |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
492 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
493 |
fun is_assm_repetition id rule = |
75274
e89709b80b6e
used more descriptive assert names in SMT-Lib output
desharna
parents:
74817
diff
changeset
|
494 |
rule = input_rule andalso can SMTLIB_Interface.role_and_index_of_assert_name id |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
495 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
496 |
fun extract_skolem ([SMTLIB.Sym var, typ, choice]) = (var, typ, choice) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
497 |
| extract_skolem t = raise Fail ("fail to parse type" ^ @{make_string} t) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
498 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
499 |
(* The preprocessing takes care of: |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
500 |
1. unfolding the shared terms |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
501 |
2. extract the declarations of skolems to make sure that there are not unfolded |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
502 |
*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
503 |
fun preprocess compress step = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
504 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
505 |
fun expand_assms cs = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
506 |
map (fn t => case AList.lookup (op =) cs t of NONE => t | SOME a => a) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
507 |
fun expand_lonely_arguments (args as SMTLIB.S [SMTLIB.Sym "=", _, _]) = [args] |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
508 |
| expand_lonely_arguments (x as SMTLIB.S [SMTLIB.Sym var, _]) = [SMTLIB.S [SMTLIB.Sym "=", x, SMTLIB.Sym var]] |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
509 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
510 |
fun preprocess (Raw_VeriT_Node {id, rule, args, prems, concl, subproof, ...}) (cx, remap_assms) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
511 |
let |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
512 |
val (skolem_names, stripped_args) = args |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
513 |
|> (fn SMTLIB.S args => args) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
514 |
|> map |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
515 |
(fn SMTLIB.S [SMTLIB.Key "=", x, y] => SMTLIB.S [SMTLIB.Sym "=", x, y] |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
516 |
| x => x) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
517 |
|> (rule = "bind" orelse rule = "onepoint") ? flat o (map expand_lonely_arguments) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
518 |
|> `(if rule = veriT_def then single o extract_skolem else K []) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
519 |
||> SMTLIB.S |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
520 |
val (subproof, (cx, _)) = fold_map preprocess subproof (cx, remap_assms) |> apfst flat |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
521 |
val remap_assms = (if rule = "or" then (id, hd prems) :: remap_assms else remap_assms) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
522 |
(* declare variables in the context *) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
523 |
val declarations = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
524 |
if rule = veriT_def |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
525 |
then skolem_names |> map (fn (name, _, choice) => (name, choice)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
526 |
else [] |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
527 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
528 |
if compress andalso rule = "or" |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
529 |
then ([], (cx, remap_assms)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
530 |
else ([Raw_VeriT_Node {id = id, rule = rule, args = stripped_args, |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
531 |
prems = expand_assms remap_assms prems, declarations = declarations, concl = concl, subproof = subproof}], |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
532 |
(cx, remap_assms)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
533 |
end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
534 |
in preprocess step end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
535 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
536 |
fun filter_split _ [] = ([], []) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
537 |
| filter_split f (a :: xs) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
538 |
(if f a then apfst (curry op :: a) else apsnd (curry op :: a)) (filter_split f xs) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
539 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
540 |
fun collect_skolem_defs (Raw_VeriT_Node {rule, subproof = subproof, args, ...}) = |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
541 |
(if is_skolemization rule then map (fn id => id ^ veriT_def) (skolems_introduced_by_rule args) else []) @ |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
542 |
flat (map collect_skolem_defs subproof) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
543 |
|
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
544 |
fun extract_types_of_args (SMTLIB.S [var, typ, t as SMTLIB.S [SMTLIB.Sym "choice", _, _]]) = |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
545 |
(SMTLIB.S [var, typ, t], SOME typ) |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
546 |
|> single |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
547 |
| extract_types_of_args (SMTLIB.S t) = |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
548 |
let |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
549 |
fun extract_types_of_arg (SMTLIB.S [eq, SMTLIB.S [var, typ], t]) = (SMTLIB.S [eq, var, t], SOME typ) |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
550 |
| extract_types_of_arg t = (t, NONE) |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
551 |
in |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
552 |
t |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
553 |
|> map extract_types_of_arg |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
554 |
end |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
555 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
556 |
(*The postprocessing does: |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
557 |
1. translate the terms to Isabelle syntax, taking care of free variables |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
558 |
2. remove the ambiguity in the proof terms: |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
559 |
x \<leadsto> y |- x = x |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
560 |
means y = x. To remove ambiguity, we use the fact that y is a free variable and replace the term |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
561 |
by: |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
562 |
xy \<leadsto> y |- xy = x. |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
563 |
This is now does not have an ambiguity and we can safely move the "xy \<leadsto> y" to the proof |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
564 |
assumptions. |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
565 |
*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
566 |
fun postprocess_proof compress ctxt step cx = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
567 |
let |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
568 |
fun postprocess (Raw_VeriT_Node {id, rule, args, prems, declarations, concl, subproof}) (cx, rew) = |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
569 |
let |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
570 |
val _ = (SMT_Config.verit_msg ctxt) (fn () => @{print} ("id =", id, "concl =", concl)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
571 |
|
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
572 |
val (args) = extract_types_of_args args |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
573 |
val globally_bound_vars = declared_csts cx rule args |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
574 |
val cx = fold (update_binding o (fn (s, typ) => (s, Term (Free (s, type_of cx typ))))) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
575 |
globally_bound_vars cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
576 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
577 |
(*find rebound variables specific to the LHS of the equivalence symbol*) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
578 |
val bound_vars = bound_vars_by_rule cx rule args |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
579 |
val bound_vars_no_typ = map fst bound_vars |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
580 |
val rhs_vars = |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
581 |
fold (fn [t', t] => t <> t' ? (curry (op ::) t) | _ => fn x => x) bound_vars_no_typ [] |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
582 |
fun not_already_bound cx t = SMTLIB_Proof.lookup_binding cx t = None andalso |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
583 |
not (member (op =) rhs_vars t) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
584 |
val (shadowing_vars, rebound_lhs_vars) = bound_vars |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
585 |
|> filter_split (fn ([t, _], typ) => not_already_bound cx t | _ => true) |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
586 |
|>> map (apfst (hd)) |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
587 |
|>> (fn vars => vars @ flat (map (fn ([_, t], typ) => [(t, typ)] | _ => []) bound_vars)) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
588 |
val subproof_rew = fold (fn [t, t'] => curry (op ::) (t, t ^ t')) |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
589 |
(map fst rebound_lhs_vars) rew |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
590 |
val subproof_rewriter = fold (fn (t, t') => synctatic_rew_in_lhs_subst t t') |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
591 |
subproof_rew |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
592 |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
593 |
val ((concl, bounds), cx') = node_of concl cx |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
594 |
|
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
595 |
val extra_lhs_vars = map (fn ([a,b], typ) => (a, a^b, typ)) rebound_lhs_vars |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
596 |
val old_lhs_vars = map (fn (a, _, typ) => (a, typ)) extra_lhs_vars |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
597 |
val new_lhs_vars = map (fn (_, newvar, typ) => (newvar, typ)) extra_lhs_vars |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
598 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
599 |
(* postprocess conclusion *) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
600 |
val concl = SMTLIB_Isar.unskolemize_names ctxt (subproof_rewriter concl) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
601 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
602 |
val _ = (SMT_Config.verit_msg ctxt) (fn () => \<^print> ("id =", id, "concl =", concl)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
603 |
val _ = (SMT_Config.verit_msg ctxt) (fn () => \<^print> ("id =", id, "cx' =", cx', |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
604 |
"bound_vars =", bound_vars)) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
605 |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
606 |
val bound_tvars = |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
607 |
map (fn (s, SOME typ) => (s, type_of cx typ)) |
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
608 |
(shadowing_vars @ new_lhs_vars) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
609 |
val subproof_cx = |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
610 |
add_bound_variables_to_ctxt cx (shadowing_vars @ new_lhs_vars) cx |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
611 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
612 |
fun could_unify (Bound i, Bound j) = i = j |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
613 |
| could_unify (Var v, Var v') = v = v' |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
614 |
| could_unify (Free v, Free v') = v = v' |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
615 |
| could_unify (Const (v, ty), Const (v', ty')) = v = v' andalso ty = ty' |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
616 |
| could_unify (Abs (_, ty, bdy), Abs (_, ty', bdy')) = ty = ty' andalso could_unify (bdy, bdy') |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
617 |
| could_unify (u $ v, u' $ v') = could_unify (u, u') andalso could_unify (v, v') |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
618 |
| could_unify _ = false |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
619 |
fun is_alpha_renaming t = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
620 |
t |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
621 |
|> HOLogic.dest_Trueprop |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
622 |
|> HOLogic.dest_eq |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
623 |
|> could_unify |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
624 |
handle TERM _ => false |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
625 |
val alpha_conversion = rule = "bind" andalso is_alpha_renaming concl |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
626 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
627 |
val can_remove_subproof = |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
628 |
compress andalso (is_skolemization rule orelse alpha_conversion) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
629 |
val (fixed_subproof : veriT_replay_node list, _) = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
630 |
fold_map postprocess (if can_remove_subproof then [] else subproof) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
631 |
(subproof_cx, subproof_rew) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
632 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
633 |
val unsk_and_rewrite = SMTLIB_Isar.unskolemize_names ctxt o subproof_rewriter |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
634 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
635 |
(* postprocess assms *) |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
636 |
val stripped_args = map fst args |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
637 |
val sanitized_args = proof_ctxt_of_rule rule stripped_args |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
638 |
|
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
639 |
val arg_cx = add_bound_variables_to_ctxt cx (shadowing_vars @ old_lhs_vars) subproof_cx |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
640 |
val (termified_args, _) = fold_map node_of sanitized_args arg_cx |> apfst (map fst) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
641 |
val normalized_args = map unsk_and_rewrite termified_args |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
642 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
643 |
val subproof_assms = proof_ctxt_of_rule rule normalized_args |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
644 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
645 |
(* postprocess arguments *) |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
646 |
val rule_args = args_of_rule rule stripped_args |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
647 |
val (termified_args, _) = fold_map term_of rule_args subproof_cx |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
648 |
val normalized_args = map unsk_and_rewrite termified_args |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
649 |
val rule_args = map subproof_rewriter normalized_args |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
650 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
651 |
val raw_insts = insts_of_forall_inst rule stripped_args |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
652 |
fun termify_term (x, t) cx = let val (t, cx) = term_of t cx in ((x, t), cx) end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
653 |
val (termified_args, _) = fold_map termify_term raw_insts subproof_cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
654 |
val insts = Symtab.empty |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
655 |
|> fold (fn (x, t) => fn insts => Symtab.update_new (x, t) insts) termified_args |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
656 |
|> Symtab.map (K unsk_and_rewrite) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
657 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
658 |
(* declarations *) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
659 |
val (declarations, _) = fold_map termify_term declarations cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
660 |
|> apfst (map (apsnd unsk_and_rewrite)) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
661 |
|
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
662 |
(* fix step *) |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
663 |
val _ = if bounds <> [] then raise (Fail "found dangling variable in concl") else () |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
664 |
val skolem_defs = (if is_skolemization rule |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
665 |
then map (fn id => id ^ veriT_def) (skolems_introduced_by_rule (SMTLIB.S (map fst args))) else []) |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
666 |
val skolems_of_subproof = (if is_skolemization rule |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
667 |
then flat (map collect_skolem_defs subproof) else []) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
668 |
val fixed_prems = |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
669 |
prems @ (if is_assm_repetition id rule then [id] else []) @ |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
670 |
skolem_defs @ skolems_of_subproof @ (id_of_last_step fixed_subproof) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
671 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
672 |
(* fix subproof *) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
673 |
val normalized_rule = normalized_rule_name id rule |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
674 |
|> (if compress andalso alpha_conversion then K "refl" else I) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
675 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
676 |
val extra_assms2 = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
677 |
(if rule = subproof_rule then extract_assumptions_from_subproof fixed_subproof else []) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
678 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
679 |
val step = mk_replay_node id normalized_rule rule_args fixed_prems subproof_assms concl |
74403
dbd69d287ec6
update syntax for verit
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
74382
diff
changeset
|
680 |
[] insts declarations (bound_tvars, subproof_assms, extra_assms2, fixed_subproof) |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
681 |
|
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
682 |
in |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
683 |
(step, (cx', rew)) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
684 |
end |
57705 | 685 |
in |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
686 |
postprocess step (cx, []) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
687 |
|> (fn (step, (cx, _)) => (step, cx)) |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
688 |
end |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
689 |
|
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
690 |
fun combine_proof_steps ((step1 : veriT_replay_node) :: step2 :: steps) = |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
691 |
let |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
692 |
val (VeriT_Replay_Node {id = id1, rule = rule1, args = args1, prems = prems1, |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
693 |
proof_ctxt = proof_ctxt1, concl = concl1, bounds = bounds1, insts = insts1, |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
694 |
declarations = declarations1, |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
695 |
subproof = (bound_sub1, assms_sub1, assms_extra1, subproof1)}) = step1 |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
696 |
val (VeriT_Replay_Node {id = id2, rule = rule2, args = args2, prems = prems2, |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
697 |
proof_ctxt = proof_ctxt2, concl = concl2, bounds = bounds2, insts = insts2, |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
698 |
declarations = declarations2, |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
699 |
subproof = (bound_sub2, assms_sub2, assms_extra2, subproof2)}) = step2 |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
700 |
val goals1 = |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
701 |
(case concl1 of |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
702 |
_ $ (Const (\<^const_name>\<open>HOL.disj\<close>, _) $ _ $ |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
703 |
(Const (\<^const_name>\<open>HOL.disj\<close>, _) $ (Const (\<^const_name>\<open>HOL.Not\<close>, _) $a) $ b)) => [a,b] |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
704 |
| _ => []) |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
705 |
val goal2 = (case concl2 of _ $ a => a) |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
706 |
in |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
707 |
if rule1 = equiv_pos2_rule andalso rule2 = th_resolution_rule andalso member (op =) prems2 id1 |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
708 |
andalso member (op =) goals1 goal2 |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
709 |
then |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
710 |
mk_replay_node id2 theory_resolution2_rule args2 (filter_out (curry (op =) id1) prems2) |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
711 |
proof_ctxt2 concl2 bounds2 insts2 declarations2 |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
712 |
(bound_sub2, assms_sub2, assms_extra2, combine_proof_steps subproof2) :: |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
713 |
combine_proof_steps steps |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
714 |
else |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
715 |
mk_replay_node id1 rule1 args1 prems1 |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
716 |
proof_ctxt1 concl1 bounds1 insts1 declarations1 |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
717 |
(bound_sub1, assms_sub1, assms_extra1, combine_proof_steps subproof1) :: |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
718 |
combine_proof_steps (step2 :: steps) |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
719 |
end |
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
720 |
| combine_proof_steps steps = steps |
57704 | 721 |
|
57705 | 722 |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
723 |
val linearize_proof = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
724 |
let |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
725 |
fun map_node_concl f (VeriT_Node {id, rule, prems, proof_ctxt, concl}) = |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
726 |
mk_node id rule prems proof_ctxt (f concl) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
727 |
fun linearize (VeriT_Replay_Node {id = id, rule = rule, args = _, prems = prems, |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
728 |
proof_ctxt = proof_ctxt, concl = concl, bounds = bounds, insts = _, declarations = _, |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
729 |
subproof = (bounds', assms, inputs, subproof)}) = |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
730 |
let |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
731 |
val bounds = distinct (op =) bounds |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
732 |
val bounds' = distinct (op =) bounds' |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
733 |
fun mk_prop_of_term concl = |
69593 | 734 |
concl |> fastype_of concl = \<^typ>\<open>bool\<close> ? curry (op $) \<^term>\<open>Trueprop\<close> |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
735 |
fun remove_assumption_id assumption_id prems = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
736 |
filter_out (curry (op =) assumption_id) prems |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
737 |
fun add_assumption assumption concl = |
74382 | 738 |
\<^Const>\<open>Pure.imp for \<open>mk_prop_of_term assumption\<close> \<open>mk_prop_of_term concl\<close>\<close> |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
739 |
fun inline_assumption assumption assumption_id |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
740 |
(VeriT_Node {id, rule, prems, proof_ctxt, concl}) = |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
741 |
mk_node id rule (remove_assumption_id assumption_id prems) proof_ctxt |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
742 |
(add_assumption assumption concl) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
743 |
fun find_input_steps_and_inline [] = [] |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
744 |
| find_input_steps_and_inline |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
745 |
(VeriT_Node {id = id', rule, prems, concl, ...} :: steps) = |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
746 |
if rule = input_rule then |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
747 |
find_input_steps_and_inline (map (inline_assumption concl id') steps) |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
748 |
else |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
749 |
mk_node (id') rule prems [] concl :: find_input_steps_and_inline steps |
57708
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
750 |
|
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
751 |
fun free_bounds bounds (concl) = |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
752 |
fold (fn (var, typ) => fn t => Logic.all (Free (var, typ)) t) bounds concl |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
753 |
val subproof = subproof |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
754 |
|> flat o map linearize |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
755 |
|> map (map_node_concl (fold add_assumption (assms @ inputs))) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
756 |
|> map (map_node_concl (free_bounds (bounds @ bounds'))) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
757 |
|> find_input_steps_and_inline |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
758 |
val concl = free_bounds bounds concl |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
759 |
in |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
760 |
subproof @ [mk_node id rule prems proof_ctxt concl] |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
761 |
end |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
762 |
in linearize end |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
763 |
|
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
764 |
fun rule_of (VeriT_Replay_Node {rule,...}) = rule |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
765 |
fun subproof_of (VeriT_Replay_Node {subproof = (_, _, _, subproof),...}) = subproof |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
766 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
767 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
768 |
(* Massage Skolems for Sledgehammer. |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
769 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
770 |
We have to make sure that there is an "arrow" in the graph for skolemization steps. |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
771 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
772 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
773 |
A. The normal easy case |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
774 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
775 |
This function detects the steps of the form |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
776 |
P \<longleftrightarrow> Q :skolemization |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
777 |
Q :resolution with P |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
778 |
and replace them by |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
779 |
Q :skolemization |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
780 |
Throwing away the step "P \<longleftrightarrow> Q" completely. This throws away a lot of information, but it does not |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
781 |
matter too much for Sledgehammer. |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
782 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
783 |
|
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
784 |
B. Skolems in subproofs |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
785 |
Supporting this is more or less hopeless as long as the Isar reconstruction of Sledgehammer |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
786 |
does not support more features like definitions. veriT is able to generate proofs with skolemization |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
787 |
happening in subproofs inside the formula. |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
788 |
(assume "A \<or> P" |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
789 |
... |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
790 |
P \<longleftrightarrow> Q :skolemization in the subproof |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
791 |
...) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
792 |
hence A \<or> P \<longrightarrow> A \<or> Q :lemma |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
793 |
... |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
794 |
R :something with some rule |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
795 |
and replace them by |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
796 |
R :skolemization with some rule |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
797 |
Without any subproof |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
798 |
*) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
799 |
fun remove_skolem_definitions_proof steps = |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
800 |
let |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
801 |
fun replace_equivalent_by_imp (judgement $ ((Const(\<^const_name>\<open>HOL.eq\<close>, typ) $ arg1) $ arg2)) = |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
802 |
judgement $ ((Const(\<^const_name>\<open>HOL.implies\<close>, typ) $ arg1) $ arg2) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
803 |
| replace_equivalent_by_imp a = a (*This case is probably wrong*) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
804 |
fun remove_skolem_definitions (VeriT_Replay_Node {id = id, rule = rule, args = args, |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
805 |
prems = prems, |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
806 |
proof_ctxt = proof_ctxt, concl = concl, bounds = bounds, insts = insts, |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
807 |
declarations = declarations, |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
808 |
subproof = (vars, assms', extra_assms', subproof)}) (prems_to_remove, skolems) = |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
809 |
let |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
810 |
val prems = prems |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
811 |
|> filter_out (member (op =) prems_to_remove) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
812 |
val trivial_step = is_SH_trivial rule |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
813 |
fun has_skolem_substep st NONE = if is_skolemization (rule_of st) then SOME (rule_of st) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
814 |
else fold has_skolem_substep (subproof_of st) NONE |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
815 |
| has_skolem_substep _ a = a |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
816 |
val promote_to_skolem = exists (fn t => member (op =) skolems t) prems |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
817 |
val promote_from_assms = fold has_skolem_substep subproof NONE <> NONE |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
818 |
val promote_step = promote_to_skolem orelse promote_from_assms |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
819 |
val skolem_step_to_skip = is_skolemization rule orelse |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
820 |
(promote_from_assms andalso length prems > 1) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
821 |
val is_skolem = is_skolemization rule orelse promote_step |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
822 |
val prems = prems |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
823 |
|> filter_out (fn t => member (op =) skolems t) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
824 |
|> is_skolem ? filter_out (String.isPrefix id) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
825 |
val rule = (if promote_step then default_skolem_rule else rule) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
826 |
val subproof = subproof |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
827 |
|> (is_skolem ? K []) (*subproofs of skolemization steps are useless for SH*) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
828 |
|> map (fst o (fn st => remove_skolem_definitions st (prems_to_remove, skolems))) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
829 |
(*no new definitions in subproofs*) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
830 |
|> flat |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
831 |
val concl = concl |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
832 |
|> is_skolem ? replace_equivalent_by_imp |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
833 |
val step = (if skolem_step_to_skip orelse rule = veriT_def orelse trivial_step then [] |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
834 |
else mk_replay_node id rule args prems proof_ctxt concl bounds insts declarations |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
835 |
(vars, assms', extra_assms', subproof) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
836 |
|> single) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
837 |
val defs = (if rule = veriT_def orelse trivial_step then id :: prems_to_remove |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
838 |
else prems_to_remove) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
839 |
val skolems = (if skolem_step_to_skip then id :: skolems else skolems) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
840 |
in |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
841 |
(step, (defs, skolems)) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
842 |
end |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
843 |
in |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
844 |
fold_map remove_skolem_definitions steps ([], []) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
845 |
|> fst |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
846 |
|> flat |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
847 |
end |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
848 |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
849 |
local |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
850 |
fun import_proof_and_post_process typs funs lines ctxt = |
57708
4b52c1b319ce
veriT changes for lifted terms, and ite_elim rules.
fleury
parents:
57705
diff
changeset
|
851 |
let |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
852 |
val compress = SMT_Config.compress_verit_proofs ctxt |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
853 |
val smtlib_lines_without_qm = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
854 |
lines |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
855 |
|> map single |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
856 |
|> map SMTLIB.parse |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
857 |
|> map remove_all_qm2 |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
858 |
val (raw_steps, _, _) = |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
859 |
parse_raw_proof_steps NONE smtlib_lines_without_qm SMTLIB_Proof.empty_name_binding |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
860 |
|
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
861 |
fun process step (cx, cx') = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
862 |
let fun postprocess step (cx, cx') = |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
863 |
let val (step, cx) = postprocess_proof compress ctxt step cx |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
864 |
in (step, (cx, cx')) end |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
865 |
in uncurry (fold_map postprocess) (preprocess compress step (cx, cx')) end |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
866 |
val step = |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
867 |
(empty_context ctxt typs funs, []) |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
868 |
|> fold_map process raw_steps |
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
869 |
|> (fn (steps, (cx, _)) => (flat steps, cx)) |
72908
6a26a955308e
improve and activate compression for veriT proof reconstruction
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72513
diff
changeset
|
870 |
|> compress? apfst combine_proof_steps |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
871 |
in step end |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
872 |
in |
57704 | 873 |
|
874 |
fun parse typs funs lines ctxt = |
|
875 |
let |
|
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
876 |
val (u, env) = import_proof_and_post_process typs funs lines ctxt |
72513
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
877 |
val t = u |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
878 |
|> remove_skolem_definitions_proof |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
879 |
|> flat o (map linearize_proof) |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
880 |
fun node_to_step (VeriT_Node {id, rule, prems, concl, ...}) = |
75f5c63f6cfa
better handling of skolemization for Isar reconstruction in Sledgehammer for veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
72458
diff
changeset
|
881 |
mk_step id rule prems [] concl [] |
58490 | 882 |
in |
57705 | 883 |
(map node_to_step t, ctxt_of env) |
57704 | 884 |
end |
885 |
||
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
886 |
fun parse_replay typs funs lines ctxt = |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
887 |
let |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
888 |
val (u, env) = import_proof_and_post_process typs funs lines ctxt |
72458
b44e894796d5
add reconstruction for the SMT solver veriT
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
69597
diff
changeset
|
889 |
val _ = (SMT_Config.verit_msg ctxt) (fn () => \<^print> u) |
69205
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
890 |
in |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
891 |
(u, ctxt_of env) |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
892 |
end |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
893 |
end |
8050734eee3e
add reconstruction by veriT in method smt
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
61611
diff
changeset
|
894 |
|
57704 | 895 |
end; |