The 2D Dependency Pair Framework for conditional

2 downloads 0 Views 281KB Size Report
Sep 19, 2018 - b → f(a) f(x) x ⇐ g(x) c(y) we have. DPH(R) : G(a) → B. (1). B → F(a) (2) ... 2 Proving termination properties of CTRSs with 2D Dependency Pairs. 3 The Open ... The chain is minimal if for all i ≥ 1, terms obtained after a. Λ.
The 2D Dependency Pair Framework for conditional rewrite systems Salvador Lucas1 1 DSIC, 2 CS

Jos´e Meseguer2

Ra´ ul Guti´errez1

Universitat Polit` ecnica de Val` encia, Spain

Dept., University of Illinois at Urbana-Champaign, USA

´ n y Lenguajes XVIII Jornadas sobre Programacio PROLE 2018 Sevilla, Spain

1

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

1 / 18

The 2D DP Framework for CTRSs

Introduction

For Conditional TRSs (CTRSs) which are not operationally terminating, two nonterminating behaviors can be observed [LM17]: 1 Infinite reduction sequences, a ‘horizontal’ dimension: nontermination 2 Infinitely many attempts to satisfy the conditions of the rules before issuing a reduction step, a ‘vertical’ dimension: non-V -termination The 2D DP Framework is used to automatically (dis)prove operational termination, termination and V -termination by using dependency pairs [LMG18]

Example (A terminating but non-V-terminating CTRS) For the CTRS R: g(a) → c(b)

b → f(a)

f(x) → x ⇐ g(x) → c(y )

we have DPH (R) :

G(a) → B

(1)

DPV (R) :

F(x) → G(x) (3)

B → F(a) (2) and DPVH (R) = DPH (R) 2

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

2 / 18

The 2D DP Framework for CTRSs

Summary

Summary 1

2D Dependency Pairs and chains

2

Proving termination properties of CTRSs with 2D Dependency Pairs

3

The Open 2D DP Framework Some processors:

4

SCC Processor Narrowing Processors 3 Detection of Nontermination 1 2

5

Implementation

6

Conclusions and future work

3

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

3 / 18

2D Dependency pairs and chains

Dependency pairs

2D Dependency Pairs: main idea Use new rules u → v ⇐ c to track function calls 1

Horizontal: ` = f (`1 , . . . , `m ) → C [g (v1 , . . . , vn )] = r ⇐ c

2

Vertical: ` = f (`1 , . . . , `m ) → r ⇐ · · · ∧ C [g (v1 , . . . , vn )] → ti ∧ · · ·

1

Rules in DPH (R) track horizontal computations that never go up Rules in DPV (R) track computations that go infinitely often up Rules in DPVH (R) are used for the horizontal connection of rules in DPV (R)

2 3

4

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

4 / 18

2D Dependency pairs and chains

Dependency pairs

2D Dependency Pairs: main idea Use new rules u → v ⇐ c to track function calls 1

Horizontal: ` = f (`1 , . . . , `m ) → C [g (v1 , . . . , vn )] = r ⇐ c

2

Vertical: ` = f (`1 , . . . , `m ) → r ⇐ · · · ∧ C [g (v1 , . . . , vn )] → ti ∧ · · ·

1

Rules in DPH (R) track horizontal computations that never go up Rules in DPV (R) track computations that go infinitely often up Rules in DPVH (R) are used for the horizontal connection of rules in DPV (R)

2 3

Feasible pairs! Only R-feasible pairs are considered. For each of such pairs u → v ⇐ c there is a substitution σ such that for all s → t ∈ c, σ(s) →∗R σ(t) holds. Feasibility is undecidable. In practice, we ‘accept’ all pairs as feasible, except those which can be proved R-infeasible [LG18] 4

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

4 / 18

2D Dependency pairs and chains

Chains of dependency pairs

Λ

Given CTRSs R and S we write s →S,R t if there is ` → r ⇐ c ∈ S and σ such that s = σ(`), t = σ(r ) and σ(u) →∗R σ(v ) for all u → v ∈ c.

Definition (Chain of pairs) Let P, Q, and R be CTRSs. A (P, Q, R)-chain is a sequence of pairs ui → vi ⇐ ci ∈ P with a substitution σ such that, for all i ≥ 1, 1

