diff -r ff61cbfb3f2d -r c183a6a69f2d src/HOL/Algebra/Ring.thy --- a/src/HOL/Algebra/Ring.thy Tue Jun 12 16:09:12 2018 +0100 +++ b/src/HOL/Algebra/Ring.thy Thu Jun 14 14:23:38 2018 +0100 @@ -25,10 +25,9 @@ a_inv :: "[('a, 'm) ring_scheme, 'a ] \ 'a" ("\\ _" [81] 80) where "a_inv R = m_inv (add_monoid R)" - definition a_minus :: "[('a, 'm) ring_scheme, 'a, 'a] => 'a" ("(_ \\ _)" [65,66] 65) - where "\ x \ carrier R; y \ carrier R \ \ x \\<^bsub>R\<^esub> y = x \\<^bsub>R\<^esub> (\\<^bsub>R\<^esub> y)" + where "x \\<^bsub>R\<^esub> y = x \\<^bsub>R\<^esub> (\\<^bsub>R\<^esub> y)" definition add_pow :: "[_, ('b :: semiring_1), 'a] \ 'a" ("[_] \\ _" [81, 81] 80) @@ -212,7 +211,6 @@ lemmas l_neg = add.l_inv [simp del] lemmas r_neg = add.r_inv [simp del] -lemmas minus_zero = add.inv_one lemmas minus_minus = add.inv_inv lemmas a_inv_inj = add.inv_inj lemmas minus_equality = add.inv_equality @@ -344,6 +342,8 @@ lemma (in cring) is_cring: "cring R" by (rule cring_axioms) +lemma (in ring) minus_zero [simp]: "\ \ = \" + by (simp add: a_inv_def) subsubsection \Normaliser for Rings\ @@ -416,9 +416,8 @@ end -lemma (in abelian_group) minus_eq: - "\ x \ carrier G; y \ carrier G \ \ x \ y = x \ (\ y)" - by (simp only: a_minus_def) +lemma (in abelian_group) minus_eq: "x \ y = x \ (\ y)" + by (rule a_minus_def) text \Setup algebra method: compute distributive normal form in locale contexts\ @@ -602,7 +601,6 @@ using add_pow_int_lt[of k R b] add_pow_int_lt[of k R "a \ b"] add_pow_rdistr[OF assms, of "nat (- k)"] assms r_minus by auto qed -(* ************************************************************************** *) subsection \Integral Domains\ @@ -631,7 +629,7 @@ with R have "a \ (b \ c) = \" by algebra with R have "a = \ \ (b \ c) = \" by (simp add: integral_iff) with prem and R have "b \ c = \" by auto - with R have "b = b \ (b \ c)" by algebra + with R have "b = b \ (b \ c)" by algebra also from R have "b \ (b \ c) = c" by algebra finally show "b = c" . next @@ -805,4 +803,111 @@ "\ f \ ring_hom R S; g \ ring_hom S T \ \ g \ f \ ring_hom R T" by (rule ring_hom_memI) (auto simp add: ring_hom_closed ring_hom_mult ring_hom_add ring_hom_one) +subsection\Jeremy Avigad's @{text"More_Finite_Product"} material\ + +(* need better simplification rules for rings *) +(* the next one holds more generally for abelian groups *) + +lemma (in cring) sum_zero_eq_neg: "x \ carrier R \ y \ carrier R \ x \ y = \ \ x = \ y" + by (metis minus_equality) + +lemma (in domain) square_eq_one: + fixes x + assumes [simp]: "x \ carrier R" + and "x \ x = \" + shows "x = \ \ x = \\" +proof - + have "(x \ \) \ (x \ \ \) = x \ x \ \ \" + by (simp add: ring_simprules) + also from \x \ x = \\ have "\ = \" + by (simp add: ring_simprules) + finally have "(x \ \) \ (x \ \ \) = \" . + then have "(x \ \) = \ \ (x \ \ \) = \" + by (intro integral) auto + then show ?thesis + by (metis add.inv_closed add.inv_solve_right assms(1) l_zero one_closed zero_closed) +qed + +lemma (in domain) inv_eq_self: "x \ Units R \ x = inv x \ x = \ \ x = \\" + by (metis Units_closed Units_l_inv square_eq_one) + + +text \ + The following translates theorems about groups to the facts about + the units of a ring. (The list should be expanded as more things are + needed.) +\ + +lemma (in ring) finite_ring_finite_units [intro]: "finite (carrier R) \ finite (Units R)" + by (rule finite_subset) auto + +lemma (in monoid) units_of_pow: + fixes n :: nat + shows "x \ Units G \ x [^]\<^bsub>units_of G\<^esub> n = x [^]\<^bsub>G\<^esub> n" + apply (induct n) + apply (auto simp add: units_group group.is_monoid + monoid.nat_pow_0 monoid.nat_pow_Suc units_of_one units_of_mult) + done + +lemma (in cring) units_power_order_eq_one: + "finite (Units R) \ a \ Units R \ a [^] card(Units R) = \" + by (metis comm_group.power_order_eq_one units_comm_group units_of_carrier units_of_one units_of_pow) + +subsection\Jeremy Avigad's @{text"More_Ring"} material\ + +lemma (in cring) field_intro2: "\\<^bsub>R\<^esub> \ \\<^bsub>R\<^esub> \ \x \ carrier R - {\\<^bsub>R\<^esub>}. x \ Units R \ field R" + apply (unfold_locales) + apply (use cring_axioms in auto) + apply (rule trans) + apply (subgoal_tac "a = (a \ b) \ inv b") + apply assumption + apply (subst m_assoc) + apply auto + apply (unfold Units_def) + apply auto + done + +lemma (in monoid) inv_char: + "x \ carrier G \ y \ carrier G \ x \ y = \ \ y \ x = \ \ inv x = y" + apply (subgoal_tac "x \ Units G") + apply (subgoal_tac "y = inv x \ \") + apply simp + apply (erule subst) + apply (subst m_assoc [symmetric]) + apply auto + apply (unfold Units_def) + apply auto + done + +lemma (in comm_monoid) comm_inv_char: "x \ carrier G \ y \ carrier G \ x \ y = \ \ inv x = y" + by (simp add: inv_char m_comm) + +lemma (in ring) inv_neg_one [simp]: "inv (\ \) = \ \" + apply (rule inv_char) + apply (auto simp add: l_minus r_minus) + done + +lemma (in monoid) inv_eq_imp_eq: "x \ Units G \ y \ Units G \ inv x = inv y \ x = y" + apply (subgoal_tac "inv (inv x) = inv (inv y)") + apply (subst (asm) Units_inv_inv)+ + apply auto + done + +lemma (in ring) Units_minus_one_closed [intro]: "\ \ \ Units R" + apply (unfold Units_def) + apply auto + apply (rule_tac x = "\ \" in bexI) + apply auto + apply (simp add: l_minus r_minus) + done + +lemma (in ring) inv_eq_neg_one_eq: "x \ Units R \ inv x = \ \ \ x = \ \" + apply auto + apply (subst Units_inv_inv [symmetric]) + apply auto + done + +lemma (in monoid) inv_eq_one_eq: "x \ Units G \ inv x = \ \ x = \" + by (metis Units_inv_inv inv_one) + end