equal
deleted
inserted
replaced
3 *) |
3 *) |
4 |
4 |
5 section \<open>Using the transfer method between nat and int\<close> |
5 section \<open>Using the transfer method between nat and int\<close> |
6 |
6 |
7 theory Transfer_Int_Nat |
7 theory Transfer_Int_Nat |
8 imports GCD |
8 imports Main |
9 begin |
9 begin |
10 |
10 |
11 subsection \<open>Correspondence relation\<close> |
11 subsection \<open>Correspondence relation\<close> |
12 |
12 |
13 definition ZN :: "int \<Rightarrow> nat \<Rightarrow> bool" |
13 definition ZN :: "int \<Rightarrow> nat \<Rightarrow> bool" |
14 where "ZN = (\<lambda>z n. z = of_nat n)" |
14 where "ZN = (\<lambda>z n. z = of_nat n)" |
15 |
15 |
16 subsection \<open>Transfer domain rules\<close> |
16 subsection \<open>Transfer domain rules\<close> |
17 |
17 |
18 lemma Domainp_ZN [transfer_domain_rule]: "Domainp ZN = (\<lambda>x. x \<ge> 0)" |
18 lemma Domainp_ZN [transfer_domain_rule]: "Domainp ZN = (\<lambda>x. x \<ge> 0)" |
19 unfolding ZN_def Domainp_iff[abs_def] by (auto intro: zero_le_imp_eq_int) |
19 unfolding ZN_def Domainp_iff[abs_def] by (auto intro: zero_le_imp_eq_int) |
20 |
20 |
21 subsection \<open>Transfer rules\<close> |
21 subsection \<open>Transfer rules\<close> |
22 |
22 |
23 context includes lifting_syntax |
23 context includes lifting_syntax |
175 apply (transfer fixing: i j) |
175 apply (transfer fixing: i j) |
176 apply fact |
176 apply fact |
177 done |
177 done |
178 |
178 |
179 lemma |
179 lemma |
180 assumes "\<And>x y z::int. \<lbrakk>0 \<le> x; 0 \<le> y; 0 \<le> z\<rbrakk> \<Longrightarrow> |
180 assumes "\<And>x y z::int. \<lbrakk>0 \<le> x; 0 \<le> y; 0 \<le> z\<rbrakk> \<Longrightarrow> |
181 sum_list [x, y, z] = 0 \<longleftrightarrow> list_all (\<lambda>x. x = 0) [x, y, z]" |
181 sum_list [x, y, z] = 0 \<longleftrightarrow> list_all (\<lambda>x. x = 0) [x, y, z]" |
182 shows "sum_list [x, y, z] = (0::nat) \<longleftrightarrow> list_all (\<lambda>x. x = 0) [x, y, z]" |
182 shows "sum_list [x, y, z] = (0::nat) \<longleftrightarrow> list_all (\<lambda>x. x = 0) [x, y, z]" |
183 apply transfer |
183 apply transfer |
184 apply fact |
184 apply fact |
185 done |
185 done |