author  huffman 
Sun, 01 Apr 2012 16:09:58 +0200  
changeset 47255  30a1692557b0 
parent 47159  978c00c20a59 
child 48891  c0eafbd55de3 
permissions  rwrr 
33366  1 
(* Author: Various *) 
2 

3 
header {* Combination and Cancellation Simprocs for Numeral Expressions *} 

4 

5 
theory Numeral_Simprocs 

6 
imports Divides 

7 
uses 

8 
"~~/src/Provers/Arith/assoc_fold.ML" 

9 
"~~/src/Provers/Arith/cancel_numerals.ML" 

10 
"~~/src/Provers/Arith/combine_numerals.ML" 

11 
"~~/src/Provers/Arith/cancel_numeral_factor.ML" 

12 
"~~/src/Provers/Arith/extract_common_term.ML" 

13 
("Tools/numeral_simprocs.ML") 

14 
("Tools/nat_numeral_simprocs.ML") 

15 
begin 

16 

47255
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

17 
lemmas semiring_norm = 
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

18 
Let_def arith_simps nat_arith rel_simps 
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

19 
if_False if_True 
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

20 
add_0 add_Suc add_numeral_left 
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

21 
add_neg_numeral_left mult_numeral_left 
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

22 
numeral_1_eq_1 [symmetric] Suc_eq_plus1 
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

23 
eq_numeral_iff_iszero not_iszero_Numeral1 
30a1692557b0
removed Nat_Numeral.thy, moving all theorems elsewhere
huffman
parents:
47159
diff
changeset

24 

47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

25 
declare split_div [of _ _ "numeral k", arith_split] for k 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

26 
declare split_mod [of _ _ "numeral k", arith_split] for k 
33366  27 

28 
text {* For @{text combine_numerals} *} 

29 

30 
lemma left_add_mult_distrib: "i*u + (j*u + k) = (i+j)*u + (k::nat)" 

31 
by (simp add: add_mult_distrib) 

32 

33 
text {* For @{text cancel_numerals} *} 

34 

35 
lemma nat_diff_add_eq1: 

36 
"j <= (i::nat) ==> ((i*u + m)  (j*u + n)) = (((ij)*u + m)  n)" 

37 
by (simp split add: nat_diff_split add: add_mult_distrib) 

38 

39 
lemma nat_diff_add_eq2: 

40 
"i <= (j::nat) ==> ((i*u + m)  (j*u + n)) = (m  ((ji)*u + n))" 

41 
by (simp split add: nat_diff_split add: add_mult_distrib) 

42 

43 
lemma nat_eq_add_iff1: 

44 
"j <= (i::nat) ==> (i*u + m = j*u + n) = ((ij)*u + m = n)" 

45 
by (auto split add: nat_diff_split simp add: add_mult_distrib) 

46 

47 
lemma nat_eq_add_iff2: 

48 
"i <= (j::nat) ==> (i*u + m = j*u + n) = (m = (ji)*u + n)" 

49 
by (auto split add: nat_diff_split simp add: add_mult_distrib) 

50 

51 
lemma nat_less_add_iff1: 

52 
"j <= (i::nat) ==> (i*u + m < j*u + n) = ((ij)*u + m < n)" 

53 
by (auto split add: nat_diff_split simp add: add_mult_distrib) 

54 

55 
lemma nat_less_add_iff2: 

56 
"i <= (j::nat) ==> (i*u + m < j*u + n) = (m < (ji)*u + n)" 

57 
by (auto split add: nat_diff_split simp add: add_mult_distrib) 

58 

59 
lemma nat_le_add_iff1: 

60 
"j <= (i::nat) ==> (i*u + m <= j*u + n) = ((ij)*u + m <= n)" 

61 
by (auto split add: nat_diff_split simp add: add_mult_distrib) 

62 

63 
lemma nat_le_add_iff2: 

64 
"i <= (j::nat) ==> (i*u + m <= j*u + n) = (m <= (ji)*u + n)" 

65 
by (auto split add: nat_diff_split simp add: add_mult_distrib) 

66 

67 
text {* For @{text cancel_numeral_factors} *} 

68 

