From c9ab1152c402d9bb30be8617b0c141106dc54594 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 25 Jul 2023 00:10:57 -0700 Subject: [PATCH] Minor cleanup of Map module Signed-off-by: Danila Fedorin --- Map.agda | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Map.agda b/Map.agda index 59dfc34..44493ce 100644 --- a/Map.agda +++ b/Map.agda @@ -29,9 +29,6 @@ data Unique {c} {C : Set c} : List C → Set c where → Unique xs → Unique (x ∷ xs) -Map : Set (a ⊔ b) -Map = Σ (List (A × B)) (λ l → Unique (keys l)) - Unique-append : ∀ {c} {C : Set c} {x : C} {xs : List C} → ¬ MemProp._∈_ x xs → Unique xs → Unique (xs ++ (x ∷ [])) Unique-append {c} {C} {x} {[]} _ _ = push [] empty Unique-append {c} {C} {x} {x' ∷ xs'} x∉xs (push x'≢ uxs') = push (help x'≢) (Unique-append (λ x∈xs' → x∉xs (there x∈xs')) uxs') @@ -43,24 +40,27 @@ Unique-append {c} {C} {x} {x' ∷ xs'} x∉xs (push x'≢ uxs') = push (help x' help {[]} _ = x'≢x ∷ [] help {e ∷ es} (x'≢e ∷ x'≢es) = x'≢e ∷ help x'≢es -_∈_ : (A × B) → List (A × B) → Set (a ⊔ b) -_∈_ p m = MemProp._∈_ p m +Map : Set (a ⊔ b) +Map = Σ (List (A × B)) (λ l → Unique (keys l)) -foldr : ∀ {c} {C : Set c} → (A → B → C → C) -> C -> List (A × B) -> C -foldr f b [] = b -foldr f b ((k , v) ∷ xs) = f k v (foldr f b xs) +_∈_ : (A × B) → Map → Set (a ⊔ b) +_∈_ p (kvs , _) = MemProp._∈_ p kvs absurd : ∀ {a} {A : Set a} → ⊥ → A absurd () private module ImplRelation (_≈_ : B → B → Set b) where subset : List (A × B) → List (A × B) → Set (a ⊔ b) - subset m₁ m₂ = ∀ (k : A) (v : B) → (k , v) ∈ m₁ → Σ B (λ v' → v ≈ v' × ((k , v') ∈ m₂)) + subset m₁ m₂ = ∀ (k : A) (v : B) → MemProp._∈_ (k , v) m₁ → Σ B (λ v' → v ≈ v' × (MemProp._∈_ (k , v') m₂)) private module ImplInsert (f : B → B → B) where _∈k_ : A → List (A × B) → Set a _∈k_ k m = MemProp._∈_ k (keys m) + foldr : ∀ {c} {C : Set c} → (A → B → C → C) -> C -> List (A × B) -> C + foldr f b [] = b + foldr f b ((k , v) ∷ xs) = f k v (foldr f b xs) + insert : A → B → List (A × B) → List (A × B) insert k v [] = (k , v) ∷ [] insert k v (x@(k' , v') ∷ xs) with ≡-dec-A k k'