src/Pure/proofterm.ML
changeset 70810 8623422d07de
parent 70809 58677c92bef7
child 70811 785a2112f861
equal deleted inserted replaced
70809:58677c92bef7 70810:8623422d07de
  1075     type_variable = fn typ => map (fn c => (hyps (typ, c), c)) (Type.sort_of_atyp typ)};
  1075     type_variable = fn typ => map (fn c => (hyps (typ, c), c)) (Type.sort_of_atyp typ)};
  1076 
  1076 
  1077 
  1077 
  1078 
  1078 
  1079 (** axioms and theorems **)
  1079 (** axioms and theorems **)
       
  1080 
       
  1081 fun tvars_of t = map TVar (rev (Term.add_tvars t []));
       
  1082 fun tfrees_of t = map TFree (rev (Term.add_tfrees t []));
       
  1083 fun type_variables_of t = tvars_of t @ tfrees_of t;
  1080 
  1084 
  1081 fun vars_of t = map Var (rev (Term.add_vars t []));
  1085 fun vars_of t = map Var (rev (Term.add_vars t []));
  1082 fun frees_of t = map Free (rev (Term.add_frees t []));
  1086 fun frees_of t = map Free (rev (Term.add_frees t []));
  1083 fun variables_of t = vars_of t @ frees_of t;
  1087 fun variables_of t = vars_of t @ frees_of t;
  1084 
  1088 
  1571 fun forall_intr_vfs prop = fold_rev Logic.all (variables_of prop) prop;
  1575 fun forall_intr_vfs prop = fold_rev Logic.all (variables_of prop) prop;
  1572 fun forall_intr_vfs_prf prop prf = fold_rev forall_intr_proof' (variables_of prop) prf;
  1576 fun forall_intr_vfs_prf prop prf = fold_rev forall_intr_proof' (variables_of prop) prf;
  1573 
  1577 
  1574 fun app_types shift prop Ts prf =
  1578 fun app_types shift prop Ts prf =
  1575   let
  1579   let
  1576     val tvars = rev (Term.add_tvars prop []);
  1580     val inst = type_variables_of prop ~~ Ts;
  1577     val tfrees = rev (Term.add_tfrees prop []) |> map (fn (a, S) => ((a, ~1), S));
  1581     fun subst_same A =
  1578     val inst = (tvars @ tfrees) ~~ Ts;
  1582       (case AList.lookup (op =) inst A of SOME T => T | NONE => raise Same.SAME);
  1579     fun subst_same v = (case AList.lookup (op =) inst v of SOME T => T | NONE => raise Same.SAME);
       
  1580     val subst_type_same =
  1583     val subst_type_same =
  1581       Term_Subst.map_atypsT_same
  1584       Term_Subst.map_atypsT_same
  1582         (fn TVar ((a, i), S) => subst_same ((a, i - shift), S)
  1585         (fn TVar ((a, i), S) => subst_same (TVar ((a, i - shift), S)) | A => subst_same A);
  1583           | TFree (a, S) => subst_same ((a, ~1), S));
       
  1584   in Same.commit (map_proof_types_same subst_type_same) prf end;
  1586   in Same.commit (map_proof_types_same subst_type_same) prf end;
  1585 
  1587 
  1586 fun guess_name (PThm ({name, ...}, _)) = name
  1588 fun guess_name (PThm ({name, ...}, _)) = name
  1587   | guess_name (prf %% Hyp _) = guess_name prf
  1589   | guess_name (prf %% Hyp _) = guess_name prf
  1588   | guess_name (prf %% OfClass _) = guess_name prf
  1590   | guess_name (prf %% OfClass _) = guess_name prf