module FL where open import Level hiding ( suc ; zero ) open import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ ; _≟_) open import Data.Fin.Properties hiding ( <-trans ; ≤-trans ; ≤-irrelevant ; _≟_ ) renaming ( <-cmp to <-fcmp ) open import Data.Fin.Permutation open import Data.Nat -- using (ℕ; suc; zero; s≤s ; z≤n ) open import Relation.Binary.PropositionalEquality open import Data.List using (List; []; _∷_ ; length ; _++_ ; head ; tail ) renaming (reverse to rev ) open import Data.Product open import Relation.Nullary open import Data.Empty open import Relation.Binary.Core open import Relation.Binary.Definitions open import logic open import nat infixr 100 _::_ data FL : (n : ℕ )→ Set where f0 : FL 0 _::_ : { n : ℕ } → Fin (suc n ) → FL n → FL (suc n) data _f<_ : {n : ℕ } (x : FL n ) (y : FL n) → Set where f : {n : ℕ } {x : FL n } {y : FL n} → x f< y → y f< x → ⊥ f-<> (f x x₁ f-<> (f (f (f lt lt2 f-≡< : {n : ℕ } {x : FL n } {y : FL n} → x ≡ y → y f< x → ⊥ f-≡< refl (f lt (f ¬a ¬b c = tri> (λ lt → f-<> lt (f lt (f ¬a₁ ¬b c = tri> (λ lt → f-<> lt (f ¬a ¬b c = no ( ¬a ) _f≤_ : {n : ℕ } (x : FL n ) (y : FL n) → Set _f≤_ x y = (x ≡ y ) ∨ (x f< y ) FL0 : {n : ℕ } → FL n FL0 {zero} = f0 FL0 {suc n} = zero :: FL0 fmax : { n : ℕ } → FL n fmax {zero} = f0 fmax {suc n} = fromℕ< a (fmax1 x) lt where fmax1 : {n : ℕ } → (x : Fin (suc n)) → toℕ x ≤ toℕ (fromℕ< {n} a ¬a ¬b c = ⊥-elim (fmax< c) FL0≤ : {n : ℕ } → FL0 {n} f≤ fmax FL0≤ {zero} = case1 refl FL0≤ {suc zero} = case1 refl FL0≤ {suc n} with <-fcmp zero (fromℕ< {n} a ¬a ¬b c = inj₂ (case2 (f ¬a₁ ¬b c = inj₂ (case2 (subst (λ k → (y :: yt ) f< (k :: xt) ) (sym b) (f