Reals form a ring (#59)

This commit is contained in:
Patrick Stevens
2019-11-02 08:34:09 +00:00
committed by GitHub
parent df1ac6a303
commit a66080b8ae
22 changed files with 155 additions and 51 deletions

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields

View File

@@ -5,7 +5,7 @@ open import Orders
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields
@@ -49,18 +49,18 @@ approxLemma a e e/2 0<e prE/2 m N ans | inl (inr x) with <WellDefined (Equivalen
approxLemma a e e/2 0<e prE/2 m N ans | inr x with transferToRight additiveGroup (Equivalence.symmetric eq x)
... | bl = <WellDefined (+WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq bl)) groupIsAbelian (orderRespectsAddition (halfLess e/2 e 0<e prE/2) (index (CauchyCompletion.elts a) N))
approximateAboveCrude : (0R 1R False) (a : CauchyCompletion) Sg A (λ b (a <Cr b))
approximateAboveCrude 0!=1 a with CauchyCompletion.converges a 1R (0<1 0!=1)
... | N , conv = ((((index (CauchyCompletion.elts a) (succ N)) + 1R) + 1R) + 1R) , (1R , (0<1 0!=1 ,, (N , ans)))
approximateAboveCrude : (a : CauchyCompletion) Sg A (λ b (a <Cr b))
approximateAboveCrude a with CauchyCompletion.converges a 1R (0<1 (charNot2ImpliesNontrivial charNot2))
... | N , conv = ((((index (CauchyCompletion.elts a) (succ N)) + 1R) + 1R) + 1R) , (1R , (0<1 (charNot2ImpliesNontrivial charNot2) ,, (N , ans)))
where
ans : (m : ) (N <N m) (1R + index (CauchyCompletion.elts a) m) < (((index (CauchyCompletion.elts a) (succ N) + 1R) + 1R) + 1R)
ans m N<m with conv {m} {succ N} N<m (le 0 refl)
... | bl with totality 0G (index (CauchyCompletion.elts a) m + inverse (index (CauchyCompletion.elts a) (succ N)))
ans m N<m | bl | inl (inl 0<am-aN) with <WellDefined (Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.symmetric eq +Associative) (+WellDefined (Equivalence.reflexive eq) (invLeft))) identRight) (Equivalence.reflexive eq) (orderRespectsAddition bl (index (CauchyCompletion.elts a) (succ N)))
... | am<1+an = <WellDefined (Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq) identLeft) groupIsAbelian) (Equivalence.transitive eq (+WellDefined groupIsAbelian (Equivalence.reflexive eq)) +Associative) (ringAddInequalities am<1+an (orderRespectsAddition (0<1 0!=1) 1R))
... | am<1+an = <WellDefined (Equivalence.transitive eq (+WellDefined (Equivalence.reflexive eq) identLeft) groupIsAbelian) (Equivalence.transitive eq (+WellDefined groupIsAbelian (Equivalence.reflexive eq)) +Associative) (ringAddInequalities am<1+an (orderRespectsAddition (0<1 (charNot2ImpliesNontrivial charNot2)) 1R))
ans m N<m | bl | inl (inr am-aN<0) with <WellDefined (Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.symmetric eq +Associative) (+WellDefined (Equivalence.reflexive eq) invLeft)) identRight) identLeft (orderRespectsAddition am-aN<0 (index (CauchyCompletion.elts a) (succ N)))
... | am<aN = <WellDefined groupIsAbelian (Equivalence.reflexive eq) (orderRespectsAddition (SetoidPartialOrder.transitive pOrder am<aN (<WellDefined (Equivalence.reflexive eq) (+Associative) (<WellDefined identLeft groupIsAbelian (orderRespectsAddition (<WellDefined identLeft (Equivalence.reflexive eq) (ringAddInequalities (0<1 0!=1) (0<1 0!=1))) (index (CauchyCompletion.elts a) (succ N)))))) 1R)
ans m N<m | bl | inr 0=am-aN = <WellDefined (Equivalence.transitive eq (+WellDefined identLeft (Equivalence.reflexive eq)) identLeft) (Equivalence.transitive eq groupIsAbelian (Equivalence.transitive eq (+WellDefined (Equivalence.transitive eq groupIsAbelian (+WellDefined (transferToRight additiveGroup (Equivalence.symmetric eq 0=am-aN)) (Equivalence.reflexive eq))) (Equivalence.reflexive eq)) +Associative)) (orderRespectsAddition (ringAddInequalities (0<1 0!=1) (0<1 0!=1)) (1R + (index (CauchyCompletion.elts a) m)))
... | am<aN = <WellDefined groupIsAbelian (Equivalence.reflexive eq) (orderRespectsAddition (SetoidPartialOrder.transitive pOrder am<aN (<WellDefined (Equivalence.reflexive eq) (+Associative) (<WellDefined identLeft groupIsAbelian (orderRespectsAddition (<WellDefined identLeft (Equivalence.reflexive eq) (ringAddInequalities (0<1 (charNot2ImpliesNontrivial charNot2)) (0<1 (charNot2ImpliesNontrivial charNot2)))) (index (CauchyCompletion.elts a) (succ N)))))) 1R)
ans m N<m | bl | inr 0=am-aN = <WellDefined (Equivalence.transitive eq (+WellDefined identLeft (Equivalence.reflexive eq)) identLeft) (Equivalence.transitive eq groupIsAbelian (Equivalence.transitive eq (+WellDefined (Equivalence.transitive eq groupIsAbelian (+WellDefined (transferToRight additiveGroup (Equivalence.symmetric eq 0=am-aN)) (Equivalence.reflexive eq))) (Equivalence.reflexive eq)) +Associative)) (orderRespectsAddition (ringAddInequalities (0<1 (charNot2ImpliesNontrivial charNot2)) (0<1 (charNot2ImpliesNontrivial charNot2))) (1R + (index (CauchyCompletion.elts a) m)))
rationalApproximatelyAbove : (a : CauchyCompletion) (e : A) (0G < e) A
rationalApproximatelyAbove a e 0<e with halve charNot2 e
@@ -136,67 +136,61 @@ approximateBelow a e 0<e with approximateAbove (-C a) e 0<e
pr1 m N<m with prBound m N<m
... | bl rewrite indexAndApply (CauchyCompletion.elts a) (map inverse (constSequence (inverse x))) _+_ {m} | equalityCommutative (mapAndIndex (constSequence (inverse x)) inverse m) | indexAndConst x m | indexAndApply (constSequence x) (map inverse (map inverse (CauchyCompletion.elts a))) _+_ {m} | indexAndConst x m | equalityCommutative (mapAndIndex (map inverse (CauchyCompletion.elts a)) inverse m) | equalityCommutative (mapAndIndex (CauchyCompletion.elts a) inverse m) | indexAndConst (inverse x) m = <WellDefined (+WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq groupIsAbelian (+WellDefined (invTwice additiveGroup _) (Equivalence.symmetric eq (invTwice additiveGroup _))))) (Equivalence.reflexive eq) bl
boundModulus' : (0R < 1R) (a : CauchyCompletion) Sg A (λ b Sg (λ N (m : ) (N <N m) (abs (index (CauchyCompletion.elts a) m)) < b))
boundModulus' 0!=1 a with approximateBelow a 1R 0!=1
... | below , (below<a ,, a-below<e) with approximateAbove a 1R 0!=1
boundModulus : (a : CauchyCompletion) Sg A (λ b Sg (λ N (m : ) (N <N m) (abs (index (CauchyCompletion.elts a) m)) < b))
boundModulus a with approximateBelow a 1R (0<1 (charNot2ImpliesNontrivial charNot2))
... | below , (below<a ,, a-below<e) with approximateAbove a 1R (0<1 (charNot2ImpliesNontrivial charNot2))
... | above , (a<above ,, above-a<e) with SetoidTotalOrder.totality tOrder 0R below
boundModulus' 0!=1 a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inl 0<below) with SetoidTotalOrder.totality tOrder 0R above
boundModulus' 0!=1 a | below , ((belowBound , (0<belowBound ,, (Nbelow , prBelow))) ,, a-below<e) | above , ((bound , (0<bound ,, (N , ans))) ,, above-a<e) | inl (inl 0<below) | inl (inl 0<above) = above , ((N +N Nbelow) , λ m N<m SetoidPartialOrder.transitive pOrder (res m N<m) (ans m (inequalityShrinkLeft N<m)))
boundModulus a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inl 0<below) with SetoidTotalOrder.totality tOrder 0R above
boundModulus a | below , ((belowBound , (0<belowBound ,, (Nbelow , prBelow))) ,, a-below<e) | above , ((bound , (0<bound ,, (N , ans))) ,, above-a<e) | inl (inl 0<below) | inl (inl 0<above) = above , ((N +N Nbelow) , λ m N<m SetoidPartialOrder.transitive pOrder (res m N<m) (ans m (inequalityShrinkLeft N<m)))
where
res : (m : ) ((N +N Nbelow) <N m) (abs (index (CauchyCompletion.elts a) m)) < (bound + index (CauchyCompletion.elts a) m)
res m N<m with SetoidTotalOrder.totality tOrder 0R (index (CauchyCompletion.elts a) m)
res m N<m | inl (inl _) = <WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<bound (index (CauchyCompletion.elts a) m))
res m N<m | inl (inr am<0) = exFalso (irreflexive (SetoidPartialOrder.transitive pOrder 0<below (SetoidPartialOrder.transitive pOrder (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft groupIsAbelian (orderRespectsAddition 0<belowBound below)) (prBelow m (inequalityShrinkRight N<m))) am<0)))
res m N<m | inr 0=am = <WellDefined 0=am (Equivalence.transitive eq (Equivalence.symmetric eq identRight) (+WellDefined (Equivalence.reflexive eq) 0=am)) 0<bound
boundModulus' 0!=1 a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inl 0<below) | inl (inr above<0) = exFalso (irreflexive (SetoidPartialOrder.transitive pOrder 0<below (SetoidPartialOrder.transitive pOrder (chain a below<a a<above) above<0)))
boundModulus' 0!=1 a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inl 0<below) | inr 0=above = exFalso (irreflexive (SetoidPartialOrder.transitive pOrder 0<below (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq 0=above) (chain a below<a a<above))))
boundModulus' 0!=1 a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inr below<0) with SetoidTotalOrder.totality tOrder 0R above
boundModulus' 0!=1 a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) with SetoidTotalOrder.totality tOrder (inverse below) above
boundModulus' 0!=1 a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) | inl (inl -bel<ab) = above , ((N +N Nabove) , ans)
boundModulus a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inl 0<below) | inl (inr above<0) = exFalso (irreflexive (SetoidPartialOrder.transitive pOrder 0<below (SetoidPartialOrder.transitive pOrder (chain a below<a a<above) above<0)))
boundModulus a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inl 0<below) | inr 0=above = exFalso (irreflexive (SetoidPartialOrder.transitive pOrder 0<below (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq 0=above) (chain a below<a a<above))))
boundModulus a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inr below<0) with SetoidTotalOrder.totality tOrder 0R above
boundModulus a | below , (below<a ,, a-below<e) | above , (a<above ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) with SetoidTotalOrder.totality tOrder (inverse below) above
boundModulus a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) | inl (inl -bel<ab) = above , ((N +N Nabove) , ans)
where
ans : (m : ) (N +N Nabove <N m) abs (index (CauchyCompletion.elts a) m) < above
ans m N<m with SetoidTotalOrder.totality tOrder 0G (index (CauchyCompletion.elts a) m)
ans m N<m | inl (inl 0<am) = SetoidPartialOrder.transitive pOrder (<WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<boundAbove (index (CauchyCompletion.elts a) m))) (prBoundAbove m (inequalityShrinkRight N<m))
ans m N<m | inl (inr am<0) = SetoidPartialOrder.transitive pOrder (ringSwapNegatives' (prBoundBelow m (inequalityShrinkLeft N<m))) (SetoidPartialOrder.transitive pOrder (ringSwapNegatives' (<WellDefined identLeft groupIsAbelian (orderRespectsAddition 0<boundBelow below))) -bel<ab)
ans m N<m | inr 0=am = <WellDefined 0=am (Equivalence.reflexive eq) 0<above
boundModulus' 0!=1 a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) | inl (inr ab<-bel) = inverse below , ((N +N Nabove) , ans)
boundModulus a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) | inl (inr ab<-bel) = inverse below , ((N +N Nabove) , ans)
where
ans : (m : ) (N +N Nabove <N m) abs (index (CauchyCompletion.elts a) m) < (inverse below)
ans m N<m with SetoidTotalOrder.totality tOrder 0G (index (CauchyCompletion.elts a) m)
ans m N<m | inl (inl 0<am) = SetoidPartialOrder.transitive pOrder (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<boundAbove (index (CauchyCompletion.elts a) m))) (prBoundAbove m (inequalityShrinkRight N<m))) ab<-bel
ans m N<m | inl (inr am<0) = ringSwapNegatives' (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft groupIsAbelian (orderRespectsAddition 0<boundBelow below)) (prBoundBelow m (inequalityShrinkLeft N<m)))
ans m N<m | inr 0=am = <WellDefined 0=am (Equivalence.reflexive eq) (lemm2 below below<0)
boundModulus' 0!=1 a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) | inr -bel=ab = above , ((N +N Nabove) , ans)
boundModulus a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inl 0<above) | inr -bel=ab = above , ((N +N Nabove) , ans)
where
ans : (m : ) (N +N Nabove <N m) abs (index (CauchyCompletion.elts a) m) < above
ans m N<m with SetoidTotalOrder.totality tOrder 0G (index (CauchyCompletion.elts a) m)
ans m N<m | inl (inl 0<am) = SetoidPartialOrder.transitive pOrder (<WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<boundAbove (index (CauchyCompletion.elts a) m))) (prBoundAbove m (inequalityShrinkRight N<m))
ans m N<m | inl (inr am<0) = <WellDefined (Equivalence.reflexive eq) (-bel=ab) (ringSwapNegatives' (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft groupIsAbelian (orderRespectsAddition 0<boundBelow below)) (prBoundBelow m (inequalityShrinkLeft N<m))))
ans m N<m | inr 0=am = <WellDefined 0=am (Equivalence.reflexive eq) 0<above
boundModulus' 0!=1 a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inr above<0) = inverse below , ((N +N Nabove) , ans)
boundModulus a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inl (inr above<0) = inverse below , ((N +N Nabove) , ans)
where
ans : (m : ) ((N +N Nabove) <N m) abs (index (CauchyCompletion.elts a) m) < inverse below
ans m N<m with SetoidTotalOrder.totality tOrder 0R (index (CauchyCompletion.elts a) m)
ans m N<m | inl (inl 0<am) = exFalso (irreflexive {0G} (SetoidPartialOrder.transitive pOrder 0<am (SetoidPartialOrder.transitive pOrder (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<boundAbove (index (CauchyCompletion.elts a) m))) (prBoundAbove m (inequalityShrinkRight N<m))) above<0)))
ans m N<m | inl (inr am<0) = ringSwapNegatives' (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft groupIsAbelian (orderRespectsAddition 0<boundBelow below)) (prBoundBelow m (inequalityShrinkLeft N<m)))
ans m N<m | inr 0=am = exFalso (irreflexive {0G} (<WellDefined (Equivalence.symmetric eq 0=am) (Equivalence.reflexive eq) (SetoidPartialOrder.transitive pOrder (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<boundAbove (index (CauchyCompletion.elts a) m))) (prBoundAbove m (inequalityShrinkRight N<m))) above<0)))
boundModulus' 0!=1 a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inr 0=above = inverse below , ((N +N Nabove) , ans)
boundModulus a | below , ((boundBelow , (0<boundBelow ,, (N , prBoundBelow))) ,, a-below<e) | above , ((boundAbove , (0<boundAbove ,, (Nabove , prBoundAbove))) ,, above-a<e) | inl (inr below<0) | inr 0=above = inverse below , ((N +N Nabove) , ans)
where
ans : (m : ) ((N +N Nabove) <N m) abs (index (CauchyCompletion.elts a) m) < inverse below
ans m N<m with SetoidTotalOrder.totality tOrder 0R (index (CauchyCompletion.elts a) m)
ans m N<m | inl (inl 0<am) = exFalso (irreflexive {0G} (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq 0=above) (SetoidPartialOrder.transitive pOrder 0<am (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<boundAbove (index (CauchyCompletion.elts a) m))) (prBoundAbove m (inequalityShrinkRight N<m))))))
ans m N<m | inl (inr am<0) = ringSwapNegatives' (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft groupIsAbelian (orderRespectsAddition 0<boundBelow below)) (prBoundBelow m (inequalityShrinkLeft N<m)))
ans m N<m | inr 0=am = <WellDefined 0=am (Equivalence.reflexive eq) (lemm2 _ below<0)
boundModulus' 0!=1 a | below , ((boundBelow , ((boundBelowDiff ,, (Nb , ansBelow)))) ,, a-below<e) | above , ((bound , (0<bound ,, (N , ans))) ,, above-a<e) | inr 0=below = above , ((N +N Nb) , λ m N<m SetoidPartialOrder.transitive pOrder (res m N<m) (ans m (inequalityShrinkLeft N<m)))
boundModulus a | below , ((boundBelow , ((boundBelowDiff ,, (Nb , ansBelow)))) ,, a-below<e) | above , ((bound , (0<bound ,, (N , ans))) ,, above-a<e) | inr 0=below = above , ((N +N Nb) , λ m N<m SetoidPartialOrder.transitive pOrder (res m N<m) (ans m (inequalityShrinkLeft N<m)))
where
res : (m : ) (N +N Nb) <N m (abs (index (CauchyCompletion.elts a) m)) < (bound + index (CauchyCompletion.elts a) m)
res m N<m with SetoidTotalOrder.totality tOrder 0R (index (CauchyCompletion.elts a) m)
res m N<m | inl (inl 0<am) = <WellDefined identLeft (Equivalence.reflexive eq) (orderRespectsAddition 0<bound (index (CauchyCompletion.elts a) m))
res m N<m | inl (inr am<0) = exFalso (irreflexive (<WellDefined (Equivalence.symmetric eq 0=below) (Equivalence.reflexive eq) (SetoidPartialOrder.transitive pOrder (SetoidPartialOrder.transitive pOrder (<WellDefined identLeft groupIsAbelian (orderRespectsAddition boundBelowDiff below)) (ansBelow m (inequalityShrinkRight N<m))) am<0)))
res m N<m | inr 0=am = <WellDefined 0=am (Equivalence.transitive eq (Equivalence.symmetric eq identRight) (+WellDefined (Equivalence.reflexive eq) 0=am)) 0<bound
boundModulus : (0G 1R False) (a : CauchyCompletion) Sg A (λ b Sg (λ N (m : ) (N <N m) (abs (index (CauchyCompletion.elts a) m)) < b))
boundModulus with SetoidTotalOrder.totality tOrder 0R 1R
... | inl (inl 0<1) = λ _ boundModulus' 0<1
... | inl (inr 1<0) = exFalso (1<0False 1<0)
... | inr (0=1) = λ bad exFalso (bad 0=1)

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields

