fixed bug in handling of new numerals -- the left-hand side of "Numeral1 = 1" should be left alone and not translated to a built-in Kodkod numeral in the specification of the "numeral" function
authorblanchet
Thu, 26 Apr 2012 20:09:38 +0200
changeset 47782 1678955ca991
parent 47781 49381b55b2c1
child 47783 0eadfb89badb
fixed bug in handling of new numerals -- the left-hand side of "Numeral1 = 1" should be left alone and not translated to a built-in Kodkod numeral in the specification of the "numeral" function
src/HOL/Tools/Nitpick/nitpick_hol.ML
--- a/src/HOL/Tools/Nitpick/nitpick_hol.ML	Thu Apr 26 19:44:18 2012 +0200
+++ b/src/HOL/Tools/Nitpick/nitpick_hol.ML	Thu Apr 26 20:09:38 2012 +0200
@@ -1642,14 +1642,20 @@
          let
            val j = mult * (HOLogic.dest_num t1)
                    |> T = nat_T ? Integer.max 0
-           val s = numeral_prefix ^ signed_string_of_int j
          in
-           if is_integer_like_type T then
-             if is_standard_datatype thy stds T then Const (s, T)
-             else funpow j (curry (op $) (suc_const T)) (zero_const T)
+           if j = 1 then
+             raise SAME ()
            else
-             do_term depth Ts (Const (@{const_name of_int}, int_T --> T)
-                               $ Const (s, int_T))
+             let
+               val s = numeral_prefix ^ signed_string_of_int j
+             in
+               if is_integer_like_type T then
+                 if is_standard_datatype thy stds T then Const (s, T)
+                 else funpow j (curry (op $) (suc_const T)) (zero_const T)
+               else
+                 do_term depth Ts (Const (@{const_name of_int}, int_T --> T)
+                                   $ Const (s, int_T))
+             end
          end
          handle TERM _ => raise SAME ()
        else