69 
lemma nat_mult_le_cancel1: "(0::nat) < k ==> (k*m <= k*n) = (m<=n)" 

70 
by auto 

71 

72 
lemma nat_mult_less_cancel1: "(0::nat) < k ==> (k*m < k*n) = (m<n)" 

73 
by auto 

74 

75 
lemma nat_mult_eq_cancel1: "(0::nat) < k ==> (k*m = k*n) = (m=n)" 

76 
by auto 

77 

78 
lemma nat_mult_div_cancel1: "(0::nat) < k ==> (k*m) div (k*n) = (m div n)" 

79 
by auto 

80 

81 
lemma nat_mult_dvd_cancel_disj[simp]: 

82 
"(k*m) dvd (k*n) = (k=0  m dvd (n::nat))" 

47159  83 
by (auto simp: dvd_eq_mod_eq_0 mod_mult_mult1) 
33366  84 

85 
lemma nat_mult_dvd_cancel1: "0 < k \<Longrightarrow> (k*m) dvd (k*n::nat) = (m dvd n)" 

86 
by(auto) 

87 

88 
text {* For @{text cancel_factor} *} 

89 

90 
lemma nat_mult_le_cancel_disj: "(k*m <= k*n) = ((0::nat) < k > m<=n)" 

91 
by auto 

92 

93 
lemma nat_mult_less_cancel_disj: "(k*m < k*n) = ((0::nat) < k & m<n)" 

94 
by auto 

95 

96 
lemma nat_mult_eq_cancel_disj: "(k*m = k*n) = (k = (0::nat)  m=n)" 

97 
by auto 

98 

99 
lemma nat_mult_div_cancel_disj[simp]: 

100 
"(k*m) div (k*n) = (if k = (0::nat) then 0 else m div n)" 

101 
by (simp add: nat_mult_div_cancel1) 

102 

103 
use "Tools/numeral_simprocs.ML" 

104 

45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

105 
simproc_setup semiring_assoc_fold 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

106 
("(a::'a::comm_semiring_1_cancel) * b") = 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

