Move predecessor code into Graphs

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-05-09 23:13:49 -07:00
parent a081edb881
commit 41ada43047
2 changed files with 8 additions and 4 deletions

View File

@ -86,6 +86,4 @@ record Program : Set where
edge⇒incoming : {s₁ s₂ : State} (s₁ , s₂) ListMem.∈ (Graph.edges graph)
s₁ ListMem.∈ (incoming s₂)
edge⇒incoming {s₁} {s₂} s₁,s₂∈es =
∈-filter⁺ (λ s' (s' , s₂) ∈? (Graph.edges graph))
(states-complete s₁) s₁,s₂∈es
edge⇒incoming = edge⇒predecessor graph

View File

@ -6,7 +6,7 @@ open import Data.Fin as 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 ()
open import Data.List.Membership.Propositional.Properties as ListMemProp using ()
open import Data.List.Membership.Propositional.Properties as ListMemProp using (∈-filter⁺)
open import Data.List.Relation.Unary.All using (All; []; _∷_)
open import Data.List.Relation.Unary.Any as RelAny using ()
open import Data.Nat as Nat using (; suc)
@ -161,3 +161,9 @@ module _ (g : Graph) where
predecessors : (Graph.Index g) List (Graph.Index g)
predecessors idx = List.filter (λ idx' (idx' , idx) ∈? (Graph.edges g)) indices
edge⇒predecessor : {idx₁ idx₂ : Graph.Index g} (idx₁ , idx₂) ListMem.∈ (Graph.edges g)
idx₁ ListMem.∈ (predecessors idx₂)
edge⇒predecessor {idx₁} {idx₂} idx₁,idx₂∈es =
∈-filter⁺ (λ idx' (idx' , idx₂) ∈? (Graph.edges g))
(indices-complete idx₁) idx₁,idx₂∈es