Next: , Previous: , Up: Programs   [Contents][Index]


3.9.3 Complex Conjunctions

An interpreter relation query is a Complex Conjunction.

This has the form:

Cond1 & Cond2 & ... & Condn, n>=1 where each condi is one of:

A Simple Conjunction is a Complex Conjunction which does not contain any forall

In a negated condition the existentially quantified variables are local variables of SConj, variables that do not appear elsewhere in the query or rule body in which the negation appears. All other variable of SimpleConj, except underscore anonymous variables, must be given ground values before the condition is evaluated. Underscore variables are always implicitly existentially quantified just before the predication in which they appear. If there are no such local variables the exists VarSeq is absent.

The type of call is call: rel(!relcall). relcall is the system type comprising all terms that denote type correct calls to primitive or program defined relations. For the relcall type the ! mode has a special meaning. It does not mean that Var has to be a ground term. It means only that all input arguments of the type declaration of the relation named by the functor of its compound term value must be ground. This is often guaranteed by preceding the meta call with the type test type(Var,!relcall).

In a forall, each variable in UVars must appear in both SimpleConj1 and SimpleConj2. It must be a local variable of the forall. All other variables of the forall, except the existentially quantified variables and underscore variables, must have ground values when the forall condition is evaluated. Each EVarsi contains variables local to SimpleConji. If there are no existentially quantified variable, for either the antecedent or consequent, the exists operator is dropped.

Suppose we have a collection of child_of(C, P), age_is and male dynamic relation facts. The following query will return as an answer each parent who only has male children age over 17.

 child_of(_, P) & forall C (child_of(C,P) => 
                          exists A (male(C) & age_is(C,A) & A>17))

Note that P will be given a value before the evaluation of the forall, as required.


Next: , Previous: , Up: Programs   [Contents][Index]