COGENT Online |

CONTENTS |

COGENT Help |

See also: Processes

Built-in conditions are accessed via a series of pull-down menus in the Rule editor and Condition Editor. They are intended to simplify programming, by predefining a wide range of primitive facilities, and by helping the user to avoid several common syntax errors.

**member**

*Term* **is a member of** *List*
Succeeds if *Term* can be matched with a member of *List*.
*List* should normally be instantiated. If *Term* matches with
more than one element of *List* (e.g. if *Term* is
uninstantiated), **member** will re-satisfy for each distinct
possibility.

**length**

*Integer* **is the length of** *List*

Succeeds if *Integer* can be matched with the
length of *List*. *List* should be instantiated.

**replace**

**replace the first** *Term1* **in** *List1* **with** *
Term2* **to give** *List2*

Succeeds if *List2* results from replacing the first instance of
*Term1* in *List1* with *Term2*. *Term1*, *
Term2* and *List1* should be instantiated.

**replace all**

**replace each** *Term1* **in** *List1* **with** *
Term2* **to give** *List2*

Succeeds if *List2* results from replacing all instances of
*Term1* in *List1* with *Term2*. *Term1*, *
Term2* and *List1* should be instantiated.

**sort**

*List1* **results from sorting** *List2*

Succeeds if *List1* is the result of sorting *List2*. *
List2* should be instantiated.

**first element**

*Term* **is the first element of** *List*

Succeeds if *Term* can be matched with the first element of
*List*. *List* should normally be instantiated.

**last element**

*Term* **is the last element of** *List*

Succeeds if *Term* can be matched with the last element of
*List*. *List* should normally be instantiated.

**append**

*List1* **results from appending** *List2* **to** *List3*

Succeeds if *List1* is the result of appending *List2* to
*List3*. With *List2* and *List3* instantiated, and
*List1* uninstantiated, **append** will create a new *
List1*; however, with only *List1* instantiated, **append**
will split the list into two parts, re-satisfying once for each
possible pair of sublists.

**delete**

*List1* **results from deleting** *Term* **from** *List2*

Succeeds if *List1* is the result of deleting a term which
matches with *Term* from *List2*. If *Term* matches
more than one element of *List2* (e.g. if *Term* is
uninstantiated), **delete** will re-satisfy for each distinct
possibility.

**sublist**

*List1* **is a sublist of** *List2*

Succeeds if *List1* is a sublist of *List2*. *List2*
should normally be instantiated. If *List1* is uninstantiated,
**sublist** should re-satisfy for all possible sublists.

**findall**

*List* **is the list of all** *Term* **such that** `CONDITION`

Succeeds if *List* matches the list of all *Term such that
some condition CONDITION holds. CONDITION is selected as a
subcondition using the usual pull-down condition editor
menus. Normally Term will contain at least one uninstantiated
variable which also occurs in CONDITION, so that List is
a list of solutions to CONDITION.*

**is**

*Number* **is** *Expression*

Succeeds if *Number* matches the result of evaluating the
arithmetic expression *Expression*. Allowable operators in *
Expression* will depend on the underlying Prolog implementation; see
your Prolog manual for details. Note, however, that COGENT
provides built-in conditions for many arithmetic and mathematical
functions, independently of Prolog implementation --- these are listed
below.

**plus**

*Number1* **is** *Number2* **+** *Number3*

**minus**

*Number1* **is** *Number2* **-** *Number3*

**times**

*Number1* **is** *Number2* ***** *Number3*

**divide**

