------------------------------------------------------------------------ -- The Agda standard library -- -- Lexicographic ordering of lists ------------------------------------------------------------------------ -- The definitions of lexicographic ordering used here are suitable if -- the argument order is a strict partial order. {-# OPTIONS --cubical-compatible --safe #-} module Data.List.Relation.Binary.Lex.Strict where open import Function.Base using (_∘_; id) open import Data.Product.Base using (_,_) open import Data.Sum.Base using (inj₁; inj₂) open import Data.List.Base using (List; []; _∷_) open import Level using (_⊔_) open import Relation.Nullary using (yes; no; ¬_) open import Relation.Binary.Core using (Rel; _⇒_) open import Relation.Binary.Bundles using (StrictPartialOrder; StrictTotalOrder; Preorder; Poset; DecPoset; DecTotalOrder) open import Relation.Binary.Structures using (IsEquivalence; IsStrictPartialOrder; IsStrictTotalOrder; IsPreorder; IsPartialOrder; IsDecPartialOrder; IsTotalOrder; IsDecTotalOrder) open import Relation.Binary.Definitions using (Irreflexive; Symmetric; _Respects₂_; Total; Asymmetric; Antisymmetric; Transitive; Trichotomous; Decidable; tri≈; tri<; tri>) open import Relation.Binary.Consequences open import Data.List.Relation.Binary.Pointwise as Pointwise using (Pointwise; []; _∷_; head; tail) import Data.List.Relation.Binary.Lex as Core ------------------------------------------------------------------------ -- Re-exporting core definitions open Core public using (Lex-<; Lex-≤; base; halt; this; next; ¬≤-this; ¬≤-next) ------------------------------------------------------------------------ -- Strict lexicographic ordering. module _ {a ℓ₁ ℓ₂} {A : Set a} where -- Properties module _ {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂} where private _≋_ = Pointwise _≈_ _<_ = Lex-< _≈_ _≺_ xs≮[] : ∀ {xs} → ¬ xs < [] xs≮[] (base ()) ¬[]<[] : ¬ [] < [] ¬[]<[] = xs≮[] <-irreflexive : Irreflexive _≈_ _≺_ → Irreflexive _≋_ _<_ <-irreflexive irr (x≈y ∷ xs≋ys) (this x (λ()) (λ()) halt <-compare sym tri (x ∷ xs) (y ∷ ys) with tri x y ... | tri< x x≮y x≉y y (¬≤-this x≉y x≮y) (x≉y ∘ head) (this y xs≮ys xs≉ys ys (¬≤-next x≮y xs≮ys) (xs≉ys ∘ tail) (next (sym x≈y) ys _ _ y