------------------------------------------------------------------------ -- The Agda standard library -- -- Core lemmas needed to make list argmin/max functions work ------------------------------------------------------------------------ {-# OPTIONS --cubical-compatible --safe #-} open import Relation.Binary.Bundles using (TotalOrder; Setoid) module Data.List.Extrema.Core {b ℓ₁ ℓ₂} (totalOrder : TotalOrder b ℓ₁ ℓ₂) where open import Algebra.Construct.LiftedChoice using (Lift; sel-≡; preservesᵒ; preservesᵇ ; forcesᵇ) open import Algebra.Core using (Op₂) open import Algebra.Definitions using (Selective) import Algebra.Construct.NaturalChoice.Min as Min using (_⊓_; x⊓y≈y⇒y≤x; x⊓y≈x⇒x≤y; ⊓-sel; ⊓-isSelectiveMagma) import Algebra.Construct.NaturalChoice.Max as Max using (_⊔_; x⊔y≈y⇒x≤y; x⊔y≈x⇒y≤x; ⊔-sel; ⊔-isSelectiveMagma) open import Data.Product.Base using (_×_; _,_) open import Data.Sum.Base using (_⊎_; inj₁; inj₂) open import Level using (Level) open import Relation.Binary.PropositionalEquality.Core using (_≡_) open import Relation.Binary.Definitions using (Trans) open TotalOrder totalOrder renaming (Carrier to B) open import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ using (_<_; <-≤-trans; ≤-<-trans) ------------------------------------------------------------------------ -- Setup -- open NonStrictToStrict totalOrder using (_<_; ≤-<-trans; <-≤-trans) open Max totalOrder open Min totalOrder private variable a : Level A : Set a <-transʳ : Trans _≤_ _<_ _<_ <-transʳ = ≤-<-trans trans antisym ≤-respˡ-≈ <-transˡ : Trans _<_ _≤_ _<_ <-transˡ = <-≤-trans Eq.sym trans antisym ≤-respʳ-≈ module _ (f : A → B) where lemma₁ : ∀ {x y v} → f x ≤ v → f x ⊓ f y ≈ f y → f y ≤ v lemma₁ fx≤v fx⊓fy≈fy = trans (x⊓y≈y⇒y≤x fx⊓fy≈fy) fx≤v lemma₂ : ∀ {x y v} → f y ≤ v → f x ⊓ f y ≈ f x → f x ≤ v lemma₂ fy≤v fx⊓fy≈fx = trans (x⊓y≈x⇒x≤y fx⊓fy≈fx) fy≤v lemma₃ : ∀ {x y v} → f x < v → f x ⊓ f y ≈ f y → f y < v lemma₃ fx