104 let |
104 let |
105 val ct = Thm.cprem_of thm 1 |
105 val ct = Thm.cprem_of thm 1 |
106 val (thm', ctxt') = yield_singleton Assumption.add_assumes ct ctxt |
106 val (thm', ctxt') = yield_singleton Assumption.add_assumes ct ctxt |
107 in (thm' RS thm, ctxt') end |
107 in (thm' RS thm, ctxt') end |
108 |
108 |
109 fun add1 id fixes thm1 ((i, th), exact) ((idis, thms), (ctxt, ptab)) = |
109 fun add1 id fixes thm1 ((i, th), exact) ((iidths, thms), (ctxt, ptab)) = |
110 let |
110 let |
111 val (thm, ctxt') = if exact then (Thm.implies_elim thm1 th, ctxt) else assume thm1 ctxt |
111 val (thm, ctxt') = if exact then (Thm.implies_elim thm1 th, ctxt) else assume thm1 ctxt |
112 val thms' = if exact then thms else th :: thms |
112 val thms' = if exact then thms else th :: thms |
113 in (((id, i) :: idis, thms'), (ctxt', Inttab.update (id, (fixes, thm)) ptab)) end |
113 in (((i, (id, th)) :: iidths, thms'), (ctxt', Inttab.update (id, (fixes, thm)) ptab)) end |
114 |
114 |
115 fun add (Z3_New_Proof.Z3_Step {id, rule, concl, fixes, ...}) |
115 fun add (Z3_New_Proof.Z3_Step {id, rule, concl, fixes, ...}) |
116 (cx as ((idis, thms), (ctxt, ptab))) = |
116 (cx as ((iidths, thms), (ctxt, ptab))) = |
117 if Z3_New_Replay_Methods.is_assumption rule andalso rule <> Z3_New_Proof.Hypothesis then |
117 if Z3_New_Replay_Methods.is_assumption rule andalso rule <> Z3_New_Proof.Hypothesis then |
118 let |
118 let |
119 val ct = SMT2_Util.certify ctxt concl |
119 val ct = SMT2_Util.certify ctxt concl |
120 val thm1 = Thm.trivial ct |> Conv.fconv_rule (Conv.arg1_conv (revert_conv outer_ctxt)) |
120 val thm1 = Thm.trivial ct |> Conv.fconv_rule (Conv.arg1_conv (revert_conv outer_ctxt)) |
121 val thm2 = singleton (Variable.export ctxt outer_ctxt) thm1 |
121 val thm2 = singleton (Variable.export ctxt outer_ctxt) thm1 |
122 in |
122 in |
123 (case lookup_assm assms_net (Thm.cprem_of thm2 1) of |
123 (case lookup_assm assms_net (Thm.cprem_of thm2 1) of |
124 [] => |
124 [] => |
125 let val (thm, ctxt') = assume thm1 ctxt |
125 let val (thm, ctxt') = assume thm1 ctxt |
126 in ((idis, thms), (ctxt', Inttab.update (id, (fixes, thm)) ptab)) end |
126 in ((iidths, thms), (ctxt', Inttab.update (id, (fixes, thm)) ptab)) end |
127 | ithms => fold (add1 id fixes thm1) ithms cx) |
127 | ithms => fold (add1 id fixes thm1) ithms cx) |
128 end |
128 end |
129 else |
129 else |
130 cx |
130 cx |
131 in fold add steps (([], []), (ctxt, Inttab.empty)) end |
131 in fold add steps (([], []), (ctxt, Inttab.empty)) end |
174 |
174 |
175 fun replay outer_ctxt |
175 fun replay outer_ctxt |
176 ({context=ctxt, typs, terms, rewrite_rules, assms} : SMT2_Translate.replay_data) output = |
176 ({context=ctxt, typs, terms, rewrite_rules, assms} : SMT2_Translate.replay_data) output = |
177 let |
177 let |
178 val (steps, ctxt2) = Z3_New_Proof.parse typs terms output ctxt |
178 val (steps, ctxt2) = Z3_New_Proof.parse typs terms output ctxt |
179 val ((idis, rules), (ctxt3, assumed)) = add_asserted outer_ctxt rewrite_rules assms steps ctxt2 |
179 val ((iidths, rules), (ctxt3, assumed)) = add_asserted outer_ctxt rewrite_rules assms steps ctxt2 |
180 in |
180 in |
181 if Config.get ctxt3 SMT2_Config.filter_only_facts then |
181 if Config.get ctxt3 SMT2_Config.filter_only_facts then |
182 ((idis, steps), TrueI) |
182 ((iidths, steps), TrueI) |
183 else |
183 else |
184 let |
184 let |
185 val ctxt4 = put_simpset (Z3_New_Replay_Util.make_simpset ctxt3 []) ctxt3 |
185 val ctxt4 = put_simpset (Z3_New_Replay_Util.make_simpset ctxt3 []) ctxt3 |
186 val proofs = fold (replay_step ctxt4 assumed) steps assumed |
186 val proofs = fold (replay_step ctxt4 assumed) steps assumed |
187 val (_, Z3_New_Proof.Z3_Step {id, ...}) = split_last steps |
187 val (_, Z3_New_Proof.Z3_Step {id, ...}) = split_last steps |