2024-03-01 21:58:58 -08:00
|
|
|
|
module Main where
|
|
|
|
|
|
|
|
|
|
open import IO
|
2024-03-01 23:42:10 -08:00
|
|
|
|
open import Level using (0ℓ)
|
2024-03-01 21:58:58 -08:00
|
|
|
|
open import Data.Nat.Show using (show)
|
2024-03-01 23:42:10 -08:00
|
|
|
|
open import Data.List using (List; _∷_; []; foldr)
|
|
|
|
|
open import Data.String using (String; _++_) renaming (_≟_ to _≟ˢ_)
|
2024-03-01 21:58:58 -08:00
|
|
|
|
open import Data.Unit using (⊤; tt) renaming (_≟_ to _≟ᵘ_)
|
2024-03-01 23:42:10 -08:00
|
|
|
|
open import Data.Product using (_,_; _×_; proj₁; proj₂)
|
2024-03-01 21:58:58 -08:00
|
|
|
|
open import Data.List.Relation.Unary.All using (_∷_; [])
|
|
|
|
|
open import Relation.Binary.PropositionalEquality as Eq using (_≡_; sym; subst; refl; trans)
|
|
|
|
|
open import Relation.Nullary using (¬_)
|
|
|
|
|
|
|
|
|
|
open import Utils using (Unique; push; empty)
|
|
|
|
|
|
|
|
|
|
xyzw : List String
|
|
|
|
|
xyzw = "x" ∷ "y" ∷ "z" ∷ "w" ∷ []
|
|
|
|
|
|
|
|
|
|
xyzw-Unique : Unique xyzw
|
|
|
|
|
xyzw-Unique = push ((λ ()) ∷ (λ ()) ∷ (λ ()) ∷ []) (push ((λ ()) ∷ (λ ()) ∷ []) (push ((λ ()) ∷ []) (push [] empty)))
|
|
|
|
|
|
2024-03-01 23:42:10 -08:00
|
|
|
|
open import Lattice using (IsFiniteHeightLattice; FiniteHeightLattice; Monotonic)
|
2024-03-09 21:46:15 -08:00
|
|
|
|
|
2024-03-01 23:42:10 -08:00
|
|
|
|
open import Lattice.AboveBelow ⊤ _≡_ (record { ≈-refl = refl; ≈-sym = sym; ≈-trans = trans }) _≟ᵘ_ as AB using () renaming (≈-dec to ≈ᵘ-dec)
|
|
|
|
|
open AB.Plain using () renaming (finiteHeightLattice to finiteHeightLatticeᵘ)
|
|
|
|
|
|
|
|
|
|
showAboveBelow : AB.AboveBelow → String
|
|
|
|
|
showAboveBelow AB.⊤ = "⊤"
|
|
|
|
|
showAboveBelow AB.⊥ = "⊥"
|
|
|
|
|
showAboveBelow (AB.[_] tt) = "()"
|
|
|
|
|
|
2024-03-09 21:46:15 -08:00
|
|
|
|
fhlᵘ = finiteHeightLatticeᵘ (Data.Unit.tt)
|
|
|
|
|
|
|
|
|
|
import Lattice.Bundles.FiniteValueMap
|
|
|
|
|
open Lattice.Bundles.FiniteValueMap.FromFiniteHeightLattice String AB.AboveBelow _≟ˢ_ fhlᵘ xyzw-Unique ≈ᵘ-dec using (FiniteMap; ≈-dec) renaming (finiteHeightLattice to fhlⁱᵖ)
|
2024-03-01 23:42:10 -08:00
|
|
|
|
|
2024-03-09 21:46:15 -08:00
|
|
|
|
showMap : FiniteMap → String
|
|
|
|
|
showMap ((kvs , _) , _) = "{" ++ foldr (λ (x , y) rest → x ++ " ↦ " ++ showAboveBelow y ++ ", " ++ rest) "" kvs ++ "}"
|
2024-03-01 21:58:58 -08:00
|
|
|
|
|
2024-03-01 23:42:10 -08:00
|
|
|
|
open FiniteHeightLattice fhlⁱᵖ using (_≈_; _⊔_; _⊓_; ⊔-idemp; _≼_; ≈-⊔-cong; ≈-refl; ≈-trans; ≈-sym; ⊔-assoc; ⊔-comm; ⊔-Monotonicˡ)
|
|
|
|
|
open import Relation.Binary.Reasoning.Base.Single _≈_ (λ {m} → ≈-refl {m}) (λ {m₁} {m₂} {m₃} → ≈-trans {m₁} {m₂} {m₃}) -- why am I having to eta-expand here?
|
|
|
|
|
|
|
|
|
|
smallestMap = proj₁ (proj₁ (proj₁ (FiniteHeightLattice.fixedHeight fhlⁱᵖ)))
|
|
|
|
|
largestMap = proj₂ (proj₁ (proj₁ (FiniteHeightLattice.fixedHeight fhlⁱᵖ)))
|
|
|
|
|
|
2024-03-09 21:46:15 -08:00
|
|
|
|
dumb : FiniteMap
|
2024-03-01 23:42:10 -08:00
|
|
|
|
dumb = ((("x" , AB.[_] tt) ∷ ("y" , AB.⊥) ∷ ("z" , AB.⊥) ∷ ("w" , AB.⊥) ∷ [] , xyzw-Unique) , refl)
|
|
|
|
|
|
2024-03-09 21:46:15 -08:00
|
|
|
|
dumbFunction : FiniteMap → FiniteMap
|
2024-03-01 23:42:10 -08:00
|
|
|
|
dumbFunction = _⊔_ dumb
|
|
|
|
|
|
|
|
|
|
dumbFunction-Monotonic : Monotonic _≼_ _≼_ dumbFunction
|
|
|
|
|
dumbFunction-Monotonic {m₁} {m₂} m₁≼m₂ = ⊔-Monotonicˡ dumb {m₁} {m₂} m₁≼m₂
|
|
|
|
|
|
2024-03-09 21:46:15 -08:00
|
|
|
|
open import Fixedpoint {0ℓ} {FiniteMap} {8} {_≈_} {_⊔_} {_⊓_} ≈-dec (FiniteHeightLattice.isFiniteHeightLattice fhlⁱᵖ) dumbFunction (λ {m₁} {m₂} m₁≼m₂ → dumbFunction-Monotonic {m₁} {m₂} m₁≼m₂)
|
2024-03-01 23:42:10 -08:00
|
|
|
|
|
|
|
|
|
main = run {0ℓ} (putStrLn (showMap aᶠ))
|