| author | Fabian Huch <huch@in.tum.de> | 
| Mon, 10 Jun 2024 14:08:15 +0200 | |
| changeset 80335 | b835b40f53ec | 
| parent 69597 | ff784d5a5bfb | 
| child 82965 | 8142462f0883 | 
| permissions | -rw-r--r-- | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 1 | (* Title: HOL/ex/Simproc_Tests.thy | 
| 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 2 | Author: Brian Huffman | 
| 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 3 | *) | 
| 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 4 | |
| 61343 | 5 | section \<open>Testing of arithmetic simprocs\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 6 | |
| 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 7 | theory Simproc_Tests | 
| 48372 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 8 | imports Main | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 9 | begin | 
| 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 10 | |
| 61343 | 11 | text \<open> | 
| 63680 | 12 | This theory tests the various simprocs defined in \<^file>\<open>~~/src/HOL/Nat.thy\<close> and | 
| 13 | \<^file>\<open>~~/src/HOL/Numeral_Simprocs.thy\<close>. Many of the tests are derived from commented-out code | |
| 14 | originally found in \<^file>\<open>~~/src/HOL/Tools/numeral_simprocs.ML\<close>. | |
| 61343 | 15 | \<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 16 | |
| 61343 | 17 | subsection \<open>ML bindings\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 18 | |
| 61343 | 19 | ML \<open> | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
48559diff
changeset | 20 | fun test ctxt ps = | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
48559diff
changeset | 21 | CHANGED (asm_simp_tac (put_simpset HOL_basic_ss ctxt addsimprocs ps) 1) | 
| 61343 | 22 | \<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 23 | |
| 61933 | 24 | subsection \<open>Cancellation simprocs from \<open>Nat.thy\<close>\<close> | 
| 48372 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 25 | |
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 26 | notepad begin | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 27 | fix a b c d :: nat | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 28 |   {
 | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 29 | assume "b = Suc c" have "a + b = Suc (c + a)" | 
| 69597 | 30 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_sums\<close>]\<close>) fact | 
| 48372 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 31 | next | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 32 | assume "b < Suc c" have "a + b < Suc (c + a)" | 
| 69597 | 33 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natless_cancel_sums\<close>]\<close>) fact | 
| 48372 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 34 | next | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 35 | assume "b \<le> Suc c" have "a + b \<le> Suc (c + a)" | 
| 69597 | 36 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natle_cancel_sums\<close>]\<close>) fact | 
| 48372 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 37 | next | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 38 | assume "b - Suc c = d" have "a + b - Suc (c + a) = d" | 
| 69597 | 39 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_sums\<close>]\<close>) fact | 
| 48372 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 40 | } | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 41 | end | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 42 | |
| 61337 | 43 | schematic_goal "\<And>(y::?'b::size). size (?x::?'a::size) \<le> size y + size ?x" | 
| 69597 | 44 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natle_cancel_sums\<close>]\<close>) (rule le0) | 
| 48372 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 45 | (* TODO: test more simprocs with schematic variables *) | 
| 
868dc809c8a2
make nat_cancel_sums simprocs robust in the presence of schematic variables; add regression tests
 huffman parents: 
47108diff
changeset | 46 | |
| 61343 | 47 | subsection \<open>Abelian group cancellation simprocs\<close> | 
| 45464 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 48 | |
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 49 | notepad begin | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 50 | fix a b c u :: "'a::ab_group_add" | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 51 |   {
 | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 52 | assume "(a + 0) - (b + 0) = u" have "(a + c) - (b + c) = u" | 
| 69597 | 53 | by (tactic \<open>test \<^context> [\<^simproc>\<open>group_cancel_diff\<close>]\<close>) fact | 
| 45464 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 54 | next | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 55 | assume "a + 0 = b + 0" have "a + c = b + c" | 
| 69597 | 56 | by (tactic \<open>test \<^context> [\<^simproc>\<open>group_cancel_eq\<close>]\<close>) fact | 
| 45464 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 57 | } | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 58 | end | 
| 48556 
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
 huffman parents: 
48372diff
changeset | 59 | (* TODO: more tests for Groups.group_cancel_{add,diff,eq,less,le} *)
 | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 60 | |