σ(s) →∗R σ(t) for all s → t ∈ ci and

2

σ(vi )(→R ∪ →Q,R )∗ σ(ui+1 ).

Λ

Λ

The chain is minimal if for all i ≥ 1, terms obtained after a →P∪Q,R -step are all R-operationally terminating

Definition (CTRS problem) A CTRS problem is a tuple τ = (P, Q, R, f ), where P, Q and R are CTRSs, and f is a flag ranging on F = {a, m} (referring arbitrary/minimal chains) 5

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

5 / 18

Proving termination properties of CTRSs with 2D DPs

A CTRS problem τ = (P, Q, R, f ) is finite iff there is no infinite τ -chain (arbitrary or minimal, depending on f ); τ is infinite otherwise. Two kind of initial CTRS problems (for f ∈ F): τfH = (DPH (R), ∅, R, f ) and τfV = (DPV (R), DPVH (R), R, f ) Initial CTRS problems Requirements on R Fin/Inf τaH preserves terminating Fin substitutions Nontermination τfH , f ∈ F None Inf V -Termination τaV deterministic 3-CTRS Fin Non-V -Termination τfV , f ∈ F None Inf H Op. termination τf and τfV0 , f , f 0 ∈ F deterministic 3-CTRS Fin Op. nontermination τfH or τfV , f ∈ F None Inf Term. prop. Termination

Investigate all these termination properties using a single framework!

6

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

6 / 18

Proving termination properties of CTRSs with 2D DPs

A CTRS problem τ = (P, Q, R, f ) is finite iff there is no infinite τ -chain (arbitrary or minimal, depending on f ); τ is infinite otherwise. Two kind of initial CTRS problems (for f ∈ F): τfH = (DPH (R), ∅, R, f ) and τfV = (DPV (R), DPVH (R), R, f ) Initial CTRS problems Requirements on R Fin/Inf τaH preserves terminating Fin substitutions Nontermination τfH , f ∈ F None Inf V -Termination τaV deterministic 3-CTRS Fin Non-V -Termination τfV , f ∈ F None Inf H Op. termination τf and τfV0 , f , f 0 ∈ F deterministic 3-CTRS Fin Op. nontermination τfH or τfV , f ∈ F None Inf Term. prop. Termination

Investigate all these termination properties using a single framework! How to avoid a fixed value for f ? 6

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

6 / 18

The Open 2D DP Framework

Open CTRS problems and processors

Definition (Open CTRS problem) An Open CTRS problem is a tuple τˇ = (P, Q, R, ϕ), where P, Q and R are CTRSs, and ϕ is a constant flag in {a, m} or a variable flag f ∈ V

Definition (Open CTRS processor) An open CTRS processor P is a partial function from OCTRS problems τˇ = (P, Q, R, ϕ) into sets of OCTRS problems introducing no new variable flag; alternatively, it can return “no”.

Definition (Soundness and completeness) Let τˇ = (P, Q, R, ϕ), and f ∈ F be such that ςf (ϕ) = f . P is said to be: • (ˇ τ , f )-sound iff ςf (ˇ τ ) is finite whenever P(ˇ τ ) 6= no and for all

τˇ0 ∈ P(ˇ τ ), ςf (ˇ τ 0 ) is finite. • (ˇ τ , f )-complete iff ςf (ˇ τ ) is infinite whenever P(ˇ τ ) = no or there is

τˇ0 ∈ P(ˇ τ ) such that ςf (ˇ τ 0 ) is infinite. 7

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

7 / 18

The Open 2D DP Framework

OCTRS Proof trees

Divide and conquer proof strategy using processors to build an Open CTRS Proof tree (OCTRSP-tree): ϕ1s [ τˇ1 ] ϕ1c

• Plugging schemes hϕs , ϕc i make

the soundness and completeness requirements of processors explicit when applied to an OCTRS

P1

ϕ2s [ τˇ2 ] ϕ2c P2

