Skip to content

Commit

Permalink
finished module and vector space definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
SKolodynski committed Mar 22, 2024
1 parent 9a8d576 commit f32ffe9
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 74 deletions.
2 changes: 1 addition & 1 deletion IsarMathLib/Field_ZF.thy
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ locale field0 = ring0 K A M for K A M +

assumes not_triv: "\<zero> \<noteq> \<one>"

assumes inv_exists: "\<forall>a\<in>K. a\<noteq>\<zero> \<longrightarrow> (\<exists>b\<in>K. a\<cdot>b = \<one>)"
assumes inv_exists: "\<forall>x\<in>K. x\<noteq>\<zero> \<longrightarrow> (\<exists>y\<in>K. x\<cdot>y = \<one>)"

fixes non_zero ("K\<^sub>0")
defines non_zero_def[simp]: "K\<^sub>0 \<equiv> K-{\<zero>}"
Expand Down
6 changes: 6 additions & 0 deletions IsarMathLib/Fol1.thy
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ text\<open>The "exclusive or" is the same as negation of equivalence.\<close>
lemma Fol1_L9: shows "p Xor q \<longleftrightarrow> \<not>(p\<longleftrightarrow>q)"
using Xor_def by auto

text\<open>Constructions from the same sets are the same.
It is suprising but we do have to use this as a rule in rarte cases.\<close>

lemma same_constr: assumes "x=y" shows "P(x) = P(y)"
using assms by simp

text\<open>Equivalence relations are symmetric.\<close>

lemma equiv_is_sym: assumes A1: "equiv(X,r)" and A2: "\<langle>x,y\<rangle> \<in> r"
Expand Down
22 changes: 22 additions & 0 deletions IsarMathLib/Group_ZF_2.thy
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ proof -
by simp
qed

text\<open>The propositions proven in the \<open>group0\<close> context are valid in the same context
when applied to the function space with the lifted group operation.\<close>

lemma (in group0) group0_valid_fun_space:
shows "group0(X\<rightarrow>G,P {lifted to function space over} X)"
using Group_ZF_2_1_T2 unfolding group0_def by simp

text\<open>What is the group inverse for the lifted group?\<close>

lemma (in group0) Group_ZF_2_1_L6:
Expand Down Expand Up @@ -276,6 +283,21 @@ proof -
ultimately show ?thesis by simp
qed

text\<open>The neutral element of a subgroup of the lifted group is the constant
function with value equal to the neutral element of the group. \<close>

lemma (in group0) lift_group_subgr_neut:
assumes "F = P {lifted to function space over} X" and "IsAsubgroup(H,F)"
shows "TheNeutralElement(H,restrict(F,H\<times>H)) = ConstantFunction(X,\<one>)"
proof -
from assms have
"TheNeutralElement(H,restrict(F,H\<times>H)) = TheNeutralElement(X\<rightarrow>G,F)"
using group0_valid_fun_space group0.group0_3_L4 by blast
also from groupAssum assms(1) have "... = ConstantFunction(X,\<one>)"
using Group_ZF_2_1_L2 unfolding IsAgroup_def by simp
finally show ?thesis by simp
qed

text\<open>If a group is abelian, then its lift to a function space is also
abelian.\<close>

Expand Down
28 changes: 25 additions & 3 deletions IsarMathLib/Group_ZF_5.thy
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ text\<open>Endomoprhisms of a group form a monoid with composition as the binary

theorem (in group0) end_comp_monoid:
shows "IsAmonoid(End(G,P),InEnd(Composition(G),G,P))"
and "TheNeutralElement(End(G,P),InEnd(Composition(G),G,P))=id(G)"
and "TheNeutralElement(End(G,P),InEnd(Composition(G),G,P)) = id(G)"
proof -
let ?C\<^sub>0 = "InEnd(Composition(G),G,P)"
have fun: "id(G):G\<rightarrow>G" unfolding id_def by auto
Expand Down Expand Up @@ -153,6 +153,14 @@ proof-
} with fun2 show ?thesis using eq_endomor by simp
qed

text\<open>The value of a product of endomorphisms on a group element is the product of values.\<close>

lemma (in abelian_group) end_pointwise_add_val:
assumes "f\<in>End(G,P)" "g\<in>End(G,P)" "x\<in>G" "F = P {lifted to function space over} G"
shows "(InEnd(F,G,P)`\<langle>f,g\<rangle>)`(x) = (f`(x))\<cdot>(g`(x))"
using assms group_oper_fun monoid.group0_1_L3B func_ZF_1_L4
unfolding End_def by simp

