src/HOL/ex/Arith_Examples.thy
author webertj
Sat, 02 Jun 2007 20:14:38 +0200
changeset 23208 4d8a0976fa1c
parent 23198 174b5f2ec7c1
child 23211 4d56ad10b5e8
permissions -rw-r--r--
extended
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     1
(*  Title:  HOL/ex/Arith_Examples.thy
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     2
    ID:     $Id$
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     3
    Author: Tjark Weber
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     4
*)
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     5
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     6
header {* {\tt arith} *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     7
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     8
theory Arith_Examples imports Main begin
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     9
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    10
text {*
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    11
  The {\tt arith} tactic is used frequently throughout the Isabelle
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    12
  distribution.  This file merely contains some additional tests and special
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    13
  corner cases.  Some rather technical remarks:
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    14
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    15
  {\tt fast_arith_tac} is a very basic version of the tactic.  It performs no
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    16
  meta-to-object-logic conversion, and only some splitting of operators.
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    17
  {\tt simple_arith_tac} performs meta-to-object-logic conversion, full
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    18
  splitting of operators, and NNF normalization of the goal.  The {\tt arith}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    19
  tactic combines them both, and tries other tactics (e.g.~{\tt presburger})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    20
  as well.  This is the one that you should use in your proofs!
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    21
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    22
  An {\tt arith}-based simproc is available as well (see {\tt
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    23
  Fast_Arith.lin_arith_prover}), which---for performance reasons---however
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    24
  does even less splitting than {\tt fast_arith_tac} at the moment (namely
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    25
  inequalities only).  (On the other hand, it does take apart conjunctions,
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    26
  which {\tt fast_arith_tac} currently does not do.)
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    27
*}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    28
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
    29
(*
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    30
ML {* set trace_arith; *}
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
    31
*)
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    32
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    33
section {* Splitting of Operators: @{term max}, @{term min}, @{term abs},
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    34
           @{term HOL.minus}, @{term nat}, @{term Divides.mod},
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    35
           @{term Divides.div} *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    36
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    37
lemma "(i::nat) <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    38
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    39
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    40
lemma "(i::int) <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    41
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    42
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    43
lemma "min i j <= (i::nat)"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    44
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    45
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    46
lemma "min i j <= (i::int)"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    47
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    48
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    49
lemma "min (i::nat) j <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    50
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    51
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    52
lemma "min (i::int) j <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    53
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    54
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    55
lemma "min (i::nat) j + max i j = i + j"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    56
  by (tactic {* fast_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    57
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    58
lemma "min (i::int) j + max i j = i + j"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    59
  by (tactic {* fast_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    60
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    61
lemma "(i::nat) < j ==> min i j < max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    62
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    63
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    64
lemma "(i::int) < j ==> min i j < max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    65
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    66
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    67
lemma "(0::int) <= abs i"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    68
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    69
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    70
lemma "(i::int) <= abs i"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    71
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    72
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    73
lemma "abs (abs (i::int)) = abs i"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    74
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    75
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    76
text {* Also testing subgoals with bound variables. *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    77
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    78
lemma "!!x. (x::nat) <= y ==> x - y = 0"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    79
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    80
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    81
lemma "!!x. (x::nat) - y = 0 ==> x <= y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    82
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    83
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    84
lemma "!!x. ((x::nat) <= y) = (x - y = 0)"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    85
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    86
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    87
lemma "[| (x::nat) < y; d < 1 |] ==> x - y = d"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    88
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    89
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    90
lemma "[| (x::nat) < y; d < 1 |] ==> x - y - x = d - x"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    91
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    92
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    93
lemma "(x::int) < y ==> x - y < 0"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    94
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    95
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    96
lemma "nat (i + j) <= nat i + nat j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    97
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    98
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    99
lemma "i < j ==> nat (i - j) = 0"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   100
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   101
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   102
lemma "(i::nat) mod 0 = i"
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   103
  (* FIXME: need to replace 0 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   104
  apply (subst nat_numeral_0_eq_0 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   105
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   106
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   107
lemma "(i::nat) mod 1 = 0"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   108
  (* FIXME: need to replace 1 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   109
  apply (subst nat_numeral_1_eq_1 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   110
  by (tactic {* fast_arith_tac 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   111
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   112
lemma "(i::nat) mod 42 <= 41"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   113
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   114
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   115
lemma "(i::int) mod 0 = i"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   116
  (* FIXME: need to replace 0 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   117
  apply (subst numeral_0_eq_0 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   118
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   119
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   120
lemma "(i::int) mod 1 = 0"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   121
  (* FIXME: need to replace 1 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   122
  apply (subst numeral_1_eq_1 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   123
  (* FIXME: arith does not know about iszero *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   124
  apply (tactic {* LA_Data_Ref.pre_tac 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   125
oops
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   126
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   127
lemma "(i::int) mod 42 <= 41"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   128
  (* FIXME: arith does not know about iszero *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   129
  apply (tactic {* LA_Data_Ref.pre_tac 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   130
oops
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   131
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   132
section {* Meta-Logic *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   133
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   134
lemma "x < Suc y == x <= y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   135
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   136
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   137
lemma "((x::nat) == z ==> x ~= y) ==> x ~= y | z ~= y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   138
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   139
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   140
section {* Various Other Examples *}
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   141
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   142
lemma "(x < Suc y) = (x <= y)"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   143
  by (tactic {* simple_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   144
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   145
lemma "[| (x::nat) < y; y < z |] ==> x < z"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   146
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   147
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   148
lemma "(x::nat) < y & y < z ==> x < z"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   149
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   150
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   151
text {* This example involves no arithmetic at all, but is solved by
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   152
  preprocessing (i.e. NNF normalization) alone. *}
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   153
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   154
lemma "(P::bool) = Q ==> Q = P"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   155
  by (tactic {* simple_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   156
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   157
lemma "[| P = (x = 0); (~P) = (y = 0) |] ==> min (x::nat) y = 0"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   158
  by (tactic {* simple_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   159
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   160
lemma "[| P = (x = 0); (~P) = (y = 0) |] ==> max (x::nat) y = x + y"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   161
  by (tactic {* simple_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   162
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   163
lemma "[| (x::nat) ~= y; a + 2 = b; a < y; y < b; a < x; x < b |] ==> False"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   164
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   165
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   166
lemma "[| (x::nat) > y; y > z; z > x |] ==> False"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   167
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   168
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   169
lemma "(x::nat) - 5 > y ==> y < x"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   170
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   171
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   172
lemma "(x::nat) ~= 0 ==> 0 < x"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   173
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   174
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   175
lemma "[| (x::nat) ~= y; x <= y |] ==> x < y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   176
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   177
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   178
lemma "[| (x::nat) < y; P (x - y) |] ==> P 0"
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   179
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   180
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   181
lemma "(x - y) - (x::nat) = (x - x) - y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   182
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   183
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   184
lemma "[| (a::nat) < b; c < d |] ==> (a - b) = (c - d)"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   185
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   186
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   187
lemma "((a::nat) - (b - (c - (d - e)))) = (a - (b - (c - (d - e))))"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   188
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   189
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   190
lemma "(n < m & m < n') | (n < m & m = n') | (n < n' & n' < m) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   191
  (n = n' & n' < m) | (n = m & m < n') |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   192
  (n' < m & m < n) | (n' < m & m = n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   193
  (n' < n & n < m) | (n' = n & n < m) | (n' = m & m < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   194
  (m < n & n < n') | (m < n & n' = n) | (m < n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   195
  (m = n & n < n') | (m = n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   196
  (n' = m & m = (n::nat))"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   197
(* FIXME: this should work in principle, but is extremely slow because     *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   198
(*        preprocessing negates the goal and tries to compute its negation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   199
(*        normal form, which creates lots of separate cases for this       *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   200
(*        disjunction of conjunctions                                      *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   201
(* by (tactic {* simple_arith_tac 1 *}) *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   202
oops
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   203
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   204
lemma "2 * (x::nat) ~= 1"
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   205
(* FIXME: this is beyond the scope of the decision procedure at the moment, *)
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   206
(*        because its negation is satisfiable in the rationals?             *)
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   207
(* by (tactic {* fast_arith_tac 1 *}) *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   208
oops
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   209
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   210
text {* Constants. *}
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   211
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   212
lemma "(0::nat) < 1"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   213
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   214
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   215
lemma "(0::int) < 1"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   216
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   217
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   218
lemma "(47::nat) + 11 < 08 * 15"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   219
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   220
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   221
lemma "(47::int) + 11 < 08 * 15"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   222
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   223
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   224
text {* Splitting of inequalities of different type. *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   225
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   226
lemma "[| (a::nat) ~= b; (i::int) ~= j; a < 2; b < 2 |] ==>
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   227
  a + b <= nat (max (abs i) (abs j))"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   228
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   229
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   230
text {* Again, but different order. *}
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   231
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   232
lemma "[| (i::int) ~= j; (a::nat) ~= b; a < 2; b < 2 |] ==>
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   233
  a + b <= nat (max (abs i) (abs j))"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   234
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   235
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   236
(*
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   237
ML {* reset trace_arith; *}
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   238
*)
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   239
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   240
end