Control constructs/predicates

Author(s): Daniel Cabeza, Manuel Hermenegildo.

This module contains the set of basic control predicates, except the predicates dealing with exceptions, which are in Exception and Signal handling.

Usage and interface

Documentation on exports

PREDICATE
P,Q

Conjunction (P and Q).
Meta-predicate with arguments: goal,goal.

Usage: ISO

  • The following properties should hold at call time:
    (basic_props:callable/1)P is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:callable/1)Q is a term which represents a goal, i.e., an atom or a structure.

PREDICATE
P;Q

Disjunction (P or Q). Note that in Ciao |/2 is not equivalent to ;/2.
Meta-predicate with arguments: goal;goal.

Usage: ISO

  • The following properties should hold at call time:
    (basic_props:callable/1)P is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:callable/1)Q is a term which represents a goal, i.e., an atom or a structure.

PREDICATE
P->Q

If P then Q else fail, using first solution of P only. Also, (P -> Q ; R), if P then Q else R, using first solution of P only. No cuts are allowed in P.
Meta-predicate with arguments: goal->goal.

Usage: ISO

  • The following properties should hold at call time:
    (basic_props:callable/1)P is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:callable/1)Q is a term which represents a goal, i.e., an atom or a structure.

PREDICATE

Usage: ISO

  • Description: Commit to any choices taken in the current predicate.
  • The following properties hold globally:
    (native_props:is_det/1)All calls of the form ! are deterministic.
    (native_props:not_fails/1)All the calls of the form ! do not fail.
    (native_props:relations/2)Goal ! produces 1 solutions.

PREDICATE
\+P

Goal P is not provable (negation by failure). Fails if P has a solution, and succeeds otherwise. No cuts are allowed in P.
Meta-predicate with arguments: \+goal.

Usage: ISO

  • The following properties should hold at call time:
    (basic_props:callable/1)P is a term which represents a goal, i.e., an atom or a structure.
  • The following properties hold globally:
    (basic_props:native/2)This predicate is understood natively by CiaoPP as not(X).
    (native_props:is_det/1)All calls of the form \+P are deterministic.

PREDICATE
if(P,Q,R)

If P then Q else R, exploring all solutions of P. No cuts are allowed in P.
Meta-predicate with arguments: if(goal,goal,goal).

Usage: if(A,B,C)

  • The following properties should hold at call time:
    (term_typing:nonvar/1)A is currently a term which is not a free variable.
    (term_typing:nonvar/1)B is currently a term which is not a free variable.
    (term_typing:nonvar/1)C is currently a term which is not a free variable.
    (basic_props:callable/1)A is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:callable/1)B is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:callable/1)C is a term which represents a goal, i.e., an atom or a structure.
  • The following properties hold upon exit:
    (basic_props:callable/1)A is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:callable/1)B is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:callable/1)C is a term which represents a goal, i.e., an atom or a structure.

PREDICATE

General properties:
  • The following properties hold globally:
    (basic_props:eval/1)true is evaluable at compile-time.

Usage: ISO

  • Description: Succeed (noop).
  • The following properties hold globally:
    (basic_props:native/1)This predicate is understood natively by CiaoPP.
    (basic_props:sideff/2)true is side-effect free.
    (native_props:is_det/1)All calls of the form true are deterministic.
    (native_props:not_fails/1)All the calls of the form true do not fail.
    (native_props:relations/2)Goal true produces 1 solutions.

PREDICATE

General properties:
  • The following properties hold globally:
    (basic_props:eval/1)fail is evaluable at compile-time.
  • The following properties hold globally:
    (basic_props:equiv/2)fail is equivalent to fail.

Usage: ISO

  • Description: Fail, backtrack immediately.
  • The following properties hold globally:
    (basic_props:native/1)This predicate is understood natively by CiaoPP.
    (basic_props:sideff/2)fail is side-effect free.
    (native_props:is_det/1)All calls of the form fail are deterministic.
    (native_props:fails/1)Calls of the form fail fail.
    (native_props:relations/2)Goal fail produces 0 solutions.

PREDICATE

Usage: ISO

  • Description: Generates an infinite sequence of backtracking choices.
  • The following properties hold globally:
    (basic_props:native/1)This predicate is understood natively by CiaoPP.
    (basic_props:sideff/2)repeat is side-effect free.

PREDICATE

General properties:
  • The following properties hold globally:
    (basic_props:sideff/2)false is side-effect free.
    (basic_props:eval/1)false is evaluable at compile-time.

PREDICATE

General properties:
  • The following properties hold globally:
    (basic_props:sideff/2)otherwise is side-effect free.
    (basic_props:eval/1)otherwise is evaluable at compile-time.

Known bugs and planned improvements

  • Run-time checks have been reported not to work with this code. That means that either the assertions here, or the code that implements the run-time checks are erroneous.