fix soundness bug in Nitpick's handling of negative literals (e.g., -1::rat)
authorblanchet
Tue, 24 Nov 2009 13:22:18 +0100
changeset 33882 9db7854eafc7
parent 33881 d8958955ecb5
child 33883 b19493866894
child 33884 a0c43f185fef
fix soundness bug in Nitpick's handling of negative literals (e.g., -1::rat)
src/HOL/Tools/Nitpick/HISTORY
src/HOL/Tools/Nitpick/nitpick_hol.ML
--- a/src/HOL/Tools/Nitpick/HISTORY	Tue Nov 24 12:29:08 2009 +0100
+++ b/src/HOL/Tools/Nitpick/HISTORY	Tue Nov 24 13:22:18 2009 +0100
@@ -11,7 +11,7 @@
     the formula to falsify
   * Added support for codatatype view of datatypes
   * Fixed soundness bugs related to sets, sets of sets, (co)inductive
-    predicates, typedefs, and "finite"
+    predicates, typedefs, "finite", and negative literals
   * Fixed monotonicity check
   * Fixed error when processing definitions
   * Fixed error in "star_linear_preds" optimization
--- a/src/HOL/Tools/Nitpick/nitpick_hol.ML	Tue Nov 24 12:29:08 2009 +0100
+++ b/src/HOL/Tools/Nitpick/nitpick_hol.ML	Tue Nov 24 13:22:18 2009 +0100
@@ -1440,7 +1440,7 @@
         ((if is_number_type thy ran_T then
             let
               val j = t1 |> HOLogic.dest_numeral
-                         |> ran_T <> int_T ? curry Int.max 0
+                         |> ran_T = nat_T ? Integer.max 0
               val s = numeral_prefix ^ signed_string_of_int j
             in
               if is_integer_type ran_T then
@@ -1656,7 +1656,7 @@
        let
          val binders_T = HOLogic.mk_tupleT (binder_types T)
          val rel_T = HOLogic.mk_prodT (binders_T, binders_T) --> bool_T
-         val j = List.foldl Int.max 0 (map maxidx_of_term intro_ts) + 1
+         val j = fold Integer.max (map maxidx_of_term intro_ts) 0 + 1
          val rel = (("R", j), rel_T)
          val prop = Const (@{const_name wf}, rel_T --> bool_T) $ Var rel ::
                     map (wf_constraint_for_triple rel) triples
@@ -2922,7 +2922,7 @@
   let
     val (bounds1, bounds2) = pairself (map Var o special_bounds) (ts1, ts2)
     val Ts = binder_types T
-    val max_j = fold (fold (curry Int.max)) [js1, js2] ~1
+    val max_j = fold (fold Integer.max) [js1, js2] ~1
     val (eqs, (args1, args2)) =
       fold (fn j => case pairself (fn ps => AList.lookup (op =) ps j)
                                   (js1 ~~ ts1, js2 ~~ ts2) of