ϕ31 ˇ31 ] ϕ31 s [τ c

ϕ32 ˇ32 ] ϕ32 s [τ c

P31

L31

P32

ϕ41 ˇ41 ] ϕ41 s [τ c P41

L41 8

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

8 / 18

The Open 2D DP Framework

OCTRS Proof trees

Divide and conquer proof strategy using processors to build an Open CTRS Proof tree (OCTRSP-tree): ϕ1s [ τˇ1 ] ϕ1c

• Plugging schemes hϕs , ϕc i make

the soundness and completeness requirements of processors explicit when applied to an OCTRS

P1

ϕ2s [ τˇ2 ] ϕ2c

• Leaves get labels ‘yes’ or ‘no’

P2

ϕ31 ˇ31 ] ϕ31 s [τ c

ϕ32 ˇ32 ] ϕ32 s [τ c

P31

L31

P32

ϕ41 ˇ41 ] ϕ41 s [τ c P41

L41 8

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

8 / 18

The Open 2D DP Framework

OCTRS Proof trees

Divide and conquer proof strategy using processors to build an Open CTRS Proof tree (OCTRSP-tree): ϕ1s [ τˇ1 ] ϕ1c

• Plugging schemes hϕs , ϕc i make

the soundness and completeness requirements of processors explicit when applied to an OCTRS

P1

ϕ2s [ τˇ2 ] ϕ2c

• Leaves get labels ‘yes’ or ‘no’

P2

ϕ31 ˇ31 ] ϕ31 s [τ c

ϕ32 ˇ32 ] ϕ32 s [τ c

P31

L31

P32

• Soundness and completeness

equations Es or Ec are obtained from the tree

ϕ41 ˇ41 ] ϕ41 s [τ c P41

L41 8

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

8 / 18

The Open 2D DP Framework

OCTRS Proof trees

Divide and conquer proof strategy using processors to build an Open CTRS Proof tree (OCTRSP-tree): ϕ1s [ τˇ1 ] ϕ1c

• Plugging schemes hϕs , ϕc i make

the soundness and completeness requirements of processors explicit when applied to an OCTRS

P1

ϕ2s [ τˇ2 ] ϕ2c

• Leaves get labels ‘yes’ or ‘no’

P2

ϕ31 ˇ31 ] ϕ31 s [τ c

ϕ32 ˇ32 ] ϕ32 s [τ c

P31

L31

P32

ϕ41 ˇ41 ] ϕ41 s [τ c

• Soundness and completeness

equations Es or Ec are obtained from the tree • A unifier ς of the equations is

eventually obtained

P41

L41 8

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

8 / 18

The Open 2D DP Framework

OCTRS Proof trees

Divide and conquer proof strategy using processors to build an Open CTRS Proof tree (OCTRSP-tree): ϕ1s [ τˇ1 ] ϕ1c

• Plugging schemes hϕs , ϕc i make

the soundness and completeness requirements of processors explicit when applied to an OCTRS

P1

ϕ2s [ τˇ2 ] ϕ2c

• Leaves get labels ‘yes’ or ‘no’

P2

ϕ31 ˇ31 ] ϕ31 s [τ c

ϕ32 ˇ32 ] ϕ32 s [τ c

P31

L31

P32

ϕ41 ˇ41 ] ϕ41 s [τ c P41

L41

• Soundness and completeness

equations Es or Ec are obtained from the tree • A unifier ς of the equations is

eventually obtained • The instance ς(ϕ) of the flag

variable ϕ in τˇ1 is used to obtain a conclusion according to the table 8

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

8 / 18

Some processors

The SCC processor

Given τˇ = (P, Q, R, ϕ), infinite τˇ-chains are represented as cycles in a Dependency Graph EG(ˇ τ ). The nodes are (R-feasible) pairs from P; arcs between nodes are established according to possible chains between them

Running example 1

2 EG(ˇ τH)

G(a) → B

1

F(x) → G(x)

3

2

B → F(a)

3 EG(ˇ τV )

Approximating the cycle in EG(ˇ τV )

SCC Processor Processor PSCC returns the set of CTRS problems obtained from the Strongly Connected Components of the graph associated to τˇ. It follows the plugging scheme hf , f i with all OCTRS problems 9

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

9 / 18

Some processors

The SCC processor

With PSCC , we can simplify τˇH in our running example: PSCC (ˇ τH) = ∅ because there is no cycle in EG(ˇ τ H ).

Example (Termination of the running example) Since PSCC (ˇ τ H ) = ∅, the OCTRSP-tree Tˇ H for τˇH is: f0 [ˇ τ H ] f0 PSCC

yes

10

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

10 / 18

Some processors

The SCC processor

With PSCC , we can simplify τˇH in our running example: PSCC (ˇ τH) = ∅ because there is no cycle in EG(ˇ τ H ).

Example (Termination of the running example) Since PSCC (ˇ τ H ) = ∅, the OCTRSP-tree Tˇ H for τˇH is: f0 [ˇ τ H ] f0 PSCC

yes Now, Es (Tˇ H ) = {f = f0 } is unified by the ground flag substitution ςa .

10

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

10 / 18

Some processors

The SCC processor

With PSCC , we can simplify τˇH in our running example: PSCC (ˇ τH) = ∅ because there is no cycle in EG(ˇ τ H ).

Example (Termination of the running example) Since PSCC (ˇ τ H ) = ∅, the OCTRSP-tree Tˇ H for τˇH is: f0 [ˇ τ H ] f0 PSCC

yes Now, Es (Tˇ H ) = {f = f0 } is unified by the ground flag substitution ςa . Thus, ςa (ˇ τ H ) = (DPH (R), ∅, R, a) is proved finite.

10

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

10 / 18

Some processors

The SCC processor

With PSCC , we can simplify τˇH in our running example: PSCC (ˇ τH) = ∅ because there is no cycle in EG(ˇ τ H ).

Example (Termination of the running example) Since PSCC (ˇ τ H ) = ∅, the OCTRSP-tree Tˇ H for τˇH is: f0 [ˇ τ H ] f0 PSCC

yes Now, Es (Tˇ H ) = {f = f0 } is unified by the ground flag substitution ςa . Thus, ςa (ˇ τ H ) = (DPH (R), ∅, R, a) is proved finite. Since R is a 2-CTRS (and preserves terminating substitutions), this proves R terminating 10

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

10 / 18

Some processors

The SCC processor

With PSCC , we can simplify τˇH in our running example: PSCC (ˇ τH) = ∅ because there is no cycle in EG(ˇ τ H ).

Example (Termination of the running example) Since PSCC (ˇ τ H ) = ∅, the OCTRSP-tree Tˇ H for τˇH is: f0 [ˇ τ H ] f0 PSCC

yes Now, Es (Tˇ H ) = {f = f0 } is unified by the ground flag substitution ςa . Thus, ςa (ˇ τ H ) = (DPH (R), ∅, R, a) is proved finite. Since R is a 2-CTRS (and preserves terminating substitutions), this proves R terminating Note: ςm also unifies Es (Tˇ H ), but it does not lead to conclude termination! 10

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

10 / 18

Some processors

Narrowing processors

Connections between dependency pairs u → v ⇐ c and u 0 → v 0 ⇐ c 0 , i.e., the existence of a substitution σ such that σ(v ) →∗R σ(u 0 ) can be investigated by using narrowing

Narrowing processors (sketch) Given τˇ = (P, Q, R, ϕ) and u → v ⇐ c ∈ P, the pair is replaced in P by a set N of pairs which is obtained by issuing a single narrowing step on v : • With PNR , the step is issued by using R • With PNQ , the step is issued (at the topmost position) by using Q;

furthermore, the output flag is fixed to a Both processors follow the plugging schemes hf , ai and h•, ai

Application of PNQ to τˇV (running example) For τˇV = ({F(x) → G(x)}, {G(a) → B, B → F(a)}, R, ϕ), we have: 1

PNQ (ˇ τ V ) = {ˇ τ1V }, where τˇ1V = ({F(a) → B}, {(1), (2)}, R, a)

2

PNQ (ˇ τ1V ) = {ˇ τ2V }, where τˇ2V = ({F(a) → F(a)}, {(1), (2)}, R, a) 11

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

11 / 18

Some processors

Infiniteness processor

The following processor is used to prove CTRS problems infinite.

Infiniteness processor Let τˇ = (P, Q, R, ϕ), u → v ⇐ c ∈ P and θ, η be substitutions such that for all s → t ∈ c, η(s) →∗R η(t) and η(v ) = θ(η(u)). Then, PInf (P, Q, R, ϕ) = no It follows the plugging scheme h•, ai

Application of PInf to τˇ2V (running example) We apply PInf to τˇ2V = ({F(a) → F(a)}, {(1), (2)}, R, a) by using the (trivial or empty) substitutions θ = η = . Thus, PInf (ˇ τ2V ) = no

12

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

12 / 18

Some processors

Infiniteness processor

Non-V-termination of the running example The OCTRSP-tree Tˇ V for τˇV is: f0 [ˇ τV ] a PNQ

f1 [ˇ τ1V ] a PNQ

• [ˇ τ2V ] a PInf

no We have Ec (Tˇ V ) = {f = a, a = a}, which unifies with ςa . Thus, ςa (ˇ τ V ) = (DPV (R), DPVH (R), R, a) is proved infinite. Since R is a deterministic 3-CTRS, this proves R non-V-terminating 13

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

13 / 18

Some processors

Additional processors

Other processors developed so far are: • P removes pairs u → v ⇐ c from P and Q by comparing subterms

of u and v without paying attention to the rules in R • PRTN uses well-founded relations to remove pairs from P and Q.

Rules in R must be ‘compatible’ with appropriate relations • PIR and PRIR (re)move infeasible rules from R • PNC transforms the conditions si of conditional rules

` → r ⇐ s1 → t1 , . . . , sn → tn by using narrowing. • PSUC simplifies the conditional part of the rules by removing

conditions si → ti such that si and ti unify. • PSUNC combines PNC and PSUC .

14

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

14 / 18

Implementation

We have developed the first implementation of the 2D DP Framework as part of the tool mu-term (http://zenon.dsic.upv.es/muterm/) The development consists of 20 modules and more than 4000 lines of code written in Haskell. On the 117 benchmark examples of the 2018 Termination Problems Data Base (TPDB), all processors are used during the proofs: Proc PSCC PSUC PNQ

# uses 399 8 2

Proc P PNR

# uses 48 5

Proc PRTN PNC

# uses 21 5

Proc PInf PSUNC

# uses 16 3

15

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

15 / 18

Conclusions and future work

First framework for (dis)proving termination properties of CTRSs (termination, V-termination, operational termination) using ‘native’ dependency pairs (without transformations into TRSs)

16

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

16 / 18

Conclusions and future work

First framework for (dis)proving termination properties of CTRSs (termination, V-termination, operational termination) using ‘native’ dependency pairs (without transformations into TRSs) Thanks to the 2D DP Framework, our tool is currently the only one that disproves operational termination of CTRSs

16

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

16 / 18

Conclusions and future work

First framework for (dis)proving termination properties of CTRSs (termination, V-termination, operational termination) using ‘native’ dependency pairs (without transformations into TRSs) Thanks to the 2D DP Framework, our tool is currently the only one that disproves operational termination of CTRSs Since 2014, we have participated in the yearly International Termination Competition, each year obtaining the first position among the tools in the TRS Conditional subcategory, see http://zenon.dsic.upv.es/muterm/?page_id=82 for a summary

16

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

16 / 18

Conclusions and future work

First framework for (dis)proving termination properties of CTRSs (termination, V-termination, operational termination) using ‘native’ dependency pairs (without transformations into TRSs) Thanks to the 2D DP Framework, our tool is currently the only one that disproves operational termination of CTRSs Since 2014, we have participated in the yearly International Termination Competition, each year obtaining the first position among the tools in the TRS Conditional subcategory, see http://zenon.dsic.upv.es/muterm/?page_id=82 for a summary

Future work • Improve the integration of model generators (used in proofs of

infeasibility and also to generate well-founded models) • Use as part of external tools like the Maude Termination Tool (MTT) 16

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

16 / 18

The 2D DP Framework for CTRSs

The 2D Dependency Pair Framework for conditional rewrite systems

Thanks!

17

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

17 / 18

References

S. Lucas and R. Guti´errez. Use of logical models for proving infeasibility in term rewriting. Information Processing Letters, 136:90-95, 2018. S. Lucas and J. Meseguer. Dependency pairs for proving termination properties of conditional term rewriting systems. Journal of Logical and Algebraic Methods in Programming, 86:236-268, 2017. S. Lucas, J. Meseguer, and R. Guti´errez. The 2D Dependency Pair Framework for conditional rewrite systems. Part I: Definition and basic processors. Journal of Computer Systems Sciences 96:74–106, 2018.

18

S. Lucas, J. Meseguer, and R. Guti´ errez

JCSS 2018 @ PROLE 2018

September 17-19, 2018

18 / 18

Suggest Documents