src/FOLP/simp.ML
changeset 29265 5b4247055bd7
parent 26939 1035c89b4c02
child 30190 479806475f3c
equal deleted inserted replaced
29264:4ea3358fac3f 29265:5b4247055bd7
     1 (*  Title:      FOLP/simp
     1 (*  Title:      FOLP/simp.ML
     2     ID:         $Id$
       
     3     Author:     Tobias Nipkow
     2     Author:     Tobias Nipkow
     4     Copyright   1993  University of Cambridge
     3     Copyright   1993  University of Cambridge
     5 
     4 
     6 FOLP version of...
     5 FOLP version of...
     7 
     6 
   154 val atomic = null o Logic.strip_assums_hyp;
   153 val atomic = null o Logic.strip_assums_hyp;
   155 
   154 
   156 (*ccs contains the names of the constants possessing congruence rules*)
   155 (*ccs contains the names of the constants possessing congruence rules*)
   157 fun add_hidden_vars ccs =
   156 fun add_hidden_vars ccs =
   158   let fun add_hvars tm hvars = case tm of
   157   let fun add_hvars tm hvars = case tm of
   159               Abs(_,_,body) => add_term_vars(body,hvars)
   158               Abs(_,_,body) => OldTerm.add_term_vars(body,hvars)
   160             | _$_ => let val (f,args) = strip_comb tm 
   159             | _$_ => let val (f,args) = strip_comb tm 
   161                      in case f of
   160                      in case f of
   162                             Const(c,T) => 
   161                             Const(c,T) => 
   163                                 if member (op =) ccs c
   162                                 if member (op =) ccs c
   164                                 then fold_rev add_hvars args hvars
   163                                 then fold_rev add_hvars args hvars
   165                                 else add_term_vars (tm, hvars)
   164                                 else OldTerm.add_term_vars (tm, hvars)
   166                           | _ => add_term_vars (tm, hvars)
   165                           | _ => OldTerm.add_term_vars (tm, hvars)
   167                      end
   166                      end
   168             | _ => hvars;
   167             | _ => hvars;
   169   in add_hvars end;
   168   in add_hvars end;
   170 
   169 
   171 fun add_new_asm_vars new_asms =
   170 fun add_new_asm_vars new_asms =
   172     let fun itf (tm, at) vars =
   171     let fun itf (tm, at) vars =
   173                 if at then vars else add_term_vars(tm,vars)
   172                 if at then vars else OldTerm.add_term_vars(tm,vars)
   174         fun add_list(tm,al,vars) = let val (_,tml) = strip_comb tm
   173         fun add_list(tm,al,vars) = let val (_,tml) = strip_comb tm
   175                 in if length(tml)=length(al)
   174                 in if length(tml)=length(al)
   176                    then fold_rev itf (tml ~~ al) vars
   175                    then fold_rev itf (tml ~~ al) vars
   177                    else vars
   176                    else vars
   178                 end
   177                 end
   196     val asms = tl(rev(tl(prems_of thm')))
   195     val asms = tl(rev(tl(prems_of thm')))
   197     val hvars = fold_rev (add_hidden_vars ccs) (lhs::rhs::asms) []
   196     val hvars = fold_rev (add_hidden_vars ccs) (lhs::rhs::asms) []
   198     val hvars = add_new_asm_vars new_asms (rhs,hvars)
   197     val hvars = add_new_asm_vars new_asms (rhs,hvars)
   199     fun it_asms asm hvars =
   198     fun it_asms asm hvars =
   200         if atomic asm then add_new_asm_vars new_asms (asm,hvars)
   199         if atomic asm then add_new_asm_vars new_asms (asm,hvars)
   201         else add_term_frees(asm,hvars)
   200         else OldTerm.add_term_frees(asm,hvars)
   202     val hvars = fold_rev it_asms asms hvars
   201     val hvars = fold_rev it_asms asms hvars
   203     val hvs = map (#1 o dest_Var) hvars
   202     val hvs = map (#1 o dest_Var) hvars
   204     val refl1_tac = refl_tac 1
   203     val refl1_tac = refl_tac 1
   205     fun norm_step_tac st = st |>
   204     fun norm_step_tac st = st |>
   206 	 (case head_of(rhs_of_eq 1 st) of
   205 	 (case head_of(rhs_of_eq 1 st) of
   540 in Abs("", T, Const(eq,[fT,fT]--->eqT) $ lhs $ rhs) end;
   539 in Abs("", T, Const(eq,[fT,fT]--->eqT) $ lhs $ rhs) end;
   541 
   540 
   542 fun find_subst sg T =
   541 fun find_subst sg T =
   543 let fun find (thm::thms) =
   542 let fun find (thm::thms) =
   544         let val (Const(_,cT), va, vb) = dest_red(hd(prems_of thm));
   543         let val (Const(_,cT), va, vb) = dest_red(hd(prems_of thm));
   545             val [P] = add_term_vars(concl_of thm,[]) \\ [va,vb]
   544             val [P] = OldTerm.add_term_vars(concl_of thm,[]) \\ [va,vb]
   546             val eqT::_ = binder_types cT
   545             val eqT::_ = binder_types cT
   547         in if Sign.typ_instance sg (T,eqT) then SOME(thm,va,vb,P)
   546         in if Sign.typ_instance sg (T,eqT) then SOME(thm,va,vb,P)
   548            else find thms
   547            else find thms
   549         end
   548         end
   550       | find [] = NONE
   549       | find [] = NONE