| 61933 | 61 | subsection \<open>\<open>int_combine_numerals\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 62 | |
| 45464 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 63 | (* FIXME: int_combine_numerals often unnecessarily regroups addition | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 64 | and rewrites subtraction to negation. Ideally it should behave more | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 65 | like Groups.abel_cancel_sum, preserving the shape of terms as much as | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 66 | possible. *) | 
| 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 67 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 68 | notepad begin | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 69 | fix a b c d oo uu i j k l u v w x y z :: "'a::comm_ring_1" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 70 |   {
 | 
| 45464 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 71 | assume "a + - b = u" have "(a + c) - (b + c) = u" | 
| 69597 | 72 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45464 
5a5a6e6c6789
abel_cancel.ML: avoid canceling zeros, which would cause the simproc to return a trivial rewrite;
 huffman parents: 
45463diff
changeset | 73 | next | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 74 | assume "10 + (2 * l + oo) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 75 | have "l + 2 + 2 + 2 + (l + 2) + (oo + 2) = uu" | 
| 69597 | 76 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 77 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 78 | assume "-3 + (i + (j + k)) = y" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 79 | have "(i + j + 12 + k) - 15 = y" | 
| 69597 | 80 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 81 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 82 | assume "7 + (i + (j + k)) = y" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 83 | have "(i + j + 12 + k) - 5 = y" | 
| 69597 | 84 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 85 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 86 | assume "-4 * (u * v) + (2 * x + y) = w" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 87 | have "(2*x - (u*v) + y) - v*3*u = w" | 
| 69597 | 88 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 89 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 90 | assume "2 * x * u * v + y = w" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 91 | have "(2*x*u*v + (u*v)*4 + y) - v*u*4 = w" | 
| 69597 | 92 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 93 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 94 | assume "3 * (u * v) + (2 * x * u * v + y) = w" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 95 | have "(2*x*u*v + (u*v)*4 + y) - v*u = w" | 
| 69597 | 96 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 97 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 98 | assume "-3 * (u * v) + (- (x * u * v) + - y) = w" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 99 | have "u*v - (x*u*v + (u*v)*4 + y) = w" | 
| 69597 | 100 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 101 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 102 | assume "a + - c = d" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 103 | have "a + -(b+c) + b = d" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 104 | apply (simp only: minus_add_distrib) | 
| 69597 | 105 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 106 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 107 | assume "-2 * b + (a + - c) = d" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 108 | have "a + -(b+c) - b = d" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 109 | apply (simp only: minus_add_distrib) | 
| 69597 | 110 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 111 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 112 | assume "-7 + (i + (j + (k + (- u + - y)))) = z" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 113 | have "(i + j + -2 + k) - (u + 5 + y) = z" | 
| 69597 | 114 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 115 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 116 | assume "-27 + (i + (j + k)) = y" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 117 | have "(i + j + -12 + k) - 15 = y" | 
| 69597 | 118 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 119 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 120 | assume "27 + (i + (j + k)) = y" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 121 | have "(i + j + 12 + k) - -15 = y" | 
| 69597 | 122 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 123 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 124 | assume "3 + (i + (j + k)) = y" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 125 | have "(i + j + -12 + k) - -15 = y" | 
| 69597 | 126 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 127 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 128 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 129 | |
| 61933 | 130 | subsection \<open>\<open>inteq_cancel_numerals\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 131 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 132 | notepad begin | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 133 | fix i j k u vv w y z w' y' z' :: "'a::comm_ring_1" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 134 |   {
 | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 135 | assume "u = 0" have "2*u = u" | 
| 69597 | 136 | by (tactic \<open>test \<^context> [\<^simproc>\<open>inteq_cancel_numerals\<close>]\<close>) fact | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 137 | (* conclusion matches Rings.ring_1_no_zero_divisors_class.mult_cancel_right2 *) | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 138 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 139 | assume "i + (j + k) = 3 + (u + y)" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 140 | have "(i + j + 12 + k) = u + 15 + y" | 
| 69597 | 141 | by (tactic \<open>test \<^context> [\<^simproc>\<open>inteq_cancel_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 142 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 143 | assume "7 + (j + (i + k)) = y" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 144 | have "(i + j*2 + 12 + k) = j + 5 + y" | 
| 69597 | 145 | by (tactic \<open>test \<^context> [\<^simproc>\<open>inteq_cancel_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 146 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 147 | assume "u + (6*z + (4*y + 6*w)) = 6*z' + (4*y' + (6*w' + vv))" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 148 | have "2*y + 3*z + 6*w + 2*y + 3*z + 2*u = 2*y' + 3*z' + 6*w' + 2*y' + 3*z' + u + vv" | 
| 69597 | 149 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_combine_numerals\<close>, \<^simproc>\<open>inteq_cancel_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 150 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 151 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 152 | |
| 61933 | 153 | subsection \<open>\<open>intless_cancel_numerals\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 154 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 155 | notepad begin | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 156 | fix b c i j k u y :: "'a::linordered_idom" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 157 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 158 | assume "y < 2 * b" have "y - b < b" | 
| 69597 | 159 | by (tactic \<open>test \<^context> [\<^simproc>\<open>intless_cancel_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 160 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 161 | assume "c + y < 4 * b" have "y - (3*b + c) < b - 2*c" | 
| 69597 | 162 | by (tactic \<open>test \<^context> [\<^simproc>\<open>intless_cancel_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 163 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 164 | assume "i + (j + k) < 8 + (u + y)" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 165 | have "(i + j + -3 + k) < u + 5 + y" | 
| 69597 | 166 | by (tactic \<open>test \<^context> [\<^simproc>\<open>intless_cancel_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 167 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 168 | assume "9 + (i + (j + k)) < u + y" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 169 | have "(i + j + 3 + k) < u + -6 + y" | 
| 69597 | 170 | by (tactic \<open>test \<^context> [\<^simproc>\<open>intless_cancel_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 171 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 172 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 173 | |
| 61933 | 174 | subsection \<open>\<open>ring_eq_cancel_numeral_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 175 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 176 | notepad begin | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 177 |   fix x y :: "'a::{idom,ring_char_0}"
 | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 178 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 179 | assume "3*x = 4*y" have "9*x = 12 * y" | 
| 69597 | 180 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 181 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 182 | assume "-3*x = 4*y" have "-99*x = 132 * y" | 
| 69597 | 183 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 184 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 185 | assume "111*x = -44*y" have "999*x = -396 * y" | 
| 69597 | 186 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 187 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 188 | assume "11*x = 9*y" have "-99*x = -81 * y" | 
| 69597 | 189 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 190 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 191 | assume "2*x = y" have "-2 * x = -1 * y" | 
| 69597 | 192 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 193 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 194 | assume "2*x = y" have "-2 * x = -y" | 
| 69597 | 195 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 196 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 197 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 198 | |
| 61933 | 199 | subsection \<open>\<open>int_div_cancel_numeral_factors\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 200 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 201 | notepad begin | 
| 66806 
a4e82b58d833
abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
 haftmann parents: 
64240diff
changeset | 202 |   fix x y z :: "'a::{unique_euclidean_semiring,comm_ring_1,ring_char_0}"
 | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 203 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 204 | assume "(3*x) div (4*y) = z" have "(9*x) div (12*y) = z" | 
| 69597 | 205 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_numeral_factors\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 206 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 207 | assume "(-3*x) div (4*y) = z" have "(-99*x) div (132*y) = z" | 
| 69597 | 208 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_numeral_factors\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 209 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 210 | assume "(111*x) div (-44*y) = z" have "(999*x) div (-396*y) = z" | 
| 69597 | 211 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_numeral_factors\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 212 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 213 | assume "(11*x) div (9*y) = z" have "(-99*x) div (-81*y) = z" | 
| 69597 | 214 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_numeral_factors\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 215 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 216 | assume "(2*x) div y = z" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 217 | have "(-2 * x) div (-1 * y) = z" | 
| 69597 | 218 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_numeral_factors\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 219 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 220 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 221 | |
| 61933 | 222 | subsection \<open>\<open>ring_less_cancel_numeral_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 223 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 224 | notepad begin | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 225 | fix x y :: "'a::linordered_idom" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 226 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 227 | assume "3*x < 4*y" have "9*x < 12 * y" | 
| 69597 | 228 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_less_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 229 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 230 | assume "-3*x < 4*y" have "-99*x < 132 * y" | 
| 69597 | 231 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_less_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 232 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 233 | assume "111*x < -44*y" have "999*x < -396 * y" | 
| 69597 | 234 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_less_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 235 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 236 | assume "9*y < 11*x" have "-99*x < -81 * y" | 
| 69597 | 237 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_less_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 238 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 239 | assume "y < 2*x" have "-2 * x < -y" | 
| 69597 | 240 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_less_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 241 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 242 | assume "23*y < x" have "-x < -23 * y" | 
| 69597 | 243 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_less_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 244 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 245 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 246 | |
| 61933 | 247 | subsection \<open>\<open>ring_le_cancel_numeral_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 248 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 249 | notepad begin | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 250 | fix x y :: "'a::linordered_idom" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 251 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 252 | assume "3*x \<le> 4*y" have "9*x \<le> 12 * y" | 
| 69597 | 253 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 254 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 255 | assume "-3*x \<le> 4*y" have "-99*x \<le> 132 * y" | 
| 69597 | 256 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 257 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 258 | assume "111*x \<le> -44*y" have "999*x \<le> -396 * y" | 
| 69597 | 259 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 260 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 261 | assume "9*y \<le> 11*x" have "-99*x \<le> -81 * y" | 
| 69597 | 262 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 263 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 264 | assume "y \<le> 2*x" have "-2 * x \<le> -1 * y" | 
| 69597 | 265 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 266 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 267 | assume "23*y \<le> x" have "-x \<le> -23 * y" | 
| 69597 | 268 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 269 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 270 | assume "y \<le> 0" have "0 \<le> y * -2" | 
| 69597 | 271 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 272 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 273 | assume "- x \<le> y" have "- (2 * x) \<le> 2*y" | 
| 69597 | 274 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 275 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 276 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 277 | |
| 61933 | 278 | subsection \<open>\<open>divide_cancel_numeral_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 279 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 280 | notepad begin | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
58889diff
changeset | 281 |   fix x y z :: "'a::{field,ring_char_0}"
 | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 282 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 283 | assume "(3*x) / (4*y) = z" have "(9*x) / (12 * y) = z" | 
| 69597 | 284 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 285 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 286 | assume "(-3*x) / (4*y) = z" have "(-99*x) / (132 * y) = z" | 
| 69597 | 287 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 288 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 289 | assume "(111*x) / (-44*y) = z" have "(999*x) / (-396 * y) = z" | 
| 69597 | 290 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 291 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 292 | assume "(11*x) / (9*y) = z" have "(-99*x) / (-81 * y) = z" | 
| 69597 | 293 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 294 | next | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 295 | assume "(2*x) / y = z" have "(-2 * x) / (-1 * y) = z" | 
| 69597 | 296 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_numeral_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 297 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 298 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 299 | |
| 61933 | 300 | subsection \<open>\<open>ring_eq_cancel_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 301 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 302 | notepad begin | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 303 | fix a b c d k x y :: "'a::idom" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 304 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 305 | assume "k = 0 \<or> x = y" have "x*k = k*y" | 
| 69597 | 306 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 307 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 308 | assume "k = 0 \<or> 1 = y" have "k = k*y" | 
| 69597 | 309 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 310 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 311 | assume "b = 0 \<or> a*c = 1" have "a*(b*c) = b" | 
| 69597 | 312 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 313 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 314 | assume "a = 0 \<or> b = 0 \<or> c = d*x" have "a*(b*c) = d*b*(x*a)" | 
| 69597 | 315 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 316 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 317 | assume "k = 0 \<or> x = y" have "x*k = k*y" | 
| 69597 | 318 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 319 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 320 | assume "k = 0 \<or> 1 = y" have "k = k*y" | 
| 69597 | 321 | by (tactic \<open>test \<^context> [\<^simproc>\<open>ring_eq_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 322 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 323 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 324 | |
| 61933 | 325 | subsection \<open>\<open>int_div_cancel_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 326 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 327 | notepad begin | 
| 66806 
a4e82b58d833
abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
 haftmann parents: 
64240diff
changeset | 328 | fix a b c d k uu x y :: "'a::unique_euclidean_semiring" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 329 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 330 | assume "(if k = 0 then 0 else x div y) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 331 | have "(x*k) div (k*y) = uu" | 
| 69597 | 332 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 333 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 334 | assume "(if k = 0 then 0 else 1 div y) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 335 | have "(k) div (k*y) = uu" | 
| 69597 | 336 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 337 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 338 | assume "(if b = 0 then 0 else a * c) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 339 | have "(a*(b*c)) div b = uu" | 
| 69597 | 340 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 341 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 342 | assume "(if a = 0 then 0 else if b = 0 then 0 else c div (d * x)) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 343 | have "(a*(b*c)) div (d*b*(x*a)) = uu" | 
| 69597 | 344 | by (tactic \<open>test \<^context> [\<^simproc>\<open>int_div_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 345 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 346 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 347 | |
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
58889diff
changeset | 348 | lemma shows "a*(b*c)/(y*z) = d*(b::'a::linordered_field)*(x*a)/z" | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
66806diff
changeset | 349 | oops \<comment> \<open>FIXME: need simproc to cover this case\<close> | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 350 | |
| 61933 | 351 | subsection \<open>\<open>divide_cancel_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 352 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 353 | notepad begin | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
58889diff
changeset | 354 | fix a b c d k uu x y :: "'a::field" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 355 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 356 | assume "(if k = 0 then 0 else x / y) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 357 | have "(x*k) / (k*y) = uu" | 
| 69597 | 358 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 359 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 360 | assume "(if k = 0 then 0 else 1 / y) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 361 | have "(k) / (k*y) = uu" | 
| 69597 | 362 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 363 | next | 
| 64240 | 364 | assume "(if b = 0 then 0 else a * c) = uu" | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 365 | have "(a*(b*c)) / b = uu" | 
| 69597 | 366 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 367 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 368 | assume "(if a = 0 then 0 else if b = 0 then 0 else c / (d * x)) = uu" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 369 | have "(a*(b*c)) / (d*b*(x*a)) = uu" | 
| 69597 | 370 | by (tactic \<open>test \<^context> [\<^simproc>\<open>divide_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 371 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 372 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 373 | |
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 374 | lemma | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
58889diff
changeset | 375 | fixes a b c d x y z :: "'a::linordered_field" | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 376 | shows "a*(b*c)/(y*z) = d*(b)*(x*a)/z" | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
66806diff
changeset | 377 | oops \<comment> \<open>FIXME: need simproc to cover this case\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 378 | |
| 61933 | 379 | subsection \<open>\<open>linordered_ring_less_cancel_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 380 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 381 | notepad begin | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 382 | fix x y z :: "'a::linordered_idom" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 383 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 384 | assume "0 < z \<Longrightarrow> x < y" have "0 < z \<Longrightarrow> x*z < y*z" | 
| 69597 | 385 | by (tactic \<open>test \<^context> [\<^simproc>\<open>linordered_ring_less_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 386 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 387 | assume "0 < z \<Longrightarrow> x < y" have "0 < z \<Longrightarrow> x*z < z*y" | 
| 69597 | 388 | by (tactic \<open>test \<^context> [\<^simproc>\<open>linordered_ring_less_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 389 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 390 | assume "0 < z \<Longrightarrow> x < y" have "0 < z \<Longrightarrow> z*x < y*z" | 
| 69597 | 391 | by (tactic \<open>test \<^context> [\<^simproc>\<open>linordered_ring_less_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 392 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 393 | assume "0 < z \<Longrightarrow> x < y" have "0 < z \<Longrightarrow> z*x < z*y" | 
| 69597 | 394 | by (tactic \<open>test \<^context> [\<^simproc>\<open>linordered_ring_less_cancel_factor\<close>]\<close>) fact | 
| 46240 
933f35c4e126
factor-cancellation simprocs now call the full simplifier to prove that factors are non-zero
 huffman parents: 
45530diff
changeset | 395 | next | 
| 
933f35c4e126
factor-cancellation simprocs now call the full simplifier to prove that factors are non-zero
 huffman parents: 
45530diff
changeset | 396 | txt "This simproc now uses the simplifier to prove that terms to | 
| 
933f35c4e126
factor-cancellation simprocs now call the full simplifier to prove that factors are non-zero
 huffman parents: 
45530diff
changeset | 397 | be canceled are positive/negative." | 
| 
933f35c4e126
factor-cancellation simprocs now call the full simplifier to prove that factors are non-zero
 huffman parents: 
45530diff
changeset | 398 | assume z_pos: "0 < z" | 
| 
933f35c4e126
factor-cancellation simprocs now call the full simplifier to prove that factors are non-zero
 huffman parents: 
45530diff
changeset | 399 | assume "x < y" have "z*x < z*y" | 
| 69597 | 400 | by (tactic \<open>CHANGED (asm_simp_tac (put_simpset HOL_basic_ss \<^context> | 
| 401 | addsimprocs [\<^simproc>\<open>linordered_ring_less_cancel_factor\<close>] | |
| 61343 | 402 |         addsimps [@{thm z_pos}]) 1)\<close>) fact
 | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 403 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 404 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 405 | |
| 61933 | 406 | subsection \<open>\<open>linordered_ring_le_cancel_factor\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 407 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 408 | notepad begin | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 409 | fix x y z :: "'a::linordered_idom" | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 410 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 411 | assume "0 < z \<Longrightarrow> x \<le> y" have "0 < z \<Longrightarrow> x*z \<le> y*z" | 
| 69597 | 412 | by (tactic \<open>test \<^context> [\<^simproc>\<open>linordered_ring_le_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 413 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 414 | assume "0 < z \<Longrightarrow> x \<le> y" have "0 < z \<Longrightarrow> z*x \<le> z*y" | 
| 69597 | 415 | by (tactic \<open>test \<^context> [\<^simproc>\<open>linordered_ring_le_cancel_factor\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 416 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 417 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 418 | |
| 61933 | 419 | subsection \<open>\<open>field_combine_numerals\<close>\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 420 | |
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 421 | notepad begin | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
58889diff
changeset | 422 |   fix x y z uu :: "'a::{field,ring_char_0}"
 | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 423 |   {
 | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 424 | assume "5 / 6 * x = uu" have "x / 2 + x / 3 = uu" | 
| 69597 | 425 | by (tactic \<open>test \<^context> [\<^simproc>\<open>field_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 426 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 427 | assume "6 / 9 * x + y = uu" have "x / 3 + y + x / 3 = uu" | 
| 69597 | 428 | by (tactic \<open>test \<^context> [\<^simproc>\<open>field_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 429 | next | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 430 | assume "9 / 9 * x = uu" have "2 * x / 3 + x / 3 = uu" | 
| 69597 | 431 | by (tactic \<open>test \<^context> [\<^simproc>\<open>field_combine_numerals\<close>]\<close>) fact | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 432 | next | 
| 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 433 | assume "y + z = uu" | 
| 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 434 | have "x / 2 + y - 3 * x / 6 + z = uu" | 
| 69597 | 435 | by (tactic \<open>test \<^context> [\<^simproc>\<open>field_combine_numerals\<close>]\<close>) fact | 
| 45437 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 436 | next | 
| 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 437 | assume "1 / 15 * x + y = uu" | 
| 
958d19d3405b
tune post-processing of simproc-generated rules so they won't produce Numeral0 or Numeral1
 huffman parents: 
45436diff
changeset | 438 | have "7 * x / 5 + y - 4 * x / 3 = uu" | 
| 69597 | 439 | by (tactic \<open>test \<^context> [\<^simproc>\<open>field_combine_numerals\<close>]\<close>) fact | 
| 45435 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 440 | } | 
| 
d660c4b9daa6
add ring_char_0 class constraints to several simprocs (internal proofs of #n ~= 0 fail for type
 huffman parents: 
45285diff
changeset | 441 | end | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 442 | |
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 443 | lemma | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
58889diff
changeset | 444 |   fixes x :: "'a::{linordered_field}"
 | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 445 | shows "2/3 * x + x / 3 = uu" | 
| 69597 | 446 | apply (tactic \<open>test \<^context> [\<^simproc>\<open>field_combine_numerals\<close>]\<close>)? | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
66806diff
changeset | 447 | oops \<comment> \<open>FIXME: test fails\<close> | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 448 | |
| 61933 | 449 | subsection \<open>\<open>nat_combine_numerals\<close>\<close> | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 450 | |
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 451 | notepad begin | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 452 | fix i j k m n u :: nat | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 453 |   {
 | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 454 | assume "4*k = u" have "k + 3*k = u" | 
| 69597 | 455 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_combine_numerals\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 456 | next | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 457 | (* FIXME "Suc (i + 3) \<equiv> i + 4" *) | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 458 | assume "4 * Suc 0 + i = u" have "Suc (i + 3) = u" | 
| 69597 | 459 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_combine_numerals\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 460 | next | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 461 | (* FIXME "Suc (i + j + 3 + k) \<equiv> i + j + 4 + k" *) | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 462 | assume "4 * Suc 0 + (i + (j + k)) = u" have "Suc (i + j + 3 + k) = u" | 
| 69597 | 463 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_combine_numerals\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 464 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 465 | assume "2 * j + 4 * k = u" have "k + j + 3*k + j = u" | 
| 69597 | 466 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_combine_numerals\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 467 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 468 | assume "6 * Suc 0 + (5 * (i * j) + (4 * k + i)) = u" | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 469 | have "Suc (j*i + i + k + 5 + 3*k + i*j*4) = u" | 
| 69597 | 470 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_combine_numerals\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 471 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 472 | assume "5 * (m * n) = u" have "(2*n*m) + (3*(m*n)) = u" | 
| 69597 | 473 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_combine_numerals\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 474 | } | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 475 | end | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 476 | |
| 61933 | 477 | subsection \<open>\<open>nateq_cancel_numerals\<close>\<close> | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 478 | |
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 479 | notepad begin | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 480 | fix i j k l oo u uu vv w y z w' y' z' :: "nat" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 481 |   {
 | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 482 | assume "Suc 0 * u = 0" have "2*u = (u::nat)" | 
| 69597 | 483 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 484 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 485 | assume "Suc 0 * u = Suc 0" have "2*u = Suc (u)" | 
| 69597 | 486 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 487 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 488 | assume "i + (j + k) = 3 * Suc 0 + (u + y)" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 489 | have "(i + j + 12 + k) = u + 15 + y" | 
| 69597 | 490 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 491 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 492 | assume "7 * Suc 0 + (i + (j + k)) = u + y" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 493 | have "(i + j + 12 + k) = u + 5 + y" | 
| 69597 | 494 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 495 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 496 | assume "11 * Suc 0 + (i + (j + k)) = u + y" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 497 | have "(i + j + 12 + k) = Suc (u + y)" | 
| 69597 | 498 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 499 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 500 | assume "i + (j + k) = 2 * Suc 0 + (u + y)" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 501 | have "(i + j + 5 + k) = Suc (Suc (Suc (Suc (Suc (Suc (Suc (u + y)))))))" | 
| 69597 | 502 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 503 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 504 | assume "Suc 0 * u + (2 * y + 3 * z) = Suc 0" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 505 | have "2*y + 3*z + 2*u = Suc (u)" | 
| 69597 | 506 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 507 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 508 | assume "Suc 0 * u + (2 * y + (3 * z + (6 * w + (2 * y + 3 * z)))) = Suc 0" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 509 | have "2*y + 3*z + 6*w + 2*y + 3*z + 2*u = Suc (u)" | 
| 69597 | 510 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 511 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 512 | assume "Suc 0 * u + (2 * y + (3 * z + (6 * w + (2 * y + 3 * z)))) = | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 513 | 2 * y' + (3 * z' + (6 * w' + (2 * y' + (3 * z' + vv))))" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 514 | have "2*y + 3*z + 6*w + 2*y + 3*z + 2*u = | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 515 | 2*y' + 3*z' + 6*w' + 2*y' + 3*z' + u + vv" | 
| 69597 | 516 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 517 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 518 | assume "2 * u + (2 * z + (5 * Suc 0 + 2 * y)) = vv" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 519 | have "6 + 2*y + 3*z + 4*u = Suc (vv + 2*u + z)" | 
| 69597 | 520 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nateq_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 521 | } | 
| 45224 
b1d5b3820d82
add HOL/ex/Simproc_Tests.thy: testing for Tools/numeral_simprocs.ML
 huffman parents: diff
changeset | 522 | end | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 523 | |
| 61933 | 524 | subsection \<open>\<open>natless_cancel_numerals\<close>\<close> | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 525 | |
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 526 | notepad begin | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 527 | fix length :: "'a \<Rightarrow> nat" and l1 l2 xs :: "'a" and f :: "nat \<Rightarrow> 'a" | 
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 528 | fix c i j k l m oo u uu vv w y z w' y' z' :: "nat" | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 529 |   {
 | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 530 | assume "0 < j" have "(2*length xs < 2*length xs + j)" | 
| 69597 | 531 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natless_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 532 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 533 | assume "0 < j" have "(2*length xs < length xs * 2 + j)" | 
| 69597 | 534 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natless_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 535 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 536 | assume "i + (j + k) < u + y" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 537 | have "(i + j + 5 + k) < Suc (Suc (Suc (Suc (Suc (u + y)))))" | 
| 69597 | 538 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natless_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 539 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 540 | assume "0 < Suc 0 * (m * n) + u" have "(2*n*m) < (3*(m*n)) + u" | 
| 69597 | 541 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natless_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 542 | } | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 543 | end | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 544 | |
| 61933 | 545 | subsection \<open>\<open>natle_cancel_numerals\<close>\<close> | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 546 | |
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 547 | notepad begin | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 548 | fix length :: "'a \<Rightarrow> nat" and l2 l3 :: "'a" and f :: "nat \<Rightarrow> 'a" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 549 | fix c e i j k l oo u uu vv w y z w' y' z' :: "nat" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 550 |   {
 | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 551 | assume "u + y \<le> 36 * Suc 0 + (i + (j + k))" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 552 | have "Suc (Suc (Suc (Suc (Suc (u + y))))) \<le> ((i + j) + 41 + k)" | 
| 69597 | 553 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natle_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 554 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 555 | assume "5 * Suc 0 + (case length (f c) of 0 \<Rightarrow> 0 | Suc k \<Rightarrow> k) = 0" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 556 | have "(Suc (Suc (Suc (Suc (Suc (Suc (case length (f c) of 0 => 0 | Suc k => k)))))) \<le> Suc 0)" | 
| 69597 | 557 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natle_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 558 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 559 | assume "6 + length l2 = 0" have "Suc (Suc (Suc (Suc (Suc (Suc (length l1 + length l2)))))) \<le> length l1" | 
| 69597 | 560 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natle_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 561 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 562 | assume "5 + length l3 = 0" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 563 | have "( (Suc (Suc (Suc (Suc (Suc (length (compT P E A ST mxr e) + length l3)))))) \<le> length (compT P E A ST mxr e))" | 
| 69597 | 564 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natle_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 565 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 566 | assume "5 + length (compT P E (A \<union> A' e) ST mxr c) = 0" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 567 | have "( (Suc (Suc (Suc (Suc (Suc (length (compT P E A ST mxr e) + length (compT P E (A Un A' e) ST mxr c))))))) \<le> length (compT P E A ST mxr e))" | 
| 69597 | 568 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natle_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 569 | } | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 570 | end | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 571 | |
| 61933 | 572 | subsection \<open>\<open>natdiff_cancel_numerals\<close>\<close> | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 573 | |
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 574 | notepad begin | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 575 | fix length :: "'a \<Rightarrow> nat" and l2 l3 :: "'a" and f :: "nat \<Rightarrow> 'a" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 576 | fix c e i j k l oo u uu vv v w x y z zz w' y' z' :: "nat" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 577 |   {
 | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 578 | assume "i + (j + k) - 3 * Suc 0 = y" have "(i + j + 12 + k) - 15 = y" | 
| 69597 | 579 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 580 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 581 | assume "7 * Suc 0 + (i + (j + k)) - 0 = y" have "(i + j + 12 + k) - 5 = y" | 
| 69597 | 582 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 583 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 584 | assume "u - Suc 0 * Suc 0 = y" have "Suc u - 2 = y" | 
| 69597 | 585 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 586 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 587 | assume "Suc 0 * Suc 0 + u - 0 = y" have "Suc (Suc (Suc u)) - 2 = y" | 
| 69597 | 588 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 589 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 590 | assume "Suc 0 * Suc 0 + (i + (j + k)) - 0 = y" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 591 | have "(i + j + 2 + k) - 1 = y" | 
| 69597 | 592 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 593 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 594 | assume "i + (j + k) - Suc 0 * Suc 0 = y" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 595 | have "(i + j + 1 + k) - 2 = y" | 
| 69597 | 596 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 597 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 598 | assume "2 * x + y - 2 * (u * v) = w" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 599 | have "(2*x + (u*v) + y) - v*3*u = w" | 
| 69597 | 600 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 601 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 602 | assume "2 * x * u * v + (5 + y) - 0 = w" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 603 | have "(2*x*u*v + 5 + (u*v)*4 + y) - v*u*4 = w" | 
| 69597 | 604 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 605 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 606 | assume "3 * (u * v) + (2 * x * u * v + y) - 0 = w" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 607 | have "(2*x*u*v + (u*v)*4 + y) - v*u = w" | 
| 69597 | 608 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 609 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 610 | assume "3 * u + (2 + (2 * x * u * v + y)) - 0 = w" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 611 | have "Suc (Suc (2*x*u*v + u*4 + y)) - u = w" | 
| 69597 | 612 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 613 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 614 | assume "Suc (Suc 0 * (u * v)) - 0 = w" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 615 | have "Suc ((u*v)*4) - v*3*u = w" | 
| 69597 | 616 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 617 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 618 | assume "2 - 0 = w" have "Suc (Suc ((u*v)*3)) - v*3*u = w" | 
| 69597 | 619 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 620 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 621 | assume "17 * Suc 0 + (i + (j + k)) - (u + y) = zz" | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 622 | have "(i + j + 32 + k) - (u + 15 + y) = zz" | 
| 69597 | 623 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 624 | next | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 625 | assume "u + y - 0 = v" have "Suc (Suc (Suc (Suc (Suc (u + y))))) - 5 = v" | 
| 69597 | 626 | by (tactic \<open>test \<^context> [\<^simproc>\<open>natdiff_cancel_numerals\<close>]\<close>) fact | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 627 | } | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 628 | end | 
| 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 629 | |
| 69597 | 630 | subsection \<open>Factor-cancellation simprocs for type \<^typ>\<open>nat\<close>\<close> | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 631 | |
| 61933 | 632 | text \<open>\<open>nat_eq_cancel_factor\<close>, \<open>nat_less_cancel_factor\<close>, | 
| 633 | \<open>nat_le_cancel_factor\<close>, \<open>nat_divide_cancel_factor\<close>, and | |
| 634 | \<open>nat_dvd_cancel_factor\<close>.\<close> | |
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 635 | |
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 636 | notepad begin | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 637 | fix a b c d k x y uu :: nat | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 638 |   {
 | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 639 | assume "k = 0 \<or> x = y" have "x*k = k*y" | 
| 69597 | 640 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_eq_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 641 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 642 | assume "k = 0 \<or> Suc 0 = y" have "k = k*y" | 
| 69597 | 643 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_eq_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 644 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 645 | assume "b = 0 \<or> a * c = Suc 0" have "a*(b*c) = b" | 
| 69597 | 646 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_eq_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 647 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 648 | assume "a = 0 \<or> b = 0 \<or> c = d * x" have "a*(b*c) = d*b*(x*a)" | 
| 69597 | 649 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_eq_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 650 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 651 | assume "0 < k \<and> x < y" have "x*k < k*y" | 
| 69597 | 652 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_less_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 653 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 654 | assume "0 < k \<and> Suc 0 < y" have "k < k*y" | 
| 69597 | 655 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_less_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 656 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 657 | assume "0 < b \<and> a * c < Suc 0" have "a*(b*c) < b" | 
| 69597 | 658 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_less_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 659 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 660 | assume "0 < a \<and> 0 < b \<and> c < d * x" have "a*(b*c) < d*b*(x*a)" | 
| 69597 | 661 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_less_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 662 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 663 | assume "0 < k \<longrightarrow> x \<le> y" have "x*k \<le> k*y" | 
| 69597 | 664 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_le_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 665 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 666 | assume "0 < k \<longrightarrow> Suc 0 \<le> y" have "k \<le> k*y" | 
| 69597 | 667 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_le_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 668 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 669 | assume "0 < b \<longrightarrow> a * c \<le> Suc 0" have "a*(b*c) \<le> b" | 
| 69597 | 670 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_le_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 671 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 672 | assume "0 < a \<longrightarrow> 0 < b \<longrightarrow> c \<le> d * x" have "a*(b*c) \<le> d*b*(x*a)" | 
| 69597 | 673 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_le_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 674 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 675 | assume "(if k = 0 then 0 else x div y) = uu" have "(x*k) div (k*y) = uu" | 
| 69597 | 676 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_div_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 677 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 678 | assume "(if k = 0 then 0 else Suc 0 div y) = uu" have "k div (k*y) = uu" | 
| 69597 | 679 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_div_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 680 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 681 | assume "(if b = 0 then 0 else a * c) = uu" have "(a*(b*c)) div (b) = uu" | 
| 69597 | 682 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_div_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 683 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 684 | assume "(if a = 0 then 0 else if b = 0 then 0 else c div (d * x)) = uu" | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 685 | have "(a*(b*c)) div (d*b*(x*a)) = uu" | 
| 69597 | 686 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_div_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 687 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 688 | assume "k = 0 \<or> x dvd y" have "(x*k) dvd (k*y)" | 
| 69597 | 689 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_dvd_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 690 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 691 | assume "k = 0 \<or> Suc 0 dvd y" have "k dvd (k*y)" | 
| 69597 | 692 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_dvd_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 693 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 694 | assume "b = 0 \<or> a * c dvd Suc 0" have "(a*(b*c)) dvd (b)" | 
| 69597 | 695 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_dvd_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 696 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 697 | assume "b = 0 \<or> Suc 0 dvd a * c" have "b dvd (a*(b*c))" | 
| 69597 | 698 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_dvd_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 699 | next | 
| 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 700 | assume "a = 0 \<or> b = 0 \<or> c dvd d * x" have "(a*(b*c)) dvd (d*b*(x*a))" | 
| 69597 | 701 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_dvd_cancel_factor\<close>]\<close>) fact | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 702 | } | 
| 45436 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
 huffman parents: 
45435diff
changeset | 703 | end | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 704 | |
| 69597 | 705 | subsection \<open>Numeral-cancellation simprocs for type \<^typ>\<open>nat\<close>\<close> | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 706 | |
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 707 | notepad begin | 
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 708 | fix x y z :: nat | 
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 709 |   {
 | 
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 710 | assume "3 * x = 4 * y" have "9*x = 12 * y" | 
| 69597 | 711 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_eq_cancel_numeral_factor\<close>]\<close>) fact | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 712 | next | 
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 713 | assume "3 * x < 4 * y" have "9*x < 12 * y" | 
| 69597 | 714 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_less_cancel_numeral_factor\<close>]\<close>) fact | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 715 | next | 
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 716 | assume "3 * x \<le> 4 * y" have "9*x \<le> 12 * y" | 
| 69597 | 717 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_le_cancel_numeral_factor\<close>]\<close>) fact | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 718 | next | 
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 719 | assume "(3 * x) div (4 * y) = z" have "(9*x) div (12 * y) = z" | 
| 69597 | 720 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_div_cancel_numeral_factor\<close>]\<close>) fact | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 721 | next | 
| 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 722 | assume "(3 * x) dvd (4 * y)" have "(9*x) dvd (12 * y)" | 
| 69597 | 723 | by (tactic \<open>test \<^context> [\<^simproc>\<open>nat_dvd_cancel_numeral_factor\<close>]\<close>) fact | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 724 | } | 
| 45462 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
 huffman parents: 
45437diff
changeset | 725 | end | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 726 | |
| 61343 | 727 | subsection \<open>Integer numeral div/mod simprocs\<close> | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 728 | |
| 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 729 | notepad begin | 
| 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 730 | have "(10::int) div 3 = 3" | 
| 69597 | 731 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 732 | have "(10::int) mod 3 = 1" | 
| 69597 | 733 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 734 | have "(10::int) div -3 = -4" | 
| 69597 | 735 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 736 | have "(10::int) mod -3 = -2" | 
| 69597 | 737 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 738 | have "(-10::int) div 3 = -4" | 
| 69597 | 739 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 740 | have "(-10::int) mod 3 = 2" | 
| 69597 | 741 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 742 | have "(-10::int) div -3 = 3" | 
| 69597 | 743 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 744 | have "(-10::int) mod -3 = -1" | 
| 69597 | 745 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 746 | have "(8452::int) mod 3 = 1" | 
| 69597 | 747 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 748 | have "(59485::int) div 434 = 137" | 
| 69597 | 749 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 750 | have "(1000006::int) mod 10 = 6" | 
| 69597 | 751 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 752 | have "10000000 div 2 = (5000000::int)" | 
| 69597 | 753 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 754 | have "10000001 mod 2 = (1::int)" | 
| 69597 | 755 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 756 | have "10000055 div 32 = (312501::int)" | 
| 69597 | 757 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 758 | have "10000055 mod 32 = (23::int)" | 
| 69597 | 759 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 760 | have "100094 div 144 = (695::int)" | 
| 69597 | 761 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 762 | have "100094 mod 144 = (14::int)" | 
| 69597 | 763 | by (tactic \<open>test \<^context> [\<^simproc>\<open>numeral_divmod\<close>]\<close>) | 
| 45463 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
 huffman parents: 
45462diff
changeset | 764 | end | 
| 45530 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 765 | |
| 
0c4853bb77bf
rewrite integer numeral div/mod simprocs to not return conditional rewrites; add regression tests
 huffman parents: 
45464diff
changeset | 766 | end |