src/HOL/ex/Arith_Examples.thy
author krauss
Tue, 05 Aug 2008 14:40:48 +0200
changeset 27742 df552e6027cf
parent 24328 83afe527504d
child 30686 47a32dd1b86e
permissions -rw-r--r--
fix HOL/ex/LexOrds.thy; add to regression
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
24093
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    22
  An @{text arith}-based simproc is available as well (see @{ML
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    23
  LinArith.lin_arith_simproc}), which---for performance
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    24
  reasons---however does even less splitting than @{ML fast_arith_tac}
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    25
  at the moment (namely inequalities only).  (On the other hand, it
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    26
  does take apart conjunctions, which @{ML fast_arith_tac} currently
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    27
  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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    39
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    42
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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)"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    45
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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)"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    48
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    51
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    54
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    57
  by (tactic {* fast_arith_tac @{context} 1 *})
23208
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    60
  by (tactic {* fast_arith_tac @{context} 1 *})
23208
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    63
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    66
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    69
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    72
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    75
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    80
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    83
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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)"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    86
  by (tactic {* simple_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    89
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    92
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    95
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
    98
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   101
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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])
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   106
  by (tactic {* fast_arith_tac @{context} 1 *})
23198
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])
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   111
  by (tactic {* fast_arith_tac @{context} 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"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   114
  by (tactic {* fast_arith_tac @{context} 1 *})
23198
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])
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   119
  by (tactic {* fast_arith_tac @{context} 1 *})
23198
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 *)
24093
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
   125
  apply (tactic {* lin_arith_pre_tac @{context} 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 *)
24093
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
   130
  apply (tactic {* lin_arith_pre_tac @{context} 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
24328
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   133
lemma "-(i::int) * 1 = 0 ==> i = 0"
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   134
  by (tactic {* fast_arith_tac @{context} 1 *})
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   135
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   136
lemma "[| (0::int) < abs i; abs i * 1 < abs i * j |] ==> 1 < abs i * j"
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   137
  by (tactic {* fast_arith_tac @{context} 1 *})
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   138
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   139
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   140
subsection {* Meta-Logic *}
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   141
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   142
lemma "x < Suc y == x <= y"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   143
  by (tactic {* simple_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   144
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   145
lemma "((x::nat) == z ==> x ~= y) ==> x ~= y | z ~= y"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   146
  by (tactic {* simple_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   147
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   148
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   149
subsection {* Various Other Examples *}
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   150
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   151
lemma "(x < Suc y) = (x <= y)"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   152
  by (tactic {* simple_arith_tac @{context} 1 *})
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   153
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   154
lemma "[| (x::nat) < y; y < z |] ==> x < z"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   155
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   156
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   157
lemma "(x::nat) < y & y < z ==> x < z"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   158
  by (tactic {* simple_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   159
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   160
text {* This example involves no arithmetic at all, but is solved by
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   161
  preprocessing (i.e. NNF normalization) alone. *}
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   162
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   163
lemma "(P::bool) = Q ==> Q = P"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   164
  by (tactic {* simple_arith_tac @{context} 1 *})
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   165
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   166
lemma "[| P = (x = 0); (~P) = (y = 0) |] ==> min (x::nat) y = 0"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   167
  by (tactic {* simple_arith_tac @{context} 1 *})
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   168
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   169
lemma "[| P = (x = 0); (~P) = (y = 0) |] ==> max (x::nat) y = x + y"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   170
  by (tactic {* simple_arith_tac @{context} 1 *})
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   171
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   172
lemma "[| (x::nat) ~= y; a + 2 = b; a < y; y < b; a < x; x < b |] ==> False"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   173
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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; y > z; z > x |] ==> False"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   176
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
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) - 5 > y ==> y < x"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   179
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   180
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   181
lemma "(x::nat) ~= 0 ==> 0 < x"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   182
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   183
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   184
lemma "[| (x::nat) ~= y; x <= y |] ==> x < y"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   185
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   186
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   187
lemma "[| (x::nat) < y; P (x - y) |] ==> P 0"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   188
  by (tactic {* simple_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   189
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   190
lemma "(x - y) - (x::nat) = (x - x) - y"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   191
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   192
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   193
lemma "[| (a::nat) < b; c < d |] ==> (a - b) = (c - d)"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   194
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   195
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   196
lemma "((a::nat) - (b - (c - (d - e)))) = (a - (b - (c - (d - e))))"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   197
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   198
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   199
lemma "(n < m & m < n') | (n < m & m = n') | (n < n' & n' < m) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   200
  (n = n' & n' < m) | (n = m & m < n') |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   201
  (n' < m & m < n) | (n' < m & m = n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   202
  (n' < n & n < m) | (n' = n & n < m) | (n' = m & m < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   203
  (m < n & n < n') | (m < n & n' = n) | (m < n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   204
  (m = n & n < n') | (m = n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   205
  (n' = m & m = (n::nat))"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   206
(* FIXME: this should work in principle, but is extremely slow because     *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   207
(*        preprocessing negates the goal and tries to compute its negation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   208
(*        normal form, which creates lots of separate cases for this       *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   209
(*        disjunction of conjunctions                                      *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   210
(* by (tactic {* simple_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
lemma "2 * (x::nat) ~= 1"
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   214
(* FIXME: this is beyond the scope of the decision procedure at the moment, *)
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   215
(*        because its negation is satisfiable in the rationals?             *)
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   216
(* by (tactic {* fast_arith_tac 1 *}) *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   217
oops
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   218
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   219
text {* Constants. *}
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   220
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   221
lemma "(0::nat) < 1"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   222
  by (tactic {* fast_arith_tac @{context} 1 *})
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   223
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   224
lemma "(0::int) < 1"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   225
  by (tactic {* fast_arith_tac @{context} 1 *})
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   226
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   227
lemma "(47::nat) + 11 < 08 * 15"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   228
  by (tactic {* fast_arith_tac @{context} 1 *})
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   229
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   230
lemma "(47::int) + 11 < 08 * 15"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   231
  by (tactic {* fast_arith_tac @{context} 1 *})
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   232
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   233
text {* Splitting of inequalities of different type. *}
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   234
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   235
lemma "[| (a::nat) ~= b; (i::int) ~= j; a < 2; b < 2 |] ==>
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   236
  a + b <= nat (max (abs i) (abs j))"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   237
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   238
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   239
text {* Again, but different order. *}
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   240
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   241
lemma "[| (i::int) ~= j; (a::nat) ~= b; a < 2; b < 2 |] ==>
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   242
  a + b <= nat (max (abs i) (abs j))"
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23218
diff changeset
   243
  by (tactic {* fast_arith_tac @{context} 1 *})
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   244
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   245
(*
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   246
ML {* reset trace_arith; *}
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   247
*)
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   248
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   249
end