src/HOL/ex/Arith_Examples.thy
changeset 61945 1135b8de26c3
parent 61933 cf58b5b794b2
child 63950 cdc1e59aa513
equal deleted inserted replaced
61944:5d06ecfdb472 61945:1135b8de26c3
    61   by linarith
    61   by linarith
    62 
    62 
    63 lemma "(i::int) < j ==> min i j < max i j"
    63 lemma "(i::int) < j ==> min i j < max i j"
    64   by linarith
    64   by linarith
    65 
    65 
    66 lemma "(0::int) <= abs i"
    66 lemma "(0::int) <= \<bar>i\<bar>"
    67   by linarith
    67   by linarith
    68 
    68 
    69 lemma "(i::int) <= abs i"
    69 lemma "(i::int) <= \<bar>i\<bar>"
    70   by linarith
    70   by linarith
    71 
    71 
    72 lemma "abs (abs (i::int)) = abs i"
    72 lemma "\<bar>\<bar>i::int\<bar>\<bar> = \<bar>i\<bar>"
    73   by linarith
    73   by linarith
    74 
    74 
    75 text \<open>Also testing subgoals with bound variables.\<close>
    75 text \<open>Also testing subgoals with bound variables.\<close>
    76 
    76 
    77 lemma "!!x. (x::nat) <= y ==> x - y = 0"
    77 lemma "!!x. (x::nat) <= y ==> x - y = 0"
   125   by linarith
   125   by linarith
   126 
   126 
   127 lemma "-(i::int) * 1 = 0 ==> i = 0"
   127 lemma "-(i::int) * 1 = 0 ==> i = 0"
   128   by linarith
   128   by linarith
   129 
   129 
   130 lemma "[| (0::int) < abs i; abs i * 1 < abs i * j |] ==> 1 < abs i * j"
   130 lemma "[| (0::int) < \<bar>i\<bar>; \<bar>i\<bar> * 1 < \<bar>i\<bar> * j |] ==> 1 < \<bar>i\<bar> * j"
   131   by linarith
   131   by linarith
   132 
   132 
   133 
   133 
   134 subsection \<open>Meta-Logic\<close>
   134 subsection \<open>Meta-Logic\<close>
   135 
   135 
   225   by linarith
   225   by linarith
   226 
   226 
   227 text \<open>Splitting of inequalities of different type.\<close>
   227 text \<open>Splitting of inequalities of different type.\<close>
   228 
   228 
   229 lemma "[| (a::nat) ~= b; (i::int) ~= j; a < 2; b < 2 |] ==>
   229 lemma "[| (a::nat) ~= b; (i::int) ~= j; a < 2; b < 2 |] ==>
   230   a + b <= nat (max (abs i) (abs j))"
   230   a + b <= nat (max \<bar>i\<bar> \<bar>j\<bar>)"
   231   by linarith
   231   by linarith
   232 
   232 
   233 text \<open>Again, but different order.\<close>
   233 text \<open>Again, but different order.\<close>
   234 
   234 
   235 lemma "[| (i::int) ~= j; (a::nat) ~= b; a < 2; b < 2 |] ==>
   235 lemma "[| (i::int) ~= j; (a::nat) ~= b; a < 2; b < 2 |] ==>
   236   a + b <= nat (max (abs i) (abs j))"
   236   a + b <= nat (max \<bar>i\<bar> \<bar>j\<bar>)"
   237   by linarith
   237   by linarith
   238 
   238 
   239 end
   239 end