Skip to content

Commit 2c9232b

Browse files
committedMay 2, 2022
[ re agda#1752 ] add properties of ordered structures for Nat.
1 parent cadca35 commit 2c9232b

File tree

2 files changed

+230
-230
lines changed

2 files changed

+230
-230
lines changed
 

‎CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,16 @@ Other minor changes
12691269
12701270
anyUpTo? : ∀ (P? : U.Decidable P) (v : ℕ) → Dec (∃ λ n → n < v × P n)
12711271
allUpTo? : ∀ (P? : U.Decidable P) (v : ℕ) → Dec (∀ {n} → n < v → P n)
1272+
1273+
+-isPomagma : IsPomagma _+_
1274+
+-isPosemigroup : IsPosemigroup _+_
1275+
+-0-isPomonoid : IsPomonoid _+_ 0
1276+
+-0-isCommutativePomonoid : IsCommutativePomonoid _+_ 0
1277+
+-0-commutativePomonoid : CommutativePomonoid 0ℓ 0ℓ 0ℓ
1278+
+-*-isPosemiring : IsPosemiring _+_ _*_ 0 1
1279+
*-1-isCommutativePomonoid : IsCommutativePomonoid _*_ 1
1280+
+-*-posemiring : Posemiring 0ℓ 0ℓ 0ℓ
1281+
*-1-commutativePomonoid : CommutativePomonoid 0ℓ 0ℓ 0ℓ
12721282
```
12731283

12741284
* Added new functions in `Data.Nat`:

‎src/Data/Nat/Properties.agda

Lines changed: 220 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Data.Nat.Properties where
1313

1414
open import Axiom.UniquenessOfIdentityProofs
1515
open import Algebra.Bundles
16+
open import Algebra.Ordered.Bundles
1617
open import Algebra.Morphism
1718
open import Algebra.Consequences.Propositional
1819
open import Algebra.Construct.NaturalChoice.Base
@@ -44,6 +45,7 @@ open import Algebra.Definitions {A = ℕ} _≡_
4445
open import Algebra.Definitions
4546
using (LeftCancellative; RightCancellative; Cancellative)
4647
open import Algebra.Structures {A = ℕ} _≡_
48+
import Algebra.Ordered.Structures as OrderedStructures
4749

4850
------------------------------------------------------------------------
4951
-- Properties of NonZero
@@ -537,111 +539,6 @@ open ≤-Reasoning
537539
+-cancel-≡ : Cancellative _≡_ _+_
538540
+-cancel-≡ = +-cancelˡ-≡ , +-cancelʳ-≡
539541

540-
------------------------------------------------------------------------
541-
-- Structures
542-
543-
+-isMagma : IsMagma _+_
544-
+-isMagma = record
545-
{ isEquivalence = isEquivalence
546-
; ∙-cong = cong₂ _+_
547-
}
548-
549-
+-isSemigroup : IsSemigroup _+_
550-
+-isSemigroup = record
551-
{ isMagma = +-isMagma
552-
; assoc = +-assoc
553-
}
554-
555-
+-isCommutativeSemigroup : IsCommutativeSemigroup _+_
556-
+-isCommutativeSemigroup = record
557-
{ isSemigroup = +-isSemigroup
558-
; comm = +-comm
559-
}
560-
561-
+-0-isMonoid : IsMonoid _+_ 0
562-
+-0-isMonoid = record
563-
{ isSemigroup = +-isSemigroup
564-
; identity = +-identity
565-
}
566-
567-
+-0-isCommutativeMonoid : IsCommutativeMonoid _+_ 0
568-
+-0-isCommutativeMonoid = record
569-
{ isMonoid = +-0-isMonoid
570-
; comm = +-comm
571-
}
572-
573-
------------------------------------------------------------------------
574-
-- Raw bundles
575-
576-
+-rawMagma : RawMagma 0ℓ 0ℓ
577-
+-rawMagma = record
578-
{ _≈_ = _≡_
579-
; _∙_ = _+_
580-
}
581-
582-
+-0-rawMonoid : RawMonoid 0ℓ 0ℓ
583-
+-0-rawMonoid = record
584-
{ _≈_ = _≡_
585-
; _∙_ = _+_
586-
; ε = 0
587-
}
588-
589-
------------------------------------------------------------------------
590-
-- Bundles
591-
592-
+-magma : Magma 0ℓ 0ℓ
593-
+-magma = record
594-
{ isMagma = +-isMagma
595-
}
596-
597-
+-semigroup : Semigroup 0ℓ 0ℓ
598-
+-semigroup = record
599-
{ isSemigroup = +-isSemigroup
600-
}
601-
602-
+-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ
603-
+-commutativeSemigroup = record
604-
{ isCommutativeSemigroup = +-isCommutativeSemigroup
605-
}
606-
607-
+-0-monoid : Monoid 0ℓ 0ℓ
608-
+-0-monoid = record
609-
{ isMonoid = +-0-isMonoid
610-
}
611-
612-
+-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ
613-
+-0-commutativeMonoid = record
614-
{ isCommutativeMonoid = +-0-isCommutativeMonoid
615-
}
616-
617-
∸-magma : Magma 0ℓ 0ℓ
618-
∸-magma = magma _∸_
619-
620-
621-
------------------------------------------------------------------------
622-
-- Other properties of _+_ and _≡_
623-
624-
m≢1+m+n : m {n} m ≢ suc (m + n)
625-
m≢1+m+n (suc m) eq = m≢1+m+n m (cong pred eq)
626-
627-
m≢1+n+m : m {n} m ≢ suc (n + m)
628-
m≢1+n+m m m≡1+n+m = m≢1+m+n m (trans m≡1+n+m (cong suc (+-comm _ m)))
629-
630-
m+1+n≢m : m {n} m + suc n ≢ m
631-
m+1+n≢m (suc m) = (m+1+n≢m m) ∘ suc-injective
632-
633-
m+1+n≢n : m {n} m + suc n ≢ n
634-
m+1+n≢n m {n} rewrite +-suc m n = ≢-sym (m≢1+n+m n)
635-
636-
m+1+n≢0 : m {n} m + suc n ≢ 0
637-
m+1+n≢0 m {n} rewrite +-suc m n = λ()
638-
639-
m+n≡0⇒m≡0 : m {n} m + n ≡ 0 m ≡ 0
640-
m+n≡0⇒m≡0 zero eq = refl
641-
642-
m+n≡0⇒n≡0 : m {n} m + n ≡ 0 n ≡ 0
643-
m+n≡0⇒n≡0 m {n} m+n≡0 = m+n≡0⇒m≡0 n (trans (+-comm n m) (m+n≡0))
644-
645542
------------------------------------------------------------------------
646543
-- Properties of _+_ and _≤_/_<_
647544

@@ -732,6 +629,107 @@ m+n≮n (suc m) (suc n) (s<s m+n<n) = m+n≮n m (suc n) (<-step m+n<n)
732629
m+n≮m : m n m + n ≮ m
733630
m+n≮m m n = subst (_≮ m) (+-comm n m) (m+n≮n n m)
734631

632+
------------------------------------------------------------------------
633+
-- Structures
634+
635+
open OrderedStructures _≡_ _≤_
636+
637+
+-isPomagma : IsPomagma _+_
638+
+-isPomagma = record
639+
{ isPartialOrder = ≤-isPartialOrder
640+
; mono = +-mono-≤
641+
}
642+
643+
+-isPosemigroup : IsPosemigroup _+_
644+
+-isPosemigroup = record
645+
{ isPomagma = +-isPomagma
646+
; assoc = +-assoc
647+
}
648+
649+
+-0-isPomonoid : IsPomonoid _+_ 0
650+
+-0-isPomonoid = record
651+
{ isPosemigroup = +-isPosemigroup
652+
; identity = +-identity
653+
}
654+
655+
+-0-isCommutativePomonoid : IsCommutativePomonoid _+_ 0
656+
+-0-isCommutativePomonoid = record
657+
{ isPomonoid = +-0-isPomonoid
658+
; comm = +-comm
659+
}
660+
661+
open IsCommutativePomonoid +-0-isCommutativePomonoid public using ()
662+
renaming
663+
( isMagma to +-isMagma
664+
; isSemigroup to +-isSemigroup
665+
; isCommutativeSemigroup to +-isCommutativeSemigroup
666+
; isMonoid to +-0-isMonoid
667+
; isCommutativeMonoid to +-0-isCommutativeMonoid
668+
)
669+
670+
------------------------------------------------------------------------
671+
-- Raw bundles
672+
673+
+-rawMagma : RawMagma 0ℓ 0ℓ
674+
+-rawMagma = record
675+
{ _≈_ = _≡_
676+
; _∙_ = _+_
677+
}
678+
679+
+-0-rawMonoid : RawMonoid 0ℓ 0ℓ
680+
+-0-rawMonoid = record
681+
{ _≈_ = _≡_
682+
; _∙_ = _+_
683+
; ε = 0
684+
}
685+
686+
------------------------------------------------------------------------
687+
-- Bundles
688+
689+
+-0-commutativePomonoid : CommutativePomonoid 0ℓ 0ℓ 0ℓ
690+
+-0-commutativePomonoid = record
691+
{ isCommutativePomonoid = +-0-isCommutativePomonoid
692+
}
693+
694+
open CommutativePomonoid +-0-commutativePomonoid public using () renaming
695+
( magma to +-magma
696+
; pomagma to +-pomagma
697+
; semigroup to +-semigroup
698+
; posemigroup to +-posemigroup
699+
; commutativeSemigroup to +-commutativeSemigroup
700+
; monoid to +-0-monoid
701+
; pomonoid to +-0-pomonoid
702+
; commutativeMonoid to +-0-commutativeMonoid
703+
)
704+
705+
∸-magma : Magma 0ℓ 0ℓ
706+
∸-magma = magma _∸_
707+
708+
------------------------------------------------------------------------
709+
-- Other properties of _+_ and _≡_
710+
711+
m≢1+m+n : m {n} m ≢ suc (m + n)
712+
m≢1+m+n (suc m) eq = m≢1+m+n m (cong pred eq)
713+
714+
m≢1+n+m : m {n} m ≢ suc (n + m)
715+
m≢1+n+m m m≡1+n+m = m≢1+m+n m (trans m≡1+n+m (cong suc (+-comm _ m)))
716+
717+
m+1+n≢m : m {n} m + suc n ≢ m
718+
m+1+n≢m (suc m) = (m+1+n≢m m) ∘ suc-injective
719+
720+
m+1+n≢n : m {n} m + suc n ≢ n
721+
m+1+n≢n m {n} rewrite +-suc m n = ≢-sym (m≢1+n+m n)
722+
723+
m+1+n≢0 : m {n} m + suc n ≢ 0
724+
m+1+n≢0 m {n} rewrite +-suc m n = λ()
725+
726+
m+n≡0⇒m≡0 : m {n} m + n ≡ 0 m ≡ 0
727+
m+n≡0⇒m≡0 zero eq = refl
728+
729+
m+n≡0⇒n≡0 : m {n} m + n ≡ 0 n ≡ 0
730+
m+n≡0⇒n≡0 m {n} m+n≡0 = m+n≡0⇒m≡0 n (trans (+-comm n m) (m+n≡0))
731+
732+
735733
------------------------------------------------------------------------
736734
-- Properties of _*_
737735
------------------------------------------------------------------------
@@ -804,48 +802,101 @@ m+n≮m m n = subst (_≮ m) (+-comm n m) (m+n≮n n m)
804802
suc m * (n * o) ∎
805803

806804
------------------------------------------------------------------------
807-
-- Structures
805+
-- Other properties of _*_ and _≤_/_<_
808806

809-
*-isMagma : IsMagma _*_
810-
*-isMagma = record
811-
{ isEquivalence = isEquivalence
812-
; ∙-cong = cong₂ _*_
813-
}
807+
*-cancelʳ-≤ : m n o .{{_ : NonZero o}} m * o ≤ n * o m ≤ n
808+
*-cancelʳ-≤ zero _ (suc o) _ = z≤n
809+
*-cancelʳ-≤ (suc m) (suc n) (suc o) le =
810+
s≤s (*-cancelʳ-≤ m n (suc o) (+-cancelˡ-≤ (suc o) le))
814811

815-
*-isSemigroup : IsSemigroup _*_
816-
*-isSemigroup = record
817-
{ isMagma = *-isMagma
818-
; assoc = *-assoc
819-
}
812+
*-cancelˡ-≤ : {m n} o .{{_ : NonZero o}} o * m ≤ o * n m ≤ n
813+
*-cancelˡ-≤ {m} {n} o rewrite *-comm o m | *-comm o n = *-cancelʳ-≤ m n o
820814

821-
*-isCommutativeSemigroup : IsCommutativeSemigroup _*_
822-
*-isCommutativeSemigroup = record
823-
{ isSemigroup = *-isSemigroup
824-
; comm = *-comm
825-
}
815+
*-mono-≤ : _*_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_
816+
*-mono-≤ z≤n _ = z≤n
817+
*-mono-≤ (s≤s m≤n) u≤v = +-mono-≤ u≤v (*-mono-≤ m≤n u≤v)
826818

827-
*-1-isMonoid : IsMonoid _*_ 1
828-
*-1-isMonoid = record
829-
{ isSemigroup = *-isSemigroup
830-
; identity = *-identity
831-
}
819+
*-monoˡ-≤ : n (_* n) Preserves _≤_ ⟶ _≤_
820+
*-monoˡ-≤ n m≤o = *-mono-≤ m≤o (≤-refl {n})
832821

833-
*-1-isCommutativeMonoid : IsCommutativeMonoid _*_ 1
834-
*-1-isCommutativeMonoid = record
835-
{ isMonoid = *-1-isMonoid
836-
; comm = *-comm
822+
*-monoʳ-≤ : n (n *_) Preserves _≤_ ⟶ _≤_
823+
*-monoʳ-≤ n m≤o = *-mono-≤ (≤-refl {n}) m≤o
824+
825+
*-mono-< : _*_ Preserves₂ _<_ ⟶ _<_ ⟶ _<_
826+
*-mono-< z<s u<v@(s≤s _) = 0<1+n
827+
*-mono-< (s<s m<n@(s≤s _)) u<v@(s≤s _) = +-mono-< u<v (*-mono-< m<n u<v)
828+
829+
*-monoˡ-< : n .{{_ : NonZero n}} (_* n) Preserves _<_ ⟶ _<_
830+
*-monoˡ-< (suc n) z<s = 0<1+n
831+
*-monoˡ-< (suc n) (s<s m<o@(s≤s _)) =
832+
+-mono-≤-< (≤-refl {suc n}) (*-monoˡ-< (suc n) m<o)
833+
834+
*-monoʳ-< : n .{{_ : NonZero n}} (n *_) Preserves _<_ ⟶ _<_
835+
*-monoʳ-< (suc zero) m<o@(s≤s _) = +-mono-≤ m<o z≤n
836+
*-monoʳ-< (suc (suc n)) m<o@(s≤s _) =
837+
+-mono-≤ m<o (<⇒≤ (*-monoʳ-< (suc n) m<o))
838+
839+
m≤m*n : m n .{{_ : NonZero n}} m ≤ m * n
840+
m≤m*n m n@(suc _) = begin
841+
m ≡⟨ sym (*-identityʳ m) ⟩
842+
m * 1 ≤⟨ *-monoʳ-≤ m 0<1+n ⟩
843+
m * n ∎
844+
845+
m≤n*m : m n .{{_ : NonZero n}} m ≤ n * m
846+
m≤n*m m n@(suc _) = begin
847+
m ≤⟨ m≤m*n m n ⟩
848+
m * n ≡⟨ *-comm m n ⟩
849+
n * m ∎
850+
851+
m<m*n : m n .{{_ : NonZero m}} 1 < n m < m * n
852+
m<m*n m@(suc m-1) n@(suc (suc n-2)) (s≤s (s≤s _)) = begin-strict
853+
m <⟨ s≤s (s≤s (m≤n+m m-1 n-2)) ⟩
854+
n + m-1 ≤⟨ +-monoʳ-≤ n (m≤m*n m-1 n) ⟩
855+
n + m-1 * n ≡⟨⟩
856+
m * n ∎
857+
858+
*-cancelʳ-< : RightCancellative _<_ _*_
859+
*-cancelʳ-< {zero} zero (suc o) _ = 0<1+n
860+
*-cancelʳ-< {suc m} zero (suc o) _ = 0<1+n
861+
*-cancelʳ-< {m} (suc n) (suc o) nm<om =
862+
s≤s (*-cancelʳ-< n o (+-cancelˡ-< m nm<om))
863+
864+
*-cancelˡ-< : LeftCancellative _<_ _*_
865+
*-cancelˡ-< x {y} {z} rewrite *-comm x y | *-comm x z = *-cancelʳ-< y z
866+
867+
*-cancel-< : Cancellative _<_ _*_
868+
*-cancel-< = *-cancelˡ-< , *-cancelʳ-<
869+
870+
------------------------------------------------------------------------
871+
-- Structures
872+
873+
+-*-isPosemiring : IsPosemiring _+_ _*_ 0 1
874+
+-*-isPosemiring = record
875+
{ +-isCommutativePomonoid = +-0-isCommutativePomonoid
876+
; *-mono = *-mono-≤
877+
; *-assoc = *-assoc
878+
; *-identity = *-identity
879+
; distrib = *-distrib-+
880+
; zero = *-zero
837881
}
838882

839-
+-*-isSemiring : IsSemiring _+_ _*_ 0 1
840-
+-*-isSemiring = record
841-
{ isSemiringWithoutAnnihilatingZero = record
842-
{ +-isCommutativeMonoid = +-0-isCommutativeMonoid
843-
; *-cong = cong₂ _*_
844-
; *-assoc = *-assoc
845-
; *-identity = *-identity
846-
; distrib = *-distrib-+
847-
}
848-
; zero = *-zero
883+
open IsPosemiring +-*-isPosemiring public
884+
using
885+
( *-isMagma
886+
; *-isSemigroup
887+
; *-isPomagma
888+
; *-isPosemigroup
889+
)
890+
renaming
891+
( *-isMonoid to *-1-isMonoid
892+
; *-isPomonoid to *-1-isPomonoid
893+
; isSemiring to +-*-isSemiring
894+
)
895+
896+
*-1-isCommutativePomonoid : IsCommutativePomonoid _*_ 1
897+
*-1-isCommutativePomonoid = record
898+
{ isPomonoid = *-1-isPomonoid
899+
; comm = *-comm
849900
}
850901

851902
+-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0 1
@@ -855,7 +906,7 @@ m+n≮m m n = subst (_≮ m) (+-comm n m) (m+n≮n n m)
855906
}
856907

857908
------------------------------------------------------------------------
858-
-- Bundles
909+
-- Raw bundles
859910

860911
*-rawMagma : RawMagma 0ℓ 0ℓ
861912
*-rawMagma = record
@@ -870,35 +921,40 @@ m+n≮m m n = subst (_≮ m) (+-comm n m) (m+n≮n n m)
870921
; ε = 1
871922
}
872923

873-
*-magma : Magma 0ℓ 0ℓ
874-
*-magma = record
875-
{ isMagma = *-isMagma
876-
}
877-
878-
*-semigroup : Semigroup 0ℓ 0ℓ
879-
*-semigroup = record
880-
{ isSemigroup = *-isSemigroup
881-
}
924+
------------------------------------------------------------------------
925+
-- Bundles
882926

883-
*-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ
884-
*-commutativeSemigroup = record
885-
{ isCommutativeSemigroup = *-isCommutativeSemigroup
927+
+-*-posemiring : Posemiring 0ℓ 0ℓ 0ℓ
928+
+-*-posemiring = record
929+
{ isPosemiring = +-*-isPosemiring
886930
}
887931

888-
*-1-monoid : Monoid 0ℓ 0ℓ
889-
*-1-monoid = record
890-
{ isMonoid = *-1-isMonoid
891-
}
932+
open Posemiring +-*-posemiring public
933+
using
934+
( *-magma
935+
; *-pomagma
936+
; *-semigroup
937+
; *-posemigroup
938+
; *-isPomagma
939+
; *-isPosemigroup
940+
)
941+
renaming
942+
( *-monoid to *-1-monoid
943+
; *-pomonoid to *-1-pomonoid
944+
; semiring to +-*-semiring
945+
)
892946

893-
*-1-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ
894-
*-1-commutativeMonoid = record
895-
{ isCommutativeMonoid = *-1-isCommutativeMonoid
947+
*-1-commutativePomonoid : CommutativePomonoid 0ℓ 0ℓ 0ℓ
948+
*-1-commutativePomonoid = record
949+
{ isCommutativePomonoid = *-1-isCommutativePomonoid
896950
}
897951

898-
+-*-semiring : Semiring 0ℓ 0ℓ
899-
+-*-semiring = record
900-
{ isSemiring = +-*-isSemiring
901-
}
952+
open CommutativePomonoid *-1-commutativePomonoid public using () renaming
953+
( isCommutativeSemigroup to *-isCommutativeSemigroup
954+
; commutativeSemigroup to *-commutativeSemigroup
955+
; isCommutativeMonoid to *-1-isCommutativeMonoid
956+
; commutativeMonoid to *-1-commutativeMonoid
957+
)
902958

903959
+-*-commutativeSemiring : CommutativeSemiring 0ℓ 0ℓ
904960
+-*-commutativeSemiring = record
@@ -943,72 +999,6 @@ m*n≡1⇒n≡1 m n eq = m*n≡1⇒m≡1 n m (trans (*-comm n m) eq)
943999
(m * o) * (n * p) ∎
9441000
where open CommSemigroupProperties *-commutativeSemigroup
9451001

946-
------------------------------------------------------------------------
947-
-- Other properties of _*_ and _≤_/_<_
948-
949-
*-cancelʳ-≤ : m n o .{{_ : NonZero o}} m * o ≤ n * o m ≤ n
950-
*-cancelʳ-≤ zero _ (suc o) _ = z≤n
951-
*-cancelʳ-≤ (suc m) (suc n) (suc o) le =
952-
s≤s (*-cancelʳ-≤ m n (suc o) (+-cancelˡ-≤ (suc o) le))
953-
954-
*-cancelˡ-≤ : {m n} o .{{_ : NonZero o}} o * m ≤ o * n m ≤ n
955-
*-cancelˡ-≤ {m} {n} o rewrite *-comm o m | *-comm o n = *-cancelʳ-≤ m n o
956-
957-
*-mono-≤ : _*_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_
958-
*-mono-≤ z≤n _ = z≤n
959-
*-mono-≤ (s≤s m≤n) u≤v = +-mono-≤ u≤v (*-mono-≤ m≤n u≤v)
960-
961-
*-monoˡ-≤ : n (_* n) Preserves _≤_ ⟶ _≤_
962-
*-monoˡ-≤ n m≤o = *-mono-≤ m≤o (≤-refl {n})
963-
964-
*-monoʳ-≤ : n (n *_) Preserves _≤_ ⟶ _≤_
965-
*-monoʳ-≤ n m≤o = *-mono-≤ (≤-refl {n}) m≤o
966-
967-
*-mono-< : _*_ Preserves₂ _<_ ⟶ _<_ ⟶ _<_
968-
*-mono-< z<s u<v@(s≤s _) = 0<1+n
969-
*-mono-< (s<s m<n@(s≤s _)) u<v@(s≤s _) = +-mono-< u<v (*-mono-< m<n u<v)
970-
971-
*-monoˡ-< : n .{{_ : NonZero n}} (_* n) Preserves _<_ ⟶ _<_
972-
*-monoˡ-< (suc n) z<s = 0<1+n
973-
*-monoˡ-< (suc n) (s<s m<o@(s≤s _)) =
974-
+-mono-≤-< (≤-refl {suc n}) (*-monoˡ-< (suc n) m<o)
975-
976-
*-monoʳ-< : n .{{_ : NonZero n}} (n *_) Preserves _<_ ⟶ _<_
977-
*-monoʳ-< (suc zero) m<o@(s≤s _) = +-mono-≤ m<o z≤n
978-
*-monoʳ-< (suc (suc n)) m<o@(s≤s _) =
979-
+-mono-≤ m<o (<⇒≤ (*-monoʳ-< (suc n) m<o))
980-
981-
m≤m*n : m n .{{_ : NonZero n}} m ≤ m * n
982-
m≤m*n m n@(suc _) = begin
983-
m ≡⟨ sym (*-identityʳ m) ⟩
984-
m * 1 ≤⟨ *-monoʳ-≤ m 0<1+n ⟩
985-
m * n ∎
986-
987-
m≤n*m : m n .{{_ : NonZero n}} m ≤ n * m
988-
m≤n*m m n@(suc _) = begin
989-
m ≤⟨ m≤m*n m n ⟩
990-
m * n ≡⟨ *-comm m n ⟩
991-
n * m ∎
992-
993-
m<m*n : m n .{{_ : NonZero m}} 1 < n m < m * n
994-
m<m*n m@(suc m-1) n@(suc (suc n-2)) (s≤s (s≤s _)) = begin-strict
995-
m <⟨ s≤s (s≤s (m≤n+m m-1 n-2)) ⟩
996-
n + m-1 ≤⟨ +-monoʳ-≤ n (m≤m*n m-1 n) ⟩
997-
n + m-1 * n ≡⟨⟩
998-
m * n ∎
999-
1000-
*-cancelʳ-< : RightCancellative _<_ _*_
1001-
*-cancelʳ-< {zero} zero (suc o) _ = 0<1+n
1002-
*-cancelʳ-< {suc m} zero (suc o) _ = 0<1+n
1003-
*-cancelʳ-< {m} (suc n) (suc o) nm<om =
1004-
s≤s (*-cancelʳ-< n o (+-cancelˡ-< m nm<om))
1005-
1006-
*-cancelˡ-< : LeftCancellative _<_ _*_
1007-
*-cancelˡ-< x {y} {z} rewrite *-comm x y | *-comm x z = *-cancelʳ-< y z
1008-
1009-
*-cancel-< : Cancellative _<_ _*_
1010-
*-cancel-< = *-cancelˡ-< , *-cancelʳ-<
1011-
10121002
------------------------------------------------------------------------
10131003
-- Properties of _^_
10141004
------------------------------------------------------------------------

0 commit comments

Comments
 (0)
Please sign in to comment.