A rule is a span L ← I → R where:
L is the pattern (left-hand side)
I is the interface (preserved structure)
R is the replacement (right-hand side)
Usage
Rule(
l = ACSetTransformation(),
r = ACSetTransformation(),
monic = logical(0),
semantics = character(0)
)
rule(l, r, monic = TRUE, semantics = "DPO")Examples
# DPO rule: delete an edge (keep both vertices)
L <- path_graph(2) # 1 -> 2 (pattern: an edge)
I <- Graph(V = 2) # 1 2 (interface: two vertices, no edge)
R <- Graph(V = 2) # 1 2 (replacement: same)
l <- ACSetTransformation(list(V = c(1L, 2L), E = integer(0)), I, L)
r <- ACSetTransformation(list(V = c(1L, 2L), E = integer(0)), I, R)
rl <- rule(l, r)
# Apply to a triangle (3-cycle)
tri <- cycle_graph(3)
result <- rewrite(rl, tri)
ne(result) # 2 (one edge deleted)
#> [1] 2