src/Pure/proofterm.ML
changeset 79134 5f0bbed1c606
parent 79130 3ae09d27ee7a
child 79135 db2dc7634d62
equal deleted inserted replaced
79133:cfe995369655 79134:5f0bbed1c606
   119   val trivial_proof: proof
   119   val trivial_proof: proof
   120   val implies_intr_proof: term -> proof -> proof
   120   val implies_intr_proof: term -> proof -> proof
   121   val implies_intr_proof': term -> proof -> proof
   121   val implies_intr_proof': term -> proof -> proof
   122   val forall_intr_proof: string * term -> typ option -> proof -> proof
   122   val forall_intr_proof: string * term -> typ option -> proof -> proof
   123   val forall_intr_proof': term -> proof -> proof
   123   val forall_intr_proof': term -> proof -> proof
   124   val varify_proof: term -> TFrees.set -> proof -> proof
   124   val varify_proof: ((string * sort) * (indexname * sort)) list -> proof -> proof
   125   val legacy_freezeT: term -> proof -> proof
   125   val legacy_freezeT: term -> proof -> proof
   126   val rotate_proof: term list -> term -> (string * typ) list -> term list -> int -> proof -> proof
   126   val rotate_proof: term list -> term -> (string * typ) list -> term list -> int -> proof -> proof
   127   val permute_prems_proof: term list -> int -> int -> proof -> proof
   127   val permute_prems_proof: term list -> int -> int -> proof -> proof
   128   val generalize_proof: Names.set * Names.set -> int -> term -> proof -> proof
   128   val generalize_proof: Names.set * Names.set -> int -> term -> proof -> proof
   129   val instantiate: typ TVars.table * term Vars.table -> proof -> proof
   129   val instantiate: typ TVars.table * term Vars.table -> proof -> proof
   930   in forall_intr_proof (a, v) (SOME T) prf end;
   930   in forall_intr_proof (a, v) (SOME T) prf end;
   931 
   931 
   932 
   932 
   933 (* varify *)
   933 (* varify *)
   934 
   934 
   935 fun varify_names t fixed =
   935 fun varify_proof names prf =
   936   let
   936   let
   937     val xs =
   937     val tab = TFrees.make names;
   938       build (t |> (Term.fold_types o Term.fold_atyps)
   938     fun varify v =
   939         (fn TFree v => if TFrees.defined fixed v then I else insert (op =) v | _ => I));
   939       (case TFrees.lookup tab v of
   940     val used =
   940         NONE => TFree v
   941       Name.build_context (t |>
   941       | SOME w => TVar w);
   942         (fold_types o fold_atyps) (fn TVar ((a, _), _) => Name.declare a | _ => I));
       
   943     val (ys, _) = fold_map Name.variant (map #1 xs) used;
       
   944     val zs = map2 (fn (_, S) => fn y => ((y, 0), S)) xs ys;
       
   945   in xs ~~ zs end;
       
   946 
       
   947 fun varify_proof t fixed prf =
       
   948   let
       
   949     val table = TFrees.make (varify_names t fixed);
       
   950     fun varify (a, S) =
       
   951       (case TFrees.lookup table (a, S) of
       
   952         NONE => TFree (a, S)
       
   953       | SOME b => TVar b);
       
   954   in map_proof_terms (map_types (map_type_tfree varify)) (map_type_tfree varify) prf end;
   942   in map_proof_terms (map_types (map_type_tfree varify)) (map_type_tfree varify) prf end;
   955 
   943 
   956 
   944 
   957 local
   945 local
   958 
   946