2023-09-23 17:12:12 -07:00
|
|
|
|
open import Lattice
|
|
|
|
|
open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl; sym; trans; cong; subst)
|
|
|
|
|
open import Relation.Binary.Definitions using (Decidable)
|
|
|
|
|
open import Agda.Primitive using (Level) renaming (_⊔_ to _⊔ℓ_)
|
|
|
|
|
|
|
|
|
|
module Lattice.MapSet {a : Level} (A : Set a) (≡-dec-A : Decidable (_≡_ {a} {A})) where
|
|
|
|
|
|
2024-03-09 13:58:40 -08:00
|
|
|
|
open import Data.List using (List; map)
|
2024-03-10 16:41:21 -07:00
|
|
|
|
open import Data.Product using (_,_; proj₁)
|
2024-03-09 13:58:40 -08:00
|
|
|
|
open import Function using (_∘_)
|
|
|
|
|
|
|
|
|
|
open import Lattice.Unit using (⊤; tt) renaming (_≈_ to _≈₂_; _⊔_ to _⊔₂_; _⊓_ to _⊓₂_; isLattice to ⊤-isLattice)
|
2023-09-23 17:12:12 -07:00
|
|
|
|
import Lattice.Map
|
|
|
|
|
|
|
|
|
|
private module UnitMap = Lattice.Map A ⊤ _≈₂_ _⊔₂_ _⊓₂_ ≡-dec-A ⊤-isLattice
|
2024-03-10 16:41:21 -07:00
|
|
|
|
open UnitMap
|
|
|
|
|
using (Map; Expr; ⟦_⟧)
|
|
|
|
|
renaming
|
|
|
|
|
( Expr-Provenance to Expr-Provenanceᵐ
|
|
|
|
|
)
|
|
|
|
|
open UnitMap
|
|
|
|
|
using
|
|
|
|
|
( _⊆_; _≈_; ≈-equiv; _⊔_; _⊓_; _∪_ ; _∩_ ; `_; empty; forget
|
|
|
|
|
; isUnionSemilattice; isIntersectSemilattice; isLattice; lattice
|
|
|
|
|
; Provenance
|
|
|
|
|
; ⊔-preserves-∈k₁
|
|
|
|
|
; ⊔-preserves-∈k₂
|
|
|
|
|
)
|
|
|
|
|
renaming (_∈k_ to _∈_) public
|
|
|
|
|
open Provenance public
|
2023-09-23 17:12:12 -07:00
|
|
|
|
|
|
|
|
|
MapSet : Set a
|
|
|
|
|
MapSet = Map
|
2024-03-09 13:58:40 -08:00
|
|
|
|
|
|
|
|
|
to-List : MapSet → List A
|
|
|
|
|
to-List = map proj₁ ∘ proj₁
|
|
|
|
|
|
|
|
|
|
insert : A → MapSet → MapSet
|
|
|
|
|
insert k = UnitMap.insert k tt
|
2024-03-10 16:41:21 -07:00
|
|
|
|
|
|
|
|
|
singleton : A → MapSet
|
|
|
|
|
singleton k = UnitMap.insert k tt empty
|
|
|
|
|
|
|
|
|
|
Expr-Provenance : ∀ (k : A) (e : Expr) → k ∈ ⟦ e ⟧ → Provenance k tt e
|
|
|
|
|
Expr-Provenance k e k∈e = let (tt , (prov , _)) = Expr-Provenanceᵐ k e k∈e in prov
|