next up previous
Next: Resource Consumption Up: RESOURCE HANDLING Previous: RESOURCE HANDLING

Resource Addition

Resource is added by the execution of a goal formula tex2html_wrap_inline387 . For example, the following query adds a resource r(1) to the resource table, then executes a goal r(X) which consumes r(1) by letting tex2html_wrap_inline389 .

?- r(1) -<> r(X).
In the execution of the goal tex2html_wrap_inline387 , all resources in R should be consumed up during the execution of G. For example, the following query fails since r(1) is not consumed.
?- r(1) -<> true.

Resource formula tex2html_wrap_inline397 is used to represent a rule-type resource. The goal G is executed on resource consumption. The following query displays 1.

?- (write(X) -<> r(X)) -<> r(1).

Resource formula tex2html_wrap_inline401 is used to add multiple resources. The following query adds resources r(1) and r(2), then consumes both of them by letting tex2html_wrap_inline389 and tex2html_wrap_inline405 , or tex2html_wrap_inline407 and tex2html_wrap_inline409 .

?- (r(1), r(2)) -<> (r(X), r(Y)).

Resource formulas tex2html_wrap_inline411 and tex2html_wrap_inline413 mean infinite resources, that is, they can be consumed arbitrary times (including zero times). The following query succeeds by letting tex2html_wrap_inline389 or tex2html_wrap_inline407 .

?- (!r(1), !r(2)) -<> (r(X), r(X)).

Resource formula tex2html_wrap_inline419 is used to represent a selective resource. For example, when r(1)&r(2) is added as a resource, either r(1) or r(2) can be consumed, but not both of them. The following query succeeds by letting tex2html_wrap_inline421 or tex2html_wrap_inline423 .

?- (r(1) & r(2)) -<> r(X).

Naoyuki Tamura
Thu May 8 20:39:01 JST 1997