From 96e0e284a61547b310719953180eef4a40ad1238 Mon Sep 17 00:00:00 2001 From: shhyou Date: Wed, 29 Oct 2025 10:55:44 +0800 Subject: [PATCH] [ release ] rollback doc for version 2.3 The current v2.3 doc is slightly ahead of the v2.3 release, causing it to be slightly out-of-sync, e.g., Data.Fin.Properties shows extra, newer definitions. This commit re-generates the doc of agda-stdlib 2.3. --- ...ess.Properties.HeytingCommutativeRing.html | 22 +- v2.3/Algebra.Apartness.Structures.html | 6 +- v2.3/Algebra.Bundles.html | 152 +- v2.3/Algebra.Construct.DirectProduct.html | 134 +- v2.3/Algebra.Construct.Flip.Op.html | 649 ++- v2.3/Algebra.Construct.LexProduct.Inner.html | 38 +- v2.3/Algebra.Construct.LexProduct.html | 4 +- v2.3/Algebra.Construct.Pointwise.html | 146 +- v2.3/Algebra.Construct.Subst.Equality.html | 38 +- v2.3/Algebra.Definitions.html | 30 +- ...bra.Lattice.Properties.BooleanAlgebra.html | 62 +- v2.3/Algebra.Module.Bundles.html | 4 +- ...Algebra.Module.Construct.Idealization.html | 32 +- v2.3/Algebra.Module.Construct.TensorUnit.html | 52 +- ....Module.Morphism.BimoduleMonomorphism.html | 12 +- ...ule.Morphism.BisemimoduleMonomorphism.html | 6 +- ...odule.Morphism.LeftModuleMonomorphism.html | 8 +- ...e.Morphism.LeftSemimoduleMonomorphism.html | 4 +- ...ra.Module.Morphism.ModuleHomomorphism.html | 4 +- ...ra.Module.Morphism.ModuleMonomorphism.html | 8 +- ...dule.Morphism.RightModuleMonomorphism.html | 8 +- ....Morphism.RightSemimoduleMonomorphism.html | 4 +- ...odule.Morphism.SemimoduleMonomorphism.html | 8 +- .../Algebra.Module.Properties.Semimodule.html | 6 +- v2.3/Algebra.Module.Structures.Biased.html | 8 +- v2.3/Algebra.Morphism.RingMonomorphism.html | 28 +- ...rties.CancellativeCommutativeSemiring.html | 10 +- ...bra.Properties.CommutativeMonoid.Mult.html | 2 +- ...ebra.Properties.CommutativeMonoid.Sum.html | 26 +- ...ies.CommutativeSemigroup.Divisibility.html | 88 +- ...gebra.Properties.CommutativeSemigroup.html | 257 +- ...operties.CommutativeSemiring.Binomial.html | 6 +- ...s.CommutativeSemiring.Exp.TCOptimised.html | 2 +- v2.3/Algebra.Properties.Group.html | 18 +- ...roperties.IdempotentCommutativeMonoid.html | 40 +- v2.3/Algebra.Properties.KleeneAlgebra.html | 98 +- v2.3/Algebra.Properties.Loop.html | 8 +- ...Algebra.Properties.Magma.Divisibility.html | 12 +- v2.3/Algebra.Properties.MiddleBolLoop.html | 18 +- v2.3/Algebra.Properties.MoufangLoop.html | 22 +- v2.3/Algebra.Properties.Quasigroup.html | 12 +- v2.3/Algebra.Properties.Ring.html | 4 +- v2.3/Algebra.Properties.RingWithoutOne.html | 108 +- .../Algebra.Properties.Semiring.Binomial.html | 428 +- ...ebra.Properties.Semiring.Divisibility.html | 4 +- ...a.Properties.Semiring.Exp.TCOptimised.html | 6 +- ...s.Semiring.Exp.TailRecursiveOptimised.html | 12 +- v2.3/Algebra.Properties.Semiring.Exp.html | 20 +- ....Properties.Semiring.Mult.TCOptimised.html | 4 +- v2.3/Algebra.Properties.Semiring.Mult.html | 20 +- ...Algebra.Properties.Semiring.Primality.html | 2 +- v2.3/Algebra.Properties.Semiring.Sum.html | 8 +- ...gebra.Solver.CommutativeMonoid.Normal.html | 222 +- v2.3/Algebra.Solver.CommutativeMonoid.html | 2 +- ...er.IdempotentCommutativeMonoid.Normal.html | 12 +- v2.3/Algebra.Solver.Monoid.Normal.html | 2 +- ...bra.Solver.Ring.AlmostCommutativeRing.html | 12 +- v2.3/Algebra.Solver.Ring.Lemmas.html | 74 +- v2.3/Algebra.Solver.Ring.html | 54 +- v2.3/Algebra.Structures.Biased.html | 100 +- v2.3/Algebra.Structures.html | 1347 +++--- ...ata.Guarded.Stream.Relation.Unary.Any.html | 6 +- .../Codata.Musical.Colist.Infinite-merge.html | 4 +- ....Colist.Relation.Unary.Any.Properties.html | 4 +- v2.3/Codata.Musical.Colist.html | 4 +- v2.3/Data.Bool.Properties.html | 50 +- v2.3/Data.Char.Properties.html | 24 +- .../Data.Container.Combinator.Properties.html | 4 +- v2.3/Data.Digit.Properties.html | 10 +- v2.3/Data.Digit.html | 42 +- v2.3/Data.Fin.Base.html | 6 +- v2.3/Data.Fin.Induction.html | 36 +- v2.3/Data.Fin.Instances.html | 6 +- v2.3/Data.Fin.Literals.html | 4 +- v2.3/Data.Fin.Permutation.Components.html | 142 +- ...ta.Fin.Permutation.Transposition.List.html | 40 +- v2.3/Data.Fin.Permutation.html | 670 +-- v2.3/Data.Fin.Properties.html | 2427 +++++----- v2.3/Data.Fin.Show.html | 6 +- v2.3/Data.Fin.Subset.Induction.html | 4 +- v2.3/Data.Fin.Subset.Properties.html | 906 ++-- v2.3/Data.Fin.html | 4 +- v2.3/Data.Graph.Acyclic.html | 12 +- v2.3/Data.Integer.Base.html | 4 +- v2.3/Data.Integer.DivMod.html | 4 +- v2.3/Data.Integer.Divisibility.Signed.html | 4 +- v2.3/Data.Integer.Properties.NatLemmas.html | 38 +- v2.3/Data.Integer.Properties.html | 384 +- v2.3/Data.List.Countdown.html | 18 +- v2.3/Data.List.Extrema.Nat.html | 8 +- ...st.Fresh.Membership.Setoid.Properties.html | 14 +- ...t.Fresh.Relation.Unary.Any.Properties.html | 6 +- v2.3/Data.List.Fresh.Relation.Unary.Any.html | 6 +- ...t.Membership.Propositional.Properties.html | 22 +- ...ata.List.Membership.Setoid.Properties.html | 16 +- v2.3/Data.List.Properties.html | 70 +- ...ist.Relation.Binary.BagAndSetEquality.html | 8 +- ...Binary.Infix.Heterogeneous.Properties.html | 18 +- v2.3/Data.List.Relation.Binary.Lex.html | 8 +- ...ry.Permutation.Algorithmic.Properties.html | 86 - ...lation.Binary.Permutation.Algorithmic.html | 152 - ...ry.Permutation.Declarative.Properties.html | 67 - ...lation.Binary.Permutation.Declarative.html | 117 - ...lation.Binary.Permutation.Homogeneous.html | 10 +- ....Binary.Permutation.Setoid.Properties.html | 30 +- v2.3/Data.List.Relation.Binary.Pointwise.html | 10 +- ...inary.Prefix.Heterogeneous.Properties.html | 8 +- ...nary.Sublist.Heterogeneous.Properties.html | 34 +- ...n.Binary.Sublist.Heterogeneous.Solver.html | 2 +- ...tion.Binary.Sublist.Setoid.Properties.html | 2 +- ...ation.Binary.Subset.Setoid.Properties.html | 4 +- ...inary.Suffix.Heterogeneous.Properties.html | 28 +- ...ation.Ternary.Interleaving.Properties.html | 4 +- ...st.Relation.Unary.All.Properties.Core.html | 6 +- ...ta.List.Relation.Unary.All.Properties.html | 14 +- ...st.Relation.Unary.AllPairs.Properties.html | 10 +- ...ta.List.Relation.Unary.Any.Properties.html | 10 +- v2.3/Data.List.Relation.Unary.Any.html | 6 +- ...on.Unary.Enumerates.Setoid.Properties.html | 8 +- ....List.Relation.Unary.First.Properties.html | 16 +- v2.3/Data.List.Relation.Unary.First.html | 4 +- ...ist.Relation.Unary.Grouped.Properties.html | 6 +- ...List.Relation.Unary.Linked.Properties.html | 4 +- ...on.Unary.Sorted.TotalOrder.Properties.html | 6 +- ...Unary.Unique.Propositional.Properties.html | 6 +- ...lation.Unary.Unique.Setoid.Properties.html | 6 +- ...ta.List.Sort.InsertionSort.Properties.html | 24 +- v2.3/Data.List.Sort.MergeSort.Base.html | 4 +- v2.3/Data.List.Sort.MergeSort.Properties.html | 2 +- v2.3/Data.Nat.Base.html | 4 +- v2.3/Data.Nat.Binary.Properties.html | 192 +- v2.3/Data.Nat.Binary.Subtraction.html | 322 +- v2.3/Data.Nat.Combinatorics.Base.html | 4 +- .../Data.Nat.Combinatorics.Specification.html | 88 +- v2.3/Data.Nat.Combinatorics.html | 260 +- v2.3/Data.Nat.Coprimality.html | 10 +- v2.3/Data.Nat.DivMod.Core.html | 142 +- v2.3/Data.Nat.DivMod.WithK.html | 10 +- v2.3/Data.Nat.DivMod.html | 154 +- v2.3/Data.Nat.Divisibility.Core.html | 4 +- v2.3/Data.Nat.Divisibility.html | 76 +- v2.3/Data.Nat.GCD.Lemmas.html | 102 +- v2.3/Data.Nat.GCD.html | 18 +- v2.3/Data.Nat.GeneralisedArithmetic.html | 10 +- v2.3/Data.Nat.Induction.html | 4 +- v2.3/Data.Nat.InfinitelyOften.html | 14 +- v2.3/Data.Nat.Instances.html | 4 +- v2.3/Data.Nat.LCM.html | 8 +- v2.3/Data.Nat.ListAction.Properties.html | 20 +- v2.3/Data.Nat.Logarithm.Core.html | 24 +- v2.3/Data.Nat.Primality.Factorisation.html | 38 +- v2.3/Data.Nat.Primality.html | 50 +- v2.3/Data.Nat.Properties.html | 4232 ++++++++--------- v2.3/Data.Nat.Show.Properties.html | 4 +- v2.3/Data.Nat.Show.html | 12 +- v2.3/Data.Nat.Solver.html | 2 +- v2.3/Data.Nat.Tactic.RingSolver.html | 4 +- v2.3/Data.Nat.html | 18 +- v2.3/Data.Parity.Properties.html | 46 +- v2.3/Data.Product.Algebra.html | 26 +- ...ta.Product.Relation.Binary.Lex.Strict.html | 8 +- v2.3/Data.Rational.Base.html | 6 +- v2.3/Data.Rational.Properties.html | 32 +- v2.3/Data.Rational.Unnormalised.Base.html | 6 +- ...Data.Rational.Unnormalised.Properties.html | 74 +- v2.3/Data.Sign.Properties.html | 6 +- v2.3/Data.String.html | 2 +- v2.3/Data.Sum.Function.Propositional.html | 6 +- v2.3/Data.Sum.Function.Setoid.html | 90 +- v2.3/Data.Sum.Relation.Binary.LeftOrder.html | 491 +- v2.3/Data.Sum.Relation.Binary.Pointwise.html | 424 +- ...Indexed.Relation.Unary.Any.Properties.html | 6 +- ...p.Membership.Propositional.Properties.html | 6 +- v2.3/Data.Tree.Binary.Zipper.Properties.html | 24 +- v2.3/Data.Vec.Bounded.Base.html | 28 +- v2.3/Data.Vec.Functional.Properties.html | 24 +- ...elation.Binary.Permutation.Properties.html | 12 +- ...unctional.Relation.Binary.Permutation.html | 4 +- ....Relation.Binary.Pointwise.Properties.html | 8 +- ...ctional.Relation.Unary.All.Properties.html | 6 +- ...ata.Vec.Functional.Relation.Unary.All.html | 4 +- ...ata.Vec.Functional.Relation.Unary.Any.html | 4 +- v2.3/Data.Vec.Properties.WithK.html | 4 +- v2.3/Data.Vec.Properties.html | 52 +- v2.3/Data.Vec.Recursive.html | 10 +- v2.3/Data.Vec.Relation.Binary.Lex.Core.html | 22 +- v2.3/Data.Vec.Relation.Binary.Lex.Strict.html | 4 +- ...ec.Relation.Unary.AllPairs.Properties.html | 4 +- v2.3/Data.Vec.Relation.Unary.Any.html | 6 +- ...Unary.Unique.Propositional.Properties.html | 2 +- ...lation.Unary.Unique.Setoid.Properties.html | 8 +- v2.3/Data.Vec.html | 4 +- v2.3/Data.Word64.Properties.html | 4 +- v2.3/Effect.Foldable.html | 2 +- v2.3/Everything.html | 2855 ++++++----- v2.3/EverythingSafe.html | 2627 +++++----- v2.3/Function.Consequences.Propositional.html | 2 +- v2.3/Function.Consequences.html | 4 +- v2.3/Function.Endo.Propositional.html | 2 +- v2.3/Function.Endo.Setoid.html | 2 +- v2.3/Function.Related.TypeIsomorphisms.html | 4 +- v2.3/Induction.InfiniteDescent.html | 4 +- v2.3/README.Data.List.Fresh.html | 4 +- ...ME.Data.List.Relation.Binary.Equality.html | 2 +- v2.3/README.Data.List.Relation.Unary.All.html | 4 +- v2.3/README.Data.List.Relation.Unary.Any.html | 4 +- v2.3/README.Data.Nat.html | 8 +- v2.3/README.Data.Tree.AVL.html | 4 +- ...ata.Vec.Relation.Binary.Equality.Cast.html | 2 +- v2.3/README.Data.Wrap.html | 8 +- v2.3/README.Design.Hierarchies.html | 688 ++- v2.3/README.Function.Reasoning.html | 2 +- v2.3/README.Inspect.html | 6 +- v2.3/README.Nary.html | 28 +- v2.3/README.html | 395 +- v2.3/Relation.Binary.Consequences.html | 12 +- ...ct.Closure.Reflexive.Properties.WithK.html | 6 +- ...onstruct.Closure.Reflexive.Properties.html | 4 +- ...on.Binary.Construct.NonStrictToStrict.html | 6 +- ...on.Binary.Construct.StrictToNonStrict.html | 4 +- ...erogeneousEquality.Quotients.Examples.html | 50 +- ...ry.Lattice.Properties.JoinSemilattice.html | 4 +- v2.3/Relation.Binary.Properties.Poset.html | 6 +- v2.3/Relation.Binary.Properties.Setoid.html | 4 +- v2.3/Relation.Binary.Reasoning.Syntax.html | 4 +- v2.3/Relation.Binary.Rewriting.html | 10 +- v2.3/Relation.Nullary.Decidable.Core.html | 6 +- v2.3/Relation.Nullary.Decidable.html | 6 +- v2.3/Relation.Nullary.Negation.Core.html | 48 +- v2.3/Relation.Nullary.Negation.html | 16 +- v2.3/Relation.Nullary.Reflects.html | 8 +- v2.3/Relation.Nullary.Universe.html | 20 +- v2.3/Relation.Unary.Algebra.html | 40 +- v2.3/System.Clock.html | 2 +- v2.3/System.Random.html | 12 +- ...RingSolver.Core.AlmostCommutativeRing.html | 12 +- ...actic.RingSolver.Core.Polynomial.Base.html | 12 +- ...Core.Polynomial.Homomorphism.Addition.html | 52 +- ...olynomial.Homomorphism.Exponentiation.html | 6 +- ...r.Core.Polynomial.Homomorphism.Lemmas.html | 42 +- ...olynomial.Homomorphism.Multiplication.html | 54 +- ...Core.Polynomial.Homomorphism.Negation.html | 6 +- ...ore.Polynomial.Homomorphism.Variables.html | 2 +- ....RingSolver.Core.Polynomial.Reasoning.html | 8 +- v2.3/Tactic.RingSolver.NonReflective.html | 4 +- v2.3/Text.Pretty.Core.html | 38 +- v2.3/Text.Pretty.html | 2 +- v2.3/Text.Regex.Derivative.Brzozowski.html | 14 +- v2.3/Text.Regex.Properties.Core.html | 4 +- v2.3/Text.Regex.Properties.html | 2 +- v2.3/Text.Regex.Search.html | 14 +- v2.3/Text.Regex.SmartConstructors.html | 14 +- v2.3/Text.Tabular.List.html | 2 +- v2.3/index.html | 1380 +++--- 254 files changed, 12893 insertions(+), 13251 deletions(-) delete mode 100644 v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.Properties.html delete mode 100644 v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.html delete mode 100644 v2.3/Data.List.Relation.Binary.Permutation.Declarative.Properties.html delete mode 100644 v2.3/Data.List.Relation.Binary.Permutation.Declarative.html diff --git a/v2.3/Algebra.Apartness.Properties.HeytingCommutativeRing.html b/v2.3/Algebra.Apartness.Properties.HeytingCommutativeRing.html index b6777eb7b7..dc0275f301 100644 --- a/v2.3/Algebra.Apartness.Properties.HeytingCommutativeRing.html +++ b/v2.3/Algebra.Apartness.Properties.HeytingCommutativeRing.html @@ -20,7 +20,7 @@ open CommutativeRing commutativeRing using (ring; *-commutativeMonoid) open import Algebra.Properties.Ring ring - using (-0#≈0#; -‿distribˡ-*; -‿distribʳ-*; -‿anti-homo-+; -‿involutive) + using (-0#≈0#; -‿distribˡ-*; -‿distribʳ-*; -‿anti-homo-+; -‿involutive) open import Relation.Binary.Definitions using (Symmetric) import Relation.Binary.Reasoning.Setoid as ≈-Reasoning open import Algebra.Properties.CommutativeMonoid *-commutativeMonoid @@ -35,13 +35,13 @@ invertibleʳ⇒# = invertible⇒# invertibleʳ⇒invertible x-0≈x : RightIdentity _≈_ 0# _-_ -x-0≈x x = trans (+-congˡ -0#≈0#) (+-identityʳ x) +x-0≈x x = trans (+-congˡ -0#≈0#) (+-identityʳ x) 1#0 : 1# # 0# 1#0 = invertibleˡ⇒# (1# , 1*[x-0]≈x) where 1*[x-0]≈x : 1# * (x - 0#) x - 1*[x-0]≈x {x} = trans (*-identityˡ (x - 0#)) (x-0≈x x) + 1*[x-0]≈x {x} = trans (*-identityˡ (x - 0#)) (x-0≈x x) x#0y#0→xy#0 : x # 0# y # 0# x * y # 0# x#0y#0→xy#0 {x} {y} x#0 y#0 = helper (#⇒invertible x#0) (#⇒invertible y#0) @@ -55,13 +55,13 @@ y⁻¹*x⁻¹*x*y≈1 : y⁻¹ * x⁻¹ * (x * y - 0#) 1# y⁻¹*x⁻¹*x*y≈1 = begin - y⁻¹ * x⁻¹ * (x * y - 0#) ≈⟨ *-congˡ (x-0≈x (x * y)) - y⁻¹ * x⁻¹ * (x * y) ≈⟨ *-assoc y⁻¹ x⁻¹ (x * y) - y⁻¹ * (x⁻¹ * (x * y)) ≈⟨ *-congˡ (*-assoc x⁻¹ x y) - y⁻¹ * ((x⁻¹ * x) * y) ≈⟨ *-congˡ (*-congʳ (*-congˡ (x-0≈x x))) - y⁻¹ * ((x⁻¹ * (x - 0#)) * y) ≈⟨ *-congˡ (*-congʳ x⁻¹*x≈1) - y⁻¹ * (1# * y) ≈⟨ *-congˡ (*-identityˡ y) - y⁻¹ * y ≈⟨ *-congˡ (x-0≈x y) + y⁻¹ * x⁻¹ * (x * y - 0#) ≈⟨ *-congˡ (x-0≈x (x * y)) + y⁻¹ * x⁻¹ * (x * y) ≈⟨ *-assoc y⁻¹ x⁻¹ (x * y) + y⁻¹ * (x⁻¹ * (x * y)) ≈⟨ *-congˡ (*-assoc x⁻¹ x y) + y⁻¹ * ((x⁻¹ * x) * y) ≈⟨ *-congˡ (*-congʳ (*-congˡ (x-0≈x x))) + y⁻¹ * ((x⁻¹ * (x - 0#)) * y) ≈⟨ *-congˡ (*-congʳ x⁻¹*x≈1) + y⁻¹ * (1# * y) ≈⟨ *-congˡ (*-identityˡ y) + y⁻¹ * y ≈⟨ *-congˡ (x-0≈x y) y⁻¹ * (y - 0#) ≈⟨ y⁻¹*y≈1 1# @@ -77,7 +77,7 @@ x-z⁻¹*y-z≈1 : x-z⁻¹ * (y - z) 1# x-z⁻¹*y-z≈1 = begin - x-z⁻¹ * (y - z) ≈⟨ *-congˡ (+-congʳ x≈y) + x-z⁻¹ * (y - z) ≈⟨ *-congˡ (+-congʳ x≈y) x-z⁻¹ * (x - z) ≈⟨ x-z⁻¹*x-z≈1# 1# diff --git a/v2.3/Algebra.Apartness.Structures.html b/v2.3/Algebra.Apartness.Structures.html index abf5af080d..d189baeb91 100644 --- a/v2.3/Algebra.Apartness.Structures.html +++ b/v2.3/Algebra.Apartness.Structures.html @@ -20,7 +20,7 @@ open import Level using (_⊔_; suc) open import Data.Product.Base using (∃-syntax; _×_; _,_; proj₂) open import Algebra.Definitions _≈_ using (Invertible) -open import Algebra.Structures _≈_ using (IsCommutativeRing) +open import Algebra.Structures _≈_ using (IsCommutativeRing) open import Relation.Binary.Structures using (IsEquivalence; IsApartnessRelation) open import Relation.Binary.Definitions using (Tight) open import Relation.Nullary.Negation using (¬_) @@ -30,10 +30,10 @@ record IsHeytingCommutativeRing : Set (c ℓ₁ ℓ₂) where field - isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1# + isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1# isApartnessRelation : IsApartnessRelation _≈_ _#_ - open IsCommutativeRing isCommutativeRing public + open IsCommutativeRing isCommutativeRing public open IsApartnessRelation isApartnessRelation public renaming ( irrefl to #-irrefl diff --git a/v2.3/Algebra.Bundles.html b/v2.3/Algebra.Bundles.html index cf0639351a..cabf5618e9 100644 --- a/v2.3/Algebra.Bundles.html +++ b/v2.3/Algebra.Bundles.html @@ -523,9 +523,9 @@ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier - isNearSemiring : IsNearSemiring _≈_ _+_ _*_ 0# + isNearSemiring : IsNearSemiring _≈_ _+_ _*_ 0# - open IsNearSemiring isNearSemiring public + open IsNearSemiring isNearSemiring public rawNearSemiring : RawNearSemiring _ _ rawNearSemiring = record @@ -536,7 +536,7 @@ } +-monoid : Monoid _ _ - +-monoid = record { isMonoid = +-isMonoid } + +-monoid = record { isMonoid = +-isMonoid } open Monoid +-monoid public using (_≉_) renaming @@ -548,7 +548,7 @@ ) *-semigroup : Semigroup _ _ - *-semigroup = record { isSemigroup = *-isSemigroup } + *-semigroup = record { isSemigroup = *-isSemigroup } open Semigroup *-semigroup public using () renaming @@ -567,12 +567,12 @@ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier - isSemiringWithoutOne : IsSemiringWithoutOne _≈_ _+_ _*_ 0# + isSemiringWithoutOne : IsSemiringWithoutOne _≈_ _+_ _*_ 0# - open IsSemiringWithoutOne isSemiringWithoutOne public + open IsSemiringWithoutOne isSemiringWithoutOne public nearSemiring : NearSemiring _ _ - nearSemiring = record { isNearSemiring = isNearSemiring } + nearSemiring = record { isNearSemiring = isNearSemiring } open NearSemiring nearSemiring public using @@ -583,7 +583,7 @@ ) +-commutativeMonoid : CommutativeMonoid _ _ - +-commutativeMonoid = record { isCommutativeMonoid = +-isCommutativeMonoid } + +-commutativeMonoid = record { isCommutativeMonoid = +-isCommutativeMonoid } open CommutativeMonoid +-commutativeMonoid public using () renaming @@ -603,14 +603,14 @@ _*_ : Op₂ Carrier 0# : Carrier isCommutativeSemiringWithoutOne : - IsCommutativeSemiringWithoutOne _≈_ _+_ _*_ 0# + IsCommutativeSemiringWithoutOne _≈_ _+_ _*_ 0# - open IsCommutativeSemiringWithoutOne + open IsCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne public semiringWithoutOne : SemiringWithoutOne _ _ semiringWithoutOne = - record { isSemiringWithoutOne = isSemiringWithoutOne } + record { isSemiringWithoutOne = isSemiringWithoutOne } open SemiringWithoutOne semiringWithoutOne public using @@ -636,9 +636,9 @@ 0# : Carrier 1# : Carrier isSemiringWithoutAnnihilatingZero : - IsSemiringWithoutAnnihilatingZero _≈_ _+_ _*_ 0# 1# + IsSemiringWithoutAnnihilatingZero _≈_ _+_ _*_ 0# 1# - open IsSemiringWithoutAnnihilatingZero + open IsSemiringWithoutAnnihilatingZero isSemiringWithoutAnnihilatingZero public rawSemiring : RawSemiring c @@ -655,7 +655,7 @@ +-commutativeMonoid : CommutativeMonoid _ _ +-commutativeMonoid = - record { isCommutativeMonoid = +-isCommutativeMonoid } + record { isCommutativeMonoid = +-isCommutativeMonoid } open CommutativeMonoid +-commutativeMonoid public using (_≉_) renaming @@ -670,7 +670,7 @@ ) *-monoid : Monoid _ _ - *-monoid = record { isMonoid = *-isMonoid } + *-monoid = record { isMonoid = *-isMonoid } open Monoid *-monoid public using () renaming @@ -692,14 +692,14 @@ _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier - isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1# + isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1# - open IsSemiring isSemiring public + open IsSemiring isSemiring public semiringWithoutAnnihilatingZero : SemiringWithoutAnnihilatingZero _ _ semiringWithoutAnnihilatingZero = record { isSemiringWithoutAnnihilatingZero = - isSemiringWithoutAnnihilatingZero + isSemiringWithoutAnnihilatingZero } open SemiringWithoutAnnihilatingZero @@ -715,7 +715,7 @@ semiringWithoutOne : SemiringWithoutOne _ _ semiringWithoutOne = - record { isSemiringWithoutOne = isSemiringWithoutOne } + record { isSemiringWithoutOne = isSemiringWithoutOne } open SemiringWithoutOne semiringWithoutOne public using (nearSemiring) @@ -732,12 +732,12 @@ _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier - isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# + isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# - open IsCommutativeSemiring isCommutativeSemiring public + open IsCommutativeSemiring isCommutativeSemiring public semiring : Semiring _ _ - semiring = record { isSemiring = isSemiring } + semiring = record { isSemiring = isSemiring } open Semiring semiring public using @@ -753,7 +753,7 @@ *-commutativeMonoid : CommutativeMonoid _ _ *-commutativeMonoid = record - { isCommutativeMonoid = *-isCommutativeMonoid + { isCommutativeMonoid = *-isCommutativeMonoid } open CommutativeMonoid *-commutativeMonoid public @@ -764,7 +764,7 @@ commutativeSemiringWithoutOne : CommutativeSemiringWithoutOne _ _ commutativeSemiringWithoutOne = record - { isCommutativeSemiringWithoutOne = isCommutativeSemiringWithoutOne + { isCommutativeSemiringWithoutOne = isCommutativeSemiringWithoutOne } @@ -779,13 +779,13 @@ _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier - isCancellativeCommutativeSemiring : IsCancellativeCommutativeSemiring _≈_ _+_ _*_ 0# 1# + isCancellativeCommutativeSemiring : IsCancellativeCommutativeSemiring _≈_ _+_ _*_ 0# 1# - open IsCancellativeCommutativeSemiring isCancellativeCommutativeSemiring public + open IsCancellativeCommutativeSemiring isCancellativeCommutativeSemiring public commutativeSemiring : CommutativeSemiring c commutativeSemiring = record - { isCommutativeSemiring = isCommutativeSemiring + { isCommutativeSemiring = isCommutativeSemiring } open CommutativeSemiring commutativeSemiring public @@ -813,12 +813,12 @@ _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier - isIdempotentSemiring : IsIdempotentSemiring _≈_ _+_ _*_ 0# 1# + isIdempotentSemiring : IsIdempotentSemiring _≈_ _+_ _*_ 0# 1# - open IsIdempotentSemiring isIdempotentSemiring public + open IsIdempotentSemiring isIdempotentSemiring public semiring : Semiring _ _ - semiring = record { isSemiring = isSemiring } + semiring = record { isSemiring = isSemiring } open Semiring semiring public using @@ -833,7 +833,7 @@ ) +-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ - +-idempotentCommutativeMonoid = record { isIdempotentCommutativeMonoid = +-isIdempotentCommutativeMonoid } + +-idempotentCommutativeMonoid = record { isIdempotentCommutativeMonoid = +-isIdempotentCommutativeMonoid } open IdempotentCommutativeMonoid +-idempotentCommutativeMonoid public using () @@ -855,12 +855,12 @@ _⋆ : Op₁ Carrier 0# : Carrier 1# : Carrier - isKleeneAlgebra : IsKleeneAlgebra _≈_ _+_ _*_ _⋆ 0# 1# + isKleeneAlgebra : IsKleeneAlgebra _≈_ _+_ _*_ _⋆ 0# 1# - open IsKleeneAlgebra isKleeneAlgebra public + open IsKleeneAlgebra isKleeneAlgebra public idempotentSemiring : IdempotentSemiring _ _ - idempotentSemiring = record { isIdempotentSemiring = isIdempotentSemiring } + idempotentSemiring = record { isIdempotentSemiring = isIdempotentSemiring } open IdempotentSemiring idempotentSemiring public using @@ -895,12 +895,12 @@ _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier - isQuasiring : IsQuasiring _≈_ _+_ _*_ 0# 1# + isQuasiring : IsQuasiring _≈_ _+_ _*_ 0# 1# - open IsQuasiring isQuasiring public + open IsQuasiring isQuasiring public +-monoid : Monoid _ _ - +-monoid = record { isMonoid = +-isMonoid } + +-monoid = record { isMonoid = +-isMonoid } open Monoid +-monoid public using (_≉_) renaming @@ -912,7 +912,7 @@ ) *-monoid : Monoid _ _ - *-monoid = record { isMonoid = *-isMonoid } + *-monoid = record { isMonoid = *-isMonoid } open Monoid *-monoid public using () renaming @@ -938,18 +938,18 @@ _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier - isRingWithoutOne : IsRingWithoutOne _≈_ _+_ _*_ -_ 0# + isRingWithoutOne : IsRingWithoutOne _≈_ _+_ _*_ -_ 0# - open IsRingWithoutOne isRingWithoutOne public + open IsRingWithoutOne isRingWithoutOne public nearSemiring : NearSemiring _ _ - nearSemiring = record { isNearSemiring = isNearSemiring } + nearSemiring = record { isNearSemiring = isNearSemiring } open NearSemiring nearSemiring public using (*-semigroup; *-magma) +-abelianGroup : AbelianGroup _ _ - +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } + +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } open AbelianGroup +-abelianGroup public using () @@ -987,18 +987,18 @@ -_ : Op₁ Carrier 0# : Carrier 1# : Carrier - isNonAssociativeRing : IsNonAssociativeRing _≈_ _+_ _*_ -_ 0# 1# + isNonAssociativeRing : IsNonAssociativeRing _≈_ _+_ _*_ -_ 0# 1# - open IsNonAssociativeRing isNonAssociativeRing public + open IsNonAssociativeRing isNonAssociativeRing public +-abelianGroup : AbelianGroup _ _ - +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } + +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } open AbelianGroup +-abelianGroup public using () renaming (group to +-group; invertibleMagma to +-invertibleMagma; invertibleUnitalMagma to +-invertibleUnitalMagma) *-unitalMagma : UnitalMagma _ _ - *-unitalMagma = record { isUnitalMagma = *-isUnitalMagma} + *-unitalMagma = record { isUnitalMagma = *-isUnitalMagma} open UnitalMagma *-unitalMagma public using () renaming (magma to *-magma; identity to *-identity) @@ -1016,12 +1016,12 @@ -_ : Op₁ Carrier 0# : Carrier 1# : Carrier - isNearring : IsNearring _≈_ _+_ _*_ 0# 1# -_ + isNearring : IsNearring _≈_ _+_ _*_ 0# 1# -_ - open IsNearring isNearring public + open IsNearring isNearring public quasiring : Quasiring _ _ - quasiring = record { isQuasiring = isQuasiring } + quasiring = record { isQuasiring = isQuasiring } open Quasiring quasiring public using @@ -1043,18 +1043,18 @@ -_ : Op₁ Carrier 0# : Carrier 1# : Carrier - isRing : IsRing _≈_ _+_ _*_ -_ 0# 1# + isRing : IsRing _≈_ _+_ _*_ -_ 0# 1# - open IsRing isRing public + open IsRing isRing public +-abelianGroup : AbelianGroup _ _ - +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } + +-abelianGroup = record { isAbelianGroup = +-isAbelianGroup } ringWithoutOne : RingWithoutOne _ _ - ringWithoutOne = record { isRingWithoutOne = isRingWithoutOne } + ringWithoutOne = record { isRingWithoutOne = isRingWithoutOne } semiring : Semiring _ _ - semiring = record { isSemiring = isSemiring } + semiring = record { isSemiring = isSemiring } open Semiring semiring public using @@ -1100,18 +1100,18 @@ -_ : Op₁ Carrier 0# : Carrier 1# : Carrier - isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1# + isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1# - open IsCommutativeRing isCommutativeRing public + open IsCommutativeRing isCommutativeRing public ring : Ring _ _ - ring = record { isRing = isRing } + ring = record { isRing = isRing } open Ring ring public using (_≉_; rawRing; +-invertibleMagma; +-invertibleUnitalMagma; +-group; +-abelianGroup) commutativeSemiring : CommutativeSemiring _ _ commutativeSemiring = - record { isCommutativeSemiring = isCommutativeSemiring } + record { isCommutativeSemiring = isCommutativeSemiring } open CommutativeSemiring commutativeSemiring public using @@ -1140,12 +1140,12 @@ _∙_ : Op₂ Carrier _\\_ : Op₂ Carrier _//_ : Op₂ Carrier - isQuasigroup : IsQuasigroup _≈_ _∙_ _\\_ _//_ + isQuasigroup : IsQuasigroup _≈_ _∙_ _\\_ _//_ - open IsQuasigroup isQuasigroup public + open IsQuasigroup isQuasigroup public magma : Magma c - magma = record { isMagma = isMagma } + magma = record { isMagma = isMagma } open Magma magma public using (_≉_; rawMagma) @@ -1173,9 +1173,9 @@ _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier - isLoop : IsLoop _≈_ _∙_ _\\_ _//_ ε + isLoop : IsLoop _≈_ _∙_ _\\_ _//_ ε - open IsLoop isLoop public + open IsLoop isLoop public rawLoop : RawLoop c rawLoop = record @@ -1187,7 +1187,7 @@ } quasigroup : Quasigroup _ _ - quasigroup = record { isQuasigroup = isQuasigroup } + quasigroup = record { isQuasigroup = isQuasigroup } open Quasigroup quasigroup public using (_≉_; ∙-rawMagma; \\-rawMagma; //-rawMagma) @@ -1204,12 +1204,12 @@ _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier - isLeftBolLoop : IsLeftBolLoop _≈_ _∙_ _\\_ _//_ ε + isLeftBolLoop : IsLeftBolLoop _≈_ _∙_ _\\_ _//_ ε - open IsLeftBolLoop isLeftBolLoop public + open IsLeftBolLoop isLeftBolLoop public loop : Loop _ _ - loop = record { isLoop = isLoop } + loop = record { isLoop = isLoop } open Loop loop public using (quasigroup) @@ -1226,12 +1226,12 @@ _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier - isRightBolLoop : IsRightBolLoop _≈_ _∙_ _\\_ _//_ ε + isRightBolLoop : IsRightBolLoop _≈_ _∙_ _\\_ _//_ ε - open IsRightBolLoop isRightBolLoop public + open IsRightBolLoop isRightBolLoop public loop : Loop _ _ - loop = record { isLoop = isLoop } + loop = record { isLoop = isLoop } open Loop loop public using (quasigroup) @@ -1248,12 +1248,12 @@ _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier - isMoufangLoop : IsMoufangLoop _≈_ _∙_ _\\_ _//_ ε + isMoufangLoop : IsMoufangLoop _≈_ _∙_ _\\_ _//_ ε - open IsMoufangLoop isMoufangLoop public + open IsMoufangLoop isMoufangLoop public leftBolLoop : LeftBolLoop _ _ - leftBolLoop = record { isLeftBolLoop = isLeftBolLoop } + leftBolLoop = record { isLeftBolLoop = isLeftBolLoop } open LeftBolLoop leftBolLoop public using (loop) @@ -1270,12 +1270,12 @@ _\\_ : Op₂ Carrier _//_ : Op₂ Carrier ε : Carrier - isMiddleBolLoop : IsMiddleBolLoop _≈_ _∙_ _\\_ _//_ ε + isMiddleBolLoop : IsMiddleBolLoop _≈_ _∙_ _\\_ _//_ ε - open IsMiddleBolLoop isMiddleBolLoop public + open IsMiddleBolLoop isMiddleBolLoop public loop : Loop _ _ - loop = record { isLoop = isLoop } + loop = record { isLoop = isLoop } open Loop loop public using (quasigroup) diff --git a/v2.3/Algebra.Construct.DirectProduct.html b/v2.3/Algebra.Construct.DirectProduct.html index c5d3644d15..1ba0e47fd2 100644 --- a/v2.3/Algebra.Construct.DirectProduct.html +++ b/v2.3/Algebra.Construct.DirectProduct.html @@ -272,15 +272,15 @@ SemiringWithoutAnnihilatingZero (a b) (ℓ₁ ℓ₂) semiringWithoutAnnihilatingZero R S = record { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = CommutativeMonoid.isCommutativeMonoid + { +-isCommutativeMonoid = CommutativeMonoid.isCommutativeMonoid (commutativeMonoid R.+-commutativeMonoid S.+-commutativeMonoid) - ; *-cong = zip R.*-cong S.*-cong - ; *-assoc = λ x y z (R.*-assoc , S.*-assoc) <*> x <*> y <*> z - ; *-identity = (R.*-identityˡ , S.*-identityˡ <*>_) - , (R.*-identityʳ , S.*-identityʳ <*>_) - ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) - , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) + ; *-cong = zip R.*-cong S.*-cong + ; *-assoc = λ x y z (R.*-assoc , S.*-assoc) <*> x <*> y <*> z + ; *-identity = (R.*-identityˡ , S.*-identityˡ <*>_) + , (R.*-identityʳ , S.*-identityʳ <*>_) + ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) + , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) } } where module R = SemiringWithoutAnnihilatingZero R module S = SemiringWithoutAnnihilatingZero S @@ -288,10 +288,10 @@ semiring : Semiring a ℓ₁ Semiring b ℓ₂ Semiring (a b) (ℓ₁ ℓ₂) semiring R S = record { isSemiring = record - { isSemiringWithoutAnnihilatingZero = + { isSemiringWithoutAnnihilatingZero = SemiringWithoutAnnihilatingZero.isSemiringWithoutAnnihilatingZero U - ; zero = uncurry x y R.zeroˡ x , S.zeroˡ y) - , uncurry x y R.zeroʳ x , S.zeroʳ y) + ; zero = uncurry x y R.zeroˡ x , S.zeroˡ y) + , uncurry x y R.zeroʳ x , S.zeroʳ y) } } where @@ -304,38 +304,38 @@ CommutativeSemiring (a b) (ℓ₁ ℓ₂) commutativeSemiring R S = record { isCommutativeSemiring = record - { isSemiring = Semiring.isSemiring (semiring R.semiring S.semiring) - ; *-comm = λ x y (R.*-comm , S.*-comm) <*> x <*> y + { isSemiring = Semiring.isSemiring (semiring R.semiring S.semiring) + ; *-comm = λ x y (R.*-comm , S.*-comm) <*> x <*> y } } where module R = CommutativeSemiring R; module S = CommutativeSemiring S idempotentSemiring : IdempotentSemiring a ℓ₁ IdempotentSemiring b ℓ₂ IdempotentSemiring (a b) (ℓ₁ ℓ₂) idempotentSemiring K L = record { isIdempotentSemiring = record - { isSemiring = Semiring.isSemiring (semiring K.semiring L.semiring) - ; +-idem = λ x (K.+-idem , L.+-idem) <*> x + { isSemiring = Semiring.isSemiring (semiring K.semiring L.semiring) + ; +-idem = λ x (K.+-idem , L.+-idem) <*> x } } where module K = IdempotentSemiring K; module L = IdempotentSemiring L kleeneAlgebra : KleeneAlgebra a ℓ₁ KleeneAlgebra b ℓ₂ KleeneAlgebra (a b) (ℓ₁ ℓ₂) kleeneAlgebra K L = record { isKleeneAlgebra = record - { isIdempotentSemiring = IdempotentSemiring.isIdempotentSemiring (idempotentSemiring K.idempotentSemiring L.idempotentSemiring) - ; starExpansive = x (K.starExpansiveˡ , L.starExpansiveˡ) <*> x) - , x (K.starExpansiveʳ , L.starExpansiveʳ) <*> x) - ; starDestructive = a b x x₁ (K.starDestructiveˡ , L.starDestructiveˡ) <*> a <*> b <*> x <*> x₁) - , a b x x₁ (K.starDestructiveʳ , L.starDestructiveʳ) <*> a <*> b <*> x <*> x₁) + { isIdempotentSemiring = IdempotentSemiring.isIdempotentSemiring (idempotentSemiring K.idempotentSemiring L.idempotentSemiring) + ; starExpansive = x (K.starExpansiveˡ , L.starExpansiveˡ) <*> x) + , x (K.starExpansiveʳ , L.starExpansiveʳ) <*> x) + ; starDestructive = a b x x₁ (K.starDestructiveˡ , L.starDestructiveˡ) <*> a <*> b <*> x <*> x₁) + , a b x x₁ (K.starDestructiveʳ , L.starDestructiveʳ) <*> a <*> b <*> x <*> x₁) } } where module K = KleeneAlgebra K; module L = KleeneAlgebra L ringWithoutOne : RingWithoutOne a ℓ₁ RingWithoutOne b ℓ₂ RingWithoutOne (a b) (ℓ₁ ℓ₂) ringWithoutOne R S = record { isRingWithoutOne = record - { +-isAbelianGroup = AbelianGroup.isAbelianGroup ((abelianGroup R.+-abelianGroup S.+-abelianGroup)) - ; *-cong = Semigroup.∙-cong (semigroup R.*-semigroup S.*-semigroup) - ; *-assoc = Semigroup.assoc (semigroup R.*-semigroup S.*-semigroup) - ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) - , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) + { +-isAbelianGroup = AbelianGroup.isAbelianGroup ((abelianGroup R.+-abelianGroup S.+-abelianGroup)) + ; *-cong = Semigroup.∙-cong (semigroup R.*-semigroup S.*-semigroup) + ; *-assoc = Semigroup.assoc (semigroup R.*-semigroup S.*-semigroup) + ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) + , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) } } where module R = RingWithoutOne R; module S = RingWithoutOne S @@ -343,13 +343,13 @@ nonAssociativeRing : NonAssociativeRing a ℓ₁ NonAssociativeRing b ℓ₂ NonAssociativeRing (a b) (ℓ₁ ℓ₂) nonAssociativeRing R S = record { isNonAssociativeRing = record - { +-isAbelianGroup = AbelianGroup.isAbelianGroup ((abelianGroup R.+-abelianGroup S.+-abelianGroup)) - ; *-cong = UnitalMagma.∙-cong (unitalMagma R.*-unitalMagma S.*-unitalMagma) - ; *-identity = UnitalMagma.identity (unitalMagma R.*-unitalMagma S.*-unitalMagma) - ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) - , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) - ; zero = uncurry x y R.zeroˡ x , S.zeroˡ y) - , uncurry x y R.zeroʳ x , S.zeroʳ y) + { +-isAbelianGroup = AbelianGroup.isAbelianGroup ((abelianGroup R.+-abelianGroup S.+-abelianGroup)) + ; *-cong = UnitalMagma.∙-cong (unitalMagma R.*-unitalMagma S.*-unitalMagma) + ; *-identity = UnitalMagma.identity (unitalMagma R.*-unitalMagma S.*-unitalMagma) + ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) + , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) + ; zero = uncurry x y R.zeroˡ x , S.zeroˡ y) + , uncurry x y R.zeroʳ x , S.zeroʳ y) } } where module R = NonAssociativeRing R; module S = NonAssociativeRing S @@ -357,14 +357,14 @@ quasiring : Quasiring a ℓ₁ Quasiring b ℓ₂ Quasiring (a b) (ℓ₁ ℓ₂) quasiring R S = record { isQuasiring = record - { +-isMonoid = Monoid.isMonoid ((monoid R.+-monoid S.+-monoid)) - ; *-cong = Monoid.∙-cong (monoid R.*-monoid S.*-monoid) - ; *-assoc = Monoid.assoc (monoid R.*-monoid S.*-monoid) - ; *-identity = Monoid.identity ((monoid R.*-monoid S.*-monoid)) - ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) - , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) - ; zero = uncurry x y R.zeroˡ x , S.zeroˡ y) - , uncurry x y R.zeroʳ x , S.zeroʳ y) + { +-isMonoid = Monoid.isMonoid ((monoid R.+-monoid S.+-monoid)) + ; *-cong = Monoid.∙-cong (monoid R.*-monoid S.*-monoid) + ; *-assoc = Monoid.assoc (monoid R.*-monoid S.*-monoid) + ; *-identity = Monoid.identity ((monoid R.*-monoid S.*-monoid)) + ; distrib = x y z (R.distribˡ , S.distribˡ) <*> x <*> y <*> z) + , x y z (R.distribʳ , S.distribʳ) <*> x <*> y <*> z) + ; zero = uncurry x y R.zeroˡ x , S.zeroˡ y) + , uncurry x y R.zeroʳ x , S.zeroʳ y) } } where module R = Quasiring R; module S = Quasiring S @@ -372,10 +372,10 @@ nearring : Nearring a ℓ₁ Nearring b ℓ₂ Nearring (a b) (ℓ₁ ℓ₂) nearring R S = record { isNearring = record - { isQuasiring = Quasiring.isQuasiring (quasiring R.quasiring S.quasiring) - ; +-inverse = x (R.+-inverseˡ , S.+-inverseˡ) <*> x) - , x (R.+-inverseʳ , S.+-inverseʳ) <*> x) - ; ⁻¹-cong = map R.⁻¹-cong S.⁻¹-cong + { isQuasiring = Quasiring.isQuasiring (quasiring R.quasiring S.quasiring) + ; +-inverse = x (R.+-inverseˡ , S.+-inverseˡ) <*> x) + , x (R.+-inverseʳ , S.+-inverseʳ) <*> x) + ; ⁻¹-cong = map R.⁻¹-cong S.⁻¹-cong } } where module R = Nearring R; module S = Nearring S @@ -383,11 +383,11 @@ ring R S = record { -_ = uncurry x y R.-_ x , S.-_ y) ; isRing = record - { +-isAbelianGroup = AbelianGroup.isAbelianGroup A - ; *-cong = Semiring.*-cong Semi - ; *-assoc = Semiring.*-assoc Semi - ; *-identity = Semiring.*-identity Semi - ; distrib = Semiring.distrib Semi + { +-isAbelianGroup = AbelianGroup.isAbelianGroup A + ; *-cong = Semiring.*-cong Semi + ; *-assoc = Semiring.*-assoc Semi + ; *-identity = Semiring.*-identity Semi + ; distrib = Semiring.distrib Semi } } where @@ -400,8 +400,8 @@ CommutativeRing (a b) (ℓ₁ ℓ₂) commutativeRing R S = record { isCommutativeRing = record - { isRing = Ring.isRing (ring R.ring S.ring) - ; *-comm = λ x y (R.*-comm , S.*-comm) <*> x <*> y + { isRing = Ring.isRing (ring R.ring S.ring) + ; *-comm = λ x y (R.*-comm , S.*-comm) <*> x <*> y } } where module R = CommutativeRing R; module S = CommutativeRing S @@ -410,11 +410,11 @@ { _\\_ = zip M._\\_ N._\\_ ; _//_ = zip M._//_ N._//_ ; isQuasigroup = record - { isMagma = Magma.isMagma (magma M.magma N.magma) - ; \\-cong = zip M.\\-cong N.\\-cong - ; //-cong = zip M.//-cong N.//-cong - ; leftDivides = x y M.leftDividesˡ , N.leftDividesˡ <*> x <*> y) , x y M.leftDividesʳ , N.leftDividesʳ <*> x <*> y) - ; rightDivides = x y M.rightDividesˡ , N.rightDividesˡ <*> x <*> y) , x y M.rightDividesʳ , N.rightDividesʳ <*> x <*> y) + { isMagma = Magma.isMagma (magma M.magma N.magma) + ; \\-cong = zip M.\\-cong N.\\-cong + ; //-cong = zip M.//-cong N.//-cong + ; leftDivides = x y M.leftDividesˡ , N.leftDividesˡ <*> x <*> y) , x y M.leftDividesʳ , N.leftDividesʳ <*> x <*> y) + ; rightDivides = x y M.rightDividesˡ , N.rightDividesˡ <*> x <*> y) , x y M.rightDividesʳ , N.rightDividesʳ <*> x <*> y) } } where module M = Quasigroup M; module N = Quasigroup N @@ -422,42 +422,42 @@ loop M N = record { ε = M.ε , N.ε ; isLoop = record - { isQuasigroup = Quasigroup.isQuasigroup (quasigroup M.quasigroup N.quasigroup) - ; identity = (M.identityˡ , N.identityˡ <*>_) - , (M.identityʳ , N.identityʳ <*>_) + { isQuasigroup = Quasigroup.isQuasigroup (quasigroup M.quasigroup N.quasigroup) + ; identity = (M.identityˡ , N.identityˡ <*>_) + , (M.identityʳ , N.identityʳ <*>_) } } where module M = Loop M; module N = Loop N leftBolLoop : LeftBolLoop a ℓ₁ LeftBolLoop b ℓ₂ LeftBolLoop (a b) (ℓ₁ ℓ₂) leftBolLoop M N = record { isLeftBolLoop = record - { isLoop = Loop.isLoop (loop M.loop N.loop) - ; leftBol = λ x y z M.leftBol , N.leftBol <*> x <*> y <*> z + { isLoop = Loop.isLoop (loop M.loop N.loop) + ; leftBol = λ x y z M.leftBol , N.leftBol <*> x <*> y <*> z } } where module M = LeftBolLoop M; module N = LeftBolLoop N rightBolLoop : RightBolLoop a ℓ₁ RightBolLoop b ℓ₂ RightBolLoop (a b) (ℓ₁ ℓ₂) rightBolLoop M N = record { isRightBolLoop = record - { isLoop = Loop.isLoop (loop M.loop N.loop) - ; rightBol = λ x y z M.rightBol , N.rightBol <*> x <*> y <*> z + { isLoop = Loop.isLoop (loop M.loop N.loop) + ; rightBol = λ x y z M.rightBol , N.rightBol <*> x <*> y <*> z } } where module M = RightBolLoop M; module N = RightBolLoop N middleBolLoop : MiddleBolLoop a ℓ₁ MiddleBolLoop b ℓ₂ MiddleBolLoop (a b) (ℓ₁ ℓ₂) middleBolLoop M N = record { isMiddleBolLoop = record - { isLoop = Loop.isLoop (loop M.loop N.loop) - ; middleBol = λ x y z M.middleBol , N.middleBol <*> x <*> y <*> z + { isLoop = Loop.isLoop (loop M.loop N.loop) + ; middleBol = λ x y z M.middleBol , N.middleBol <*> x <*> y <*> z } } where module M = MiddleBolLoop M; module N = MiddleBolLoop N moufangLoop : MoufangLoop a ℓ₁ MoufangLoop b ℓ₂ MoufangLoop (a b) (ℓ₁ ℓ₂) moufangLoop M N = record { isMoufangLoop = record - { isLeftBolLoop = LeftBolLoop.isLeftBolLoop (leftBolLoop M.leftBolLoop N.leftBolLoop) - ; rightBol = λ x y z M.rightBol , N.rightBol <*> x <*> y <*> z - ; identical = λ x y z M.identical , N.identical <*> x <*> y <*> z + { isLeftBolLoop = LeftBolLoop.isLeftBolLoop (leftBolLoop M.leftBolLoop N.leftBolLoop) + ; rightBol = λ x y z M.rightBol , N.rightBol <*> x <*> y <*> z + ; identical = λ x y z M.identical , N.identical <*> x <*> y <*> z } } where module M = MoufangLoop M; module N = MoufangLoop N \ No newline at end of file diff --git a/v2.3/Algebra.Construct.Flip.Op.html b/v2.3/Algebra.Construct.Flip.Op.html index 5bfdbb4117..f639b19eb2 100644 --- a/v2.3/Algebra.Construct.Flip.Op.html +++ b/v2.3/Algebra.Construct.Flip.Op.html @@ -10,234 +10,423 @@ module Algebra.Construct.Flip.Op where -open import Algebra -import Data.Product.Base as Product -import Data.Sum.Base as Sum -open import Function.Base using (flip) -open import Level using (Level) -open import Relation.Binary.Core using (Rel; _Preserves₂_⟶_⟶_) -open import Relation.Binary.Definitions using (Symmetric) - -private - variable - a : Level - A : Set a - : Rel A - ε : A - ⁻¹ : Op₁ A - : Op₂ A - ------------------------------------------------------------------------- --- Properties - -preserves₂ : ( : Rel A ) - Preserves₂ (flip ) Preserves₂ -preserves₂ _ _ _ pres = flip pres - -module _ ( : Rel A ) ( : Op₂ A) where - - associative : Symmetric Associative Associative (flip ) - associative sym assoc x y z = sym (assoc z y x) - - identity : Identity ε Identity ε (flip ) - identity id = Product.swap id - - commutative : Commutative Commutative (flip ) - commutative comm = flip comm - - selective : Selective Selective (flip ) - selective sel x y = Sum.swap (sel y x) - - idempotent : Idempotent Idempotent (flip ) - idempotent idem = idem - - inverse : Inverse ε ⁻¹ Inverse ε ⁻¹ (flip ) - inverse inv = Product.swap inv - ------------------------------------------------------------------------- --- Structures - -module _ { : Rel A } { : Op₂ A} where - - isMagma : IsMagma IsMagma (flip ) - isMagma m = record - { isEquivalence = isEquivalence - ; ∙-cong = preserves₂ ∙-cong - } - where open IsMagma m - - isSelectiveMagma : IsSelectiveMagma IsSelectiveMagma (flip ) - isSelectiveMagma m = record - { isMagma = isMagma m.isMagma - ; sel = selective m.sel - } - where module m = IsSelectiveMagma m - - isCommutativeMagma : IsCommutativeMagma IsCommutativeMagma (flip ) - isCommutativeMagma m = record - { isMagma = isMagma m.isMagma - ; comm = commutative m.comm - } - where module m = IsCommutativeMagma m - - isSemigroup : IsSemigroup IsSemigroup (flip ) - isSemigroup s = record - { isMagma = isMagma s.isMagma - ; assoc = associative s.sym s.assoc - } - where module s = IsSemigroup s - - isBand : IsBand IsBand (flip ) - isBand b = record - { isSemigroup = isSemigroup b.isSemigroup - ; idem = b.idem - } - where module b = IsBand b - - isCommutativeSemigroup : IsCommutativeSemigroup - IsCommutativeSemigroup (flip ) - isCommutativeSemigroup s = record - { isSemigroup = isSemigroup s.isSemigroup - ; comm = commutative s.comm - } - where module s = IsCommutativeSemigroup s - - isUnitalMagma : IsUnitalMagma ε IsUnitalMagma (flip ) ε - isUnitalMagma m = record - { isMagma = isMagma m.isMagma - ; identity = identity m.identity - } - where module m = IsUnitalMagma m - - isMonoid : IsMonoid ε IsMonoid (flip ) ε - isMonoid m = record - { isSemigroup = isSemigroup m.isSemigroup - ; identity = identity m.identity - } - where module m = IsMonoid m - - isCommutativeMonoid : IsCommutativeMonoid ε - IsCommutativeMonoid (flip ) ε - isCommutativeMonoid m = record - { isMonoid = isMonoid m.isMonoid - ; comm = commutative m.comm - } - where module m = IsCommutativeMonoid m - - isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid ε - IsIdempotentCommutativeMonoid (flip ) ε - isIdempotentCommutativeMonoid m = record - { isCommutativeMonoid = isCommutativeMonoid m.isCommutativeMonoid - ; idem = idempotent m.idem - } - where module m = IsIdempotentCommutativeMonoid m - - isInvertibleMagma : IsInvertibleMagma ε ⁻¹ - IsInvertibleMagma (flip ) ε ⁻¹ - isInvertibleMagma m = record - { isMagma = isMagma m.isMagma - ; inverse = inverse m.inverse - ; ⁻¹-cong = m.⁻¹-cong - } - where module m = IsInvertibleMagma m - - isInvertibleUnitalMagma : IsInvertibleUnitalMagma ε ⁻¹ - IsInvertibleUnitalMagma (flip ) ε ⁻¹ - isInvertibleUnitalMagma m = record - { isInvertibleMagma = isInvertibleMagma m.isInvertibleMagma - ; identity = identity m.identity - } - where module m = IsInvertibleUnitalMagma m - - isGroup : IsGroup ε ⁻¹ IsGroup (flip ) ε ⁻¹ - isGroup g = record - { isMonoid = isMonoid g.isMonoid - ; inverse = inverse g.inverse - ; ⁻¹-cong = g.⁻¹-cong - } - where module g = IsGroup g - - isAbelianGroup : IsAbelianGroup ε ⁻¹ IsAbelianGroup (flip ) ε ⁻¹ - isAbelianGroup g = record - { isGroup = isGroup g.isGroup - ; comm = commutative g.comm - } - where module g = IsAbelianGroup g - ------------------------------------------------------------------------- --- Bundles - -magma : Magma a Magma a -magma m = record { isMagma = isMagma m.isMagma } - where module m = Magma m - -commutativeMagma : CommutativeMagma a CommutativeMagma a -commutativeMagma m = record - { isCommutativeMagma = isCommutativeMagma m.isCommutativeMagma - } - where module m = CommutativeMagma m - -selectiveMagma : SelectiveMagma a SelectiveMagma a -selectiveMagma m = record - { isSelectiveMagma = isSelectiveMagma m.isSelectiveMagma - } - where module m = SelectiveMagma m - -semigroup : Semigroup a Semigroup a -semigroup s = record { isSemigroup = isSemigroup s.isSemigroup } - where module s = Semigroup s - -band : Band a Band a -band b = record { isBand = isBand b.isBand } - where module b = Band b - -commutativeSemigroup : CommutativeSemigroup a CommutativeSemigroup a -commutativeSemigroup s = record - { isCommutativeSemigroup = isCommutativeSemigroup s.isCommutativeSemigroup - } - where module s = CommutativeSemigroup s - -unitalMagma : UnitalMagma a UnitalMagma a -unitalMagma m = record - { isUnitalMagma = isUnitalMagma m.isUnitalMagma - } - where module m = UnitalMagma m - -monoid : Monoid a Monoid a -monoid m = record { isMonoid = isMonoid m.isMonoid } - where module m = Monoid m - -commutativeMonoid : CommutativeMonoid a CommutativeMonoid a -commutativeMonoid m = record - { isCommutativeMonoid = isCommutativeMonoid m.isCommutativeMonoid - } - where module m = CommutativeMonoid m - -idempotentCommutativeMonoid : IdempotentCommutativeMonoid a - IdempotentCommutativeMonoid a -idempotentCommutativeMonoid m = record - { isIdempotentCommutativeMonoid = - isIdempotentCommutativeMonoid m.isIdempotentCommutativeMonoid - } - where module m = IdempotentCommutativeMonoid m - -invertibleMagma : InvertibleMagma a InvertibleMagma a -invertibleMagma m = record - { isInvertibleMagma = isInvertibleMagma m.isInvertibleMagma - } - where module m = InvertibleMagma m - -invertibleUnitalMagma : InvertibleUnitalMagma a InvertibleUnitalMagma a -invertibleUnitalMagma m = record - { isInvertibleUnitalMagma = isInvertibleUnitalMagma m.isInvertibleUnitalMagma - } - where module m = InvertibleUnitalMagma m - -group : Group a Group a -group g = record { isGroup = isGroup g.isGroup } - where module g = Group g - -abelianGroup : AbelianGroup a AbelianGroup a -abelianGroup g = record { isAbelianGroup = isAbelianGroup g.isAbelianGroup } - where module g = AbelianGroup g +open import Algebra.Core +open import Algebra.Bundles +import Algebra.Definitions as Def +import Algebra.Structures as Str +import Algebra.Consequences.Setoid as Consequences +import Data.Product as Prod +import Data.Sum as Sum +open import Function.Base using (flip) +open import Level using (Level) +open import Relation.Binary.Core using (Rel; _Preserves₂_⟶_⟶_) +open import Relation.Binary.Definitions using (Symmetric) + +private + variable + a : Level + A : Set a + : Rel A + ε : A + ⁻¹ : Op₁ A + : Op₂ A + +------------------------------------------------------------------------ +-- Properties + +preserves₂ : ( : Rel A ) + Preserves₂ (flip ) Preserves₂ +preserves₂ _ _ _ pres = flip pres + +module ∙-Properties ( : Rel A ) ( : Op₂ A) where + + open Def + + associative : Symmetric Associative Associative (flip ) + associative sym assoc x y z = sym (assoc z y x) + + identity : Identity ε Identity ε (flip ) + identity id = Prod.swap id + + commutative : Commutative Commutative (flip ) + commutative comm = flip comm + + selective : Selective Selective (flip ) + selective sel x y = Sum.swap (sel y x) + + idempotent : Idempotent Idempotent (flip ) + idempotent idem = idem + + inverse : Inverse ε ⁻¹ Inverse ε ⁻¹ (flip ) + inverse inv = Prod.swap inv + + zero : Zero ε Zero ε (flip ) + zero zer = Prod.swap zer + +module *-Properties ( : Rel A ) (* + : Op₂ A) where + + open Def + + distributes : * DistributesOver + (flip *) DistributesOver + + distributes distrib = Prod.swap distrib + +------------------------------------------------------------------------ +-- Structures + +module _ { : Rel A } { : Op₂ A} where + + open Def + open Str + open ∙-Properties + + isMagma : IsMagma IsMagma (flip ) + isMagma m = record + { isEquivalence = isEquivalence + ; ∙-cong = preserves₂ ∙-cong + } + where open IsMagma m + + isSelectiveMagma : IsSelectiveMagma IsSelectiveMagma (flip ) + isSelectiveMagma m = record + { isMagma = isMagma m.isMagma + ; sel = selective m.sel + } + where module m = IsSelectiveMagma m + + isCommutativeMagma : IsCommutativeMagma IsCommutativeMagma (flip ) + isCommutativeMagma m = record + { isMagma = isMagma m.isMagma + ; comm = commutative m.comm + } + where module m = IsCommutativeMagma m + + isSemigroup : IsSemigroup IsSemigroup (flip ) + isSemigroup s = record + { isMagma = isMagma s.isMagma + ; assoc = associative s.sym s.assoc + } + where module s = IsSemigroup s + + isBand : IsBand IsBand (flip ) + isBand b = record + { isSemigroup = isSemigroup b.isSemigroup + ; idem = b.idem + } + where module b = IsBand b + + isCommutativeSemigroup : IsCommutativeSemigroup + IsCommutativeSemigroup (flip ) + isCommutativeSemigroup s = record + { isSemigroup = isSemigroup s.isSemigroup + ; comm = commutative s.comm + } + where module s = IsCommutativeSemigroup s + + isUnitalMagma : IsUnitalMagma ε IsUnitalMagma (flip ) ε + isUnitalMagma m = record + { isMagma = isMagma m.isMagma + ; identity = identity m.identity + } + where module m = IsUnitalMagma m + + isMonoid : IsMonoid ε IsMonoid (flip ) ε + isMonoid m = record + { isSemigroup = isSemigroup m.isSemigroup + ; identity = identity m.identity + } + where module m = IsMonoid m + + isCommutativeMonoid : IsCommutativeMonoid ε + IsCommutativeMonoid (flip ) ε + isCommutativeMonoid m = record + { isMonoid = isMonoid m.isMonoid + ; comm = commutative m.comm + } + where module m = IsCommutativeMonoid m + + isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid ε + IsIdempotentCommutativeMonoid (flip ) ε + isIdempotentCommutativeMonoid m = record + { isCommutativeMonoid = isCommutativeMonoid m.isCommutativeMonoid + ; idem = idempotent m.idem + } + where module m = IsIdempotentCommutativeMonoid m + + isInvertibleMagma : IsInvertibleMagma ε ⁻¹ + IsInvertibleMagma (flip ) ε ⁻¹ + isInvertibleMagma m = record + { isMagma = isMagma m.isMagma + ; inverse = inverse m.inverse + ; ⁻¹-cong = m.⁻¹-cong + } + where module m = IsInvertibleMagma m + + isInvertibleUnitalMagma : IsInvertibleUnitalMagma ε ⁻¹ + IsInvertibleUnitalMagma (flip ) ε ⁻¹ + isInvertibleUnitalMagma m = record + { isInvertibleMagma = isInvertibleMagma m.isInvertibleMagma + ; identity = identity m.identity + } + where module m = IsInvertibleUnitalMagma m + + isGroup : IsGroup ε ⁻¹ IsGroup (flip ) ε ⁻¹ + isGroup g = record + { isMonoid = isMonoid g.isMonoid + ; inverse = inverse g.inverse + ; ⁻¹-cong = g.⁻¹-cong + } + where module g = IsGroup g + + isAbelianGroup : IsAbelianGroup ε ⁻¹ IsAbelianGroup (flip ) ε ⁻¹ + isAbelianGroup g = record + { isGroup = isGroup g.isGroup + ; comm = commutative g.comm + } + where module g = IsAbelianGroup g + +module _ { : Rel A } {+ * : Op₂ A} {0# 1# : A} where + + open Str + open ∙-Properties * + open *-Properties * + + + isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero + * 0# 1# + IsSemiringWithoutAnnihilatingZero + (flip *) 0# 1# + isSemiringWithoutAnnihilatingZero r = record + { +-isCommutativeMonoid = r.+-isCommutativeMonoid + ; *-cong = preserves₂ r.*-cong + ; *-assoc = associative r.sym r.*-assoc + ; *-identity = identity r.*-identity + ; distrib = distributes r.distrib + } + where module r = IsSemiringWithoutAnnihilatingZero r + + isSemiring : IsSemiring + * 0# 1# IsSemiring + (flip *) 0# 1# + isSemiring r = record + { isSemiringWithoutAnnihilatingZero = isSemiringWithoutAnnihilatingZero r.isSemiringWithoutAnnihilatingZero + ; zero = zero r.zero + } + where module r = IsSemiring r + + isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# + IsCommutativeSemiring + (flip *) 0# 1# + isCommutativeSemiring r = record + { isSemiring = isSemiring r.isSemiring + ; *-comm = commutative r.*-comm + } + where module r = IsCommutativeSemiring r + + isCancellativeCommutativeSemiring : IsCancellativeCommutativeSemiring + * 0# 1# + IsCancellativeCommutativeSemiring + (flip *) 0# 1# + isCancellativeCommutativeSemiring r = record + { isCommutativeSemiring = isCommutativeSemiring r.isCommutativeSemiring + ; *-cancelˡ-nonZero = Consequences.comm∧almostCancelˡ⇒almostCancelʳ r.setoid r.*-comm r.*-cancelˡ-nonZero + } + where module r = IsCancellativeCommutativeSemiring r + + isIdempotentSemiring : IsIdempotentSemiring + * 0# 1# + IsIdempotentSemiring + (flip *) 0# 1# + isIdempotentSemiring r = record + { isSemiring = isSemiring r.isSemiring + ; +-idem = r.+-idem + } + where module r = IsIdempotentSemiring r + + isQuasiring : IsQuasiring + * 0# 1# IsQuasiring + (flip *) 0# 1# + isQuasiring r = record + { +-isMonoid = r.+-isMonoid + ; *-cong = preserves₂ r.*-cong + ; *-assoc = associative r.sym r.*-assoc + ; *-identity = identity r.*-identity + ; distrib = distributes r.distrib + ; zero = zero r.zero + } + where module r = IsQuasiring r + +module _ { : Rel A } {+ * : Op₂ A} { - : Op₁ A} {0# : A} where + + open Str + open ∙-Properties * + open *-Properties * + + + isRingWithoutOne : IsRingWithoutOne + * - 0# IsRingWithoutOne + (flip *) - 0# + isRingWithoutOne r = record + { +-isAbelianGroup = r.+-isAbelianGroup + ; *-cong = preserves₂ r.*-cong + ; *-assoc = associative r.sym r.*-assoc + ; distrib = distributes r.distrib + } + where module r = IsRingWithoutOne r + +module _ { : Rel A } {+ * : Op₂ A} { - : Op₁ A} {0# 1# : A} where + + open Str + open ∙-Properties * + open *-Properties * + + + isNonAssociativeRing : IsNonAssociativeRing + * - 0# 1# + IsNonAssociativeRing + (flip *) - 0# 1# + isNonAssociativeRing r = record + { +-isAbelianGroup = r.+-isAbelianGroup + ; *-cong = preserves₂ r.*-cong + ; *-identity = identity r.*-identity + ; distrib = distributes r.distrib + ; zero = zero r.zero + } + where module r = IsNonAssociativeRing r + + isNearring : IsNearring + * 0# 1# - IsNearring + (flip *) 0# 1# - + isNearring r = record + { isQuasiring = isQuasiring r.isQuasiring + ; +-inverse = r.+-inverse + ; ⁻¹-cong = r.⁻¹-cong + } + where module r = IsNearring r + + isRing : IsRing + * - 0# 1# IsRing + (flip *) - 0# 1# + isRing r = record + { +-isAbelianGroup = r.+-isAbelianGroup + ; *-cong = preserves₂ r.*-cong + ; *-assoc = associative r.sym r.*-assoc + ; *-identity = identity r.*-identity + ; distrib = distributes r.distrib + } + where module r = IsRing r + + isCommutativeRing : IsCommutativeRing + * - 0# 1# + IsCommutativeRing + (flip *) - 0# 1# + isCommutativeRing r = record + { isRing = isRing r.isRing + ; *-comm = commutative r.*-comm + } + where module r = IsCommutativeRing r + + +------------------------------------------------------------------------ +-- Bundles + +magma : Magma a Magma a +magma m = record { isMagma = isMagma m.isMagma } + where module m = Magma m + +commutativeMagma : CommutativeMagma a CommutativeMagma a +commutativeMagma m = record + { isCommutativeMagma = isCommutativeMagma m.isCommutativeMagma + } + where module m = CommutativeMagma m + +selectiveMagma : SelectiveMagma a SelectiveMagma a +selectiveMagma m = record + { isSelectiveMagma = isSelectiveMagma m.isSelectiveMagma + } + where module m = SelectiveMagma m + +semigroup : Semigroup a Semigroup a +semigroup s = record { isSemigroup = isSemigroup s.isSemigroup } + where module s = Semigroup s + +band : Band a Band a +band b = record { isBand = isBand b.isBand } + where module b = Band b + +commutativeSemigroup : CommutativeSemigroup a CommutativeSemigroup a +commutativeSemigroup s = record + { isCommutativeSemigroup = isCommutativeSemigroup s.isCommutativeSemigroup + } + where module s = CommutativeSemigroup s + +unitalMagma : UnitalMagma a UnitalMagma a +unitalMagma m = record + { isUnitalMagma = isUnitalMagma m.isUnitalMagma + } + where module m = UnitalMagma m + +monoid : Monoid a Monoid a +monoid m = record { isMonoid = isMonoid m.isMonoid } + where module m = Monoid m + +commutativeMonoid : CommutativeMonoid a CommutativeMonoid a +commutativeMonoid m = record + { isCommutativeMonoid = isCommutativeMonoid m.isCommutativeMonoid + } + where module m = CommutativeMonoid m + +idempotentCommutativeMonoid : IdempotentCommutativeMonoid a + IdempotentCommutativeMonoid a +idempotentCommutativeMonoid m = record + { isIdempotentCommutativeMonoid = + isIdempotentCommutativeMonoid m.isIdempotentCommutativeMonoid + } + where module m = IdempotentCommutativeMonoid m + +invertibleMagma : InvertibleMagma a InvertibleMagma a +invertibleMagma m = record + { isInvertibleMagma = isInvertibleMagma m.isInvertibleMagma + } + where module m = InvertibleMagma m + +invertibleUnitalMagma : InvertibleUnitalMagma a InvertibleUnitalMagma a +invertibleUnitalMagma m = record + { isInvertibleUnitalMagma = isInvertibleUnitalMagma m.isInvertibleUnitalMagma + } + where module m = InvertibleUnitalMagma m + +group : Group a Group a +group g = record { isGroup = isGroup g.isGroup } + where module g = Group g + +abelianGroup : AbelianGroup a AbelianGroup a +abelianGroup g = record { isAbelianGroup = isAbelianGroup g.isAbelianGroup } + where module g = AbelianGroup g + +semiringWithoutAnnihilatingZero : SemiringWithoutAnnihilatingZero a + SemiringWithoutAnnihilatingZero a +semiringWithoutAnnihilatingZero r = record + { isSemiringWithoutAnnihilatingZero = isSemiringWithoutAnnihilatingZero r.isSemiringWithoutAnnihilatingZero } + where module r = SemiringWithoutAnnihilatingZero r + +semiring : Semiring a Semiring a +semiring r = record { isSemiring = isSemiring r.isSemiring } + where module r = Semiring r + +commutativeSemiring : CommutativeSemiring a CommutativeSemiring a +commutativeSemiring r = record + { isCommutativeSemiring = isCommutativeSemiring r.isCommutativeSemiring } + where module r = CommutativeSemiring r + +cancellativeCommutativeSemiring : CancellativeCommutativeSemiring a + CancellativeCommutativeSemiring a +cancellativeCommutativeSemiring r = record + { isCancellativeCommutativeSemiring = isCancellativeCommutativeSemiring r.isCancellativeCommutativeSemiring } + where module r = CancellativeCommutativeSemiring r + +idempotentSemiring : IdempotentSemiring a IdempotentSemiring a +idempotentSemiring r = record + { isIdempotentSemiring = isIdempotentSemiring r.isIdempotentSemiring } + where module r = IdempotentSemiring r + +quasiring : Quasiring a Quasiring a +quasiring r = record { isQuasiring = isQuasiring r.isQuasiring } + where module r = Quasiring r + +ringWithoutOne : RingWithoutOne a RingWithoutOne a +ringWithoutOne r = record { isRingWithoutOne = isRingWithoutOne r.isRingWithoutOne } + where module r = RingWithoutOne r + +nonAssociativeRing : NonAssociativeRing a NonAssociativeRing a +nonAssociativeRing r = record + { isNonAssociativeRing = isNonAssociativeRing r.isNonAssociativeRing } + where module r = NonAssociativeRing r + +nearring : Nearring a Nearring a +nearring r = record { isNearring = isNearring r.isNearring } + where module r = Nearring r + +ring : Ring a Ring a +ring r = record { isRing = isRing r.isRing } + where module r = Ring r + +commutativeRing : CommutativeRing a CommutativeRing a +commutativeRing r = record { isCommutativeRing = isCommutativeRing r.isCommutativeRing } + where module r = CommutativeRing r \ No newline at end of file diff --git a/v2.3/Algebra.Construct.LexProduct.Inner.html b/v2.3/Algebra.Construct.LexProduct.Inner.html index 25fcd8b5a8..3594f9c98f 100644 --- a/v2.3/Algebra.Construct.LexProduct.Inner.html +++ b/v2.3/Algebra.Construct.LexProduct.Inner.html @@ -15,7 +15,7 @@ open import Relation.Binary.Definitions using (Decidable) open import Relation.Nullary.Decidable using (does; yes; no) open import Relation.Nullary.Negation - using (contradiction; contradiction₂) + using (contradiction; contradiction₂) import Relation.Binary.Reasoning.Setoid as SetoidReasoning import Algebra.Construct.LexProduct.Base as Base @@ -124,20 +124,20 @@ case₁ : a b ≈₁ a a b ≉₁ b lex a b x y ≈₂ x case₁ {a} {b} ab≈a ab≉b with (a b) ≟₁ a | (a b) ≟₁ b -... | no ab≉a | _ = contradiction ab≈a ab≉a -... | yes _ | yes ab≈b = contradiction ab≈b ab≉b +... | no ab≉a | _ = contradiction ab≈a ab≉a +... | yes _ | yes ab≈b = contradiction ab≈b ab≉b ... | yes _ | no _ = N.refl case₂ : a b ≉₁ a a b ≈₁ b lex a b x y ≈₂ y case₂ {a} {b} ab≉a ab≈b with (a b) ≟₁ a | (a b) ≟₁ b -... | yes ab≈a | _ = contradiction ab≈a ab≉a -... | no _ | no ab≉b = contradiction ab≈b ab≉b +... | yes ab≈a | _ = contradiction ab≈a ab≉a +... | no _ | no ab≉b = contradiction ab≈b ab≉b ... | no _ | yes _ = N.refl case₃ : a b ≈₁ a a b ≈₁ b lex a b x y ≈₂ (x y) case₃ {a} {b} ab≈a ab≈b with (a b) ≟₁ a | (a b) ≟₁ b -... | no ab≉a | _ = contradiction ab≈a ab≉a -... | yes _ | no ab≉b = contradiction ab≈b ab≉b +... | no ab≉a | _ = contradiction ab≈a ab≉a +... | yes _ | no ab≉b = contradiction ab≈b ab≉b ... | yes _ | yes _ = N.refl ------------------------------------------------------------------------ @@ -152,10 +152,10 @@ ... | no _ | no _ | no _ | no _ = ◦-cong w≈x y≈z ... | yes _ | no _ | yes _ | no _ = w≈x ... | no _ | yes _ | no _ | yes _ = y≈z -... | _ | yes ac≈c | _ | no bd≉d = contradiction (≤∙ˡ-resp-≈ ac≈c a≈b c≈d) bd≉d -... | yes ac≈a | _ | no bd≉b | _ = contradiction (≤∙ʳ-resp-≈ ac≈a a≈b c≈d) bd≉b -... | _ | no ac≉c | _ | yes bd≈d = contradiction (≤∙ˡ-resp-≈ bd≈d (M.sym a≈b) (M.sym c≈d)) ac≉c -... | no ac≉a | _ | yes bd≈b | _ = contradiction (≤∙ʳ-resp-≈ bd≈b (M.sym a≈b) (M.sym c≈d)) ac≉a +... | _ | yes ac≈c | _ | no bd≉d = contradiction (≤∙ˡ-resp-≈ ac≈c a≈b c≈d) bd≉d +... | yes ac≈a | _ | no bd≉b | _ = contradiction (≤∙ʳ-resp-≈ ac≈a a≈b c≈d) bd≉b +... | _ | no ac≉c | _ | yes bd≈d = contradiction (≤∙ˡ-resp-≈ bd≈d (M.sym a≈b) (M.sym c≈d)) ac≉c +... | no ac≉a | _ | yes bd≈b | _ = contradiction (≤∙ʳ-resp-≈ bd≈b (M.sym a≈b) (M.sym c≈d)) ac≉a cong₁₂ : a ≈₁ b c ≈₁ d lex a c x y ≈₂ lex b d x y cong₁₂ a≈b c≈d = cong a≈b c≈d N.refl N.refl @@ -174,8 +174,8 @@ a b c x y z lex (a b) c (lex a b x y) z ≈₂ lex a (b c) x (lex b c y z) assoc ∙-assoc ∙-comm ∙-sel ◦-assoc a b c x y z with (a b) ≟₁ a | (a b) ≟₁ b | (b c) ≟₁ b | (b c) ≟₁ c -... | _ | _ | no bc≉b | no bc≉c = contradiction₂ (∙-sel b c) bc≉b bc≉c -... | no ab≉a | no ab≉b | _ | _ = contradiction₂ (∙-sel a b) ab≉a ab≉b +... | _ | _ | no bc≉b | no bc≉c = contradiction₂ (∙-sel b c) bc≉b bc≉c +... | no ab≉a | no ab≉b | _ | _ = contradiction₂ (∙-sel a b) ab≉a ab≉b ... | yes ab≈a | no ab≉b | no bc≉b | yes bc≈c = cong₁₂ ab≈a (M.sym bc≈c) ... | no ab≉a | yes ab≈b | yes bc≈b | yes bc≈c = begin lex (a b) c y z ≈⟨ cong₁ ab≈b @@ -231,10 +231,10 @@ a b x y lex a b x y ≈₂ lex b a y x comm ∙-comm ◦-comm a b x y with (a b) ≟₁ a | (a b) ≟₁ b | (b a) ≟₁ b | (b a) ≟₁ a -... | yes ab≈a | _ | _ | no ba≉a = contradiction (M.trans (∙-comm b a) ab≈a) ba≉a -... | no ab≉a | _ | _ | yes ba≈a = contradiction (M.trans (∙-comm a b) ba≈a) ab≉a -... | _ | yes ab≈b | no ba≉b | _ = contradiction (M.trans (∙-comm b a) ab≈b) ba≉b -... | _ | no ab≉b | yes ba≈b | _ = contradiction (M.trans (∙-comm a b) ba≈b) ab≉b +... | yes ab≈a | _ | _ | no ba≉a = contradiction (M.trans (∙-comm b a) ab≈a) ba≉a +... | no ab≉a | _ | _ | yes ba≈a = contradiction (M.trans (∙-comm a b) ba≈a) ab≉a +... | _ | yes ab≈b | no ba≉b | _ = contradiction (M.trans (∙-comm b a) ab≈b) ba≉b +... | _ | no ab≉b | yes ba≈b | _ = contradiction (M.trans (∙-comm a b) ba≈b) ab≉b ... | yes _ | yes _ | yes _ | yes _ = ◦-comm x y ... | yes _ | no _ | no _ | yes _ = N.refl ... | no _ | yes _ | yes _ | no _ = N.refl @@ -250,14 +250,14 @@ zeroʳ : {e f} RightZero _≈₁_ e _∙_ RightZero _≈₂_ f _◦_ lex a e x f ≈₂ f zeroʳ {a} {x} {e} {f} ze₁ ze₂ with (a e) ≟₁ a | (a e) ≟₁ e -... | _ | no a∙e≉e = contradiction (ze₁ a) a∙e≉e +... | _ | no a∙e≉e = contradiction (ze₁ a) a∙e≉e ... | no _ | yes _ = N.refl ... | yes _ | yes _ = ze₂ x identityʳ : {e f} RightIdentity _≈₁_ e _∙_ RightIdentity _≈₂_ f _◦_ lex a e x f ≈₂ x identityʳ {a} {x} {e} {f} id₁ id₂ with (a e) ≟₁ a | (a e) ≟₁ e -... | no a∙e≉a | _ = contradiction (id₁ a) a∙e≉a +... | no a∙e≉a | _ = contradiction (id₁ a) a∙e≉a ... | yes _ | no _ = N.refl ... | yes _ | yes _ = id₂ x \ No newline at end of file diff --git a/v2.3/Algebra.Construct.LexProduct.html b/v2.3/Algebra.Construct.LexProduct.html index 1576a21055..5a2d86de08 100644 --- a/v2.3/Algebra.Construct.LexProduct.html +++ b/v2.3/Algebra.Construct.LexProduct.html @@ -17,7 +17,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Binary.Definitions using (Decidable) open import Relation.Nullary.Decidable.Core using (does; yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contradiction; contradiction₂) +open import Relation.Nullary.Negation.Core using (¬_; contradiction; contradiction₂) import Relation.Binary.Reasoning.Setoid as ≈-Reasoning module Algebra.Construct.LexProduct @@ -105,7 +105,7 @@ sel : Selective _≈₁_ _∙_ Selective _≈₂_ _◦_ Selective _≋_ _⊕_ sel ∙-sel ◦-sel (a , x) (b , y) with (a b) ≟₁ a | (a b) ≟₁ b -... | no ab≉a | no ab≉b = contradiction₂ (∙-sel a b) ab≉a ab≉b +... | no ab≉a | no ab≉b = contradiction₂ (∙-sel a b) ab≉a ab≉b ... | yes ab≈a | no _ = inj₁ (ab≈a , ≈₂-refl) ... | no _ | yes ab≈b = inj₂ (ab≈b , ≈₂-refl) ... | yes ab≈a | yes ab≈b = map (ab≈a ,_) (ab≈b ,_) (◦-sel x y) diff --git a/v2.3/Algebra.Construct.Pointwise.html b/v2.3/Algebra.Construct.Pointwise.html index 3e2bfe433c..b18aa4086b 100644 --- a/v2.3/Algebra.Construct.Pointwise.html +++ b/v2.3/Algebra.Construct.Pointwise.html @@ -121,111 +121,111 @@ } where module M = IsAbelianGroup isAbelianGroup -isNearSemiring : IsNearSemiring _≈_ _+_ _*_ 0# - IsNearSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) +isNearSemiring : IsNearSemiring _≈_ _+_ _*_ 0# + IsNearSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) isNearSemiring isNearSemiring = record - { +-isMonoid = isMonoid M.+-isMonoid - ; *-cong = λ g h _ M.*-cong (g _) (h _) - ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) - ; distribʳ = λ f g h _ M.distribʳ (f _) (g _) (h _) - ; zeroˡ = λ f _ M.zeroˡ (f _) + { +-isMonoid = isMonoid M.+-isMonoid + ; *-cong = λ g h _ M.*-cong (g _) (h _) + ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) + ; distribʳ = λ f g h _ M.distribʳ (f _) (g _) (h _) + ; zeroˡ = λ f _ M.zeroˡ (f _) } - where module M = IsNearSemiring isNearSemiring + where module M = IsNearSemiring isNearSemiring -isSemiringWithoutOne : IsSemiringWithoutOne _≈_ _+_ _*_ 0# - IsSemiringWithoutOne (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) +isSemiringWithoutOne : IsSemiringWithoutOne _≈_ _+_ _*_ 0# + IsSemiringWithoutOne (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) isSemiringWithoutOne isSemiringWithoutOne = record - { +-isCommutativeMonoid = isCommutativeMonoid M.+-isCommutativeMonoid - ; *-cong = λ g h _ M.*-cong (g _) (h _) - ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) - ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , f g h _ M.distribʳ (f _) (g _) (h _)) - ; zero = f _ M.zeroˡ (f _)) , f _ M.zeroʳ (f _)) + { +-isCommutativeMonoid = isCommutativeMonoid M.+-isCommutativeMonoid + ; *-cong = λ g h _ M.*-cong (g _) (h _) + ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) + ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , f g h _ M.distribʳ (f _) (g _) (h _)) + ; zero = f _ M.zeroˡ (f _)) , f _ M.zeroʳ (f _)) } - where module M = IsSemiringWithoutOne isSemiringWithoutOne + where module M = IsSemiringWithoutOne isSemiringWithoutOne -isCommutativeSemiringWithoutOne : IsCommutativeSemiringWithoutOne _≈_ _+_ _*_ 0# - IsCommutativeSemiringWithoutOne (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) +isCommutativeSemiringWithoutOne : IsCommutativeSemiringWithoutOne _≈_ _+_ _*_ 0# + IsCommutativeSemiringWithoutOne (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) isCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne = record - { isSemiringWithoutOne = isSemiringWithoutOne M.isSemiringWithoutOne - ; *-comm = λ f g _ M.*-comm (f _) (g _) + { isSemiringWithoutOne = isSemiringWithoutOne M.isSemiringWithoutOne + ; *-comm = λ f g _ M.*-comm (f _) (g _) } - where module M = IsCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne + where module M = IsCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne -isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _≈_ _+_ _*_ 0# 1# - IsSemiringWithoutAnnihilatingZero (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) +isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _≈_ _+_ _*_ 0# 1# + IsSemiringWithoutAnnihilatingZero (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) isSemiringWithoutAnnihilatingZero isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = isCommutativeMonoid M.+-isCommutativeMonoid - ; *-cong = λ g h _ M.*-cong (g _) (h _) - ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) - ; *-identity = f _ M.*-identityˡ (f _)) , λ f _ M.*-identityʳ (f _) - ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , λ f g h _ M.distribʳ (f _) (g _) (h _) + { +-isCommutativeMonoid = isCommutativeMonoid M.+-isCommutativeMonoid + ; *-cong = λ g h _ M.*-cong (g _) (h _) + ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) + ; *-identity = f _ M.*-identityˡ (f _)) , λ f _ M.*-identityʳ (f _) + ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , λ f g h _ M.distribʳ (f _) (g _) (h _) } - where module M = IsSemiringWithoutAnnihilatingZero isSemiringWithoutAnnihilatingZero + where module M = IsSemiringWithoutAnnihilatingZero isSemiringWithoutAnnihilatingZero -isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1# - IsSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) +isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1# + IsSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) isSemiring isSemiring = record - { isSemiringWithoutAnnihilatingZero = isSemiringWithoutAnnihilatingZero M.isSemiringWithoutAnnihilatingZero - ; zero = f _ M.zeroˡ (f _)) , λ f _ M.zeroʳ (f _) + { isSemiringWithoutAnnihilatingZero = isSemiringWithoutAnnihilatingZero M.isSemiringWithoutAnnihilatingZero + ; zero = f _ M.zeroˡ (f _)) , λ f _ M.zeroʳ (f _) } - where module M = IsSemiring isSemiring + where module M = IsSemiring isSemiring -isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# - IsCommutativeSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) +isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# + IsCommutativeSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) isCommutativeSemiring isCommutativeSemiring = record - { isSemiring = isSemiring M.isSemiring - ; *-comm = λ f g _ M.*-comm (f _) (g _) + { isSemiring = isSemiring M.isSemiring + ; *-comm = λ f g _ M.*-comm (f _) (g _) } - where module M = IsCommutativeSemiring isCommutativeSemiring + where module M = IsCommutativeSemiring isCommutativeSemiring -isIdempotentSemiring : IsIdempotentSemiring _≈_ _+_ _*_ 0# 1# - IsIdempotentSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) +isIdempotentSemiring : IsIdempotentSemiring _≈_ _+_ _*_ 0# 1# + IsIdempotentSemiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) isIdempotentSemiring isIdempotentSemiring = record - { isSemiring = isSemiring M.isSemiring - ; +-idem = λ f _ M.+-idem (f _) + { isSemiring = isSemiring M.isSemiring + ; +-idem = λ f _ M.+-idem (f _) } - where module M = IsIdempotentSemiring isIdempotentSemiring + where module M = IsIdempotentSemiring isIdempotentSemiring -isKleeneAlgebra : IsKleeneAlgebra _≈_ _+_ _*_ _⋆ 0# 1# - IsKleeneAlgebra (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₁ _⋆) (lift₀ 0#) (lift₀ 1#) +isKleeneAlgebra : IsKleeneAlgebra _≈_ _+_ _*_ _⋆ 0# 1# + IsKleeneAlgebra (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₁ _⋆) (lift₀ 0#) (lift₀ 1#) isKleeneAlgebra isKleeneAlgebra = record - { isIdempotentSemiring = isIdempotentSemiring M.isIdempotentSemiring - ; starExpansive = f _ M.starExpansiveˡ (f _)) , λ f _ M.starExpansiveʳ (f _) - ; starDestructive = f g h i _ M.starDestructiveˡ (f _) (g _) (h _) (i _)) - , f g h i _ M.starDestructiveʳ (f _) (g _) (h _) (i _)) + { isIdempotentSemiring = isIdempotentSemiring M.isIdempotentSemiring + ; starExpansive = f _ M.starExpansiveˡ (f _)) , λ f _ M.starExpansiveʳ (f _) + ; starDestructive = f g h i _ M.starDestructiveˡ (f _) (g _) (h _) (i _)) + , f g h i _ M.starDestructiveʳ (f _) (g _) (h _) (i _)) } - where module M = IsKleeneAlgebra isKleeneAlgebra + where module M = IsKleeneAlgebra isKleeneAlgebra -isQuasiring : IsQuasiring _≈_ _+_ _*_ 0# 1# - IsQuasiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) +isQuasiring : IsQuasiring _≈_ _+_ _*_ 0# 1# + IsQuasiring (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₀ 0#) (lift₀ 1#) isQuasiring isQuasiring = record - { +-isMonoid = isMonoid M.+-isMonoid - ; *-cong = λ g h _ M.*-cong (g _) (h _) - ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) - ; *-identity = f _ M.*-identityˡ (f _)) , λ f _ M.*-identityʳ (f _) - ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , λ f g h _ M.distribʳ (f _) (g _) (h _) - ; zero = f _ M.zeroˡ (f _)) , λ f _ M.zeroʳ (f _) + { +-isMonoid = isMonoid M.+-isMonoid + ; *-cong = λ g h _ M.*-cong (g _) (h _) + ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) + ; *-identity = f _ M.*-identityˡ (f _)) , λ f _ M.*-identityʳ (f _) + ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , λ f g h _ M.distribʳ (f _) (g _) (h _) + ; zero = f _ M.zeroˡ (f _)) , λ f _ M.zeroʳ (f _) } - where module M = IsQuasiring isQuasiring + where module M = IsQuasiring isQuasiring -isRing : IsRing _≈_ _+_ _*_ -_ 0# 1# - IsRing (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₁ -_) (lift₀ 0#) (lift₀ 1#) +isRing : IsRing _≈_ _+_ _*_ -_ 0# 1# + IsRing (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₁ -_) (lift₀ 0#) (lift₀ 1#) isRing isRing = record - { +-isAbelianGroup = isAbelianGroup M.+-isAbelianGroup - ; *-cong = λ g h _ M.*-cong (g _) (h _) - ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) - ; *-identity = f _ M.*-identityˡ (f _)) , λ f _ M.*-identityʳ (f _) - ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , λ f g h _ M.distribʳ (f _) (g _) (h _) + { +-isAbelianGroup = isAbelianGroup M.+-isAbelianGroup + ; *-cong = λ g h _ M.*-cong (g _) (h _) + ; *-assoc = λ f g h _ M.*-assoc (f _) (g _) (h _) + ; *-identity = f _ M.*-identityˡ (f _)) , λ f _ M.*-identityʳ (f _) + ; distrib = f g h _ M.distribˡ (f _) (g _) (h _)) , λ f g h _ M.distribʳ (f _) (g _) (h _) } - where module M = IsRing isRing + where module M = IsRing isRing -isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1# - IsCommutativeRing (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₁ -_) (lift₀ 0#) (lift₀ 1#) +isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1# + IsCommutativeRing (liftRel _≈_) (lift₂ _+_) (lift₂ _*_) (lift₁ -_) (lift₀ 0#) (lift₀ 1#) isCommutativeRing isCommutativeRing = record - { isRing = isRing M.isRing - ; *-comm = λ f g _ M.*-comm (f _) (g _) + { isRing = isRing M.isRing + ; *-comm = λ f g _ M.*-comm (f _) (g _) } - where module M = IsCommutativeRing isCommutativeRing + where module M = IsCommutativeRing isCommutativeRing ------------------------------------------------------------------------ -- Bundles diff --git a/v2.3/Algebra.Construct.Subst.Equality.html b/v2.3/Algebra.Construct.Subst.Equality.html index feadccb799..f9f0a0f902 100644 --- a/v2.3/Algebra.Construct.Subst.Equality.html +++ b/v2.3/Algebra.Construct.Subst.Equality.html @@ -126,30 +126,30 @@ } where module S = IsAbelianGroup S isNearSemiring : {+ * 0#} - IsNearSemiring ≈₁ + * 0# IsNearSemiring ≈₂ + * 0# + IsNearSemiring ≈₁ + * 0# IsNearSemiring ≈₂ + * 0# isNearSemiring {* = *} S = record - { +-isMonoid = isMonoid S.+-isMonoid - ; *-cong = cong₂ S.*-cong - ; *-assoc = assoc {*} S.*-assoc - ; distribʳ = λ x y z to (S.distribʳ x y z) - ; zeroˡ = to S.zeroˡ - } where module S = IsNearSemiring S + { +-isMonoid = isMonoid S.+-isMonoid + ; *-cong = cong₂ S.*-cong + ; *-assoc = assoc {*} S.*-assoc + ; distribʳ = λ x y z to (S.distribʳ x y z) + ; zeroˡ = to S.zeroˡ + } where module S = IsNearSemiring S isSemiringWithoutOne : {+ * 0#} - IsSemiringWithoutOne ≈₁ + * 0# IsSemiringWithoutOne ≈₂ + * 0# + IsSemiringWithoutOne ≈₁ + * 0# IsSemiringWithoutOne ≈₂ + * 0# isSemiringWithoutOne {+} {*} S = record - { +-isCommutativeMonoid = isCommutativeMonoid S.+-isCommutativeMonoid - ; *-cong = cong₂ S.*-cong - ; *-assoc = assoc {*} S.*-assoc - ; distrib = distrib {*} {+} S.distrib - ; zero = Product.map (to ∘_) (to ∘_) S.zero - } where module S = IsSemiringWithoutOne S + { +-isCommutativeMonoid = isCommutativeMonoid S.+-isCommutativeMonoid + ; *-cong = cong₂ S.*-cong + ; *-assoc = assoc {*} S.*-assoc + ; distrib = distrib {*} {+} S.distrib + ; zero = Product.map (to ∘_) (to ∘_) S.zero + } where module S = IsSemiringWithoutOne S isCommutativeSemiringWithoutOne : {+ * 0#} - IsCommutativeSemiringWithoutOne ≈₁ + * 0# - IsCommutativeSemiringWithoutOne ≈₂ + * 0# + IsCommutativeSemiringWithoutOne ≈₁ + * 0# + IsCommutativeSemiringWithoutOne ≈₂ + * 0# isCommutativeSemiringWithoutOne S = record - { isSemiringWithoutOne = isSemiringWithoutOne S.isSemiringWithoutOne - ; *-comm = comm S.*-comm - } where module S = IsCommutativeSemiringWithoutOne S + { isSemiringWithoutOne = isSemiringWithoutOne S.isSemiringWithoutOne + ; *-comm = comm S.*-comm + } where module S = IsCommutativeSemiringWithoutOne S \ No newline at end of file diff --git a/v2.3/Algebra.Definitions.html b/v2.3/Algebra.Definitions.html index efbdfbb440..8811dbd175 100644 --- a/v2.3/Algebra.Definitions.html +++ b/v2.3/Algebra.Definitions.html @@ -213,26 +213,26 @@ Flexible _∙_ = x y ((x y) x) (x (y x)) Medial : Op₂ A Set _ -Medial _∙_ = Interchangable _∙_ _∙_ +Medial _∙_ = x y u z ((x y) (u z)) ((x u) (y z)) -LeftSemimedial : Op₂ A Set _ -LeftSemimedial _∙_ = x y z ((x x) (y z)) ((x y) (x z)) +LeftSemimedial : Op₂ A Set _ +LeftSemimedial _∙_ = x y z ((x x) (y z)) ((x y) (x z)) -RightSemimedial : Op₂ A Set _ -RightSemimedial _∙_ = x y z ((y z) (x x)) ((y x) (z x)) +RightSemimedial : Op₂ A Set _ +RightSemimedial _∙_ = x y z ((y z) (x x)) ((y x) (z x)) -Semimedial : Op₂ A Set _ -Semimedial _∙_ = (LeftSemimedial _∙_) × (RightSemimedial _∙_) +Semimedial : Op₂ A Set _ +Semimedial _∙_ = (LeftSemimedial _∙_) × (RightSemimedial _∙_) -LeftBol : Op₂ A Set _ -LeftBol _∙_ = x y z (x (y (x z))) ((x (y x)) z ) +LeftBol : Op₂ A Set _ +LeftBol _∙_ = x y z (x (y (x z))) ((x (y x)) z ) -RightBol : Op₂ A Set _ -RightBol _∙_ = x y z (((z x) y) x) (z ((x y) x)) +RightBol : Op₂ A Set _ +RightBol _∙_ = x y z (((z x) y) x) (z ((x y) x)) -MiddleBol : Op₂ A Op₂ A Op₂ A Set _ -MiddleBol _∙_ _\\_ _//_ = x y z (x ((y z) \\ x)) ((x // z) (y \\ x)) +MiddleBol : Op₂ A Op₂ A Op₂ A Set _ +MiddleBol _∙_ _\\_ _//_ = x y z (x ((y z) \\ x)) ((x // z) (y \\ x)) -Identical : Op₂ A Set _ -Identical _∙_ = x y z ((z x) (y z)) (z ((x y) z)) +Identical : Op₂ A Set _ +Identical _∙_ = x y z ((z x) (y z)) (z ((x y) z)) \ No newline at end of file diff --git a/v2.3/Algebra.Lattice.Properties.BooleanAlgebra.html b/v2.3/Algebra.Lattice.Properties.BooleanAlgebra.html index 0360b4e1bf..633b2a2097 100644 --- a/v2.3/Algebra.Lattice.Properties.BooleanAlgebra.html +++ b/v2.3/Algebra.Lattice.Properties.BooleanAlgebra.html @@ -127,40 +127,40 @@ ; comm = ∧-comm } -∨-∧-isSemiring : IsSemiring _∨_ _∧_ +∨-∧-isSemiring : IsSemiring _∨_ _∧_ ∨-∧-isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = ∨-⊥-isCommutativeMonoid - ; *-cong = ∧-cong - ; *-assoc = ∧-assoc - ; *-identity = ∧-identity - ; distrib = ∧-distrib-∨ + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = ∨-⊥-isCommutativeMonoid + ; *-cong = ∧-cong + ; *-assoc = ∧-assoc + ; *-identity = ∧-identity + ; distrib = ∧-distrib-∨ } - ; zero = ∧-zero + ; zero = ∧-zero } -∧-∨-isSemiring : IsSemiring _∧_ _∨_ +∧-∨-isSemiring : IsSemiring _∧_ _∨_ ∧-∨-isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = ∧-⊤-isCommutativeMonoid - ; *-cong = ∨-cong - ; *-assoc = ∨-assoc - ; *-identity = ∨-identity - ; distrib = ∨-distrib-∧ + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = ∧-⊤-isCommutativeMonoid + ; *-cong = ∨-cong + ; *-assoc = ∨-assoc + ; *-identity = ∨-identity + ; distrib = ∨-distrib-∧ } - ; zero = ∨-zero + ; zero = ∨-zero } -∨-∧-isCommutativeSemiring : IsCommutativeSemiring _∨_ _∧_ +∨-∧-isCommutativeSemiring : IsCommutativeSemiring _∨_ _∧_ ∨-∧-isCommutativeSemiring = record - { isSemiring = ∨-∧-isSemiring - ; *-comm = ∧-comm + { isSemiring = ∨-∧-isSemiring + ; *-comm = ∧-comm } -∧-∨-isCommutativeSemiring : IsCommutativeSemiring _∧_ _∨_ +∧-∨-isCommutativeSemiring : IsCommutativeSemiring _∧_ _∨_ ∧-∨-isCommutativeSemiring = record - { isSemiring = ∧-∨-isSemiring - ; *-comm = ∨-comm + { isSemiring = ∧-∨-isSemiring + ; *-comm = ∨-comm } ∨-∧-commutativeSemiring : CommutativeSemiring _ _ @@ -510,19 +510,19 @@ ; comm = ⊕-comm } - ⊕-∧-isRing : IsRing _⊕_ _∧_ id + ⊕-∧-isRing : IsRing _⊕_ _∧_ id ⊕-∧-isRing = record - { +-isAbelianGroup = ⊕-⊥-isAbelianGroup - ; *-cong = ∧-cong - ; *-assoc = ∧-assoc - ; *-identity = ∧-identity - ; distrib = ∧-distrib-⊕ + { +-isAbelianGroup = ⊕-⊥-isAbelianGroup + ; *-cong = ∧-cong + ; *-assoc = ∧-assoc + ; *-identity = ∧-identity + ; distrib = ∧-distrib-⊕ } - ⊕-∧-isCommutativeRing : IsCommutativeRing _⊕_ _∧_ id + ⊕-∧-isCommutativeRing : IsCommutativeRing _⊕_ _∧_ id ⊕-∧-isCommutativeRing = record - { isRing = ⊕-∧-isRing - ; *-comm = ∧-comm + { isRing = ⊕-∧-isRing + ; *-comm = ∧-comm } ⊕-∧-commutativeRing : CommutativeRing _ _ diff --git a/v2.3/Algebra.Module.Bundles.html b/v2.3/Algebra.Module.Bundles.html index 78d4ac00a3..d66886ba78 100644 --- a/v2.3/Algebra.Module.Bundles.html +++ b/v2.3/Algebra.Module.Bundles.html @@ -373,14 +373,14 @@ *ₗ-comm : L.Commutative _*ₗ_ *ₗ-comm x y m = begin x *ₗ y *ₗ m ≈⟨ ≈ᴹ-sym (*ₗ-assoc x y m) - (x * y) *ₗ m ≈⟨ *ₗ-cong (*-comm _ _) ≈ᴹ-refl + (x * y) *ₗ m ≈⟨ *ₗ-cong (*-comm _ _) ≈ᴹ-refl (y * x) *ₗ m ≈⟨ *ₗ-assoc y x m y *ₗ x *ₗ m *ᵣ-comm : R.Commutative _*ᵣ_ *ᵣ-comm m x y = begin m *ᵣ x *ᵣ y ≈⟨ *ᵣ-assoc m x y - m *ᵣ (x * y) ≈⟨ *ᵣ-cong ≈ᴹ-refl (*-comm _ _) + m *ᵣ (x * y) ≈⟨ *ᵣ-cong ≈ᴹ-refl (*-comm _ _) m *ᵣ (y * x) ≈⟨ ≈ᴹ-sym (*ᵣ-assoc m y x) m *ᵣ y *ᵣ x diff --git a/v2.3/Algebra.Module.Construct.Idealization.html b/v2.3/Algebra.Module.Construct.Idealization.html index 1608385299..63e34d672f 100644 --- a/v2.3/Algebra.Module.Construct.Idealization.html +++ b/v2.3/Algebra.Module.Construct.Idealization.html @@ -45,7 +45,7 @@ ; LeftIdentity; RightIdentity; Identity; Associative) import Algebra.Module.Construct.DirectProduct as DirectProduct using (bimodule) import Algebra.Module.Construct.TensorUnit as TensorUnit using (bimodule) -open import Algebra.Structures using (IsAbelianGroup; IsRing) +open import Algebra.Structures using (IsAbelianGroup; IsRing) open import Data.Product.Base using (_,_; ∃-syntax) open import Level using (Level; _⊔_) open import Relation.Binary.Bundles using (Setoid) @@ -105,16 +105,16 @@ -- * an 'M'-component, where the work happens *-cong : Congruent₂ _*_ -*-cong (r₁ , m₁) (r₂ , m₂) = R.*-cong r₁ r₂ , +ᴹ-cong (*ₗ-cong r₁ m₂) (*ᵣ-cong m₁ r₂) +*-cong (r₁ , m₁) (r₂ , m₂) = R.*-cong r₁ r₂ , +ᴹ-cong (*ₗ-cong r₁ m₂) (*ᵣ-cong m₁ r₂) *-identityˡ : LeftIdentity 1# _*_ -*-identityˡ (r , m) = R.*-identityˡ r , (begin +*-identityˡ (r , m) = R.*-identityˡ r , (begin R.1# *ₗ m +ᴹ 0ᴹ *ᵣ r ≈⟨ +ᴹ-cong (*ₗ-identityˡ m) (*ᵣ-zeroˡ r) m +ᴹ 0ᴹ ≈⟨ +ᴹ-identityʳ m m ) *-identityʳ : RightIdentity 1# _*_ -*-identityʳ (r , m) = R.*-identityʳ r , (begin +*-identityʳ (r , m) = R.*-identityʳ r , (begin r *ₗ 0ᴹ +ᴹ m *ᵣ R.1# ≈⟨ +ᴹ-cong (*ₗ-zeroʳ r) (*ᵣ-identityʳ m) 0ᴹ +ᴹ m ≈⟨ +ᴹ-identityˡ m m ) @@ -123,7 +123,7 @@ *-identity = *-identityˡ , *-identityʳ *-assoc : Associative _*_ -*-assoc (r₁ , m₁) (r₂ , m₂) (r₃ , m₃) = R.*-assoc r₁ r₂ r₃ , (begin +*-assoc (r₁ , m₁) (r₂ , m₂) (r₃ , m₃) = R.*-assoc r₁ r₂ r₃ , (begin (r₁ R.* r₂) *ₗ m₃ +ᴹ (r₁ *ₗ m₂ +ᴹ m₁ *ᵣ r₂) *ᵣ r₃ ≈⟨ +ᴹ-cong (*ₗ-assoc r₁ r₂ m₃) (*ᵣ-distribʳ r₃ (r₁ *ₗ m₂) (m₁ *ᵣ r₂)) r₁ *ₗ (r₂ *ₗ m₃) +ᴹ ((r₁ *ₗ m₂) *ᵣ r₃ +ᴹ (m₁ *ᵣ r₂) *ᵣ r₃) @@ -135,7 +135,7 @@ r₁ *ₗ (r₂ *ₗ m₃ +ᴹ m₂ *ᵣ r₃) +ᴹ m₁ *ᵣ (r₂ R.* r₃) ) distribˡ : _*_ DistributesOverˡ _+_ -distribˡ (r₁ , m₁) (r₂ , m₂) (r₃ , m₃) = R.distribˡ r₁ r₂ r₃ , (begin +distribˡ (r₁ , m₁) (r₂ , m₂) (r₃ , m₃) = R.distribˡ r₁ r₂ r₃ , (begin r₁ *ₗ (m₂ +ᴹ m₃) +ᴹ m₁ *ᵣ (r₂ R.+ r₃) ≈⟨ +ᴹ-cong (*ₗ-distribˡ r₁ m₂ m₃) (*ᵣ-distribˡ m₁ r₂ r₃) (r₁ *ₗ m₂ +ᴹ r₁ *ₗ m₃) +ᴹ (m₁ *ᵣ r₂ +ᴹ m₁ *ᵣ r₃) @@ -144,7 +144,7 @@ distribʳ : _*_ DistributesOverʳ _+_ -distribʳ (r₁ , m₁) (r₂ , m₂) (r₃ , m₃) = R.distribʳ r₁ r₂ r₃ , (begin +distribʳ (r₁ , m₁) (r₂ , m₂) (r₃ , m₃) = R.distribʳ r₁ r₂ r₃ , (begin (r₂ R.+ r₃) *ₗ m₁ +ᴹ (m₂ +ᴹ m₃) *ᵣ r₁ ≈⟨ +ᴹ-cong (*ₗ-distribʳ m₁ r₂ r₃) (*ᵣ-distribʳ r₁ m₂ m₃) (r₂ *ₗ m₁ +ᴹ r₃ *ₗ m₁) +ᴹ (m₂ *ᵣ r₁ +ᴹ m₃ *ᵣ r₁) @@ -160,13 +160,13 @@ -- Structure -isRingᴺ : IsRing _≈_ _+_ _*_ -_ 0# 1# +isRingᴺ : IsRing _≈_ _+_ _*_ -_ 0# 1# isRingᴺ = record - { +-isAbelianGroup = +-isAbelianGroup - ; *-cong = *-cong - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = distrib + { +-isAbelianGroup = +-isAbelianGroup + ; *-cong = *-cong + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = distrib } -- Bundle @@ -178,13 +178,13 @@ -- M is an ideal of R ⋉ M satisfying m₁ * m₂ ≈ 0# ιᴹ-idealˡ : (n : N) (m : M) ∃[ n*m ] n * ιᴹ m ιᴹ n*m -ιᴹ-idealˡ n@(r , _) m = _ , R.zeroʳ r , ≈ᴹ-refl +ιᴹ-idealˡ n@(r , _) m = _ , R.zeroʳ r , ≈ᴹ-refl ιᴹ-idealʳ : (m : M) (n : N) ∃[ m*n ] ιᴹ m * n ιᴹ m*n -ιᴹ-idealʳ m n@(r , _) = _ , R.zeroˡ r , ≈ᴹ-refl +ιᴹ-idealʳ m n@(r , _) = _ , R.zeroˡ r , ≈ᴹ-refl *-annihilates-ιᴹ : (m₁ m₂ : M) ιᴹ m₁ * ιᴹ m₂ 0# -*-annihilates-ιᴹ m₁ m₂ = R.zeroˡ R.0# , (begin +*-annihilates-ιᴹ m₁ m₂ = R.zeroˡ R.0# , (begin R.0# *ₗ m₂ +ᴹ m₁ *ᵣ R.0# ≈⟨ +ᴹ-cong (*ₗ-zeroˡ m₂) (*ᵣ-zeroʳ m₁) 0ᴹ +ᴹ 0ᴹ ≈⟨ +ᴹ-identityˡ 0ᴹ 0ᴹ ) diff --git a/v2.3/Algebra.Module.Construct.TensorUnit.html b/v2.3/Algebra.Module.Construct.TensorUnit.html index bbf40a1cb7..d478184c66 100644 --- a/v2.3/Algebra.Module.Construct.TensorUnit.html +++ b/v2.3/Algebra.Module.Construct.TensorUnit.html @@ -90,15 +90,15 @@ ; _*ₗ_ = _*_ ; 0ᴹ = 0# ; isLeftSemimodule = record - { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid + { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid ; isPreleftSemimodule = record - { *ₗ-cong = *-cong - ; *ₗ-zeroˡ = zeroˡ - ; *ₗ-distribʳ = distribʳ - ; *ₗ-identityˡ = *-identityˡ - ; *ₗ-assoc = *-assoc - ; *ₗ-zeroʳ = zeroʳ - ; *ₗ-distribˡ = distribˡ + { *ₗ-cong = *-cong + ; *ₗ-zeroˡ = zeroˡ + ; *ₗ-distribʳ = distribʳ + ; *ₗ-identityˡ = *-identityˡ + ; *ₗ-assoc = *-assoc + ; *ₗ-zeroʳ = zeroʳ + ; *ₗ-distribˡ = distribˡ } } } where open Semiring semiring @@ -111,15 +111,15 @@ ; _*ᵣ_ = _*_ ; 0ᴹ = 0# ; isRightSemimodule = record - { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid + { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid ; isPrerightSemimodule = record - { *ᵣ-cong = *-cong - ; *ᵣ-zeroʳ = zeroʳ - ; *ᵣ-distribˡ = distribˡ - ; *ᵣ-identityʳ = *-identityʳ - ; *ᵣ-assoc = *-assoc - ; *ᵣ-zeroˡ = zeroˡ - ; *ᵣ-distribʳ = distribʳ + { *ᵣ-cong = *-cong + ; *ᵣ-zeroʳ = zeroʳ + ; *ᵣ-distribˡ = distribˡ + ; *ᵣ-identityʳ = *-identityʳ + ; *ᵣ-assoc = *-assoc + ; *ᵣ-zeroˡ = zeroˡ + ; *ᵣ-distribʳ = distribʳ } } } where open Semiring semiring @@ -127,12 +127,12 @@ bisemimodule : {R : Semiring c } Bisemimodule R R c bisemimodule {R = semiring} = record { isBisemimodule = record - { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid + { +ᴹ-isCommutativeMonoid = +-isCommutativeMonoid ; isPreleftSemimodule = LeftSemimodule.isPreleftSemimodule leftSemimodule ; isPrerightSemimodule = RightSemimodule.isPrerightSemimodule rightSemimodule - ; *ₗ-*ᵣ-assoc = *-assoc + ; *ₗ-*ᵣ-assoc = *-assoc } } where open Semiring semiring @@ -140,7 +140,7 @@ semimodule {R = commutativeSemiring} = record { isSemimodule = record { isBisemimodule = Bisemimodule.isBisemimodule bisemimodule - ; *ₗ-*ᵣ-coincident = *-comm + ; *ₗ-*ᵣ-coincident = *-comm } } where open CommutativeSemiring commutativeSemiring @@ -149,8 +149,8 @@ { -ᴹ_ = -_ ; isLeftModule = record { isLeftSemimodule = LeftSemimodule.isLeftSemimodule leftSemimodule - ; -ᴹ‿cong = -‿cong - ; -ᴹ‿inverse = -‿inverse + ; -ᴹ‿cong = -‿cong + ; -ᴹ‿inverse = -‿inverse } } where open Ring ring @@ -159,8 +159,8 @@ { -ᴹ_ = -_ ; isRightModule = record { isRightSemimodule = RightSemimodule.isRightSemimodule rightSemimodule - ; -ᴹ‿cong = -‿cong - ; -ᴹ‿inverse = -‿inverse + ; -ᴹ‿cong = -‿cong + ; -ᴹ‿inverse = -‿inverse } } where open Ring ring @@ -168,8 +168,8 @@ bimodule {R = ring} = record { isBimodule = record { isBisemimodule = Bisemimodule.isBisemimodule bisemimodule - ; -ᴹ‿cong = -‿cong - ; -ᴹ‿inverse = -‿inverse + ; -ᴹ‿cong = -‿cong + ; -ᴹ‿inverse = -‿inverse } } where open Ring ring @@ -177,7 +177,7 @@ ⟨module⟩ {R = commutativeRing} = record { isModule = record { isBimodule = Bimodule.isBimodule bimodule - ; *ₗ-*ᵣ-coincident = *-comm + ; *ₗ-*ᵣ-coincident = *-comm } } where open CommutativeRing commutativeRing \ No newline at end of file diff --git a/v2.3/Algebra.Module.Morphism.BimoduleMonomorphism.html b/v2.3/Algebra.Module.Morphism.BimoduleMonomorphism.html index 34ca861e3c..ad180fcc65 100644 --- a/v2.3/Algebra.Module.Morphism.BimoduleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.BimoduleMonomorphism.html @@ -22,7 +22,7 @@ open import Algebra.Bundles using (Ring) open import Algebra.Module.Structures using (IsBimodule) -open import Algebra.Structures using (IsRing) +open import Algebra.Structures using (IsRing) open import Relation.Binary.Core using (Rel) ------------------------------------------------------------------------ @@ -46,8 +46,8 @@ module _ {ℓr} {_≈r_ : Rel R ℓr} {_+r_ _*r_ -r_ 0r 1r} {ℓs} {_≈s_ : Rel S ℓs} {_+s_ _*s_ -s_ 0s 1s} - (R-isRing : IsRing _≈r_ _+r_ _*r_ -r_ 0r 1r) - (S-isRing : IsRing _≈s_ _+s_ _*s_ -s_ 0s 1s) + (R-isRing : IsRing _≈r_ _+r_ _*r_ -r_ 0r 1r) + (S-isRing : IsRing _≈s_ _+s_ _*s_ -s_ 0s 1s) where private @@ -57,14 +57,14 @@ S-ring : Ring _ _ S-ring = record { isRing = S-isRing } - module R = IsRing R-isRing - module S = IsRing S-isRing + module R = IsRing R-isRing + module S = IsRing S-isRing isBimodule : IsBimodule R-ring S-ring N._≈ᴹ_ N._+ᴹ_ N.0ᴹ N.-ᴹ_ N._*ₗ_ N._*ᵣ_ IsBimodule R-ring S-ring M._≈ᴹ_ M._+ᴹ_ M.0ᴹ M.-ᴹ_ M._*ₗ_ M._*ᵣ_ isBimodule isBimodule = record - { isBisemimodule = isBisemimodule R.isSemiring S.isSemiring NN.isBisemimodule + { isBisemimodule = isBisemimodule R.isSemiring S.isSemiring NN.isBisemimodule ; -ᴹ‿cong = -ᴹ‿cong NN.+ᴹ-isMagma NN.-ᴹ‿cong ; -ᴹ‿inverse = -ᴹ‿inverse NN.+ᴹ-isMagma NN.-ᴹ‿inverse } diff --git a/v2.3/Algebra.Module.Morphism.BisemimoduleMonomorphism.html b/v2.3/Algebra.Module.Morphism.BisemimoduleMonomorphism.html index 27f21fa6e0..7fab050d14 100644 --- a/v2.3/Algebra.Module.Morphism.BisemimoduleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.BisemimoduleMonomorphism.html @@ -26,7 +26,7 @@ import Algebra.Module.Definitions.Left as LeftDefs using (LeftCongruent) import Algebra.Module.Definitions.Right as RightDefs using (RightCongruent) open import Algebra.Module.Structures using (IsBisemimodule) -open import Algebra.Structures using (IsMagma; IsSemiring) +open import Algebra.Structures using (IsMagma; IsSemiring) open import Function.Base using (flip; _$_) open import Relation.Binary.Core using (Rel) import Relation.Binary.Reasoning.Setoid as SetoidReasoning @@ -110,8 +110,8 @@ module _ {ℓr} {_≈r_ : Rel R ℓr} {_+r_ _*r_ 0r 1r} {ℓs} {_≈s_ : Rel S ℓs} {_+s_ _*s_ 0s 1s} - (R-isSemiring : IsSemiring _≈r_ _+r_ _*r_ 0r 1r) - (S-isSemiring : IsSemiring _≈s_ _+s_ _*s_ 0s 1s) + (R-isSemiring : IsSemiring _≈r_ _+r_ _*r_ 0r 1r) + (S-isSemiring : IsSemiring _≈s_ _+s_ _*s_ 0s 1s) where private diff --git a/v2.3/Algebra.Module.Morphism.LeftModuleMonomorphism.html b/v2.3/Algebra.Module.Morphism.LeftModuleMonomorphism.html index ce8d0b5202..42537dcab1 100644 --- a/v2.3/Algebra.Module.Morphism.LeftModuleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.LeftModuleMonomorphism.html @@ -23,7 +23,7 @@ open import Algebra.Bundles using (Ring) open import Algebra.Core using (Op₂) open import Algebra.Module.Structures using (IsLeftModule) -open import Algebra.Structures using (IsRing) +open import Algebra.Structures using (IsRing) open import Relation.Binary.Core using (Rel) ------------------------------------------------------------------------ @@ -44,18 +44,18 @@ ------------------------------------------------------------------------ -- Structures -module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ -_ 0# 1#} (R-isRing : IsRing _≈_ _+_ _*_ -_ 0# 1#) where +module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ -_ 0# 1#} (R-isRing : IsRing _≈_ _+_ _*_ -_ 0# 1#) where private R-ring : Ring _ _ R-ring = record { isRing = R-isRing } - open IsRing R-isRing + open IsRing R-isRing isLeftModule : IsLeftModule R-ring N._≈ᴹ_ N._+ᴹ_ N.0ᴹ N.-ᴹ_ N._*ₗ_ IsLeftModule R-ring M._≈ᴹ_ M._+ᴹ_ M.0ᴹ M.-ᴹ_ M._*ₗ_ isLeftModule isLeftModule = record - { isLeftSemimodule = isLeftSemimodule isSemiring NN.isLeftSemimodule + { isLeftSemimodule = isLeftSemimodule isSemiring NN.isLeftSemimodule ; -ᴹ‿cong = -ᴹ‿cong NN.+ᴹ-isMagma NN.-ᴹ‿cong ; -ᴹ‿inverse = -ᴹ‿inverse NN.+ᴹ-isMagma NN.-ᴹ‿inverse } diff --git a/v2.3/Algebra.Module.Morphism.LeftSemimoduleMonomorphism.html b/v2.3/Algebra.Module.Morphism.LeftSemimoduleMonomorphism.html index 4f89034a8a..f85fb26eeb 100644 --- a/v2.3/Algebra.Module.Morphism.LeftSemimoduleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.LeftSemimoduleMonomorphism.html @@ -24,7 +24,7 @@ open import Algebra.Core using (Op₂) import Algebra.Module.Definitions.Left as LeftDefs open import Algebra.Module.Structures using (IsLeftSemimodule) -open import Algebra.Structures using (IsSemiring; IsMagma) +open import Algebra.Structures using (IsSemiring; IsMagma) open import Function.Base using (flip; _$_) open import Level using (Level) open import Relation.Binary.Core using (Rel) @@ -125,7 +125,7 @@ ------------------------------------------------------------------------ -- Structures -module _ (R-isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1#) where +module _ (R-isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1#) where private R-semiring : Semiring _ _ diff --git a/v2.3/Algebra.Module.Morphism.ModuleHomomorphism.html b/v2.3/Algebra.Module.Morphism.ModuleHomomorphism.html index 1f9af66045..0fc8cc3380 100644 --- a/v2.3/Algebra.Module.Morphism.ModuleHomomorphism.html +++ b/v2.3/Algebra.Module.Morphism.ModuleHomomorphism.html @@ -29,7 +29,7 @@ open import Data.Product.Base using (∃₂; _×_; _,_) open import Relation.Binary.Reasoning.MultiSetoid open import Relation.Nullary using (¬_) -open import Relation.Nullary.Negation using (contraposition) +open import Relation.Nullary.Negation using (contraposition) module A = Module modA module B = Module modB @@ -52,7 +52,7 @@ B.0ᴹ fx≉0⇒x≉0 : {x} f x B.≉ᴹ B.0ᴹ x A.≉ᴹ A.0ᴹ -fx≉0⇒x≉0 = contraposition x≈0⇒fx≈0 +fx≉0⇒x≉0 = contraposition x≈0⇒fx≈0 -- Zero is a unique output of non-trivial (i.e. - ≉ `const 0`) linear map. x≉0⇒f[x]≉0 : {x} NonTrivial x x A.≉ᴹ A.0ᴹ f x B.≉ᴹ B.0ᴹ diff --git a/v2.3/Algebra.Module.Morphism.ModuleMonomorphism.html b/v2.3/Algebra.Module.Morphism.ModuleMonomorphism.html index 24c7257458..ab78d88802 100644 --- a/v2.3/Algebra.Module.Morphism.ModuleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.ModuleMonomorphism.html @@ -23,7 +23,7 @@ open import Algebra.Bundles using (CommutativeRing) open import Algebra.Core using (Op₂) open import Algebra.Module.Structures using (IsModule) -open import Algebra.Structures using (IsCommutativeRing) +open import Algebra.Structures using (IsCommutativeRing) open import Relation.Binary.Core using (Rel) ------------------------------------------------------------------------ @@ -36,19 +36,19 @@ ------------------------------------------------------------------------ -- Structures -module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ -_ 0# 1#} (R-isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1#) where +module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ -_ 0# 1#} (R-isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0# 1#) where private R-commutativeRing : CommutativeRing _ _ R-commutativeRing = record { isCommutativeRing = R-isCommutativeRing } - open IsCommutativeRing R-isCommutativeRing + open IsCommutativeRing R-isCommutativeRing isModule : IsModule R-commutativeRing N._≈ᴹ_ N._+ᴹ_ N.0ᴹ N.-ᴹ_ N._*ₗ_ N._*ᵣ_ IsModule R-commutativeRing M._≈ᴹ_ M._+ᴹ_ M.0ᴹ M.-ᴹ_ M._*ₗ_ M._*ᵣ_ isModule isModule = record - { isBimodule = isBimodule isRing isRing NN.isBimodule + { isBimodule = isBimodule isRing isRing NN.isBimodule ; *ₗ-*ᵣ-coincident = *ₗ-*ᵣ-coincident NN.+ᴹ-isMagma NN.*ₗ-*ᵣ-coincident } where diff --git a/v2.3/Algebra.Module.Morphism.RightModuleMonomorphism.html b/v2.3/Algebra.Module.Morphism.RightModuleMonomorphism.html index 955ec482e2..48b7813cc0 100644 --- a/v2.3/Algebra.Module.Morphism.RightModuleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.RightModuleMonomorphism.html @@ -22,7 +22,7 @@ open import Algebra.Bundles using (Ring) open import Algebra.Core using (Op₂) open import Algebra.Module.Structures using (IsRightModule) -open import Algebra.Structures using (IsRing) +open import Algebra.Structures using (IsRing) open import Relation.Binary.Core using (Rel) ------------------------------------------------------------------------ @@ -43,18 +43,18 @@ ------------------------------------------------------------------------ -- Structures -module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ -_ 0# 1#} (R-isRing : IsRing _≈_ _+_ _*_ -_ 0# 1#) where +module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ -_ 0# 1#} (R-isRing : IsRing _≈_ _+_ _*_ -_ 0# 1#) where private R-ring : Ring _ _ R-ring = record { isRing = R-isRing} - open IsRing R-isRing + open IsRing R-isRing isRightModule : IsRightModule R-ring N._≈ᴹ_ N._+ᴹ_ N.0ᴹ N.-ᴹ_ N._*ᵣ_ IsRightModule R-ring M._≈ᴹ_ M._+ᴹ_ M.0ᴹ M.-ᴹ_ M._*ᵣ_ isRightModule isRightModule = record - { isRightSemimodule = isRightSemimodule isSemiring NN.isRightSemimodule + { isRightSemimodule = isRightSemimodule isSemiring NN.isRightSemimodule ; -ᴹ‿cong = -ᴹ‿cong NN.+ᴹ-isMagma NN.-ᴹ‿cong ; -ᴹ‿inverse = -ᴹ‿inverse NN.+ᴹ-isMagma NN.-ᴹ‿inverse } diff --git a/v2.3/Algebra.Module.Morphism.RightSemimoduleMonomorphism.html b/v2.3/Algebra.Module.Morphism.RightSemimoduleMonomorphism.html index 7d3746b716..fd4fd692e1 100644 --- a/v2.3/Algebra.Module.Morphism.RightSemimoduleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.RightSemimoduleMonomorphism.html @@ -24,7 +24,7 @@ open import Algebra.Core using (Op₂) import Algebra.Module.Definitions.Right as RightDefs open import Algebra.Module.Structures using (IsRightSemimodule) -open import Algebra.Structures using (IsMagma; IsSemiring) +open import Algebra.Structures using (IsMagma; IsSemiring) open import Function.Base using (flip; _$_) open import Level using (Level) open import Relation.Binary.Core using (Rel) @@ -125,7 +125,7 @@ ------------------------------------------------------------------------ -- Structures -module _ (R-isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1#) where +module _ (R-isSemiring : IsSemiring _≈_ _+_ _*_ 0# 1#) where private R-semiring : Semiring _ _ diff --git a/v2.3/Algebra.Module.Morphism.SemimoduleMonomorphism.html b/v2.3/Algebra.Module.Morphism.SemimoduleMonomorphism.html index 75e639deb2..cff1246d9f 100644 --- a/v2.3/Algebra.Module.Morphism.SemimoduleMonomorphism.html +++ b/v2.3/Algebra.Module.Morphism.SemimoduleMonomorphism.html @@ -24,7 +24,7 @@ open import Algebra.Core using (Op₂) import Algebra.Module.Definitions.Bi.Simultaneous as SimulDefs open import Algebra.Module.Structures using (IsSemimodule) -open import Algebra.Structures using (IsCommutativeSemiring; IsMagma) +open import Algebra.Structures using (IsCommutativeSemiring; IsMagma) open import Function.Base using (flip; _$_) open import Relation.Binary.Core using (Rel) import Relation.Binary.Reasoning.Setoid as SetoidReasoning @@ -57,19 +57,19 @@ ------------------------------------------------------------------------ -- Structures -module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ 0# 1#} (R-isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1#) where +module _ {ℓr} {_≈_ : Rel R ℓr} {_+_ _*_ 0# 1#} (R-isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1#) where private R-commutativeSemiring : CommutativeSemiring _ _ R-commutativeSemiring = record { isCommutativeSemiring = R-isCommutativeSemiring } - open IsCommutativeSemiring R-isCommutativeSemiring + open IsCommutativeSemiring R-isCommutativeSemiring isSemimodule : IsSemimodule R-commutativeSemiring N._≈ᴹ_ N._+ᴹ_ N.0ᴹ N._*ₗ_ N._*ᵣ_ IsSemimodule R-commutativeSemiring M._≈ᴹ_ M._+ᴹ_ M.0ᴹ M._*ₗ_ M._*ᵣ_ isSemimodule isSemimodule = record - { isBisemimodule = isBisemimodule isSemiring isSemiring NN.isBisemimodule + { isBisemimodule = isBisemimodule isSemiring isSemiring NN.isBisemimodule ; *ₗ-*ᵣ-coincident = *ₗ-*ᵣ-coincident NN.+ᴹ-isMagma NN.*ₗ-*ᵣ-coincident } where diff --git a/v2.3/Algebra.Module.Properties.Semimodule.html b/v2.3/Algebra.Module.Properties.Semimodule.html index a320d6f6ec..b67f48f665 100644 --- a/v2.3/Algebra.Module.Properties.Semimodule.html +++ b/v2.3/Algebra.Module.Properties.Semimodule.html @@ -20,7 +20,7 @@ open CommutativeSemiring semiring open Semimodule semimod open import Relation.Binary.Reasoning.Setoid ≈ᴹ-setoid -open import Relation.Nullary.Negation using (contraposition) +open import Relation.Nullary.Negation using (contraposition) x≈0⇒x*y≈0 : {x y} x 0# x *ₗ y ≈ᴹ 0ᴹ x≈0⇒x*y≈0 {x} {y} x≈0 = begin @@ -35,8 +35,8 @@ 0ᴹ x*y≉0⇒x≉0 : {x y} x *ₗ y ≉ᴹ 0ᴹ x 0# -x*y≉0⇒x≉0 = contraposition x≈0⇒x*y≈0 +x*y≉0⇒x≉0 = contraposition x≈0⇒x*y≈0 x*y≉0⇒y≉0 : {x y} x *ₗ y ≉ᴹ 0ᴹ y ≉ᴹ 0ᴹ -x*y≉0⇒y≉0 = contraposition y≈0⇒x*y≈0 +x*y≉0⇒y≉0 = contraposition y≈0⇒x*y≈0 \ No newline at end of file diff --git a/v2.3/Algebra.Module.Structures.Biased.html b/v2.3/Algebra.Module.Structures.Biased.html index 5ce15ad7fb..d5a27a2573 100644 --- a/v2.3/Algebra.Module.Structures.Biased.html +++ b/v2.3/Algebra.Module.Structures.Biased.html @@ -52,12 +52,12 @@ ; *ᵣ-distribˡ = *ₗ-distribʳ ; *ᵣ-identityʳ = *ₗ-identityˡ ; *ᵣ-assoc = - *ₗ-assoc∧comm⇒*ᵣ-assoc _≈_ ≈ᴹ-setoid *ₗ-congʳ *ₗ-assoc *-comm + *ₗ-assoc∧comm⇒*ᵣ-assoc _≈_ ≈ᴹ-setoid *ₗ-congʳ *ₗ-assoc *-comm ; *ᵣ-zeroˡ = *ₗ-zeroʳ ; *ᵣ-distribʳ = *ₗ-distribˡ } ; *ₗ-*ᵣ-assoc = - *ₗ-assoc∧comm⇒*ₗ-*ᵣ-assoc _≈_ ≈ᴹ-setoid *ₗ-congʳ *ₗ-assoc *-comm + *ₗ-assoc∧comm⇒*ₗ-*ᵣ-assoc _≈_ ≈ᴹ-setoid *ₗ-congʳ *ₗ-assoc *-comm } isSemimodule : IsSemimodule commutativeSemiring ≈ᴹ +ᴹ 0ᴹ *ₗ (flip *ₗ) @@ -85,13 +85,13 @@ ; *ₗ-distribʳ = *ᵣ-distribˡ ; *ₗ-identityˡ = *ᵣ-identityʳ ; *ₗ-assoc = - *ᵣ-assoc∧comm⇒*ₗ-assoc _≈_ ≈ᴹ-setoid *ᵣ-congˡ *ᵣ-assoc *-comm + *ᵣ-assoc∧comm⇒*ₗ-assoc _≈_ ≈ᴹ-setoid *ᵣ-congˡ *ᵣ-assoc *-comm ; *ₗ-zeroʳ = *ᵣ-zeroˡ ; *ₗ-distribˡ = *ᵣ-distribʳ } ; isPrerightSemimodule = isPrerightSemimodule ; *ₗ-*ᵣ-assoc = - *ᵣ-assoc∧comm⇒*ₗ-*ᵣ-assoc _≈_ ≈ᴹ-setoid *ᵣ-congˡ *ᵣ-assoc *-comm + *ᵣ-assoc∧comm⇒*ₗ-*ᵣ-assoc _≈_ ≈ᴹ-setoid *ᵣ-congˡ *ᵣ-assoc *-comm } isSemimodule : IsSemimodule commutativeSemiring ≈ᴹ +ᴹ 0ᴹ (flip *ᵣ) *ᵣ diff --git a/v2.3/Algebra.Morphism.RingMonomorphism.html b/v2.3/Algebra.Morphism.RingMonomorphism.html index b3669e8f46..6e872702a1 100644 --- a/v2.3/Algebra.Morphism.RingMonomorphism.html +++ b/v2.3/Algebra.Morphism.RingMonomorphism.html @@ -31,7 +31,7 @@ using (_DistributesOverˡ_; _DistributesOverʳ_ ; _DistributesOver_ ; LeftZero; RightZero; Zero) open import Algebra.Structures - using (IsRing; IsCommutativeRing; IsGroup; IsMagma) + using (IsRing; IsCommutativeRing; IsGroup; IsMagma) open import Data.Product.Base using (proj₁; proj₂; _,_) import Relation.Binary.Reasoning.Setoid as ≈-Reasoning @@ -147,19 +147,19 @@ x - y ≈⟨ sym (*-homo x (- y)) x * - y ) -isRing : IsRing _≈₂_ _⊕_ _⊛_ ⊝_ 0#₂ 1#₂ IsRing _≈₁_ _+_ _*_ -_ 0# 1# +isRing : IsRing _≈₂_ _⊕_ _⊛_ ⊝_ 0#₂ 1#₂ IsRing _≈₁_ _+_ _*_ -_ 0# 1# isRing isRing = record - { +-isAbelianGroup = isAbelianGroup R.+-isAbelianGroup - ; *-cong = *-cong R.*-isMagma - ; *-assoc = *-assoc R.*-isMagma R.*-assoc - ; *-identity = *-identity R.*-isMagma R.*-identity - ; distrib = distrib R.+-isGroup R.*-isMagma R.distrib - } where module R = IsRing isRing - -isCommutativeRing : IsCommutativeRing _≈₂_ _⊕_ _⊛_ ⊝_ 0#₂ 1#₂ - IsCommutativeRing _≈₁_ _+_ _*_ -_ 0# 1# + { +-isAbelianGroup = isAbelianGroup R.+-isAbelianGroup + ; *-cong = *-cong R.*-isMagma + ; *-assoc = *-assoc R.*-isMagma R.*-assoc + ; *-identity = *-identity R.*-isMagma R.*-identity + ; distrib = distrib R.+-isGroup R.*-isMagma R.distrib + } where module R = IsRing isRing + +isCommutativeRing : IsCommutativeRing _≈₂_ _⊕_ _⊛_ ⊝_ 0#₂ 1#₂ + IsCommutativeRing _≈₁_ _+_ _*_ -_ 0# 1# isCommutativeRing isCommRing = record - { isRing = isRing C.isRing - ; *-comm = *-comm C.*-isMagma C.*-comm - } where module C = IsCommutativeRing isCommRing + { isRing = isRing C.isRing + ; *-comm = *-comm C.*-isMagma C.*-comm + } where module C = IsCommutativeRing isCommRing \ No newline at end of file diff --git a/v2.3/Algebra.Properties.CancellativeCommutativeSemiring.html b/v2.3/Algebra.Properties.CancellativeCommutativeSemiring.html index ac9d50f4d1..810651e968 100644 --- a/v2.3/Algebra.Properties.CancellativeCommutativeSemiring.html +++ b/v2.3/Algebra.Properties.CancellativeCommutativeSemiring.html @@ -17,23 +17,23 @@ open import Data.Sum.Base using (_⊎_; inj₁; inj₂) open import Relation.Binary.Definitions using (Decidable) open import Relation.Nullary.Decidable using (yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open CancellativeCommutativeSemiring R open import Algebra.Consequences.Setoid setoid open import Relation.Binary.Reasoning.Setoid setoid *-almostCancelʳ : AlmostRightCancellative _≈_ 0# _*_ -*-almostCancelʳ = comm∧almostCancelˡ⇒almostCancelʳ *-comm *-cancelˡ-nonZero +*-almostCancelʳ = comm∧almostCancelˡ⇒almostCancelʳ *-comm *-cancelˡ-nonZero xy≈0⇒x≈0∨y≈0 : Decidable _≈_ {x y} x * y 0# x 0# y 0# xy≈0⇒x≈0∨y≈0 _≟_ {x} {y} xy≈0 with x 0# | y 0# ... | yes x≈0 | _ = inj₁ x≈0 ... | no _ | yes y≈0 = inj₂ y≈0 -... | no x≉0 | no y≉0 = contradiction y≈0 y≉0 +... | no x≉0 | no y≉0 = contradiction y≈0 y≉0 where - xy≈x*0 = trans xy≈0 (sym (zeroʳ x)) - y≈0 = *-cancelˡ-nonZero _ y 0# x≉0 xy≈x*0 + xy≈x*0 = trans xy≈0 (sym (zeroʳ x)) + y≈0 = *-cancelˡ-nonZero _ y 0# x≉0 xy≈x*0 x≉0∧y≉0⇒xy≉0 : Decidable _≈_ {x y} x 0# y 0# x * y 0# x≉0∧y≉0⇒xy≉0 _≟_ x≉0 y≉0 xy≈0 with xy≈0⇒x≈0∨y≈0 _≟_ xy≈0 diff --git a/v2.3/Algebra.Properties.CommutativeMonoid.Mult.html b/v2.3/Algebra.Properties.CommutativeMonoid.Mult.html index ff95515bb7..d364f50f8b 100644 --- a/v2.3/Algebra.Properties.CommutativeMonoid.Mult.html +++ b/v2.3/Algebra.Properties.CommutativeMonoid.Mult.html @@ -42,7 +42,7 @@ ×-distrib-+ x y (suc n) = begin x + y + n × (x + y) ≈⟨ +-congˡ (×-distrib-+ x y n) x + y + (n × x + n × y) ≈⟨ +-assoc x y (n × x + n × y) - x + (y + (n × x + n × y)) ≈⟨ +-congˡ (x∙yz≈y∙xz y (n × x) (n × y)) + x + (y + (n × x + n × y)) ≈⟨ +-congˡ (x∙yz≈y∙xz y (n × x) (n × y)) x + (n × x + suc n × y) ≈⟨ x∙yz≈xy∙z x (n × x) (suc n × y) suc n × x + suc n × y \ No newline at end of file diff --git a/v2.3/Algebra.Properties.CommutativeMonoid.Sum.html b/v2.3/Algebra.Properties.CommutativeMonoid.Sum.html index f5c912a9db..f0615c5fa9 100644 --- a/v2.3/Algebra.Properties.CommutativeMonoid.Sum.html +++ b/v2.3/Algebra.Properties.CommutativeMonoid.Sum.html @@ -11,12 +11,12 @@ open import Data.Bool.Base using (Bool; true; false) open import Data.Nat.Base as using (; zero; suc; NonZero) open import Data.Fin.Base using (Fin; zero; suc) -open import Data.Fin.Permutation as Perm using (Permutation; _⟨$⟩ˡ_; _⟨$⟩ʳ_) +open import Data.Fin.Permutation as Perm using (Permutation; _⟨$⟩ˡ_; _⟨$⟩ʳ_) open import Data.Fin.Patterns using (0F) open import Data.Vec.Functional using (Vector; rearrange; removeAt; tail; head) open import Function.Base using (_∘_) open import Relation.Binary.PropositionalEquality.Core as using (_≡_) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) module Algebra.Properties.CommutativeMonoid.Sum {a } (M : CommutativeMonoid a ) where @@ -85,24 +85,24 @@ ∑[ j < n ] (f zero j + ∑[ i < m ] f (suc i) j) -- Summation is insensitive to permutations of the input -sum-permute : {m n} f (π : Permutation m n) sum f sum (rearrange (π ⟨$⟩ʳ_) f) +sum-permute : {m n} f (π : Permutation m n) sum f sum (rearrange (π ⟨$⟩ʳ_) f) sum-permute {zero} {zero} f π = refl -sum-permute {zero} {suc n} f π = contradiction π (Perm.refute λ()) -sum-permute {suc m} {zero} f π = contradiction π (Perm.refute λ()) +sum-permute {zero} {suc n} f π = contradiction π (Perm.refute λ()) +sum-permute {suc m} {zero} f π = contradiction π (Perm.refute λ()) sum-permute {suc m} {suc n} f π = begin sum f ≡⟨⟩ - f 0F + sum f/0 ≡⟨ ≡.cong (_+ sum f/0) (≡.cong f (Perm.inverseʳ π)) - πf π₀ + sum f/0 ≈⟨ +-congˡ (sum-permute f/0 (Perm.remove π₀ π)) - πf π₀ + sum (rearrange (π/0 ⟨$⟩ʳ_) f/0) ≡⟨ ≡.cong (πf π₀ +_) (sum-cong-≗ (≡.cong f Perm.punchIn-permute′ π 0F)) + f 0F + sum f/0 ≡⟨ ≡.cong (_+ sum f/0) (≡.cong f (Perm.inverseʳ π)) + πf π₀ + sum f/0 ≈⟨ +-congˡ (sum-permute f/0 (Perm.remove π₀ π)) + πf π₀ + sum (rearrange (π/0 ⟨$⟩ʳ_) f/0) ≡⟨ ≡.cong (πf π₀ +_) (sum-cong-≗ (≡.cong f Perm.punchIn-permute′ π 0F)) πf π₀ + sum (removeAt πf π₀) ≈⟨ sym (sum-remove πf) sum πf where f/0 = removeAt f 0F - π₀ = π ⟨$⟩ˡ 0F - π/0 = Perm.remove π₀ π - πf = rearrange (π ⟨$⟩ʳ_) f + π₀ = π ⟨$⟩ˡ 0F + π/0 = Perm.remove π₀ π + πf = rearrange (π ⟨$⟩ʳ_) f -∑-permute : {m n} (f : Vector Carrier n) (π : Permutation m n) - ∑[ i < n ] f i ∑[ i < m ] f (π ⟨$⟩ʳ i) +∑-permute : {m n} (f : Vector Carrier n) (π : Permutation m n) + ∑[ i < n ] f i ∑[ i < m ] f (π ⟨$⟩ʳ i) ∑-permute f π = sum-permute f π \ No newline at end of file diff --git a/v2.3/Algebra.Properties.CommutativeSemigroup.Divisibility.html b/v2.3/Algebra.Properties.CommutativeSemigroup.Divisibility.html index e173b21ebd..0fb99a7c89 100644 --- a/v2.3/Algebra.Properties.CommutativeSemigroup.Divisibility.html +++ b/v2.3/Algebra.Properties.CommutativeSemigroup.Divisibility.html @@ -8,48 +8,48 @@ {-# OPTIONS --cubical-compatible --safe #-} open import Algebra using (CommutativeSemigroup) - -module Algebra.Properties.CommutativeSemigroup.Divisibility - {a } (commutativeSemigroup : CommutativeSemigroup a ) - where - -open import Data.Product.Base using (_,_) - -open CommutativeSemigroup commutativeSemigroup -open import Algebra.Properties.CommutativeSemigroup commutativeSemigroup - using (medial; x∙yz≈xz∙y; x∙yz≈y∙xz) -open import Relation.Binary.Reasoning.Setoid setoid - ------------------------------------------------------------------------- --- Re-export the contents of divisibility over semigroups - -open import Algebra.Properties.Semigroup.Divisibility semigroup public - ------------------------------------------------------------------------- --- Re-export the contents of divisibility over commutative magmas - -open import Algebra.Properties.CommutativeMagma.Divisibility commutativeMagma public - using (x∣xy; xy≈z⇒x∣z; ∣-factors; ∣-factors-≈) - ------------------------------------------------------------------------- --- New properties - -x∣y∧z∣x/y⇒xz∣y : {x y z} ((x/y , _) : x y) z x/y x z y -x∣y∧z∣x/y⇒xz∣y {x} {y} {z} (x/y , x/y∙x≈y) (p , pz≈x/y) = p , (begin - p (x z) ≈⟨ x∙yz≈xz∙y p x z - (p z) x ≈⟨ ∙-congʳ pz≈x/y - x/y x ≈⟨ x/y∙x≈y - y ) - -∙-cong-∣ : {x y a b} x y a b x a y b -∙-cong-∣ {x} {y} {a} {b} (p , px≈y) (q , qa≈b) = p q , (begin - (p q) (x a) ≈⟨ medial p q x a - (p x) (q a) ≈⟨ ∙-cong px≈y qa≈b - y b ) - -x∣y⇒zx∣zy : {x y} z x y z x z y -x∣y⇒zx∣zy {x} {y} z (q , qx≈y) = q , (begin - q (z x) ≈⟨ x∙yz≈y∙xz q z x - z (q x) ≈⟨ ∙-congˡ qx≈y - z y ) +open import Data.Product.Base using (_,_) +import Relation.Binary.Reasoning.Setoid as ≈-Reasoning + +module Algebra.Properties.CommutativeSemigroup.Divisibility + {a } (CS : CommutativeSemigroup a ) + where + +open CommutativeSemigroup CS +open import Algebra.Properties.CommutativeSemigroup CS + using (interchange; x∙yz≈xz∙y; x∙yz≈y∙xz) +open ≈-Reasoning setoid + +------------------------------------------------------------------------ +-- Re-export the contents of divisibility over semigroups + +open import Algebra.Properties.Semigroup.Divisibility semigroup public + +------------------------------------------------------------------------ +-- Re-export the contents of divisibility over commutative magmas + +open import Algebra.Properties.CommutativeMagma.Divisibility commutativeMagma public + using (x∣xy; xy≈z⇒x∣z; ∣-factors; ∣-factors-≈) + +------------------------------------------------------------------------ +-- New properties + +x∣y∧z∣x/y⇒xz∣y : {x y z} ((x/y , _) : x y) z x/y x z y +x∣y∧z∣x/y⇒xz∣y {x} {y} {z} (x/y , x/y∙x≈y) (p , pz≈x/y) = p , (begin + p (x z) ≈⟨ x∙yz≈xz∙y p x z + (p z) x ≈⟨ ∙-congʳ pz≈x/y + x/y x ≈⟨ x/y∙x≈y + y ) + +∙-cong-∣ : {x y a b} x y a b x a y b +∙-cong-∣ {x} {y} {a} {b} (p , px≈y) (q , qa≈b) = p q , (begin + (p q) (x a) ≈⟨ interchange p q x a + (p x) (q a) ≈⟨ ∙-cong px≈y qa≈b + y b ) + +x∣y⇒zx∣zy : {x y} z x y z x z y +x∣y⇒zx∣zy {x} {y} z (q , qx≈y) = q , (begin + q (z x) ≈⟨ x∙yz≈y∙xz q z x + z (q x) ≈⟨ ∙-congˡ qx≈y + z y ) \ No newline at end of file diff --git a/v2.3/Algebra.Properties.CommutativeSemigroup.html b/v2.3/Algebra.Properties.CommutativeSemigroup.html index 930a0ae6ac..ee5cda840e 100644 --- a/v2.3/Algebra.Properties.CommutativeSemigroup.html +++ b/v2.3/Algebra.Properties.CommutativeSemigroup.html @@ -10,181 +10,166 @@ open import Algebra.Bundles using (CommutativeSemigroup) module Algebra.Properties.CommutativeSemigroup - {a } (commutativeSemigroup : CommutativeSemigroup a ) - where + {a } (CS : CommutativeSemigroup a ) + where -open CommutativeSemigroup commutativeSemigroup -open import Algebra.Definitions _≈_ -open import Relation.Binary.Reasoning.Setoid setoid -open import Data.Product.Base using (_,_) +open CommutativeSemigroup CS +open import Algebra.Definitions _≈_ +open import Relation.Binary.Reasoning.Setoid setoid +open import Data.Product.Base using (_,_) ------------------------------------------------------------------------- --- Re-export the contents of semigroup +------------------------------------------------------------------------ +-- Re-export the contents of semigroup -open import Algebra.Properties.Semigroup semigroup public +open import Algebra.Properties.Semigroup semigroup public ------------------------------------------------------------------------- --- Properties +------------------------------------------------------------------------ +-- Properties -medial : Medial _∙_ -medial a b c d = begin - (a b) (c d) ≈⟨ assoc a b (c d) - a (b (c d)) ≈⟨ ∙-congˡ (assoc b c d) - a ((b c) d) ≈⟨ ∙-congˡ (∙-congʳ (comm b c)) - a ((c b) d) ≈⟨ ∙-congˡ (assoc c b d) - a (c (b d)) ≈⟨ assoc a c (b d) - (a c) (b d) +interchange : Interchangable _∙_ _∙_ +interchange a b c d = begin + (a b) (c d) ≈⟨ assoc a b (c d) + a (b (c d)) ≈⟨ ∙-congˡ (assoc b c d) + a ((b c) d) ≈⟨ ∙-congˡ (∙-congʳ (comm b c)) + a ((c b) d) ≈⟨ ∙-congˡ (assoc c b d) + a (c (b d)) ≈⟨ assoc a c (b d) + (a c) (b d) ------------------------------------------------------------------------- --- Permutation laws for _∙_ for three factors. +------------------------------------------------------------------------ +-- Permutation laws for _∙_ for three factors. --- There are five nontrivial permutations. +-- There are five nontrivial permutations. ------------------------------------------------------------------------- --- Partitions (1,1). +------------------------------------------------------------------------ +-- Partitions (1,1). -x∙yz≈y∙xz : x y z x (y z) y (x z) -x∙yz≈y∙xz x y z = begin - x (y z) ≈⟨ sym (assoc x y z) - (x y) z ≈⟨ ∙-congʳ (comm x y) - (y x) z ≈⟨ assoc y x z - y (x z) +x∙yz≈y∙xz : x y z x (y z) y (x z) +x∙yz≈y∙xz x y z = begin + x (y z) ≈⟨ sym (assoc x y z) + (x y) z ≈⟨ ∙-congʳ (comm x y) + (y x) z ≈⟨ assoc y x z + y (x z) -x∙yz≈z∙yx : x y z x (y z) z (y x) -x∙yz≈z∙yx x y z = begin - x (y z) ≈⟨ ∙-congˡ (comm y z) - x (z y) ≈⟨ x∙yz≈y∙xz x z y - z (x y) ≈⟨ ∙-congˡ (comm x y) - z (y x) +x∙yz≈z∙yx : x y z x (y z) z (y x) +x∙yz≈z∙yx x y z = begin + x (y z) ≈⟨ ∙-congˡ (comm y z) + x (z y) ≈⟨ x∙yz≈y∙xz x z y + z (x y) ≈⟨ ∙-congˡ (comm x y) + z (y x) -x∙yz≈x∙zy : x y z x (y z) x (z y) -x∙yz≈x∙zy _ y z = ∙-congˡ (comm y z) +x∙yz≈x∙zy : x y z x (y z) x (z y) +x∙yz≈x∙zy _ y z = ∙-congˡ (comm y z) -x∙yz≈y∙zx : x y z x (y z) y (z x) -x∙yz≈y∙zx x y z = begin - x (y z) ≈⟨ comm x _ - (y z) x ≈⟨ assoc y z x - y (z x) +x∙yz≈y∙zx : x y z x (y z) y (z x) +x∙yz≈y∙zx x y z = begin + x (y z) ≈⟨ comm x _ + (y z) x ≈⟨ assoc y z x + y (z x) -x∙yz≈z∙xy : x y z x (y z) z (x y) -x∙yz≈z∙xy x y z = begin - x (y z) ≈⟨ sym (assoc x y z) - (x y) z ≈⟨ comm _ z - z (x y) +x∙yz≈z∙xy : x y z x (y z) z (x y) +x∙yz≈z∙xy x y z = begin + x (y z) ≈⟨ sym (assoc x y z) + (x y) z ≈⟨ comm _ z + z (x y) ------------------------------------------------------------------------- --- Partitions (1,2). +------------------------------------------------------------------------ +-- Partitions (1,2). --- These permutation laws are proved by composing the proofs for --- partitions (1,1) with \p → trans p (sym (assoc _ _ _)). +-- These permutation laws are proved by composing the proofs for +-- partitions (1,1) with \p → trans p (sym (assoc _ _ _)). -x∙yz≈yx∙z : x y z x (y z) (y x) z -x∙yz≈yx∙z x y z = trans (x∙yz≈y∙xz x y z) (sym (assoc y x z)) +x∙yz≈yx∙z : x y z x (y z) (y x) z +x∙yz≈yx∙z x y z = trans (x∙yz≈y∙xz x y z) (sym (assoc y x z)) -x∙yz≈zy∙x : x y z x (y z) (z y) x -x∙yz≈zy∙x x y z = trans (x∙yz≈z∙yx x y z) (sym (assoc z y x)) +x∙yz≈zy∙x : x y z x (y z) (z y) x +x∙yz≈zy∙x x y z = trans (x∙yz≈z∙yx x y z) (sym (assoc z y x)) -x∙yz≈xz∙y : x y z x (y z) (x z) y -x∙yz≈xz∙y x y z = trans (x∙yz≈x∙zy x y z) (sym (assoc x z y)) +x∙yz≈xz∙y : x y z x (y z) (x z) y +x∙yz≈xz∙y x y z = trans (x∙yz≈x∙zy x y z) (sym (assoc x z y)) -x∙yz≈yz∙x : x y z x (y z) (y z) x -x∙yz≈yz∙x x y z = trans (x∙yz≈y∙zx _ _ _) (sym (assoc y z x)) +x∙yz≈yz∙x : x y z x (y z) (y z) x +x∙yz≈yz∙x x y z = trans (x∙yz≈y∙zx _ _ _) (sym (assoc y z x)) -x∙yz≈zx∙y : x y z x (y z) (z x) y -x∙yz≈zx∙y x y z = trans (x∙yz≈z∙xy x y z) (sym (assoc z x y)) +x∙yz≈zx∙y : x y z x (y z) (z x) y +x∙yz≈zx∙y x y z = trans (x∙yz≈z∙xy x y z) (sym (assoc z x y)) ------------------------------------------------------------------------- --- Partitions (2,1). +------------------------------------------------------------------------ +-- Partitions (2,1). --- Their laws are proved by composing proofs for partitions (1,1) with --- trans (assoc x y z). +-- Their laws are proved by composing proofs for partitions (1,1) with +-- trans (assoc x y z). -xy∙z≈y∙xz : x y z (x y) z y (x z) -xy∙z≈y∙xz x y z = trans (assoc x y z) (x∙yz≈y∙xz x y z) +xy∙z≈y∙xz : x y z (x y) z y (x z) +xy∙z≈y∙xz x y z = trans (assoc x y z) (x∙yz≈y∙xz x y z) -xy∙z≈z∙yx : x y z (x y) z z (y x) -xy∙z≈z∙yx x y z = trans (assoc x y z) (x∙yz≈z∙yx x y z) +xy∙z≈z∙yx : x y z (x y) z z (y x) +xy∙z≈z∙yx x y z = trans (assoc x y z) (x∙yz≈z∙yx x y z) -xy∙z≈x∙zy : x y z (x y) z x (z y) -xy∙z≈x∙zy x y z = trans (assoc x y z) (x∙yz≈x∙zy x y z) +xy∙z≈x∙zy : x y z (x y) z x (z y) +xy∙z≈x∙zy x y z = trans (assoc x y z) (x∙yz≈x∙zy x y z) -xy∙z≈y∙zx : x y z (x y) z y (z x) -xy∙z≈y∙zx x y z = trans (assoc x y z) (x∙yz≈y∙zx x y z) +xy∙z≈y∙zx : x y z (x y) z y (z x) +xy∙z≈y∙zx x y z = trans (assoc x y z) (x∙yz≈y∙zx x y z) -xy∙z≈z∙xy : x y z (x y) z z (x y) -xy∙z≈z∙xy x y z = trans (assoc x y z) (x∙yz≈z∙xy x y z) +xy∙z≈z∙xy : x y z (x y) z z (x y) +xy∙z≈z∙xy x y z = trans (assoc x y z) (x∙yz≈z∙xy x y z) ------------------------------------------------------------------------- --- Partitions (2,2). +------------------------------------------------------------------------ +-- Partitions (2,2). --- These proofs are by composing with the proofs for (2,1). +-- These proofs are by composing with the proofs for (2,1). -xy∙z≈yx∙z : x y z (x y) z (y x) z -xy∙z≈yx∙z x y z = trans (xy∙z≈y∙xz _ _ _) (sym (assoc y x z)) +xy∙z≈yx∙z : x y z (x y) z (y x) z +xy∙z≈yx∙z x y z = trans (xy∙z≈y∙xz _ _ _) (sym (assoc y x z)) -xy∙z≈zy∙x : x y z (x y) z (z y) x -xy∙z≈zy∙x x y z = trans (xy∙z≈z∙yx x y z) (sym (assoc z y x)) +xy∙z≈zy∙x : x y z (x y) z (z y) x +xy∙z≈zy∙x x y z = trans (xy∙z≈z∙yx x y z) (sym (assoc z y x)) -xy∙z≈xz∙y : x y z (x y) z (x z) y -xy∙z≈xz∙y x y z = trans (xy∙z≈x∙zy x y z) (sym (assoc x z y)) +xy∙z≈xz∙y : x y z (x y) z (x z) y +xy∙z≈xz∙y x y z = trans (xy∙z≈x∙zy x y z) (sym (assoc x z y)) -xy∙z≈yz∙x : x y z (x y) z (y z) x -xy∙z≈yz∙x x y z = trans (xy∙z≈y∙zx x y z) (sym (assoc y z x)) +xy∙z≈yz∙x : x y z (x y) z (y z) x +xy∙z≈yz∙x x y z = trans (xy∙z≈y∙zx x y z) (sym (assoc y z x)) -xy∙z≈zx∙y : x y z (x y) z (z x) y -xy∙z≈zx∙y x y z = trans (xy∙z≈z∙xy x y z) (sym (assoc z x y)) +xy∙z≈zx∙y : x y z (x y) z (z x) y +xy∙z≈zx∙y x y z = trans (xy∙z≈z∙xy x y z) (sym (assoc z x y)) ------------------------------------------------------------------------- --- commutative semigroup has Jordan identity +------------------------------------------------------------------------ +-- commutative semigroup has Jordan identity -xy∙xx≈x∙yxx : x y (x y) (x x) x (y (x x)) -xy∙xx≈x∙yxx x y = assoc x y ((x x)) +xy∙xx≈x∙yxx : x y (x y) (x x) x (y (x x)) +xy∙xx≈x∙yxx x y = assoc x y ((x x)) ------------------------------------------------------------------------- --- commutative semigroup is left/right/middle semiMedial +------------------------------------------------------------------------ +-- commutative semigroup is left/right/middle semiMedial -semimedialˡ : LeftSemimedial _∙_ -semimedialˡ x y z = begin - (x x) (y z) ≈⟨ assoc x x (y z) - x (x (y z)) ≈⟨ ∙-congˡ (sym (assoc x y z)) - x ((x y) z) ≈⟨ ∙-congˡ (∙-congʳ (comm x y)) - x ((y x) z) ≈⟨ ∙-congˡ (assoc y x z) - x (y (x z)) ≈⟨ sym (assoc x y ((x z))) - (x y) (x z) +semimedialˡ : LeftSemimedial _∙_ +semimedialˡ x y z = begin + (x x) (y z) ≈⟨ assoc x x (y z) + x (x (y z)) ≈⟨ ∙-congˡ (sym (assoc x y z)) + x ((x y) z) ≈⟨ ∙-congˡ (∙-congʳ (comm x y)) + x ((y x) z) ≈⟨ ∙-congˡ (assoc y x z) + x (y (x z)) ≈⟨ sym (assoc x y ((x z))) + (x y) (x z) -semimedialʳ : RightSemimedial _∙_ -semimedialʳ x y z = begin - (y z) (x x) ≈⟨ assoc y z (x x) - y (z (x x)) ≈⟨ ∙-congˡ (sym (assoc z x x)) - y ((z x) x) ≈⟨ ∙-congˡ (∙-congʳ (comm z x)) - y ((x z) x) ≈⟨ ∙-congˡ (assoc x z x) - y (x (z x)) ≈⟨ sym (assoc y x ((z x))) - (y x) (z x) +semimedialʳ : RightSemimedial _∙_ +semimedialʳ x y z = begin + (y z) (x x) ≈⟨ assoc y z (x x) + y (z (x x)) ≈⟨ ∙-congˡ (sym (assoc z x x)) + y ((z x) x) ≈⟨ ∙-congˡ (∙-congʳ (comm z x)) + y ((x z) x) ≈⟨ ∙-congˡ (assoc x z x) + y (x (z x)) ≈⟨ sym (assoc y x ((z x))) + (y x) (z x) -middleSemimedial : x y z (x y) (z x) (x z) (y x) -middleSemimedial x y z = begin - (x y) (z x) ≈⟨ assoc x y ((z x)) - x (y (z x)) ≈⟨ ∙-congˡ (sym (assoc y z x)) - x ((y z) x) ≈⟨ ∙-congˡ (∙-congʳ (comm y z)) - x ((z y) x) ≈⟨ ∙-congˡ ( assoc z y x) - x (z (y x)) ≈⟨ sym (assoc x z ((y x))) - (x z) (y x) +middleSemimedial : x y z (x y) (z x) (x z) (y x) +middleSemimedial x y z = begin + (x y) (z x) ≈⟨ assoc x y ((z x)) + x (y (z x)) ≈⟨ ∙-congˡ (sym (assoc y z x)) + x ((y z) x) ≈⟨ ∙-congˡ (∙-congʳ (comm y z)) + x ((z y) x) ≈⟨ ∙-congˡ ( assoc z y x) + x (z (y x)) ≈⟨ sym (assoc x z ((y x))) + (x z) (y x) -semimedial : Semimedial _∙_ -semimedial = semimedialˡ , semimedialʳ - - ------------------------------------------------------------------------- --- DEPRECATED NAMES ------------------------------------------------------------------------- --- Please use the new names as continuing support for the old names is --- not guaranteed. - --- Version 2.3 - -interchange = medial -{-# WARNING_ON_USAGE interchange -"Warning: interchange was deprecated in v2.3. -Please use medial instead." -#-} +semimedial : Semimedial _∙_ +semimedial = semimedialˡ , semimedialʳ \ No newline at end of file diff --git a/v2.3/Algebra.Properties.CommutativeSemiring.Binomial.html b/v2.3/Algebra.Properties.CommutativeSemiring.Binomial.html index a628e0566d..2dd8ac07c6 100644 --- a/v2.3/Algebra.Properties.CommutativeSemiring.Binomial.html +++ b/v2.3/Algebra.Properties.CommutativeSemiring.Binomial.html @@ -14,12 +14,12 @@ open CommutativeSemiring S open import Algebra.Properties.Semiring.Exp semiring using (_^_) import Algebra.Properties.Semiring.Binomial semiring as Binomial -open Binomial public hiding (theorem) +open Binomial public hiding (theorem) ------------------------------------------------------------------------ -- Here it is -theorem : n x y (x + y) ^ n binomialExpansion x y n -theorem n x y = Binomial.theorem x y (*-comm x y) n +theorem : n x y (x + y) ^ n binomialExpansion x y n +theorem n x y = Binomial.theorem x y (*-comm x y) n \ No newline at end of file diff --git a/v2.3/Algebra.Properties.CommutativeSemiring.Exp.TCOptimised.html b/v2.3/Algebra.Properties.CommutativeSemiring.Exp.TCOptimised.html index 1875af79bb..ece03c32d5 100644 --- a/v2.3/Algebra.Properties.CommutativeSemiring.Exp.TCOptimised.html +++ b/v2.3/Algebra.Properties.CommutativeSemiring.Exp.TCOptimised.html @@ -21,7 +21,7 @@ ------------------------------------------------------------------------ -- Re-export definition and properties for semirings open import Data.Nat.Base as using (zero; suc) -import Data.Nat.Properties as using (+-assoc; +-identityˡ; +-identityʳ) +import Data.Nat.Properties as using (+-assoc; +-identityˡ; +-identityʳ) open import Relation.Binary.PropositionalEquality.Core using (_≡_) open import Algebra.Properties.Semiring.Exp.TCOptimised semiring public diff --git a/v2.3/Algebra.Properties.Group.html b/v2.3/Algebra.Properties.Group.html index e6ff25936d..586fb8aa7d 100644 --- a/v2.3/Algebra.Properties.Group.html +++ b/v2.3/Algebra.Properties.Group.html @@ -20,7 +20,7 @@ open Group G open import Algebra.Consequences.Setoid setoid open import Algebra.Definitions _≈_ -open import Algebra.Structures _≈_ using (IsLoop; IsQuasigroup) +open import Algebra.Structures _≈_ using (IsLoop; IsQuasigroup) open import Relation.Binary.Reasoning.Setoid setoid \\-cong₂ : Congruent₂ _\\_ @@ -67,13 +67,13 @@ //-rightDivides : RightDivides _∙_ _//_ //-rightDivides = //-rightDividesˡ , //-rightDividesʳ -isQuasigroup : IsQuasigroup _∙_ _\\_ _//_ +isQuasigroup : IsQuasigroup _∙_ _\\_ _//_ isQuasigroup = record - { isMagma = isMagma - ; \\-cong = \\-cong₂ - ; //-cong = //-cong₂ - ; leftDivides = \\-leftDivides - ; rightDivides = //-rightDivides + { isMagma = isMagma + ; \\-cong = \\-cong₂ + ; //-cong = //-cong₂ + ; leftDivides = \\-leftDivides + ; rightDivides = //-rightDivides } quasigroup : Quasigroup _ _ @@ -86,8 +86,8 @@ ------------------------------------------------------------------------ -- Groups are loops -isLoop : IsLoop _∙_ _\\_ _//_ ε -isLoop = record { isQuasigroup = isQuasigroup ; identity = identity } +isLoop : IsLoop _∙_ _\\_ _//_ ε +isLoop = record { isQuasigroup = isQuasigroup ; identity = identity } loop : Loop _ _ loop = record { isLoop = isLoop } diff --git a/v2.3/Algebra.Properties.IdempotentCommutativeMonoid.html b/v2.3/Algebra.Properties.IdempotentCommutativeMonoid.html index 0d97298dc7..9c2cb1e528 100644 --- a/v2.3/Algebra.Properties.IdempotentCommutativeMonoid.html +++ b/v2.3/Algebra.Properties.IdempotentCommutativeMonoid.html @@ -10,31 +10,31 @@ open import Algebra.Bundles using (IdempotentCommutativeMonoid) module Algebra.Properties.IdempotentCommutativeMonoid - {c } (idempotentCommutativeMonoid : IdempotentCommutativeMonoid c ) where + {c } (M : IdempotentCommutativeMonoid c ) where -open IdempotentCommutativeMonoid idempotentCommutativeMonoid +open IdempotentCommutativeMonoid M -open import Algebra.Consequences.Setoid setoid - using (comm∧distrˡ⇒distrʳ; comm∧distrˡ⇒distr) -open import Algebra.Definitions _≈_ - using (_DistributesOverˡ_; _DistributesOverʳ_; _DistributesOver_) -open import Algebra.Properties.CommutativeSemigroup commutativeSemigroup - using (medial) -open import Relation.Binary.Reasoning.Setoid setoid +open import Algebra.Consequences.Setoid setoid + using (comm∧distrˡ⇒distrʳ; comm∧distrˡ⇒distr) +open import Algebra.Definitions _≈_ + using (_DistributesOverˡ_; _DistributesOverʳ_; _DistributesOver_) +open import Algebra.Properties.CommutativeSemigroup commutativeSemigroup + using (interchange) +open import Relation.Binary.Reasoning.Setoid setoid ------------------------------------------------------------------------- --- Distributivity +------------------------------------------------------------------------ +-- Distributivity -∙-distrˡ-∙ : _∙_ DistributesOverˡ _∙_ -∙-distrˡ-∙ a b c = begin - a (b c) ≈⟨ ∙-congʳ (idem a) - (a a) (b c) ≈⟨ medial _ _ _ _ - (a b) (a c) +∙-distrˡ-∙ : _∙_ DistributesOverˡ _∙_ +∙-distrˡ-∙ a b c = begin + a (b c) ≈⟨ ∙-congʳ (idem a) + (a a) (b c) ≈⟨ interchange _ _ _ _ + (a b) (a c) -∙-distrʳ-∙ : _∙_ DistributesOverʳ _∙_ -∙-distrʳ-∙ = comm∧distrˡ⇒distrʳ ∙-cong comm ∙-distrˡ-∙ +∙-distrʳ-∙ : _∙_ DistributesOverʳ _∙_ +∙-distrʳ-∙ = comm∧distrˡ⇒distrʳ ∙-cong comm ∙-distrˡ-∙ -∙-distr-∙ : _∙_ DistributesOver _∙_ -∙-distr-∙ = comm∧distrˡ⇒distr ∙-cong comm ∙-distrˡ-∙ +∙-distr-∙ : _∙_ DistributesOver _∙_ +∙-distr-∙ = comm∧distrˡ⇒distr ∙-cong comm ∙-distrˡ-∙ \ No newline at end of file diff --git a/v2.3/Algebra.Properties.KleeneAlgebra.html b/v2.3/Algebra.Properties.KleeneAlgebra.html index 62bc8edbe9..8b74b8a2a8 100644 --- a/v2.3/Algebra.Properties.KleeneAlgebra.html +++ b/v2.3/Algebra.Properties.KleeneAlgebra.html @@ -17,115 +17,115 @@ 0⋆≈1 : 0# 1# 0⋆≈1 = begin - 0# ≈⟨ sym (starExpansiveˡ 0#) - 1# + 0# * 0# ≈⟨ +-congˡ ( zeroʳ (0# )) - 1# + 0# ≈⟨ +-identityʳ 1# + 0# ≈⟨ sym (starExpansiveˡ 0#) + 1# + 0# * 0# ≈⟨ +-congˡ ( zeroʳ (0# )) + 1# + 0# ≈⟨ +-identityʳ 1# 1# 1+x⋆≈x⋆ : x 1# + x x 1+x⋆≈x⋆ x = sym (begin - x ≈⟨ sym (starExpansiveʳ x) - 1# + x * x ≈⟨ +-congʳ (sym (+-idem 1#)) - 1# + 1# + x * x ≈⟨ +-assoc 1# 1# ((x * x )) - 1# + (1# + x * x ) ≈⟨ +-congˡ (starExpansiveʳ x) + x ≈⟨ sym (starExpansiveʳ x) + 1# + x * x ≈⟨ +-congʳ (sym (+-idem 1#)) + 1# + 1# + x * x ≈⟨ +-assoc 1# 1# ((x * x )) + 1# + (1# + x * x ) ≈⟨ +-congˡ (starExpansiveʳ x) 1# + x ) x⋆+xx⋆≈x⋆ : x x + x * x x x⋆+xx⋆≈x⋆ x = begin - x + x * x ≈⟨ +-congʳ (sym (1+x⋆≈x⋆ x)) - 1# + x + x * x ≈⟨ +-congʳ (+-comm 1# ((x ))) - x + 1# + x * x ≈⟨ +-assoc ((x )) 1# ((x * x )) - x + (1# + x * x ) ≈⟨ +-congˡ (starExpansiveʳ x) - x + x ≈⟨ +-idem (x ) + x + x * x ≈⟨ +-congʳ (sym (1+x⋆≈x⋆ x)) + 1# + x + x * x ≈⟨ +-congʳ (+-comm 1# ((x ))) + x + 1# + x * x ≈⟨ +-assoc ((x )) 1# ((x * x )) + x + (1# + x * x ) ≈⟨ +-congˡ (starExpansiveʳ x) + x + x ≈⟨ +-idem (x ) x x⋆+x⋆x≈x⋆ : x x + x * x x x⋆+x⋆x≈x⋆ x = begin - x + x * x ≈⟨ +-congʳ (sym (1+x⋆≈x⋆ x)) - 1# + x + x * x ≈⟨ +-congʳ (+-comm 1# (x )) - x + 1# + x * x ≈⟨ +-assoc (x ) 1# (x * x) - x + (1# + x * x) ≈⟨ +-congˡ (starExpansiveˡ x) - x + x ≈⟨ +-idem (x ) + x + x * x ≈⟨ +-congʳ (sym (1+x⋆≈x⋆ x)) + 1# + x + x * x ≈⟨ +-congʳ (+-comm 1# (x )) + x + 1# + x * x ≈⟨ +-assoc (x ) 1# (x * x) + x + (1# + x * x) ≈⟨ +-congˡ (starExpansiveˡ x) + x + x ≈⟨ +-idem (x ) x x+x⋆≈x⋆ : x x + x x x+x⋆≈x⋆ x = begin - x + x ≈⟨ +-congˡ (sym (starExpansiveʳ x)) - x + (1# + x * x ) ≈⟨ +-congʳ (sym (*-identityʳ x)) - x * 1# + (1# + x * x ) ≈⟨ sym (+-assoc (x * 1#) 1# (x * x )) - x * 1# + 1# + x * x ≈⟨ +-congʳ (+-comm (x * 1#) 1#) - 1# + x * 1# + x * x ≈⟨ +-assoc 1# (x * 1#) (x * x ) - 1# + (x * 1# + x * x ) ≈⟨ +-congˡ (sym (distribˡ x 1# ((x )))) - 1# + x * (1# + x ) ≈⟨ +-congˡ (*-congˡ (1+x⋆≈x⋆ x)) - 1# + x * x ≈⟨ (starExpansiveʳ x) + x + x ≈⟨ +-congˡ (sym (starExpansiveʳ x)) + x + (1# + x * x ) ≈⟨ +-congʳ (sym (*-identityʳ x)) + x * 1# + (1# + x * x ) ≈⟨ sym (+-assoc (x * 1#) 1# (x * x )) + x * 1# + 1# + x * x ≈⟨ +-congʳ (+-comm (x * 1#) 1#) + 1# + x * 1# + x * x ≈⟨ +-assoc 1# (x * 1#) (x * x ) + 1# + (x * 1# + x * x ) ≈⟨ +-congˡ (sym (distribˡ x 1# ((x )))) + 1# + x * (1# + x ) ≈⟨ +-congˡ (*-congˡ (1+x⋆≈x⋆ x)) + 1# + x * x ≈⟨ (starExpansiveʳ x) x 1+x+x⋆≈x⋆ : x 1# + x + x x 1+x+x⋆≈x⋆ x = begin - 1# + x + x ≈⟨ +-assoc 1# x (x ) - 1# + (x + x ) ≈⟨ +-congˡ (x+x⋆≈x⋆ x) + 1# + x + x ≈⟨ +-assoc 1# x (x ) + 1# + (x + x ) ≈⟨ +-congˡ (x+x⋆≈x⋆ x) 1# + x ≈⟨ 1+x⋆≈x⋆ x x 0+x+x⋆≈x⋆ : x 0# + x + x x 0+x+x⋆≈x⋆ x = begin - 0# + x + x ≈⟨ +-assoc 0# x (x ) - 0# + (x + x ) ≈⟨ +-identityˡ ((x + x )) + 0# + x + x ≈⟨ +-assoc 0# x (x ) + 0# + (x + x ) ≈⟨ +-identityˡ ((x + x )) (x + x ) ≈⟨ x+x⋆≈x⋆ x x x⋆x⋆≈x⋆ : x x * x x -x⋆x⋆≈x⋆ x = starDestructiveˡ x (x ) (x ) (x⋆+xx⋆≈x⋆ x) +x⋆x⋆≈x⋆ x = starDestructiveˡ x (x ) (x ) (x⋆+xx⋆≈x⋆ x) 1+x⋆x⋆≈x⋆ : x 1# + x * x x 1+x⋆x⋆≈x⋆ x = begin - 1# + x * x ≈⟨ +-congˡ (x⋆x⋆≈x⋆ x) + 1# + x * x ≈⟨ +-congˡ (x⋆x⋆≈x⋆ x) 1# + x ≈⟨ 1+x⋆≈x⋆ x x x⋆⋆≈x⋆ : x (x ) x x⋆⋆≈x⋆ x = begin - (x ) ≈⟨ sym (*-identityʳ ((x ) )) - (x ) * 1# ≈⟨ starDestructiveˡ (x ) 1# (x ) (1+x⋆x⋆≈x⋆ x) + (x ) ≈⟨ sym (*-identityʳ ((x ) )) + (x ) * 1# ≈⟨ starDestructiveˡ (x ) 1# (x ) (1+x⋆x⋆≈x⋆ x) x 1+11≈1 : 1# + 1# * 1# 1# 1+11≈1 = begin - 1# + 1# * 1# ≈⟨ +-congˡ ( *-identityʳ 1#) - 1# + 1# ≈⟨ +-idem 1# + 1# + 1# * 1# ≈⟨ +-congˡ ( *-identityʳ 1#) + 1# + 1# ≈⟨ +-idem 1# 1# 1⋆≈1 : 1# 1# 1⋆≈1 = begin - 1# ≈⟨ sym (*-identityʳ (1# )) - 1# * 1# ≈⟨ starDestructiveˡ 1# 1# 1# 1+11≈1 + 1# ≈⟨ sym (*-identityʳ (1# )) + 1# * 1# ≈⟨ starDestructiveˡ 1# 1# 1# 1+11≈1 1# x≈y⇒1+xy⋆≈y⋆ : x y x y 1# + x * y y x≈y⇒1+xy⋆≈y⋆ x y eq = begin - 1# + x * y ≈⟨ +-congˡ (*-congʳ (eq)) - 1# + y * y ≈⟨ starExpansiveʳ y + 1# + x * y ≈⟨ +-congˡ (*-congʳ (eq)) + 1# + y * y ≈⟨ starExpansiveʳ y y x≈y⇒x⋆≈y⋆ : x y x y x y x≈y⇒x⋆≈y⋆ x y eq = begin - x ≈⟨ sym (*-identityʳ (x )) - x * 1# ≈⟨ (starDestructiveˡ x 1# (y ) (x≈y⇒1+xy⋆≈y⋆ x y eq)) + x ≈⟨ sym (*-identityʳ (x )) + x * 1# ≈⟨ (starDestructiveˡ x 1# (y ) (x≈y⇒1+xy⋆≈y⋆ x y eq)) y ax≈xb⇒x+axb⋆≈xb⋆ : x a b a * x x * b x + a * (x * b ) x * b ax≈xb⇒x+axb⋆≈xb⋆ x a b eq = begin - x + a * (x * b ) ≈⟨ +-congˡ (sym(*-assoc a x (b ))) - x + a * x * b ≈⟨ +-congʳ (sym (*-identityʳ x)) - x * 1# + a * x * b ≈⟨ +-congˡ (*-congʳ (eq)) - x * 1# + x * b * b ≈⟨ +-congˡ (*-assoc x b (b ) ) - x * 1# + x * (b * b ) ≈⟨ sym (distribˡ x 1# (b * b )) - x * (1# + b * b ) ≈⟨ *-congˡ (starExpansiveʳ b) + x + a * (x * b ) ≈⟨ +-congˡ (sym(*-assoc a x (b ))) + x + a * x * b ≈⟨ +-congʳ (sym (*-identityʳ x)) + x * 1# + a * x * b ≈⟨ +-congˡ (*-congʳ (eq)) + x * 1# + x * b * b ≈⟨ +-congˡ (*-assoc x b (b ) ) + x * 1# + x * (b * b ) ≈⟨ sym (distribˡ x 1# (b * b )) + x * (1# + b * b ) ≈⟨ *-congˡ (starExpansiveʳ b) x * b ax≈xb⇒a⋆x≈xb⋆ : x a b a * x x * b a * x x * b -ax≈xb⇒a⋆x≈xb⋆ x a b eq = starDestructiveˡ a x ((x * b )) (ax≈xb⇒x+axb⋆≈xb⋆ x a b eq) +ax≈xb⇒a⋆x≈xb⋆ x a b eq = starDestructiveˡ a x ((x * b )) (ax≈xb⇒x+axb⋆≈xb⋆ x a b eq) [xy]⋆x≈x[yx]⋆ : x y (x * y) * x x * (y * x) -[xy]⋆x≈x[yx]⋆ x y = ax≈xb⇒a⋆x≈xb⋆ x (x * y) (y * x) (*-assoc x y x) +[xy]⋆x≈x[yx]⋆ x y = ax≈xb⇒a⋆x≈xb⋆ x (x * y) (y * x) (*-assoc x y x) \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Loop.html b/v2.3/Algebra.Properties.Loop.html index f89242f9d6..9c3b593d56 100644 --- a/v2.3/Algebra.Properties.Loop.html +++ b/v2.3/Algebra.Properties.Loop.html @@ -18,16 +18,16 @@ open import Relation.Binary.Reasoning.Setoid setoid x//x≈ε : x x // x ε -x//x≈ε x = sym (x≈z//y _ _ _ (identityˡ x)) +x//x≈ε x = sym (x≈z//y _ _ _ (identityˡ x)) x\\x≈ε : x x \\ x ε -x\\x≈ε x = sym (y≈x\\z _ _ _ (identityʳ x)) +x\\x≈ε x = sym (y≈x\\z _ _ _ (identityʳ x)) ε\\x≈x : x ε \\ x x -ε\\x≈x x = sym (y≈x\\z _ _ _ (identityˡ x)) +ε\\x≈x x = sym (y≈x\\z _ _ _ (identityˡ x)) x//ε≈x : x x // ε x -x//ε≈x x = sym (x≈z//y _ _ _ (identityʳ x)) +x//ε≈x x = sym (x≈z//y _ _ _ (identityʳ x)) identityˡ-unique : x y x y y x ε identityˡ-unique x y eq = begin diff --git a/v2.3/Algebra.Properties.Magma.Divisibility.html b/v2.3/Algebra.Properties.Magma.Divisibility.html index e01a32fac4..93b9c7206b 100644 --- a/v2.3/Algebra.Properties.Magma.Divisibility.html +++ b/v2.3/Algebra.Properties.Magma.Divisibility.html @@ -14,7 +14,7 @@ open import Data.Product.Base using (_,_; swap) open import Relation.Binary.Definitions using (_Respects_; _Respectsˡ_; _Respectsʳ_; _Respects₂_; Symmetric) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open Magma M @@ -64,10 +64,10 @@ -- Properties of non-divisibility ∤-respˡ-≈ : _∤_ Respectsˡ _≈_ -∤-respˡ-≈ x≈y x∤z y∣ʳz = contradiction (∣ʳ-respˡ-≈ (sym x≈y) y∣ʳz) x∤z +∤-respˡ-≈ x≈y x∤z y∣ʳz = contradiction (∣ʳ-respˡ-≈ (sym x≈y) y∣ʳz) x∤z ∤-respʳ-≈ : _∤_ Respectsʳ _≈_ -∤-respʳ-≈ x≈y z∤x z∣ʳy = contradiction (∣ʳ-respʳ-≈ (sym x≈y) z∣ʳy) z∤x +∤-respʳ-≈ x≈y z∤x z∣ʳy = contradiction (∣ʳ-respʳ-≈ (sym x≈y) z∣ʳy) z∤x ∤-resp-≈ : _∤_ Respects₂ _≈_ ∤-resp-≈ = ∤-respʳ-≈ , ∤-respˡ-≈ @@ -91,13 +91,13 @@ -- Properties of mutual non-divisibility _∤∤_ ∦-sym : Symmetric _∦_ -∦-sym x∦y y∥x = contradiction (∥-sym y∥x) x∦y +∦-sym x∦y y∥x = contradiction (∥-sym y∥x) x∦y ∦-respˡ-≈ : _∦_ Respectsˡ _≈_ -∦-respˡ-≈ x≈y x∦z y∥z = contradiction (∥-respˡ-≈ (sym x≈y) y∥z) x∦z +∦-respˡ-≈ x≈y x∦z y∥z = contradiction (∥-respˡ-≈ (sym x≈y) y∥z) x∦z ∦-respʳ-≈ : _∦_ Respectsʳ _≈_ -∦-respʳ-≈ x≈y z∦x z∥y = contradiction (∥-respʳ-≈ (sym x≈y) z∥y) z∦x +∦-respʳ-≈ x≈y z∦x z∥y = contradiction (∥-respʳ-≈ (sym x≈y) z∥y) z∦x ∦-resp-≈ : _∦_ Respects₂ _≈_ ∦-resp-≈ = ∦-respʳ-≈ , ∦-respˡ-≈ diff --git a/v2.3/Algebra.Properties.MiddleBolLoop.html b/v2.3/Algebra.Properties.MiddleBolLoop.html index b4dc0934aa..5493e8662f 100644 --- a/v2.3/Algebra.Properties.MiddleBolLoop.html +++ b/v2.3/Algebra.Properties.MiddleBolLoop.html @@ -19,42 +19,42 @@ xyx\\x≈y\\x : x y x ((y x) \\ x) y \\ x xyx\\x≈y\\x x y = begin - x ((y x) \\ x) ≈⟨ middleBol x y x + x ((y x) \\ x) ≈⟨ middleBol x y x (x // x) (y \\ x) ≈⟨ ∙-congʳ (x//x≈ε x) - ε (y \\ x) ≈⟨ identityˡ ((y \\ x)) + ε (y \\ x) ≈⟨ identityˡ ((y \\ x)) y \\ x xxz\\x≈x//z : x z x ((x z) \\ x) x // z xxz\\x≈x//z x z = begin - x ((x z) \\ x) ≈⟨ middleBol x x z + x ((x z) \\ x) ≈⟨ middleBol x x z (x // z) (x \\ x) ≈⟨ ∙-congˡ (x\\x≈ε x) - (x // z) ε ≈⟨ identityʳ ((x // z)) + (x // z) ε ≈⟨ identityʳ ((x // z)) x // z xz\\x≈x//zx : x z x (z \\ x) (x // z) x xz\\x≈x//zx x z = begin - x (z \\ x) ≈⟨ ∙-congˡ (\\-congʳ( sym (identityˡ z))) - x ((ε z) \\ x) ≈⟨ middleBol x ε z + x (z \\ x) ≈⟨ ∙-congˡ (\\-congʳ( sym (identityˡ z))) + x ((ε z) \\ x) ≈⟨ middleBol x ε z x // z (ε \\ x) ≈⟨ ∙-congˡ (ε\\x≈x x) x // z x x//yzx≈x//zy\\x : x y z (x // (y z)) x (x // z) (y \\ x) x//yzx≈x//zy\\x x y z = begin (x // (y z)) x ≈⟨ sym (xz\\x≈x//zx x ((y z))) - x ((y z) \\ x) ≈⟨ middleBol x y z + x ((y z) \\ x) ≈⟨ middleBol x y z (x // z) (y \\ x) x//yxx≈y\\x : x y (x // (y x)) x y \\ x x//yxx≈y\\x x y = begin (x // (y x)) x ≈⟨ x//yzx≈x//zy\\x x y x (x // x) (y \\ x) ≈⟨ ∙-congʳ (x//x≈ε x) - ε (y \\ x) ≈⟨ identityˡ ((y \\ x)) + ε (y \\ x) ≈⟨ identityˡ ((y \\ x)) y \\ x x//xzx≈x//z : x z (x // (x z)) x x // z x//xzx≈x//z x z = begin (x // (x z)) x ≈⟨ x//yzx≈x//zy\\x x x z (x // z) (x \\ x) ≈⟨ ∙-congˡ (x\\x≈ε x) - (x // z) ε ≈⟨ identityʳ (x // z) + (x // z) ε ≈⟨ identityʳ (x // z) x // z \ No newline at end of file diff --git a/v2.3/Algebra.Properties.MoufangLoop.html b/v2.3/Algebra.Properties.MoufangLoop.html index c74e593b9a..aaa9ae8895 100644 --- a/v2.3/Algebra.Properties.MoufangLoop.html +++ b/v2.3/Algebra.Properties.MoufangLoop.html @@ -18,16 +18,16 @@ alternativeˡ : LeftAlternative _∙_ alternativeˡ x y = begin - (x x) y ≈⟨ ∙-congʳ (∙-congˡ (sym (identityˡ x))) - (x (ε x)) y ≈⟨ sym (leftBol x ε y) - x (ε (x y)) ≈⟨ ∙-congˡ (identityˡ ((x y))) + (x x) y ≈⟨ ∙-congʳ (∙-congˡ (sym (identityˡ x))) + (x (ε x)) y ≈⟨ sym (leftBol x ε y) + x (ε (x y)) ≈⟨ ∙-congˡ (identityˡ ((x y))) x (x y) alternativeʳ : RightAlternative _∙_ alternativeʳ x y = begin - x (y y) ≈⟨ ∙-congˡ(∙-congʳ(sym (identityʳ y))) - x ((y ε) y) ≈⟨ sym (rightBol y ε x) - ((x y) ε ) y ≈⟨ ∙-congʳ (identityʳ ((x y))) + x (y y) ≈⟨ ∙-congˡ(∙-congʳ(sym (identityʳ y))) + x ((y ε) y) ≈⟨ sym (rightBol y ε x) + ((x y) ε ) y ≈⟨ ∙-congʳ (identityʳ ((x y))) (x y) y alternative : Alternative _∙_ @@ -35,21 +35,21 @@ flex : Flexible _∙_ flex x y = begin - (x y) x ≈⟨ ∙-congˡ (sym (identityˡ x)) - (x y) (ε x) ≈⟨ identical y ε x - x ((y ε) x) ≈⟨ ∙-congˡ (∙-congʳ (identityʳ y)) + (x y) x ≈⟨ ∙-congˡ (sym (identityˡ x)) + (x y) (ε x) ≈⟨ identical y ε x + x ((y ε) x) ≈⟨ ∙-congˡ (∙-congʳ (identityʳ y)) x (y x) z∙xzy≈zxz∙y : x y z (z (x (z y))) (((z x) z) y) z∙xzy≈zxz∙y x y z = sym (begin ((z x) z) y ≈⟨ (∙-congʳ (flex z x )) - (z (x z)) y ≈⟨ sym (leftBol z x y) + (z (x z)) y ≈⟨ sym (leftBol z x y) z (x (z y)) ) x∙zyz≈xzy∙z : x y z (x (z (y z))) (((x z) y) z) x∙zyz≈xzy∙z x y z = begin x (z (y z)) ≈⟨ (∙-congˡ (sym (flex z y ))) - x ((z y) z) ≈⟨ sym (rightBol z y x) + x ((z y) z) ≈⟨ sym (rightBol z y x) ((x z) y) z z∙xyz≈zxy∙z : x y z (z ((x y) z)) ((z (x y)) z) diff --git a/v2.3/Algebra.Properties.Quasigroup.html b/v2.3/Algebra.Properties.Quasigroup.html index 85eee22246..cfb007917a 100644 --- a/v2.3/Algebra.Properties.Quasigroup.html +++ b/v2.3/Algebra.Properties.Quasigroup.html @@ -18,26 +18,26 @@ y≈x\\z : x y z x y z y x \\ z y≈x\\z x y z eq = begin - y ≈⟨ leftDividesʳ x y - x \\ (x y) ≈⟨ \\-congˡ eq + y ≈⟨ leftDividesʳ x y + x \\ (x y) ≈⟨ \\-congˡ eq x \\ z x≈z//y : x y z x y z x z // y x≈z//y x y z eq = begin - x ≈⟨ rightDividesʳ y x - (x y) // y ≈⟨ //-congʳ eq + x ≈⟨ rightDividesʳ y x + (x y) // y ≈⟨ //-congʳ eq z // y cancelˡ : LeftCancellative _∙_ cancelˡ x y z eq = begin y ≈⟨ y≈x\\z x y (x z) eq - x \\ (x z) ≈⟨ leftDividesʳ x z + x \\ (x z) ≈⟨ leftDividesʳ x z z cancelʳ : RightCancellative _∙_ cancelʳ x y z eq = begin y ≈⟨ x≈z//y y x (z x) eq - (z x) // x ≈⟨ rightDividesʳ x z + (z x) // x ≈⟨ rightDividesʳ x z z cancel : Cancellative _∙_ diff --git a/v2.3/Algebra.Properties.Ring.html b/v2.3/Algebra.Properties.Ring.html index ff9dcc3e47..478af89c4f 100644 --- a/v2.3/Algebra.Properties.Ring.html +++ b/v2.3/Algebra.Properties.Ring.html @@ -28,7 +28,7 @@ -1*x≈-x : x - 1# * x - x -1*x≈-x x = begin - - 1# * x ≈⟨ -‿distribˡ-* 1# x - - (1# * x) ≈⟨ -‿cong ( *-identityˡ x ) + - 1# * x ≈⟨ -‿distribˡ-* 1# x + - (1# * x) ≈⟨ -‿cong ( *-identityˡ x ) - x \ No newline at end of file diff --git a/v2.3/Algebra.Properties.RingWithoutOne.html b/v2.3/Algebra.Properties.RingWithoutOne.html index e2e0ae33a1..eec8b89eb6 100644 --- a/v2.3/Algebra.Properties.RingWithoutOne.html +++ b/v2.3/Algebra.Properties.RingWithoutOne.html @@ -18,69 +18,59 @@ open import Relation.Binary.Reasoning.Setoid setoid ------------------------------------------------------------------------ --- Re-export abelian group properties for addition +-- Export properties of abelian groups -open AbelianGroupProperties +-abelianGroup public - renaming - ( ε⁻¹≈ε to -0#≈0# - ; ∙-cancelˡ to +-cancelˡ - ; ∙-cancelʳ to +-cancelʳ - ; ∙-cancel to +-cancel - ; ⁻¹-involutive to -‿involutive - ; ⁻¹-injective to -‿injective - ; ⁻¹-anti-homo-∙ to -‿anti-homo-+ - ; identityˡ-unique to +-identityˡ-unique - ; identityʳ-unique to +-identityʳ-unique - ; identity-unique to +-identity-unique - ; inverseˡ-unique to +-inverseˡ-unique - ; inverseʳ-unique to +-inverseʳ-unique - ; ⁻¹-∙-comm to -‿+-comm - ) +open AbelianGroupProperties +-abelianGroup public + renaming + ( ε⁻¹≈ε to -0#≈0# + ; ∙-cancelˡ to +-cancelˡ + ; ∙-cancelʳ to +-cancelʳ + ; ∙-cancel to +-cancel + ; ⁻¹-involutive to -‿involutive + ; ⁻¹-injective to -‿injective + ; ⁻¹-anti-homo-∙ to -‿anti-homo-+ + ; identityˡ-unique to +-identityˡ-unique + ; identityʳ-unique to +-identityʳ-unique + ; identity-unique to +-identity-unique + ; inverseˡ-unique to +-inverseˡ-unique + ; inverseʳ-unique to +-inverseʳ-unique + ; ⁻¹-∙-comm to -‿+-comm + ) -x+x≈x⇒x≈0 : x x + x x x 0# -x+x≈x⇒x≈0 x eq = +-identityˡ-unique x x eq +-‿distribˡ-* : x y - (x * y) - x * y +-‿distribˡ-* x y = sym $ begin + - x * y ≈⟨ +-identityʳ (- x * y) + - x * y + 0# ≈⟨ +-congˡ $ -‿inverseʳ (x * y) + - x * y + (x * y + - (x * y)) ≈⟨ +-assoc (- x * y) (x * y) (- (x * y)) + - x * y + x * y + - (x * y) ≈⟨ +-congʳ $ distribʳ y (- x) x + (- x + x) * y + - (x * y) ≈⟨ +-congʳ $ *-congʳ $ -‿inverseˡ x + 0# * y + - (x * y) ≈⟨ +-congʳ $ zeroˡ y + 0# + - (x * y) ≈⟨ +-identityˡ (- (x * y)) + - (x * y) ------------------------------------------------------------------------- --- Consequences of distributivity +-‿distribʳ-* : x y - (x * y) x * - y +-‿distribʳ-* x y = sym $ begin + x * - y ≈⟨ +-identityˡ (x * - y) + 0# + x * - y ≈⟨ +-congʳ $ -‿inverseˡ (x * y) + - (x * y) + x * y + x * - y ≈⟨ +-assoc (- (x * y)) (x * y) (x * - y) + - (x * y) + (x * y + x * - y) ≈⟨ +-congˡ $ distribˡ x y (- y) + - (x * y) + x * (y + - y) ≈⟨ +-congˡ $ *-congˡ $ -‿inverseʳ y + - (x * y) + x * 0# ≈⟨ +-congˡ $ zeroʳ x + - (x * y) + 0# ≈⟨ +-identityʳ (- (x * y)) + - (x * y) --‿distribˡ-* : x y - (x * y) - x * y --‿distribˡ-* x y = sym $ begin - - x * y ≈⟨ +-identityʳ (- x * y) - - x * y + 0# ≈⟨ +-congˡ $ -‿inverseʳ (x * y) - - x * y + (x * y + - (x * y)) ≈⟨ +-assoc (- x * y) (x * y) (- (x * y)) - - x * y + x * y + - (x * y) ≈⟨ +-congʳ $ distribʳ y (- x) x - (- x + x) * y + - (x * y) ≈⟨ +-congʳ $ *-congʳ $ -‿inverseˡ x - 0# * y + - (x * y) ≈⟨ +-congʳ $ zeroˡ y - 0# + - (x * y) ≈⟨ +-identityˡ (- (x * y)) - - (x * y) +x+x≈x⇒x≈0 : x x + x x x 0# +x+x≈x⇒x≈0 x eq = +-identityˡ-unique x x eq --‿distribʳ-* : x y - (x * y) x * - y --‿distribʳ-* x y = sym $ begin - x * - y ≈⟨ +-identityˡ (x * - y) - 0# + x * - y ≈⟨ +-congʳ $ -‿inverseˡ (x * y) - - (x * y) + x * y + x * - y ≈⟨ +-assoc (- (x * y)) (x * y) (x * - y) - - (x * y) + (x * y + x * - y) ≈⟨ +-congˡ $ distribˡ x y (- y) - - (x * y) + x * (y + - y) ≈⟨ +-congˡ $ *-congˡ $ -‿inverseʳ y - - (x * y) + x * 0# ≈⟨ +-congˡ $ zeroʳ x - - (x * y) + 0# ≈⟨ +-identityʳ (- (x * y)) - - (x * y) +x[y-z]≈xy-xz : x y z x * (y - z) x * y - x * z +x[y-z]≈xy-xz x y z = begin + x * (y - z) ≈⟨ distribˡ x y (- z) + x * y + x * - z ≈⟨ +-congˡ (sym (-‿distribʳ-* x z)) + x * y - x * z -[-x][-y]≈xy : x y - x * - y x * y -[-x][-y]≈xy x y = begin - - x * - y ≈⟨ -‿distribˡ-* x (- y) - - (x * - y) ≈⟨ -‿cong (-‿distribʳ-* x y) - - (- (x * y)) ≈⟨ -‿involutive (x * y) - x * y - -x[y-z]≈xy-xz : x y z x * (y - z) x * y - x * z -x[y-z]≈xy-xz x y z = begin - x * (y - z) ≈⟨ distribˡ x y (- z) - x * y + x * - z ≈⟨ +-congˡ (-‿distribʳ-* x z) - x * y - x * z - -[y-z]x≈yx-zx : x y z (y - z) * x (y * x) - (z * x) -[y-z]x≈yx-zx x y z = begin - (y - z) * x ≈⟨ distribʳ x y (- z) - y * x + - z * x ≈⟨ +-congˡ (-‿distribˡ-* z x) - y * x - z * x +[y-z]x≈yx-zx : x y z (y - z) * x (y * x) - (z * x) +[y-z]x≈yx-zx x y z = begin + (y - z) * x ≈⟨ distribʳ x y (- z) + y * x + - z * x ≈⟨ +-congˡ (sym (-‿distribˡ-* z x)) + y * x - z * x \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Semiring.Binomial.html b/v2.3/Algebra.Properties.Semiring.Binomial.html index ecebec79c5..8d66e86657 100644 --- a/v2.3/Algebra.Properties.Semiring.Binomial.html +++ b/v2.3/Algebra.Properties.Semiring.Binomial.html @@ -20,219 +20,219 @@ open import Data.Bool.Base using (true) open import Data.Nat.Base as hiding (_+_; _*_; _^_) open import Data.Nat.Combinatorics - using (_C_; nCn≡1; nC1≡n; nCk+nC[k+1]≡[n+1]C[k+1]) + using (_C_; nCn≡1; nC1≡n; nCk+nC[k+1]≡[n+1]C[k+1]) open import Data.Nat.Properties as - using (<⇒<ᵇ; n<1+n; n∸n≡0; ∸-suc) -open import Data.Fin.Base as Fin - using (Fin; zero; suc; toℕ; fromℕ; inject₁) -open import Data.Fin.Patterns using (0F) -open import Data.Fin.Properties as Fin - using (toℕ<n; toℕ-fromℕ; toℕ-inject₁) -open import Data.Fin.Relation.Unary.Top - using (view; ‵fromℕ; ‵inject₁; view-fromℕ; view-inject₁) -open import Function.Base using (_∘_) -open import Relation.Binary.PropositionalEquality.Core as - using (_≡_; _≢_; cong) - -open import Algebra.Definitions _≈_ -open import Algebra.Properties.Semiring.Sum S -open import Algebra.Properties.Semiring.Mult S -open import Algebra.Properties.Semiring.Exp S -open import Relation.Binary.Reasoning.Setoid setoid - ------------------------------------------------------------------------- --- Definitions - --- Note - `n` could be implicit in many of these definitions, but the --- code is more readable if left explicit. - -binomial : (n : ) Fin (suc n) Carrier -binomial n k = (x ^ toℕ k) * (y ^ (n toℕ k)) - -binomialTerm : (n : ) Fin (suc n) Carrier -binomialTerm n k = (n C toℕ k) × binomial n k - -binomialExpansion : Carrier -binomialExpansion n = ∑[ k n ] (binomialTerm n k) - -term₁ : (n : ) Fin (suc (suc n)) Carrier -term₁ n zero = 0# -term₁ n (suc k) = x * (binomialTerm n k) - -term₂ : (n : ) Fin (suc (suc n)) Carrier -term₂ n k with view k -... | ‵fromℕ = 0# -... | ‵inject₁ j = y * binomialTerm n j - -sum₁ : Carrier -sum₁ n = ∑[ k suc n ] term₁ n k - -sum₂ : Carrier -sum₂ n = ∑[ k suc n ] term₂ n k - ------------------------------------------------------------------------- --- Properties - -term₂[n,n+1]≈0# : n term₂ n (fromℕ (suc n)) 0# -term₂[n,n+1]≈0# n rewrite view-fromℕ (suc n) = refl - -lemma₁ : n x * binomialExpansion n sum₁ n -lemma₁ n = begin - x * binomialExpansion n ≈⟨ *-distribˡ-sum x (binomialTerm n) - ∑[ i n ] (x * binomialTerm n i) ≈⟨ +-identityˡ _ - 0# + ∑[ i n ] (x * binomialTerm n i) ≡⟨⟩ - 0# + ∑[ i n ] term₁ n (suc i) ≡⟨⟩ - sum₁ n - -lemma₂ : n y * binomialExpansion n sum₂ n -lemma₂ n = begin - y * binomialExpansion n ≈⟨ *-distribˡ-sum y (binomialTerm n) - ∑[ i n ] (y * binomialTerm n i) ≈⟨ +-identityʳ _ - ∑[ i n ] (y * binomialTerm n i) + 0# ≈⟨ +-cong (sum-cong-≋ lemma₂-inject₁) (sym (term₂[n,n+1]≈0# n)) - (∑[ i n ] term₂-inject₁ i) + term₂ n [n+1] ≈⟨ sum-init-last (term₂ n) - sum (term₂ n) ≡⟨⟩ - sum₂ n - where - [n+1] = fromℕ (suc n) - - term₂-inject₁ : (i : Fin (suc n)) Carrier - term₂-inject₁ i = term₂ n (inject₁ i) - - lemma₂-inject₁ : i y * binomialTerm n i term₂-inject₁ i - lemma₂-inject₁ i rewrite view-inject₁ i = refl - ------------------------------------------------------------------------- --- Next, a lemma which is independent of commutativity - -x*lemma : {n} (i : Fin (suc n)) - x * binomialTerm n i (n C toℕ i) × binomial (suc n) (suc i) -x*lemma {n} i = begin - x * binomialTerm n i ≡⟨⟩ - x * ((n C k) × (x ^ k * y ^ (n k))) ≈⟨ *-congˡ (×-assoc-* (n C k) _ _) - x * ((n C k) × x ^ k * y ^ (n k)) ≈⟨ *-assoc x ((n C k) × x ^ k) _ - (x * (n C k) × x ^ k) * y ^ (n k) ≈⟨ *-congʳ (×-comm-* (n C k) _ _) - (n C k) × x ^ (suc k) * y ^ (n k) ≡⟨⟩ - (n C k) × x ^ (suc k) * y ^ (suc n suc k) ≈⟨ ×-assoc-* (n C k) _ _ - (n C k) × binomial (suc n) (suc i) - where k = toℕ i - ------------------------------------------------------------------------- --- Next, a lemma which does require commutativity - -y*lemma : x * y y * x {n : } (j : Fin n) - y * binomialTerm n (suc j) (n C toℕ (suc j)) × binomial (suc n) (suc (inject₁ j)) -y*lemma x*y≈y*x {n} j = begin - y * binomialTerm n (suc j) - ≈⟨ ×-comm-* nC[j+1] y (binomial n (suc j)) - nC[j+1] × (y * binomial n (suc j)) - ≈⟨ ×-congʳ nC[j+1] (y*x^m*y^n≈x^m*y^[n+1] x*y≈y*x [j+1] [n-j-1]) - nC[j+1] × (x ^ [j+1] * y ^ [n-j]) - ≈⟨ ×-congʳ nC[j+1] (*-congʳ (^-congʳ x (cong suc k≡j))) - nC[j+1] × (x ^ [k+1] * y ^ [n-j]) - ≈⟨ ×-congʳ nC[j+1] (*-congˡ (^-congʳ y [n-k]≡[n-j])) - nC[j+1] × (x ^ [k+1] * y ^ [n-k]) - ≡⟨⟩ - nC[j+1] × (x ^ [k+1] * y ^ [n+1]-[k+1]) - ≡⟨⟩ - (n C toℕ (suc j)) × binomial (suc n) (suc i) - where - i = inject₁ j - k = toℕ i - [k+1] = ℕ.suc k - [j+1] = toℕ (suc j) - [n-k] = n k - [n+1]-[k+1] = [n-k] - [n-j-1] = n [j+1] - [n-j] = ℕ.suc [n-j-1] - nC[j+1] = n C [j+1] - - k≡j : k toℕ j - k≡j = toℕ-inject₁ j - - [n-k]≡[n-j] : [n-k] [n-j] - [n-k]≡[n-j] = ≡.trans (cong (n ∸_) k≡j) (∸-suc (toℕ<n j)) - ------------------------------------------------------------------------- --- Now, a lemma characterising the sum of the term₁ and term₂ expressions - -private - n<ᵇ1+n : n (n ℕ.<ᵇ suc n) true - n<ᵇ1+n n with truen ℕ.<ᵇ suc n | _<⇒<ᵇ (n<1+n n) = ≡.refl - -term₁+term₂≈term : x * y y * x n i term₁ n i + term₂ n i binomialTerm (suc n) i - -term₁+term₂≈term x*y≈y*x n 0F = begin - term₁ n 0F + term₂ n 0F ≡⟨⟩ - 0# + y * (1 × (1# * y ^ n)) ≈⟨ +-identityˡ _ - y * (1 × (1# * y ^ n)) ≈⟨ *-congˡ (+-identityʳ (1# * y ^ n)) - y * (1# * y ^ n) ≈⟨ *-congˡ (*-identityˡ (y ^ n)) - y * y ^ n ≡⟨⟩ - y ^ suc n ≈⟨ *-identityˡ (y ^ suc n) - 1# * y ^ suc n ≈⟨ +-identityʳ (1# * y ^ suc n) - 1 × (1# * y ^ suc n) ≡⟨⟩ - binomialTerm (suc n) 0F - -term₁+term₂≈term x*y≈y*x n (suc i) with view i -... | ‵fromℕ {n} -{- remembering that i = fromℕ n, definitionally -} - rewrite toℕ-fromℕ n - | nCn≡1 n - | n∸n≡0 n - | n<ᵇ1+n n - = begin - x * ((x ^ n * 1#) + 0#) + 0# ≈⟨ +-identityʳ _ - x * ((x ^ n * 1#) + 0#) ≈⟨ *-congˡ (+-identityʳ _) - x * (x ^ n * 1#) ≈⟨ *-assoc _ _ _ - x * x ^ n * 1# ≈⟨ +-identityʳ _ - 1 × (x * x ^ n * 1#) - -... | ‵inject₁ j -{- remembering that i = inject₁ j, definitionally -} - = begin - (x * binomialTerm n i) + (y * binomialTerm n (suc j)) - ≈⟨ +-cong (x*lemma i) (y*lemma x*y≈y*x j) - (nCk × [x^k+1]*[y^n-k]) + (nC[j+1] × [x^k+1]*[y^n-k]) - ≈⟨ +-congˡ (×-congˡ nC[k+1]≡nC[j+1]) - (nCk × [x^k+1]*[y^n-k]) + (nC[k+1] × [x^k+1]*[y^n-k]) - ≈⟨ ×-homo-+ [x^k+1]*[y^n-k] nCk nC[k+1] - (nCk ℕ.+ nC[k+1]) × [x^k+1]*[y^n-k] - ≡⟨ cong ( [x^k+1]*[y^n-k]) (nCk+nC[k+1]≡[n+1]C[k+1] n k) - ((suc n) C (suc k)) × [x^k+1]*[y^n-k] - ≡⟨⟩ - binomialTerm (suc n) (suc i) - where - k = toℕ i - [k+1] = ℕ.suc k - [j+1] = toℕ (suc j) - nCk = n C k - nC[k+1] = n C [k+1] - nC[j+1] = n C [j+1] - [x^k+1]*[y^n-k] = binomial (suc n) (suc i) - - nC[k+1]≡nC[j+1] : nC[k+1] nC[j+1] - nC[k+1]≡nC[j+1] = cong ((n C_) suc) (toℕ-inject₁ j) - ------------------------------------------------------------------------- --- Finally, the main result - -theorem : x * y y * x n (x + y) ^ n binomialExpansion n -theorem x*y≈y*x zero = begin - (x + y) ^ 0 ≡⟨⟩ - 1# ≈⟨ ×-homo-1 1# - 1 × 1# ≈⟨ *-identityʳ (1 × 1#) - (1 × 1#) * 1# ≈⟨ ×-assoc-* 1 1# 1# - 1 × (1# * 1#) ≡⟨⟩ - 1 × (x ^ 0 * y ^ 0) ≈⟨ +-identityʳ _ - 1 × (x ^ 0 * y ^ 0) + 0# ≡⟨⟩ - (0 C 0) × (x ^ 0 * y ^ 0) + 0# ≡⟨⟩ - binomialExpansion 0 -theorem x*y≈y*x n+1@(suc n) = begin - (x + y) ^ n+1 ≡⟨⟩ - (x + y) * (x + y) ^ n ≈⟨ *-congˡ (theorem x*y≈y*x n) - (x + y) * binomialExpansion n ≈⟨ distribʳ _ _ _ - x * binomialExpansion n + y * binomialExpansion n ≈⟨ +-cong (lemma₁ n) (lemma₂ n) - sum₁ n + sum₂ n ≈⟨ ∑-distrib-+ (term₁ n) (term₂ n) - ∑[ i n+1 ] (term₁ n i + term₂ n i) ≈⟨ sum-cong-≋ (term₁+term₂≈term x*y≈y*x n) - ∑[ i n+1 ] binomialTerm n+1 i ≡⟨⟩ - binomialExpansion n+1 + using (<⇒<ᵇ; n<1+n; n∸n≡0; +-∸-assoc) +open import Data.Fin.Base as Fin + using (Fin; zero; suc; toℕ; fromℕ; inject₁) +open import Data.Fin.Patterns using (0F) +open import Data.Fin.Properties as Fin + using (toℕ<n; toℕ-fromℕ; toℕ-inject₁) +open import Data.Fin.Relation.Unary.Top + using (view; ‵fromℕ; ‵inject₁; view-fromℕ; view-inject₁) +open import Function.Base using (_∘_) +open import Relation.Binary.PropositionalEquality.Core as + using (_≡_; _≢_; cong) + +open import Algebra.Definitions _≈_ +open import Algebra.Properties.Semiring.Sum S +open import Algebra.Properties.Semiring.Mult S +open import Algebra.Properties.Semiring.Exp S +open import Relation.Binary.Reasoning.Setoid setoid + +------------------------------------------------------------------------ +-- Definitions + +-- Note - `n` could be implicit in many of these definitions, but the +-- code is more readable if left explicit. + +binomial : (n : ) Fin (suc n) Carrier +binomial n k = (x ^ toℕ k) * (y ^ (n toℕ k)) + +binomialTerm : (n : ) Fin (suc n) Carrier +binomialTerm n k = (n C toℕ k) × binomial n k + +binomialExpansion : Carrier +binomialExpansion n = ∑[ k n ] (binomialTerm n k) + +term₁ : (n : ) Fin (suc (suc n)) Carrier +term₁ n zero = 0# +term₁ n (suc k) = x * (binomialTerm n k) + +term₂ : (n : ) Fin (suc (suc n)) Carrier +term₂ n k with view k +... | ‵fromℕ = 0# +... | ‵inject₁ j = y * binomialTerm n j + +sum₁ : Carrier +sum₁ n = ∑[ k suc n ] term₁ n k + +sum₂ : Carrier +sum₂ n = ∑[ k suc n ] term₂ n k + +------------------------------------------------------------------------ +-- Properties + +term₂[n,n+1]≈0# : n term₂ n (fromℕ (suc n)) 0# +term₂[n,n+1]≈0# n rewrite view-fromℕ (suc n) = refl + +lemma₁ : n x * binomialExpansion n sum₁ n +lemma₁ n = begin + x * binomialExpansion n ≈⟨ *-distribˡ-sum x (binomialTerm n) + ∑[ i n ] (x * binomialTerm n i) ≈⟨ +-identityˡ _ + 0# + ∑[ i n ] (x * binomialTerm n i) ≡⟨⟩ + 0# + ∑[ i n ] term₁ n (suc i) ≡⟨⟩ + sum₁ n + +lemma₂ : n y * binomialExpansion n sum₂ n +lemma₂ n = begin + y * binomialExpansion n ≈⟨ *-distribˡ-sum y (binomialTerm n) + ∑[ i n ] (y * binomialTerm n i) ≈⟨ +-identityʳ _ + ∑[ i n ] (y * binomialTerm n i) + 0# ≈⟨ +-cong (sum-cong-≋ lemma₂-inject₁) (sym (term₂[n,n+1]≈0# n)) + (∑[ i n ] term₂-inject₁ i) + term₂ n [n+1] ≈⟨ sum-init-last (term₂ n) + sum (term₂ n) ≡⟨⟩ + sum₂ n + where + [n+1] = fromℕ (suc n) + + term₂-inject₁ : (i : Fin (suc n)) Carrier + term₂-inject₁ i = term₂ n (inject₁ i) + + lemma₂-inject₁ : i y * binomialTerm n i term₂-inject₁ i + lemma₂-inject₁ i rewrite view-inject₁ i = refl + +------------------------------------------------------------------------ +-- Next, a lemma which is independent of commutativity + +x*lemma : {n} (i : Fin (suc n)) + x * binomialTerm n i (n C toℕ i) × binomial (suc n) (suc i) +x*lemma {n} i = begin + x * binomialTerm n i ≡⟨⟩ + x * ((n C k) × (x ^ k * y ^ (n k))) ≈⟨ *-congˡ (×-assoc-* (n C k) _ _) + x * ((n C k) × x ^ k * y ^ (n k)) ≈⟨ *-assoc x ((n C k) × x ^ k) _ + (x * (n C k) × x ^ k) * y ^ (n k) ≈⟨ *-congʳ (×-comm-* (n C k) _ _) + (n C k) × x ^ (suc k) * y ^ (n k) ≡⟨⟩ + (n C k) × x ^ (suc k) * y ^ (suc n suc k) ≈⟨ ×-assoc-* (n C k) _ _ + (n C k) × binomial (suc n) (suc i) + where k = toℕ i + +------------------------------------------------------------------------ +-- Next, a lemma which does require commutativity + +y*lemma : x * y y * x {n : } (j : Fin n) + y * binomialTerm n (suc j) (n C toℕ (suc j)) × binomial (suc n) (suc (inject₁ j)) +y*lemma x*y≈y*x {n} j = begin + y * binomialTerm n (suc j) + ≈⟨ ×-comm-* nC[j+1] y (binomial n (suc j)) + nC[j+1] × (y * binomial n (suc j)) + ≈⟨ ×-congʳ nC[j+1] (y*x^m*y^n≈x^m*y^[n+1] x*y≈y*x [j+1] [n-j-1]) + nC[j+1] × (x ^ [j+1] * y ^ [n-j]) + ≈⟨ ×-congʳ nC[j+1] (*-congʳ (^-congʳ x (cong suc k≡j))) + nC[j+1] × (x ^ [k+1] * y ^ [n-j]) + ≈⟨ ×-congʳ nC[j+1] (*-congˡ (^-congʳ y [n-k]≡[n-j])) + nC[j+1] × (x ^ [k+1] * y ^ [n-k]) + ≡⟨⟩ + nC[j+1] × (x ^ [k+1] * y ^ [n+1]-[k+1]) + ≡⟨⟩ + (n C toℕ (suc j)) × binomial (suc n) (suc i) + where + i = inject₁ j + k = toℕ i + [k+1] = ℕ.suc k + [j+1] = toℕ (suc j) + [n-k] = n k + [n+1]-[k+1] = [n-k] + [n-j-1] = n [j+1] + [n-j] = ℕ.suc [n-j-1] + nC[j+1] = n C [j+1] + + k≡j : k toℕ j + k≡j = toℕ-inject₁ j + + [n-k]≡[n-j] : [n-k] [n-j] + [n-k]≡[n-j] = ≡.trans (cong (n ∸_) k≡j) (+-∸-assoc 1 (toℕ<n j)) + +------------------------------------------------------------------------ +-- Now, a lemma characterising the sum of the term₁ and term₂ expressions + +private + n<ᵇ1+n : n (n ℕ.<ᵇ suc n) true + n<ᵇ1+n n with truen ℕ.<ᵇ suc n | _<⇒<ᵇ (n<1+n n) = ≡.refl + +term₁+term₂≈term : x * y y * x n i term₁ n i + term₂ n i binomialTerm (suc n) i + +term₁+term₂≈term x*y≈y*x n 0F = begin + term₁ n 0F + term₂ n 0F ≡⟨⟩ + 0# + y * (1 × (1# * y ^ n)) ≈⟨ +-identityˡ _ + y * (1 × (1# * y ^ n)) ≈⟨ *-congˡ (+-identityʳ (1# * y ^ n)) + y * (1# * y ^ n) ≈⟨ *-congˡ (*-identityˡ (y ^ n)) + y * y ^ n ≡⟨⟩ + y ^ suc n ≈⟨ *-identityˡ (y ^ suc n) + 1# * y ^ suc n ≈⟨ +-identityʳ (1# * y ^ suc n) + 1 × (1# * y ^ suc n) ≡⟨⟩ + binomialTerm (suc n) 0F + +term₁+term₂≈term x*y≈y*x n (suc i) with view i +... | ‵fromℕ {n} +{- remembering that i = fromℕ n, definitionally -} + rewrite toℕ-fromℕ n + | nCn≡1 n + | n∸n≡0 n + | n<ᵇ1+n n + = begin + x * ((x ^ n * 1#) + 0#) + 0# ≈⟨ +-identityʳ _ + x * ((x ^ n * 1#) + 0#) ≈⟨ *-congˡ (+-identityʳ _) + x * (x ^ n * 1#) ≈⟨ *-assoc _ _ _ + x * x ^ n * 1# ≈⟨ +-identityʳ _ + 1 × (x * x ^ n * 1#) + +... | ‵inject₁ j +{- remembering that i = inject₁ j, definitionally -} + = begin + (x * binomialTerm n i) + (y * binomialTerm n (suc j)) + ≈⟨ +-cong (x*lemma i) (y*lemma x*y≈y*x j) + (nCk × [x^k+1]*[y^n-k]) + (nC[j+1] × [x^k+1]*[y^n-k]) + ≈⟨ +-congˡ (×-congˡ nC[k+1]≡nC[j+1]) + (nCk × [x^k+1]*[y^n-k]) + (nC[k+1] × [x^k+1]*[y^n-k]) + ≈⟨ ×-homo-+ [x^k+1]*[y^n-k] nCk nC[k+1] + (nCk ℕ.+ nC[k+1]) × [x^k+1]*[y^n-k] + ≡⟨ cong ( [x^k+1]*[y^n-k]) (nCk+nC[k+1]≡[n+1]C[k+1] n k) + ((suc n) C (suc k)) × [x^k+1]*[y^n-k] + ≡⟨⟩ + binomialTerm (suc n) (suc i) + where + k = toℕ i + [k+1] = ℕ.suc k + [j+1] = toℕ (suc j) + nCk = n C k + nC[k+1] = n C [k+1] + nC[j+1] = n C [j+1] + [x^k+1]*[y^n-k] = binomial (suc n) (suc i) + + nC[k+1]≡nC[j+1] : nC[k+1] nC[j+1] + nC[k+1]≡nC[j+1] = cong ((n C_) suc) (toℕ-inject₁ j) + +------------------------------------------------------------------------ +-- Finally, the main result + +theorem : x * y y * x n (x + y) ^ n binomialExpansion n +theorem x*y≈y*x zero = begin + (x + y) ^ 0 ≡⟨⟩ + 1# ≈⟨ ×-homo-1 1# + 1 × 1# ≈⟨ *-identityʳ (1 × 1#) + (1 × 1#) * 1# ≈⟨ ×-assoc-* 1 1# 1# + 1 × (1# * 1#) ≡⟨⟩ + 1 × (x ^ 0 * y ^ 0) ≈⟨ +-identityʳ _ + 1 × (x ^ 0 * y ^ 0) + 0# ≡⟨⟩ + (0 C 0) × (x ^ 0 * y ^ 0) + 0# ≡⟨⟩ + binomialExpansion 0 +theorem x*y≈y*x n+1@(suc n) = begin + (x + y) ^ n+1 ≡⟨⟩ + (x + y) * (x + y) ^ n ≈⟨ *-congˡ (theorem x*y≈y*x n) + (x + y) * binomialExpansion n ≈⟨ distribʳ _ _ _ + x * binomialExpansion n + y * binomialExpansion n ≈⟨ +-cong (lemma₁ n) (lemma₂ n) + sum₁ n + sum₂ n ≈⟨ ∑-distrib-+ (term₁ n) (term₂ n) + ∑[ i n+1 ] (term₁ n i + term₂ n i) ≈⟨ sum-cong-≋ (term₁+term₂≈term x*y≈y*x n) + ∑[ i n+1 ] binomialTerm n+1 i ≡⟨⟩ + binomialExpansion n+1 \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Semiring.Divisibility.html b/v2.3/Algebra.Properties.Semiring.Divisibility.html index 38cdd6d44e..2fc9389c80 100644 --- a/v2.3/Algebra.Properties.Semiring.Divisibility.html +++ b/v2.3/Algebra.Properties.Semiring.Divisibility.html @@ -26,10 +26,10 @@ infixr 8 _∣0 _∣0 : x x 0# -x ∣0 = 0# , zeroˡ x +x ∣0 = 0# , zeroˡ x 0∣x⇒x≈0 : {x} 0# x x 0# -0∣x⇒x≈0 (q , q*0≈x) = trans (sym q*0≈x) (zeroʳ q) +0∣x⇒x≈0 (q , q*0≈x) = trans (sym q*0≈x) (zeroʳ q) x∣y∧y≉0⇒x≉0 : {x y} x y y 0# x 0# x∣y∧y≉0⇒x≉0 x∣y y≉0 x≈0 = y≉0 (0∣x⇒x≈0 (∣-respˡ x≈0 x∣y)) diff --git a/v2.3/Algebra.Properties.Semiring.Exp.TCOptimised.html b/v2.3/Algebra.Properties.Semiring.Exp.TCOptimised.html index c2f2c4c51c..b0a5c3fbd0 100644 --- a/v2.3/Algebra.Properties.Semiring.Exp.TCOptimised.html +++ b/v2.3/Algebra.Properties.Semiring.Exp.TCOptimised.html @@ -13,10 +13,10 @@ {a } (S : Semiring a ) where open import Data.Nat.Base as using (zero; suc) -import Data.Nat.Properties as using (+-suc; *-comm) +import Data.Nat.Properties as using (+-suc; *-comm) open import Relation.Binary.Core using (_Preserves_⟶_; _Preserves₂_⟶_⟶_) open import Relation.Binary.PropositionalEquality.Core using (_≡_) -open Semiring S renaming (zero to *-zero) +open Semiring S renaming (zero to *-zero) open import Relation.Binary.Reasoning.Setoid setoid import Algebra.Properties.Monoid.Mult.TCOptimised *-monoid as Mult @@ -44,5 +44,5 @@ -- (xᵐ)ⁿ≈xᵐ*ⁿ ^-assocʳ : x m n (x ^ m) ^ n x ^ (m ℕ.* n) -^-assocʳ x m n rewrite ℕ.*-comm m n = Mult.×-assocˡ x n m +^-assocʳ x m n rewrite ℕ.*-comm m n = Mult.×-assocˡ x n m \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Semiring.Exp.TailRecursiveOptimised.html b/v2.3/Algebra.Properties.Semiring.Exp.TailRecursiveOptimised.html index 030b3939e7..6bb861c937 100644 --- a/v2.3/Algebra.Properties.Semiring.Exp.TailRecursiveOptimised.html +++ b/v2.3/Algebra.Properties.Semiring.Exp.TailRecursiveOptimised.html @@ -13,10 +13,10 @@ {a } (S : Semiring a ) where open import Data.Nat.Base as using (zero; suc) -open import Data.Nat.Properties as using (+-suc) +open import Data.Nat.Properties as using (+-suc) open import Relation.Binary.Core using (_Preserves_⟶_; _Preserves₂_⟶_⟶_) -open Semiring S renaming (zero to *-zero) +open Semiring S renaming (zero to *-zero) open import Relation.Binary.Reasoning.Setoid setoid open import Algebra.Properties.Semiring.Exp S as U using () renaming (_^_ to _^ᵘ_) @@ -33,7 +33,7 @@ ^[]*-cong : n (_^[ n ]*_) Preserves₂ _≈_ _≈_ _≈_ ^[]*-cong zero x≈y u≈v = u≈v -^[]*-cong (suc n) x≈y u≈v = ^[]*-cong n x≈y (*-cong x≈y u≈v) +^[]*-cong (suc n) x≈y u≈v = ^[]*-cong n x≈y (*-cong x≈y u≈v) ^[]*-congʳ : x n (x ^[ n ]*_) Preserves _≈_ _≈_ ^[]*-congʳ x n = ^[]*-cong n refl @@ -46,7 +46,7 @@ x^[m]*y*z≈x^[m]*[y*z] x zero y z = refl x^[m]*y*z≈x^[m]*[y*z] x (suc m) y z = begin x ^[ suc m ]* y * z ≈⟨ x^[m]*y*z≈x^[m]*[y*z] x m (x * y) z - x ^[ m ]* ((x * y) * z) ≈⟨ ^[]*-congʳ x m (*-assoc x y z) + x ^[ m ]* ((x * y) * z) ≈⟨ ^[]*-congʳ x m (*-assoc x y z) x ^[ m ]* (x * (y * z)) x^[m+n]*y≈x^[m]*x^[n]*y : x m n y x ^[ (m ℕ.+ n) ]* y x ^[ m ]* x ^[ n ]* y @@ -59,7 +59,7 @@ x^m*y≈x^[m]*y : x m y x ^ m * y x ^[ m ]* y x^m*y≈x^[m]*y x m y = begin x ^ m * y ≈⟨ x^[m]*y*z≈x^[m]*[y*z] x m 1# y - x ^[ m ]* (1# * y) ≈⟨ ^[]*-congʳ x m (*-identityˡ y) + x ^[ m ]* (1# * y) ≈⟨ ^[]*-congʳ x m (*-identityˡ y) x ^[ m ]* y ------------------------------------------------------------------------ @@ -81,6 +81,6 @@ ^≈^ᵘ x zero = refl ^≈^ᵘ x (suc m) = begin x ^ (suc m) ≈⟨ x^[m+1]≈x*[x^m] x m - x * x ^ m ≈⟨ *-congˡ (^≈^ᵘ x m) + x * x ^ m ≈⟨ *-congˡ (^≈^ᵘ x m) x * x ^ᵘ m \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Semiring.Exp.html b/v2.3/Algebra.Properties.Semiring.Exp.html index 8d496737dc..76d42b5fd5 100644 --- a/v2.3/Algebra.Properties.Semiring.Exp.html +++ b/v2.3/Algebra.Properties.Semiring.Exp.html @@ -15,7 +15,7 @@ open import Data.Nat.Base as using (; zero; suc) open import Relation.Binary.Core using (_Preserves_⟶_; _Preserves₂_⟶_⟶_) open import Relation.Binary.PropositionalEquality.Core as using (_≡_) -import Data.Nat.Properties as using (*-comm) +import Data.Nat.Properties as using (*-comm) -- Need to see almost everything, including setoid open Semiring S @@ -47,7 +47,7 @@ -- (xᵐ)ⁿ≈xᵐ*ⁿ ^-assocʳ : x m n (x ^ m) ^ n x ^ (m ℕ.* n) -^-assocʳ x m n rewrite ℕ.*-comm m n = Mult.×-assocˡ x n m +^-assocʳ x m n rewrite ℕ.*-comm m n = Mult.×-assocˡ x n m ------------------------------------------------------------------------ -- A lemma using commutativity, needed for the Binomial Theorem @@ -59,19 +59,19 @@ helper : m n y * (x ^ m * y ^ n) x ^ m * y ^ suc n helper zero n = begin y * (x ^ ℕ.zero * y ^ n) ≡⟨⟩ - y * (1# * y ^ n) ≈⟨ *-congˡ (*-identityˡ (y ^ n)) + y * (1# * y ^ n) ≈⟨ *-congˡ (*-identityˡ (y ^ n)) y * (y ^ n) ≡⟨⟩ - y ^ (suc n) ≈⟨ *-identityˡ (y ^ suc n) + y ^ (suc n) ≈⟨ *-identityˡ (y ^ suc n) 1# * y ^ (suc n) ≡⟨⟩ x ^ ℕ.zero * y ^ (suc n) helper (suc m) n = begin y * (x ^ suc m * y ^ n) ≡⟨⟩ - y * ((x * x ^ m) * y ^ n) ≈⟨ *-congˡ (*-assoc x (x ^ m) (y ^ n)) - y * (x * (x ^ m * y ^ n)) ≈⟨ *-assoc y x (x ^ m * y ^ n) - y * x * (x ^ m * y ^ n) ≈⟨ *-congʳ x*y≈y*x - x * y * (x ^ m * y ^ n) ≈⟨ *-assoc x y _ - x * (y * (x ^ m * y ^ n)) ≈⟨ *-congˡ (helper m n) - x * (x ^ m * y ^ suc n) ≈⟨ *-assoc x (x ^ m) (y ^ suc n) + y * ((x * x ^ m) * y ^ n) ≈⟨ *-congˡ (*-assoc x (x ^ m) (y ^ n)) + y * (x * (x ^ m * y ^ n)) ≈⟨ *-assoc y x (x ^ m * y ^ n) + y * x * (x ^ m * y ^ n) ≈⟨ *-congʳ x*y≈y*x + x * y * (x ^ m * y ^ n) ≈⟨ *-assoc x y _ + x * (y * (x ^ m * y ^ n)) ≈⟨ *-congˡ (helper m n) + x * (x ^ m * y ^ suc n) ≈⟨ *-assoc x (x ^ m) (y ^ suc n) (x * x ^ m) * y ^ suc n ≡⟨⟩ x ^ suc m * y ^ suc n \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Semiring.Mult.TCOptimised.html b/v2.3/Algebra.Properties.Semiring.Mult.TCOptimised.html index 504e668f39..95456d8775 100644 --- a/v2.3/Algebra.Properties.Semiring.Mult.TCOptimised.html +++ b/v2.3/Algebra.Properties.Semiring.Mult.TCOptimised.html @@ -13,7 +13,7 @@ module Algebra.Properties.Semiring.Mult.TCOptimised {a } (S : Semiring a ) where -open Semiring S renaming (zero to *-zero) +open Semiring S renaming (zero to *-zero) open import Relation.Binary.Reasoning.Setoid setoid open import Algebra.Properties.Semiring.Mult S as U @@ -33,6 +33,6 @@ ×1-homo-* m n = begin (m ℕ.* n) × 1# ≈⟨ ×ᵤ≈× (m ℕ.* n) 1# (m ℕ.* n) ×ᵤ 1# ≈⟨ U.×1-homo-* m n - (m ×ᵤ 1#) * (n ×ᵤ 1#) ≈⟨ *-cong (×ᵤ≈× m 1#) (×ᵤ≈× n 1#) + (m ×ᵤ 1#) * (n ×ᵤ 1#) ≈⟨ *-cong (×ᵤ≈× m 1#) (×ᵤ≈× n 1#) (m × 1#) * (n × 1#) \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Semiring.Mult.html b/v2.3/Algebra.Properties.Semiring.Mult.html index bf7e287e3e..db348920b9 100644 --- a/v2.3/Algebra.Properties.Semiring.Mult.html +++ b/v2.3/Algebra.Properties.Semiring.Mult.html @@ -14,7 +14,7 @@ open import Data.Nat.Base as using (zero; suc) -open Semiring S renaming (zero to *-zero) +open Semiring S renaming (zero to *-zero) open import Relation.Binary.Reasoning.Setoid setoid open import Algebra.Definitions _≈_ using (_IdempotentOn_) @@ -30,32 +30,32 @@ -- (0 ×_) is (0# *_) ×-homo-0# : x 0 × x 0# * x -×-homo-0# x = sym (zeroˡ x) +×-homo-0# x = sym (zeroˡ x) -- (1 ×_) is (1# *_) ×-homo-1# : x 1 × x 1# * x -×-homo-1# x = trans (×-homo-1 x) (sym (*-identityˡ x)) +×-homo-1# x = trans (×-homo-1 x) (sym (*-identityˡ x)) -- (n ×_) commutes with _*_ ×-comm-* : n x y x * (n × y) n × (x * y) -×-comm-* zero x y = zeroʳ x +×-comm-* zero x y = zeroʳ x ×-comm-* (suc n) x y = begin x * (suc n × y) ≡⟨⟩ - x * (y + n × y) ≈⟨ distribˡ _ _ _ - x * y + x * (n × y) ≈⟨ +-congˡ (×-comm-* n _ _) + x * (y + n × y) ≈⟨ distribˡ _ _ _ + x * y + x * (n × y) ≈⟨ +-congˡ (×-comm-* n _ _) x * y + n × (x * y) ≡⟨⟩ suc n × (x * y) -- (n ×_) associates with _*_ ×-assoc-* : n x y (n × x) * y n × (x * y) -×-assoc-* zero x y = zeroˡ y +×-assoc-* zero x y = zeroˡ y ×-assoc-* (suc n) x y = begin (suc n × x) * y ≡⟨⟩ - (x + n × x) * y ≈⟨ distribʳ _ _ _ - x * y + (n × x) * y ≈⟨ +-congˡ (×-assoc-* n _ _) + (x + n × x) * y ≈⟨ distribʳ _ _ _ + x * y + (n × x) * y ≈⟨ +-congˡ (×-assoc-* n _ _) x * y + n × (x * y) ≡⟨⟩ suc n × (x * y) @@ -72,7 +72,7 @@ -- (_× 1#) is homomorphic with respect to _ℕ.*_/_*_. ×1-homo-* : m n (m ℕ.* n) × 1# (m × 1#) * (n × 1#) -×1-homo-* m n = sym (idem-×-homo-* m n (*-identityʳ 1#)) +×1-homo-* m n = sym (idem-×-homo-* m n (*-identityʳ 1#)) ------------------------------------------------------------------------ -- DEPRECATED NAMES diff --git a/v2.3/Algebra.Properties.Semiring.Primality.html b/v2.3/Algebra.Properties.Semiring.Primality.html index d53fa46a7c..d1be8f8eed 100644 --- a/v2.3/Algebra.Properties.Semiring.Primality.html +++ b/v2.3/Algebra.Properties.Semiring.Primality.html @@ -45,5 +45,5 @@ Irreducible⇒≉0 : 0# 1# {p} Irreducible p p 0# Irreducible⇒≉0 0≉1 (mkIrred _ chooseInvertible) p≈0 = - 0∤1 0≉1 (reduce (chooseInvertible (trans p≈0 (sym (zeroˡ 0#))))) + 0∤1 0≉1 (reduce (chooseInvertible (trans p≈0 (sym (zeroˡ 0#))))) \ No newline at end of file diff --git a/v2.3/Algebra.Properties.Semiring.Sum.html b/v2.3/Algebra.Properties.Semiring.Sum.html index ba2bf0e9f8..574e99ec50 100644 --- a/v2.3/Algebra.Properties.Semiring.Sum.html +++ b/v2.3/Algebra.Properties.Semiring.Sum.html @@ -25,10 +25,10 @@ -- Properties *-distribˡ-sum : {n} x (ys : Vector Carrier n) x * sum ys sum (map (x *_) ys) -*-distribˡ-sum {zero} x ys = zeroʳ x -*-distribˡ-sum {suc n} x ys = trans (distribˡ x (head ys) (sum (tail ys))) (+-congˡ (*-distribˡ-sum x (tail ys))) +*-distribˡ-sum {zero} x ys = zeroʳ x +*-distribˡ-sum {suc n} x ys = trans (distribˡ x (head ys) (sum (tail ys))) (+-congˡ (*-distribˡ-sum x (tail ys))) *-distribʳ-sum : {n} x (ys : Vector Carrier n) sum ys * x sum (map (_* x) ys) -*-distribʳ-sum {zero} x ys = zeroˡ x -*-distribʳ-sum {suc n} x ys = trans (distribʳ x (head ys) (sum (tail ys))) (+-congˡ (*-distribʳ-sum x (tail ys))) +*-distribʳ-sum {zero} x ys = zeroˡ x +*-distribʳ-sum {suc n} x ys = trans (distribʳ x (head ys) (sum (tail ys))) (+-congˡ (*-distribʳ-sum x (tail ys))) \ No newline at end of file diff --git a/v2.3/Algebra.Solver.CommutativeMonoid.Normal.html b/v2.3/Algebra.Solver.CommutativeMonoid.Normal.html index 5d6ab41183..cb028f56c0 100644 --- a/v2.3/Algebra.Solver.CommutativeMonoid.Normal.html +++ b/v2.3/Algebra.Solver.CommutativeMonoid.Normal.html @@ -14,153 +14,153 @@ module Algebra.Solver.CommutativeMonoid.Normal {c } (M : CommutativeMonoid c ) where import Algebra.Properties.CommutativeSemigroup as CSProperties - using (medial) -import Algebra.Properties.Monoid.Mult as MultProperties - using (_×_; ×-homo-1; ×-homo-+) -open import Data.Fin.Base using (Fin; zero; suc) -open import Data.Nat as using (; zero; suc; _+_) -open import Data.Vec.Base using (Vec; []; _∷_; lookup; replicate; zipWith) -import Data.Vec.Relation.Binary.Pointwise.Inductive as Pointwise - using (Pointwise; _∷_; []; Pointwise-≡↔≡; decidable) -open import Relation.Binary.Definitions using (DecidableEquality) -import Relation.Binary.Reasoning.Setoid as ≈-Reasoning -import Relation.Nullary.Decidable as Dec using (map) + using (interchange) +import Algebra.Properties.Monoid.Mult as MultProperties + using (_×_; ×-homo-1; ×-homo-+) +open import Data.Fin.Base using (Fin; zero; suc) +open import Data.Nat as using (; zero; suc; _+_) +open import Data.Vec.Base using (Vec; []; _∷_; lookup; replicate; zipWith) +import Data.Vec.Relation.Binary.Pointwise.Inductive as Pointwise + using (Pointwise; _∷_; []; Pointwise-≡↔≡; decidable) +open import Relation.Binary.Definitions using (DecidableEquality) +import Relation.Binary.Reasoning.Setoid as ≈-Reasoning +import Relation.Nullary.Decidable as Dec using (map) -open CommutativeMonoid M -open MultProperties monoid using (_×_; ×-homo-1; ×-homo-+) -open CSProperties commutativeSemigroup using (medial) -open ≈-Reasoning setoid +open CommutativeMonoid M +open MultProperties monoid using (_×_; ×-homo-1; ×-homo-+) +open CSProperties commutativeSemigroup using (interchange) +open ≈-Reasoning setoid -private - variable - n : +private + variable + n : ------------------------------------------------------------------------- --- Monoid expressions +------------------------------------------------------------------------ +-- Monoid expressions -open import Algebra.Solver.Monoid.Expression rawMonoid public - hiding (NormalAPI) +open import Algebra.Solver.Monoid.Expression rawMonoid public + hiding (NormalAPI) ------------------------------------------------------------------------- --- Normal forms +------------------------------------------------------------------------ +-- Normal forms --- A normal form is a vector of multiplicities (a bag). +-- A normal form is a vector of multiplicities (a bag). -Normal : Set -Normal n = Vec n +Normal : Set +Normal n = Vec n --- The semantics of a normal form. +-- The semantics of a normal form. -⟦_⟧⇓ : Normal n Env n Carrier - [] ⟧⇓ _ = ε - n v ⟧⇓ (a ρ) = (n × a) ( v ⟧⇓ ρ) +⟦_⟧⇓ : Normal n Env n Carrier + [] ⟧⇓ _ = ε + n v ⟧⇓ (a ρ) = (n × a) ( v ⟧⇓ ρ) --- We can decide if two normal forms are /syntactically/ equal. +-- We can decide if two normal forms are /syntactically/ equal. -infix 5 _≟_ +infix 5 _≟_ -_≟_ : DecidableEquality (Normal n) -nf₁ nf₂ = Dec.map Pointwise-≡↔≡ (decidable ℕ._≟_ nf₁ nf₂) - where open Pointwise using (Pointwise-≡↔≡; decidable) +_≟_ : DecidableEquality (Normal n) +nf₁ nf₂ = Dec.map Pointwise-≡↔≡ (decidable ℕ._≟_ nf₁ nf₂) + where open Pointwise using (Pointwise-≡↔≡; decidable) ------------------------------------------------------------------------- --- Constructions on normal forms +------------------------------------------------------------------------ +-- Constructions on normal forms --- The empty bag. +-- The empty bag. -empty : Normal n -empty = replicate _ 0 +empty : Normal n +empty = replicate _ 0 --- A singleton bag. +-- A singleton bag. -singleton : (i : Fin n) Normal n -singleton zero = 1 empty -singleton (suc i) = 0 singleton i +singleton : (i : Fin n) Normal n +singleton zero = 1 empty +singleton (suc i) = 0 singleton i --- The composition of normal forms. -infixr 10 _•_ +-- The composition of normal forms. +infixr 10 _•_ -_•_ : (v w : Normal n) Normal n -_•_ = zipWith _+_ +_•_ : (v w : Normal n) Normal n +_•_ = zipWith _+_ ------------------------------------------------------------------------- --- Correctness of the constructions on normal forms +------------------------------------------------------------------------ +-- Correctness of the constructions on normal forms --- The empty bag stands for the unit ε. +-- The empty bag stands for the unit ε. -empty-correct : (ρ : Env n) empty ⟧⇓ ρ ε -empty-correct [] = refl -empty-correct (a ρ) = begin - ε empty ⟧⇓ ρ ≈⟨ identityˡ _ - empty ⟧⇓ ρ ≈⟨ empty-correct ρ - ε +empty-correct : (ρ : Env n) empty ⟧⇓ ρ ε +empty-correct [] = refl +empty-correct (a ρ) = begin + ε empty ⟧⇓ ρ ≈⟨ identityˡ _ + empty ⟧⇓ ρ ≈⟨ empty-correct ρ + ε --- The singleton bag stands for a single variable. +-- The singleton bag stands for a single variable. -singleton-correct : (x : Fin n) (ρ : Env n) - singleton x ⟧⇓ ρ lookup ρ x -singleton-correct zero (x ρ) = begin - (1 × x) empty ⟧⇓ ρ ≈⟨ ∙-congʳ (×-homo-1 _) - x empty ⟧⇓ ρ ≈⟨ ∙-congˡ (empty-correct ρ) - x ε ≈⟨ identityʳ _ - x -singleton-correct (suc x) (m ρ) = begin - ε singleton x ⟧⇓ ρ ≈⟨ identityˡ _ - singleton x ⟧⇓ ρ ≈⟨ singleton-correct x ρ - lookup ρ x +singleton-correct : (x : Fin n) (ρ : Env n) + singleton x ⟧⇓ ρ lookup ρ x +singleton-correct zero (x ρ) = begin + (1 × x) empty ⟧⇓ ρ ≈⟨ ∙-congʳ (×-homo-1 _) + x empty ⟧⇓ ρ ≈⟨ ∙-congˡ (empty-correct ρ) + x ε ≈⟨ identityʳ _ + x +singleton-correct (suc x) (m ρ) = begin + ε singleton x ⟧⇓ ρ ≈⟨ identityˡ _ + singleton x ⟧⇓ ρ ≈⟨ singleton-correct x ρ + lookup ρ x --- Normal form composition corresponds to the composition of the monoid. +-- Normal form composition corresponds to the composition of the monoid. -comp-correct : v w (ρ : Env n) - v w ⟧⇓ ρ ( v ⟧⇓ ρ w ⟧⇓ ρ) -comp-correct [] [] _ = sym (identityˡ _) -comp-correct (l v) (m w) (a ρ) = begin - ((l + m) × a) v w ⟧⇓ ρ ≈⟨ ∙-congʳ (×-homo-+ a l m) - (l × a) (m × a) v w ⟧⇓ ρ ≈⟨ ∙-congˡ (comp-correct v w ρ) - (l × a) (m × a) ( v ⟧⇓ ρ w ⟧⇓ ρ) ≈⟨ medial _ _ _ _ - l v ⟧⇓ (a ρ) m w ⟧⇓ (a ρ) +comp-correct : v w (ρ : Env n) + v w ⟧⇓ ρ ( v ⟧⇓ ρ w ⟧⇓ ρ) +comp-correct [] [] _ = sym (identityˡ _) +comp-correct (l v) (m w) (a ρ) = begin + ((l + m) × a) v w ⟧⇓ ρ ≈⟨ ∙-congʳ (×-homo-+ a l m) + (l × a) (m × a) v w ⟧⇓ ρ ≈⟨ ∙-congˡ (comp-correct v w ρ) + (l × a) (m × a) ( v ⟧⇓ ρ w ⟧⇓ ρ) ≈⟨ interchange _ _ _ _ + l v ⟧⇓ (a ρ) m w ⟧⇓ (a ρ) ------------------------------------------------------------------------- --- Normalization +------------------------------------------------------------------------ +-- Normalization --- A normaliser. +-- A normaliser. -normalise : Expr n Normal n -normalise (var x) = singleton x -normalise id = empty -normalise (e₁ e₂) = normalise e₁ normalise e₂ +normalise : Expr n Normal n +normalise (var x) = singleton x +normalise id = empty +normalise (e₁ e₂) = normalise e₁ normalise e₂ --- The normaliser preserves the semantics of the expression. +-- The normaliser preserves the semantics of the expression. -correct : e ρ normalise {n = n} e ⟧⇓ ρ e ρ -correct (var x) ρ = singleton-correct x ρ -correct id ρ = empty-correct ρ -correct (e₁ e₂) ρ = begin - normalise e₁ normalise e₂ ⟧⇓ ρ - ≈⟨ comp-correct (normalise e₁) (normalise e₂) ρ - normalise e₁ ⟧⇓ ρ normalise e₂ ⟧⇓ ρ - ≈⟨ ∙-cong (correct e₁ ρ) (correct e₂ ρ) - e₁ ρ e₂ ρ - +correct : e ρ normalise {n = n} e ⟧⇓ ρ e ρ +correct (var x) ρ = singleton-correct x ρ +correct id ρ = empty-correct ρ +correct (e₁ e₂) ρ = begin + normalise e₁ normalise e₂ ⟧⇓ ρ + ≈⟨ comp-correct (normalise e₁) (normalise e₂) ρ + normalise e₁ ⟧⇓ ρ normalise e₂ ⟧⇓ ρ + ≈⟨ ∙-cong (correct e₁ ρ) (correct e₂ ρ) + e₁ ρ e₂ ρ + ------------------------------------------------------------------------- --- DEPRECATED NAMES ------------------------------------------------------------------------- --- Please use the new names as continuing support for the old names is --- not guaranteed. +------------------------------------------------------------------------ +-- DEPRECATED NAMES +------------------------------------------------------------------------ +-- Please use the new names as continuing support for the old names is +-- not guaranteed. --- Version 2.2 +-- Version 2.2 -sg = singleton -{-# WARNING_ON_USAGE sg -"Warning: sg was deprecated in v2.2. +sg = singleton +{-# WARNING_ON_USAGE sg +"Warning: sg was deprecated in v2.2. Please use singleton instead." -#-} -sg-correct = singleton-correct -{-# WARNING_ON_USAGE sg-correct -"Warning: sg-correct was deprecated in v2.2. +#-} +sg-correct = singleton-correct +{-# WARNING_ON_USAGE sg-correct +"Warning: sg-correct was deprecated in v2.2. Please use singleton-correct instead." -#-} +#-} \ No newline at end of file diff --git a/v2.3/Algebra.Solver.CommutativeMonoid.html b/v2.3/Algebra.Solver.CommutativeMonoid.html index 18c92352de..e2e7b61487 100644 --- a/v2.3/Algebra.Solver.CommutativeMonoid.html +++ b/v2.3/Algebra.Solver.CommutativeMonoid.html @@ -26,7 +26,7 @@ -- Normal forms open N public - renaming (correct to normalise-correct) + renaming (correct to normalise-correct) ------------------------------------------------------------------------ -- Proof procedures diff --git a/v2.3/Algebra.Solver.IdempotentCommutativeMonoid.Normal.html b/v2.3/Algebra.Solver.IdempotentCommutativeMonoid.Normal.html index b60bf0860f..7c7d97cf52 100644 --- a/v2.3/Algebra.Solver.IdempotentCommutativeMonoid.Normal.html +++ b/v2.3/Algebra.Solver.IdempotentCommutativeMonoid.Normal.html @@ -15,7 +15,7 @@ {c } (M : IdempotentCommutativeMonoid c ) where import Algebra.Properties.CommutativeSemigroup as CSProperties -open import Algebra.Properties.IdempotentCommutativeMonoid M using (∙-distrˡ-∙) +open import Algebra.Properties.IdempotentCommutativeMonoid M using (∙-distrˡ-∙) open import Data.Bool as Bool using (Bool; true; false; if_then_else_; _∨_) open import Data.Fin.Base using (Fin; zero; suc) open import Data.Nat.Base using () @@ -27,7 +27,7 @@ import Relation.Nullary.Decidable as Dec using (map) open IdempotentCommutativeMonoid M -open CSProperties commutativeSemigroup using (x∙yz≈xy∙z; x∙yz≈y∙xz) +open CSProperties commutativeSemigroup using (x∙yz≈xy∙z; x∙yz≈y∙xz) open ≈-Reasoning setoid private @@ -108,11 +108,11 @@ v w ⟧⇓ ρ ( v ⟧⇓ ρ w ⟧⇓ ρ) comp-correct [] [] ρ = sym (identityˡ _) comp-correct (true v) (true w) (a ρ) = - trans (∙-congˡ (comp-correct v w ρ)) (∙-distrˡ-∙ _ _ _) + trans (∙-congˡ (comp-correct v w ρ)) (∙-distrˡ-∙ _ _ _) comp-correct (true v) (false w) (a ρ) = trans (∙-congˡ (comp-correct v w ρ)) (x∙yz≈xy∙z _ _ _) comp-correct (false v) (true w) (a ρ) = - trans (∙-congˡ (comp-correct v w ρ)) (x∙yz≈y∙xz _ _ _) + trans (∙-congˡ (comp-correct v w ρ)) (x∙yz≈y∙xz _ _ _) comp-correct (false v) (false w) (a ρ) = comp-correct v w ρ @@ -148,12 +148,12 @@ -- Version 2.2 -flip12 = x∙yz≈y∙xz +flip12 = x∙yz≈y∙xz {-# WARNING_ON_USAGE flip12 "Warning: flip12 was deprecated in v2.2. Please use Algebra.Properties.CommutativeSemigroup.x∙yz≈y∙xz instead." #-} -distr = ∙-distrˡ-∙ +distr = ∙-distrˡ-∙ {-# WARNING_ON_USAGE distr "Warning: distr was deprecated in v2.2. Please use Algebra.Properties.IdempotentCommutativeMonoid.∙-distrˡ-∙ instead." diff --git a/v2.3/Algebra.Solver.Monoid.Normal.html b/v2.3/Algebra.Solver.Monoid.Normal.html index 57b4d29e3f..8ddcf017cf 100644 --- a/v2.3/Algebra.Solver.Monoid.Normal.html +++ b/v2.3/Algebra.Solver.Monoid.Normal.html @@ -55,7 +55,7 @@ _≟_ : DecidableEquality (Normal n) nf₁ nf₂ = Dec.map′ ≋⇒≡ ≡⇒≋ (nf₁ ≋? nf₂) - where open Fin._≟_ using (_≋?_; ≋⇒≡; ≡⇒≋) + where open Fin._≟_ using (_≋?_; ≋⇒≡; ≡⇒≋) -- A normaliser. diff --git a/v2.3/Algebra.Solver.Ring.AlmostCommutativeRing.html b/v2.3/Algebra.Solver.Ring.AlmostCommutativeRing.html index 47296461e5..643e263ea0 100644 --- a/v2.3/Algebra.Solver.Ring.AlmostCommutativeRing.html +++ b/v2.3/Algebra.Solver.Ring.AlmostCommutativeRing.html @@ -12,7 +12,7 @@ open import Algebra using (Op₁; Op₂; CommutativeSemiring; RawRing; CommutativeRing) -open import Algebra.Structures using (IsCommutativeSemiring) +open import Algebra.Structures using (IsCommutativeSemiring) open import Algebra.Definitions using (Congruent₁; Congruent₂) import Algebra.Morphism.Definitions as MorphismDefinitions using (Homomorphic₀; Homomorphic₁; Homomorphic₂; Morphism) @@ -25,12 +25,12 @@ (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ) where field - isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# + isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# -‿cong : Congruent₁ _≈_ -_ -‿*-distribˡ : x y ((- x) * y) (- (x * y)) -‿+-comm : x y ((- x) + (- y)) (- (x + y)) - open IsCommutativeSemiring isCommutativeSemiring public + open IsCommutativeSemiring isCommutativeSemiring public record AlmostCommutativeRing c : Set (suc (c )) where @@ -126,9 +126,9 @@ fromCommutativeRing : {r₁ r₂} CommutativeRing r₁ r₂ AlmostCommutativeRing r₁ r₂ fromCommutativeRing CR = record { isAlmostCommutativeRing = record - { isCommutativeSemiring = isCommutativeSemiring - ; -‿cong = -‿cong - ; -‿*-distribˡ = λ x y sym (-‿distribˡ-* x y) + { isCommutativeSemiring = isCommutativeSemiring + ; -‿cong = -‿cong + ; -‿*-distribˡ = λ x y sym (-‿distribˡ-* x y) ; -‿+-comm = ⁻¹-∙-comm } } diff --git a/v2.3/Algebra.Solver.Ring.Lemmas.html b/v2.3/Algebra.Solver.Ring.Lemmas.html index a5fb7bb281..2abb1d44fb 100644 --- a/v2.3/Algebra.Solver.Ring.Lemmas.html +++ b/v2.3/Algebra.Solver.Ring.Lemmas.html @@ -30,87 +30,87 @@ lemma₀ : a b c x (a + b) * x + c a * x + (b * x + c) lemma₀ a b c x = begin - (a + b) * x + c ≈⟨ distribʳ _ _ _ +-cong refl - (a * x + b * x) + c ≈⟨ +-assoc _ _ _ + (a + b) * x + c ≈⟨ distribʳ _ _ _ +-cong refl + (a * x + b * x) + c ≈⟨ +-assoc _ _ _ a * x + (b * x + c) lemma₁ : a b c d x (a + b) * x + (c + d) (a * x + c) + (b * x + d) lemma₁ a b c d x = begin (a + b) * x + (c + d) ≈⟨ lemma₀ _ _ _ _ - a * x + (b * x + (c + d)) ≈⟨ refl +-cong sym (+-assoc _ _ _) - a * x + ((b * x + c) + d) ≈⟨ refl +-cong (+-comm _ _ +-cong refl) - a * x + ((c + b * x) + d) ≈⟨ refl +-cong +-assoc _ _ _ - a * x + (c + (b * x + d)) ≈⟨ sym $ +-assoc _ _ _ + a * x + (b * x + (c + d)) ≈⟨ refl +-cong sym (+-assoc _ _ _) + a * x + ((b * x + c) + d) ≈⟨ refl +-cong (+-comm _ _ +-cong refl) + a * x + ((c + b * x) + d) ≈⟨ refl +-cong +-assoc _ _ _ + a * x + (c + (b * x + d)) ≈⟨ sym $ +-assoc _ _ _ (a * x + c) + (b * x + d) lemma₂ : a b c x a * c * x + b * c (a * x + b) * c lemma₂ a b c x = begin - a * c * x + b * c ≈⟨ lem +-cong refl - a * x * c + b * c ≈⟨ sym $ distribʳ _ _ _ + a * c * x + b * c ≈⟨ lem +-cong refl + a * x * c + b * c ≈⟨ sym $ distribʳ _ _ _ (a * x + b) * c where lem = begin - a * c * x ≈⟨ *-assoc _ _ _ - a * (c * x) ≈⟨ refl *-cong *-comm _ _ - a * (x * c) ≈⟨ sym $ *-assoc _ _ _ + a * c * x ≈⟨ *-assoc _ _ _ + a * (c * x) ≈⟨ refl *-cong *-comm _ _ + a * (x * c) ≈⟨ sym $ *-assoc _ _ _ a * x * c lemma₃ : a b c x a * b * x + a * c a * (b * x + c) lemma₃ a b c x = begin - a * b * x + a * c ≈⟨ *-assoc _ _ _ +-cong refl - a * (b * x) + a * c ≈⟨ sym $ distribˡ _ _ _ + a * b * x + a * c ≈⟨ *-assoc _ _ _ +-cong refl + a * (b * x) + a * c ≈⟨ sym $ distribˡ _ _ _ a * (b * x + c) lemma₄ : a b c d x (a * c * x + (a * d + b * c)) * x + b * d (a * x + b) * (c * x + d) lemma₄ a b c d x = begin - (a * c * x + (a * d + b * c)) * x + b * d ≈⟨ distribʳ _ _ _ +-cong refl - (a * c * x * x + (a * d + b * c) * x) + b * d ≈⟨ refl +-cong ((refl +-cong refl) *-cong refl) +-cong refl - (a * c * x * x + (a * d + b * c) * x) + b * d ≈⟨ +-assoc _ _ _ - a * c * x * x + ((a * d + b * c) * x + b * d) ≈⟨ lem₁ +-cong (lem₂ +-cong refl) - a * x * (c * x) + (a * x * d + b * (c * x) + b * d) ≈⟨ refl +-cong +-assoc _ _ _ - a * x * (c * x) + (a * x * d + (b * (c * x) + b * d)) ≈⟨ sym $ +-assoc _ _ _ - a * x * (c * x) + a * x * d + (b * (c * x) + b * d) ≈⟨ sym $ distribˡ _ _ _ +-cong distribˡ _ _ _ - a * x * (c * x + d) + b * (c * x + d) ≈⟨ sym $ distribʳ _ _ _ + (a * c * x + (a * d + b * c)) * x + b * d ≈⟨ distribʳ _ _ _ +-cong refl + (a * c * x * x + (a * d + b * c) * x) + b * d ≈⟨ refl +-cong ((refl +-cong refl) *-cong refl) +-cong refl + (a * c * x * x + (a * d + b * c) * x) + b * d ≈⟨ +-assoc _ _ _ + a * c * x * x + ((a * d + b * c) * x + b * d) ≈⟨ lem₁ +-cong (lem₂ +-cong refl) + a * x * (c * x) + (a * x * d + b * (c * x) + b * d) ≈⟨ refl +-cong +-assoc _ _ _ + a * x * (c * x) + (a * x * d + (b * (c * x) + b * d)) ≈⟨ sym $ +-assoc _ _ _ + a * x * (c * x) + a * x * d + (b * (c * x) + b * d) ≈⟨ sym $ distribˡ _ _ _ +-cong distribˡ _ _ _ + a * x * (c * x + d) + b * (c * x + d) ≈⟨ sym $ distribʳ _ _ _ (a * x + b) * (c * x + d) where lem₁′ = begin - a * c * x ≈⟨ *-assoc _ _ _ - a * (c * x) ≈⟨ refl *-cong *-comm _ _ - a * (x * c) ≈⟨ sym $ *-assoc _ _ _ + a * c * x ≈⟨ *-assoc _ _ _ + a * (c * x) ≈⟨ refl *-cong *-comm _ _ + a * (x * c) ≈⟨ sym $ *-assoc _ _ _ a * x * c lem₁ = begin - a * c * x * x ≈⟨ lem₁′ *-cong refl - a * x * c * x ≈⟨ *-assoc _ _ _ + a * c * x * x ≈⟨ lem₁′ *-cong refl + a * x * c * x ≈⟨ *-assoc _ _ _ a * x * (c * x) lem₂ = begin - (a * d + b * c) * x ≈⟨ distribʳ _ _ _ - a * d * x + b * c * x ≈⟨ *-assoc _ _ _ +-cong *-assoc _ _ _ - a * (d * x) + b * (c * x) ≈⟨ (refl *-cong *-comm _ _) +-cong refl - a * (x * d) + b * (c * x) ≈⟨ sym $ *-assoc _ _ _ +-cong refl + (a * d + b * c) * x ≈⟨ distribʳ _ _ _ + a * d * x + b * c * x ≈⟨ *-assoc _ _ _ +-cong *-assoc _ _ _ + a * (d * x) + b * (c * x) ≈⟨ (refl *-cong *-comm _ _) +-cong refl + a * (x * d) + b * (c * x) ≈⟨ sym $ *-assoc _ _ _ +-cong refl a * x * d + b * (c * x) lemma₅ : x (0# * x + 1#) * x + 0# x lemma₅ x = begin - (0# * x + 1#) * x + 0# ≈⟨ ((zeroˡ _ +-cong refl) *-cong refl) +-cong refl - (0# + 1#) * x + 0# ≈⟨ (+-identityˡ _ *-cong refl) +-cong refl - 1# * x + 0# ≈⟨ +-identityʳ _ - 1# * x ≈⟨ *-identityˡ _ + (0# * x + 1#) * x + 0# ≈⟨ ((zeroˡ _ +-cong refl) *-cong refl) +-cong refl + (0# + 1#) * x + 0# ≈⟨ (+-identityˡ _ *-cong refl) +-cong refl + 1# * x + 0# ≈⟨ +-identityʳ _ + 1# * x ≈⟨ *-identityˡ _ x lemma₆ : a x 0# * x + a a lemma₆ a x = begin - 0# * x + a ≈⟨ zeroˡ _ +-cong refl - 0# + a ≈⟨ +-identityˡ _ + 0# * x + a ≈⟨ zeroˡ _ +-cong refl + 0# + a ≈⟨ +-identityˡ _ a lemma₇ : x - 1# * x - x lemma₇ x = begin - 1# * x ≈⟨ -‿*-distribˡ _ _ - - (1# * x) ≈⟨ -‿cong (*-identityˡ _) + - (1# * x) ≈⟨ -‿cong (*-identityˡ _) - x \ No newline at end of file diff --git a/v2.3/Algebra.Solver.Ring.html b/v2.3/Algebra.Solver.Ring.html index d63b84c92b..d07dc89aec 100644 --- a/v2.3/Algebra.Solver.Ring.html +++ b/v2.3/Algebra.Solver.Ring.html @@ -34,7 +34,7 @@ open import Algebra.Solver.Ring.Lemmas Coeff R morphism private module C = RawRing Coeff open AlmostCommutativeRing R - renaming (zero to *-zero; zeroˡ to *-zeroˡ; zeroʳ to *-zeroʳ) + renaming (zero to *-zero; zeroˡ to *-zeroˡ; zeroʳ to *-zeroʳ) open import Algebra.Definitions _≈_ open import Algebra.Morphism open _-Raw-AlmostCommutative⟶_ morphism renaming (⟦_⟧ to ⟦_⟧′) @@ -213,8 +213,8 @@ p₁ ≈H p₂ ρ p₁ ⟧H ρ p₂ ⟧H ρ ⟧H-cong _ = refl p₁≈p₂ *x+ c₁≈c₂ ⟧H-cong (x ρ) = - ( p₁≈p₂ ⟧H-cong (x ρ) *-cong refl) - +-cong + ( p₁≈p₂ ⟧H-cong (x ρ) *-cong refl) + +-cong c₁≈c₂ ⟧N-cong ρ ⟦_⟧N-cong : {p₁ p₂ : Normal n} @@ -356,7 +356,7 @@ 1N-homo : {n} ρ 1N {n} ⟧N ρ 1# 1N-homo [] = 1-homo 1N-homo (x ρ) = begin - 0# * x + 1N ⟧N ρ ≈⟨ refl +-cong 1N-homo ρ + 0# * x + 1N ⟧N ρ ≈⟨ refl +-cong 1N-homo ρ 0# * x + 1# ≈⟨ lemma₆ _ _ 1# @@ -382,12 +382,12 @@ +H-homo : {n} (p₁ p₂ : HNF (suc n)) ρ p₁ +H p₂ ⟧H ρ p₁ ⟧H ρ + p₂ ⟧H ρ - +H-homo p₂ ρ = sym (+-identityˡ _) - +H-homo (p₁ *x+ x₁) ρ = sym (+-identityʳ _) + +H-homo p₂ ρ = sym (+-identityˡ _) + +H-homo (p₁ *x+ x₁) ρ = sym (+-identityʳ _) +H-homo (p₁ *x+ c₁) (p₂ *x+ c₂) (x ρ) = begin (p₁ +H p₂) *x+HN (c₁ +N c₂) ⟧H (x ρ) ≈⟨ *x+HN≈*x+ (p₁ +H p₂) (c₁ +N c₂) (x ρ) - p₁ +H p₂ ⟧H (x ρ) * x + c₁ +N c₂ ⟧N ρ ≈⟨ (+H-homo p₁ p₂ (x ρ) *-cong refl) +-cong +N-homo c₁ c₂ ρ + p₁ +H p₂ ⟧H (x ρ) * x + c₁ +N c₂ ⟧N ρ ≈⟨ (+H-homo p₁ p₂ (x ρ) *-cong refl) +-cong +N-homo c₁ c₂ ρ ( p₁ ⟧H (x ρ) + p₂ ⟧H (x ρ)) * x + ( c₁ ⟧N ρ + c₂ ⟧N ρ) ≈⟨ lemma₁ _ _ _ _ _ @@ -405,11 +405,11 @@ p₁ ⟧H (x ρ) * x + p₂ ⟧H (x ρ) *x+H-homo _ _ = sym $ lemma₆ _ _ *x+H-homo (p *x+ c) x ρ = begin - p *x+ c ⟧H (x ρ) * x + 0N ⟧N ρ ≈⟨ refl +-cong 0N-homo ρ + p *x+ c ⟧H (x ρ) * x + 0N ⟧N ρ ≈⟨ refl +-cong 0N-homo ρ p *x+ c ⟧H (x ρ) * x + 0# *x+H-homo p₁ (p₂ *x+ c₂) x ρ = begin (p₁ +H p₂) *x+HN c₂ ⟧H (x ρ) ≈⟨ *x+HN≈*x+ (p₁ +H p₂) c₂ (x ρ) - p₁ +H p₂ ⟧H (x ρ) * x + c₂ ⟧N ρ ≈⟨ (+H-homo p₁ p₂ (x ρ) *-cong refl) +-cong refl + p₁ +H p₂ ⟧H (x ρ) * x + c₂ ⟧N ρ ≈⟨ (+H-homo p₁ p₂ (x ρ) *-cong refl) +-cong refl ( p₁ ⟧H (x ρ) + p₂ ⟧H (x ρ)) * x + c₂ ⟧N ρ ≈⟨ lemma₀ _ _ _ _ p₁ ⟧H (x ρ) * x + ( p₂ ⟧H (x ρ) * x + c₂ ⟧N ρ) @@ -422,10 +422,10 @@ *NH-homo c (p *x+ c′) x ρ with c ≟N 0N ... | just c≈0 = begin 0# ≈⟨ sym (*-zeroˡ _) - 0# * ( p ⟧H (x ρ) * x + c′ ⟧N ρ) ≈⟨ 0≈⟦0⟧ c≈0 ρ *-cong refl + 0# * ( p ⟧H (x ρ) * x + c′ ⟧N ρ) ≈⟨ 0≈⟦0⟧ c≈0 ρ *-cong refl c ⟧N ρ * ( p ⟧H (x ρ) * x + c′ ⟧N ρ) ... | nothing = begin - c *NH p ⟧H (x ρ) * x + c *N c′ ⟧N ρ ≈⟨ (*NH-homo c p x ρ *-cong refl) +-cong *N-homo c c′ ρ + c *NH p ⟧H (x ρ) * x + c *N c′ ⟧N ρ ≈⟨ (*NH-homo c p x ρ *-cong refl) +-cong *N-homo c c′ ρ ( c ⟧N ρ * p ⟧H (x ρ)) * x + ( c ⟧N ρ * c′ ⟧N ρ) ≈⟨ lemma₃ _ _ _ _ c ⟧N ρ * ( p ⟧H (x ρ) * x + c′ ⟧N ρ) @@ -436,10 +436,10 @@ *HN-homo (p *x+ c′) c x ρ with c ≟N 0N ... | just c≈0 = begin 0# ≈⟨ sym (*-zeroʳ _) - ( p ⟧H (x ρ) * x + c′ ⟧N ρ) * 0# ≈⟨ refl *-cong 0≈⟦0⟧ c≈0 ρ + ( p ⟧H (x ρ) * x + c′ ⟧N ρ) * 0# ≈⟨ refl *-cong 0≈⟦0⟧ c≈0 ρ ( p ⟧H (x ρ) * x + c′ ⟧N ρ) * c ⟧N ρ ... | nothing = begin - p *HN c ⟧H (x ρ) * x + c′ *N c ⟧N ρ ≈⟨ (*HN-homo p c x ρ *-cong refl) +-cong *N-homo c′ c ρ + p *HN c ⟧H (x ρ) * x + c′ *N c ⟧N ρ ≈⟨ (*HN-homo p c x ρ *-cong refl) +-cong *N-homo c′ c ρ ( p ⟧H (x ρ) * c ⟧N ρ) * x + ( c′ ⟧N ρ * c ⟧N ρ) ≈⟨ lemma₂ _ _ _ _ ( p ⟧H (x ρ) * x + c′ ⟧N ρ) * c ⟧N ρ @@ -454,25 +454,25 @@ (p₁ *H p₂) *x+H ((p₁ *HN c₂) +H (c₁ *NH p₂)) ⟧H (x ρ) * x + c₁ *N c₂ ⟧N ρ ≈⟨ (*x+H-homo (p₁ *H p₂) ((p₁ *HN c₂) +H (c₁ *NH p₂)) x ρ - *-cong + *-cong refl) - +-cong + +-cong *N-homo c₁ c₂ ρ ( p₁ *H p₂ ⟧H (x ρ) * x + (p₁ *HN c₂) +H (c₁ *NH p₂) ⟧H (x ρ)) * x + - c₁ ⟧N ρ * c₂ ⟧N ρ ≈⟨ (((*H-homo p₁ p₂ (x ρ) *-cong refl) - +-cong + c₁ ⟧N ρ * c₂ ⟧N ρ ≈⟨ (((*H-homo p₁ p₂ (x ρ) *-cong refl) + +-cong (+H-homo (p₁ *HN c₂) (c₁ *NH p₂) (x ρ))) - *-cong + *-cong refl) - +-cong + +-cong refl ( p₁ ⟧H (x ρ) * p₂ ⟧H (x ρ) * x + ( p₁ *HN c₂ ⟧H (x ρ) + c₁ *NH p₂ ⟧H (x ρ))) * x + - c₁ ⟧N ρ * c₂ ⟧N ρ ≈⟨ ((refl +-cong (*HN-homo p₁ c₂ x ρ +-cong *NH-homo c₁ p₂ x ρ)) - *-cong + c₁ ⟧N ρ * c₂ ⟧N ρ ≈⟨ ((refl +-cong (*HN-homo p₁ c₂ x ρ +-cong *NH-homo c₁ p₂ x ρ)) + *-cong refl) - +-cong + +-cong refl ( p₁ ⟧H (x ρ) * p₂ ⟧H (x ρ) * x + ( p₁ ⟧H (x ρ) * c₂ ⟧N ρ + c₁ ⟧N ρ * p₂ ⟧H (x ρ))) * x + @@ -491,7 +491,7 @@ ^N-homo p zero ρ = 1N-homo ρ ^N-homo p (suc k) ρ = begin p *N (p ^N k) ⟧N ρ ≈⟨ *N-homo p (p ^N k) ρ - p ⟧N ρ * p ^N k ⟧N ρ ≈⟨ refl *-cong ^N-homo p k ρ + p ⟧N ρ * p ^N k ⟧N ρ ≈⟨ refl *-cong ^N-homo p k ρ p ⟧N ρ * ( p ⟧N ρ ^ k) mutual @@ -500,7 +500,7 @@ ρ -H p ⟧H ρ - p ⟧H ρ -H‿-homo p (x ρ) = begin (-N 1N) *NH p ⟧H (x ρ) ≈⟨ *NH-homo (-N 1N) p x ρ - -N 1N ⟧N ρ * p ⟧H (x ρ) ≈⟨ trans (-N‿-homo 1N ρ) (-‿cong (1N-homo ρ)) *-cong refl + -N 1N ⟧N ρ * p ⟧H (x ρ) ≈⟨ trans (-N‿-homo 1N ρ) (-‿cong (1N-homo ρ)) *-cong refl - 1# * p ⟧H (x ρ) ≈⟨ lemma₇ _ - p ⟧H (x ρ) @@ -527,18 +527,18 @@ normalise-var i ⟧N ρ ≈⟨ correct-var i ρ lookup ρ i correct-var zero (x ρ) = begin - (0# * x + 1N ⟧N ρ) * x + 0N ⟧N ρ ≈⟨ ((refl +-cong 1N-homo ρ) *-cong refl) +-cong 0N-homo ρ + (0# * x + 1N ⟧N ρ) * x + 0N ⟧N ρ ≈⟨ ((refl +-cong 1N-homo ρ) *-cong refl) +-cong 0N-homo ρ (0# * x + 1#) * x + 0# ≈⟨ lemma₅ _ x correct : {n} (p : Polynomial n) ρ p ⟧↓ ρ p ρ correct (op [+] p₁ p₂) ρ = begin normalise p₁ +N normalise p₂ ⟧N ρ ≈⟨ +N-homo (normalise p₁) (normalise p₂) ρ - p₁ ⟧↓ ρ + p₂ ⟧↓ ρ ≈⟨ correct p₁ ρ +-cong correct p₂ ρ + p₁ ⟧↓ ρ + p₂ ⟧↓ ρ ≈⟨ correct p₁ ρ +-cong correct p₂ ρ p₁ ρ + p₂ ρ correct (op [*] p₁ p₂) ρ = begin normalise p₁ *N normalise p₂ ⟧N ρ ≈⟨ *N-homo (normalise p₁) (normalise p₂) ρ - p₁ ⟧↓ ρ * p₂ ⟧↓ ρ ≈⟨ correct p₁ ρ *-cong correct p₂ ρ + p₁ ⟧↓ ρ * p₂ ⟧↓ ρ ≈⟨ correct p₁ ρ *-cong correct p₂ ρ p₁ ρ * p₂ ρ correct (con c) ρ = correct-con c ρ correct (var i) ρ = correct-var i ρ diff --git a/v2.3/Algebra.Structures.Biased.html b/v2.3/Algebra.Structures.Biased.html index 3657125c32..4cb48ae04e 100644 --- a/v2.3/Algebra.Structures.Biased.html +++ b/v2.3/Algebra.Structures.Biased.html @@ -74,13 +74,13 @@ distrib : * DistributesOver + zero : Zero 0# * - isSemiringWithoutOne : IsSemiringWithoutOne + * 0# + isSemiringWithoutOne : IsSemiringWithoutOne + * 0# isSemiringWithoutOne = record - { +-isCommutativeMonoid = +-isCommutativeMonoid - ; *-cong = ∙-cong - ; *-assoc = assoc - ; distrib = distrib - ; zero = zero + { +-isCommutativeMonoid = +-isCommutativeMonoid + ; *-cong = ∙-cong + ; *-assoc = assoc + ; distrib = distrib + ; zero = zero } where open IsSemigroup *-isSemigroup open IsSemiringWithoutOne* public @@ -96,13 +96,13 @@ distribʳ : * DistributesOverʳ + zeroˡ : LeftZero 0# * - isNearSemiring : IsNearSemiring + * 0# + isNearSemiring : IsNearSemiring + * 0# isNearSemiring = record - { +-isMonoid = +-isMonoid - ; *-cong = ∙-cong - ; *-assoc = assoc - ; distribʳ = distribʳ - ; zeroˡ = zeroˡ + { +-isMonoid = +-isMonoid + ; *-cong = ∙-cong + ; *-assoc = assoc + ; distribʳ = distribʳ + ; zeroˡ = zeroˡ } where open IsSemigroup *-isSemigroup open IsNearSemiring* public @@ -117,13 +117,13 @@ *-isMonoid : IsMonoid * 1# distrib : * DistributesOver + - isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero + * 0# 1# + isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero + * 0# 1# isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-isCommutativeMonoid - ; *-cong = ∙-cong - ; *-assoc = assoc - ; *-identity = identity - ; distrib = distrib + { +-isCommutativeMonoid = +-isCommutativeMonoid + ; *-cong = ∙-cong + ; *-assoc = assoc + ; *-identity = identity + ; distrib = distrib } where open IsMonoid *-isMonoid open IsSemiringWithoutAnnihilatingZero* public @@ -139,19 +139,19 @@ distribʳ : * DistributesOverʳ + zeroˡ : LeftZero 0# * - isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# + isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# isCommutativeSemiring = record - { isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-isCommutativeMonoid - ; *-cong = *.∙-cong - ; *-assoc = *.assoc - ; *-identity = *.identity - ; distrib = comm∧distrʳ⇒distr +.setoid +.∙-cong *.comm distribʳ + { isSemiring = record + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = +-isCommutativeMonoid + ; *-cong = *.∙-cong + ; *-assoc = *.assoc + ; *-identity = *.identity + ; distrib = comm∧distrʳ⇒distr +.setoid +.∙-cong *.comm distribʳ } - ; zero = comm∧zeˡ⇒ze +.setoid *.comm zeroˡ + ; zero = comm∧zeˡ⇒ze +.setoid *.comm zeroˡ } - ; *-comm = *.comm + ; *-comm = *.comm } where module + = IsCommutativeMonoid +-isCommutativeMonoid @@ -168,19 +168,19 @@ distribˡ : * DistributesOverˡ + zeroʳ : RightZero 0# * - isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# + isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# isCommutativeSemiring = record - { isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-isCommutativeMonoid - ; *-cong = *.∙-cong - ; *-assoc = *.assoc - ; *-identity = *.identity - ; distrib = comm∧distrˡ⇒distr +.setoid +.∙-cong *.comm distribˡ + { isSemiring = record + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = +-isCommutativeMonoid + ; *-cong = *.∙-cong + ; *-assoc = *.assoc + ; *-identity = *.identity + ; distrib = comm∧distrˡ⇒distr +.setoid +.∙-cong *.comm distribˡ } - ; zero = comm∧zeʳ⇒ze +.setoid *.comm zeroʳ + ; zero = comm∧zeʳ⇒ze +.setoid *.comm zeroʳ } - ; *-comm = *.comm + ; *-comm = *.comm } where module + = IsCommutativeMonoid +-isCommutativeMonoid @@ -200,13 +200,13 @@ distrib : * DistributesOver + zero : Zero 0# * - isRing : IsRing + * -_ 0# 1# + isRing : IsRing + * -_ 0# 1# isRing = record - { +-isAbelianGroup = +-isAbelianGroup - ; *-cong = ∙-cong - ; *-assoc = assoc - ; *-identity = identity - ; distrib = distrib + { +-isAbelianGroup = +-isAbelianGroup + ; *-cong = ∙-cong + ; *-assoc = assoc + ; *-identity = identity + ; distrib = distrib } where open IsMonoid *-isMonoid open IsRing* public @@ -245,13 +245,13 @@ zero : Zero 0# * zero = (zeroˡ , zeroʳ) - isRing : IsRing + * -_ 0# 1# + isRing : IsRing + * -_ 0# 1# isRing = record - { +-isAbelianGroup = +-isAbelianGroup - ; *-cong = *.∙-cong - ; *-assoc = *.assoc - ; *-identity = *.identity - ; distrib = distrib + { +-isAbelianGroup = +-isAbelianGroup + ; *-cong = *.∙-cong + ; *-assoc = *.assoc + ; *-identity = *.identity + ; distrib = distrib } open IsRingWithoutAnnihilatingZero public diff --git a/v2.3/Algebra.Structures.html b/v2.3/Algebra.Structures.html index 0a6cb84492..86cf344520 100644 --- a/v2.3/Algebra.Structures.html +++ b/v2.3/Algebra.Structures.html @@ -102,14 +102,14 @@ record IsSemimedialMagma ( : Op₂ A) : Set (a ) where field isMagma : IsMagma - semiMedial : Semimedial + semiMedial : Semimedial open IsMagma isMagma public - semimedialˡ : LeftSemimedial + semimedialˡ : LeftSemimedial semimedialˡ = proj₁ semiMedial - semimedialʳ : RightSemimedial + semimedialʳ : RightSemimedial semimedialʳ = proj₂ semiMedial record IsSelectiveMagma ( : Op₂ A) : Set (a ) where @@ -368,696 +368,679 @@ -- Structures with 2 binary operations & 1 element ------------------------------------------------------------------------ --- In what follows, for all the `IsXRing` structures, there is a --- fundamental representation problem, namely how to associate the --- multiplicative structure to the additive, in such a way as to avoid --- the possibility of ambiguity as to the underlying `IsEquivalence` --- substructure which is to be *shared* between the two operations. - --- The `stdlib` designers have chosen to privilege the underlying --- *additive* structure over the multiplicative: thus for structure --- `IsNearSemiring` defined here, the additive structure is declared --- via a field `+-isMonoid : IsMonoid + 0#`, while the multiplicative --- is given 'unbundled' as the *components* of an `IsSemigroup *` structure, --- namely as an operation satisfying both `*-cong : Congruent₂ *` and --- also `*-assoc : Associative *`, from which the corresponding `IsMagma *` --- and `IsSemigroup *` are then immediately derived. - --- Similar considerations apply to all of the `Ring`-like structures below. - -record IsNearSemiring (+ * : Op₂ A) (0# : A) : Set (a ) where - field - +-isMonoid : IsMonoid + 0# - *-cong : Congruent₂ * - *-assoc : Associative * - distribʳ : * DistributesOverʳ + - zeroˡ : LeftZero 0# * - - open IsMonoid +-isMonoid public - renaming - ( assoc to +-assoc - ; ∙-cong to +-cong - ; ∙-congˡ to +-congˡ - ; ∙-congʳ to +-congʳ - ; identity to +-identity - ; identityˡ to +-identityˡ - ; identityʳ to +-identityʳ - ; isMagma to +-isMagma - ; isUnitalMagma to +-isUnitalMagma - ; isSemigroup to +-isSemigroup - ) - - *-isMagma : IsMagma * - *-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = *-cong - } - - *-isSemigroup : IsSemigroup * - *-isSemigroup = record - { isMagma = *-isMagma - ; assoc = *-assoc - } - - open IsMagma *-isMagma public - using () - renaming - ( ∙-congˡ to *-congˡ - ; ∙-congʳ to *-congʳ - ) - - -record IsSemiringWithoutOne (+ * : Op₂ A) (0# : A) : Set (a ) where - field - +-isCommutativeMonoid : IsCommutativeMonoid + 0# - *-cong : Congruent₂ * - *-assoc : Associative * - distrib : * DistributesOver + - zero : Zero 0# * - - open IsCommutativeMonoid +-isCommutativeMonoid public - using (setoid; isEquivalence) - renaming - ( ∙-cong to +-cong - ; ∙-congˡ to +-congˡ - ; ∙-congʳ to +-congʳ - ; assoc to +-assoc - ; identity to +-identity - ; identityˡ to +-identityˡ - ; identityʳ to +-identityʳ - ; comm to +-comm - ; isMonoid to +-isMonoid - ; isCommutativeMagma to +-isCommutativeMagma - ; isCommutativeSemigroup to +-isCommutativeSemigroup - ) - - open IsEquivalence isEquivalence public - - *-isMagma : IsMagma * - *-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = *-cong - } - - *-isSemigroup : IsSemigroup * - *-isSemigroup = record - { isMagma = *-isMagma - ; assoc = *-assoc - } - - open IsMagma *-isMagma public - using () - renaming - ( ∙-congˡ to *-congˡ - ; ∙-congʳ to *-congʳ - ) - - distribˡ : * DistributesOverˡ + - distribˡ = proj₁ distrib - - distribʳ : * DistributesOverʳ + - distribʳ = proj₂ distrib - - zeroˡ : LeftZero 0# * - zeroˡ = proj₁ zero - - zeroʳ : RightZero 0# * - zeroʳ = proj₂ zero - - isNearSemiring : IsNearSemiring + * 0# - isNearSemiring = record - { +-isMonoid = +-isMonoid - ; *-cong = *-cong - ; *-assoc = *-assoc - ; distribʳ = proj₂ distrib - ; zeroˡ = zeroˡ - } - -record IsCommutativeSemiringWithoutOne - (+ * : Op₂ A) (0# : A) : Set (a ) where - field - isSemiringWithoutOne : IsSemiringWithoutOne + * 0# - *-comm : Commutative * - - open IsSemiringWithoutOne isSemiringWithoutOne public - - *-isCommutativeSemigroup : IsCommutativeSemigroup * - *-isCommutativeSemigroup = record - { isSemigroup = *-isSemigroup - ; comm = *-comm - } - - open IsCommutativeSemigroup *-isCommutativeSemigroup public - using () renaming (isCommutativeMagma to *-isCommutativeMagma) - ------------------------------------------------------------------------- --- Structures with 2 binary operations & 2 elements ------------------------------------------------------------------------- - -record IsSemiringWithoutAnnihilatingZero (+ * : Op₂ A) - (0# 1# : A) : Set (a ) where - field - -- Note that these structures do have an additive unit, but this - -- unit does not necessarily annihilate multiplication. - +-isCommutativeMonoid : IsCommutativeMonoid + 0# - *-cong : Congruent₂ * - *-assoc : Associative * - *-identity : Identity 1# * - distrib : * DistributesOver + - - distribˡ : * DistributesOverˡ + - distribˡ = proj₁ distrib - - distribʳ : * DistributesOverʳ + - distribʳ = proj₂ distrib - - open IsCommutativeMonoid +-isCommutativeMonoid public - renaming - ( assoc to +-assoc - ; ∙-cong to +-cong - ; ∙-congˡ to +-congˡ - ; ∙-congʳ to +-congʳ - ; identity to +-identity - ; identityˡ to +-identityˡ - ; identityʳ to +-identityʳ - ; comm to +-comm - ; isMagma to +-isMagma - ; isSemigroup to +-isSemigroup - ; isMonoid to +-isMonoid - ; isUnitalMagma to +-isUnitalMagma - ; isCommutativeMagma to +-isCommutativeMagma - ; isCommutativeSemigroup to +-isCommutativeSemigroup - ) - - *-isMagma : IsMagma * - *-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = *-cong - } - - *-isSemigroup : IsSemigroup * - *-isSemigroup = record - { isMagma = *-isMagma - ; assoc = *-assoc - } - - *-isMonoid : IsMonoid * 1# - *-isMonoid = record - { isSemigroup = *-isSemigroup - ; identity = *-identity - } - - open IsMonoid *-isMonoid public - using () - renaming - ( ∙-congˡ to *-congˡ - ; ∙-congʳ to *-congʳ - ; identityˡ to *-identityˡ - ; identityʳ to *-identityʳ - ) - - -record IsSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where - field - isSemiringWithoutAnnihilatingZero : - IsSemiringWithoutAnnihilatingZero + * 0# 1# - zero : Zero 0# * - - open IsSemiringWithoutAnnihilatingZero - isSemiringWithoutAnnihilatingZero public - - isSemiringWithoutOne : IsSemiringWithoutOne + * 0# - isSemiringWithoutOne = record - { +-isCommutativeMonoid = +-isCommutativeMonoid - ; *-cong = *-cong - ; *-assoc = *-assoc - ; distrib = distrib - ; zero = zero - } - - open IsSemiringWithoutOne isSemiringWithoutOne public - using - ( isNearSemiring - ; zeroˡ - ; zeroʳ - ) - - -record IsCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where - field - isSemiring : IsSemiring + * 0# 1# - *-comm : Commutative * - - open IsSemiring isSemiring public - - isCommutativeSemiringWithoutOne : - IsCommutativeSemiringWithoutOne + * 0# - isCommutativeSemiringWithoutOne = record - { isSemiringWithoutOne = isSemiringWithoutOne - ; *-comm = *-comm - } - - open IsCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne public - using - ( *-isCommutativeMagma - ; *-isCommutativeSemigroup - ) - - *-isCommutativeMonoid : IsCommutativeMonoid * 1# - *-isCommutativeMonoid = record - { isMonoid = *-isMonoid - ; comm = *-comm - } - - -record IsCancellativeCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where - field - isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# - *-cancelˡ-nonZero : AlmostLeftCancellative 0# * - - open IsCommutativeSemiring isCommutativeSemiring public - - *-cancelʳ-nonZero : AlmostRightCancellative 0# * - *-cancelʳ-nonZero = Consequences.comm∧almostCancelˡ⇒almostCancelʳ setoid - *-comm *-cancelˡ-nonZero - -record IsIdempotentSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where - field - isSemiring : IsSemiring + * 0# 1# - +-idem : Idempotent + - - open IsSemiring isSemiring public - - +-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid + 0# - +-isIdempotentCommutativeMonoid = record - { isCommutativeMonoid = +-isCommutativeMonoid - ; idem = +-idem - } - - open IsIdempotentCommutativeMonoid +-isIdempotentCommutativeMonoid public - using () - renaming ( isCommutativeBand to +-isCommutativeBand - ; isBand to +-isBand - ; isIdempotentMonoid to +-isIdempotentMonoid - ) - - -record IsKleeneAlgebra (+ * : Op₂ A) ( : Op₁ A) (0# 1# : A) : Set (a ) where - field - isIdempotentSemiring : IsIdempotentSemiring + * 0# 1# - starExpansive : StarExpansive 1# + * - starDestructive : StarDestructive + * - - open IsIdempotentSemiring isIdempotentSemiring public - - starExpansiveˡ : StarLeftExpansive 1# + * - starExpansiveˡ = proj₁ starExpansive - - starExpansiveʳ : StarRightExpansive 1# + * - starExpansiveʳ = proj₂ starExpansive - - starDestructiveˡ : StarLeftDestructive + * - starDestructiveˡ = proj₁ starDestructive - - starDestructiveʳ : StarRightDestructive + * - starDestructiveʳ = proj₂ starDestructive - -record IsQuasiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where - field - +-isMonoid : IsMonoid + 0# - *-cong : Congruent₂ * - *-assoc : Associative * - *-identity : Identity 1# * - distrib : * DistributesOver + - zero : Zero 0# * - - open IsMonoid +-isMonoid public - renaming - ( assoc to +-assoc - ; ∙-cong to +-cong - ; ∙-congˡ to +-congˡ - ; ∙-congʳ to +-congʳ - ; identity to +-identity - ; identityˡ to +-identityˡ - ; identityʳ to +-identityʳ - ; isMagma to +-isMagma - ; isUnitalMagma to +-isUnitalMagma - ; isSemigroup to +-isSemigroup - ) - - distribˡ : * DistributesOverˡ + - distribˡ = proj₁ distrib - - distribʳ : * DistributesOverʳ + - distribʳ = proj₂ distrib - - zeroˡ : LeftZero 0# * - zeroˡ = proj₁ zero - - zeroʳ : RightZero 0# * - zeroʳ = proj₂ zero - - identityˡ : LeftIdentity 1# * - identityˡ = proj₁ *-identity - - identityʳ : RightIdentity 1# * - identityʳ = proj₂ *-identity - - *-isMagma : IsMagma * - *-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = *-cong - } - - *-isSemigroup : IsSemigroup * - *-isSemigroup = record - { isMagma = *-isMagma - ; assoc = *-assoc - } - - *-isMonoid : IsMonoid * 1# - *-isMonoid = record - { isSemigroup = *-isSemigroup - ; identity = *-identity - } - - open IsMonoid *-isMonoid public - using () - renaming - ( ∙-congˡ to *-congˡ - ; ∙-congʳ to *-congʳ - ; identityˡ to *-identityˡ - ; identityʳ to *-identityʳ - ) - ------------------------------------------------------------------------- --- Structures with 2 binary operations, 1 unary operation & 1 element ------------------------------------------------------------------------- - -record IsRingWithoutOne (+ * : Op₂ A) (-_ : Op₁ A) (0# : A) : Set (a ) where - field - +-isAbelianGroup : IsAbelianGroup + 0# -_ - *-cong : Congruent₂ * - *-assoc : Associative * - distrib : * DistributesOver + - - open IsAbelianGroup +-isAbelianGroup public - renaming - ( assoc to +-assoc - ; ∙-cong to +-cong - ; ∙-congˡ to +-congˡ - ; ∙-congʳ to +-congʳ - ; identity to +-identity - ; identityˡ to +-identityˡ - ; identityʳ to +-identityʳ - ; inverse to -‿inverse - ; inverseˡ to -‿inverseˡ - ; inverseʳ to -‿inverseʳ - ; ⁻¹-cong to -‿cong - ; comm to +-comm - ; isMagma to +-isMagma - ; isSemigroup to +-isSemigroup - ; isMonoid to +-isMonoid - ; isUnitalMagma to +-isUnitalMagma - ; isCommutativeMagma to +-isCommutativeMagma - ; isCommutativeMonoid to +-isCommutativeMonoid - ; isCommutativeSemigroup to +-isCommutativeSemigroup - ; isInvertibleMagma to +-isInvertibleMagma - ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma - ; isGroup to +-isGroup - ) - - distribˡ : * DistributesOverˡ + - distribˡ = proj₁ distrib - - distribʳ : * DistributesOverʳ + - distribʳ = proj₂ distrib - - zeroˡ : LeftZero 0# * - zeroˡ = Consequences.assoc∧distribʳ∧idʳ∧invʳ⇒zeˡ setoid - +-cong *-cong +-assoc distribʳ +-identityʳ -‿inverseʳ - - zeroʳ : RightZero 0# * - zeroʳ = Consequences.assoc∧distribˡ∧idʳ∧invʳ⇒zeʳ setoid - +-cong *-cong +-assoc distribˡ +-identityʳ -‿inverseʳ - - zero : Zero 0# * - zero = zeroˡ , zeroʳ - - isNearSemiring : IsNearSemiring + * 0# - isNearSemiring = record - { +-isMonoid = +-isMonoid - ; *-cong = *-cong - ; *-assoc = *-assoc - ; distribʳ = distribʳ - ; zeroˡ = zeroˡ - } - - open IsNearSemiring isNearSemiring public - using (*-isMagma; *-isSemigroup; *-congˡ; *-congʳ) - ------------------------------------------------------------------------- --- Structures with 2 binary operations, 1 unary operation & 2 elements ------------------------------------------------------------------------- - -record IsNonAssociativeRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ) where - field - +-isAbelianGroup : IsAbelianGroup + 0# -_ - *-cong : Congruent₂ * - *-identity : Identity 1# * - distrib : * DistributesOver + - zero : Zero 0# * - - open IsAbelianGroup +-isAbelianGroup public - renaming - ( assoc to +-assoc - ; ∙-cong to +-cong - ; ∙-congˡ to +-congˡ - ; ∙-congʳ to +-congʳ - ; identity to +-identity - ; identityˡ to +-identityˡ - ; identityʳ to +-identityʳ - ; inverse to -‿inverse - ; inverseˡ to -‿inverseˡ - ; inverseʳ to -‿inverseʳ - ; ⁻¹-cong to -‿cong - ; comm to +-comm - ; isMagma to +-isMagma - ; isSemigroup to +-isSemigroup - ; isMonoid to +-isMonoid - ; isUnitalMagma to +-isUnitalMagma - ; isCommutativeMagma to +-isCommutativeMagma - ; isCommutativeMonoid to +-isCommutativeMonoid - ; isCommutativeSemigroup to +-isCommutativeSemigroup - ; isInvertibleMagma to +-isInvertibleMagma - ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma - ; isGroup to +-isGroup - ) - - zeroˡ : LeftZero 0# * - zeroˡ = proj₁ zero - - zeroʳ : RightZero 0# * - zeroʳ = proj₂ zero - - distribˡ : * DistributesOverˡ + - distribˡ = proj₁ distrib - - distribʳ : * DistributesOverʳ + - distribʳ = proj₂ distrib - - *-isMagma : IsMagma * - *-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = *-cong - } - - *-identityˡ : LeftIdentity 1# * - *-identityˡ = proj₁ *-identity - - *-identityʳ : RightIdentity 1# * - *-identityʳ = proj₂ *-identity - - *-isUnitalMagma : IsUnitalMagma * 1# - *-isUnitalMagma = record - { isMagma = *-isMagma - ; identity = *-identity - } - - open IsUnitalMagma *-isUnitalMagma public - using () - renaming - ( ∙-congˡ to *-congˡ - ; ∙-congʳ to *-congʳ - ) - -record IsNearring (+ * : Op₂ A) (0# 1# : A) (_⁻¹ : Op₁ A) : Set (a ) where - field - isQuasiring : IsQuasiring + * 0# 1# - +-inverse : Inverse 0# _⁻¹ + - ⁻¹-cong : Congruent₁ _⁻¹ - - open IsQuasiring isQuasiring public - - +-inverseˡ : LeftInverse 0# _⁻¹ + - +-inverseˡ = proj₁ +-inverse - - +-inverseʳ : RightInverse 0# _⁻¹ + - +-inverseʳ = proj₂ +-inverse - -record IsRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ) where - field - +-isAbelianGroup : IsAbelianGroup + 0# -_ - *-cong : Congruent₂ * - *-assoc : Associative * - *-identity : Identity 1# * - distrib : * DistributesOver + - - isRingWithoutOne : IsRingWithoutOne + * -_ 0# - isRingWithoutOne = record - { +-isAbelianGroup = +-isAbelianGroup - ; *-cong = *-cong - ; *-assoc = *-assoc - ; distrib = distrib - } - - open IsRingWithoutOne isRingWithoutOne public - hiding (+-isAbelianGroup; *-cong; *-assoc; distrib) - - *-isMonoid : IsMonoid * 1# - *-isMonoid = record - { isSemigroup = *-isSemigroup - ; identity = *-identity - } - - open IsMonoid *-isMonoid public - using () - renaming - ( identityˡ to *-identityˡ - ; identityʳ to *-identityʳ - ) - - isSemiringWithoutAnnihilatingZero - : IsSemiringWithoutAnnihilatingZero + * 0# 1# - isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-isCommutativeMonoid - ; *-cong = *-cong - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = distrib - } - - isSemiring : IsSemiring + * 0# 1# - isSemiring = record - { isSemiringWithoutAnnihilatingZero = - isSemiringWithoutAnnihilatingZero - ; zero = zero - } - - open IsSemiring isSemiring public - using (isSemiringWithoutOne) - - -record IsCommutativeRing - (+ * : Op₂ A) (- : Op₁ A) (0# 1# : A) : Set (a ) where - field - isRing : IsRing + * - 0# 1# - *-comm : Commutative * - - open IsRing isRing public - - isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# - isCommutativeSemiring = record - { isSemiring = isSemiring - ; *-comm = *-comm - } - - open IsCommutativeSemiring isCommutativeSemiring public - using - ( isCommutativeSemiringWithoutOne - ; *-isCommutativeMagma - ; *-isCommutativeSemigroup - ; *-isCommutativeMonoid - ) - ------------------------------------------------------------------------- --- Structures with 3 binary operations ------------------------------------------------------------------------- - -record IsQuasigroup ( \\ // : Op₂ A) : Set (a ) where - field - isMagma : IsMagma - \\-cong : Congruent₂ \\ - //-cong : Congruent₂ // - leftDivides : LeftDivides \\ - rightDivides : RightDivides // - - open IsMagma isMagma public - - \\-congˡ : LeftCongruent \\ - \\-congˡ y≈z = \\-cong refl y≈z - - \\-congʳ : RightCongruent \\ - \\-congʳ y≈z = \\-cong y≈z refl - - //-congˡ : LeftCongruent // - //-congˡ y≈z = //-cong refl y≈z - - //-congʳ : RightCongruent // - //-congʳ y≈z = //-cong y≈z refl - - leftDividesˡ : LeftDividesˡ \\ - leftDividesˡ = proj₁ leftDivides - - leftDividesʳ : LeftDividesʳ \\ - leftDividesʳ = proj₂ leftDivides - - rightDividesˡ : RightDividesˡ // - rightDividesˡ = proj₁ rightDivides - - rightDividesʳ : RightDividesʳ // - rightDividesʳ = proj₂ rightDivides +record IsNearSemiring (+ * : Op₂ A) (0# : A) : Set (a ) where + field + +-isMonoid : IsMonoid + 0# + *-cong : Congruent₂ * + *-assoc : Associative * + distribʳ : * DistributesOverʳ + + zeroˡ : LeftZero 0# * + + open IsMonoid +-isMonoid public + renaming + ( assoc to +-assoc + ; ∙-cong to +-cong + ; ∙-congˡ to +-congˡ + ; ∙-congʳ to +-congʳ + ; identity to +-identity + ; identityˡ to +-identityˡ + ; identityʳ to +-identityʳ + ; isMagma to +-isMagma + ; isUnitalMagma to +-isUnitalMagma + ; isSemigroup to +-isSemigroup + ) + + *-isMagma : IsMagma * + *-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = *-cong + } + + *-isSemigroup : IsSemigroup * + *-isSemigroup = record + { isMagma = *-isMagma + ; assoc = *-assoc + } + + open IsMagma *-isMagma public + using () + renaming + ( ∙-congˡ to *-congˡ + ; ∙-congʳ to *-congʳ + ) + + +record IsSemiringWithoutOne (+ * : Op₂ A) (0# : A) : Set (a ) where + field + +-isCommutativeMonoid : IsCommutativeMonoid + 0# + *-cong : Congruent₂ * + *-assoc : Associative * + distrib : * DistributesOver + + zero : Zero 0# * + + open IsCommutativeMonoid +-isCommutativeMonoid public + using (setoid; isEquivalence) + renaming + ( ∙-cong to +-cong + ; ∙-congˡ to +-congˡ + ; ∙-congʳ to +-congʳ + ; assoc to +-assoc + ; identity to +-identity + ; identityˡ to +-identityˡ + ; identityʳ to +-identityʳ + ; comm to +-comm + ; isMonoid to +-isMonoid + ; isCommutativeMagma to +-isCommutativeMagma + ; isCommutativeSemigroup to +-isCommutativeSemigroup + ) + + open IsEquivalence isEquivalence public + + *-isMagma : IsMagma * + *-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = *-cong + } + + *-isSemigroup : IsSemigroup * + *-isSemigroup = record + { isMagma = *-isMagma + ; assoc = *-assoc + } + + open IsMagma *-isMagma public + using () + renaming + ( ∙-congˡ to *-congˡ + ; ∙-congʳ to *-congʳ + ) + + distribˡ : * DistributesOverˡ + + distribˡ = proj₁ distrib + + distribʳ : * DistributesOverʳ + + distribʳ = proj₂ distrib + + zeroˡ : LeftZero 0# * + zeroˡ = proj₁ zero + + zeroʳ : RightZero 0# * + zeroʳ = proj₂ zero + + isNearSemiring : IsNearSemiring + * 0# + isNearSemiring = record + { +-isMonoid = +-isMonoid + ; *-cong = *-cong + ; *-assoc = *-assoc + ; distribʳ = proj₂ distrib + ; zeroˡ = zeroˡ + } + +record IsCommutativeSemiringWithoutOne + (+ * : Op₂ A) (0# : A) : Set (a ) where + field + isSemiringWithoutOne : IsSemiringWithoutOne + * 0# + *-comm : Commutative * + + open IsSemiringWithoutOne isSemiringWithoutOne public + + *-isCommutativeSemigroup : IsCommutativeSemigroup * + *-isCommutativeSemigroup = record + { isSemigroup = *-isSemigroup + ; comm = *-comm + } + + open IsCommutativeSemigroup *-isCommutativeSemigroup public + using () renaming (isCommutativeMagma to *-isCommutativeMagma) + +------------------------------------------------------------------------ +-- Structures with 2 binary operations & 2 elements +------------------------------------------------------------------------ + +record IsSemiringWithoutAnnihilatingZero (+ * : Op₂ A) + (0# 1# : A) : Set (a ) where + field + -- Note that these structures do have an additive unit, but this + -- unit does not necessarily annihilate multiplication. + +-isCommutativeMonoid : IsCommutativeMonoid + 0# + *-cong : Congruent₂ * + *-assoc : Associative * + *-identity : Identity 1# * + distrib : * DistributesOver + + + distribˡ : * DistributesOverˡ + + distribˡ = proj₁ distrib + + distribʳ : * DistributesOverʳ + + distribʳ = proj₂ distrib + + open IsCommutativeMonoid +-isCommutativeMonoid public + renaming + ( assoc to +-assoc + ; ∙-cong to +-cong + ; ∙-congˡ to +-congˡ + ; ∙-congʳ to +-congʳ + ; identity to +-identity + ; identityˡ to +-identityˡ + ; identityʳ to +-identityʳ + ; comm to +-comm + ; isMagma to +-isMagma + ; isSemigroup to +-isSemigroup + ; isMonoid to +-isMonoid + ; isUnitalMagma to +-isUnitalMagma + ; isCommutativeMagma to +-isCommutativeMagma + ; isCommutativeSemigroup to +-isCommutativeSemigroup + ) + + *-isMagma : IsMagma * + *-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = *-cong + } + + *-isSemigroup : IsSemigroup * + *-isSemigroup = record + { isMagma = *-isMagma + ; assoc = *-assoc + } + + *-isMonoid : IsMonoid * 1# + *-isMonoid = record + { isSemigroup = *-isSemigroup + ; identity = *-identity + } + + open IsMonoid *-isMonoid public + using () + renaming + ( ∙-congˡ to *-congˡ + ; ∙-congʳ to *-congʳ + ; identityˡ to *-identityˡ + ; identityʳ to *-identityʳ + ) + + +record IsSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where + field + isSemiringWithoutAnnihilatingZero : + IsSemiringWithoutAnnihilatingZero + * 0# 1# + zero : Zero 0# * + + open IsSemiringWithoutAnnihilatingZero + isSemiringWithoutAnnihilatingZero public + + isSemiringWithoutOne : IsSemiringWithoutOne + * 0# + isSemiringWithoutOne = record + { +-isCommutativeMonoid = +-isCommutativeMonoid + ; *-cong = *-cong + ; *-assoc = *-assoc + ; distrib = distrib + ; zero = zero + } + + open IsSemiringWithoutOne isSemiringWithoutOne public + using + ( isNearSemiring + ; zeroˡ + ; zeroʳ + ) + + +record IsCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where + field + isSemiring : IsSemiring + * 0# 1# + *-comm : Commutative * + + open IsSemiring isSemiring public + + isCommutativeSemiringWithoutOne : + IsCommutativeSemiringWithoutOne + * 0# + isCommutativeSemiringWithoutOne = record + { isSemiringWithoutOne = isSemiringWithoutOne + ; *-comm = *-comm + } + + open IsCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne public + using + ( *-isCommutativeMagma + ; *-isCommutativeSemigroup + ) + + *-isCommutativeMonoid : IsCommutativeMonoid * 1# + *-isCommutativeMonoid = record + { isMonoid = *-isMonoid + ; comm = *-comm + } + + +record IsCancellativeCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where + field + isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# + *-cancelˡ-nonZero : AlmostLeftCancellative 0# * + + open IsCommutativeSemiring isCommutativeSemiring public + + *-cancelʳ-nonZero : AlmostRightCancellative 0# * + *-cancelʳ-nonZero = Consequences.comm∧almostCancelˡ⇒almostCancelʳ setoid + *-comm *-cancelˡ-nonZero + +record IsIdempotentSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where + field + isSemiring : IsSemiring + * 0# 1# + +-idem : Idempotent + + + open IsSemiring isSemiring public + + +-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid + 0# + +-isIdempotentCommutativeMonoid = record + { isCommutativeMonoid = +-isCommutativeMonoid + ; idem = +-idem + } + + open IsIdempotentCommutativeMonoid +-isIdempotentCommutativeMonoid public + using () + renaming ( isCommutativeBand to +-isCommutativeBand + ; isBand to +-isBand + ; isIdempotentMonoid to +-isIdempotentMonoid + ) + + +record IsKleeneAlgebra (+ * : Op₂ A) ( : Op₁ A) (0# 1# : A) : Set (a ) where + field + isIdempotentSemiring : IsIdempotentSemiring + * 0# 1# + starExpansive : StarExpansive 1# + * + starDestructive : StarDestructive + * + + open IsIdempotentSemiring isIdempotentSemiring public + + starExpansiveˡ : StarLeftExpansive 1# + * + starExpansiveˡ = proj₁ starExpansive + + starExpansiveʳ : StarRightExpansive 1# + * + starExpansiveʳ = proj₂ starExpansive + + starDestructiveˡ : StarLeftDestructive + * + starDestructiveˡ = proj₁ starDestructive + + starDestructiveʳ : StarRightDestructive + * + starDestructiveʳ = proj₂ starDestructive + +record IsQuasiring (+ * : Op₂ A) (0# 1# : A) : Set (a ) where + field + +-isMonoid : IsMonoid + 0# + *-cong : Congruent₂ * + *-assoc : Associative * + *-identity : Identity 1# * + distrib : * DistributesOver + + zero : Zero 0# * + + open IsMonoid +-isMonoid public + renaming + ( assoc to +-assoc + ; ∙-cong to +-cong + ; ∙-congˡ to +-congˡ + ; ∙-congʳ to +-congʳ + ; identity to +-identity + ; identityˡ to +-identityˡ + ; identityʳ to +-identityʳ + ; isMagma to +-isMagma + ; isUnitalMagma to +-isUnitalMagma + ; isSemigroup to +-isSemigroup + ) + + distribˡ : * DistributesOverˡ + + distribˡ = proj₁ distrib + + distribʳ : * DistributesOverʳ + + distribʳ = proj₂ distrib + + zeroˡ : LeftZero 0# * + zeroˡ = proj₁ zero + + zeroʳ : RightZero 0# * + zeroʳ = proj₂ zero + + identityˡ : LeftIdentity 1# * + identityˡ = proj₁ *-identity + + identityʳ : RightIdentity 1# * + identityʳ = proj₂ *-identity + + *-isMagma : IsMagma * + *-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = *-cong + } + + *-isSemigroup : IsSemigroup * + *-isSemigroup = record + { isMagma = *-isMagma + ; assoc = *-assoc + } + + *-isMonoid : IsMonoid * 1# + *-isMonoid = record + { isSemigroup = *-isSemigroup + ; identity = *-identity + } + + open IsMonoid *-isMonoid public + using () + renaming + ( ∙-congˡ to *-congˡ + ; ∙-congʳ to *-congʳ + ; identityˡ to *-identityˡ + ; identityʳ to *-identityʳ + ) + +------------------------------------------------------------------------ +-- Structures with 2 binary operations, 1 unary operation & 1 element +------------------------------------------------------------------------ + +record IsRingWithoutOne (+ * : Op₂ A) (-_ : Op₁ A) (0# : A) : Set (a ) where + field + +-isAbelianGroup : IsAbelianGroup + 0# -_ + *-cong : Congruent₂ * + *-assoc : Associative * + distrib : * DistributesOver + + + open IsAbelianGroup +-isAbelianGroup public + renaming + ( assoc to +-assoc + ; ∙-cong to +-cong + ; ∙-congˡ to +-congˡ + ; ∙-congʳ to +-congʳ + ; identity to +-identity + ; identityˡ to +-identityˡ + ; identityʳ to +-identityʳ + ; inverse to -‿inverse + ; inverseˡ to -‿inverseˡ + ; inverseʳ to -‿inverseʳ + ; ⁻¹-cong to -‿cong + ; comm to +-comm + ; isMagma to +-isMagma + ; isSemigroup to +-isSemigroup + ; isMonoid to +-isMonoid + ; isUnitalMagma to +-isUnitalMagma + ; isCommutativeMagma to +-isCommutativeMagma + ; isCommutativeMonoid to +-isCommutativeMonoid + ; isCommutativeSemigroup to +-isCommutativeSemigroup + ; isInvertibleMagma to +-isInvertibleMagma + ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma + ; isGroup to +-isGroup + ) + + distribˡ : * DistributesOverˡ + + distribˡ = proj₁ distrib + + distribʳ : * DistributesOverʳ + + distribʳ = proj₂ distrib + + zeroˡ : LeftZero 0# * + zeroˡ = Consequences.assoc∧distribʳ∧idʳ∧invʳ⇒zeˡ setoid + +-cong *-cong +-assoc distribʳ +-identityʳ -‿inverseʳ + + zeroʳ : RightZero 0# * + zeroʳ = Consequences.assoc∧distribˡ∧idʳ∧invʳ⇒zeʳ setoid + +-cong *-cong +-assoc distribˡ +-identityʳ -‿inverseʳ + + zero : Zero 0# * + zero = zeroˡ , zeroʳ + + isNearSemiring : IsNearSemiring + * 0# + isNearSemiring = record + { +-isMonoid = +-isMonoid + ; *-cong = *-cong + ; *-assoc = *-assoc + ; distribʳ = distribʳ + ; zeroˡ = zeroˡ + } + + open IsNearSemiring isNearSemiring public + using (*-isMagma; *-isSemigroup; *-congˡ; *-congʳ) + +------------------------------------------------------------------------ +-- Structures with 2 binary operations, 1 unary operation & 2 elements +------------------------------------------------------------------------ + +record IsNonAssociativeRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ) where + field + +-isAbelianGroup : IsAbelianGroup + 0# -_ + *-cong : Congruent₂ * + *-identity : Identity 1# * + distrib : * DistributesOver + + zero : Zero 0# * + + open IsAbelianGroup +-isAbelianGroup public + renaming + ( assoc to +-assoc + ; ∙-cong to +-cong + ; ∙-congˡ to +-congˡ + ; ∙-congʳ to +-congʳ + ; identity to +-identity + ; identityˡ to +-identityˡ + ; identityʳ to +-identityʳ + ; inverse to -‿inverse + ; inverseˡ to -‿inverseˡ + ; inverseʳ to -‿inverseʳ + ; ⁻¹-cong to -‿cong + ; comm to +-comm + ; isMagma to +-isMagma + ; isSemigroup to +-isSemigroup + ; isMonoid to +-isMonoid + ; isUnitalMagma to +-isUnitalMagma + ; isCommutativeMagma to +-isCommutativeMagma + ; isCommutativeMonoid to +-isCommutativeMonoid + ; isCommutativeSemigroup to +-isCommutativeSemigroup + ; isInvertibleMagma to +-isInvertibleMagma + ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma + ; isGroup to +-isGroup + ) + + zeroˡ : LeftZero 0# * + zeroˡ = proj₁ zero + + zeroʳ : RightZero 0# * + zeroʳ = proj₂ zero + + distribˡ : * DistributesOverˡ + + distribˡ = proj₁ distrib + + distribʳ : * DistributesOverʳ + + distribʳ = proj₂ distrib + + *-isMagma : IsMagma * + *-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = *-cong + } + + *-identityˡ : LeftIdentity 1# * + *-identityˡ = proj₁ *-identity + + *-identityʳ : RightIdentity 1# * + *-identityʳ = proj₂ *-identity + + *-isUnitalMagma : IsUnitalMagma * 1# + *-isUnitalMagma = record + { isMagma = *-isMagma + ; identity = *-identity + } + + open IsUnitalMagma *-isUnitalMagma public + using () + renaming + ( ∙-congˡ to *-congˡ + ; ∙-congʳ to *-congʳ + ) + +record IsNearring (+ * : Op₂ A) (0# 1# : A) (_⁻¹ : Op₁ A) : Set (a ) where + field + isQuasiring : IsQuasiring + * 0# 1# + +-inverse : Inverse 0# _⁻¹ + + ⁻¹-cong : Congruent₁ _⁻¹ + + open IsQuasiring isQuasiring public + + +-inverseˡ : LeftInverse 0# _⁻¹ + + +-inverseˡ = proj₁ +-inverse + + +-inverseʳ : RightInverse 0# _⁻¹ + + +-inverseʳ = proj₂ +-inverse + +record IsRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ) where + field + +-isAbelianGroup : IsAbelianGroup + 0# -_ + *-cong : Congruent₂ * + *-assoc : Associative * + *-identity : Identity 1# * + distrib : * DistributesOver + + + isRingWithoutOne : IsRingWithoutOne + * -_ 0# + isRingWithoutOne = record + { +-isAbelianGroup = +-isAbelianGroup + ; *-cong = *-cong + ; *-assoc = *-assoc + ; distrib = distrib + } + + open IsRingWithoutOne isRingWithoutOne public + hiding (+-isAbelianGroup; *-cong; *-assoc; distrib) + + *-isMonoid : IsMonoid * 1# + *-isMonoid = record + { isSemigroup = *-isSemigroup + ; identity = *-identity + } + + open IsMonoid *-isMonoid public + using () + renaming + ( identityˡ to *-identityˡ + ; identityʳ to *-identityʳ + ) + + isSemiringWithoutAnnihilatingZero + : IsSemiringWithoutAnnihilatingZero + * 0# 1# + isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = +-isCommutativeMonoid + ; *-cong = *-cong + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = distrib + } + + isSemiring : IsSemiring + * 0# 1# + isSemiring = record + { isSemiringWithoutAnnihilatingZero = + isSemiringWithoutAnnihilatingZero + ; zero = zero + } + + open IsSemiring isSemiring public + using (isSemiringWithoutOne) + + +record IsCommutativeRing + (+ * : Op₂ A) (- : Op₁ A) (0# 1# : A) : Set (a ) where + field + isRing : IsRing + * - 0# 1# + *-comm : Commutative * + + open IsRing isRing public + + isCommutativeSemiring : IsCommutativeSemiring + * 0# 1# + isCommutativeSemiring = record + { isSemiring = isSemiring + ; *-comm = *-comm + } + + open IsCommutativeSemiring isCommutativeSemiring public + using + ( isCommutativeSemiringWithoutOne + ; *-isCommutativeMagma + ; *-isCommutativeSemigroup + ; *-isCommutativeMonoid + ) + +------------------------------------------------------------------------ +-- Structures with 3 binary operations +------------------------------------------------------------------------ + +record IsQuasigroup ( \\ // : Op₂ A) : Set (a ) where + field + isMagma : IsMagma + \\-cong : Congruent₂ \\ + //-cong : Congruent₂ // + leftDivides : LeftDivides \\ + rightDivides : RightDivides // + + open IsMagma isMagma public + + \\-congˡ : LeftCongruent \\ + \\-congˡ y≈z = \\-cong refl y≈z + + \\-congʳ : RightCongruent \\ + \\-congʳ y≈z = \\-cong y≈z refl + + //-congˡ : LeftCongruent // + //-congˡ y≈z = //-cong refl y≈z + + //-congʳ : RightCongruent // + //-congʳ y≈z = //-cong y≈z refl + + leftDividesˡ : LeftDividesˡ \\ + leftDividesˡ = proj₁ leftDivides + + leftDividesʳ : LeftDividesʳ \\ + leftDividesʳ = proj₂ leftDivides + + rightDividesˡ : RightDividesˡ // + rightDividesˡ = proj₁ rightDivides + + rightDividesʳ : RightDividesʳ // + rightDividesʳ = proj₂ rightDivides -record IsLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where - field - isQuasigroup : IsQuasigroup \\ // - identity : Identity ε +record IsLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where + field + isQuasigroup : IsQuasigroup \\ // + identity : Identity ε - open IsQuasigroup isQuasigroup public + open IsQuasigroup isQuasigroup public - identityˡ : LeftIdentity ε - identityˡ = proj₁ identity + identityˡ : LeftIdentity ε + identityˡ = proj₁ identity - identityʳ : RightIdentity ε - identityʳ = proj₂ identity + identityʳ : RightIdentity ε + identityʳ = proj₂ identity -record IsLeftBolLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where - field - isLoop : IsLoop \\ // ε - leftBol : LeftBol +record IsLeftBolLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where + field + isLoop : IsLoop \\ // ε + leftBol : LeftBol - open IsLoop isLoop public + open IsLoop isLoop public -record IsRightBolLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where - field - isLoop : IsLoop \\ // ε - rightBol : RightBol +record IsRightBolLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where + field + isLoop : IsLoop \\ // ε + rightBol : RightBol - open IsLoop isLoop public + open IsLoop isLoop public -record IsMoufangLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where - field - isLeftBolLoop : IsLeftBolLoop \\ // ε - rightBol : RightBol - identical : Identical +record IsMoufangLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where + field + isLeftBolLoop : IsLeftBolLoop \\ // ε + rightBol : RightBol + identical : Identical - open IsLeftBolLoop isLeftBolLoop public + open IsLeftBolLoop isLeftBolLoop public -record IsMiddleBolLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where - field - isLoop : IsLoop \\ // ε - middleBol : MiddleBol \\ // +record IsMiddleBolLoop ( \\ // : Op₂ A) (ε : A) : Set (a ) where + field + isLoop : IsLoop \\ // ε + middleBol : MiddleBol \\ // - open IsLoop isLoop public + open IsLoop isLoop public \ No newline at end of file diff --git a/v2.3/Codata.Guarded.Stream.Relation.Unary.Any.html b/v2.3/Codata.Guarded.Stream.Relation.Unary.Any.html index ce3d1367de..56ad15ce2d 100644 --- a/v2.3/Codata.Guarded.Stream.Relation.Unary.Any.html +++ b/v2.3/Codata.Guarded.Stream.Relation.Unary.Any.html @@ -12,7 +12,7 @@ open import Codata.Guarded.Stream as Stream using (Stream) open import Data.Nat.Base hiding (_⊔_) open import Level hiding (zero; suc) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary using (Pred; _⊆_) private @@ -28,10 +28,10 @@ head : ¬ Any P (Stream.tail xs) Any P xs P (Stream.head xs) head ¬t (here h) = h -head ¬t (there t) = contradiction t ¬t +head ¬t (there t) = contradiction t ¬t tail : ¬ P (Stream.head xs) Any P xs Any P (Stream.tail xs) -tail ¬h (here h) = contradiction h ¬h +tail ¬h (here h) = contradiction h ¬h tail ¬h (there t) = t map : P Q Any P Any Q diff --git a/v2.3/Codata.Musical.Colist.Infinite-merge.html b/v2.3/Codata.Musical.Colist.Infinite-merge.html index 8240848876..e845ad1328 100644 --- a/v2.3/Codata.Musical.Colist.Infinite-merge.html +++ b/v2.3/Codata.Musical.Colist.Infinite-merge.html @@ -13,7 +13,7 @@ open import Codata.Musical.Colist as Colist hiding (_⋎_) open import Data.Nat.Base using (; zero; suc; _≤_; _≥′_; _<′_; _≤′_) open import Data.Nat.Induction using (<′-wellFounded) -open import Data.Nat.Properties using (s≤′s) +open import Data.Nat.Properties using (s≤′s) open import Data.Product.Base as Product using (_×_; _,_; ; ∃₂; proj₁; proj₂) open import Data.Sum.Base using (_⊎_; inj₁; inj₂; [_,_]′) open import Data.Sum.Properties using (inj₁-injective; inj₂-injective) @@ -198,7 +198,7 @@ ... | inj₂ q | refl | q≤p = Product.map there (cong (there (Inverse.from (Any-⋎P xs)) inj₂)) - (rec (s≤′s q≤p)) + (rec (s≤′s q≤p)) to∘from = λ p from-injective _ _ (proj₂ (to xss (from p))) diff --git a/v2.3/Codata.Musical.Colist.Relation.Unary.Any.Properties.html b/v2.3/Codata.Musical.Colist.Relation.Unary.Any.Properties.html index bd7353fa52..1cbc98d59a 100644 --- a/v2.3/Codata.Musical.Colist.Relation.Unary.Any.Properties.html +++ b/v2.3/Codata.Musical.Colist.Relation.Unary.Any.Properties.html @@ -16,7 +16,7 @@ open import Data.Maybe using (Is-just) open import Data.Maybe.Relation.Unary.Any using (just) open import Data.Nat.Base using (suc; _≥′_; ≤′-refl; ≤′-step) -open import Data.Nat.Properties using (s≤′s) +open import Data.Nat.Properties using (s≤′s) open import Data.Sum.Base using (_⊎_; inj₁; inj₂; [_,_]′; [_,_]) open import Function.Base using (_∋_; _∘_) open import Function.Bundles @@ -179,5 +179,5 @@ index-Any-⋎ (x xs) {ys = ys} (there p) with Inverse.to (Any-⋎ ys) p | index-Any-⋎ ys p ... | inj₁ q | q≤p = ≤′-step q≤p -... | inj₂ q | q≤p = s≤′s q≤p +... | inj₂ q | q≤p = s≤′s q≤p \ No newline at end of file diff --git a/v2.3/Codata.Musical.Colist.html b/v2.3/Codata.Musical.Colist.html index 208fcf5181..748ad76adb 100644 --- a/v2.3/Codata.Musical.Colist.html +++ b/v2.3/Codata.Musical.Colist.html @@ -38,7 +38,7 @@ open import Relation.Binary.Reasoning.Syntax open import Relation.Nullary.Reflects using (invert) open import Relation.Nullary -open import Relation.Nullary.Negation using (¬_; contradiction; ¬¬-Monad) +open import Relation.Nullary.Negation using (¬_; contradiction; ¬¬-Monad) open import Relation.Nullary.Decidable using (¬¬-excluded-middle) open import Relation.Unary using (Pred) @@ -237,7 +237,7 @@ not-finite-is-infinite : (xs : Colist A) ¬ Finite xs Infinite xs -not-finite-is-infinite [] hyp = contradiction [] hyp +not-finite-is-infinite [] hyp = contradiction [] hyp not-finite-is-infinite (x xs) hyp = x not-finite-is-infinite ( xs) (hyp _∷_ x) diff --git a/v2.3/Data.Bool.Properties.html b/v2.3/Data.Bool.Properties.html index 78051546e7..dbaf0152f4 100644 --- a/v2.3/Data.Bool.Properties.html +++ b/v2.3/Data.Bool.Properties.html @@ -42,7 +42,7 @@ using (module ≡-Reasoning; setoid; decSetoid; isEquivalence) open import Relation.Nullary.Decidable.Core using (True; yes; no; fromWitness ; toWitness) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) import Relation.Unary as U open import Algebra.Definitions {A = Bool} _≡_ @@ -544,23 +544,23 @@ { isIdempotentCommutativeMonoid = ∧-isIdempotentCommutativeMonoid } -∨-∧-isSemiring : IsSemiring _∨_ _∧_ false true +∨-∧-isSemiring : IsSemiring _∨_ _∧_ false true ∨-∧-isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = ∨-isCommutativeMonoid - ; *-cong = cong₂ _∧_ - ; *-assoc = ∧-assoc - ; *-identity = ∧-identity - ; distrib = ∧-distrib-∨ + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = ∨-isCommutativeMonoid + ; *-cong = cong₂ _∧_ + ; *-assoc = ∧-assoc + ; *-identity = ∧-identity + ; distrib = ∧-distrib-∨ } - ; zero = ∧-zero + ; zero = ∧-zero } ∨-∧-isCommutativeSemiring - : IsCommutativeSemiring _∨_ _∧_ false true + : IsCommutativeSemiring _∨_ _∧_ false true ∨-∧-isCommutativeSemiring = record - { isSemiring = ∨-∧-isSemiring - ; *-comm = ∧-comm + { isSemiring = ∨-∧-isSemiring + ; *-comm = ∧-comm } ∨-∧-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ @@ -572,23 +572,23 @@ ; isCommutativeSemiring = ∨-∧-isCommutativeSemiring } -∧-∨-isSemiring : IsSemiring _∧_ _∨_ true false +∧-∨-isSemiring : IsSemiring _∧_ _∨_ true false ∧-∨-isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = ∧-isCommutativeMonoid - ; *-cong = cong₂ _∨_ - ; *-assoc = ∨-assoc - ; *-identity = ∨-identity - ; distrib = ∨-distrib-∧ + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = ∧-isCommutativeMonoid + ; *-cong = cong₂ _∨_ + ; *-assoc = ∨-assoc + ; *-identity = ∨-identity + ; distrib = ∨-distrib-∧ } - ; zero = ∨-zero + ; zero = ∨-zero } ∧-∨-isCommutativeSemiring - : IsCommutativeSemiring _∧_ _∨_ true false + : IsCommutativeSemiring _∧_ _∨_ true false ∧-∨-isCommutativeSemiring = record - { isSemiring = ∧-∨-isSemiring - ; *-comm = ∨-comm + { isSemiring = ∧-∨-isSemiring + ; *-comm = ∨-comm } ∧-∨-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ @@ -658,10 +658,10 @@ not-¬ {false} refl () ¬-not : {x y} x y x not y -¬-not {true} {true} x≢y = contradiction refl x≢y +¬-not {true} {true} x≢y = contradiction refl x≢y ¬-not {true} {false} _ = refl ¬-not {false} {true} _ = refl -¬-not {false} {false} x≢y = contradiction refl x≢y +¬-not {false} {false} x≢y = contradiction refl x≢y ------------------------------------------------------------------------ -- Properties of _xor_ diff --git a/v2.3/Data.Char.Properties.html b/v2.3/Data.Char.Properties.html index 1f96d093cf..9876c9df4f 100644 --- a/v2.3/Data.Char.Properties.html +++ b/v2.3/Data.Char.Properties.html @@ -13,8 +13,8 @@ open import Data.Char.Base using (Char; _≈_; _≉_; _<_; _≤_; toℕ) import Data.Nat.Base as using (; _<_; _≤_) import Data.Nat.Properties as - using (_<?_; <-cmp; <-isStrictPartialOrder; <-isStrictTotalOrder - ; <-strictPartialOrder; <-strictTotalOrder; <-irrefl; <-trans; <-asym + using (_<?_; <-cmp; <-isStrictPartialOrder; <-isStrictTotalOrder + ; <-strictPartialOrder; <-strictTotalOrder; <-irrefl; <-trans; <-asym ; _≟_) open import Data.Product.Base using (_,_) open import Function.Base using (const; _∘′_) @@ -106,22 +106,22 @@ infix 4 _<?_ _<?_ : Decidable _<_ -_<?_ = On.decidable toℕ ℕ._<_ ℕ._<?_ +_<?_ = On.decidable toℕ ℕ._<_ ℕ._<?_ <-cmp : Trichotomous _≡_ _<_ -<-cmp c d with ℕ.<-cmp (toℕ c) (toℕ d) +<-cmp c d with ℕ.<-cmp (toℕ c) (toℕ d) ... | tri< lt ¬eq ¬gt = tri< lt (≉⇒≢ ¬eq) ¬gt ... | tri≈ ¬lt eq ¬gt = tri≈ ¬lt (≈⇒≡ eq) ¬gt ... | tri> ¬lt ¬eq gt = tri> ¬lt (≉⇒≢ ¬eq) gt <-irrefl : Irreflexive _≡_ _<_ -<-irrefl = ℕ.<-irrefl ∘′ cong toℕ +<-irrefl = ℕ.<-irrefl ∘′ cong toℕ <-trans : Transitive _<_ -<-trans {c} {d} {e} = On.transitive toℕ ℕ._<_ ℕ.<-trans {c} {d} {e} +<-trans {c} {d} {e} = On.transitive toℕ ℕ._<_ ℕ.<-trans {c} {d} {e} <-asym : Asymmetric _<_ -<-asym {c} {d} = On.asymmetric toℕ ℕ._<_ ℕ.<-asym {c} {d} +<-asym {c} {d} = On.asymmetric toℕ ℕ._<_ ℕ.<-asym {c} {d} <-isStrictPartialOrder : IsStrictPartialOrder _≡_ _<_ <-isStrictPartialOrder = record @@ -162,7 +162,7 @@ ≤-trans = Refl.trans {a} {b} {c} <-trans {a} {b} {c}) ≤-antisym : Antisymmetric _≡_ _≤_ -≤-antisym = Refl.antisym _≡_ refl ℕ.<-asym +≤-antisym = Refl.antisym _≡_ refl ℕ.<-asym ≤-isPreorder : IsPreorder _≡_ _≤_ ≤-isPreorder = record @@ -288,28 +288,28 @@ #-} <-isStrictPartialOrder-≈ : IsStrictPartialOrder _≈_ _<_ -<-isStrictPartialOrder-≈ = On.isStrictPartialOrder toℕ ℕ.<-isStrictPartialOrder +<-isStrictPartialOrder-≈ = On.isStrictPartialOrder toℕ ℕ.<-isStrictPartialOrder {-# WARNING_ON_USAGE <-isStrictPartialOrder-≈ "Warning: <-isStrictPartialOrder-≈ was deprecated in v1.5. Please use <-isStrictPartialOrder instead." #-} <-isStrictTotalOrder-≈ : IsStrictTotalOrder _≈_ _<_ -<-isStrictTotalOrder-≈ = On.isStrictTotalOrder toℕ ℕ.<-isStrictTotalOrder +<-isStrictTotalOrder-≈ = On.isStrictTotalOrder toℕ ℕ.<-isStrictTotalOrder {-# WARNING_ON_USAGE <-isStrictTotalOrder-≈ "Warning: <-isStrictTotalOrder-≈ was deprecated in v1.5. Please use <-isStrictTotalOrder instead." #-} <-strictPartialOrder-≈ : StrictPartialOrder _ _ _ -<-strictPartialOrder-≈ = On.strictPartialOrder ℕ.<-strictPartialOrder toℕ +<-strictPartialOrder-≈ = On.strictPartialOrder ℕ.<-strictPartialOrder toℕ {-# WARNING_ON_USAGE <-strictPartialOrder-≈ "Warning: <-strictPartialOrder-≈ was deprecated in v1.5. Please use <-strictPartialOrder instead." #-} <-strictTotalOrder-≈ : StrictTotalOrder _ _ _ -<-strictTotalOrder-≈ = On.strictTotalOrder ℕ.<-strictTotalOrder toℕ +<-strictTotalOrder-≈ = On.strictTotalOrder ℕ.<-strictTotalOrder toℕ {-# WARNING_ON_USAGE <-strictTotalOrder-≈ "Warning: <-strictTotalOrder-≈ was deprecated in v1.5. Please use <-strictTotalOrder instead." diff --git a/v2.3/Data.Container.Combinator.Properties.html b/v2.3/Data.Container.Combinator.Properties.html index 2c4b928bc1..5fa2e419f1 100644 --- a/v2.3/Data.Container.Combinator.Properties.html +++ b/v2.3/Data.Container.Combinator.Properties.html @@ -20,7 +20,7 @@ open import Level using (_⊔_; lower) open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≗_; refl; cong) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) -- I have proved some of the correctness statements under the -- assumption of functional extensionality. I could have reformulated @@ -37,7 +37,7 @@ correct {x} {y} X {Y} = mk↔ₛ′ (from-const X) (to-const X) _ refl) from∘to where from∘to : (x : const X Y) to-const X (proj₁ x) x - from∘to xs = cong (proj₁ xs ,_) (ext x contradiction x lower )) + from∘to xs = cong (proj₁ xs ,_) (ext x contradiction x lower )) module Composition {s₁ s₂ p₁ p₂} (C₁ : Container s₁ p₁) (C₂ : Container s₂ p₂) where diff --git a/v2.3/Data.Digit.Properties.html b/v2.3/Data.Digit.Properties.html index 86fa2b6a30..02fff0aa71 100644 --- a/v2.3/Data.Digit.Properties.html +++ b/v2.3/Data.Digit.Properties.html @@ -10,8 +10,8 @@ open import Data.Digit using (digitChars; Digit; showDigit; toDigits) import Data.Char.Properties as Char open import Data.Nat.Base using () -open import Data.Nat.Properties using (_≤?_) -open import Data.Fin.Properties using (inject≤-injective) +open import Data.Nat.Properties using (_≤?_) +open import Data.Fin.Properties using (inject≤-injective) open import Data.Product.Base using (_,_; proj₁) open import Data.Vec.Relation.Unary.Unique.Propositional using (Unique) import Data.Vec.Relation.Unary.Unique.Propositional.Properties as Unique @@ -26,12 +26,12 @@ digitCharsUnique = from-yes (allPairs? x y ¬? (x Char.≟ y)) digitChars) module _ (base : ) where - module _ {base≥2 base≥2′ : True (2 ≤? base)} where + module _ {base≥2 base≥2′ : True (2 ≤? base)} where toDigits-injective : n m proj₁ (toDigits base {base≥2} n) proj₁ (toDigits base {base≥2′} m) n m toDigits-injective n m eq with toDigits base {base≥2} n | toDigits base {base≥2′} m toDigits-injective ._ ._ refl | _ , refl | ._ , refl = refl - module _ {base≤16 base≤16′ : True (base ≤? 16)} where + module _ {base≤16 base≤16′ : True (base ≤? 16)} where showDigit-injective : (n m : Digit base) showDigit {base} {base≤16} n showDigit {base} {base≤16′} m n m - showDigit-injective n m = inject≤-injective _ _ n m Unique.lookup-injective digitCharsUnique _ _ + showDigit-injective n m = inject≤-injective _ _ n m Unique.lookup-injective digitCharsUnique _ _ \ No newline at end of file diff --git a/v2.3/Data.Digit.html b/v2.3/Data.Digit.html index 8163923062..23fd02ab97 100644 --- a/v2.3/Data.Digit.html +++ b/v2.3/Data.Digit.html @@ -12,8 +12,8 @@ open import Data.Nat.Base using (; zero; suc; _<_; _/_; _%_; sz<ss; _+_; _*_; 2+; _≤′_) open import Data.Nat.Properties - using (_≤?_; _<?_; ≤⇒≤′; module ≤-Reasoning; m≤m+n; +-comm; +-assoc - ; *-distribˡ-+; *-identityʳ) + using (_≤?_; _<?_; ≤⇒≤′; module ≤-Reasoning; m≤m+n; +-comm; +-assoc + ; *-distribˡ-+; *-identityʳ) open import Data.Fin.Base as Fin using (Fin; zero; suc; toℕ) open import Data.Bool.Base using (Bool; true; false) open import Data.Char.Base using (Char) @@ -53,13 +53,13 @@ ------------------------------------------------------------------------ -- Converting between `ℕ` and `expansions of ℕ` -toNatDigits : (base : ) {base≤16 : True (1 ≤? base)} List +toNatDigits : (base : ) {base≤16 : True (1 ≤? base)} List toNatDigits base@(suc zero) n = replicate n 1 toNatDigits base@(suc (suc _)) n = aux (<-wellFounded-fast n) [] where aux : {n : } Acc _<_ n List List aux {zero} _ xs = (0 xs) - aux {n@(suc _)} (acc wf) xs with does (0 <? n / base) + aux {n@(suc _)} (acc wf) xs with does (0 <? n / base) ... | false = (n % base) xs -- Could this more simply be n ∷ xs here? ... | true = aux (wf (m/n<m n base sz<ss)) ((n % base) xs) @@ -82,7 +82,7 @@ -- -- Note that the list of digits is always non-empty. -toDigits : (base : ) {base≥2 : True (2 ≤? base)} (n : ) +toDigits : (base : ) {base≥2 : True (2 ≤? base)} (n : ) λ (ds : Expansion base) fromDigits ds n toDigits base@(suc (suc k)) n = <′-rec Pred helper n where @@ -94,30 +94,30 @@ lem′ : x k x + x + (k + x * k) k + x * 2+ k lem′ x k = begin - x + x + (k + x * k) ≡⟨ +-assoc (x + x) k _ - x + x + k + x * k ≡⟨ cong (_+ x * k) (+-comm _ k) - k + (x + x) + x * k ≡⟨ +-assoc k (x + x) _ + x + x + (k + x * k) ≡⟨ +-assoc (x + x) k _ + x + x + k + x * k ≡⟨ cong (_+ x * k) (+-comm _ k) + k + (x + x) + x * k ≡⟨ +-assoc k (x + x) _ k + ((x + x) + x * k) ≡⟨ cong (k +_) (begin - (x + x) + x * k ≡⟨ +-assoc x x _ - x + (x + x * k) ≡⟨ cong (x +_) (cong (_+ x * k) (*-identityʳ x)) - x + (x * 1 + x * k) ≡⟨ cong₂ _+_ (*-identityʳ x) (*-distribˡ-+ x 1 k ) - x * 1 + (x * suc k) ≡⟨ *-distribˡ-+ x 1 (1 + k) + (x + x) + x * k ≡⟨ +-assoc x x _ + x + (x + x * k) ≡⟨ cong (x +_) (cong (_+ x * k) (*-identityʳ x)) + x + (x * 1 + x * k) ≡⟨ cong₂ _+_ (*-identityʳ x) (*-distribˡ-+ x 1 k ) + x * 1 + (x * suc k) ≡⟨ *-distribˡ-+ x 1 (1 + k) x * 2+ k ) k + x * 2+ k where open ≡-Reasoning lem : x k r 2 + x ≤′ r + (1 + x) * (2 + k) - lem x k r = ≤⇒≤′ $ begin - 2 + x ≤⟨ m≤m+n _ _ - 2 + x + (x + (1 + x) * k + r) ≡⟨ cong ((2 + x) +_) (+-comm _ r) - 2 + x + (r + (x + (1 + x) * k)) ≡⟨ +-assoc (2 + x) r _ - 2 + x + r + (x + (1 + x) * k) ≡⟨ cong (_+ (x + (1 + x) * k)) (+-comm (2 + x) r) - r + (2 + x) + (x + (1 + x) * k) ≡⟨ +-assoc r (2 + x) _ - r + ((2 + x) + (x + (1 + x) * k)) ≡⟨ cong (r +_) (cong 2+ (+-assoc x x _)) + lem x k r = ≤⇒≤′ $ begin + 2 + x ≤⟨ m≤m+n _ _ + 2 + x + (x + (1 + x) * k + r) ≡⟨ cong ((2 + x) +_) (+-comm _ r) + 2 + x + (r + (x + (1 + x) * k)) ≡⟨ +-assoc (2 + x) r _ + 2 + x + r + (x + (1 + x) * k) ≡⟨ cong (_+ (x + (1 + x) * k)) (+-comm (2 + x) r) + r + (2 + x) + (x + (1 + x) * k) ≡⟨ +-assoc r (2 + x) _ + r + ((2 + x) + (x + (1 + x) * k)) ≡⟨ cong (r +_) (cong 2+ (+-assoc x x _)) r + (2 + (x + x + (1 + x) * k)) ≡⟨ cong z r + (2+ z)) (lem′ x k) r + (2 + (k + x * (2 + k))) ≡⟨⟩ r + (1 + x) * (2 + k) - where open ≤-Reasoning + where open ≤-Reasoning helper : n <′-Rec Pred n Pred n helper n rec with n divMod base @@ -136,7 +136,7 @@ -- showDigit shows digits in base ≤ 16. -showDigit : {base} {base≤16 : True (base ≤? 16)} Digit base Char +showDigit : {base} {base≤16 : True (base ≤? 16)} Digit base Char showDigit {base≤16 = base≤16} d = Vec.lookup digitChars (Fin.inject≤ d (toWitness base≤16)) \ No newline at end of file diff --git a/v2.3/Data.Fin.Base.html b/v2.3/Data.Fin.Base.html index 922242c777..8d9de3521f 100644 --- a/v2.3/Data.Fin.Base.html +++ b/v2.3/Data.Fin.Base.html @@ -20,7 +20,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≢_; refl; cong) open import Relation.Binary.Indexed.Heterogeneous.Core using (IRel) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) private variable @@ -118,7 +118,7 @@ -- lower₁ "i" _ = "i". lower₁ : (i : Fin (suc n)) n toℕ i Fin n -lower₁ {zero} zero ne = contradiction refl ne +lower₁ {zero} zero ne = contradiction refl ne lower₁ {suc n} zero _ = zero lower₁ {suc n} (suc i) ne = suc (lower₁ i (ne cong suc)) @@ -254,7 +254,7 @@ -- McBride's "First-order unification by structural recursion". punchOut : {i j : Fin (suc n)} i j Fin n -punchOut {_} {zero} {zero} i≢j = contradiction refl i≢j +punchOut {_} {zero} {zero} i≢j = contradiction refl i≢j punchOut {_} {zero} {suc j} _ = j punchOut {suc _} {suc i} {zero} _ = zero punchOut {suc _} {suc i} {suc j} i≢j = suc (punchOut (i≢j cong suc)) diff --git a/v2.3/Data.Fin.Induction.html b/v2.3/Data.Fin.Induction.html index 1688b052b4..10f2225301 100644 --- a/v2.3/Data.Fin.Induction.html +++ b/v2.3/Data.Fin.Induction.html @@ -12,13 +12,13 @@ open import Data.Fin.Base using (Fin; zero; suc; _<_; toℕ; inject₁; _≥_; _>_; fromℕ; _≺_) -open import Data.Fin.Properties using (toℕ-inject₁; ≤-refl; <-cmp; - toℕ≤n; toℕ-injective; toℕ-fromℕ; toℕ-lower₁; inject₁-lower₁; - pigeonhole; ≺⇒<′) +open import Data.Fin.Properties using (toℕ-inject₁; ≤-refl; <-cmp; + toℕ≤n; toℕ-injective; toℕ-fromℕ; toℕ-lower₁; inject₁-lower₁; + pigeonhole; ≺⇒<′) open import Data.Nat.Base as using (; zero; suc; _∸_; s≤s) -open import Data.Nat.Properties using (n<1+n; ≤⇒≯) +open import Data.Nat.Properties using (n<1+n; ≤⇒≯) import Data.Nat.Induction as using (<′-wellFounded; <-wellFounded) -import Data.Nat.Properties as using (<-cmp) +import Data.Nat.Properties as using (<-cmp) open import Data.Product.Base using (_,_) open import Data.Vec.Base as Vec using (Vec; []; _∷_) open import Data.Vec.Relation.Unary.Linked as Linked using (Linked; [-]; _∷_) @@ -40,7 +40,7 @@ open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; sym; subst; trans; cong) open import Relation.Nullary.Decidable using (yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Unary using (Pred) private @@ -63,16 +63,16 @@ {i} P i (∀ j P (inject₁ j) P (suc j)) {j} j i P j -<-weakInduction-startingFrom P {i} Pi Pᵢ⇒Pᵢ₊₁ {j} j≥i = induct (<-wellFounded _) (<-cmp i j) j≥i +<-weakInduction-startingFrom P {i} Pi Pᵢ⇒Pᵢ₊₁ {j} j≥i = induct (<-wellFounded _) (<-cmp i j) j≥i where induct : {j} Acc _<_ j Tri (i < j) (i j) (i > j) j i P j induct (acc rs) (tri≈ _ refl _) i≤j = Pi - induct (acc rs) (tri> _ _ i>sj) i≤j with ()≤⇒≯ i≤j i>sj + induct (acc rs) (tri> _ _ i>sj) i≤j with ()≤⇒≯ i≤j i>sj induct {suc j} (acc rs) (tri< (s≤s i≤j) _ _) _ = Pᵢ⇒Pᵢ₊₁ j P[1+j] where - toℕj≡toℕinjJ = sym $ toℕ-inject₁ j - P[1+j] = induct (rs (s≤s (subst (ℕ._≤ toℕ j) toℕj≡toℕinjJ ≤-refl))) - (<-cmp i $ inject₁ j) (subst (toℕ i ℕ.≤_) toℕj≡toℕinjJ i≤j) + toℕj≡toℕinjJ = sym $ toℕ-inject₁ j + P[1+j] = induct (rs (s≤s (subst (ℕ._≤ toℕ j) toℕj≡toℕinjJ ≤-refl))) + (<-cmp i $ inject₁ j) (subst (toℕ i ℕ.≤_) toℕj≡toℕinjJ i≤j) <-weakInduction : (P : Pred (Fin (suc n)) ) P zero @@ -86,7 +86,7 @@ private acc-map : {x : Fin n} Acc ℕ._<_ (n toℕ x) Acc _>_ x - acc-map (acc rs) = acc λ y>x acc-map (rs (ℕ.∸-monoʳ-< y>x (toℕ≤n _))) + acc-map (acc rs) = acc λ y>x acc-map (rs (ℕ.∸-monoʳ-< y>x (toℕ≤n _))) >-wellFounded : WellFounded {A = Fin n} _>_ >-wellFounded {n} x = acc-map (ℕ.<-wellFounded (n toℕ x)) @@ -99,9 +99,9 @@ where induct : {i} Acc _>_ i P i induct {i} (acc rec) with n ℕ.≟ toℕ i - ... | yes n≡i = subst P (toℕ-injective (trans (toℕ-fromℕ n) n≡i)) Pₙ - ... | no n≢i = subst P (inject₁-lower₁ i n≢i) (Pᵢ₊₁⇒Pᵢ _ Pᵢ₊₁) - where Pᵢ₊₁ = induct (rec (ℕ.≤-reflexive (cong suc (sym (toℕ-lower₁ i n≢i))))) + ... | yes n≡i = subst P (toℕ-injective (trans (toℕ-fromℕ n) n≡i)) Pₙ + ... | no n≢i = subst P (inject₁-lower₁ i n≢i) (Pᵢ₊₁⇒Pᵢ _ Pᵢ₊₁) + where Pᵢ₊₁ = induct (rec (ℕ.≤-reflexive (cong suc (sym (toℕ-lower₁ i n≢i))))) ------------------------------------------------------------------------ -- Well-foundedness of other (strict) partial orders on Fin @@ -129,10 +129,10 @@ pigeon : {xs : Vec (Fin n) n} Linked (flip _⊏_) (i xs) WellFounded _⊏_ pigeon {xs} i∷xs↑ = - let (i₁ , i₂ , i₁<i₂ , xs[i₁]≡xs[i₂]) = pigeonhole (n<1+n n) (Vec.lookup (i xs)) in + let (i₁ , i₂ , i₁<i₂ , xs[i₁]≡xs[i₂]) = pigeonhole (n<1+n n) (Vec.lookup (i xs)) in let xs[i₁]⊏xs[i₂] = Linked.lookup⁺ (Ord.transitive _⊏_ ⊏.trans) i∷xs↑ i₁<i₂ in let xs[i₁]⊏xs[i₁] = ⊏.<-respʳ-≈ (⊏.Eq.reflexive xs[i₁]≡xs[i₂]) xs[i₁]⊏xs[i₂] in - contradiction xs[i₁]⊏xs[i₁] (⊏.irrefl ⊏.Eq.refl) + contradiction xs[i₁]⊏xs[i₁] (⊏.irrefl ⊏.Eq.refl) po-wellFounded : {r} {_⊑_ : Rel (Fin n) r} IsPartialOrder _≈_ _⊑_ WellFounded (ToStrict._<_ _≈_ _⊑_) @@ -163,7 +163,7 @@ ≺-Rec = WfRec _≺_ ≺-wellFounded : WellFounded _≺_ -≺-wellFounded = Subrelation.wellFounded ≺⇒<′ ℕ.<′-wellFounded +≺-wellFounded = Subrelation.wellFounded ≺⇒<′ ℕ.<′-wellFounded module _ {} where open WF.All ≺-wellFounded public diff --git a/v2.3/Data.Fin.Instances.html b/v2.3/Data.Fin.Instances.html index 7cde94e63c..31003b1ffc 100644 --- a/v2.3/Data.Fin.Instances.html +++ b/v2.3/Data.Fin.Instances.html @@ -10,9 +10,9 @@ module Data.Fin.Instances where open import Data.Fin.Base using (Fin) -open import Data.Fin.Properties using (≡-isDecEquivalence; ≤-isDecTotalOrder) +open import Data.Fin.Properties using (≡-isDecEquivalence; ≤-isDecTotalOrder) instance - Fin-≡-isDecEquivalence = ≡-isDecEquivalence - Fin-≤-isDecTotalOrder = ≤-isDecTotalOrder + Fin-≡-isDecEquivalence = ≡-isDecEquivalence + Fin-≤-isDecTotalOrder = ≤-isDecTotalOrder \ No newline at end of file diff --git a/v2.3/Data.Fin.Literals.html b/v2.3/Data.Fin.Literals.html index e20382cd31..b8fb9d2897 100644 --- a/v2.3/Data.Fin.Literals.html +++ b/v2.3/Data.Fin.Literals.html @@ -10,13 +10,13 @@ module Data.Fin.Literals where open import Agda.Builtin.FromNat using (Number) -open import Data.Nat using (suc; _≤?_) +open import Data.Nat using (suc; _≤?_) open import Data.Fin using (Fin ; #_) open import Relation.Nullary.Decidable using (True) number : n Number (Fin n) number n = record - { Constraint = λ m True (suc m ≤? n) + { Constraint = λ m True (suc m ≤? n) ; fromNat = λ m {{pr}} (# m) {n} {pr} } \ No newline at end of file diff --git a/v2.3/Data.Fin.Permutation.Components.html b/v2.3/Data.Fin.Permutation.Components.html index 89e8a5ca2f..8b93ec6906 100644 --- a/v2.3/Data.Fin.Permutation.Components.html +++ b/v2.3/Data.Fin.Permutation.Components.html @@ -12,85 +12,79 @@ open import Data.Bool.Base using (Bool; true; false) open import Data.Fin.Base using (Fin; suc; opposite; toℕ) open import Data.Fin.Properties - using (_≟_; ≟-≡; ≟-≡-refl - ; opposite-prop; opposite-involutive; opposite-suc) -open import Relation.Nullary.Decidable.Core using (does; yes; no) -open import Relation.Binary.PropositionalEquality.Core - using (_≡_; refl; sym) - ------------------------------------------------------------------------- --- Functions ------------------------------------------------------------------------- - --- 'transpose i j' swaps the places of 'i' and 'j'. - -transpose : {n} Fin n Fin n Fin n Fin n -transpose i j k with does (k i) -... | true = j -... | false with does (k j) -... | true = i -... | false = k - ------------------------------------------------------------------------- --- Properties ------------------------------------------------------------------------- - -transpose[i,i,j]≡j : {n} (i j : Fin n) transpose i i j j -transpose[i,i,j]≡j i j with j i in j≟i -... | yes j≡i = sym j≡i -... | no _ rewrite j≟i = refl - -transpose[i,j,j]≡i : {n} (i j : Fin n) transpose i j j i -transpose[i,j,j]≡i i j with j i -... | yes j≡i = j≡i -... | no _ rewrite ≟-≡-refl j = refl - -transpose[i,j,i]≡j : {n} (i j : Fin n) transpose i j i j -transpose[i,j,i]≡j i j rewrite ≟-≡-refl i = refl - -transpose-transpose : {n} {i j k l : Fin n} - transpose i j k l transpose j i l k -transpose-transpose {n} {i} {j} {k} {l} eq with k i in k≟i -... | yes k≡i rewrite ≟-≡ (sym eq) = sym k≡i -... | no k≢i with k j in k≟j -... | yes k≡j rewrite eq | transpose[i,j,j]≡i j l = sym k≡j -... | no k≢j rewrite eq | k≟j | k≟i = refl - -transpose-inverse : {n} (i j : Fin n) {k} - transpose i j (transpose j i k) k -transpose-inverse i j = transpose-transpose refl - - ------------------------------------------------------------------------- --- DEPRECATED NAMES ------------------------------------------------------------------------- --- Please use the new names as continuing support for the old names is --- not guaranteed. - --- Version 2.0 - -reverse = opposite -{-# WARNING_ON_USAGE reverse -"Warning: reverse was deprecated in v2.0. + using (_≟_; opposite-prop; opposite-involutive; opposite-suc) +open import Data.Nat.Base as using (zero; suc; _∸_) +open import Data.Product.Base using (proj₂) +open import Function.Base using (_∘_) +open import Relation.Nullary.Reflects using (invert) +open import Relation.Nullary using (does; _because_; yes; no) +open import Relation.Nullary.Decidable using (dec-true; dec-false) +open import Relation.Binary.PropositionalEquality.Core + using (_≡_; refl; sym; trans) +open import Relation.Binary.PropositionalEquality.Properties + using (module ≡-Reasoning) +open import Algebra.Definitions using (Involutive) +open ≡-Reasoning + +------------------------------------------------------------------------ +-- Functions +------------------------------------------------------------------------ + +-- 'tranpose i j' swaps the places of 'i' and 'j'. + +transpose : {n} Fin n Fin n Fin n Fin n +transpose i j k with does (k i) +... | true = j +... | false with does (k j) +... | true = i +... | false = k + +------------------------------------------------------------------------ +-- Properties +------------------------------------------------------------------------ + +transpose-inverse : {n} (i j : Fin n) {k} + transpose i j (transpose j i k) k +transpose-inverse i j {k} with k j +... | true because [k≡j] rewrite dec-true (i i) refl = sym (invert [k≡j]) +... | false because [k≢j] with k i +... | true because [k≡i] + rewrite dec-false (j i) (invert [k≢j] trans (invert [k≡i]) sym) + | dec-true (j j) refl + = sym (invert [k≡i]) +... | false because [k≢i] rewrite dec-false (k i) (invert [k≢i]) + | dec-false (k j) (invert [k≢j]) = refl + +------------------------------------------------------------------------ +-- DEPRECATED NAMES +------------------------------------------------------------------------ +-- Please use the new names as continuing support for the old names is +-- not guaranteed. + +-- Version 2.0 + +reverse = opposite +{-# WARNING_ON_USAGE reverse +"Warning: reverse was deprecated in v2.0. Please use opposite from Data.Fin.Base instead." -#-} +#-} -reverse-prop = opposite-prop -{-# WARNING_ON_USAGE reverse-prop -"Warning: reverse-prop was deprecated in v2.0. +reverse-prop = opposite-prop +{-# WARNING_ON_USAGE reverse-prop +"Warning: reverse-prop was deprecated in v2.0. Please use opposite-prop from Data.Fin.Properties instead." -#-} +#-} -reverse-involutive = opposite-involutive -{-# WARNING_ON_USAGE reverse-involutive -"Warning: reverse-involutive was deprecated in v2.0. +reverse-involutive = opposite-involutive +{-# WARNING_ON_USAGE reverse-involutive +"Warning: reverse-involutive was deprecated in v2.0. Please use opposite-involutive from Data.Fin.Properties instead." -#-} +#-} -reverse-suc : {n} {i : Fin n} toℕ (opposite (suc i)) toℕ (opposite i) -reverse-suc {i = i} = opposite-suc i -{-# WARNING_ON_USAGE reverse-suc -"Warning: reverse-suc was deprecated in v2.0. +reverse-suc : {n} {i : Fin n} toℕ (opposite (suc i)) toℕ (opposite i) +reverse-suc {i = i} = opposite-suc i +{-# WARNING_ON_USAGE reverse-suc +"Warning: reverse-suc was deprecated in v2.0. Please use opposite-suc from Data.Fin.Properties instead." -#-} +#-} \ No newline at end of file diff --git a/v2.3/Data.Fin.Permutation.Transposition.List.html b/v2.3/Data.Fin.Permutation.Transposition.List.html index 50160cc34c..fec8ac2e24 100644 --- a/v2.3/Data.Fin.Permutation.Transposition.List.html +++ b/v2.3/Data.Fin.Permutation.Transposition.List.html @@ -11,7 +11,7 @@ open import Data.Fin.Base using (Fin; suc) open import Data.Fin.Patterns using (0F) -open import Data.Fin.Permutation as P hiding (lift₀) +open import Data.Fin.Permutation as P hiding (lift₀) import Data.Fin.Permutation.Components as PC open import Data.List.Base using (List; []; _∷_; map) open import Data.Nat.Base using (; suc; zero) @@ -43,33 +43,33 @@ lift₀ : TranspositionList n TranspositionList (suc n) lift₀ xs = map (i , j) (suc i , suc j)) xs -eval : TranspositionList n Permutation′ n -eval [] = id -eval ((i , j) xs) = transpose i j ∘ₚ eval xs +eval : TranspositionList n Permutation′ n +eval [] = id +eval ((i , j) xs) = transpose i j ∘ₚ eval xs -decompose : Permutation′ n TranspositionList n +decompose : Permutation′ n TranspositionList n decompose {zero} π = [] -decompose {suc n} π = (π ⟨$⟩ˡ 0F , 0F) lift₀ (decompose (remove 0F ((transpose 0F (π ⟨$⟩ˡ 0F)) ∘ₚ π))) +decompose {suc n} π = (π ⟨$⟩ˡ 0F , 0F) lift₀ (decompose (remove 0F ((transpose 0F (π ⟨$⟩ˡ 0F)) ∘ₚ π))) ------------------------------------------------------------------------ -- Properties -eval-lift : (xs : TranspositionList n) eval (lift₀ xs) P.lift₀ (eval xs) -eval-lift [] = sym lift₀-id +eval-lift : (xs : TranspositionList n) eval (lift₀ xs) P.lift₀ (eval xs) +eval-lift [] = sym lift₀-id eval-lift ((i , j) xs) k = begin - transpose (suc i) (suc j) ∘ₚ eval (lift₀ xs) ⟨$⟩ʳ k ≡⟨ cong (eval (lift₀ xs) ⟨$⟩ʳ_) (lift₀-transpose i j k) - P.lift₀ (transpose i j) ∘ₚ eval (lift₀ xs) ⟨$⟩ʳ k ≡⟨ eval-lift xs (P.lift₀ (transpose i j) ⟨$⟩ʳ k) - P.lift₀ (eval xs) ⟨$⟩ʳ (P.lift₀ (transpose i j) ⟨$⟩ʳ k) ≡⟨ lift₀-comp (transpose i j) (eval xs) k - P.lift₀ (transpose i j ∘ₚ eval xs) ⟨$⟩ʳ k + transpose (suc i) (suc j) ∘ₚ eval (lift₀ xs) ⟨$⟩ʳ k ≡⟨ cong (eval (lift₀ xs) ⟨$⟩ʳ_) (lift₀-transpose i j k) + P.lift₀ (transpose i j) ∘ₚ eval (lift₀ xs) ⟨$⟩ʳ k ≡⟨ eval-lift xs (P.lift₀ (transpose i j) ⟨$⟩ʳ k) + P.lift₀ (eval xs) ⟨$⟩ʳ (P.lift₀ (transpose i j) ⟨$⟩ʳ k) ≡⟨ lift₀-comp (transpose i j) (eval xs) k + P.lift₀ (transpose i j ∘ₚ eval xs) ⟨$⟩ʳ k -eval-decompose : (π : Permutation′ n) eval (decompose π) π +eval-decompose : (π : Permutation′ n) eval (decompose π) π eval-decompose {suc n} π i = begin - tπ0 ∘ₚ eval (lift₀ (decompose (remove 0F (t0π ∘ₚ π)))) ⟨$⟩ʳ i ≡⟨ eval-lift (decompose (remove 0F (t0π ∘ₚ π))) (tπ0 ⟨$⟩ʳ i) - tπ0 ∘ₚ P.lift₀ (eval (decompose (remove 0F (t0π ∘ₚ π)))) ⟨$⟩ʳ i ≡⟨ lift₀-cong _ _ (eval-decompose _) (tπ0 ⟨$⟩ʳ i) - tπ0 ∘ₚ P.lift₀ (remove 0F (t0π ∘ₚ π)) ⟨$⟩ʳ i ≡⟨ lift₀-remove (t0π ∘ₚ π) (inverseʳ π) (tπ0 ⟨$⟩ʳ i) - tπ0 ∘ₚ t0π ∘ₚ π ⟨$⟩ʳ i ≡⟨ cong (π ⟨$⟩ʳ_) (PC.transpose-inverse 0F (π ⟨$⟩ˡ 0F)) - π ⟨$⟩ʳ i + tπ0 ∘ₚ eval (lift₀ (decompose (remove 0F (t0π ∘ₚ π)))) ⟨$⟩ʳ i ≡⟨ eval-lift (decompose (remove 0F (t0π ∘ₚ π))) (tπ0 ⟨$⟩ʳ i) + tπ0 ∘ₚ P.lift₀ (eval (decompose (remove 0F (t0π ∘ₚ π)))) ⟨$⟩ʳ i ≡⟨ lift₀-cong _ _ (eval-decompose _) (tπ0 ⟨$⟩ʳ i) + tπ0 ∘ₚ P.lift₀ (remove 0F (t0π ∘ₚ π)) ⟨$⟩ʳ i ≡⟨ lift₀-remove (t0π ∘ₚ π) (inverseʳ π) (tπ0 ⟨$⟩ʳ i) + tπ0 ∘ₚ t0π ∘ₚ π ⟨$⟩ʳ i ≡⟨ cong (π ⟨$⟩ʳ_) (PC.transpose-inverse 0F (π ⟨$⟩ˡ 0F)) + π ⟨$⟩ʳ i where - tπ0 = transpose (π ⟨$⟩ˡ 0F) 0F - t0π = transpose 0F (π ⟨$⟩ˡ 0F) + tπ0 = transpose (π ⟨$⟩ˡ 0F) 0F + t0π = transpose 0F (π ⟨$⟩ˡ 0F) \ No newline at end of file diff --git a/v2.3/Data.Fin.Permutation.html b/v2.3/Data.Fin.Permutation.html index c4f59bd799..02a53df1e7 100644 --- a/v2.3/Data.Fin.Permutation.html +++ b/v2.3/Data.Fin.Permutation.html @@ -12,337 +12,341 @@ open import Data.Bool.Base using (true; false) open import Data.Fin.Base using (Fin; suc; cast; opposite; punchIn; punchOut) open import Data.Fin.Patterns using (0F; 1F) -open import Data.Fin.Properties - using (¬Fin0; _≟_; ≟-≡-refl; ≟-≢ - ; cast-involutive; opposite-involutive - ; punchInᵢ≢i; punchOut-punchIn; punchIn-punchOut - ; punchOut-cong; punchOut-cong′) -import Data.Fin.Permutation.Components as PC -open import Data.Nat.Base using (; suc; zero; 2+) -open import Data.Product.Base using (_,_; proj₂) -open import Function.Bundles using (_↔_; Injection; Inverse; mk↔ₛ′) -open import Function.Construct.Composition using (_↔-∘_) -open import Function.Construct.Identity using (↔-id) -open import Function.Construct.Symmetry using (↔-sym) -open import Function.Definitions using (StrictlyInverseˡ; StrictlyInverseʳ) -open import Function.Properties.Inverse using (↔⇒↣) -open import Function.Base using (_∘_; _∘′_) -open import Level using (0ℓ) -open import Relation.Binary.Core using (Rel) -open import Relation.Nullary.Decidable.Core using (does; yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) -open import Relation.Binary.PropositionalEquality.Core - using (_≡_; _≢_; refl; sym; trans; subst; cong; cong₂) -open import Relation.Binary.PropositionalEquality.Properties - using (module ≡-Reasoning) -open ≡-Reasoning - -private - variable - m n o : - ------------------------------------------------------------------------- --- Types - --- A bijection between finite sets of potentially different sizes. --- There only exist inhabitants of this type if in fact m = n, however --- it is often easier to prove the existence of a bijection without --- first proving that the sets have the same size. Indeed such a --- bijection is a useful way to prove that the sets are in fact the same --- size. See '↔-≡' below. - -Permutation : Set -Permutation m n = Fin m Fin n - -Permutation′ : Set -Permutation′ n = Permutation n n - ------------------------------------------------------------------------- --- Helper functions - -permutation : (f : Fin m Fin n) - (g : Fin n Fin m) - StrictlyInverseˡ _≡_ f g - StrictlyInverseʳ _≡_ f g - Permutation m n -permutation = mk↔ₛ′ - -infixl 5 _⟨$⟩ʳ_ _⟨$⟩ˡ_ - -_⟨$⟩ʳ_ : Permutation m n Fin m Fin n -_⟨$⟩ʳ_ = Inverse.to - -_⟨$⟩ˡ_ : Permutation m n Fin n Fin m -_⟨$⟩ˡ_ = Inverse.from - -inverseˡ : (π : Permutation m n) {i} π ⟨$⟩ˡ (π ⟨$⟩ʳ i) i -inverseˡ π = Inverse.inverseʳ π refl - -inverseʳ : (π : Permutation m n) {i} π ⟨$⟩ʳ (π ⟨$⟩ˡ i) i -inverseʳ π = Inverse.inverseˡ π refl - ------------------------------------------------------------------------- --- Equality over permutations - -infix 6 _≈_ - -_≈_ : Rel (Permutation m n) 0ℓ -π ρ = i π ⟨$⟩ʳ i ρ ⟨$⟩ʳ i - ------------------------------------------------------------------------- --- Permutation properties - -id : Permutation n n -id = ↔-id _ - -flip : Permutation m n Permutation n m -flip = ↔-sym - -infixr 9 _∘ₚ_ - -_∘ₚ_ : Permutation m n Permutation n o Permutation m o -π₁ ∘ₚ π₂ = π₂ ↔-∘ π₁ - ------------------------------------------------------------------------- --- Non-trivial identity - -cast-id : .(m n) Permutation m n -cast-id m≡n = permutation - (cast m≡n) - (cast (sym m≡n)) - (cast-involutive m≡n (sym m≡n)) - (cast-involutive (sym m≡n) m≡n) - ------------------------------------------------------------------------- --- Transposition - --- Transposes two elements in the permutation, keeping the remainder --- of the permutation the same -transpose : Fin n Fin n Permutation n n -transpose i j = permutation - (PC.transpose i j) - (PC.transpose j i) - _ PC.transpose-inverse _ _) - _ PC.transpose-inverse _ _) - ------------------------------------------------------------------------- --- Reverse - --- Reverses a permutation -reverse : Permutation n n -reverse = permutation - opposite - opposite - opposite-involutive - opposite-involutive - ------------------------------------------------------------------------- --- Element removal --- --- `remove k [0 ↦ i₀, …, k ↦ iₖ, …, n ↦ iₙ]` yields --- --- [0 ↦ i₀, …, k-1 ↦ iₖ₋₁, k ↦ iₖ₊₁, k+1 ↦ iₖ₊₂, …, n-1 ↦ iₙ] - -remove : Fin (suc m) Permutation (suc m) (suc n) Permutation m n -remove {m} {n} i π = permutation to from inverseˡ′ inverseʳ′ - where - πʳ = π ⟨$⟩ʳ_ - πˡ = π ⟨$⟩ˡ_ - - permute-≢ : {i j} i j πʳ i πʳ j - permute-≢ p = p Injection.injective (↔⇒↣ π) - - to-punchOut : {j : Fin m} πʳ i πʳ (punchIn i j) - to-punchOut = permute-≢ (punchInᵢ≢i _ _ sym) - - from-punchOut : {j : Fin n} i πˡ (punchIn (πʳ i) j) - from-punchOut {j} p = punchInᵢ≢i (πʳ i) j (sym (begin - πʳ i ≡⟨ cong πʳ p - πʳ (πˡ (punchIn (πʳ i) j)) ≡⟨ inverseʳ π - punchIn (πʳ i) j )) - - to : Fin m Fin n - to j = punchOut (to-punchOut {j}) - - from : Fin n Fin m - from j = punchOut {j = πˡ (punchIn (πʳ i) j)} from-punchOut - - inverseʳ′ : StrictlyInverseʳ _≡_ to from - inverseʳ′ j = begin - from (to j) ≡⟨⟩ - punchOut {i = i} {πˡ (punchIn (πʳ i) (punchOut to-punchOut))} _ ≡⟨ punchOut-cong′ i (cong πˡ (punchIn-punchOut _)) - punchOut {i = i} {πˡ (πʳ (punchIn i j))} _ ≡⟨ punchOut-cong i (inverseˡ π) - punchOut {i = i} {punchIn i j} _ ≡⟨ punchOut-punchIn i - j - - inverseˡ′ : StrictlyInverseˡ _≡_ to from - inverseˡ′ j = begin - to (from j) ≡⟨⟩ - punchOut {i = πʳ i} {πʳ (punchIn i (punchOut from-punchOut))} _ ≡⟨ punchOut-cong′ (πʳ i) (cong πʳ (punchIn-punchOut _)) - punchOut {i = πʳ i} {πʳ (πˡ (punchIn (πʳ i) j))} _ ≡⟨ punchOut-cong (πʳ i) (inverseʳ π) - punchOut {i = πʳ i} {punchIn (πʳ i) j} _ ≡⟨ punchOut-punchIn (πʳ i) - j - ------------------------------------------------------------------------- --- Lifting - --- Takes a permutation m → n and creates a permutation (suc m) → (suc n) --- by mapping 0 to 0 and applying the input permutation to everything else --- --- Note: should be refactored as a special-case when we add the --- concatenation of two permutations -lift₀ : Permutation m n Permutation (suc m) (suc n) -lift₀ {m} {n} π = permutation to from inverseˡ′ inverseʳ′ - where - to : Fin (suc m) Fin (suc n) - to 0F = 0F - to (suc i) = suc (π ⟨$⟩ʳ i) - - from : Fin (suc n) Fin (suc m) - from 0F = 0F - from (suc i) = suc (π ⟨$⟩ˡ i) - - inverseʳ′ : StrictlyInverseʳ _≡_ to from - inverseʳ′ 0F = refl - inverseʳ′ (suc j) = cong suc (inverseˡ π) - - inverseˡ′ : StrictlyInverseˡ _≡_ to from - inverseˡ′ 0F = refl - inverseˡ′ (suc j) = cong suc (inverseʳ π) - ------------------------------------------------------------------------- --- Insertion - --- insert i j π is the permutation that maps i to j and otherwise looks like π --- it's roughly an inverse of remove -insert : {m n} Fin (suc m) Fin (suc n) Permutation m n Permutation (suc m) (suc n) -insert {m} {n} i j π = permutation to from inverseˡ′ inverseʳ′ - where - to : Fin (suc m) Fin (suc n) - to k with i k - ... | yes i≡k = j - ... | no i≢k = punchIn j (π ⟨$⟩ʳ punchOut i≢k) - - from : Fin (suc n) Fin (suc m) - from k with j k - ... | yes j≡k = i - ... | no j≢k = punchIn i (π ⟨$⟩ˡ punchOut j≢k) - - inverseʳ′ : StrictlyInverseʳ _≡_ to from - inverseʳ′ k with i k - ... | yes i≡k rewrite ≟-≡-refl j = i≡k - ... | no i≢k - with j≢punchInⱼπʳpunchOuti≢kpunchInᵢ≢i j (π ⟨$⟩ʳ punchOut i≢k) sym - rewrite ≟-≢ j≢punchInⱼπʳpunchOuti≢k - = begin - punchIn i (π ⟨$⟩ˡ punchOut j≢punchInⱼπʳpunchOuti≢k) ≡⟨ cong l punchIn i (π ⟨$⟩ˡ l)) (punchOut-cong j refl) - punchIn i (π ⟨$⟩ˡ punchOut (punchInᵢ≢i j (π ⟨$⟩ʳ punchOut i≢k) sym)) ≡⟨ cong l punchIn i (π ⟨$⟩ˡ l)) (punchOut-punchIn j) - punchIn i (π ⟨$⟩ˡ (π ⟨$⟩ʳ punchOut i≢k)) ≡⟨ cong (punchIn i) (inverseˡ π) - punchIn i (punchOut i≢k) ≡⟨ punchIn-punchOut i≢k - k - - inverseˡ′ : StrictlyInverseˡ _≡_ to from - inverseˡ′ k with j k - ... | yes j≡k rewrite ≟-≡-refl i = j≡k - ... | no j≢k - with i≢punchInᵢπˡpunchOutj≢kpunchInᵢ≢i i (π ⟨$⟩ˡ punchOut j≢k) sym - rewrite ≟-≢ i≢punchInᵢπˡpunchOutj≢k - = begin - punchIn j (π ⟨$⟩ʳ punchOut i≢punchInᵢπˡpunchOutj≢k) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-cong i refl) - punchIn j (π ⟨$⟩ʳ punchOut (punchInᵢ≢i i (π ⟨$⟩ˡ punchOut j≢k) sym)) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-punchIn i) - punchIn j (π ⟨$⟩ʳ (π ⟨$⟩ˡ punchOut j≢k)) ≡⟨ cong (punchIn j) (inverseʳ π) - punchIn j (punchOut j≢k) ≡⟨ punchIn-punchOut j≢k - k - ------------------------------------------------------------------------- --- Swapping - --- Takes a permutation m → n and creates a permutation --- suc (suc m) → suc (suc n) by mapping 0 to 1 and 1 to 0 and --- then applying the input permutation to everything else --- --- Note: should be refactored as a special-case when we add the --- concatenation of two permutations -swap : Permutation m n Permutation (2+ m) (2+ n) -swap π = transpose 0F 1F ∘ₚ lift₀ (lift₀ π) - ------------------------------------------------------------------------- --- Other properties - -module _ (π : Permutation (suc m) (suc n)) where - private - πʳ = π ⟨$⟩ʳ_ - πˡ = π ⟨$⟩ˡ_ - - punchIn-permute : i j πʳ (punchIn i j) punchIn (πʳ i) (remove i π ⟨$⟩ʳ j) - punchIn-permute i j = sym (punchIn-punchOut _) - - punchIn-permute′ : i j πʳ (punchIn (πˡ i) j) punchIn i (remove (πˡ i) π ⟨$⟩ʳ j) - punchIn-permute′ i j = begin - πʳ (punchIn (πˡ i) j) ≡⟨ punchIn-permute _ _ - punchIn (πʳ (πˡ i)) (remove (πˡ i) π ⟨$⟩ʳ j) ≡⟨ cong₂ punchIn (inverseʳ π) refl - punchIn i (remove (πˡ i) π ⟨$⟩ʳ j) - - lift₀-remove : πʳ 0F 0F lift₀ (remove 0F π) π - lift₀-remove p 0F = sym p - lift₀-remove p (suc i) = punchOut-zero (πʳ (suc i)) p - where - punchOut-zero : {i} (j : Fin (suc n)) {neq} i 0F suc (punchOut {i = i} {j} neq) j - punchOut-zero 0F {neq} p = contradiction p neq - punchOut-zero (suc j) refl = refl - -↔⇒≡ : Permutation m n m n -↔⇒≡ {zero} {zero} π = refl -↔⇒≡ {zero} {suc n} π = contradiction (π ⟨$⟩ˡ 0F) ¬Fin0 -↔⇒≡ {suc m} {zero} π = contradiction (π ⟨$⟩ʳ 0F) ¬Fin0 -↔⇒≡ {suc m} {suc n} π = cong suc (↔⇒≡ (remove 0F π)) - -fromPermutation : Permutation m n Permutation′ m -fromPermutation π = subst (Permutation _) (sym (↔⇒≡ π)) π - -refute : m n ¬ Permutation m n -refute m≢n π = contradiction (↔⇒≡ π) m≢n - -lift₀-id : (i : Fin (suc n)) lift₀ id ⟨$⟩ʳ i i -lift₀-id 0F = refl -lift₀-id (suc i) = refl - -lift₀-comp : (π : Permutation m n) (ρ : Permutation n o) - lift₀ π ∘ₚ lift₀ ρ lift₀ (π ∘ₚ ρ) -lift₀-comp π ρ 0F = refl -lift₀-comp π ρ (suc i) = refl - -lift₀-cong : (π ρ : Permutation m n) π ρ lift₀ π lift₀ ρ -lift₀-cong π ρ f 0F = refl -lift₀-cong π ρ f (suc i) = cong suc (f i) - -lift₀-transpose : (i j : Fin n) transpose (suc i) (suc j) lift₀ (transpose i j) -lift₀-transpose i j 0F = refl -lift₀-transpose i j (suc k) with does (k i) -... | true = refl -... | false with does (k j) -... | false = refl -... | true = refl - -insert-punchIn : i j (π : Permutation m n) k insert i j π ⟨$⟩ʳ punchIn i k punchIn j (π ⟨$⟩ʳ k) -insert-punchIn i j π k with i punchIn i k -... | yes i≡punchInᵢk = contradiction (sym i≡punchInᵢk) (punchInᵢ≢i i k) -... | no i≢punchInᵢk = begin - punchIn j (π ⟨$⟩ʳ punchOut i≢punchInᵢk) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-cong i refl) - punchIn j (π ⟨$⟩ʳ punchOut (punchInᵢ≢i i k sym)) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-punchIn i) - punchIn j (π ⟨$⟩ʳ k) - -insert-remove : i (π : Permutation (suc m) (suc n)) insert i (π ⟨$⟩ʳ i) (remove i π) π -insert-remove {m = m} {n = n} i π j with i j -... | yes i≡j = cong (π ⟨$⟩ʳ_) i≡j -... | no i≢j = begin - punchIn (π ⟨$⟩ʳ i) (punchOut (punchInᵢ≢i i (punchOut i≢j) sym Injection.injective (↔⇒↣ π))) ≡⟨ punchIn-punchOut _ - π ⟨$⟩ʳ punchIn i (punchOut i≢j) ≡⟨ cong (π ⟨$⟩ʳ_) (punchIn-punchOut i≢j) - π ⟨$⟩ʳ j - -remove-insert : i j (π : Permutation m n) remove i (insert i j π) π -remove-insert i j π k rewrite ≟-≡-refl i = begin - punchOut {i = j} _ ≡⟨ punchOut-cong j (insert-punchIn i j π k) - punchOut {i = j} (punchInᵢ≢i j (π ⟨$⟩ʳ k) sym) ≡⟨ punchOut-punchIn j - π ⟨$⟩ʳ k +open import Data.Fin.Properties using (punchInᵢ≢i; punchOut-punchIn; + punchOut-cong; punchOut-cong′; punchIn-punchOut + ; _≟_; ¬Fin0; cast-involutive; opposite-involutive) +import Data.Fin.Permutation.Components as PC +open import Data.Nat.Base using (; suc; zero; 2+) +open import Data.Product.Base using (_,_; proj₂) +open import Function.Bundles using (_↔_; Injection; Inverse; mk↔ₛ′) +open import Function.Construct.Composition using (_↔-∘_) +open import Function.Construct.Identity using (↔-id) +open import Function.Construct.Symmetry using (↔-sym) +open import Function.Definitions using (StrictlyInverseˡ; StrictlyInverseʳ) +open import Function.Properties.Inverse using (↔⇒↣) +open import Function.Base using (_∘_; _∘′_) +open import Level using (0ℓ) +open import Relation.Binary.Core using (Rel) +open import Relation.Nullary using (does; ¬_; yes; no) +open import Relation.Nullary.Decidable using (dec-yes; dec-no) +open import Relation.Nullary.Negation using (contradiction) +open import Relation.Binary.PropositionalEquality.Core + using (_≡_; _≢_; refl; sym; trans; subst; cong; cong₂) +open import Relation.Binary.PropositionalEquality.Properties + using (module ≡-Reasoning) +open ≡-Reasoning + +private + variable + m n o : + +------------------------------------------------------------------------ +-- Types + +-- A bijection between finite sets of potentially different sizes. +-- There only exist inhabitants of this type if in fact m = n, however +-- it is often easier to prove the existence of a bijection without +-- first proving that the sets have the same size. Indeed such a +-- bijection is a useful way to prove that the sets are in fact the same +-- size. See '↔-≡' below. + +Permutation : Set +Permutation m n = Fin m Fin n + +Permutation′ : Set +Permutation′ n = Permutation n n + +------------------------------------------------------------------------ +-- Helper functions + +permutation : (f : Fin m Fin n) + (g : Fin n Fin m) + StrictlyInverseˡ _≡_ f g + StrictlyInverseʳ _≡_ f g + Permutation m n +permutation = mk↔ₛ′ + +infixl 5 _⟨$⟩ʳ_ _⟨$⟩ˡ_ + +_⟨$⟩ʳ_ : Permutation m n Fin m Fin n +_⟨$⟩ʳ_ = Inverse.to + +_⟨$⟩ˡ_ : Permutation m n Fin n Fin m +_⟨$⟩ˡ_ = Inverse.from + +inverseˡ : (π : Permutation m n) {i} π ⟨$⟩ˡ (π ⟨$⟩ʳ i) i +inverseˡ π = Inverse.inverseʳ π refl + +inverseʳ : (π : Permutation m n) {i} π ⟨$⟩ʳ (π ⟨$⟩ˡ i) i +inverseʳ π = Inverse.inverseˡ π refl + +------------------------------------------------------------------------ +-- Equality over permutations + +infix 6 _≈_ + +_≈_ : Rel (Permutation m n) 0ℓ +π ρ = i π ⟨$⟩ʳ i ρ ⟨$⟩ʳ i + +------------------------------------------------------------------------ +-- Permutation properties + +id : Permutation n n +id = ↔-id _ + +flip : Permutation m n Permutation n m +flip = ↔-sym + +infixr 9 _∘ₚ_ + +_∘ₚ_ : Permutation m n Permutation n o Permutation m o +π₁ ∘ₚ π₂ = π₂ ↔-∘ π₁ + +------------------------------------------------------------------------ +-- Non-trivial identity + +cast-id : .(m n) Permutation m n +cast-id m≡n = permutation + (cast m≡n) + (cast (sym m≡n)) + (cast-involutive m≡n (sym m≡n)) + (cast-involutive (sym m≡n) m≡n) + +------------------------------------------------------------------------ +-- Transposition + +-- Transposes two elements in the permutation, keeping the remainder +-- of the permutation the same +transpose : Fin n Fin n Permutation n n +transpose i j = permutation + (PC.transpose i j) + (PC.transpose j i) + _ PC.transpose-inverse _ _) + _ PC.transpose-inverse _ _) + +------------------------------------------------------------------------ +-- Reverse + +-- Reverses a permutation +reverse : Permutation n n +reverse = permutation + opposite + opposite + opposite-involutive + opposite-involutive + +------------------------------------------------------------------------ +-- Element removal +-- +-- `remove k [0 ↦ i₀, …, k ↦ iₖ, …, n ↦ iₙ]` yields +-- +-- [0 ↦ i₀, …, k-1 ↦ iₖ₋₁, k ↦ iₖ₊₁, k+1 ↦ iₖ₊₂, …, n-1 ↦ iₙ] + +remove : Fin (suc m) Permutation (suc m) (suc n) Permutation m n +remove {m} {n} i π = permutation to from inverseˡ′ inverseʳ′ + where + πʳ = π ⟨$⟩ʳ_ + πˡ = π ⟨$⟩ˡ_ + + permute-≢ : {i j} i j πʳ i πʳ j + permute-≢ p = p Injection.injective (↔⇒↣ π) + + to-punchOut : {j : Fin m} πʳ i πʳ (punchIn i j) + to-punchOut = permute-≢ (punchInᵢ≢i _ _ sym) + + from-punchOut : {j : Fin n} i πˡ (punchIn (πʳ i) j) + from-punchOut {j} p = punchInᵢ≢i (πʳ i) j (sym (begin + πʳ i ≡⟨ cong πʳ p + πʳ (πˡ (punchIn (πʳ i) j)) ≡⟨ inverseʳ π + punchIn (πʳ i) j )) + + to : Fin m Fin n + to j = punchOut (to-punchOut {j}) + + from : Fin n Fin m + from j = punchOut {j = πˡ (punchIn (πʳ i) j)} from-punchOut + + inverseʳ′ : StrictlyInverseʳ _≡_ to from + inverseʳ′ j = begin + from (to j) ≡⟨⟩ + punchOut {i = i} {πˡ (punchIn (πʳ i) (punchOut to-punchOut))} _ ≡⟨ punchOut-cong′ i (cong πˡ (punchIn-punchOut _)) + punchOut {i = i} {πˡ (πʳ (punchIn i j))} _ ≡⟨ punchOut-cong i (inverseˡ π) + punchOut {i = i} {punchIn i j} _ ≡⟨ punchOut-punchIn i + j + + inverseˡ′ : StrictlyInverseˡ _≡_ to from + inverseˡ′ j = begin + to (from j) ≡⟨⟩ + punchOut {i = πʳ i} {πʳ (punchIn i (punchOut from-punchOut))} _ ≡⟨ punchOut-cong′ (πʳ i) (cong πʳ (punchIn-punchOut _)) + punchOut {i = πʳ i} {πʳ (πˡ (punchIn (πʳ i) j))} _ ≡⟨ punchOut-cong (πʳ i) (inverseʳ π) + punchOut {i = πʳ i} {punchIn (πʳ i) j} _ ≡⟨ punchOut-punchIn (πʳ i) + j + +------------------------------------------------------------------------ +-- Lifting + +-- Takes a permutation m → n and creates a permutation (suc m) → (suc n) +-- by mapping 0 to 0 and applying the input permutation to everything else +-- +-- Note: should be refactored as a special-case when we add the +-- concatenation of two permutations +lift₀ : Permutation m n Permutation (suc m) (suc n) +lift₀ {m} {n} π = permutation to from inverseˡ′ inverseʳ′ + where + to : Fin (suc m) Fin (suc n) + to 0F = 0F + to (suc i) = suc (π ⟨$⟩ʳ i) + + from : Fin (suc n) Fin (suc m) + from 0F = 0F + from (suc i) = suc (π ⟨$⟩ˡ i) + + inverseʳ′ : StrictlyInverseʳ _≡_ to from + inverseʳ′ 0F = refl + inverseʳ′ (suc j) = cong suc (inverseˡ π) + + inverseˡ′ : StrictlyInverseˡ _≡_ to from + inverseˡ′ 0F = refl + inverseˡ′ (suc j) = cong suc (inverseʳ π) + +------------------------------------------------------------------------ +-- Insertion + +-- insert i j π is the permutation that maps i to j and otherwise looks like π +-- it's roughly an inverse of remove +insert : {m n} Fin (suc m) Fin (suc n) Permutation m n Permutation (suc m) (suc n) +insert {m} {n} i j π = permutation to from inverseˡ′ inverseʳ′ + where + to : Fin (suc m) Fin (suc n) + to k with i k + ... | yes i≡k = j + ... | no i≢k = punchIn j (π ⟨$⟩ʳ punchOut i≢k) + + from : Fin (suc n) Fin (suc m) + from k with j k + ... | yes j≡k = i + ... | no j≢k = punchIn i (π ⟨$⟩ˡ punchOut j≢k) + + inverseʳ′ : StrictlyInverseʳ _≡_ to from + inverseʳ′ k with i k + ... | yes i≡k rewrite proj₂ (dec-yes (j j) refl) = i≡k + ... | no i≢k + with j≢punchInⱼπʳpunchOuti≢kpunchInᵢ≢i j (π ⟨$⟩ʳ punchOut i≢k) sym + rewrite dec-no (j punchIn j (π ⟨$⟩ʳ punchOut i≢k)) j≢punchInⱼπʳpunchOuti≢k + = begin + punchIn i (π ⟨$⟩ˡ punchOut j≢punchInⱼπʳpunchOuti≢k) ≡⟨ cong l punchIn i (π ⟨$⟩ˡ l)) (punchOut-cong j refl) + punchIn i (π ⟨$⟩ˡ punchOut (punchInᵢ≢i j (π ⟨$⟩ʳ punchOut i≢k) sym)) ≡⟨ cong l punchIn i (π ⟨$⟩ˡ l)) (punchOut-punchIn j) + punchIn i (π ⟨$⟩ˡ (π ⟨$⟩ʳ punchOut i≢k)) ≡⟨ cong (punchIn i) (inverseˡ π) + punchIn i (punchOut i≢k) ≡⟨ punchIn-punchOut i≢k + k + + inverseˡ′ : StrictlyInverseˡ _≡_ to from + inverseˡ′ k with j k + ... | yes j≡k rewrite proj₂ (dec-yes (i i) refl) = j≡k + ... | no j≢k + with i≢punchInᵢπˡpunchOutj≢kpunchInᵢ≢i i (π ⟨$⟩ˡ punchOut j≢k) sym + rewrite dec-no (i punchIn i (π ⟨$⟩ˡ punchOut j≢k)) i≢punchInᵢπˡpunchOutj≢k + = begin + punchIn j (π ⟨$⟩ʳ punchOut i≢punchInᵢπˡpunchOutj≢k) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-cong i refl) + punchIn j (π ⟨$⟩ʳ punchOut (punchInᵢ≢i i (π ⟨$⟩ˡ punchOut j≢k) sym)) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-punchIn i) + punchIn j (π ⟨$⟩ʳ (π ⟨$⟩ˡ punchOut j≢k)) ≡⟨ cong (punchIn j) (inverseʳ π) + punchIn j (punchOut j≢k) ≡⟨ punchIn-punchOut j≢k + k + +------------------------------------------------------------------------ +-- Swapping + +-- Takes a permutation m → n and creates a permutation +-- suc (suc m) → suc (suc n) by mapping 0 to 1 and 1 to 0 and +-- then applying the input permutation to everything else +-- +-- Note: should be refactored as a special-case when we add the +-- concatenation of two permutations +swap : Permutation m n Permutation (2+ m) (2+ n) +swap π = transpose 0F 1F ∘ₚ lift₀ (lift₀ π) + +------------------------------------------------------------------------ +-- Other properties + +module _ (π : Permutation (suc m) (suc n)) where + private + πʳ = π ⟨$⟩ʳ_ + πˡ = π ⟨$⟩ˡ_ + + punchIn-permute : i j πʳ (punchIn i j) punchIn (πʳ i) (remove i π ⟨$⟩ʳ j) + punchIn-permute i j = sym (punchIn-punchOut _) + + punchIn-permute′ : i j πʳ (punchIn (πˡ i) j) punchIn i (remove (πˡ i) π ⟨$⟩ʳ j) + punchIn-permute′ i j = begin + πʳ (punchIn (πˡ i) j) ≡⟨ punchIn-permute _ _ + punchIn (πʳ (πˡ i)) (remove (πˡ i) π ⟨$⟩ʳ j) ≡⟨ cong₂ punchIn (inverseʳ π) refl + punchIn i (remove (πˡ i) π ⟨$⟩ʳ j) + + lift₀-remove : πʳ 0F 0F lift₀ (remove 0F π) π + lift₀-remove p 0F = sym p + lift₀-remove p (suc i) = punchOut-zero (πʳ (suc i)) p + where + punchOut-zero : {i} (j : Fin (suc n)) {neq} i 0F suc (punchOut {i = i} {j} neq) j + punchOut-zero 0F {neq} p = contradiction p neq + punchOut-zero (suc j) refl = refl + +↔⇒≡ : Permutation m n m n +↔⇒≡ {zero} {zero} π = refl +↔⇒≡ {zero} {suc n} π = contradiction (π ⟨$⟩ˡ 0F) ¬Fin0 +↔⇒≡ {suc m} {zero} π = contradiction (π ⟨$⟩ʳ 0F) ¬Fin0 +↔⇒≡ {suc m} {suc n} π = cong suc (↔⇒≡ (remove 0F π)) + +fromPermutation : Permutation m n Permutation′ m +fromPermutation π = subst (Permutation _) (sym (↔⇒≡ π)) π + +refute : m n ¬ Permutation m n +refute m≢n π = contradiction (↔⇒≡ π) m≢n + +lift₀-id : (i : Fin (suc n)) lift₀ id ⟨$⟩ʳ i i +lift₀-id 0F = refl +lift₀-id (suc i) = refl + +lift₀-comp : (π : Permutation m n) (ρ : Permutation n o) + lift₀ π ∘ₚ lift₀ ρ lift₀ (π ∘ₚ ρ) +lift₀-comp π ρ 0F = refl +lift₀-comp π ρ (suc i) = refl + +lift₀-cong : (π ρ : Permutation m n) π ρ lift₀ π lift₀ ρ +lift₀-cong π ρ f 0F = refl +lift₀-cong π ρ f (suc i) = cong suc (f i) + +lift₀-transpose : (i j : Fin n) transpose (suc i) (suc j) lift₀ (transpose i j) +lift₀-transpose i j 0F = refl +lift₀-transpose i j (suc k) with does (k i) +... | true = refl +... | false with does (k j) +... | false = refl +... | true = refl + +insert-punchIn : i j (π : Permutation m n) k insert i j π ⟨$⟩ʳ punchIn i k punchIn j (π ⟨$⟩ʳ k) +insert-punchIn i j π k with i punchIn i k +... | yes i≡punchInᵢk = contradiction (sym i≡punchInᵢk) (punchInᵢ≢i i k) +... | no i≢punchInᵢk = begin + punchIn j (π ⟨$⟩ʳ punchOut i≢punchInᵢk) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-cong i refl) + punchIn j (π ⟨$⟩ʳ punchOut (punchInᵢ≢i i k sym)) ≡⟨ cong l punchIn j (π ⟨$⟩ʳ l)) (punchOut-punchIn i) + punchIn j (π ⟨$⟩ʳ k) + +insert-remove : i (π : Permutation (suc m) (suc n)) insert i (π ⟨$⟩ʳ i) (remove i π) π +insert-remove {m = m} {n = n} i π j with i j +... | yes i≡j = cong (π ⟨$⟩ʳ_) i≡j +... | no i≢j = begin + punchIn (π ⟨$⟩ʳ i) (punchOut (punchInᵢ≢i i (punchOut i≢j) sym Injection.injective (↔⇒↣ π))) ≡⟨ punchIn-punchOut _ + π ⟨$⟩ʳ punchIn i (punchOut i≢j) ≡⟨ cong (π ⟨$⟩ʳ_) (punchIn-punchOut i≢j) + π ⟨$⟩ʳ j + +remove-insert : i j (π : Permutation m n) remove i (insert i j π) π +remove-insert i j π k with i i +... | no i≢i = contradiction refl i≢i +... | yes _ = begin + punchOut {i = j} _ + ≡⟨ punchOut-cong j (insert-punchIn i j π k) + punchOut {i = j} (punchInᵢ≢i j (π ⟨$⟩ʳ k) sym) + ≡⟨ punchOut-punchIn j + π ⟨$⟩ʳ k + \ No newline at end of file diff --git a/v2.3/Data.Fin.Properties.html b/v2.3/Data.Fin.Properties.html index 3d87918620..7a799d330a 100644 --- a/v2.3/Data.Fin.Properties.html +++ b/v2.3/Data.Fin.Properties.html @@ -12,1241 +12,1252 @@ module Data.Fin.Properties where open import Axiom.Extensionality.Propositional -open import Axiom.UniquenessOfIdentityProofs using (module Decidable⇒UIP) -open import Algebra.Definitions using (Involutive) -open import Effect.Applicative using (RawApplicative) -open import Effect.Functor using (RawFunctor) -open import Data.Bool.Base using (Bool; true; false; not; _∧_; _∨_) -open import Data.Empty using (; ⊥-elim) -open import Data.Fin.Base -open import Data.Fin.Patterns -open import Data.Nat.Base as - using (; zero; suc; s≤s; z≤n; z<s; s<s; s<s⁻¹; _∸_; _^_) -import Data.Nat.Properties as -open import Data.Unit.Base using (; tt) -open import Data.Product.Base as Product - using (; ∃₂; _×_; _,_; map; proj₁; proj₂; uncurry; <_,_>) -open import Data.Product.Properties using (,-injective) -open import Data.Product.Algebra using (×-cong) -open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂; [_,_]; [_,_]′) -open import Data.Sum.Properties using ([,]-map; [,]-∘) -open import Function.Base using (_∘_; id; _$_; flip) -open import Function.Bundles using (Injection; _↣_; _⇔_; _↔_; mk⇔; mk↔ₛ′) -open import Function.Definitions using (Injective; Surjective) -open import Function.Consequences.Propositional using (contraInjective) -open import Function.Construct.Composition as Comp hiding (injective) -open import Level using (Level) -open import Relation.Binary.Definitions as B hiding (Decidable) -open import Relation.Binary.Core using (_⇒_; _Preserves_⟶_) -open import Relation.Binary.Bundles - using (Preorder; Setoid; DecSetoid; Poset; TotalOrder; DecTotalOrder; StrictPartialOrder; StrictTotalOrder) -open import Relation.Binary.Structures - using (IsDecEquivalence; IsPreorder; IsPartialOrder; IsTotalOrder; IsDecTotalOrder; IsStrictPartialOrder; IsStrictTotalOrder) -open import Relation.Binary.PropositionalEquality.Core as - using (_≡_; _≢_; refl; sym; trans; cong; cong₂; subst; _≗_) -open import Relation.Binary.PropositionalEquality.Properties as - using (module ≡-Reasoning) -open import Relation.Binary.PropositionalEquality as - using (≡-≟-identity; ≢-≟-identity) -open import Relation.Nullary.Decidable as Dec - using (Dec; _because_; yes; no; _×-dec_; _⊎-dec_; map′) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) -open import Relation.Nullary.Reflects using (invert) -open import Relation.Unary as U - using (U; Pred; Decidable; _⊆_; Satisfiable; Universal) -open import Relation.Unary.Properties using (U?) - -private - variable - a : Level - A : Set a - m n o : - i j : Fin n - ------------------------------------------------------------------------- --- Fin ------------------------------------------------------------------------- - -¬Fin0 : ¬ Fin 0 -¬Fin0 () - -nonZeroIndex : Fin n ℕ.NonZero n -nonZeroIndex {n = suc _} _ = _ - ------------------------------------------------------------------------- --- Bundles - -0↔⊥ : Fin 0 -0↔⊥ = mk↔ₛ′ ¬Fin0 ()) ()) ()) - -1↔⊤ : Fin 1 -1↔⊤ = mk↔ₛ′ { 0F tt }) { tt 0F }) { tt refl }) λ { 0F refl } - -2↔Bool : Fin 2 Bool -2↔Bool = mk↔ₛ′ { 0F false; 1F true }) { false 0F ; true 1F }) - { false refl ; true refl }) { 0F refl ; 1F refl }) - ------------------------------------------------------------------------- --- Properties of _≡_ ------------------------------------------------------------------------- - -0≢1+n : zero Fin.suc i -0≢1+n () - -suc-injective : Fin.suc i suc j i j -suc-injective refl = refl - -infix 4 _≟_ - -_≟_ : DecidableEquality (Fin n) -zero zero = yes refl -zero suc y = no λ() -suc x zero = no λ() -suc x suc y = map′ (cong suc) suc-injective (x y) - -≡-irrelevant : Irrelevant {A = Fin n} _≡_ -≡-irrelevant = Decidable⇒UIP.≡-irrelevant _≟_ - -≟-≡ : (eq : i j) (i j) yes eq -≟-≡ = ≡-≟-identity _≟_ - -≟-≡-refl : (i : Fin n) (i i) yes refl -≟-≡-refl _ = ≟-≡ refl - -≟-≢ : (i≢j : i j) (i j) no i≢j -≟-≢ = ≢-≟-identity _≟_ - ------------------------------------------------------------------------- --- Structures - -≡-isDecEquivalence : IsDecEquivalence {A = Fin n} _≡_ -≡-isDecEquivalence = record - { isEquivalence = ≡.isEquivalence - ; _≟_ = _≟_ - } - ------------------------------------------------------------------------- --- Bundles - -≡-preorder : Preorder _ _ _ -≡-preorder n = ≡.preorder (Fin n) - -≡-setoid : Setoid _ _ -≡-setoid n = ≡.setoid (Fin n) - -≡-decSetoid : DecSetoid _ _ -≡-decSetoid n = record - { isDecEquivalence = ≡-isDecEquivalence {n} - } - ------------------------------------------------------------------------- --- toℕ ------------------------------------------------------------------------- - -toℕ-injective : toℕ i toℕ j i j -toℕ-injective {zero} {} {} _ -toℕ-injective {suc n} {zero} {zero} eq = refl -toℕ-injective {suc n} {suc i} {suc j} eq = - cong suc (toℕ-injective (cong ℕ.pred eq)) +open import Algebra.Definitions using (Involutive) +open import Effect.Applicative using (RawApplicative) +open import Effect.Functor using (RawFunctor) +open import Data.Bool.Base using (Bool; true; false; not; _∧_; _∨_) +open import Data.Empty using (; ⊥-elim) +open import Data.Fin.Base +open import Data.Fin.Patterns +open import Data.Nat.Base as + using (; zero; suc; s≤s; z≤n; z<s; s<s; s<s⁻¹; _∸_; _^_) +import Data.Nat.Properties as +open import Data.Unit.Base using (; tt) +open import Data.Product.Base as Product + using (; ∃₂; _×_; _,_; map; proj₁; proj₂; uncurry; <_,_>) +open import Data.Product.Properties using (,-injective) +open import Data.Product.Algebra using (×-cong) +open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂; [_,_]; [_,_]′) +open import Data.Sum.Properties using ([,]-map; [,]-∘) +open import Function.Base using (_∘_; id; _$_; flip) +open import Function.Bundles using (Injection; _↣_; _⇔_; _↔_; mk⇔; mk↔ₛ′) +open import Function.Definitions using (Injective; Surjective) +open import Function.Consequences.Propositional using (contraInjective) +open import Function.Construct.Composition as Comp hiding (injective) +open import Level using (Level) +open import Relation.Binary.Definitions as B hiding (Decidable) +open import Relation.Binary.Core using (_⇒_; _Preserves_⟶_) +open import Relation.Binary.Bundles + using (Preorder; Setoid; DecSetoid; Poset; TotalOrder; DecTotalOrder; StrictPartialOrder; StrictTotalOrder) +open import Relation.Binary.Structures + using (IsDecEquivalence; IsPreorder; IsPartialOrder; IsTotalOrder; IsDecTotalOrder; IsStrictPartialOrder; IsStrictTotalOrder) +open import Relation.Binary.PropositionalEquality.Core as + using (_≡_; _≢_; refl; sym; trans; cong; cong₂; subst; _≗_) +open import Relation.Binary.PropositionalEquality.Properties as + using (module ≡-Reasoning) +open import Relation.Nullary.Decidable as Dec + using (Dec; _because_; yes; no; _×-dec_; _⊎-dec_; map′) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Reflects using (Reflects; invert) +open import Relation.Unary as U + using (U; Pred; Decidable; _⊆_; Satisfiable; Universal) +open import Relation.Unary.Properties using (U?) + +private + variable + a : Level + A : Set a + m n o : + i j : Fin n + +------------------------------------------------------------------------ +-- Fin +------------------------------------------------------------------------ + +¬Fin0 : ¬ Fin 0 +¬Fin0 () + +nonZeroIndex : Fin n ℕ.NonZero n +nonZeroIndex {n = suc _} _ = _ + +------------------------------------------------------------------------ +-- Bundles + +0↔⊥ : Fin 0 +0↔⊥ = mk↔ₛ′ ¬Fin0 ()) ()) ()) + +1↔⊤ : Fin 1 +1↔⊤ = mk↔ₛ′ { 0F tt }) { tt 0F }) { tt refl }) λ { 0F refl } + +2↔Bool : Fin 2 Bool +2↔Bool = mk↔ₛ′ { 0F false; 1F true }) { false 0F ; true 1F }) + { false refl ; true refl }) { 0F refl ; 1F refl }) + +------------------------------------------------------------------------ +-- Properties of _≡_ +------------------------------------------------------------------------ + +0≢1+n : zero Fin.suc i +0≢1+n () + +suc-injective : Fin.suc i suc j i j +suc-injective refl = refl + +infix 4 _≟_ + +_≟_ : DecidableEquality (Fin n) +zero zero = yes refl +zero suc y = no λ() +suc x zero = no λ() +suc x suc y = map′ (cong suc) suc-injective (x y) + +------------------------------------------------------------------------ +-- Structures + +≡-isDecEquivalence : IsDecEquivalence {A = Fin n} _≡_ +≡-isDecEquivalence = record + { isEquivalence = ≡.isEquivalence + ; _≟_ = _≟_ + } + +------------------------------------------------------------------------ +-- Bundles + +≡-preorder : Preorder _ _ _ +≡-preorder n = ≡.preorder (Fin n) + +≡-setoid : Setoid _ _ +≡-setoid n = ≡.setoid (Fin n) + +≡-decSetoid : DecSetoid _ _ +≡-decSetoid n = record + { isDecEquivalence = ≡-isDecEquivalence {n} + } + +------------------------------------------------------------------------ +-- toℕ +------------------------------------------------------------------------ + +toℕ-injective : toℕ i toℕ j i j +toℕ-injective {zero} {} {} _ +toℕ-injective {suc n} {zero} {zero} eq = refl +toℕ-injective {suc n} {suc i} {suc j} eq = + cong suc (toℕ-injective (cong ℕ.pred eq)) + +toℕ-strengthen : (i : Fin n) toℕ (strengthen i) toℕ i +toℕ-strengthen zero = refl +toℕ-strengthen (suc i) = cong suc (toℕ-strengthen i) + +------------------------------------------------------------------------ +-- toℕ-↑ˡ: "i" ↑ˡ n = "i" in Fin (m + n) +------------------------------------------------------------------------ + +toℕ-↑ˡ : (i : Fin m) n toℕ (i ↑ˡ n) toℕ i +toℕ-↑ˡ zero n = refl +toℕ-↑ˡ (suc i) n = cong suc (toℕ-↑ˡ i n) + +↑ˡ-injective : n (i j : Fin m) i ↑ˡ n j ↑ˡ n i j +↑ˡ-injective n zero zero refl = refl +↑ˡ-injective n (suc i) (suc j) eq = + cong suc (↑ˡ-injective n i j (suc-injective eq)) + +------------------------------------------------------------------------ +-- toℕ-↑ʳ: n ↑ʳ "i" = "n + i" in Fin (n + m) +------------------------------------------------------------------------ + +toℕ-↑ʳ : n (i : Fin m) toℕ (n ↑ʳ i) n ℕ.+ toℕ i +toℕ-↑ʳ zero i = refl +toℕ-↑ʳ (suc n) i = cong suc (toℕ-↑ʳ n i) -toℕ-strengthen : (i : Fin n) toℕ (strengthen i) toℕ i -toℕ-strengthen zero = refl -toℕ-strengthen (suc i) = cong suc (toℕ-strengthen i) +↑ʳ-injective : n (i j : Fin m) n ↑ʳ i n ↑ʳ j i j +↑ʳ-injective zero i i refl = refl +↑ʳ-injective (suc n) i j eq = ↑ʳ-injective n i j (suc-injective eq) ------------------------------------------------------------------------- --- toℕ-↑ˡ: "i" ↑ˡ n = "i" in Fin (m + n) ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- toℕ and the ordering relations +------------------------------------------------------------------------ -toℕ-↑ˡ : (i : Fin m) n toℕ (i ↑ˡ n) toℕ i -toℕ-↑ˡ zero n = refl -toℕ-↑ˡ (suc i) n = cong suc (toℕ-↑ˡ i n) +toℕ<n : (i : Fin n) toℕ i ℕ.< n +toℕ<n {n = suc _} zero = z<s +toℕ<n {n = suc _} (suc i) = s<s (toℕ<n i) + +toℕ≤pred[n] : (i : Fin n) toℕ i ℕ.≤ ℕ.pred n +toℕ≤pred[n] zero = z≤n +toℕ≤pred[n] (suc {n = suc n} i) = s≤s (toℕ≤pred[n] i) + +toℕ≤n : (i : Fin n) toℕ i ℕ.≤ n +toℕ≤n {suc n} i = ℕ.m≤n⇒m≤1+n (toℕ≤pred[n] i) + +-- A simpler implementation of toℕ≤pred[n], +-- however, with a different reduction behavior. +-- If no one needs the reduction behavior of toℕ≤pred[n], +-- it can be removed in favor of toℕ≤pred[n]′. +toℕ≤pred[n]′ : (i : Fin n) toℕ i ℕ.≤ ℕ.pred n +toℕ≤pred[n]′ i = ℕ.<⇒≤pred (toℕ<n i) + +toℕ-mono-< : i < j toℕ i ℕ.< toℕ j +toℕ-mono-< i<j = i<j + +toℕ-mono-≤ : i j toℕ i ℕ.≤ toℕ j +toℕ-mono-≤ i≤j = i≤j + +toℕ-cancel-≤ : toℕ i ℕ.≤ toℕ j i j +toℕ-cancel-≤ i≤j = i≤j + +toℕ-cancel-< : toℕ i ℕ.< toℕ j i < j +toℕ-cancel-< i<j = i<j + +------------------------------------------------------------------------ +-- fromℕ +------------------------------------------------------------------------ + +toℕ-fromℕ : n toℕ (fromℕ n) n +toℕ-fromℕ zero = refl +toℕ-fromℕ (suc n) = cong suc (toℕ-fromℕ n) + +fromℕ-toℕ : (i : Fin n) fromℕ (toℕ i) strengthen i +fromℕ-toℕ zero = refl +fromℕ-toℕ (suc i) = cong suc (fromℕ-toℕ i) -↑ˡ-injective : n (i j : Fin m) i ↑ˡ n j ↑ˡ n i j -↑ˡ-injective n zero zero refl = refl -↑ˡ-injective n (suc i) (suc j) eq = - cong suc (↑ˡ-injective n i j (suc-injective eq)) +≤fromℕ : (i : Fin (suc n)) i fromℕ n +≤fromℕ {n = n} i rewrite toℕ-fromℕ n = ℕ.s≤s⁻¹ (toℕ<n i) ------------------------------------------------------------------------- --- toℕ-↑ʳ: n ↑ʳ "i" = "n + i" in Fin (n + m) ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- fromℕ< +------------------------------------------------------------------------ -toℕ-↑ʳ : n (i : Fin m) toℕ (n ↑ʳ i) n ℕ.+ toℕ i -toℕ-↑ʳ zero i = refl -toℕ-↑ʳ (suc n) i = cong suc (toℕ-↑ʳ n i) +fromℕ<-toℕ : (i : Fin n) .(i<n : toℕ i ℕ.< n) fromℕ< i<n i +fromℕ<-toℕ zero _ = refl +fromℕ<-toℕ (suc i) i<n = cong suc (fromℕ<-toℕ i (ℕ.s<s⁻¹ i<n)) + +toℕ-fromℕ< : .(m<n : m ℕ.< n) toℕ (fromℕ< m<n) m +toℕ-fromℕ< {m = zero} {n = suc _} _ = refl +toℕ-fromℕ< {m = suc m} {n = suc _} m<n = cong suc (toℕ-fromℕ< (ℕ.s<s⁻¹ m<n)) + +-- fromℕ is a special case of fromℕ<. +fromℕ-def : n fromℕ n fromℕ< ℕ.≤-refl +fromℕ-def zero = refl +fromℕ-def (suc n) = cong suc (fromℕ-def n) + +fromℕ<-cong : m n {o} m n .(m<o : m ℕ.< o) .(n<o : n ℕ.< o) + fromℕ< m<o fromℕ< n<o +fromℕ<-cong 0 0 _ _ _ = refl +fromℕ<-cong (suc _) (suc _) {o = suc _} r m<n n<o + = cong suc (fromℕ<-cong _ _ (ℕ.suc-injective r) (ℕ.s<s⁻¹ m<n) (ℕ.s<s⁻¹ n<o)) + +fromℕ<-injective : m n {o} .(m<o : m ℕ.< o) .(n<o : n ℕ.< o) + fromℕ< m<o fromℕ< n<o m n +fromℕ<-injective 0 0 _ _ _ = refl +fromℕ<-injective 0 (suc _) {o = suc _} _ _ () +fromℕ<-injective (suc _) (suc _) {o = suc _} m<n n<o r + = cong suc (fromℕ<-injective _ _ (ℕ.s<s⁻¹ m<n) (ℕ.s<s⁻¹ n<o) (suc-injective r)) + +------------------------------------------------------------------------ +-- fromℕ<″ +------------------------------------------------------------------------ + +fromℕ<≡fromℕ<″ : (m<n : m ℕ.< n) (m<″n : m ℕ.<″ n) + fromℕ< m<n fromℕ<″ m m<″n +fromℕ<≡fromℕ<″ {m = zero} {n = suc _} _ _ = refl +fromℕ<≡fromℕ<″ {m = suc m} {n = suc _} m<n m<″n + = cong suc (fromℕ<≡fromℕ<″ (ℕ.s<s⁻¹ m<n) (ℕ.s<″s⁻¹ m<″n)) + +toℕ-fromℕ<″ : (m<n : m ℕ.<″ n) toℕ (fromℕ<″ m m<n) m +toℕ-fromℕ<″ {m} {n} m<n = begin + toℕ (fromℕ<″ m m<n) ≡⟨ cong toℕ (sym (fromℕ<≡fromℕ<″ (ℕ.≤″⇒≤ m<n) m<n)) + toℕ (fromℕ< _) ≡⟨ toℕ-fromℕ< (ℕ.≤″⇒≤ m<n) + m + where open ≡-Reasoning + +------------------------------------------------------------------------ +-- Properties of cast +------------------------------------------------------------------------ + +toℕ-cast : .(eq : m n) (k : Fin m) toℕ (cast eq k) toℕ k +toℕ-cast {n = suc n} eq zero = refl +toℕ-cast {n = suc n} eq (suc k) = cong suc (toℕ-cast (cong ℕ.pred eq) k) + +cast-is-id : .(eq : m m) (k : Fin m) cast eq k k +cast-is-id eq zero = refl +cast-is-id eq (suc k) = cong suc (cast-is-id (ℕ.suc-injective eq) k) + +subst-is-cast : (eq : m n) (k : Fin m) subst Fin eq k cast eq k +subst-is-cast refl k = sym (cast-is-id refl k) + +cast-trans : .(eq₁ : m n) .(eq₂ : n o) (k : Fin m) + cast eq₂ (cast eq₁ k) cast (trans eq₁ eq₂) k +cast-trans {m = suc _} {n = suc _} {o = suc _} eq₁ eq₂ zero = refl +cast-trans {m = suc _} {n = suc _} {o = suc _} eq₁ eq₂ (suc k) = + cong suc (cast-trans (ℕ.suc-injective eq₁) (ℕ.suc-injective eq₂) k) + +cast-involutive : .(eq₁ : m n) .(eq₂ : n m) + k cast eq₁ (cast eq₂ k) k +cast-involutive eq₁ eq₂ k = trans (cast-trans eq₂ eq₁ k) (cast-is-id refl k) + +------------------------------------------------------------------------ +-- Properties of _≤_ +------------------------------------------------------------------------ +-- Relational properties + +≤-reflexive : _≡_ (_≤_ {n}) +≤-reflexive refl = ℕ.≤-refl + +≤-refl : Reflexive (_≤_ {n}) +≤-refl = ≤-reflexive refl + +≤-trans : Transitive (_≤_ {n}) +≤-trans = ℕ.≤-trans + +≤-antisym : Antisymmetric _≡_ (_≤_ {n}) +≤-antisym x≤y y≤x = toℕ-injective (ℕ.≤-antisym x≤y y≤x) + +≤-total : Total (_≤_ {n}) +≤-total x y = ℕ.≤-total (toℕ x) (toℕ y) + +≤-irrelevant : Irrelevant (_≤_ {m} {n}) +≤-irrelevant = ℕ.≤-irrelevant + +infix 4 _≤?_ _<?_ + +_≤?_ : B.Decidable (_≤_ {m} {n}) +a ≤? b = toℕ a ℕ.≤? toℕ b + +_<?_ : B.Decidable (_<_ {m} {n}) +m <? n = suc (toℕ m) ℕ.≤? toℕ n + +------------------------------------------------------------------------ +-- Structures + +≤-isPreorder : IsPreorder {A = Fin n} _≡_ _≤_ +≤-isPreorder = record + { isEquivalence = ≡.isEquivalence + ; reflexive = ≤-reflexive + ; trans = ≤-trans + } + +≤-isPartialOrder : IsPartialOrder {A = Fin n} _≡_ _≤_ +≤-isPartialOrder = record + { isPreorder = ≤-isPreorder + ; antisym = ≤-antisym + } + +≤-isTotalOrder : IsTotalOrder {A = Fin n} _≡_ _≤_ +≤-isTotalOrder = record + { isPartialOrder = ≤-isPartialOrder + ; total = ≤-total + } + +≤-isDecTotalOrder : IsDecTotalOrder {A = Fin n} _≡_ _≤_ +≤-isDecTotalOrder = record + { isTotalOrder = ≤-isTotalOrder + ; _≟_ = _≟_ + ; _≤?_ = _≤?_ + } + +------------------------------------------------------------------------ +-- Bundles + +≤-preorder : Preorder _ _ _ +≤-preorder n = record + { isPreorder = ≤-isPreorder {n} + } + +≤-poset : Poset _ _ _ +≤-poset n = record + { isPartialOrder = ≤-isPartialOrder {n} + } + +≤-totalOrder : TotalOrder _ _ _ +≤-totalOrder n = record + { isTotalOrder = ≤-isTotalOrder {n} + } + +≤-decTotalOrder : DecTotalOrder _ _ _ +≤-decTotalOrder n = record + { isDecTotalOrder = ≤-isDecTotalOrder {n} + } + +------------------------------------------------------------------------ +-- Properties of _<_ +------------------------------------------------------------------------ +-- Relational properties + +<-irrefl : Irreflexive _≡_ (_<_ {n}) +<-irrefl refl = ℕ.<-irrefl refl + +<-asym : Asymmetric (_<_ {n}) +<-asym = ℕ.<-asym + +<-trans : Transitive (_<_ {n}) +<-trans = ℕ.<-trans + +<-cmp : Trichotomous _≡_ (_<_ {n}) +<-cmp zero zero = tri≈ (λ()) refl (λ()) +<-cmp zero (suc j) = tri< z<s (λ()) (λ()) +<-cmp (suc i) zero = tri> (λ()) (λ()) z<s +<-cmp (suc i) (suc j) with <-cmp i j +... | tri< i<j i≢j j≮i = tri< (s<s i<j) (i≢j suc-injective) (j≮i s<s⁻¹) +... | tri> i≮j i≢j j<i = tri> (i≮j s<s⁻¹) (i≢j suc-injective) (s<s j<i) +... | tri≈ i≮j i≡j j≮i = tri≈ (i≮j s<s⁻¹) (cong suc i≡j) (j≮i s<s⁻¹) -↑ʳ-injective : n (i j : Fin m) n ↑ʳ i n ↑ʳ j i j -↑ʳ-injective zero i i refl = refl -↑ʳ-injective (suc n) i j eq = ↑ʳ-injective n i j (suc-injective eq) - ------------------------------------------------------------------------- --- toℕ and the ordering relations ------------------------------------------------------------------------- - -toℕ<n : (i : Fin n) toℕ i ℕ.< n -toℕ<n {n = suc _} zero = z<s -toℕ<n {n = suc _} (suc i) = s<s (toℕ<n i) - -toℕ≤pred[n] : (i : Fin n) toℕ i ℕ.≤ ℕ.pred n -toℕ≤pred[n] zero = z≤n -toℕ≤pred[n] (suc {n = suc n} i) = s≤s (toℕ≤pred[n] i) - -toℕ≤n : (i : Fin n) toℕ i ℕ.≤ n -toℕ≤n {suc n} i = ℕ.m≤n⇒m≤1+n (toℕ≤pred[n] i) - --- A simpler implementation of toℕ≤pred[n], --- however, with a different reduction behavior. --- If no one needs the reduction behavior of toℕ≤pred[n], --- it can be removed in favor of toℕ≤pred[n]′. -toℕ≤pred[n]′ : (i : Fin n) toℕ i ℕ.≤ ℕ.pred n -toℕ≤pred[n]′ i = ℕ.<⇒≤pred (toℕ<n i) - -toℕ-mono-< : i < j toℕ i ℕ.< toℕ j -toℕ-mono-< i<j = i<j - -toℕ-mono-≤ : i j toℕ i ℕ.≤ toℕ j -toℕ-mono-≤ i≤j = i≤j - -toℕ-cancel-≤ : toℕ i ℕ.≤ toℕ j i j -toℕ-cancel-≤ i≤j = i≤j - -toℕ-cancel-< : toℕ i ℕ.< toℕ j i < j -toℕ-cancel-< i<j = i<j - ------------------------------------------------------------------------- --- fromℕ ------------------------------------------------------------------------- - -toℕ-fromℕ : n toℕ (fromℕ n) n -toℕ-fromℕ zero = refl -toℕ-fromℕ (suc n) = cong suc (toℕ-fromℕ n) - -fromℕ-toℕ : (i : Fin n) fromℕ (toℕ i) strengthen i -fromℕ-toℕ zero = refl -fromℕ-toℕ (suc i) = cong suc (fromℕ-toℕ i) - -≤fromℕ : (i : Fin (suc n)) i fromℕ n -≤fromℕ {n = n} i rewrite toℕ-fromℕ n = ℕ.s≤s⁻¹ (toℕ<n i) - ------------------------------------------------------------------------- --- fromℕ< ------------------------------------------------------------------------- - -fromℕ<-toℕ : (i : Fin n) .(i<n : toℕ i ℕ.< n) fromℕ< i<n i -fromℕ<-toℕ zero _ = refl -fromℕ<-toℕ (suc i) i<n = cong suc (fromℕ<-toℕ i (ℕ.s<s⁻¹ i<n)) - -toℕ-fromℕ< : .(m<n : m ℕ.< n) toℕ (fromℕ< m<n) m -toℕ-fromℕ< {m = zero} {n = suc _} _ = refl -toℕ-fromℕ< {m = suc m} {n = suc _} m<n = cong suc (toℕ-fromℕ< (ℕ.s<s⁻¹ m<n)) - --- fromℕ is a special case of fromℕ<. -fromℕ-def : n fromℕ n fromℕ< ℕ.≤-refl -fromℕ-def zero = refl -fromℕ-def (suc n) = cong suc (fromℕ-def n) - -fromℕ<-cong : m n {o} m n .(m<o : m ℕ.< o) .(n<o : n ℕ.< o) - fromℕ< m<o fromℕ< n<o -fromℕ<-cong 0 0 _ _ _ = refl -fromℕ<-cong (suc _) (suc _) {o = suc _} r m<n n<o - = cong suc (fromℕ<-cong _ _ (ℕ.suc-injective r) (ℕ.s<s⁻¹ m<n) (ℕ.s<s⁻¹ n<o)) - -fromℕ<-injective : m n {o} .(m<o : m ℕ.< o) .(n<o : n ℕ.< o) - fromℕ< m<o fromℕ< n<o m n -fromℕ<-injective 0 0 _ _ _ = refl -fromℕ<-injective 0 (suc _) {o = suc _} _ _ () -fromℕ<-injective (suc _) (suc _) {o = suc _} m<n n<o r - = cong suc (fromℕ<-injective _ _ (ℕ.s<s⁻¹ m<n) (ℕ.s<s⁻¹ n<o) (suc-injective r)) - ------------------------------------------------------------------------- --- fromℕ<″ ------------------------------------------------------------------------- - -fromℕ<≡fromℕ<″ : (m<n : m ℕ.< n) (m<″n : m ℕ.<″ n) - fromℕ< m<n fromℕ<″ m m<″n -fromℕ<≡fromℕ<″ {m = zero} {n = suc _} _ _ = refl -fromℕ<≡fromℕ<″ {m = suc m} {n = suc _} m<n m<″n - = cong suc (fromℕ<≡fromℕ<″ (ℕ.s<s⁻¹ m<n) (ℕ.s<″s⁻¹ m<″n)) - -toℕ-fromℕ<″ : (m<n : m ℕ.<″ n) toℕ (fromℕ<″ m m<n) m -toℕ-fromℕ<″ {m} {n} m<n = begin - toℕ (fromℕ<″ m m<n) ≡⟨ cong toℕ (sym (fromℕ<≡fromℕ<″ (ℕ.≤″⇒≤ m<n) m<n)) - toℕ (fromℕ< _) ≡⟨ toℕ-fromℕ< (ℕ.≤″⇒≤ m<n) - m - where open ≡-Reasoning - ------------------------------------------------------------------------- --- Properties of cast ------------------------------------------------------------------------- - -toℕ-cast : .(eq : m n) (k : Fin m) toℕ (cast eq k) toℕ k -toℕ-cast {n = suc n} eq zero = refl -toℕ-cast {n = suc n} eq (suc k) = cong suc (toℕ-cast (cong ℕ.pred eq) k) - -cast-is-id : .(eq : m m) (k : Fin m) cast eq k k -cast-is-id eq zero = refl -cast-is-id eq (suc k) = cong suc (cast-is-id (ℕ.suc-injective eq) k) - -subst-is-cast : (eq : m n) (k : Fin m) subst Fin eq k cast eq k -subst-is-cast refl k = sym (cast-is-id refl k) - -cast-trans : .(eq₁ : m n) .(eq₂ : n o) (k : Fin m) - cast eq₂ (cast eq₁ k) cast (trans eq₁ eq₂) k -cast-trans {m = suc _} {n = suc _} {o = suc _} eq₁ eq₂ zero = refl -cast-trans {m = suc _} {n = suc _} {o = suc _} eq₁ eq₂ (suc k) = - cong suc (cast-trans (ℕ.suc-injective eq₁) (ℕ.suc-injective eq₂) k) - -cast-involutive : .(eq₁ : m n) .(eq₂ : n m) - k cast eq₁ (cast eq₂ k) k -cast-involutive eq₁ eq₂ k = trans (cast-trans eq₂ eq₁ k) (cast-is-id refl k) - ------------------------------------------------------------------------- --- Properties of _≤_ ------------------------------------------------------------------------- --- Relational properties - -≤-reflexive : _≡_ (_≤_ {n}) -≤-reflexive refl = ℕ.≤-refl - -≤-refl : Reflexive (_≤_ {n}) -≤-refl = ≤-reflexive refl - -≤-trans : Transitive (_≤_ {n}) -≤-trans = ℕ.≤-trans - -≤-antisym : Antisymmetric _≡_ (_≤_ {n}) -≤-antisym x≤y y≤x = toℕ-injective (ℕ.≤-antisym x≤y y≤x) - -≤-total : Total (_≤_ {n}) -≤-total x y = ℕ.≤-total (toℕ x) (toℕ y) - -≤-irrelevant : Irrelevant (_≤_ {m} {n}) -≤-irrelevant = ℕ.≤-irrelevant - -infix 4 _≤?_ _<?_ - -_≤?_ : B.Decidable (_≤_ {m} {n}) -a ≤? b = toℕ a ℕ.≤? toℕ b - -_<?_ : B.Decidable (_<_ {m} {n}) -m <? n = suc (toℕ m) ℕ.≤? toℕ n - ------------------------------------------------------------------------- --- Structures - -≤-isPreorder : IsPreorder {A = Fin n} _≡_ _≤_ -≤-isPreorder = record - { isEquivalence = ≡.isEquivalence - ; reflexive = ≤-reflexive - ; trans = ≤-trans - } - -≤-isPartialOrder : IsPartialOrder {A = Fin n} _≡_ _≤_ -≤-isPartialOrder = record - { isPreorder = ≤-isPreorder - ; antisym = ≤-antisym - } - -≤-isTotalOrder : IsTotalOrder {A = Fin n} _≡_ _≤_ -≤-isTotalOrder = record - { isPartialOrder = ≤-isPartialOrder - ; total = ≤-total - } - -≤-isDecTotalOrder : IsDecTotalOrder {A = Fin n} _≡_ _≤_ -≤-isDecTotalOrder = record - { isTotalOrder = ≤-isTotalOrder - ; _≟_ = _≟_ - ; _≤?_ = _≤?_ - } - ------------------------------------------------------------------------- --- Bundles - -≤-preorder : Preorder _ _ _ -≤-preorder n = record - { isPreorder = ≤-isPreorder {n} - } - -≤-poset : Poset _ _ _ -≤-poset n = record - { isPartialOrder = ≤-isPartialOrder {n} - } - -≤-totalOrder : TotalOrder _ _ _ -≤-totalOrder n = record - { isTotalOrder = ≤-isTotalOrder {n} - } - -≤-decTotalOrder : DecTotalOrder _ _ _ -≤-decTotalOrder n = record - { isDecTotalOrder = ≤-isDecTotalOrder {n} - } - ------------------------------------------------------------------------- --- Properties of _<_ ------------------------------------------------------------------------- --- Relational properties - -<-irrefl : Irreflexive _≡_ (_<_ {n}) -<-irrefl refl = ℕ.<-irrefl refl - -<-asym : Asymmetric (_<_ {n}) -<-asym = ℕ.<-asym - -<-trans : Transitive (_<_ {n}) -<-trans = ℕ.<-trans - -<-cmp : Trichotomous _≡_ (_<_ {n}) -<-cmp zero zero = tri≈ (λ()) refl (λ()) -<-cmp zero (suc j) = tri< z<s (λ()) (λ()) -<-cmp (suc i) zero = tri> (λ()) (λ()) z<s -<-cmp (suc i) (suc j) with <-cmp i j -... | tri< i<j i≢j j≮i = tri< (s<s i<j) (i≢j suc-injective) (j≮i s<s⁻¹) -... | tri> i≮j i≢j j<i = tri> (i≮j s<s⁻¹) (i≢j suc-injective) (s<s j<i) -... | tri≈ i≮j i≡j j≮i = tri≈ (i≮j s<s⁻¹) (cong suc i≡j) (j≮i s<s⁻¹) - -<-respˡ-≡ : (_<_ {m} {n}) Respectsˡ _≡_ -<-respˡ-≡ refl x≤y = x≤y - -<-respʳ-≡ : (_<_ {m} {n}) Respectsʳ _≡_ -<-respʳ-≡ refl x≤y = x≤y - -<-resp₂-≡ : (_<_ {n}) Respects₂ _≡_ -<-resp₂-≡ = <-respʳ-≡ , <-respˡ-≡ - -<-irrelevant : Irrelevant (_<_ {m} {n}) -<-irrelevant = ℕ.<-irrelevant - ------------------------------------------------------------------------- --- Structures - -<-isStrictPartialOrder : IsStrictPartialOrder {A = Fin n} _≡_ _<_ -<-isStrictPartialOrder = record - { isEquivalence = ≡.isEquivalence - ; irrefl = <-irrefl - ; trans = <-trans - ; <-resp-≈ = <-resp₂-≡ - } - -<-isStrictTotalOrder : IsStrictTotalOrder {A = Fin n} _≡_ _<_ -<-isStrictTotalOrder = record - { isStrictPartialOrder = <-isStrictPartialOrder - ; compare = <-cmp - } - ------------------------------------------------------------------------- --- Bundles - -<-strictPartialOrder : StrictPartialOrder _ _ _ -<-strictPartialOrder n = record - { isStrictPartialOrder = <-isStrictPartialOrder {n} - } - -<-strictTotalOrder : StrictTotalOrder _ _ _ -<-strictTotalOrder n = record - { isStrictTotalOrder = <-isStrictTotalOrder {n} - } - ------------------------------------------------------------------------- --- Other properties - -i<1+i : (i : Fin n) i < suc i -i<1+i = ℕ.n<1+n toℕ - -<⇒≢ : i < j i j -<⇒≢ i<i refl = ℕ.n≮n _ i<i - -≤∧≢⇒< : i j i j i < j -≤∧≢⇒< {i = zero} {zero} _ 0≢0 = contradiction refl 0≢0 -≤∧≢⇒< {i = zero} {suc j} _ _ = z<s -≤∧≢⇒< {i = suc i} {suc j} 1+i≤1+j 1+i≢1+j = - s<s (≤∧≢⇒< (ℕ.s≤s⁻¹ 1+i≤1+j) (1+i≢1+j (cong suc))) - ------------------------------------------------------------------------- --- inject ------------------------------------------------------------------------- - -toℕ-inject : {i : Fin n} (j : Fin′ i) toℕ (inject j) toℕ j -toℕ-inject {i = suc i} zero = refl -toℕ-inject {i = suc i} (suc j) = cong suc (toℕ-inject j) - ------------------------------------------------------------------------- --- inject₁ ------------------------------------------------------------------------- - -fromℕ≢inject₁ : fromℕ n inject₁ i -fromℕ≢inject₁ {i = suc i} eq = fromℕ≢inject₁ {i = i} (suc-injective eq) - -inject₁-injective : inject₁ i inject₁ j i j -inject₁-injective {i = zero} {zero} i≡j = refl -inject₁-injective {i = suc i} {suc j} i≡j = - cong suc (inject₁-injective (suc-injective i≡j)) - -toℕ-inject₁ : (i : Fin n) toℕ (inject₁ i) toℕ i -toℕ-inject₁ zero = refl -toℕ-inject₁ (suc i) = cong suc (toℕ-inject₁ i) - -toℕ-inject₁-≢ : (i : Fin n) n toℕ (inject₁ i) -toℕ-inject₁-≢ (suc i) = toℕ-inject₁-≢ i ℕ.suc-injective - -inject₁ℕ< : (i : Fin n) toℕ (inject₁ i) ℕ.< n -inject₁ℕ< i rewrite toℕ-inject₁ i = toℕ<n i - -inject₁ℕ≤ : (i : Fin n) toℕ (inject₁ i) ℕ.≤ n -inject₁ℕ≤ = ℕ.<⇒≤ inject₁ℕ< - -≤̄⇒inject₁< : i j inject₁ i < suc j -≤̄⇒inject₁< {i = i} i≤j rewrite sym (toℕ-inject₁ i) = s<s i≤j - -ℕ<⇒inject₁< : {i : Fin (ℕ.suc n)} {j : Fin n} j < i inject₁ j < i -ℕ<⇒inject₁< {i = suc i} j≤i = ≤̄⇒inject₁< (ℕ.s≤s⁻¹ j≤i) - -i≤inject₁[j]⇒i≤1+j : i inject₁ j i suc j -i≤inject₁[j]⇒i≤1+j {i = zero} _ = z≤n -i≤inject₁[j]⇒i≤1+j {i = suc i} {j = suc j} i≤j = s≤s (ℕ.m≤n⇒m≤1+n (subst (toℕ i ℕ.≤_) (toℕ-inject₁ j) (ℕ.s≤s⁻¹ i≤j))) - ------------------------------------------------------------------------- --- inject! ------------------------------------------------------------------------- - -inject!-injective : {i : Fin (suc n)} Injective _≡_ _≡_ (inject! {i = i}) -inject!-injective {n = suc n} {i = suc i} {0F} {0F} refl = refl -inject!-injective {n = suc n} {i = suc i} {suc x} {suc y} eq = - cong suc (inject!-injective (suc-injective eq)) - -inject!-< : {i : Fin (suc n)} (k : Fin′ i) inject! k < i -inject!-< {suc n} {suc i} 0F = s≤s z≤n -inject!-< {suc n} {suc i} (suc k) = s≤s (inject!-< k) - ------------------------------------------------------------------------- --- lower₁ ------------------------------------------------------------------------- - -toℕ-lower₁ : i (p : n toℕ i) toℕ (lower₁ i p) toℕ i -toℕ-lower₁ {ℕ.zero} zero p = contradiction refl p -toℕ-lower₁ {ℕ.suc m} zero p = refl -toℕ-lower₁ {ℕ.suc m} (suc i) p = cong ℕ.suc (toℕ-lower₁ i (p cong ℕ.suc)) - -lower₁-injective : {n≢i : n toℕ i} {n≢j : n toℕ j} - lower₁ i n≢i lower₁ j n≢j i j -lower₁-injective {zero} {zero} {_} {n≢i} {_} _ = contradiction refl n≢i -lower₁-injective {zero} {_} {zero} {_} {n≢j} _ = contradiction refl n≢j -lower₁-injective {suc n} {zero} {zero} {_} {_} refl = refl -lower₁-injective {suc n} {suc i} {suc j} {n≢i} {n≢j} eq = - cong suc (lower₁-injective (suc-injective eq)) - ------------------------------------------------------------------------- --- inject₁ and lower₁ - -inject₁-lower₁ : (i : Fin (suc n)) (n≢i : n toℕ i) - inject₁ (lower₁ i n≢i) i -inject₁-lower₁ {zero} zero 0≢0 = contradiction refl 0≢0 -inject₁-lower₁ {suc n} zero _ = refl -inject₁-lower₁ {suc n} (suc i) n+1≢i+1 = - cong suc (inject₁-lower₁ i (n+1≢i+1 cong suc)) - -lower₁-inject₁′ : (i : Fin n) (n≢i : n toℕ (inject₁ i)) - lower₁ (inject₁ i) n≢i i -lower₁-inject₁′ zero _ = refl -lower₁-inject₁′ (suc i) n+1≢i+1 = - cong suc (lower₁-inject₁′ i (n+1≢i+1 cong suc)) - -lower₁-inject₁ : (i : Fin n) - lower₁ (inject₁ i) (toℕ-inject₁-≢ i) i -lower₁-inject₁ i = lower₁-inject₁′ i (toℕ-inject₁-≢ i) - -lower₁-irrelevant : (i : Fin (suc n)) (n≢i₁ n≢i₂ : n toℕ i) - lower₁ i n≢i₁ lower₁ i n≢i₂ -lower₁-irrelevant {zero} zero 0≢0 _ = contradiction refl 0≢0 -lower₁-irrelevant {suc n} zero _ _ = refl -lower₁-irrelevant {suc n} (suc i) _ _ = - cong suc (lower₁-irrelevant i _ _) - -inject₁≡⇒lower₁≡ : {i : Fin n} {j : Fin (ℕ.suc n)} - (n≢j : n toℕ j) inject₁ i j lower₁ j n≢j i -inject₁≡⇒lower₁≡ n≢j i≡j = inject₁-injective (trans (inject₁-lower₁ _ n≢j) (sym i≡j)) - ------------------------------------------------------------------------- --- lower ------------------------------------------------------------------------- - -lower-injective : (i j : Fin m) - .{i<n : toℕ i ℕ.< n} .{j<n : toℕ j ℕ.< n} - lower i i<n lower j j<n i j -lower-injective {n = suc n} zero zero eq = refl -lower-injective {n = suc n} (suc i) (suc j) eq = - cong suc (lower-injective i j (suc-injective eq)) - ------------------------------------------------------------------------- --- inject≤ ------------------------------------------------------------------------- - -toℕ-inject≤ : i .(m≤n : m ℕ.≤ n) toℕ (inject≤ i m≤n) toℕ i -toℕ-inject≤ {_} {suc n} zero _ = refl -toℕ-inject≤ {_} {suc n} (suc i) _ = cong suc (toℕ-inject≤ i _) - -inject≤-refl : i .(n≤n : n ℕ.≤ n) inject≤ i n≤n i -inject≤-refl {suc n} zero _ = refl -inject≤-refl {suc n} (suc i) _ = cong suc (inject≤-refl i _) - -inject≤-idempotent : (i : Fin m) - .(m≤n : m ℕ.≤ n) .(n≤o : n ℕ.≤ o) .(m≤o : m ℕ.≤ o) - inject≤ (inject≤ i m≤n) n≤o inject≤ i m≤o -inject≤-idempotent {_} {suc n} {suc o} zero _ _ _ = refl -inject≤-idempotent {_} {suc n} {suc o} (suc i) _ _ _ = - cong suc (inject≤-idempotent i _ _ _) - -inject≤-trans : (i : Fin m) .(m≤n : m ℕ.≤ n) .(n≤o : n ℕ.≤ o) - inject≤ (inject≤ i m≤n) n≤o inject≤ i (ℕ.≤-trans m≤n n≤o) -inject≤-trans i _ _ = inject≤-idempotent i _ _ _ - -inject≤-injective : .(m≤n m≤n′ : m ℕ.≤ n) i j - inject≤ i m≤n inject≤ j m≤n′ i j -inject≤-injective {n = suc _} _ _ zero zero eq = refl -inject≤-injective {n = suc _} _ _ (suc i) (suc j) eq = - cong suc (inject≤-injective _ _ i j (suc-injective eq)) - -inject≤-irrelevant : .(m≤n m≤n′ : m ℕ.≤ n) i - inject≤ i m≤n inject≤ i m≤n′ -inject≤-irrelevant _ _ i = refl - ------------------------------------------------------------------------- --- pred ------------------------------------------------------------------------- - -pred< : (i : Fin (suc n)) i zero pred i < i -pred< zero i≢0 = contradiction refl i≢0 -pred< (suc i) _ = ≤̄⇒inject₁< ℕ.≤-refl - ------------------------------------------------------------------------- --- splitAt ------------------------------------------------------------------------- - --- Fin (m + n) ↔ Fin m ⊎ Fin n - -splitAt-↑ˡ : m i n splitAt m (i ↑ˡ n) inj₁ i -splitAt-↑ˡ (suc m) zero n = refl -splitAt-↑ˡ (suc m) (suc i) n rewrite splitAt-↑ˡ m i n = refl - -splitAt⁻¹-↑ˡ : {m} {n} {i} {j} splitAt m {n} i inj₁ j j ↑ˡ n i -splitAt⁻¹-↑ˡ {suc m} {n} {0F} {.0F} refl = refl -splitAt⁻¹-↑ˡ {suc m} {n} {suc i} {j} eq - with inj₁ ksplitAt m i in splitAt[m][i]≡inj₁[j] - with refleq - = cong suc (splitAt⁻¹-↑ˡ {i = i} {j = k} splitAt[m][i]≡inj₁[j]) - -splitAt-↑ʳ : m n i splitAt m (m ↑ʳ i) inj₂ {B = Fin n} i -splitAt-↑ʳ zero n i = refl -splitAt-↑ʳ (suc m) n i rewrite splitAt-↑ʳ m n i = refl - -splitAt⁻¹-↑ʳ : {m} {n} {i} {j} splitAt m {n} i inj₂ j m ↑ʳ j i -splitAt⁻¹-↑ʳ {zero} {n} {i} {j} refl = refl -splitAt⁻¹-↑ʳ {suc m} {n} {suc i} {j} eq - with inj₂ ksplitAt m i in splitAt[m][i]≡inj₂[k] - with refleq - = cong suc (splitAt⁻¹-↑ʳ {i = i} {j = k} splitAt[m][i]≡inj₂[k]) - -splitAt-join : m n i splitAt m (join m n i) i -splitAt-join m n (inj₁ x) = splitAt-↑ˡ m x n -splitAt-join m n (inj₂ y) = splitAt-↑ʳ m n y - -join-splitAt : m n i join m n (splitAt m i) i -join-splitAt zero n i = refl -join-splitAt (suc m) n zero = refl -join-splitAt (suc m) n (suc i) = begin - [ _↑ˡ n , (suc m) ↑ʳ_ ]′ (splitAt (suc m) (suc i)) ≡⟨ [,]-map (splitAt m i) - [ suc (_↑ˡ n) , suc (m ↑ʳ_) ]′ (splitAt m i) ≡⟨ [,]-∘ suc (splitAt m i) - suc ([ _↑ˡ n , m ↑ʳ_ ]′ (splitAt m i)) ≡⟨ cong suc (join-splitAt m n i) - suc i - where open ≡-Reasoning - --- splitAt "m" "i" ≡ inj₁ "i" if i < m - -splitAt-< : m {n} (i : Fin (m ℕ.+ n)) .(i<m : toℕ i ℕ.< m) - splitAt m i inj₁ (fromℕ< i<m) -splitAt-< (suc m) zero _ = refl -splitAt-< (suc m) (suc i) i<m = cong (Sum.map suc id) (splitAt-< m i (ℕ.s<s⁻¹ i<m)) - --- splitAt "m" "i" ≡ inj₂ "i - m" if i ≥ m - -splitAt-≥ : m {n} (i : Fin (m ℕ.+ n)) .(i≥m : toℕ i ℕ.≥ m) - splitAt m i inj₂ (reduce≥ i i≥m) -splitAt-≥ zero i _ = refl -splitAt-≥ (suc m) (suc i) i≥m = cong (Sum.map suc id) (splitAt-≥ m i (ℕ.s≤s⁻¹ i≥m)) - ------------------------------------------------------------------------- --- Bundles - -+↔⊎ : Fin (m ℕ.+ n) (Fin m Fin n) -+↔⊎ {m} {n} = mk↔ₛ′ (splitAt m {n}) (join m n) (splitAt-join m n) (join-splitAt m n) - ------------------------------------------------------------------------- --- remQuot ------------------------------------------------------------------------- - --- Fin (m * n) ↔ Fin m × Fin n - -remQuot-combine : {n k} (i : Fin n) j remQuot k (combine i j) (i , j) -remQuot-combine {suc n} {k} zero j rewrite splitAt-↑ˡ k j (n ℕ.* k) = refl -remQuot-combine {suc n} {k} (suc i) j rewrite splitAt-↑ʳ k (n ℕ.* k) (combine i j) = - cong (Product.map₁ suc) (remQuot-combine i j) - -combine-remQuot : {n} k (i : Fin (n ℕ.* k)) uncurry combine (remQuot {n} k i) i -combine-remQuot {suc n} k i with splitAt k i in eq -... | inj₁ j = begin - join k (n ℕ.* k) (inj₁ j) ≡⟨ cong (join k (n ℕ.* k)) eq - join k (n ℕ.* k) (splitAt k i) ≡⟨ join-splitAt k (n ℕ.* k) i - i - where open ≡-Reasoning -... | inj₂ j = begin - k ↑ʳ (uncurry combine (remQuot {n} k j)) ≡⟨ cong (k ↑ʳ_) (combine-remQuot {n} k j) - join k (n ℕ.* k) (inj₂ j) ≡⟨ cong (join k (n ℕ.* k)) eq - join k (n ℕ.* k) (splitAt k i) ≡⟨ join-splitAt k (n ℕ.* k) i - i - where open ≡-Reasoning - -toℕ-combine : (i : Fin m) (j : Fin n) toℕ (combine i j) n ℕ.* toℕ i ℕ.+ toℕ j -toℕ-combine {suc m} {n} i@0F j = begin - toℕ (combine i j) ≡⟨⟩ - toℕ (j ↑ˡ (m ℕ.* n)) ≡⟨ toℕ-↑ˡ j (m ℕ.* n) - toℕ j ≡⟨⟩ - 0 ℕ.+ toℕ j ≡⟨ cong (ℕ._+ toℕ j) (ℕ.*-zeroʳ n) - n ℕ.* toℕ i ℕ.+ toℕ j - where open ≡-Reasoning -toℕ-combine {suc m} {n} (suc i) j = begin - toℕ (combine (suc i) j) ≡⟨⟩ - toℕ (n ↑ʳ combine i j) ≡⟨ toℕ-↑ʳ n (combine i j) - n ℕ.+ toℕ (combine i j) ≡⟨ cong (n ℕ.+_) (toℕ-combine i j) - n ℕ.+ (n ℕ.* toℕ i ℕ.+ toℕ j) ≡⟨ ℕ.+-assoc n _ (toℕ j) - n ℕ.+ n ℕ.* toℕ i ℕ.+ toℕ j ≡⟨ cong z z ℕ.+ n ℕ.* toℕ i ℕ.+ toℕ j) (ℕ.*-identityʳ n) - n ℕ.* 1 ℕ.+ n ℕ.* toℕ i ℕ.+ toℕ j ≡⟨ cong (ℕ._+ toℕ j) (ℕ.*-distribˡ-+ n 1 (toℕ i) ) - n ℕ.* toℕ (suc i) ℕ.+ toℕ j - where open ≡-Reasoning - -combine-monoˡ-< : {i j : Fin m} (k l : Fin n) - i < j combine i k < combine j l -combine-monoˡ-< {m} {n} {i} {j} k l i<j = begin-strict - toℕ (combine i k) ≡⟨ toℕ-combine i k - n ℕ.* toℕ i ℕ.+ toℕ k <⟨ ℕ.+-monoʳ-< (n ℕ.* toℕ i) (toℕ<n k) - n ℕ.* toℕ i ℕ.+ n ≡⟨ ℕ.+-comm _ n - n ℕ.+ n ℕ.* toℕ i ≡⟨ cong (n ℕ.+_) (ℕ.*-comm n _) - n ℕ.+ toℕ i ℕ.* n ≡⟨ ℕ.*-comm (suc (toℕ i)) n - n ℕ.* suc (toℕ i) ≤⟨ ℕ.*-monoʳ-≤ n (toℕ-mono-< i<j) - n ℕ.* toℕ j ≤⟨ ℕ.m≤m+n (n ℕ.* toℕ j) (toℕ l) - n ℕ.* toℕ j ℕ.+ toℕ l ≡⟨ toℕ-combine j l - toℕ (combine j l) - where open ℕ.≤-Reasoning - -combine-injectiveˡ : (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) - combine i j combine k l i k -combine-injectiveˡ i j k l cᵢⱼ≡cₖₗ with <-cmp i k -... | tri< i<k _ _ = contradiction cᵢⱼ≡cₖₗ (<⇒≢ (combine-monoˡ-< j l i<k)) -... | tri≈ _ i≡k _ = i≡k -... | tri> _ _ i>k = contradiction (sym cᵢⱼ≡cₖₗ) (<⇒≢ (combine-monoˡ-< l j i>k)) - -combine-injectiveʳ : (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) - combine i j combine k l j l -combine-injectiveʳ {m} {n} i j k l cᵢⱼ≡cₖₗ - with reflcombine-injectiveˡ i j k l cᵢⱼ≡cₖₗ - = toℕ-injective (ℕ.+-cancelˡ-≡ (n ℕ.* toℕ i) _ _ (begin - n ℕ.* toℕ i ℕ.+ toℕ j ≡⟨ toℕ-combine i j - toℕ (combine i j) ≡⟨ cong toℕ cᵢⱼ≡cₖₗ - toℕ (combine i l) ≡⟨ toℕ-combine i l - n ℕ.* toℕ i ℕ.+ toℕ l )) - where open ≡-Reasoning - -combine-injective : (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) - combine i j combine k l i k × j l -combine-injective i j k l cᵢⱼ≡cₖₗ = - combine-injectiveˡ i j k l cᵢⱼ≡cₖₗ , - combine-injectiveʳ i j k l cᵢⱼ≡cₖₗ - -combine-surjective : (i : Fin (m ℕ.* n)) ∃₂ λ j k combine j k i -combine-surjective {m} {n} i with j , kremQuot {m} n i in eq - = j , k , (begin - combine j k ≡⟨ uncurry (cong₂ combine) (,-injective eq) - uncurry combine (remQuot {m} n i) ≡⟨ combine-remQuot {m} n i - i ) - where open ≡-Reasoning - ------------------------------------------------------------------------- --- Bundles - -*↔× : Fin (m ℕ.* n) (Fin m × Fin n) -*↔× {m} {n} = mk↔ₛ′ (remQuot {m} n) (uncurry combine) - (uncurry remQuot-combine) - (combine-remQuot {m} n) - ------------------------------------------------------------------------- --- fin→fun ------------------------------------------------------------------------- - -funToFin-finToFin : funToFin {m} {n} finToFun id -funToFin-finToFin {zero} {n} zero = refl -funToFin-finToFin {suc m} {n} k = - begin - combine (finToFun {n} {suc m} k zero) (funToFin (finToFun {n} {suc m} k suc)) - ≡⟨⟩ - combine (quotient {n} (n ^ m) k) - (funToFin (finToFun {n} {m} (remainder {n} (n ^ m) k))) - ≡⟨ cong (combine (quotient {n} (n ^ m) k)) - (funToFin-finToFin {m} (remainder {n} (n ^ m) k)) - combine (quotient {n} (n ^ m) k) (remainder {n} (n ^ m) k) - ≡⟨⟩ - uncurry combine (remQuot {n} (n ^ m) k) - ≡⟨ combine-remQuot {n = n} (n ^ m) k - k - where open ≡-Reasoning - -finToFun-funToFin : (f : Fin m Fin n) finToFun (funToFin f) f -finToFun-funToFin {suc m} {n} f zero = - begin - quotient (n ^ m) (combine (f zero) (funToFin (f suc))) - ≡⟨ cong proj₁ (remQuot-combine _ _) - proj₁ (f zero , funToFin (f suc)) - ≡⟨⟩ - f zero - where open ≡-Reasoning -finToFun-funToFin {suc m} {n} f (suc i) = - begin - finToFun (remainder {n} (n ^ m) (combine (f zero) (funToFin (f suc)))) i - ≡⟨ cong rq finToFun (proj₂ rq) i) (remQuot-combine {n} _ _) - finToFun (proj₂ (f zero , funToFin (f suc))) i - ≡⟨⟩ - finToFun (funToFin (f suc)) i - ≡⟨ finToFun-funToFin (f suc) i - (f suc) i - ≡⟨⟩ - f (suc i) - where open ≡-Reasoning - ------------------------------------------------------------------------- --- Bundles - -^↔→ : Extensionality _ _ Fin (m ^ n) (Fin n Fin m) -^↔→ {m} {n} ext = mk↔ₛ′ finToFun funToFin - (ext finToFun-funToFin) - (funToFin-finToFin {n} {m}) - ------------------------------------------------------------------------- --- lift ------------------------------------------------------------------------- - -lift-injective : (f : Fin m Fin n) Injective _≡_ _≡_ f - k Injective _≡_ _≡_ (lift k f) -lift-injective f inj zero {_} {_} eq = inj eq -lift-injective f inj (suc k) {zero} {zero} eq = refl -lift-injective f inj (suc k) {suc _} {suc _} eq = - cong suc (lift-injective f inj k (suc-injective eq)) - ------------------------------------------------------------------------- --- pred ------------------------------------------------------------------------- - -<⇒≤pred : i < j i pred j -<⇒≤pred {i = zero} {j = suc j} z<s = z≤n -<⇒≤pred {i = suc i} {j = suc j} (s<s i<j) rewrite toℕ-inject₁ j = i<j - ------------------------------------------------------------------------- --- _ℕ-_ ------------------------------------------------------------------------- - -toℕ‿ℕ- : n i toℕ (n ℕ- i) n toℕ i -toℕ‿ℕ- n zero = toℕ-fromℕ n -toℕ‿ℕ- (suc n) (suc i) = toℕ‿ℕ- n i - ------------------------------------------------------------------------- --- _ℕ-ℕ_ ------------------------------------------------------------------------- - -ℕ-ℕ≡toℕ‿ℕ- : n i n ℕ-ℕ i toℕ (n ℕ- i) -ℕ-ℕ≡toℕ‿ℕ- n zero = sym (toℕ-fromℕ n) -ℕ-ℕ≡toℕ‿ℕ- (suc n) (suc i) = ℕ-ℕ≡toℕ‿ℕ- n i - -nℕ-ℕi≤n : n i n ℕ-ℕ i ℕ.≤ n -nℕ-ℕi≤n n zero = ℕ.≤-refl -nℕ-ℕi≤n (suc n) (suc i) = begin - n ℕ-ℕ i ≤⟨ nℕ-ℕi≤n n i - n ≤⟨ ℕ.n≤1+n n - suc n - where open ℕ.≤-Reasoning - ------------------------------------------------------------------------- --- punchIn ------------------------------------------------------------------------- - -punchIn-injective : i (j k : Fin n) - punchIn i j punchIn i k j k -punchIn-injective zero _ _ refl = refl -punchIn-injective (suc i) zero zero _ = refl -punchIn-injective (suc i) (suc j) (suc k) ↑j+1≡↑k+1 = - cong suc (punchIn-injective i j k (suc-injective ↑j+1≡↑k+1)) - -punchInᵢ≢i : i (j : Fin n) punchIn i j i -punchInᵢ≢i (suc i) (suc j) = punchInᵢ≢i i j suc-injective - ------------------------------------------------------------------------- --- punchOut ------------------------------------------------------------------------- - --- A version of 'cong' for 'punchOut' in which the inequality argument --- can be changed out arbitrarily (reflecting the proof-irrelevance of --- that argument). - -punchOut-cong : (i : Fin (suc n)) {j k} {i≢j : i j} {i≢k : i k} - j k punchOut i≢j punchOut i≢k -punchOut-cong {_} zero {zero} {i≢j = 0≢0} = contradiction refl 0≢0 -punchOut-cong {_} zero {suc j} {zero} {i≢k = 0≢0} = contradiction refl 0≢0 -punchOut-cong {_} zero {suc j} {suc k} = suc-injective -punchOut-cong {suc n} (suc i) {zero} {zero} _ = refl -punchOut-cong {suc n} (suc i) {suc j} {suc k} = cong suc punchOut-cong i suc-injective - --- An alternative to 'punchOut-cong' in the which the new inequality --- argument is specific. Useful for enabling the omission of that --- argument during equational reasoning. - -punchOut-cong′ : (i : Fin (suc n)) {j k} {p : i j} (q : j k) - punchOut p punchOut (p sym trans q sym) -punchOut-cong′ i q = punchOut-cong i q - -punchOut-injective : {i j k : Fin (suc n)} - (i≢j : i j) (i≢k : i k) - punchOut i≢j punchOut i≢k j k -punchOut-injective {_} {zero} {zero} {_} 0≢0 _ _ = contradiction refl 0≢0 -punchOut-injective {_} {zero} {_} {zero} _ 0≢0 _ = contradiction refl 0≢0 -punchOut-injective {_} {zero} {suc j} {suc k} _ _ pⱼ≡pₖ = cong suc pⱼ≡pₖ -punchOut-injective {suc n} {suc i} {zero} {zero} _ _ _ = refl -punchOut-injective {suc n} {suc i} {suc j} {suc k} i≢j i≢k pⱼ≡pₖ = - cong suc (punchOut-injective (i≢j cong suc) (i≢k cong suc) (suc-injective pⱼ≡pₖ)) - -punchIn-punchOut : {i j : Fin (suc n)} (i≢j : i j) - punchIn i (punchOut i≢j) j -punchIn-punchOut {_} {zero} {zero} 0≢0 = contradiction refl 0≢0 -punchIn-punchOut {_} {zero} {suc j} _ = refl -punchIn-punchOut {suc m} {suc i} {zero} i≢j = refl -punchIn-punchOut {suc m} {suc i} {suc j} i≢j = - cong suc (punchIn-punchOut (i≢j cong suc)) - -punchOut-punchIn : i {j : Fin n} punchOut {i = i} {j = punchIn i j} (punchInᵢ≢i i j sym) j -punchOut-punchIn zero {j} = refl -punchOut-punchIn (suc i) {zero} = refl -punchOut-punchIn (suc i) {suc j} = cong suc (begin - punchOut (punchInᵢ≢i i j suc-injective sym cong suc) ≡⟨ punchOut-cong i refl - punchOut (punchInᵢ≢i i j sym) ≡⟨ punchOut-punchIn i - j ) - where open ≡-Reasoning - - ------------------------------------------------------------------------- --- pinch ------------------------------------------------------------------------- - -pinch-surjective : (i : Fin n) Surjective _≡_ _≡_ (pinch i) -pinch-surjective _ zero = zero , λ { refl refl } -pinch-surjective zero (suc j) = suc (suc j) , λ { refl refl } -pinch-surjective (suc i) (suc j) = map suc {f refl cong suc (f refl)}) (pinch-surjective i j) - -pinch-mono-≤ : (i : Fin n) Monotonic₁ _≤_ _≤_ (pinch i) -pinch-mono-≤ 0F {0F} {k} 0≤n = z≤n -pinch-mono-≤ 0F {suc j} {suc k} j≤k = ℕ.s≤s⁻¹ j≤k -pinch-mono-≤ (suc i) {0F} {k} 0≤n = z≤n -pinch-mono-≤ (suc i) {suc j} {suc k} j≤k = s≤s (pinch-mono-≤ i (ℕ.s≤s⁻¹ j≤k)) - -pinch-injective : {i : Fin n} {j k : Fin (ℕ.suc n)} - suc i j suc i k pinch i j pinch i k j k -pinch-injective {i = i} {zero} {zero} _ _ _ = refl -pinch-injective {i = zero} {zero} {suc k} _ 1+i≢k eq = - contradiction (cong suc eq) 1+i≢k -pinch-injective {i = zero} {suc j} {zero} 1+i≢j _ eq = - contradiction (cong suc (sym eq)) 1+i≢j -pinch-injective {i = zero} {suc j} {suc k} _ _ eq = - cong suc eq -pinch-injective {i = suc i} {suc j} {suc k} 1+i≢j 1+i≢k eq = - cong suc - (pinch-injective (1+i≢j cong suc) (1+i≢k cong suc) - (suc-injective eq)) - ------------------------------------------------------------------------- --- Quantification ------------------------------------------------------------------------- - -module _ {p} {P : Pred (Fin (suc n)) p} where - - ∀-cons : P zero Π[ P suc ] Π[ P ] - ∀-cons z s zero = z - ∀-cons z s (suc i) = s i - - ∀-cons-⇔ : (P zero × Π[ P suc ]) Π[ P ] - ∀-cons-⇔ = mk⇔ (uncurry ∀-cons) < _$ zero , _∘ suc > - - ∃-here : P zero ∃⟨ P - ∃-here = zero ,_ - - ∃-there : ∃⟨ P suc ∃⟨ P - ∃-there = map suc id - - ∃-toSum : ∃⟨ P P zero ∃⟨ P suc - ∃-toSum ( zero , P₀ ) = inj₁ P₀ - ∃-toSum (suc f , P₁₊) = inj₂ (f , P₁₊) - - ⊎⇔∃ : (P zero ∃⟨ P suc ) ∃⟨ P - ⊎⇔∃ = mk⇔ [ ∃-here , ∃-there ] ∃-toSum - -decFinSubset : {p q} {P : Pred (Fin n) p} {Q : Pred (Fin n) q} - Decidable Q (∀ {i} Q i Dec (P i)) Dec (Q P) -decFinSubset {zero} {_} {_} Q? P? = yes λ {} -decFinSubset {suc n} {P = P} {Q} Q? P? - with Q? zero | ∀-cons {P = λ x Q x P x} -... | false because [¬Q0] | cons = - map′ f {x} cons (⊥-elim invert [¬Q0]) x f {x}) x) - f {x} f {suc x}) - (decFinSubset (Q? suc) P?) -... | true because [Q0] | cons = - map′ (uncurry λ P0 rec {x} cons _ P0) x rec {x}) x) - < _$ invert [Q0] , f {x} f {suc x}) > - (P? (invert [Q0]) ×-dec decFinSubset (Q? suc) P?) - -any? : {p} {P : Pred (Fin n) p} Decidable P Dec ( P) -any? {zero} {P = _} P? = no λ { (() , _) } -any? {suc n} {P = P} P? = Dec.map ⊎⇔∃ (P? zero ⊎-dec any? (P? suc)) - -all? : {p} {P : Pred (Fin n) p} Decidable P Dec (∀ f P f) -all? P? = map′ ∀p f ∀p tt) ∀p {x} _ ∀p x) - (decFinSubset U? {f} _ P? f)) - -private - -- A nice computational property of `all?`: - -- The boolean component of the result is exactly the - -- obvious fold of boolean tests (`foldr _∧_ true`). - note : {p} {P : Pred (Fin 3) p} (P? : Decidable P) - λ z Dec.does (all? P?) z - note P? = Dec.does (P? 0F) Dec.does (P? 1F) Dec.does (P? 2F) true - , refl - --- If a decidable predicate P over a finite set is sometimes false, --- then we can find the smallest value for which this is the case. - -¬∀⟶∃¬-smallest : n {p} (P : Pred (Fin n) p) Decidable P - ¬ (∀ i P i) λ i ¬ P i × ((j : Fin′ i) P (inject j)) -¬∀⟶∃¬-smallest zero P P? ¬∀P = contradiction (λ()) ¬∀P -¬∀⟶∃¬-smallest (suc n) P P? ¬∀P with P? zero -... | false because [¬P₀] = (zero , invert [¬P₀] , λ ()) -... | true because [P₀] = map suc (map id (∀-cons (invert [P₀]))) - (¬∀⟶∃¬-smallest n (P suc) (P? suc) (¬∀P (∀-cons (invert [P₀])))) - --- When P is a decidable predicate over a finite set the following --- lemma can be proved. - -¬∀⟶∃¬ : n {p} (P : Pred (Fin n) p) Decidable P - ¬ (∀ i P i) ( λ i ¬ P i) -¬∀⟶∃¬ n P P? ¬P = map id proj₁ (¬∀⟶∃¬-smallest n P P? ¬P) - ------------------------------------------------------------------------- --- Properties of functions to and from Fin ------------------------------------------------------------------------- - --- The pigeonhole principle. - -pigeonhole : m ℕ.< n (f : Fin n Fin m) ∃₂ λ i j i < j × f i f j -pigeonhole z<s f = contradiction (f zero) λ() -pigeonhole (s<s m<n@(s≤s _)) f with any? k f zero f (suc k)) -... | yes (j , f₀≡fⱼ) = zero , suc j , z<s , f₀≡fⱼ -... | no f₀≢fₖ - with i , j , i<j , fᵢ≡fⱼpigeonhole m<n j punchOut (f₀≢fₖ (j ,_ ))) - = suc i , suc j , s<s i<j , punchOut-injective (f₀≢fₖ (i ,_)) _ fᵢ≡fⱼ - -injective⇒≤ : {f : Fin m Fin n} Injective _≡_ _≡_ f m ℕ.≤ n -injective⇒≤ {zero} {_} {f} _ = z≤n -injective⇒≤ {suc _} {zero} {f} _ = contradiction (f zero) ¬Fin0 -injective⇒≤ {suc _} {suc _} {f} inj = s≤s (injective⇒≤ eq - suc-injective (inj (punchOut-injective - (contraInjective inj 0≢1+n) - (contraInjective inj 0≢1+n) eq)))) - -<⇒notInjective : {f : Fin m Fin n} n ℕ.< m ¬ (Injective _≡_ _≡_ f) -<⇒notInjective n<m inj = ℕ.≤⇒≯ (injective⇒≤ inj) n<m - -ℕ→Fin-notInjective : (f : Fin n) ¬ (Injective _≡_ _≡_ f) -ℕ→Fin-notInjective f inj = ℕ.<-irrefl refl - (injective⇒≤ (Comp.injective _≡_ _≡_ _≡_ toℕ-injective inj)) - --- Cantor-Schröder-Bernstein for finite sets - -cantor-schröder-bernstein : {f : Fin m Fin n} {g : Fin n Fin m} - Injective _≡_ _≡_ f Injective _≡_ _≡_ g - m n -cantor-schröder-bernstein f-inj g-inj = ℕ.≤-antisym - (injective⇒≤ f-inj) (injective⇒≤ g-inj) - -injective⇒existsPivot : {f : Fin n Fin m} Injective _≡_ _≡_ f - (i : Fin n) λ j j i × i f j -injective⇒existsPivot {f = f} f-injective i - with any? j j ≤? i ×-dec i ≤? f j) -... | yes result = result -... | no ¬result = contradiction (injective⇒≤ f∘inject!-injective) ℕ.1+n≰n - where - fj<i : (j : Fin′ (suc i)) f (inject! j) < i - fj<i j with f (inject! j) <? i - ... | yes fj<i = fj<i - ... | no fj≮i = contradiction (_ , ℕ.s≤s⁻¹ (inject!-< j) , ℕ.≮⇒≥ fj≮i) ¬result - - f∘inject! : Fin′ (suc i) Fin′ i - f∘inject! j = lower (f (inject! j)) (fj<i j) - - f∘inject!-injective : Injective _≡_ _≡_ f∘inject! - f∘inject!-injective = inject!-injective f-injective lower-injective _ _ - ------------------------------------------------------------------------- --- Effectful ------------------------------------------------------------------------- - -module _ {f} {F : Set f Set f} (RA : RawApplicative F) where - - open RawApplicative RA - - sequence : {n} {P : Pred (Fin n) f} - (∀ i F (P i)) F (∀ i P i) - sequence {zero} ∀iPi = pure λ() - sequence {suc n} ∀iPi = ∀-cons <$> ∀iPi zero <*> sequence (∀iPi suc) - -module _ {f} {F : Set f Set f} (RF : RawFunctor F) where - - open RawFunctor RF - - sequence⁻¹ : {A : Set f} {P : Pred A f} - F (∀ i P i) (∀ i F (P i)) - sequence⁻¹ F∀iPi i = f f i) <$> F∀iPi - ------------------------------------------------------------------------- --- If there is an injection from a type A to a finite set, then the type --- has decidable equality. - -module _ {} {S : Setoid a } (inj : Injection S (≡-setoid n)) where - open Setoid S - - inj⇒≟ : B.Decidable _≈_ - inj⇒≟ = Dec.via-injection inj _≟_ - - inj⇒decSetoid : DecSetoid a - inj⇒decSetoid = record - { isDecEquivalence = record - { isEquivalence = isEquivalence - ; _≟_ = inj⇒≟ - } - } - ------------------------------------------------------------------------- --- Opposite ------------------------------------------------------------------------- - -opposite-prop : (i : Fin n) toℕ (opposite i) n suc (toℕ i) -opposite-prop {suc n} zero = toℕ-fromℕ n -opposite-prop {suc n} (suc i) = begin - toℕ (inject₁ (opposite i)) ≡⟨ toℕ-inject₁ (opposite i) - toℕ (opposite i) ≡⟨ opposite-prop i - n suc (toℕ i) - where open ≡-Reasoning - -opposite-involutive : Involutive {A = Fin n} _≡_ opposite -opposite-involutive {suc n} i = toℕ-injective (begin - toℕ (opposite (opposite i)) ≡⟨ opposite-prop (opposite i) - n (toℕ (opposite i)) ≡⟨ cong (n ∸_) (opposite-prop i) - n (n (toℕ i)) ≡⟨ ℕ.m∸[m∸n]≡n (toℕ≤pred[n] i) - toℕ i ) - where open ≡-Reasoning - -opposite-suc : (i : Fin n) toℕ (opposite (suc i)) toℕ (opposite i) -opposite-suc {n} i = begin - toℕ (opposite (suc i)) ≡⟨ opposite-prop (suc i) - suc n suc (toℕ (suc i)) ≡⟨⟩ - n toℕ (suc i) ≡⟨⟩ - n suc (toℕ i) ≡⟨ opposite-prop i - toℕ (opposite i) - where open ≡-Reasoning - - ------------------------------------------------------------------------- --- DEPRECATED NAMES ------------------------------------------------------------------------- --- Please use the new names as continuing support for the old names is --- not guaranteed. - --- Version 1.5 - -inject+-raise-splitAt = join-splitAt -{-# WARNING_ON_USAGE inject+-raise-splitAt -"Warning: inject+-raise-splitAt was deprecated in v1.5. +<-respˡ-≡ : (_<_ {m} {n}) Respectsˡ _≡_ +<-respˡ-≡ refl x≤y = x≤y + +<-respʳ-≡ : (_<_ {m} {n}) Respectsʳ _≡_ +<-respʳ-≡ refl x≤y = x≤y + +<-resp₂-≡ : (_<_ {n}) Respects₂ _≡_ +<-resp₂-≡ = <-respʳ-≡ , <-respˡ-≡ + +<-irrelevant : Irrelevant (_<_ {m} {n}) +<-irrelevant = ℕ.<-irrelevant + +------------------------------------------------------------------------ +-- Structures + +<-isStrictPartialOrder : IsStrictPartialOrder {A = Fin n} _≡_ _<_ +<-isStrictPartialOrder = record + { isEquivalence = ≡.isEquivalence + ; irrefl = <-irrefl + ; trans = <-trans + ; <-resp-≈ = <-resp₂-≡ + } + +<-isStrictTotalOrder : IsStrictTotalOrder {A = Fin n} _≡_ _<_ +<-isStrictTotalOrder = record + { isStrictPartialOrder = <-isStrictPartialOrder + ; compare = <-cmp + } + +------------------------------------------------------------------------ +-- Bundles + +<-strictPartialOrder : StrictPartialOrder _ _ _ +<-strictPartialOrder n = record + { isStrictPartialOrder = <-isStrictPartialOrder {n} + } + +<-strictTotalOrder : StrictTotalOrder _ _ _ +<-strictTotalOrder n = record + { isStrictTotalOrder = <-isStrictTotalOrder {n} + } + +------------------------------------------------------------------------ +-- Other properties + +i<1+i : (i : Fin n) i < suc i +i<1+i = ℕ.n<1+n toℕ + +<⇒≢ : i < j i j +<⇒≢ i<i refl = ℕ.n≮n _ i<i + +≤∧≢⇒< : i j i j i < j +≤∧≢⇒< {i = zero} {zero} _ 0≢0 = contradiction refl 0≢0 +≤∧≢⇒< {i = zero} {suc j} _ _ = z<s +≤∧≢⇒< {i = suc i} {suc j} 1+i≤1+j 1+i≢1+j = + s<s (≤∧≢⇒< (ℕ.s≤s⁻¹ 1+i≤1+j) (1+i≢1+j (cong suc))) + +------------------------------------------------------------------------ +-- inject +------------------------------------------------------------------------ + +toℕ-inject : {i : Fin n} (j : Fin′ i) toℕ (inject j) toℕ j +toℕ-inject {i = suc i} zero = refl +toℕ-inject {i = suc i} (suc j) = cong suc (toℕ-inject j) + +------------------------------------------------------------------------ +-- inject₁ +------------------------------------------------------------------------ + +fromℕ≢inject₁ : fromℕ n inject₁ i +fromℕ≢inject₁ {i = suc i} eq = fromℕ≢inject₁ {i = i} (suc-injective eq) + +inject₁-injective : inject₁ i inject₁ j i j +inject₁-injective {i = zero} {zero} i≡j = refl +inject₁-injective {i = suc i} {suc j} i≡j = + cong suc (inject₁-injective (suc-injective i≡j)) + +toℕ-inject₁ : (i : Fin n) toℕ (inject₁ i) toℕ i +toℕ-inject₁ zero = refl +toℕ-inject₁ (suc i) = cong suc (toℕ-inject₁ i) + +toℕ-inject₁-≢ : (i : Fin n) n toℕ (inject₁ i) +toℕ-inject₁-≢ (suc i) = toℕ-inject₁-≢ i ℕ.suc-injective + +inject₁ℕ< : (i : Fin n) toℕ (inject₁ i) ℕ.< n +inject₁ℕ< i rewrite toℕ-inject₁ i = toℕ<n i + +inject₁ℕ≤ : (i : Fin n) toℕ (inject₁ i) ℕ.≤ n +inject₁ℕ≤ = ℕ.<⇒≤ inject₁ℕ< + +≤̄⇒inject₁< : i j inject₁ i < suc j +≤̄⇒inject₁< {i = i} i≤j rewrite sym (toℕ-inject₁ i) = s<s i≤j + +ℕ<⇒inject₁< : {i : Fin (ℕ.suc n)} {j : Fin n} j < i inject₁ j < i +ℕ<⇒inject₁< {i = suc i} j≤i = ≤̄⇒inject₁< (ℕ.s≤s⁻¹ j≤i) + +i≤inject₁[j]⇒i≤1+j : i inject₁ j i suc j +i≤inject₁[j]⇒i≤1+j {i = zero} _ = z≤n +i≤inject₁[j]⇒i≤1+j {i = suc i} {j = suc j} i≤j = s≤s (ℕ.m≤n⇒m≤1+n (subst (toℕ i ℕ.≤_) (toℕ-inject₁ j) (ℕ.s≤s⁻¹ i≤j))) + +------------------------------------------------------------------------ +-- inject! +------------------------------------------------------------------------ + +inject!-injective : {i : Fin (suc n)} Injective _≡_ _≡_ (inject! {i = i}) +inject!-injective {n = suc n} {i = suc i} {0F} {0F} refl = refl +inject!-injective {n = suc n} {i = suc i} {suc x} {suc y} eq = + cong suc (inject!-injective (suc-injective eq)) + +inject!-< : {i : Fin (suc n)} (k : Fin′ i) inject! k < i +inject!-< {suc n} {suc i} 0F = s≤s z≤n +inject!-< {suc n} {suc i} (suc k) = s≤s (inject!-< k) + +------------------------------------------------------------------------ +-- lower₁ +------------------------------------------------------------------------ + +toℕ-lower₁ : i (p : n toℕ i) toℕ (lower₁ i p) toℕ i +toℕ-lower₁ {ℕ.zero} zero p = contradiction refl p +toℕ-lower₁ {ℕ.suc m} zero p = refl +toℕ-lower₁ {ℕ.suc m} (suc i) p = cong ℕ.suc (toℕ-lower₁ i (p cong ℕ.suc)) + +lower₁-injective : {n≢i : n toℕ i} {n≢j : n toℕ j} + lower₁ i n≢i lower₁ j n≢j i j +lower₁-injective {zero} {zero} {_} {n≢i} {_} _ = contradiction refl n≢i +lower₁-injective {zero} {_} {zero} {_} {n≢j} _ = contradiction refl n≢j +lower₁-injective {suc n} {zero} {zero} {_} {_} refl = refl +lower₁-injective {suc n} {suc i} {suc j} {n≢i} {n≢j} eq = + cong suc (lower₁-injective (suc-injective eq)) + +------------------------------------------------------------------------ +-- inject₁ and lower₁ + +inject₁-lower₁ : (i : Fin (suc n)) (n≢i : n toℕ i) + inject₁ (lower₁ i n≢i) i +inject₁-lower₁ {zero} zero 0≢0 = contradiction refl 0≢0 +inject₁-lower₁ {suc n} zero _ = refl +inject₁-lower₁ {suc n} (suc i) n+1≢i+1 = + cong suc (inject₁-lower₁ i (n+1≢i+1 cong suc)) + +lower₁-inject₁′ : (i : Fin n) (n≢i : n toℕ (inject₁ i)) + lower₁ (inject₁ i) n≢i i +lower₁-inject₁′ zero _ = refl +lower₁-inject₁′ (suc i) n+1≢i+1 = + cong suc (lower₁-inject₁′ i (n+1≢i+1 cong suc)) + +lower₁-inject₁ : (i : Fin n) + lower₁ (inject₁ i) (toℕ-inject₁-≢ i) i +lower₁-inject₁ i = lower₁-inject₁′ i (toℕ-inject₁-≢ i) + +lower₁-irrelevant : (i : Fin (suc n)) (n≢i₁ n≢i₂ : n toℕ i) + lower₁ i n≢i₁ lower₁ i n≢i₂ +lower₁-irrelevant {zero} zero 0≢0 _ = contradiction refl 0≢0 +lower₁-irrelevant {suc n} zero _ _ = refl +lower₁-irrelevant {suc n} (suc i) _ _ = + cong suc (lower₁-irrelevant i _ _) + +inject₁≡⇒lower₁≡ : {i : Fin n} {j : Fin (ℕ.suc n)} + (n≢j : n toℕ j) inject₁ i j lower₁ j n≢j i +inject₁≡⇒lower₁≡ n≢j i≡j = inject₁-injective (trans (inject₁-lower₁ _ n≢j) (sym i≡j)) + +------------------------------------------------------------------------ +-- lower +------------------------------------------------------------------------ + +lower-injective : (i j : Fin m) + .{i<n : toℕ i ℕ.< n} .{j<n : toℕ j ℕ.< n} + lower i i<n lower j j<n i j +lower-injective {n = suc n} zero zero eq = refl +lower-injective {n = suc n} (suc i) (suc j) eq = + cong suc (lower-injective i j (suc-injective eq)) + +------------------------------------------------------------------------ +-- inject≤ +------------------------------------------------------------------------ + +toℕ-inject≤ : i .(m≤n : m ℕ.≤ n) toℕ (inject≤ i m≤n) toℕ i +toℕ-inject≤ {_} {suc n} zero _ = refl +toℕ-inject≤ {_} {suc n} (suc i) _ = cong suc (toℕ-inject≤ i _) + +inject≤-refl : i .(n≤n : n ℕ.≤ n) inject≤ i n≤n i +inject≤-refl {suc n} zero _ = refl +inject≤-refl {suc n} (suc i) _ = cong suc (inject≤-refl i _) + +inject≤-idempotent : (i : Fin m) + .(m≤n : m ℕ.≤ n) .(n≤o : n ℕ.≤ o) .(m≤o : m ℕ.≤ o) + inject≤ (inject≤ i m≤n) n≤o inject≤ i m≤o +inject≤-idempotent {_} {suc n} {suc o} zero _ _ _ = refl +inject≤-idempotent {_} {suc n} {suc o} (suc i) _ _ _ = + cong suc (inject≤-idempotent i _ _ _) + +inject≤-trans : (i : Fin m) .(m≤n : m ℕ.≤ n) .(n≤o : n ℕ.≤ o) + inject≤ (inject≤ i m≤n) n≤o inject≤ i (ℕ.≤-trans m≤n n≤o) +inject≤-trans i _ _ = inject≤-idempotent i _ _ _ + +inject≤-injective : .(m≤n m≤n′ : m ℕ.≤ n) i j + inject≤ i m≤n inject≤ j m≤n′ i j +inject≤-injective {n = suc _} _ _ zero zero eq = refl +inject≤-injective {n = suc _} _ _ (suc i) (suc j) eq = + cong suc (inject≤-injective _ _ i j (suc-injective eq)) + +inject≤-irrelevant : .(m≤n m≤n′ : m ℕ.≤ n) i + inject≤ i m≤n inject≤ i m≤n′ +inject≤-irrelevant _ _ i = refl + +------------------------------------------------------------------------ +-- pred +------------------------------------------------------------------------ + +pred< : (i : Fin (suc n)) i zero pred i < i +pred< zero i≢0 = contradiction refl i≢0 +pred< (suc i) _ = ≤̄⇒inject₁< ℕ.≤-refl + +------------------------------------------------------------------------ +-- splitAt +------------------------------------------------------------------------ + +-- Fin (m + n) ↔ Fin m ⊎ Fin n + +splitAt-↑ˡ : m i n splitAt m (i ↑ˡ n) inj₁ i +splitAt-↑ˡ (suc m) zero n = refl +splitAt-↑ˡ (suc m) (suc i) n rewrite splitAt-↑ˡ m i n = refl + +splitAt⁻¹-↑ˡ : {m} {n} {i} {j} splitAt m {n} i inj₁ j j ↑ˡ n i +splitAt⁻¹-↑ˡ {suc m} {n} {0F} {.0F} refl = refl +splitAt⁻¹-↑ˡ {suc m} {n} {suc i} {j} eq + with inj₁ ksplitAt m i in splitAt[m][i]≡inj₁[j] + with refleq + = cong suc (splitAt⁻¹-↑ˡ {i = i} {j = k} splitAt[m][i]≡inj₁[j]) + +splitAt-↑ʳ : m n i splitAt m (m ↑ʳ i) inj₂ {B = Fin n} i +splitAt-↑ʳ zero n i = refl +splitAt-↑ʳ (suc m) n i rewrite splitAt-↑ʳ m n i = refl + +splitAt⁻¹-↑ʳ : {m} {n} {i} {j} splitAt m {n} i inj₂ j m ↑ʳ j i +splitAt⁻¹-↑ʳ {zero} {n} {i} {j} refl = refl +splitAt⁻¹-↑ʳ {suc m} {n} {suc i} {j} eq + with inj₂ ksplitAt m i in splitAt[m][i]≡inj₂[k] + with refleq + = cong suc (splitAt⁻¹-↑ʳ {i = i} {j = k} splitAt[m][i]≡inj₂[k]) + +splitAt-join : m n i splitAt m (join m n i) i +splitAt-join m n (inj₁ x) = splitAt-↑ˡ m x n +splitAt-join m n (inj₂ y) = splitAt-↑ʳ m n y + +join-splitAt : m n i join m n (splitAt m i) i +join-splitAt zero n i = refl +join-splitAt (suc m) n zero = refl +join-splitAt (suc m) n (suc i) = begin + [ _↑ˡ n , (suc m) ↑ʳ_ ]′ (splitAt (suc m) (suc i)) ≡⟨ [,]-map (splitAt m i) + [ suc (_↑ˡ n) , suc (m ↑ʳ_) ]′ (splitAt m i) ≡⟨ [,]-∘ suc (splitAt m i) + suc ([ _↑ˡ n , m ↑ʳ_ ]′ (splitAt m i)) ≡⟨ cong suc (join-splitAt m n i) + suc i + where open ≡-Reasoning + +-- splitAt "m" "i" ≡ inj₁ "i" if i < m + +splitAt-< : m {n} (i : Fin (m ℕ.+ n)) .(i<m : toℕ i ℕ.< m) + splitAt m i inj₁ (fromℕ< i<m) +splitAt-< (suc m) zero _ = refl +splitAt-< (suc m) (suc i) i<m = cong (Sum.map suc id) (splitAt-< m i (ℕ.s<s⁻¹ i<m)) + +-- splitAt "m" "i" ≡ inj₂ "i - m" if i ≥ m + +splitAt-≥ : m {n} (i : Fin (m ℕ.+ n)) .(i≥m : toℕ i ℕ.≥ m) + splitAt m i inj₂ (reduce≥ i i≥m) +splitAt-≥ zero i _ = refl +splitAt-≥ (suc m) (suc i) i≥m = cong (Sum.map suc id) (splitAt-≥ m i (ℕ.s≤s⁻¹ i≥m)) + +------------------------------------------------------------------------ +-- Bundles + ++↔⊎ : Fin (m ℕ.+ n) (Fin m Fin n) ++↔⊎ {m} {n} = mk↔ₛ′ (splitAt m {n}) (join m n) (splitAt-join m n) (join-splitAt m n) + +------------------------------------------------------------------------ +-- remQuot +------------------------------------------------------------------------ + +-- Fin (m * n) ↔ Fin m × Fin n + +remQuot-combine : {n k} (i : Fin n) j remQuot k (combine i j) (i , j) +remQuot-combine {suc n} {k} zero j rewrite splitAt-↑ˡ k j (n ℕ.* k) = refl +remQuot-combine {suc n} {k} (suc i) j rewrite splitAt-↑ʳ k (n ℕ.* k) (combine i j) = + cong (Product.map₁ suc) (remQuot-combine i j) + +combine-remQuot : {n} k (i : Fin (n ℕ.* k)) uncurry combine (remQuot {n} k i) i +combine-remQuot {suc n} k i with splitAt k i in eq +... | inj₁ j = begin + join k (n ℕ.* k) (inj₁ j) ≡⟨ cong (join k (n ℕ.* k)) eq + join k (n ℕ.* k) (splitAt k i) ≡⟨ join-splitAt k (n ℕ.* k) i + i + where open ≡-Reasoning +... | inj₂ j = begin + k ↑ʳ (uncurry combine (remQuot {n} k j)) ≡⟨ cong (k ↑ʳ_) (combine-remQuot {n} k j) + join k (n ℕ.* k) (inj₂ j) ≡⟨ cong (join k (n ℕ.* k)) eq + join k (n ℕ.* k) (splitAt k i) ≡⟨ join-splitAt k (n ℕ.* k) i + i + where open ≡-Reasoning + +toℕ-combine : (i : Fin m) (j : Fin n) toℕ (combine i j) n ℕ.* toℕ i ℕ.+ toℕ j +toℕ-combine {suc m} {n} i@0F j = begin + toℕ (combine i j) ≡⟨⟩ + toℕ (j ↑ˡ (m ℕ.* n)) ≡⟨ toℕ-↑ˡ j (m ℕ.* n) + toℕ j ≡⟨⟩ + 0 ℕ.+ toℕ j ≡⟨ cong (ℕ._+ toℕ j) (ℕ.*-zeroʳ n) + n ℕ.* toℕ i ℕ.+ toℕ j + where open ≡-Reasoning +toℕ-combine {suc m} {n} (suc i) j = begin + toℕ (combine (suc i) j) ≡⟨⟩ + toℕ (n ↑ʳ combine i j) ≡⟨ toℕ-↑ʳ n (combine i j) + n ℕ.+ toℕ (combine i j) ≡⟨ cong (n ℕ.+_) (toℕ-combine i j) + n ℕ.+ (n ℕ.* toℕ i ℕ.+ toℕ j) ≡⟨ ℕ.+-assoc n _ (toℕ j) + n ℕ.+ n ℕ.* toℕ i ℕ.+ toℕ j ≡⟨ cong z z ℕ.+ n ℕ.* toℕ i ℕ.+ toℕ j) (ℕ.*-identityʳ n) + n ℕ.* 1 ℕ.+ n ℕ.* toℕ i ℕ.+ toℕ j ≡⟨ cong (ℕ._+ toℕ j) (ℕ.*-distribˡ-+ n 1 (toℕ i) ) + n ℕ.* toℕ (suc i) ℕ.+ toℕ j + where open ≡-Reasoning + +combine-monoˡ-< : {i j : Fin m} (k l : Fin n) + i < j combine i k < combine j l +combine-monoˡ-< {m} {n} {i} {j} k l i<j = begin-strict + toℕ (combine i k) ≡⟨ toℕ-combine i k + n ℕ.* toℕ i ℕ.+ toℕ k <⟨ ℕ.+-monoʳ-< (n ℕ.* toℕ i) (toℕ<n k) + n ℕ.* toℕ i ℕ.+ n ≡⟨ ℕ.+-comm _ n + n ℕ.+ n ℕ.* toℕ i ≡⟨ cong (n ℕ.+_) (ℕ.*-comm n _) + n ℕ.+ toℕ i ℕ.* n ≡⟨ ℕ.*-comm (suc (toℕ i)) n + n ℕ.* suc (toℕ i) ≤⟨ ℕ.*-monoʳ-≤ n (toℕ-mono-< i<j) + n ℕ.* toℕ j ≤⟨ ℕ.m≤m+n (n ℕ.* toℕ j) (toℕ l) + n ℕ.* toℕ j ℕ.+ toℕ l ≡⟨ toℕ-combine j l + toℕ (combine j l) + where open ℕ.≤-Reasoning + +combine-injectiveˡ : (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) + combine i j combine k l i k +combine-injectiveˡ i j k l cᵢⱼ≡cₖₗ with <-cmp i k +... | tri< i<k _ _ = contradiction cᵢⱼ≡cₖₗ (<⇒≢ (combine-monoˡ-< j l i<k)) +... | tri≈ _ i≡k _ = i≡k +... | tri> _ _ i>k = contradiction (sym cᵢⱼ≡cₖₗ) (<⇒≢ (combine-monoˡ-< l j i>k)) + +combine-injectiveʳ : (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) + combine i j combine k l j l +combine-injectiveʳ {m} {n} i j k l cᵢⱼ≡cₖₗ + with reflcombine-injectiveˡ i j k l cᵢⱼ≡cₖₗ + = toℕ-injective (ℕ.+-cancelˡ-≡ (n ℕ.* toℕ i) _ _ (begin + n ℕ.* toℕ i ℕ.+ toℕ j ≡⟨ toℕ-combine i j + toℕ (combine i j) ≡⟨ cong toℕ cᵢⱼ≡cₖₗ + toℕ (combine i l) ≡⟨ toℕ-combine i l + n ℕ.* toℕ i ℕ.+ toℕ l )) + where open ≡-Reasoning + +combine-injective : (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) + combine i j combine k l i k × j l +combine-injective i j k l cᵢⱼ≡cₖₗ = + combine-injectiveˡ i j k l cᵢⱼ≡cₖₗ , + combine-injectiveʳ i j k l cᵢⱼ≡cₖₗ + +combine-surjective : (i : Fin (m ℕ.* n)) ∃₂ λ j k combine j k i +combine-surjective {m} {n} i with j , kremQuot {m} n i in eq + = j , k , (begin + combine j k ≡⟨ uncurry (cong₂ combine) (,-injective eq) + uncurry combine (remQuot {m} n i) ≡⟨ combine-remQuot {m} n i + i ) + where open ≡-Reasoning + +------------------------------------------------------------------------ +-- Bundles + +*↔× : Fin (m ℕ.* n) (Fin m × Fin n) +*↔× {m} {n} = mk↔ₛ′ (remQuot {m} n) (uncurry combine) + (uncurry remQuot-combine) + (combine-remQuot {m} n) + +------------------------------------------------------------------------ +-- fin→fun +------------------------------------------------------------------------ + +funToFin-finToFin : funToFin {m} {n} finToFun id +funToFin-finToFin {zero} {n} zero = refl +funToFin-finToFin {suc m} {n} k = + begin + combine (finToFun {n} {suc m} k zero) (funToFin (finToFun {n} {suc m} k suc)) + ≡⟨⟩ + combine (quotient {n} (n ^ m) k) + (funToFin (finToFun {n} {m} (remainder {n} (n ^ m) k))) + ≡⟨ cong (combine (quotient {n} (n ^ m) k)) + (funToFin-finToFin {m} (remainder {n} (n ^ m) k)) + combine (quotient {n} (n ^ m) k) (remainder {n} (n ^ m) k) + ≡⟨⟩ + uncurry combine (remQuot {n} (n ^ m) k) + ≡⟨ combine-remQuot {n = n} (n ^ m) k + k + where open ≡-Reasoning + +finToFun-funToFin : (f : Fin m Fin n) finToFun (funToFin f) f +finToFun-funToFin {suc m} {n} f zero = + begin + quotient (n ^ m) (combine (f zero) (funToFin (f suc))) + ≡⟨ cong proj₁ (remQuot-combine _ _) + proj₁ (f zero , funToFin (f suc)) + ≡⟨⟩ + f zero + where open ≡-Reasoning +finToFun-funToFin {suc m} {n} f (suc i) = + begin + finToFun (remainder {n} (n ^ m) (combine (f zero) (funToFin (f suc)))) i + ≡⟨ cong rq finToFun (proj₂ rq) i) (remQuot-combine {n} _ _) + finToFun (proj₂ (f zero , funToFin (f suc))) i + ≡⟨⟩ + finToFun (funToFin (f suc)) i + ≡⟨ finToFun-funToFin (f suc) i + (f suc) i + ≡⟨⟩ + f (suc i) + where open ≡-Reasoning + +------------------------------------------------------------------------ +-- Bundles + +^↔→ : Extensionality _ _ Fin (m ^ n) (Fin n Fin m) +^↔→ {m} {n} ext = mk↔ₛ′ finToFun funToFin + (ext finToFun-funToFin) + (funToFin-finToFin {n} {m}) + +------------------------------------------------------------------------ +-- lift +------------------------------------------------------------------------ + +lift-injective : (f : Fin m Fin n) Injective _≡_ _≡_ f + k Injective _≡_ _≡_ (lift k f) +lift-injective f inj zero {_} {_} eq = inj eq +lift-injective f inj (suc k) {zero} {zero} eq = refl +lift-injective f inj (suc k) {suc _} {suc _} eq = + cong suc (lift-injective f inj k (suc-injective eq)) + +------------------------------------------------------------------------ +-- pred +------------------------------------------------------------------------ + +<⇒≤pred : i < j i pred j +<⇒≤pred {i = zero} {j = suc j} z<s = z≤n +<⇒≤pred {i = suc i} {j = suc j} (s<s i<j) rewrite toℕ-inject₁ j = i<j + +------------------------------------------------------------------------ +-- _ℕ-_ +------------------------------------------------------------------------ + +toℕ‿ℕ- : n i toℕ (n ℕ- i) n toℕ i +toℕ‿ℕ- n zero = toℕ-fromℕ n +toℕ‿ℕ- (suc n) (suc i) = toℕ‿ℕ- n i + +------------------------------------------------------------------------ +-- _ℕ-ℕ_ +------------------------------------------------------------------------ + +ℕ-ℕ≡toℕ‿ℕ- : n i n ℕ-ℕ i toℕ (n ℕ- i) +ℕ-ℕ≡toℕ‿ℕ- n zero = sym (toℕ-fromℕ n) +ℕ-ℕ≡toℕ‿ℕ- (suc n) (suc i) = ℕ-ℕ≡toℕ‿ℕ- n i + +nℕ-ℕi≤n : n i n ℕ-ℕ i ℕ.≤ n +nℕ-ℕi≤n n zero = ℕ.≤-refl +nℕ-ℕi≤n (suc n) (suc i) = begin + n ℕ-ℕ i ≤⟨ nℕ-ℕi≤n n i + n ≤⟨ ℕ.n≤1+n n + suc n + where open ℕ.≤-Reasoning + +------------------------------------------------------------------------ +-- punchIn +------------------------------------------------------------------------ + +punchIn-injective : i (j k : Fin n) + punchIn i j punchIn i k j k +punchIn-injective zero _ _ refl = refl +punchIn-injective (suc i) zero zero _ = refl +punchIn-injective (suc i) (suc j) (suc k) ↑j+1≡↑k+1 = + cong suc (punchIn-injective i j k (suc-injective ↑j+1≡↑k+1)) + +punchInᵢ≢i : i (j : Fin n) punchIn i j i +punchInᵢ≢i (suc i) (suc j) = punchInᵢ≢i i j suc-injective + +punchIn-mono-≤ : i (j k : Fin n) j k punchIn i j punchIn i k +punchIn-mono-≤ zero _ _ j≤k = s≤s j≤k +punchIn-mono-≤ (suc _) zero _ z≤n = z≤n +punchIn-mono-≤ (suc i) (suc j) (suc k) (s≤s j≤k) = s≤s (punchIn-mono-≤ i j k j≤k) + +punchIn-cancel-≤ : i (j k : Fin n) punchIn i j punchIn i k j k +punchIn-cancel-≤ zero _ _ (s≤s j≤k) = j≤k +punchIn-cancel-≤ (suc _) zero _ z≤n = z≤n +punchIn-cancel-≤ (suc i) (suc j) (suc k) (s≤s ↑j≤↑k) = s≤s (punchIn-cancel-≤ i j k ↑j≤↑k) + +------------------------------------------------------------------------ +-- punchOut +------------------------------------------------------------------------ + +-- A version of 'cong' for 'punchOut' in which the inequality argument +-- can be changed out arbitrarily (reflecting the proof-irrelevance of +-- that argument). + +punchOut-cong : (i : Fin (suc n)) {j k} {i≢j : i j} {i≢k : i k} + j k punchOut i≢j punchOut i≢k +punchOut-cong {_} zero {zero} {i≢j = 0≢0} = contradiction refl 0≢0 +punchOut-cong {_} zero {suc j} {zero} {i≢k = 0≢0} = contradiction refl 0≢0 +punchOut-cong {_} zero {suc j} {suc k} = suc-injective +punchOut-cong {suc n} (suc i) {zero} {zero} _ = refl +punchOut-cong {suc n} (suc i) {suc j} {suc k} = cong suc punchOut-cong i suc-injective + +-- An alternative to 'punchOut-cong' in the which the new inequality +-- argument is specific. Useful for enabling the omission of that +-- argument during equational reasoning. + +punchOut-cong′ : (i : Fin (suc n)) {j k} {p : i j} (q : j k) + punchOut p punchOut (p sym trans q sym) +punchOut-cong′ i q = punchOut-cong i q + +punchOut-injective : {i j k : Fin (suc n)} + (i≢j : i j) (i≢k : i k) + punchOut i≢j punchOut i≢k j k +punchOut-injective {_} {zero} {zero} {_} 0≢0 _ _ = contradiction refl 0≢0 +punchOut-injective {_} {zero} {_} {zero} _ 0≢0 _ = contradiction refl 0≢0 +punchOut-injective {_} {zero} {suc j} {suc k} _ _ pⱼ≡pₖ = cong suc pⱼ≡pₖ +punchOut-injective {suc n} {suc i} {zero} {zero} _ _ _ = refl +punchOut-injective {suc n} {suc i} {suc j} {suc k} i≢j i≢k pⱼ≡pₖ = + cong suc (punchOut-injective (i≢j cong suc) (i≢k cong suc) (suc-injective pⱼ≡pₖ)) + +punchOut-mono-≤ : {i j k : Fin (suc n)} (i≢j : i j) (i≢k : i k) + j k punchOut i≢j punchOut i≢k +punchOut-mono-≤ {_ } {zero } {zero } {_ } 0≢0 _ z≤n = contradiction refl 0≢0 +punchOut-mono-≤ {_ } {zero } {suc _} {suc _} _ _ (s≤s j≤k) = j≤k +punchOut-mono-≤ {suc _} {suc _} {zero } {_ } _ _ z≤n = z≤n +punchOut-mono-≤ {suc _} {suc _} {suc _} {suc _} i≢j i≢k (s≤s j≤k) = s≤s (punchOut-mono-≤ (i≢j cong suc) (i≢k cong suc) j≤k) + +punchOut-cancel-≤ : {i j k : Fin (suc n)} (i≢j : i j) (i≢k : i k) + punchOut i≢j punchOut i≢k j k +punchOut-cancel-≤ {_ } {zero } {zero } {_ } 0≢0 _ _ = contradiction refl 0≢0 +punchOut-cancel-≤ {_ } {zero } {suc _} {zero } _ 0≢0 _ = contradiction refl 0≢0 +punchOut-cancel-≤ {suc _} {zero } {suc _} {suc _} _ _ pⱼ≤pₖ = s≤s pⱼ≤pₖ +punchOut-cancel-≤ {_ } {suc _} {zero } {_ } _ _ _ = z≤n +punchOut-cancel-≤ {suc _} {suc _} {suc _} {zero } _ _ () +punchOut-cancel-≤ {suc _} {suc _} {suc _} {suc _} i≢j i≢k (s≤s pⱼ≤pₖ) = s≤s (punchOut-cancel-≤ (i≢j cong suc) (i≢k cong suc) pⱼ≤pₖ) + +punchIn-punchOut : {i j : Fin (suc n)} (i≢j : i j) + punchIn i (punchOut i≢j) j +punchIn-punchOut {_} {zero} {zero} 0≢0 = contradiction refl 0≢0 +punchIn-punchOut {_} {zero} {suc j} _ = refl +punchIn-punchOut {suc m} {suc i} {zero} i≢j = refl +punchIn-punchOut {suc m} {suc i} {suc j} i≢j = + cong suc (punchIn-punchOut (i≢j cong suc)) + +punchOut-punchIn : i {j : Fin n} punchOut {i = i} {j = punchIn i j} (punchInᵢ≢i i j sym) j +punchOut-punchIn zero {j} = refl +punchOut-punchIn (suc i) {zero} = refl +punchOut-punchIn (suc i) {suc j} = cong suc (begin + punchOut (punchInᵢ≢i i j suc-injective sym cong suc) ≡⟨ punchOut-cong i refl + punchOut (punchInᵢ≢i i j sym) ≡⟨ punchOut-punchIn i + j ) + where open ≡-Reasoning + + +------------------------------------------------------------------------ +-- pinch +------------------------------------------------------------------------ + +pinch-surjective : (i : Fin n) Surjective _≡_ _≡_ (pinch i) +pinch-surjective _ zero = zero , λ { refl refl } +pinch-surjective zero (suc j) = suc (suc j) , λ { refl refl } +pinch-surjective (suc i) (suc j) = map suc {f refl cong suc (f refl)}) (pinch-surjective i j) + +pinch-mono-≤ : (i : Fin n) Monotonic₁ _≤_ _≤_ (pinch i) +pinch-mono-≤ 0F {0F} {k} 0≤n = z≤n +pinch-mono-≤ 0F {suc j} {suc k} j≤k = ℕ.s≤s⁻¹ j≤k +pinch-mono-≤ (suc i) {0F} {k} 0≤n = z≤n +pinch-mono-≤ (suc i) {suc j} {suc k} j≤k = s≤s (pinch-mono-≤ i (ℕ.s≤s⁻¹ j≤k)) + +pinch-injective : {i : Fin n} {j k : Fin (ℕ.suc n)} + suc i j suc i k pinch i j pinch i k j k +pinch-injective {i = i} {zero} {zero} _ _ _ = refl +pinch-injective {i = zero} {zero} {suc k} _ 1+i≢k eq = + contradiction (cong suc eq) 1+i≢k +pinch-injective {i = zero} {suc j} {zero} 1+i≢j _ eq = + contradiction (cong suc (sym eq)) 1+i≢j +pinch-injective {i = zero} {suc j} {suc k} _ _ eq = + cong suc eq +pinch-injective {i = suc i} {suc j} {suc k} 1+i≢j 1+i≢k eq = + cong suc + (pinch-injective (1+i≢j cong suc) (1+i≢k cong suc) + (suc-injective eq)) + +------------------------------------------------------------------------ +-- Quantification +------------------------------------------------------------------------ + +module _ {p} {P : Pred (Fin (suc n)) p} where + + ∀-cons : P zero Π[ P suc ] Π[ P ] + ∀-cons z s zero = z + ∀-cons z s (suc i) = s i + + ∀-cons-⇔ : (P zero × Π[ P suc ]) Π[ P ] + ∀-cons-⇔ = mk⇔ (uncurry ∀-cons) < _$ zero , _∘ suc > + + ∃-here : P zero ∃⟨ P + ∃-here = zero ,_ + + ∃-there : ∃⟨ P suc ∃⟨ P + ∃-there = map suc id + + ∃-toSum : ∃⟨ P P zero ∃⟨ P suc + ∃-toSum ( zero , P₀ ) = inj₁ P₀ + ∃-toSum (suc f , P₁₊) = inj₂ (f , P₁₊) + + ⊎⇔∃ : (P zero ∃⟨ P suc ) ∃⟨ P + ⊎⇔∃ = mk⇔ [ ∃-here , ∃-there ] ∃-toSum + +decFinSubset : {p q} {P : Pred (Fin n) p} {Q : Pred (Fin n) q} + Decidable Q (∀ {i} Q i Dec (P i)) Dec (Q P) +decFinSubset {zero} {_} {_} Q? P? = yes λ {} +decFinSubset {suc n} {P = P} {Q} Q? P? + with Q? zero | ∀-cons {P = λ x Q x P x} +... | false because [¬Q0] | cons = + map′ f {x} cons (⊥-elim invert [¬Q0]) x f {x}) x) + f {x} f {suc x}) + (decFinSubset (Q? suc) P?) +... | true because [Q0] | cons = + map′ (uncurry λ P0 rec {x} cons _ P0) x rec {x}) x) + < _$ invert [Q0] , f {x} f {suc x}) > + (P? (invert [Q0]) ×-dec decFinSubset (Q? suc) P?) + +any? : {p} {P : Pred (Fin n) p} Decidable P Dec ( P) +any? {zero} {P = _} P? = no λ { (() , _) } +any? {suc n} {P = P} P? = Dec.map ⊎⇔∃ (P? zero ⊎-dec any? (P? suc)) + +all? : {p} {P : Pred (Fin n) p} Decidable P Dec (∀ f P f) +all? P? = map′ ∀p f ∀p tt) ∀p {x} _ ∀p x) + (decFinSubset U? {f} _ P? f)) + +private + -- A nice computational property of `all?`: + -- The boolean component of the result is exactly the + -- obvious fold of boolean tests (`foldr _∧_ true`). + note : {p} {P : Pred (Fin 3) p} (P? : Decidable P) + λ z Dec.does (all? P?) z + note P? = Dec.does (P? 0F) Dec.does (P? 1F) Dec.does (P? 2F) true + , refl + +-- If a decidable predicate P over a finite set is sometimes false, +-- then we can find the smallest value for which this is the case. + +¬∀⟶∃¬-smallest : n {p} (P : Pred (Fin n) p) Decidable P + ¬ (∀ i P i) λ i ¬ P i × ((j : Fin′ i) P (inject j)) +¬∀⟶∃¬-smallest zero P P? ¬∀P = contradiction (λ()) ¬∀P +¬∀⟶∃¬-smallest (suc n) P P? ¬∀P with P? zero +... | false because [¬P₀] = (zero , invert [¬P₀] , λ ()) +... | true because [P₀] = map suc (map id (∀-cons (invert [P₀]))) + (¬∀⟶∃¬-smallest n (P suc) (P? suc) (¬∀P (∀-cons (invert [P₀])))) + +-- When P is a decidable predicate over a finite set the following +-- lemma can be proved. + +¬∀⟶∃¬ : n {p} (P : Pred (Fin n) p) Decidable P + ¬ (∀ i P i) ( λ i ¬ P i) +¬∀⟶∃¬ n P P? ¬P = map id proj₁ (¬∀⟶∃¬-smallest n P P? ¬P) + +------------------------------------------------------------------------ +-- Properties of functions to and from Fin +------------------------------------------------------------------------ + +-- The pigeonhole principle. + +pigeonhole : m ℕ.< n (f : Fin n Fin m) ∃₂ λ i j i < j × f i f j +pigeonhole z<s f = contradiction (f zero) λ() +pigeonhole (s<s m<n@(s≤s _)) f with any? k f zero f (suc k)) +... | yes (j , f₀≡fⱼ) = zero , suc j , z<s , f₀≡fⱼ +... | no f₀≢fₖ + with i , j , i<j , fᵢ≡fⱼpigeonhole m<n j punchOut (f₀≢fₖ (j ,_ ))) + = suc i , suc j , s<s i<j , punchOut-injective (f₀≢fₖ (i ,_)) _ fᵢ≡fⱼ + +injective⇒≤ : {f : Fin m Fin n} Injective _≡_ _≡_ f m ℕ.≤ n +injective⇒≤ {zero} {_} {f} _ = z≤n +injective⇒≤ {suc _} {zero} {f} _ = contradiction (f zero) ¬Fin0 +injective⇒≤ {suc _} {suc _} {f} inj = s≤s (injective⇒≤ eq + suc-injective (inj (punchOut-injective + (contraInjective inj 0≢1+n) + (contraInjective inj 0≢1+n) eq)))) + +<⇒notInjective : {f : Fin m Fin n} n ℕ.< m ¬ (Injective _≡_ _≡_ f) +<⇒notInjective n<m inj = ℕ.≤⇒≯ (injective⇒≤ inj) n<m + +ℕ→Fin-notInjective : (f : Fin n) ¬ (Injective _≡_ _≡_ f) +ℕ→Fin-notInjective f inj = ℕ.<-irrefl refl + (injective⇒≤ (Comp.injective _≡_ _≡_ _≡_ toℕ-injective inj)) + +-- Cantor-Schröder-Bernstein for finite sets + +cantor-schröder-bernstein : {f : Fin m Fin n} {g : Fin n Fin m} + Injective _≡_ _≡_ f Injective _≡_ _≡_ g + m n +cantor-schröder-bernstein f-inj g-inj = ℕ.≤-antisym + (injective⇒≤ f-inj) (injective⇒≤ g-inj) + +injective⇒existsPivot : {f : Fin n Fin m} Injective _≡_ _≡_ f + (i : Fin n) λ j j i × i f j +injective⇒existsPivot {f = f} f-injective i + with any? j j ≤? i ×-dec i ≤? f j) +... | yes result = result +... | no ¬result = contradiction (injective⇒≤ f∘inject!-injective) ℕ.1+n≰n + where + fj<i : (j : Fin′ (suc i)) f (inject! j) < i + fj<i j with f (inject! j) <? i + ... | yes fj<i = fj<i + ... | no fj≮i = contradiction (_ , ℕ.s≤s⁻¹ (inject!-< j) , ℕ.≮⇒≥ fj≮i) ¬result + + f∘inject! : Fin′ (suc i) Fin′ i + f∘inject! j = lower (f (inject! j)) (fj<i j) + + f∘inject!-injective : Injective _≡_ _≡_ f∘inject! + f∘inject!-injective = inject!-injective f-injective lower-injective _ _ + +------------------------------------------------------------------------ +-- Effectful +------------------------------------------------------------------------ + +module _ {f} {F : Set f Set f} (RA : RawApplicative F) where + + open RawApplicative RA + + sequence : {n} {P : Pred (Fin n) f} + (∀ i F (P i)) F (∀ i P i) + sequence {zero} ∀iPi = pure λ() + sequence {suc n} ∀iPi = ∀-cons <$> ∀iPi zero <*> sequence (∀iPi suc) + +module _ {f} {F : Set f Set f} (RF : RawFunctor F) where + + open RawFunctor RF + + sequence⁻¹ : {A : Set f} {P : Pred A f} + F (∀ i P i) (∀ i F (P i)) + sequence⁻¹ F∀iPi i = f f i) <$> F∀iPi + +------------------------------------------------------------------------ +-- If there is an injection from a type A to a finite set, then the type +-- has decidable equality. + +module _ {} {S : Setoid a } (inj : Injection S (≡-setoid n)) where + open Setoid S + + inj⇒≟ : B.Decidable _≈_ + inj⇒≟ = Dec.via-injection inj _≟_ + + inj⇒decSetoid : DecSetoid a + inj⇒decSetoid = record + { isDecEquivalence = record + { isEquivalence = isEquivalence + ; _≟_ = inj⇒≟ + } + } + +------------------------------------------------------------------------ +-- Opposite +------------------------------------------------------------------------ + +opposite-prop : (i : Fin n) toℕ (opposite i) n suc (toℕ i) +opposite-prop {suc n} zero = toℕ-fromℕ n +opposite-prop {suc n} (suc i) = begin + toℕ (inject₁ (opposite i)) ≡⟨ toℕ-inject₁ (opposite i) + toℕ (opposite i) ≡⟨ opposite-prop i + n suc (toℕ i) + where open ≡-Reasoning + +opposite-involutive : Involutive {A = Fin n} _≡_ opposite +opposite-involutive {suc n} i = toℕ-injective (begin + toℕ (opposite (opposite i)) ≡⟨ opposite-prop (opposite i) + n (toℕ (opposite i)) ≡⟨ cong (n ∸_) (opposite-prop i) + n (n (toℕ i)) ≡⟨ ℕ.m∸[m∸n]≡n (toℕ≤pred[n] i) + toℕ i ) + where open ≡-Reasoning + +opposite-suc : (i : Fin n) toℕ (opposite (suc i)) toℕ (opposite i) +opposite-suc {n} i = begin + toℕ (opposite (suc i)) ≡⟨ opposite-prop (suc i) + suc n suc (toℕ (suc i)) ≡⟨⟩ + n toℕ (suc i) ≡⟨⟩ + n suc (toℕ i) ≡⟨ opposite-prop i + toℕ (opposite i) + where open ≡-Reasoning + + +------------------------------------------------------------------------ +-- DEPRECATED NAMES +------------------------------------------------------------------------ +-- Please use the new names as continuing support for the old names is +-- not guaranteed. + +-- Version 1.5 + +inject+-raise-splitAt = join-splitAt +{-# WARNING_ON_USAGE inject+-raise-splitAt +"Warning: inject+-raise-splitAt was deprecated in v1.5. Please use join-splitAt instead." -#-} +#-} --- Version 2.0 +-- Version 2.0 -toℕ-raise = toℕ-↑ʳ -{-# WARNING_ON_USAGE toℕ-raise -"Warning: toℕ-raise was deprecated in v2.0. +toℕ-raise = toℕ-↑ʳ +{-# WARNING_ON_USAGE toℕ-raise +"Warning: toℕ-raise was deprecated in v2.0. Please use toℕ-↑ʳ instead." -#-} -toℕ-inject+ : {m} n (i : Fin m) toℕ i toℕ (i ↑ˡ n) -toℕ-inject+ n i = sym (toℕ-↑ˡ i n) -{-# WARNING_ON_USAGE toℕ-inject+ -"Warning: toℕ-inject+ was deprecated in v2.0. +#-} +toℕ-inject+ : {m} n (i : Fin m) toℕ i toℕ (i ↑ˡ n) +toℕ-inject+ n i = sym (toℕ-↑ˡ i n) +{-# WARNING_ON_USAGE toℕ-inject+ +"Warning: toℕ-inject+ was deprecated in v2.0. Please use toℕ-↑ˡ instead. NB argument order has been flipped: the left-hand argument is the Fin m the right-hand is the Nat index increment." -#-} -splitAt-inject+ : m n i splitAt m (i ↑ˡ n) inj₁ i -splitAt-inject+ m n i = splitAt-↑ˡ m i n -{-# WARNING_ON_USAGE splitAt-inject+ -"Warning: splitAt-inject+ was deprecated in v2.0. +#-} +splitAt-inject+ : m n i splitAt m (i ↑ˡ n) inj₁ i +splitAt-inject+ m n i = splitAt-↑ˡ m i n +{-# WARNING_ON_USAGE splitAt-inject+ +"Warning: splitAt-inject+ was deprecated in v2.0. Please use splitAt-↑ˡ instead. NB argument order has been flipped." -#-} -splitAt-raise : m n i splitAt m (m ↑ʳ i) inj₂ {B = Fin n} i -splitAt-raise = splitAt-↑ʳ -{-# WARNING_ON_USAGE splitAt-raise -"Warning: splitAt-raise was deprecated in v2.0. +#-} +splitAt-raise : m n i splitAt m (m ↑ʳ i) inj₂ {B = Fin n} i +splitAt-raise = splitAt-↑ʳ +{-# WARNING_ON_USAGE splitAt-raise +"Warning: splitAt-raise was deprecated in v2.0. Please use splitAt-↑ʳ instead." -#-} -Fin0↔⊥ : Fin 0 -Fin0↔⊥ = 0↔⊥ -{-# WARNING_ON_USAGE Fin0↔⊥ -"Warning: Fin0↔⊥ was deprecated in v2.0. +#-} +Fin0↔⊥ : Fin 0 +Fin0↔⊥ = 0↔⊥ +{-# WARNING_ON_USAGE Fin0↔⊥ +"Warning: Fin0↔⊥ was deprecated in v2.0. Please use 0↔⊥ instead." -#-} -eq? : A Fin n DecidableEquality A -eq? = inj⇒≟ -{-# WARNING_ON_USAGE eq? -"Warning: eq? was deprecated in v2.0. +#-} +eq? : A Fin n DecidableEquality A +eq? = inj⇒≟ +{-# WARNING_ON_USAGE eq? +"Warning: eq? was deprecated in v2.0. Please use inj⇒≟ instead." -#-} +#-} -private +private - z≺s : {n} zero suc n - z≺s = _ ≻toℕ zero + z≺s : {n} zero suc n + z≺s = _ ≻toℕ zero - s≺s : {m n} m n suc m suc n - s≺s (n ≻toℕ i) = (suc n) ≻toℕ (suc i) + s≺s : {m n} m n suc m suc n + s≺s (n ≻toℕ i) = (suc n) ≻toℕ (suc i) - <⇒≺ : ℕ._<_ _≺_ - <⇒≺ {zero} z<s = z≺s - <⇒≺ {suc m} (s<s lt) = s≺s (<⇒≺ lt) + <⇒≺ : ℕ._<_ _≺_ + <⇒≺ {zero} z<s = z≺s + <⇒≺ {suc m} (s<s lt) = s≺s (<⇒≺ lt) - ≺⇒< : _≺_ ℕ._<_ - ≺⇒< (n ≻toℕ i) = toℕ<n i + ≺⇒< : _≺_ ℕ._<_ + ≺⇒< (n ≻toℕ i) = toℕ<n i -≺⇒<′ : _≺_ ℕ._<′_ -≺⇒<′ lt = ℕ.<⇒<′ (≺⇒< lt) -{-# WARNING_ON_USAGE ≺⇒<′ -"Warning: ≺⇒<′ was deprecated in v2.0. +≺⇒<′ : _≺_ ℕ._<′_ +≺⇒<′ lt = ℕ.<⇒<′ (≺⇒< lt) +{-# WARNING_ON_USAGE ≺⇒<′ +"Warning: ≺⇒<′ was deprecated in v2.0. Please use <⇒<′ instead." -#-} +#-} -<′⇒≺ : ℕ._<′_ _≺_ -<′⇒≺ lt = <⇒≺ (ℕ.<′⇒< lt) -{-# WARNING_ON_USAGE <′⇒≺ -"Warning: <′⇒≺ was deprecated in v2.0. +<′⇒≺ : ℕ._<′_ _≺_ +<′⇒≺ lt = <⇒≺ (ℕ.<′⇒< lt) +{-# WARNING_ON_USAGE <′⇒≺ +"Warning: <′⇒≺ was deprecated in v2.0. Please use <′⇒< instead." -#-} +#-} \ No newline at end of file diff --git a/v2.3/Data.Fin.Show.html b/v2.3/Data.Fin.Show.html index 0022d78ce5..84e71c504c 100644 --- a/v2.3/Data.Fin.Show.html +++ b/v2.3/Data.Fin.Show.html @@ -11,7 +11,7 @@ open import Data.Fin.Base using (Fin; toℕ; fromℕ<) open import Data.Maybe.Base using (Maybe; nothing; just; _>>=_) -open import Data.Nat as using (; _≤?_; _<?_) +open import Data.Nat as using (; _≤?_; _<?_) import Data.Nat.Show as using (show; readMaybe) open import Data.String.Base using (String) open import Function.Base @@ -21,10 +21,10 @@ show : {n} Fin n String show = ℕ.show ∘′ toℕ -readMaybe : {n} base {base≤16 : True (base ≤? 16)} String Maybe (Fin n) +readMaybe : {n} base {base≤16 : True (base ≤? 16)} String Maybe (Fin n) readMaybe {n} base {pr} str = do nat ℕ.readMaybe base {pr} str - case nat <? n of λ where + case nat <? n of λ where (yes pr) just (fromℕ< pr) (no ¬pr) nothing \ No newline at end of file diff --git a/v2.3/Data.Fin.Subset.Induction.html b/v2.3/Data.Fin.Subset.Induction.html index 4213c015a2..20a288e1c9 100644 --- a/v2.3/Data.Fin.Subset.Induction.html +++ b/v2.3/Data.Fin.Subset.Induction.html @@ -12,7 +12,7 @@ open import Data.Nat.Base using () open import Data.Nat.Induction using (<-wellFounded) open import Data.Fin.Subset using (Subset; ; _⊂_; _⊃_; ∣_∣) -open import Data.Fin.Subset.Properties using (p⊂q⇒∣p∣<∣q∣; p⊂q⇒∁p⊃∁q) +open import Data.Fin.Subset.Properties using (p⊂q⇒∣p∣<∣q∣; p⊂q⇒∁p⊃∁q) open import Induction using (RecStruct) open import Induction.WellFounded as WF open import Level using (Level) @@ -45,6 +45,6 @@ ⊃-Rec = WfRec _⊃_ ⊃-wellFounded : WellFounded {A = Subset n} _⊃_ -⊃-wellFounded = Subrelation.wellFounded p⊂q⇒∁p⊃∁q +⊃-wellFounded = Subrelation.wellFounded p⊂q⇒∁p⊃∁q (On.wellFounded ⊂-wellFounded) \ No newline at end of file diff --git a/v2.3/Data.Fin.Subset.Properties.html b/v2.3/Data.Fin.Subset.Properties.html index 714436e758..2f6692a9d5 100644 --- a/v2.3/Data.Fin.Subset.Properties.html +++ b/v2.3/Data.Fin.Subset.Properties.html @@ -27,7 +27,7 @@ open import Data.Bool.Properties open import Data.Fin.Base using (Fin; suc; zero) open import Data.Fin.Subset -open import Data.Fin.Properties using (any?; decFinSubset) +open import Data.Fin.Properties using (any?; decFinSubset) open import Data.Nat.Base hiding (∣_-_∣) import Data.Nat.Properties as open import Data.Product as Product using (; ; _×_; _,_; proj₁) @@ -48,7 +48,7 @@ open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning; isEquivalence) open import Relation.Nullary.Decidable as Dec using (Dec; yes; no; _⊎-dec_) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Unary using (Pred; Decidable; Satisfiable) private @@ -66,13 +66,13 @@ drop-there (there x∈p) = x∈p drop-not-there : suc x s p x p -drop-not-there x∉sp x∈p = contradiction (there x∈p) x∉sp +drop-not-there x∉sp x∈p = contradiction (there x∈p) x∉sp drop-∷-⊆ : s p t q p q drop-∷-⊆ sp⊆tq x∈p = drop-there (sp⊆tq (there x∈p)) drop-∷-⊂ : s p s q p q -drop-∷-⊂ {s = inside} (_ , zero , _ , x∉sp) = contradiction here x∉sp +drop-∷-⊂ {s = inside} (_ , zero , _ , x∉sp) = contradiction here x∉sp drop-∷-⊂ {s} (sp⊆sq , suc x , there x∈q , x∉sp) = drop-∷-⊆ sp⊆sq , x , x∈q , drop-not-there x∉sp out⊆ : p q outside p s q @@ -130,12 +130,12 @@ Empty-unique : Empty p p Empty-unique {p = []} ¬∃∈ = refl -Empty-unique {p = inside p} ¬∃∈ = contradiction (zero , here) ¬∃∈ +Empty-unique {p = inside p} ¬∃∈ = contradiction (zero , here) ¬∃∈ Empty-unique {p = outside p} ¬∃∈ = cong (outside ∷_) (Empty-unique (drop-∷-Empty ¬∃∈)) nonempty? : Decidable {A = Subset n} Nonempty -nonempty? p = any? (_∈? p) +nonempty? p = any? (_∈? p) ------------------------------------------------------------------------ -- ∣_∣ @@ -144,8 +144,8 @@ ∣p∣≤n = count≤n (_≟ inside) ∣p∣≤∣x∷p∣ : x (p : Subset n) p x p -∣p∣≤∣x∷p∣ outside p = ℕ.≤-refl -∣p∣≤∣x∷p∣ inside p = ℕ.n≤1+n p +∣p∣≤∣x∷p∣ outside p = ℕ.≤-refl +∣p∣≤∣x∷p∣ inside p = ℕ.n≤1+n p ------------------------------------------------------------------------ -- ⊥ @@ -154,7 +154,7 @@ ∉⊥ (there p) = ∉⊥ p ⊥⊆ : p -⊥⊆ x∈⊥ = contradiction x∈⊥ ∉⊥ +⊥⊆ x∈⊥ = contradiction x∈⊥ ∉⊥ ∣⊥∣≡0 : n {n = n} 0 ∣⊥∣≡0 zero = refl @@ -176,7 +176,7 @@ ∣p∣≡n⇒p≡⊤ : p n p {n} ∣p∣≡n⇒p≡⊤ {p = []} _ = refl -∣p∣≡n⇒p≡⊤ {p = outside p} |p|≡n = contradiction |p|≡n (ℕ.<⇒≢ (s≤s (∣p∣≤n p))) +∣p∣≡n⇒p≡⊤ {p = outside p} |p|≡n = contradiction |p|≡n (ℕ.<⇒≢ (s≤s (∣p∣≤n p))) ∣p∣≡n⇒p≡⊤ {p = inside p} |p|≡n = cong (inside ∷_) (∣p∣≡n⇒p≡⊤ (ℕ.suc-injective |p|≡n)) ------------------------------------------------------------------------ @@ -188,7 +188,7 @@ x∈⁅y⁆⇒x≡y : {x} (y : Fin n) x y x y x∈⁅y⁆⇒x≡y zero here = refl -x∈⁅y⁆⇒x≡y zero (there p) = contradiction p ∉⊥ +x∈⁅y⁆⇒x≡y zero (there p) = contradiction p ∉⊥ x∈⁅y⁆⇒x≡y (suc y) (there p) = cong suc (x∈⁅y⁆⇒x≡y y p) x∈⁅y⁆⇔x≡y : x y x y @@ -222,8 +222,8 @@ ⊆-antisym {i = []} {[]} p⊆q q⊆p = refl ⊆-antisym {i = x xs} {y ys} p⊆q q⊆p with x | y ... | inside | inside = cong₂ _∷_ refl (⊆-antisym (drop-∷-⊆ p⊆q) (drop-∷-⊆ q⊆p)) -... | inside | outside = contradiction (p⊆q here) λ() -... | outside | inside = contradiction (q⊆p here) λ() +... | inside | outside = contradiction (p⊆q here) λ() +... | outside | inside = contradiction (q⊆p here) λ() ... | outside | outside = cong₂ _∷_ refl (⊆-antisym (drop-∷-⊆ p⊆q) (drop-∷-⊆ q⊆p)) ⊆-min : Minimum {A = Subset n} _⊆_ @@ -267,8 +267,8 @@ p⊆q⇒∣p∣≤∣q∣ : p q p q p⊆q⇒∣p∣≤∣q∣ {p = []} {[]} p⊆q = z≤n p⊆q⇒∣p∣≤∣q∣ {p = outside p} {outside q} p⊆q = p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ p⊆q) -p⊆q⇒∣p∣≤∣q∣ {p = outside p} {inside q} p⊆q = ℕ.m≤n⇒m≤1+n (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ p⊆q)) -p⊆q⇒∣p∣≤∣q∣ {p = inside p} {outside q} p⊆q = contradiction (p⊆q here) λ() +p⊆q⇒∣p∣≤∣q∣ {p = outside p} {inside q} p⊆q = ℕ.m≤n⇒m≤1+n (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ p⊆q)) +p⊆q⇒∣p∣≤∣q∣ {p = inside p} {outside q} p⊆q = contradiction (p⊆q here) λ() p⊆q⇒∣p∣≤∣q∣ {p = inside p} {inside q} p⊆q = s≤s (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ p⊆q)) @@ -288,13 +288,13 @@ ⊆-⊂-trans p⊆q (q⊆r , x , x∈r , x∉q) = ⊆-trans p⊆q q⊆r , x , x∈r , x∉q p⊆q ⊂-irref : Irreflexive {A = Subset n} _≡_ _⊂_ -⊂-irref refl (_ , x , x∈p , x∉q) = contradiction x∈p x∉q +⊂-irref refl (_ , x , x∈p , x∉q) = contradiction x∈p x∉q ⊂-antisym : Antisymmetric {A = Subset n} _≡_ _⊂_ ⊂-antisym (p⊆q , _) (q⊆p , _) = ⊆-antisym p⊆q q⊆p ⊂-asymmetric : Asymmetric {A = Subset n} _⊂_ -⊂-asymmetric (p⊆q , _) (_ , x , x∈p , x∉q) = contradiction (p⊆q x∈p) x∉q +⊂-asymmetric (p⊆q , _) (_ , x , x∈p , x∉q) = contradiction (p⊆q x∈p) x∉q infix 4 _⊂?_ @@ -335,8 +335,8 @@ p⊂q⇒∣p∣<∣q∣ : p q p < q p⊂q⇒∣p∣<∣q∣ {p = outside p} {outside q} op⊂oq@(_ , _ , _ , _) = p⊂q⇒∣p∣<∣q∣ (drop-∷-⊂ op⊂oq) p⊂q⇒∣p∣<∣q∣ {p = outside p} {inside q} (op⊆iq , _ , _ , _) = s≤s (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ op⊆iq)) -p⊂q⇒∣p∣<∣q∣ {p = inside p} {outside q} (ip⊆oq , _ , _ , _) = contradiction (ip⊆oq here) λ() -p⊂q⇒∣p∣<∣q∣ {p = inside p} {inside q} (_ , zero , _ , x∉ip) = contradiction here x∉ip +p⊂q⇒∣p∣<∣q∣ {p = inside p} {outside q} (ip⊆oq , _ , _ , _) = contradiction (ip⊆oq here) λ() +p⊂q⇒∣p∣<∣q∣ {p = inside p} {inside q} (_ , zero , _ , x∉ip) = contradiction here x∉ip p⊂q⇒∣p∣<∣q∣ {p = inside p} {inside q} ip⊂iq@(_ , suc x , _ , _) = s≤s (p⊂q⇒∣p∣<∣q∣ (drop-∷-⊂ ip⊂iq)) ------------------------------------------------------------------------ @@ -349,13 +349,13 @@ x∈∁p⇒x∉p (there x∈∁p) (there x∈p) = x∈∁p⇒x∉p x∈∁p x∈p x∉∁p⇒x∈p : x p x p -x∉∁p⇒x∈p {x = zero} {outside p} x∉∁p = contradiction here x∉∁p +x∉∁p⇒x∈p {x = zero} {outside p} x∉∁p = contradiction here x∉∁p x∉∁p⇒x∈p {x = zero} {inside p} x∉∁p = here x∉∁p⇒x∈p {x = suc x} {_ p} x∉∁p = there (x∉∁p⇒x∈p (x∉∁p there)) x∉p⇒x∈∁p : x p x p x∉p⇒x∈∁p {x = zero} {outside p} x∉p = here -x∉p⇒x∈∁p {x = zero} {inside p} x∉p = contradiction here x∉p +x∉p⇒x∈∁p {x = zero} {inside p} x∉p = contradiction here x∉p x∉p⇒x∈∁p {x = suc x} {_ p} x∉p = there (x∉p⇒x∈∁p (x∉p there)) p∪∁p≡⊤ : (p : Subset n) p p @@ -368,533 +368,533 @@ ∣∁p∣≡n∸∣p∣ (inside p) = ∣∁p∣≡n∸∣p∣ p ∣∁p∣≡n∸∣p∣ (outside p) = begin suc p ≡⟨ cong suc (∣∁p∣≡n∸∣p∣ p) - suc (_ p ) ≡⟨ sym (ℕ.∸-suc (∣p∣≤n p)) - suc _ p - where open ≡-Reasoning + suc (_ p ) ≡⟨ sym (ℕ.+-∸-assoc 1 (∣p∣≤n p)) + suc _ p + where open ≡-Reasoning -p⊆q⇒∁p⊇∁q : p q p q -p⊆q⇒∁p⊇∁q p⊆q x∈∁q = x∉p⇒x∈∁p (x∈∁p⇒x∉p x∈∁q p⊆q) +p⊆q⇒∁p⊇∁q : p q p q +p⊆q⇒∁p⊇∁q p⊆q x∈∁q = x∉p⇒x∈∁p (x∈∁p⇒x∉p x∈∁q p⊆q) -∁p⊆∁q⇒p⊇q : p q p q -∁p⊆∁q⇒p⊇q ∁p⊆∁q x∈q = x∉∁p⇒x∈p (x∈p⇒x∉∁p x∈q ∁p⊆∁q) +∁p⊆∁q⇒p⊇q : p q p q +∁p⊆∁q⇒p⊇q ∁p⊆∁q x∈q = x∉∁p⇒x∈p (x∈p⇒x∉∁p x∈q ∁p⊆∁q) -p⊂q⇒∁p⊃∁q : p q p q -p⊂q⇒∁p⊃∁q (p⊆q , x , x∈q , x∉p) = p⊆q⇒∁p⊇∁q p⊆q , x , x∉p⇒x∈∁p x∉p , x∈p⇒x∉∁p x∈q +p⊂q⇒∁p⊃∁q : p q p q +p⊂q⇒∁p⊃∁q (p⊆q , x , x∈q , x∉p) = p⊆q⇒∁p⊇∁q p⊆q , x , x∉p⇒x∈∁p x∉p , x∈p⇒x∉∁p x∈q -∁p⊂∁q⇒p⊃q : p q p q -∁p⊂∁q⇒p⊃q (∁p⊆∁q , x , x∈∁q , x∉∁p) = ∁p⊆∁q⇒p⊇q ∁p⊆∁q , x , x∉∁p⇒x∈p x∉∁p , x∈∁p⇒x∉p x∈∁q +∁p⊂∁q⇒p⊃q : p q p q +∁p⊂∁q⇒p⊃q (∁p⊆∁q , x , x∈∁q , x∉∁p) = ∁p⊆∁q⇒p⊇q ∁p⊆∁q , x , x∉∁p⇒x∈p x∉∁p , x∈∁p⇒x∉p x∈∁q ------------------------------------------------------------------------- --- _∩_ +------------------------------------------------------------------------ +-- _∩_ -module _ {n : } where +module _ {n : } where - open AlgebraicDefinitions {A = Subset n} _≡_ + open AlgebraicDefinitions {A = Subset n} _≡_ - ∩-assoc : Associative _∩_ - ∩-assoc = zipWith-assoc ∧-assoc + ∩-assoc : Associative _∩_ + ∩-assoc = zipWith-assoc ∧-assoc - ∩-comm : Commutative _∩_ - ∩-comm = zipWith-comm ∧-comm + ∩-comm : Commutative _∩_ + ∩-comm = zipWith-comm ∧-comm - ∩-idem : Idempotent _∩_ - ∩-idem = zipWith-idem ∧-idem + ∩-idem : Idempotent _∩_ + ∩-idem = zipWith-idem ∧-idem - ∩-identityˡ : LeftIdentity _∩_ - ∩-identityˡ = zipWith-identityˡ ∧-identityˡ + ∩-identityˡ : LeftIdentity _∩_ + ∩-identityˡ = zipWith-identityˡ ∧-identityˡ - ∩-identityʳ : RightIdentity _∩_ - ∩-identityʳ = zipWith-identityʳ ∧-identityʳ + ∩-identityʳ : RightIdentity _∩_ + ∩-identityʳ = zipWith-identityʳ ∧-identityʳ - ∩-identity : Identity _∩_ - ∩-identity = ∩-identityˡ , ∩-identityʳ + ∩-identity : Identity _∩_ + ∩-identity = ∩-identityˡ , ∩-identityʳ - ∩-zeroˡ : LeftZero _∩_ - ∩-zeroˡ = zipWith-zeroˡ ∧-zeroˡ + ∩-zeroˡ : LeftZero _∩_ + ∩-zeroˡ = zipWith-zeroˡ ∧-zeroˡ - ∩-zeroʳ : RightZero _∩_ - ∩-zeroʳ = zipWith-zeroʳ ∧-zeroʳ + ∩-zeroʳ : RightZero _∩_ + ∩-zeroʳ = zipWith-zeroʳ ∧-zeroʳ - ∩-zero : Zero _∩_ - ∩-zero = ∩-zeroˡ , ∩-zeroʳ + ∩-zero : Zero _∩_ + ∩-zero = ∩-zeroˡ , ∩-zeroʳ - ∩-inverseˡ : LeftInverse _∩_ - ∩-inverseˡ = zipWith-inverseˡ ∧-inverseˡ + ∩-inverseˡ : LeftInverse _∩_ + ∩-inverseˡ = zipWith-inverseˡ ∧-inverseˡ - ∩-inverseʳ : RightInverse _∩_ - ∩-inverseʳ = zipWith-inverseʳ ∧-inverseʳ + ∩-inverseʳ : RightInverse _∩_ + ∩-inverseʳ = zipWith-inverseʳ ∧-inverseʳ - ∩-inverse : Inverse _∩_ - ∩-inverse = ∩-inverseˡ , ∩-inverseʳ + ∩-inverse : Inverse _∩_ + ∩-inverse = ∩-inverseˡ , ∩-inverseʳ -module _ (n : ) where +module _ (n : ) where - open AlgebraicStructures {A = Subset n} _≡_ - open AlgebraicLatticeStructures {A = Subset n} _≡_ + open AlgebraicStructures {A = Subset n} _≡_ + open AlgebraicLatticeStructures {A = Subset n} _≡_ - ∩-isMagma : IsMagma _∩_ - ∩-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = cong₂ _∩_ - } + ∩-isMagma : IsMagma _∩_ + ∩-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = cong₂ _∩_ + } - ∩-isSemigroup : IsSemigroup _∩_ - ∩-isSemigroup = record - { isMagma = ∩-isMagma - ; assoc = ∩-assoc - } + ∩-isSemigroup : IsSemigroup _∩_ + ∩-isSemigroup = record + { isMagma = ∩-isMagma + ; assoc = ∩-assoc + } - ∩-isBand : IsBand _∩_ - ∩-isBand = record - { isSemigroup = ∩-isSemigroup - ; idem = ∩-idem - } + ∩-isBand : IsBand _∩_ + ∩-isBand = record + { isSemigroup = ∩-isSemigroup + ; idem = ∩-idem + } - ∩-isSemilattice : IsSemilattice _∩_ - ∩-isSemilattice = record - { isBand = ∩-isBand - ; comm = ∩-comm - } + ∩-isSemilattice : IsSemilattice _∩_ + ∩-isSemilattice = record + { isBand = ∩-isBand + ; comm = ∩-comm + } - ∩-isMonoid : IsMonoid _∩_ - ∩-isMonoid = record - { isSemigroup = ∩-isSemigroup - ; identity = ∩-identity - } + ∩-isMonoid : IsMonoid _∩_ + ∩-isMonoid = record + { isSemigroup = ∩-isSemigroup + ; identity = ∩-identity + } - ∩-isCommutativeMonoid : IsCommutativeMonoid _∩_ - ∩-isCommutativeMonoid = record - { isMonoid = ∩-isMonoid - ; comm = ∩-comm - } + ∩-isCommutativeMonoid : IsCommutativeMonoid _∩_ + ∩-isCommutativeMonoid = record + { isMonoid = ∩-isMonoid + ; comm = ∩-comm + } - ∩-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∩_ - ∩-isIdempotentCommutativeMonoid = record - { isCommutativeMonoid = ∩-isCommutativeMonoid - ; idem = ∩-idem - } + ∩-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∩_ + ∩-isIdempotentCommutativeMonoid = record + { isCommutativeMonoid = ∩-isCommutativeMonoid + ; idem = ∩-idem + } - ∩-magma : Magma _ _ - ∩-magma = record - { isMagma = ∩-isMagma - } + ∩-magma : Magma _ _ + ∩-magma = record + { isMagma = ∩-isMagma + } - ∩-semigroup : Semigroup _ _ - ∩-semigroup = record - { isSemigroup = ∩-isSemigroup - } + ∩-semigroup : Semigroup _ _ + ∩-semigroup = record + { isSemigroup = ∩-isSemigroup + } - ∩-band : Band _ _ - ∩-band = record - { isBand = ∩-isBand - } + ∩-band : Band _ _ + ∩-band = record + { isBand = ∩-isBand + } - ∩-semilattice : Semilattice _ _ - ∩-semilattice = record - { isSemilattice = ∩-isSemilattice - } + ∩-semilattice : Semilattice _ _ + ∩-semilattice = record + { isSemilattice = ∩-isSemilattice + } - ∩-monoid : Monoid _ _ - ∩-monoid = record - { isMonoid = ∩-isMonoid - } + ∩-monoid : Monoid _ _ + ∩-monoid = record + { isMonoid = ∩-isMonoid + } - ∩-commutativeMonoid : CommutativeMonoid _ _ - ∩-commutativeMonoid = record - { isCommutativeMonoid = ∩-isCommutativeMonoid - } + ∩-commutativeMonoid : CommutativeMonoid _ _ + ∩-commutativeMonoid = record + { isCommutativeMonoid = ∩-isCommutativeMonoid + } - ∩-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ - ∩-idempotentCommutativeMonoid = record - { isIdempotentCommutativeMonoid = ∩-isIdempotentCommutativeMonoid - } + ∩-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ + ∩-idempotentCommutativeMonoid = record + { isIdempotentCommutativeMonoid = ∩-isIdempotentCommutativeMonoid + } -p∩q⊆p : (p q : Subset n) p q p -p∩q⊆p [] [] x∈p∩q = x∈p∩q -p∩q⊆p (inside p) (inside q) here = here -p∩q⊆p (inside p) (_ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) -p∩q⊆p (outside p) (_ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) +p∩q⊆p : (p q : Subset n) p q p +p∩q⊆p [] [] x∈p∩q = x∈p∩q +p∩q⊆p (inside p) (inside q) here = here +p∩q⊆p (inside p) (_ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) +p∩q⊆p (outside p) (_ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) -p∩q⊆q : (p q : Subset n) p q q -p∩q⊆q p q rewrite ∩-comm p q = p∩q⊆p q p +p∩q⊆q : (p q : Subset n) p q q +p∩q⊆q p q rewrite ∩-comm p q = p∩q⊆p q p -x∈p∩q⁺ : x p × x q x p q -x∈p∩q⁺ (here , here) = here -x∈p∩q⁺ (there x∈p , there x∈q) = there (x∈p∩q⁺ (x∈p , x∈q)) +x∈p∩q⁺ : x p × x q x p q +x∈p∩q⁺ (here , here) = here +x∈p∩q⁺ (there x∈p , there x∈q) = there (x∈p∩q⁺ (x∈p , x∈q)) -x∈p∩q⁻ : (p q : Subset n) x p q x p × x q -x∈p∩q⁻ (inside p) (inside q) here = here , here -x∈p∩q⁻ (s p) (t q) (there x∈p∩q) = - Product.map there there (x∈p∩q⁻ p q x∈p∩q) +x∈p∩q⁻ : (p q : Subset n) x p q x p × x q +x∈p∩q⁻ (inside p) (inside q) here = here , here +x∈p∩q⁻ (s p) (t q) (there x∈p∩q) = + Product.map there there (x∈p∩q⁻ p q x∈p∩q) -∩⇔× : x p q (x p × x q) -∩⇔× = mk⇔ (x∈p∩q⁻ _ _) x∈p∩q⁺ +∩⇔× : x p q (x p × x q) +∩⇔× = mk⇔ (x∈p∩q⁻ _ _) x∈p∩q⁺ -∣p∩q∣≤∣p∣ : (p q : Subset n) p q p -∣p∩q∣≤∣p∣ p q = p⊆q⇒∣p∣≤∣q∣ (p∩q⊆p p q) +∣p∩q∣≤∣p∣ : (p q : Subset n) p q p +∣p∩q∣≤∣p∣ p q = p⊆q⇒∣p∣≤∣q∣ (p∩q⊆p p q) -∣p∩q∣≤∣q∣ : (p q : Subset n) p q q -∣p∩q∣≤∣q∣ p q = p⊆q⇒∣p∣≤∣q∣ (p∩q⊆q p q) +∣p∩q∣≤∣q∣ : (p q : Subset n) p q q +∣p∩q∣≤∣q∣ p q = p⊆q⇒∣p∣≤∣q∣ (p∩q⊆q p q) -∣p∩q∣≤∣p∣⊓∣q∣ : (p q : Subset n) p q p q -∣p∩q∣≤∣p∣⊓∣q∣ p q = ℕ.⊓-glb (∣p∩q∣≤∣p∣ p q) (∣p∩q∣≤∣q∣ p q) +∣p∩q∣≤∣p∣⊓∣q∣ : (p q : Subset n) p q p q +∣p∩q∣≤∣p∣⊓∣q∣ p q = ℕ.⊓-glb (∣p∩q∣≤∣p∣ p q) (∣p∩q∣≤∣q∣ p q) ------------------------------------------------------------------------- --- _∪_ +------------------------------------------------------------------------ +-- _∪_ -module _ {n : } where +module _ {n : } where - open AlgebraicDefinitions {A = Subset n} _≡_ + open AlgebraicDefinitions {A = Subset n} _≡_ - ∪-assoc : Associative _∪_ - ∪-assoc = zipWith-assoc ∨-assoc + ∪-assoc : Associative _∪_ + ∪-assoc = zipWith-assoc ∨-assoc - ∪-comm : Commutative _∪_ - ∪-comm = zipWith-comm ∨-comm + ∪-comm : Commutative _∪_ + ∪-comm = zipWith-comm ∨-comm - ∪-idem : Idempotent _∪_ - ∪-idem = zipWith-idem ∨-idem + ∪-idem : Idempotent _∪_ + ∪-idem = zipWith-idem ∨-idem - ∪-identityˡ : LeftIdentity _∪_ - ∪-identityˡ = zipWith-identityˡ ∨-identityˡ + ∪-identityˡ : LeftIdentity _∪_ + ∪-identityˡ = zipWith-identityˡ ∨-identityˡ - ∪-identityʳ : RightIdentity _∪_ - ∪-identityʳ = zipWith-identityʳ ∨-identityʳ + ∪-identityʳ : RightIdentity _∪_ + ∪-identityʳ = zipWith-identityʳ ∨-identityʳ - ∪-identity : Identity _∪_ - ∪-identity = ∪-identityˡ , ∪-identityʳ + ∪-identity : Identity _∪_ + ∪-identity = ∪-identityˡ , ∪-identityʳ - ∪-zeroˡ : LeftZero _∪_ - ∪-zeroˡ = zipWith-zeroˡ ∨-zeroˡ + ∪-zeroˡ : LeftZero _∪_ + ∪-zeroˡ = zipWith-zeroˡ ∨-zeroˡ - ∪-zeroʳ : RightZero _∪_ - ∪-zeroʳ = zipWith-zeroʳ ∨-zeroʳ + ∪-zeroʳ : RightZero _∪_ + ∪-zeroʳ = zipWith-zeroʳ ∨-zeroʳ - ∪-zero : Zero _∪_ - ∪-zero = ∪-zeroˡ , ∪-zeroʳ + ∪-zero : Zero _∪_ + ∪-zero = ∪-zeroˡ , ∪-zeroʳ - ∪-inverseˡ : LeftInverse _∪_ - ∪-inverseˡ = zipWith-inverseˡ ∨-inverseˡ + ∪-inverseˡ : LeftInverse _∪_ + ∪-inverseˡ = zipWith-inverseˡ ∨-inverseˡ - ∪-inverseʳ : RightInverse _∪_ - ∪-inverseʳ = zipWith-inverseʳ ∨-inverseʳ + ∪-inverseʳ : RightInverse _∪_ + ∪-inverseʳ = zipWith-inverseʳ ∨-inverseʳ - ∪-inverse : Inverse _∪_ - ∪-inverse = ∪-inverseˡ , ∪-inverseʳ + ∪-inverse : Inverse _∪_ + ∪-inverse = ∪-inverseˡ , ∪-inverseʳ - ∪-distribˡ-∩ : _∪_ DistributesOverˡ _∩_ - ∪-distribˡ-∩ = zipWith-distribˡ ∨-distribˡ-∧ + ∪-distribˡ-∩ : _∪_ DistributesOverˡ _∩_ + ∪-distribˡ-∩ = zipWith-distribˡ ∨-distribˡ-∧ - ∪-distribʳ-∩ : _∪_ DistributesOverʳ _∩_ - ∪-distribʳ-∩ = zipWith-distribʳ ∨-distribʳ-∧ + ∪-distribʳ-∩ : _∪_ DistributesOverʳ _∩_ + ∪-distribʳ-∩ = zipWith-distribʳ ∨-distribʳ-∧ - ∪-distrib-∩ : _∪_ DistributesOver _∩_ - ∪-distrib-∩ = ∪-distribˡ-∩ , ∪-distribʳ-∩ + ∪-distrib-∩ : _∪_ DistributesOver _∩_ + ∪-distrib-∩ = ∪-distribˡ-∩ , ∪-distribʳ-∩ - ∩-distribˡ-∪ : _∩_ DistributesOverˡ _∪_ - ∩-distribˡ-∪ = zipWith-distribˡ ∧-distribˡ-∨ + ∩-distribˡ-∪ : _∩_ DistributesOverˡ _∪_ + ∩-distribˡ-∪ = zipWith-distribˡ ∧-distribˡ-∨ - ∩-distribʳ-∪ : _∩_ DistributesOverʳ _∪_ - ∩-distribʳ-∪ = zipWith-distribʳ ∧-distribʳ-∨ + ∩-distribʳ-∪ : _∩_ DistributesOverʳ _∪_ + ∩-distribʳ-∪ = zipWith-distribʳ ∧-distribʳ-∨ - ∩-distrib-∪ : _∩_ DistributesOver _∪_ - ∩-distrib-∪ = ∩-distribˡ-∪ , ∩-distribʳ-∪ + ∩-distrib-∪ : _∩_ DistributesOver _∪_ + ∩-distrib-∪ = ∩-distribˡ-∪ , ∩-distribʳ-∪ - ∪-abs-∩ : _∪_ Absorbs _∩_ - ∪-abs-∩ = zipWith-absorbs ∨-abs-∧ + ∪-abs-∩ : _∪_ Absorbs _∩_ + ∪-abs-∩ = zipWith-absorbs ∨-abs-∧ - ∩-abs-∪ : _∩_ Absorbs _∪_ - ∩-abs-∪ = zipWith-absorbs ∧-abs-∨ + ∩-abs-∪ : _∩_ Absorbs _∪_ + ∩-abs-∪ = zipWith-absorbs ∧-abs-∨ -module _ (n : ) where +module _ (n : ) where - open AlgebraicStructures {A = Subset n} _≡_ - open AlgebraicLatticeStructures {A = Subset n} _≡_ - - ∪-isMagma : IsMagma _∪_ - ∪-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = cong₂ _∪_ - } + open AlgebraicStructures {A = Subset n} _≡_ + open AlgebraicLatticeStructures {A = Subset n} _≡_ + + ∪-isMagma : IsMagma _∪_ + ∪-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = cong₂ _∪_ + } - ∪-magma : Magma _ _ - ∪-magma = record - { isMagma = ∪-isMagma - } - - ∪-isSemigroup : IsSemigroup _∪_ - ∪-isSemigroup = record - { isMagma = ∪-isMagma - ; assoc = ∪-assoc - } - - ∪-semigroup : Semigroup _ _ - ∪-semigroup = record - { isSemigroup = ∪-isSemigroup - } - - ∪-isBand : IsBand _∪_ - ∪-isBand = record - { isSemigroup = ∪-isSemigroup - ; idem = ∪-idem - } - - ∪-band : Band _ _ - ∪-band = record - { isBand = ∪-isBand - } - - ∪-isSemilattice : IsSemilattice _∪_ - ∪-isSemilattice = record - { isBand = ∪-isBand - ; comm = ∪-comm - } - - ∪-semilattice : Semilattice _ _ - ∪-semilattice = record - { isSemilattice = ∪-isSemilattice - } - - ∪-isMonoid : IsMonoid _∪_ - ∪-isMonoid = record - { isSemigroup = ∪-isSemigroup - ; identity = ∪-identity - } - - ∪-monoid : Monoid _ _ - ∪-monoid = record - { isMonoid = ∪-isMonoid - } - - ∪-isCommutativeMonoid : IsCommutativeMonoid _∪_ - ∪-isCommutativeMonoid = record - { isMonoid = ∪-isMonoid - ; comm = ∪-comm - } - - ∪-commutativeMonoid : CommutativeMonoid _ _ - ∪-commutativeMonoid = record - { isCommutativeMonoid = ∪-isCommutativeMonoid - } - - ∪-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∪_ - ∪-isIdempotentCommutativeMonoid = record - { isCommutativeMonoid = ∪-isCommutativeMonoid - ; idem = ∪-idem - } - - ∪-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ - ∪-idempotentCommutativeMonoid = record - { isIdempotentCommutativeMonoid = ∪-isIdempotentCommutativeMonoid - } - - ∪-∩-isLattice : IsLattice _∪_ _∩_ - ∪-∩-isLattice = record - { isEquivalence = isEquivalence - ; ∨-comm = ∪-comm - ; ∨-assoc = ∪-assoc - ; ∨-cong = cong₂ _∪_ - ; ∧-comm = ∩-comm - ; ∧-assoc = ∩-assoc - ; ∧-cong = cong₂ _∩_ - ; absorptive = ∪-abs-∩ , ∩-abs-∪ - } - - ∪-∩-lattice : Lattice _ _ - ∪-∩-lattice = record - { isLattice = ∪-∩-isLattice - } - - ∪-∩-isDistributiveLattice : IsDistributiveLattice _∪_ _∩_ - ∪-∩-isDistributiveLattice = record - { isLattice = ∪-∩-isLattice - ; ∨-distrib-∧ = ∪-distrib-∩ - ; ∧-distrib-∨ = ∩-distrib-∪ - } - - ∪-∩-distributiveLattice : DistributiveLattice _ _ - ∪-∩-distributiveLattice = record - { isDistributiveLattice = ∪-∩-isDistributiveLattice - } - - ∪-∩-isBooleanAlgebra : IsBooleanAlgebra _∪_ _∩_ - ∪-∩-isBooleanAlgebra = record - { isDistributiveLattice = ∪-∩-isDistributiveLattice - ; ∨-complement = ∪-inverse - ; ∧-complement = ∩-inverse - ; ¬-cong = cong - } - - ∪-∩-booleanAlgebra : BooleanAlgebra _ _ - ∪-∩-booleanAlgebra = record - { isBooleanAlgebra = ∪-∩-isBooleanAlgebra - } - - ∩-∪-isLattice : IsLattice _∩_ _∪_ - ∩-∪-isLattice = L.∧-∨-isLattice ∪-∩-lattice - - ∩-∪-lattice : Lattice _ _ - ∩-∪-lattice = L.∧-∨-lattice ∪-∩-lattice - - ∩-∪-isDistributiveLattice : IsDistributiveLattice _∩_ _∪_ - ∩-∪-isDistributiveLattice = DL.∧-∨-isDistributiveLattice ∪-∩-distributiveLattice - - ∩-∪-distributiveLattice : DistributiveLattice _ _ - ∩-∪-distributiveLattice = DL.∧-∨-distributiveLattice ∪-∩-distributiveLattice - - ∩-∪-isBooleanAlgebra : IsBooleanAlgebra _∩_ _∪_ - ∩-∪-isBooleanAlgebra = BA.∧-∨-isBooleanAlgebra ∪-∩-booleanAlgebra - - ∩-∪-booleanAlgebra : BooleanAlgebra _ _ - ∩-∪-booleanAlgebra = BA.∧-∨-booleanAlgebra ∪-∩-booleanAlgebra - -p⊆p∪q : (q : Subset n) p p q -p⊆p∪q (s q) here = here -p⊆p∪q (s q) (there x∈p) = there (p⊆p∪q q x∈p) - -q⊆p∪q : (p q : Subset n) q p q -q⊆p∪q p q rewrite ∪-comm p q = p⊆p∪q p - -x∈p∪q⁻ : (p q : Subset n) x p q x p x q -x∈p∪q⁻ (inside p) (t q) here = inj₁ here -x∈p∪q⁻ (outside p) (inside q) here = inj₂ here -x∈p∪q⁻ (s p) (t q) (there x∈p∪q) = - Sum.map there there (x∈p∪q⁻ p q x∈p∪q) - -x∈p∪q⁺ : x p x q x p q -x∈p∪q⁺ (inj₁ x∈p) = p⊆p∪q _ x∈p -x∈p∪q⁺ (inj₂ x∈q) = q⊆p∪q _ _ x∈q - -∪⇔⊎ : x p q (x p x q) -∪⇔⊎ = mk⇔ (x∈p∪q⁻ _ _) x∈p∪q⁺ - -∣p∣≤∣p∪q∣ : (p q : Subset n) p p q -∣p∣≤∣p∪q∣ p q = p⊆q⇒∣p∣≤∣q∣ (p⊆p∪q {p = p} q) - -∣q∣≤∣p∪q∣ : (p q : Subset n) q p q -∣q∣≤∣p∪q∣ p q = p⊆q⇒∣p∣≤∣q∣ (q⊆p∪q p q) - -∣p∣⊔∣q∣≤∣p∪q∣ : (p q : Subset n) p q p q -∣p∣⊔∣q∣≤∣p∪q∣ p q = ℕ.⊔-lub (∣p∣≤∣p∪q∣ p q) (∣q∣≤∣p∪q∣ p q) - ------------------------------------------------------------------------- --- Properties of _─_ - -p─⊥≡p : (p : Subset n) p p -p─⊥≡p [] = refl -p─⊥≡p (x p) = cong (x ∷_) (p─⊥≡p p) - -p─⊤≡⊥ : (p : Subset n) p -p─⊤≡⊥ [] = refl -p─⊤≡⊥ (x p) = cong (outside ∷_) (p─⊤≡⊥ p) - -p─q─r≡p─q∪r : (p q r : Subset n) p q r p (q r) -p─q─r≡p─q∪r [] [] [] = refl -p─q─r≡p─q∪r (x p) (outside q) (outside r) = cong (x ∷_) (p─q─r≡p─q∪r p q r) -p─q─r≡p─q∪r (x p) (inside q) (outside r) = cong (outside ∷_) (p─q─r≡p─q∪r p q r) -p─q─r≡p─q∪r (x p) (outside q) (inside r) = cong (outside ∷_) (p─q─r≡p─q∪r p q r) -p─q─r≡p─q∪r (x p) (inside q) (inside r) = cong (outside ∷_) (p─q─r≡p─q∪r p q r) + ∪-magma : Magma _ _ + ∪-magma = record + { isMagma = ∪-isMagma + } + + ∪-isSemigroup : IsSemigroup _∪_ + ∪-isSemigroup = record + { isMagma = ∪-isMagma + ; assoc = ∪-assoc + } + + ∪-semigroup : Semigroup _ _ + ∪-semigroup = record + { isSemigroup = ∪-isSemigroup + } + + ∪-isBand : IsBand _∪_ + ∪-isBand = record + { isSemigroup = ∪-isSemigroup + ; idem = ∪-idem + } + + ∪-band : Band _ _ + ∪-band = record + { isBand = ∪-isBand + } + + ∪-isSemilattice : IsSemilattice _∪_ + ∪-isSemilattice = record + { isBand = ∪-isBand + ; comm = ∪-comm + } + + ∪-semilattice : Semilattice _ _ + ∪-semilattice = record + { isSemilattice = ∪-isSemilattice + } + + ∪-isMonoid : IsMonoid _∪_ + ∪-isMonoid = record + { isSemigroup = ∪-isSemigroup + ; identity = ∪-identity + } + + ∪-monoid : Monoid _ _ + ∪-monoid = record + { isMonoid = ∪-isMonoid + } + + ∪-isCommutativeMonoid : IsCommutativeMonoid _∪_ + ∪-isCommutativeMonoid = record + { isMonoid = ∪-isMonoid + ; comm = ∪-comm + } + + ∪-commutativeMonoid : CommutativeMonoid _ _ + ∪-commutativeMonoid = record + { isCommutativeMonoid = ∪-isCommutativeMonoid + } + + ∪-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∪_ + ∪-isIdempotentCommutativeMonoid = record + { isCommutativeMonoid = ∪-isCommutativeMonoid + ; idem = ∪-idem + } + + ∪-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ + ∪-idempotentCommutativeMonoid = record + { isIdempotentCommutativeMonoid = ∪-isIdempotentCommutativeMonoid + } + + ∪-∩-isLattice : IsLattice _∪_ _∩_ + ∪-∩-isLattice = record + { isEquivalence = isEquivalence + ; ∨-comm = ∪-comm + ; ∨-assoc = ∪-assoc + ; ∨-cong = cong₂ _∪_ + ; ∧-comm = ∩-comm + ; ∧-assoc = ∩-assoc + ; ∧-cong = cong₂ _∩_ + ; absorptive = ∪-abs-∩ , ∩-abs-∪ + } + + ∪-∩-lattice : Lattice _ _ + ∪-∩-lattice = record + { isLattice = ∪-∩-isLattice + } + + ∪-∩-isDistributiveLattice : IsDistributiveLattice _∪_ _∩_ + ∪-∩-isDistributiveLattice = record + { isLattice = ∪-∩-isLattice + ; ∨-distrib-∧ = ∪-distrib-∩ + ; ∧-distrib-∨ = ∩-distrib-∪ + } + + ∪-∩-distributiveLattice : DistributiveLattice _ _ + ∪-∩-distributiveLattice = record + { isDistributiveLattice = ∪-∩-isDistributiveLattice + } + + ∪-∩-isBooleanAlgebra : IsBooleanAlgebra _∪_ _∩_ + ∪-∩-isBooleanAlgebra = record + { isDistributiveLattice = ∪-∩-isDistributiveLattice + ; ∨-complement = ∪-inverse + ; ∧-complement = ∩-inverse + ; ¬-cong = cong + } + + ∪-∩-booleanAlgebra : BooleanAlgebra _ _ + ∪-∩-booleanAlgebra = record + { isBooleanAlgebra = ∪-∩-isBooleanAlgebra + } + + ∩-∪-isLattice : IsLattice _∩_ _∪_ + ∩-∪-isLattice = L.∧-∨-isLattice ∪-∩-lattice + + ∩-∪-lattice : Lattice _ _ + ∩-∪-lattice = L.∧-∨-lattice ∪-∩-lattice + + ∩-∪-isDistributiveLattice : IsDistributiveLattice _∩_ _∪_ + ∩-∪-isDistributiveLattice = DL.∧-∨-isDistributiveLattice ∪-∩-distributiveLattice + + ∩-∪-distributiveLattice : DistributiveLattice _ _ + ∩-∪-distributiveLattice = DL.∧-∨-distributiveLattice ∪-∩-distributiveLattice + + ∩-∪-isBooleanAlgebra : IsBooleanAlgebra _∩_ _∪_ + ∩-∪-isBooleanAlgebra = BA.∧-∨-isBooleanAlgebra ∪-∩-booleanAlgebra + + ∩-∪-booleanAlgebra : BooleanAlgebra _ _ + ∩-∪-booleanAlgebra = BA.∧-∨-booleanAlgebra ∪-∩-booleanAlgebra + +p⊆p∪q : (q : Subset n) p p q +p⊆p∪q (s q) here = here +p⊆p∪q (s q) (there x∈p) = there (p⊆p∪q q x∈p) + +q⊆p∪q : (p q : Subset n) q p q +q⊆p∪q p q rewrite ∪-comm p q = p⊆p∪q p + +x∈p∪q⁻ : (p q : Subset n) x p q x p x q +x∈p∪q⁻ (inside p) (t q) here = inj₁ here +x∈p∪q⁻ (outside p) (inside q) here = inj₂ here +x∈p∪q⁻ (s p) (t q) (there x∈p∪q) = + Sum.map there there (x∈p∪q⁻ p q x∈p∪q) + +x∈p∪q⁺ : x p x q x p q +x∈p∪q⁺ (inj₁ x∈p) = p⊆p∪q _ x∈p +x∈p∪q⁺ (inj₂ x∈q) = q⊆p∪q _ _ x∈q + +∪⇔⊎ : x p q (x p x q) +∪⇔⊎ = mk⇔ (x∈p∪q⁻ _ _) x∈p∪q⁺ + +∣p∣≤∣p∪q∣ : (p q : Subset n) p p q +∣p∣≤∣p∪q∣ p q = p⊆q⇒∣p∣≤∣q∣ (p⊆p∪q {p = p} q) + +∣q∣≤∣p∪q∣ : (p q : Subset n) q p q +∣q∣≤∣p∪q∣ p q = p⊆q⇒∣p∣≤∣q∣ (q⊆p∪q p q) + +∣p∣⊔∣q∣≤∣p∪q∣ : (p q : Subset n) p q p q +∣p∣⊔∣q∣≤∣p∪q∣ p q = ℕ.⊔-lub (∣p∣≤∣p∪q∣ p q) (∣q∣≤∣p∪q∣ p q) + +------------------------------------------------------------------------ +-- Properties of _─_ + +p─⊥≡p : (p : Subset n) p p +p─⊥≡p [] = refl +p─⊥≡p (x p) = cong (x ∷_) (p─⊥≡p p) + +p─⊤≡⊥ : (p : Subset n) p +p─⊤≡⊥ [] = refl +p─⊤≡⊥ (x p) = cong (outside ∷_) (p─⊤≡⊥ p) + +p─q─r≡p─q∪r : (p q r : Subset n) p q r p (q r) +p─q─r≡p─q∪r [] [] [] = refl +p─q─r≡p─q∪r (x p) (outside q) (outside r) = cong (x ∷_) (p─q─r≡p─q∪r p q r) +p─q─r≡p─q∪r (x p) (inside q) (outside r) = cong (outside ∷_) (p─q─r≡p─q∪r p q r) +p─q─r≡p─q∪r (x p) (outside q) (inside r) = cong (outside ∷_) (p─q─r≡p─q∪r p q r) +p─q─r≡p─q∪r (x p) (inside q) (inside r) = cong (outside ∷_) (p─q─r≡p─q∪r p q r) -p─q─q≡p─q : (p q : Subset n) p q q p q -p─q─q≡p─q p q = begin - p q q ≡⟨ p─q─r≡p─q∪r p q q - p q q ≡⟨ cong (p ─_) (∪-idem q) - p q - where open ≡-Reasoning +p─q─q≡p─q : (p q : Subset n) p q q p q +p─q─q≡p─q p q = begin + p q q ≡⟨ p─q─r≡p─q∪r p q q + p q q ≡⟨ cong (p ─_) (∪-idem q) + p q + where open ≡-Reasoning -p─q─r≡p─r─q : (p q r : Subset n) p q r p r q -p─q─r≡p─r─q p q r = begin - (p q) r ≡⟨ p─q─r≡p─q∪r p q r - p (q r) ≡⟨ cong (p ─_) (∪-comm q r) - p (r q) ≡⟨ p─q─r≡p─q∪r p r q - (p r) q - where open ≡-Reasoning +p─q─r≡p─r─q : (p q r : Subset n) p q r p r q +p─q─r≡p─r─q p q r = begin + (p q) r ≡⟨ p─q─r≡p─q∪r p q r + p (q r) ≡⟨ cong (p ─_) (∪-comm q r) + p (r q) ≡⟨ p─q─r≡p─q∪r p r q + (p r) q + where open ≡-Reasoning -x∈p∧x∉q⇒x∈p─q : x p x q x p q -x∈p∧x∉q⇒x∈p─q {q = outside q} here i∉q = here -x∈p∧x∉q⇒x∈p─q {q = inside q} here i∉q = contradiction here i∉q -x∈p∧x∉q⇒x∈p─q {q = outside q} (there i∈p) i∉q = there (x∈p∧x∉q⇒x∈p─q i∈p (i∉q there)) -x∈p∧x∉q⇒x∈p─q {q = inside q} (there i∈p) i∉q = there (x∈p∧x∉q⇒x∈p─q i∈p (i∉q there)) +x∈p∧x∉q⇒x∈p─q : x p x q x p q +x∈p∧x∉q⇒x∈p─q {q = outside q} here i∉q = here +x∈p∧x∉q⇒x∈p─q {q = inside q} here i∉q = contradiction here i∉q +x∈p∧x∉q⇒x∈p─q {q = outside q} (there i∈p) i∉q = there (x∈p∧x∉q⇒x∈p─q i∈p (i∉q there)) +x∈p∧x∉q⇒x∈p─q {q = inside q} (there i∈p) i∉q = there (x∈p∧x∉q⇒x∈p─q i∈p (i∉q there)) -p─q⊆p : (p q : Subset n) p q p -p─q⊆p (inside p) (outside q) here = here -p─q⊆p (inside p) (outside q) (there x∈p) = there (p─q⊆p p q x∈p) -p─q⊆p (outside p) (outside q) (there x∈p) = there (p─q⊆p p q x∈p) -p─q⊆p (_ p) (inside q) (there x∈p) = there (p─q⊆p p q x∈p) +p─q⊆p : (p q : Subset n) p q p +p─q⊆p (inside p) (outside q) here = here +p─q⊆p (inside p) (outside q) (there x∈p) = there (p─q⊆p p q x∈p) +p─q⊆p (outside p) (outside q) (there x∈p) = there (p─q⊆p p q x∈p) +p─q⊆p (_ p) (inside q) (there x∈p) = there (p─q⊆p p q x∈p) -p∩q≢∅⇒p─q⊂p : (p q : Subset n) Nonempty (p q) p q p -p∩q≢∅⇒p─q⊂p (inside p) (inside q) (zero , here) = out⊂in (p─q⊆p p q) -p∩q≢∅⇒p─q⊂p (x p) (inside q) (suc i , there i∈p∩q) = out⊂ (p∩q≢∅⇒p─q⊂p p q (i , i∈p∩q)) -p∩q≢∅⇒p─q⊂p (outside p) (outside q) (suc i , there i∈p∩q) = out⊂ (p∩q≢∅⇒p─q⊂p p q (i , i∈p∩q)) -p∩q≢∅⇒p─q⊂p (inside p) (outside q) (suc i , there i∈p∩q) = s⊂s (p∩q≢∅⇒p─q⊂p p q (i , i∈p∩q)) +p∩q≢∅⇒p─q⊂p : (p q : Subset n) Nonempty (p q) p q p +p∩q≢∅⇒p─q⊂p (inside p) (inside q) (zero , here) = out⊂in (p─q⊆p p q) +p∩q≢∅⇒p─q⊂p (x p) (inside q) (suc i , there i∈p∩q) = out⊂ (p∩q≢∅⇒p─q⊂p p q (i , i∈p∩q)) +p∩q≢∅⇒p─q⊂p (outside p) (outside q) (suc i , there i∈p∩q) = out⊂ (p∩q≢∅⇒p─q⊂p p q (i , i∈p∩q)) +p∩q≢∅⇒p─q⊂p (inside p) (outside q) (suc i , there i∈p∩q) = s⊂s (p∩q≢∅⇒p─q⊂p p q (i , i∈p∩q)) -∣p─q∣≤∣p∣ : (p q : Subset n) p q p -∣p─q∣≤∣p∣ p q = p⊆q⇒∣p∣≤∣q∣ (p─q⊆p p q) +∣p─q∣≤∣p∣ : (p q : Subset n) p q p +∣p─q∣≤∣p∣ p q = p⊆q⇒∣p∣≤∣q∣ (p─q⊆p p q) -p∩q≢∅⇒∣p─q∣<∣p∣ : (p q : Subset n) Nonempty (p q) p q < p -p∩q≢∅⇒∣p─q∣<∣p∣ p q ne = p⊂q⇒∣p∣<∣q∣ (p∩q≢∅⇒p─q⊂p p q ne) +p∩q≢∅⇒∣p─q∣<∣p∣ : (p q : Subset n) Nonempty (p q) p q < p +p∩q≢∅⇒∣p─q∣<∣p∣ p q ne = p⊂q⇒∣p∣<∣q∣ (p∩q≢∅⇒p─q⊂p p q ne) ------------------------------------------------------------------------- --- Properties of _-_ +------------------------------------------------------------------------ +-- Properties of _-_ -x∈p∧x≢y⇒x∈p-y : x p x y x p - y -x∈p∧x≢y⇒x∈p-y x∈p x≢y = x∈p∧x∉q⇒x∈p─q x∈p (x≢y⇒x∉⁅y⁆ x≢y) +x∈p∧x≢y⇒x∈p-y : x p x y x p - y +x∈p∧x≢y⇒x∈p-y x∈p x≢y = x∈p∧x∉q⇒x∈p─q x∈p (x≢y⇒x∉⁅y⁆ x≢y) -p─x─y≡p─y─x : (p : Subset n) x y p - x - y p - y - x -p─x─y≡p─y─x p x y = p─q─r≡p─r─q p x y +p─x─y≡p─y─x : (p : Subset n) x y p - x - y p - y - x +p─x─y≡p─y─x p x y = p─q─r≡p─r─q p x y -x∈p⇒p-x⊂p : x p p - x p -x∈p⇒p-x⊂p {n} {x} {p} x∈p = p∩q≢∅⇒p─q⊂p p x (x , x∈p∩q⁺ (x∈p , x∈⁅x⁆ x)) +x∈p⇒p-x⊂p : x p p - x p +x∈p⇒p-x⊂p {n} {x} {p} x∈p = p∩q≢∅⇒p─q⊂p p x (x , x∈p∩q⁺ (x∈p , x∈⁅x⁆ x)) -x∈p⇒∣p-x∣<∣p∣ : x p p - x < p -x∈p⇒∣p-x∣<∣p∣ x∈p = p⊂q⇒∣p∣<∣q∣ (x∈p⇒p-x⊂p x∈p) +x∈p⇒∣p-x∣<∣p∣ : x p p - x < p +x∈p⇒∣p-x∣<∣p∣ x∈p = p⊂q⇒∣p∣<∣q∣ (x∈p⇒p-x⊂p x∈p) ------------------------------------------------------------------------- --- Lift +------------------------------------------------------------------------ +-- Lift -Lift? : {P : Pred (Fin n) } Decidable P Decidable (Lift P) -Lift? P? p = decFinSubset (_∈? p) {x} _ P? x) +Lift? : {P : Pred (Fin n) } Decidable P Decidable (Lift P) +Lift? P? p = decFinSubset (_∈? p) {x} _ P? x) ------------------------------------------------------------------------- --- Other +------------------------------------------------------------------------ +-- Other -module _ {P : Pred (Subset 0) } where +module _ {P : Pred (Subset 0) } where - ∃-Subset-zero : ∃⟨ P P [] - ∃-Subset-zero ([] , P[]) = P[] + ∃-Subset-zero : ∃⟨ P P [] + ∃-Subset-zero ([] , P[]) = P[] - ∃-Subset-[]-⇔ : P [] ∃⟨ P - ∃-Subset-[]-⇔ = mk⇔ ([] ,_) ∃-Subset-zero + ∃-Subset-[]-⇔ : P [] ∃⟨ P + ∃-Subset-[]-⇔ = mk⇔ ([] ,_) ∃-Subset-zero -module _ {P : Pred (Subset (suc n)) } where +module _ {P : Pred (Subset (suc n)) } where - ∃-Subset-suc : ∃⟨ P ∃⟨ P (inside ∷_) ∃⟨ P (outside ∷_) - ∃-Subset-suc (outside p , Pop) = inj₂ (p , Pop) - ∃-Subset-suc ( inside p , Pip) = inj₁ (p , Pip) + ∃-Subset-suc : ∃⟨ P ∃⟨ P (inside ∷_) ∃⟨ P (outside ∷_) + ∃-Subset-suc (outside p , Pop) = inj₂ (p , Pop) + ∃-Subset-suc ( inside p , Pip) = inj₁ (p , Pip) - ∃-Subset-∷-⇔ : (∃⟨ P (inside ∷_) ∃⟨ P (outside ∷_) ) ∃⟨ P - ∃-Subset-∷-⇔ = mk⇔ - [ Product.map _ id , Product.map _ id ]′ - ∃-Subset-suc + ∃-Subset-∷-⇔ : (∃⟨ P (inside ∷_) ∃⟨ P (outside ∷_) ) ∃⟨ P + ∃-Subset-∷-⇔ = mk⇔ + [ Product.map _ id , Product.map _ id ]′ + ∃-Subset-suc -anySubset? : {P : Pred (Subset n) } Decidable P Dec ∃⟨ P -anySubset? {n = zero} P? = Dec.map ∃-Subset-[]-⇔ (P? []) -anySubset? {n = suc n} P? = Dec.map ∃-Subset-∷-⇔ - (anySubset? (P? (inside ∷_)) ⊎-dec anySubset? (P? (outside ∷_))) +anySubset? : {P : Pred (Subset n) } Decidable P Dec ∃⟨ P +anySubset? {n = zero} P? = Dec.map ∃-Subset-[]-⇔ (P? []) +anySubset? {n = suc n} P? = Dec.map ∃-Subset-∷-⇔ + (anySubset? (P? (inside ∷_)) ⊎-dec anySubset? (P? (outside ∷_))) ------------------------------------------------------------------------- --- DEPRECATED NAMES ------------------------------------------------------------------------- --- Please use the new names as continuing support for the old names is --- not guaranteed. +------------------------------------------------------------------------ +-- DEPRECATED NAMES +------------------------------------------------------------------------ +-- Please use the new names as continuing support for the old names is +-- not guaranteed. --- Version 1.3 +-- Version 1.3 -p⊆q⇒∣p∣<∣q∣ = p⊆q⇒∣p∣≤∣q∣ -{-# WARNING_ON_USAGE p⊆q⇒∣p∣<∣q∣ -"Warning: p⊆q⇒∣p∣<∣q∣ was deprecated in v1.3. +p⊆q⇒∣p∣<∣q∣ = p⊆q⇒∣p∣≤∣q∣ +{-# WARNING_ON_USAGE p⊆q⇒∣p∣<∣q∣ +"Warning: p⊆q⇒∣p∣<∣q∣ was deprecated in v1.3. Please use p⊆q⇒∣p∣≤∣q∣ instead." -#-} +#-} \ No newline at end of file diff --git a/v2.3/Data.Fin.html b/v2.3/Data.Fin.html index 535baa7dd7..f51217da92 100644 --- a/v2.3/Data.Fin.html +++ b/v2.3/Data.Fin.html @@ -21,12 +21,12 @@ -- Publicly re-export queries open import Data.Fin.Properties public - using (_≟_; _≤?_; _<?_) + using (_≟_; _≤?_; _<?_) -- # m = "m". infix 10 #_ -#_ : m {n} {m<n : True (m ℕ.<? n)} Fin n +#_ : m {n} {m<n : True (m ℕ.<? n)} Fin n #_ _ {m<n = m<n} = fromℕ< (toWitness m<n) \ No newline at end of file diff --git a/v2.3/Data.Graph.Acyclic.html b/v2.3/Data.Graph.Acyclic.html index 822f83cf5d..2521d330e8 100644 --- a/v2.3/Data.Graph.Acyclic.html +++ b/v2.3/Data.Graph.Acyclic.html @@ -16,11 +16,11 @@ open import Level using (_⊔_) open import Data.Nat.Base as using (; zero; suc; _<′_) open import Data.Nat.Induction using (<′-rec; <′-Rec) -import Data.Nat.Properties as using (≤⇒≤′) +import Data.Nat.Properties as using (≤⇒≤′) open import Data.Fin as Fin - using (Fin; Fin′; zero; suc; #_; toℕ; _≟_; opposite) + using (Fin; Fin′; zero; suc; #_; toℕ; _≟_; opposite) renaming (_ℕ-ℕ_ to _-_) -open import Data.Fin.Properties as Fin using (nℕ-ℕi≤n) +open import Data.Fin.Properties as Fin using (nℕ-ℕi≤n) open import Data.Product.Base as Prod using (; _×_; _,_) open import Data.Maybe.Base as Maybe using (Maybe) open import Data.Empty using () @@ -37,7 +37,7 @@ private lemma : n (i : Fin n) n - suc i <′ n - lemma (suc n) i = ℕ.≤⇒≤′ $ ℕ.s≤s $ Fin.nℕ-ℕi≤n n i + lemma (suc n) i = ℕ.≤⇒≤′ $ ℕ.s≤s $ Fin.nℕ-ℕi≤n n i ------------------------------------------------------------------------ -- Node contexts @@ -240,7 +240,7 @@ (List.map (Prod.map suc id) $ preds g i) where p : {e} {E : Set e} {n} (i : Fin n) E × Fin n Maybe (Fin′ (suc i) × E) - p i (e , j) = Maybe.map (λ{ refl zero , e }) (dec⇒weaklyDec _≟_ i j) + p i (e , j) = Maybe.map (λ{ refl zero , e }) (dec⇒weaklyDec _≟_ i j) private @@ -254,7 +254,7 @@ -- Weakens a node label. weaken : {n} {i : Fin n} Fin (n - suc i) Fin n -weaken {n} {i} j = Fin.inject≤ j (Fin.nℕ-ℕi≤n n (suc i)) +weaken {n} {i} j = Fin.inject≤ j (Fin.nℕ-ℕi≤n n (suc i)) -- Labels each node with its node number. diff --git a/v2.3/Data.Integer.Base.html b/v2.3/Data.Integer.Base.html index 530c2a3f18..2a11d95234 100644 --- a/v2.3/Data.Integer.Base.html +++ b/v2.3/Data.Integer.Base.html @@ -21,7 +21,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≢_; refl) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary using (Pred) infix 8 -_ @@ -164,7 +164,7 @@ ≢-nonZero : {i} i 0ℤ NonZero i ≢-nonZero { +[1+ n ]} _ = _ -≢-nonZero { +0} 0≢0 = contradiction refl 0≢0 +≢-nonZero { +0} 0≢0 = contradiction refl 0≢0 ≢-nonZero { -[1+ n ]} _ = _ >-nonZero : {i} i > 0ℤ NonZero i diff --git a/v2.3/Data.Integer.DivMod.html b/v2.3/Data.Integer.DivMod.html index 2a96378c8a..f19f22adb1 100644 --- a/v2.3/Data.Integer.DivMod.html +++ b/v2.3/Data.Integer.DivMod.html @@ -14,7 +14,7 @@ +<+) open import Data.Integer.Properties open import Data.Nat.Base as using (; z≤n; s≤s; z<s; s<s) -import Data.Nat.Properties as using (m∸n≤m) +import Data.Nat.Properties as using (m∸n≤m) import Data.Nat.DivMod as using (m≡m%n+[m/n]*n; m%n≤n; m%n<n) open import Function.Base using (_∘′_) open import Relation.Binary.PropositionalEquality.Core @@ -34,7 +34,7 @@ n%ℕd<d (+ n) d = ℕ.m%n<n n d n%ℕd<d -[1+ n ] d@(ℕ.suc _) with ℕ.suc n ℕ.% d ... | ℕ.zero = z<s -... | ℕ.suc r = s<s (ℕ.m∸n≤m _ r) +... | ℕ.suc r = s<s (ℕ.m∸n≤m _ r) n%d<d : n d .{{_ : NonZero d}} n % d ℕ.< d n%d<d n (+ d) = n%ℕd<d n d diff --git a/v2.3/Data.Integer.Divisibility.Signed.html b/v2.3/Data.Integer.Divisibility.Signed.html index 6905b64979..d106e7f01c 100644 --- a/v2.3/Data.Integer.Divisibility.Signed.html +++ b/v2.3/Data.Integer.Divisibility.Signed.html @@ -16,7 +16,7 @@ import Data.Integer.Divisibility as Unsigned import Data.Nat.Base as using (; suc; _*_) import Data.Nat.Divisibility as -import Data.Nat.Properties as using (*-zeroʳ ; <-cmp; module ≤-Reasoning) +import Data.Nat.Properties as using (*-zeroʳ ; <-cmp; module ≤-Reasoning) import Data.Sign.Base as Sign import Data.Sign.Properties as Sign open import Relation.Binary.Core using (_⇒_; _Preserves_⟶_) @@ -50,7 +50,7 @@ ∣ᵤ⇒∣ : {k i} k Unsigned.∣ i k i ∣ᵤ⇒∣ {k} {i} (Unsigned.divides 0 eq) = divides +0 (∣i∣≡0⇒i≡0 eq) ∣ᵤ⇒∣ {k} {i} (Unsigned.divides q@(ℕ.suc _) eq) with k +0 -... | yes refl = divides +0 (∣i∣≡0⇒i≡0 (trans eq (ℕ.*-zeroʳ q))) +... | yes refl = divides +0 (∣i∣≡0⇒i≡0 (trans eq (ℕ.*-zeroʳ q))) ... | no neq = divides s[i*k]◃q (◃-cong sign-eq abs-eq) where s[i*k] = sign i Sign.* sign k diff --git a/v2.3/Data.Integer.Properties.NatLemmas.html b/v2.3/Data.Integer.Properties.NatLemmas.html index 913bc9f40c..c0d42a5b54 100644 --- a/v2.3/Data.Integer.Properties.NatLemmas.html +++ b/v2.3/Data.Integer.Properties.NatLemmas.html @@ -12,7 +12,7 @@ open import Data.Nat.Base using (; _+_; _*_; suc) open import Data.Nat.Properties - using (*-distribʳ-+; *-assoc; +-assoc; +-comm; +-suc) + using (*-distribʳ-+; *-assoc; +-assoc; +-comm; +-suc) open import Function.Base using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_; cong; cong₂; sym; module ≡-Reasoning) @@ -23,49 +23,49 @@ o + n * suc o + m * suc (o + n * suc o) inner-assoc m n o = begin o + (n + m * suc n) * suc o ≡⟨ cong (o +_) (begin - (n + m * suc n) * suc o ≡⟨ *-distribʳ-+ (suc o) n (m * suc n) - n * suc o + m * suc n * suc o ≡⟨ cong (n * suc o +_) (*-assoc m (suc n) (suc o)) + (n + m * suc n) * suc o ≡⟨ *-distribʳ-+ (suc o) n (m * suc n) + n * suc o + m * suc n * suc o ≡⟨ cong (n * suc o +_) (*-assoc m (suc n) (suc o)) n * suc o + m * suc (o + n * suc o) ) - o + (n * suc o + m * suc (o + n * suc o)) ≡⟨ +-assoc o _ _ + o + (n * suc o + m * suc (o + n * suc o)) ≡⟨ +-assoc o _ _ o + n * suc o + m * suc (o + n * suc o) private assoc-comm : a b c d a + b + c + d (a + c) + (b + d) assoc-comm a b c d = begin - a + b + c + d ≡⟨ cong (_+ d) (+-assoc a b c) - a + (b + c) + d ≡⟨ cong z a + z + d) (+-comm b c) - a + (c + b) + d ≡⟨ cong (_+ d) (+-assoc a c b) - (a + c) + b + d ≡⟨ +-assoc (a + c) b d + a + b + c + d ≡⟨ cong (_+ d) (+-assoc a b c) + a + (b + c) + d ≡⟨ cong z a + z + d) (+-comm b c) + a + (c + b) + d ≡⟨ cong (_+ d) (+-assoc a c b) + (a + c) + b + d ≡⟨ +-assoc (a + c) b d (a + c) + (b + d) assoc-comm′ : a b c d a + (b + (c + d)) a + c + (b + d) assoc-comm′ a b c d = begin - a + (b + (c + d)) ≡⟨ cong (a +_) (+-assoc b c d) - a + (b + c + d) ≡⟨ cong z a + (z + d)) (+-comm b c) - a + (c + b + d) ≡⟨ cong (a +_) (+-assoc c b d) - a + (c + (b + d)) ≡⟨ +-assoc a c _ + a + (b + (c + d)) ≡⟨ cong (a +_) (+-assoc b c d) + a + (b + c + d) ≡⟨ cong z a + (z + d)) (+-comm b c) + a + (c + b + d) ≡⟨ cong (a +_) (+-assoc c b d) + a + (c + (b + d)) ≡⟨ +-assoc a c _ a + c + (b + d) assoc₁ : m n o (2 + n + o) * (1 + m) (1 + n) * (1 + m) + (1 + o) * (1 + m) assoc₁ m n o = begin (2 + n + o) * (1 + m) ≡⟨ cong (_* (1 + m)) (assoc-comm 1 1 n o) - ((1 + n) + (1 + o)) * (1 + m) ≡⟨ *-distribʳ-+ (1 + m) (1 + n) (1 + o) + ((1 + n) + (1 + o)) * (1 + m) ≡⟨ *-distribʳ-+ (1 + m) (1 + n) (1 + o) (1 + n) * (1 + m) + (1 + o) * (1 + m) assoc₂ : m n o (1 + n + (1 + o)) * (1 + m) (1 + n) * (1 + m) + (1 + o) * (1 + m) -assoc₂ m n o = *-distribʳ-+ (1 + m) (1 + n) (1 + o) +assoc₂ m n o = *-distribʳ-+ (1 + m) (1 + n) (1 + o) assoc₃ : m n o m + (n + (1 + o)) * (1 + m) (1 + n) * (1 + m) + (m + o * (1 + m)) assoc₃ m n o = begin - m + (n + (1 + o)) * (1 + m) ≡⟨ cong (m +_) (*-distribʳ-+ (1 + m) n (1 + o)) - m + (n * (1 + m) + (1 + o) * (1 + m)) ≡⟨ +-assoc m _ _ - (m + n * (1 + m)) + (1 + o) * (1 + m) ≡⟨ +-suc _ _ + m + (n + (1 + o)) * (1 + m) ≡⟨ cong (m +_) (*-distribʳ-+ (1 + m) n (1 + o)) + m + (n * (1 + m) + (1 + o) * (1 + m)) ≡⟨ +-assoc m _ _ + (m + n * (1 + m)) + (1 + o) * (1 + m) ≡⟨ +-suc _ _ (1 + n) * (1 + m) + (m + o * (1 + m)) assoc₄ : m n o m + (1 + m + (n + o) * (1 + m)) (1 + n) * (1 + m) + (m + o * (1 + m)) assoc₄ m n o = begin - m + (1 + m + (n + o) * (1 + m)) ≡⟨ +-suc _ _ - 1 + m + (m + (n + o) * (1 + m)) ≡⟨ cong z suc (m + (m + z))) (*-distribʳ-+ (suc m) n o) + m + (1 + m + (n + o) * (1 + m)) ≡⟨ +-suc _ _ + 1 + m + (m + (n + o) * (1 + m)) ≡⟨ cong z suc (m + (m + z))) (*-distribʳ-+ (suc m) n o) 1 + m + (m + (n * (1 + m) + o * (1 + m))) ≡⟨ cong suc (assoc-comm′ m m _ _) (1 + n) * (1 + m) + (m + o * (1 + m)) \ No newline at end of file diff --git a/v2.3/Data.Integer.Properties.html b/v2.3/Data.Integer.Properties.html index b52f518170..9b0b0a4e63 100644 --- a/v2.3/Data.Integer.Properties.html +++ b/v2.3/Data.Integer.Properties.html @@ -42,7 +42,7 @@ using (module ≡-Reasoning; setoid; decSetoid; isEquivalence) open import Relation.Nullary.Decidable.Core using (yes; no) import Relation.Nullary.Reflects as Reflects -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) import Relation.Nullary.Decidable as Dec open import Algebra.Definitions {A = } _≡_ @@ -98,8 +98,8 @@ -- Relational properties ≤-reflexive : _≡_ _≤_ -≤-reflexive { -[1+ n ]} refl = -≤- ℕ.≤-refl -≤-reflexive {+ n} refl = +≤+ ℕ.≤-refl +≤-reflexive { -[1+ n ]} refl = -≤- ℕ.≤-refl +≤-reflexive {+ n} refl = +≤+ ℕ.≤-refl ≤-refl : Reflexive _≤_ ≤-refl = ≤-reflexive refl @@ -107,30 +107,30 @@ ≤-trans : Transitive _≤_ ≤-trans -≤+ (+≤+ n≤m) = -≤+ ≤-trans (-≤- n≤m) -≤+ = -≤+ -≤-trans (-≤- n≤m) (-≤- k≤n) = -≤- (ℕ.≤-trans k≤n n≤m) -≤-trans (+≤+ m≤n) (+≤+ n≤k) = +≤+ (ℕ.≤-trans m≤n n≤k) +≤-trans (-≤- n≤m) (-≤- k≤n) = -≤- (ℕ.≤-trans k≤n n≤m) +≤-trans (+≤+ m≤n) (+≤+ n≤k) = +≤+ (ℕ.≤-trans m≤n n≤k) ≤-antisym : Antisymmetric _≡_ _≤_ -≤-antisym (-≤- n≤m) (-≤- m≤n) = cong -[1+_] $ ℕ.≤-antisym m≤n n≤m -≤-antisym (+≤+ m≤n) (+≤+ n≤m) = cong (+_) $ ℕ.≤-antisym m≤n n≤m +≤-antisym (-≤- n≤m) (-≤- m≤n) = cong -[1+_] $ ℕ.≤-antisym m≤n n≤m +≤-antisym (+≤+ m≤n) (+≤+ n≤m) = cong (+_) $ ℕ.≤-antisym m≤n n≤m ≤-total : Total _≤_ -≤-total (-[1+ m ]) (-[1+ n ]) = Sum.map -≤- -≤- (ℕ.≤-total n m) +≤-total (-[1+ m ]) (-[1+ n ]) = Sum.map -≤- -≤- (ℕ.≤-total n m) ≤-total (-[1+ m ]) (+ n ) = inj₁ -≤+ ≤-total (+ m ) (-[1+ n ]) = inj₂ -≤+ -≤-total (+ m ) (+ n ) = Sum.map +≤+ +≤+ (ℕ.≤-total m n) +≤-total (+ m ) (+ n ) = Sum.map +≤+ +≤+ (ℕ.≤-total m n) infix 4 _≤?_ _≤?_ : Decidable _≤_ --[1+ m ] ≤? -[1+ n ] = Dec.map′ -≤- drop‿-≤- (n ℕ.≤? m) +-[1+ m ] ≤? -[1+ n ] = Dec.map′ -≤- drop‿-≤- (n ℕ.≤? m) -[1+ m ] ≤? + n = yes -≤+ + m ≤? -[1+ n ] = no λ () -+ m ≤? + n = Dec.map′ +≤+ drop‿+≤+ (m ℕ.≤? n) ++ m ≤? + n = Dec.map′ +≤+ drop‿+≤+ (m ℕ.≤? n) ≤-irrelevant : Irrelevant _≤_ ≤-irrelevant -≤+ -≤+ = refl -≤-irrelevant (-≤- n≤m₁) (-≤- n≤m₂) = cong -≤- (ℕ.≤-irrelevant n≤m₁ n≤m₂) -≤-irrelevant (+≤+ n≤m₁) (+≤+ n≤m₂) = cong +≤+ (ℕ.≤-irrelevant n≤m₁ n≤m₂) +≤-irrelevant (-≤- n≤m₁) (-≤- n≤m₂) = cong -≤- (ℕ.≤-irrelevant n≤m₁ n≤m₂) +≤-irrelevant (+≤+ n≤m₁) (+≤+ n≤m₂) = cong +≤+ (ℕ.≤-irrelevant n≤m₁ n≤m₂) ------------------------------------------------------------------------ -- Structures @@ -200,14 +200,14 @@ ------------------------------------------------------------------------ ≤ᵇ⇒≤ : T (i ≤ᵇ j) i j -≤ᵇ⇒≤ {+ _} {+ _} i≤j = +≤+ (ℕ.≤ᵇ⇒≤ _ _ i≤j) +≤ᵇ⇒≤ {+ _} {+ _} i≤j = +≤+ (ℕ.≤ᵇ⇒≤ _ _ i≤j) ≤ᵇ⇒≤ { -[1+ _ ]} {+ _} i≤j = -≤+ -≤ᵇ⇒≤ { -[1+ _ ]} { -[1+ _ ]} i≤j = -≤- (ℕ.≤ᵇ⇒≤ _ _ i≤j) +≤ᵇ⇒≤ { -[1+ _ ]} { -[1+ _ ]} i≤j = -≤- (ℕ.≤ᵇ⇒≤ _ _ i≤j) ≤⇒≤ᵇ : i j T (i ≤ᵇ j) -≤⇒≤ᵇ (-≤- n≤m) = ℕ.≤⇒≤ᵇ n≤m +≤⇒≤ᵇ (-≤- n≤m) = ℕ.≤⇒≤ᵇ n≤m ≤⇒≤ᵇ -≤+ = _ -≤⇒≤ᵇ (+≤+ m≤n) = ℕ.≤⇒≤ᵇ m≤n +≤⇒≤ᵇ (+≤+ m≤n) = ℕ.≤⇒≤ᵇ m≤n ------------------------------------------------------------------------ -- Properties _<_ @@ -229,42 +229,42 @@ -- Relationship between other operators <⇒≤ : _<_ _≤_ -<⇒≤ (-<- i<j) = -≤- (ℕ.<⇒≤ i<j) +<⇒≤ (-<- i<j) = -≤- (ℕ.<⇒≤ i<j) <⇒≤ -<+ = -≤+ -<⇒≤ (+<+ i<j) = +≤+ (ℕ.<⇒≤ i<j) +<⇒≤ (+<+ i<j) = +≤+ (ℕ.<⇒≤ i<j) <⇒≢ : _<_ _≢_ -<⇒≢ (-<- n<m) refl = ℕ.<⇒≢ n<m refl -<⇒≢ (+<+ m<n) refl = ℕ.<⇒≢ m<n refl +<⇒≢ (-<- n<m) refl = ℕ.<⇒≢ n<m refl +<⇒≢ (+<+ m<n) refl = ℕ.<⇒≢ m<n refl <⇒≱ : _<_ _≱_ -<⇒≱ (-<- n<m) = ℕ.<⇒≱ n<m drop‿-≤- -<⇒≱ (+<+ m<n) = ℕ.<⇒≱ m<n drop‿+≤+ +<⇒≱ (-<- n<m) = ℕ.<⇒≱ n<m drop‿-≤- +<⇒≱ (+<+ m<n) = ℕ.<⇒≱ m<n drop‿+≤+ ≤⇒≯ : _≤_ _≯_ -≤⇒≯ (-≤- n≤m) (-<- n<m) = ℕ.≤⇒≯ n≤m n<m +≤⇒≯ (-≤- n≤m) (-<- n<m) = ℕ.≤⇒≯ n≤m n<m ≤⇒≯ -≤+ = +≮- -≤⇒≯ (+≤+ m≤n) (+<+ m<n) = ℕ.≤⇒≯ m≤n m<n +≤⇒≯ (+≤+ m≤n) (+<+ m<n) = ℕ.≤⇒≯ m≤n m<n ≰⇒> : _≰_ _>_ -≰⇒> {+ n} {+_ n₁} i≰j = +<+ (ℕ.≰⇒> (i≰j +≤+)) +≰⇒> {+ n} {+_ n₁} i≰j = +<+ (ℕ.≰⇒> (i≰j +≤+)) ≰⇒> {+ n} { -[1+_] n₁} i≰j = -<+ -≰⇒> { -[1+_] n} {+_ n₁} i≰j = contradiction -≤+ i≰j -≰⇒> { -[1+_] n} { -[1+_] n₁} i≰j = -<- (ℕ.≰⇒> (i≰j -≤-)) +≰⇒> { -[1+_] n} {+_ n₁} i≰j = contradiction -≤+ i≰j +≰⇒> { -[1+_] n} { -[1+_] n₁} i≰j = -<- (ℕ.≰⇒> (i≰j -≤-)) ≮⇒≥ : _≮_ _≥_ -≮⇒≥ {+ i} {+ j} i≮j = +≤+ (ℕ.≮⇒≥ (i≮j +<+)) +≮⇒≥ {+ i} {+ j} i≮j = +≤+ (ℕ.≮⇒≥ (i≮j +<+)) ≮⇒≥ {+ i} { -[1+_] j} i≮j = -≤+ -≮⇒≥ { -[1+_] i} {+ j} i≮j = contradiction -<+ i≮j -≮⇒≥ { -[1+_] i} { -[1+_] j} i≮j = -≤- (ℕ.≮⇒≥ (i≮j -<-)) +≮⇒≥ { -[1+_] i} {+ j} i≮j = contradiction -<+ i≮j +≮⇒≥ { -[1+_] i} { -[1+_] j} i≮j = -≤- (ℕ.≮⇒≥ (i≮j -<-)) >⇒≰ : _>_ _≰_ >⇒≰ = <⇒≱ ≤∧≢⇒< : i j i j i < j -≤∧≢⇒< (-≤- m≤n) i≢j = -<- (ℕ.≤∧≢⇒< m≤n (i≢j cong -[1+_] sym)) +≤∧≢⇒< (-≤- m≤n) i≢j = -<- (ℕ.≤∧≢⇒< m≤n (i≢j cong -[1+_] sym)) ≤∧≢⇒< -≤+ i≢j = -<+ -≤∧≢⇒< (+≤+ n≤m) i≢j = +<+ (ℕ.≤∧≢⇒< n≤m (i≢j cong (+_))) +≤∧≢⇒< (+≤+ n≤m) i≢j = +<+ (ℕ.≤∧≢⇒< n≤m (i≢j cong (+_))) ≤∧≮⇒≡ : i j i j i j ≤∧≮⇒≡ i≤j i≮j = ≤-antisym i≤j (≮⇒≥ i≮j) @@ -273,25 +273,25 @@ -- Relational properties <-irrefl : Irreflexive _≡_ _<_ -<-irrefl { -[1+ n ]} refl = ℕ.<-irrefl refl drop‿-<- +<-irrefl { -[1+ n ]} refl = ℕ.<-irrefl refl drop‿-<- <-irrefl { +0} refl (+<+ ()) -<-irrefl { +[1+ n ]} refl = ℕ.<-irrefl refl drop‿+<+ +<-irrefl { +[1+ n ]} refl = ℕ.<-irrefl refl drop‿+<+ <-asym : Asymmetric _<_ -<-asym (-<- n<m) = ℕ.<-asym n<m drop‿-<- -<-asym (+<+ m<n) = ℕ.<-asym m<n drop‿+<+ +<-asym (-<- n<m) = ℕ.<-asym n<m drop‿-<- +<-asym (+<+ m<n) = ℕ.<-asym m<n drop‿+<+ ≤-<-trans : LeftTrans _≤_ _<_ -≤-<-trans (-≤- n≤m) (-<- o<n) = -<- (ℕ.<-≤-trans o<n n≤m) +≤-<-trans (-≤- n≤m) (-<- o<n) = -<- (ℕ.<-≤-trans o<n n≤m) ≤-<-trans (-≤- n≤m) -<+ = -<+ ≤-<-trans -≤+ (+<+ m<o) = -<+ -≤-<-trans (+≤+ m≤n) (+<+ n<o) = +<+ (ℕ.≤-<-trans m≤n n<o) +≤-<-trans (+≤+ m≤n) (+<+ n<o) = +<+ (ℕ.≤-<-trans m≤n n<o) <-≤-trans : RightTrans _<_ _≤_ -<-≤-trans (-<- n<m) (-≤- o≤n) = -<- (ℕ.≤-<-trans o≤n n<m) +<-≤-trans (-<- n<m) (-≤- o≤n) = -<- (ℕ.≤-<-trans o≤n n<m) <-≤-trans (-<- n<m) -≤+ = -<+ <-≤-trans -<+ (+≤+ m≤n) = -<+ -<-≤-trans (+<+ m<n) (+≤+ n≤o) = +<+ (ℕ.<-≤-trans m<n n≤o) +<-≤-trans (+<+ m<n) (+≤+ n≤o) = +<+ (ℕ.<-≤-trans m<n n≤o) <-trans : Transitive _<_ <-trans m<n n<p = ≤-<-trans (<⇒≤ m<n) n<p @@ -302,26 +302,26 @@ <-cmp +[1+ n ] +0 = tri> +≮0 (λ()) (+<+ z<s) <-cmp (+ m) -[1+ n ] = tri> +≮- (λ()) -<+ <-cmp -[1+ m ] (+ n) = tri< -<+ (λ()) +≮- -<-cmp -[1+ m ] -[1+ n ] with ℕ.<-cmp m n +<-cmp -[1+ m ] -[1+ n ] with ℕ.<-cmp m n ... | tri< m<n m≢n n≯m = tri> (n≯m drop‿-<-) (m≢n -[1+-injective) (-<- m<n) ... | tri≈ m≮n m≡n n≯m = tri≈ (n≯m drop‿-<-) (cong -[1+_] m≡n) (m≮n drop‿-<-) ... | tri> m≮n m≢n n>m = tri< (-<- n>m) (m≢n -[1+-injective) (m≮n drop‿-<-) -<-cmp +[1+ m ] +[1+ n ] with ℕ.<-cmp m n +<-cmp +[1+ m ] +[1+ n ] with ℕ.<-cmp m n ... | tri< m<n m≢n n≯m = tri< (+<+ (s<s m<n)) (m≢n +[1+-injective) (n≯m s<s⁻¹ drop‿+<+) ... | tri≈ m≮n m≡n n≯m = tri≈ (m≮n s<s⁻¹ drop‿+<+) (cong (+_ suc) m≡n) (n≯m s<s⁻¹ drop‿+<+) ... | tri> m≮n m≢n n>m = tri> (m≮n s<s⁻¹ drop‿+<+) (m≢n +[1+-injective) (+<+ (s<s n>m)) infix 4 _<?_ _<?_ : Decidable _<_ --[1+ m ] <? -[1+ n ] = Dec.map′ -<- drop‿-<- (n ℕ.<? m) +-[1+ m ] <? -[1+ n ] = Dec.map′ -<- drop‿-<- (n ℕ.<? m) -[1+ m ] <? + n = yes -<+ + m <? -[1+ n ] = no λ() -+ m <? + n = Dec.map′ +<+ drop‿+<+ (m ℕ.<? n) ++ m <? + n = Dec.map′ +<+ drop‿+<+ (m ℕ.<? n) <-irrelevant : Irrelevant _<_ -<-irrelevant (-<- n<m₁) (-<- n<m₂) = cong -<- (ℕ.<-irrelevant n<m₁ n<m₂) +<-irrelevant (-<- n<m₁) (-<- n<m₂) = cong -<- (ℕ.<-irrelevant n<m₁ n<m₂) <-irrelevant -<+ -<+ = refl -<-irrelevant (+<+ m<n₁) (+<+ m<n₂) = cong +<+ (ℕ.<-irrelevant m<n₁ m<n₂) +<-irrelevant (+<+ m<n₁) (+<+ m<n₂) = cong +<+ (ℕ.<-irrelevant m<n₁ m<n₂) ------------------------------------------------------------------------ -- Structures @@ -466,8 +466,8 @@ n⊖n≡0 : n n n 0ℤ n⊖n≡0 n with n ℕ.<ᵇ n in leq -... | true = cong (-_ +_) (ℕ.n∸n≡0 n) -- this is actually impossible! -... | false = cong +_ (ℕ.n∸n≡0 n) +... | true = cong (-_ +_) (ℕ.n∸n≡0 n) -- this is actually impossible! +... | false = cong +_ (ℕ.n∸n≡0 n) [1+m]⊖[1+n]≡m⊖n : m n suc m suc n m n [1+m]⊖[1+n]≡m⊖n m n with m ℕ.<ᵇ n @@ -485,8 +485,8 @@ - (suc n suc m) where open ≡-Reasoning ⊖-≥ : m ℕ.≥ n m n + (m n) -⊖-≥ {m} {n} p with m ℕ.<ᵇ n | Reflects.invert (ℕ.<ᵇ-reflects-< m n) -... | true | q = contradiction (ℕ.≤-<-trans p q) (ℕ.<-irrefl refl) +⊖-≥ {m} {n} p with m ℕ.<ᵇ n | Reflects.invert (ℕ.<ᵇ-reflects-< m n) +... | true | q = contradiction (ℕ.≤-<-trans p q) (ℕ.<-irrefl refl) ... | false | q = refl ≤-⊖ : m ℕ.≤ n n m + (n m) @@ -498,15 +498,15 @@ + (suc n suc m) where open ≡-Reasoning ⊖-≤ : m ℕ.≤ n m n - + (n m) -⊖-≤ {m} {n} p with m ℕ.<ᵇ n | Reflects.invert (ℕ.<ᵇ-reflects-< m n) +⊖-≤ {m} {n} p with m ℕ.<ᵇ n | Reflects.invert (ℕ.<ᵇ-reflects-< m n) ... | true | q = refl -... | false | q rewrite ℕ.≤-antisym p (ℕ.≮⇒≥ q) | ℕ.n∸n≡0 n = refl +... | false | q rewrite ℕ.≤-antisym p (ℕ.≮⇒≥ q) | ℕ.n∸n≡0 n = refl ⊖-< : m ℕ.< n m n - + (n m) -⊖-< = ⊖-≤ ℕ.<⇒≤ +⊖-< = ⊖-≤ ℕ.<⇒≤ ⊖-≰ : n ℕ.≰ m m n - + (n m) -⊖-≰ = ⊖-< ℕ.≰⇒> +⊖-≰ = ⊖-< ℕ.≰⇒> ∣⊖∣-≤ : m ℕ.≤ n m n n m ∣⊖∣-≤ {m} {n} p = begin @@ -523,7 +523,7 @@ n m where open ≡-Reasoning ∣⊖∣-≰ : n ℕ.≰ m m n n m -∣⊖∣-≰ = ∣⊖∣-< ℕ.≰⇒> +∣⊖∣-≰ = ∣⊖∣-< ℕ.≰⇒> -m+n≡n⊖m : m n - (+ m) + + n n m -m+n≡n⊖m zero n = refl @@ -532,18 +532,18 @@ m-n≡m⊖n : m n + m + (- + n) m n m-n≡m⊖n zero zero = refl m-n≡m⊖n zero (suc n) = refl -m-n≡m⊖n (suc m) zero = cong +[1+_] (ℕ.+-identityʳ m) +m-n≡m⊖n (suc m) zero = cong +[1+_] (ℕ.+-identityʳ m) m-n≡m⊖n (suc m) (suc n) = refl -[n⊖m]≡-m+n : m n - (m n) (- (+ m)) + (+ n) --[n⊖m]≡-m+n m n with m ℕ.<ᵇ n | Reflects.invert (ℕ.<ᵇ-reflects-< m n) +-[n⊖m]≡-m+n m n with m ℕ.<ᵇ n | Reflects.invert (ℕ.<ᵇ-reflects-< m n) ... | true | p = begin - (- (+ (n m))) ≡⟨ neg-involutive (+ (n m)) - + (n m) ≡⟨ ⊖-≥ (ℕ.≤-trans (ℕ.m≤n+m m 1) p) + + (n m) ≡⟨ ⊖-≥ (ℕ.≤-trans (ℕ.m≤n+m m 1) p) n m ≡⟨ -m+n≡n⊖m m n - (+ m) + + n where open ≡-Reasoning ... | false | p = begin - - (+ (m n)) ≡⟨ ⊖-≤ (ℕ.≮⇒≥ p) + - (+ (m n)) ≡⟨ ⊖-≤ (ℕ.≮⇒≥ p) n m ≡⟨ -m+n≡n⊖m m n - (+ m) + + n where open ≡-Reasoning @@ -566,11 +566,11 @@ m⊖n≤m (suc m) (suc n) = begin suc m suc n ≡⟨ [1+m]⊖[1+n]≡m⊖n m n m n ≤⟨ m⊖n≤m m n - + m ≤⟨ +≤+ (ℕ.n≤1+n m) + + m ≤⟨ +≤+ (ℕ.n≤1+n m) +[1+ m ] where open ≤-Reasoning m⊖n<1+m : m n m n < +[1+ m ] -m⊖n<1+m m n = ≤-<-trans (m⊖n≤m m n) (+<+ (ℕ.m<n+m m z<s)) +m⊖n<1+m m n = ≤-<-trans (m⊖n≤m m n) (+<+ (ℕ.m<n+m m z<s)) m⊖1+n<m : m n .{{_ : ℕ.NonZero n}} m n < + m m⊖1+n<m zero (suc n) = -<+ @@ -581,9 +581,9 @@ -1+m<n⊖m : m n -[1+ m ] < n m -1+m<n⊖m zero n = -<+ --1+m<n⊖m (suc m) zero = -<- ℕ.≤-refl +-1+m<n⊖m (suc m) zero = -<- ℕ.≤-refl -1+m<n⊖m (suc m) (suc n) = begin-strict - -[1+ suc m ] <⟨ -<- ℕ.≤-refl + -[1+ suc m ] <⟨ -<- ℕ.≤-refl -[1+ m ] <⟨ -1+m<n⊖m m n n m ≡⟨ [1+m]⊖[1+n]≡m⊖n n m suc n suc m where open ≤-Reasoning @@ -610,7 +610,7 @@ Sign.- where open ≡-Reasoning sign-⊖-≰ : n ℕ.≰ m sign (m n) Sign.- -sign-⊖-≰ = sign-⊖-< ℕ.≰⇒> +sign-⊖-≰ = sign-⊖-< ℕ.≰⇒> ⊖-monoʳ-≥-≤ : LeftMonotonic ℕ._≥_ _≤_ _⊖_ ⊖-monoʳ-≥-≤ zero {m} z≤n = 0⊖m≤+ m @@ -630,7 +630,7 @@ ⊖-monoˡ-≤ zero {_} {_} m≤o = +≤+ m≤o ⊖-monoˡ-≤ (suc n) {_} {0} z≤n = ≤-refl ⊖-monoˡ-≤ (suc n) {_} {suc o} z≤n = begin - zero suc n ≤⟨ ⊖-monoʳ-≥-≤ 0 (ℕ.n≤1+n n) + zero suc n ≤⟨ ⊖-monoʳ-≥-≤ 0 (ℕ.n≤1+n n) zero n ≤⟨ ⊖-monoˡ-≤ n z≤n o n ≡⟨ [1+m]⊖[1+n]≡m⊖n o n suc o suc n where open ≤-Reasoning @@ -680,40 +680,40 @@ +∣i∣≡i⊎+∣i∣≡-i (-[1+ n ]) = inj₂ refl ∣m⊝n∣≤m⊔n : m n m n ℕ.≤ m ℕ.⊔ n -∣m⊝n∣≤m⊔n = wlog ℕ.≤-total +∣m⊝n∣≤m⊔n = wlog ℕ.≤-total {m n} subst₂ ℕ._≤_ (∣m⊖n∣≡∣n⊖m∣ m n) (ℕ.⊔-comm m n)) $′ λ m n m≤n begin m n ≡⟨ cong ∣_∣ (⊖-≤ m≤n) - + (n ℕ.∸ m) ≡⟨ ∣-i∣≡∣i∣ (+ (n ℕ.∸ m)) + (n ℕ.∸ m) ≡⟨⟩ - n ℕ.∸ m ≤⟨ ℕ.m∸n≤m n m - n ≤⟨ ℕ.m≤n⊔m m n + n ℕ.∸ m ≤⟨ ℕ.m∸n≤m n m + n ≤⟨ ℕ.m≤n⊔m m n m ℕ.⊔ n - where open ℕ.≤-Reasoning + where open ℕ.≤-Reasoning ∣i+j∣≤∣i∣+∣j∣ : i j i + j ℕ.≤ i ℕ.+ j -∣i+j∣≤∣i∣+∣j∣ +[1+ m ] (+ n) = ℕ.≤-refl -∣i+j∣≤∣i∣+∣j∣ +0 (+ n) = ℕ.≤-refl -∣i+j∣≤∣i∣+∣j∣ +0 -[1+ n ] = ℕ.≤-refl -∣i+j∣≤∣i∣+∣j∣ -[1+ m ] -[1+ n ] rewrite ℕ.+-suc (suc m) n = ℕ.≤-refl +∣i+j∣≤∣i∣+∣j∣ +[1+ m ] (+ n) = ℕ.≤-refl +∣i+j∣≤∣i∣+∣j∣ +0 (+ n) = ℕ.≤-refl +∣i+j∣≤∣i∣+∣j∣ +0 -[1+ n ] = ℕ.≤-refl +∣i+j∣≤∣i∣+∣j∣ -[1+ m ] -[1+ n ] rewrite ℕ.+-suc (suc m) n = ℕ.≤-refl ∣i+j∣≤∣i∣+∣j∣ +[1+ m ] -[1+ n ] = begin suc m suc n ≤⟨ ∣m⊝n∣≤m⊔n (suc m) (suc n) - suc m ℕ.⊔ suc n ≤⟨ ℕ.m⊔n≤m+n (suc m) (suc n) + suc m ℕ.⊔ suc n ≤⟨ ℕ.m⊔n≤m+n (suc m) (suc n) suc m ℕ.+ suc n - where open ℕ.≤-Reasoning + where open ℕ.≤-Reasoning ∣i+j∣≤∣i∣+∣j∣ -[1+ m ] (+ n) = begin n suc m ≤⟨ ∣m⊝n∣≤m⊔n n (suc m) - n ℕ.⊔ suc m ≤⟨ ℕ.m⊔n≤m+n n (suc m) - n ℕ.+ suc m ≡⟨ ℕ.+-comm n (suc m) + n ℕ.⊔ suc m ≤⟨ ℕ.m⊔n≤m+n n (suc m) + n ℕ.+ suc m ≡⟨ ℕ.+-comm n (suc m) suc m ℕ.+ n - where open ℕ.≤-Reasoning + where open ℕ.≤-Reasoning ∣i-j∣≤∣i∣+∣j∣ : i j i - j ℕ.≤ i ℕ.+ j ∣i-j∣≤∣i∣+∣j∣ i j = begin i - j ≤⟨ ∣i+j∣≤∣i∣+∣j∣ i (- j) i ℕ.+ - j ≡⟨ cong ( i ℕ.+_) (∣-i∣≡∣i∣ j) i ℕ.+ j - where open ℕ.≤-Reasoning + where open ℕ.≤-Reasoning ------------------------------------------------------------------------ -- Properties of sign and _◃_ @@ -809,8 +809,8 @@ -- Algebraic properties of _+_ +-comm : Commutative _+_ -+-comm -[1+ m ] -[1+ n ] = cong (-[1+_] suc) (ℕ.+-comm m n) -+-comm (+ m) (+ n) = cong +_ (ℕ.+-comm m n) ++-comm -[1+ m ] -[1+ n ] = cong (-[1+_] suc) (ℕ.+-comm m n) ++-comm (+ m) (+ n) = cong +_ (ℕ.+-comm m n) +-comm -[1+ _ ] (+ _) = refl +-comm (+ _) -[1+ _ ] = refl @@ -848,14 +848,14 @@ distribʳ-⊖-+-pos m n o = begin + m + (n o) ≡⟨ +-comm (+ m) (n o) (n o) + + m ≡⟨ distribˡ-⊖-+-pos m n o - n ℕ.+ m o ≡⟨ cong (_⊖ o) (ℕ.+-comm n m) + n ℕ.+ m o ≡⟨ cong (_⊖ o) (ℕ.+-comm n m) m ℕ.+ n o where open ≡-Reasoning distribʳ-⊖-+-neg : m n o -[1+ m ] + (n o) n (suc m ℕ.+ o) distribʳ-⊖-+-neg m n o = begin -[1+ m ] + (n o) ≡⟨ +-comm -[1+ m ] (n o) (n o) + -[1+ m ] ≡⟨ distribˡ-⊖-+-neg m n o - n suc (o ℕ.+ m) ≡⟨ cong x n suc x) (ℕ.+-comm o m) + n suc (o ℕ.+ m) ≡⟨ cong x n suc x) (ℕ.+-comm o m) n suc (m ℕ.+ o) where open ≡-Reasoning +-assoc : Associative _+_ @@ -882,20 +882,20 @@ | [1+m]⊖[1+n]≡m⊖n o n | distribˡ-⊖-+-pos (suc o) m n | distribʳ-⊖-+-pos (suc m) o n - | sym (ℕ.+-assoc m 1 o) - | ℕ.+-comm m 1 + | sym (ℕ.+-assoc m 1 o) + | ℕ.+-comm m 1 = refl +-assoc +[1+ m ] +[1+ n ] -[1+ o ] rewrite [1+m]⊖[1+n]≡m⊖n n o | [1+m]⊖[1+n]≡m⊖n (m ℕ.+ suc n) o | distribʳ-⊖-+-pos (suc m) n o - | sym (ℕ.+-assoc m 1 n) - | ℕ.+-comm m 1 + | sym (ℕ.+-assoc m 1 n) + | ℕ.+-comm m 1 = refl +-assoc -[1+ m ] -[1+ n ] -[1+ o ] - rewrite sym (ℕ.+-assoc m 1 (n ℕ.+ o)) - | ℕ.+-comm m 1 - | ℕ.+-assoc m n o + rewrite sym (ℕ.+-assoc m 1 (n ℕ.+ o)) + | ℕ.+-comm m 1 + | ℕ.+-assoc m n o = refl +-assoc -[1+ m ] +[1+ n ] -[1+ o ] rewrite [1+m]⊖[1+n]≡m⊖n n m @@ -904,7 +904,7 @@ | distribˡ-⊖-+-neg o n m = refl +-assoc +[1+ m ] +[1+ n ] +[1+ o ] - rewrite ℕ.+-assoc (suc m) (suc n) (suc o) + rewrite ℕ.+-assoc (suc m) (suc n) (suc o) = refl +-inverseˡ : LeftInverse +0 -_ _+_ @@ -1007,9 +1007,9 @@ neg-distrib-+ : i j - (i + j) (- i) + (- j) neg-distrib-+ +0 +0 = refl neg-distrib-+ +0 +[1+ n ] = refl -neg-distrib-+ +[1+ m ] +0 = cong -[1+_] (ℕ.+-identityʳ m) -neg-distrib-+ +[1+ m ] +[1+ n ] = cong -[1+_] (ℕ.+-suc m n) -neg-distrib-+ -[1+ m ] -[1+ n ] = cong +[1+_] (sym (ℕ.+-suc m n)) +neg-distrib-+ +[1+ m ] +0 = cong -[1+_] (ℕ.+-identityʳ m) +neg-distrib-+ +[1+ m ] +[1+ n ] = cong -[1+_] (ℕ.+-suc m n) +neg-distrib-+ -[1+ m ] -[1+ n ] = cong +[1+_] (sym (ℕ.+-suc m n)) neg-distrib-+ (+ m) -[1+ n ] = -[n⊖m]≡-m+n m (suc n) neg-distrib-+ -[1+ m ] (+ n) = trans (-[n⊖m]≡-m+n n (suc m)) (+-comm (- + n) (+ suc m)) @@ -1032,10 +1032,10 @@ +-monoʳ-≤ : LeftMonotonic _≤_ _≤_ _+_ +-monoʳ-≤ (+ n) {_} (-≤- o≤m) = ⊖-monoʳ-≥-≤ n (s≤s o≤m) -+-monoʳ-≤ (+ n) { -[1+ m ]} -≤+ = ≤-trans (m⊖n≤m n (suc m)) (+≤+ (ℕ.m≤m+n n _)) -+-monoʳ-≤ (+ n) {_} (+≤+ m≤o) = +≤+ (ℕ.+-monoʳ-≤ n m≤o) -+-monoʳ-≤ -[1+ n ] {_} {_} (-≤- n≤m) = -≤- (ℕ.+-monoʳ-≤ (suc n) n≤m) -+-monoʳ-≤ -[1+ n ] {_} {+ m} -≤+ = ≤-trans (-≤- (ℕ.m≤m+n (suc n) _)) (-1+m≤n⊖m (suc n) m) ++-monoʳ-≤ (+ n) { -[1+ m ]} -≤+ = ≤-trans (m⊖n≤m n (suc m)) (+≤+ (ℕ.m≤m+n n _)) ++-monoʳ-≤ (+ n) {_} (+≤+ m≤o) = +≤+ (ℕ.+-monoʳ-≤ n m≤o) ++-monoʳ-≤ -[1+ n ] {_} {_} (-≤- n≤m) = -≤- (ℕ.+-monoʳ-≤ (suc n) n≤m) ++-monoʳ-≤ -[1+ n ] {_} {+ m} -≤+ = ≤-trans (-≤- (ℕ.m≤m+n (suc n) _)) (-1+m≤n⊖m (suc n) m) +-monoʳ-≤ -[1+ n ] {_} {_} (+≤+ m≤n) = ⊖-monoˡ-≤ (suc n) m≤n +-monoˡ-≤ : RightMonotonic _≤_ _≤_ _+_ @@ -1062,10 +1062,10 @@ +-monoʳ-< : LeftMonotonic _<_ _<_ _+_ +-monoʳ-< (+ n) {_} {_} (-<- o<m) = ⊖-monoʳ->-< n (s<s o<m) -+-monoʳ-< (+ n) {_} {_} -<+ = <-≤-trans (m⊖1+n<m n _) (+≤+ (ℕ.m≤m+n n _)) -+-monoʳ-< (+ n) {_} {_} (+<+ m<o) = +<+ (ℕ.+-monoʳ-< n m<o) -+-monoʳ-< -[1+ n ] {_} {_} (-<- o<m) = -<- (ℕ.+-monoʳ-< (suc n) o<m) -+-monoʳ-< -[1+ n ] {_} {+ o} -<+ = <-≤-trans (-<- (ℕ.m≤m+n (suc n) _)) (-[1+m]≤n⊖m+1 n o) ++-monoʳ-< (+ n) {_} {_} -<+ = <-≤-trans (m⊖1+n<m n _) (+≤+ (ℕ.m≤m+n n _)) ++-monoʳ-< (+ n) {_} {_} (+<+ m<o) = +<+ (ℕ.+-monoʳ-< n m<o) ++-monoʳ-< -[1+ n ] {_} {_} (-<- o<m) = -<- (ℕ.+-monoʳ-< (suc n) o<m) ++-monoʳ-< -[1+ n ] {_} {+ o} -<+ = <-≤-trans (-<- (ℕ.m≤m+n (suc n) _)) (-[1+m]≤n⊖m+1 n o) +-monoʳ-< -[1+ n ] {_} {_} (+<+ m<o) = ⊖-monoˡ-< (suc n) m<o +-monoˡ-< : RightMonotonic _<_ _<_ _+_ @@ -1090,8 +1090,8 @@ neg-minus-pos : m n -[1+ m ] - (+ n) -[1+ (n ℕ.+ m) ] neg-minus-pos m zero = refl -neg-minus-pos zero (suc n) = cong (-[1+_] suc) (sym (ℕ.+-identityʳ n)) -neg-minus-pos (suc m) (suc n) = cong (-[1+_] suc) (ℕ.+-comm (suc m) n) +neg-minus-pos zero (suc n) = cong (-[1+_] suc) (sym (ℕ.+-identityʳ n)) +neg-minus-pos (suc m) (suc n) = cong (-[1+_] suc) (ℕ.+-comm (suc m) n) +-minus-telescope : i j k (i - j) + (j - k) i - k +-minus-telescope i j k = begin @@ -1105,17 +1105,17 @@ [+m]-[+n]≡m⊖n : m n (+ m) - (+ n) m n [+m]-[+n]≡m⊖n zero zero = refl [+m]-[+n]≡m⊖n zero (suc n) = refl -[+m]-[+n]≡m⊖n (suc m) zero = cong +[1+_] (ℕ.+-identityʳ m) +[+m]-[+n]≡m⊖n (suc m) zero = cong +[1+_] (ℕ.+-identityʳ m) [+m]-[+n]≡m⊖n (suc m) (suc n) = refl ∣i-j∣≡∣j-i∣ : i j i - j j - i ∣i-j∣≡∣j-i∣ -[1+ m ] -[1+ n ] = ∣m⊖n∣≡∣n⊖m∣ (suc n) (suc m) ∣i-j∣≡∣j-i∣ -[1+ m ] (+ n) = begin -[1+ m ] - (+ n) ≡⟨ cong ∣_∣ (neg-minus-pos m n) - suc (n ℕ.+ m) ≡⟨ ℕ.+-suc n m + suc (n ℕ.+ m) ≡⟨ ℕ.+-suc n m n ℕ.+ suc m where open ≡-Reasoning ∣i-j∣≡∣j-i∣ (+ m) -[1+ n ] = begin - m ℕ.+ suc n ≡⟨ ℕ.+-suc m n + m ℕ.+ suc n ≡⟨ ℕ.+-suc m n suc (m ℕ.+ n) ≡⟨ cong ∣_∣ (neg-minus-pos n m) -[1+ n ] + - + m where open ≡-Reasoning ∣i-j∣≡∣j-i∣ (+ m) (+ n) = begin @@ -1134,7 +1134,7 @@ ∣-∣-≤ (-≤+ {m} {zero}) = refl ∣-∣-≤ (-≤+ {m} {suc n}) = begin + -[1+ m ] - + suc n ≡⟨⟩ - + suc (suc m ℕ.+ n) ≡⟨ cong n + suc n) (ℕ.+-comm (suc m) n) + + suc (suc m ℕ.+ n) ≡⟨ cong n + suc n) (ℕ.+-comm (suc m) n) + (suc n ℕ.+ suc m) ≡⟨⟩ + suc n - -[1+ m ] where open ≡-Reasoning ∣-∣-≤ (+≤+ {m} {n} m≤n) = begin @@ -1159,7 +1159,7 @@ i≤j⇒i-k≤j : k .{{_ : NonNegative k}} i j i - k j i≤j⇒i-k≤j {i} +0 i≤j rewrite +-identityʳ i = i≤j i≤j⇒i-k≤j {+ m} +[1+ n ] i≤j = ≤-trans (m⊖n≤m m (suc n)) i≤j -i≤j⇒i-k≤j { -[1+ m ]} +[1+ n ] i≤j = ≤-trans (-≤- (ℕ.≤-trans (ℕ.m≤m+n m n) (ℕ.n≤1+n _))) i≤j +i≤j⇒i-k≤j { -[1+ m ]} +[1+ n ] i≤j = ≤-trans (-≤- (ℕ.≤-trans (ℕ.m≤m+n m n) (ℕ.n≤1+n _))) i≤j i-j≤i : i j .{{_ : NonNegative j}} i - j i i-j≤i i j = i≤j⇒i-k≤j j ≤-refl @@ -1291,7 +1291,7 @@ i≤pred[j]⇒i<j : i pred j i < j i≤pred[j]⇒i<j {_} { + n} leq = ≤-<-trans leq (m⊖1+n<m n 1) -i≤pred[j]⇒i<j {_} { -[1+ n ]} leq = ≤-<-trans leq (-<- ℕ.≤-refl) +i≤pred[j]⇒i<j {_} { -[1+ n ]} leq = ≤-<-trans leq (-<- ℕ.≤-refl) i<j⇒i≤pred[j] : i < j i pred j i<j⇒i≤pred[j] {_} { +0} -<+ = -≤- z≤n @@ -1301,9 +1301,9 @@ i≤j⇒pred[i]≤j : i j pred i j i≤j⇒pred[i]≤j -≤+ = -≤+ -i≤j⇒pred[i]≤j (-≤- n≤m) = -≤- (ℕ.m≤n⇒m≤1+n n≤m) +i≤j⇒pred[i]≤j (-≤- n≤m) = -≤- (ℕ.m≤n⇒m≤1+n n≤m) i≤j⇒pred[i]≤j (+≤+ z≤n) = -≤+ -i≤j⇒pred[i]≤j (+≤+ (s≤s m≤n)) = +≤+ (ℕ.m≤n⇒m≤1+n m≤n) +i≤j⇒pred[i]≤j (+≤+ (s≤s m≤n)) = +≤+ (ℕ.m≤n⇒m≤1+n m≤n) pred-mono : pred Preserves _≤_ _≤_ pred-mono (-≤+ {n = 0}) = -≤- z≤n @@ -1317,15 +1317,15 @@ -- Algebraic properties *-comm : Commutative _*_ -*-comm -[1+ m ] -[1+ n ] rewrite ℕ.*-comm (suc m) (suc n) = refl -*-comm -[1+ m ] (+ n) rewrite ℕ.*-comm (suc m) n = refl -*-comm (+ m) -[1+ n ] rewrite ℕ.*-comm m (suc n) = refl -*-comm (+ m) (+ n) rewrite ℕ.*-comm m n = refl +*-comm -[1+ m ] -[1+ n ] rewrite ℕ.*-comm (suc m) (suc n) = refl +*-comm -[1+ m ] (+ n) rewrite ℕ.*-comm (suc m) n = refl +*-comm (+ m) -[1+ n ] rewrite ℕ.*-comm m (suc n) = refl +*-comm (+ m) (+ n) rewrite ℕ.*-comm m n = refl *-identityˡ : LeftIdentity 1ℤ _*_ -*-identityˡ -[1+ n ] rewrite ℕ.+-identityʳ n = refl +*-identityˡ -[1+ n ] rewrite ℕ.+-identityʳ n = refl *-identityˡ +0 = refl -*-identityˡ +[1+ n ] rewrite ℕ.+-identityʳ n = refl +*-identityˡ +[1+ n ] rewrite ℕ.+-identityʳ n = refl *-identityʳ : RightIdentity 1ℤ _*_ *-identityʳ = comm∧idˡ⇒idʳ *-comm *-identityˡ @@ -1344,11 +1344,11 @@ *-assoc : Associative _*_ *-assoc +0 _ _ = refl -*-assoc i +0 _ rewrite ℕ.*-zeroʳ i = refl +*-assoc i +0 _ rewrite ℕ.*-zeroʳ i = refl *-assoc i j +0 rewrite - ℕ.*-zeroʳ j - | ℕ.*-zeroʳ i - | ℕ.*-zeroʳ sign i Sign.* sign j i ℕ.* j + ℕ.*-zeroʳ j + | ℕ.*-zeroʳ i + | ℕ.*-zeroʳ sign i Sign.* sign j i ℕ.* j = refl *-assoc -[1+ m ] -[1+ n ] +[1+ o ] = cong (+_ suc) (inner-assoc m n o) *-assoc -[1+ m ] +[1+ n ] -[1+ o ] = cong (+_ suc) (inner-assoc m n o) @@ -1366,27 +1366,27 @@ distrib-lemma m n o rewrite +-cancelˡ-⊖ m (n ℕ.* suc m) (o ℕ.* suc m) | ⊖-swap (n ℕ.* suc m) (o ℕ.* suc m) - with n ℕ.≤? o + with n ℕ.≤? o ... | yes n≤o rewrite ⊖-≥ n≤o - | ⊖-≥ (ℕ.*-mono-≤ n≤o (ℕ.≤-refl {x = suc m})) + | ⊖-≥ (ℕ.*-mono-≤ n≤o (ℕ.≤-refl {x = suc m})) | -◃n≡-n ((o n) ℕ.* suc m) - | ℕ.*-distribʳ-∸ (suc m) o n + | ℕ.*-distribʳ-∸ (suc m) o n = refl ... | no n≰o rewrite sign-⊖-≰ n≰o | ∣⊖∣-≰ n≰o | +◃n≡+n ((n o) ℕ.* suc m) - | ⊖-≰ (n≰o ℕ.*-cancelʳ-≤ n o (suc m)) + | ⊖-≰ (n≰o ℕ.*-cancelʳ-≤ n o (suc m)) | neg-involutive (+ (n ℕ.* suc m o ℕ.* suc m)) - | ℕ.*-distribʳ-∸ (suc m) n o + | ℕ.*-distribʳ-∸ (suc m) n o = refl *-distribʳ-+ : _*_ DistributesOverʳ _+_ *-distribʳ-+ +0 y z - rewrite ℕ.*-zeroʳ y - | ℕ.*-zeroʳ z - | ℕ.*-zeroʳ y + z + rewrite ℕ.*-zeroʳ y + | ℕ.*-zeroʳ z + | ℕ.*-zeroʳ y + z = refl *-distribʳ-+ x +0 z rewrite +-identityˡ z @@ -1410,14 +1410,14 @@ (n o) * -[1+ m ] ≡⟨ distrib-lemma m o n m ℕ.+ o ℕ.* suc m (m ℕ.+ n ℕ.* suc m) ≡⟨ [1+m]⊖[1+n]≡m⊖n (m ℕ.+ o ℕ.* suc m) (m ℕ.+ n ℕ.* suc m) +[1+ n ] * -[1+ m ] + -[1+ o ] * -[1+ m ] where open ≡-Reasoning -*-distribʳ-+ +[1+ m ] -[1+ n ] +[1+ o ] with n ℕ.≤? o +*-distribʳ-+ +[1+ m ] -[1+ n ] +[1+ o ] with n ℕ.≤? o ... | yes n≤o rewrite [1+m]⊖[1+n]≡m⊖n o n | [1+m]⊖[1+n]≡m⊖n (m ℕ.+ o ℕ.* suc m) (m ℕ.+ n ℕ.* suc m) | +-cancelˡ-⊖ m (o ℕ.* suc m) (n ℕ.* suc m) | ⊖-≥ n≤o - | ⊖-≥ (ℕ.*-mono-≤ n≤o (ℕ.≤-refl {x = suc m})) - | ℕ.*-distribʳ-∸ (suc m) o n + | ⊖-≥ (ℕ.*-mono-≤ n≤o (ℕ.≤-refl {x = suc m})) + | ℕ.*-distribʳ-∸ (suc m) o n | +◃n≡+n (o ℕ.* suc m n ℕ.* suc m) = refl ... | no n≰o @@ -1427,18 +1427,18 @@ | sign-⊖-≰ n≰o | ∣⊖∣-≰ n≰o | -◃n≡-n ((n o) ℕ.* suc m) - | ⊖-≰ (n≰o ℕ.*-cancelʳ-≤ n o (suc m)) - | ℕ.*-distribʳ-∸ (suc m) n o + | ⊖-≰ (n≰o ℕ.*-cancelʳ-≤ n o (suc m)) + | ℕ.*-distribʳ-∸ (suc m) n o = refl -*-distribʳ-+ +[1+ o ] +[1+ m ] -[1+ n ] with n ℕ.≤? m +*-distribʳ-+ +[1+ o ] +[1+ m ] -[1+ n ] with n ℕ.≤? m ... | yes n≤m rewrite [1+m]⊖[1+n]≡m⊖n m n | [1+m]⊖[1+n]≡m⊖n (o ℕ.+ m ℕ.* suc o) (o ℕ.+ n ℕ.* suc o) | +-cancelˡ-⊖ o (m ℕ.* suc o) (n ℕ.* suc o) | ⊖-≥ n≤m - | ⊖-≥ (ℕ.*-mono-≤ n≤m (ℕ.≤-refl {x = suc o})) + | ⊖-≥ (ℕ.*-mono-≤ n≤m (ℕ.≤-refl {x = suc o})) | +◃n≡+n ((m n) ℕ.* suc o) - | ℕ.*-distribʳ-∸ (suc o) m n + | ℕ.*-distribʳ-∸ (suc o) m n = refl ... | no n≰m rewrite [1+m]⊖[1+n]≡m⊖n m n @@ -1446,9 +1446,9 @@ | +-cancelˡ-⊖ o (m ℕ.* suc o) (n ℕ.* suc o) | sign-⊖-≰ n≰m | ∣⊖∣-≰ n≰m - | ⊖-≰ (n≰m ℕ.*-cancelʳ-≤ n m (suc o)) + | ⊖-≰ (n≰m ℕ.*-cancelʳ-≤ n m (suc o)) | -◃n≡-n ((n m) ℕ.* suc o) - | ℕ.*-distribʳ-∸ (suc o) n m + | ℕ.*-distribʳ-∸ (suc o) n m = refl *-distribˡ-+ : _*_ DistributesOverˡ _+_ @@ -1490,37 +1490,37 @@ ; comm = *-comm } -+-*-isSemiring : IsSemiring _+_ _*_ 0ℤ 1ℤ ++-*-isSemiring : IsSemiring _+_ _*_ 0ℤ 1ℤ +-*-isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-0-isCommutativeMonoid - ; *-cong = cong₂ _*_ - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = *-distrib-+ + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = +-0-isCommutativeMonoid + ; *-cong = cong₂ _*_ + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = *-distrib-+ } - ; zero = *-zero + ; zero = *-zero } -+-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0ℤ 1ℤ ++-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0ℤ 1ℤ +-*-isCommutativeSemiring = record - { isSemiring = +-*-isSemiring - ; *-comm = *-comm + { isSemiring = +-*-isSemiring + ; *-comm = *-comm } -+-*-isRing : IsRing _+_ _*_ -_ 0ℤ 1ℤ ++-*-isRing : IsRing _+_ _*_ -_ 0ℤ 1ℤ +-*-isRing = record - { +-isAbelianGroup = +-0-isAbelianGroup - ; *-cong = cong₂ _*_ - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = *-distrib-+ + { +-isAbelianGroup = +-0-isAbelianGroup + ; *-cong = cong₂ _*_ + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = *-distrib-+ } -+-*-isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0ℤ 1ℤ ++-*-isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0ℤ 1ℤ +-*-isCommutativeRing = record - { isRing = +-*-isRing - ; *-comm = *-comm + { isRing = +-*-isRing + ; *-comm = *-comm } ------------------------------------------------------------------------ @@ -1584,10 +1584,10 @@ *-cancelʳ-≡ i j k eq with sign-cong′ eq ... | inj₁ s[ik]≡s[jk] = ◃-cong (Sign.*-cancelʳ-≡ (sign k) (sign i) (sign j) s[ik]≡s[jk]) - (ℕ.*-cancelʳ-≡ i j _ (abs-cong eq)) + (ℕ.*-cancelʳ-≡ i j _ (abs-cong eq)) ... | inj₂ (∣ik∣≡0 , ∣jk∣≡0) = trans - (∣i∣≡0⇒i≡0 (ℕ.m*n≡0⇒m≡0 _ _ ∣ik∣≡0)) - (sym (∣i∣≡0⇒i≡0 (ℕ.m*n≡0⇒m≡0 _ _ ∣jk∣≡0))) + (∣i∣≡0⇒i≡0 (ℕ.m*n≡0⇒m≡0 _ _ ∣ik∣≡0)) + (sym (∣i∣≡0⇒i≡0 (ℕ.m*n≡0⇒m≡0 _ _ ∣jk∣≡0))) *-cancelˡ-≡ : i j k .{{_ : NonZero i}} i * j i * k j k *-cancelˡ-≡ i j k rewrite *-comm i j | *-comm i k = *-cancelʳ-≡ j k i @@ -1608,17 +1608,17 @@ where open ≡-Reasoning -1*i≡-i : i -1ℤ * i - i --1*i≡-i -[1+ n ] = cong +[1+_] (ℕ.+-identityʳ n) +-1*i≡-i -[1+ n ] = cong +[1+_] (ℕ.+-identityʳ n) -1*i≡-i +0 = refl --1*i≡-i +[1+ n ] = cong -[1+_] (ℕ.+-identityʳ n) +-1*i≡-i +[1+ n ] = cong -[1+_] (ℕ.+-identityʳ n) i*j≡0⇒i≡0∨j≡0 : i {j} i * j 0ℤ i 0ℤ j 0ℤ -i*j≡0⇒i≡0∨j≡0 i p with ℕ.m*n≡0⇒m≡0∨n≡0 i (abs-cong {t = Sign.+} p) +i*j≡0⇒i≡0∨j≡0 i p with ℕ.m*n≡0⇒m≡0∨n≡0 i (abs-cong {t = Sign.+} p) ... | inj₁ ∣i∣≡0 = inj₁ (∣i∣≡0⇒i≡0 ∣i∣≡0) ... | inj₂ ∣j∣≡0 = inj₂ (∣i∣≡0⇒i≡0 ∣j∣≡0) i*j≢0 : i j .{{_ : NonZero i}} .{{_ : NonZero j}} NonZero (i * j) -i*j≢0 i j rewrite abs-* i j = ℕ.m*n≢0 i j +i*j≢0 i j rewrite abs-* i j = ℕ.m*n≢0 i j ------------------------------------------------------------------------ -- Properties of _^_ @@ -1657,11 +1657,11 @@ } ^-*-assoc : i m n (i ^ m) ^ n i ^ (m ℕ.* n) -^-*-assoc i m zero = cong (i ^_) (sym $ ℕ.*-zeroʳ m) +^-*-assoc i m zero = cong (i ^_) (sym $ ℕ.*-zeroʳ m) ^-*-assoc i m (suc n) = begin (i ^ m) * ((i ^ m) ^ n) ≡⟨ cong ((i ^ m) *_) (^-*-assoc i m n) (i ^ m) * (i ^ (m ℕ.* n)) ≡⟨ sym (^-distribˡ-+-* i m (m ℕ.* n)) - i ^ (m ℕ.+ m ℕ.* n) ≡⟨ cong (i ^_) (sym (ℕ.*-suc m n)) + i ^ (m ℕ.+ m ℕ.* n) ≡⟨ cong (i ^_) (sym (ℕ.*-suc m n)) i ^ (m ℕ.* suc n) where open ≡-Reasoning @@ -1698,7 +1698,7 @@ ◃-distrib-* s t zero (suc n) = refl ◃-distrib-* s t (suc m) zero = trans - (cong₂ _◃_ (Sign.*-comm s t) (ℕ.*-comm m 0)) + (cong₂ _◃_ (Sign.*-comm s t) (ℕ.*-comm m 0)) (*-comm (t zero) (s suc m)) ◃-distrib-* s t (suc m) (suc n) = sym (cong₂ _◃_ @@ -1710,13 +1710,13 @@ *-cancelʳ-≤-pos : i j k .{{_ : Positive k}} i * k j * k i j *-cancelʳ-≤-pos -[1+ m ] -[1+ n ] +[1+ o ] (-≤- n≤m) = - -≤- (s≤s⁻¹ (ℕ.*-cancelʳ-≤ (suc n) (suc m) (suc o) (s≤s n≤m))) + -≤- (s≤s⁻¹ (ℕ.*-cancelʳ-≤ (suc n) (suc m) (suc o) (s≤s n≤m))) *-cancelʳ-≤-pos -[1+ _ ] (+ _) +[1+ o ] _ = -≤+ *-cancelʳ-≤-pos +0 +0 +[1+ o ] _ = +≤+ z≤n *-cancelʳ-≤-pos +0 +[1+ _ ] +[1+ o ] _ = +≤+ z≤n *-cancelʳ-≤-pos +[1+ _ ] +0 +[1+ o ] (+≤+ ()) *-cancelʳ-≤-pos +[1+ m ] +[1+ n ] +[1+ o ] (+≤+ m≤n) = - +≤+ (ℕ.*-cancelʳ-≤ (suc m) (suc n) (suc o) m≤n) + +≤+ (ℕ.*-cancelʳ-≤ (suc m) (suc n) (suc o) m≤n) *-cancelˡ-≤-pos : i j k .{{_ : Positive k}} k * i k * j i j *-cancelˡ-≤-pos i j k rewrite *-comm k i | *-comm k j = *-cancelʳ-≤-pos i j k @@ -1725,10 +1725,10 @@ *-monoʳ-≤-nonNeg +0 {i} {j} i≤j rewrite *-zeroʳ i | *-zeroʳ j = +≤+ z≤n *-monoʳ-≤-nonNeg +[1+ n ] (-≤+ {n = 0}) = -≤+ *-monoʳ-≤-nonNeg +[1+ n ] (-≤+ {n = suc _}) = -≤+ -*-monoʳ-≤-nonNeg +[1+ n ] (-≤- n≤m) = -≤- (s≤s⁻¹ (ℕ.*-mono-≤ (s≤s n≤m) (ℕ.≤-refl {x = suc n}))) +*-monoʳ-≤-nonNeg +[1+ n ] (-≤- n≤m) = -≤- (s≤s⁻¹ (ℕ.*-mono-≤ (s≤s n≤m) (ℕ.≤-refl {x = suc n}))) *-monoʳ-≤-nonNeg +[1+ n ] {+0} {+0} (+≤+ m≤n) = +≤+ m≤n *-monoʳ-≤-nonNeg +[1+ n ] {+0} {+[1+ _ ]} (+≤+ m≤n) = +≤+ z≤n -*-monoʳ-≤-nonNeg +[1+ n ] {+[1+ _ ]} {+[1+ _ ]} (+≤+ m≤n) = +≤+ (ℕ.*-monoˡ-≤ (suc n) m≤n) +*-monoʳ-≤-nonNeg +[1+ n ] {+[1+ _ ]} {+[1+ _ ]} (+≤+ m≤n) = +≤+ (ℕ.*-monoˡ-≤ (suc n) m≤n) *-monoˡ-≤-nonNeg : i .{{_ : NonNegative i}} Monotonic₁ _≤_ _≤_ (i *_) *-monoˡ-≤-nonNeg i {j} {k} rewrite *-comm i j | *-comm i k = *-monoʳ-≤-nonNeg i @@ -1764,18 +1764,18 @@ -- Properties of _*_ and _<_ *-monoˡ-<-pos : i .{{_ : Positive i}} Monotonic₁ _<_ _<_ (i *_) -*-monoˡ-<-pos +[1+ n ] {+ m} {+ o} (+<+ m<o) = +◃-mono-< (ℕ.+-mono-<-≤ m<o (ℕ.*-monoʳ-≤ n (ℕ.<⇒≤ m<o))) +*-monoˡ-<-pos +[1+ n ] {+ m} {+ o} (+<+ m<o) = +◃-mono-< (ℕ.+-mono-<-≤ m<o (ℕ.*-monoʳ-≤ n (ℕ.<⇒≤ m<o))) *-monoˡ-<-pos +[1+ n ] { -[1+ m ]} {+ o} leq = -◃<+◃ _ (suc n ℕ.* o) -*-monoˡ-<-pos +[1+ n ] { -[1+ m ]} { -[1+ o ]} (-<- o<m) = -<- (ℕ.+-mono-<-≤ o<m (ℕ.*-monoʳ-≤ n (ℕ.<⇒≤ (s≤s o<m)))) +*-monoˡ-<-pos +[1+ n ] { -[1+ m ]} { -[1+ o ]} (-<- o<m) = -<- (ℕ.+-mono-<-≤ o<m (ℕ.*-monoʳ-≤ n (ℕ.<⇒≤ (s≤s o<m)))) *-monoʳ-<-pos : i .{{_ : Positive i}} Monotonic₁ _<_ _<_ (_* i) *-monoʳ-<-pos i {j} {k} rewrite *-comm j i | *-comm k i = *-monoˡ-<-pos i *-cancelˡ-<-nonNeg : k .{{_ : NonNegative k}} k * i < k * j i < j -*-cancelˡ-<-nonNeg {+ i} {+ j} (+ n) leq = +<+ (ℕ.*-cancelˡ-< n _ _ (+◃-cancel-< leq)) -*-cancelˡ-<-nonNeg {+ i} { -[1+ j ]} (+ n) leq = contradiction leq +◃≮-◃ +*-cancelˡ-<-nonNeg {+ i} {+ j} (+ n) leq = +<+ (ℕ.*-cancelˡ-< n _ _ (+◃-cancel-< leq)) +*-cancelˡ-<-nonNeg {+ i} { -[1+ j ]} (+ n) leq = contradiction leq +◃≮-◃ *-cancelˡ-<-nonNeg { -[1+ i ]} {+ j} (+ n)leq = -<+ -*-cancelˡ-<-nonNeg { -[1+ i ]} { -[1+ j ]} (+ n) leq = -<- (s<s⁻¹ (ℕ.*-cancelˡ-< n _ _ (neg◃-cancel-< leq))) +*-cancelˡ-<-nonNeg { -[1+ i ]} { -[1+ j ]} (+ n) leq = -<- (s<s⁻¹ (ℕ.*-cancelˡ-< n _ _ (neg◃-cancel-< leq))) *-cancelʳ-<-nonNeg : k .{{_ : NonNegative k}} i * k < j * k i < j *-cancelʳ-<-nonNeg {i} {j} k rewrite *-comm i k | *-comm j k = *-cancelˡ-<-nonNeg k @@ -1825,24 +1825,24 @@ -- Basic specification in terms of _≤_ i≤j⇒i⊓j≡i : i j i j i -i≤j⇒i⊓j≡i (-≤- i≥j) = cong -[1+_] (ℕ.m≥n⇒m⊔n≡m i≥j) +i≤j⇒i⊓j≡i (-≤- i≥j) = cong -[1+_] (ℕ.m≥n⇒m⊔n≡m i≥j) i≤j⇒i⊓j≡i -≤+ = refl -i≤j⇒i⊓j≡i (+≤+ i≤j) = cong +_ (ℕ.m≤n⇒m⊓n≡m i≤j) +i≤j⇒i⊓j≡i (+≤+ i≤j) = cong +_ (ℕ.m≤n⇒m⊓n≡m i≤j) i≥j⇒i⊓j≡j : i j i j j -i≥j⇒i⊓j≡j (-≤- i≥j) = cong -[1+_] (ℕ.m≤n⇒m⊔n≡n i≥j) +i≥j⇒i⊓j≡j (-≤- i≥j) = cong -[1+_] (ℕ.m≤n⇒m⊔n≡n i≥j) i≥j⇒i⊓j≡j -≤+ = refl -i≥j⇒i⊓j≡j (+≤+ i≤j) = cong +_ (ℕ.m≥n⇒m⊓n≡n i≤j) +i≥j⇒i⊓j≡j (+≤+ i≤j) = cong +_ (ℕ.m≥n⇒m⊓n≡n i≤j) i≤j⇒i⊔j≡j : i j i j j -i≤j⇒i⊔j≡j (-≤- i≥j) = cong -[1+_] (ℕ.m≥n⇒m⊓n≡n i≥j) +i≤j⇒i⊔j≡j (-≤- i≥j) = cong -[1+_] (ℕ.m≥n⇒m⊓n≡n i≥j) i≤j⇒i⊔j≡j -≤+ = refl -i≤j⇒i⊔j≡j (+≤+ i≤j) = cong +_ (ℕ.m≤n⇒m⊔n≡n i≤j) +i≤j⇒i⊔j≡j (+≤+ i≤j) = cong +_ (ℕ.m≤n⇒m⊔n≡n i≤j) i≥j⇒i⊔j≡i : i j i j i -i≥j⇒i⊔j≡i (-≤- i≥j) = cong -[1+_] (ℕ.m≤n⇒m⊓n≡m i≥j) +i≥j⇒i⊔j≡i (-≤- i≥j) = cong -[1+_] (ℕ.m≤n⇒m⊓n≡m i≥j) i≥j⇒i⊔j≡i -≤+ = refl -i≥j⇒i⊔j≡i (+≤+ i≤j) = cong +_ (ℕ.m≥n⇒m⊔n≡m i≤j) +i≥j⇒i⊔j≡i (+≤+ i≤j) = cong +_ (ℕ.m≥n⇒m⊔n≡m i≤j) ⊓-operator : MinOperator ≤-totalPreorder ⊓-operator = record @@ -2160,15 +2160,15 @@ +-pos-monoʳ-≤ : n (_+_ (+ n)) Preserves _≤_ _≤_ +-pos-monoʳ-≤ n {_} (-≤- o≤m) = ⊖-monoʳ-≥-≤ n (s≤s o≤m) -+-pos-monoʳ-≤ n { -[1+ m ]} -≤+ = ≤-trans (m⊖n≤m n (suc m)) (+≤+ (ℕ.m≤m+n n _)) -+-pos-monoʳ-≤ n {_} (+≤+ m≤o) = +≤+ (ℕ.+-monoʳ-≤ n m≤o) ++-pos-monoʳ-≤ n { -[1+ m ]} -≤+ = ≤-trans (m⊖n≤m n (suc m)) (+≤+ (ℕ.m≤m+n n _)) ++-pos-monoʳ-≤ n {_} (+≤+ m≤o) = +≤+ (ℕ.+-monoʳ-≤ n m≤o) {-# WARNING_ON_USAGE +-pos-monoʳ-≤ "Warning: +-pos-monoʳ-≤ was deprecated in v2.0 Please use +-monoʳ-≤ instead." #-} +-neg-monoʳ-≤ : n (_+_ (-[1+ n ])) Preserves _≤_ _≤_ -+-neg-monoʳ-≤ n {_} {_} (-≤- n≤m) = -≤- (ℕ.+-monoʳ-≤ (suc n) n≤m) -+-neg-monoʳ-≤ n {_} {+ m} -≤+ = ≤-trans (-≤- (ℕ.m≤m+n (suc n) _)) (-1+m≤n⊖m (suc n) m) ++-neg-monoʳ-≤ n {_} {_} (-≤- n≤m) = -≤- (ℕ.+-monoʳ-≤ (suc n) n≤m) ++-neg-monoʳ-≤ n {_} {+ m} -≤+ = ≤-trans (-≤- (ℕ.m≤m+n (suc n) _)) (-1+m≤n⊖m (suc n) m) +-neg-monoʳ-≤ n {_} {_} (+≤+ m≤n) = ⊖-monoˡ-≤ (suc n) m≤n {-# WARNING_ON_USAGE +-neg-monoʳ-≤ "Warning: +-neg-monoʳ-≤ was deprecated in v2.0 diff --git a/v2.3/Data.List.Countdown.html b/v2.3/Data.List.Countdown.html index fc40f91599..a999a5a53c 100644 --- a/v2.3/Data.List.Countdown.html +++ b/v2.3/Data.List.Countdown.html @@ -14,7 +14,7 @@ module Data.List.Countdown (D : DecSetoid 0ℓ 0ℓ) where open import Data.Fin.Base using (Fin; zero; suc; punchOut) -open import Data.Fin.Properties using (suc-injective; punchOut-injective) +open import Data.Fin.Properties using (suc-injective; punchOut-injective) open import Data.Bool.Base using (true; false) open import Data.List.Base hiding (lookup) open import Data.List.Relation.Unary.Any as Any using (here; there) @@ -29,7 +29,7 @@ open import Relation.Nullary.Reflects using (invert) open import Relation.Nullary.Decidable.Core using (Dec; yes; no; _because_) open import Relation.Nullary.Decidable using (dec-true; dec-false) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) import Relation.Binary.PropositionalEquality.Properties as @@ -76,8 +76,8 @@ helper (there {x = x} x₁∈xs) (there x₂∈xs) with x₁ x | x₂ x ... | true because _ | true because _ = refl ... | false because _ | false because _ = cong suc $ helper x₁∈xs x₂∈xs - ... | yes x₁≈x | no x₂≉x = contradiction (trans (sym x₁≈x₂) x₁≈x) x₂≉x - ... | no x₁≉x | yes x₂≈x = contradiction (trans x₁≈x₂ x₂≈x) x₁≉x + ... | yes x₁≈x | no x₂≉x = contradiction (trans (sym x₁≈x₂) x₁≈x) x₂≉x + ... | no x₁≉x | yes x₂≈x = contradiction (trans x₁≈x₂ x₂≈x) x₁≉x -- first-index is injective in its first argument. @@ -100,7 +100,7 @@ helper (there {x = x} x₁∈xs) (there x₂∈xs) () | yes x₁≈x | no x₂≉x helper (there {x = x} x₁∈xs) (there x₂∈xs) () | no x₁≉x | yes x₂≈x helper (there {x = x} x₁∈xs) (there x₂∈xs) eq | no x₁≉x | no x₂≉x = - helper x₁∈xs x₂∈xs (suc-injective eq) + helper x₁∈xs x₂∈xs (suc-injective eq) ------------------------------------------------------------------------ -- The countdown data structure @@ -166,7 +166,7 @@ counted m x x counted λ n m suc n lookup‼ {suc m} counted⊕n x x∉counted = (m , refl) lookup‼ {zero} counted⊕n x x∉counted = - contradiction (lookup! counted⊕n x) x∉counted + contradiction (lookup! counted⊕n x) x∉counted -- Counts a previously uncounted element. @@ -184,7 +184,7 @@ kind′ : y y x counted Fin n kind′ y with y x | kind x | kind y | helper x y kind′ y | yes y≈x | _ | _ | _ = inj₁ (here y≈x) - kind′ y | _ | inj₁ x∈counted | _ | _ = contradiction x∈counted x∉counted + kind′ y | _ | inj₁ x∈counted | _ | _ = contradiction x∈counted x∉counted kind′ y | _ | _ | inj₁ y∈counted | _ = inj₁ (there y∈counted) kind′ y | no y≉x | inj₂ i | inj₂ j | hlp = inj₂ (punchOut (y≉x sym hlp _ refl refl)) @@ -194,12 +194,12 @@ | helper x y | helper x z | helper y z inj () _ | yes _ | _ | _ | _ | _ | _ | _ | _ inj _ () | _ | yes _ | _ | _ | _ | _ | _ | _ - inj _ _ | no _ | no _ | inj₁ x∈counted | _ | _ | _ | _ | _ = contradiction x∈counted x∉counted + inj _ _ | no _ | no _ | inj₁ x∈counted | _ | _ | _ | _ | _ = contradiction x∈counted x∉counted inj () _ | no _ | no _ | inj₂ _ | inj₁ _ | _ | _ | _ | _ inj _ () | no _ | no _ | inj₂ _ | _ | inj₁ _ | _ | _ | _ inj eq₁ eq₂ | no _ | no _ | inj₂ i | inj₂ _ | inj₂ _ | _ | _ | hlp = hlp _ refl refl $ - punchOut-injective {i = i} _ _ $ + punchOut-injective {i = i} _ _ $ (≡.trans (inj₂-injective eq₁) (≡.sym (inj₂-injective eq₂))) -- Counts an element if it has not already been counted. diff --git a/v2.3/Data.List.Extrema.Nat.html b/v2.3/Data.List.Extrema.Nat.html index 344288f997..42e41164a4 100644 --- a/v2.3/Data.List.Extrema.Nat.html +++ b/v2.3/Data.List.Extrema.Nat.html @@ -13,7 +13,7 @@ module Data.List.Extrema.Nat where open import Data.Nat.Base using (; _≤_; _<_) -open import Data.Nat.Properties as using (≤∧≢⇒<; <⇒≤; <⇒≢) +open import Data.Nat.Properties as using (≤∧≢⇒<; <⇒≤; <⇒≢) open import Data.Sum.Base as Sum using (_⊎_) open import Data.List.Base using (List) import Data.List.Extrema @@ -29,12 +29,12 @@ A : Set a <⇒<× : {x y} x < y x y × x y - <⇒<× x<y = <⇒≤ x<y , <⇒≢ x<y + <⇒<× x<y = <⇒≤ x<y , <⇒≢ x<y <×⇒< : {x y} x y × x y x < y - <×⇒< (x≤y , x≢y) = ≤∧≢⇒< x≤y x≢y + <×⇒< (x≤y , x≢y) = ≤∧≢⇒< x≤y x≢y - module Extrema = Data.List.Extrema ℕ.≤-totalOrder + module Extrema = Data.List.Extrema ℕ.≤-totalOrder ------------------------------------------------------------------------ -- Re-export the contents of Extrema diff --git a/v2.3/Data.List.Fresh.Membership.Setoid.Properties.html b/v2.3/Data.List.Fresh.Membership.Setoid.Properties.html index a6f08dc961..969af82b21 100644 --- a/v2.3/Data.List.Fresh.Membership.Setoid.Properties.html +++ b/v2.3/Data.List.Fresh.Membership.Setoid.Properties.html @@ -21,7 +21,7 @@ using (length-remove) open import Data.Empty using (; ⊥-elim) open import Data.Nat.Base using (; suc; zero; _≤_; _<_; z≤n; s≤s; z<s; s<s) -open import Data.Nat.Properties using (module ≤-Reasoning) +open import Data.Nat.Properties using (module ≤-Reasoning) open import Data.Product.Base using (; _×_; _,_) open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂; fromInj₂) open import Function.Base using (id; _∘′_; _$_) @@ -33,7 +33,7 @@ import Relation.Binary.PropositionalEquality.Core as using (_≡_; cong; sym; subst) open import Relation.Nary using (∀[_]; _⇒_) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open Setoid S renaming (Carrier to A) @@ -111,7 +111,7 @@ where - open ≤-Reasoning + open ≤-Reasoning x∉xs : x xs x∉xs = fresh⇒∉ R⇒≉ pr @@ -131,10 +131,10 @@ where - open ≤-Reasoning + open ≤-Reasoning step : {y} y xs y (ys x∈ys) - step {y} y∈xs = fromInj₂ x≈y contradiction ((≈-subst-∈ (sym x≈y) y∈xs)) x∉xs) + step {y} y∈xs = fromInj₂ x≈y contradiction ((≈-subst-∈ (sym x≈y) y∈xs)) x∉xs) $ remove-inv x∈ys (inj y∈xs) @@ -149,7 +149,7 @@ ∈-irrelevant (there x∈xs₁) (there x∈xs₂) = ≡.cong there (∈-irrelevant x∈xs₁ x∈xs₂) -- absurd cases ∈-irrelevant {xs = cons x xs pr} (here x≈y) (there x∈xs₂) = - contradiction x≈y (distinct x∈xs₂ (fresh⇒∉ R⇒≉ pr)) + contradiction x≈y (distinct x∈xs₂ (fresh⇒∉ R⇒≉ pr)) ∈-irrelevant {xs = cons x xs pr} (there x∈xs₁) (here x≈y) = - contradiction x≈y (distinct x∈xs₁ (fresh⇒∉ R⇒≉ pr)) + contradiction x≈y (distinct x∈xs₁ (fresh⇒∉ R⇒≉ pr)) \ No newline at end of file diff --git a/v2.3/Data.List.Fresh.Relation.Unary.Any.Properties.html b/v2.3/Data.List.Fresh.Relation.Unary.Any.Properties.html index d2c00faa80..5426a72623 100644 --- a/v2.3/Data.List.Fresh.Relation.Unary.Any.Properties.html +++ b/v2.3/Data.List.Fresh.Relation.Unary.Any.Properties.html @@ -24,7 +24,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Nary using (∀[_]; _⇒_; ; Decidable) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong) -open import Relation.Nullary.Negation.Core using (contradiction; ¬_) +open import Relation.Nullary.Negation.Core using (contradiction; ¬_) private variable @@ -56,7 +56,7 @@ module _ {R : Rel A r} {P : Pred A p} {Q : Pred A q} (P? : Decidable P) where ¬All⇒Any : {xs : List# A R} ¬ (All P xs) Any ( P) xs - ¬All⇒Any {xs = []} ¬ps = contradiction [] ¬ps + ¬All⇒Any {xs = []} ¬ps = contradiction [] ¬ps ¬All⇒Any {xs = x ∷# xs} ¬ps with P? x ... | true because [p] = there (¬All⇒Any (¬ps ∘′ (invert [p] ∷_))) ... | false because [¬p] = here (invert [¬p]) @@ -64,7 +64,7 @@ ¬Any⇒All : {xs : List# A R} ¬ (Any P xs) All ( P) xs ¬Any⇒All {xs = []} ¬ps = [] ¬Any⇒All {xs = x ∷# xs} ¬ps with P? x - ... | true because [p] = contradiction (here (invert [p])) ¬ps + ... | true because [p] = contradiction (here (invert [p])) ¬ps ... | false because [¬p] = invert [¬p] ¬Any⇒All (¬ps ∘′ there) ------------------------------------------------------------------------ diff --git a/v2.3/Data.List.Fresh.Relation.Unary.Any.html b/v2.3/Data.List.Fresh.Relation.Unary.Any.html index e73f4be0cb..f72c48e168 100644 --- a/v2.3/Data.List.Fresh.Relation.Unary.Any.html +++ b/v2.3/Data.List.Fresh.Relation.Unary.Any.html @@ -15,7 +15,7 @@ open import Data.Sum.Base using (_⊎_; [_,_]′; inj₁; inj₂) open import Function.Bundles using (_⇔_; mk⇔) open import Level using (Level; _⊔_; Lift) -open import Relation.Nullary.Negation using (¬_; contradiction) +open import Relation.Nullary.Negation using (¬_; contradiction) open import Relation.Nullary.Decidable as Dec using (Dec; no; _⊎-dec_) open import Relation.Unary as U using (Pred; IUniversal; Universal; Decidable; _⇒_; _∪_; _∩_) open import Relation.Binary.Core using (Rel) @@ -35,10 +35,10 @@ head : ¬ Any P xs Any P (cons x xs pr) P x head ¬tail (here p) = p - head ¬tail (there ps) = contradiction ps ¬tail + head ¬tail (there ps) = contradiction ps ¬tail tail : ¬ P x Any P (cons x xs pr) Any P xs - tail ¬head (here p) = contradiction p ¬head + tail ¬head (here p) = contradiction p ¬head tail ¬head (there ps) = ps toSum : Any P (cons x xs pr) P x Any P xs diff --git a/v2.3/Data.List.Membership.Propositional.Properties.html b/v2.3/Data.List.Membership.Propositional.Properties.html index c2777f892b..d5846983c1 100644 --- a/v2.3/Data.List.Membership.Propositional.Properties.html +++ b/v2.3/Data.List.Membership.Propositional.Properties.html @@ -24,7 +24,7 @@ using (map↔; concat↔; >>=↔; ⊛↔; Any-cong; ⊗↔′; ¬Any[]) open import Data.Nat.Base using (; suc; s≤s; _≤_; _<_; _≰_) open import Data.Nat.Properties - using (suc-injective; m≤n⇒m≤1+n; _≤?_; <⇒≢; ≰⇒>) + using (suc-injective; m≤n⇒m≤1+n; _≤?_; <⇒≢; ≰⇒>) open import Data.Product.Base using (; ∃₂; _×_; _,_; ∃-syntax; -,_; map₂) open import Data.Product.Properties using (×-≡,≡↔≡) open import Data.Product.Function.NonDependent.Propositional using (_×-cong_) @@ -46,7 +46,7 @@ import Relation.Binary.Properties.DecTotalOrder as DTOProperties open import Relation.Nullary.Decidable.Core using (Dec; yes; no; ¬¬-excluded-middle) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Reflects using (invert) open import Relation.Unary using (_⟨×⟩_; Decidable) @@ -394,7 +394,7 @@ not-x : {i} f i x f i xs not-x {i} fᵢ≢x with fᵢ∈x∷xs i - ... | here fᵢ≡x = contradiction fᵢ≡x fᵢ≢x + ... | here fᵢ≡x = contradiction fᵢ≡x fᵢ≢x ... | there fᵢ∈xs = fᵢ∈xs helper : ¬ Dec ( λ i f i x) @@ -402,7 +402,7 @@ helper (yes (i , fᵢ≡x)) = finite f′-inj xs f′ⱼ∈xs where f′ : _ - f′ j with i ≤? j + f′ j with i ≤? j ... | yes _ = f (suc j) ... | no _ = f j @@ -410,18 +410,18 @@ ∈-if-not-i i≢j = not-x (i≢j f-inj trans fᵢ≡x sym) lemma : {k j} i j i k suc j k - lemma i≤j i≰1+j refl = i≰1+j (m≤n⇒m≤1+n i≤j) + lemma i≤j i≰1+j refl = i≰1+j (m≤n⇒m≤1+n i≤j) f′ⱼ∈xs : j f′ j xs - f′ⱼ∈xs j with i ≤? j - ... | yes i≤j = ∈-if-not-i (<⇒≢ (s≤s i≤j)) - ... | no i≰j = ∈-if-not-i (<⇒≢ (≰⇒> i≰j) sym) + f′ⱼ∈xs j with i ≤? j + ... | yes i≤j = ∈-if-not-i (<⇒≢ (s≤s i≤j)) + ... | no i≰j = ∈-if-not-i (<⇒≢ (≰⇒> i≰j) sym) f′-injective′ : Injective _≡_ _≡_ f′ - f′-injective′ {j} {k} eq with i ≤? j | i ≤? k + f′-injective′ {j} {k} eq with i ≤? j | i ≤? k ... | yes i≤j | yes i≤k = suc-injective (f-inj eq) - ... | yes i≤j | no i≰k = contradiction (f-inj eq) (lemma i≤j i≰k) - ... | no i≰j | yes i≤k = contradiction (f-inj eq) (lemma i≤k i≰j sym) + ... | yes i≤j | no i≰k = contradiction (f-inj eq) (lemma i≤j i≰k) + ... | no i≰j | yes i≤k = contradiction (f-inj eq) (lemma i≤k i≰j sym) ... | no i≰j | no i≰k = f-inj eq f′-inj : _ diff --git a/v2.3/Data.List.Membership.Setoid.Properties.html b/v2.3/Data.List.Membership.Setoid.Properties.html index 6bb363a984..f5568fac94 100644 --- a/v2.3/Data.List.Membership.Setoid.Properties.html +++ b/v2.3/Data.List.Membership.Setoid.Properties.html @@ -12,7 +12,7 @@ open import Algebra using (Op₂; Selective) open import Data.Bool.Base using (true; false) open import Data.Fin.Base using (Fin; zero; suc) -open import Data.Fin.Properties using (suc-injective) +open import Data.Fin.Properties using (suc-injective) open import Data.List.Base hiding (find) import Data.List.Membership.Setoid as Membership import Data.List.Relation.Binary.Equality.Setoid as Equality @@ -33,7 +33,7 @@ open import Relation.Binary.Bundles using (Setoid) open import Relation.Binary.PropositionalEquality.Core as using (_≡_) open import Relation.Nullary.Decidable using (does; _because_; yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Reflects using (invert) open import Relation.Unary as Unary using (Decidable; Pred) @@ -89,7 +89,7 @@ index-injective : {x₁ x₂ xs} (x₁∈xs : x₁ xs) (x₂∈xs : x₂ xs) Any.index x₁∈xs Any.index x₂∈xs x₁ x₂ index-injective (here x₁≈x) (here x₂≈x) _ = trans x₁≈x (sym x₂≈x) - index-injective (there x₁∈xs) (there x₂∈xs) eq = index-injective x₁∈xs x₂∈xs (suc-injective eq) + index-injective (there x₁∈xs) (there x₂∈xs) eq = index-injective x₁∈xs x₂∈xs (suc-injective eq) ------------------------------------------------------------------------ -- Irrelevance @@ -110,9 +110,9 @@ unique⇒irrelevant ≈-irr (_ u) (there p) (there q) = ≡.cong there (unique⇒irrelevant ≈-irr u p q) unique⇒irrelevant ≈-irr (≉s _) (here p) (there q) = - contradiction p (∉×∈⇒≉ ≉s q) + contradiction p (∉×∈⇒≉ ≉s q) unique⇒irrelevant ≈-irr (≉s _) (there p) (here q) = - contradiction q (∉×∈⇒≉ ≉s p) + contradiction q (∉×∈⇒≉ ≉s p) ------------------------------------------------------------------------ -- mapWith∈ @@ -385,7 +385,7 @@ ∈-filter⁺ : {v xs} v xs P v v filter P? xs ∈-filter⁺ {xs = x _} (here v≈x) Pv with P? x ... | true because _ = here v≈x - ... | false because [¬Px] = contradiction (resp v≈x Pv) (invert [¬Px]) + ... | false because [¬Px] = contradiction (resp v≈x Pv) (invert [¬Px]) ∈-filter⁺ {xs = x _} (there v∈xs) Pv with does (P? x) ... | true = there (∈-filter⁺ v∈xs Pv) ... | false = ∈-filter⁺ v∈xs Pv @@ -502,13 +502,13 @@ ∈-∷=⁺-updated (there pxs) = there (∈-∷=⁺-updated pxs) ∈-∷=⁺-untouched : {xs x y v} (x∈xs : x xs) (¬ x y) y xs y (x∈xs ∷= v) - ∈-∷=⁺-untouched (here x≈z) x≉y (here y≈z) = contradiction (trans x≈z (sym y≈z)) x≉y + ∈-∷=⁺-untouched (here x≈z) x≉y (here y≈z) = contradiction (trans x≈z (sym y≈z)) x≉y ∈-∷=⁺-untouched (here x≈z) x≉y (there y∈xs) = there y∈xs ∈-∷=⁺-untouched (there x∈xs) x≉y (here y≈z) = here y≈z ∈-∷=⁺-untouched (there x∈xs) x≉y (there y∈xs) = there (∈-∷=⁺-untouched x∈xs x≉y y∈xs) ∈-∷=⁻ : {xs x y v} (x∈xs : x xs) (¬ y v) y (x∈xs ∷= v) y xs - ∈-∷=⁻ (here x≈z) y≉v (here y≈v) = contradiction y≈v y≉v + ∈-∷=⁻ (here x≈z) y≉v (here y≈v) = contradiction y≈v y≉v ∈-∷=⁻ (here x≈z) y≉v (there y∈) = there y∈ ∈-∷=⁻ (there x∈xs) y≉v (here y≈z) = here y≈z ∈-∷=⁻ (there x∈xs) y≉v (there y∈) = there (∈-∷=⁻ x∈xs y≉v y∈) diff --git a/v2.3/Data.List.Properties.html b/v2.3/Data.List.Properties.html index ffa772dcb5..4444db39af 100644 --- a/v2.3/Data.List.Properties.html +++ b/v2.3/Data.List.Properties.html @@ -33,7 +33,7 @@ import Data.Product.Relation.Unary.All as Product using (All) open import Data.Sum using (_⊎_; inj₁; inj₂; isInj₁; isInj₂) open import Data.These.Base as These using (These; this; that; these) -open import Data.Fin.Properties using (toℕ-cast) +open import Data.Fin.Properties using (toℕ-cast) open import Function.Base using (id; _∘_; _∘′_; _∋_; _-⟨_∣; ∣_⟩-_; _$_; const; flip) open import Function.Definitions using (Injective) open import Level using (Level) @@ -44,7 +44,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Nullary.Reflects using (invert) open import Relation.Nullary.Decidable.Core using (Dec; yes; no; _because_; does) -open import Relation.Nullary.Negation.Core using (contradiction; ¬_) +open import Relation.Nullary.Negation.Core using (contradiction; ¬_) open import Relation.Nullary.Decidable as Decidable using (isYes; map′; ⌊_⌋; ¬?; _×-dec_; dec-true; dec-false) open import Relation.Unary using (Pred; Decidable; ; _≐_) @@ -172,9 +172,9 @@ ++-cancelʳ : RightCancellative _++_ ++-cancelʳ _ [] [] _ = refl ++-cancelʳ xs [] (z zs) eq = - contradiction (trans (cong length eq) (length-++ (z zs))) (m≢1+n+m (length xs)) + contradiction (trans (cong length eq) (length-++ (z zs))) (m≢1+n+m (length xs)) ++-cancelʳ xs (y ys) [] eq = - contradiction (trans (sym (length-++ (y ys))) (cong length eq)) (m≢1+n+m (length xs) sym) + contradiction (trans (sym (length-++ (y ys))) (cong length eq)) (m≢1+n+m (length xs) sym) ++-cancelʳ _ (y ys) (z zs) eq = cong₂ _∷_ (∷-injectiveˡ eq) (++-cancelʳ _ ys zs (∷-injectiveʳ eq)) @@ -225,7 +225,7 @@ length-++-≤ʳ : (ys : List A) {xs} length ys length (xs ++ ys) -length-++-≤ʳ ys {xs} = ≤-trans (length-++-≤ˡ ys) (≤-reflexive (length-++-comm ys xs)) +length-++-≤ʳ ys {xs} = ≤-trans (length-++-≤ˡ ys) (≤-reflexive (length-++-comm ys xs)) module _ {A : Set a} where @@ -769,9 +769,9 @@ catMaybes-concatMap (nothing xs) = catMaybes-concatMap xs length-catMaybes : xs length (catMaybes {A = A} xs) length xs -length-catMaybes [] = ≤-refl +length-catMaybes [] = ≤-refl length-catMaybes (just _ xs) = s≤s $ length-catMaybes xs -length-catMaybes (nothing xs) = m≤n⇒m≤1+n $ length-catMaybes xs +length-catMaybes (nothing xs) = m≤n⇒m≤1+n $ length-catMaybes xs catMaybes-++ : (xs ys : List (Maybe A)) catMaybes (xs ++ ys) catMaybes xs ++ catMaybes ys @@ -816,9 +816,9 @@ length-mapMaybe : xs length (mapMaybe f xs) length xs length-mapMaybe xs = ≤-begin length (mapMaybe f xs) ≤⟨ length-catMaybes (map f xs) - length (map f xs) ≤⟨ ≤-reflexive (length-map f xs) + length (map f xs) ≤⟨ ≤-reflexive (length-map f xs) length xs ≤-∎ - where open ≤-Reasoning renaming (begin_ to ≤-begin_; _∎ to _≤-∎) + where open ≤-Reasoning renaming (begin_ to ≤-begin_; _∎ to _≤-∎) mapMaybe-++ : xs ys mapMaybe f (xs ++ ys) mapMaybe f xs ++ mapMaybe f ys @@ -1045,7 +1045,7 @@ take-suc-tabulate : {n} (f : Fin n A) (i : Fin n) let m = toℕ i in take (suc m) (tabulate f) take m (tabulate f) ∷ʳ f i -take-suc-tabulate f i rewrite sym (toℕ-cast (sym (length-tabulate f)) i) | sym (lookup-tabulate f i) +take-suc-tabulate f i rewrite sym (toℕ-cast (sym (length-tabulate f)) i) | sym (lookup-tabulate f i) = take-suc (tabulate f) (cast _ i) -- If you take at least as many elements from a list as it has, you get @@ -1106,7 +1106,7 @@ drop-take-suc-tabulate : {n} (f : Fin n A) (i : Fin n) let m = toℕ i in drop m (take (suc m) (tabulate f)) [ f i ] -drop-take-suc-tabulate f i rewrite sym (toℕ-cast (sym (length-tabulate f)) i) | sym (lookup-tabulate f i) +drop-take-suc-tabulate f i rewrite sym (toℕ-cast (sym (length-tabulate f)) i) | sym (lookup-tabulate f i) = drop-take-suc (tabulate f) (cast _ i) -- Dropping m elements and then n elements is same as dropping m+n elements @@ -1199,52 +1199,52 @@ length-filter : xs length (filter P? xs) length xs length-filter [] = z≤n length-filter (x xs) with ihlength-filter xs | does (P? x) - ... | false = m≤n⇒m≤1+n ih + ... | false = m≤n⇒m≤1+n ih ... | true = s≤s ih filter-all : {xs} All P xs filter P? xs xs filter-all {[]} [] = refl filter-all {x xs} (px pxs) with P? x - ... | no ¬px = contradiction px ¬px + ... | no ¬px = contradiction px ¬px ... | true because _ = cong (x ∷_) (filter-all pxs) filter-notAll : xs Any ( P) xs length (filter P? xs) < length xs filter-notAll (x xs) (here ¬px) with P? x ... | false because _ = s≤s (length-filter xs) - ... | yes px = contradiction px ¬px + ... | yes px = contradiction px ¬px filter-notAll (x xs) (there any) with ihfilter-notAll xs any | does (P? x) - ... | false = m≤n⇒m≤1+n ih + ... | false = m≤n⇒m≤1+n ih ... | true = s≤s ih filter-some : {xs} Any P xs 0 < length (filter P? xs) filter-some {x xs} (here px) with P? x ... | true because _ = z<s - ... | no ¬px = contradiction px ¬px + ... | no ¬px = contradiction px ¬px filter-some {x xs} (there pxs) with does (P? x) - ... | true = m≤n⇒m≤1+n (filter-some pxs) + ... | true = m≤n⇒m≤1+n (filter-some pxs) ... | false = filter-some pxs filter-none : {xs} All ( P) xs filter P? xs [] filter-none {[]} [] = refl filter-none {x xs} (¬px ¬pxs) with P? x ... | false because _ = filter-none ¬pxs - ... | yes px = contradiction px ¬px + ... | yes px = contradiction px ¬px filter-complete : {xs} length (filter P? xs) length xs filter P? xs xs filter-complete {[]} eq = refl filter-complete {x xs} eq with does (P? x) - ... | false = contradiction eq (<⇒≢ (s≤s (length-filter xs))) + ... | false = contradiction eq (<⇒≢ (s≤s (length-filter xs))) ... | true = cong (x ∷_) (filter-complete (suc-injective eq)) filter-accept : {x xs} P x filter P? (x xs) x (filter P? xs) filter-accept {x} Px with P? x ... | true because _ = refl - ... | no ¬Px = contradiction Px ¬Px + ... | no ¬Px = contradiction Px ¬Px filter-reject : {x xs} ¬ P x filter P? (x xs) filter P? xs filter-reject {x} ¬Px with P? x - ... | yes Px = contradiction Px ¬Px + ... | yes Px = contradiction Px ¬Px ... | false because _ = refl filter-idem : filter P? filter P? filter P? @@ -1273,10 +1273,10 @@ module _ {R : Rel A p} (R? : B.Decidable R) where length-derun : xs length (derun R? xs) length xs - length-derun [] = ≤-refl - length-derun (x []) = ≤-refl + length-derun [] = ≤-refl + length-derun (x []) = ≤-refl length-derun (x y xs) with ihlength-derun (y xs) | does (R? x y) - ... | true = m≤n⇒m≤1+n ih + ... | true = m≤n⇒m≤1+n ih ... | false = s≤s ih length-deduplicate : xs length (deduplicate R? xs) length xs @@ -1286,17 +1286,17 @@ 1 + length r ≤⟨ s≤s (length-deduplicate xs) 1 + length xs ≤-∎ where - open ≤-Reasoning renaming (begin_ to ≤-begin_; _∎ to _≤-∎) + open ≤-Reasoning renaming (begin_ to ≤-begin_; _∎ to _≤-∎) r = deduplicate R? xs derun-reject : {x y} xs R x y derun R? (x y xs) derun R? (y xs) derun-reject {x} {y} xs Rxy with R? x y ... | yes _ = refl - ... | no ¬Rxy = contradiction Rxy ¬Rxy + ... | no ¬Rxy = contradiction Rxy ¬Rxy derun-accept : {x y} xs ¬ R x y derun R? (x y xs) x derun R? (y xs) derun-accept {x} {y} xs ¬Rxy with R? x y - ... | yes Rxy = contradiction Rxy ¬Rxy + ... | yes Rxy = contradiction Rxy ¬Rxy ... | no _ = refl ------------------------------------------------------------------------ @@ -1314,8 +1314,8 @@ length ys length xs × length zs length xs length-partition [] = z≤n , z≤n length-partition (x xs) with ihlength-partition xs | does (P? x) - ... | true = Product.map s≤s m≤n⇒m≤1+n ih - ... | false = Product.map m≤n⇒m≤1+n s≤s ih + ... | true = Product.map s≤s m≤n⇒m≤1+n ih + ... | false = Product.map m≤n⇒m≤1+n s≤s ih partition-is-foldr : partition P? foldr x if does (P? x) then Product.map₁ (x ∷_) else Product.map₂ (x ∷_)) @@ -1367,7 +1367,7 @@ length-ʳ++ (x xs) {ys} = begin length ((x xs) ʳ++ ys) ≡⟨⟩ length (xs ʳ++ x ys) ≡⟨ length-ʳ++ xs - length xs + length (x ys) ≡⟨ +-suc _ _ + length xs + length (x ys) ≡⟨ +-suc _ _ length (x xs) + length ys -- map distributes over reverse-append. @@ -1454,7 +1454,7 @@ length-reverse xs = begin length (reverse xs) ≡⟨⟩ length (xs ʳ++ []) ≡⟨ length-ʳ++ xs - length xs + 0 ≡⟨ +-identityʳ _ + length xs + 0 ≡⟨ +-identityʳ _ length xs reverse-map : (f : A B) map f reverse reverse map f @@ -1686,7 +1686,7 @@ sum-++ [] ys = refl sum-++ (x xs) ys = begin x + sum (xs ++ ys) ≡⟨ cong (x +_) (sum-++ xs ys) - x + (sum xs + sum ys) ≡⟨ +-assoc x _ _ + x + (sum xs + sum ys) ≡⟨ +-assoc x _ _ (x + sum xs) + sum ys {-# WARNING_ON_USAGE sum-++ "Warning: sum-++ was deprecated in v2.3. @@ -1711,7 +1711,7 @@ product≢0 : {ns} All NonZero ns NonZero (product ns) product≢0 [] = _ -product≢0 {n ns} (n≢0 ns≢0) = m*n≢0 n (product ns) {{n≢0}} {{product≢0 ns≢0}} +product≢0 {n ns} (n≢0 ns≢0) = m*n≢0 n (product ns) {{n≢0}} {{product≢0 ns≢0}} {-# WARNING_ON_USAGE product≢0 "Warning: product≢0 was deprecated in v2.3. Please use Data.Nat.ListAction.Properties.product≢0 instead." @@ -1719,9 +1719,9 @@ ∈⇒≤product : {n ns} All NonZero ns n ns n product ns ∈⇒≤product {ns = n ns} (_ ns≢0) (here refl) = - m≤m*n n (product ns) {{product≢0 ns≢0}} + m≤m*n n (product ns) {{product≢0 ns≢0}} ∈⇒≤product {ns = n _} (n≢0 ns≢0) (there n∈ns) = - m≤n⇒m≤o*n n {{n≢0}} (∈⇒≤product ns≢0 n∈ns) + m≤n⇒m≤o*n n {{n≢0}} (∈⇒≤product ns≢0 n∈ns) {-# WARNING_ON_USAGE ∈⇒≤product "Warning: ∈⇒≤product was deprecated in v2.3. Please use Data.Nat.ListAction.Properties.∈⇒≤product instead." diff --git a/v2.3/Data.List.Relation.Binary.BagAndSetEquality.html b/v2.3/Data.List.Relation.Binary.BagAndSetEquality.html index 77afcdc989..eed8d726f2 100644 --- a/v2.3/Data.List.Relation.Binary.BagAndSetEquality.html +++ b/v2.3/Data.List.Relation.Binary.BagAndSetEquality.html @@ -54,7 +54,7 @@ open import Relation.Binary.PropositionalEquality.Properties as using (module ≡-Reasoning) open import Relation.Binary.Reasoning.Syntax -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) private variable @@ -486,7 +486,7 @@ g″ : {a b} f (inj₂ b) inj₁ a (f (inj₁ a) ≡_) C g″ _ (inj₂ c , _) = c - g″ eq₁ (inj₁ _ , eq₂) = contradiction eq₂ (hyp eq₁) + g″ eq₁ (inj₁ _ , eq₂) = contradiction eq₂ (hyp eq₁) g∘g : {b c} {B : Set b} {C : Set c} (f : (A B) (A C)) @@ -510,7 +510,7 @@ inj₂ b ... | () g∘g′ | inj₁ a , eq₁ with inspect (to f (inj₁ a)) - g∘g′ | inj₁ a , eq₁ | inj₁ a′ , eq₂ = contradiction eq₂ (to-hyp eq₁) + g∘g′ | inj₁ a , eq₁ | inj₁ a′ , eq₂ = contradiction eq₂ (to-hyp eq₁) g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ with inspect (from f (inj₂ c)) g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₂ b′ , eq₃ with inj₁ a ≡⟨ ≡.sym (to-from f eq₂) @@ -518,7 +518,7 @@ inj₂ b′ ... | () g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ with inspect (from f $ inj₁ a′) - g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ | inj₁ a″ , eq₄ = contradiction eq₄ (from-hyp eq₃) + g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ | inj₁ a″ , eq₄ = contradiction eq₄ (from-hyp eq₃) g∘g′ | inj₁ a , eq₁ | inj₂ c , eq₂ | inj₁ a′ , eq₃ | inj₂ b′ , eq₄ = inj₂-injective ( let lemma = inj₁ a′ ≡⟨ ≡.sym eq₃ diff --git a/v2.3/Data.List.Relation.Binary.Infix.Heterogeneous.Properties.html b/v2.3/Data.List.Relation.Binary.Infix.Heterogeneous.Properties.html index c5ed8cfe3f..a6b0c452bf 100644 --- a/v2.3/Data.List.Relation.Binary.Infix.Heterogeneous.Properties.html +++ b/v2.3/Data.List.Relation.Binary.Infix.Heterogeneous.Properties.html @@ -25,12 +25,12 @@ open import Data.Sum.Base using (_⊎_; inj₁; inj₂; [_,_]′) open import Function.Base using (case_of_; _$′_) open import Relation.Nullary.Decidable using (yes; no; does; map′; _⊎-dec_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary as U using (Pred) open import Relation.Binary.Core using (REL; _⇒_) open import Relation.Binary.Definitions using (Decidable; Trans; Antisym) open import Relation.Binary.PropositionalEquality.Core using (_≢_; refl; cong) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) @@ -71,7 +71,7 @@ length-mono : {as bs} Infix R as bs length as length bs length-mono (here pref) = Prefix.length-mono pref -length-mono (there p) = ℕ.m≤n⇒m≤1+n (length-mono p) +length-mono (there p) = ℕ.m≤n⇒m≤1+n (length-mono p) ------------------------------------------------------------------------ -- As an order @@ -101,20 +101,20 @@ antisym : Antisym R S T Antisym (Infix R) (Infix S) (Pointwise T) antisym asym (here p) (here q) = Prefix.antisym asym p q antisym asym {i = a as} {j = bs} p@(here _) (there q) - = contradiction (begin-strict + = contradiction (begin-strict length as <⟨ length-mono p length bs ≤⟨ length-mono q - length as ) (ℕ.<-irrefl refl) where open ℕ.≤-Reasoning + length as ) (ℕ.<-irrefl refl) where open ℕ.≤-Reasoning antisym asym {i = as} {j = b bs} (there p) q@(here _) - = contradiction (begin-strict + = contradiction (begin-strict length bs <⟨ length-mono q length as ≤⟨ length-mono p - length bs ) (ℕ.<-irrefl refl) where open ℕ.≤-Reasoning + length bs ) (ℕ.<-irrefl refl) where open ℕ.≤-Reasoning antisym asym {i = a as} {j = b bs} (there p) (there q) - = contradiction (begin-strict + = contradiction (begin-strict length as <⟨ length-mono p length bs <⟨ length-mono q - length as ) (ℕ.<-irrefl refl) where open ℕ.≤-Reasoning + length as ) (ℕ.<-irrefl refl) where open ℕ.≤-Reasoning ------------------------------------------------------------------------ -- map diff --git a/v2.3/Data.List.Relation.Binary.Lex.html b/v2.3/Data.List.Relation.Binary.Lex.html index 2dbd4edcf1..8ad1e46b0b 100644 --- a/v2.3/Data.List.Relation.Binary.Lex.html +++ b/v2.3/Data.List.Relation.Binary.Lex.html @@ -18,7 +18,7 @@ open import Function.Base using (_∘_; flip; id) open import Function.Bundles using (_⇔_; mk⇔) open import Level using (_⊔_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Decidable as Dec using (Dec; yes; no; _×-dec_; _⊎-dec_) open import Relation.Binary.Core using (Rel) @@ -59,9 +59,9 @@ where as : Antisymmetric _≋_ _<_ as (base _) (base _) = [] - as (this x≺y) (this y≺x) = contradiction y≺x (asym x≺y) - as (this x≺y) (next y≈x ys<xs) = contradiction x≺y (ir (sym y≈x)) - as (next x≈y xs<ys) (this y≺x) = contradiction y≺x (ir (sym x≈y)) + as (this x≺y) (this y≺x) = contradiction y≺x (asym x≺y) + as (this x≺y) (next y≈x ys<xs) = contradiction x≺y (ir (sym y≈x)) + as (next x≈y xs<ys) (this y≺x) = contradiction y≺x (ir (sym x≈y)) as (next x≈y xs<ys) (next y≈x ys<xs) = x≈y as xs<ys ys<xs toSum : {x y xs ys} (x xs) < (y ys) (x y (x y × xs < ys)) diff --git a/v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.Properties.html b/v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.Properties.html deleted file mode 100644 index 86b25b183e..0000000000 --- a/v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.Properties.html +++ /dev/null @@ -1,86 +0,0 @@ - -Data.List.Relation.Binary.Permutation.Algorithmic.Properties
-------------------------------------------------------------------------------
--- The Agda standard library
---
--- Properties of the `Algorithmic` definition of the permutation relation.
--------------------------------------------------------------------------------
-
-{-# OPTIONS --cubical-compatible --safe #-}
-
-open import Relation.Binary.Bundles using (Setoid)
-
-module Data.List.Relation.Binary.Permutation.Algorithmic.Properties
-  {s } (S : Setoid s ) where
-
-open import Data.List.Base using (List; []; _∷_; _++_)
-open import Data.List.Properties using (++-identityʳ)
-import Relation.Binary.PropositionalEquality as 
-  using (sym)
-
-open import Data.List.Relation.Binary.Equality.Setoid S as 
-  using (≋-reflexive)
-open import Data.List.Relation.Binary.Permutation.Algorithmic S
-import Data.List.Relation.Binary.Permutation.Setoid S as ↭ₛ
-  using (_↭_; refl; prep; swap; trans; ↭-refl; ↭-prep; ↭-swap; ↭-trans)
-
-open Setoid S
-  renaming (Carrier to A; refl to ≈-refl; sym to ≈-sym; trans to ≈-trans)
-
-private
-  variable
-    a b c d : A
-    as bs cs ds : List A
-
-
--------------------------------------------------------------------------------
--- Properties
-
-↭-swap : a  c  b  d  cs  ds  a  b  cs  d  c  ds
-↭-swap a≈c b≈d cs≈ds = (b≈d  cs≈ds)  (a≈c  ↭-refl _)
-
-↭-swap-++ : (as bs : List A)  as ++ bs  bs ++ as
-↭-swap-++ [] bs = ↭-reflexive (≋-reflexive (≡.sym (++-identityʳ bs)))
-↭-swap-++ (a  as) bs = lemma bs (↭-swap-++ as bs)
-  where
-  lemma :  bs  cs  bs ++ as  a  cs  bs ++ a  as
-  lemma []        cs↭as
-    = a ≡∷ cs↭as
-  lemma (b  bs) (a≈b  cs↭bs++as)
-    = (a≈b  ↭-refl _)  lemma bs cs↭bs++as
-  lemma (b  bs) (cs↭b∷ds  a∷ds↭bs++as)
-    = (cs↭b∷ds  (↭-refl _))  (lemma bs a∷ds↭bs++as)
-
-↭-congʳ :  cs  as  bs  cs ++ as  cs ++ bs
-↭-congʳ {as = as} {bs = bs} cs as↭bs = lemma cs
-  where
-  lemma :  cs  cs ++ as  cs ++ bs
-  lemma []       = as↭bs
-  lemma (c  cs) = c ≡∷ lemma cs
-
-↭-congˡ : as  bs   cs  as ++ cs  bs ++ cs
-↭-congˡ as↭bs cs = lemma as↭bs
-  where
-  lemma : as  bs  as ++ cs  bs ++ cs
-  lemma []                  = ↭-refl cs
-  lemma (a≈b  as↭bs)       = a≈b  lemma as↭bs
-  lemma (as↭b∷xs  bs↭a∷xs) = lemma as↭b∷xs  lemma bs↭a∷xs
-
-↭-cong : as  bs  cs  ds  as ++ cs  bs ++ ds
-↭-cong as↭bs cs↭ds = ↭-trans (↭-congˡ as↭bs _) (↭-congʳ _ cs↭ds)
-
--------------------------------------------------------------------------------
--- Equivalence with `Setoid` definition of _↭_
-
-↭ₛ⇒↭ : as ↭ₛ.↭ bs  as  bs
-↭ₛ⇒↭ (↭ₛ.refl as≋bs)         = ↭-reflexive as≋bs
-↭ₛ⇒↭ (↭ₛ.prep a≈b as↭bs)     = a≈b  ↭ₛ⇒↭ as↭bs
-↭ₛ⇒↭ (↭ₛ.swap a≈c b≈d cs↭ds) = ↭-swap a≈c b≈d (↭ₛ⇒↭ cs↭ds)
-↭ₛ⇒↭ (↭ₛ.trans as↭bs bs↭cs)  = ↭-trans (↭ₛ⇒↭ as↭bs) (↭ₛ⇒↭ bs↭cs)
-
-↭⇒↭ₛ : as  bs  as ↭ₛ.↭ bs
-↭⇒↭ₛ []                  = ↭ₛ.↭-refl
-↭⇒↭ₛ (a≈b  as↭bs)       = ↭ₛ.prep a≈b (↭⇒↭ₛ as↭bs)
-↭⇒↭ₛ (as↭b∷cs  a∷cs↭bs) = ↭ₛ.↭-trans (↭ₛ.↭-prep _ (↭⇒↭ₛ as↭b∷cs))
-                            (↭ₛ.↭-trans (↭ₛ.↭-swap _ _ ↭ₛ.↭-refl)
-                               (↭ₛ.↭-prep _ (↭⇒↭ₛ a∷cs↭bs)))
-
\ No newline at end of file diff --git a/v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.html b/v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.html deleted file mode 100644 index b134482bba..0000000000 --- a/v2.3/Data.List.Relation.Binary.Permutation.Algorithmic.html +++ /dev/null @@ -1,152 +0,0 @@ - -Data.List.Relation.Binary.Permutation.Algorithmic
-------------------------------------------------------------------------------
--- The Agda standard library
---
--- A alternative definition for the permutation relation using setoid equality
--- Based on Choudhury and Fiore, "Free Commutative Monoids in HoTT" (MFPS, 2022)
--- Constructor `_⋎_` below is rule (3), directly after the proof of Theorem 6.3,
--- and appears as rule `commrel` of their earlier presentation at (HoTT, 2019),
--- "The finite-multiset construction in HoTT".
---
--- `Algorithmic` ⊆ `Data.List.Relation.Binary.Permutation.Declarative`
--- but enjoys a much smaller space of derivations, without being so (over-)
--- deterministic as to being inductively defined as the relation generated
--- by swapping the top two elements (the relational analogue of bubble-sort).
-
--- In particular, transitivity, `↭-trans` below, is an admissible property.
---
--- So this relation is 'better' for proving properties of `_↭_`, while at the
--- same time also being a better fit, via `_⋎_`, for the operational features
--- of e.g. sorting algorithms which transpose at arbitary positions.
--------------------------------------------------------------------------------
-
-{-# OPTIONS --cubical-compatible --safe #-}
-
-open import Relation.Binary.Bundles using (Setoid)
-
-module Data.List.Relation.Binary.Permutation.Algorithmic
-  {s } (S : Setoid s ) where
-
-open import Data.List.Base using (List; []; _∷_; length)
-open import Data.List.Properties using (++-identityʳ)
-open import Data.Nat.Base using (; suc)
-open import Data.Nat.Properties using (suc-injective)
-open import Level using (_⊔_)
-open import Relation.Binary.PropositionalEquality as  using (_≡_)
-
-open import Data.List.Relation.Binary.Equality.Setoid S as 
-  using (_≋_; []; _∷_; ≋-refl)
-
-open Setoid S
-  renaming (Carrier to A; refl to ≈-refl; sym to ≈-sym; trans to ≈-trans)
-
-private
-  variable
-    a b c d : A
-    as bs cs ds : List A
-    n : 
-
-
--------------------------------------------------------------------------------
--- Definition
-
-infix  4  _↭_
-infix  5 _⋎_ _⋎[_]_
-
-data _↭_ : List A  List A  Set (s  ) where
-  []   : []  []
-  _∷_  : a  b  as  bs  a  as  b  bs
-  _⋎_  : as  b  cs  a  cs  bs  a  as  b  bs
-
--- smart constructor for prefix congruence
-
-_≡∷_  :  c  as  bs  c  as  c  bs
-_≡∷_ c = ≈-refl ∷_
-
--- pattern synonym to allow naming the 'middle' term
-pattern _⋎[_]_ {as} {b} {a} {bs} as↭b∷cs cs a∷cs↭bs
-  = _⋎_ {as} {b} {cs = cs} {a} {bs} as↭b∷cs a∷cs↭bs
-
--------------------------------------------------------------------------------
--- Properties
-
-↭-reflexive : as  bs  as  bs
-↭-reflexive []            = []
-↭-reflexive (a≈b  as↭bs) = a≈b  ↭-reflexive as↭bs
-
-↭-refl :  as  as  as
-↭-refl _ = ↭-reflexive ≋-refl
-
-↭-sym : as  bs  bs  as
-↭-sym []                  = []
-↭-sym (a≈b      as↭bs)   = ≈-sym a≈b  ↭-sym as↭bs
-↭-sym (as↭b∷cs  a∷cs↭bs) = ↭-sym a∷cs↭bs  ↭-sym as↭b∷cs
-
-≋∘↭⇒↭ : as  bs  bs  cs  as  cs
-≋∘↭⇒↭ []            []                  = []
-≋∘↭⇒↭ (a≈b  as≋bs) (b≈c  bs↭cs)       = ≈-trans a≈b b≈c  ≋∘↭⇒↭ as≋bs bs↭cs
-≋∘↭⇒↭ (a≈b  as≋bs) (bs↭c∷ds  b∷ds↭cs) =
-  ≋∘↭⇒↭ as≋bs bs↭c∷ds  ≋∘↭⇒↭ (a≈b  ≋-refl) b∷ds↭cs
-
-↭∘≋⇒↭ : as  bs  bs  cs  as  cs
-↭∘≋⇒↭ []                  []            = []
-↭∘≋⇒↭ (a≈b  as↭bs)       (b≈c  bs≋cs) = ≈-trans a≈b b≈c  ↭∘≋⇒↭ as↭bs bs≋cs
-↭∘≋⇒↭ (as↭b∷cs  a∷cs↭bs) (b≈d  bs≋ds) =
-  ↭∘≋⇒↭ as↭b∷cs (b≈d  ≋-refl)  ↭∘≋⇒↭ a∷cs↭bs bs≋ds
-
-↭-length : as  bs  length as  length bs
-↭-length []                  = ≡.refl
-↭-length (a≈b  as↭bs)       = ≡.cong suc (↭-length as↭bs)
-↭-length (as↭b∷cs  a∷cs↭bs) = ≡.cong suc (≡.trans (↭-length as↭b∷cs) (↭-length a∷cs↭bs))
-
-↭-trans  : as  bs  bs  cs  as  cs
-↭-trans = lemma ≡.refl
-  where
-  lemma : n  length bs  as  bs  bs  cs  as  cs
-
--- easy base case for bs = [], eq: 0 ≡ 0
-  lemma _ [] [] = []
-
--- fiddly step case for bs = b ∷ bs, where eq : suc n ≡ suc (length bs)
--- hence suc-injective eq : n ≡ length bs
-
-  lemma {n = suc n} eq (a≈b  as↭bs) (b≈c  bs↭cs)
-    = ≈-trans a≈b b≈c  lemma (suc-injective eq) as↭bs bs↭cs
-
-  lemma {n = suc n} eq (a≈b  as↭bs) (bs↭c∷ys  b∷ys↭cs)
-    = ≋∘↭⇒↭ (a≈b  ≋-refl) (lemma (suc-injective eq) as↭bs bs↭c∷ys  b∷ys↭cs)
-
-  lemma {n = suc n} eq (as↭b∷xs  a∷xs↭bs) (a≈b  bs↭cs)
-    = ↭∘≋⇒↭ (as↭b∷xs  lemma (suc-injective eq) a∷xs↭bs bs↭cs) (a≈b  ≋-refl)
-
-  lemma {n = suc n} {bs = b  bs} {as = a  as} {cs = c  cs} eq
-    (as↭b∷xs ⋎[ xs ] a∷xs↭bs) (bs↭c∷ys ⋎[ ys ] b∷ys↭cs) = a∷as↭c∷cs
-    where
-    n≡∣bs∣ : n  length bs
-    n≡∣bs∣ = suc-injective eq
-
-    n≡∣b∷xs∣ : n  length (b  xs)
-    n≡∣b∷xs∣ = ≡.trans n≡∣bs∣ (≡.sym (↭-length a∷xs↭bs))
-
-    n≡∣b∷ys∣ : n  length (b  ys)
-    n≡∣b∷ys∣ = ≡.trans n≡∣bs∣ (↭-length bs↭c∷ys)
-
-    a∷as↭c∷cs : a  as  c  cs
-    a∷as↭c∷cs with lemma n≡∣bs∣ a∷xs↭bs bs↭c∷ys
-    ... | a≈c  xs↭ys = a≈c  as↭cs
-      where
-      as↭cs : as  cs
-      as↭cs = lemma n≡∣b∷xs∣ as↭b∷xs
-               (lemma n≡∣b∷ys∣ (b ≡∷ xs↭ys) b∷ys↭cs)
-    ... | xs↭c∷zs ⋎[ zs ] a∷zs↭ys
-      = lemma n≡∣b∷xs∣ as↭b∷xs b∷xs↭c∷b∷zs
-        ⋎[ b  zs ]
-        lemma n≡∣b∷ys∣ a∷b∷zs↭b∷ys b∷ys↭cs
-      where
-      b∷zs↭b∷zs : b  zs  b  zs
-      b∷zs↭b∷zs = ↭-refl (b  zs)
-      b∷xs↭c∷b∷zs : b  xs  c  (b  zs)
-      b∷xs↭c∷b∷zs = xs↭c∷zs ⋎[ zs ] b∷zs↭b∷zs
-      a∷b∷zs↭b∷ys : a  (b  zs)  b  ys
-      a∷b∷zs↭b∷ys = b∷zs↭b∷zs ⋎[ zs ] a∷zs↭ys
-
\ No newline at end of file diff --git a/v2.3/Data.List.Relation.Binary.Permutation.Declarative.Properties.html b/v2.3/Data.List.Relation.Binary.Permutation.Declarative.Properties.html deleted file mode 100644 index 68baa6fff7..0000000000 --- a/v2.3/Data.List.Relation.Binary.Permutation.Declarative.Properties.html +++ /dev/null @@ -1,67 +0,0 @@ - -Data.List.Relation.Binary.Permutation.Declarative.Properties
-------------------------------------------------------------------------------
--- The Agda standard library
---
--- Properties of declarative definition of permutation
--------------------------------------------------------------------------------
-
-{-# OPTIONS --cubical-compatible --safe #-}
-
-open import Relation.Binary.Bundles using (Setoid)
-
-module Data.List.Relation.Binary.Permutation.Declarative.Properties
-  {s } (S : Setoid s ) where
-
-open import Data.List.Base using (List; []; _∷_; length; _++_)
-open import Data.List.Properties using (length-++)
-open import Data.Nat.Base using (suc; _+_)
-open import Data.Nat.Properties using (+-comm)
-open import Relation.Binary.PropositionalEquality as  using (_≡_)
-open import Relation.Binary.PropositionalEquality.Properties as 
-  using (module ≡-Reasoning)
-
-open import Data.List.Relation.Binary.Permutation.Algorithmic S
-  using ([]; _∷_; _⋎_)
-  renaming (_↭_ to _↭ₐ_; ↭-trans to ↭ₐ-trans)
-open import Data.List.Relation.Binary.Permutation.Algorithmic.Properties S
-  using ()
-  renaming (↭-swap-++ to ↭ₐ-swap-++)
-open import Data.List.Relation.Binary.Permutation.Declarative S
-
-open Setoid S
-  using ()
-  renaming (Carrier to A)
-
-private
-  variable
-    as bs : List A
-
-
--------------------------------------------------------------------------------
--- Properties
-
-↭-length : as  bs  length as  length bs
-↭-length []                  = ≡.refl
-↭-length (a≈b  as↭bs)       = ≡.cong suc (↭-length as↭bs)
-↭-length (trans as↭cs cs↭bs) = ≡.trans (↭-length as↭cs) (↭-length cs↭bs)
-↭-length (as ++ᵒ bs)         = begin
-  length (as ++ bs)     ≡⟨ length-++ as 
-  length as + length bs ≡⟨ +-comm (length as) (length bs) 
-  length bs + length as ≡⟨ length-++ bs 
-  length (bs ++ as)     
-  where open ≡-Reasoning
-
--------------------------------------------------------------------------------
--- Equivalence with `Algorithmic` definition of _↭_
-
-↭ₐ⇒↭ : as ↭ₐ bs  as  bs
-↭ₐ⇒↭ []                  = []
-↭ₐ⇒↭ (a≈b  as↭bs)       = a≈b  ↭ₐ⇒↭ as↭bs
-↭ₐ⇒↭ (as↭b∷cs  a∷cs↭bs) = ↭ₐ⇒↭ as↭b∷cs ↭-⋎ ↭ₐ⇒↭ a∷cs↭bs
-
-↭⇒↭ₐ : as  bs  as ↭ₐ bs
-↭⇒↭ₐ []                  = []
-↭⇒↭ₐ (a≈b  as↭bs)       = a≈b  ↭⇒↭ₐ as↭bs
-↭⇒↭ₐ (trans as↭cs cs↭bs) = ↭ₐ-trans (↭⇒↭ₐ as↭cs) (↭⇒↭ₐ cs↭bs)
-↭⇒↭ₐ (as ++ᵒ bs)         = ↭ₐ-swap-++ as bs
-
\ No newline at end of file diff --git a/v2.3/Data.List.Relation.Binary.Permutation.Declarative.html b/v2.3/Data.List.Relation.Binary.Permutation.Declarative.html deleted file mode 100644 index 17c481aea1..0000000000 --- a/v2.3/Data.List.Relation.Binary.Permutation.Declarative.html +++ /dev/null @@ -1,117 +0,0 @@ - -Data.List.Relation.Binary.Permutation.Declarative
-------------------------------------------------------------------------------
--- The Agda standard library
---
--- A declarative definition of the permutation relation, inductively defined
--- as the least congruence on `List` which makes `_++_` commutative. Thus, for
--- `(A, _≈_)` a setoid, `List A` with equality given by `_↭_` is a constructive
--- presentation of the free commutative monoid on `A`.
---
--- NB. we do not need to specify symmetry as a constructor; the rules defining
--- `_↭_` are themselves symmetric, by inspection, whence `↭-sym` below.
---
--- `_↭_` is somehow the 'maximally non-deterministic' (permissive) presentation
--- of the permutation relation on lists, so is 'easiest' to establish for any
--- given pair of lists, while nevertheless provably equivalent to more
--- operationally defined versions, in particular
--- `Declarative` ⊆ `Data.List.Relation.Binary.Permutation.Algorithmic`
--------------------------------------------------------------------------------
-
-{-# OPTIONS --cubical-compatible --safe #-}
-
-open import Relation.Binary.Bundles using (Setoid)
-
-module Data.List.Relation.Binary.Permutation.Declarative
-  {s } (S : Setoid s ) where
-
-open import Data.List.Base using (List; []; _∷_; [_]; _++_)
-open import Data.List.Properties using (++-identityʳ)
-open import Function.Base using (id; _∘_)
-open import Level using (_⊔_)
-import Relation.Binary.PropositionalEquality as  using (sym)
-
-open import Data.List.Relation.Binary.Equality.Setoid S as 
-  using (_≋_; []; _∷_; ≋-refl; ≋-reflexive)
-
-open Setoid S
-  renaming (Carrier to A; refl to ≈-refl; sym to ≈-sym; trans to ≈-trans)
-
-private
-  variable
-    a b c d : A
-    as bs cs ds : List A
-
-
--------------------------------------------------------------------------------
--- Definition
-
-infix  4  _↭_
-
-data _↭_ : List A  List A  Set (s  ) where
-  []     : []  []
-  _∷_    : a  b  as  bs  a  as  b  bs
-  trans  : as  bs  bs  cs  as  cs
-  _++ᵒ_  :  as bs  as ++ bs  bs ++ as
-
--- smart constructor for prefix congruence
-
-_≡∷_  :  c  as  bs  c  as  c  bs
-_≡∷_ c = ≈-refl ∷_
-
--------------------------------------------------------------------------------
--- Basic properties and smart constructors
-
-↭-reflexive : as  bs  as  bs
-↭-reflexive []            = []
-↭-reflexive (a≈b  as↭bs) = a≈b  ↭-reflexive as↭bs
-
-↭-refl :  as  as  as
-↭-refl _ = ↭-reflexive ≋-refl
-
-↭-sym : as  bs  bs  as
-↭-sym []                  = []
-↭-sym (a≈b  as↭bs)       = ≈-sym a≈b  ↭-sym as↭bs
-↭-sym (trans as↭cs cs↭bs) = trans (↭-sym cs↭bs) (↭-sym as↭cs)
-↭-sym (as ++ᵒ bs)         = bs ++ᵒ as
-
--- smart constructor for trans
-
-↭-trans  : as  bs  bs  cs  as  cs
-↭-trans []                  = id
-↭-trans (trans as↭bs bs↭cs) = ↭-trans as↭bs  ↭-trans bs↭cs
-↭-trans as↭bs               = trans as↭bs
-
--- smart constructor for swap
-
-↭-swap-++ : (as bs : List A)  as ++ bs  bs ++ as
-↭-swap-++ []         bs         = ↭-reflexive (≋-reflexive (≡.sym (++-identityʳ bs)))
-↭-swap-++ as@(_  _) []         = ↭-reflexive (≋-reflexive (++-identityʳ as))
-↭-swap-++ as@(_  _) bs@(_  _) = as ++ᵒ bs
-
-↭-congʳ : as  bs  cs ++ as  cs ++ bs
-↭-congʳ {as = as} {bs = bs} {cs = cs} as↭bs = lemma cs
-  where
-  lemma :  cs  cs ++ as  cs ++ bs
-  lemma []       = as↭bs
-  lemma (c  cs) = c ≡∷ lemma cs
-
-↭-congˡ : as  bs  as ++ cs  bs ++ cs
-↭-congˡ {as = as} {bs = bs} {cs = cs} as↭bs =
-  ↭-trans (↭-swap-++ as cs) (↭-trans (↭-congʳ as↭bs) (↭-swap-++ cs bs))
-
-↭-cong : as  bs  cs  ds  as ++ cs  bs ++ ds
-↭-cong as↭bs cs↭ds = ↭-trans (↭-congˡ as↭bs) (↭-congʳ cs↭ds)
-
--- smart constructor for generalised swap
-
-infix  5 _↭-⋎_
-
-_↭-⋎_ : as  b  cs  a  cs  bs  a  as  b  bs
-_↭-⋎_ {b = b} {a = a} as↭b∷cs a∷cs↭bs =
-  trans (a ≡∷ as↭b∷cs) (↭-trans (↭-congˡ ([ a ] ++ᵒ [ b ])) (b ≡∷ a∷cs↭bs))
-
-⋎-syntax :  cs  as  b  cs  a  cs  bs  a  as  b  bs
-⋎-syntax cs = _↭-⋎_ {cs = cs}
-
-syntax ⋎-syntax cs as↭b∷cs a∷cs↭bs = as↭b∷cs ↭-⋎[ cs ] a∷cs↭bs
-
\ No newline at end of file diff --git a/v2.3/Data.List.Relation.Binary.Permutation.Homogeneous.html b/v2.3/Data.List.Relation.Binary.Permutation.Homogeneous.html index 0ba0912ef8..5dc073106c 100644 --- a/v2.3/Data.List.Relation.Binary.Permutation.Homogeneous.html +++ b/v2.3/Data.List.Relation.Binary.Permutation.Homogeneous.html @@ -69,9 +69,9 @@ steps (swap _ _ xs↭ys) = suc (steps xs↭ys) steps (trans xs↭ys ys↭zs) = steps xs↭ys + steps ys↭zs -onIndices : {xs ys} Permutation R xs ys Fin.Permutation (length xs) (length ys) -onIndices (refl ) = Fin.cast-id (Pointwise.Pointwise-length ) -onIndices (prep e xs↭ys) = Fin.lift₀ (onIndices xs↭ys) -onIndices (swap e f xs↭ys) = Fin.swap (onIndices xs↭ys) -onIndices (trans ↭₁ ↭₂) = onIndices ↭₁ Fin.∘ₚ onIndices ↭₂ +onIndices : {xs ys} Permutation R xs ys Fin.Permutation (length xs) (length ys) +onIndices (refl ) = Fin.cast-id (Pointwise.Pointwise-length ) +onIndices (prep e xs↭ys) = Fin.lift₀ (onIndices xs↭ys) +onIndices (swap e f xs↭ys) = Fin.swap (onIndices xs↭ys) +onIndices (trans ↭₁ ↭₂) = onIndices ↭₁ Fin.∘ₚ onIndices ↭₂ \ No newline at end of file diff --git a/v2.3/Data.List.Relation.Binary.Permutation.Setoid.Properties.html b/v2.3/Data.List.Relation.Binary.Permutation.Setoid.Properties.html index 0773e4227d..a042740269 100644 --- a/v2.3/Data.List.Relation.Binary.Permutation.Setoid.Properties.html +++ b/v2.3/Data.List.Relation.Binary.Permutation.Setoid.Properties.html @@ -44,7 +44,7 @@ open import Relation.Binary.PropositionalEquality.Core as using (_≡_ ; refl; sym; cong; cong₂; subst; _≢_) open import Relation.Nullary.Decidable using (yes; no; does) -open import Relation.Nullary.Negation using (¬_; contradiction; contraposition) +open import Relation.Nullary.Negation using (¬_; contradiction; contraposition) open Setoid S using (_≈_) @@ -113,7 +113,7 @@ xs↭ys⇒|xs|≡|ys| (trans xs↭ys xs↭ys₁) = ≡.trans (xs↭ys⇒|xs|≡|ys| xs↭ys) (xs↭ys⇒|xs|≡|ys| xs↭ys₁) ¬x∷xs↭[] : {x xs} ¬ (x xs []) -¬x∷xs↭[] = contraposition xs↭ys⇒|xs|≡|ys| λ() +¬x∷xs↭[] = contraposition xs↭ys⇒|xs|≡|ys| λ() ------------------------------------------------------------------------ -- Core properties depending on the representation of _↭_ @@ -192,29 +192,29 @@ filter⁺ (trans xs↭zs zs↭ys) = trans (filter⁺ xs↭zs) (filter⁺ zs↭ys) filter⁺ {x xs} {y ys} (prep x≈y xs↭ys) with P? x | P? y ... | yes _ | yes _ = prep x≈y (filter⁺ xs↭ys) - ... | yes Px | no ¬Py = contradiction (P≈ x≈y Px) ¬Py - ... | no ¬Px | yes Py = contradiction (P≈ (≈-sym x≈y) Py) ¬Px + ... | yes Px | no ¬Py = contradiction (P≈ x≈y Px) ¬Py + ... | no ¬Px | yes Py = contradiction (P≈ (≈-sym x≈y) Py) ¬Px ... | no _ | no _ = filter⁺ xs↭ys filter⁺ {x w xs} {y z ys} (swap x≈z w≈y xs↭ys) with P? x | P? y filter⁺ {x w xs} {y z ys} (swap x≈z w≈y xs↭ys) | no ¬Px | no ¬Py with P? z | P? w - ... | _ | yes Pw = contradiction (P≈ w≈y Pw) ¬Py - ... | yes Pz | _ = contradiction (P≈ (≈-sym x≈z) Pz) ¬Px + ... | _ | yes Pw = contradiction (P≈ w≈y Pw) ¬Py + ... | yes Pz | _ = contradiction (P≈ (≈-sym x≈z) Pz) ¬Px ... | no _ | no _ = filter⁺ xs↭ys filter⁺ {x w xs} {y z ys} (swap x≈z w≈y xs↭ys) | no ¬Px | yes Py with P? z | P? w - ... | _ | no ¬Pw = contradiction (P≈ (≈-sym w≈y) Py) ¬Pw - ... | yes Pz | _ = contradiction (P≈ (≈-sym x≈z) Pz) ¬Px + ... | _ | no ¬Pw = contradiction (P≈ (≈-sym w≈y) Py) ¬Pw + ... | yes Pz | _ = contradiction (P≈ (≈-sym x≈z) Pz) ¬Px ... | no _ | yes _ = prep w≈y (filter⁺ xs↭ys) filter⁺ {x w xs} {y z ys} (swap x≈z w≈y xs↭ys) | yes Px | no ¬Py with P? z | P? w - ... | no ¬Pz | _ = contradiction (P≈ x≈z Px) ¬Pz - ... | _ | yes Pw = contradiction (P≈ w≈y Pw) ¬Py + ... | no ¬Pz | _ = contradiction (P≈ x≈z Px) ¬Pz + ... | _ | yes Pw = contradiction (P≈ w≈y Pw) ¬Py ... | yes _ | no _ = prep x≈z (filter⁺ xs↭ys) filter⁺ {x w xs} {y z ys} (swap x≈z w≈y xs↭ys) | yes Px | yes Py with P? z | P? w - ... | no ¬Pz | _ = contradiction (P≈ x≈z Px) ¬Pz - ... | _ | no ¬Pw = contradiction (P≈ (≈-sym w≈y) Py) ¬Pw + ... | no ¬Pz | _ = contradiction (P≈ x≈z Px) ¬Pz + ... | _ | no ¬Pw = contradiction (P≈ (≈-sym w≈y) Py) ¬Pw ... | yes _ | yes _ = swap x≈z w≈y (filter⁺ xs↭ys) ------------------------------------------------------------------------ @@ -479,10 +479,10 @@ 0<steps : (xs↭ys : xs ys) 0 < steps xs↭ys 0<steps (refl _) = z<s -0<steps (prep eq xs↭ys) = m<n⇒m<1+n (0<steps xs↭ys) -0<steps (swap eq₁ eq₂ xs↭ys) = m<n⇒m<1+n (0<steps xs↭ys) +0<steps (prep eq xs↭ys) = m<n⇒m<1+n (0<steps xs↭ys) +0<steps (swap eq₁ eq₂ xs↭ys) = m<n⇒m<1+n (0<steps xs↭ys) 0<steps (trans xs↭ys xs↭ys₁) = - <-≤-trans (0<steps xs↭ys) (m≤m+n (steps xs↭ys) (steps xs↭ys₁)) + <-≤-trans (0<steps xs↭ys) (m≤m+n (steps xs↭ys) (steps xs↭ys₁)) steps-respˡ : (ys≋xs : ys xs) (ys↭zs : ys zs) steps (↭-respˡ-≋ ys≋xs ys↭zs) steps ys↭zs diff --git a/v2.3/Data.List.Relation.Binary.Pointwise.html b/v2.3/Data.List.Relation.Binary.Pointwise.html index 87deb10d51..8e5eb86c02 100644 --- a/v2.3/Data.List.Relation.Binary.Pointwise.html +++ b/v2.3/Data.List.Relation.Binary.Pointwise.html @@ -35,7 +35,7 @@ import Relation.Binary.PropositionalEquality.Properties as open import Relation.Nullary.Decidable as Dec using (map′; yes; no; Dec; _because_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary as U using (Pred) private @@ -161,9 +161,9 @@ ++-cancelʳ (y ys) (z zs) (y∼z ys∼zs) = y∼z (++-cancelʳ ys zs ys∼zs) -- Impossible cases ++-cancelʳ {xs = xs} [] (z zs) eq = - contradiction (≡.trans (Pointwise-length eq) (length-++ (z zs))) (m≢1+n+m (length xs)) + contradiction (≡.trans (Pointwise-length eq) (length-++ (z zs))) (m≢1+n+m (length xs)) ++-cancelʳ {xs = xs} (y ys) [] eq = - contradiction (≡.trans (≡.sym (length-++ (y ys))) (Pointwise-length eq)) (m≢1+n+m (length xs) ≡.sym) + contradiction (≡.trans (≡.sym (length-++ (y ys))) (Pointwise-length eq)) (m≢1+n+m (length xs) ≡.sym) module _ (rfl : Reflexive R) where @@ -237,8 +237,8 @@ filter⁺ {x _} {y _} (r rs) with P? x | Q? y ... | true because _ | true because _ = r filter⁺ rs ... | false because _ | false because _ = filter⁺ rs - ... | yes p | no ¬q = contradiction (P⇒Q r p) ¬q - ... | no ¬p | yes q = contradiction (Q⇒P r q) ¬p + ... | yes p | no ¬q = contradiction (P⇒Q r p) ¬q + ... | no ¬p | yes q = contradiction (Q⇒P r q) ¬p ------------------------------------------------------------------------ -- replicate diff --git a/v2.3/Data.List.Relation.Binary.Prefix.Heterogeneous.Properties.html b/v2.3/Data.List.Relation.Binary.Prefix.Heterogeneous.Properties.html index 5bf8caa731..21b46e8e5f 100644 --- a/v2.3/Data.List.Relation.Binary.Prefix.Heterogeneous.Properties.html +++ b/v2.3/Data.List.Relation.Binary.Prefix.Heterogeneous.Properties.html @@ -30,7 +30,7 @@ using (_≡_; _≢_; refl; cong₂) open import Relation.Nullary.Decidable.Core as Dec using (_×-dec_; yes; no; _because_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary as U using (Pred) private @@ -116,8 +116,8 @@ filter⁺ [] = [] filter⁺ {a as} {b bs} (r rs) with P? a | Q? b ... | true because _ | true because _ = r filter⁺ rs - ... | yes pa | no ¬qb = contradiction (P⇒Q r pa) ¬qb - ... | no ¬pa | yes qb = contradiction (Q⇒P r qb) ¬pa + ... | yes pa | no ¬qb = contradiction (P⇒Q r pa) ¬qb + ... | no ¬pa | yes qb = contradiction (Q⇒P r qb) ¬pa ... | false because _ | false because _ = filter⁺ rs ------------------------------------------------------------------------ @@ -161,7 +161,7 @@ replicate⁻ : {m n a b} m 0 Prefix R (replicate m a) (replicate n b) R a b -replicate⁻ {m = zero} {n} m≢0 r = contradiction refl m≢0 +replicate⁻ {m = zero} {n} m≢0 r = contradiction refl m≢0 replicate⁻ {m = suc m} {suc n} m≢0 rs = Prefix.head rs ------------------------------------------------------------------------ diff --git a/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Properties.html b/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Properties.html index c4f8c45d54..b31cb553e6 100644 --- a/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Properties.html +++ b/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Properties.html @@ -30,7 +30,7 @@ open import Function.Bundles using (_⤖_; _⇔_ ; mk⤖; mk⇔) open import Function.Consequences.Propositional using (strictlySurjective⇒surjective) open import Relation.Nullary.Decidable as Dec using (Dec; does; _because_; yes; no; ¬?) -open import Relation.Nullary.Negation using (¬_; contradiction) +open import Relation.Nullary.Negation using (¬_; contradiction) open import Relation.Nullary.Reflects using (invert) open import Relation.Unary as U using (Pred) open import Relation.Binary.Core using (Rel; REL; _⇒_) @@ -79,7 +79,7 @@ length-mono-≤ : Sublist R as bs length as length bs length-mono-≤ [] = z≤n - length-mono-≤ (y ∷ʳ rs) = ℕ.m≤n⇒m≤1+n (length-mono-≤ rs) + length-mono-≤ (y ∷ʳ rs) = ℕ.m≤n⇒m≤1+n (length-mono-≤ rs) length-mono-≤ (r rs) = s≤s (length-mono-≤ rs) ------------------------------------------------------------------------ @@ -94,7 +94,7 @@ toPointwise {bs = []} eq [] = [] toPointwise {bs = b bs} eq (r rs) = r toPointwise (ℕ.suc-injective eq) rs toPointwise {bs = b bs} eq (b ∷ʳ rs) = - contradiction (s≤s (length-mono-≤ rs)) (ℕ.<-irrefl eq) + contradiction (s≤s (length-mono-≤ rs)) (ℕ.<-irrefl eq) ------------------------------------------------------------------------ -- Various functions' outputs are sublists @@ -165,7 +165,7 @@ ∷ʳ⁻ : ¬ R x y Sublist R (x xs) (y ys) Sublist R (x xs) ys ∷ʳ⁻ ¬r (y ∷ʳ rs) = rs - ∷ʳ⁻ ¬r (r rs) = contradiction r ¬r + ∷ʳ⁻ ¬r (r rs) = contradiction r ¬r ∷⁻ : Sublist R (x xs) (y ys) Sublist R xs ys ∷⁻ (y ∷ʳ rs) = ∷ˡ⁻ rs @@ -238,7 +238,7 @@ Sublist R (drop m as) (drop n bs) drop⁺ (z≤n {m}) rs = drop-Sublist m rs drop⁺ (s≤s m≥n) [] = [] - drop⁺ (s≤s m≥n) (y ∷ʳ rs) = drop⁺ (ℕ.m≤n⇒m≤1+n m≥n) rs + drop⁺ (s≤s m≥n) (y ∷ʳ rs) = drop⁺ (ℕ.m≤n⇒m≤1+n m≥n) rs drop⁺ (s≤s m≥n) (r rs) = drop⁺ m≥n rs drop⁺-≥ : m n Pointwise R as bs @@ -247,7 +247,7 @@ drop⁺-⊆ : m Sublist R as bs Sublist R (drop m as) (drop m bs) - drop⁺-⊆ m = drop⁺ (ℕ.≤-refl {m}) + drop⁺-⊆ m = drop⁺ (ℕ.≤-refl {m}) module _ {R : REL A B r} {P : Pred A p} {Q : Pred B q} (P? : U.Decidable P) (Q? : U.Decidable Q) where @@ -259,7 +259,7 @@ ⊆-takeWhile-Sublist {a as} {b bs} rp⇒q (p ps) with P? a | Q? b ... | false because _ | _ = minimum _ ... | true because _ | true because _ = p ⊆-takeWhile-Sublist rp⇒q ps - ... | yes pa | no ¬qb = contradiction (rp⇒q p pa) ¬qb + ... | yes pa | no ¬qb = contradiction (rp⇒q p pa) ¬qb ⊇-dropWhile-Sublist : (∀ {a b} R a b Q b P a) Pointwise R as bs @@ -270,7 +270,7 @@ ... | true because _ | false because _ = b ∷ʳ dropWhile-Sublist P? (fromPointwise ps) ... | false because _ | false because _ = p fromPointwise ps - ... | no ¬pa | yes qb = contradiction (rq⇒p p qb) ¬pa + ... | no ¬pa | yes qb = contradiction (rq⇒p p qb) ¬pa ⊆-filter-Sublist : (∀ {a b} R a b P a Q b) Sublist R as bs Sublist R (filter P? as) (filter Q? bs) @@ -282,7 +282,7 @@ ... | true because _ | true because _ = r ⊆-filter-Sublist rp⇒q rs ... | false because _ | true because _ = _ ∷ʳ ⊆-filter-Sublist rp⇒q rs ... | false because _ | false because _ = ⊆-filter-Sublist rp⇒q rs - ... | yes pa | no ¬qb = contradiction (rp⇒q r pa) ¬qb + ... | yes pa | no ¬qb = contradiction (rp⇒q r pa) ¬qb module _ {R : Rel A r} {P : Pred A p} (P? : U.Decidable P) where @@ -399,28 +399,28 @@ {R : REL A B r} {S : REL B A s} {E : REL A B e} (rs⇒e : Antisym R S E) where - open ℕ.≤-Reasoning + open ℕ.≤-Reasoning antisym : Antisym (Sublist R) (Sublist S) (Pointwise E) antisym [] [] = [] antisym (r rs) (s ss) = rs⇒e r s antisym rs ss -- impossible cases antisym (_∷ʳ_ {xs} {ys₁} y rs) (_∷ʳ_ {ys₂} {zs} z ss) = - contradiction (begin + contradiction (begin length (y ys₁) ≤⟨ length-mono-≤ ss - length zs ≤⟨ ℕ.n≤1+n (length zs) + length zs ≤⟨ ℕ.n≤1+n (length zs) length (z zs) ≤⟨ length-mono-≤ rs - length ys₁ ) $ ℕ.<-irrefl ≡.refl + length ys₁ ) $ ℕ.<-irrefl ≡.refl antisym (_∷ʳ_ {xs} {ys₁} y rs) (_∷_ {y} {ys₂} {z} {zs} s ss) = - contradiction (begin + contradiction (begin length (z zs) ≤⟨ length-mono-≤ rs length ys₁ ≤⟨ length-mono-≤ ss - length zs ) $ ℕ.<-irrefl ≡.refl + length zs ) $ ℕ.<-irrefl ≡.refl antisym (_∷_ {x} {xs} {y} {ys₁} r rs) (_∷ʳ_ {ys₂} {zs} z ss) = - contradiction (begin + contradiction (begin length (y ys₁) ≤⟨ length-mono-≤ ss length xs ≤⟨ length-mono-≤ rs - length ys₁ ) $ ℕ.<-irrefl ≡.refl + length ys₁ ) $ ℕ.<-irrefl ≡.refl open Antisymmetry public diff --git a/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Solver.html b/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Solver.html index 990235597d..fbb268a5e9 100644 --- a/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Solver.html +++ b/v2.3/Data.List.Relation.Binary.Sublist.Heterogeneous.Solver.html @@ -126,7 +126,7 @@ -- Solver for items solveI : {n} (a b : Item n) Maybe (a ⊆I b) -solveI (var k) (var l) = Maybe.map var $ dec⇒weaklyDec Fin._≟_ k l +solveI (var k) (var l) = Maybe.map var $ dec⇒weaklyDec Fin._≟_ k l solveI (val a) (val b) = Maybe.map val $ dec⇒weaklyDec R? a b solveI _ _ = nothing diff --git a/v2.3/Data.List.Relation.Binary.Sublist.Setoid.Properties.html b/v2.3/Data.List.Relation.Binary.Sublist.Setoid.Properties.html index fa00aa1040..5b6729c870 100644 --- a/v2.3/Data.List.Relation.Binary.Sublist.Setoid.Properties.html +++ b/v2.3/Data.List.Relation.Binary.Sublist.Setoid.Properties.html @@ -240,7 +240,7 @@ module _ where drop⁺-⊆ : n xs ys drop n xs drop n ys - drop⁺-⊆ n xs⊆ys = drop⁺ {n} ℕ.≤-refl xs⊆ys + drop⁺-⊆ n xs⊆ys = drop⁺ {n} ℕ.≤-refl xs⊆ys ------------------------------------------------------------------------ -- takeWhile / dropWhile diff --git a/v2.3/Data.List.Relation.Binary.Subset.Setoid.Properties.html b/v2.3/Data.List.Relation.Binary.Subset.Setoid.Properties.html index 48ecdc617c..e7f8028de2 100644 --- a/v2.3/Data.List.Relation.Binary.Subset.Setoid.Properties.html +++ b/v2.3/Data.List.Relation.Binary.Subset.Setoid.Properties.html @@ -27,7 +27,7 @@ open import Function.Base using (_∘_; _∘₂_; _$_; case_of_) open import Level using (Level) open import Relation.Nullary using (¬_; does; yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Unary using (Pred; Decidable) renaming (_⊆_ to _⋐_) open import Relation.Binary.Core using (_⇒_; _Preserves_⟶_) open import Relation.Binary.Definitions @@ -217,7 +217,7 @@ ⊆∷∧∉⇒⊆ : xs y ys y xs xs ys ⊆∷∧∉⇒⊆ xs⊆y∷ys y∉xs with ⊆∷⇒∈∨⊆ xs⊆y∷ys - ... | inj₁ y∈xs = contradiction y∈xs y∉xs + ... | inj₁ y∈xs = contradiction y∈xs y∉xs ... | inj₂ xs⊆ys = xs⊆ys ------------------------------------------------------------------------ diff --git a/v2.3/Data.List.Relation.Binary.Suffix.Heterogeneous.Properties.html b/v2.3/Data.List.Relation.Binary.Suffix.Heterogeneous.Properties.html index 3f76b41261..7b4b86c9fb 100644 --- a/v2.3/Data.List.Relation.Binary.Suffix.Heterogeneous.Properties.html +++ b/v2.3/Data.List.Relation.Binary.Suffix.Heterogeneous.Properties.html @@ -24,7 +24,7 @@ open import Relation.Nullary using (Dec; does; ¬_) import Relation.Nullary.Decidable as Dec open import Relation.Unary as U using (Pred) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.Core using (REL; Rel; _⇒_) open import Relation.Binary.Definitions as B using (Trans; Antisym; Irrelevant) @@ -75,12 +75,12 @@ module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where length-mono : {as bs} Suffix R as bs length as length bs - length-mono (here rs) = ≤-reflexive (Pointwise-length rs) - length-mono (there suf) = m≤n⇒m≤1+n (length-mono suf) + length-mono (here rs) = ≤-reflexive (Pointwise-length rs) + length-mono (there suf) = m≤n⇒m≤1+n (length-mono suf) S[as][bs]⇒∣as∣≢1+∣bs∣ : {as bs} Suffix R as bs length as suc (length bs) - S[as][bs]⇒∣as∣≢1+∣bs∣ suf eq = <⇒≱ (≤-reflexive (sym eq)) (length-mono suf) + S[as][bs]⇒∣as∣≢1+∣bs∣ suf eq = <⇒≱ (≤-reflexive (sym eq)) (length-mono suf) ------------------------------------------------------------------------ -- Pointwise conversion @@ -93,7 +93,7 @@ toPointwise : {as bs} length as length bs Suffix R as bs Pointwise R as bs toPointwise eq (here rs) = rs - toPointwise eq (there suf) = contradiction eq (S[as][bs]⇒∣as∣≢1+∣bs∣ suf) + toPointwise eq (there suf) = contradiction eq (S[as][bs]⇒∣as∣≢1+∣bs∣ suf) ------------------------------------------------------------------------ -- Suffix as a partial order @@ -114,7 +114,7 @@ rs⇒e (toPointwise eq rsuf) (toPointwise (sym eq) ssuf) - where eq = ≤-antisym (length-mono rsuf) (length-mono ssuf) + where eq = ≤-antisym (length-mono rsuf) (length-mono ssuf) ------------------------------------------------------------------------ -- _++_ @@ -131,13 +131,13 @@ ++⁻ {_ _} {_} {_} {_} eq suf = ++⁻ eq (tail suf) ++⁻ {[]} {[]} {_} {_} eq suf = toPointwise eq suf ++⁻ {[]} {b bs} {_} {_} eq (there suf) = ++⁻ eq suf - ++⁻ {[]} {b bs} {cs} {ds} eq (here rs) = contradiction (sym eq) (<⇒≢ ds<cs) + ++⁻ {[]} {b bs} {cs} {ds} eq (here rs) = contradiction (sym eq) (<⇒≢ ds<cs) where - open ≤-Reasoning + open ≤-Reasoning ds<cs : length ds < length cs ds<cs = begin-strict - length ds ≤⟨ m≤n+m (length ds) (length bs) - length bs + length ds <⟨ ≤-refl + length ds ≤⟨ m≤n+m (length ds) (length bs) + length bs + length ds <⟨ ≤-refl suc (length bs + length ds) ≡⟨ sym $ List.length-++ (b bs) length (b bs ++ ds) ≡⟨ sym $ Pointwise-length rs length cs @@ -159,7 +159,7 @@ Suffix a b R (f a) (g b)) as bs map⁻ {as} {b bs} f g (here rs) = here (Pw.map⁻ f g rs) map⁻ {as} {b bs} f g (there suf) = there (map⁻ f g suf) - map⁻ {x as} {[]} f g suf = contradiction (length-mono suf) λ() + map⁻ {x as} {[]} f g suf = contradiction (length-mono suf) λ() map⁻ {[]} {[]} f g suf = here [] ------------------------------------------------------------------------ @@ -186,7 +186,7 @@ replicate⁺ : {m n a b} m n R a b Suffix R (replicate m a) (replicate n b) - replicate⁺ {a = a} {b = b} m≤n r = repl (≤⇒≤′ m≤n) + replicate⁺ {a = a} {b = b} m≤n r = repl (≤⇒≤′ m≤n) where repl : {m n} m ≤′ n Suffix R (replicate m a) (replicate n b) repl ≤′-refl = here (Pw.replicate⁺ r _) @@ -199,8 +199,8 @@ irrelevant : Irrelevant R Irrelevant (Suffix R) irrelevant irr (here rs) (here rs₁) = cong here $ Pw.irrelevant irr rs rs₁ - irrelevant irr (here rs) (there rsuf) = contradiction (Pointwise-length rs) (S[as][bs]⇒∣as∣≢1+∣bs∣ rsuf) - irrelevant irr (there rsuf) (here rs) = contradiction (Pointwise-length rs) (S[as][bs]⇒∣as∣≢1+∣bs∣ rsuf) + irrelevant irr (here rs) (there rsuf) = contradiction (Pointwise-length rs) (S[as][bs]⇒∣as∣≢1+∣bs∣ rsuf) + irrelevant irr (there rsuf) (here rs) = contradiction (Pointwise-length rs) (S[as][bs]⇒∣as∣≢1+∣bs∣ rsuf) irrelevant irr (there rsuf) (there rsuf₁) = cong there $ irrelevant irr rsuf rsuf₁ ------------------------------------------------------------------------ diff --git a/v2.3/Data.List.Relation.Ternary.Interleaving.Properties.html b/v2.3/Data.List.Relation.Ternary.Interleaving.Properties.html index f36a62f086..c7cc0acbb0 100644 --- a/v2.3/Data.List.Relation.Ternary.Interleaving.Properties.html +++ b/v2.3/Data.List.Relation.Ternary.Interleaving.Properties.html @@ -10,7 +10,7 @@ module Data.List.Relation.Ternary.Interleaving.Properties where open import Data.Nat.Base -open import Data.Nat.Properties using (+-suc) +open import Data.Nat.Properties using (+-suc) open import Data.List.Base hiding (_∷ʳ_) open import Data.List.Properties using (reverse-involutive) open import Data.List.Relation.Ternary.Interleaving hiding (map) @@ -34,7 +34,7 @@ interleave-length (l ∷ˡ sp) = cong suc (interleave-length sp) interleave-length {as} {l} {r rs} (_ ∷ʳ sp) = begin length as ≡⟨ cong suc (interleave-length sp) - suc (length l + length rs) ≡⟨ sym $ +-suc _ _ + suc (length l + length rs) ≡⟨ sym $ +-suc _ _ length l + length (r rs) ------------------------------------------------------------------------ diff --git a/v2.3/Data.List.Relation.Unary.All.Properties.Core.html b/v2.3/Data.List.Relation.Unary.All.Properties.Core.html index 034b255814..6c3a6b62b3 100644 --- a/v2.3/Data.List.Relation.Unary.All.Properties.Core.html +++ b/v2.3/Data.List.Relation.Unary.All.Properties.Core.html @@ -22,7 +22,7 @@ open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong; cong₂) open import Relation.Nullary.Reflects using (invert) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Decidable.Core using (_because_) open import Relation.Unary using (Decidable; Pred; Universal) @@ -47,7 +47,7 @@ All¬⇒¬Any (_ ¬p) (there p) = All¬⇒¬Any ¬p p ¬All⇒Any¬ : Decidable P xs ¬ All P xs Any (¬_ P) xs -¬All⇒Any¬ dec [] ¬∀ = contradiction [] ¬∀ +¬All⇒Any¬ dec [] ¬∀ = contradiction [] ¬∀ ¬All⇒Any¬ dec (x xs) ¬∀ with dec x ... | true because [p] = there (¬All⇒Any¬ dec xs (¬∀ _∷_ (invert [p]))) ... | false because [¬p] = here (invert [¬p]) @@ -82,7 +82,7 @@ -- equivalence could be strengthened to a surjection. to∘from : Extensionality _ _ (dec : Decidable P) (¬∀ : ¬ All P xs) Any¬⇒¬All (¬All⇒Any¬ dec xs ¬∀) ¬∀ - to∘from ext P ¬∀ = ext λ ∀P contradiction ∀P ¬∀ + to∘from ext P ¬∀ = ext λ ∀P contradiction ∀P ¬∀ module _ {_~_ : REL A B } where diff --git a/v2.3/Data.List.Relation.Unary.All.Properties.html b/v2.3/Data.List.Relation.Unary.All.Properties.html index dd86aae9dc..b849a2ef40 100644 --- a/v2.3/Data.List.Relation.Unary.All.Properties.html +++ b/v2.3/Data.List.Relation.Unary.All.Properties.html @@ -33,7 +33,7 @@ open import Data.Maybe.Relation.Unary.All as Maybe using (just; nothing; fromAny) open import Data.Maybe.Relation.Unary.Any as Maybe using (just) open import Data.Nat.Base using (zero; suc; s≤s; _<_; z<s; s<s) -open import Data.Nat.Properties using (≤-refl; m≤n⇒m≤1+n) +open import Data.Nat.Properties using (≤-refl; m≤n⇒m≤1+n) open import Data.Product.Base as Product using (_×_; _,_; uncurry; uncurry′) open import Function.Base using (_∘_; _$_; id; case_of_; flip) open import Function.Bundles using (_↠_; mk↠ₛ; _⇔_; mk⇔; _↔_; mk↔ₛ′; Equivalence) @@ -44,7 +44,7 @@ open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; sym; cong; cong₂; _≗_) open import Relation.Nullary.Reflects using (invert) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Decidable using (Dec; does; yes; no; _because_; ¬?; decidable-stable; dec-true) open import Relation.Unary @@ -164,7 +164,7 @@ pxs [ i ]= px updateAt j f pxs [ i ]= px updateAt-minimal (here .refl) (here refl) (px pxs) i≢j here = - contradiction refl (i≢j refl) + contradiction refl (i≢j refl) updateAt-minimal (here .refl) (there j) (px pxs) i≢j here = here updateAt-minimal (there i) (here refl) (px pxs) i≢j (there val) = there val updateAt-minimal (there i) (there j) (px pxs) i≢j (there val) = @@ -257,7 +257,7 @@ i ≢∈ j updateAt {P = P} i f updateAt j g updateAt j g updateAt i f updateAt-commutes (here refl) (here refl) i≢j (px pxs) = - contradiction refl (i≢j refl) + contradiction refl (i≢j refl) updateAt-commutes (here refl) (there j) i≢j (px pxs) = refl updateAt-commutes (there i) (here refl) i≢j (px pxs) = refl updateAt-commutes (there i) (there j) i≢j (px pxs) = @@ -508,7 +508,7 @@ applyDownFrom⁺₁ : f n (∀ {i} i < n P (f i)) All P (applyDownFrom f n) applyDownFrom⁺₁ f zero Pf = [] -applyDownFrom⁺₁ f (suc n) Pf = Pf ≤-refl applyDownFrom⁺₁ f n (Pf m≤n⇒m≤1+n) +applyDownFrom⁺₁ f (suc n) Pf = Pf ≤-refl applyDownFrom⁺₁ f n (Pf m≤n⇒m≤1+n) applyDownFrom⁺₂ : f n (∀ i P (f i)) All P (applyDownFrom f n) applyDownFrom⁺₂ f n Pf = applyDownFrom⁺₁ f n _ Pf _) @@ -557,10 +557,10 @@ filter⁻ : All Q (filter P? xs) All Q (filter (¬? P?) xs) All Q xs filter⁻ {xs = []} [] [] = [] filter⁻ {xs = x _} all⁺ all⁻ with P? x | ¬? (P? x) - filter⁻ {xs = x _} all⁺ all⁻ | yes Px | yes ¬Px = contradiction Px ¬Px + filter⁻ {xs = x _} all⁺ all⁻ | yes Px | yes ¬Px = contradiction Px ¬Px filter⁻ {xs = x _} (qx all⁺) all⁻ | yes Px | no ¬¬Px = qx filter⁻ all⁺ all⁻ filter⁻ {xs = x _} all⁺ (qx all⁻) | no _ | yes ¬Px = qx filter⁻ all⁺ all⁻ - filter⁻ {xs = x _} all⁺ all⁻ | no ¬Px | no ¬¬Px = contradiction ¬Px ¬¬Px + filter⁻ {xs = x _} all⁺ all⁻ | no ¬Px | no ¬¬Px = contradiction ¬Px ¬¬Px ------------------------------------------------------------------------ -- partition diff --git a/v2.3/Data.List.Relation.Unary.AllPairs.Properties.html b/v2.3/Data.List.Relation.Unary.AllPairs.Properties.html index 95a339c05d..a3e0b9f2da 100644 --- a/v2.3/Data.List.Relation.Unary.AllPairs.Properties.html +++ b/v2.3/Data.List.Relation.Unary.AllPairs.Properties.html @@ -18,9 +18,9 @@ open import Data.Maybe.Base using (Maybe; nothing; just) open import Data.Maybe.Relation.Binary.Pointwise using (pointwise⊆any; Pointwise) open import Data.Fin.Base as F using (Fin) -open import Data.Fin.Properties using (suc-injective; <⇒≢) +open import Data.Fin.Properties using (suc-injective; <⇒≢) open import Data.Nat.Base using (zero; suc; _<_; z≤n; s≤s; z<s; s<s) -open import Data.Nat.Properties using (≤-refl; m<n⇒m<1+n) +open import Data.Nat.Properties using (≤-refl; m<n⇒m<1+n) open import Function.Base using (_∘_; flip; _on_) open import Level using (Level) open import Relation.Binary.Core using (Rel) @@ -111,8 +111,8 @@ AllPairs R (applyDownFrom f n) applyDownFrom⁺₁ f zero Rf = [] applyDownFrom⁺₁ f (suc n) Rf = - All.applyDownFrom⁺₁ _ n (flip Rf ≤-refl) - applyDownFrom⁺₁ f n j<i i<n Rf j<i (m<n⇒m<1+n i<n)) + All.applyDownFrom⁺₁ _ n (flip Rf ≤-refl) + applyDownFrom⁺₁ f n j<i i<n Rf j<i (m<n⇒m<1+n i<n)) applyDownFrom⁺₂ : f n (∀ i j R (f i) (f j)) AllPairs R (applyDownFrom f n) applyDownFrom⁺₂ f n Rf = applyDownFrom⁺₁ f n _ _ Rf _ _) @@ -131,7 +131,7 @@ tabulate⁺ : {n} {f : Fin n A} (∀ {i j} i j R (f i) (f j)) AllPairs R (tabulate f) - tabulate⁺ fᵢ~fⱼ = tabulate⁺-< (fᵢ~fⱼ <⇒≢) + tabulate⁺ fᵢ~fⱼ = tabulate⁺-< (fᵢ~fⱼ <⇒≢) ------------------------------------------------------------------------ -- filter diff --git a/v2.3/Data.List.Relation.Unary.Any.Properties.html b/v2.3/Data.List.Relation.Unary.Any.Properties.html index ea57979f18..7169efd7b8 100644 --- a/v2.3/Data.List.Relation.Unary.Any.Properties.html +++ b/v2.3/Data.List.Relation.Unary.Any.Properties.html @@ -23,7 +23,7 @@ open import Data.List.Relation.Binary.Pointwise using (Pointwise; []; _∷_) open import Data.Nat.Base using (zero; suc; _<_; z<s; s<s; s≤s) -open import Data.Nat.Properties using (_≟_; ≤∧≢⇒<; ≤-refl; m<n⇒m<1+n) +open import Data.Nat.Properties using (_≟_; ≤∧≢⇒<; ≤-refl; m<n⇒m<1+n) open import Data.Maybe.Base using (Maybe; just; nothing) open import Data.Maybe.Relation.Unary.Any as MAny using (just) open import Data.Product.Base as Product @@ -49,7 +49,7 @@ using (Pred; _⟨×⟩_; _⟨→⟩_) renaming (_⊆_ to _⋐_) open import Relation.Nullary.Decidable.Core using (¬?; _because_; does; yes; no; decidable-stable) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Reflects using (invert) private @@ -525,13 +525,13 @@ applyDownFrom⁺ : f {i n} P (f i) i < n Any P (applyDownFrom f n) applyDownFrom⁺ f {i} {suc n} p (s≤s i≤n) with i n ... | yes refl = here p -... | no i≢n = there (applyDownFrom⁺ f p (≤∧≢⇒< i≤n i≢n)) +... | no i≢n = there (applyDownFrom⁺ f p (≤∧≢⇒< i≤n i≢n)) applyDownFrom⁻ : f {n} Any P (applyDownFrom f n) λ i i < n × P (f i) -applyDownFrom⁻ f {suc n} (here p) = n , ≤-refl , p +applyDownFrom⁻ f {suc n} (here p) = n , ≤-refl , p applyDownFrom⁻ f {suc n} (there p) = - let i , i<n , q = applyDownFrom⁻ f p in i , m<n⇒m<1+n i<n , q + let i , i<n , q = applyDownFrom⁻ f p in i , m<n⇒m<1+n i<n , q ------------------------------------------------------------------------ -- tabulate diff --git a/v2.3/Data.List.Relation.Unary.Any.html b/v2.3/Data.List.Relation.Unary.Any.html index 9e400d3509..b41632e012 100644 --- a/v2.3/Data.List.Relation.Unary.Any.html +++ b/v2.3/Data.List.Relation.Unary.Any.html @@ -15,7 +15,7 @@ open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂) open import Level using (Level; _⊔_) open import Relation.Nullary.Decidable.Core as Dec using (no; _⊎-dec_) -open import Relation.Nullary.Negation using (¬_; contradiction) +open import Relation.Nullary.Negation using (¬_; contradiction) open import Relation.Unary using (Pred; _⊆_; Decidable; Satisfiable) private @@ -42,10 +42,10 @@ head : ¬ Any P xs Any P (x xs) P x head ¬pxs (here px) = px -head ¬pxs (there pxs) = contradiction pxs ¬pxs +head ¬pxs (there pxs) = contradiction pxs ¬pxs tail : ¬ P x Any P (x xs) Any P xs -tail ¬px (here px) = contradiction px ¬px +tail ¬px (here px) = contradiction px ¬px tail ¬px (there pxs) = pxs map : P Q Any P Any Q diff --git a/v2.3/Data.List.Relation.Unary.Enumerates.Setoid.Properties.html b/v2.3/Data.List.Relation.Unary.Enumerates.Setoid.Properties.html index d7c0458cde..c86bc3b3a4 100644 --- a/v2.3/Data.List.Relation.Unary.Enumerates.Setoid.Properties.html +++ b/v2.3/Data.List.Relation.Unary.Enumerates.Setoid.Properties.html @@ -16,7 +16,7 @@ open import Data.List.Relation.Unary.Enumerates.Setoid open import Data.Sum.Base using (inj₁; inj₂) open import Data.Sum.Relation.Binary.Pointwise - using (_⊎ₛ_; inj₁; inj₂) + using (_⊎ₛ_; inj₁; inj₂) open import Data.Product.Base using (_,_) open import Data.Product.Relation.Binary.Pointwise.NonDependent using (_×ₛ_) @@ -60,9 +60,9 @@ module _ (S : Setoid a ℓ₁) (T : Setoid b ℓ₂) where ++⁺ : IsEnumeration S xs IsEnumeration T ys - IsEnumeration (S ⊎ₛ T) (map inj₁ xs ++ map inj₂ ys) - ++⁺ _∈xs _ (inj₁ x) = ∈-++⁺ˡ (S ⊎ₛ T) (∈-map⁺ S (S ⊎ₛ T) inj₁ (x ∈xs)) - ++⁺ _ _∈ys (inj₂ y) = ∈-++⁺ʳ (S ⊎ₛ T) _ (∈-map⁺ T (S ⊎ₛ T) inj₂ (y ∈ys)) + IsEnumeration (S ⊎ₛ T) (map inj₁ xs ++ map inj₂ ys) + ++⁺ _∈xs _ (inj₁ x) = ∈-++⁺ˡ (S ⊎ₛ T) (∈-map⁺ S (S ⊎ₛ T) inj₁ (x ∈xs)) + ++⁺ _ _∈ys (inj₂ y) = ∈-++⁺ʳ (S ⊎ₛ T) _ (∈-map⁺ T (S ⊎ₛ T) inj₂ (y ∈ys)) ------------------------------------------------------------------------ -- cartesianProduct diff --git a/v2.3/Data.List.Relation.Unary.First.Properties.html b/v2.3/Data.List.Relation.Unary.First.Properties.html index d8bc1fe93b..47a0131c2e 100644 --- a/v2.3/Data.List.Relation.Unary.First.Properties.html +++ b/v2.3/Data.List.Relation.Unary.First.Properties.html @@ -19,7 +19,7 @@ open import Function.Base using (_∘′_; _∘_; id) open import Relation.Binary.PropositionalEquality.Core as using (_≡_; refl; _≗_) open import Relation.Nullary.Decidable.Core as Dec -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Relation.Nullary.Reflects using (invert) open import Relation.Unary using (Pred; _⊆_; ; Irrelevant; Decidable) @@ -55,7 +55,7 @@ module _ {a p q} {A : Set a} {P : Pred A p} {Q : Pred A q} where All⇒¬First : P Q All P (First P Q) - All⇒¬First p⇒¬q (px pxs) [ qx ] = contradiction qx (p⇒¬q px) + All⇒¬First p⇒¬q (px pxs) [ qx ] = contradiction qx (p⇒¬q px) All⇒¬First p⇒¬q (_ pxs) (_ hf) = All⇒¬First p⇒¬q pxs hf First⇒¬All : Q P First P Q (All P) @@ -69,7 +69,7 @@ px ¬First⇒All ¬q⇒p (¬pqxxs (px ∷_)) ¬All⇒First : Decidable P P Q (All P) First P Q - ¬All⇒First P? ¬p⇒q {x = []} ¬⊤ = contradiction [] ¬⊤ + ¬All⇒First P? ¬p⇒q {x = []} ¬⊤ = contradiction [] ¬⊤ ¬All⇒First P? ¬p⇒q {x = x xs} ¬∀ with P? x ... | true because [px] = let px = invert [px] in px ¬All⇒First P? ¬p⇒q (¬∀ (px ∷_)) @@ -80,14 +80,14 @@ unique-index : {xs} P Q (f₁ f₂ : First P Q xs) index f₁ index f₂ unique-index p⇒¬q [ _ ] [ _ ] = refl - unique-index p⇒¬q [ qx ] (px _) = contradiction qx (p⇒¬q px) - unique-index p⇒¬q (px _) [ qx ] = contradiction qx (p⇒¬q px) + unique-index p⇒¬q [ qx ] (px _) = contradiction qx (p⇒¬q px) + unique-index p⇒¬q (px _) [ qx ] = contradiction qx (p⇒¬q px) unique-index p⇒¬q (_ f₁) (_ f₂) = ≡.cong suc (unique-index p⇒¬q f₁ f₂) irrelevant : P Q Irrelevant P Irrelevant Q Irrelevant (First P Q) irrelevant p⇒¬q p-irr q-irr [ px ] [ qx ] = ≡.cong [_] (q-irr px qx) - irrelevant p⇒¬q p-irr q-irr [ qx ] (px _) = contradiction qx (p⇒¬q px) - irrelevant p⇒¬q p-irr q-irr (px _) [ qx ] = contradiction qx (p⇒¬q px) + irrelevant p⇒¬q p-irr q-irr [ qx ] (px _) = contradiction qx (p⇒¬q px) + irrelevant p⇒¬q p-irr q-irr (px _) [ qx ] = contradiction qx (p⇒¬q px) irrelevant p⇒¬q p-irr q-irr (px f) (qx g) = ≡.cong₂ _∷_ (p-irr px qx) (irrelevant p⇒¬q p-irr q-irr f g) @@ -98,7 +98,7 @@ first? : Decidable P Decidable (First P ( P)) first? P? = Dec.fromSum - Sum.map₂ (All⇒¬First contradiction) + Sum.map₂ (All⇒¬First contradiction) first (Dec.toSum P?) cofirst? : Decidable P Decidable (First ( P) P) diff --git a/v2.3/Data.List.Relation.Unary.First.html b/v2.3/Data.List.Relation.Unary.First.html index 83d05ed69c..5655e957b4 100644 --- a/v2.3/Data.List.Relation.Unary.First.html +++ b/v2.3/Data.List.Relation.Unary.First.html @@ -19,7 +19,7 @@ open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂) open import Function.Base using (id; _∘′_) open import Relation.Unary -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) ------------------------------------------------------------------------ -- Basic type. @@ -68,7 +68,7 @@ empty () tail : {x xs} ¬ Q x First P Q (x xs) First P Q xs - tail ¬qx [ qx ] = contradiction qx ¬qx + tail ¬qx [ qx ] = contradiction qx ¬qx tail ¬qx (px pqxs) = pqxs index : First P Q (Fin ∘′ List.length) diff --git a/v2.3/Data.List.Relation.Unary.Grouped.Properties.html b/v2.3/Data.List.Relation.Unary.Grouped.Properties.html index 6ecb1b921a..b1ec5e26af 100644 --- a/v2.3/Data.List.Relation.Unary.Grouped.Properties.html +++ b/v2.3/Data.List.Relation.Unary.Grouped.Properties.html @@ -22,7 +22,7 @@ open import Relation.Binary.Core using (_⇔_; REL; Rel) open import Relation.Unary as U using (Pred) open import Relation.Nullary.Decidable.Core using (does; yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) private variable @@ -62,9 +62,9 @@ grouped[xs]⇒unique[derun[xs]] [] [] = [] grouped[xs]⇒unique[derun[xs]] (x []) ([] ∷≉ []) = [] [] grouped[xs]⇒unique[derun[xs]] (x y xs) (all[¬Px,y∷xs]@(¬Pxy _) ∷≉ grouped[y∷xs]) with P? x y - ... | yes Pxy = contradiction Pxy ¬Pxy + ... | yes Pxy = contradiction Pxy ¬Pxy ... | no _ = All.derun⁺ P? all[¬Px,y∷xs] grouped[xs]⇒unique[derun[xs]] (y xs) grouped[y∷xs] grouped[xs]⇒unique[derun[xs]] (x y xs) (Pxy ∷≈ grouped[xs]) with P? x y ... | yes _ = grouped[xs]⇒unique[derun[xs]] (y xs) grouped[xs] - ... | no ¬Pxy = contradiction Pxy ¬Pxy + ... | no ¬Pxy = contradiction Pxy ¬Pxy \ No newline at end of file diff --git a/v2.3/Data.List.Relation.Unary.Linked.Properties.html b/v2.3/Data.List.Relation.Unary.Linked.Properties.html index 652a4b2247..50362b4586 100644 --- a/v2.3/Data.List.Relation.Unary.Linked.Properties.html +++ b/v2.3/Data.List.Relation.Unary.Linked.Properties.html @@ -18,7 +18,7 @@ open import Data.List.Relation.Unary.Linked as Linked using (Linked; []; [-]; _∷_) open import Data.Nat.Base using (zero; suc; _<_; z<s; s<s) -open import Data.Nat.Properties using (≤-refl; m≤n⇒m≤1+n) +open import Data.Nat.Properties using (≤-refl; m≤n⇒m≤1+n) open import Data.Maybe.Relation.Binary.Connected using (Connected; just; nothing; just-nothing; nothing-just) open import Level using (Level) @@ -119,7 +119,7 @@ applyDownFrom⁺₁ f 0 Rf = [] applyDownFrom⁺₁ f 1 Rf = [-] applyDownFrom⁺₁ f (suc n@(suc _)) Rf = - Rf ≤-refl applyDownFrom⁺₁ f n (Rf m≤n⇒m≤1+n) + Rf ≤-refl applyDownFrom⁺₁ f n (Rf m≤n⇒m≤1+n) applyDownFrom⁺₂ : f n (∀ i R (f (suc i)) (f i)) Linked R (applyDownFrom f n) diff --git a/v2.3/Data.List.Relation.Unary.Sorted.TotalOrder.Properties.html b/v2.3/Data.List.Relation.Unary.Sorted.TotalOrder.Properties.html index 081f1c8851..db21955677 100644 --- a/v2.3/Data.List.Relation.Unary.Sorted.TotalOrder.Properties.html +++ b/v2.3/Data.List.Relation.Unary.Sorted.TotalOrder.Properties.html @@ -40,7 +40,7 @@ import Relation.Binary.Properties.TotalOrder as TotalOrderProperties import Relation.Binary.Reasoning.PartialOrder as PosetReasoning open import Relation.Unary using (Pred; Decidable) -open import Relation.Nullary using (contradiction) +open import Relation.Nullary using (contradiction) open import Relation.Nullary.Decidable using (yes; no) open import Relation.Binary.PropositionalEquality.Core as using (_≡_) @@ -204,10 +204,10 @@ {i j} toℕ i toℕ j lookup ys j lookup xs i ↗↭↗⇒≤ {xs} {ys} xs↭ys xs↗ ys↗ {i} {j} i≡j - with Fin.injective⇒existsPivot (inverseʳ⇒injective _ (Inverse.inverseʳ (onIndices xs↭ys))) i + with Fin.injective⇒existsPivot (inverseʳ⇒injective _ (Inverse.inverseʳ (onIndices xs↭ys))) i ... | (k , k≤i , i≤π[k]) = begin lookup ys j ≤⟨ lookup-mono-≤ O ys↗ (≡.subst (ℕ._≤ _) i≡j i≤π[k]) - lookup ys (onIndices xs↭ys ⟨$⟩ʳ k) ≈⟨ onIndices-lookup xs↭ys k + lookup ys (onIndices xs↭ys ⟨$⟩ʳ k) ≈⟨ onIndices-lookup xs↭ys k lookup xs k ≤⟨ lookup-mono-≤ O xs↗ k≤i lookup xs i \ No newline at end of file diff --git a/v2.3/Data.List.Relation.Unary.Unique.Propositional.Properties.html b/v2.3/Data.List.Relation.Unary.Unique.Propositional.Properties.html index 7a8fff5a83..ee5eadef8f 100644 --- a/v2.3/Data.List.Relation.Unary.Unique.Propositional.Properties.html +++ b/v2.3/Data.List.Relation.Unary.Unique.Propositional.Properties.html @@ -23,7 +23,7 @@ import Data.List.Relation.Unary.Unique.Setoid.Properties as Setoid open import Data.Fin.Base using (Fin) open import Data.Nat.Base using (_<_) -open import Data.Nat.Properties using (<⇒≢) +open import Data.Nat.Properties using (<⇒≢) open import Data.Product.Base using (_×_; _,_) open import Data.Product.Relation.Binary.Pointwise.NonDependent using (≡⇒≡×≡) open import Function.Base using (id; _∘_) @@ -121,7 +121,7 @@ -- upTo upTo⁺ : n Unique (upTo n) -upTo⁺ n = applyUpTo⁺₁ id n i<j _ <⇒≢ i<j) +upTo⁺ n = applyUpTo⁺₁ id n i<j _ <⇒≢ i<j) ------------------------------------------------------------------------ -- applyDownFrom @@ -140,7 +140,7 @@ -- downFrom downFrom⁺ : n Unique (downFrom n) -downFrom⁺ n = applyDownFrom⁺₁ id n j<i _ <⇒≢ j<i sym) +downFrom⁺ n = applyDownFrom⁺₁ id n j<i _ <⇒≢ j<i sym) ------------------------------------------------------------------------ -- tabulate diff --git a/v2.3/Data.List.Relation.Unary.Unique.Setoid.Properties.html b/v2.3/Data.List.Relation.Unary.Unique.Setoid.Properties.html index 7739869997..6c7a22b791 100644 --- a/v2.3/Data.List.Relation.Unary.Unique.Setoid.Properties.html +++ b/v2.3/Data.List.Relation.Unary.Unique.Setoid.Properties.html @@ -32,7 +32,7 @@ open import Relation.Binary.PropositionalEquality.Core using (_≡_) open import Relation.Unary using (Pred; Decidable) open import Relation.Nullary.Negation using (¬_) -open import Relation.Nullary.Negation using (contraposition) +open import Relation.Nullary.Negation using (contraposition) private variable @@ -50,11 +50,11 @@ map⁺ : {f} (∀ {x y} f x ≈₂ f y x ≈₁ y) {xs} Unique S xs Unique R (map f xs) - map⁺ inj xs! = AllPairs.map⁺ (AllPairs.map (contraposition inj) xs!) + map⁺ inj xs! = AllPairs.map⁺ (AllPairs.map (contraposition inj) xs!) map⁻ : {f} Congruent _≈₁_ _≈₂_ f {xs} Unique R (map f xs) Unique S xs - map⁻ cong fxs! = AllPairs.map (contraposition cong) (AllPairs.map⁻ fxs!) + map⁻ cong fxs! = AllPairs.map (contraposition cong) (AllPairs.map⁻ fxs!) ------------------------------------------------------------------------ -- ++ diff --git a/v2.3/Data.List.Sort.InsertionSort.Properties.html b/v2.3/Data.List.Sort.InsertionSort.Properties.html index e845f99aa6..69c5141fce 100644 --- a/v2.3/Data.List.Sort.InsertionSort.Properties.html +++ b/v2.3/Data.List.Sort.InsertionSort.Properties.html @@ -24,7 +24,7 @@ open import Relation.Binary.Definitions using (Decidable) open import Relation.Binary.Properties.DecTotalOrder O using (≰⇒≥) open import Relation.Nullary.Decidable.Core using (does; yes; no) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open DecTotalOrder O renaming (Carrier to A; trans to ≤-trans) using (totalOrder; _≤?_; _≤_; module Eq; _≈_; ≤-respʳ-≈; ≤-respˡ-≈; antisym) @@ -95,16 +95,16 @@ insert-congʳ z [] = ≋-refl insert-congʳ z (_∷_ {x} {y} {xs} {ys} x∼y eq) with z ≤? x | z ≤? y ... | yes _ | yes _ = Eq.refl x∼y eq -... | no z≰x | yes z≤y = contradiction (≤-respʳ-≈ (Eq.sym x∼y) z≤y) z≰x -... | yes z≤x | no z≰y = contradiction (≤-respʳ-≈ x∼y z≤x) z≰y +... | no z≰x | yes z≤y = contradiction (≤-respʳ-≈ (Eq.sym x∼y) z≤y) z≰x +... | yes z≤x | no z≰y = contradiction (≤-respʳ-≈ x∼y z≤x) z≰y ... | no _ | no _ = x∼y insert-congʳ z eq insert-congˡ : {x y} xs x y insert x xs insert y xs insert-congˡ {x} {y} [] eq = eq [] insert-congˡ {x} {y} (z xs) eq with x ≤? z | y ≤? z ... | yes _ | yes _ = eq ≋-refl -... | no x≰z | yes y≤z = contradiction (≤-respˡ-≈ (Eq.sym eq) y≤z) x≰z -... | yes x≤z | no y≰z = contradiction (≤-respˡ-≈ eq x≤z) y≰z +... | no x≰z | yes y≤z = contradiction (≤-respˡ-≈ (Eq.sym eq) y≤z) x≰z +... | yes x≤z | no y≰z = contradiction (≤-respˡ-≈ eq x≤z) y≰z ... | no _ | no _ = Eq.refl insert-congˡ xs eq insert-cong : {x y xs ys} x y xs ys insert x xs insert y ys @@ -117,7 +117,7 @@ private insert-swap-≤ : {x y} xs x y insert x (insert y xs) insert y (insert x xs) insert-swap-≤ {x} {y} [] x≤y with x ≤? y - ... | no xy = contradiction x≤y xy + ... | no xy = contradiction x≤y xy ... | yes xy with y ≤? x ... | yes yx = Eq.sym eq eq [] where eq = antisym yx xy ... | no _ = ≋-refl @@ -129,17 +129,17 @@ Eq.sym eq eq ≋-refl where eq = antisym yx xy insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | yes xy | yes xz | no yx with y ≤? z insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | yes xy | yes xz | no yx | yes yz' = ≋-refl - insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | yes xy | yes xz | no yx | no yz' = contradiction yz yz' - insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | yes xy | no xz = contradiction (≤-trans xy yz) xz - insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | no xy = contradiction x≤y xy + insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | yes xy | yes xz | no yx | no yz' = contradiction yz yz' + insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | yes xy | no xz = contradiction (≤-trans xy yz) xz + insert-swap-≤ {x} {y} (z xs) x≤y | yes yz | no xy = contradiction x≤y xy insert-swap-≤ {x} {y} (z xs) x≤y | no yz with x ≤? z insert-swap-≤ {x} {y} (z xs) x≤y | no yz | yes xz with y ≤? x - insert-swap-≤ {x} {y} (z xs) x≤y | no yz | yes xz | yes yx = contradiction (≤-trans yx xz) yz + insert-swap-≤ {x} {y} (z xs) x≤y | no yz | yes xz | yes yx = contradiction (≤-trans yx xz) yz insert-swap-≤ {x} {y} (z xs) x≤y | no yz | yes xz | no yx with y ≤? z - insert-swap-≤ {x} {y} (z xs) x≤y | no yz | yes xz | no yx | yes yz' = contradiction yz' yz + insert-swap-≤ {x} {y} (z xs) x≤y | no yz | yes xz | no yx | yes yz' = contradiction yz' yz insert-swap-≤ {x} {y} (z xs) x≤y | no yz | yes xz | no yx | no yz' = ≋-refl insert-swap-≤ {x} {y} (z xs) x≤y | no yz | no xz with y ≤? z - insert-swap-≤ {x} {y} (z xs) x≤y | no yz | no xz | yes yz' = contradiction yz' yz + insert-swap-≤ {x} {y} (z xs) x≤y | no yz | no xz | yes yz' = contradiction yz' yz insert-swap-≤ {x} {y} (z xs) x≤y | no yz | no xz | no yz' = Eq.refl (insert-swap-≤ xs x≤y) insert-swap : x y xs insert x (insert y xs) insert y (insert x xs) diff --git a/v2.3/Data.List.Sort.MergeSort.Base.html b/v2.3/Data.List.Sort.MergeSort.Base.html index fe745f28cc..323b9489d9 100644 --- a/v2.3/Data.List.Sort.MergeSort.Base.html +++ b/v2.3/Data.List.Sort.MergeSort.Base.html @@ -21,7 +21,7 @@ open import Data.Nat.Base using (_<_; _>_; z<s; s<s) open import Data.Nat.Induction -open import Data.Nat.Properties using (m<n⇒m<1+n) +open import Data.Nat.Properties using (m<n⇒m<1+n) open DecTotalOrder O renaming (Carrier to A) @@ -37,7 +37,7 @@ length (mergePairs zss) < length zss length-mergePairs _ _ [] = s<s z<s length-mergePairs _ _ (xs []) = s<s (s<s z<s) - length-mergePairs _ _ (xs ys yss) = s<s (m<n⇒m<1+n (length-mergePairs xs ys yss)) + length-mergePairs _ _ (xs ys yss) = s<s (m<n⇒m<1+n (length-mergePairs xs ys yss)) mergeAll : (xss : List (List A)) Acc _<_ (length xss) List A mergeAll [] _ = [] diff --git a/v2.3/Data.List.Sort.MergeSort.Properties.html b/v2.3/Data.List.Sort.MergeSort.Properties.html index e99d7a1670..abf1d14459 100644 --- a/v2.3/Data.List.Sort.MergeSort.Properties.html +++ b/v2.3/Data.List.Sort.MergeSort.Properties.html @@ -29,7 +29,7 @@ open import Data.Maybe.Base using (just) open import Data.Nat.Base using (_<_; _>_; z<s; s<s) open import Data.Nat.Induction -open import Data.Nat.Properties using (m<n⇒m<1+n) +open import Data.Nat.Properties using (m<n⇒m<1+n) open import Data.Product.Base as Product using (_,_) open import Function.Base using (_∘_) open import Relation.Nullary.Negation.Core using (¬_) diff --git a/v2.3/Data.Nat.Base.html b/v2.3/Data.Nat.Base.html index c0ea811c4d..938c1bdac4 100644 --- a/v2.3/Data.Nat.Base.html +++ b/v2.3/Data.Nat.Base.html @@ -20,7 +20,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≢_; refl; cong) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary using (Pred) ------------------------------------------------------------------------ @@ -127,7 +127,7 @@ -- Constructors ≢-nonZero : {n} n 0 NonZero n -≢-nonZero {zero} 0≢0 = contradiction refl 0≢0 +≢-nonZero {zero} 0≢0 = contradiction refl 0≢0 ≢-nonZero {suc n} n≢0 = _ >-nonZero : {n} n > 0 NonZero n diff --git a/v2.3/Data.Nat.Binary.Properties.html b/v2.3/Data.Nat.Binary.Properties.html index d0f35608d9..39076cbbf6 100644 --- a/v2.3/Data.Nat.Binary.Properties.html +++ b/v2.3/Data.Nat.Binary.Properties.html @@ -47,12 +47,12 @@ isEquivalence) open import Relation.Nullary using (¬_; yes; no) import Relation.Nullary.Decidable as Dec -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Algebra.Definitions {A = ℕᵇ} _≡_ open import Algebra.Structures {A = ℕᵇ} _≡_ import Algebra.Properties.CommutativeSemigroup as CommSemigProp -import Algebra.Properties.CommutativeSemigroup ℕ.+-commutativeSemigroup +import Algebra.Properties.CommutativeSemigroup ℕ.+-commutativeSemigroup as ℕ-+-semigroupProperties import Relation.Binary.Construct.StrictToNonStrict _≡_ _<_ as StrictToNonStrict @@ -107,16 +107,16 @@ toℕ-double : x toℕ (double x) 2 ℕ.* (toℕ x) toℕ-double zero = refl toℕ-double 1+[2 x ] = cong ((2 ℕ.*_) ℕ.suc) (toℕ-double x) -toℕ-double 2[1+ x ] = cong (2 ℕ.*_) (sym (ℕ.*-distribˡ-+ 2 1 (toℕ x))) +toℕ-double 2[1+ x ] = cong (2 ℕ.*_) (sym (ℕ.*-distribˡ-+ 2 1 (toℕ x))) toℕ-suc : x toℕ (suc x) ℕ.suc (toℕ x) toℕ-suc zero = refl toℕ-suc 2[1+ x ] = cong (ℕ.suc (2 ℕ.*_)) (toℕ-suc x) -toℕ-suc 1+[2 x ] = ℕ.*-distribˡ-+ 2 1 (toℕ x) +toℕ-suc 1+[2 x ] = ℕ.*-distribˡ-+ 2 1 (toℕ x) toℕ-pred : x toℕ (pred x) ℕ.pred (toℕ x) toℕ-pred zero = refl -toℕ-pred 2[1+ x ] = cong ℕ.pred $ sym $ ℕ.*-distribˡ-+ 2 1 (toℕ x) +toℕ-pred 2[1+ x ] = cong ℕ.pred $ sym $ ℕ.*-distribˡ-+ 2 1 (toℕ x) toℕ-pred 1+[2 x ] = toℕ-double x toℕ-fromℕ' : toℕ fromℕ' id @@ -129,7 +129,7 @@ where open ≡-Reasoning fromℕ≡fromℕ' : fromℕ fromℕ' -fromℕ≡fromℕ' n = fromℕ-helper≡fromℕ' n n ℕ.≤-refl +fromℕ≡fromℕ' n = fromℕ-helper≡fromℕ' n n ℕ.≤-refl where split : ℕᵇ Maybe Bool × ℕᵇ split zero = nothing , zero @@ -183,7 +183,7 @@ just (n % 2 ℕ.≡ᵇ 0) , fromℕ' (n / 2) ≡⟨ cong₂ _,_ (head-homo n) (tail-homo n) head (fromℕ' (ℕ.suc n)) , tail (fromℕ' (ℕ.suc n)) ≡⟨⟩ split (fromℕ' (ℕ.suc n)) ) - where rec-n/2 = fromℕ-helper≡fromℕ' (n / 2) w (ℕ.≤-trans (m/n≤m n 2) n≤w) + where rec-n/2 = fromℕ-helper≡fromℕ' (n / 2) w (ℕ.≤-trans (m/n≤m n 2) n≤w) toℕ-fromℕ : toℕ fromℕ id toℕ-fromℕ n rewrite fromℕ≡fromℕ' n = toℕ-fromℕ' n @@ -192,20 +192,20 @@ toℕ-injective {zero} {zero} _ = refl toℕ-injective {2[1+ x ]} {2[1+ y ]} 2[1+xN]≡2[1+yN] = cong 2[1+_] x≡y where - 1+xN≡1+yN = ℕ.*-cancelˡ-≡ (ℕ.suc _) (ℕ.suc _) 2 2[1+xN]≡2[1+yN] + 1+xN≡1+yN = ℕ.*-cancelˡ-≡ (ℕ.suc _) (ℕ.suc _) 2 2[1+xN]≡2[1+yN] xN≡yN = cong ℕ.pred 1+xN≡1+yN x≡y = toℕ-injective xN≡yN toℕ-injective {2[1+ x ]} {1+[2 y ]} 2[1+xN]≡1+2yN = - contradiction 2[1+xN]≡1+2yN (ℕ.even≢odd (ℕ.suc (toℕ x)) (toℕ y)) + contradiction 2[1+xN]≡1+2yN (ℕ.even≢odd (ℕ.suc (toℕ x)) (toℕ y)) toℕ-injective {1+[2 x ]} {2[1+ y ]} 1+2xN≡2[1+yN] = - contradiction (sym 1+2xN≡2[1+yN]) (ℕ.even≢odd (ℕ.suc (toℕ y)) (toℕ x)) + contradiction (sym 1+2xN≡2[1+yN]) (ℕ.even≢odd (ℕ.suc (toℕ y)) (toℕ x)) toℕ-injective {1+[2 x ]} {1+[2 y ]} 1+2xN≡1+2yN = cong 1+[2_] x≡y where 2xN≡2yN = cong ℕ.pred 1+2xN≡1+2yN - xN≡yN = ℕ.*-cancelˡ-≡ _ _ 2 2xN≡2yN + xN≡yN = ℕ.*-cancelˡ-≡ _ _ 2 2xN≡2yN x≡y = toℕ-injective xN≡yN toℕ-surjective : Surjective _≡_ _≡_ toℕ @@ -260,7 +260,7 @@ x≮0 () x≢0⇒x>0 : x zero x > zero -x≢0⇒x>0 {zero} 0≢0 = contradiction refl 0≢0 +x≢0⇒x>0 {zero} 0≢0 = contradiction refl 0≢0 x≢0⇒x>0 {2[1+ _ ]} _ = 0<even x≢0⇒x>0 {1+[2 _ ]} _ = 0<odd @@ -298,43 +298,43 @@ -- Properties of _<_ and toℕ & fromℕ. toℕ-mono-< : toℕ Preserves _<_ ℕ._<_ -toℕ-mono-< {zero} {2[1+ _ ]} _ = ℕ.0<1+n -toℕ-mono-< {zero} {1+[2 _ ]} _ = ℕ.0<1+n +toℕ-mono-< {zero} {2[1+ _ ]} _ = ℕ.0<1+n +toℕ-mono-< {zero} {1+[2 _ ]} _ = ℕ.0<1+n toℕ-mono-< {2[1+ x ]} {2[1+ y ]} (even<even x<y) = begin - ℕ.suc (2 ℕ.* (ℕ.suc xN)) ≤⟨ ℕ.+-monoʳ-≤ 1 (ℕ.*-monoʳ-≤ 2 xN<yN) - ℕ.suc (2 ℕ.* yN) ≤⟨ ℕ.n≤1+n _ - 2 ℕ.+ (2 ℕ.* yN) ≡⟨ sym (ℕ.*-distribˡ-+ 2 1 yN) + ℕ.suc (2 ℕ.* (ℕ.suc xN)) ≤⟨ ℕ.+-monoʳ-≤ 1 (ℕ.*-monoʳ-≤ 2 xN<yN) + ℕ.suc (2 ℕ.* yN) ≤⟨ ℕ.n≤1+n _ + 2 ℕ.+ (2 ℕ.* yN) ≡⟨ sym (ℕ.*-distribˡ-+ 2 1 yN) 2 ℕ.* (ℕ.suc yN) - where open ℕ.≤-Reasoning; xN = toℕ x; yN = toℕ y; xN<yN = toℕ-mono-< x<y + where open ℕ.≤-Reasoning; xN = toℕ x; yN = toℕ y; xN<yN = toℕ-mono-< x<y toℕ-mono-< {2[1+ x ]} {1+[2 y ]} (even<odd x<y) = - ℕ.+-monoʳ-≤ 1 (ℕ.*-monoʳ-≤ 2 (toℕ-mono-< x<y)) + ℕ.+-monoʳ-≤ 1 (ℕ.*-monoʳ-≤ 2 (toℕ-mono-< x<y)) toℕ-mono-< {1+[2 x ]} {2[1+ y ]} (odd<even (inj₁ x<y)) = begin ℕ.suc (ℕ.suc (2 ℕ.* xN)) ≡⟨⟩ - 2 ℕ.+ (2 ℕ.* xN) ≡⟨ sym (ℕ.*-distribˡ-+ 2 1 xN) - 2 ℕ.* (ℕ.suc xN) ≤⟨ ℕ.*-monoʳ-≤ 2 xN<yN - 2 ℕ.* yN ≤⟨ ℕ.*-monoʳ-≤ 2 (ℕ.n≤1+n _) + 2 ℕ.+ (2 ℕ.* xN) ≡⟨ sym (ℕ.*-distribˡ-+ 2 1 xN) + 2 ℕ.* (ℕ.suc xN) ≤⟨ ℕ.*-monoʳ-≤ 2 xN<yN + 2 ℕ.* yN ≤⟨ ℕ.*-monoʳ-≤ 2 (ℕ.n≤1+n _) 2 ℕ.* (ℕ.suc yN) - where open ℕ.≤-Reasoning; xN = toℕ x; yN = toℕ y; xN<yN = toℕ-mono-< x<y + where open ℕ.≤-Reasoning; xN = toℕ x; yN = toℕ y; xN<yN = toℕ-mono-< x<y toℕ-mono-< {1+[2 x ]} {2[1+ .x ]} (odd<even (inj₂ refl)) = - ℕ.≤-reflexive (sym (ℕ.*-distribˡ-+ 2 1 (toℕ x))) -toℕ-mono-< {1+[2 x ]} {1+[2 y ]} (odd<odd x<y) = ℕ.+-monoʳ-< 1 (ℕ.*-monoʳ-< 2 xN<yN) + ℕ.≤-reflexive (sym (ℕ.*-distribˡ-+ 2 1 (toℕ x))) +toℕ-mono-< {1+[2 x ]} {1+[2 y ]} (odd<odd x<y) = ℕ.+-monoʳ-< 1 (ℕ.*-monoʳ-< 2 xN<yN) where xN = toℕ x; yN = toℕ y; xN<yN = toℕ-mono-< x<y toℕ-cancel-< : {x y} toℕ x ℕ.< toℕ y x < y toℕ-cancel-< {zero} {2[1+ y ]} x<y = 0<even toℕ-cancel-< {zero} {1+[2 y ]} x<y = 0<odd toℕ-cancel-< {2[1+ x ]} {2[1+ y ]} x<y = - even<even (toℕ-cancel-< (s<s⁻¹ (ℕ.*-cancelˡ-< 2 _ _ x<y))) + even<even (toℕ-cancel-< (s<s⁻¹ (ℕ.*-cancelˡ-< 2 _ _ x<y))) toℕ-cancel-< {2[1+ x ]} {1+[2 y ]} x<y - rewrite ℕ.*-distribˡ-+ 2 1 (toℕ x) = - even<odd (toℕ-cancel-< (ℕ.*-cancelˡ-< 2 _ _ (ℕ.≤-trans (s≤s (ℕ.n≤1+n _)) (s<s⁻¹ x<y)))) + rewrite ℕ.*-distribˡ-+ 2 1 (toℕ x) = + even<odd (toℕ-cancel-< (ℕ.*-cancelˡ-< 2 _ _ (ℕ.≤-trans (s≤s (ℕ.n≤1+n _)) (s<s⁻¹ x<y)))) toℕ-cancel-< {1+[2 x ]} {2[1+ y ]} x<y with toℕ x ℕ.≟ toℕ y ... | yes x≡y = odd<even (inj₂ (toℕ-injective x≡y)) ... | no x≢y - rewrite ℕ.+-suc (toℕ y) (toℕ y ℕ.+ 0) = - odd<even (inj₁ (toℕ-cancel-< (ℕ.≤∧≢⇒< (ℕ.*-cancelˡ-≤ 2 (ℕ.+-cancelˡ-≤ 2 _ _ x<y)) x≢y))) + rewrite ℕ.+-suc (toℕ y) (toℕ y ℕ.+ 0) = + odd<even (inj₁ (toℕ-cancel-< (ℕ.≤∧≢⇒< (ℕ.*-cancelˡ-≤ 2 (ℕ.+-cancelˡ-≤ 2 _ _ x<y)) x≢y))) toℕ-cancel-< {1+[2 x ]} {1+[2 y ]} x<y = - odd<odd (toℕ-cancel-< (ℕ.*-cancelˡ-< 2 _ _ (s<s⁻¹ x<y))) + odd<odd (toℕ-cancel-< (ℕ.*-cancelˡ-< 2 _ _ (s<s⁻¹ x<y))) fromℕ-cancel-< : {x y} fromℕ x < fromℕ y x ℕ.< y fromℕ-cancel-< = subst₂ ℕ._<_ (toℕ-fromℕ _) (toℕ-fromℕ _) toℕ-mono-< @@ -461,27 +461,27 @@ -- Basic properties <⇒≱ : _<_ _≱_ -<⇒≱ x<y (inj₁ y<x) = contradiction y<x (<⇒≯ x<y) -<⇒≱ x<y (inj₂ y≡x) = contradiction (sym y≡x) (<⇒≢ x<y) +<⇒≱ x<y (inj₁ y<x) = contradiction y<x (<⇒≯ x<y) +<⇒≱ x<y (inj₂ y≡x) = contradiction (sym y≡x) (<⇒≢ x<y) ≤⇒≯ : _≤_ _≯_ ≤⇒≯ x≤y x>y = <⇒≱ x>y x≤y ≮⇒≥ : _≮_ _≥_ ≮⇒≥ {x} {y} x≮y with <-cmp x y -... | tri< lt _ _ = contradiction lt x≮y +... | tri< lt _ _ = contradiction lt x≮y ... | tri≈ _ eq _ = inj₂ (sym eq) ... | tri> _ _ y<x = <⇒≤ y<x ≰⇒> : _≰_ _>_ ≰⇒> {x} {y} x≰y with <-cmp x y -... | tri< lt _ _ = contradiction (<⇒≤ lt) x≰y -... | tri≈ _ eq _ = contradiction (inj₂ eq) x≰y +... | tri< lt _ _ = contradiction (<⇒≤ lt) x≰y +... | tri≈ _ eq _ = contradiction (inj₂ eq) x≰y ... | tri> _ _ x>y = x>y ≤∧≢⇒< : {x y} x y x y x < y ≤∧≢⇒< (inj₁ x<y) _ = x<y -≤∧≢⇒< (inj₂ x≡y) x≢y = contradiction x≡y x≢y +≤∧≢⇒< (inj₂ x≡y) x≢y = contradiction x≡y x≢y 0≤x : x zero x 0≤x zero = inj₂ refl @@ -495,13 +495,13 @@ -- Properties of _<_ and toℕ & fromℕ. fromℕ-mono-≤ : fromℕ Preserves ℕ._≤_ _≤_ -fromℕ-mono-≤ m≤n with ℕ.m≤n⇒m<n∨m≡n m≤n +fromℕ-mono-≤ m≤n with ℕ.m≤n⇒m<n∨m≡n m≤n ... | inj₁ m<n = inj₁ (fromℕ-mono-< m<n) ... | inj₂ m≡n = inj₂ (cong fromℕ m≡n) toℕ-mono-≤ : toℕ Preserves _≤_ ℕ._≤_ -toℕ-mono-≤ (inj₁ x<y) = ℕ.<⇒≤ (toℕ-mono-< x<y) -toℕ-mono-≤ (inj₂ refl) = ℕ.≤-reflexive refl +toℕ-mono-≤ (inj₁ x<y) = ℕ.<⇒≤ (toℕ-mono-< x<y) +toℕ-mono-≤ (inj₂ refl) = ℕ.≤-reflexive refl toℕ-cancel-≤ : {x y} toℕ x ℕ.≤ toℕ y x y toℕ-cancel-≤ = subst₂ _≤_ (fromℕ-toℕ _) (fromℕ-toℕ _) fromℕ-mono-≤ @@ -650,8 +650,8 @@ toℕ-homo-+ : x y toℕ (x + y) toℕ x ℕ.+ toℕ y toℕ-homo-+ zero _ = refl -toℕ-homo-+ 2[1+ x ] zero = cong ℕ.suc (sym (ℕ.+-identityʳ _)) -toℕ-homo-+ 1+[2 x ] zero = cong ℕ.suc (sym (ℕ.+-identityʳ _)) +toℕ-homo-+ 2[1+ x ] zero = cong ℕ.suc (sym (ℕ.+-identityʳ _)) +toℕ-homo-+ 1+[2 x ] zero = cong ℕ.suc (sym (ℕ.+-identityʳ _)) toℕ-homo-+ 2[1+ x ] 2[1+ y ] = begin toℕ (2[1+ x ] + 2[1+ y ]) ≡⟨⟩ toℕ 2[1+ (suc (x + y)) ] ≡⟨⟩ @@ -758,25 +758,25 @@ module +-Monomorphism = MonoidMonomorphism toℕ-isMonoidMonomorphism-+ +-assoc : Associative _+_ -+-assoc = +-Monomorphism.assoc ℕ.+-isMagma ℕ.+-assoc ++-assoc = +-Monomorphism.assoc ℕ.+-isMagma ℕ.+-assoc +-comm : Commutative _+_ -+-comm = +-Monomorphism.comm ℕ.+-isMagma ℕ.+-comm ++-comm = +-Monomorphism.comm ℕ.+-isMagma ℕ.+-comm +-identityˡ : LeftIdentity zero _+_ +-identityˡ _ = refl +-identityʳ : RightIdentity zero _+_ -+-identityʳ = +-Monomorphism.identityʳ ℕ.+-isMagma ℕ.+-identityʳ ++-identityʳ = +-Monomorphism.identityʳ ℕ.+-isMagma ℕ.+-identityʳ +-identity : Identity zero _+_ +-identity = +-identityˡ , +-identityʳ +-cancelˡ-≡ : LeftCancellative _+_ -+-cancelˡ-≡ = +-Monomorphism.cancelˡ ℕ.+-isMagma ℕ.+-cancelˡ-≡ ++-cancelˡ-≡ = +-Monomorphism.cancelˡ ℕ.+-isMagma ℕ.+-cancelˡ-≡ +-cancelʳ-≡ : RightCancellative _+_ -+-cancelʳ-≡ = +-Monomorphism.cancelʳ ℕ.+-isMagma ℕ.+-cancelʳ-≡ ++-cancelʳ-≡ = +-Monomorphism.cancelʳ ℕ.+-isMagma ℕ.+-cancelʳ-≡ ------------------------------------------------------------------------ -- Structures for _+_ @@ -785,7 +785,7 @@ +-isMagma = isMagma _+_ +-isSemigroup : IsSemigroup _+_ -+-isSemigroup = +-Monomorphism.isSemigroup ℕ.+-isSemigroup ++-isSemigroup = +-Monomorphism.isSemigroup ℕ.+-isSemigroup +-isCommutativeSemigroup : IsCommutativeSemigroup _+_ +-isCommutativeSemigroup = record @@ -794,10 +794,10 @@ } +-0-isMonoid : IsMonoid _+_ 0ᵇ -+-0-isMonoid = +-Monomorphism.isMonoid ℕ.+-0-isMonoid ++-0-isMonoid = +-Monomorphism.isMonoid ℕ.+-0-isMonoid +-0-isCommutativeMonoid : IsCommutativeMonoid _+_ 0ᵇ -+-0-isCommutativeMonoid = +-Monomorphism.isCommutativeMonoid ℕ.+-0-isCommutativeMonoid ++-0-isCommutativeMonoid = +-Monomorphism.isCommutativeMonoid ℕ.+-0-isCommutativeMonoid ------------------------------------------------------------------------ -- Bundles for _+_ @@ -835,7 +835,7 @@ +-mono-≤ {x} {x′} {y} {y′} x≤x′ y≤y′ = begin x + y ≡⟨ sym $ cong₂ _+_ (fromℕ-toℕ x) (fromℕ-toℕ y) fromℕ m + fromℕ n ≡⟨ sym (fromℕ-homo-+ m n) - fromℕ (m ℕ.+ n) ≤⟨ fromℕ-mono-≤ (ℕ.+-mono-≤ m≤m′ n≤n′) + fromℕ (m ℕ.+ n) ≤⟨ fromℕ-mono-≤ (ℕ.+-mono-≤ m≤m′ n≤n′) fromℕ (m′ ℕ.+ n′) ≡⟨ fromℕ-homo-+ m′ n′ fromℕ m′ + fromℕ n′ ≡⟨ cong₂ _+_ (fromℕ-toℕ x′) (fromℕ-toℕ y′) x′ + y′ @@ -855,7 +855,7 @@ +-mono-<-≤ {x} {x′} {y} {y′} x<x′ y≤y′ = begin-strict x + y ≡⟨ sym $ cong₂ _+_ (fromℕ-toℕ x) (fromℕ-toℕ y) fromℕ m + fromℕ n ≡⟨ sym (fromℕ-homo-+ m n) - fromℕ (m ℕ.+ n) <⟨ fromℕ-mono-< (ℕ.+-mono-<-≤ m<m′ n≤n′) + fromℕ (m ℕ.+ n) <⟨ fromℕ-mono-< (ℕ.+-mono-<-≤ m<m′ n≤n′) fromℕ (m′ ℕ.+ n′) ≡⟨ fromℕ-homo-+ m′ n′ fromℕ m′ + fromℕ n′ ≡⟨ cong₂ _+_ (fromℕ-toℕ x′) (fromℕ-toℕ y′) x′ + y′ @@ -893,7 +893,7 @@ x<x+y : x {y} y > 0ᵇ x < x + y x<x+y x {y} y>0 = begin-strict x ≡⟨ sym (fromℕ-toℕ x) - fromℕ (toℕ x) <⟨ fromℕ-mono-< (ℕ.m<m+n (toℕ x) (toℕ-mono-< y>0)) + fromℕ (toℕ x) <⟨ fromℕ-mono-< (ℕ.m<m+n (toℕ x) (toℕ-mono-< y>0)) fromℕ (toℕ x ℕ.+ toℕ y) ≡⟨ fromℕ-homo-+ (toℕ x) (toℕ y) fromℕ (toℕ x) + fromℕ (toℕ y) ≡⟨ cong₂ _+_ (fromℕ-toℕ x) (fromℕ-toℕ y) x + y @@ -913,7 +913,7 @@ x≢0⇒x+y≢0 : {x} (y : ℕᵇ) x zero x + y zero x≢0⇒x+y≢0 {2[1+ _ ]} zero _ = λ() -x≢0⇒x+y≢0 {zero} _ 0≢0 = contradiction refl 0≢0 +x≢0⇒x+y≢0 {zero} _ 0≢0 = contradiction refl 0≢0 ------------------------------------------------------------------------ -- Properties of _*_ @@ -923,12 +923,12 @@ private 2*ₙ2*ₙ = (2 ℕ.*_) (2 ℕ.*_) toℕ-homo-* : x y toℕ (x * y) toℕ x ℕ.* toℕ y -toℕ-homo-* x y = aux x y (size x ℕ.+ size y) ℕ.≤-refl +toℕ-homo-* x y = aux x y (size x ℕ.+ size y) ℕ.≤-refl where aux : (x y : ℕᵇ) (cnt : ) (size x ℕ.+ size y ℕ.≤ cnt) toℕ (x * y) toℕ x ℕ.* toℕ y aux zero _ _ _ = refl - aux 2[1+ x ] zero _ _ = sym (ℕ.*-zeroʳ (toℕ x ℕ.+ (ℕ.suc (toℕ x ℕ.+ 0)))) - aux 1+[2 x ] zero _ _ = sym (ℕ.*-zeroʳ (toℕ x ℕ.+ (toℕ x ℕ.+ 0))) + aux 2[1+ x ] zero _ _ = sym (ℕ.*-zeroʳ (toℕ x ℕ.+ (ℕ.suc (toℕ x ℕ.+ 0)))) + aux 1+[2 x ] zero _ _ = sym (ℕ.*-zeroʳ (toℕ x ℕ.+ (toℕ x ℕ.+ 0))) aux 2[1+ x ] 2[1+ y ] (ℕ.suc cnt) (s≤s |x|+1+|y|≤cnt) = begin toℕ (2[1+ x ] * 2[1+ y ]) ≡⟨⟩ toℕ (double 2[1+ (x + (y + xy)) ]) ≡⟨ toℕ-double 2[1+ (x + (y + xy)) ] @@ -945,7 +945,7 @@ where open ≡-Reasoning; m = toℕ x; n = toℕ y; xy = x * y - |x|+|y|≤cnt = ℕ.≤-trans (ℕ.+-monoʳ-≤ (size x) (ℕ.n≤1+n (size y))) |x|+1+|y|≤cnt + |x|+|y|≤cnt = ℕ.≤-trans (ℕ.+-monoʳ-≤ (size x) (ℕ.n≤1+n (size y))) |x|+1+|y|≤cnt aux 2[1+ x ] 1+[2 y ] (ℕ.suc cnt) (s≤s |x|+1+|y|≤cnt) = begin toℕ (2[1+ x ] * 1+[2 y ]) ≡⟨⟩ @@ -964,7 +964,7 @@ open ≡-Reasoning; m = toℕ x; n = toℕ y; 1+m = ℕ.suc m; 2[1+m] = 2 ℕ.* (ℕ.suc m) eq : size x ℕ.+ (ℕ.suc (size y)) size y ℕ.+ (ℕ.suc (size x)) - eq = ℕ-+-semigroupProperties.x∙yz≈z∙yx (size x) 1 _ + eq = ℕ-+-semigroupProperties.x∙yz≈z∙yx (size x) 1 _ |y|+1+|x|≤cnt = subst (ℕ._≤ cnt) eq |x|+1+|y|≤cnt @@ -993,13 +993,13 @@ ℕ.suc (2 ℕ.* (toℕ (x + y * 1+2x))) ≡⟨ cong (ℕ.suc (2 ℕ.*_)) (toℕ-homo-+ x (y * 1+2x)) ℕ.suc (2 ℕ.* (m ℕ.+ (toℕ (y * 1+2x)))) ≡⟨ cong (ℕ.suc (2 ℕ.*_) (m ℕ.+_)) (aux y 1+2x cnt |y|+1+|x|≤cnt) - ℕ.suc (2 ℕ.* (m ℕ.+ (n ℕ.* [1+2x]′))) ≡⟨ cong ℕ.suc $ ℕ.*-distribˡ-+ 2 m (n ℕ.* [1+2x]′) - ℕ.suc (2m ℕ.+ (2 ℕ.* (n ℕ.* [1+2x]′))) ≡⟨ cong (ℕ.suc (2m ℕ.+_)) (sym (ℕ.*-assoc 2 n _)) + ℕ.suc (2 ℕ.* (m ℕ.+ (n ℕ.* [1+2x]′))) ≡⟨ cong ℕ.suc $ ℕ.*-distribˡ-+ 2 m (n ℕ.* [1+2x]′) + ℕ.suc (2m ℕ.+ (2 ℕ.* (n ℕ.* [1+2x]′))) ≡⟨ cong (ℕ.suc (2m ℕ.+_)) (sym (ℕ.*-assoc 2 n _)) (ℕ.suc 2m) ℕ.+ 2n ℕ.* [1+2x]′ ≡⟨⟩ [1+2x]′ ℕ.+ 2n ℕ.* [1+2x]′ ≡⟨ cong (ℕ._+ (2n ℕ.* [1+2x]′)) $ - sym (ℕ.*-identityˡ [1+2x]′) - 1 ℕ.* [1+2x]′ ℕ.+ 2n ℕ.* [1+2x]′ ≡⟨ sym (ℕ.*-distribʳ-+ [1+2x]′ 1 2n) - (ℕ.suc 2n) ℕ.* [1+2x]′ ≡⟨ ℕ.*-comm (ℕ.suc 2n) [1+2x]′ + sym (ℕ.*-identityˡ [1+2x]′) + 1 ℕ.* [1+2x]′ ℕ.+ 2n ℕ.* [1+2x]′ ≡⟨ sym (ℕ.*-distribʳ-+ [1+2x]′ 1 2n) + (ℕ.suc 2n) ℕ.* [1+2x]′ ≡⟨ ℕ.*-comm (ℕ.suc 2n) [1+2x]′ toℕ 1+[2 x ] ℕ.* toℕ 1+[2 y ] where open ≡-Reasoning @@ -1007,7 +1007,7 @@ 1+2x = 1+[2 x ]; [1+2x]′ = toℕ 1+2x eq : size x ℕ.+ (ℕ.suc (size y)) size y ℕ.+ (ℕ.suc (size x)) - eq = ℕ-+-semigroupProperties.x∙yz≈z∙yx (size x) 1 _ + eq = ℕ-+-semigroupProperties.x∙yz≈z∙yx (size x) 1 _ |y|+1+|x|≤cnt = subst (ℕ._≤ cnt) eq |x|+1+|y|≤cnt @@ -1051,13 +1051,13 @@ -- by `toℕ`/`fromℕ`. *-assoc : Associative _*_ -*-assoc = *-Monomorphism.assoc ℕ.*-isMagma ℕ.*-assoc +*-assoc = *-Monomorphism.assoc ℕ.*-isMagma ℕ.*-assoc *-comm : Commutative _*_ -*-comm = *-Monomorphism.comm ℕ.*-isMagma ℕ.*-comm +*-comm = *-Monomorphism.comm ℕ.*-isMagma ℕ.*-comm *-identityˡ : LeftIdentity 1ᵇ _*_ -*-identityˡ = *-Monomorphism.identityˡ ℕ.*-isMagma ℕ.*-identityˡ +*-identityˡ = *-Monomorphism.identityˡ ℕ.*-isMagma ℕ.*-identityˡ *-identityʳ : RightIdentity 1ᵇ _*_ *-identityʳ x = trans (*-comm x 1ᵇ) (*-identityˡ x) @@ -1081,7 +1081,7 @@ a * (b + c) ≡⟨ sym (fromℕ-toℕ (a * (b + c))) fromℕ (toℕ (a * (b + c))) ≡⟨ cong fromℕ (toℕ-homo-* a (b + c)) fromℕ (k ℕ.* (toℕ (b + c))) ≡⟨ cong (fromℕ (k ℕ.*_)) (toℕ-homo-+ b c) - fromℕ (k ℕ.* (m ℕ.+ n)) ≡⟨ cong fromℕ (ℕ.*-distribˡ-+ k m n) + fromℕ (k ℕ.* (m ℕ.+ n)) ≡⟨ cong fromℕ (ℕ.*-distribˡ-+ k m n) fromℕ (k ℕ.* m ℕ.+ k ℕ.* n) ≡⟨ cong fromℕ $ sym $ cong₂ ℕ._+_ (toℕ-homo-* a b) (toℕ-homo-* a c) fromℕ (toℕ (a * b) ℕ.+ toℕ (a * c)) ≡⟨ cong fromℕ (sym (toℕ-homo-+ (a * b) (a * c))) @@ -1102,33 +1102,33 @@ *-isMagma = isMagma _*_ *-isSemigroup : IsSemigroup _*_ -*-isSemigroup = *-Monomorphism.isSemigroup ℕ.*-isSemigroup +*-isSemigroup = *-Monomorphism.isSemigroup ℕ.*-isSemigroup *-1-isMonoid : IsMonoid _*_ 1ᵇ -*-1-isMonoid = *-Monomorphism.isMonoid ℕ.*-1-isMonoid +*-1-isMonoid = *-Monomorphism.isMonoid ℕ.*-1-isMonoid *-1-isCommutativeMonoid : IsCommutativeMonoid _*_ 1ᵇ -*-1-isCommutativeMonoid = *-Monomorphism.isCommutativeMonoid ℕ.*-1-isCommutativeMonoid +*-1-isCommutativeMonoid = *-Monomorphism.isCommutativeMonoid ℕ.*-1-isCommutativeMonoid -+-*-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _+_ _*_ zero 1ᵇ ++-*-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _+_ _*_ zero 1ᵇ +-*-isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-0-isCommutativeMonoid - ; *-cong = cong₂ _*_ - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = *-distrib-+ + { +-isCommutativeMonoid = +-0-isCommutativeMonoid + ; *-cong = cong₂ _*_ + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = *-distrib-+ } -+-*-isSemiring : IsSemiring _+_ _*_ zero 1ᵇ ++-*-isSemiring : IsSemiring _+_ _*_ zero 1ᵇ +-*-isSemiring = record - { isSemiringWithoutAnnihilatingZero = +-*-isSemiringWithoutAnnihilatingZero - ; zero = *-zero + { isSemiringWithoutAnnihilatingZero = +-*-isSemiringWithoutAnnihilatingZero + ; zero = *-zero } -+-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ zero 1ᵇ ++-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ zero 1ᵇ +-*-isCommutativeSemiring = record - { isSemiring = +-*-isSemiring - ; *-comm = *-comm + { isSemiring = +-*-isSemiring + ; *-comm = *-comm } ------------------------------------------------------------------------ @@ -1170,10 +1170,10 @@ *-mono-≤ : _*_ Preserves₂ _≤_ _≤_ _≤_ *-mono-≤ {x} {u} {y} {v} x≤u y≤v = toℕ-cancel-≤ (begin toℕ (x * y) ≡⟨ toℕ-homo-* x y - toℕ x ℕ.* toℕ y ≤⟨ ℕ.*-mono-≤ (toℕ-mono-≤ x≤u) (toℕ-mono-≤ y≤v) + toℕ x ℕ.* toℕ y ≤⟨ ℕ.*-mono-≤ (toℕ-mono-≤ x≤u) (toℕ-mono-≤ y≤v) toℕ u ℕ.* toℕ v ≡⟨ sym (toℕ-homo-* u v) toℕ (u * v) ) - where open ℕ.≤-Reasoning + where open ℕ.≤-Reasoning *-monoʳ-≤ : x (x *_) Preserves _≤_ _≤_ *-monoʳ-≤ x y≤y′ = *-mono-≤ (≤-refl {x}) y≤y′ @@ -1184,10 +1184,10 @@ *-mono-< : _*_ Preserves₂ _<_ _<_ _<_ *-mono-< {x} {u} {y} {v} x<u y<v = toℕ-cancel-< (begin-strict toℕ (x * y) ≡⟨ toℕ-homo-* x y - toℕ x ℕ.* toℕ y <⟨ ℕ.*-mono-< (toℕ-mono-< x<u) (toℕ-mono-< y<v) + toℕ x ℕ.* toℕ y <⟨ ℕ.*-mono-< (toℕ-mono-< x<u) (toℕ-mono-< y<v) toℕ u ℕ.* toℕ v ≡⟨ sym (toℕ-homo-* u v) toℕ (u * v) ) - where open ℕ.≤-Reasoning + where open ℕ.≤-Reasoning *-monoʳ-< : x ((1ᵇ + x) *_) Preserves _<_ _<_ *-monoʳ-< x {y} {z} y<z = begin-strict @@ -1303,13 +1303,13 @@ double-cancel-≤ {x} {y} 2x≤2y with <-cmp x y ... | tri< x<y _ _ = <⇒≤ x<y ... | tri≈ _ x≡y _ = ≤-reflexive x≡y -... | tri> _ _ x>y = contradiction 2x≤2y (<⇒≱ (double-mono-< x>y)) +... | tri> _ _ x>y = contradiction 2x≤2y (<⇒≱ (double-mono-< x>y)) double-cancel-< : {x y} double x < double y x < y double-cancel-< {x} {y} 2x<2y with <-cmp x y ... | tri< x<y _ _ = x<y -... | tri≈ _ refl _ = contradiction 2x<2y (<-irrefl refl) -... | tri> _ _ x>y = contradiction (double-mono-< x>y) (<⇒≯ 2x<2y) +... | tri≈ _ refl _ = contradiction 2x<2y (<-irrefl refl) +... | tri> _ _ x>y = contradiction (double-mono-< x>y) (<⇒≯ 2x<2y) x<double[x] : x x zero x < double x x<double[x] x x≢0 = begin-strict @@ -1345,8 +1345,8 @@ suc-injective : Injective _≡_ _≡_ suc suc-injective {zero} {zero} p = refl -suc-injective {zero} {2[1+ y ]} p = contradiction 1+[2 p ]-injective (suc≢0 sym) -suc-injective {2[1+ x ]} {zero} p = contradiction 1+[2 p ]-injective suc≢0 +suc-injective {zero} {2[1+ y ]} p = contradiction 1+[2 p ]-injective (suc≢0 sym) +suc-injective {2[1+ x ]} {zero} p = contradiction 1+[2 p ]-injective suc≢0 suc-injective {2[1+ x ]} {2[1+ y ]} p = cong 2[1+_] (suc-injective 1+[2 p ]-injective) suc-injective {1+[2 x ]} {1+[2 y ]} refl = refl @@ -1460,7 +1460,7 @@ pred-suc 1+[2 x ] = refl suc-pred : x zero suc (pred x) x -suc-pred {zero} 0≢0 = contradiction refl 0≢0 +suc-pred {zero} 0≢0 = contradiction refl 0≢0 suc-pred {2[1+ _ ]} _ = refl suc-pred {1+[2 x ]} _ = sym (1+[2_]-suc-double x) @@ -1468,7 +1468,7 @@ pred-mono-≤ {x} {y} x≤y = begin pred x ≡⟨ cong pred (sym (fromℕ-toℕ x)) pred (fromℕ m) ≡⟨ sym (fromℕ-pred m) - fromℕ (ℕ.pred m) ≤⟨ fromℕ-mono-≤ (ℕ.pred-mono-≤ (toℕ-mono-≤ x≤y)) + fromℕ (ℕ.pred m) ≤⟨ fromℕ-mono-≤ (ℕ.pred-mono-≤ (toℕ-mono-≤ x≤y)) fromℕ (ℕ.pred n) ≡⟨ fromℕ-pred n pred (fromℕ n) ≡⟨ cong pred (fromℕ-toℕ y) pred y @@ -1486,7 +1486,7 @@ pred[x]+y≡x+pred[y] {x} {y} x≢0 y≢0 = begin px + y ≡⟨ cong (px +_) (sym (suc-pred y≢0)) px + suc py ≡⟨ cong (px +_) (suc≗1+ py) - px + (1ᵇ + py) ≡⟨ Bin+CSemigroup.x∙yz≈yx∙z px 1ᵇ py + px + (1ᵇ + py) ≡⟨ Bin+CSemigroup.x∙yz≈yx∙z px 1ᵇ py (1ᵇ + px) + py ≡⟨ cong (_+ py) (sym (suc≗1+ px)) (suc px) + py ≡⟨ cong (_+ py) (suc-pred x≢0) x + py diff --git a/v2.3/Data.Nat.Binary.Subtraction.html b/v2.3/Data.Nat.Binary.Subtraction.html index 5e95a02545..1f7d7db0e5 100644 --- a/v2.3/Data.Nat.Binary.Subtraction.html +++ b/v2.3/Data.Nat.Binary.Subtraction.html @@ -33,11 +33,11 @@ open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning) open import Relation.Nullary using (Dec; yes; no; does) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Algebra.Definitions {A = ℕᵇ} _≡_ open import Algebra.Properties.CommutativeSemigroup +-commutativeSemigroup - using (xy∙z≈y∙xz; x∙yz≈y∙xz) + using (xy∙z≈y∙xz; x∙yz≈y∙xz) open import Algebra.Solver.CommutativeMonoid +-0-commutativeMonoid private @@ -81,168 +81,168 @@ toℕ-homo-∸ 2[1+ x ] 2[1+ y ] = begin toℕ (double (x y)) ≡⟨ toℕ-double (x y) 2 ℕ.* toℕ (x y) ≡⟨ cong (2 ℕ.*_) (toℕ-homo-∸ x y) - 2 ℕ.* (toℕ x ℕ.∸ toℕ y) ≡⟨ ℕ.*-distribˡ-∸ 2 (ℕ.suc (toℕ x)) (ℕ.suc (toℕ y)) + 2 ℕ.* (toℕ x ℕ.∸ toℕ y) ≡⟨ ℕ.*-distribˡ-∸ 2 (ℕ.suc (toℕ x)) (ℕ.suc (toℕ y)) toℕ 2[1+ x ] ℕ.∸ toℕ 2[1+ y ] where open ≡-Reasoning toℕ-homo-∸ 2[1+ x ] 1+[2 y ] with x <? y -... | yes x<y = sym (ℕ.m≤n⇒m∸n≡0 (toℕ-mono-≤ (inj₁ (even<odd x<y)))) +... | yes x<y = sym (ℕ.m≤n⇒m∸n≡0 (toℕ-mono-≤ (inj₁ (even<odd x<y)))) ... | no x≮y = begin ℕ.suc (2 ℕ.* toℕ (x y)) ≡⟨ cong (ℕ.suc (2 ℕ.*_)) (toℕ-homo-∸ x y) - ℕ.suc (2 ℕ.* (toℕ x ℕ.∸ toℕ y)) ≡⟨ cong ℕ.suc (ℕ.*-distribˡ-∸ 2 (toℕ x) (toℕ y)) - ℕ.suc (2 ℕ.* toℕ x ℕ.∸ 2 ℕ.* toℕ y) ≡⟨ sym (ℕ.∸-suc (ℕ.*-monoʳ-≤ 2 (toℕ-mono-≤ (≮⇒≥ x≮y)))) - ℕ.suc (2 ℕ.* toℕ x) ℕ.∸ 2 ℕ.* toℕ y ≡⟨ sym (cong (ℕ._∸ 2 ℕ.* toℕ y) (ℕ.+-suc (toℕ x) (1 ℕ.* toℕ x))) - 2 ℕ.* (ℕ.suc (toℕ x)) ℕ.∸ ℕ.suc (2 ℕ.* toℕ y) - where open ≡-Reasoning -toℕ-homo-∸ 1+[2 x ] zero = refl -toℕ-homo-∸ 1+[2 x ] 2[1+ y ] with x ≤? y -... | yes x≤y = sym (ℕ.m≤n⇒m∸n≡0 (toℕ-mono-≤ (inj₁ (odd<even x≤y)))) -... | no _ = begin - toℕ (pred (double (x y))) ≡⟨ toℕ-pred (double (x y)) - ℕ.pred (toℕ (double (x y))) ≡⟨ cong ℕ.pred (toℕ-double (x y)) - ℕ.pred (2 ℕ.* toℕ (x y)) ≡⟨ cong (ℕ.pred (2 ℕ.*_)) (toℕ-homo-∸ x y) - ℕ.pred (2 ℕ.* (toℕ x ℕ.∸ toℕ y)) ≡⟨ cong ℕ.pred (ℕ.*-distribˡ-∸ 2 (toℕ x) (toℕ y)) - ℕ.pred (2 ℕ.* toℕ x ℕ.∸ 2 ℕ.* toℕ y) ≡⟨ ℕ.pred[m∸n]≡m∸[1+n] (2 ℕ.* toℕ x) (2 ℕ.* toℕ y) - 2 ℕ.* toℕ x ℕ.∸ ℕ.suc (2 ℕ.* toℕ y) ≡⟨ sym (cong (2 ℕ.* toℕ x ℕ.∸_) (ℕ.+-suc (toℕ y) (1 ℕ.* toℕ y))) - ℕ.suc (2 ℕ.* toℕ x) ℕ.∸ 2 ℕ.* (ℕ.suc (toℕ y)) - where open ≡-Reasoning -toℕ-homo-∸ 1+[2 x ] 1+[2 y ] = begin - toℕ (double (x y)) ≡⟨ toℕ-double (x y) - 2 ℕ.* toℕ (x y) ≡⟨ cong (2 ℕ.*_) (toℕ-homo-∸ x y) - 2 ℕ.* (toℕ x ℕ.∸ toℕ y) ≡⟨ ℕ.*-distribˡ-∸ 2 (toℕ x) (toℕ y) - 2 ℕ.* toℕ x ℕ.∸ 2 ℕ.* toℕ y - where open ≡-Reasoning - -fromℕ-homo-∸ : m n fromℕ (m ℕ.∸ n) (fromℕ m) (fromℕ n) -fromℕ-homo-∸ = homomorphic₂-inv ∸-magma ℕ.∸-magma - (cong fromℕ) toℕ-inverseᵇ toℕ-homo-∸ - ------------------------------------------------------------------------- --- Properties of _∸_ and _≤_/_<_ - -even∸odd-for≥ : x y 2[1+ x ] 1+[2 y ] 1+[2 (x y) ] -even∸odd-for≥ {x} {y} x≥y with x <? y -... | no _ = refl -... | yes x<y = contradiction x≥y (<⇒≱ x<y) - -odd∸even-for> : x > y 1+[2 x ] 2[1+ y ] pred (double (x y)) -odd∸even-for> {x} {y} x>y with x ≤? y -... | no _ = refl -... | yes x≤y = contradiction x>y (≤⇒≯ x≤y) - -x≤y⇒x∸y≡0 : x y x y 0ᵇ -x≤y⇒x∸y≡0 {x} {y} = toℕ-injective trans (toℕ-homo-∸ x y) ℕ.m≤n⇒m∸n≡0 toℕ-mono-≤ - -x∸y≡0⇒x≤y : x y 0ᵇ x y -x∸y≡0⇒x≤y {x} {y} = toℕ-cancel-≤ ℕ.m∸n≡0⇒m≤n trans (sym (toℕ-homo-∸ x y)) cong toℕ - -x<y⇒y∸x>0 : x < y y x > 0ᵇ -x<y⇒y∸x>0 {x} {y} = toℕ-cancel-< subst (ℕ._> 0) (sym (toℕ-homo-∸ y x)) ℕ.m<n⇒0<n∸m toℕ-mono-< - ------------------------------------------------------------------------- --- Properties of _∸_ and _+_ - -[x∸y]+y≡x : x y (x y) + y x -[x∸y]+y≡x {x} {y} x≥y = toℕ-injective (begin - toℕ (x y + y) ≡⟨ toℕ-homo-+ (x y) y - toℕ (x y) ℕ.+ toℕ y ≡⟨ cong (ℕ._+ toℕ y) (toℕ-homo-∸ x y) - (toℕ x ℕ.∸ toℕ y) ℕ.+ toℕ y ≡⟨ ℕ.m∸n+n≡m (toℕ-mono-≤ x≥y) - toℕ x ) - where open ≡-Reasoning - -x+y∸y≡x : x y (x + y) y x -x+y∸y≡x x y = +-cancelʳ-≡ _ _ x ([x∸y]+y≡x (x≤y+x y x)) - -[x+y]∸x≡y : x y (x + y) x y -[x+y]∸x≡y x y = trans (cong (_∸ x) (+-comm x y)) (x+y∸y≡x y x) - -x+[y∸x]≡y : x y x + (y x) y -x+[y∸x]≡y {x} {y} x≤y = begin-equality - x + (y x) ≡⟨ +-comm x _ - (y x) + x ≡⟨ [x∸y]+y≡x x≤y - y - where open ≤-Reasoning - -∸-+-assoc : x y z (x y) z x (y + z) -∸-+-assoc x y z = toℕ-injective $ begin - toℕ ((x y) z) ≡⟨ toℕ-homo-∸ (x y) z - toℕ (x y) ℕ.∸ n ≡⟨ cong (ℕ._∸ n) (toℕ-homo-∸ x y) - (k ℕ.∸ m) ℕ.∸ n ≡⟨ ℕ.∸-+-assoc k m n - k ℕ.∸ (m ℕ.+ n) ≡⟨ cong (k ℕ.∸_) (sym (toℕ-homo-+ y z)) - k ℕ.∸ (toℕ (y + z)) ≡⟨ sym (toℕ-homo-∸ x (y + z)) - toℕ (x (y + z)) - where open ≡-Reasoning; k = toℕ x; m = toℕ y; n = toℕ z - -+-∸-assoc : x {y z} z y (x + y) z x + (y z) -+-∸-assoc x {y} {z} z≤y = toℕ-injective $ begin - toℕ ((x + y) z) ≡⟨ toℕ-homo-∸ (x + y) z - (toℕ (x + y)) ℕ.∸ n ≡⟨ cong (ℕ._∸ n) (toℕ-homo-+ x y) - (k ℕ.+ m) ℕ.∸ n ≡⟨ ℕ.+-∸-assoc k n≤m - k ℕ.+ (m ℕ.∸ n) ≡⟨ cong (k ℕ.+_) (sym (toℕ-homo-∸ y z)) - k ℕ.+ toℕ (y z) ≡⟨ sym (toℕ-homo-+ x (y z)) - toℕ (x + (y z)) - where - open ≡-Reasoning; k = toℕ x; m = toℕ y; n = toℕ z; n≤m = toℕ-mono-≤ z≤y - -x+y∸x+z≡y∸z : x y z (x + y) (x + z) y z -x+y∸x+z≡y∸z x y z = begin-equality - (x + y) (x + z) ≡⟨ sym (∸-+-assoc (x + y) x z) - ((x + y) x) z ≡⟨ cong (_∸ z) ([x+y]∸x≡y x y) - y z - where open ≤-Reasoning - -suc[x]∸suc[y] : x y suc x suc y x y -suc[x]∸suc[y] x y = begin-equality - suc x suc y ≡⟨ cong₂ _∸_ (suc≗1+ x) (suc≗1+ y) - (1ᵇ + x) (1ᵇ + y) ≡⟨ x+y∸x+z≡y∸z 1ᵇ x y - x y - where open ≤-Reasoning - -∸-mono-≤ : _∸_ Preserves₂ _≤_ _≥_ _≤_ -∸-mono-≤ {x} {y} {u} {v} x≤y v≤u = toℕ-cancel-≤ (begin - toℕ (x u) ≡⟨ toℕ-homo-∸ x u - toℕ x ℕ.∸ toℕ u ≤⟨ ℕ.∸-mono (toℕ-mono-≤ x≤y) (toℕ-mono-≤ v≤u) - toℕ y ℕ.∸ toℕ v ≡⟨ sym (toℕ-homo-∸ y v) - toℕ (y v) ) - where open ℕ.≤-Reasoning - -∸-monoˡ-≤ : (x : ℕᵇ) (_∸ x) Preserves _≤_ _≤_ -∸-monoˡ-≤ x y≤z = ∸-mono-≤ y≤z (≤-refl {x}) - -∸-monoʳ-≤ : (x : ℕᵇ) (x ∸_) Preserves _≥_ _≤_ -∸-monoʳ-≤ x y≥z = ∸-mono-≤ (≤-refl {x}) y≥z - -x∸y≤x : x y x y x -x∸y≤x x y = begin - x y ≤⟨ ∸-monoʳ-≤ x (0≤x y) - x 0ᵇ ≡⟨ x∸0≡x x - x - where open ≤-Reasoning - -x∸y<x : {x y : ℕᵇ} x 0ᵇ y 0ᵇ x y < x -x∸y<x {x} {y} x≢0 y≢0 = begin-strict - x y ≡⟨ cong₂ _∸_ (sym (suc-pred x≢0)) (sym (suc-pred y≢0)) - suc px suc py ≡⟨ suc[x]∸suc[y] px py - px py ≤⟨ x∸y≤x px py - px <⟨ pred[x]<x x≢0 - x - where open ≤-Reasoning; px = pred x; py = pred y - ------------------------------------------------------------------------- --- Properties of _∸_ and _*_ - -*-distribˡ-∸ : _*_ DistributesOverˡ _∸_ -*-distribˡ-∸ x y z = toℕ-injective $ begin - toℕ (x * (y z)) ≡⟨ toℕ-homo-* x (y z) - k ℕ.* (toℕ (y z)) ≡⟨ cong (k ℕ.*_) (toℕ-homo-∸ y z) - k ℕ.* (m ℕ.∸ n) ≡⟨ ℕ.*-distribˡ-∸ k m n - (k ℕ.* m) ℕ.∸ (k ℕ.* n) ≡⟨ cong₂ ℕ._∸_ (sym (toℕ-homo-* x y)) (sym (toℕ-homo-* x z)) - toℕ (x * y) ℕ.∸ toℕ (x * z) ≡⟨ sym (toℕ-homo-∸ (x * y) (x * z)) - toℕ ((x * y) (x * z)) - where open ≡-Reasoning; k = toℕ x; m = toℕ y; n = toℕ z - -*-distribʳ-∸ : _*_ DistributesOverʳ _∸_ -*-distribʳ-∸ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-∸ - -*-distrib-∸ : _*_ DistributesOver _∸_ -*-distrib-∸ = *-distribˡ-∸ , *-distribʳ-∸ + ℕ.suc (2 ℕ.* (toℕ x ℕ.∸ toℕ y)) ≡⟨ cong ℕ.suc (ℕ.*-distribˡ-∸ 2 (toℕ x) (toℕ y)) + ℕ.suc (2 ℕ.* toℕ x ℕ.∸ 2 ℕ.* toℕ y) ≡⟨ sym (ℕ.+-∸-assoc 1 (ℕ.*-monoʳ-≤ 2 (toℕ-mono-≤ (≮⇒≥ x≮y)))) + ℕ.suc (2 ℕ.* toℕ x) ℕ.∸ 2 ℕ.* toℕ y ≡⟨ sym (cong (ℕ._∸ 2 ℕ.* toℕ y) (ℕ.+-suc (toℕ x) (1 ℕ.* toℕ x))) + 2 ℕ.* (ℕ.suc (toℕ x)) ℕ.∸ ℕ.suc (2 ℕ.* toℕ y) + where open ≡-Reasoning +toℕ-homo-∸ 1+[2 x ] zero = refl +toℕ-homo-∸ 1+[2 x ] 2[1+ y ] with x ≤? y +... | yes x≤y = sym (ℕ.m≤n⇒m∸n≡0 (toℕ-mono-≤ (inj₁ (odd<even x≤y)))) +... | no _ = begin + toℕ (pred (double (x y))) ≡⟨ toℕ-pred (double (x y)) + ℕ.pred (toℕ (double (x y))) ≡⟨ cong ℕ.pred (toℕ-double (x y)) + ℕ.pred (2 ℕ.* toℕ (x y)) ≡⟨ cong (ℕ.pred (2 ℕ.*_)) (toℕ-homo-∸ x y) + ℕ.pred (2 ℕ.* (toℕ x ℕ.∸ toℕ y)) ≡⟨ cong ℕ.pred (ℕ.*-distribˡ-∸ 2 (toℕ x) (toℕ y)) + ℕ.pred (2 ℕ.* toℕ x ℕ.∸ 2 ℕ.* toℕ y) ≡⟨ ℕ.pred[m∸n]≡m∸[1+n] (2 ℕ.* toℕ x) (2 ℕ.* toℕ y) + 2 ℕ.* toℕ x ℕ.∸ ℕ.suc (2 ℕ.* toℕ y) ≡⟨ sym (cong (2 ℕ.* toℕ x ℕ.∸_) (ℕ.+-suc (toℕ y) (1 ℕ.* toℕ y))) + ℕ.suc (2 ℕ.* toℕ x) ℕ.∸ 2 ℕ.* (ℕ.suc (toℕ y)) + where open ≡-Reasoning +toℕ-homo-∸ 1+[2 x ] 1+[2 y ] = begin + toℕ (double (x y)) ≡⟨ toℕ-double (x y) + 2 ℕ.* toℕ (x y) ≡⟨ cong (2 ℕ.*_) (toℕ-homo-∸ x y) + 2 ℕ.* (toℕ x ℕ.∸ toℕ y) ≡⟨ ℕ.*-distribˡ-∸ 2 (toℕ x) (toℕ y) + 2 ℕ.* toℕ x ℕ.∸ 2 ℕ.* toℕ y + where open ≡-Reasoning + +fromℕ-homo-∸ : m n fromℕ (m ℕ.∸ n) (fromℕ m) (fromℕ n) +fromℕ-homo-∸ = homomorphic₂-inv ∸-magma ℕ.∸-magma + (cong fromℕ) toℕ-inverseᵇ toℕ-homo-∸ + +------------------------------------------------------------------------ +-- Properties of _∸_ and _≤_/_<_ + +even∸odd-for≥ : x y 2[1+ x ] 1+[2 y ] 1+[2 (x y) ] +even∸odd-for≥ {x} {y} x≥y with x <? y +... | no _ = refl +... | yes x<y = contradiction x≥y (<⇒≱ x<y) + +odd∸even-for> : x > y 1+[2 x ] 2[1+ y ] pred (double (x y)) +odd∸even-for> {x} {y} x>y with x ≤? y +... | no _ = refl +... | yes x≤y = contradiction x>y (≤⇒≯ x≤y) + +x≤y⇒x∸y≡0 : x y x y 0ᵇ +x≤y⇒x∸y≡0 {x} {y} = toℕ-injective trans (toℕ-homo-∸ x y) ℕ.m≤n⇒m∸n≡0 toℕ-mono-≤ + +x∸y≡0⇒x≤y : x y 0ᵇ x y +x∸y≡0⇒x≤y {x} {y} = toℕ-cancel-≤ ℕ.m∸n≡0⇒m≤n trans (sym (toℕ-homo-∸ x y)) cong toℕ + +x<y⇒y∸x>0 : x < y y x > 0ᵇ +x<y⇒y∸x>0 {x} {y} = toℕ-cancel-< subst (ℕ._> 0) (sym (toℕ-homo-∸ y x)) ℕ.m<n⇒0<n∸m toℕ-mono-< + +------------------------------------------------------------------------ +-- Properties of _∸_ and _+_ + +[x∸y]+y≡x : x y (x y) + y x +[x∸y]+y≡x {x} {y} x≥y = toℕ-injective (begin + toℕ (x y + y) ≡⟨ toℕ-homo-+ (x y) y + toℕ (x y) ℕ.+ toℕ y ≡⟨ cong (ℕ._+ toℕ y) (toℕ-homo-∸ x y) + (toℕ x ℕ.∸ toℕ y) ℕ.+ toℕ y ≡⟨ ℕ.m∸n+n≡m (toℕ-mono-≤ x≥y) + toℕ x ) + where open ≡-Reasoning + +x+y∸y≡x : x y (x + y) y x +x+y∸y≡x x y = +-cancelʳ-≡ _ _ x ([x∸y]+y≡x (x≤y+x y x)) + +[x+y]∸x≡y : x y (x + y) x y +[x+y]∸x≡y x y = trans (cong (_∸ x) (+-comm x y)) (x+y∸y≡x y x) + +x+[y∸x]≡y : x y x + (y x) y +x+[y∸x]≡y {x} {y} x≤y = begin-equality + x + (y x) ≡⟨ +-comm x _ + (y x) + x ≡⟨ [x∸y]+y≡x x≤y + y + where open ≤-Reasoning + +∸-+-assoc : x y z (x y) z x (y + z) +∸-+-assoc x y z = toℕ-injective $ begin + toℕ ((x y) z) ≡⟨ toℕ-homo-∸ (x y) z + toℕ (x y) ℕ.∸ n ≡⟨ cong (ℕ._∸ n) (toℕ-homo-∸ x y) + (k ℕ.∸ m) ℕ.∸ n ≡⟨ ℕ.∸-+-assoc k m n + k ℕ.∸ (m ℕ.+ n) ≡⟨ cong (k ℕ.∸_) (sym (toℕ-homo-+ y z)) + k ℕ.∸ (toℕ (y + z)) ≡⟨ sym (toℕ-homo-∸ x (y + z)) + toℕ (x (y + z)) + where open ≡-Reasoning; k = toℕ x; m = toℕ y; n = toℕ z + ++-∸-assoc : x {y z} z y (x + y) z x + (y z) ++-∸-assoc x {y} {z} z≤y = toℕ-injective $ begin + toℕ ((x + y) z) ≡⟨ toℕ-homo-∸ (x + y) z + (toℕ (x + y)) ℕ.∸ n ≡⟨ cong (ℕ._∸ n) (toℕ-homo-+ x y) + (k ℕ.+ m) ℕ.∸ n ≡⟨ ℕ.+-∸-assoc k n≤m + k ℕ.+ (m ℕ.∸ n) ≡⟨ cong (k ℕ.+_) (sym (toℕ-homo-∸ y z)) + k ℕ.+ toℕ (y z) ≡⟨ sym (toℕ-homo-+ x (y z)) + toℕ (x + (y z)) + where + open ≡-Reasoning; k = toℕ x; m = toℕ y; n = toℕ z; n≤m = toℕ-mono-≤ z≤y + +x+y∸x+z≡y∸z : x y z (x + y) (x + z) y z +x+y∸x+z≡y∸z x y z = begin-equality + (x + y) (x + z) ≡⟨ sym (∸-+-assoc (x + y) x z) + ((x + y) x) z ≡⟨ cong (_∸ z) ([x+y]∸x≡y x y) + y z + where open ≤-Reasoning + +suc[x]∸suc[y] : x y suc x suc y x y +suc[x]∸suc[y] x y = begin-equality + suc x suc y ≡⟨ cong₂ _∸_ (suc≗1+ x) (suc≗1+ y) + (1ᵇ + x) (1ᵇ + y) ≡⟨ x+y∸x+z≡y∸z 1ᵇ x y + x y + where open ≤-Reasoning + +∸-mono-≤ : _∸_ Preserves₂ _≤_ _≥_ _≤_ +∸-mono-≤ {x} {y} {u} {v} x≤y v≤u = toℕ-cancel-≤ (begin + toℕ (x u) ≡⟨ toℕ-homo-∸ x u + toℕ x ℕ.∸ toℕ u ≤⟨ ℕ.∸-mono (toℕ-mono-≤ x≤y) (toℕ-mono-≤ v≤u) + toℕ y ℕ.∸ toℕ v ≡⟨ sym (toℕ-homo-∸ y v) + toℕ (y v) ) + where open ℕ.≤-Reasoning + +∸-monoˡ-≤ : (x : ℕᵇ) (_∸ x) Preserves _≤_ _≤_ +∸-monoˡ-≤ x y≤z = ∸-mono-≤ y≤z (≤-refl {x}) + +∸-monoʳ-≤ : (x : ℕᵇ) (x ∸_) Preserves _≥_ _≤_ +∸-monoʳ-≤ x y≥z = ∸-mono-≤ (≤-refl {x}) y≥z + +x∸y≤x : x y x y x +x∸y≤x x y = begin + x y ≤⟨ ∸-monoʳ-≤ x (0≤x y) + x 0ᵇ ≡⟨ x∸0≡x x + x + where open ≤-Reasoning + +x∸y<x : {x y : ℕᵇ} x 0ᵇ y 0ᵇ x y < x +x∸y<x {x} {y} x≢0 y≢0 = begin-strict + x y ≡⟨ cong₂ _∸_ (sym (suc-pred x≢0)) (sym (suc-pred y≢0)) + suc px suc py ≡⟨ suc[x]∸suc[y] px py + px py ≤⟨ x∸y≤x px py + px <⟨ pred[x]<x x≢0 + x + where open ≤-Reasoning; px = pred x; py = pred y + +------------------------------------------------------------------------ +-- Properties of _∸_ and _*_ + +*-distribˡ-∸ : _*_ DistributesOverˡ _∸_ +*-distribˡ-∸ x y z = toℕ-injective $ begin + toℕ (x * (y z)) ≡⟨ toℕ-homo-* x (y z) + k ℕ.* (toℕ (y z)) ≡⟨ cong (k ℕ.*_) (toℕ-homo-∸ y z) + k ℕ.* (m ℕ.∸ n) ≡⟨ ℕ.*-distribˡ-∸ k m n + (k ℕ.* m) ℕ.∸ (k ℕ.* n) ≡⟨ cong₂ ℕ._∸_ (sym (toℕ-homo-* x y)) (sym (toℕ-homo-* x z)) + toℕ (x * y) ℕ.∸ toℕ (x * z) ≡⟨ sym (toℕ-homo-∸ (x * y) (x * z)) + toℕ ((x * y) (x * z)) + where open ≡-Reasoning; k = toℕ x; m = toℕ y; n = toℕ z + +*-distribʳ-∸ : _*_ DistributesOverʳ _∸_ +*-distribʳ-∸ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-∸ + +*-distrib-∸ : _*_ DistributesOver _∸_ +*-distrib-∸ = *-distribˡ-∸ , *-distribʳ-∸ \ No newline at end of file diff --git a/v2.3/Data.Nat.Combinatorics.Base.html b/v2.3/Data.Nat.Combinatorics.Base.html index f1c6924308..d37a45e927 100644 --- a/v2.3/Data.Nat.Combinatorics.Base.html +++ b/v2.3/Data.Nat.Combinatorics.Base.html @@ -11,7 +11,7 @@ open import Data.Bool.Base using (if_then_else_) open import Data.Nat.Base -open import Data.Nat.Properties using (_!≢0) +open import Data.Nat.Properties using (_!≢0) -- NOTE: These operators are not implemented as efficiently as they -- could be. See the following link for more details. @@ -53,7 +53,7 @@ _C′_ : n C′ k = (n P′ k) / k ! - where instance _ = k !≢0 + where instance _ = k !≢0 -- Main definition. Valid for all k. -- Deals with boundary case and exploits symmetry to improve performance. diff --git a/v2.3/Data.Nat.Combinatorics.Specification.html b/v2.3/Data.Nat.Combinatorics.Specification.html index c7686c7419..7c5c4536fc 100644 --- a/v2.3/Data.Nat.Combinatorics.Specification.html +++ b/v2.3/Data.Nat.Combinatorics.Specification.html @@ -22,37 +22,37 @@ open import Data.Nat.Combinatorics.Base using (_P′_; _P_; _C′_; _C_) open import Data.Sum.Base using (inj₁; inj₂) open import Relation.Nullary.Decidable using (yes; no; does) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.PropositionalEquality.Core using (_≡_; trans; _≢_; subst; refl; sym; cong; cong₂) -import Algebra.Properties.CommutativeSemigroup *-commutativeSemigroup as *-CS +import Algebra.Properties.CommutativeSemigroup *-commutativeSemigroup as *-CS ------------------------------------------------------------------------ -- Prelude private ≤ᵇ⇒≤′ : {m n} (m ≤ᵇ n) true m n - ≤ᵇ⇒≤′ {m} {n} eq = ≤ᵇ⇒≤ m n (subst T (sym eq) _) + ≤ᵇ⇒≤′ {m} {n} eq = ≤ᵇ⇒≤ m n (subst T (sym eq) _) ------------------------------------------------------------------------ -- Properties of _P′_ -nP′k≡n!/[n∸k]! : {n k} k n n P′ k (n ! / (n k) !) {{(n k) !≢0}} -nP′k≡n!/[n∸k]! {n} {zero} z≤n = sym (n/n≡1 (n !) {{n !≢0}}) +nP′k≡n!/[n∸k]! : {n k} k n n P′ k (n ! / (n k) !) {{(n k) !≢0}} +nP′k≡n!/[n∸k]! {n} {zero} z≤n = sym (n/n≡1 (n !) {{n !≢0}}) nP′k≡n!/[n∸k]! {n} {suc k} k<n = begin-equality - (n k) * (n P′ k) ≡⟨ cong ((n k) *_) (nP′k≡n!/[n∸k]! (<⇒≤ k<n)) - (n k) * (n ! / (n k) !) ≡⟨ *-/-assoc (n k) (m≤n⇒m!∣n! (m∸n≤m n k)) + (n k) * (n P′ k) ≡⟨ cong ((n k) *_) (nP′k≡n!/[n∸k]! (<⇒≤ k<n)) + (n k) * (n ! / (n k) !) ≡⟨ *-/-assoc (n k) (m≤n⇒m!∣n! (m∸n≤m n k)) (((n k) * n !) / (n k) !) ≡⟨ m*n/m!≡n/[m∸1]! (n k) (n !) - (n ! / (pred (n k) !)) ≡⟨ /-congʳ (cong _! (pred[m∸n]≡m∸[1+n] n k)) + (n ! / (pred (n k) !)) ≡⟨ /-congʳ (cong _! (pred[m∸n]≡m∸[1+n] n k)) (n ! / (n suc k) !) where - open ≤-Reasoning + open ≤-Reasoning instance - _ = (n k) !≢0 - _ = (pred (n k)) !≢0 - _ = (n suc k) !≢0 - _ = >-nonZero (m<n⇒0<n∸m k<n) + _ = (n k) !≢0 + _ = (pred (n k)) !≢0 + _ = (n suc k) !≢0 + _ = >-nonZero (m<n⇒0<n∸m k<n) nP′k≡n[n∸1P′k∸1] : n k .{{NonZero n}} .{{NonZero k}} n P′ k n * (pred n P′ pred k) @@ -60,29 +60,29 @@ nP′k≡n[n∸1P′k∸1] n@(suc n-1) k@(suc k-1@(suc k-2)) = begin-equality n P′ k ≡⟨⟩ (n k-1) * (n P′ k-1) ≡⟨ cong ((n k-1) *_) (nP′k≡n[n∸1P′k∸1] n k-1) - (n k-1) * (n * (n-1 P′ k-2)) ≡⟨ x∙yz≈y∙xz (n k-1) n (n-1 P′ k-2) + (n k-1) * (n * (n-1 P′ k-2)) ≡⟨ x∙yz≈y∙xz (n k-1) n (n-1 P′ k-2) n * ((n k-1) * (n-1 P′ k-2)) ≡⟨⟩ n * (n-1 P′ k-1) - where open ≤-Reasoning; open *-CS + where open ≤-Reasoning; open *-CS P′-rec : {n k} k n .{{NonZero k}} n P′ k k * (pred n P′ pred k) + pred n P′ k P′-rec n@{suc n-1} k@{suc k-1} k≤n = begin-equality n P′ k ≡⟨ nP′k≡n[n∸1P′k∸1] n k - n * (n-1 P′ k-1) ≡⟨ cong (_* (n-1 P′ k-1)) (m+[n∸m]≡n {k} {n} k≤n) - (k + (n k)) * (n-1 P′ k-1) ≡⟨ *-distribʳ-+ (n-1 P′ k-1) k (n k) + n * (n-1 P′ k-1) ≡⟨ cong (_* (n-1 P′ k-1)) (m+[n∸m]≡n {k} {n} k≤n) + (k + (n k)) * (n-1 P′ k-1) ≡⟨ *-distribʳ-+ (n-1 P′ k-1) k (n k) k * (n-1 P′ k-1) + (n-1 k-1) * (n-1 P′ k-1) ≡⟨⟩ k * (n-1 P′ k-1) + (n-1 P′ k) - where open ≤-Reasoning + where open ≤-Reasoning nP′n≡n! : n n P′ n n ! nP′n≡n! n = begin-equality - n P′ n ≡⟨ nP′k≡n!/[n∸k]! (≤-refl {n}) - n ! / (n n) ! ≡⟨ /-congʳ (cong _! (n∸n≡0 n)) + n P′ n ≡⟨ nP′k≡n!/[n∸k]! (≤-refl {n}) + n ! / (n n) ! ≡⟨ /-congʳ (cong _! (n∸n≡0 n)) n ! / 0 ! ≡⟨⟩ n ! / 1 ≡⟨ n/1≡n (n !) n ! - where open ≤-Reasoning; instance _ = (n n) !≢0 + where open ≤-Reasoning; instance _ = (n n) !≢0 k!∣nP′k : {n k} k n k ! n P′ k k!∣nP′k {n} {zero} k≤n = ∣-refl @@ -90,74 +90,74 @@ ... | yes refl = ∣-reflexive (sym (nP′n≡n! n)) ... | no k≢n = begin k ! ≡⟨⟩ - k * k-1 ! ∣⟨ ∣m∣n⇒∣m+n (*-monoʳ-∣ k (k!∣nP′k k-1≤n-1)) ( k!∣nP′k (≤∧≢⇒< k-1≤n-1 k≢n)) + k * k-1 ! ∣⟨ ∣m∣n⇒∣m+n (*-monoʳ-∣ k (k!∣nP′k k-1≤n-1)) ( k!∣nP′k (≤∧≢⇒< k-1≤n-1 k≢n)) k * (n-1 P′ k-1) + (n-1 P′ k) ≡⟨ P′-rec k≤n n P′ k where open ∣-Reasoning [n∸k]!k!∣n! : {n k} k n (n k) ! * k ! n ! -[n∸k]!k!∣n! {n} {k} k≤n = m∣n/o⇒o*m∣n (m≤n⇒m!∣n! (m∸n≤m n k)) +[n∸k]!k!∣n! {n} {k} k≤n = m∣n/o⇒o*m∣n (m≤n⇒m!∣n! (m∸n≤m n k)) (subst (k ! ∣_) (nP′k≡n!/[n∸k]! k≤n) (k!∣nP′k k≤n)) - where instance _ = (n k) !≢0 + where instance _ = (n k) !≢0 ------------------------------------------------------------------------ -- Properties of _P_ -nPk≡n!/[n∸k]! : {n k} k n n P k (n ! / (n k) !) {{(n k) !≢0}} +nPk≡n!/[n∸k]! : {n k} k n n P k (n ! / (n k) !) {{(n k) !≢0}} nPk≡n!/[n∸k]! {n} {k} k≤n with k ≤ᵇ n in eq ... | true = nP′k≡n!/[n∸k]! k≤n -... | false = contradiction (≤⇒≤ᵇ k≤n) (subst T eq) +... | false = contradiction (≤⇒≤ᵇ k≤n) (subst T eq) k>n⇒nPk≡0 : {n k} k > n n P k 0 k>n⇒nPk≡0 {n} {k} k>n with k ≤ᵇ n in eq -... | true = contradiction (≤ᵇ⇒≤′ eq) (<⇒≱ k>n) +... | true = contradiction (≤ᵇ⇒≤′ eq) (<⇒≱ k>n) ... | false = refl ------------------------------------------------------------------------ -- Properties of _C′_ -nC′k≡n!/k![n-k]! : {n k} k n n C′ k (n ! / (k ! * (n k) !)) {{k !* (n k) !≢0}} +nC′k≡n!/k![n-k]! : {n k} k n n C′ k (n ! / (k ! * (n k) !)) {{k !* (n k) !≢0}} nC′k≡n!/k![n-k]! {n} {k} k≤n = begin-equality n C′ k ≡⟨⟩ (n P′ k) / k ! ≡⟨ /-congˡ (nP′k≡n!/[n∸k]! k≤n) (n ! / (n k) !) / k ! ≡⟨ m/n/o≡m/[n*o] (n !) ((n k) !) (k !) - n ! / ((n k) ! * k !) ≡⟨ /-congʳ (*-comm ((n k)!) (k !)) + n ! / ((n k) ! * k !) ≡⟨ /-congʳ (*-comm ((n k)!) (k !)) n ! / (k ! * (n k) !) where - open ≤-Reasoning + open ≤-Reasoning instance - _ = k !≢0 - _ = (n k) !≢0 - _ = (n k) !* k !≢0 - _ = k !* (n k) !≢0 + _ = k !≢0 + _ = (n k) !≢0 + _ = (n k) !* k !≢0 + _ = k !* (n k) !≢0 C′-sym : {n k} k n n C′ (n k) n C′ k C′-sym {n} {k} k≤n = begin-equality - n C′ (n k) ≡⟨ nC′k≡n!/k![n-k]! {n} {n k} (m≤n⇒n∸m≤n k≤n) - n ! / ((n k) ! * (n (n k)) !) ≡⟨ /-congʳ (cong ((n k) ! *_) (cong _! (m∸[m∸n]≡n k≤n))) - n ! / ((n k) ! * k !) ≡⟨ /-congʳ (*-comm ((n k) !) (k !)) + n C′ (n k) ≡⟨ nC′k≡n!/k![n-k]! {n} {n k} (m≤n⇒n∸m≤n k≤n) + n ! / ((n k) ! * (n (n k)) !) ≡⟨ /-congʳ (cong ((n k) ! *_) (cong _! (m∸[m∸n]≡n k≤n))) + n ! / ((n k) ! * k !) ≡⟨ /-congʳ (*-comm ((n k) !) (k !)) n ! / (k ! * (n k) !) ≡⟨ nC′k≡n!/k![n-k]! k≤n n C′ k where - open ≤-Reasoning + open ≤-Reasoning instance - _ = (n k) !* k !≢0 - _ = k !* (n k) !≢0 - _ = (n k) !* (n (n k)) !≢0 + _ = (n k) !* k !≢0 + _ = k !* (n k) !≢0 + _ = (n k) !* (n (n k)) !≢0 ------------------------------------------------------------------------ -- Properties of _C_ nCk≡n!/k![n-k]! : {n k} k n - n C k (n ! / (k ! * (n k) !)) {{k !* (n k) !≢0}} + n C k (n ! / (k ! * (n k) !)) {{k !* (n k) !≢0}} nCk≡n!/k![n-k]! {n} {k} k≤n with k ≤ᵇ n in eq2 -... | false = contradiction (≤⇒≤ᵇ k≤n) (subst T eq2) +... | false = contradiction (≤⇒≤ᵇ k≤n) (subst T eq2) ... | true with ⊓-sel k (n k) ... | inj₁ k⊓[n∸k]≡k rewrite k⊓[n∸k]≡k = nC′k≡n!/k![n-k]! k≤n ... | inj₂ k⊓[n∸k]≡n∸k rewrite k⊓[n∸k]≡n∸k = trans (C′-sym k≤n) (nC′k≡n!/k![n-k]! k≤n) k>n⇒nCk≡0 : {n k} k > n n C k 0 k>n⇒nCk≡0 {n} {k} k>n with k ≤ᵇ n in eq -... | true = contradiction (≤ᵇ⇒≤′ eq) (<⇒≱ k>n) +... | true = contradiction (≤ᵇ⇒≤′ eq) (<⇒≱ k>n) ... | false = refl \ No newline at end of file diff --git a/v2.3/Data.Nat.Combinatorics.html b/v2.3/Data.Nat.Combinatorics.html index e09a4ea4c8..0332498ab4 100644 --- a/v2.3/Data.Nat.Combinatorics.html +++ b/v2.3/Data.Nat.Combinatorics.html @@ -23,7 +23,7 @@ import Data.Nat.Combinatorics.Specification as Specification import Algebra.Properties.CommutativeSemigroup as CommSemigroupProperties -open ≤-Reasoning +open ≤-Reasoning private variable @@ -43,13 +43,13 @@ nPn≡n! : n n P n n ! nPn≡n! n = begin-equality - n P n ≡⟨ nPk≡n!/[n∸k]! (≤-refl {n}) - n ! / (n n) ! ≡⟨ /-congʳ (cong _! (n∸n≡0 n)) + n P n ≡⟨ nPk≡n!/[n∸k]! (≤-refl {n}) + n ! / (n n) ! ≡⟨ /-congʳ (cong _! (n∸n≡0 n)) n ! / 0 ! ≡⟨⟩ n ! / 1 ≡⟨ n/1≡n (n !) n ! where instance - _ = (n n) !≢0 + _ = (n n) !≢0 nP1≡n : n n P 1 n nP1≡n zero = refl @@ -58,7 +58,7 @@ n ! / n-1 ! ≡⟨ m*n/n≡m n (n-1 !) n where instance - _ = n-1 !≢0 + _ = n-1 !≢0 ------------------------------------------------------------------------ -- Properties of _C_ @@ -69,36 +69,36 @@ nCk≡nC[n∸k] : k n n C k n C (n k) nCk≡nC[n∸k] {k} {n} k≤n = begin-equality n C k ≡⟨ nCk≡n!/k![n-k]! k≤n - n ! / (k ! * (n k) !) ≡⟨ /-congʳ (*-comm ((n k) !) (k !)) - n ! / ((n k) ! * k !) ≡⟨ /-congʳ (cong ((n k) ! *_) (cong _! (m∸[m∸n]≡n k≤n))) - n ! / ((n k) ! * (n (n k)) !) ≡⟨ nCk≡n!/k![n-k]! (m≤n⇒n∸m≤n k≤n) + n ! / (k ! * (n k) !) ≡⟨ /-congʳ (*-comm ((n k) !) (k !)) + n ! / ((n k) ! * k !) ≡⟨ /-congʳ (cong ((n k) ! *_) (cong _! (m∸[m∸n]≡n k≤n))) + n ! / ((n k) ! * (n (n k)) !) ≡⟨ nCk≡n!/k![n-k]! (m≤n⇒n∸m≤n k≤n) n C (n k) where instance - _ = (n k) !* k !≢0 - _ = k !* (n k) !≢0 - _ = (n k) !* (n (n k)) !≢0 + _ = (n k) !* k !≢0 + _ = k !* (n k) !≢0 + _ = (n k) !* (n (n k)) !≢0 -nCk≡nPk/k! : k n n C k ((n P k) / k !) {{k !≢0}} +nCk≡nPk/k! : k n n C k ((n P k) / k !) {{k !≢0}} nCk≡nPk/k! {k} {n} k≤n = begin-equality n C k ≡⟨ nCk≡n!/k![n-k]! k≤n - n ! / (k ! * (n k) !) ≡⟨ /-congʳ (*-comm ((n k)!) (k !)) + n ! / (k ! * (n k) !) ≡⟨ /-congʳ (*-comm ((n k)!) (k !)) n ! / ((n k) ! * k !) ≡⟨ m/n/o≡m/[n*o] (n !) ((n k) !) (k !) (n ! / (n k) !) / k ! ≡⟨ /-congˡ (nPk≡n!/[n∸k]! k≤n) (n P k) / k ! where instance - _ = k !≢0 - _ = (n k) !≢0 - _ = (n k) !* k !≢0 - _ = k !* (n k) !≢0 + _ = k !≢0 + _ = (n k) !≢0 + _ = (n k) !* k !≢0 + _ = k !* (n k) !≢0 nCn≡1 : n n C n 1 nCn≡1 n = begin-equality - n C n ≡⟨ nCk≡nPk/k! (≤-refl {n}) + n C n ≡⟨ nCk≡nPk/k! (≤-refl {n}) (n P n) / n ! ≡⟨ /-congˡ (nPn≡n! n) n ! / n ! ≡⟨ n/n≡1 (n !) 1 where instance - _ = n !≢0 + _ = n !≢0 nC1≡n : n n C 1 n nC1≡n zero = refl @@ -123,115 +123,115 @@ [n-k-1]! = [n-k-1] ! [n-k]≡1+[n-k-1] : [n-k] suc [n-k-1] - [n-k]≡1+[n-k-1] = ∸-suc k<n - - - [n-k]*[n-k-1]!≡[n-k]! : [n-k] * [n-k-1]! [n-k]! - [n-k]*[n-k-1]!≡[n-k]! = begin-equality - [n-k] * [n-k-1]! - ≡⟨ cong (_* [n-k-1]!) [n-k]≡1+[n-k-1] - (suc [n-k-1]) * [n-k-1]! - ≡⟨ cong _! [n-k]≡1+[n-k-1] - [n-k]! - - private - - n! = n ! - k! = k ! - [k+1]! = (suc k) ! - - d[k] = k! * [n-k]! - [k+1]*d[k] = (suc k) * d[k] - d[k+1] = [k+1]! * [n-k-1]! - [n-k]*d[k+1] = [n-k] * d[k+1] - - [n-k]*d[k+1]≡[k+1]*d[k] : [n-k]*d[k+1] [k+1]*d[k] - [n-k]*d[k+1]≡[k+1]*d[k] = begin-equality - [n-k]*d[k+1] - ≡⟨ x∙yz≈y∙xz [n-k] [k+1]! [n-k-1]! - [k+1]! * ([n-k] * [n-k-1]!) - ≡⟨ *-assoc (suc k) k! ([n-k] * [n-k-1]!) - (suc k) * (k! * ([n-k] * [n-k-1]!)) - ≡⟨ cong ((suc k) *_) (cong (k! *_) [n-k]*[n-k-1]!≡[n-k]!) - [k+1]*d[k] - where open CommSemigroupProperties *-commutativeSemigroup - -k![n∸k]!∣n! : {n k} k n k ! * (n k) ! n ! -k![n∸k]!∣n! {n} {k} k≤n = subst (_∣ n !) (*-comm ((n k) !) (k !)) ([n∸k]!k!∣n! k≤n) - -nCk+nC[k+1]≡[n+1]C[k+1] : n k n C k + n C (suc k) suc n C suc k -nCk+nC[k+1]≡[n+1]C[k+1] n k with <-cmp k n -{- case k>n, in which case 1+k>1+n>n -} -... | tri> _ _ k>n = begin-equality - n C k + n C (suc k) ≡⟨ cong (_+ (n C (suc k))) (k>n⇒nCk≡0 k>n) - 0 + n C (suc k) ≡⟨⟩ - n C (suc k) ≡⟨ k>n⇒nCk≡0 (m<n⇒m<1+n k>n) - 0 ≡⟨ k>n⇒nCk≡0 (s<s k>n) - suc n C suc k -{- case k≡n, in which case 1+k≡1+n>n -} -... | tri≈ _ k≡n _ rewrite k≡n = begin-equality - n C n + n C (suc n) ≡⟨ cong (n C n +_) (k>n⇒nCk≡0 (n<1+n n)) - n C n + 0 ≡⟨ +-identityʳ (n C n) - n C n ≡⟨ nCn≡1 n - 1 ≡⟨ nCn≡1 (suc n) - suc n C suc n -{- case k<n, in which case 1+k<1+n and there's arithmetic to perform -} -... | tri< k<n _ _ = begin-equality - n C k + n C (suc k) - ≡⟨ cong (n C k +_) (nCk≡n!/k![n-k]! k<n) - n C k + (n! / d[k+1]) - ≡⟨ cong (n C k +_) (m*n/m*o≡n/o (n k) n! d[k+1]) - n C k + [n-k]*n!/[n-k]*d[k+1] - ≡⟨ cong (_+ [n-k]*n!/[n-k]*d[k+1]) (nCk≡n!/k![n-k]! k≤n) - n! / d[k] + _ - ≡⟨ cong (_+ [n-k]*n!/[n-k]*d[k+1]) (m*n/m*o≡n/o (suc k) n! d[k]) - (suc k * n!) / [k+1]*d[k] + _ - ≡⟨ cong (((suc k * n!) / [k+1]*d[k]) +_) (/-congʳ ([n-k]*d[k+1]≡[k+1]*d[k] k<n)) - (suc k * n!) / [k+1]*d[k] + ((n k) * n! / [k+1]*d[k]) - ≡⟨ +-distrib-/-∣ˡ _ (*-monoʳ-∣ (suc k) (k![n∸k]!∣n! k≤n)) - ((suc k) * n! + (n k) * n!) / [k+1]*d[k] - ≡⟨ cong (_/ [k+1]*d[k]) (*-distribʳ-+ (n !) (suc k) (n k)) - ((suc k + (n k)) * n !) / [k+1]*d[k] - ≡⟨ cong z z * n ! / [k+1]*d[k]) [k+1]+[n-k]≡[n+1] - ((suc n) * n !) / [k+1]*d[k] - ≡⟨ /-congʳ (*-assoc (suc k) (k !) ((n k) !)) - ((suc n) * n !) / (((suc k) * k !) * (n k) !) - ≡⟨⟩ - suc n ! / (suc k ! * (suc n suc k) !) - ≡⟨ nCk≡n!/k![n-k]! [k+1]≤[n+1] - suc n C suc k - where - k≤n : k n - k≤n = <⇒≤ k<n - - [k+1]≤[n+1] : suc k suc n - [k+1]≤[n+1] = s≤s k≤n - - [k+1]+[n-k]≡[n+1] : (suc k) + (n k) suc n - [k+1]+[n-k]≡[n+1] = m+[n∸m]≡n {suc k} [k+1]≤[n+1] - - [n-k] = n k - [n-k-1] = n suc k - - n! = n ! - k! = k ! - [k+1]! = (suc k) ! - [n-k]! = [n-k] ! - [n-k-1]! = [n-k-1] ! - - d[k] = k! * [n-k]! - [k+1]*d[k] = (suc k) * d[k] - d[k+1] = [k+1]! * [n-k-1]! - [n-k]*d[k+1] = [n-k] * d[k+1] - n!/[n-k]*d[k+1] = n ! / [n-k]*d[k+1] - [n-k]*n!/[n-k]*d[k+1] = [n-k] * n! / [n-k]*d[k+1] - [n-k]*n!/[k+1]*d[k] = [n-k] * n! / [k+1]*d[k] - - instance - [k+1]!*[n-k]!≢0 = (suc k) !* [n-k] !≢0 - d[k]≢0 = k !* [n-k] !≢0 - d[k+1]≢0 = (suc k) !* (n suc k) !≢0 - [k+1]*d[k]≢0 = m*n≢0 (suc k) d[k] - [n-k]≢0 = ≢-nonZero (m>n⇒m∸n≢0 k<n) - [n-k]*d[k+1]≢0 = m*n≢0 [n-k] d[k+1] + [n-k]≡1+[n-k-1] = +-∸-assoc 1 k<n + + + [n-k]*[n-k-1]!≡[n-k]! : [n-k] * [n-k-1]! [n-k]! + [n-k]*[n-k-1]!≡[n-k]! = begin-equality + [n-k] * [n-k-1]! + ≡⟨ cong (_* [n-k-1]!) [n-k]≡1+[n-k-1] + (suc [n-k-1]) * [n-k-1]! + ≡⟨ cong _! [n-k]≡1+[n-k-1] + [n-k]! + + private + + n! = n ! + k! = k ! + [k+1]! = (suc k) ! + + d[k] = k! * [n-k]! + [k+1]*d[k] = (suc k) * d[k] + d[k+1] = [k+1]! * [n-k-1]! + [n-k]*d[k+1] = [n-k] * d[k+1] + + [n-k]*d[k+1]≡[k+1]*d[k] : [n-k]*d[k+1] [k+1]*d[k] + [n-k]*d[k+1]≡[k+1]*d[k] = begin-equality + [n-k]*d[k+1] + ≡⟨ x∙yz≈y∙xz [n-k] [k+1]! [n-k-1]! + [k+1]! * ([n-k] * [n-k-1]!) + ≡⟨ *-assoc (suc k) k! ([n-k] * [n-k-1]!) + (suc k) * (k! * ([n-k] * [n-k-1]!)) + ≡⟨ cong ((suc k) *_) (cong (k! *_) [n-k]*[n-k-1]!≡[n-k]!) + [k+1]*d[k] + where open CommSemigroupProperties *-commutativeSemigroup + +k![n∸k]!∣n! : {n k} k n k ! * (n k) ! n ! +k![n∸k]!∣n! {n} {k} k≤n = subst (_∣ n !) (*-comm ((n k) !) (k !)) ([n∸k]!k!∣n! k≤n) + +nCk+nC[k+1]≡[n+1]C[k+1] : n k n C k + n C (suc k) suc n C suc k +nCk+nC[k+1]≡[n+1]C[k+1] n k with <-cmp k n +{- case k>n, in which case 1+k>1+n>n -} +... | tri> _ _ k>n = begin-equality + n C k + n C (suc k) ≡⟨ cong (_+ (n C (suc k))) (k>n⇒nCk≡0 k>n) + 0 + n C (suc k) ≡⟨⟩ + n C (suc k) ≡⟨ k>n⇒nCk≡0 (m<n⇒m<1+n k>n) + 0 ≡⟨ k>n⇒nCk≡0 (s<s k>n) + suc n C suc k +{- case k≡n, in which case 1+k≡1+n>n -} +... | tri≈ _ k≡n _ rewrite k≡n = begin-equality + n C n + n C (suc n) ≡⟨ cong (n C n +_) (k>n⇒nCk≡0 (n<1+n n)) + n C n + 0 ≡⟨ +-identityʳ (n C n) + n C n ≡⟨ nCn≡1 n + 1 ≡⟨ nCn≡1 (suc n) + suc n C suc n +{- case k<n, in which case 1+k<1+n and there's arithmetic to perform -} +... | tri< k<n _ _ = begin-equality + n C k + n C (suc k) + ≡⟨ cong (n C k +_) (nCk≡n!/k![n-k]! k<n) + n C k + (n! / d[k+1]) + ≡⟨ cong (n C k +_) (m*n/m*o≡n/o (n k) n! d[k+1]) + n C k + [n-k]*n!/[n-k]*d[k+1] + ≡⟨ cong (_+ [n-k]*n!/[n-k]*d[k+1]) (nCk≡n!/k![n-k]! k≤n) + n! / d[k] + _ + ≡⟨ cong (_+ [n-k]*n!/[n-k]*d[k+1]) (m*n/m*o≡n/o (suc k) n! d[k]) + (suc k * n!) / [k+1]*d[k] + _ + ≡⟨ cong (((suc k * n!) / [k+1]*d[k]) +_) (/-congʳ ([n-k]*d[k+1]≡[k+1]*d[k] k<n)) + (suc k * n!) / [k+1]*d[k] + ((n k) * n! / [k+1]*d[k]) + ≡⟨ +-distrib-/-∣ˡ _ (*-monoʳ-∣ (suc k) (k![n∸k]!∣n! k≤n)) + ((suc k) * n! + (n k) * n!) / [k+1]*d[k] + ≡⟨ cong (_/ [k+1]*d[k]) (*-distribʳ-+ (n !) (suc k) (n k)) + ((suc k + (n k)) * n !) / [k+1]*d[k] + ≡⟨ cong z z * n ! / [k+1]*d[k]) [k+1]+[n-k]≡[n+1] + ((suc n) * n !) / [k+1]*d[k] + ≡⟨ /-congʳ (*-assoc (suc k) (k !) ((n k) !)) + ((suc n) * n !) / (((suc k) * k !) * (n k) !) + ≡⟨⟩ + suc n ! / (suc k ! * (suc n suc k) !) + ≡⟨ nCk≡n!/k![n-k]! [k+1]≤[n+1] + suc n C suc k + where + k≤n : k n + k≤n = <⇒≤ k<n + + [k+1]≤[n+1] : suc k suc n + [k+1]≤[n+1] = s≤s k≤n + + [k+1]+[n-k]≡[n+1] : (suc k) + (n k) suc n + [k+1]+[n-k]≡[n+1] = m+[n∸m]≡n {suc k} [k+1]≤[n+1] + + [n-k] = n k + [n-k-1] = n suc k + + n! = n ! + k! = k ! + [k+1]! = (suc k) ! + [n-k]! = [n-k] ! + [n-k-1]! = [n-k-1] ! + + d[k] = k! * [n-k]! + [k+1]*d[k] = (suc k) * d[k] + d[k+1] = [k+1]! * [n-k-1]! + [n-k]*d[k+1] = [n-k] * d[k+1] + n!/[n-k]*d[k+1] = n ! / [n-k]*d[k+1] + [n-k]*n!/[n-k]*d[k+1] = [n-k] * n! / [n-k]*d[k+1] + [n-k]*n!/[k+1]*d[k] = [n-k] * n! / [k+1]*d[k] + + instance + [k+1]!*[n-k]!≢0 = (suc k) !* [n-k] !≢0 + d[k]≢0 = k !* [n-k] !≢0 + d[k+1]≢0 = (suc k) !* (n suc k) !≢0 + [k+1]*d[k]≢0 = m*n≢0 (suc k) d[k] + [n-k]≢0 = ≢-nonZero (m>n⇒m∸n≢0 k<n) + [n-k]*d[k+1]≢0 = m*n≢0 [n-k] d[k+1] \ No newline at end of file diff --git a/v2.3/Data.Nat.Coprimality.html b/v2.3/Data.Nat.Coprimality.html index 9b3ebd3225..b419d96c5d 100644 --- a/v2.3/Data.Nat.Coprimality.html +++ b/v2.3/Data.Nat.Coprimality.html @@ -23,14 +23,14 @@ open import Level using (0ℓ) open import Relation.Binary.PropositionalEquality.Core as using (_≡_; _≢_; refl; trans; cong; subst) -open import Relation.Nullary as Nullary using (¬_; contradiction; map′) +open import Relation.Nullary as Nullary using (¬_; contradiction; map′) open import Relation.Binary.Core using (Rel) open import Relation.Binary.Definitions using (Symmetric; Decidable) private variable d m n o p : -open ≤-Reasoning +open ≤-Reasoning ------------------------------------------------------------------------ -- Definition @@ -49,7 +49,7 @@ GCD≡1⇒coprime : GCD m n 1 Coprime m n GCD≡1⇒coprime g cd with divides q eqGCD.greatest g cd - = m*n≡1⇒n≡1 q _ (≡.sym eq) + = m*n≡1⇒n≡1 q _ (≡.sym eq) coprime⇒gcd≡1 : Coprime m n gcd m n 1 coprime⇒gcd≡1 coprime = GCD.unique (gcd-GCD _ _) (coprime⇒GCD≡1 coprime) @@ -84,7 +84,7 @@ 0-coprimeTo-m⇒m≡1 {m} coprime = coprime (m ∣0 , ∣-refl) ¬0-coprimeTo-2+ : .{{NonTrivial n}} ¬ Coprime 0 n -¬0-coprimeTo-2+ {n} coprime = contradiction (0-coprimeTo-m⇒m≡1 coprime) (nonTrivial⇒≢1 {n}) +¬0-coprimeTo-2+ {n} coprime = contradiction (0-coprimeTo-m⇒m≡1 coprime) (nonTrivial⇒≢1 {n}) -- If m and n are coprime, then n + m and n are also coprime. @@ -135,5 +135,5 @@ prime⇒coprime : Prime p .{{NonZero n}} n < p Coprime p n prime⇒coprime p n<p (d∣p , d∣n) with prime⇒irreducible p d∣p ... | inj₁ d≡1 = d≡1 -... | inj₂ d≡p@refl = contradiction n<p (≤⇒≯ (∣⇒≤ d∣n)) +... | inj₂ d≡p@refl = contradiction n<p (≤⇒≯ (∣⇒≤ d∣n)) \ No newline at end of file diff --git a/v2.3/Data.Nat.DivMod.Core.html b/v2.3/Data.Nat.DivMod.Core.html index 193a05949c..2d56dae2ab 100644 --- a/v2.3/Data.Nat.DivMod.Core.html +++ b/v2.3/Data.Nat.DivMod.Core.html @@ -20,9 +20,9 @@ open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong; sym; subst; trans) open import Relation.Nullary.Decidable using (yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) -open ≤-Reasoning +open ≤-Reasoning ------------------------------------------------------------------------ -- Helper lemmas that have no interpretation for _%_, only for modₕ @@ -33,12 +33,12 @@ mod-cong₃ refl = refl modₕ-skipTo0 : acc n a b modₕ acc n (b + a) a modₕ (a + acc) n b 0 - modₕ-skipTo0 acc n zero b = cong v modₕ acc n v 0) (+-identityʳ b) + modₕ-skipTo0 acc n zero b = cong v modₕ acc n v 0) (+-identityʳ b) modₕ-skipTo0 acc n (suc a) b = begin-equality - modₕ acc n (b + suc a) (suc a) ≡⟨ mod-cong₃ (+-suc b a) + modₕ acc n (b + suc a) (suc a) ≡⟨ mod-cong₃ (+-suc b a) modₕ acc n (suc b + a) (suc a) ≡⟨⟩ modₕ (suc acc) n (b + a) a ≡⟨ modₕ-skipTo0 (suc acc) n a b - modₕ (a + suc acc) n b 0 ≡⟨ cong v modₕ v n b 0) (+-suc a acc) + modₕ (a + suc acc) n b 0 ≡⟨ cong v modₕ v n b 0) (+-suc a acc) modₕ (suc a + acc) n b 0 ------------------------------------------------------------------------ @@ -52,71 +52,71 @@ n[modₕ]n≡0 acc v = modₕ-skipTo0 acc (acc + v) v 1 a[modₕ]n<n : acc d n modₕ acc (acc + n) d n acc + n -a[modₕ]n<n acc zero n = m≤m+n acc n +a[modₕ]n<n acc zero n = m≤m+n acc n a[modₕ]n<n acc (suc d) zero = a[modₕ]n<n zero d (acc + 0) -a[modₕ]n<n acc (suc d) (suc n) rewrite +-suc acc n = a[modₕ]n<n (suc acc) d n +a[modₕ]n<n acc (suc d) (suc n) rewrite +-suc acc n = a[modₕ]n<n (suc acc) d n a[modₕ]n≤a : acc a n modₕ acc (acc + n) a n acc + a -a[modₕ]n≤a acc zero n = ≤-reflexive (sym (+-identityʳ acc)) +a[modₕ]n≤a acc zero n = ≤-reflexive (sym (+-identityʳ acc)) a[modₕ]n≤a acc (suc a) (suc n) = begin - modₕ acc (acc + suc n) (suc a) (suc n) ≡⟨ cong v modₕ acc v (suc a) (suc n)) (+-suc acc n) + modₕ acc (acc + suc n) (suc a) (suc n) ≡⟨ cong v modₕ acc v (suc a) (suc n)) (+-suc acc n) modₕ acc (suc acc + n) (suc a) (suc n) ≤⟨ a[modₕ]n≤a (suc acc) a n - suc acc + a ≡⟨ sym (+-suc acc a) + suc acc + a ≡⟨ sym (+-suc acc a) acc + suc a a[modₕ]n≤a acc (suc a) zero = begin - modₕ acc (acc + 0) (suc a) 0 ≡⟨ cong v modₕ acc v (suc a) 0) (+-identityʳ acc) + modₕ acc (acc + 0) (suc a) 0 ≡⟨ cong v modₕ acc v (suc a) 0) (+-identityʳ acc) modₕ acc acc (suc a) 0 ≤⟨ a[modₕ]n≤a 0 a acc - a ≤⟨ n≤1+n a - suc a ≤⟨ m≤n+m (suc a) acc + a ≤⟨ n≤1+n a + suc a ≤⟨ m≤n+m (suc a) acc acc + suc a a≤n⇒a[modₕ]n≡a : acc n a b modₕ acc n a (a + b) acc + a -a≤n⇒a[modₕ]n≡a acc n zero b = sym (+-identityʳ acc) +a≤n⇒a[modₕ]n≡a acc n zero b = sym (+-identityʳ acc) a≤n⇒a[modₕ]n≡a acc n (suc a) b = begin-equality modₕ (suc acc) n a (a + b) ≡⟨ a≤n⇒a[modₕ]n≡a (suc acc) n a b - suc acc + a ≡⟨ sym (+-suc acc a) + suc acc + a ≡⟨ sym (+-suc acc a) acc + suc a modₕ-idem : acc a n modₕ 0 (acc + n) (modₕ acc (acc + n) a n) (acc + n) modₕ acc (acc + n) a n modₕ-idem acc zero n = a≤n⇒a[modₕ]n≡a 0 (acc + n) acc n -modₕ-idem acc (suc a) zero rewrite +-identityʳ acc = modₕ-idem 0 a acc -modₕ-idem acc (suc a) (suc n) rewrite +-suc acc n = modₕ-idem (suc acc) a n +modₕ-idem acc (suc a) zero rewrite +-identityʳ acc = modₕ-idem 0 a acc +modₕ-idem acc (suc a) (suc n) rewrite +-suc acc n = modₕ-idem (suc acc) a n a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 : acc l n modₕ acc (acc + l) (suc n) l 0 modₕ acc (acc + l) n l acc + l -a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc zero zero eq rewrite +-identityʳ acc = refl -a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc zero (suc n) eq rewrite +-identityʳ acc = a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 acc n eq -a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc (suc l) (suc n) eq rewrite +-suc acc l = a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 (suc acc) l n eq +a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc zero zero eq rewrite +-identityʳ acc = refl +a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc zero (suc n) eq rewrite +-identityʳ acc = a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 acc n eq +a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc (suc l) (suc n) eq rewrite +-suc acc l = a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 (suc acc) l n eq k<1+a[modₕ]n⇒k≤a[modₕ]n : acc k n l suc k modₕ acc (acc + l) (suc n) l k modₕ acc (acc + l) n l k<1+a[modₕ]n⇒k≤a[modₕ]n acc k zero (suc l) (s≤s leq) = leq -k<1+a[modₕ]n⇒k≤a[modₕ]n acc k (suc n) zero leq rewrite +-identityʳ acc = k<1+a[modₕ]n⇒k≤a[modₕ]n 0 k n acc leq -k<1+a[modₕ]n⇒k≤a[modₕ]n acc k (suc n) (suc l) leq rewrite +-suc acc l = k<1+a[modₕ]n⇒k≤a[modₕ]n (suc acc) k n l leq +k<1+a[modₕ]n⇒k≤a[modₕ]n acc k (suc n) zero leq rewrite +-identityʳ acc = k<1+a[modₕ]n⇒k≤a[modₕ]n 0 k n acc leq +k<1+a[modₕ]n⇒k≤a[modₕ]n acc k (suc n) (suc l) leq rewrite +-suc acc l = k<1+a[modₕ]n⇒k≤a[modₕ]n (suc acc) k n l leq 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k : acc k n l 0 < modₕ acc (acc + l) (suc n) l modₕ acc (acc + l) (suc n) l suc k modₕ acc (acc + l) n l k 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k zero (suc l) 0<mod (s≤s leq) = leq -1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k (suc n) zero 0<mod leq rewrite +-identityʳ acc = 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 k n acc 0<mod leq -1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k (suc n) (suc l) 0<mod leq rewrite +-suc acc l = 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k (suc acc) k n l 0<mod leq +1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k (suc n) zero 0<mod leq rewrite +-identityʳ acc = 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 k n acc 0<mod leq +1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k (suc n) (suc l) 0<mod leq rewrite +-suc acc l = 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k (suc acc) k n l 0<mod leq a+n[modₕ]n≡a[modₕ]n : acc a n modₕ acc (acc + n) (acc + a + suc n) n modₕ acc (acc + n) a n -a+n[modₕ]n≡a[modₕ]n acc zero n rewrite +-identityʳ acc = begin-equality - modₕ acc (acc + n) (acc + suc n) n ≡⟨ mod-cong₃ (+-suc acc n) +a+n[modₕ]n≡a[modₕ]n acc zero n rewrite +-identityʳ acc = begin-equality + modₕ acc (acc + n) (acc + suc n) n ≡⟨ mod-cong₃ (+-suc acc n) modₕ acc (acc + n) (suc acc + n) n ≡⟨ modₕ-skipTo0 acc (acc + n) n (suc acc) modₕ (acc + n) (acc + n) (suc acc) 0 ≡⟨⟩ modₕ 0 (acc + n) acc (acc + n) ≡⟨ a≤n⇒a[modₕ]n≡a 0 (acc + n) acc n acc -a+n[modₕ]n≡a[modₕ]n acc (suc a) zero rewrite +-identityʳ acc = begin-equality - modₕ acc acc (acc + suc a + 1) 0 ≡⟨ mod-cong₃ (+-comm (acc + suc a) 1) +a+n[modₕ]n≡a[modₕ]n acc (suc a) zero rewrite +-identityʳ acc = begin-equality + modₕ acc acc (acc + suc a + 1) 0 ≡⟨ mod-cong₃ (+-comm (acc + suc a) 1) modₕ acc acc (1 + (acc + suc a)) 0 ≡⟨⟩ - modₕ 0 acc (acc + suc a) acc ≡⟨ mod-cong₃ (+-comm acc (suc a)) - modₕ 0 acc (suc a + acc) acc ≡⟨ mod-cong₃ (sym (+-suc a acc)) + modₕ 0 acc (acc + suc a) acc ≡⟨ mod-cong₃ (+-comm acc (suc a)) + modₕ 0 acc (suc a + acc) acc ≡⟨ mod-cong₃ (sym (+-suc a acc)) modₕ 0 acc (a + suc acc) acc ≡⟨ a+n[modₕ]n≡a[modₕ]n 0 a acc modₕ 0 acc a acc -a+n[modₕ]n≡a[modₕ]n acc (suc a) (suc n) rewrite +-suc acc n = begin-equality - mod₁ (acc + suc a + (2 + n)) (suc n) ≡⟨ cong v mod₁ (v + suc (suc n)) (suc n)) (+-suc acc a) +a+n[modₕ]n≡a[modₕ]n acc (suc a) (suc n) rewrite +-suc acc n = begin-equality + mod₁ (acc + suc a + (2 + n)) (suc n) ≡⟨ cong v mod₁ (v + suc (suc n)) (suc n)) (+-suc acc a) mod₁ (suc acc + a + (2 + n)) (suc n) ≡⟨⟩ - mod₂ (acc + a + (2 + n)) n ≡⟨ mod-cong₃ (sym (+-assoc (acc + a) 1 (suc n))) - mod₂ (acc + a + 1 + suc n) n ≡⟨ mod-cong₃ (cong (_+ suc n) (+-comm (acc + a) 1)) + mod₂ (acc + a + (2 + n)) n ≡⟨ mod-cong₃ (sym (+-assoc (acc + a) 1 (suc n))) + mod₂ (acc + a + 1 + suc n) n ≡⟨ mod-cong₃ (cong (_+ suc n) (+-comm (acc + a) 1)) mod₂ (suc acc + a + suc n) n ≡⟨ a+n[modₕ]n≡a[modₕ]n (suc acc) a n mod₂ a n where @@ -132,8 +132,8 @@ div-cong₃ refl = refl acc≤divₕ[acc] : {acc} d n j acc divₕ acc d n j - acc≤divₕ[acc] {acc} d zero j = ≤-refl - acc≤divₕ[acc] {acc} d (suc n) zero = ≤-trans (n≤1+n acc) (acc≤divₕ[acc] d n d) + acc≤divₕ[acc] {acc} d zero j = ≤-refl + acc≤divₕ[acc] {acc} d (suc n) zero = ≤-trans (n≤1+n acc) (acc≤divₕ[acc] d n d) acc≤divₕ[acc] {acc} d (suc n) (suc j) = acc≤divₕ[acc] d n j pattern inj₂′ x = inj₂ (inj₁ x) @@ -153,31 +153,31 @@ divₕ-offsetEq d zero j k j≤d k≤d (inj₃ (eq , () , _)) -- (0 , 0) cases divₕ-offsetEq d (suc n) zero zero j≤d k≤d (inj₁ (refl , _)) = - divₕ-offsetEq d n d d ≤-refl ≤-refl (inj₂′ (refl , a[modₕ]n<n 0 n d , ≤-refl)) + divₕ-offsetEq d n d d ≤-refl ≤-refl (inj₂′ (refl , a[modₕ]n<n 0 n d , ≤-refl)) divₕ-offsetEq d (suc n) zero zero j≤d k≤d (inj₂′ (refl , _)) = - divₕ-offsetEq d n d d ≤-refl ≤-refl (inj₂′ (refl , a[modₕ]n<n 0 n d , ≤-refl)) + divₕ-offsetEq d n d d ≤-refl ≤-refl (inj₂′ (refl , a[modₕ]n<n 0 n d , ≤-refl)) divₕ-offsetEq d (suc n) zero zero j≤d k≤d (inj₃ (_ , 0<mod , mod≤0)) = - contradiction (<-≤-trans 0<mod mod≤0) λ() + contradiction (<-≤-trans 0<mod mod≤0) λ() -- (0 , suc) cases divₕ-offsetEq d (suc n) zero (suc k) j≤d k≤d (inj₁ (refl , _ , 1+k<mod)) = - divₕ-offsetEq d n d k ≤-refl (<⇒≤ k≤d) (inj₃ (refl , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d 1+k<mod , a[modₕ]n<n 0 n d)) + divₕ-offsetEq d n d k ≤-refl (<⇒≤ k≤d) (inj₃ (refl , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d 1+k<mod , a[modₕ]n<n 0 n d)) divₕ-offsetEq d (suc n) zero (suc k) j≤d k≤d (inj₂′ (refl , mod≤0 , _)) = - divₕ-offsetEq d n d k ≤-refl (<⇒≤ k≤d) (inj₃ (refl , subst (k <_) (sym (a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 d n (n≤0⇒n≡0 mod≤0))) k≤d , a[modₕ]n<n 0 n d)) + divₕ-offsetEq d n d k ≤-refl (<⇒≤ k≤d) (inj₃ (refl , subst (k <_) (sym (a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 d n (n≤0⇒n≡0 mod≤0))) k≤d , a[modₕ]n<n 0 n d)) divₕ-offsetEq d (suc n) zero (suc k) j≤d k≤d (inj₃ (_ , 1+k<mod , mod≤0)) = - contradiction (<-≤-trans 1+k<mod mod≤0) λ() + contradiction (<-≤-trans 1+k<mod mod≤0) λ() -- (suc , 0) cases divₕ-offsetEq d (suc n) (suc j) zero j≤d k≤d (inj₁ (_ , () , _)) divₕ-offsetEq d (suc n) (suc j) zero j≤d k≤d (inj₂′ (_ , _ , ())) divₕ-offsetEq d (suc n) (suc j) zero j≤d k≤d (inj₃ (eq , 0<mod , mod≤1+j)) = - divₕ-offsetEq d n j d (<⇒≤ j≤d) ≤-refl (inj₂′ (eq , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d 0<mod mod≤1+j , <⇒≤ j≤d)) + divₕ-offsetEq d n j d (<⇒≤ j≤d) ≤-refl (inj₂′ (eq , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d 0<mod mod≤1+j , <⇒≤ j≤d)) -- (suc , suc) cases divₕ-offsetEq d (suc n) (suc j) (suc k) j≤d k≤d (inj₁ (eq , s≤s j≤k , 1+k<mod)) = - divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₁ (eq , j≤k , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d 1+k<mod)) + divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₁ (eq , j≤k , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d 1+k<mod)) divₕ-offsetEq d (suc n) (suc j) (suc k) j≤d k≤d (inj₂′ (eq , mod≤1+j , (s≤s j≤k))) with modₕ 0 d (suc n) d 0 - ... | yes mod≡0 = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₁ (eq , j≤k , subst (k <_) (sym (a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 d n mod≡0)) k≤d)) - ... | no mod≢0 = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₂′ (eq , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d (n≢0⇒n>0 mod≢0) mod≤1+j , j≤k)) + ... | yes mod≡0 = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₁ (eq , j≤k , subst (k <_) (sym (a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 d n mod≡0)) k≤d)) + ... | no mod≢0 = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₂′ (eq , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d (n≢0⇒n>0 mod≢0) mod≤1+j , j≤k)) divₕ-offsetEq d (suc n) (suc j) (suc k) j≤d k≤d (inj₃ (eq , k<mod , mod≤1+j)) = - divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₃ (eq , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d k<mod , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d (≤-<-trans z≤n k<mod) mod≤1+j)) + divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₃ (eq , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d k<mod , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d (≤-<-trans z≤n k<mod) mod≤1+j)) ------------------------------------------------------------------------ -- Lemmas for divₕ that also have an interpretation for _/_ @@ -188,16 +188,16 @@ div-mod-lemma : accᵐ accᵈ d n accᵐ + accᵈ * suc (accᵐ + n) + d modₕ accᵐ (accᵐ + n) d n + divₕ accᵈ (accᵐ + n) d n * suc (accᵐ + n) -div-mod-lemma accᵐ accᵈ zero n = +-identityʳ _ -div-mod-lemma accᵐ accᵈ (suc d) zero rewrite +-identityʳ accᵐ = begin-equality - accᵐ + accᵈ * suc accᵐ + suc d ≡⟨ +-suc _ d +div-mod-lemma accᵐ accᵈ zero n = +-identityʳ _ +div-mod-lemma accᵐ accᵈ (suc d) zero rewrite +-identityʳ accᵐ = begin-equality + accᵐ + accᵈ * suc accᵐ + suc d ≡⟨ +-suc _ d suc accᵈ * suc accᵐ + d ≡⟨ div-mod-lemma zero (suc accᵈ) d accᵐ modₕ 0 accᵐ d accᵐ + divₕ (suc accᵈ) accᵐ d accᵐ * suc accᵐ ≡⟨⟩ modₕ accᵐ accᵐ (suc d) 0 + divₕ accᵈ accᵐ (suc d) 0 * suc accᵐ -div-mod-lemma accᵐ accᵈ (suc d) (suc n) rewrite +-suc accᵐ n = begin-equality - accᵐ + accᵈ * m + suc d ≡⟨ +-suc _ d +div-mod-lemma accᵐ accᵈ (suc d) (suc n) rewrite +-suc accᵐ n = begin-equality + accᵐ + accᵈ * m + suc d ≡⟨ +-suc _ d suc (accᵐ + accᵈ * m + d) ≡⟨ div-mod-lemma (suc accᵐ) accᵈ d n modₕ _ _ d n + divₕ accᵈ _ d n * m where @@ -208,11 +208,11 @@ divₕ-restart d (suc n) (suc j) (s≤s j<n) = divₕ-restart d n j j<n divₕ-extractAcc : acc d n j divₕ acc d n j acc + divₕ 0 d n j -divₕ-extractAcc acc d zero j = sym (+-identityʳ acc) +divₕ-extractAcc acc d zero j = sym (+-identityʳ acc) divₕ-extractAcc acc d (suc n) (suc j) = divₕ-extractAcc acc d n j divₕ-extractAcc acc d (suc n) zero = begin-equality divₕ (suc acc) d n d ≡⟨ divₕ-extractAcc (suc acc) d n d - suc acc + divₕ 0 d n d ≡⟨ sym (+-suc acc _) + suc acc + divₕ 0 d n d ≡⟨ sym (+-suc acc _) acc + suc (divₕ 0 d n d) ≡⟨ cong (acc +_) (sym (divₕ-extractAcc 1 d n d)) acc + divₕ 1 d n d @@ -225,42 +225,42 @@ n[divₕ]n≡1 n (suc m) = n[divₕ]n≡1 n m a[divₕ]1≡a : acc a divₕ acc 0 a 0 acc + a -a[divₕ]1≡a acc zero = sym (+-identityʳ acc) -a[divₕ]1≡a acc (suc a) = trans (a[divₕ]1≡a (suc acc) a) (sym (+-suc acc a)) +a[divₕ]1≡a acc zero = sym (+-identityʳ acc) +a[divₕ]1≡a acc (suc a) = trans (a[divₕ]1≡a (suc acc) a) (sym (+-suc acc a)) a*n[divₕ]n≡a : acc a n divₕ acc n (a * suc n) n acc + a -a*n[divₕ]n≡a acc zero n = sym (+-identityʳ acc) +a*n[divₕ]n≡a acc zero n = sym (+-identityʳ acc) a*n[divₕ]n≡a acc (suc a) n = begin-equality - divₕ acc n (suc a * suc n) n ≡⟨ divₕ-restart n (suc a * suc n) n (m≤m+n (suc n) _) + divₕ acc n (suc a * suc n) n ≡⟨ divₕ-restart n (suc a * suc n) n (m≤m+n (suc n) _) divₕ (suc acc) n (suc a * suc n suc n) n ≡⟨⟩ - divₕ (suc acc) n (suc n + a * suc n suc n) n ≡⟨ div-cong₃ (m+n∸m≡n (suc n) (a * suc n)) + divₕ (suc acc) n (suc n + a * suc n suc n) n ≡⟨ div-cong₃ (m+n∸m≡n (suc n) (a * suc n)) divₕ (suc acc) n (a * suc n) n ≡⟨ a*n[divₕ]n≡a (suc acc) a n - suc acc + a ≡⟨ sym (+-suc acc a) + suc acc + a ≡⟨ sym (+-suc acc a) acc + suc a +-distrib-divₕ : acc k m n j modₕ k (k + j) m j + modₕ 0 (k + j) n (k + j) < suc (k + j) divₕ acc (k + j) (m + n) j divₕ acc (k + j) m j + divₕ 0 (k + j) n (k + j) -+-distrib-divₕ acc k (suc m) n zero leq rewrite +-identityʳ k = +-distrib-divₕ (suc acc) 0 m n k leq -+-distrib-divₕ acc k (suc m) n (suc j) leq rewrite +-suc k j = +-distrib-divₕ acc (suc k) m n j leq ++-distrib-divₕ acc k (suc m) n zero leq rewrite +-identityʳ k = +-distrib-divₕ (suc acc) 0 m n k leq ++-distrib-divₕ acc k (suc m) n (suc j) leq rewrite +-suc k j = +-distrib-divₕ acc (suc k) m n j leq +-distrib-divₕ acc k zero n j leq = begin-equality divₕ acc (k + j) n j ≡⟨ divₕ-extractAcc acc (k + j) n j - acc + divₕ 0 (k + j) n j ≡⟨ cong (acc +_) (divₕ-offsetEq _ n j _ (m≤n+m j k) ≤-refl case) + acc + divₕ 0 (k + j) n j ≡⟨ cong (acc +_) (divₕ-offsetEq _ n j _ (m≤n+m j k) ≤-refl case) acc + divₕ 0 (k + j) n (k + j) where - case = inj₂′ (refl , +-cancelˡ-≤ (suc k) _ _ leq , m≤n+m j k) + case = inj₂′ (refl , +-cancelˡ-≤ (suc k) _ _ leq , m≤n+m j k) divₕ-mono-≤ : {acc} k {m n o p} m n p o divₕ acc (k + o) m o divₕ acc (k + p) n p divₕ-mono-≤ {acc} k {0} {n} {_} {p} z≤n p≤o = acc≤divₕ[acc] (k + p) n p divₕ-mono-≤ {acc} k {_} {_} {suc o} {suc p} (s≤s m≤n) (s≤s p≤o) - rewrite +-suc k o | +-suc k p = divₕ-mono-≤ (suc k) m≤n p≤o -divₕ-mono-≤ {acc} k {suc m} {suc n} {o} {0} (s≤s m≤n) z≤n with o <? suc m -... | no o≮1+m rewrite +-identityʳ k = begin - divₕ acc (k + o) (suc m) o ≡⟨ divₕ-finish (k + o) (suc m) o (≮⇒≥ o≮1+m) - acc ≤⟨ n≤1+n acc + rewrite +-suc k o | +-suc k p = divₕ-mono-≤ (suc k) m≤n p≤o +divₕ-mono-≤ {acc} k {suc m} {suc n} {o} {0} (s≤s m≤n) z≤n with o <? suc m +... | no o≮1+m rewrite +-identityʳ k = begin + divₕ acc (k + o) (suc m) o ≡⟨ divₕ-finish (k + o) (suc m) o (≮⇒≥ o≮1+m) + acc ≤⟨ n≤1+n acc suc acc ≤⟨ acc≤divₕ[acc] k n k divₕ (suc acc) k n k -... | yes o<1+m rewrite +-identityʳ k = begin +... | yes o<1+m rewrite +-identityʳ k = begin divₕ acc (k + o) (suc m) o ≡⟨ divₕ-restart (k + o) (suc m) o o<1+m - divₕ (suc acc) (k + o) (m o) (k + o) ≤⟨ divₕ-mono-≤ 0 (≤-trans (m∸n≤m m o) m≤n) (m≤m+n k o) + divₕ (suc acc) (k + o) (m o) (k + o) ≤⟨ divₕ-mono-≤ 0 (≤-trans (m∸n≤m m o) m≤n) (m≤m+n k o) divₕ (suc acc) k n k \ No newline at end of file diff --git a/v2.3/Data.Nat.DivMod.WithK.html b/v2.3/Data.Nat.DivMod.WithK.html index 4b74a9265a..b5d5d906de 100644 --- a/v2.3/Data.Nat.DivMod.WithK.html +++ b/v2.3/Data.Nat.DivMod.WithK.html @@ -11,10 +11,10 @@ open import Data.Nat.Base using (; NonZero; _+_; _*_) open import Data.Nat.DivMod hiding (_mod_; _divMod_) -open import Data.Nat.Properties using (≤⇒≤″) +open import Data.Nat.Properties using (≤⇒≤″) open import Data.Nat.WithK using (≤″-erase) open import Data.Fin.Base using (Fin; toℕ; fromℕ<″) -open import Data.Fin.Properties using (toℕ-fromℕ<″) +open import Data.Fin.Properties using (toℕ-fromℕ<″) open import Function.Base using (_$_) open import Relation.Binary.PropositionalEquality.Core using (cong) open import Relation.Binary.PropositionalEquality.Properties @@ -29,7 +29,7 @@ -- Certified modulus _mod_ : (dividend divisor : ) .{{ _ : NonZero divisor }} Fin divisor -m mod n = fromℕ<″ (m % n) (≤″-erase (≤⇒≤″ (m%n<n m n))) +m mod n = fromℕ<″ (m % n) (≤″-erase (≤⇒≤″ (m%n<n m n))) ------------------------------------------------------------------------ -- Returns modulus and division result with correctness proof @@ -38,7 +38,7 @@ DivMod dividend divisor m divMod n = result (m / n) (m mod n) $ ≡-erase $ begin m ≡⟨ m≡m%n+[m/n]*n m n - m % n + [m/n]*n ≡⟨ cong (_+ [m/n]*n) (toℕ-fromℕ<″ lemma″) + m % n + [m/n]*n ≡⟨ cong (_+ [m/n]*n) (toℕ-fromℕ<″ lemma″) toℕ (fromℕ<″ _ lemma″) + [m/n]*n - where [m/n]*n = m / n * n ; lemma″ = ≤″-erase (≤⇒≤″ (m%n<n m n)) + where [m/n]*n = m / n * n ; lemma″ = ≤″-erase (≤⇒≤″ (m%n<n m n)) \ No newline at end of file diff --git a/v2.3/Data.Nat.DivMod.html b/v2.3/Data.Nat.DivMod.html index 4cd4e070ca..7561f8a1f6 100644 --- a/v2.3/Data.Nat.DivMod.html +++ b/v2.3/Data.Nat.DivMod.html @@ -12,7 +12,7 @@ open import Agda.Builtin.Nat using (div-helper; mod-helper) open import Data.Fin.Base using (Fin; toℕ; fromℕ<) -open import Data.Fin.Properties using (nonZeroIndex; toℕ-fromℕ<) +open import Data.Fin.Properties using (nonZeroIndex; toℕ-fromℕ<) open import Data.Nat.Base open import Data.Nat.DivMod.Core open import Data.Nat.Divisibility.Core @@ -23,9 +23,9 @@ open import Function.Base using (_$_; _∘_) open import Relation.Binary.PropositionalEquality.Core using (_≡_; cong; cong₂; refl; trans; _≢_; sym) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) -open ≤-Reasoning +open ≤-Reasoning private variable @@ -45,7 +45,7 @@ m%n≡m∸m/n*n : m n .{{_ : NonZero n}} m % n m (m / n) * n m%n≡m∸m/n*n m n = begin-equality - m % n ≡⟨ m+n∸n≡m (m % n) m/n*n + m % n ≡⟨ m+n∸n≡m (m % n) m/n*n m % n + m/n*n m/n*n ≡⟨ cong (_∸ m/n*n) (m≡m%n+[m/n]*n m n) m m/n*n where m/n*n = (m / n) * n @@ -73,9 +73,9 @@ [m+n]%n≡m%n m (suc n-1) = a+n[modₕ]n≡a[modₕ]n 0 m n-1 [m+kn]%n≡m%n : m k n .{{_ : NonZero n}} (m + k * n) % n m % n -[m+kn]%n≡m%n m zero n = cong (_% n) (+-identityʳ m) +[m+kn]%n≡m%n m zero n = cong (_% n) (+-identityʳ m) [m+kn]%n≡m%n m (suc k) n = begin-equality - (m + (n + k * n)) % n ≡⟨ cong (_% n) (+-assoc m n (k * n)) + (m + (n + k * n)) % n ≡⟨ cong (_% n) (+-assoc m n (k * n)) (m + n + k * n) % n ≡⟨ [m+kn]%n≡m%n (m + n) k n (m + n) % n ≡⟨ [m+n]%n≡m%n m n m % n @@ -84,14 +84,14 @@ (n m) % m n % m m≤n⇒[n∸m]%m≡n%m {m} {n} m≤n = begin-equality (n m) % m ≡⟨ [m+n]%n≡m%n (n m) m - (n m + m) % m ≡⟨ cong (_% m) (m∸n+n≡m m≤n) + (n m + m) % m ≡⟨ cong (_% m) (m∸n+n≡m m≤n) n % m m*n≤o⇒[o∸m*n]%n≡o%n : m {n o} .{{_ : NonZero n}} m * n o (o m * n) % n o % n m*n≤o⇒[o∸m*n]%n≡o%n m {n} {o} m*n≤o = begin-equality (o m * n) % n ≡⟨ [m+kn]%n≡m%n (o m * n) m n - (o m * n + m * n) % n ≡⟨ cong (_% n) (m∸n+n≡m m*n≤o) + (o m * n + m * n) % n ≡⟨ cong (_% n) (m∸n+n≡m m*n≤o) o % n m*n%n≡0 : m n .{{_ : NonZero n}} (m * n) % n 0 @@ -101,17 +101,17 @@ m%n<n m (suc n-1) = s≤s (a[modₕ]n<n 0 m n-1) m%n≤n : m n .{{_ : NonZero n}} m % n n -m%n≤n m n = <⇒≤ (m%n<n m n) +m%n≤n m n = <⇒≤ (m%n<n m n) m%n≤m : m n .{{_ : NonZero n}} m % n m m%n≤m m (suc n-1) = a[modₕ]n≤a 0 m n-1 m≤n⇒m%n≡m : m n m % suc n m -m≤n⇒m%n≡m {m = m} m≤n with k , reflm≤n⇒∃[o]m+o≡n m≤n +m≤n⇒m%n≡m {m = m} m≤n with k , reflm≤n⇒∃[o]m+o≡n m≤n = a≤n⇒a[modₕ]n≡a 0 (m + k) m k m<n⇒m%n≡m : .{{_ : NonZero n}} m < n m % n m -m<n⇒m%n≡m {n = suc _} m<n = m≤n⇒m%n≡m (<⇒≤pred m<n) +m<n⇒m%n≡m {n = suc _} m<n = m≤n⇒m%n≡m (<⇒≤pred m<n) %-pred-≡0 : {m n} .{{_ : NonZero n}} (suc m % n) 0 (m % n) n 1 %-pred-≡0 {m} {suc n-1} eq = a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 n-1 m eq @@ -125,12 +125,12 @@ %-distribˡ-+ : m n d .{{_ : NonZero d}} (m + n) % d ((m % d) + (n % d)) % d %-distribˡ-+ m n d@(suc d-1) = begin-equality (m + n) % d ≡⟨ cong v (v + n) % d) (m≡m%n+[m/n]*n m d) - (m % d + m / d * d + n) % d ≡⟨ cong (_% d) (+-assoc (m % d) _ n) - (m % d + (m / d * d + n)) % d ≡⟨ cong v (m % d + v) % d) (+-comm _ n) - (m % d + (n + m / d * d)) % d ≡⟨ cong (_% d) (+-assoc (m % d) n _) + (m % d + m / d * d + n) % d ≡⟨ cong (_% d) (+-assoc (m % d) _ n) + (m % d + (m / d * d + n)) % d ≡⟨ cong v (m % d + v) % d) (+-comm _ n) + (m % d + (n + m / d * d)) % d ≡⟨ cong (_% d) (+-assoc (m % d) n _) (m % d + n + m / d * d) % d ≡⟨ [m+kn]%n≡m%n (m % d + n) (m / d) d (m % d + n) % d ≡⟨ cong v (m % d + v) % d) (m≡m%n+[m/n]*n n d) - (m % d + (n % d + (n / d) * d)) % d ≡⟨ cong (_% d) (+-assoc (m % d) (n % d) _) + (m % d + (n % d + (n / d) * d)) % d ≡⟨ cong (_% d) (+-assoc (m % d) (n % d) _) (m % d + n % d + (n / d) * d) % d ≡⟨ [m+kn]%n≡m%n (m % d + n % d) (n / d) d (m % d + n % d) % d @@ -149,22 +149,22 @@ j = n / d lemma : (m′ + k * d) * (n′ + j * d) m′ * n′ + (m′ * j + (n′ + j * d) * k) * d lemma = begin-equality - (m′ + k * d) * (n′ + j * d) ≡⟨ *-distribʳ-+ (n′ + j * d) m′ (k * d) - m′ * (n′ + j * d) + (k * d) * (n′ + j * d) ≡⟨ cong₂ _+_ (*-distribˡ-+ m′ n′ (j * d)) (*-comm (k * d) (n′ + j * d)) - (m′ * n′ + m′ * (j * d)) + (n′ + j * d) * (k * d) ≡⟨ +-assoc (m′ * n′) (m′ * (j * d)) ((n′ + j * d) * (k * d)) - m′ * n′ + (m′ * (j * d) + (n′ + j * d) * (k * d)) ≡⟨ cong (m′ * n′ +_) (cong₂ _+_ (*-assoc m′ j d) (*-assoc (n′ + j * d) k d)) - m′ * n′ + ((m′ * j) * d + ((n′ + j * d) * k) * d) ≡⟨ cong (m′ * n′ +_) (*-distribʳ-+ d (m′ * j) ((n′ + j * d) * k)) + (m′ + k * d) * (n′ + j * d) ≡⟨ *-distribʳ-+ (n′ + j * d) m′ (k * d) + m′ * (n′ + j * d) + (k * d) * (n′ + j * d) ≡⟨ cong₂ _+_ (*-distribˡ-+ m′ n′ (j * d)) (*-comm (k * d) (n′ + j * d)) + (m′ * n′ + m′ * (j * d)) + (n′ + j * d) * (k * d) ≡⟨ +-assoc (m′ * n′) (m′ * (j * d)) ((n′ + j * d) * (k * d)) + m′ * n′ + (m′ * (j * d) + (n′ + j * d) * (k * d)) ≡⟨ cong (m′ * n′ +_) (cong₂ _+_ (*-assoc m′ j d) (*-assoc (n′ + j * d) k d)) + m′ * n′ + ((m′ * j) * d + ((n′ + j * d) * k) * d) ≡⟨ cong (m′ * n′ +_) (*-distribʳ-+ d (m′ * j) ((n′ + j * d) * k)) m′ * n′ + (m′ * j + (n′ + j * d) * k) * d %-remove-+ˡ : {m} n {d} .{{_ : NonZero d}} d m (m + n) % d n % d %-remove-+ˡ {m@.(p * d)} n {d} (divides-refl p) = begin-equality (m + n) % d ≡⟨⟩ - (p * d + n) % d ≡⟨ cong (_% d) (+-comm (p * d) n) + (p * d + n) % d ≡⟨ cong (_% d) (+-comm (p * d) n) (n + p * d) % d ≡⟨ [m+kn]%n≡m%n n p d n % d %-remove-+ʳ : m {n d} .{{_ : NonZero d}} d n (m + n) % d m % d -%-remove-+ʳ m {n} rewrite +-comm m n = %-remove-+ˡ {n} m +%-remove-+ʳ m {n} rewrite +-comm m n = %-remove-+ˡ {n} m ------------------------------------------------------------------------ -- Properties of _/_ @@ -191,26 +191,26 @@ m/n*n≡m {n = n} (divides-refl q) = cong (_* n) (m*n/n≡m q n) m*[n/m]≡n : .{{_ : NonZero m}} m n m * (n / m) n -m*[n/m]≡n {m} m∣n = trans (*-comm m (_ / m)) (m/n*n≡m m∣n) +m*[n/m]≡n {m} m∣n = trans (*-comm m (_ / m)) (m/n*n≡m m∣n) m/n*n≤m : m n .{{_ : NonZero n}} (m / n) * n m m/n*n≤m m n = begin - (m / n) * n ≤⟨ m≤m+n ((m / n) * n) (m % n) - (m / n) * n + m % n ≡⟨ +-comm _ (m % n) + (m / n) * n ≤⟨ m≤m+n ((m / n) * n) (m % n) + (m / n) * n + m % n ≡⟨ +-comm _ (m % n) m % n + (m / n) * n ≡⟨ m≡m%n+[m/n]*n m n m m/n≤m : m n .{{_ : NonZero n}} (m / n) m -m/n≤m m n = *-cancelʳ-≤ (m / n) m n (begin +m/n≤m m n = *-cancelʳ-≤ (m / n) m n (begin (m / n) * n ≤⟨ m/n*n≤m m n - m ≤⟨ m≤m*n m n + m ≤⟨ m≤m*n m n m * n ) m/n<m : m n .{{_ : NonZero m}} .{{_ : NonZero n}} 1 < n m / n < m -m/n<m m n 1<n = *-cancelʳ-< _ (m / n) m $ begin-strict +m/n<m m n 1<n = *-cancelʳ-< _ (m / n) m $ begin-strict m / n * n ≤⟨ m/n*n≤m m n - m <⟨ m<m*n m n 1<n + m <⟨ m<m*n m n 1<n m * n /-mono-≤ : .{{_ : NonZero o}} .{{_ : NonZero p}} @@ -218,11 +218,11 @@ /-mono-≤ m≤n (s≤s o≥p) = divₕ-mono-≤ 0 m≤n o≥p /-monoˡ-≤ : o .{{_ : NonZero o}} m n m / o n / o -/-monoˡ-≤ o m≤n = /-mono-≤ m≤n (≤-refl {o}) +/-monoˡ-≤ o m≤n = /-mono-≤ m≤n (≤-refl {o}) /-monoʳ-≤ : m {n o} .{{_ : NonZero n}} .{{_ : NonZero o}} n o m / n m / o -/-monoʳ-≤ m n≥o = /-mono-≤ ≤-refl n≥o +/-monoʳ-≤ m n≥o = /-mono-≤ ≤-refl n≥o /-cancelʳ-≡ : {m n o} .{{_ : NonZero o}} o m o n m / o n / o m n @@ -242,14 +242,14 @@ m / n m/n≡0⇒m<n : {m n} .{{_ : NonZero n}} m / n 0 m < n -m/n≡0⇒m<n {m} {n@(suc _)} m/n≡0 with <-≤-connex m n +m/n≡0⇒m<n {m} {n@(suc _)} m/n≡0 with <-≤-connex m n ... | inj₁ m<n = m<n -... | inj₂ n≤m = contradiction m/n≡0 (≢-nonZero⁻¹ _) +... | inj₂ n≤m = contradiction m/n≡0 (≢-nonZero⁻¹ _) where instance _ = >-nonZero (m≥n⇒m/n>0 n≤m) m/n≢0⇒n≤m : {m n} .{{_ : NonZero n}} m / n 0 n m -m/n≢0⇒n≤m {m} {n@(suc _)} m/n≢0 with <-≤-connex m n -... | inj₁ m<n = contradiction (m<n⇒m/n≡0 m<n) m/n≢0 +m/n≢0⇒n≤m {m} {n@(suc _)} m/n≢0 with <-≤-connex m n +... | inj₁ m<n = contradiction (m<n⇒m/n≡0 m<n) m/n≢0 ... | inj₂ n≤m = n≤m +-distrib-/ : m n {d} .{{_ : NonZero d}} m % d + n % d < d @@ -269,7 +269,7 @@ +-distrib-/-∣ʳ m {n@.(p * d)} {d} (divides-refl p) = +-distrib-/ m n $ begin-strict m % d + n % d ≡⟨⟩ m % d + p * d % d ≡⟨ cong (m % d +_) (m*n%n≡0 p d) - m % d + 0 ≡⟨ +-identityʳ _ + m % d + 0 ≡⟨ +-identityʳ _ m % d <⟨ m%n<n m d d @@ -282,9 +282,9 @@ 1 + (m n) / n [m∸n]/n≡m/n∸1 : m n .{{_ : NonZero n}} (m n) / n pred (m / n) -[m∸n]/n≡m/n∸1 m n with <-≤-connex m n +[m∸n]/n≡m/n∸1 m n with <-≤-connex m n ... | inj₁ m<n = begin-equality - (m n) / n ≡⟨ m<n⇒m/n≡0 (≤-<-trans (m∸n≤m m n) m<n) + (m n) / n ≡⟨ m<n⇒m/n≡0 (≤-<-trans (m∸n≤m m n) m<n) 0 ≡⟨⟩ pred 0 ≡⟨ cong pred (m<n⇒m/n≡0 m<n) pred (m / n) @@ -298,7 +298,7 @@ m∣n⇒o%n%m≡o%m m n@.(p * m) o (divides-refl p) = begin-equality o % n % m ≡⟨⟩ o % pm % m ≡⟨ %-congˡ (m%n≡m∸m/n*n o pm) - (o o / pm * pm) % m ≡⟨ cong # (o #) % m) (*-assoc (o / pm) p m) + (o o / pm * pm) % m ≡⟨ cong # (o #) % m) (*-assoc (o / pm) p m) (o o / pm * p * m) % m ≡⟨ m*n≤o⇒[o∸m*n]%n≡o%n (o / pm * p) lem o % m where @@ -306,7 +306,7 @@ lem : o / pm * p * m o lem = begin - o / pm * p * m ≡⟨ *-assoc (o / pm) p m + o / pm * p * m ≡⟨ *-assoc (o / pm) p m o / pm * pm ≤⟨ m/n*n≤m o pm o @@ -314,50 +314,50 @@ (m * n) / (m * o) n / o m*n/m*o≡n/o m n o = helper (<-wellFounded n) where - instance _ = m*n≢0 m o + instance _ = m*n≢0 m o helper : {n} Acc _<_ n (m * n) / (m * o) n / o - helper {n} (acc rec) with <-≤-connex n o - ... | inj₁ n<o = trans (m<n⇒m/n≡0 (*-monoʳ-< m n<o)) (sym (m<n⇒m/n≡0 n<o)) - where instance _ = m*n≢0⇒m≢0 m + helper {n} (acc rec) with <-≤-connex n o + ... | inj₁ n<o = trans (m<n⇒m/n≡0 (*-monoʳ-< m n<o)) (sym (m<n⇒m/n≡0 n<o)) + where instance _ = m*n≢0⇒m≢0 m ... | inj₂ n≥o = begin-equality - (m * n) / (m * o) ≡⟨ m/n≡1+[m∸n]/n (*-monoʳ-≤ m n≥o) - 1 + (m * n m * o) / (m * o) ≡⟨ cong (suc (_/ (m * o))) (*-distribˡ-∸ m n o) + (m * n) / (m * o) ≡⟨ m/n≡1+[m∸n]/n (*-monoʳ-≤ m n≥o) + 1 + (m * n m * o) / (m * o) ≡⟨ cong (suc (_/ (m * o))) (*-distribˡ-∸ m n o) 1 + (m * (n o)) / (m * o) ≡⟨ cong suc (helper (rec n∸o<n)) 1 + (n o) / o ≡⟨ m/n≡1+[m∸n]/n n≥o n / o - where n∸o<n = ∸-monoʳ-< (n≢0⇒n>0 (≢-nonZero⁻¹ o)) n≥o + where n∸o<n = ∸-monoʳ-< (n≢0⇒n>0 (≢-nonZero⁻¹ o)) n≥o m*n/o*n≡m/o : m n o .{{_ : NonZero o}} .{{_ : NonZero (o * n)}} m * n / (o * n) m / o m*n/o*n≡m/o m n o = begin-equality - m * n / (o * n) ≡⟨ /-congˡ (*-comm m n) - n * m / (o * n) ≡⟨ /-congʳ (*-comm o n) + m * n / (o * n) ≡⟨ /-congˡ (*-comm m n) + n * m / (o * n) ≡⟨ /-congʳ (*-comm o n) n * m / (n * o) ≡⟨ m*n/m*o≡n/o n m o m / o where instance _ : NonZero n - _ = m*n≢0⇒n≢0 o + _ = m*n≢0⇒n≢0 o _ : NonZero (n * o) - _ = m*n≢0 n o + _ = m*n≢0 n o m<n*o⇒m/o<n : {m n o} .{{_ : NonZero o}} m < n * o m / o < n -m<n*o⇒m/o<n {m} {1} {o} m<o rewrite *-identityˡ o = begin-strict +m<n*o⇒m/o<n {m} {1} {o} m<o rewrite *-identityˡ o = begin-strict m / o ≡⟨ m<n⇒m/n≡0 m<o 0 <⟨ z<s 1 -m<n*o⇒m/o<n {m} {suc n@(suc _)} {o} m<n*o = pred-cancel-< $ begin-strict +m<n*o⇒m/o<n {m} {suc n@(suc _)} {o} m<n*o = pred-cancel-< $ begin-strict pred (m / o) ≡⟨ [m∸n]/n≡m/n∸1 m o - (m o) / o <⟨ m<n*o⇒m/o<n (m<n+o⇒m∸n<o m o m<n*o) + (m o) / o <⟨ m<n*o⇒m/o<n (m<n+o⇒m∸n<o m o m<n*o) n - where instance _ = m*n≢0 n o + where instance _ = m*n≢0 n o [m∸n*o]/o≡m/o∸n : m n o .{{_ : NonZero o}} (m n * o) / o m / o n [m∸n*o]/o≡m/o∸n m zero o = refl [m∸n*o]/o≡m/o∸n m (suc n) o = begin-equality - (m (o + n * o)) / o ≡⟨ /-congˡ (∸-+-assoc m o (n * o)) + (m (o + n * o)) / o ≡⟨ /-congˡ (∸-+-assoc m o (n * o)) (m o n * o) / o ≡⟨ [m∸n*o]/o≡m/o∸n (m o) n o (m o) / o n ≡⟨ cong (_∸ n) ([m∸n]/n≡m/n∸1 m o) - m / o 1 n ≡⟨ ∸-+-assoc (m / o) 1 n + m / o 1 n ≡⟨ ∸-+-assoc (m / o) 1 n m / o suc n m/n/o≡m/[n*o] : m n o .{{_ : NonZero n}} .{{_ : NonZero o}} @@ -376,21 +376,21 @@ lem₁ : n m / n*o * n*o lem₁ = divides (m / n*o * o) $ begin-equality - m / n*o * n*o ≡⟨ cong (m / n*o *_) (*-comm n o) - m / n*o * o*n ≡⟨ *-assoc (m / n*o) o n + m / n*o * n*o ≡⟨ cong (m / n*o *_) (*-comm n o) + m / n*o * o*n ≡⟨ *-assoc (m / n*o) o n m / n*o * o * n lem₂ : m / n*o * n*o / n m / n*o * o lem₂ = begin-equality - m / n*o * n*o / n ≡⟨ cong # m / n*o * # / n) (*-comm n o) - m / n*o * o*n / n ≡⟨ /-congˡ (*-assoc (m / n*o) o n) + m / n*o * n*o / n ≡⟨ cong # m / n*o * # / n) (*-comm n o) + m / n*o * o*n / n ≡⟨ /-congˡ (*-assoc (m / n*o) o n) m / n*o * o * n / n ≡⟨ m*n/n≡m (m / n*o * o) n m / n*o * o lem₃ : m % n*o < o*n lem₃ = begin-strict m % n*o <⟨ m%n<n m n*o - n*o ≡⟨ *-comm n o + n*o ≡⟨ *-comm n o o*n *-/-assoc : m {n d} .{{_ : NonZero d}} d n m * n / d m * (n / d) @@ -405,39 +405,39 @@ /-*-interchange {o} {p} {m@.(q * o)} {n@.(r * p)} (divides-refl q) (divides-refl r) = begin-equality (m * n) / (o * p) ≡⟨⟩ - q * o * (r * p) / (o * p) ≡⟨ /-congˡ ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) + q * o * (r * p) / (o * p) ≡⟨ /-congˡ ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) q * r * (o * p) / (o * p) ≡⟨ m*n/n≡m (q * r) (o * p) q * r ≡⟨ cong₂ _*_ (m*n/n≡m q o) (m*n/n≡m r p) (q * o / o) * (r * p / p) ≡⟨⟩ (m / o) * (n / p) m*n/m!≡n/[m∸1]! : m n .{{_ : NonZero m}} - let instance _ = m !≢0 ; instance _ = (pred m) !≢0 in + let instance _ = m !≢0 ; instance _ = (pred m) !≢0 in (m * n / m !) (n / (pred m) !) m*n/m!≡n/[m∸1]! m′@(suc m) n = m*n/m*o≡n/o m′ n (m !) where instance - _ = m !≢0 - _ = m′ !≢0 + _ = m !≢0 + _ = m′ !≢0 m%[n*o]/o≡m/o%n : m n o .{{_ : NonZero n}} .{{_ : NonZero o}} {{_ : NonZero (n * o)}} m % (n * o) / o m / o % n m%[n*o]/o≡m/o%n m n o = begin-equality m % (n * o) / o ≡⟨ /-congˡ (m%n≡m∸m/n*n m (n * o)) - (m (m / (n * o) * (n * o))) / o ≡⟨ cong # (m #) / o) (*-assoc (m / (n * o)) n o) + (m (m / (n * o) * (n * o))) / o ≡⟨ cong # (m #) / o) (*-assoc (m / (n * o)) n o) (m (m / (n * o) * n * o)) / o ≡⟨ [m∸n*o]/o≡m/o∸n m (m / (n * o) * n) o - m / o m / (n * o) * n ≡⟨ cong # m / o # * n) (/-congʳ (*-comm n o)) + m / o m / (n * o) * n ≡⟨ cong # m / o # * n) (/-congʳ (*-comm n o)) m / o m / (o * n) * n ≡⟨ cong # m / o # * n) (m/n/o≡m/[n*o] m o n ) m / o m / o / n * n ≡⟨ m%n≡m∸m/n*n (m / o) n m / o % n - where instance _ = m*n≢0 o n + where instance _ = m*n≢0 o n m%n*o≡m*o%[n*o] : m n o .{{_ : NonZero n}} .{{_ : NonZero (n * o)}} m % n * o m * o % (n * o) m%n*o≡m*o%[n*o] m n o = begin-equality m % n * o ≡⟨ cong (_* o) (m%n≡m∸m/n*n m n) - (m m / n * n) * o ≡⟨ *-distribʳ-∸ o m (m / n * n) + (m m / n * n) * o ≡⟨ *-distribʳ-∸ o m (m / n * n) m * o m / n * n * o ≡⟨ cong # m * o # * n * o) (m*n/o*n≡m/o m o n) - m * o m * o / (n * o) * n * o ≡⟨ cong (m * o ∸_) (*-assoc (m * o / (n * o)) n o) + m * o m * o / (n * o) * n * o ≡⟨ cong (m * o ∸_) (*-assoc (m * o / (n * o)) n o) m * o m * o / (n * o) * (n * o) ≡⟨ m%n≡m∸m/n*n (m * o) (n * o) m * o % (n * o) @@ -445,7 +445,7 @@ (m * n + o) % (p * n) (m * n) % (p * n) + o [m*n+o]%[p*n]≡[m*n]%[p*n]+o m {n} {o} p@(suc p-1) o<n = begin-equality (mn + o) % pn ≡⟨ %-distribˡ-+ mn o pn - (mn % pn + o % pn) % pn ≡⟨ cong # (mn % pn + #) % pn) (m<n⇒m%n≡m (m<n⇒m<o*n p o<n)) + (mn % pn + o % pn) % pn ≡⟨ cong # (mn % pn + #) % pn) (m<n⇒m%n≡m (m<n⇒m<o*n p o<n)) (mn % pn + o) % pn ≡⟨ m<n⇒m%n≡m lem₂ mn % pn + o where @@ -455,13 +455,13 @@ lem₁ : mn % pn p-1 * n lem₁ = begin mn % pn ≡⟨ m%n*o≡m*o%[n*o] m p n - (m % p) * n ≤⟨ *-monoˡ-≤ n (m<1+n⇒m≤n (m%n<n m p)) + (m % p) * n ≤⟨ *-monoˡ-≤ n (m<1+n⇒m≤n (m%n<n m p)) p-1 * n lem₂ : mn % pn + o < pn lem₂ = begin-strict - mn % pn + o <⟨ +-mono-≤-< lem₁ o<n - p-1 * n + n ≡⟨ +-comm (p-1 * n) n + mn % pn + o <⟨ +-mono-≤-< lem₁ o<n + p-1 * n + n ≡⟨ +-comm (p-1 * n) n pn ------------------------------------------------------------------------ @@ -475,7 +475,7 @@ property : dividend toℕ remainder + quotient * divisor nonZeroDivisor : NonZero divisor - nonZeroDivisor = nonZeroIndex remainder + nonZeroDivisor = nonZeroIndex remainder infixl 7 _div_ _mod_ _divMod_ @@ -490,7 +490,7 @@ DivMod dividend divisor m divMod n = result (m / n) (m mod n) $ begin-equality m ≡⟨ m≡m%n+[m/n]*n m n - m % n + [m/n]*n ≡⟨ cong (_+ [m/n]*n) (toℕ-fromℕ< [m%n]<n) + m % n + [m/n]*n ≡⟨ cong (_+ [m/n]*n) (toℕ-fromℕ< [m%n]<n) toℕ (fromℕ< [m%n]<n) + [m/n]*n where [m/n]*n = m / n * n ; [m%n]<n = m%n<n m n diff --git a/v2.3/Data.Nat.Divisibility.Core.html b/v2.3/Data.Nat.Divisibility.Core.html index d55aba2944..9bd09d24eb 100644 --- a/v2.3/Data.Nat.Divisibility.Core.html +++ b/v2.3/Data.Nat.Divisibility.Core.html @@ -14,7 +14,7 @@ module Data.Nat.Divisibility.Core where open import Data.Nat.Base using (; _*_; _<_; NonTrivial) -open import Data.Nat.Properties using ([m*n]*[o*p]≡[m*o]*[n*p]) +open import Data.Nat.Properties using ([m*n]*[o*p]≡[m*o]*[n*p]) open import Relation.Nullary.Negation using (¬_) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core @@ -74,7 +74,7 @@ *-pres-∣ : o m p n o * p m * n *-pres-∣ {o} {m@.(q * o)} {p} {n@.(r * p)} (divides-refl q) (divides-refl r) = - divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) + divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) {-# WARNING_ON_USAGE *-pres-∣ "Warning: *-pres-∣ was deprecated in v2.1. diff --git a/v2.3/Data.Nat.Divisibility.html b/v2.3/Data.Nat.Divisibility.html index 9b488dfced..ca3cb18bb1 100644 --- a/v2.3/Data.Nat.Divisibility.html +++ b/v2.3/Data.Nat.Divisibility.html @@ -17,7 +17,7 @@ open import Function.Bundles using (_⇔_; mk⇔) open import Level using (0ℓ) open import Relation.Nullary.Decidable as Dec using (yes; no) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Relation.Binary.Core using (_⇒_) open import Relation.Binary.Bundles using (Preorder; Poset) open import Relation.Binary.Structures @@ -41,31 +41,31 @@ open import Data.Nat.Divisibility.Core public hiding (*-pres-∣) quotient≢0 : (m∣n : m n) .{{NonZero n}} NonZero (quotient m∣n) -quotient≢0 m∣n rewrite _∣_.equality m∣n = m*n≢0⇒m≢0 (quotient m∣n) +quotient≢0 m∣n rewrite _∣_.equality m∣n = m*n≢0⇒m≢0 (quotient m∣n) m∣n⇒n≡quotient*m : (m∣n : m n) n (quotient m∣n) * m m∣n⇒n≡quotient*m m∣n = _∣_.equality m∣n m∣n⇒n≡m*quotient : (m∣n : m n) n m * (quotient m∣n) -m∣n⇒n≡m*quotient {m = m} m∣n rewrite _∣_.equality m∣n = *-comm (quotient m∣n) m +m∣n⇒n≡m*quotient {m = m} m∣n rewrite _∣_.equality m∣n = *-comm (quotient m∣n) m quotient-∣ : (m∣n : m n) (quotient m∣n) n quotient-∣ {m = m} m∣n = divides m (m∣n⇒n≡m*quotient m∣n) quotient>1 : (m∣n : m n) m < n 1 < quotient m∣n -quotient>1 {m} {n} m∣n m<n = *-cancelˡ-< m 1 (quotient m∣n) $ begin-strict - m * 1 ≡⟨ *-identityʳ m +quotient>1 {m} {n} m∣n m<n = *-cancelˡ-< m 1 (quotient m∣n) $ begin-strict + m * 1 ≡⟨ *-identityʳ m m <⟨ m<n n ≡⟨ m∣n⇒n≡m*quotient m∣n m * quotient m∣n - where open ≤-Reasoning + where open ≤-Reasoning quotient-< : (m∣n : m n) .{{NonTrivial m}} .{{NonZero n}} quotient m∣n < n quotient-< {m} {n} m∣n = begin-strict - quotient m∣n <⟨ m<m*n (quotient m∣n) m (nonTrivial⇒n>1 m) + quotient m∣n <⟨ m<m*n (quotient m∣n) m (nonTrivial⇒n>1 m) quotient m∣n * m ≡⟨ _∣_.equality m∣n n - where open ≤-Reasoning; instance _ = quotient≢0 m∣n + where open ≤-Reasoning; instance _ = quotient≢0 m∣n ------------------------------------------------------------------------ -- Relating _/_ and quotient @@ -93,10 +93,10 @@ -- Properties of _∣_ and _≤_ ∣⇒≤ : .{{_ : NonZero n}} m n m n -∣⇒≤ {n@.(q * m)} {m} (divides-refl q@(suc p)) = m≤m+n m (p * m) +∣⇒≤ {n@.(q * m)} {m} (divides-refl q@(suc p)) = m≤m+n m (p * m) >⇒∤ : .{{_ : NonZero n}} m > n m n ->⇒∤ {n@(suc _)} n<m@(s<s _) m∣n = contradiction (∣⇒≤ m∣n) (<⇒≱ n<m) +>⇒∤ {n@(suc _)} n<m@(s<s _) m∣n = contradiction (∣⇒≤ m∣n) (<⇒≱ n<m) ------------------------------------------------------------------------ -- _∣_ is a partial order @@ -104,19 +104,19 @@ -- these could/should inherit from Algebra.Properties.Monoid.Divisibility ∣-reflexive : _≡_ _∣_ -∣-reflexive {n} refl = divides 1 (sym (*-identityˡ n)) +∣-reflexive {n} refl = divides 1 (sym (*-identityˡ n)) ∣-refl : Reflexive _∣_ ∣-refl = ∣-reflexive refl ∣-trans : Transitive _∣_ ∣-trans (divides-refl p) (divides-refl q) = - divides (q * p) (sym (*-assoc q p _)) + divides (q * p) (sym (*-assoc q p _)) ∣-antisym : Antisymmetric _≡_ _∣_ ∣-antisym {m} {zero} _ q∣p = m∣n⇒n≡m*quotient q∣p ∣-antisym {zero} {n} p∣q _ = sym (m∣n⇒n≡m*quotient p∣q) -∣-antisym {suc m} {suc n} p∣q q∣p = ≤-antisym (∣⇒≤ p∣q) (∣⇒≤ q∣p) +∣-antisym {suc m} {suc n} p∣q q∣p = ≤-antisym (∣⇒≤ p∣q) (∣⇒≤ q∣p) infix 4 _∣?_ @@ -173,7 +173,7 @@ 0∣⇒≡0 {n} 0∣n = ∣-antisym (n ∣0) 0∣n 1∣_ : n 1 n -1∣ n = divides n (sym (*-identityʳ n)) +1∣ n = divides n (sym (*-identityʳ n)) ∣1⇒≡1 : n 1 n 1 ∣1⇒≡1 {n} n∣1 = ∣-antisym n∣1 (1∣ n) @@ -186,15 +186,15 @@ ∣m∣n⇒∣m+n : d m d n d m + n ∣m∣n⇒∣m+n (divides-refl p) (divides-refl q) = - divides (p + q) (sym (*-distribʳ-+ _ p q)) + divides (p + q) (sym (*-distribʳ-+ _ p q)) ∣m+n∣m⇒∣n : d m + n d m d n ∣m+n∣m⇒∣n {d} {m} {n} (divides p m+n≡p*d) (divides-refl q) = divides (p q) $ begin-equality - n ≡⟨ m+n∸n≡m n m - n + m m ≡⟨ cong (_∸ m) (+-comm n m) + n ≡⟨ m+n∸n≡m n m + n + m m ≡⟨ cong (_∸ m) (+-comm n m) m + n m ≡⟨ cong (_∸ m) m+n≡p*d - p * d q * d ≡⟨ *-distribʳ-∸ d p q + p * d q * d ≡⟨ *-distribʳ-∸ d p q (p q) * d where open ∣-Reasoning @@ -205,7 +205,7 @@ n∣m*n m = divides m refl m∣m*n : {m} n m m * n -m∣m*n n = divides n (*-comm _ n) +m∣m*n n = divides n (*-comm _ n) n∣m*n*o : m {n} o n m * n * o n∣m*n*o m o = ∣-trans (n∣m*n m) (m∣m*n o) @@ -214,17 +214,17 @@ ∣m⇒∣m*n n (divides-refl q) = ∣-trans (n∣m*n q) (m∣m*n n) ∣n⇒∣m*n : m {n} d n d m * n -∣n⇒∣m*n m {n} rewrite *-comm m n = ∣m⇒∣m*n m +∣n⇒∣m*n m {n} rewrite *-comm m n = ∣m⇒∣m*n m m*n∣⇒m∣ : m n m * n d m d m*n∣⇒m∣ m n (divides-refl q) = ∣n⇒∣m*n q (m∣m*n n) m*n∣⇒n∣ : m n m * n d n d -m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m +m*n∣⇒n∣ m n rewrite *-comm m n = m*n∣⇒m∣ n m *-pres-∣ : o m p n o * p m * n *-pres-∣ {o} {m@.(q * o)} {p} {n@.(r * p)} (divides-refl q) (divides-refl r) = - divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) + divides (q * r) ([m*n]*[o*p]≡[m*o]*[n*p] q o r p) *-monoʳ-∣ : o m n o * m o * n *-monoʳ-∣ o = *-pres-∣ (∣-refl {o}) @@ -233,17 +233,17 @@ *-monoˡ-∣ o = flip *-pres-∣ (∣-refl {o}) *-cancelˡ-∣ : o .{{_ : NonZero o}} o * m o * n m n -*-cancelˡ-∣ {m} {n} o o*m∣o*n = divides q $ *-cancelˡ-≡ n (q * m) o $ begin-equality +*-cancelˡ-∣ {m} {n} o o*m∣o*n = divides q $ *-cancelˡ-≡ n (q * m) o $ begin-equality o * n ≡⟨ m∣n⇒n≡m*quotient o*m∣o*n - o * m * q ≡⟨ *-assoc o m q - o * (m * q) ≡⟨ cong (o *_) (*-comm q m) + o * m * q ≡⟨ *-assoc o m q + o * (m * q) ≡⟨ cong (o *_) (*-comm q m) o * (q * m) where open ∣-Reasoning q = quotient o*m∣o*n *-cancelʳ-∣ : o .{{_ : NonZero o}} m * o n * o m n -*-cancelʳ-∣ {m} {n} o rewrite *-comm m o | *-comm n o = *-cancelˡ-∣ o +*-cancelʳ-∣ {m} {n} o rewrite *-comm m o | *-comm n o = *-cancelˡ-∣ o ------------------------------------------------------------------------ -- Properties of _∣_ and _∸_ @@ -251,10 +251,10 @@ ∣m∸n∣n⇒∣m : d n m d m n d n d m ∣m∸n∣n⇒∣m {n} {m} d n≤m (divides p m∸n≡p*d) (divides-refl q) = divides (p + q) $ begin-equality - m ≡⟨ m+[n∸m]≡n n≤m - n + (m n) ≡⟨ +-comm n (m n) + m ≡⟨ m+[n∸m]≡n n≤m + n + (m n) ≡⟨ +-comm n (m n) m n + n ≡⟨ cong (_+ n) m∸n≡p*d - p * d + q * d ≡⟨ *-distribʳ-+ d p q + p * d + q * d ≡⟨ *-distribʳ-+ d p q (p + q) * d where open ∣-Reasoning @@ -276,7 +276,7 @@ where open ∣-Reasoning m*n∣o⇒n∣o/m : m n .{{_ : NonZero m}} m * n o n (o / m) -m*n∣o⇒n∣o/m m n rewrite *-comm m n = m*n∣o⇒m∣o/n n m +m*n∣o⇒n∣o/m m n rewrite *-comm m n = m*n∣o⇒m∣o/n n m m∣n/o⇒m*o∣n : .{{_ : NonZero o}} o n m n / o m * o n m∣n/o⇒m*o∣n {o} {n@.(p * o)} {m} (divides-refl p) m∣p*o/o = begin @@ -285,7 +285,7 @@ where open ∣-Reasoning m∣n/o⇒o*m∣n : .{{_ : NonZero o}} o n m n / o o * m n -m∣n/o⇒o*m∣n {o} {_} {m} rewrite *-comm o m = m∣n/o⇒m*o∣n +m∣n/o⇒o*m∣n {o} {_} {m} rewrite *-comm o m = m∣n/o⇒m*o∣n m/n∣o⇒m∣o*n : .{{_ : NonZero n}} n m m / n o m o * n m/n∣o⇒m∣o*n {n} {m@.(p * n)} {o} (divides-refl p) p*n/n∣o = begin @@ -310,8 +310,8 @@ m ≡⟨ m≡m%n+[m/n]*n m n m % n + (m / n) * n ≡⟨ cong (_+ (m / n) * n) m%n≡qd q * d + (m / n) * n ≡⟨⟩ - q * d + (m / n) * (p * d) ≡⟨ cong (q * d +_) (*-assoc (m / n) p d) - q * d + ((m / n) * p) * d ≡⟨ *-distribʳ-+ d q _ + q * d + (m / n) * (p * d) ≡⟨ cong (q * d +_) (*-assoc (m / n) p d) + q * d + ((m / n) * p) * d ≡⟨ *-distribʳ-+ d q _ (q + (m / n) * p) * d where open ∣-Reasoning @@ -320,9 +320,9 @@ divides (p m / n * q) $ begin-equality m % n ≡⟨ m%n≡m∸m/n*n m n m m / n * n ≡⟨ cong v m m / n * v) 1+n≡qd - m m / n * (q * d) ≡⟨ cong (m ∸_) (*-assoc (m / n) q d) + m m / n * (q * d) ≡⟨ cong (m ∸_) (*-assoc (m / n) q d) m (m / n * q) * d ≡⟨⟩ - p * d (m / n * q) * d ≡⟨ *-distribʳ-∸ d p (m / n * q) + p * d (m / n * q) * d ≡⟨ *-distribʳ-∸ d p (m / n * q) (p m / n * q) * d where open ∣-Reasoning @@ -330,7 +330,7 @@ -- Properties of _∣_ and !_ m≤n⇒m!∣n! : m n m ! n ! -m≤n⇒m!∣n! m≤n = help (≤⇒≤′ m≤n) +m≤n⇒m!∣n! m≤n = help (≤⇒≤′ m≤n) where help : m ≤′ n m ! n ! help ≤′-refl = ∣-refl @@ -344,7 +344,7 @@ hasNonTrivialDivisor-≢ : .{{NonTrivial d}} .{{NonZero n}} d n d n n HasNonTrivialDivisorLessThan n hasNonTrivialDivisor-≢ d≢n d∣n - = hasNonTrivialDivisor (≤∧≢⇒< (∣⇒≤ d∣n) d≢n) d∣n + = hasNonTrivialDivisor (≤∧≢⇒< (∣⇒≤ d∣n) d≢n) d∣n -- Monotonicity wrt ∣ @@ -358,5 +358,5 @@ hasNonTrivialDivisor-≤ : m HasNonTrivialDivisorLessThan n n o m HasNonTrivialDivisorLessThan o hasNonTrivialDivisor-≤ (hasNonTrivialDivisor d<n d∣m) n≤o - = hasNonTrivialDivisor (<-≤-trans d<n n≤o) d∣m + = hasNonTrivialDivisor (<-≤-trans d<n n≤o) d∣m \ No newline at end of file diff --git a/v2.3/Data.Nat.GCD.Lemmas.html b/v2.3/Data.Nat.GCD.Lemmas.html index aaa6b48060..4f1b96ac1a 100644 --- a/v2.3/Data.Nat.GCD.Lemmas.html +++ b/v2.3/Data.Nat.GCD.Lemmas.html @@ -23,14 +23,14 @@ private comm-factor : x k n x * k + x * n x * (n + k) comm-factor x k n = begin - x * k + x * n ≡⟨ +-comm (x * k) _ - x * n + x * k ≡⟨ *-distribˡ-+ x n k + x * k + x * n ≡⟨ +-comm (x * k) _ + x * n + x * k ≡⟨ *-distribˡ-+ x n k x * (n + k) distrib-comm₂ : d x k n d + x * (n + k) d + x * k + x * n distrib-comm₂ d x k n = begin d + x * (n + k) ≡⟨ cong (d +_) (comm-factor x k n) - d + (x * k + x * n) ≡⟨ +-assoc d _ _ + d + (x * k + x * n) ≡⟨ +-assoc d _ _ d + x * k + x * n -- Other properties @@ -38,23 +38,23 @@ -- handle ∸ would be nice... lem₀ : i j m n i * m j * m + n (i j) * m n lem₀ i j m n eq = begin - (i j) * m ≡⟨ *-distribʳ-∸ m i j + (i j) * m ≡⟨ *-distribʳ-∸ m i j (i * m) (j * m) ≡⟨ cong (_∸ j * m) eq - (j * m + n) (j * m) ≡⟨ cong (_∸ j * m) (+-comm (j * m) n) - (n + j * m) (j * m) ≡⟨ m+n∸n≡m n (j * m) + (j * m + n) (j * m) ≡⟨ cong (_∸ j * m) (+-comm (j * m) n) + (n + j * m) (j * m) ≡⟨ m+n∸n≡m n (j * m) n lem₁ : i j 2 + i ≤′ 2 + j + i -lem₁ i j = ≤⇒≤′ $ s≤s $ s≤s $ m≤n+m i j +lem₁ i j = ≤⇒≤′ $ s≤s $ s≤s $ m≤n+m i j private times2 : x x + x 2 * x - times2 x = cong (x +_) (sym (+-identityʳ x)) + times2 x = cong (x +_) (sym (+-identityʳ x)) times2′ : x y x * y + x * y 2 * x * y times2′ x y = begin x * y + x * y ≡⟨ times2 (x * y) - 2 * (x * y) ≡⟨ *-assoc 2 x y + 2 * (x * y) ≡⟨ *-assoc 2 x y 2 * x * y lem₂ : d x {k n} @@ -68,64 +68,64 @@ private distrib₃ : a b c x (a + b + c) * x a * x + b * x + c * x distrib₃ a b c x = begin - (a + b + c) * x ≡⟨ *-distribʳ-+ x (a + b) c - (a + b) * x + c * x ≡⟨ cong (_+ c * x) (*-distribʳ-+ x a b) + (a + b + c) * x ≡⟨ *-distribʳ-+ x (a + b) c + (a + b) * x + c * x ≡⟨ cong (_+ c * x) (*-distribʳ-+ x a b) a * x + b * x + c * x lem₃₁ : a b c a + (b + c) b + a + c lem₃₁ a b c = begin - a + (b + c) ≡⟨ +-assoc a b c - (a + b) + c ≡⟨ cong (_+ c) (+-comm a b) + a + (b + c) ≡⟨ +-assoc a b c + (a + b) + c ≡⟨ cong (_+ c) (+-comm a b) b + a + c +-assoc-comm : a b c d a + (b + c + d) (a + c) + (b + d) +-assoc-comm a b c d = begin - a + (b + c + d) ≡⟨ cong (a +_) (cong (_+ d) (+-comm b c)) - a + (c + b + d) ≡⟨ cong (a +_) (+-assoc c b d) - a + (c + (b + d)) ≡⟨ +-assoc a c _ + a + (b + c + d) ≡⟨ cong (a +_) (cong (_+ d) (+-comm b c)) + a + (c + b + d) ≡⟨ cong (a +_) (+-assoc c b d) + a + (c + (b + d)) ≡⟨ +-assoc a c _ (a + c) + (b + d) *-on-right : a b c {d} b * c d a * b * c a * d *-on-right a b c {d} eq = begin - a * b * c ≡⟨ *-assoc a b c + a * b * c ≡⟨ *-assoc a b c a * (b * c) ≡⟨ cong (a *_) eq a * d *-on-left : a b c {d} a * b d a * (b * c) d * c *-on-left a b c {d} eq = begin - a * (b * c) ≡⟨ *-assoc a b c + a * (b * c) ≡⟨ *-assoc a b c a * b * c ≡⟨ cong (_* c) eq d * c +-on-right : a b c {d} b + c d a + b + c a + d +-on-right a b c {d} eq = begin - a + b + c ≡⟨ +-assoc a b c + a + b + c ≡⟨ +-assoc a b c a + (b + c) ≡⟨ cong (a +_) eq a + d +-on-left : a b c d a + b d a + (b + c) d + c +-on-left a b c d eq = begin - a + (b + c) ≡⟨ +-assoc a b c + a + (b + c) ≡⟨ +-assoc a b c a + b + c ≡⟨ cong (_+ c) eq d + c +-focus-mid : a b c d a + b + c + d a + (b + c) + d +-focus-mid a b c d = begin - a + b + c + d ≡⟨ cong (_+ d) (+-assoc a b c) + a + b + c + d ≡⟨ cong (_+ d) (+-assoc a b c) a + (b + c) + d +-assoc-comm′ : a b c d a + b + c + d a + (b + d) + c +-assoc-comm′ a b c d = begin - a + b + c + d ≡⟨ +-on-left a (b + c) d (a + b + c) (sym $ +-assoc a b c) - a + (b + c + d) ≡⟨ cong (a +_) (+-on-right b c d (+-comm c d)) - a + (b + (d + c)) ≡⟨ cong (a +_) (+-assoc b d c) - a + (b + d + c) ≡⟨ +-assoc a _ c + a + b + c + d ≡⟨ +-on-left a (b + c) d (a + b + c) (sym $ +-assoc a b c) + a + (b + c + d) ≡⟨ cong (a +_) (+-on-right b c d (+-comm c d)) + a + (b + (d + c)) ≡⟨ cong (a +_) (+-assoc b d c) + a + (b + d + c) ≡⟨ +-assoc a _ c a + (b + d) + c lem₃₂ : a b c n a * n + (b * n + a * n + c * n) (a + a + (b + c)) * n lem₃₂ a b c n = begin a * n + (b * n + a * n + c * n) ≡⟨ cong (a * n +_) (distrib₃ b a c n) - a * n + (b + a + c) * n ≡⟨ *-distribʳ-+ n a _ + a * n + (b + a + c) * n ≡⟨ *-distribʳ-+ n a _ (a + (b + a + c)) * n ≡⟨ cong (_* n) (+-assoc-comm a b a c) (a + a + (b + c)) * n @@ -138,8 +138,8 @@ mid-to-left : a b c a + 2 * b + c b + (a + b + c) mid-to-left a b c = begin a + 2 * b + c ≡⟨ cong x a + x + c) (times2 b) - a + (b + b) + c ≡⟨ cong (_+ c) (+-on-left a b b _ (+-comm a b)) - b + a + b + c ≡⟨ +-on-left b (a + b) c (b + a + b) (sym $ +-assoc b a b) + a + (b + b) + c ≡⟨ cong (_+ c) (+-on-left a b b _ (+-comm a b)) + b + a + b + c ≡⟨ +-on-left b (a + b) c (b + a + b) (sym $ +-assoc b a b) b + (a + b + c) lem₃ : d x {i k n} @@ -161,7 +161,7 @@ lem₄ d y {k} {i} n eq = begin d + y * (n + k) ≡⟨ distrib-comm₂ d y k n d + y * k + y * n ≡⟨ cong (_+ y * n) eq - (1 + y + i) * n + y * n ≡⟨ *-distribʳ-+ n (1 + y + i) y + (1 + y + i) * n + y * n ≡⟨ *-distribʳ-+ n (1 + y + i) y (1 + y + i + y) * n ≡⟨ cong (_* n) (mid-to-right 1 y i) (1 + 2 * y + i) * n @@ -170,7 +170,7 @@ d + 2 * x * n x * (n + k) lem₅ d x {n} {k} eq = begin d + 2 * x * n ≡⟨ cong (d +_) (times2′ x n) - d + (x * n + x * n) ≡⟨ +-assoc d (x * n) _ + d + (x * n + x * n) ≡⟨ +-assoc d (x * n) _ d + x * n + x * n ≡⟨ cong (_+ x * n) eq x * k + x * n ≡⟨ comm-factor x k n x * (n + k) @@ -180,7 +180,7 @@ d + (1 + 2 * x + i) * n (1 + x + i) * (n + k) lem₆ d x {n} {i} {k} eq = begin d + (1 + 2 * x + i) * n ≡⟨ cong z d + z * n) (mid-to-left 1 x i) - d + (x + y) * n ≡⟨ cong (d +_) (*-distribʳ-+ n x y) + d + (x + y) * n ≡⟨ cong (d +_) (*-distribʳ-+ n x y) d + (x * n + y * n) ≡⟨ +-on-left d _ _ _ eq y * k + y * n ≡⟨ comm-factor y k n y * (n + k) @@ -191,7 +191,7 @@ d + (1 + 2 * y + i) * n y * (n + k) lem₇ d y {i} n {k} eq = begin d + (1 + 2 * y + i) * n ≡⟨ cong z d + z * n) (mid-to-right 1 y i) - d + (1 + y + i + y) * n ≡⟨ cong (d +_) (*-distribʳ-+ n (1 + y + i) y) + d + (1 + y + i + y) * n ≡⟨ cong (d +_) (*-distribʳ-+ n (1 + y + i) y) d + ((1 + y + i) * n + y * n) ≡⟨ +-on-left d _ _ _ eq y * k + y * n ≡⟨ comm-factor y k n y * (n + k) @@ -203,12 +203,12 @@ sym (lem₀ (x * k) (y * q) i k lemma) where lemma = begin - x * k * i ≡⟨ *-on-right x k i (*-comm k i) + x * k * i ≡⟨ *-on-right x k i (*-comm k i) x * (i * k) ≡⟨ *-on-left x i k (sym eq) - (1 + y * j) * k ≡⟨ +-comm k _ - (y * j) * k + k ≡⟨ cong (_+ k) (*-assoc y j k) + (1 + y * j) * k ≡⟨ +-comm k _ + (y * j) * k + k ≡⟨ cong (_+ k) (*-assoc y j k) y * (j * k) + k ≡⟨ cong n y * n + k) eq′ - y * (q * i) + k ≡⟨ cong (_+ k) (*-assoc y q i) + y * (q * i) + k ≡⟨ cong (_+ k) (*-assoc y q i) y * q * i + k lem₉ : {i j k q} x y @@ -219,38 +219,38 @@ where lem : a b c a * b * c b * c * a lem a b c = begin - a * b * c ≡⟨ *-assoc a b c - a * (b * c) ≡⟨ *-comm a _ + a * b * c ≡⟨ *-assoc a b c + a * (b * c) ≡⟨ *-comm a _ b * c * a lemma = begin y * q * i ≡⟨ lem y q i q * i * y ≡⟨ cong n n * y) eq′ j * k * y ≡⟨ lem y j k y * j * k ≡⟨ cong n n * k) eq - (1 + x * i) * k ≡⟨ +-comm k _ - x * i * k + k ≡⟨ cong (_+ k) (*-on-right x i k (*-comm i k)) - x * (k * i) + k ≡⟨ cong (_+ k) (*-assoc x k i) + (1 + x * i) * k ≡⟨ +-comm k _ + x * i * k + k ≡⟨ cong (_+ k) (*-on-right x i k (*-comm i k)) + x * (k * i) + k ≡⟨ cong (_+ k) (*-assoc x k i) x * k * i + k lem₁₀ : {a′} b c {d} e f let a = suc a′ in a + b * (c * d * a) e * (f * d * a) d 1 lem₁₀ {a′} b c {d} e f eq = - m*n≡1⇒n≡1 (e * f b * c) d + m*n≡1⇒n≡1 (e * f b * c) d (lem₀ (e * f) (b * c) d 1 - (*-cancelʳ-≡ (e * f * d) (b * c * d + 1) _ (begin + (*-cancelʳ-≡ (e * f * d) (b * c * d + 1) _ (begin e * f * d * a ≡⟨ *-assoc₄₃ e f d a e * (f * d * a) ≡⟨ eq a + b * (c * d * a) ≡⟨ cong (a +_) (*-assoc₄₃ b c d a) - a + b * c * d * a ≡⟨ +-comm a _ - b * c * d * a + a ≡⟨ cong (b * c * d * a +_) (+-identityʳ a) - b * c * d * a + (a + 0) ≡⟨ *-distribʳ-+ a (b * c * d) 1 + a + b * c * d * a ≡⟨ +-comm a _ + b * c * d * a + a ≡⟨ cong (b * c * d * a +_) (+-identityʳ a) + b * c * d * a + (a + 0) ≡⟨ *-distribʳ-+ a (b * c * d) 1 (b * c * d + 1) * a ))) where a = suc a′ *-assoc₄₃ : w x y z w * x * y * z w * (x * y * z) *-assoc₄₃ w x y z = begin - w * x * y * z ≡⟨ cong (_* z) (*-assoc w x y) - w * (x * y) * z ≡⟨ *-assoc w _ z + w * x * y * z ≡⟨ cong (_* z) (*-assoc w x y) + w * (x * y) * z ≡⟨ *-assoc w _ z w * (x * y * z) lem₁₁ : {i j m n k d} x y @@ -260,9 +260,9 @@ sym (lem₀ (x * m) (y * n) d k (begin x * m * d ≡⟨ *-on-right x m d (sym eq₁) x * (i * k) ≡⟨ *-on-left x i k (sym eq) - (1 + y * j) * k ≡⟨ +-comm k _ - y * j * k + k ≡⟨ cong (_+ k) (*-assoc y j k) + (1 + y * j) * k ≡⟨ +-comm k _ + y * j * k + k ≡⟨ cong (_+ k) (*-assoc y j k) y * (j * k) + k ≡⟨ cong p y * p + k) eq₂ - y * (n * d) + k ≡⟨ cong (_+ k) (*-assoc y n d) + y * (n * d) + k ≡⟨ cong (_+ k) (*-assoc y n d) y * n * d + k )) \ No newline at end of file diff --git a/v2.3/Data.Nat.GCD.html b/v2.3/Data.Nat.GCD.html index 2609581ada..0d41b09407 100644 --- a/v2.3/Data.Nat.GCD.html +++ b/v2.3/Data.Nat.GCD.html @@ -28,7 +28,7 @@ open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning) open import Relation.Nullary.Decidable.Core using (Dec) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) import Relation.Nullary.Decidable as Dec open import Algebra.Definitions {A = } _≡_ as Algebra @@ -49,7 +49,7 @@ gcd′ m n@(suc _) (acc rec) n<m = gcd′ n (m % n) (rec n<m) (m%n<n m n) gcd : -gcd m n with <-cmp m n +gcd m n with <-cmp m n ... | tri< m<n _ _ = gcd′ n m (<-wellFounded-fast n) m<n ... | tri≈ _ _ _ = m ... | tri> _ _ n<m = gcd′ m n (<-wellFounded-fast m) n<m @@ -72,19 +72,19 @@ -- Core properties of gcd gcd[m,n]∣m : m n gcd m n m -gcd[m,n]∣m m n with <-cmp m n +gcd[m,n]∣m m n with <-cmp m n ... | tri< n<m _ _ = proj₂ (gcd′[m,n]∣m,n {n} {m} _ _) ... | tri≈ _ _ _ = ∣-refl ... | tri> _ _ m<n = proj₁ (gcd′[m,n]∣m,n {m} {n} _ _) gcd[m,n]∣n : m n gcd m n n -gcd[m,n]∣n m n with <-cmp m n +gcd[m,n]∣n m n with <-cmp m n ... | tri< n<m _ _ = proj₁ (gcd′[m,n]∣m,n {n} {m} _ _) ... | tri≈ _ ≡.refl _ = ∣-refl ... | tri> _ _ m<n = proj₂ (gcd′[m,n]∣m,n {m} {n} _ _) gcd-greatest : {m n c} c m c n c gcd m n -gcd-greatest {m} {n} c∣m c∣n with <-cmp m n +gcd-greatest {m} {n} c∣m c∣n with <-cmp m n ... | tri< n<m _ _ = gcd′-greatest _ _ c∣n c∣m ... | tri≈ _ _ _ = c∣m ... | tri> _ _ m<n = gcd′-greatest _ _ c∣m c∣n @@ -104,11 +104,11 @@ gcd[m,n]≡0⇒m≡0 : {m n} gcd m n 0 m 0 gcd[m,n]≡0⇒m≡0 {zero} {n} eq = ≡.refl -gcd[m,n]≡0⇒m≡0 {suc m} {n} eq = contradiction eq (gcd[m,n]≢0 (suc m) n (inj₁ λ())) +gcd[m,n]≡0⇒m≡0 {suc m} {n} eq = contradiction eq (gcd[m,n]≢0 (suc m) n (inj₁ λ())) gcd[m,n]≡0⇒n≡0 : m {n} gcd m n 0 n 0 gcd[m,n]≡0⇒n≡0 m {zero} eq = ≡.refl -gcd[m,n]≡0⇒n≡0 m {suc n} eq = contradiction eq (gcd[m,n]≢0 m (suc n) (inj₂ λ())) +gcd[m,n]≡0⇒n≡0 m {suc n} eq = contradiction eq (gcd[m,n]≢0 m (suc n) (inj₂ λ())) gcd-comm : Commutative gcd gcd-comm m n = ∣-antisym @@ -200,7 +200,7 @@ n/gcd[m,n]≢0 : m n .{{_ : NonZero n}} .{{gcd≢0 : NonZero (gcd m n)}} n / gcd m n 0 -n/gcd[m,n]≢0 m n = m<n⇒n≢0 (m≥n⇒m/n>0 {n} {gcd m n} (gcd[m,n]≤n m n)) +n/gcd[m,n]≢0 m n = m<n⇒n≢0 (m≥n⇒m/n>0 {n} {gcd m n} (gcd[m,n]≤n m n)) m/gcd[m,n]≢0 : m n .{{_ : NonZero m}} .{{gcd≢0 : NonZero (gcd m n)}} m / gcd m n 0 @@ -372,7 +372,7 @@ stepˡ : {n k} Lemma n (suc k) Lemma n (suc (n + k)) stepˡ {n} {k} (result d g b) = - subst (Lemma n) (+-suc n k) $ + subst (Lemma n) (+-suc n k) $ result d (GCD.step g) (Identity.step b) stepʳ : {n k} Lemma (suc k) n Lemma (suc (n + k)) n diff --git a/v2.3/Data.Nat.GeneralisedArithmetic.html b/v2.3/Data.Nat.GeneralisedArithmetic.html index 8ea11cef31..049ab2f911 100644 --- a/v2.3/Data.Nat.GeneralisedArithmetic.html +++ b/v2.3/Data.Nat.GeneralisedArithmetic.html @@ -11,7 +11,7 @@ open import Data.Nat.Base using (; zero; suc; _+_; _*_; _^_) open import Data.Nat.Properties - using (+-comm; +-assoc; *-identityˡ; *-assoc) + using (+-comm; +-assoc; *-identityˡ; *-assoc) open import Function.Base using (_∘′_; _∘_; id) open import Level using (Level) open import Relation.Binary.PropositionalEquality.Core @@ -73,7 +73,7 @@ iterate-is-fold : (z : A) s m fold z s m iterate s z m iterate-is-fold z s zero = refl iterate-is-fold z s (suc m) = begin - fold z s (suc m) ≡⟨ cong (fold z s) (+-comm 1 m) + fold z s (suc m) ≡⟨ cong (fold z s) (+-comm 1 m) fold z s (m + 1) ≡⟨ fold-+ z s m fold (s z) s m ≡⟨ iterate-is-fold (s z) s m iterate s (s z) m @@ -97,14 +97,14 @@ *+-is-fold : m n {p} fold p (n +_) m m * n + p *+-is-fold m n {p} = begin fold p (n +_) m ≡⟨ fold-pull _ _ _+_ p refl - l sym (+-assoc n l p)) m + l sym (+-assoc n l p)) m fold 0 (n +_) m + p ≡⟨ cong (_+ p) (*-is-fold m) m * n + p ^*-is-fold : m n {p} fold p (m *_) n m ^ n * p ^*-is-fold m n {p} = begin - fold p (m *_) n ≡⟨ fold-pull _ _ _*_ p (*-identityˡ p) - l sym (*-assoc m l p)) n + fold p (m *_) n ≡⟨ fold-pull _ _ _*_ p (*-identityˡ p) + l sym (*-assoc m l p)) n fold 1 (m *_) n * p ≡⟨ cong (_* p) (^-is-fold n) m ^ n * p \ No newline at end of file diff --git a/v2.3/Data.Nat.Induction.html b/v2.3/Data.Nat.Induction.html index fbb78e1888..7e21e38c68 100644 --- a/v2.3/Data.Nat.Induction.html +++ b/v2.3/Data.Nat.Induction.html @@ -10,7 +10,7 @@ module Data.Nat.Induction where open import Data.Nat.Base -open import Data.Nat.Properties using (<⇒<′) +open import Data.Nat.Properties using (<⇒<′) open import Data.Product.Base using (_×_; _,_) open import Data.Unit.Polymorphic.Base using () open import Induction using (RecStruct; RecursorBuilder; Recursor; build) @@ -85,7 +85,7 @@ <-Rec = WfRec _<_ <-wellFounded : WellFounded _<_ -<-wellFounded = Subrelation.wellFounded <⇒<′ <′-wellFounded +<-wellFounded = Subrelation.wellFounded <⇒<′ <′-wellFounded -- A version of `<-wellFounded` that cheats by skipping building -- the first billion proofs. Use this when you require the function diff --git a/v2.3/Data.Nat.InfinitelyOften.html b/v2.3/Data.Nat.InfinitelyOften.html index b0750ef970..a9eda26da8 100644 --- a/v2.3/Data.Nat.InfinitelyOften.html +++ b/v2.3/Data.Nat.InfinitelyOften.html @@ -18,9 +18,9 @@ open import Level using (Level; 0ℓ) open import Relation.Binary.PropositionalEquality.Core using (_≢_) open import Relation.Nullary.Negation using (¬¬-Monad; call/cc) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary using (Pred; _∪_; _⊆_) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open RawMonad (¬¬-Monad {a = 0ℓ}) @@ -45,15 +45,15 @@ _∪-Fin_ : {ℓp ℓq P Q} Fin {ℓp} P Fin {ℓq} Q Fin (P Q) _∪-Fin_ {P = P} {Q} (i , ¬p) (j , ¬q) = (i j , helper) where - open ≤-Reasoning + open ≤-Reasoning helper : k i j k ¬ (P Q) k helper k i⊔j≤k (inj₁ p) = ¬p k (begin - i ≤⟨ m≤m⊔n i j + i ≤⟨ m≤m⊔n i j i j ≤⟨ i⊔j≤k k ) p helper k i⊔j≤k (inj₂ q) = ¬q k (begin - j ≤⟨ m≤m⊔n j i + j ≤⟨ m≤m⊔n j i j i ≡⟨ ⊔-comm j i i j ≤⟨ i⊔j≤k k ) q @@ -63,7 +63,7 @@ commutes-with-∪ : {P Q} Inf (P Q) ¬ ¬ (Inf P Inf Q) commutes-with-∪ p∪q = call/cc λ ¬[p⊎q] - ¬p ¬q contradiction (¬p ∪-Fin ¬q) p∪q) + ¬p ¬q contradiction (¬p ∪-Fin ¬q) p∪q) <$> ¬[p⊎q] inj₁ ¬[p⊎q] inj₂ -- Inf is functorial. @@ -95,5 +95,5 @@ twoDifferentWitnesses inf = witness inf >>= λ w₁ witness (up (1 + proj₁ w₁) inf) >>= λ w₂ - pure (_ , _ , m≢1+m+n (proj₁ w₁) , proj₂ w₁ , proj₂ w₂) + pure (_ , _ , m≢1+m+n (proj₁ w₁) , proj₂ w₁ , proj₂ w₂) \ No newline at end of file diff --git a/v2.3/Data.Nat.Instances.html b/v2.3/Data.Nat.Instances.html index 9fa29cb53b..4cd127532b 100644 --- a/v2.3/Data.Nat.Instances.html +++ b/v2.3/Data.Nat.Instances.html @@ -9,11 +9,11 @@ module Data.Nat.Instances where -open import Data.Nat.Properties using (≤-isDecTotalOrder; _≟_) +open import Data.Nat.Properties using (≤-isDecTotalOrder; _≟_) open import Relation.Binary.PropositionalEquality.Properties using (isDecEquivalence) instance ℕ-≡-isDecEquivalence = isDecEquivalence _≟_ - ℕ-≤-isDecTotalOrder = ≤-isDecTotalOrder + ℕ-≤-isDecTotalOrder = ≤-isDecTotalOrder \ No newline at end of file diff --git a/v2.3/Data.Nat.LCM.html b/v2.3/Data.Nat.LCM.html index 40b8f472b2..8af18effe6 100644 --- a/v2.3/Data.Nat.LCM.html +++ b/v2.3/Data.Nat.LCM.html @@ -15,7 +15,7 @@ open import Data.Nat.Coprimality using (Coprime) open import Data.Nat.Divisibility open import Data.Nat.DivMod -open import Data.Nat.Properties using (*-comm; *-assoc; *-zeroʳ) +open import Data.Nat.Properties using (*-comm; *-assoc; *-zeroʳ) open import Data.Nat.GCD using (GCD; gcd; gcd-GCD; gcd-greatest; gcd[m,n]≢0; gcd[m,n]∣n; gcd[m,n]∣m ; c*gcd[m,n]≡gcd[cm,cn]) @@ -58,7 +58,7 @@ n∣lcm[m,n] m@(suc m-1) n = begin n ∣⟨ m∣m*n (m / gcd m n) n * (m / gcd m n) ≡⟨ *-/-assoc n (gcd[m,n]∣m m n) - n * m / gcd m n ≡⟨ cong (_/ gcd m n) (*-comm n m) + n * m / gcd m n ≡⟨ cong (_/ gcd m n) (*-comm n m) m * n / gcd m n ≡⟨ rearrange m n m * (n / gcd m n) where open ∣-Reasoning; instance _ = gcd≢0ˡ {m} {n} @@ -77,7 +77,7 @@ mn∣c*gcd : m * n c * gcd m n mn∣c*gcd = begin - m * n ∣⟨ gcd-greatest (subst (_∣ c * m) (*-comm n m) (*-monoˡ-∣ m n∣c)) (*-monoˡ-∣ n m∣c) + m * n ∣⟨ gcd-greatest (subst (_∣ c * m) (*-comm n m) (*-monoˡ-∣ m n∣c)) (*-monoˡ-∣ n m∣c) gcd (c * m) (c * n) ≡⟨ c*gcd[m,n]≡gcd[cm,cn] c m n c * gcd m n @@ -88,7 +88,7 @@ -- 3 core properties above. gcd*lcm : m n gcd m n * lcm m n m * n -gcd*lcm zero n = *-zeroʳ (gcd 0 n) +gcd*lcm zero n = *-zeroʳ (gcd 0 n) gcd*lcm m@(suc m-1) n = trans (cong (gcd m n *_) (rearrange m n)) (m*[n/m]≡n (begin gcd m n ∣⟨ gcd[m,n]∣m m n m ∣⟨ m∣m*n n diff --git a/v2.3/Data.Nat.ListAction.Properties.html b/v2.3/Data.Nat.ListAction.Properties.html index d5df370079..d6b16be607 100644 --- a/v2.3/Data.Nat.ListAction.Properties.html +++ b/v2.3/Data.Nat.ListAction.Properties.html @@ -25,8 +25,8 @@ open import Data.Nat.Divisibility using (_∣_; m∣m*n; ∣n⇒∣m*n) open import Data.Nat.ListAction using (sum; product) open import Data.Nat.Properties - using (+-assoc; *-assoc; *-identityˡ; m*n≢0; m≤m*n; m≤n⇒m≤o*n - ; +-0-commutativeMonoid; *-1-commutativeMonoid) + using (+-assoc; *-assoc; *-identityˡ; m*n≢0; m≤m*n; m≤n⇒m≤o*n + ; +-0-commutativeMonoid; *-1-commutativeMonoid) open import Relation.Binary.Core using (_Preserves_⟶_) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; sym; cong) @@ -48,22 +48,22 @@ sum-++ [] ns = refl sum-++ (m ms) ns = begin m + sum (ms ++ ns) ≡⟨ cong (m +_) (sum-++ ms ns) - m + (sum ms + sum ns) ≡⟨ +-assoc m _ _ + m + (sum ms + sum ns) ≡⟨ +-assoc m _ _ (m + sum ms) + sum ns where open ≡-Reasoning sum-↭ : sum Preserves _↭_ _≡_ sum-↭ p = foldr-commMonoid ℕ-+-0.setoid ℕ-+-0.isCommutativeMonoid (↭⇒↭ₛ p) - where module ℕ-+-0 = CommutativeMonoid +-0-commutativeMonoid + where module ℕ-+-0 = CommutativeMonoid +-0-commutativeMonoid -- product product-++ : ms ns product (ms ++ ns) product ms * product ns -product-++ [] ns = sym (*-identityˡ _) +product-++ [] ns = sym (*-identityˡ _) product-++ (m ms) ns = begin m * product (ms ++ ns) ≡⟨ cong (m *_) (product-++ ms ns) - m * (product ms * product ns) ≡⟨ *-assoc m _ _ + m * (product ms * product ns) ≡⟨ *-assoc m _ _ (m * product ms) * product ns where open ≡-Reasoning @@ -73,13 +73,13 @@ product≢0 : All NonZero ns NonZero (product ns) product≢0 [] = _ -product≢0 (n≢0 ns≢0) = m*n≢0 _ _ {{n≢0}} {{product≢0 ns≢0}} +product≢0 (n≢0 ns≢0) = m*n≢0 _ _ {{n≢0}} {{product≢0 ns≢0}} ∈⇒≤product : All NonZero ns n ns n product ns -∈⇒≤product (n≢0 ns≢0) (here refl) = m≤m*n _ _ {{product≢0 ns≢0}} -∈⇒≤product (n≢0 ns≢0) (there n∈ns) = m≤n⇒m≤o*n _ {{n≢0}} (∈⇒≤product ns≢0 n∈ns) +∈⇒≤product (n≢0 ns≢0) (here refl) = m≤m*n _ _ {{product≢0 ns≢0}} +∈⇒≤product (n≢0 ns≢0) (there n∈ns) = m≤n⇒m≤o*n _ {{n≢0}} (∈⇒≤product ns≢0 n∈ns) product-↭ : product Preserves _↭_ _≡_ product-↭ p = foldr-commMonoid ℕ-*-1.setoid ℕ-*-1.isCommutativeMonoid (↭⇒↭ₛ p) - where module ℕ-*-1 = CommutativeMonoid *-1-commutativeMonoid + where module ℕ-*-1 = CommutativeMonoid *-1-commutativeMonoid \ No newline at end of file diff --git a/v2.3/Data.Nat.Logarithm.Core.html b/v2.3/Data.Nat.Logarithm.Core.html index c0c6f02fc2..93a82404af 100644 --- a/v2.3/Data.Nat.Logarithm.Core.html +++ b/v2.3/Data.Nat.Logarithm.Core.html @@ -28,7 +28,7 @@ ⌊log2⌋ : n Acc _<_ n ⌊log2⌋ 0 _ = 0 ⌊log2⌋ 1 _ = 0 -⌊log2⌋ (suc n′@(suc n)) (acc rs) = 1 + ⌊log2⌋ (suc n /2⌋) (rs (⌊n/2⌋<n n′)) +⌊log2⌋ (suc n′@(suc n)) (acc rs) = 1 + ⌊log2⌋ (suc n /2⌋) (rs (⌊n/2⌋<n n′)) -- Ceil version @@ -36,7 +36,7 @@ ⌈log2⌉ : n Acc _<_ n ⌈log2⌉ 0 _ = 0 ⌈log2⌉ 1 _ = 0 -⌈log2⌉ (suc (suc n)) (acc rs) = 1 + ⌈log2⌉ (suc n /2⌉) (rs (⌈n/2⌉<n n)) +⌈log2⌉ (suc (suc n)) (acc rs) = 1 + ⌈log2⌉ (suc n /2⌉) (rs (⌈n/2⌉<n n)) ------------------------------------------------------------------------ -- Properties of ⌊log2⌋ @@ -55,7 +55,7 @@ ⌊log2⌋-mono-≤ {_} {_} z≤n = z≤n ⌊log2⌋-mono-≤ {_} {_} (s≤s z≤n) = z≤n ⌊log2⌋-mono-≤ {acc = acc _} {acc _} (s≤s (s≤s p)) = - s≤s (⌊log2⌋-mono-≤ (⌊n/2⌋-mono (+-monoʳ-≤ 2 p))) + s≤s (⌊log2⌋-mono-≤ (⌊n/2⌋-mono (+-monoʳ-≤ 2 p))) ⌊log2⌋⌊n/2⌋≡⌊log2⌋n∸1 : n {acc} {acc'} ⌊log2⌋ n /2⌋ acc ⌊log2⌋ n acc' 1 @@ -67,17 +67,17 @@ ⌊log2⌋2*b≡1+⌊log2⌋b : n {acc acc'} .{{ _ : NonZero n}} ⌊log2⌋ (2 * n) acc 1 + ⌊log2⌋ n acc' ⌊log2⌋2*b≡1+⌊log2⌋b (suc n) = begin - ⌊log2⌋ (suc (n + suc (n + zero))) _ ≡⟨ ⌊log2⌋-cong-irr (cong x suc (n + suc x)) (+-comm n zero)) - ⌊log2⌋ (suc (n + suc n)) (<-wellFounded _) ≡⟨ ⌊log2⌋-cong-irr {acc' = <-wellFounded _} (cong suc (+-comm n (suc n))) + ⌊log2⌋ (suc (n + suc (n + zero))) _ ≡⟨ ⌊log2⌋-cong-irr (cong x suc (n + suc x)) (+-comm n zero)) + ⌊log2⌋ (suc (n + suc n)) (<-wellFounded _) ≡⟨ ⌊log2⌋-cong-irr {acc' = <-wellFounded _} (cong suc (+-comm n (suc n))) ⌊log2⌋ (suc (suc n + n)) (<-wellFounded _) ≡⟨ cong suc (⌊log2⌋-cong-irr {a = suc n + n /2⌋} refl) - suc (⌊log2⌋ (suc n + n /2⌋) (<-wellFounded _)) ≡⟨ cong suc (⌊log2⌋-cong-irr (cong suc (sym (n≡⌊n+n/2⌋ n)))) + suc (⌊log2⌋ (suc n + n /2⌋) (<-wellFounded _)) ≡⟨ cong suc (⌊log2⌋-cong-irr (cong suc (sym (n≡⌊n+n/2⌋ n)))) suc (⌊log2⌋ (suc n) _) where open ≡-Reasoning ⌊log2⌋2^n≡n : n {acc} ⌊log2⌋ (2 ^ n) acc n ⌊log2⌋2^n≡n zero = refl ⌊log2⌋2^n≡n (suc n) = begin - ⌊log2⌋ ((2 ^ n) + ((2 ^ n) + zero)) _ ≡⟨ ⌊log2⌋2*b≡1+⌊log2⌋b (2 ^ n) {{m^n≢0 2 n}} + ⌊log2⌋ ((2 ^ n) + ((2 ^ n) + zero)) _ ≡⟨ ⌊log2⌋2*b≡1+⌊log2⌋b (2 ^ n) {{m^n≢0 2 n}} 1 + ⌊log2⌋ (2 ^ n) (<-wellFounded _) ≡⟨ cong suc (⌊log2⌋2^n≡n n) suc n where open ≡-Reasoning @@ -99,7 +99,7 @@ ⌈log2⌉-mono-≤ {_} {_} z≤n = z≤n ⌈log2⌉-mono-≤ {_} {_} (s≤s z≤n) = z≤n ⌈log2⌉-mono-≤ {acc = acc rs} {acc rs'} (s≤s (s≤s p)) = - s≤s (⌈log2⌉-mono-≤ (⌈n/2⌉-mono (+-monoʳ-≤ 2 p))) + s≤s (⌈log2⌉-mono-≤ (⌈n/2⌉-mono (+-monoʳ-≤ 2 p))) ⌈log2⌉⌈n/2⌉≡⌈log2⌉n∸1 : n {acc} {acc'} ⌈log2⌉ n /2⌉ acc ⌈log2⌉ n acc' 1 @@ -111,17 +111,17 @@ ⌈log2⌉2*n≡1+⌈log2⌉n : n {acc acc'} .{{_ : NonZero n}} ⌈log2⌉ (2 * n) acc 1 + ⌈log2⌉ n acc' ⌈log2⌉2*n≡1+⌈log2⌉n (suc n) = begin - ⌈log2⌉ (suc (n + suc (n + zero))) _ ≡⟨ ⌈log2⌉-cong-irr (cong x suc (n + suc x)) (+-comm n zero)) - ⌈log2⌉ (suc (n + suc n)) (<-wellFounded _) ≡⟨ ⌈log2⌉-cong-irr {acc' = <-wellFounded _} (cong suc (+-comm n (suc n))) + ⌈log2⌉ (suc (n + suc (n + zero))) _ ≡⟨ ⌈log2⌉-cong-irr (cong x suc (n + suc x)) (+-comm n zero)) + ⌈log2⌉ (suc (n + suc n)) (<-wellFounded _) ≡⟨ ⌈log2⌉-cong-irr {acc' = <-wellFounded _} (cong suc (+-comm n (suc n))) ⌈log2⌉ (suc (suc n + n)) (<-wellFounded _) ≡⟨ cong suc (⌈log2⌉-cong-irr {m = suc n + n /2⌉} refl) - suc (⌈log2⌉ (suc n + n /2⌉) (<-wellFounded _)) ≡⟨ cong suc (⌈log2⌉-cong-irr (cong suc (sym (n≡⌈n+n/2⌉ n)))) + suc (⌈log2⌉ (suc n + n /2⌉) (<-wellFounded _)) ≡⟨ cong suc (⌈log2⌉-cong-irr (cong suc (sym (n≡⌈n+n/2⌉ n)))) suc (⌈log2⌉ (suc n) _) where open ≡-Reasoning ⌈log2⌉2^n≡n : n {acc} ⌈log2⌉ (2 ^ n) acc n ⌈log2⌉2^n≡n zero = refl ⌈log2⌉2^n≡n (suc n) = begin - ⌈log2⌉ ((2 ^ n) + ((2 ^ n) + zero)) _ ≡⟨ ⌈log2⌉2*n≡1+⌈log2⌉n (2 ^ n) {{m^n≢0 2 n}} + ⌈log2⌉ ((2 ^ n) + ((2 ^ n) + zero)) _ ≡⟨ ⌈log2⌉2*n≡1+⌈log2⌉n (2 ^ n) {{m^n≢0 2 n}} 1 + ⌈log2⌉ (2 ^ n) (<-wellFounded _) ≡⟨ cong suc (⌈log2⌉2^n≡n n) suc n where open ≡-Reasoning diff --git a/v2.3/Data.Nat.Primality.Factorisation.html b/v2.3/Data.Nat.Primality.Factorisation.html index 3a379dcd4e..98588f4128 100644 --- a/v2.3/Data.Nat.Primality.Factorisation.html +++ b/v2.3/Data.Nat.Primality.Factorisation.html @@ -35,7 +35,7 @@ open import Induction using (build) open import Induction.Lexicographic using (_⊗_; [_⊗_]) open import Relation.Nullary.Decidable using (yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; sym; trans; cong) open import Relation.Binary.PropositionalEquality.Properties @@ -70,7 +70,7 @@ primeFactorisation[p] : Prime n PrimeFactorisation n primeFactorisation[p] {n} pr = record { factors = n [] - ; isFactorisation = sym (*-identityʳ n) + ; isFactorisation = sym (*-identityʳ n) ; factorsPrime = pr [] } @@ -93,14 +93,14 @@ facRec : n×k (<-Rec <-Rec) P n×k P n×k facRec (n , zero) _ rough eq = -- Case 1: m * m > n, ∴ Prime n - primeFactorisation[p] (rough∧square>⇒prime rough (m∸n≡0⇒m≤n eq)) + primeFactorisation[p] (rough∧square>⇒prime rough (m∸n≡0⇒m≤n eq)) facRec (n@(2+ _) , suc k) (recFactor , recQuotient) {m@(2+ _)} rough eq with m ∣? n -- Case 2: m ∤ n, try larger m, reducing k accordingly - ... | no m∤n = recFactor (≤-<-trans (m∸n≤m k (m + m)) (n<1+n k)) {suc m} (∤⇒rough-suc m∤n rough) $ begin - suc n (suc m + m * suc m) ≡⟨ cong # suc n (suc m + #)) (*-suc m m) - suc n (suc m + (m + m * m)) ≡⟨ cong (suc n ∸_) (+-assoc (suc m) m (m * m)) - suc n (suc (m + m) + m * m) ≡⟨ cong (suc n ∸_) (+-comm (suc (m + m)) (m * m)) - suc n (m * m + suc (m + m)) ≡⟨ ∸-+-assoc (suc n) (m * m) (suc (m + m)) + ... | no m∤n = recFactor (≤-<-trans (m∸n≤m k (m + m)) (n<1+n k)) {suc m} (∤⇒rough-suc m∤n rough) $ begin + suc n (suc m + m * suc m) ≡⟨ cong # suc n (suc m + #)) (*-suc m m) + suc n (suc m + (m + m * m)) ≡⟨ cong (suc n ∸_) (+-assoc (suc m) m (m * m)) + suc n (suc (m + m) + m * m) ≡⟨ cong (suc n ∸_) (+-comm (suc (m + m)) (m * m)) + suc n (m * m + suc (m + m)) ≡⟨ ∸-+-assoc (suc n) (m * m) (suc (m + m)) (suc n m * m) suc (m + m) ≡⟨ cong (_∸ suc (m + m)) eq suc k suc (m + m) where open ≡-Reasoning @@ -113,10 +113,10 @@ where m<n : m < n m<n = begin-strict - m <⟨ s≤s (≤-trans (m≤n+m m _) (+-monoʳ-≤ _ (m≤m+n m _))) - pred (m * m) <⟨ s<s⁻¹ (m∸n≢0⇒n<m λ eq′ 0≢1+n (trans (sym eq′) eq)) + m <⟨ s≤s (≤-trans (m≤n+m m _) (+-monoʳ-≤ _ (m≤m+n m _))) + pred (m * m) <⟨ s<s⁻¹ (m∸n≢0⇒n<m λ eq′ 0≢1+n (trans (sym eq′) eq)) n - where open ≤-Reasoning + where open ≤-Reasoning q = quotient m∣n @@ -140,27 +140,27 @@ -- Properties of a factorisation factorisationHasAllPrimeFactors : {as} {p} Prime p p product as All Prime as p as -factorisationHasAllPrimeFactors {[]} {2+ p} pPrime p∣Πas [] = contradiction (∣1⇒≡1 p∣Πas) λ () +factorisationHasAllPrimeFactors {[]} {2+ p} pPrime p∣Πas [] = contradiction (∣1⇒≡1 p∣Πas) λ () factorisationHasAllPrimeFactors {a as} {p} pPrime p∣aΠas (aPrime asPrime) with euclidsLemma a (product as) pPrime p∣aΠas ... | inj₂ p∣Πas = there (factorisationHasAllPrimeFactors pPrime p∣Πas asPrime) ... | inj₁ p∣a with prime⇒irreducible aPrime p∣a -... | inj₁ refl = contradiction pPrime ¬prime[1] +... | inj₁ refl = contradiction pPrime ¬prime[1] ... | inj₂ refl = here refl private factorisationUnique′ : (as bs : List ) product as product bs All Prime as All Prime bs as bs factorisationUnique′ [] [] Πas≡Πbs asPrime bsPrime = ↭-refl factorisationUnique′ [] (b@(2+ _) bs) Πas≡Πbs prime[as] (_ prime[bs]) = - contradiction Πas≡Πbs (<⇒≢ Πas<Πbs) + contradiction Πas≡Πbs (<⇒≢ Πas<Πbs) where Πas<Πbs : product [] < product (b bs) Πas<Πbs = begin-strict 1 ≡⟨⟩ - 1 * 1 <⟨ *-monoˡ-< 1 {1} {b} sz<ss - b * 1 ≤⟨ *-monoʳ-≤ b (productOfPrimes≥1 prime[bs]) + 1 * 1 <⟨ *-monoˡ-< 1 {1} {b} sz<ss + b * 1 ≤⟨ *-monoʳ-≤ b (productOfPrimes≥1 prime[bs]) b * product bs ≡⟨⟩ product (b bs) - where open ≤-Reasoning + where open ≤-Reasoning factorisationUnique′ (a as) bs Πas≡Πbs (prime[a] prime[as]) prime[bs] = a∷as↭bs where @@ -168,7 +168,7 @@ a∣Πbs = divides (product as) $ begin product bs ≡⟨ Πas≡Πbs product (a as) ≡⟨⟩ - a * product as ≡⟨ *-comm a (product as) + a * product as ≡⟨ *-comm a (product as) product as * a where open ≡-Reasoning @@ -180,7 +180,7 @@ bs↭a∷bs′ = proj₂ shuffle Πas≡Πbs′ : product as product bs′ - Πas≡Πbs′ = *-cancelˡ-≡ (product as) (product bs′) a {{prime⇒nonZero prime[a]}} $ begin + Πas≡Πbs′ = *-cancelˡ-≡ (product as) (product bs′) a {{prime⇒nonZero prime[a]}} $ begin a * product as ≡⟨ Πas≡Πbs product bs ≡⟨ product-↭ bs↭a∷bs′ a * product bs′ diff --git a/v2.3/Data.Nat.Primality.html b/v2.3/Data.Nat.Primality.html index b14ff9511a..c9deadd5c9 100644 --- a/v2.3/Data.Nat.Primality.html +++ b/v2.3/Data.Nat.Primality.html @@ -23,7 +23,7 @@ open import Function.Bundles using (_⇔_; mk⇔) open import Relation.Nullary.Decidable as Dec using (yes; no; from-yes; from-no; ¬?; _×-dec_; _⊎-dec_; _→-dec_; decidable-stable) -open import Relation.Nullary.Negation.Core using (¬_; contradiction; contradiction₂) +open import Relation.Nullary.Negation.Core using (¬_; contradiction; contradiction₂) open import Relation.Unary using (Pred; Decidable) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core @@ -103,7 +103,7 @@ -- 1 is always n-rough rough-1 : n n Rough 1 rough-1 _ (hasNonTrivialDivisor _ d∣1) = - contradiction (∣1⇒≡1 d∣1) nonTrivial⇒≢1 + contradiction (∣1⇒≡1 d∣1) nonTrivial⇒≢1 -- Any number is 0-, 1- and 2-rough, -- because no proper divisor d can be strictly less than 0, 1, or 2 @@ -118,15 +118,15 @@ -- If a number n > 1 is m-rough, then m ≤ n rough⇒≤ : .{{NonTrivial n}} m Rough n m n -rough⇒≤ rough = ≮⇒≥ n≮m +rough⇒≤ rough = ≮⇒≥ n≮m where n≮m = λ m>n rough (hasNonTrivialDivisor m>n ∣-refl) -- If a number n is m-rough, and m ∤ n, then n is (suc m)-rough ∤⇒rough-suc : m n m Rough n (suc m) Rough n ∤⇒rough-suc m∤n r (hasNonTrivialDivisor d<1+m d∣n) - with m<1+n⇒m<n∨m≡n d<1+m + with m<1+n⇒m<n∨m≡n d<1+m ... | inj₁ d<m = r (hasNonTrivialDivisor d<m d∣n) -... | inj₂ d≡m@refl = contradiction d∣n m∤n +... | inj₂ d≡m@refl = contradiction d∣n m∤n -- If a number is m-rough, then so are all of its divisors rough∧∣⇒rough : m Rough o n o m Rough n @@ -143,10 +143,10 @@ composite-∣ : .{{NonZero n}} Composite m m n Composite n composite-∣ (composite {d} d<m d∣n) m∣n@(divides-refl q) - = composite (*-monoʳ-< q d<m) (*-monoʳ-∣ q d∣n) + = composite (*-monoʳ-< q d<m) (*-monoʳ-∣ q d∣n) where instance - _ = m≢0∧n>1⇒m*n>1 q d - _ = m*n≢0⇒m≢0 q + _ = m≢0∧n>1⇒m*n>1 q d + _ = m*n≢0⇒m≢0 q -- Basic (counter-)examples of Composite @@ -167,7 +167,7 @@ composite⇒nonTrivial : Composite n NonTrivial n composite⇒nonTrivial {1} composite[1] = - contradiction composite[1] ¬composite[1] + contradiction composite[1] ¬composite[1] composite⇒nonTrivial {2+ _} _ = _ composite? : Decidable Composite @@ -195,7 +195,7 @@ -- Proof of decidability compositeUpTo? : Decidable CompositeUpTo - compositeUpTo? n = anyUpTo? d nonTrivial? d ×-dec d ∣? n) n + compositeUpTo? n = anyUpTo? d nonTrivial? d ×-dec d ∣? n) n ------------------------------------------------------------------------ -- Primality @@ -240,7 +240,7 @@ -- Proof of decidability primeUpTo? : Decidable PrimeUpTo - primeUpTo? n = allUpTo? d nonTrivial? d →-dec ¬? (d ∣? n)) n + primeUpTo? n = allUpTo? d nonTrivial? d →-dec ¬? (d ∣? n)) n -- Euclid's lemma - for p prime, if p ∣ m * n, then either p ∣ m or p ∣ n. -- @@ -257,7 +257,7 @@ p∣rmn r = begin p ∣⟨ p∣m*n m * n ∣⟨ n∣m*n r - r * (m * n) ≡⟨ *-assoc r m n + r * (m * n) ≡⟨ *-assoc r m n r * m * n result : p m p n @@ -266,7 +266,7 @@ -- impossible as p is a prime. -- note: this should be a typechecker-rejectable case!? ... | Bézout.result 0 g _ = - contradiction (0∣⇒≡0 (GCD.gcd∣n g)) (≢-nonZero⁻¹ _) + contradiction (0∣⇒≡0 (GCD.gcd∣n g)) (≢-nonZero⁻¹ _) -- if the GCD of m and p is one then m and p are coprime, and we know -- that for some integers s and r, sm + rp = 1. We can use this fact @@ -275,21 +275,21 @@ inj₂ (flip ∣m+n∣m⇒∣n (n∣m*n*o s n) (begin p ∣⟨ p∣rmn r r * m * n ≡⟨ cong (_* n) 1+sp≡rm - n + s * p * n ≡⟨ +-comm n (s * p * n) + n + s * p * n ≡⟨ +-comm n (s * p * n) s * p * n + n )) ... | Bézout.result 1 _ (Bézout.-+ r s 1+rm≡sp) = inj₂ (flip ∣m+n∣m⇒∣n (p∣rmn r) (begin p ∣⟨ n∣m*n*o s n s * p * n ≡⟨ cong (_* n) 1+rm≡sp - n + r * m * n ≡⟨ +-comm n (r * m * n) + n + r * m * n ≡⟨ +-comm n (r * m * n) r * m * n + n )) -- if the GCD of m and p is greater than one, then it must be p and -- hence p ∣ m. ... | Bézout.result d@(2+ _) g _ with d p ... | yes d≡p@refl = inj₁ (GCD.gcd∣m g) - ... | no d≢p = contradiction (composite-≢ d d≢p (GCD.gcd∣n g)) pr + ... | no d≢p = contradiction (composite-≢ d d≢p (GCD.gcd∣n g)) pr -- Relationship between roughness and primality. prime⇒rough : Prime p p Rough p @@ -304,8 +304,8 @@ rough∧square>⇒prime rough m*m>n = prime ¬composite where ¬composite : ¬ Composite _ - ¬composite (composite d<n d∣n) = contradiction (m∣n⇒n≡quotient*m d∣n) - (<⇒≢ (<-≤-trans m*m>n (*-mono-≤ + ¬composite (composite d<n d∣n) = contradiction (m∣n⇒n≡quotient*m d∣n) + (<⇒≢ (<-≤-trans m*m>n (*-mono-≤ (rough⇒≤ (rough∧∣⇒rough rough (quotient-∣ d∣n))) (rough⇒≤ (rough∧∣⇒rough rough d∣n))))) where instance _ = n>1⇒nonTrivial (quotient>1 d∣n d<n) @@ -335,7 +335,7 @@ -- Basic (counter-)examples of Irreducible ¬irreducible[0] : ¬ Irreducible 0 -¬irreducible[0] irr[0] = contradiction₂ 2≡1⊎2≡0 ()) ()) +¬irreducible[0] irr[0] = contradiction₂ 2≡1⊎2≡0 ()) ()) where 2≡1⊎2≡0 = irr[0] {2} (divides-refl 0) irreducible[1] : Irreducible 1 @@ -348,7 +348,7 @@ ... | s<s z<s = inj₂ refl irreducible⇒nonZero : Irreducible n NonZero n -irreducible⇒nonZero {zero} = flip contradiction ¬irreducible[0] +irreducible⇒nonZero {zero} = flip contradiction ¬irreducible[0] irreducible⇒nonZero {suc _} _ = _ irreducible? : Decidable Irreducible @@ -363,7 +363,7 @@ -- Proof of equivalence irr-upto⇒irr : .{{NonZero n}} IrreducibleUpTo n Irreducible n irr-upto⇒irr irr-upto m∣n - = [ flip irr-upto m∣n , inj₂ ]′ (m≤n⇒m<n∨m≡n (∣⇒≤ m∣n)) + = [ flip irr-upto m∣n , inj₂ ]′ (m≤n⇒m<n∨m≡n (∣⇒≤ m∣n)) irr⇒irr-upto : Irreducible n IrreducibleUpTo n irr⇒irr-upto irr m<n m∣n = irr m∣n @@ -374,7 +374,7 @@ -- Decidability irreducibleUpTo? : Decidable IrreducibleUpTo - irreducibleUpTo? n = allUpTo? + irreducibleUpTo? n = allUpTo? m (m ∣? n) →-dec (m 1 ⊎-dec m n)) n -- Relationship between primality and irreducibility. @@ -383,15 +383,15 @@ where instance _ = prime⇒nonZero pp irr : .{{NonZero p}} Irreducible p - irr {0} 0∣p = contradiction (0∣⇒≡0 0∣p) (≢-nonZero⁻¹ p) + irr {0} 0∣p = contradiction (0∣⇒≡0 0∣p) (≢-nonZero⁻¹ p) irr {1} 1∣p = inj₁ refl - irr {2+ _} d∣p = inj₂ (≤∧≮⇒≡ (∣⇒≤ d∣p) d≮p) + irr {2+ _} d∣p = inj₂ (≤∧≮⇒≡ (∣⇒≤ d∣p) d≮p) where d≮p = λ d<p pr (composite d<p d∣p) irreducible⇒prime : .{{NonTrivial p}} Irreducible p Prime p irreducible⇒prime irr = prime - λ (composite d<p d∣p) [ nonTrivial⇒≢1 , (<⇒≢ d<p) ]′ (irr d∣p) + λ (composite d<p d∣p) [ nonTrivial⇒≢1 , (<⇒≢ d<p) ]′ (irr d∣p) ------------------------------------------------------------------------ -- Using decidability diff --git a/v2.3/Data.Nat.Properties.html b/v2.3/Data.Nat.Properties.html index 30395986a8..7f10dfbcb8 100644 --- a/v2.3/Data.Nat.Properties.html +++ b/v2.3/Data.Nat.Properties.html @@ -51,7 +51,7 @@ open import Relation.Binary.Structures.Biased open import Relation.Nullary.Decidable using (True; via-injection; map′; recompute; no; yes; Dec; _because_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Reflects using (fromEquivalence; Reflects; invert) @@ -115,2335 +115,2329 @@ ≟-diag : (eq : m n) (m n) yes eq ≟-diag = ≡-≟-identity _≟_ -≟-≡ : (m≢n : m n) (m n) no m≢n -≟-≡ = ≢-≟-identity _≟_ +≡-isDecEquivalence : IsDecEquivalence (_≡_ {A = }) +≡-isDecEquivalence = record + { isEquivalence = isEquivalence + ; _≟_ = _≟_ + } -≡-isDecEquivalence : IsDecEquivalence (_≡_ {A = }) -≡-isDecEquivalence = record - { isEquivalence = isEquivalence - ; _≟_ = _≟_ - } +≡-decSetoid : DecSetoid 0ℓ 0ℓ +≡-decSetoid = record + { Carrier = + ; _≈_ = _≡_ + ; isDecEquivalence = ≡-isDecEquivalence + } -≡-decSetoid : DecSetoid 0ℓ 0ℓ -≡-decSetoid = record - { Carrier = - ; _≈_ = _≡_ - ; isDecEquivalence = ≡-isDecEquivalence - } +0≢1+n : 0 suc n +0≢1+n () -0≢1+n : 0 suc n -0≢1+n () +1+n≢0 : suc n 0 +1+n≢0 () -1+n≢0 : suc n 0 -1+n≢0 () +1+n≢n : suc n n +1+n≢n {suc n} = 1+n≢n suc-injective -1+n≢n : suc n n -1+n≢n {suc n} = 1+n≢n suc-injective +------------------------------------------------------------------------ +-- Properties of _<ᵇ_ +------------------------------------------------------------------------ ------------------------------------------------------------------------- --- Properties of _<ᵇ_ ------------------------------------------------------------------------- +<ᵇ⇒< : m n T (m <ᵇ n) m < n +<ᵇ⇒< zero (suc n) m<n = z<s +<ᵇ⇒< (suc m) (suc n) m<n = s<s (<ᵇ⇒< m n m<n) -<ᵇ⇒< : m n T (m <ᵇ n) m < n -<ᵇ⇒< zero (suc n) m<n = z<s -<ᵇ⇒< (suc m) (suc n) m<n = s<s (<ᵇ⇒< m n m<n) +<⇒<ᵇ : m < n T (m <ᵇ n) +<⇒<ᵇ z<s = tt +<⇒<ᵇ (s<s m<n@(s≤s _)) = <⇒<ᵇ m<n + +<ᵇ-reflects-< : m n Reflects (m < n) (m <ᵇ n) +<ᵇ-reflects-< m n = fromEquivalence (<ᵇ⇒< m n) <⇒<ᵇ + +------------------------------------------------------------------------ +-- Properties of _≤ᵇ_ +------------------------------------------------------------------------ + +≤ᵇ⇒≤ : m n T (m ≤ᵇ n) m n +≤ᵇ⇒≤ zero n m≤n = z≤n +≤ᵇ⇒≤ (suc m) n m≤n = <ᵇ⇒< m n m≤n + +≤⇒≤ᵇ : m n T (m ≤ᵇ n) +≤⇒≤ᵇ z≤n = tt +≤⇒≤ᵇ m≤n@(s≤s _) = <⇒<ᵇ m≤n + +≤ᵇ-reflects-≤ : m n Reflects (m n) (m ≤ᵇ n) +≤ᵇ-reflects-≤ m n = fromEquivalence (≤ᵇ⇒≤ m n) ≤⇒≤ᵇ + +------------------------------------------------------------------------ +-- Properties of _≤_ +------------------------------------------------------------------------ + +≰⇒≥ : _≰_ _≥_ +≰⇒≥ {m} {zero} m≰n = z≤n +≰⇒≥ {zero} {suc n} m≰n = contradiction z≤n m≰n +≰⇒≥ {suc m} {suc n} m≰n = s≤s (≰⇒≥ (m≰n s≤s)) + +------------------------------------------------------------------------ +-- Relational properties of _≤_ + +≤-reflexive : _≡_ _≤_ +≤-reflexive {zero} refl = z≤n +≤-reflexive {suc m} refl = s≤s (≤-reflexive refl) + +≤-refl : Reflexive _≤_ +≤-refl = ≤-reflexive refl + +≤-antisym : Antisymmetric _≡_ _≤_ +≤-antisym z≤n z≤n = refl +≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m) + +≤-trans : Transitive _≤_ +≤-trans z≤n _ = z≤n +≤-trans (s≤s m≤n) (s≤s n≤o) = s≤s (≤-trans m≤n n≤o) + +≤-irrelevant : Irrelevant _≤_ +≤-irrelevant z≤n z≤n = refl +≤-irrelevant (s≤s m≤n₁) (s≤s m≤n₂) = cong s≤s (≤-irrelevant m≤n₁ m≤n₂) + +-- NB: we use the builtin function `_<ᵇ_` here so that the function +-- quickly decides whether to return `yes` or `no`. It still takes +-- a linear amount of time to generate the proof if it is inspected. +-- We expect the main benefit to be visible in compiled code as the +-- backend erases proofs. + +infix 4 _≤?_ _≥?_ + +_≤?_ : Decidable _≤_ +m ≤? n = map′ (≤ᵇ⇒≤ m n) ≤⇒≤ᵇ (T? (m ≤ᵇ n)) -<⇒<ᵇ : m < n T (m <ᵇ n) -<⇒<ᵇ z<s = tt -<⇒<ᵇ (s<s m<n@(s≤s _)) = <⇒<ᵇ m<n - -<ᵇ-reflects-< : m n Reflects (m < n) (m <ᵇ n) -<ᵇ-reflects-< m n = fromEquivalence (<ᵇ⇒< m n) <⇒<ᵇ - ------------------------------------------------------------------------- --- Properties of _≤ᵇ_ ------------------------------------------------------------------------- - -≤ᵇ⇒≤ : m n T (m ≤ᵇ n) m n -≤ᵇ⇒≤ zero n m≤n = z≤n -≤ᵇ⇒≤ (suc m) n m≤n = <ᵇ⇒< m n m≤n - -≤⇒≤ᵇ : m n T (m ≤ᵇ n) -≤⇒≤ᵇ z≤n = tt -≤⇒≤ᵇ m≤n@(s≤s _) = <⇒<ᵇ m≤n - -≤ᵇ-reflects-≤ : m n Reflects (m n) (m ≤ᵇ n) -≤ᵇ-reflects-≤ m n = fromEquivalence (≤ᵇ⇒≤ m n) ≤⇒≤ᵇ - ------------------------------------------------------------------------- --- Properties of _≤_ ------------------------------------------------------------------------- - -≰⇒≥ : _≰_ _≥_ -≰⇒≥ {m} {zero} m≰n = z≤n -≰⇒≥ {zero} {suc n} m≰n = contradiction z≤n m≰n -≰⇒≥ {suc m} {suc n} m≰n = s≤s (≰⇒≥ (m≰n s≤s)) - ------------------------------------------------------------------------- --- Relational properties of _≤_ - -≤-reflexive : _≡_ _≤_ -≤-reflexive {zero} refl = z≤n -≤-reflexive {suc m} refl = s≤s (≤-reflexive refl) - -≤-refl : Reflexive _≤_ -≤-refl = ≤-reflexive refl - -≤-antisym : Antisymmetric _≡_ _≤_ -≤-antisym z≤n z≤n = refl -≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m) - -≤-trans : Transitive _≤_ -≤-trans z≤n _ = z≤n -≤-trans (s≤s m≤n) (s≤s n≤o) = s≤s (≤-trans m≤n n≤o) - -≤-irrelevant : Irrelevant _≤_ -≤-irrelevant z≤n z≤n = refl -≤-irrelevant (s≤s m≤n₁) (s≤s m≤n₂) = cong s≤s (≤-irrelevant m≤n₁ m≤n₂) - --- NB: we use the builtin function `_<ᵇ_` here so that the function --- quickly decides whether to return `yes` or `no`. It still takes --- a linear amount of time to generate the proof if it is inspected. --- We expect the main benefit to be visible in compiled code as the --- backend erases proofs. - -infix 4 _≤?_ _≥?_ +_≥?_ : Decidable _≥_ +_≥?_ = flip _≤?_ -_≤?_ : Decidable _≤_ -m ≤? n = map′ (≤ᵇ⇒≤ m n) ≤⇒≤ᵇ (T? (m ≤ᵇ n)) +≤-total : Total _≤_ +≤-total m n with m ≤? n +... | true because m≤n = inj₁ (invert m≤n) +... | false because m≰n = inj₂ (≰⇒≥ (invert m≰n)) + +------------------------------------------------------------------------ +-- Structures -_≥?_ : Decidable _≥_ -_≥?_ = flip _≤?_ +≤-isPreorder : IsPreorder _≡_ _≤_ +≤-isPreorder = record + { isEquivalence = isEquivalence + ; reflexive = ≤-reflexive + ; trans = ≤-trans + } -≤-total : Total _≤_ -≤-total m n with m ≤? n -... | true because m≤n = inj₁ (invert m≤n) -... | false because m≰n = inj₂ (≰⇒≥ (invert m≰n)) - ------------------------------------------------------------------------- --- Structures +≤-isTotalPreorder : IsTotalPreorder _≡_ _≤_ +≤-isTotalPreorder = record + { isPreorder = ≤-isPreorder + ; total = ≤-total + } -≤-isPreorder : IsPreorder _≡_ _≤_ -≤-isPreorder = record - { isEquivalence = isEquivalence - ; reflexive = ≤-reflexive - ; trans = ≤-trans - } +≤-isPartialOrder : IsPartialOrder _≡_ _≤_ +≤-isPartialOrder = record + { isPreorder = ≤-isPreorder + ; antisym = ≤-antisym + } -≤-isTotalPreorder : IsTotalPreorder _≡_ _≤_ -≤-isTotalPreorder = record - { isPreorder = ≤-isPreorder - ; total = ≤-total - } +≤-isTotalOrder : IsTotalOrder _≡_ _≤_ +≤-isTotalOrder = record + { isPartialOrder = ≤-isPartialOrder + ; total = ≤-total + } -≤-isPartialOrder : IsPartialOrder _≡_ _≤_ -≤-isPartialOrder = record - { isPreorder = ≤-isPreorder - ; antisym = ≤-antisym - } +≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_ +≤-isDecTotalOrder = record + { isTotalOrder = ≤-isTotalOrder + ; _≟_ = _≟_ + ; _≤?_ = _≤?_ + } -≤-isTotalOrder : IsTotalOrder _≡_ _≤_ -≤-isTotalOrder = record - { isPartialOrder = ≤-isPartialOrder - ; total = ≤-total - } +------------------------------------------------------------------------ +-- Bundles -≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_ -≤-isDecTotalOrder = record - { isTotalOrder = ≤-isTotalOrder - ; _≟_ = _≟_ - ; _≤?_ = _≤?_ - } +≤-preorder : Preorder 0ℓ 0ℓ 0ℓ +≤-preorder = record + { isPreorder = ≤-isPreorder + } ------------------------------------------------------------------------- --- Bundles +≤-totalPreorder : TotalPreorder 0ℓ 0ℓ 0ℓ +≤-totalPreorder = record + { isTotalPreorder = ≤-isTotalPreorder + } -≤-preorder : Preorder 0ℓ 0ℓ 0ℓ -≤-preorder = record - { isPreorder = ≤-isPreorder - } +≤-poset : Poset 0ℓ 0ℓ 0ℓ +≤-poset = record + { isPartialOrder = ≤-isPartialOrder + } -≤-totalPreorder : TotalPreorder 0ℓ 0ℓ 0ℓ -≤-totalPreorder = record - { isTotalPreorder = ≤-isTotalPreorder - } +≤-totalOrder : TotalOrder 0ℓ 0ℓ 0ℓ +≤-totalOrder = record + { isTotalOrder = ≤-isTotalOrder + } -≤-poset : Poset 0ℓ 0ℓ 0ℓ -≤-poset = record - { isPartialOrder = ≤-isPartialOrder - } +≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ +≤-decTotalOrder = record + { isDecTotalOrder = ≤-isDecTotalOrder + } -≤-totalOrder : TotalOrder 0ℓ 0ℓ 0ℓ -≤-totalOrder = record - { isTotalOrder = ≤-isTotalOrder - } +------------------------------------------------------------------------ +-- Other properties of _≤_ -≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ -≤-decTotalOrder = record - { isDecTotalOrder = ≤-isDecTotalOrder - } +s≤s-injective : {p q : m n} s≤s p s≤s q p q +s≤s-injective refl = refl ------------------------------------------------------------------------- --- Other properties of _≤_ +suc[m]≤n⇒m≤pred[n] : suc m n m pred n +suc[m]≤n⇒m≤pred[n] {n = suc _} = s≤s⁻¹ -s≤s-injective : {p q : m n} s≤s p s≤s q p q -s≤s-injective refl = refl +m≤pred[n]⇒suc[m]≤n : .{{NonZero n}} m pred n suc m n +m≤pred[n]⇒suc[m]≤n {n = suc _} = s≤s -suc[m]≤n⇒m≤pred[n] : suc m n m pred n -suc[m]≤n⇒m≤pred[n] {n = suc _} = s≤s⁻¹ +≤-pred : suc m suc n m n +≤-pred = suc[m]≤n⇒m≤pred[n] -m≤pred[n]⇒suc[m]≤n : .{{NonZero n}} m pred n suc m n -m≤pred[n]⇒suc[m]≤n {n = suc _} = s≤s +m≤n⇒m≤1+n : m n m 1 + n +m≤n⇒m≤1+n z≤n = z≤n +m≤n⇒m≤1+n (s≤s m≤n) = s≤s (m≤n⇒m≤1+n m≤n) -≤-pred : suc m suc n m n -≤-pred = suc[m]≤n⇒m≤pred[n] +n≤1+n : n n 1 + n +n≤1+n _ = m≤n⇒m≤1+n ≤-refl -m≤n⇒m≤1+n : m n m 1 + n -m≤n⇒m≤1+n z≤n = z≤n -m≤n⇒m≤1+n (s≤s m≤n) = s≤s (m≤n⇒m≤1+n m≤n) +1+n≰n : 1 + n n +1+n≰n (s≤s 1+n≤n) = 1+n≰n 1+n≤n -n≤1+n : n n 1 + n -n≤1+n _ = m≤n⇒m≤1+n ≤-refl +n≤0⇒n≡0 : n 0 n 0 +n≤0⇒n≡0 z≤n = refl -1+n≰n : 1 + n n -1+n≰n (s≤s 1+n≤n) = 1+n≰n 1+n≤n +n≤1⇒n≡0∨n≡1 : n 1 n 0 n 1 +n≤1⇒n≡0∨n≡1 z≤n = inj₁ refl +n≤1⇒n≡0∨n≡1 (s≤s z≤n) = inj₂ refl -n≤0⇒n≡0 : n 0 n 0 -n≤0⇒n≡0 z≤n = refl +------------------------------------------------------------------------ +-- Properties of _<_ +------------------------------------------------------------------------ -n≤1⇒n≡0∨n≡1 : n 1 n 0 n 1 -n≤1⇒n≡0∨n≡1 z≤n = inj₁ refl -n≤1⇒n≡0∨n≡1 (s≤s z≤n) = inj₂ refl +-- Relationships between the various relations ------------------------------------------------------------------------- --- Properties of _<_ ------------------------------------------------------------------------- +<⇒≤ : _<_ _≤_ +<⇒≤ z<s = z≤n +<⇒≤ (s<s m<n@(s≤s _)) = s≤s (<⇒≤ m<n) --- Relationships between the various relations +<⇒≢ : _<_ _≢_ +<⇒≢ m<n refl = 1+n≰n m<n -<⇒≤ : _<_ _≤_ -<⇒≤ z<s = z≤n -<⇒≤ (s<s m<n@(s≤s _)) = s≤s (<⇒≤ m<n) +>⇒≢ : _>_ _≢_ +>⇒≢ = ≢-sym <⇒≢ -<⇒≢ : _<_ _≢_ -<⇒≢ m<n refl = 1+n≰n m<n +≤⇒≯ : _≤_ _≯_ +≤⇒≯ (s≤s m≤n) (s≤s n≤m) = ≤⇒≯ m≤n n≤m ->⇒≢ : _>_ _≢_ ->⇒≢ = ≢-sym <⇒≢ +<⇒≱ : _<_ _≱_ +<⇒≱ (s≤s m+1≤n) (s≤s n≤m) = <⇒≱ m+1≤n n≤m -≤⇒≯ : _≤_ _≯_ -≤⇒≯ (s≤s m≤n) (s≤s n≤m) = ≤⇒≯ m≤n n≤m +<⇒≯ : _<_ _≯_ +<⇒≯ (s≤s m<n) (s≤s n<m) = <⇒≯ m<n n<m -<⇒≱ : _<_ _≱_ -<⇒≱ (s≤s m+1≤n) (s≤s n≤m) = <⇒≱ m+1≤n n≤m +≰⇒≮ : _≰_ _≮_ +≰⇒≮ m≰n 1+m≤n = m≰n (<⇒≤ 1+m≤n) -<⇒≯ : _<_ _≯_ -<⇒≯ (s≤s m<n) (s≤s n<m) = <⇒≯ m<n n<m +≰⇒> : _≰_ _>_ +≰⇒> {zero} z≰n = contradiction z≤n z≰n +≰⇒> {suc m} {zero} _ = z<s +≰⇒> {suc m} {suc n} m≰n = s<s (≰⇒> (m≰n s≤s)) -≰⇒≮ : _≰_ _≮_ -≰⇒≮ m≰n 1+m≤n = m≰n (<⇒≤ 1+m≤n) +≮⇒≥ : _≮_ _≥_ +≮⇒≥ {_} {zero} _ = z≤n +≮⇒≥ {zero} {suc j} 1≮j+1 = contradiction z<s 1≮j+1 +≮⇒≥ {suc i} {suc j} i+1≮j+1 = s≤s (≮⇒≥ (i+1≮j+1 s<s)) -≰⇒> : _≰_ _>_ -≰⇒> {zero} z≰n = contradiction z≤n z≰n -≰⇒> {suc m} {zero} _ = z<s -≰⇒> {suc m} {suc n} m≰n = s<s (≰⇒> (m≰n s≤s)) +≤∧≢⇒< : {m n} m n m n m < n +≤∧≢⇒< {_} {zero} z≤n m≢n = contradiction refl m≢n +≤∧≢⇒< {_} {suc n} z≤n m≢n = z<s +≤∧≢⇒< {_} {suc n} (s≤s m≤n) 1+m≢1+n = + s<s (≤∧≢⇒< m≤n (1+m≢1+n cong suc)) -≮⇒≥ : _≮_ _≥_ -≮⇒≥ {_} {zero} _ = z≤n -≮⇒≥ {zero} {suc j} 1≮j+1 = contradiction z<s 1≮j+1 -≮⇒≥ {suc i} {suc j} i+1≮j+1 = s≤s (≮⇒≥ (i+1≮j+1 s<s)) +≤∧≮⇒≡ : {m n} m n m n m n +≤∧≮⇒≡ m≤n m≮n = ≤-antisym m≤n (≮⇒≥ m≮n) -≤∧≢⇒< : {m n} m n m n m < n -≤∧≢⇒< {_} {zero} z≤n m≢n = contradiction refl m≢n -≤∧≢⇒< {_} {suc n} z≤n m≢n = z<s -≤∧≢⇒< {_} {suc n} (s≤s m≤n) 1+m≢1+n = - s<s (≤∧≢⇒< m≤n (1+m≢1+n cong suc)) +≤-<-connex : Connex _≤_ _<_ +≤-<-connex m n with m ≤? n +... | yes m≤n = inj₁ m≤n +... | no ¬m≤n = inj₂ (≰⇒> ¬m≤n) -≤∧≮⇒≡ : {m n} m n m n m n -≤∧≮⇒≡ m≤n m≮n = ≤-antisym m≤n (≮⇒≥ m≮n) +≥->-connex : Connex _≥_ _>_ +≥->-connex = flip ≤-<-connex -≤-<-connex : Connex _≤_ _<_ -≤-<-connex m n with m ≤? n -... | yes m≤n = inj₁ m≤n -... | no ¬m≤n = inj₂ (≰⇒> ¬m≤n) +<-≤-connex : Connex _<_ _≤_ +<-≤-connex = flip-Connex ≤-<-connex -≥->-connex : Connex _≥_ _>_ -≥->-connex = flip ≤-<-connex +>-≥-connex : Connex _>_ _≥_ +>-≥-connex = flip-Connex ≥->-connex -<-≤-connex : Connex _<_ _≤_ -<-≤-connex = flip-Connex ≤-<-connex +------------------------------------------------------------------------ +-- Relational properties of _<_ ->-≥-connex : Connex _>_ _≥_ ->-≥-connex = flip-Connex ≥->-connex +<-irrefl : Irreflexive _≡_ _<_ +<-irrefl refl (s<s n<n) = <-irrefl refl n<n ------------------------------------------------------------------------- --- Relational properties of _<_ +<-asym : Asymmetric _<_ +<-asym (s<s n<m) (s<s m<n) = <-asym n<m m<n -<-irrefl : Irreflexive _≡_ _<_ -<-irrefl refl (s<s n<n) = <-irrefl refl n<n +<-trans : Transitive _<_ +<-trans (s≤s i≤j) (s≤s j<k) = s≤s (≤-trans i≤j (≤-trans (n≤1+n _) j<k)) -<-asym : Asymmetric _<_ -<-asym (s<s n<m) (s<s m<n) = <-asym n<m m<n +≤-<-trans : LeftTrans _≤_ _<_ +≤-<-trans m≤n (s<s n≤o) = s≤s (≤-trans m≤n n≤o) -<-trans : Transitive _<_ -<-trans (s≤s i≤j) (s≤s j<k) = s≤s (≤-trans i≤j (≤-trans (n≤1+n _) j<k)) +<-≤-trans : RightTrans _<_ _≤_ +<-≤-trans (s<s m≤n) (s≤s n≤o) = s≤s (≤-trans m≤n n≤o) -≤-<-trans : LeftTrans _≤_ _<_ -≤-<-trans m≤n (s<s n≤o) = s≤s (≤-trans m≤n n≤o) +-- NB: we use the builtin function `_<ᵇ_` here so that the function +-- quickly decides which constructor to return. It still takes a +-- linear amount of time to generate the proof if it is inspected. +-- We expect the main benefit to be visible in compiled code as the +-- backend erases proofs. -<-≤-trans : RightTrans _<_ _≤_ -<-≤-trans (s<s m≤n) (s≤s n≤o) = s≤s (≤-trans m≤n n≤o) +<-cmp : Trichotomous _≡_ _<_ +<-cmp m n with m n | T? (m <ᵇ n) +... | yes m≡n | _ = tri≈ (<-irrefl m≡n) m≡n (<-irrefl (sym m≡n)) +... | no m≢n | yes m<n = tri< (<ᵇ⇒< m n m<n) m≢n (<⇒≯ (<ᵇ⇒< m n m<n)) +... | no m≢n | no m≮n = tri> (m≮n <⇒<ᵇ) m≢n (≤∧≢⇒< (≮⇒≥ (m≮n <⇒<ᵇ)) (m≢n sym)) --- NB: we use the builtin function `_<ᵇ_` here so that the function --- quickly decides which constructor to return. It still takes a --- linear amount of time to generate the proof if it is inspected. --- We expect the main benefit to be visible in compiled code as the --- backend erases proofs. +infix 4 _<?_ _>?_ -<-cmp : Trichotomous _≡_ _<_ -<-cmp m n with m n | T? (m <ᵇ n) -... | yes m≡n | _ = tri≈ (<-irrefl m≡n) m≡n (<-irrefl (sym m≡n)) -... | no m≢n | yes m<n = tri< (<ᵇ⇒< m n m<n) m≢n (<⇒≯ (<ᵇ⇒< m n m<n)) -... | no m≢n | no m≮n = tri> (m≮n <⇒<ᵇ) m≢n (≤∧≢⇒< (≮⇒≥ (m≮n <⇒<ᵇ)) (m≢n sym)) +_<?_ : Decidable _<_ +m <? n = suc m ≤? n -infix 4 _<?_ _>?_ +_>?_ : Decidable _>_ +_>?_ = flip _<?_ -_<?_ : Decidable _<_ -m <? n = suc m ≤? n +<-irrelevant : Irrelevant _<_ +<-irrelevant = ≤-irrelevant -_>?_ : Decidable _>_ -_>?_ = flip _<?_ +<-resp₂-≡ : _<_ Respects₂ _≡_ +<-resp₂-≡ = subst (_ <_) , subst (_< _) -<-irrelevant : Irrelevant _<_ -<-irrelevant = ≤-irrelevant +------------------------------------------------------------------------ +-- Bundles -<-resp₂-≡ : _<_ Respects₂ _≡_ -<-resp₂-≡ = subst (_ <_) , subst (_< _) +<-isStrictPartialOrder : IsStrictPartialOrder _≡_ _<_ +<-isStrictPartialOrder = record + { isEquivalence = isEquivalence + ; irrefl = <-irrefl + ; trans = <-trans + ; <-resp-≈ = <-resp₂-≡ + } ------------------------------------------------------------------------- --- Bundles +<-isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_ +<-isStrictTotalOrder = isStrictTotalOrderᶜ record + { isEquivalence = isEquivalence + ; trans = <-trans + ; compare = <-cmp + } -<-isStrictPartialOrder : IsStrictPartialOrder _≡_ _<_ -<-isStrictPartialOrder = record - { isEquivalence = isEquivalence - ; irrefl = <-irrefl - ; trans = <-trans - ; <-resp-≈ = <-resp₂-≡ - } +<-strictPartialOrder : StrictPartialOrder 0ℓ 0ℓ 0ℓ +<-strictPartialOrder = record + { isStrictPartialOrder = <-isStrictPartialOrder + } -<-isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_ -<-isStrictTotalOrder = isStrictTotalOrderᶜ record - { isEquivalence = isEquivalence - ; trans = <-trans - ; compare = <-cmp - } +<-strictTotalOrder : StrictTotalOrder 0ℓ 0ℓ 0ℓ +<-strictTotalOrder = record + { isStrictTotalOrder = <-isStrictTotalOrder + } -<-strictPartialOrder : StrictPartialOrder 0ℓ 0ℓ 0ℓ -<-strictPartialOrder = record - { isStrictPartialOrder = <-isStrictPartialOrder - } +------------------------------------------------------------------------ +-- Other properties of _<_ -<-strictTotalOrder : StrictTotalOrder 0ℓ 0ℓ 0ℓ -<-strictTotalOrder = record - { isStrictTotalOrder = <-isStrictTotalOrder - } +s<s-injective : {p q : m < n} s<s p s<s q p q +s<s-injective refl = refl ------------------------------------------------------------------------- --- Other properties of _<_ +<-pred : suc m < suc n m < n +<-pred = s<s⁻¹ -s<s-injective : {p q : m < n} s<s p s<s q p q -s<s-injective refl = refl +m<n⇒m<1+n : m < n m < 1 + n +m<n⇒m<1+n z<s = z<s +m<n⇒m<1+n (s<s m<n@(s≤s _)) = s<s (m<n⇒m<1+n m<n) -<-pred : suc m < suc n m < n -<-pred = s<s⁻¹ +n≮0 : n 0 +n≮0 () -m<n⇒m<1+n : m < n m < 1 + n -m<n⇒m<1+n z<s = z<s -m<n⇒m<1+n (s<s m<n@(s≤s _)) = s<s (m<n⇒m<1+n m<n) +n≮n : n n n -- implicit? +n≮n n = <-irrefl (refl {x = n}) -n≮0 : n 0 -n≮0 () +0<1+n : 0 < suc n +0<1+n = z<s -n≮n : n n n -- implicit? -n≮n n = <-irrefl (refl {x = n}) +n<1+n : n n < suc n +n<1+n n = ≤-refl -0<1+n : 0 < suc n -0<1+n = z<s +n<1⇒n≡0 : n < 1 n 0 +n<1⇒n≡0 (s≤s n≤0) = n≤0⇒n≡0 n≤0 -n<1+n : n n < suc n -n<1+n n = ≤-refl +n>0⇒n≢0 : n > 0 n 0 +n>0⇒n≢0 {suc n} _ () -n<1⇒n≡0 : n < 1 n 0 -n<1⇒n≡0 (s≤s n≤0) = n≤0⇒n≡0 n≤0 +n≢0⇒n>0 : n 0 n > 0 +n≢0⇒n>0 {zero} 0≢0 = contradiction refl 0≢0 +n≢0⇒n>0 {suc n} _ = 0<1+n -n>0⇒n≢0 : n > 0 n 0 -n>0⇒n≢0 {suc n} _ () +m<n⇒0<n : m < n 0 < n +m<n⇒0<n = ≤-trans 0<1+n + +m<n⇒n≢0 : m < n n 0 +m<n⇒n≢0 (s≤s m≤n) () + +m<n⇒m≤1+n : m < n m suc n +m<n⇒m≤1+n = m≤n⇒m≤1+n <⇒≤ + +m<1+n⇒m<n∨m≡n : {m n} m < suc n m < n m n +m<1+n⇒m<n∨m≡n {0} {0} _ = inj₂ refl +m<1+n⇒m<n∨m≡n {0} {suc n} _ = inj₁ 0<1+n +m<1+n⇒m<n∨m≡n {suc m} {suc n} (s<s m<1+n) = Sum.map s<s (cong suc) (m<1+n⇒m<n∨m≡n m<1+n) + +m≤n⇒m<n∨m≡n : m n m < n m n +m≤n⇒m<n∨m≡n m≤n = m<1+n⇒m<n∨m≡n (s≤s m≤n) + +m<1+n⇒m≤n : m < suc n m n +m<1+n⇒m≤n (s≤s m≤n) = m≤n + +∀[m≤n⇒m≢o]⇒n<o : n o (∀ {m} m n m o) n < o +∀[m≤n⇒m≢o]⇒n<o _ zero m≤n⇒n≢0 = contradiction refl (m≤n⇒n≢0 z≤n) +∀[m≤n⇒m≢o]⇒n<o zero (suc o) _ = 0<1+n +∀[m≤n⇒m≢o]⇒n<o (suc n) (suc o) m≤n⇒n≢o = s≤s (∀[m≤n⇒m≢o]⇒n<o n o rec) + where + rec : {m} m n m o + rec m≤n refl = m≤n⇒n≢o (s≤s m≤n) refl + +∀[m<n⇒m≢o]⇒n≤o : n o (∀ {m} m < n m o) n o +∀[m<n⇒m≢o]⇒n≤o zero n _ = z≤n +∀[m<n⇒m≢o]⇒n≤o (suc n) zero m<n⇒m≢0 = contradiction refl (m<n⇒m≢0 0<1+n) +∀[m<n⇒m≢o]⇒n≤o (suc n) (suc o) m<n⇒m≢o = s≤s (∀[m<n⇒m≢o]⇒n≤o n o rec) + where + rec : {m} m < n m o + rec o<n refl = m<n⇒m≢o (s<s o<n) refl + +------------------------------------------------------------------------ +-- A module for reasoning about the _≤_ and _<_ relations +------------------------------------------------------------------------ + +module ≤-Reasoning where + open import Relation.Binary.Reasoning.Base.Triple + ≤-isPreorder + <-asym + <-trans + (resp₂ _<_) + <⇒≤ + <-≤-trans + ≤-<-trans + public + hiding (step-≈; step-≈˘; step-≈-⟩; step-≈-⟨) + +open ≤-Reasoning + +------------------------------------------------------------------------ +-- Properties of _+_ +------------------------------------------------------------------------ + ++-suc : m n m + suc n suc (m + n) ++-suc zero n = refl ++-suc (suc m) n = cong suc (+-suc m n) + +------------------------------------------------------------------------ +-- Algebraic properties of _+_ + ++-assoc : Associative _+_ ++-assoc zero _ _ = refl ++-assoc (suc m) n o = cong suc (+-assoc m n o) + ++-identityˡ : LeftIdentity 0 _+_ ++-identityˡ _ = refl + ++-identityʳ : RightIdentity 0 _+_ ++-identityʳ zero = refl ++-identityʳ (suc n) = cong suc (+-identityʳ n) + ++-identity : Identity 0 _+_ ++-identity = +-identityˡ , +-identityʳ + ++-comm : Commutative _+_ ++-comm zero n = sym (+-identityʳ n) ++-comm (suc m) n = begin-equality + suc m + n ≡⟨⟩ + suc (m + n) ≡⟨ cong suc (+-comm m n) + suc (n + m) ≡⟨ sym (+-suc n m) + n + suc m + ++-cancelˡ-≡ : LeftCancellative _≡_ _+_ ++-cancelˡ-≡ zero _ _ eq = eq ++-cancelˡ-≡ (suc m) _ _ eq = +-cancelˡ-≡ m _ _ (cong pred eq) + ++-cancelʳ-≡ : RightCancellative _≡_ _+_ ++-cancelʳ-≡ = comm∧cancelˡ⇒cancelʳ +-comm +-cancelˡ-≡ + ++-cancel-≡ : Cancellative _≡_ _+_ ++-cancel-≡ = +-cancelˡ-≡ , +-cancelʳ-≡ + +------------------------------------------------------------------------ +-- Structures + ++-isMagma : IsMagma _+_ ++-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = cong₂ _+_ + } + ++-isSemigroup : IsSemigroup _+_ ++-isSemigroup = record + { isMagma = +-isMagma + ; assoc = +-assoc + } + ++-isCommutativeSemigroup : IsCommutativeSemigroup _+_ ++-isCommutativeSemigroup = record + { isSemigroup = +-isSemigroup + ; comm = +-comm + } + ++-0-isMonoid : IsMonoid _+_ 0 ++-0-isMonoid = record + { isSemigroup = +-isSemigroup + ; identity = +-identity + } + ++-0-isCommutativeMonoid : IsCommutativeMonoid _+_ 0 ++-0-isCommutativeMonoid = record + { isMonoid = +-0-isMonoid + ; comm = +-comm + } + +------------------------------------------------------------------------ +-- Bundles -n≢0⇒n>0 : n 0 n > 0 -n≢0⇒n>0 {zero} 0≢0 = contradiction refl 0≢0 -n≢0⇒n>0 {suc n} _ = 0<1+n ++-magma : Magma 0ℓ 0ℓ ++-magma = record + { isMagma = +-isMagma + } -m<n⇒0<n : m < n 0 < n -m<n⇒0<n = ≤-trans 0<1+n - -m<n⇒n≢0 : m < n n 0 -m<n⇒n≢0 (s≤s m≤n) () - -m<n⇒m≤1+n : m < n m suc n -m<n⇒m≤1+n = m≤n⇒m≤1+n <⇒≤ - -m<1+n⇒m<n∨m≡n : {m n} m < suc n m < n m n -m<1+n⇒m<n∨m≡n {0} {0} _ = inj₂ refl -m<1+n⇒m<n∨m≡n {0} {suc n} _ = inj₁ 0<1+n -m<1+n⇒m<n∨m≡n {suc m} {suc n} (s<s m<1+n) = Sum.map s<s (cong suc) (m<1+n⇒m<n∨m≡n m<1+n) - -m≤n⇒m<n∨m≡n : m n m < n m n -m≤n⇒m<n∨m≡n m≤n = m<1+n⇒m<n∨m≡n (s≤s m≤n) - -m<1+n⇒m≤n : m < suc n m n -m<1+n⇒m≤n (s≤s m≤n) = m≤n - -∀[m≤n⇒m≢o]⇒n<o : n o (∀ {m} m n m o) n < o -∀[m≤n⇒m≢o]⇒n<o _ zero m≤n⇒n≢0 = contradiction refl (m≤n⇒n≢0 z≤n) -∀[m≤n⇒m≢o]⇒n<o zero (suc o) _ = 0<1+n -∀[m≤n⇒m≢o]⇒n<o (suc n) (suc o) m≤n⇒n≢o = s≤s (∀[m≤n⇒m≢o]⇒n<o n o rec) - where - rec : {m} m n m o - rec m≤n refl = m≤n⇒n≢o (s≤s m≤n) refl - -∀[m<n⇒m≢o]⇒n≤o : n o (∀ {m} m < n m o) n o -∀[m<n⇒m≢o]⇒n≤o zero n _ = z≤n -∀[m<n⇒m≢o]⇒n≤o (suc n) zero m<n⇒m≢0 = contradiction refl (m<n⇒m≢0 0<1+n) -∀[m<n⇒m≢o]⇒n≤o (suc n) (suc o) m<n⇒m≢o = s≤s (∀[m<n⇒m≢o]⇒n≤o n o rec) - where - rec : {m} m < n m o - rec o<n refl = m<n⇒m≢o (s<s o<n) refl - ------------------------------------------------------------------------- --- A module for reasoning about the _≤_ and _<_ relations ------------------------------------------------------------------------- - -module ≤-Reasoning where - open import Relation.Binary.Reasoning.Base.Triple - ≤-isPreorder - <-asym - <-trans - (resp₂ _<_) - <⇒≤ - <-≤-trans - ≤-<-trans - public - hiding (step-≈; step-≈˘; step-≈-⟩; step-≈-⟨) - -open ≤-Reasoning - ------------------------------------------------------------------------- --- Properties of _+_ ------------------------------------------------------------------------- - -+-suc : m n m + suc n suc (m + n) -+-suc zero n = refl -+-suc (suc m) n = cong suc (+-suc m n) - ------------------------------------------------------------------------- --- Algebraic properties of _+_ - -+-assoc : Associative _+_ -+-assoc zero _ _ = refl -+-assoc (suc m) n o = cong suc (+-assoc m n o) - -+-identityˡ : LeftIdentity 0 _+_ -+-identityˡ _ = refl - -+-identityʳ : RightIdentity 0 _+_ -+-identityʳ zero = refl -+-identityʳ (suc n) = cong suc (+-identityʳ n) - -+-identity : Identity 0 _+_ -+-identity = +-identityˡ , +-identityʳ - -+-comm : Commutative _+_ -+-comm zero n = sym (+-identityʳ n) -+-comm (suc m) n = begin-equality - suc m + n ≡⟨⟩ - suc (m + n) ≡⟨ cong suc (+-comm m n) - suc (n + m) ≡⟨ sym (+-suc n m) - n + suc m - -+-cancelˡ-≡ : LeftCancellative _≡_ _+_ -+-cancelˡ-≡ zero _ _ eq = eq -+-cancelˡ-≡ (suc m) _ _ eq = +-cancelˡ-≡ m _ _ (cong pred eq) - -+-cancelʳ-≡ : RightCancellative _≡_ _+_ -+-cancelʳ-≡ = comm∧cancelˡ⇒cancelʳ +-comm +-cancelˡ-≡ - -+-cancel-≡ : Cancellative _≡_ _+_ -+-cancel-≡ = +-cancelˡ-≡ , +-cancelʳ-≡ - ------------------------------------------------------------------------- --- Structures - -+-isMagma : IsMagma _+_ -+-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = cong₂ _+_ - } - -+-isSemigroup : IsSemigroup _+_ -+-isSemigroup = record - { isMagma = +-isMagma - ; assoc = +-assoc - } - -+-isCommutativeSemigroup : IsCommutativeSemigroup _+_ -+-isCommutativeSemigroup = record - { isSemigroup = +-isSemigroup - ; comm = +-comm - } - -+-0-isMonoid : IsMonoid _+_ 0 -+-0-isMonoid = record - { isSemigroup = +-isSemigroup - ; identity = +-identity - } - -+-0-isCommutativeMonoid : IsCommutativeMonoid _+_ 0 -+-0-isCommutativeMonoid = record - { isMonoid = +-0-isMonoid - ; comm = +-comm - } - ------------------------------------------------------------------------- --- Bundles ++-semigroup : Semigroup 0ℓ 0ℓ ++-semigroup = record + { isSemigroup = +-isSemigroup + } -+-magma : Magma 0ℓ 0ℓ -+-magma = record - { isMagma = +-isMagma - } ++-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ ++-commutativeSemigroup = record + { isCommutativeSemigroup = +-isCommutativeSemigroup + } -+-semigroup : Semigroup 0ℓ 0ℓ -+-semigroup = record - { isSemigroup = +-isSemigroup - } ++-0-monoid : Monoid 0ℓ 0ℓ ++-0-monoid = record + { isMonoid = +-0-isMonoid + } -+-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ -+-commutativeSemigroup = record - { isCommutativeSemigroup = +-isCommutativeSemigroup - } ++-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ ++-0-commutativeMonoid = record + { isCommutativeMonoid = +-0-isCommutativeMonoid + } -+-0-monoid : Monoid 0ℓ 0ℓ -+-0-monoid = record - { isMonoid = +-0-isMonoid - } +∸-magma : Magma 0ℓ 0ℓ +∸-magma = magma _∸_ -+-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ -+-0-commutativeMonoid = record - { isCommutativeMonoid = +-0-isCommutativeMonoid - } -∸-magma : Magma 0ℓ 0ℓ -∸-magma = magma _∸_ +------------------------------------------------------------------------ +-- Other properties of _+_ and _≡_ +m≢1+m+n : m {n} m suc (m + n) +m≢1+m+n (suc m) eq = m≢1+m+n m (cong pred eq) ------------------------------------------------------------------------- --- Other properties of _+_ and _≡_ +m≢1+n+m : m {n} m suc (n + m) +m≢1+n+m m m≡1+n+m = m≢1+m+n m (trans m≡1+n+m (cong suc (+-comm _ m))) -m≢1+m+n : m {n} m suc (m + n) -m≢1+m+n (suc m) eq = m≢1+m+n m (cong pred eq) +m+1+n≢m : m {n} m + suc n m +m+1+n≢m (suc m) = (m+1+n≢m m) suc-injective -m≢1+n+m : m {n} m suc (n + m) -m≢1+n+m m m≡1+n+m = m≢1+m+n m (trans m≡1+n+m (cong suc (+-comm _ m))) +m+1+n≢n : m {n} m + suc n n +m+1+n≢n m {n} rewrite +-suc m n = ≢-sym (m≢1+n+m n) -m+1+n≢m : m {n} m + suc n m -m+1+n≢m (suc m) = (m+1+n≢m m) suc-injective +m+1+n≢0 : m {n} m + suc n 0 +m+1+n≢0 m {n} rewrite +-suc m n = λ() -m+1+n≢n : m {n} m + suc n n -m+1+n≢n m {n} rewrite +-suc m n = ≢-sym (m≢1+n+m n) +m+n≡0⇒m≡0 : m {n} m + n 0 m 0 +m+n≡0⇒m≡0 zero eq = refl -m+1+n≢0 : m {n} m + suc n 0 -m+1+n≢0 m {n} rewrite +-suc m n = λ() +m+n≡0⇒n≡0 : m {n} m + n 0 n 0 +m+n≡0⇒n≡0 m {n} m+n≡0 = m+n≡0⇒m≡0 n (trans (+-comm n m) (m+n≡0)) -m+n≡0⇒m≡0 : m {n} m + n 0 m 0 -m+n≡0⇒m≡0 zero eq = refl +------------------------------------------------------------------------ +-- Properties of _+_ and _≤_/_<_ -m+n≡0⇒n≡0 : m {n} m + n 0 n 0 -m+n≡0⇒n≡0 m {n} m+n≡0 = m+n≡0⇒m≡0 n (trans (+-comm n m) (m+n≡0)) ++-cancelˡ-≤ : LeftCancellative _≤_ _+_ ++-cancelˡ-≤ zero _ _ le = le ++-cancelˡ-≤ (suc m) _ _ (s≤s le) = +-cancelˡ-≤ m _ _ le ------------------------------------------------------------------------- --- Properties of _+_ and _≤_/_<_ ++-cancelʳ-≤ : RightCancellative _≤_ _+_ ++-cancelʳ-≤ m n o le = + +-cancelˡ-≤ m _ _ (subst₂ _≤_ (+-comm n m) (+-comm o m) le) -+-cancelˡ-≤ : LeftCancellative _≤_ _+_ -+-cancelˡ-≤ zero _ _ le = le -+-cancelˡ-≤ (suc m) _ _ (s≤s le) = +-cancelˡ-≤ m _ _ le ++-cancel-≤ : Cancellative _≤_ _+_ ++-cancel-≤ = +-cancelˡ-≤ , +-cancelʳ-≤ -+-cancelʳ-≤ : RightCancellative _≤_ _+_ -+-cancelʳ-≤ m n o le = - +-cancelˡ-≤ m _ _ (subst₂ _≤_ (+-comm n m) (+-comm o m) le) ++-cancelˡ-< : LeftCancellative _<_ _+_ ++-cancelˡ-< m n o = +-cancelˡ-≤ m (suc n) o subst (_≤ m + o) (sym (+-suc m n)) -+-cancel-≤ : Cancellative _≤_ _+_ -+-cancel-≤ = +-cancelˡ-≤ , +-cancelʳ-≤ ++-cancelʳ-< : RightCancellative _<_ _+_ ++-cancelʳ-< m n o n+m<o+m = +-cancelʳ-≤ m (suc n) o n+m<o+m -+-cancelˡ-< : LeftCancellative _<_ _+_ -+-cancelˡ-< m n o = +-cancelˡ-≤ m (suc n) o subst (_≤ m + o) (sym (+-suc m n)) ++-cancel-< : Cancellative _<_ _+_ ++-cancel-< = +-cancelˡ-< , +-cancelʳ-< -+-cancelʳ-< : RightCancellative _<_ _+_ -+-cancelʳ-< m n o n+m<o+m = +-cancelʳ-≤ m (suc n) o n+m<o+m +m≤n⇒m≤o+n : o m n m o + n +m≤n⇒m≤o+n zero m≤n = m≤n +m≤n⇒m≤o+n (suc o) m≤n = m≤n⇒m≤1+n (m≤n⇒m≤o+n o m≤n) -+-cancel-< : Cancellative _<_ _+_ -+-cancel-< = +-cancelˡ-< , +-cancelʳ-< +m≤n⇒m≤n+o : o m n m n + o +m≤n⇒m≤n+o {m} o m≤n = subst (m ≤_) (+-comm o _) (m≤n⇒m≤o+n o m≤n) -m≤n⇒m≤o+n : o m n m o + n -m≤n⇒m≤o+n zero m≤n = m≤n -m≤n⇒m≤o+n (suc o) m≤n = m≤n⇒m≤1+n (m≤n⇒m≤o+n o m≤n) +m≤m+n : m n m m + n +m≤m+n zero n = z≤n +m≤m+n (suc m) n = s≤s (m≤m+n m n) -m≤n⇒m≤n+o : o m n m n + o -m≤n⇒m≤n+o {m} o m≤n = subst (m ≤_) (+-comm o _) (m≤n⇒m≤o+n o m≤n) +m≤n+m : m n m n + m +m≤n+m m n = subst (m ≤_) (+-comm m n) (m≤m+n m n) -m≤m+n : m n m m + n -m≤m+n zero n = z≤n -m≤m+n (suc m) n = s≤s (m≤m+n m n) +m+n≤o⇒m≤o : m {n o} m + n o m o +m+n≤o⇒m≤o zero m+n≤o = z≤n +m+n≤o⇒m≤o (suc m) (s≤s m+n≤o) = s≤s (m+n≤o⇒m≤o m m+n≤o) -m≤n+m : m n m n + m -m≤n+m m n = subst (m ≤_) (+-comm m n) (m≤m+n m n) +m+n≤o⇒n≤o : m {n o} m + n o n o +m+n≤o⇒n≤o zero n≤o = n≤o +m+n≤o⇒n≤o (suc m) m+n<o = m+n≤o⇒n≤o m (<⇒≤ m+n<o) -m+n≤o⇒m≤o : m {n o} m + n o m o -m+n≤o⇒m≤o zero m+n≤o = z≤n -m+n≤o⇒m≤o (suc m) (s≤s m+n≤o) = s≤s (m+n≤o⇒m≤o m m+n≤o) ++-mono-≤ : Monotonic₂ _≤_ _≤_ _≤_ _+_ ++-mono-≤ {_} {m} z≤n o≤p = ≤-trans o≤p (m≤n+m _ m) ++-mono-≤ {_} {_} (s≤s m≤n) o≤p = s≤s (+-mono-≤ m≤n o≤p) -m+n≤o⇒n≤o : m {n o} m + n o n o -m+n≤o⇒n≤o zero n≤o = n≤o -m+n≤o⇒n≤o (suc m) m+n<o = m+n≤o⇒n≤o m (<⇒≤ m+n<o) ++-monoˡ-≤ : RightMonotonic _≤_ _≤_ _+_ ++-monoˡ-≤ = mono₂⇒monoʳ _ _ _≤_ ≤-refl +-mono-≤ -+-mono-≤ : Monotonic₂ _≤_ _≤_ _≤_ _+_ -+-mono-≤ {_} {m} z≤n o≤p = ≤-trans o≤p (m≤n+m _ m) -+-mono-≤ {_} {_} (s≤s m≤n) o≤p = s≤s (+-mono-≤ m≤n o≤p) ++-monoʳ-≤ : LeftMonotonic _≤_ _≤_ _+_ ++-monoʳ-≤ = mono₂⇒monoˡ _ _ _≤_ ≤-refl +-mono-≤ -+-monoˡ-≤ : RightMonotonic _≤_ _≤_ _+_ -+-monoˡ-≤ = mono₂⇒monoʳ _ _ _≤_ ≤-refl +-mono-≤ ++-mono-<-≤ : Monotonic₂ _<_ _≤_ _<_ _+_ ++-mono-<-≤ {_} {suc n} z<s o≤p = s≤s (m≤n⇒m≤o+n n o≤p) ++-mono-<-≤ {_} {_} (s<s m<n@(s≤s _)) o≤p = s≤s (+-mono-<-≤ m<n o≤p) -+-monoʳ-≤ : LeftMonotonic _≤_ _≤_ _+_ -+-monoʳ-≤ = mono₂⇒monoˡ _ _ _≤_ ≤-refl +-mono-≤ ++-mono-≤-< : Monotonic₂ _≤_ _<_ _<_ _+_ ++-mono-≤-< {_} {n} z≤n o<p = ≤-trans o<p (m≤n+m _ n) ++-mono-≤-< {_} {_} (s≤s m≤n) o<p = s≤s (+-mono-≤-< m≤n o<p) -+-mono-<-≤ : Monotonic₂ _<_ _≤_ _<_ _+_ -+-mono-<-≤ {_} {suc n} z<s o≤p = s≤s (m≤n⇒m≤o+n n o≤p) -+-mono-<-≤ {_} {_} (s<s m<n@(s≤s _)) o≤p = s≤s (+-mono-<-≤ m<n o≤p) ++-mono-< : Monotonic₂ _<_ _<_ _<_ _+_ ++-mono-< m≤n = +-mono-≤-< (<⇒≤ m≤n) -+-mono-≤-< : Monotonic₂ _≤_ _<_ _<_ _+_ -+-mono-≤-< {_} {n} z≤n o<p = ≤-trans o<p (m≤n+m _ n) -+-mono-≤-< {_} {_} (s≤s m≤n) o<p = s≤s (+-mono-≤-< m≤n o<p) ++-monoˡ-< : RightMonotonic _<_ _<_ _+_ ++-monoˡ-< n = +-monoˡ-≤ n -+-mono-< : Monotonic₂ _<_ _<_ _<_ _+_ -+-mono-< m≤n = +-mono-≤-< (<⇒≤ m≤n) ++-monoʳ-< : LeftMonotonic _<_ _<_ _+_ ++-monoʳ-< zero m≤o = m≤o ++-monoʳ-< (suc n) m≤o = s≤s (+-monoʳ-< n m≤o) -+-monoˡ-< : RightMonotonic _<_ _<_ _+_ -+-monoˡ-< n = +-monoˡ-≤ n +m+1+n≰m : m {n} m + suc n m +m+1+n≰m (suc m) m+1+n≤m = m+1+n≰m m (s≤s⁻¹ m+1+n≤m) -+-monoʳ-< : LeftMonotonic _<_ _<_ _+_ -+-monoʳ-< zero m≤o = m≤o -+-monoʳ-< (suc n) m≤o = s≤s (+-monoʳ-< n m≤o) +m<m+n : m {n} n > 0 m < m + n +m<m+n zero n>0 = n>0 +m<m+n (suc m) n>0 = s<s (m<m+n m n>0) -m+1+n≰m : m {n} m + suc n m -m+1+n≰m (suc m) m+1+n≤m = m+1+n≰m m (s≤s⁻¹ m+1+n≤m) +m<n+m : m {n} n > 0 m < n + m +m<n+m m {n} n>0 rewrite +-comm n m = m<m+n m n>0 -m<m+n : m {n} n > 0 m < m + n -m<m+n zero n>0 = n>0 -m<m+n (suc m) n>0 = s<s (m<m+n m n>0) +m+n≮n : m n m + n n +m+n≮n zero n = n≮n n +m+n≮n (suc m) n@(suc _) sm+n<n = m+n≮n m n (m<n⇒m<1+n (s<s⁻¹ sm+n<n)) + +m+n≮m : m n m + n m +m+n≮m m n = subst (_≮ m) (+-comm n m) (m+n≮n n m) + +------------------------------------------------------------------------ +-- Properties of _*_ +------------------------------------------------------------------------ + +*-suc : m n m * suc n m + m * n +*-suc zero n = refl +*-suc (suc m) n = begin-equality + suc m * suc n ≡⟨⟩ + suc n + m * suc n ≡⟨ cong (suc n +_) (*-suc m n) + suc n + (m + m * n) ≡⟨⟩ + suc (n + (m + m * n)) ≡⟨ cong suc (sym (+-assoc n m (m * n))) + suc (n + m + m * n) ≡⟨ cong x suc (x + m * n)) (+-comm n m) + suc (m + n + m * n) ≡⟨ cong suc (+-assoc m n (m * n)) + suc (m + (n + m * n)) ≡⟨⟩ + suc m + suc m * n + +------------------------------------------------------------------------ +-- Algebraic properties of _*_ + +*-identityˡ : LeftIdentity 1 _*_ +*-identityˡ n = +-identityʳ n + +*-identityʳ : RightIdentity 1 _*_ +*-identityʳ zero = refl +*-identityʳ (suc n) = cong suc (*-identityʳ n) + +*-identity : Identity 1 _*_ +*-identity = *-identityˡ , *-identityʳ + +*-zeroˡ : LeftZero 0 _*_ +*-zeroˡ _ = refl + +*-zeroʳ : RightZero 0 _*_ +*-zeroʳ zero = refl +*-zeroʳ (suc n) = *-zeroʳ n + +*-zero : Zero 0 _*_ +*-zero = *-zeroˡ , *-zeroʳ + +*-comm : Commutative _*_ +*-comm zero n = sym (*-zeroʳ n) +*-comm (suc m) n = begin-equality + suc m * n ≡⟨⟩ + n + m * n ≡⟨ cong (n +_) (*-comm m n) + n + n * m ≡⟨ sym (*-suc n m) + n * suc m + +*-distribʳ-+ : _*_ DistributesOverʳ _+_ +*-distribʳ-+ m zero o = refl +*-distribʳ-+ m (suc n) o = begin-equality + (suc n + o) * m ≡⟨⟩ + m + (n + o) * m ≡⟨ cong (m +_) (*-distribʳ-+ m n o) + m + (n * m + o * m) ≡⟨ sym (+-assoc m (n * m) (o * m)) + m + n * m + o * m ≡⟨⟩ + suc n * m + o * m + +*-distribˡ-+ : _*_ DistributesOverˡ _+_ +*-distribˡ-+ = comm∧distrʳ⇒distrˡ *-comm *-distribʳ-+ + +*-distrib-+ : _*_ DistributesOver _+_ +*-distrib-+ = *-distribˡ-+ , *-distribʳ-+ + +*-assoc : Associative _*_ +*-assoc zero n o = refl +*-assoc (suc m) n o = begin-equality + (suc m * n) * o ≡⟨⟩ + (n + m * n) * o ≡⟨ *-distribʳ-+ o n (m * n) + n * o + (m * n) * o ≡⟨ cong (n * o +_) (*-assoc m n o) + n * o + m * (n * o) ≡⟨⟩ + suc m * (n * o) + +------------------------------------------------------------------------ +-- Structures + +*-isMagma : IsMagma _*_ +*-isMagma = record + { isEquivalence = isEquivalence + ; ∙-cong = cong₂ _*_ + } + +*-isSemigroup : IsSemigroup _*_ +*-isSemigroup = record + { isMagma = *-isMagma + ; assoc = *-assoc + } + +*-isCommutativeSemigroup : IsCommutativeSemigroup _*_ +*-isCommutativeSemigroup = record + { isSemigroup = *-isSemigroup + ; comm = *-comm + } + +*-1-isMonoid : IsMonoid _*_ 1 +*-1-isMonoid = record + { isSemigroup = *-isSemigroup + ; identity = *-identity + } + +*-1-isCommutativeMonoid : IsCommutativeMonoid _*_ 1 +*-1-isCommutativeMonoid = record + { isMonoid = *-1-isMonoid + ; comm = *-comm + } + ++-*-isSemiring : IsSemiring _+_ _*_ 0 1 ++-*-isSemiring = record + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = +-0-isCommutativeMonoid + ; *-cong = cong₂ _*_ + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = *-distrib-+ + } + ; zero = *-zero + } + ++-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0 1 ++-*-isCommutativeSemiring = record + { isSemiring = +-*-isSemiring + ; *-comm = *-comm + } + +------------------------------------------------------------------------ +-- Bundles + +*-magma : Magma 0ℓ 0ℓ +*-magma = record + { isMagma = *-isMagma + } + +*-semigroup : Semigroup 0ℓ 0ℓ +*-semigroup = record + { isSemigroup = *-isSemigroup + } + +*-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ +*-commutativeSemigroup = record + { isCommutativeSemigroup = *-isCommutativeSemigroup + } + +*-1-monoid : Monoid 0ℓ 0ℓ +*-1-monoid = record + { isMonoid = *-1-isMonoid + } + +*-1-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ +*-1-commutativeMonoid = record + { isCommutativeMonoid = *-1-isCommutativeMonoid + } + ++-*-semiring : Semiring 0ℓ 0ℓ ++-*-semiring = record + { isSemiring = +-*-isSemiring + } + ++-*-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ ++-*-commutativeSemiring = record + { isCommutativeSemiring = +-*-isCommutativeSemiring + } + +------------------------------------------------------------------------ +-- Other properties of _*_ and _≡_ + +*-cancelʳ-≡ : m n o .{{_ : NonZero o}} m * o n * o m n +*-cancelʳ-≡ zero zero (suc o) eq = refl +*-cancelʳ-≡ (suc m) (suc n) (suc o) eq = + cong suc (*-cancelʳ-≡ m n (suc o) (+-cancelˡ-≡ (suc o) (m * suc o) (n * suc o) eq)) + +*-cancelˡ-≡ : m n o .{{_ : NonZero o}} o * m o * n m n +*-cancelˡ-≡ m n o rewrite *-comm o m | *-comm o n = *-cancelʳ-≡ m n o + +m*n≡0⇒m≡0∨n≡0 : m {n} m * n 0 m 0 n 0 +m*n≡0⇒m≡0∨n≡0 zero {n} eq = inj₁ refl +m*n≡0⇒m≡0∨n≡0 (suc m) {zero} eq = inj₂ refl + +m*n≢0 : m n .{{_ : NonZero m}} .{{_ : NonZero n}} NonZero (m * n) +m*n≢0 (suc m) (suc n) = _ + +m*n≢0⇒m≢0 : m {n} .{{NonZero (m * n)}} NonZero m +m*n≢0⇒m≢0 (suc _) = _ + +m*n≢0⇒n≢0 : m {n} .{{NonZero (m * n)}} NonZero n +m*n≢0⇒n≢0 m {n} rewrite *-comm m n = m*n≢0⇒m≢0 n {m} + +m*n≡0⇒m≡0 : m n .{{_ : NonZero n}} m * n 0 m 0 +m*n≡0⇒m≡0 zero (suc _) eq = refl + +m*n≡1⇒m≡1 : m n m * n 1 m 1 +m*n≡1⇒m≡1 (suc zero) n _ = refl +m*n≡1⇒m≡1 (suc (suc m)) (suc zero) () +m*n≡1⇒m≡1 (suc (suc m)) zero eq = + contradiction (trans (sym $ *-zeroʳ m) eq) λ() + +m*n≡1⇒n≡1 : m n m * n 1 n 1 +m*n≡1⇒n≡1 m n eq = m*n≡1⇒m≡1 n m (trans (*-comm n m) eq) + +[m*n]*[o*p]≡[m*o]*[n*p] : m n o p (m * n) * (o * p) (m * o) * (n * p) +[m*n]*[o*p]≡[m*o]*[n*p] m n o p = begin-equality + (m * n) * (o * p) ≡⟨ *-assoc m n (o * p) + m * (n * (o * p)) ≡⟨ cong (m *_) (x∙yz≈y∙xz n o p) + m * (o * (n * p)) ≡⟨ *-assoc m o (n * p) + (m * o) * (n * p) + where open CommSemigroupProperties *-commutativeSemigroup + +m≢0∧n>1⇒m*n>1 : m n .{{_ : NonZero m}} .{{_ : NonTrivial n}} NonTrivial (m * n) +m≢0∧n>1⇒m*n>1 (suc m) (2+ n) = _ + +n≢0∧m>1⇒m*n>1 : m n .{{_ : NonZero n}} .{{_ : NonTrivial m}} NonTrivial (m * n) +n≢0∧m>1⇒m*n>1 m n rewrite *-comm m n = m≢0∧n>1⇒m*n>1 n m + +------------------------------------------------------------------------ +-- Other properties of _*_ and _≤_/_<_ + +*-cancelʳ-≤ : m n o .{{_ : NonZero o}} m * o n * o m n +*-cancelʳ-≤ zero _ _ _ = z≤n +*-cancelʳ-≤ (suc m) (suc n) o@(suc _) le = + s≤s (*-cancelʳ-≤ m n o (+-cancelˡ-≤ _ _ _ le)) + +*-cancelˡ-≤ : o .{{_ : NonZero o}} o * m o * n m n +*-cancelˡ-≤ {m} {n} o rewrite *-comm o m | *-comm o n = *-cancelʳ-≤ m n o + +*-mono-≤ : Monotonic₂ _≤_ _≤_ _≤_ _*_ +*-mono-≤ z≤n u≤v = z≤n +*-mono-≤ (s≤s m≤n) u≤v = +-mono-≤ u≤v (*-mono-≤ m≤n u≤v) + +*-monoˡ-≤ : RightMonotonic _≤_ _≤_ _*_ +*-monoˡ-≤ = mono₂⇒monoʳ _ _ _≤_ ≤-refl *-mono-≤ + +*-monoʳ-≤ : LeftMonotonic _≤_ _≤_ _*_ +*-monoʳ-≤ = mono₂⇒monoˡ _≤_ _≤_ _≤_ ≤-refl *-mono-≤ + +*-mono-< : Monotonic₂ _<_ _<_ _<_ _*_ +*-mono-< z<s u<v@(s≤s _) = 0<1+n +*-mono-< (s<s m<n@(s≤s _)) u<v@(s≤s _) = +-mono-< u<v (*-mono-< m<n u<v) + +*-monoˡ-< : n .{{_ : NonZero n}} Monotonic₁ _<_ _<_ (_* n) +*-monoˡ-< n@(suc _) z<s = 0<1+n +*-monoˡ-< n@(suc _) (s<s m<o@(s≤s _)) = +-mono-≤-< ≤-refl (*-monoˡ-< n m<o) + +*-monoʳ-< : n .{{_ : NonZero n}} Monotonic₁ _<_ _<_ (n *_) +*-monoʳ-< (suc zero) m<o@(s≤s _) = +-mono-≤ m<o z≤n +*-monoʳ-< (suc n@(suc _)) m<o@(s≤s _) = +-mono-≤ m<o (<⇒≤ (*-monoʳ-< n m<o)) + +m≤m*n : m n .{{_ : NonZero n}} m m * n +m≤m*n m n@(suc _) = begin + m ≡⟨ sym (*-identityʳ m) + m * 1 ≤⟨ *-monoʳ-≤ m 0<1+n + m * n + +m≤n*m : m n .{{_ : NonZero n}} m n * m +m≤n*m m n@(suc _) = begin + m ≤⟨ m≤m*n m n + m * n ≡⟨ *-comm m n + n * m + +m≤n⇒m≤o*n : o .{{_ : NonZero o}} m n m o * n +m≤n⇒m≤o*n o m≤n = ≤-trans m≤n (m≤n*m _ o) + +m≤n⇒m≤n*o : o .{{_ : NonZero o}} m n m n * o +m≤n⇒m≤n*o o m≤n = ≤-trans m≤n (m≤m*n _ o) + +m<m*n : m n .{{_ : NonZero m}} 1 < n m < m * n +m<m*n m@(suc m-1) n@(suc (suc n-2)) (s≤s (s≤s _)) = begin-strict + m <⟨ s≤s (s≤s (m≤n+m m-1 n-2)) + n + m-1 ≤⟨ +-monoʳ-≤ n (m≤m*n m-1 n) + n + m-1 * n ≡⟨⟩ + m * n + +m<n⇒m<n*o : o .{{_ : NonZero o}} m < n m < n * o +m<n⇒m<n*o = m≤n⇒m≤n*o + +m<n⇒m<o*n : {m n} o .{{_ : NonZero o}} m < n m < o * n +m<n⇒m<o*n = m≤n⇒m≤o*n + +*-cancelʳ-< : RightCancellative _<_ _*_ +*-cancelʳ-< zero zero (suc o) _ = 0<1+n +*-cancelʳ-< (suc m) zero (suc o) _ = 0<1+n +*-cancelʳ-< m (suc n) (suc o) nm<om = + s≤s (*-cancelʳ-< m n o (+-cancelˡ-< m _ _ nm<om)) + +*-cancelˡ-< : LeftCancellative _<_ _*_ +*-cancelˡ-< x y z rewrite *-comm x y | *-comm x z = *-cancelʳ-< x y z + +*-cancel-< : Cancellative _<_ _*_ +*-cancel-< = *-cancelˡ-< , *-cancelʳ-< + +------------------------------------------------------------------------ +-- Properties of _^_ +------------------------------------------------------------------------ + +^-identityʳ : RightIdentity 1 _^_ +^-identityʳ zero = refl +^-identityʳ (suc n) = cong suc (^-identityʳ n) + +^-zeroˡ : LeftZero 1 _^_ +^-zeroˡ zero = refl +^-zeroˡ (suc n) = begin-equality + 1 ^ suc n ≡⟨⟩ + 1 * (1 ^ n) ≡⟨ *-identityˡ (1 ^ n) + 1 ^ n ≡⟨ ^-zeroˡ n + 1 + +^-distribˡ-+-* : m n o m ^ (n + o) m ^ n * m ^ o +^-distribˡ-+-* m zero o = sym (+-identityʳ (m ^ o)) +^-distribˡ-+-* m (suc n) o = begin-equality + m * (m ^ (n + o)) ≡⟨ cong (m *_) (^-distribˡ-+-* m n o) + m * ((m ^ n) * (m ^ o)) ≡⟨ sym (*-assoc m _ _) + (m * (m ^ n)) * (m ^ o) + +^-semigroup-morphism : {n} (n ^_) Is +-semigroup -Semigroup⟶ *-semigroup +^-semigroup-morphism = record + { ⟦⟧-cong = cong (_ ^_) + ; ∙-homo = ^-distribˡ-+-* _ + } + +^-monoid-morphism : {n} (n ^_) Is +-0-monoid -Monoid⟶ *-1-monoid +^-monoid-morphism = record + { sm-homo = ^-semigroup-morphism + ; ε-homo = refl + } + +^-*-assoc : m n o (m ^ n) ^ o m ^ (n * o) +^-*-assoc m n zero = cong (m ^_) (sym $ *-zeroʳ n) +^-*-assoc m n (suc o) = begin-equality + (m ^ n) * ((m ^ n) ^ o) ≡⟨ cong ((m ^ n) *_) (^-*-assoc m n o) + (m ^ n) * (m ^ (n * o)) ≡⟨ sym (^-distribˡ-+-* m n (n * o)) + m ^ (n + n * o) ≡⟨ cong (m ^_) (sym (*-suc n o)) + m ^ (n * (suc o)) + +m^n≡0⇒m≡0 : m n m ^ n 0 m 0 +m^n≡0⇒m≡0 m (suc n) eq = [ id , m^n≡0⇒m≡0 m n ]′ (m*n≡0⇒m≡0∨n≡0 m eq) + +m^n≡1⇒n≡0∨m≡1 : m n m ^ n 1 n 0 m 1 +m^n≡1⇒n≡0∨m≡1 m zero _ = inj₁ refl +m^n≡1⇒n≡0∨m≡1 m (suc n) eq = inj₂ (m*n≡1⇒m≡1 m (m ^ n) eq) + +m^n≢0 : m n .{{_ : NonZero m}} NonZero (m ^ n) +m^n≢0 m n = ≢-nonZero (≢-nonZero⁻¹ m ∘′ m^n≡0⇒m≡0 m n) + +m^n>0 : m .{{_ : NonZero m}} n m ^ n > 0 +m^n>0 m n = >-nonZero⁻¹ (m ^ n) {{m^n≢0 m n}} + +^-monoˡ-≤ : RightMonotonic _≤_ _≤_ _^_ +^-monoˡ-≤ zero m≤o = s≤s z≤n +^-monoˡ-≤ (suc n) m≤o = *-mono-≤ m≤o (^-monoˡ-≤ n m≤o) + +^-monoʳ-≤ : m .{{_ : NonZero m}} Monotonic₁ _≤_ _≤_ (m ^_) +^-monoʳ-≤ m {_} {o} z≤n = n≢0⇒n>0 (≢-nonZero⁻¹ (m ^ o) {{m^n≢0 m o}}) +^-monoʳ-≤ m (s≤s n≤o) = *-monoʳ-≤ m (^-monoʳ-≤ m n≤o) + +^-monoˡ-< : n .{{_ : NonZero n}} Monotonic₁ _<_ _<_ (_^ n) +^-monoˡ-< (suc zero) m<o = *-monoˡ-< 1 m<o +^-monoˡ-< (suc n@(suc _)) m<o = *-mono-< m<o (^-monoˡ-< n m<o) + +^-monoʳ-< : m 1 < m Monotonic₁ _<_ _<_ (m ^_) +^-monoʳ-< m@(suc _) 1<m {zero} {suc o} z<s = *-mono-≤ 1<m (m^n>0 m o) +^-monoʳ-< m@(suc _) 1<m {suc n} {suc o} (s<s n<o) = *-monoʳ-< m (^-monoʳ-< m 1<m n<o) + +------------------------------------------------------------------------ +-- Properties of _⊓_ and _⊔_ +------------------------------------------------------------------------ +-- Basic specification in terms of _≤_ + +m≤n⇒m⊔n≡n : m n m n n +m≤n⇒m⊔n≡n {zero} _ = refl +m≤n⇒m⊔n≡n {suc m} (s≤s m≤n) = cong suc (m≤n⇒m⊔n≡n m≤n) + +m≥n⇒m⊔n≡m : m n m n m +m≥n⇒m⊔n≡m {zero} {zero} z≤n = refl +m≥n⇒m⊔n≡m {suc m} {zero} z≤n = refl +m≥n⇒m⊔n≡m {suc m} {suc n} (s≤s m≥n) = cong suc (m≥n⇒m⊔n≡m m≥n) + +m≤n⇒m⊓n≡m : m n m n m +m≤n⇒m⊓n≡m {zero} z≤n = refl +m≤n⇒m⊓n≡m {suc m} (s≤s m≤n) = cong suc (m≤n⇒m⊓n≡m m≤n) + +m≥n⇒m⊓n≡n : m n m n n +m≥n⇒m⊓n≡n {zero} {zero} z≤n = refl +m≥n⇒m⊓n≡n {suc m} {zero} z≤n = refl +m≥n⇒m⊓n≡n {suc m} {suc n} (s≤s m≤n) = cong suc (m≥n⇒m⊓n≡n m≤n) + +⊓-operator : MinOperator ≤-totalPreorder +⊓-operator = record + { x≤y⇒x⊓y≈x = m≤n⇒m⊓n≡m + ; x≥y⇒x⊓y≈y = m≥n⇒m⊓n≡n + } + +⊔-operator : MaxOperator ≤-totalPreorder +⊔-operator = record + { x≤y⇒x⊔y≈y = m≤n⇒m⊔n≡n + ; x≥y⇒x⊔y≈x = m≥n⇒m⊔n≡m + } + +------------------------------------------------------------------------ +-- Equality to their counterparts defined in terms of primitive operations + +⊔≡⊔′ : m n m n m ⊔′ n +⊔≡⊔′ m n with m <ᵇ n in eq +... | false = m≥n⇒m⊔n≡m (≮⇒≥ m<n subst T eq (<⇒<ᵇ m<n))) +... | true = m≤n⇒m⊔n≡n (<⇒≤ (<ᵇ⇒< m n (subst T (sym eq) _))) + +⊓≡⊓′ : m n m n m ⊓′ n +⊓≡⊓′ m n with m <ᵇ n in eq +... | false = m≥n⇒m⊓n≡n (≮⇒≥ m<n subst T eq (<⇒<ᵇ m<n))) +... | true = m≤n⇒m⊓n≡m (<⇒≤ (<ᵇ⇒< m n (subst T (sym eq) _))) + +------------------------------------------------------------------------ +-- Derived properties of _⊓_ and _⊔_ + +private + module ⊓-⊔-properties = MinMaxOp ⊓-operator ⊔-operator + module ⊓-⊔-latticeProperties = LatticeMinMaxOp ⊓-operator ⊔-operator + +open ⊓-⊔-properties public + using + ( ⊓-idem -- : Idempotent _⊓_ + ; ⊓-sel -- : Selective _⊓_ + ; ⊓-assoc -- : Associative _⊓_ + ; ⊓-comm -- : Commutative _⊓_ + + ; ⊔-idem -- : Idempotent _⊔_ + ; ⊔-sel -- : Selective _⊔_ + ; ⊔-assoc -- : Associative _⊔_ + ; ⊔-comm -- : Commutative _⊔_ + + ; ⊓-distribˡ-⊔ -- : _⊓_ DistributesOverˡ _⊔_ + ; ⊓-distribʳ-⊔ -- : _⊓_ DistributesOverʳ _⊔_ + ; ⊓-distrib-⊔ -- : _⊓_ DistributesOver _⊔_ + ; ⊔-distribˡ-⊓ -- : _⊔_ DistributesOverˡ _⊓_ + ; ⊔-distribʳ-⊓ -- : _⊔_ DistributesOverʳ _⊓_ + ; ⊔-distrib-⊓ -- : _⊔_ DistributesOver _⊓_ + ; ⊓-absorbs-⊔ -- : _⊓_ Absorbs _⊔_ + ; ⊔-absorbs-⊓ -- : _⊔_ Absorbs _⊓_ + ; ⊔-⊓-absorptive -- : Absorptive _⊔_ _⊓_ + ; ⊓-⊔-absorptive -- : Absorptive _⊓_ _⊔_ + + ; ⊓-isMagma -- : IsMagma _⊓_ + ; ⊓-isSemigroup -- : IsSemigroup _⊓_ + ; ⊓-isCommutativeSemigroup -- : IsCommutativeSemigroup _⊓_ + ; ⊓-isBand -- : IsBand _⊓_ + ; ⊓-isSelectiveMagma -- : IsSelectiveMagma _⊓_ + + ; ⊔-isMagma -- : IsMagma _⊔_ + ; ⊔-isSemigroup -- : IsSemigroup _⊔_ + ; ⊔-isCommutativeSemigroup -- : IsCommutativeSemigroup _⊔_ + ; ⊔-isBand -- : IsBand _⊔_ + ; ⊔-isSelectiveMagma -- : IsSelectiveMagma _⊔_ + + ; ⊓-magma -- : Magma _ _ + ; ⊓-semigroup -- : Semigroup _ _ + ; ⊓-band -- : Band _ _ + ; ⊓-commutativeSemigroup -- : CommutativeSemigroup _ _ + ; ⊓-selectiveMagma -- : SelectiveMagma _ _ + + ; ⊔-magma -- : Magma _ _ + ; ⊔-semigroup -- : Semigroup _ _ + ; ⊔-band -- : Band _ _ + ; ⊔-commutativeSemigroup -- : CommutativeSemigroup _ _ + ; ⊔-selectiveMagma -- : SelectiveMagma _ _ + + ; ⊓-glb -- : ∀ {m n o} → m ≥ o → n ≥ o → m ⊓ n ≥ o + ; ⊓-triangulate -- : ∀ m n o → m ⊓ n ⊓ o ≡ (m ⊓ n) ⊓ (n ⊓ o) + ; ⊓-mono-≤ -- : _⊓_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_ + ; ⊓-monoˡ-≤ -- : ∀ n → (_⊓ n) Preserves _≤_ ⟶ _≤_ + ; ⊓-monoʳ-≤ -- : ∀ n → (n ⊓_) Preserves _≤_ ⟶ _≤_ + + ; ⊔-lub -- : ∀ {m n o} → m ≤ o → n ≤ o → m ⊔ n ≤ o + ; ⊔-triangulate -- : ∀ m n o → m ⊔ n ⊔ o ≡ (m ⊔ n) ⊔ (n ⊔ o) + ; ⊔-mono-≤ -- : _⊔_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_ + ; ⊔-monoˡ-≤ -- : ∀ n → (_⊔ n) Preserves _≤_ ⟶ _≤_ + ; ⊔-monoʳ-≤ -- : ∀ n → (n ⊔_) Preserves _≤_ ⟶ _≤_ + ) + renaming + ( x⊓y≈y⇒y≤x to m⊓n≡n⇒n≤m -- : ∀ {m n} → m ⊓ n ≡ n → n ≤ m + ; x⊓y≈x⇒x≤y to m⊓n≡m⇒m≤n -- : ∀ {m n} → m ⊓ n ≡ m → m ≤ n + ; x⊓y≤x to m⊓n≤m -- : ∀ m n → m ⊓ n ≤ m + ; x⊓y≤y to m⊓n≤n -- : ∀ m n → m ⊓ n ≤ n + ; x≤y⇒x⊓z≤y to m≤n⇒m⊓o≤n -- : ∀ {m n} o → m ≤ n → m ⊓ o ≤ n + ; x≤y⇒z⊓x≤y to m≤n⇒o⊓m≤n -- : ∀ {m n} o → m ≤ n → o ⊓ m ≤ n + ; x≤y⊓z⇒x≤y to m≤n⊓o⇒m≤n -- : ∀ {m} n o → m ≤ n ⊓ o → m ≤ n + ; x≤y⊓z⇒x≤z to m≤n⊓o⇒m≤o -- : ∀ {m} n o → m ≤ n ⊓ o → m ≤ o + + ; x⊔y≈y⇒x≤y to m⊔n≡n⇒m≤n -- : ∀ {m n} → m ⊔ n ≡ n → m ≤ n + ; x⊔y≈x⇒y≤x to m⊔n≡m⇒n≤m -- : ∀ {m n} → m ⊔ n ≡ m → n ≤ m + ; x≤x⊔y to m≤m⊔n -- : ∀ m n → m ≤ m ⊔ n + ; x≤y⊔x to m≤n⊔m -- : ∀ m n → m ≤ n ⊔ m + ; x≤y⇒x≤y⊔z to m≤n⇒m≤n⊔o -- : ∀ {m n} o → m ≤ n → m ≤ n ⊔ o + ; x≤y⇒x≤z⊔y to m≤n⇒m≤o⊔n -- : ∀ {m n} o → m ≤ n → m ≤ o ⊔ n + ; x⊔y≤z⇒x≤z to m⊔n≤o⇒m≤o -- : ∀ m n {o} → m ⊔ n ≤ o → m ≤ o + ; x⊔y≤z⇒y≤z to m⊔n≤o⇒n≤o -- : ∀ m n {o} → m ⊔ n ≤ o → n ≤ o + + ; x⊓y≤x⊔y to m⊓n≤m⊔n -- : ∀ m n → m ⊓ n ≤ m ⊔ n + ) + +open ⊓-⊔-latticeProperties public + using + ( ⊓-isSemilattice -- : IsSemilattice _⊓_ + ; ⊔-isSemilattice -- : IsSemilattice _⊔_ + ; ⊔-⊓-isLattice -- : IsLattice _⊔_ _⊓_ + ; ⊓-⊔-isLattice -- : IsLattice _⊓_ _⊔_ + ; ⊔-⊓-isDistributiveLattice -- : IsDistributiveLattice _⊔_ _⊓_ + ; ⊓-⊔-isDistributiveLattice -- : IsDistributiveLattice _⊓_ _⊔_ + + ; ⊓-semilattice -- : Semilattice _ _ + ; ⊔-semilattice -- : Semilattice _ _ + ; ⊔-⊓-lattice -- : Lattice _ _ + ; ⊓-⊔-lattice -- : Lattice _ _ + ; ⊔-⊓-distributiveLattice -- : DistributiveLattice _ _ + ; ⊓-⊔-distributiveLattice -- : DistributiveLattice _ _ + ) + +------------------------------------------------------------------------ +-- Automatically derived properties of _⊓_ and _⊔_ + +⊔-identityˡ : LeftIdentity 0 _⊔_ +⊔-identityˡ _ = refl + +⊔-identityʳ : RightIdentity 0 _⊔_ +⊔-identityʳ zero = refl +⊔-identityʳ (suc n) = refl + +⊔-identity : Identity 0 _⊔_ +⊔-identity = ⊔-identityˡ , ⊔-identityʳ + +------------------------------------------------------------------------ +-- Structures + +⊔-0-isMonoid : IsMonoid _⊔_ 0 +⊔-0-isMonoid = record + { isSemigroup = ⊔-isSemigroup + ; identity = ⊔-identity + } + +⊔-0-isCommutativeMonoid : IsCommutativeMonoid _⊔_ 0 +⊔-0-isCommutativeMonoid = record + { isMonoid = ⊔-0-isMonoid + ; comm = ⊔-comm + } + +------------------------------------------------------------------------ +-- Bundles + +⊔-0-monoid : Monoid 0ℓ 0ℓ +⊔-0-monoid = record + { isMonoid = ⊔-0-isMonoid + } + +⊔-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ +⊔-0-commutativeMonoid = record + { isCommutativeMonoid = ⊔-0-isCommutativeMonoid + } + +------------------------------------------------------------------------ +-- Other properties of _⊔_ and _≤_/_<_ + +mono-≤-distrib-⊔ : {f} f Preserves _≤_ _≤_ + m n f (m n) f m f n +mono-≤-distrib-⊔ {f} = ⊓-⊔-properties.mono-≤-distrib-⊔ (cong f) + +mono-≤-distrib-⊓ : {f} f Preserves _≤_ _≤_ + m n f (m n) f m f n +mono-≤-distrib-⊓ {f} = ⊓-⊔-properties.mono-≤-distrib-⊓ (cong f) + +antimono-≤-distrib-⊓ : {f} f Preserves _≤_ _≥_ + m n f (m n) f m f n +antimono-≤-distrib-⊓ {f} = ⊓-⊔-properties.antimono-≤-distrib-⊓ (cong f) + +antimono-≤-distrib-⊔ : {f} f Preserves _≤_ _≥_ + m n f (m n) f m f n +antimono-≤-distrib-⊔ {f} = ⊓-⊔-properties.antimono-≤-distrib-⊔ (cong f) + +m<n⇒m<n⊔o : o m < n m < n o +m<n⇒m<n⊔o = m≤n⇒m≤n⊔o + +m<n⇒m<o⊔n : o m < n m < o n +m<n⇒m<o⊔n = m≤n⇒m≤o⊔n + +m⊔n<o⇒m<o : m n {o} m n < o m < o +m⊔n<o⇒m<o m n m⊔n<o = ≤-<-trans (m≤m⊔n m n) m⊔n<o + +m⊔n<o⇒n<o : m n {o} m n < o n < o +m⊔n<o⇒n<o m n m⊔n<o = ≤-<-trans (m≤n⊔m m n) m⊔n<o + +⊔-mono-< : _⊔_ Preserves₂ _<_ _<_ _<_ +⊔-mono-< = ⊔-mono-≤ + +⊔-pres-<m : n < m o < m n o < m +⊔-pres-<m {m = m} n<m o<m = subst (_ <_) (⊔-idem m) (⊔-mono-< n<m o<m) + +------------------------------------------------------------------------ +-- Other properties of _⊔_ and _+_ + ++-distribˡ-⊔ : _+_ DistributesOverˡ _⊔_ ++-distribˡ-⊔ zero n o = refl ++-distribˡ-⊔ (suc m) n o = cong suc (+-distribˡ-⊔ m n o) + ++-distribʳ-⊔ : _+_ DistributesOverʳ _⊔_ ++-distribʳ-⊔ = comm∧distrˡ⇒distrʳ +-comm +-distribˡ-⊔ + ++-distrib-⊔ : _+_ DistributesOver _⊔_ ++-distrib-⊔ = +-distribˡ-⊔ , +-distribʳ-⊔ -m<n+m : m {n} n > 0 m < n + m -m<n+m m {n} n>0 rewrite +-comm n m = m<m+n m n>0 +m⊔n≤m+n : m n m n m + n +m⊔n≤m+n m n with ⊔-sel m n +... | inj₁ m⊔n≡m rewrite m⊔n≡m = m≤m+n m n +... | inj₂ m⊔n≡n rewrite m⊔n≡n = m≤n+m n m -m+n≮n : m n m + n n -m+n≮n zero n = n≮n n -m+n≮n (suc m) n@(suc _) sm+n<n = m+n≮n m n (m<n⇒m<1+n (s<s⁻¹ sm+n<n)) - -m+n≮m : m n m + n m -m+n≮m m n = subst (_≮ m) (+-comm n m) (m+n≮n n m) - ------------------------------------------------------------------------- --- Properties of _*_ ------------------------------------------------------------------------- - -*-suc : m n m * suc n m + m * n -*-suc zero n = refl -*-suc (suc m) n = begin-equality - suc m * suc n ≡⟨⟩ - suc n + m * suc n ≡⟨ cong (suc n +_) (*-suc m n) - suc n + (m + m * n) ≡⟨⟩ - suc (n + (m + m * n)) ≡⟨ cong suc (sym (+-assoc n m (m * n))) - suc (n + m + m * n) ≡⟨ cong x suc (x + m * n)) (+-comm n m) - suc (m + n + m * n) ≡⟨ cong suc (+-assoc m n (m * n)) - suc (m + (n + m * n)) ≡⟨⟩ - suc m + suc m * n - ------------------------------------------------------------------------- --- Algebraic properties of _*_ - -*-identityˡ : LeftIdentity 1 _*_ -*-identityˡ n = +-identityʳ n - -*-identityʳ : RightIdentity 1 _*_ -*-identityʳ zero = refl -*-identityʳ (suc n) = cong suc (*-identityʳ n) - -*-identity : Identity 1 _*_ -*-identity = *-identityˡ , *-identityʳ - -*-zeroˡ : LeftZero 0 _*_ -*-zeroˡ _ = refl - -*-zeroʳ : RightZero 0 _*_ -*-zeroʳ zero = refl -*-zeroʳ (suc n) = *-zeroʳ n - -*-zero : Zero 0 _*_ -*-zero = *-zeroˡ , *-zeroʳ - -*-comm : Commutative _*_ -*-comm zero n = sym (*-zeroʳ n) -*-comm (suc m) n = begin-equality - suc m * n ≡⟨⟩ - n + m * n ≡⟨ cong (n +_) (*-comm m n) - n + n * m ≡⟨ sym (*-suc n m) - n * suc m - -*-distribʳ-+ : _*_ DistributesOverʳ _+_ -*-distribʳ-+ m zero o = refl -*-distribʳ-+ m (suc n) o = begin-equality - (suc n + o) * m ≡⟨⟩ - m + (n + o) * m ≡⟨ cong (m +_) (*-distribʳ-+ m n o) - m + (n * m + o * m) ≡⟨ sym (+-assoc m (n * m) (o * m)) - m + n * m + o * m ≡⟨⟩ - suc n * m + o * m - -*-distribˡ-+ : _*_ DistributesOverˡ _+_ -*-distribˡ-+ = comm∧distrʳ⇒distrˡ *-comm *-distribʳ-+ - -*-distrib-+ : _*_ DistributesOver _+_ -*-distrib-+ = *-distribˡ-+ , *-distribʳ-+ - -*-assoc : Associative _*_ -*-assoc zero n o = refl -*-assoc (suc m) n o = begin-equality - (suc m * n) * o ≡⟨⟩ - (n + m * n) * o ≡⟨ *-distribʳ-+ o n (m * n) - n * o + (m * n) * o ≡⟨ cong (n * o +_) (*-assoc m n o) - n * o + m * (n * o) ≡⟨⟩ - suc m * (n * o) - ------------------------------------------------------------------------- --- Structures - -*-isMagma : IsMagma _*_ -*-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = cong₂ _*_ - } - -*-isSemigroup : IsSemigroup _*_ -*-isSemigroup = record - { isMagma = *-isMagma - ; assoc = *-assoc - } - -*-isCommutativeSemigroup : IsCommutativeSemigroup _*_ -*-isCommutativeSemigroup = record - { isSemigroup = *-isSemigroup - ; comm = *-comm - } - -*-1-isMonoid : IsMonoid _*_ 1 -*-1-isMonoid = record - { isSemigroup = *-isSemigroup - ; identity = *-identity - } - -*-1-isCommutativeMonoid : IsCommutativeMonoid _*_ 1 -*-1-isCommutativeMonoid = record - { isMonoid = *-1-isMonoid - ; comm = *-comm - } - -+-*-isSemiring : IsSemiring _+_ _*_ 0 1 -+-*-isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-0-isCommutativeMonoid - ; *-cong = cong₂ _*_ - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = *-distrib-+ - } - ; zero = *-zero - } - -+-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0 1 -+-*-isCommutativeSemiring = record - { isSemiring = +-*-isSemiring - ; *-comm = *-comm - } - ------------------------------------------------------------------------- --- Bundles - -*-magma : Magma 0ℓ 0ℓ -*-magma = record - { isMagma = *-isMagma - } - -*-semigroup : Semigroup 0ℓ 0ℓ -*-semigroup = record - { isSemigroup = *-isSemigroup - } - -*-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ -*-commutativeSemigroup = record - { isCommutativeSemigroup = *-isCommutativeSemigroup - } - -*-1-monoid : Monoid 0ℓ 0ℓ -*-1-monoid = record - { isMonoid = *-1-isMonoid - } - -*-1-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ -*-1-commutativeMonoid = record - { isCommutativeMonoid = *-1-isCommutativeMonoid - } - -+-*-semiring : Semiring 0ℓ 0ℓ -+-*-semiring = record - { isSemiring = +-*-isSemiring - } - -+-*-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ -+-*-commutativeSemiring = record - { isCommutativeSemiring = +-*-isCommutativeSemiring - } - ------------------------------------------------------------------------- --- Other properties of _*_ and _≡_ - -*-cancelʳ-≡ : m n o .{{_ : NonZero o}} m * o n * o m n -*-cancelʳ-≡ zero zero (suc o) eq = refl -*-cancelʳ-≡ (suc m) (suc n) (suc o) eq = - cong suc (*-cancelʳ-≡ m n (suc o) (+-cancelˡ-≡ (suc o) (m * suc o) (n * suc o) eq)) - -*-cancelˡ-≡ : m n o .{{_ : NonZero o}} o * m o * n m n -*-cancelˡ-≡ m n o rewrite *-comm o m | *-comm o n = *-cancelʳ-≡ m n o - -m*n≡0⇒m≡0∨n≡0 : m {n} m * n 0 m 0 n 0 -m*n≡0⇒m≡0∨n≡0 zero {n} eq = inj₁ refl -m*n≡0⇒m≡0∨n≡0 (suc m) {zero} eq = inj₂ refl - -m*n≢0 : m n .{{_ : NonZero m}} .{{_ : NonZero n}} NonZero (m * n) -m*n≢0 (suc m) (suc n) = _ - -m*n≢0⇒m≢0 : m {n} .{{NonZero (m * n)}} NonZero m -m*n≢0⇒m≢0 (suc _) = _ - -m*n≢0⇒n≢0 : m {n} .{{NonZero (m * n)}} NonZero n -m*n≢0⇒n≢0 m {n} rewrite *-comm m n = m*n≢0⇒m≢0 n {m} - -m*n≡0⇒m≡0 : m n .{{_ : NonZero n}} m * n 0 m 0 -m*n≡0⇒m≡0 zero (suc _) eq = refl - -m*n≡1⇒m≡1 : m n m * n 1 m 1 -m*n≡1⇒m≡1 (suc zero) n _ = refl -m*n≡1⇒m≡1 (suc (suc m)) (suc zero) () -m*n≡1⇒m≡1 (suc (suc m)) zero eq = - contradiction (trans (sym $ *-zeroʳ m) eq) λ() - -m*n≡1⇒n≡1 : m n m * n 1 n 1 -m*n≡1⇒n≡1 m n eq = m*n≡1⇒m≡1 n m (trans (*-comm n m) eq) - -[m*n]*[o*p]≡[m*o]*[n*p] : m n o p (m * n) * (o * p) (m * o) * (n * p) -[m*n]*[o*p]≡[m*o]*[n*p] m n o p = begin-equality - (m * n) * (o * p) ≡⟨ *-assoc m n (o * p) - m * (n * (o * p)) ≡⟨ cong (m *_) (x∙yz≈y∙xz n o p) - m * (o * (n * p)) ≡⟨ *-assoc m o (n * p) - (m * o) * (n * p) - where open CommSemigroupProperties *-commutativeSemigroup - -m≢0∧n>1⇒m*n>1 : m n .{{_ : NonZero m}} .{{_ : NonTrivial n}} NonTrivial (m * n) -m≢0∧n>1⇒m*n>1 (suc m) (2+ n) = _ - -n≢0∧m>1⇒m*n>1 : m n .{{_ : NonZero n}} .{{_ : NonTrivial m}} NonTrivial (m * n) -n≢0∧m>1⇒m*n>1 m n rewrite *-comm m n = m≢0∧n>1⇒m*n>1 n m - ------------------------------------------------------------------------- --- Other properties of _*_ and _≤_/_<_ - -*-cancelʳ-≤ : m n o .{{_ : NonZero o}} m * o n * o m n -*-cancelʳ-≤ zero _ _ _ = z≤n -*-cancelʳ-≤ (suc m) (suc n) o@(suc _) le = - s≤s (*-cancelʳ-≤ m n o (+-cancelˡ-≤ _ _ _ le)) - -*-cancelˡ-≤ : o .{{_ : NonZero o}} o * m o * n m n -*-cancelˡ-≤ {m} {n} o rewrite *-comm o m | *-comm o n = *-cancelʳ-≤ m n o - -*-mono-≤ : Monotonic₂ _≤_ _≤_ _≤_ _*_ -*-mono-≤ z≤n u≤v = z≤n -*-mono-≤ (s≤s m≤n) u≤v = +-mono-≤ u≤v (*-mono-≤ m≤n u≤v) - -*-monoˡ-≤ : RightMonotonic _≤_ _≤_ _*_ -*-monoˡ-≤ = mono₂⇒monoʳ _ _ _≤_ ≤-refl *-mono-≤ - -*-monoʳ-≤ : LeftMonotonic _≤_ _≤_ _*_ -*-monoʳ-≤ = mono₂⇒monoˡ _≤_ _≤_ _≤_ ≤-refl *-mono-≤ - -*-mono-< : Monotonic₂ _<_ _<_ _<_ _*_ -*-mono-< z<s u<v@(s≤s _) = 0<1+n -*-mono-< (s<s m<n@(s≤s _)) u<v@(s≤s _) = +-mono-< u<v (*-mono-< m<n u<v) - -*-monoˡ-< : n .{{_ : NonZero n}} Monotonic₁ _<_ _<_ (_* n) -*-monoˡ-< n@(suc _) z<s = 0<1+n -*-monoˡ-< n@(suc _) (s<s m<o@(s≤s _)) = +-mono-≤-< ≤-refl (*-monoˡ-< n m<o) - -*-monoʳ-< : n .{{_ : NonZero n}} Monotonic₁ _<_ _<_ (n *_) -*-monoʳ-< (suc zero) m<o@(s≤s _) = +-mono-≤ m<o z≤n -*-monoʳ-< (suc n@(suc _)) m<o@(s≤s _) = +-mono-≤ m<o (<⇒≤ (*-monoʳ-< n m<o)) - -m≤m*n : m n .{{_ : NonZero n}} m m * n -m≤m*n m n@(suc _) = begin - m ≡⟨ sym (*-identityʳ m) - m * 1 ≤⟨ *-monoʳ-≤ m 0<1+n - m * n - -m≤n*m : m n .{{_ : NonZero n}} m n * m -m≤n*m m n@(suc _) = begin - m ≤⟨ m≤m*n m n - m * n ≡⟨ *-comm m n - n * m - -m≤n⇒m≤o*n : o .{{_ : NonZero o}} m n m o * n -m≤n⇒m≤o*n o m≤n = ≤-trans m≤n (m≤n*m _ o) - -m≤n⇒m≤n*o : o .{{_ : NonZero o}} m n m n * o -m≤n⇒m≤n*o o m≤n = ≤-trans m≤n (m≤m*n _ o) - -m<m*n : m n .{{_ : NonZero m}} 1 < n m < m * n -m<m*n m@(suc m-1) n@(suc (suc n-2)) (s≤s (s≤s _)) = begin-strict - m <⟨ s≤s (s≤s (m≤n+m m-1 n-2)) - n + m-1 ≤⟨ +-monoʳ-≤ n (m≤m*n m-1 n) - n + m-1 * n ≡⟨⟩ - m * n - -m<n⇒m<n*o : o .{{_ : NonZero o}} m < n m < n * o -m<n⇒m<n*o = m≤n⇒m≤n*o - -m<n⇒m<o*n : {m n} o .{{_ : NonZero o}} m < n m < o * n -m<n⇒m<o*n = m≤n⇒m≤o*n - -*-cancelʳ-< : RightCancellative _<_ _*_ -*-cancelʳ-< zero zero (suc o) _ = 0<1+n -*-cancelʳ-< (suc m) zero (suc o) _ = 0<1+n -*-cancelʳ-< m (suc n) (suc o) nm<om = - s≤s (*-cancelʳ-< m n o (+-cancelˡ-< m _ _ nm<om)) - -*-cancelˡ-< : LeftCancellative _<_ _*_ -*-cancelˡ-< x y z rewrite *-comm x y | *-comm x z = *-cancelʳ-< x y z - -*-cancel-< : Cancellative _<_ _*_ -*-cancel-< = *-cancelˡ-< , *-cancelʳ-< - ------------------------------------------------------------------------- --- Properties of _^_ ------------------------------------------------------------------------- - -^-identityʳ : RightIdentity 1 _^_ -^-identityʳ zero = refl -^-identityʳ (suc n) = cong suc (^-identityʳ n) - -^-zeroˡ : LeftZero 1 _^_ -^-zeroˡ zero = refl -^-zeroˡ (suc n) = begin-equality - 1 ^ suc n ≡⟨⟩ - 1 * (1 ^ n) ≡⟨ *-identityˡ (1 ^ n) - 1 ^ n ≡⟨ ^-zeroˡ n - 1 - -^-distribˡ-+-* : m n o m ^ (n + o) m ^ n * m ^ o -^-distribˡ-+-* m zero o = sym (+-identityʳ (m ^ o)) -^-distribˡ-+-* m (suc n) o = begin-equality - m * (m ^ (n + o)) ≡⟨ cong (m *_) (^-distribˡ-+-* m n o) - m * ((m ^ n) * (m ^ o)) ≡⟨ sym (*-assoc m _ _) - (m * (m ^ n)) * (m ^ o) - -^-semigroup-morphism : {n} (n ^_) Is +-semigroup -Semigroup⟶ *-semigroup -^-semigroup-morphism = record - { ⟦⟧-cong = cong (_ ^_) - ; ∙-homo = ^-distribˡ-+-* _ - } - -^-monoid-morphism : {n} (n ^_) Is +-0-monoid -Monoid⟶ *-1-monoid -^-monoid-morphism = record - { sm-homo = ^-semigroup-morphism - ; ε-homo = refl - } - -^-*-assoc : m n o (m ^ n) ^ o m ^ (n * o) -^-*-assoc m n zero = cong (m ^_) (sym $ *-zeroʳ n) -^-*-assoc m n (suc o) = begin-equality - (m ^ n) * ((m ^ n) ^ o) ≡⟨ cong ((m ^ n) *_) (^-*-assoc m n o) - (m ^ n) * (m ^ (n * o)) ≡⟨ sym (^-distribˡ-+-* m n (n * o)) - m ^ (n + n * o) ≡⟨ cong (m ^_) (sym (*-suc n o)) - m ^ (n * (suc o)) - -m^n≡0⇒m≡0 : m n m ^ n 0 m 0 -m^n≡0⇒m≡0 m (suc n) eq = [ id , m^n≡0⇒m≡0 m n ]′ (m*n≡0⇒m≡0∨n≡0 m eq) - -m^n≡1⇒n≡0∨m≡1 : m n m ^ n 1 n 0 m 1 -m^n≡1⇒n≡0∨m≡1 m zero _ = inj₁ refl -m^n≡1⇒n≡0∨m≡1 m (suc n) eq = inj₂ (m*n≡1⇒m≡1 m (m ^ n) eq) - -m^n≢0 : m n .{{_ : NonZero m}} NonZero (m ^ n) -m^n≢0 m n = ≢-nonZero (≢-nonZero⁻¹ m ∘′ m^n≡0⇒m≡0 m n) - -m^n>0 : m .{{_ : NonZero m}} n m ^ n > 0 -m^n>0 m n = >-nonZero⁻¹ (m ^ n) {{m^n≢0 m n}} - -^-monoˡ-≤ : RightMonotonic _≤_ _≤_ _^_ -^-monoˡ-≤ zero m≤o = s≤s z≤n -^-monoˡ-≤ (suc n) m≤o = *-mono-≤ m≤o (^-monoˡ-≤ n m≤o) - -^-monoʳ-≤ : m .{{_ : NonZero m}} Monotonic₁ _≤_ _≤_ (m ^_) -^-monoʳ-≤ m {_} {o} z≤n = n≢0⇒n>0 (≢-nonZero⁻¹ (m ^ o) {{m^n≢0 m o}}) -^-monoʳ-≤ m (s≤s n≤o) = *-monoʳ-≤ m (^-monoʳ-≤ m n≤o) - -^-monoˡ-< : n .{{_ : NonZero n}} Monotonic₁ _<_ _<_ (_^ n) -^-monoˡ-< (suc zero) m<o = *-monoˡ-< 1 m<o -^-monoˡ-< (suc n@(suc _)) m<o = *-mono-< m<o (^-monoˡ-< n m<o) - -^-monoʳ-< : m 1 < m Monotonic₁ _<_ _<_ (m ^_) -^-monoʳ-< m@(suc _) 1<m {zero} {suc o} z<s = *-mono-≤ 1<m (m^n>0 m o) -^-monoʳ-< m@(suc _) 1<m {suc n} {suc o} (s<s n<o) = *-monoʳ-< m (^-monoʳ-< m 1<m n<o) - ------------------------------------------------------------------------- --- Properties of _⊓_ and _⊔_ ------------------------------------------------------------------------- --- Basic specification in terms of _≤_ - -m≤n⇒m⊔n≡n : m n m n n -m≤n⇒m⊔n≡n {zero} _ = refl -m≤n⇒m⊔n≡n {suc m} (s≤s m≤n) = cong suc (m≤n⇒m⊔n≡n m≤n) - -m≥n⇒m⊔n≡m : m n m n m -m≥n⇒m⊔n≡m {zero} {zero} z≤n = refl -m≥n⇒m⊔n≡m {suc m} {zero} z≤n = refl -m≥n⇒m⊔n≡m {suc m} {suc n} (s≤s m≥n) = cong suc (m≥n⇒m⊔n≡m m≥n) - -m≤n⇒m⊓n≡m : m n m n m -m≤n⇒m⊓n≡m {zero} z≤n = refl -m≤n⇒m⊓n≡m {suc m} (s≤s m≤n) = cong suc (m≤n⇒m⊓n≡m m≤n) - -m≥n⇒m⊓n≡n : m n m n n -m≥n⇒m⊓n≡n {zero} {zero} z≤n = refl -m≥n⇒m⊓n≡n {suc m} {zero} z≤n = refl -m≥n⇒m⊓n≡n {suc m} {suc n} (s≤s m≤n) = cong suc (m≥n⇒m⊓n≡n m≤n) - -⊓-operator : MinOperator ≤-totalPreorder -⊓-operator = record - { x≤y⇒x⊓y≈x = m≤n⇒m⊓n≡m - ; x≥y⇒x⊓y≈y = m≥n⇒m⊓n≡n - } - -⊔-operator : MaxOperator ≤-totalPreorder -⊔-operator = record - { x≤y⇒x⊔y≈y = m≤n⇒m⊔n≡n - ; x≥y⇒x⊔y≈x = m≥n⇒m⊔n≡m - } - ------------------------------------------------------------------------- --- Equality to their counterparts defined in terms of primitive operations - -⊔≡⊔′ : m n m n m ⊔′ n -⊔≡⊔′ m n with m <ᵇ n in eq -... | false = m≥n⇒m⊔n≡m (≮⇒≥ m<n subst T eq (<⇒<ᵇ m<n))) -... | true = m≤n⇒m⊔n≡n (<⇒≤ (<ᵇ⇒< m n (subst T (sym eq) _))) - -⊓≡⊓′ : m n m n m ⊓′ n -⊓≡⊓′ m n with m <ᵇ n in eq -... | false = m≥n⇒m⊓n≡n (≮⇒≥ m<n subst T eq (<⇒<ᵇ m<n))) -... | true = m≤n⇒m⊓n≡m (<⇒≤ (<ᵇ⇒< m n (subst T (sym eq) _))) - ------------------------------------------------------------------------- --- Derived properties of _⊓_ and _⊔_ - -private - module ⊓-⊔-properties = MinMaxOp ⊓-operator ⊔-operator - module ⊓-⊔-latticeProperties = LatticeMinMaxOp ⊓-operator ⊔-operator - -open ⊓-⊔-properties public - using - ( ⊓-idem -- : Idempotent _⊓_ - ; ⊓-sel -- : Selective _⊓_ - ; ⊓-assoc -- : Associative _⊓_ - ; ⊓-comm -- : Commutative _⊓_ - - ; ⊔-idem -- : Idempotent _⊔_ - ; ⊔-sel -- : Selective _⊔_ - ; ⊔-assoc -- : Associative _⊔_ - ; ⊔-comm -- : Commutative _⊔_ - - ; ⊓-distribˡ-⊔ -- : _⊓_ DistributesOverˡ _⊔_ - ; ⊓-distribʳ-⊔ -- : _⊓_ DistributesOverʳ _⊔_ - ; ⊓-distrib-⊔ -- : _⊓_ DistributesOver _⊔_ - ; ⊔-distribˡ-⊓ -- : _⊔_ DistributesOverˡ _⊓_ - ; ⊔-distribʳ-⊓ -- : _⊔_ DistributesOverʳ _⊓_ - ; ⊔-distrib-⊓ -- : _⊔_ DistributesOver _⊓_ - ; ⊓-absorbs-⊔ -- : _⊓_ Absorbs _⊔_ - ; ⊔-absorbs-⊓ -- : _⊔_ Absorbs _⊓_ - ; ⊔-⊓-absorptive -- : Absorptive _⊔_ _⊓_ - ; ⊓-⊔-absorptive -- : Absorptive _⊓_ _⊔_ - - ; ⊓-isMagma -- : IsMagma _⊓_ - ; ⊓-isSemigroup -- : IsSemigroup _⊓_ - ; ⊓-isCommutativeSemigroup -- : IsCommutativeSemigroup _⊓_ - ; ⊓-isBand -- : IsBand _⊓_ - ; ⊓-isSelectiveMagma -- : IsSelectiveMagma _⊓_ - - ; ⊔-isMagma -- : IsMagma _⊔_ - ; ⊔-isSemigroup -- : IsSemigroup _⊔_ - ; ⊔-isCommutativeSemigroup -- : IsCommutativeSemigroup _⊔_ - ; ⊔-isBand -- : IsBand _⊔_ - ; ⊔-isSelectiveMagma -- : IsSelectiveMagma _⊔_ - - ; ⊓-magma -- : Magma _ _ - ; ⊓-semigroup -- : Semigroup _ _ - ; ⊓-band -- : Band _ _ - ; ⊓-commutativeSemigroup -- : CommutativeSemigroup _ _ - ; ⊓-selectiveMagma -- : SelectiveMagma _ _ - - ; ⊔-magma -- : Magma _ _ - ; ⊔-semigroup -- : Semigroup _ _ - ; ⊔-band -- : Band _ _ - ; ⊔-commutativeSemigroup -- : CommutativeSemigroup _ _ - ; ⊔-selectiveMagma -- : SelectiveMagma _ _ - - ; ⊓-glb -- : ∀ {m n o} → m ≥ o → n ≥ o → m ⊓ n ≥ o - ; ⊓-triangulate -- : ∀ m n o → m ⊓ n ⊓ o ≡ (m ⊓ n) ⊓ (n ⊓ o) - ; ⊓-mono-≤ -- : _⊓_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_ - ; ⊓-monoˡ-≤ -- : ∀ n → (_⊓ n) Preserves _≤_ ⟶ _≤_ - ; ⊓-monoʳ-≤ -- : ∀ n → (n ⊓_) Preserves _≤_ ⟶ _≤_ - - ; ⊔-lub -- : ∀ {m n o} → m ≤ o → n ≤ o → m ⊔ n ≤ o - ; ⊔-triangulate -- : ∀ m n o → m ⊔ n ⊔ o ≡ (m ⊔ n) ⊔ (n ⊔ o) - ; ⊔-mono-≤ -- : _⊔_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_ - ; ⊔-monoˡ-≤ -- : ∀ n → (_⊔ n) Preserves _≤_ ⟶ _≤_ - ; ⊔-monoʳ-≤ -- : ∀ n → (n ⊔_) Preserves _≤_ ⟶ _≤_ - ) - renaming - ( x⊓y≈y⇒y≤x to m⊓n≡n⇒n≤m -- : ∀ {m n} → m ⊓ n ≡ n → n ≤ m - ; x⊓y≈x⇒x≤y to m⊓n≡m⇒m≤n -- : ∀ {m n} → m ⊓ n ≡ m → m ≤ n - ; x⊓y≤x to m⊓n≤m -- : ∀ m n → m ⊓ n ≤ m - ; x⊓y≤y to m⊓n≤n -- : ∀ m n → m ⊓ n ≤ n - ; x≤y⇒x⊓z≤y to m≤n⇒m⊓o≤n -- : ∀ {m n} o → m ≤ n → m ⊓ o ≤ n - ; x≤y⇒z⊓x≤y to m≤n⇒o⊓m≤n -- : ∀ {m n} o → m ≤ n → o ⊓ m ≤ n - ; x≤y⊓z⇒x≤y to m≤n⊓o⇒m≤n -- : ∀ {m} n o → m ≤ n ⊓ o → m ≤ n - ; x≤y⊓z⇒x≤z to m≤n⊓o⇒m≤o -- : ∀ {m} n o → m ≤ n ⊓ o → m ≤ o - - ; x⊔y≈y⇒x≤y to m⊔n≡n⇒m≤n -- : ∀ {m n} → m ⊔ n ≡ n → m ≤ n - ; x⊔y≈x⇒y≤x to m⊔n≡m⇒n≤m -- : ∀ {m n} → m ⊔ n ≡ m → n ≤ m - ; x≤x⊔y to m≤m⊔n -- : ∀ m n → m ≤ m ⊔ n - ; x≤y⊔x to m≤n⊔m -- : ∀ m n → m ≤ n ⊔ m - ; x≤y⇒x≤y⊔z to m≤n⇒m≤n⊔o -- : ∀ {m n} o → m ≤ n → m ≤ n ⊔ o - ; x≤y⇒x≤z⊔y to m≤n⇒m≤o⊔n -- : ∀ {m n} o → m ≤ n → m ≤ o ⊔ n - ; x⊔y≤z⇒x≤z to m⊔n≤o⇒m≤o -- : ∀ m n {o} → m ⊔ n ≤ o → m ≤ o - ; x⊔y≤z⇒y≤z to m⊔n≤o⇒n≤o -- : ∀ m n {o} → m ⊔ n ≤ o → n ≤ o - - ; x⊓y≤x⊔y to m⊓n≤m⊔n -- : ∀ m n → m ⊓ n ≤ m ⊔ n - ) - -open ⊓-⊔-latticeProperties public - using - ( ⊓-isSemilattice -- : IsSemilattice _⊓_ - ; ⊔-isSemilattice -- : IsSemilattice _⊔_ - ; ⊔-⊓-isLattice -- : IsLattice _⊔_ _⊓_ - ; ⊓-⊔-isLattice -- : IsLattice _⊓_ _⊔_ - ; ⊔-⊓-isDistributiveLattice -- : IsDistributiveLattice _⊔_ _⊓_ - ; ⊓-⊔-isDistributiveLattice -- : IsDistributiveLattice _⊓_ _⊔_ - - ; ⊓-semilattice -- : Semilattice _ _ - ; ⊔-semilattice -- : Semilattice _ _ - ; ⊔-⊓-lattice -- : Lattice _ _ - ; ⊓-⊔-lattice -- : Lattice _ _ - ; ⊔-⊓-distributiveLattice -- : DistributiveLattice _ _ - ; ⊓-⊔-distributiveLattice -- : DistributiveLattice _ _ - ) - ------------------------------------------------------------------------- --- Automatically derived properties of _⊓_ and _⊔_ - -⊔-identityˡ : LeftIdentity 0 _⊔_ -⊔-identityˡ _ = refl - -⊔-identityʳ : RightIdentity 0 _⊔_ -⊔-identityʳ zero = refl -⊔-identityʳ (suc n) = refl - -⊔-identity : Identity 0 _⊔_ -⊔-identity = ⊔-identityˡ , ⊔-identityʳ - ------------------------------------------------------------------------- --- Structures - -⊔-0-isMonoid : IsMonoid _⊔_ 0 -⊔-0-isMonoid = record - { isSemigroup = ⊔-isSemigroup - ; identity = ⊔-identity - } - -⊔-0-isCommutativeMonoid : IsCommutativeMonoid _⊔_ 0 -⊔-0-isCommutativeMonoid = record - { isMonoid = ⊔-0-isMonoid - ; comm = ⊔-comm - } - ------------------------------------------------------------------------- --- Bundles - -⊔-0-monoid : Monoid 0ℓ 0ℓ -⊔-0-monoid = record - { isMonoid = ⊔-0-isMonoid - } - -⊔-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ -⊔-0-commutativeMonoid = record - { isCommutativeMonoid = ⊔-0-isCommutativeMonoid - } - ------------------------------------------------------------------------- --- Other properties of _⊔_ and _≤_/_<_ - -mono-≤-distrib-⊔ : {f} f Preserves _≤_ _≤_ - m n f (m n) f m f n -mono-≤-distrib-⊔ {f} = ⊓-⊔-properties.mono-≤-distrib-⊔ (cong f) - -mono-≤-distrib-⊓ : {f} f Preserves _≤_ _≤_ - m n f (m n) f m f n -mono-≤-distrib-⊓ {f} = ⊓-⊔-properties.mono-≤-distrib-⊓ (cong f) - -antimono-≤-distrib-⊓ : {f} f Preserves _≤_ _≥_ - m n f (m n) f m f n -antimono-≤-distrib-⊓ {f} = ⊓-⊔-properties.antimono-≤-distrib-⊓ (cong f) - -antimono-≤-distrib-⊔ : {f} f Preserves _≤_ _≥_ - m n f (m n) f m f n -antimono-≤-distrib-⊔ {f} = ⊓-⊔-properties.antimono-≤-distrib-⊔ (cong f) - -m<n⇒m<n⊔o : o m < n m < n o -m<n⇒m<n⊔o = m≤n⇒m≤n⊔o - -m<n⇒m<o⊔n : o m < n m < o n -m<n⇒m<o⊔n = m≤n⇒m≤o⊔n - -m⊔n<o⇒m<o : m n {o} m n < o m < o -m⊔n<o⇒m<o m n m⊔n<o = ≤-<-trans (m≤m⊔n m n) m⊔n<o - -m⊔n<o⇒n<o : m n {o} m n < o n < o -m⊔n<o⇒n<o m n m⊔n<o = ≤-<-trans (m≤n⊔m m n) m⊔n<o - -⊔-mono-< : _⊔_ Preserves₂ _<_ _<_ _<_ -⊔-mono-< = ⊔-mono-≤ - -⊔-pres-<m : n < m o < m n o < m -⊔-pres-<m {m = m} n<m o<m = subst (_ <_) (⊔-idem m) (⊔-mono-< n<m o<m) - ------------------------------------------------------------------------- --- Other properties of _⊔_ and _+_ - -+-distribˡ-⊔ : _+_ DistributesOverˡ _⊔_ -+-distribˡ-⊔ zero n o = refl -+-distribˡ-⊔ (suc m) n o = cong suc (+-distribˡ-⊔ m n o) - -+-distribʳ-⊔ : _+_ DistributesOverʳ _⊔_ -+-distribʳ-⊔ = comm∧distrˡ⇒distrʳ +-comm +-distribˡ-⊔ - -+-distrib-⊔ : _+_ DistributesOver _⊔_ -+-distrib-⊔ = +-distribˡ-⊔ , +-distribʳ-⊔ +------------------------------------------------------------------------ +-- Other properties of _⊔_ and _*_ -m⊔n≤m+n : m n m n m + n -m⊔n≤m+n m n with ⊔-sel m n -... | inj₁ m⊔n≡m rewrite m⊔n≡m = m≤m+n m n -... | inj₂ m⊔n≡n rewrite m⊔n≡n = m≤n+m n m +*-distribˡ-⊔ : _*_ DistributesOverˡ _⊔_ +*-distribˡ-⊔ m zero o = sym (cong (_⊔ m * o) (*-zeroʳ m)) +*-distribˡ-⊔ m (suc n) zero = begin-equality + m * (suc n zero) ≡⟨⟩ + m * suc n ≡⟨ ⊔-identityʳ (m * suc n) + m * suc n zero ≡⟨ cong (m * suc n ⊔_) (*-zeroʳ m) + m * suc n m * zero +*-distribˡ-⊔ m (suc n) (suc o) = begin-equality + m * (suc n suc o) ≡⟨⟩ + m * suc (n o) ≡⟨ *-suc m (n o) + m + m * (n o) ≡⟨ cong (m +_) (*-distribˡ-⊔ m n o) + m + (m * n m * o) ≡⟨ +-distribˡ-⊔ m (m * n) (m * o) + (m + m * n) (m + m * o) ≡⟨ cong₂ _⊔_ (*-suc m n) (*-suc m o) + (m * suc n) (m * suc o) + +*-distribʳ-⊔ : _*_ DistributesOverʳ _⊔_ +*-distribʳ-⊔ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-⊔ + +*-distrib-⊔ : _*_ DistributesOver _⊔_ +*-distrib-⊔ = *-distribˡ-⊔ , *-distribʳ-⊔ + +------------------------------------------------------------------------ +-- Properties of _⊓_ +------------------------------------------------------------------------ + +------------------------------------------------------------------------ +-- Algebraic properties + +⊓-zeroˡ : LeftZero 0 _⊓_ +⊓-zeroˡ _ = refl + +⊓-zeroʳ : RightZero 0 _⊓_ +⊓-zeroʳ zero = refl +⊓-zeroʳ (suc n) = refl + +⊓-zero : Zero 0 _⊓_ +⊓-zero = ⊓-zeroˡ , ⊓-zeroʳ + +------------------------------------------------------------------------ +-- Structures + +⊔-⊓-isSemiringWithoutOne : IsSemiringWithoutOne _⊔_ _⊓_ 0 +⊔-⊓-isSemiringWithoutOne = record + { +-isCommutativeMonoid = ⊔-0-isCommutativeMonoid + ; *-cong = cong₂ _⊓_ + ; *-assoc = ⊓-assoc + ; distrib = ⊓-distrib-⊔ + ; zero = ⊓-zero + } + +⊔-⊓-isCommutativeSemiringWithoutOne + : IsCommutativeSemiringWithoutOne _⊔_ _⊓_ 0 +⊔-⊓-isCommutativeSemiringWithoutOne = record + { isSemiringWithoutOne = ⊔-⊓-isSemiringWithoutOne + ; *-comm = ⊓-comm + } + +------------------------------------------------------------------------ +-- Bundles + +⊔-⊓-commutativeSemiringWithoutOne : CommutativeSemiringWithoutOne 0ℓ 0ℓ +⊔-⊓-commutativeSemiringWithoutOne = record + { isCommutativeSemiringWithoutOne = + ⊔-⊓-isCommutativeSemiringWithoutOne + } + +------------------------------------------------------------------------ +-- Other properties of _⊓_ and _≤_/_<_ + +m<n⇒m⊓o<n : o m < n m o < n +m<n⇒m⊓o<n o m<n = ≤-<-trans (m⊓n≤m _ o) m<n + +m<n⇒o⊓m<n : o m < n o m < n +m<n⇒o⊓m<n o m<n = ≤-<-trans (m⊓n≤n o _) m<n + +m<n⊓o⇒m<n : n o m < n o m < n +m<n⊓o⇒m<n = m≤n⊓o⇒m≤n + +m<n⊓o⇒m<o : n o m < n o m < o +m<n⊓o⇒m<o = m≤n⊓o⇒m≤o + +⊓-mono-< : _⊓_ Preserves₂ _<_ _<_ _<_ +⊓-mono-< = ⊓-mono-≤ + +⊓-pres-m< : m < n m < o m < n o +⊓-pres-m< {m} m<n m<o = subst (_< _) (⊓-idem m) (⊓-mono-< m<n m<o) + +------------------------------------------------------------------------ +-- Other properties of _⊓_ and _+_ + ++-distribˡ-⊓ : _+_ DistributesOverˡ _⊓_ ++-distribˡ-⊓ zero n o = refl ++-distribˡ-⊓ (suc m) n o = cong suc (+-distribˡ-⊓ m n o) + ++-distribʳ-⊓ : _+_ DistributesOverʳ _⊓_ ++-distribʳ-⊓ = comm∧distrˡ⇒distrʳ +-comm +-distribˡ-⊓ + ++-distrib-⊓ : _+_ DistributesOver _⊓_ ++-distrib-⊓ = +-distribˡ-⊓ , +-distribʳ-⊓ + +m⊓n≤m+n : m n m n m + n +m⊓n≤m+n m n with ⊓-sel m n +... | inj₁ m⊓n≡m rewrite m⊓n≡m = m≤m+n m n +... | inj₂ m⊓n≡n rewrite m⊓n≡n = m≤n+m n m + +------------------------------------------------------------------------ +-- Other properties of _⊓_ and _*_ + +*-distribˡ-⊓ : _*_ DistributesOverˡ _⊓_ +*-distribˡ-⊓ m 0 o = begin-equality + m * (0 o) ≡⟨⟩ + m * 0 ≡⟨ *-zeroʳ m + 0 ≡⟨⟩ + 0 (m * o) ≡⟨ cong (_⊓ (m * o)) (*-zeroʳ m) + (m * 0) (m * o) +*-distribˡ-⊓ m (suc n) 0 = begin-equality + m * (suc n 0) ≡⟨⟩ + m * 0 ≡⟨ *-zeroʳ m + 0 ≡⟨ ⊓-zeroʳ (m * suc n) + (m * suc n) 0 ≡⟨ cong (m * suc n ⊓_) (*-zeroʳ m) + (m * suc n) (m * 0) +*-distribˡ-⊓ m (suc n) (suc o) = begin-equality + m * (suc n suc o) ≡⟨⟩ + m * suc (n o) ≡⟨ *-suc m (n o) + m + m * (n o) ≡⟨ cong (m +_) (*-distribˡ-⊓ m n o) + m + (m * n) (m * o) ≡⟨ +-distribˡ-⊓ m (m * n) (m * o) + (m + m * n) (m + m * o) ≡⟨ cong₂ _⊓_ (*-suc m n) (*-suc m o) + (m * suc n) (m * suc o) + +*-distribʳ-⊓ : _*_ DistributesOverʳ _⊓_ +*-distribʳ-⊓ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-⊓ + +*-distrib-⊓ : _*_ DistributesOver _⊓_ +*-distrib-⊓ = *-distribˡ-⊓ , *-distribʳ-⊓ + +------------------------------------------------------------------------ +-- Properties of _∸_ +------------------------------------------------------------------------ + +0∸n≡0 : LeftZero zero _∸_ +0∸n≡0 zero = refl +0∸n≡0 (suc _) = refl + +n∸n≡0 : n n n 0 +n∸n≡0 zero = refl +n∸n≡0 (suc n) = n∸n≡0 n + +------------------------------------------------------------------------ +-- Properties of _∸_ and pred + +pred[m∸n]≡m∸[1+n] : m n pred (m n) m suc n +pred[m∸n]≡m∸[1+n] zero zero = refl +pred[m∸n]≡m∸[1+n] (suc m) zero = refl +pred[m∸n]≡m∸[1+n] zero (suc n) = refl +pred[m∸n]≡m∸[1+n] (suc m) (suc n) = pred[m∸n]≡m∸[1+n] m n + +------------------------------------------------------------------------ +-- Properties of _∸_ and _≤_/_<_ + +m∸n≤m : m n m n m +m∸n≤m n zero = ≤-refl +m∸n≤m zero (suc n) = ≤-refl +m∸n≤m (suc m) (suc n) = ≤-trans (m∸n≤m m n) (n≤1+n m) + +m≮m∸n : m n m m n +m≮m∸n m zero = n≮n m +m≮m∸n (suc m) (suc n) = m≮m∸n m n ≤-trans (n≤1+n (suc m)) + +1+m≢m∸n : {m} n suc m m n +1+m≢m∸n {m} n eq = m≮m∸n m n (≤-reflexive eq) + +∸-mono : _∸_ Preserves₂ _≤_ _≥_ _≤_ +∸-mono z≤n (s≤s n₁≥n₂) = z≤n +∸-mono (s≤s m₁≤m₂) (s≤s n₁≥n₂) = ∸-mono m₁≤m₂ n₁≥n₂ +∸-mono m₁≤m₂ (z≤n {n = n₁}) = ≤-trans (m∸n≤m _ n₁) m₁≤m₂ + +∸-monoˡ-≤ : o m n m o n o +∸-monoˡ-≤ o m≤n = ∸-mono {u = o} m≤n ≤-refl + +∸-monoʳ-≤ : o m n o m o n +∸-monoʳ-≤ _ m≤n = ∸-mono ≤-refl m≤n + +∸-monoˡ-< : {m n o} m < o n m m n < o n +∸-monoˡ-< {m} {zero} {o} m<o n≤m = m<o +∸-monoˡ-< {suc m} {suc n} {suc o} (s≤s m<o) (s≤s n≤m) = ∸-monoˡ-< m<o n≤m + +∸-monoʳ-< : {m n o} o < n n m m n < m o +∸-monoʳ-< {n = suc n} {zero} (s≤s o<n) (s≤s n<m) = s≤s (m∸n≤m _ n) +∸-monoʳ-< {n = suc n} {suc o} (s≤s o<n) (s≤s n<m) = ∸-monoʳ-< o<n n<m + +∸-cancelʳ-≤ : {m n o} m o o n o m m n +∸-cancelʳ-≤ {_} {_} z≤n _ = z≤n +∸-cancelʳ-≤ {suc m} {zero} (s≤s _) o<o∸m = contradiction o<o∸m (m≮m∸n _ m) +∸-cancelʳ-≤ {suc m} {suc n} (s≤s m≤o) o∸n<o∸m = s≤s (∸-cancelʳ-≤ m≤o o∸n<o∸m) + +∸-cancelʳ-< : {m n o} o m < o n n < m +∸-cancelʳ-< {zero} {n} {o} o<o∸n = contradiction o<o∸n (m≮m∸n o n) +∸-cancelʳ-< {suc m} {zero} {_} o∸n<o∸m = 0<1+n +∸-cancelʳ-< {suc m} {suc n} {suc o} o∸n<o∸m = s≤s (∸-cancelʳ-< o∸n<o∸m) + +∸-cancelˡ-≡ : n m o m m n m o n o +∸-cancelˡ-≡ {_} z≤n z≤n _ = refl +∸-cancelˡ-≡ {o = suc o} z≤n (s≤s _) eq = contradiction eq (1+m≢m∸n o) +∸-cancelˡ-≡ {n = suc n} (s≤s _) z≤n eq = contradiction (sym eq) (1+m≢m∸n n) +∸-cancelˡ-≡ {_} (s≤s n≤m) (s≤s o≤m) eq = cong suc (∸-cancelˡ-≡ n≤m o≤m eq) + +∸-cancelʳ-≡ : o m o n m o n o m n +∸-cancelʳ-≡ z≤n z≤n eq = eq +∸-cancelʳ-≡ (s≤s o≤m) (s≤s o≤n) eq = cong suc (∸-cancelʳ-≡ o≤m o≤n eq) + +m∸n≡0⇒m≤n : m n 0 m n +m∸n≡0⇒m≤n {zero} {_} _ = z≤n +m∸n≡0⇒m≤n {suc m} {suc n} eq = s≤s (m∸n≡0⇒m≤n eq) + +m≤n⇒m∸n≡0 : m n m n 0 +m≤n⇒m∸n≡0 {n = n} z≤n = 0∸n≡0 n +m≤n⇒m∸n≡0 {_} (s≤s m≤n) = m≤n⇒m∸n≡0 m≤n + +m<n⇒0<n∸m : m < n 0 < n m +m<n⇒0<n∸m {zero} {suc n} _ = 0<1+n +m<n⇒0<n∸m {suc m} {suc n} (s≤s m<n) = m<n⇒0<n∸m m<n + +m∸n≢0⇒n<m : m n 0 n < m +m∸n≢0⇒n<m {m} {n} m∸n≢0 with n <? m +... | yes n<m = n<m +... | no n≮m = contradiction (m≤n⇒m∸n≡0 (≮⇒≥ n≮m)) m∸n≢0 + +m>n⇒m∸n≢0 : m > n m n 0 +m>n⇒m∸n≢0 {n = suc n} (s≤s m>n) = m>n⇒m∸n≢0 m>n + +m≤n⇒n∸m≤n : m n n m n +m≤n⇒n∸m≤n z≤n = ≤-refl +m≤n⇒n∸m≤n (s≤s m≤n) = m≤n⇒m≤1+n (m≤n⇒n∸m≤n m≤n) + +------------------------------------------------------------------------ +-- Properties of _∸_ and _+_ + ++-∸-comm : {m} n {o} o m (m + n) o (m o) + n ++-∸-comm {zero} _ {zero} _ = refl ++-∸-comm {suc m} _ {zero} _ = refl ++-∸-comm {suc m} n {suc o} (s≤s o≤m) = +-∸-comm n o≤m + +∸-+-assoc : m n o (m n) o m (n + o) +∸-+-assoc zero zero o = refl +∸-+-assoc zero (suc n) o = 0∸n≡0 o +∸-+-assoc (suc m) zero o = refl +∸-+-assoc (suc m) (suc n) o = ∸-+-assoc m n o + ++-∸-assoc : m {n o} o n (m + n) o m + (n o) ++-∸-assoc m (z≤n {n = n}) = begin-equality m + n ++-∸-assoc m (s≤s {m = o} {n = n} o≤n) = begin-equality + (m + suc n) suc o ≡⟨ cong (_∸ suc o) (+-suc m n) + suc (m + n) suc o ≡⟨⟩ + (m + n) o ≡⟨ +-∸-assoc m o≤n + m + (n o) + +m≤n+o⇒m∸n≤o : m n {o} m n + o m n o +m≤n+o⇒m∸n≤o m zero le = le +m≤n+o⇒m∸n≤o zero (suc n) _ = z≤n +m≤n+o⇒m∸n≤o (suc m) (suc n) le = m≤n+o⇒m∸n≤o m n (s≤s⁻¹ le) + +m<n+o⇒m∸n<o : m n {o} .{{NonZero o}} m < n + o m n < o +m<n+o⇒m∸n<o m zero lt = lt +m<n+o⇒m∸n<o zero (suc n) {o@(suc _)} lt = z<s +m<n+o⇒m∸n<o (suc m) (suc n) lt = m<n+o⇒m∸n<o m n (s<s⁻¹ lt) + +m+n≤o⇒m≤o∸n : m {n o} m + n o m o n +m+n≤o⇒m≤o∸n zero le = z≤n +m+n≤o⇒m≤o∸n (suc m) (s≤s le) + rewrite +-∸-assoc 1 (m+n≤o⇒n≤o m le) = s≤s (m+n≤o⇒m≤o∸n m le) + +m≤o∸n⇒m+n≤o : m {n o} (n≤o : n o) m o n m + n o +m≤o∸n⇒m+n≤o m z≤n le rewrite +-identityʳ m = le +m≤o∸n⇒m+n≤o m {suc n} (s≤s n≤o) le rewrite +-suc m n = s≤s (m≤o∸n⇒m+n≤o m n≤o le) + +m≤n+m∸n : m n m n + (m n) +m≤n+m∸n zero n = z≤n +m≤n+m∸n (suc m) zero = ≤-refl +m≤n+m∸n (suc m) (suc n) = s≤s (m≤n+m∸n m n) + +m+n∸n≡m : m n m + n n m +m+n∸n≡m m n = begin-equality + (m + n) n ≡⟨ +-∸-assoc m (≤-refl {x = n}) + m + (n n) ≡⟨ cong (m +_) (n∸n≡0 n) + m + 0 ≡⟨ +-identityʳ m + m + +m+n∸m≡n : m n m + n m n +m+n∸m≡n m n = trans (cong (_∸ m) (+-comm m n)) (m+n∸n≡m n m) + +m+[n∸m]≡n : m n m + (n m) n +m+[n∸m]≡n {m} {n} m≤n = begin-equality + m + (n m) ≡⟨ sym $ +-∸-assoc m m≤n + (m + n) m ≡⟨ cong (_∸ m) (+-comm m n) + (n + m) m ≡⟨ m+n∸n≡m n m + n + +m∸n+n≡m : {m n} n m (m n) + n m +m∸n+n≡m {m} {n} n≤m = begin-equality + (m n) + n ≡⟨ sym (+-∸-comm n n≤m) + (m + n) n ≡⟨ m+n∸n≡m m n + m + +m∸[m∸n]≡n : {m n} n m m (m n) n +m∸[m∸n]≡n {m} {_} z≤n = n∸n≡0 m +m∸[m∸n]≡n {suc m} {suc n} (s≤s n≤m) = begin-equality + suc m (m n) ≡⟨ +-∸-assoc 1 (m∸n≤m m n) + suc (m (m n)) ≡⟨ cong suc (m∸[m∸n]≡n n≤m) + suc n + +[m+n]∸[m+o]≡n∸o : m n o (m + n) (m + o) n o +[m+n]∸[m+o]≡n∸o zero n o = refl +[m+n]∸[m+o]≡n∸o (suc m) n o = [m+n]∸[m+o]≡n∸o m n o + +------------------------------------------------------------------------ +-- Properties of _∸_ and _*_ + +*-distribʳ-∸ : _*_ DistributesOverʳ _∸_ +*-distribʳ-∸ m zero zero = refl +*-distribʳ-∸ zero zero (suc o) = sym (0∸n≡0 (o * zero)) +*-distribʳ-∸ (suc m) zero (suc o) = refl +*-distribʳ-∸ m (suc n) zero = refl +*-distribʳ-∸ m (suc n) (suc o) = begin-equality + (n o) * m ≡⟨ *-distribʳ-∸ m n o + n * m o * m ≡⟨ sym $ [m+n]∸[m+o]≡n∸o m _ _ + m + n * m (m + o * m) + +*-distribˡ-∸ : _*_ DistributesOverˡ _∸_ +*-distribˡ-∸ = comm∧distrʳ⇒distrˡ *-comm *-distribʳ-∸ + +*-distrib-∸ : _*_ DistributesOver _∸_ +*-distrib-∸ = *-distribˡ-∸ , *-distribʳ-∸ + +even≢odd : m n 2 * m suc (2 * n) +even≢odd (suc m) zero eq = contradiction (suc-injective eq) (m+1+n≢0 m) +even≢odd (suc m) (suc n) eq = even≢odd m n (suc-injective (begin-equality + suc (2 * m) ≡⟨ sym (+-suc m _) + m + suc (m + 0) ≡⟨ suc-injective eq + suc n + suc (n + 0) ≡⟨ cong suc (+-suc n _) + suc (suc (2 * n)) )) + +------------------------------------------------------------------------ +-- Properties of _∸_ and _⊓_ and _⊔_ + +m⊓n+n∸m≡n : m n (m n) + (n m) n +m⊓n+n∸m≡n zero n = refl +m⊓n+n∸m≡n (suc m) zero = refl +m⊓n+n∸m≡n (suc m) (suc n) = cong suc $ m⊓n+n∸m≡n m n + +[m∸n]⊓[n∸m]≡0 : m n (m n) (n m) 0 +[m∸n]⊓[n∸m]≡0 zero zero = refl +[m∸n]⊓[n∸m]≡0 zero (suc n) = refl +[m∸n]⊓[n∸m]≡0 (suc m) zero = refl +[m∸n]⊓[n∸m]≡0 (suc m) (suc n) = [m∸n]⊓[n∸m]≡0 m n + +∸-distribˡ-⊓-⊔ : m n o m (n o) (m n) (m o) +∸-distribˡ-⊓-⊔ m n o = antimono-≤-distrib-⊓ (∸-monoʳ-≤ m) n o + +∸-distribʳ-⊓ : _∸_ DistributesOverʳ _⊓_ +∸-distribʳ-⊓ m n o = mono-≤-distrib-⊓ (∸-monoˡ-≤ m) n o + +∸-distribˡ-⊔-⊓ : m n o m (n o) (m n) (m o) +∸-distribˡ-⊔-⊓ m n o = antimono-≤-distrib-⊔ (∸-monoʳ-≤ m) n o + +∸-distribʳ-⊔ : _∸_ DistributesOverʳ _⊔_ +∸-distribʳ-⊔ m n o = mono-≤-distrib-⊔ (∸-monoˡ-≤ m) n o + +------------------------------------------------------------------------ +-- Properties of pred +------------------------------------------------------------------------ + +pred[n]≤n : pred n n +pred[n]≤n {zero} = z≤n +pred[n]≤n {suc n} = n≤1+n n + +≤pred⇒≤ : m pred n m n +≤pred⇒≤ {n = zero} le = le +≤pred⇒≤ {n = suc n} le = m≤n⇒m≤1+n le + +≤⇒pred≤ : m n pred m n +≤⇒pred≤ {zero} le = le +≤⇒pred≤ {suc m} le = ≤-trans (n≤1+n m) le + +<⇒≤pred : m < n m pred n +<⇒≤pred (s≤s le) = le + +suc-pred : n .{{_ : NonZero n}} suc (pred n) n +suc-pred (suc n) = refl + +pred-mono-≤ : pred Preserves _≤_ _≤_ +pred-mono-≤ {zero} _ = z≤n +pred-mono-≤ {suc _} {suc _} m≤n = s≤s⁻¹ m≤n + +pred-mono-< : .{{NonZero m}} m < n pred m < pred n +pred-mono-< {m = suc _} {n = suc _} = s<s⁻¹ + +pred-cancel-≤ : pred m pred n (m 1 × n 0) m n +pred-cancel-≤ {m = zero} {n = zero} _ = inj₂ z≤n +pred-cancel-≤ {m = zero} {n = suc _} _ = inj₂ z≤n +pred-cancel-≤ {m = suc _} {n = zero} z≤n = inj₁ (refl , refl) +pred-cancel-≤ {m = suc _} {n = suc _} le = inj₂ (s≤s le) + +pred-cancel-< : pred m < pred n m < n +pred-cancel-< {m = zero} {n = suc _} _ = z<s +pred-cancel-< {m = suc _} {n = suc _} = s<s + +pred-injective : .{{NonZero m}} .{{NonZero n}} pred m pred n m n +pred-injective {suc m} {suc n} = cong suc + +pred-cancel-≡ : pred m pred n ((m 0 × n 1) (m 1 × n 0)) m n +pred-cancel-≡ {m = zero} {n = zero} _ = inj₂ refl +pred-cancel-≡ {m = zero} {n = suc _} refl = inj₁ (inj₁ (refl , refl)) +pred-cancel-≡ {m = suc _} {n = zero} refl = inj₁ (inj₂ (refl , refl)) +pred-cancel-≡ {m = suc _} {n = suc _} = inj₂ pred-injective + +------------------------------------------------------------------------ +-- Properties of ∣_-_∣ +------------------------------------------------------------------------ + +------------------------------------------------------------------------ +-- Basic + +m≡n⇒∣m-n∣≡0 : m n m - n 0 +m≡n⇒∣m-n∣≡0 {zero} refl = refl +m≡n⇒∣m-n∣≡0 {suc m} refl = m≡n⇒∣m-n∣≡0 {m} refl + +∣m-n∣≡0⇒m≡n : m - n 0 m n +∣m-n∣≡0⇒m≡n {zero} {zero} eq = refl +∣m-n∣≡0⇒m≡n {suc m} {suc n} eq = cong suc (∣m-n∣≡0⇒m≡n eq) + +m≤n⇒∣n-m∣≡n∸m : m n n - m n m +m≤n⇒∣n-m∣≡n∸m {n = zero} z≤n = refl +m≤n⇒∣n-m∣≡n∸m {n = suc n} z≤n = refl +m≤n⇒∣n-m∣≡n∸m {n = _} (s≤s m≤n) = m≤n⇒∣n-m∣≡n∸m m≤n + +m≤n⇒∣m-n∣≡n∸m : m n m - n n m +m≤n⇒∣m-n∣≡n∸m {n = zero} z≤n = refl +m≤n⇒∣m-n∣≡n∸m {n = suc n} z≤n = refl +m≤n⇒∣m-n∣≡n∸m {n = _} (s≤s m≤n) = m≤n⇒∣m-n∣≡n∸m m≤n + +∣m-n∣≡m∸n⇒n≤m : m - n m n n m +∣m-n∣≡m∸n⇒n≤m {zero} {zero} eq = z≤n +∣m-n∣≡m∸n⇒n≤m {suc m} {zero} eq = z≤n +∣m-n∣≡m∸n⇒n≤m {suc m} {suc n} eq = s≤s (∣m-n∣≡m∸n⇒n≤m eq) + +∣n-n∣≡0 : n n - n 0 +∣n-n∣≡0 n = m≡n⇒∣m-n∣≡0 {n} refl + +∣m-m+n∣≡n : m n m - m + n n +∣m-m+n∣≡n zero n = refl +∣m-m+n∣≡n (suc m) n = ∣m-m+n∣≡n m n + +∣m+n-m+o∣≡∣n-o∣ : m n o m + n - m + o n - o +∣m+n-m+o∣≡∣n-o∣ zero n o = refl +∣m+n-m+o∣≡∣n-o∣ (suc m) n o = ∣m+n-m+o∣≡∣n-o∣ m n o + +m∸n≤∣m-n∣ : m n m n m - n +m∸n≤∣m-n∣ m n with ≤-total m n +... | inj₁ m≤n = subst (_≤ m - n ) (sym (m≤n⇒m∸n≡0 m≤n)) z≤n +... | inj₂ n≤m = subst (m n ≤_) (sym (m≤n⇒∣n-m∣≡n∸m n≤m)) ≤-refl + +∣m-n∣≤m⊔n : m n m - n m n +∣m-n∣≤m⊔n zero m = ≤-refl +∣m-n∣≤m⊔n (suc m) zero = ≤-refl +∣m-n∣≤m⊔n (suc m) (suc n) = m≤n⇒m≤1+n (∣m-n∣≤m⊔n m n) + +∣-∣-identityˡ : LeftIdentity 0 ∣_-_∣ +∣-∣-identityˡ x = refl + +∣-∣-identityʳ : RightIdentity 0 ∣_-_∣ +∣-∣-identityʳ zero = refl +∣-∣-identityʳ (suc x) = refl + +∣-∣-identity : Identity 0 ∣_-_∣ +∣-∣-identity = ∣-∣-identityˡ , ∣-∣-identityʳ + +∣-∣-comm : Commutative ∣_-_∣ +∣-∣-comm zero zero = refl +∣-∣-comm zero (suc n) = refl +∣-∣-comm (suc m) zero = refl +∣-∣-comm (suc m) (suc n) = ∣-∣-comm m n + +∣m-n∣≡[m∸n]∨[n∸m] : m n ( m - n m n) ( m - n n m) +∣m-n∣≡[m∸n]∨[n∸m] m n with ≤-total m n +... | inj₂ n≤m = inj₁ $ m≤n⇒∣n-m∣≡n∸m n≤m +... | inj₁ m≤n = inj₂ $ begin-equality + m - n ≡⟨ ∣-∣-comm m n + n - m ≡⟨ m≤n⇒∣n-m∣≡n∸m m≤n + n m + +*-distribˡ-∣-∣ : _*_ DistributesOverˡ ∣_-_∣ +*-distribˡ-∣-∣ a = wlog ≤-total (comm⇒sym[distribˡ] {_◦_ = _*_} ∣-∣-comm a) + $′ λ m n m≤n begin-equality + a * m - n ≡⟨ cong (a *_) (m≤n⇒∣m-n∣≡n∸m m≤n) + a * (n m) ≡⟨ *-distribˡ-∸ a n m + a * n a * m ≡⟨ m≤n⇒∣m-n∣≡n∸m (*-monoʳ-≤ a m≤n) + a * m - a * n + +*-distribʳ-∣-∣ : _*_ DistributesOverʳ ∣_-_∣ +*-distribʳ-∣-∣ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-∣-∣ + +*-distrib-∣-∣ : _*_ DistributesOver ∣_-_∣ +*-distrib-∣-∣ = *-distribˡ-∣-∣ , *-distribʳ-∣-∣ + +m≤n+∣n-m∣ : m n m n + n - m +m≤n+∣n-m∣ zero n = z≤n +m≤n+∣n-m∣ (suc m) zero = ≤-refl +m≤n+∣n-m∣ (suc m) (suc n) = s≤s (m≤n+∣n-m∣ m n) + +m≤n+∣m-n∣ : m n m n + m - n +m≤n+∣m-n∣ m n = subst (m ≤_) (cong (n +_) (∣-∣-comm n m)) (m≤n+∣n-m∣ m n) + +m≤∣m-n∣+n : m n m m - n + n +m≤∣m-n∣+n m n = subst (m ≤_) (+-comm n _) (m≤n+∣m-n∣ m n) + +∣-∣-triangle : TriangleInequality ∣_-_∣ +∣-∣-triangle zero y z = m≤n+∣n-m∣ z y +∣-∣-triangle x zero z = begin + x - z ≤⟨ ∣m-n∣≤m⊔n x z + x z ≤⟨ m⊔n≤m+n x z + x + z ≡⟨ cong₂ _+_ (sym (∣-∣-identityʳ x)) refl + x - 0 + z + where open ≤-Reasoning +∣-∣-triangle x y zero = begin + x - 0 ≡⟨ ∣-∣-identityʳ x + x ≤⟨ m≤∣m-n∣+n x y + x - y + y ≡⟨ cong₂ _+_ refl (sym (∣-∣-identityʳ y)) + x - y + y - 0 + where open ≤-Reasoning +∣-∣-triangle (suc x) (suc y) (suc z) = ∣-∣-triangle x y z + +∣-∣≡∣-∣′ : m n m - n m - n ∣′ +∣-∣≡∣-∣′ m n with m <ᵇ n in eq +... | false = m≤n⇒∣n-m∣≡n∸m {n} {m} (≮⇒≥ m<n subst T eq (<⇒<ᵇ m<n))) +... | true = m≤n⇒∣m-n∣≡n∸m {m} {n} (<⇒≤ (<ᵇ⇒< m n (subst T (sym eq) _))) + +------------------------------------------------------------------------ +-- Metric structures + +∣-∣-isProtoMetric : IsProtoMetric _≡_ ∣_-_∣ +∣-∣-isProtoMetric = record + { isPartialOrder = ≤-isPartialOrder + ; ≈-isEquivalence = isEquivalence + ; cong = cong₂ ∣_-_∣ + ; nonNegative = z≤n + } + +∣-∣-isPreMetric : IsPreMetric _≡_ ∣_-_∣ +∣-∣-isPreMetric = record + { isProtoMetric = ∣-∣-isProtoMetric + ; ≈⇒0 = m≡n⇒∣m-n∣≡0 + } + +∣-∣-isQuasiSemiMetric : IsQuasiSemiMetric _≡_ ∣_-_∣ +∣-∣-isQuasiSemiMetric = record + { isPreMetric = ∣-∣-isPreMetric + ; 0⇒≈ = ∣m-n∣≡0⇒m≡n + } + +∣-∣-isSemiMetric : IsSemiMetric _≡_ ∣_-_∣ +∣-∣-isSemiMetric = record + { isQuasiSemiMetric = ∣-∣-isQuasiSemiMetric + ; sym = ∣-∣-comm + } + +∣-∣-isMetric : IsMetric _≡_ ∣_-_∣ +∣-∣-isMetric = record + { isSemiMetric = ∣-∣-isSemiMetric + ; triangle = ∣-∣-triangle + } + +------------------------------------------------------------------------ +-- Metric bundles + +∣-∣-quasiSemiMetric : QuasiSemiMetric 0ℓ 0ℓ +∣-∣-quasiSemiMetric = record + { isQuasiSemiMetric = ∣-∣-isQuasiSemiMetric + } + +∣-∣-semiMetric : SemiMetric 0ℓ 0ℓ +∣-∣-semiMetric = record + { isSemiMetric = ∣-∣-isSemiMetric + } + +∣-∣-preMetric : PreMetric 0ℓ 0ℓ +∣-∣-preMetric = record + { isPreMetric = ∣-∣-isPreMetric + } + +∣-∣-metric : Metric 0ℓ 0ℓ +∣-∣-metric = record + { isMetric = ∣-∣-isMetric + } + +------------------------------------------------------------------------ +-- Properties of ⌊_/2⌋ and ⌈_/2⌉ +------------------------------------------------------------------------ + +⌊n/2⌋-mono : ⌊_/2⌋ Preserves _≤_ _≤_ +⌊n/2⌋-mono z≤n = z≤n +⌊n/2⌋-mono (s≤s z≤n) = z≤n +⌊n/2⌋-mono (s≤s (s≤s m≤n)) = s≤s (⌊n/2⌋-mono m≤n) + +⌈n/2⌉-mono : ⌈_/2⌉ Preserves _≤_ _≤_ +⌈n/2⌉-mono m≤n = ⌊n/2⌋-mono (s≤s m≤n) + +⌊n/2⌋≤⌈n/2⌉ : n n /2⌋ n /2⌉ +⌊n/2⌋≤⌈n/2⌉ zero = z≤n +⌊n/2⌋≤⌈n/2⌉ (suc zero) = z≤n +⌊n/2⌋≤⌈n/2⌉ (suc (suc n)) = s≤s (⌊n/2⌋≤⌈n/2⌉ n) + +⌊n/2⌋+⌈n/2⌉≡n : n n /2⌋ + n /2⌉ n +⌊n/2⌋+⌈n/2⌉≡n zero = refl +⌊n/2⌋+⌈n/2⌉≡n (suc n) = begin-equality + suc n /2⌋ + suc n /2⌋ ≡⟨ +-comm suc n /2⌋ (suc n /2⌋) + suc n /2⌋ + suc n /2⌋ ≡⟨⟩ + suc ( n /2⌋ + suc n /2⌋) ≡⟨ cong suc (⌊n/2⌋+⌈n/2⌉≡n n) + suc n + +⌊n/2⌋≤n : n n /2⌋ n +⌊n/2⌋≤n zero = z≤n +⌊n/2⌋≤n (suc zero) = z≤n +⌊n/2⌋≤n (suc (suc n)) = s≤s (m≤n⇒m≤1+n (⌊n/2⌋≤n n)) + +⌊n/2⌋<n : n suc n /2⌋ < suc n +⌊n/2⌋<n zero = z<s +⌊n/2⌋<n (suc n) = s<s (s≤s (⌊n/2⌋≤n n)) + +n≡⌊n+n/2⌋ : n n n + n /2⌋ +n≡⌊n+n/2⌋ zero = refl +n≡⌊n+n/2⌋ (suc zero) = refl +n≡⌊n+n/2⌋ (suc n′@(suc n)) = + cong suc (trans (n≡⌊n+n/2⌋ _) (cong ⌊_/2⌋ (sym (+-suc n n′)))) + +⌈n/2⌉≤n : n n /2⌉ n +⌈n/2⌉≤n zero = z≤n +⌈n/2⌉≤n (suc n) = s≤s (⌊n/2⌋≤n n) + +⌈n/2⌉<n : n suc (suc n) /2⌉ < suc (suc n) +⌈n/2⌉<n n = s<s (⌊n/2⌋<n n) + +n≡⌈n+n/2⌉ : n n n + n /2⌉ +n≡⌈n+n/2⌉ zero = refl +n≡⌈n+n/2⌉ (suc zero) = refl +n≡⌈n+n/2⌉ (suc n′@(suc n)) = + cong suc (trans (n≡⌈n+n/2⌉ _) (cong ⌈_/2⌉ (sym (+-suc n n′)))) + +------------------------------------------------------------------------ +-- Properties of !_ + +1≤n! : n 1 n ! +1≤n! zero = ≤-refl +1≤n! (suc n) = *-mono-≤ (m≤m+n 1 n) (1≤n! n) + +infix 4 _!≢0 _!*_!≢0 ------------------------------------------------------------------------- --- Other properties of _⊔_ and _*_ +_!≢0 : n NonZero (n !) +n !≢0 = >-nonZero (1≤n! n) -*-distribˡ-⊔ : _*_ DistributesOverˡ _⊔_ -*-distribˡ-⊔ m zero o = sym (cong (_⊔ m * o) (*-zeroʳ m)) -*-distribˡ-⊔ m (suc n) zero = begin-equality - m * (suc n zero) ≡⟨⟩ - m * suc n ≡⟨ ⊔-identityʳ (m * suc n) - m * suc n zero ≡⟨ cong (m * suc n ⊔_) (*-zeroʳ m) - m * suc n m * zero -*-distribˡ-⊔ m (suc n) (suc o) = begin-equality - m * (suc n suc o) ≡⟨⟩ - m * suc (n o) ≡⟨ *-suc m (n o) - m + m * (n o) ≡⟨ cong (m +_) (*-distribˡ-⊔ m n o) - m + (m * n m * o) ≡⟨ +-distribˡ-⊔ m (m * n) (m * o) - (m + m * n) (m + m * o) ≡⟨ cong₂ _⊔_ (*-suc m n) (*-suc m o) - (m * suc n) (m * suc o) - -*-distribʳ-⊔ : _*_ DistributesOverʳ _⊔_ -*-distribʳ-⊔ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-⊔ - -*-distrib-⊔ : _*_ DistributesOver _⊔_ -*-distrib-⊔ = *-distribˡ-⊔ , *-distribʳ-⊔ - ------------------------------------------------------------------------- --- Properties of _⊓_ ------------------------------------------------------------------------- - ------------------------------------------------------------------------- --- Algebraic properties - -⊓-zeroˡ : LeftZero 0 _⊓_ -⊓-zeroˡ _ = refl - -⊓-zeroʳ : RightZero 0 _⊓_ -⊓-zeroʳ zero = refl -⊓-zeroʳ (suc n) = refl - -⊓-zero : Zero 0 _⊓_ -⊓-zero = ⊓-zeroˡ , ⊓-zeroʳ - ------------------------------------------------------------------------- --- Structures - -⊔-⊓-isSemiringWithoutOne : IsSemiringWithoutOne _⊔_ _⊓_ 0 -⊔-⊓-isSemiringWithoutOne = record - { +-isCommutativeMonoid = ⊔-0-isCommutativeMonoid - ; *-cong = cong₂ _⊓_ - ; *-assoc = ⊓-assoc - ; distrib = ⊓-distrib-⊔ - ; zero = ⊓-zero - } - -⊔-⊓-isCommutativeSemiringWithoutOne - : IsCommutativeSemiringWithoutOne _⊔_ _⊓_ 0 -⊔-⊓-isCommutativeSemiringWithoutOne = record - { isSemiringWithoutOne = ⊔-⊓-isSemiringWithoutOne - ; *-comm = ⊓-comm - } - ------------------------------------------------------------------------- --- Bundles - -⊔-⊓-commutativeSemiringWithoutOne : CommutativeSemiringWithoutOne 0ℓ 0ℓ -⊔-⊓-commutativeSemiringWithoutOne = record - { isCommutativeSemiringWithoutOne = - ⊔-⊓-isCommutativeSemiringWithoutOne - } - ------------------------------------------------------------------------- --- Other properties of _⊓_ and _≤_/_<_ - -m<n⇒m⊓o<n : o m < n m o < n -m<n⇒m⊓o<n o m<n = ≤-<-trans (m⊓n≤m _ o) m<n - -m<n⇒o⊓m<n : o m < n o m < n -m<n⇒o⊓m<n o m<n = ≤-<-trans (m⊓n≤n o _) m<n - -m<n⊓o⇒m<n : n o m < n o m < n -m<n⊓o⇒m<n = m≤n⊓o⇒m≤n - -m<n⊓o⇒m<o : n o m < n o m < o -m<n⊓o⇒m<o = m≤n⊓o⇒m≤o - -⊓-mono-< : _⊓_ Preserves₂ _<_ _<_ _<_ -⊓-mono-< = ⊓-mono-≤ - -⊓-pres-m< : m < n m < o m < n o -⊓-pres-m< {m} m<n m<o = subst (_< _) (⊓-idem m) (⊓-mono-< m<n m<o) - ------------------------------------------------------------------------- --- Other properties of _⊓_ and _+_ - -+-distribˡ-⊓ : _+_ DistributesOverˡ _⊓_ -+-distribˡ-⊓ zero n o = refl -+-distribˡ-⊓ (suc m) n o = cong suc (+-distribˡ-⊓ m n o) - -+-distribʳ-⊓ : _+_ DistributesOverʳ _⊓_ -+-distribʳ-⊓ = comm∧distrˡ⇒distrʳ +-comm +-distribˡ-⊓ - -+-distrib-⊓ : _+_ DistributesOver _⊓_ -+-distrib-⊓ = +-distribˡ-⊓ , +-distribʳ-⊓ - -m⊓n≤m+n : m n m n m + n -m⊓n≤m+n m n with ⊓-sel m n -... | inj₁ m⊓n≡m rewrite m⊓n≡m = m≤m+n m n -... | inj₂ m⊓n≡n rewrite m⊓n≡n = m≤n+m n m - ------------------------------------------------------------------------- --- Other properties of _⊓_ and _*_ - -*-distribˡ-⊓ : _*_ DistributesOverˡ _⊓_ -*-distribˡ-⊓ m 0 o = begin-equality - m * (0 o) ≡⟨⟩ - m * 0 ≡⟨ *-zeroʳ m - 0 ≡⟨⟩ - 0 (m * o) ≡⟨ cong (_⊓ (m * o)) (*-zeroʳ m) - (m * 0) (m * o) -*-distribˡ-⊓ m (suc n) 0 = begin-equality - m * (suc n 0) ≡⟨⟩ - m * 0 ≡⟨ *-zeroʳ m - 0 ≡⟨ ⊓-zeroʳ (m * suc n) - (m * suc n) 0 ≡⟨ cong (m * suc n ⊓_) (*-zeroʳ m) - (m * suc n) (m * 0) -*-distribˡ-⊓ m (suc n) (suc o) = begin-equality - m * (suc n suc o) ≡⟨⟩ - m * suc (n o) ≡⟨ *-suc m (n o) - m + m * (n o) ≡⟨ cong (m +_) (*-distribˡ-⊓ m n o) - m + (m * n) (m * o) ≡⟨ +-distribˡ-⊓ m (m * n) (m * o) - (m + m * n) (m + m * o) ≡⟨ cong₂ _⊓_ (*-suc m n) (*-suc m o) - (m * suc n) (m * suc o) - -*-distribʳ-⊓ : _*_ DistributesOverʳ _⊓_ -*-distribʳ-⊓ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-⊓ - -*-distrib-⊓ : _*_ DistributesOver _⊓_ -*-distrib-⊓ = *-distribˡ-⊓ , *-distribʳ-⊓ - ------------------------------------------------------------------------- --- Properties of _∸_ ------------------------------------------------------------------------- - -0∸n≡0 : LeftZero zero _∸_ -0∸n≡0 zero = refl -0∸n≡0 (suc _) = refl - -n∸n≡0 : n n n 0 -n∸n≡0 zero = refl -n∸n≡0 (suc n) = n∸n≡0 n - ------------------------------------------------------------------------- --- Properties of _∸_ and pred - -pred[m∸n]≡m∸[1+n] : m n pred (m n) m suc n -pred[m∸n]≡m∸[1+n] zero zero = refl -pred[m∸n]≡m∸[1+n] (suc m) zero = refl -pred[m∸n]≡m∸[1+n] zero (suc n) = refl -pred[m∸n]≡m∸[1+n] (suc m) (suc n) = pred[m∸n]≡m∸[1+n] m n - ------------------------------------------------------------------------- --- Properties of _∸_ and _≤_/_<_ - -∸-suc : m n suc n m suc (n m) -∸-suc z≤n = refl -∸-suc (s≤s m≤n) = ∸-suc m≤n - -m∸n≤m : m n m n m -m∸n≤m n zero = ≤-refl -m∸n≤m zero (suc n) = ≤-refl -m∸n≤m (suc m) (suc n) = ≤-trans (m∸n≤m m n) (n≤1+n m) - -m≮m∸n : m n m m n -m≮m∸n m zero = n≮n m -m≮m∸n (suc m) (suc n) = m≮m∸n m n ≤-trans (n≤1+n (suc m)) - -1+m≢m∸n : {m} n suc m m n -1+m≢m∸n {m} n eq = m≮m∸n m n (≤-reflexive eq) - -∸-mono : _∸_ Preserves₂ _≤_ _≥_ _≤_ -∸-mono z≤n (s≤s n₁≥n₂) = z≤n -∸-mono (s≤s m₁≤m₂) (s≤s n₁≥n₂) = ∸-mono m₁≤m₂ n₁≥n₂ -∸-mono m₁≤m₂ (z≤n {n = n₁}) = ≤-trans (m∸n≤m _ n₁) m₁≤m₂ - -∸-monoˡ-≤ : o m n m o n o -∸-monoˡ-≤ o m≤n = ∸-mono {u = o} m≤n ≤-refl - -∸-monoʳ-≤ : o m n o m o n -∸-monoʳ-≤ _ m≤n = ∸-mono ≤-refl m≤n - -∸-monoˡ-< : {m n o} m < o n m m n < o n -∸-monoˡ-< {m} {zero} {o} m<o n≤m = m<o -∸-monoˡ-< {suc m} {suc n} {suc o} (s≤s m<o) (s≤s n≤m) = ∸-monoˡ-< m<o n≤m - -∸-monoʳ-< : {m n o} o < n n m m n < m o -∸-monoʳ-< {n = suc n} {zero} (s≤s o<n) (s≤s n<m) = s≤s (m∸n≤m _ n) -∸-monoʳ-< {n = suc n} {suc o} (s≤s o<n) (s≤s n<m) = ∸-monoʳ-< o<n n<m - -∸-cancelʳ-≤ : {m n o} m o o n o m m n -∸-cancelʳ-≤ {_} {_} z≤n _ = z≤n -∸-cancelʳ-≤ {suc m} {zero} (s≤s _) o<o∸m = contradiction o<o∸m (m≮m∸n _ m) -∸-cancelʳ-≤ {suc m} {suc n} (s≤s m≤o) o∸n<o∸m = s≤s (∸-cancelʳ-≤ m≤o o∸n<o∸m) - -∸-cancelʳ-< : {m n o} o m < o n n < m -∸-cancelʳ-< {zero} {n} {o} o<o∸n = contradiction o<o∸n (m≮m∸n o n) -∸-cancelʳ-< {suc m} {zero} {_} o∸n<o∸m = 0<1+n -∸-cancelʳ-< {suc m} {suc n} {suc o} o∸n<o∸m = s≤s (∸-cancelʳ-< o∸n<o∸m) - -∸-cancelˡ-≡ : n m o m m n m o n o -∸-cancelˡ-≡ {_} z≤n z≤n _ = refl -∸-cancelˡ-≡ {o = suc o} z≤n (s≤s _) eq = contradiction eq (1+m≢m∸n o) -∸-cancelˡ-≡ {n = suc n} (s≤s _) z≤n eq = contradiction (sym eq) (1+m≢m∸n n) -∸-cancelˡ-≡ {_} (s≤s n≤m) (s≤s o≤m) eq = cong suc (∸-cancelˡ-≡ n≤m o≤m eq) - -∸-cancelʳ-≡ : o m o n m o n o m n -∸-cancelʳ-≡ z≤n z≤n eq = eq -∸-cancelʳ-≡ (s≤s o≤m) (s≤s o≤n) eq = cong suc (∸-cancelʳ-≡ o≤m o≤n eq) - -m∸n≡0⇒m≤n : m n 0 m n -m∸n≡0⇒m≤n {zero} {_} _ = z≤n -m∸n≡0⇒m≤n {suc m} {suc n} eq = s≤s (m∸n≡0⇒m≤n eq) - -m≤n⇒m∸n≡0 : m n m n 0 -m≤n⇒m∸n≡0 {n = n} z≤n = 0∸n≡0 n -m≤n⇒m∸n≡0 {_} (s≤s m≤n) = m≤n⇒m∸n≡0 m≤n - -m<n⇒0<n∸m : m < n 0 < n m -m<n⇒0<n∸m {zero} {suc n} _ = 0<1+n -m<n⇒0<n∸m {suc m} {suc n} (s≤s m<n) = m<n⇒0<n∸m m<n - -m∸n≢0⇒n<m : m n 0 n < m -m∸n≢0⇒n<m {m} {n} m∸n≢0 with n <? m -... | yes n<m = n<m -... | no n≮m = contradiction (m≤n⇒m∸n≡0 (≮⇒≥ n≮m)) m∸n≢0 - -m>n⇒m∸n≢0 : m > n m n 0 -m>n⇒m∸n≢0 {n = suc n} (s≤s m>n) = m>n⇒m∸n≢0 m>n - -m≤n⇒n∸m≤n : m n n m n -m≤n⇒n∸m≤n z≤n = ≤-refl -m≤n⇒n∸m≤n (s≤s m≤n) = m≤n⇒m≤1+n (m≤n⇒n∸m≤n m≤n) - ------------------------------------------------------------------------- --- Properties of _∸_ and _+_ - -+-∸-comm : {m} n {o} o m (m + n) o (m o) + n -+-∸-comm {zero} _ {zero} _ = refl -+-∸-comm {suc m} _ {zero} _ = refl -+-∸-comm {suc m} n {suc o} (s≤s o≤m) = +-∸-comm n o≤m - -∸-+-assoc : m n o (m n) o m (n + o) -∸-+-assoc zero zero o = refl -∸-+-assoc zero (suc n) o = 0∸n≡0 o -∸-+-assoc (suc m) zero o = refl -∸-+-assoc (suc m) (suc n) o = ∸-+-assoc m n o - -+-∸-assoc : m {n o} o n (m + n) o m + (n o) -+-∸-assoc zero {n = n} {o = o} _ = begin-equality n o -+-∸-assoc (suc m) {n = n} {o = o} o≤n = begin-equality - suc (m + n) o ≡⟨ ∸-suc (m≤n⇒m≤o+n m o≤n) - suc ((m + n) o) ≡⟨ cong suc (+-∸-assoc m o≤n) - suc (m + (n o)) - -m≤n+o⇒m∸n≤o : m n {o} m n + o m n o -m≤n+o⇒m∸n≤o m zero le = le -m≤n+o⇒m∸n≤o zero (suc n) _ = z≤n -m≤n+o⇒m∸n≤o (suc m) (suc n) le = m≤n+o⇒m∸n≤o m n (s≤s⁻¹ le) - -m<n+o⇒m∸n<o : m n {o} .{{NonZero o}} m < n + o m n < o -m<n+o⇒m∸n<o m zero lt = lt -m<n+o⇒m∸n<o zero (suc n) {o@(suc _)} lt = z<s -m<n+o⇒m∸n<o (suc m) (suc n) lt = m<n+o⇒m∸n<o m n (s<s⁻¹ lt) - -m+n≤o⇒m≤o∸n : m {n o} m + n o m o n -m+n≤o⇒m≤o∸n zero le = z≤n -m+n≤o⇒m≤o∸n (suc m) (s≤s le) - rewrite ∸-suc (m+n≤o⇒n≤o m le) = s≤s (m+n≤o⇒m≤o∸n m le) - -m≤o∸n⇒m+n≤o : m {n o} (n≤o : n o) m o n m + n o -m≤o∸n⇒m+n≤o m z≤n le rewrite +-identityʳ m = le -m≤o∸n⇒m+n≤o m {suc n} (s≤s n≤o) le rewrite +-suc m n = s≤s (m≤o∸n⇒m+n≤o m n≤o le) - -m≤n+m∸n : m n m n + (m n) -m≤n+m∸n zero n = z≤n -m≤n+m∸n (suc m) zero = ≤-refl -m≤n+m∸n (suc m) (suc n) = s≤s (m≤n+m∸n m n) - -m+n∸n≡m : m n m + n n m -m+n∸n≡m m n = begin-equality - (m + n) n ≡⟨ +-∸-assoc m (≤-refl {x = n}) - m + (n n) ≡⟨ cong (m +_) (n∸n≡0 n) - m + 0 ≡⟨ +-identityʳ m - m - -m+n∸m≡n : m n m + n m n -m+n∸m≡n m n = trans (cong (_∸ m) (+-comm m n)) (m+n∸n≡m n m) - -m+[n∸m]≡n : m n m + (n m) n -m+[n∸m]≡n {m} {n} m≤n = begin-equality - m + (n m) ≡⟨ sym $ +-∸-assoc m m≤n - (m + n) m ≡⟨ cong (_∸ m) (+-comm m n) - (n + m) m ≡⟨ m+n∸n≡m n m - n - -m∸n+n≡m : {m n} n m (m n) + n m -m∸n+n≡m {m} {n} n≤m = begin-equality - (m n) + n ≡⟨ sym (+-∸-comm n n≤m) - (m + n) n ≡⟨ m+n∸n≡m m n - m - -m∸[m∸n]≡n : {m n} n m m (m n) n -m∸[m∸n]≡n {m} {_} z≤n = n∸n≡0 m -m∸[m∸n]≡n {suc m} {suc n} (s≤s n≤m) = begin-equality - suc m (m n) ≡⟨ ∸-suc (m∸n≤m m n) - suc (m (m n)) ≡⟨ cong suc (m∸[m∸n]≡n n≤m) - suc n - -[m+n]∸[m+o]≡n∸o : m n o (m + n) (m + o) n o -[m+n]∸[m+o]≡n∸o zero n o = refl -[m+n]∸[m+o]≡n∸o (suc m) n o = [m+n]∸[m+o]≡n∸o m n o - ------------------------------------------------------------------------- --- Properties of _∸_ and _*_ - -*-distribʳ-∸ : _*_ DistributesOverʳ _∸_ -*-distribʳ-∸ m zero zero = refl -*-distribʳ-∸ zero zero (suc o) = sym (0∸n≡0 (o * zero)) -*-distribʳ-∸ (suc m) zero (suc o) = refl -*-distribʳ-∸ m (suc n) zero = refl -*-distribʳ-∸ m (suc n) (suc o) = begin-equality - (n o) * m ≡⟨ *-distribʳ-∸ m n o - n * m o * m ≡⟨ sym $ [m+n]∸[m+o]≡n∸o m _ _ - m + n * m (m + o * m) - -*-distribˡ-∸ : _*_ DistributesOverˡ _∸_ -*-distribˡ-∸ = comm∧distrʳ⇒distrˡ *-comm *-distribʳ-∸ - -*-distrib-∸ : _*_ DistributesOver _∸_ -*-distrib-∸ = *-distribˡ-∸ , *-distribʳ-∸ - -even≢odd : m n 2 * m suc (2 * n) -even≢odd (suc m) zero eq = contradiction (suc-injective eq) (m+1+n≢0 m) -even≢odd (suc m) (suc n) eq = even≢odd m n (suc-injective (begin-equality - suc (2 * m) ≡⟨ sym (+-suc m _) - m + suc (m + 0) ≡⟨ suc-injective eq - suc n + suc (n + 0) ≡⟨ cong suc (+-suc n _) - suc (suc (2 * n)) )) - ------------------------------------------------------------------------- --- Properties of _∸_ and _⊓_ and _⊔_ - -m⊓n+n∸m≡n : m n (m n) + (n m) n -m⊓n+n∸m≡n zero n = refl -m⊓n+n∸m≡n (suc m) zero = refl -m⊓n+n∸m≡n (suc m) (suc n) = cong suc $ m⊓n+n∸m≡n m n - -[m∸n]⊓[n∸m]≡0 : m n (m n) (n m) 0 -[m∸n]⊓[n∸m]≡0 zero zero = refl -[m∸n]⊓[n∸m]≡0 zero (suc n) = refl -[m∸n]⊓[n∸m]≡0 (suc m) zero = refl -[m∸n]⊓[n∸m]≡0 (suc m) (suc n) = [m∸n]⊓[n∸m]≡0 m n - -∸-distribˡ-⊓-⊔ : m n o m (n o) (m n) (m o) -∸-distribˡ-⊓-⊔ m n o = antimono-≤-distrib-⊓ (∸-monoʳ-≤ m) n o - -∸-distribʳ-⊓ : _∸_ DistributesOverʳ _⊓_ -∸-distribʳ-⊓ m n o = mono-≤-distrib-⊓ (∸-monoˡ-≤ m) n o - -∸-distribˡ-⊔-⊓ : m n o m (n o) (m n) (m o) -∸-distribˡ-⊔-⊓ m n o = antimono-≤-distrib-⊔ (∸-monoʳ-≤ m) n o - -∸-distribʳ-⊔ : _∸_ DistributesOverʳ _⊔_ -∸-distribʳ-⊔ m n o = mono-≤-distrib-⊔ (∸-monoˡ-≤ m) n o - ------------------------------------------------------------------------- --- Properties of pred ------------------------------------------------------------------------- - -pred[n]≤n : pred n n -pred[n]≤n {zero} = z≤n -pred[n]≤n {suc n} = n≤1+n n - -≤pred⇒≤ : m pred n m n -≤pred⇒≤ {n = zero} le = le -≤pred⇒≤ {n = suc n} le = m≤n⇒m≤1+n le - -≤⇒pred≤ : m n pred m n -≤⇒pred≤ {zero} le = le -≤⇒pred≤ {suc m} le = ≤-trans (n≤1+n m) le - -<⇒≤pred : m < n m pred n -<⇒≤pred (s≤s le) = le - -suc-pred : n .{{_ : NonZero n}} suc (pred n) n -suc-pred (suc n) = refl - -pred-mono-≤ : pred Preserves _≤_ _≤_ -pred-mono-≤ {zero} _ = z≤n -pred-mono-≤ {suc _} {suc _} m≤n = s≤s⁻¹ m≤n - -pred-mono-< : .{{NonZero m}} m < n pred m < pred n -pred-mono-< {m = suc _} {n = suc _} = s<s⁻¹ - -pred-cancel-≤ : pred m pred n (m 1 × n 0) m n -pred-cancel-≤ {m = zero} {n = zero} _ = inj₂ z≤n -pred-cancel-≤ {m = zero} {n = suc _} _ = inj₂ z≤n -pred-cancel-≤ {m = suc _} {n = zero} z≤n = inj₁ (refl , refl) -pred-cancel-≤ {m = suc _} {n = suc _} le = inj₂ (s≤s le) - -pred-cancel-< : pred m < pred n m < n -pred-cancel-< {m = zero} {n = suc _} _ = z<s -pred-cancel-< {m = suc _} {n = suc _} = s<s - -pred-injective : .{{NonZero m}} .{{NonZero n}} pred m pred n m n -pred-injective {suc m} {suc n} = cong suc - -pred-cancel-≡ : pred m pred n ((m 0 × n 1) (m 1 × n 0)) m n -pred-cancel-≡ {m = zero} {n = zero} _ = inj₂ refl -pred-cancel-≡ {m = zero} {n = suc _} refl = inj₁ (inj₁ (refl , refl)) -pred-cancel-≡ {m = suc _} {n = zero} refl = inj₁ (inj₂ (refl , refl)) -pred-cancel-≡ {m = suc _} {n = suc _} = inj₂ pred-injective - ------------------------------------------------------------------------- --- Properties of ∣_-_∣ ------------------------------------------------------------------------- - ------------------------------------------------------------------------- --- Basic - -m≡n⇒∣m-n∣≡0 : m n m - n 0 -m≡n⇒∣m-n∣≡0 {zero} refl = refl -m≡n⇒∣m-n∣≡0 {suc m} refl = m≡n⇒∣m-n∣≡0 {m} refl - -∣m-n∣≡0⇒m≡n : m - n 0 m n -∣m-n∣≡0⇒m≡n {zero} {zero} eq = refl -∣m-n∣≡0⇒m≡n {suc m} {suc n} eq = cong suc (∣m-n∣≡0⇒m≡n eq) - -m≤n⇒∣n-m∣≡n∸m : m n n - m n m -m≤n⇒∣n-m∣≡n∸m {n = zero} z≤n = refl -m≤n⇒∣n-m∣≡n∸m {n = suc n} z≤n = refl -m≤n⇒∣n-m∣≡n∸m {n = _} (s≤s m≤n) = m≤n⇒∣n-m∣≡n∸m m≤n - -m≤n⇒∣m-n∣≡n∸m : m n m - n n m -m≤n⇒∣m-n∣≡n∸m {n = zero} z≤n = refl -m≤n⇒∣m-n∣≡n∸m {n = suc n} z≤n = refl -m≤n⇒∣m-n∣≡n∸m {n = _} (s≤s m≤n) = m≤n⇒∣m-n∣≡n∸m m≤n - -∣m-n∣≡m∸n⇒n≤m : m - n m n n m -∣m-n∣≡m∸n⇒n≤m {zero} {zero} eq = z≤n -∣m-n∣≡m∸n⇒n≤m {suc m} {zero} eq = z≤n -∣m-n∣≡m∸n⇒n≤m {suc m} {suc n} eq = s≤s (∣m-n∣≡m∸n⇒n≤m eq) - -∣n-n∣≡0 : n n - n 0 -∣n-n∣≡0 n = m≡n⇒∣m-n∣≡0 {n} refl - -∣m-m+n∣≡n : m n m - m + n n -∣m-m+n∣≡n zero n = refl -∣m-m+n∣≡n (suc m) n = ∣m-m+n∣≡n m n - -∣m+n-m+o∣≡∣n-o∣ : m n o m + n - m + o n - o -∣m+n-m+o∣≡∣n-o∣ zero n o = refl -∣m+n-m+o∣≡∣n-o∣ (suc m) n o = ∣m+n-m+o∣≡∣n-o∣ m n o - -m∸n≤∣m-n∣ : m n m n m - n -m∸n≤∣m-n∣ m n with ≤-total m n -... | inj₁ m≤n = subst (_≤ m - n ) (sym (m≤n⇒m∸n≡0 m≤n)) z≤n -... | inj₂ n≤m = subst (m n ≤_) (sym (m≤n⇒∣n-m∣≡n∸m n≤m)) ≤-refl - -∣m-n∣≤m⊔n : m n m - n m n -∣m-n∣≤m⊔n zero m = ≤-refl -∣m-n∣≤m⊔n (suc m) zero = ≤-refl -∣m-n∣≤m⊔n (suc m) (suc n) = m≤n⇒m≤1+n (∣m-n∣≤m⊔n m n) - -∣-∣-identityˡ : LeftIdentity 0 ∣_-_∣ -∣-∣-identityˡ x = refl - -∣-∣-identityʳ : RightIdentity 0 ∣_-_∣ -∣-∣-identityʳ zero = refl -∣-∣-identityʳ (suc x) = refl - -∣-∣-identity : Identity 0 ∣_-_∣ -∣-∣-identity = ∣-∣-identityˡ , ∣-∣-identityʳ - -∣-∣-comm : Commutative ∣_-_∣ -∣-∣-comm zero zero = refl -∣-∣-comm zero (suc n) = refl -∣-∣-comm (suc m) zero = refl -∣-∣-comm (suc m) (suc n) = ∣-∣-comm m n - -∣m-n∣≡[m∸n]∨[n∸m] : m n ( m - n m n) ( m - n n m) -∣m-n∣≡[m∸n]∨[n∸m] m n with ≤-total m n -... | inj₂ n≤m = inj₁ $ m≤n⇒∣n-m∣≡n∸m n≤m -... | inj₁ m≤n = inj₂ $ begin-equality - m - n ≡⟨ ∣-∣-comm m n - n - m ≡⟨ m≤n⇒∣n-m∣≡n∸m m≤n - n m - -*-distribˡ-∣-∣ : _*_ DistributesOverˡ ∣_-_∣ -*-distribˡ-∣-∣ a = wlog ≤-total (comm⇒sym[distribˡ] {_◦_ = _*_} ∣-∣-comm a) - $′ λ m n m≤n begin-equality - a * m - n ≡⟨ cong (a *_) (m≤n⇒∣m-n∣≡n∸m m≤n) - a * (n m) ≡⟨ *-distribˡ-∸ a n m - a * n a * m ≡⟨ m≤n⇒∣m-n∣≡n∸m (*-monoʳ-≤ a m≤n) - a * m - a * n - -*-distribʳ-∣-∣ : _*_ DistributesOverʳ ∣_-_∣ -*-distribʳ-∣-∣ = comm∧distrˡ⇒distrʳ *-comm *-distribˡ-∣-∣ - -*-distrib-∣-∣ : _*_ DistributesOver ∣_-_∣ -*-distrib-∣-∣ = *-distribˡ-∣-∣ , *-distribʳ-∣-∣ - -m≤n+∣n-m∣ : m n m n + n - m -m≤n+∣n-m∣ zero n = z≤n -m≤n+∣n-m∣ (suc m) zero = ≤-refl -m≤n+∣n-m∣ (suc m) (suc n) = s≤s (m≤n+∣n-m∣ m n) - -m≤n+∣m-n∣ : m n m n + m - n -m≤n+∣m-n∣ m n = subst (m ≤_) (cong (n +_) (∣-∣-comm n m)) (m≤n+∣n-m∣ m n) - -m≤∣m-n∣+n : m n m m - n + n -m≤∣m-n∣+n m n = subst (m ≤_) (+-comm n _) (m≤n+∣m-n∣ m n) - -∣-∣-triangle : TriangleInequality ∣_-_∣ -∣-∣-triangle zero y z = m≤n+∣n-m∣ z y -∣-∣-triangle x zero z = begin - x - z ≤⟨ ∣m-n∣≤m⊔n x z - x z ≤⟨ m⊔n≤m+n x z - x + z ≡⟨ cong₂ _+_ (sym (∣-∣-identityʳ x)) refl - x - 0 + z - where open ≤-Reasoning -∣-∣-triangle x y zero = begin - x - 0 ≡⟨ ∣-∣-identityʳ x - x ≤⟨ m≤∣m-n∣+n x y - x - y + y ≡⟨ cong₂ _+_ refl (sym (∣-∣-identityʳ y)) - x - y + y - 0 - where open ≤-Reasoning -∣-∣-triangle (suc x) (suc y) (suc z) = ∣-∣-triangle x y z - -∣-∣≡∣-∣′ : m n m - n m - n ∣′ -∣-∣≡∣-∣′ m n with m <ᵇ n in eq -... | false = m≤n⇒∣n-m∣≡n∸m {n} {m} (≮⇒≥ m<n subst T eq (<⇒<ᵇ m<n))) -... | true = m≤n⇒∣m-n∣≡n∸m {m} {n} (<⇒≤ (<ᵇ⇒< m n (subst T (sym eq) _))) - ------------------------------------------------------------------------- --- Metric structures - -∣-∣-isProtoMetric : IsProtoMetric _≡_ ∣_-_∣ -∣-∣-isProtoMetric = record - { isPartialOrder = ≤-isPartialOrder - ; ≈-isEquivalence = isEquivalence - ; cong = cong₂ ∣_-_∣ - ; nonNegative = z≤n - } - -∣-∣-isPreMetric : IsPreMetric _≡_ ∣_-_∣ -∣-∣-isPreMetric = record - { isProtoMetric = ∣-∣-isProtoMetric - ; ≈⇒0 = m≡n⇒∣m-n∣≡0 - } - -∣-∣-isQuasiSemiMetric : IsQuasiSemiMetric _≡_ ∣_-_∣ -∣-∣-isQuasiSemiMetric = record - { isPreMetric = ∣-∣-isPreMetric - ; 0⇒≈ = ∣m-n∣≡0⇒m≡n - } - -∣-∣-isSemiMetric : IsSemiMetric _≡_ ∣_-_∣ -∣-∣-isSemiMetric = record - { isQuasiSemiMetric = ∣-∣-isQuasiSemiMetric - ; sym = ∣-∣-comm - } - -∣-∣-isMetric : IsMetric _≡_ ∣_-_∣ -∣-∣-isMetric = record - { isSemiMetric = ∣-∣-isSemiMetric - ; triangle = ∣-∣-triangle - } - ------------------------------------------------------------------------- --- Metric bundles - -∣-∣-quasiSemiMetric : QuasiSemiMetric 0ℓ 0ℓ -∣-∣-quasiSemiMetric = record - { isQuasiSemiMetric = ∣-∣-isQuasiSemiMetric - } - -∣-∣-semiMetric : SemiMetric 0ℓ 0ℓ -∣-∣-semiMetric = record - { isSemiMetric = ∣-∣-isSemiMetric - } - -∣-∣-preMetric : PreMetric 0ℓ 0ℓ -∣-∣-preMetric = record - { isPreMetric = ∣-∣-isPreMetric - } - -∣-∣-metric : Metric 0ℓ 0ℓ -∣-∣-metric = record - { isMetric = ∣-∣-isMetric - } - ------------------------------------------------------------------------- --- Properties of ⌊_/2⌋ and ⌈_/2⌉ ------------------------------------------------------------------------- - -⌊n/2⌋-mono : ⌊_/2⌋ Preserves _≤_ _≤_ -⌊n/2⌋-mono z≤n = z≤n -⌊n/2⌋-mono (s≤s z≤n) = z≤n -⌊n/2⌋-mono (s≤s (s≤s m≤n)) = s≤s (⌊n/2⌋-mono m≤n) - -⌈n/2⌉-mono : ⌈_/2⌉ Preserves _≤_ _≤_ -⌈n/2⌉-mono m≤n = ⌊n/2⌋-mono (s≤s m≤n) - -⌊n/2⌋≤⌈n/2⌉ : n n /2⌋ n /2⌉ -⌊n/2⌋≤⌈n/2⌉ zero = z≤n -⌊n/2⌋≤⌈n/2⌉ (suc zero) = z≤n -⌊n/2⌋≤⌈n/2⌉ (suc (suc n)) = s≤s (⌊n/2⌋≤⌈n/2⌉ n) - -⌊n/2⌋+⌈n/2⌉≡n : n n /2⌋ + n /2⌉ n -⌊n/2⌋+⌈n/2⌉≡n zero = refl -⌊n/2⌋+⌈n/2⌉≡n (suc n) = begin-equality - suc n /2⌋ + suc n /2⌋ ≡⟨ +-comm suc n /2⌋ (suc n /2⌋) - suc n /2⌋ + suc n /2⌋ ≡⟨⟩ - suc ( n /2⌋ + suc n /2⌋) ≡⟨ cong suc (⌊n/2⌋+⌈n/2⌉≡n n) - suc n - -⌊n/2⌋≤n : n n /2⌋ n -⌊n/2⌋≤n zero = z≤n -⌊n/2⌋≤n (suc zero) = z≤n -⌊n/2⌋≤n (suc (suc n)) = s≤s (m≤n⇒m≤1+n (⌊n/2⌋≤n n)) - -⌊n/2⌋<n : n suc n /2⌋ < suc n -⌊n/2⌋<n zero = z<s -⌊n/2⌋<n (suc n) = s<s (s≤s (⌊n/2⌋≤n n)) - -n≡⌊n+n/2⌋ : n n n + n /2⌋ -n≡⌊n+n/2⌋ zero = refl -n≡⌊n+n/2⌋ (suc zero) = refl -n≡⌊n+n/2⌋ (suc n′@(suc n)) = - cong suc (trans (n≡⌊n+n/2⌋ _) (cong ⌊_/2⌋ (sym (+-suc n n′)))) - -⌈n/2⌉≤n : n n /2⌉ n -⌈n/2⌉≤n zero = z≤n -⌈n/2⌉≤n (suc n) = s≤s (⌊n/2⌋≤n n) - -⌈n/2⌉<n : n suc (suc n) /2⌉ < suc (suc n) -⌈n/2⌉<n n = s<s (⌊n/2⌋<n n) - -n≡⌈n+n/2⌉ : n n n + n /2⌉ -n≡⌈n+n/2⌉ zero = refl -n≡⌈n+n/2⌉ (suc zero) = refl -n≡⌈n+n/2⌉ (suc n′@(suc n)) = - cong suc (trans (n≡⌈n+n/2⌉ _) (cong ⌈_/2⌉ (sym (+-suc n n′)))) - ------------------------------------------------------------------------- --- Properties of !_ - -1≤n! : n 1 n ! -1≤n! zero = ≤-refl -1≤n! (suc n) = *-mono-≤ (m≤m+n 1 n) (1≤n! n) - -infix 4 _!≢0 _!*_!≢0 +_!*_!≢0 : m n NonZero (m ! * n !) +m !* n !≢0 = m*n≢0 _ _ {{m !≢0}} {{n !≢0}} -_!≢0 : n NonZero (n !) -n !≢0 = >-nonZero (1≤n! n) +------------------------------------------------------------------------ +-- Properties of _≤′_ and _<′_ -_!*_!≢0 : m n NonZero (m ! * n !) -m !* n !≢0 = m*n≢0 _ _ {{m !≢0}} {{n !≢0}} +≤′-trans : Transitive _≤′_ +≤′-trans m≤n ≤′-refl = m≤n +≤′-trans m≤n (≤′-step n≤o) = ≤′-step (≤′-trans m≤n n≤o) ------------------------------------------------------------------------- --- Properties of _≤′_ and _<′_ +z≤′n : zero ≤′ n +z≤′n {zero} = ≤′-refl +z≤′n {suc n} = ≤′-step z≤′n -≤′-trans : Transitive _≤′_ -≤′-trans m≤n ≤′-refl = m≤n -≤′-trans m≤n (≤′-step n≤o) = ≤′-step (≤′-trans m≤n n≤o) +s≤′s : m ≤′ n suc m ≤′ suc n +s≤′s (≤′-reflexive m≡n) = ≤′-reflexive (cong suc m≡n) +s≤′s (≤′-step m≤′n) = ≤′-step (s≤′s m≤′n) -z≤′n : zero ≤′ n -z≤′n {zero} = ≤′-refl -z≤′n {suc n} = ≤′-step z≤′n +≤′⇒≤ : _≤′_ _≤_ +≤′⇒≤ (≤′-reflexive m≡n) = ≤-reflexive m≡n +≤′⇒≤ (≤′-step m≤′n) = m≤n⇒m≤1+n (≤′⇒≤ m≤′n) -s≤′s : m ≤′ n suc m ≤′ suc n -s≤′s (≤′-reflexive m≡n) = ≤′-reflexive (cong suc m≡n) -s≤′s (≤′-step m≤′n) = ≤′-step (s≤′s m≤′n) +≤⇒≤′ : _≤_ _≤′_ +≤⇒≤′ z≤n = z≤′n +≤⇒≤′ (s≤s m≤n) = s≤′s (≤⇒≤′ m≤n) -≤′⇒≤ : _≤′_ _≤_ -≤′⇒≤ (≤′-reflexive m≡n) = ≤-reflexive m≡n -≤′⇒≤ (≤′-step m≤′n) = m≤n⇒m≤1+n (≤′⇒≤ m≤′n) +≤′-step-injective : {p q : m ≤′ n} ≤′-step p ≤′-step q p q +≤′-step-injective refl = refl -≤⇒≤′ : _≤_ _≤′_ -≤⇒≤′ z≤n = z≤′n -≤⇒≤′ (s≤s m≤n) = s≤′s (≤⇒≤′ m≤n) +------------------------------------------------------------------------ +-- Properties of _<′_ and _<_ +------------------------------------------------------------------------ -≤′-step-injective : {p q : m ≤′ n} ≤′-step p ≤′-step q p q -≤′-step-injective refl = refl +z<′s : zero <′ suc n +z<′s {zero} = <′-base +z<′s {suc n} = <′-step (z<′s {n}) ------------------------------------------------------------------------- --- Properties of _<′_ and _<_ ------------------------------------------------------------------------- +s<′s : m <′ n suc m <′ suc n +s<′s <′-base = <′-base +s<′s (<′-step m<′n) = <′-step (s<′s m<′n) -z<′s : zero <′ suc n -z<′s {zero} = <′-base -z<′s {suc n} = <′-step (z<′s {n}) +<⇒<′ : m < n m <′ n +<⇒<′ z<s = z<′s +<⇒<′ (s<s m<n@(s≤s _)) = s<′s (<⇒<′ m<n) -s<′s : m <′ n suc m <′ suc n -s<′s <′-base = <′-base -s<′s (<′-step m<′n) = <′-step (s<′s m<′n) +<′⇒< : m <′ n m < n +<′⇒< <′-base = n<1+n _ +<′⇒< (<′-step m<′n) = m<n⇒m<1+n (<′⇒< m<′n) -<⇒<′ : m < n m <′ n -<⇒<′ z<s = z<′s -<⇒<′ (s<s m<n@(s≤s _)) = s<′s (<⇒<′ m<n) +m<1+n⇒m<n∨m≡n′ : m < suc n m < n m n +m<1+n⇒m<n∨m≡n′ m<n with <⇒<′ m<n +... | <′-base = inj₂ refl +... | <′-step m<′n = inj₁ (<′⇒< m<′n) -<′⇒< : m <′ n m < n -<′⇒< <′-base = n<1+n _ -<′⇒< (<′-step m<′n) = m<n⇒m<1+n (<′⇒< m<′n) +------------------------------------------------------------------------ +-- Other properties of _≤′_ and _<′_ +------------------------------------------------------------------------ -m<1+n⇒m<n∨m≡n′ : m < suc n m < n m n -m<1+n⇒m<n∨m≡n′ m<n with <⇒<′ m<n -... | <′-base = inj₂ refl -... | <′-step m<′n = inj₁ (<′⇒< m<′n) +infix 4 _≤′?_ _<′?_ _≥′?_ _>′?_ ------------------------------------------------------------------------- --- Other properties of _≤′_ and _<′_ ------------------------------------------------------------------------- +_≤′?_ : Decidable _≤′_ +m ≤′? n = map′ ≤⇒≤′ ≤′⇒≤ (m ≤? n) -infix 4 _≤′?_ _<′?_ _≥′?_ _>′?_ +_<′?_ : Decidable _<′_ +m <′? n = suc m ≤′? n -_≤′?_ : Decidable _≤′_ -m ≤′? n = map′ ≤⇒≤′ ≤′⇒≤ (m ≤? n) +_≥′?_ : Decidable _≥′_ +_≥′?_ = flip _≤′?_ -_<′?_ : Decidable _<′_ -m <′? n = suc m ≤′? n +_>′?_ : Decidable _>′_ +_>′?_ = flip _<′?_ -_≥′?_ : Decidable _≥′_ -_≥′?_ = flip _≤′?_ +m≤′m+n : m n m ≤′ m + n +m≤′m+n m n = ≤⇒≤′ (m≤m+n m n) -_>′?_ : Decidable _>′_ -_>′?_ = flip _<′?_ +n≤′m+n : m n n ≤′ m + n +n≤′m+n zero n = ≤′-refl +n≤′m+n (suc m) n = ≤′-step (n≤′m+n m n) -m≤′m+n : m n m ≤′ m + n -m≤′m+n m n = ≤⇒≤′ (m≤m+n m n) +⌈n/2⌉≤′n : n n /2⌉ ≤′ n +⌈n/2⌉≤′n zero = ≤′-refl +⌈n/2⌉≤′n (suc zero) = ≤′-refl +⌈n/2⌉≤′n (suc (suc n)) = s≤′s (≤′-step (⌈n/2⌉≤′n n)) -n≤′m+n : m n n ≤′ m + n -n≤′m+n zero n = ≤′-refl -n≤′m+n (suc m) n = ≤′-step (n≤′m+n m n) +⌊n/2⌋≤′n : n n /2⌋ ≤′ n +⌊n/2⌋≤′n zero = ≤′-refl +⌊n/2⌋≤′n (suc n) = ≤′-step (⌈n/2⌉≤′n n) -⌈n/2⌉≤′n : n n /2⌉ ≤′ n -⌈n/2⌉≤′n zero = ≤′-refl -⌈n/2⌉≤′n (suc zero) = ≤′-refl -⌈n/2⌉≤′n (suc (suc n)) = s≤′s (≤′-step (⌈n/2⌉≤′n n)) +------------------------------------------------------------------------ +-- Properties of _≤″_ and _<″_ +------------------------------------------------------------------------ -⌊n/2⌋≤′n : n n /2⌋ ≤′ n -⌊n/2⌋≤′n zero = ≤′-refl -⌊n/2⌋≤′n (suc n) = ≤′-step (⌈n/2⌉≤′n n) +-- equivalence of _≤″_ to _≤_ ------------------------------------------------------------------------- --- Properties of _≤″_ and _<″_ ------------------------------------------------------------------------- +≤⇒≤″ : _≤_ _≤″_ +≤⇒≤″ = (_ ,_) m+[n∸m]≡n --- equivalence of _≤″_ to _≤_ +<⇒<″ : _<_ _<″_ +<⇒<″ = ≤⇒≤″ -≤⇒≤″ : _≤_ _≤″_ -≤⇒≤″ = (_ ,_) m+[n∸m]≡n +≤″⇒≤ : _≤″_ _≤_ +≤″⇒≤ (k , refl) = m≤m+n _ k -<⇒<″ : _<_ _<″_ -<⇒<″ = ≤⇒≤″ +-- equivalence to the old definition of _≤″_ -≤″⇒≤ : _≤″_ _≤_ -≤″⇒≤ (k , refl) = m≤m+n _ k +≤″-proof : (le : m ≤″ n) let k , _ = le in m + k n +≤″-proof (_ , prf) = prf --- equivalence to the old definition of _≤″_ +-- yielding analogous proof for _≤_ -≤″-proof : (le : m ≤″ n) let k , _ = le in m + k n -≤″-proof (_ , prf) = prf +m≤n⇒∃[o]m+o≡n : .(m n) λ k m + k n +m≤n⇒∃[o]m+o≡n m≤n = _ , m+[n∸m]≡n (recompute (_ ≤? _) m≤n) --- yielding analogous proof for _≤_ +-- whose witness is equal to monus -m≤n⇒∃[o]m+o≡n : .(m n) λ k m + k n -m≤n⇒∃[o]m+o≡n m≤n = _ , m+[n∸m]≡n (recompute (_ ≤? _) m≤n) +guarded-∸≗∸ : {m n} .(m≤n : m n) + let k , _ = m≤n⇒∃[o]m+o≡n m≤n in k n m +guarded-∸≗∸ m≤n = refl --- whose witness is equal to monus +-- equivalence of _<″_ to _<ᵇ_ -guarded-∸≗∸ : {m n} .(m≤n : m n) - let k , _ = m≤n⇒∃[o]m+o≡n m≤n in k n m -guarded-∸≗∸ m≤n = refl +m<ᵇn⇒1+m+[n-1+m]≡n : m n T (m <ᵇ n) suc m + (n suc m) n +m<ᵇn⇒1+m+[n-1+m]≡n m n lt = m+[n∸m]≡n (<ᵇ⇒< m n lt) --- equivalence of _<″_ to _<ᵇ_ +m<ᵇ1+m+n : m {n} T (m <ᵇ suc (m + n)) +m<ᵇ1+m+n m = <⇒<ᵇ (m≤m+n (suc m) _) -m<ᵇn⇒1+m+[n-1+m]≡n : m n T (m <ᵇ n) suc m + (n suc m) n -m<ᵇn⇒1+m+[n-1+m]≡n m n lt = m+[n∸m]≡n (<ᵇ⇒< m n lt) +<ᵇ⇒<″ : T (m <ᵇ n) m <″ n +<ᵇ⇒<″ {m} {n} = <⇒<″ (<ᵇ⇒< m n) -m<ᵇ1+m+n : m {n} T (m <ᵇ suc (m + n)) -m<ᵇ1+m+n m = <⇒<ᵇ (m≤m+n (suc m) _) +<″⇒<ᵇ : {m n} m <″ n T (m <ᵇ n) +<″⇒<ᵇ {m} (k , refl) = <⇒<ᵇ (m≤m+n (suc m) k) -<ᵇ⇒<″ : T (m <ᵇ n) m <″ n -<ᵇ⇒<″ {m} {n} = <⇒<″ (<ᵇ⇒< m n) +-- NB: we use the builtin function `_<ᵇ_ : (m n : ℕ) → Bool` here so +-- that the function quickly decides whether to return `yes` or `no`. +-- It still takes a linear amount of time to generate the proof if it +-- is inspected. We expect the main benefit to be visible for compiled +-- code: the backend erases proofs. -<″⇒<ᵇ : {m n} m <″ n T (m <ᵇ n) -<″⇒<ᵇ {m} (k , refl) = <⇒<ᵇ (m≤m+n (suc m) k) +infix 4 _<″?_ _≤″?_ _≥″?_ _>″?_ --- NB: we use the builtin function `_<ᵇ_ : (m n : ℕ) → Bool` here so --- that the function quickly decides whether to return `yes` or `no`. --- It still takes a linear amount of time to generate the proof if it --- is inspected. We expect the main benefit to be visible for compiled --- code: the backend erases proofs. +_<″?_ : Decidable _<″_ +m <″? n = map′ <ᵇ⇒<″ <″⇒<ᵇ (T? (m <ᵇ n)) -infix 4 _<″?_ _≤″?_ _≥″?_ _>″?_ +_≤″?_ : Decidable _≤″_ +zero ≤″? n = yes (n , refl) +suc m ≤″? n = m <″? n -_<″?_ : Decidable _<″_ -m <″? n = map′ <ᵇ⇒<″ <″⇒<ᵇ (T? (m <ᵇ n)) +_≥″?_ : Decidable _≥″_ +_≥″?_ = flip _≤″?_ -_≤″?_ : Decidable _≤″_ -zero ≤″? n = yes (n , refl) -suc m ≤″? n = m <″? n +_>″?_ : Decidable _>″_ +_>″?_ = flip _<″?_ -_≥″?_ : Decidable _≥″_ -_≥″?_ = flip _≤″?_ +≤″-irrelevant : Irrelevant _≤″_ +≤″-irrelevant {m} (_ , eq₁) (_ , eq₂) + with refl+-cancelˡ-≡ m _ _ (trans eq₁ (sym eq₂)) + = cong (_ ,_) (≡-irrelevant eq₁ eq₂) -_>″?_ : Decidable _>″_ -_>″?_ = flip _<″?_ +<″-irrelevant : Irrelevant _<″_ +<″-irrelevant = ≤″-irrelevant -≤″-irrelevant : Irrelevant _≤″_ -≤″-irrelevant {m} (_ , eq₁) (_ , eq₂) - with refl+-cancelˡ-≡ m _ _ (trans eq₁ (sym eq₂)) - = cong (_ ,_) (≡-irrelevant eq₁ eq₂) +>″-irrelevant : Irrelevant _>″_ +>″-irrelevant = ≤″-irrelevant -<″-irrelevant : Irrelevant _<″_ -<″-irrelevant = ≤″-irrelevant +≥″-irrelevant : Irrelevant _≥″_ +≥″-irrelevant = ≤″-irrelevant ->″-irrelevant : Irrelevant _>″_ ->″-irrelevant = ≤″-irrelevant +------------------------------------------------------------------------ +-- Properties of _≤‴_ +------------------------------------------------------------------------ -≥″-irrelevant : Irrelevant _≥″_ -≥″-irrelevant = ≤″-irrelevant +≤‴⇒≤″ : m ≤‴ n m ≤″ n +≤‴⇒≤″ ≤‴-refl = _ , +-identityʳ _ +≤‴⇒≤″ (≤‴-step m≤n) = _ , trans (+-suc _ _) (≤″-proof (≤‴⇒≤″ m≤n)) ------------------------------------------------------------------------- --- Properties of _≤‴_ ------------------------------------------------------------------------- +m≤‴m+k : m + k n m ≤‴ n +m≤‴m+k {k = zero} = ≤‴-reflexive trans (sym (+-identityʳ _)) +m≤‴m+k {k = suc _} = ≤‴-step m≤‴m+k trans (sym (+-suc _ _)) -≤‴⇒≤″ : m ≤‴ n m ≤″ n -≤‴⇒≤″ ≤‴-refl = _ , +-identityʳ _ -≤‴⇒≤″ (≤‴-step m≤n) = _ , trans (+-suc _ _) (≤″-proof (≤‴⇒≤″ m≤n)) +≤″⇒≤‴ : m ≤″ n m ≤‴ n +≤″⇒≤‴ = m≤‴m+k ≤″-proof -m≤‴m+k : m + k n m ≤‴ n -m≤‴m+k {k = zero} = ≤‴-reflexive trans (sym (+-identityʳ _)) -m≤‴m+k {k = suc _} = ≤‴-step m≤‴m+k trans (sym (+-suc _ _)) +0≤‴n : 0 ≤‴ n +0≤‴n = m≤‴m+k refl -≤″⇒≤‴ : m ≤″ n m ≤‴ n -≤″⇒≤‴ = m≤‴m+k ≤″-proof +<ᵇ⇒<‴ : T (m <ᵇ n) m <‴ n +<ᵇ⇒<‴ = ≤″⇒≤‴ <ᵇ⇒<″ -0≤‴n : 0 ≤‴ n -0≤‴n = m≤‴m+k refl +<‴⇒<ᵇ : m <‴ n T (m <ᵇ n) +<‴⇒<ᵇ = <″⇒<ᵇ ≤‴⇒≤″ -<ᵇ⇒<‴ : T (m <ᵇ n) m <‴ n -<ᵇ⇒<‴ = ≤″⇒≤‴ <ᵇ⇒<″ +infix 4 _<‴?_ _≤‴?_ _≥‴?_ _>‴?_ -<‴⇒<ᵇ : m <‴ n T (m <ᵇ n) -<‴⇒<ᵇ = <″⇒<ᵇ ≤‴⇒≤″ +_<‴?_ : Decidable _<‴_ +m <‴? n = map′ <ᵇ⇒<‴ <‴⇒<ᵇ (T? (m <ᵇ n)) -infix 4 _<‴?_ _≤‴?_ _≥‴?_ _>‴?_ +_≤‴?_ : Decidable _≤‴_ +zero ≤‴? n = yes 0≤‴n +suc m ≤‴? n = m <‴? n -_<‴?_ : Decidable _<‴_ -m <‴? n = map′ <ᵇ⇒<‴ <‴⇒<ᵇ (T? (m <ᵇ n)) +_≥‴?_ : Decidable _≥‴_ +_≥‴?_ = flip _≤‴?_ -_≤‴?_ : Decidable _≤‴_ -zero ≤‴? n = yes 0≤‴n -suc m ≤‴? n = m <‴? n +_>‴?_ : Decidable _>‴_ +_>‴?_ = flip _<‴?_ -_≥‴?_ : Decidable _≥‴_ -_≥‴?_ = flip _≤‴?_ +≤⇒≤‴ : _≤_ _≤‴_ +≤⇒≤‴ = ≤″⇒≤‴ ≤⇒≤″ -_>‴?_ : Decidable _>‴_ -_>‴?_ = flip _<‴?_ +≤‴⇒≤ : _≤‴_ _≤_ +≤‴⇒≤ = ≤″⇒≤ ≤‴⇒≤″ -≤⇒≤‴ : _≤_ _≤‴_ -≤⇒≤‴ = ≤″⇒≤‴ ≤⇒≤″ +<‴-irrefl : Irreflexive _≡_ _<‴_ +<‴-irrefl eq = <-irrefl eq ≤‴⇒≤ -≤‴⇒≤ : _≤‴_ _≤_ -≤‴⇒≤ = ≤″⇒≤ ≤‴⇒≤″ +≤‴-irrelevant : Irrelevant _≤‴_ +≤‴-irrelevant (≤‴-reflexive eq₁) (≤‴-reflexive eq₂) = cong ≤‴-reflexive (≡-irrelevant eq₁ eq₂) +≤‴-irrelevant (≤‴-reflexive eq₁) (≤‴-step q) with ()<‴-irrefl eq₁ q +≤‴-irrelevant (≤‴-step p) (≤‴-reflexive eq₂) with ()<‴-irrefl eq₂ p +≤‴-irrelevant (≤‴-step p) (≤‴-step q) = cong ≤‴-step (≤‴-irrelevant p q) -<‴-irrefl : Irreflexive _≡_ _<‴_ -<‴-irrefl eq = <-irrefl eq ≤‴⇒≤ +<‴-irrelevant : Irrelevant {A = } _<‴_ +<‴-irrelevant = ≤‴-irrelevant -≤‴-irrelevant : Irrelevant _≤‴_ -≤‴-irrelevant (≤‴-reflexive eq₁) (≤‴-reflexive eq₂) = cong ≤‴-reflexive (≡-irrelevant eq₁ eq₂) -≤‴-irrelevant (≤‴-reflexive eq₁) (≤‴-step q) with ()<‴-irrefl eq₁ q -≤‴-irrelevant (≤‴-step p) (≤‴-reflexive eq₂) with ()<‴-irrefl eq₂ p -≤‴-irrelevant (≤‴-step p) (≤‴-step q) = cong ≤‴-step (≤‴-irrelevant p q) +>‴-irrelevant : Irrelevant {A = } _>‴_ +>‴-irrelevant = ≤‴-irrelevant -<‴-irrelevant : Irrelevant {A = } _<‴_ -<‴-irrelevant = ≤‴-irrelevant +≥‴-irrelevant : Irrelevant {A = } _≥‴_ +≥‴-irrelevant = ≤‴-irrelevant ->‴-irrelevant : Irrelevant {A = } _>‴_ ->‴-irrelevant = ≤‴-irrelevant +------------------------------------------------------------------------ +-- Other properties +------------------------------------------------------------------------ -≥‴-irrelevant : Irrelevant {A = } _≥‴_ -≥‴-irrelevant = ≤‴-irrelevant +-- If there is an injection from a type to ℕ, then the type has +-- decidable equality. ------------------------------------------------------------------------- --- Other properties ------------------------------------------------------------------------- +eq? : {a} {A : Set a} A DecidableEquality A +eq? inj = via-injection inj _≟_ --- If there is an injection from a type to ℕ, then the type has --- decidable equality. +-- It's possible to decide existential and universal predicates up to +-- a limit. -eq? : {a} {A : Set a} A DecidableEquality A -eq? inj = via-injection inj _≟_ +module _ {p} {P : Pred p} (P? : U.Decidable P) where --- It's possible to decide existential and universal predicates up to --- a limit. + anyUpTo? : v Dec ( λ n n < v × P n) + anyUpTo? zero = no λ {(_ , () , _)} + anyUpTo? (suc v) with P? v | anyUpTo? v + ... | yes Pv | _ = yes (v , ≤-refl , Pv) + ... | _ | yes (n , n<v , Pn) = yes (n , m≤n⇒m≤1+n n<v , Pn) + ... | no ¬Pv | no ¬Pn<v = no ¬Pn<1+v + where + ¬Pn<1+v : ¬ ( λ n n < suc v × P n) + ¬Pn<1+v (n , s≤s n≤v , Pn) with n v + ... | yes refl = ¬Pv Pn + ... | no n≢v = ¬Pn<v (n , ≤∧≢⇒< n≤v n≢v , Pn) -module _ {p} {P : Pred p} (P? : U.Decidable P) where + allUpTo? : v Dec (∀ {n} n < v P n) + allUpTo? zero = yes λ() + allUpTo? (suc v) with P? v | allUpTo? v + ... | no ¬Pv | _ = no λ prf ¬Pv (prf ≤-refl) + ... | _ | no ¬Pn<v = no λ prf ¬Pn<v (prf m≤n⇒m≤1+n) + ... | yes Pn | yes Pn<v = yes Pn<1+v + where + Pn<1+v : {n} n < suc v P n + Pn<1+v {n} (s≤s n≤v) with n v + ... | yes refl = Pn + ... | no n≢v = Pn<v (≤∧≢⇒< n≤v n≢v) - anyUpTo? : v Dec ( λ n n < v × P n) - anyUpTo? zero = no λ {(_ , () , _)} - anyUpTo? (suc v) with P? v | anyUpTo? v - ... | yes Pv | _ = yes (v , ≤-refl , Pv) - ... | _ | yes (n , n<v , Pn) = yes (n , m≤n⇒m≤1+n n<v , Pn) - ... | no ¬Pv | no ¬Pn<v = no ¬Pn<1+v - where - ¬Pn<1+v : ¬ ( λ n n < suc v × P n) - ¬Pn<1+v (n , s≤s n≤v , Pn) with n v - ... | yes refl = ¬Pv Pn - ... | no n≢v = ¬Pn<v (n , ≤∧≢⇒< n≤v n≢v , Pn) - allUpTo? : v Dec (∀ {n} n < v P n) - allUpTo? zero = yes λ() - allUpTo? (suc v) with P? v | allUpTo? v - ... | no ¬Pv | _ = no λ prf ¬Pv (prf ≤-refl) - ... | _ | no ¬Pn<v = no λ prf ¬Pn<v (prf m≤n⇒m≤1+n) - ... | yes Pn | yes Pn<v = yes Pn<1+v - where - Pn<1+v : {n} n < suc v P n - Pn<1+v {n} (s≤s n≤v) with n v - ... | yes refl = Pn - ... | no n≢v = Pn<v (≤∧≢⇒< n≤v n≢v) +------------------------------------------------------------------------ +-- DEPRECATED NAMES +------------------------------------------------------------------------ +-- Please use the new names as continuing support for the old names is +-- not guaranteed. +-- Version 1.3 ------------------------------------------------------------------------- --- DEPRECATED NAMES ------------------------------------------------------------------------- --- Please use the new names as continuing support for the old names is --- not guaranteed. - --- Version 1.3 - -∀[m≤n⇒m≢o]⇒o<n : n o (∀ {m} m n m o) n < o -∀[m≤n⇒m≢o]⇒o<n = ∀[m≤n⇒m≢o]⇒n<o -{-# WARNING_ON_USAGE ∀[m≤n⇒m≢o]⇒o<n -"Warning: ∀[m≤n⇒m≢o]⇒o<n was deprecated in v1.3. +∀[m≤n⇒m≢o]⇒o<n : n o (∀ {m} m n m o) n < o +∀[m≤n⇒m≢o]⇒o<n = ∀[m≤n⇒m≢o]⇒n<o +{-# WARNING_ON_USAGE ∀[m≤n⇒m≢o]⇒o<n +"Warning: ∀[m≤n⇒m≢o]⇒o<n was deprecated in v1.3. Please use ∀[m≤n⇒m≢o]⇒n<o instead." -#-} -∀[m<n⇒m≢o]⇒o≤n : n o (∀ {m} m < n m o) n o -∀[m<n⇒m≢o]⇒o≤n = ∀[m<n⇒m≢o]⇒n≤o -{-# WARNING_ON_USAGE ∀[m<n⇒m≢o]⇒o≤n -"Warning: ∀[m<n⇒m≢o]⇒o≤n was deprecated in v1.3. +#-} +∀[m<n⇒m≢o]⇒o≤n : n o (∀ {m} m < n m o) n o +∀[m<n⇒m≢o]⇒o≤n = ∀[m<n⇒m≢o]⇒n≤o +{-# WARNING_ON_USAGE ∀[m<n⇒m≢o]⇒o≤n +"Warning: ∀[m<n⇒m≢o]⇒o≤n was deprecated in v1.3. Please use ∀[m<n⇒m≢o]⇒n≤o instead." -#-} +#-} --- Version 1.4 +-- Version 1.4 -*-+-isSemiring = +-*-isSemiring -{-# WARNING_ON_USAGE *-+-isSemiring -"Warning: *-+-isSemiring was deprecated in v1.4. +*-+-isSemiring = +-*-isSemiring +{-# WARNING_ON_USAGE *-+-isSemiring +"Warning: *-+-isSemiring was deprecated in v1.4. Please use +-*-isSemiring instead." -#-} -*-+-isCommutativeSemiring = +-*-isCommutativeSemiring -{-# WARNING_ON_USAGE *-+-isCommutativeSemiring -"Warning: *-+-isCommutativeSemiring was deprecated in v1.4. +#-} +*-+-isCommutativeSemiring = +-*-isCommutativeSemiring +{-# WARNING_ON_USAGE *-+-isCommutativeSemiring +"Warning: *-+-isCommutativeSemiring was deprecated in v1.4. Please use +-*-isCommutativeSemiring instead." -#-} -*-+-semiring = +-*-semiring -{-# WARNING_ON_USAGE *-+-semiring -"Warning: *-+-semiring was deprecated in v1.4. +#-} +*-+-semiring = +-*-semiring +{-# WARNING_ON_USAGE *-+-semiring +"Warning: *-+-semiring was deprecated in v1.4. Please use +-*-semiring instead." -#-} -*-+-commutativeSemiring = +-*-commutativeSemiring -{-# WARNING_ON_USAGE *-+-commutativeSemiring -"Warning: *-+-commutativeSemiring was deprecated in v1.4. +#-} +*-+-commutativeSemiring = +-*-commutativeSemiring +{-# WARNING_ON_USAGE *-+-commutativeSemiring +"Warning: *-+-commutativeSemiring was deprecated in v1.4. Please use +-*-commutativeSemiring instead." -#-} +#-} --- Version 1.6 +-- Version 1.6 -∣m+n-m+o∣≡∣n-o| = ∣m+n-m+o∣≡∣n-o∣ -{-# WARNING_ON_USAGE ∣m+n-m+o∣≡∣n-o| -"Warning: ∣m+n-m+o∣≡∣n-o| was deprecated in v1.6. +∣m+n-m+o∣≡∣n-o| = ∣m+n-m+o∣≡∣n-o∣ +{-# WARNING_ON_USAGE ∣m+n-m+o∣≡∣n-o| +"Warning: ∣m+n-m+o∣≡∣n-o| was deprecated in v1.6. Please use ∣m+n-m+o∣≡∣n-o∣ instead. Note the final is a \\| rather than a |" -#-} -m≤n⇒n⊔m≡n = m≥n⇒m⊔n≡m -{-# WARNING_ON_USAGE m≤n⇒n⊔m≡n -"Warning: m≤n⇒n⊔m≡n was deprecated in v1.6. Please use m≥n⇒m⊔n≡m instead." -#-} -m≤n⇒n⊓m≡m = m≥n⇒m⊓n≡n -{-# WARNING_ON_USAGE m≤n⇒n⊓m≡m -"Warning: m≤n⇒n⊓m≡m was deprecated in v1.6. Please use m≥n⇒m⊓n≡n instead." -#-} -n⊔m≡m⇒n≤m = m⊔n≡n⇒m≤n -{-# WARNING_ON_USAGE n⊔m≡m⇒n≤m -"Warning: n⊔m≡m⇒n≤m was deprecated in v1.6. Please use m⊔n≡n⇒m≤n instead." -#-} -n⊔m≡n⇒m≤n = m⊔n≡m⇒n≤m -{-# WARNING_ON_USAGE n⊔m≡n⇒m≤n -"Warning: n⊔m≡n⇒m≤n was deprecated in v1.6. Please use m⊔n≡m⇒n≤m instead." -#-} -n≤m⊔n = m≤n⊔m -{-# WARNING_ON_USAGE n≤m⊔n -"Warning: n≤m⊔n was deprecated in v1.6. Please use m≤n⊔m instead." -#-} -⊔-least = ⊔-lub -{-# WARNING_ON_USAGE ⊔-least -"Warning: ⊔-least was deprecated in v1.6. Please use ⊔-lub instead." -#-} -⊓-greatest = ⊓-glb -{-# WARNING_ON_USAGE ⊓-greatest -"Warning: ⊓-greatest was deprecated in v1.6. Please use ⊓-glb instead." -#-} -⊔-pres-≤m = ⊔-lub -{-# WARNING_ON_USAGE ⊔-pres-≤m -"Warning: ⊔-pres-≤m was deprecated in v1.6. Please use ⊔-lub instead." -#-} -⊓-pres-m≤ = ⊓-glb -{-# WARNING_ON_USAGE ⊓-pres-m≤ -"Warning: ⊓-pres-m≤ was deprecated in v1.6. Please use ⊓-glb instead." -#-} -⊔-abs-⊓ = ⊔-absorbs-⊓ -{-# WARNING_ON_USAGE ⊔-abs-⊓ -"Warning: ⊔-abs-⊓ was deprecated in v1.6. Please use ⊔-absorbs-⊓ instead." -#-} -⊓-abs-⊔ = ⊓-absorbs-⊔ -{-# WARNING_ON_USAGE ⊓-abs-⊔ -"Warning: ⊓-abs-⊔ was deprecated in v1.6. Please use ⊓-absorbs-⊔ instead." -#-} - --- Version 2.0 - -suc[pred[n]]≡n : n 0 suc (pred n) n -suc[pred[n]]≡n {zero} 0≢0 = contradiction refl 0≢0 -suc[pred[n]]≡n {suc n} _ = refl -{-# WARNING_ON_USAGE suc[pred[n]]≡n -"Warning: suc[pred[n]]≡n was deprecated in v2.0. Please use suc-pred instead. Note that the proof now uses instance arguments" -#-} - -≤-step = m≤n⇒m≤1+n -{-# WARNING_ON_USAGE ≤-step -"Warning: ≤-step was deprecated in v2.0. Please use m≤n⇒m≤1+n instead. " -#-} - -≤-stepsˡ = m≤n⇒m≤o+n -{-# WARNING_ON_USAGE ≤-stepsˡ -"Warning: ≤-stepsˡ was deprecated in v2.0. Please use m≤n⇒m≤o+n instead. " -#-} - -≤-stepsʳ = m≤n⇒m≤n+o -{-# WARNING_ON_USAGE ≤-stepsʳ -"Warning: ≤-stepsʳ was deprecated in v2.0. Please use m≤n⇒m≤n+o instead. " -#-} - -<-step = m<n⇒m<1+n -{-# WARNING_ON_USAGE <-step -"Warning: <-step was deprecated in v2.0. Please use m<n⇒m<1+n instead. " -#-} - -pred-mono = pred-mono-≤ -{-# WARNING_ON_USAGE pred-mono -"Warning: pred-mono was deprecated in v2.0. Please use pred-mono-≤ instead. " -#-} - -{- issue1844/issue1755: raw bundles have moved to `Data.X.Base` -} -open Data.Nat.Base public - using (*-rawMagma; *-1-rawMonoid) - -<-transʳ = ≤-<-trans -{-# WARNING_ON_USAGE <-transʳ -"Warning: <-transʳ was deprecated in v2.0. Please use ≤-<-trans instead. " -#-} - -<-transˡ = <-≤-trans -{-# WARNING_ON_USAGE <-transˡ -"Warning: <-transˡ was deprecated in v2.0. Please use <-≤-trans instead. " -#-} +#-} +m≤n⇒n⊔m≡n = m≥n⇒m⊔n≡m +{-# WARNING_ON_USAGE m≤n⇒n⊔m≡n +"Warning: m≤n⇒n⊔m≡n was deprecated in v1.6. Please use m≥n⇒m⊔n≡m instead." +#-} +m≤n⇒n⊓m≡m = m≥n⇒m⊓n≡n +{-# WARNING_ON_USAGE m≤n⇒n⊓m≡m +"Warning: m≤n⇒n⊓m≡m was deprecated in v1.6. Please use m≥n⇒m⊓n≡n instead." +#-} +n⊔m≡m⇒n≤m = m⊔n≡n⇒m≤n +{-# WARNING_ON_USAGE n⊔m≡m⇒n≤m +"Warning: n⊔m≡m⇒n≤m was deprecated in v1.6. Please use m⊔n≡n⇒m≤n instead." +#-} +n⊔m≡n⇒m≤n = m⊔n≡m⇒n≤m +{-# WARNING_ON_USAGE n⊔m≡n⇒m≤n +"Warning: n⊔m≡n⇒m≤n was deprecated in v1.6. Please use m⊔n≡m⇒n≤m instead." +#-} +n≤m⊔n = m≤n⊔m +{-# WARNING_ON_USAGE n≤m⊔n +"Warning: n≤m⊔n was deprecated in v1.6. Please use m≤n⊔m instead." +#-} +⊔-least = ⊔-lub +{-# WARNING_ON_USAGE ⊔-least +"Warning: ⊔-least was deprecated in v1.6. Please use ⊔-lub instead." +#-} +⊓-greatest = ⊓-glb +{-# WARNING_ON_USAGE ⊓-greatest +"Warning: ⊓-greatest was deprecated in v1.6. Please use ⊓-glb instead." +#-} +⊔-pres-≤m = ⊔-lub +{-# WARNING_ON_USAGE ⊔-pres-≤m +"Warning: ⊔-pres-≤m was deprecated in v1.6. Please use ⊔-lub instead." +#-} +⊓-pres-m≤ = ⊓-glb +{-# WARNING_ON_USAGE ⊓-pres-m≤ +"Warning: ⊓-pres-m≤ was deprecated in v1.6. Please use ⊓-glb instead." +#-} +⊔-abs-⊓ = ⊔-absorbs-⊓ +{-# WARNING_ON_USAGE ⊔-abs-⊓ +"Warning: ⊔-abs-⊓ was deprecated in v1.6. Please use ⊔-absorbs-⊓ instead." +#-} +⊓-abs-⊔ = ⊓-absorbs-⊔ +{-# WARNING_ON_USAGE ⊓-abs-⊔ +"Warning: ⊓-abs-⊔ was deprecated in v1.6. Please use ⊓-absorbs-⊔ instead." +#-} + +-- Version 2.0 + +suc[pred[n]]≡n : n 0 suc (pred n) n +suc[pred[n]]≡n {zero} 0≢0 = contradiction refl 0≢0 +suc[pred[n]]≡n {suc n} _ = refl +{-# WARNING_ON_USAGE suc[pred[n]]≡n +"Warning: suc[pred[n]]≡n was deprecated in v2.0. Please use suc-pred instead. Note that the proof now uses instance arguments" +#-} + +≤-step = m≤n⇒m≤1+n +{-# WARNING_ON_USAGE ≤-step +"Warning: ≤-step was deprecated in v2.0. Please use m≤n⇒m≤1+n instead. " +#-} + +≤-stepsˡ = m≤n⇒m≤o+n +{-# WARNING_ON_USAGE ≤-stepsˡ +"Warning: ≤-stepsˡ was deprecated in v2.0. Please use m≤n⇒m≤o+n instead. " +#-} + +≤-stepsʳ = m≤n⇒m≤n+o +{-# WARNING_ON_USAGE ≤-stepsʳ +"Warning: ≤-stepsʳ was deprecated in v2.0. Please use m≤n⇒m≤n+o instead. " +#-} + +<-step = m<n⇒m<1+n +{-# WARNING_ON_USAGE <-step +"Warning: <-step was deprecated in v2.0. Please use m<n⇒m<1+n instead. " +#-} + +pred-mono = pred-mono-≤ +{-# WARNING_ON_USAGE pred-mono +"Warning: pred-mono was deprecated in v2.0. Please use pred-mono-≤ instead. " +#-} + +{- issue1844/issue1755: raw bundles have moved to `Data.X.Base` -} +open Data.Nat.Base public + using (*-rawMagma; *-1-rawMonoid) + +<-transʳ = ≤-<-trans +{-# WARNING_ON_USAGE <-transʳ +"Warning: <-transʳ was deprecated in v2.0. Please use ≤-<-trans instead. " +#-} + +<-transˡ = <-≤-trans +{-# WARNING_ON_USAGE <-transˡ +"Warning: <-transˡ was deprecated in v2.0. Please use <-≤-trans instead. " +#-} \ No newline at end of file diff --git a/v2.3/Data.Nat.Show.Properties.html b/v2.3/Data.Nat.Show.Properties.html index fd0f7f07b1..698db583e4 100644 --- a/v2.3/Data.Nat.Show.Properties.html +++ b/v2.3/Data.Nat.Show.Properties.html @@ -10,7 +10,7 @@ open import Data.Digit.Properties using (toDigits-injective; showDigit-injective) import Data.List.Properties as Listₚ open import Data.Nat.Base using () -open import Data.Nat.Properties using (_≤?_) +open import Data.Nat.Properties using (_≤?_) open import Data.Nat.Show using (charsInBase) open import Function.Base using (_∘_) open import Relation.Nullary.Decidable.Core using (True) @@ -18,7 +18,7 @@ module Data.Nat.Show.Properties where -module _ (base : ) {base≥2 : True (2 ≤? base)} {base≤16 : True (base ≤? 16)} where +module _ (base : ) {base≥2 : True (2 ≤? base)} {base≤16 : True (base ≤? 16)} where private charsInBase-base = charsInBase base {base≥2} {base≤16} diff --git a/v2.3/Data.Nat.Show.html b/v2.3/Data.Nat.Show.html index 489fc63fd3..a26db357d6 100644 --- a/v2.3/Data.Nat.Show.html +++ b/v2.3/Data.Nat.Show.html @@ -16,7 +16,7 @@ open import Data.List.Effectful using (module TraversableA) open import Data.Maybe.Base as Maybe using (Maybe; nothing; _<∣>_; when) import Data.Maybe.Effectful as Maybe using (applicative) -open import Data.Nat using (; _≤?_; _<ᵇ_; _≤ᵇ_; _∸_; _*_; _+_) +open import Data.Nat using (; _≤?_; _<ᵇ_; _≤ᵇ_; _∸_; _*_; _+_) open import Data.Product.Base using (proj₁) open import Data.String.Base using (toList; fromList; String) open import Function.Base using (_∘′_; _∘_) @@ -25,7 +25,7 @@ ------------------------------------------------------------------------ -- Read -readMaybe : base {base≤16 : True (base ≤? 16)} String Maybe +readMaybe : base {base≤16 : True (base ≤? 16)} String Maybe readMaybe _ "" = nothing readMaybe base = Maybe.map convert ∘′ TraversableA.mapA Maybe.applicative readDigit @@ -70,8 +70,8 @@ -- O(n) instead of the expected O(log(n)). charsInBase : (base : ) - {base≥2 : True (2 ≤? base)} - {base≤16 : True (base ≤? 16)} + {base≥2 : True (2 ≤? base)} + {base≤16 : True (base ≤? 16)} List Char charsInBase base {base≥2} {base≤16} = List.map (showDigit {base≤16 = base≤16}) List.reverse @@ -79,8 +79,8 @@ toDigits base {base≥2 = base≥2} showInBase : (base : ) - {base≥2 : True (2 ≤? base)} - {base≤16 : True (base ≤? 16)} + {base≥2 : True (2 ≤? base)} + {base≤16 : True (base ≤? 16)} String showInBase base {base≥2} {base≤16} = fromList charsInBase base {base≥2} {base≤16} diff --git a/v2.3/Data.Nat.Solver.html b/v2.3/Data.Nat.Solver.html index a040fc2f08..3225c81f48 100644 --- a/v2.3/Data.Nat.Solver.html +++ b/v2.3/Data.Nat.Solver.html @@ -20,5 +20,5 @@ -- containing _+_ and _*_ module +-*-Solver = - Solver (ACR.fromCommutativeSemiring +-*-commutativeSemiring) _≟_ + Solver (ACR.fromCommutativeSemiring +-*-commutativeSemiring) _≟_ \ No newline at end of file diff --git a/v2.3/Data.Nat.Tactic.RingSolver.html b/v2.3/Data.Nat.Tactic.RingSolver.html index 19fbce2ea7..afc4ce0d25 100644 --- a/v2.3/Data.Nat.Tactic.RingSolver.html +++ b/v2.3/Data.Nat.Tactic.RingSolver.html @@ -15,7 +15,7 @@ open import Data.Maybe.Base using (just; nothing) open import Data.Nat.Base using (zero) -open import Data.Nat.Properties using (+-*-commutativeSemiring) +open import Data.Nat.Properties using (+-*-commutativeSemiring) open import Level using (0ℓ) open import Data.Unit.Base using () open import Relation.Binary.PropositionalEquality.Core using (refl) @@ -28,7 +28,7 @@ -- containing _+_ and _*_ ring : ACR.AlmostCommutativeRing 0ℓ 0ℓ -ring = ACR.fromCommutativeSemiring +-*-commutativeSemiring +ring = ACR.fromCommutativeSemiring +-*-commutativeSemiring λ { zero just refl; _ nothing } macro diff --git a/v2.3/Data.Nat.html b/v2.3/Data.Nat.html index 247e0563ed..1c5b213e4c 100644 --- a/v2.3/Data.Nat.html +++ b/v2.3/Data.Nat.html @@ -25,17 +25,17 @@ -- key values ( nonZero? -- equalities - ; _≟_ ; eq? + ; _≟_ ; eq? -- standard orders & their relationship - ; _≤?_ ; _≥?_ ; _<?_ ; _>?_ - ; ≤-<-connex ; ≥->-connex ; <-≤-connex ; >-≥-connex - ; <-cmp + ; _≤?_ ; _≥?_ ; _<?_ ; _>?_ + ; ≤-<-connex ; ≥->-connex ; <-≤-connex ; >-≥-connex + ; <-cmp -- alternative definitions of the orders - ; _≤′?_; _≥′?_; _<′?_; _>′?_ - ; _≤″?_; _<″?_; _≥″?_; _>″?_ - ; _<‴?_; _≤‴?_; _≥‴?_; _>‴?_ + ; _≤′?_; _≥′?_; _<′?_; _>′?_ + ; _≤″?_; _<″?_; _≥″?_; _>″?_ + ; _<‴?_; _≤‴?_; _≥‴?_; _>‴?_ -- bounded predicates - ; anyUpTo? ; allUpTo? + ; anyUpTo? ; allUpTo? ) ------------------------------------------------------------------------ @@ -47,5 +47,5 @@ -- solely for the re-export of this name, formerly in `Data.Nat.Properties.Core` open import Data.Nat.Properties public - using (≤-pred) + using (≤-pred) \ No newline at end of file diff --git a/v2.3/Data.Parity.Properties.html b/v2.3/Data.Parity.Properties.html index 92c01b7309..1ad3992af9 100644 --- a/v2.3/Data.Parity.Properties.html +++ b/v2.3/Data.Parity.Properties.html @@ -28,7 +28,7 @@ open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning; setoid; isEquivalence; decSetoid; isDecEquivalence) open import Relation.Nullary.Decidable.Core using (yes; no) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Algebra.Structures {A = Parity} _≡_ open import Algebra.Definitions {A = Parity} _≡_ @@ -134,8 +134,8 @@ +-cancelʳ-≡ : RightCancellative ℙ._+_ +-cancelʳ-≡ _ 1ℙ 1ℙ _ = refl -+-cancelʳ-≡ _ 1ℙ 0ℙ eq = contradiction (sym eq) (p≢p⁻¹ _) -+-cancelʳ-≡ _ 0ℙ 1ℙ eq = contradiction eq (p≢p⁻¹ _) ++-cancelʳ-≡ _ 1ℙ 0ℙ eq = contradiction (sym eq) (p≢p⁻¹ _) ++-cancelʳ-≡ _ 0ℙ 1ℙ eq = contradiction eq (p≢p⁻¹ _) +-cancelʳ-≡ _ 0ℙ 0ℙ _ = refl +-cancelˡ-≡ : LeftCancellative ℙ._+_ @@ -341,16 +341,16 @@ { isCommutativeMonoid = *-1-isCommutativeMonoid } -+-*-isSemiring : IsSemiring ℙ._+_ ℙ._*_ 0ℙ 1ℙ ++-*-isSemiring : IsSemiring ℙ._+_ ℙ._*_ 0ℙ 1ℙ +-*-isSemiring = record - { isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = +-0-isCommutativeMonoid - ; *-cong = cong₂ ℙ._*_ - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = *-distrib-+ + { isSemiringWithoutAnnihilatingZero = record + { +-isCommutativeMonoid = +-0-isCommutativeMonoid + ; *-cong = cong₂ ℙ._*_ + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = *-distrib-+ } - ; zero = *-zero + ; zero = *-zero } +-*-semiring : Semiring 0ℓ 0ℓ @@ -358,10 +358,10 @@ { isSemiring = +-*-isSemiring } -+-*-isCommutativeSemiring : IsCommutativeSemiring ℙ._+_ ℙ._*_ 0ℙ 1ℙ ++-*-isCommutativeSemiring : IsCommutativeSemiring ℙ._+_ ℙ._*_ 0ℙ 1ℙ +-*-isCommutativeSemiring = record - { isSemiring = +-*-isSemiring - ; *-comm = *-comm + { isSemiring = +-*-isSemiring + ; *-comm = *-comm } +-*-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ @@ -369,13 +369,13 @@ { isCommutativeSemiring = +-*-isCommutativeSemiring } -+-*-isRing : IsRing ℙ._+_ ℙ._*_ id 0ℙ 1ℙ ++-*-isRing : IsRing ℙ._+_ ℙ._*_ id 0ℙ 1ℙ +-*-isRing = record - { +-isAbelianGroup = +-0-isAbelianGroup - ; *-cong = cong₂ ℙ._*_ - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = *-distrib-+ + { +-isAbelianGroup = +-0-isAbelianGroup + ; *-cong = cong₂ ℙ._*_ + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = *-distrib-+ } +-*-ring : Ring 0ℓ 0ℓ @@ -383,10 +383,10 @@ { isRing = +-*-isRing } -+-*-isCommutativeRing : IsCommutativeRing ℙ._+_ ℙ._*_ id 0ℙ 1ℙ ++-*-isCommutativeRing : IsCommutativeRing ℙ._+_ ℙ._*_ id 0ℙ 1ℙ +-*-isCommutativeRing = record - { isRing = +-*-isRing - ; *-comm = *-comm + { isRing = +-*-isRing + ; *-comm = *-comm } +-*-commutativeRing : CommutativeRing 0ℓ 0ℓ diff --git a/v2.3/Data.Product.Algebra.html b/v2.3/Data.Product.Algebra.html index d40a9a9e93..32051b5e8c 100644 --- a/v2.3/Data.Product.Algebra.html +++ b/v2.3/Data.Product.Algebra.html @@ -14,7 +14,7 @@ open import Algebra.Definitions open import Algebra.Structures using (IsMagma; IsSemigroup; IsMonoid; IsCommutativeMonoid - ; IsSemiringWithoutAnnihilatingZero; IsSemiring; IsCommutativeSemiring) + ; IsSemiringWithoutAnnihilatingZero; IsSemiring; IsCommutativeSemiring) open import Data.Bool.Base using (true; false) open import Data.Empty.Polymorphic using (; ⊥-elim) open import Data.Product.Base @@ -136,25 +136,25 @@ ; comm = ×-comm } - ⊎-×-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _↔_ _⊎_ _×_ + ⊎-×-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _↔_ _⊎_ _×_ ⊎-×-isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = ⊎-isCommutativeMonoid - ; *-cong = ×-cong - ; *-assoc = ×-assoc - ; *-identity = ×-identity - ; distrib = ×-distrib-⊎ + { +-isCommutativeMonoid = ⊎-isCommutativeMonoid + ; *-cong = ×-cong + ; *-assoc = ×-assoc + ; *-identity = ×-identity + ; distrib = ×-distrib-⊎ } - ⊎-×-isSemiring : IsSemiring _↔_ _⊎_ _×_ + ⊎-×-isSemiring : IsSemiring _↔_ _⊎_ _×_ ⊎-×-isSemiring = record - { isSemiringWithoutAnnihilatingZero = ⊎-×-isSemiringWithoutAnnihilatingZero - ; zero = ×-zero + { isSemiringWithoutAnnihilatingZero = ⊎-×-isSemiringWithoutAnnihilatingZero + ; zero = ×-zero } - ⊎-×-isCommutativeSemiring : IsCommutativeSemiring _↔_ _⊎_ _×_ + ⊎-×-isCommutativeSemiring : IsCommutativeSemiring _↔_ _⊎_ _×_ ⊎-×-isCommutativeSemiring = record - { isSemiring = ⊎-×-isSemiring - ; *-comm = ×-comm + { isSemiring = ⊎-×-isSemiring + ; *-comm = ×-comm } ------------------------------------------------------------------------ -- Algebraic bundles diff --git a/v2.3/Data.Product.Relation.Binary.Lex.Strict.html b/v2.3/Data.Product.Relation.Binary.Lex.Strict.html index f7a2ae011e..abf9600640 100644 --- a/v2.3/Data.Product.Relation.Binary.Lex.Strict.html +++ b/v2.3/Data.Product.Relation.Binary.Lex.Strict.html @@ -31,7 +31,7 @@ open import Relation.Binary.Consequences using (asym⇒irr) open import Relation.Binary.PropositionalEquality.Core as using (_≡_) open import Relation.Nullary.Decidable.Core using (yes; no; _⊎-dec_; _×-dec_) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) private variable @@ -135,11 +135,11 @@ where antisym : Antisymmetric _≋_ _<ₗₑₓ_ antisym (inj₁ x₁<y₁) (inj₁ y₁<x₁) = - contradiction y₁<x₁ (asym₁ x₁<y₁) + contradiction y₁<x₁ (asym₁ x₁<y₁) antisym (inj₁ x₁<y₁) (inj₂ y≈≤x) = - contradiction x₁<y₁ (irrefl₁ (sym₁ $ proj₁ y≈≤x)) + contradiction x₁<y₁ (irrefl₁ (sym₁ $ proj₁ y≈≤x)) antisym (inj₂ x≈≤y) (inj₁ y₁<x₁) = - contradiction y₁<x₁ (irrefl₁ (sym₁ $ proj₁ x≈≤y)) + contradiction y₁<x₁ (irrefl₁ (sym₁ $ proj₁ x≈≤y)) antisym (inj₂ x≈≤y) (inj₂ y≈≤x) = proj₁ x≈≤y , antisym₂ (proj₂ x≈≤y) (proj₂ y≈≤x) diff --git a/v2.3/Data.Rational.Base.html b/v2.3/Data.Rational.Base.html index e1a77834f0..23e3329578 100644 --- a/v2.3/Data.Rational.Base.html +++ b/v2.3/Data.Rational.Base.html @@ -24,7 +24,7 @@ open import Function.Base using (id) open import Level using (0ℓ) open import Relation.Nullary.Decidable.Core using (recompute) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary using (Pred) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core @@ -193,9 +193,9 @@ ≢-nonZero : {p} p 0ℚ NonZero p ≢-nonZero {mkℚ -[1+ _ ] _ _} _ = _ ≢-nonZero {mkℚ +[1+ _ ] _ _} _ = _ -≢-nonZero {mkℚ +0 zero _} p≢0 = contradiction refl p≢0 +≢-nonZero {mkℚ +0 zero _} p≢0 = contradiction refl p≢0 ≢-nonZero {mkℚ +0 d@(suc m) c} p≢0 = - contradiction {d} ℕ.recompute c {d}) (¬0-coprimeTo-2+ {{ℕ.nonTrivial {m}}}) + contradiction {d} ℕ.recompute c {d}) (¬0-coprimeTo-2+ {{ℕ.nonTrivial {m}}}) >-nonZero : {p} p > 0ℚ NonZero p >-nonZero {p@(mkℚ _ _ _)} (*<* p<q) = ℚᵘ.>-nonZero {toℚᵘ p} (ℚᵘ.*<* p<q) diff --git a/v2.3/Data.Rational.Properties.html b/v2.3/Data.Rational.Properties.html index b1267273e5..9ff82d8478 100644 --- a/v2.3/Data.Rational.Properties.html +++ b/v2.3/Data.Rational.Properties.html @@ -67,7 +67,7 @@ open import Relation.Binary.Reasoning.Syntax using (module ≃-syntax) open import Relation.Nullary.Decidable.Core as Dec using (yes; no; recompute; map′; _×-dec_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Algebra.Definitions {A = } _≡_ open import Algebra.Structures {A = } _≡_ @@ -329,7 +329,7 @@ (m ℕ.* d) ℕ./ (gcd[m,c] ℕ.* gcd[n,d]) ≡⟨ ℕ./-*-interchange gcd[m,c]∣m gcd[n,d]∣d (m ℕ./ gcd[m,c]) ℕ.* (d ℕ./ gcd[n,d]) ≡⟨ cong₂ ℕ._*_ m/gcd[m,c]≡n/gcd[n,d] (sym c/gcd[m,c]≡d/gcd[n,d]) (n ℕ./ gcd[n,d]) ℕ.* (c ℕ./ gcd[m,c]) ≡⟨ ℕ./-*-interchange gcd[n,d]∣n gcd[m,c]∣c - (n ℕ.* c) ℕ./ (gcd[n,d] ℕ.* gcd[m,c]) ≡⟨ ℕ./-congʳ (ℕ.*-comm gcd[n,d] gcd[m,c]) + (n ℕ.* c) ℕ./ (gcd[n,d] ℕ.* gcd[m,c]) ≡⟨ ℕ./-congʳ (ℕ.*-comm gcd[n,d] gcd[m,c]) (n ℕ.* c) ℕ./ (gcd[m,c] ℕ.* gcd[n,d]) where open ≡-Reasoning @@ -341,7 +341,7 @@ gcd[n,d]∣d = ℕ.gcd[m,n]∣n n d md∣gcd[m,c]gcd[n,d] = *-pres-∣ gcd[m,c]∣m gcd[n,d]∣d nc∣gcd[n,d]gcd[m,c] = *-pres-∣ gcd[n,d]∣n gcd[m,c]∣c - nc∣gcd[m,c]gcd[n,d] = subst (_∣ n ℕ.* c) (ℕ.*-comm gcd[n,d] gcd[m,c]) nc∣gcd[n,d]gcd[m,c] + nc∣gcd[m,c]gcd[n,d] = subst (_∣ n ℕ.* c) (ℕ.*-comm gcd[n,d] gcd[m,c]) nc∣gcd[n,d]gcd[m,c] gcd[m,c]≢0′ = ℕ.gcd[m,n]≢0 m c (inj₂ (ℕ.≢-nonZero⁻¹ c)) gcd[n,d]≢0′ = ℕ.gcd[m,n]≢0 n d (inj₂ (ℕ.≢-nonZero⁻¹ d)) @@ -350,8 +350,8 @@ gcd[n,d]≢0 = ℕ.≢-nonZero gcd[n,d]≢0′ c/gcd[m,c]≢0 = ℕ.≢-nonZero (ℕ.n/gcd[m,n]≢0 m c {{gcd≢0 = gcd[m,c]≢0}}) d/gcd[n,d]≢0 = ℕ.≢-nonZero (ℕ.n/gcd[m,n]≢0 n d {{gcd≢0 = gcd[n,d]≢0}}) - gcd[m,c]*gcd[n,d]≢0 = ℕ.m*n≢0 gcd[m,c] gcd[n,d] - gcd[n,d]*gcd[m,c]≢0 = ℕ.m*n≢0 gcd[n,d] gcd[m,c] + gcd[m,c]*gcd[n,d]≢0 = ℕ.m*n≢0 gcd[m,c] gcd[n,d] + gcd[n,d]*gcd[m,c]≢0 = ℕ.m*n≢0 gcd[n,d] gcd[m,c] div = mkℚ+-injective eq m/gcd[m,c]≡n/gcd[n,d] = proj₁ div @@ -404,7 +404,7 @@ /-injective-≃-helper : {m n c d} .{{_ : ℕ.NonZero c}} .{{_ : ℕ.NonZero d}} - normalize (suc m) c normalize n d mkℚᵘ -[1+ m ] (ℕ.pred c) ≃ᵘ mkℚᵘ (+ n) (ℕ.pred d) - /-injective-≃-helper {m} {n} {c} {d} -norm≡norm = contradiction + /-injective-≃-helper {m} {n} {c} {d} -norm≡norm = contradiction (sym -norm≡norm) (nonNeg≢neg (normalize n d) (- normalize (suc m) c)) where instance @@ -864,7 +864,7 @@ ... | no nf[p,q]≢0 = *≡* (ℤ.*-cancelʳ-≡ _ _ (+-nf p q) {{ℤ.≢-nonZero nf[p,q]≢0}} $ begin (↥ᵘ (toℚᵘ (p + q))) ℤ.* ↧+ᵘ p q ℤ.* +-nf p q ≡⟨ cong v v ℤ.* ↧+ᵘ p q ℤ.* +-nf p q) (↥ᵘ-toℚᵘ (p + q)) - (p + q) ℤ.* ↧+ᵘ p q ℤ.* +-nf p q ≡⟨ xy∙z≈xz∙y ( (p + q)) _ _ + (p + q) ℤ.* ↧+ᵘ p q ℤ.* +-nf p q ≡⟨ xy∙z≈xz∙y ( (p + q)) _ _ (p + q) ℤ.* +-nf p q ℤ.* ↧+ᵘ p q ≡⟨ cong (ℤ._* ↧+ᵘ p q) (↥-+ p q) ↥+ᵘ p q ℤ.* ↧+ᵘ p q ≡⟨ cong (↥+ᵘ p q ℤ.*_) (sym (↧-+ p q)) ↥+ᵘ p q ℤ.* ( (p + q) ℤ.* +-nf p q) ≡⟨ x∙yz≈xy∙z (↥+ᵘ p q) _ _ @@ -1099,7 +1099,7 @@ eq rewrite eq2 = cong ↥_ (0/n≡0 (↧ₙ p ℕ.* ↧ₙ q)) ... | no nf[p,q]≢0 = *≡* (ℤ.*-cancelʳ-≡ _ _ (*-nf p q) {{ℤ.≢-nonZero nf[p,q]≢0}} $ begin ↥ᵘ (toℚᵘ (p * q)) ℤ.* ( p ℤ.* q) ℤ.* *-nf p q ≡⟨ cong v v ℤ.* ( p ℤ.* q) ℤ.* *-nf p q) (↥ᵘ-toℚᵘ (p * q)) - (p * q) ℤ.* ( p ℤ.* q) ℤ.* *-nf p q ≡⟨ xy∙z≈xz∙y ( (p * q)) _ _ + (p * q) ℤ.* ( p ℤ.* q) ℤ.* *-nf p q ≡⟨ xy∙z≈xz∙y ( (p * q)) _ _ (p * q) ℤ.* *-nf p q ℤ.* ( p ℤ.* q) ≡⟨ cong (ℤ._* ( p ℤ.* q)) (↥-* p q) ( p ℤ.* q) ℤ.* ( p ℤ.* q) ≡⟨ cong (( p ℤ.* q) ℤ.*_) (sym (↧-* p q)) ( p ℤ.* q) ℤ.* ( (p * q) ℤ.* *-nf p q) ≡⟨ x∙yz≈xy∙z ( p ℤ.* q) _ _ @@ -1236,10 +1236,10 @@ *-1-isCommutativeMonoid : IsCommutativeMonoid _*_ 1ℚ *-1-isCommutativeMonoid = +-*-Monomorphism.*-isCommutativeMonoid ℚᵘ.*-1-isCommutativeMonoid -+-*-isRing : IsRing _+_ _*_ -_ 0ℚ 1ℚ ++-*-isRing : IsRing _+_ _*_ -_ 0ℚ 1ℚ +-*-isRing = +-*-Monomorphism.isRing ℚᵘ.+-*-isRing -+-*-isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0ℚ 1ℚ ++-*-isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0ℚ 1ℚ +-*-isCommutativeRing = +-*-Monomorphism.isCommutativeRing ℚᵘ.+-*-isCommutativeRing ------------------------------------------------------------------------ @@ -1281,7 +1281,7 @@ module _ where open CommutativeRing +-*-commutativeRing - using (+-group; zeroˡ; *-congʳ; isCommutativeRing) + using (+-group; zeroˡ; *-congʳ; isCommutativeRing) open GroupProperties +-group open DecSetoidProperties ≡-decSetoid @@ -1291,14 +1291,14 @@ where instance _ = ≢-nonZero (p≢q (x∙y⁻¹≈ε⇒x≈y p q)) invertible⇒# : Invertible 1ℚ _*_ (p - q) p q - invertible⇒# {p} {q} (1/[p-q] , _ , [p-q]/[p-q]≡1) p≡q = contradiction 1≡0 1≢0 + invertible⇒# {p} {q} (1/[p-q] , _ , [p-q]/[p-q]≡1) p≡q = contradiction 1≡0 1≢0 where open ≈-Reasoning ≡-setoid 1≡0 : 1ℚ 0ℚ 1≡0 = begin 1ℚ ≈⟨ [p-q]/[p-q]≡1 - (p - q) * 1/[p-q] ≈⟨ *-congʳ (x≈y⇒x∙y⁻¹≈ε p≡q) - 0ℚ * 1/[p-q] ≈⟨ zeroˡ 1/[p-q] + (p - q) * 1/[p-q] ≈⟨ *-congʳ (x≈y⇒x∙y⁻¹≈ε p≡q) + 0ℚ * 1/[p-q] ≈⟨ zeroˡ 1/[p-q] 0ℚ isHeytingCommutativeRing : IsHeytingCommutativeRing _≡_ _≢_ _+_ _*_ -_ 0ℚ 1ℚ @@ -1479,7 +1479,7 @@ p≤q⇒p⊔q≡q : p q p q q p≤q⇒p⊔q≡q {p@record{}} {q@record{}} p≤q with p ≤ᵇ q in p≰q ... | true = refl -... | false = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) +... | false = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) p≥q⇒p⊔q≡p : p q p q p p≥q⇒p⊔q≡p {p@record{}} {q@record{}} p≥q with p ≤ᵇ q in p≤q @@ -1489,7 +1489,7 @@ p≤q⇒p⊓q≡p : p q p q p p≤q⇒p⊓q≡p {p@record{}} {q@record{}} p≤q with p ≤ᵇ q in p≰q ... | true = refl -... | false = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) +... | false = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) p≥q⇒p⊓q≡q : p q p q q p≥q⇒p⊓q≡q {p@record{}} {q@record{}} p≥q with p ≤ᵇ q in p≤q diff --git a/v2.3/Data.Rational.Unnormalised.Base.html b/v2.3/Data.Rational.Unnormalised.Base.html index 32a2629c78..495471c612 100644 --- a/v2.3/Data.Rational.Unnormalised.Base.html +++ b/v2.3/Data.Rational.Unnormalised.Base.html @@ -17,7 +17,7 @@ hiding (module ) open import Data.Nat.Base as using (; zero; suc) open import Level using (0ℓ) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Unary using (Pred) open import Relation.Binary.Core using (Rel) open import Relation.Binary.PropositionalEquality.Core @@ -166,8 +166,8 @@ ≢-nonZero : {p} p 0ℚᵘ NonZero p ≢-nonZero {mkℚᵘ -[1+ _ ] _ } _ = _ ≢-nonZero {mkℚᵘ +[1+ _ ] _ } _ = _ -≢-nonZero {mkℚᵘ +0 zero } p≢0 = contradiction (*≡* refl) p≢0 -≢-nonZero {mkℚᵘ +0 (suc d)} p≢0 = contradiction (*≡* refl) p≢0 +≢-nonZero {mkℚᵘ +0 zero } p≢0 = contradiction (*≡* refl) p≢0 +≢-nonZero {mkℚᵘ +0 (suc d)} p≢0 = contradiction (*≡* refl) p≢0 >-nonZero : {p} p > 0ℚᵘ NonZero p >-nonZero {mkℚᵘ +0 _} (*<* (+<+ ())) diff --git a/v2.3/Data.Rational.Unnormalised.Properties.html b/v2.3/Data.Rational.Unnormalised.Properties.html index 927e856939..de1d47c377 100644 --- a/v2.3/Data.Rational.Unnormalised.Properties.html +++ b/v2.3/Data.Rational.Unnormalised.Properties.html @@ -13,8 +13,8 @@ open import Algebra.Definitions open import Algebra.Structures using (IsMagma; IsSemigroup; IsBand; IsSelectiveMagma; IsMonoid - ; IsCommutativeMonoid; IsGroup; IsAbelianGroup; IsRing - ; IsCommutativeRing) + ; IsCommutativeMonoid; IsGroup; IsAbelianGroup; IsRing + ; IsCommutativeRing) open import Algebra.Bundles open import Algebra.Apartness using (IsHeytingCommutativeRing; IsHeytingField @@ -31,8 +31,8 @@ open import Data.Bool.Base using (T; true; false) open import Data.Nat.Base as using (suc; pred) import Data.Nat.Properties as - using (≤-refl; +-comm; +-identityʳ; +-assoc - ; *-identityʳ; *-comm; *-assoc; *-suc) + using (≤-refl; +-comm; +-identityʳ; +-assoc + ; *-identityʳ; *-comm; *-assoc; *-suc) open import Data.Integer.Base as using (; +0; +[1+_]; -[1+_]; 0ℤ; 1ℤ; -1ℤ) open import Data.Integer.Solver renaming (module +-*-Solver to ℤ-solver) import Data.Integer.Properties as @@ -43,7 +43,7 @@ open import Function.Base using (_on_; _$_; _∘_; flip) open import Level using (0ℓ) open import Relation.Nullary.Decidable.Core as Dec using (yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Binary.Core using (_⇒_; _Preserves_⟶_; _Preserves₂_⟶_⟶_) open import Relation.Binary.Bundles using (Setoid; DecSetoid; Preorder; TotalPreorder; Poset; TotalOrder @@ -109,11 +109,11 @@ ≃-trans : Transitive _≃_ ≃-trans {x} {y} {z} (*≡* ad≡cb) (*≡* cf≡ed) = *≡* (ℤ.*-cancelʳ-≡ ( x ℤ.* z) ( z ℤ.* x) ( y) (begin - x ℤ.* z ℤ.* y ≡⟨ xy∙z≈xz∙y ( x) _ _ + x ℤ.* z ℤ.* y ≡⟨ xy∙z≈xz∙y ( x) _ _ x ℤ.* y ℤ.* z ≡⟨ cong (ℤ._* z) ad≡cb - y ℤ.* x ℤ.* z ≡⟨ xy∙z≈xz∙y ( y) _ _ + y ℤ.* x ℤ.* z ≡⟨ xy∙z≈xz∙y ( y) _ _ y ℤ.* z ℤ.* x ≡⟨ cong (ℤ._* x) cf≡ed - z ℤ.* y ℤ.* x ≡⟨ xy∙z≈xz∙y ( z) _ _ + z ℤ.* y ℤ.* x ≡⟨ xy∙z≈xz∙y ( z) _ _ z ℤ.* x ℤ.* y )) where open ≡-Reasoning @@ -135,7 +135,7 @@ ≄-cotransitive {x} {y} x≄y z with x ≃? z | z ≃? y ... | no x≄z | _ = inj₁ x≄z ... | yes _ | no z≄y = inj₂ z≄y -... | yes x≃z | yes z≃y = contradiction (≃-trans x≃z z≃y) x≄y +... | yes x≃z | yes z≃y = contradiction (≃-trans x≃z z≃y) x≄y ≃-isEquivalence : IsEquivalence _≃_ ≃-isEquivalence = record @@ -725,7 +725,7 @@ where open ℤ-solver +-assoc-↧ : Associative (_≡_ on ↧ₙ_) _+_ -+-assoc-↧ p@record{} q@record{} r@record{} = ℕ.*-assoc (↧ₙ p) (↧ₙ q) (↧ₙ r) ++-assoc-↧ p@record{} q@record{} r@record{} = ℕ.*-assoc (↧ₙ p) (↧ₙ q) (↧ₙ r) +-assoc-≡ : Associative _≡_ _+_ +-assoc-≡ p q r = ↥↧≡⇒≡ (+-assoc-↥ p q r) (+-assoc-↧ p q r) @@ -739,7 +739,7 @@ +-comm-↥ p@record{} q@record{} = ℤ.+-comm ( p ℤ.* q) ( q ℤ.* p) +-comm-↧ : Commutative (_≡_ on ↧ₙ_) _+_ -+-comm-↧ p@record{} q@record{} = ℕ.*-comm (↧ₙ p) (↧ₙ q) ++-comm-↧ p@record{} q@record{} = ℕ.*-comm (↧ₙ p) (↧ₙ q) +-comm-≡ : Commutative _≡_ _+_ +-comm-≡ p q = ↥↧≡⇒≡ (+-comm-↥ p q) (+-comm-↧ p q) @@ -756,7 +756,7 @@ p where open ≡-Reasoning +-identityˡ-↧ : LeftIdentity (_≡_ on ↧ₙ_) 0ℚᵘ _+_ -+-identityˡ-↧ p@record{} = ℕ.+-identityʳ (↧ₙ p) ++-identityˡ-↧ p@record{} = ℕ.+-identityʳ (↧ₙ p) +-identityˡ-≡ : LeftIdentity _≡_ 0ℚᵘ _+_ +-identityˡ-≡ p = ↥↧≡⇒≡ (+-identityˡ-↥ p) (+-identityˡ-↧ p) @@ -1096,7 +1096,7 @@ *-assoc-↥ p@record{} q@record{} r@record{} = ℤ.*-assoc ( p) ( q) ( r) *-assoc-↧ : Associative (_≡_ on ↧ₙ_) _*_ -*-assoc-↧ p@record{} q@record{} r@record{} = ℕ.*-assoc (↧ₙ p) (↧ₙ q) (↧ₙ r) +*-assoc-↧ p@record{} q@record{} r@record{} = ℕ.*-assoc (↧ₙ p) (↧ₙ q) (↧ₙ r) *-assoc-≡ : Associative _≡_ _*_ *-assoc-≡ p q r = ↥↧≡⇒≡ (*-assoc-↥ p q r) (*-assoc-↧ p q r) @@ -1110,7 +1110,7 @@ *-comm-↥ p@record{} q@record{} = ℤ.*-comm ( p) ( q) *-comm-↧ : Commutative (_≡_ on ↧ₙ_) _*_ -*-comm-↧ p@record{} q@record{} = ℕ.*-comm (↧ₙ p) (↧ₙ q) +*-comm-↧ p@record{} q@record{} = ℕ.*-comm (↧ₙ p) (↧ₙ q) *-comm-≡ : Commutative _≡_ _*_ *-comm-≡ p q = ↥↧≡⇒≡ (*-comm-↥ p q) (*-comm-↧ p q) @@ -1121,7 +1121,7 @@ -- Identities *-identityˡ-≡ : LeftIdentity _≡_ 1ℚᵘ _*_ -*-identityˡ-≡ p@record{} = ↥↧≡⇒≡ (ℤ.*-identityˡ ( p)) (ℕ.+-identityʳ (↧ₙ p)) +*-identityˡ-≡ p@record{} = ↥↧≡⇒≡ (ℤ.*-identityˡ ( p)) (ℕ.+-identityʳ (↧ₙ p)) *-identityʳ-≡ : RightIdentity _≡_ 1ℚᵘ _*_ *-identityʳ-≡ = comm∧idˡ⇒idʳ *-comm-≡ {e = 1ℚᵘ} *-identityˡ-≡ @@ -1141,13 +1141,13 @@ *-inverseˡ : p .{{_ : NonZero p}} (1/ p) * p 1ℚᵘ *-inverseˡ p@(mkℚᵘ -[1+ n ] d) = *-inverseˡ (mkℚᵘ +[1+ n ] d) *-inverseˡ p@(mkℚᵘ +[1+ n ] d) = *≡* $ cong +[1+_] $ begin - (n ℕ.+ d ℕ.* suc n) ℕ.* 1 ≡⟨ ℕ.*-identityʳ _ - n ℕ.+ d ℕ.* suc n ≡⟨ cong (n ℕ.+_) (ℕ.*-suc d n) - n ℕ.+ (d ℕ.+ d ℕ.* n) ≡⟨ trans (sym $ ℕ.+-assoc n d _) (trans - (cong₂ ℕ._+_ (ℕ.+-comm n d) (ℕ.*-comm d n)) - (ℕ.+-assoc d n _)) - d ℕ.+ (n ℕ.+ n ℕ.* d) ≡⟨ cong (d ℕ.+_) (sym (ℕ.*-suc n d)) - d ℕ.+ n ℕ.* suc d ≡⟨ ℕ.+-identityʳ _ + (n ℕ.+ d ℕ.* suc n) ℕ.* 1 ≡⟨ ℕ.*-identityʳ _ + n ℕ.+ d ℕ.* suc n ≡⟨ cong (n ℕ.+_) (ℕ.*-suc d n) + n ℕ.+ (d ℕ.+ d ℕ.* n) ≡⟨ trans (sym $ ℕ.+-assoc n d _) (trans + (cong₂ ℕ._+_ (ℕ.+-comm n d) (ℕ.*-comm d n)) + (ℕ.+-assoc d n _)) + d ℕ.+ (n ℕ.+ n ℕ.* d) ≡⟨ cong (d ℕ.+_) (sym (ℕ.*-suc n d)) + d ℕ.+ n ℕ.* suc d ≡⟨ ℕ.+-identityʳ _ d ℕ.+ n ℕ.* suc d ℕ.+ 0 where open ≡-Reasoning @@ -1215,7 +1215,7 @@ *-cancelˡ-/ p {q} {r} = *≡* (begin-equality ( ((ℤ.+ p ℤ.* q) / (p ℕ.* r))) ℤ.* ( (q / r)) ≡⟨ cong (ℤ._* (q / r)) (↥[n/d]≡n (ℤ.+ p ℤ.* q) (p ℕ.* r)) (ℤ.+ p ℤ.* q) ℤ.* ( (q / r)) ≡⟨ cong ((ℤ.+ p ℤ.* q) ℤ.*_) (↧[n/d]≡d q r) - (ℤ.+ p ℤ.* q) ℤ.* ℤ.+ r ≡⟨ xy∙z≈y∙xz (ℤ.+ p) q (ℤ.+ r) + (ℤ.+ p ℤ.* q) ℤ.* ℤ.+ r ≡⟨ xy∙z≈y∙xz (ℤ.+ p) q (ℤ.+ r) (q ℤ.* (ℤ.+ p ℤ.* ℤ.+ r)) ≡⟨ cong (ℤ._* (ℤ.+ p ℤ.* ℤ.+ r)) (↥[n/d]≡n q r) ( (q / r)) ℤ.* (ℤ.+ p ℤ.* ℤ.+ r) ≡⟨ cong ( (q / r) ℤ.*_) (ℤ.pos-* p r) ( (q / r)) ℤ.* (ℤ.+ (p ℕ.* r)) ≡⟨ cong ( (q / r) ℤ.*_) (↧[n/d]≡d (ℤ.+ p ℤ.* q) (p ℕ.* r)) @@ -1224,7 +1224,7 @@ *-cancelʳ-/ : p {q r} .{{_ : ℕ.NonZero r}} .{{_ : ℕ.NonZero (r ℕ.* p)}} ((q ℤ.* ℤ.+ p) / (r ℕ.* p)) (q / r) -*-cancelʳ-/ p {q} {r} rewrite ℕ.*-comm r p | ℤ.*-comm q (ℤ.+ p) = *-cancelˡ-/ p +*-cancelʳ-/ p {q} {r} rewrite ℕ.*-comm r p | ℤ.*-comm q (ℤ.+ p) = *-cancelˡ-/ p ------------------------------------------------------------------------ -- Properties of _*_ and _≤_ @@ -1401,19 +1401,19 @@ ; comm = *-comm } -+-*-isRing : IsRing _≃_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ ++-*-isRing : IsRing _≃_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ +-*-isRing = record - { +-isAbelianGroup = +-0-isAbelianGroup - ; *-cong = *-cong - ; *-assoc = *-assoc - ; *-identity = *-identity - ; distrib = *-distrib-+ + { +-isAbelianGroup = +-0-isAbelianGroup + ; *-cong = *-cong + ; *-assoc = *-assoc + ; *-identity = *-identity + ; distrib = *-distrib-+ } -+-*-isCommutativeRing : IsCommutativeRing _≃_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ ++-*-isCommutativeRing : IsCommutativeRing _≃_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ +-*-isCommutativeRing = record - { isRing = +-*-isRing - ; *-comm = *-comm + { isRing = +-*-isRing + ; *-comm = *-comm } +-*-isHeytingCommutativeRing : IsHeytingCommutativeRing _≃_ _≄_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ @@ -1479,7 +1479,7 @@ private p>1⇒p≢0 : p > 1ℚᵘ NonZero p - p>1⇒p≢0 {p} p>1 = pos⇒nonZero p {{positive (<-trans (*<* (ℤ.+<+ ℕ.≤-refl)) p>1)}} + p>1⇒p≢0 {p} p>1 = pos⇒nonZero p {{positive (<-trans (*<* (ℤ.+<+ ℕ.≤-refl)) p>1)}} 1/nonZero⇒nonZero : p .{{_ : NonZero p}} NonZero (1/ p) 1/nonZero⇒nonZero (mkℚᵘ (+[1+ _ ]) _) = _ @@ -1545,7 +1545,7 @@ p≤q⇒p⊔q≃q : p q p q q p≤q⇒p⊔q≃q {p@record{}} {q@record{}} p≤q with p ≤ᵇ q | inspect (p ≤ᵇ_) q ... | true | _ = ≃-refl -... | false | [ p≰q ] = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) +... | false | [ p≰q ] = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) p≥q⇒p⊔q≃p : p q p q p p≥q⇒p⊔q≃p {p@record{}} {q@record{}} p≥q with p ≤ᵇ q | inspect (p ≤ᵇ_) q @@ -1555,7 +1555,7 @@ p≤q⇒p⊓q≃p : p q p q p p≤q⇒p⊓q≃p {p@record{}} {q@record{}} p≤q with p ≤ᵇ q | inspect (p ≤ᵇ_) q ... | true | _ = ≃-refl -... | false | [ p≰q ] = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) +... | false | [ p≰q ] = contradiction (≤⇒≤ᵇ p≤q) (subst (¬_ T) (sym p≰q) λ()) p≥q⇒p⊓q≃q : p q p q q p≥q⇒p⊓q≃q {p@record{}} {q@record{}} p≥q with p ≤ᵇ q | inspect (p ≤ᵇ_) q @@ -1819,7 +1819,7 @@ 0≤p⇒∣p∣≡p : 0ℚᵘ p p p 0≤p⇒∣p∣≡p {mkℚᵘ (ℤ.+ n) d-1} 0≤p = refl -0≤p⇒∣p∣≡p {mkℚᵘ -[1+ n ] d-1} 0≤p = contradiction 0≤p (<⇒≱ (*<* ℤ.-<+)) +0≤p⇒∣p∣≡p {mkℚᵘ -[1+ n ] d-1} 0≤p = contradiction 0≤p (<⇒≱ (*<* ℤ.-<+)) 0≤p⇒∣p∣≃p : 0ℚᵘ p p p 0≤p⇒∣p∣≃p {p} = ≃-reflexive 0≤p⇒∣p∣≡p {p} diff --git a/v2.3/Data.Sign.Properties.html b/v2.3/Data.Sign.Properties.html index 8131cbd006..dcedc0ee77 100644 --- a/v2.3/Data.Sign.Properties.html +++ b/v2.3/Data.Sign.Properties.html @@ -25,7 +25,7 @@ open import Relation.Binary.PropositionalEquality.Properties using (setoid; decSetoid; isDecEquivalence; isEquivalence) open import Relation.Nullary.Decidable using (yes; no) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Algebra.Structures {A = Sign} _≡_ open import Algebra.Definitions {A = Sign} _≡_ @@ -109,8 +109,8 @@ *-cancelʳ-≡ : RightCancellative _*_ *-cancelʳ-≡ _ - - _ = refl -*-cancelʳ-≡ _ - + eq = contradiction (sym eq) (s≢opposite[s] _) -*-cancelʳ-≡ _ + - eq = contradiction eq (s≢opposite[s] _) +*-cancelʳ-≡ _ - + eq = contradiction (sym eq) (s≢opposite[s] _) +*-cancelʳ-≡ _ + - eq = contradiction eq (s≢opposite[s] _) *-cancelʳ-≡ _ + + _ = refl *-cancelˡ-≡ : LeftCancellative _*_ diff --git a/v2.3/Data.String.html b/v2.3/Data.String.html index 5bee8b04d7..3011035001 100644 --- a/v2.3/Data.String.html +++ b/v2.3/Data.String.html @@ -15,7 +15,7 @@ open import Data.Nat.Base as using () import Data.Nat.Properties as open import Data.List.Base as List using (List) -open import Data.List.Extrema ℕ.≤-totalOrder +open import Data.List.Extrema ℕ.≤-totalOrder open import Data.Vec.Base as Vec using (Vec) open import Data.Char.Base as Char using (Char) import Data.Char.Properties as Char using (_≟_) diff --git a/v2.3/Data.Sum.Function.Propositional.html b/v2.3/Data.Sum.Function.Propositional.html index 783e210c8d..09b33ab81b 100644 --- a/v2.3/Data.Sum.Function.Propositional.html +++ b/v2.3/Data.Sum.Function.Propositional.html @@ -13,7 +13,7 @@ open import Data.Sum.Function.Setoid using (_⊎-function_; _⊎-equivalence_; _⊎-injection_; _⊎-surjection_ ; _⊎-leftInverse_; _⊎-rightInverse_; _⊎-bijection_; _⊎-inverse_) -open import Data.Sum.Relation.Binary.Pointwise using (Pointwise-≡↔≡; _⊎ₛ_) +open import Data.Sum.Relation.Binary.Pointwise using (Pointwise-≡↔≡; _⊎ₛ_) open import Function.Construct.Composition as Compose open import Function.Related.Propositional using (_∼[_]_; implication; reverseImplication; equivalence; injection; @@ -42,11 +42,11 @@ liftViaInverse : {R : {a b ℓ₁ ℓ₂} REL (Setoid a ℓ₁) (Setoid b ℓ₂) (a b ℓ₁ ℓ₂)} (∀ {a b c ℓ₁ ℓ₂ ℓ₃} {S : Setoid a ℓ₁} {T : Setoid b ℓ₂} {U : Setoid c ℓ₃} R S T R T U R S U) (∀ {a b ℓ₁ ℓ₂} {S : Setoid a ℓ₁} {T : Setoid b ℓ₂} Inverse S T R S T) - (R (setoid A) (setoid C) R (setoid B) (setoid D) R (setoid A ⊎ₛ setoid B) (setoid C ⊎ₛ setoid D)) + (R (setoid A) (setoid C) R (setoid B) (setoid D) R (setoid A ⊎ₛ setoid B) (setoid C ⊎ₛ setoid D)) R (setoid A) (setoid C) R (setoid B) (setoid D) R (setoid (A B)) (setoid (C D)) liftViaInverse trans inv⇒R lift RAC RBD = - Inv.transportVia trans inv⇒R (Inv.sym (Pointwise-≡↔≡ _ _)) (lift RAC RBD) (Pointwise-≡↔≡ _ _) + Inv.transportVia trans inv⇒R (Inv.sym (Pointwise-≡↔≡ _ _)) (lift RAC RBD) (Pointwise-≡↔≡ _ _) ------------------------------------------------------------------------ -- Combinators for various function types diff --git a/v2.3/Data.Sum.Function.Setoid.html b/v2.3/Data.Sum.Function.Setoid.html index bbb24cf1e8..40779686cf 100644 --- a/v2.3/Data.Sum.Function.Setoid.html +++ b/v2.3/Data.Sum.Function.Setoid.html @@ -33,21 +33,21 @@ ------------------------------------------------------------------------ -- Combinators for equality preserving functions -inj₁ₛ : Func S (S ⊎ₛ T) -inj₁ₛ = record { to = inj₁ ; cong = inj₁ } +inj₁ₛ : Func S (S ⊎ₛ T) +inj₁ₛ = record { to = inj₁ ; cong = inj₁ } -inj₂ₛ : Func T (S ⊎ₛ T) -inj₂ₛ = record { to = inj₂ ; cong = inj₂ } +inj₂ₛ : Func T (S ⊎ₛ T) +inj₂ₛ = record { to = inj₂ ; cong = inj₂ } -[_,_]ₛ : Func S U Func T U Func (S ⊎ₛ T) U +[_,_]ₛ : Func S U Func T U Func (S ⊎ₛ T) U [ f , g ]ₛ = record { to = [ to f , to g ] ; cong = λ where - (inj₁ x∼₁y) cong f x∼₁y - (inj₂ x∼₂y) cong g x∼₂y + (inj₁ x∼₁y) cong f x∼₁y + (inj₂ x∼₂y) cong g x∼₂y } where open Func -swapₛ : Func (S ⊎ₛ T) (T ⊎ₛ S) +swapₛ : Func (S ⊎ₛ T) (T ⊎ₛ S) swapₛ = [ inj₂ₛ , inj₁ₛ ]ₛ ------------------------------------------------------------------------ @@ -56,26 +56,26 @@ ⊎-injective : {f g} Injective ≈₁ ≈₂ f Injective ≈₃ ≈₄ g - Injective (Pointwise ≈₁ ≈₃) (Pointwise ≈₂ ≈₄) (Sum.map f g) -⊎-injective f-inj g-inj {inj₁ x} {inj₁ y} (inj₁ x∼₁y) = inj₁ (f-inj x∼₁y) -⊎-injective f-inj g-inj {inj₂ x} {inj₂ y} (inj₂ x∼₂y) = inj₂ (g-inj x∼₂y) + Injective (Pointwise ≈₁ ≈₃) (Pointwise ≈₂ ≈₄) (Sum.map f g) +⊎-injective f-inj g-inj {inj₁ x} {inj₁ y} (inj₁ x∼₁y) = inj₁ (f-inj x∼₁y) +⊎-injective f-inj g-inj {inj₂ x} {inj₂ y} (inj₂ x∼₂y) = inj₂ (g-inj x∼₂y) ⊎-strictlySurjective : {f : A B} {g : C D} StrictlySurjective ≈₁ f StrictlySurjective ≈₂ g - StrictlySurjective (Pointwise ≈₁ ≈₂) (Sum.map f g) + StrictlySurjective (Pointwise ≈₁ ≈₂) (Sum.map f g) ⊎-strictlySurjective f-sur g-sur = - [ Product.map inj₁ inj₁ f-sur - , Product.map inj₂ inj₂ g-sur + [ Product.map inj₁ inj₁ f-sur + , Product.map inj₂ inj₂ g-sur ] ⊎-surjective : {f : A B} {g : C D} Surjective ≈₁ ≈₂ f Surjective ≈₃ ≈₄ g - Surjective (Pointwise ≈₁ ≈₃) (Pointwise ≈₂ ≈₄) (Sum.map f g) + Surjective (Pointwise ≈₁ ≈₃) (Pointwise ≈₂ ≈₄) (Sum.map f g) ⊎-surjective f-sur g-sur = - [ Product.map inj₁ { fwd (inj₁ x) inj₁ (fwd x)}) f-sur - , Product.map inj₂ { fwd (inj₂ y) inj₂ (fwd y)}) g-sur + [ Product.map inj₁ { fwd (inj₁ x) inj₁ (fwd x)}) f-sur + , Product.map inj₂ { fwd (inj₂ y) inj₂ (fwd y)}) g-sur ] @@ -84,81 +84,81 @@ ------------------------------------------------------------------------ -- Function bundles -_⊎-function_ : Func S T Func U V Func (S ⊎ₛ U) (T ⊎ₛ V) +_⊎-function_ : Func S T Func U V Func (S ⊎ₛ U) (T ⊎ₛ V) S→T ⊎-function U→V = record { to = Sum.map (to S→T) (to U→V) - ; cong = Pointwise.map (cong S→T) (cong U→V) + ; cong = Pointwise.map (cong S→T) (cong U→V) } where open Func _⊎-equivalence_ : Equivalence S T Equivalence U V - Equivalence (S ⊎ₛ U) (T ⊎ₛ V) + Equivalence (S ⊎ₛ U) (T ⊎ₛ V) S⇔T ⊎-equivalence U⇔V = record { to = Sum.map (to S⇔T) (to U⇔V) ; from = Sum.map (from S⇔T) (from U⇔V) - ; to-cong = Pointwise.map (to-cong S⇔T) (to-cong U⇔V) - ; from-cong = Pointwise.map (from-cong S⇔T) (from-cong U⇔V) + ; to-cong = Pointwise.map (to-cong S⇔T) (to-cong U⇔V) + ; from-cong = Pointwise.map (from-cong S⇔T) (from-cong U⇔V) } where open Equivalence _⊎-injection_ : Injection S T Injection U V - Injection (S ⊎ₛ U) (T ⊎ₛ V) + Injection (S ⊎ₛ U) (T ⊎ₛ V) S↣T ⊎-injection U↣V = record { to = Sum.map (to S↣T) (to U↣V) - ; cong = Pointwise.map (cong S↣T) (cong U↣V) + ; cong = Pointwise.map (cong S↣T) (cong U↣V) ; injective = ⊎-injective (injective S↣T) (injective U↣V) } where open Injection infixr 1 _⊎-surjection_ _⊎-inverse_ _⊎-surjection_ : Surjection S T Surjection U V - Surjection (S ⊎ₛ U) (T ⊎ₛ V) + Surjection (S ⊎ₛ U) (T ⊎ₛ V) S↠T ⊎-surjection U↠V = record { to = Sum.map (to S↠T) (to U↠V) - ; cong = Pointwise.map (cong S↠T) (cong U↠V) + ; cong = Pointwise.map (cong S↠T) (cong U↠V) ; surjective = ⊎-surjective (surjective S↠T) (surjective U↠V) } where open Surjection _⊎-bijection_ : Bijection S T Bijection U V - Bijection (S ⊎ₛ U) (T ⊎ₛ V) + Bijection (S ⊎ₛ U) (T ⊎ₛ V) S⤖T ⊎-bijection U⤖V = record { to = Sum.map (to S⤖T) (to U⤖V) - ; cong = Pointwise.map (cong S⤖T) (cong U⤖V) + ; cong = Pointwise.map (cong S⤖T) (cong U⤖V) ; bijective = ⊎-injective (injective S⤖T) (injective U⤖V) , ⊎-surjective (surjective S⤖T) (surjective U⤖V) } where open Bijection _⊎-leftInverse_ : LeftInverse S T LeftInverse U V - LeftInverse (S ⊎ₛ U) (T ⊎ₛ V) + LeftInverse (S ⊎ₛ U) (T ⊎ₛ V) S↩T ⊎-leftInverse U↩V = record { to = Sum.map (to S↩T) (to U↩V) ; from = Sum.map (from S↩T) (from U↩V) - ; to-cong = Pointwise.map (to-cong S↩T) (to-cong U↩V) - ; from-cong = Pointwise.map (from-cong S↩T) (from-cong U↩V) - ; inverseˡ = λ { {inj₁ _} {.(inj₁ _)} (inj₁ x) inj₁ (inverseˡ S↩T x) - ; {inj₂ _} {.(inj₂ _)} (inj₂ x) inj₂ (inverseˡ U↩V x)} + ; to-cong = Pointwise.map (to-cong S↩T) (to-cong U↩V) + ; from-cong = Pointwise.map (from-cong S↩T) (from-cong U↩V) + ; inverseˡ = λ { {inj₁ _} {.(inj₁ _)} (inj₁ x) inj₁ (inverseˡ S↩T x) + ; {inj₂ _} {.(inj₂ _)} (inj₂ x) inj₂ (inverseˡ U↩V x)} } where open LeftInverse _⊎-rightInverse_ : RightInverse S T RightInverse U V - RightInverse (S ⊎ₛ U) (T ⊎ₛ V) + RightInverse (S ⊎ₛ U) (T ⊎ₛ V) S↪T ⊎-rightInverse U↪V = record { to = Sum.map (to S↪T) (to U↪V) ; from = Sum.map (from S↪T) (from U↪V) - ; to-cong = Pointwise.map (to-cong S↪T) (to-cong U↪V) - ; from-cong = Pointwise.map (from-cong S↪T) (from-cong U↪V) - ; inverseʳ = λ { {inj₁ _} (inj₁ x) inj₁ (inverseʳ S↪T x) - ; {inj₂ _} (inj₂ x) inj₂ (inverseʳ U↪V x) + ; to-cong = Pointwise.map (to-cong S↪T) (to-cong U↪V) + ; from-cong = Pointwise.map (from-cong S↪T) (from-cong U↪V) + ; inverseʳ = λ { {inj₁ _} (inj₁ x) inj₁ (inverseʳ S↪T x) + ; {inj₂ _} (inj₂ x) inj₂ (inverseʳ U↪V x) } } where open RightInverse _⊎-inverse_ : Inverse S T Inverse U V - Inverse (S ⊎ₛ U) (T ⊎ₛ V) + Inverse (S ⊎ₛ U) (T ⊎ₛ V) S↔T ⊎-inverse U↔V = record { to = Sum.map (to S↔T) (to U↔V) ; from = Sum.map (from S↔T) (from U↔V) - ; to-cong = Pointwise.map (to-cong S↔T) (to-cong U↔V) - ; from-cong = Pointwise.map (from-cong S↔T) (from-cong U↔V) - ; inverse = { {inj₁ _} (inj₁ x) inj₁ (inverseˡ S↔T x) - ; {inj₂ _} (inj₂ x) inj₂ (inverseˡ U↔V x)}) , - λ { {inj₁ _} (inj₁ x) inj₁ (inverseʳ S↔T x) - ; {inj₂ _} (inj₂ x) inj₂ (inverseʳ U↔V x) + ; to-cong = Pointwise.map (to-cong S↔T) (to-cong U↔V) + ; from-cong = Pointwise.map (from-cong S↔T) (from-cong U↔V) + ; inverse = { {inj₁ _} (inj₁ x) inj₁ (inverseˡ S↔T x) + ; {inj₂ _} (inj₂ x) inj₂ (inverseˡ U↔V x)}) , + λ { {inj₁ _} (inj₁ x) inj₁ (inverseʳ S↔T x) + ; {inj₂ _} (inj₂ x) inj₂ (inverseʳ U↔V x) } } where open Inverse diff --git a/v2.3/Data.Sum.Relation.Binary.LeftOrder.html b/v2.3/Data.Sum.Relation.Binary.LeftOrder.html index 6f995eb767..a1f5c35caf 100644 --- a/v2.3/Data.Sum.Relation.Binary.LeftOrder.html +++ b/v2.3/Data.Sum.Relation.Binary.LeftOrder.html @@ -11,245 +11,260 @@ open import Data.Sum.Base as Sum using (inj₁; inj₂; _⊎_) open import Data.Sum.Relation.Binary.Pointwise as PW - using (Pointwise; inj₁; inj₂) + using (Pointwise; inj₁; inj₂) open import Data.Product.Base using (_,_) open import Data.Empty using () open import Function.Base using (_$_; _∘_) -open import Level using (Level; _⊔_) -open import Relation.Nullary.Negation.Core using (¬_) -open import Relation.Nullary.Decidable.Core using (yes; no) -import Relation.Nullary.Decidable as Dec using (Dec; map; map′) -open import Relation.Binary.Core using (Rel; _⇒_) -open import Relation.Binary.Bundles - using (Preorder; Poset; StrictPartialOrder; TotalOrder; DecTotalOrder - ; StrictTotalOrder) -open import Relation.Binary.Structures - using (IsPreorder; IsPartialOrder; IsStrictPartialOrder; IsTotalOrder - ; IsDecTotalOrder; IsStrictTotalOrder) -open import Relation.Binary.Definitions - using (Reflexive; Transitive; Asymmetric; Total; Decidable; Irreflexive - ; Antisymmetric; Trichotomous; _Respectsʳ_; _Respectsˡ_; _Respects₂_ - ; tri<; tri>; tri≈) -open import Relation.Binary.PropositionalEquality.Core using (_≡_) - ------------------------------------------------------------------------- --- Definition - -infixr 1 _⊎-<_ - -data _⊎-<_ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} - {ℓ₁ ℓ₂} (_∼₁_ : Rel A₁ ℓ₁) (_∼₂_ : Rel A₂ ℓ₂) : - Rel (A₁ A₂) (a₁ a₂ ℓ₁ ℓ₂) where - ₁∼₂ : {x y} (_∼₁_ ⊎-< _∼₂_) (inj₁ x) (inj₂ y) - ₁∼₁ : {x y} (x∼₁y : x ∼₁ y) (_∼₁_ ⊎-< _∼₂_) (inj₁ x) (inj₁ y) - ₂∼₂ : {x y} (x∼₂y : x ∼₂ y) (_∼₁_ ⊎-< _∼₂_) (inj₂ x) (inj₂ y) - ------------------------------------------------------------------------- --- Some properties which are preserved by _⊎-<_ - -module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} - {ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {∼₂ : Rel A₂ ℓ₂} - where - - drop-inj₁ : {x y} (∼₁ ⊎-< ∼₂) (inj₁ x) (inj₁ y) ∼₁ x y - drop-inj₁ (₁∼₁ x∼₁y) = x∼₁y - - drop-inj₂ : {x y} (∼₁ ⊎-< ∼₂) (inj₂ x) (inj₂ y) ∼₂ x y - drop-inj₂ (₂∼₂ x∼₂y) = x∼₂y - - ⊎-<-refl : Reflexive ∼₁ Reflexive ∼₂ - Reflexive (∼₁ ⊎-< ∼₂) - ⊎-<-refl refl₁ refl₂ {inj₁ x} = ₁∼₁ refl₁ - ⊎-<-refl refl₁ refl₂ {inj₂ y} = ₂∼₂ refl₂ - - ⊎-<-transitive : Transitive ∼₁ Transitive ∼₂ - Transitive (∼₁ ⊎-< ∼₂) - ⊎-<-transitive trans₁ trans₂ ₁∼₂ (₂∼₂ x∼₂y) = ₁∼₂ - ⊎-<-transitive trans₁ trans₂ (₁∼₁ x∼₁y) ₁∼₂ = ₁∼₂ - ⊎-<-transitive trans₁ trans₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = ₁∼₁ (trans₁ x∼₁y x∼₁y₁) - ⊎-<-transitive trans₁ trans₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = ₂∼₂ (trans₂ x∼₂y x∼₂y₁) - - ⊎-<-asymmetric : Asymmetric ∼₁ Asymmetric ∼₂ - Asymmetric (∼₁ ⊎-< ∼₂) - ⊎-<-asymmetric asym₁ asym₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = asym₁ x∼₁y x∼₁y₁ - ⊎-<-asymmetric asym₁ asym₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = asym₂ x∼₂y x∼₂y₁ - - ⊎-<-total : Total ∼₁ Total ∼₂ Total (∼₁ ⊎-< ∼₂) - ⊎-<-total total₁ total₂ = total - where - total : Total (_ ⊎-< _) - total (inj₁ x) (inj₁ y) = Sum.map ₁∼₁ ₁∼₁ $ total₁ x y - total (inj₁ x) (inj₂ y) = inj₁ ₁∼₂ - total (inj₂ x) (inj₁ y) = inj₂ ₁∼₂ - total (inj₂ x) (inj₂ y) = Sum.map ₂∼₂ ₂∼₂ $ total₂ x y - - ⊎-<-decidable : Decidable ∼₁ Decidable ∼₂ - Decidable (∼₁ ⊎-< ∼₂) - ⊎-<-decidable dec₁ dec₂ (inj₁ x) (inj₁ y) = Dec.map′ ₁∼₁ drop-inj₁ (dec₁ x y) - ⊎-<-decidable dec₁ dec₂ (inj₁ x) (inj₂ y) = yes ₁∼₂ - ⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₁ y) = no λ() - ⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₂ y) = Dec.map′ ₂∼₂ drop-inj₂ (dec₂ x y) - -module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} - {ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {≈₁ : Rel A₁ ℓ₂} - {ℓ₃ ℓ₄} {∼₂ : Rel A₂ ℓ₃} {≈₂ : Rel A₂ ℓ₄} - where - - ⊎-<-reflexive : ≈₁ ∼₁ ≈₂ ∼₂ - (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-reflexive refl₁ refl₂ (inj₁ x) = ₁∼₁ (refl₁ x) - ⊎-<-reflexive refl₁ refl₂ (inj₂ x) = ₂∼₂ (refl₂ x) - - ⊎-<-irreflexive : Irreflexive ≈₁ ∼₁ Irreflexive ≈₂ ∼₂ - Irreflexive (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-irreflexive irrefl₁ irrefl₂ (inj₁ x) (₁∼₁ x∼₁y) = irrefl₁ x x∼₁y - ⊎-<-irreflexive irrefl₁ irrefl₂ (inj₂ x) (₂∼₂ x∼₂y) = irrefl₂ x x∼₂y - - ⊎-<-antisymmetric : Antisymmetric ≈₁ ∼₁ Antisymmetric ≈₂ ∼₂ - Antisymmetric (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-antisymmetric antisym₁ antisym₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = inj₁ (antisym₁ x∼₁y x∼₁y₁) - ⊎-<-antisymmetric antisym₁ antisym₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = inj₂ (antisym₂ x∼₂y x∼₂y₁) - - ⊎-<-respectsʳ : ∼₁ Respectsʳ ≈₁ ∼₂ Respectsʳ ≈₂ - (∼₁ ⊎-< ∼₂) Respectsʳ (Pointwise ≈₁ ≈₂) - ⊎-<-respectsʳ resp₁ resp₂ (inj₁ x₁) (₁∼₁ x∼₁y) = ₁∼₁ (resp₁ x₁ x∼₁y) - ⊎-<-respectsʳ resp₁ resp₂ (inj₂ x₁) ₁∼₂ = ₁∼₂ - ⊎-<-respectsʳ resp₁ resp₂ (inj₂ x₁) (₂∼₂ x∼₂y) = ₂∼₂ (resp₂ x₁ x∼₂y) - - ⊎-<-respectsˡ : ∼₁ Respectsˡ ≈₁ ∼₂ Respectsˡ ≈₂ - (∼₁ ⊎-< ∼₂) Respectsˡ (Pointwise ≈₁ ≈₂) - ⊎-<-respectsˡ resp₁ resp₂ (inj₁ x) ₁∼₂ = ₁∼₂ - ⊎-<-respectsˡ resp₁ resp₂ (inj₁ x) (₁∼₁ x∼₁y) = ₁∼₁ (resp₁ x x∼₁y) - ⊎-<-respectsˡ resp₁ resp₂ (inj₂ x) (₂∼₂ x∼₂y) = ₂∼₂ (resp₂ x x∼₂y) - - ⊎-<-respects₂ : ∼₁ Respects₂ ≈₁ ∼₂ Respects₂ ≈₂ - (∼₁ ⊎-< ∼₂) Respects₂ (Pointwise ≈₁ ≈₂) - ⊎-<-respects₂ (r₁ , l₁) (r₂ , l₂) = ⊎-<-respectsʳ r₁ r₂ , ⊎-<-respectsˡ l₁ l₂ - - ⊎-<-trichotomous : Trichotomous ≈₁ ∼₁ Trichotomous ≈₂ ∼₂ - Trichotomous (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-trichotomous tri₁ tri₂ (inj₁ x) (inj₂ y) = tri< ₁∼₂ (λ()) (λ()) - ⊎-<-trichotomous tri₁ tri₂ (inj₂ x) (inj₁ y) = tri> (λ()) (λ()) ₁∼₂ - ⊎-<-trichotomous tri₁ tri₂ (inj₁ x) (inj₁ y) with tri₁ x y - ... | tri< x<y x≉y x≯y = tri< (₁∼₁ x<y) (x≉y PW.drop-inj₁) (x≯y drop-inj₁) - ... | tri≈ x≮y x≈y x≯y = tri≈ (x≮y drop-inj₁) (inj₁ x≈y) (x≯y drop-inj₁) - ... | tri> x≮y x≉y x>y = tri> (x≮y drop-inj₁) (x≉y PW.drop-inj₁) (₁∼₁ x>y) - ⊎-<-trichotomous tri₁ tri₂ (inj₂ x) (inj₂ y) with tri₂ x y - ... | tri< x<y x≉y x≯y = tri< (₂∼₂ x<y) (x≉y PW.drop-inj₂) (x≯y drop-inj₂) - ... | tri≈ x≮y x≈y x≯y = tri≈ (x≮y drop-inj₂) (inj₂ x≈y) (x≯y drop-inj₂) - ... | tri> x≮y x≉y x>y = tri> (x≮y drop-inj₂) (x≉y PW.drop-inj₂) (₂∼₂ x>y) - ------------------------------------------------------------------------- --- Some collections of properties which are preserved - -module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} - {ℓ₁ ℓ₂} {≈₁ : Rel A₁ ℓ₁} {∼₁ : Rel A₁ ℓ₂} - {ℓ₃ ℓ₄} {≈₂ : Rel A₂ ℓ₃} {∼₂ : Rel A₂ ℓ₄} where - - ⊎-<-isPreorder : IsPreorder ≈₁ ∼₁ IsPreorder ≈₂ ∼₂ - IsPreorder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-isPreorder pre₁ pre₂ = record - { isEquivalence = PW.⊎-isEquivalence (isEquivalence pre₁) (isEquivalence pre₂) - ; reflexive = ⊎-<-reflexive (reflexive pre₁) (reflexive pre₂) - ; trans = ⊎-<-transitive (trans pre₁) (trans pre₂) - } - where open IsPreorder - - ⊎-<-isPartialOrder : IsPartialOrder ≈₁ ∼₁ - IsPartialOrder ≈₂ ∼₂ - IsPartialOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-isPartialOrder po₁ po₂ = record - { isPreorder = ⊎-<-isPreorder (isPreorder po₁) (isPreorder po₂) - ; antisym = ⊎-<-antisymmetric (antisym po₁) (antisym po₂) - } - where open IsPartialOrder - - ⊎-<-isStrictPartialOrder : IsStrictPartialOrder ≈₁ ∼₁ - IsStrictPartialOrder ≈₂ ∼₂ - IsStrictPartialOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-isStrictPartialOrder spo₁ spo₂ = record - { isEquivalence = PW.⊎-isEquivalence (isEquivalence spo₁) (isEquivalence spo₂) - ; irrefl = ⊎-<-irreflexive (irrefl spo₁) (irrefl spo₂) - ; trans = ⊎-<-transitive (trans spo₁) (trans spo₂) - ; <-resp-≈ = ⊎-<-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂) - } - where open IsStrictPartialOrder - - ⊎-<-isTotalOrder : IsTotalOrder ≈₁ ∼₁ - IsTotalOrder ≈₂ ∼₂ - IsTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-isTotalOrder to₁ to₂ = record - { isPartialOrder = ⊎-<-isPartialOrder (isPartialOrder to₁) (isPartialOrder to₂) - ; total = ⊎-<-total (total to₁) (total to₂) - } - where open IsTotalOrder - - ⊎-<-isDecTotalOrder : IsDecTotalOrder ≈₁ ∼₁ - IsDecTotalOrder ≈₂ ∼₂ - IsDecTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-isDecTotalOrder to₁ to₂ = record - { isTotalOrder = ⊎-<-isTotalOrder (isTotalOrder to₁) (isTotalOrder to₂) - ; _≟_ = PW.⊎-decidable (_≟_ to₁) (_≟_ to₂) - ; _≤?_ = ⊎-<-decidable (_≤?_ to₁) (_≤?_ to₂) - } - where open IsDecTotalOrder - - ⊎-<-isStrictTotalOrder : IsStrictTotalOrder ≈₁ ∼₁ - IsStrictTotalOrder ≈₂ ∼₂ - IsStrictTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) - ⊎-<-isStrictTotalOrder sto₁ sto₂ = record - { isStrictPartialOrder = ⊎-<-isStrictPartialOrder (isStrictPartialOrder sto₁) (isStrictPartialOrder sto₂) - ; compare = ⊎-<-trichotomous (compare sto₁) (compare sto₂) - } - where open IsStrictTotalOrder - ------------------------------------------------------------------------- --- "Bundles" can also be combined. - -module _ {a b c d e f} where - - ⊎-<-preorder : Preorder a b c - Preorder d e f - Preorder _ _ _ - ⊎-<-preorder p₁ p₂ = record - { isPreorder = - ⊎-<-isPreorder (isPreorder p₁) (isPreorder p₂) - } where open Preorder - - ⊎-<-poset : Poset a b c - Poset a b c - Poset _ _ _ - ⊎-<-poset po₁ po₂ = record - { isPartialOrder = - ⊎-<-isPartialOrder (isPartialOrder po₁) (isPartialOrder po₂) - } where open Poset - - ⊎-<-strictPartialOrder : StrictPartialOrder a b c - StrictPartialOrder d e f - StrictPartialOrder _ _ _ - ⊎-<-strictPartialOrder spo₁ spo₂ = record - { isStrictPartialOrder = - ⊎-<-isStrictPartialOrder (isStrictPartialOrder spo₁) (isStrictPartialOrder spo₂) - } where open StrictPartialOrder - - ⊎-<-totalOrder : TotalOrder a b c - TotalOrder d e f - TotalOrder _ _ _ - ⊎-<-totalOrder to₁ to₂ = record - { isTotalOrder = ⊎-<-isTotalOrder (isTotalOrder to₁) (isTotalOrder to₂) - } where open TotalOrder - - ⊎-<-decTotalOrder : DecTotalOrder a b c - DecTotalOrder d e f - DecTotalOrder _ _ _ - ⊎-<-decTotalOrder to₁ to₂ = record - { isDecTotalOrder = ⊎-<-isDecTotalOrder (isDecTotalOrder to₁) (isDecTotalOrder to₂) - } where open DecTotalOrder - - ⊎-<-strictTotalOrder : StrictTotalOrder a b c - StrictTotalOrder a b c - StrictTotalOrder _ _ _ - ⊎-<-strictTotalOrder sto₁ sto₂ = record - { isStrictTotalOrder = ⊎-<-isStrictTotalOrder (isStrictTotalOrder sto₁) (isStrictTotalOrder sto₂) - } where open StrictTotalOrder +open import Induction.WellFounded +open import Level using (Level; _⊔_) +open import Relation.Nullary.Negation.Core using (¬_) +open import Relation.Nullary.Decidable.Core using (yes; no) +import Relation.Nullary.Decidable as Dec using (Dec; map; map′) +open import Relation.Binary.Core using (Rel; _⇒_) +open import Relation.Binary.Bundles + using (Preorder; Poset; StrictPartialOrder; TotalOrder; DecTotalOrder + ; StrictTotalOrder) +open import Relation.Binary.Structures + using (IsPreorder; IsPartialOrder; IsStrictPartialOrder; IsTotalOrder + ; IsDecTotalOrder; IsStrictTotalOrder) +open import Relation.Binary.Definitions + using (Reflexive; Transitive; Asymmetric; Total; Decidable; Irreflexive + ; Antisymmetric; Trichotomous; _Respectsʳ_; _Respectsˡ_; _Respects₂_ + ; tri<; tri>; tri≈) +open import Relation.Binary.PropositionalEquality.Core using (_≡_) + +------------------------------------------------------------------------ +-- Definition + +infixr 1 _⊎-<_ + +data _⊎-<_ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} + {ℓ₁ ℓ₂} (_∼₁_ : Rel A₁ ℓ₁) (_∼₂_ : Rel A₂ ℓ₂) : + Rel (A₁ A₂) (a₁ a₂ ℓ₁ ℓ₂) where + ₁∼₂ : {x y} (_∼₁_ ⊎-< _∼₂_) (inj₁ x) (inj₂ y) + ₁∼₁ : {x y} (x∼₁y : x ∼₁ y) (_∼₁_ ⊎-< _∼₂_) (inj₁ x) (inj₁ y) + ₂∼₂ : {x y} (x∼₂y : x ∼₂ y) (_∼₁_ ⊎-< _∼₂_) (inj₂ x) (inj₂ y) + +------------------------------------------------------------------------ +-- Some properties which are preserved by _⊎-<_ + +module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} + {ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {∼₂ : Rel A₂ ℓ₂} + where + + drop-inj₁ : {x y} (∼₁ ⊎-< ∼₂) (inj₁ x) (inj₁ y) ∼₁ x y + drop-inj₁ (₁∼₁ x∼₁y) = x∼₁y + + drop-inj₂ : {x y} (∼₁ ⊎-< ∼₂) (inj₂ x) (inj₂ y) ∼₂ x y + drop-inj₂ (₂∼₂ x∼₂y) = x∼₂y + + ⊎-<-refl : Reflexive ∼₁ Reflexive ∼₂ + Reflexive (∼₁ ⊎-< ∼₂) + ⊎-<-refl refl₁ refl₂ {inj₁ x} = ₁∼₁ refl₁ + ⊎-<-refl refl₁ refl₂ {inj₂ y} = ₂∼₂ refl₂ + + ⊎-<-transitive : Transitive ∼₁ Transitive ∼₂ + Transitive (∼₁ ⊎-< ∼₂) + ⊎-<-transitive trans₁ trans₂ ₁∼₂ (₂∼₂ x∼₂y) = ₁∼₂ + ⊎-<-transitive trans₁ trans₂ (₁∼₁ x∼₁y) ₁∼₂ = ₁∼₂ + ⊎-<-transitive trans₁ trans₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = ₁∼₁ (trans₁ x∼₁y x∼₁y₁) + ⊎-<-transitive trans₁ trans₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = ₂∼₂ (trans₂ x∼₂y x∼₂y₁) + + ⊎-<-asymmetric : Asymmetric ∼₁ Asymmetric ∼₂ + Asymmetric (∼₁ ⊎-< ∼₂) + ⊎-<-asymmetric asym₁ asym₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = asym₁ x∼₁y x∼₁y₁ + ⊎-<-asymmetric asym₁ asym₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = asym₂ x∼₂y x∼₂y₁ + + ⊎-<-total : Total ∼₁ Total ∼₂ Total (∼₁ ⊎-< ∼₂) + ⊎-<-total total₁ total₂ = total + where + total : Total (_ ⊎-< _) + total (inj₁ x) (inj₁ y) = Sum.map ₁∼₁ ₁∼₁ $ total₁ x y + total (inj₁ x) (inj₂ y) = inj₁ ₁∼₂ + total (inj₂ x) (inj₁ y) = inj₂ ₁∼₂ + total (inj₂ x) (inj₂ y) = Sum.map ₂∼₂ ₂∼₂ $ total₂ x y + + ⊎-<-decidable : Decidable ∼₁ Decidable ∼₂ + Decidable (∼₁ ⊎-< ∼₂) + ⊎-<-decidable dec₁ dec₂ (inj₁ x) (inj₁ y) = Dec.map′ ₁∼₁ drop-inj₁ (dec₁ x y) + ⊎-<-decidable dec₁ dec₂ (inj₁ x) (inj₂ y) = yes ₁∼₂ + ⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₁ y) = no λ() + ⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₂ y) = Dec.map′ ₂∼₂ drop-inj₂ (dec₂ x y) + + ⊎-<-wellFounded : WellFounded ∼₁ WellFounded ∼₂ WellFounded (∼₁ ⊎-< ∼₂) + ⊎-<-wellFounded wf₁ wf₂ x = acc (⊎-<-acc x) + where + ⊎-<-acc₁ : {x} Acc ∼₁ x WfRec (∼₁ ⊎-< ∼₂) (Acc (∼₁ ⊎-< ∼₂)) (inj₁ x) + ⊎-<-acc₁ (acc rec) (₁∼₁ x∼₁y) = acc (⊎-<-acc₁ (rec x∼₁y)) + + ⊎-<-acc₂ : {x} Acc ∼₂ x WfRec (∼₁ ⊎-< ∼₂) (Acc (∼₁ ⊎-< ∼₂)) (inj₂ x) + ⊎-<-acc₂ (acc rec) {inj₁ x} ₁∼₂ = acc (⊎-<-acc₁ (wf₁ x)) + ⊎-<-acc₂ (acc rec) (₂∼₂ x∼₂y) = acc (⊎-<-acc₂ (rec x∼₂y)) + + ⊎-<-acc : x WfRec (∼₁ ⊎-< ∼₂) (Acc (∼₁ ⊎-< ∼₂)) x + ⊎-<-acc (inj₁ x) = ⊎-<-acc₁ (wf₁ x) + ⊎-<-acc (inj₂ x) = ⊎-<-acc₂ (wf₂ x) + +module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} + {ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {≈₁ : Rel A₁ ℓ₂} + {ℓ₃ ℓ₄} {∼₂ : Rel A₂ ℓ₃} {≈₂ : Rel A₂ ℓ₄} + where + + ⊎-<-reflexive : ≈₁ ∼₁ ≈₂ ∼₂ + (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-reflexive refl₁ refl₂ (inj₁ x) = ₁∼₁ (refl₁ x) + ⊎-<-reflexive refl₁ refl₂ (inj₂ x) = ₂∼₂ (refl₂ x) + + ⊎-<-irreflexive : Irreflexive ≈₁ ∼₁ Irreflexive ≈₂ ∼₂ + Irreflexive (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-irreflexive irrefl₁ irrefl₂ (inj₁ x) (₁∼₁ x∼₁y) = irrefl₁ x x∼₁y + ⊎-<-irreflexive irrefl₁ irrefl₂ (inj₂ x) (₂∼₂ x∼₂y) = irrefl₂ x x∼₂y + + ⊎-<-antisymmetric : Antisymmetric ≈₁ ∼₁ Antisymmetric ≈₂ ∼₂ + Antisymmetric (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-antisymmetric antisym₁ antisym₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = inj₁ (antisym₁ x∼₁y x∼₁y₁) + ⊎-<-antisymmetric antisym₁ antisym₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = inj₂ (antisym₂ x∼₂y x∼₂y₁) + + ⊎-<-respectsʳ : ∼₁ Respectsʳ ≈₁ ∼₂ Respectsʳ ≈₂ + (∼₁ ⊎-< ∼₂) Respectsʳ (Pointwise ≈₁ ≈₂) + ⊎-<-respectsʳ resp₁ resp₂ (inj₁ x₁) (₁∼₁ x∼₁y) = ₁∼₁ (resp₁ x₁ x∼₁y) + ⊎-<-respectsʳ resp₁ resp₂ (inj₂ x₁) ₁∼₂ = ₁∼₂ + ⊎-<-respectsʳ resp₁ resp₂ (inj₂ x₁) (₂∼₂ x∼₂y) = ₂∼₂ (resp₂ x₁ x∼₂y) + + ⊎-<-respectsˡ : ∼₁ Respectsˡ ≈₁ ∼₂ Respectsˡ ≈₂ + (∼₁ ⊎-< ∼₂) Respectsˡ (Pointwise ≈₁ ≈₂) + ⊎-<-respectsˡ resp₁ resp₂ (inj₁ x) ₁∼₂ = ₁∼₂ + ⊎-<-respectsˡ resp₁ resp₂ (inj₁ x) (₁∼₁ x∼₁y) = ₁∼₁ (resp₁ x x∼₁y) + ⊎-<-respectsˡ resp₁ resp₂ (inj₂ x) (₂∼₂ x∼₂y) = ₂∼₂ (resp₂ x x∼₂y) + + ⊎-<-respects₂ : ∼₁ Respects₂ ≈₁ ∼₂ Respects₂ ≈₂ + (∼₁ ⊎-< ∼₂) Respects₂ (Pointwise ≈₁ ≈₂) + ⊎-<-respects₂ (r₁ , l₁) (r₂ , l₂) = ⊎-<-respectsʳ r₁ r₂ , ⊎-<-respectsˡ l₁ l₂ + + ⊎-<-trichotomous : Trichotomous ≈₁ ∼₁ Trichotomous ≈₂ ∼₂ + Trichotomous (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-trichotomous tri₁ tri₂ (inj₁ x) (inj₂ y) = tri< ₁∼₂ (λ()) (λ()) + ⊎-<-trichotomous tri₁ tri₂ (inj₂ x) (inj₁ y) = tri> (λ()) (λ()) ₁∼₂ + ⊎-<-trichotomous tri₁ tri₂ (inj₁ x) (inj₁ y) with tri₁ x y + ... | tri< x<y x≉y x≯y = tri< (₁∼₁ x<y) (x≉y PW.drop-inj₁) (x≯y drop-inj₁) + ... | tri≈ x≮y x≈y x≯y = tri≈ (x≮y drop-inj₁) (inj₁ x≈y) (x≯y drop-inj₁) + ... | tri> x≮y x≉y x>y = tri> (x≮y drop-inj₁) (x≉y PW.drop-inj₁) (₁∼₁ x>y) + ⊎-<-trichotomous tri₁ tri₂ (inj₂ x) (inj₂ y) with tri₂ x y + ... | tri< x<y x≉y x≯y = tri< (₂∼₂ x<y) (x≉y PW.drop-inj₂) (x≯y drop-inj₂) + ... | tri≈ x≮y x≈y x≯y = tri≈ (x≮y drop-inj₂) (inj₂ x≈y) (x≯y drop-inj₂) + ... | tri> x≮y x≉y x>y = tri> (x≮y drop-inj₂) (x≉y PW.drop-inj₂) (₂∼₂ x>y) + +------------------------------------------------------------------------ +-- Some collections of properties which are preserved + +module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} + {ℓ₁ ℓ₂} {≈₁ : Rel A₁ ℓ₁} {∼₁ : Rel A₁ ℓ₂} + {ℓ₃ ℓ₄} {≈₂ : Rel A₂ ℓ₃} {∼₂ : Rel A₂ ℓ₄} where + + ⊎-<-isPreorder : IsPreorder ≈₁ ∼₁ IsPreorder ≈₂ ∼₂ + IsPreorder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-isPreorder pre₁ pre₂ = record + { isEquivalence = PW.⊎-isEquivalence (isEquivalence pre₁) (isEquivalence pre₂) + ; reflexive = ⊎-<-reflexive (reflexive pre₁) (reflexive pre₂) + ; trans = ⊎-<-transitive (trans pre₁) (trans pre₂) + } + where open IsPreorder + + ⊎-<-isPartialOrder : IsPartialOrder ≈₁ ∼₁ + IsPartialOrder ≈₂ ∼₂ + IsPartialOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-isPartialOrder po₁ po₂ = record + { isPreorder = ⊎-<-isPreorder (isPreorder po₁) (isPreorder po₂) + ; antisym = ⊎-<-antisymmetric (antisym po₁) (antisym po₂) + } + where open IsPartialOrder + + ⊎-<-isStrictPartialOrder : IsStrictPartialOrder ≈₁ ∼₁ + IsStrictPartialOrder ≈₂ ∼₂ + IsStrictPartialOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-isStrictPartialOrder spo₁ spo₂ = record + { isEquivalence = PW.⊎-isEquivalence (isEquivalence spo₁) (isEquivalence spo₂) + ; irrefl = ⊎-<-irreflexive (irrefl spo₁) (irrefl spo₂) + ; trans = ⊎-<-transitive (trans spo₁) (trans spo₂) + ; <-resp-≈ = ⊎-<-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂) + } + where open IsStrictPartialOrder + + ⊎-<-isTotalOrder : IsTotalOrder ≈₁ ∼₁ + IsTotalOrder ≈₂ ∼₂ + IsTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-isTotalOrder to₁ to₂ = record + { isPartialOrder = ⊎-<-isPartialOrder (isPartialOrder to₁) (isPartialOrder to₂) + ; total = ⊎-<-total (total to₁) (total to₂) + } + where open IsTotalOrder + + ⊎-<-isDecTotalOrder : IsDecTotalOrder ≈₁ ∼₁ + IsDecTotalOrder ≈₂ ∼₂ + IsDecTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-isDecTotalOrder to₁ to₂ = record + { isTotalOrder = ⊎-<-isTotalOrder (isTotalOrder to₁) (isTotalOrder to₂) + ; _≟_ = PW.⊎-decidable (_≟_ to₁) (_≟_ to₂) + ; _≤?_ = ⊎-<-decidable (_≤?_ to₁) (_≤?_ to₂) + } + where open IsDecTotalOrder + + ⊎-<-isStrictTotalOrder : IsStrictTotalOrder ≈₁ ∼₁ + IsStrictTotalOrder ≈₂ ∼₂ + IsStrictTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂) + ⊎-<-isStrictTotalOrder sto₁ sto₂ = record + { isStrictPartialOrder = ⊎-<-isStrictPartialOrder (isStrictPartialOrder sto₁) (isStrictPartialOrder sto₂) + ; compare = ⊎-<-trichotomous (compare sto₁) (compare sto₂) + } + where open IsStrictTotalOrder + +------------------------------------------------------------------------ +-- "Bundles" can also be combined. + +module _ {a b c d e f} where + + ⊎-<-preorder : Preorder a b c + Preorder d e f + Preorder _ _ _ + ⊎-<-preorder p₁ p₂ = record + { isPreorder = + ⊎-<-isPreorder (isPreorder p₁) (isPreorder p₂) + } where open Preorder + + ⊎-<-poset : Poset a b c + Poset a b c + Poset _ _ _ + ⊎-<-poset po₁ po₂ = record + { isPartialOrder = + ⊎-<-isPartialOrder (isPartialOrder po₁) (isPartialOrder po₂) + } where open Poset + + ⊎-<-strictPartialOrder : StrictPartialOrder a b c + StrictPartialOrder d e f + StrictPartialOrder _ _ _ + ⊎-<-strictPartialOrder spo₁ spo₂ = record + { isStrictPartialOrder = + ⊎-<-isStrictPartialOrder (isStrictPartialOrder spo₁) (isStrictPartialOrder spo₂) + } where open StrictPartialOrder + + ⊎-<-totalOrder : TotalOrder a b c + TotalOrder d e f + TotalOrder _ _ _ + ⊎-<-totalOrder to₁ to₂ = record + { isTotalOrder = ⊎-<-isTotalOrder (isTotalOrder to₁) (isTotalOrder to₂) + } where open TotalOrder + + ⊎-<-decTotalOrder : DecTotalOrder a b c + DecTotalOrder d e f + DecTotalOrder _ _ _ + ⊎-<-decTotalOrder to₁ to₂ = record + { isDecTotalOrder = ⊎-<-isDecTotalOrder (isDecTotalOrder to₁) (isDecTotalOrder to₂) + } where open DecTotalOrder + + ⊎-<-strictTotalOrder : StrictTotalOrder a b c + StrictTotalOrder a b c + StrictTotalOrder _ _ _ + ⊎-<-strictTotalOrder sto₁ sto₂ = record + { isStrictTotalOrder = ⊎-<-isStrictTotalOrder (isStrictTotalOrder sto₁) (isStrictTotalOrder sto₂) + } where open StrictTotalOrder \ No newline at end of file diff --git a/v2.3/Data.Sum.Relation.Binary.Pointwise.html b/v2.3/Data.Sum.Relation.Binary.Pointwise.html index 29c31f52bf..bc3fbc2835 100644 --- a/v2.3/Data.Sum.Relation.Binary.Pointwise.html +++ b/v2.3/Data.Sum.Relation.Binary.Pointwise.html @@ -11,209 +11,223 @@ open import Data.Product.Base using (_,_) open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂) -open import Level using (Level; _⊔_) -open import Function.Base using (const; _∘_; id) -open import Function.Bundles using (Inverse; mk↔) -open import Relation.Nullary.Decidable.Core as Dec using (yes; no; map′) -open import Relation.Nullary.Negation.Core using (¬_) -open import Relation.Binary -open import Relation.Binary.PropositionalEquality.Core as using (_≡_) -import Relation.Binary.PropositionalEquality.Properties as - -private - variable - a b c d ℓ₁ ℓ₂ ℓ₃ : Level - A B C D : Set - R S T U : REL A B - ≈₁ ≈₂ : Rel A - ------------------------------------------------------------------------- --- Definition - -data Pointwise {A : Set a} {B : Set b} {C : Set c} {D : Set d} - (R : REL A C ℓ₁) (S : REL B D ℓ₂) - : REL (A B) (C D) (a b c d ℓ₁ ℓ₂) where - inj₁ : {a c} R a c Pointwise R S (inj₁ a) (inj₁ c) - inj₂ : {b d} S b d Pointwise R S (inj₂ b) (inj₂ d) - ----------------------------------------------------------------------- --- Functions - -map : {f : A C} {g : B D} - R =[ f ]⇒ T S =[ g ]⇒ U - Pointwise R S =[ Sum.map f g ]⇒ Pointwise T U -map R⇒T _ (inj₁ x) = inj₁ (R⇒T x) -map _ S⇒U (inj₂ x) = inj₂ (S⇒U x) - ------------------------------------------------------------------------- --- Relational properties - -drop-inj₁ : {x y} Pointwise R S (inj₁ x) (inj₁ y) R x y -drop-inj₁ (inj₁ x) = x - -drop-inj₂ : {x y} Pointwise R S (inj₂ x) (inj₂ y) S x y -drop-inj₂ (inj₂ x) = x - -⊎-refl : Reflexive R Reflexive S Reflexive (Pointwise R S) -⊎-refl refl₁ refl₂ {inj₁ x} = inj₁ refl₁ -⊎-refl refl₁ refl₂ {inj₂ y} = inj₂ refl₂ - -⊎-symmetric : Symmetric R Symmetric S - Symmetric (Pointwise R S) -⊎-symmetric sym₁ sym₂ (inj₁ x) = inj₁ (sym₁ x) -⊎-symmetric sym₁ sym₂ (inj₂ x) = inj₂ (sym₂ x) - -⊎-transitive : Transitive R Transitive S - Transitive (Pointwise R S) -⊎-transitive trans₁ trans₂ (inj₁ x) (inj₁ y) = inj₁ (trans₁ x y) -⊎-transitive trans₁ trans₂ (inj₂ x) (inj₂ y) = inj₂ (trans₂ x y) - -⊎-asymmetric : Asymmetric R Asymmetric S - Asymmetric (Pointwise R S) -⊎-asymmetric asym₁ asym₂ (inj₁ x) = λ { (inj₁ y) asym₁ x y } -⊎-asymmetric asym₁ asym₂ (inj₂ x) = λ { (inj₂ y) asym₂ x y } - -⊎-substitutive : Substitutive R ℓ₃ Substitutive S ℓ₃ - Substitutive (Pointwise R S) ℓ₃ -⊎-substitutive subst₁ subst₂ P (inj₁ x) = subst₁ (P inj₁) x -⊎-substitutive subst₁ subst₂ P (inj₂ x) = subst₂ (P inj₂) x - -⊎-decidable : Decidable R Decidable S Decidable (Pointwise R S) -⊎-decidable _≟₁_ _≟₂_ (inj₁ x) (inj₁ y) = Dec.map′ inj₁ drop-inj₁ (x ≟₁ y) -⊎-decidable _≟₁_ _≟₂_ (inj₁ x) (inj₂ y) = no λ() -⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₁ y) = no λ() -⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₂ y) = Dec.map′ inj₂ drop-inj₂ (x ≟₂ y) - -⊎-reflexive : ≈₁ R ≈₂ S - (Pointwise ≈₁ ≈₂) (Pointwise R S) -⊎-reflexive refl₁ refl₂ (inj₁ x) = inj₁ (refl₁ x) -⊎-reflexive refl₁ refl₂ (inj₂ x) = inj₂ (refl₂ x) - -⊎-irreflexive : Irreflexive ≈₁ R Irreflexive ≈₂ S - Irreflexive (Pointwise ≈₁ ≈₂) (Pointwise R S) -⊎-irreflexive irrefl₁ irrefl₂ (inj₁ x) (inj₁ y) = irrefl₁ x y -⊎-irreflexive irrefl₁ irrefl₂ (inj₂ x) (inj₂ y) = irrefl₂ x y - -⊎-antisymmetric : Antisymmetric ≈₁ R Antisymmetric ≈₂ S - Antisymmetric (Pointwise ≈₁ ≈₂) (Pointwise R S) -⊎-antisymmetric antisym₁ antisym₂ (inj₁ x) (inj₁ y) = inj₁ (antisym₁ x y) -⊎-antisymmetric antisym₁ antisym₂ (inj₂ x) (inj₂ y) = inj₂ (antisym₂ x y) - -⊎-respectsˡ : R Respectsˡ ≈₁ S Respectsˡ ≈₂ - (Pointwise R S) Respectsˡ (Pointwise ≈₁ ≈₂) -⊎-respectsˡ resp₁ resp₂ (inj₁ x) (inj₁ y) = inj₁ (resp₁ x y) -⊎-respectsˡ resp₁ resp₂ (inj₂ x) (inj₂ y) = inj₂ (resp₂ x y) - -⊎-respectsʳ : R Respectsʳ ≈₁ S Respectsʳ ≈₂ - (Pointwise R S) Respectsʳ (Pointwise ≈₁ ≈₂) -⊎-respectsʳ resp₁ resp₂ (inj₁ x) (inj₁ y) = inj₁ (resp₁ x y) -⊎-respectsʳ resp₁ resp₂ (inj₂ x) (inj₂ y) = inj₂ (resp₂ x y) - -⊎-respects₂ : R Respects₂ ≈₁ S Respects₂ ≈₂ - (Pointwise R S) Respects₂ (Pointwise ≈₁ ≈₂) -⊎-respects₂ (r₁ , l₁) (r₂ , l₂) = ⊎-respectsʳ r₁ r₂ , ⊎-respectsˡ l₁ l₂ - ------------------------------------------------------------------------- --- Structures - -⊎-isEquivalence : IsEquivalence ≈₁ IsEquivalence ≈₂ - IsEquivalence (Pointwise ≈₁ ≈₂) -⊎-isEquivalence eq₁ eq₂ = record - { refl = ⊎-refl (refl eq₁) (refl eq₂) - ; sym = ⊎-symmetric (sym eq₁) (sym eq₂) - ; trans = ⊎-transitive (trans eq₁) (trans eq₂) - } where open IsEquivalence - -⊎-isDecEquivalence : IsDecEquivalence ≈₁ IsDecEquivalence ≈₂ - IsDecEquivalence (Pointwise ≈₁ ≈₂) -⊎-isDecEquivalence eq₁ eq₂ = record - { isEquivalence = - ⊎-isEquivalence (isEquivalence eq₁) (isEquivalence eq₂) - ; _≟_ = ⊎-decidable (_≟_ eq₁) (_≟_ eq₂) - } where open IsDecEquivalence - -⊎-isPreorder : IsPreorder ≈₁ R IsPreorder ≈₂ S - IsPreorder (Pointwise ≈₁ ≈₂) (Pointwise R S) -⊎-isPreorder pre₁ pre₂ = record - { isEquivalence = - ⊎-isEquivalence (isEquivalence pre₁) (isEquivalence pre₂) - ; reflexive = ⊎-reflexive (reflexive pre₁) (reflexive pre₂) - ; trans = ⊎-transitive (trans pre₁) (trans pre₂) - } where open IsPreorder - -⊎-isPartialOrder : IsPartialOrder ≈₁ R IsPartialOrder ≈₂ S - IsPartialOrder - (Pointwise ≈₁ ≈₂) (Pointwise R S) -⊎-isPartialOrder po₁ po₂ = record - { isPreorder = ⊎-isPreorder (isPreorder po₁) (isPreorder po₂) - ; antisym = ⊎-antisymmetric (antisym po₁) (antisym po₂) - } where open IsPartialOrder - -⊎-isStrictPartialOrder : IsStrictPartialOrder ≈₁ R - IsStrictPartialOrder ≈₂ S - IsStrictPartialOrder - (Pointwise ≈₁ ≈₂) (Pointwise R S) -⊎-isStrictPartialOrder spo₁ spo₂ = record - { isEquivalence = - ⊎-isEquivalence (isEquivalence spo₁) (isEquivalence spo₂) - ; irrefl = ⊎-irreflexive (irrefl spo₁) (irrefl spo₂) - ; trans = ⊎-transitive (trans spo₁) (trans spo₂) - ; <-resp-≈ = ⊎-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂) - } where open IsStrictPartialOrder - ------------------------------------------------------------------------- --- Bundles - -⊎-setoid : Setoid a b Setoid c d Setoid _ _ -⊎-setoid s₁ s₂ = record - { isEquivalence = - ⊎-isEquivalence (isEquivalence s₁) (isEquivalence s₂) - } where open Setoid - -⊎-decSetoid : DecSetoid a b DecSetoid c d DecSetoid _ _ -⊎-decSetoid ds₁ ds₂ = record - { isDecEquivalence = - ⊎-isDecEquivalence (isDecEquivalence ds₁) (isDecEquivalence ds₂) - } where open DecSetoid - -⊎-preorder : Preorder a b ℓ₁ Preorder c d ℓ₂ Preorder _ _ _ -⊎-preorder p₁ p₂ = record - { isPreorder = - ⊎-isPreorder (isPreorder p₁) (isPreorder p₂) - } where open Preorder - -⊎-poset : Poset a b c Poset a b c Poset _ _ _ -⊎-poset po₁ po₂ = record - { isPartialOrder = - ⊎-isPartialOrder (isPartialOrder po₁) (isPartialOrder po₂) - } where open Poset - ------------------------------------------------------------------------- --- Additional notation - --- Infix combining setoids -infix 4 _⊎ₛ_ -_⊎ₛ_ : Setoid a b Setoid c d Setoid _ _ -_⊎ₛ_ = ⊎-setoid - ------------------------------------------------------------------------- --- The propositional equality setoid over products can be --- decomposed using Pointwise - -Pointwise-≡⇒≡ : (Pointwise _≡_ _≡_) _≡_ {A = A B} -Pointwise-≡⇒≡ (inj₁ x) = ≡.cong inj₁ x -Pointwise-≡⇒≡ (inj₂ x) = ≡.cong inj₂ x - -≡⇒Pointwise-≡ : _≡_ {A = A B} (Pointwise _≡_ _≡_) -≡⇒Pointwise-≡ ≡.refl = ⊎-refl ≡.refl ≡.refl - -Pointwise-≡↔≡ : (A : Set a) (B : Set b) - Inverse (≡.setoid A ⊎ₛ ≡.setoid B) (≡.setoid (A B)) -Pointwise-≡↔≡ _ _ = record - { to = id - ; from = id - ; to-cong = Pointwise-≡⇒≡ - ; from-cong = ≡⇒Pointwise-≡ - ; inverse = Pointwise-≡⇒≡ , ≡⇒Pointwise-≡ - } +open import Induction.WellFounded +open import Level using (Level; _⊔_) +open import Function.Base using (const; _∘_; id) +open import Function.Bundles using (Inverse; mk↔) +open import Relation.Nullary.Decidable.Core as Dec using (yes; no; map′) +open import Relation.Nullary.Negation.Core using (¬_) +open import Relation.Binary +open import Relation.Binary.PropositionalEquality.Core as using (_≡_) +import Relation.Binary.PropositionalEquality.Properties as + +private + variable + a b c d ℓ₁ ℓ₂ ℓ₃ : Level + A B C D : Set + R S T U : REL A B + ≈₁ ≈₂ : Rel A + +------------------------------------------------------------------------ +-- Definition + +data Pointwise {A : Set a} {B : Set b} {C : Set c} {D : Set d} + (R : REL A C ℓ₁) (S : REL B D ℓ₂) + : REL (A B) (C D) (a b c d ℓ₁ ℓ₂) where + inj₁ : {a c} R a c Pointwise R S (inj₁ a) (inj₁ c) + inj₂ : {b d} S b d Pointwise R S (inj₂ b) (inj₂ d) + +---------------------------------------------------------------------- +-- Functions + +map : {f : A C} {g : B D} + R =[ f ]⇒ T S =[ g ]⇒ U + Pointwise R S =[ Sum.map f g ]⇒ Pointwise T U +map R⇒T _ (inj₁ x) = inj₁ (R⇒T x) +map _ S⇒U (inj₂ x) = inj₂ (S⇒U x) + +------------------------------------------------------------------------ +-- Relational properties + +drop-inj₁ : {x y} Pointwise R S (inj₁ x) (inj₁ y) R x y +drop-inj₁ (inj₁ x) = x + +drop-inj₂ : {x y} Pointwise R S (inj₂ x) (inj₂ y) S x y +drop-inj₂ (inj₂ x) = x + +⊎-refl : Reflexive R Reflexive S Reflexive (Pointwise R S) +⊎-refl refl₁ refl₂ {inj₁ x} = inj₁ refl₁ +⊎-refl refl₁ refl₂ {inj₂ y} = inj₂ refl₂ + +⊎-symmetric : Symmetric R Symmetric S + Symmetric (Pointwise R S) +⊎-symmetric sym₁ sym₂ (inj₁ x) = inj₁ (sym₁ x) +⊎-symmetric sym₁ sym₂ (inj₂ x) = inj₂ (sym₂ x) + +⊎-transitive : Transitive R Transitive S + Transitive (Pointwise R S) +⊎-transitive trans₁ trans₂ (inj₁ x) (inj₁ y) = inj₁ (trans₁ x y) +⊎-transitive trans₁ trans₂ (inj₂ x) (inj₂ y) = inj₂ (trans₂ x y) + +⊎-asymmetric : Asymmetric R Asymmetric S + Asymmetric (Pointwise R S) +⊎-asymmetric asym₁ asym₂ (inj₁ x) = λ { (inj₁ y) asym₁ x y } +⊎-asymmetric asym₁ asym₂ (inj₂ x) = λ { (inj₂ y) asym₂ x y } + +⊎-substitutive : Substitutive R ℓ₃ Substitutive S ℓ₃ + Substitutive (Pointwise R S) ℓ₃ +⊎-substitutive subst₁ subst₂ P (inj₁ x) = subst₁ (P inj₁) x +⊎-substitutive subst₁ subst₂ P (inj₂ x) = subst₂ (P inj₂) x + +⊎-decidable : Decidable R Decidable S Decidable (Pointwise R S) +⊎-decidable _≟₁_ _≟₂_ (inj₁ x) (inj₁ y) = Dec.map′ inj₁ drop-inj₁ (x ≟₁ y) +⊎-decidable _≟₁_ _≟₂_ (inj₁ x) (inj₂ y) = no λ() +⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₁ y) = no λ() +⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₂ y) = Dec.map′ inj₂ drop-inj₂ (x ≟₂ y) + +⊎-reflexive : ≈₁ R ≈₂ S + (Pointwise ≈₁ ≈₂) (Pointwise R S) +⊎-reflexive refl₁ refl₂ (inj₁ x) = inj₁ (refl₁ x) +⊎-reflexive refl₁ refl₂ (inj₂ x) = inj₂ (refl₂ x) + +⊎-irreflexive : Irreflexive ≈₁ R Irreflexive ≈₂ S + Irreflexive (Pointwise ≈₁ ≈₂) (Pointwise R S) +⊎-irreflexive irrefl₁ irrefl₂ (inj₁ x) (inj₁ y) = irrefl₁ x y +⊎-irreflexive irrefl₁ irrefl₂ (inj₂ x) (inj₂ y) = irrefl₂ x y + +⊎-wellFounded : WellFounded ≈₁ WellFounded ≈₂ WellFounded (Pointwise ≈₁ ≈₂) +⊎-wellFounded {≈₁ = ≈₁} {≈₂ = ≈₂} wf₁ wf₂ x = acc (⊎-acc x) + where + ⊎-acc₁ : {x} Acc ≈₁ x WfRec (Pointwise ≈₁ ≈₂) (Acc (Pointwise ≈₁ ≈₂)) (inj₁ x) + ⊎-acc₁ (acc rec) (inj₁ x≈₁y) = acc (⊎-acc₁ (rec x≈₁y)) + + ⊎-acc₂ : {x} Acc ≈₂ x WfRec (Pointwise ≈₁ ≈₂) (Acc (Pointwise ≈₁ ≈₂)) (inj₂ x) + ⊎-acc₂ (acc rec) (inj₂ x≈₂y) = acc (⊎-acc₂ (rec x≈₂y)) + + ⊎-acc : x WfRec (Pointwise ≈₁ ≈₂) (Acc (Pointwise ≈₁ ≈₂)) x + ⊎-acc (inj₁ x) = ⊎-acc₁ (wf₁ x) + ⊎-acc (inj₂ x) = ⊎-acc₂ (wf₂ x) + +⊎-antisymmetric : Antisymmetric ≈₁ R Antisymmetric ≈₂ S + Antisymmetric (Pointwise ≈₁ ≈₂) (Pointwise R S) +⊎-antisymmetric antisym₁ antisym₂ (inj₁ x) (inj₁ y) = inj₁ (antisym₁ x y) +⊎-antisymmetric antisym₁ antisym₂ (inj₂ x) (inj₂ y) = inj₂ (antisym₂ x y) + +⊎-respectsˡ : R Respectsˡ ≈₁ S Respectsˡ ≈₂ + (Pointwise R S) Respectsˡ (Pointwise ≈₁ ≈₂) +⊎-respectsˡ resp₁ resp₂ (inj₁ x) (inj₁ y) = inj₁ (resp₁ x y) +⊎-respectsˡ resp₁ resp₂ (inj₂ x) (inj₂ y) = inj₂ (resp₂ x y) + +⊎-respectsʳ : R Respectsʳ ≈₁ S Respectsʳ ≈₂ + (Pointwise R S) Respectsʳ (Pointwise ≈₁ ≈₂) +⊎-respectsʳ resp₁ resp₂ (inj₁ x) (inj₁ y) = inj₁ (resp₁ x y) +⊎-respectsʳ resp₁ resp₂ (inj₂ x) (inj₂ y) = inj₂ (resp₂ x y) + +⊎-respects₂ : R Respects₂ ≈₁ S Respects₂ ≈₂ + (Pointwise R S) Respects₂ (Pointwise ≈₁ ≈₂) +⊎-respects₂ (r₁ , l₁) (r₂ , l₂) = ⊎-respectsʳ r₁ r₂ , ⊎-respectsˡ l₁ l₂ + +------------------------------------------------------------------------ +-- Structures + +⊎-isEquivalence : IsEquivalence ≈₁ IsEquivalence ≈₂ + IsEquivalence (Pointwise ≈₁ ≈₂) +⊎-isEquivalence eq₁ eq₂ = record + { refl = ⊎-refl (refl eq₁) (refl eq₂) + ; sym = ⊎-symmetric (sym eq₁) (sym eq₂) + ; trans = ⊎-transitive (trans eq₁) (trans eq₂) + } where open IsEquivalence + +⊎-isDecEquivalence : IsDecEquivalence ≈₁ IsDecEquivalence ≈₂ + IsDecEquivalence (Pointwise ≈₁ ≈₂) +⊎-isDecEquivalence eq₁ eq₂ = record + { isEquivalence = + ⊎-isEquivalence (isEquivalence eq₁) (isEquivalence eq₂) + ; _≟_ = ⊎-decidable (_≟_ eq₁) (_≟_ eq₂) + } where open IsDecEquivalence + +⊎-isPreorder : IsPreorder ≈₁ R IsPreorder ≈₂ S + IsPreorder (Pointwise ≈₁ ≈₂) (Pointwise R S) +⊎-isPreorder pre₁ pre₂ = record + { isEquivalence = + ⊎-isEquivalence (isEquivalence pre₁) (isEquivalence pre₂) + ; reflexive = ⊎-reflexive (reflexive pre₁) (reflexive pre₂) + ; trans = ⊎-transitive (trans pre₁) (trans pre₂) + } where open IsPreorder + +⊎-isPartialOrder : IsPartialOrder ≈₁ R IsPartialOrder ≈₂ S + IsPartialOrder + (Pointwise ≈₁ ≈₂) (Pointwise R S) +⊎-isPartialOrder po₁ po₂ = record + { isPreorder = ⊎-isPreorder (isPreorder po₁) (isPreorder po₂) + ; antisym = ⊎-antisymmetric (antisym po₁) (antisym po₂) + } where open IsPartialOrder + +⊎-isStrictPartialOrder : IsStrictPartialOrder ≈₁ R + IsStrictPartialOrder ≈₂ S + IsStrictPartialOrder + (Pointwise ≈₁ ≈₂) (Pointwise R S) +⊎-isStrictPartialOrder spo₁ spo₂ = record + { isEquivalence = + ⊎-isEquivalence (isEquivalence spo₁) (isEquivalence spo₂) + ; irrefl = ⊎-irreflexive (irrefl spo₁) (irrefl spo₂) + ; trans = ⊎-transitive (trans spo₁) (trans spo₂) + ; <-resp-≈ = ⊎-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂) + } where open IsStrictPartialOrder + +------------------------------------------------------------------------ +-- Bundles + +⊎-setoid : Setoid a b Setoid c d Setoid _ _ +⊎-setoid s₁ s₂ = record + { isEquivalence = + ⊎-isEquivalence (isEquivalence s₁) (isEquivalence s₂) + } where open Setoid + +⊎-decSetoid : DecSetoid a b DecSetoid c d DecSetoid _ _ +⊎-decSetoid ds₁ ds₂ = record + { isDecEquivalence = + ⊎-isDecEquivalence (isDecEquivalence ds₁) (isDecEquivalence ds₂) + } where open DecSetoid + +⊎-preorder : Preorder a b ℓ₁ Preorder c d ℓ₂ Preorder _ _ _ +⊎-preorder p₁ p₂ = record + { isPreorder = + ⊎-isPreorder (isPreorder p₁) (isPreorder p₂) + } where open Preorder + +⊎-poset : Poset a b c Poset a b c Poset _ _ _ +⊎-poset po₁ po₂ = record + { isPartialOrder = + ⊎-isPartialOrder (isPartialOrder po₁) (isPartialOrder po₂) + } where open Poset + +------------------------------------------------------------------------ +-- Additional notation + +-- Infix combining setoids +infix 4 _⊎ₛ_ +_⊎ₛ_ : Setoid a b Setoid c d Setoid _ _ +_⊎ₛ_ = ⊎-setoid + +------------------------------------------------------------------------ +-- The propositional equality setoid over products can be +-- decomposed using Pointwise + +Pointwise-≡⇒≡ : (Pointwise _≡_ _≡_) _≡_ {A = A B} +Pointwise-≡⇒≡ (inj₁ x) = ≡.cong inj₁ x +Pointwise-≡⇒≡ (inj₂ x) = ≡.cong inj₂ x + +≡⇒Pointwise-≡ : _≡_ {A = A B} (Pointwise _≡_ _≡_) +≡⇒Pointwise-≡ ≡.refl = ⊎-refl ≡.refl ≡.refl + +Pointwise-≡↔≡ : (A : Set a) (B : Set b) + Inverse (≡.setoid A ⊎ₛ ≡.setoid B) (≡.setoid (A B)) +Pointwise-≡↔≡ _ _ = record + { to = id + ; from = id + ; to-cong = Pointwise-≡⇒≡ + ; from-cong = ≡⇒Pointwise-≡ + ; inverse = Pointwise-≡⇒≡ , ≡⇒Pointwise-≡ + } \ No newline at end of file diff --git a/v2.3/Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties.html b/v2.3/Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties.html index d455c24c8a..033a606727 100644 --- a/v2.3/Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties.html +++ b/v2.3/Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties.html @@ -23,7 +23,7 @@ open import Level using (Level) open import Relation.Binary.Definitions using (_Respects_; tri<; tri≈; tri>) open import Relation.Binary.PropositionalEquality.Core using (_≡_) renaming (refl to ≡-refl) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Decidable.Core as Dec using (Dec; yes; no) open import Relation.Unary using (Pred; _∩_) @@ -256,7 +256,7 @@ Any-insertWith-nothing (leaf l<u) seg pr ¬p = here pr Any-insertWith-nothing (node kv@(k′ , v) lk ku bal) (l<k , k<u) pr ¬p with compare k k′ - ... | tri≈ _ k≈k′ _ = contradiction (here k≈k′) ¬p + ... | tri≈ _ k≈k′ _ = contradiction (here k≈k′) ¬p ... | tri< k<k′ _ _ = let seg′ = l<k , [ k<k′ ]ᴿ; lk′ = insertWith k f lk seg′ ih = Any-insertWith-nothing lk seg′ pr p ¬p (left p)) in joinˡ⁺-left⁺ kv lk′ ku bal ih @@ -328,7 +328,7 @@ with compare k k′ ... | tri< k<k′ _ _ = let l′ = insertWith k f l (l<k , [ k<k′ ]ᴿ) in joinˡ⁺-here⁺ kv l′ r bal p - ... | tri≈ _ k≈k′ _ = contradiction k≈k′ k≉ + ... | tri≈ _ k≈k′ _ = contradiction k≈k′ k≉ ... | tri> _ _ k′<k = let r′ = insertWith k f r ([ k′<k ]ᴿ , k<u) in joinʳ⁺-here⁺ kv l r′ bal p insertWith⁺ (node kv@(k′ , v′) l r bal) (l<k , k<u) (left p) k≉ diff --git a/v2.3/Data.Tree.AVL.Map.Membership.Propositional.Properties.html b/v2.3/Data.Tree.AVL.Map.Membership.Propositional.Properties.html index 4e90225d40..2d2795cf16 100644 --- a/v2.3/Data.Tree.AVL.Map.Membership.Propositional.Properties.html +++ b/v2.3/Data.Tree.AVL.Map.Membership.Propositional.Properties.html @@ -31,7 +31,7 @@ using (_≡_; cong) renaming (refl to ≡-refl; sym to ≡-sym; trans to ≡-trans) open import Relation.Nullary.Reflects using (Reflects) open import Relation.Nullary.Decidable.Core using (yes; no) -open import Relation.Nullary.Negation.Core using (contradiction; ¬_) +open import Relation.Nullary.Negation.Core using (contradiction; ¬_) open StrictTotalOrder strictTotalOrder renaming (Carrier to Key) hiding (trans) open Eq using (refl; sym; trans) @@ -115,7 +115,7 @@ ∈ₖᵥ-lookup⁺ : (k , x) ∈ₖᵥ m lookup m k just x ∈ₖᵥ-lookup⁺ {k = k} {m = tree t} (tree kx∈m) with IAnyₚ.lookup⁺ t k (⊥⁺<[ _ ]<⊤⁺) kx∈m | IAnyₚ.lookup-result kx∈m -... | inj₁ p≉k | k≈p , x≡p = contradiction (sym k≈p) p≉k +... | inj₁ p≉k | k≈p , x≡p = contradiction (sym k≈p) p≉k ... | inj₂ (p≈k , eq) | k≈p , x≡p = ≡-trans eq (cong just (≡-sym x≡p)) ∈ₖᵥ-lookup⁻ : lookup m k just x (k , x) ∈ₖᵥ m @@ -125,7 +125,7 @@ ∈ₖᵥ-lookup-nothing⁺ : (∀ x (k , x) ∉ₖᵥ m) lookup m k nothing ∈ₖᵥ-lookup-nothing⁺ {k = k} {m = m@(tree t)} k∉m with lookup m k in eq ... | nothing = ≡-refl -... | just x = contradiction (∈ₖᵥ-lookup⁻ eq) (k∉m x) +... | just x = contradiction (∈ₖᵥ-lookup⁻ eq) (k∉m x) ∈ₖᵥ-lookup-nothing⁻ : lookup m k nothing (k , x) ∉ₖᵥ m ∈ₖᵥ-lookup-nothing⁻ eq kx∈m with ≡-trans (≡-sym eq) (∈ₖᵥ-lookup⁺ kx∈m) diff --git a/v2.3/Data.Tree.Binary.Zipper.Properties.html b/v2.3/Data.Tree.Binary.Zipper.Properties.html index 226d341d91..4046a57424 100644 --- a/v2.3/Data.Tree.Binary.Zipper.Properties.html +++ b/v2.3/Data.Tree.Binary.Zipper.Properties.html @@ -13,7 +13,7 @@ open import Data.Maybe.Base using (Maybe; just; nothing) open import Data.Maybe.Relation.Unary.All using (All; just; nothing) open import Data.Nat.Base using (; suc; _+_) -open import Data.Nat.Properties using (+-identityʳ; +-comm; +-assoc) +open import Data.Nat.Properties using (+-identityʳ; +-comm; +-assoc) open import Data.Nat.ListAction using (sum) open import Data.Tree.Binary as BT using (Tree; node; leaf) open import Data.Tree.Binary.Zipper using (Zipper; toTree; up; mkZipper; @@ -62,23 +62,23 @@ helper : (cs : List (Crumb N L)) (t : Tree N L) #nodes (mkZipper cs t) BT.#nodes (toTree (mkZipper cs t)) - helper [] foc = +-identityʳ (BT.#nodes foc) + helper [] foc = +-identityʳ (BT.#nodes foc) helper cs@(leftBranch m l ctx) foc = let #ctx = sum (List.map (suc BT.#nodes getTree) ctx) #foc = BT.#nodes foc #l = BT.#nodes l in begin - #foc + (1 + (#l + #ctx)) ≡⟨ +-assoc #foc 1 (#l + #ctx) - #foc + 1 + (#l + #ctx) ≡⟨ cong (_+ (#l + #ctx)) (+-comm #foc 1) - 1 + #foc + (#l + #ctx) ≡⟨ +-assoc (1 + #foc) #l #ctx - 1 + #foc + #l + #ctx ≡⟨ cong (_+ #ctx) (+-comm (1 + #foc) #l) + #foc + (1 + (#l + #ctx)) ≡⟨ +-assoc #foc 1 (#l + #ctx) + #foc + 1 + (#l + #ctx) ≡⟨ cong (_+ (#l + #ctx)) (+-comm #foc 1) + 1 + #foc + (#l + #ctx) ≡⟨ +-assoc (1 + #foc) #l #ctx + 1 + #foc + #l + #ctx ≡⟨ cong (_+ #ctx) (+-comm (1 + #foc) #l) #nodes (mkZipper ctx (node l m foc)) ≡⟨ helper ctx (node l m foc) BT.#nodes (toTree (mkZipper cs foc)) helper cs@(rightBranch m r ctx) foc = let #ctx = sum (List.map (suc BT.#nodes getTree) ctx) #foc = BT.#nodes foc #r = BT.#nodes r in begin - #foc + (1 + (#r + #ctx)) ≡⟨ cong (#foc +_) (+-assoc 1 #r #ctx) - #foc + (1 + #r + #ctx) ≡⟨ +-assoc #foc (suc #r) #ctx + #foc + (1 + (#r + #ctx)) ≡⟨ cong (#foc +_) (+-assoc 1 #r #ctx) + #foc + (1 + #r + #ctx) ≡⟨ +-assoc #foc (suc #r) #ctx #nodes (mkZipper ctx (node foc m r)) ≡⟨ helper ctx (node foc m r) BT.#nodes (toTree (mkZipper cs foc)) @@ -88,20 +88,20 @@ helper : (cs : List (Crumb N L)) (t : Tree N L) #leaves (mkZipper cs t) BT.#leaves (toTree (mkZipper cs t)) - helper [] foc = +-identityʳ (BT.#leaves foc) + helper [] foc = +-identityʳ (BT.#leaves foc) helper cs@(leftBranch m l ctx) foc = let #ctx = sum (List.map (BT.#leaves getTree) ctx) #foc = BT.#leaves foc #l = BT.#leaves l in begin - #foc + (#l + #ctx) ≡⟨ +-assoc #foc #l #ctx - #foc + #l + #ctx ≡⟨ cong (_+ #ctx) (+-comm #foc #l) + #foc + (#l + #ctx) ≡⟨ +-assoc #foc #l #ctx + #foc + #l + #ctx ≡⟨ cong (_+ #ctx) (+-comm #foc #l) #leaves (mkZipper ctx (node l m foc)) ≡⟨ helper ctx (node l m foc) BT.#leaves (toTree (mkZipper cs foc)) helper cs@(rightBranch m r ctx) foc = let #ctx = sum (List.map (BT.#leaves getTree) ctx) #foc = BT.#leaves foc #r = BT.#leaves r in begin - #foc + (#r + #ctx) ≡⟨ +-assoc #foc #r #ctx + #foc + (#r + #ctx) ≡⟨ +-assoc #foc #r #ctx #leaves (mkZipper ctx (node foc m r)) ≡⟨ helper ctx (node foc m r) BT.#leaves (toTree (mkZipper cs foc)) diff --git a/v2.3/Data.Vec.Bounded.Base.html b/v2.3/Data.Vec.Bounded.Base.html index 1abd595ee6..b8af67cf2f 100644 --- a/v2.3/Data.Vec.Bounded.Base.html +++ b/v2.3/Data.Vec.Bounded.Base.html @@ -26,7 +26,7 @@ open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning) -open import Data.List.Extrema ℕ.≤-totalOrder +open import Data.List.Extrema ℕ.≤-totalOrder private variable @@ -48,7 +48,7 @@ -- projection to recompute irrelevant field isBounded : (as : Vec≤ A n) Vec≤.length as n -isBounded as@(_ , m≤n) = recompute (_ ℕ.≤? _) m≤n +isBounded as@(_ , m≤n) = recompute (_ ℕ.≤? _) m≤n ------------------------------------------------------------------------ -- Conversion functions @@ -57,32 +57,32 @@ toVec as@(vs , _) = vs fromVec : Vec A n Vec≤ A n -fromVec v = v , ℕ.≤-refl +fromVec v = v , ℕ.≤-refl padRight : A Vec≤ A n Vec A n padRight a as@(vs , m≤n) - with k , reflℕ.m≤n⇒∃[o]m+o≡n m≤n + with k , reflℕ.m≤n⇒∃[o]m+o≡n m≤n = vs Vec.++ Vec.replicate k a padLeft : A Vec≤ A n Vec A n padLeft a record { length = m ; vec = vs ; bound = m≤n } - with k , reflℕ.m≤n⇒∃[o]m+o≡n m≤n - rewrite ℕ.+-comm m k + with k , reflℕ.m≤n⇒∃[o]m+o≡n m≤n + rewrite ℕ.+-comm m k = Vec.replicate k a Vec.++ vs private split : m k m + k k /2⌋ + (m + k /2⌉) split m k = begin - m + k ≡⟨ ≡.cong (m +_) (ℕ.⌊n/2⌋+⌈n/2⌉≡n k) - m + ( k /2⌋ + k /2⌉) ≡⟨ ≡.cong (m +_) (ℕ.+-comm k /2⌋ k /2⌉) - m + ( k /2⌉ + k /2⌋) ≡⟨ ℕ.+-assoc m k /2⌉ k /2⌋ - m + k /2⌉ + k /2⌋ ≡⟨ ℕ.+-comm _ k /2⌋ + m + k ≡⟨ ≡.cong (m +_) (ℕ.⌊n/2⌋+⌈n/2⌉≡n k) + m + ( k /2⌋ + k /2⌉) ≡⟨ ≡.cong (m +_) (ℕ.+-comm k /2⌋ k /2⌉) + m + ( k /2⌉ + k /2⌋) ≡⟨ ℕ.+-assoc m k /2⌉ k /2⌋ + m + k /2⌉ + k /2⌋ ≡⟨ ℕ.+-comm _ k /2⌋ k /2⌋ + (m + k /2⌉) where open ≡-Reasoning padBoth : A A Vec≤ A n Vec A n padBoth aₗ aᵣ record { length = m ; vec = vs ; bound = m≤n } - with k , reflℕ.m≤n⇒∃[o]m+o≡n m≤n + with k , reflℕ.m≤n⇒∃[o]m+o≡n m≤n rewrite split m k = Vec.replicate k /2⌋ aₗ Vec.++ vs @@ -112,10 +112,10 @@ -- Modifying Vec≤ vectors ≤-cast : .(m≤n : m n) Vec≤ A m Vec≤ A n -≤-cast m≤n (v , p) = v , ℕ.≤-trans p m≤n +≤-cast m≤n (v , p) = v , ℕ.≤-trans p m≤n ≡-cast : .(eq : m n) Vec≤ A m Vec≤ A n -≡-cast m≡n = ≤-cast (ℕ.≤-reflexive m≡n) +≡-cast m≡n = ≤-cast (ℕ.≤-reflexive m≡n) map : (A B) Vec≤ A n Vec≤ B n map f (v , p) = Vec.map f v , p @@ -129,7 +129,7 @@ alignWith f (as , p) (bs , q) = Vec.alignWith f as bs , ℕ.⊔-lub p q zipWith : (A B C) Vec≤ A n Vec≤ B n Vec≤ C n -zipWith f (as , p) (bs , q) = Vec.restrictWith f as bs , ℕ.m≤n⇒m⊓o≤n _ p +zipWith f (as , p) (bs , q) = Vec.restrictWith f as bs , ℕ.m≤n⇒m⊓o≤n _ p zip : Vec≤ A n Vec≤ B n Vec≤ (A × B) n zip = zipWith _,_ diff --git a/v2.3/Data.Vec.Functional.Properties.html b/v2.3/Data.Vec.Functional.Properties.html index eb6a6f4363..47eb6be513 100644 --- a/v2.3/Data.Vec.Functional.Properties.html +++ b/v2.3/Data.Vec.Functional.Properties.html @@ -30,7 +30,7 @@ using (module ≡-Reasoning) open import Relation.Nullary.Decidable using (Dec; does; yes; no; map′; _×-dec_) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) import Data.Fin.Properties as Finₚ @@ -71,7 +71,7 @@ updateAt-minimal : (i j : Fin n) {f : A A} (xs : Vector A n) i j updateAt xs j f i xs i -updateAt-minimal zero zero xs 0≢0 = contradiction refl 0≢0 +updateAt-minimal zero zero xs 0≢0 = contradiction refl 0≢0 updateAt-minimal zero (suc j) xs _ = refl updateAt-minimal (suc i) zero xs _ = refl updateAt-minimal (suc i) (suc j) xs i≢j = updateAt-minimal i j (tail xs) (i≢j cong suc) @@ -118,7 +118,7 @@ updateAt-commutes : (i j : Fin n) {f g : A A} i j (xs : Vector A n) updateAt (updateAt xs j g) i f updateAt (updateAt xs i f) j g -updateAt-commutes zero zero 0≢0 xs k = contradiction refl 0≢0 +updateAt-commutes zero zero 0≢0 xs k = contradiction refl 0≢0 updateAt-commutes zero (suc j) _ xs zero = refl updateAt-commutes zero (suc j) _ xs (suc k) = refl updateAt-commutes (suc i) zero _ xs zero = refl @@ -164,26 +164,26 @@ lookup-++-< : (xs : Vector A m) (ys : Vector A n) i (i<m : toℕ i ℕ.< m) (xs ++ ys) i xs (fromℕ< i<m) -lookup-++-< {m = m} xs ys i i<m = cong Sum.[ xs , ys ] (Finₚ.splitAt-< m i i<m) +lookup-++-< {m = m} xs ys i i<m = cong Sum.[ xs , ys ] (Finₚ.splitAt-< m i i<m) lookup-++-≥ : (xs : Vector A m) (ys : Vector A n) i (i≥m : toℕ i ℕ.≥ m) (xs ++ ys) i ys (reduce≥ i i≥m) -lookup-++-≥ {m = m} xs ys i i≥m = cong Sum.[ xs , ys ] (Finₚ.splitAt-≥ m i i≥m) +lookup-++-≥ {m = m} xs ys i i≥m = cong Sum.[ xs , ys ] (Finₚ.splitAt-≥ m i i≥m) lookup-++ˡ : (xs : Vector A m) (ys : Vector A n) i (xs ++ ys) (i ↑ˡ n) xs i -lookup-++ˡ {m = m} {n = n} xs ys i = cong Sum.[ xs , ys ] (Finₚ.splitAt-↑ˡ m i n) +lookup-++ˡ {m = m} {n = n} xs ys i = cong Sum.[ xs , ys ] (Finₚ.splitAt-↑ˡ m i n) lookup-++ʳ : (xs : Vector A m) (ys : Vector A n) i (xs ++ ys) (m ↑ʳ i) ys i -lookup-++ʳ {m = m} {n = n} xs ys i = cong Sum.[ xs , ys ] (Finₚ.splitAt-↑ʳ m n i) +lookup-++ʳ {m = m} {n = n} xs ys i = cong Sum.[ xs , ys ] (Finₚ.splitAt-↑ʳ m n i) module _ {ys ys′ : Vector A m} where ++-cong : (xs xs′ : Vector A n) xs xs′ ys ys′ xs ++ ys xs′ ++ ys′ - ++-cong {n} xs xs′ eq₁ eq₂ i with toℕ i ℕ.<? n + ++-cong {n} xs xs′ eq₁ eq₂ i with toℕ i ℕ.<? n ... | yes i<n = begin (xs ++ ys) i ≡⟨ lookup-++-< xs ys i i<n xs (fromℕ< i<n) ≡⟨ eq₁ (fromℕ< i<n) @@ -191,9 +191,9 @@ (xs′ ++ ys′) i where open ≡-Reasoning ... | no i≮n = begin - (xs ++ ys) i ≡⟨ lookup-++-≥ xs ys i (ℕ.≮⇒≥ i≮n) - ys (reduce≥ i (ℕ.≮⇒≥ i≮n)) ≡⟨ eq₂ (reduce≥ i (ℕ.≮⇒≥ i≮n)) - ys′ (reduce≥ i (ℕ.≮⇒≥ i≮n)) ≡⟨ lookup-++-≥ xs′ ys′ i (ℕ.≮⇒≥ i≮n) + (xs ++ ys) i ≡⟨ lookup-++-≥ xs ys i (ℕ.≮⇒≥ i≮n) + ys (reduce≥ i (ℕ.≮⇒≥ i≮n)) ≡⟨ eq₂ (reduce≥ i (ℕ.≮⇒≥ i≮n)) + ys′ (reduce≥ i (ℕ.≮⇒≥ i≮n)) ≡⟨ lookup-++-≥ xs′ ys′ i (ℕ.≮⇒≥ i≮n) (xs′ ++ ys′) i where open ≡-Reasoning @@ -239,7 +239,7 @@ removeAt-punchOut : (xs : Vector A (suc n)) {i : Fin (suc n)} {j : Fin (suc n)} (i≢j : i j) removeAt xs i (punchOut i≢j) xs j -removeAt-punchOut {n = n} xs {zero} {zero} i≢j = contradiction refl i≢j +removeAt-punchOut {n = n} xs {zero} {zero} i≢j = contradiction refl i≢j removeAt-punchOut {n = suc n} xs {zero} {suc j} i≢j = refl removeAt-punchOut {n = suc n} xs {suc i} {zero} i≢j = refl removeAt-punchOut {n = suc n} xs {suc i} {suc j} i≢j = removeAt-punchOut (tail xs) (i≢j cong suc) diff --git a/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.Properties.html b/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.Properties.html index cb8715e0bc..06b577b502 100644 --- a/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.Properties.html +++ b/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.Properties.html @@ -12,7 +12,7 @@ open import Level using (Level) open import Data.Product.Base using (_,_; proj₁; proj₂) open import Data.Nat.Base using () -open import Data.Fin.Permutation using (id; flip; _⟨$⟩ʳ_; inverseʳ; _∘ₚ_) +open import Data.Fin.Permutation using (id; flip; _⟨$⟩ʳ_; inverseʳ; _∘ₚ_) open import Data.Vec.Functional using (Vector) open import Data.Vec.Functional.Relation.Binary.Permutation using (_↭_) open import Relation.Binary.PropositionalEquality.Core @@ -34,21 +34,21 @@ -- Basics ↭-refl : Reflexive (Vector A) _↭_ -↭-refl = id , λ _ refl +↭-refl = id , λ _ refl ↭-reflexive : xs ys xs ys ↭-reflexive refl = ↭-refl ↭-sym : Symmetric (Vector A) _↭_ -proj₁ (↭-sym (xs↭ys , _)) = flip xs↭ys +proj₁ (↭-sym (xs↭ys , _)) = flip xs↭ys proj₂ (↭-sym {x = xs} {ys} (xs↭ys , xs↭ys≡)) i = begin - ys (flip xs↭ys ⟨$⟩ʳ i) ≡⟨ xs↭ys≡ _ - xs (xs↭ys ⟨$⟩ʳ (flip xs↭ys ⟨$⟩ʳ i)) ≡⟨ cong xs (inverseʳ xs↭ys) + ys (flip xs↭ys ⟨$⟩ʳ i) ≡⟨ xs↭ys≡ _ + xs (xs↭ys ⟨$⟩ʳ (flip xs↭ys ⟨$⟩ʳ i)) ≡⟨ cong xs (inverseʳ xs↭ys) xs i where open ≡-Reasoning ↭-trans : Transitive (Vector A) _↭_ -proj₁ (↭-trans (xs↭ys , _) (ys↭zs , _)) = ys↭zs ∘ₚ xs↭ys +proj₁ (↭-trans (xs↭ys , _) (ys↭zs , _)) = ys↭zs ∘ₚ xs↭ys proj₂ (↭-trans (_ , xs↭ys) (_ , ys↭zs)) _ = trans (xs↭ys _) (ys↭zs _) ------------------------------------------------------------------------ diff --git a/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.html b/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.html index 92555ca677..ad3763bcb2 100644 --- a/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.html +++ b/v2.3/Data.Vec.Functional.Relation.Binary.Permutation.html @@ -11,7 +11,7 @@ open import Level using (Level) open import Data.Product.Base using (Σ-syntax) -open import Data.Fin.Permutation using (Permutation; _⟨$⟩ʳ_) +open import Data.Fin.Permutation using (Permutation; _⟨$⟩ʳ_) open import Data.Vec.Functional using (Vector) open import Relation.Binary.Indexed.Heterogeneous.Core using (IRel) open import Relation.Binary.PropositionalEquality.Core using (_≡_) @@ -24,5 +24,5 @@ infix 3 _↭_ _↭_ : IRel (Vector A) _ -xs ys = Σ[ ρ Permutation _ _ ] (∀ i xs (ρ ⟨$⟩ʳ i) ys i) +xs ys = Σ[ ρ Permutation _ _ ] (∀ i xs (ρ ⟨$⟩ʳ i) ys i) \ No newline at end of file diff --git a/v2.3/Data.Vec.Functional.Relation.Binary.Pointwise.Properties.html b/v2.3/Data.Vec.Functional.Relation.Binary.Pointwise.Properties.html index b9034a763e..410bb6c3ab 100644 --- a/v2.3/Data.Vec.Functional.Relation.Binary.Pointwise.Properties.html +++ b/v2.3/Data.Vec.Functional.Relation.Binary.Pointwise.Properties.html @@ -10,7 +10,7 @@ module Data.Vec.Functional.Relation.Binary.Pointwise.Properties where open import Data.Fin.Base using (zero; suc; _↑ˡ_; _↑ʳ_; splitAt) -open import Data.Fin.Properties using (all?; splitAt-↑ˡ; splitAt-↑ʳ) +open import Data.Fin.Properties using (all?; splitAt-↑ˡ; splitAt-↑ʳ) open import Data.Nat.Base using (; zero; suc) open import Data.Product.Base using (_×_; _,_; proj₁; proj₂) open import Data.Product.Relation.Binary.Pointwise.NonDependent @@ -53,7 +53,7 @@ trans t xsys yszs i = t (xsys i) (yszs i) decidable : Decidable R {n} Decidable (Pointwise R {n}) - decidable r? xs ys = all? λ i r? (xs i) (ys i) + decidable r? xs ys = all? λ i r? (xs i) (ys i) ------------------------------------------------------------------------ -- Structures @@ -126,12 +126,12 @@ ++⁻ˡ : {m n} (xs : Vector A m) (ys : Vector B m) {xs′ ys′} Pointwise R (xs ++ xs′) (ys ++ ys′) Pointwise R xs ys ++⁻ˡ {m} {n} _ _ rs i with rs (i ↑ˡ n) - ... | r rewrite splitAt-↑ˡ m i n = r + ... | r rewrite splitAt-↑ˡ m i n = r ++⁻ʳ : {m n} (xs : Vector A m) (ys : Vector B m) {xs′ ys′} Pointwise R (xs ++ xs′) (ys ++ ys′) Pointwise R xs′ ys′ ++⁻ʳ {m} {n} _ _ rs i with rs (m ↑ʳ i) - ... | r rewrite splitAt-↑ʳ m n i = r + ... | r rewrite splitAt-↑ʳ m n i = r ++⁻ : {m n} xs ys {xs′ ys′} Pointwise R (xs ++ xs′) (ys ++ ys′) diff --git a/v2.3/Data.Vec.Functional.Relation.Unary.All.Properties.html b/v2.3/Data.Vec.Functional.Relation.Unary.All.Properties.html index 33044e4a95..b5f325aa88 100644 --- a/v2.3/Data.Vec.Functional.Relation.Unary.All.Properties.html +++ b/v2.3/Data.Vec.Functional.Relation.Unary.All.Properties.html @@ -11,7 +11,7 @@ open import Data.Nat.Base using () open import Data.Fin.Base using (zero; suc; _↑ˡ_; _↑ʳ_; splitAt) -open import Data.Fin.Properties using (splitAt-↑ˡ; splitAt-↑ʳ) +open import Data.Fin.Properties using (splitAt-↑ˡ; splitAt-↑ʳ) open import Data.Product.Base as Σ using (_×_; _,_; proj₁; proj₂; uncurry) open import Data.Sum.Base using (_⊎_; inj₁; inj₂; [_,_]) open import Data.Vec.Functional as VF hiding (map) @@ -92,11 +92,11 @@ ++⁻ˡ : All P (xs ++ ys) All P xs ++⁻ˡ ps i with ps (i ↑ˡ n) - ... | p rewrite splitAt-↑ˡ m i n = p + ... | p rewrite splitAt-↑ˡ m i n = p ++⁻ʳ : All P (xs ++ ys) All P ys ++⁻ʳ ps i with ps (m ↑ʳ i) - ... | p rewrite splitAt-↑ʳ m n i = p + ... | p rewrite splitAt-↑ʳ m n i = p ++⁻ : All P (xs ++ ys) All P xs × All P ys ++⁻ ps = ++⁻ˡ ps , ++⁻ʳ ps diff --git a/v2.3/Data.Vec.Functional.Relation.Unary.All.html b/v2.3/Data.Vec.Functional.Relation.Unary.All.html index 8b464153b0..c7a559f0be 100644 --- a/v2.3/Data.Vec.Functional.Relation.Unary.All.html +++ b/v2.3/Data.Vec.Functional.Relation.Unary.All.html @@ -9,7 +9,7 @@ module Data.Vec.Functional.Relation.Unary.All where -open import Data.Fin.Properties using (all?) +open import Data.Fin.Properties using (all?) open import Data.Product.Base using (_,_) open import Data.Vec.Functional as VF hiding (map) open import Level using (Level) @@ -40,7 +40,7 @@ module _ {P : Pred A p} where all : Decidable P {n} Decidable (All P {n = n}) - all p? xs = all? λ i p? (xs i) + all p? xs = all? λ i p? (xs i) universal : Universal P {n} Universal (All P {n = n}) universal uni xs i = uni (xs i) diff --git a/v2.3/Data.Vec.Functional.Relation.Unary.Any.html b/v2.3/Data.Vec.Functional.Relation.Unary.Any.html index 26e99125e2..d899e10a0d 100644 --- a/v2.3/Data.Vec.Functional.Relation.Unary.Any.html +++ b/v2.3/Data.Vec.Functional.Relation.Unary.Any.html @@ -10,7 +10,7 @@ module Data.Vec.Functional.Relation.Unary.Any where open import Data.Fin.Base using (zero; suc) -open import Data.Fin.Properties using (any?) +open import Data.Fin.Properties using (any?) open import Data.Nat.Base using () open import Data.Product.Base as Σ using (Σ; ; _×_; _,_; proj₁; proj₂) open import Data.Vec.Functional as VF hiding (map) @@ -52,5 +52,5 @@ module _ {P : Pred A p} where any : Decidable P {n} Decidable (Any P {n = n}) - any p? xs = any? λ i p? (xs i) + any p? xs = any? λ i p? (xs i) \ No newline at end of file diff --git a/v2.3/Data.Vec.Properties.WithK.html b/v2.3/Data.Vec.Properties.WithK.html index 44de850676..c75e9aa734 100644 --- a/v2.3/Data.Vec.Properties.WithK.html +++ b/v2.3/Data.Vec.Properties.WithK.html @@ -11,7 +11,7 @@ module Data.Vec.Properties.WithK where open import Data.Nat.Base using (; suc) -open import Data.Nat.Properties using (+-assoc) +open import Data.Nat.Properties using (+-assoc) open import Data.Vec.Base open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong) open import Relation.Binary.HeterogeneousEquality as using (_≅_; refl) @@ -36,7 +36,7 @@ (xs ++ ys) ++ zs xs ++ (ys ++ zs) ++-assoc [] ys zs = refl ++-assoc {suc m} (x xs) ys zs = - ≅.icong (Vec A) (+-assoc m _ _) (x ∷_) (++-assoc xs ys zs) + ≅.icong (Vec A) (+-assoc m _ _) (x ∷_) (++-assoc xs ys zs) ------------------------------------------------------------------------ -- foldr diff --git a/v2.3/Data.Vec.Properties.html b/v2.3/Data.Vec.Properties.html index dc88c09078..24818da2f4 100644 --- a/v2.3/Data.Vec.Properties.html +++ b/v2.3/Data.Vec.Properties.html @@ -18,8 +18,8 @@ open import Data.Nat.Base using (; zero; suc; _+_; _≤_; _<_; s≤s; pred; s<s⁻¹; _≥_; s≤s⁻¹; z≤n) open import Data.Nat.Properties - using (+-assoc; m≤n⇒m≤1+n; m≤m+n; ≤-refl; ≤-trans; ≤-irrelevant; ≤⇒≤″ - ; suc-injective; +-comm; +-suc; +-identityʳ) + using (+-assoc; m≤n⇒m≤1+n; m≤m+n; ≤-refl; ≤-trans; ≤-irrelevant; ≤⇒≤″ + ; suc-injective; +-comm; +-suc; +-identityʳ) open import Data.Product.Base as Product using (_×_; _,_; proj₁; proj₂; <_,_>; uncurry) open import Data.Sum.Base using ([_,_]′) @@ -38,12 +38,12 @@ open import Relation.Unary using (Pred; Decidable) open import Relation.Nullary.Decidable.Core using (Dec; does; yes; _×-dec_; map′) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) import Data.Nat.GeneralisedArithmetic as private m+n+o≡n+[m+o] : m n o m + n + o n + (m + o) - m+n+o≡n+[m+o] m n o = trans (cong (_+ o) (+-comm m n)) (+-assoc n m o) + m+n+o≡n+[m+o] m n o = trans (cong (_+ o) (+-comm m n)) (+-assoc n m o) private variable @@ -133,17 +133,17 @@ ------------------------------------------------------------------------ -- truncate -truncate-refl : (xs : Vec A n) truncate ≤-refl xs xs +truncate-refl : (xs : Vec A n) truncate ≤-refl xs xs truncate-refl [] = refl truncate-refl (x xs) = cong (x ∷_) (truncate-refl xs) truncate-trans : {p} (m≤n : m n) (n≤p : n p) (xs : Vec A p) - truncate (≤-trans m≤n n≤p) xs truncate m≤n (truncate n≤p xs) + truncate (≤-trans m≤n n≤p) xs truncate m≤n (truncate n≤p xs) truncate-trans z≤n n≤p xs = refl truncate-trans (s≤s m≤n) (s≤s n≤p) (x xs) = cong (x ∷_) (truncate-trans m≤n n≤p xs) truncate-irrelevant : (m≤n₁ m≤n₂ : m n) truncate {A = A} m≤n₁ truncate m≤n₂ -truncate-irrelevant m≤n₁ m≤n₂ xs = cong m≤n truncate m≤n xs) (≤-irrelevant m≤n₁ m≤n₂) +truncate-irrelevant m≤n₁ m≤n₂ xs = cong m≤n truncate m≤n xs) (≤-irrelevant m≤n₁ m≤n₂) truncate≡take : (m≤n : m n) (xs : Vec A n) .(eq : n m + o) truncate m≤n xs take m (cast eq xs) @@ -151,14 +151,14 @@ truncate≡take (s≤s m≤n) (x xs) eq = cong (x ∷_) (truncate≡take m≤n xs (suc-injective eq)) take≡truncate : m (xs : Vec A (m + n)) - take m xs truncate (m≤m+n m n) xs + take m xs truncate (m≤m+n m n) xs take≡truncate zero _ = refl take≡truncate (suc m) (x xs) = cong (x ∷_) (take≡truncate m xs) ------------------------------------------------------------------------ -- pad -padRight-refl : (a : A) (xs : Vec A n) padRight ≤-refl a xs xs +padRight-refl : (a : A) (xs : Vec A n) padRight ≤-refl a xs xs padRight-refl a [] = refl padRight-refl a (x xs) = cong (x ∷_) (padRight-refl a xs) @@ -167,7 +167,7 @@ padRight-replicate (s≤s m≤n) a = cong (a ∷_) (padRight-replicate m≤n a) padRight-trans : {p} (m≤n : m n) (n≤p : n p) (a : A) (xs : Vec A m) - padRight (≤-trans m≤n n≤p) a xs padRight n≤p a (padRight m≤n a xs) + padRight (≤-trans m≤n n≤p) a xs padRight n≤p a (padRight m≤n a xs) padRight-trans z≤n n≤p a [] = padRight-replicate n≤p a padRight-trans (s≤s m≤n) (s≤s n≤p) a (x xs) = cong (x ∷_) (padRight-trans m≤n n≤p a xs) @@ -210,13 +210,13 @@ lookup-truncate (s≤s m≤m+n) (_ xs) (suc i) = lookup-truncate m≤m+n xs i lookup-take-inject≤ : (xs : Vec A (m + n)) (i : Fin m) - lookup (take m xs) i lookup xs (Fin.inject≤ i (m≤m+n m n)) + lookup (take m xs) i lookup xs (Fin.inject≤ i (m≤m+n m n)) lookup-take-inject≤ {m = m} {n = n} xs i = begin lookup (take _ xs) i ≡⟨ cong ys lookup ys i) (take≡truncate m xs) lookup (truncate _ xs) i - ≡⟨ lookup-truncate (m≤m+n m n) xs i - lookup xs (Fin.inject≤ i (m≤m+n m n)) + ≡⟨ lookup-truncate (m≤m+n m n) xs i + lookup xs (Fin.inject≤ i (m≤m+n m n)) where open ≡-Reasoning ------------------------------------------------------------------------ @@ -233,7 +233,7 @@ updateAt-minimal : (i j : Fin n) {f : A A} (xs : Vec A n) i j xs [ i ]= x (updateAt xs j f) [ i ]= x -updateAt-minimal zero zero (x xs) 0≢0 here = contradiction refl 0≢0 +updateAt-minimal zero zero (x xs) 0≢0 here = contradiction refl 0≢0 updateAt-minimal zero (suc j) (x xs) _ here = here updateAt-minimal (suc i) zero (x xs) _ (there loc) = there loc updateAt-minimal (suc i) (suc j) (x xs) i≢j (there loc) = @@ -303,7 +303,7 @@ updateAt-commutes : (i j : Fin n) {f g : A A} i j (xs : Vec A n) updateAt (updateAt xs j g) i f updateAt (updateAt xs i f) j g -updateAt-commutes zero zero 0≢0 (x xs) = contradiction refl 0≢0 +updateAt-commutes zero zero 0≢0 (x xs) = contradiction refl 0≢0 updateAt-commutes zero (suc j) i≢j (x xs) = refl updateAt-commutes (suc i) zero i≢j (x xs) = refl updateAt-commutes (suc i) (suc j) i≢j (x xs) = @@ -493,12 +493,12 @@ ++-injective ws xs eq = (++-injectiveˡ ws xs eq , ++-injectiveʳ ws xs eq) -++-assoc-eqFree : (xs : Vec A m) (ys : Vec A n) (zs : Vec A o) let eq = +-assoc m n o in +++-assoc-eqFree : (xs : Vec A m) (ys : Vec A n) (zs : Vec A o) let eq = +-assoc m n o in cast eq ((xs ++ ys) ++ zs) xs ++ (ys ++ zs) ++-assoc-eqFree [] ys zs = cast-is-id refl (ys ++ zs) ++-assoc-eqFree (x xs) ys zs = cong (x ∷_) (++-assoc-eqFree xs ys zs) -++-identityʳ-eqFree : (xs : Vec A n) cast (+-identityʳ n) (xs ++ []) xs +++-identityʳ-eqFree : (xs : Vec A n) cast (+-identityʳ n) (xs ++ []) xs ++-identityʳ-eqFree [] = refl ++-identityʳ-eqFree (x xs) = cong (x ∷_) (++-identityʳ-eqFree xs) @@ -892,7 +892,7 @@ -- snoc is snoc -unfold-∷ʳ-eqFree : x (xs : Vec A n) cast (+-comm 1 n) (xs ∷ʳ x) xs ++ [ x ] +unfold-∷ʳ-eqFree : x (xs : Vec A n) cast (+-comm 1 n) (xs ∷ʳ x) xs ++ [ x ] unfold-∷ʳ-eqFree x [] = refl unfold-∷ʳ-eqFree x (y xs) = cong (y ∷_) (unfold-∷ʳ-eqFree x xs) @@ -941,13 +941,13 @@ -- _++_ and _∷ʳ_ -++-∷ʳ-eqFree : z (xs : Vec A m) (ys : Vec A n) let eq = sym (+-suc m n) in +++-∷ʳ-eqFree : z (xs : Vec A m) (ys : Vec A n) let eq = sym (+-suc m n) in cast eq ((xs ++ ys) ∷ʳ z) xs ++ (ys ∷ʳ z) ++-∷ʳ-eqFree {m = zero} z [] [] = refl ++-∷ʳ-eqFree {m = zero} z [] (y ys) = cong (y ∷_) (++-∷ʳ-eqFree z [] ys) ++-∷ʳ-eqFree {m = suc m} z (x xs) ys = cong (x ∷_) (++-∷ʳ-eqFree z xs ys) -∷ʳ-++-eqFree : a (xs : Vec A n) {ys : Vec A m} let eq = sym (+-suc n m) in +∷ʳ-++-eqFree : a (xs : Vec A n) {ys : Vec A m} let eq = sym (+-suc n m) in cast eq ((xs ∷ʳ a) ++ ys) xs ++ (a ys) ∷ʳ-++-eqFree a [] {ys} = cong (a ∷_) (cast-is-id refl ys) ∷ʳ-++-eqFree a (x xs) {ys} = cong (x ∷_) (∷ʳ-++-eqFree a xs) @@ -1050,9 +1050,9 @@ where open ≡-Reasoning reverse-++-eqFree : (xs : Vec A m) (ys : Vec A n) - reverse (xs ++ ys) ≈[ +-comm m n ] reverse ys ++ reverse xs + reverse (xs ++ ys) ≈[ +-comm m n ] reverse ys ++ reverse xs reverse-++-eqFree {m = m} {n = n} xs ys = - toList-injective (+-comm m n) (reverse (xs ++ ys)) (reverse ys ++ reverse xs) $ + toList-injective (+-comm m n) (reverse (xs ++ ys)) (reverse ys ++ reverse xs) $ begin toList (reverse (xs ++ ys)) ≡⟨ toList-reverse ((xs ++ ys)) List.reverse (toList (xs ++ ys)) ≡⟨ cong List.reverse (toList-++ xs ys) @@ -1137,7 +1137,7 @@ sum-++ {_} [] = refl sum-++ {ys = ys} (x xs) = begin x + sum (xs ++ ys) ≡⟨ cong (x +_) (sum-++ xs) - x + (sum xs + sum ys) ≡⟨ +-assoc x (sum xs) (sum ys) + x + (sum xs + sum ys) ≡⟨ +-assoc x (sum xs) (sum ys) sum (x xs) + sum ys where open ≡-Reasoning @@ -1260,7 +1260,7 @@ count≤n [] = z≤n count≤n (x xs) with does (P? x) ... | true = s≤s (count≤n xs) - ... | false = m≤n⇒m≤1+n (count≤n xs) + ... | false = m≤n⇒m≤1+n (count≤n xs) ------------------------------------------------------------------------ -- length @@ -1293,7 +1293,7 @@ removeAt-punchOut : (xs : Vec A (suc n)) {i} {j} (i≢j : i j) lookup (removeAt xs i) (Fin.punchOut i≢j) lookup xs j -removeAt-punchOut (x xs) {zero} {zero} i≢j = contradiction refl i≢j +removeAt-punchOut (x xs) {zero} {zero} i≢j = contradiction refl i≢j removeAt-punchOut (x xs) {zero} {suc j} i≢j = refl removeAt-punchOut (x y xs) {suc i} {zero} i≢j = refl removeAt-punchOut (x y xs) {suc i} {suc j} i≢j = @@ -1371,7 +1371,7 @@ -- Version 2.3 -∷-ʳ++-eqFree : a (xs : Vec A m) {ys : Vec A n} let eq = sym (+-suc m n) in +∷-ʳ++-eqFree : a (xs : Vec A m) {ys : Vec A n} let eq = sym (+-suc m n) in cast eq ((a xs) ʳ++ ys) xs ʳ++ (a ys) ∷-ʳ++-eqFree a xs {ys} = ʳ++-ʳ++-eqFree (a []) {ys = xs} {zs = ys} {-# WARNING_ON_USAGE ∷-ʳ++-eqFree diff --git a/v2.3/Data.Vec.Recursive.html b/v2.3/Data.Vec.Recursive.html index d25c60e374..1edf957282 100644 --- a/v2.3/Data.Vec.Recursive.html +++ b/v2.3/Data.Vec.Recursive.html @@ -18,10 +18,10 @@ module Data.Vec.Recursive where open import Data.Nat.Base as Nat using (; zero; suc; NonZero; pred) -open import Data.Nat.Properties using (+-comm; *-comm) +open import Data.Nat.Properties using (+-comm; *-comm) open import Data.Empty.Polymorphic using () open import Data.Fin.Base as Fin using (Fin; zero; suc) -open import Data.Fin.Properties using (1↔⊤; *↔×) +open import Data.Fin.Properties using (1↔⊤; *↔×) open import Data.Product.Base as Product using (_×_; _,_; proj₁; proj₂) open import Data.Product.Algebra using (×-cong) open import Data.Sum.Base as Sum using (_⊎_) @@ -160,8 +160,8 @@ lift↔ (suc n@(suc _)) A↔B = ×-cong A↔B (lift↔ n A↔B) Fin[m^n]↔Fin[m]^n : m n Fin (m Nat.^ n) Fin m ^ n -Fin[m^n]↔Fin[m]^n m 0 = ↔-trans 1↔⊤ (↔-sym ⊤↔⊤*) +Fin[m^n]↔Fin[m]^n m 0 = ↔-trans 1↔⊤ (↔-sym ⊤↔⊤*) Fin[m^n]↔Fin[m]^n m 1 = subst x Fin x Fin m) - (trans (sym (+-comm m zero)) (*-comm 1 m)) ↔-refl -Fin[m^n]↔Fin[m]^n m (suc (suc n)) = ↔-trans (*↔× {m = m}) (×-cong ↔-refl (Fin[m^n]↔Fin[m]^n _ _)) + (trans (sym (+-comm m zero)) (*-comm 1 m)) ↔-refl +Fin[m^n]↔Fin[m]^n m (suc (suc n)) = ↔-trans (*↔× {m = m}) (×-cong ↔-refl (Fin[m^n]↔Fin[m]^n _ _)) \ No newline at end of file diff --git a/v2.3/Data.Vec.Relation.Binary.Lex.Core.html b/v2.3/Data.Vec.Relation.Binary.Lex.Core.html index 57bee3777a..fd0ae589ff 100644 --- a/v2.3/Data.Vec.Relation.Binary.Lex.Core.html +++ b/v2.3/Data.Vec.Relation.Binary.Lex.Core.html @@ -27,7 +27,7 @@ using (_≡_; refl; cong) import Relation.Nullary as Nullary open import Relation.Nullary.Decidable as Dec using (Dec; yes; no; _×-dec_; _⊎-dec_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) private variable @@ -76,13 +76,13 @@ ≰-this : {x y m n} {xs : Vec A m} {ys : Vec A n} ¬ (x y) ¬ (x y) ¬ (x xs) <ₗₑₓ (y ys) - ≰-this x≉y x≮y (this x≺y m≡n) = contradiction x≺y x≮y - ≰-this x≉y x≮y (next x≈y xs<ys) = contradiction x≈y x≉y + ≰-this x≉y x≮y (this x≺y m≡n) = contradiction x≺y x≮y + ≰-this x≉y x≮y (next x≈y xs<ys) = contradiction x≈y x≉y ≰-next : {x y m n} {xs : Vec A m} {ys : Vec A n} ¬ (x y) ¬ (xs <ₗₑₓ ys) ¬ (x xs) <ₗₑₓ (y ys) - ≰-next x≮y xs≮ys (this x≺y m≡n) = contradiction x≺y x≮y - ≰-next x≮y xs≮ys (next x≈y xs<ys) = contradiction xs<ys xs≮ys + ≰-next x≮y xs≮ys (this x≺y m≡n) = contradiction x≺y x≮y + ≰-next x≮y xs≮ys (next x≈y xs<ys) = contradiction xs<ys xs≮ys P⇔[]<[] : P [] <ₗₑₓ [] P⇔[]<[] = mk⇔ base { (base p) p }) @@ -114,9 +114,9 @@ antisym : {n} Antisymmetric (_≋_ {n}) (_<ₗₑₓ_) antisym (base _) (base _) = [] - antisym (this x≺y m≡n) (this y≺x n≡m) = contradiction y≺x (≺-asym x≺y) - antisym (this x≺y m≡n) (next y≈x ys<xs) = contradiction x≺y (≺-irrefl (≈-sym y≈x)) - antisym (next x≈y xs<ys) (this y≺x m≡n) = contradiction y≺x (≺-irrefl (≈-sym x≈y)) + antisym (this x≺y m≡n) (this y≺x n≡m) = contradiction y≺x (≺-asym x≺y) + antisym (this x≺y m≡n) (next y≈x ys<xs) = contradiction x≺y (≺-irrefl (≈-sym y≈x)) + antisym (next x≈y xs<ys) (this y≺x m≡n) = contradiction y≺x (≺-irrefl (≈-sym x≈y)) antisym (next x≈y xs<ys) (next y≈x ys<xs) = x≈y (antisym xs<ys ys<xs) module _ (≈-equiv : IsPartialEquivalence _≈_) (open IsPartialEquivalence ≈-equiv) where @@ -140,7 +140,7 @@ decidable {m} {n} xs ys with m ℕ.≟ n decidable {_} {_} [] [] | yes refl = Dec.map P⇔[]<[] P? decidable {_} {_} (x xs) (y ys) | yes refl = Dec.map ∷<∷-⇔ ((x ≺? y) ⊎-dec (x ≈? y) ×-dec (decidable xs ys)) - decidable {_} {_} _ _ | no m≢n = no xs<ys contradiction (length-equal xs<ys) m≢n) + decidable {_} {_} _ _ | no m≢n = no xs<ys contradiction (length-equal xs<ys) m≢n) module _ (P-irrel : Nullary.Irrelevant P) (≈-irrel : Irrelevant _≈_) @@ -151,7 +151,7 @@ irrelevant : {m n} Irrelevant (_<ₗₑₓ_ {m} {n}) irrelevant (base p₁) (base p₂) rewrite P-irrel p₁ p₂ = refl irrelevant (this x≺y₁ m≡n₁) (this x≺y₂ m≡n₂) rewrite ≺-irrel x≺y₁ x≺y₂ | ℕ.≡-irrelevant m≡n₁ m≡n₂ = refl - irrelevant (this x≺y m≡n) (next x≈y xs<ys₂) = contradiction x≺y (≺-irrefl x≈y) - irrelevant (next x≈y xs<ys₁) (this x≺y m≡n) = contradiction x≺y (≺-irrefl x≈y) + irrelevant (this x≺y m≡n) (next x≈y xs<ys₂) = contradiction x≺y (≺-irrefl x≈y) + irrelevant (next x≈y xs<ys₁) (this x≺y m≡n) = contradiction x≺y (≺-irrefl x≈y) irrelevant (next x≈y₁ xs<ys₁) (next x≈y₂ xs<ys₂) rewrite ≈-irrel x≈y₁ x≈y₂ | irrelevant xs<ys₁ xs<ys₂ = refl \ No newline at end of file diff --git a/v2.3/Data.Vec.Relation.Binary.Lex.Strict.html b/v2.3/Data.Vec.Relation.Binary.Lex.Strict.html index 469793ca32..94111b5556 100644 --- a/v2.3/Data.Vec.Relation.Binary.Lex.Strict.html +++ b/v2.3/Data.Vec.Relation.Binary.Lex.Strict.html @@ -41,7 +41,7 @@ open import Relation.Binary.Construct.On as On using (wellFounded) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) open import Relation.Nullary.Decidable.Core using (yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) private variable @@ -141,7 +141,7 @@ where <-wellFounded : {n} WellFounded (_<_ {n}) - <-wellFounded {0} [] = acc λ ys<[] contradiction ys<[] xs≮[] + <-wellFounded {0} [] = acc λ ys<[] contradiction ys<[] xs≮[] <-wellFounded {suc n} xs = Subrelation.wellFounded <⇒uncons-Lex uncons-Lex-wellFounded xs where diff --git a/v2.3/Data.Vec.Relation.Unary.AllPairs.Properties.html b/v2.3/Data.Vec.Relation.Unary.AllPairs.Properties.html index b53b48d98c..5cee59f4da 100644 --- a/v2.3/Data.Vec.Relation.Unary.AllPairs.Properties.html +++ b/v2.3/Data.Vec.Relation.Unary.AllPairs.Properties.html @@ -16,7 +16,7 @@ open import Data.Vec.Relation.Unary.AllPairs as AllPairs using (AllPairs; []; _∷_) open import Data.Bool.Base using (true; false) open import Data.Fin.Base using (Fin) -open import Data.Fin.Properties using (suc-injective) +open import Data.Fin.Properties using (suc-injective) open import Data.Nat.Base using (zero; suc; _+_) open import Function.Base using (_∘_) open import Level using (Level) @@ -87,5 +87,5 @@ tabulate⁺ {zero} fᵢ~fⱼ = [] tabulate⁺ {suc n} fᵢ~fⱼ = All.tabulate⁺ j fᵢ~fⱼ λ()) - tabulate⁺ (fᵢ~fⱼ (_∘ suc-injective)) + tabulate⁺ (fᵢ~fⱼ (_∘ suc-injective)) \ No newline at end of file diff --git a/v2.3/Data.Vec.Relation.Unary.Any.html b/v2.3/Data.Vec.Relation.Unary.Any.html index a6af48634c..147cc6ce93 100644 --- a/v2.3/Data.Vec.Relation.Unary.Any.html +++ b/v2.3/Data.Vec.Relation.Unary.Any.html @@ -15,7 +15,7 @@ open import Data.Vec.Base as Vec using (Vec; []; [_]; _∷_) open import Data.Product.Base as Product using (; _,_) open import Level using (Level; _⊔_) -open import Relation.Nullary.Negation using (¬_; contradiction) +open import Relation.Nullary.Negation using (¬_; contradiction) open import Relation.Nullary.Decidable as Dec using (no; _⊎-dec_) open import Relation.Unary @@ -40,11 +40,11 @@ -- If the tail does not satisfy the predicate, then the head will. head : {x} ¬ Any P xs Any P (x xs) P x head ¬pxs (here px) = px -head ¬pxs (there pxs) = contradiction pxs ¬pxs +head ¬pxs (there pxs) = contradiction pxs ¬pxs -- If the head does not satisfy the predicate, then the tail will. tail : {x} ¬ P x Any P (x xs) Any P xs -tail ¬px (here px) = contradiction px ¬px +tail ¬px (here px) = contradiction px ¬px tail ¬px (there pxs) = pxs -- Convert back and forth with sum diff --git a/v2.3/Data.Vec.Relation.Unary.Unique.Propositional.Properties.html b/v2.3/Data.Vec.Relation.Unary.Unique.Propositional.Properties.html index d59320523a..e7353640e7 100644 --- a/v2.3/Data.Vec.Relation.Unary.Unique.Propositional.Properties.html +++ b/v2.3/Data.Vec.Relation.Unary.Unique.Propositional.Properties.html @@ -16,7 +16,7 @@ import Data.Vec.Relation.Unary.Unique.Setoid.Properties as Setoid open import Data.Fin.Base using (Fin) open import Data.Nat.Base using (_+_) -open import Data.Nat.Properties using (<⇒≢) +open import Data.Nat.Properties using (<⇒≢) open import Data.Product.Base using (_×_; _,_) open import Data.Product.Relation.Binary.Pointwise.NonDependent using (≡⇒≡×≡) open import Function.Base using (id; _∘_) diff --git a/v2.3/Data.Vec.Relation.Unary.Unique.Setoid.Properties.html b/v2.3/Data.Vec.Relation.Unary.Unique.Setoid.Properties.html index 25e15b9305..13b7f8a104 100644 --- a/v2.3/Data.Vec.Relation.Unary.Unique.Setoid.Properties.html +++ b/v2.3/Data.Vec.Relation.Unary.Unique.Setoid.Properties.html @@ -22,7 +22,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Binary.Bundles using (Setoid) open import Relation.Binary.PropositionalEquality.Core as using (_≡_) -open import Relation.Nullary.Negation using (contradiction; contraposition) +open import Relation.Nullary.Negation using (contradiction; contraposition) private variable @@ -40,7 +40,7 @@ map⁺ : {f} (∀ {x y} f x ≈₂ f y x ≈₁ y) {n xs} Unique S {n} xs Unique R {n} (map f xs) - map⁺ inj xs! = AllPairs.map⁺ (AllPairs.map (contraposition inj) xs!) + map⁺ inj xs! = AllPairs.map⁺ (AllPairs.map (contraposition inj) xs!) ------------------------------------------------------------------------ -- take & drop @@ -73,7 +73,7 @@ lookup-injective : {n xs} Unique S {n} xs i j lookup xs i lookup xs j i j lookup-injective (px pxs) zero zero eq = ≡.refl - lookup-injective (px pxs) zero (suc j) eq = contradiction eq (All.lookup⁺ px j) - lookup-injective (px pxs) (suc i) zero eq = contradiction (sym eq) (All.lookup⁺ px i) + lookup-injective (px pxs) zero (suc j) eq = contradiction eq (All.lookup⁺ px j) + lookup-injective (px pxs) (suc i) zero eq = contradiction (sym eq) (All.lookup⁺ px i) lookup-injective (px pxs) (suc i) (suc j) eq = ≡.cong suc (lookup-injective pxs i j eq) \ No newline at end of file diff --git a/v2.3/Data.Vec.html b/v2.3/Data.Vec.html index 0eaa4a5cad..a40c6584cc 100644 --- a/v2.3/Data.Vec.html +++ b/v2.3/Data.Vec.html @@ -43,7 +43,7 @@ filter : {n} Vec A n Vec≤ A n filter [] = Vec≤.[] - filter (a as) = if does (P? a) then a Vec≤.∷_ else ≤-cast (ℕ.n≤1+n _) $ filter as + filter (a as) = if does (P? a) then a Vec≤.∷_ else ≤-cast (ℕ.n≤1+n _) $ filter as takeWhile : {n} Vec A n Vec≤ A n takeWhile [] = Vec≤.[] @@ -52,6 +52,6 @@ dropWhile : {n} Vec A n Vec≤ A n dropWhile Vec.[] = Vec≤.[] dropWhile (a Vec.∷ as) = - if does (P? a) then ≤-cast (ℕ.n≤1+n _) (dropWhile as) + if does (P? a) then ≤-cast (ℕ.n≤1+n _) (dropWhile as) else fromVec (a Vec.∷ as) \ No newline at end of file diff --git a/v2.3/Data.Word64.Properties.html b/v2.3/Data.Word64.Properties.html index c4839ec6a0..580c1e5ae7 100644 --- a/v2.3/Data.Word64.Properties.html +++ b/v2.3/Data.Word64.Properties.html @@ -103,8 +103,8 @@ infix 4 _<?_ _<?_ : Decidable _<_ -_<?_ = On.decidable toℕ ℕ._<_ ℕ._<?_ +_<?_ = On.decidable toℕ ℕ._<_ ℕ._<?_ <-strictTotalOrder-≈ : StrictTotalOrder _ _ _ -<-strictTotalOrder-≈ = On.strictTotalOrder ℕ.<-strictTotalOrder toℕ +<-strictTotalOrder-≈ = On.strictTotalOrder ℕ.<-strictTotalOrder toℕ \ No newline at end of file diff --git a/v2.3/Effect.Foldable.html b/v2.3/Effect.Foldable.html index 2bfa0105db..d5f33532cd 100644 --- a/v2.3/Effect.Foldable.html +++ b/v2.3/Effect.Foldable.html @@ -60,7 +60,7 @@ foldl : (C -> A -> C) -> C -> F A -> C foldl {C = C} f z t = foldMap M₀ (flip f) t z - where M = Op.monoid (∘-id-monoid C) ; M₀ = Monoid.rawMonoid M + where M = Op.monoid (∘-id-monoid C) ; M₀ = Monoid.rawMonoid M toList : F A List A toList {A = A} = foldMap (List.++-[]-rawMonoid A) [_] diff --git a/v2.3/Everything.html b/v2.3/Everything.html index ad4e68421f..cc7e153be8 100644 --- a/v2.3/Everything.html +++ b/v2.3/Everything.html @@ -1199,2105 +1199,2086 @@ -- Lexicographic ordering of lists import Data.List.Relation.Binary.Lex.Strict --- A alternative definition for the permutation relation using setoid equality --- Based on Choudhury and Fiore, "Free Commutative Monoids in HoTT" (MFPS, 2022) --- Constructor `_⋎_` below is rule (3), directly after the proof of Theorem 6.3, --- and appears as rule `commrel` of their earlier presentation at (HoTT, 2019), --- "The finite-multiset construction in HoTT". -import Data.List.Relation.Binary.Permutation.Algorithmic +-- A definition for the permutation relation using setoid equality +import Data.List.Relation.Binary.Permutation.Homogeneous --- Properties of the `Algorithmic` definition of the permutation relation. -import Data.List.Relation.Binary.Permutation.Algorithmic.Properties +-- An inductive definition for the permutation relation +import Data.List.Relation.Binary.Permutation.Propositional --- A declarative definition of the permutation relation, inductively defined --- as the least congruence on `List` which makes `_++_` commutative. Thus, for --- `(A, _≈_)` a setoid, `List A` with equality given by `_↭_` is a constructive --- presentation of the free commutative monoid on `A`. -import Data.List.Relation.Binary.Permutation.Declarative +-- Properties of permutation +import Data.List.Relation.Binary.Permutation.Propositional.Properties --- Properties of declarative definition of permutation -import Data.List.Relation.Binary.Permutation.Declarative.Properties +-- Properties of permutation (with K) +import Data.List.Relation.Binary.Permutation.Propositional.Properties.WithK --- A definition for the permutation relation using setoid equality -import Data.List.Relation.Binary.Permutation.Homogeneous +-- A definition for the permutation relation using setoid equality +import Data.List.Relation.Binary.Permutation.Setoid --- An inductive definition for the permutation relation -import Data.List.Relation.Binary.Permutation.Propositional +-- Properties of permutations using setoid equality +import Data.List.Relation.Binary.Permutation.Setoid.Properties --- Properties of permutation -import Data.List.Relation.Binary.Permutation.Propositional.Properties +-- Properties of permutations using setoid equality (on Maybe elements) +import Data.List.Relation.Binary.Permutation.Setoid.Properties.Maybe --- Properties of permutation (with K) -import Data.List.Relation.Binary.Permutation.Propositional.Properties.WithK +-- Pointwise lifting of relations to lists +import Data.List.Relation.Binary.Pointwise --- A definition for the permutation relation using setoid equality -import Data.List.Relation.Binary.Permutation.Setoid +-- Pointwise lifting of relations to lists +import Data.List.Relation.Binary.Pointwise.Base --- Properties of permutations using setoid equality -import Data.List.Relation.Binary.Permutation.Setoid.Properties +-- Properties of pointwise lifting of relations to lists +import Data.List.Relation.Binary.Pointwise.Properties --- Properties of permutations using setoid equality (on Maybe elements) -import Data.List.Relation.Binary.Permutation.Setoid.Properties.Maybe +-- An inductive definition of the heterogeneous prefix relation +import Data.List.Relation.Binary.Prefix.Heterogeneous --- Pointwise lifting of relations to lists -import Data.List.Relation.Binary.Pointwise +-- Properties of the heterogeneous prefix relation +import Data.List.Relation.Binary.Prefix.Heterogeneous.Properties --- Pointwise lifting of relations to lists -import Data.List.Relation.Binary.Pointwise.Base +-- Properties of the homogeneous prefix relation +import Data.List.Relation.Binary.Prefix.Homogeneous.Properties --- Properties of pointwise lifting of relations to lists -import Data.List.Relation.Binary.Pointwise.Properties +-- Properties of the propositional prefix relation +import Data.List.Relation.Binary.Prefix.Propositional.Properties --- An inductive definition of the heterogeneous prefix relation -import Data.List.Relation.Binary.Prefix.Heterogeneous +-- An inductive definition of the sublist relation for types which have +-- a decidable equality. This is commonly known as Order Preserving +-- Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.DecPropositional --- Properties of the heterogeneous prefix relation -import Data.List.Relation.Binary.Prefix.Heterogeneous.Properties +-- A solver for proving that one list is a sublist of the other for +-- types which enjoy decidable equalities. +import Data.List.Relation.Binary.Sublist.DecPropositional.Solver --- Properties of the homogeneous prefix relation -import Data.List.Relation.Binary.Prefix.Homogeneous.Properties +-- An inductive definition of the sublist relation with respect to a +-- setoid which is decidable. This is a generalisation of what is +-- commonly known as Order Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.DecSetoid --- Properties of the propositional prefix relation -import Data.List.Relation.Binary.Prefix.Propositional.Properties +-- A solver for proving that one list is a sublist of the other. +import Data.List.Relation.Binary.Sublist.DecSetoid.Solver --- An inductive definition of the sublist relation for types which have --- a decidable equality. This is commonly known as Order Preserving --- Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.DecPropositional +-- An inductive definition of the heterogeneous sublist relation +-- This is a generalisation of what is commonly known as Order +-- Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.Heterogeneous --- A solver for proving that one list is a sublist of the other for --- types which enjoy decidable equalities. -import Data.List.Relation.Binary.Sublist.DecPropositional.Solver +-- Properties of the heterogeneous sublist relation +import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties --- An inductive definition of the sublist relation with respect to a --- setoid which is decidable. This is a generalisation of what is --- commonly known as Order Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.DecSetoid +-- A solver for proving that one list is a sublist of the other. +import Data.List.Relation.Binary.Sublist.Heterogeneous.Solver --- A solver for proving that one list is a sublist of the other. -import Data.List.Relation.Binary.Sublist.DecSetoid.Solver +-- An inductive definition of the sublist relation. This is commonly +-- known as Order Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.Propositional --- An inductive definition of the heterogeneous sublist relation --- This is a generalisation of what is commonly known as Order --- Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.Heterogeneous +-- A larger example for sublists (propositional case): +-- Simply-typed lambda terms with globally unique variables +-- (both bound and free ones). +import Data.List.Relation.Binary.Sublist.Propositional.Example.UniqueBoundVariables --- Properties of the heterogeneous sublist relation -import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties +-- Sublist-related properties +import Data.List.Relation.Binary.Sublist.Propositional.Properties --- A solver for proving that one list is a sublist of the other. -import Data.List.Relation.Binary.Sublist.Heterogeneous.Solver +-- Slices in the propositional sublist category. +import Data.List.Relation.Binary.Sublist.Propositional.Slice --- An inductive definition of the sublist relation. This is commonly --- known as Order Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.Propositional +-- An inductive definition of the sublist relation with respect to a +-- setoid. This is a generalisation of what is commonly known as Order +-- Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.Setoid --- A larger example for sublists (propositional case): --- Simply-typed lambda terms with globally unique variables --- (both bound and free ones). -import Data.List.Relation.Binary.Sublist.Propositional.Example.UniqueBoundVariables +-- Properties of the setoid sublist relation +import Data.List.Relation.Binary.Sublist.Setoid.Properties --- Sublist-related properties -import Data.List.Relation.Binary.Sublist.Propositional.Properties +-- Decidability of the subset relation over propositional equality. +import Data.List.Relation.Binary.Subset.DecPropositional --- Slices in the propositional sublist category. -import Data.List.Relation.Binary.Sublist.Propositional.Slice +-- Decidability of the subset relation over setoid equality. +import Data.List.Relation.Binary.Subset.DecSetoid --- An inductive definition of the sublist relation with respect to a --- setoid. This is a generalisation of what is commonly known as Order --- Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.Setoid +-- The sublist relation over propositional equality. +import Data.List.Relation.Binary.Subset.Propositional --- Properties of the setoid sublist relation -import Data.List.Relation.Binary.Sublist.Setoid.Properties +-- Properties of the sublist relation over setoid equality. +import Data.List.Relation.Binary.Subset.Propositional.Properties --- Decidability of the subset relation over propositional equality. -import Data.List.Relation.Binary.Subset.DecPropositional +-- The extensional sublist relation over setoid equality. +import Data.List.Relation.Binary.Subset.Setoid --- Decidability of the subset relation over setoid equality. -import Data.List.Relation.Binary.Subset.DecSetoid +-- Properties of the extensional sublist relation over setoid equality. +import Data.List.Relation.Binary.Subset.Setoid.Properties --- The sublist relation over propositional equality. -import Data.List.Relation.Binary.Subset.Propositional +-- An inductive definition of the heterogeneous suffix relation +import Data.List.Relation.Binary.Suffix.Heterogeneous --- Properties of the sublist relation over setoid equality. -import Data.List.Relation.Binary.Subset.Propositional.Properties +-- Properties of the heterogeneous suffix relation +import Data.List.Relation.Binary.Suffix.Heterogeneous.Properties --- The extensional sublist relation over setoid equality. -import Data.List.Relation.Binary.Subset.Setoid +-- Properties of the homogeneous suffix relation +import Data.List.Relation.Binary.Suffix.Homogeneous.Properties --- Properties of the extensional sublist relation over setoid equality. -import Data.List.Relation.Binary.Subset.Setoid.Properties +-- Properties of the propositional suffix relation +import Data.List.Relation.Binary.Suffix.Propositional.Properties --- An inductive definition of the heterogeneous suffix relation -import Data.List.Relation.Binary.Suffix.Heterogeneous +-- Generalised view of appending two lists into one. +import Data.List.Relation.Ternary.Appending --- Properties of the heterogeneous suffix relation -import Data.List.Relation.Binary.Suffix.Heterogeneous.Properties +-- Properties of the generalised view of appending two lists +import Data.List.Relation.Ternary.Appending.Properties --- Properties of the homogeneous suffix relation -import Data.List.Relation.Binary.Suffix.Homogeneous.Properties +-- Appending of lists using propositional equality +import Data.List.Relation.Ternary.Appending.Propositional --- Properties of the propositional suffix relation -import Data.List.Relation.Binary.Suffix.Propositional.Properties +-- Properties of list appending +import Data.List.Relation.Ternary.Appending.Propositional.Properties --- Generalised view of appending two lists into one. -import Data.List.Relation.Ternary.Appending +-- Appending of lists using setoid equality +import Data.List.Relation.Ternary.Appending.Setoid --- Properties of the generalised view of appending two lists -import Data.List.Relation.Ternary.Appending.Properties +-- Properties of list appending +import Data.List.Relation.Ternary.Appending.Setoid.Properties --- Appending of lists using propositional equality -import Data.List.Relation.Ternary.Appending.Propositional +-- Generalised notion of interleaving two lists into one in an +-- order-preserving manner +import Data.List.Relation.Ternary.Interleaving --- Properties of list appending -import Data.List.Relation.Ternary.Appending.Propositional.Properties +-- Properties of general interleavings +import Data.List.Relation.Ternary.Interleaving.Properties --- Appending of lists using setoid equality -import Data.List.Relation.Ternary.Appending.Setoid +-- Interleavings of lists using propositional equality +import Data.List.Relation.Ternary.Interleaving.Propositional --- Properties of list appending -import Data.List.Relation.Ternary.Appending.Setoid.Properties +-- Properties of interleaving using propositional equality +import Data.List.Relation.Ternary.Interleaving.Propositional.Properties --- Generalised notion of interleaving two lists into one in an --- order-preserving manner -import Data.List.Relation.Ternary.Interleaving +-- Interleavings of lists using setoid equality +import Data.List.Relation.Ternary.Interleaving.Setoid --- Properties of general interleavings -import Data.List.Relation.Ternary.Interleaving.Properties +-- Properties of interleaving using setoid equality +import Data.List.Relation.Ternary.Interleaving.Setoid.Properties --- Interleavings of lists using propositional equality -import Data.List.Relation.Ternary.Interleaving.Propositional +-- Lists where all elements satisfy a given property +import Data.List.Relation.Unary.All --- Properties of interleaving using propositional equality -import Data.List.Relation.Ternary.Interleaving.Propositional.Properties +-- Properties related to All +import Data.List.Relation.Unary.All.Properties --- Interleavings of lists using setoid equality -import Data.List.Relation.Ternary.Interleaving.Setoid +-- Lists where every pair of elements are related (symmetrically) +import Data.List.Relation.Unary.AllPairs --- Properties of interleaving using setoid equality -import Data.List.Relation.Ternary.Interleaving.Setoid.Properties +-- Properties related to AllPairs +import Data.List.Relation.Unary.AllPairs.Properties --- Lists where all elements satisfy a given property -import Data.List.Relation.Unary.All +-- Lists where at least one element satisfies a given property +import Data.List.Relation.Unary.Any --- Properties related to All -import Data.List.Relation.Unary.All.Properties +-- Properties related to Any +import Data.List.Relation.Unary.Any.Properties --- Lists where every pair of elements are related (symmetrically) -import Data.List.Relation.Unary.AllPairs +-- Lists which contain every element of a given type +import Data.List.Relation.Unary.Enumerates.Setoid --- Properties related to AllPairs -import Data.List.Relation.Unary.AllPairs.Properties +-- Properties of lists which contain every element of a given type +import Data.List.Relation.Unary.Enumerates.Setoid.Properties --- Lists where at least one element satisfies a given property -import Data.List.Relation.Unary.Any +-- First generalizes the idea that an element is the first in a list to +-- satisfy a predicate. +import Data.List.Relation.Unary.First --- Properties related to Any -import Data.List.Relation.Unary.Any.Properties +-- Properties of First +import Data.List.Relation.Unary.First.Properties --- Lists which contain every element of a given type -import Data.List.Relation.Unary.Enumerates.Setoid +-- Property that elements are grouped +import Data.List.Relation.Unary.Grouped --- Properties of lists which contain every element of a given type -import Data.List.Relation.Unary.Enumerates.Setoid.Properties +-- Property related to Grouped +import Data.List.Relation.Unary.Grouped.Properties --- First generalizes the idea that an element is the first in a list to --- satisfy a predicate. -import Data.List.Relation.Unary.First +-- Lists where every consecutative pair of elements is related. +import Data.List.Relation.Unary.Linked --- Properties of First -import Data.List.Relation.Unary.First.Properties +-- Properties related to Linked +import Data.List.Relation.Unary.Linked.Properties --- Property that elements are grouped -import Data.List.Relation.Unary.Grouped +-- Sorted lists +import Data.List.Relation.Unary.Sorted.TotalOrder --- Property related to Grouped -import Data.List.Relation.Unary.Grouped.Properties +-- Sorted lists +import Data.List.Relation.Unary.Sorted.TotalOrder.Properties --- Lists where every consecutative pair of elements is related. -import Data.List.Relation.Unary.Linked +-- 'Sufficient' lists: a structurally inductive view of lists xs +-- as given by xs ≡ non-empty prefix + sufficient suffix +import Data.List.Relation.Unary.Sufficient --- Properties related to Linked -import Data.List.Relation.Unary.Linked.Properties +-- Lists made up entirely of unique elements (setoid equality) +import Data.List.Relation.Unary.Unique.DecPropositional --- Sorted lists -import Data.List.Relation.Unary.Sorted.TotalOrder +-- Properties of lists made up entirely of decidably unique elements +import Data.List.Relation.Unary.Unique.DecPropositional.Properties --- Sorted lists -import Data.List.Relation.Unary.Sorted.TotalOrder.Properties +-- Lists made up entirely of unique elements (setoid equality) +import Data.List.Relation.Unary.Unique.DecSetoid --- 'Sufficient' lists: a structurally inductive view of lists xs --- as given by xs ≡ non-empty prefix + sufficient suffix -import Data.List.Relation.Unary.Sufficient +-- Properties of lists made up entirely of decidably unique elements +import Data.List.Relation.Unary.Unique.DecSetoid.Properties --- Lists made up entirely of unique elements (setoid equality) -import Data.List.Relation.Unary.Unique.DecPropositional +-- Lists made up entirely of unique elements (propositional equality) +import Data.List.Relation.Unary.Unique.Propositional --- Properties of lists made up entirely of decidably unique elements -import Data.List.Relation.Unary.Unique.DecPropositional.Properties +-- Properties of unique lists (setoid equality) +import Data.List.Relation.Unary.Unique.Propositional.Properties --- Lists made up entirely of unique elements (setoid equality) -import Data.List.Relation.Unary.Unique.DecSetoid +-- Lists made up entirely of unique elements (setoid equality) +import Data.List.Relation.Unary.Unique.Setoid --- Properties of lists made up entirely of decidably unique elements -import Data.List.Relation.Unary.Unique.DecSetoid.Properties +-- Properties of unique lists (setoid equality) +import Data.List.Relation.Unary.Unique.Setoid.Properties --- Lists made up entirely of unique elements (propositional equality) -import Data.List.Relation.Unary.Unique.Propositional +-- Reverse view +import Data.List.Reverse --- Properties of unique lists (setoid equality) -import Data.List.Relation.Unary.Unique.Propositional.Properties +-- List scans: definitions +import Data.List.Scans.Base --- Lists made up entirely of unique elements (setoid equality) -import Data.List.Relation.Unary.Unique.Setoid +-- List scans: properties +import Data.List.Scans.Properties --- Properties of unique lists (setoid equality) -import Data.List.Relation.Unary.Unique.Setoid.Properties +-- Showing lists +import Data.List.Show --- Reverse view -import Data.List.Reverse +-- Functions and definitions for sorting lists +import Data.List.Sort --- List scans: definitions -import Data.List.Scans.Base +-- The core definition of a sorting algorithm +import Data.List.Sort.Base --- List scans: properties -import Data.List.Scans.Properties +-- An implementation of insertion sort and its properties +import Data.List.Sort.InsertionSort --- Showing lists -import Data.List.Show +-- An implementation of insertion sort +import Data.List.Sort.InsertionSort.Base --- Functions and definitions for sorting lists -import Data.List.Sort +-- Properties of insertion sort +import Data.List.Sort.InsertionSort.Properties --- The core definition of a sorting algorithm -import Data.List.Sort.Base +-- An implementation of merge sort along with proofs of correctness. +import Data.List.Sort.MergeSort --- An implementation of insertion sort and its properties -import Data.List.Sort.InsertionSort +-- An implementation of merge sort +import Data.List.Sort.MergeSort.Base --- An implementation of insertion sort -import Data.List.Sort.InsertionSort.Base +-- An implementation of merge sort along with proofs of correctness. +import Data.List.Sort.MergeSort.Properties --- Properties of insertion sort -import Data.List.Sort.InsertionSort.Properties +-- List Zippers, basic types and operations +import Data.List.Zipper --- An implementation of merge sort along with proofs of correctness. -import Data.List.Sort.MergeSort +-- List Zipper-related properties +import Data.List.Zipper.Properties --- An implementation of merge sort -import Data.List.Sort.MergeSort.Base +-- The Maybe type +import Data.Maybe --- An implementation of merge sort along with proofs of correctness. -import Data.List.Sort.MergeSort.Properties +-- The Maybe type and some operations +import Data.Maybe.Base --- List Zippers, basic types and operations -import Data.List.Zipper +-- An effectful view of Maybe +import Data.Maybe.Effectful --- List Zipper-related properties -import Data.List.Zipper.Properties +-- An effectful view of Maybe +import Data.Maybe.Effectful.Transformer --- The Maybe type -import Data.Maybe +-- Typeclass instances for Maybe +import Data.Maybe.Instances --- The Maybe type and some operations -import Data.Maybe.Base +-- Maybe-related properties +import Data.Maybe.Properties --- An effectful view of Maybe -import Data.Maybe.Effectful +-- Lifting a relation such that `nothing` is also related to `just` +import Data.Maybe.Relation.Binary.Connected --- An effectful view of Maybe -import Data.Maybe.Effectful.Transformer +-- Pointwise lifting of relations to maybes +import Data.Maybe.Relation.Binary.Pointwise --- Typeclass instances for Maybe -import Data.Maybe.Instances +-- Maybes where all the elements satisfy a given property +import Data.Maybe.Relation.Unary.All --- Maybe-related properties -import Data.Maybe.Properties +-- Properties related to All +import Data.Maybe.Relation.Unary.All.Properties --- Lifting a relation such that `nothing` is also related to `just` -import Data.Maybe.Relation.Binary.Connected +-- Maybes where one of the elements satisfies a given property +import Data.Maybe.Relation.Unary.Any --- Pointwise lifting of relations to maybes -import Data.Maybe.Relation.Binary.Pointwise +-- Natural numbers +import Data.Nat --- Maybes where all the elements satisfy a given property -import Data.Maybe.Relation.Unary.All +-- Natural numbers, basic types and operations +import Data.Nat.Base --- Properties related to All -import Data.Maybe.Relation.Unary.All.Properties +-- Natural numbers represented in binary natively in Agda. +import Data.Nat.Binary --- Maybes where one of the elements satisfies a given property -import Data.Maybe.Relation.Unary.Any +-- Natural numbers represented in binary. +import Data.Nat.Binary.Base --- Natural numbers -import Data.Nat +-- Induction over _<_ for ℕᵇ. +import Data.Nat.Binary.Induction --- Natural numbers, basic types and operations -import Data.Nat.Base +-- Instances for binary natural numbers +import Data.Nat.Binary.Instances --- Natural numbers represented in binary natively in Agda. -import Data.Nat.Binary +-- Basic properties of ℕᵇ +import Data.Nat.Binary.Properties --- Natural numbers represented in binary. -import Data.Nat.Binary.Base +-- Subtraction on Bin and some of its properties. +import Data.Nat.Binary.Subtraction --- Induction over _<_ for ℕᵇ. -import Data.Nat.Binary.Induction +-- Combinatorial operations +import Data.Nat.Combinatorics --- Instances for binary natural numbers -import Data.Nat.Binary.Instances +-- Combinatorics operations +import Data.Nat.Combinatorics.Base --- Basic properties of ℕᵇ -import Data.Nat.Binary.Properties +-- The specification for combinatorics operations +import Data.Nat.Combinatorics.Specification --- Subtraction on Bin and some of its properties. -import Data.Nat.Binary.Subtraction +-- Coprimality +import Data.Nat.Coprimality --- Combinatorial operations -import Data.Nat.Combinatorics +-- Natural number division +import Data.Nat.DivMod --- Combinatorics operations -import Data.Nat.Combinatorics.Base +-- More efficient mod and divMod operations (require the K axiom) +import Data.Nat.DivMod.WithK --- The specification for combinatorics operations -import Data.Nat.Combinatorics.Specification +-- Divisibility +import Data.Nat.Divisibility --- Coprimality -import Data.Nat.Coprimality +-- Greatest common divisor +import Data.Nat.GCD --- Natural number division -import Data.Nat.DivMod +-- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality +import Data.Nat.GCD.Lemmas --- More efficient mod and divMod operations (require the K axiom) -import Data.Nat.DivMod.WithK +-- A generalisation of the arithmetic operations +import Data.Nat.GeneralisedArithmetic --- Divisibility -import Data.Nat.Divisibility +-- Various forms of induction for natural numbers +import Data.Nat.Induction --- Greatest common divisor -import Data.Nat.GCD +-- Definition of and lemmas related to "true infinitely often" +import Data.Nat.InfinitelyOften --- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality -import Data.Nat.GCD.Lemmas +-- Instances for natural numbers +import Data.Nat.Instances --- A generalisation of the arithmetic operations -import Data.Nat.GeneralisedArithmetic +-- Least common multiple +import Data.Nat.LCM --- Various forms of induction for natural numbers -import Data.Nat.Induction +-- Natural numbers: sum and product of lists +import Data.Nat.ListAction --- Definition of and lemmas related to "true infinitely often" -import Data.Nat.InfinitelyOften +-- Natural numbers: properties of sum and product +import Data.Nat.ListAction.Properties --- Instances for natural numbers -import Data.Nat.Instances +-- Natural Literals +import Data.Nat.Literals --- Least common multiple -import Data.Nat.LCM +-- Logarithm base 2 and respective properties +import Data.Nat.Logarithm --- Natural numbers: sum and product of lists -import Data.Nat.ListAction +-- Primality +import Data.Nat.Primality --- Natural numbers: properties of sum and product -import Data.Nat.ListAction.Properties +-- Prime factorisation of natural numbers and its properties +import Data.Nat.Primality.Factorisation --- Natural Literals -import Data.Nat.Literals +-- A bunch of properties about natural number operations +import Data.Nat.Properties --- Logarithm base 2 and respective properties -import Data.Nat.Logarithm +-- Linear congruential pseudo random generators for natural numbers +-- /!\ NB: LCGs must not be used for cryptographic applications +import Data.Nat.PseudoRandom.LCG --- Primality -import Data.Nat.Primality +-- Unsafe operations over linear congruential pseudo random generators +-- for natural numbers +-- /!\ NB: LCGs must not be used for cryptographic applications +import Data.Nat.PseudoRandom.LCG.Unsafe --- Prime factorisation of natural numbers and its properties -import Data.Nat.Primality.Factorisation +-- Reflection utilities for ℕ +import Data.Nat.Reflection --- A bunch of properties about natural number operations -import Data.Nat.Properties +-- Showing natural numbers +import Data.Nat.Show --- Linear congruential pseudo random generators for natural numbers --- /!\ NB: LCGs must not be used for cryptographic applications -import Data.Nat.PseudoRandom.LCG +-- Properties of showing natural numbers +import Data.Nat.Show.Properties --- Unsafe operations over linear congruential pseudo random generators --- for natural numbers --- /!\ NB: LCGs must not be used for cryptographic applications -import Data.Nat.PseudoRandom.LCG.Unsafe +-- Automatic solvers for equations over naturals +import Data.Nat.Solver --- Reflection utilities for ℕ -import Data.Nat.Reflection +-- Automatic solvers for equations over naturals +import Data.Nat.Tactic.RingSolver --- Showing natural numbers -import Data.Nat.Show +-- Natural number types and operations requiring the axiom K. +import Data.Nat.WithK --- Properties of showing natural numbers -import Data.Nat.Show.Properties +-- Parity +import Data.Parity --- Automatic solvers for equations over naturals -import Data.Nat.Solver +-- Parity +import Data.Parity.Base --- Automatic solvers for equations over naturals -import Data.Nat.Tactic.RingSolver +-- Instances for parities +import Data.Parity.Instances --- Natural number types and operations requiring the axiom K. -import Data.Nat.WithK +-- Some properties about parities +import Data.Parity.Properties --- Parity -import Data.Parity +-- Products +import Data.Product --- Parity -import Data.Parity.Base +-- Algebraic properties of products +import Data.Product.Algebra --- Instances for parities -import Data.Parity.Instances +-- Products +import Data.Product.Base --- Some properties about parities -import Data.Parity.Properties +-- Universe-sensitive functor and monad instances for the Product type. +import Data.Product.Effectful.Examples --- Products -import Data.Product +-- Left-biased universe-sensitive functor and monad instances for the +-- Product type. +import Data.Product.Effectful.Left --- Algebraic properties of products -import Data.Product.Algebra +-- Base definitions for the left-biased universe-sensitive functor and +-- monad instances for the Product type. +import Data.Product.Effectful.Left.Base --- Products -import Data.Product.Base +-- Right-biased universe-sensitive functor and monad instances for the +-- Product type. +import Data.Product.Effectful.Right --- Universe-sensitive functor and monad instances for the Product type. -import Data.Product.Effectful.Examples +-- Base definitions for the right-biased universe-sensitive functor +-- and monad instances for the Product type. +import Data.Product.Effectful.Right.Base --- Left-biased universe-sensitive functor and monad instances for the --- Product type. -import Data.Product.Effectful.Left +-- Dependent product combinators for propositional equality +-- preserving functions +import Data.Product.Function.Dependent.Propositional --- Base definitions for the left-biased universe-sensitive functor and --- monad instances for the Product type. -import Data.Product.Effectful.Left.Base +-- Dependent product combinators for propositional equality +-- preserving functions +import Data.Product.Function.Dependent.Propositional.WithK --- Right-biased universe-sensitive functor and monad instances for the --- Product type. -import Data.Product.Effectful.Right +-- Dependent product combinators for setoid equality preserving +-- functions. +import Data.Product.Function.Dependent.Setoid --- Base definitions for the right-biased universe-sensitive functor --- and monad instances for the Product type. -import Data.Product.Effectful.Right.Base +-- Non-dependent product combinators for propositional equality +-- preserving functions +import Data.Product.Function.NonDependent.Propositional --- Dependent product combinators for propositional equality --- preserving functions -import Data.Product.Function.Dependent.Propositional +-- Non-dependent product combinators for setoid equality preserving +-- functions +import Data.Product.Function.NonDependent.Setoid --- Dependent product combinators for propositional equality --- preserving functions -import Data.Product.Function.Dependent.Propositional.WithK +-- Typeclass instances for products +import Data.Product.Instances --- Dependent product combinators for setoid equality preserving --- functions. -import Data.Product.Function.Dependent.Setoid +-- Nondependent heterogeneous N-ary products +import Data.Product.Nary.NonDependent --- Non-dependent product combinators for propositional equality --- preserving functions -import Data.Product.Function.NonDependent.Propositional +-- Properties of products +import Data.Product.Properties --- Non-dependent product combinators for setoid equality preserving --- functions -import Data.Product.Function.NonDependent.Setoid +-- Properties of 'very dependent' map / zipWith over products +import Data.Product.Properties.Dependent --- Typeclass instances for products -import Data.Product.Instances +-- Properties, related to products, that rely on the K rule +import Data.Product.Properties.WithK --- Nondependent heterogeneous N-ary products -import Data.Product.Nary.NonDependent +-- Lexicographic products of binary relations +import Data.Product.Relation.Binary.Lex.NonStrict --- Properties of products -import Data.Product.Properties +-- Lexicographic products of binary relations +import Data.Product.Relation.Binary.Lex.Strict --- Properties of 'very dependent' map / zipWith over products -import Data.Product.Properties.Dependent +-- Pointwise lifting of binary relations to sigma types +import Data.Product.Relation.Binary.Pointwise.Dependent --- Properties, related to products, that rely on the K rule -import Data.Product.Properties.WithK +-- Properties that are related to pointwise lifting of binary +-- relations to sigma types and make use of heterogeneous equality +import Data.Product.Relation.Binary.Pointwise.Dependent.WithK --- Lexicographic products of binary relations -import Data.Product.Relation.Binary.Lex.NonStrict +-- Pointwise products of binary relations +import Data.Product.Relation.Binary.Pointwise.NonDependent --- Lexicographic products of binary relations -import Data.Product.Relation.Binary.Lex.Strict +-- Lifting of two predicates +import Data.Product.Relation.Unary.All --- Pointwise lifting of binary relations to sigma types -import Data.Product.Relation.Binary.Pointwise.Dependent +-- Rational numbers +import Data.Rational --- Properties that are related to pointwise lifting of binary --- relations to sigma types and make use of heterogeneous equality -import Data.Product.Relation.Binary.Pointwise.Dependent.WithK +-- Rational numbers +import Data.Rational.Base --- Pointwise products of binary relations -import Data.Product.Relation.Binary.Pointwise.NonDependent +-- Instances for rational numbers +import Data.Rational.Instances --- Lifting of two predicates -import Data.Product.Relation.Unary.All +-- Rational Literals +import Data.Rational.Literals --- Rational numbers -import Data.Rational +-- Properties of Rational numbers +import Data.Rational.Properties --- Rational numbers -import Data.Rational.Base +-- Showing rational numbers +import Data.Rational.Show --- Instances for rational numbers -import Data.Rational.Instances +-- Automatic solvers for equations over rationals +import Data.Rational.Solver --- Rational Literals -import Data.Rational.Literals +-- Rational numbers in non-reduced form. +import Data.Rational.Unnormalised --- Properties of Rational numbers -import Data.Rational.Properties +-- Rational numbers in non-reduced form. +import Data.Rational.Unnormalised.Base --- Showing rational numbers -import Data.Rational.Show +-- Properties of unnormalized Rational numbers +import Data.Rational.Unnormalised.Properties --- Automatic solvers for equations over rationals -import Data.Rational.Solver +-- Showing unnormalised rational numbers +import Data.Rational.Unnormalised.Show --- Rational numbers in non-reduced form. -import Data.Rational.Unnormalised +-- Automatic solvers for equations over rationals +import Data.Rational.Unnormalised.Solver --- Rational numbers in non-reduced form. -import Data.Rational.Unnormalised.Base +-- Record types with manifest fields and "with", based on Randy +-- Pollack's "Dependently Typed Records in Type Theory" +import Data.Record --- Properties of unnormalized Rational numbers -import Data.Rational.Unnormalised.Properties +-- Refinement type: a value together with a proof irrelevant witness. +import Data.Refinement --- Showing unnormalised rational numbers -import Data.Rational.Unnormalised.Show +-- Refinement type: a value together with a proof irrelevant witness. +import Data.Refinement.Base --- Automatic solvers for equations over rationals -import Data.Rational.Unnormalised.Solver +-- Properties of refinement types +import Data.Refinement.Properties --- Record types with manifest fields and "with", based on Randy --- Pollack's "Dependently Typed Records in Type Theory" -import Data.Record +-- Predicate lifting for refinement types +import Data.Refinement.Relation.Unary.All --- Refinement type: a value together with a proof irrelevant witness. -import Data.Refinement +-- Signs +import Data.Sign --- Refinement type: a value together with a proof irrelevant witness. -import Data.Refinement.Base +-- Signs +import Data.Sign.Base --- Properties of refinement types -import Data.Refinement.Properties +-- Instances for signs +import Data.Sign.Instances --- Predicate lifting for refinement types -import Data.Refinement.Relation.Unary.All +-- Some properties about signs +import Data.Sign.Properties --- Signs -import Data.Sign +-- Showing signs +import Data.Sign.Show --- Signs -import Data.Sign.Base +-- Bounded vectors (inefficient implementation) +import Data.Star.BoundedVec --- Instances for signs -import Data.Sign.Instances +-- Decorated star-lists +import Data.Star.Decoration --- Some properties about signs -import Data.Sign.Properties +-- Environments (heterogeneous collections) +import Data.Star.Environment --- Showing signs -import Data.Sign.Show +-- Finite sets defined using the reflexive-transitive closure, Star +import Data.Star.Fin --- Bounded vectors (inefficient implementation) -import Data.Star.BoundedVec +-- Lists defined in terms of the reflexive-transitive closure, Star +import Data.Star.List --- Decorated star-lists -import Data.Star.Decoration +-- Natural numbers defined using the reflexive-transitive closure, Star +import Data.Star.Nat --- Environments (heterogeneous collections) -import Data.Star.Environment +-- Pointers into star-lists +import Data.Star.Pointer --- Finite sets defined using the reflexive-transitive closure, Star -import Data.Star.Fin +-- Vectors defined in terms of the reflexive-transitive closure, Star +import Data.Star.Vec --- Lists defined in terms of the reflexive-transitive closure, Star -import Data.Star.List +-- Strings +import Data.String --- Natural numbers defined using the reflexive-transitive closure, Star -import Data.Star.Nat +-- Strings: builtin type and basic operations +import Data.String.Base --- Pointers into star-lists -import Data.Star.Pointer +-- Instances for strings +import Data.String.Instances --- Vectors defined in terms of the reflexive-transitive closure, Star -import Data.Star.Vec +-- String Literals +import Data.String.Literals --- Strings -import Data.String +-- Properties of operations on strings +import Data.String.Properties --- Strings: builtin type and basic operations -import Data.String.Base +-- Unsafe String operations and proofs +import Data.String.Unsafe --- Instances for strings -import Data.String.Instances +-- Sums (disjoint unions) +import Data.Sum --- String Literals -import Data.String.Literals +-- Algebraic properties of sums (disjoint unions) +import Data.Sum.Algebra --- Properties of operations on strings -import Data.String.Properties +-- Sums (disjoint unions) +import Data.Sum.Base --- Unsafe String operations and proofs -import Data.String.Unsafe +-- Usage examples of the effectful view of the Sum type +import Data.Sum.Effectful.Examples --- Sums (disjoint unions) -import Data.Sum +-- An effectful view of the Sum type (Left-biased) +import Data.Sum.Effectful.Left --- Algebraic properties of sums (disjoint unions) -import Data.Sum.Algebra +-- An effectful view of the Sum type (Left-biased) +import Data.Sum.Effectful.Left.Transformer --- Sums (disjoint unions) -import Data.Sum.Base +-- An effectful view of the Sum type (Right-biased) +import Data.Sum.Effectful.Right --- Usage examples of the effectful view of the Sum type -import Data.Sum.Effectful.Examples +-- An effectful view of the Sum type (Right-biased) +import Data.Sum.Effectful.Right.Transformer --- An effectful view of the Sum type (Left-biased) -import Data.Sum.Effectful.Left +-- Sum combinators for propositional equality preserving functions +import Data.Sum.Function.Propositional --- An effectful view of the Sum type (Left-biased) -import Data.Sum.Effectful.Left.Transformer +-- Sum combinators for setoid equality preserving functions +import Data.Sum.Function.Setoid --- An effectful view of the Sum type (Right-biased) -import Data.Sum.Effectful.Right +-- Typeclass instances for sums +import Data.Sum.Instances --- An effectful view of the Sum type (Right-biased) -import Data.Sum.Effectful.Right.Transformer +-- Properties of sums (disjoint unions) +import Data.Sum.Properties --- Sum combinators for propositional equality preserving functions -import Data.Sum.Function.Propositional +-- Sums of binary relations +import Data.Sum.Relation.Binary.LeftOrder --- Sum combinators for setoid equality preserving functions -import Data.Sum.Function.Setoid +-- Pointwise sum +import Data.Sum.Relation.Binary.Pointwise --- Typeclass instances for sums -import Data.Sum.Instances +-- Heterogeneous `All` predicate for disjoint sums +import Data.Sum.Relation.Unary.All --- Properties of sums (disjoint unions) -import Data.Sum.Properties +-- An either-or-both data type +import Data.These --- Sums of binary relations -import Data.Sum.Relation.Binary.LeftOrder +-- An either-or-both data type, basic type and operations +import Data.These.Base --- Pointwise sum -import Data.Sum.Relation.Binary.Pointwise +-- Left-biased universe-sensitive functor and monad instances for These. +import Data.These.Effectful.Left --- Heterogeneous `All` predicate for disjoint sums -import Data.Sum.Relation.Unary.All +-- Base definitions for the left-biased universe-sensitive functor and +-- monad instances for These. +import Data.These.Effectful.Left.Base --- An either-or-both data type -import Data.These +-- Right-biased universe-sensitive functor and monad instances for These. +import Data.These.Effectful.Right --- An either-or-both data type, basic type and operations -import Data.These.Base +-- Base definitions for the right-biased universe-sensitive functor and +-- monad instances for These. +import Data.These.Effectful.Right.Base --- Left-biased universe-sensitive functor and monad instances for These. -import Data.These.Effectful.Left +-- Typeclass instances for These +import Data.These.Instances --- Base definitions for the left-biased universe-sensitive functor and --- monad instances for These. -import Data.These.Effectful.Left.Base +-- Properties of These +import Data.These.Properties --- Right-biased universe-sensitive functor and monad instances for These. -import Data.These.Effectful.Right +-- AVL trees +import Data.Tree.AVL --- Base definitions for the right-biased universe-sensitive functor and --- monad instances for These. -import Data.These.Effectful.Right.Base +-- Types and functions which are used to keep track of height +-- invariants in AVL Trees +import Data.Tree.AVL.Height --- Typeclass instances for These -import Data.These.Instances +-- AVL trees where the stored values may depend on their key +import Data.Tree.AVL.Indexed --- Properties of These -import Data.These.Properties +-- AVL trees whose elements satisfy a given property +import Data.Tree.AVL.Indexed.Relation.Unary.All --- AVL trees -import Data.Tree.AVL +-- AVL trees where at least one element satisfies a given property +import Data.Tree.AVL.Indexed.Relation.Unary.Any --- Types and functions which are used to keep track of height --- invariants in AVL Trees -import Data.Tree.AVL.Height +-- Properties related to Any +import Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties --- AVL trees where the stored values may depend on their key -import Data.Tree.AVL.Indexed +-- Some code related to indexed AVL trees that relies on the K rule +import Data.Tree.AVL.Indexed.WithK --- AVL trees whose elements satisfy a given property -import Data.Tree.AVL.Indexed.Relation.Unary.All +-- Finite maps with indexed keys and values, based on AVL trees +import Data.Tree.AVL.IndexedMap --- AVL trees where at least one element satisfies a given property -import Data.Tree.AVL.Indexed.Relation.Unary.Any +-- Keys for AVL trees -- the original key type extended with a new +-- minimum and maximum. +import Data.Tree.AVL.Key --- Properties related to Any -import Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties +-- Maps from keys to values, based on AVL trees +-- This modules provides a simpler map interface, without a dependency +-- between the key and value types. +import Data.Tree.AVL.Map --- Some code related to indexed AVL trees that relies on the K rule -import Data.Tree.AVL.Indexed.WithK +-- Membership relation for AVL Maps identifying values up to +-- propositional equality. +import Data.Tree.AVL.Map.Membership.Propositional --- Finite maps with indexed keys and values, based on AVL trees -import Data.Tree.AVL.IndexedMap +-- Properties of the membership relation for AVL Maps identifying values +-- up to propositional equality. +import Data.Tree.AVL.Map.Membership.Propositional.Properties --- Keys for AVL trees -- the original key type extended with a new --- minimum and maximum. -import Data.Tree.AVL.Key +-- AVL trees where at least one element satisfies a given property +import Data.Tree.AVL.Map.Relation.Unary.Any --- Maps from keys to values, based on AVL trees --- This modules provides a simpler map interface, without a dependency --- between the key and value types. -import Data.Tree.AVL.Map +-- Non-empty AVL trees +import Data.Tree.AVL.NonEmpty --- Membership relation for AVL Maps identifying values up to --- propositional equality. -import Data.Tree.AVL.Map.Membership.Propositional +-- Non-empty AVL trees, where equality for keys is propositional equality +import Data.Tree.AVL.NonEmpty.Propositional --- Properties of the membership relation for AVL Maps identifying values --- up to propositional equality. -import Data.Tree.AVL.Map.Membership.Propositional.Properties +-- AVL trees where at least one element satisfies a given property +import Data.Tree.AVL.Relation.Unary.Any --- AVL trees where at least one element satisfies a given property -import Data.Tree.AVL.Map.Relation.Unary.Any +-- Finite sets, based on AVL trees +import Data.Tree.AVL.Sets --- Non-empty AVL trees -import Data.Tree.AVL.NonEmpty +-- Membership relation for AVL sets +import Data.Tree.AVL.Sets.Membership --- Non-empty AVL trees, where equality for keys is propositional equality -import Data.Tree.AVL.NonEmpty.Propositional +-- Properties of membership for AVL sets +import Data.Tree.AVL.Sets.Membership.Properties --- AVL trees where at least one element satisfies a given property -import Data.Tree.AVL.Relation.Unary.Any +-- Values for AVL trees +-- Values must respect the underlying equivalence on keys +import Data.Tree.AVL.Value --- Finite sets, based on AVL trees -import Data.Tree.AVL.Sets +-- Binary Trees +import Data.Tree.Binary --- Membership relation for AVL sets -import Data.Tree.AVL.Sets.Membership +-- Properties of binary trees +import Data.Tree.Binary.Properties --- Properties of membership for AVL sets -import Data.Tree.AVL.Sets.Membership.Properties +-- Pointwise lifting of a predicate to a binary tree +import Data.Tree.Binary.Relation.Unary.All --- Values for AVL trees --- Values must respect the underlying equivalence on keys -import Data.Tree.AVL.Value +-- Properties of the pointwise lifting of a predicate to a binary tree +import Data.Tree.Binary.Relation.Unary.All.Properties --- Binary Trees -import Data.Tree.Binary +-- 1 dimensional pretty printing of binary trees +import Data.Tree.Binary.Show --- Properties of binary trees -import Data.Tree.Binary.Properties +-- Zippers for Binary Trees +import Data.Tree.Binary.Zipper --- Pointwise lifting of a predicate to a binary tree -import Data.Tree.Binary.Relation.Unary.All +-- Tree Zipper-related properties +import Data.Tree.Binary.Zipper.Properties --- Properties of the pointwise lifting of a predicate to a binary tree -import Data.Tree.Binary.Relation.Unary.All.Properties +-- Rose trees +import Data.Tree.Rose --- 1 dimensional pretty printing of binary trees -import Data.Tree.Binary.Show +-- Properties of rose trees +import Data.Tree.Rose.Properties --- Zippers for Binary Trees -import Data.Tree.Binary.Zipper +-- 1 dimensional pretty printing of rose trees +import Data.Tree.Rose.Show --- Tree Zipper-related properties -import Data.Tree.Binary.Zipper.Properties +-- Trie, basic type and operations +import Data.Trie --- Rose trees -import Data.Tree.Rose +-- Non empty trie, basic type and operations +import Data.Trie.NonEmpty --- Properties of rose trees -import Data.Tree.Rose.Properties +-- The unit type, Level-monomorphic version +import Data.Unit --- 1 dimensional pretty printing of rose trees -import Data.Tree.Rose.Show +-- The unit type and the total relation on unit +import Data.Unit.Base --- Trie, basic type and operations -import Data.Trie +-- Instances for the unit type +import Data.Unit.Instances --- Non empty trie, basic type and operations -import Data.Trie.NonEmpty +-- Some unit types +import Data.Unit.NonEta --- The unit type, Level-monomorphic version -import Data.Unit +-- The universe polymorphic unit type and the total relation on unit +import Data.Unit.Polymorphic --- The unit type and the total relation on unit -import Data.Unit.Base +-- A universe polymorphic unit type, as a Lift of the Level 0 one. +import Data.Unit.Polymorphic.Base --- Instances for the unit type -import Data.Unit.Instances +-- Instances for the polymorphic unit type +import Data.Unit.Polymorphic.Instances --- Some unit types -import Data.Unit.NonEta +-- Properties of the polymorphic unit type +-- Defines Decidable Equality and Decidable Ordering as well +import Data.Unit.Polymorphic.Properties --- The universe polymorphic unit type and the total relation on unit -import Data.Unit.Polymorphic +-- Properties of the unit type +import Data.Unit.Properties --- A universe polymorphic unit type, as a Lift of the Level 0 one. -import Data.Unit.Polymorphic.Base +-- Universes +import Data.Universe --- Instances for the polymorphic unit type -import Data.Unit.Polymorphic.Instances +-- Indexed universes +import Data.Universe.Indexed --- Properties of the polymorphic unit type --- Defines Decidable Equality and Decidable Ordering as well -import Data.Unit.Polymorphic.Properties +-- Vectors +import Data.Vec --- Properties of the unit type -import Data.Unit.Properties +-- Vectors, basic types and operations +import Data.Vec.Base --- Universes -import Data.Universe +-- Bounded vectors +import Data.Vec.Bounded --- Indexed universes -import Data.Universe.Indexed +-- Bounded vectors, basic types and operations +import Data.Vec.Bounded.Base --- Vectors -import Data.Vec +-- Showing bounded vectors +import Data.Vec.Bounded.Show --- Vectors, basic types and operations -import Data.Vec.Base +-- An effectful view of Vec +import Data.Vec.Effectful --- Bounded vectors -import Data.Vec.Bounded +-- Vec is Foldable +import Data.Vec.Effectful.Foldable --- Bounded vectors, basic types and operations -import Data.Vec.Bounded.Base +-- An effectful view of Vec +import Data.Vec.Effectful.Transformer --- Showing bounded vectors -import Data.Vec.Bounded.Show +-- Vectors defined as functions from a finite set to a type. +import Data.Vec.Functional --- An effectful view of Vec -import Data.Vec.Effectful +-- Some Vector-related properties +import Data.Vec.Functional.Properties --- Vec is Foldable -import Data.Vec.Effectful.Foldable +-- Pointwise lifting of relations over Vector +import Data.Vec.Functional.Relation.Binary.Equality.Setoid --- An effectful view of Vec -import Data.Vec.Effectful.Transformer +-- Permutation relations over Vector +import Data.Vec.Functional.Relation.Binary.Permutation --- Vectors defined as functions from a finite set to a type. -import Data.Vec.Functional +-- Properties of permutation +import Data.Vec.Functional.Relation.Binary.Permutation.Properties --- Some Vector-related properties -import Data.Vec.Functional.Properties +-- Pointwise lifting of relations over Vector +import Data.Vec.Functional.Relation.Binary.Pointwise --- Pointwise lifting of relations over Vector -import Data.Vec.Functional.Relation.Binary.Equality.Setoid +-- Properties related to Pointwise +import Data.Vec.Functional.Relation.Binary.Pointwise.Properties --- Permutation relations over Vector -import Data.Vec.Functional.Relation.Binary.Permutation +-- Universal lifting of predicates over Vectors +import Data.Vec.Functional.Relation.Unary.All --- Properties of permutation -import Data.Vec.Functional.Relation.Binary.Permutation.Properties +-- Properties related to All +import Data.Vec.Functional.Relation.Unary.All.Properties --- Pointwise lifting of relations over Vector -import Data.Vec.Functional.Relation.Binary.Pointwise +-- Existential lifting of predicates over Vectors +import Data.Vec.Functional.Relation.Unary.Any --- Properties related to Pointwise -import Data.Vec.Functional.Relation.Binary.Pointwise.Properties +-- Typeclass instances for Vec +import Data.Vec.Instances --- Universal lifting of predicates over Vectors -import Data.Vec.Functional.Relation.Unary.All +-- Decidable propositional membership over vectors +import Data.Vec.Membership.DecPropositional --- Properties related to All -import Data.Vec.Functional.Relation.Unary.All.Properties +-- Decidable setoid membership over vectors. +import Data.Vec.Membership.DecSetoid --- Existential lifting of predicates over Vectors -import Data.Vec.Functional.Relation.Unary.Any +-- Data.Vec.Any.Membership instantiated with propositional equality, +-- along with some additional definitions. +import Data.Vec.Membership.Propositional --- Typeclass instances for Vec -import Data.Vec.Instances +-- Properties of membership of vectors based on propositional equality. +import Data.Vec.Membership.Propositional.Properties --- Decidable propositional membership over vectors -import Data.Vec.Membership.DecPropositional +-- Membership of vectors, along with some additional definitions. +import Data.Vec.Membership.Setoid --- Decidable setoid membership over vectors. -import Data.Vec.Membership.DecSetoid +-- Code for converting Vec A n → B to and from n-ary functions +import Data.Vec.N-ary --- Data.Vec.Any.Membership instantiated with propositional equality, --- along with some additional definitions. -import Data.Vec.Membership.Propositional +-- Some Vec-related properties +import Data.Vec.Properties --- Properties of membership of vectors based on propositional equality. -import Data.Vec.Membership.Propositional.Properties +-- Some Vec-related properties that depend on the K rule or make use +-- of heterogeneous equality +import Data.Vec.Properties.WithK --- Membership of vectors, along with some additional definitions. -import Data.Vec.Membership.Setoid +-- Vectors defined by recursion +import Data.Vec.Recursive --- Code for converting Vec A n → B to and from n-ary functions -import Data.Vec.N-ary +-- An effectful view of vectors defined by recursion +import Data.Vec.Recursive.Effectful --- Some Vec-related properties -import Data.Vec.Properties +-- Properties of n-ary products +import Data.Vec.Recursive.Properties --- Some Vec-related properties that depend on the K rule or make use --- of heterogeneous equality -import Data.Vec.Properties.WithK +-- Reflection utilities for Vector +import Data.Vec.Reflection --- Vectors defined by recursion -import Data.Vec.Recursive +-- An equational reasoning library for propositional equality over +-- vectors of different indices using cast. +import Data.Vec.Relation.Binary.Equality.Cast --- An effectful view of vectors defined by recursion -import Data.Vec.Recursive.Effectful +-- Decidable vector equality over propositional equality +import Data.Vec.Relation.Binary.Equality.DecPropositional --- Properties of n-ary products -import Data.Vec.Recursive.Properties +-- Decidable semi-heterogeneous vector equality over setoids +import Data.Vec.Relation.Binary.Equality.DecSetoid --- Reflection utilities for Vector -import Data.Vec.Reflection +-- Vector equality over propositional equality +import Data.Vec.Relation.Binary.Equality.Propositional --- An equational reasoning library for propositional equality over --- vectors of different indices using cast. -import Data.Vec.Relation.Binary.Equality.Cast +-- Code related to vector equality over propositional equality that +-- makes use of heterogeneous equality +import Data.Vec.Relation.Binary.Equality.Propositional.WithK --- Decidable vector equality over propositional equality -import Data.Vec.Relation.Binary.Equality.DecPropositional +-- Semi-heterogeneous vector equality over setoids +import Data.Vec.Relation.Binary.Equality.Setoid --- Decidable semi-heterogeneous vector equality over setoids -import Data.Vec.Relation.Binary.Equality.DecSetoid +-- Lexicographic ordering of same-length vector +import Data.Vec.Relation.Binary.Lex.NonStrict --- Vector equality over propositional equality -import Data.Vec.Relation.Binary.Equality.Propositional +-- Lexicographic ordering of lists of same-length vectors +import Data.Vec.Relation.Binary.Lex.Strict --- Code related to vector equality over propositional equality that --- makes use of heterogeneous equality -import Data.Vec.Relation.Binary.Equality.Propositional.WithK +-- Extensional pointwise lifting of relations to vectors +import Data.Vec.Relation.Binary.Pointwise.Extensional --- Semi-heterogeneous vector equality over setoids -import Data.Vec.Relation.Binary.Equality.Setoid +-- Inductive pointwise lifting of relations to vectors +import Data.Vec.Relation.Binary.Pointwise.Inductive --- Lexicographic ordering of same-length vector -import Data.Vec.Relation.Binary.Lex.NonStrict +-- Vectors where all elements satisfy a given property +import Data.Vec.Relation.Unary.All --- Lexicographic ordering of lists of same-length vectors -import Data.Vec.Relation.Binary.Lex.Strict +-- Properties related to All +import Data.Vec.Relation.Unary.All.Properties --- Extensional pointwise lifting of relations to vectors -import Data.Vec.Relation.Binary.Pointwise.Extensional +-- Vectors where every pair of elements are related (symmetrically) +import Data.Vec.Relation.Unary.AllPairs --- Inductive pointwise lifting of relations to vectors -import Data.Vec.Relation.Binary.Pointwise.Inductive +-- Properties related to AllPairs +import Data.Vec.Relation.Unary.AllPairs.Properties --- Vectors where all elements satisfy a given property -import Data.Vec.Relation.Unary.All +-- Vectors where at least one element satisfies a given property +import Data.Vec.Relation.Unary.Any --- Properties related to All -import Data.Vec.Relation.Unary.All.Properties +-- Properties of vector's Any +import Data.Vec.Relation.Unary.Any.Properties --- Vectors where every pair of elements are related (symmetrically) -import Data.Vec.Relation.Unary.AllPairs +-- Vectors where every consecutative pair of elements is related. +import Data.Vec.Relation.Unary.Linked --- Properties related to AllPairs -import Data.Vec.Relation.Unary.AllPairs.Properties +-- Properties related to Linked +import Data.Vec.Relation.Unary.Linked.Properties --- Vectors where at least one element satisfies a given property -import Data.Vec.Relation.Unary.Any +-- Vectors made up entirely of unique elements (propositional equality) +import Data.Vec.Relation.Unary.Unique.Propositional --- Properties of vector's Any -import Data.Vec.Relation.Unary.Any.Properties +-- Properties of unique vectors (setoid equality) +import Data.Vec.Relation.Unary.Unique.Propositional.Properties --- Vectors where every consecutative pair of elements is related. -import Data.Vec.Relation.Unary.Linked +-- Vectors made up entirely of unique elements (setoid equality) +import Data.Vec.Relation.Unary.Unique.Setoid --- Properties related to Linked -import Data.Vec.Relation.Unary.Linked.Properties +-- Properties of unique vectors (setoid equality) +import Data.Vec.Relation.Unary.Unique.Setoid.Properties --- Vectors made up entirely of unique elements (propositional equality) -import Data.Vec.Relation.Unary.Unique.Propositional +-- Showing vectors +import Data.Vec.Show --- Properties of unique vectors (setoid equality) -import Data.Vec.Relation.Unary.Unique.Propositional.Properties +-- W-types +import Data.W --- Vectors made up entirely of unique elements (setoid equality) -import Data.Vec.Relation.Unary.Unique.Setoid +-- Indexed W-types aka Petersson-Synek trees +import Data.W.Indexed --- Properties of unique vectors (setoid equality) -import Data.Vec.Relation.Unary.Unique.Setoid.Properties +-- Sized W-types +import Data.W.Sized --- Showing vectors -import Data.Vec.Show +-- Some code related to the W type that relies on the K rule +import Data.W.WithK --- W-types -import Data.W +-- Machine words +import Data.Word64 --- Indexed W-types aka Petersson-Synek trees -import Data.W.Indexed +-- Machine words: basic type and conversion functions +import Data.Word64.Base --- Sized W-types -import Data.W.Sized +-- Instances for words +import Data.Word64.Instances --- Some code related to the W type that relies on the K rule -import Data.W.WithK +-- Word64 Literals +import Data.Word64.Literals --- Machine words -import Data.Word64 +-- Word64: simple bindings to Haskell types and functions +import Data.Word64.Primitive --- Machine words: basic type and conversion functions -import Data.Word64.Base +-- Properties of operations on machine words +import Data.Word64.Properties --- Instances for words -import Data.Word64.Instances +-- Bytes: showing bit patterns +import Data.Word64.Show --- Word64 Literals -import Data.Word64.Literals +-- Machine words: unsafe functions using the FFI +import Data.Word64.Unsafe --- Word64: simple bindings to Haskell types and functions -import Data.Word64.Primitive +-- Bytes: base type and functions +import Data.Word8.Base --- Properties of operations on machine words -import Data.Word64.Properties +-- Byte Literals +import Data.Word8.Literals --- Bytes: showing bit patterns -import Data.Word64.Show +-- Bytes: simple bindings to Haskell types and functions +import Data.Word8.Primitive --- Machine words: unsafe functions using the FFI -import Data.Word64.Unsafe +-- Bytes: showing bit patterns +import Data.Word8.Show --- Bytes: base type and functions -import Data.Word8.Base +-- Turn a relation into a record definition so as to remember the things +-- being related. +-- This module has a readme file: README.Data.Wrap +import Data.Wrap --- Byte Literals -import Data.Word8.Literals +-- Printing Strings During Evaluation +import Debug.Trace --- Bytes: simple bindings to Haskell types and functions -import Data.Word8.Primitive +-- Applicative functors +import Effect.Applicative --- Bytes: showing bit patterns -import Data.Word8.Show +-- Indexed applicative functors +import Effect.Applicative.Indexed --- Turn a relation into a record definition so as to remember the things --- being related. --- This module has a readme file: README.Data.Wrap -import Data.Wrap +-- Applicative functors on indexed sets (predicates) +import Effect.Applicative.Predicate --- Printing Strings During Evaluation -import Debug.Trace +-- Type constructors giving rise to a semigroup at every type +-- e.g. (List, _++_) +import Effect.Choice --- Applicative functors -import Effect.Applicative +-- Comonads +import Effect.Comonad --- Indexed applicative functors -import Effect.Applicative.Indexed +-- Empty values (e.g. [] for List, nothing for Maybe) +import Effect.Empty --- Applicative functors on indexed sets (predicates) -import Effect.Applicative.Predicate +-- Foldable functors +import Effect.Foldable --- Type constructors giving rise to a semigroup at every type --- e.g. (List, _++_) -import Effect.Choice +-- Functors +import Effect.Functor --- Comonads -import Effect.Comonad +-- Functors on indexed sets (predicates) +import Effect.Functor.Predicate --- Empty values (e.g. [] for List, nothing for Maybe) -import Effect.Empty +-- Monads +import Effect.Monad --- Foldable functors -import Effect.Foldable +-- A delimited continuation monad +import Effect.Monad.Continuation --- Functors -import Effect.Functor +-- The error monad transformer +import Effect.Monad.Error.Transformer --- Functors on indexed sets (predicates) -import Effect.Functor.Predicate +-- The IO monad +import Effect.Monad.IO --- Monads -import Effect.Monad +-- Typeclass instances for the IO monad +import Effect.Monad.IO.Instances --- A delimited continuation monad -import Effect.Monad.Continuation +-- An effectful view of the identity function +import Effect.Monad.Identity --- The error monad transformer -import Effect.Monad.Error.Transformer +-- Typeclass instances for Identity +import Effect.Monad.Identity.Instances --- The IO monad -import Effect.Monad.IO +-- Indexed monads +import Effect.Monad.Indexed --- Typeclass instances for the IO monad -import Effect.Monad.IO.Instances +-- The partiality monad +import Effect.Monad.Partiality --- An effectful view of the identity function -import Effect.Monad.Identity +-- An All predicate for the partiality monad +import Effect.Monad.Partiality.All --- Typeclass instances for Identity -import Effect.Monad.Identity.Instances +-- Typeclass instances for _⊥ +import Effect.Monad.Partiality.Instances --- Indexed monads -import Effect.Monad.Indexed +-- Monads on indexed sets (predicates) +import Effect.Monad.Predicate --- The partiality monad -import Effect.Monad.Partiality +-- The reader monad +import Effect.Monad.Reader --- An All predicate for the partiality monad -import Effect.Monad.Partiality.All +-- The indexed reader monad +import Effect.Monad.Reader.Indexed --- Typeclass instances for _⊥ -import Effect.Monad.Partiality.Instances +-- Instances for the reader monad +import Effect.Monad.Reader.Instances --- Monads on indexed sets (predicates) -import Effect.Monad.Predicate +-- The reader monad transformer +import Effect.Monad.Reader.Transformer --- The reader monad -import Effect.Monad.Reader +-- Basic type and definition of the reader monad transformer +import Effect.Monad.Reader.Transformer.Base --- The indexed reader monad -import Effect.Monad.Reader.Indexed +-- The state monad +import Effect.Monad.State --- Instances for the reader monad -import Effect.Monad.Reader.Instances +-- The indexed state monad +import Effect.Monad.State.Indexed --- The reader monad transformer -import Effect.Monad.Reader.Transformer +-- Instances for the state monad +import Effect.Monad.State.Instances --- Basic type and definition of the reader monad transformer -import Effect.Monad.Reader.Transformer.Base +-- The state monad transformer +import Effect.Monad.State.Transformer --- The state monad -import Effect.Monad.State +-- Basic definition and functions on the state monad transformer +import Effect.Monad.State.Transformer.Base --- The indexed state monad -import Effect.Monad.State.Indexed +-- The writer monad +import Effect.Monad.Writer --- Instances for the state monad -import Effect.Monad.State.Instances +-- The indexed writer monad +import Effect.Monad.Writer.Indexed --- The state monad transformer -import Effect.Monad.State.Transformer +-- Instances for the writer monad +import Effect.Monad.Writer.Instances --- Basic definition and functions on the state monad transformer -import Effect.Monad.State.Transformer.Base +-- The writer monad transformer +import Effect.Monad.Writer.Transformer --- The writer monad -import Effect.Monad.Writer +-- Basic type and definition of the writer monad transformer +import Effect.Monad.Writer.Transformer.Base --- The indexed writer monad -import Effect.Monad.Writer.Indexed +-- Type(s) used (only) when calling out to Haskell via the FFI +import Foreign.Haskell --- Instances for the writer monad -import Effect.Monad.Writer.Instances +-- Zero-cost coercion to cross the FFI boundary +import Foreign.Haskell.Coerce --- The writer monad transformer -import Effect.Monad.Writer.Transformer +-- The Either type which calls out to Haskell via the FFI +import Foreign.Haskell.Either --- Basic type and definition of the writer monad transformer -import Effect.Monad.Writer.Transformer.Base +-- The NonEmpty type which calls out to Haskell via the FFI +import Foreign.Haskell.List.NonEmpty --- Type(s) used (only) when calling out to Haskell via the FFI -import Foreign.Haskell +-- The Pair type which calls out to Haskell via the FFI +import Foreign.Haskell.Pair --- Zero-cost coercion to cross the FFI boundary -import Foreign.Haskell.Coerce +-- Functions +import Function --- The Either type which calls out to Haskell via the FFI -import Foreign.Haskell.Either +-- Simple combinators working solely on and with functions +import Function.Base --- The NonEmpty type which calls out to Haskell via the FFI -import Foreign.Haskell.List.NonEmpty +-- Bundles for types of functions +import Function.Bundles --- The Pair type which calls out to Haskell via the FFI -import Foreign.Haskell.Pair +-- Relationships between properties of functions. See +-- `Function.Consequences.Propositional` for specialisations to +-- propositional equality. +import Function.Consequences --- Functions -import Function +-- Relationships between properties of functions where the equality +-- over both the domain and codomain is assumed to be _≡_ +import Function.Consequences.Propositional --- Simple combinators working solely on and with functions -import Function.Base +-- Relationships between properties of functions where the equality +-- over both the domain and codomain are assumed to be setoids. +import Function.Consequences.Setoid --- Bundles for types of functions -import Function.Bundles +-- Composition of functional properties +import Function.Construct.Composition --- Relationships between properties of functions. See --- `Function.Consequences.Propositional` for specialisations to --- propositional equality. -import Function.Consequences +-- The constant function +import Function.Construct.Constant --- Relationships between properties of functions where the equality --- over both the domain and codomain is assumed to be _≡_ -import Function.Consequences.Propositional +-- The identity function +import Function.Construct.Identity --- Relationships between properties of functions where the equality --- over both the domain and codomain are assumed to be setoids. -import Function.Consequences.Setoid +-- Some functional properties are symmetric +import Function.Construct.Symmetry --- Composition of functional properties -import Function.Construct.Composition +-- Definitions for types of functions. +import Function.Definitions --- The constant function -import Function.Construct.Constant +-- Bundles for types of functions +import Function.Dependent.Bundles --- The identity function -import Function.Construct.Identity +-- Endomorphisms on a Set +import Function.Endo.Propositional --- Some functional properties are symmetric -import Function.Construct.Symmetry +-- Endomorphisms on a Setoid +import Function.Endo.Setoid --- Definitions for types of functions. -import Function.Definitions +-- An effectful view of the identity function +import Function.Identity.Effectful --- Bundles for types of functions -import Function.Dependent.Bundles +-- Operations on Relations for Indexed sets +import Function.Indexed.Bundles --- Endomorphisms on a Set -import Function.Endo.Propositional +-- Function setoids and related constructions +import Function.Indexed.Relation.Binary.Equality --- Endomorphisms on a Setoid -import Function.Endo.Setoid +-- Metrics with arbitrary domains and codomains +import Function.Metric --- An effectful view of the identity function -import Function.Identity.Effectful +-- Bundles for metrics +import Function.Metric.Bundles --- Operations on Relations for Indexed sets -import Function.Indexed.Bundles +-- Definitions of properties over distance functions +import Function.Metric.Definitions --- Function setoids and related constructions -import Function.Indexed.Relation.Binary.Equality +-- Metrics with ℕ as the codomain of the metric function +import Function.Metric.Nat --- Metrics with arbitrary domains and codomains -import Function.Metric +-- Bundles for metrics over ℕ +import Function.Metric.Nat.Bundles --- Bundles for metrics -import Function.Metric.Bundles +-- Core definitions for metrics over ℕ +import Function.Metric.Nat.Definitions --- Definitions of properties over distance functions -import Function.Metric.Definitions +-- Core definitions for metrics over ℕ +import Function.Metric.Nat.Structures --- Metrics with ℕ as the codomain of the metric function -import Function.Metric.Nat +-- Metrics with ℚ as the codomain of the metric function +import Function.Metric.Rational --- Bundles for metrics over ℕ -import Function.Metric.Nat.Bundles +-- Bundles for metrics over ℚ +import Function.Metric.Rational.Bundles --- Core definitions for metrics over ℕ -import Function.Metric.Nat.Definitions +-- Core definitions for metrics over ℚ +import Function.Metric.Rational.Definitions --- Core definitions for metrics over ℕ -import Function.Metric.Nat.Structures +-- Core definitions for metrics over ℚ +import Function.Metric.Rational.Structures --- Metrics with ℚ as the codomain of the metric function -import Function.Metric.Rational +-- Some metric structures (not packed up with sets, operations, etc.) +import Function.Metric.Structures --- Bundles for metrics over ℚ -import Function.Metric.Rational.Bundles +-- Heterogeneous N-ary Functions +import Function.Nary.NonDependent --- Core definitions for metrics over ℚ -import Function.Metric.Rational.Definitions +-- Heterogeneous N-ary Functions: basic types and operations +import Function.Nary.NonDependent.Base --- Core definitions for metrics over ℚ -import Function.Metric.Rational.Structures +-- Basic properties of the function type +import Function.Properties --- Some metric structures (not packed up with sets, operations, etc.) -import Function.Metric.Structures +-- Some basic properties of bijections. +import Function.Properties.Bijection --- Heterogeneous N-ary Functions -import Function.Nary.NonDependent +-- Some basic properties of equivalences. This file is designed to be +-- imported qualified. +import Function.Properties.Equivalence --- Heterogeneous N-ary Functions: basic types and operations -import Function.Nary.NonDependent.Base +-- Properties for injections +import Function.Properties.Injection --- Basic properties of the function type -import Function.Properties +-- Properties of inverses. +import Function.Properties.Inverse --- Some basic properties of bijections. -import Function.Properties.Bijection +-- Half adjoint equivalences +import Function.Properties.Inverse.HalfAdjointEquivalence --- Some basic properties of equivalences. This file is designed to be --- imported qualified. -import Function.Properties.Equivalence +-- Properties of right inverses +import Function.Properties.RightInverse --- Properties for injections -import Function.Properties.Injection +-- Properties of surjections +import Function.Properties.Surjection --- Properties of inverses. -import Function.Properties.Inverse +-- A module used for creating function pipelines, see +-- README.Function.Reasoning for examples +import Function.Reasoning --- Half adjoint equivalences -import Function.Properties.Inverse.HalfAdjointEquivalence +-- Relatedness for the function hierarchy +import Function.Related.Propositional --- Properties of right inverses -import Function.Properties.RightInverse +-- Basic lemmas showing that various types are related (isomorphic or +-- equivalent or…) +import Function.Related.TypeIsomorphisms --- Properties of surjections -import Function.Properties.Surjection +-- Automatic solver for equations over product and sum types +import Function.Related.TypeIsomorphisms.Solver --- A module used for creating function pipelines, see --- README.Function.Reasoning for examples -import Function.Reasoning +-- Function Equality setoid +import Function.Relation.Binary.Setoid.Equality --- Relatedness for the function hierarchy -import Function.Related.Propositional +-- Strict combinators (i.e. that use call-by-value) +import Function.Strict --- Basic lemmas showing that various types are related (isomorphic or --- equivalent or…) -import Function.Related.TypeIsomorphisms +-- Structures for types of functions +import Function.Structures --- Automatic solver for equations over product and sum types -import Function.Related.TypeIsomorphisms.Solver +-- Ways to give instances of certain structures where some fields can +-- be given in terms of others. +-- The contents of this file should usually be accessed from `Function`. +import Function.Structures.Biased --- Function Equality setoid -import Function.Relation.Binary.Setoid.Equality +-- IO +import IO --- Strict combinators (i.e. that use call-by-value) -import Function.Strict +-- IO: basic types and functions +import IO.Base --- Structures for types of functions -import Function.Structures +-- An effectful view of IO +import IO.Effectful --- Ways to give instances of certain structures where some fields can --- be given in terms of others. --- The contents of this file should usually be accessed from `Function`. -import Function.Structures.Biased +-- IO only involving finite objects +import IO.Finite --- IO -import IO +-- IO handles: simple bindings to Haskell types and functions +import IO.Handle --- IO: basic types and functions -import IO.Base +-- IO only involving infinite objects +import IO.Infinite --- An effectful view of IO -import IO.Effectful +-- Typeclass instances for IO +import IO.Instances --- IO only involving finite objects -import IO.Finite +-- Primitive IO: simple bindings to Haskell types and functions +-- Everything is assumed to be finite +import IO.Primitive.Finite --- IO handles: simple bindings to Haskell types and functions -import IO.Handle +-- Primitive IO handles: simple bindings to Haskell types and functions +import IO.Primitive.Handle --- IO only involving infinite objects -import IO.Infinite +-- Primitive IO: simple bindings to Haskell types and functions +-- manipulating potentially infinite objects +import IO.Primitive.Infinite --- Typeclass instances for IO -import IO.Instances +-- An abstraction of various forms of recursion/induction +import Induction --- Primitive IO: simple bindings to Haskell types and functions --- Everything is assumed to be finite -import IO.Primitive.Finite +-- A standard consequence of accessibility/well-foundedness: +-- the impossibility of 'infinite descent' from any (accessible) +-- element x satisfying P to 'smaller' y also satisfying P +import Induction.InfiniteDescent --- Primitive IO handles: simple bindings to Haskell types and functions -import IO.Primitive.Handle +-- Lexicographic induction +import Induction.Lexicographic --- Primitive IO: simple bindings to Haskell types and functions --- manipulating potentially infinite objects -import IO.Primitive.Infinite +-- Well-founded induction +import Induction.WellFounded --- An abstraction of various forms of recursion/induction -import Induction +-- Universe levels +import Level --- A standard consequence of accessibility/well-foundedness: --- the impossibility of 'infinite descent' from any (accessible) --- element x satisfying P to 'smaller' y also satisfying P -import Induction.InfiniteDescent +-- Conversion from naturals to universe levels +import Level.Literals --- Lexicographic induction -import Induction.Lexicographic +-- Support for reflection +import Reflection --- Well-founded induction -import Induction.WellFounded +-- The reflected abstract syntax tree +import Reflection.AST --- Universe levels -import Level +-- Abstractions used in the reflection machinery +import Reflection.AST.Abstraction --- Conversion from naturals to universe levels -import Level.Literals +-- Alpha equality over terms +import Reflection.AST.AlphaEquality --- Support for reflection -import Reflection +-- Arguments used in the reflection machinery +import Reflection.AST.Argument --- The reflected abstract syntax tree -import Reflection.AST +-- Argument information used in the reflection machinery +import Reflection.AST.Argument.Information --- Abstractions used in the reflection machinery -import Reflection.AST.Abstraction +-- Modalities used in the reflection machinery +import Reflection.AST.Argument.Modality --- Alpha equality over terms -import Reflection.AST.AlphaEquality +-- Argument quantities used in the reflection machinery +import Reflection.AST.Argument.Quantity --- Arguments used in the reflection machinery -import Reflection.AST.Argument +-- Argument relevance used in the reflection machinery +import Reflection.AST.Argument.Relevance --- Argument information used in the reflection machinery -import Reflection.AST.Argument.Information +-- Argument visibility used in the reflection machinery +import Reflection.AST.Argument.Visibility --- Modalities used in the reflection machinery -import Reflection.AST.Argument.Modality +-- Weakening, strengthening and free variable check for reflected terms. +import Reflection.AST.DeBruijn --- Argument quantities used in the reflection machinery -import Reflection.AST.Argument.Quantity +-- Definitions used in the reflection machinery +import Reflection.AST.Definition --- Argument relevance used in the reflection machinery -import Reflection.AST.Argument.Relevance +-- Instances for reflected syntax +import Reflection.AST.Instances --- Argument visibility used in the reflection machinery -import Reflection.AST.Argument.Visibility +-- Literals used in the reflection machinery +import Reflection.AST.Literal --- Weakening, strengthening and free variable check for reflected terms. -import Reflection.AST.DeBruijn +-- Metavariables used in the reflection machinery +import Reflection.AST.Meta --- Definitions used in the reflection machinery -import Reflection.AST.Definition +-- Names used in the reflection machinery +import Reflection.AST.Name --- Instances for reflected syntax -import Reflection.AST.Instances +-- Patterns used in the reflection machinery +import Reflection.AST.Pattern --- Literals used in the reflection machinery -import Reflection.AST.Literal +-- Converting reflection machinery to strings +import Reflection.AST.Show --- Metavariables used in the reflection machinery -import Reflection.AST.Meta +-- Terms used in the reflection machinery +import Reflection.AST.Term --- Names used in the reflection machinery -import Reflection.AST.Name +-- de Bruijn-aware generic traversal of reflected terms. +import Reflection.AST.Traversal --- Patterns used in the reflection machinery -import Reflection.AST.Pattern +-- A universe for the types involved in the reflected syntax. +import Reflection.AST.Universe --- Converting reflection machinery to strings -import Reflection.AST.Show +-- Annotated reflected syntax. +import Reflection.AnnotatedAST --- Terms used in the reflection machinery -import Reflection.AST.Term +-- Computing free variable annotations on reflected syntax. +import Reflection.AnnotatedAST.Free --- de Bruijn-aware generic traversal of reflected terms. -import Reflection.AST.Traversal +-- Support for system calls as part of reflection +import Reflection.External --- A universe for the types involved in the reflected syntax. -import Reflection.AST.Universe +-- The TC (Type Checking) monad +import Reflection.TCM --- Annotated reflected syntax. -import Reflection.AnnotatedAST +-- Typeclass instances for TC +import Reflection.TCM.Effectful --- Computing free variable annotations on reflected syntax. -import Reflection.AnnotatedAST.Free +-- Printf-style versions of typeError and debugPrint +import Reflection.TCM.Format --- Support for system calls as part of reflection -import Reflection.External +-- Typeclass instances for TC +import Reflection.TCM.Instances --- The TC (Type Checking) monad -import Reflection.TCM +-- Monad syntax for the TC monad +import Reflection.TCM.Syntax --- Typeclass instances for TC -import Reflection.TCM.Effectful +-- Reflection utilities +import Reflection.TCM.Utilities --- Printf-style versions of typeError and debugPrint -import Reflection.TCM.Format +-- Properties of homogeneous binary relations +import Relation.Binary --- Typeclass instances for TC -import Reflection.TCM.Instances +-- Bundles for homogeneous binary relations +import Relation.Binary.Bundles --- Monad syntax for the TC monad -import Reflection.TCM.Syntax +-- Raw bundles for homogeneous binary relations +import Relation.Binary.Bundles.Raw --- Reflection utilities -import Reflection.TCM.Utilities +-- Some properties imply others +import Relation.Binary.Consequences --- Properties of homogeneous binary relations -import Relation.Binary +-- A pointwise lifting of a relation to incorporate new extrema. +import Relation.Binary.Construct.Add.Extrema.Equality --- Bundles for homogeneous binary relations -import Relation.Binary.Bundles +-- The lifting of a non-strict order to incorporate new extrema +import Relation.Binary.Construct.Add.Extrema.NonStrict --- Raw bundles for homogeneous binary relations -import Relation.Binary.Bundles.Raw +-- The lifting of a strict order to incorporate new extrema +import Relation.Binary.Construct.Add.Extrema.Strict --- Some properties imply others -import Relation.Binary.Consequences +-- A pointwise lifting of a relation to incorporate a new infimum. +import Relation.Binary.Construct.Add.Infimum.Equality --- A pointwise lifting of a relation to incorporate new extrema. -import Relation.Binary.Construct.Add.Extrema.Equality +-- The lifting of a non-strict order to incorporate a new infimum +import Relation.Binary.Construct.Add.Infimum.NonStrict --- The lifting of a non-strict order to incorporate new extrema -import Relation.Binary.Construct.Add.Extrema.NonStrict +-- The lifting of a strict order to incorporate a new infimum +import Relation.Binary.Construct.Add.Infimum.Strict --- The lifting of a strict order to incorporate new extrema -import Relation.Binary.Construct.Add.Extrema.Strict +-- A pointwise lifting of a relation to incorporate an additional point. +import Relation.Binary.Construct.Add.Point.Equality --- A pointwise lifting of a relation to incorporate a new infimum. -import Relation.Binary.Construct.Add.Infimum.Equality +-- A pointwise lifting of a relation to incorporate a new supremum. +import Relation.Binary.Construct.Add.Supremum.Equality --- The lifting of a non-strict order to incorporate a new infimum -import Relation.Binary.Construct.Add.Infimum.NonStrict +-- The lifting of a non-strict order to incorporate a new supremum +import Relation.Binary.Construct.Add.Supremum.NonStrict --- The lifting of a strict order to incorporate a new infimum -import Relation.Binary.Construct.Add.Infimum.Strict +-- The lifting of a strict order to incorporate a new supremum +import Relation.Binary.Construct.Add.Supremum.Strict --- A pointwise lifting of a relation to incorporate an additional point. -import Relation.Binary.Construct.Add.Point.Equality +-- The universal binary relation +import Relation.Binary.Construct.Always --- A pointwise lifting of a relation to incorporate a new supremum. -import Relation.Binary.Construct.Add.Supremum.Equality +-- The reflexive, symmetric and transitive closure of a binary +-- relation (aka the equivalence closure). +import Relation.Binary.Construct.Closure.Equivalence --- The lifting of a non-strict order to incorporate a new supremum -import Relation.Binary.Construct.Add.Supremum.NonStrict +-- Some properties of equivalence closures. +import Relation.Binary.Construct.Closure.Equivalence.Properties --- The lifting of a strict order to incorporate a new supremum -import Relation.Binary.Construct.Add.Supremum.Strict +-- Reflexive closures +import Relation.Binary.Construct.Closure.Reflexive --- The universal binary relation -import Relation.Binary.Construct.Always +-- Some properties of reflexive closures +import Relation.Binary.Construct.Closure.Reflexive.Properties --- The reflexive, symmetric and transitive closure of a binary --- relation (aka the equivalence closure). -import Relation.Binary.Construct.Closure.Equivalence +-- Some properties of reflexive closures which rely on the K rule +import Relation.Binary.Construct.Closure.Reflexive.Properties.WithK --- Some properties of equivalence closures. -import Relation.Binary.Construct.Closure.Equivalence.Properties +-- The reflexive transitive closures of McBride, Norell and Jansson +import Relation.Binary.Construct.Closure.ReflexiveTransitive --- Reflexive closures -import Relation.Binary.Construct.Closure.Reflexive +-- Some properties of reflexive transitive closures. +import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties --- Some properties of reflexive closures -import Relation.Binary.Construct.Closure.Reflexive.Properties +-- Properties, related to reflexive transitive closures, that rely on +-- the K rule +import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties.WithK --- Some properties of reflexive closures which rely on the K rule -import Relation.Binary.Construct.Closure.Reflexive.Properties.WithK +-- Symmetric closures of binary relations +import Relation.Binary.Construct.Closure.Symmetric --- The reflexive transitive closures of McBride, Norell and Jansson -import Relation.Binary.Construct.Closure.ReflexiveTransitive +-- Symmetric transitive closures of binary relations +import Relation.Binary.Construct.Closure.SymmetricTransitive --- Some properties of reflexive transitive closures. -import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties +-- Transitive closures +import Relation.Binary.Construct.Closure.Transitive --- Properties, related to reflexive transitive closures, that rely on --- the K rule -import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties.WithK +-- Some code related to transitive closures that relies on the K rule +import Relation.Binary.Construct.Closure.Transitive.WithK --- Symmetric closures of binary relations -import Relation.Binary.Construct.Closure.Symmetric +-- Composition of two binary relations +import Relation.Binary.Construct.Composition --- Symmetric transitive closures of binary relations -import Relation.Binary.Construct.Closure.SymmetricTransitive +-- The binary relation defined by a constant +import Relation.Binary.Construct.Constant --- Transitive closures -import Relation.Binary.Construct.Closure.Transitive +-- Many properties which hold for `∼` also hold for `flip ∼`. Unlike +-- the module `Relation.Binary.Construct.Flip.Ord` this module does not +-- flip the underlying equality. +import Relation.Binary.Construct.Flip.EqAndOrd --- Some code related to transitive closures that relies on the K rule -import Relation.Binary.Construct.Closure.Transitive.WithK +-- Many properties which hold for `∼` also hold for `flip ∼`. Unlike +-- the module `Relation.Binary.Construct.Flip.EqAndOrd` this module +-- flips both the relation and the underlying equality. +import Relation.Binary.Construct.Flip.Ord --- Composition of two binary relations -import Relation.Binary.Construct.Composition +-- Every respectful unary relation induces a preorder. No claim is +-- made that this preorder is unique. +import Relation.Binary.Construct.FromPred --- The binary relation defined by a constant -import Relation.Binary.Construct.Constant +-- Every respectful binary relation induces a preorder. No claim is +-- made that this preorder is unique. +import Relation.Binary.Construct.FromRel --- Many properties which hold for `∼` also hold for `flip ∼`. Unlike --- the module `Relation.Binary.Construct.Flip.Ord` this module does not --- flip the underlying equality. -import Relation.Binary.Construct.Flip.EqAndOrd +-- Symmetric interior of a binary relation +import Relation.Binary.Construct.Interior.Symmetric --- Many properties which hold for `∼` also hold for `flip ∼`. Unlike --- the module `Relation.Binary.Construct.Flip.EqAndOrd` this module --- flips both the relation and the underlying equality. -import Relation.Binary.Construct.Flip.Ord +-- Intersection of two binary relations +import Relation.Binary.Construct.Intersection --- Every respectful unary relation induces a preorder. No claim is --- made that this preorder is unique. -import Relation.Binary.Construct.FromPred +-- Conversion of binary operators to binary relations via the left +-- natural order. +import Relation.Binary.Construct.NaturalOrder.Left --- Every respectful binary relation induces a preorder. No claim is --- made that this preorder is unique. -import Relation.Binary.Construct.FromRel +-- Conversion of binary operators to binary relations via the right +-- natural order. +import Relation.Binary.Construct.NaturalOrder.Right --- Symmetric interior of a binary relation -import Relation.Binary.Construct.Interior.Symmetric +-- The empty binary relation +import Relation.Binary.Construct.Never --- Intersection of two binary relations -import Relation.Binary.Construct.Intersection +-- Conversion of _≤_ to _<_ +import Relation.Binary.Construct.NonStrictToStrict --- Conversion of binary operators to binary relations via the left --- natural order. -import Relation.Binary.Construct.NaturalOrder.Left +-- Many properties which hold for `_∼_` also hold for `_∼_ on f` +import Relation.Binary.Construct.On --- Conversion of binary operators to binary relations via the right --- natural order. -import Relation.Binary.Construct.NaturalOrder.Right +-- Conversion of < to ≤, along with a number of properties +import Relation.Binary.Construct.StrictToNonStrict --- The empty binary relation -import Relation.Binary.Construct.Never +-- Substituting equalities for binary relations +import Relation.Binary.Construct.Subst.Equality --- Conversion of _≤_ to _<_ -import Relation.Binary.Construct.NonStrictToStrict +-- Union of two binary relations +import Relation.Binary.Construct.Union --- Many properties which hold for `_∼_` also hold for `_∼_ on f` -import Relation.Binary.Construct.On +-- Properties of binary relations +import Relation.Binary.Definitions --- Conversion of < to ≤, along with a number of properties -import Relation.Binary.Construct.StrictToNonStrict +-- Heterogeneous equality +import Relation.Binary.HeterogeneousEquality --- Substituting equalities for binary relations -import Relation.Binary.Construct.Subst.Equality +-- Quotients for Heterogeneous equality +import Relation.Binary.HeterogeneousEquality.Quotients --- Union of two binary relations -import Relation.Binary.Construct.Union +-- Example of a Quotient: ℤ as (ℕ × ℕ / ∼) +import Relation.Binary.HeterogeneousEquality.Quotients.Examples --- Properties of binary relations -import Relation.Binary.Definitions +-- Heterogeneously-indexed binary relations +import Relation.Binary.Indexed.Heterogeneous --- Heterogeneous equality -import Relation.Binary.HeterogeneousEquality +-- Indexed binary relations +import Relation.Binary.Indexed.Heterogeneous.Bundles --- Quotients for Heterogeneous equality -import Relation.Binary.HeterogeneousEquality.Quotients +-- Instantiates indexed binary structures at an index to the equivalent +-- non-indexed structures. +import Relation.Binary.Indexed.Heterogeneous.Construct.At --- Example of a Quotient: ℤ as (ℕ × ℕ / ∼) -import Relation.Binary.HeterogeneousEquality.Quotients.Examples +-- Creates trivially indexed records from their non-indexed counterpart. +import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial --- Heterogeneously-indexed binary relations -import Relation.Binary.Indexed.Heterogeneous +-- Indexed binary relations +import Relation.Binary.Indexed.Heterogeneous.Definitions --- Indexed binary relations -import Relation.Binary.Indexed.Heterogeneous.Bundles +-- Indexed binary relations +import Relation.Binary.Indexed.Heterogeneous.Structures --- Instantiates indexed binary structures at an index to the equivalent --- non-indexed structures. -import Relation.Binary.Indexed.Heterogeneous.Construct.At +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous --- Creates trivially indexed records from their non-indexed counterpart. -import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous.Bundles --- Indexed binary relations -import Relation.Binary.Indexed.Heterogeneous.Definitions +-- Instantiating homogeneously indexed bundles at a particular index +import Relation.Binary.Indexed.Homogeneous.Construct.At --- Indexed binary relations -import Relation.Binary.Indexed.Heterogeneous.Structures +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous.Definitions --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous.Structures --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous.Bundles +-- Order-theoretic lattices +import Relation.Binary.Lattice --- Instantiating homogeneously indexed bundles at a particular index -import Relation.Binary.Indexed.Homogeneous.Construct.At +-- Bundles for order-theoretic lattices +import Relation.Binary.Lattice.Bundles --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous.Definitions +-- Definitions for order-theoretic lattices +import Relation.Binary.Lattice.Definitions --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous.Structures +-- Properties satisfied by bounded join semilattices +import Relation.Binary.Lattice.Properties.BoundedJoinSemilattice --- Order-theoretic lattices -import Relation.Binary.Lattice +-- Properties satisfied by bounded lattice +import Relation.Binary.Lattice.Properties.BoundedLattice --- Bundles for order-theoretic lattices -import Relation.Binary.Lattice.Bundles +-- Properties satisfied by bounded meet semilattices +import Relation.Binary.Lattice.Properties.BoundedMeetSemilattice --- Definitions for order-theoretic lattices -import Relation.Binary.Lattice.Definitions +-- Properties for distributive lattice +import Relation.Binary.Lattice.Properties.DistributiveLattice --- Properties satisfied by bounded join semilattices -import Relation.Binary.Lattice.Properties.BoundedJoinSemilattice +-- Properties satisfied by Heyting Algebra +import Relation.Binary.Lattice.Properties.HeytingAlgebra --- Properties satisfied by bounded lattice -import Relation.Binary.Lattice.Properties.BoundedLattice +-- Properties satisfied by join semilattices +import Relation.Binary.Lattice.Properties.JoinSemilattice --- Properties satisfied by bounded meet semilattices -import Relation.Binary.Lattice.Properties.BoundedMeetSemilattice +-- Properties satisfied by lattices +import Relation.Binary.Lattice.Properties.Lattice --- Properties for distributive lattice -import Relation.Binary.Lattice.Properties.DistributiveLattice +-- Properties satisfied by meet semilattices +import Relation.Binary.Lattice.Properties.MeetSemilattice --- Properties satisfied by Heyting Algebra -import Relation.Binary.Lattice.Properties.HeytingAlgebra +-- Structures for order-theoretic lattices +import Relation.Binary.Lattice.Structures --- Properties satisfied by join semilattices -import Relation.Binary.Lattice.Properties.JoinSemilattice +-- Order morphisms +import Relation.Binary.Morphism --- Properties satisfied by lattices -import Relation.Binary.Lattice.Properties.Lattice +-- Bundles for morphisms between binary relations +import Relation.Binary.Morphism.Bundles --- Properties satisfied by meet semilattices -import Relation.Binary.Lattice.Properties.MeetSemilattice +-- The composition of morphisms between binary relations +import Relation.Binary.Morphism.Construct.Composition --- Structures for order-theoretic lattices -import Relation.Binary.Lattice.Structures +-- Constant morphisms between binary relations +import Relation.Binary.Morphism.Construct.Constant --- Order morphisms -import Relation.Binary.Morphism +-- The identity morphism for binary relations +import Relation.Binary.Morphism.Construct.Identity --- Bundles for morphisms between binary relations -import Relation.Binary.Morphism.Bundles +-- The projection morphisms for relational structures arising from the +-- non-dependent product construction +import Relation.Binary.Morphism.Construct.Product --- The composition of morphisms between binary relations -import Relation.Binary.Morphism.Construct.Composition +-- Basic definitions for morphisms between algebraic structures +import Relation.Binary.Morphism.Definitions --- Constant morphisms between binary relations -import Relation.Binary.Morphism.Construct.Constant +-- Consequences of a monomorphism between orders +import Relation.Binary.Morphism.OrderMonomorphism --- The identity morphism for binary relations -import Relation.Binary.Morphism.Construct.Identity +-- Consequences of a monomorphism between binary relations +import Relation.Binary.Morphism.RelMonomorphism --- The projection morphisms for relational structures arising from the --- non-dependent product construction -import Relation.Binary.Morphism.Construct.Product +-- Order morphisms +import Relation.Binary.Morphism.Structures --- Basic definitions for morphisms between algebraic structures -import Relation.Binary.Morphism.Definitions +-- Apartness properties +import Relation.Binary.Properties.ApartnessRelation --- Consequences of a monomorphism between orders -import Relation.Binary.Morphism.OrderMonomorphism +-- Every decidable setoid induces tight apartness relation. +import Relation.Binary.Properties.DecSetoid --- Consequences of a monomorphism between binary relations -import Relation.Binary.Morphism.RelMonomorphism +-- Properties satisfied by decidable total orders +import Relation.Binary.Properties.DecTotalOrder --- Order morphisms -import Relation.Binary.Morphism.Structures +-- Additional properties for setoids +import Relation.Binary.Properties.PartialSetoid --- Apartness properties -import Relation.Binary.Properties.ApartnessRelation +-- Properties satisfied by posets +import Relation.Binary.Properties.Poset --- Every decidable setoid induces tight apartness relation. -import Relation.Binary.Properties.DecSetoid +-- Properties satisfied by preorders +import Relation.Binary.Properties.Preorder --- Properties satisfied by decidable total orders -import Relation.Binary.Properties.DecTotalOrder +-- Additional properties for setoids +import Relation.Binary.Properties.Setoid --- Additional properties for setoids -import Relation.Binary.Properties.PartialSetoid +-- Properties satisfied by strict partial orders +import Relation.Binary.Properties.StrictPartialOrder --- Properties satisfied by posets -import Relation.Binary.Properties.Poset +-- Properties satisfied by strict partial orders +import Relation.Binary.Properties.StrictTotalOrder --- Properties satisfied by preorders -import Relation.Binary.Properties.Preorder +-- Properties satisfied by total orders +import Relation.Binary.Properties.TotalOrder --- Additional properties for setoids -import Relation.Binary.Properties.Setoid +-- Propositional (intensional) equality +import Relation.Binary.PropositionalEquality --- Properties satisfied by strict partial orders -import Relation.Binary.Properties.StrictPartialOrder +-- Propositional (intensional) equality - Algebraic structures +import Relation.Binary.PropositionalEquality.Algebra --- Properties satisfied by strict partial orders -import Relation.Binary.Properties.StrictTotalOrder +-- Propositional equality +import Relation.Binary.PropositionalEquality.Properties --- Properties satisfied by total orders -import Relation.Binary.Properties.TotalOrder +-- An equality postulate which evaluates +import Relation.Binary.PropositionalEquality.TrustMe --- Propositional (intensional) equality -import Relation.Binary.PropositionalEquality +-- Some code related to propositional equality that relies on the K +-- rule +import Relation.Binary.PropositionalEquality.WithK --- Propositional (intensional) equality - Algebraic structures -import Relation.Binary.PropositionalEquality.Algebra +-- The basic code for equational reasoning with three relations: +-- equality and apartness +import Relation.Binary.Reasoning.Base.Apartness --- Propositional equality -import Relation.Binary.PropositionalEquality.Properties +-- The basic code for equational reasoning with two relations: +-- equality and some other ordering. +import Relation.Binary.Reasoning.Base.Double --- An equality postulate which evaluates -import Relation.Binary.PropositionalEquality.TrustMe +-- The basic code for equational reasoning with a non-reflexive relation +import Relation.Binary.Reasoning.Base.Partial --- Some code related to propositional equality that relies on the K --- rule -import Relation.Binary.PropositionalEquality.WithK +-- The basic code for equational reasoning with a single relation +import Relation.Binary.Reasoning.Base.Single --- The basic code for equational reasoning with three relations: --- equality and apartness -import Relation.Binary.Reasoning.Base.Apartness +-- The basic code for equational reasoning with three relations: +-- equality, strict ordering and non-strict ordering. +import Relation.Binary.Reasoning.Base.Triple --- The basic code for equational reasoning with two relations: --- equality and some other ordering. -import Relation.Binary.Reasoning.Base.Double +-- Convenient syntax for "equational reasoning" in multiple Setoids. +import Relation.Binary.Reasoning.MultiSetoid --- The basic code for equational reasoning with a non-reflexive relation -import Relation.Binary.Reasoning.Base.Partial +-- Convenient syntax for "equational reasoning" using a partial order +import Relation.Binary.Reasoning.PartialOrder --- The basic code for equational reasoning with a single relation -import Relation.Binary.Reasoning.Base.Single +-- Convenient syntax for reasoning with a partial setoid +import Relation.Binary.Reasoning.PartialSetoid --- The basic code for equational reasoning with three relations: --- equality, strict ordering and non-strict ordering. -import Relation.Binary.Reasoning.Base.Triple +-- Convenient syntax for "equational reasoning" using a preorder +import Relation.Binary.Reasoning.Preorder --- Convenient syntax for "equational reasoning" in multiple Setoids. -import Relation.Binary.Reasoning.MultiSetoid +-- Convenient syntax for reasoning with a setoid +import Relation.Binary.Reasoning.Setoid --- Convenient syntax for "equational reasoning" using a partial order -import Relation.Binary.Reasoning.PartialOrder +-- Convenient syntax for "equational reasoning" using a strict partial +-- order. +import Relation.Binary.Reasoning.StrictPartialOrder --- Convenient syntax for reasoning with a partial setoid -import Relation.Binary.Reasoning.PartialSetoid +-- Syntax for the building blocks of equational reasoning modules +import Relation.Binary.Reasoning.Syntax --- Convenient syntax for "equational reasoning" using a preorder -import Relation.Binary.Reasoning.Preorder +-- Helpers intended to ease the development of "tactics" which use +-- proof by reflection +import Relation.Binary.Reflection --- Convenient syntax for reasoning with a setoid -import Relation.Binary.Reasoning.Setoid +-- Concepts from rewriting theory +-- Definitions are based on "Term Rewriting Systems" by J.W. Klop +import Relation.Binary.Rewriting --- Convenient syntax for "equational reasoning" using a strict partial --- order. -import Relation.Binary.Reasoning.StrictPartialOrder +-- Structures for homogeneous binary relations +import Relation.Binary.Structures --- Syntax for the building blocks of equational reasoning modules -import Relation.Binary.Reasoning.Syntax +-- Ways to give instances of certain structures where some fields can +-- be given in terms of others +import Relation.Binary.Structures.Biased --- Helpers intended to ease the development of "tactics" which use --- proof by reflection -import Relation.Binary.Reflection +-- Typeclasses for use with instance arguments +import Relation.Binary.TypeClasses --- Concepts from rewriting theory --- Definitions are based on "Term Rewriting Systems" by J.W. Klop -import Relation.Binary.Rewriting +-- Heterogeneous N-ary Relations +import Relation.Nary --- Structures for homogeneous binary relations -import Relation.Binary.Structures +-- Operations on nullary relations (like negation and decidability) +import Relation.Nullary --- Ways to give instances of certain structures where some fields can --- be given in terms of others -import Relation.Binary.Structures.Biased +-- Notation for freely adding extrema to any set +import Relation.Nullary.Construct.Add.Extrema --- Typeclasses for use with instance arguments -import Relation.Binary.TypeClasses +-- Notation for freely adding an infimum to any set +import Relation.Nullary.Construct.Add.Infimum --- Heterogeneous N-ary Relations -import Relation.Nary +-- Notation for adding an additional point to any set +import Relation.Nullary.Construct.Add.Point --- Operations on nullary relations (like negation and decidability) -import Relation.Nullary +-- Notation for freely adding a supremum to any set +import Relation.Nullary.Construct.Add.Supremum --- Notation for freely adding extrema to any set -import Relation.Nullary.Construct.Add.Extrema +-- Operations on and properties of decidable relations +import Relation.Nullary.Decidable --- Notation for freely adding an infimum to any set -import Relation.Nullary.Construct.Add.Infimum +-- Negation indexed by a Level +import Relation.Nullary.Indexed --- Notation for adding an additional point to any set -import Relation.Nullary.Construct.Add.Point +-- Properties of indexed negation +import Relation.Nullary.Indexed.Negation --- Notation for freely adding a supremum to any set -import Relation.Nullary.Construct.Add.Supremum +-- A type `A` is irrelevant if all of its elements are equal. +-- This is also refered to as "A is an h-proposition". +import Relation.Nullary.Irrelevant --- Operations on and properties of decidable relations -import Relation.Nullary.Decidable +-- Properties related to negation +import Relation.Nullary.Negation --- Negation indexed by a Level -import Relation.Nullary.Indexed +-- Recomputable types and their algebra as Harrop formulas +import Relation.Nullary.Recomputable --- Properties of indexed negation -import Relation.Nullary.Indexed.Negation +-- Properties of the `Reflects` construct +import Relation.Nullary.Reflects --- A type `A` is irrelevant if all of its elements are equal. --- This is also refered to as "A is an h-proposition". -import Relation.Nullary.Irrelevant +-- A universe of proposition functors, along with some properties +import Relation.Nullary.Universe --- Properties related to negation -import Relation.Nullary.Negation +-- Unary relations +import Relation.Unary --- Recomputable types and their algebra as Harrop formulas -import Relation.Nullary.Recomputable +-- Algebraic properties of constructions over unary relations +import Relation.Unary.Algebra --- Properties of the `Reflects` construct -import Relation.Nullary.Reflects +-- Closures of a unary relation with respect to a binary one. +import Relation.Unary.Closure.Base --- A universe of proposition functors, along with some properties -import Relation.Nullary.Universe +-- Closure of a unary relation with respect to a preorder +import Relation.Unary.Closure.Preorder --- Unary relations -import Relation.Unary +-- Closures of a unary relation with respect to a strict partial order +import Relation.Unary.Closure.StrictPartialOrder --- Algebraic properties of constructions over unary relations -import Relation.Unary.Algebra +-- Some properties imply others +import Relation.Unary.Consequences --- Closures of a unary relation with respect to a binary one. -import Relation.Unary.Closure.Base +-- Indexed unary relations +import Relation.Unary.Indexed --- Closure of a unary relation with respect to a preorder -import Relation.Unary.Closure.Preorder +-- Polymorphic versions of standard definitions in Relation.Unary +import Relation.Unary.Polymorphic --- Closures of a unary relation with respect to a strict partial order -import Relation.Unary.Closure.StrictPartialOrder +-- Properties of polymorphic versions of standard definitions in +-- Relation.Unary +import Relation.Unary.Polymorphic.Properties --- Some properties imply others -import Relation.Unary.Consequences +-- Predicate transformers +import Relation.Unary.PredicateTransformer --- Indexed unary relations -import Relation.Unary.Indexed +-- Properties of constructions over unary relations +import Relation.Unary.Properties --- Polymorphic versions of standard definitions in Relation.Unary -import Relation.Unary.Polymorphic +-- Equality of unary relations +import Relation.Unary.Relation.Binary.Equality --- Properties of polymorphic versions of standard definitions in --- Relation.Unary -import Relation.Unary.Polymorphic.Properties +-- Order properties of the subset relations _⊆_ and _⊂_ +import Relation.Unary.Relation.Binary.Subset --- Predicate transformers -import Relation.Unary.PredicateTransformer +-- Indexed unary relations over sized types +import Relation.Unary.Sized --- Properties of constructions over unary relations -import Relation.Unary.Properties +-- Sizes for Agda's sized types +import Size --- Equality of unary relations -import Relation.Unary.Relation.Binary.Equality +-- Measuring time +import System.Clock --- Order properties of the subset relations _⊆_ and _⊂_ -import Relation.Unary.Relation.Binary.Subset +-- Primitive System.Clock simple bindings to Haskell functions +import System.Clock.Primitive --- Indexed unary relations over sized types -import Relation.Unary.Sized +-- ANSI escape codes +import System.Console.ANSI --- Sizes for Agda's sized types -import Size +-- Directory manipulation +import System.Directory --- Measuring time -import System.Clock +-- Primitive System.Direcotry simple bindings to Haskell functions +import System.Directory.Primitive --- Primitive System.Clock simple bindings to Haskell functions -import System.Clock.Primitive +-- Miscellanous information about the system environment +import System.Environment --- ANSI escape codes -import System.Console.ANSI +-- Primitive System.Environment: simple bindings to Haskell functions +import System.Environment.Primitive --- Directory manipulation -import System.Directory +-- Exiting the program. +import System.Exit --- Primitive System.Direcotry simple bindings to Haskell functions -import System.Directory.Primitive +-- Primitive System.Exit simple bindings to Haskell functions +import System.Exit.Primitive --- Miscellanous information about the system environment -import System.Environment +-- Posix filepaths +import System.FilePath.Posix --- Primitive System.Environment: simple bindings to Haskell functions -import System.Environment.Primitive +-- Primitive System.FilePath.Posix simple bindings to Haskell functions +import System.FilePath.Posix.Primitive --- Exiting the program. -import System.Exit +-- Calling external processes +import System.Process --- Primitive System.Exit simple bindings to Haskell functions -import System.Exit.Primitive +-- Primitive System.Process simple bindings to Haskell functions +import System.Process.Primitive --- Posix filepaths -import System.FilePath.Posix +-- *Pseudo-random* number generation +import System.Random --- Primitive System.FilePath.Posix simple bindings to Haskell functions -import System.FilePath.Posix.Primitive +-- Primitive System.Random simple bindings to Haskell functions +import System.Random.Primitive --- Calling external processes -import System.Process +-- A simple tactic for used to automatically compute the function +-- argument to cong. +import Tactic.Cong --- Primitive System.Process simple bindings to Haskell functions -import System.Process.Primitive +-- Reflection-based solver for monoid equalities +import Tactic.MonoidSolver --- *Pseudo-random* number generation -import System.Random +-- A solver that uses reflection to automatically obtain and solve +-- equations over rings. +import Tactic.RingSolver --- Primitive System.Random simple bindings to Haskell functions -import System.Random.Primitive +-- Almost commutative rings +import Tactic.RingSolver.Core.AlmostCommutativeRing --- A simple tactic for used to automatically compute the function --- argument to cong. -import Tactic.Cong +-- A type for expressions over a raw ring. +import Tactic.RingSolver.Core.Expression --- Reflection-based solver for monoid equalities -import Tactic.MonoidSolver +-- Simple implementation of sets of ℕ. +import Tactic.RingSolver.Core.NatSet --- A solver that uses reflection to automatically obtain and solve --- equations over rings. -import Tactic.RingSolver +-- Sparse polynomials in a commutative ring, encoded in Horner normal +-- form. +import Tactic.RingSolver.Core.Polynomial.Base --- Almost commutative rings -import Tactic.RingSolver.Core.AlmostCommutativeRing +-- Some specialised instances of the ring solver +import Tactic.RingSolver.Core.Polynomial.Homomorphism --- A type for expressions over a raw ring. -import Tactic.RingSolver.Core.Expression +-- Homomorphism proofs for addition over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition --- Simple implementation of sets of ℕ. -import Tactic.RingSolver.Core.NatSet +-- Homomorphism proofs for constants over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Constants --- Sparse polynomials in a commutative ring, encoded in Horner normal --- form. -import Tactic.RingSolver.Core.Polynomial.Base +-- Homomorphism proofs for exponentiation over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation --- Some specialised instances of the ring solver -import Tactic.RingSolver.Core.Polynomial.Homomorphism +-- Lemmas for use in proving the polynomial homomorphism. +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas --- Homomorphism proofs for addition over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition +-- Homomorphism proofs for multiplication over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication --- Homomorphism proofs for constants over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Constants +-- Homomorphism proofs for negation over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation --- Homomorphism proofs for exponentiation over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation +-- Homomorphism proofs for variables and constants over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables --- Lemmas for use in proving the polynomial homomorphism. -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas +-- Bundles of parameters for passing to the Ring Solver +import Tactic.RingSolver.Core.Polynomial.Parameters --- Homomorphism proofs for multiplication over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication +-- Polynomial reasoning +import Tactic.RingSolver.Core.Polynomial.Reasoning --- Homomorphism proofs for negation over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation +-- "Evaluating" a polynomial, using Horner's method. +import Tactic.RingSolver.Core.Polynomial.Semantics --- Homomorphism proofs for variables and constants over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables +-- An implementation of the ring solver that requires you to manually +-- pass the equation you wish to solve. +import Tactic.RingSolver.NonReflective --- Bundles of parameters for passing to the Ring Solver -import Tactic.RingSolver.Core.Polynomial.Parameters +-- Golden testing framework +import Test.Golden --- Polynomial reasoning -import Tactic.RingSolver.Core.Polynomial.Reasoning +-- Format strings for Printf and Scanf +import Text.Format --- "Evaluating" a polynomial, using Horner's method. -import Tactic.RingSolver.Core.Polynomial.Semantics +-- Format strings for Printf and Scanf +import Text.Format.Generic --- An implementation of the ring solver that requires you to manually --- pass the equation you wish to solve. -import Tactic.RingSolver.NonReflective +-- Pretty Printing +-- This module is based on Jean-Philippe Bernardy's functional pearl +-- "A Pretty But Not Greedy Printer" +import Text.Pretty --- Golden testing framework -import Test.Golden +-- Printf +import Text.Printf --- Format strings for Printf and Scanf -import Text.Format +-- Generic printf function. +import Text.Printf.Generic --- Format strings for Printf and Scanf -import Text.Format.Generic +-- Regular expressions +import Text.Regex --- Pretty Printing --- This module is based on Jean-Philippe Bernardy's functional pearl --- "A Pretty But Not Greedy Printer" -import Text.Pretty +-- Regular expressions: basic types and semantics +import Text.Regex.Base --- Printf -import Text.Printf +-- Regular expressions: Brzozowski derivative +import Text.Regex.Derivative.Brzozowski --- Generic printf function. -import Text.Printf.Generic +-- Properties of regular expressions and their semantics +import Text.Regex.Properties --- Regular expressions -import Text.Regex +-- Regular expressions: search algorithms +import Text.Regex.Search --- Regular expressions: basic types and semantics -import Text.Regex.Base +-- Regular expressions: smart constructors +-- Computing the Brzozowski derivative of a regular expression may lead +-- to a blow-up in the size of the expression. To keep it tractable it +-- is crucial to use smart constructors. +import Text.Regex.SmartConstructors --- Regular expressions: Brzozowski derivative -import Text.Regex.Derivative.Brzozowski +-- Regular expressions acting on strings +import Text.Regex.String --- Properties of regular expressions and their semantics -import Text.Regex.Properties +-- Regular expressions acting on strings, using unsafe features +import Text.Regex.String.Unsafe --- Regular expressions: search algorithms -import Text.Regex.Search +-- Fancy display functions for List-based tables +import Text.Tabular.Base --- Regular expressions: smart constructors --- Computing the Brzozowski derivative of a regular expression may lead --- to a blow-up in the size of the expression. To keep it tractable it --- is crucial to use smart constructors. -import Text.Regex.SmartConstructors +-- Fancy display functions for List-based tables +import Text.Tabular.List --- Regular expressions acting on strings -import Text.Regex.String - --- Regular expressions acting on strings, using unsafe features -import Text.Regex.String.Unsafe - --- Fancy display functions for List-based tables -import Text.Tabular.Base - --- Fancy display functions for List-based tables -import Text.Tabular.List - --- Fancy display functions for Vec-based tables -import Text.Tabular.Vec +-- Fancy display functions for Vec-based tables +import Text.Tabular.Vec \ No newline at end of file diff --git a/v2.3/EverythingSafe.html b/v2.3/EverythingSafe.html index 6451559eda..b5b189968c 100644 --- a/v2.3/EverythingSafe.html +++ b/v2.3/EverythingSafe.html @@ -1047,1937 +1047,1918 @@ -- Lexicographic ordering of lists import Data.List.Relation.Binary.Lex.Strict --- A alternative definition for the permutation relation using setoid equality --- Based on Choudhury and Fiore, "Free Commutative Monoids in HoTT" (MFPS, 2022) --- Constructor `_⋎_` below is rule (3), directly after the proof of Theorem 6.3, --- and appears as rule `commrel` of their earlier presentation at (HoTT, 2019), --- "The finite-multiset construction in HoTT". -import Data.List.Relation.Binary.Permutation.Algorithmic +-- A definition for the permutation relation using setoid equality +import Data.List.Relation.Binary.Permutation.Homogeneous --- Properties of the `Algorithmic` definition of the permutation relation. -import Data.List.Relation.Binary.Permutation.Algorithmic.Properties +-- An inductive definition for the permutation relation +import Data.List.Relation.Binary.Permutation.Propositional --- A declarative definition of the permutation relation, inductively defined --- as the least congruence on `List` which makes `_++_` commutative. Thus, for --- `(A, _≈_)` a setoid, `List A` with equality given by `_↭_` is a constructive --- presentation of the free commutative monoid on `A`. -import Data.List.Relation.Binary.Permutation.Declarative +-- Properties of permutation +import Data.List.Relation.Binary.Permutation.Propositional.Properties --- Properties of declarative definition of permutation -import Data.List.Relation.Binary.Permutation.Declarative.Properties +-- Properties of permutation (with K) +import Data.List.Relation.Binary.Permutation.Propositional.Properties.WithK --- A definition for the permutation relation using setoid equality -import Data.List.Relation.Binary.Permutation.Homogeneous +-- A definition for the permutation relation using setoid equality +import Data.List.Relation.Binary.Permutation.Setoid --- An inductive definition for the permutation relation -import Data.List.Relation.Binary.Permutation.Propositional +-- Properties of permutations using setoid equality +import Data.List.Relation.Binary.Permutation.Setoid.Properties --- Properties of permutation -import Data.List.Relation.Binary.Permutation.Propositional.Properties +-- Properties of permutations using setoid equality (on Maybe elements) +import Data.List.Relation.Binary.Permutation.Setoid.Properties.Maybe --- Properties of permutation (with K) -import Data.List.Relation.Binary.Permutation.Propositional.Properties.WithK +-- Pointwise lifting of relations to lists +import Data.List.Relation.Binary.Pointwise --- A definition for the permutation relation using setoid equality -import Data.List.Relation.Binary.Permutation.Setoid +-- Pointwise lifting of relations to lists +import Data.List.Relation.Binary.Pointwise.Base --- Properties of permutations using setoid equality -import Data.List.Relation.Binary.Permutation.Setoid.Properties +-- Properties of pointwise lifting of relations to lists +import Data.List.Relation.Binary.Pointwise.Properties --- Properties of permutations using setoid equality (on Maybe elements) -import Data.List.Relation.Binary.Permutation.Setoid.Properties.Maybe +-- An inductive definition of the heterogeneous prefix relation +import Data.List.Relation.Binary.Prefix.Heterogeneous --- Pointwise lifting of relations to lists -import Data.List.Relation.Binary.Pointwise +-- Properties of the heterogeneous prefix relation +import Data.List.Relation.Binary.Prefix.Heterogeneous.Properties --- Pointwise lifting of relations to lists -import Data.List.Relation.Binary.Pointwise.Base +-- Properties of the homogeneous prefix relation +import Data.List.Relation.Binary.Prefix.Homogeneous.Properties --- Properties of pointwise lifting of relations to lists -import Data.List.Relation.Binary.Pointwise.Properties +-- Properties of the propositional prefix relation +import Data.List.Relation.Binary.Prefix.Propositional.Properties --- An inductive definition of the heterogeneous prefix relation -import Data.List.Relation.Binary.Prefix.Heterogeneous +-- An inductive definition of the sublist relation for types which have +-- a decidable equality. This is commonly known as Order Preserving +-- Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.DecPropositional --- Properties of the heterogeneous prefix relation -import Data.List.Relation.Binary.Prefix.Heterogeneous.Properties +-- A solver for proving that one list is a sublist of the other for +-- types which enjoy decidable equalities. +import Data.List.Relation.Binary.Sublist.DecPropositional.Solver --- Properties of the homogeneous prefix relation -import Data.List.Relation.Binary.Prefix.Homogeneous.Properties +-- An inductive definition of the sublist relation with respect to a +-- setoid which is decidable. This is a generalisation of what is +-- commonly known as Order Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.DecSetoid --- Properties of the propositional prefix relation -import Data.List.Relation.Binary.Prefix.Propositional.Properties +-- A solver for proving that one list is a sublist of the other. +import Data.List.Relation.Binary.Sublist.DecSetoid.Solver --- An inductive definition of the sublist relation for types which have --- a decidable equality. This is commonly known as Order Preserving --- Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.DecPropositional +-- An inductive definition of the heterogeneous sublist relation +-- This is a generalisation of what is commonly known as Order +-- Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.Heterogeneous --- A solver for proving that one list is a sublist of the other for --- types which enjoy decidable equalities. -import Data.List.Relation.Binary.Sublist.DecPropositional.Solver +-- Properties of the heterogeneous sublist relation +import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties --- An inductive definition of the sublist relation with respect to a --- setoid which is decidable. This is a generalisation of what is --- commonly known as Order Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.DecSetoid +-- A solver for proving that one list is a sublist of the other. +import Data.List.Relation.Binary.Sublist.Heterogeneous.Solver --- A solver for proving that one list is a sublist of the other. -import Data.List.Relation.Binary.Sublist.DecSetoid.Solver +-- An inductive definition of the sublist relation. This is commonly +-- known as Order Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.Propositional --- An inductive definition of the heterogeneous sublist relation --- This is a generalisation of what is commonly known as Order --- Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.Heterogeneous +-- A larger example for sublists (propositional case): +-- Simply-typed lambda terms with globally unique variables +-- (both bound and free ones). +import Data.List.Relation.Binary.Sublist.Propositional.Example.UniqueBoundVariables --- Properties of the heterogeneous sublist relation -import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties +-- Sublist-related properties +import Data.List.Relation.Binary.Sublist.Propositional.Properties --- A solver for proving that one list is a sublist of the other. -import Data.List.Relation.Binary.Sublist.Heterogeneous.Solver +-- Slices in the propositional sublist category. +import Data.List.Relation.Binary.Sublist.Propositional.Slice --- An inductive definition of the sublist relation. This is commonly --- known as Order Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.Propositional +-- An inductive definition of the sublist relation with respect to a +-- setoid. This is a generalisation of what is commonly known as Order +-- Preserving Embeddings (OPE). +import Data.List.Relation.Binary.Sublist.Setoid --- A larger example for sublists (propositional case): --- Simply-typed lambda terms with globally unique variables --- (both bound and free ones). -import Data.List.Relation.Binary.Sublist.Propositional.Example.UniqueBoundVariables +-- Properties of the setoid sublist relation +import Data.List.Relation.Binary.Sublist.Setoid.Properties --- Sublist-related properties -import Data.List.Relation.Binary.Sublist.Propositional.Properties +-- Decidability of the subset relation over propositional equality. +import Data.List.Relation.Binary.Subset.DecPropositional --- Slices in the propositional sublist category. -import Data.List.Relation.Binary.Sublist.Propositional.Slice +-- Decidability of the subset relation over setoid equality. +import Data.List.Relation.Binary.Subset.DecSetoid --- An inductive definition of the sublist relation with respect to a --- setoid. This is a generalisation of what is commonly known as Order --- Preserving Embeddings (OPE). -import Data.List.Relation.Binary.Sublist.Setoid +-- The sublist relation over propositional equality. +import Data.List.Relation.Binary.Subset.Propositional --- Properties of the setoid sublist relation -import Data.List.Relation.Binary.Sublist.Setoid.Properties +-- Properties of the sublist relation over setoid equality. +import Data.List.Relation.Binary.Subset.Propositional.Properties --- Decidability of the subset relation over propositional equality. -import Data.List.Relation.Binary.Subset.DecPropositional +-- The extensional sublist relation over setoid equality. +import Data.List.Relation.Binary.Subset.Setoid --- Decidability of the subset relation over setoid equality. -import Data.List.Relation.Binary.Subset.DecSetoid +-- Properties of the extensional sublist relation over setoid equality. +import Data.List.Relation.Binary.Subset.Setoid.Properties --- The sublist relation over propositional equality. -import Data.List.Relation.Binary.Subset.Propositional +-- An inductive definition of the heterogeneous suffix relation +import Data.List.Relation.Binary.Suffix.Heterogeneous --- Properties of the sublist relation over setoid equality. -import Data.List.Relation.Binary.Subset.Propositional.Properties +-- Properties of the heterogeneous suffix relation +import Data.List.Relation.Binary.Suffix.Heterogeneous.Properties --- The extensional sublist relation over setoid equality. -import Data.List.Relation.Binary.Subset.Setoid +-- Properties of the homogeneous suffix relation +import Data.List.Relation.Binary.Suffix.Homogeneous.Properties --- Properties of the extensional sublist relation over setoid equality. -import Data.List.Relation.Binary.Subset.Setoid.Properties +-- Properties of the propositional suffix relation +import Data.List.Relation.Binary.Suffix.Propositional.Properties --- An inductive definition of the heterogeneous suffix relation -import Data.List.Relation.Binary.Suffix.Heterogeneous +-- Generalised view of appending two lists into one. +import Data.List.Relation.Ternary.Appending --- Properties of the heterogeneous suffix relation -import Data.List.Relation.Binary.Suffix.Heterogeneous.Properties +-- Properties of the generalised view of appending two lists +import Data.List.Relation.Ternary.Appending.Properties --- Properties of the homogeneous suffix relation -import Data.List.Relation.Binary.Suffix.Homogeneous.Properties +-- Appending of lists using propositional equality +import Data.List.Relation.Ternary.Appending.Propositional --- Properties of the propositional suffix relation -import Data.List.Relation.Binary.Suffix.Propositional.Properties +-- Properties of list appending +import Data.List.Relation.Ternary.Appending.Propositional.Properties --- Generalised view of appending two lists into one. -import Data.List.Relation.Ternary.Appending +-- Appending of lists using setoid equality +import Data.List.Relation.Ternary.Appending.Setoid --- Properties of the generalised view of appending two lists -import Data.List.Relation.Ternary.Appending.Properties +-- Properties of list appending +import Data.List.Relation.Ternary.Appending.Setoid.Properties --- Appending of lists using propositional equality -import Data.List.Relation.Ternary.Appending.Propositional +-- Generalised notion of interleaving two lists into one in an +-- order-preserving manner +import Data.List.Relation.Ternary.Interleaving --- Properties of list appending -import Data.List.Relation.Ternary.Appending.Propositional.Properties +-- Properties of general interleavings +import Data.List.Relation.Ternary.Interleaving.Properties --- Appending of lists using setoid equality -import Data.List.Relation.Ternary.Appending.Setoid +-- Interleavings of lists using propositional equality +import Data.List.Relation.Ternary.Interleaving.Propositional --- Properties of list appending -import Data.List.Relation.Ternary.Appending.Setoid.Properties +-- Properties of interleaving using propositional equality +import Data.List.Relation.Ternary.Interleaving.Propositional.Properties --- Generalised notion of interleaving two lists into one in an --- order-preserving manner -import Data.List.Relation.Ternary.Interleaving +-- Interleavings of lists using setoid equality +import Data.List.Relation.Ternary.Interleaving.Setoid --- Properties of general interleavings -import Data.List.Relation.Ternary.Interleaving.Properties +-- Properties of interleaving using setoid equality +import Data.List.Relation.Ternary.Interleaving.Setoid.Properties --- Interleavings of lists using propositional equality -import Data.List.Relation.Ternary.Interleaving.Propositional +-- Lists where all elements satisfy a given property +import Data.List.Relation.Unary.All --- Properties of interleaving using propositional equality -import Data.List.Relation.Ternary.Interleaving.Propositional.Properties +-- Properties related to All +import Data.List.Relation.Unary.All.Properties --- Interleavings of lists using setoid equality -import Data.List.Relation.Ternary.Interleaving.Setoid +-- Lists where every pair of elements are related (symmetrically) +import Data.List.Relation.Unary.AllPairs --- Properties of interleaving using setoid equality -import Data.List.Relation.Ternary.Interleaving.Setoid.Properties +-- Properties related to AllPairs +import Data.List.Relation.Unary.AllPairs.Properties --- Lists where all elements satisfy a given property -import Data.List.Relation.Unary.All +-- Lists where at least one element satisfies a given property +import Data.List.Relation.Unary.Any --- Properties related to All -import Data.List.Relation.Unary.All.Properties +-- Properties related to Any +import Data.List.Relation.Unary.Any.Properties --- Lists where every pair of elements are related (symmetrically) -import Data.List.Relation.Unary.AllPairs +-- Lists which contain every element of a given type +import Data.List.Relation.Unary.Enumerates.Setoid --- Properties related to AllPairs -import Data.List.Relation.Unary.AllPairs.Properties +-- Properties of lists which contain every element of a given type +import Data.List.Relation.Unary.Enumerates.Setoid.Properties --- Lists where at least one element satisfies a given property -import Data.List.Relation.Unary.Any +-- First generalizes the idea that an element is the first in a list to +-- satisfy a predicate. +import Data.List.Relation.Unary.First --- Properties related to Any -import Data.List.Relation.Unary.Any.Properties +-- Properties of First +import Data.List.Relation.Unary.First.Properties --- Lists which contain every element of a given type -import Data.List.Relation.Unary.Enumerates.Setoid +-- Property that elements are grouped +import Data.List.Relation.Unary.Grouped --- Properties of lists which contain every element of a given type -import Data.List.Relation.Unary.Enumerates.Setoid.Properties +-- Property related to Grouped +import Data.List.Relation.Unary.Grouped.Properties --- First generalizes the idea that an element is the first in a list to --- satisfy a predicate. -import Data.List.Relation.Unary.First +-- Lists where every consecutative pair of elements is related. +import Data.List.Relation.Unary.Linked --- Properties of First -import Data.List.Relation.Unary.First.Properties +-- Properties related to Linked +import Data.List.Relation.Unary.Linked.Properties --- Property that elements are grouped -import Data.List.Relation.Unary.Grouped +-- Sorted lists +import Data.List.Relation.Unary.Sorted.TotalOrder --- Property related to Grouped -import Data.List.Relation.Unary.Grouped.Properties +-- Sorted lists +import Data.List.Relation.Unary.Sorted.TotalOrder.Properties --- Lists where every consecutative pair of elements is related. -import Data.List.Relation.Unary.Linked +-- 'Sufficient' lists: a structurally inductive view of lists xs +-- as given by xs ≡ non-empty prefix + sufficient suffix +import Data.List.Relation.Unary.Sufficient --- Properties related to Linked -import Data.List.Relation.Unary.Linked.Properties +-- Lists made up entirely of unique elements (setoid equality) +import Data.List.Relation.Unary.Unique.DecPropositional --- Sorted lists -import Data.List.Relation.Unary.Sorted.TotalOrder +-- Properties of lists made up entirely of decidably unique elements +import Data.List.Relation.Unary.Unique.DecPropositional.Properties --- Sorted lists -import Data.List.Relation.Unary.Sorted.TotalOrder.Properties +-- Lists made up entirely of unique elements (setoid equality) +import Data.List.Relation.Unary.Unique.DecSetoid --- 'Sufficient' lists: a structurally inductive view of lists xs --- as given by xs ≡ non-empty prefix + sufficient suffix -import Data.List.Relation.Unary.Sufficient +-- Properties of lists made up entirely of decidably unique elements +import Data.List.Relation.Unary.Unique.DecSetoid.Properties --- Lists made up entirely of unique elements (setoid equality) -import Data.List.Relation.Unary.Unique.DecPropositional +-- Lists made up entirely of unique elements (propositional equality) +import Data.List.Relation.Unary.Unique.Propositional --- Properties of lists made up entirely of decidably unique elements -import Data.List.Relation.Unary.Unique.DecPropositional.Properties +-- Properties of unique lists (setoid equality) +import Data.List.Relation.Unary.Unique.Propositional.Properties --- Lists made up entirely of unique elements (setoid equality) -import Data.List.Relation.Unary.Unique.DecSetoid +-- Lists made up entirely of unique elements (setoid equality) +import Data.List.Relation.Unary.Unique.Setoid --- Properties of lists made up entirely of decidably unique elements -import Data.List.Relation.Unary.Unique.DecSetoid.Properties +-- Properties of unique lists (setoid equality) +import Data.List.Relation.Unary.Unique.Setoid.Properties --- Lists made up entirely of unique elements (propositional equality) -import Data.List.Relation.Unary.Unique.Propositional +-- Reverse view +import Data.List.Reverse --- Properties of unique lists (setoid equality) -import Data.List.Relation.Unary.Unique.Propositional.Properties +-- List scans: definitions +import Data.List.Scans.Base --- Lists made up entirely of unique elements (setoid equality) -import Data.List.Relation.Unary.Unique.Setoid +-- List scans: properties +import Data.List.Scans.Properties --- Properties of unique lists (setoid equality) -import Data.List.Relation.Unary.Unique.Setoid.Properties +-- Showing lists +import Data.List.Show --- Reverse view -import Data.List.Reverse +-- Functions and definitions for sorting lists +import Data.List.Sort --- List scans: definitions -import Data.List.Scans.Base +-- The core definition of a sorting algorithm +import Data.List.Sort.Base --- List scans: properties -import Data.List.Scans.Properties +-- An implementation of insertion sort and its properties +import Data.List.Sort.InsertionSort --- Showing lists -import Data.List.Show +-- An implementation of insertion sort +import Data.List.Sort.InsertionSort.Base --- Functions and definitions for sorting lists -import Data.List.Sort +-- Properties of insertion sort +import Data.List.Sort.InsertionSort.Properties --- The core definition of a sorting algorithm -import Data.List.Sort.Base +-- An implementation of merge sort along with proofs of correctness. +import Data.List.Sort.MergeSort --- An implementation of insertion sort and its properties -import Data.List.Sort.InsertionSort +-- An implementation of merge sort +import Data.List.Sort.MergeSort.Base --- An implementation of insertion sort -import Data.List.Sort.InsertionSort.Base +-- An implementation of merge sort along with proofs of correctness. +import Data.List.Sort.MergeSort.Properties --- Properties of insertion sort -import Data.List.Sort.InsertionSort.Properties +-- List Zippers, basic types and operations +import Data.List.Zipper --- An implementation of merge sort along with proofs of correctness. -import Data.List.Sort.MergeSort +-- List Zipper-related properties +import Data.List.Zipper.Properties --- An implementation of merge sort -import Data.List.Sort.MergeSort.Base +-- The Maybe type +import Data.Maybe --- An implementation of merge sort along with proofs of correctness. -import Data.List.Sort.MergeSort.Properties +-- The Maybe type and some operations +import Data.Maybe.Base --- List Zippers, basic types and operations -import Data.List.Zipper +-- An effectful view of Maybe +import Data.Maybe.Effectful --- List Zipper-related properties -import Data.List.Zipper.Properties +-- An effectful view of Maybe +import Data.Maybe.Effectful.Transformer --- The Maybe type -import Data.Maybe +-- Typeclass instances for Maybe +import Data.Maybe.Instances --- The Maybe type and some operations -import Data.Maybe.Base +-- Maybe-related properties +import Data.Maybe.Properties --- An effectful view of Maybe -import Data.Maybe.Effectful +-- Lifting a relation such that `nothing` is also related to `just` +import Data.Maybe.Relation.Binary.Connected --- An effectful view of Maybe -import Data.Maybe.Effectful.Transformer +-- Pointwise lifting of relations to maybes +import Data.Maybe.Relation.Binary.Pointwise --- Typeclass instances for Maybe -import Data.Maybe.Instances +-- Maybes where all the elements satisfy a given property +import Data.Maybe.Relation.Unary.All --- Maybe-related properties -import Data.Maybe.Properties +-- Properties related to All +import Data.Maybe.Relation.Unary.All.Properties --- Lifting a relation such that `nothing` is also related to `just` -import Data.Maybe.Relation.Binary.Connected +-- Maybes where one of the elements satisfies a given property +import Data.Maybe.Relation.Unary.Any --- Pointwise lifting of relations to maybes -import Data.Maybe.Relation.Binary.Pointwise +-- Natural numbers +import Data.Nat --- Maybes where all the elements satisfy a given property -import Data.Maybe.Relation.Unary.All +-- Natural numbers, basic types and operations +import Data.Nat.Base --- Properties related to All -import Data.Maybe.Relation.Unary.All.Properties +-- Natural numbers represented in binary natively in Agda. +import Data.Nat.Binary --- Maybes where one of the elements satisfies a given property -import Data.Maybe.Relation.Unary.Any +-- Natural numbers represented in binary. +import Data.Nat.Binary.Base --- Natural numbers -import Data.Nat +-- Induction over _<_ for ℕᵇ. +import Data.Nat.Binary.Induction --- Natural numbers, basic types and operations -import Data.Nat.Base +-- Instances for binary natural numbers +import Data.Nat.Binary.Instances --- Natural numbers represented in binary natively in Agda. -import Data.Nat.Binary +-- Basic properties of ℕᵇ +import Data.Nat.Binary.Properties --- Natural numbers represented in binary. -import Data.Nat.Binary.Base +-- Subtraction on Bin and some of its properties. +import Data.Nat.Binary.Subtraction --- Induction over _<_ for ℕᵇ. -import Data.Nat.Binary.Induction +-- Combinatorial operations +import Data.Nat.Combinatorics --- Instances for binary natural numbers -import Data.Nat.Binary.Instances +-- Combinatorics operations +import Data.Nat.Combinatorics.Base --- Basic properties of ℕᵇ -import Data.Nat.Binary.Properties +-- The specification for combinatorics operations +import Data.Nat.Combinatorics.Specification --- Subtraction on Bin and some of its properties. -import Data.Nat.Binary.Subtraction +-- Coprimality +import Data.Nat.Coprimality --- Combinatorial operations -import Data.Nat.Combinatorics +-- Natural number division +import Data.Nat.DivMod --- Combinatorics operations -import Data.Nat.Combinatorics.Base +-- More efficient mod and divMod operations (require the K axiom) +import Data.Nat.DivMod.WithK --- The specification for combinatorics operations -import Data.Nat.Combinatorics.Specification +-- Divisibility +import Data.Nat.Divisibility --- Coprimality -import Data.Nat.Coprimality +-- Greatest common divisor +import Data.Nat.GCD --- Natural number division -import Data.Nat.DivMod +-- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality +import Data.Nat.GCD.Lemmas --- More efficient mod and divMod operations (require the K axiom) -import Data.Nat.DivMod.WithK +-- A generalisation of the arithmetic operations +import Data.Nat.GeneralisedArithmetic --- Divisibility -import Data.Nat.Divisibility +-- Various forms of induction for natural numbers +import Data.Nat.Induction --- Greatest common divisor -import Data.Nat.GCD +-- Definition of and lemmas related to "true infinitely often" +import Data.Nat.InfinitelyOften --- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality -import Data.Nat.GCD.Lemmas +-- Instances for natural numbers +import Data.Nat.Instances --- A generalisation of the arithmetic operations -import Data.Nat.GeneralisedArithmetic +-- Least common multiple +import Data.Nat.LCM --- Various forms of induction for natural numbers -import Data.Nat.Induction +-- Natural numbers: sum and product of lists +import Data.Nat.ListAction --- Definition of and lemmas related to "true infinitely often" -import Data.Nat.InfinitelyOften +-- Natural numbers: properties of sum and product +import Data.Nat.ListAction.Properties --- Instances for natural numbers -import Data.Nat.Instances +-- Natural Literals +import Data.Nat.Literals --- Least common multiple -import Data.Nat.LCM +-- Logarithm base 2 and respective properties +import Data.Nat.Logarithm --- Natural numbers: sum and product of lists -import Data.Nat.ListAction +-- Primality +import Data.Nat.Primality --- Natural numbers: properties of sum and product -import Data.Nat.ListAction.Properties +-- Prime factorisation of natural numbers and its properties +import Data.Nat.Primality.Factorisation --- Natural Literals -import Data.Nat.Literals +-- A bunch of properties about natural number operations +import Data.Nat.Properties --- Logarithm base 2 and respective properties -import Data.Nat.Logarithm +-- Linear congruential pseudo random generators for natural numbers +-- /!\ NB: LCGs must not be used for cryptographic applications +import Data.Nat.PseudoRandom.LCG --- Primality -import Data.Nat.Primality +-- Reflection utilities for ℕ +import Data.Nat.Reflection --- Prime factorisation of natural numbers and its properties -import Data.Nat.Primality.Factorisation +-- Showing natural numbers +import Data.Nat.Show --- A bunch of properties about natural number operations -import Data.Nat.Properties +-- Properties of showing natural numbers +import Data.Nat.Show.Properties --- Linear congruential pseudo random generators for natural numbers --- /!\ NB: LCGs must not be used for cryptographic applications -import Data.Nat.PseudoRandom.LCG +-- Automatic solvers for equations over naturals +import Data.Nat.Solver --- Reflection utilities for ℕ -import Data.Nat.Reflection +-- Automatic solvers for equations over naturals +import Data.Nat.Tactic.RingSolver --- Showing natural numbers -import Data.Nat.Show +-- Natural number types and operations requiring the axiom K. +import Data.Nat.WithK --- Properties of showing natural numbers -import Data.Nat.Show.Properties +-- Parity +import Data.Parity --- Automatic solvers for equations over naturals -import Data.Nat.Solver +-- Parity +import Data.Parity.Base --- Automatic solvers for equations over naturals -import Data.Nat.Tactic.RingSolver +-- Instances for parities +import Data.Parity.Instances --- Natural number types and operations requiring the axiom K. -import Data.Nat.WithK +-- Some properties about parities +import Data.Parity.Properties --- Parity -import Data.Parity +-- Products +import Data.Product --- Parity -import Data.Parity.Base +-- Algebraic properties of products +import Data.Product.Algebra --- Instances for parities -import Data.Parity.Instances +-- Products +import Data.Product.Base --- Some properties about parities -import Data.Parity.Properties +-- Universe-sensitive functor and monad instances for the Product type. +import Data.Product.Effectful.Examples --- Products -import Data.Product +-- Left-biased universe-sensitive functor and monad instances for the +-- Product type. +import Data.Product.Effectful.Left --- Algebraic properties of products -import Data.Product.Algebra +-- Base definitions for the left-biased universe-sensitive functor and +-- monad instances for the Product type. +import Data.Product.Effectful.Left.Base --- Products -import Data.Product.Base +-- Right-biased universe-sensitive functor and monad instances for the +-- Product type. +import Data.Product.Effectful.Right --- Universe-sensitive functor and monad instances for the Product type. -import Data.Product.Effectful.Examples +-- Base definitions for the right-biased universe-sensitive functor +-- and monad instances for the Product type. +import Data.Product.Effectful.Right.Base --- Left-biased universe-sensitive functor and monad instances for the --- Product type. -import Data.Product.Effectful.Left +-- Dependent product combinators for propositional equality +-- preserving functions +import Data.Product.Function.Dependent.Propositional --- Base definitions for the left-biased universe-sensitive functor and --- monad instances for the Product type. -import Data.Product.Effectful.Left.Base +-- Dependent product combinators for propositional equality +-- preserving functions +import Data.Product.Function.Dependent.Propositional.WithK --- Right-biased universe-sensitive functor and monad instances for the --- Product type. -import Data.Product.Effectful.Right +-- Dependent product combinators for setoid equality preserving +-- functions. +import Data.Product.Function.Dependent.Setoid --- Base definitions for the right-biased universe-sensitive functor --- and monad instances for the Product type. -import Data.Product.Effectful.Right.Base +-- Non-dependent product combinators for propositional equality +-- preserving functions +import Data.Product.Function.NonDependent.Propositional --- Dependent product combinators for propositional equality --- preserving functions -import Data.Product.Function.Dependent.Propositional +-- Non-dependent product combinators for setoid equality preserving +-- functions +import Data.Product.Function.NonDependent.Setoid --- Dependent product combinators for propositional equality --- preserving functions -import Data.Product.Function.Dependent.Propositional.WithK +-- Typeclass instances for products +import Data.Product.Instances --- Dependent product combinators for setoid equality preserving --- functions. -import Data.Product.Function.Dependent.Setoid +-- Nondependent heterogeneous N-ary products +import Data.Product.Nary.NonDependent --- Non-dependent product combinators for propositional equality --- preserving functions -import Data.Product.Function.NonDependent.Propositional +-- Properties of products +import Data.Product.Properties --- Non-dependent product combinators for setoid equality preserving --- functions -import Data.Product.Function.NonDependent.Setoid +-- Properties of 'very dependent' map / zipWith over products +import Data.Product.Properties.Dependent --- Typeclass instances for products -import Data.Product.Instances +-- Properties, related to products, that rely on the K rule +import Data.Product.Properties.WithK --- Nondependent heterogeneous N-ary products -import Data.Product.Nary.NonDependent +-- Lexicographic products of binary relations +import Data.Product.Relation.Binary.Lex.NonStrict --- Properties of products -import Data.Product.Properties +-- Lexicographic products of binary relations +import Data.Product.Relation.Binary.Lex.Strict --- Properties of 'very dependent' map / zipWith over products -import Data.Product.Properties.Dependent +-- Pointwise lifting of binary relations to sigma types +import Data.Product.Relation.Binary.Pointwise.Dependent --- Properties, related to products, that rely on the K rule -import Data.Product.Properties.WithK +-- Properties that are related to pointwise lifting of binary +-- relations to sigma types and make use of heterogeneous equality +import Data.Product.Relation.Binary.Pointwise.Dependent.WithK --- Lexicographic products of binary relations -import Data.Product.Relation.Binary.Lex.NonStrict +-- Pointwise products of binary relations +import Data.Product.Relation.Binary.Pointwise.NonDependent --- Lexicographic products of binary relations -import Data.Product.Relation.Binary.Lex.Strict +-- Lifting of two predicates +import Data.Product.Relation.Unary.All --- Pointwise lifting of binary relations to sigma types -import Data.Product.Relation.Binary.Pointwise.Dependent +-- Rational numbers +import Data.Rational --- Properties that are related to pointwise lifting of binary --- relations to sigma types and make use of heterogeneous equality -import Data.Product.Relation.Binary.Pointwise.Dependent.WithK +-- Rational numbers +import Data.Rational.Base --- Pointwise products of binary relations -import Data.Product.Relation.Binary.Pointwise.NonDependent +-- Instances for rational numbers +import Data.Rational.Instances --- Lifting of two predicates -import Data.Product.Relation.Unary.All +-- Rational Literals +import Data.Rational.Literals --- Rational numbers -import Data.Rational +-- Properties of Rational numbers +import Data.Rational.Properties --- Rational numbers -import Data.Rational.Base +-- Showing rational numbers +import Data.Rational.Show --- Instances for rational numbers -import Data.Rational.Instances +-- Automatic solvers for equations over rationals +import Data.Rational.Solver --- Rational Literals -import Data.Rational.Literals +-- Rational numbers in non-reduced form. +import Data.Rational.Unnormalised --- Properties of Rational numbers -import Data.Rational.Properties +-- Rational numbers in non-reduced form. +import Data.Rational.Unnormalised.Base --- Showing rational numbers -import Data.Rational.Show +-- Properties of unnormalized Rational numbers +import Data.Rational.Unnormalised.Properties --- Automatic solvers for equations over rationals -import Data.Rational.Solver +-- Showing unnormalised rational numbers +import Data.Rational.Unnormalised.Show --- Rational numbers in non-reduced form. -import Data.Rational.Unnormalised +-- Automatic solvers for equations over rationals +import Data.Rational.Unnormalised.Solver --- Rational numbers in non-reduced form. -import Data.Rational.Unnormalised.Base +-- Record types with manifest fields and "with", based on Randy +-- Pollack's "Dependently Typed Records in Type Theory" +import Data.Record --- Properties of unnormalized Rational numbers -import Data.Rational.Unnormalised.Properties +-- Refinement type: a value together with a proof irrelevant witness. +import Data.Refinement --- Showing unnormalised rational numbers -import Data.Rational.Unnormalised.Show +-- Refinement type: a value together with a proof irrelevant witness. +import Data.Refinement.Base --- Automatic solvers for equations over rationals -import Data.Rational.Unnormalised.Solver +-- Properties of refinement types +import Data.Refinement.Properties --- Record types with manifest fields and "with", based on Randy --- Pollack's "Dependently Typed Records in Type Theory" -import Data.Record +-- Predicate lifting for refinement types +import Data.Refinement.Relation.Unary.All --- Refinement type: a value together with a proof irrelevant witness. -import Data.Refinement +-- Signs +import Data.Sign --- Refinement type: a value together with a proof irrelevant witness. -import Data.Refinement.Base +-- Signs +import Data.Sign.Base --- Properties of refinement types -import Data.Refinement.Properties +-- Instances for signs +import Data.Sign.Instances --- Predicate lifting for refinement types -import Data.Refinement.Relation.Unary.All +-- Some properties about signs +import Data.Sign.Properties --- Signs -import Data.Sign +-- Showing signs +import Data.Sign.Show --- Signs -import Data.Sign.Base +-- Bounded vectors (inefficient implementation) +import Data.Star.BoundedVec --- Instances for signs -import Data.Sign.Instances +-- Decorated star-lists +import Data.Star.Decoration --- Some properties about signs -import Data.Sign.Properties +-- Environments (heterogeneous collections) +import Data.Star.Environment --- Showing signs -import Data.Sign.Show +-- Finite sets defined using the reflexive-transitive closure, Star +import Data.Star.Fin --- Bounded vectors (inefficient implementation) -import Data.Star.BoundedVec +-- Lists defined in terms of the reflexive-transitive closure, Star +import Data.Star.List --- Decorated star-lists -import Data.Star.Decoration +-- Natural numbers defined using the reflexive-transitive closure, Star +import Data.Star.Nat --- Environments (heterogeneous collections) -import Data.Star.Environment +-- Pointers into star-lists +import Data.Star.Pointer --- Finite sets defined using the reflexive-transitive closure, Star -import Data.Star.Fin +-- Vectors defined in terms of the reflexive-transitive closure, Star +import Data.Star.Vec --- Lists defined in terms of the reflexive-transitive closure, Star -import Data.Star.List +-- Strings +import Data.String --- Natural numbers defined using the reflexive-transitive closure, Star -import Data.Star.Nat +-- Strings: builtin type and basic operations +import Data.String.Base --- Pointers into star-lists -import Data.Star.Pointer +-- Instances for strings +import Data.String.Instances --- Vectors defined in terms of the reflexive-transitive closure, Star -import Data.Star.Vec +-- String Literals +import Data.String.Literals --- Strings -import Data.String +-- Properties of operations on strings +import Data.String.Properties --- Strings: builtin type and basic operations -import Data.String.Base +-- Sums (disjoint unions) +import Data.Sum --- Instances for strings -import Data.String.Instances +-- Algebraic properties of sums (disjoint unions) +import Data.Sum.Algebra --- String Literals -import Data.String.Literals +-- Sums (disjoint unions) +import Data.Sum.Base --- Properties of operations on strings -import Data.String.Properties +-- Usage examples of the effectful view of the Sum type +import Data.Sum.Effectful.Examples --- Sums (disjoint unions) -import Data.Sum +-- An effectful view of the Sum type (Left-biased) +import Data.Sum.Effectful.Left --- Algebraic properties of sums (disjoint unions) -import Data.Sum.Algebra +-- An effectful view of the Sum type (Left-biased) +import Data.Sum.Effectful.Left.Transformer --- Sums (disjoint unions) -import Data.Sum.Base +-- An effectful view of the Sum type (Right-biased) +import Data.Sum.Effectful.Right --- Usage examples of the effectful view of the Sum type -import Data.Sum.Effectful.Examples +-- An effectful view of the Sum type (Right-biased) +import Data.Sum.Effectful.Right.Transformer --- An effectful view of the Sum type (Left-biased) -import Data.Sum.Effectful.Left +-- Sum combinators for propositional equality preserving functions +import Data.Sum.Function.Propositional --- An effectful view of the Sum type (Left-biased) -import Data.Sum.Effectful.Left.Transformer +-- Sum combinators for setoid equality preserving functions +import Data.Sum.Function.Setoid --- An effectful view of the Sum type (Right-biased) -import Data.Sum.Effectful.Right +-- Typeclass instances for sums +import Data.Sum.Instances --- An effectful view of the Sum type (Right-biased) -import Data.Sum.Effectful.Right.Transformer +-- Properties of sums (disjoint unions) +import Data.Sum.Properties --- Sum combinators for propositional equality preserving functions -import Data.Sum.Function.Propositional +-- Sums of binary relations +import Data.Sum.Relation.Binary.LeftOrder --- Sum combinators for setoid equality preserving functions -import Data.Sum.Function.Setoid +-- Pointwise sum +import Data.Sum.Relation.Binary.Pointwise --- Typeclass instances for sums -import Data.Sum.Instances +-- Heterogeneous `All` predicate for disjoint sums +import Data.Sum.Relation.Unary.All --- Properties of sums (disjoint unions) -import Data.Sum.Properties +-- An either-or-both data type +import Data.These --- Sums of binary relations -import Data.Sum.Relation.Binary.LeftOrder +-- An either-or-both data type, basic type and operations +import Data.These.Base --- Pointwise sum -import Data.Sum.Relation.Binary.Pointwise +-- Left-biased universe-sensitive functor and monad instances for These. +import Data.These.Effectful.Left --- Heterogeneous `All` predicate for disjoint sums -import Data.Sum.Relation.Unary.All +-- Base definitions for the left-biased universe-sensitive functor and +-- monad instances for These. +import Data.These.Effectful.Left.Base --- An either-or-both data type -import Data.These +-- Right-biased universe-sensitive functor and monad instances for These. +import Data.These.Effectful.Right --- An either-or-both data type, basic type and operations -import Data.These.Base +-- Base definitions for the right-biased universe-sensitive functor and +-- monad instances for These. +import Data.These.Effectful.Right.Base --- Left-biased universe-sensitive functor and monad instances for These. -import Data.These.Effectful.Left +-- Typeclass instances for These +import Data.These.Instances --- Base definitions for the left-biased universe-sensitive functor and --- monad instances for These. -import Data.These.Effectful.Left.Base +-- Properties of These +import Data.These.Properties --- Right-biased universe-sensitive functor and monad instances for These. -import Data.These.Effectful.Right +-- AVL trees +import Data.Tree.AVL --- Base definitions for the right-biased universe-sensitive functor and --- monad instances for These. -import Data.These.Effectful.Right.Base +-- Types and functions which are used to keep track of height +-- invariants in AVL Trees +import Data.Tree.AVL.Height --- Typeclass instances for These -import Data.These.Instances +-- AVL trees where the stored values may depend on their key +import Data.Tree.AVL.Indexed --- Properties of These -import Data.These.Properties +-- AVL trees whose elements satisfy a given property +import Data.Tree.AVL.Indexed.Relation.Unary.All --- AVL trees -import Data.Tree.AVL +-- AVL trees where at least one element satisfies a given property +import Data.Tree.AVL.Indexed.Relation.Unary.Any --- Types and functions which are used to keep track of height --- invariants in AVL Trees -import Data.Tree.AVL.Height +-- Properties related to Any +import Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties --- AVL trees where the stored values may depend on their key -import Data.Tree.AVL.Indexed +-- Some code related to indexed AVL trees that relies on the K rule +import Data.Tree.AVL.Indexed.WithK --- AVL trees whose elements satisfy a given property -import Data.Tree.AVL.Indexed.Relation.Unary.All +-- Finite maps with indexed keys and values, based on AVL trees +import Data.Tree.AVL.IndexedMap --- AVL trees where at least one element satisfies a given property -import Data.Tree.AVL.Indexed.Relation.Unary.Any +-- Keys for AVL trees -- the original key type extended with a new +-- minimum and maximum. +import Data.Tree.AVL.Key --- Properties related to Any -import Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties +-- Maps from keys to values, based on AVL trees +-- This modules provides a simpler map interface, without a dependency +-- between the key and value types. +import Data.Tree.AVL.Map --- Some code related to indexed AVL trees that relies on the K rule -import Data.Tree.AVL.Indexed.WithK +-- Membership relation for AVL Maps identifying values up to +-- propositional equality. +import Data.Tree.AVL.Map.Membership.Propositional --- Finite maps with indexed keys and values, based on AVL trees -import Data.Tree.AVL.IndexedMap +-- Properties of the membership relation for AVL Maps identifying values +-- up to propositional equality. +import Data.Tree.AVL.Map.Membership.Propositional.Properties --- Keys for AVL trees -- the original key type extended with a new --- minimum and maximum. -import Data.Tree.AVL.Key +-- AVL trees where at least one element satisfies a given property +import Data.Tree.AVL.Map.Relation.Unary.Any --- Maps from keys to values, based on AVL trees --- This modules provides a simpler map interface, without a dependency --- between the key and value types. -import Data.Tree.AVL.Map +-- Non-empty AVL trees +import Data.Tree.AVL.NonEmpty --- Membership relation for AVL Maps identifying values up to --- propositional equality. -import Data.Tree.AVL.Map.Membership.Propositional +-- Non-empty AVL trees, where equality for keys is propositional equality +import Data.Tree.AVL.NonEmpty.Propositional --- Properties of the membership relation for AVL Maps identifying values --- up to propositional equality. -import Data.Tree.AVL.Map.Membership.Propositional.Properties +-- AVL trees where at least one element satisfies a given property +import Data.Tree.AVL.Relation.Unary.Any --- AVL trees where at least one element satisfies a given property -import Data.Tree.AVL.Map.Relation.Unary.Any +-- Finite sets, based on AVL trees +import Data.Tree.AVL.Sets --- Non-empty AVL trees -import Data.Tree.AVL.NonEmpty +-- Membership relation for AVL sets +import Data.Tree.AVL.Sets.Membership --- Non-empty AVL trees, where equality for keys is propositional equality -import Data.Tree.AVL.NonEmpty.Propositional +-- Properties of membership for AVL sets +import Data.Tree.AVL.Sets.Membership.Properties --- AVL trees where at least one element satisfies a given property -import Data.Tree.AVL.Relation.Unary.Any +-- Values for AVL trees +-- Values must respect the underlying equivalence on keys +import Data.Tree.AVL.Value --- Finite sets, based on AVL trees -import Data.Tree.AVL.Sets +-- Binary Trees +import Data.Tree.Binary --- Membership relation for AVL sets -import Data.Tree.AVL.Sets.Membership +-- Properties of binary trees +import Data.Tree.Binary.Properties --- Properties of membership for AVL sets -import Data.Tree.AVL.Sets.Membership.Properties +-- Pointwise lifting of a predicate to a binary tree +import Data.Tree.Binary.Relation.Unary.All --- Values for AVL trees --- Values must respect the underlying equivalence on keys -import Data.Tree.AVL.Value +-- Properties of the pointwise lifting of a predicate to a binary tree +import Data.Tree.Binary.Relation.Unary.All.Properties --- Binary Trees -import Data.Tree.Binary +-- Zippers for Binary Trees +import Data.Tree.Binary.Zipper --- Properties of binary trees -import Data.Tree.Binary.Properties +-- Tree Zipper-related properties +import Data.Tree.Binary.Zipper.Properties --- Pointwise lifting of a predicate to a binary tree -import Data.Tree.Binary.Relation.Unary.All +-- The unit type, Level-monomorphic version +import Data.Unit --- Properties of the pointwise lifting of a predicate to a binary tree -import Data.Tree.Binary.Relation.Unary.All.Properties +-- The unit type and the total relation on unit +import Data.Unit.Base --- Zippers for Binary Trees -import Data.Tree.Binary.Zipper +-- Instances for the unit type +import Data.Unit.Instances --- Tree Zipper-related properties -import Data.Tree.Binary.Zipper.Properties +-- Some unit types +import Data.Unit.NonEta --- The unit type, Level-monomorphic version -import Data.Unit +-- The universe polymorphic unit type and the total relation on unit +import Data.Unit.Polymorphic --- The unit type and the total relation on unit -import Data.Unit.Base +-- A universe polymorphic unit type, as a Lift of the Level 0 one. +import Data.Unit.Polymorphic.Base --- Instances for the unit type -import Data.Unit.Instances +-- Instances for the polymorphic unit type +import Data.Unit.Polymorphic.Instances --- Some unit types -import Data.Unit.NonEta +-- Properties of the polymorphic unit type +-- Defines Decidable Equality and Decidable Ordering as well +import Data.Unit.Polymorphic.Properties --- The universe polymorphic unit type and the total relation on unit -import Data.Unit.Polymorphic +-- Properties of the unit type +import Data.Unit.Properties --- A universe polymorphic unit type, as a Lift of the Level 0 one. -import Data.Unit.Polymorphic.Base +-- Universes +import Data.Universe --- Instances for the polymorphic unit type -import Data.Unit.Polymorphic.Instances +-- Indexed universes +import Data.Universe.Indexed --- Properties of the polymorphic unit type --- Defines Decidable Equality and Decidable Ordering as well -import Data.Unit.Polymorphic.Properties +-- Vectors +import Data.Vec --- Properties of the unit type -import Data.Unit.Properties +-- Vectors, basic types and operations +import Data.Vec.Base --- Universes -import Data.Universe +-- Bounded vectors +import Data.Vec.Bounded --- Indexed universes -import Data.Universe.Indexed +-- Bounded vectors, basic types and operations +import Data.Vec.Bounded.Base --- Vectors -import Data.Vec +-- Showing bounded vectors +import Data.Vec.Bounded.Show --- Vectors, basic types and operations -import Data.Vec.Base +-- An effectful view of Vec +import Data.Vec.Effectful --- Bounded vectors -import Data.Vec.Bounded +-- Vec is Foldable +import Data.Vec.Effectful.Foldable --- Bounded vectors, basic types and operations -import Data.Vec.Bounded.Base +-- An effectful view of Vec +import Data.Vec.Effectful.Transformer --- Showing bounded vectors -import Data.Vec.Bounded.Show +-- Vectors defined as functions from a finite set to a type. +import Data.Vec.Functional --- An effectful view of Vec -import Data.Vec.Effectful +-- Some Vector-related properties +import Data.Vec.Functional.Properties --- Vec is Foldable -import Data.Vec.Effectful.Foldable +-- Pointwise lifting of relations over Vector +import Data.Vec.Functional.Relation.Binary.Equality.Setoid --- An effectful view of Vec -import Data.Vec.Effectful.Transformer +-- Permutation relations over Vector +import Data.Vec.Functional.Relation.Binary.Permutation --- Vectors defined as functions from a finite set to a type. -import Data.Vec.Functional +-- Properties of permutation +import Data.Vec.Functional.Relation.Binary.Permutation.Properties --- Some Vector-related properties -import Data.Vec.Functional.Properties +-- Pointwise lifting of relations over Vector +import Data.Vec.Functional.Relation.Binary.Pointwise --- Pointwise lifting of relations over Vector -import Data.Vec.Functional.Relation.Binary.Equality.Setoid +-- Properties related to Pointwise +import Data.Vec.Functional.Relation.Binary.Pointwise.Properties --- Permutation relations over Vector -import Data.Vec.Functional.Relation.Binary.Permutation +-- Universal lifting of predicates over Vectors +import Data.Vec.Functional.Relation.Unary.All --- Properties of permutation -import Data.Vec.Functional.Relation.Binary.Permutation.Properties +-- Properties related to All +import Data.Vec.Functional.Relation.Unary.All.Properties --- Pointwise lifting of relations over Vector -import Data.Vec.Functional.Relation.Binary.Pointwise +-- Existential lifting of predicates over Vectors +import Data.Vec.Functional.Relation.Unary.Any --- Properties related to Pointwise -import Data.Vec.Functional.Relation.Binary.Pointwise.Properties +-- Typeclass instances for Vec +import Data.Vec.Instances --- Universal lifting of predicates over Vectors -import Data.Vec.Functional.Relation.Unary.All +-- Decidable propositional membership over vectors +import Data.Vec.Membership.DecPropositional --- Properties related to All -import Data.Vec.Functional.Relation.Unary.All.Properties +-- Decidable setoid membership over vectors. +import Data.Vec.Membership.DecSetoid --- Existential lifting of predicates over Vectors -import Data.Vec.Functional.Relation.Unary.Any +-- Data.Vec.Any.Membership instantiated with propositional equality, +-- along with some additional definitions. +import Data.Vec.Membership.Propositional --- Typeclass instances for Vec -import Data.Vec.Instances +-- Properties of membership of vectors based on propositional equality. +import Data.Vec.Membership.Propositional.Properties --- Decidable propositional membership over vectors -import Data.Vec.Membership.DecPropositional +-- Membership of vectors, along with some additional definitions. +import Data.Vec.Membership.Setoid --- Decidable setoid membership over vectors. -import Data.Vec.Membership.DecSetoid +-- Code for converting Vec A n → B to and from n-ary functions +import Data.Vec.N-ary --- Data.Vec.Any.Membership instantiated with propositional equality, --- along with some additional definitions. -import Data.Vec.Membership.Propositional +-- Some Vec-related properties +import Data.Vec.Properties --- Properties of membership of vectors based on propositional equality. -import Data.Vec.Membership.Propositional.Properties +-- Some Vec-related properties that depend on the K rule or make use +-- of heterogeneous equality +import Data.Vec.Properties.WithK --- Membership of vectors, along with some additional definitions. -import Data.Vec.Membership.Setoid +-- Vectors defined by recursion +import Data.Vec.Recursive --- Code for converting Vec A n → B to and from n-ary functions -import Data.Vec.N-ary +-- An effectful view of vectors defined by recursion +import Data.Vec.Recursive.Effectful --- Some Vec-related properties -import Data.Vec.Properties +-- Properties of n-ary products +import Data.Vec.Recursive.Properties --- Some Vec-related properties that depend on the K rule or make use --- of heterogeneous equality -import Data.Vec.Properties.WithK +-- Reflection utilities for Vector +import Data.Vec.Reflection --- Vectors defined by recursion -import Data.Vec.Recursive +-- An equational reasoning library for propositional equality over +-- vectors of different indices using cast. +import Data.Vec.Relation.Binary.Equality.Cast --- An effectful view of vectors defined by recursion -import Data.Vec.Recursive.Effectful +-- Decidable vector equality over propositional equality +import Data.Vec.Relation.Binary.Equality.DecPropositional --- Properties of n-ary products -import Data.Vec.Recursive.Properties +-- Decidable semi-heterogeneous vector equality over setoids +import Data.Vec.Relation.Binary.Equality.DecSetoid --- Reflection utilities for Vector -import Data.Vec.Reflection +-- Vector equality over propositional equality +import Data.Vec.Relation.Binary.Equality.Propositional --- An equational reasoning library for propositional equality over --- vectors of different indices using cast. -import Data.Vec.Relation.Binary.Equality.Cast +-- Code related to vector equality over propositional equality that +-- makes use of heterogeneous equality +import Data.Vec.Relation.Binary.Equality.Propositional.WithK --- Decidable vector equality over propositional equality -import Data.Vec.Relation.Binary.Equality.DecPropositional +-- Semi-heterogeneous vector equality over setoids +import Data.Vec.Relation.Binary.Equality.Setoid --- Decidable semi-heterogeneous vector equality over setoids -import Data.Vec.Relation.Binary.Equality.DecSetoid +-- Lexicographic ordering of same-length vector +import Data.Vec.Relation.Binary.Lex.NonStrict --- Vector equality over propositional equality -import Data.Vec.Relation.Binary.Equality.Propositional +-- Lexicographic ordering of lists of same-length vectors +import Data.Vec.Relation.Binary.Lex.Strict --- Code related to vector equality over propositional equality that --- makes use of heterogeneous equality -import Data.Vec.Relation.Binary.Equality.Propositional.WithK +-- Extensional pointwise lifting of relations to vectors +import Data.Vec.Relation.Binary.Pointwise.Extensional --- Semi-heterogeneous vector equality over setoids -import Data.Vec.Relation.Binary.Equality.Setoid +-- Inductive pointwise lifting of relations to vectors +import Data.Vec.Relation.Binary.Pointwise.Inductive --- Lexicographic ordering of same-length vector -import Data.Vec.Relation.Binary.Lex.NonStrict +-- Vectors where all elements satisfy a given property +import Data.Vec.Relation.Unary.All --- Lexicographic ordering of lists of same-length vectors -import Data.Vec.Relation.Binary.Lex.Strict +-- Properties related to All +import Data.Vec.Relation.Unary.All.Properties --- Extensional pointwise lifting of relations to vectors -import Data.Vec.Relation.Binary.Pointwise.Extensional +-- Vectors where every pair of elements are related (symmetrically) +import Data.Vec.Relation.Unary.AllPairs --- Inductive pointwise lifting of relations to vectors -import Data.Vec.Relation.Binary.Pointwise.Inductive +-- Properties related to AllPairs +import Data.Vec.Relation.Unary.AllPairs.Properties --- Vectors where all elements satisfy a given property -import Data.Vec.Relation.Unary.All +-- Vectors where at least one element satisfies a given property +import Data.Vec.Relation.Unary.Any --- Properties related to All -import Data.Vec.Relation.Unary.All.Properties +-- Properties of vector's Any +import Data.Vec.Relation.Unary.Any.Properties --- Vectors where every pair of elements are related (symmetrically) -import Data.Vec.Relation.Unary.AllPairs +-- Vectors where every consecutative pair of elements is related. +import Data.Vec.Relation.Unary.Linked --- Properties related to AllPairs -import Data.Vec.Relation.Unary.AllPairs.Properties +-- Properties related to Linked +import Data.Vec.Relation.Unary.Linked.Properties --- Vectors where at least one element satisfies a given property -import Data.Vec.Relation.Unary.Any +-- Vectors made up entirely of unique elements (propositional equality) +import Data.Vec.Relation.Unary.Unique.Propositional --- Properties of vector's Any -import Data.Vec.Relation.Unary.Any.Properties +-- Properties of unique vectors (setoid equality) +import Data.Vec.Relation.Unary.Unique.Propositional.Properties --- Vectors where every consecutative pair of elements is related. -import Data.Vec.Relation.Unary.Linked +-- Vectors made up entirely of unique elements (setoid equality) +import Data.Vec.Relation.Unary.Unique.Setoid --- Properties related to Linked -import Data.Vec.Relation.Unary.Linked.Properties +-- Properties of unique vectors (setoid equality) +import Data.Vec.Relation.Unary.Unique.Setoid.Properties --- Vectors made up entirely of unique elements (propositional equality) -import Data.Vec.Relation.Unary.Unique.Propositional +-- Showing vectors +import Data.Vec.Show --- Properties of unique vectors (setoid equality) -import Data.Vec.Relation.Unary.Unique.Propositional.Properties +-- W-types +import Data.W --- Vectors made up entirely of unique elements (setoid equality) -import Data.Vec.Relation.Unary.Unique.Setoid +-- Indexed W-types aka Petersson-Synek trees +import Data.W.Indexed --- Properties of unique vectors (setoid equality) -import Data.Vec.Relation.Unary.Unique.Setoid.Properties +-- Some code related to the W type that relies on the K rule +import Data.W.WithK --- Showing vectors -import Data.Vec.Show +-- Machine words +import Data.Word64 --- W-types -import Data.W +-- Machine words: basic type and conversion functions +import Data.Word64.Base --- Indexed W-types aka Petersson-Synek trees -import Data.W.Indexed +-- Instances for words +import Data.Word64.Instances --- Some code related to the W type that relies on the K rule -import Data.W.WithK +-- Word64 Literals +import Data.Word64.Literals --- Machine words -import Data.Word64 +-- Properties of operations on machine words +import Data.Word64.Properties --- Machine words: basic type and conversion functions -import Data.Word64.Base +-- Turn a relation into a record definition so as to remember the things +-- being related. +-- This module has a readme file: README.Data.Wrap +import Data.Wrap --- Instances for words -import Data.Word64.Instances +-- Applicative functors +import Effect.Applicative --- Word64 Literals -import Data.Word64.Literals +-- Indexed applicative functors +import Effect.Applicative.Indexed --- Properties of operations on machine words -import Data.Word64.Properties +-- Applicative functors on indexed sets (predicates) +import Effect.Applicative.Predicate --- Turn a relation into a record definition so as to remember the things --- being related. --- This module has a readme file: README.Data.Wrap -import Data.Wrap +-- Type constructors giving rise to a semigroup at every type +-- e.g. (List, _++_) +import Effect.Choice --- Applicative functors -import Effect.Applicative +-- Comonads +import Effect.Comonad --- Indexed applicative functors -import Effect.Applicative.Indexed +-- Empty values (e.g. [] for List, nothing for Maybe) +import Effect.Empty --- Applicative functors on indexed sets (predicates) -import Effect.Applicative.Predicate +-- Foldable functors +import Effect.Foldable --- Type constructors giving rise to a semigroup at every type --- e.g. (List, _++_) -import Effect.Choice +-- Functors +import Effect.Functor --- Comonads -import Effect.Comonad +-- Functors on indexed sets (predicates) +import Effect.Functor.Predicate --- Empty values (e.g. [] for List, nothing for Maybe) -import Effect.Empty +-- Monads +import Effect.Monad --- Foldable functors -import Effect.Foldable +-- A delimited continuation monad +import Effect.Monad.Continuation --- Functors -import Effect.Functor +-- The error monad transformer +import Effect.Monad.Error.Transformer --- Functors on indexed sets (predicates) -import Effect.Functor.Predicate +-- An effectful view of the identity function +import Effect.Monad.Identity --- Monads -import Effect.Monad +-- Typeclass instances for Identity +import Effect.Monad.Identity.Instances --- A delimited continuation monad -import Effect.Monad.Continuation +-- Indexed monads +import Effect.Monad.Indexed --- The error monad transformer -import Effect.Monad.Error.Transformer +-- The partiality monad +import Effect.Monad.Partiality --- An effectful view of the identity function -import Effect.Monad.Identity +-- An All predicate for the partiality monad +import Effect.Monad.Partiality.All --- Typeclass instances for Identity -import Effect.Monad.Identity.Instances +-- Typeclass instances for _⊥ +import Effect.Monad.Partiality.Instances --- Indexed monads -import Effect.Monad.Indexed +-- Monads on indexed sets (predicates) +import Effect.Monad.Predicate --- The partiality monad -import Effect.Monad.Partiality +-- The reader monad +import Effect.Monad.Reader --- An All predicate for the partiality monad -import Effect.Monad.Partiality.All +-- The indexed reader monad +import Effect.Monad.Reader.Indexed --- Typeclass instances for _⊥ -import Effect.Monad.Partiality.Instances +-- Instances for the reader monad +import Effect.Monad.Reader.Instances --- Monads on indexed sets (predicates) -import Effect.Monad.Predicate +-- The reader monad transformer +import Effect.Monad.Reader.Transformer --- The reader monad -import Effect.Monad.Reader +-- Basic type and definition of the reader monad transformer +import Effect.Monad.Reader.Transformer.Base --- The indexed reader monad -import Effect.Monad.Reader.Indexed +-- The state monad +import Effect.Monad.State --- Instances for the reader monad -import Effect.Monad.Reader.Instances +-- The indexed state monad +import Effect.Monad.State.Indexed --- The reader monad transformer -import Effect.Monad.Reader.Transformer +-- Instances for the state monad +import Effect.Monad.State.Instances --- Basic type and definition of the reader monad transformer -import Effect.Monad.Reader.Transformer.Base +-- The state monad transformer +import Effect.Monad.State.Transformer --- The state monad -import Effect.Monad.State +-- Basic definition and functions on the state monad transformer +import Effect.Monad.State.Transformer.Base --- The indexed state monad -import Effect.Monad.State.Indexed +-- The writer monad +import Effect.Monad.Writer --- Instances for the state monad -import Effect.Monad.State.Instances +-- The indexed writer monad +import Effect.Monad.Writer.Indexed --- The state monad transformer -import Effect.Monad.State.Transformer +-- Instances for the writer monad +import Effect.Monad.Writer.Instances --- Basic definition and functions on the state monad transformer -import Effect.Monad.State.Transformer.Base +-- The writer monad transformer +import Effect.Monad.Writer.Transformer --- The writer monad -import Effect.Monad.Writer +-- Basic type and definition of the writer monad transformer +import Effect.Monad.Writer.Transformer.Base --- The indexed writer monad -import Effect.Monad.Writer.Indexed +-- Functions +import Function --- Instances for the writer monad -import Effect.Monad.Writer.Instances +-- Simple combinators working solely on and with functions +import Function.Base --- The writer monad transformer -import Effect.Monad.Writer.Transformer +-- Bundles for types of functions +import Function.Bundles --- Basic type and definition of the writer monad transformer -import Effect.Monad.Writer.Transformer.Base +-- Relationships between properties of functions. See +-- `Function.Consequences.Propositional` for specialisations to +-- propositional equality. +import Function.Consequences --- Functions -import Function +-- Relationships between properties of functions where the equality +-- over both the domain and codomain is assumed to be _≡_ +import Function.Consequences.Propositional --- Simple combinators working solely on and with functions -import Function.Base +-- Relationships between properties of functions where the equality +-- over both the domain and codomain are assumed to be setoids. +import Function.Consequences.Setoid --- Bundles for types of functions -import Function.Bundles +-- Composition of functional properties +import Function.Construct.Composition --- Relationships between properties of functions. See --- `Function.Consequences.Propositional` for specialisations to --- propositional equality. -import Function.Consequences +-- The constant function +import Function.Construct.Constant --- Relationships between properties of functions where the equality --- over both the domain and codomain is assumed to be _≡_ -import Function.Consequences.Propositional +-- The identity function +import Function.Construct.Identity --- Relationships between properties of functions where the equality --- over both the domain and codomain are assumed to be setoids. -import Function.Consequences.Setoid +-- Some functional properties are symmetric +import Function.Construct.Symmetry --- Composition of functional properties -import Function.Construct.Composition +-- Definitions for types of functions. +import Function.Definitions --- The constant function -import Function.Construct.Constant +-- Bundles for types of functions +import Function.Dependent.Bundles --- The identity function -import Function.Construct.Identity +-- Endomorphisms on a Set +import Function.Endo.Propositional --- Some functional properties are symmetric -import Function.Construct.Symmetry +-- Endomorphisms on a Setoid +import Function.Endo.Setoid --- Definitions for types of functions. -import Function.Definitions +-- An effectful view of the identity function +import Function.Identity.Effectful --- Bundles for types of functions -import Function.Dependent.Bundles +-- Operations on Relations for Indexed sets +import Function.Indexed.Bundles --- Endomorphisms on a Set -import Function.Endo.Propositional +-- Function setoids and related constructions +import Function.Indexed.Relation.Binary.Equality --- Endomorphisms on a Setoid -import Function.Endo.Setoid +-- Metrics with arbitrary domains and codomains +import Function.Metric --- An effectful view of the identity function -import Function.Identity.Effectful +-- Bundles for metrics +import Function.Metric.Bundles --- Operations on Relations for Indexed sets -import Function.Indexed.Bundles +-- Definitions of properties over distance functions +import Function.Metric.Definitions --- Function setoids and related constructions -import Function.Indexed.Relation.Binary.Equality +-- Metrics with ℕ as the codomain of the metric function +import Function.Metric.Nat --- Metrics with arbitrary domains and codomains -import Function.Metric +-- Bundles for metrics over ℕ +import Function.Metric.Nat.Bundles --- Bundles for metrics -import Function.Metric.Bundles +-- Core definitions for metrics over ℕ +import Function.Metric.Nat.Definitions --- Definitions of properties over distance functions -import Function.Metric.Definitions +-- Core definitions for metrics over ℕ +import Function.Metric.Nat.Structures --- Metrics with ℕ as the codomain of the metric function -import Function.Metric.Nat +-- Metrics with ℚ as the codomain of the metric function +import Function.Metric.Rational --- Bundles for metrics over ℕ -import Function.Metric.Nat.Bundles +-- Bundles for metrics over ℚ +import Function.Metric.Rational.Bundles --- Core definitions for metrics over ℕ -import Function.Metric.Nat.Definitions +-- Core definitions for metrics over ℚ +import Function.Metric.Rational.Definitions --- Core definitions for metrics over ℕ -import Function.Metric.Nat.Structures +-- Core definitions for metrics over ℚ +import Function.Metric.Rational.Structures --- Metrics with ℚ as the codomain of the metric function -import Function.Metric.Rational +-- Some metric structures (not packed up with sets, operations, etc.) +import Function.Metric.Structures --- Bundles for metrics over ℚ -import Function.Metric.Rational.Bundles +-- Heterogeneous N-ary Functions +import Function.Nary.NonDependent --- Core definitions for metrics over ℚ -import Function.Metric.Rational.Definitions +-- Heterogeneous N-ary Functions: basic types and operations +import Function.Nary.NonDependent.Base --- Core definitions for metrics over ℚ -import Function.Metric.Rational.Structures +-- Basic properties of the function type +import Function.Properties --- Some metric structures (not packed up with sets, operations, etc.) -import Function.Metric.Structures +-- Some basic properties of bijections. +import Function.Properties.Bijection --- Heterogeneous N-ary Functions -import Function.Nary.NonDependent +-- Some basic properties of equivalences. This file is designed to be +-- imported qualified. +import Function.Properties.Equivalence --- Heterogeneous N-ary Functions: basic types and operations -import Function.Nary.NonDependent.Base +-- Properties for injections +import Function.Properties.Injection --- Basic properties of the function type -import Function.Properties +-- Properties of inverses. +import Function.Properties.Inverse --- Some basic properties of bijections. -import Function.Properties.Bijection +-- Half adjoint equivalences +import Function.Properties.Inverse.HalfAdjointEquivalence --- Some basic properties of equivalences. This file is designed to be --- imported qualified. -import Function.Properties.Equivalence +-- Properties of right inverses +import Function.Properties.RightInverse --- Properties for injections -import Function.Properties.Injection +-- Properties of surjections +import Function.Properties.Surjection --- Properties of inverses. -import Function.Properties.Inverse +-- A module used for creating function pipelines, see +-- README.Function.Reasoning for examples +import Function.Reasoning --- Half adjoint equivalences -import Function.Properties.Inverse.HalfAdjointEquivalence +-- Relatedness for the function hierarchy +import Function.Related.Propositional --- Properties of right inverses -import Function.Properties.RightInverse +-- Basic lemmas showing that various types are related (isomorphic or +-- equivalent or…) +import Function.Related.TypeIsomorphisms --- Properties of surjections -import Function.Properties.Surjection +-- Automatic solver for equations over product and sum types +import Function.Related.TypeIsomorphisms.Solver --- A module used for creating function pipelines, see --- README.Function.Reasoning for examples -import Function.Reasoning +-- Function Equality setoid +import Function.Relation.Binary.Setoid.Equality --- Relatedness for the function hierarchy -import Function.Related.Propositional +-- Strict combinators (i.e. that use call-by-value) +import Function.Strict --- Basic lemmas showing that various types are related (isomorphic or --- equivalent or…) -import Function.Related.TypeIsomorphisms +-- Structures for types of functions +import Function.Structures --- Automatic solver for equations over product and sum types -import Function.Related.TypeIsomorphisms.Solver +-- Ways to give instances of certain structures where some fields can +-- be given in terms of others. +-- The contents of this file should usually be accessed from `Function`. +import Function.Structures.Biased --- Function Equality setoid -import Function.Relation.Binary.Setoid.Equality +-- An abstraction of various forms of recursion/induction +import Induction --- Strict combinators (i.e. that use call-by-value) -import Function.Strict +-- A standard consequence of accessibility/well-foundedness: +-- the impossibility of 'infinite descent' from any (accessible) +-- element x satisfying P to 'smaller' y also satisfying P +import Induction.InfiniteDescent --- Structures for types of functions -import Function.Structures +-- Lexicographic induction +import Induction.Lexicographic --- Ways to give instances of certain structures where some fields can --- be given in terms of others. --- The contents of this file should usually be accessed from `Function`. -import Function.Structures.Biased +-- Well-founded induction +import Induction.WellFounded --- An abstraction of various forms of recursion/induction -import Induction +-- Universe levels +import Level --- A standard consequence of accessibility/well-foundedness: --- the impossibility of 'infinite descent' from any (accessible) --- element x satisfying P to 'smaller' y also satisfying P -import Induction.InfiniteDescent +-- Conversion from naturals to universe levels +import Level.Literals --- Lexicographic induction -import Induction.Lexicographic +-- Support for reflection +import Reflection --- Well-founded induction -import Induction.WellFounded +-- The reflected abstract syntax tree +import Reflection.AST --- Universe levels -import Level +-- Abstractions used in the reflection machinery +import Reflection.AST.Abstraction --- Conversion from naturals to universe levels -import Level.Literals +-- Alpha equality over terms +import Reflection.AST.AlphaEquality --- Support for reflection -import Reflection +-- Arguments used in the reflection machinery +import Reflection.AST.Argument --- The reflected abstract syntax tree -import Reflection.AST +-- Argument information used in the reflection machinery +import Reflection.AST.Argument.Information --- Abstractions used in the reflection machinery -import Reflection.AST.Abstraction +-- Modalities used in the reflection machinery +import Reflection.AST.Argument.Modality --- Alpha equality over terms -import Reflection.AST.AlphaEquality +-- Argument quantities used in the reflection machinery +import Reflection.AST.Argument.Quantity --- Arguments used in the reflection machinery -import Reflection.AST.Argument +-- Argument relevance used in the reflection machinery +import Reflection.AST.Argument.Relevance --- Argument information used in the reflection machinery -import Reflection.AST.Argument.Information +-- Argument visibility used in the reflection machinery +import Reflection.AST.Argument.Visibility --- Modalities used in the reflection machinery -import Reflection.AST.Argument.Modality +-- Weakening, strengthening and free variable check for reflected terms. +import Reflection.AST.DeBruijn --- Argument quantities used in the reflection machinery -import Reflection.AST.Argument.Quantity +-- Definitions used in the reflection machinery +import Reflection.AST.Definition --- Argument relevance used in the reflection machinery -import Reflection.AST.Argument.Relevance +-- Instances for reflected syntax +import Reflection.AST.Instances --- Argument visibility used in the reflection machinery -import Reflection.AST.Argument.Visibility +-- Literals used in the reflection machinery +import Reflection.AST.Literal --- Weakening, strengthening and free variable check for reflected terms. -import Reflection.AST.DeBruijn +-- Metavariables used in the reflection machinery +import Reflection.AST.Meta --- Definitions used in the reflection machinery -import Reflection.AST.Definition +-- Names used in the reflection machinery +import Reflection.AST.Name --- Instances for reflected syntax -import Reflection.AST.Instances +-- Patterns used in the reflection machinery +import Reflection.AST.Pattern --- Literals used in the reflection machinery -import Reflection.AST.Literal +-- Converting reflection machinery to strings +import Reflection.AST.Show --- Metavariables used in the reflection machinery -import Reflection.AST.Meta +-- Terms used in the reflection machinery +import Reflection.AST.Term --- Names used in the reflection machinery -import Reflection.AST.Name +-- de Bruijn-aware generic traversal of reflected terms. +import Reflection.AST.Traversal --- Patterns used in the reflection machinery -import Reflection.AST.Pattern +-- A universe for the types involved in the reflected syntax. +import Reflection.AST.Universe --- Converting reflection machinery to strings -import Reflection.AST.Show +-- Annotated reflected syntax. +import Reflection.AnnotatedAST --- Terms used in the reflection machinery -import Reflection.AST.Term +-- Computing free variable annotations on reflected syntax. +import Reflection.AnnotatedAST.Free --- de Bruijn-aware generic traversal of reflected terms. -import Reflection.AST.Traversal +-- Support for system calls as part of reflection +import Reflection.External --- A universe for the types involved in the reflected syntax. -import Reflection.AST.Universe +-- The TC (Type Checking) monad +import Reflection.TCM --- Annotated reflected syntax. -import Reflection.AnnotatedAST +-- Typeclass instances for TC +import Reflection.TCM.Effectful --- Computing free variable annotations on reflected syntax. -import Reflection.AnnotatedAST.Free +-- Printf-style versions of typeError and debugPrint +import Reflection.TCM.Format --- Support for system calls as part of reflection -import Reflection.External +-- Typeclass instances for TC +import Reflection.TCM.Instances --- The TC (Type Checking) monad -import Reflection.TCM +-- Monad syntax for the TC monad +import Reflection.TCM.Syntax --- Typeclass instances for TC -import Reflection.TCM.Effectful +-- Reflection utilities +import Reflection.TCM.Utilities --- Printf-style versions of typeError and debugPrint -import Reflection.TCM.Format +-- Properties of homogeneous binary relations +import Relation.Binary --- Typeclass instances for TC -import Reflection.TCM.Instances +-- Bundles for homogeneous binary relations +import Relation.Binary.Bundles --- Monad syntax for the TC monad -import Reflection.TCM.Syntax +-- Raw bundles for homogeneous binary relations +import Relation.Binary.Bundles.Raw --- Reflection utilities -import Reflection.TCM.Utilities +-- Some properties imply others +import Relation.Binary.Consequences --- Properties of homogeneous binary relations -import Relation.Binary +-- A pointwise lifting of a relation to incorporate new extrema. +import Relation.Binary.Construct.Add.Extrema.Equality --- Bundles for homogeneous binary relations -import Relation.Binary.Bundles +-- The lifting of a non-strict order to incorporate new extrema +import Relation.Binary.Construct.Add.Extrema.NonStrict --- Raw bundles for homogeneous binary relations -import Relation.Binary.Bundles.Raw +-- The lifting of a strict order to incorporate new extrema +import Relation.Binary.Construct.Add.Extrema.Strict --- Some properties imply others -import Relation.Binary.Consequences +-- A pointwise lifting of a relation to incorporate a new infimum. +import Relation.Binary.Construct.Add.Infimum.Equality --- A pointwise lifting of a relation to incorporate new extrema. -import Relation.Binary.Construct.Add.Extrema.Equality +-- The lifting of a non-strict order to incorporate a new infimum +import Relation.Binary.Construct.Add.Infimum.NonStrict --- The lifting of a non-strict order to incorporate new extrema -import Relation.Binary.Construct.Add.Extrema.NonStrict +-- The lifting of a strict order to incorporate a new infimum +import Relation.Binary.Construct.Add.Infimum.Strict --- The lifting of a strict order to incorporate new extrema -import Relation.Binary.Construct.Add.Extrema.Strict +-- A pointwise lifting of a relation to incorporate an additional point. +import Relation.Binary.Construct.Add.Point.Equality --- A pointwise lifting of a relation to incorporate a new infimum. -import Relation.Binary.Construct.Add.Infimum.Equality +-- A pointwise lifting of a relation to incorporate a new supremum. +import Relation.Binary.Construct.Add.Supremum.Equality --- The lifting of a non-strict order to incorporate a new infimum -import Relation.Binary.Construct.Add.Infimum.NonStrict +-- The lifting of a non-strict order to incorporate a new supremum +import Relation.Binary.Construct.Add.Supremum.NonStrict --- The lifting of a strict order to incorporate a new infimum -import Relation.Binary.Construct.Add.Infimum.Strict +-- The lifting of a strict order to incorporate a new supremum +import Relation.Binary.Construct.Add.Supremum.Strict --- A pointwise lifting of a relation to incorporate an additional point. -import Relation.Binary.Construct.Add.Point.Equality +-- The universal binary relation +import Relation.Binary.Construct.Always --- A pointwise lifting of a relation to incorporate a new supremum. -import Relation.Binary.Construct.Add.Supremum.Equality +-- The reflexive, symmetric and transitive closure of a binary +-- relation (aka the equivalence closure). +import Relation.Binary.Construct.Closure.Equivalence --- The lifting of a non-strict order to incorporate a new supremum -import Relation.Binary.Construct.Add.Supremum.NonStrict +-- Some properties of equivalence closures. +import Relation.Binary.Construct.Closure.Equivalence.Properties --- The lifting of a strict order to incorporate a new supremum -import Relation.Binary.Construct.Add.Supremum.Strict +-- Reflexive closures +import Relation.Binary.Construct.Closure.Reflexive --- The universal binary relation -import Relation.Binary.Construct.Always +-- Some properties of reflexive closures +import Relation.Binary.Construct.Closure.Reflexive.Properties --- The reflexive, symmetric and transitive closure of a binary --- relation (aka the equivalence closure). -import Relation.Binary.Construct.Closure.Equivalence +-- Some properties of reflexive closures which rely on the K rule +import Relation.Binary.Construct.Closure.Reflexive.Properties.WithK --- Some properties of equivalence closures. -import Relation.Binary.Construct.Closure.Equivalence.Properties +-- The reflexive transitive closures of McBride, Norell and Jansson +import Relation.Binary.Construct.Closure.ReflexiveTransitive --- Reflexive closures -import Relation.Binary.Construct.Closure.Reflexive +-- Some properties of reflexive transitive closures. +import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties --- Some properties of reflexive closures -import Relation.Binary.Construct.Closure.Reflexive.Properties +-- Properties, related to reflexive transitive closures, that rely on +-- the K rule +import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties.WithK --- Some properties of reflexive closures which rely on the K rule -import Relation.Binary.Construct.Closure.Reflexive.Properties.WithK +-- Symmetric closures of binary relations +import Relation.Binary.Construct.Closure.Symmetric --- The reflexive transitive closures of McBride, Norell and Jansson -import Relation.Binary.Construct.Closure.ReflexiveTransitive +-- Symmetric transitive closures of binary relations +import Relation.Binary.Construct.Closure.SymmetricTransitive --- Some properties of reflexive transitive closures. -import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties +-- Transitive closures +import Relation.Binary.Construct.Closure.Transitive --- Properties, related to reflexive transitive closures, that rely on --- the K rule -import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties.WithK +-- Some code related to transitive closures that relies on the K rule +import Relation.Binary.Construct.Closure.Transitive.WithK --- Symmetric closures of binary relations -import Relation.Binary.Construct.Closure.Symmetric +-- Composition of two binary relations +import Relation.Binary.Construct.Composition --- Symmetric transitive closures of binary relations -import Relation.Binary.Construct.Closure.SymmetricTransitive +-- The binary relation defined by a constant +import Relation.Binary.Construct.Constant --- Transitive closures -import Relation.Binary.Construct.Closure.Transitive +-- Many properties which hold for `∼` also hold for `flip ∼`. Unlike +-- the module `Relation.Binary.Construct.Flip.Ord` this module does not +-- flip the underlying equality. +import Relation.Binary.Construct.Flip.EqAndOrd --- Some code related to transitive closures that relies on the K rule -import Relation.Binary.Construct.Closure.Transitive.WithK +-- Many properties which hold for `∼` also hold for `flip ∼`. Unlike +-- the module `Relation.Binary.Construct.Flip.EqAndOrd` this module +-- flips both the relation and the underlying equality. +import Relation.Binary.Construct.Flip.Ord --- Composition of two binary relations -import Relation.Binary.Construct.Composition +-- Every respectful unary relation induces a preorder. No claim is +-- made that this preorder is unique. +import Relation.Binary.Construct.FromPred --- The binary relation defined by a constant -import Relation.Binary.Construct.Constant +-- Every respectful binary relation induces a preorder. No claim is +-- made that this preorder is unique. +import Relation.Binary.Construct.FromRel --- Many properties which hold for `∼` also hold for `flip ∼`. Unlike --- the module `Relation.Binary.Construct.Flip.Ord` this module does not --- flip the underlying equality. -import Relation.Binary.Construct.Flip.EqAndOrd +-- Symmetric interior of a binary relation +import Relation.Binary.Construct.Interior.Symmetric --- Many properties which hold for `∼` also hold for `flip ∼`. Unlike --- the module `Relation.Binary.Construct.Flip.EqAndOrd` this module --- flips both the relation and the underlying equality. -import Relation.Binary.Construct.Flip.Ord +-- Intersection of two binary relations +import Relation.Binary.Construct.Intersection --- Every respectful unary relation induces a preorder. No claim is --- made that this preorder is unique. -import Relation.Binary.Construct.FromPred +-- Conversion of binary operators to binary relations via the left +-- natural order. +import Relation.Binary.Construct.NaturalOrder.Left --- Every respectful binary relation induces a preorder. No claim is --- made that this preorder is unique. -import Relation.Binary.Construct.FromRel +-- Conversion of binary operators to binary relations via the right +-- natural order. +import Relation.Binary.Construct.NaturalOrder.Right --- Symmetric interior of a binary relation -import Relation.Binary.Construct.Interior.Symmetric +-- The empty binary relation +import Relation.Binary.Construct.Never --- Intersection of two binary relations -import Relation.Binary.Construct.Intersection +-- Conversion of _≤_ to _<_ +import Relation.Binary.Construct.NonStrictToStrict --- Conversion of binary operators to binary relations via the left --- natural order. -import Relation.Binary.Construct.NaturalOrder.Left +-- Many properties which hold for `_∼_` also hold for `_∼_ on f` +import Relation.Binary.Construct.On --- Conversion of binary operators to binary relations via the right --- natural order. -import Relation.Binary.Construct.NaturalOrder.Right +-- Conversion of < to ≤, along with a number of properties +import Relation.Binary.Construct.StrictToNonStrict --- The empty binary relation -import Relation.Binary.Construct.Never +-- Substituting equalities for binary relations +import Relation.Binary.Construct.Subst.Equality --- Conversion of _≤_ to _<_ -import Relation.Binary.Construct.NonStrictToStrict +-- Union of two binary relations +import Relation.Binary.Construct.Union --- Many properties which hold for `_∼_` also hold for `_∼_ on f` -import Relation.Binary.Construct.On +-- Properties of binary relations +import Relation.Binary.Definitions --- Conversion of < to ≤, along with a number of properties -import Relation.Binary.Construct.StrictToNonStrict +-- Heterogeneous equality +import Relation.Binary.HeterogeneousEquality --- Substituting equalities for binary relations -import Relation.Binary.Construct.Subst.Equality +-- Quotients for Heterogeneous equality +import Relation.Binary.HeterogeneousEquality.Quotients --- Union of two binary relations -import Relation.Binary.Construct.Union +-- Example of a Quotient: ℤ as (ℕ × ℕ / ∼) +import Relation.Binary.HeterogeneousEquality.Quotients.Examples --- Properties of binary relations -import Relation.Binary.Definitions +-- Heterogeneously-indexed binary relations +import Relation.Binary.Indexed.Heterogeneous --- Heterogeneous equality -import Relation.Binary.HeterogeneousEquality +-- Indexed binary relations +import Relation.Binary.Indexed.Heterogeneous.Bundles --- Quotients for Heterogeneous equality -import Relation.Binary.HeterogeneousEquality.Quotients +-- Instantiates indexed binary structures at an index to the equivalent +-- non-indexed structures. +import Relation.Binary.Indexed.Heterogeneous.Construct.At --- Example of a Quotient: ℤ as (ℕ × ℕ / ∼) -import Relation.Binary.HeterogeneousEquality.Quotients.Examples +-- Creates trivially indexed records from their non-indexed counterpart. +import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial --- Heterogeneously-indexed binary relations -import Relation.Binary.Indexed.Heterogeneous +-- Indexed binary relations +import Relation.Binary.Indexed.Heterogeneous.Definitions --- Indexed binary relations -import Relation.Binary.Indexed.Heterogeneous.Bundles +-- Indexed binary relations +import Relation.Binary.Indexed.Heterogeneous.Structures --- Instantiates indexed binary structures at an index to the equivalent --- non-indexed structures. -import Relation.Binary.Indexed.Heterogeneous.Construct.At +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous --- Creates trivially indexed records from their non-indexed counterpart. -import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous.Bundles --- Indexed binary relations -import Relation.Binary.Indexed.Heterogeneous.Definitions +-- Instantiating homogeneously indexed bundles at a particular index +import Relation.Binary.Indexed.Homogeneous.Construct.At --- Indexed binary relations -import Relation.Binary.Indexed.Heterogeneous.Structures +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous.Definitions --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous +-- Homogeneously-indexed binary relations +import Relation.Binary.Indexed.Homogeneous.Structures --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous.Bundles +-- Order-theoretic lattices +import Relation.Binary.Lattice --- Instantiating homogeneously indexed bundles at a particular index -import Relation.Binary.Indexed.Homogeneous.Construct.At +-- Bundles for order-theoretic lattices +import Relation.Binary.Lattice.Bundles --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous.Definitions +-- Definitions for order-theoretic lattices +import Relation.Binary.Lattice.Definitions --- Homogeneously-indexed binary relations -import Relation.Binary.Indexed.Homogeneous.Structures +-- Properties satisfied by bounded join semilattices +import Relation.Binary.Lattice.Properties.BoundedJoinSemilattice --- Order-theoretic lattices -import Relation.Binary.Lattice +-- Properties satisfied by bounded lattice +import Relation.Binary.Lattice.Properties.BoundedLattice --- Bundles for order-theoretic lattices -import Relation.Binary.Lattice.Bundles +-- Properties satisfied by bounded meet semilattices +import Relation.Binary.Lattice.Properties.BoundedMeetSemilattice --- Definitions for order-theoretic lattices -import Relation.Binary.Lattice.Definitions +-- Properties for distributive lattice +import Relation.Binary.Lattice.Properties.DistributiveLattice --- Properties satisfied by bounded join semilattices -import Relation.Binary.Lattice.Properties.BoundedJoinSemilattice +-- Properties satisfied by Heyting Algebra +import Relation.Binary.Lattice.Properties.HeytingAlgebra --- Properties satisfied by bounded lattice -import Relation.Binary.Lattice.Properties.BoundedLattice +-- Properties satisfied by join semilattices +import Relation.Binary.Lattice.Properties.JoinSemilattice --- Properties satisfied by bounded meet semilattices -import Relation.Binary.Lattice.Properties.BoundedMeetSemilattice +-- Properties satisfied by lattices +import Relation.Binary.Lattice.Properties.Lattice --- Properties for distributive lattice -import Relation.Binary.Lattice.Properties.DistributiveLattice +-- Properties satisfied by meet semilattices +import Relation.Binary.Lattice.Properties.MeetSemilattice --- Properties satisfied by Heyting Algebra -import Relation.Binary.Lattice.Properties.HeytingAlgebra +-- Structures for order-theoretic lattices +import Relation.Binary.Lattice.Structures --- Properties satisfied by join semilattices -import Relation.Binary.Lattice.Properties.JoinSemilattice +-- Order morphisms +import Relation.Binary.Morphism --- Properties satisfied by lattices -import Relation.Binary.Lattice.Properties.Lattice +-- Bundles for morphisms between binary relations +import Relation.Binary.Morphism.Bundles --- Properties satisfied by meet semilattices -import Relation.Binary.Lattice.Properties.MeetSemilattice +-- The composition of morphisms between binary relations +import Relation.Binary.Morphism.Construct.Composition --- Structures for order-theoretic lattices -import Relation.Binary.Lattice.Structures +-- Constant morphisms between binary relations +import Relation.Binary.Morphism.Construct.Constant --- Order morphisms -import Relation.Binary.Morphism +-- The identity morphism for binary relations +import Relation.Binary.Morphism.Construct.Identity --- Bundles for morphisms between binary relations -import Relation.Binary.Morphism.Bundles +-- The projection morphisms for relational structures arising from the +-- non-dependent product construction +import Relation.Binary.Morphism.Construct.Product --- The composition of morphisms between binary relations -import Relation.Binary.Morphism.Construct.Composition +-- Basic definitions for morphisms between algebraic structures +import Relation.Binary.Morphism.Definitions --- Constant morphisms between binary relations -import Relation.Binary.Morphism.Construct.Constant +-- Consequences of a monomorphism between orders +import Relation.Binary.Morphism.OrderMonomorphism --- The identity morphism for binary relations -import Relation.Binary.Morphism.Construct.Identity +-- Consequences of a monomorphism between binary relations +import Relation.Binary.Morphism.RelMonomorphism --- The projection morphisms for relational structures arising from the --- non-dependent product construction -import Relation.Binary.Morphism.Construct.Product +-- Order morphisms +import Relation.Binary.Morphism.Structures --- Basic definitions for morphisms between algebraic structures -import Relation.Binary.Morphism.Definitions +-- Apartness properties +import Relation.Binary.Properties.ApartnessRelation --- Consequences of a monomorphism between orders -import Relation.Binary.Morphism.OrderMonomorphism +-- Every decidable setoid induces tight apartness relation. +import Relation.Binary.Properties.DecSetoid --- Consequences of a monomorphism between binary relations -import Relation.Binary.Morphism.RelMonomorphism +-- Properties satisfied by decidable total orders +import Relation.Binary.Properties.DecTotalOrder --- Order morphisms -import Relation.Binary.Morphism.Structures +-- Additional properties for setoids +import Relation.Binary.Properties.PartialSetoid --- Apartness properties -import Relation.Binary.Properties.ApartnessRelation +-- Properties satisfied by posets +import Relation.Binary.Properties.Poset --- Every decidable setoid induces tight apartness relation. -import Relation.Binary.Properties.DecSetoid +-- Properties satisfied by preorders +import Relation.Binary.Properties.Preorder --- Properties satisfied by decidable total orders -import Relation.Binary.Properties.DecTotalOrder +-- Additional properties for setoids +import Relation.Binary.Properties.Setoid --- Additional properties for setoids -import Relation.Binary.Properties.PartialSetoid +-- Properties satisfied by strict partial orders +import Relation.Binary.Properties.StrictPartialOrder --- Properties satisfied by posets -import Relation.Binary.Properties.Poset +-- Properties satisfied by strict partial orders +import Relation.Binary.Properties.StrictTotalOrder --- Properties satisfied by preorders -import Relation.Binary.Properties.Preorder +-- Properties satisfied by total orders +import Relation.Binary.Properties.TotalOrder --- Additional properties for setoids -import Relation.Binary.Properties.Setoid +-- Propositional (intensional) equality +import Relation.Binary.PropositionalEquality --- Properties satisfied by strict partial orders -import Relation.Binary.Properties.StrictPartialOrder +-- Propositional (intensional) equality - Algebraic structures +import Relation.Binary.PropositionalEquality.Algebra --- Properties satisfied by strict partial orders -import Relation.Binary.Properties.StrictTotalOrder +-- Propositional equality +import Relation.Binary.PropositionalEquality.Properties --- Properties satisfied by total orders -import Relation.Binary.Properties.TotalOrder +-- Some code related to propositional equality that relies on the K +-- rule +import Relation.Binary.PropositionalEquality.WithK --- Propositional (intensional) equality -import Relation.Binary.PropositionalEquality +-- The basic code for equational reasoning with three relations: +-- equality and apartness +import Relation.Binary.Reasoning.Base.Apartness --- Propositional (intensional) equality - Algebraic structures -import Relation.Binary.PropositionalEquality.Algebra +-- The basic code for equational reasoning with two relations: +-- equality and some other ordering. +import Relation.Binary.Reasoning.Base.Double --- Propositional equality -import Relation.Binary.PropositionalEquality.Properties +-- The basic code for equational reasoning with a non-reflexive relation +import Relation.Binary.Reasoning.Base.Partial --- Some code related to propositional equality that relies on the K --- rule -import Relation.Binary.PropositionalEquality.WithK +-- The basic code for equational reasoning with a single relation +import Relation.Binary.Reasoning.Base.Single --- The basic code for equational reasoning with three relations: --- equality and apartness -import Relation.Binary.Reasoning.Base.Apartness +-- The basic code for equational reasoning with three relations: +-- equality, strict ordering and non-strict ordering. +import Relation.Binary.Reasoning.Base.Triple --- The basic code for equational reasoning with two relations: --- equality and some other ordering. -import Relation.Binary.Reasoning.Base.Double +-- Convenient syntax for "equational reasoning" in multiple Setoids. +import Relation.Binary.Reasoning.MultiSetoid --- The basic code for equational reasoning with a non-reflexive relation -import Relation.Binary.Reasoning.Base.Partial +-- Convenient syntax for "equational reasoning" using a partial order +import Relation.Binary.Reasoning.PartialOrder --- The basic code for equational reasoning with a single relation -import Relation.Binary.Reasoning.Base.Single +-- Convenient syntax for reasoning with a partial setoid +import Relation.Binary.Reasoning.PartialSetoid --- The basic code for equational reasoning with three relations: --- equality, strict ordering and non-strict ordering. -import Relation.Binary.Reasoning.Base.Triple +-- Convenient syntax for "equational reasoning" using a preorder +import Relation.Binary.Reasoning.Preorder --- Convenient syntax for "equational reasoning" in multiple Setoids. -import Relation.Binary.Reasoning.MultiSetoid +-- Convenient syntax for reasoning with a setoid +import Relation.Binary.Reasoning.Setoid --- Convenient syntax for "equational reasoning" using a partial order -import Relation.Binary.Reasoning.PartialOrder +-- Convenient syntax for "equational reasoning" using a strict partial +-- order. +import Relation.Binary.Reasoning.StrictPartialOrder --- Convenient syntax for reasoning with a partial setoid -import Relation.Binary.Reasoning.PartialSetoid +-- Syntax for the building blocks of equational reasoning modules +import Relation.Binary.Reasoning.Syntax --- Convenient syntax for "equational reasoning" using a preorder -import Relation.Binary.Reasoning.Preorder +-- Helpers intended to ease the development of "tactics" which use +-- proof by reflection +import Relation.Binary.Reflection --- Convenient syntax for reasoning with a setoid -import Relation.Binary.Reasoning.Setoid +-- Concepts from rewriting theory +-- Definitions are based on "Term Rewriting Systems" by J.W. Klop +import Relation.Binary.Rewriting --- Convenient syntax for "equational reasoning" using a strict partial --- order. -import Relation.Binary.Reasoning.StrictPartialOrder +-- Structures for homogeneous binary relations +import Relation.Binary.Structures --- Syntax for the building blocks of equational reasoning modules -import Relation.Binary.Reasoning.Syntax +-- Ways to give instances of certain structures where some fields can +-- be given in terms of others +import Relation.Binary.Structures.Biased --- Helpers intended to ease the development of "tactics" which use --- proof by reflection -import Relation.Binary.Reflection +-- Typeclasses for use with instance arguments +import Relation.Binary.TypeClasses --- Concepts from rewriting theory --- Definitions are based on "Term Rewriting Systems" by J.W. Klop -import Relation.Binary.Rewriting +-- Heterogeneous N-ary Relations +import Relation.Nary --- Structures for homogeneous binary relations -import Relation.Binary.Structures +-- Operations on nullary relations (like negation and decidability) +import Relation.Nullary --- Ways to give instances of certain structures where some fields can --- be given in terms of others -import Relation.Binary.Structures.Biased +-- Notation for freely adding extrema to any set +import Relation.Nullary.Construct.Add.Extrema --- Typeclasses for use with instance arguments -import Relation.Binary.TypeClasses +-- Notation for freely adding an infimum to any set +import Relation.Nullary.Construct.Add.Infimum --- Heterogeneous N-ary Relations -import Relation.Nary +-- Notation for adding an additional point to any set +import Relation.Nullary.Construct.Add.Point --- Operations on nullary relations (like negation and decidability) -import Relation.Nullary +-- Notation for freely adding a supremum to any set +import Relation.Nullary.Construct.Add.Supremum --- Notation for freely adding extrema to any set -import Relation.Nullary.Construct.Add.Extrema +-- Operations on and properties of decidable relations +import Relation.Nullary.Decidable --- Notation for freely adding an infimum to any set -import Relation.Nullary.Construct.Add.Infimum +-- Negation indexed by a Level +import Relation.Nullary.Indexed --- Notation for adding an additional point to any set -import Relation.Nullary.Construct.Add.Point +-- Properties of indexed negation +import Relation.Nullary.Indexed.Negation --- Notation for freely adding a supremum to any set -import Relation.Nullary.Construct.Add.Supremum +-- A type `A` is irrelevant if all of its elements are equal. +-- This is also refered to as "A is an h-proposition". +import Relation.Nullary.Irrelevant --- Operations on and properties of decidable relations -import Relation.Nullary.Decidable +-- Properties related to negation +import Relation.Nullary.Negation --- Negation indexed by a Level -import Relation.Nullary.Indexed +-- Recomputable types and their algebra as Harrop formulas +import Relation.Nullary.Recomputable --- Properties of indexed negation -import Relation.Nullary.Indexed.Negation +-- Properties of the `Reflects` construct +import Relation.Nullary.Reflects --- A type `A` is irrelevant if all of its elements are equal. --- This is also refered to as "A is an h-proposition". -import Relation.Nullary.Irrelevant +-- A universe of proposition functors, along with some properties +import Relation.Nullary.Universe --- Properties related to negation -import Relation.Nullary.Negation +-- Unary relations +import Relation.Unary --- Recomputable types and their algebra as Harrop formulas -import Relation.Nullary.Recomputable +-- Algebraic properties of constructions over unary relations +import Relation.Unary.Algebra --- Properties of the `Reflects` construct -import Relation.Nullary.Reflects +-- Closures of a unary relation with respect to a binary one. +import Relation.Unary.Closure.Base --- A universe of proposition functors, along with some properties -import Relation.Nullary.Universe +-- Closure of a unary relation with respect to a preorder +import Relation.Unary.Closure.Preorder --- Unary relations -import Relation.Unary +-- Closures of a unary relation with respect to a strict partial order +import Relation.Unary.Closure.StrictPartialOrder --- Algebraic properties of constructions over unary relations -import Relation.Unary.Algebra +-- Some properties imply others +import Relation.Unary.Consequences --- Closures of a unary relation with respect to a binary one. -import Relation.Unary.Closure.Base +-- Indexed unary relations +import Relation.Unary.Indexed --- Closure of a unary relation with respect to a preorder -import Relation.Unary.Closure.Preorder +-- Polymorphic versions of standard definitions in Relation.Unary +import Relation.Unary.Polymorphic --- Closures of a unary relation with respect to a strict partial order -import Relation.Unary.Closure.StrictPartialOrder +-- Properties of polymorphic versions of standard definitions in +-- Relation.Unary +import Relation.Unary.Polymorphic.Properties --- Some properties imply others -import Relation.Unary.Consequences +-- Predicate transformers +import Relation.Unary.PredicateTransformer --- Indexed unary relations -import Relation.Unary.Indexed +-- Properties of constructions over unary relations +import Relation.Unary.Properties --- Polymorphic versions of standard definitions in Relation.Unary -import Relation.Unary.Polymorphic +-- Equality of unary relations +import Relation.Unary.Relation.Binary.Equality --- Properties of polymorphic versions of standard definitions in --- Relation.Unary -import Relation.Unary.Polymorphic.Properties +-- Order properties of the subset relations _⊆_ and _⊂_ +import Relation.Unary.Relation.Binary.Subset --- Predicate transformers -import Relation.Unary.PredicateTransformer +-- ANSI escape codes +import System.Console.ANSI --- Properties of constructions over unary relations -import Relation.Unary.Properties +-- A simple tactic for used to automatically compute the function +-- argument to cong. +import Tactic.Cong --- Equality of unary relations -import Relation.Unary.Relation.Binary.Equality +-- Reflection-based solver for monoid equalities +import Tactic.MonoidSolver --- Order properties of the subset relations _⊆_ and _⊂_ -import Relation.Unary.Relation.Binary.Subset +-- A solver that uses reflection to automatically obtain and solve +-- equations over rings. +import Tactic.RingSolver --- ANSI escape codes -import System.Console.ANSI +-- Almost commutative rings +import Tactic.RingSolver.Core.AlmostCommutativeRing --- A simple tactic for used to automatically compute the function --- argument to cong. -import Tactic.Cong +-- A type for expressions over a raw ring. +import Tactic.RingSolver.Core.Expression --- Reflection-based solver for monoid equalities -import Tactic.MonoidSolver +-- Simple implementation of sets of ℕ. +import Tactic.RingSolver.Core.NatSet --- A solver that uses reflection to automatically obtain and solve --- equations over rings. -import Tactic.RingSolver +-- Sparse polynomials in a commutative ring, encoded in Horner normal +-- form. +import Tactic.RingSolver.Core.Polynomial.Base --- Almost commutative rings -import Tactic.RingSolver.Core.AlmostCommutativeRing +-- Some specialised instances of the ring solver +import Tactic.RingSolver.Core.Polynomial.Homomorphism --- A type for expressions over a raw ring. -import Tactic.RingSolver.Core.Expression +-- Homomorphism proofs for addition over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition --- Simple implementation of sets of ℕ. -import Tactic.RingSolver.Core.NatSet +-- Homomorphism proofs for constants over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Constants --- Sparse polynomials in a commutative ring, encoded in Horner normal --- form. -import Tactic.RingSolver.Core.Polynomial.Base +-- Homomorphism proofs for exponentiation over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation --- Some specialised instances of the ring solver -import Tactic.RingSolver.Core.Polynomial.Homomorphism +-- Lemmas for use in proving the polynomial homomorphism. +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas --- Homomorphism proofs for addition over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition +-- Homomorphism proofs for multiplication over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication --- Homomorphism proofs for constants over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Constants +-- Homomorphism proofs for negation over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation --- Homomorphism proofs for exponentiation over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation +-- Homomorphism proofs for variables and constants over polynomials +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables --- Lemmas for use in proving the polynomial homomorphism. -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas +-- Bundles of parameters for passing to the Ring Solver +import Tactic.RingSolver.Core.Polynomial.Parameters --- Homomorphism proofs for multiplication over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication +-- Polynomial reasoning +import Tactic.RingSolver.Core.Polynomial.Reasoning --- Homomorphism proofs for negation over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation +-- "Evaluating" a polynomial, using Horner's method. +import Tactic.RingSolver.Core.Polynomial.Semantics --- Homomorphism proofs for variables and constants over polynomials -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables +-- An implementation of the ring solver that requires you to manually +-- pass the equation you wish to solve. +import Tactic.RingSolver.NonReflective --- Bundles of parameters for passing to the Ring Solver -import Tactic.RingSolver.Core.Polynomial.Parameters +-- Format strings for Printf and Scanf +import Text.Format --- Polynomial reasoning -import Tactic.RingSolver.Core.Polynomial.Reasoning +-- Format strings for Printf and Scanf +import Text.Format.Generic --- "Evaluating" a polynomial, using Horner's method. -import Tactic.RingSolver.Core.Polynomial.Semantics +-- Printf +import Text.Printf --- An implementation of the ring solver that requires you to manually --- pass the equation you wish to solve. -import Tactic.RingSolver.NonReflective +-- Generic printf function. +import Text.Printf.Generic --- Format strings for Printf and Scanf -import Text.Format +-- Regular expressions +import Text.Regex --- Format strings for Printf and Scanf -import Text.Format.Generic +-- Regular expressions: basic types and semantics +import Text.Regex.Base --- Printf -import Text.Printf +-- Regular expressions: Brzozowski derivative +import Text.Regex.Derivative.Brzozowski --- Generic printf function. -import Text.Printf.Generic +-- Properties of regular expressions and their semantics +import Text.Regex.Properties --- Regular expressions -import Text.Regex +-- Regular expressions: search algorithms +import Text.Regex.Search --- Regular expressions: basic types and semantics -import Text.Regex.Base +-- Regular expressions: smart constructors +-- Computing the Brzozowski derivative of a regular expression may lead +-- to a blow-up in the size of the expression. To keep it tractable it +-- is crucial to use smart constructors. +import Text.Regex.SmartConstructors --- Regular expressions: Brzozowski derivative -import Text.Regex.Derivative.Brzozowski +-- Regular expressions acting on strings +import Text.Regex.String --- Properties of regular expressions and their semantics -import Text.Regex.Properties +-- Fancy display functions for List-based tables +import Text.Tabular.Base --- Regular expressions: search algorithms -import Text.Regex.Search +-- Fancy display functions for List-based tables +import Text.Tabular.List --- Regular expressions: smart constructors --- Computing the Brzozowski derivative of a regular expression may lead --- to a blow-up in the size of the expression. To keep it tractable it --- is crucial to use smart constructors. -import Text.Regex.SmartConstructors - --- Regular expressions acting on strings -import Text.Regex.String - --- Fancy display functions for List-based tables -import Text.Tabular.Base - --- Fancy display functions for List-based tables -import Text.Tabular.List - --- Fancy display functions for Vec-based tables -import Text.Tabular.Vec +-- Fancy display functions for Vec-based tables +import Text.Tabular.Vec \ No newline at end of file diff --git a/v2.3/Function.Consequences.Propositional.html b/v2.3/Function.Consequences.Propositional.html index 5de42bfcd2..2fb02e3f43 100644 --- a/v2.3/Function.Consequences.Propositional.html +++ b/v2.3/Function.Consequences.Propositional.html @@ -18,7 +18,7 @@ open import Function.Definitions using (StrictlySurjective; StrictlyInverseˡ; StrictlyInverseʳ; Inverseˡ ; Inverseʳ; Surjective) -open import Relation.Nullary.Negation.Core using (contraposition) +open import Relation.Nullary.Negation.Core using (contraposition) import Function.Consequences.Setoid (setoid A) (setoid B) as Setoid diff --git a/v2.3/Function.Consequences.html b/v2.3/Function.Consequences.html index 28866ff109..28d4ffc7d2 100644 --- a/v2.3/Function.Consequences.html +++ b/v2.3/Function.Consequences.html @@ -17,7 +17,7 @@ open import Relation.Binary.Core using (Rel) open import Relation.Binary.Bundles using (Setoid) open import Relation.Binary.Definitions using (Reflexive; Symmetric; Transitive) -open import Relation.Nullary.Negation.Core using (¬_; contraposition) +open import Relation.Nullary.Negation.Core using (¬_; contraposition) private variable @@ -31,7 +31,7 @@ contraInjective : (≈₂ : Rel B ℓ₂) Injective ≈₁ ≈₂ f {x y} ¬ (≈₁ x y) ¬ (≈₂ (f x) (f y)) -contraInjective _ inj p = contraposition inj p +contraInjective _ inj p = contraposition inj p ------------------------------------------------------------------------ -- Inverseˡ diff --git a/v2.3/Function.Endo.Propositional.html b/v2.3/Function.Endo.Propositional.html index 78a12808e1..b43d621d43 100644 --- a/v2.3/Function.Endo.Propositional.html +++ b/v2.3/Function.Endo.Propositional.html @@ -18,7 +18,7 @@ using (module Definitions; IsMagmaHomomorphism; IsMonoidHomomorphism) open Definitions using (Homomorphic₂) open import Data.Nat.Base using (; zero; suc; _+_; +-rawMagma; +-0-rawMonoid) -open import Data.Nat.Properties using (+-0-monoid; +-semigroup) +open import Data.Nat.Properties using (+-0-monoid; +-semigroup) open import Data.Product.Base using (_,_) open import Function.Base using (id; _∘′_; _∋_; flip) open import Function.Bundles using (Func; _⟶ₛ_; _⟨$⟩_) diff --git a/v2.3/Function.Endo.Setoid.html b/v2.3/Function.Endo.Setoid.html index 4985e7bd2a..158b842736 100644 --- a/v2.3/Function.Endo.Setoid.html +++ b/v2.3/Function.Endo.Setoid.html @@ -20,7 +20,7 @@ using (module Definitions; IsMagmaHomomorphism; IsMonoidHomomorphism) open Definitions using (Homomorphic₂) open import Data.Nat.Base using (; zero; suc; _+_; +-rawMagma; +-0-rawMonoid) -open import Data.Nat.Properties using (+-semigroup; +-identityʳ) +open import Data.Nat.Properties using (+-semigroup; +-identityʳ) open import Data.Product.Base using (_,_) open import Function.Bundles using (Func; _⟶ₛ_; _⟨$⟩_) open import Function.Construct.Identity using () renaming (function to identity) diff --git a/v2.3/Function.Related.TypeIsomorphisms.html b/v2.3/Function.Related.TypeIsomorphisms.html index 6e5420ff15..08be105e29 100644 --- a/v2.3/Function.Related.TypeIsomorphisms.html +++ b/v2.3/Function.Related.TypeIsomorphisms.html @@ -17,7 +17,7 @@ ; Associative; _DistributesOverˡ_; _DistributesOverʳ_; _DistributesOver_) open import Algebra.Structures public using (IsMagma; IsSemigroup; IsMonoid; IsCommutativeMonoid - ; IsCommutativeSemiring) + ; IsCommutativeSemiring) open import Algebra.Structures.Biased using (isCommutativeSemiringˡ) open import Axiom.Extensionality.Propositional using (Extensionality) open import Data.Bool.Base using (true; false) @@ -257,7 +257,7 @@ } ×-⊎-isCommutativeSemiring : k - IsCommutativeSemiring (Related k ) _⊎_ _×_ + IsCommutativeSemiring (Related k ) _⊎_ _×_ ×-⊎-isCommutativeSemiring k = isCommutativeSemiringˡ record { +-isCommutativeMonoid = ⊎-isCommutativeMonoid k ; *-isCommutativeMonoid = ×-isCommutativeMonoid k diff --git a/v2.3/Induction.InfiniteDescent.html b/v2.3/Induction.InfiniteDescent.html index 03fbe7a26a..b3ddc410f0 100644 --- a/v2.3/Induction.InfiniteDescent.html +++ b/v2.3/Induction.InfiniteDescent.html @@ -75,7 +75,7 @@ sequence⁺ : InfiniteDescendingSequence (TransClosure _<_) f InfiniteDescendingSequence⁺ _<_ f -sequence⁺ {_<_ = _<_} {f = f} seq[f] = seq⁺[f]′ ℕ.<⇒<′ +sequence⁺ {_<_ = _<_} {f = f} seq[f] = seq⁺[f]′ ℕ.<⇒<′ where seq⁺[f]′ : {m n} m ℕ.<′ n TransClosure _<_ (f n) (f m) seq⁺[f]′ ℕ.<′-base = seq[f] _ @@ -83,7 +83,7 @@ sequence⁻ : InfiniteDescendingSequence⁺ _<_ f InfiniteDescendingSequence (TransClosure _<_) f -sequence⁻ seq[f] = seq[f] n<1+n +sequence⁻ seq[f] = seq[f] n<1+n ------------------------------------------------------------------------ -- Results about unrestricted descent diff --git a/v2.3/README.Data.List.Fresh.html b/v2.3/README.Data.List.Fresh.html index e5b8dafee0..392cebfb73 100644 --- a/v2.3/README.Data.List.Fresh.html +++ b/v2.3/README.Data.List.Fresh.html @@ -37,7 +37,7 @@ -- We call this new type *I*SortedList because all the proofs will be implicit. ISortedList : Set -ISortedList = List# _<?_ +ISortedList = List# _<?_ -- The same example is now much shorter. It looks pretty much like a normal list -- except that we know for sure that it is well ordered. @@ -54,7 +54,7 @@ ns = proj₁ (toList ins) sorted : AllPairs _<_ ns -sorted = AllPairs.map (fromWitness _<_ _<?_) (proj₂ (toList ins)) +sorted = AllPairs.map (fromWitness _<_ _<?_) (proj₂ (toList ins)) -- See the following module for an applied use-case of fresh lists open import README.Data.Trie.NonDependent diff --git a/v2.3/README.Data.List.Relation.Binary.Equality.html b/v2.3/README.Data.List.Relation.Binary.Equality.html index d1d9b90a0c..5d7043c102 100644 --- a/v2.3/README.Data.List.Relation.Binary.Equality.html +++ b/v2.3/README.Data.List.Relation.Binary.Equality.html @@ -97,7 +97,7 @@ lem₄ = 2x+2≗2[x+1] [] where 2x+2≗2[x+1] : x x + 1) x x + 2 1) - 2x+2≗2[x+1] x = sym (+-∸-assoc x (s≤s z≤n)) + 2x+2≗2[x+1] x = sym (+-∸-assoc x (s≤s z≤n)) -- The modules also provide proofs that the `_≋_` relation is a -- setoid in its own right and therefore is reflexive, symmetric, diff --git a/v2.3/README.Data.List.Relation.Unary.All.html b/v2.3/README.Data.List.Relation.Unary.All.html index 68d40ed02c..3dacb2008e 100644 --- a/v2.3/README.Data.List.Relation.Unary.All.html +++ b/v2.3/README.Data.List.Relation.Unary.All.html @@ -9,7 +9,7 @@ open import Data.List.Base using ([]; _∷_) open import Data.Nat using (; s≤s; z≤n; _≤_) -open import Data.Nat.Properties using (≤-trans; n≤1+n) +open import Data.Nat.Properties using (≤-trans; n≤1+n) ------------------------------------------------------------------------ -- All @@ -38,7 +38,7 @@ lem₂ = All.map ≤1⇒≤2 lem₁ where ≤1⇒≤2 : {x} x 1 x 2 - ≤1⇒≤2 x≤1 = ≤-trans x≤1 (n≤1+n 1) + ≤1⇒≤2 x≤1 = ≤-trans x≤1 (n≤1+n 1) -- Properties of how list functions interact with `All` can be -- found in: diff --git a/v2.3/README.Data.List.Relation.Unary.Any.html b/v2.3/README.Data.List.Relation.Unary.Any.html index 15a765a3e0..4e65a80890 100644 --- a/v2.3/README.Data.List.Relation.Unary.Any.html +++ b/v2.3/README.Data.List.Relation.Unary.Any.html @@ -9,7 +9,7 @@ open import Data.List.Base using ([]; _∷_) open import Data.Nat.Base using (; _+_; _<_; s≤s; z≤n; _*_; _∸_; _≤_) -open import Data.Nat.Properties using (≤-trans; n≤1+n) +open import Data.Nat.Properties using (≤-trans; n≤1+n) ------------------------------------------------------------------------ -- Any @@ -57,7 +57,7 @@ lem₃ = Any.map 4≤x⇒3≤x lem₂ where 4≤x⇒3≤x : {x} 4 x 3 x - 4≤x⇒3≤x = ≤-trans (n≤1+n 3) + 4≤x⇒3≤x = ≤-trans (n≤1+n 3) -- Properties of how list functions interact with `Any` can be -- found in: diff --git a/v2.3/README.Data.Nat.html b/v2.3/README.Data.Nat.html index 9c5b60c456..6ddf800b22 100644 --- a/v2.3/README.Data.Nat.html +++ b/v2.3/README.Data.Nat.html @@ -31,10 +31,10 @@ -- Data.Nat.Properties contains a number of properties about natural -- numbers. -open import Data.Nat.Properties using (*-comm; +-identityʳ) +open import Data.Nat.Properties using (*-comm; +-identityʳ) ex₃ : m n m * n n * m -ex₃ m n = *-comm m n +ex₃ m n = *-comm m n -- The module ≡-Reasoning in Relation.Binary.PropositionalEquality -- provides some combinators for equational reasoning. @@ -43,8 +43,8 @@ ex₄ : m n m * (n + 0) n * m ex₄ m n = begin - m * (n + 0) ≡⟨ cong (_*_ m) (+-identityʳ n) - m * n ≡⟨ *-comm m n + m * (n + 0) ≡⟨ cong (_*_ m) (+-identityʳ n) + m * n ≡⟨ *-comm m n n * m where open ≡-Reasoning diff --git a/v2.3/README.Data.Tree.AVL.html b/v2.3/README.Data.Tree.AVL.html index 1e1c139273..aeb704d259 100644 --- a/v2.3/README.Data.Tree.AVL.html +++ b/v2.3/README.Data.Tree.AVL.html @@ -20,13 +20,13 @@ -- total order, and values, which are indexed by keys. Let us use -- natural numbers as keys and vectors of strings as values. -open import Data.Nat.Properties using (<-strictTotalOrder) +open import Data.Nat.Properties using (<-strictTotalOrder) open import Data.Product.Base as Product using (_,_; _,′_) open import Data.String.Base using (String) open import Data.Vec.Base using (Vec; _∷_; []) open import Relation.Binary.PropositionalEquality -open Data.Tree.AVL <-strictTotalOrder renaming (Tree to Tree′) +open Data.Tree.AVL <-strictTotalOrder renaming (Tree to Tree′) Tree = Tree′ (MkValue (Vec String) (subst (Vec String))) -- The first argument to `MkValue` should be a function from a key diff --git a/v2.3/README.Data.Vec.Relation.Binary.Equality.Cast.html b/v2.3/README.Data.Vec.Relation.Binary.Equality.Cast.html index ad3534ac43..88bcaeed3f 100644 --- a/v2.3/README.Data.Vec.Relation.Binary.Equality.Cast.html +++ b/v2.3/README.Data.Vec.Relation.Binary.Equality.Cast.html @@ -100,7 +100,7 @@ where open ≡-Reasoning eq₁ = List.length-++ xs {List.[ x ]} - eq₂ = +-comm (List.length xs) 1 + eq₂ = +-comm (List.length xs) 1 -- The `cast`s are irrelevant to core of the proof. At the same time, -- they can be inferred from the lemmas used during the reasoning steps diff --git a/v2.3/README.Data.Wrap.html b/v2.3/README.Data.Wrap.html index 3ce35a3d7f..7b280a4b5c 100644 --- a/v2.3/README.Data.Wrap.html +++ b/v2.3/README.Data.Wrap.html @@ -91,10 +91,10 @@ -- This lets us use the respective monoids when checking the respective -- definitions. - test-+ : MonoidEl +-0-monoid + test-+ : MonoidEl +-0-monoid test-+ = ([ 3 ] ε) [ 2 ] - test-* : MonoidEl *-1-monoid + test-* : MonoidEl *-1-monoid test-* = ([ 3 ] ε) [ 2 ] -- The reader is invited to normalise these two definitions @@ -133,7 +133,7 @@ assoc-→ : {m n o p} ( λ no Factor m no p × Factor no n o) ( λ op Factor m n op × Factor op o p) - assoc-→ {m} {n} {o} {p} (._ , refl , refl) = _ , *-assoc n o p , refl + assoc-→ {m} {n} {o} {p} (._ , refl , refl) = _ , *-assoc n o p , refl -- We must give at least some arguments to `*-assoc`, as Agda is unable to -- unify `? * ? * ?` with `n * o * p`, as `_*_` is a function and not @@ -178,7 +178,7 @@ ( λ no Factor m no p × Factor no n o) ( λ op Factor m n op × Factor op o p) assoc-→ {m} {n} {o} {p} (._ , [ refl ] , [ refl ]) = - _ , [ *-assoc n o p ] , [ refl ] + _ , [ *-assoc n o p ] , [ refl ] -- The difference is that now we have our basic lemma, the complex proof -- can work purely in terms of `Factor` trees. In particular, diff --git a/v2.3/README.Design.Hierarchies.html b/v2.3/README.Design.Hierarchies.html index 30a795abb9..b2920a20d0 100644 --- a/v2.3/README.Design.Hierarchies.html +++ b/v2.3/README.Design.Hierarchies.html @@ -10,437 +10,363 @@ module README.Design.Hierarchies where open import Data.Sum.Base using (_⊎_) -open import Data.Product.Base using (_×_) -open import Level using (Level; _⊔_; suc) -open import Relation.Binary.Core using (_Preserves₂_⟶_⟶_) - -private - variable - a b : Level - A : Set a +open import Level using (Level; _⊔_; suc) +open import Relation.Binary.Core using (_Preserves₂_⟶_⟶_) ------------------------------------------------------------------------- --- Introduction ------------------------------------------------------------------------- +private + variable + a b : Level + A : Set a --- One of the key design decisions facing the library is how to handle --- mathematical hierarchies, e.g. --- ∙ Binary relations: preorder → partial order → total order --- ↘ equivalence --- ∙ Algebraic structures: magma → semigroup → monoid → group --- ↘ band → semilattice --- --- Some of the hierarchies in the library are: --- ∙ Algebra --- ∙ Function --- ∙ Relation.Binary --- ∙ Relation.Binary.Indexed --- --- A given hierarchy `X` is always split into 4 separate folders: --- ∙ X.Core --- ∙ X.Definitions --- ∙ X.Structures --- ∙ X.Bundles --- all four of which are publicly re-exported by `X` itself. --- --- Additionally a hierarchy `X` may contain additional files --- ∙ X.Bundles.Raw --- ∙ X.Consequences --- ∙ X.Constructs --- ∙ X.Properties --- ∙ X.Morphisms --- --- Descriptions of these modules are now described below using the --- running example of the `Relation.Binary` and `Algebra` hierarchies. - --- Note that we redefine everything here for illustrative purposes, --- and that the definitions given below may be slightly simpler --- than the real definitions in order to focus on the points being --- discussed. +------------------------------------------------------------------------ +-- Introduction +------------------------------------------------------------------------ +-- One of the key design decisions facing the library is how to handle +-- mathematical hierarchies, e.g. +-- ∙ Binary relations: preorder → partial order → total order +-- ↘ equivalence +-- ∙ Algebraic structures: magma → semigroup → monoid → group +-- ↘ band → semilattice +-- +-- Some of the hierarchies in the library are: +-- ∙ Algebra +-- ∙ Function +-- ∙ Relation.Binary +-- ∙ Relation.Binary.Indexed +-- +-- A given hierarchy `X` is always split into 4 separate folders: +-- ∙ X.Core +-- ∙ X.Definitions +-- ∙ X.Structures +-- ∙ X.Bundles +-- all four of which are publicly re-exported by `X` itself. +-- +-- Additionally a hierarchy `X` may contain additional files +-- ∙ X.Bundles.Raw +-- ∙ X.Consequences +-- ∙ X.Constructs +-- ∙ X.Properties +-- ∙ X.Morphisms +-- +-- Descriptions of these modules are now described below using the +-- running example of the `Relation.Binary` and `Algebra` hierarchies. + +-- Note that we redefine everything here for illustrative purposes, +-- and that the definitions given below may be slightly simpler +-- than the real definitions in order to focus on the points being +-- discussed. + + +------------------------------------------------------------------------ +-- Main hierarchy modules +------------------------------------------------------------------------ + +------------------------------------------------------------------------ +-- X.Core + +-- The Core module contains the basic units of the hierarchy. + +-- For example, in the case of binary relations these are homogeneous and +-- heterogeneous binary relations: + +REL : Set a Set b ( : Level) Set (a b suc ) +REL A B = A B Set + +Rel : Set a ( : Level) Set (a suc ) +Rel A = A A Set + +-- and in Algebra these are unary and binary operators, e.g. + +Op₁ : Set a Set a +Op₁ A = A A + +Op₂ : Set a Set a +Op₂ A = A A A + + +------------------------------------------------------------------------ +-- X.Definitions + +-- The Definitions module defines the various properties that the +-- basic units of the hierarchy may have. + +-- Examples in Relation.Binary include reflexivity, transitivity, etc. + +Reflexive : Rel A Set _ +Reflexive _∼_ = {x} x x + +Symmetric : Rel A Set _ +Symmetric _∼_ = {x y} x y y x + +Transitive : Rel A Set _ +Transitive _∼_ = {x y z} x y y z x z + +Total : Rel A Set _ +Total _∼_ = x y x y y x + +-- Examples in Algebra include associativity, commutativity. +-- Note that all definitions for Algebra are based on some notion of +-- underlying equality. + +Associative : Rel A Op₂ A Set _ +Associative _≈_ _∙_ = x y z ((x y) z) (x (y z)) + +Commutative : Rel A Op₂ A Set _ +Commutative _≈_ _∙_ = x y (x y) (y x) + +LeftIdentity : Rel A A Op₂ A Set _ +LeftIdentity _≈_ e _∙_ = x (e x) x + +RightIdentity : Rel A A Op₂ A Set _ +RightIdentity _≈_ e _∙_ = x (x e) x + +-- Note that the types in `Definitions` modules are not meant to express +-- the full concept on their own. For example the `Associative` type does +-- not require the underlying relation to be an equivalence relation. +-- Instead they are designed to aid modular reuse of the core concepts. +-- The complete concepts are captured in various structures/bundles +-- where the definitions are correctly used in context. + + +------------------------------------------------------------------------ +-- X.Structures ------------------------------------------------------------------------- --- Main hierarchy modules ------------------------------------------------------------------------- +-- When an abstract hierarchy of some sort (for instance semigroup → +-- monoid → group) is included in the library, the basic approach is to +-- specify the properties of every concept in terms of a record +-- containing just properties, parameterised on the underlying +-- sets, relations and operations. For example: ------------------------------------------------------------------------- --- X.Core +record IsEquivalence {A : Set a} + (_≈_ : Rel A ) + : Set (a ) + where + field + refl : Reflexive _≈_ + sym : Symmetric _≈_ + trans : Transitive _≈_ --- The Core module contains the basic units of the hierarchy. +-- More specific concepts are then specified in terms of simpler ones: --- For example, in the case of binary relations these are homogeneous and --- heterogeneous binary relations: +record IsMagma {A : Set a} ( : Rel A ) ( : Op₂ A) : Set (a ) where + field + isEquivalence : IsEquivalence + ∙-cong : Preserves₂ -REL : Set a Set b ( : Level) Set (a b suc ) -REL A B = A B Set +record IsSemigroup {A : Set a} ( : Rel A ) ( : Op₂ A) : Set (a ) where + field + isMagma : IsMagma + associative : Associative -Rel : Set a ( : Level) Set (a suc ) -Rel A = A A Set + open IsMagma isMagma public --- and in Algebra these are unary and binary operators, e.g. +-- Note here that `open IsMagma isMagma public` ensures that the +-- fields of the `isMagma` record can be accessed directly; this +-- technique enables the user of an `IsSemigroup` record to use underlying +-- records without having to manually open an entire record hierarchy. +-- +-- This is not always possible, though. Consider the following definition +-- of preorders: -Op₁ : Set a Set a -Op₁ A = A A +record IsPreorder {A : Set a} + (_≈_ : Rel A ) -- The underlying equality. + (_∼_ : Rel A ) -- The relation. + : Set (a ) where + field + isEquivalence : IsEquivalence _≈_ + refl : Reflexive _∼_ + trans : Transitive _∼_ -Op₂ : Set a Set a -Op₂ A = A A A + module Eq = IsEquivalence isEquivalence +-- The IsEquivalence field in IsPreorder is not opened publicly because +-- the `refl` and `trans` fields would clash with those in the +-- `IsPreorder` record. Instead we provide an internal module and the +-- equality fields can be accessed via `Eq.refl` and `Eq.trans`. ------------------------------------------------------------------------- --- X.Definitions --- The Definitions module defines the various properties that the --- basic units of the hierarchy may have. +------------------------------------------------------------------------ +-- X.Bundles --- Examples in Relation.Binary include reflexivity, transitivity, etc. +-- Although structures are useful for describing the properties of a +-- given set of operations/relations, sometimes you don't require the +-- properties to hold for a given set of objects but only that such a +-- set of objects exists. In this case bundles are what you're after. -Reflexive : Rel A Set _ -Reflexive _∼_ = {x} x x +-- Each structure has a corresponding bundle that include the structure +-- along with the corresponding sets, relations and operations as +-- fields. -Symmetric : Rel A Set _ -Symmetric _∼_ = {x y} x y y x +record Setoid c : Set (suc (c )) where + field + Carrier : Set c + _≈_ : Rel Carrier + isEquivalence : IsEquivalence _≈_ -Transitive : Rel A Set _ -Transitive _∼_ = {x y z} x y y z x z - -Total : Rel A Set _ -Total _∼_ = x y x y y x + open IsEquivalence isEquivalence public --- Examples in Algebra include associativity, commutativity. --- Note that all definitions for Algebra are based on some notion of --- underlying equality. - -Associative : Rel A Op₂ A Set _ -Associative _≈_ _∙_ = x y z ((x y) z) (x (y z)) +-- The contents of the structure is always re-exported publicly, +-- providing access to its fields. -Commutative : Rel A Op₂ A Set _ -Commutative _≈_ _∙_ = x y (x y) (y x) +record Magma c : Set (suc (c )) where + infixl 7 _∙_ + infix 4 _≈_ + field + Carrier : Set c + _≈_ : Rel Carrier + _∙_ : Op₂ Carrier + isMagma : IsMagma _≈_ _∙_ + + open IsMagma isMagma public + + +record Semigroup : Set (suc (a )) where + infixl 7 _∙_ + infix 4 _≈_ + field + Carrier : Set a + _≈_ : Rel Carrier + _∙_ : Op₂ Carrier + isSemigroup : IsSemigroup _≈_ _∙_ + + open IsSemigroup isSemigroup public + + magma : Magma a + magma = record { isMagma = isMagma } + +-- Note that the `Semigroup` record does not include a (primitive; +-- definitional) `Magma` field, by contrast with the `IsSemigroup` +-- structure which *does* include an `isMagma` field as primitive. +-- Instead, the `Semigroup` record includes an additional declaration +-- (a 'manifest field' of the `record`) defining a `Magma` bundle, in +-- terms of that exported `isMagma` field. In this way, 'inheritance' +-- is *automatic* for the `IsX` sub*structures* of a given bundle, +-- while supporting the *optional* export of inherited sub*bundles*. -LeftIdentity : Rel A A Op₂ A Set _ -LeftIdentity _≈_ e _∙_ = x (e x) x +-- The above setup may seem a bit complicated, but it has been arrived +-- at after a lot of thought and is designed to both make the hierarchies +-- easy to work with whilst also providing enough flexibility for the +-- different applications of their concepts. -RightIdentity : Rel A A Op₂ A Set _ -RightIdentity _≈_ e _∙_ = x (x e) x +-- NOTE: bundles for the function hierarchy are designed a little +-- differently, as a function with an unknown domain and codomain is +-- of little use. -Identity : Rel A A Op₂ A Set _ -Identity _≈_ e = (LeftIdentity _≈_ e ) × (RightIdentity _≈_ e ) +------------------------- +-- Bundle re-exporting -- +------------------------- -LeftZero : Rel A A Op₂ A Set _ -LeftZero _≈_ z _∙_ = x (z x) z +-- In general ensuring that bundles re-export everything in their +-- sub-bundles can get a little tricky. -DistributesOverʳ : Rel A Op₂ A Op₂ A Set _ -DistributesOverʳ _≈_ _*_ _+_ = - x y z ((y + z) * x) ((y * x) + (z * x)) +-- Imagine we have the following general scenario where bundle A is a +-- direct refinement of bundle C (i.e. the record `IsA` has an `IsC` field) +-- but is also morally a refinement of bundles B and D. +-- Structures Bundles +-- ========== ======= +-- IsA A +-- / || \ / || \ +-- IsB IsC IsD B C D + +-- The procedure for re-exports in the bundles is as follows: --- Note that the types in `Definitions` modules are not meant to express --- the full concept on their own. For example the `Associative` type does --- not require the underlying relation to be an equivalence relation. --- Instead they are designed to aid modular reuse of the core concepts. --- The complete concepts are captured in various structures/bundles --- where the definitions are correctly used in context. +-- 1. `open IsA isA public using (IsC, M)` where `M` is everything +-- exported by `IsA` that is not exported by `IsC`. +-- 2. Construct `c : C` via the `isC` obtained in step 1. ------------------------------------------------------------------------- --- X.Structures +-- 3. `open C c public hiding (N)` where `N` is the list of fields +-- shared by both `A` and `C`. --- When an abstract hierarchy of some sort (for instance semigroup → --- monoid → group) is included in the library, the basic approach is to --- specify the properties of every concept in terms of a record --- containing just properties, parameterised on the underlying --- sets, relations and operations. For example: +-- 4. Construct `b : B` via the `isB` obtained in step 1. -record IsEquivalence {A : Set a} - (_≈_ : Rel A ) - : Set (a ) - where - field - refl : Reflexive _≈_ - sym : Symmetric _≈_ - trans : Transitive _≈_ +-- 5. `open B b public using (O)` where `O` is everything exported +-- by `B` but not exported by `IsA`. --- More specific concepts are then specified in terms of simpler ones: +-- 6. Construct `d : D` via the `isC` obtained in step 1. -record IsMagma {A : Set a} ( : Rel A ) ( : Op₂ A) : Set (a ) where - field - isEquivalence : IsEquivalence - ∙-cong : Preserves₂ +-- 7. `open D d public using (P)` where `P` is everything exported +-- by `D` but not exported by `IsA`. + +------------------------------------------------------------------------ +-- Other hierarchy modules +------------------------------------------------------------------------ -record IsSemigroup {A : Set a} ( : Rel A ) ( : Op₂ A) : Set (a ) where - field - isMagma : IsMagma - associative : Associative +------------------------------------------------------------------------ +-- X.Bundles.Raw - open IsMagma isMagma public +-- Sometimes it is useful to have the bundles without any accompanying +-- laws. These correspond more or less to what the definitions would +-- be in non-dependently typed languages like Haskell. --- Note here that `open IsMagma isMagma public` ensures that the --- fields of the `isMagma` record can be accessed directly; this --- technique enables the user of an `IsSemigroup` record to use underlying --- records without having to manually open an entire record hierarchy. +-- Each bundle therefore has a corresponding raw bundle that only +-- includes the operations, but not the laws. --- Thus, we may incrementally build monoids out of semigroups by adding an --- `Identity` for the underlying operation, as follows: +record RawMagma c : Set (suc (c )) where + infixl 7 _∙_ + infix 4 _≈_ + field + Carrier : Set c + _≈_ : Rel Carrier + _∙_ : Op₂ Carrier -record IsMonoid {A : Set a} ( : Rel A ) ( : Op₂ A) (ε : A) : Set (a ) where - field - isSemigroup : IsSemigroup - identity : Identity ε +record RawMonoid c : Set (suc (c )) where + infixl 7 _∙_ + infix 4 _≈_ + field + Carrier : Set c + _≈_ : Rel Carrier + _∙_ : Op₂ Carrier + ε : Carrier - open IsSemigroup isSemigroup public - --- where the `open IsSemigroup isSemigroup public` ensures, transitively, --- that both `associative` and (all the subfields of) `isMagma` are brought --- into scope. - --- This is not always possible, though. Consider the following definition --- of preorders: - -record IsPreorder {A : Set a} - (_≈_ : Rel A ) -- The underlying equality. - (_∼_ : Rel A ) -- The relation. - : Set (a ) where - field - isEquivalence : IsEquivalence _≈_ - refl : Reflexive _∼_ - trans : Transitive _∼_ - - module Eq = IsEquivalence isEquivalence - --- The IsEquivalence field in IsPreorder is not opened publicly because --- the `refl` and `trans` fields would clash with those in the --- `IsPreorder` record. Instead we provide an internal module and the --- equality fields can be accessed via `Eq.refl` and `Eq.trans`. - --- More generally, we quickly face the issue of how to model structures --- in which there are *two* (or more!) interacting algebraic substructures --- which *share* an underlying `IsEquivalence` in terms of which their --- respective axiomatisations are expressed. - --- For example, in the family of `IsXRing` structures, there is a --- fundamental representation problem, namely how to associate the --- multiplicative structure to the additive, in such a way as to avoid --- the possibility of ambiguity as to the underlying `IsEquivalence` --- substructure which is to be *shared* between the two operations. - --- The simplest instance of this is `IsNearSemiring`, defined as: - -record IsNearSemiring - {A : Set a} ( : Rel A ) (+ * : Op₂ A) (0# : A) : Set (a ) where - field - +-isMonoid : IsMonoid + 0# - *-cong : * Preserves₂ - *-assoc : Associative * - distribʳ : DistributesOverʳ * + - zeroˡ : LeftZero 0# * - --- where a multiplicative `IsSemigroup *` *acts* on the underlying --- `+-isMonoid` (whence the distributivity), but is not represented --- *directly* as a primitive `*-isSemigroup : IsSemigroup *` field. - --- Rather, the `stdlib` designers have chosen to privilege the underlying --- *additive* structure over the multiplicative: thus for structure --- `IsNearSemiring` defined here, the additive structure is declared --- via a field `+-isMonoid : IsMonoid + 0#`, while the multiplicative --- is given 'unbundled' as the *components* of an `IsSemigroup *` structure, --- namely as an operation satisfying both `*-cong : Congruent₂ *` and --- also `*-assoc : Associative *`, from which the corresponding `IsMagma *` --- and `IsSemigroup *` are then immediately derivable: - - open IsMonoid +-isMonoid public using (isEquivalence) - - *-isMagma : IsMagma * - *-isMagma = record - { isEquivalence = isEquivalence - ; ∙-cong = *-cong - } - - *-isSemigroup : IsSemigroup * - *-isSemigroup = record - { isMagma = *-isMagma - ; associative = *-assoc - } - ------------------------------------------------------------------------- --- X.Bundles - --- Although structures are useful for describing the properties of a --- given set of operations/relations, sometimes you don't require the --- properties to hold for a given set of objects but only that such a --- set of objects exists. In this case bundles are what you're after. - --- Each structure has a corresponding bundle that include the structure --- along with the corresponding sets, relations and operations as --- fields. - -record Setoid c : Set (suc (c )) where - field - Carrier : Set c - _≈_ : Rel Carrier - isEquivalence : IsEquivalence _≈_ - - open IsEquivalence isEquivalence public - --- The contents of the structure is always re-exported publicly, --- providing access to its fields. - -record Magma c : Set (suc (c )) where - infixl 7 _∙_ - infix 4 _≈_ - field - Carrier : Set c - _≈_ : Rel Carrier - _∙_ : Op₂ Carrier - isMagma : IsMagma _≈_ _∙_ - - open IsMagma isMagma public - - -record Semigroup : Set (suc (a )) where - infixl 7 _∙_ - infix 4 _≈_ - field - Carrier : Set a - _≈_ : Rel Carrier - _∙_ : Op₂ Carrier - isSemigroup : IsSemigroup _≈_ _∙_ - - open IsSemigroup isSemigroup public - - magma : Magma a - magma = record { isMagma = isMagma } - --- Note that the `Semigroup` record does not include a (primitive; --- definitional) `Magma` field, by contrast with the `IsSemigroup` --- structure which *does* include an `isMagma` field as primitive. --- Instead, the `Semigroup` record includes an additional declaration --- (a 'manifest field' of the `record`) defining a `Magma` bundle, in --- terms of that exported `isMagma` field. In this way, 'inheritance' --- is *automatic* for the `IsX` sub*structures* of a given bundle, --- while supporting the *optional* export of inherited sub*bundles*. - --- The above setup may seem a bit complicated, but it has been arrived --- at after a lot of thought and is designed to both make the hierarchies --- easy to work with whilst also providing enough flexibility for the --- different applications of their concepts. - --- NOTE: bundles for the function hierarchy are designed a little --- differently, as a function with an unknown domain and codomain is --- of little use. - -------------------------- --- Bundle re-exporting -- -------------------------- - --- In general ensuring that bundles re-export everything in their --- sub-bundles can get a little tricky. - --- Imagine we have the following general scenario where bundle A is a --- direct refinement of bundle C (i.e. the record `IsA` has an `IsC` field) --- but is also morally a refinement of bundles B and D. - --- Structures Bundles --- ========== ======= --- IsA A --- / || \ / || \ --- IsB IsC IsD B C D - --- The procedure for re-exports in the bundles is as follows: +------------------------------------------------------------------------ +-- X.Consequences --- 1. `open IsA isA public using (IsC, M)` where `M` is everything --- exported by `IsA` that is not exported by `IsC`. - --- 2. Construct `c : C` via the `isC` obtained in step 1. - --- 3. `open C c public hiding (N)` where `N` is the list of fields --- shared by both `A` and `C`. +-- The "consequences" modules contains proofs for how the different +-- types in the `Definitions` module relate to each other. For example: +-- that any total relation is reflexive or that commutativity allows +-- one to translate between left and right identities. --- 4. Construct `b : B` via the `isB` obtained in step 1. - --- 5. `open B b public using (O)` where `O` is everything exported --- by `B` but not exported by `IsA`. +total⇒refl : {_∼_ : Rel A } Total _∼_ Reflexive _∼_ +total⇒refl = {!!} --- 6. Construct `d : D` via the `isC` obtained in step 1. +idˡ∧comm⇒idʳ : {_≈_ : Rel A } {e _∙_} Commutative _≈_ _∙_ + LeftIdentity _≈_ e _∙_ RightIdentity _≈_ e _∙_ +idˡ∧comm⇒idʳ = {!!} --- 7. `open D d public using (P)` where `P` is everything exported --- by `D` but not exported by `IsA`. - ------------------------------------------------------------------------- --- Other hierarchy modules ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- X.Construct ------------------------------------------------------------------------- --- X.Bundles.Raw +-- The "construct" folder contains various generic ways of constructing +-- new instances of the hierarchy. For example, --- Sometimes it is useful to have the bundles without any accompanying --- laws. These correspond more or less to what the definitions would --- be in non-dependently typed languages like Haskell. +import Relation.Binary.Construct.Intersection --- Each bundle therefore has a corresponding raw bundle that only --- includes the operations, but not the laws. +-- takes in two relations and forms the new relation that says two +-- elements are only related if they are related via both of the +-- original relations. -record RawMagma c : Set (suc (c )) where - infixl 7 _∙_ - infix 4 _≈_ - field - Carrier : Set c - _≈_ : Rel Carrier - _∙_ : Op₂ Carrier +-- These files are layed out in four parts, mimicking the main modules +-- of the hierarchy itself. First they define the new relation, then +-- subsequently the definitions, then structures and finally +-- bundles can be translated across to it. -record RawMonoid c : Set (suc (c )) where - infixl 7 _∙_ - infix 4 _≈_ - field - Carrier : Set c - _≈_ : Rel Carrier - _∙_ : Op₂ Carrier - ε : Carrier +------------------------------------------------------------------------ +-- X.Morphisms ------------------------------------------------------------------------- --- X.Consequences +-- The `Morphisms` folder is a sub-hierarchy containing relationships +-- such as homomorphisms, monomorphisms and isomorphisms between the +-- structures and bundles in the hierarchy. --- The "consequences" modules contains proofs for how the different --- types in the `Definitions` module relate to each other. For example: --- that any total relation is reflexive or that commutativity allows --- one to translate between left and right identities. +------------------------------------------------------------------------ +-- X.Properties -total⇒refl : {_∼_ : Rel A } Total _∼_ Reflexive _∼_ -total⇒refl = {!!} - -idˡ∧comm⇒idʳ : {_≈_ : Rel A } {e _∙_} Commutative _≈_ _∙_ - LeftIdentity _≈_ e _∙_ RightIdentity _≈_ e _∙_ -idˡ∧comm⇒idʳ = {!!} - ------------------------------------------------------------------------- --- X.Construct - --- The "construct" folder contains various generic ways of constructing --- new instances of the hierarchy. For example, - -import Relation.Binary.Construct.Intersection - --- takes in two relations and forms the new relation that says two --- elements are only related if they are related via both of the --- original relations. - --- These files are layed out in four parts, mimicking the main modules --- of the hierarchy itself. First they define the new relation, then --- subsequently the definitions, then structures and finally --- bundles can be translated across to it. - ------------------------------------------------------------------------- --- X.Morphisms - --- The `Morphisms` folder is a sub-hierarchy containing relationships --- such as homomorphisms, monomorphisms and isomorphisms between the --- structures and bundles in the hierarchy. - ------------------------------------------------------------------------- --- X.Properties - --- The `Properties` folder contains additional proofs about the theory --- of each bundle. They are usually designed so that a bundle's --- `Properties` file re-exports the contents of the `Properties` files --- above it in the hierarchy. For example --- `Algebra.Properties.AbelianGroup` re-exports the contents of --- `Algebra.Properties.Group`. +-- The `Properties` folder contains additional proofs about the theory +-- of each bundle. They are usually designed so that a bundle's +-- `Properties` file re-exports the contents of the `Properties` files +-- above it in the hierarchy. For example +-- `Algebra.Properties.AbelianGroup` re-exports the contents of +-- `Algebra.Properties.Group`. \ No newline at end of file diff --git a/v2.3/README.Function.Reasoning.html b/v2.3/README.Function.Reasoning.html index 8a94c54633..0086e17b10 100644 --- a/v2.3/README.Function.Reasoning.html +++ b/v2.3/README.Function.Reasoning.html @@ -55,7 +55,7 @@ |> inits List Chars |> concatMap tails List Chars -- then only keeps the ones which are not singletons - |> filter cs 2 ≤? length cs) List Chars + |> filter cs 2 ≤? length cs) List Chars -- only keep the ones that are palindromes |> map < fromList , fromList reverse > List (String × String) |> filter (uncurry String._≟_) List (String × String) diff --git a/v2.3/README.Inspect.html b/v2.3/README.Inspect.html index 98516217d4..8f52d0e157 100644 --- a/v2.3/README.Inspect.html +++ b/v2.3/README.Inspect.html @@ -74,7 +74,7 @@ plus-eq-with : m n Plus-eq m n (m + n) plus-eq-with m n with m + n | inspect (m +_) n -... | zero | [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0 +... | zero | [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0 ... | suc p | [ m+n≡1+p ] = m+n≡1+p @@ -89,7 +89,7 @@ plus-eq-aux m n = aux m n (m + n) refl where aux : m n p m + n p Plus-eq m n p - aux m n zero m+n≡0 = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0 + aux m n zero m+n≡0 = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0 aux m n (suc p) m+n≡1+p = m+n≡1+p -- The problem is that when we write ̀with f x | pr`, `with` decides to call `y` @@ -126,7 +126,7 @@ plus-eq-reveal m n = aux m n (m + n) (my-inspect (m +_) n) where aux : m n p MyReveal (m +_) · n is p Plus-eq m n p - aux m n zero [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0 + aux m n zero [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0 aux m n (suc p) [ m+n≡1+p ] = m+n≡1+p -- At the cost of having to unwrap the constructor `[_]` around the equality diff --git a/v2.3/README.Nary.html b/v2.3/README.Nary.html index 19b98aef4a..9696584dc5 100644 --- a/v2.3/README.Nary.html +++ b/v2.3/README.Nary.html @@ -85,11 +85,11 @@ _ : m n p q suc (m + (p * n) + (q ^ (m + n))) (m + 0) + (n * p) + (q ^ m * q ^ n) + 1 _ = λ m n p q begin - suc (m + (p * n) + (q ^ (m + n))) ≡⟨ +-comm 1 _ + suc (m + (p * n) + (q ^ (m + n))) ≡⟨ +-comm 1 _ m + (p * n) + (q ^ (m + n)) + 1 ≡⟨ congₙ 3 m n p m + n + p + 1) - (+-comm 0 m) - (*-comm p n) - (^-distribˡ-+-* q m n) + (+-comm 0 m) + (*-comm p n) + (^-distribˡ-+-* q m n) m + 0 + n * p + (q ^ m) * (q ^ n) + 1 where open ≡-Reasoning @@ -98,7 +98,7 @@ -- and not by the type of the function it works on. _ : m (m +_) ((m + 0) +_) -_ = λ m congₙ 1 _+_ (+-comm 0 m) +_ = λ m congₙ 1 _+_ (+-comm 0 m) -- We don't have to work on the function's first argument either: we can just as -- easily use `congₙ` to act on the second one by `flip`ping it. See `holeₙ` for @@ -106,7 +106,7 @@ -- arguments and not just the first or second one. _ : m (_+ m) (_+ (m + 0)) -_ = λ m congₙ 1 (flip _+_) (+-comm 0 m) +_ = λ m congₙ 1 (flip _+_) (+-comm 0 m) ------------------------------------------------------------------------ -- substₙ : (P : A₁ → ⋯ → Aₙ → Set p) → @@ -124,7 +124,7 @@ _ : k m n j mod-helper k m (n + 1) (j + 1) mod-helper (k + 1) m n j _ = λ k m n j let P sk sn sj = mod-helper k m sn sj mod-helper sk m n j - in substₙ P (+-comm 1 k) (+-comm 1 n) (+-comm 1 j) refl + in substₙ P (+-comm 1 k) (+-comm 1 n) (+-comm 1 j) refl ----------------------------------------------------------------------- -- Generic programs working on n-ary products & functions @@ -280,7 +280,7 @@ -- Reusing mod-helper just because it takes a lot of arguments: hole₁ : k m n j mod-helper k (m + 1) n j mod-helper k (suc m) n j -hole₁ = λ k m n j cong (holeₙ 2 (mod-helper k) n j) (+-comm m 1) +hole₁ = λ k m n j cong (holeₙ 2 (mod-helper k) n j) (+-comm m 1) ----------------------------------------------------------------------- -- mapₙ : ∀ n → (B → C) → (A₁ → ⋯ Aₙ → B) → (A₁ → ⋯ → Aₙ → C) @@ -353,16 +353,16 @@ -- P ⇒ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ → Q a₁ ⋯ aₙ antisym : ∀[ _≤_ _≥_ _≡_ ] -antisym = ≤-antisym +antisym = ≤-antisym ------------------------------------------------------------------------ -- _∪_ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set s) → (A₁ → ⋯ → Aₙ → Set _) -- P ∪ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ ⊎ Q a₁ ⋯ aₙ ≤->-connex : Π[ _≤_ _>_ ] -≤->-connex m n with <-cmp m n -... | tri< a ¬b ¬c = inj₁ (<⇒≤ a) -... | tri≈ ¬a b ¬c = inj₁ (≤-reflexive b) +≤->-connex m n with <-cmp m n +... | tri< a ¬b ¬c = inj₁ (<⇒≤ a) +... | tri≈ ¬a b ¬c = inj₁ (≤-reflexive b) ... | tri> ¬a ¬b c = inj₂ c ------------------------------------------------------------------------ @@ -370,12 +370,12 @@ -- P ∩ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ × Q a₁ ⋯ aₙ <-inversion : ∀[ _<_ _≤_ _≢_ ] -<-inversion m<n = <⇒≤ m<n , <⇒≢ m<n +<-inversion m<n = <⇒≤ m<n , <⇒≢ m<n ------------------------------------------------------------------------ -- ∁ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set _) -- ∁ P = λ a₁ → ⋯ → λ aₙ → ¬ (P a₁ ⋯ aₙ) m<n⇒m≱n : ∀[ _>_ _≤_ ] -m<n⇒m≱n m>n m≤n = <⇒≱ m>n m≤n +m<n⇒m≱n m>n m≤n = <⇒≱ m>n m≤n \ No newline at end of file diff --git a/v2.3/README.html b/v2.3/README.html index 253ea675b0..c967ad3470 100644 --- a/v2.3/README.html +++ b/v2.3/README.html @@ -4,291 +4,292 @@ module README where ------------------------------------------------------------------------ --- The Agda standard library, version 2.4-dev --- --- Authors: Nils Anders Danielsson, Matthew Daggitt, Guillaume Allais --- with contributions from Andreas Abel, Stevan Andjelkovic, --- Jean-Philippe Bernardy, Peter Berry, Bradley Hardy, Joachim Breitner, --- Samuel Bronson, Daniel Brown, Jacques Carette, James Chapman, --- Liang-Ting Chen, Dominique Devriese, Dan Doel, Érdi Gergő, --- Zack Grannan, Helmut Grohne, Simon Foster, Liyang Hu, Jason Hu, --- Patrik Jansson, Alan Jeffrey, Wen Kokke, Evgeny Kotelnikov, --- James McKinna, Sergei Meshveliani, Eric Mertens, Darin Morrison, --- Guilhem Moulin, Shin-Cheng Mu, Ulf Norell, Noriyuki Ohkawa, --- Nicolas Pouillard, Andrés Sicard-Ramírez, Lex van der Stoep, --- Sandro Stucki, Milo Turner, Noam Zeilberger, Shu-Hung You --- and other anonymous contributors. ------------------------------------------------------------------------- +-- The Agda standard library, version 2.3 +-- +-- Authors: Nils Anders Danielsson, Matthew Daggitt, Guillaume Allais +-- with contributions from Andreas Abel, Stevan Andjelkovic, +-- Jean-Philippe Bernardy, Peter Berry, Bradley Hardy, Joachim Breitner, +-- Samuel Bronson, Daniel Brown, Jacques Carette, James Chapman, +-- Liang-Ting Chen, Dominique Devriese, Dan Doel, Érdi Gergő, +-- Zack Grannan, Helmut Grohne, Simon Foster, Liyang Hu, Jason Hu, +-- Patrik Jansson, Alan Jeffrey, Wen Kokke, Evgeny Kotelnikov, +-- James McKinna, Sergei Meshveliani, Eric Mertens, Darin Morrison, +-- Guilhem Moulin, Shin-Cheng Mu, Ulf Norell, Noriyuki Ohkawa, +-- Nicolas Pouillard, Andrés Sicard-Ramírez, Lex van der Stoep, +-- Sandro Stucki, Milo Turner, Noam Zeilberger, Shu-Hung You +-- and other anonymous contributors. +------------------------------------------------------------------------ --- This version of the library has been tested using Agda 2.8.0 +-- This version of the library has been tested using Agda 2.7.0 and +-- 2.8.0 --- The library comes with a .agda-lib file, for use with the library --- management system. +-- The library comes with a .agda-lib file, for use with the library +-- management system. --- Currently the library does not support the JavaScript compiler --- backend. +-- Currently the library does not support the JavaScript compiler +-- backend. ------------------------------------------------------------------------- --- Stability guarantees ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- Stability guarantees +------------------------------------------------------------------------ --- We do our best to adhere to the spirit of semantic versioning in that --- minor versions should not break people's code. This applies to the --- the entire library with one exception: modules with names that end in --- either ".Core" or ".Primitive". +-- We do our best to adhere to the spirit of semantic versioning in that +-- minor versions should not break people's code. This applies to the +-- the entire library with one exception: modules with names that end in +-- either ".Core" or ".Primitive". --- The former have (mostly) been created to avoid mutual recursion --- between modules and the latter to bind primitive operations to the --- more efficient operations supplied by the relevant backend. +-- The former have (mostly) been created to avoid mutual recursion +-- between modules and the latter to bind primitive operations to the +-- more efficient operations supplied by the relevant backend. --- These modules may undergo backwards incompatible changes between --- minor versions and therefore are imported directly at your own risk. --- Instead their contents should be accessed by their parent module, --- whose interface will remain stable. +-- These modules may undergo backwards incompatible changes between +-- minor versions and therefore are imported directly at your own risk. +-- Instead their contents should be accessed by their parent module, +-- whose interface will remain stable. ------------------------------------------------------------------------- --- High-level overview of contents ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- High-level overview of contents +------------------------------------------------------------------------ --- The top-level module names of the library are currently allocated --- as follows: --- --- • Algebra --- Abstract algebra (monoids, groups, rings etc.), along with --- properties needed to specify these structures (associativity, --- commutativity, etc.), and operations on and proofs about the --- structures. +-- The top-level module names of the library are currently allocated +-- as follows: +-- +-- • Algebra +-- Abstract algebra (monoids, groups, rings etc.), along with +-- properties needed to specify these structures (associativity, +-- commutativity, etc.), and operations on and proofs about the +-- structures. --- • Axiom --- Types and consequences of various additional axioms not --- necessarily included in Agda, e.g. uniqueness of identity --- proofs, function extensionality and excluded middle. +-- • Axiom +-- Types and consequences of various additional axioms not +-- necessarily included in Agda, e.g. uniqueness of identity +-- proofs, function extensionality and excluded middle. -import README.Axiom +import README.Axiom --- • Codata --- Coinductive data types and properties. There are two different --- approaches taken. The `Codata.Sized` folder contains the new more --- standard approach using sized types. The `Codata.Musical` --- folder contains modules using the old musical notation. +-- • Codata +-- Coinductive data types and properties. There are two different +-- approaches taken. The `Codata.Sized` folder contains the new more +-- standard approach using sized types. The `Codata.Musical` +-- folder contains modules using the old musical notation. --- • Data --- Data types and properties. +-- • Data +-- Data types and properties. --- • Effect --- Category theory-inspired idioms used to structure functional --- programs (functors and monads, for instance). +-- • Effect +-- Category theory-inspired idioms used to structure functional +-- programs (functors and monads, for instance). -import README.Data +import README.Data --- • Function --- Combinators and properties related to functions. +-- • Function +-- Combinators and properties related to functions. --- • Foreign --- Related to the foreign function interface. +-- • Foreign +-- Related to the foreign function interface. --- • Induction --- A general framework for induction (includes lexicographic and --- well-founded induction). +-- • Induction +-- A general framework for induction (includes lexicographic and +-- well-founded induction). --- • IO --- Input/output-related functions. +-- • IO +-- Input/output-related functions. -import README.IO +import README.IO --- • Level --- Universe levels. +-- • Level +-- Universe levels. --- • Reflection --- Support for reflection. +-- • Reflection +-- Support for reflection. --- • Relation --- Properties of and proofs about relations. +-- • Relation +-- Properties of and proofs about relations. --- • Size --- Sizes used by the sized types mechanism. +-- • Size +-- Sizes used by the sized types mechanism. --- • Strict --- Provides access to the builtins relating to strictness. +-- • Strict +-- Provides access to the builtins relating to strictness. --- • Tactic --- Tactics for automatic proof generation +-- • Tactic +-- Tactics for automatic proof generation --- • Text --- Format-based printing, Pretty-printing, and regular expressions +-- • Text +-- Format-based printing, Pretty-printing, and regular expressions ------------------------------------------------------------------------- --- Library design ------------------------------------------------------------------------- --- The following modules contain a discussion of some of the choices --- that have been made whilst designing the library. +------------------------------------------------------------------------ +-- Library design +------------------------------------------------------------------------ +-- The following modules contain a discussion of some of the choices +-- that have been made whilst designing the library. --- • How mathematical hierarchies (e.g. preorder, partial order, total --- order) are handled in the library. +-- • How mathematical hierarchies (e.g. preorder, partial order, total +-- order) are handled in the library. -import README.Design.Hierarchies +import README.Design.Hierarchies --- • How decidability is handled in the library. +-- • How decidability is handled in the library. -import README.Design.Decidability +import README.Design.Decidability ------------------------------------------------------------------------- --- A selection of useful library modules ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- A selection of useful library modules +------------------------------------------------------------------------ --- Note that module names in source code are often hyperlinked to the --- corresponding module. In the Emacs mode you can follow these --- hyperlinks by typing M-. or clicking with the middle mouse button. +-- Note that module names in source code are often hyperlinked to the +-- corresponding module. In the Emacs mode you can follow these +-- hyperlinks by typing M-. or clicking with the middle mouse button. --- • Some data types +-- • Some data types -import Data.Bool -- Booleans. -import Data.Char -- Characters. -import Data.Empty -- The empty type. -import Data.Fin -- Finite sets. -import Data.List -- Lists. -import Data.Maybe -- The maybe type. -import Data.Nat -- Natural numbers. -import Data.Product -- Products. -import Data.String -- Strings. -import Data.Sum -- Disjoint sums. -import Data.Unit -- The unit type. -import Data.Vec -- Fixed-length vectors. +import Data.Bool -- Booleans. +import Data.Char -- Characters. +import Data.Empty -- The empty type. +import Data.Fin -- Finite sets. +import Data.List -- Lists. +import Data.Maybe -- The maybe type. +import Data.Nat -- Natural numbers. +import Data.Product -- Products. +import Data.String -- Strings. +import Data.Sum -- Disjoint sums. +import Data.Unit -- The unit type. +import Data.Vec -- Fixed-length vectors. --- • Some co-inductive data types +-- • Some co-inductive data types -import Codata.Sized.Stream -- Streams. -import Codata.Sized.Colist -- Colists. +import Codata.Sized.Stream -- Streams. +import Codata.Sized.Colist -- Colists. --- • Some types used to structure computations +-- • Some types used to structure computations -import Effect.Functor -- Functors. -import Effect.Applicative -- Applicative functors. -import Effect.Monad -- Monads. +import Effect.Functor -- Functors. +import Effect.Applicative -- Applicative functors. +import Effect.Monad -- Monads. --- • Equality +-- • Equality --- Propositional equality: -import Relation.Binary.PropositionalEquality +-- Propositional equality: +import Relation.Binary.PropositionalEquality --- Convenient syntax for "equational reasoning" using a preorder: -import Relation.Binary.Reasoning.Preorder +-- Convenient syntax for "equational reasoning" using a preorder: +import Relation.Binary.Reasoning.Preorder --- Solver for commutative ring or semiring equalities: -import Algebra.Solver.Ring +-- Solver for commutative ring or semiring equalities: +import Algebra.Solver.Ring --- • Properties of functions, sets and relations +-- • Properties of functions, sets and relations --- Monoids, rings and similar algebraic structures: -import Algebra +-- Monoids, rings and similar algebraic structures: +import Algebra --- Negation, decidability, and similar operations on sets: -import Relation.Nullary +-- Negation, decidability, and similar operations on sets: +import Relation.Nullary --- Properties of homogeneous binary relations: -import Relation.Binary +-- Properties of homogeneous binary relations: +import Relation.Binary --- • Induction +-- • Induction --- An abstraction of various forms of recursion/induction: -import Induction +-- An abstraction of various forms of recursion/induction: +import Induction --- Well-founded induction: -import Induction.WellFounded +-- Well-founded induction: +import Induction.WellFounded --- Various forms of induction for natural numbers: -import Data.Nat.Induction +-- Various forms of induction for natural numbers: +import Data.Nat.Induction --- • Support for coinduction +-- • Support for coinduction -import Codata.Musical.Notation -import Codata.Sized.Thunk +import Codata.Musical.Notation +import Codata.Sized.Thunk --- • IO +-- • IO -import IO +import IO --- ∙ Text +-- ∙ Text --- Dependently typed formatted printing -import Text.Printf +-- Dependently typed formatted printing +import Text.Printf ------------------------------------------------------------------------- --- More documentation ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- More documentation +------------------------------------------------------------------------ --- Some examples showing how the case expression can be used. +-- Some examples showing how the case expression can be used. -import README.Case +import README.Case --- Showcasing the framework for well-scoped substitutions +-- Showcasing the framework for well-scoped substitutions -import README.Data.Fin.Substitution.UntypedLambda +import README.Data.Fin.Substitution.UntypedLambda --- Some examples showing how combinators can be used to emulate --- "functional reasoning" +-- Some examples showing how combinators can be used to emulate +-- "functional reasoning" -import README.Function.Reasoning +import README.Function.Reasoning --- An example showing how to use the debug tracing mechanism to inspect --- the behaviour of compiled Agda programs. +-- An example showing how to use the debug tracing mechanism to inspect +-- the behaviour of compiled Agda programs. -import README.Debug.Trace +import README.Debug.Trace --- An exploration of the generic programs acting on n-ary functions and --- n-ary heterogeneous products +-- An exploration of the generic programs acting on n-ary functions and +-- n-ary heterogeneous products -import README.Nary +import README.Nary --- Explaining the inspect idiom: use case, equivalent handwritten --- auxiliary definitions, and implementation details. +-- Explaining the inspect idiom: use case, equivalent handwritten +-- auxiliary definitions, and implementation details. -import README.Inspect +import README.Inspect --- Explaining how to use the automatic solvers +-- Explaining how to use the automatic solvers -import README.Tactic.MonoidSolver -import README.Tactic.RingSolver +import README.Tactic.MonoidSolver +import README.Tactic.RingSolver --- Explaining how the Haskell FFI works +-- Explaining how the Haskell FFI works -import README.Foreign.Haskell +import README.Foreign.Haskell --- Explaining string formats and the behaviour of printf +-- Explaining string formats and the behaviour of printf -import README.Text.Printf +import README.Text.Printf --- Showcasing the pretty printing module +-- Showcasing the pretty printing module -import README.Text.Pretty +import README.Text.Pretty --- Demonstrating the regular expression matching +-- Demonstrating the regular expression matching -import README.Text.Regex +import README.Text.Regex --- Explaining how to display tables of strings: +-- Explaining how to display tables of strings: -import README.Text.Tabular +import README.Text.Tabular ------------------------------------------------------------------------- --- All library modules ------------------------------------------------------------------------- +------------------------------------------------------------------------ +-- All library modules +------------------------------------------------------------------------ --- For short descriptions of every library module, see Everything; --- to exclude unsafe modules, see EverythingSafe: +-- For short descriptions of every library module, see Everything; +-- to exclude unsafe modules, see EverythingSafe: -import Everything -import EverythingSafe +import Everything +import EverythingSafe --- Note that the Everything* modules are generated automatically. If --- you have downloaded the library from its Git repository and want --- to type check README then you can (try to) construct Everything by --- running "cabal install && GenerateEverything". +-- Note that the Everything* modules are generated automatically. If +-- you have downloaded the library from its Git repository and want +-- to type check README then you can (try to) construct Everything by +-- running "cabal install && GenerateEverything". --- Note that all library sources are located under src or ffi. The --- modules README, README.* and Everything are not really part of the --- library, so these modules are located in the top-level directory --- instead. +-- Note that all library sources are located under src or ffi. The +-- modules README, README.* and Everything are not really part of the +-- library, so these modules are located in the top-level directory +-- instead. \ No newline at end of file diff --git a/v2.3/Relation.Binary.Consequences.html b/v2.3/Relation.Binary.Consequences.html index b217820a37..aa6d0d8abc 100644 --- a/v2.3/Relation.Binary.Consequences.html +++ b/v2.3/Relation.Binary.Consequences.html @@ -15,7 +15,7 @@ open import Level using (Level) open import Relation.Binary.Core open import Relation.Binary.Definitions -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Decidable.Core using (yes; no; recompute; map′; dec⇒maybe) open import Relation.Unary using (; Pred) @@ -136,7 +136,7 @@ irrefl (antisym x<y y<x) x<y asym⇒antisym : Asymmetric _<_ Antisymmetric _≈_ _<_ - asym⇒antisym asym x<y y<x = contradiction y<x (asym x<y) + asym⇒antisym asym x<y y<x = contradiction y<x (asym x<y) asym⇒irr : _<_ Respects₂ _≈_ Symmetric _≈_ Asymmetric _<_ Irreflexive _≈_ _<_ @@ -172,16 +172,16 @@ _<_ Respectsʳ _≈_ trans∧tri⇒respʳ sym ≈-tr <-tr tri {x} {y} {z} y≈z x<y with tri x z ... | tri< x<z _ _ = x<z - ... | tri≈ _ x≈z _ = contradiction x<y (tri⇒irr tri (≈-tr x≈z (sym y≈z))) - ... | tri> _ _ z<x = contradiction (<-tr z<x x<y) (tri⇒irr tri (sym y≈z)) + ... | tri≈ _ x≈z _ = contradiction x<y (tri⇒irr tri (≈-tr x≈z (sym y≈z))) + ... | tri> _ _ z<x = contradiction (<-tr z<x x<y) (tri⇒irr tri (sym y≈z)) trans∧tri⇒respˡ : Transitive _≈_ Transitive _<_ Trichotomous _≈_ _<_ _<_ Respectsˡ _≈_ trans∧tri⇒respˡ ≈-tr <-tr tri {z} {_} {y} x≈y x<z with tri y z ... | tri< y<z _ _ = y<z - ... | tri≈ _ y≈z _ = contradiction x<z (tri⇒irr tri (≈-tr x≈y y≈z)) - ... | tri> _ _ z<y = contradiction (<-tr x<z z<y) (tri⇒irr tri x≈y) + ... | tri≈ _ y≈z _ = contradiction x<z (tri⇒irr tri (≈-tr x≈y y≈z)) + ... | tri> _ _ z<y = contradiction (<-tr x<z z<y) (tri⇒irr tri x≈y) trans∧tri⇒resp : Symmetric _≈_ Transitive _≈_ Transitive _<_ Trichotomous _≈_ _<_ diff --git a/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.WithK.html b/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.WithK.html index 2f5b294433..51ebd4ad28 100644 --- a/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.WithK.html +++ b/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.WithK.html @@ -14,7 +14,7 @@ open import Relation.Binary.Construct.Closure.Reflexive using (ReflClosure; [_]; refl) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Relation.Binary.Construct.Closure.Reflexive.Properties public @@ -22,7 +22,7 @@ irrel : Irrelevant _∼_ Irreflexive _≡_ _∼_ Irrelevant (ReflClosure _∼_) irrel irrel irrefl [ x∼y₁ ] [ x∼y₂ ] = cong [_] (irrel x∼y₁ x∼y₂) - irrel irrel irrefl [ x∼y ] refl = contradiction x∼y (irrefl refl) - irrel irrel irrefl refl [ x∼y ] = contradiction x∼y (irrefl refl) + irrel irrel irrefl [ x∼y ] refl = contradiction x∼y (irrefl refl) + irrel irrel irrefl refl [ x∼y ] = contradiction x∼y (irrefl refl) irrel irrel irrefl refl refl = refl \ No newline at end of file diff --git a/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.html b/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.html index 3f28a5bb51..26516e6ae2 100644 --- a/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.html +++ b/v2.3/Relation.Binary.Construct.Closure.Reflexive.Properties.html @@ -27,7 +27,7 @@ using (ReflClosure; [_]; refl) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) import Relation.Binary.PropositionalEquality.Properties as -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Relation.Nullary.Decidable as Dec using (yes; no) open import Relation.Unary using (Pred) @@ -74,7 +74,7 @@ antisym : (_≈_ : Rel A p) Reflexive _≈_ Asymmetric _~_ Antisymmetric _≈_ _~ᵒ_ - antisym _≈_ ref asym [ x∼y ] [ y∼x ] = contradiction x∼y (asym y∼x) + antisym _≈_ ref asym [ x∼y ] [ y∼x ] = contradiction x∼y (asym y∼x) antisym _≈_ ref asym [ x∼y ] refl = ref antisym _≈_ ref asym refl _ = ref diff --git a/v2.3/Relation.Binary.Construct.NonStrictToStrict.html b/v2.3/Relation.Binary.Construct.NonStrictToStrict.html index b075e7d343..3b649732fc 100644 --- a/v2.3/Relation.Binary.Construct.NonStrictToStrict.html +++ b/v2.3/Relation.Binary.Construct.NonStrictToStrict.html @@ -17,7 +17,7 @@ open import Function.Base using (_∘_; flip) open import Relation.Nullary using (¬_; yes; no) open import Relation.Nullary.Decidable using (¬?; _×-dec_) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.Structures using (IsPartialOrder; IsEquivalence; IsStrictPartialOrder; IsDecPartialOrder ; IsDecStrictPartialOrder; IsTotalOrder; IsStrictTotalOrder @@ -60,7 +60,7 @@ ≰⇒> : Symmetric _≈_ (_≈_ _≤_) Total _≤_ {x y} ¬ (x y) y < x ≰⇒> sym refl total {x} {y} x≰y with total x y -... | inj₁ x≤y = contradiction x≤y x≰y +... | inj₁ x≤y = contradiction x≤y x≰y ... | inj₂ y≤x = y≤x , x≰y refl sym ≮⇒≥ : Symmetric _≈_ Decidable _≈_ _≈_ _≤_ Total _≤_ @@ -68,7 +68,7 @@ ≮⇒≥ sym _≟_ ≤-refl _≤?_ {x} {y} x≮y with x y | y ≤? x ... | yes x≈y | _ = ≤-refl (sym x≈y) ... | _ | inj₁ y≤x = y≤x -... | no x≉y | inj₂ x≤y = contradiction (x≤y , x≉y) x≮y +... | no x≉y | inj₂ x≤y = contradiction (x≤y , x≉y) x≮y ------------------------------------------------------------------------ -- Relational properties diff --git a/v2.3/Relation.Binary.Construct.StrictToNonStrict.html b/v2.3/Relation.Binary.Construct.StrictToNonStrict.html index c05ed42b4c..938dc0b535 100644 --- a/v2.3/Relation.Binary.Construct.StrictToNonStrict.html +++ b/v2.3/Relation.Binary.Construct.StrictToNonStrict.html @@ -30,7 +30,7 @@ using (Transitive; Symmetric; Irreflexive; Antisymmetric; Trichotomous; Decidable ; Trans; Total; _Respects₂_; _Respectsʳ_; _Respectsˡ_; tri<; tri≈; tri>) open import Relation.Nullary.Decidable.Core using (_⊎-dec_; yes; no) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) ------------------------------------------------------------------------ -- Conversion @@ -61,7 +61,7 @@ as (inj₂ x≈y) _ = x≈y as (inj₁ _) (inj₂ y≈x) = Eq.sym y≈x as (inj₁ x<y) (inj₁ y<x) = - contradiction y<x (trans∧irr⇒asym {_≈_ = _≈_} Eq.refl trans irrefl x<y) + contradiction y<x (trans∧irr⇒asym {_≈_ = _≈_} Eq.refl trans irrefl x<y) trans : IsEquivalence _≈_ _<_ Respects₂ _≈_ Transitive _<_ Transitive _≤_ diff --git a/v2.3/Relation.Binary.HeterogeneousEquality.Quotients.Examples.html b/v2.3/Relation.Binary.HeterogeneousEquality.Quotients.Examples.html index 1eb6f2ef1d..54e7958014 100644 --- a/v2.3/Relation.Binary.HeterogeneousEquality.Quotients.Examples.html +++ b/v2.3/Relation.Binary.HeterogeneousEquality.Quotients.Examples.html @@ -11,7 +11,7 @@ open import Data.Nat.Base using (; zero; suc;_+_) open import Data.Nat.Properties - using (+-assoc; +-comm; +-identityʳ; +-cancelˡ-≡) + using (+-assoc; +-comm; +-identityʳ; +-cancelˡ-≡) open import Data.Product.Base using (_×_; _,_) open import Function.Base open import Level using (0ℓ) @@ -34,16 +34,16 @@ ∼-trans : {i j k} i j j k i k ∼-trans {x₁ , y₁} {x₂ , y₂} {x₃ , y₃} p q = - ≡-to-≅ $ +-cancelˡ-≡ y₂ _ _ $ ≅-to-≡ $ begin - y₂ + (x₁ + y₃) ≡⟨ ≡.sym (+-assoc y₂ x₁ y₃) - y₂ + x₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm y₂ x₁) + ≡-to-≅ $ +-cancelˡ-≡ y₂ _ _ $ ≅-to-≡ $ begin + y₂ + (x₁ + y₃) ≡⟨ ≡.sym (+-assoc y₂ x₁ y₃) + y₂ + x₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm y₂ x₁) x₁ + y₂ + y₃ ≅⟨ cong (_+ y₃) p - x₂ + y₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm x₂ y₁) - y₁ + x₂ + y₃ ≡⟨ +-assoc y₁ x₂ y₃ + x₂ + y₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm x₂ y₁) + y₁ + x₂ + y₃ ≡⟨ +-assoc y₁ x₂ y₃ y₁ + (x₂ + y₃) ≅⟨ cong (y₁ +_) q - y₁ + (x₃ + y₂) ≡⟨ +-comm y₁ (x₃ + y₂) - x₃ + y₂ + y₁ ≡⟨ ≡.cong (_+ y₁) (+-comm x₃ y₂) - y₂ + x₃ + y₁ ≡⟨ +-assoc y₂ x₃ y₁ + y₁ + (x₃ + y₂) ≡⟨ +-comm y₁ (x₃ + y₂) + x₃ + y₂ + y₁ ≡⟨ ≡.cong (_+ y₁) (+-comm x₃ y₂) + y₂ + x₃ + y₁ ≡⟨ +-assoc y₂ x₃ y₁ y₂ + (x₃ + y₁) ∼-isEquivalence : IsEquivalence _∼_ @@ -70,20 +70,20 @@ +²-cong : ∀{a b a′ b′} a a′ b b′ (a b) (a′ b′) +²-cong {a₁ , b₁} {c₁ , d₁} {a₂ , b₂} {c₂ , d₂} ab∼cd₁ ab∼cd₂ = begin - (a₁ + c₁) + (b₂ + d₂) ≡⟨ ≡.cong (_+ (b₂ + d₂)) (+-comm a₁ c₁) - (c₁ + a₁) + (b₂ + d₂) ≡⟨ +-assoc c₁ a₁ (b₂ + d₂) - c₁ + (a₁ + (b₂ + d₂)) ≡⟨ ≡.cong (c₁ +_) (≡.sym (+-assoc a₁ b₂ d₂)) + (a₁ + c₁) + (b₂ + d₂) ≡⟨ ≡.cong (_+ (b₂ + d₂)) (+-comm a₁ c₁) + (c₁ + a₁) + (b₂ + d₂) ≡⟨ +-assoc c₁ a₁ (b₂ + d₂) + c₁ + (a₁ + (b₂ + d₂)) ≡⟨ ≡.cong (c₁ +_) (≡.sym (+-assoc a₁ b₂ d₂)) c₁ + (a₁ + b₂ + d₂) ≅⟨ cong n c₁ + (n + d₂)) ab∼cd₁ - c₁ + (a₂ + b₁ + d₂) ≡⟨ ≡.cong (c₁ +_) (+-assoc a₂ b₁ d₂) - c₁ + (a₂ + (b₁ + d₂)) ≡⟨ ≡.cong n c₁ + (a₂ + n)) (+-comm b₁ d₂) - c₁ + (a₂ + (d₂ + b₁)) ≡⟨ ≡.sym (+-assoc c₁ a₂ (d₂ + b₁)) - (c₁ + a₂) + (d₂ + b₁) ≡⟨ ≡.cong (_+ (d₂ + b₁)) (+-comm c₁ a₂) - (a₂ + c₁) + (d₂ + b₁) ≡⟨ +-assoc a₂ c₁ (d₂ + b₁) - a₂ + (c₁ + (d₂ + b₁)) ≡⟨ ≡.cong (a₂ +_) (≡.sym (+-assoc c₁ d₂ b₁)) + c₁ + (a₂ + b₁ + d₂) ≡⟨ ≡.cong (c₁ +_) (+-assoc a₂ b₁ d₂) + c₁ + (a₂ + (b₁ + d₂)) ≡⟨ ≡.cong n c₁ + (a₂ + n)) (+-comm b₁ d₂) + c₁ + (a₂ + (d₂ + b₁)) ≡⟨ ≡.sym (+-assoc c₁ a₂ (d₂ + b₁)) + (c₁ + a₂) + (d₂ + b₁) ≡⟨ ≡.cong (_+ (d₂ + b₁)) (+-comm c₁ a₂) + (a₂ + c₁) + (d₂ + b₁) ≡⟨ +-assoc a₂ c₁ (d₂ + b₁) + a₂ + (c₁ + (d₂ + b₁)) ≡⟨ ≡.cong (a₂ +_) (≡.sym (+-assoc c₁ d₂ b₁)) a₂ + (c₁ + d₂ + b₁) ≅⟨ cong n a₂ + (n + b₁)) ab∼cd₂ - a₂ + (c₂ + d₁ + b₁) ≡⟨ ≡.cong (a₂ +_) (+-assoc c₂ d₁ b₁) - a₂ + (c₂ + (d₁ + b₁)) ≡⟨ ≡.cong n a₂ + (c₂ + n)) (+-comm d₁ b₁) - a₂ + (c₂ + (b₁ + d₁)) ≡⟨ ≡.sym (+-assoc a₂ c₂ (b₁ + d₁)) + a₂ + (c₂ + d₁ + b₁) ≡⟨ ≡.cong (a₂ +_) (+-assoc c₂ d₁ b₁) + a₂ + (c₂ + (d₁ + b₁)) ≡⟨ ≡.cong n a₂ + (c₂ + n)) (+-comm d₁ b₁) + a₂ + (c₂ + (b₁ + d₁)) ≡⟨ ≡.sym (+-assoc a₂ c₂ (b₁ + d₁)) (a₂ + c₂) + (b₁ + d₁) module _ (ext : {a b} {A : Set a} {B₁ B₂ : A Set b} {f₁ : a B₁ a} @@ -103,8 +103,8 @@ +²-identityʳ : (i : ℕ²) (i zero²) i +²-identityʳ (x , y) = begin - (x + 0) + y ≡⟨ ≡.cong (_+ y) (+-identityʳ x) - x + y ≡⟨ ≡.cong (x +_) (≡.sym (+-identityʳ y)) + (x + 0) + y ≡⟨ ≡.cong (_+ y) (+-identityʳ x) + x + y ≡⟨ ≡.cong (x +_) (≡.sym (+-identityʳ y)) x + (y + 0) +ℤ-on-abs≅abs-+₂ : a b abs a +ℤ abs b abs (a b) @@ -136,8 +136,8 @@ +²-assoc : (i j k : ℕ²) ((i j) k) (i (j k)) +²-assoc (a , b) (c , d) (e , f) = begin - ((a + c) + e) + (b + (d + f)) ≡⟨ ≡.cong (_+ (b + (d + f))) (+-assoc a c e) - (a + (c + e)) + (b + (d + f)) ≡⟨ ≡.cong ((a + (c + e)) +_) (≡.sym (+-assoc b d f)) + ((a + c) + e) + (b + (d + f)) ≡⟨ ≡.cong (_+ (b + (d + f))) (+-assoc a c e) + (a + (c + e)) + (b + (d + f)) ≡⟨ ≡.cong ((a + (c + e)) +_) (≡.sym (+-assoc b d f)) (a + (c + e)) + ((b + d) + f) +ℤ-assoc : i j k (i +ℤ j) +ℤ k i +ℤ (j +ℤ k) diff --git a/v2.3/Relation.Binary.Lattice.Properties.JoinSemilattice.html b/v2.3/Relation.Binary.Lattice.Properties.JoinSemilattice.html index a5fa3827c5..06f53bff58 100644 --- a/v2.3/Relation.Binary.Lattice.Properties.JoinSemilattice.html +++ b/v2.3/Relation.Binary.Lattice.Properties.JoinSemilattice.html @@ -20,7 +20,7 @@ open import Relation.Binary.Structures using (IsDecPartialOrder) open import Relation.Binary.Definitions using (Decidable) open import Relation.Nullary.Decidable.Core using (yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contraposition) +open import Relation.Nullary.Negation.Core using (¬_; contraposition) open JoinSemilattice J @@ -117,7 +117,7 @@ ≈-dec⇒≤-dec : Decidable _≈_ Decidable _≤_ ≈-dec⇒≤-dec _≟_ x y with (x y) y ... | yes x∨y≈y = yes (trans (x≤x∨y x y) (reflexive x∨y≈y)) -... | no x∨y≉y = no (contraposition x≤y⇒x∨y≈y x∨y≉y) +... | no x∨y≉y = no (contraposition x≤y⇒x∨y≈y x∨y≉y) ≈-dec⇒isDecPartialOrder : Decidable _≈_ IsDecPartialOrder _≈_ _≤_ ≈-dec⇒isDecPartialOrder _≟_ = record diff --git a/v2.3/Relation.Binary.Properties.Poset.html b/v2.3/Relation.Binary.Properties.Poset.html index 24fcee53ad..6f60cc9762 100644 --- a/v2.3/Relation.Binary.Properties.Poset.html +++ b/v2.3/Relation.Binary.Properties.Poset.html @@ -22,7 +22,7 @@ open import Relation.Binary.Structures using (IsPartialOrder; IsStrictPartialOrder; IsDecPartialOrder) open import Relation.Nullary.Decidable.Core using (yes; no) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open Poset P renaming (Carrier to A) @@ -109,8 +109,8 @@ ≤-dec⇒≈-dec : Decidable _≤_ Decidable _≈_ ≤-dec⇒≈-dec _≤?_ x y with x ≤? y | y ≤? x ... | yes x≤y | yes y≤x = yes (antisym x≤y y≤x) -... | yes x≤y | no y≰x = no λ x≈y contradiction (reflexive (Eq.sym x≈y)) y≰x -... | no x≰y | _ = no λ x≈y contradiction (reflexive x≈y) x≰y +... | yes x≤y | no y≰x = no λ x≈y contradiction (reflexive (Eq.sym x≈y)) y≰x +... | no x≰y | _ = no λ x≈y contradiction (reflexive x≈y) x≰y ≤-dec⇒isDecPartialOrder : Decidable _≤_ IsDecPartialOrder _≈_ _≤_ ≤-dec⇒isDecPartialOrder _≤?_ = record diff --git a/v2.3/Relation.Binary.Properties.Setoid.html b/v2.3/Relation.Binary.Properties.Setoid.html index 70cdfbcf98..f90ef0de5d 100644 --- a/v2.3/Relation.Binary.Properties.Setoid.html +++ b/v2.3/Relation.Binary.Properties.Setoid.html @@ -20,7 +20,7 @@ using (Symmetric; _Respectsˡ_; _Respectsʳ_; _Respects₂_; Irreflexive) open import Relation.Binary.PropositionalEquality.Core as using (_≡_) open import Relation.Binary.Structures using (IsPreorder; IsPartialOrder) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open Setoid S @@ -83,7 +83,7 @@ ≉-resp₂ = ≉-respʳ , ≉-respˡ ≉-irrefl : Irreflexive _≈_ _≉_ -≉-irrefl x≈y x≉y = contradiction x≈y x≉y +≉-irrefl x≈y x≉y = contradiction x≈y x≉y ------------------------------------------------------------------------ -- Equality is closed under composition diff --git a/v2.3/Relation.Binary.Reasoning.Syntax.html b/v2.3/Relation.Binary.Reasoning.Syntax.html index 9a1a695abc..ea70cebe16 100644 --- a/v2.3/Relation.Binary.Reasoning.Syntax.html +++ b/v2.3/Relation.Binary.Reasoning.Syntax.html @@ -22,7 +22,7 @@ open import Level using (Level; _⊔_; suc) open import Relation.Nullary.Decidable.Core using (Dec; True; toWitness) -open import Relation.Nullary.Negation.Core using (contradiction) +open import Relation.Nullary.Negation.Core using (contradiction) open import Relation.Binary.Core using (Rel; REL; _⇒_) open import Relation.Binary.Definitions using (_Respectsʳ_; Asymmetric; Trans; Sym; Reflexive) @@ -134,7 +134,7 @@ begin-contradiction_ : (xRx : R x x) {s : True (IsS? xRx)} {b} {B : Set b} B - begin-contradiction_ {x} r {s} = contradiction x<x (asym x<x) + begin-contradiction_ {x} r {s} = contradiction x<x (asym x<x) where x<x : S x x x<x = extract (toWitness s) diff --git a/v2.3/Relation.Binary.Rewriting.html b/v2.3/Relation.Binary.Rewriting.html index acc538f56b..38ba835bdb 100644 --- a/v2.3/Relation.Binary.Rewriting.html +++ b/v2.3/Relation.Binary.Rewriting.html @@ -23,7 +23,7 @@ open import Relation.Binary.Construct.Closure.Symmetric using (fwd; bwd) open import Relation.Binary.Construct.Closure.Transitive using (Plus; [_]; _∼⁺⟨_⟩_) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) -- The following definitions are taken from Klop [5] module _ {a } {A : Set a} (_⟶_ : Rel A ) where @@ -81,15 +81,15 @@ conf⇒nf c aIsNF ε = ε conf⇒nf c aIsNF (fwd x rest) = x conf⇒nf c aIsNF rest conf⇒nf c aIsNF (bwd y rest) with c (y ε) (conf⇒nf c aIsNF rest) - ... | _ , _ , x _ = contradiction (_ , x) aIsNF + ... | _ , _ , x _ = contradiction (_ , x) aIsNF ... | _ , left , ε = left conf⇒unf : Confluent _⟶_ UniqueNormalForm _⟶_ conf⇒unf _ _ _ ε = refl - conf⇒unf _ aIsNF _ (fwd x _) = contradiction (_ , x) aIsNF + conf⇒unf _ aIsNF _ (fwd x _) = contradiction (_ , x) aIsNF conf⇒unf c aIsNF bIsNF (bwd y r) with c (y ε) (conf⇒nf c bIsNF r) - ... | _ , ε , x _ = contradiction (_ , x) bIsNF - ... | _ , x _ , _ = contradiction (_ , x) aIsNF + ... | _ , ε , x _ = contradiction (_ , x) bIsNF + ... | _ , x _ , _ = contradiction (_ , x) aIsNF ... | _ , ε , ε = refl un&wn⇒cr : UniqueNormalForm _⟶_ WeaklyNormalizing _⟶_ Confluent _⟶_ diff --git a/v2.3/Relation.Nullary.Decidable.Core.html b/v2.3/Relation.Nullary.Decidable.Core.html index bb96fc5bf6..b14633913a 100644 --- a/v2.3/Relation.Nullary.Decidable.Core.html +++ b/v2.3/Relation.Nullary.Decidable.Core.html @@ -29,7 +29,7 @@ open import Relation.Nullary.Reflects as Reflects hiding (recompute; recompute-constant) open import Relation.Nullary.Negation.Core - using (¬_; Stable; negated-stable; contradiction; DoubleNegation) + using (¬_; Stable; negated-stable; contradiction; DoubleNegation) private @@ -213,10 +213,10 @@ decidable-stable : Dec A Stable A decidable-stable (true because [a]) ¬¬a = invert [a] -decidable-stable (false because [¬a]) ¬¬a = contradiction (invert [¬a]) ¬¬a +decidable-stable (false because [¬a]) ¬¬a = contradiction (invert [¬a]) ¬¬a ¬-drop-Dec : Dec (¬ ¬ A) Dec (¬ A) -¬-drop-Dec ¬¬a? = map′ negated-stable contradiction (¬? ¬¬a?) +¬-drop-Dec ¬¬a? = map′ negated-stable contradiction (¬? ¬¬a?) -- A double-negation-translated variant of excluded middle (or: every -- nullary relation is decidable in the double-negation monad). diff --git a/v2.3/Relation.Nullary.Decidable.html b/v2.3/Relation.Nullary.Decidable.html index 38089b3324..bfa2c906b0 100644 --- a/v2.3/Relation.Nullary.Decidable.html +++ b/v2.3/Relation.Nullary.Decidable.html @@ -17,7 +17,7 @@ open import Relation.Binary.Bundles using (Setoid; module Setoid) open import Relation.Binary.Definitions using (Decidable) open import Relation.Nullary.Irrelevant using (Irrelevant) -open import Relation.Nullary.Negation.Core using (¬_; contradiction) +open import Relation.Nullary.Negation.Core using (¬_; contradiction) open import Relation.Nullary.Reflects using (invert) open import Relation.Binary.PropositionalEquality.Core as using (_≡_; refl; sym; trans) @@ -72,11 +72,11 @@ dec-true : (a? : Dec A) A does a? true dec-true (true because _ ) a = refl -dec-true (false because [¬a]) a = contradiction a (invert [¬a]) +dec-true (false because [¬a]) a = contradiction a (invert [¬a]) dec-false : (a? : Dec A) ¬ A does a? false dec-false (false because _ ) ¬a = refl -dec-false (true because [a]) ¬a = contradiction (invert [a]) ¬a +dec-false (true because [a]) ¬a = contradiction (invert [a]) ¬a dec-yes-recompute : (a? : Dec A) .(a : A) a? yes (recompute a? a) dec-yes-recompute a? a with yes _a? | refldec-true a? (recompute a? a) = refl diff --git a/v2.3/Relation.Nullary.Negation.Core.html b/v2.3/Relation.Nullary.Negation.Core.html index 355f8b2ca7..1712661c32 100644 --- a/v2.3/Relation.Nullary.Negation.Core.html +++ b/v2.3/Relation.Nullary.Negation.Core.html @@ -48,38 +48,38 @@ ------------------------------------------------------------------------ -- Uses of negation -contradiction-irr : .A .(¬ A) Whatever -contradiction-irr a ¬a = ⊥-elim-irr (¬a a) +contradiction-irr : .A ¬ A Whatever +contradiction-irr a ¬a = ⊥-elim-irr (¬a a) -contradiction : A ¬ A Whatever -contradiction a ¬a = contradiction-irr a ¬a +contradiction : A ¬ A Whatever +contradiction a = contradiction-irr a -contradiction₂ : A B ¬ A ¬ B Whatever -contradiction₂ (inj₁ a) ¬a ¬b = contradiction a ¬a -contradiction₂ (inj₂ b) ¬a ¬b = contradiction b ¬b +contradiction₂ : A B ¬ A ¬ B Whatever +contradiction₂ (inj₁ a) ¬a ¬b = contradiction a ¬a +contradiction₂ (inj₂ b) ¬a ¬b = contradiction b ¬b -contraposition : (A B) ¬ B ¬ A -contraposition f ¬b a = contradiction (f a) ¬b +contraposition : (A B) ¬ B ¬ A +contraposition f ¬b a = contradiction (f a) ¬b --- Self-contradictory propositions are false by 'diagonalisation' +-- Self-contradictory propositions are false by 'diagonalisation' -contra-diagonal : (A ¬ A) ¬ A -contra-diagonal self a = self a a +contra-diagonal : (A ¬ A) ¬ A +contra-diagonal self a = self a a --- Everything is stable in the double-negation monad. -stable : ¬ ¬ Stable A -stable ¬[¬¬a→a] = ¬[¬¬a→a] (contradiction (¬[¬¬a→a] const)) +-- Everything is stable in the double-negation monad. +stable : ¬ ¬ Stable A +stable ¬[¬¬a→a] = ¬[¬¬a→a] (contradiction (¬[¬¬a→a] const)) --- Negated predicates are stable. -negated-stable : Stable (¬ A) -negated-stable ¬¬¬a a = ¬¬¬a (contradiction a) +-- Negated predicates are stable. +negated-stable : Stable (¬ A) +negated-stable ¬¬¬a a = ¬¬¬a (contradiction a) -¬¬-map : (A B) ¬ ¬ A ¬ ¬ B -¬¬-map f = contraposition (contraposition f) +¬¬-map : (A B) ¬ ¬ A ¬ ¬ B +¬¬-map f = contraposition (contraposition f) --- Note also the following use of flip: -private - note : (A ¬ B) B ¬ A - note = flip +-- Note also the following use of flip: +private + note : (A ¬ B) B ¬ A + note = flip \ No newline at end of file diff --git a/v2.3/Relation.Nullary.Negation.html b/v2.3/Relation.Nullary.Negation.html index 5725339f8c..c72daccffc 100644 --- a/v2.3/Relation.Nullary.Negation.html +++ b/v2.3/Relation.Nullary.Negation.html @@ -57,8 +57,8 @@ ¬¬-Monad : RawMonad {a} DoubleNegation ¬¬-Monad = mkRawMonad DoubleNegation - contradiction - x f negated-stable (¬¬-map f x)) + contradiction + x f negated-stable (¬¬-map f x)) ¬¬-push : DoubleNegation Π[ P ] Π[ DoubleNegation P ] ¬¬-push ¬¬∀P a ¬Pa = ¬¬∀P ∀P ¬Pa (∀P a)) @@ -73,26 +73,26 @@ -- ⊥). call/cc : ((A Whatever) DoubleNegation A) DoubleNegation A -call/cc hyp ¬a = hyp (flip contradiction ¬a) ¬a +call/cc hyp ¬a = hyp (flip contradiction ¬a) ¬a -- The "independence of premise" rule, in the double-negation monad. -- It is assumed that the index set (A) is inhabited. independence-of-premise : A (B Σ A P) DoubleNegation (Σ[ x A ] (B P x)) -independence-of-premise {A = A} {B = B} {P = P} q f = ¬¬-map helper ¬¬-excluded-middle +independence-of-premise {A = A} {B = B} {P = P} q f = ¬¬-map helper ¬¬-excluded-middle where helper : Dec B Σ[ x A ] (B P x) helper (yes p) = Product.map₂ const (f p) - helper (no ¬p) = (q , flip contradiction ¬p) + helper (no ¬p) = (q , flip contradiction ¬p) -- The independence of premise rule for binary sums. independence-of-premise-⊎ : (A B C) DoubleNegation ((A B) (A C)) -independence-of-premise-⊎ {A = A} {B = B} {C = C} f = ¬¬-map helper ¬¬-excluded-middle +independence-of-premise-⊎ {A = A} {B = B} {C = C} f = ¬¬-map helper ¬¬-excluded-middle where helper : Dec A (A B) (A C) helper (yes p) = Sum.map const const (f p) - helper (no ¬p) = inj₁ (flip contradiction ¬p) + helper (no ¬p) = inj₁ (flip contradiction ¬p) private @@ -102,7 +102,7 @@ corollary : {B C : Set b} (A B C) DoubleNegation ((A B) (A C)) corollary {A = A} {B = B} {C = C} f = - ¬¬-map helper (independence-of-premise true ([ _,_ true , _,_ false ] ∘′ f)) + ¬¬-map helper (independence-of-premise true ([ _,_ true , _,_ false ] ∘′ f)) where helper : b A if b then B else C) (A B) (A C) helper (true , f) = inj₁ f diff --git a/v2.3/Relation.Nullary.Reflects.html b/v2.3/Relation.Nullary.Reflects.html index a9face3dde..893764ca4d 100644 --- a/v2.3/Relation.Nullary.Reflects.html +++ b/v2.3/Relation.Nullary.Reflects.html @@ -19,7 +19,7 @@ open import Level using (Level) open import Function.Base using (_$_; _∘_; const; id) open import Relation.Nullary.Negation.Core - using (¬_; contradiction-irr; contradiction; _¬-⊎_) + using (¬_; contradiction-irr; contradiction; _¬-⊎_) open import Relation.Nullary.Recomputable as Recomputable using (Recomputable) private @@ -104,7 +104,7 @@ Reflects (A B) (not a b) ofʸ a →-reflects ofʸ b = of (const b) ofʸ a →-reflects ofⁿ ¬b = of (¬b (_$ a)) -ofⁿ ¬a →-reflects _ = of a contradiction a ¬a) +ofⁿ ¬a →-reflects _ = of a contradiction a ¬a) ------------------------------------------------------------------------ -- Other lemmas @@ -116,8 +116,8 @@ -- `Reflects` is deterministic. det : {b b′} Reflects A b Reflects A b′ b b′ det (ofʸ a) (ofʸ _) = refl -det (ofʸ a) (ofⁿ ¬a) = contradiction a ¬a -det (ofⁿ ¬a) (ofʸ a) = contradiction a ¬a +det (ofʸ a) (ofⁿ ¬a) = contradiction a ¬a +det (ofⁿ ¬a) (ofʸ a) = contradiction a ¬a det (ofⁿ ¬a) (ofⁿ _) = refl T-reflects-elim : {a b} Reflects (T a) b b a diff --git a/v2.3/Relation.Nullary.Universe.html b/v2.3/Relation.Nullary.Universe.html index 2169967f02..b0663fd76a 100644 --- a/v2.3/Relation.Nullary.Universe.html +++ b/v2.3/Relation.Nullary.Universe.html @@ -10,7 +10,7 @@ module Relation.Nullary.Universe where open import Data.Sum.Base as Sum hiding (map) -open import Data.Sum.Relation.Binary.Pointwise using (_⊎ₛ_; inj₁; inj₂) +open import Data.Sum.Relation.Binary.Pointwise using (_⊎ₛ_; inj₁; inj₂) open import Data.Product.Base as Product hiding (map) open import Data.Product.Relation.Binary.Pointwise.NonDependent using (_×ₛ_) open import Data.Empty using () @@ -20,7 +20,7 @@ open import Function.Indexed.Relation.Binary.Equality using (≡-setoid) open import Level using (Level; _⊔_; suc; Lift; lift; lower) open import Relation.Nullary.Negation - using (¬_; contradiction; ¬¬-Monad; ¬¬-map; negated-stable) + using (¬_; contradiction; ¬¬-Monad; ¬¬-map; negated-stable) open import Relation.Binary.Core using (Rel) open import Relation.Binary.Bundles using (Setoid) import Relation.Binary.Construct.Always as Always using (setoid) @@ -53,7 +53,7 @@ setoid : {p} PropF p Set p Setoid p p setoid Id P = PropEq.setoid P setoid (K P) _ = PropEq.setoid P - setoid (F₁ F₂) P = (setoid F₁ P) ⊎ₛ (setoid F₂ P) + setoid (F₁ F₂) P = (setoid F₁ P) ⊎ₛ (setoid F₂ P) setoid (F₁ F₂) P = (setoid F₁ P) ×ₛ (setoid F₂ P) setoid (P₁ F₂) P = ≡-setoid P₁ (Trivial.indexedSetoid (setoid F₂ P)) @@ -73,13 +73,13 @@ map (F₁ F₂) f FP = Sum.map (map F₁ f) (map F₂ f) FP map (F₁ F₂) f FP = Product.map (map F₁ f) (map F₂ f) FP map (P₁ F₂) f FP = map F₂ f FP -map (¬¬ F) f FP = ¬¬-map (map F f) FP +map (¬¬ F) f FP = ¬¬-map (map F f) FP map-id : {p} (F : PropF p) {P} F P F map F id id map-id Id x = refl map-id (K P) x = refl -map-id (F₁ F₂) (inj₁ x) = inj₁ (map-id F₁ x) -map-id (F₁ F₂) (inj₂ y) = inj₂ (map-id F₂ y) +map-id (F₁ F₂) (inj₁ x) = inj₁ (map-id F₁ x) +map-id (F₁ F₂) (inj₂ y) = inj₂ (map-id F₂ y) map-id (F₁ F₂) (x , y) = (map-id F₁ x , map-id F₂ y) map-id (P₁ F₂) f = λ x map-id F₂ (f x) map-id (¬¬ F) ¬¬x = _ @@ -88,8 +88,8 @@ F P F map F f map F g map F (f g) map-∘ Id f g x = refl map-∘ (K P) f g x = refl -map-∘ (F₁ F₂) f g (inj₁ x) = inj₁ (map-∘ F₁ f g x) -map-∘ (F₁ F₂) f g (inj₂ y) = inj₂ (map-∘ F₂ f g y) +map-∘ (F₁ F₂) f g (inj₁ x) = inj₁ (map-∘ F₁ f g x) +map-∘ (F₁ F₂) f g (inj₂ y) = inj₂ (map-∘ F₂ f g y) map-∘ (F₁ F₂) f g x = (map-∘ F₁ f g (proj₁ x) , map-∘ F₂ f g (proj₂ x)) map-∘ (P₁ F₂) f g h = λ x map-∘ F₂ f g (h x) @@ -124,9 +124,9 @@ F (¬ ¬ P) ¬ ¬ F P ¬¬-pull = sequence rawApplicative f f lower) - f g g x contradiction y g _ y)) (f x))) + f g g x contradiction y g _ y)) (f x))) ¬¬-remove : {p} (F : PropF p) {P} ¬ ¬ F (¬ ¬ P) ¬ ¬ F P -¬¬-remove F = negated-stable ¬¬-pull (¬¬ F) +¬¬-remove F = negated-stable ¬¬-pull (¬¬ F) \ No newline at end of file diff --git a/v2.3/Relation.Unary.Algebra.html b/v2.3/Relation.Unary.Algebra.html index bc81a4c8b3..7d95e9d0b8 100644 --- a/v2.3/Relation.Unary.Algebra.html +++ b/v2.3/Relation.Unary.Algebra.html @@ -20,8 +20,8 @@ using (IsLattice; IsDistributiveLattice; IsSemilattice) import Algebra.Structures as AlgebraicStructures using (IsMagma; IsSemigroup; IsBand; IsMonoid; IsCommutativeMonoid - ; IsIdempotentCommutativeMonoid; IsSemiringWithoutAnnihilatingZero - ; IsSemiring; IsCommutativeSemiring) + ; IsIdempotentCommutativeMonoid; IsSemiringWithoutAnnihilatingZero + ; IsSemiring; IsCommutativeSemiring) open import Data.Empty.Polymorphic using (⊥-elim) open import Data.Product.Base as Product using (_,_; proj₁; proj₂; <_,_>; curry; uncurry) @@ -237,25 +237,25 @@ ------------------------------------------------------------------------ -- Algebraic structures of _∩_ and _∪_ - ∪-∩-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _∪_ _∩_ U + ∪-∩-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _∪_ _∩_ U ∪-∩-isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = ∪-isCommutativeMonoid - ; *-cong = ∩-cong - ; *-assoc = ∩-assoc - ; *-identity = ∩-identity - ; distrib = ∩-distrib-∪ + { +-isCommutativeMonoid = ∪-isCommutativeMonoid + ; *-cong = ∩-cong + ; *-assoc = ∩-assoc + ; *-identity = ∩-identity + ; distrib = ∩-distrib-∪ } - ∪-∩-isSemiring : IsSemiring _∪_ _∩_ U + ∪-∩-isSemiring : IsSemiring _∪_ _∩_ U ∪-∩-isSemiring = record - { isSemiringWithoutAnnihilatingZero = ∪-∩-isSemiringWithoutAnnihilatingZero - ; zero = ∩-zero + { isSemiringWithoutAnnihilatingZero = ∪-∩-isSemiringWithoutAnnihilatingZero + ; zero = ∩-zero } - ∪-∩-isCommutativeSemiring : IsCommutativeSemiring _∪_ _∩_ U + ∪-∩-isCommutativeSemiring : IsCommutativeSemiring _∪_ _∩_ U ∪-∩-isCommutativeSemiring = record - { isSemiring = ∪-∩-isSemiring - ; *-comm = ∩-comm + { isSemiring = ∪-∩-isSemiring + ; *-comm = ∩-comm } ∪-∩-isLattice : IsLattice _∪_ _∩_ @@ -277,13 +277,13 @@ ; ∧-distrib-∨ = ∩-distrib-∪ } - ∩-∪-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _∩_ _∪_ U + ∩-∪-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _∩_ _∪_ U ∩-∪-isSemiringWithoutAnnihilatingZero = record - { +-isCommutativeMonoid = ∩-isCommutativeMonoid - ; *-cong = ∪-cong - ; *-assoc = ∪-assoc - ; *-identity = ∪-identity - ; distrib = ∪-distrib-∩ + { +-isCommutativeMonoid = ∩-isCommutativeMonoid + ; *-cong = ∪-cong + ; *-assoc = ∪-assoc + ; *-identity = ∪-identity + ; distrib = ∪-distrib-∩ } ------------------------------------------------------------------------ diff --git a/v2.3/System.Clock.html b/v2.3/System.Clock.html index 05d96292c5..b09687afec 100644 --- a/v2.3/System.Clock.html +++ b/v2.3/System.Clock.html @@ -105,6 +105,6 @@ show (mkTime s ns) prec = secs ++ "s" ++ padLeft '0' decimals nsecs where decimals = toℕ prec secs = ℕ.show s - prf = ℕ.m^n≢0 10 (9 decimals) + prf = ℕ.m^n≢0 10 (9 decimals) nsecs = ℕ.show ((ns / (10 ^ (9 decimals))) {{prf}}) \ No newline at end of file diff --git a/v2.3/System.Random.html b/v2.3/System.Random.html index 81cd291a33..1f355b6f82 100644 --- a/v2.3/System.Random.html +++ b/v2.3/System.Random.html @@ -119,17 +119,17 @@ toℕ-cancel-InBounds {n} {lo} {hi} (k ∈[ toℕlo≤k , k≤toℕhi ]) = let .k<n : k ℕ.< n - k<n = ℕ.≤-<-trans k≤toℕhi (Fin.toℕ<n hi) + k<n = ℕ.≤-<-trans k≤toℕhi (Fin.toℕ<n hi) .lo≤k : lo fromℕ< k<n - lo≤k = Fin.toℕ-cancel-≤ $ let open ℕ.≤-Reasoning in begin + lo≤k = Fin.toℕ-cancel-≤ $ let open ℕ.≤-Reasoning in begin toℕ lo ≤⟨ toℕlo≤k - k ≡⟨ Fin.toℕ-fromℕ< k<n + k ≡⟨ Fin.toℕ-fromℕ< k<n toℕ (fromℕ< k<n) .k≤hi : fromℕ< k<n hi - k≤hi = Fin.toℕ-cancel-≤ $ let open ℕ.≤-Reasoning in begin - toℕ (fromℕ< k<n) ≡⟨ Fin.toℕ-fromℕ< k<n + k≤hi = Fin.toℕ-cancel-≤ $ let open ℕ.≤-Reasoning in begin + toℕ (fromℕ< k<n) ≡⟨ Fin.toℕ-fromℕ< k<n k ≤⟨ k≤toℕhi toℕ hi @@ -137,7 +137,7 @@ randomRIO : {n} RandomRIO {A = Fin n} _≤_ randomRIO {n} lo hi p = do - k ℕ.randomRIO (toℕ lo) (toℕ hi) (Fin.toℕ-mono-≤ p) + k ℕ.randomRIO (toℕ lo) (toℕ hi) (Fin.toℕ-mono-≤ p) pure (toℕ-cancel-InBounds k) module List {a} {A : Set a} (rIO : IO A) where diff --git a/v2.3/Tactic.RingSolver.Core.AlmostCommutativeRing.html b/v2.3/Tactic.RingSolver.Core.AlmostCommutativeRing.html index e638c230aa..9b5c93c750 100644 --- a/v2.3/Tactic.RingSolver.Core.AlmostCommutativeRing.html +++ b/v2.3/Tactic.RingSolver.Core.AlmostCommutativeRing.html @@ -12,7 +12,7 @@ open import Level open import Relation.Binary.Core using (Rel; _Preserves_⟶_) open import Algebra.Core using (Op₁; Op₂) -open import Algebra.Structures using (IsCommutativeSemiring) +open import Algebra.Structures using (IsCommutativeSemiring) open import Algebra.Definitions open import Algebra.Bundles using (RawRing; CommutativeRing; CommutativeSemiring) import Algebra.Morphism as Morphism @@ -24,12 +24,12 @@ {a } {A : Set a} (_≈_ : Rel A ) (_+_ _*_ : A A A) (-_ : A A) (0# 1# : A) : Set (a ) where field - isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# + isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# -‿cong : -_ Preserves _≈_ _≈_ -‿*-distribˡ : x y ((- x) * y) (- (x * y)) -‿+-comm : x y ((- x) + (- y)) (- (x + y)) - open IsCommutativeSemiring isCommutativeSemiring public + open IsCommutativeSemiring isCommutativeSemiring public import Algebra.Definitions.RawSemiring as Exp @@ -136,9 +136,9 @@ AlmostCommutativeRing _ _ fromCommutativeRing CR 0≟_ = record { isAlmostCommutativeRing = record - { isCommutativeSemiring = isCommutativeSemiring - ; -‿cong = -‿cong - ; -‿*-distribˡ = λ x y sym (-‿distribˡ-* x y) + { isCommutativeSemiring = isCommutativeSemiring + ; -‿cong = -‿cong + ; -‿*-distribˡ = λ x y sym (-‿distribˡ-* x y) ; -‿+-comm = ⁻¹-∙-comm } ; 0≟_ = 0≟_ diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Base.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Base.html index 779765ebf2..38f25c3805 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Base.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Base.html @@ -56,7 +56,7 @@ open import Data.Fin.Base as Fin using (Fin; zero; suc) open import Data.List.Kleene open import Data.Nat.Base as using (; suc; zero; _≤′_; compare; ≤′-refl; ≤′-step; _<′_) -open import Data.Nat.Properties using (z≤′n; ≤′-trans) +open import Data.Nat.Properties using (z≤′n; ≤′-trans) open import Data.Nat.Induction open import Data.Product.Base using (_×_; _,_; map₁; curry; uncurry) open import Data.Unit.Base using (; tt) @@ -76,10 +76,10 @@ data InjectionOrdering {n : } : {i j} (i≤n : i ≤′ n) (j≤n : j ≤′ n) Set where inj-lt : {i j-1} (i≤j-1 : i ≤′ j-1) (j≤n : suc j-1 ≤′ n) - InjectionOrdering (≤′-step i≤j-1 ≤′-trans j≤n) j≤n + InjectionOrdering (≤′-step i≤j-1 ≤′-trans j≤n) j≤n inj-gt : {i-1 j} (i≤n : suc i-1 ≤′ n) (j≤i-1 : j ≤′ i-1) - InjectionOrdering i≤n (≤′-step j≤i-1 ≤′-trans i≤n) + InjectionOrdering i≤n (≤′-step j≤i-1 ≤′-trans i≤n) inj-eq : {i} (i≤n : i ≤′ n) InjectionOrdering i≤n i≤n @@ -202,12 +202,12 @@ -- Inject a polynomial into a larger polynomial with more variables _⊐↑_ : {n m} Poly n (suc n ≤′ m) Poly m -(xs i≤n) ⊐↑ n≤m = xs (≤′-step i≤n ≤′-trans n≤m) +(xs i≤n) ⊐↑ n≤m = xs (≤′-step i≤n ≤′-trans n≤m) {-# INLINE _⊐↑_ #-} infixr 4 _⊐↓_ _⊐↓_ : {i n} Coeff i * suc i ≤′ n Poly n -[] ⊐↓ i≤n = Κ 0# z≤′n +[] ⊐↓ i≤n = Κ 0# z≤′n ( (x ≠0 Δ zero & [] )) ⊐↓ i≤n = x ⊐↑ i≤n ( (x Δ zero & xs)) ⊐↓ i≤n = (x Δ zero & xs) i≤n ( (x Δ suc j & xs )) ⊐↓ i≤n = (x Δ suc j & xs) i≤n @@ -391,7 +391,7 @@ -- The constant polynomial κ : {n} Carrier Poly n -κ x = Κ x z≤′n +κ x = Κ x z≤′n {-# INLINE κ #-} -- A variable diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition.html index b54de9a770..d9f2bd33a7 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition.html @@ -15,7 +15,7 @@ where open import Data.Nat.Base as using (; suc; zero; compare; _≤′_; ≤′-step; ≤′-refl) -open import Data.Nat.Properties as using (≤′-trans) +open import Data.Nat.Properties as using (≤′-trans) open import Data.Product.Base using (_,_; _×_; proj₂) open import Data.List.Base using (_∷_; []) open import Data.List.Kleene @@ -60,9 +60,9 @@ ≈⟨ ⊞-inj-hom j≤i-1 ys xs ρ Ρ′ ys j≤i-1 (proj₂ (drop-1 i≤n Ρ)) + ⅀⟦ xs (drop-1 i≤n Ρ) ≈⟨ ≪+ trans-join-hom j≤i-1 i≤n ys Ρ - ys (≤′-step j≤i-1 ≤′-trans i≤n) Ρ + ⅀⟦ xs (drop-1 i≤n Ρ) - ≈⟨ +-comm _ _ - ⅀⟦ xs (drop-1 i≤n Ρ) + ys (≤′-step j≤i-1 ≤′-trans i≤n) Ρ + ys (≤′-step j≤i-1 ≤′-trans i≤n) Ρ + ⅀⟦ xs (drop-1 i≤n Ρ) + ≈⟨ +-comm _ _ + ⅀⟦ xs (drop-1 i≤n Ρ) + ys (≤′-step j≤i-1 ≤′-trans i≤n) Ρ ⊞-match-hom (inj-lt i≤j-1 j≤n) xs ( ys) Ρ = let (ρ , Ρ′) = drop-1 j≤n Ρ @@ -74,7 +74,7 @@ ≈⟨ ⊞-inj-hom i≤j-1 xs ys ρ Ρ′ xs i≤j-1 (proj₂ (drop-1 j≤n Ρ)) + ⅀⟦ ys (drop-1 j≤n Ρ) ≈⟨ ≪+ trans-join-hom i≤j-1 j≤n xs Ρ - xs (≤′-step i≤j-1 ≤′-trans j≤n) Ρ + ⅀⟦ ys (drop-1 j≤n Ρ) + xs (≤′-step i≤j-1 ≤′-trans j≤n) Ρ + ⅀⟦ ys (drop-1 j≤n Ρ) ⊞-inj-hom : {i k} @@ -91,7 +91,7 @@ ⊞-match (inj-compare j≤k i≤k) y xs Ρ ≈⟨ ⊞-match-hom (inj-compare j≤k i≤k) y xs Ρ ( y j≤k Ρ + xs i≤k Ρ) - ≈⟨ +-comm _ _ + ≈⟨ +-comm _ _ xs i≤k Ρ + ( y j≤k Ρ) ⊞-inj-hom i≤k xs (y j≤k ≠0 Δ 0 & ( ys )) ρ Ρ = @@ -101,7 +101,7 @@ ρ * ⅀⟦ ys (ρ , Ρ) + ⊞-match (inj-compare j≤k i≤k) y xs Ρ ≈⟨ +≫ ⊞-match-hom (inj-compare j≤k i≤k) y xs Ρ ρ * ⅀⟦ ys (ρ , Ρ) + ( y j≤k Ρ + xs i≤k Ρ) - ≈⟨ sym (+-assoc _ _ _) trans +-comm _ _ + ≈⟨ sym (+-assoc _ _ _) trans +-comm _ _ xs i≤k Ρ + (ρ * ⅀⟦ ys (ρ , Ρ) + y j≤k Ρ) ⊞-inj-hom i≤k xs (y Δ suc j & ys) ρ Ρ = @@ -111,7 +111,7 @@ ⅀?⟦ xs i≤k Δ 0 ∷↓ ( y Δ j & ys ) (ρ , Ρ) ≈⟨ ∷↓-hom-0 (xs i≤k) ( y Δ j & ys ) ρ Ρ ρ * ⅀⟦ y Δ j & ys (ρ , Ρ) + xs i≤k Ρ - ≈⟨ +-comm _ _ + ≈⟨ +-comm _ _ xs i≤k Ρ + ρ * ⅀⟦ y Δ j & ys (ρ , Ρ) ≈⟨ +≫ ( begin @@ -120,7 +120,7 @@ ρ * (((poly y , ys) ⟦∷⟧ (ρ , Ρ)) *⟨ ρ ⟩^ j) ≈⟨ *≫ pow-opt _ ρ j ρ * (ρ ^ j * ((poly y , ys) ⟦∷⟧ (ρ , Ρ))) - ≈⟨ sym (*-assoc ρ _ _) + ≈⟨ sym (*-assoc ρ _ _) ρ * ρ ^ j * ((poly y , ys) ⟦∷⟧ (ρ , Ρ)) ≈⟨ ≪* sym (pow-suc ρ j) ⅀⟦ y Δ suc j & ys (ρ , Ρ) @@ -130,7 +130,7 @@ ⊞-coeffs-hom : {n} (xs : Coeff n *) (ys : Coeff n *) ρ ⅀?⟦ ⊞-coeffs xs ys ρ ⅀?⟦ xs ρ + ⅀?⟦ ys ρ - ⊞-coeffs-hom [] ys Ρ = sym (+-identityˡ (⅀?⟦ ys Ρ)) + ⊞-coeffs-hom [] ys Ρ = sym (+-identityˡ (⅀?⟦ ys Ρ)) ⊞-coeffs-hom ( x Δ i & xs ) = ⊞-zip-r-hom i x xs ⊞-zip-hom : {n i j} @@ -154,24 +154,24 @@ ρ ^ i * (ρ * ⅀?⟦ ⊞-coeffs xs ys (ρ , Ρ) + x y Ρ) ≈⟨ *≫ begin ρ * ⅀?⟦ ⊞-coeffs xs ys (ρ , Ρ) + x y Ρ - ≈⟨ (*≫ ⊞-coeffs-hom xs ys (ρ , Ρ)) +-cong ⊞-hom x y Ρ + ≈⟨ (*≫ ⊞-coeffs-hom xs ys (ρ , Ρ)) +-cong ⊞-hom x y Ρ ρ * (xs′ + ys′) + (x′ + y′) - ≈⟨ ≪+ distribˡ ρ xs′ ys′ + ≈⟨ ≪+ distribˡ ρ xs′ ys′ ρ * xs′ + ρ * ys′ + (x′ + y′) - ≈⟨ +-assoc _ _ _ trans (+≫ (sym (+-assoc _ _ _) trans (≪+ +-comm _ _))) + ≈⟨ +-assoc _ _ _ trans (+≫ (sym (+-assoc _ _ _) trans (≪+ +-comm _ _))) ρ * xs′ + (x′ + ρ * ys′ + y′) - ≈⟨ (+≫ +-assoc _ _ _) trans sym (+-assoc _ _ _) + ≈⟨ (+≫ +-assoc _ _ _) trans sym (+-assoc _ _ _) (ρ * xs′ + x′) + (ρ * ys′ + y′) ρ ^ i * ((ρ * xs′ + x′) + (ρ * ys′ + y′)) - ≈⟨ distribˡ (ρ ^ i) _ _ + ≈⟨ distribˡ (ρ ^ i) _ _ ρ ^ i * (ρ * xs′ + x′) + ρ ^ i * (ρ * ys′ + y′) - ≈⟨ sym (pow-opt _ ρ i +-cong pow-opt _ ρ i) + ≈⟨ sym (pow-opt _ ρ i +-cong pow-opt _ ρ i) (ρ * xs′ + x′) *⟨ ρ ⟩^ i + (ρ * ys′ + y′) *⟨ ρ ⟩^ i - ≈⟨ pow-mul-cong (sym (⟦∷⟧-hom x xs ρ Ρ)) ρ i +-cong pow-mul-cong (sym (⟦∷⟧-hom y ys ρ Ρ)) ρ i + ≈⟨ pow-mul-cong (sym (⟦∷⟧-hom x xs ρ Ρ)) ρ i +-cong pow-mul-cong (sym (⟦∷⟧-hom y ys ρ Ρ)) ρ i ((x , xs) ⟦∷⟧ (ρ , Ρ)) *⟨ ρ ⟩^ i + ((y , ys) ⟦∷⟧ (ρ , Ρ)) *⟨ ρ ⟩^ i - ⊞-zip-hom (ℕ.less i k) x xs y ys (ρ , Ρ) = ⊞-zip-r-step-hom i k y ys x xs (ρ , Ρ) +-comm _ _ + ⊞-zip-hom (ℕ.less i k) x xs y ys (ρ , Ρ) = ⊞-zip-r-step-hom i k y ys x xs (ρ , Ρ) +-comm _ _ ⊞-zip-hom (ℕ.greater j k) = ⊞-zip-r-step-hom j k ⊞-zip-r-step-hom : {n} j k @@ -194,25 +194,25 @@ ρ ^ j * (ρ * ⅀?⟦ ⊞-zip-r x k xs ys (ρ , Ρ) + y′) ≈⟨ *≫ ≪+ *≫ (⊞-zip-r-hom k x xs ys (ρ , Ρ) trans (≪+ pow-mul-cong (⟦∷⟧-hom (poly x) xs ρ Ρ) ρ k)) ρ ^ j * (ρ * ((ρ * xs′ + x′) *⟨ ρ ⟩^ k + ys′) + y′) - ≈⟨ *≫ ≪+ distribˡ ρ _ _ + ≈⟨ *≫ ≪+ distribˡ ρ _ _ ρ ^ j * ((ρ * (ρ * xs′ + x′) *⟨ ρ ⟩^ k + ρ * ys′) + y′) - ≈⟨ *≫ +-assoc _ _ _ + ≈⟨ *≫ +-assoc _ _ _ ρ ^ j * (ρ * (ρ * xs′ + x′) *⟨ ρ ⟩^ k + (ρ * ys′ + y′)) - ≈⟨ distribˡ _ _ _ + ≈⟨ distribˡ _ _ _ ρ ^ j * (ρ * (ρ * xs′ + x′) *⟨ ρ ⟩^ k) + ρ ^ j * (ρ * ys′ + y′) - ≈⟨ sym (pow-opt _ ρ j) flip +-cong + ≈⟨ sym (pow-opt _ ρ j) flip +-cong (begin ρ ^ j * (ρ * ((ρ * ⅀?⟦ xs (ρ , Ρ) + poly x Ρ) *⟨ ρ ⟩^ k)) - ≈⟨ (sym (*-assoc _ _ _) trans (≪* sym (pow-sucʳ ρ j))) + ≈⟨ (sym (*-assoc _ _ _) trans (≪* sym (pow-sucʳ ρ j))) ρ ^ suc j * ((ρ * ⅀?⟦ xs (ρ , Ρ) + poly x Ρ) *⟨ ρ ⟩^ k) ≈⟨ pow-add _ _ k j (ρ * ⅀?⟦ xs (ρ , Ρ) + poly x Ρ) *⟨ ρ ⟩^ (k ℕ.+ suc j) - ≡⟨ ≡.cong i (ρ * ⅀?⟦ xs (ρ , Ρ) + poly x Ρ) *⟨ ρ ⟩^ i) (ℕ.+-comm k (suc j)) + ≡⟨ ≡.cong i (ρ * ⅀?⟦ xs (ρ , Ρ) + poly x Ρ) *⟨ ρ ⟩^ i) (ℕ.+-comm k (suc j)) (ρ * ⅀?⟦ xs (ρ , Ρ) + poly x Ρ) *⟨ ρ ⟩^ (suc j ℕ.+ k) ) (ρ * xs′ + x′) *⟨ ρ ⟩^ suc (j ℕ.+ k) + (ρ * ys′ + y′) *⟨ ρ ⟩^ j - ≈⟨ pow-mul-cong (sym (⟦∷⟧-hom (poly x) xs ρ Ρ)) ρ (suc (j ℕ.+ k)) +-cong pow-mul-cong (sym (⟦∷⟧-hom (poly y) ys ρ Ρ)) ρ j + ≈⟨ pow-mul-cong (sym (⟦∷⟧-hom (poly x) xs ρ Ρ)) ρ (suc (j ℕ.+ k)) +-cong pow-mul-cong (sym (⟦∷⟧-hom (poly y) ys ρ Ρ)) ρ j ((poly x , xs) ⟦∷⟧ (ρ , Ρ)) *⟨ ρ ⟩^ suc (j ℕ.+ k) + ((poly y , ys) ⟦∷⟧ (ρ , Ρ)) *⟨ ρ ⟩^ j @@ -221,6 +221,6 @@ (xs ys : Coeff n *) (Ρ : Carrier × Vec Carrier n) ⅀?⟦ ⊞-zip-r x i xs ys (Ρ) ⅀⟦ x Δ i & xs ( Ρ) + ⅀?⟦ ys ( Ρ) - ⊞-zip-r-hom i x xs [] (ρ , Ρ) = sym (+-identityʳ _) + ⊞-zip-r-hom i x xs [] (ρ , Ρ) = sym (+-identityʳ _) ⊞-zip-r-hom i x xs ( (y Δ j) & ys ) = ⊞-zip-hom (compare i j) x xs y ys \ No newline at end of file diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation.html index a090539865..a9b7abb1e8 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation.html @@ -65,15 +65,15 @@ rearrange zero = begin (ρ′ RawPow.^ (i ℕ.* 0)) * ( x Ρ RawPow.^ suc i) - ≡⟨ ≡.cong k (ρ′ RawPow.^ k) * ( x Ρ RawPow.^ suc i)) (ℕ.*-zeroʳ i) + ≡⟨ ≡.cong k (ρ′ RawPow.^ k) * ( x Ρ RawPow.^ suc i)) (ℕ.*-zeroʳ i) 1# * ( x Ρ RawPow.^ suc i) - ≈⟨ *-identityˡ _ + ≈⟨ *-identityˡ _ x Ρ RawPow.^ suc i rearrange j@(suc j′) = begin (ρ′ RawPow.^ (suc i ℕ.* j)) * ( x Ρ RawPow.^ suc i) - ≡⟨ ≡.cong v (ρ′ RawPow.^ v) * ( x Ρ RawPow.^ suc i)) (ℕ.*-comm (suc i) j) + ≡⟨ ≡.cong v (ρ′ RawPow.^ v) * ( x Ρ RawPow.^ suc i)) (ℕ.*-comm (suc i) j) (ρ′ RawPow.^ (j ℕ.* suc i)) * ( x Ρ RawPow.^ suc i) ≈⟨ ≪* sym (RawPow.^-assocʳ ρ′ j (suc i)) ((ρ′ RawPow.^ suc j′) RawPow.^ suc i) * ( x Ρ RawPow.^ suc i) diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas.html index 434f41858f..407f3e65b9 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas.html @@ -16,7 +16,7 @@ open import Data.Bool.Base using (Bool;true;false) open import Data.Nat.Base as using (; suc; zero; compare; _≤′_; ≤′-step; ≤′-refl) -open import Data.Nat.Properties as using (≤′-trans) +open import Data.Nat.Properties as using (≤′-trans) open import Data.Vec.Base as Vec using (Vec; _∷_) open import Data.Fin.Base using (Fin; zero; suc) open import Data.List.Base using (_∷_; []) @@ -44,7 +44,7 @@ -- First, that the optimised operator is the same as normal -- exponentiation. pow-opt : x ρ i x *⟨ ρ ⟩^ i ρ ^ i * x -pow-opt x ρ zero = sym (*-identityˡ x) +pow-opt x ρ zero = sym (*-identityˡ x) pow-opt x ρ (suc i) = refl pow-add : x y i j y ^ (suc j) * x *⟨ y ⟩^ i x *⟨ y ⟩^ (i ℕ.+ suc j) @@ -52,11 +52,11 @@ pow-add x y (suc i) j = go x y i j where go : x y i j (y ^ suc j) * ((y ^ suc i) * x) y ^ suc (i ℕ.+ suc j) * x - go x y zero j = sym (*-assoc _ _ _) + go x y zero j = sym (*-assoc _ _ _) go x y (suc i) j = begin - (y ^ suc j) * (y ^ (suc i) * y * x) ≈⟨ *≫ *-assoc _ y x + (y ^ suc j) * (y ^ (suc i) * y * x) ≈⟨ *≫ *-assoc _ y x (y ^ suc j) * (y ^ (suc i) * (y * x)) ≈⟨ go (y * x) y i j - y ^ suc (i ℕ.+ suc j) * (y * x) ≈⟨ sym (*-assoc _ y x) + y ^ suc (i ℕ.+ suc j) * (y * x) ≈⟨ sym (*-assoc _ y x) y ^ suc (suc i ℕ.+ suc j) * x -- Here we show a homomorphism on exponentiation, i.e. that using the @@ -66,7 +66,7 @@ (xs : Coeff n +) ρ ρs ⅀⟦ xs (ρ , ρs) *⟨ ρ ⟩^ i ⅀⟦ xs ⍓+ i (ρ , ρs) -pow-hom zero (x Δ j & xs) ρ ρs rewrite ℕ.+-identityʳ j = refl +pow-hom zero (x Δ j & xs) ρ ρs rewrite ℕ.+-identityʳ j = refl pow-hom (suc i) (x ≠0 Δ j & xs) ρ ρs = begin ρ ^ (suc i) * (((x , xs) ⟦∷⟧ (ρ , ρs)) *⟨ ρ ⟩^ j) @@ -86,12 +86,12 @@ -- x¹⁺ⁿ = xxⁿ pow-suc : x i x ^ suc i x * x ^ i -pow-suc x zero = sym (*-identityʳ _) -pow-suc x (suc i) = *-comm _ _ +pow-suc x zero = sym (*-identityʳ _) +pow-suc x (suc i) = *-comm _ _ -- x¹⁺ⁿ = xⁿx pow-sucʳ : x i x ^ suc i x ^ i * x -pow-sucʳ x zero = sym (*-identityˡ _) +pow-sucʳ x zero = sym (*-identityˡ _) pow-sucʳ x (suc i) = refl -- In the proper evaluation function, we avoid ever inserting an @@ -110,12 +110,12 @@ ⟦∷⟧?-hom : {n} (x : Poly n) xs ρ ρs (x , xs) ⟦∷⟧? (ρ , ρs) (x , xs) ⟦∷⟧ (ρ , ρs) ⟦∷⟧?-hom x ( xs ) ρ ρs = refl -⟦∷⟧?-hom x [] ρ ρs = (≪+ zeroʳ _) trans +-identityˡ _ +⟦∷⟧?-hom x [] ρ ρs = (≪+ zeroʳ _) trans +-identityˡ _ pow′-hom : {n} i (xs : Coeff n *) ρ ρs ((⅀?⟦ xs (ρ , ρs)) *⟨ ρ ⟩^ i) (⅀?⟦ xs ⍓* i (ρ , ρs)) pow′-hom i ( xs ) ρ ρs = pow-hom i xs ρ ρs pow′-hom zero [] ρ ρs = refl -pow′-hom (suc i) [] ρ ρs = zeroʳ _ +pow′-hom (suc i) [] ρ ρs = zeroʳ _ -- Here, we show that the normalising cons is correct. -- This lets us prove with respect to the non-normalising form, @@ -129,22 +129,22 @@ ⅀⟦ xs ⍓+ 1 (ρ , ρs) ≈⟨ sym (pow-hom 1 xs ρ ρs) ρ * ⅀⟦ xs (ρ , ρs) - ≈⟨ sym (+-identityʳ _) trans (+≫ zero-hom x p ρs) + ≈⟨ sym (+-identityʳ _) trans (+≫ zero-hom x p ρs) ρ * ⅀⟦ xs (ρ , ρs) + x ρs ∷↓-hom-s : {n} (x : Poly n) i xs ρ ρs ⅀?⟦ x Δ suc i ∷↓ xs (ρ , ρs) (ρ ^ suc i) * (x , xs) ⟦∷⟧ (ρ , ρs) ∷↓-hom-s x i xs ρ ρs with zero? x ∷↓-hom-s x i xs ρ ρs | no ¬p = refl -∷↓-hom-s x i [] ρ ρs | yes p = sym ((*≫ sym (zero-hom x p ρs)) trans zeroʳ _) +∷↓-hom-s x i [] ρ ρs | yes p = sym ((*≫ sym (zero-hom x p ρs)) trans zeroʳ _) ∷↓-hom-s x i ( xs ) ρ ρs | yes p = begin ⅀⟦ xs ⍓+ (suc (suc i)) (ρ , ρs) ≈⟨ sym (pow-hom (suc (suc i)) xs ρ ρs) (ρ ^ suc (suc i)) * ⅀⟦ xs (ρ , ρs) - ≈⟨ *-assoc _ _ _ + ≈⟨ *-assoc _ _ _ (ρ ^ suc i) * (ρ * ⅀⟦ xs (ρ , ρs)) - ≈⟨ *≫ (sym (+-identityʳ _) trans (+≫ zero-hom x p ρs)) + ≈⟨ *≫ (sym (+-identityʳ _) trans (+≫ zero-hom x p ρs)) (ρ ^ suc i) * (ρ * ⅀⟦ xs (ρ , ρs) + x ρs) @@ -152,14 +152,14 @@ (x : Poly n) i xs ρ ρs ⅀?⟦ x Δ i ∷↓ xs (ρ , ρs) ρ ^ i * ((x , xs) ⟦∷⟧ (ρ , ρs)) -∷↓-hom x zero xs ρ ρs = ∷↓-hom-0 x xs ρ ρs trans sym (*-identityˡ _) +∷↓-hom x zero xs ρ ρs = ∷↓-hom-0 x xs ρ ρs trans sym (*-identityˡ _) ∷↓-hom x (suc i) xs ρ ρs = ∷↓-hom-s x i xs ρ ρs ⟦∷⟧-hom : {n} (x : Poly n) (xs : Coeff n *) ρ ρs (x , xs) ⟦∷⟧ (ρ , ρs) ρ * ⅀?⟦ xs (ρ , ρs) + x ρs -⟦∷⟧-hom x [] ρ ρs = sym ((≪+ zeroʳ _) trans +-identityˡ _) +⟦∷⟧-hom x [] ρ ρs = sym ((≪+ zeroʳ _) trans +-identityˡ _) ⟦∷⟧-hom x ( xs) ρ ρs = refl -- This proves that injecting a polynomial into more variables is @@ -170,7 +170,7 @@ (si≤n : suc i ≤′ n) (sn≤m : suc n ≤′ m) ρ - ⅀⟦ xs (drop-1 (≤′-step si≤n ≤′-trans sn≤m) ρ) + ⅀⟦ xs (drop-1 (≤′-step si≤n ≤′-trans sn≤m) ρ) ⅀⟦ xs (drop-1 si≤n (proj₂ (drop-1 sn≤m ρ))) ⅀-⊐↑-hom xs si≤n ≤′-refl (_ _) = refl ⅀-⊐↑-hom xs si≤n (≤′-step sn≤m) (_ ρ) = ⅀-⊐↑-hom xs si≤n sn≤m ρ @@ -188,7 +188,7 @@ (j≤n : suc j-1 ≤′ n) (xs : Coeff i +) ρ - ⅀⟦ xs (drop-1 i≤j-1 (proj₂ (drop-1 j≤n ρ))) ⅀⟦ xs (drop-1 (≤′-step i≤j-1 ≤′-trans j≤n) ρ) + ⅀⟦ xs (drop-1 i≤j-1 (proj₂ (drop-1 j≤n ρ))) ⅀⟦ xs (drop-1 (≤′-step i≤j-1 ≤′-trans j≤n) ρ) trans-join-coeffs-hom i<j-1 ≤′-refl xs (_ _) = refl trans-join-coeffs-hom i<j-1 (≤′-step j<n) xs (_ ρ) = trans-join-coeffs-hom i<j-1 j<n xs ρ @@ -197,7 +197,7 @@ (j≤n : suc j-1 ≤′ n) (x : FlatPoly i) ρ - x i≤j-1 (proj₂ (drop-1 j≤n ρ)) x (≤′-step i≤j-1 ≤′-trans j≤n) ρ + x i≤j-1 (proj₂ (drop-1 j≤n ρ)) x (≤′-step i≤j-1 ≤′-trans j≤n) ρ trans-join-hom i≤j-1 j≤n (Κ x) _ = refl trans-join-hom i≤j-1 j≤n ( x) = trans-join-coeffs-hom i≤j-1 j≤n x @@ -327,7 +327,7 @@ map₁ [f] (y , ys) ⟦∷⟧? (ρ , ρs) ≡⟨⟩ ρ * ⅀?⟦ ys (ρ , ρs) + [f] y ρs - ≈⟨ ((*≫ ys≋zs) trans *-dist ρ _) +-cong step′ y + ≈⟨ ((*≫ ys≋zs) trans *-dist ρ _) +-cong step′ y f (ρ * ⅀?⟦ zs (ρ , ρs)) + f ( y ρs) ≈⟨ sym (+-dist _ _) f ((y , zs) ⟦∷⟧? (ρ , ρs)) diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication.html index 15d0183c96..cec39ad50a 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication.html @@ -15,7 +15,7 @@ where open import Data.Nat.Base as using (; suc; zero; _<′_; _≤′_; ≤′-step; ≤′-refl) -open import Data.Nat.Properties using (≤′-trans) +open import Data.Nat.Properties using (≤′-trans) open import Data.Nat.Induction open import Data.Product.Base using (_×_; _,_; proj₁; proj₂; map₁) open import Data.List.Kleene @@ -35,7 +35,7 @@ using () renaming (_^′_ to _^_) reassoc : {y} x z x * (y * z) y * (x * z) -reassoc {y} x z = sym (*-assoc x y z) trans ((≪* *-comm x y) trans *-assoc y x z) +reassoc {y} x z = sym (*-assoc x y z) trans ((≪* *-comm x y) trans *-assoc y x z) mutual ⊠-step′-hom : {n} (a : Acc _<′_ n) (xs ys : Poly n) ρ ⊠-step′ a xs ys ρ xs ρ * ys ρ @@ -78,11 +78,11 @@ Ρ (⊠-Κ a x) ( x ⟧ᵣ *_) - (*-cong refl) + (*-cong refl) reassoc - (distribˡ x ⟧ᵣ) + (distribˡ x ⟧ᵣ) ys ⊠-Κ-hom a x ys Ρ) - (zeroʳ _) + (zeroʳ _) xs ⊠-⅀-hom : {i n} @@ -100,7 +100,7 @@ ⅀?⟦ ⊠-Κ-inj (wf i<n) y xs (drop-1 i<n ρ) ≈⟨ ⊠-Κ-inj-hom (wf i<n) y xs (drop-1 i<n ρ) y ⟧ᵣ * ⅀⟦ xs (drop-1 i<n ρ) - ≈⟨ *-comm _ _ + ≈⟨ *-comm _ _ ⅀⟦ xs (drop-1 i<n ρ) * y ⟧ᵣ @@ -119,7 +119,7 @@ ⅀?⟦ ⊠-Κ-inj (wf i<k) y x (drop-1 i<k ρ) ≈⟨ ⊠-Κ-inj-hom (wf i<k) y x (drop-1 i<k ρ) y ⟧ᵣ * ⅀⟦ x (drop-1 i<k ρ) - ≈⟨ *-comm _ _ + ≈⟨ *-comm _ _ ⅀⟦ x (drop-1 i<k ρ) * y ⟧ᵣ @@ -135,7 +135,7 @@ ⅀⟦ xs (drop-1 i<n Ρ) * ⅀⟦ ys (drop-1 j<n Ρ) ⊠-match-hom {j = j} (acc wf) (inj-lt i≤j-1 j≤n) xs ys Ρ′ = let (ρ , Ρ) = drop-1 j≤n Ρ′ - xs′ = ⅀⟦ xs (drop-1 (≤′-trans (≤′-step i≤j-1) j≤n) Ρ′) + xs′ = ⅀⟦ xs (drop-1 (≤′-trans (≤′-step i≤j-1) j≤n) Ρ′) in begin poly-map ( (⊠-⅀-inj (wf j≤n) i≤j-1 xs)) ys ⊐↓ j≤n Ρ′ @@ -143,18 +143,18 @@ ⅀?⟦ poly-map ( (⊠-⅀-inj (wf j≤n) i≤j-1 xs)) ys (ρ , Ρ) ≈⟨ poly-mapR ρ Ρ (⊠-⅀-inj (wf j≤n) i≤j-1 xs) (_ *_) - (*-cong refl) + (*-cong refl) reassoc - (distribˡ _) + (distribˡ _) y ⊠-⅀-inj-hom (wf j≤n) i≤j-1 xs y _) - (zeroʳ _) ys + (zeroʳ _) ys ⅀⟦ xs (drop-1 i≤j-1 Ρ) * ⅀⟦ ys (ρ , Ρ) ≈⟨ ≪* trans-join-coeffs-hom i≤j-1 j≤n xs Ρ′ xs′ * ⅀⟦ ys (ρ , Ρ) ⊠-match-hom (acc wf) (inj-gt i≤n j≤i-1) xs ys Ρ′ = let (ρ , Ρ) = drop-1 i≤n Ρ′ - ys′ = ⅀⟦ ys (drop-1 (≤′-step j≤i-1 ≤′-trans i≤n) Ρ′) + ys′ = ⅀⟦ ys (drop-1 (≤′-step j≤i-1 ≤′-trans i≤n) Ρ′) in begin poly-map ( (⊠-⅀-inj (wf i≤n) j≤i-1 ys)) xs ⊐↓ i≤n Ρ′ @@ -162,15 +162,15 @@ ⅀?⟦ poly-map ( (⊠-⅀-inj (wf i≤n) j≤i-1 ys)) xs (ρ , Ρ) ≈⟨ poly-mapR ρ Ρ (⊠-⅀-inj (wf i≤n) j≤i-1 ys) (_ *_) - (*-cong refl) + (*-cong refl) reassoc - (distribˡ _) + (distribˡ _) x ⊠-⅀-inj-hom (wf i≤n) j≤i-1 ys x _) - (zeroʳ _) xs + (zeroʳ _) xs ⅀⟦ ys (drop-1 j≤i-1 Ρ) * ⅀⟦ xs (ρ , Ρ) ≈⟨ ≪* trans-join-coeffs-hom j≤i-1 i≤n ys Ρ′ ys′ * ⅀⟦ xs (ρ , Ρ) - ≈⟨ *-comm ys′ _ + ≈⟨ *-comm ys′ _ ⅀⟦ xs (ρ , Ρ) * ys′ ⊠-match-hom (acc wf) (inj-eq ij≤n) xs ys Ρ = @@ -191,13 +191,13 @@ ⅀?⟦ poly-map (⊠-step′ a y) xs ⍓* j (ρ , Ρ) ≈⟨ sym (pow′-hom j (poly-map (⊠-step′ a y) xs) ρ Ρ) ⅀?⟦ poly-map (⊠-step′ a y) xs (ρ , Ρ) *⟨ ρ ⟩^ j - ≈⟨ pow-mul-cong (poly-mapR ρ Ρ (⊠-step′ a y) ( y Ρ *_) (*-cong refl) reassoc (distribˡ _) z ⊠-step′-hom a y z Ρ) (zeroʳ _) xs) ρ j + ≈⟨ pow-mul-cong (poly-mapR ρ Ρ (⊠-step′ a y) ( y Ρ *_) (*-cong refl) reassoc (distribˡ _) z ⊠-step′-hom a y z Ρ) (zeroʳ _) xs) ρ j ( y Ρ * ⅀⟦ xs (ρ , Ρ)) *⟨ ρ ⟩^ j ≈⟨ pow-opt _ ρ j (ρ ^ j) * ( y Ρ * ⅀⟦ xs (ρ , Ρ)) - ≈⟨ sym (*-assoc _ _ _) + ≈⟨ sym (*-assoc _ _ _) (ρ ^ j) * y Ρ * ⅀⟦ xs (ρ , Ρ) - ≈⟨ *-comm _ _ + ≈⟨ *-comm _ _ ⅀⟦ xs (ρ , Ρ) * ((ρ ^ j) * y Ρ) ≈⟨ *≫ sym (pow-opt _ ρ j) ⅀⟦ xs (ρ , Ρ) * ( y Ρ *⟨ ρ ⟩^ j) @@ -213,7 +213,7 @@ ρ ^ j * ⅀?⟦ para (⊠-cons a y ys) xs (ρ , Ρ) ≈⟨ *≫ ⊠-cons-hom a y ys xs ρ Ρ ρ ^ j * (xs′ * (ρ * ys′ + y′)) - ≈⟨ sym (*-assoc _ _ _) trans (≪* *-comm _ _) trans *-assoc _ _ _ trans (*≫ sym (pow-opt _ ρ j)) + ≈⟨ sym (*-assoc _ _ _) trans (≪* *-comm _ _) trans *-assoc _ _ _ trans (*≫ sym (pow-opt _ ρ j)) xs′ * ((ρ * ys′ + y′) *⟨ ρ ⟩^ j) @@ -226,7 +226,7 @@ ⅀?⟦ para (⊠-cons a y ys) xs (ρ , Ρ) ⅀⟦ xs (ρ , Ρ) * (ρ * ⅀⟦ ys (ρ , Ρ) + y Ρ) -- ⊠-cons-hom a y [] xs ρ Ρ = {!!} - ⊠-cons-hom a y ys xs ρ Ρ = poly-foldR ρ Ρ (⊠-cons a y ys) (flip _*_ (ρ * ⅀⟦ ys (ρ , Ρ) + y Ρ)) (flip *-cong refl) x y sym (*-assoc x y _)) step (zeroˡ _) xs + ⊠-cons-hom a y ys xs ρ Ρ = poly-foldR ρ Ρ (⊠-cons a y ys) (flip _*_ (ρ * ⅀⟦ ys (ρ , Ρ) + y Ρ)) (flip *-cong refl) x y sym (*-assoc x y _)) step (zeroˡ _) xs where step = λ { (z j≤n) {ys₁} zs ys≋zs let x′ = z j≤n Ρ @@ -237,17 +237,17 @@ in begin ρ * ⅀?⟦ ⊞-coeffs (poly-map ( (⊠-step a z j≤n)) ys) ys₁ (ρ , Ρ) + ⊠-step a z j≤n y Ρ - ≈⟨ (*≫ ⊞-coeffs-hom (poly-map (⊠-step a z j≤n) ys) _ (ρ , Ρ)) +-cong ⊠-step-hom a z j≤n y Ρ + ≈⟨ (*≫ ⊞-coeffs-hom (poly-map (⊠-step a z j≤n) ys) _ (ρ , Ρ)) +-cong ⊠-step-hom a z j≤n y Ρ ρ * (⅀?⟦ poly-map (⊠-step a z j≤n) ys (ρ , Ρ) + ⅀?⟦ ys₁ (ρ , Ρ)) + x′ * y′ - ≈⟨ ≪+ *≫ (poly-mapR ρ Ρ (⊠-step a z j≤n) (x′ *_) (*-cong refl) reassoc (distribˡ _) step (zeroʳ _) ys +-cong ys≋zs) + ≈⟨ ≪+ *≫ (poly-mapR ρ Ρ (⊠-step a z j≤n) (x′ *_) (*-cong refl) reassoc (distribˡ _) step (zeroʳ _) ys +-cong ys≋zs) ρ * (x′ * ys′ + xs′ * (ρ * ys′ + y′)) + (x′ * y′) - ≈⟨ ≪+ distribˡ _ _ _ + ≈⟨ ≪+ distribˡ _ _ _ ρ * (x′ * ys′) + ρ * (xs′ * (ρ * ys′ + y′)) + (x′ * y′) - ≈⟨ (≪+ +-comm _ _) trans +-assoc _ _ _ + ≈⟨ (≪+ +-comm _ _) trans +-assoc _ _ _ ρ * (xs′ * (ρ * ys′ + y′)) + (ρ * (x′ * ys′) + (x′ * y′)) - ≈⟨ sym (*-assoc _ _ _) +-cong ((≪+ (sym (*-assoc _ _ _) trans (≪* *-comm _ _) trans *-assoc _ _ _)) trans sym (distribˡ _ _ _)) + ≈⟨ sym (*-assoc _ _ _) +-cong ((≪+ (sym (*-assoc _ _ _) trans (≪* *-comm _ _) trans *-assoc _ _ _)) trans sym (distribˡ _ _ _)) ρ * xs′ * (ρ * ys′ + y′) + x′ * (ρ * ys′ + y′) - ≈⟨ sym (distribʳ _ _ _) + ≈⟨ sym (distribʳ _ _ _) (ρ * xs′ + x′) * (ρ * ys′ + y′) } diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation.html index 80bd0159a2..fb8ec511c4 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation.html @@ -34,11 +34,11 @@ neg-zero = begin 0# - ≈⟨ sym (zeroʳ _) + ≈⟨ sym (zeroʳ _) - 0# * 0# ≈⟨ -‿*-distribˡ 0# 0# - (0# * 0#) - ≈⟨ -‿cong (zeroˡ 0#) + ≈⟨ -‿cong (zeroˡ 0#) - 0# in @@ -46,7 +46,7 @@ poly-map (⊟-step (wf i≤n)) xs ⊐↓ i≤n ρ′ ≈⟨ ⊐↓-hom (poly-map (⊟-step (wf i≤n)) xs) i≤n ρ′ ⅀?⟦ poly-map (⊟-step (wf i≤n)) xs (ρ , ρs) - ≈⟨ poly-mapR ρ ρs (⊟-step (wf i≤n)) -_ (-‿cong) x y *-comm x (- y) trans -‿*-distribˡ y x trans -‿cong (*-comm _ _)) x y sym (-‿+-comm x y)) (flip (⊟-step-hom (wf i≤n)) ρs) (sym neg-zero ) xs + ≈⟨ poly-mapR ρ ρs (⊟-step (wf i≤n)) -_ (-‿cong) x y *-comm x (- y) trans -‿*-distribˡ y x trans -‿cong (*-comm _ _)) x y sym (-‿+-comm x y)) (flip (⊟-step-hom (wf i≤n)) ρs) (sym neg-zero ) xs - ⅀⟦ xs (ρ , ρs) diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables.html index 509ba346ad..4cd89731e6 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables.html @@ -31,7 +31,7 @@ (κ Raw.1# Δ 1 ∷↓ []) ⊐↓ space≤′n i Ρ′ ≈⟨ ⊐↓-hom (κ Raw.1# Δ 1 ∷↓ []) (space≤′n i) Ρ′ ⅀?⟦ κ Raw.1# Δ 1 ∷↓ [] (ρ , Ρ) ≈⟨ ∷↓-hom-s (κ Raw.1#) 0 [] ρ Ρ ρ * κ Raw.1# Ρ ≈⟨ *≫ 1-homo - ρ * 1# ≈⟨ *-identityʳ ρ + ρ * 1# ≈⟨ *-identityʳ ρ ρ ≡⟨ drop-1⇒lookup i Ρ′ Vec.lookup Ρ′ i \ No newline at end of file diff --git a/v2.3/Tactic.RingSolver.Core.Polynomial.Reasoning.html b/v2.3/Tactic.RingSolver.Core.Polynomial.Reasoning.html index 916a612da8..7467a25e7d 100644 --- a/v2.3/Tactic.RingSolver.Core.Polynomial.Reasoning.html +++ b/v2.3/Tactic.RingSolver.Core.Polynomial.Reasoning.html @@ -21,19 +21,19 @@ infixr 0 _⊙_ ≪+_ : {x₁ x₂ y} x₁ x₂ x₁ + y x₂ + y -≪+ prf = +-cong prf refl +≪+ prf = +-cong prf refl {-# INLINE ≪+_ #-} +≫_ : {x y₁ y₂} y₁ y₂ x + y₁ x + y₂ -+≫_ = +-cong refl ++≫_ = +-cong refl {-# INLINE +≫_ #-} ≪*_ : {x₁ x₂ y} x₁ x₂ x₁ * y x₂ * y -≪* prf = *-cong prf refl +≪* prf = *-cong prf refl {-# INLINE ≪*_ #-} *≫_ : {x y₁ y₂} y₁ y₂ x * y₁ x * y₂ -*≫_ = *-cong refl +*≫_ = *-cong refl {-# INLINE *≫_ #-} -- transitivity as an operator diff --git a/v2.3/Tactic.RingSolver.NonReflective.html b/v2.3/Tactic.RingSolver.NonReflective.html index 0e97f3736a..4851a64efc 100644 --- a/v2.3/Tactic.RingSolver.NonReflective.html +++ b/v2.3/Tactic.RingSolver.NonReflective.html @@ -78,8 +78,8 @@ go : (expr : Expr Carrier n) ρ expr ⇓⟧ ρ expr ρ go (Κ x) ρ = κ-hom x ρ go (Ι x) ρ = ι-hom x ρ - go (x y) ρ = ⊞-hom (norm x) (norm y) ρ trans (go x ρ +-cong go y ρ) - go (x y) ρ = ⊠-hom (norm x) (norm y) ρ trans (go x ρ *-cong go y ρ) + go (x y) ρ = ⊞-hom (norm x) (norm y) ρ trans (go x ρ +-cong go y ρ) + go (x y) ρ = ⊠-hom (norm x) (norm y) ρ trans (go x ρ *-cong go y ρ) go ( x) ρ = ⊟-hom (norm x) ρ trans -‿cong (go x ρ) go (x i) ρ = ⊡-hom (norm x) i ρ trans ^-congˡ i (go x ρ) diff --git a/v2.3/Text.Pretty.Core.html b/v2.3/Text.Pretty.Core.html index 7d3ec6eeaa..dfac7f72f0 100644 --- a/v2.3/Text.Pretty.Core.html +++ b/v2.3/Text.Pretty.Core.html @@ -17,8 +17,8 @@ open import Data.Irrelevant as Irrelevant using (Irrelevant) hiding (module Irrelevant) open import Data.List.Base as List using (List; []; _∷_) open import Data.Nat.Base using (; zero; suc; _+_; _⊔_; _≤_; z≤n) -open import Data.Nat.Properties using (≤-refl; ≤-trans; +-identityʳ; - module ≤-Reasoning; m≤n⊔m; +-monoʳ-≤; m≤m⊔n; +-comm; _≤?_) +open import Data.Nat.Properties using (≤-refl; ≤-trans; +-identityʳ; + module ≤-Reasoning; m≤n⊔m; +-monoʳ-≤; m≤m⊔n; +-comm; _≤?_) open import Data.Product.Base as Prod using (_×_; _,_; uncurry; proj₁; proj₂) import Data.Product.Relation.Unary.All as Allᴾ @@ -85,7 +85,7 @@ ; block = nothing , refl ; lastWidth = width ; last = s , refl - ; maxWidth = width , (≤-refl , nothing) + ; maxWidth = width , (≤-refl , nothing) } where width = length s; open Irrelevant ------------------------------------------------------------------------ @@ -112,7 +112,7 @@ where step : {p} p m p n - step = flip ≤-trans m≤n + step = flip ≤-trans m≤n All≤-node? : {l m r n} All≤ n l length m n Allᵀ.All s length s n) U r @@ -195,7 +195,7 @@ isBlock ∣x∣ ∣y∣ with blocky ... | nothing = begin size blockx ≡⟨ ∣x∣ - x.height ≡⟨ +-identityʳ x.height + x.height ≡⟨ +-identityʳ x.height x.height + 0 ≡⟨ cong (_ +_) ∣y∣ x.height + y.height where open ≡-Reasoning ... | just (hd , tl) = begin @@ -239,9 +239,9 @@ isMaxWidth₁ : y.lastWidth widthy lastWidth vMaxWidth isMaxWidth₁ p = begin - lastWidth ≤⟨ +-monoʳ-≤ x.lastWidth p - x.lastWidth + widthy ≤⟨ m≤n⊔m _ _ - vMaxWidth where open ≤-Reasoning + lastWidth ≤⟨ +-monoʳ-≤ x.lastWidth p + x.lastWidth + widthy ≤⟨ m≤n⊔m _ _ + vMaxWidth where open ≤-Reasoning isMaxWidth₂ : length lastx x.lastWidth x.lastWidth widthx @@ -249,10 +249,10 @@ All≤ widthy blocky All≤ vMaxWidth vBlock isMaxWidth₂ ∣x∣≡ ∣x∣≤ ∣xs∣ ∣ys∣ with blocky - ... | nothing = ≤-Content (m≤m⊔n _ _) ∣xs∣ + ... | nothing = ≤-Content (m≤m⊔n _ _) ∣xs∣ isMaxWidth₂ ∣x∣≡ ∣x∣≤ ∣xs∣ (just (∣hd∣ , ∣tl∣)) | just (hd , tl) = - All≤-node? (≤-Content (m≤m⊔n _ _) ∣xs∣) + All≤-node? (≤-Content (m≤m⊔n _ _) ∣xs∣) middle (subst (Allᵀ.All _ U) (sym $ unfold-indents pad tl) $ Allᵀ.mapₙ⁺ (indent pad) (Allᵀ.mapₙ (indented _) ∣tl∣)) @@ -262,18 +262,18 @@ middle = begin length (lastx ++ hd) ≡⟨ String.length-++ lastx hd length lastx + length hd ≡⟨ cong (_+ _) ∣x∣≡ - x.lastWidth + length hd ≤⟨ +-monoʳ-≤ x.lastWidth ∣hd∣ - x.lastWidth + widthy ≤⟨ m≤n⊔m _ _ - vMaxWidth where open ≤-Reasoning + x.lastWidth + length hd ≤⟨ +-monoʳ-≤ x.lastWidth ∣hd∣ + x.lastWidth + widthy ≤⟨ m≤n⊔m _ _ + vMaxWidth where open ≤-Reasoning indented : s length s widthy length (indent pad s) vMaxWidth indented s ∣s∣ = begin length (indent pad s) ≡⟨ size-indent pad s maybe′ length 0 pad + length s ≡⟨ cong (_+ _) size-pad - x.lastWidth + length s ≤⟨ +-monoʳ-≤ x.lastWidth ∣s∣ - x.lastWidth + widthy ≤⟨ m≤n⊔m (widthx) _ - vMaxWidth where open ≤-Reasoning + x.lastWidth + length s ≤⟨ +-monoʳ-≤ x.lastWidth ∣s∣ + x.lastWidth + widthy ≤⟨ m≤n⊔m (widthx) _ + vMaxWidth where open ≤-Reasoning maxWidth : [ n lastWidth n × All≤ n vBlock ] maxWidth .value = vMaxWidth @@ -315,7 +315,7 @@ isBlock ∣x∣ = begin size vContent ≡⟨ ∣node?∣ blockx lastx (leaf tt) size blockx + 1 ≡⟨ cong (_+ 1) ∣x∣ - heightx + 1 ≡⟨ +-comm heightx 1 + heightx + 1 ≡⟨ +-comm heightx 1 height where open ≡-Reasoning block : [ xs Content size xs height ] @@ -337,7 +337,7 @@ middle p q = begin length lastx ≡⟨ p x.lastWidth ≤⟨ q - vMaxWidth where open ≤-Reasoning + vMaxWidth where open ≤-Reasoning flush : Block Block flush x = record { flush x } @@ -351,5 +351,5 @@ $ node? (Block.block x .value) (Block.last x .value) (leaf tt) valid : (width : ) (b : Block) Dec (Block.maxWidth b .value width) -valid width b = Block.maxWidth b .value ≤? width +valid width b = Block.maxWidth b .value ≤? width \ No newline at end of file diff --git a/v2.3/Text.Pretty.html b/v2.3/Text.Pretty.html index 5aa9582052..3608018b10 100644 --- a/v2.3/Text.Pretty.html +++ b/v2.3/Text.Pretty.html @@ -28,7 +28,7 @@ open RawMonad (List.monad {Level.zero}) import Data.Nat.Properties as -open import Data.List.Extrema.Core ℕ.≤-totalOrder using (⊓ᴸ) +open import Data.List.Extrema.Core ℕ.≤-totalOrder using (⊓ᴸ) ------------------------------------------------------------------------ -- Internal representation of documents and rendering function diff --git a/v2.3/Text.Regex.Derivative.Brzozowski.html b/v2.3/Text.Regex.Derivative.Brzozowski.html index 1e6e877216..e0487e37c0 100644 --- a/v2.3/Text.Regex.Derivative.Brzozowski.html +++ b/v2.3/Text.Regex.Derivative.Brzozowski.html @@ -17,7 +17,7 @@ open import Function.Base using (_$_; _∘′_; case_of_) open import Relation.Nullary.Decidable using (Dec; yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Nullary.Decidable using (map′; ¬?) open import Relation.Binary.Definitions using (Decidable) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong) @@ -52,13 +52,13 @@ -- This action is sound and complete with respect to matching eat-sound : x {xs} e xs eat x e (x xs) e -eat-sound x ε pr = contradiction pr ∉∅ +eat-sound x ε pr = contradiction pr ∉∅ eat-sound x [ rs ] pr with (x []) ∈?[ rs ] ... | yes p = case pr of λ where ε p -... | no _ = contradiction pr ∉∅ +... | no _ = contradiction pr ∉∅ eat-sound x [^ rs ] pr with (x []) ∈?[^ rs ] ... | yes p = case pr of λ where ε p -... | no _ = contradiction pr ∉∅ +... | no _ = contradiction pr ∉∅ eat-sound x (e R.∣ f) pr with ∣-sound (eat x e) (eat x f) pr ... | sum pr′ = sum $ Sum.map (eat-sound x e) (eat-sound x f) pr′ eat-sound x (e R.∙ f) pr with []∈? e @@ -80,17 +80,17 @@ eat-complete′ x [ rs ] (refl []) [ p ] with (x []) ∈?[ rs ] ... | yes _ = ε -... | no ¬p = contradiction [ p ] ¬p +... | no ¬p = contradiction [ p ] ¬p eat-complete′ x [^ rs ] (refl []) [^ p ] with (x []) ∈?[^ rs ] ... | yes _ = ε -... | no ¬p = contradiction [^ p ] ¬p +... | no ¬p = contradiction [^ p ] ¬p eat-complete′ x (e R.∣ f) eq (sum p) = ∣-complete (eat x e) (eat x f) $ sum $ Sum.map (eat-complete′ x e eq) (eat-complete′ x f eq) p eat-complete′ x (e R.∙ f) eq p with []∈? e eat-complete′ x (e R.∙ f) (refl eq) (prod ([]++ _) p q) | no []∉e - = contradiction p []∉e + = contradiction p []∉e eat-complete′ x (e R.∙ f) (refl eq) (prod (refl app) p q) | no []∉e = ∙-complete (eat x e) f (prod (respʳ-≋ app eq) (eat-complete x e p) q) eat-complete′ x (e R.∙ f) eq (prod ([]++ eq′) p q) | yes []∈e diff --git a/v2.3/Text.Regex.Properties.Core.html b/v2.3/Text.Regex.Properties.Core.html index 2e2fed3d64..04144a5670 100644 --- a/v2.3/Text.Regex.Properties.Core.html +++ b/v2.3/Text.Regex.Properties.Core.html @@ -22,7 +22,7 @@ open import Data.Sum.Base using (_⊎_; inj₁; inj₂) open import Relation.Nullary using (¬_; Dec; yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Unary using (Pred) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) @@ -64,7 +64,7 @@ ∈∅⋆-inv : {w} w ( ) w ε ∈∅⋆-inv (star (sum (inj₁ ε))) = ε -∈∅⋆-inv (star (sum (inj₂ (prod eq p q)))) = contradiction p ∉∅ +∈∅⋆-inv (star (sum (inj₂ (prod eq p q)))) = contradiction p ∉∅ ∈ε∙e-inv : {w e} w (ε e) w e ∈ε∙e-inv (prod eq ε p) rewrite []++⁻¹ eq = p diff --git a/v2.3/Text.Regex.Properties.html b/v2.3/Text.Regex.Properties.html index da9690f127..9a4ad9c2d1 100644 --- a/v2.3/Text.Regex.Properties.html +++ b/v2.3/Text.Regex.Properties.html @@ -21,7 +21,7 @@ open import Relation.Nullary.Decidable using (Dec; yes; no; map′; ¬?; _×-dec_; _⊎-dec_) open import Relation.Nullary.Negation - using (¬_; contradiction) + using (¬_; contradiction) import Relation.Unary as U open import Relation.Binary.Definitions using (Decidable) diff --git a/v2.3/Text.Regex.Search.html b/v2.3/Text.Regex.Search.html index cfb7c896e2..7d2949c7ca 100644 --- a/v2.3/Text.Regex.Search.html +++ b/v2.3/Text.Regex.Search.html @@ -29,7 +29,7 @@ open import Relation.Nullary using (Dec; ¬_; yes; no) open import Relation.Nullary.Decidable using (map′) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.Core using (Rel; _⇒_) open import Relation.Binary.Definitions using (Decidable) open import Relation.Binary.PropositionalEquality.Core @@ -96,7 +96,7 @@ _∷⁻¹ᴹ_ : {xs x e} [] e Match (Prefix _≡_) (x xs) e Match (Prefix _≡_) xs (eat x e) - []∉e ∷⁻¹ᴹ (mkMatch .[] []∈e []) = contradiction []∈e []∉e + []∉e ∷⁻¹ᴹ (mkMatch .[] []∈e []) = contradiction []∈e []∉e []∉e ∷⁻¹ᴹ (mkMatch (._ ys) ys∈e (refl ys≤xs)) = mkMatch ys (eat-complete _ _ ys∈e) ys≤xs shortest : Decidable (Match (Prefix _≡_)) @@ -135,8 +135,8 @@ Match (Infix _≡_) (x xs) e Match (Prefix _≡_) (x xs) acc Match (Infix _≡_) xs e Match (Prefix _≡_) xs (eat x (acc e)) -- can't possibly be the empty match - step⁻¹ x []∉e []∉acc (inj₁ (mkMatch .[] ys∈e (here []))) = contradiction ys∈e []∉e - step⁻¹ x []∉e []∉acc (inj₂ (mkMatch .[] ys∈e [])) = contradiction ys∈e []∉acc + step⁻¹ x []∉e []∉acc (inj₁ (mkMatch .[] ys∈e (here []))) = contradiction ys∈e []∉e + step⁻¹ x []∉e []∉acc (inj₂ (mkMatch .[] ys∈e [])) = contradiction ys∈e []∉acc -- if it starts 'there', it's an infix solution step⁻¹ x []∉e []∉acc (inj₁ (mkMatch ys ys∈e (there p))) = inj₁ (mkMatch ys ys∈e p) -- if it starts 'here' we're in prefix territory @@ -151,7 +151,7 @@ searchND xs e acc []∉e with []∈? acc ... | yes []∈acc with Prefix.longest xs acc -- get the best match possible ... | yes longer = yes (inj₂ longer) - ... | no noMatch = contradiction (mkMatch [] []∈acc []) noMatch + ... | no noMatch = contradiction (mkMatch [] []∈acc []) noMatch searchND [] e acc []∉e | no []∉acc = no ([ []∉e , []∉acc ]′ ∘′ []⁻¹ᴹ) searchND (x xs) e acc []∉e | no []∉acc = map′ (step x) (step⁻¹ x []∉e []∉acc) (searchND xs e (eat x (acc e)) []∉e) @@ -162,7 +162,7 @@ ... | no []∉e with searchND xs e []∉e ... | no ¬p = no (¬p ∘′ inj₁) ... | yes (inj₁ p) = yes p - ... | yes (inj₂ p) = contradiction (match p) ∉∅ + ... | yes (inj₂ p) = contradiction (match p) ∉∅ module Whole where @@ -213,7 +213,7 @@ search xs e with searchND xs e ... | no ¬p = no (¬p ∘′ inj₁) ... | yes (inj₁ p) = yes p - ... | yes (inj₂ p) = contradiction (match p) ∉∅ + ... | yes (inj₂ p) = contradiction (match p) ∉∅ ------------------------------------------------------------------------ -- Search for the user-specified span diff --git a/v2.3/Text.Regex.SmartConstructors.html b/v2.3/Text.Regex.SmartConstructors.html index ab98932d55..c2008d653d 100644 --- a/v2.3/Text.Regex.SmartConstructors.html +++ b/v2.3/Text.Regex.SmartConstructors.html @@ -19,7 +19,7 @@ open import Data.Sum.Base using (inj₁; inj₂; fromInj₁; fromInj₂) open import Relation.Nullary.Decidable using (yes; no) -open import Relation.Nullary.Negation using (contradiction) +open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.PropositionalEquality.Core using (refl) open import Text.Regex.Base P as R hiding (_∣_; _∙_; _⋆) @@ -44,8 +44,8 @@ ∣-complete : {w} e f w (e R.∣ f) w (e f) ∣-complete e f pr@(sum p) with is-∅ e | is-∅ f -... | yes refl | _ = fromInj₂ p contradiction p ∉∅) p -... | no _ | yes refl = fromInj₁ p contradiction p ∉∅) p +... | yes refl | _ = fromInj₂ p contradiction p ∉∅) p +... | no _ | yes refl = fromInj₁ p contradiction p ∉∅) p ... | no _ | no _ = pr ------------------------------------------------------------------------ @@ -63,17 +63,17 @@ ∙-sound : {w} e f w (e f) w (e R.∙ f) ∙-sound e f p with is-∅ e | is-ε e | is-∅ f | is-ε f -... | yes refl | _ | _ | _ = contradiction p ∉∅ +... | yes refl | _ | _ | _ = contradiction p ∉∅ ... | no _ | yes refl | _ | _ = prod ([] ++ _) ε p -... | no _ | no _ | yes refl | _ = contradiction p ∉∅ +... | no _ | no _ | yes refl | _ = contradiction p ∉∅ ... | no _ | no _ | no _ | yes refl = prod (_ ++[]) p ε ... | no _ | no _ | no _ | no _ = p ∙-complete : {w} e f w (e R.∙ f) w (e f) ∙-complete e f pr@(prod eq p q) with is-∅ e | is-ε e | is-∅ f | is-ε f -... | yes refl | _ | _ | _ = contradiction p ∉∅ +... | yes refl | _ | _ | _ = contradiction p ∉∅ ... | no _ | yes refl | _ | _ = ∈ε∙e-inv pr -... | no _ | no _ | yes refl | _ = contradiction q ∉∅ +... | no _ | no _ | yes refl | _ = contradiction q ∉∅ ... | no _ | no _ | no _ | yes refl = ∈e∙ε-inv pr ... | no _ | no _ | no _ | no _ = pr diff --git a/v2.3/Text.Tabular.List.html b/v2.3/Text.Tabular.List.html index d80bb9338f..133a5fb0af 100644 --- a/v2.3/Text.Tabular.List.html +++ b/v2.3/Text.Tabular.List.html @@ -25,7 +25,7 @@ where alignment : Vec Alignment _ alignment = Vec≤.padRight Left - $ Vec≤.≤-cast (ℕ.m⊓n≤m _ _) + $ Vec≤.≤-cast (ℕ.m⊓n≤m _ _) $ Vec≤.take _ (Vec≤.fromList a) rectangle : Vec (Vec String _) _ diff --git a/v2.3/index.html b/v2.3/index.html index 1587527d32..83f761fdd5 100644 --- a/v2.3/index.html +++ b/v2.3/index.html @@ -383,696 +383,692 @@ import Data.List.Relation.Binary.Lex.Core import Data.List.Relation.Binary.Lex.NonStrict import Data.List.Relation.Binary.Lex.Strict -import Data.List.Relation.Binary.Permutation.Algorithmic -import Data.List.Relation.Binary.Permutation.Algorithmic.Properties -import Data.List.Relation.Binary.Permutation.Declarative -import Data.List.Relation.Binary.Permutation.Declarative.Properties -import Data.List.Relation.Binary.Permutation.Homogeneous -import Data.List.Relation.Binary.Permutation.Propositional -import Data.List.Relation.Binary.Permutation.Propositional.Properties -import Data.List.Relation.Binary.Permutation.Propositional.Properties.WithK -import Data.List.Relation.Binary.Permutation.Setoid -import Data.List.Relation.Binary.Permutation.Setoid.Properties -import Data.List.Relation.Binary.Permutation.Setoid.Properties.Maybe -import Data.List.Relation.Binary.Pointwise -import Data.List.Relation.Binary.Pointwise.Base -import Data.List.Relation.Binary.Pointwise.Properties -import Data.List.Relation.Binary.Prefix.Heterogeneous -import Data.List.Relation.Binary.Prefix.Heterogeneous.Properties -import Data.List.Relation.Binary.Prefix.Homogeneous.Properties -import Data.List.Relation.Binary.Prefix.Propositional.Properties -import Data.List.Relation.Binary.Sublist.DecPropositional -import Data.List.Relation.Binary.Sublist.DecPropositional.Solver -import Data.List.Relation.Binary.Sublist.DecSetoid -import Data.List.Relation.Binary.Sublist.DecSetoid.Solver -import Data.List.Relation.Binary.Sublist.Heterogeneous -import Data.List.Relation.Binary.Sublist.Heterogeneous.Core -import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties -import Data.List.Relation.Binary.Sublist.Heterogeneous.Solver -import Data.List.Relation.Binary.Sublist.Propositional -import Data.List.Relation.Binary.Sublist.Propositional.Example.UniqueBoundVariables -import Data.List.Relation.Binary.Sublist.Propositional.Properties -import Data.List.Relation.Binary.Sublist.Propositional.Slice -import Data.List.Relation.Binary.Sublist.Setoid -import Data.List.Relation.Binary.Sublist.Setoid.Properties -import Data.List.Relation.Binary.Subset.DecPropositional -import Data.List.Relation.Binary.Subset.DecSetoid -import Data.List.Relation.Binary.Subset.Propositional -import Data.List.Relation.Binary.Subset.Propositional.Properties -import Data.List.Relation.Binary.Subset.Setoid -import Data.List.Relation.Binary.Subset.Setoid.Properties -import Data.List.Relation.Binary.Suffix.Heterogeneous -import Data.List.Relation.Binary.Suffix.Heterogeneous.Properties -import Data.List.Relation.Binary.Suffix.Homogeneous.Properties -import Data.List.Relation.Binary.Suffix.Propositional.Properties -import Data.List.Relation.Ternary.Appending -import Data.List.Relation.Ternary.Appending.Properties -import Data.List.Relation.Ternary.Appending.Propositional -import Data.List.Relation.Ternary.Appending.Propositional.Properties -import Data.List.Relation.Ternary.Appending.Setoid -import Data.List.Relation.Ternary.Appending.Setoid.Properties -import Data.List.Relation.Ternary.Interleaving -import Data.List.Relation.Ternary.Interleaving.Properties -import Data.List.Relation.Ternary.Interleaving.Propositional -import Data.List.Relation.Ternary.Interleaving.Propositional.Properties -import Data.List.Relation.Ternary.Interleaving.Setoid -import Data.List.Relation.Ternary.Interleaving.Setoid.Properties -import Data.List.Relation.Unary.All -import Data.List.Relation.Unary.AllPairs -import Data.List.Relation.Unary.AllPairs.Core -import Data.List.Relation.Unary.AllPairs.Properties -import Data.List.Relation.Unary.All.Properties -import Data.List.Relation.Unary.All.Properties.Core -import Data.List.Relation.Unary.Any -import Data.List.Relation.Unary.Any.Properties -import Data.List.Relation.Unary.Enumerates.Setoid -import Data.List.Relation.Unary.Enumerates.Setoid.Properties -import Data.List.Relation.Unary.First -import Data.List.Relation.Unary.First.Properties -import Data.List.Relation.Unary.Grouped -import Data.List.Relation.Unary.Grouped.Properties -import Data.List.Relation.Unary.Linked -import Data.List.Relation.Unary.Linked.Properties -import Data.List.Relation.Unary.Sorted.TotalOrder -import Data.List.Relation.Unary.Sorted.TotalOrder.Properties -import Data.List.Relation.Unary.Sufficient -import Data.List.Relation.Unary.Unique.DecPropositional -import Data.List.Relation.Unary.Unique.DecPropositional.Properties -import Data.List.Relation.Unary.Unique.DecSetoid -import Data.List.Relation.Unary.Unique.DecSetoid.Properties -import Data.List.Relation.Unary.Unique.Propositional -import Data.List.Relation.Unary.Unique.Propositional.Properties -import Data.List.Relation.Unary.Unique.Setoid -import Data.List.Relation.Unary.Unique.Setoid.Properties -import Data.List.Reverse -import Data.List.Scans.Base -import Data.List.Scans.Properties -import Data.List.Show -import Data.List.Sort -import Data.List.Sort.Base -import Data.List.Sort.InsertionSort -import Data.List.Sort.InsertionSort.Base -import Data.List.Sort.InsertionSort.Properties -import Data.List.Sort.MergeSort -import Data.List.Sort.MergeSort.Base -import Data.List.Sort.MergeSort.Properties -import Data.List.Zipper -import Data.List.Zipper.Properties -import Data.Maybe -import Data.Maybe.Base -import Data.Maybe.Effectful -import Data.Maybe.Effectful.Transformer -import Data.Maybe.Instances -import Data.Maybe.Properties -import Data.Maybe.Relation.Binary.Connected -import Data.Maybe.Relation.Binary.Pointwise -import Data.Maybe.Relation.Unary.All -import Data.Maybe.Relation.Unary.All.Properties -import Data.Maybe.Relation.Unary.Any -import Data.Nat -import Data.Nat.Base -import Data.Nat.Binary -import Data.Nat.Binary.Base -import Data.Nat.Binary.Induction -import Data.Nat.Binary.Instances -import Data.Nat.Binary.Properties -import Data.Nat.Binary.Subtraction -import Data.Nat.Combinatorics -import Data.Nat.Combinatorics.Base -import Data.Nat.Combinatorics.Specification -import Data.Nat.Coprimality -import Data.Nat.Divisibility -import Data.Nat.Divisibility.Core -import Data.Nat.DivMod -import Data.Nat.DivMod.Core -import Data.Nat.DivMod.WithK -import Data.Nat.GCD -import Data.Nat.GCD.Lemmas -import Data.Nat.GeneralisedArithmetic -import Data.Nat.Induction -import Data.Nat.InfinitelyOften -import Data.Nat.Instances -import Data.Nat.LCM -import Data.Nat.ListAction -import Data.Nat.ListAction.Properties -import Data.Nat.Literals -import Data.Nat.Logarithm -import Data.Nat.Logarithm.Core -import Data.Nat.Primality -import Data.Nat.Primality.Factorisation -import Data.Nat.Properties -import Data.Nat.PseudoRandom.LCG -import Data.Nat.PseudoRandom.LCG.Unsafe -import Data.Nat.Reflection -import Data.Nat.Show -import Data.Nat.Show.Properties -import Data.Nat.Solver -import Data.Nat.Tactic.RingSolver -import Data.Nat.WithK -import Data.Parity -import Data.Parity.Base -import Data.Parity.Instances -import Data.Parity.Properties -import Data.Product -import Data.Product.Algebra -import Data.Product.Base -import Data.Product.Effectful.Examples -import Data.Product.Effectful.Left -import Data.Product.Effectful.Left.Base -import Data.Product.Effectful.Right -import Data.Product.Effectful.Right.Base -import Data.Product.Function.Dependent.Propositional -import Data.Product.Function.Dependent.Propositional.WithK -import Data.Product.Function.Dependent.Setoid -import Data.Product.Function.NonDependent.Propositional -import Data.Product.Function.NonDependent.Setoid -import Data.Product.Instances -import Data.Product.Nary.NonDependent -import Data.Product.Properties -import Data.Product.Properties.Dependent -import Data.Product.Properties.WithK -import Data.Product.Relation.Binary.Lex.NonStrict -import Data.Product.Relation.Binary.Lex.Strict -import Data.Product.Relation.Binary.Pointwise.Dependent -import Data.Product.Relation.Binary.Pointwise.Dependent.WithK -import Data.Product.Relation.Binary.Pointwise.NonDependent -import Data.Product.Relation.Unary.All -import Data.Rational -import Data.Rational.Base -import Data.Rational.Instances -import Data.Rational.Literals -import Data.Rational.Properties -import Data.Rational.Show -import Data.Rational.Solver -import Data.Rational.Unnormalised -import Data.Rational.Unnormalised.Base -import Data.Rational.Unnormalised.Properties -import Data.Rational.Unnormalised.Show -import Data.Rational.Unnormalised.Solver -import Data.Record -import Data.Refinement -import Data.Refinement.Base -import Data.Refinement.Properties -import Data.Refinement.Relation.Unary.All -import Data.Sign -import Data.Sign.Base -import Data.Sign.Instances -import Data.Sign.Properties -import Data.Sign.Show -import Data.Star.BoundedVec -import Data.Star.Decoration -import Data.Star.Environment -import Data.Star.Fin -import Data.Star.List -import Data.Star.Nat -import Data.Star.Pointer -import Data.Star.Vec -import Data.String -import Data.String.Base -import Data.String.Instances -import Data.String.Literals -import Data.String.Properties -import Data.String.Unsafe -import Data.Sum -import Data.Sum.Algebra -import Data.Sum.Base -import Data.Sum.Effectful.Examples -import Data.Sum.Effectful.Left -import Data.Sum.Effectful.Left.Transformer -import Data.Sum.Effectful.Right -import Data.Sum.Effectful.Right.Transformer -import Data.Sum.Function.Propositional -import Data.Sum.Function.Setoid -import Data.Sum.Instances -import Data.Sum.Properties -import Data.Sum.Relation.Binary.LeftOrder -import Data.Sum.Relation.Binary.Pointwise -import Data.Sum.Relation.Unary.All -import Data.These -import Data.These.Base -import Data.These.Effectful.Left -import Data.These.Effectful.Left.Base -import Data.These.Effectful.Right -import Data.These.Effectful.Right.Base -import Data.These.Instances -import Data.These.Properties -import Data.Tree.AVL -import Data.Tree.AVL.Height -import Data.Tree.AVL.Indexed -import Data.Tree.AVL.IndexedMap -import Data.Tree.AVL.Indexed.Relation.Unary.All -import Data.Tree.AVL.Indexed.Relation.Unary.Any -import Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties -import Data.Tree.AVL.Indexed.WithK -import Data.Tree.AVL.Key -import Data.Tree.AVL.Map -import Data.Tree.AVL.Map.Membership.Propositional -import Data.Tree.AVL.Map.Membership.Propositional.Properties -import Data.Tree.AVL.Map.Relation.Unary.Any -import Data.Tree.AVL.NonEmpty -import Data.Tree.AVL.NonEmpty.Propositional -import Data.Tree.AVL.Relation.Unary.Any -import Data.Tree.AVL.Sets -import Data.Tree.AVL.Sets.Membership -import Data.Tree.AVL.Sets.Membership.Properties -import Data.Tree.AVL.Value -import Data.Tree.Binary -import Data.Tree.Binary.Properties -import Data.Tree.Binary.Relation.Unary.All -import Data.Tree.Binary.Relation.Unary.All.Properties -import Data.Tree.Binary.Show -import Data.Tree.Binary.Zipper -import Data.Tree.Binary.Zipper.Properties -import Data.Tree.Rose -import Data.Tree.Rose.Properties -import Data.Tree.Rose.Show -import Data.Trie -import Data.Trie.NonEmpty -import Data.Unit -import Data.Unit.Base -import Data.Unit.Instances -import Data.Unit.NonEta -import Data.Unit.Polymorphic -import Data.Unit.Polymorphic.Base -import Data.Unit.Polymorphic.Instances -import Data.Unit.Polymorphic.Properties -import Data.Unit.Properties -import Data.Universe -import Data.Universe.Indexed -import Data.Vec -import Data.Vec.Base -import Data.Vec.Bounded -import Data.Vec.Bounded.Base -import Data.Vec.Bounded.Show -import Data.Vec.Effectful -import Data.Vec.Effectful.Foldable -import Data.Vec.Effectful.Transformer -import Data.Vec.Functional -import Data.Vec.Functional.Properties -import Data.Vec.Functional.Relation.Binary.Equality.Setoid -import Data.Vec.Functional.Relation.Binary.Permutation -import Data.Vec.Functional.Relation.Binary.Permutation.Properties -import Data.Vec.Functional.Relation.Binary.Pointwise -import Data.Vec.Functional.Relation.Binary.Pointwise.Properties -import Data.Vec.Functional.Relation.Unary.All -import Data.Vec.Functional.Relation.Unary.All.Properties -import Data.Vec.Functional.Relation.Unary.Any -import Data.Vec.Instances -import Data.Vec.Membership.DecPropositional -import Data.Vec.Membership.DecSetoid -import Data.Vec.Membership.Propositional -import Data.Vec.Membership.Propositional.Properties -import Data.Vec.Membership.Setoid -import Data.Vec.N-ary -import Data.Vec.Properties -import Data.Vec.Properties.WithK -import Data.Vec.Recursive -import Data.Vec.Recursive.Effectful -import Data.Vec.Recursive.Properties -import Data.Vec.Reflection -import Data.Vec.Relation.Binary.Equality.Cast -import Data.Vec.Relation.Binary.Equality.DecPropositional -import Data.Vec.Relation.Binary.Equality.DecSetoid -import Data.Vec.Relation.Binary.Equality.Propositional -import Data.Vec.Relation.Binary.Equality.Propositional.WithK -import Data.Vec.Relation.Binary.Equality.Setoid -import Data.Vec.Relation.Binary.Lex.Core -import Data.Vec.Relation.Binary.Lex.NonStrict -import Data.Vec.Relation.Binary.Lex.Strict -import Data.Vec.Relation.Binary.Pointwise.Extensional -import Data.Vec.Relation.Binary.Pointwise.Inductive -import Data.Vec.Relation.Unary.All -import Data.Vec.Relation.Unary.AllPairs -import Data.Vec.Relation.Unary.AllPairs.Core -import Data.Vec.Relation.Unary.AllPairs.Properties -import Data.Vec.Relation.Unary.All.Properties -import Data.Vec.Relation.Unary.Any -import Data.Vec.Relation.Unary.Any.Properties -import Data.Vec.Relation.Unary.Linked -import Data.Vec.Relation.Unary.Linked.Properties -import Data.Vec.Relation.Unary.Unique.Propositional -import Data.Vec.Relation.Unary.Unique.Propositional.Properties -import Data.Vec.Relation.Unary.Unique.Setoid -import Data.Vec.Relation.Unary.Unique.Setoid.Properties -import Data.Vec.Show -import Data.W -import Data.W.Indexed -import Data.Word64 -import Data.Word64.Base -import Data.Word64.Instances -import Data.Word64.Literals -import Data.Word64.Primitive -import Data.Word64.Properties -import Data.Word64.Show -import Data.Word64.Unsafe -import Data.Word8.Base -import Data.Word8.Literals -import Data.Word8.Primitive -import Data.Word8.Show -import Data.Wrap -import Data.W.Sized -import Data.W.WithK -import Debug.Trace -import Effect.Applicative -import Effect.Applicative.Indexed -import Effect.Applicative.Predicate -import Effect.Choice -import Effect.Comonad -import Effect.Empty -import Effect.Foldable -import Effect.Functor -import Effect.Functor.Predicate -import Effect.Monad -import Effect.Monad.Continuation -import Effect.Monad.Error.Transformer -import Effect.Monad.Identity -import Effect.Monad.Identity.Instances -import Effect.Monad.Indexed -import Effect.Monad.IO -import Effect.Monad.IO.Instances -import Effect.Monad.Partiality -import Effect.Monad.Partiality.All -import Effect.Monad.Partiality.Instances -import Effect.Monad.Predicate -import Effect.Monad.Reader -import Effect.Monad.Reader.Indexed -import Effect.Monad.Reader.Instances -import Effect.Monad.Reader.Transformer -import Effect.Monad.Reader.Transformer.Base -import Effect.Monad.State -import Effect.Monad.State.Indexed -import Effect.Monad.State.Instances -import Effect.Monad.State.Transformer -import Effect.Monad.State.Transformer.Base -import Effect.Monad.Writer -import Effect.Monad.Writer.Indexed -import Effect.Monad.Writer.Instances -import Effect.Monad.Writer.Transformer -import Effect.Monad.Writer.Transformer.Base -import Foreign.Haskell -import Foreign.Haskell.Coerce -import Foreign.Haskell.Either -import Foreign.Haskell.List.NonEmpty -import Foreign.Haskell.Pair -import Function -import Function.Base -import Function.Bundles -import Function.Consequences -import Function.Consequences.Propositional -import Function.Consequences.Setoid -import Function.Construct.Composition -import Function.Construct.Constant -import Function.Construct.Identity -import Function.Construct.Symmetry -import Function.Core -import Function.Definitions -import Function.Dependent.Bundles -import Function.Endo.Propositional -import Function.Endo.Setoid -import Function.Identity.Effectful -import Function.Indexed.Bundles -import Function.Indexed.Relation.Binary.Equality -import Function.Metric -import Function.Metric.Bundles -import Function.Metric.Core -import Function.Metric.Definitions -import Function.Metric.Nat -import Function.Metric.Nat.Bundles -import Function.Metric.Nat.Core -import Function.Metric.Nat.Definitions -import Function.Metric.Nat.Structures -import Function.Metric.Rational -import Function.Metric.Rational.Bundles -import Function.Metric.Rational.Core -import Function.Metric.Rational.Definitions -import Function.Metric.Rational.Structures -import Function.Metric.Structures -import Function.Nary.NonDependent -import Function.Nary.NonDependent.Base -import Function.Properties -import Function.Properties.Bijection -import Function.Properties.Equivalence -import Function.Properties.Injection -import Function.Properties.Inverse -import Function.Properties.Inverse.HalfAdjointEquivalence -import Function.Properties.RightInverse -import Function.Properties.Surjection -import Function.Reasoning -import Function.Related.Propositional -import Function.Related.TypeIsomorphisms -import Function.Related.TypeIsomorphisms.Solver -import Function.Relation.Binary.Setoid.Equality -import Function.Strict -import Function.Structures -import Function.Structures.Biased -import Induction -import Induction.InfiniteDescent -import Induction.Lexicographic -import Induction.WellFounded -import IO -import IO.Base -import IO.Effectful -import IO.Finite -import IO.Handle -import IO.Infinite -import IO.Instances -import IO.Primitive.Core -import IO.Primitive.Finite -import IO.Primitive.Handle -import IO.Primitive.Infinite -import Level -import Level.Literals -import Reflection -import Reflection.AnnotatedAST -import Reflection.AnnotatedAST.Free -import Reflection.AST.Abstraction -import Reflection.AST -import Reflection.AST.AlphaEquality -import Reflection.AST.Argument -import Reflection.AST.Argument.Information -import Reflection.AST.Argument.Modality -import Reflection.AST.Argument.Quantity -import Reflection.AST.Argument.Relevance -import Reflection.AST.Argument.Visibility -import Reflection.AST.DeBruijn -import Reflection.AST.Definition -import Reflection.AST.Instances -import Reflection.AST.Literal -import Reflection.AST.Meta -import Reflection.AST.Name -import Reflection.AST.Pattern -import Reflection.AST.Show -import Reflection.AST.Term -import Reflection.AST.Traversal -import Reflection.AST.Universe -import Reflection.External -import Reflection.TCM -import Reflection.TCM.Effectful -import Reflection.TCM.Format -import Reflection.TCM.Instances -import Reflection.TCM.Syntax -import Reflection.TCM.Utilities -import Relation.Binary -import Relation.Binary.Bundles -import Relation.Binary.Bundles.Raw -import Relation.Binary.Consequences -import Relation.Binary.Construct.Add.Extrema.Equality -import Relation.Binary.Construct.Add.Extrema.NonStrict -import Relation.Binary.Construct.Add.Extrema.Strict -import Relation.Binary.Construct.Add.Infimum.Equality -import Relation.Binary.Construct.Add.Infimum.NonStrict -import Relation.Binary.Construct.Add.Infimum.Strict -import Relation.Binary.Construct.Add.Point.Equality -import Relation.Binary.Construct.Add.Supremum.Equality -import Relation.Binary.Construct.Add.Supremum.NonStrict -import Relation.Binary.Construct.Add.Supremum.Strict -import Relation.Binary.Construct.Always -import Relation.Binary.Construct.Closure.Equivalence -import Relation.Binary.Construct.Closure.Equivalence.Properties -import Relation.Binary.Construct.Closure.Reflexive -import Relation.Binary.Construct.Closure.Reflexive.Properties -import Relation.Binary.Construct.Closure.Reflexive.Properties.WithK -import Relation.Binary.Construct.Closure.ReflexiveTransitive -import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties -import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties.WithK -import Relation.Binary.Construct.Closure.Symmetric -import Relation.Binary.Construct.Closure.SymmetricTransitive -import Relation.Binary.Construct.Closure.Transitive -import Relation.Binary.Construct.Closure.Transitive.WithK -import Relation.Binary.Construct.Composition -import Relation.Binary.Construct.Constant -import Relation.Binary.Construct.Constant.Core -import Relation.Binary.Construct.Flip.EqAndOrd -import Relation.Binary.Construct.Flip.Ord -import Relation.Binary.Construct.FromPred -import Relation.Binary.Construct.FromRel -import Relation.Binary.Construct.Interior.Symmetric -import Relation.Binary.Construct.Intersection -import Relation.Binary.Construct.NaturalOrder.Left -import Relation.Binary.Construct.NaturalOrder.Right -import Relation.Binary.Construct.Never -import Relation.Binary.Construct.NonStrictToStrict -import Relation.Binary.Construct.On -import Relation.Binary.Construct.StrictToNonStrict -import Relation.Binary.Construct.Subst.Equality -import Relation.Binary.Construct.Union -import Relation.Binary.Core -import Relation.Binary.Definitions -import Relation.Binary.HeterogeneousEquality -import Relation.Binary.HeterogeneousEquality.Core -import Relation.Binary.HeterogeneousEquality.Quotients -import Relation.Binary.HeterogeneousEquality.Quotients.Examples -import Relation.Binary.Indexed.Heterogeneous -import Relation.Binary.Indexed.Heterogeneous.Bundles -import Relation.Binary.Indexed.Heterogeneous.Construct.At -import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial -import Relation.Binary.Indexed.Heterogeneous.Core -import Relation.Binary.Indexed.Heterogeneous.Definitions -import Relation.Binary.Indexed.Heterogeneous.Structures -import Relation.Binary.Indexed.Homogeneous -import Relation.Binary.Indexed.Homogeneous.Bundles -import Relation.Binary.Indexed.Homogeneous.Construct.At -import Relation.Binary.Indexed.Homogeneous.Core -import Relation.Binary.Indexed.Homogeneous.Definitions -import Relation.Binary.Indexed.Homogeneous.Structures -import Relation.Binary.Lattice -import Relation.Binary.Lattice.Bundles -import Relation.Binary.Lattice.Definitions -import Relation.Binary.Lattice.Properties.BoundedJoinSemilattice -import Relation.Binary.Lattice.Properties.BoundedLattice -import Relation.Binary.Lattice.Properties.BoundedMeetSemilattice -import Relation.Binary.Lattice.Properties.DistributiveLattice -import Relation.Binary.Lattice.Properties.HeytingAlgebra -import Relation.Binary.Lattice.Properties.JoinSemilattice -import Relation.Binary.Lattice.Properties.Lattice -import Relation.Binary.Lattice.Properties.MeetSemilattice -import Relation.Binary.Lattice.Structures -import Relation.Binary.Morphism -import Relation.Binary.Morphism.Bundles -import Relation.Binary.Morphism.Construct.Composition -import Relation.Binary.Morphism.Construct.Constant -import Relation.Binary.Morphism.Construct.Identity -import Relation.Binary.Morphism.Construct.Product -import Relation.Binary.Morphism.Definitions -import Relation.Binary.Morphism.OrderMonomorphism -import Relation.Binary.Morphism.RelMonomorphism -import Relation.Binary.Morphism.Structures -import Relation.Binary.Properties.ApartnessRelation -import Relation.Binary.Properties.DecSetoid -import Relation.Binary.Properties.DecTotalOrder -import Relation.Binary.Properties.PartialSetoid -import Relation.Binary.Properties.Poset -import Relation.Binary.Properties.Preorder -import Relation.Binary.Properties.Setoid -import Relation.Binary.Properties.StrictPartialOrder -import Relation.Binary.Properties.StrictTotalOrder -import Relation.Binary.Properties.TotalOrder -import Relation.Binary.PropositionalEquality -import Relation.Binary.PropositionalEquality.Algebra -import Relation.Binary.PropositionalEquality.Core -import Relation.Binary.PropositionalEquality.Properties -import Relation.Binary.PropositionalEquality.TrustMe -import Relation.Binary.PropositionalEquality.WithK -import Relation.Binary.Reasoning.Base.Apartness -import Relation.Binary.Reasoning.Base.Double -import Relation.Binary.Reasoning.Base.Partial -import Relation.Binary.Reasoning.Base.Single -import Relation.Binary.Reasoning.Base.Triple -import Relation.Binary.Reasoning.MultiSetoid -import Relation.Binary.Reasoning.PartialOrder -import Relation.Binary.Reasoning.PartialSetoid -import Relation.Binary.Reasoning.Preorder -import Relation.Binary.Reasoning.Setoid -import Relation.Binary.Reasoning.StrictPartialOrder -import Relation.Binary.Reasoning.Syntax -import Relation.Binary.Reflection -import Relation.Binary.Rewriting -import Relation.Binary.Structures -import Relation.Binary.Structures.Biased -import Relation.Binary.TypeClasses -import Relation.Nary -import Relation.Nullary -import Relation.Nullary.Construct.Add.Extrema -import Relation.Nullary.Construct.Add.Infimum -import Relation.Nullary.Construct.Add.Point -import Relation.Nullary.Construct.Add.Supremum -import Relation.Nullary.Decidable -import Relation.Nullary.Decidable.Core -import Relation.Nullary.Indexed -import Relation.Nullary.Indexed.Negation -import Relation.Nullary.Irrelevant -import Relation.Nullary.Negation -import Relation.Nullary.Negation.Core -import Relation.Nullary.Recomputable -import Relation.Nullary.Recomputable.Core -import Relation.Nullary.Reflects -import Relation.Nullary.Universe -import Relation.Unary -import Relation.Unary.Algebra -import Relation.Unary.Closure.Base -import Relation.Unary.Closure.Preorder -import Relation.Unary.Closure.StrictPartialOrder -import Relation.Unary.Consequences -import Relation.Unary.Indexed -import Relation.Unary.Polymorphic -import Relation.Unary.Polymorphic.Properties -import Relation.Unary.PredicateTransformer -import Relation.Unary.Properties -import Relation.Unary.Relation.Binary.Equality -import Relation.Unary.Relation.Binary.Subset -import Relation.Unary.Sized -import Size -import System.Clock -import System.Clock.Primitive -import System.Console.ANSI -import System.Directory -import System.Directory.Primitive -import System.Environment -import System.Environment.Primitive -import System.Exit -import System.Exit.Primitive -import System.FilePath.Posix -import System.FilePath.Posix.Primitive -import System.Process -import System.Process.Primitive -import System.Random -import System.Random.Primitive -import Tactic.Cong -import Tactic.MonoidSolver -import Tactic.RingSolver -import Tactic.RingSolver.Core.AlmostCommutativeRing -import Tactic.RingSolver.Core.Expression -import Tactic.RingSolver.Core.NatSet -import Tactic.RingSolver.Core.Polynomial.Base -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition -import Tactic.RingSolver.Core.Polynomial.Homomorphism -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Constants -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation -import Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables -import Tactic.RingSolver.Core.Polynomial.Parameters -import Tactic.RingSolver.Core.Polynomial.Reasoning -import Tactic.RingSolver.Core.Polynomial.Semantics -import Tactic.RingSolver.NonReflective -import Test.Golden -import Text.Format -import Text.Format.Generic -import Text.Pretty -import Text.Pretty.Core -import Text.Printf -import Text.Printf.Generic -import Text.Regex -import Text.Regex.Base -import Text.Regex.Derivative.Brzozowski -import Text.Regex.Properties -import Text.Regex.Properties.Core -import Text.Regex.Search -import Text.Regex.SmartConstructors -import Text.Regex.String -import Text.Regex.String.Unsafe -import Text.Tabular.Base -import Text.Tabular.List -import Text.Tabular.Vec +import Data.List.Relation.Binary.Permutation.Homogeneous +import Data.List.Relation.Binary.Permutation.Propositional +import Data.List.Relation.Binary.Permutation.Propositional.Properties +import Data.List.Relation.Binary.Permutation.Propositional.Properties.WithK +import Data.List.Relation.Binary.Permutation.Setoid +import Data.List.Relation.Binary.Permutation.Setoid.Properties +import Data.List.Relation.Binary.Permutation.Setoid.Properties.Maybe +import Data.List.Relation.Binary.Pointwise +import Data.List.Relation.Binary.Pointwise.Base +import Data.List.Relation.Binary.Pointwise.Properties +import Data.List.Relation.Binary.Prefix.Heterogeneous +import Data.List.Relation.Binary.Prefix.Heterogeneous.Properties +import Data.List.Relation.Binary.Prefix.Homogeneous.Properties +import Data.List.Relation.Binary.Prefix.Propositional.Properties +import Data.List.Relation.Binary.Sublist.DecPropositional +import Data.List.Relation.Binary.Sublist.DecPropositional.Solver +import Data.List.Relation.Binary.Sublist.DecSetoid +import Data.List.Relation.Binary.Sublist.DecSetoid.Solver +import Data.List.Relation.Binary.Sublist.Heterogeneous +import Data.List.Relation.Binary.Sublist.Heterogeneous.Core +import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties +import Data.List.Relation.Binary.Sublist.Heterogeneous.Solver +import Data.List.Relation.Binary.Sublist.Propositional +import Data.List.Relation.Binary.Sublist.Propositional.Example.UniqueBoundVariables +import Data.List.Relation.Binary.Sublist.Propositional.Properties +import Data.List.Relation.Binary.Sublist.Propositional.Slice +import Data.List.Relation.Binary.Sublist.Setoid +import Data.List.Relation.Binary.Sublist.Setoid.Properties +import Data.List.Relation.Binary.Subset.DecPropositional +import Data.List.Relation.Binary.Subset.DecSetoid +import Data.List.Relation.Binary.Subset.Propositional +import Data.List.Relation.Binary.Subset.Propositional.Properties +import Data.List.Relation.Binary.Subset.Setoid +import Data.List.Relation.Binary.Subset.Setoid.Properties +import Data.List.Relation.Binary.Suffix.Heterogeneous +import Data.List.Relation.Binary.Suffix.Heterogeneous.Properties +import Data.List.Relation.Binary.Suffix.Homogeneous.Properties +import Data.List.Relation.Binary.Suffix.Propositional.Properties +import Data.List.Relation.Ternary.Appending +import Data.List.Relation.Ternary.Appending.Properties +import Data.List.Relation.Ternary.Appending.Propositional +import Data.List.Relation.Ternary.Appending.Propositional.Properties +import Data.List.Relation.Ternary.Appending.Setoid +import Data.List.Relation.Ternary.Appending.Setoid.Properties +import Data.List.Relation.Ternary.Interleaving +import Data.List.Relation.Ternary.Interleaving.Properties +import Data.List.Relation.Ternary.Interleaving.Propositional +import Data.List.Relation.Ternary.Interleaving.Propositional.Properties +import Data.List.Relation.Ternary.Interleaving.Setoid +import Data.List.Relation.Ternary.Interleaving.Setoid.Properties +import Data.List.Relation.Unary.All +import Data.List.Relation.Unary.All.Properties +import Data.List.Relation.Unary.All.Properties.Core +import Data.List.Relation.Unary.AllPairs +import Data.List.Relation.Unary.AllPairs.Core +import Data.List.Relation.Unary.AllPairs.Properties +import Data.List.Relation.Unary.Any +import Data.List.Relation.Unary.Any.Properties +import Data.List.Relation.Unary.Enumerates.Setoid +import Data.List.Relation.Unary.Enumerates.Setoid.Properties +import Data.List.Relation.Unary.First +import Data.List.Relation.Unary.First.Properties +import Data.List.Relation.Unary.Grouped +import Data.List.Relation.Unary.Grouped.Properties +import Data.List.Relation.Unary.Linked +import Data.List.Relation.Unary.Linked.Properties +import Data.List.Relation.Unary.Sorted.TotalOrder +import Data.List.Relation.Unary.Sorted.TotalOrder.Properties +import Data.List.Relation.Unary.Sufficient +import Data.List.Relation.Unary.Unique.DecPropositional +import Data.List.Relation.Unary.Unique.DecPropositional.Properties +import Data.List.Relation.Unary.Unique.DecSetoid +import Data.List.Relation.Unary.Unique.DecSetoid.Properties +import Data.List.Relation.Unary.Unique.Propositional +import Data.List.Relation.Unary.Unique.Propositional.Properties +import Data.List.Relation.Unary.Unique.Setoid +import Data.List.Relation.Unary.Unique.Setoid.Properties +import Data.List.Reverse +import Data.List.Scans.Base +import Data.List.Scans.Properties +import Data.List.Show +import Data.List.Sort +import Data.List.Sort.Base +import Data.List.Sort.InsertionSort +import Data.List.Sort.InsertionSort.Base +import Data.List.Sort.InsertionSort.Properties +import Data.List.Sort.MergeSort +import Data.List.Sort.MergeSort.Base +import Data.List.Sort.MergeSort.Properties +import Data.List.Zipper +import Data.List.Zipper.Properties +import Data.Maybe +import Data.Maybe.Base +import Data.Maybe.Effectful +import Data.Maybe.Effectful.Transformer +import Data.Maybe.Instances +import Data.Maybe.Properties +import Data.Maybe.Relation.Binary.Connected +import Data.Maybe.Relation.Binary.Pointwise +import Data.Maybe.Relation.Unary.All +import Data.Maybe.Relation.Unary.All.Properties +import Data.Maybe.Relation.Unary.Any +import Data.Nat +import Data.Nat.Base +import Data.Nat.Binary +import Data.Nat.Binary.Base +import Data.Nat.Binary.Induction +import Data.Nat.Binary.Instances +import Data.Nat.Binary.Properties +import Data.Nat.Binary.Subtraction +import Data.Nat.Combinatorics +import Data.Nat.Combinatorics.Base +import Data.Nat.Combinatorics.Specification +import Data.Nat.Coprimality +import Data.Nat.Divisibility +import Data.Nat.Divisibility.Core +import Data.Nat.DivMod +import Data.Nat.DivMod.Core +import Data.Nat.DivMod.WithK +import Data.Nat.GCD +import Data.Nat.GCD.Lemmas +import Data.Nat.GeneralisedArithmetic +import Data.Nat.Induction +import Data.Nat.InfinitelyOften +import Data.Nat.Instances +import Data.Nat.LCM +import Data.Nat.ListAction +import Data.Nat.ListAction.Properties +import Data.Nat.Literals +import Data.Nat.Logarithm +import Data.Nat.Logarithm.Core +import Data.Nat.Primality +import Data.Nat.Primality.Factorisation +import Data.Nat.Properties +import Data.Nat.PseudoRandom.LCG +import Data.Nat.PseudoRandom.LCG.Unsafe +import Data.Nat.Reflection +import Data.Nat.Show +import Data.Nat.Show.Properties +import Data.Nat.Solver +import Data.Nat.Tactic.RingSolver +import Data.Nat.WithK +import Data.Parity +import Data.Parity.Base +import Data.Parity.Instances +import Data.Parity.Properties +import Data.Product +import Data.Product.Algebra +import Data.Product.Base +import Data.Product.Effectful.Examples +import Data.Product.Effectful.Left +import Data.Product.Effectful.Left.Base +import Data.Product.Effectful.Right +import Data.Product.Effectful.Right.Base +import Data.Product.Function.Dependent.Propositional +import Data.Product.Function.Dependent.Propositional.WithK +import Data.Product.Function.Dependent.Setoid +import Data.Product.Function.NonDependent.Propositional +import Data.Product.Function.NonDependent.Setoid +import Data.Product.Instances +import Data.Product.Nary.NonDependent +import Data.Product.Properties +import Data.Product.Properties.Dependent +import Data.Product.Properties.WithK +import Data.Product.Relation.Binary.Lex.NonStrict +import Data.Product.Relation.Binary.Lex.Strict +import Data.Product.Relation.Binary.Pointwise.Dependent +import Data.Product.Relation.Binary.Pointwise.Dependent.WithK +import Data.Product.Relation.Binary.Pointwise.NonDependent +import Data.Product.Relation.Unary.All +import Data.Rational +import Data.Rational.Base +import Data.Rational.Instances +import Data.Rational.Literals +import Data.Rational.Properties +import Data.Rational.Show +import Data.Rational.Solver +import Data.Rational.Unnormalised +import Data.Rational.Unnormalised.Base +import Data.Rational.Unnormalised.Properties +import Data.Rational.Unnormalised.Show +import Data.Rational.Unnormalised.Solver +import Data.Record +import Data.Refinement +import Data.Refinement.Base +import Data.Refinement.Properties +import Data.Refinement.Relation.Unary.All +import Data.Sign +import Data.Sign.Base +import Data.Sign.Instances +import Data.Sign.Properties +import Data.Sign.Show +import Data.Star.BoundedVec +import Data.Star.Decoration +import Data.Star.Environment +import Data.Star.Fin +import Data.Star.List +import Data.Star.Nat +import Data.Star.Pointer +import Data.Star.Vec +import Data.String +import Data.String.Base +import Data.String.Instances +import Data.String.Literals +import Data.String.Properties +import Data.String.Unsafe +import Data.Sum +import Data.Sum.Algebra +import Data.Sum.Base +import Data.Sum.Effectful.Examples +import Data.Sum.Effectful.Left +import Data.Sum.Effectful.Left.Transformer +import Data.Sum.Effectful.Right +import Data.Sum.Effectful.Right.Transformer +import Data.Sum.Function.Propositional +import Data.Sum.Function.Setoid +import Data.Sum.Instances +import Data.Sum.Properties +import Data.Sum.Relation.Binary.LeftOrder +import Data.Sum.Relation.Binary.Pointwise +import Data.Sum.Relation.Unary.All +import Data.These +import Data.These.Base +import Data.These.Effectful.Left +import Data.These.Effectful.Left.Base +import Data.These.Effectful.Right +import Data.These.Effectful.Right.Base +import Data.These.Instances +import Data.These.Properties +import Data.Tree.AVL +import Data.Tree.AVL.Height +import Data.Tree.AVL.Indexed +import Data.Tree.AVL.Indexed.Relation.Unary.All +import Data.Tree.AVL.Indexed.Relation.Unary.Any +import Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties +import Data.Tree.AVL.Indexed.WithK +import Data.Tree.AVL.IndexedMap +import Data.Tree.AVL.Key +import Data.Tree.AVL.Map +import Data.Tree.AVL.Map.Membership.Propositional +import Data.Tree.AVL.Map.Membership.Propositional.Properties +import Data.Tree.AVL.Map.Relation.Unary.Any +import Data.Tree.AVL.NonEmpty +import Data.Tree.AVL.NonEmpty.Propositional +import Data.Tree.AVL.Relation.Unary.Any +import Data.Tree.AVL.Sets +import Data.Tree.AVL.Sets.Membership +import Data.Tree.AVL.Sets.Membership.Properties +import Data.Tree.AVL.Value +import Data.Tree.Binary +import Data.Tree.Binary.Properties +import Data.Tree.Binary.Relation.Unary.All +import Data.Tree.Binary.Relation.Unary.All.Properties +import Data.Tree.Binary.Show +import Data.Tree.Binary.Zipper +import Data.Tree.Binary.Zipper.Properties +import Data.Tree.Rose +import Data.Tree.Rose.Properties +import Data.Tree.Rose.Show +import Data.Trie +import Data.Trie.NonEmpty +import Data.Unit +import Data.Unit.Base +import Data.Unit.Instances +import Data.Unit.NonEta +import Data.Unit.Polymorphic +import Data.Unit.Polymorphic.Base +import Data.Unit.Polymorphic.Instances +import Data.Unit.Polymorphic.Properties +import Data.Unit.Properties +import Data.Universe +import Data.Universe.Indexed +import Data.Vec +import Data.Vec.Base +import Data.Vec.Bounded +import Data.Vec.Bounded.Base +import Data.Vec.Bounded.Show +import Data.Vec.Effectful +import Data.Vec.Effectful.Foldable +import Data.Vec.Effectful.Transformer +import Data.Vec.Functional +import Data.Vec.Functional.Properties +import Data.Vec.Functional.Relation.Binary.Equality.Setoid +import Data.Vec.Functional.Relation.Binary.Permutation +import Data.Vec.Functional.Relation.Binary.Permutation.Properties +import Data.Vec.Functional.Relation.Binary.Pointwise +import Data.Vec.Functional.Relation.Binary.Pointwise.Properties +import Data.Vec.Functional.Relation.Unary.All +import Data.Vec.Functional.Relation.Unary.All.Properties +import Data.Vec.Functional.Relation.Unary.Any +import Data.Vec.Instances +import Data.Vec.Membership.DecPropositional +import Data.Vec.Membership.DecSetoid +import Data.Vec.Membership.Propositional +import Data.Vec.Membership.Propositional.Properties +import Data.Vec.Membership.Setoid +import Data.Vec.N-ary +import Data.Vec.Properties +import Data.Vec.Properties.WithK +import Data.Vec.Recursive +import Data.Vec.Recursive.Effectful +import Data.Vec.Recursive.Properties +import Data.Vec.Reflection +import Data.Vec.Relation.Binary.Equality.Cast +import Data.Vec.Relation.Binary.Equality.DecPropositional +import Data.Vec.Relation.Binary.Equality.DecSetoid +import Data.Vec.Relation.Binary.Equality.Propositional +import Data.Vec.Relation.Binary.Equality.Propositional.WithK +import Data.Vec.Relation.Binary.Equality.Setoid +import Data.Vec.Relation.Binary.Lex.Core +import Data.Vec.Relation.Binary.Lex.NonStrict +import Data.Vec.Relation.Binary.Lex.Strict +import Data.Vec.Relation.Binary.Pointwise.Extensional +import Data.Vec.Relation.Binary.Pointwise.Inductive +import Data.Vec.Relation.Unary.All +import Data.Vec.Relation.Unary.All.Properties +import Data.Vec.Relation.Unary.AllPairs +import Data.Vec.Relation.Unary.AllPairs.Core +import Data.Vec.Relation.Unary.AllPairs.Properties +import Data.Vec.Relation.Unary.Any +import Data.Vec.Relation.Unary.Any.Properties +import Data.Vec.Relation.Unary.Linked +import Data.Vec.Relation.Unary.Linked.Properties +import Data.Vec.Relation.Unary.Unique.Propositional +import Data.Vec.Relation.Unary.Unique.Propositional.Properties +import Data.Vec.Relation.Unary.Unique.Setoid +import Data.Vec.Relation.Unary.Unique.Setoid.Properties +import Data.Vec.Show +import Data.W +import Data.W.Indexed +import Data.W.Sized +import Data.W.WithK +import Data.Word64 +import Data.Word64.Base +import Data.Word64.Instances +import Data.Word64.Literals +import Data.Word64.Primitive +import Data.Word64.Properties +import Data.Word64.Show +import Data.Word64.Unsafe +import Data.Word8.Base +import Data.Word8.Literals +import Data.Word8.Primitive +import Data.Word8.Show +import Data.Wrap +import Debug.Trace +import Effect.Applicative +import Effect.Applicative.Indexed +import Effect.Applicative.Predicate +import Effect.Choice +import Effect.Comonad +import Effect.Empty +import Effect.Foldable +import Effect.Functor +import Effect.Functor.Predicate +import Effect.Monad +import Effect.Monad.Continuation +import Effect.Monad.Error.Transformer +import Effect.Monad.Identity +import Effect.Monad.Identity.Instances +import Effect.Monad.Indexed +import Effect.Monad.IO +import Effect.Monad.IO.Instances +import Effect.Monad.Partiality +import Effect.Monad.Partiality.All +import Effect.Monad.Partiality.Instances +import Effect.Monad.Predicate +import Effect.Monad.Reader +import Effect.Monad.Reader.Indexed +import Effect.Monad.Reader.Instances +import Effect.Monad.Reader.Transformer +import Effect.Monad.Reader.Transformer.Base +import Effect.Monad.State +import Effect.Monad.State.Indexed +import Effect.Monad.State.Instances +import Effect.Monad.State.Transformer +import Effect.Monad.State.Transformer.Base +import Effect.Monad.Writer +import Effect.Monad.Writer.Indexed +import Effect.Monad.Writer.Instances +import Effect.Monad.Writer.Transformer +import Effect.Monad.Writer.Transformer.Base +import Foreign.Haskell +import Foreign.Haskell.Coerce +import Foreign.Haskell.Either +import Foreign.Haskell.List.NonEmpty +import Foreign.Haskell.Pair +import Function +import Function.Base +import Function.Bundles +import Function.Consequences +import Function.Consequences.Propositional +import Function.Consequences.Setoid +import Function.Construct.Composition +import Function.Construct.Constant +import Function.Construct.Identity +import Function.Construct.Symmetry +import Function.Core +import Function.Definitions +import Function.Dependent.Bundles +import Function.Endo.Propositional +import Function.Endo.Setoid +import Function.Identity.Effectful +import Function.Indexed.Bundles +import Function.Indexed.Relation.Binary.Equality +import Function.Metric +import Function.Metric.Bundles +import Function.Metric.Core +import Function.Metric.Definitions +import Function.Metric.Nat +import Function.Metric.Nat.Bundles +import Function.Metric.Nat.Core +import Function.Metric.Nat.Definitions +import Function.Metric.Nat.Structures +import Function.Metric.Rational +import Function.Metric.Rational.Bundles +import Function.Metric.Rational.Core +import Function.Metric.Rational.Definitions +import Function.Metric.Rational.Structures +import Function.Metric.Structures +import Function.Nary.NonDependent +import Function.Nary.NonDependent.Base +import Function.Properties +import Function.Properties.Bijection +import Function.Properties.Equivalence +import Function.Properties.Injection +import Function.Properties.Inverse +import Function.Properties.Inverse.HalfAdjointEquivalence +import Function.Properties.RightInverse +import Function.Properties.Surjection +import Function.Reasoning +import Function.Related.Propositional +import Function.Related.TypeIsomorphisms +import Function.Related.TypeIsomorphisms.Solver +import Function.Relation.Binary.Setoid.Equality +import Function.Strict +import Function.Structures +import Function.Structures.Biased +import Induction +import Induction.InfiniteDescent +import Induction.Lexicographic +import Induction.WellFounded +import IO +import IO.Base +import IO.Effectful +import IO.Finite +import IO.Handle +import IO.Infinite +import IO.Instances +import IO.Primitive.Core +import IO.Primitive.Finite +import IO.Primitive.Handle +import IO.Primitive.Infinite +import Level +import Level.Literals +import Reflection +import Reflection.AnnotatedAST +import Reflection.AnnotatedAST.Free +import Reflection.AST +import Reflection.AST.Abstraction +import Reflection.AST.AlphaEquality +import Reflection.AST.Argument +import Reflection.AST.Argument.Information +import Reflection.AST.Argument.Modality +import Reflection.AST.Argument.Quantity +import Reflection.AST.Argument.Relevance +import Reflection.AST.Argument.Visibility +import Reflection.AST.DeBruijn +import Reflection.AST.Definition +import Reflection.AST.Instances +import Reflection.AST.Literal +import Reflection.AST.Meta +import Reflection.AST.Name +import Reflection.AST.Pattern +import Reflection.AST.Show +import Reflection.AST.Term +import Reflection.AST.Traversal +import Reflection.AST.Universe +import Reflection.External +import Reflection.TCM +import Reflection.TCM.Effectful +import Reflection.TCM.Format +import Reflection.TCM.Instances +import Reflection.TCM.Syntax +import Reflection.TCM.Utilities +import Relation.Binary +import Relation.Binary.Bundles +import Relation.Binary.Bundles.Raw +import Relation.Binary.Consequences +import Relation.Binary.Construct.Add.Extrema.Equality +import Relation.Binary.Construct.Add.Extrema.NonStrict +import Relation.Binary.Construct.Add.Extrema.Strict +import Relation.Binary.Construct.Add.Infimum.Equality +import Relation.Binary.Construct.Add.Infimum.NonStrict +import Relation.Binary.Construct.Add.Infimum.Strict +import Relation.Binary.Construct.Add.Point.Equality +import Relation.Binary.Construct.Add.Supremum.Equality +import Relation.Binary.Construct.Add.Supremum.NonStrict +import Relation.Binary.Construct.Add.Supremum.Strict +import Relation.Binary.Construct.Always +import Relation.Binary.Construct.Closure.Equivalence +import Relation.Binary.Construct.Closure.Equivalence.Properties +import Relation.Binary.Construct.Closure.Reflexive +import Relation.Binary.Construct.Closure.Reflexive.Properties +import Relation.Binary.Construct.Closure.Reflexive.Properties.WithK +import Relation.Binary.Construct.Closure.ReflexiveTransitive +import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties +import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties.WithK +import Relation.Binary.Construct.Closure.Symmetric +import Relation.Binary.Construct.Closure.SymmetricTransitive +import Relation.Binary.Construct.Closure.Transitive +import Relation.Binary.Construct.Closure.Transitive.WithK +import Relation.Binary.Construct.Composition +import Relation.Binary.Construct.Constant +import Relation.Binary.Construct.Constant.Core +import Relation.Binary.Construct.Flip.EqAndOrd +import Relation.Binary.Construct.Flip.Ord +import Relation.Binary.Construct.FromPred +import Relation.Binary.Construct.FromRel +import Relation.Binary.Construct.Interior.Symmetric +import Relation.Binary.Construct.Intersection +import Relation.Binary.Construct.NaturalOrder.Left +import Relation.Binary.Construct.NaturalOrder.Right +import Relation.Binary.Construct.Never +import Relation.Binary.Construct.NonStrictToStrict +import Relation.Binary.Construct.On +import Relation.Binary.Construct.StrictToNonStrict +import Relation.Binary.Construct.Subst.Equality +import Relation.Binary.Construct.Union +import Relation.Binary.Core +import Relation.Binary.Definitions +import Relation.Binary.HeterogeneousEquality +import Relation.Binary.HeterogeneousEquality.Core +import Relation.Binary.HeterogeneousEquality.Quotients +import Relation.Binary.HeterogeneousEquality.Quotients.Examples +import Relation.Binary.Indexed.Heterogeneous +import Relation.Binary.Indexed.Heterogeneous.Bundles +import Relation.Binary.Indexed.Heterogeneous.Construct.At +import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial +import Relation.Binary.Indexed.Heterogeneous.Core +import Relation.Binary.Indexed.Heterogeneous.Definitions +import Relation.Binary.Indexed.Heterogeneous.Structures +import Relation.Binary.Indexed.Homogeneous +import Relation.Binary.Indexed.Homogeneous.Bundles +import Relation.Binary.Indexed.Homogeneous.Construct.At +import Relation.Binary.Indexed.Homogeneous.Core +import Relation.Binary.Indexed.Homogeneous.Definitions +import Relation.Binary.Indexed.Homogeneous.Structures +import Relation.Binary.Lattice +import Relation.Binary.Lattice.Bundles +import Relation.Binary.Lattice.Definitions +import Relation.Binary.Lattice.Properties.BoundedJoinSemilattice +import Relation.Binary.Lattice.Properties.BoundedLattice +import Relation.Binary.Lattice.Properties.BoundedMeetSemilattice +import Relation.Binary.Lattice.Properties.DistributiveLattice +import Relation.Binary.Lattice.Properties.HeytingAlgebra +import Relation.Binary.Lattice.Properties.JoinSemilattice +import Relation.Binary.Lattice.Properties.Lattice +import Relation.Binary.Lattice.Properties.MeetSemilattice +import Relation.Binary.Lattice.Structures +import Relation.Binary.Morphism +import Relation.Binary.Morphism.Bundles +import Relation.Binary.Morphism.Construct.Composition +import Relation.Binary.Morphism.Construct.Constant +import Relation.Binary.Morphism.Construct.Identity +import Relation.Binary.Morphism.Construct.Product +import Relation.Binary.Morphism.Definitions +import Relation.Binary.Morphism.OrderMonomorphism +import Relation.Binary.Morphism.RelMonomorphism +import Relation.Binary.Morphism.Structures +import Relation.Binary.Properties.ApartnessRelation +import Relation.Binary.Properties.DecSetoid +import Relation.Binary.Properties.DecTotalOrder +import Relation.Binary.Properties.PartialSetoid +import Relation.Binary.Properties.Poset +import Relation.Binary.Properties.Preorder +import Relation.Binary.Properties.Setoid +import Relation.Binary.Properties.StrictPartialOrder +import Relation.Binary.Properties.StrictTotalOrder +import Relation.Binary.Properties.TotalOrder +import Relation.Binary.PropositionalEquality +import Relation.Binary.PropositionalEquality.Algebra +import Relation.Binary.PropositionalEquality.Core +import Relation.Binary.PropositionalEquality.Properties +import Relation.Binary.PropositionalEquality.TrustMe +import Relation.Binary.PropositionalEquality.WithK +import Relation.Binary.Reasoning.Base.Apartness +import Relation.Binary.Reasoning.Base.Double +import Relation.Binary.Reasoning.Base.Partial +import Relation.Binary.Reasoning.Base.Single +import Relation.Binary.Reasoning.Base.Triple +import Relation.Binary.Reasoning.MultiSetoid +import Relation.Binary.Reasoning.PartialOrder +import Relation.Binary.Reasoning.PartialSetoid +import Relation.Binary.Reasoning.Preorder +import Relation.Binary.Reasoning.Setoid +import Relation.Binary.Reasoning.StrictPartialOrder +import Relation.Binary.Reasoning.Syntax +import Relation.Binary.Reflection +import Relation.Binary.Rewriting +import Relation.Binary.Structures +import Relation.Binary.Structures.Biased +import Relation.Binary.TypeClasses +import Relation.Nary +import Relation.Nullary +import Relation.Nullary.Construct.Add.Extrema +import Relation.Nullary.Construct.Add.Infimum +import Relation.Nullary.Construct.Add.Point +import Relation.Nullary.Construct.Add.Supremum +import Relation.Nullary.Decidable +import Relation.Nullary.Decidable.Core +import Relation.Nullary.Indexed +import Relation.Nullary.Indexed.Negation +import Relation.Nullary.Irrelevant +import Relation.Nullary.Negation +import Relation.Nullary.Negation.Core +import Relation.Nullary.Recomputable +import Relation.Nullary.Recomputable.Core +import Relation.Nullary.Reflects +import Relation.Nullary.Universe +import Relation.Unary +import Relation.Unary.Algebra +import Relation.Unary.Closure.Base +import Relation.Unary.Closure.Preorder +import Relation.Unary.Closure.StrictPartialOrder +import Relation.Unary.Consequences +import Relation.Unary.Indexed +import Relation.Unary.Polymorphic +import Relation.Unary.Polymorphic.Properties +import Relation.Unary.PredicateTransformer +import Relation.Unary.Properties +import Relation.Unary.Relation.Binary.Equality +import Relation.Unary.Relation.Binary.Subset +import Relation.Unary.Sized +import Size +import System.Clock +import System.Clock.Primitive +import System.Console.ANSI +import System.Directory +import System.Directory.Primitive +import System.Environment +import System.Environment.Primitive +import System.Exit +import System.Exit.Primitive +import System.FilePath.Posix +import System.FilePath.Posix.Primitive +import System.Process +import System.Process.Primitive +import System.Random +import System.Random.Primitive +import Tactic.Cong +import Tactic.MonoidSolver +import Tactic.RingSolver +import Tactic.RingSolver.Core.AlmostCommutativeRing +import Tactic.RingSolver.Core.Expression +import Tactic.RingSolver.Core.NatSet +import Tactic.RingSolver.Core.Polynomial.Base +import Tactic.RingSolver.Core.Polynomial.Homomorphism +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Addition +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Constants +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Exponentiation +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Multiplication +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation +import Tactic.RingSolver.Core.Polynomial.Homomorphism.Variables +import Tactic.RingSolver.Core.Polynomial.Parameters +import Tactic.RingSolver.Core.Polynomial.Reasoning +import Tactic.RingSolver.Core.Polynomial.Semantics +import Tactic.RingSolver.NonReflective +import Test.Golden +import Text.Format +import Text.Format.Generic +import Text.Pretty +import Text.Pretty.Core +import Text.Printf +import Text.Printf.Generic +import Text.Regex +import Text.Regex.Base +import Text.Regex.Derivative.Brzozowski +import Text.Regex.Properties +import Text.Regex.Properties.Core +import Text.Regex.Search +import Text.Regex.SmartConstructors +import Text.Regex.String +import Text.Regex.String.Unsafe +import Text.Tabular.Base +import Text.Tabular.List +import Text.Tabular.Vec \ No newline at end of file