This paper presents a new method to transform regular tree grammars representing narrowing trees into overapproximations of substitution ranges, extending previous work to tuples of terms for better analysis.
Contribution
It introduces a novel transformation that overapproximates substitution ranges using tuples of terms, improving upon previous single-variable restrictions.
Findings
01
The transformation overapproximates the ranges of ground substitutions.
02
It extends previous work by representing substitution ranges as tuples.
03
The language of the transformed grammar is proven to be an overapproximation.
Abstract
The grammar representation of a narrowing tree for a syntactically deterministic conditional term rewriting system and a pair of terms is a regular tree grammar that generates expressions for substitutions obtained by all possible innermost-narrowing derivations that start with the pair and end with particular non-narrowable terms. In this paper, under a certain syntactic condition, we show a transformation of the grammar representation of a narrowing tree into another regular tree grammar that overapproximately generates the ranges of ground substitutions generated by the grammar representation. In our previous work, such a transformation is restricted to the ranges w.r.t. a given single variable, and thus, the usefulness is limited. We extend the previous transformation by representing the range of a ground substitution as a tuple of terms, which is obtained by the coding for finite…
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Full text
On Transforming Narrowing Trees into Regular Tree Grammars Generating Ranges of Substitutions††thanks: This work was partially supported by JSPS KAKENHI Grant Number JP17H01722.
The grammar representation of a narrowing tree for a syntactically deterministic conditional term rewriting system and a pair of terms is a regular tree grammar that generates expressions for substitutions obtained by all possible innermost-narrowing derivations that start with the pair and end with particular non-narrowable terms.
In this paper, under a certain syntactic condition, we show a transformation of the grammar representation of a narrowing tree into another regular tree grammar that overapproximately generates the ranges of ground substitutions generated by the grammar representation.
In our previous work, such a transformation is restricted to the ranges w.r.t. a given single variable, and thus, the usefulness is limited.
We extend the previous transformation by representing the range of a ground substitution as a tuple of terms, which is obtained by the coding for finite trees.
We show a precise definition of the transformation and prove that the language of the transformed regular tree grammar is an overapproximation of the ranges of ground substitutions generated by the grammar representation.
We leave an experiment to evaluate the usefulness of the transformation as future work.
1 Introduction
Conditional term rewriting [26, Chapter 7] is known to be more complicated
than unconditional term rewriting in the sense of analyzing properties,
e.g., operational termination [18],
confluence [30], and reachability [6].
A popular approach to the analysis of conditional rewriting is to transform a conditional term rewriting system (a CTRS, for short) into an unconditional term rewriting
system (a TRS, for short) that is in general an overapproximation of the CTRS in
terms of reduction.
This approach enables us to use existing techniques for the analysis of TRSs.
For example, a CTRS is operationally terminating if the unraveled TRS [19, 26]
is terminating [5].
To prove termination of the
unraveled TRS, we can use many techniques for proving termination of TRSs (cf. [26]).
On the other hand, it is not so easy to analyze reachability which is relevant to, e.g., (in)feasibility of conditions.
Let us consider to prove confluence of the following syntactically deterministic 3-CTRS [26, Example 7.1.5] defining the gcd operator over the natural numbers represented by 0 and s:
[TABLE]
A transformational approach in [12, 11] does not succeed in proving confluence of R1.
On the other hand, a direct approach to reachability analysis to prove infeasibility of the conditional critical pairs (i.e., non-existence of substitutions satisfying conditions), which is implemented in some confluence provers, does not prove confluence of R1 well, either.
Let us consider the critical pairs of R1:
[TABLE]
Note that the above critical pairs are symmetric because they are caused by overlaps at the root position only.
An operationally terminating CTRS is confluent if all critical pairs of the CTRS are infeasible (cf. [2, 4]).
Operational termination of R1 can be proved by, e.g., AProVE [9].
To prove infeasibility of the critical pairs above, it suffices to show
both (i) non-existence of terms t such that t<t→R1∗true, and (ii) non-existence of terms t1,t2 such that t1<t2→R1∗true and t2<t1→R1∗true.
Thanks to the meaning of <, it would be easy for a human to notice that such terms t,t1,t2 do not exist.
However, it is not so easy to mechanize a way to show non-existence of t,t1,t2.
In fact, confluence provers for CTRSs,
ConCon [29], CO3 [21], and CoScart [10], based on e.g., transformations of CTRSs into TRSs or reachability analysis for infeasibility of conditional critical pairs, failed to prove confluence of R1 (see Confluence Competition 2016,
2017,
and 2018,111 http://cops.uibk.ac.at/results/?y=2018&c=CTRS
327.trs).
In addition, a semantic approach in [17, 16] cannot prove confluence of R1 using AGES [13], a tool for generating logical models of order-sorted first-order theories—non-existence of t1,t2 above cannot be proved via its web interface with default parameters.
Timbuk 3.2 [8], which is based on tree automata techniques [7], cannot prove infeasibility of x<y↠true,y<x↠true w.r.t. the rules for < under the default use.
The non-existence of a term t with t<t→R1∗true can be reduced to the non-existence of substitutions θ such that x<x⇝θ,R1∗true, where ⇝ denotes the narrowing step [15]—for example, x<y⇝{x↦0,y↦s(y′)},R1true.
In addition, the non-existence of such substitutions can be reduced to the emptiness of the set of the substitutions, i.e., the emptiness of {θ∣x<x⇝θ,R1∗true}.
From this viewpoint, for a pair of terms, the enumeration of substitutions obtained by narrowing would be useful in analyzing rewriting that starts with instances of the pair.
To analyze sets of substitutions derived by innermost narrowing, narrowing trees [24] are useful.
For example, infeasibility of conditional critical pairs of some normal 1-CTRS can be proved by using the grammar representation of a narrowing tree [22].
Simplification of the grammar representation implies the non-existence of substitutions satisfying the conditional part of a critical pair.
However, there are some examples (shown later) for which the simplification method in [22] does not succeed in converting grammar representations to those explicitly representing the empty set.
In this paper, under a certain syntactic condition, we show a transformation of the grammar representation of a narrowing tree into a regular tree grammar [3] (an RTG, for short) that overapproximately generates the ranges of ground substitutions generated by the grammar representation.
The aim of the transformation is to simplify grammar representations as much as possible together with the existing one in [22].
Let R be a syntactically deterministic 3-CTRS (a 3-SDCTRS, for short) that is a constructor system, s a basic term, and t a constructor term, where basic terms are of the form f(u1,…,un) with a defined symbol f and constructor terms u1,…,un.
A narrowing tree [24, 22] of R with the root pair s↠t is a finite representation that defines the set of substitutions θ such that
the pair s↠t narrows to a particular ground term u⊤ consisting of a special binary symbol & and a special constant ⊤ by innermost narrowing ⇝iR with a substitution θ (i.e., (s↠t)⇝iθ,R∗u⊤ and thus θs→cR∗θt).
Note that ↠ is considered a binary symbol, (x↠x)→⊤ is assumed to be implicitly included in R, and →cR denotes the constructor-based rewriting step which applies rewrite rules to basic terms.
Such a narrowing tree can be the enumeration of substitutions obtained by innermost narrowing of R to ground terms consisting of & and ⊤.
The idea of narrowing trees has been extended to finite representations of SLD trees for logic programs [25].
Using narrowing trees, it is easy to see that there is no substitution θ such that x<x⇝iθ,R1∗true, and hence the above four critical pairs with x<x↠true are infeasible.
Let us now consider to prove infeasibility of x<y↠true,y<x↠true.
A narrowing tree for x<y↠true&y<x↠true can be represented by the following grammar representation [24, 22] that can be considered an RTG (see Section 4):
[TABLE]
We denote by G1 the RTG
with the initial non-terminal Γx<y↠true&y<x↠true, the other non-terminals Γx<y↠true,Γy<x↠true, and the above production rules.
We also denote by P1 the set of the above production rules, i.e., (1).
Substitutions are considered constants, and the RTG generates terms over &, ∅, ∙, rec, and substitutions.
The binary symbols ∙ and & are interpreted by standard composition and parallel composition [14, 27],
respectively.
Parallel composition ⇑ of two substitutions returns a most general unifier of the substitutions if the substitutions are unifiable (see Definition 4.2).
For example, {y′↦a,y↦a}⇑{y′↦y} returns {y′↦a,y↦a} and {y′↦a,y↦b}⇑{y′↦y} fails.
The symbol rec is used for recursion, which is interpreted as standard composition of a renaming and a substitution recursively generated.
To simplify the discussion in the remainder of this section, following the meaning of the operators, we simplify the rules of Γx<y↠true and Γy<x↠true as follows:
[TABLE]
In our previous work [22], to show the emptiness of the set of substitutions generated from e.g., Γx<y↠true&Γy<x↠true, we transform the grammar representation to an RTG that overapproximately generates the ranges of ground substitutions w.r.t. a single variable.
For example, for x, the production rules of (2) is transformed into the following ones:
[TABLE]
Note that non-terminal A generates arbitrary ground constructor terms.
Since we focus on x only, non-terminals Γx<y↠truex and Γy<x↠truex generate {sn(a)∣n≥0,a∈{0,true,false}} and {sn(a)∣n>0,a∈{0,true,false}}, respectively, and we cannot prove that there is no substitution generated from Γx<y↠true&Γy<x↠true.
In this paper, we aim at showing that there is no substitution generated by (2) from the initial non-terminal Γx<y↠true&y<x↠true, i.e.,
showing that L(G1,Γx<y↠true)∩L(G1,Γy<x↠true)=∅.
To this end, under a certain syntactic condition, we show a transformation of the grammar representation of a narrowing tree into an RTG that overapproximately generates the ranges of ground substitutions generated by the grammar representation (Section 5).
More precisely, using the idea of coding for tuples of ground terms [3, Section 3.2.1] (see Figure 1), we extend a transformation in [22] w.r.t. a single variable to two variables.
It is straightforward to further extend the transformation to three or more variables.
We do not explain how to, given a constructor 3-SDCTRS, construct (the grammar representation of) a narrowing tree, and concentrate on how to transform a grammar representation into an RTG that generates the ranges of ground substitutions generated by the grammar representation.
Outline of Our Approach
Using the rules of (2), we briefly illustrate the outline of the transformation.
Roughly speaking, we apply the coding for tuples of terms to the range of substitutions, e.g., 0 and s(y2) for {x↦0,y↦s(y2)}.
The rules for Γx<y↠true are transformed into
[TABLE]
where the non-terminal ⊥A generates ground terms obtained by applying the coding to ⊥ and ground constructor terms.
The coding of s(x) and s(y) is ss(xy).
Variables x,y are instantiated by substitutions generated from Γx<y↠true, and hence we replaced xy by Γx<y↠true(x,y).
The rule for Γy<x↠true is transformed into
[TABLE]
Since x,y are swapped by {x↦y,y↦x}, we generate a new non-terminal Γx<y↠true(y,x) and its rules as well as the above rules:
[TABLE]
where the non-terminal A⊥ generates ground terms obtained by applying the coding to ground constructor terms and ⊥.
Every ground term generated from Γx<y↠true(x,y) contains 0s, and every ground term generated from Γy<x↠true(x,y) contains s0.
Neither 0s nor s0 is shared by the languages of Γx<y↠true(x,y) and Γy<x↠true(x,y), and hence there is no substitution which corresponds to an expression generated from Γx<y↠true&y<x↠true.
For this reason, we can transform Γx<y↠true&y<x↠true of (1) into
[TABLE]
which means that there exist no constructor substitution θ satisfying the condition x<y↠true&y<x↠true under the constructor-based rewriting.
One may think that tuples of terms are enough for our goal.
However, substitutions are generated by standard compositions, and tuples makes us introduce composition of tuples.
For example, the range of σ={x↦f(x′,g(a)),y↦f(y′,a)} is represented as a tuple
tup2(f(x′,g(a)),f(y′,a)),
where tup2 is a binary symbol for tuples of two terms.
To apply θ={x′↦g(a),y′↦f(a,a)} to the tuple, we reconstruct a tuple from tup2(f(x′,g(a)),f(y′,a)) and θ.
On the other hand, the coding of terms makes us avoid the reconstruction and use standard composition of substitutions to compute the range of composed substitution. For example, σ and θ can be represented by {xy↦ff(x′y′,ga(a⊥))} and {x′y′↦gf(aa,⊥a)}, respectively, where both xy and x′y′ are considered single variables.
Using the rules for Γx<y↠true of (2), we further show that the weakness of the above approach of using tuples.
Let us try to transform the rules of Γx<y↠true into an RTG that generates {tup2(sm(0),sn(a))∣0≤m<n,a∈{0,true,false}}.
The first rule Γx<y↠true→{x↦0,y↦s(y2)} is transformed into Γx<y↠true(x,y)→tup2(0,s(A)) with the rules of A above.
The second rule Γx<y↠true→Γx<y↠true∙{x↦s(x),y↦s(y)} is transformed into Γx<y↠true(x,y)→tup2(s(Γx<y↠truex),s(Γx<y↠truey)) with the rules of Γx<y↠truex and Γx<y↠truey above.
These rules generates not only terms in {tup2(sm(0),sn(a))∣0≤m<n,a∈{0,true,false}} but also other terms, e.g., tup2(s(0),s(0)).
The term tup2(s(0),s(0)) should not be generated because the term can be a common element generated by Γx<y↠true(x,y) and Γy<x↠true(x,y) and we cannot prove Γx<y↠true&Γy<x↠true does not generate any substitution.
2 Preliminaries
In this section, we recall basic notions and notations of term
rewriting [2, 26] and regular tree grammars [3].
Familiarity with basic notions on term rewriting [2, 26] is assumed.
2.1 Terms and Substitutions
Throughout the paper, we use V as a countably infinite set of
variables.
Let F be a signature, a finite set of function symbolsf
each of which has its own fixed arity, denoted by arity(f).
We often write f/n∈F instead of “an n-ary symbol f∈F”, and so on.
The set of terms over F and V (⊆V) is denoted
by T(F,V), and T(F,∅), the set of ground terms, is abbreviated to T(F).
The set of variables appearing in any of terms
t1,…,tn is denoted by Var(t1,…,tn).
We denote the set of positions of a term t by Pos(t).
For a term t and a position p of t, the subterm of t at
p is denoted by t∣p.
The function symbol at the root position ε of a term
t is denoted by root(t).
Given terms s,t and a position p of s, we denote by s[t]p the term obtained from s by replacing the subterm s∣p at p by t.
A substitutionσ is a mapping from variables to terms such that the number of variables x with σ(x)=x is finite, and is naturally extended over terms.
The domain and range of σ are denoted by
Dom(σ) and Ran(σ), respectively.
The set of variables in Ran(σ) is denoted by VRan(σ):
VRan(σ)=⋃x∈Dom(σ)Var(σx).
We may denote σ by {x1↦t1,…,xn↦tn} if Dom(σ)={x1,…,xn} and σ(xi)=ti
for all 1≤i≤n.
The identity substitution is denoted by id.
The set of substitutions that range over a signature F and a set V of variables is denoted by Subst(F,V):
\mathit{Subst}(\mathcal{F},V)=\{\sigma\mid\mbox{\sigma is a substitution},~{}{\mathcal{R}\mathit{an}}(\sigma)\subseteq\mathcal{T}(\mathcal{F},V)\}.
The application of a substitution σ to a term t is abbreviated to σt, and σt is called
an instance of t.
Given a set V of variables, σ∣V denotes the restricted
substitution of σ w.r.t. V:
σ∣V={x↦σx∣x∈Dom(σ)∩V}.
A substitution σ is called a renaming if σ is a bijection on V.
The compositionθ⋅σ (simply θσ)
of substitutions σ and θ is defined as (θ⋅σ)(x)=θ(σ(x)).
A substitution σ is called idempotent if σσ=σ (i.e., Dom(σ)∩VRan(σ)=∅).
A substitution σ is called more general than a substitution θ, written by σ≤θ, if there exists a substitution δ such that
δσ=θ.
A finite set E of term equations s≈t is called unifiable if there exists a unifier of E such that σs=σt for all term equations s≈t in E.
A most general unifier (mgu) of E is denoted by mgu(E) if E is unifiable.
Terms s and t are called unifiable if {s≈t} is unifiable.
The application of a substitution θ to E, denoted by θE, is defined as θE={θs≈θt∣s≈t∈E}.
2.2 Conditional Rewriting
An oriented conditional rewrite rule over a signature F is
a triple (ℓ,r,c), denoted by ℓ→r⇐c, such that the
left-hand sideℓ is a non-variable term in T(F,V), the
right-hand sider is a term in T(F,V), and the
conditional partc is a sequence s1↠t1,…,sk↠tk of term pairs (k≥0) where s1,t1,…,sk,tk∈T(F,V).
In particular, a conditional rewrite rule is called unconditional
if the conditional part is the empty sequence (i.e., k=0), and we
may abbreviate it to ℓ→r.
Variables in Var(r,c)∖Var(ℓ) are called extra variables of the rule.
An oriented conditional term rewriting system (a CTRS, for short) over F is a set of oriented conditional rewrite rules over F.
A CTRS is called an (unconditional) term rewriting system (a TRS, for short)
if every rule ℓ→r⇐c in the CTRS is unconditional and
satisfies Var(ℓ)⊇Var(r).
The reduction relation→R of a CTRS R is defined as
→R=⋃n≥0→(n),R, where
→(0),R=∅, and →(i+1),R={(s[σℓ]p,s[σr]p)∣s∈T(F,V),ℓ→r⇐s1↠t1,…,sk↠tk∈R,σs1→(i),R∗σt1,…,σsk→(i),R∗σtk} for i≥0.
To specify the position where the rule is applied, we may write →p,R instead of →R.
The underlying unconditional system{ℓ→r∣ℓ→r⇐c∈R} of R is denoted by Ru.
A term t is called a normal form (of R) if t is
irreducible w.r.t. R.
A substitution σ is called normalized
(w.r.t. R) if σx is a normal form of R for each variable x∈Dom(σ).
A CTRS R is called
Type 3 (3-CTRS, for short) if every rule ℓ→r⇐c∈R satisfies that Var(r)⊆Var(ℓ,c).
Var(si)⊆Var(ℓ,t1,…,ti−1) for all 1≤i≤k.
The sets of defined symbols and constructors of a CTRS R over a signature F are
denoted by DR and CR, respectively:
DR={root(ℓ)∣ℓ→r⇐c∈R} and
CR=F∖DR.
Terms in T(CR,V) are called constructor terms of R.
A substitution in Subst(CR,V) is called a constructor substitution of R.
A term of the form f(t1,…,tn) with f/n∈DR and t1,…,tn∈T(CR,V) is called basic.
A CTRS R is called a constructor system if for every rule ℓ→r⇐c in R, ℓ is basic.
A 3-DCTRS R is called syntactically deterministic (an SDCTRS, for short) if for
every rule ℓ→r⇐s1↠t1,…,sk↠tk∈R, every ti is a constructor term or a ground normal
form of Ru.
A CTRS R is called operationally terminating if there are no
infinite well-formed trees in a certain logical inference
system [18]—operational termination means that the evaluation of conditions must either successfully terminate or fail in finite time.
Two terms s and t are said to be joinable, written as s↓Rt, if there exists a term u such that s→R∗u←R∗t.
A CTRS R is called confluent if t1↓Rt2 for any terms t1,t2 such that t1←R∗⋅→R∗t2.
2.3 Innermost Conditional Narrowing
We denote a pair of terms s,t by s↠t (not an equation s≈t) because we analyze conditions of rewrite rules and distinguish the left- and right-hand sides of s↠t.
In addition, we deal with pairs of terms as terms by considering ↠ a binary function symbol.
For this reason, we apply many notions for terms to pairs of terms without notice.
For readability, when we deal with s↠t as a term, we often bracket it such as (s↠t).
As in [20], any CTRS in this paper is assumed to implicitly include the rule (x↠x)→⊤ where ⊤ is a special constant.
The rule (x↠x)→⊤ is used to test structural equivalence between two terms t1,t2 by means of t1↠t2.
To deal with a conjunction of pairs e1,…,ek of terms (ei is either si↠ti or ⊤) as a term, we write e1&⋯&ek by using an associative binary symbol &.
We call such a term an equational term.
Unlike [24], to avoid & to be a defined symbol, we do not use
any rule for &, e.g., (⊤&x)→x.
Instead of derivations ending with ⊤, we consider derivations that end with terms in T({⊤,&}).
We assume that none of &, ↠, or ⊤ is included in the range of any substitution below.
In the following, for a constructor 3-SDCTRS R, a pair s↠t of terms is called a goal of R if the left-hand side s is either a constructor term or a basic term and the right-hand side t is a constructor term.
An equational term is called a goal clause of R if it is a conjunction of goals for R.
Note that for a goal clause T, any instance θT with θ a constructor substitution is a goal clause.
Example 2.1
The equational term x<y↠true&y<x↠true is a goal clause of R1.
The narrowing relation [28, 15]
mainly extends rewriting by replacing matching with unification.
This paper follows the formalization in [23], while we use the rule (x↠x)→⊤ instead of the corresponding inference rule.
Let R be a CTRS.
A goal clause
S=U&s↠t&S′ with U∈T({⊤,&}) is said to conditionally narrow into an equational term Tat an innermost position, written as S⇝iRT, if there exist a non-variable position p of (s↠t), a variant ℓ→r⇐C of a rule in R, and a constructor substitution σ such that Var(ℓ,r,C)∩Var(S)=∅, (s↠t)∣p is basic, (s↠t)∣p and ℓ are unifiable, σ=mgu({(s↠t)∣p≈ℓ}), and
T=U&σC&σ((s↠t)[r]p)&σS′.
Note that all extra variables of ℓ→r⇐C remain in T as fresh variables which do not appear in S.
We assume that Var(S)∩VRan(σ∣Var((s↠t)∣p))=∅ (i.e., σ∣Var((s↠t)∣p) is idempotent) and
Var((s↠t)∣p)⊆Dom(σ).
We write S⇝iσ∣Var(S),RT to make the substitution explicit. An innermost narrowing derivationT0⇝iσ,R∗Tn (and T0⇝iσ,RnTn) denotes a
sequence of narrowing steps T0⇝iσ1,R⋯⇝iσn,RTn with σ=(σn⋯σ1)∣Var(T0) an idempotent substitution.
When we consider two (or more) narrowing derivations S1⇝iσ1,R∗T1 and S2⇝iσ2,R∗T2, we assume that VRan(σ1)∩VRan(σ2)=∅.
Innermost narrowing is a counterpart of constructor-based rewriting (cf. [23]).
Following [23], we define constructor-based conditional rewriting on goal clauses as follows:
for a goal clause
S=U&s↠t&S′ with U∈T({⊤,&}),
we write S→cRT if there exist a non-variable position p of (s↠t), a rule ℓ→r⇐C in R, and a constructor substitution σ such that (s↠t)∣p is basic, (s↠t)∣p=σℓ, and
T=U&σC&(s↠t)[σr]p&S′.
Let R be a constructor SDCTRS, T a goal clause, and U∈T({⊤,&}).
•
If T⇝iσ,R∗U, then σT→cR∗U (i.e.,
σs→cR∗σt for all goals s↠t in T).
•
For a constructor substitution θ, if θT→cR∗U, then there exists an idempotent constructor substitution σ such that T⇝iσ,R∗U and σ≤θ.
Example 2.3
Consider R1 in Section 1 again.
The following is an instance of innermost conditional narrowing of R1:
[TABLE]
The following constructor-based rewriting derivation corresponds to the above narrowing derivation:
[TABLE]
2.4 Regular Tree Grammars
A regular tree grammar (an RTG, for short) is a quadruple G=(S,N,F,P) such that F is a signature, N is a finite set of non-terminals (constants not in F), S∈N, and P is a finite set of production rules of the form A→β with A∈N and β∈T(F∪N).
Given a non-terminal S′∈N, the set {t∈T(F)∣S′→P∗t} is the language generated by G from S′, denoted by L(G,S′).
The initial non-terminal S is not so relevant in this paper.
A regular tree language is a language generated by an RTG from one of its non-terminals.
The class of regular tree languages is equivalent to the class of recognizable tree languages which are recognized by tree automata.
This means that the intersection (non-)emptiness problem for regular tree languages is decidable.
Example 2.4
The RTG G2=(X,{X,X′},{0/0,s/1},{X→0,X→s(X′),X′→s(X)}) generates the sets of even and odd numbers over 0 and s from X and X′, respectively:
L(G2,X)=L(G2)={s2n(0)∣n≥0} and L(G2,X′)={s2n+1(0)∣n≥0}.
3 Coding of Tuples of Ground Terms
In this section, we introduce the notion of coding of tuples of ground terms [3, Section 3.2.1].
To simplify discussions, we consider pairs of terms.
Let F be a signature. We prepare the signature F′=(F∪{⊥})2, where ⊥ is a new constant.
For symbols f1,f2∈F, we denote the function symbol (f1,f2)∈F′ by f1f2, and the arity of f1f2 is max(arity(f1),arity(f2)).
The coding of pairs of ground terms, [⋅,⋅], is recursively defined as follows:
•
[f(s1,…,sm),g(t1,…,tn)]=fg([s1,t1],…,[sm,tm],[⊥,tm+1],…,[⊥,tn])
if m≤n,
•
[f(s1,…,sm),g(t1,…,tn)]=fg([s1,t1],…,[sn,tn],[sn+1,⊥],…,[sm,⊥]) if m>n,
•
[f(s1,…,sm),⊥]=f⊥([s1,⊥],…,[sm,⊥]),
and
•
[⊥,g(t1,…,tn)]=⊥g([⊥,t1],…,[⊥,tn]).
Note that Pos([t1,t2])=Pos(t1)∪Pos(t2).
Note also that for i=1,2 and for p∈Pos([t1,t2]), if p∈/Pos(ti), then ⊥ is complemented for ti.
As described in [3, Section 3.2.1], the basic idea of coding is to stack function symbols as illustrated in Figure 1.
Example 3.1
As in Figure 1,
[f(g(a),g(a)),f(f(a,a),a)]=ff(gf(aa,⊥a),ga(a⊥)).
4 Grammar Representations for Sets of Idempotent Substitutions
In this section, we briefly introduce grammar representations that define sets of idempotent substitutions.
We follow the formalization in [22], which is based on success set equations in [24].
Since substitutions derived by narrowing steps are assumed to be idempotent, we deal with only idempotent substitutions which introduce only fresh variables not appearing in any previous term.
In the following, a renaming ξ is used to (partially) rename a particular term t w.r.t. a set X of variables with X⊆Var(t)∩Dom(ξ) by assuming that ξ∣X is injective on X (i.e., for all variables x,y∈X, if x=y then ξx=ξy) and VRan(ξ∣X)∩(Var(t)∖X)=∅.
For this reason, we write ξ∣X instead of ξ, and call ξ∣X a renaming for t (simply, a renaming).
We first introduce terms to represent idempotent substitutions computed using composition operators ⋅ and ⇑.
We prepare the signature Σ consisting of the following symbols [22]:
•
a finite number of idempotent substitutions which are considered constants,
(basic elements)
•
a constant ∅,
(the empty set/non-existence)
•
an associative binary symbol ∙,
(standard composition)
•
an associative binary symbol &, and
(parallel composition)
•
a binary symbol rec.
(recursion with renaming)
We use infix notation for ∙ and &, and may omit brackets with the precedence such that ∙ has a higher priority than &.
We deal with terms over Σ and some constants used for non-terminals of grammar representations, where we allow such constants to only appear in the first argument of rec.
Note that a term without any constant may appear in the first argument of rec.
Given a finite set N of constants (Σ∩N=∅), we denote the set of such terms by T(Σ∪N).
We assume that each constant in N has a term t (possibly a goal clause) as subscript such as Γt.
For an expression \textscrec(Γt,δ), the role of Γt is to generate substitutions (more precisely, terms in T(Σ)) from Γt, e.g., recursively, and the role of δ is to connect such substitutions with other substitutions if necessary, where the application of δ to some term results in t.
For this reason, we restrict the second argument of rec to renamings, and for each term \textscrec(Γt,δ), we require δ to be an idempotent renaming (i.e., Dom(δ)∩VRan(δ)=∅ and δ is injective on Dom(δ)) such that VRan(δ)⊆Var(t), and Dom(δ)∩(Var(t)∖VRan(δ))=∅.
Note that substitutions {y↦0}, {x↦s(y)}, {x′↦s(y)}, {x↦x′}, {x↦s(s(z))}, {y↦z}, {x↦0,y↦s(y′)}, {x′↦x,y′↦y}, {y↦s(x′)} are considered constants.
Next, we recall parallel composition⇑ of idempotent substitutions [14, 27], which is one of the most important key operations to enable us to construct finite narrowing trees.
Given a substitution θ={x1↦t1,…,xn↦tn}, we denote the set of term equations {x1≈t1,…,xn≈tn} by θ.
Let θ1 and θ2 be idempotent substitutions.
Then, we define ⇑ as follows:
θ1⇑θ2=mgu(θ1∪θ2) if θ1&θ2 is unifiable, and otherwise, θ1⇑θ2=fail.
Note that we define θ1⇑θ2=fail if θ1 or θ2 is not idempotent.
Parallel composition is extended to sets Θ1,Θ2 of idempotent substitutions in the natural way:
Θ1⇑Θ2={θ1⇑θ2∣θ1∈Θ1,θ2∈Θ2,θ1⇑θ2=fail}.
We often have two or more substitutions that can be results of θ1⇑θ2 (=fail), while most general unifiers are unique up to variable renaming.
To simplify the semantics of grammar representations for substitutions, as a result of θ1⇑θ2 (=fail), we adopt an idempotent substitution σ such that Dom(θ1)∪Dom(θ2)⊆Dom(σ).
Note that most general unifiers we can adopt as results of θ1⇑θ2 under the convention are still not unique, while they are unique up to variable renaming.
The parallel composition {x↦s(z),y↦z}⇑{x↦w} may return {x↦s(z),y↦z,w↦s(z)}, but we do not allow {x↦s(y),z↦y,w↦s(y)} as a result because y appears in the range.
On the other hand, {x↦s(z),y↦z}⇑{x↦y}=fail.
A key of construction of narrowing trees (and their grammar representations) is compositionality of innermost narrowing (cf. [22]):
S1&S2⇝iσ,R∗T if and only if S1⇝iσ1,R∗T1, S2⇝iσ2,R∗T2, T=T1&T2, and σ=σ1⇑σ2.
To compute a substitution derived by innermost narrowing from a goal clause S1&S2, we compute substitutions σ1 and σ2 derived by innermost narrowing from S1 and S2, respectively, and then compute σ1⇑σ2.
When we compute σ1⇑σ2
from two narrowing derivations S1⇝iσ1,R∗T1 and S2⇝iσ2,R∗T2,
we assume that VRan(σ1)∩VRan(σ2)=∅.
To satisfy this assumption explicitly in the semantics for T(Σ), we introduce an operation freshδ(⋅) of substitutions to make a substitution introduce only variables that do not appear in Dom(δ)∪VRan(δ):
for substitutions σ,δ, we define freshδ(σ) by (ξ⋅σ)∣Dom(σ) where ξ is a renaming such that Dom(ξ)=VRan(σ) and VRan(ξ)∩(Dom(δ)∪VRan(δ)∪Dom(σ))=∅.222
For VRan(ξ), we choose variables not appearing in any substitutions in Σ.
The subscript δ of freshδ(⋅) is used to specify freshness of variables—we say that a variable x is fresh w.r.t. a set X of variables if x∈/X.
A term e in T(Σ) defines a substitution.
The semantics of terms in T(Σ) is inductively defined as follows [22]:
•
[[θ]]=θ if θ is a substitution,
•
[[e1∙e2]]=[[e1]]⋅[[e2]] if [[e2]]=fail and [[e1]]=fail,
•
[[e1&e2]]=(θ1⇑θ2)∣Dom(θ1)∪Dom(θ2) if [[e1]]=fail and [[e2]]=fail, where θ1=[[e1]] and θ2=freshθ1([[e2]]),
•
[[\textscrec(e,δ)]]=(freshδ([[e]])⋅δ)∣Dom(δ)
if [[e]]=fail and VRan(δ)⊆Dom([[e]]), and
•
otherwise, [[e]]=fail (e.g., [[∅]]=fail).
Notice that Γt, a non-terminal used in an RTG, is not included in T(Σ), and thus, [[Γt]] is not defined.
Since ⇑ may fail, we allow to have fail, e.g.,
[[{y↦s(x)}∙{x↦y}&{z↦0}]]=fail.
The number of variables appearing in an RTG defined below is finite.
However, we would like to use RTGs to define infinitely many substitutions such that the maximum number of variables we need cannot be fixed.
To solve this problem, in the definition of [[\textscrec(e,δ)]], we introduced the operation freshδ(⋅) that makes all variables introduced by [[e]]fresh w.r.t. Dom(δ)∪VRan(δ).
In [24], this operation is implicitly considered, but in [22], rec is explicitly introduced to the syntax in order to convert terms in T(Σ) precisely.
To assume VRan([[e1]])∩VRan([[e2]])=∅ for [[e1&e2]], we also introduced freshθ1(⋅) in the case of [[e1&e2]].
The semantics of terms in T(Σ) is naturally extended to subsets of T(Σ) as follows:
for a set L⊆T(Σ),
[[L]]={[[e]]∣e∈L,[[e]]=fail}.
To define sets of idempotent substitutions, we adopt RTGs.
In the following, we drop the third component from grammars constructed below because the third one is fixed to Σ with a finite number of substitutions that are clear from production rules.
A substitution-set grammar (SSG) for a term t0 is an RTG G=(Γt0,N,P) such that N is a finite set of non-terminals Γt, Γt0∈N, and P is a finite set of production rules of the form Γt→β with β∈T(Σ∪N).
Note that L(G,Γt)={e∈T(Σ)∣Γt→G∗e} for each Γt∈N, and the numbers of variables appearing in L(G,Γt) is finite.
The set of substitutions generated by G from Γt∈N is [[L(G,Γt)]], i.e.,
[[L(G,Γt)]]={[[e]]∣e∈L(G,Γt),[[e]]=fail}.
Note that the number of variables in ⋃θ∈[[L(G,Γt)]]VRan(θ) may be infinite because of the interpretation for rec.
Example 4.5
The RTG G1 in Section 1 is an SSG for a term Γx<y↠true&y<x↠true.
We have that
[TABLE]
and
[[L(G1,Γx<y↠true)]]={{x↦sm(0),y↦sn(a)}∣0≤m<n,a∈{0,true,false}}.
5 Transforming SSGs into RTGs Generating Ranges of Substitutions
In this section, given a goal clause T and two variables x1,x2 appearing in T, we show a transformation of an SSG G=(ΓT0,N,P) into an RTG G′ such that L(G′,ΓT(x1,x2))⊇{[ξθx1,ξθx2]∣θ∈L(G,ΓT),ξ∈Subst(C),Var(θx1,θx2)⊆Dom(ξ)}, where C is a set of constructors we deal with.
Note that T does not have to be T0.
The transformation is an extension of the transformation in [22, Section 7] and applicable to SSGs satisfying a certain syntactic condition shown later.
In the following,
we aim at showing that L(G1,Γx<y↠true)∩L(G1,Γy<x↠true)=∅.
We use C as a set of constructors unless noted otherwise.
Let G be an SSG (ΓT0,N,P) and T a goal clause such that ΓT∈N.
We denote by P∣ΓT the set of production rules that are reachable from ΓT.
We assume that any rule in P∣ΓT is of the following form:
[TABLE]
where VRan(δj)=Var(Tj)444
In defining SSGs, we only required that VRan(δj)⊆Var(Tj), but to make the transformation below precise, we require that VRan(δj)=Var(Tj).
This requirement is not restrictive because SSGs for narrowing trees satisfy this requirement because δj connects Tj with a renamed variant which has no shared variable with Tj.
for all 1≤j≤n, and θ1,…,θm+n are idempotent substitutions such that Dom(θj)=Var(T′) for all 1≤j≤m+n.
Note that ΓT′→\textscrec(ΓT′′,δ) is considered ΓT′→\textscrec(ΓT′′,δ)∙id.
In addition, for each ΓT′→\textscrec(ΓTi,δi)∙θm+i with 1≤i≤n,
we assume that
for all variables x,y in T′ and for each position p∈Pos(δθm+ix)∩Pos(δθm+iy),
all of the following hold:
•
if (δθm+ix)∣p∈Var(Ti), then (δθm+iy)∣p∈Var(Ti)∪T(C,V∖Var(Ti)),
and
•
if (δθm+iy)∣p∈Var(Ti), then (δθm+ix)∣p∈Var(Ti)∪T(C,V∖Var(Ti)).
This assumption implies that
for such x, y, and p,
the terms (δθm+ix)∣p and (δθm+iy)∣p satisfy one of the following:
(a)
both are rooted by function symbols,
2. (b)
both are variables in Var(Ti),
3. (c)
one is a variable in Var(Ti) and the other is a term in T(C,V∖Var(Ti)),
or
4. (d)
both are terms in T(C,V∖Var(Ti)).
For example, both P1∣Γx<y↠true and P1∣Γy<↠true satisfy the above assumption.
Our idea of extending the previous transformation is the use of coding;
Roughly speaking, for ΓT′→\textscrec(ΓTi,δi)∙θm+i with 1≤i≤n and for all variables x,y in T′, we apply coding to δθm+ix and δθm+iy.
A variable in Var(Ti), which is instantiated by substitutions generated from ΓTi, may prevent us from constructing a finite number of production rules (see Example 5.3 below).
For this reason, we expect any variable555 This is not the case where either (a) or (d) holds.
in Var(δθm+ix,δθm+iy)∩Var(Ti) to be coded with
•
⊥ (the case where the precondition “p∈Pos(δθm+ix)∩Pos(δθm+1y)” does not hold),
•
another variable in Var(δθm+ix,δθm+iy)∩Var(Ti) (the case where (b) above holds), or
•
a constructor term without any variable in Var(Ti) (the case where (c) above holds).
Definition 5.1
*We denote the set of constructor terms appearing in substitutions in P by Patterns(P), where such constructor terms are instantiated with a non-terminal A introduced during the transformation below:
{\mathit{Patterns}}(\mathcal{P})=\left\{{\{x\mapsto A\mid x\in{\mathcal{V}\mathit{ar}}(t)\}(t)}\mid\mbox{\thetaappearsin\mathcal{P}},~{}s\in{\mathcal{VR}\mathit{an}}(\theta),~{}t\unlhd s\right\}.666
The current definition of Patterns(P) is not well optimized and Patterns(P) may include some terms that are not necessary for the transformation.
However, for readability, we adopt this simpler definition.
We denote the set of variables appearing in N by Vars(N):
Vars(N)=⋃ΓT′∈NVar(T′).
The RTG obtained from G and variables x1,x2 in T, denoted by Ran(G,T,x1,x2),
is (ΓT(x1,x2),N′∪NA,P1′∪P2′∪PAA∪PA⊥∪P⊥A) such that*
where ⟨⋅,⋅⟩T′, which takes a goal clause T′ and two terms in T(F∪{A},Var(T′)) as input and returns a set of terms in T(F∪N′∪NA), is recursively defined as follows:
•
⟨x,y⟩T′={ΓT′(x,y)}, where x,y∈V,
•
⟨x,t⟩T′={ΓT′(x,t)}, where x∈V and t∈Patterns(P),
•
⟨x,⊥⟩T′={ΓT′(x,⊥)}, where x∈V,
•
⟨t,y⟩T′={ΓT′(A,y)}, where y∈V and t∈Patterns(P),
⟨f(s1,…,sm),g(t1,…,tn)⟩T′={fg(u1,…,um,um+1,…,un)∣1≤i≤m,ui∈⟨si,ti⟩T′,1≤j≤n−m,um+j∈⟨⊥,tm+j⟩T′}* if m<n, and*
•
⟨f(s1,…,sm),g(t1,…,tn)⟩T′={fg(u1,…,un,un+1,…,um)∣1≤i≤n,ui∈⟨si,ti⟩T′,1≤j≤m−n,un+j∈⟨sn+j,⊥⟩T′}* if m≥n.*
Note that the non-terminal AA generates {[t1,t2]∣t1,t2∈T(C)}, the non-terminal A⊥ generates {[t1,⊥]∣t1∈T(C)}, and the non-terminal ⊥A generates {[⊥,t2]∣t2∈T(C)}.
Note also that we generate only production rules that are reachable from ΓT(x1,x2), and drop from N′∪NA non-terminals not appearing in the generated production rules.
Example 5.2
Consider G1=(Γx<y↠true&y<x↠true,{Γx<y↠true&y<x↠true,Γx<y↠true,Γy<x↠true},P1) in Section 1.
We have that
Let us focus on Γx<y↠true and x,y.
Since neither Γx<y↠true&y<x↠true nor Γy<x↠true is reachable from Γx<y↠true by P1, when we construct the RTG Ran(G1,Γx<y↠true,x,y), we do not take into account Γx<y↠true&y<x↠true,Γy<x↠true, and their rules.
The RTG Ran(G1,Γx<y↠true,x,y)=(Γx<y↠true(x,y),N′∪NA,P1′∪P2′∪PAA∪PA⊥∪P⊥A) is constructed as follows:
P1′={Γx<y↠true(x,y)→0s(⊥A)},
because Γx<y↠true→{x↦0,y↦s(y2)}∈P1 and ⟨0,s(A)⟩⊤={0s(⊥A)},
•
P2′={Γx<y↠true(x,y)→ss(Γx<y↠true(x,y))},
because Γx<y↠true→\textscrec(Γx<y↠true,{x3↦x,y3↦y})∙{x↦s(x3),y↦s(y3)}∈P1 and ⟨s(x),s(y)⟩x<y↠true={ss(Γx<y↠true(x,y))},
For Γy<x↠true and x,y, we add Γy<x↠true(x,y)→Γx<y↠true(y,x) to the above production rules.
Rules that are not reachable from Γx<y↠true(x,y) or Γy<x↠true(x,y) can be dropped from Ran(G1,Γx<y↠true,x,y), obtaining an RTG, denoted by G4, with the following production rules:
and hence, there is no shared constant between the two sets.
This means that
[TABLE]
and hence
[TABLE]
Note that the emptiness problem of RTGs is decidable, and hence we can decide the emptiness problem of L(G4,Γx<y↠true(x,y))∩L(G4,Γy<x↠true(x,y)).
The following example illustrates both why not all SSGs can be transformed and why we adopt the assumption.
Example 5.3
Let G5 be the following SSG which does not satisfy the assumption:
[TABLE]
The domains of substitutions generated by G5 w.r.t. x,y is
{(sn(0),s2n(0))∣n≥0} which is not recognizable.
This implies that there is no RTG generating this set, while every substitution appearing in G5 preserves linearity.
Let us now apply Ran to G5, while G5 does not satisfy the assumption.
To generate rules from Γx↠y→\textscrec(Γx↠y,{x′↦x,y′↦y})∙{x↦s(x′),y↦s(s(y′))}, we need to compute ⟨s(x),s(s(y))⟩Γx↠y, resulting in ss(⟨x,s(y)⟩Γx↠y).
The first argument x of ⟨x,s(y)⟩Γx↠y cannot be instantiated any more without Γx↠y.
Then, let us define ⟨x,s(y)⟩Γx↠y=Γx↠y(x,s(y)).
Then, the non-terminal Γx↠y(x,s(y)) is not generated in computing the set of non-terminals (N′∪NA in Definition 5.1).
Let us now add Γx↠y(x,s(y)) into the set of non-terminals, and generate rules for Γx↠y(x,s(y)) from Γx↠y→\textscrec(Γx↠y,{x′↦x,y′↦y})∙{x↦s(x′),y↦s(s(y′))}.
Then, we need non-terminal Γx↠y(x,s(s(s(y)))).
In summary, we need infinitely many non-terminals and their production rules.
The assumption enables us to avoid such a case.
Finally, we show correctness of the transformation in Definition 5.1, i.e., that
L(Ran(G,T,x1,x2)) is an overapproximation of the ranges of ground substitutions obtained from [[L(G,ΓT)]] w.r.t. x1,x2.
We first show some auxiliary lemmas, and then show the main theorem.
Lemma 5.4
Let T be a goal clause, t1,t2∈T(C,V), θ∈Subst(C), ξ∈Subst(C) such that
Dom(θ)∩Dom(ξ)=∅ and
Dom(θ)∪Dom(ξ)=Var(t1,t2).
Note that θ∪ξ=θξ=ξθ.
Let ξA={x↦A∣x∈Dom(ξ)} and u∈⟨ξAt1,ξAt2⟩T.
Suppose that for all positions p∈Pos(t1)∩Pos(t2),
both of the following hold:
•
if t1∣p∈Dom(θ), then t2∣p∈Dom(θ)∪T(C,Dom(ξ)),
and
for any position p∈Pos(t1)∩Pos(t2), all of the following hold:
•
*if t1∣p=x∈Dom(θ) and t2∣p=y∈Dom(θ), then
([t1,t2])∣p=xy (i.e., ([θξt1,θξt2])∣p=[θx,θy])) and
u∣p=ΓT(x,y)
*
•
if t1∣p=x∈Dom(θ) and t2∣p=y∈Dom(ξ), then
([t1,t2])∣p=xy (i.e., ([θξt1,θξt2])∣p=[θx,ξy]) and
u∣p=ΓT(x,A)
•
if t1∣p=x∈Dom(ξ) and t2∣p=y∈Dom(θ), then
([t1,t2])∣p=xy (i.e, ([θξt1,θξt2])∣p=[ξx,θy]) and
u∣p=ΓT(A,y)
•
if t1∣p=x∈Dom(ξ) and t2∣p=y∈Dom(ξ), then
([t1,t2])∣p=xy (i.e., ([θξt1,θξt2])∣p=[ξx,ξy]) and
u∣p=AA
•
if t1∣p=x∈Dom(θ) and root(t2∣p)=g∈C, then
root(([t1,t2])∣p)=xg (i.e., ([θξt1,θξt2])∣p=[θx,ξ(t2∣p)]) and
u∣p=ΓT(x,ξA(t2∣p))
•
if t1∣p=x∈Dom(ξ) and root(t2∣p)=g∈C, then
root(([t1,t2])∣p)=xg (i.e., ([θξt1,θξt2])∣p=[ξx,ξ(t2∣p)]),
u∣p∈⟨A,ξA(t2∣p)⟩⊥,
and
there exists a term t1′∈T(C,V) and a term u′∈⟨A,ξA(t2∣p)⟩⊥ such that
t1′≤ξx,
u′=[ξA′t1′,t2∣p],
–
*for all q∈Pos(t1′)∩Pos(t2∣p), ξA′(t1′∣q)=A if and only if t2∣pq=A,777
This implies that if q∈Pos(t1′)∩Pos(t2∣p), then pq∈Pos(u′) and u∣pq=AA.
*
and
–
*for all q∈Pos(t1′)∖Pos(t2∣p), ξA′(t1′∣q)=A,*888
This implies that if q∈Pos(t1′)∖Pos(t2∣p), then pq∈Pos(u′) and u∣pq=A⊥.
**
where ξA′={x↦A∣x∈Dom(t1′)},
•
if root(t1∣p)=f∈C and t2∣p=y∈Dom(θ), then
root(([t1,t2])∣p)=fy (i.e., ([θξt1,θξt2])∣p=[ξ(t1∣p),θy]) and
u∣p=ΓT(ξA(t1∣p),y)
•
if root(t1∣p)=f∈C and t2∣p=y∈Dom(ξ), then
root(([t1,t2])∣p)=fy (i.e., ([θξt1,θξt2])∣p=[ξ(t1∣p),ξy]),
u∣p∈⟨ξA(t1∣p),A⟩⊤,
and
there exists a term t2′∈T(C,V) and a term u′∈⟨ξA(t1∣p),A⟩⊤ such that
t2′≤ξy,
u′=[t1∣p,ξA′t2′],
–
for all q∈Pos(t2′)∩Pos(t1∣p), ξA′(t2′∣q)=A if and only if t1∣pq=A,
and
–
for all q∈Pos(t2′)∖Pos(t1∣p), ξA′(t2′∣q)=A,
where ξA′={x↦A∣x∈Dom(t2′)},
•
if root(t1∣p)=f∈C and root(t2∣p)=g∈C, then
root(([t1,t2])∣p)=root(([θξt1,θξt2])∣p)=root(u∣p)=fg (i.e., ([θξt1,θξt2])∣p=[θξ(t1∣p),θξ(t2∣p)]),
3. (c)
for any position p∈Pos(t1)∖Pos(t2), both of the following hold:
•
if t1∣p=x∈Dom(θ), then
([t1,t2])∣p=x⊥ (i.e, ([θξt1,θξt2])∣p=([θx,⊥])∣p) and
u∣p=ΓT(x,⊥),
•
*if t1∣p=x∈Dom(ξ), then
([t1,t2])∣p=x⊥ (i.e., ([θξt1,θξt2])∣p=([ξx,⊥])∣p) and
u∣p=A⊥,
and
*
•
if root(t1∣p)=f∈C, then
root(([t1,t2])∣p)=root(([θξt1,θξt2])∣p)=root(u∣p)=f⊥ (i.e., ([θξt1,θξt2])∣p=([θξ(t1∣p),⊥])∣p),
and
4. (d)
for any position p∈Pos(t2)∖Pos(t1), both of the following hold:
•
if t2∣p=y∈Dom(θ), then
([t1,t2])∣p=⊥y (i.e., ([θξt1,θξt2])∣p=([⊥,θy])∣p) and
u∣p=ΓT(⊥,y),
•
if t2∣p=y∈Dom(ξ), then
([t1,t2])∣p=⊥y (i.e., ([θξt1,θξt2])∣p=([⊥,ξy])∣p) and
u∣p=⊥A,
and
•
if root(t2∣p)=g∈C, then
root(([t1,t2])∣p)=root(([θξt1,θξt2])∣p)=root(u∣p)=⊥g (i.e., ([θξt1,θξt2])∣p=([⊥,θξ(t2∣p)])∣p).
*Proof. *
By definition, the claim (a) is trivial.
The claims (b)–(d) can be proved by induction on the length of p.
For the claims (b), (c), and (d), we make a case distinction depending on
what t1∣p and t2∣p are,
what t1∣p is, and
what t2∣p is, respectively.
□
Lemma 5.5
Let T be a goal clause, t1,t2∈T(C,V), θ∈Subst(C), ξ∈Subst(C) such that
Dom(θ)∩Dom(ξ)=∅ and
Dom(θ)∪Dom(ξ)=Var(t1,t2).
Note that θ∪ξ=θξ=ξθ.
Let ξA={x↦A∣x∈Dom(ξ)}.
Suppose that for all positions p∈Pos(t1)∩Pos(t2),
both of the following hold:
•
if t1∣p∈V∩Dom(θ), then t2∣p∈Dom(θ)∪T(C,Dom(ξ)),
and
•
if t2∣p∈V∩Dom(θ), then t1∣p∈Dom(θ)∪T(C,Dom(ξ)).
Then, there exists a term u∈⟨ξAt1,ξAt2⟩T, a context C[]∈T((C∪{⊥})2∪{□}), terms S1,…,Sn, and non-terminals Γ1,…,Γn such that
[θξt1,θξt2]=C[S1,…,Sn],
u=C[Γ1,…,Γn],
and
for all 1≤i≤n, all of the following hold:
•
Si=xy* if and only if Γi=ΓT(x,y),*
•
Si=[θx,ξ(t2∣p)]* if and only if Γi=ΓT(x,ξA(t2∣p)) for some p∈Pos(t2),*
•
Si=[θx,⊥]* if and only if Γi=ΓT(x,⊥),*
•
Si=[ξ(t1∣p),θy]* if and only if Γi=ΓT(ξA(t1∣p),y) for some p∈Pos(t1),*
•
Si=[⊥,θy]* if and only if Γi=ΓT(⊥,y),*
•
Si=[ξ(t1∣p),ξ(t2∣p)]* for some p∈Pos(ξt1)∩Pos(ξt2) if and only if Γi=AA,*
•
Si=[ξ(t1∣p),⊥]* for some p∈Pos(ξt1)∖Pos(ξt2) if and only if Γi=A⊥,
and*
•
Si=[⊥,ξ(t2∣p)]* for some p∈Pos(ξt2)∖Pos(ξt1) if and only if Γi=⊥A.*
*Proof. *
Using Lemma 5.4, this lemma can be proved by structural induction on t1,t2.
□
Lemma 5.6
Let G be an SSG (ΓT0,N,P), ΓT∈N, x1,x2∈Var(T), Ran(G,T,x1,x2) be constructed, and
G′=Ran(G,T,x1,x2).
Let t1,t2∈T(C,V), ξ∈Subst(C) with Dom(ξ)⊇Var(t1,t2), and ξA={x↦A∣x∈Var(t1,t2)}.
Then, all of the following hold:
•
there exists a term u∈⟨ξAt1,ξAt2⟩⊤ such that u→G′∗[ξt1,ξt2],
•
there exists a term u∈⟨ξAt1,⊥⟩⊤ such that u→G′∗[ξt1,⊥],
and
•
there exists a term u∈⟨⊥,ξAt2⟩⊤ such that u→G′∗[⊥,ξt2].
*Proof. *
Using the definition of PAA, PA⊥, and P⊥A, and Lemma 5.4, this lemma can be proved by structural induction on t1,t2.
□
Theorem 5.7
Let G be an SSG (ΓT0,N,P), ΓT∈N, x1,x2∈Var(T), and Ran(G,T,x1,x2) be constructed (i.e., P∣T satisfies the assumption).
Then,
[TABLE]
*Proof. *
Let G′=Ran(G,T,x1,x2).
It suffices to show that
for all ΓT′∈N, t1,t2∈Var(T′)∪Patterns(P)∪{⊥} with {t1,t2}∩V=∅, and e∈L(G,ΓT′) with
θ=[[e]], we have [ξθt1,ξθt2]∈L(G′,ΓT′(t1,t2)) for all substitutions ξ∈Subst(C) with Dom(ξ)=Var(ξθt1,ξθt2).
We prove this claim by induction on the length of derivations from ΓT′ to e.
We make a case distinction depending on which rule is applied at the first step.
•
The case where ΓT′→θ is applied.
By construction, we have the following production rule
ΓT′(t1,t2)→u∈G′ for each u∈⟨ξAθt1,ξAθt2⟩⊤,
where ξA={x↦A∣x∈Var(ξAθt1,ξAθt2)}.
Then, the claim follows from Lemma 5.6.
•
The remaining case where ΓT′→\textscrec(ΓT′′,δ)∙σ is applied.
Suppose that ΓT′′→G′∗e′ and θ=[[\textscrec(e′,δ)∙σ]].
Let θ′=[[e′]].
Then, θ=(θ′δ)∣Dom(δ)σ.
By construction, we have the following production rule ΓT′(t1,t2)→u∈G′ for each u∈⟨ξAδσt1,ξAδσt2⟩T′.
where ξA={x↦A∣x∈Var(δσt1,δσt2)∖Var(T′′)}.
By the assumption, Var(T′′)=VRan(δ), and thus, Dom(ξA)∩VRan(δ)=∅.
Since ξA is a ground substitution, we have that
ξAδσti=δξA∣VRan(σ)∖Dom(δ)σti.
Since ξ is a ground substitution and Dom(ξ)⊇VRan(θ)=VRan((θ′δ)∣Dom(δ)σ), we have that
–
ξθti=ξ(θ′δ)∣Dom(δ)σti=ξθ′δξ∣Dom(VRan(σ)∖Dom(δ)σti,
and
–
ξAδσti=ξAδξA∣Dom(VRan(σ)∖Dom(δ)σti,
and hence
[TABLE]
It follows from Lemma 5.5 that there exists a term u∈⟨ξAδσt1,ξAδσt2⟩T′′, a context C[]∈T((C∪{⊥})2∪{□}), terms S1,…,Sn, and non-terminals Γ1,…,Γn such that
[ξθt1,ξθt2]=C[S1,…,Sn],
u=C[Γ1,…,Γn],
and
for all 1≤i≤n, all of the following hold:
–
Si=xy if and only if Γi=ΓT′′(x,y),
–
Si=[ξθx,ξθ(t2∣p)] if and only if Γi=ΓT′′(x,ξA(t2∣p)) for some p∈Pos(t2),
–
Si=[ξθx,⊥] if and only if Γi=ΓT′′(x,⊥),
–
Si=[ξθ(t1∣p),ξθy] if and only if Γi=ΓT′′(ξA(t1∣p),y) for some p∈Pos(t1),
–
Si=[⊥,ξθy] if and only if Γi=ΓT′′(⊥,y),
–
Si=[ξθ(t1∣p),ξθ(t2∣p)] for some p∈Pos(ξθt1)∩Pos(ξθt2) if and only if Γi=AA,
–
Si=[ξθ(t1∣p),⊥] for some p∈Pos(ξθt1)∖Pos(ξθt2) if and only if Γi=A⊥,
and
–
Si=[⊥,ξθ(t2∣p)] for some p∈Pos(ξθt2)∖Pos(ξθt1) if and only if Γi=⊥A.
In the case where Γi is ΓT′′(x,y), ΓT′′(x,ξA(t2∣p)), ΓT′′(x,⊥), ΓT′′(ξA(t1∣p),y), or ΓT′′(⊥,y), it follows from the induction hypothesis that Γi→G′∗Si.
In the remaining case where Γi is AA, A⊥, or ⊥A, it follows from Lemma 5.6 that Γi→G′∗Si.
Therefore, we have that
ΓT′(t1,t2)→G′u=C[Γ1,…,Γn]→G′∗C[S1,…,Sn]=[ξθt1,ξθt2],
and hence, [ξθt1,ξθt2]∈L(G′,ΓT′(t1,t2)).
□
The converse inclusion (i.e., L(Ran(G,T,x1,x2))⊆{[ξθx1,ξθx2]∣θ∈[[L(G,ΓT)]],…})
does not hold in general (cf. [22, Example 31]).
6 Conclusion
In this paper, under a certain syntactic condition, we showed a transformation of the grammar representation of a narrowing tree into an RTG that overapproximately generates the ranges of ground substitutions generated by the grammar representation.
We showed a precise definition of the transformation and proved that the language of the transformed RTG is an overapproximation of the ranges of ground substitutions generated by the grammar representation.
We will make an experiment to evaluate the usefulness of the transformation in e.g., proving confluence of CTRSs.
The syntactic assumption in Section 5 is a sufficient condition to, given an SSG, obtain an RTG that generates the ranges of ground substitutions generated by the SSG.
It is not known yet whether the assumption is a necessary condition or not.
We will try to clarify this point.
As stated in Section 5, the converse inclusion of Theorem 5.7, L(Ran(G,T,x1,x2))⊆{[ξθx1,ξθx2]∣θ∈[[L(G,ΓT)]],…}, does not hold in general.
However, the converse inclusion must hold for an SSG such that all substitutions in the SSG preserve linearity, i.e.,
for any substitution σ in the SSG, σx is linear for all x∈Dom(σ), and Var(σx)∩Var(σy)=∅ for all x,y∈Dom(σ) such that x=y.
We will prove this conjecture and try to find other sufficient conditions for the converse inclusion.
Acknowledgements
We gratefully acknowledge the anonymous reviewers for their useful comments and suggestions to improve the paper.
Bibliography30
The reference list from the paper itself. Each links out to its DOI / PubMed record.
1[1]
2[2] Franz Baader & Tobias Nipkow (1998): Term Rewriting and All That . Cambridge University Press, 10.1017/CBO 9781139172752 . · doi ↗
3[3] Hubert Comon, Max Dauchet, Rémi Gilleron, Florent Jacquemard, Denis Lugiez, Christof Löding, Sophie Tison & Marc Tommasi (2007): Tree Automata Techniques and Applications . Available on: http://www.grappa.univ-lille 3.fr/tata . Release October, 12th 2007.
4[4] Nachum Dershowitz, Mitsuhiro Okada & G. Sivakumar (1988): Canonical Conditional Rewrite Systems . In: Proceedings of the 9th International Conference on Automated Deduction , Lecture Notes in Computer Science 310, Springer, pp. 538–549, 10.1007/B Fb 0012855 . · doi ↗
5[5] Francisco Durán, Salvador Lucas, José Meseguer, Claude Marché & Xavier Urbain (2004): Proving termination of membership equational programs . In: Proceedings of the 2004 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-based Program Manipulation , ACM, pp. 147–158, 10.1145/1014007.1014022 . · doi ↗
6[6] Guillaume Feuillade & Thomas Genet (2003): Reachability in Conditional Term Rewriting Systems . Electronic Notes in Theoretical Computer Science 86(1), pp. 133–146, 10.1016/S 1571-0661(04)80658-3 . · doi ↗
7[7] Thomas Genet & Vlad Rusu (2010): Equational approximations for tree automata completion . Journal of Symbolic Computation 45(5), pp. 574–597, 10.1016/j.jsc.2010.01.009 . · doi ↗
8[8] Thomas Genet & Valérie Viet Triem Tong (2001): Reachability Analysis of Term Rewriting Systems with Timbuk . In Robert Nieuwenhuis & Andrei Voronkov, editors: Proceedings of the 8th International Conference on Logic for Programming, Artificial Intelligence, and Reasoning , Lecture Notes in Computer Science 2250, Springer, pp. 695–706, 10.1007/3-540-45653-8_48 . · doi ↗