{-# OPTIONS --without-K --safe #-} module FinMerge.Properties where open import Data.Empty using (⊥-elim) open import Data.Fin using (Fin; fromℕ<; toℕ; #_; lower₁; _↑ˡ_; cast) open import Data.Fin.Properties using (¬Fin0) open import Data.Nat using (ℕ; _+_; _≤_; _<_; z) open import Util using (_<_<_; _<_≤_; toℕ<; Ordering; less; equal; greater; compare) open import FinMerge using (merge; unmerge; pluck; glue-once; glue-unglue-once; glue-iter; unpluck) private variable m n : ℕ s≡s⁻¹ : {j k : ℕ} → ℕ.suc j ≡ ℕ.suc k → j ≡ k s≡s⁻¹ {ℕ.zero} {ℕ.zero} _ = refl s≡s⁻¹ {ℕ.suc j} {ℕ.suc .j} refl = refl not-n : {x : Fin (ℕ.suc n)} → toℕ x < m ≤ n → n ≢ toℕ x not-n (x : {i j k : Fin (ℕ.suc n)} → (i {n} {i} {j} {Fin.suc k} i j≤n j : {j : Fin (ℕ.suc m)} {k : Fin m} (j≤m : toℕ j ≤ m) (j {ℕ.suc m} {Fin.zero} {_} z≤n (s≤s j {ℕ.suc m} {Fin.suc j} {Fin.suc k} (s≤s j≤m) (s≤s j j≤m j i : {i j : Fin (ℕ.suc n)} → {k : Fin n} → (i {n} {i} {j} {k} i j≤n j : {j : Fin (ℕ.suc m)} → {k : Fin m} → (j≤m : toℕ j ≤ m) → (j {ℕ.suc m} {Fin.zero} {Fin.suc k} z≤n (s≤s j {ℕ.suc m} {Fin.suc j} {Fin.suc k} (s≤s j≤m) (s≤s j j≤m j _ _ j i