Prove that graphs build by buildCfg are sufficient

That is, if we have a (semantic) trace, we can
find a corresponding path through the CFG.

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
2024-04-29 20:57:43 -07:00
parent bbfba34e05
commit c574ca9c56
3 changed files with 72 additions and 57 deletions

View File

@@ -79,19 +79,13 @@ _↦_ g₁ g₂ = record
}
loop : Graph → Graph
loop g = record g
{ edges = Graph.edges g List.++
List.cartesianProduct (Graph.outputs g) (Graph.inputs g)
}
optional : Graph → Graph
optional g = record
loop g = record
{ size = 2 Nat.+ Graph.size g
; nodes = [] ∷ [] ∷ Graph.nodes g
; edges = (2 ↑ʳᵉ Graph.edges g) List.++
List.map (zero ,_) (2 ↑ʳⁱ Graph.inputs g) List.++
List.map (_, suc zero) (2 ↑ʳⁱ Graph.outputs g) List.++
((zero , suc zero) ∷ [])
((suc zero , zero) ∷ (zero , suc zero) ∷ [])
; inputs = zero ∷ []
; outputs = (suc zero) ∷ []
}
@@ -122,4 +116,4 @@ buildCfg : Stmt → Graph
buildCfg ⟨ bs₁ ⟩ = singleton (bs₁ ∷ [])
buildCfg (s₁ then s₂) = buildCfg s₁ ↦ buildCfg s₂
buildCfg (if _ then s₁ else s₂) = singleton [] ↦ (buildCfg s₁ ∙ buildCfg s₂) ↦ singleton []
buildCfg (while _ repeat s) = optional (loop (buildCfg s))
buildCfg (while _ repeat s) = loop (buildCfg s)