# Probability / Numbers.agda

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44``` ```open import Algebra module Numbers where open import Level open import Relation.Binary record Nums : Set₁ where field commRing : CommutativeRing zero zero module CR = CommutativeRing commRing hiding ( isEquivalence ; trans ; zero ; reflexive) renaming (Carrier to Num) open CR field _≤_ : Rel Num _ isTotalOrder : IsTotalOrder _≈_ _≤_ 0≤_ : Num → Set 0≤_ n = 0# ≤ n field +-monotonicity : _+_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_ 0≤1 : 0≤ 1# -- это легко доказывается. см. замечания в Probability a≈b→c+a≈c+b : ∀ {a b} → a ≈ b → ∀ c → c + a ≈ c + b totalOrder : TotalOrder zero zero zero totalOrder = record { Carrier = Num; _≈_ = _≈_; _≤_ = _≤_; isTotalOrder = isTotalOrder } module TO = TotalOrder totalOrder hiding (_≤_ ; _≈_ ; isTotalOrder ; refl) open TO public open CR public import Relation.Binary.PartialOrderReasoning as POR open POR {{...}} open import Data.Product using (proj₁ ; proj₂) 0≤b→a+b≈c→a≤c : ∀ {a b c} → 0# ≤ b → a + b ≈ c → a ≤ c 0≤b→a+b≈c→a≤c {a} {b} {c} 0≤b a+b≈c = begin a ≈⟨ sym (proj₂ +-identity _) ⟩ a + 0# ≤⟨ +-monotonicity (reflexive refl) 0≤b ⟩ a + b ≈⟨ a+b≈c ⟩ c ∎ ```