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 predication RelExp(Exp1,...,Expk), k>=0, where each Expi is an expression - a term that may contain function calls and RelExp is an expression returning a k-ary relation rel’ such that the values of the argument expressions will satisfy the mode and type constraints of rel’ when it is called. Certain binary primitive relations, for example =,=?,in, can be written with the relation name between the arguments.
  • a not (exists VarSeq SConj ) negated condition, where VarSeq is a sequence of local variables of SConj, which is a Simple Conjunction. not is the QuLog negation-as-failure operator.
  • a predication, or a (..) bracketed Simple Conjunction, prefixed with once - find one solution only
  • a universally quantified implication of the form

    forall UVars (exists EVars1 SConj1 => exists EVars2 SConj2 )

    The UVars variables are universally quantified over the implication. The sequence of variables of EVarsi are existentially quantified over SConji, i=1,2. Each SConji is a Simple Conjunction.

  • a remote query of the form

    (Cond) query_at Agent

    (Var1 ... Varn :: Cond) query_at Agent

    (Num of Var1 ... Varn :: Cond) query_at Agent

    Remote queries are queries that are evaluated using relation definitions local to another QuLog process that the querying QuLog process is allowed to query. Cond is a complex conjunction except that its must not contain a remote query.

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.


On This Site