Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Eval [ei ] ⇒ D<br />
Eval [e1=:=e2 ] ⇒ replace(e1=:=e2, i, D) if ei = f(t1, . . . , tn), i ∈ {1, 2}<br />
Eval [c(e1, . . . , en)=:=c(e ′ 1 , . . . , e′ n)] ⇒ {id e1=:=e ′ 1 & . . . & en=:=e ′ n}<br />
Eval [c(e1, . . . , en)=:=d(e ′ 1 , . . . , e′ m)] ⇒ ∅<br />
Eval [x=:=e] ⇒ D<br />
Eval [e=:=x] ⇒ D<br />
if e is not a variable<br />
Eval [x=:=y ] ⇒ {{x ↦→ y} success}<br />
if c �= d or n �= m<br />
Eval [x=:=c(e1, . . . , en)] ⇒ {σ y1=:=σ(e1) & . . . & yn=:=σ(en)}<br />
Eval [x=:=c(e1, . . . , en)] ⇒ ∅ if x ∈ cv(c(e1, . . . , en))<br />
Figure 4: Solving equational constraints<br />
if x �∈ cv(c(e1, . . . , en)),<br />
σ = {x ↦→ c(y1, . . . , yn)},<br />
y1, . . . , yn fresh variables<br />
lazy evaluation of the expressions and binding of variables to constructor terms. The evaluation<br />
steps implementing this method are shown in Figure 4, where we consider the symbol =:= is a<br />
binary infix function symbol. The last two rules implements an occur check where the critical<br />
variables (cv) are only those variables occurring outside a function call:<br />
cv(x) = {x}<br />
cv(c(e1, . . . , en)) = cv(e1) ∪ . . . ∪ cv(en)<br />
cv(f(e1, . . . , en)) = ∅<br />
However, <strong>Curry</strong> implementations can also provide other methods to solve equational constraints<br />
or other types of constraints with appropriate constraint solvers. The only property, which is<br />
important for the operational semantics, is the fact that a solved constraint has the form success,<br />
i.e., a solvable constraint c is reducible to the answer expression σ success where σ is a solution<br />
of c.<br />
D.5 Higher-Order Features<br />
Warren [49] has shown for the case of logic programming that the higher-order features of functional<br />
programming can be implemented by providing a (first-order) definition of the application function.<br />
Since <strong>Curry</strong> supports the higher-order features of current functional languages but excludes the<br />
guessing of higher-order objects by higher-order unification (as, e.g., in [24, 38, 43]), the operational<br />
semantics specified in Figure 2 can be simply extended to cover <strong>Curry</strong>’s higher-order features by<br />
adding the following axiom (here we denote by the infix operator “@” the application of a function<br />
69