B ohm Reduction for Terms and Term Graphs Confluence in Infinitary - - PowerPoint PPT Presentation

b ohm reduction for terms and term graphs
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

  • hm Reduction for

Terms and Term Graphs

Confluence in Infinitary Rewriting Patrick Bahr

IT University of Copenhagen

slide-2
SLIDE 2

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

1 / 32

slide-3
SLIDE 3

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

from(x) → x :: from(s(x))

1 / 32

slide-4
SLIDE 4

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

from(x) → x :: from(s(x)) from(0)

1 / 32

slide-5
SLIDE 5

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

from(x) → x :: from(s(x)) from(0) → 0 :: from(1)

1 / 32

slide-6
SLIDE 6

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

from(x) → x :: from(s(x)) from(0) → 0 :: from(1) → 0 :: 1 :: from(2)

1 / 32

slide-7
SLIDE 7

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

from(x) → x :: from(s(x)) from(0) → 0 :: from(1) → 0 :: 1 :: from(2) → 0 :: 1 :: 2 :: from(3)

1 / 32

slide-8
SLIDE 8

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

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

slide-9
SLIDE 9

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

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

slide-10
SLIDE 10

Infinitary Term Rewriting

Assign outcome to (well-formed) infinite reductions.

Example

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

slide-11
SLIDE 11

Confluence in Infinitary Rewriting

t t1 t2

2 / 32

slide-12
SLIDE 12

Confluence in Infinitary Rewriting

t t1 t2 t′

2 / 32

slide-13
SLIDE 13

Confluence in Infinitary Rewriting

t t1 t2 t′ infinite reductions

2 / 32

slide-14
SLIDE 14

Confluence in Infinitary Rewriting

t t1 t2 t′ infinite reductions

Infinitary Confluence Breaks for

◮ orthogonal term rewriting systems ◮ lambda calculus

2 / 32

slide-15
SLIDE 15

Counter Example

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

slide-16
SLIDE 16

Counter Example

for Orthogonal Term Rewriting Systems

f (x) → x g(x) → x f g f g f g

3 / 32

slide-17
SLIDE 17

Counter Example

for Orthogonal Term Rewriting Systems

f (x) → x g(x) → x f g f g f g

3 / 32

slide-18
SLIDE 18

Counter Example

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

slide-19
SLIDE 19

Counter Example

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

slide-20
SLIDE 20

Counter Example

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

slide-21
SLIDE 21

Counter Example

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

slide-22
SLIDE 22

Counter Example

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

slide-23
SLIDE 23

Counter Example

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

slide-24
SLIDE 24

Outline

  • 1. Infinitary Term Rewriting
  • 2. B¨
  • hm Reduction
  • 3. Partial Order Infinitary Rewriting
  • 4. Term Graph Rewriting
slide-25
SLIDE 25

Infinitary Term Rewriting

slide-26
SLIDE 26

The Metric Model of Infinitary Rewriting

Convergence

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

slide-27
SLIDE 27

The Metric Model of Infinitary Rewriting

Convergence

based on the ‘usual’ complete metric space on terms d(s, t) = 2−n n = depth of the shallowest discrepancy of s and t

Convergence of reductions

(a.k.a. strong convergence)

◮ convergence in the metric space, and ◮ rewrite rules are applied (eventually) at

increasingly large depth

4 / 32

slide-28
SLIDE 28

The Metric Model of Infinitary Rewriting

Convergence

based on the ‘usual’ complete metric space on terms d(s, t) = 2−n n = depth of the shallowest discrepancy of s and t

Convergence of reductions

(a.k.a. strong convergence)

◮ convergence in the metric space, and ◮ rewrite rules are applied (eventually) at

increasingly large depth

  • convergence of a reduction: depth at which the

rewrite rules are applied tends to infinity

4 / 32

slide-29
SLIDE 29

Example: Convergence of a Reduction

from from(x) → x : from(s(x))

5 / 32

slide-30
SLIDE 30

Example: Convergence of a Reduction

from : from 1 from(x) → x : from(s(x))

5 / 32

slide-31
SLIDE 31

Example: Convergence of a Reduction

from : : 1 from 2 from(x) → x : from(s(x))

5 / 32

slide-32
SLIDE 32

Example: Convergence of a Reduction

