819 definition Rats :: "'a set" ("\<rat>") |
819 definition Rats :: "'a set" ("\<rat>") |
820 where "\<rat> = range of_rat" |
820 where "\<rat> = range of_rat" |
821 |
821 |
822 end |
822 end |
823 |
823 |
824 lemma Rats_of_rat [simp]: "of_rat r \<in> \<rat>" |
|
825 by (simp add: Rats_def) |
|
826 |
|
827 lemma Rats_of_int [simp]: "of_int z \<in> \<rat>" |
|
828 by (subst of_rat_of_int_eq [symmetric]) (rule Rats_of_rat) |
|
829 |
|
830 lemma Ints_subset_Rats: "\<int> \<subseteq> \<rat>" |
|
831 using Ints_cases Rats_of_int by blast |
|
832 |
|
833 lemma Rats_of_nat [simp]: "of_nat n \<in> \<rat>" |
|
834 by (subst of_rat_of_nat_eq [symmetric]) (rule Rats_of_rat) |
|
835 |
|
836 lemma Nats_subset_Rats: "\<nat> \<subseteq> \<rat>" |
|
837 using Ints_subset_Rats Nats_subset_Ints by blast |
|
838 |
|
839 lemma Rats_number_of [simp]: "numeral w \<in> \<rat>" |
|
840 by (subst of_rat_numeral_eq [symmetric]) (rule Rats_of_rat) |
|
841 |
|
842 lemma Rats_0 [simp]: "0 \<in> \<rat>" |
|
843 unfolding Rats_def by (rule range_eqI) (rule of_rat_0 [symmetric]) |
|
844 |
|
845 lemma Rats_1 [simp]: "1 \<in> \<rat>" |
|
846 unfolding Rats_def by (rule range_eqI) (rule of_rat_1 [symmetric]) |
|
847 |
|
848 lemma Rats_add [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a + b \<in> \<rat>" |
|
849 apply (auto simp add: Rats_def) |
|
850 apply (rule range_eqI) |
|
851 apply (rule of_rat_add [symmetric]) |
|
852 done |
|
853 |
|
854 lemma Rats_minus [simp]: "a \<in> \<rat> \<Longrightarrow> - a \<in> \<rat>" |
|
855 apply (auto simp add: Rats_def) |
|
856 apply (rule range_eqI) |
|
857 apply (rule of_rat_minus [symmetric]) |
|
858 done |
|
859 |
|
860 lemma Rats_diff [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a - b \<in> \<rat>" |
|
861 apply (auto simp add: Rats_def) |
|
862 apply (rule range_eqI) |
|
863 apply (rule of_rat_diff [symmetric]) |
|
864 done |
|
865 |
|
866 lemma Rats_mult [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a * b \<in> \<rat>" |
|
867 apply (auto simp add: Rats_def) |
|
868 apply (rule range_eqI) |
|
869 apply (rule of_rat_mult [symmetric]) |
|
870 done |
|
871 |
|
872 lemma Rats_inverse [simp]: "a \<in> \<rat> \<Longrightarrow> inverse a \<in> \<rat>" |
|
873 for a :: "'a::field_char_0" |
|
874 apply (auto simp add: Rats_def) |
|
875 apply (rule range_eqI) |
|
876 apply (rule of_rat_inverse [symmetric]) |
|
877 done |
|
878 |
|
879 lemma Rats_divide [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a / b \<in> \<rat>" |
|
880 for a b :: "'a::field_char_0" |
|
881 apply (auto simp add: Rats_def) |
|
882 apply (rule range_eqI) |
|
883 apply (rule of_rat_divide [symmetric]) |
|
884 done |
|
885 |
|
886 lemma Rats_power [simp]: "a \<in> \<rat> \<Longrightarrow> a ^ n \<in> \<rat>" |
|
887 for a :: "'a::field_char_0" |
|
888 apply (auto simp add: Rats_def) |
|
889 apply (rule range_eqI) |
|
890 apply (rule of_rat_power [symmetric]) |
|
891 done |
|
892 |
|
893 lemma Rats_cases [cases set: Rats]: |
824 lemma Rats_cases [cases set: Rats]: |
894 assumes "q \<in> \<rat>" |
825 assumes "q \<in> \<rat>" |
895 obtains (of_rat) r where "q = of_rat r" |
826 obtains (of_rat) r where "q = of_rat r" |
896 proof - |
827 proof - |
897 from \<open>q \<in> \<rat>\<close> have "q \<in> range of_rat" |
828 from \<open>q \<in> \<rat>\<close> have "q \<in> range of_rat" |
898 by (simp only: Rats_def) |
829 by (simp only: Rats_def) |
899 then obtain r where "q = of_rat r" .. |
830 then obtain r where "q = of_rat r" .. |
900 then show thesis .. |
831 then show thesis .. |
901 qed |
832 qed |
|
833 |
|
834 lemma Rats_of_rat [simp]: "of_rat r \<in> \<rat>" |
|
835 by (simp add: Rats_def) |
|
836 |
|
837 lemma Rats_of_int [simp]: "of_int z \<in> \<rat>" |
|
838 by (subst of_rat_of_int_eq [symmetric]) (rule Rats_of_rat) |
|
839 |
|
840 lemma Ints_subset_Rats: "\<int> \<subseteq> \<rat>" |
|
841 using Ints_cases Rats_of_int by blast |
|
842 |
|
843 lemma Rats_of_nat [simp]: "of_nat n \<in> \<rat>" |
|
844 by (subst of_rat_of_nat_eq [symmetric]) (rule Rats_of_rat) |
|
845 |
|
846 lemma Nats_subset_Rats: "\<nat> \<subseteq> \<rat>" |
|
847 using Ints_subset_Rats Nats_subset_Ints by blast |
|
848 |
|
849 lemma Rats_number_of [simp]: "numeral w \<in> \<rat>" |
|
850 by (subst of_rat_numeral_eq [symmetric]) (rule Rats_of_rat) |
|
851 |
|
852 lemma Rats_0 [simp]: "0 \<in> \<rat>" |
|
853 unfolding Rats_def by (rule range_eqI) (rule of_rat_0 [symmetric]) |
|
854 |
|
855 lemma Rats_1 [simp]: "1 \<in> \<rat>" |
|
856 unfolding Rats_def by (rule range_eqI) (rule of_rat_1 [symmetric]) |
|
857 |
|
858 lemma Rats_add [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a + b \<in> \<rat>" |
|
859 apply (auto simp add: Rats_def) |
|
860 apply (rule range_eqI) |
|
861 apply (rule of_rat_add [symmetric]) |
|
862 done |
|
863 |
|
864 lemma Rats_minus_iff [simp]: "- a \<in> \<rat> \<longleftrightarrow> a \<in> \<rat>" |
|
865 by (metis Rats_cases Rats_of_rat add.inverse_inverse of_rat_minus) |
|
866 |
|
867 lemma Rats_diff [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a - b \<in> \<rat>" |
|
868 apply (auto simp add: Rats_def) |
|
869 apply (rule range_eqI) |
|
870 apply (rule of_rat_diff [symmetric]) |
|
871 done |
|
872 |
|
873 lemma Rats_mult [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a * b \<in> \<rat>" |
|
874 apply (auto simp add: Rats_def) |
|
875 apply (rule range_eqI) |
|
876 apply (rule of_rat_mult [symmetric]) |
|
877 done |
|
878 |
|
879 lemma Rats_inverse [simp]: "a \<in> \<rat> \<Longrightarrow> inverse a \<in> \<rat>" |
|
880 for a :: "'a::field_char_0" |
|
881 apply (auto simp add: Rats_def) |
|
882 apply (rule range_eqI) |
|
883 apply (rule of_rat_inverse [symmetric]) |
|
884 done |
|
885 |
|
886 lemma Rats_divide [simp]: "a \<in> \<rat> \<Longrightarrow> b \<in> \<rat> \<Longrightarrow> a / b \<in> \<rat>" |
|
887 for a b :: "'a::field_char_0" |
|
888 apply (auto simp add: Rats_def) |
|
889 apply (rule range_eqI) |
|
890 apply (rule of_rat_divide [symmetric]) |
|
891 done |
|
892 |
|
893 lemma Rats_power [simp]: "a \<in> \<rat> \<Longrightarrow> a ^ n \<in> \<rat>" |
|
894 for a :: "'a::field_char_0" |
|
895 apply (auto simp add: Rats_def) |
|
896 apply (rule range_eqI) |
|
897 apply (rule of_rat_power [symmetric]) |
|
898 done |
902 |
899 |
903 lemma Rats_induct [case_names of_rat, induct set: Rats]: "q \<in> \<rat> \<Longrightarrow> (\<And>r. P (of_rat r)) \<Longrightarrow> P q" |
900 lemma Rats_induct [case_names of_rat, induct set: Rats]: "q \<in> \<rat> \<Longrightarrow> (\<And>r. P (of_rat r)) \<Longrightarrow> P q" |
904 by (rule Rats_cases) auto |
901 by (rule Rats_cases) auto |
905 |
902 |
906 lemma Rats_infinite: "\<not> finite \<rat>" |
903 lemma Rats_infinite: "\<not> finite \<rat>" |