107 
{* fn phi => Numeral_Simprocs.assoc_fold *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

108 

47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

109 
(* TODO: see whether the type class can be generalized further *) 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

110 
simproc_setup int_combine_numerals 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

111 
("(i::'a::comm_ring_1) + j"  "(i::'a::comm_ring_1)  j") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

112 
{* fn phi => Numeral_Simprocs.combine_numerals *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

113 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

114 
simproc_setup field_combine_numerals 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

115 
("(i::'a::{field_inverse_zero,ring_char_0}) + j" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

116 
"(i::'a::{field_inverse_zero,ring_char_0})  j") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

117 
{* fn phi => Numeral_Simprocs.field_combine_numerals *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

118 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

119 
simproc_setup inteq_cancel_numerals 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

120 
("(l::'a::comm_ring_1) + m = n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

121 
"(l::'a::comm_ring_1) = m + n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

122 
"(l::'a::comm_ring_1)  m = n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

123 
"(l::'a::comm_ring_1) = m  n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

124 
"(l::'a::comm_ring_1) * m = n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

125 
"(l::'a::comm_ring_1) = m * n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

126 
" (l::'a::comm_ring_1) = m" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

127 
"(l::'a::comm_ring_1) =  m") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

128 
{* fn phi => Numeral_Simprocs.eq_cancel_numerals *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

129 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

130 
simproc_setup intless_cancel_numerals 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

131 
("(l::'a::linordered_idom) + m < n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

132 
"(l::'a::linordered_idom) < m + n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

133 
"(l::'a::linordered_idom)  m < n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

134 
"(l::'a::linordered_idom) < m  n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

135 
"(l::'a::linordered_idom) * m < n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

136 
"(l::'a::linordered_idom) < m * n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

137 
" (l::'a::linordered_idom) < m" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

138 
"(l::'a::linordered_idom) <  m") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

139 
{* fn phi => Numeral_Simprocs.less_cancel_numerals *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

140 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

141 
simproc_setup intle_cancel_numerals 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

142 
("(l::'a::linordered_idom) + m \<le> n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

143 
"(l::'a::linordered_idom) \<le> m + n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

144 
"(l::'a::linordered_idom)  m \<le> n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

145 
"(l::'a::linordered_idom) \<le> m  n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

146 
"(l::'a::linordered_idom) * m \<le> n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

147 
"(l::'a::linordered_idom) \<le> m * n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

148 
" (l::'a::linordered_idom) \<le> m" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

149 
"(l::'a::linordered_idom) \<le>  m") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

150 
{* fn phi => Numeral_Simprocs.le_cancel_numerals *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

151 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

152 
simproc_setup ring_eq_cancel_numeral_factor 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

153 
("(l::'a::{idom,ring_char_0}) * m = n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

154 
"(l::'a::{idom,ring_char_0}) = m * n") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

155 
{* fn phi => Numeral_Simprocs.eq_cancel_numeral_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

156 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

157 
simproc_setup ring_less_cancel_numeral_factor 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

158 
("(l::'a::linordered_idom) * m < n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

159 
"(l::'a::linordered_idom) < m * n") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

160 
{* fn phi => Numeral_Simprocs.less_cancel_numeral_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

161 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

162 
simproc_setup ring_le_cancel_numeral_factor 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

163 
("(l::'a::linordered_idom) * m <= n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

164 
"(l::'a::linordered_idom) <= m * n") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

165 
{* fn phi => Numeral_Simprocs.le_cancel_numeral_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

166 

47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

167 
(* TODO: remove comm_ring_1 constraint if possible *) 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

168 
simproc_setup int_div_cancel_numeral_factors 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

169 
("((l::'a::{semiring_div,comm_ring_1,ring_char_0}) * m) div n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

170 
"(l::'a::{semiring_div,comm_ring_1,ring_char_0}) div (m * n)") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

171 
{* fn phi => Numeral_Simprocs.div_cancel_numeral_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

172 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

173 
simproc_setup divide_cancel_numeral_factor 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

174 
("((l::'a::{field_inverse_zero,ring_char_0}) * m) / n" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

175 
"(l::'a::{field_inverse_zero,ring_char_0}) / (m * n)" 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

176 
"((numeral v)::'a::{field_inverse_zero,ring_char_0}) / (numeral w)") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

177 
{* fn phi => Numeral_Simprocs.divide_cancel_numeral_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

178 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

179 
simproc_setup ring_eq_cancel_factor 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

180 
("(l::'a::idom) * m = n"  "(l::'a::idom) = m * n") = 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

181 
{* fn phi => Numeral_Simprocs.eq_cancel_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

182 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

183 
simproc_setup linordered_ring_le_cancel_factor 
45296
7a97b2bda137
more accurate class constraints on cancellation simproc patterns
huffman
parents:
45284
diff
changeset

184 
("(l::'a::linordered_idom) * m <= n" 
7a97b2bda137
more accurate class constraints on cancellation simproc patterns
huffman
parents:
45284
diff
changeset

185 
"(l::'a::linordered_idom) <= m * n") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

186 
{* fn phi => Numeral_Simprocs.le_cancel_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

187 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

188 
simproc_setup linordered_ring_less_cancel_factor 
45296
7a97b2bda137
more accurate class constraints on cancellation simproc patterns
huffman
parents:
45284
diff
changeset

189 
("(l::'a::linordered_idom) * m < n" 
7a97b2bda137
more accurate class constraints on cancellation simproc patterns
huffman
parents:
45284
diff
changeset

190 
"(l::'a::linordered_idom) < m * n") = 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

191 
{* fn phi => Numeral_Simprocs.less_cancel_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

192 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

193 
simproc_setup int_div_cancel_factor 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

194 
("((l::'a::semiring_div) * m) div n" 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

195 
"(l::'a::semiring_div) div (m * n)") = 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

196 
{* fn phi => Numeral_Simprocs.div_cancel_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

197 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

198 
simproc_setup int_mod_cancel_factor 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

199 
("((l::'a::semiring_div) * m) mod n" 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

200 
"(l::'a::semiring_div) mod (m * n)") = 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

201 
{* fn phi => Numeral_Simprocs.mod_cancel_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

202 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

203 
simproc_setup dvd_cancel_factor 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

204 
("((l::'a::idom) * m) dvd n" 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

205 
"(l::'a::idom) dvd (m * n)") = 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

206 
{* fn phi => Numeral_Simprocs.dvd_cancel_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

207 

ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

208 
simproc_setup divide_cancel_factor 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

209 
("((l::'a::field_inverse_zero) * m) / n" 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

210 
"(l::'a::field_inverse_zero) / (m * n)") = 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

211 
{* fn phi => Numeral_Simprocs.divide_cancel_factor *} 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

212 

33366  213 
use "Tools/nat_numeral_simprocs.ML" 
214 

45462
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

215 
simproc_setup nat_combine_numerals 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

216 
("(i::nat) + j"  "Suc (i + j)") = 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

217 
{* fn phi => Nat_Numeral_Simprocs.combine_numerals *} 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

218 

45436
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

219 
simproc_setup nateq_cancel_numerals 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

220 
("(l::nat) + m = n"  "(l::nat) = m + n"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

221 
"(l::nat) * m = n"  "(l::nat) = m * n"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

222 
"Suc m = n"  "m = Suc n") = 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

223 
{* fn phi => Nat_Numeral_Simprocs.eq_cancel_numerals *} 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

224 

62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

225 
simproc_setup natless_cancel_numerals 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

226 
("(l::nat) + m < n"  "(l::nat) < m + n"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

227 
"(l::nat) * m < n"  "(l::nat) < m * n"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

228 
"Suc m < n"  "m < Suc n") = 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

229 
{* fn phi => Nat_Numeral_Simprocs.less_cancel_numerals *} 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

230 

62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

231 
simproc_setup natle_cancel_numerals 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

232 
("(l::nat) + m \<le> n"  "(l::nat) \<le> m + n"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

233 
"(l::nat) * m \<le> n"  "(l::nat) \<le> m * n"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

234 
"Suc m \<le> n"  "m \<le> Suc n") = 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

235 
{* fn phi => Nat_Numeral_Simprocs.le_cancel_numerals *} 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

236 

62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

237 
simproc_setup natdiff_cancel_numerals 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

238 
("((l::nat) + m)  n"  "(l::nat)  (m + n)"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

239 
"(l::nat) * m  n"  "(l::nat)  m * n"  
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

240 
"Suc m  n"  "m  Suc n") = 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

241 
{* fn phi => Nat_Numeral_Simprocs.diff_cancel_numerals *} 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

242 

45463
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

243 
simproc_setup nat_eq_cancel_numeral_factor 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

244 
("(l::nat) * m = n"  "(l::nat) = m * n") = 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

245 
{* fn phi => Nat_Numeral_Simprocs.eq_cancel_numeral_factor *} 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

246 

9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

247 
simproc_setup nat_less_cancel_numeral_factor 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

248 
("(l::nat) * m < n"  "(l::nat) < m * n") = 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

249 
{* fn phi => Nat_Numeral_Simprocs.less_cancel_numeral_factor *} 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

250 

9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

251 
simproc_setup nat_le_cancel_numeral_factor 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

252 
("(l::nat) * m <= n"  "(l::nat) <= m * n") = 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

253 
{* fn phi => Nat_Numeral_Simprocs.le_cancel_numeral_factor *} 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

254 

9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

255 
simproc_setup nat_div_cancel_numeral_factor 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

256 
("((l::nat) * m) div n"  "(l::nat) div (m * n)") = 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

257 
{* fn phi => Nat_Numeral_Simprocs.div_cancel_numeral_factor *} 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

258 

9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

259 
simproc_setup nat_dvd_cancel_numeral_factor 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

260 
("((l::nat) * m) dvd n"  "(l::nat) dvd (m * n)") = 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

261 
{* fn phi => Nat_Numeral_Simprocs.dvd_cancel_numeral_factor *} 
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

262 

45462
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

263 
simproc_setup nat_eq_cancel_factor 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

264 
("(l::nat) * m = n"  "(l::nat) = m * n") = 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

265 
{* fn phi => Nat_Numeral_Simprocs.eq_cancel_factor *} 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

266 

aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

267 
simproc_setup nat_less_cancel_factor 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

268 
("(l::nat) * m < n"  "(l::nat) < m * n") = 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

269 
{* fn phi => Nat_Numeral_Simprocs.less_cancel_factor *} 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

270 

aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

271 
simproc_setup nat_le_cancel_factor 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

272 
("(l::nat) * m <= n"  "(l::nat) <= m * n") = 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

273 
{* fn phi => Nat_Numeral_Simprocs.le_cancel_factor *} 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

274 

45463
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

275 
simproc_setup nat_div_cancel_factor 
45462
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

276 
("((l::nat) * m) div n"  "(l::nat) div (m * n)") = 
45463
9a588a835c1e
use simproc_setup for the remaining nat_numeral simprocs
huffman
parents:
45462
diff
changeset

277 
{* fn phi => Nat_Numeral_Simprocs.div_cancel_factor *} 
45462
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

278 

aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

279 
simproc_setup nat_dvd_cancel_factor 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

280 
("((l::nat) * m) dvd n"  "(l::nat) dvd (m * n)") = 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

281 
{* fn phi => Nat_Numeral_Simprocs.dvd_cancel_factor *} 
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

282 

47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

283 
(* FIXME: duplicate rule warnings for: 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

284 
ring_distribs 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

285 
numeral_plus_numeral numeral_times_numeral 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

286 
numeral_eq_iff numeral_less_iff numeral_le_iff 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

287 
numeral_neq_zero zero_neq_numeral zero_less_numeral 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

288 
if_True if_False *) 
33366  289 
declaration {* 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

290 
K (Lin_Arith.add_simps ([@{thm Suc_numeral}, @{thm int_numeral}]) 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

291 
#> Lin_Arith.add_simps (@{thms ring_distribs} @ [@{thm Let_numeral}, @{thm Let_neg_numeral}, @{thm Let_0}, @{thm Let_1}, 
33366  292 
@{thm nat_0}, @{thm nat_1}, 
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

293 
@{thm numeral_plus_numeral}, @{thm diff_nat_numeral}, @{thm numeral_times_numeral}, 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

294 
@{thm numeral_eq_iff}, @{thm numeral_less_iff}, @{thm numeral_le_iff}, 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

295 
@{thm le_Suc_numeral}, @{thm le_numeral_Suc}, 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

296 
@{thm less_Suc_numeral}, @{thm less_numeral_Suc}, 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

297 
@{thm Suc_eq_numeral}, @{thm eq_numeral_Suc}, 
33366  298 
@{thm mult_Suc}, @{thm mult_Suc_right}, 
299 
@{thm add_Suc}, @{thm add_Suc_right}, 

47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

300 
@{thm numeral_neq_zero}, @{thm zero_neq_numeral}, @{thm zero_less_numeral}, 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
45607
diff
changeset

301 
@{thm of_int_numeral}, @{thm of_nat_numeral}, @{thm nat_numeral}, 
33366  302 
@{thm if_True}, @{thm if_False}]) 
45284
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

303 
#> Lin_Arith.add_simprocs 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

304 
[@{simproc semiring_assoc_fold}, 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

305 
@{simproc int_combine_numerals}, 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

306 
@{simproc inteq_cancel_numerals}, 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

307 
@{simproc intless_cancel_numerals}, 
ae78a4ffa81d
use simproc_setup for cancellation simprocs, to get proper name bindings
huffman
parents:
37886
diff
changeset

308 
@{simproc intle_cancel_numerals}] 
45436
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

309 
#> Lin_Arith.add_simprocs 
45462
aba629d6cee5
use simproc_setup for more nat_numeral simprocs; add simproc tests
huffman
parents:
45436
diff
changeset

310 
[@{simproc nat_combine_numerals}, 
45436
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

311 
@{simproc nateq_cancel_numerals}, 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

312 
@{simproc natless_cancel_numerals}, 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

313 
@{simproc natle_cancel_numerals}, 
62bc9474d04b
use simproc_setup for some nat_numeral simprocs; add simproc tests
huffman
parents:
45435
diff
changeset

314 
@{simproc natdiff_cancel_numerals}]) 
33366  315 
*} 
316 

37886  317 
end 