476 |
476 |
477 (**** extract program ****) |
477 (**** extract program ****) |
478 |
478 |
479 val dummyt = Const ("dummy", dummyT); |
479 val dummyt = Const ("dummy", dummyT); |
480 |
480 |
481 fun extract thms thy = |
481 fun extract thm_vss thy = |
482 let |
482 let |
483 val thy' = add_syntax thy; |
483 val thy' = add_syntax thy; |
484 val {realizes_eqns, typeof_eqns, types, realizers, defs, expand, prep} = |
484 val {realizes_eqns, typeof_eqns, types, realizers, defs, expand, prep} = |
485 ExtractionData.get thy; |
485 ExtractionData.get thy; |
486 val procs = maps (rev o fst o snd) types; |
486 val procs = maps (rev o fst o snd) types; |
767 (Reconstruct.prop_of (Proofterm.proof_combt (prf0, ts))))) |
767 (Reconstruct.prop_of (Proofterm.proof_combt (prf0, ts))))) |
768 end |
768 end |
769 |
769 |
770 | extr d vs ts Ts hs _ defs = error "extr: bad proof"; |
770 | extr d vs ts Ts hs _ defs = error "extr: bad proof"; |
771 |
771 |
772 fun prep_thm (thm, vs) = |
772 fun prep_thm vs thm = |
773 let |
773 let |
774 val thy = Thm.theory_of_thm thm; |
774 val thy = Thm.theory_of_thm thm; |
775 val prop = Thm.prop_of thm; |
775 val prop = Thm.prop_of thm; |
776 val prf = Thm.proof_of thm; |
776 val prf = Thm.proof_of thm; |
777 val name = Thm.derivation_name thm; |
777 val name = Thm.derivation_name thm; |
778 val _ = name <> "" orelse error "extraction: unnamed theorem"; |
778 val _ = name <> "" orelse error "extraction: unnamed theorem"; |
779 val _ = etype_of thy' vs [] prop <> nullT orelse error ("theorem " ^ |
779 val _ = etype_of thy' vs [] prop <> nullT orelse error ("theorem " ^ |
780 quote name ^ " has no computational content") |
780 quote name ^ " has no computational content") |
781 in (Reconstruct.reconstruct_proof thy prop prf, vs) end; |
781 in Reconstruct.reconstruct_proof thy prop prf end; |
782 |
782 |
783 val defs = |
783 val defs = |
784 fold (fn (prf, vs) => snd o extr 0 vs [] [] [] prf) |
784 fold (fn (thm, vs) => snd o (extr 0 vs [] [] [] o prep_thm vs) thm) |
785 (map prep_thm thms) []; |
785 thm_vss []; |
786 |
786 |
787 fun add_def (s, (vs, ((t, u), (prf, _)))) thy = |
787 fun add_def (s, (vs, ((t, u), (prf, _)))) thy = |
788 (case Sign.const_type thy (extr_name s vs) of |
788 (case Sign.const_type thy (extr_name s vs) of |
789 NONE => |
789 NONE => |
790 let |
790 let |