From 1cff95c652aaf5033ebab195c973a14a720f7d7f Mon Sep 17 00:00:00 2001 From: Patrick Stevens Date: Fri, 10 Apr 2020 09:24:53 +0100 Subject: [PATCH] UFD progress (#108) --- Everything/Safe.agda | 2 +- Rings/Divisible/Definition.agda | 1 - Rings/Divisible/Lemmas.agda | 30 ++++++++++ Rings/Irreducibles/Lemmas.agda | 1 - .../Definition.agda | 51 +++++++++++++---- Rings/UniqueFactorisationDomains/Lemmas.agda | 57 +++++++++++++++++++ Vectors.agda | 23 ++++++++ 7 files changed, 152 insertions(+), 13 deletions(-) create mode 100644 Rings/Divisible/Lemmas.agda create mode 100644 Rings/UniqueFactorisationDomains/Lemmas.agda diff --git a/Everything/Safe.agda b/Everything/Safe.agda index 96da870..014ed6d 100644 --- a/Everything/Safe.agda +++ b/Everything/Safe.agda @@ -81,7 +81,7 @@ open import Rings.Subrings.Definition open import Rings.Ideals.Maximal.Lemmas open import Rings.Primes.Lemmas open import Rings.Irreducibles.Definition -open import Rings.Divisible.Definition +open import Rings.Divisible.Lemmas open import Rings.Associates.Lemmas open import Rings.InitialRing open import Rings.Homomorphisms.Lemmas diff --git a/Rings/Divisible/Definition.agda b/Rings/Divisible/Definition.agda index d6c1a1d..177488e 100644 --- a/Rings/Divisible/Definition.agda +++ b/Rings/Divisible/Definition.agda @@ -6,7 +6,6 @@ open import Functions open import Sets.EquivalenceRelations open import Rings.Definition - module Rings.Divisible.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where open Setoid S diff --git a/Rings/Divisible/Lemmas.agda b/Rings/Divisible/Lemmas.agda new file mode 100644 index 0000000..84c027d --- /dev/null +++ b/Rings/Divisible/Lemmas.agda @@ -0,0 +1,30 @@ +{-# OPTIONS --safe --warning=error --without-K #-} + +open import LogicalFormulae +open import Setoids.Setoids +open import Functions +open import Sets.EquivalenceRelations +open import Rings.Definition + +module Rings.Divisible.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where + +open Setoid S +open Equivalence eq +open Ring R +open import Rings.Divisible.Definition R +open import Rings.Units.Definition R + +divisionTransitive : (x y z : A) → x ∣ y → y ∣ z → x ∣ z +divisionTransitive x y z (a , pr) (b , pr2) = (a * b) , transitive (transitive *Associative (*WellDefined pr reflexive)) pr2 + +divisionReflexive : (x : A) → x ∣ x +divisionReflexive x = 1R , transitive *Commutative identIsIdent + +everythingDividesZero : (r : A) → r ∣ 0R +everythingDividesZero r = 0R , timesZero + +nonzeroInherits : {x y : A} (nz : (x ∼ 0R) → False) → y ∣ x → (y ∼ 0R) → False +nonzeroInherits {x} {y} nz (c , pr) y=0 = nz (transitive (symmetric pr) (transitive (*WellDefined y=0 reflexive) (transitive *Commutative timesZero))) + +nonunitInherits : {x y : A} (nonunit : Unit x → False) → x ∣ y → Unit y → False +nonunitInherits nu (s , pr) (a , b) = nu ((s * a) , transitive (transitive *Associative (*WellDefined pr reflexive)) b) diff --git a/Rings/Irreducibles/Lemmas.agda b/Rings/Irreducibles/Lemmas.agda index eef3c5e..62dc11d 100644 --- a/Rings/Irreducibles/Lemmas.agda +++ b/Rings/Irreducibles/Lemmas.agda @@ -6,7 +6,6 @@ open import Sets.EquivalenceRelations open import Rings.IntegralDomains.Definition open import Rings.Definition - module Rings.Irreducibles.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where open import Rings.Irreducibles.Definition intDom diff --git a/Rings/UniqueFactorisationDomains/Definition.agda b/Rings/UniqueFactorisationDomains/Definition.agda index 6a626b3..2048777 100644 --- a/Rings/UniqueFactorisationDomains/Definition.agda +++ b/Rings/UniqueFactorisationDomains/Definition.agda @@ -4,7 +4,10 @@ open import LogicalFormulae open import Setoids.Setoids open import Rings.Definition open import Rings.IntegralDomains.Definition -open import Lists.Lists +open import Vectors +open import Numbers.Naturals.Semiring +open import Numbers.Naturals.Order +open import Numbers.Naturals.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) @@ -12,16 +15,44 @@ module Rings.UniqueFactorisationDomains.Definition {a b : _} {A : Set a} {S : Se open import Rings.Units.Definition R open import Rings.Irreducibles.Definition intDom +open import Rings.Associates.Definition intDom +open import Rings.Primes.Definition intDom open Ring R open Setoid S -record Factorisation {r : A} (nonzero : (r ∼ 0R) → False) (nonunit : (Unit r) → False) : Set (a ⊔ b) where - field - factorise : List A - factoriseIsFactorisation : fold (_*_) 1R factorise ∼ r - factoriseIsIrreducibles : allTrue Irreducible factorise +private + power : A → ℕ → A + power x zero = 1R + power x (succ n) = x * power x n ---record UFD : Set (a ⊔ b) where --- field --- factorisation : {r : A} → (nonzero : (r ∼ 0R) → False) → (nonunit : (Unit r) → False) → Factorisation nonzero nonunit --- uniqueFactorisation : {r : A} → (nonzero : (r ∼ 0R) → False) → (nonunit : (Unit r) → False) → (f1 f2 : Factorisation nonzero nonunit) → {!Sg !} + allDistinct : {n : ℕ} → Vec A n → Set (a ⊔ b) + allDistinct [] = True' + allDistinct (x ,- xs) = (allDistinct xs) && vecAllTrue (λ n → (n ∼ x) → False) xs + +record Factorisation {r : A} .(nonzero : (r ∼ 0R) → False) .(nonunit : (Unit r) → False) : Set (a ⊔ b) where + field + len : ℕ + factorise : Vec (A && ℕ) len + factoriseIsFactorisation : vecFold (λ x y → y * power (_&&_.fst x) (succ (_&&_.snd x))) 1R factorise ∼ r + factoriseIsIrreducibles : vecAllTrue Irreducible (vecMap _&&_.fst factorise) + distinct : allDistinct (vecMap _&&_.fst factorise) + +private + equality : {n : ℕ} (v1 v2 : Vec (A && ℕ) n) → Set (a ⊔ b) + equality [] [] = True' + equality {succ n} ((a ,, an) ,- v1) v2 = Sg ℕ (λ index → Sg (index