src/Pure/proofterm.ML
changeset 12923 9ba7c5358fa0
parent 12907 27e6d344d724
child 13102 b6f8aae5f152
equal deleted inserted replaced
12922:ed70a600f0ea 12923:9ba7c5358fa0
    95   val equal_elim : term -> term -> proof -> proof -> proof
    95   val equal_elim : term -> term -> proof -> proof -> proof
    96   val axm_proof : string -> term -> proof
    96   val axm_proof : string -> term -> proof
    97   val oracle_proof : string -> term -> proof
    97   val oracle_proof : string -> term -> proof
    98   val thm_proof : Sign.sg -> string * (string * string list) list ->
    98   val thm_proof : Sign.sg -> string * (string * string list) list ->
    99     term list -> term -> proof -> proof
    99     term list -> term -> proof -> proof
   100   val get_name_tags : term -> proof -> string * (string * string list) list
   100   val get_name_tags : term list -> term -> proof -> string * (string * string list) list
   101 
   101 
   102   (** rewriting on proof terms **)
   102   (** rewriting on proof terms **)
   103   val add_prf_rrules : (proof * proof) list -> theory -> theory
   103   val add_prf_rrules : (proof * proof) list -> theory -> theory
   104   val add_prf_rprocs : (string * (Term.typ list -> proof -> proof option)) list ->
   104   val add_prf_rprocs : (string * (Term.typ list -> proof -> proof option)) list ->
   105     theory -> theory
   105     theory -> theory
   884 
   884 
   885 exception PMatch;
   885 exception PMatch;
   886 
   886 
   887 (** see pattern.ML **)
   887 (** see pattern.ML **)
   888 
   888 
   889 fun flt i = filter (fn n => n < i);
   889 fun flt (i: int) = filter (fn n => n < i);
   890 
   890 
   891 fun fomatch Ts tymatch j =
   891 fun fomatch Ts tymatch j =
   892   let
   892   let
   893     fun mtch (instsp as (tyinsts, insts)) = fn
   893     fun mtch (instsp as (tyinsts, insts)) = fn
   894         (Var (ixn, T), t)  =>
   894         (Var (ixn, T), t)  =>
  1106   let val r = ProofData.get thy
  1106   let val r = ProofData.get thy
  1107   in ProofData.put (fst r, ps @ snd r) thy end;
  1107   in ProofData.put (fst r, ps @ snd r) thy end;
  1108 
  1108 
  1109 fun thm_proof sign (name, tags) hyps prop prf =
  1109 fun thm_proof sign (name, tags) hyps prop prf =
  1110   let
  1110   let
  1111     val hyps' = gen_distinct op aconv hyps;
  1111     val prop = Logic.list_implies (hyps, prop);
  1112     val prop = Logic.list_implies (hyps', prop);
       
  1113     val nvs = needed_vars prop;
  1112     val nvs = needed_vars prop;
  1114     val args = map (fn (v as Var (ixn, _)) =>
  1113     val args = map (fn (v as Var (ixn, _)) =>
  1115         if ixn mem nvs then Some v else None) (vars_of prop) @
  1114         if ixn mem nvs then Some v else None) (vars_of prop) @
  1116       map Some (sort (make_ord atless) (term_frees prop));
  1115       map Some (sort (make_ord atless) (term_frees prop));
  1117     val opt_prf = if ! proofs = 2 then
  1116     val opt_prf = if ! proofs = 2 then
  1118         #4 (shrink [] 0 (rewrite_prf fst (ProofData.get_sg sign)
  1117         #4 (shrink [] 0 (rewrite_prf fst (ProofData.get_sg sign)
  1119           (foldr (uncurry implies_intr_proof) (hyps', prf))))
  1118           (foldr (uncurry implies_intr_proof) (hyps, prf))))
  1120       else MinProof (mk_min_proof ([], prf));
  1119       else MinProof (mk_min_proof ([], prf));
  1121     val head = (case strip_combt (fst (strip_combP prf)) of
  1120     val head = (case strip_combt (fst (strip_combP prf)) of
  1122         (PThm ((old_name, _), prf', prop', None), args') =>
  1121         (PThm ((old_name, _), prf', prop', None), args') =>
  1123           if (old_name="" orelse old_name=name) andalso
  1122           if (old_name="" orelse old_name=name) andalso
  1124              prop = prop' andalso args = args' then
  1123              prop = prop' andalso args = args' then
  1125             PThm ((name, tags), prf', prop, None)
  1124             PThm ((name, tags), prf', prop, None)
  1126           else
  1125           else
  1127             PThm ((name, tags), opt_prf, prop, None)
  1126             PThm ((name, tags), opt_prf, prop, None)
  1128       | _ => PThm ((name, tags), opt_prf, prop, None))
  1127       | _ => PThm ((name, tags), opt_prf, prop, None))
  1129   in
  1128   in
  1130     proof_combP (proof_combt' (head, args), map Hyp hyps')
  1129     proof_combP (proof_combt' (head, args), map Hyp hyps)
  1131   end;
  1130   end;
  1132 
  1131 
  1133 fun get_name_tags prop prf = (case strip_combt (fst (strip_combP prf)) of
  1132 fun get_name_tags hyps prop prf =
       
  1133   let val prop = Logic.list_implies (hyps, prop) in
       
  1134     (case strip_combt (fst (strip_combP prf)) of
  1134       (PThm ((name, tags), _, prop', _), _) =>
  1135       (PThm ((name, tags), _, prop', _), _) =>
  1135         if prop=prop' then (name, tags) else ("", [])
  1136         if prop=prop' then (name, tags) else ("", [])
  1136     | (PAxm (name, prop', _), _) =>
  1137     | (PAxm (name, prop', _), _) =>
  1137         if prop=prop' then (name, []) else ("", [])
  1138         if prop=prop' then (name, []) else ("", [])
  1138     | _ => ("", []));
  1139     | _ => ("", []))
       
  1140   end;
  1139 
  1141 
  1140 end;
  1142 end;
  1141 
  1143 
  1142 structure BasicProofterm : BASIC_PROOFTERM = Proofterm;
  1144 structure BasicProofterm : BASIC_PROOFTERM = Proofterm;
  1143 open BasicProofterm;
  1145 open BasicProofterm;