Skip to content

Commit

Permalink
Better naming of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Minh Nguyen committed Oct 30, 2023
1 parent 304309c commit c3907c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 5 additions & 9 deletions src/Graph/Slice.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ bwdSlice αs0 g0 = fst $ runWithGraph $ tailRecM go (empty × L.fromFoldable αs
extend α βs
pure $ Loop ((visited # insert α) × (L.fromFoldable βs <> αs))

-- Doesn't do the final negation..
fwdSliceDeMorgan :: forall g. Graph g => Set Vertex -> g -> g
fwdSliceDeMorgan αs_0 g_0 =
bwdSlice (sinks g_0 `difference` αs_0) (op g_0)

-- | De Morgan dual of backward slicing (◁_G)° ≡ Forward slicing on the opposite graph (▷_{G_op})
bwdSliceDual :: forall g. Graph g => Set Vertex -> g -> g
bwdSliceDual αs0 g0 = fwdSlice αs0 (op g0)
Expand All @@ -51,13 +46,14 @@ fwdSlice αs0 g0 = fst $ runWithGraph $ tailRecM go (M.empty × inEdges g0 αs0)
pure $ Loop (M.insert α βs h × es)

-- | De Morgan dual of forward slicing (▷_G)° ≡ Backward slicing on the opposite graph (◁_{G_op})
fwdDualAsBwdOp :: forall g. Graph g => Set Vertex -> g -> g
fwdDualAsBwdOp αs0 g0 = bwdSlice αs0 (op g0)
fwdSliceDualAsBwdOp :: forall g. Graph g => Set Vertex -> g -> g
fwdSliceDualAsBwdOp αs0 g0 = bwdSlice αs0 (op g0)

fwdDual :: forall g. Graph g => Set Vertex -> g -> g
fwdDual αs0 g0 = fwdSlice (sinks g0 `difference` αs0) g0
fwdSliceDual :: forall g. Graph g => Set Vertex -> g -> g
fwdSliceDual αs0 g0 = fwdSlice (sinks g0 `difference` αs0) g0

-- | Forward slicing (▷_G) ≡ De Morgan dual of backward slicing on the opposite graph (◁_{G_op})°
-- Doesn't do the final negation..
fwdSliceAsDeMorgan :: forall g. Graph g => Set Vertex -> g -> g
fwdSliceAsDeMorgan αs0 g0 =
bwdSlice (sinks g0 `difference` αs0) (op g0)
6 changes: 3 additions & 3 deletions test/Util.purs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Expr (ProgCxt)
import GaloisConnection (GaloisConnection(..))
import Graph (Vertex, selectαs, select𝔹s, sinks, vertices)
import Graph.GraphImpl (GraphImpl)
import Graph.Slice (bwdSliceDual, fwdDualAsBwdOp, fwdSliceDeMorgan) as G
import Graph.Slice (bwdSliceDual, fwdSliceDualAsBwdOp, fwdSliceAsDeMorgan) as G
import Lattice (Raw, 𝔹, botOf, erase, topOf)
import Module (File, initialConfig, open, parse)
import Parse (program)
Expand Down Expand Up @@ -153,12 +153,12 @@ testGraph s gconfig spec@{ δv } benchmarking = do
when logging (logAs "BwdAll/input slice" (prettyP $ select𝔹s eα αs'))

do
g' <- benchmark (method <> "-FwdDual") $ \_ -> pure (G.fwdDualAsBwdOp αs_in g)
g' <- benchmark (method <> "-FwdDual") $ \_ -> pure (G.fwdSliceDualAsBwdOp αs_in g)
-- g'' <- benchmark (method <> "-FwdDual2") $ \_ -> pure (G.fwdDual αs_in g)
when logging (logAs "FwdDual/output slice" (prettyP $ select𝔹s vα (vertices g')))
-- when logging (logAs "FwdDual2/output slice" (prettyP $ select𝔹s vα (vertices g'') <#> not))
do
g' <- benchmark (method <> "-FwdAsDeMorgan") $ \_ -> pure (G.fwdSliceDeMorgan αs_in g)
g' <- benchmark (method <> "-FwdAsDeMorgan") $ \_ -> pure (G.fwdSliceAsDeMorgan αs_in g)
when logging (logAs "FwdAsDeMorgan/output slice" (prettyP $ select𝔹s vα (vertices g') <#> not))

type TestSpec =
Expand Down

0 comments on commit c3907c5

Please sign in to comment.