Parameterize FiniteMap by its keys right away

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2025-01-04 22:19:02 -08:00
parent cf824dc744
commit ffe9d193d9
2 changed files with 13 additions and 13 deletions

View File

@ -10,7 +10,6 @@ module Analysis.Forward.Lattices
open import Data.String using (String) renaming (_≟_ to _≟ˢ_) open import Data.String using (String) renaming (_≟_ to _≟ˢ_)
open import Data.Product using (proj₁; proj₂; _,_) open import Data.Product using (proj₁; proj₂; _,_)
open import Data.Unit using (tt)
open import Data.Sum using (inj₁; inj₂) open import Data.Sum using (inj₁; inj₂)
open import Data.List using (List; _∷_; []; foldr) open import Data.List using (List; _∷_; []; foldr)
open import Data.List.Membership.Propositional using () renaming (_∈_ to _∈ˡ_) open import Data.List.Membership.Propositional using () renaming (_∈_ to _∈ˡ_)
@ -38,7 +37,7 @@ instance
-- with keys strings. Use a bundle to avoid explicitly specifying operators. -- with keys strings. Use a bundle to avoid explicitly specifying operators.
-- It's helpful to export these via 'public' since consumers tend to -- It's helpful to export these via 'public' since consumers tend to
-- use various variable lattice operations. -- use various variable lattice operations.
module VariableValuesFiniteMap = Lattice.FiniteMap.WithKeys String L tt vars module VariableValuesFiniteMap = Lattice.FiniteMap String L vars
open VariableValuesFiniteMap open VariableValuesFiniteMap
using () using ()
renaming renaming
@ -65,13 +64,13 @@ open IsLattice isLatticeᵛ
; ⊔-idemp to ⊔ᵛ-idemp ; ⊔-idemp to ⊔ᵛ-idemp
) )
public public
open Lattice.FiniteMap.IterProdIsomorphism String L _ open Lattice.FiniteMap.IterProdIsomorphism String L vars
using () using ()
renaming renaming
( Provenance-union to Provenance-unionᵐ ( Provenance-union to Provenance-unionᵐ
) )
public public
open Lattice.FiniteMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight String L _ vars-Unique open Lattice.FiniteMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight String L vars vars-Unique
using () using ()
renaming renaming
( isFiniteHeightLattice to isFiniteHeightLatticeᵛ ( isFiniteHeightLattice to isFiniteHeightLatticeᵛ
@ -83,7 +82,7 @@ open Lattice.FiniteMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight String L
⊥ᵛ = Chain.Height.⊥ fixedHeightᵛ ⊥ᵛ = Chain.Height.⊥ fixedHeightᵛ
-- Finally, the map we care about is (state -> (variables -> value)). Bring that in. -- Finally, the map we care about is (state -> (variables -> value)). Bring that in.
module StateVariablesFiniteMap = Lattice.FiniteMap.WithKeys State VariableValues tt states module StateVariablesFiniteMap = Lattice.FiniteMap State VariableValues states
open StateVariablesFiniteMap open StateVariablesFiniteMap
using (_[_]; []-∈; m₁≼m₂⇒m₁[ks]≼m₂[ks]; m₁≈m₂⇒k∈m₁⇒k∈km₂⇒v₁≈v₂) using (_[_]; []-∈; m₁≼m₂⇒m₁[ks]≼m₂[ks]; m₁≈m₂⇒k∈m₁⇒k∈km₂⇒v₁≈v₂)
renaming renaming
@ -98,7 +97,7 @@ open StateVariablesFiniteMap
; m₁≼m₂⇒m₁[k]≼m₂[k] to m₁≼m₂⇒m₁[k]ᵐ≼m₂[k]ᵐ ; m₁≼m₂⇒m₁[k]≼m₂[k] to m₁≼m₂⇒m₁[k]ᵐ≼m₂[k]ᵐ
) )
public public
open Lattice.FiniteMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight State VariableValues _ states-Unique open Lattice.FiniteMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight State VariableValues states states-Unique
using () using ()
renaming renaming
( isFiniteHeightLattice to isFiniteHeightLatticeᵐ ( isFiniteHeightLattice to isFiniteHeightLatticeᵐ

View File

@ -9,10 +9,10 @@ module Lattice.FiniteMap (A : Set) (B : Set)
{_≈₂_ : B B Set} {_≈₂_ : B B Set}
{_⊔₂_ : B B B} {_⊓₂_ : B B B} {_⊔₂_ : B B B} {_⊓₂_ : B B B}
{{≡-Decidable-A : IsDecidable {_} {A} _≡_}} {{≡-Decidable-A : IsDecidable {_} {A} _≡_}}
{{lB : IsLattice B _≈₂_ _⊔₂_ _⊓₂_}} (dummy : ) where {{lB : IsLattice B _≈₂_ _⊔₂_ _⊓₂_}} (ks : List A) where
open IsLattice lB using () renaming (_≼_ to _≼₂_) open IsLattice lB using () renaming (_≼_ to _≼₂_)
open import Lattice.Map A B dummy as Map open import Lattice.Map A B _ as Map
using using
( Map ( Map
; ⊔-equal-keys ; ⊔-equal-keys
@ -74,7 +74,7 @@ open import Showable using (Showable; show)
open import Isomorphism using (IsInverseˡ; IsInverseʳ) open import Isomorphism using (IsInverseˡ; IsInverseʳ)
open import Chain using (Height) open import Chain using (Height)
module WithKeys (ks : List A) where private module WithKeys (ks : List A) where
FiniteMap : Set FiniteMap : Set
FiniteMap = Σ Map (λ m Map.keys m ks) FiniteMap = Σ Map (λ m Map.keys m ks)
@ -131,7 +131,7 @@ module WithKeys (ks : List A) where
[]-∈ : {k : A} {v : B} {ks' : List A} (fm : FiniteMap) []-∈ : {k : A} {v : B} {ks' : List A} (fm : FiniteMap)
k ∈ˡ ks' (k , v) fm v ∈ˡ (fm [ ks' ]) k ∈ˡ ks' (k , v) fm v ∈ˡ (fm [ ks' ])
[]-∈ {k} {v} {ks'} (m , _) k∈ks' k,v∈fm = []ᵐ-∈ m k,v∈fm k∈ks' []-∈ {k} {v} {ks'} (m , _) k∈ks' k,v∈fm = []ᵐ-∈ m k,v∈fm k∈ks'
≈-equiv : IsEquivalence FiniteMap _≈_ ≈-equiv : IsEquivalence FiniteMap _≈_
≈-equiv = record ≈-equiv = record
@ -253,9 +253,8 @@ module WithKeys (ks : List A) where
... | yes k∈km₁ | no k∉km₂ = ⊥-elim (∈k-exclusive fm₁ fm₂ (k∈km₁ , k∉km₂)) ... | yes k∈km₁ | no k∉km₂ = ⊥-elim (∈k-exclusive fm₁ fm₂ (k∈km₁ , k∉km₂))
... | no k∉km₁ | yes k∈km₂ = ⊥-elim (∈k-exclusive fm₂ fm₁ (k∈km₂ , k∉km₁)) ... | no k∉km₁ | yes k∈km₂ = ⊥-elim (∈k-exclusive fm₂ fm₁ (k∈km₂ , k∉km₁))
open WithKeys public
module IterProdIsomorphism where module IterProdIsomorphism where
open WithKeys
open import Data.Unit using (tt) open import Data.Unit using (tt)
open import Lattice.Unit using () open import Lattice.Unit using ()
renaming renaming
@ -267,7 +266,7 @@ module IterProdIsomorphism where
; ≈-equiv to ≈ᵘ-equiv ; ≈-equiv to ≈ᵘ-equiv
; fixedHeight to fixedHeightᵘ ; fixedHeight to fixedHeightᵘ
) )
open import Lattice.IterProd B dummy open import Lattice.IterProd B _
as IP as IP
using (IterProd) using (IterProd)
open IsLattice lB using () open IsLattice lB using ()
@ -631,3 +630,5 @@ module IterProdIsomorphism where
⊥-contains-bottoms {k} {v} k,v∈⊥ ⊥-contains-bottoms {k} {v} k,v∈⊥
rewrite IP.⊥-built {length ks} {{fhB = fixedHeightᵘ}} = rewrite IP.⊥-built {length ks} {{fhB = fixedHeightᵘ}} =
to-build uks k v k,v∈⊥ to-build uks k v k,v∈⊥
open WithKeys ks public