B¨
- hm Reduction in
Infinitary Term Graph Rewriting Systems
Patrick Bahr
IT University of Copenhagen
B ohm Reduction in Infinitary Term Graph Rewriting Systems - - PowerPoint PPT Presentation
B ohm Reduction in Infinitary Term Graph Rewriting Systems Patrick Bahr IT University of Copenhagen Overview 1. Motivation Why term graphs? Why infinitary term graph rewriting? Why B ohm reduction? 2. B ohm Reduction on
Patrick Bahr
IT University of Copenhagen
◮ Why term graphs? ◮ Why infinitary term graph rewriting? ◮ Why B¨
f (g(a), h(g(a), a))
1 / 17
f (g(a), h(g(a), a)) f g a h g a a
1 / 17
f (g(a), h(g(a), a)) f g a h g a a f g a h
1 / 17
f (g(a), h(g(a), a)) f g a h g a a f g a h unravel
1 / 17
f g a h g a a f g a h a → b unravel
1 / 17
f g a h g a a f g b h a → b unravel
1 / 17
f g b h g b b f g b h a → b unravel
1 / 17
f g b h g b b f g b h
1 / 17
f g b h g b f g b h g b f g b h unravel
1 / 17
f g b h g b f g b h g b f g b h b → c unravel
1 / 17
f g b h g b f g b h g b f g c h b → c unravel
1 / 17
f g c h g c f g c h g c f g c h b → c unravel
1 / 17
For every left-linear, left-finite GRS R we have
g h
∗
s U (·) U (R) R
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
2 / 17
For every left-linear, left-finite GRS R we have
g h
∗
s U (·) U (R) R t U (·)
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
2 / 17
For every left-linear, left-finite GRS R we have
g h
∗
s U (·) U (R) R t U (·)
s t
regular
g U (·) U (R) R
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
2 / 17
For every left-linear, left-finite GRS R we have
g h
∗
s U (·) U (R) R t U (·)
s t
regular
g U (·) U (R) R h
∗
U (·)
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
2 / 17
For every left-linear, left-finite GRS R we have
g h
∗
s U (·) U (R) R t U (·)
s t
regular
g U (·) U (R) R h
∗
U (·)
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
2 / 17
For every left-linear, left-finite GRS R we have
g h
∗
s U (·) U (R) R t U (·)
s t
regular
g U (·) U (R) R t′ h
∗
U (·)
regular
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
2 / 17
◮ A common formalism
◮ study correspondences between infinitary TRSs and
finitary GRSs
letrec”. In: Annals of Pure and Applied Logic (2002).
Letrec”. In: ICFP. 2014.
3 / 17
◮ A common formalism
◮ study correspondences between infinitary TRSs and
finitary GRSs
◮ Lazy evaluation
◮ infinitary term rewriting only covers non-strictness ◮ however: lazy evaluation = non-strictness + sharing
letrec”. In: Annals of Pure and Applied Logic (2002).
Letrec”. In: ICFP. 2014.
3 / 17
◮ A common formalism
◮ study correspondences between infinitary TRSs and
finitary GRSs
◮ Lazy evaluation
◮ infinitary term rewriting only covers non-strictness ◮ however: lazy evaluation = non-strictness + sharing
◮ lambda calculi with letrec2,3
◮ these calculi are non-confluent ◮ but there is a notion of infinite normal forms
letrec”. In: Annals of Pure and Applied Logic (2002).
Letrec”. In: ICFP. 2014.
3 / 17
Term graph rules for a :: x → b :: a :: x ::
l
a x ::
r
b :: a ρ1:
4 / 17
Term graph rules for a :: x → b :: a :: x ::
l
a x ::
r
b :: a ρ1: Reductions: :: a :: b :: a :: b :: b :: a
ρ1 ρ1
4 / 17
Term graph rules for a :: x → b :: a :: x ::
l
a x ::
r
b :: a ρ1: Reductions: :: a :: b :: a :: b :: b :: b
ρ1 ρ1
4 / 17
Term graph rules for a :: x → b :: a :: x ::
l
a x ::
r
b :: a ρ1: ::
l
a x ::
r
b ρ2: Reductions: :: a :: b :: a :: b :: b :: b
ρ1 ρ1
4 / 17
Term graph rules for a :: x → b :: a :: x ::
l
a x ::
r
b :: a ρ1: ::
l
a x ::
r
b ρ2: Reductions: :: a :: b :: a :: b :: b :: b :: b
ρ1 ρ1 ρ2
4 / 17
g g1 g2
5 / 17
g g1 g2 g ′
5 / 17
g g1 g2 g ′
5 / 17
g g1 g2 g ′
s t g U (·) U (R) R
5 / 17
g g1 g2 g ′
s t g U (·) U (R) R t′ h U (·)
5 / 17
g g1 g2 g ′
s t g U (·) U (R) R t′ h U (·)
5 / 17
◮ B¨
◮ partial order infinitary rewriting
Rewriting”. In: J. Funct. Logic Programming (1999).
In: LMCS (2014).
In: RTA. 2012.
6 / 17
◮ B¨
◮ partial order infinitary rewriting
◮ both yield confluence for infinitary term
rewriting4,5
◮ partial order approach yields completeness
property for infinitary term graph rewriting6
Rewriting”. In: J. Funct. Logic Programming (1999).
In: LMCS (2014).
In: RTA. 2012.
6 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g f (g(f (g(f (g(. . . ))))))
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g g f g f g x ← f (x)
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g g g f g x ← f (x) x ← f (x)
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g g g g x ← f (x) x ← f (x) x ← f (x)
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g g g g x ← f (x) x ← f (x) x ← f (x)
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g g g g f f f x ← f (x) x ← f (x) x ← f (x) g(x) → x g(x) → x g(x) → x
7 / 17
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g g g g f f f g ω f ω
7 / 17
◮ terms like f ω and g ω are
considered meaningless
◮ for each meaningless term
t, add rule t → ⊥
◮ meaningless terms are
characterised by a set of axioms f (g(f (g(. . . )))) f ω g ω
In: Theoretical Computer Science (1997).
Rewriting”. In: J. Funct. Logic Programming (1999).
8 / 17
◮ terms like f ω and g ω are
considered meaningless
◮ for each meaningless term
t, add rule t → ⊥
◮ meaningless terms are
characterised by a set of axioms f (g(f (g(. . . )))) f ω g ω ⊥
In: Theoretical Computer Science (1997).
Rewriting”. In: J. Funct. Logic Programming (1999).
8 / 17
◮ terms like f ω and g ω are
considered meaningless
◮ for each meaningless term
t, add rule t → ⊥
◮ meaningless terms are
characterised by a set of axioms f (g(f (g(. . . )))) f ω g ω ⊥ B¨
In: Theoretical Computer Science (1997).
Rewriting”. In: J. Funct. Logic Programming (1999).
8 / 17
◮ Alternative characterisation of B¨
◮ Changes the notion of convergence instead of
adding rules (uses a partial order instead of a metric)
In: LMCS (2014).
9 / 17
◮ Alternative characterisation of B¨
◮ Changes the notion of convergence instead of
adding rules (uses a partial order instead of a metric)
+ less ad hoc + no need for infinitely many reduction rules
terms (namely: root-active terms)
In: LMCS (2014).
9 / 17
R = {a → g(a)} f a
10 / 17
R = {a → g(a)} f a
10 / 17
R = {a → g(a)} f a f g a
10 / 17
R = {a → g(a)} f a f g a
10 / 17
R = {a → g(a)} f a f g a f g g a
10 / 17
R = {a → g(a)} f a f g a f g g a
10 / 17
R = {a → g(a)} f a f g a f g g a f g g g a
10 / 17
R = {a → g(a)} f a f g a f g g a f g g g a f g g g g a
10 / 17
R = {a → g(a)} f a f g a f g g a f g g g a f g g g g a
10 / 17
R = {a → g(a)} f (a) ։ω
R f (g ω)
f a f g a f g g a f g g g a f g g g g a
10 / 17
R =
h(x) → h(g(x)) f a h b
11 / 17
R =
h(x) → h(g(x)) f a h b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b f g a h g g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b f g a h g g b f g g a h g g b
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b f g a h g g b f g g a h g g b . . .
11 / 17
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b f g a h g g b f g g a h g g b . . .
11 / 17
f a h b f a h g b f g a h g b f g a h g g b f g g a h g g b . . . f g g a h g g b
12 / 17
f a h b f a h g b f g a h g b f g a h g g b f g g a h g g b . . . f g g a h g g b f g g eventually stable:
12 / 17
f a h b f a h g b f g a h g b f g a h g g b f g g a h g g b . . . f g g a h g g b f g g ⊥ p-converges to
12 / 17
property metric B¨
compression ✔ ✔
✔ ✔ developments ✘ ✔
✘ ✔
✘ ✔
13 / 17
property metric B¨
compression ✔ ✔ ✔
✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ✔ ✔
13 / 17
property metric B¨
compression ✔ ✔ ✔
✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ✔ ✔
If R is an orthogonal TRS and B the B¨
extension of R (w.r.t. root-active terms), then s ։
p R t
iff s ։
m B t.
13 / 17
property metric B¨
compression ✔ ? ✔
✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ? ?
14 / 17
property metric B¨
compression ✔ ? ✔
✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ? ?
modulo bisim. ✘ ✔ ✔
14 / 17
property metric B¨
compression ✔ ? ✔
✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ? ?
modulo bisim. ✘ ✔ ✔
If R is an orth. GRS and B the B¨
R (w.r.t. root-active term graphs), then g ։
p R h
iff g ։
m B h.
14 / 17
For every left-linear, left-finite GRS R we have g h
p
s U (·) U (R) R
In: RTA. 2012.
15 / 17
For every left-linear, left-finite GRS R we have g h
p
s U (·) U (R) R t
p
U (·)
In: RTA. 2012.
15 / 17
For every left-linear, left-finite GRS R we have g h
p
s U (·) U (R) R t
p
U (·)
s t
p
g U (·) U (R) R
In: RTA. 2012.
15 / 17
For every left-linear, left-finite GRS R we have g h
p
s U (·) U (R) R t
p
U (·)
s t
p
g U (·) U (R) R t′ h
p
U (·)
p
In: RTA. 2012.
15 / 17
For every left-linear, left-finite GRS R we have g h
B
s U (·) U (R) R t
B
U (·)
s t
B
g U (·) U (R) R t′ h
B
U (·)
B
In: RTA. 2012.
15 / 17
Some Observations ◮ Term graphs can be messy
◮ Very operational style of term graph rewriting ◮ B¨
◮ But: sharing simplifies some things
◮ Reduction produces no duplication ◮ Residuals & developments are easier 16 / 17
Some Observations ◮ Term graphs can be messy
◮ Very operational style of term graph rewriting ◮ B¨
◮ But: sharing simplifies some things
◮ Reduction produces no duplication ◮ Residuals & developments are easier
g
l
x f
r
ρ: g c f c ρ
16 / 17
Some Observations ◮ Term graphs can be messy
◮ Very operational style of term graph rewriting ◮ B¨
◮ But: sharing simplifies some things
◮ Reduction produces no duplication ◮ Residuals & developments are easier
◮ Weak convergence is even weirder than on terms:
16 / 17
Some Observations ◮ Term graphs can be messy
◮ Very operational style of term graph rewriting ◮ B¨
◮ But: sharing simplifies some things
◮ Reduction produces no duplication ◮ Residuals & developments are easier
◮ Weak convergence is even weirder than on terms:
f c c f c f c c f c f c c
16 / 17
◮ Infinitary confluence for term graphs ◮ Coinductive definition of infinitary term graph
rewriting
◮ Axiomatic account of meaningless term graphs ◮ Partial-order reduction corresponding to B¨
reductions other than root-active terms
17 / 17
Patrick Bahr
IT University of Copenhagen
based on the ‘usual’ complete metric space on terms d(s, t) = 2−n n = depth of the shallowest discrepancy of s and t
18 / 17
based on the ‘usual’ complete metric space on terms d(s, t) = 2−n n = depth of the shallowest discrepancy of s and t
(a.k.a. strong convergence)
◮ convergence in the metric space, and ◮ rewrite rules are applied (eventually) at
increasingly large depth
18 / 17
based on the ‘usual’ complete metric space on terms d(s, t) = 2−n n = depth of the shallowest discrepancy of s and t
(a.k.a. strong convergence)
◮ convergence in the metric space, and ◮ rewrite rules are applied (eventually) at
increasingly large depth
rewrite rules are applied tends to infinity
18 / 17
◮ partial terms: terms with additional constant ⊥ ◮ partial order ≤⊥ reads as: “is less defined than” ◮ ≤⊥ is a complete semilattice
(= cpo + glbs of non-empty sets)
19 / 17
◮ partial terms: terms with additional constant ⊥ ◮ partial order ≤⊥ reads as: “is less defined than” ◮ ≤⊥ is a complete semilattice
(= cpo + glbs of non-empty sets)
lim infι→α tι =
β<α
19 / 17
◮ partial terms: terms with additional constant ⊥ ◮ partial order ≤⊥ reads as: “is less defined than” ◮ ≤⊥ is a complete semilattice
(= cpo + glbs of non-empty sets)
lim infι→α tι =
β<α
◮ intuition: eventual persistence of nodes in the tree ◮ strong convergence: limit inferior of the contexts
19 / 17
Depth of a node = length of a shortest path from the root to the node.
20 / 17
Depth of a node = length of a shortest path from the root to the node.
The truncation g†d is obtained from g by
◮ relabelling all nodes at depth d with ⊥, and ◮ removing all nodes that thus become
unreachable from the root.
20 / 17
Depth of a node = length of a shortest path from the root to the node.
The truncation g†d is obtained from g by
◮ relabelling all nodes at depth d with ⊥, and ◮ removing all nodes that thus become
unreachable from the root.
d(g, h) = 2−n Where n = maximum depth d s.t. g†d ∼ = h†d.
20 / 17
◮ homomorphism condition suspended on
⊥-nodes
◮ allow mapping of ⊥-nodes to arbitrary nodes
21 / 17
◮ homomorphism condition suspended on
⊥-nodes
◮ allow mapping of ⊥-nodes to arbitrary nodes
For all terms s, t: s ≤⊥ t iff ∃φ: s →⊥ t
21 / 17
◮ homomorphism condition suspended on
⊥-nodes
◮ allow mapping of ⊥-nodes to arbitrary nodes
For all terms s, t: s ≤⊥ t iff ∃φ: s →⊥ t
For all term graphs g, h, let g ≤⊥ h iff there is some φ: g →⊥ h.
21 / 17
R = { n(x, y) → n + 1(x, y) | n ∈ N }.
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
22 / 17
R = { n(x, y) → n + 1(x, y) | n ∈ N }. 1 1 1 2 1 2
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
22 / 17
R = { n(x, y) → n + 1(x, y) | n ∈ N }. 1 1 1 2 1 2 1 2 2 1 2 2
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
22 / 17
R = { n(x, y) → n + 1(x, y) | n ∈ N }. 1 1 1 2 1 2 1 2 2 1 2 2 ? ?
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
22 / 17
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s
23 / 17
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s Reductions: from
23 / 17
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s Reductions: from :: from s
23 / 17
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s Reductions: from :: from s :: :: s from s
23 / 17
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s Reductions: from :: from s :: :: s from s :: :: s : s
23 / 17