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


4.10.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 not (exists VarSeq SConj ) negated condition the existentially quantified variable sequence VarSeq must contain all the named local variables of SConj. These are the variables that do not appear elsewhere in the query or rule body in which the negation appears. All other variables 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 named local variables in SConj the exists VarSeq is absent.

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.

The special relation =? is used to split up lists and string based on patterns and tests.

For lists the general form is

GroundList =? ListPattern1 :: Cond1 <> ... <> ListPatternn :: Condn

where GroundList is a ground list, ListPatterni are list patterns - a variable, a list possibly containing variables or have a variable tail. Condi are conditions and the :: Condi can be elided if Condi is simply true.

For strings the general form is

String =? StringPattern1 / REString1 :: Cond1 ++ ... ++ StringPatternn / REStringn :: Condn

where String is a string, StringPatterni are either variables or strings, REStringi are strings (regular expressions) and Condi are conditions. Both the / REStringi and :: Condi can be elided.

Examples of use of conditions that can be used in a complex conjunction and semantics are given in the semantics section.


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