equal
deleted
inserted
replaced
26 defs (overloaded) |
26 defs (overloaded) |
27 even_def: "even (x::int) == x mod 2 = 0" |
27 even_def: "even (x::int) == x mod 2 = 0" |
28 even_nat_def: "even (x::nat) == even (int x)" |
28 even_nat_def: "even (x::nat) == even (int x)" |
29 |
29 |
30 |
30 |
31 subsection {* Casting a nat power to an integer *} |
|
32 |
|
33 lemma zpow_int: "int (x^y) = (int x)^y" |
|
34 apply (induct y) |
|
35 apply (simp, simp add: zmult_int [THEN sym]) |
|
36 done |
|
37 |
|
38 subsection {* Even and odd are mutually exclusive *} |
31 subsection {* Even and odd are mutually exclusive *} |
39 |
32 |
40 lemma int_pos_lt_two_imp_zero_or_one: |
33 lemma int_pos_lt_two_imp_zero_or_one: |
41 "0 <= x ==> (x::int) < 2 ==> x = 0 | x = 1" |
34 "0 <= x ==> (x::int) < 2 ==> x = 0 | x = 1" |
42 by auto |
35 by auto |
141 |
134 |
142 lemma pos_int_even_equiv_nat_even: "0 \<le> x ==> even x = even (nat x)" |
135 lemma pos_int_even_equiv_nat_even: "0 \<le> x ==> even x = even (nat x)" |
143 by (simp add: even_nat_def) |
136 by (simp add: even_nat_def) |
144 |
137 |
145 lemma even_nat_product: "even((x::nat) * y) = (even x | even y)" |
138 lemma even_nat_product: "even((x::nat) * y) = (even x | even y)" |
146 by (simp add: even_nat_def zmult_int [THEN sym]) |
139 by (simp add: even_nat_def int_mult) |
147 |
140 |
148 lemma even_nat_sum: "even ((x::nat) + y) = |
141 lemma even_nat_sum: "even ((x::nat) + y) = |
149 ((even x & even y) | (odd x & odd y))" |
142 ((even x & even y) | (odd x & odd y))" |
150 by (unfold even_nat_def, simp) |
143 by (unfold even_nat_def, simp) |
151 |
144 |
161 |
154 |
162 text{*Compatibility, in case Avigad uses this*} |
155 text{*Compatibility, in case Avigad uses this*} |
163 lemmas even_nat_suc = even_nat_Suc |
156 lemmas even_nat_suc = even_nat_Suc |
164 |
157 |
165 lemma even_nat_power: "even ((x::nat)^y) = (even x & 0 < y)" |
158 lemma even_nat_power: "even ((x::nat)^y) = (even x & 0 < y)" |
166 by (simp add: even_nat_def zpow_int) |
159 by (simp add: even_nat_def int_power) |
167 |
160 |
168 lemma even_nat_zero: "even (0::nat)" |
161 lemma even_nat_zero: "even (0::nat)" |
169 by (simp add: even_nat_def) |
162 by (simp add: even_nat_def) |
170 |
163 |
171 lemmas even_odd_nat_simps [simp] = even_nat_def[of "number_of v",standard] |
164 lemmas even_odd_nat_simps [simp] = even_nat_def[of "number_of v",standard] |