src/Pure/drule.ML
changeset 22681 9d42e5365ad1
parent 22561 705d4fb9e628
child 22695 17073e9b94f2
equal deleted inserted replaced
22680:31a2303f4283 22681:9d42e5365ad1
   251 
   251 
   252 
   252 
   253 (** reading of instantiations **)
   253 (** reading of instantiations **)
   254 
   254 
   255 fun absent ixn =
   255 fun absent ixn =
   256   error("No such variable in term: " ^ Syntax.string_of_vname ixn);
   256   error("No such variable in term: " ^ Term.string_of_vname ixn);
   257 
   257 
   258 fun inst_failure ixn =
   258 fun inst_failure ixn =
   259   error("Instantiation of " ^ Syntax.string_of_vname ixn ^ " fails");
   259   error("Instantiation of " ^ Term.string_of_vname ixn ^ " fails");
   260 
   260 
   261 fun read_insts thy (rtypes,rsorts) (types,sorts) used insts =
   261 fun read_insts thy (rtypes,rsorts) (types,sorts) used insts =
   262 let
   262 let
   263     fun is_tv ((a, _), _) =
   263     fun is_tv ((a, _), _) =
   264       (case Symbol.explode a of "'" :: _ => true | _ => false);
   264       (case Symbol.explode a of "'" :: _ => true | _ => false);
   265     val (tvs, vs) = List.partition is_tv insts;
   265     val (tvs, vs) = List.partition is_tv insts;
   266     fun sort_of ixn = case rsorts ixn of SOME S => S | NONE => absent ixn;
   266     fun sort_of ixn = case rsorts ixn of SOME S => S | NONE => absent ixn;
   267     fun readT (ixn, st) =
   267     fun readT (ixn, st) =
   268         let val S = sort_of ixn;
   268         let val S = sort_of ixn;
   269             val T = Sign.read_typ (thy,sorts) st;
   269             val T = Sign.read_def_typ (thy,sorts) st;
   270         in if Sign.typ_instance thy (T, TVar(ixn,S)) then (ixn,T)
   270         in if Sign.typ_instance thy (T, TVar(ixn,S)) then (ixn,T)
   271            else inst_failure ixn
   271            else inst_failure ixn
   272         end
   272         end
   273     val tye = map readT tvs;
   273     val tye = map readT tvs;
   274     fun mkty(ixn,st) = (case rtypes ixn of
   274     fun mkty(ixn,st) = (case rtypes ixn of
   275                           SOME T => (ixn,(st,typ_subst_TVars tye T))
   275                           SOME T => (ixn,(st,typ_subst_TVars tye T))
   276                         | NONE => absent ixn);
   276                         | NONE => absent ixn);
   277     val ixnsTs = map mkty vs;
   277     val ixnsTs = map mkty vs;
   278     val ixns = map fst ixnsTs
   278     val ixns = map fst ixnsTs
   279     and sTs  = map snd ixnsTs
   279     and sTs  = map snd ixnsTs
   280     val (cts,tye2) = read_def_cterms(thy,types,sorts) used false sTs;
   280     val (cts,tye2) = Thm.read_def_cterms(thy,types,sorts) used false sTs;
   281     fun mkcVar(ixn,T) =
   281     fun mkcVar(ixn,T) =
   282         let val U = typ_subst_TVars tye2 T
   282         let val U = typ_subst_TVars tye2 T
   283         in cterm_of thy (Var(ixn,U)) end
   283         in cterm_of thy (Var(ixn,U)) end
   284     val ixnTs = ListPair.zip(ixns, map snd sTs)
   284     val ixnTs = ListPair.zip(ixns, map snd sTs)
   285 in (map (fn (ixn, T) => (ctyp_of thy (TVar (ixn, sort_of ixn)),
   285 in (map (fn (ixn, T) => (ctyp_of thy (TVar (ixn, sort_of ixn)),
   571 
   571 
   572 
   572 
   573 
   573 
   574 (*** Meta-Rewriting Rules ***)
   574 (*** Meta-Rewriting Rules ***)
   575 
   575 
   576 fun read_prop s = read_cterm ProtoPure.thy (s, propT);
   576 fun read_prop s = Thm.read_cterm ProtoPure.thy (s, propT);
   577 
   577 
   578 fun store_thm name thm = hd (PureThy.smart_store_thms (name, [thm]));
   578 fun store_thm name thm = hd (PureThy.smart_store_thms (name, [thm]));
   579 fun store_standard_thm name thm = store_thm name (standard thm);
   579 fun store_standard_thm name thm = store_thm name (standard thm);
   580 fun store_thm_open name thm = hd (PureThy.smart_store_thms_open (name, [thm]));
   580 fun store_thm_open name thm = hd (PureThy.smart_store_thms_open (name, [thm]));
   581 fun store_standard_thm_open name thm = store_thm_open name (standard' thm);
   581 fun store_standard_thm_open name thm = store_thm_open name (standard' thm);