Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
the set of demanded positions of a call pattern π w.r.t. a set of rules R. For instance, the demanded<br />
positions of the call pattern leq(x,y) w.r.t. the rules for the predicate leq (see Section 17, page 65)<br />
are {1, 2} referring to the pattern variables x and y. Furthermore, we define by<br />
IP (π, R) = {o ∈ DP (π, R) | root(l|o) ∈ C for all l = r ∈ R}<br />
the set of inductive positions of a call pattern π w.r.t. a set of rules R. Thus, the inductive<br />
positions are those demanded positions where a constructor occurs in all left-hand sides defining<br />
this function. For instance, the set of inductive positions of the call pattern leq(x,y) w.r.t. the<br />
rules for the predicate leq is {1}.<br />
The generation of a definitional tree for a call pattern π and a set of rules R (where l is<br />
an instance of π for each l = r ∈ R) is described by the function gt(π, m, R) (m ∈ {flex, rigid}<br />
determines the mode annotation in the generated branch nodes). We distinguish the following<br />
cases for gt:<br />
1. If the position o is leftmost in IP (π, R), {root(l|o) | l = r ∈ R} = {c1, . . . , ck} where c1, . . . , ck<br />
are different constructors with arities n1, . . . , nk, and Ri = {l = r ∈ R | root(l|o) = ci}, then<br />
gt(π, m, R) = branch(π, o, m, gt(π[c1(x11, . . . , x1n1 )]o, m, R1),<br />
. . . ,<br />
gt(π[ck(xk1, . . . , xknk )]o, m, Rk))<br />
where xij are fresh variables. I.e., we generate a branch node for the leftmost inductive<br />
position (provided that there exists such a position).<br />
2. If IP (π, R) = ∅, let o be the leftmost position in DP (π, R) and R ′ = {l = r ∈ R | root(l|o) ∈<br />
C}. Then<br />
gt(π, m, R) = or(gt(π, m, R ′ ), gt(π, m, R − R ′ ))<br />
I.e., we generate an or node if the leftmost demanded position of the call pattern is not<br />
demanded by the left-hand sides of all rules.<br />
3. If DP (π, R) = ∅ and l = r variant of some rule in R with l = π, then<br />
gt(π, m, R) = rule(l = r)<br />
Note that all rules in R are variants of each other if there is no demanded position (this<br />
follows from the weak orthogonality of the rewrite system). For non-weakly orthogonal rewrite<br />
systems, which may occur in the presence of non-deterministic functions [18] or conditional<br />
rules, the rules in R may not be variants. In this case we simply connect the different rules<br />
by or nodes.<br />
If R is the set of all rules defining the n-ary function f, then a definitional tree for f is generated by<br />
computing gt(f(x1, . . . , xn), m, R), where m = rigid if the type of f has the form · · ·->IO ..., i.e.,<br />
if f denotes an IO action, and m = flex otherwise (this default can be changed by the evaluation<br />
annotation “eval rigid”, see Section 3).<br />
71