View File

@@ -0,0 +1,102 @@
{-# OPTIONS --safe --warning=error --without-K --guardedness #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields
open import Sets.EquivalenceRelations
open import Sequences
open import Setoids.Orders
open import Functions
open import LogicalFormulae
open import Numbers.Naturals.Naturals
module Fields.CauchyCompletion.EquivalentMonotone {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A A A} {_*_ : A A A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {tOrder : SetoidTotalOrder {_<_ = _<_} pOrder} {R : Ring S _+_ _*_} (order : OrderedRing R tOrder) (F : Field R) (charNot2 : Setoid.__ S ((Ring.1R R) + (Ring.1R R)) (Ring.0R R) False) where
open Setoid S
open SetoidTotalOrder tOrder
open SetoidPartialOrder pOrder
open Equivalence eq
open OrderedRing order
open Field F
open Group (Ring.additiveGroup R)
open Ring R
open import Fields.Lemmas F
open import Fields.Orders.Lemmas {F = F} record { oRing = order }
open import Rings.Orders.Lemmas(order)
open import Fields.CauchyCompletion.Definition order F
open import Fields.CauchyCompletion.Multiplication order F charNot2
open import Fields.CauchyCompletion.Addition order F charNot2
open import Fields.CauchyCompletion.Setoid order F charNot2
open import Fields.CauchyCompletion.Group order F charNot2
open import Fields.CauchyCompletion.Ring order F charNot2
open import Fields.CauchyCompletion.Comparison order F charNot2
open import Fields.CauchyCompletion.Approximation order F charNot2
halvingSequence : (start : A) Sequence A
Sequence.head (halvingSequence start) = start
Sequence.tail (halvingSequence start) with halve charNot2 start
Sequence.tail (halvingSequence start) | start/2 , _ = halvingSequence start/2
halvingSequenceMultiple : (start : A) {n : } index (halvingSequence start) n index (map (start *_) (halvingSequence (Ring.1R R))) n
halvingSequenceMultiple start {zero} = Equivalence.symmetric eq (Equivalence.transitive eq *Commutative identIsIdent)
halvingSequenceMultiple start {succ n} with halve charNot2 start
... | start/2 , _ with allInvertible (1R + 1R) charNot2
halvingSequenceMultiple start {succ n} | start/2 , b | 1/2 , pr1/2 rewrite equalityCommutative (mapAndIndex (halvingSequence (1R * 1/2)) (_*_ start) n) = Equivalence.transitive eq (halvingSequenceMultiple start/2 {n}) f
where
g : (start * (1/2 * index (halvingSequence 1R) n)) (start * index (map (_*_ (1R * 1/2)) (halvingSequence 1R)) n)
g rewrite equalityCommutative (mapAndIndex (halvingSequence 1R) (_*_ (1R * 1/2)) n) = *WellDefined (Equivalence.reflexive eq) (*WellDefined (Equivalence.symmetric eq identIsIdent) (Equivalence.reflexive eq))
f : index (map (_*_ start/2) (halvingSequence 1R)) n (start * index (halvingSequence (1R * 1/2)) n)
f rewrite equalityCommutative (mapAndIndex (halvingSequence 1R) (_*_ start/2) n) = Equivalence.transitive eq (Equivalence.transitive eq (Equivalence.transitive eq (*WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (*WellDefined (Equivalence.symmetric eq b) (Equivalence.reflexive eq)) (halfHalves 1/2 (Equivalence.transitive eq (Equivalence.transitive eq (+WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq *Commutative identIsIdent)) (Equivalence.symmetric eq (Equivalence.transitive eq *Commutative identIsIdent))) (Equivalence.symmetric eq *DistributesOver+)) pr1/2)))) (Equivalence.reflexive eq)) (Equivalence.symmetric eq *Associative)) g) (Equivalence.symmetric eq (*WellDefined (Equivalence.reflexive eq) (halvingSequenceMultiple (1R * 1/2) {n})))
Decreasing : Sequence A Set o
Decreasing seq = (N : ) (index seq (succ N)) < (index seq N)
halvingSequencePositive : (n : ) 0G < index (halvingSequence 1R) n
halvingSequencePositive zero = 0<1 (charNot2ImpliesNontrivial charNot2)
halvingSequencePositive (succ n) with halve charNot2 1R
halvingSequencePositive (succ n) | 1/2 , pr1/2 = <WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq (Equivalence.transitive eq (halvingSequenceMultiple 1/2 {n}) (Equivalence.transitive eq (identityOfIndiscernablesLeft __ (Equivalence.reflexive eq) (mapAndIndex (halvingSequence 1R) (_*_ 1/2) n)) *Commutative))) (orderRespectsMultiplication (halvingSequencePositive n) (halvePositive 1/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq pr1/2) (0<1 (charNot2ImpliesNontrivial charNot2)))))
decreasingHalving : Decreasing (halvingSequence 1R)
decreasingHalving N with halve charNot2 1R
decreasingHalving N | 1/2 , pr1/2 with (halfLess 1/2 1R (0<1 (charNot2ImpliesNontrivial charNot2)) pr1/2)
... | 1/2<1 = <WellDefined (Equivalence.transitive eq (identityOfIndiscernablesLeft __ (Equivalence.reflexive eq) (equalityCommutative (mapAndIndex (halvingSequence 1R) (_*_ 1/2) N))) (Equivalence.symmetric eq (halvingSequenceMultiple 1/2 {N}))) identIsIdent (ringCanMultiplyByPositive {c = index (halvingSequence 1R) N} (halvingSequencePositive N) 1/2<1)
halvesCauchy : cauchy (halvingSequence 1R)
halvesCauchy e 0<e = {!!}
multipleOfCauchyIsCauchy : (mult : A) (seq : Sequence A) cauchy seq cauchy (map (mult *_) seq)
multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e with SetoidTotalOrder.totality tOrder 0R mult
multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e | inl (inl x) with allInvertible mult λ pr irreflexive (<WellDefined (Equivalence.reflexive eq) pr x)
... | 1/mult , pr1/mult = {!!}
multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e | inl (inr x) with allInvertible mult λ pr irreflexive (<WellDefined pr (Equivalence.reflexive eq) x)
... | 1/mult , pr1/mult = {!!}
multipleOfCauchyIsCauchy mult seq seqCauchy e 0<e | inr 0=mult = 0 , ans
where
ans : {m n : } (0 <N m) (0 <N n) abs (index (map (_*_ mult) seq) m + inverse (index (map (_*_ mult) seq) n)) < e
ans {m} {n} _ _ rewrite equalityCommutative (mapAndIndex seq (_*_ mult) m) | equalityCommutative (mapAndIndex seq (_*_ mult) n) = <WellDefined {!!} (Equivalence.reflexive eq) 0<e
halvingSequenceCauchy : (start : A) cauchy (halvingSequence start)
halvingSequenceCauchy start = {!!}
sequenceAllAbove : (a : CauchyCompletion) Sequence A
sequenceAllAbove a = go (Ring.1R R) (0<1 (charNot2ImpliesNontrivial charNot2))
where
go : (e : A) (0G < e) Sequence A
Sequence.head (go e 0<e) = rationalApproximatelyAbove a e 0<e
Sequence.tail (go e 0<e) with halve charNot2 e
... | e/2 , prE/2 = go e/2 (halvePositive e/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq prE/2) 0<e))
sequenceAllAboveCauchy : (a : CauchyCompletion) cauchy (sequenceAllAbove a)
sequenceAllAboveCauchy a e 0<e = {!!}
-- find N such that 1/2^N < e
-- show that this N is enough
-- show that sequenceAllAbove a
-- monotonify sequenceAllAbove
-- show that monotonify of a sequence which is all above its limit still converges to that limit

