Theory Multimonoid
section ‹Multimonoids›
theory Multimonoid
imports Catoid
begin
context multimagma
begin
subsection ‹Unital multimagmas›
text ‹This component presents an alternative approach to catoids, as multisemigroups with many units.
This is more akin to the formalisation of single-set categories in Chapter I of Mac Lane's book, but
in fact this approach to axiomatising categories goes back to the middle of the twentieth century.›
text ‹Units can already be defined in multimagmas.›
definition "munitl e = ((∃x. x ∈ e ⊙ x) ∧ (∀x y. y ∈ e ⊙ x ⟶ y = x))"
definition "munitr e = ((∃x. x ∈ x ⊙ e) ∧ (∀x y. y ∈ x ⊙ e ⟶ y = x))"
abbreviation "munit e ≡ (munitl e ∨ munitr e)"
end
text ‹A multimagma is unital if every element has a left and a right unit.›
class unital_multimagma_var = multimagma +
assumes munitl_ex: "∀x.∃e. munitl e ∧ Δ e x"
assumes munitr_ex: "∀x.∃e. munitr e ∧ Δ x e"
begin
lemma munitl_ex_var: "∀x.∃e. munitl e ∧ x ∈ e ⊙ x"
by (metis equals0I local.munitl_def local.munitl_ex)
lemma unitl: "⋃{e ⊙ x |e. munitl e} = {x}"
apply safe
apply (simp add: multimagma.munitl_def)
by (simp, metis munitl_ex_var)
lemma munitr_ex_var: "∀x.∃e. munitr e ∧ x ∈ x ⊙ e"
by (metis equals0I local.munitr_def local.munitr_ex)
lemma unitr: "⋃{x ⊙ e |e. munitr e} = {x}"
apply safe
apply (simp add: multimagma.munitr_def)
by (simp, metis munitr_ex_var)
end
text ‹Here is an alternative definition.›
class unital_multimagma = multimagma +
fixes E :: "'a set"
assumes El: "⋃{e ⊙ x |e. e ∈ E} = {x}"
and Er: "⋃{x ⊙ e |e. e ∈ E} = {x}"
begin
lemma E1: "∀e ∈ E. (∀x y. y ∈ e ⊙ x ⟶ y = x)"
using local.El by fastforce
lemma E2: "∀e ∈ E. (∀x y. y ∈ x ⊙ e ⟶ y = x)"
using local.Er by fastforce
lemma El11: "∀x.∃e ∈ E. x ∈ e ⊙ x"
using local.El by fastforce
lemma El12: "∀x.∃e ∈ E. e ⊙ x = {x}"
using E1 El11 by fastforce
lemma Er11: "∀x.∃e ∈ E. x ∈ x ⊙ e"
using local.Er by fastforce
lemma Er12: "∀x.∃e ∈ E. x ⊙ e = {x}"
using Er Er11 by fastforce
text ‹Units are "orthogonal" idempotents.›
lemma unit_id: "∀e ∈ E. e ∈ e ⊙ e"
using E1 local.Er by fastforce
lemma unit_id_eq: "∀e ∈ E. e ⊙ e = {e}"
by (simp add: E1 equalityI subsetI unit_id)
lemma unit_comp:
assumes "e⇩1 ∈ E"
and "e⇩2 ∈ E"
and "Δ e⇩1 e⇩2"
shows "e⇩1 = e⇩2"
proof-
obtain x where a: "x ∈ e⇩1 ⊙ e⇩2"
using assms(3) by auto
hence b: "x = e⇩1"
using E2 assms(2) by blast
hence "x = e⇩2"
using E1 a assms(1) by blast
thus "e⇩1 = e⇩2"
by (simp add: b)
qed
lemma unit_comp_iff: "e⇩1 ∈ E ⟹ e⇩2 ∈ E ⟹ (Δ e⇩1 e⇩2 = (e⇩1 = e⇩2))"
using unit_comp unit_id by fastforce
lemma "∀e ∈ E.∃x. x ∈ e ⊙ x"
using unit_id by force
lemma "∀e ∈ E.∃x. x ∈ x ⊙ e"
using unit_id by force
sublocale unital_multimagma_var
apply unfold_locales
apply (metis E1 El12 empty_not_insert insertI1 local.munitl_def)
by (metis E2 Er12 empty_not_insert insertI1 local.munitr_def)
text ‹Now it is clear that the two definitions are equivalent.›
text ‹The next two lemmas show that the set of units is a left and right unit of composition at powerset level.›
lemma conv_unl: "E ⋆ X = X"
unfolding conv_def
apply safe
using E1 apply blast
using El12 by fastforce
lemma conv_unr: "X ⋆ E = X"
unfolding conv_def
apply safe
using E2 apply blast
using Er12 by fastforce
end
subsection ‹Multimonoids›
text ‹A multimonoid is a unital multisemigroup.›
class multimonoid = multisemigroup + unital_multimagma
begin
text ‹In a multimonoid, left and right units are unique for each element.›
lemma munits_uniquel: "∀x.∃!e. e ∈ E ∧ e ⊙ x = {x}"
proof-
{fix x
obtain e where a: "e ∈ E ∧ e ⊙ x = {x}"
using local.El12 by blast
{fix e'
assume b: "e' ∈ E ∧ e' ⊙ x = {x}"
hence "{e} ⋆ (e' ⊙ x) = {x}"
by (simp add: a multimagma.conv_atom)
hence "(e ⊙ e') ⋆ {x} = {x}"
by (simp add: local.assoc_var)
hence "Δ e e'"
using local.conv_exp2 by auto
hence "e = e'"
by (simp add: a b local.unit_comp_iff)}
hence "∃e ∈ E. e ⊙ x = {x} ∧ (∀e' ∈ E. e' ⊙ x = {x} ⟶ e = e)"
using a by blast}
thus ?thesis
by (metis emptyE local.assoc_exp local.unit_comp singletonI)
qed
lemma munits_uniquer: "∀x.∃!e. e ∈ E ∧ x ⊙ e = {x}"
apply safe
apply (meson local.Er12)
by (metis insertI1 local.E1 local.E2 local.assoc_var local.conv_exp2)
text ‹In a monoid, there is of course one single unit, and my definition of many units reduces to this one.›
lemma units_unique: "(∀x y. Δ x y) ⟹ ∃!e. e ∈ E"
apply safe
using local.El11 apply blast
using local.unit_comp_iff by presburger
lemma units_rm2l: "e⇩1 ∈ E ⟹ e⇩2 ∈ E ⟹ Δ e⇩1 x ⟹ Δ e⇩2 x ⟹ e⇩1 = e⇩2"
by (smt (verit, del_insts) ex_in_conv local.E1 local.assoc_exp local.unit_comp)
lemma units_rm2r: "e⇩1 ∈ E ⟹ e⇩2 ∈ E ⟹ Δ x e⇩1 ⟹ Δ x e⇩2 ⟹ e⇩1 = e⇩2"
by (metis (full_types) ex_in_conv local.E2 local.assoc_exp local.unit_comp)
text ‹One can therefore express the functional relationship between elements and their units in terms of
explict (source and target) maps -- as in catoids.›
definition so :: "'a ⇒ 'a" where
"so x = (THE e. e ∈ E ∧ e ⊙ x = {x})"
definition ta :: "'a ⇒ 'a" where
"ta x = (THE e. e ∈ E ∧ x ⊙ e = {x})"
abbreviation So :: "'a set ⇒ 'a set" where
"So X ≡ image so X"
abbreviation Ta :: "'a set ⇒ 'a set" where
"Ta X ≡ image ta X"
end
subsection ‹Multimonoids and catoids›
text ‹It is now easy to show that every catoid is a multimonoid and vice versa.›
text ‹One cannot have both sublocale statements at the same time.›
text ‹The converse direction requires some preparation.›
lemma (in multimonoid) so_unit: "so x ∈ E"
unfolding so_def by (metis (mono_tags, lifting) local.munits_uniquel theI')
lemma (in multimonoid) ta_unit: "ta x ∈ E"
unfolding ta_def by (metis (mono_tags, lifting) local.munits_uniquer theI')
lemma (in multimonoid) so_absorbl: "so x ⊙ x = {x}"
unfolding so_def by (metis (mono_tags, lifting) local.munits_uniquel the_equality)
lemma (in multimonoid) ta_absorbr: "x ⊙ ta x = {x}"
unfolding ta_def by (metis (mono_tags, lifting) local.munits_uniquer the_equality)
lemma (in multimonoid) semi_locality: "Δ x y ⟹ ta x = so y"
by (smt (verit, best) local.assoc_var local.conv_atom local.so_absorbl local.so_unit local.ta_absorbr local.ta_unit local.units_rm2l local.units_rm2r)