src/HOL/ex/Arith_Examples.thy
author wenzelm
Sat, 05 Jan 2019 17:24:33 +0100
changeset 69597 ff784d5a5bfb
parent 63950 cdc1e59aa513
child 70356 4a327c061870
permissions -rw-r--r--
isabelle update -u control_cartouches;
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
    Author: Tjark Weber
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     3
*)
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     4
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
     5
section \<open>Arithmetic\<close>
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
     6
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
     7
theory Arith_Examples
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
     8
imports Main
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
     9
begin
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    10
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
    11
text \<open>
61933
cf58b5b794b2 isabelle update_cartouches -c -t;
wenzelm
parents: 61343
diff changeset
    12
  The \<open>arith\<close> method is used frequently throughout the Isabelle
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    13
  distribution.  This file merely contains some additional tests and special
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    14
  corner cases.  Some rather technical remarks:
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    15
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    16
  \<^ML>\<open>Lin_Arith.simple_tac\<close> is a very basic version of the tactic.  It performs no
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    17
  meta-to-object-logic conversion, and only some splitting of operators.
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    18
  \<^ML>\<open>Lin_Arith.tac\<close> performs meta-to-object-logic conversion, full
61933
cf58b5b794b2 isabelle update_cartouches -c -t;
wenzelm
parents: 61343
diff changeset
    19
  splitting of operators, and NNF normalization of the goal.  The \<open>arith\<close>
cf58b5b794b2 isabelle update_cartouches -c -t;
wenzelm
parents: 61343
diff changeset
    20
  method combines them both, and tries other methods (e.g.~\<open>presburger\<close>)
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    21
  as well.  This is the one that you should use in your proofs!
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    22
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    23
  An \<open>arith\<close>-based simproc is available as well (see \<^ML>\<open>Lin_Arith.simproc\<close>), which---for performance
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    24
  reasons---however does even less splitting than \<^ML>\<open>Lin_Arith.simple_tac\<close>
24093
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    25
  at the moment (namely inequalities only).  (On the other hand, it
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    26
  does take apart conjunctions, which \<^ML>\<open>Lin_Arith.simple_tac\<close> currently
24093
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
    27
  does not do.)
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
    28
\<close>
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    29
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    30
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    31
subsection \<open>Splitting of Operators: \<^term>\<open>max\<close>, \<^term>\<open>min\<close>, \<^term>\<open>abs\<close>,
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    32
           \<^term>\<open>minus\<close>, \<^term>\<open>nat\<close>, \<^term>\<open>modulo\<close>,
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 63950
diff changeset
    33
           \<^term>\<open>divide\<close>\<close>
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    34
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    35
lemma "(i::nat) <= max i j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    36
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    37
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    38
lemma "(i::int) <= max i j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    39
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    40
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    41
lemma "min i j <= (i::nat)"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    42
  by linarith
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::int)"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    45
  by linarith
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::nat) j <= max i j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    48
  by linarith
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::int) j <= max i j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    51
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    52
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    53
lemma "min (i::nat) j + max i j = i + j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    54
  by linarith
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    55
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    56
lemma "min (i::int) j + max i j = i + j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    57
  by linarith
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
    58
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    59
lemma "(i::nat) < j ==> min i j < max i j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    60
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    61
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    62
lemma "(i::int) < j ==> min i j < max i j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    63
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    64
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61933
diff changeset
    65
lemma "(0::int) <= \<bar>i\<bar>"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    66
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    67
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61933
diff changeset
    68
lemma "(i::int) <= \<bar>i\<bar>"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    69
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    70
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61933
diff changeset
    71
lemma "\<bar>\<bar>i::int\<bar>\<bar> = \<bar>i\<bar>"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    72
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    73
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
    74
text \<open>Also testing subgoals with bound variables.\<close>
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    75
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    76
lemma "!!x. (x::nat) <= y ==> x - y = 0"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    77
  by linarith
23193
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 = 0 ==> x <= y"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    80
  by linarith
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) = (x - y = 0)"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    83
  by linarith
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::nat) < y; d < 1 |] ==> x - y = d"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    86
  by linarith
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 - x = d - x"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    89
  by linarith
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::int) < y ==> x - y < 0"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    92
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    93
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    94
lemma "nat (i + j) <= nat i + nat j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    95
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    96
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
    97
lemma "i < j ==> nat (i - j) = 0"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
    98
  by linarith
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::nat) mod 0 = i"
46597
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   101
  (* rule split_mod is only declared by default for numerals *)
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   102
  using split_mod [of _ _ "0", arith_split]
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   103
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   104
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   105
lemma "(i::nat) mod 1 = 0"
46597
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   106
  (* rule split_mod is only declared by default for numerals *)
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   107
  using split_mod [of _ _ "1", arith_split]
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   108
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   109
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   110
lemma "(i::nat) mod 42 <= 41"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   111
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   112
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   113
lemma "(i::int) mod 0 = i"
46597
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   114
  (* rule split_zmod is only declared by default for numerals *)
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   115
  using split_zmod [of _ _ "0", arith_split]
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   116
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   117
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   118
lemma "(i::int) mod 1 = 0"
46597
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   119
  (* rule split_zmod is only declared by default for numerals *)
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   120
  using split_zmod [of _ _ "1", arith_split]
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   121
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   122
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   123
lemma "(i::int) mod 42 <= 41"
46597
7fc239ebece2 deal with FIXMEs for linarith examples
huffman
parents: 44654
diff changeset
   124
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   125
24328
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   126
lemma "-(i::int) * 1 = 0 ==> i = 0"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   127
  by linarith
24328
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   128
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61933
diff changeset
   129
