數學是非常難學的,因為數學需要大量的練習才能真正掌握。一般教科書的證明,通常會提點一些大方向,或是用上讀者不懂的其他「常識」,就算是證明完畢,剩下的讓讀者自己練習填上。如果是在課堂上學習,倒也還能跟助教、老師詢問,但自學的人要怎麼知道自己寫的證明正確無誤呢?我認為 Agda 或是 Lean 這類的定理證明器就可以幫上忙,除了能夠證明你寫下的程式正確,用自己的想法把數學陳述寫成程式並證明,本身就是有益的練習。
我把初等的抽象代數事實整理成這個網站,把一些代數的事實紀錄下來,既可以用做查詢,也可以讓初學者當作學習的補充材料。
請用 Cmd + K 或是 Ctrl + K 查詢內容
有興趣嘗試證明器的讀者更是可以試著 fork 專案 https://github.com/dannypsnl/AbstractAlgebra 練習更多的延伸命題,用 Agda 學習抽象代數。
Group Theory [alg-0000]
Group Theory [alg-0000]
這裡我們開始介紹群論
Definition. 群 Group [group-0000]
Definition. 群 Group [group-0000]
module group-0000 where open import MLTT.Spartan hiding (_∙_) renaming (_⁻¹ to sym) open import UF.Base open import UF.Sets open import UF.Sets-Properties
一個群(group)是由一個非空集合 G 跟一個二元運算子(binary operation)
• : G × G → G
構成,且滿足以下條件
- G 有一個特別的元素叫單位元素(identity 或是 neutral element),用 e 表示,任何元素 g 跟它運算都是 g,也就是 g = g • e = e • g
- 這個運算子是 associative 的,也就是說 (a • b) • c = a • (b • c),所以我們可以安全的寫成 a • b • c
- 每個元素 g ∈ G 都有一個反元素 g−1 ∈ G,滿足以下等式 g • g−1 = g−1 • g = e
我們把這些條件匯總,就寫成了下面的定義
record Group (G : 𝓤 ̇) : 𝓤 ̇ where field size : is-set G _∙_ : G → G → G ∙-assoc : associative _∙_ e : G neu-l : left-neutral e _∙_ neu-r : right-neutral e _∙_ _⁻¹ : G → G cancel : {x : G} → ((x ⁻¹) ∙ x = e) × (x ∙ (x ⁻¹) = e) infix 40 _⁻¹ infixl 20 _∙_
Agda 小知識 [agda-0000]
Agda 小知識 [agda-0000]
在我們開始之前需要知道怎麼閱讀 agda 的證明,這裡使用的是由 Martin Escardo 維護的 TypeTopology 程式庫,下面經常會用到的是等式證明,寫成形式
A =⟨ B ⟩ C ∎
這段程式的意思是「因為 ,所以 等於 」。每個寫好的證明,都可由其他程式引用,比如
proposition-4 : {G H : 𝓤 ̇} {{∈G : Group G}} {{∈H : Group H}}
→ (φ : G → H)
→ IsGroupHomomorphism G H φ
→ φ e = e
就可以引用
φ e =⟨ proposition-4 φ is-hom ⟩ e ∎
這就是說 ,因為前面證明過的事實 proposition-4 φ is-hom。
Basic facts about groups [local-0]
Basic facts about groups [local-0]
現在來看一些命題
Proposition. Identity is unique [group-0001]
Proposition. Identity is unique [group-0001]
module group-0001 where open import MLTT.Spartan hiding (_∙_) renaming (_⁻¹ to sym) open import group-0000 open Group {{...}}
假設元素 h ∈ G 是另一個滿足單位元素條件的元素,那 h = e。
事實上,很酷的事情是甚至不用完全滿足單位元素條件,就如下面的證明所演示的
proposition-1 : {G : 𝓤 ̇} {{_ : Group G}} {h : G} → left-neutral h _∙_ → h = e proposition-1 {G}{_} {h} h-is-identity = h =⟨ sym (neu-r h) ⟩ h ∙ e =⟨ h-is-identity e ⟩ e ∎
這個命題的重點是單位元素是唯一的,所以英文的話你可以用「the」修飾。
sym把等式翻面:A = B變成B = Ak
Proposition. Inverse element is unique [group-0002]
Proposition. Inverse element is unique [group-0002]
module group-0002 where open import MLTT.Spartan hiding (_∙_) renaming (_⁻¹ to sym) open import group-0000 open Group {{...}}
如果 h1 and h2 的反元素都是 g,那 h1 = h2。或者我們會說反元素是唯一的,跟上面的命題的意義類似。
proposition-2 : {G : 𝓤 ̇} {{_ : Group G}} {g h1 h2 : G} → (g ∙ h1 = e) → (g ∙ h2 = e) → h1 = h2 proposition-2 {G}{_} {g}{h1}{h2} fact1 fact2 = h1 =⟨ sym (neu-l h1) ⟩ e ∙ h1 =⟨ ap (_∙ h1) (sym (cancel .pr₁)) ⟩ g ⁻¹ ∙ g ∙ h1 =⟨ ∙-assoc (g ⁻¹) g h1 ⟩ g ⁻¹ ∙ (g ∙ h1) =⟨ ap (g ⁻¹ ∙_) fact1 ⟩ g ⁻¹ ∙ e =⟨ ap ((g ⁻¹) ∙_) (sym fact2) ⟩ g ⁻¹ ∙ (g ∙ h2) =⟨ sym (∙-assoc (g ⁻¹) g h2) ⟩ g ⁻¹ ∙ g ∙ h2 =⟨ ap (_∙ h2) (cancel .pr₁) ⟩ e ∙ h2 =⟨ neu-l h2 ⟩ h2 ∎
ap把等式裡的 expression 中沒有變化的部分抽出來用的,這樣才能操作其餘要改變的部分
Proposition. Every element can be cancelled [group-0003]
Proposition. Every element can be cancelled [group-0003]
module group-0003 where open import MLTT.Spartan hiding (_∙_) renaming (_⁻¹ to sym) open import group-0000 open Group {{...}}
這個命題在說每個元素都可以取消,這是一個非常好用的事實,而且完全不必感到陌生,我等一下再解釋這點。我們先來看它的具體描述
- 如果 g • a = h • a,則 g = h
- 如果 a • g = a • h,則 g = h
proposition-3 : {G : 𝓤 ̇} {{_ : Group G}} {g h a : G} → (g ∙ a = h ∙ a → g = h) × (a ∙ g = a ∙ h → g = h) proposition-3 {G}{_} {g}{h}{a} = I , II where I : g ∙ a = h ∙ a → g = h I fact = g =⟨ sym (neu-r g) ⟩ g ∙ e =⟨ ap (g ∙_) (sym (cancel .pr₂)) ⟩ g ∙ (a ∙ a ⁻¹) =⟨ sym (∙-assoc g a (a ⁻¹)) ⟩ g ∙ a ∙ a ⁻¹ =⟨ ap (_∙ a ⁻¹) fact ⟩ h ∙ a ∙ a ⁻¹ =⟨ ∙-assoc h a (a ⁻¹) ⟩ h ∙ (a ∙ a ⁻¹) =⟨ ap (h ∙_) (cancel .pr₂) ⟩ h ∙ e =⟨ neu-r h ⟩ h ∎ II : a ∙ g = a ∙ h → g = h II fact = g =⟨ sym (neu-l g) ⟩ e ∙ g =⟨ ap (_∙ g) (sym (cancel .pr₁)) ⟩ a ⁻¹ ∙ a ∙ g =⟨ ∙-assoc (a ⁻¹) a g ⟩ a ⁻¹ ∙ (a ∙ g) =⟨ ap (a ⁻¹ ∙_) fact ⟩ a ⁻¹ ∙ (a ∙ h) =⟨ sym (∙-assoc (a ⁻¹) a h) ⟩ a ⁻¹ ∙ a ∙ h =⟨ ap (_∙ h) (cancel .pr₁) ⟩ e ∙ h =⟨ neu-l h ⟩ h ∎
為什麼不必對這個命題感到陌生呢?因為這其實是我們日常也很容易遇到的算術事實:如果 2x = 2y 那 x = y。
Definition. Group Homomorphism [group-0004]
Definition. Group Homomorphism [group-0004]
module group-0004 where open import MLTT.Spartan hiding (_∙_) renaming (_⁻¹ to sym) open import group-0000 open Group {{...}}
我們先看 group homomorphism 的定義:
IsGroupHomomorphism : (G H : 𝓤 ̇) {{_ : Group G}} {{_ : Group H}} → (φ : G → H) → 𝓤 ̇ IsGroupHomomorphism G H φ = (x y : G) → φ (x ∙ y) = (φ x) ∙ (φ y)
基本上它的意思是,我們定義如果函數 φ : G → H 能讓
φ(a • b) = φ(a) • φ(b)
對所有 a, b ∈ G 成立,那 φ 是一個 group homomorphism。
這些 homomorphism 之所以特別,就是它們保留了一些結構,讓我們能夠對群整體做出推論,這種想法以範疇論為主,有非常多有趣又深刻的延伸。
Basic facts of group homomorphism [local-1]
Basic facts of group homomorphism [local-1]
所以我們接著來看一個 group homomorphism 會有什麼特性。
Proposition. Preserve identity [group-0005]
Proposition. Preserve identity [group-0005]
module group-0005 where open import MLTT.Spartan renaming (_⁻¹ to sym; _∙_ to _then_) open import group-0000 open Group {{...}} open import group-0003 open import group-0004
Group homomorphism 保留單位元素,也就是說 φ(eG) = eH。
注意到雖然我們在數學式裡面用下標 G、H 區分,但在 Agda 裡面它自己就知道這件事,所以不用特別寫出
proposition-4 : {G H : 𝓤 ̇} {{∈G : Group G}} {{∈H : Group H}} → (φ : G → H) → IsGroupHomomorphism G H φ → φ e = e proposition-4 φ is-hom = II where
證明 φ(eG) • φ(eG) = eH • φ(eG)
I : (φ e) ∙ (φ e) = e ∙ (φ e) I = (φ e) ∙ (φ e) =⟨ sym (is-hom e e) ⟩ φ (e ∙ e) =⟨ ap φ (neu-l e) ⟩ φ e =⟨ sym (neu-l (φ e)) ⟩ e ∙ φ e ∎
那我們就可以用前面證明過的 [Proposition 3] 任何元素都能取消 得出結論
II : (φ e) = e II = (proposition-3 .pr₁) I
Proposition. Preserve inverse [group-0006]
Proposition. Preserve inverse [group-0006]
module group-0006 where open import MLTT.Spartan renaming (_⁻¹ to sym; _∙_ to _then_) open import group-0000 open Group {{...}} open import group-0003 open import group-0004 open import group-0005
Group homomorphism 保留反元素,也就是說 φ(g−1) = φ(g)−1 對所有 g ∈ G 成立。
proposition-5 : {G H : 𝓤 ̇} {{∈G : Group G}} {{∈H : Group H}} → (φ : G → H) → IsGroupHomomorphism G H φ → (g : G) → φ (g ⁻¹) = (φ g) ⁻¹ proposition-5 φ is-hom g = (proposition-3 .pr₁) III where
這裡馬上就用到剛剛證明的保留 identity 性質
I : φ (g ⁻¹) ∙ φ g = e I = φ (g ⁻¹) ∙ φ g =⟨ sym (is-hom (g ⁻¹) g) ⟩ φ (g ⁻¹ ∙ g) =⟨ ap φ (cancel .pr₁) ⟩ φ e =⟨ proposition-4 φ is-hom ⟩ e ∎ II : e = (φ g) ⁻¹ ∙ (φ g) II = sym (cancel .pr₁) III : φ (g ⁻¹) ∙ φ g = (φ g) ⁻¹ ∙ (φ g) III = I then II
Definition. 子群 Subgroup [group-0007]
Definition. 子群 Subgroup [group-0007]
module group-0007 where open import MLTT.Spartan open import group-0000 open import group-0004
子群的定義是,如果存在一個 inclusion 函數 i : H → G 是一個 group homomorphism,那 H 是 G 的子群。
IsSubgroup : {𝓤 : Universe} (H G : 𝓤 ̇) {{_ : Group H}} {{_ : Group G}} → 𝓤 ̇ IsSubgroup H G = Σ i ꞉ (H → G) , left-cancellable i × IsGroupHomomorphism H G i
Basic facts of subgroup [local-2]
Basic facts of subgroup [local-2]
Proposition. Trivial group is a subgroup of all groups [group-0008]
Proposition. Trivial group is a subgroup of all groups [group-0008]
module group-0008 where open import MLTT.Spartan renaming (_⁻¹ to sym; _∙_ to _then_) open import UF.Subsingletons open import UF.Subsingletons-Properties open import group-0000 open Group {{...}} open import group-0004 open import group-0007
這個命題是說,對所有群都有一個子群是 trivial group。
要證明之前,我們需要看一下什麼是 trivial
group,基本上它就是只有一個估拎拎的 e
元素的集合,那因為只有一個元素,能定義的二元運算子也就只有一個,根據這些我們可以定義
trivial group(𝟙 是一個只有單一元素 ⋆
的型別)
trivial-group : Group (𝟙 {𝓤}) trivial-group .size = props-are-sets 𝟙-is-prop trivial-group ._∙_ = λ _ _ → ⋆ trivial-group .∙-assoc = λ _ _ _ → refl trivial-group .e = ⋆ trivial-group .neu-l = λ _ → refl trivial-group .neu-r = λ _ → refl trivial-group ._⁻¹ = λ _ → ⋆ trivial-group .cancel = refl , refl
現在我們可以回到證明,因為 IsSubgroup 是一個 Sigma
類型,所以我們需要提出一個 map ι,然後證明這個 map 是 inclusion
而且是 group homomorphism。
proposition-6 : {G : 𝓤 ̇} {{∈G : Group G}} {{∈𝟙 : Group 𝟙}} → IsSubgroup 𝟙 G proposition-6 {𝓤} {G} = ι , lc , is-hom where
這個 map 在數學上常被稱為 canonical map,用來指示「很明顯」會選這個的意思,這在不同數學領域都會有類似的 canonical 的用法,雖然那個「明顯」可能很不一樣。
ι : 𝟙 → G ι ⋆ = e
它的 inclusion 特性很明顯,甚至都不用到
p,因為只有一個元素
lc : left-cancellable ι lc p = refl
最後要滿足 group homomorphism,下面利用 e 攤開出我們需要的表達式
is-hom : IsGroupHomomorphism 𝟙 G ι is-hom ⋆ ⋆ = ι (⋆ ∙ ⋆) =⟨by-definition⟩ e =⟨ sym (neu-l e) ⟩ e ∙ e =⟨by-definition⟩ (ι ⋆) ∙ (ι ⋆) ∎
Proposition. Subgroup equivalent condition [group-0009]
Proposition. Subgroup equivalent condition [group-0009]
module group-0009 where open import MLTT.Spartan renaming (_⁻¹ to sym; _∙_ to _then_) open import UF.Sets open import group-0000 open Group {{...}} open import group-0002 open import group-0004 open import group-0007
這個命題說 H 是 G 的 subgroup 等價於說
H 是 G 的非空子集合,且
a • b−1 ∈ H
下面只證明這個條件可以推出
- H 是一個群
- H 是 G 的子群
因為反過來非常明顯:一個群本身當然是封閉的。
跟之前一樣,子集合寫成 inclusion 函數
proposition-7 : {G H : 𝓤 ̇} {{∈G : Group G}} → (i : H → G) → left-cancellable i → is-set H
怎麼表達 H 不是空集呢?只要說存在一個元素就好
→ (h : H)
∀ (a b : G) → Σ y ꞉ H , a ∙ b ⁻¹ = i y這整個型別要這樣解讀「對所有 a, b ∈ G,存在 y ∈ H 使 a • b−1 = i(y)」。這裡是目前第一次用到Σ,也就是說Σ當命題時,其實就是用來表達「存在某某某滿足什麼什麼條件」的
→ (∀ (a b : G) → Σ y ꞉ H , a ∙ b ⁻¹ = i y) → Σ is-grp ꞉ Group H , IsSubgroup {𝓤} H G {{is-grp}} proposition-7 {𝓤}{G}{H} {{∈G}} i inclusion H-is-set h cond = H-is-group , i , inclusion , is-hom where
接下來的證明很大的複雜性都在
H是群這點上,尤其是因為把cond的類型定義成存在y ∈ H映射到a ∙ b ⁻¹這點上,會讓接下來很多簡單的東西都藏在定義後面。其實如果可以,技巧上最好是以G為類型,滿足某種條件的元素,而不是真的用另一個型別H,事情會簡單很多
這裡先定義一些工具,像 I 就在說 H
一定有一個元素可以當單位元,也就是採用前面 inhabited 那個
h : H 然後取 i h ∙ i h ⁻¹
為單位元(這邊就是技術細節導致的問題,i h ∙ i h ⁻¹ 的類型是
G 不能直接用,還需要取一次 pr₁ 才是
H 的 term)
I : Σ y ꞉ H , i h ∙ i h ⁻¹ = i y I = cond (i h) (i h) eH : H eH = I .pr₁ prop-eH : i h ∙ i h ⁻¹ = i eH prop-eH = I .pr₂ eH-is-identity : i eH = e eH-is-identity = (sym prop-eH) then (cancel .pr₂) II : (a b : H) → Σ y ꞉ H , i a ∙ i b ⁻¹ ⁻¹ = i y II a b = cond (i a) (i b ⁻¹) III : (a : H) → Σ y ꞉ H , i eH ∙ i a ⁻¹ = i y III a = cond (i eH) (i a) inv-inv : (a : G) → a ⁻¹ ⁻¹ = a inv-inv a = proposition-2 F S where F : a ⁻¹ ∙ a ⁻¹ ⁻¹ = e F = cancel .pr₂ S : a ⁻¹ ∙ a = e S = cancel .pr₁
H 可以用上面定義的工具滿足群的條件
H-is-group : Group H H-is-group .size = H-is-set H-is-group ._∙_ a b = II a b .pr₁ H-is-group .∙-assoc x y z = inclusion VII where IV : Σ xy ꞉ H , i x ∙ i y ⁻¹ ⁻¹ = i xy IV = II x y xy = IV .pr₁ Hxy : i x ∙ i y ⁻¹ ⁻¹ = i xy Hxy = IV .pr₂ V : Σ yz ꞉ H , i y ∙ i z ⁻¹ ⁻¹ = i yz V = II y z yz = V .pr₁ Hyz : i y ∙ i z ⁻¹ ⁻¹ = i yz Hyz = V .pr₂ left = II xy z .pr₁ right = II x yz .pr₁ help1 = II xy z .pr₂ help2 = II x yz .pr₂ mid : i xy ∙ i z ⁻¹ ⁻¹ = i x ∙ i yz ⁻¹ ⁻¹ mid = i xy ∙ i z ⁻¹ ⁻¹ =⟨ ap (i xy ∙_) (inv-inv (i z)) ⟩ i xy ∙ i z =⟨ ap (_∙ i z) (sym Hxy) ⟩ i x ∙ i y ⁻¹ ⁻¹ ∙ i z =⟨ ap (λ y → i x ∙ y ∙ i z) (inv-inv (i y)) ⟩ i x ∙ i y ∙ i z =⟨ ap (i x ∙ i y ∙_) (sym (inv-inv (i z))) ⟩ i x ∙ i y ∙ i z ⁻¹ ⁻¹ =⟨ ∙-assoc (i x) (i y) (i z ⁻¹ ⁻¹) ⟩ i x ∙ (i y ∙ i z ⁻¹ ⁻¹) =⟨ ap (i x ∙_) Hyz ⟩ i x ∙ i yz =⟨ ap (i x ∙_) (sym (inv-inv (i yz))) ⟩ i x ∙ i yz ⁻¹ ⁻¹ ∎ VII : i left = i right VII = (sym help1) then mid then help2 H-is-group .e = eH H-is-group .neu-l x = inclusion VI where IV : Σ y ꞉ H , i eH ∙ i x ⁻¹ ⁻¹ = i y IV = II eH x y = IV .pr₁ V : i eH ∙ i x ⁻¹ ⁻¹ = i y V = IV .pr₂ VI : i y = i x VI = i y =⟨ sym V ⟩ i eH ∙ i x ⁻¹ ⁻¹ =⟨ ap (_∙ i x ⁻¹ ⁻¹) eH-is-identity ⟩ e ∙ i x ⁻¹ ⁻¹ =⟨ neu-l (i x ⁻¹ ⁻¹) ⟩ i x ⁻¹ ⁻¹ =⟨ inv-inv (i x) ⟩ i x ∎ H-is-group .neu-r x = inclusion VI where IV : Σ y ꞉ H , i x ∙ i eH ⁻¹ ⁻¹ = i y IV = II x eH y = IV .pr₁ V : i x ∙ i eH ⁻¹ ⁻¹ = i y V = IV .pr₂ VI : i y = i x VI = i y =⟨ sym V ⟩ i x ∙ i eH ⁻¹ ⁻¹ =⟨ ap (i x ∙_) (inv-inv (i eH)) ⟩ i x ∙ i eH =⟨ ap (i x ∙_) eH-is-identity ⟩ i x ∙ e =⟨ neu-r (i x) ⟩ i x ∎ H-is-group ._⁻¹ x = III x .pr₁ H-is-group .cancel {x} = left , right where x' = III x .pr₁ Hx' : i eH ∙ i x ⁻¹ = i x' Hx' = III x .pr₂ l = II x' x .pr₁ Hl : i x' ∙ i x ⁻¹ ⁻¹ = i l Hl = II x' x .pr₂ step-left : i x' ∙ i x ⁻¹ ⁻¹ = i eH step-left = i x' ∙ i x ⁻¹ ⁻¹ =⟨ ap (_∙ i x ⁻¹ ⁻¹) (sym Hx') ⟩ i eH ∙ i x ⁻¹ ∙ i x ⁻¹ ⁻¹ =⟨ ∙-assoc (i eH) (i x ⁻¹) (i x ⁻¹ ⁻¹) ⟩ i eH ∙ (i x ⁻¹ ∙ i x ⁻¹ ⁻¹) =⟨ ap (i eH ∙_) (cancel .pr₂) ⟩ i eH ∙ e =⟨ neu-r (i eH) ⟩ i eH ∎ r = II x x' .pr₁ Hr : i x ∙ i x' ⁻¹ ⁻¹ = i r Hr = II x x' .pr₂ step-right : i x ∙ i x' ⁻¹ ⁻¹ = i eH step-right = i x ∙ i x' ⁻¹ ⁻¹ =⟨ ap (i x ∙_) (inv-inv (i x')) ⟩ i x ∙ i x' =⟨ ap (i x ∙_) (sym Hx') ⟩ i x ∙ (i eH ∙ i x ⁻¹) =⟨ ap (i x ∙_) (ap (_∙ i x ⁻¹) eH-is-identity) ⟩ i x ∙ (e ∙ i x ⁻¹) =⟨ ap (i x ∙_) (neu-l (i x ⁻¹)) ⟩ i x ∙ i x ⁻¹ =⟨ cancel .pr₂ ⟩ e =⟨ sym eH-is-identity ⟩ i eH ∎ left : (l = eH) left = inclusion ((sym Hl) then step-left) right : (II x x' .pr₁ = eH) right = inclusion ((sym Hr) then step-right)
證明的最後一個部分是推論出這樣的 inclusion map 一定是 group homomorphism
is-hom : IsGroupHomomorphism H G {{H-is-group}} i is-hom x y = i (II x y .pr₁) =⟨ sym (II x y .pr₂) ⟩ i x ∙ i y ⁻¹ ⁻¹ =⟨ ap (i x ∙_) (inv-inv (i y)) ⟩ i x ∙ i y ∎
這裡來嘗試第二種編碼方式證明同樣的命題
- 用
∈H : G → 𝓤 ̇編碼了屬於H集合這個前提 - 規定
∈H是 proposition(沒錯,在 HoTT 裡你同樣能問一個類型是不是一個命題) - inhabited
h : G且h ∈H表示了H不是空集合
下面會反覆使用的技術是
to-Σ-=,這樣就會證明一次G中元素在屬於H時的等式,隨後要處理一個 transport 問題,但因為上面第二個條件(∈H是 proposition),使得這個證明是完全由 Agda 可以自動合成的
open import UF.Sets-Properties open import UF.Subsingletons open import UF.Base proposition-7' : {G : 𝓤 ̇ } {{∈G : Group G}} → (_∈H : G → 𝓤 ̇ ) → (∀ (a : G) → is-prop (a ∈H)) → (∀ (a b : G) → a ∙ b ⁻¹ ∈H) → (h : G) → h ∈H → Σ is-grp ꞉ Group (Σ x ꞉ G , x ∈H) , IsSubgroup {𝓤} (Σ x ꞉ G , x ∈H) G {{is-grp}} proposition-7' {𝓤}{G}{{∈G}} _∈H ∈H-is-prop cond h h∈H = H-is-grp , is-subgroup where inv-inv : (a : G) → a ⁻¹ ⁻¹ = a inv-inv a = proposition-2 F S where F : a ⁻¹ ∙ a ⁻¹ ⁻¹ = e F = cancel .pr₂ S : a ⁻¹ ∙ a = e S = cancel .pr₁ H-is-grp : Group (Σ x ꞉ G , x ∈H) H-is-grp .size = subsets-of-sets-are-sets G _∈H (Group.size ∈G) λ {x = x₁} → ∈H-is-prop x₁ H-is-grp ._∙_ (a , a∈H) (b , b∈H) = a ∙ b ⁻¹ ⁻¹ , cond a (b ⁻¹) H-is-grp .∙-assoc (a , a∈H) (b , b∈H) (c , c∈H) = to-Σ-= (elem , ∈H-is-prop (pr₁ ((H-is-grp Group.∙ (a , a∈H)) ((H-is-grp Group.∙ (b , b∈H)) (c , c∈H)))) (transport _∈H elem (pr₂ ((H-is-grp Group.∙ (H-is-grp Group.∙ (a , a∈H)) (b , b∈H)) (c , c∈H)))) (pr₂ ((H-is-grp Group.∙ (a , a∈H)) ((H-is-grp Group.∙ (b , b∈H)) (c , c∈H))))) where elem : (a ∙ b ⁻¹ ⁻¹) ∙ c ⁻¹ ⁻¹ = a ∙ (b ∙ c ⁻¹ ⁻¹) ⁻¹ ⁻¹ elem = (a ∙ b ⁻¹ ⁻¹) ∙ c ⁻¹ ⁻¹ =⟨ ∙-assoc a (b ⁻¹ ⁻¹) (c ⁻¹ ⁻¹) ⟩ a ∙ (b ⁻¹ ⁻¹ ∙ c ⁻¹ ⁻¹) =⟨ ap (λ b → a ∙ (b ∙ c ⁻¹ ⁻¹)) (inv-inv b) ⟩ a ∙ (b ∙ c ⁻¹ ⁻¹) =⟨ ap (a ∙_) (sym (inv-inv (b ∙ c ⁻¹ ⁻¹))) ⟩ a ∙ (b ∙ c ⁻¹ ⁻¹) ⁻¹ ⁻¹ ∎ H-is-grp .e = (h ∙ h ⁻¹) , cond h h H-is-grp .neu-l (x , x∈H) = to-Σ-= (elem , ∈H-is-prop x (transport _∈H elem (pr₂ ((H-is-grp Group.∙ H-is-grp .Group.e) (x , x∈H)))) x∈H) where elem : (h ∙ h ⁻¹) ∙ x ⁻¹ ⁻¹ = x elem = (h ∙ h ⁻¹) ∙ x ⁻¹ ⁻¹ =⟨ ap (_∙ (x ⁻¹) ⁻¹) (∈G .cancel .pr₂) ⟩ e ∙ x ⁻¹ ⁻¹ =⟨ neu-l (x ⁻¹ ⁻¹) ⟩ x ⁻¹ ⁻¹ =⟨ inv-inv x ⟩ x ∎ H-is-grp .neu-r (x , x∈H) = to-Σ-= (elem , ∈H-is-prop x (transport _∈H elem (pr₂ ((H-is-grp Group.∙ (x , x∈H)) (H-is-grp .Group.e)))) x∈H) where elem : x ∙ (h ∙ h ⁻¹) ⁻¹ ⁻¹ = x elem = x ∙ (h ∙ h ⁻¹) ⁻¹ ⁻¹ =⟨ ap (x ∙_) (inv-inv (h ∙ h ⁻¹)) ⟩ x ∙ (h ∙ h ⁻¹) =⟨ ap (x ∙_) (∈G .cancel .pr₂) ⟩ x ∙ e =⟨ neu-r x ⟩ x ∎ H-is-grp ._⁻¹ (x , x∈H) = (h ∙ h ⁻¹) ∙ x ⁻¹ , cond (h ∙ h ⁻¹) x H-is-grp .cancel {x} = to-Σ-= (cL , ∈H-is-prop (pr₁ (Group.e H-is-grp)) (transport _∈H cL (pr₂ ((H-is-grp Group.∙ (H-is-grp Group.⁻¹) x) x))) (pr₂ (Group.e H-is-grp))) , to-Σ-= (cR , ∈H-is-prop (pr₁ (Group.e H-is-grp)) (transport _∈H cR (pr₂ ((H-is-grp Group.∙ x) ((H-is-grp Group.⁻¹) x)))) (pr₂ (Group.e H-is-grp))) where k = x .pr₁ cL : (h ∙ h ⁻¹ ∙ k ⁻¹) ∙ k ⁻¹ ⁻¹ = h ∙ h ⁻¹ cL = (h ∙ h ⁻¹ ∙ k ⁻¹) ∙ k ⁻¹ ⁻¹ =⟨ ap (h ∙ h ⁻¹ ∙ k ⁻¹ ∙_) (inv-inv k) ⟩ (h ∙ h ⁻¹ ∙ k ⁻¹) ∙ k =⟨ ap (_∙ k) (∙-assoc h (h ⁻¹) (k ⁻¹)) ⟩ h ∙ (h ⁻¹ ∙ k ⁻¹) ∙ k =⟨ ∙-assoc h (h ⁻¹ ∙ k ⁻¹) k ⟩ h ∙ ((h ⁻¹ ∙ k ⁻¹) ∙ k) =⟨ ap (h ∙_) (∙-assoc (h ⁻¹) (k ⁻¹) k) ⟩ h ∙ (h ⁻¹ ∙ (k ⁻¹ ∙ k)) =⟨ ap (h ∙_) (ap (h ⁻¹ ∙_) (cancel .pr₁)) ⟩ h ∙ (h ⁻¹ ∙ e) =⟨ ap (h ∙_) (neu-r (h ⁻¹)) ⟩ h ∙ h ⁻¹ ∎ cR : k ∙ (h ∙ h ⁻¹ ∙ k ⁻¹) ⁻¹ ⁻¹ = h ∙ h ⁻¹ cR = k ∙ (h ∙ h ⁻¹ ∙ k ⁻¹) ⁻¹ ⁻¹ =⟨ ap (k ∙_) (inv-inv (h ∙ h ⁻¹ ∙ k ⁻¹)) ⟩ k ∙ (h ∙ h ⁻¹ ∙ k ⁻¹) =⟨ ap (k ∙_) (ap (_∙ k ⁻¹) (cancel .pr₂)) ⟩ k ∙ (e ∙ k ⁻¹) =⟨ ap (k ∙_) (neu-l (k ⁻¹)) ⟩ k ∙ k ⁻¹ =⟨ cancel .pr₂ ⟩ e =⟨ sym (cancel .pr₂) ⟩ h ∙ h ⁻¹ ∎ ι : Σ x ꞉ G , x ∈H → G ι (x , _) = x is-subgroup : IsSubgroup {𝓤} (Σ x ꞉ G , x ∈H) G {{H-is-grp}} {{∈G}} is-subgroup = ι , (inj , is-hom) where inj : left-cancellable ι inj {x}{y} P = x =⟨ to-Σ-= (P , ∈H-is-prop (y .pr₁) (transport _∈H P (pr₂ x)) (y .pr₂)) ⟩ y ∎ is-hom : IsGroupHomomorphism (Σ x ꞉ G , x ∈H) G {{H-is-grp}} {{∈G}} ι is-hom (x , x∈H) (y , y∈H) = ι ((x , x∈H) ∙ᴴ (y , y∈H)) =⟨by-definition⟩ x ∙ y ⁻¹ ⁻¹ =⟨ ap (x ∙_) (inv-inv y) ⟩ x ∙ y =⟨by-definition⟩ ι (x , x∈H) ∙ ι (y , y∈H) ∎ where open Group H-is-grp renaming (_∙_ to _∙ᴴ_) hiding (_⁻¹)
Definition. Kernel [group-000A]
Definition. Kernel [group-000A]
module group-000A where open import MLTT.Spartan open import group-0000 open Group {{...}} open import group-0004
一個 Kernel 是指一個 group homomorphism 的 domain 的子集裡面,那些 maps 到 codomain 的 identity 的元素,所以這裡定義成
Ker : {𝓤 : Universe} (H G : 𝓤 ̇) {{_ : Group H}} {{_ : Group G}} (i : H → G) → IsGroupHomomorphism H G i → 𝓤 ̇ Ker H G i _ = Σ h ꞉ H , i h = e
Basic facts of Kernel [local-3]
Basic facts of Kernel [local-3]
Proposition. If is injective, then Kernel is singleton [group-000B]
Proposition. If is injective, then Kernel is singleton [group-000B]
module group-000B where open import MLTT.Spartan renaming (_⁻¹ to sym; _∙_ to _then_) open import UF.Base open import UF.Equiv open import group-0000 open Group {{...}} open import group-0004 open import group-0005 open import group-000A
這個命題是說,如果 group homomorphism i : H → G 是 inclusion,那 Kernel 的元素其實只有單位元素 eH。
proposition-8 : {H G : 𝓤 ̇} {{∈H : Group H}} {{∈G : Group G}} (i : H → G) → (is-hom : IsGroupHomomorphism H G i) → left-cancellable i → ((y : Ker H G i is-hom) → e = y .pr₁) proposition-8 {𝓤} {H}{G}{{∈H}}{{∈G}} i is-hom inclusion (h , p) = inclusion I where I : i e = i h I = (proposition-4 i is-hom) then (sym p)
這也順便說明了,用 Propopsition 4 就已經知道 Ker i 最少最少也有一個 eH,因此任何
Kernel 都不是空集合。 事實上這還可以說成,這樣 Kernel 就會跟
𝟙 同構,因為只有一個元素,這也表示這時候 Kernel 是 trivial
group。
proposition-8' : {H G : 𝓤 ̇} {{∈H : Group H}} {{∈G : Group G}} (i : H → G) → (is-hom : IsGroupHomomorphism H G i) → left-cancellable i → Ker H G i is-hom ≃ 𝟙 {𝓤} proposition-8' {𝓤} {H}{G}{{∈H}}{{∈G}} i is-hom inclusion = ι , (ρ , λ x → refl) , ρ , final where ι : Ker H G i is-hom → 𝟙 ι _ = ⋆ P4 = proposition-4 i is-hom ρ : 𝟙 → Ker H G i is-hom ρ ⋆ = e , P4 final : (x : Ker H G i is-hom) → ρ ⋆ = x final (k , hk) = ρ ⋆ =⟨by-definition⟩ e , P4 =⟨ to-Σ-= (I , size (transport (λ h → i h = e) I P4) hk) ⟩ k , hk ∎ where I : e = k I = inclusion (i e =⟨ P4 ⟩ e =⟨ sym hk ⟩ i k ∎)
Proposition. Normal subgroup equivalent condition [group-000C]
Proposition. Normal subgroup equivalent condition [group-000C]
module group-000C where open import MLTT.Spartan renaming (_⁻¹ to sym; _∙_ to _then_) open import group-0000 open Group {{...}} open import group-0004 open import group-0006
為了避免複雜的編碼,下面直接根據需求定義。
這個命題是說,任何 φ : H → G 的 Kernel 都是 H 的 normal subgroup。 所以我們想要證明的是對於任何屬於 Kernel 的元素 h,元素 g • h • g−1 也屬於 Kernel。
前面已經提過 φ 的 Kernel
的定義是 φh = e
的那些元素,因此定義 x ∈Ker[ φ , φ-is-hom ] 為
φ x = e。
_∈Ker[_,_] : {H G : 𝓤 ̇} {{∈H : Group H}} {{∈G : Group G}} (h : H) → (φ : H → G) → IsGroupHomomorphism H G φ → 𝓤 ̇ h ∈Ker[ φ , is-hom ] = φ h = e
明確提供
IsGroupHomomorphism是無奈之舉,因為以目前的定義方式,如果把IsGroupHomomorphism設為隱式參數,agda 會找不到而留下一個未解的變量。
proposition-9 : {H G : 𝓤 ̇} {{∈H : Group H}} {{∈G : Group G}} (f : H → G) → (is-hom : IsGroupHomomorphism H G f) → ((h : H) → h ∈Ker[ f , is-hom ] → (g : H) → g ∙ h ∙ g ⁻¹ ∈Ker[ f , is-hom ]) proposition-9 {𝓤} {H}{G}{{∈H}}{{∈G}} f is-hom h in-ker g = I where I : f (g ∙ h ∙ g ⁻¹) = e I = f (g ∙ h ∙ g ⁻¹) =⟨ is-hom (g ∙ h) (g ⁻¹) ⟩ f (g ∙ h) ∙ f (g ⁻¹) =⟨ ap (_∙ f (g ⁻¹)) (is-hom g h) ⟩ f g ∙ f h ∙ f (g ⁻¹) =⟨ ap (f g ∙ f h ∙_) (proposition-5 f is-hom g) ⟩ f g ∙ f h ∙ f g ⁻¹ =⟨ ap (λ x → f g ∙ x ∙ f g ⁻¹) in-ker ⟩
因為 h 屬於 Kernel 所以 f h 可以換成
e
f g ∙ e ∙ f g ⁻¹ =⟨ ap (_∙ f g ⁻¹) (neu-r (f g)) ⟩ f g ∙ f g ⁻¹ =⟨ cancel .pr₂ ⟩ e ∎
Proposition. 群可以視為一個範疇 [group-000D]
Proposition. 群可以視為一個範疇 [group-000D]
open import UF.FunExt module group-000D (fe : Fun-Ext) where open import MLTT.Spartan renaming (_⁻¹ to sym; _∙_ to _then_) open import Categories.Category fe open import group-0000 open Group {{...}}
最後我們就用範疇論的常見笑話:群也可以視為一個範疇作為群論的收尾
group-is-cat : (G : 𝓥 ̇ ) {{_ : Group G}} → precategory 𝓤 𝓥 group-is-cat {𝓥}{𝓤} G = make str axioms where
這個範疇只會有一個物件,所以型別是 𝟙
ob = 𝟙
這個範疇的 hom-set 就是群 G
hom : 𝟙 → 𝟙 → 𝓥 ̇ hom ⋆ ⋆ = G
物件 x 的 identity hom
idx 由
G 的 identity element 提供
idn : 𝟙 → G idn ⋆ = e
⊚ 表示 hom 的組合,計算上由 G 的 operation
提供
⊚ : (A B C : 𝟙) → (f g : G) → G ⊚ ⋆ ⋆ ⋆ f g = f ∙ g
這些構成了範疇論需要的基本資料
str : category-structure 𝓤 𝓥 str = ob , hom , idn , ⊚
我們需要證明它滿足範疇論所有 hom 的性質
- hom-set 是一個集合
- idx 接 f 等於 f
- f 接 idx 等於 f
- associativity 的性質
這些都是直接繼承 G 自己的性質。
axioms : precategory-axioms str axioms = (λ A B → size) , (λ A B → neu-l) , (λ A B → neu-r) , final where final : (A B C D : 𝟙) → (f g h : G) → ⊚ A B D f (⊚ B C D g h) = ⊚ A C D (⊚ A B C f g) h final A B C D f g h = ⊚ A B D f (⊚ B C D g h) =⟨by-definition⟩ f ∙ (g ∙ h) =⟨ sym (∙-assoc f g h) ⟩ (f ∙ g) ∙ h =⟨by-definition⟩ ⊚ A C D (⊚ A B C f g) h ∎
Ring Theory [alg-0001]
Ring Theory [alg-0001]
Definition. 環 Ring [ring-0000]
Definition. 環 Ring [ring-0000]
module ring-0000 where open import MLTT.Spartan open import UF.Sets
record Ring (R : 𝓤 ̇ ) : 𝓤 ̇ where field size : is-set R _+ᴿ_ : R → R → R +-assoc : associative _+ᴿ_ +-comm : commutative _+ᴿ_ 0r : R +-neuL : left-neutral 0r _+ᴿ_ +-neuR : right-neutral 0r _+ᴿ_ -_ : R → R cancel : {x : R} → (x +ᴿ - x = 0r) _·_ : R → R → R ·-assoc : associative _·_ 1r : R ·-neuL : left-neutral 1r _·_ ·-neuR : right-neutral 1r _·_ distribL : {r s t : R} → (r +ᴿ s) · t = (r · t) +ᴿ (s · t) distribR : {r s t : R} → t · (r +ᴿ s) = (t · r) +ᴿ (t · s) infixl 30 _+ᴿ_ infixl 41 _·_ infixl 50 -_
下面這個命題是因為 (R, ⊕, 0R) 也可以看成一個 commutative group,因此也可以取消共相加的元素來得到結果。其實就是「若 x + 2 = y + 2 則 x = y」
open Ring {{...}} ring-cancel-right : {R : 𝓤 ̇ } → {{_ : Ring R}} {r s t : R} → s +ᴿ r = t +ᴿ r → s = t ring-cancel-right {R}{_} {r}{s}{t} fact = s =⟨ +-neuR s ⁻¹ ⟩ s +ᴿ 0r =⟨ ap (s +ᴿ_) (cancel ⁻¹) ⟩ s +ᴿ (r +ᴿ - r) =⟨ +-assoc s r (- r) ⁻¹ ⟩ s +ᴿ r +ᴿ - r =⟨ ap (_+ᴿ - r) fact ⟩ t +ᴿ r +ᴿ - r =⟨ +-assoc t r (- r) ⟩ t +ᴿ (r +ᴿ - r) =⟨ ap (t +ᴿ_) cancel ⟩ t +ᴿ 0r =⟨ +-neuR t ⟩ t ∎
Example. trivial ring [ring-0001]
Example. trivial ring [ring-0001]
module ring-0001 where open import MLTT.Spartan open import UF.Subsingletons open import UF.Subsingletons-Properties open import UF.Equiv open import ring-0000 open Ring {{...}} open import ring-0002
Trivial ring 就像前面群論提過的 trivial group,在 trivial ring 裡加法、乘法都一樣,因為作為只有一個元素的集合,能選擇的 n-元運算都只有一個。 也因此下面的 terms 幾乎都可以由 agda 自動填滿
trivial-ring : Ring (𝟙 {𝓤}) trivial-ring .size = props-are-sets 𝟙-is-prop trivial-ring ._+ᴿ_ _ _ = ⋆ trivial-ring .0r = ⋆ trivial-ring .+-assoc = λ x y z → refl trivial-ring .+-neuL = λ x → refl trivial-ring .+-neuR = λ x → refl trivial-ring .-_ _ = ⋆ trivial-ring .cancel = refl trivial-ring .+-comm = λ x y → refl trivial-ring ._·_ _ _ = ⋆ trivial-ring .·-assoc = λ x y z → refl trivial-ring .1r = ⋆ trivial-ring .·-neuL = λ x → refl trivial-ring .·-neuR = λ x → refl trivial-ring .distribL = refl trivial-ring .distribR = refl
事實上如果 Ring R 的 1 = 0,那麼 R 只有一個元素
0=1-leads-trivial-ring : {R : 𝓤 ̇ } → {{∈R : Ring R}} → 1r = 0r → 𝟙 {𝓤} ≃ R 0=1-leads-trivial-ring {𝓤}{R} 1=0 = (λ _ → 0r) , (ι , λ x → every-elem-is-0 x ⁻¹) , (ι , λ _ → refl) where ι : R → 𝟙 {𝓤} ι _ = ⋆ every-elem-is-0 : ∀ (x : R) → x = 0r every-elem-is-0 x = x =⟨ ·-neuR x ⁻¹ ⟩ x · 1r =⟨ ap (x ·_) 1=0 ⟩ x · 0r =⟨ lemma-1 x .pr₁ ⟩
這裡雖然用了等一下才要證明的定理,但任何元素乘上 0 等於 0 應該是很直覺的想法
0r ∎
Lemma. Multiply 0 is 0 [ring-0002]
Lemma. Multiply 0 is 0 [ring-0002]
module ring-0002 where open import MLTT.Spartan open import ring-0000 open Ring {{...}}
lemma-1 : {R : 𝓤 ̇ } {{_ : Ring R}} → (r : R) → (r · 0r = 0r) × (0r · r = 0r) lemma-1 r = (ring-cancel-right I ⁻¹) , (ring-cancel-right II ⁻¹) where I : 0r +ᴿ r · 0r = r · 0r +ᴿ r · 0r I = 0r +ᴿ r · 0r =⟨ +-neuL (r · 0r) ⟩ r · 0r =⟨ ap (r ·_) (+-neuL 0r ⁻¹) ⟩ r · (0r +ᴿ 0r) =⟨ distribR ⟩ r · 0r +ᴿ r · 0r ∎ II : 0r +ᴿ 0r · r = 0r · r +ᴿ 0r · r II = 0r +ᴿ 0r · r =⟨ +-neuL (0r · r) ⟩ 0r · r =⟨ ap (_· r) (+-neuL 0r ⁻¹) ⟩ (0r +ᴿ 0r) · r =⟨ distribL ⟩ 0r · r +ᴿ 0r · r ∎
Proposition. 負負得正 [ring-0003]
Proposition. 負負得正 [ring-0003]
module ring-0003 where open import MLTT.Spartan open import ring-0000 open Ring {{...}} open import ring-0002
負負得正通常可能在說兩件事。第一,− − a = a,因為 −a 的反元素是 a 也可以是 − − a,因此 − − a 一定等於 a(因為 Ring 的加法部分是一個 commutative group)。
neg-neg-lemma : {R : 𝓤 ̇ } {{_ : Ring R}} (x : R) → - - x = x neg-neg-lemma x = ring-cancel-right (I ∙ II ⁻¹) where I : - - x +ᴿ - x = 0r I = (+-comm (- - x) (- x)) ∙ cancel II : x +ᴿ - x = 0r II = cancel
或是更重要的 −a × −b = a × b,也就是這裡要證明的命題
neg-lemma-left : {R : 𝓤 ̇ } {{_ : Ring R}} (a b : R) → - a · b = - (a · b) neg-lemma-left a b = ring-cancel-right (II ∙ I ⁻¹) where I : (- (a · b)) +ᴿ a · b = 0r I = (- (a · b)) +ᴿ a · b =⟨ (+-comm (- (a · b)) (a · b)) ∙ cancel ⟩ 0r ∎ II : (- a · b) +ᴿ a · b = 0r II = (- a · b) +ᴿ a · b =⟨ distribL ⁻¹ ⟩ (- a +ᴿ a) · b =⟨ ap (_· b) ((+-comm (- a) a) ∙ cancel) ⟩ 0r · b =⟨ lemma-1 b .pr₂ ⟩ 0r ∎ neg-lemma-right : {R : 𝓤 ̇ } {{_ : Ring R}} (a b : R) → a · - b = - (a · b) neg-lemma-right a b = ring-cancel-right (II ∙ I ⁻¹) where I : (- (a · b)) +ᴿ a · b = 0r I = (+-comm (- (a · b)) (a · b)) ∙ cancel II : (a · - b) +ᴿ a · b = 0r II = (a · - b) +ᴿ a · b =⟨ distribR ⁻¹ ⟩ a · (- b +ᴿ b) =⟨ ap (a ·_) ((+-comm (- b) b) ∙ cancel) ⟩ a · 0r =⟨ lemma-1 a .pr₁ ⟩ 0r ∎ proposition-2 : {R : 𝓤 ̇ } {{_ : Ring R}} → (a b : R) → - a · - b = a · b proposition-2 {_}{R} a b = (- a · - b) =⟨ neg-lemma-left a (- b) ⟩ - (a · - b) =⟨ ap -_ (neg-lemma-right a b) ⟩ - - (a · b) =⟨ neg-neg-lemma (a · b) ⟩ a · b ∎
Definition. Non zero-divisor [ring-0004]
Definition. Non zero-divisor [ring-0004]
module ring-0004 where open import MLTT.Spartan open import ring-0000 open Ring {{...}}
一個 Ring R 中的元素 a 是 zero divisor 就表示存在 b ≠ 0 ∈ R 使 ab = 0。 所以我們稱 a 是 non zero-divisor 指如果 ab = 0,那 b 一定等於 0。
NonZeroDivisor : {R : 𝓤 ̇ } {{_ : Ring R}} (a : R) → 𝓤 ̇ NonZeroDivisor {_}{R} a = (b : R) → (a · b = 0r → b = 0r)
(Left) Action [ring-0006]
(Left) Action [ring-0006]
module ring-0006 where open import MLTT.Spartan open import ring-0000 open Ring {{...}}
一個 Ring R 中的元素 a 所謂的 (left) action 是指
x ↦ a ⋅ x
R → R 這樣的 map,通常記為 La。所謂的 (right) action 可想而知,在乘法交換的 commutative ring 中兩種 action 並沒有差異,這時候定義通常跟那個領域的慣例有關。
left-action : {R : 𝓤 ̇ } {{_ : Ring R}} (a : R) → R → R left-action a x = a · x right-action : {R : 𝓤 ̇ } {{_ : Ring R}} (a : R) → R → R right-action a x = x · a
Proposition. An element is not a (left) zero divisor if and only if (left) action is injective [ring-0005]
Proposition. An element is not a (left) zero divisor if and only if (left) action is injective [ring-0005]
不是 zero divisor 若且唯若其 left action 是 injective(也就是 left-cancellable)
module ring-0005 where open import MLTT.Spartan open import ring-0000 open Ring {{...}} open import ring-0002 open import ring-0003 open import ring-0004 open import ring-0006
proposition-3 : {R : 𝓤 ̇ } {{_ : Ring R}} {a : R} → NonZeroDivisor a ↔ left-cancellable (left-action a) proposition-3 {_}{R}{a} = if , only-if where if : NonZeroDivisor a → left-cancellable (left-action a) if is-not-zd {x}{y} Ax=Ay = ring-cancel-right (II ∙ III ⁻¹) where I : left-action a (x +ᴿ - y) = 0r I = left-action a (x +ᴿ - y) =⟨by-definition⟩ a · (x +ᴿ - y) =⟨ distribR ⟩ a · x +ᴿ a · - y =⟨ ap (a · x +ᴿ_) (neg-lemma-right a y) ⟩ a · x +ᴿ - (a · y) =⟨ ap (_+ᴿ - (a · y)) Ax=Ay ⟩ a · y +ᴿ - (a · y) =⟨ cancel ⟩ 0r ∎ II : x +ᴿ - y = 0r II = is-not-zd (x +ᴿ - y) I III : y +ᴿ - y = 0r III = cancel only-if : left-cancellable (left-action a) → NonZeroDivisor a only-if inj b ab=0 = inj I where I : a · b = a · 0r I = left-action a b =⟨by-definition⟩ a · b =⟨ ab=0 ⟩ 0r =⟨ lemma-1 a .pr₁ ⁻¹ ⟩ a · 0r =⟨by-definition⟩ left-action a 0r ∎
(Left) Unit [ring-0007]
(Left) Unit [ring-0007]
module ring-0007 where open import MLTT.Spartan open import ring-0000 open Ring {{...}}
- u 是 left unit 的意思是存在 v 使 u ⋅ v = 1
- u 是 right unit 的意思是存在 v 使 v ⋅ u = 1
is-left-unit : {R : 𝓤 ̇ } {{_ : Ring R}} → R → 𝓤 ̇ is-left-unit {_} {R} u = Σ v ꞉ R , u · v = 1r is-right-unit : {R : 𝓤 ̇ } {{_ : Ring R}} → R → 𝓤 ̇ is-right-unit {_} {R} u = Σ v ꞉ R , v · u = 1r
Proposition. An element is a (left) unit if and only if (left) action has a section [ring-0008]
Proposition. An element is a (left) unit if and only if (left) action has a section [ring-0008]
module ring-0008 where open import MLTT.Spartan open import UF.Retracts open import ring-0000 open Ring {{...}} open import ring-0006 open import ring-0007
proposition-4 : {R : 𝓤 ̇ } {{_ : Ring R}} → (u : R) → is-left-unit u ↔ has-section (left-action u) proposition-4 {_} {R} u = if , only-if where if : is-left-unit u → has-section (left-action u) if (v , mul-to-one) = left-action v , iso-to-id where iso-to-id : (r : R) → (left-action u (left-action v r)) = r iso-to-id r = (left-action u (left-action v r)) =⟨by-definition⟩ u · (v · r) =⟨ ·-assoc u v r ⁻¹ ⟩ (u · v) · r =⟨ ap (_· r) mul-to-one ⟩ 1r · r =⟨ ·-neuL r ⟩ r ∎ only-if : has-section (left-action u) → is-left-unit u only-if (sec , to-id) = sec 1r , to-id 1r
Proposition. If an element is a (left) unit then its (right) action is injective [ring-0009]
Proposition. If an element is a (left) unit then its (right) action is injective [ring-0009]
module ring-0009 where open import MLTT.Spartan open import UF.Retracts open import ring-0000 open Ring {{...}} open import ring-0006 open import ring-0007
proposition-5 : {R : 𝓤 ̇ } {{_ : Ring R}} → (u : R) → is-left-unit u → left-cancellable (right-action u) proposition-5 u (v , uv=1) {x}{y} xu=yu = x =⟨ ·-neuR x ⁻¹ ⟩ x · 1r =⟨ ap (x ·_) (uv=1 ⁻¹) ⟩ x · (u · v) =⟨ ·-assoc x u v ⁻¹ ⟩ x · u · v =⟨ ap (_· v) xu=yu ⟩ y · u · v =⟨ ·-assoc y u v ⟩ y · (u · v) =⟨ ap (y ·_) uv=1 ⟩ y · 1r =⟨ ·-neuR y ⟩ y ∎
Proposition. Multiplication inverse of two sided unit is unique [ring-000A]
Proposition. Multiplication inverse of two sided unit is unique [ring-000A]
module ring-000A where open import MLTT.Spartan open import ring-0000 open Ring {{...}} open import ring-0007
proposition-6 : {R : 𝓤 ̇ } {{_ : Ring R}} → (u : R) → (L : is-left-unit u) → (R : is-right-unit u) → L .pr₁ = R .pr₁ proposition-6 u (v , uv=1) (k , ku=1) = v =⟨ ·-neuL v ⁻¹ ⟩ 1r · v =⟨ ap (_· v) (ku=1 ⁻¹) ⟩ k · u · v =⟨ ·-assoc k u v ⟩ k · (u · v) =⟨ ap (k ·_) uv=1 ⟩ k · 1r =⟨ ·-neuR k ⟩ k ∎
Definition. Ideal [ring-000B]
Definition. Ideal [ring-000B]
module ring-000B where open import MLTT.Spartan open import UF.Powerset open import ring-0000 open Ring {{...}}
record IsIdeal {R : 𝓤 ̇ } {{_ : Ring R}} (I : 𝓟 R) : 𝓤 ̇ where no-eta-equality field close-+ : ∀ {i} {i2} → i ∈ I → i2 ∈ I → (i +ᴿ i2) ∈ I close-neg : ∀ {i} → i ∈ I → (- i) ∈ I closeL : ∀ r {i} → i ∈ I → r · i ∈ I closeR : ∀ r {i} → i ∈ I → i · r ∈ I
Proposition. Ideals contain zero [ring-000C]
Proposition. Ideals contain zero [ring-000C]
module ring-000C where open import MLTT.Spartan open import UF.Powerset open import ring-0000 open Ring {{...}} open import ring-000B
這個命題說每個 Ideal 都有元素 0
proposition-7 : {R : 𝓤 ̇ } {{_ : Ring R}} {i : R} (I : 𝓟 R) → IsIdeal I → i ∈ I → 0r ∈ I proposition-7 {_}{R} {i} I is-ideal i∈I = transport (_∈ I) cancel m where open IsIdeal is-ideal neg : - i ∈ I neg = close-neg i∈I m : (i +ᴿ - i) ∈ I m = close-+ i∈I neg
Proposition. Ideals 相加的構造還是一個 ideal [ring-000D]
Proposition. Ideals 相加的構造還是一個 ideal [ring-000D]
open import UF.PropTrunc module ring-000D (pt : propositional-truncations-exist) where open import MLTT.Spartan open import UF.Powerset open import UF.SubtypeClassifier open import UF.Subsingletons open import ring-0000 open Ring {{...}} open import ring-000B open import ring-000C open PropositionalTruncation pt
如果 I 跟 J 是 R 的 ideals,那麼
I + J := {i + j ∣ i ∈ I, j ∈ J}
也是 R 的 ideal。
T : {R : 𝓤 ̇ } {{_ : Ring R}} → (I J : 𝓟 R) → (r : R) → 𝓤 ̇ T {_}{R} I J r = Σ i ꞉ R , Σ j ꞉ R , (i ∈ I) × (j ∈ J) × (r = i +ᴿ j) _+ᴵ_ : {R : 𝓤 ̇ } {{_ : Ring R}} → (I J : 𝓟 R) → 𝓟 R _+ᴵ_ {_}{R} I J r = ∥ T I J r ∥ , ∥∥-is-prop
使用 propositional truncation ∥_∥
來表示「存在某種分解」。下面開始證明
proposition-8 : {R : 𝓤 ̇ } {{_ : Ring R}} {I J : 𝓟 R} → IsIdeal I → IsIdeal J → IsIdeal (I +ᴵ J) proposition-8 {_}{R}{I}{J} I-is-ideal J-is-ideal = main where open IsIdeal main : IsIdeal (I +ᴵ J) main .close-+ {i1}{i2} = ∥∥-rec₂ ∥∥-is-prop helper where helper : T I J i1 → T I J i2 → ∥ T I J (i1 +ᴿ i2) ∥ helper (a1 , a2 , a1∈I , a2∈J , i=a1+a2) (b1 , b2 , b1∈I , b2∈J , j=b1+b2) = ∣ a1 +ᴿ b1 , a2 +ᴿ b2 , I-is-ideal .close-+ a1∈I b1∈I , J-is-ideal .close-+ a2∈J b2∈J , res ∣ where res : i1 +ᴿ i2 = (a1 +ᴿ b1) +ᴿ (a2 +ᴿ b2) res = i1 +ᴿ i2 =⟨ ap (_+ᴿ i2) i=a1+a2 ⟩ (a1 +ᴿ a2) +ᴿ i2 =⟨ ap (a1 +ᴿ a2 +ᴿ_) j=b1+b2 ⟩ (a1 +ᴿ a2) +ᴿ (b1 +ᴿ b2) =⟨ +-assoc (a1 +ᴿ a2) b1 b2 ⁻¹ ⟩ (a1 +ᴿ a2 +ᴿ b1) +ᴿ b2 =⟨ ap (_+ᴿ b2) (+-assoc a1 a2 b1) ⟩ (a1 +ᴿ (a2 +ᴿ b1)) +ᴿ b2 =⟨ ap (λ - → a1 +ᴿ - +ᴿ b2) (+-comm a2 b1) ⟩ (a1 +ᴿ (b1 +ᴿ a2)) +ᴿ b2 =⟨ ap (_+ᴿ b2) (+-assoc a1 b1 a2 ⁻¹) ⟩ (a1 +ᴿ b1 +ᴿ a2) +ᴿ b2 =⟨ +-assoc (a1 +ᴿ b1) a2 b2 ⟩ (a1 +ᴿ b1) +ᴿ (a2 +ᴿ b2) ∎ main .close-neg {i} = ∥∥-rec ∥∥-is-prop helper where helper : T I J i → ∥ T I J (- i) ∥ helper (a , b , a∈I , b∈J , i=a+b) = ∣ - a , - b , (I-is-ideal .close-neg a∈I , J-is-ideal .close-neg b∈J , res) ∣ where P : ((- a) +ᴿ (- b)) +ᴿ (a +ᴿ b) = 0r P = ((- a) +ᴿ (- b)) +ᴿ (a +ᴿ b) =⟨ ap (_+ᴿ (a +ᴿ b)) (+-comm (- a) (- b)) ⟩ ((- b) +ᴿ (- a)) +ᴿ (a +ᴿ b) =⟨ +-assoc (- b) (- a) (a +ᴿ b) ⟩ (- b) +ᴿ ((- a) +ᴿ (a +ᴿ b)) =⟨ ap ((- b) +ᴿ_) (+-assoc (- a) a b ⁻¹) ⟩ (- b) +ᴿ ((- a) +ᴿ a +ᴿ b) =⟨ ap (- b +ᴿ_) (ap (_+ᴿ b) ((+-comm (- a) a) ∙ cancel)) ⟩ (- b) +ᴿ (0r +ᴿ b) =⟨ ap (- b +ᴿ_) (+-neuL b) ⟩ (- b) +ᴿ b =⟨ ((+-comm (- b) b) ∙ cancel) ⟩ 0r ∎ Q : - (a +ᴿ b) +ᴿ (a +ᴿ b) = 0r Q = - (a +ᴿ b) +ᴿ (a +ᴿ b) =⟨ +-comm (- (a +ᴿ b)) (a +ᴿ b) ⟩ (a +ᴿ b) +ᴿ - (a +ᴿ b) =⟨ cancel ⟩ 0r ∎ res : - i = (- a) +ᴿ (- b) res = - i =⟨ ap -_ i=a+b ⟩ - (a +ᴿ b) =⟨ ring-cancel-right (Q ∙ P ⁻¹) ⟩ (- a) +ᴿ (- b) ∎ main .closeL r {i} = ∥∥-rec ∥∥-is-prop helper where helper : T I J i → ∥ T I J (r · i) ∥ helper (a , b , a∈I , b∈J , i=a+b) = ∣ r · a , r · b , I-is-ideal .closeL r a∈I , J-is-ideal .closeL r b∈J , res ∣ where res : r · i = r · a +ᴿ r · b res = r · i =⟨ ap (r ·_) i=a+b ⟩ r · (a +ᴿ b) =⟨ distribR ⟩ r · a +ᴿ r · b ∎ main .closeR r {i} = ∥∥-rec ∥∥-is-prop helper where helper : T I J i → ∥ T I J (i · r) ∥ helper (a , b , a∈I , b∈J , i=a+b) = ∣ a · r , b · r , I-is-ideal .closeR r a∈I , J-is-ideal .closeR r b∈J , res ∣ where res : i · r = a · r +ᴿ b · r res = i · r =⟨ ap (_· r) i=a+b ⟩ (a +ᴿ b) · r =⟨ distribL ⟩ a · r +ᴿ b · r ∎
近期更新 [recent-changes]
近期更新 [recent-changes]
這部分會定期建立 update-XXXX 中成為新貼文。
[update-0005]
[update-0005]
- 2026/5/30 建立 代數理論的 presentation
- 2026/4/29 建立 關於交換群 Eckmann–Hilton argument
[update-0004]
[update-0004]
- 建立 Ideals 相加的構造還是一個 ideal
- 建立 Ideals contain zero
- 建立 Ideal
- Subgroup equivalent condition 新增更簡單的證明
- 更新 Group Theory 中的地址
- Multiplication inverse of two sided unit is unique title 更新
[update-0003]
[update-0003]
- 更新 Trivial group is a subgroup of all groups 的說明
- Multiplication inverse of two sided unit is unique
- If an element is a (left) unit then its (right) action is injective
- An element is a (left) unit if and only if (left) action has a section
- (Left) Unit
- (Left) Action
- An element is not a (left) zero divisor if and only if (left) action is injective
- Non zero-divisor
- 負負得正
- 開始寫 Ring 理論
[update-0002]
[update-0002]
- Group 可以視為 Category
- TypeTopology 的定義會跳到 TypeTopology 網站
- Normal subgroup 的相關命題 Normal subgroup equivalent condition
- Kernel 的相關命題 If is injective, then Kernel is singleton
- Kernel 的定義 Kernel
[update-0001]
[update-0001]
- 證明比較有挑戰性的子群等價條件 Subgroup equivalent condition
[update-0000]
[update-0000]
- 從 https://github.com/dannypsnl/blackboard 移植初步定義建立程式庫