132 |
132 |
133 val promise_proof: theory -> serial -> term -> proof |
133 val promise_proof: theory -> serial -> term -> proof |
134 val fulfill_norm_proof: theory -> (serial * proof_body) list -> proof_body -> proof_body |
134 val fulfill_norm_proof: theory -> (serial * proof_body) list -> proof_body -> proof_body |
135 val unconstrain_thm_proofs: bool Unsynchronized.ref |
135 val unconstrain_thm_proofs: bool Unsynchronized.ref |
136 val thm_proof: theory -> string -> sort list -> term list -> term -> |
136 val thm_proof: theory -> string -> sort list -> term list -> term -> |
|
137 (serial * proof_body future) list -> proof_body -> pthm * proof |
|
138 val unconstrain_thm_proof: theory -> sort list -> term -> |
137 (serial * proof_body future) list -> proof_body -> pthm * proof |
139 (serial * proof_body future) list -> proof_body -> pthm * proof |
138 val get_name: term list -> term -> proof -> string |
140 val get_name: term list -> term -> proof -> string |
139 val get_name_unconstrained: sort list -> term list -> term -> proof -> string |
141 val get_name_unconstrained: sort list -> term list -> term -> proof -> string |
140 val guess_name: proof -> string |
142 val guess_name: proof -> string |
141 end |
143 end |
1398 #> fold_rev (implies_intr_proof o snd) constraints |
1400 #> fold_rev (implies_intr_proof o snd) constraints |
1399 end; |
1401 end; |
1400 |
1402 |
1401 fun unconstrainT_body thy constrs (PBody {oracles, thms, proof}) = |
1403 fun unconstrainT_body thy constrs (PBody {oracles, thms, proof}) = |
1402 PBody |
1404 PBody |
1403 {oracles = oracles, (* FIXME unconstrain (!?!) *) |
1405 {oracles = oracles, (* FIXME merge (!), unconstrain (!?!) *) |
1404 thms = thms, |
1406 thms = thms, (* FIXME merge (!) *) |
1405 proof = unconstrainT_prf thy constrs proof}; |
1407 proof = unconstrainT_prf thy constrs proof}; |
1406 |
1408 |
1407 |
1409 |
1408 (***** theorems *****) |
1410 (***** theorems *****) |
1409 |
1411 |
1410 val unconstrain_thm_proofs = Unsynchronized.ref false; |
1412 fun prepare_thm_proof do_unconstrain thy name shyps hyps concl promises body = |
1411 |
|
1412 fun thm_proof thy name shyps hyps concl promises body = |
|
1413 let |
1413 let |
1414 val PBody {oracles = oracles0, thms = thms0, proof = prf} = body; |
1414 val PBody {oracles = oracles0, thms = thms0, proof = prf} = body; |
1415 val prop = Logic.list_implies (hyps, concl); |
1415 val prop = Logic.list_implies (hyps, concl); |
1416 val nvs = needed_vars prop; |
1416 val nvs = needed_vars prop; |
1417 val args = map (fn (v as Var (ixn, _)) => |
1417 val args = map (fn (v as Var (ixn, _)) => |
1418 if member (op =) nvs ixn then SOME v else NONE) (vars_of prop) @ |
1418 if member (op =) nvs ixn then SOME v else NONE) (vars_of prop) @ |
1419 map SOME (frees_of prop); |
1419 map SOME (frees_of prop); |
1420 |
1420 |
1421 val (postproc, ofclasses, prop1) = |
1421 val (postproc, ofclasses, prop1, args1) = |
1422 if ! unconstrain_thm_proofs then |
1422 if do_unconstrain then |
1423 let |
1423 let |
1424 val ((atyp_map, constraints), prop1) = Logic.unconstrainT shyps prop; |
1424 val ((atyp_map, constraints), prop1) = Logic.unconstrainT shyps prop; |
1425 val postproc = unconstrainT_body thy (atyp_map, constraints); |
1425 val postproc = unconstrainT_body thy (atyp_map, constraints); |
1426 in (postproc, map (OfClass o fst) constraints, prop1) end |
1426 val args1 = |
1427 else (I, [], prop); |
1427 (map o Option.map o Term.map_types o Term.map_atyps) |
|
1428 (Type.strip_sorts o atyp_map) args; |
|
1429 in (postproc, map (OfClass o fst) constraints, prop1, args1) end |
|
1430 else (I, [], prop, args); |
1428 val argsP = ofclasses @ map Hyp hyps; |
1431 val argsP = ofclasses @ map Hyp hyps; |
1429 |
1432 |
1430 val proof0 = |
1433 val proof0 = |
1431 if ! proofs = 2 then |
1434 if ! proofs = 2 then |
1432 #4 (shrink_proof [] 0 (rew_proof thy (fold_rev implies_intr_proof hyps prf))) |
1435 #4 (shrink_proof [] 0 (rew_proof thy (fold_rev implies_intr_proof hyps prf))) |
1440 if (old_name = "" orelse old_name = name) andalso prop1 = prop' andalso args = args' |
1443 if (old_name = "" orelse old_name = name) andalso prop1 = prop' andalso args = args' |
1441 then (i, body') |
1444 then (i, body') |
1442 else new_prf () |
1445 else new_prf () |
1443 | _ => new_prf ()); |
1446 | _ => new_prf ()); |
1444 val head = PThm (i, ((name, prop1, NONE), body')); |
1447 val head = PThm (i, ((name, prop1, NONE), body')); |
1445 in |
1448 in ((i, (name, prop1, body')), head, args, argsP, args1) end; |
1446 ((i, (name, prop1, body')), proof_combP (proof_combt' (head, args), argsP)) |
1449 |
1447 end; |
1450 val unconstrain_thm_proofs = Unsynchronized.ref false; |
|
1451 |
|
1452 fun thm_proof thy name shyps hyps concl promises body = |
|
1453 let val (pthm, head, args, argsP, _) = |
|
1454 prepare_thm_proof (! unconstrain_thm_proofs) thy name shyps hyps concl promises body |
|
1455 in (pthm, proof_combP (proof_combt' (head, args), argsP)) end; |
|
1456 |
|
1457 fun unconstrain_thm_proof thy shyps concl promises body = |
|
1458 let |
|
1459 val (pthm, head, _, _, args) = |
|
1460 prepare_thm_proof true thy "" shyps [] concl promises body |
|
1461 in (pthm, proof_combt' (head, args)) end; |
|
1462 |
1448 |
1463 |
1449 fun get_name hyps prop prf = |
1464 fun get_name hyps prop prf = |
1450 let val prop = Logic.list_implies (hyps, prop) in |
1465 let val prop = Logic.list_implies (hyps, prop) in |
1451 (case strip_combt (fst (strip_combP prf)) of |
1466 (case strip_combt (fst (strip_combP prf)) of |
1452 (PThm (_, ((name, prop', _), _)), _) => if prop = prop' then name else "" |
1467 (PThm (_, ((name, prop', _), _)), _) => if prop = prop' then name else "" |