src/HOL/ex/Arith_Examples.thy
author wenzelm
Sun, 03 Jun 2007 23:16:46 +0200
changeset 23218 01c4d19f597e
parent 23211 4d56ad10b5e8
child 24075 366d4d234814
permissions -rw-r--r--
use antiquotations instead of raw TeX code; tuned document;
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
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
     6
header {* Arithmetic *}
23193
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 {*
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    11
  The @{text arith} method is used frequently throughout the Isabelle
23193
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
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    15
  @{ML fast_arith_tac} is a very basic version of the tactic.  It performs no
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    16
  meta-to-object-logic conversion, and only some splitting of operators.
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    17
  @{ML simple_arith_tac} performs meta-to-object-logic conversion, full
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    18
  splitting of operators, and NNF normalization of the goal.  The @{text arith}
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    19
  method combines them both, and tries other methods (e.g.~@{text presburger})
23193
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
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    22
  An @{text arith}-based simproc is available as well
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    23
  (see @{ML Fast_Arith.lin_arith_prover}),
23211
4d56ad10b5e8 fixed tex error
nipkow
parents: 23208
diff changeset
    24
  which---for performance reasons---however
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    25
  does even less splitting than @{ML fast_arith_tac} at the moment (namely
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    26
  inequalities only).  (On the other hand, it does take apart conjunctions,
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    27
  which @{ML fast_arith_tac} currently does not do.)
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    28
*}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    29
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
    30
(*
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    31
ML {* set trace_arith; *}
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
    32
*)
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    33
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
    34
