src/Pure/theory.ML
changeset 61249 8611f408ec13
parent 61248 066792098895
child 61255 15865e0c5598
equal deleted inserted replaced
61248:066792098895 61249:8611f408ec13
   219 
   219 
   220 fun dependencies ctxt unchecked def description lhs rhs =
   220 fun dependencies ctxt unchecked def description lhs rhs =
   221   let
   221   let
   222     val thy = Proof_Context.theory_of ctxt;
   222     val thy = Proof_Context.theory_of ctxt;
   223     val consts = Sign.consts_of thy;
   223     val consts = Sign.consts_of thy;
       
   224 
   224     fun prep (DConst const) =
   225     fun prep (DConst const) =
   225       let val Const (c, T) = Sign.no_vars ctxt (Const const)
   226         let val Const (c, T) = Sign.no_vars ctxt (Const const)
   226       in (Defs.NConst c, Consts.typargs consts (c, Logic.varifyT_global T)) end
   227         in ((Defs.Constant, c), Consts.typargs consts (c, Logic.varifyT_global T)) end
   227     | prep (DType typ) =
   228     | prep (DType typ) =
   228       let val Type (c, T) = Type.no_tvars (Type typ)
   229         let val Type (c, Ts) = Type.no_tvars (Type typ)
   229       in (Defs.NType c, map Logic.varifyT_global T) end;
   230         in ((Defs.Type, c), map Logic.varifyT_global Ts) end;
       
   231 
   230     fun fold_dep_tfree f (DConst (_, T)) = fold_atyps (fn TFree v => f v | _ => I) T
   232     fun fold_dep_tfree f (DConst (_, T)) = fold_atyps (fn TFree v => f v | _ => I) T
   231       | fold_dep_tfree f (DType (_, Ts)) = fold (fold_atyps (fn TFree v => f v | _ => I)) Ts
   233       | fold_dep_tfree f (DType (_, Ts)) = fold (fold_atyps (fn TFree v => f v | _ => I)) Ts;
       
   234 
   232     val lhs_vars = fold_dep_tfree (insert (op =)) lhs [];
   235     val lhs_vars = fold_dep_tfree (insert (op =)) lhs [];
   233     val rhs_extras = fold (fold_dep_tfree
   236     val rhs_extras = fold (fold_dep_tfree
   234       (fn v => if member (op =) lhs_vars v then I else insert (op =) v)) rhs [];
   237       (fn v => if member (op =) lhs_vars v then I else insert (op =) v)) rhs [];
   235     val _ =
   238     val _ =
   236       if null rhs_extras then ()
   239       if null rhs_extras then ()