src/Pure/thm.ML
changeset 225 76f60e6400e8
parent 222 5eb3020f7a03
child 229 4002c4cd450c
equal deleted inserted replaced
224:d762f9421933 225:76f60e6400e8
   904      | _ => err()
   904      | _ => err()
   905   end;
   905   end;
   906 
   906 
   907 (*Conversion to apply the meta simpset to a term*)
   907 (*Conversion to apply the meta simpset to a term*)
   908 fun rewritec (prover,signt) (mss as Mss{net,...}) (hypst,t) =
   908 fun rewritec (prover,signt) (mss as Mss{net,...}) (hypst,t) =
   909   let fun rew (t, {thm as Thm{sign,hyps,maxidx,prop,...}, lhs}) =
   909   let val t = Pattern.eta_contract t;
       
   910       fun rew {thm as Thm{sign,hyps,maxidx,prop,...}, lhs} =
   910 	let val unit = if Sign.subsig(sign,signt) then ()
   911 	let val unit = if Sign.subsig(sign,signt) then ()
   911                   else (writeln"Warning: rewrite rule from different theory";
   912                   else (writeln"Warning: rewrite rule from different theory";
   912                         raise Pattern.MATCH)
   913                         raise Pattern.MATCH)
   913             val insts = Pattern.match (#tsig(Sign.rep_sg signt)) (lhs,t)
   914             val insts = Pattern.match (#tsig(Sign.rep_sg signt)) (lhs,t)
   914             val prop' = subst_vars insts prop;
   915             val prop' = subst_vars insts prop;
   921                  case prover mss thm' of
   922                  case prover mss thm' of
   922                    None       => (trace_thm "FAILED" thm'; None)
   923                    None       => (trace_thm "FAILED" thm'; None)
   923                  | Some(thm2) => check_conv(thm2,prop'))
   924                  | Some(thm2) => check_conv(thm2,prop'))
   924         end
   925         end
   925 
   926 
   926       fun rews t =
   927       fun rews [] = None
   927         let fun rews1 [] = None
   928         | rews (rrule::rrules) =
   928               | rews1 (rrule::rrules) =
   929             let val opt = rew rrule handle Pattern.MATCH => None
   929                   let val opt = rew(t,rrule) handle Pattern.MATCH => None
   930             in case opt of None => rews rrules | some => some end;
   930                   in case opt of None => rews1 rrules | some => some end;
       
   931         in rews1 end
       
   932 
       
   933       fun eta_rews([]) = None
       
   934         | eta_rews(rrules) = rews (Pattern.eta_contract t) rrules
       
   935 
   931 
   936   in case t of
   932   in case t of
   937        Abs(_,_,body) $ u => Some(hypst,subst_bounds([u], body))
   933        Abs(_,_,body) $ u => Some(hypst,subst_bounds([u], body))
   938      | _                 => eta_rews(Net.match_term net t)
   934      | _                 => rews(Net.match_term net t)
   939   end;
   935   end;
   940 
   936 
   941 (*Conversion to apply a congruence rule to a term*)
   937 (*Conversion to apply a congruence rule to a term*)
   942 fun congc (prover,signt) {thm=cong,lhs=lhs} (hypst,t) =
   938 fun congc (prover,signt) {thm=cong,lhs=lhs} (hypst,t) =
   943   let val Thm{sign,hyps,maxidx,prop,...} = cong
   939   let val Thm{sign,hyps,maxidx,prop,...} = cong