subsection {* Splitting of Operators: @{term max}, @{term min}, @{term abs},
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    35
           @{term HOL.minus}, @{term nat}, @{term Divides.mod},
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    36
           @{term Divides.div} *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    37
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    38
lemma "(i::nat) <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    39
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    40
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    41
lemma "(i::int) <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    42
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    43
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    44
lemma "min i j <= (i::nat)"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    45
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    46
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    47
lemma "min i j <= (i::int)"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    48
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    49
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    50
lemma "min (i::nat) j <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    51
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    52
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    53
lemma "min (i::int) j <= max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    54
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    55
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    56
lemma "min (i::nat) j + max i j = i + j"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    57
  by (tactic {* fast_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    58
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    59
lemma "min (i::int) j + max i j = i + j"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    60
  by (tactic {* fast_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    61
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    62
lemma "(i::nat) < j ==> min i j < max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    63
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    64
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    65
lemma "(i::int) < j ==> min i j < max i j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    66
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    67
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    68
lemma "(0::int) <= abs i"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    69
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    70
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    71
lemma "(i::int) <= abs i"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    72
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    73
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    74
lemma "abs (abs (i::int)) = abs i"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    75
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    76
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    77
text {* Also testing subgoals with bound variables. *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    78
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    79
lemma "!!x. (x::nat) <= y ==> x - y = 0"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    80
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    81
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    82
lemma "!!x. (x::nat) - y = 0 ==> x <= y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    83
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    84
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    85
lemma "!!x. ((x::nat) <= y) = (x - y = 0)"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    86
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    87
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    88
lemma "[| (x::nat) < y; d < 1 |] ==> x - y = d"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    89
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    90
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    91
lemma "[| (x::nat) < y; d < 1 |] ==> x - y - x = d - x"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    92
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    93
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    94
lemma "(x::int) < y ==> x - y < 0"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    95
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    96
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    97
lemma "nat (i + j) <= nat i + nat j"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    98
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    99
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   100
lemma "i < j ==> nat (i - j) = 0"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   101
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   102
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   103
lemma "(i::nat) mod 0 = i"
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   104
  (* FIXME: need to replace 0 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   105
  apply (subst nat_numeral_0_eq_0 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   106
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   107
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   108
lemma "(i::nat) mod 1 = 0"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   109
  (* FIXME: need to replace 1 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   110
  apply (subst nat_numeral_1_eq_1 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   111
  by (tactic {* fast_arith_tac 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   112
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   113
lemma "(i::nat) mod 42 <= 41"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   114
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   115
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   116
lemma "(i::int) mod 0 = i"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   117
  (* FIXME: need to replace 0 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   118
  apply (subst numeral_0_eq_0 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   119
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   120
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   121
lemma "(i::int) mod 1 = 0"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   122
  (* FIXME: need to replace 1 by its numeral representation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   123
  apply (subst numeral_1_eq_1 [symmetric])
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   124
  (* FIXME: arith does not know about iszero *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   125
  apply (tactic {* LA_Data_Ref.pre_tac 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   126
oops
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   127
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   128
lemma "(i::int) mod 42 <= 41"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   129
  (* FIXME: arith does not know about iszero *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   130
  apply (tactic {* LA_Data_Ref.pre_tac 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   131
oops
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   132
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   133
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   134
subsection {* Meta-Logic *}
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   135
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   136
lemma "x < Suc y == x <= y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   137
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   138
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   139
lemma "((x::nat) == z ==> x ~= y) ==> x ~= y | z ~= y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   140
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   141
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   142
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   143
subsection {* Various Other Examples *}
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   144
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   145
lemma "(x < Suc y) = (x <= y)"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   146
  by (tactic {* simple_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   147
23193
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 {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   150
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   151
lemma "(x::nat) < y & y < z ==> x < z"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   152
  by (tactic {* simple_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   153
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   154
text {* This example involves no arithmetic at all, but is solved by
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   155
  preprocessing (i.e. NNF normalization) alone. *}
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   156
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   157
lemma "(P::bool) = Q ==> Q = P"
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) |] ==> min (x::nat) y = 0"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   161
  by (tactic {* simple_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   162
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   163
lemma "[| P = (x = 0); (~P) = (y = 0) |] ==> max (x::nat) y = x + y"
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   164
  by (tactic {* simple_arith_tac 1 *})
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   165
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   166
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
   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) > y; y > z; z > x |] ==> False"
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) - 5 > y ==> y < 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) ~= 0 ==> 0 < x"
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
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   178
lemma "[| (x::nat) ~= y; x <= y |] ==> x < y"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   179
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   180
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   181
lemma "[| (x::nat) < y; P (x - y) |] ==> P 0"
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   182
  by (tactic {* simple_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 "(x - y) - (x::nat) = (x - x) - y"
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 |] ==> (a - b) = (c - d)"
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
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   190
lemma "((a::nat) - (b - (c - (d - e)))) = (a - (b - (c - (d - e))))"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   191
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   192
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   193
lemma "(n < m & m < n') | (n < m & m = n') | (n < n' & n' < m) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   194
  (n = n' & n' < m) | (n = m & m < n') |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   195
  (n' < m & m < n) | (n' < m & m = n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   196
  (n' < n & n < m) | (n' = n & n < m) | (n' = m & m < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   197
  (m < n & n < n') | (m < n & n' = n) | (m < n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   198
  (m = n & n < n') | (m = n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   199
  (n' = m & m = (n::nat))"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   200
(* FIXME: this should work in principle, but is extremely slow because     *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   201
(*        preprocessing negates the goal and tries to compute its negation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   202
(*        normal form, which creates lots of separate cases for this       *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   203
(*        disjunction of conjunctions                                      *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   204
(* by (tactic {* simple_arith_tac 1 *}) *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   205
oops
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   206
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   207
lemma "2 * (x::nat) ~= 1"
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   208
(* FIXME: this is beyond the scope of the decision procedure at the moment, *)
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   209
(*        because its negation is satisfiable in the rationals?             *)
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   210
(* by (tactic {* fast_arith_tac 1 *}) *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   211
oops
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   212
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   213
text {* Constants. *}
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   214
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   215
lemma "(0::nat) < 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 "(0::int) < 1"
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::nat) + 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
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   224
lemma "(47::int) + 11 < 08 * 15"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   225
  by (tactic {* fast_arith_tac 1 *})
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   226
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   227
text {* Splitting of inequalities of different type. *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   228
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   229
lemma "[| (a::nat) ~= b; (i::int) ~= j; a < 2; b < 2 |] ==>
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   230
  a + b <= nat (max (abs i) (abs j))"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   231
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   232
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   233
text {* Again, but different order. *}
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   234
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   235
lemma "[| (i::int) ~= j; (a::nat) ~= b; a < 2; b < 2 |] ==>
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   236
  a + b <= nat (max (abs i) (abs j))"
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   237
  by (tactic {* fast_arith_tac 1 *})
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   238
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   239
(*
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   240
ML {* reset trace_arith; *}
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   241
*)
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   242
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   243
end