------------------------------------------------------------------------ -- The Agda standard library -- -- Lexicographic ordering of same-length vectors ------------------------------------------------------------------------ {-# OPTIONS --cubical-compatible --safe #-} module Data.Vec.Relation.Binary.Lex.Core {a} {A : Set a} where open import Data.Nat.Base using (ℕ; suc) import Data.Nat.Properties as ℕ using (_≟_; ≡-irrelevant) open import Data.Product.Base using (_×_; _,_; proj₁; proj₂; uncurry) open import Data.Vec.Base using (Vec; []; _∷_) open import Data.Sum.Base using (_⊎_; inj₁; inj₂; [_,_]) open import Data.Vec.Relation.Binary.Pointwise.Inductive using (Pointwise; []; _∷_) open import Function.Base using (flip) open import Function.Bundles using (_⇔_; mk⇔) open import Level using (Level; _⊔_) open import Relation.Binary.Core using (Rel; REL) open import Relation.Binary.Definitions using (Transitive; Symmetric; Asymmetric; Antisymmetric; Irreflexive; Trans ; _Respects₂_; _Respectsˡ_; _Respectsʳ_; Decidable; Irrelevant) open import Relation.Binary.Structures using (IsPartialEquivalence) open import Relation.Binary.PropositionalEquality.Core as ≡ 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) private variable ℓ₁ ℓ₂ : Level ------------------------------------------------------------------------ -- Definition -- The lexicographic ordering itself can be either strict or non-strict, -- depending on whether type P is inhabited. data Lex {A : Set a} (P : Set) (_≈_ : Rel A ℓ₁) (_≺_ : Rel A ℓ₂) : ∀ {m n} → REL (Vec A m) (Vec A n) (a ⊔ ℓ₁ ⊔ ℓ₂) where base : (p : P) → Lex P _≈_ _≺_ [] [] this : ∀ {x y m n} {xs : Vec A m} {ys : Vec A n} (x≺y : x ≺ y) (m≡n : m ≡ n) → Lex P _≈_ _≺_ (x ∷ xs) (y ∷ ys) next : ∀ {x y m n} {xs : Vec A m} {ys : Vec A n} (x≈y : x ≈ y) (xs