From 9a8dc821469836bce507e276059502ee921949e7 Mon Sep 17 00:00:00 2001 From: Chloe Brown Date: Thu, 23 Sep 2021 13:46:05 +0100 Subject: Define Motzkin numbers. --- src/Data/List/Relation/Binary/Suffix.agda | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/Data/List/Relation/Binary/Suffix.agda (limited to 'src/Data/List/Relation/Binary/Suffix.agda') diff --git a/src/Data/List/Relation/Binary/Suffix.agda b/src/Data/List/Relation/Binary/Suffix.agda new file mode 100644 index 0000000..6b41a67 --- /dev/null +++ b/src/Data/List/Relation/Binary/Suffix.agda @@ -0,0 +1,73 @@ +module Data.List.Relation.Binary.Suffix where + +open import Data.Bool using (true; false; _∧_; _∨_) +open import Data.Empty using (⊥-elim) +open import Data.List using (List; []; _∷_; length) +open import Data.List.Relation.Binary.Pointwise as Pointwise using (Pointwise; []; _∷_; setoid) +open import Data.Nat using (suc; _≤_; z≤n; s≤s) +open import Data.Nat.Properties using (n<1+n; ≤-step; <⇒≱; module ≤-Reasoning) +open import Data.Sum using (inj₁; inj₂; [_,_]) +open import Level using (Level; _⊔_) +open import Relation.Binary +open import Relation.Nullary using (yes; no; ¬_) +import Relation.Nullary.Decidable as Dec +open import Relation.Nullary.Sum using (_⊎-dec_) + +private + variable + a ℓ : Level + +module _ + {A : Set a} (_≈_ : Rel A ℓ) + where + + data Suffix : Rel (List A) (a ⊔ ℓ) where + base : ∀ {xs ys} → (xs≋ys : Pointwise _≈_ xs ys) → Suffix xs ys + next : ∀ y {xs ys} → Suffix xs ys → Suffix xs (y ∷ ys) + +module _ + {A : Set a} {_≈_ : Rel A ℓ} + where + + private + _≋_ = Pointwise _≈_ + _<_ = Suffix _≈_ + + length≤ : ∀ {xs ys} → xs < ys → length xs ≤ length ys + length≤ (base []) = z≤n + length≤ (base (x∼y ∷ xs≋ys)) = s≤s (length≤ (base xs≋ys)) + length≤ (next y xs