text\<open>The inverse of an abelian group is an endomorphism.\<close>

lemma (in abelian_group) end_inverse_group:
Expand All @@ -162,7 +170,7 @@ lemma (in abelian_group) end_inverse_group:
unfolding End_def IsMorphism_def by simp

text\<open>The set of homomorphisms of an abelian group is an abelian subgroup of
the group of functions from a set to a group, under pointwise multiplication.\<close>
the group of functions from a set to a group, under pointwise addition.\<close>

theorem (in abelian_group) end_addition_group:
assumes "F = P {lifted to function space over} G"
Expand All @@ -172,7 +180,7 @@ proof-
have "End(G,P)\<noteq>0" using end_comp_monoid(1) monoid0.group0_1_L3A
unfolding monoid0_def by auto
moreover have "End(G,P) \<subseteq> G\<rightarrow>G" unfolding End_def by auto
moreover from isAbelian assms(1) have "End(G,P){is closed under}F"
moreover from isAbelian assms(1) have "End(G,P){is closed under} F"
unfolding IsOpClosed_def using end_pointwise_addition by auto
moreover from groupAssum assms(1) have
"\<forall>f\<in>End(G,P). GroupInv(G\<rightarrow>G,F)`(f) \<in> End(G,P)"
Expand All @@ -187,6 +195,20 @@ proof-
using Group_ZF_2_1_L7 unfolding End_def IsCommutative_def by auto
qed

text\<open>Endomorphisms form a subgroup of the space of functions that map the group to itself.\<close>

lemma (in abelian_group) end_addition_subgroup:
shows "IsAsubgroup(End(G,P),P {lifted to function space over} G)"
using end_addition_group unfolding IsAsubgroup_def by simp

text\<open>The neutral element of the group of endomorphisms of a group is the constant function
with value equal to the neutral element of the group.\<close>

lemma (in abelian_group) end_add_neut_elem:
assumes "F = P {lifted to function space over} G"
shows "TheNeutralElement(End(G,P),InEnd(F,G,P)) = ConstantFunction(G,\<one>)"
using assms end_addition_subgroup lift_group_subgr_neut by simp

text\<open>For the endomorphisms of a group $G$ the group operation lifted to the function space
over $G$ is distributive with respect to the composition operation. \<close>

Expand Down
270 changes: 270 additions & 0 deletions IsarMathLib/Module_ZF.thy
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
(*
This file is a part of IsarMathLib -
a library of formalized mathematics written for Isabelle/Isar.
Copyright (C) 2024 Slawomir Kolodynski
This program is free software; Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)

section \<open> Modules\<close>

theory Module_ZF imports Ring_ZF_3 Field_ZF

begin

text\<open>A module is a generalization of the concept of a vector space in which scalars
do not form a field but a ring. \<close>

subsection\<open>Definition and basic properties of modules\<close>

text\<open>Let $R$ be a ring and $M$ be an abelian group. The most common definition
of a left $R$-module states posits the existence of a scalar multiplication operation
$R\times M\rightarrow M$ satisfying certain four properties.
Here we take a bit more concise and abstract approach defining a module as a ring action
on an abelian group. \<close>

text\<open>We know that endomorphisms of an abelian group $\cal{M}$ form a ring with pointwise addition
as the additive operation and composition as the ring multiplication.
This asssertion is a bit imprecise though as the domain of pointwise addition
is a binary operation on the space of functions $\cal{M}\rightarrow \cal{M}$
(i.e. its domain is $(\cal{M}\rightarrow \cal{M})\times \cal{M}\rightarrow \cal{M}$)
while we need the space of endomorphisms to be the
domain of the ring addition and multiplication. Therefore, to get the actual additive operation
we need to restrict the pointwise addition of functions $\cal{M}\rightarrow \cal{M}$
to the set of endomorphisms of $\cal{M}$.
Recall from the \<open>Group_ZF_5\<close> that the \<open>InEnd\<close> operator restricts an operation to
the set of endomorphisms and see the \<open>func_ZF\<close> theory for definitions
of lifting an operation on a set to a function space over that set. \<close>

definition "EndAdd(\<M>,A) \<equiv> InEnd(A {lifted to function space over} \<M>,\<M>,A)"

