| MINERVAの新しい算術関数は、内蔵関数と全く同じように使用することが
できます。
算術表現の関数表記と関係を示す表記の両方の表記が可能です。
MINERVAの数値を求める述語について、
例えば、is/2 を例に挙げて考えます。
"Result = f(A,...,N)" のような関数は、
"f(A,...,N,Result)" の述語の探索として行なわれます。
これにより、MINERVAによる数式は、
計算途中の値を保持するための変数の記述を省略することができ、
理解しやすくなっています。
% example: compute the cost for industrial urethane foam
% notation as relations
a(Price) :-
height(H), width(W), depth(D),
unit_price_per_volume(U),
Price is H * W * D * U.
% notation as functions
b(Price) :-
Price is height * width * depth * unit_price_per_volume.
% uniform notation of functions resp. data base
height(6).
depth(38).
width(75).
unit_price_per_volume(0.01).
上のプログラムの結果は以下の通りです。
?- a(Price).
Price = 171.0
yes
?- b(Price).
Price = 171.0
yes
?-
|