View File

@@ -45,8 +45,11 @@ boundedMap a | inl (inl x) = underlying (allInvertible a λ pr → irreflexive (
boundedMap a | inl (inr x) = underlying (allInvertible a λ pr irreflexive (<WellDefined pr (Equivalence.reflexive eq) x))
boundedMap a | inr x = Ring.1R R
aNonzeroImpliesBounded : (a : CauchyCompletion) (Setoid.__ cauchyCompletionSetoid a (injection 0G) False) (a <C (injection 0G)) || (injection 0G) <C a
aNonzeroImpliesBounded a a!=0 = ?
-- TODO: make a real which is equivalent by approximating from above;
-- make a real which is equivalent by approximating from below.
-- Use not-zero to show that one of those sequences must pass 0 at some point.
aNonzeroImpliesBounded : (a : CauchyCompletion) (Setoid.__ cauchyCompletionSetoid a (injection 0G) False) (a <Cr 0G) || 0G r<C a
aNonzeroImpliesBounded a a!=0 = {!!}
1/aConverges : (a : CauchyCompletion) (Setoid.__ cauchyCompletionSetoid a (injection 0G) False) cauchy (map boundedMap (CauchyCompletion.elts a))
1/aConverges a a!=0 e 0<e = {!!}

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields
@@ -44,8 +44,8 @@ littleLemma {a} {b} {c} {d} = Equivalence.transitive eq (Equivalence.transitive
_*C_ : CauchyCompletion CauchyCompletion CauchyCompletion
CauchyCompletion.elts (record { elts = a ; converges = aConv } *C record { elts = b ; converges = bConv }) = apply _*_ a b
CauchyCompletion.converges (record { elts = a ; converges = aConv } *C record { elts = b ; converges = bConv }) e 0<e with boundModulus (0!=1 0<e) record { elts = a ; converges = aConv }
... | aBound , (Na , prABound) with boundModulus (0!=1 0<e) record { elts = b ; converges = bConv }
CauchyCompletion.converges (record { elts = a ; converges = aConv } *C record { elts = b ; converges = bConv }) e 0<e with boundModulus record { elts = a ; converges = aConv }
... | aBound , (Na , prABound) with boundModulus record { elts = b ; converges = bConv }
... | bBound , (Nb , prBBound) = N , ans
where
boundBoth : A
@@ -162,7 +162,7 @@ multiplicationWellDefinedLeft' : (0!=1 : 0R 1R → False) (a b c : CauchyCom
multiplicationWellDefinedLeft' 0!=1 a b c a=b ε 0<e = N , ans
where
cBoundAndPr : Sg A (λ b Sg (λ N (m : ) (N <N m) (abs (index (CauchyCompletion.elts c) m)) < b))
cBoundAndPr = boundModulus 0!=1 c
cBoundAndPr = boundModulus c
cBound : A
cBound with cBoundAndPr
... | a , _ = a

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields

View File

@@ -5,7 +5,7 @@ open import Groups.Groups
open import Groups.Definition
open import Groups.Lemmas
open import Rings.Definition
open import Rings.Order
open import Rings.Orders.Definition
open import Rings.Orders.Lemmas
open import Rings.Lemmas
open import Rings.IntegralDomains

View File

@@ -4,7 +4,7 @@ open import LogicalFormulae
open import Groups.Groups
open import Groups.Definition
open import Rings.Definition
open import Rings.Order
open import Rings.Orders.Definition
open import Rings.Lemmas
open import Setoids.Setoids
open import Setoids.Orders

View File

@@ -4,7 +4,7 @@ open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Lemmas
open import Rings.Order
open import Rings.Orders.Definition
open import Groups.Definition
open import Groups.Groups
open import Fields.Fields

View File

@@ -4,7 +4,7 @@ open import LogicalFormulae
open import Groups.Groups
open import Groups.Definition
open import Rings.Definition
open import Rings.Order
open import Rings.Orders.Definition
open import Rings.Lemmas
open import Setoids.Setoids
open import Setoids.Orders

View File

@@ -4,7 +4,7 @@ open import LogicalFormulae
open import Groups.Groups
open import Groups.Definition
open import Rings.Definition
open import Rings.Order
open import Rings.Orders.Definition
open import Rings.Lemmas
open import Setoids.Setoids
open import Setoids.Orders