34 include BASIC_PROOFTERM |
34 include BASIC_PROOFTERM |
35 val proofs: int Unsynchronized.ref |
35 val proofs: int Unsynchronized.ref |
36 type pthm = serial * thm_node |
36 type pthm = serial * thm_node |
37 type oracle = string * term |
37 type oracle = string * term |
38 val proof_of: proof_body -> proof |
38 val proof_of: proof_body -> proof |
|
39 val map_proof_of: (proof -> proof) -> proof_body -> proof_body |
39 val thm_node_name: thm_node -> string |
40 val thm_node_name: thm_node -> string |
40 val thm_node_prop: thm_node -> term |
41 val thm_node_prop: thm_node -> term |
41 val thm_node_body: thm_node -> proof_body future |
42 val thm_node_body: thm_node -> proof_body future |
42 val join_proof: proof_body future -> proof |
43 val join_proof: proof_body future -> proof |
43 val fold_proof_atoms: bool -> (proof -> 'a -> 'a) -> proof list -> 'a -> 'a |
44 val fold_proof_atoms: bool -> (proof -> 'a -> 'a) -> proof list -> 'a -> 'a |
187 type oracle = string * term; |
188 type oracle = string * term; |
188 type pthm = serial * thm_node; |
189 type pthm = serial * thm_node; |
189 |
190 |
190 fun proof_of (PBody {proof, ...}) = proof; |
191 fun proof_of (PBody {proof, ...}) = proof; |
191 val join_proof = Future.join #> proof_of; |
192 val join_proof = Future.join #> proof_of; |
|
193 |
|
194 fun map_proof_of f (PBody {oracles, thms, proof}) = |
|
195 PBody {oracles = oracles, thms = thms, proof = f proof}; |
192 |
196 |
193 fun rep_thm_node (Thm_Node args) = args; |
197 fun rep_thm_node (Thm_Node args) = args; |
194 val thm_node_name = #name o rep_thm_node; |
198 val thm_node_name = #name o rep_thm_node; |
195 val thm_node_prop = #prop o rep_thm_node; |
199 val thm_node_prop = #prop o rep_thm_node; |
196 val thm_node_body = #body o rep_thm_node; |
200 val thm_node_body = #body o rep_thm_node; |
1305 union (op =) (if b then map (fst o dest_Var) (vars_of t) else []) (needed u ts prfs) |
1309 union (op =) (if b then map (fst o dest_Var) (vars_of t) else []) (needed u ts prfs) |
1306 | needed (Var (ixn, _)) (_::_) _ = [ixn] |
1310 | needed (Var (ixn, _)) (_::_) _ = [ixn] |
1307 | needed _ _ _ = []; |
1311 | needed _ _ _ = []; |
1308 in fn prf => #4 (shrink [] 0 prf) end; |
1312 in fn prf => #4 (shrink [] 0 prf) end; |
1309 |
1313 |
1310 fun shrink_proof_body (PBody {oracles, thms, proof}) = |
|
1311 PBody {oracles = oracles, thms = thms, proof = shrink_proof proof}; |
|
1312 |
|
1313 |
1314 |
1314 (**** Simple first order matching functions for terms and proofs ****) |
1315 (**** Simple first order matching functions for terms and proofs ****) |
1315 |
1316 |
1316 exception PMatch; |
1317 exception PMatch; |
1317 |
1318 |
1669 val body0 = |
1670 val body0 = |
1670 if not (proofs_enabled ()) then Future.value (make_body0 MinProof) |
1671 if not (proofs_enabled ()) then Future.value (make_body0 MinProof) |
1671 else |
1672 else |
1672 let |
1673 let |
1673 val rew = rew_proof thy; |
1674 val rew = rew_proof thy; |
1674 val prf' = fold_rev implies_intr_proof hyps prf; |
1675 val prf0 = fold_rev implies_intr_proof hyps prf; |
1675 in |
1676 in |
1676 (singleton o Future.cond_forks) |
1677 (singleton o Future.cond_forks) |
1677 {name = "Proofterm.prepare_thm_proof", group = NONE, |
1678 {name = "Proofterm.prepare_thm_proof", group = NONE, |
1678 deps = [], pri = 1, interrupts = true} |
1679 deps = [], pri = 1, interrupts = true} |
1679 (fn () => make_body0 (rew prf')) |
1680 (fn () => make_body0 (rew prf0)) |
1680 end; |
1681 end; |
1681 |
1682 |
1682 val postproc = |
|
1683 unconstrainT_body thy (atyp_map, constraints) #> shrink_proof_body; |
|
1684 |
|
1685 fun new_prf () = |
1683 fun new_prf () = |
1686 (serial (), fulfill_proof_future thy promises postproc body0); |
1684 let |
|
1685 val i = serial (); |
|
1686 fun export prf1 = |
|
1687 (if Options.default_bool "export_proofs" then |
|
1688 Export.export thy (Path.binding0 (Path.make ["proofs", string_of_int i])) |
|
1689 (Buffer.chunks |
|
1690 (YXML.buffer_body (Term_XML.Encode.term (term_of_proof prf1)) Buffer.empty)) |
|
1691 else (); |
|
1692 if Options.default_bool "prune_proofs" then MinProof else prf1); |
|
1693 val postproc = |
|
1694 unconstrainT_body thy (atyp_map, constraints) #> |
|
1695 map_proof_of (export #> shrink_proof); |
|
1696 in (i, fulfill_proof_future thy promises postproc body0) end; |
|
1697 |
1687 val (i, body') = |
1698 val (i, body') = |
1688 (*non-deterministic, depends on unknown promises*) |
1699 (*non-deterministic, depends on unknown promises*) |
1689 (case strip_combt (fst (strip_combP prf)) of |
1700 (case strip_combt (fst (strip_combP prf)) of |
1690 (PThm (i, ((old_name, prop', NONE), body')), args') => |
1701 (PThm (i, ((old_name, prop', NONE), body')), args') => |
1691 if (old_name = "" orelse old_name = name) andalso prop1 = prop' andalso args = args' |
1702 if (old_name = "" orelse old_name = name) andalso prop1 = prop' andalso args = args' |