1 level from : : 1 from 2 from(x) → x : from(s(x))

5 / 32

slide-33
SLIDE 33

Example: Convergence of a Reduction

1 level from : : 1 : 2 from 3 from(x) → x : from(s(x))

5 / 32

slide-34
SLIDE 34

Example: Convergence of a Reduction

2 levels from : : 1 : 2 from 3 from(x) → x : from(s(x))

5 / 32

slide-35
SLIDE 35

Example: Convergence of a Reduction

2 levels from : : 1 : 2 : 3 from 4 from(x) → x : from(s(x))

5 / 32

slide-36
SLIDE 36

Example: Convergence of a Reduction

3 levels from : : 1 : 2 : 3 from 4 from(x) → x : from(s(x))

5 / 32

slide-37
SLIDE 37

Example: Convergence of a Reduction

3 levels from : : 1 : 2 : 3 : 4 from(x) → x : from(s(x))

5 / 32

slide-38
SLIDE 38

Example: Convergence of a Reduction

from : : 1 : 2 : 3 : 4 from(x) → x : from(s(x))

5 / 32

slide-39
SLIDE 39

  • hm Reduction
slide-40
SLIDE 40

Obtaining Infinitary Confluence

f (g(f (g(. . . )))) f ω g ω t

6 / 32

slide-41
SLIDE 41

Obtaining Infinitary Confluence

f (g(f (g(. . . )))) f ω g ω t

Option 1

Disallow systems with more than one collapsing rule (i.e. rules of the form t → x)

6 / 32

slide-42
SLIDE 42

Obtaining Infinitary Confluence

f (g(f (g(. . . )))) f ω g ω t

Option 1

Disallow systems with more than one collapsing rule (i.e. rules of the form t → x)

Option 2

Extend the reduction system so that f ω ։ t և g ω

6 / 32

slide-43
SLIDE 43

Obtaining Infinitary Confluence

f (g(f (g(. . . )))) f ω g ω t

Option 1

Disallow systems with more than one collapsing rule (i.e. rules of the form t → x)

Option 2

Extend the reduction system so that f ω ։ t և g ω

6 / 32

slide-44
SLIDE 44

  • hm Reduction

Idea

◮ terms like f ω and g ω are

considered meaningless

◮ for each meaningless term

t, add rule t → ⊥

  • 1R. Kennaway et al. “Infinitary lambda calculus”.

In: Theoretical Computer Science (1997).

  • 2R. Kennaway, V. van Oostrom, and F.-J. de Vries. “Meaningless Terms in

Rewriting”. In: J. Funct. Logic Programming (1999).

7 / 32

slide-45
SLIDE 45

  • hm Reduction

Idea

◮ terms like f ω and g ω are

considered meaningless

◮ for each meaningless term

t, add rule t → ⊥ f (g(f (g(. . . )))) f ω g ω

  • 1R. Kennaway et al. “Infinitary lambda calculus”.

In: Theoretical Computer Science (1997).

  • 2R. Kennaway, V. van Oostrom, and F.-J. de Vries. “Meaningless Terms in

Rewriting”. In: J. Funct. Logic Programming (1999).

7 / 32

slide-46
SLIDE 46

  • hm Reduction

Idea

◮ terms like f ω and g ω are

considered meaningless

◮ for each meaningless term

t, add rule t → ⊥ f (g(f (g(. . . )))) f ω g ω ⊥

  • 1R. Kennaway et al. “Infinitary lambda calculus”.

In: Theoretical Computer Science (1997).

  • 2R. Kennaway, V. van Oostrom, and F.-J. de Vries. “Meaningless Terms in

Rewriting”. In: J. Funct. Logic Programming (1999).

7 / 32

slide-47
SLIDE 47

  • hm Reduction

Idea

◮ terms like f ω and g ω are

considered meaningless

◮ for each meaningless term

t, add rule t → ⊥ f (g(f (g(. . . )))) f ω g ω ⊥ B¨

  • hm reduction = infinitary rewriting with ⊥-rules
  • 1R. Kennaway et al. “Infinitary lambda calculus”.

In: Theoretical Computer Science (1997).

  • 2R. Kennaway, V. van Oostrom, and F.-J. de Vries. “Meaningless Terms in

