Disproving Confluence of Term Rewriting Systems by Interpretation - - PowerPoint PPT Presentation

disproving confluence of term rewriting systems by
SMART_READER_LITE
LIVE PREVIEW

Disproving Confluence of Term Rewriting Systems by Interpretation - - PowerPoint PPT Presentation

Disproving Confluence of Term Rewriting Systems by Interpretation and Ordering FroCoS 2013 Takahito Aoto (Tohoku University) Outline 1. Backgrounds: TRS and Confluence 2. Backgrounds: Proving (Non)-Confluence 3. Proving Non-Joinability by


slide-1
SLIDE 1

Disproving Confluence

  • f Term Rewriting Systems

by Interpretation and Ordering

FroCoS 2013 Takahito Aoto (Tohoku University)

slide-2
SLIDE 2

Outline

  • 1. Backgrounds: TRS and Confluence
  • 2. Backgrounds: Proving (Non)-Confluence
  • 3. Proving Non-Joinability by Interpretation
  • 4. Proving Non-Joinability by Ordering
  • 5. Implementation and Experiments
slide-3
SLIDE 3

Term Rewriting Systems (TRSs)

Example: TRS modelling addition of natural numbers R = +(0, y) → y +(s(x), y) → s(+(x, y))

  • Natural

numbers 0, 1, 2, . . . are represented by 0, s(0), s(s(0)), . . ..

  • Computational model:

Equational logic + Functional programs

  • Automated theorem proving: KB-completion, etc.
  • Automated verification: Termination, Confluence, etc.

1/24

slide-4
SLIDE 4

R = +(0, y) → y +(s(x), y) → s(+(x, y))

  • Computation by reduction (“2 + 2 = 4”)

+(s(s(0)), s(s(0))) →R s(+(s(0), s(s(0)))) →R s(s(+(0, s(s(0))))) →R s(s(s(s(0)))) normal form LHS patterns of rewrite rules are replaced by the corresponding RHS patterns.

2/24

slide-5
SLIDE 5

R = +(0, y) → y +(s(x), y) → s(+(x, y))

  • Computation by reduction (“2 + 2 = 4”)

+(s(s(0)), s(s(0))) →R s(+(s(0), s(s(0)))) →R s(s(+(0, s(s(0))))) →R s(s(s(s(0)))) normal form LHS patterns of rewrite rules are replaced by the corresponding RHS patterns.

t0

→R tn

def

⇔ t0 →R t1 →R · · · →R tn

2/24

slide-6
SLIDE 6

Confluence (Church-Rosser)

t t1 t2 s ∗ ∗ ∗ ∗

3/24

slide-7
SLIDE 7

Confluence (Church-Rosser)

t t1 t2 s ∗ ∗ ∗ ∗ A TRS R is confluent if

←R ◦

→R ⊆

→R ◦

←R , i.e. any two terms obtained from one term by reduction are joinable by reduction.

3/24

slide-8
SLIDE 8

Confluence (Church-Rosser)