text\<open>Similarly we define the multiplication in the ring of endomorphisms
as the restriction of compositions to the endomorphisms of $\cal{M}$.
See the \<open>func_ZF\<close> theory for the definition of the \<open>Composition\<close> operator. \<close>

definition "EndMult(\<M>,A) \<equiv> InEnd(Composition(\<M>),\<M>,A)"

text\<open>We can now reformulate the theorem \<open>end_is_ring\<close> from the \<open>Group_ZF_5\<close> theory
in terms of the addition and multiplication of endomorphisms defined above. \<close>

lemma (in abelian_group) end_is_ring1:
shows "IsAring(End(G,P),EndAdd(G,P),EndMult(G,P))"
using end_is_ring unfolding EndAdd_def EndMult_def by simp

text\<open>We define an \<open>action\<close> as a homomorphism into a space of endomorphisms (typically of some
abelian group). In the definition below $S$ is the set of scalars, $A$ is the addition operation
on this set, $M$ is multiplication on the set, $V$ is the set of vectors, $A_V$ is the
operation of vector addition, and $H$ is the homomorphism that defines the vector space.
On the right hand side of the definition \<open>End(V,A\<^sub>V)\<close> is the set of endomorphisms,
This definition is only ever used as part of the definition of a module and vector space,
it's just convenient to split it off to shorten the main definitions. \<close>

definition
"IsAction(S,A,M,\<M>,A\<^sub>M,H) \<equiv> ringHomomor(H,S,A,M,End(\<M>,A\<^sub>M),EndAdd(\<M>,A\<^sub>M),EndMult(\<M>,A\<^sub>M))"

text\<open>A module is a ring action on an abelian group.\<close>

definition "IsLeftModule(S,A,M,\<M>,A\<^sub>M,H) \<equiv>
IsAring(S,A,M) \<and> IsAgroup(\<M>,A\<^sub>M) \<and> (A\<^sub>M {is commutative on} \<M>) \<and> IsAction(S,A,M,\<M>,A\<^sub>M,H)"


text\<open>The next locale defines context (i.e. common assumptions and notation) when considering
modules. We reuse notation from the \<open>ring0\<close> locale and add notation specific to
modules. The addition and multiplication in the ring of scalars is denoted $+$ and $\cdot$,
resp. The addition of module elements will be denoted $+_V$.
The multiplication (scaling) of scalars by module elemenst will be denoted $\cdot_S$.
$\Theta$ is the zero module element, i.e. the neutral element of the abelian group
of the module elements. \<close>

locale module0 = ring0 +

fixes \<M> A\<^sub>M H

assumes mAbGr: "IsAgroup(\<M>,A\<^sub>M) \<and> (A\<^sub>M {is commutative on} \<M>)"

assumes mAction: "IsAction(R,A,M,\<M>,A\<^sub>M,H)"

fixes zero_vec ("\<Theta>")
defines zero_vec_def [simp]: "\<Theta> \<equiv> TheNeutralElement(\<M>,A\<^sub>M)"

fixes vAdd (infixl "+\<^sub>V" 80)
defines vAdd_def [simp]: "v\<^sub>1 +\<^sub>V v\<^sub>2 \<equiv> A\<^sub>M`\<langle>v\<^sub>1,v\<^sub>2\<rangle>"

fixes scal (infix "\<cdot>\<^sub>S" 90)
defines scal_def [simp]: "s \<cdot>\<^sub>S v \<equiv> (H`(s))`(v)"

fixes negV ("\<midarrow>_")
defines negV_def [simp]: "\<midarrow>v \<equiv> GroupInv(\<M>,A\<^sub>M)`(v)"

fixes vSub (infix "-\<^sub>V" 80)
defines vSub_def [simp]: "v\<^sub>1 -\<^sub>V v\<^sub>2 \<equiv> v\<^sub>1 +\<^sub>V (\<midarrow>v\<^sub>2)"

text\<open>We indeed talk about modules in the \<open>module0\<close> context.\<close>

lemma (in module0) module_in_module0: shows "IsLeftModule(R,A,M,\<M>,A\<^sub>M,H)"
using ringAssum mAbGr mAction unfolding IsLeftModule_def by simp

text\<open>Theorems proven in the \<open>abelian_group\<close> context are valid as applied to the \<open>module0\<close>
context as applied to the abelian group of "vectors". \<close>

