Stop using modules in 'Sign' analysis

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-03-10 19:23:48 -07:00
parent 8515491327
commit 237250cf72
3 changed files with 36 additions and 20 deletions

View File

@ -12,9 +12,7 @@ open import Data.Unit using ()
open import Language open import Language
open import Lattice open import Lattice
open import Utils using (Pairwise) open import Utils using (Pairwise)
import Lattice.Bundles.FiniteValueMap import Lattice.FiniteValueMap
private module FixedHeightFiniteMap = Lattice.Bundles.FiniteValueMap.FromFiniteHeightLattice
data Sign : Set where data Sign : Set where
+ : Sign + : Sign
@ -52,6 +50,8 @@ open import Lattice.AboveBelow Sign _≡_ (record { ≈-refl = refl; ≈-sym = s
open AB.Plain 0ˢ using () open AB.Plain 0ˢ using ()
renaming renaming
( finiteHeightLattice to finiteHeightLatticeᵍ ( finiteHeightLattice to finiteHeightLatticeᵍ
; isLattice to isLatticeᵍ
; fixedHeight to fixedHeightᵍ
; _≼_ to _≼ᵍ_ ; _≼_ to _≼ᵍ_
; _⊔_ to _⊔ᵍ_ ; _⊔_ to _⊔ᵍ_
) )
@ -98,45 +98,54 @@ module _ (prog : Program) where
open Program prog open Program prog
-- The variable -> sign map is a finite value-map with keys strings. Use a bundle to avoid explicitly specifying operators. -- 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 () using ()
renaming renaming
( finiteHeightLattice to finiteHeightLatticeᵛ ( FiniteMap to VariableSigns
; FiniteMap to VariableSigns ; isLattice to isLatticeᵛ
; _≈_ to _≈ᵛ_ ; _≈_ to _≈ᵛ_
; _⊔_ to _⊔ᵛ_ ; _⊔_ to _⊔ᵛ_
; ≈-dec to ≈ᵛ-dec ; _≼_ to _≼ᵛ_
; ≈₂-dec⇒≈-dec to ≈ᵍ-dec⇒≈ᵛ-dec
; _∈_ to _∈ᵛ_ ; _∈_ to _∈ᵛ_
; _∈k_ to _∈kᵛ_ ; _∈k_ to _∈kᵛ_
; _updating_via_ to _updatingᵛ_via_ ; _updating_via_ to _updatingᵛ_via_
; locate to locateᵛ ; locate to locateᵛ
) )
open FiniteHeightLattice finiteHeightLatticeᵛ open IsLattice isLatticeᵛ
using () using ()
renaming renaming
( ⊔-Monotonicˡ to ⊔ᵛ-Monotonicˡ ( ⊔-Monotonicˡ to ⊔ᵛ-Monotonicˡ
; ⊔-Monotonicʳ to ⊔ᵛ-Monotonicʳ ; ⊔-Monotonicʳ to ⊔ᵛ-Monotonicʳ
; _≼_ to _≼ᵛ_
; joinSemilattice to joinSemilatticeᵛ
; ⊔-idemp to ⊔ᵛ-idemp ; ⊔-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. -- 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 open StateVariablesFiniteMap
using (_[_]; m₁≼m₂⇒m₁[ks]≼m₂[ks]) using (_[_]; m₁≼m₂⇒m₁[ks]≼m₂[ks])
renaming renaming
( finiteHeightLattice to finiteHeightLatticeᵐ ( FiniteMap to StateVariables
; FiniteMap to StateVariables
; isLattice to isLatticeᵐ ; isLattice to isLatticeᵐ
; _∈k_ to _∈kᵐ_ ; _∈k_ to _∈kᵐ_
; locate to locateᵐ ; locate to locateᵐ
; _≼_ to _≼ᵐ_
) )
open FiniteHeightLattice finiteHeightLatticeᵐ open Lattice.FiniteValueMap.IterProdIsomorphism.WithUniqueKeysAndFixedHeight _≟_ isLatticeᵛ states-Unique ≈ᵛ-dec _ fixedHeightᵛ
using () using ()
renaming (_≼_ to _≼ᵐ_) renaming
( isFiniteHeightLattice to isFiniteHeightLatticeᵛ
)
-- build up the 'join' function, which follows from Exercise 4.26's -- build up the 'join' function, which follows from Exercise 4.26's
-- --
@ -195,4 +204,8 @@ module _ (prog : Program) where
in in
vs updatingᵛ (k []) via (λ _ eval e k∈e⇒k∈vars vs) 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
)

View File

@ -299,7 +299,7 @@ module Plain (x : A) where
; isLattice = isLattice ; isLattice = isLattice
} }
open IsLattice isLattice using (_≼_; _≺_) public open IsLattice isLattice using (_≼_; _≺_; ⊔-Monotonicˡ; ⊔-Monotonicʳ) public
⊥≺[x] : (x : A) [ x ] ⊥≺[x] : (x : A) [ x ]
⊥≺[x] x = (≈-refl , λ ()) ⊥≺[x] x = (≈-refl , λ ())
@ -343,10 +343,13 @@ module Plain (x : A) where
isLongest {} (step {_} {[ x ]} _ (≈-lift _) (step [x]≺y y≈z c@(step _ _ _))) isLongest {} (step {_} {[ x ]} _ (≈-lift _) (step [x]≺y y≈z c@(step _ _ _)))
rewrite [x]≺y⇒y≡ _ _ [x]≺y with ≈-- y≈z = ⊥-elim (¬-Chain- c) 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 : IsFiniteHeightLattice AboveBelow 2 _≈_ _⊔_ _⊓_
isFiniteHeightLattice = record isFiniteHeightLattice = record
{ isLattice = isLattice { isLattice = isLattice
; fixedHeight = ((( , ) , longestChain) , isLongest) ; fixedHeight = fixedHeight
} }
finiteHeightLattice : FiniteHeightLattice AboveBelow finiteHeightLattice : FiniteHeightLattice AboveBelow

View File

@ -128,7 +128,7 @@ module WithKeys (ks : List A) where
; absorb-⊓-⊔ = λ (m₁ , _) (m₂ , _) absorb-⊓ᵐ-⊔ᵐ m₁ m₂ ; absorb-⊓-⊔ = λ (m₁ , _) (m₂ , _) absorb-⊓ᵐ-⊔ᵐ m₁ m₂
} }
open IsLattice isLattice using (_≼_) public open IsLattice isLattice using (_≼_; ⊔-Monotonicˡ; ⊔-Monotonicʳ) public
lattice : Lattice FiniteMap lattice : Lattice FiniteMap
lattice = record lattice = record