lemma "[| (0::int) < \<bar>i\<bar>; \<bar>i\<bar> * 1 < \<bar>i\<bar> * j |] ==> 1 < \<bar>i\<bar> * j"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   130
  by linarith
24328
83afe527504d fixed a bug in demult: -a in (-a * b) is no longer treated as atomic
webertj
parents: 24093
diff changeset
   131
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   132
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   133
subsection \<open>Meta-Logic\<close>
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   134
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   135
lemma "x < Suc y == x <= y"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   136
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   137
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   138
lemma "((x::nat) == z ==> x ~= y) ==> x ~= y | z ~= y"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   139
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   140
23218
01c4d19f597e use antiquotations instead of raw TeX code;
wenzelm
parents: 23211
diff changeset
   141
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   142
subsection \<open>Various Other Examples\<close>
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   143
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   144
lemma "(x < Suc y) = (x <= y)"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   145
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   146
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   147
lemma "[| (x::nat) < y; y < z |] ==> x < z"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   148
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   149
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   150
lemma "(x::nat) < y & y < z ==> x < z"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   151
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   152
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   153
text \<open>This example involves no arithmetic at all, but is solved by
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   154
  preprocessing (i.e. NNF normalization) alone.\<close>
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   155
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   156
lemma "(P::bool) = Q ==> Q = P"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   157
  by linarith
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   158
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   159
lemma "[| P = (x = 0); (~P) = (y = 0) |] ==> min (x::nat) y = 0"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   160
  by linarith
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   161
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   162
lemma "[| P = (x = 0); (~P) = (y = 0) |] ==> max (x::nat) y = x + y"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   163
  by linarith
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   164
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   165
lemma "[| (x::nat) ~= y; a + 2 = b; a < y; y < b; a < x; x < b |] ==> False"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   166
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   167
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   168
lemma "[| (x::nat) > y; y > z; z > x |] ==> False"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   169
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   170
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   171
lemma "(x::nat) - 5 > y ==> y < x"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   172
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   173
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   174
lemma "(x::nat) ~= 0 ==> 0 < x"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   175
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   176
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   177
lemma "[| (x::nat) ~= y; x <= y |] ==> x < y"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   178
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   179
23196
fabf2e8a7ba4 tracing disabled
webertj
parents: 23193
diff changeset
   180
lemma "[| (x::nat) < y; P (x - y) |] ==> P 0"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   181
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   182
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   183
lemma "(x - y) - (x::nat) = (x - x) - y"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   184
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   185
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   186
lemma "[| (a::nat) < b; c < d |] ==> (a - b) = (c - d)"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   187
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   188
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   189
lemma "((a::nat) - (b - (c - (d - e)))) = (a - (b - (c - (d - e))))"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   190
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   191
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   192
lemma "(n < m & m < n') | (n < m & m = n') | (n < n' & n' < m) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   193
  (n = n' & n' < m) | (n = m & m < n') |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   194
  (n' < m & m < n) | (n' < m & m = n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   195
  (n' < n & n < m) | (n' = n & n < m) | (n' = m & m < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   196
  (m < n & n < n') | (m < n & n' = n) | (m < n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   197
  (m = n & n < n') | (m = n' & n' < n) |
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   198
  (n' = m & m = (n::nat))"
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   199
(* FIXME: this should work in principle, but is extremely slow because     *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   200
(*        preprocessing negates the goal and tries to compute its negation *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   201
(*        normal form, which creates lots of separate cases for this       *)
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   202
(*        disjunction of conjunctions                                      *)
31101
26c7bb764a38 qualified names for Lin_Arith tactics and simprocs
haftmann
parents: 31100
diff changeset
   203
(* by (tactic {* Lin_Arith.tac 1 *}) *)
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   204
oops
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   205
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   206
lemma "2 * (x::nat) ~= 1"
23208
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   207
(* FIXME: this is beyond the scope of the decision procedure at the moment, *)
4d8a0976fa1c extended
webertj
parents: 23198
diff changeset
   208
(*        because its negation is satisfiable in the rationals?             *)
31101
26c7bb764a38 qualified names for Lin_Arith tactics and simprocs
haftmann
parents: 31100
diff changeset
   209
(* by (tactic {* Lin_Arith.simple_tac 1 *}) *)
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   210
oops
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   211
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   212
text \<open>Constants.\<close>
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   213
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   214
lemma "(0::nat) < 1"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   215
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   216
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   217
lemma "(0::int) < 1"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   218
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   219
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46597
diff changeset
   220
lemma "(47::nat) + 11 < 8 * 15"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   221
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   222
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46597
diff changeset
   223
lemma "(47::int) + 11 < 8 * 15"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   224
  by linarith
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   225
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   226
text \<open>Splitting of inequalities of different type.\<close>
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   227
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   228
lemma "[| (a::nat) ~= b; (i::int) ~= j; a < 2; b < 2 |] ==>
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61933
diff changeset
   229
  a + b <= nat (max \<bar>i\<bar> \<bar>j\<bar>)"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   230
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   231
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60429
diff changeset
   232
text \<open>Again, but different order.\<close>
23198
174b5f2ec7c1 extended
webertj
parents: 23196
diff changeset
   233
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   234
lemma "[| (i::int) ~= j; (a::nat) ~= b; a < 2; b < 2 |] ==>
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61933
diff changeset
   235
  a + b <= nat (max \<bar>i\<bar> \<bar>j\<bar>)"
31066
972c870da225 explicit method linarith
haftmann
parents: 30686
diff changeset
   236
  by linarith
23193
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   237
1f2d94b6a8ef some tests for arith added
webertj
parents:
diff changeset
   238
end