@@ -10,26 +10,26 @@ module Data.List.Membership.Propositional.Properties where
1010
1111open import Algebra.Core using (Op₂)
1212open import Algebra.Definitions using (Selective)
13- open import Effect.Monad using (RawMonad)
14- open import Data.Bool.Base using (Bool; false; true; T)
1513open import Data.Fin.Base using (Fin)
1614open import Data.List.Base as List
17- open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
18- open import Data.List.Relation.Unary.Any.Properties
19- using (map↔; concat↔; >>=↔; ⊛↔; Any-cong; ⊗↔′; ¬Any[])
15+ open import Data.List.Effectful using (monad)
2016open import Data.List.Membership.Propositional
2117 using (_∈_; _∉_; mapWith∈; _≢∈_)
2218import Data.List.Membership.Setoid.Properties as Membership
2319open import Data.List.Relation.Binary.Equality.Propositional
2420 using (_≋_; ≡⇒≋; ≋⇒≡)
25- open import Data.List.Effectful using (monad)
26- open import Data.Nat.Base using (ℕ; zero; suc; pred; s≤s; _≤_; _<_; _≤ᵇ_)
27- open import Data.Nat.Properties using (_≤?_; m≤n⇒m≤1+n; ≤ᵇ-reflects-≤; <⇒≢; ≰⇒>)
21+ open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
22+ open import Data.List.Relation.Unary.Any.Properties
23+ using (map↔; concat↔; >>=↔; ⊛↔; Any-cong; ⊗↔′; ¬Any[])
24+ open import Data.Nat.Base using (ℕ; suc; s≤s; _≤_; _<_; _≰_)
25+ open import Data.Nat.Properties
26+ using (suc-injective; m≤n⇒m≤1+n; _≤?_; <⇒≢; ≰⇒>)
2827open import Data.Product.Base using (∃; ∃₂; _×_; _,_)
2928open import Data.Product.Properties using (×-≡,≡↔≡)
3029open import Data.Product.Function.NonDependent.Propositional using (_×-cong_)
3130import Data.Product.Function.Dependent.Propositional as Σ
3231open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂)
32+ open import Effect.Monad using (RawMonad)
3333open import Function.Base using (_∘_; _∘′_; _$_; id; flip; _⟨_⟩_)
3434open import Function.Definitions using (Injective)
3535import Function.Related.Propositional as Related
@@ -40,15 +40,14 @@ open import Level using (Level)
4040open import Relation.Binary.Core using (Rel)
4141open import Relation.Binary.Definitions as Binary hiding (Decidable)
4242open import Relation.Binary.PropositionalEquality.Core as ≡
43- using (_≡_; _≢_; refl; sym; trans; cong; cong₂; subst ; _≗_)
43+ using (_≡_; _≢_; refl; sym; trans; cong; cong₂; resp ; _≗_)
4444open import Relation.Binary.PropositionalEquality.Properties as ≡ using (setoid)
4545import Relation.Binary.Properties.DecTotalOrder as DTOProperties
46- open import Relation.Unary using (_⟨×⟩_; Decidable)
47- import Relation.Nullary.Reflects as Reflects
46+ open import Relation.Nullary.Decidable.Core
47+ using (Dec; yes; no; ¬¬-excluded-middle)
48+ open import Relation.Nullary.Negation.Core using (¬_; contradiction)
4849open import Relation.Nullary.Reflects using (invert)
49- open import Relation.Nullary using (¬_; Dec; does; yes; no; _because_)
50- open import Relation.Nullary.Negation using (contradiction)
51- open import Relation.Nullary.Decidable using (¬¬-excluded-middle)
50+ open import Relation.Unary using (_⟨×⟩_; Decidable)
5251
5352private
5453 open module ListMonad {ℓ} = RawMonad (monad {ℓ = ℓ})
@@ -128,8 +127,9 @@ module _ {v : A} where
128127 ∈-insert xs = Membership.∈-insert (≡.setoid A) xs refl
129128
130129 ∈-∃++ : ∀ {xs} → v ∈ xs → ∃₂ λ ys zs → xs ≡ ys ++ [ v ] ++ zs
131- ∈-∃++ v∈xs with Membership.∈-∃++ (≡.setoid A) v∈xs
132- ... | ys , zs , _ , refl , eq = ys , zs , ≋⇒≡ eq
130+ ∈-∃++ v∈xs
131+ with ys , zs , _ , refl , eq ← Membership.∈-∃++ (≡.setoid A) v∈xs
132+ = ys , zs , ≋⇒≡ eq
133133
134134------------------------------------------------------------------------
135135-- concat
@@ -147,8 +147,9 @@ module _ {v : A} where
147147 Membership.∈-concat⁺′ (≡.setoid A) v∈vs (Any.map ≡⇒≋ vs∈xss)
148148
149149 ∈-concat⁻′ : ∀ xss → v ∈ concat xss → ∃ λ xs → v ∈ xs × xs ∈ xss
150- ∈-concat⁻′ xss v∈c with Membership.∈-concat⁻′ (≡.setoid A) xss v∈c
151- ... | xs , v∈xs , xs∈xss = xs , v∈xs , Any.map ≋⇒≡ xs∈xss
150+ ∈-concat⁻′ xss v∈c =
151+ let xs , v∈xs , xs∈xss = Membership.∈-concat⁻′ (≡.setoid A) xss v∈c
152+ in xs , v∈xs , Any.map ≋⇒≡ xs∈xss
152153
153154 concat-∈↔ : ∀ {xss : List (List A)} →
154155 (∃ λ xs → v ∈ xs × xs ∈ xss) ↔ v ∈ concat xss
@@ -183,8 +184,9 @@ module _ (f : A → B → C) where
183184
184185∈-cartesianProduct⁻ : ∀ xs ys {xy@(x , y) : A × B} →
185186 xy ∈ cartesianProduct xs ys → x ∈ xs × y ∈ ys
186- ∈-cartesianProduct⁻ xs ys xy∈p[xs,ys] with ∈-cartesianProductWith⁻ _,_ xs ys xy∈p[xs,ys]
187- ... | (x , y , x∈xs , y∈ys , refl) = x∈xs , y∈ys
187+ ∈-cartesianProduct⁻ xs ys xy∈p[xs,ys]
188+ with _ , _ , x∈xs , y∈ys , refl ← ∈-cartesianProductWith⁻ _,_ xs ys xy∈p[xs,ys]
189+ = x∈xs , y∈ys
188190
189191------------------------------------------------------------------------
190192-- applyUpTo
@@ -205,8 +207,7 @@ module _ (f : ℕ → A) where
205207∈-upTo⁺ = ∈-applyUpTo⁺ id
206208
207209∈-upTo⁻ : ∀ {n i} → i ∈ upTo n → i < n
208- ∈-upTo⁻ p with ∈-applyUpTo⁻ id p
209- ... | _ , i<n , refl = i<n
210+ ∈-upTo⁻ p with _ , i<n , refl ← ∈-applyUpTo⁻ id p = i<n
210211
211212------------------------------------------------------------------------
212213-- applyDownFrom
@@ -227,8 +228,7 @@ module _ (f : ℕ → A) where
227228∈-downFrom⁺ i<n = ∈-applyDownFrom⁺ id i<n
228229
229230∈-downFrom⁻ : ∀ {n i} → i ∈ downFrom n → i < n
230- ∈-downFrom⁻ p with ∈-applyDownFrom⁻ id p
231- ... | _ , i<n , refl = i<n
231+ ∈-downFrom⁻ p with _ , i<n , refl ← ∈-applyDownFrom⁻ id p = i<n
232232
233233------------------------------------------------------------------------
234234-- tabulate
@@ -247,10 +247,10 @@ module _ {n} {f : Fin n → A} where
247247module _ {p} {P : A → Set p} (P? : Decidable P) where
248248
249249 ∈-filter⁺ : ∀ {x xs} → x ∈ xs → P x → x ∈ filter P? xs
250- ∈-filter⁺ = Membership.∈-filter⁺ (≡.setoid A) P? (subst P)
250+ ∈-filter⁺ = Membership.∈-filter⁺ (≡.setoid A) P? (≡.resp P)
251251
252252 ∈-filter⁻ : ∀ {v xs} → v ∈ filter P? xs → v ∈ xs × P v
253- ∈-filter⁻ = Membership.∈-filter⁻ (≡.setoid A) P? (subst P)
253+ ∈-filter⁻ = Membership.∈-filter⁻ (≡.setoid A) P? (≡.resp P)
254254
255255------------------------------------------------------------------------
256256-- derun and deduplicate
@@ -310,7 +310,7 @@ module _ (_≈?_ : DecidableEquality A) where
310310------------------------------------------------------------------------
311311-- length
312312
313- ∈-length : ∀ {x : A} {xs} → x ∈ xs → 1 ≤ length xs
313+ ∈-length : ∀ {x : A} {xs} → x ∈ xs → 0 < length xs
314314∈-length = Membership.∈-length (≡.setoid _)
315315
316316------------------------------------------------------------------------
@@ -365,28 +365,27 @@ finite inj (x ∷ xs) fᵢ∈x∷xs = ¬¬-excluded-middle helper
365365 helper (yes (i , fᵢ≡x)) = finite f′-inj xs f′ⱼ∈xs
366366 where
367367 f′ : ℕ → _
368- f′ j with does ( i ≤? j)
369- ... | true = f (suc j)
370- ... | false = f j
368+ f′ j with i ≤? j
369+ ... | yes _ = f (suc j)
370+ ... | no _ = f j
371371
372372 ∈-if-not-i : ∀ {j} → i ≢ j → f j ∈ xs
373373 ∈-if-not-i i≢j = not-x (i≢j ∘ f-inj ∘ trans fᵢ≡x ∘ sym)
374374
375- lemma : ∀ {k j} → i ≤ j → ¬ (i ≤ k) → suc j ≢ k
375+ lemma : ∀ {k j} → i ≤ j → i ≰ k → suc j ≢ k
376376 lemma i≤j i≰1+j refl = i≰1+j (m≤n⇒m≤1+n i≤j)
377377
378378 f′ⱼ∈xs : ∀ j → f′ j ∈ xs
379- f′ⱼ∈xs j with i ≤ᵇ j | Reflects.invert (≤ᵇ-reflects-≤ i j)
380- ... | true | p = ∈-if-not-i (<⇒≢ (s≤s p ))
381- ... | false | p = ∈-if-not-i (<⇒≢ (≰⇒> p ) ∘ sym)
379+ f′ⱼ∈xs j with i ≤? j
380+ ... | yes i≤j = ∈-if-not-i (<⇒≢ (s≤s i≤j ))
381+ ... | no i≰j = ∈-if-not-i (<⇒≢ (≰⇒> i≰j ) ∘ sym)
382382
383383 f′-injective′ : Injective _≡_ _≡_ f′
384- f′-injective′ {j} {k} eq with i ≤ᵇ j | Reflects.invert (≤ᵇ-reflects-≤ i j)
385- | i ≤ᵇ k | Reflects.invert (≤ᵇ-reflects-≤ i k)
386- ... | true | p | true | q = ≡.cong pred (f-inj eq)
387- ... | true | p | false | q = contradiction (f-inj eq) (lemma p q)
388- ... | false | p | true | q = contradiction (f-inj eq) (lemma q p ∘ sym)
389- ... | false | p | false | q = f-inj eq
384+ f′-injective′ {j} {k} eq with i ≤? j | i ≤? k
385+ ... | yes i≤j | yes i≤k = suc-injective (f-inj eq)
386+ ... | yes i≤j | no i≰k = contradiction (f-inj eq) (lemma i≤j i≰k)
387+ ... | no i≰j | yes i≤k = contradiction (f-inj eq) (lemma i≤k i≰j ∘ sym)
388+ ... | no i≰j | no i≰k = f-inj eq
390389
391390 f′-inj : ℕ ↣ _
392391 f′-inj = record
0 commit comments