workaround for bug in weight handling -- sometimes numerals got replaced by Vars and this confused the weight extractor
authorblanchet
Wed, 15 Dec 2010 14:29:04 +0100
changeset 41165 ceb81a08534e
parent 41162 2181c47a02fe
child 41166 4b2a457b17e8
child 41172 a17c2d669c40
workaround for bug in weight handling -- sometimes numerals got replaced by Vars and this confused the weight extractor
src/HOL/Tools/SMT/smt_translate.ML
--- a/src/HOL/Tools/SMT/smt_translate.ML	Wed Dec 15 13:35:50 2010 +0100
+++ b/src/HOL/Tools/SMT/smt_translate.ML	Wed Dec 15 14:29:04 2010 +0100
@@ -496,7 +496,14 @@
   | group_quant _ Ts t = (Ts, t)
 
 fun dest_weight (@{const SMT.weight} $ w $ t) =
-      (SOME (snd (HOLogic.dest_number w)), t)
+      ((SOME (snd (HOLogic.dest_number w)), t)
+       handle TERM _ =>
+                (case w of
+                  Var ((s, _), _) => (* FIXME: temporary workaround *)
+                    (case Int.fromString s of
+                      SOME n => (SOME n, t)
+                    | NONE => raise TERM ("bad weight", [w]))
+                 | _ => raise TERM ("bad weight", [w])))
   | dest_weight t = (NONE, t)
 
 fun dest_pat (Const (@{const_name pat}, _) $ t) = (t, true)