| 16417 |      1 | theory Calc imports Main begin
 | 
| 13999 |      2 | 
 | 
|  |      3 | subsection{* Chains of equalities *}
 | 
|  |      4 | 
 | 
|  |      5 | axclass
 | 
|  |      6 |   group < zero, plus, minus
 | 
|  |      7 |   assoc:       "(x + y) + z = x + (y + z)"
 | 
|  |      8 |   left_0:      "0 + x = x"
 | 
|  |      9 |   left_minus:  "-x + x = 0"
 | 
|  |     10 | 
 | 
|  |     11 | theorem right_minus: "x + -x = (0::'a::group)"
 | 
|  |     12 | proof -
 | 
|  |     13 |   have   "x + -x = (-(-x) + -x) + (x + -x)"
 | 
|  |     14 |     by (simp only: left_0 left_minus)
 | 
|  |     15 |   also have "... = -(-x) + ((-x + x) + -x)"
 | 
|  |     16 |     by (simp only: group.assoc)
 | 
|  |     17 |   also have "... = 0"
 | 
|  |     18 |     by (simp only: left_0 left_minus)
 | 
|  |     19 |   finally show ?thesis .
 | 
|  |     20 | qed
 | 
|  |     21 | 
 | 
|  |     22 | subsection{* Inequalities and substitution *}
 | 
|  |     23 | 
 | 
|  |     24 | lemmas distrib = zadd_zmult_distrib zadd_zmult_distrib2
 | 
|  |     25 |                  zdiff_zmult_distrib zdiff_zmult_distrib2
 | 
|  |     26 | declare numeral_2_eq_2[simp]
 | 
|  |     27 | 
 | 
|  |     28 | 
 | 
|  |     29 | lemma fixes a :: int shows "(a+b)\<twosuperior> \<le> 2*(a\<twosuperior> + b\<twosuperior>)"
 | 
|  |     30 | proof -
 | 
|  |     31 |        have "(a+b)\<twosuperior> \<le> (a+b)\<twosuperior> + (a-b)\<twosuperior>"  by simp
 | 
|  |     32 |   also have "(a+b)\<twosuperior> \<le> a\<twosuperior> + b\<twosuperior> + 2*a*b"  by(simp add:distrib)
 | 
|  |     33 |   also have "(a-b)\<twosuperior> = a\<twosuperior> + b\<twosuperior> - 2*a*b"  by(simp add:distrib)
 | 
|  |     34 |   finally show ?thesis by simp
 | 
|  |     35 | qed
 | 
|  |     36 | 
 | 
|  |     37 | 
 | 
|  |     38 | subsection{* More transitivity *}
 | 
|  |     39 | 
 | 
|  |     40 | lemma assumes R: "(a,b) \<in> R" "(b,c) \<in> R" "(c,d) \<in> R"
 | 
|  |     41 |       shows "(a,d) \<in> R\<^sup>*"
 | 
|  |     42 | proof -
 | 
|  |     43 |        have "(a,b) \<in> R\<^sup>*" ..
 | 
|  |     44 |   also have "(b,c) \<in> R\<^sup>*" ..
 | 
|  |     45 |   also have "(c,d) \<in> R\<^sup>*" ..
 | 
|  |     46 |   finally show ?thesis .
 | 
|  |     47 | qed
 | 
|  |     48 | 
 | 
|  |     49 | end |