Add formalization of 'traces through graph'
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
6e3f06ca5d
commit
e218d1b7a3
|
@ -5,7 +5,7 @@ open import Language.Base
|
|||
open import Data.Integer using (ℤ; +_) renaming (_+_ to _+ᶻ_; _-_ to _-ᶻ_)
|
||||
open import Data.Product using (_×_; _,_)
|
||||
open import Data.String using (String)
|
||||
open import Data.List using (List; _∷_)
|
||||
open import Data.List as List using (List)
|
||||
open import Data.Nat using (ℕ)
|
||||
open import Relation.Nullary using (¬_)
|
||||
open import Relation.Binary.PropositionalEquality using (_≡_)
|
||||
|
@ -17,8 +17,8 @@ Env : Set
|
|||
Env = List (String × Value)
|
||||
|
||||
data _∈_ : (String × Value) → Env → Set where
|
||||
here : ∀ (s : String) (v : Value) (ρ : Env) → (s , v) ∈ ((s , v) ∷ ρ)
|
||||
there : ∀ (s s' : String) (v v' : Value) (ρ : Env) → ¬ (s ≡ s') → (s , v) ∈ ρ → (s , v) ∈ ((s' , v') ∷ ρ)
|
||||
here : ∀ (s : String) (v : Value) (ρ : Env) → (s , v) ∈ ((s , v) List.∷ ρ)
|
||||
there : ∀ (s s' : String) (v v' : Value) (ρ : Env) → ¬ (s ≡ s') → (s , v) ∈ ρ → (s , v) ∈ ((s' , v') List.∷ ρ)
|
||||
|
||||
data _,_⇒ᵉ_ : Env → Expr → Value → Set where
|
||||
⇒ᵉ-ℕ : ∀ (ρ : Env) (n : ℕ) → ρ , (# n) ⇒ᵉ (↑ᶻ (+ n))
|
||||
|
@ -33,7 +33,12 @@ data _,_⇒ᵉ_ : Env → Expr → Value → Set where
|
|||
data _,_⇒ᵇ_ : Env → BasicStmt → Env → Set where
|
||||
⇒ᵇ-noop : ∀ (ρ : Env) → ρ , noop ⇒ᵇ ρ
|
||||
⇒ᵇ-← : ∀ (ρ : Env) (x : String) (e : Expr) (v : Value) →
|
||||
ρ , e ⇒ᵉ v → ρ , (x ← e) ⇒ᵇ ((x , v) ∷ ρ)
|
||||
ρ , e ⇒ᵉ v → ρ , (x ← e) ⇒ᵇ ((x , v) List.∷ ρ)
|
||||
|
||||
data _,_⇒ᵇˢ_ : Env → List BasicStmt → Env → Set where
|
||||
[] : ∀ {ρ : Env} → ρ , List.[] ⇒ᵇˢ ρ
|
||||
_∷_ : ∀ {ρ₁ ρ₂ ρ₃ : Env} {bs : BasicStmt} {bss : List BasicStmt} →
|
||||
ρ₁ , bs ⇒ᵇ ρ₂ → ρ₂ , bss ⇒ᵇˢ ρ₃ → ρ₁ , (bs List.∷ bss) ⇒ᵇˢ ρ₃
|
||||
|
||||
data _,_⇒ˢ_ : Env → Stmt → Env → Set where
|
||||
⇒ˢ-⟨⟩ : ∀ (ρ₁ ρ₂ : Env) (bs : BasicStmt) →
|
||||
|
|
24
Language/Traces.agda
Normal file
24
Language/Traces.agda
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Language.Traces where
|
||||
|
||||
open import Language.Base public
|
||||
open import Language.Semantics public
|
||||
open import Language.Graphs public
|
||||
|
||||
open import Data.Product using (_,_)
|
||||
open import Data.List.Membership.Propositional as MemProp using ()
|
||||
|
||||
module _ {g : Graph} where
|
||||
open Graph g using (Index; edges)
|
||||
|
||||
data Trace : Index → Index → Env → Env → Set where
|
||||
Trace-single : ∀ {ρ₁ ρ₂ : Env} {idx : Index} →
|
||||
ρ₁ , (g [ idx ]) ⇒ᵇˢ ρ₂ → Trace idx idx ρ₁ ρ₂
|
||||
Trace-edge : ∀ {ρ₁ ρ₂ ρ₃ : Env} {idx₁ idx₂ idx₃ : Index} →
|
||||
ρ₁ , (g [ idx₁ ]) ⇒ᵇˢ ρ₂ → (idx₁ , idx₂) MemProp.∈ edges →
|
||||
Trace idx₂ idx₃ ρ₂ ρ₃ → Trace idx₁ idx₃ ρ₁ ρ₃
|
||||
|
||||
_++⟨_⟩_ : ∀ {idx₁ idx₂ idx₃ idx₄ : Index} {ρ₁ ρ₂ ρ₃ : Env} →
|
||||
Trace idx₁ idx₂ ρ₁ ρ₂ → (idx₂ , idx₃) MemProp.∈ edges →
|
||||
Trace idx₃ idx₄ ρ₂ ρ₃ → Trace idx₁ idx₄ ρ₁ ρ₃
|
||||
_++⟨_⟩_ (Trace-single ρ₁⇒ρ₂) idx₂→idx₃ tr = Trace-edge ρ₁⇒ρ₂ idx₂→idx₃ tr
|
||||
_++⟨_⟩_ (Trace-edge ρ₁⇒ρ₂ idx₁→idx' tr') idx₂→idx₃ tr = Trace-edge ρ₁⇒ρ₂ idx₁→idx' (tr' ++⟨ idx₂→idx₃ ⟩ tr)
|
Loading…
Reference in New Issue
Block a user