Rewriting”. In: J. Funct. Logic Programming (1999).

7 / 32

slide-48
SLIDE 48

Meaningless Terms

Origins in lambda calculus

◮ B¨

  • hm trees3

◮ undefined elements4

  • 3H. P. Barendregt. The Lambda Calculus: Its Syntax and Semantics.

1984.

  • 4H. P. Barendregt. “Representing ’undefined’ in the lambda calculus”.

In: Journal

  • f Functional Programming 2 (1992), pp. 367–374.

8 / 32

slide-49
SLIDE 49

Meaningless Terms

Origins in lambda calculus

◮ B¨

  • hm trees3

◮ undefined elements4

Intuition

◮ terms that have no information content ◮ because they cannot be distinguished from one

another

  • 3H. P. Barendregt. The Lambda Calculus: Its Syntax and Semantics.

1984.

  • 4H. P. Barendregt. “Representing ’undefined’ in the lambda calculus”.

In: Journal

  • f Functional Programming 2 (1992), pp. 367–374.

8 / 32

slide-50
SLIDE 50

Axiomatic Characterisation

A set of terms U is called meaningless if it satisfies a number of axioms.5,6

  • 1. U is closed under rewriting.
  • 2. If a redex t overlaps a subterm in U, then

t ∈ U.

  • 3. U is closed under substitution. (for λ-calculus)
  • 4. If t root-active/hypercollapsing, then t ∈ U.
  • 5. If s

U

↔ t, then s ∈ U if and only if t ∈ U.

  • 5Z. M. Ariola et al. “Syntactic definitions of undefined: On defining the

undefined”. In: Theoretical Aspects of Computer Software. 1994.

  • 6R. Kennaway, V. van Oostrom, and F.-J. de Vries. “Meaningless Terms in

Rewriting”. In: J. Funct. Logic Programming (1999).

9 / 32

slide-51
SLIDE 51

Properties of B¨

  • hm Reduction

◮ Let R be an orthogonal TRS, and U a set of

meaningless terms.

◮ Define B = R ∪ {t → ⊥ | t ∈ U⊥ \ {⊥}}

10 / 32

slide-52
SLIDE 52

Properties of B¨

  • hm Reduction

◮ Let R be an orthogonal TRS, and U a set of

meaningless terms.

◮ Define B = R ∪ {t → ⊥ | t ∈ U⊥ \ {⊥}}

Theorem

◮ 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

slide-53
SLIDE 53

Properties of B¨

  • hm Reduction

◮ Let R be an orthogonal TRS, and U a set of

meaningless terms.

◮ Define B = R ∪ {t → ⊥ | t ∈ U⊥ \ {⊥}}

Theorem

◮ 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.

Corollary

Each term has a unique infinitary normal form in B (called B¨

  • hm tree).

10 / 32

slide-54
SLIDE 54

Partial Order Infinitary Rewriting

slide-55
SLIDE 55

Partial Order Infinitary Rewriting

◮ Alternative characterisation of B¨

  • hm reduction

◮ Changes the notion of convergence instead of

adding rules

  • 7B. “Partial Order Infinitary Term Rewriting”.

In: Logical Methods in Computer Science (2014).

11 / 32

slide-56
SLIDE 56

Partial Order Infinitary Rewriting

◮ Alternative characterisation of B¨

  • hm reduction

◮ Changes the notion of convergence instead of

adding rules

The Good & The Bad

+ less ad hoc + no need for infinitely many reduction rules

  • captures only a particular set of meaningless

terms

  • 7B. “Partial Order Infinitary Term Rewriting”.

In: Logical Methods in Computer Science (2014).

11 / 32

slide-57
SLIDE 57

Recap: Strong Convergence

R = {a → g(a)} f a

12 / 32

slide-58
SLIDE 58

Recap: Strong Convergence

R = {a → g(a)} f a

12 / 32

slide-59
SLIDE 59

Recap: Strong Convergence

R = {a → g(a)} f a f g a

12 / 32

slide-60
SLIDE 60

Recap: Strong Convergence

R = {a → g(a)} f a f g a

12 / 32

slide-61
SLIDE 61

Recap: Strong Convergence

R = {a → g(a)} f a f g a f g g a

12 / 32

slide-62
SLIDE 62

Recap: Strong Convergence