*Number1* **is** *Number2* **/** *Number3*

**sqrt**

*Number1* **is the square root of** *Number2*

**abs**

*Number1* **is the absolute value of** *Number2*

**log**

*Number1* **is the natural log of** *Number2*

**exp**

*Number1* **is e to the power** *Number2*

**power**

*Number1* **is** *Number2* **to the power** *Integer*

**sigmoid**

*Number1* **is sigmoid(** *Number2* **)**

**factorial**

*Integer1* **is** *Integer2* **factorial**

**random number: uniform**

*Number* **is randomly drawn from U(** *LowerBound* **,** *UpperBound* **)**

Succeeds if *Number* matches a random number drawn from the
uniformly distributed interval [*LowerBound*,*
Upperbound*). Unlikely to succeed if *Number* is instantiated.

**random number: normal**

*Number* **is randomly drawn from N(** *Mean* **,** *Variance* **)**

Succeeds if *Number* matches a random number drawn from the
normal distribution with the specified *Mean* and *
Variance* (=S.D.^2). Unlikely to succeed if *Number* is
instantiated.

**random number: integer**

*Number* **is a random integer drawn from ** *LowerBound* **to** *UpperBound* **inclusive**

Succeeds if *Number* matches a random integer drawn from the
interval from *LowerBound* to *
Upperbound* inclusive. Unlikely to succeed if *Number* is instantiated.

**trig function: sin**

*Number1* **is sin(** *Number2* **)**

Succeeds if *Number1* is the sine of *Number2* (expressed
in radians). Same for the other trig functions below.

**trig function: cos**

*Number1* **is sin(** *Number2* **)**

**trig function: tan**

*Number1* **is sin(** *Number2* **)**

**trig function: asin**

*Number1* **is sin(** *Number2* **)**

**trig function: acos**

*Number1* **is sin(** *Number2* **)**

**trig function: atan**

*Number1* **is sin(** *Number2* **)**

**List Arithmetic: minimum value**

*Number* **is the smallest numeric element in** *List*

**List Arithmetic: maximum value**

*Number* **is the largest numeric element in** *List*

**List Arithmetic: sum**

*Number* **is the sum of the elements of** *List*

**List Arithmetic: product**

*Number* **is the product of the elements of** *List*

**List Arithmetic: arithmetic mean**

*Number* **is the average of the elements of** *List*

**List Arithmetic: geometric mean**

*Number* **is the geometric mean of the elements of** *List*

**List Arithmetic: standard deviation**

*Number* **is the s.d of the elements of** *List*

**List Arithmetic: dot product**

*Number* **is the dot product of** *List1* **and** *List2*

**atom**

*Term* **is an atom**

Succeeds if *Term* is an atom.

**integer**

*Term* **is an integer**

Succeeds if *Term* is an integer.

**number**

*Term* **is a number**

Succeeds if *Term* is a (possibly floating-point) number.

**variable**

*Term* **is a variable**

Succeeds if *Term* is an uninstantiated variable.

**is identical to**

*Term1* **==** *Term2*

Succeeds if *Term1* is strictly equal to *Term2*. That is,
uninstantiated variables must occur in the same places in both terms,
as well as all other elements being equal.

**is distinct from**

*Term1* **\==** *Term2*

Succeeds if *Term1* is not strictly equal to *Term2*. See
**is identical to** for a definition of strict equality.

**unifies with**

*Term1* **=** *Term2*

Succeeds if *Term1* unifies with (matches) *Term2*. May
result in instantiation of uninstantiated variables in either term.

**arithmetic: is equal to**

*Number* **=:=** *Expression*

Succeeds if *Number* is equal to the evaluation of *
Expression. Use in preference to is for equality checking,
since is doesn't force types.*

**arithmetic: is not equal to**

*Number* **=\=** *Expression*

**arithmetic: is less than**

*Number1* **<** *Number2*

**arithmetic: is not less than**

*Number1* **>=** *Number2*

**arithmetic: is greater than**

*Number1* **>** *Number2*

**arithmetic: is not greater than**

*Number1* **=<** *Number2*

**alphanumeric: is before**

*Atom1* **@<** *Atom2*

Succeeds if *Atom1* is before *Atom2* in alphanumeric
comparison (similar to alphabetic order). Similarly for the other
alphanumeric comparisons.

**alphanumeric: is not before**

*Atom1* **@>=** *Atom2*

**alphanumeric: is after**

*Atom1* **@>** *Atom2*

**alphanumeric: is not after**

*Atom1* **@=<** *Atom2*

**match**

*Term* is in `BUFFER`

Succeeds if *Term* can be matched with an item in the selected
`BUFFER`. `BUFFER` is selected from a pull-down menu listing
all accessible buffers.

**!**

**!**

The prolog cut (only available in the condition editor).

**call**

**call** *Term*

Succeeds if *Term* succeeds as a Prolog goal. This is used
for calling built-in Prolog predicates.

**call in module**

**call** *Term* **in** `BUFFER`

Succeeds if *Term* matches a condition defined within the selected
`BUFFER`. This is used for calling procedures/methods defined within
buffers. Such definitions are appropriate when the procedures depend upon the
the buffer's properties or the buffer's contents.

**get value of property**

**the value of the** `PROPERTY` **property is** *Term*

Succeeds if `PROPERTY` (which is selected from a pull-down menu) is a
property of the current box, and the value of that property within the current
box unifies with *Term*. This is used for retrieving the values of
properties of modules.

**current cycle**

**the current cycle is** *Integer*

Succeeds if *Integer* matches an integer specifying the
current COGENT cycle number.

**current trial**

**Trial** *Integer1* **of** *Integer2*

Succeeds if *Integer1* matches an integer specifying the
current COGENT trial number and *Integer2* matches the total
number of trials in the current block.

**current block**

**the current block is** *Integer*

Succeeds if *Integer* matches an integer specifying the
current COGENT block number.

**current subject**

**the current subject is** *Integer*

Succeeds if *Integer* matches an integer specifying the
current COGENT subject number.

**not**

**not** `CONDITION`

Succeeds if `CONDITION` fails.

**exists**

**exists** `CONDITION`

Succeeds if `CONDITION` succeeds, but without instantiating any
variables in `CONDITION`. Equivalent to **not not** `
condition.`

**once**

**once** `CONDITION`

Permits `CONDITION` to succeed only once, without re-satisfying.

**unique**

**unique** `CONDITION`

Succeeds if `CONDITION` has a unique solution, i.e. if `CONDITION` succeeds only once.

**trace**

**trace** `CONDITION`

Succeeds if the `CONDITION` succeeds, with the side-effect of
printing the condition on the process box's Messages window, for debugging purposes.

COGENT Online |

CONTENTS |

COGENT Help |