src/Provers/hypsubst.ML
changeset 2722 3e07c20b967c
parent 2174 0829b7b632c5
child 2750 fe3799355b5e
equal deleted inserted replaced
2721:f08042e18c7d 2722:3e07c20b967c
    45   val inspect_pair           : bool -> bool -> term * term -> bool
    45   val inspect_pair           : bool -> bool -> term * term -> bool
    46   val mk_eqs                 : thm -> thm list
    46   val mk_eqs                 : thm -> thm list
    47   val thin_leading_eqs_tac   : bool -> int -> int -> tactic
    47   val thin_leading_eqs_tac   : bool -> int -> int -> tactic
    48   end;
    48   end;
    49 
    49 
       
    50 
       
    51 
    50 functor HypsubstFun(Data: HYPSUBST_DATA): HYPSUBST = 
    52 functor HypsubstFun(Data: HYPSUBST_DATA): HYPSUBST = 
    51 struct
    53 struct
    52 
    54 
    53 local open Data in
    55 local open Data in
    54 
    56 
    60 in
    62 in
    61 (*Simplifier turns Bound variables to dotted Free variables: 
    63 (*Simplifier turns Bound variables to dotted Free variables: 
    62   change it back (any Bound variable will do)
    64   change it back (any Bound variable will do)
    63 *)
    65 *)
    64 fun contract t =
    66 fun contract t =
    65     case Pattern.eta_contract t of
    67     case Pattern.eta_contract_atom t of
    66 	Free(a,T) => if (ord a = odot) then Bound 0 else Free(a,T)
    68 	Free(a,T) => if (ord a = odot) then Bound 0 else Free(a,T)
    67       | t'        => t'
    69       | t'        => t'
    68 end;
    70 end;
    69 
    71 
    70 fun has_vars t = maxidx_of_term t <> ~1;
    72 fun has_vars t = maxidx_of_term t <> ~1;
   119 	  | count (A::Bs) = ((inspect_pair bnd true (dest_eq A);  
   121 	  | count (A::Bs) = ((inspect_pair bnd true (dest_eq A);  
   120 			      1 + count Bs)
   122 			      1 + count Bs)
   121                              handle Match => 0)
   123                              handle Match => 0)
   122 	val (_,_,Bi,_) = dest_state(state,i)
   124 	val (_,_,Bi,_) = dest_state(state,i)
   123         val j = Int.min(m, count (Logic.strip_assums_hyp Bi))
   125         val j = Int.min(m, count (Logic.strip_assums_hyp Bi))
   124     in  REPEAT_DETERM_N j     (etac thin_rl i)   THEN
   126     in  REPEAT_DETERM_N j (etac thin_rl i)  THEN  rotate_tac (m-j) i
   125         REPEAT_DETERM_N (m-j) (etac revcut_rl i)
       
   126     end);
   127     end);
   127 
   128 
   128 (*For the simpset.  Adds ALL suitable equalities, even if not first!
   129 (*For the simpset.  Adds ALL suitable equalities, even if not first!
   129   No vars are allowed here, as simpsets are built from meta-assumptions*)
   130   No vars are allowed here, as simpsets are built from meta-assumptions*)
   130 fun mk_eqs th = 
   131 fun mk_eqs th = 
   143   fun gen_hyp_subst_tac bnd i = DETERM (STATE(fn state =>
   144   fun gen_hyp_subst_tac bnd i = DETERM (STATE(fn state =>
   144 	let val (_,_,Bi,_) = dest_state(state,i)
   145 	let val (_,_,Bi,_) = dest_state(state,i)
   145 	    val n = length(Logic.strip_assums_hyp Bi) - 1
   146 	    val n = length(Logic.strip_assums_hyp Bi) - 1
   146 	    val (k,_) = eq_var bnd true Bi
   147 	    val (k,_) = eq_var bnd true Bi
   147 	in 
   148 	in 
   148 	   EVERY [REPEAT_DETERM_N k (etac revcut_rl i),
   149 	   EVERY [rotate_tac k i,
   149 		  asm_full_simp_tac hyp_subst_ss i,
   150 		  asm_full_simp_tac hyp_subst_ss i,
   150 		  etac thin_rl i,
   151 		  etac thin_rl i,
   151 		  thin_leading_eqs_tac bnd (n-k) i]
   152 		  thin_leading_eqs_tac bnd (n-k) i]
   152 	end
   153 	end
   153 	handle THM _ => no_tac | EQ_VAR => no_tac));
   154 	handle THM _ => no_tac | EQ_VAR => no_tac));