R = {a → g(a)} f a f g a f g g a

12 / 32

slide-63
SLIDE 63

Recap: Strong Convergence

R = {a → g(a)} f a f g a f g g a f g g g a

12 / 32

slide-64
SLIDE 64

Recap: Strong Convergence

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

slide-65
SLIDE 65

Recap: Strong Convergence

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

slide-66
SLIDE 66

Recap: Strong Convergence

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

slide-67
SLIDE 67

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b

13 / 32

slide-68
SLIDE 68

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b

13 / 32

slide-69
SLIDE 69

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b f a h g b

13 / 32

slide-70
SLIDE 70

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b f a h g b

13 / 32

slide-71
SLIDE 71

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b f a h g b

13 / 32

slide-72
SLIDE 72

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b f a h g b f g a h g b

13 / 32

slide-73
SLIDE 73

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b f a h g b f g a h g b

13 / 32

slide-74
SLIDE 74

Example: Non-Convergence

R =

  • a → g(a)

h(x) → h(g(x)) f a h b f a h g b f g a h g b

13 / 32

slide-75
SLIDE 75

Example: Non-Convergence

R =

  • a → g(a)

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

slide-76
SLIDE 76

Example: Non-Convergence

R =

  • a → g(a)

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

slide-77
SLIDE 77

Example: Non-Convergence

R =

  • a → g(a)

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

slide-78
SLIDE 78

Example: Non-Convergence

R =

  • a → g(a)

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

slide-79
SLIDE 79

Partial Order Convergence

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

slide-80
SLIDE 80

Partial Order Convergence

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

slide-81
SLIDE 81

Partial Order Convergence

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

slide-82
SLIDE 82

How does it work? (I)

Partial order on terms

◮ 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

slide-83
SLIDE 83

How does it work? (II)

Convergence: limit inferior

lim infι→α tι =

β<α

  • β≤ι<α tι

16 / 32

slide-84
SLIDE 84

How does it work? (II)

Convergence: limit inferior

lim infι→α tι =

β<α

  • β≤ι<α tι

◮ intuition: eventual persistence of nodes in the tree ◮ strong convergence: limit inferior of the contexts

  • f the reduction

16 / 32

slide-85
SLIDE 85

Partial Order Convergence

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

slide-86
SLIDE 86

Partial Order Convergence

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

slide-87
SLIDE 87

Partial Order Convergence

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

slide-88
SLIDE 88

Properties of Orthogonal TRS

property metric B¨

  • hm red.

compression ✔ ✔ finite approx. ✔ ✔ developments ✘ ✔

  • inf. confluence

✘ ✔

  • inf. normalisation

✘ ✔

18 / 32

slide-89
SLIDE 89

Properties of Orthogonal TRS

property metric B¨

  • hm red.
  • part. order

compression ✔ ✔ ✔ finite approx. ✔ ✔ ✔ developments ✘ ✔ ✔

  • inf. confluence

✘ ✔ ✔

  • inf. normalisation

✘ ✔ ✔

18 / 32

slide-90
SLIDE 90

Partial Order vs. B¨

  • hm Reduction

Theorem

If R is an orthogonal TRS and s, t total terms, then s ։

p R t

iff s ։

m R t.

19 / 32

slide-91
SLIDE 91

Partial Order vs. B¨

  • hm Reduction

Theorem

If R is an orthogonal TRS and s, t total terms, then s ։

p R t

iff s ։

m R t.

Theorem

If R is an orthogonal TRS and B the B¨

  • hm

extension of R (w.r.t. root-active terms), then s ։

p R t

iff s ։

m B t.

19 / 32

slide-92
SLIDE 92

Term Graph Rewriting

slide-93
SLIDE 93

From Terms to Term Graphs

f (g(a), h(g(a), a))

20 / 32

slide-94
SLIDE 94

From Terms to Term Graphs

f (g(a), h(g(a), a)) f g a h g a a

20 / 32

slide-95
SLIDE 95

From Terms to Term Graphs

f (g(a), h(g(a), a)) f g a h g a a f g a h

20 / 32

slide-96
SLIDE 96

From Terms to Term Graphs

f (g(a), h(g(a), a)) f g a h g a a f g a h unravel

20 / 32

slide-97
SLIDE 97

