B¨
- hm Reduction for
Terms and Term Graphs
Confluence in Infinitary Rewriting Patrick Bahr
IT University of Copenhagen
B ohm Reduction for Terms and Term Graphs Confluence in Infinitary - - PowerPoint PPT Presentation
B ohm Reduction for Terms and Term Graphs Confluence in Infinitary Rewriting Patrick Bahr IT University of Copenhagen Infinitary Term Rewriting Assign outcome to (well-formed) infinite reductions. 1 / 32 Infinitary Term Rewriting Assign
Confluence in Infinitary Rewriting Patrick Bahr
IT University of Copenhagen
Assign outcome to (well-formed) infinite reductions.
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x))
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x)) from(0)
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x)) from(0) → 0 :: from(1)
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x)) from(0) → 0 :: from(1) → 0 :: 1 :: from(2)
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x)) from(0) → 0 :: from(1) → 0 :: 1 :: from(2) → 0 :: 1 :: 2 :: from(3)
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x)) from(0) → 0 :: from(1) → 0 :: 1 :: from(2) → 0 :: 1 :: 2 :: from(3) → 0 :: 1 :: 2 :: 3 :: from(4)
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x)) from(0) → 0 :: from(1) → 0 :: 1 :: from(2) → 0 :: 1 :: 2 :: from(3) → 0 :: 1 :: 2 :: 3 :: from(4) → . . .
1 / 32
Assign outcome to (well-formed) infinite reductions.
from(x) → x :: from(s(x)) from(0) → 0 :: from(1) → 0 :: 1 :: from(2) → 0 :: 1 :: 2 :: from(3) → 0 :: 1 :: 2 :: 3 :: from(4) → . . . intuitively this converges to the infinite list 0 :: 1 :: 2 :: 3 :: 4 :: 5 :: . . . .
1 / 32
t t1 t2
2 / 32
t t1 t2 t′
2 / 32
t t1 t2 t′ infinite reductions
2 / 32
t t1 t2 t′ infinite reductions
◮ orthogonal term rewriting systems ◮ lambda calculus
2 / 32
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g f (g(f (g(f (g(. . . ))))))
3 / 32
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g
3 / 32
for Orthogonal Term Rewriting Systems
f (x) → x g(x) → x f g f g f g
3 / 32
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)
3 / 32
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)
3 / 32
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)
3 / 32
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)
3 / 32
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
3 / 32
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 ω
3 / 32
based on the ‘usual’ complete metric space on terms d(s, t) = 2−n n = depth of the shallowest discrepancy of s and t
4 / 32
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
4 / 32
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
4 / 32
from from(x) → x : from(s(x))
5 / 32
from : from 1 from(x) → x : from(s(x))
5 / 32
from : : 1 from 2 from(x) → x : from(s(x))
5 / 32
1 level from : : 1 from 2 from(x) → x : from(s(x))
5 / 32
1 level from : : 1 : 2 from 3 from(x) → x : from(s(x))
5 / 32
2 levels from : : 1 : 2 from 3 from(x) → x : from(s(x))
5 / 32
2 levels from : : 1 : 2 : 3 from 4 from(x) → x : from(s(x))
5 / 32
3 levels from : : 1 : 2 : 3 from 4 from(x) → x : from(s(x))
5 / 32
3 levels from : : 1 : 2 : 3 : 4 from(x) → x : from(s(x))
5 / 32
from : : 1 : 2 : 3 : 4 from(x) → x : from(s(x))
5 / 32
f (g(f (g(. . . )))) f ω g ω t
6 / 32
f (g(f (g(. . . )))) f ω g ω t
Disallow systems with more than one collapsing rule (i.e. rules of the form t → x)
6 / 32
f (g(f (g(. . . )))) f ω g ω t
Disallow systems with more than one collapsing rule (i.e. rules of the form t → x)
Extend the reduction system so that f ω ։ t և g ω
6 / 32
f (g(f (g(. . . )))) f ω g ω t
Disallow systems with more than one collapsing rule (i.e. rules of the form t → x)
Extend the reduction system so that f ω ։ t և g ω
6 / 32
◮ terms like f ω and g ω are
considered meaningless
◮ for each meaningless term
t, add rule t → ⊥
In: Theoretical Computer Science (1997).
Rewriting”. In: J. Funct. Logic Programming (1999).
7 / 32
◮ terms like f ω and g ω are
considered meaningless
◮ for each meaningless term
t, add rule t → ⊥ f (g(f (g(. . . )))) f ω g ω
In: Theoretical Computer Science (1997).
Rewriting”. In: J. Funct. Logic Programming (1999).
7 / 32
◮ terms like f ω and g ω are
considered meaningless
◮ for each meaningless term
t, add rule t → ⊥ f (g(f (g(. . . )))) f ω g ω ⊥
In: Theoretical Computer Science (1997).
Rewriting”. In: J. Funct. Logic Programming (1999).
7 / 32
◮ terms like f ω and g ω are
considered meaningless
◮ for each meaningless term
t, add rule t → ⊥ f (g(f (g(. . . )))) f ω g ω ⊥ B¨
In: Theoretical Computer Science (1997).
Rewriting”. In: J. Funct. Logic Programming (1999).
7 / 32
◮ B¨
◮ undefined elements4
1984.
In: Journal
8 / 32
◮ B¨
◮ undefined elements4
◮ terms that have no information content ◮ because they cannot be distinguished from one
another
1984.
In: Journal
8 / 32
A set of terms U is called meaningless if it satisfies a number of axioms.5,6
t ∈ U.
U
↔ t, then s ∈ U if and only if t ∈ U.
undefined”. In: Theoretical Aspects of Computer Software. 1994.
Rewriting”. In: J. Funct. Logic Programming (1999).
9 / 32
◮ Let R be an orthogonal TRS, and U a set of
meaningless terms.
◮ Define B = R ∪ {t → ⊥ | t ∈ U⊥ \ {⊥}}
10 / 32
◮ Let R be an orthogonal TRS, and U a set of
meaningless terms.
◮ Define B = R ∪ {t → ⊥ | t ∈ U⊥ \ {⊥}}
◮ B is infinitarily confluent,
i.e. t1 ևB t ։B t2 implies t1 ։B t′ ևB t2.
◮ B is infinitarily normalising, i.e. for each term t
there is a reduction t ։B t′ to a normal form.
10 / 32
◮ Let R be an orthogonal TRS, and U a set of
meaningless terms.
◮ Define B = R ∪ {t → ⊥ | t ∈ U⊥ \ {⊥}}
◮ B is infinitarily confluent,
i.e. t1 ևB t ։B t2 implies t1 ։B t′ ևB t2.
◮ B is infinitarily normalising, i.e. for each term t
there is a reduction t ։B t′ to a normal form.
Each term has a unique infinitary normal form in B (called B¨
10 / 32
◮ Alternative characterisation of B¨
◮ Changes the notion of convergence instead of
adding rules
In: Logical Methods in Computer Science (2014).
11 / 32
◮ Alternative characterisation of B¨
◮ Changes the notion of convergence instead of
adding rules
+ less ad hoc + no need for infinitely many reduction rules
terms
In: Logical Methods in Computer Science (2014).
11 / 32
R = {a → g(a)} f a
12 / 32
R = {a → g(a)} f a
12 / 32
R = {a → g(a)} f a f g a
12 / 32
R = {a → g(a)} f a f g a
12 / 32
R = {a → g(a)} f a f g a f g g a
12 / 32
R = {a → g(a)} f a f g a f g g a
12 / 32
R = {a → g(a)} f a f g a f g g a f g g g a
12 / 32
R = {a → g(a)} f a f g a f g g a f g g g a f g g g g a
12 / 32
R = {a → g(a)} f a f g a f g g a f g g g a f g g g g a
12 / 32
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
12 / 32
R =
h(x) → h(g(x)) f a h b
13 / 32
R =
h(x) → h(g(x)) f a h b
13 / 32
R =
h(x) → h(g(x)) f a h b f a h g b
13 / 32
R =
h(x) → h(g(x)) f a h b f a h g b
13 / 32
R =
h(x) → h(g(x)) f a h b f a h g b
13 / 32
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b
13 / 32
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b
13 / 32
R =
h(x) → h(g(x)) f a h b f a h g b f g a h g b
13 / 32
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
13 / 32
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
13 / 32
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 . . .
13 / 32
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 . . .
13 / 32
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
14 / 32
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:
14 / 32
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
14 / 32
◮ partial terms: terms with additional constant ⊥ ◮ partial order ≤⊥ reads as: “is less defined than”
◮ ⊥ ≤⊥ t, ◮ s ≤⊥ t =
⇒ f (s) ≤⊥ f (t)
◮ e.g. f (⊥, g(x)) ≤⊥ f (y, g(x)) ◮ ≤⊥ is a complete semilattice
(= cpo + glbs of non-empty sets)
15 / 32
lim infι→α tι =
β<α
16 / 32
lim infι→α tι =
β<α
◮ intuition: eventual persistence of nodes in the tree ◮ strong convergence: limit inferior of the contexts
16 / 32
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
17 / 32
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:
17 / 32
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
17 / 32
property metric B¨
compression ✔ ✔ finite approx. ✔ ✔ developments ✘ ✔
✘ ✔
✘ ✔
18 / 32
property metric B¨
compression ✔ ✔ ✔ finite approx. ✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ✔ ✔
18 / 32
If R is an orthogonal TRS and s, t total terms, then s ։
p R t
iff s ։
m R t.
19 / 32
If R is an orthogonal TRS and s, t total terms, then s ։
p R t
iff s ։
m R t.
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.
19 / 32
f (g(a), h(g(a), a))
20 / 32
f (g(a), h(g(a), a)) f g a h g a a
20 / 32
f (g(a), h(g(a), a)) f g a h g a a f g a h
20 / 32
f (g(a), h(g(a), a)) f g a h g a a f g a h unravel
20 / 32
f g a h g a a f g a h a → b unravel
20 / 32
f g a h g a a f g b h a → b unravel
20 / 32
f g b h g b b f g b h a → b unravel
20 / 32
f g b h g b b f g b h
20 / 32
f g b h g b f g b h g b f g b h unravel
20 / 32
f g b h g b f g b h g b f g b h b → c unravel
20 / 32
f g b h g b f g b h g b f g c h b → c unravel
20 / 32
f g c h g c f g c h g c f g c h b → c unravel
20 / 32
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).
21 / 32
For every left-linear, left-finite GRS R we have g h
∗
s U (·) U (R) R t
m
U (·)
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
21 / 32
For every left-linear, left-finite GRS R we have g h
∗
s U (·) U (R) R t
m
U (·)
s t
regular
g U (·) U (R) R
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
21 / 32
For every left-linear, left-finite GRS R we have g h
∗
s U (·) U (R) R t
m
U (·)
s t
regular
g U (·) U (R) R h
∗
U (·)
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
21 / 32
For every left-linear, left-finite GRS R we have g h
∗
s U (·) U (R) R t
m
U (·)
s t
regular
g U (·) U (R) R h
∗
U (·)
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
21 / 32
For every left-linear, left-finite GRS R we have g h
∗
s U (·) U (R) R t
m
U (·)
s t
regular
g U (·) U (R) R t′ h
∗
U (·)
regular
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
21 / 32
◮ A common formalism
◮ study correspondences between infinitary TRSs and
finitary GRSs
letrec”. In: Annals of Pure and Applied Logic (2002).
Letrec”. In: ICFP. 2014.
22 / 32
◮ 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.
22 / 32
◮ 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
◮ infinitary lambda calculi with letrec9,10
◮ 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.
22 / 32
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s
23 / 32
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s Reductions: from
23 / 32
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s Reductions: from : from s
23 / 32
Term graph rule for from(x) → x :: from(s(x)) from
l
x ::
r
from s Reductions: from : from s : : s from s
23 / 32
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 / 32
Term graph rules for a :: x → b :: a :: x ::
l
a x ::
r
b :: a ρ1:
24 / 32
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
24 / 32
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
24 / 32
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
24 / 32
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
24 / 32
g h
m
s U (·) U (R) R
In: RTA. 2012.
25 / 32
g h
m
s U (·) U (R) R t
m
U (·)
In: RTA. 2012.
25 / 32
g h
m
s U (·) U (R) R t
m
U (·)
s t
m
g U (·) U (R) R
In: RTA. 2012.
25 / 32
g h
m
s U (·) U (R) R t
m
U (·)
s t
m
g U (·) U (R) R h
m
U (·)
In: RTA. 2012.
25 / 32
g h
m
s U (·) U (R) R t
m
U (·)
s t
m
g U (·) U (R) R h
m
U (·)
In: RTA. 2012.
25 / 32
g h
m
s U (·) U (R) R t
m
U (·)
s t
m
g U (·) U (R) R t′ h
m
U (·)
m
In: RTA. 2012.
25 / 32
g h
m
s U (·) U (R) R t
m
U (·)
s t
m
g U (·) U (R) R t′ h
m
U (·)
m
In: RTA. 2012.
25 / 32
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.
25 / 32
R = { n(x, y) → n + 1(x, y) | n ∈ N }.
rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).
26 / 32
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).
26 / 32
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).
26 / 32
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).
26 / 32
for Orthogonal Term (Graph) Rewriting Systems
f (x) → x g(x) → x f g f g f g g g g f f f g ω f ω
27 / 32
property metric B¨
compression ✔ ? ✔ soundness ✔ ✔ ✔ completeness ✘ ✔ ✔
✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ? ?
In: FSCD. 2017.
28 / 32
property metric B¨
compression ✔ ? ✔ soundness ✔ ✔ ✔ completeness ✘ ✔ ✔
✔ ✔ ✔ developments ✘ ✔ ✔
✘ ✔ ✔
✘ ? ?
modulo bisim. ✘ ✔ ✔
In: FSCD. 2017.
28 / 32
If R is an orthogonal GRS and g, h total term graphs, then g ։
p R h
iff g ։
m R h.
In: FSCD. 2017.
29 / 32
If R is an orthogonal GRS and g, h total term graphs, then g ։
p R h
iff g ։
m R h.
If R is an orthogonal GRS and B the B¨
extension of R (w.r.t. root-active term graphs), then g ։
p R h
iff g ։
m B h.
In: FSCD. 2017.
29 / 32
Depth of a node = length of a shortest path from the root to the node.
30 / 32
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.
30 / 32
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.
30 / 32
◮ homomorphism condition suspended on
⊥-nodes
◮ allow mapping of ⊥-nodes to arbitrary nodes
31 / 32
◮ homomorphism condition suspended on
⊥-nodes
◮ allow mapping of ⊥-nodes to arbitrary nodes
For all terms s, t: s ≤⊥ t iff ∃φ: s →⊥ t
31 / 32
◮ 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.
31 / 32
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 32 / 32
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 ρ
32 / 32
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:
32 / 32
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
32 / 32
Confluence in Infinitary Rewriting Patrick Bahr
IT University of Copenhagen