diff --git a/Analysis/Sign.agda b/Analysis/Sign.agda index 4767dfd..42ed8ad 100644 --- a/Analysis/Sign.agda +++ b/Analysis/Sign.agda @@ -12,9 +12,7 @@ open import Data.Unit using (⊤) open import Language open import Lattice open import Utils using (Pairwise) -import Lattice.Bundles.FiniteValueMap - -private module FixedHeightFiniteMap = Lattice.Bundles.FiniteValueMap.FromFiniteHeightLattice +import Lattice.FiniteValueMap data Sign : Set where + : Sign @@ -52,6 +50,8 @@ open import Lattice.AboveBelow Sign _≡_ (record { ≈-refl = refl; ≈-sym = s open AB.Plain 0ˢ using () renaming ( finiteHeightLattice to finiteHeightLatticeᵍ + ; isLattice to isLatticeᵍ + ; fixedHeight to fixedHeightᵍ ; _≼_ to _≼ᵍ_ ; _⊔_ to _⊔ᵍ_ ) @@ -98,45 +98,54 @@ module _ (prog : Program) where open Program prog -- The variable -> sign map is a finite value-map with keys strings. Use a bundle to avoid explicitly specifying operators. - open FixedHeightFiniteMap String SignLattice _≟ˢ_ finiteHeightLatticeᵍ vars-Unique ≈ᵍ-dec + open Lattice.FiniteValueMap.WithKeys _≟ˢ_ isLatticeᵍ vars using () renaming - ( finiteHeightLattice to finiteHeightLatticeᵛ - ; FiniteMap to VariableSigns + ( FiniteMap to VariableSigns + ; isLattice to isLatticeᵛ ; _≈_ to _≈ᵛ_ ; _⊔_ to _⊔ᵛ_ - ; ≈-dec to ≈ᵛ-dec + ; _≼_ to _≼ᵛ_ + ; ≈₂-dec⇒≈-dec to ≈ᵍ-dec⇒≈ᵛ-dec ; _∈_ to _∈ᵛ_ ; _∈k_ to _∈kᵛ_ ; _updating_via_ to _updatingᵛ_via_ ; locate to locateᵛ ) - open FiniteHeightLattice finiteHeightLatticeᵛ + open IsLattice isLatticeᵛ using () renaming ( ⊔-Monotonicˡ to ⊔ᵛ-Monotonicˡ ; ⊔-Monotonicʳ to ⊔ᵛ-Monotonicʳ - ; _≼_ to _≼ᵛ_ - ; joinSemilattice to joinSemilatticeᵛ ; ⊔-idemp to ⊔ᵛ-idemp ) + open Lattice.FiniteValueMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight _≟ˢ_ isLatticeᵍ vars-Unique ≈ᵍ-dec _ fixedHeightᵍ + using () + renaming + ( isFiniteHeightLattice to isFiniteHeightLatticeᵛ + ) - ⊥ᵛ = proj₁ (proj₁ (proj₁ (FiniteHeightLattice.fixedHeight finiteHeightLatticeᵛ))) + ≈ᵛ-dec = ≈ᵍ-dec⇒≈ᵛ-dec ≈ᵍ-dec + joinSemilatticeᵛ = IsFiniteHeightLattice.joinSemilattice isFiniteHeightLatticeᵛ + fixedHeightᵛ = IsFiniteHeightLattice.fixedHeight isFiniteHeightLatticeᵛ + ⊥ᵛ = proj₁ (proj₁ (proj₁ fixedHeightᵛ)) -- Finally, the map we care about is (state -> (variables -> sign)). Bring that in. - module StateVariablesFiniteMap = FixedHeightFiniteMap State VariableSigns _≟_ finiteHeightLatticeᵛ states-Unique ≈ᵛ-dec + module StateVariablesFiniteMap = Lattice.FiniteValueMap.WithKeys _≟_ isLatticeᵛ states open StateVariablesFiniteMap using (_[_]; m₁≼m₂⇒m₁[ks]≼m₂[ks]) renaming - ( finiteHeightLattice to finiteHeightLatticeᵐ - ; FiniteMap to StateVariables + ( FiniteMap to StateVariables ; isLattice to isLatticeᵐ ; _∈k_ to _∈kᵐ_ ; locate to locateᵐ + ; _≼_ to _≼ᵐ_ ) - open FiniteHeightLattice finiteHeightLatticeᵐ + open Lattice.FiniteValueMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight _≟_ isLatticeᵛ states-Unique ≈ᵛ-dec _ fixedHeightᵛ using () - renaming (_≼_ to _≼ᵐ_) + renaming + ( isFiniteHeightLattice to isFiniteHeightLatticeᵛ + ) -- build up the 'join' function, which follows from Exercise 4.26's -- @@ -195,4 +204,8 @@ module _ (prog : Program) where in vs updatingᵛ (k ∷ []) via (λ _ → eval e k∈e⇒k∈vars vs) - -- module Test = StateVariablesFiniteMap.GeneralizedUpdate states isLatticeᵐ joinAll joinAll-Mono + open StateVariablesFiniteMap.GeneralizedUpdate states isLatticeᵐ (λ x → x) (λ a₁≼a₂ → a₁≼a₂) updateForState {!!} states + renaming + ( f' to updateAll + ; f'-Monotonic to updateAll-Mono + ) diff --git a/Lattice/AboveBelow.agda b/Lattice/AboveBelow.agda index 71c1349..1ee94ae 100644 --- a/Lattice/AboveBelow.agda +++ b/Lattice/AboveBelow.agda @@ -299,7 +299,7 @@ module Plain (x : A) where ; isLattice = isLattice } - open IsLattice isLattice using (_≼_; _≺_) public + open IsLattice isLattice using (_≼_; _≺_; ⊔-Monotonicˡ; ⊔-Monotonicʳ) public ⊥≺[x] : ∀ (x : A) → ⊥ ≺ [ x ] ⊥≺[x] x = (≈-refl , λ ()) @@ -343,10 +343,13 @@ module Plain (x : A) where isLongest {⊥} (step {_} {[ x ]} _ (≈-lift _) (step [x]≺y y≈z c@(step _ _ _))) rewrite [x]≺y⇒y≡⊤ _ _ [x]≺y with ≈-⊤-⊤ ← y≈z = ⊥-elim (¬-Chain-⊤ c) + fixedHeight : IsLattice.FixedHeight isLattice 2 + fixedHeight = (((⊥ , ⊤) , longestChain) , isLongest) + isFiniteHeightLattice : IsFiniteHeightLattice AboveBelow 2 _≈_ _⊔_ _⊓_ isFiniteHeightLattice = record { isLattice = isLattice - ; fixedHeight = (((⊥ , ⊤) , longestChain) , isLongest) + ; fixedHeight = fixedHeight } finiteHeightLattice : FiniteHeightLattice AboveBelow diff --git a/Lattice/FiniteMap.agda b/Lattice/FiniteMap.agda index 87c3d78..8eedc8f 100644 --- a/Lattice/FiniteMap.agda +++ b/Lattice/FiniteMap.agda @@ -128,7 +128,7 @@ module WithKeys (ks : List A) where ; absorb-⊓-⊔ = λ (m₁ , _) (m₂ , _) → absorb-⊓ᵐ-⊔ᵐ m₁ m₂ } - open IsLattice isLattice using (_≼_) public + open IsLattice isLattice using (_≼_; ⊔-Monotonicˡ; ⊔-Monotonicʳ) public lattice : Lattice FiniteMap lattice = record