From Terms to Term Graphs

f g a h g a a f g a h a → b unravel

20 / 32

slide-98
SLIDE 98

From Terms to Term Graphs

f g a h g a a f g b h a → b unravel

20 / 32

slide-99
SLIDE 99

From Terms to Term Graphs

f g b h g b b f g b h a → b unravel

20 / 32

slide-100
SLIDE 100

From Terms to Term Graphs

f g b h g b b f g b h

20 / 32

slide-101
SLIDE 101

From Terms to Term Graphs

f g b h g b f g b h g b f g b h unravel

20 / 32

slide-102
SLIDE 102

From Terms to Term Graphs

f g b h g b f g b h g b f g b h b → c unravel

20 / 32

slide-103
SLIDE 103

From Terms to Term Graphs

f g b h g b f g b h g b f g c h b → c unravel

20 / 32

slide-104
SLIDE 104

From Terms to Term Graphs

f g c h g c f g c h g c f g c h b → c unravel

20 / 32

slide-105
SLIDE 105

Soundness & Completeness

Soundness of finite reductions

For every left-linear, left-finite GRS R we have g h

s U (·) U (R) R

  • 8R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

21 / 32

slide-106
SLIDE 106

Soundness & Completeness

Soundness of finite reductions

For every left-linear, left-finite GRS R we have g h

s U (·) U (R) R t

m

U (·)

  • 8R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

21 / 32

slide-107
SLIDE 107

Soundness & Completeness

Soundness of finite reductions

For every left-linear, left-finite GRS R we have g h

s U (·) U (R) R t

m

U (·)

Completeness property

s t

regular

g U (·) U (R) R

  • 8R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

21 / 32

slide-108
SLIDE 108

Soundness & Completeness

Soundness of finite reductions

For every left-linear, left-finite GRS R we have g h

s U (·) U (R) R t

m

U (·)

Completeness property

s t

regular

g U (·) U (R) R h

U (·)

  • 8R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

21 / 32

slide-109
SLIDE 109

Soundness & Completeness

Soundness of finite reductions

For every left-linear, left-finite GRS R we have g h

s U (·) U (R) R t

m

U (·)

Completeness property

s t

regular

g U (·) U (R) R h

U (·)

  • 8R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

21 / 32

slide-110
SLIDE 110

Soundness & Completeness

Soundness of finite reductions

For every left-linear, left-finite GRS R we have g h

s U (·) U (R) R t

m

U (·)

Completeness property

s t

regular

g U (·) U (R) R t′ h

U (·)

regular

  • 8R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

21 / 32

slide-111
SLIDE 111

Infinitary Term Graph Rewriting

◮ A common formalism

◮ study correspondences between infinitary TRSs and

finitary GRSs

  • 9Z. M. Ariola and S. Blom. “Skew confluence and the lambda calculus with

letrec”. In: Annals of Pure and Applied Logic (2002).

  • 10C. Grabmayer and J. Rochel. “Maximal Sharing in the Lambda Calculus with

Letrec”. In: ICFP. 2014.

22 / 32

slide-112
SLIDE 112

Infinitary Term Graph Rewriting

◮ 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

  • 9Z. M. Ariola and S. Blom. “Skew confluence and the lambda calculus with

letrec”. In: Annals of Pure and Applied Logic (2002).

  • 10C. Grabmayer and J. Rochel. “Maximal Sharing in the Lambda Calculus with

Letrec”. In: ICFP. 2014.

22 / 32

slide-113
SLIDE 113

Infinitary Term Graph Rewriting

◮ 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

  • 9Z. M. Ariola and S. Blom. “Skew confluence and the lambda calculus with

letrec”. In: Annals of Pure and Applied Logic (2002).

  • 10C. Grabmayer and J. Rochel. “Maximal Sharing in the Lambda Calculus with

Letrec”. In: ICFP. 2014.

22 / 32

slide-114
SLIDE 114

Example: Acyclic Sharing

Term graph rule for from(x) → x :: from(s(x)) from

l

x ::

r

from s

23 / 32

slide-115
SLIDE 115

Example: Acyclic Sharing

Term graph rule for from(x) → x :: from(s(x)) from

l

x ::

r

from s Reductions: from

23 / 32

slide-116
SLIDE 116

Example: Acyclic Sharing

