equal
deleted
inserted
replaced
139 let |
139 let |
140 val frees = Term.term_frees prop |
140 val frees = Term.term_frees prop |
141 val tsig = Sign.tsig_of (sign_of thy) |
141 val tsig = Sign.tsig_of (sign_of thy) |
142 val _ = assert (forall (fn v => Type.of_sort tsig (type_of v,HOLogic.typeS)) frees) |
142 val _ = assert (forall (fn v => Type.of_sort tsig (type_of v,HOLogic.typeS)) frees) |
143 "Specificaton: Only free variables of sort 'type' allowed" |
143 "Specificaton: Only free variables of sort 'type' allowed" |
144 val prop_closed = foldr (fn ((vname,T),prop) => HOLogic.mk_all (vname,T,prop)) (map dest_Free frees,prop) |
144 val prop_closed = Library.foldr (fn ((vname,T),prop) => HOLogic.mk_all (vname,T,prop)) (map dest_Free frees,prop) |
145 in |
145 in |
146 (prop_closed,frees) |
146 (prop_closed,frees) |
147 end |
147 end |
148 |
148 |
149 val props'' = map proc_single props' |
149 val props'' = map proc_single props' |
162 fun proc_const c = |
162 fun proc_const c = |
163 let |
163 let |
164 val c' = fst (Type.varify (c,[])) |
164 val c' = fst (Type.varify (c,[])) |
165 val (cname,ctyp) = dest_Const c' |
165 val (cname,ctyp) = dest_Const c' |
166 in |
166 in |
167 case filter (fn t => let val (name,typ) = dest_Const t |
167 case List.filter (fn t => let val (name,typ) = dest_Const t |
168 in name = cname andalso typ_equiv typ ctyp |
168 in name = cname andalso typ_equiv typ ctyp |
169 end) thawed_prop_consts of |
169 end) thawed_prop_consts of |
170 [] => error ("Specification: No suitable instances of constant \"" ^ (Sign.string_of_term sg c) ^ "\" found") |
170 [] => error ("Specification: No suitable instances of constant \"" ^ (Sign.string_of_term sg c) ^ "\" found") |
171 | [cf] => unvarify cf vmap |
171 | [cf] => unvarify cf vmap |
172 | _ => error ("Specification: Several variations of \"" ^ (Sign.string_of_term sg c) ^ "\" found (try applying explicit type constraints)") |
172 | _ => error ("Specification: Several variations of \"" ^ (Sign.string_of_term sg c) ^ "\" found (try applying explicit type constraints)") |
180 then cname |
180 then cname |
181 else "x" |
181 else "x" |
182 in |
182 in |
183 HOLogic.exists_const T $ Abs(vname,T,Term.abstract_over (c,prop)) |
183 HOLogic.exists_const T $ Abs(vname,T,Term.abstract_over (c,prop)) |
184 end |
184 end |
185 val ex_prop = foldr mk_exist (proc_consts,prop) |
185 val ex_prop = Library.foldr mk_exist (proc_consts,prop) |
186 val cnames = map (fst o dest_Const) proc_consts |
186 val cnames = map (fst o dest_Const) proc_consts |
187 fun post_process (arg as (thy,thm)) = |
187 fun post_process (arg as (thy,thm)) = |
188 let |
188 let |
189 fun inst_all sg (thm,v) = |
189 fun inst_all sg (thm,v) = |
190 let |
190 let |
192 val cT = ctyp_of_term cv |
192 val cT = ctyp_of_term cv |
193 val spec' = instantiate' [SOME cT] [NONE,SOME cv] spec |
193 val spec' = instantiate' [SOME cT] [NONE,SOME cv] spec |
194 in |
194 in |
195 thm RS spec' |
195 thm RS spec' |
196 end |
196 end |
197 fun remove_alls frees thm = foldl (inst_all (sign_of_thm thm)) (thm,frees) |
197 fun remove_alls frees thm = Library.foldl (inst_all (sign_of_thm thm)) (thm,frees) |
198 fun process_single ((name,atts),rew_imp,frees) args = |
198 fun process_single ((name,atts),rew_imp,frees) args = |
199 let |
199 let |
200 fun undo_imps thm = |
200 fun undo_imps thm = |
201 equal_elim (symmetric rew_imp) thm |
201 equal_elim (symmetric rew_imp) thm |
202 |
202 |