lemma (in module0) abelian_group_valid_module0:
shows "abelian_group(\<M>,A\<^sub>M)"
using mAbGr group0_def abelian_group_def abelian_group_axioms_def
by simp

text\<open>Another way to state that theorems proven in the \<open>abelian_group\<close> context
can be used in the \<open>module0\<close> context: \<close>

sublocale module0 < mod_ab_gr: abelian_group \<M> A\<^sub>M "\<Theta>" vAdd negV
using abelian_group_valid_module0 by auto

text\<open>Theorems proven in the \<open>ring_homo\<close> context are valid in the \<open>module0\<close> context, as
applied to ring $R$ and the ring of endomorphisms of the vector group. \<close>

lemma (in module0) ring_homo_valid_module0:
shows "ring_homo(R,A,M,End(\<M>,A\<^sub>M),EndAdd(\<M>,A\<^sub>M),EndMult(\<M>,A\<^sub>M),H)"
using ringAssum mAction abelian_group_valid_module0 abelian_group.end_is_ring1
unfolding IsAction_def ring_homo_def by simp

text\<open>Another way to make theorems proven in the \<open>ring_homo\<close> context available in the
\<open>module0\<close> context: \<close>

sublocale module0 < vec_act_homo: ring_homo R A M
"End(\<M>,A\<^sub>M)" "EndAdd(\<M>,A\<^sub>M)" "EndMult(\<M>,A\<^sub>M)" H
ringa
ringminus
ringsub
ringm
ringzero
ringone
ringtwo
ringsq
"\<lambda>x y. EndAdd(\<M>,A\<^sub>M) ` \<langle>x, y\<rangle>"
"\<lambda>x. GroupInv(End(\<M>,A\<^sub>M), EndAdd(\<M>, A\<^sub>M))`(x)"
"\<lambda>x y. EndAdd(\<M>,A\<^sub>M)`\<langle>x,GroupInv(End(\<M>, A\<^sub>M), EndAdd(\<M>, A\<^sub>M))`(y)\<rangle>"
"\<lambda>x y. EndMult(\<M>,A\<^sub>M)`\<langle>x, y\<rangle>"
"TheNeutralElement(End(\<M>, A\<^sub>M), EndAdd(\<M>, A\<^sub>M))"
"TheNeutralElement(End(\<M>, A\<^sub>M), EndMult(\<M>, A\<^sub>M))"
"EndAdd(\<M>,A\<^sub>M)`\<langle>TheNeutralElement(End(\<M>, A\<^sub>M),EndMult(\<M>, A\<^sub>M)),TheNeutralElement(End(\<M>, A\<^sub>M), EndMult(\<M>,A\<^sub>M))\<rangle>"
"\<lambda>x. EndMult(\<M>,A\<^sub>M)`\<langle>x, x\<rangle>"
using ring_homo_valid_module0 by auto

text\<open>In the ring of endomorphisms of the module the neutral element of the additive operation
is the zero valued constant function. The neutral element of the multiplicative operation is
the identity function.\<close>

lemma (in module0) add_mult_neut_elems: shows
"TheNeutralElement(End(\<M>, A\<^sub>M), EndMult(\<M>,A\<^sub>M)) = id(\<M>)" and
"TheNeutralElement(End(\<M>,A\<^sub>M),EndAdd(\<M>,A\<^sub>M)) = ConstantFunction(\<M>,\<Theta>)"
proof -
show "TheNeutralElement(End(\<M>, A\<^sub>M), EndMult(\<M>, A\<^sub>M)) = id(\<M>)"
using mod_ab_gr.end_comp_monoid(2) unfolding EndMult_def
by blast
show "TheNeutralElement(End(\<M>, A\<^sub>M), EndAdd(\<M>, A\<^sub>M)) = ConstantFunction(\<M>,\<Theta>)"
using mod_ab_gr.end_add_neut_elem unfolding EndAdd_def by blast
qed

text\<open>The value of the homomorphism defining the module is an endomorphism
of the vector space group and hence a function that maps the vector space into itself.\<close>

lemma (in module0) H_val_type: assumes "r\<in>R" shows
"H`(r) \<in> End(\<M>,A\<^sub>M)" and "H`(r):\<M>\<rightarrow>\<M>"
using mAction assms apply_funtype unfolding IsAction_def ringHomomor_def End_def
by auto

