330 lemma cringE: |
330 lemma cringE: |
331 fixes R (structure) |
331 fixes R (structure) |
332 assumes "cring R" |
332 assumes "cring R" |
333 shows "comm_monoid R" |
333 shows "comm_monoid R" |
334 and "\<And>x y z. \<lbrakk> x \<in> carrier R; y \<in> carrier R; z \<in> carrier R \<rbrakk> \<Longrightarrow> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z" |
334 and "\<And>x y z. \<lbrakk> x \<in> carrier R; y \<in> carrier R; z \<in> carrier R \<rbrakk> \<Longrightarrow> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z" |
335 using assms cring_def apply auto by (simp add: assms cring.axioms(1) ringE(3)) |
335 using assms cring_def by auto (simp add: assms cring.axioms(1) ringE(3)) |
336 |
336 |
337 lemma (in cring) is_cring: |
337 lemma (in cring) is_cring: |
338 "cring R" by (rule cring_axioms) |
338 "cring R" by (rule cring_axioms) |
339 |
339 |
340 lemma (in ring) minus_zero [simp]: "\<ominus> \<zero> = \<zero>" |
340 lemma (in ring) minus_zero [simp]: "\<ominus> \<zero> = \<zero>" |
685 qed (rule field_Units) |
682 qed (rule field_Units) |
686 |
683 |
687 text \<open>Another variant to show that something is a field\<close> |
684 text \<open>Another variant to show that something is a field\<close> |
688 lemma (in cring) cring_fieldI2: |
685 lemma (in cring) cring_fieldI2: |
689 assumes notzero: "\<zero> \<noteq> \<one>" |
686 assumes notzero: "\<zero> \<noteq> \<one>" |
690 and invex: "\<And>a. \<lbrakk>a \<in> carrier R; a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> \<exists>b\<in>carrier R. a \<otimes> b = \<one>" |
687 and invex: "\<And>a. \<lbrakk>a \<in> carrier R; a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> \<exists>b\<in>carrier R. a \<otimes> b = \<one>" |
691 shows "field R" |
688 shows "field R" |
692 apply (rule cring_fieldI, simp add: Units_def) |
689 proof - |
693 apply (rule, clarsimp) |
690 have *: "carrier R - {\<zero>} \<subseteq> {y \<in> carrier R. \<exists>x\<in>carrier R. x \<otimes> y = \<one> \<and> y \<otimes> x = \<one>}" |
694 apply (simp add: notzero) |
691 proof (clarsimp) |
695 proof (clarsimp) |
692 fix x |
696 fix x |
693 assume xcarr: "x \<in> carrier R" and "x \<noteq> \<zero>" |
697 assume xcarr: "x \<in> carrier R" |
694 obtain y where ycarr: "y \<in> carrier R" and xy: "x \<otimes> y = \<one>" |
698 and "x \<noteq> \<zero>" |
695 using \<open>x \<noteq> \<zero>\<close> invex xcarr by blast |
699 then have "\<exists>y\<in>carrier R. x \<otimes> y = \<one>" by (rule invex) |
696 with ycarr and xy show "\<exists>y\<in>carrier R. y \<otimes> x = \<one> \<and> x \<otimes> y = \<one>" |
700 then obtain y where ycarr: "y \<in> carrier R" and xy: "x \<otimes> y = \<one>" by fast |
697 using m_comm xcarr by fastforce |
701 from xy xcarr ycarr have "y \<otimes> x = \<one>" by (simp add: m_comm) |
698 qed |
702 with ycarr and xy show "\<exists>y\<in>carrier R. y \<otimes> x = \<one> \<and> x \<otimes> y = \<one>" by fast |
699 show ?thesis |
|
700 apply (rule cring_fieldI, simp add: Units_def) |
|
701 using * |
|
702 using group_l_invI notzero set_diff_eq by auto |
703 qed |
703 qed |
704 |
704 |
705 |
705 |
706 subsection \<open>Morphisms\<close> |
706 subsection \<open>Morphisms\<close> |
707 |
707 |
857 "finite (Units R) \<Longrightarrow> a \<in> Units R \<Longrightarrow> a [^] card(Units R) = \<one>" |
857 "finite (Units R) \<Longrightarrow> a \<in> Units R \<Longrightarrow> a [^] card(Units R) = \<one>" |
858 by (metis comm_group.power_order_eq_one units_comm_group units_of_carrier units_of_one units_of_pow) |
858 by (metis comm_group.power_order_eq_one units_comm_group units_of_carrier units_of_one units_of_pow) |
859 |
859 |
860 subsection\<open>Jeremy Avigad's @{text"More_Ring"} material\<close> |
860 subsection\<open>Jeremy Avigad's @{text"More_Ring"} material\<close> |
861 |
861 |
862 lemma (in cring) field_intro2: "\<zero>\<^bsub>R\<^esub> \<noteq> \<one>\<^bsub>R\<^esub> \<Longrightarrow> \<forall>x \<in> carrier R - {\<zero>\<^bsub>R\<^esub>}. x \<in> Units R \<Longrightarrow> field R" |
862 lemma (in cring) field_intro2: |
863 apply (unfold_locales) |
863 assumes "\<zero>\<^bsub>R\<^esub> \<noteq> \<one>\<^bsub>R\<^esub>" and un: "\<And>x. x \<in> carrier R - {\<zero>\<^bsub>R\<^esub>} \<Longrightarrow> x \<in> Units R" |
864 apply (use cring_axioms in auto) |
864 shows "field R" |
865 apply (rule trans) |
865 proof unfold_locales |
866 apply (subgoal_tac "a = (a \<otimes> b) \<otimes> inv b") |
866 show "\<one> \<noteq> \<zero>" using assms by auto |
867 apply assumption |
867 show "\<lbrakk>a \<otimes> b = \<zero>; a \<in> carrier R; |
868 apply (subst m_assoc) |
868 b \<in> carrier R\<rbrakk> |
869 apply auto |
869 \<Longrightarrow> a = \<zero> \<or> b = \<zero>" for a b |
870 apply (unfold Units_def) |
870 by (metis un Units_l_cancel insert_Diff_single insert_iff r_null zero_closed) |
871 apply auto |
871 qed (use assms in \<open>auto simp: Units_def\<close>) |
872 done |
|
873 |
872 |
874 lemma (in monoid) inv_char: |
873 lemma (in monoid) inv_char: |
875 "x \<in> carrier G \<Longrightarrow> y \<in> carrier G \<Longrightarrow> x \<otimes> y = \<one> \<Longrightarrow> y \<otimes> x = \<one> \<Longrightarrow> inv x = y" |
874 assumes "x \<in> carrier G" "y \<in> carrier G" "x \<otimes> y = \<one>" "y \<otimes> x = \<one>" |
876 apply (subgoal_tac "x \<in> Units G") |
875 shows "inv x = y" |
877 apply (subgoal_tac "y = inv x \<otimes> \<one>") |
876 using assms inv_unique' by auto |
878 apply simp |
|
879 apply (erule subst) |
|
880 apply (subst m_assoc [symmetric]) |
|
881 apply auto |
|
882 apply (unfold Units_def) |
|
883 apply auto |
|
884 done |
|
885 |
877 |
886 lemma (in comm_monoid) comm_inv_char: "x \<in> carrier G \<Longrightarrow> y \<in> carrier G \<Longrightarrow> x \<otimes> y = \<one> \<Longrightarrow> inv x = y" |
878 lemma (in comm_monoid) comm_inv_char: "x \<in> carrier G \<Longrightarrow> y \<in> carrier G \<Longrightarrow> x \<otimes> y = \<one> \<Longrightarrow> inv x = y" |
887 by (simp add: inv_char m_comm) |
879 by (simp add: inv_char m_comm) |
888 |
880 |
889 lemma (in ring) inv_neg_one [simp]: "inv (\<ominus> \<one>) = \<ominus> \<one>" |
881 lemma (in ring) inv_neg_one [simp]: "inv (\<ominus> \<one>) = \<ominus> \<one>" |
890 apply (rule inv_char) |
882 by (simp add: inv_char local.ring_axioms ring.r_minus) |
891 apply (auto simp add: l_minus r_minus) |
|
892 done |
|
893 |
883 |
894 lemma (in monoid) inv_eq_imp_eq: "x \<in> Units G \<Longrightarrow> y \<in> Units G \<Longrightarrow> inv x = inv y \<Longrightarrow> x = y" |
884 lemma (in monoid) inv_eq_imp_eq: "x \<in> Units G \<Longrightarrow> y \<in> Units G \<Longrightarrow> inv x = inv y \<Longrightarrow> x = y" |
895 apply (subgoal_tac "inv (inv x) = inv (inv y)") |
885 by (metis Units_inv_inv) |
896 apply (subst (asm) Units_inv_inv)+ |
|
897 apply auto |
|
898 done |
|
899 |
886 |
900 lemma (in ring) Units_minus_one_closed [intro]: "\<ominus> \<one> \<in> Units R" |
887 lemma (in ring) Units_minus_one_closed [intro]: "\<ominus> \<one> \<in> Units R" |
901 apply (unfold Units_def) |
888 by (simp add: Units_def) (metis add.l_inv_ex local.minus_minus minus_equality one_closed r_minus r_one) |
902 apply auto |
|
903 apply (rule_tac x = "\<ominus> \<one>" in bexI) |
|
904 apply auto |
|
905 apply (simp add: l_minus r_minus) |
|
906 done |
|
907 |
889 |
908 lemma (in ring) inv_eq_neg_one_eq: "x \<in> Units R \<Longrightarrow> inv x = \<ominus> \<one> \<longleftrightarrow> x = \<ominus> \<one>" |
890 lemma (in ring) inv_eq_neg_one_eq: "x \<in> Units R \<Longrightarrow> inv x = \<ominus> \<one> \<longleftrightarrow> x = \<ominus> \<one>" |
909 apply auto |
891 by (metis Units_inv_inv inv_neg_one) |
910 apply (subst Units_inv_inv [symmetric]) |
|
911 apply auto |
|
912 done |
|
913 |
892 |
914 lemma (in monoid) inv_eq_one_eq: "x \<in> Units G \<Longrightarrow> inv x = \<one> \<longleftrightarrow> x = \<one>" |
893 lemma (in monoid) inv_eq_one_eq: "x \<in> Units G \<Longrightarrow> inv x = \<one> \<longleftrightarrow> x = \<one>" |
915 by (metis Units_inv_inv inv_one) |
894 by (metis Units_inv_inv inv_one) |
916 |
895 |
917 end |
896 end |