110 val env' = Envir.Envir |
110 val env' = Envir.Envir |
111 {maxidx = Library.foldl Int.max |
111 {maxidx = Library.foldl Int.max |
112 (~1, map (Int.max o pairself maxidx_of_term) prems'), |
112 (~1, map (Int.max o pairself maxidx_of_term) prems'), |
113 iTs = Tenv, asol = tenv}; |
113 iTs = Tenv, asol = tenv}; |
114 val env'' = Library.foldl (fn (env, p) => |
114 val env'' = Library.foldl (fn (env, p) => |
115 Pattern.unify (sign, env, [pairself (lookup rew) p])) (env', prems') |
115 Pattern.unify (thy, env, [pairself (lookup rew) p])) (env', prems') |
116 in SOME (Envir.norm_term env'' (inc (ren tm2))) |
116 in SOME (Envir.norm_term env'' (inc (ren tm2))) |
117 end handle Pattern.MATCH => NONE | Pattern.Unif => NONE) |
117 end handle Pattern.MATCH => NONE | Pattern.Unif => NONE) |
118 (sort (Int.compare o pairself fst) |
118 (sort (Int.compare o pairself fst) |
119 (Net.match_term rules (Pattern.eta_contract tm))) |
119 (Net.match_term rules (Pattern.eta_contract tm))) |
120 end; |
120 end; |
176 |
176 |
177 (**** theory data ****) |
177 (**** theory data ****) |
178 |
178 |
179 (* data kind 'Pure/extraction' *) |
179 (* data kind 'Pure/extraction' *) |
180 |
180 |
181 structure ExtractionArgs = |
181 structure ExtractionData = TheoryDataFun |
182 struct |
182 (struct |
183 val name = "Pure/extraction"; |
183 val name = "Pure/extraction"; |
184 type T = |
184 type T = |
185 {realizes_eqns : rules, |
185 {realizes_eqns : rules, |
186 typeof_eqns : rules, |
186 typeof_eqns : rules, |
187 types : (string * ((term -> term option) list * |
187 types : (string * ((term -> term option) list * |
188 (term -> typ -> term -> typ -> term) option)) list, |
188 (term -> typ -> term -> typ -> term) option)) list, |
189 realizers : (string list * (term * proof)) list Symtab.table, |
189 realizers : (string list * (term * proof)) list Symtab.table, |
190 defs : thm list, |
190 defs : thm list, |
191 expand : (string * term) list, |
191 expand : (string * term) list, |
192 prep : (Sign.sg -> proof -> proof) option} |
192 prep : (theory -> proof -> proof) option} |
193 |
193 |
194 val empty = |
194 val empty = |
195 {realizes_eqns = empty_rules, |
195 {realizes_eqns = empty_rules, |
196 typeof_eqns = empty_rules, |
196 typeof_eqns = empty_rules, |
197 types = [], |
197 types = [], |
198 realizers = Symtab.empty, |
198 realizers = Symtab.empty, |
199 defs = [], |
199 defs = [], |
200 expand = [], |
200 expand = [], |
201 prep = NONE}; |
201 prep = NONE}; |
202 val copy = I; |
202 val copy = I; |
203 val prep_ext = I; |
203 val extend = I; |
204 |
204 |
205 fun merge |
205 fun merge _ |
206 (({realizes_eqns = realizes_eqns1, typeof_eqns = typeof_eqns1, types = types1, |
206 (({realizes_eqns = realizes_eqns1, typeof_eqns = typeof_eqns1, types = types1, |
207 realizers = realizers1, defs = defs1, expand = expand1, prep = prep1}, |
207 realizers = realizers1, defs = defs1, expand = expand1, prep = prep1}, |
208 {realizes_eqns = realizes_eqns2, typeof_eqns = typeof_eqns2, types = types2, |
208 {realizes_eqns = realizes_eqns2, typeof_eqns = typeof_eqns2, types = types2, |
209 realizers = realizers2, defs = defs2, expand = expand2, prep = prep2}) : T * T) = |
209 realizers = realizers2, defs = defs2, expand = expand2, prep = prep2}) : T * T) = |
210 {realizes_eqns = merge_rules realizes_eqns1 realizes_eqns2, |
210 {realizes_eqns = merge_rules realizes_eqns1 realizes_eqns2, |
214 (realizers1, realizers2), |
214 (realizers1, realizers2), |
215 defs = gen_merge_lists eq_thm defs1 defs2, |
215 defs = gen_merge_lists eq_thm defs1 defs2, |
216 expand = merge_lists expand1 expand2, |
216 expand = merge_lists expand1 expand2, |
217 prep = (case prep1 of NONE => prep2 | _ => prep1)}; |
217 prep = (case prep1 of NONE => prep2 | _ => prep1)}; |
218 |
218 |
219 fun print sg (x : T) = (); |
219 fun print _ _ = (); |
220 end; |
220 end); |
221 |
221 |
222 structure ExtractionData = TheoryDataFun(ExtractionArgs); |
|
223 val _ = Context.add_setup [ExtractionData.init]; |
222 val _ = Context.add_setup [ExtractionData.init]; |
224 |
223 |
225 fun read_condeq thy = |
224 fun read_condeq thy = |
226 let val sg = sign_of (add_syntax thy) |
225 let val thy' = add_syntax thy |
227 in fn s => |
226 in fn s => |
228 let val t = Logic.varify (term_of (read_cterm sg (s, propT))) |
227 let val t = Logic.varify (term_of (read_cterm thy' (s, propT))) |
229 in (map Logic.dest_equals (Logic.strip_imp_prems t), |
228 in (map Logic.dest_equals (Logic.strip_imp_prems t), |
230 Logic.dest_equals (Logic.strip_imp_concl t)) |
229 Logic.dest_equals (Logic.strip_imp_concl t)) |
231 end handle TERM _ => error ("Not a (conditional) meta equality:\n" ^ s) |
230 end handle TERM _ => error ("Not a (conditional) meta equality:\n" ^ s) |
232 end; |
231 end; |
233 |
232 |
284 | freeze T = T; |
283 | freeze T = T; |
285 |
284 |
286 fun freeze_thaw f x = |
285 fun freeze_thaw f x = |
287 map_term_types thaw (f (map_term_types freeze x)); |
286 map_term_types thaw (f (map_term_types freeze x)); |
288 |
287 |
289 fun etype_of sg vs Ts t = |
288 fun etype_of thy vs Ts t = |
290 let |
289 let |
291 val {typeof_eqns, ...} = ExtractionData.get_sg sg; |
290 val {typeof_eqns, ...} = ExtractionData.get thy; |
292 fun err () = error ("Unable to determine type of extracted program for\n" ^ |
291 fun err () = error ("Unable to determine type of extracted program for\n" ^ |
293 Sign.string_of_term sg t) |
292 Sign.string_of_term thy t) |
294 in case strip_abs_body (freeze_thaw (condrew sg (#net typeof_eqns) |
293 in case strip_abs_body (freeze_thaw (condrew thy (#net typeof_eqns) |
295 [typeof_proc (Sign.defaultS sg) vs]) (list_abs (map (pair "x") (rev Ts), |
294 [typeof_proc (Sign.defaultS thy) vs]) (list_abs (map (pair "x") (rev Ts), |
296 Const ("typeof", fastype_of1 (Ts, t) --> Type ("Type", [])) $ t))) of |
295 Const ("typeof", fastype_of1 (Ts, t) --> Type ("Type", [])) $ t))) of |
297 Const ("Type", _) $ u => (Logic.dest_type u handle TERM _ => err ()) |
296 Const ("Type", _) $ u => (Logic.dest_type u handle TERM _ => err ()) |
298 | _ => err () |
297 | _ => err () |
299 end; |
298 end; |
300 |
299 |
317 ExtractionData.get thy; |
316 ExtractionData.get thy; |
318 val procs = List.concat (map (fst o snd) types); |
317 val procs = List.concat (map (fst o snd) types); |
319 val rtypes = map fst types; |
318 val rtypes = map fst types; |
320 val eqns = Net.merge (#net realizes_eqns, #net typeof_eqns, K false); |
319 val eqns = Net.merge (#net realizes_eqns, #net typeof_eqns, K false); |
321 val thy' = add_syntax thy; |
320 val thy' = add_syntax thy; |
322 val sign = sign_of thy'; |
|
323 val tsg = Sign.tsig_of sign; |
|
324 val rd = ProofSyntax.read_proof thy' false |
321 val rd = ProofSyntax.read_proof thy' false |
325 in fn (thm, (vs, s1, s2)) => |
322 in fn (thm, (vs, s1, s2)) => |
326 let |
323 let |
327 val name = Thm.name_of_thm thm; |
324 val name = Thm.name_of_thm thm; |
328 val _ = assert (name <> "") "add_realizers: unnamed theorem"; |
325 val _ = assert (name <> "") "add_realizers: unnamed theorem"; |
329 val prop = Pattern.rewrite_term tsg |
326 val prop = Pattern.rewrite_term (Sign.tsig_of thy') |
330 (map (Logic.dest_equals o prop_of) defs) [] (prop_of thm); |
327 (map (Logic.dest_equals o prop_of) defs) [] (prop_of thm); |
331 val vars = vars_of prop; |
328 val vars = vars_of prop; |
332 val vars' = filter_out (fn v => |
329 val vars' = filter_out (fn v => |
333 tname_of (body_type (fastype_of v)) mem rtypes) vars; |
330 tname_of (body_type (fastype_of v)) mem rtypes) vars; |
334 val T = etype_of sign vs [] prop; |
331 val T = etype_of thy' vs [] prop; |
335 val (T', thw) = Type.freeze_thaw_type |
332 val (T', thw) = Type.freeze_thaw_type |
336 (if T = nullT then nullT else map fastype_of vars' ---> T); |
333 (if T = nullT then nullT else map fastype_of vars' ---> T); |
337 val t = map_term_types thw (term_of (read_cterm sign (s1, T'))); |
334 val t = map_term_types thw (term_of (read_cterm thy' (s1, T'))); |
338 val r' = freeze_thaw (condrew sign eqns |
335 val r' = freeze_thaw (condrew thy' eqns |
339 (procs @ [typeof_proc (Sign.defaultS sign) vs, rlz_proc])) |
336 (procs @ [typeof_proc (Sign.defaultS thy') vs, rlz_proc])) |
340 (Const ("realizes", T --> propT --> propT) $ |
337 (Const ("realizes", T --> propT --> propT) $ |
341 (if T = nullT then t else list_comb (t, vars')) $ prop); |
338 (if T = nullT then t else list_comb (t, vars')) $ prop); |
342 val r = foldr forall_intr r' (map (get_var_type r') vars); |
339 val r = foldr forall_intr r' (map (get_var_type r') vars); |
343 val prf = Reconstruct.reconstruct_proof sign r (rd s2); |
340 val prf = Reconstruct.reconstruct_proof thy' r (rd s2); |
344 in (name, (vs, (t, prf))) end |
341 in (name, (vs, (t, prf))) end |
345 end; |
342 end; |
346 |
343 |
347 val add_realizers_i = gen_add_realizers |
344 val add_realizers_i = gen_add_realizers |
348 (fn _ => fn (name, (vs, t, prf)) => (name, (vs, (t, prf)))); |
345 (fn _ => fn (name, (vs, t, prf)) => (name, (vs, (t, prf)))); |
349 val add_realizers = gen_add_realizers prep_realizer; |
346 val add_realizers = gen_add_realizers prep_realizer; |
350 |
347 |
351 fun realizes_of thy vs t prop = |
348 fun realizes_of thy vs t prop = |
352 let |
349 let |
353 val thy' = add_syntax thy; |
350 val thy' = add_syntax thy; |
354 val sign = sign_of thy'; |
|
355 val {realizes_eqns, typeof_eqns, defs, types, ...} = |
351 val {realizes_eqns, typeof_eqns, defs, types, ...} = |
356 ExtractionData.get thy'; |
352 ExtractionData.get thy'; |
357 val procs = List.concat (map (fst o snd) types); |
353 val procs = List.concat (map (fst o snd) types); |
358 val eqns = Net.merge (#net realizes_eqns, #net typeof_eqns, K false); |
354 val eqns = Net.merge (#net realizes_eqns, #net typeof_eqns, K false); |
359 val prop' = Pattern.rewrite_term (Sign.tsig_of sign) |
355 val prop' = Pattern.rewrite_term (Sign.tsig_of thy') |
360 (map (Logic.dest_equals o prop_of) defs) [] prop; |
356 (map (Logic.dest_equals o prop_of) defs) [] prop; |
361 in freeze_thaw (condrew sign eqns |
357 in freeze_thaw (condrew thy' eqns |
362 (procs @ [typeof_proc (Sign.defaultS sign) vs, rlz_proc])) |
358 (procs @ [typeof_proc (Sign.defaultS thy') vs, rlz_proc])) |
363 (Const ("realizes", fastype_of t --> propT --> propT) $ t $ prop') |
359 (Const ("realizes", fastype_of t --> propT --> propT) $ t $ prop') |
364 end; |
360 end; |
365 |
361 |
366 (** expanding theorems / definitions **) |
362 (** expanding theorems / definitions **) |
367 |
363 |
464 |
460 |
465 val dummyt = Const ("dummy", dummyT); |
461 val dummyt = Const ("dummy", dummyT); |
466 |
462 |
467 fun extract thms thy = |
463 fun extract thms thy = |
468 let |
464 let |
469 val sg = sign_of (add_syntax thy); |
465 val thy' = add_syntax thy; |
470 val tsg = Sign.tsig_of sg; |
|
471 val {realizes_eqns, typeof_eqns, types, realizers, defs, expand, prep} = |
466 val {realizes_eqns, typeof_eqns, types, realizers, defs, expand, prep} = |
472 ExtractionData.get thy; |
467 ExtractionData.get thy; |
473 val procs = List.concat (map (fst o snd) types); |
468 val procs = List.concat (map (fst o snd) types); |
474 val rtypes = map fst types; |
469 val rtypes = map fst types; |
475 val typroc = typeof_proc (Sign.defaultS sg); |
470 val typroc = typeof_proc (Sign.defaultS thy'); |
476 val prep = getOpt (prep, K I) sg o ProofRewriteRules.elim_defs sg false defs o |
471 val prep = getOpt (prep, K I) thy' o ProofRewriteRules.elim_defs thy' false defs o |
477 Reconstruct.expand_proof sg (("", NONE) :: map (apsnd SOME) expand); |
472 Reconstruct.expand_proof thy' (("", NONE) :: map (apsnd SOME) expand); |
478 val rrews = Net.merge (#net realizes_eqns, #net typeof_eqns, K false); |
473 val rrews = Net.merge (#net realizes_eqns, #net typeof_eqns, K false); |
479 |
474 |
480 fun find_inst prop Ts ts vs = |
475 fun find_inst prop Ts ts vs = |
481 let |
476 let |
482 val rvs = relevant_vars rtypes prop; |
477 val rvs = relevant_vars rtypes prop; |
483 val vars = vars_of prop; |
478 val vars = vars_of prop; |
484 val n = Int.min (length vars, length ts); |
479 val n = Int.min (length vars, length ts); |
485 |
480 |
486 fun add_args ((Var ((a, i), _), t), (vs', tye)) = |
481 fun add_args ((Var ((a, i), _), t), (vs', tye)) = |
487 if a mem rvs then |
482 if a mem rvs then |
488 let val T = etype_of sg vs Ts t |
483 let val T = etype_of thy' vs Ts t |
489 in if T = nullT then (vs', tye) |
484 in if T = nullT then (vs', tye) |
490 else (a :: vs', (("'" ^ a, i), T) :: tye) |
485 else (a :: vs', (("'" ^ a, i), T) :: tye) |
491 end |
486 end |
492 else (vs', tye) |
487 else (vs', tye) |
493 |
488 |
511 (case t of SOME (Abs (_, _, u)) => SOME u | _ => NONE) |
506 (case t of SOME (Abs (_, _, u)) => SOME u | _ => NONE) |
512 in (defs', Abst (s, SOME T, corr_prf)) end |
507 in (defs', Abst (s, SOME T, corr_prf)) end |
513 |
508 |
514 | corr d defs vs ts Ts hs (AbsP (s, SOME prop, prf)) (AbsP (_, _, prf')) t = |
509 | corr d defs vs ts Ts hs (AbsP (s, SOME prop, prf)) (AbsP (_, _, prf')) t = |
515 let |
510 let |
516 val T = etype_of sg vs Ts prop; |
511 val T = etype_of thy' vs Ts prop; |
517 val u = if T = nullT then |
512 val u = if T = nullT then |
518 (case t of SOME u => SOME (incr_boundvars 1 u) | NONE => NONE) |
513 (case t of SOME u => SOME (incr_boundvars 1 u) | NONE => NONE) |
519 else (case t of SOME (Abs (_, _, u)) => SOME u | _ => NONE); |
514 else (case t of SOME (Abs (_, _, u)) => SOME u | _ => NONE); |
520 val (defs', corr_prf) = corr d defs vs [] (T :: Ts) (prop :: hs) |
515 val (defs', corr_prf) = corr d defs vs [] (T :: Ts) (prop :: hs) |
521 (incr_pboundvars 0 1 prf) (incr_pboundvars 0 1 prf') u; |
516 (incr_pboundvars 0 1 prf) (incr_pboundvars 0 1 prf') u; |
535 val (defs', corr_prf) = corr d defs vs (t :: ts) Ts hs prf prf' |
530 val (defs', corr_prf) = corr d defs vs (t :: ts) Ts hs prf prf' |
536 (if tname_of T mem rtypes then t' |
531 (if tname_of T mem rtypes then t' |
537 else (case t' of SOME (u $ _) => SOME u | _ => NONE)); |
532 else (case t' of SOME (u $ _) => SOME u | _ => NONE)); |
538 val u = if not (tname_of T mem rtypes) then t else |
533 val u = if not (tname_of T mem rtypes) then t else |
539 let |
534 let |
540 val eT = etype_of sg vs Ts t; |
535 val eT = etype_of thy' vs Ts t; |
541 val (r, Us') = if eT = nullT then (nullt, Us) else |
536 val (r, Us') = if eT = nullT then (nullt, Us) else |
542 (Bound (length Us), eT :: Us); |
537 (Bound (length Us), eT :: Us); |
543 val u = list_comb (incr_boundvars (length Us') t, |
538 val u = list_comb (incr_boundvars (length Us') t, |
544 map Bound (length Us - 1 downto 0)); |
539 map Bound (length Us - 1 downto 0)); |
545 val u' = (case assoc (types, tname_of T) of |
540 val u' = (case assoc (types, tname_of T) of |
567 |
562 |
568 | corr d defs vs ts Ts hs (prf0 as PThm ((name, _), prf, prop, SOME Ts')) _ _ = |
563 | corr d defs vs ts Ts hs (prf0 as PThm ((name, _), prf, prop, SOME Ts')) _ _ = |
569 let |
564 let |
570 val (vs', tye) = find_inst prop Ts ts vs; |
565 val (vs', tye) = find_inst prop Ts ts vs; |
571 val tye' = (map fst (term_tvars prop) ~~ Ts') @ tye; |
566 val tye' = (map fst (term_tvars prop) ~~ Ts') @ tye; |
572 val T = etype_of sg vs' [] prop; |
567 val T = etype_of thy' vs' [] prop; |
573 val defs' = if T = nullT then defs |
568 val defs' = if T = nullT then defs |
574 else fst (extr d defs vs ts Ts hs prf0) |
569 else fst (extr d defs vs ts Ts hs prf0) |
575 in |
570 in |
576 if T = nullT andalso realizes_null vs' prop aconv prop then (defs, prf0) |
571 if T = nullT andalso realizes_null vs' prop aconv prop then (defs, prf0) |
577 else case Symtab.lookup (realizers, name) of |
572 else case Symtab.lookup (realizers, name) of |
597 end |
592 end |
598 | SOME (_, (_, prf')) => (defs', prf_subst_TVars tye' prf')) |
593 | SOME (_, (_, prf')) => (defs', prf_subst_TVars tye' prf')) |
599 | SOME rs => (case find vs' rs of |
594 | SOME rs => (case find vs' rs of |
600 SOME (_, prf') => (defs', prf_subst_TVars tye' prf') |
595 SOME (_, prf') => (defs', prf_subst_TVars tye' prf') |
601 | NONE => error ("corr: no realizer for instance of theorem " ^ |
596 | NONE => error ("corr: no realizer for instance of theorem " ^ |
602 quote name ^ ":\n" ^ Sign.string_of_term sg (Envir.beta_norm |
597 quote name ^ ":\n" ^ Sign.string_of_term thy' (Envir.beta_norm |
603 (Reconstruct.prop_of (proof_combt (prf0, ts)))))) |
598 (Reconstruct.prop_of (proof_combt (prf0, ts)))))) |
604 end |
599 end |
605 |
600 |
606 | corr d defs vs ts Ts hs (prf0 as PAxm (s, prop, SOME Ts')) _ _ = |
601 | corr d defs vs ts Ts hs (prf0 as PAxm (s, prop, SOME Ts')) _ _ = |
607 let |
602 let |
608 val (vs', tye) = find_inst prop Ts ts vs; |
603 val (vs', tye) = find_inst prop Ts ts vs; |
609 val tye' = (map fst (term_tvars prop) ~~ Ts') @ tye |
604 val tye' = (map fst (term_tvars prop) ~~ Ts') @ tye |
610 in |
605 in |
611 if etype_of sg vs' [] prop = nullT andalso |
606 if etype_of thy' vs' [] prop = nullT andalso |
612 realizes_null vs' prop aconv prop then (defs, prf0) |
607 realizes_null vs' prop aconv prop then (defs, prf0) |
613 else case find vs' (Symtab.lookup_multi (realizers, s)) of |
608 else case find vs' (Symtab.lookup_multi (realizers, s)) of |
614 SOME (_, prf) => (defs, prf_subst_TVars tye' prf) |
609 SOME (_, prf) => (defs, prf_subst_TVars tye' prf) |
615 | NONE => error ("corr: no realizer for instance of axiom " ^ |
610 | NONE => error ("corr: no realizer for instance of axiom " ^ |
616 quote s ^ ":\n" ^ Sign.string_of_term sg (Envir.beta_norm |
611 quote s ^ ":\n" ^ Sign.string_of_term thy' (Envir.beta_norm |
617 (Reconstruct.prop_of (proof_combt (prf0, ts))))) |
612 (Reconstruct.prop_of (proof_combt (prf0, ts))))) |
618 end |
613 end |
619 |
614 |
620 | corr d defs vs ts Ts hs _ _ _ = error "corr: bad proof" |
615 | corr d defs vs ts Ts hs _ _ _ = error "corr: bad proof" |
621 |
616 |
718 val tye' = (map fst (term_tvars prop) ~~ Ts') @ tye |
713 val tye' = (map fst (term_tvars prop) ~~ Ts') @ tye |
719 in |
714 in |
720 case find vs' (Symtab.lookup_multi (realizers, s)) of |
715 case find vs' (Symtab.lookup_multi (realizers, s)) of |
721 SOME (t, _) => (defs, subst_TVars tye' t) |
716 SOME (t, _) => (defs, subst_TVars tye' t) |
722 | NONE => error ("extr: no realizer for instance of axiom " ^ |
717 | NONE => error ("extr: no realizer for instance of axiom " ^ |
723 quote s ^ ":\n" ^ Sign.string_of_term sg (Envir.beta_norm |
718 quote s ^ ":\n" ^ Sign.string_of_term thy' (Envir.beta_norm |
724 (Reconstruct.prop_of (proof_combt (prf0, ts))))) |
719 (Reconstruct.prop_of (proof_combt (prf0, ts))))) |
725 end |
720 end |
726 |
721 |
727 | extr d defs vs ts Ts hs _ = error "extr: bad proof"; |
722 | extr d defs vs ts Ts hs _ = error "extr: bad proof"; |
728 |
723 |
729 fun prep_thm (thm, vs) = |
724 fun prep_thm (thm, vs) = |
730 let |
725 let |
731 val {prop, der = (_, prf), sign, ...} = rep_thm thm; |
726 val {prop, der = (_, prf), sign, ...} = rep_thm thm; |
732 val name = Thm.name_of_thm thm; |
727 val name = Thm.name_of_thm thm; |
733 val _ = assert (name <> "") "extraction: unnamed theorem"; |
728 val _ = assert (name <> "") "extraction: unnamed theorem"; |
734 val _ = assert (etype_of sg vs [] prop <> nullT) ("theorem " ^ |
729 val _ = assert (etype_of thy' vs [] prop <> nullT) ("theorem " ^ |
735 quote name ^ " has no computational content") |
730 quote name ^ " has no computational content") |
736 in (Reconstruct.reconstruct_proof sign prop prf, vs) end; |
731 in (Reconstruct.reconstruct_proof sign prop prf, vs) end; |
737 |
732 |
738 val defs = Library.foldl (fn (defs, (prf, vs)) => |
733 val defs = Library.foldl (fn (defs, (prf, vs)) => |
739 fst (extr 0 defs vs [] [] [] prf)) ([], map prep_thm thms); |
734 fst (extr 0 defs vs [] [] [] prf)) ([], map prep_thm thms); |
740 |
735 |
741 fun add_def (s, (vs, ((t, u), (prf, _)))) thy = |
736 fun add_def (s, (vs, ((t, u), (prf, _)))) thy = |
742 (case Sign.const_type (sign_of thy) (extr_name s vs) of |
737 (case Sign.const_type thy (extr_name s vs) of |
743 NONE => |
738 NONE => |
744 let |
739 let |
745 val corr_prop = Reconstruct.prop_of prf; |
740 val corr_prop = Reconstruct.prop_of prf; |
746 val ft = Type.freeze t; |
741 val ft = Type.freeze t; |
747 val fu = Type.freeze u; |
742 val fu = Type.freeze u; |