text\<open> In the \<open>module0\<close> context the neutral element of addition of module elements
is denoted $\Theta$. Of course $\Theta$ is an element of the module. \<close>

lemma (in module0) zero_in_mod: shows "\<Theta> \<in> \<M>"
using mod_ab_gr.group0_2_L2 by simp

text\<open> $\Theta$ is indeed the neutral element of addition of module elements.\<close>

lemma (in module0) zero_neutral: assumes "x\<in>\<M>"
shows "x +\<^sub>V \<Theta> = x" and "\<Theta> +\<^sub>V x = x"
using assms mod_ab_gr.group0_2_L2 by simp_all

subsection\<open>Module axioms\<close>

text\<open>A more common definition of a module assumes that $R$ is a ring, $V$
is an abelian group and lists a couple of properties that the multiplications of scalars
(elements of $R$) by the elements of the module $V$ should have.
In this section we show that the definition of a module as a ring action
on an abelian group $V$ implies these properties. \<close>

text\<open>The scalar multiplication is distributive with respect to the module addition.\<close>

lemma (in module0) module_ax1: assumes "r\<in>R" "x\<in>\<M>" "y\<in>\<M>"
shows "r\<cdot>\<^sub>S(x+\<^sub>Vy) = r\<cdot>\<^sub>Sx +\<^sub>V r\<cdot>\<^sub>Sy"
using assms H_val_type(1) mod_ab_gr.endomor_eq by simp

text\<open>The scalar addition is distributive with respect to scalar multiplication.\<close>

lemma (in module0) module_ax2: assumes "r\<in>R" "s\<in>R" "x\<in>\<M>"
shows "(r\<ra>s)\<cdot>\<^sub>Sx = r\<cdot>\<^sub>Sx +\<^sub>V s\<cdot>\<^sub>Sx"
using assms vec_act_homo.homomor_dest_add H_val_type(1) mod_ab_gr.end_pointwise_add_val
unfolding EndAdd_def by simp

text\<open>Multiplication by scalars is associative with multiplication of scalars.\<close>

lemma (in module0) module_ax3: assumes "r\<in>R" "s\<in>R" "x\<in>\<M>"
shows "(r\<cdot>s)\<cdot>\<^sub>Sx = r\<cdot>\<^sub>S(s\<cdot>\<^sub>Sx)"
proof -
let ?e = "EndMult(\<M>,A\<^sub>M)`\<langle>H`(r),H`(s)\<rangle>"
have "(r\<cdot>s)\<cdot>\<^sub>Sx = (H`(r\<cdot>s))`(x)" by simp
also have "(H`(r\<cdot>s))`(x) = ?e`(x)"
proof -
from mAction assms(1,2) have "H`(r\<cdot>s) = ?e"
using vec_act_homo.homomor_dest_mult unfolding IsAction_def
by blast
then show ?thesis by (rule same_constr)
qed
also have "?e`(x) = r\<cdot>\<^sub>S(s\<cdot>\<^sub>Sx)"
proof -
from assms(1,2) have "?e`(x) = (Composition(\<M>)`\<langle>H`(r),H`(s)\<rangle>)`(x)"
using H_val_type(1) unfolding EndMult_def by simp
also from assms have "... = r\<cdot>\<^sub>S(s\<cdot>\<^sub>Sx)" using H_val_type(2) func_ZF_5_L3
by simp
finally show "?e`(x) = r\<cdot>\<^sub>S(s\<cdot>\<^sub>Sx)" by blast
qed
finally show ?thesis by simp
qed

text\<open>Scaling a module element by one gives the same module element.\<close>

lemma (in module0) module_ax4: assumes "x\<in>\<M>" shows "\<one>\<cdot>\<^sub>Sx = x"
proof -
let ?n = "TheNeutralElement(End(\<M>,A\<^sub>M),EndMult(\<M>,A\<^sub>M))"
from mAction have "H`(TheNeutralElement(R,M)) = ?n"
unfolding IsAction_def ringHomomor_def by blast
moreover have "TheNeutralElement(R,M) = \<one>" by simp
ultimately have "H`(\<one>) = ?n" by blast
also have "?n = id(\<M>)" by (rule add_mult_neut_elems)
finally have "H`(\<one>) = id(\<M>)" by simp
with assms show "\<one>\<cdot>\<^sub>Sx = x" by simp
qed

end



Loading

0 comments on commit f32ffe9

Please sign in to comment.