86 "(pcr_integer ===> pcr_integer ===> (\<longleftrightarrow>)) (dvd) (dvd)" |
86 "(pcr_integer ===> pcr_integer ===> (\<longleftrightarrow>)) (dvd) (dvd)" |
87 by (unfold dvd_def) transfer_prover |
87 by (unfold dvd_def) transfer_prover |
88 |
88 |
89 lemma [transfer_rule]: |
89 lemma [transfer_rule]: |
90 "((\<longleftrightarrow>) ===> pcr_integer) of_bool of_bool" |
90 "((\<longleftrightarrow>) ===> pcr_integer) of_bool of_bool" |
91 by (unfold of_bool_def [abs_def]) transfer_prover |
91 by (unfold of_bool_def) transfer_prover |
92 |
92 |
93 lemma [transfer_rule]: |
93 lemma [transfer_rule]: |
94 "((=) ===> pcr_integer) int of_nat" |
94 "((=) ===> pcr_integer) int of_nat" |
95 by (rule transfer_rule_of_nat) transfer_prover+ |
95 by (rule transfer_rule_of_nat) transfer_prover+ |
96 |
96 |
106 "((=) ===> pcr_integer) numeral numeral" |
106 "((=) ===> pcr_integer) numeral numeral" |
107 by transfer_prover |
107 by transfer_prover |
108 |
108 |
109 lemma [transfer_rule]: |
109 lemma [transfer_rule]: |
110 "((=) ===> (=) ===> pcr_integer) Num.sub Num.sub" |
110 "((=) ===> (=) ===> pcr_integer) Num.sub Num.sub" |
111 by (unfold Num.sub_def [abs_def]) transfer_prover |
111 by (unfold Num.sub_def) transfer_prover |
112 |
112 |
113 lemma [transfer_rule]: |
113 lemma [transfer_rule]: |
114 "(pcr_integer ===> (=) ===> pcr_integer) (^) (^)" |
114 "(pcr_integer ===> (=) ===> pcr_integer) (^) (^)" |
115 by (unfold power_def [abs_def]) transfer_prover |
115 by (unfold power_def) transfer_prover |
116 |
116 |
117 end |
117 end |
118 |
118 |
119 lemma int_of_integer_of_nat [simp]: |
119 lemma int_of_integer_of_nat [simp]: |
120 "int_of_integer (of_nat n) = of_nat n" |
120 "int_of_integer (of_nat n) = of_nat n" |
216 instance |
216 instance |
217 by standard (transfer, simp add: algebra_simps equal less_le_not_le [symmetric] mult_strict_right_mono linear)+ |
217 by standard (transfer, simp add: algebra_simps equal less_le_not_le [symmetric] mult_strict_right_mono linear)+ |
218 |
218 |
219 end |
219 end |
220 |
220 |
221 lemma [transfer_rule]: |
221 context |
222 "rel_fun pcr_integer (rel_fun pcr_integer pcr_integer) (min :: _ \<Rightarrow> _ \<Rightarrow> int) (min :: _ \<Rightarrow> _ \<Rightarrow> integer)" |
222 includes lifting_syntax |
223 by (unfold min_def [abs_def]) transfer_prover |
223 begin |
224 |
224 |
225 lemma [transfer_rule]: |
225 lemma [transfer_rule]: |
226 "rel_fun pcr_integer (rel_fun pcr_integer pcr_integer) (max :: _ \<Rightarrow> _ \<Rightarrow> int) (max :: _ \<Rightarrow> _ \<Rightarrow> integer)" |
226 \<open>(pcr_integer ===> pcr_integer ===> pcr_integer) min min\<close> |
227 by (unfold max_def [abs_def]) transfer_prover |
227 by (unfold min_def) transfer_prover |
|
228 |
|
229 lemma [transfer_rule]: |
|
230 \<open>(pcr_integer ===> pcr_integer ===> pcr_integer) max max\<close> |
|
231 by (unfold max_def) transfer_prover |
|
232 |
|
233 end |
228 |
234 |
229 lemma int_of_integer_min [simp]: |
235 lemma int_of_integer_min [simp]: |
230 "int_of_integer (min k l) = min (int_of_integer k) (int_of_integer l)" |
236 "int_of_integer (min k l) = min (int_of_integer k) (int_of_integer l)" |
231 by transfer rule |
237 by transfer rule |
232 |
238 |
302 exp_div_exp_eq div_exp_eq mod_exp_eq mult_exp_mod_exp_eq div_exp_mod_exp_eq |
308 exp_div_exp_eq div_exp_eq mod_exp_eq mult_exp_mod_exp_eq div_exp_mod_exp_eq |
303 even_mask_div_iff even_mult_exp_div_exp_iff)+ |
309 even_mask_div_iff even_mult_exp_div_exp_iff)+ |
304 |
310 |
305 end |
311 end |
306 |
312 |
307 lemma [transfer_rule]: |
313 context |
308 "rel_fun (=) (rel_fun pcr_integer pcr_integer) (take_bit :: _ \<Rightarrow> _ \<Rightarrow> int) (take_bit :: _ \<Rightarrow> _ \<Rightarrow> integer)" |
314 includes lifting_syntax |
309 by (unfold take_bit_eq_mod [abs_def]) transfer_prover |
315 begin |
|
316 |
|
317 lemma [transfer_rule]: |
|
318 \<open>(pcr_integer ===> (=) ===> (\<longleftrightarrow>)) bit bit\<close> |
|
319 by (unfold bit_def) transfer_prover |
|
320 |
|
321 lemma [transfer_rule]: |
|
322 \<open>((=) ===> pcr_integer ===> pcr_integer) take_bit take_bit\<close> |
|
323 by (unfold take_bit_eq_mod) transfer_prover |
|
324 |
|
325 end |
310 |
326 |
311 instance integer :: unique_euclidean_semiring_with_bit_shifts .. |
327 instance integer :: unique_euclidean_semiring_with_bit_shifts .. |
312 |
328 |
313 lemma [code]: |
329 lemma [code]: |
314 \<open>push_bit n k = k * 2 ^ n\<close> |
330 \<open>push_bit n k = k * 2 ^ n\<close> |
370 |
386 |
371 definition Pos :: "num \<Rightarrow> integer" |
387 definition Pos :: "num \<Rightarrow> integer" |
372 where |
388 where |
373 [simp, code_post]: "Pos = numeral" |
389 [simp, code_post]: "Pos = numeral" |
374 |
390 |
375 lemma [transfer_rule]: |
391 context |
376 "rel_fun HOL.eq pcr_integer numeral Pos" |
392 includes lifting_syntax |
|
393 begin |
|
394 |
|
395 lemma [transfer_rule]: |
|
396 \<open>((=) ===> pcr_integer) numeral Pos\<close> |
377 by simp transfer_prover |
397 by simp transfer_prover |
|
398 |
|
399 end |
378 |
400 |
379 lemma Pos_fold [code_unfold]: |
401 lemma Pos_fold [code_unfold]: |
380 "numeral Num.One = Pos Num.One" |
402 "numeral Num.One = Pos Num.One" |
381 "numeral (Num.Bit0 k) = Pos (Num.Bit0 k)" |
403 "numeral (Num.Bit0 k) = Pos (Num.Bit0 k)" |
382 "numeral (Num.Bit1 k) = Pos (Num.Bit1 k)" |
404 "numeral (Num.Bit1 k) = Pos (Num.Bit1 k)" |
384 |
406 |
385 definition Neg :: "num \<Rightarrow> integer" |
407 definition Neg :: "num \<Rightarrow> integer" |
386 where |
408 where |
387 [simp, code_abbrev]: "Neg n = - Pos n" |
409 [simp, code_abbrev]: "Neg n = - Pos n" |
388 |
410 |
389 lemma [transfer_rule]: |
411 context |
390 "rel_fun HOL.eq pcr_integer (\<lambda>n. - numeral n) Neg" |
412 includes lifting_syntax |
391 by (simp add: Neg_def [abs_def]) transfer_prover |
413 begin |
|
414 |
|
415 lemma [transfer_rule]: |
|
416 \<open>((=) ===> pcr_integer) (\<lambda>n. - numeral n) Neg\<close> |
|
417 by (unfold Neg_def) transfer_prover |
|
418 |
|
419 end |
392 |
420 |
393 code_datatype "0::integer" Pos Neg |
421 code_datatype "0::integer" Pos Neg |
394 |
422 |
395 |
423 |
396 text \<open>A further pair of constructors for generated computations\<close> |
424 text \<open>A further pair of constructors for generated computations\<close> |
851 |
879 |
852 end |
880 end |
853 |
881 |
854 instance natural :: Rings.dvd .. |
882 instance natural :: Rings.dvd .. |
855 |
883 |
856 lemma [transfer_rule]: |
884 context |
857 "rel_fun pcr_natural (rel_fun pcr_natural HOL.iff) Rings.dvd Rings.dvd" |
885 includes lifting_syntax |
858 unfolding dvd_def by transfer_prover |
886 begin |
859 |
887 |
860 lemma [transfer_rule]: |
888 lemma [transfer_rule]: |
861 "rel_fun (=) pcr_natural (of_bool :: bool \<Rightarrow> nat) (of_bool :: bool \<Rightarrow> natural)" |
889 \<open>(pcr_natural ===> pcr_natural ===> (\<longleftrightarrow>)) (dvd) (dvd)\<close> |
862 by (unfold of_bool_def [abs_def]) transfer_prover |
890 by (unfold dvd_def) transfer_prover |
863 |
891 |
864 lemma [transfer_rule]: |
892 lemma [transfer_rule]: |
865 "rel_fun HOL.eq pcr_natural (\<lambda>n::nat. n) (of_nat :: nat \<Rightarrow> natural)" |
893 \<open>((\<longleftrightarrow>) ===> pcr_natural) of_bool of_bool\<close> |
|
894 by (unfold of_bool_def) transfer_prover |
|
895 |
|
896 lemma [transfer_rule]: |
|
897 \<open>((=) ===> pcr_natural) (\<lambda>n. n) of_nat\<close> |
866 proof - |
898 proof - |
867 have "rel_fun HOL.eq pcr_natural (of_nat :: nat \<Rightarrow> nat) (of_nat :: nat \<Rightarrow> natural)" |
899 have "rel_fun HOL.eq pcr_natural (of_nat :: nat \<Rightarrow> nat) (of_nat :: nat \<Rightarrow> natural)" |
868 by (unfold of_nat_def [abs_def]) transfer_prover |
900 by (unfold of_nat_def) transfer_prover |
869 then show ?thesis by (simp add: id_def) |
901 then show ?thesis by (simp add: id_def) |
870 qed |
902 qed |
871 |
903 |
872 lemma [transfer_rule]: |
904 lemma [transfer_rule]: |
873 "rel_fun HOL.eq pcr_natural (numeral :: num \<Rightarrow> nat) (numeral :: num \<Rightarrow> natural)" |
905 \<open>((=) ===> pcr_natural) numeral numeral\<close> |
874 proof - |
906 proof - |
875 have "rel_fun HOL.eq pcr_natural (numeral :: num \<Rightarrow> nat) (\<lambda>n. of_nat (numeral n))" |
907 have \<open>((=) ===> pcr_natural) numeral (\<lambda>n. of_nat (numeral n))\<close> |
876 by transfer_prover |
908 by transfer_prover |
877 then show ?thesis by simp |
909 then show ?thesis by simp |
878 qed |
910 qed |
879 |
911 |
880 lemma [transfer_rule]: |
912 lemma [transfer_rule]: |
881 "rel_fun pcr_natural (rel_fun (=) pcr_natural) (power :: _ \<Rightarrow> _ \<Rightarrow> nat) (power :: _ \<Rightarrow> _ \<Rightarrow> natural)" |
913 \<open>(pcr_natural ===> (=) ===> pcr_natural) (^) (^)\<close> |
882 by (unfold power_def [abs_def]) transfer_prover |
914 by (unfold power_def) transfer_prover |
|
915 |
|
916 end |
883 |
917 |
884 lemma nat_of_natural_of_nat [simp]: |
918 lemma nat_of_natural_of_nat [simp]: |
885 "nat_of_natural (of_nat n) = n" |
919 "nat_of_natural (of_nat n) = n" |
886 by transfer rule |
920 by transfer rule |
887 |
921 |
919 instance proof |
953 instance proof |
920 qed (transfer, simp add: algebra_simps equal less_le_not_le [symmetric] linear)+ |
954 qed (transfer, simp add: algebra_simps equal less_le_not_le [symmetric] linear)+ |
921 |
955 |
922 end |
956 end |
923 |
957 |
924 lemma [transfer_rule]: |
958 context |
925 "rel_fun pcr_natural (rel_fun pcr_natural pcr_natural) (min :: _ \<Rightarrow> _ \<Rightarrow> nat) (min :: _ \<Rightarrow> _ \<Rightarrow> natural)" |
959 includes lifting_syntax |
926 by (unfold min_def [abs_def]) transfer_prover |
960 begin |
927 |
961 |
928 lemma [transfer_rule]: |
962 lemma [transfer_rule]: |
929 "rel_fun pcr_natural (rel_fun pcr_natural pcr_natural) (max :: _ \<Rightarrow> _ \<Rightarrow> nat) (max :: _ \<Rightarrow> _ \<Rightarrow> natural)" |
963 \<open>(pcr_natural ===> pcr_natural ===> pcr_natural) min min\<close> |
930 by (unfold max_def [abs_def]) transfer_prover |
964 by (unfold min_def) transfer_prover |
|
965 |
|
966 lemma [transfer_rule]: |
|
967 \<open>(pcr_natural ===> pcr_natural ===> pcr_natural) max max\<close> |
|
968 by (unfold max_def) transfer_prover |
|
969 |
|
970 end |
931 |
971 |
932 lemma nat_of_natural_min [simp]: |
972 lemma nat_of_natural_min [simp]: |
933 "nat_of_natural (min k l) = min (nat_of_natural k) (nat_of_natural l)" |
973 "nat_of_natural (min k l) = min (nat_of_natural k) (nat_of_natural l)" |
934 by transfer rule |
974 by transfer rule |
935 |
975 |
999 exp_div_exp_eq div_exp_eq mod_exp_eq mult_exp_mod_exp_eq div_exp_mod_exp_eq |
1039 exp_div_exp_eq div_exp_eq mod_exp_eq mult_exp_mod_exp_eq div_exp_mod_exp_eq |
1000 even_mask_div_iff even_mult_exp_div_exp_iff)+ |
1040 even_mask_div_iff even_mult_exp_div_exp_iff)+ |
1001 |
1041 |
1002 end |
1042 end |
1003 |
1043 |
1004 lemma [transfer_rule]: |
1044 context |
1005 "rel_fun (=) (rel_fun pcr_natural pcr_natural) (take_bit :: _ \<Rightarrow> _ \<Rightarrow> nat) (take_bit :: _ \<Rightarrow> _ \<Rightarrow> natural)" |
1045 includes lifting_syntax |
1006 by (unfold take_bit_eq_mod [abs_def]) transfer_prover |
1046 begin |
|
1047 |
|
1048 lemma [transfer_rule]: |
|
1049 \<open>(pcr_natural ===> (=) ===> (\<longleftrightarrow>)) bit bit\<close> |
|
1050 by (unfold bit_def) transfer_prover |
|
1051 |
|
1052 lemma [transfer_rule]: |
|
1053 \<open>((=) ===> pcr_natural ===> pcr_natural) take_bit take_bit\<close> |
|
1054 by (unfold take_bit_eq_mod) transfer_prover |
|
1055 |
|
1056 end |
1007 |
1057 |
1008 instance natural :: unique_euclidean_semiring_with_bit_shifts .. |
1058 instance natural :: unique_euclidean_semiring_with_bit_shifts .. |
1009 |
1059 |
1010 lemma [code]: |
1060 lemma [code]: |
1011 \<open>push_bit n m = m * 2 ^ n\<close> |
1061 \<open>push_bit n m = m * 2 ^ n\<close> |