# Theory Generated_Fields

```(*  Title:      HOL/Algebra/Generated_Fields.thy
Author:     Martin Baillon
*)

theory Generated_Fields
imports Generated_Rings Subrings Multiplicative_Group
begin

inductive_set
generate_field :: "('a, 'b) ring_scheme β 'a set β 'a set"
for R and H where
one  : "π­βRβ β generate_field R H"
| incl : "h β H βΉ h β generate_field R H"
| a_inv: "h β generate_field R H βΉ ββRβ h β generate_field R H"
| m_inv: "β¦ h β generate_field R H; h β  π¬βRβ β§ βΉ invβRβ h β generate_field R H"
| eng_add : "β¦ h1 β generate_field R H; h2 β generate_field R H β§ βΉ h1 ββRβ h2 β generate_field R H"
| eng_mult: "β¦ h1 β generate_field R H; h2 β generate_field R H β§ βΉ h1 ββRβ h2 β generate_field R H"

subsectionβΉBasic Properties of Generated Rings - First PartβΊ

lemma (in field) generate_field_in_carrier:
assumes "H β carrier R"
shows "h β generate_field R H βΉ h β carrier R"
apply (induction rule: generate_field.induct)
using assms field_Units
by blast+

lemma (in field) generate_field_incl:
assumes "H β carrier R"
shows "generate_field R H β carrier R"
using generate_field_in_carrier[OF assms] by auto

lemma (in field) zero_in_generate: "π¬βRβ β generate_field R H"
using one a_inv generate_field.eng_add one_closed r_neg
by metis

lemma (in field) generate_field_is_subfield:
assumes "H β carrier R"
shows "subfield (generate_field R H) R"
proof (intro subfieldI', simp_all add: m_inv)
show "subring (generate_field R H) R"
by (auto intro: subringI[of "generate_field R H"]
qed

assumes "H β carrier R"
shows "subgroup (generate_field R H) (add_monoid R)"
using subring.axioms(1)[OF subfieldE(1)[OF generate_field_is_subfield[OF assms]]] .

lemma (in field) generate_field_is_field :
assumes "H β carrier R"
shows "field (R β¦ carrier := generate_field R H β¦)"
using subfield_iff generate_field_is_subfield assms by simp

lemma (in field) generate_field_min_subfield1:
assumes "H β carrier R"
and "subfield E R" "H β E"
shows "generate_field R H β E"
proof
fix h
assume h: "h β generate_field R H"
show "h β E"
using h and assms(3) and subfield_m_inv[OF assms(2)]
by (induct rule: generate_field.induct)
(auto simp add: subringE(3,5-7)[OF subfieldE(1)[OF assms(2)]])
qed

lemma (in field) generate_fieldI:
assumes "H β carrier R"
and "subfield E R" "H β E"
and "βK. β¦ subfield K R; H β K β§ βΉ E β K"
shows "E = generate_field R H"
proof
show "E β generate_field R H"
using assms generate_field_is_subfield generate_field.incl by (metis subset_iff)
show "generate_field R H β E"
using generate_field_min_subfield1[OF assms(1-3)] by simp
qed

lemma (in field) generate_fieldE:
assumes "H β carrier R" and "E = generate_field R H"
shows "subfield E R" and "H β E" and "βK. β¦ subfield K R; H β K β§ βΉ E β K"
proof -
show "subfield E R" using assms generate_field_is_subfield by simp
show "H β E" using assms(2) by (simp add: generate_field.incl subsetI)
show "βK. subfield K R  βΉ H β K βΉ E β K"
using assms generate_field_min_subfield1 by auto
qed

lemma (in field) generate_field_min_subfield2:
assumes "H β carrier R"
shows "generate_field R H = β{K. subfield K R β§ H β K}"
proof
have "subfield (generate_field R H) R β§ H β generate_field R H"
by (simp add: assms generate_fieldE(2) generate_field_is_subfield)
thus "β{K. subfield K R β§ H β K} β generate_field R H" by blast
next
have "βK. subfield K R β§ H β K βΉ generate_field R H β K"
thus "generate_field R H β β{K. subfield K R β§ H β K}" by blast
qed

lemma (in field) mono_generate_field:
assumes "I β J" and "J β carrier R"
shows "generate_field R I β generate_field R J"
proof-
have "I β generate_field R J "
using assms generate_fieldE(2) by blast
thus "generate_field R I β generate_field R J"
using generate_field_min_subfield1[of I "generate_field R J"] assms generate_field_is_subfield[OF assms(2)]
by blast
qed

lemma (in field) subfield_gen_incl :
assumes "subfield H R"
and  "subfield K R"
and "I β H"
and "I β K"
shows "generate_field (Rβ¦carrier := Kβ¦) I β generate_field (Rβ¦carrier := Hβ¦) I"
proof
{fix J assume J_def : "subfield J R" "I β J"
have "generate_field (R β¦ carrier := J β¦) I β J"
using field.mono_generate_field[of "(Rβ¦carrier := Jβ¦)" I J] subfield_iff(2)[OF J_def(1)]
field.generate_field_in_carrier[of "Rβ¦carrier := Jβ¦"]  field_axioms J_def
by auto}
note incl_HK = this
{fix x have "x β generate_field (Rβ¦carrier := Kβ¦) I βΉ x β generate_field (Rβ¦carrier := Hβ¦) I"
proof (induction  rule : generate_field.induct)
case one
have "π­βRβ¦carrier := Hβ¦β β π­βRβ¦carrier := Kβ¦β = π­βRβ¦carrier := Hβ¦β" by simp
moreover have "π­βRβ¦carrier := Hβ¦β β π­βRβ¦carrier := Kβ¦β = π­βRβ¦carrier := Kβ¦β" by simp
ultimately show ?case using assms generate_field.one by metis
next
case (incl h) thus ?case using generate_field.incl by force
next
case (a_inv h)
note hyp = this
have "a_inv (Rβ¦carrier := Kβ¦) h = a_inv R h"
using assms group.m_inv_consistent[of "add_monoid R" K] a_comm_group incl_HK[of K] hyp
subring.axioms(1)[OF subfieldE(1)[OF assms(2)]]
unfolding comm_group_def a_inv_def by auto
moreover have "a_inv (Rβ¦carrier := Hβ¦) h = a_inv R h"
using assms group.m_inv_consistent[of "add_monoid R" H] a_comm_group incl_HK[of H] hyp
subring.axioms(1)[OF subfieldE(1)[OF assms(1)]]
unfolding  comm_group_def a_inv_def by auto
ultimately show ?case using generate_field.a_inv a_inv.IH by fastforce
next
case (m_inv h)
note hyp = this
have h_K : "h β (K - {π¬})" using incl_HK[OF assms(2) assms(4)] hyp by auto
hence "m_inv (Rβ¦carrier := Kβ¦) h = m_inv R h"
using  field.m_inv_mult_of[OF subfield_iff(2)[OF assms(2)]]
group.m_inv_consistent[of "mult_of R" "K - {π¬}"] field_mult_group units_of_inv
subgroup_mult_of subfieldE[OF assms(2)] unfolding mult_of_def apply simp
by (metis h_K mult_of_def mult_of_is_Units subgroup.mem_carrier units_of_carrier assms(2))
moreover have h_H : "h β (H - {π¬})" using incl_HK[OF assms(1) assms(3)] hyp by auto
hence "m_inv (Rβ¦carrier := Hβ¦) h = m_inv R h"
using  field.m_inv_mult_of[OF subfield_iff(2)[OF assms(1)]]
group.m_inv_consistent[of "mult_of R" "H - {π¬}"] field_mult_group
subgroup_mult_of[OF assms(1)]  unfolding mult_of_def apply simp
by (metis h_H field_Units m_inv_mult_of mult_of_is_Units subgroup.mem_carrier units_of_def)
ultimately show ?case using generate_field.m_inv m_inv.IH h_H by fastforce
next
thus ?case using incl_HK assms generate_field.eng_add by force
next
case (eng_mult h1 h2)
thus ?case using generate_field.eng_mult by force
qed}
thus "βx. x β generate_field (Rβ¦carrier := Kβ¦) I βΉ x β generate_field (Rβ¦carrier := Hβ¦) I"
by auto
qed

lemma (in field) subfield_gen_equality:
assumes "subfield H R" "K β H"
shows "generate_field R K = generate_field (R β¦ carrier := H β¦) K"
using subfield_gen_incl[OF assms(1) carrier_is_subfield assms(2)] assms subringE(1)
subfield_gen_incl[OF carrier_is_subfield assms(1) _ assms(2)] subfieldE(1)[OF assms(1)]
by force

end
```