| 1 |
needs "Formal_ineqs/lib/ssrbool.hl";; |
| 2 |
|
| 3 |
(* Module Ssrnat*) |
| 4 |
module Ssrnat = struct |
| 5 |
|
| 6 |
open Ssreflect;; |
| 7 |
open Ssrbool;; |
| 8 |
overload_interface("+", `XOR`);; |
| 9 |
prioritize_num();; |
| 10 |
|
| 11 |
(* Lemma succnK *) |
| 12 |
let succnK = Sections.section_proof ["n"] |
| 13 |
`SUC n - 1 = n` |
| 14 |
[ |
| 15 |
((arith_tac) THEN (done_tac)); |
| 16 |
];; |
| 17 |
|
| 18 |
(* Lemma succn_inj *) |
| 19 |
let succn_inj = Sections.section_proof ["n";"m"] |
| 20 |
`SUC n = SUC m ==> n = m` |
| 21 |
[ |
| 22 |
((arith_tac) THEN (done_tac)); |
| 23 |
];; |
| 24 |
|
| 25 |
(* Lemma eqSS *) |
| 26 |
let eqSS = Sections.section_proof ["m";"n"] |
| 27 |
`(SUC m = SUC n) = (m = n)` |
| 28 |
[ |
| 29 |
((arith_tac) THEN (done_tac)); |
| 30 |
];; |
| 31 |
|
| 32 |
(* Lemma add0n *) |
| 33 |
let add0n = Sections.section_proof ["n"] |
| 34 |
`0 + n = n` |
| 35 |
[ |
| 36 |
((arith_tac) THEN (done_tac)); |
| 37 |
];; |
| 38 |
|
| 39 |
(* Lemma addSn *) |
| 40 |
let addSn = Sections.section_proof ["m";"n"] |
| 41 |
`SUC m + n = SUC (m + n)` |
| 42 |
[ |
| 43 |
((arith_tac) THEN (done_tac)); |
| 44 |
];; |
| 45 |
|
| 46 |
(* Lemma add1n *) |
| 47 |
let add1n = Sections.section_proof ["n"] |
| 48 |
`1 + n = SUC n` |
| 49 |
[ |
| 50 |
((arith_tac) THEN (done_tac)); |
| 51 |
];; |
| 52 |
|
| 53 |
(* Lemma addn0 *) |
| 54 |
let addn0 = Sections.section_proof ["n"] |
| 55 |
`n + 0 = n` |
| 56 |
[ |
| 57 |
((arith_tac) THEN (done_tac)); |
| 58 |
];; |
| 59 |
|
| 60 |
(* Lemma addnS *) |
| 61 |
let addnS = Sections.section_proof ["m";"n"] |
| 62 |
`m + SUC n = SUC (m + n)` |
| 63 |
[ |
| 64 |
((arith_tac) THEN (done_tac)); |
| 65 |
];; |
| 66 |
|
| 67 |
(* Lemma addSnnS *) |
| 68 |
let addSnnS = Sections.section_proof ["m";"n"] |
| 69 |
`SUC m + n = m + SUC n` |
| 70 |
[ |
| 71 |
((arith_tac) THEN (done_tac)); |
| 72 |
];; |
| 73 |
|
| 74 |
(* Lemma addnCA *) |
| 75 |
let addnCA = Sections.section_proof ["m";"n";"p"] |
| 76 |
`m + (n + p) = n + (m + p)` |
| 77 |
[ |
| 78 |
((arith_tac) THEN (done_tac)); |
| 79 |
];; |
| 80 |
|
| 81 |
(* Lemma addnC *) |
| 82 |
let addnC = Sections.section_proof ["m";"n"] |
| 83 |
`m + n = n + m` |
| 84 |
[ |
| 85 |
(((((fun arg_tac -> (use_arg_then2 ("addn0", [addn0])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (((use_arg_then2 ("addnCA", [addnCA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addn0", [addn0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 86 |
];; |
| 87 |
|
| 88 |
(* Lemma addn1 *) |
| 89 |
let addn1 = Sections.section_proof ["n"] |
| 90 |
`n + 1 = SUC n` |
| 91 |
[ |
| 92 |
(((((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 93 |
];; |
| 94 |
|
| 95 |
(* Lemma addnA *) |
| 96 |
let addnA = Sections.section_proof ["n";"m";"p"] |
| 97 |
`n + (m + p) = (n + m) + p` |
| 98 |
[ |
| 99 |
(((((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [(`m + p`)])))) THEN (((use_arg_then2 ("addnCA", [addnCA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 100 |
];; |
| 101 |
|
| 102 |
(* Lemma addnAC *) |
| 103 |
let addnAC = Sections.section_proof ["m";"n";"p"] |
| 104 |
`(n + m) + p = (n + p) + m` |
| 105 |
[ |
| 106 |
(((repeat_tactic 1 9 (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [(`p + m`)]))))) THEN (done_tac)); |
| 107 |
];; |
| 108 |
|
| 109 |
(* Lemma addn_eq0 *) |
| 110 |
let addn_eq0 = Sections.section_proof ["m";"n"] |
| 111 |
`(m + n = 0) <=> (m = 0) /\ (n = 0)` |
| 112 |
[ |
| 113 |
((arith_tac) THEN (done_tac)); |
| 114 |
];; |
| 115 |
|
| 116 |
(* Lemma eqn_addl *) |
| 117 |
let eqn_addl = Sections.section_proof ["p";"m";"n"] |
| 118 |
`(p + m = p + n) <=> (m = n)` |
| 119 |
[ |
| 120 |
((arith_tac) THEN (done_tac)); |
| 121 |
];; |
| 122 |
|
| 123 |
(* Lemma eqn_addr *) |
| 124 |
let eqn_addr = Sections.section_proof ["p";"m";"n"] |
| 125 |
`(m + p = n + p) = (m = n)` |
| 126 |
[ |
| 127 |
((arith_tac) THEN (done_tac)); |
| 128 |
];; |
| 129 |
|
| 130 |
(* Lemma addnI *) |
| 131 |
let addnI = Sections.section_proof ["m";"n1";"n2"] |
| 132 |
`m + n1 = m + n2 ==> n1 = n2` |
| 133 |
[ |
| 134 |
((BETA_TAC THEN (move ["Heq"])) THEN (((fun arg_tac -> (use_arg_then2 ("eqn_addl", [eqn_addl])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 135 |
];; |
| 136 |
|
| 137 |
(* Lemma addIn *) |
| 138 |
let addIn = Sections.section_proof ["m";"n1";"n2"] |
| 139 |
`n1 + m = n2 + m ==> n1 = n2` |
| 140 |
[ |
| 141 |
((repeat_tactic 1 9 (((use_arg_then2 ("addnC", [addnC]))(gsym_then (thm_tac (new_rewrite [] [(`_1 + m`)])))))) THEN (move ["Heq"])); |
| 142 |
((((fun arg_tac -> (use_arg_then2 ("addnI", [addnI])) (fun fst_arg -> (use_arg_then2 ("Heq", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (done_tac)); |
| 143 |
];; |
| 144 |
|
| 145 |
(* Lemma sub0n *) |
| 146 |
let sub0n = Sections.section_proof ["n"] |
| 147 |
`0 - n = 0` |
| 148 |
[ |
| 149 |
((arith_tac) THEN (done_tac)); |
| 150 |
];; |
| 151 |
|
| 152 |
(* Lemma subn0 *) |
| 153 |
let subn0 = Sections.section_proof ["n"] |
| 154 |
`n - 0 = n` |
| 155 |
[ |
| 156 |
((arith_tac) THEN (done_tac)); |
| 157 |
];; |
| 158 |
|
| 159 |
(* Lemma subnn *) |
| 160 |
let subnn = Sections.section_proof [] |
| 161 |
`!n. n - n = 0` |
| 162 |
[ |
| 163 |
((arith_tac) THEN (done_tac)); |
| 164 |
];; |
| 165 |
|
| 166 |
(* Lemma subSS *) |
| 167 |
let subSS = Sections.section_proof [] |
| 168 |
`!n m. SUC m - SUC n = m - n` |
| 169 |
[ |
| 170 |
((arith_tac) THEN (done_tac)); |
| 171 |
];; |
| 172 |
|
| 173 |
(* Lemma subn_add2l *) |
| 174 |
let subn_add2l = Sections.section_proof [] |
| 175 |
`!p m n. (p + m) - (p + n) = m - n` |
| 176 |
[ |
| 177 |
((arith_tac) THEN (done_tac)); |
| 178 |
];; |
| 179 |
|
| 180 |
(* Lemma subn_add2r *) |
| 181 |
let subn_add2r = Sections.section_proof [] |
| 182 |
`!p m n. (m + p) - (n + p) = m - n` |
| 183 |
[ |
| 184 |
(BETA_TAC THEN (move ["p"]) THEN (move ["m"]) THEN (move ["n"])); |
| 185 |
(((repeat_tactic 1 9 (((use_arg_then2 ("addnC", [addnC]))(gsym_then (thm_tac (new_rewrite [] [(`_1 + p`)])))))) THEN (((use_arg_then2 ("subn_add2l", [subn_add2l]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 186 |
];; |
| 187 |
|
| 188 |
(* Lemma addKn *) |
| 189 |
let addKn = Sections.section_proof ["n"] |
| 190 |
`!x. (n + x) - n = x` |
| 191 |
[ |
| 192 |
((BETA_TAC THEN (move ["m"])) THEN ((((use_arg_then2 ("addn0", [addn0]))(gsym_then (thm_tac (new_rewrite [2] [(`n`)]))))) THEN (((use_arg_then2 ("subn_add2l", [subn_add2l]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subn0", [subn0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 193 |
];; |
| 194 |
|
| 195 |
(* Lemma addnK *) |
| 196 |
let addnK = Sections.section_proof [] |
| 197 |
`!n x. (x + n) - n = x` |
| 198 |
[ |
| 199 |
((BETA_TAC THEN (move ["n"]) THEN (move ["m"])) THEN ((((fun arg_tac -> (use_arg_then2 ("addnC", [addnC])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addKn", [addKn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 200 |
];; |
| 201 |
|
| 202 |
(* Lemma subSnn *) |
| 203 |
let subSnn = Sections.section_proof ["n"] |
| 204 |
`SUC n - n = 1` |
| 205 |
[ |
| 206 |
(((((use_arg_then2 ("add1n", [add1n]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnK", [addnK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 207 |
];; |
| 208 |
|
| 209 |
(* Lemma subn_sub *) |
| 210 |
let subn_sub = Sections.section_proof ["m";"n";"p"] |
| 211 |
`(n - m) - p = n - (m + p)` |
| 212 |
[ |
| 213 |
((arith_tac) THEN (done_tac)); |
| 214 |
];; |
| 215 |
|
| 216 |
(* Lemma subnAC *) |
| 217 |
let subnAC = Sections.section_proof [] |
| 218 |
`!m n p. (m - n) - p = (m - p) - n` |
| 219 |
[ |
| 220 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("subn_sub", [subn_sub]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 221 |
];; |
| 222 |
|
| 223 |
(* Lemma predn_sub *) |
| 224 |
let predn_sub = Sections.section_proof [] |
| 225 |
`!m n. (m - n) - 1 = m - SUC n` |
| 226 |
[ |
| 227 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"])) THEN ((((use_arg_then2 ("subn_sub", [subn_sub]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addn1", [addn1]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 228 |
];; |
| 229 |
|
| 230 |
(* Lemma predn_subS *) |
| 231 |
let predn_subS = Sections.section_proof [] |
| 232 |
`!m n. (SUC m - n) - 1 = m - n` |
| 233 |
[ |
| 234 |
(((((use_arg_then2 ("predn_sub", [predn_sub]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subSS", [subSS]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 235 |
];; |
| 236 |
|
| 237 |
(* Lemma ltnS *) |
| 238 |
let ltnS = Sections.section_proof [] |
| 239 |
`!m n. (m < SUC n) = (m <= n)` |
| 240 |
[ |
| 241 |
((arith_tac) THEN (done_tac)); |
| 242 |
];; |
| 243 |
|
| 244 |
(* Lemma leq0n *) |
| 245 |
let leq0n = Sections.section_proof [] |
| 246 |
`!n. 0 <= n` |
| 247 |
[ |
| 248 |
((arith_tac) THEN (done_tac)); |
| 249 |
];; |
| 250 |
|
| 251 |
(* Lemma ltn0Sn *) |
| 252 |
let ltn0Sn = Sections.section_proof [] |
| 253 |
`!n. 0 < SUC n` |
| 254 |
[ |
| 255 |
((arith_tac) THEN (done_tac)); |
| 256 |
];; |
| 257 |
|
| 258 |
(* Lemma ltn0 *) |
| 259 |
let ltn0 = Sections.section_proof [] |
| 260 |
`!n. n < 0 <=> F` |
| 261 |
[ |
| 262 |
((arith_tac) THEN (done_tac)); |
| 263 |
];; |
| 264 |
|
| 265 |
(* Lemma leqnn *) |
| 266 |
let leqnn = Sections.section_proof [] |
| 267 |
`!n. n <= n` |
| 268 |
[ |
| 269 |
((arith_tac) THEN (done_tac)); |
| 270 |
];; |
| 271 |
|
| 272 |
(* Lemma ltnSn *) |
| 273 |
let ltnSn = Sections.section_proof [] |
| 274 |
`!n. n < SUC n` |
| 275 |
[ |
| 276 |
((arith_tac) THEN (done_tac)); |
| 277 |
];; |
| 278 |
|
| 279 |
(* Lemma eq_leq *) |
| 280 |
let eq_leq = Sections.section_proof [] |
| 281 |
`!m n. m = n ==> m <= n` |
| 282 |
[ |
| 283 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 284 |
];; |
| 285 |
|
| 286 |
(* Lemma leqnSn *) |
| 287 |
let leqnSn = Sections.section_proof [] |
| 288 |
`!n. n <= SUC n` |
| 289 |
[ |
| 290 |
((arith_tac) THEN (done_tac)); |
| 291 |
];; |
| 292 |
|
| 293 |
(* Lemma leq_pred *) |
| 294 |
let leq_pred = Sections.section_proof [] |
| 295 |
`!n. n - 1 <= n` |
| 296 |
[ |
| 297 |
((arith_tac) THEN (done_tac)); |
| 298 |
];; |
| 299 |
|
| 300 |
(* Lemma leqSpred *) |
| 301 |
let leqSpred = Sections.section_proof [] |
| 302 |
`!n. n <= SUC (n - 1)` |
| 303 |
[ |
| 304 |
((arith_tac) THEN (done_tac)); |
| 305 |
];; |
| 306 |
|
| 307 |
(* Lemma ltn_predK *) |
| 308 |
let ltn_predK = Sections.section_proof [] |
| 309 |
`!m n. m < n ==> SUC (n - 1) = n` |
| 310 |
[ |
| 311 |
((arith_tac) THEN (done_tac)); |
| 312 |
];; |
| 313 |
|
| 314 |
(* Lemma prednK *) |
| 315 |
let prednK = Sections.section_proof [] |
| 316 |
`!n. 0 < n ==> SUC (n - 1) = n` |
| 317 |
[ |
| 318 |
((BETA_TAC THEN (move ["n"]) THEN (move ["H"])) THEN (((fun arg_tac -> (use_arg_then2 ("ltn_predK", [ltn_predK])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (exact_tac))); |
| 319 |
];; |
| 320 |
|
| 321 |
(* Lemma leqNgt *) |
| 322 |
let leqNgt = Sections.section_proof [] |
| 323 |
`!m n. (m <= n) <=> ~(n < m)` |
| 324 |
[ |
| 325 |
((arith_tac) THEN (done_tac)); |
| 326 |
];; |
| 327 |
|
| 328 |
(* Lemma ltnNge *) |
| 329 |
let ltnNge = Sections.section_proof [] |
| 330 |
`!m n. (m < n) = ~(n <= m)` |
| 331 |
[ |
| 332 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"])) THEN (((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 333 |
];; |
| 334 |
|
| 335 |
(* Lemma ltnn *) |
| 336 |
let ltnn = Sections.section_proof [] |
| 337 |
`!n. n < n <=> F` |
| 338 |
[ |
| 339 |
((BETA_TAC THEN (move ["n"])) THEN ((((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 340 |
];; |
| 341 |
|
| 342 |
(* Lemma leqn0 *) |
| 343 |
let leqn0 = Sections.section_proof [] |
| 344 |
`!n. (n <= 0) = (n = 0)` |
| 345 |
[ |
| 346 |
((arith_tac) THEN (done_tac)); |
| 347 |
];; |
| 348 |
|
| 349 |
(* Lemma lt0n *) |
| 350 |
let lt0n = Sections.section_proof [] |
| 351 |
`!n. (0 < n) = ~(n = 0)` |
| 352 |
[ |
| 353 |
((arith_tac) THEN (done_tac)); |
| 354 |
];; |
| 355 |
|
| 356 |
(* Lemma lt0n_neq0 *) |
| 357 |
let lt0n_neq0 = Sections.section_proof [] |
| 358 |
`!n. 0 < n ==> ~(n = 0)` |
| 359 |
[ |
| 360 |
((arith_tac) THEN (done_tac)); |
| 361 |
];; |
| 362 |
|
| 363 |
(* Lemma eqn0Ngt *) |
| 364 |
let eqn0Ngt = Sections.section_proof [] |
| 365 |
`!n. (n = 0) = ~(0 < n)` |
| 366 |
[ |
| 367 |
((arith_tac) THEN (done_tac)); |
| 368 |
];; |
| 369 |
|
| 370 |
(* Lemma neq0_lt0n *) |
| 371 |
let neq0_lt0n = Sections.section_proof [] |
| 372 |
`!n. (n = 0) = F ==> 0 < n` |
| 373 |
[ |
| 374 |
((arith_tac) THEN (done_tac)); |
| 375 |
];; |
| 376 |
|
| 377 |
(* Lemma eqn_leq *) |
| 378 |
let eqn_leq = Sections.section_proof [] |
| 379 |
`!m n. (m = n) = (m <= n /\ n <= m)` |
| 380 |
[ |
| 381 |
((arith_tac) THEN (done_tac)); |
| 382 |
];; |
| 383 |
|
| 384 |
(* Lemma anti_leq *) |
| 385 |
let anti_leq = Sections.section_proof [] |
| 386 |
`!m n. m <= n /\ n <= m ==> m = n` |
| 387 |
[ |
| 388 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"])) THEN (((use_arg_then2 ("eqn_leq", [eqn_leq]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 389 |
];; |
| 390 |
|
| 391 |
(* Lemma neq_ltn *) |
| 392 |
let neq_ltn = Sections.section_proof [] |
| 393 |
`!m n. ~(m = n) <=> (m < n) \/ (n < m)` |
| 394 |
[ |
| 395 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 396 |
(((((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("negb_and", [negb_and]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("orbC", [orbC]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (done_tac)); |
| 397 |
];; |
| 398 |
|
| 399 |
(* Lemma leq_eqVlt *) |
| 400 |
let leq_eqVlt = Sections.section_proof ["m";"n"] |
| 401 |
`(m <= n) <=> (m = n) \/ (m < n)` |
| 402 |
[ |
| 403 |
((arith_tac) THEN (done_tac)); |
| 404 |
];; |
| 405 |
|
| 406 |
(* Lemma eq_sym *) |
| 407 |
let eq_sym = Sections.section_proof [] |
| 408 |
`!x y:A. x = y <=> y = x` |
| 409 |
[ |
| 410 |
((((use_arg_then2 ("EQ_SYM_EQ", [EQ_SYM_EQ])) (disch_tac [])) THEN (clear_assumption "EQ_SYM_EQ") THEN BETA_TAC) THEN (done_tac)); |
| 411 |
];; |
| 412 |
|
| 413 |
(* Lemma ltn_neqAle *) |
| 414 |
let ltn_neqAle = Sections.section_proof [] |
| 415 |
`!m n. (m < n) <=> ~(m = n) /\ (m <= n)` |
| 416 |
[ |
| 417 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 418 |
(((((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_eqVlt", [leq_eqVlt]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("negb_or", [negb_or]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqNgt", [leqNgt]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eq_sym", [eq_sym]))(thm_tac (new_rewrite [] [(`n = m`)]))))) THEN (done_tac)); |
| 419 |
];; |
| 420 |
|
| 421 |
(* Lemma leq_trans *) |
| 422 |
let leq_trans = Sections.section_proof [] |
| 423 |
`!n m p. m <= n ==> n <= p ==> m <= p` |
| 424 |
[ |
| 425 |
((arith_tac) THEN (done_tac)); |
| 426 |
];; |
| 427 |
|
| 428 |
(* Lemma ltE *) |
| 429 |
let ltE = Sections.section_proof [] |
| 430 |
`!n m. n < m <=> SUC n <= m` |
| 431 |
[ |
| 432 |
((arith_tac) THEN (done_tac)); |
| 433 |
];; |
| 434 |
|
| 435 |
(* Lemma leqSS *) |
| 436 |
let leqSS = Sections.section_proof [] |
| 437 |
`!n m. SUC n <= SUC m <=> n <= m` |
| 438 |
[ |
| 439 |
((arith_tac) THEN (done_tac)); |
| 440 |
];; |
| 441 |
|
| 442 |
(* Lemma leq_ltn_trans *) |
| 443 |
let leq_ltn_trans = Sections.section_proof [] |
| 444 |
`!n m p. m <= n ==> n < p ==> m < p` |
| 445 |
[ |
| 446 |
(BETA_TAC THEN (move ["n"]) THEN (move ["m"]) THEN (move ["p"]) THEN (move ["Hmn"])); |
| 447 |
(((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_trans", [leq_trans])) (disch_tac [])) THEN (clear_assumption "leq_trans") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then2 ("leqSS", [leqSS]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)) THEN (done_tac)); |
| 448 |
];; |
| 449 |
|
| 450 |
(* Lemma ltn_leq_trans *) |
| 451 |
let ltn_leq_trans = Sections.section_proof ["n";"m";"p"] |
| 452 |
`m < n ==> n <= p ==> m < p` |
| 453 |
[ |
| 454 |
((arith_tac) THEN (done_tac)); |
| 455 |
];; |
| 456 |
|
| 457 |
(* Lemma ltnW *) |
| 458 |
let ltnW = Sections.section_proof [] |
| 459 |
`!m n. m < n ==> m <= n` |
| 460 |
[ |
| 461 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"])) THEN (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_trans", [leq_trans])) (disch_tac [])) THEN (clear_assumption "leq_trans") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then2 ("leqnSn", [leqnSn]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 462 |
];; |
| 463 |
|
| 464 |
(* Lemma leqW *) |
| 465 |
let leqW = Sections.section_proof [] |
| 466 |
`!m n. m <= n ==> m <= SUC n` |
| 467 |
[ |
| 468 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["le_mn"])) THEN (((use_arg_then2 ("ltnW", [ltnW])) (disch_tac [])) THEN (clear_assumption "ltnW") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqSS", [leqSS]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 469 |
];; |
| 470 |
|
| 471 |
(* Lemma ltn_trans *) |
| 472 |
let ltn_trans = Sections.section_proof [] |
| 473 |
`!n m p. m < n ==> n < p ==> m < p` |
| 474 |
[ |
| 475 |
(BETA_TAC THEN (move ["n"]) THEN (move ["m"]) THEN (move ["p"]) THEN (move ["lt_mn"])); |
| 476 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("ltnW", [ltnW])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))); |
| 477 |
((((use_arg_then2 ("leq_trans", [leq_trans])) (disch_tac [])) THEN (clear_assumption "leq_trans") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 478 |
];; |
| 479 |
|
| 480 |
(* Lemma geqE *) |
| 481 |
let geqE = Sections.section_proof [] |
| 482 |
`!m n. m >= n <=> n <= m` |
| 483 |
[ |
| 484 |
((arith_tac) THEN (done_tac)); |
| 485 |
];; |
| 486 |
|
| 487 |
(* Lemma gtE *) |
| 488 |
let gtE = Sections.section_proof ["m";"n"] |
| 489 |
`m > n <=> n < m` |
| 490 |
[ |
| 491 |
(arith_tac); |
| 492 |
];; |
| 493 |
|
| 494 |
(* Lemma leq_total *) |
| 495 |
let leq_total = Sections.section_proof ["m";"n"] |
| 496 |
`(m <= n) \/ (n <= m)` |
| 497 |
[ |
| 498 |
((((((use_arg_then2 ("implyNb", [implyNb]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("ltnNge", [ltnNge]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["lt_nm"])) THEN (((use_arg_then2 ("ltnW", [ltnW])) (disch_tac [])) THEN (clear_assumption "ltnW") THEN (exact_tac)) THEN (done_tac)); |
| 499 |
];; |
| 500 |
|
| 501 |
(* Lemma leqP *) |
| 502 |
let leqP = Sections.section_proof ["m";"n"] |
| 503 |
`m <= n \/ n < m` |
| 504 |
[ |
| 505 |
((arith_tac) THEN (done_tac)); |
| 506 |
];; |
| 507 |
|
| 508 |
(* Lemma ltnP *) |
| 509 |
let ltnP = Sections.section_proof ["m";"n"] |
| 510 |
`m < n \/ n <= m` |
| 511 |
[ |
| 512 |
((arith_tac) THEN (done_tac)); |
| 513 |
];; |
| 514 |
|
| 515 |
(* Lemma posnP *) |
| 516 |
let posnP = Sections.section_proof ["n"] |
| 517 |
`n = 0 \/ 0 < n` |
| 518 |
[ |
| 519 |
((arith_tac) THEN (done_tac)); |
| 520 |
];; |
| 521 |
|
| 522 |
(* Lemma ltngtP *) |
| 523 |
let ltngtP = Sections.section_proof ["m";"n"] |
| 524 |
`m < n \/ n < m \/ m = n` |
| 525 |
[ |
| 526 |
((arith_tac) THEN (done_tac)); |
| 527 |
];; |
| 528 |
|
| 529 |
(* Lemma leq_add2l *) |
| 530 |
let leq_add2l = Sections.section_proof [] |
| 531 |
`!p m n. (p + m <= p + n) = (m <= n)` |
| 532 |
[ |
| 533 |
((arith_tac) THEN (done_tac)); |
| 534 |
];; |
| 535 |
|
| 536 |
(* Lemma ltn_add2l *) |
| 537 |
let ltn_add2l = Sections.section_proof [] |
| 538 |
`!p m n. (p + m < p + n) = (m < n)` |
| 539 |
[ |
| 540 |
(BETA_TAC THEN (move ["p"]) THEN (move ["m"]) THEN (move ["n"])); |
| 541 |
(((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnS", [addnS]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_add2l", [leq_add2l]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 542 |
];; |
| 543 |
|
| 544 |
(* Lemma leq_add2r *) |
| 545 |
let leq_add2r = Sections.section_proof ["p";"m";"n"] |
| 546 |
`(m + p <= n + p) = (m <= n)` |
| 547 |
[ |
| 548 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("addnC", [addnC])) (fun fst_arg -> (use_arg_then2 ("p", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("leq_add2l", [leq_add2l]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 549 |
];; |
| 550 |
|
| 551 |
(* Lemma ltn_add2r *) |
| 552 |
let ltn_add2r = Sections.section_proof [] |
| 553 |
`!p m n. (m + p < n + p) = (m < n)` |
| 554 |
[ |
| 555 |
(BETA_TAC THEN (move ["p"]) THEN (move ["m"]) THEN (move ["n"])); |
| 556 |
(((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addSn", [addSn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_add2r", [leq_add2r]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 557 |
];; |
| 558 |
|
| 559 |
(* Lemma leq_add *) |
| 560 |
let leq_add = Sections.section_proof [] |
| 561 |
`!m1 m2 n1 n2. m1 <= n1 ==> m2 <= n2 ==> m1 + m2 <= n1 + n2` |
| 562 |
[ |
| 563 |
(BETA_TAC THEN (move ["m1"]) THEN (move ["m2"]) THEN (move ["n1"]) THEN (move ["n2"]) THEN (move ["le_mn1"]) THEN (move ["le_mn2"])); |
| 564 |
(((((fun arg_tac -> (use_arg_then2 ("leq_trans", [leq_trans])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m1 + n2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_add2l", [leq_add2l]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_add2r", [leq_add2r]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 565 |
];; |
| 566 |
|
| 567 |
(* Lemma leq_addr *) |
| 568 |
let leq_addr = Sections.section_proof [] |
| 569 |
`!m n. n <= n + m` |
| 570 |
[ |
| 571 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 572 |
(((((use_arg_then2 ("addn0", [addn0]))(gsym_then (thm_tac (new_rewrite [1] [(`n`)]))))) THEN (((use_arg_then2 ("leq_add2l", [leq_add2l]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq0n", [leq0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 573 |
];; |
| 574 |
|
| 575 |
(* Lemma leq_addl *) |
| 576 |
let leq_addl = Sections.section_proof [] |
| 577 |
`!m n. n <= m + n` |
| 578 |
[ |
| 579 |
(((((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_addr", [leq_addr]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 580 |
];; |
| 581 |
|
| 582 |
(* Lemma ltn_addr *) |
| 583 |
let ltn_addr = Sections.section_proof ["m";"n";"p"] |
| 584 |
`m < n ==> m < n + p` |
| 585 |
[ |
| 586 |
((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN ((DISCH_THEN (fun snd_th -> (use_arg_then2 ("leq_trans", [leq_trans])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_addr", [leq_addr]))(thm_tac (new_rewrite [] []))))); |
| 587 |
];; |
| 588 |
|
| 589 |
(* Lemma ltn_addl *) |
| 590 |
let ltn_addl = Sections.section_proof [] |
| 591 |
`!m n p. m < n ==> m < p + n` |
| 592 |
[ |
| 593 |
((arith_tac) THEN (done_tac)); |
| 594 |
];; |
| 595 |
|
| 596 |
(* Lemma addn_gt0 *) |
| 597 |
let addn_gt0 = Sections.section_proof [] |
| 598 |
`!m n. (0 < m + n) <=> (0 < m) \/ (0 < n)` |
| 599 |
[ |
| 600 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 601 |
(((repeat_tactic 1 9 (((use_arg_then2 ("lt0n", [lt0n]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("negb_and", [negb_and]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addn_eq0", [addn_eq0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 602 |
];; |
| 603 |
|
| 604 |
(* Lemma subn_gt0 *) |
| 605 |
let subn_gt0 = Sections.section_proof ["m";"n"] |
| 606 |
`(0 < n - m) = (m < n)` |
| 607 |
[ |
| 608 |
((arith_tac) THEN (done_tac)); |
| 609 |
];; |
| 610 |
|
| 611 |
(* Lemma subn_eq0 *) |
| 612 |
let subn_eq0 = Sections.section_proof [] |
| 613 |
`!m n. (m - n = 0) = (m <= n)` |
| 614 |
[ |
| 615 |
((arith_tac) THEN (done_tac)); |
| 616 |
];; |
| 617 |
|
| 618 |
(* Lemma leqE *) |
| 619 |
let leqE = Sections.section_proof [] |
| 620 |
`!m n. m <= n <=> m - n = 0` |
| 621 |
[ |
| 622 |
((arith_tac) THEN (done_tac)); |
| 623 |
];; |
| 624 |
|
| 625 |
(* Lemma leq_sub_add *) |
| 626 |
let leq_sub_add = Sections.section_proof [] |
| 627 |
`!m n p. (m - n <= p) = (m <= n + p)` |
| 628 |
[ |
| 629 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])); |
| 630 |
(((((use_arg_then2 ("subn_eq0", [subn_eq0]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subn_sub", [subn_sub]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqE", [leqE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 631 |
];; |
| 632 |
|
| 633 |
(* Lemma leq_subr *) |
| 634 |
let leq_subr = Sections.section_proof [] |
| 635 |
`!m n. n - m <= n` |
| 636 |
[ |
| 637 |
(((((use_arg_then2 ("leq_sub_add", [leq_sub_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_addl", [leq_addl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 638 |
];; |
| 639 |
|
| 640 |
(* Lemma subnKC *) |
| 641 |
let subnKC = Sections.section_proof [] |
| 642 |
`!m n. m <= n ==> m + (n - m) = n` |
| 643 |
[ |
| 644 |
((arith_tac) THEN (done_tac)); |
| 645 |
];; |
| 646 |
|
| 647 |
(* Lemma subnK *) |
| 648 |
let subnK = Sections.section_proof [] |
| 649 |
`!m n. m <= n ==> (n - m) + m = n` |
| 650 |
[ |
| 651 |
((((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subnKC", [subnKC])) (disch_tac [])) THEN (clear_assumption "subnKC") THEN (exact_tac)) THEN (done_tac)); |
| 652 |
];; |
| 653 |
|
| 654 |
(* Lemma addn_subA *) |
| 655 |
let addn_subA = Sections.section_proof [] |
| 656 |
`!m n p. p <= n ==> m + (n - p) = (m + n) - p` |
| 657 |
[ |
| 658 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"]) THEN (move ["le_pn"])); |
| 659 |
(((((fun arg_tac -> (use_arg_then2 ("subnK", [subnK])) (fun fst_arg -> (use_arg_then2 ("le_pn", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [2] []))))) THEN (((use_arg_then2 ("addnA", [addnA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnK", [addnK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 660 |
];; |
| 661 |
|
| 662 |
(* Lemma subn_subA *) |
| 663 |
let subn_subA = Sections.section_proof [] |
| 664 |
`!m n p. p <= n ==> m - (n - p) = (m + p) - n` |
| 665 |
[ |
| 666 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"]) THEN (move ["le_pn"])); |
| 667 |
(((((fun arg_tac -> (use_arg_then2 ("subnK", [subnK])) (fun fst_arg -> (use_arg_then2 ("le_pn", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [2] []))))) THEN (((use_arg_then2 ("subn_add2r", [subn_add2r]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 668 |
];; |
| 669 |
|
| 670 |
(* Lemma subKn *) |
| 671 |
let subKn = Sections.section_proof [] |
| 672 |
`!m n. m <= n ==> n - (n - m) = m` |
| 673 |
[ |
| 674 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 675 |
(((DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then2 ("subn_subA", [subn_subA])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addKn", [addKn]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 676 |
];; |
| 677 |
|
| 678 |
(* Lemma leq_subS *) |
| 679 |
let leq_subS = Sections.section_proof [] |
| 680 |
`!m n. m <= n ==> SUC n - m = SUC (n - m)` |
| 681 |
[ |
| 682 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 683 |
((((use_arg_then2 ("add1n", [add1n]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then2 ("addn_subA", [addn_subA])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] []))))))); |
| 684 |
((((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 685 |
];; |
| 686 |
|
| 687 |
(* Lemma ltn_subS *) |
| 688 |
let ltn_subS = Sections.section_proof [] |
| 689 |
`!m n. m < n ==> n - m = SUC (n - SUC m)` |
| 690 |
[ |
| 691 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["lt_mn"])) THEN ((((use_arg_then2 ("leq_subS", [leq_subS]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("subSS", [subSS]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 692 |
];; |
| 693 |
|
| 694 |
(* Lemma leq_sub2r *) |
| 695 |
let leq_sub2r = Sections.section_proof [] |
| 696 |
`!p m n. m <= n ==> m - p <= n - p` |
| 697 |
[ |
| 698 |
(BETA_TAC THEN (move ["p"]) THEN (move ["m"]) THEN (move ["n"]) THEN (move ["le_mn"])); |
| 699 |
(((((use_arg_then2 ("leq_sub_add", [leq_sub_add]))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then2 ("leq_trans", [leq_trans])) (fun fst_arg -> (use_arg_then2 ("le_mn", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_sub_add", [leq_sub_add]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 700 |
];; |
| 701 |
|
| 702 |
(* Lemma leq_sub2l *) |
| 703 |
let leq_sub2l = Sections.section_proof [] |
| 704 |
`!p m n. m <= n ==> p - n <= p - m` |
| 705 |
[ |
| 706 |
((BETA_TAC THEN (move ["p"]) THEN (move ["m"]) THEN (move ["n"])) THEN ((((fun arg_tac -> (use_arg_then2 ("leq_add2r", [leq_add2r])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`p - m`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_sub_add", [leq_sub_add]))(thm_tac (new_rewrite [] [])))))); |
| 707 |
((((use_arg_then2 ("leq_trans", [leq_trans])) (disch_tac [])) THEN (clear_assumption "leq_trans") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then2 ("leq_sub_add", [leq_sub_add]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 708 |
];; |
| 709 |
|
| 710 |
(* Lemma leq_sub2 *) |
| 711 |
let leq_sub2 = Sections.section_proof [] |
| 712 |
`!m1 m2 n1 n2. m1 <= m2 ==> n2 <= n1 ==> m1 - n1 <= m2 - n2` |
| 713 |
[ |
| 714 |
(BETA_TAC THEN (move ["m1"]) THEN (move ["m2"]) THEN (move ["n1"]) THEN (move ["n2"])); |
| 715 |
(((DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then2 ("leq_sub2r", [leq_sub2r])) (fun fst_arg -> (use_arg_then2 ("n1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (move ["le_m12"])) THEN ((DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then2 ("leq_sub2l", [leq_sub2l])) (fun fst_arg -> (use_arg_then2 ("m2", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (((use_arg_then2 ("leq_trans", [leq_trans])) (disch_tac [])) THEN (clear_assumption "leq_trans") THEN (exact_tac))); |
| 716 |
];; |
| 717 |
|
| 718 |
(* Lemma ltn_sub2r *) |
| 719 |
let ltn_sub2r = Sections.section_proof [] |
| 720 |
`!p m n. p < n ==> m < n ==> m - p < n - p` |
| 721 |
[ |
| 722 |
(BETA_TAC THEN (move ["p"]) THEN (move ["m"]) THEN (move ["n"])); |
| 723 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("ltn_subS", [ltn_subS])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leqSS", [leqSS]))(thm_tac (new_rewrite [] [])))))); |
| 724 |
(((DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then2 ("leq_sub2r", [leq_sub2r])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`SUC p`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (((use_arg_then2 ("subSS", [subSS]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 725 |
];; |
| 726 |
|
| 727 |
(* Lemma ltn_sub2l *) |
| 728 |
let ltn_sub2l = Sections.section_proof [] |
| 729 |
`!p m n. m < p ==> m < n ==> p - n < p - m` |
| 730 |
[ |
| 731 |
(BETA_TAC THEN (move ["p"]) THEN (move ["m"]) THEN (move ["n"])); |
| 732 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("ltn_subS", [ltn_subS])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leqSS", [leqSS]))(thm_tac (new_rewrite [] [])))))); |
| 733 |
(((DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then2 ("leq_sub2l", [leq_sub2l])) (fun fst_arg -> (use_arg_then2 ("p", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (done_tac)); |
| 734 |
];; |
| 735 |
|
| 736 |
(* Lemma ltn_add_sub *) |
| 737 |
let ltn_add_sub = Sections.section_proof [] |
| 738 |
`!m n p. (m + n < p) = (n < p - m)` |
| 739 |
[ |
| 740 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])); |
| 741 |
(((repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_sub_add", [leq_sub_add]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 742 |
];; |
| 743 |
let maxn = new_definition `maxn m n = if m < n then n else m`;; |
| 744 |
let minn = new_definition `minn m n = if m < n then m else n`;; |
| 745 |
|
| 746 |
(* Lemma max0n *) |
| 747 |
let max0n = Sections.section_proof [] |
| 748 |
`!n. maxn 0 n = n` |
| 749 |
[ |
| 750 |
((((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 751 |
];; |
| 752 |
|
| 753 |
(* Lemma maxn0 *) |
| 754 |
let maxn0 = Sections.section_proof [] |
| 755 |
`!n. maxn n 0 = n` |
| 756 |
[ |
| 757 |
((((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 758 |
];; |
| 759 |
|
| 760 |
(* Lemma maxnC *) |
| 761 |
let maxnC = Sections.section_proof [] |
| 762 |
`!m n. maxn m n = maxn n m` |
| 763 |
[ |
| 764 |
((repeat_tactic 1 9 (((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); |
| 765 |
];; |
| 766 |
|
| 767 |
(* Lemma maxnl *) |
| 768 |
let maxnl = Sections.section_proof [] |
| 769 |
`!m n. n <= m ==> maxn m n = m` |
| 770 |
[ |
| 771 |
((((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 772 |
];; |
| 773 |
|
| 774 |
(* Lemma maxnr *) |
| 775 |
let maxnr = Sections.section_proof [] |
| 776 |
`!m n. m <= n ==> maxn m n = n` |
| 777 |
[ |
| 778 |
((((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 779 |
];; |
| 780 |
|
| 781 |
(* Lemma add_sub_maxn *) |
| 782 |
let add_sub_maxn = Sections.section_proof [] |
| 783 |
`!m n. m + (n - m) = maxn m n` |
| 784 |
[ |
| 785 |
((((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 786 |
];; |
| 787 |
|
| 788 |
(* Lemma maxnAC *) |
| 789 |
let maxnAC = Sections.section_proof [] |
| 790 |
`!m n p. maxn (maxn m n) p = maxn (maxn m p) n` |
| 791 |
[ |
| 792 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])); |
| 793 |
(((repeat_tactic 1 9 (((use_arg_then2 ("add_sub_maxn", [add_sub_maxn]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("subn_sub", [subn_sub]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("add_sub_maxn", [add_sub_maxn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 794 |
];; |
| 795 |
|
| 796 |
(* Lemma maxnA *) |
| 797 |
let maxnA = Sections.section_proof [] |
| 798 |
`!m n p. maxn m (maxn n p) = maxn (maxn m n) p` |
| 799 |
[ |
| 800 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])); |
| 801 |
(((repeat_tactic 1 9 (((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [(`maxn m _1`)]))))) THEN (((use_arg_then2 ("maxnAC", [maxnAC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 802 |
];; |
| 803 |
|
| 804 |
(* Lemma maxnCA *) |
| 805 |
let maxnCA = Sections.section_proof [] |
| 806 |
`!m n p. maxn m (maxn n p) = maxn n (maxn m p)` |
| 807 |
[ |
| 808 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("maxnA", [maxnA]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [(`maxn m _1`)]))))) THEN (done_tac)); |
| 809 |
];; |
| 810 |
|
| 811 |
(* Lemma eqn_maxr *) |
| 812 |
let eqn_maxr = Sections.section_proof [] |
| 813 |
`!m n. (maxn m n = n) = (m <= n)` |
| 814 |
[ |
| 815 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 816 |
(((((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addn0", [addn0]))(gsym_then (thm_tac (new_rewrite [2] [(`n`)]))))) THEN (((use_arg_then2 ("add_sub_maxn", [add_sub_maxn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eqn_addl", [eqn_addl]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqE", [leqE]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 817 |
];; |
| 818 |
|
| 819 |
(* Lemma eqn_maxl *) |
| 820 |
let eqn_maxl = Sections.section_proof [] |
| 821 |
`!m n. (maxn m n = m) = (n <= m)` |
| 822 |
[ |
| 823 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 824 |
(((((use_arg_then2 ("addn0", [addn0]))(gsym_then (thm_tac (new_rewrite [2] [(`m`)]))))) THEN (((use_arg_then2 ("add_sub_maxn", [add_sub_maxn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eqn_addl", [eqn_addl]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqE", [leqE]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 825 |
];; |
| 826 |
|
| 827 |
(* Lemma maxnn *) |
| 828 |
let maxnn = Sections.section_proof [] |
| 829 |
`!n. maxn n n = n` |
| 830 |
[ |
| 831 |
(BETA_TAC THEN (move ["n"])); |
| 832 |
(((((use_arg_then2 ("maxnl", [maxnl]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 833 |
];; |
| 834 |
|
| 835 |
(* Lemma leq_maxr *) |
| 836 |
let leq_maxr = Sections.section_proof ["m";"n1";"n2"] |
| 837 |
`(m <= maxn n1 n2) <=> (m <= n1) \/ (m <= n2)` |
| 838 |
[ |
| 839 |
((fun arg_tac -> arg_tac (Arg_term (`n2 <= n1`))) (term_tac (wlog_tac (move ["le_n21"])[`n1`; `n2`]))); |
| 840 |
(((THENL_LAST) (((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leq_total", [leq_total])) (fun fst_arg -> (use_arg_then2 ("n2", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("n1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (move ["le_n12"])) ((((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("orbC", [orbC]))(thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("le_n21", []))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 841 |
(BETA_TAC THEN (move ["le_n21"])); |
| 842 |
(((((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("le_n21", []))(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (((fun arg_tac -> (use_arg_then2 ("EXCLUDED_MIDDLE", [EXCLUDED_MIDDLE])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m <= n1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac))); |
| 843 |
((((use_arg_then2 ("contra", [contra])) (disch_tac [])) THEN (clear_assumption "contra") THEN (DISCH_THEN apply_tac)) THEN ((DISCH_THEN (fun snd_th -> (use_arg_then2 ("leq_trans", [leq_trans])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN ((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then2 ("n1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))) THEN (done_tac)); |
| 844 |
];; |
| 845 |
|
| 846 |
(* Lemma leq_maxl *) |
| 847 |
let leq_maxl = Sections.section_proof ["m";"n1";"n2"] |
| 848 |
`(maxn n1 n2 <= m) <=> (n1 <= m) /\ (n2 <= m)` |
| 849 |
[ |
| 850 |
(((((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_maxr", [leq_maxr]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("negb_or", [negb_or]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leqNgt", [leqNgt]))(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (done_tac)); |
| 851 |
];; |
| 852 |
|
| 853 |
(* Lemma addn_maxl *) |
| 854 |
let addn_maxl = Sections.section_proof [] |
| 855 |
`!m1 m2 n. (maxn m1 m2) + n = maxn (m1 + n) (m2 + n)` |
| 856 |
[ |
| 857 |
((BETA_TAC THEN (move ["m1"]) THEN (move ["m2"]) THEN (move ["n"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("add_sub_maxn", [add_sub_maxn]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("subn_add2r", [subn_add2r]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnAC", [addnAC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 858 |
];; |
| 859 |
|
| 860 |
(* Lemma addn_maxr *) |
| 861 |
let addn_maxr = Sections.section_proof [] |
| 862 |
`!m n1 n2. m + maxn n1 n2 = maxn (m + n1) (m + n2)` |
| 863 |
[ |
| 864 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n1"]) THEN (move ["n2"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [(`m + _1`)]))))) THEN (((use_arg_then2 ("addn_maxl", [addn_maxl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 865 |
];; |
| 866 |
|
| 867 |
(* Lemma min0n *) |
| 868 |
let min0n = Sections.section_proof ["n"] |
| 869 |
`minn 0 n = 0` |
| 870 |
[ |
| 871 |
((((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 872 |
];; |
| 873 |
|
| 874 |
(* Lemma minn0 *) |
| 875 |
let minn0 = Sections.section_proof ["n"] |
| 876 |
`minn n 0 = 0` |
| 877 |
[ |
| 878 |
((((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 879 |
];; |
| 880 |
|
| 881 |
(* Lemma minnC *) |
| 882 |
let minnC = Sections.section_proof ["m";"n"] |
| 883 |
`minn m n = minn n m` |
| 884 |
[ |
| 885 |
((repeat_tactic 1 9 (((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); |
| 886 |
];; |
| 887 |
|
| 888 |
(* Lemma minnr *) |
| 889 |
let minnr = Sections.section_proof ["m";"n"] |
| 890 |
`n <= m ==> minn m n = n` |
| 891 |
[ |
| 892 |
((((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 893 |
];; |
| 894 |
|
| 895 |
(* Lemma minnl *) |
| 896 |
let minnl = Sections.section_proof ["m";"n"] |
| 897 |
`m <= n ==> minn m n = m` |
| 898 |
[ |
| 899 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("minnr", [minnr])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 900 |
];; |
| 901 |
|
| 902 |
(* Lemma addn_min_max *) |
| 903 |
let addn_min_max = Sections.section_proof ["m";"n"] |
| 904 |
`minn m n + maxn m n = m + n` |
| 905 |
[ |
| 906 |
(((((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); |
| 907 |
];; |
| 908 |
|
| 909 |
(* Lemma minn_to_maxn *) |
| 910 |
let minn_to_maxn = Sections.section_proof ["m";"n"] |
| 911 |
`minn m n = (m + n) - maxn m n` |
| 912 |
[ |
| 913 |
(((((use_arg_then2 ("addn_min_max", [addn_min_max]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnK", [addnK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 914 |
];; |
| 915 |
|
| 916 |
(* Lemma sub_sub_minn *) |
| 917 |
let sub_sub_minn = Sections.section_proof ["m";"n"] |
| 918 |
`m - (m - n) = minn m n` |
| 919 |
[ |
| 920 |
(((((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("minn_to_maxn", [minn_to_maxn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add_sub_maxn", [add_sub_maxn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subn_add2l", [subn_add2l]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 921 |
];; |
| 922 |
|
| 923 |
(* Lemma minnCA *) |
| 924 |
let minnCA = Sections.section_proof [] |
| 925 |
`!m1 m2 m3. minn m1 (minn m2 m3) = minn m2 (minn m1 m3)` |
| 926 |
[ |
| 927 |
((BETA_TAC THEN (move ["m1"]) THEN (move ["m2"]) THEN (move ["m3"])) THEN (repeat_tactic 1 9 (((use_arg_then2 ("minn_to_maxn", [minn_to_maxn]))(thm_tac (new_rewrite [] [(`minn _1 (minn _2 _3)`)])))))); |
| 928 |
((((fun arg_tac -> (use_arg_then2 ("subn_add2r", [subn_add2r])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`maxn m2 m3`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> (use_arg_then2 ("subn_add2r", [subn_add2r])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`maxn m1 m3`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [(`(m2 + _1) - _2`)]))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] []))))))); |
| 929 |
(((repeat_tactic 1 9 (((use_arg_then2 ("addn_maxl", [addn_maxl]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addn_min_max", [addn_min_max]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addn_maxr", [addn_maxr]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnCA", [addnCA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("maxnAC", [maxnAC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [(`m2 + m1`)]))))) THEN (done_tac)); |
| 930 |
];; |
| 931 |
|
| 932 |
(* Lemma minnA *) |
| 933 |
let minnA = Sections.section_proof [] |
| 934 |
`!m1 m2 m3. minn m1 (minn m2 m3) = minn (minn m1 m2) m3` |
| 935 |
[ |
| 936 |
(BETA_TAC THEN (move ["m1"]) THEN (move ["m2"]) THEN (move ["m3"])); |
| 937 |
(((((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] [(`minn m2 _1`)])))) THEN (((use_arg_then2 ("minnCA", [minnCA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 938 |
];; |
| 939 |
|
| 940 |
(* Lemma minnAC *) |
| 941 |
let minnAC = Sections.section_proof ["m1";"m2";"m3"] |
| 942 |
`minn (minn m1 m2) m3 = minn (minn m1 m3) m2` |
| 943 |
[ |
| 944 |
(((((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("minnCA", [minnCA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("minnA", [minnA]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 945 |
];; |
| 946 |
|
| 947 |
(* Lemma eqn_minr *) |
| 948 |
let eqn_minr = Sections.section_proof ["m";"n"] |
| 949 |
`(minn m n = n) = (n <= m)` |
| 950 |
[ |
| 951 |
(((fun arg_tac -> (use_arg_then2 ("eqn_addr", [eqn_addr])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))); |
| 952 |
(((((use_arg_then2 ("addn_min_max", [addn_min_max]))(gsym_then (thm_tac (new_rewrite [] [(`n + m`)]))))) THEN (((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("eqn_addl", [eqn_addl]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("eq_sym", [eq_sym]))(thm_tac (new_rewrite [] [(`m = _1`)])))) THEN (((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("eqn_maxl", [eqn_maxl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 953 |
];; |
| 954 |
|
| 955 |
(* Lemma eqn_minl *) |
| 956 |
let eqn_minl = Sections.section_proof ["m";"n"] |
| 957 |
`(minn m n = m) = (m <= n)` |
| 958 |
[ |
| 959 |
(((((fun arg_tac -> (use_arg_then2 ("eqn_addr", [eqn_addr])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eq_sym", [eq_sym]))(thm_tac (new_rewrite [] [(`_1 = m + n`)])))) THEN (((use_arg_then2 ("addn_min_max", [addn_min_max]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eqn_addl", [eqn_addl]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("eqn_maxr", [eqn_maxr]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 960 |
];; |
| 961 |
|
| 962 |
(* Lemma minnn *) |
| 963 |
let minnn = Sections.section_proof ["n"] |
| 964 |
`minn n n = n` |
| 965 |
[ |
| 966 |
(((((use_arg_then2 ("minnr", [minnr]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 967 |
];; |
| 968 |
|
| 969 |
(* Lemma leq_minr *) |
| 970 |
let leq_minr = Sections.section_proof ["m";"n1";"n2"] |
| 971 |
`(m <= minn n1 n2) <=> (m <= n1) /\ (m <= n2)` |
| 972 |
[ |
| 973 |
((((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 974 |
];; |
| 975 |
|
| 976 |
(* Lemma leq_minl *) |
| 977 |
let leq_minl = Sections.section_proof ["m";"n1";"n2"] |
| 978 |
`(minn n1 n2 <= m) <=> (n1 <= m) \/ (n2 <= m)` |
| 979 |
[ |
| 980 |
(((((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_minr", [leq_minr]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("negb_and", [negb_and]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leqNgt", [leqNgt]))(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (done_tac)); |
| 981 |
];; |
| 982 |
|
| 983 |
(* Lemma addn_minl *) |
| 984 |
let addn_minl = Sections.section_proof [] |
| 985 |
`!m1 m2 n. (minn m1 m2) + n = minn (m1 + n) (m2 + n)` |
| 986 |
[ |
| 987 |
((BETA_TAC THEN (move ["m1"]) THEN (move ["m2"]) THEN (move ["n"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("minn_to_maxn", [minn_to_maxn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addn_maxl", [addn_maxl]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnA", [addnA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subn_add2r", [subn_add2r]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnAC", [addnAC]))(thm_tac (new_rewrite [] [])))))); |
| 988 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("addnC", [addnC])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [(`_1 + n`)])))))) THEN (((use_arg_then2 ("addn_subA", [addn_subA]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("addn_min_max", [addn_min_max]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_addl", [leq_addl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 989 |
];; |
| 990 |
|
| 991 |
(* Lemma addn_minr *) |
| 992 |
let addn_minr = Sections.section_proof [] |
| 993 |
`!m n1 n2. m + minn n1 n2 = minn (m + n1) (m + n2)` |
| 994 |
[ |
| 995 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n1"]) THEN (move ["n2"])); |
| 996 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("addnC", [addnC])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [(`m + _1`)]))))) THEN (((use_arg_then2 ("addn_minl", [addn_minl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 997 |
];; |
| 998 |
|
| 999 |
(* Lemma maxnK *) |
| 1000 |
let maxnK = Sections.section_proof ["m";"n"] |
| 1001 |
`minn (maxn m n) m = m` |
| 1002 |
[ |
| 1003 |
(((((use_arg_then2 ("minnr", [minnr]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("leq_maxr", [leq_maxr]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1004 |
];; |
| 1005 |
|
| 1006 |
(* Lemma maxKn *) |
| 1007 |
let maxKn = Sections.section_proof ["m";"n"] |
| 1008 |
`minn n (maxn m n) = n` |
| 1009 |
[ |
| 1010 |
(((((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("maxnK", [maxnK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1011 |
];; |
| 1012 |
|
| 1013 |
(* Lemma minnK *) |
| 1014 |
let minnK = Sections.section_proof ["m";"n"] |
| 1015 |
`maxn (minn m n) m = m` |
| 1016 |
[ |
| 1017 |
(((((use_arg_then2 ("maxnr", [maxnr]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("leq_minl", [leq_minl]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1018 |
];; |
| 1019 |
|
| 1020 |
(* Lemma minKn *) |
| 1021 |
let minKn = Sections.section_proof ["m";"n"] |
| 1022 |
`maxn n (minn m n) = n` |
| 1023 |
[ |
| 1024 |
(((((use_arg_then2 ("minnC", [minnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("minnK", [minnK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1025 |
];; |
| 1026 |
|
| 1027 |
(* Lemma maxn_minl *) |
| 1028 |
let maxn_minl = Sections.section_proof ["m1";"m2";"n"] |
| 1029 |
`maxn (minn m1 m2) n = minn (maxn m1 n) (maxn m2 n)` |
| 1030 |
[ |
| 1031 |
(((repeat_tactic 1 9 (((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] [])))))) THEN (arith_tac)); |
| 1032 |
];; |
| 1033 |
|
| 1034 |
(* Lemma maxn_minr *) |
| 1035 |
let maxn_minr = Sections.section_proof ["m";"n1";"n2"] |
| 1036 |
`maxn m (minn n1 n2) = minn (maxn m n1) (maxn m n2)` |
| 1037 |
[ |
| 1038 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("maxnC", [maxnC])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [(`maxn m _1`)]))))) THEN (((use_arg_then2 ("maxn_minl", [maxn_minl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1039 |
];; |
| 1040 |
|
| 1041 |
(* Lemma minn_maxl *) |
| 1042 |
let minn_maxl = Sections.section_proof [] |
| 1043 |
`!m1 m2 n. minn (maxn m1 m2) n = maxn (minn m1 n) (minn m2 n)` |
| 1044 |
[ |
| 1045 |
((BETA_TAC THEN (move ["m1"]) THEN (move ["m2"]) THEN (move ["n"])) THEN ((((use_arg_then2 ("maxn_minr", [maxn_minr]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("maxn_minl", [maxn_minl]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("minnA", [minnA]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("maxnn", [maxnn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("maxnC", [maxnC]))(thm_tac (new_rewrite [] [(`maxn _1 n`)])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("maxnK", [maxnK]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1046 |
];; |
| 1047 |
|
| 1048 |
(* Lemma minn_maxr *) |
| 1049 |
let minn_maxr = Sections.section_proof [] |
| 1050 |
`!m n1 n2. minn m (maxn n1 n2) = maxn (minn m n1) (minn m n2)` |
| 1051 |
[ |
| 1052 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n1"]) THEN (move ["n2"])); |
| 1053 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("minnC", [minnC])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [(`minn m _1`)]))))) THEN (((use_arg_then2 ("minn_maxl", [minn_maxl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1054 |
];; |
| 1055 |
|
| 1056 |
(* Section Iteration *) |
| 1057 |
Sections.begin_section "Iteration";; |
| 1058 |
(Sections.add_section_var (mk_var ("m", (`:num`))); Sections.add_section_var (mk_var ("n", (`:num`))));; |
| 1059 |
(Sections.add_section_var (mk_var ("x", (`:A`))); Sections.add_section_var (mk_var ("y", (`:A`))));; |
| 1060 |
let iter = define `iter (SUC n) f (x:A) = f (iter n f x) /\ iter 0 f x = x`;; |
| 1061 |
let iteri = define `iteri (SUC n) f (x:A) = f n (iteri n f x) /\ iteri 0 f x = x`;; |
| 1062 |
|
| 1063 |
(* Lemma iterSr *) |
| 1064 |
let iterSr = Sections.section_proof ["n";"f";"x"] |
| 1065 |
`iter (SUC n) f (x : A) = iter n f (f x)` |
| 1066 |
[ |
| 1067 |
((((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("iter", [iter]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (move ["n"]) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1068 |
];; |
| 1069 |
|
| 1070 |
(* Lemma iterS *) |
| 1071 |
let iterS = Sections.section_proof ["n";"f";"x"] |
| 1072 |
`iter (SUC n) f (x:A) = f (iter n f x)` |
| 1073 |
[ |
| 1074 |
((((use_arg_then2 ("iter", [iter]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1075 |
];; |
| 1076 |
|
| 1077 |
(* Lemma iter_add *) |
| 1078 |
let iter_add = Sections.section_proof ["n";"m";"f";"x"] |
| 1079 |
`iter (n + m) f (x:A) = iter n f (iter m f x)` |
| 1080 |
[ |
| 1081 |
((((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) THEN (((repeat_tactic 1 9 (((use_arg_then2 ("iter", [iter]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (((use_arg_then2 ("add0n", [add0n]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("addSn", [addSn]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (move ["n"]) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("iterS", [iterS]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 1082 |
];; |
| 1083 |
|
| 1084 |
(* Lemma iteriS *) |
| 1085 |
let iteriS = Sections.section_proof ["n";"f";"x"] |
| 1086 |
`iteri (SUC n) f x = f n (iteri n f (x:A))` |
| 1087 |
[ |
| 1088 |
((((use_arg_then2 ("iteri", [iteri]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1089 |
];; |
| 1090 |
|
| 1091 |
(* Finalization of the section Iteration *) |
| 1092 |
let iterSr = Sections.finalize_theorem iterSr;; |
| 1093 |
let iterS = Sections.finalize_theorem iterS;; |
| 1094 |
let iter_add = Sections.finalize_theorem iter_add;; |
| 1095 |
let iteriS = Sections.finalize_theorem iteriS;; |
| 1096 |
Sections.end_section "Iteration";; |
| 1097 |
|
| 1098 |
(* Lemma mul0n *) |
| 1099 |
let mul0n = Sections.section_proof ["n"] |
| 1100 |
`0 * n = 0` |
| 1101 |
[ |
| 1102 |
((arith_tac) THEN (done_tac)); |
| 1103 |
];; |
| 1104 |
|
| 1105 |
(* Lemma muln0 *) |
| 1106 |
let muln0 = Sections.section_proof ["n"] |
| 1107 |
`n * 0 = 0` |
| 1108 |
[ |
| 1109 |
((arith_tac) THEN (done_tac)); |
| 1110 |
];; |
| 1111 |
|
| 1112 |
(* Lemma mul1n *) |
| 1113 |
let mul1n = Sections.section_proof ["n"] |
| 1114 |
`1 * n = n` |
| 1115 |
[ |
| 1116 |
((arith_tac) THEN (done_tac)); |
| 1117 |
];; |
| 1118 |
|
| 1119 |
(* Lemma mulSn *) |
| 1120 |
let mulSn = Sections.section_proof ["m";"n"] |
| 1121 |
`SUC m * n = n + m * n` |
| 1122 |
[ |
| 1123 |
(arith_tac); |
| 1124 |
];; |
| 1125 |
|
| 1126 |
(* Lemma mulSnr *) |
| 1127 |
let mulSnr = Sections.section_proof ["m";"n"] |
| 1128 |
`SUC m * n = m * n + n` |
| 1129 |
[ |
| 1130 |
(arith_tac); |
| 1131 |
];; |
| 1132 |
|
| 1133 |
(* Lemma mulnS *) |
| 1134 |
let mulnS = Sections.section_proof ["m";"n"] |
| 1135 |
`m * SUC n = m + m * n` |
| 1136 |
[ |
| 1137 |
((((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN elim) THEN (((repeat_tactic 0 10 (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("addn0", [addn0]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN (move ["m"]))); |
| 1138 |
((((repeat_tactic 1 9 (((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addSn", [addSn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnCA", [addnCA]))(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1139 |
];; |
| 1140 |
|
| 1141 |
(* Lemma mulnSr *) |
| 1142 |
let mulnSr = Sections.section_proof ["m";"n"] |
| 1143 |
`m * SUC n = m * n + m` |
| 1144 |
[ |
| 1145 |
(((((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulnS", [mulnS]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1146 |
];; |
| 1147 |
|
| 1148 |
(* Lemma muln1 *) |
| 1149 |
let muln1 = Sections.section_proof ["n"] |
| 1150 |
`n * 1 = n` |
| 1151 |
[ |
| 1152 |
(((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `1 = SUC 0`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulnSr", [mulnSr]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("muln0", [muln0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1153 |
];; |
| 1154 |
|
| 1155 |
(* Lemma mulnC *) |
| 1156 |
let mulnC = Sections.section_proof [] |
| 1157 |
`!m n. m * n = n * m` |
| 1158 |
[ |
| 1159 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 1160 |
(((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; (move ["m"])]) THEN (((repeat_tactic 0 10 (((use_arg_then2 ("muln0", [muln0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("mulnS", [mulnS]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1161 |
];; |
| 1162 |
|
| 1163 |
(* Lemma muln_addl *) |
| 1164 |
let muln_addl = Sections.section_proof ["m1";"m2";"n"] |
| 1165 |
`(m1 + m2) * n = m1 * n + m2 * n` |
| 1166 |
[ |
| 1167 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("m1", [])) (disch_tac [])) THEN (clear_assumption "m1") THEN elim) [ALL_TAC; ((move ["m1"]) THEN (move ["IHm"]))]) (((((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac))); |
| 1168 |
(((((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("IHm", []))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("mulSn", [mulSn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addSn", [addSn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1169 |
];; |
| 1170 |
|
| 1171 |
(* Lemma muln_addr *) |
| 1172 |
let muln_addr = Sections.section_proof ["m";"n1";"n2"] |
| 1173 |
`m * (n1 + n2) = m * n1 + m * n2` |
| 1174 |
[ |
| 1175 |
(((repeat_tactic 1 9 (((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [(`m * _1`)]))))) THEN (((use_arg_then2 ("muln_addl", [muln_addl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1176 |
];; |
| 1177 |
|
| 1178 |
(* Lemma muln_subl *) |
| 1179 |
let muln_subl = Sections.section_proof [] |
| 1180 |
`!m n p. (m - n) * p = m * p - n * p` |
| 1181 |
[ |
| 1182 |
((THENL_FIRST) (BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN ((THENL) case [ALL_TAC; (move ["n'"])])) (((repeat_tactic 1 9 (((use_arg_then2 ("muln0", [muln0]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subn0", [subn0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1183 |
((((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN ((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; ((move ["m"]) THEN (move ["IHm"]))]) THEN ((THENL) case [ALL_TAC; (move ["n"])])) THEN ((repeat_tactic 0 10 (((fun arg_tac ->(use_arg_then2 ("mul0n", [mul0n]))(fun tmp_arg1 -> (fun arg_tac ->(use_arg_then2 ("sub0n", [sub0n]))(fun tmp_arg1 -> (use_arg_then2 ("subn0", [subn0]))(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subn_add2l", [subn_add2l]))(thm_tac (new_rewrite [] [])))))); |
| 1184 |
(((((use_arg_then2 ("IHm", []))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subSS", [subSS]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1185 |
];; |
| 1186 |
|
| 1187 |
(* Lemma muln_subr *) |
| 1188 |
let muln_subr = Sections.section_proof [] |
| 1189 |
`!m n p. m * (n - p) = m * n - m * p` |
| 1190 |
[ |
| 1191 |
((BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [(`m * _1`)]))))) THEN (((use_arg_then2 ("muln_subl", [muln_subl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1192 |
];; |
| 1193 |
|
| 1194 |
(* Lemma mulnA *) |
| 1195 |
let mulnA = Sections.section_proof [] |
| 1196 |
`!m n p. m * (n * p) = (m * n) * p` |
| 1197 |
[ |
| 1198 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"]) THEN (move ["p"])); |
| 1199 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; (move ["m"])]) ((repeat_tactic 1 9 (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1200 |
((((repeat_tactic 1 9 (((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("muln_addl", [muln_addl]))(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1201 |
];; |
| 1202 |
|
| 1203 |
(* Lemma mulnCA *) |
| 1204 |
let mulnCA = Sections.section_proof ["m";"n1";"n2"] |
| 1205 |
`m * (n1 * n2) = n1 * (m * n2)` |
| 1206 |
[ |
| 1207 |
(((repeat_tactic 1 9 (((use_arg_then2 ("mulnA", [mulnA]))(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> (use_arg_then2 ("mulnC", [mulnC])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [(`m * _1`)]))))) THEN (done_tac)); |
| 1208 |
];; |
| 1209 |
|
| 1210 |
(* Lemma mulnAC *) |
| 1211 |
let mulnAC = Sections.section_proof ["m";"n";"p"] |
| 1212 |
`(n * m) * p = (n * p) * m` |
| 1213 |
[ |
| 1214 |
(((repeat_tactic 1 9 (((use_arg_then2 ("mulnA", [mulnA]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [(`p * _1`)]))))) THEN (done_tac)); |
| 1215 |
];; |
| 1216 |
|
| 1217 |
(* Lemma muln_eq0 *) |
| 1218 |
let muln_eq0 = Sections.section_proof ["m";"n"] |
| 1219 |
`(m * n = 0) <=> (m = 0) \/ (n = 0)` |
| 1220 |
[ |
| 1221 |
((((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN ((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; (move ["m"])]) THEN ((THENL) case [ALL_TAC; (move ["n"])])) THEN ((repeat_tactic 0 10 (((fun arg_tac ->(use_arg_then2 ("muln0", [muln0]))(fun tmp_arg1 -> (use_arg_then2 ("mul0n", [mul0n]))(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN (arith_tac)); |
| 1222 |
];; |
| 1223 |
|
| 1224 |
(* Lemma eqn_mul1 *) |
| 1225 |
let eqn_mul1 = Sections.section_proof ["m";"n"] |
| 1226 |
`(m * n = 1) <=> (m = 1) /\ (n = 1)` |
| 1227 |
[ |
| 1228 |
((((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN ((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; ((THENL) case [ALL_TAC; (move ["m"])])]) THEN ((THENL) case [ALL_TAC; ((THENL) case [ALL_TAC; (move ["n"])])])) THEN (arith_tac) THEN (done_tac)); |
| 1229 |
];; |
| 1230 |
|
| 1231 |
(* Lemma muln_gt0 *) |
| 1232 |
let muln_gt0 = Sections.section_proof ["m";"n"] |
| 1233 |
`(0 < m * n) <=> (0 < m) /\ (0 < n)` |
| 1234 |
[ |
| 1235 |
((((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN ((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; (move ["m"])]) THEN ((THENL) case [ALL_TAC; (move ["n"])])) THEN (arith_tac) THEN (done_tac)); |
| 1236 |
];; |
| 1237 |
|
| 1238 |
(* Lemma leq_pmull *) |
| 1239 |
let leq_pmull = Sections.section_proof ["m";"n"] |
| 1240 |
`0 < n ==> m <= n * m` |
| 1241 |
[ |
| 1242 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("prednK", [prednK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_addr", [leq_addr]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1243 |
];; |
| 1244 |
|
| 1245 |
(* Lemma leq_pmulr *) |
| 1246 |
let leq_pmulr = Sections.section_proof ["m";"n"] |
| 1247 |
`0 < n ==> m <= m * n` |
| 1248 |
[ |
| 1249 |
(((DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then2 ("leq_pmull", [leq_pmull])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 1250 |
];; |
| 1251 |
|
| 1252 |
(* Lemma leq_mul2l *) |
| 1253 |
let leq_mul2l = Sections.section_proof ["m";"n1";"n2"] |
| 1254 |
`(m * n1 <= m * n2) <=> (m = 0) \/ (n1 <= n2)` |
| 1255 |
[ |
| 1256 |
(((((use_arg_then2 ("leqE", [leqE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("muln_subr", [muln_subr]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("muln_eq0", [muln_eq0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqE", [leqE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1257 |
];; |
| 1258 |
|
| 1259 |
(* Lemma leq_mul2r *) |
| 1260 |
let leq_mul2r = Sections.section_proof ["m";"n1";"n2"] |
| 1261 |
`(n1 * m <= n2 * m) <=> (m = 0) \/ (n1 <= n2)` |
| 1262 |
[ |
| 1263 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("mulnC", [mulnC])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [(`_1 * m`)])))))) THEN (((use_arg_then2 ("leq_mul2l", [leq_mul2l]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1264 |
];; |
| 1265 |
|
| 1266 |
(* Lemma leq_mul *) |
| 1267 |
let leq_mul = Sections.section_proof ["m1";"m2";"n1";"n2"] |
| 1268 |
`m1 <= n1 ==> m2 <= n2 ==> m1 * m2 <= n1 * n2` |
| 1269 |
[ |
| 1270 |
(BETA_TAC THEN (move ["le_mn1"]) THEN (move ["le_mn2"])); |
| 1271 |
(((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leq_trans", [leq_trans])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m1 * n2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m1 * m2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`n1 * n2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); |
| 1272 |
((THENL_FIRST) (ANTS_TAC) (((((use_arg_then2 ("leq_mul2l", [leq_mul2l]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("le_mn2", []))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1273 |
(DISCH_THEN apply_tac); |
| 1274 |
(((((use_arg_then2 ("leq_mul2r", [leq_mul2r]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("le_mn1", []))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1275 |
];; |
| 1276 |
|
| 1277 |
(* Lemma eqn_mul2l *) |
| 1278 |
let eqn_mul2l = Sections.section_proof ["m";"n1";"n2"] |
| 1279 |
`(m * n1 = m * n2) <=> (m = 0) \/ (n1 = n2)` |
| 1280 |
[ |
| 1281 |
(((((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leq_mul2l", [leq_mul2l]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("orb_andr", [orb_andr]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eqn_leq", [eqn_leq]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1282 |
];; |
| 1283 |
|
| 1284 |
(* Lemma eqn_mul2r *) |
| 1285 |
let eqn_mul2r = Sections.section_proof ["m";"n1";"n2"] |
| 1286 |
`(n1 * m = n2 * m) <=> (m = 0) \/ (n1 = n2)` |
| 1287 |
[ |
| 1288 |
(((((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leq_mul2r", [leq_mul2r]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("orb_andr", [orb_andr]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eqn_leq", [eqn_leq]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1289 |
];; |
| 1290 |
|
| 1291 |
(* Lemma leq_pmul2l *) |
| 1292 |
let leq_pmul2l = Sections.section_proof ["m";"n1";"n2"] |
| 1293 |
`0 < m ==> ((m * n1 <= m * n2) <=> (n1 <= n2))` |
| 1294 |
[ |
| 1295 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("prednK", [prednK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("leq_mul2l", [leq_mul2l]))(thm_tac (new_rewrite [] [])))) THEN ((((use_arg_then2 ("NOT_SUC", [NOT_SUC]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("orFb", [orFb]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1296 |
];; |
| 1297 |
|
| 1298 |
(* Lemma leq_pmul2r *) |
| 1299 |
let leq_pmul2r = Sections.section_proof ["m";"n1";"n2"] |
| 1300 |
`0 < m ==> ((n1 * m <= n2 * m) <=> (n1 <= n2))` |
| 1301 |
[ |
| 1302 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("prednK", [prednK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("leq_mul2r", [leq_mul2r]))(thm_tac (new_rewrite [] [])))) THEN ((((use_arg_then2 ("NOT_SUC", [NOT_SUC]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("orFb", [orFb]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1303 |
];; |
| 1304 |
|
| 1305 |
(* Lemma eqn_pmul2l *) |
| 1306 |
let eqn_pmul2l = Sections.section_proof ["m";"n1";"n2"] |
| 1307 |
`0 < m ==> ((m * n1 = m * n2) <=> (n1 = n2))` |
| 1308 |
[ |
| 1309 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("prednK", [prednK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("eqn_mul2l", [eqn_mul2l]))(thm_tac (new_rewrite [] [])))) THEN ((((use_arg_then2 ("NOT_SUC", [NOT_SUC]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("orFb", [orFb]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1310 |
];; |
| 1311 |
|
| 1312 |
(* Lemma eqn_pmul2r *) |
| 1313 |
let eqn_pmul2r = Sections.section_proof ["m";"n1";"n2"] |
| 1314 |
`0 < m ==> ((n1 * m = n2 * m) <=> (n1 = n2))` |
| 1315 |
[ |
| 1316 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("prednK", [prednK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("eqn_mul2r", [eqn_mul2r]))(thm_tac (new_rewrite [] [])))) THEN ((((use_arg_then2 ("NOT_SUC", [NOT_SUC]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("orFb", [orFb]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1317 |
];; |
| 1318 |
|
| 1319 |
(* Lemma ltn_mul2l *) |
| 1320 |
let ltn_mul2l = Sections.section_proof ["m";"n1";"n2"] |
| 1321 |
`(m * n1 < m * n2) <=> (0 < m) /\ (n1 < n2)` |
| 1322 |
[ |
| 1323 |
(((((use_arg_then2 ("lt0n", [lt0n]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_mul2l", [leq_mul2l]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("negb_or", [negb_or]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1324 |
];; |
| 1325 |
|
| 1326 |
(* Lemma ltn_mul2r *) |
| 1327 |
let ltn_mul2r = Sections.section_proof ["m";"n1";"n2"] |
| 1328 |
`(n1 * m < n2 * m) <=> (0 < m) /\ (n1 < n2)` |
| 1329 |
[ |
| 1330 |
(((((use_arg_then2 ("lt0n", [lt0n]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_mul2r", [leq_mul2r]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("negb_or", [negb_or]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1331 |
];; |
| 1332 |
|
| 1333 |
(* Lemma ltn_pmul2l *) |
| 1334 |
let ltn_pmul2l = Sections.section_proof ["m";"n1";"n2"] |
| 1335 |
`0 < m ==> ((m * n1 < m * n2) <=> (n1 < n2))` |
| 1336 |
[ |
| 1337 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("prednK", [prednK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then2 ("ltn_mul2l", [ltn_mul2l]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("LT_0", [LT_0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("andTb", [andTb]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1338 |
];; |
| 1339 |
|
| 1340 |
(* Lemma ltn_pmul2r *) |
| 1341 |
let ltn_pmul2r = Sections.section_proof ["m";"n1";"n2"] |
| 1342 |
`0 < m ==> (n1 * m < n2 * m <=> n1 < n2)` |
| 1343 |
[ |
| 1344 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("prednK", [prednK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then2 ("ltn_mul2r", [ltn_mul2r]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("LT_0", [LT_0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1345 |
];; |
| 1346 |
|
| 1347 |
(* Lemma ltn_Pmull *) |
| 1348 |
let ltn_Pmull = Sections.section_proof ["m";"n"] |
| 1349 |
`1 < n ==> 0 < m ==> m < n * m` |
| 1350 |
[ |
| 1351 |
((BETA_TAC THEN (move ["lt1n"]) THEN (move ["m_gt0"])) THEN ((((use_arg_then2 ("mul1n", [mul1n]))(gsym_then (thm_tac (new_rewrite [1] [(`m`)]))))) THEN (((use_arg_then2 ("ltn_pmul2r", [ltn_pmul2r]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1352 |
];; |
| 1353 |
|
| 1354 |
(* Lemma ltn_Pmulr *) |
| 1355 |
let ltn_Pmulr = Sections.section_proof ["m";"n"] |
| 1356 |
`1 < n ==> 0 < m ==> m < m * n` |
| 1357 |
[ |
| 1358 |
((BETA_TAC THEN (move ["lt1n"]) THEN (move ["m_gt0"])) THEN ((((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltn_Pmull", [ltn_Pmull]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1359 |
];; |
| 1360 |
|
| 1361 |
(* Lemma ltn_mul *) |
| 1362 |
let ltn_mul = Sections.section_proof ["m1";"m2";"n1";"n2"] |
| 1363 |
`m1 < n1 ==> m2 < n2 ==> m1 * m2 < n1 * n2` |
| 1364 |
[ |
| 1365 |
(BETA_TAC THEN (move ["lt_mn1"]) THEN (move ["lt_mn2"])); |
| 1366 |
(((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leq_ltn_trans", [leq_ltn_trans])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m1 * n2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m1 * m2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`n1 * n2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); |
| 1367 |
(ANTS_TAC); |
| 1368 |
(((((use_arg_then2 ("leq_mul2l", [leq_mul2l]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("orbC", [orbC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltnW", [ltnW]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1369 |
(DISCH_THEN apply_tac); |
| 1370 |
((((use_arg_then2 ("ltn_pmul2r", [ltn_pmul2r]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); |
| 1371 |
((((use_arg_then2 ("lt_mn2", [])) (disch_tac [])) THEN (clear_assumption "lt_mn2") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); |
| 1372 |
];; |
| 1373 |
|
| 1374 |
(* Lemma maxn_mulr *) |
| 1375 |
let maxn_mulr = Sections.section_proof ["m";"n1";"n2"] |
| 1376 |
`m * maxn n1 n2 = maxn (m * n1) (m * n2)` |
| 1377 |
[ |
| 1378 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; (move ["n"])]) (((repeat_tactic 1 9 (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("maxnn", [maxnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1379 |
(((repeat_tactic 1 9 (((use_arg_then2 ("maxn", [maxn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("fun_if", [fun_if]))(thm_tac (new_rewrite [] [(`SUC n * _1`)])))) THEN (((use_arg_then2 ("ltn_pmul2l", [ltn_pmul2l]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("LT_0", [LT_0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1380 |
];; |
| 1381 |
|
| 1382 |
(* Lemma maxn_mull *) |
| 1383 |
let maxn_mull = Sections.section_proof ["m1";"m2";"n"] |
| 1384 |
`maxn m1 m2 * n = maxn (m1 * n) (m2 * n)` |
| 1385 |
[ |
| 1386 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("mulnC", [mulnC])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [(`_1 * n`)])))))) THEN (((use_arg_then2 ("maxn_mulr", [maxn_mulr]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1387 |
];; |
| 1388 |
|
| 1389 |
(* Lemma minn_mulr *) |
| 1390 |
let minn_mulr = Sections.section_proof ["m";"n1";"n2"] |
| 1391 |
`m * minn n1 n2 = minn (m * n1) (m * n2)` |
| 1392 |
[ |
| 1393 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; (move ["n"])]) (((repeat_tactic 1 9 (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("if_same", [if_same]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1394 |
((repeat_tactic 1 9 (((use_arg_then2 ("minn", [minn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("fun_if", [fun_if]))(thm_tac (new_rewrite [] [(`SUC n * _1`)])))) THEN (((use_arg_then2 ("ltn_pmul2l", [ltn_pmul2l]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("LT_0", [LT_0]))(thm_tac (new_rewrite [] []))))); |
| 1395 |
];; |
| 1396 |
|
| 1397 |
(* Lemma minn_mull *) |
| 1398 |
let minn_mull = Sections.section_proof ["m1";"m2";"n"] |
| 1399 |
`minn m1 m2 * n = minn (m1 * n) (m2 * n)` |
| 1400 |
[ |
| 1401 |
(((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then2 ("mulnC", [mulnC])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [(`_1 * n`)])))))) THEN (((use_arg_then2 ("minn_mulr", [minn_mulr]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1402 |
];; |
| 1403 |
parse_as_infix("^", (24, "left"));; |
| 1404 |
override_interface("^", `EXP`);; |
| 1405 |
|
| 1406 |
(* Lemma expn0 *) |
| 1407 |
let expn0 = Sections.section_proof ["m"] |
| 1408 |
`m ^ 0 = 1` |
| 1409 |
[ |
| 1410 |
((((use_arg_then2 ("EXP", [EXP]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1411 |
];; |
| 1412 |
|
| 1413 |
(* Lemma expn1 *) |
| 1414 |
let expn1 = Sections.section_proof ["m"] |
| 1415 |
`m ^ 1 = m` |
| 1416 |
[ |
| 1417 |
((((use_arg_then2 ("EXP_1", [EXP_1]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1418 |
];; |
| 1419 |
|
| 1420 |
(* Lemma expnS *) |
| 1421 |
let expnS = Sections.section_proof ["m";"n"] |
| 1422 |
`m ^ SUC n = m * m ^ n` |
| 1423 |
[ |
| 1424 |
((((use_arg_then2 ("EXP", [EXP]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1425 |
];; |
| 1426 |
|
| 1427 |
(* Lemma expnSr *) |
| 1428 |
let expnSr = Sections.section_proof ["m";"n"] |
| 1429 |
`m ^ SUC n = m ^ n * m` |
| 1430 |
[ |
| 1431 |
(((((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1432 |
];; |
| 1433 |
|
| 1434 |
(* Lemma exp0n *) |
| 1435 |
let exp0n = Sections.section_proof ["n"] |
| 1436 |
`0 < n ==> 0 ^ n = 0` |
| 1437 |
[ |
| 1438 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN case) [ALL_TAC; (move ["n"])]) ((((use_arg_then2 ("LT_REFL", [LT_REFL]))(thm_tac (new_rewrite [] [])))) THEN (done_tac))); |
| 1439 |
(((((use_arg_then2 ("EXP", [EXP]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1440 |
];; |
| 1441 |
|
| 1442 |
(* Lemma exp1n *) |
| 1443 |
let exp1n = Sections.section_proof ["n"] |
| 1444 |
`1 ^ n = 1` |
| 1445 |
[ |
| 1446 |
(((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [(((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))); ((((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mul1n", [mul1n]))(thm_tac (new_rewrite [] [])))))]) THEN (done_tac)); |
| 1447 |
];; |
| 1448 |
|
| 1449 |
(* Lemma expn_add *) |
| 1450 |
let expn_add = Sections.section_proof ["m";"n1";"n2"] |
| 1451 |
`m ^ (n1 + n2) = m ^ n1 * m ^ n2` |
| 1452 |
[ |
| 1453 |
(((THENL) (((use_arg_then2 ("n1", [])) (disch_tac [])) THEN (clear_assumption "n1") THEN elim) [ALL_TAC; ((move ["n1"]) THEN (move ["IHn"]))]) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("mul1n", [mul1n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("addSn", [addSn]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))))); |
| 1454 |
(((((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulnA", [mulnA]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1455 |
];; |
| 1456 |
|
| 1457 |
(* Lemma expn_mull *) |
| 1458 |
let expn_mull = Sections.section_proof ["m1";"m2";"n"] |
| 1459 |
`(m1 * m2) ^ n = m1 ^ n * m2 ^ n` |
| 1460 |
[ |
| 1461 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) (((repeat_tactic 1 9 (((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("muln1", [muln1]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1462 |
(((repeat_tactic 1 9 (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("mulnA", [mulnA]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("mulnCA", [mulnCA]))(thm_tac (new_rewrite [] [(`m2 * _1`)]))))) THEN (done_tac)); |
| 1463 |
];; |
| 1464 |
|
| 1465 |
(* Lemma expn_mulr *) |
| 1466 |
let expn_mulr = Sections.section_proof ["m";"n1";"n2"] |
| 1467 |
`m ^ (n1 * n2) = (m ^ n1) ^ n2` |
| 1468 |
[ |
| 1469 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n1", [])) (disch_tac [])) THEN (clear_assumption "n1") THEN elim) [ALL_TAC; ((move ["n1"]) THEN (move ["IHn"]))]) (((repeat_tactic 1 9 (((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("exp1n", [exp1n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1470 |
(((((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("expn_add", [expn_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("expn_mull", [expn_mull]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1471 |
];; |
| 1472 |
|
| 1473 |
(* Lemma expn_gt0 *) |
| 1474 |
let expn_gt0 = Sections.section_proof ["m";"n"] |
| 1475 |
`(0 < m ^ n) <=> (0 < m) \/ (n = 0)` |
| 1476 |
[ |
| 1477 |
((THENL_FIRST) (((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; (move ["m"])]) THEN ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))])) ((((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac))); |
| 1478 |
(((((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); |
| 1479 |
((((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 1480 |
(((((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addn_gt0", [addn_gt0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); |
| 1481 |
];; |
| 1482 |
|
| 1483 |
(* Lemma expn_eq0 *) |
| 1484 |
let expn_eq0 = Sections.section_proof ["m";"e"] |
| 1485 |
`(m ^ e = 0) <=> (m = 0) /\ (0 < e)` |
| 1486 |
[ |
| 1487 |
(((repeat_tactic 1 9 (((use_arg_then2 ("eqn0Ngt", [eqn0Ngt]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("expn_gt0", [expn_gt0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("negb_or", [negb_or]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("lt0n", [lt0n]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1488 |
];; |
| 1489 |
|
| 1490 |
(* Lemma ltn_expl *) |
| 1491 |
let ltn_expl = Sections.section_proof ["m";"n"] |
| 1492 |
`1 < m ==> n < m ^ n` |
| 1493 |
[ |
| 1494 |
((THENL_FIRST) ((BETA_TAC THEN (move ["m_gt1"])) THEN ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; (move ["n"])])) ((((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac))); |
| 1495 |
((((fun arg_tac -> (use_arg_then2 ("ltnW", [ltnW])) (fun fst_arg -> (use_arg_then2 ("m_gt1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then2 ("ONE", [ONE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((DISCH_THEN (fun snd_th -> (use_arg_then2 ("leq_pmul2l", [leq_pmul2l])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC)); |
| 1496 |
(((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))); |
| 1497 |
((((use_arg_then2 ("leq_trans", [leq_trans])) (disch_tac [])) THEN (clear_assumption "leq_trans") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] [])))))); |
| 1498 |
((((fun arg_tac -> (use_arg_then2 ("ltn_Pmull", [ltn_Pmull])) (fun fst_arg -> (use_arg_then2 ("m_gt1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN (arith_tac) THEN (done_tac)); |
| 1499 |
];; |
| 1500 |
|
| 1501 |
(* Lemma leq_exp2l *) |
| 1502 |
let leq_exp2l = Sections.section_proof ["m";"n1";"n2"] |
| 1503 |
`1 < m ==> (m ^ n1 <= m ^ n2 <=> n1 <= n2)` |
| 1504 |
[ |
| 1505 |
((THENL_ROT (-1)) ((BETA_TAC THEN (move ["m_gt1"])) THEN ((THENL) (((use_arg_then2 ("n2", [])) (disch_tac [])) THEN (clear_assumption "n2") THEN ((use_arg_then2 ("n1", [])) (disch_tac [])) THEN (clear_assumption "n1") THEN elim) [ALL_TAC; ((move ["n1"]) THEN (move ["IHn"]))]) THEN (BETA_TAC THEN ((THENL) case [ALL_TAC; (move ["q"])])) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))))); |
| 1506 |
(((repeat_tactic 1 9 (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_pmul2l", [leq_pmul2l]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("leqSS", [leqSS]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltnW", [ltnW]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ONE", [ONE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1507 |
(((((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ONE", [ONE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("expn_gt0", [expn_gt0]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("m_gt1", [])) (disch_tac [])) THEN (clear_assumption "m_gt1") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); |
| 1508 |
((((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] []))))); |
| 1509 |
((((use_arg_then2 ("m_gt1", [])) (disch_tac [])) THEN (clear_assumption "m_gt1") THEN BETA_TAC) THEN ((((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] [])))) THEN (move ["m_gt1"]))); |
| 1510 |
((((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then2 ("leq_trans", [leq_trans])) (fun fst_arg -> (use_arg_then2 ("m_gt1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("ltE", [ltE]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("ltn0", [ltn0]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_pmulr", [leq_pmulr]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("expn_gt0", [expn_gt0]))(thm_tac (new_rewrite [] []))))); |
| 1511 |
((((use_arg_then2 ("m_gt1", [])) (disch_tac [])) THEN (clear_assumption "m_gt1") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); |
| 1512 |
];; |
| 1513 |
|
| 1514 |
(* Lemma ltn_exp2l *) |
| 1515 |
let ltn_exp2l = Sections.section_proof ["m";"n1";"n2"] |
| 1516 |
`1 < m ==> (m ^ n1 < m ^ n2 <=> n1 < n2)` |
| 1517 |
[ |
| 1518 |
((BETA_TAC THEN (move ["m_gt1"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_exp2l", [leq_exp2l]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1519 |
];; |
| 1520 |
|
| 1521 |
(* Lemma eqn_exp2l *) |
| 1522 |
let eqn_exp2l = Sections.section_proof ["m";"n1";"n2"] |
| 1523 |
`1 < m ==> (m ^ n1 = m ^ n2 <=> n1 = n2)` |
| 1524 |
[ |
| 1525 |
((BETA_TAC THEN (move ["m_gt1"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leq_exp2l", [leq_exp2l]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1526 |
];; |
| 1527 |
|
| 1528 |
(* Lemma expnI *) |
| 1529 |
let expnI = Sections.section_proof ["m"] |
| 1530 |
`1 < m ==> !e1 e2. m ^ e1 = m ^ e2 ==> e1 = e2` |
| 1531 |
[ |
| 1532 |
((BETA_TAC THEN (move ["m_gt1"]) THEN (move ["e1"]) THEN (move ["e2"])) THEN (((use_arg_then2 ("eqn_exp2l", [eqn_exp2l]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 1533 |
];; |
| 1534 |
|
| 1535 |
(* Lemma leq_pexp2l *) |
| 1536 |
let leq_pexp2l = Sections.section_proof ["m";"n1";"n2"] |
| 1537 |
`0 < m ==> n1 <= n2 ==> m ^ n1 <= m ^ n2` |
| 1538 |
[ |
| 1539 |
(((THENL) (((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; ((THENL) case [ALL_TAC; (move ["m"])])]) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("ltn0", [ltn0]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))) [((((use_arg_then2 ("ONE", [ONE]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("exp1n", [exp1n]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))); ((((use_arg_then2 ("leq_exp2l", [leq_exp2l]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)))]) THEN (arith_tac) THEN (done_tac)); |
| 1540 |
];; |
| 1541 |
|
| 1542 |
(* Lemma ltn_pexp2l *) |
| 1543 |
let ltn_pexp2l = Sections.section_proof ["m";"n1";"n2"] |
| 1544 |
`0 < m ==> m ^ n1 < m ^ n2 ==> n1 < n2` |
| 1545 |
[ |
| 1546 |
(((THENL) (((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN case) [ALL_TAC; ((THENL) case [ALL_TAC; (move ["m"])])]) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("ltn0", [ltn0]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))) [((((use_arg_then2 ("ONE", [ONE]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("exp1n", [exp1n]))(thm_tac (new_rewrite [] [])))))); (((use_arg_then2 ("ltn_exp2l", [ltn_exp2l]))(thm_tac (new_rewrite [] []))))]) THEN (arith_tac) THEN (done_tac)); |
| 1547 |
];; |
| 1548 |
|
| 1549 |
(* Lemma ltn_exp2r *) |
| 1550 |
let ltn_exp2r = Sections.section_proof ["m";"n";"e"] |
| 1551 |
`0 < e ==> (m ^ e < n ^ e <=> m < n)` |
| 1552 |
[ |
| 1553 |
((BETA_TAC THEN (move ["e_gt0"])) THEN ((THENL) (split_tac) [ALL_TAC; (move ["ltmn"])])); |
| 1554 |
((repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("contra", [contra])) (disch_tac [])) THEN (clear_assumption "contra") THEN (DISCH_THEN apply_tac) THEN (move ["lemn"]))); |
| 1555 |
(((THENL) (((use_arg_then2 ("e", [])) (disch_tac [])) THEN (clear_assumption "e") THEN elim) [ALL_TAC; ((move ["e'"]) THEN (move ["IHe"]))]) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_mul", [leq_mul]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1556 |
((THENL_FIRST) (((use_arg_then2 ("e_gt0", [])) (disch_tac [])) THEN (clear_assumption "e_gt0") THEN ((use_arg_then2 ("e", [])) (disch_tac [])) THEN (clear_assumption "e") THEN elim) ((((use_arg_then2 ("ltnn", [ltnn]))(thm_tac (new_rewrite [] [])))) THEN (done_tac))); |
| 1557 |
((THENL_FIRST) (BETA_TAC THEN ((THENL) case [ALL_TAC; ((move ["e"]) THEN (move ["IHe"]))])) (((((use_arg_then2 ("ONE", [ONE]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("expn1", [expn1]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac))); |
| 1558 |
(((repeat_tactic 1 9 (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("ltn_mul", [ltn_mul]))(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then2 ("expnS", [expnS]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("IHe", []))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (arith_tac)); |
| 1559 |
];; |
| 1560 |
|
| 1561 |
(* Lemma leq_exp2r *) |
| 1562 |
let leq_exp2r = Sections.section_proof ["m";"n";"e"] |
| 1563 |
`0 < e ==> (m ^ e <= n ^ e <=> m <= n)` |
| 1564 |
[ |
| 1565 |
((BETA_TAC THEN (move ["e_gt0"])) THEN ((((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltn_exp2r", [ltn_exp2r]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("leqNgt", [leqNgt]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1566 |
];; |
| 1567 |
|
| 1568 |
(* Lemma eqn_exp2r *) |
| 1569 |
let eqn_exp2r = Sections.section_proof ["m";"n";"e"] |
| 1570 |
`0 < e ==> (m ^ e = n ^ e <=> m = n)` |
| 1571 |
[ |
| 1572 |
((BETA_TAC THEN (move ["e_gt0"])) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leq_exp2r", [leq_exp2r]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1573 |
];; |
| 1574 |
|
| 1575 |
(* Lemma expIn *) |
| 1576 |
let expIn = Sections.section_proof ["e"] |
| 1577 |
`0 < e ==> !m n. m ^ e = n ^ e ==> m = n` |
| 1578 |
[ |
| 1579 |
((BETA_TAC THEN (move ["e_gt0"]) THEN (move ["m"]) THEN (move ["n"])) THEN (((use_arg_then2 ("eqn_exp2r", [eqn_exp2r]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 1580 |
];; |
| 1581 |
|
| 1582 |
(* Lemma fact0 *) |
| 1583 |
let fact0 = Sections.section_proof [] |
| 1584 |
`FACT 0 = 1` |
| 1585 |
[ |
| 1586 |
((((use_arg_then2 ("FACT", [FACT]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1587 |
];; |
| 1588 |
|
| 1589 |
(* Lemma factS *) |
| 1590 |
let factS = Sections.section_proof ["n"] |
| 1591 |
`FACT (SUC n) = (SUC n) * FACT n` |
| 1592 |
[ |
| 1593 |
((((use_arg_then2 ("FACT", [FACT]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1594 |
];; |
| 1595 |
|
| 1596 |
(* Lemma fact_gt0 *) |
| 1597 |
let fact_gt0 = Sections.section_proof ["n"] |
| 1598 |
`0 < FACT n` |
| 1599 |
[ |
| 1600 |
(((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; (move ["n"])]) THEN ((((use_arg_then2 ("FACT", [FACT]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("muln_gt0", [muln_gt0]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))))) THEN (arith_tac) THEN (done_tac)); |
| 1601 |
];; |
| 1602 |
let odd = new_basic_definition `odd = ODD`;; |
| 1603 |
|
| 1604 |
(* Lemma odd0 *) |
| 1605 |
let odd0 = Sections.section_proof [] |
| 1606 |
`odd 0 = F` |
| 1607 |
[ |
| 1608 |
((((use_arg_then2 ("odd", [odd]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 2 0 (((use_arg_then2 ("ODD", [ODD]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1609 |
];; |
| 1610 |
|
| 1611 |
(* Lemma oddS *) |
| 1612 |
let oddS = Sections.section_proof ["n"] |
| 1613 |
`odd (SUC n) = ~odd n` |
| 1614 |
[ |
| 1615 |
(((((use_arg_then2 ("odd", [odd]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("ODD", [ODD]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1616 |
];; |
| 1617 |
|
| 1618 |
(* Lemma odd1 *) |
| 1619 |
let odd1 = Sections.section_proof [] |
| 1620 |
`odd 1 = T` |
| 1621 |
[ |
| 1622 |
(((((use_arg_then2 ("ONE", [ONE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("oddS", [oddS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd0", [odd0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1623 |
];; |
| 1624 |
|
| 1625 |
(* Lemma odd_add *) |
| 1626 |
let odd_add = Sections.section_proof ["m";"n"] |
| 1627 |
`odd (m + n) = odd m + odd n` |
| 1628 |
[ |
| 1629 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; ((move ["m"]) THEN (move ["IHn"]))]) (((((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd0", [odd0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addFb", [addFb]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1630 |
(((((use_arg_then2 ("addSn", [addSn]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("oddS", [oddS]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addTb", [addTb]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addbA", [addbA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addTb", [addTb]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1631 |
];; |
| 1632 |
|
| 1633 |
(* Lemma odd_sub *) |
| 1634 |
let odd_sub = Sections.section_proof ["m";"n"] |
| 1635 |
`n <= m ==> odd (m - n) = odd m + odd n` |
| 1636 |
[ |
| 1637 |
((BETA_TAC THEN (move ["le_nm"])) THEN (((fun arg_tac -> (use_arg_then2 ("addIb", [addIb])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`odd n`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then2 ("odd_add", [odd_add]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subnK", [subnK]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("addbK", [addbK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1638 |
];; |
| 1639 |
|
| 1640 |
(* Lemma odd_opp *) |
| 1641 |
let odd_opp = Sections.section_proof ["i";"m"] |
| 1642 |
`odd m = F ==> i < m ==> odd (m - i) = odd i` |
| 1643 |
[ |
| 1644 |
(BETA_TAC THEN (move ["oddm"]) THEN (move ["lt_im"])); |
| 1645 |
(((((fun arg_tac -> (use_arg_then2 ("odd_sub", [odd_sub])) (fun fst_arg -> (fun arg_tac -> (use_arg_then2 ("ltnW", [ltnW])) (fun fst_arg -> (use_arg_then2 ("lt_im", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("oddm", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addFb", [addFb]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1646 |
];; |
| 1647 |
|
| 1648 |
(* Lemma odd_mul *) |
| 1649 |
let odd_mul = Sections.section_proof ["m";"n"] |
| 1650 |
`odd (m * n) <=> odd m /\ odd n` |
| 1651 |
[ |
| 1652 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; ((move ["m"]) THEN (move ["IHm"]))]) (((((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd0", [odd0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("andFb", [andFb]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1653 |
(((((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd_add", [odd_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("oddS", [oddS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addTb", [addTb]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("andb_addl", [andb_addl]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("IHm", []))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("andTb", [andTb]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1654 |
];; |
| 1655 |
|
| 1656 |
(* Lemma odd_exp *) |
| 1657 |
let odd_exp = Sections.section_proof ["m";"n"] |
| 1658 |
`odd (m ^ n) <=> (n = 0) \/ odd m` |
| 1659 |
[ |
| 1660 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) (((((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd1", [odd1]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1661 |
((((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd_mul", [odd_mul]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("orbC", [orbC]))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `SUC n = 0 <=> F`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("orFb", [orFb]))(thm_tac (new_rewrite [] []))))); |
| 1662 |
((fun arg_tac -> arg_tac (Arg_term (`odd m`))) (term_tac (set_tac "b"))); |
| 1663 |
(((use_arg_then2 ("IHn", [])) (disch_tac [])) THEN (clear_assumption "IHn") THEN ((use_arg_then2 ("b_def", [])) (disch_tac [])) THEN (clear_assumption "b_def") THEN BETA_TAC THEN (move ["_"]) THEN (move ["_"])); |
| 1664 |
((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac)); |
| 1665 |
];; |
| 1666 |
let double = define `double 0 = 0 /\ (!n. double (SUC n) = SUC (SUC (double n)))`;; |
| 1667 |
|
| 1668 |
(* Lemma double0 *) |
| 1669 |
let double0 = Sections.section_proof [] |
| 1670 |
`double 0 = 0` |
| 1671 |
[ |
| 1672 |
((((use_arg_then2 ("double", [double]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1673 |
];; |
| 1674 |
|
| 1675 |
(* Lemma doubleS *) |
| 1676 |
let doubleS = Sections.section_proof ["n"] |
| 1677 |
`double (SUC n) = SUC (SUC (double n))` |
| 1678 |
[ |
| 1679 |
((((use_arg_then2 ("double", [double]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); |
| 1680 |
];; |
| 1681 |
|
| 1682 |
(* Lemma addnn *) |
| 1683 |
let addnn = Sections.section_proof ["n"] |
| 1684 |
`n + n = double n` |
| 1685 |
[ |
| 1686 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) (((((use_arg_then2 ("addn0", [addn0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1687 |
(((((use_arg_then2 ("addnS", [addnS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addSn", [addSn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("doubleS", [doubleS]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1688 |
];; |
| 1689 |
|
| 1690 |
(* Lemma mul2n *) |
| 1691 |
let mul2n = Sections.section_proof ["m"] |
| 1692 |
`2 * m = double m` |
| 1693 |
[ |
| 1694 |
(((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `2 = SUC 1`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulSn", [mulSn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mul1n", [mul1n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnn", [addnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1695 |
];; |
| 1696 |
|
| 1697 |
(* Lemma muln2 *) |
| 1698 |
let muln2 = Sections.section_proof ["m"] |
| 1699 |
`m * 2 = double m` |
| 1700 |
[ |
| 1701 |
(((((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mul2n", [mul2n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1702 |
];; |
| 1703 |
|
| 1704 |
(* Lemma double_add *) |
| 1705 |
let double_add = Sections.section_proof ["m";"n"] |
| 1706 |
`double (m + n) = double m + double n` |
| 1707 |
[ |
| 1708 |
(((repeat_tactic 1 9 (((use_arg_then2 ("addnn", [addnn]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((fun arg_tac -> (use_arg_then2 ("addnCA", [addnCA])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [(`n + _1`)]))))) THEN (done_tac)); |
| 1709 |
];; |
| 1710 |
|
| 1711 |
(* Lemma double_sub *) |
| 1712 |
let double_sub = Sections.section_proof ["m";"n"] |
| 1713 |
`double (m - n) = double m - double n` |
| 1714 |
[ |
| 1715 |
((((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN ((use_arg_then2 ("m", [])) (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; ((move ["m"]) THEN (move ["IHm"]))]) THEN ((THENL) case [ALL_TAC; (move ["n"])])) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("sub0n", [sub0n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("subn0", [subn0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("subn0", [subn0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("sub0n", [sub0n]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); |
| 1716 |
(((repeat_tactic 1 9 (((use_arg_then2 ("doubleS", [doubleS]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("subSS", [subSS]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("IHm", []))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1717 |
];; |
| 1718 |
|
| 1719 |
(* Lemma leq_double *) |
| 1720 |
let leq_double = Sections.section_proof ["m";"n"] |
| 1721 |
`(double m <= double n <=> m <= n)` |
| 1722 |
[ |
| 1723 |
(((repeat_tactic 1 9 (((use_arg_then2 ("leqE", [leqE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("double_sub", [double_sub]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((THENL) (((fun arg_tac -> arg_tac (Arg_term (`m - n`))) (disch_tac [])) THEN case) [ALL_TAC; (move ["n"])]) THEN (((use_arg_then2 ("double", [double]))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); |
| 1724 |
];; |
| 1725 |
|
| 1726 |
(* Lemma ltn_double *) |
| 1727 |
let ltn_double = Sections.section_proof ["m";"n"] |
| 1728 |
`(double m < double n) = (m < n)` |
| 1729 |
[ |
| 1730 |
(((repeat_tactic 2 0 (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_double", [leq_double]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1731 |
];; |
| 1732 |
|
| 1733 |
(* Lemma ltn_Sdouble *) |
| 1734 |
let ltn_Sdouble = Sections.section_proof ["m";"n"] |
| 1735 |
`(SUC (double m) < double n) = (m < n)` |
| 1736 |
[ |
| 1737 |
((repeat_tactic 1 9 (((use_arg_then2 ("muln2", [muln2]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac)); |
| 1738 |
];; |
| 1739 |
|
| 1740 |
(* Lemma leq_Sdouble *) |
| 1741 |
let leq_Sdouble = Sections.section_proof ["m";"n"] |
| 1742 |
`(double m <= SUC (double n)) = (m <= n)` |
| 1743 |
[ |
| 1744 |
(((((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltn_Sdouble", [ltn_Sdouble]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqNgt", [leqNgt]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1745 |
];; |
| 1746 |
|
| 1747 |
(* Lemma odd_double *) |
| 1748 |
let odd_double = Sections.section_proof ["n"] |
| 1749 |
`odd (double n) = F` |
| 1750 |
[ |
| 1751 |
(((((use_arg_then2 ("addnn", [addnn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("odd_add", [odd_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addbb", [addbb]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1752 |
];; |
| 1753 |
|
| 1754 |
(* Lemma double_gt0 *) |
| 1755 |
let double_gt0 = Sections.section_proof ["n"] |
| 1756 |
`(0 < double n) = (0 < n)` |
| 1757 |
[ |
| 1758 |
(((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN case) [ALL_TAC; (move ["n"])]) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("doubleS", [doubleS]))(thm_tac (new_rewrite [] []))))) THEN (arith_tac)); |
| 1759 |
];; |
| 1760 |
|
| 1761 |
(* Lemma double_eq0 *) |
| 1762 |
let double_eq0 = Sections.section_proof ["n"] |
| 1763 |
`(double n = 0) = (n = 0)` |
| 1764 |
[ |
| 1765 |
(((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN case) [ALL_TAC; (move ["n"])]) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("doubleS", [doubleS]))(thm_tac (new_rewrite [] []))))) THEN (arith_tac)); |
| 1766 |
];; |
| 1767 |
|
| 1768 |
(* Lemma double_mull *) |
| 1769 |
let double_mull = Sections.section_proof ["m";"n"] |
| 1770 |
`double (m * n) = double m * n` |
| 1771 |
[ |
| 1772 |
(((repeat_tactic 1 9 (((use_arg_then2 ("mul2n", [mul2n]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("mulnA", [mulnA]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1773 |
];; |
| 1774 |
|
| 1775 |
(* Lemma double_mulr *) |
| 1776 |
let double_mulr = Sections.section_proof ["m";"n"] |
| 1777 |
`double (m * n) = m * double n` |
| 1778 |
[ |
| 1779 |
(((repeat_tactic 1 9 (((use_arg_then2 ("muln2", [muln2]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("mulnA", [mulnA]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1780 |
];; |
| 1781 |
let half_def = define `HALF 0 = (0, 0) /\ |
| 1782 |
!n. HALF (SUC n) = (SND (HALF n), SUC (FST (HALF n)))`;; |
| 1783 |
let half = new_basic_definition `half = FST o HALF`;; |
| 1784 |
let uphalf = new_basic_definition `uphalf = SND o HALF`;; |
| 1785 |
|
| 1786 |
(* Lemma half0 *) |
| 1787 |
let half0 = Sections.section_proof [] |
| 1788 |
`half 0 = 0` |
| 1789 |
[ |
| 1790 |
(((((use_arg_then2 ("half", [half]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("o_DEF", [o_DEF]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (simp_tac) THEN (((use_arg_then2 ("half_def", [half_def]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1791 |
];; |
| 1792 |
|
| 1793 |
(* Lemma uphalf0 *) |
| 1794 |
let uphalf0 = Sections.section_proof [] |
| 1795 |
`uphalf 0 = 0` |
| 1796 |
[ |
| 1797 |
(((((use_arg_then2 ("uphalf", [uphalf]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("o_DEF", [o_DEF]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (simp_tac) THEN (((use_arg_then2 ("half_def", [half_def]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1798 |
];; |
| 1799 |
|
| 1800 |
(* Lemma halfS *) |
| 1801 |
let halfS = Sections.section_proof ["n"] |
| 1802 |
`half (SUC n) = uphalf n` |
| 1803 |
[ |
| 1804 |
(((((use_arg_then2 ("half", [half]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("uphalf", [uphalf]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("o_DEF", [o_DEF]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (simp_tac) THEN (((use_arg_then2 ("half_def", [half_def]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1805 |
];; |
| 1806 |
|
| 1807 |
(* Lemma uphalfS *) |
| 1808 |
let uphalfS = Sections.section_proof ["n"] |
| 1809 |
`uphalf (SUC n) = SUC (half n)` |
| 1810 |
[ |
| 1811 |
(((((use_arg_then2 ("half", [half]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("uphalf", [uphalf]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then2 ("o_DEF", [o_DEF]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (simp_tac) THEN (((use_arg_then2 ("half_def", [half_def]))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); |
| 1812 |
];; |
| 1813 |
|
| 1814 |
(* Lemma doubleK *) |
| 1815 |
let doubleK = Sections.section_proof ["x"] |
| 1816 |
`half (double x) = x` |
| 1817 |
[ |
| 1818 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("x", [])) (disch_tac [])) THEN (clear_assumption "x") THEN elim) [ALL_TAC; (move ["n"])]) (((((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("half0", [half0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1819 |
((((((use_arg_then2 ("doubleS", [doubleS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("halfS", [halfS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("uphalfS", [uphalfS]))(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1820 |
];; |
| 1821 |
let half_double = doubleK;; |
| 1822 |
|
| 1823 |
(* Lemma double_inj *) |
| 1824 |
let double_inj = Sections.section_proof [] |
| 1825 |
`!m n. double m = double n ==> m = n` |
| 1826 |
[ |
| 1827 |
(BETA_TAC THEN (move ["m"]) THEN (move ["n"])); |
| 1828 |
((((((use_arg_then2 ("doubleK", [doubleK]))(gsym_then (thm_tac (new_rewrite [2] [(`m`)]))))) THEN (((use_arg_then2 ("doubleK", [doubleK]))(gsym_then (thm_tac (new_rewrite [2] [(`n`)])))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1829 |
];; |
| 1830 |
|
| 1831 |
(* Lemma uphalf_double *) |
| 1832 |
let uphalf_double = Sections.section_proof ["n"] |
| 1833 |
`uphalf (double n) = n` |
| 1834 |
[ |
| 1835 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; (move ["n"])]) (((((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("uphalf0", [uphalf0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1836 |
((((((use_arg_then2 ("doubleS", [doubleS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("uphalfS", [uphalfS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("halfS", [halfS]))(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1837 |
];; |
| 1838 |
|
| 1839 |
(* Lemma uphalf_half *) |
| 1840 |
let uphalf_half = Sections.section_proof ["n"] |
| 1841 |
`uphalf n = (if odd n then 1 else 0) + half n` |
| 1842 |
[ |
| 1843 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) (((((use_arg_then2 ("uphalf0", [uphalf0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("half0", [half0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd0", [odd0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addn0", [addn0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1844 |
((((use_arg_then2 ("halfS", [halfS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("IHn", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnA", [addnA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("oddS", [oddS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("uphalfS", [uphalfS]))(thm_tac (new_rewrite [] []))))); |
| 1845 |
((((fun arg_tac -> arg_tac (Arg_term (`odd n`))) (disch_tac [])) THEN case THEN (simp_tac)) THEN ((((fun arg_tac ->(use_arg_then2 ("add0n", [add0n]))(fun tmp_arg1 -> (use_arg_then2 ("addn0", [addn0]))(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1846 |
];; |
| 1847 |
|
| 1848 |
(* Lemma odd_double_half *) |
| 1849 |
let odd_double_half = Sections.section_proof ["n"] |
| 1850 |
`(if odd n then 1 else 0) + double (half n) = n` |
| 1851 |
[ |
| 1852 |
((THENL_FIRST) ((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) (((((use_arg_then2 ("odd0", [odd0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("half0", [half0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then2 ("addn0", [addn0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 1853 |
((((use_arg_then2 ("IHn", []))(gsym_then (thm_tac (new_rewrite [3] []))))) THEN (((use_arg_then2 ("halfS", [halfS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("uphalf_half", [uphalf_half]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("double_add", [double_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("oddS", [oddS]))(thm_tac (new_rewrite [] []))))); |
| 1854 |
(((use_arg_then2 ("IHn", [])) (disch_tac [])) THEN (clear_assumption "IHn") THEN BETA_TAC THEN (move ["_"])); |
| 1855 |
((((fun arg_tac -> arg_tac (Arg_term (`odd n`))) (disch_tac [])) THEN case THEN (simp_tac)) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("ONE", [ONE]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("doubleS", [doubleS]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addSn", [addSn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("double0", [double0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1856 |
];; |
| 1857 |
|
| 1858 |
(* Lemma half_bit_double *) |
| 1859 |
let half_bit_double = Sections.section_proof ["n";"b"] |
| 1860 |
`half ((if b then 1 else 0) + double n) = n` |
| 1861 |
[ |
| 1862 |
((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN ((simp_tac) THEN (repeat_tactic 0 10 (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("halfS", [halfS]))(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac ->(use_arg_then2 ("half_double", [half_double]))(fun tmp_arg1 -> (use_arg_then2 ("uphalf_double", [uphalf_double]))(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1863 |
];; |
| 1864 |
|
| 1865 |
(* Lemma half_add *) |
| 1866 |
let half_add = Sections.section_proof ["m";"n"] |
| 1867 |
`half (m + n) = (if odd m /\ odd n then 1 else 0) + (half m + half n)` |
| 1868 |
[ |
| 1869 |
((((use_arg_then2 ("odd_double_half", [odd_double_half]))(gsym_then (thm_tac (new_rewrite [1] [(`n`)]))))) THEN (((use_arg_then2 ("addnCA", [addnCA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("odd_double_half", [odd_double_half]))(gsym_then (thm_tac (new_rewrite [1] [(`m`)]))))) THEN (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("double_add", [double_add]))(gsym_then (thm_tac (new_rewrite [] [])))))); |
| 1870 |
((repeat_tactic 2 0 ((((fun arg_tac -> arg_tac (Arg_term (`odd _`))) (disch_tac [])) THEN case))) THEN ((simp_tac) THEN (repeat_tactic 0 10 (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("half_double", [half_double]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("halfS", [halfS]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("uphalfS", [uphalfS]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("uphalf_double", [uphalf_double]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); |
| 1871 |
((((use_arg_then2 ("half_double", [half_double]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 1872 |
];; |
| 1873 |
|
| 1874 |
(* Lemma half_leq *) |
| 1875 |
let half_leq = Sections.section_proof ["m";"n"] |
| 1876 |
`m <= n ==> half m <= half n` |
| 1877 |
[ |
| 1878 |
(((DISCH_THEN (fun snd_th -> (use_arg_then2 ("subnK", [subnK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then2 ("half_add", [half_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnA", [addnA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leq_addl", [leq_addl]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1879 |
];; |
| 1880 |
|
| 1881 |
(* Lemma half_gt0 *) |
| 1882 |
let half_gt0 = Sections.section_proof ["n"] |
| 1883 |
`(0 < half n) = (1 < n)` |
| 1884 |
[ |
| 1885 |
(((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN case) [ALL_TAC; (case THEN ALL_TAC)]) THEN ((repeat_tactic 0 10 (((use_arg_then2 ("halfS", [halfS]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("uphalfS", [uphalfS]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("uphalf0", [uphalf0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("half0", [half0]))(thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac)); |
| 1886 |
];; |
| 1887 |
|
| 1888 |
(* Lemma mulnn *) |
| 1889 |
let mulnn = Sections.section_proof ["m"] |
| 1890 |
`m * m = m ^ 2` |
| 1891 |
[ |
| 1892 |
(((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `2 = SUC (SUC 0)`)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("expnS", [expnS]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("expn0", [expn0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("muln1", [muln1]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1893 |
];; |
| 1894 |
|
| 1895 |
(* Lemma sqrn_add *) |
| 1896 |
let sqrn_add = Sections.section_proof ["m";"n"] |
| 1897 |
`(m + n) ^ 2 = (m ^ 2 + n ^ 2) + 2 * (m * n)` |
| 1898 |
[ |
| 1899 |
((repeat_tactic 1 9 (((use_arg_then2 ("mulnn", [mulnn]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("mul2n", [mul2n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("muln_addr", [muln_addr]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("muln_addl", [muln_addl]))(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> (use_arg_then2 ("mulnC", [mulnC])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] []))))))); |
| 1900 |
(((((use_arg_then2 ("EQ_ADD_LCANCEL", [EQ_ADD_LCANCEL]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnA", [addnA]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnn", [addnn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1901 |
];; |
| 1902 |
|
| 1903 |
(* Lemma sqrn_sub *) |
| 1904 |
let sqrn_sub = Sections.section_proof ["m";"n"] |
| 1905 |
`n <= m ==> (m - n) ^ 2 = (m ^ 2 + n ^ 2) - 2 * (m * n)` |
| 1906 |
[ |
| 1907 |
((DISCH_THEN (fun snd_th -> (use_arg_then2 ("subnK", [subnK])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (move ["def_m"])); |
| 1908 |
((((use_arg_then2 ("def_m", []))(gsym_then (thm_tac (new_rewrite [2] []))))) THEN (((use_arg_then2 ("sqrn_add", [sqrn_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnAC", [addnAC]))(thm_tac (new_rewrite [] []))))); |
| 1909 |
(((repeat_tactic 2 0 (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("addnn", [addnn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mul2n", [mul2n]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("muln_addr", [muln_addr]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("mulnn", [mulnn]))(gsym_then (thm_tac (new_rewrite [] [(`n EXP 2`)]))))) THEN (((use_arg_then2 ("muln_addl", [muln_addl]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("def_m", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnK", [addnK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1910 |
];; |
| 1911 |
|
| 1912 |
(* Lemma sqrn_add_sub *) |
| 1913 |
let sqrn_add_sub = Sections.section_proof ["m";"n"] |
| 1914 |
`n <= m ==> (m + n) ^ 2 - 4 * (m * n) = (m - n) ^ 2` |
| 1915 |
[ |
| 1916 |
((BETA_TAC THEN (move ["le_nm"])) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `4 = 2 * 2`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulnA", [mulnA]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("mul2n", [mul2n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnn", [addnn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subn_sub", [subn_sub]))(gsym_then (thm_tac (new_rewrite [] []))))))); |
| 1917 |
(((((use_arg_then2 ("sqrn_add", [sqrn_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnK", [addnK]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("sqrn_sub", [sqrn_sub]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1918 |
];; |
| 1919 |
|
| 1920 |
(* Lemma subn_sqr *) |
| 1921 |
let subn_sqr = Sections.section_proof ["m";"n"] |
| 1922 |
`m ^ 2 - n ^ 2 = (m - n) * (m + n)` |
| 1923 |
[ |
| 1924 |
(((((use_arg_then2 ("muln_subl", [muln_subl]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("muln_addr", [muln_addr]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then2 ("mulnC", [mulnC])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subn_add2l", [subn_add2l]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("mulnn", [mulnn]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 1925 |
];; |
| 1926 |
|
| 1927 |
(* Lemma ltn_sqr *) |
| 1928 |
let ltn_sqr = Sections.section_proof ["m";"n"] |
| 1929 |
`(m ^ 2 < n ^ 2) = (m < n)` |
| 1930 |
[ |
| 1931 |
(((((use_arg_then2 ("ltn_exp2r", [ltn_exp2r]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (arith_tac) THEN (done_tac)); |
| 1932 |
];; |
| 1933 |
|
| 1934 |
(* Lemma leq_sqr *) |
| 1935 |
let leq_sqr = Sections.section_proof ["m";"n"] |
| 1936 |
`(m ^ 2 <= n ^ 2) = (m <= n)` |
| 1937 |
[ |
| 1938 |
(((((use_arg_then2 ("leq_exp2r", [leq_exp2r]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (arith_tac) THEN (done_tac)); |
| 1939 |
];; |
| 1940 |
|
| 1941 |
(* Lemma sqrn_gt0 *) |
| 1942 |
let sqrn_gt0 = Sections.section_proof ["n"] |
| 1943 |
`(0 < n ^ 2) = (0 < n)` |
| 1944 |
[ |
| 1945 |
((THENL_FIRST) ((((fun arg_tac -> (use_arg_then2 ("ltn_sqr", [ltn_sqr])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((use_arg_then2 ("exp0n", [exp0n]))(thm_tac (new_rewrite [] []))))) ((arith_tac) THEN (done_tac))); |
| 1946 |
((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1947 |
];; |
| 1948 |
|
| 1949 |
(* Lemma eqn_sqr *) |
| 1950 |
let eqn_sqr = Sections.section_proof ["m";"n"] |
| 1951 |
`(m ^ 2 = n ^ 2) = (m = n)` |
| 1952 |
[ |
| 1953 |
(((((use_arg_then2 ("eqn_exp2r", [eqn_exp2r]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (arith_tac) THEN (done_tac)); |
| 1954 |
];; |
| 1955 |
|
| 1956 |
(* Lemma sqrn_inj *) |
| 1957 |
let sqrn_inj = Sections.section_proof ["m";"n"] |
| 1958 |
`m ^ 2 = n ^ 2 ==> m = n` |
| 1959 |
[ |
| 1960 |
(BETA_TAC THEN (move ["eq"])); |
| 1961 |
(((fun arg_tac -> (use_arg_then2 ("expIn", [expIn])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 < 2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (move ["inj"])); |
| 1962 |
((((fun arg_tac -> (use_arg_then2 ("inj", [])) (fun fst_arg -> (use_arg_then2 ("eq", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 1963 |
];; |
| 1964 |
let leqif = new_definition `!m n c. leqif m n c <=> (m <= n /\ ((m = n) <=> c))`;; |
| 1965 |
|
| 1966 |
(* Lemma leqifP *) |
| 1967 |
let leqifP = Sections.section_proof ["m";"n";"c"] |
| 1968 |
`leqif m n c <=> if c then m = n else m < n` |
| 1969 |
[ |
| 1970 |
((THENL_FIRST) (((((use_arg_then2 ("ltn_neqAle", [ltn_neqAle]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] []))))) THEN (split_tac)) ((((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac))); |
| 1971 |
((((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 1972 |
];; |
| 1973 |
|
| 1974 |
(* Lemma leqif_imp_le *) |
| 1975 |
let leqif_imp_le = Sections.section_proof ["m";"n";"c"] |
| 1976 |
`leqif m n c ==> m <= n` |
| 1977 |
[ |
| 1978 |
(((((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac)); |
| 1979 |
];; |
| 1980 |
|
| 1981 |
(* Lemma leqif_imp_eq *) |
| 1982 |
let leqif_imp_eq = Sections.section_proof ["m";"n";"c"] |
| 1983 |
`leqif m n c ==> (m = n <=> c)` |
| 1984 |
[ |
| 1985 |
(((((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac)); |
| 1986 |
];; |
| 1987 |
|
| 1988 |
(* Lemma leqif_refl *) |
| 1989 |
let leqif_refl = Sections.section_proof ["m";"c"] |
| 1990 |
`(leqif m m c) <=> c` |
| 1991 |
[ |
| 1992 |
(((((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 1993 |
];; |
| 1994 |
|
| 1995 |
(* Lemma leqif_trans *) |
| 1996 |
let leqif_trans = Sections.section_proof ["m1";"m2";"m3";"c1";"c2"] |
| 1997 |
`leqif m1 m2 c1 ==> leqif m2 m3 c2 ==> leqif m1 m3 (c1 /\ c2)` |
| 1998 |
[ |
| 1999 |
(repeat_tactic 1 9 (((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] []))))); |
| 2000 |
((THENL_FIRST) ((((use_arg_then2 ("c1", [])) (disch_tac [])) THEN (clear_assumption "c1") THEN case) THEN (((use_arg_then2 ("c2", [])) (disch_tac [])) THEN (clear_assumption "c2") THEN case THEN (simp_tac) THEN (move ["lt12"]))) ((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac))); |
| 2001 |
((repeat_tactic 1 9 (((use_arg_then2 ("ltE", [ltE]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("leq_trans", [leq_trans])) (disch_tac [])) THEN (clear_assumption "leq_trans") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then2 ("leqSS", [leqSS]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltnW", [ltnW])) (disch_tac [])) THEN (clear_assumption "ltnW") THEN (exact_tac)) THEN (done_tac)); |
| 2002 |
];; |
| 2003 |
|
| 2004 |
(* Lemma monotone_leqif *) |
| 2005 |
let monotone_leqif = Sections.section_proof ["f"] |
| 2006 |
`(!m n. f m <= f n <=> m <= n) ==> |
| 2007 |
!m n c. (leqif (f m) (f n) c) <=> (leqif m n c)` |
| 2008 |
[ |
| 2009 |
(BETA_TAC THEN (move ["f_mono"]) THEN (move ["m"]) THEN (move ["n"]) THEN (move ["c"])); |
| 2010 |
(((repeat_tactic 1 9 (((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("f_mono", []))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 2011 |
];; |
| 2012 |
|
| 2013 |
(* Lemma leqif_geq *) |
| 2014 |
let leqif_geq = Sections.section_proof ["m";"n"] |
| 2015 |
`m <= n ==> leqif m n (n <= m)` |
| 2016 |
[ |
| 2017 |
((BETA_TAC THEN (move ["lemn"])) THEN (((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] [])))) THEN ((split_tac) THEN ((TRY done_tac))) THEN (((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] []))))); |
| 2018 |
((((use_arg_then2 ("lemn", []))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 2019 |
];; |
| 2020 |
|
| 2021 |
(* Lemma leqif_eq *) |
| 2022 |
let leqif_eq = Sections.section_proof ["m";"n"] |
| 2023 |
`m <= n ==> leqif m n (m = n)` |
| 2024 |
[ |
| 2025 |
((((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 2026 |
];; |
| 2027 |
|
| 2028 |
(* Lemma geq_leqif *) |
| 2029 |
let geq_leqif = Sections.section_proof ["a";"b";"C"] |
| 2030 |
`leqif a b C ==> ((b <= a) <=> C)` |
| 2031 |
[ |
| 2032 |
((((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] [])))) THEN (case THEN (move ["le_ab"])) THEN (((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] []))))); |
| 2033 |
((((use_arg_then2 ("le_ab", []))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); |
| 2034 |
];; |
| 2035 |
|
| 2036 |
(* Lemma ltn_leqif *) |
| 2037 |
let ltn_leqif = Sections.section_proof ["a";"b";"C"] |
| 2038 |
`leqif a b C ==> (a < b <=> ~ C)` |
| 2039 |
[ |
| 2040 |
(BETA_TAC THEN (move ["le_ab"])); |
| 2041 |
(((((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then2 ("geq_leqif", [geq_leqif])) (fun fst_arg -> (use_arg_then2 ("le_ab", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2042 |
];; |
| 2043 |
|
| 2044 |
(* Lemma leqif_add *) |
| 2045 |
let leqif_add = Sections.section_proof ["m1";"n1";"c1";"m2";"n2";"c2"] |
| 2046 |
`leqif m1 n1 c1 ==> leqif m2 n2 c2 ==> leqif (m1 + m2) (n1 + n2) (c1 /\ c2)` |
| 2047 |
[ |
| 2048 |
((((fun arg_tac -> (use_arg_then2 ("monotone_leqif", [monotone_leqif])) (fun fst_arg -> (fun arg_tac -> (use_arg_then2 ("leq_add2r", [leq_add2r])) (fun fst_arg -> (use_arg_then2 ("m2", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (move ["le1"])); |
| 2049 |
(((fun arg_tac -> (use_arg_then2 ("monotone_leqif", [monotone_leqif])) (fun fst_arg -> (fun arg_tac -> (use_arg_then2 ("leq_add2l", [leq_add2l])) (fun fst_arg -> (use_arg_then2 ("n1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))); |
| 2050 |
(((use_arg_then2 ("leqif_trans", [leqif_trans])) (disch_tac [])) THEN (clear_assumption "leqif_trans") THEN (exact_tac)); |
| 2051 |
];; |
| 2052 |
|
| 2053 |
(* Lemma leqif_mul *) |
| 2054 |
let leqif_mul = Sections.section_proof ["m1";"n1";"c1";"m2";"n2";"c2"] |
| 2055 |
`leqif m1 n1 c1 ==> leqif m2 n2 c2 ==> |
| 2056 |
leqif (m1 * m2) (n1 * n2) (n1 * n2 = 0 \/ (c1 /\ c2))` |
| 2057 |
[ |
| 2058 |
(BETA_TAC THEN (move ["le1"]) THEN (move ["le2"])); |
| 2059 |
((THENL) (((fun arg_tac -> (use_arg_then2 ("posnP", [posnP])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`n1 * n2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case) [(move ["n12_0"]); ALL_TAC]); |
| 2060 |
((((use_arg_then2 ("n12_0", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("le2", [])) (disch_tac [])) THEN (clear_assumption "le2") THEN ((use_arg_then2 ("le1", [])) (disch_tac [])) THEN (clear_assumption "le1") THEN ((use_arg_then2 ("n12_0", [])) (disch_tac [])) THEN (clear_assumption "n12_0") THEN BETA_TAC) THEN (((use_arg_then2 ("muln_eq0", [muln_eq0]))(thm_tac (new_rewrite [] []))))); |
| 2061 |
((case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((THENL) (((use_arg_then2 ("m2", [])) (disch_tac [])) THEN (clear_assumption "m2") THEN ((use_arg_then2 ("m1", [])) (disch_tac [])) THEN (clear_assumption "m1") THEN case) [ALL_TAC; (move ["m"])]) THEN ((THENL) case [ALL_TAC; (move ["m'"])]) THEN ((repeat_tactic 1 9 (((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("muln0", [muln0]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("mul0n", [mul0n]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("leqnn", [leqnn]))(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (arith_tac)); |
| 2062 |
((((use_arg_then2 ("muln_gt0", [muln_gt0]))(thm_tac (new_rewrite [] [])))) THEN (BETA_TAC THEN (case THEN ((move ["n1_gt0"]) THEN (move ["n2_gt0"]))))); |
| 2063 |
(((fun arg_tac -> (use_arg_then2 ("posnP", [posnP])) (fun fst_arg -> (use_arg_then2 ("m2", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN ((THENL) case [(move ["m2_0"]); (move ["m2_gt0"])])); |
| 2064 |
((((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("le2", [])) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then2 ("leqif", [leqif]))(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN ((move ["_"]) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] []))))))))); |
| 2065 |
(((((use_arg_then2 ("andbC", [andbC]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("m2_0", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("muln0", [muln0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("muln_gt0", [muln_gt0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("n1_gt0", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("n2_gt0", []))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2066 |
((((use_arg_then2 ("n1_gt0", [])) (disch_tac [])) THEN (DISCH_THEN (fun snd_th -> (use_arg_then2 ("leq_pmul2l", [leq_pmul2l])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN ((DISCH_THEN (fun snd_th -> (use_arg_then2 ("monotone_leqif", [monotone_leqif])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (move ["Mn1"]))); |
| 2067 |
(((use_arg_then2 ("le2", [])) (disch_tac [])) THEN (clear_assumption "le2") THEN ((use_arg_then2 ("Mn1", [])) (disch_tac [])) THEN (clear_assumption "Mn1") THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))); |
| 2068 |
((((use_arg_then2 ("m2_gt0", [])) (disch_tac [])) THEN (clear_assumption "m2_gt0") THEN (DISCH_THEN (fun snd_th -> (use_arg_then2 ("leq_pmul2r", [leq_pmul2r])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN ((DISCH_THEN (fun snd_th -> (use_arg_then2 ("monotone_leqif", [monotone_leqif])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (move ["Mm2"]))); |
| 2069 |
(((use_arg_then2 ("le1", [])) (disch_tac [])) THEN (clear_assumption "le1") THEN ((use_arg_then2 ("Mm2", [])) (disch_tac [])) THEN (clear_assumption "Mm2") THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))); |
| 2070 |
(BETA_TAC THEN (move ["leq1"]) THEN (move ["leq2"])); |
| 2071 |
((((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leqif_trans", [leqif_trans])) (fun fst_arg -> (use_arg_then2 ("leq1", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("leq2", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] [])))))); |
| 2072 |
(((fun arg_tac -> arg_tac (Arg_term (`c1 /\ c2`))) (disch_tac [])) THEN case THEN (simp_tac)); |
| 2073 |
(((((use_arg_then2 ("eqn_leq", [eqn_leq]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("muln_gt0", [muln_gt0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("n1_gt0", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("n2_gt0", []))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2074 |
];; |
| 2075 |
|
| 2076 |
(* Lemma nat_Cauchy *) |
| 2077 |
let nat_Cauchy = Sections.section_proof ["m";"n"] |
| 2078 |
`leqif (2 * (m * n)) (m ^ 2 + n ^ 2) (m = n)` |
| 2079 |
[ |
| 2080 |
((fun arg_tac -> arg_tac (Arg_term (`n <= m`))) (term_tac (wlog_tac (move ["le_nm"])[`m`; `n`]))); |
| 2081 |
((((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leqP", [leqP])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN ((TRY done_tac))) THEN (((((use_arg_then2 ("eq_sym", [eq_sym]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulnC", [mulnC]))(thm_tac (new_rewrite [] [(`m * _1`)]))))) THEN (move ["mn"]))); |
| 2082 |
((((use_arg_then2 ("le_nm", [])) (disch_tac [])) THEN (clear_assumption "le_nm") THEN (DISCH_THEN apply_tac)) THEN (((fun arg_tac -> (use_arg_then2 ("ltnW", [ltnW])) (fun fst_arg -> (use_arg_then2 ("mn", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (done_tac)); |
| 2083 |
(BETA_TAC THEN (move ["le_nm"])); |
| 2084 |
(((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] [])))); |
| 2085 |
((THENL_FIRST) ((THENL) (((fun arg_tac -> (use_arg_then2 ("EXCLUDED_MIDDLE", [EXCLUDED_MIDDLE])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m = n`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case) [(((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))); (move ["ne_mn"])]) (((((use_arg_then2 ("mulnn", [mulnn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnn", [addnn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mul2n", [mul2n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac))); |
| 2086 |
(((((use_arg_then2 ("ne_mn", []))(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (simp_tac)) THEN ((((use_arg_then2 ("subn_gt0", [subn_gt0]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("sqrn_sub", [sqrn_sub]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("sqrn_gt0", [sqrn_gt0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subn_gt0", [subn_gt0]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltn_neqAle", [ltn_neqAle]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("eq_sym", [eq_sym]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2087 |
];; |
| 2088 |
|
| 2089 |
(* Lemma nat_AGM2 *) |
| 2090 |
let nat_AGM2 = Sections.section_proof ["m";"n"] |
| 2091 |
`leqif (4 * (m * n)) ((m + n) ^ 2) (m = n)` |
| 2092 |
[ |
| 2093 |
((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `4 = 2 * 2`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("mulnA", [mulnA]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("mul2n", [mul2n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addnn", [addnn]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("sqrn_add", [sqrn_add]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] []))))); |
| 2094 |
((((use_arg_then2 ("ltn_add2r", [ltn_add2r]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("eqn_addr", [eqn_addr]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltn_neqAle", [ltn_neqAle]))(thm_tac (new_rewrite [] []))))); |
| 2095 |
(((((fun arg_tac -> (use_arg_then2 ("leqif_imp_eq", [leqif_imp_eq])) (fun fst_arg -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("nat_Cauchy", [nat_Cauchy])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then2 ("leqif_imp_le", [leqif_imp_le])) (fun fst_arg -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("nat_Cauchy", [nat_Cauchy])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then2 ("if_same", [if_same]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2096 |
];; |
| 2097 |
let distn = new_definition `!m n. distn m n = (m - n) + (n - m)`;; |
| 2098 |
|
| 2099 |
(* Lemma distnC *) |
| 2100 |
let distnC = Sections.section_proof ["m";"n"] |
| 2101 |
`distn m n = distn n m` |
| 2102 |
[ |
| 2103 |
(((repeat_tactic 1 9 (((use_arg_then2 ("distn", [distn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2104 |
];; |
| 2105 |
|
| 2106 |
(* Lemma distn_add2l *) |
| 2107 |
let distn_add2l = Sections.section_proof ["d";"m";"n"] |
| 2108 |
`distn (d + m) (d + n) = distn m n` |
| 2109 |
[ |
| 2110 |
(((repeat_tactic 1 9 (((use_arg_then2 ("distn", [distn]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("subn_add2l", [subn_add2l]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 2111 |
];; |
| 2112 |
|
| 2113 |
(* Lemma distn_add2r *) |
| 2114 |
let distn_add2r = Sections.section_proof ["d";"m";"n"] |
| 2115 |
`distn (m + d) (n + d) = distn m n` |
| 2116 |
[ |
| 2117 |
(((repeat_tactic 1 9 (((use_arg_then2 ("distn", [distn]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("subn_add2r", [subn_add2r]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 2118 |
];; |
| 2119 |
|
| 2120 |
(* Lemma distnEr *) |
| 2121 |
let distnEr = Sections.section_proof ["m";"n"] |
| 2122 |
`m <= n ==> distn m n = n - m` |
| 2123 |
[ |
| 2124 |
(BETA_TAC THEN (move ["le_m_n"])); |
| 2125 |
(((((use_arg_then2 ("distn", [distn]))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("EQ_IMP", [EQ_IMP])) (fun fst_arg -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leqE", [leqE])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("le_m_n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2126 |
];; |
| 2127 |
|
| 2128 |
(* Lemma distnEl *) |
| 2129 |
let distnEl = Sections.section_proof ["m";"n"] |
| 2130 |
`n <= m ==> distn m n = m - n` |
| 2131 |
[ |
| 2132 |
((BETA_TAC THEN (move ["le_n_m"])) THEN ((((use_arg_then2 ("distnC", [distnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("distnEr", [distnEr]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2133 |
];; |
| 2134 |
|
| 2135 |
(* Lemma dist0n *) |
| 2136 |
let dist0n = Sections.section_proof ["n"] |
| 2137 |
`distn 0 n = n` |
| 2138 |
[ |
| 2139 |
(((THENL) (((use_arg_then2 ("n", [])) (disch_tac [])) THEN (clear_assumption "n") THEN case) [ALL_TAC; (move ["m"])]) THEN ((((use_arg_then2 ("distn", [distn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("sub0n", [sub0n]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("subn0", [subn0]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2140 |
];; |
| 2141 |
|
| 2142 |
(* Lemma distn0 *) |
| 2143 |
let distn0 = Sections.section_proof ["n"] |
| 2144 |
`distn n 0 = n` |
| 2145 |
[ |
| 2146 |
(((((use_arg_then2 ("distnC", [distnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("dist0n", [dist0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2147 |
];; |
| 2148 |
|
| 2149 |
(* Lemma distnn *) |
| 2150 |
let distnn = Sections.section_proof ["m"] |
| 2151 |
`distn m m = 0` |
| 2152 |
[ |
| 2153 |
(((repeat_tactic 1 9 (((use_arg_then2 ("distn", [distn]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("subnn", [subnn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addn0", [addn0]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2154 |
];; |
| 2155 |
|
| 2156 |
(* Lemma distn_eq0 *) |
| 2157 |
let distn_eq0 = Sections.section_proof ["m";"n"] |
| 2158 |
`(distn m n = 0) <=> (m = n)` |
| 2159 |
[ |
| 2160 |
(((((use_arg_then2 ("distn", [distn]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("addn_eq0", [addn_eq0]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("subn_eq0", [subn_eq0]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("eqn_leq", [eqn_leq]))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 2161 |
];; |
| 2162 |
|
| 2163 |
(* Lemma distnS *) |
| 2164 |
let distnS = Sections.section_proof ["m"] |
| 2165 |
`distn m (SUC m) = 1` |
| 2166 |
[ |
| 2167 |
((((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("distn_add2r", [distn_add2r])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then2 ("add0n", [add0n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("dist0n", [dist0n]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2168 |
];; |
| 2169 |
|
| 2170 |
(* Lemma distSn *) |
| 2171 |
let distSn = Sections.section_proof ["m"] |
| 2172 |
`distn (SUC m) m = 1` |
| 2173 |
[ |
| 2174 |
(((((use_arg_then2 ("distnC", [distnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("distnS", [distnS]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2175 |
];; |
| 2176 |
|
| 2177 |
(* Lemma distn_eq1 *) |
| 2178 |
let distn_eq1 = Sections.section_proof ["m";"n"] |
| 2179 |
`(distn m n = 1) <=> (if m < n then SUC m = n else m = SUC n)` |
| 2180 |
[ |
| 2181 |
((THENL) (((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("ltnP", [ltnP])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case) [(move ["lt_mn"]); (move ["le_mn"])]); |
| 2182 |
(((((use_arg_then2 ("eq_sym", [eq_sym]))(thm_tac (new_rewrite [] [(`_ = 1`)])))) THEN (((fun arg_tac -> (use_arg_then2 ("eqn_addr", [eqn_addr])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("distnEr", [distnEr]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("subnK", [subnK]))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("ltnW", [ltnW]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2183 |
(((((fun arg_tac -> (use_arg_then2 ("eqn_addr", [eqn_addr])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("distnEl", [distnEl]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("subnK", [subnK]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("add1n", [add1n]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("ltnNge", [ltnNge]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("le_mn", []))(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac)); |
| 2184 |
];; |
| 2185 |
|
| 2186 |
(* Lemma leqif_add_distn *) |
| 2187 |
let leqif_add_distn = Sections.section_proof ["m";"n";"p"] |
| 2188 |
`leqif (distn m p) (distn m n + distn n p) ((m <= n /\ n <= p) \/ (p <= n /\ n <= m))` |
| 2189 |
[ |
| 2190 |
(((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`!m p. m <= p ==> leqif (distn m p) (distn m n + distn n p) (m <= n /\ n <= p \/ p <= n /\ n <= m)`))) (term_tac (have_gen_tac [](move ["IH"]))))); |
| 2191 |
((((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leq_total", [leq_total])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("p", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN ((TRY done_tac))) THEN ((DISCH_THEN (fun snd_th -> (use_arg_then2 ("IH", [])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC)); |
| 2192 |
(((((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("orbC", [orbC]))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then2 ("distnC", [distnC])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [(`distn n _`)])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("distnC", [distnC]))(thm_tac (new_rewrite [] [(`distn p _`)])))))) THEN (done_tac)); |
| 2193 |
(BETA_TAC THEN (move ["m"]) THEN (move ["p"]) THEN (move ["le_mp"])); |
| 2194 |
((((use_arg_then2 ("distnEr", [distnEr]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); |
| 2195 |
((THENL) (((fun arg_tac -> (use_arg_then2 ("EXCLUDED_MIDDLE", [EXCLUDED_MIDDLE])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`m <= n /\ n <= p`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case) [((case THEN ((move ["le_mn"]) THEN (move ["le_np"]))) THEN ((simp_tac THEN TRY done_tac))); ALL_TAC]); |
| 2196 |
(((repeat_tactic 1 9 (((use_arg_then2 ("distnEr", [distnEr]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("addnC", [addnC]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((fun arg_tac -> (use_arg_then2 ("eqn_addr", [eqn_addr])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("addnA", [addnA]))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("subnK", [subnK]))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); |
| 2197 |
(((((use_arg_then2 ("negb_and", [negb_and]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("ltnNge", [ltnNge]))(gsym_then (thm_tac (new_rewrite [] []))))))) THEN ALL_TAC THEN ((THENL) case [(move ["lt_nm"]); (move ["lt_pn"])])); |
| 2198 |
(((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("ltn_leq_trans", [ltn_leq_trans])) (fun fst_arg -> (use_arg_then2 ("lt_nm", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("le_mp", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (move ["lt_np"])); |
| 2199 |
(((((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("lt_nm", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("lt_np", []))(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then2 ("ltn_addl", [ltn_addl]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("distnEr", [distnEr]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("ltnW", [ltnW]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("ltn_sub2l", [ltn_sub2l]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2200 |
(((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leq_ltn_trans", [leq_ltn_trans])) (fun fst_arg -> (use_arg_then2 ("le_mp", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("lt_pn", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (move ["lt_mn"])); |
| 2201 |
(((((use_arg_then2 ("leqifP", [leqifP]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then2 ("leqNgt", [leqNgt]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("lt_mn", []))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("lt_pn", []))(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then2 ("ltn_addr", [ltn_addr]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("distnEr", [distnEr]))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then2 ("ltn_sub2r", [ltn_sub2r]))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("ltnW", [ltnW]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2202 |
];; |
| 2203 |
|
| 2204 |
(* Lemma leq_add_distn *) |
| 2205 |
let leq_add_distn = Sections.section_proof ["m";"n";"p"] |
| 2206 |
`distn m p <= distn m n + distn n p` |
| 2207 |
[ |
| 2208 |
((((fun arg_tac -> (use_arg_then2 ("leqif_imp_le", [leqif_imp_le])) (fun fst_arg -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leqif_add_distn", [leqif_add_distn])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("p", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (done_tac)); |
| 2209 |
];; |
| 2210 |
|
| 2211 |
(* Lemma sqrn_distn *) |
| 2212 |
let sqrn_distn = Sections.section_proof ["m";"n"] |
| 2213 |
`(distn m n) ^ 2 + 2 * (m * n) = m ^ 2 + n ^ 2` |
| 2214 |
[ |
| 2215 |
((fun arg_tac -> arg_tac (Arg_term (`n <= m`))) (term_tac (wlog_tac (move ["le_nm"])[`m`; `n`]))); |
| 2216 |
(((fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("leq_total", [leq_total])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (DISCH_THEN (fun snd_th -> (use_arg_then2 ("le_nm", [])) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN ((TRY done_tac))); |
| 2217 |
(((((fun arg_tac -> (use_arg_then2 ("addnC", [addnC])) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`n EXP 2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then2 ("mulnC", [mulnC])) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("distnC", [distnC]))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2218 |
((BETA_TAC THEN (move ["le_nm"])) THEN ((((use_arg_then2 ("distnEl", [distnEl]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("sqrn_sub", [sqrn_sub]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then2 ("subnK", [subnK]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then2 ("leqif_imp_le", [leqif_imp_le])) (fun fst_arg -> (fun arg_tac -> (fun arg_tac -> (use_arg_then2 ("nat_Cauchy", [nat_Cauchy])) (fun fst_arg -> (use_arg_then2 ("m", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then2 ("n", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); |
| 2219 |
];; |
| 2220 |
|
| 2221 |
(* Close the module *) |
| 2222 |
end;; |