Compare commits

...

3 Commits

Author SHA1 Message Date
bbfba34e05 Prove another (simple) case
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-04-28 13:37:03 -07:00
aec15573fc Add properties of end-to-end traces on loops 2024-04-28 12:53:25 -07:00
b4d395767d Simplify operations used for constructing graphs
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
2024-04-28 12:40:50 -07:00
2 changed files with 58 additions and 4 deletions

View File

@ -84,6 +84,18 @@ loop g = record g
List.cartesianProduct (Graph.outputs g) (Graph.inputs g)
}
optional : Graph Graph
optional 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) [])
; inputs = zero []
; outputs = (suc zero) []
}
infixr 5 _skipto_
_skipto_ : Graph Graph Graph
_skipto_ g₁ g₂ = record (g₁ g₂)
@ -110,4 +122,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) = (loop (singleton [] buildCfg s)) skipto (singleton [])
buildCfg (while _ repeat s) = optional (loop (buildCfg s))

View File

@ -106,12 +106,51 @@ Trace-↦ʳ {g₁} {g₂} {idx₁} (Trace-edge ρ₁⇒ρ idx₁→idx tr')
(ListMemProp.∈-++⁺ˡ (x∈xs⇒fx∈fxs (Graph.size g₁ ↑ʳ_) idx₁→idx)))
(Trace-↦ʳ {g₁} {g₂} tr')
Trace-loop : {g : Graph} {idx₁ idx₂ : Graph.Index g} {ρ₁ ρ₂ : Env}
Trace {g} idx₁ idx₂ ρ₁ ρ₂ Trace {loop g} idx₁ idx₂ ρ₁ ρ₂
Trace-loop : {g : Graph} {idx₁ idx₂ : Graph.Index g} {ρ₁ ρ₂ : Env}
Trace {g} idx₁ idx₂ ρ₁ ρ₂ Trace {loop g} idx₁ idx₂ ρ₁ ρ₂
Trace-loop {idx₁ = idx₁} {idx₁} (Trace-single ρ₁⇒ρ₂) = Trace-single ρ₁⇒ρ₂
Trace-loop {g} {idx₁} (Trace-edge ρ₁⇒ρ idx₁→idx tr') =
Trace-loop {g} {idx₁} (Trace-edge ρ₁⇒ρ idx₁→idx tr') =
Trace-edge ρ₁⇒ρ (ListMemProp.∈-++⁺ˡ idx₁→idx) (Trace-loop tr')
EndToEndTrace-loop : {g : Graph} {ρ₁ ρ₂ : Env}
EndToEndTrace {g} ρ₁ ρ₂ EndToEndTrace {loop g} ρ₁ ρ₂
EndToEndTrace-loop etr = record
{ idx₁ = EndToEndTrace.idx₁ etr
; idx₁∈inputs = EndToEndTrace.idx₁∈inputs etr
; idx₂ = EndToEndTrace.idx₂ etr
; idx₂∈outputs = EndToEndTrace.idx₂∈outputs etr
; trace = Trace-loop (EndToEndTrace.trace etr)
}
EndToEndTrace-loop² : {g : Graph} {ρ₁ ρ₂ ρ₃ : Env}
EndToEndTrace {loop g} ρ₁ ρ₂
EndToEndTrace {loop g} ρ₂ ρ₃
EndToEndTrace {loop g} ρ₁ ρ₃
EndToEndTrace-loop² {g} etr₁ etr₂ = record
{ idx₁ = EndToEndTrace.idx₁ etr₁
; idx₁∈inputs = EndToEndTrace.idx₁∈inputs etr₁
; idx₂ = EndToEndTrace.idx₂ etr₂
; idx₂∈outputs = EndToEndTrace.idx₂∈outputs etr₂
; trace =
let
o∈tr₁ = EndToEndTrace.idx₂∈outputs etr₁
i∈tr₂ = EndToEndTrace.idx₁∈inputs etr₂
oi∈es = ListMemProp.∈-++⁺ʳ (Graph.edges g) (∈-cartesianProduct o∈tr₁ i∈tr₂)
in
EndToEndTrace.trace etr₁ ++⟨ oi∈es EndToEndTrace.trace etr₂
}
Trace-optional : {g : Graph} {idx₁ idx₂ : Graph.Index g} {ρ₁ ρ₂ : Env}
Trace {g} idx₁ idx₂ ρ₁ ρ₂ Trace {optional g} (2 Fin.↑ʳ idx₁) (2 Fin.↑ʳ idx₂) ρ₁ ρ₂
Trace-optional = {!!}
EndToEndTrace-optional : {g : Graph} {ρ₁ ρ₂ : Env}
EndToEndTrace {g} ρ₁ ρ₂ EndToEndTrace {optional g} ρ₁ ρ₂
EndToEndTrace-optional = {!!}
EndToEndTrace-optional-ε : {g : Graph} {ρ : Env} EndToEndTrace {optional g} ρ ρ
EndToEndTrace-optional-ε = {!!}
infixr 5 _++_
_++_ : {g₁ g₂ : Graph} {ρ₁ ρ₂ ρ₃ : Env}
EndToEndTrace {g₁} ρ₁ ρ₂ EndToEndTrace {g₂} ρ₂ ρ₃
@ -161,3 +200,6 @@ buildCfg-sufficient (⇒ˢ-if-false ρ₁ ρ₂ _ s₁ s₂ _ ρ₁,s₂⇒ρ
Trace-singleton[] ρ₁ ++
(EndToEndTrace-∙ʳ {buildCfg s₁} (buildCfg-sufficient ρ₁,s₂⇒ρ)) ++
Trace-singleton[] ρ₂
buildCfg-sufficient (⇒ˢ-while-true ρ₁ ρ₂ ρ₃ _ _ s _ _ ρ₁,s⇒ρ ρ₂,ws⇒ρ) = {!!}
buildCfg-sufficient (⇒ˢ-while-false ρ _ s _) =
EndToEndTrace-optional-ε {loop (buildCfg s)} {ρ}