+(s(0), +(s(0), s(0))) +(s(0), s(+(0, s(0)))) +(s(0), s(s(0))) s(+(0, +(0, s(0))) s(+(s(0), s(0))) s(s(s(0))) ∗ ∗

4/24

slide-9
SLIDE 9

R = +(0, y) → y +(s(x), y) → s(+(x, y))

  • Confluent

R =          f(x) → g(x) g(x) → f(x) f(x) → a g(x) → b          Not Confluent

5/24

slide-10
SLIDE 10

(Non-)Confluence Criteria

Long history of development... Decidable classes:

Terminating [Knuth&Bendix, 1970], Ground [Oyamaguchi, 1987; Dauchet et al., 1990], Right-ground [Kaiser, 2005; Tiwari et al., 2005], Right-linear shallow [Tiwari, 2002; Godoy et al, 2003; Godoy&Tiwari, 2005].

Critical Pair Conditions for Left-linear TRSs:

Orthogonal [Rosen, 1973], Left-linear development closed [Huet, 1980; Toyama, 1988; van Oostrom, 1997], Linear strongly closed [Huet, 1980], Parallel critical pairs [Toyama, 1981], Simultaneous critical pairs [Okui, 1998], Upside-parallel-closed or Outside-closed [Oyamaguchi&Ohta, 2004].

Modularity:

Persistency [Toyama,1987; Aoto&Toyama,1997], Commutativity [Toyama,1988], Layer-preservation [Ohlebusch,1994]

6/24

slide-11
SLIDE 11

Conditions for Non-E-Overlapping TRSs:

Simple-right- linear [Ohta&Oyamaguchi&Toyama, 1995], Strongly depth-preserving [Gomi&Oyamaguchi&Ohta, 1996], Strongly weight-preserving/depth- preserving root-E-closed [Gomi&Oyamaguchi&Ohta, 1998].

Decreasing Diagram [van Oostrom, 1997] Approach: rule-

labelling [van Oostrom, 1997; Aoto, 2010; Hirokawa&Middeldorp; Zankle&Middeldorp, 2011].

Others:

Weakly-non-overlapping non-collapsing shallow [Sakai&Ogawa, 2010], Reduction-preserving completion [Aoto&Toyama, 2012], Condition for relatively terminating TRSs [Klein&Hirokawa, 2012], Quasi-left-linear and parallel-closed [Suzuki&Aoto&Toyama, 2013].

Tools for proving/disproving confluence of TRSs: ACP, CSI, Saigawa, . . .

7/24

slide-12
SLIDE 12

Outline

  • 1. Backgrounds: TRS and Confluence
  • 2. Backgrounds: Disproving Confluence
  • 3. Proving Non-Joinability by Interpretation
  • 4. Proving Non-Joinability by Ordering
  • 5. Implementation and Experiments
slide-13
SLIDE 13

Disproving Confluence of TRSs (1)

  • terminating TRSs (Knuth&Bendix, 1970)

A terminating TRS is confluent iff all critical pairs are joinable.

  • relatively terminating TRSs (Klein&Hirokawa, 2012)

Suppose S is confluent, R is terminating relative to S, and R and S are strongly non-overlapping. Then R∪S is confluent iff all S-critical pairs of R are (R ∪ S)-joinable. S-critical pairs include non-minimal instances. In general, S-critical pairs are not effectively computed.

8/24

slide-14
SLIDE 14

Disproving Confluence of TRSs (2)

Decidable Classes

  • ground TRSs:

polynomial [Comon et al., 2001] [Tiwari, 2002]; cubic [Falgenhauer, 2012] · · · · · · · · · · · ·

  • linear shallow TRSs: polynomial [Godoy et al., 2003]
  • right-ground TRSs: exponential [Tiwari et al., 2005]
  • right-linear shallow TRSs: [Godoy&Tiwari, 2005]

These decidable classes are rather restrictive. Except for some basic classes, decision procedures are very complex. So far, only implemented procedure seems to be the one for ground TRSs. Needs more investigation for using in confluence tools.

9/24

slide-15
SLIDE 15

Disproving Confluence of TRSs (3)

Find terms t1, t2 such that (1) s

→ t1 and s

→ t2 for some s, and (finding ’candidates’ for non-confluence witness) (2) t1

→ u and t2

→ u for no u, i.e. {u | t1

→ u} ∩ {v | t2

→ v} = ∅. (proving non-joinability of ’candidates’)

10/24

slide-16
SLIDE 16

Disproving Confluence of TRSs (3)

Find terms t1, t2 such that (1) s

→ t1 and s

→ t2 for some s, and (finding ’candidates’ for non-confluence witness) (2) t1

→ u and t2

→ u for no u, i.e. {u | t1

→ u} ∩ {v | t2

→ v} = ∅. (proving non-joinability of ’candidates’) We let the problem (1) untouched, and consider the problem (2).

10/24

slide-17
SLIDE 17

Disproving Confluence of TRSs (3)

Find terms t1, t2 such that (1) s

→ t1 and s

→ t2 for some s, and (finding ’candidates’ for non-confluence witness) (2) t1

→ u and t2

→ u for no u, i.e. {u | t1

→ u} ∩ {v | t2

→ v} = ∅. (proving non-joinability of ’candidates’) We let the problem (1) untouched, and consider the problem (2). We abbreviate non-joinability of terms t1 and t2 (i.e. {u | t1

→ u} ∩ {v | t2

→ v} = ∅) as NJ(t1, t2) .

10/24

slide-18
SLIDE 18

Proving Non-Joinability by Tree Automata

So far, the

  • nly

serious approach for proving non-joinability is using tree automata approximation [Durand&Middeldorp, 1997] [Genet, 1998]. (1) Construct tree automata A1, A2 such that {u | ti

→ u} ⊆ L(Ai) (i = 1, 2) by tree automata approximation. (2) Check L(A1) ∩ L(A2) = ∅.

11/24

slide-19
SLIDE 19

Proving Non-Joinability by Tree Automata

So far, the

  • nly

serious approach for proving non-joinability is using tree automata approximation [Durand&Middeldorp, 1997] [Genet, 1998]. (1) Construct tree automata A1, A2 such that {u | ti

→ u} ⊆ L(Ai) (i = 1, 2) by tree automata approximation. (2) Check L(A1) ∩ L(A2) = ∅. Sometimes it is difficult to construct a well- approximated tree automaton. This work: another approach for proving non-joinability.

11/24

slide-20
SLIDE 20

Outline

  • 1. Backgrounds: TRS and Confluence
  • 2. Backgrounds: Disproving Confluence
  • 3. Proving Non-Joinability by Interpretation
  • 4. Proving Non-Joinability by Ordering
  • 5. Implementation and Experiments
slide-21
SLIDE 21

Interpretation

We first recall some standard definitions. An F-algebra A = A, f Af∈F is a set A equipped with functions f A : An → A for each n-ary function symbol f ∈ F. A valuation σ on a F-algebra A is a mapping σ : V → A. The interpretation [ [t] ]σ ∈ A of a term t ∈ T(F, V) is given by [ [x] ]σ = σ(x) [ [f(t1, . . . , tn)] ]σ = f A([ [t1] ]σ, . . . , [ [tn] ]σ)

12/24

slide-22
SLIDE 22

Interpretation for Non-Joinability

If there exist an F-algebra and a valuation σ such that (i) u →R v implies [ [u] ]σ = [ [v] ]σ and (ii) [ [t1] ]σ = [ [t2] ]σ, then NJ(t1, t2). t1 t2 [ [t1] ]σ [ [t2] ]σ s [ [s] ]σ ∗ ∗

13/24

slide-23
SLIDE 23

Interpretation for Non-Joinability

If there exist an F-algebra and a valuation σ such that (i) u →R v implies [ [u] ]σ = [ [v] ]σ and (ii) [ [t1] ]σ = [ [t2] ]σ, then NJ(t1, t2). But, since t0

→ t1 and t0

→ t2 for some t0, there is no such an F-algebra for our candidates t1, t2.

13/24

slide-24
SLIDE 24

Interpretation for Non-Joinability

If there exist an F-algebra and a valuation σ such that (i) u →R v implies [ [u] ]σ = [ [v] ]σ and (ii) [ [t1] ]σ = [ [t2] ]σ, then NJ(t1, t2). But, since t0

→ t1 and t0

→ t2 for some t0, there is no such an F-algebra for our candidates t1, t2. Idea: replace (i) by the following (i′) (i′) u →{l→r} v implies [ [u] ]σ = [ [v] ]σ for any usable rule l → r ∈ R. Here, usable means it can happen t1

→R ◦ →{l→r} u

  • r t2

→R ◦ →{l→r} u for some u (given in the next slide).

13/24

slide-25
SLIDE 25

Usable Rules for Reachability

Definition. The set of usable rules U(s) ⊆ R is the smallest set satisfying: (i) for any non-variable subterm f(u1, . . . , un) of s and l → r ∈ R, if f(TCAP(u1), . . . , TCAP(un)) and l are unifiable then l → r ∈ U(s); and (ii) if l′ → r′ ∈ U(s) and l → r ∈ U(r′), then l → r ∈ U(s).

  • Lemma. If s

→R ◦ →{l→r} t then l → r ∈ U(s). Here, we assume variable conditions of rewrite rules. It is straightforward to generalize usable rules to the case variable conditions do not hold.

14/24

slide-26
SLIDE 26

Non-Joinability by Interpretation

Theorem 1. Let A = A, f Af∈F be an F-algebra with A =

i∈I Ai (i.e. disjoint union of Ai’s), and s, t terms.

Suppose (i) [ [l] ]σ ∈ Ai implies [ [r] ]σ ∈ Ai for any l → r ∈ U(s) ∪ U(t), (ii) if a ∈ Ai implies f A(. . . , a, . . .) ∈ Aj, then for any b ∈ Ai, f A(. . . , b, . . .) ∈ Aj, and (iii) [ [s] ]ρ ∈ Ai and [ [t] ]ρ ∈ Aj with i = j for some ρ. Then NJ(s, t). (Proof Sketch) (i),(ii) imply that for any s

→R u →R v, [ [u] ]ρ ∈ Ai implies [ [v] ]ρ ∈ Ai.

  • 15/24
slide-27
SLIDE 27

Non-Joinability by Interpretation

Theorem 1. Let A = A, f Af∈F be an F-algebra with A =

i∈I Ai (i.e. disjoint union of Ai’s), and s, t terms.

Suppose (i) [ [l] ]σ ∈ Ai implies [ [r] ]σ ∈ Ai for any l → r ∈ U(s) ∪ U(t), (ii) if a ∈ Ai implies f A(. . . , a, . . .) ∈ Aj, then for any b ∈ Ai, f A(. . . , b, . . .) ∈ Aj, and (iii) [ [s] ]ρ ∈ Ai and [ [t] ]ρ ∈ Aj with i = j for some ρ. Then NJ(s, t). (Proof Sketch) (i),(ii) imply that for any s

→R u →R v, [ [u] ]ρ ∈ Ai implies [ [v] ]ρ ∈ Ai.

  • 15/24
slide-28
SLIDE 28

Example 1. R = (1) a → h(c) (3) h(x) → h(h(x)) (2) a → h(f(c)) (4) f(x) → f(g(x))

  • .

Take candidates h(c), h(f(c)). Usable rules are {(3), (4)}. Take an F-algebra A = {0, 1}, f Af∈F as aA = cA = 0, fA(n) = 1 − n, hA(n) = gA(n) = n. Then [ [h(x)] ]σ = [ [h(h(x))] ]σ, [ [f(x)] ]σ = [ [f(g(x))] ]σ and [ [h(c)] ] = [ [h(f(c))] ]. Hence, NJ(h(c), h(f(c))).

16/24

slide-29
SLIDE 29

Example 2. R = (1) a → f(c) (3) f(x) → h(g(x)) (2) a → h(c) (4) h(x) → f(g(x))

  • .

Take candidates f(c) and h(c). Usable rules are {(3), (4)}. Take an F-algebra A = N, f Af∈F as aA = cA = 0 gA(n) = n + 1 fA(n) = n hA(n) = n + 1 Then [ [f(x)] ]σ ≡ [ [h(g(x))] ]σ (mod 2), [ [h(x)] ]σ ≡ [ [f(g(x))] ]σ (mod 2) and [ [f(c)] ] ≡ [ [h(c)] ] (mod 2). Hence NJ(f(c), h(c)).

17/24

slide-30
SLIDE 30

Outline

  • 1. Backgrounds: TRS and Confluence
  • 2. Backgrounds: Disproving Confluence
  • 3. Proving Non-Joinability by Interpretation
  • 4. Proving Non-Joinability by Ordering
  • 5. Implementation and Experiments
slide-31
SLIDE 31

Non-Joinability by Ordered F-algebras

For a set of integers, an obvious choice of partition is A = {n ∈ A | n < k} ⊎ {n ∈ A | k ≤ n} for some fixed k. More generally, one can use ordered F-algebras A = A, ≤, f Af∈F, where ≤ is a partial order on A.

18/24

slide-32
SLIDE 32

Non-Joinability by Ordered F-algebras

For a set of integers, an obvious choice of partition is A = {n ∈ A | n < k} ⊎ {n ∈ A | k ≤ n} for some fixed k. More generally, one can use ordered F-algebras A = A, ≤, f Af∈F, where ≤ is a partial order on A. Theorem 2. Let A be a weakly monotone ordered F- algebra and s, t be terms. Suppose (i) [ [l] ]σ ≤ [ [r] ]σ for any valuation σ and any l → r ∈ U(s), (ii) [ [l] ]σ ≥ [ [r] ]σ for any valuation σ and any l → r ∈ U(t), (iii) [ [s] ]ρ > [ [t] ]ρ for some valuation ρ. Then NJ(s, t).

18/24

slide-33
SLIDE 33

Non-Joinability by Ordered F-algebras

For a set of integers, an obvious choice of partition is A = {n ∈ A | n < k} ⊎ {n ∈ A | k ≤ n} for some fixed k. More generally, one can use ordered F-algebras A = A, ≤, f Af∈F, where ≤ is a partial order on A. Theorem 2. Let A be a weakly monotone ordered F- algebra and s, t be terms. Suppose (i) [ [l] ]σ ≤ [ [r] ]σ for any valuation σ and any l → r ∈ U(s), (ii) [ [l] ]σ ≥ [ [r] ]σ for any valuation σ and any l → r ∈ U(t), (iii) [ [s] ]ρ > [ [t] ]ρ for some valuation ρ. Then NJ(s, t).

18/24

slide-34
SLIDE 34

Discrimination Pair

We now take term algebras for F-algebras, and ordering

  • n terms.
  • Definition. A pair , ≻ of two relations and ≻ is said

to be a discrimination pair if (i) is a rewrite relation, (ii) ≻ is an irreflexive relation and (iii) ◦ ≻ ⊆ ≻ and ≻ ◦ ⊆ ≻. Theorem 3. Let R be a TRS and s, t terms. Suppose there exists a discrimination pair , ≻ such that U(s) ⊆ , U(t) ⊆ and s ≻ t. Then NJ(s, t). In particular, various path orderings (developed for termination proving) can be used for discrimination pair.

19/24

slide-35
SLIDE 35

Argument Filtering for Non-Joinability

One can incorporates the same notion of argument filtering in a termination proving technique. Argument filtering cuts off subterms in a consistent way.

An argument filtering is a mapping such that π(f) ∈ {[i1, . . . , ik] | 1 ≤ i1 < · · · < ik ≤ arity(f)} ∪ {i | 1 ≤ i ≤ arity(f)} for each f ∈ F. We define f(t1, . . . , tn)π = f(tπ

i1, . . . , tπ ik) if π(f) =

[i1, . . . , ik], f(t1, . . . , tn)π = tπ

i if π(f) = i. For TRS R, we put

Rπ = {lπ → rπ | l → r ∈ R}.

Theorem 4. Let R be a TRS and s, t terms. Suppose there exists a discrimination pair , ≻ and argument filtering π such that URπ(sπ) ⊆ , URπ(tπ) ⊆ and sπ ≻ tπ. Then NJ(s, t).

20/24

slide-36
SLIDE 36

Example 3. R = (1) c → f(c, d), (3) f(x, y) → h(g(y), x), (2) c → h(c, d) (4) h(x, y) → f(g(y), x)

  • .

Take candidates h(f(c, d), d) and f(c, d). Take π(g) = 1, π(f) = [2] and π(h) = [1]. Then U(sπ) = {(3)π, (4)π} and U(tπ) = {(3)π, (4)π}. Then we obtain the constraint h(f(d)) ≻ f(d), f(y) ≃ h(y), h(x) ≃ f(x) which is satisfied by a discrimination pair rpo, rpo ∩ rpo with precedence f ≃ h. Thus NJ(s, t).

21/24

slide-37
SLIDE 37

Outline

  • 1. Backgrounds: TRS and Confluence
  • 2. Backgrounds: Disproving Confluence
  • 3. Proving Non-Joinability by Interpretation
  • 4. Proving Non-Joinability by Ordering
  • 5. Implementation and Experiments
slide-38
SLIDE 38

Implementation

We implemented our techniques on the confluence prover ACP.

  • Interpretation by F-algebras (Theorem 1) using the

polynomial interpretation with linear polynomials and partition N =

0≤i<k{n | n mod k = i} (k = 2, 3).

  • Interpretation by ordered F-algebras (Theorem 2) with

polynomial interpretation via linear polynomials.

  • Discrimination pair (Theorem 4) using recursive path
  • rder with argument filtering.

Criteria are encoded as a constraint and an external SMT-solver is called to check whether it has a solution.

22/24

slide-39
SLIDE 39

Experiments

Th.1 Th.1 Th.2 Th.4 all (k = 2) (k = 3) (poly) (rpo) Example 1

  • Example 2
  • ×

×

  • Example 3

× × ×

  • 23 ex. (success/t.o.)

16/0 16/3 14/0 19/0 21/1 23 ex. (time) 25 293 206 26 84 35 ex. (success/t.o.) 17/5 16/8 17/3 17/1 16/9 35 ex. (time) 318 562 446 106 761

ACP CSI Saigawa Example 1 × × × Example 2 × × × Example 3 × × × 23 ex. (success/t.o.) 9/0 12/– 3/1 23 ex. (time) 2 2107 228 35 ex. (success/t.o.) 18/1 21/– 17/6 35 ex. (time) 71 485 482 23 new examples 35 examples from Cops ACP v.0.31 CSI v.0.2 Saigawa v.1.4

23/24

slide-40
SLIDE 40

Conclusion

Disproving confluence by showing non-joinability of candidates.

  • Proving non-joinability by interpretation

F-algebra, usable rules

  • Proving non-joinability by ordering
  • rdered F-algebra

discrimination pairs, argument filtering

  • Implementation and experiments

Future Works

  • More effective interpretation and ordering

24/24