2024-02-07 22:51:08 -08:00
|
|
|
|
module Language where
|
|
|
|
|
|
2024-04-13 18:39:38 -07:00
|
|
|
|
open import Language.Base public
|
|
|
|
|
open import Language.Semantics public
|
2024-05-08 23:30:03 -07:00
|
|
|
|
open import Language.Traces public
|
2024-04-13 18:39:38 -07:00
|
|
|
|
open import Language.Graphs public
|
2024-04-20 20:25:40 -07:00
|
|
|
|
open import Language.Properties public
|
2024-04-13 18:39:38 -07:00
|
|
|
|
|
|
|
|
|
open import Data.Fin using (Fin; suc; zero)
|
|
|
|
|
open import Data.Fin.Properties as FinProp using (suc-injective)
|
|
|
|
|
open import Data.List as List using (List; []; _∷_)
|
|
|
|
|
open import Data.List.Membership.Propositional as ListMem using ()
|
2024-05-09 16:56:45 -07:00
|
|
|
|
open import Data.List.Membership.Propositional.Properties as ListMemProp using (∈-filter⁺)
|
2024-05-09 22:49:53 -07:00
|
|
|
|
open import Data.List.Relation.Unary.Any as RelAny using ()
|
2024-04-13 18:39:38 -07:00
|
|
|
|
open import Data.Nat using (ℕ; suc)
|
|
|
|
|
open import Data.Product using (_,_; Σ; proj₁; proj₂)
|
|
|
|
|
open import Data.Product.Properties as ProdProp using ()
|
|
|
|
|
open import Data.String using (String) renaming (_≟_ to _≟ˢ_)
|
|
|
|
|
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
|
2024-03-09 13:59:48 -08:00
|
|
|
|
open import Relation.Nullary using (¬_)
|
|
|
|
|
|
|
|
|
|
open import Lattice
|
2024-04-13 18:39:38 -07:00
|
|
|
|
open import Utils using (Unique; push; Unique-map; x∈xs⇒fx∈fxs)
|
|
|
|
|
open import Lattice.MapSet _≟ˢ_ using ()
|
2024-03-09 13:59:48 -08:00
|
|
|
|
renaming
|
|
|
|
|
( MapSet to StringSet
|
|
|
|
|
; to-List to to-Listˢ
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
record Program : Set where
|
|
|
|
|
field
|
2024-04-13 14:08:40 -07:00
|
|
|
|
rootStmt : Stmt
|
2024-04-13 13:39:15 -07:00
|
|
|
|
|
|
|
|
|
graph : Graph
|
2024-05-09 21:08:32 -07:00
|
|
|
|
graph = wrap (buildCfg rootStmt)
|
2024-04-13 13:39:15 -07:00
|
|
|
|
|
|
|
|
|
State : Set
|
|
|
|
|
State = Graph.Index graph
|
|
|
|
|
|
|
|
|
|
initialState : State
|
2024-05-09 21:08:32 -07:00
|
|
|
|
initialState = proj₁ (wrap-input (buildCfg rootStmt))
|
2024-04-13 13:39:15 -07:00
|
|
|
|
|
|
|
|
|
finalState : State
|
2024-05-09 21:08:32 -07:00
|
|
|
|
finalState = proj₁ (wrap-output (buildCfg rootStmt))
|
2024-03-09 13:59:48 -08:00
|
|
|
|
|
2024-05-09 22:49:53 -07:00
|
|
|
|
trace : ∀ {ρ : Env} → [] , rootStmt ⇒ˢ ρ → Trace {graph} initialState finalState [] ρ
|
|
|
|
|
trace {ρ} ∅,s⇒ρ
|
|
|
|
|
with MkEndToEndTrace idx₁ (RelAny.here refl) idx₂ (RelAny.here refl) tr
|
|
|
|
|
← EndToEndTrace-wrap (buildCfg-sufficient ∅,s⇒ρ) = tr
|
|
|
|
|
|
2024-03-09 13:59:48 -08:00
|
|
|
|
private
|
|
|
|
|
vars-Set : StringSet
|
2024-04-13 14:08:40 -07:00
|
|
|
|
vars-Set = Stmt-vars rootStmt
|
2024-03-09 13:59:48 -08:00
|
|
|
|
|
|
|
|
|
vars : List String
|
|
|
|
|
vars = to-Listˢ vars-Set
|
|
|
|
|
|
|
|
|
|
vars-Unique : Unique vars
|
|
|
|
|
vars-Unique = proj₂ vars-Set
|
|
|
|
|
|
|
|
|
|
states : List State
|
2024-05-09 21:26:32 -07:00
|
|
|
|
states = indices graph
|
2024-03-09 13:59:48 -08:00
|
|
|
|
|
2024-04-13 18:39:38 -07:00
|
|
|
|
states-complete : ∀ (s : State) → s ListMem.∈ states
|
2024-05-09 21:26:32 -07:00
|
|
|
|
states-complete = indices-complete graph
|
2024-03-10 18:13:01 -07:00
|
|
|
|
|
2024-03-09 13:59:48 -08:00
|
|
|
|
states-Unique : Unique states
|
2024-05-09 21:26:32 -07:00
|
|
|
|
states-Unique = indices-Unique graph
|
2024-03-09 13:59:48 -08:00
|
|
|
|
|
2024-04-13 13:39:15 -07:00
|
|
|
|
code : State → List BasicStmt
|
|
|
|
|
code st = graph [ st ]
|
2024-03-10 16:41:21 -07:00
|
|
|
|
|
2024-04-13 18:39:38 -07:00
|
|
|
|
-- vars-complete : ∀ {k : String} (s : State) → k ∈ᵇ (code s) → k ListMem.∈ vars
|
2024-04-03 22:29:58 -07:00
|
|
|
|
-- vars-complete {k} s = ∈⇒∈-Stmts-vars {length} {k} {stmts} {s}
|
2024-03-10 16:41:21 -07:00
|
|
|
|
|
2024-03-09 13:59:48 -08:00
|
|
|
|
_≟_ : IsDecidable (_≡_ {_} {State})
|
2024-04-13 18:39:38 -07:00
|
|
|
|
_≟_ = FinProp._≟_
|
2024-03-09 23:06:47 -08:00
|
|
|
|
|
2024-04-13 13:39:15 -07:00
|
|
|
|
_≟ᵉ_ : IsDecidable (_≡_ {_} {Graph.Edge graph})
|
2024-04-13 18:39:38 -07:00
|
|
|
|
_≟ᵉ_ = ProdProp.≡-dec _≟_ _≟_
|
2024-04-13 13:39:15 -07:00
|
|
|
|
|
2024-04-13 18:39:38 -07:00
|
|
|
|
open import Data.List.Membership.DecPropositional _≟ᵉ_ using (_∈?_)
|
2024-03-09 23:06:47 -08:00
|
|
|
|
|
|
|
|
|
incoming : State → List State
|
2024-05-09 21:26:32 -07:00
|
|
|
|
incoming = predecessors graph
|
2024-05-09 16:56:45 -07:00
|
|
|
|
|
2024-05-10 21:30:56 -07:00
|
|
|
|
initialState-pred-∅ : incoming initialState ≡ []
|
|
|
|
|
initialState-pred-∅ =
|
|
|
|
|
wrap-preds-∅ (buildCfg rootStmt) initialState (RelAny.here refl)
|
|
|
|
|
|
2024-05-09 16:56:45 -07:00
|
|
|
|
edge⇒incoming : ∀ {s₁ s₂ : State} → (s₁ , s₂) ListMem.∈ (Graph.edges graph) →
|
|
|
|
|
s₁ ListMem.∈ (incoming s₂)
|
2024-05-09 23:13:49 -07:00
|
|
|
|
edge⇒incoming = edge⇒predecessor graph
|