equal
deleted
inserted
replaced
281 fun etype_of thy vs Ts t = |
281 fun etype_of thy vs Ts t = |
282 let |
282 let |
283 val {typeof_eqns, ...} = ExtractionData.get thy; |
283 val {typeof_eqns, ...} = ExtractionData.get thy; |
284 fun err () = error ("Unable to determine type of extracted program for\n" ^ |
284 fun err () = error ("Unable to determine type of extracted program for\n" ^ |
285 Syntax.string_of_term_global thy t) |
285 Syntax.string_of_term_global thy t) |
286 in case strip_abs_body (freeze_thaw (condrew thy (#net typeof_eqns) |
286 in |
287 [typeof_proc [] vs]) (list_abs (map (pair "x") (rev Ts), |
287 (case |
288 Const ("typeof", fastype_of1 (Ts, t) --> Type ("Type", [])) $ t))) of |
288 strip_abs_body |
|
289 (freeze_thaw (condrew thy (#net typeof_eqns) [typeof_proc [] vs]) |
|
290 (fold (Term.abs o pair "x") Ts |
|
291 (Const ("typeof", fastype_of1 (Ts, t) --> Type ("Type", [])) $ t))) of |
289 Const ("Type", _) $ u => (Logic.dest_type u handle TERM _ => err ()) |
292 Const ("Type", _) $ u => (Logic.dest_type u handle TERM _ => err ()) |
290 | _ => err () |
293 | _ => err ()) |
291 end; |
294 end; |
292 |
295 |
293 (** realizers for axioms / theorems, together with correctness proofs **) |
296 (** realizers for axioms / theorems, together with correctness proofs **) |
294 |
297 |
295 fun gen_add_realizers prep_rlz rs thy = |
298 fun gen_add_realizers prep_rlz rs thy = |
511 (T, Sign.defaultS thy)) tye; |
514 (T, Sign.defaultS thy)) tye; |
512 |
515 |
513 fun find (vs: string list) = Option.map snd o find_first (curry (eq_set (op =)) vs o fst); |
516 fun find (vs: string list) = Option.map snd o find_first (curry (eq_set (op =)) vs o fst); |
514 fun find' (s: string) = map_filter (fn (s', x) => if s = s' then SOME x else NONE); |
517 fun find' (s: string) = map_filter (fn (s', x) => if s = s' then SOME x else NONE); |
515 |
518 |
516 fun app_rlz_rews Ts vs t = strip_abs (length Ts) (freeze_thaw |
519 fun app_rlz_rews Ts vs t = |
517 (condrew thy' rrews (procs @ [typroc vs, rlz_proc])) (list_abs |
520 strip_abs (length Ts) |
518 (map (pair "x") (rev Ts), t))); |
521 (freeze_thaw (condrew thy' rrews (procs @ [typroc vs, rlz_proc])) |
|
522 (fold (Term.abs o pair "x") Ts t)); |
519 |
523 |
520 fun realizes_null vs prop = app_rlz_rews [] vs |
524 fun realizes_null vs prop = app_rlz_rews [] vs |
521 (Const ("realizes", nullT --> propT --> propT) $ nullt $ prop); |
525 (Const ("realizes", nullT --> propT --> propT) $ nullt $ prop); |
522 |
526 |
523 fun corr d defs vs ts Ts hs cs (PBound i) _ _ = (defs, PBound i) |
527 fun corr d defs vs ts Ts hs cs (PBound i) _ _ = (defs, PBound i) |
562 val u = list_comb (incr_boundvars (length Us') t, |
566 val u = list_comb (incr_boundvars (length Us') t, |
563 map Bound (length Us - 1 downto 0)); |
567 map Bound (length Us - 1 downto 0)); |
564 val u' = (case AList.lookup (op =) types (tname_of T) of |
568 val u' = (case AList.lookup (op =) types (tname_of T) of |
565 SOME ((_, SOME f)) => f r eT u T |
569 SOME ((_, SOME f)) => f r eT u T |
566 | _ => Const ("realizes", eT --> T --> T) $ r $ u) |
570 | _ => Const ("realizes", eT --> T --> T) $ r $ u) |
567 in app_rlz_rews Ts vs (list_abs (map (pair "x") Us', u')) end |
571 in app_rlz_rews Ts vs (fold_rev (Term.abs o pair "x") Us' u') end |
568 in (defs', corr_prf % SOME u) end |
572 in (defs', corr_prf % SOME u) end |
569 |
573 |
570 | corr d defs vs ts Ts hs cs (prf1 %% prf2) (prf1' %% prf2') t = |
574 | corr d defs vs ts Ts hs cs (prf1 %% prf2) (prf1' %% prf2') t = |
571 let |
575 let |
572 val prop = Reconstruct.prop_of' hs prf2'; |
576 val prop = Reconstruct.prop_of' hs prf2'; |