src/FOLP/simp.ML
changeset 33955 fff6f11b1f09
parent 33339 d41f77196338
child 35021 c839a4c670c6
equal deleted inserted replaced
33954:1bc3b688548c 33955:fff6f11b1f09
   417 fun simp_lhs(thm,ss,anet,ats,cs) =
   417 fun simp_lhs(thm,ss,anet,ats,cs) =
   418     if var_lhs(thm,i) then (ss,thm,anet,ats,cs) else
   418     if var_lhs(thm,i) then (ss,thm,anet,ats,cs) else
   419     if lhs_is_NORM(thm,i) then (ss, res1(thm,trans_norms,i), anet,ats,cs)
   419     if lhs_is_NORM(thm,i) then (ss, res1(thm,trans_norms,i), anet,ats,cs)
   420     else case Seq.pull(cong_tac i thm) of
   420     else case Seq.pull(cong_tac i thm) of
   421             SOME(thm',_) =>
   421             SOME(thm',_) =>
   422                     let val ps = prems_of thm and ps' = prems_of thm';
   422                     let val ps = prems_of thm
       
   423                         and ps' = prems_of thm';
   423                         val n = length(ps')-length(ps);
   424                         val n = length(ps')-length(ps);
   424                         val a = length(Logic.strip_assums_hyp(List.nth(ps,i-1)))
   425                         val a = length(Logic.strip_assums_hyp(List.nth(ps,i-1)))
   425                         val l = map (fn p => length(Logic.strip_assums_hyp(p)))
   426                         val l = map (length o Logic.strip_assums_hyp) (take n (drop (i-1) ps'));
   426                                     (Library.take(n,Library.drop(i-1,ps')));
       
   427                     in (simp_refl(rev(l),a,REW::ss),thm',anet,ats,cs) end
   427                     in (simp_refl(rev(l),a,REW::ss),thm',anet,ats,cs) end
   428           | NONE => (REW::ss,thm,anet,ats,cs);
   428           | NONE => (REW::ss,thm,anet,ats,cs);
   429 
   429 
   430 (*NB: the "Adding rewrites:" trace will look strange because assumptions
   430 (*NB: the "Adding rewrites:" trace will look strange because assumptions
   431       are represented by rules, generalized over their parameters*)
   431       are represented by rules, generalized over their parameters*)
   533 
   533 
   534 
   534 
   535 fun Pinst(f,fT,(eq,eqT),k,i,T,yik,Ts) =
   535 fun Pinst(f,fT,(eq,eqT),k,i,T,yik,Ts) =
   536 let fun xn_list(x,n) =
   536 let fun xn_list(x,n) =
   537         let val ixs = map_range (fn i => (x^(radixstring(26,"a",i)),0)) (n - 1);
   537         let val ixs = map_range (fn i => (x^(radixstring(26,"a",i)),0)) (n - 1);
   538         in ListPair.map eta_Var (ixs, Library.take(n+1,Ts)) end
   538         in ListPair.map eta_Var (ixs, take (n+1) Ts) end
   539     val lhs = list_comb(f,xn_list("X",k-1))
   539     val lhs = list_comb(f,xn_list("X",k-1))
   540     val rhs = list_comb(f,xn_list("X",i-1) @ [Bound 0] @ yik)
   540     val rhs = list_comb(f,xn_list("X",i-1) @ [Bound 0] @ yik)
   541 in Abs("", T, Const(eq,[fT,fT]--->eqT) $ lhs $ rhs) end;
   541 in Abs("", T, Const(eq,[fT,fT]--->eqT) $ lhs $ rhs) end;
   542 
   542 
   543 fun find_subst sg T =
   543 fun find_subst sg T =