doc-src/TutorialI/Types/Numbers.thy
author paulson
Tue, 17 Dec 2002 11:04:58 +0100
changeset 13757 33b84d172c97
parent 12843 50bd380e6675
child 14288 d149e3cbdb39
permissions -rw-r--r--
new int induction rules
     1 (* ID:         $Id$ *)
     2 theory Numbers = Real:
     3 
     4 ML "Pretty.setmargin 64"
     5 ML "IsarOutput.indent := 0"  (*we don't want 5 for listing theorems*)
     6 
     7 text{*
     8 
     9 numeric literals; default simprules; can re-orient
    10 *}
    11 
    12 lemma "2 * m = m + m"
    13 txt{*
    14 @{subgoals[display,indent=0,margin=65]}
    15 *};
    16 oops
    17 
    18 consts h :: "nat \<Rightarrow> nat"
    19 recdef h "{}"
    20 "h i = (if i = 3 then 2 else i)"
    21 
    22 text{*
    23 @{term"h 3 = 2"}
    24 @{term"h i  = i"}
    25 *}
    26 
    27 text{*
    28 @{thm[display] numeral_0_eq_0[no_vars]}
    29 \rulename{numeral_0_eq_0}
    30 
    31 @{thm[display] numeral_1_eq_1[no_vars]}
    32 \rulename{numeral_1_eq_1}
    33 
    34 @{thm[display] add_2_eq_Suc[no_vars]}
    35 \rulename{add_2_eq_Suc}
    36 
    37 @{thm[display] add_2_eq_Suc'[no_vars]}
    38 \rulename{add_2_eq_Suc'}
    39 
    40 @{thm[display] add_assoc[no_vars]}
    41 \rulename{add_assoc}
    42 
    43 @{thm[display] add_commute[no_vars]}
    44 \rulename{add_commute}
    45 
    46 @{thm[display] add_left_commute[no_vars]}
    47 \rulename{add_left_commute}
    48 
    49 these form add_ac; similarly there is mult_ac
    50 *}
    51 
    52 lemma "Suc(i + j*l*k + m*n) = f (n*m + i + k*j*l)"
    53 txt{*
    54 @{subgoals[display,indent=0,margin=65]}
    55 *};
    56 apply (simp add: add_ac mult_ac)
    57 txt{*
    58 @{subgoals[display,indent=0,margin=65]}
    59 *};
    60 oops
    61 
    62 text{*
    63 @{thm[display] mult_le_mono[no_vars]}
    64 \rulename{mult_le_mono}
    65 
    66 @{thm[display] mult_less_mono1[no_vars]}
    67 \rulename{mult_less_mono1}
    68 
    69 @{thm[display] div_le_mono[no_vars]}
    70 \rulename{div_le_mono}
    71 
    72 @{thm[display] add_mult_distrib[no_vars]}
    73 \rulename{add_mult_distrib}
    74 
    75 @{thm[display] diff_mult_distrib[no_vars]}
    76 \rulename{diff_mult_distrib}
    77 
    78 @{thm[display] mod_mult_distrib[no_vars]}
    79 \rulename{mod_mult_distrib}
    80 
    81 @{thm[display] nat_diff_split[no_vars]}
    82 \rulename{nat_diff_split}
    83 *}
    84 
    85 
    86 lemma "(n - 1) * (n + 1) = n * n - (1::nat)"
    87 apply (clarsimp split: nat_diff_split iff del: less_Suc0)
    88  --{* @{subgoals[display,indent=0,margin=65]} *}
    89 apply (subgoal_tac "n=0", force, arith)
    90 done
    91 
    92 
    93 lemma "(n - 2) * (n + 2) = n * n - (4::nat)"
    94 apply (simp split: nat_diff_split, clarify)
    95  --{* @{subgoals[display,indent=0,margin=65]} *}
    96 apply (subgoal_tac "n=0 | n=1", force, arith)
    97 done
    98 
    99 text{*
   100 @{thm[display] mod_if[no_vars]}
   101 \rulename{mod_if}
   102 
   103 @{thm[display] mod_div_equality[no_vars]}
   104 \rulename{mod_div_equality}
   105 
   106 
   107 @{thm[display] div_mult1_eq[no_vars]}
   108 \rulename{div_mult1_eq}
   109 
   110 @{thm[display] mod_mult1_eq[no_vars]}
   111 \rulename{mod_mult1_eq}
   112 
   113 @{thm[display] div_mult2_eq[no_vars]}
   114 \rulename{div_mult2_eq}
   115 
   116 @{thm[display] mod_mult2_eq[no_vars]}
   117 \rulename{mod_mult2_eq}
   118 
   119 @{thm[display] div_mult_mult1[no_vars]}
   120 \rulename{div_mult_mult1}
   121 
   122 @{thm[display] DIVISION_BY_ZERO_DIV[no_vars]}
   123 \rulename{DIVISION_BY_ZERO_DIV}
   124 
   125 @{thm[display] DIVISION_BY_ZERO_MOD[no_vars]}
   126 \rulename{DIVISION_BY_ZERO_MOD}
   127 
   128 @{thm[display] dvd_anti_sym[no_vars]}
   129 \rulename{dvd_anti_sym}
   130 
   131 @{thm[display] dvd_add[no_vars]}
   132 \rulename{dvd_add}
   133 
   134 For the integers, I'd list a few theorems that somehow involve negative 
   135 numbers.*}
   136 
   137 
   138 text{*
   139 Division, remainder of negatives
   140 
   141 
   142 @{thm[display] pos_mod_sign[no_vars]}
   143 \rulename{pos_mod_sign}
   144 
   145 @{thm[display] pos_mod_bound[no_vars]}
   146 \rulename{pos_mod_bound}
   147 
   148 @{thm[display] neg_mod_sign[no_vars]}
   149 \rulename{neg_mod_sign}
   150 
   151 @{thm[display] neg_mod_bound[no_vars]}
   152 \rulename{neg_mod_bound}
   153 
   154 @{thm[display] zdiv_zadd1_eq[no_vars]}
   155 \rulename{zdiv_zadd1_eq}
   156 
   157 @{thm[display] zmod_zadd1_eq[no_vars]}
   158 \rulename{zmod_zadd1_eq}
   159 
   160 @{thm[display] zdiv_zmult1_eq[no_vars]}
   161 \rulename{zdiv_zmult1_eq}
   162 
   163 @{thm[display] zmod_zmult1_eq[no_vars]}
   164 \rulename{zmod_zmult1_eq}
   165 
   166 @{thm[display] zdiv_zmult2_eq[no_vars]}
   167 \rulename{zdiv_zmult2_eq}
   168 
   169 @{thm[display] zmod_zmult2_eq[no_vars]}
   170 \rulename{zmod_zmult2_eq}
   171 
   172 @{thm[display] abs_mult[no_vars]}
   173 \rulename{abs_mult}
   174 *}  
   175 
   176 lemma "abs (x+y) \<le> abs x + abs (y :: int)"
   177 by arith
   178 
   179 lemma "abs (2*x) = 2 * abs (x :: int)"
   180 by (simp add: zabs_def) 
   181 
   182 
   183 text {*Induction rules for the Integers
   184 
   185 @{thm[display] int_ge_induct[no_vars]}
   186 \rulename{int_ge_induct}
   187 
   188 @{thm[display] int_gr_induct[no_vars]}
   189 \rulename{int_gr_induct}
   190 
   191 @{thm[display] int_le_induct[no_vars]}
   192 \rulename{int_le_induct}
   193 
   194 @{thm[display] int_less_induct[no_vars]}
   195 \rulename{int_less_induct}
   196 *}  
   197 
   198 text {*REALS
   199 
   200 @{thm[display] realpow_abs[no_vars]}
   201 \rulename{realpow_abs}
   202 
   203 @{thm[display] real_dense[no_vars]}
   204 \rulename{real_dense}
   205 
   206 @{thm[display] realpow_abs[no_vars]}
   207 \rulename{realpow_abs}
   208 
   209 @{thm[display] real_times_divide1_eq[no_vars]}
   210 \rulename{real_times_divide1_eq}
   211 
   212 @{thm[display] real_times_divide2_eq[no_vars]}
   213 \rulename{real_times_divide2_eq}
   214 
   215 @{thm[display] real_divide_divide1_eq[no_vars]}
   216 \rulename{real_divide_divide1_eq}
   217 
   218 @{thm[display] real_divide_divide2_eq[no_vars]}
   219 \rulename{real_divide_divide2_eq}
   220 
   221 @{thm[display] real_minus_divide_eq[no_vars]}
   222 \rulename{real_minus_divide_eq}
   223 
   224 @{thm[display] real_divide_minus_eq[no_vars]}
   225 \rulename{real_divide_minus_eq}
   226 
   227 This last NOT a simprule
   228 
   229 @{thm[display] real_add_divide_distrib[no_vars]}
   230 \rulename{real_add_divide_distrib}
   231 *}
   232 
   233 lemma "3/4 < (7/8 :: real)"
   234 by simp 
   235 
   236 lemma "P ((3/4) * (8/15 :: real))"
   237 txt{*
   238 @{subgoals[display,indent=0,margin=65]}
   239 *};
   240 apply simp 
   241 txt{*
   242 @{subgoals[display,indent=0,margin=65]}
   243 *};
   244 oops
   245 
   246 lemma "(3/4) * (8/15) < (x :: real)"
   247 txt{*
   248 @{subgoals[display,indent=0,margin=65]}
   249 *};
   250 apply simp 
   251 txt{*
   252 @{subgoals[display,indent=0,margin=65]}
   253 *};
   254 oops
   255 
   256 lemma "(3/4) * (10^15) < (x :: real)"
   257 apply simp 
   258 oops
   259 
   260 
   261 
   262 end