55 val read_instantiate : (string*string)list -> thm -> thm |
55 val read_instantiate : (string*string)list -> thm -> thm |
56 val read_instantiate_sg: Sign.sg -> (string*string)list -> thm -> thm |
56 val read_instantiate_sg: Sign.sg -> (string*string)list -> thm -> thm |
57 val read_insts : |
57 val read_insts : |
58 Sign.sg -> (indexname -> typ option) * (indexname -> sort option) |
58 Sign.sg -> (indexname -> typ option) * (indexname -> sort option) |
59 -> (indexname -> typ option) * (indexname -> sort option) |
59 -> (indexname -> typ option) * (indexname -> sort option) |
60 -> (string*string)list |
60 -> string list -> (string*string)list |
61 -> (indexname*ctyp)list * (cterm*cterm)list |
61 -> (indexname*ctyp)list * (cterm*cterm)list |
62 val reflexive_thm : thm |
62 val reflexive_thm : thm |
63 val revcut_rl : thm |
63 val revcut_rl : thm |
64 val rewrite_goal_rule : bool*bool -> (meta_simpset -> thm -> thm option) |
64 val rewrite_goal_rule : bool*bool -> (meta_simpset -> thm -> thm option) |
65 -> meta_simpset -> int -> thm -> thm |
65 -> meta_simpset -> int -> thm -> thm |
247 error("No such variable in term: " ^ Syntax.string_of_vname ixn); |
247 error("No such variable in term: " ^ Syntax.string_of_vname ixn); |
248 |
248 |
249 fun inst_failure ixn = |
249 fun inst_failure ixn = |
250 error("Instantiation of " ^ Syntax.string_of_vname ixn ^ " fails"); |
250 error("Instantiation of " ^ Syntax.string_of_vname ixn ^ " fails"); |
251 |
251 |
252 fun read_insts sign (rtypes,rsorts) (types,sorts) insts = |
252 fun read_insts sign (rtypes,rsorts) (types,sorts) used insts = |
253 let val {tsig,...} = Sign.rep_sg sign |
253 let val {tsig,...} = Sign.rep_sg sign |
254 fun split([],tvs,vs) = (tvs,vs) |
254 fun split([],tvs,vs) = (tvs,vs) |
255 | split((sv,st)::l,tvs,vs) = (case explode sv of |
255 | split((sv,st)::l,tvs,vs) = (case explode sv of |
256 "'"::cs => split(l,(indexname cs,st)::tvs,vs) |
256 "'"::cs => split(l,(indexname cs,st)::tvs,vs) |
257 | cs => split(l,tvs,(indexname cs,st)::vs)); |
257 | cs => split(l,tvs,(indexname cs,st)::vs)); |
262 val T = Sign.read_typ (sign,sorts) st; |
262 val T = Sign.read_typ (sign,sorts) st; |
263 in if Type.typ_instance(tsig,T,TVar(ixn,S)) then (ixn,T) |
263 in if Type.typ_instance(tsig,T,TVar(ixn,S)) then (ixn,T) |
264 else inst_failure ixn |
264 else inst_failure ixn |
265 end |
265 end |
266 val tye = map readT tvs; |
266 val tye = map readT tvs; |
267 fun add_cterm ((cts,tye), (ixn,st)) = |
267 fun add_cterm ((cts,tye,used), (ixn,st)) = |
268 let val T = case rtypes ixn of |
268 let val T = case rtypes ixn of |
269 Some T => typ_subst_TVars tye T |
269 Some T => typ_subst_TVars tye T |
270 | None => absent ixn; |
270 | None => absent ixn; |
271 val (ct,tye2) = read_def_cterm (sign,types,sorts) (st,T); |
271 val (ct,tye2) = read_def_cterm(sign,types,sorts) used false (st,T); |
272 val cv = cterm_of sign (Var(ixn,typ_subst_TVars tye2 T)) |
272 val cv = cterm_of sign (Var(ixn,typ_subst_TVars tye2 T)) |
273 in ((cv,ct)::cts,tye2 @ tye) end |
273 val used' = add_term_tvarnames(term_of ct,used); |
274 val (cterms,tye') = foldl add_cterm (([],tye), vs); |
274 in ((cv,ct)::cts,tye2 @ tye,used') end |
|
275 val (cterms,tye',_) = foldl add_cterm (([],tye,used), vs); |
275 in (map (fn (ixn,T) => (ixn,ctyp_of sign T)) tye', cterms) end; |
276 in (map (fn (ixn,T) => (ixn,ctyp_of sign T)) tye', cterms) end; |
276 |
277 |
277 |
278 |
278 |
279 |
279 (*** Printing of theories, theorems, etc. ***) |
280 (*** Printing of theories, theorems, etc. ***) |
582 | _ => raise THM("COMP", 1, [tha,thb]); |
583 | _ => raise THM("COMP", 1, [tha,thb]); |
583 |
584 |
584 (*Instantiate theorem th, reading instantiations under signature sg*) |
585 (*Instantiate theorem th, reading instantiations under signature sg*) |
585 fun read_instantiate_sg sg sinsts th = |
586 fun read_instantiate_sg sg sinsts th = |
586 let val ts = types_sorts th; |
587 let val ts = types_sorts th; |
587 in instantiate (read_insts sg ts ts sinsts) th end; |
588 in instantiate (read_insts sg ts ts [] sinsts) th end; |
588 |
589 |
589 (*Instantiate theorem th, reading instantiations under theory of th*) |
590 (*Instantiate theorem th, reading instantiations under theory of th*) |
590 fun read_instantiate sinsts th = |
591 fun read_instantiate sinsts th = |
591 read_instantiate_sg (#sign (rep_thm th)) sinsts th; |
592 read_instantiate_sg (#sign (rep_thm th)) sinsts th; |
592 |
593 |