Term graph rule for from(x) → x :: from(s(x)) from

l

x ::

r

from s Reductions: from : from s

23 / 32

slide-117
SLIDE 117

Example: Acyclic Sharing

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

slide-118
SLIDE 118

Example: Acyclic Sharing

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

slide-119
SLIDE 119

Example: Cyclic Sharing

Term graph rules for a :: x → b :: a :: x ::

l

a x ::

r

b :: a ρ1:

24 / 32

slide-120
SLIDE 120

Example: Cyclic Sharing

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

slide-121
SLIDE 121

Example: Cyclic Sharing

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

slide-122
SLIDE 122

Example: Cyclic Sharing

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

slide-123
SLIDE 123

Example: Cyclic Sharing

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

slide-124
SLIDE 124

Soundness & Completeness

Soundness

g h

m

s U (·) U (R) R

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-125
SLIDE 125

Soundness & Completeness

Soundness

g h

m

s U (·) U (R) R t

m

U (·)

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-126
SLIDE 126

Soundness & Completeness

Soundness

g h

m

s U (·) U (R) R t

m

U (·)

Completeness property

s t

m

g U (·) U (R) R

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-127
SLIDE 127

Soundness & Completeness

Soundness

g h

m

s U (·) U (R) R t

m

U (·)

Completeness property

s t

m

g U (·) U (R) R h

m

U (·)

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-128
SLIDE 128

Soundness & Completeness

Soundness

g h

m

s U (·) U (R) R t

m

U (·)

Completeness property

s t

m

g U (·) U (R) R h

m

U (·)

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-129
SLIDE 129

Soundness & Completeness

Soundness

g h

m

s U (·) U (R) R t

m

U (·)

Completeness property

s t

m

g U (·) U (R) R t′ h

m

U (·)

m

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-130
SLIDE 130

Soundness & Completeness

Soundness

g h

m

s U (·) U (R) R t

m

U (·)

Completeness property

s t

m

g U (·) U (R) R t′ h

m

U (·)

m

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-131
SLIDE 131

Soundness & Completeness

Soundness

g h

p

s U (·) U (R) R t

p

U (·)

Completeness property

s t

p

g U (·) U (R) R t′ h

p

U (·)

p

  • 11B. “Infinitary Term Graph Rewriting is Simple, Sound and Complete”.

In: RTA. 2012.

25 / 32

slide-132
SLIDE 132

R = { n(x, y) → n + 1(x, y) | n ∈ N }.

  • 12R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

26 / 32

slide-133
SLIDE 133

R = { n(x, y) → n + 1(x, y) | n ∈ N }. 1 1 1 2 1 2

  • 12R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

26 / 32

slide-134
SLIDE 134

R = { n(x, y) → n + 1(x, y) | n ∈ N }. 1 1 1 2 1 2 1 2 2 1 2 2

  • 12R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

26 / 32

slide-135
SLIDE 135

R = { n(x, y) → n + 1(x, y) | n ∈ N }. 1 1 1 2 1 2 1 2 2 1 2 2 ? ?

  • 12R. Kennaway et al. “On the adequacy of graph rewriting for simulating term

rewriting”. In: ACM Transactions on Programming Languages and Systems (1994).

26 / 32

slide-136
SLIDE 136

Confluence Fails

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

slide-137
SLIDE 137

Properties of Orthogonal GRS

property metric B¨

  • hm red.
  • part. order

compression ✔ ? ✔ soundness ✔ ✔ ✔ completeness ✘ ✔ ✔

  • inf. strip lemma

✔ ✔ ✔ developments ✘ ✔ ✔

  • inf. normalisation

✘ ✔ ✔

  • inf. confluence

✘ ? ?

  • 13B. “B¨
  • hm Reduction in Infinitary Term Graph Rewriting Systems”.

In: FSCD. 2017.

28 / 32

slide-138
SLIDE 138

Properties of Orthogonal GRS

property metric B¨

  • hm red.
  • part. order

compression ✔ ? ✔ soundness ✔ ✔ ✔ completeness ✘ ✔ ✔

  • inf. strip lemma

✔ ✔ ✔ developments ✘ ✔ ✔

  • inf. normalisation

✘ ✔ ✔

  • inf. confluence

✘ ? ?

  • inf. confluence

