882 fun trace_term a sg t = if !trace_simp then prtm a sg t else (); |
882 fun trace_term a sg t = if !trace_simp then prtm a sg t else (); |
883 |
883 |
884 fun trace_thm a (Thm{sign,prop,...}) = trace_term a sign prop; |
884 fun trace_thm a (Thm{sign,prop,...}) = trace_term a sign prop; |
885 |
885 |
886 fun check_conv(thm as Thm{sign,hyps,prop,...}, prop0) = |
886 fun check_conv(thm as Thm{sign,hyps,prop,...}, prop0) = |
887 let fun err() = (trace_term "Proved wrong thm" sign prop; |
887 let fun err() = (trace_thm "Proved wrong thm (Check subgoaler?)" thm; None) |
888 error "Check your prover") |
|
889 val (lhs0,_) = Logic.dest_equals(Logic.strip_imp_concl prop0) |
888 val (lhs0,_) = Logic.dest_equals(Logic.strip_imp_concl prop0) |
890 in case prop of |
889 in case prop of |
891 Const("==",_) $ lhs $ rhs => |
890 Const("==",_) $ lhs $ rhs => |
892 if (lhs = lhs0) orelse |
891 if (lhs = lhs0) orelse |
893 (lhs aconv (Envir.norm_term (Envir.empty 0) lhs0)) |
892 (lhs aconv (Envir.norm_term (Envir.empty 0) lhs0)) |
894 then (trace_thm "SUCCEEDED" thm; ((sign,hyps),rhs)) |
893 then (trace_thm "SUCCEEDED" thm; Some((sign,hyps),rhs)) |
895 else err() |
894 else err() |
896 | _ => err() |
895 | _ => err() |
897 end; |
896 end; |
898 |
897 |
899 (*Conversion to apply the meta simpset to a term*) |
898 (*Conversion to apply the meta simpset to a term*) |
910 then let val (_,rhs) = Logic.dest_equals prop' |
909 then let val (_,rhs) = Logic.dest_equals prop' |
911 in trace_thm "Rewriting:" thm'; Some((sign',hyps'),rhs) end |
910 in trace_thm "Rewriting:" thm'; Some((sign',hyps'),rhs) end |
912 else (trace_thm "Trying to rewrite:" thm'; |
911 else (trace_thm "Trying to rewrite:" thm'; |
913 case prover mss thm' of |
912 case prover mss thm' of |
914 None => (trace_thm "FAILED" thm'; None) |
913 None => (trace_thm "FAILED" thm'; None) |
915 | Some(thm2) => Some(check_conv(thm2,prop'))) |
914 | Some(thm2) => check_conv(thm2,prop')) |
916 end |
915 end |
917 |
916 |
918 fun rewl [] = None |
917 fun rewl [] = None |
919 | rewl (rrule::rrules) = |
918 | rewl (rrule::rrules) = |
920 let val opt = rew rrule handle Pattern.MATCH => None |
919 let val opt = rew rrule handle Pattern.MATCH => None |
934 error("Congruence rule did not match") |
933 error("Congruence rule did not match") |
935 val prop' = subst_vars insts prop; |
934 val prop' = subst_vars insts prop; |
936 val thm' = Thm{sign=sign', hyps=hyps union hypst, |
935 val thm' = Thm{sign=sign', hyps=hyps union hypst, |
937 prop=prop', maxidx=maxidx} |
936 prop=prop', maxidx=maxidx} |
938 val unit = trace_thm "Applying congruence rule" thm'; |
937 val unit = trace_thm "Applying congruence rule" thm'; |
|
938 fun err() = error("Failed congruence proof!") |
939 |
939 |
940 in case prover thm' of |
940 in case prover thm' of |
941 None => error("Failed congruence proof!") |
941 None => err() |
942 | Some(thm2) => check_conv(thm2,prop') |
942 | Some(thm2) => (case check_conv(thm2,prop') of |
|
943 None => err() | Some(x) => x) |
943 end; |
944 end; |
944 |
945 |
945 |
946 |
946 fun bottomc prover = |
947 fun bottomc prover = |
947 let fun botc mss trec = let val trec1 = subc mss trec |
948 let fun botc mss trec = let val trec1 = subc mss trec |