modulo bisim. ✘ ✔ ✔

  • 13B. “B¨
  • hm Reduction in Infinitary Term Graph Rewriting Systems”.

In: FSCD. 2017.

28 / 32

slide-139
SLIDE 139

Partial Order vs. B¨

  • hm Reduction

Theorem

If R is an orthogonal GRS and g, h total term graphs, then g ։

p R h

iff g ։

m R h.

  • 14B. “B¨
  • hm Reduction in Infinitary Term Graph Rewriting Systems”.

In: FSCD. 2017.

29 / 32

slide-140
SLIDE 140

Partial Order vs. B¨

  • hm Reduction

Theorem

If R is an orthogonal GRS and g, h total term graphs, then g ։

p R h

iff g ։

m R h.

Theorem

If R is an orthogonal GRS and B the B¨

  • hm

extension of R (w.r.t. root-active term graphs), then g ։

p R h

iff g ։

m B h.

  • 14B. “B¨
  • hm Reduction in Infinitary Term Graph Rewriting Systems”.

In: FSCD. 2017.

29 / 32

slide-141
SLIDE 141

Metric on Term Graphs

Depth of a node = length of a shortest path from the root to the node.

30 / 32

slide-142
SLIDE 142

Metric on Term Graphs

Depth of a node = length of a shortest path from the root to the node.

Truncation of term graphs

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

slide-143
SLIDE 143

Metric on Term Graphs

Depth of a node = length of a shortest path from the root to the node.

Truncation of term graphs

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.

Metric on term graphs

d(g, h) = 2−n Where n = maximum depth d s.t. g†d ∼ = h†d.

30 / 32

slide-144
SLIDE 144

A Partial Order on Term Graphs – How?

⊥-homomorphisms φ: g →⊥ h

◮ homomorphism condition suspended on

⊥-nodes

◮ allow mapping of ⊥-nodes to arbitrary nodes

31 / 32

slide-145
SLIDE 145

A Partial Order on Term Graphs – How?

⊥-homomorphisms φ: g →⊥ h

◮ homomorphism condition suspended on

⊥-nodes

◮ allow mapping of ⊥-nodes to arbitrary nodes

Proposition

For all terms s, t: s ≤⊥ t iff ∃φ: s →⊥ t

31 / 32

slide-146
SLIDE 146

A Partial Order on Term Graphs – How?

⊥-homomorphisms φ: g →⊥ h

◮ homomorphism condition suspended on

⊥-nodes

◮ allow mapping of ⊥-nodes to arbitrary nodes

Proposition

For all terms s, t: s ≤⊥ t iff ∃φ: s →⊥ t

Definition

For all term graphs g, h, let g ≤⊥ h iff there is some φ: g →⊥ h.

31 / 32

slide-147
SLIDE 147

Working with Term Graphs

Some Observations ◮ Term graphs can be messy

◮ Very operational style of term graph rewriting ◮ B¨

  • hm reduction is not left-linear

◮ But: sharing simplifies some things

◮ Reduction produces no duplication ◮ Residuals & developments are easier 32 / 32

slide-148
SLIDE 148

Working with Term Graphs

Some Observations ◮ Term graphs can be messy

◮ Very operational style of term graph rewriting ◮ B¨

  • hm reduction is not left-linear

◮ But: sharing simplifies some things

◮ Reduction produces no duplication ◮ Residuals & developments are easier

Example (g(x) → f (x, x))

g

l

x f

r

ρ: g c f c ρ

32 / 32

slide-149
SLIDE 149

Working with Term Graphs

Some Observations ◮ Term graphs can be messy

◮ Very operational style of term graph rewriting ◮ B¨

  • hm reduction is not left-linear

◮ But: sharing simplifies some things

◮ Reduction produces no duplication ◮ Residuals & developments are easier

◮ Weak convergence is even weirder than on terms:

32 / 32

slide-150
SLIDE 150

Working with Term Graphs

Some Observations ◮ Term graphs can be messy

◮ Very operational style of term graph rewriting ◮ B¨

  • hm reduction is not left-linear

◮ 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

slide-151
SLIDE 151

  • hm Reduction for

Terms and Term Graphs

Confluence in Infinitary Rewriting Patrick Bahr

IT University of Copenhagen