Computational Logic CLP Semantics and Fundamental Results

## Constraint Domains

• Semantics parameterized by the constraint domain:
CLP(), where
• Signature : set of predicate and function symbols, together with their arity
• -formulae: constraints
• D is the set of actual elements in the domain

• -structure : gives the meaning of predicate and function symbols (and hence, constraints).

• a first-order theory (axiomatizes some properties of )
• ) is a constraint domain
• Assumptions:
• built upon a first-order language
• is identity in
• There are identically false and identically true constraints in
• is closed w.r.t. renaming, conjunction and existential quantification

## Domains (I)

• , D = R, interprets as usual,
• Arithmetic over the reals
• Eg.:
• Question: is needed? How can it be represented?

• Let us assume ,
• Linear arithmetic
• Eg.:

• Let us assume ,
• Linear equations
• Eg.:

## Domains (II)

• constant and function symbols
• D = { finite trees }
• interprets as tree constructors
• Each with arity maps trees to a tree with root labeled and whose subtrees are the arguments of the mapping
• Constraints: syntactic tree equality
• Constraints over the Herbrand domain
• Eg.:
• LP CLP()

## Domains (III)

• constants
• D = { finite strings of constants }
• interprets . as string concatenation, :: as string length
• Equations over strings of constants
• Eg.:

• D =
• interprets symbols in as boolean functions
• Boolean constraints
• Eg.:

## CLP() Programs

• Recall that:
• is a set of predicate and function symbols
• -formulae are the constraints
• : set of predicate symbols definable by a program
• Atom: , where are terms and
• Primitive constraint: , where
are terms and is a predicate symbol
• Every constraint is a (first-order) formula built from primitive constraints
• The class of constraints will vary (generally only a subset of formulas are considered constraints)
• A CLP program is a collection of rules of the form where is an atom and the 's are atoms or constraints
• A fact is a rule where is a constraint
• A goal (or query) is a conjunction of constraints and atoms

## Basic Operations on Constraints

• Constraint domains are expected to support some basic operations on constraints
1. Consistency (or satisfiability) test: ,
2. Implication or entailment: ,
3. Projection of a constraint onto variables to obtain a constraint such that ,
4. Detection of uniqueness of variable value:
• Actually, only the first one is really required
• In actual implementations, some of these operations--in particular the test of consistency--may be incomplete

• Examples:
• is inconsistent in (because )
• in
• In , the projection of on is
• In ,

• Prove the last assertion!

## Properties of CLP Languages

• axiomatizes some of the properties of
• For a given , let be a constraint domain with signature , and a -theory.
• and correspond on if:
• is a model of , and
• for every constraint , iff .
• is satisfaction complete with respect to if for every constraint , either or .
• is solution compact if

i.e., any negated constraint in can be expressed as a (in)finite disjunction of constraints

## Solution Compactness

• Important to lift SLDNF results to CLP()
• We have to deal only with user predicates

• E.g.
• in CLP() is
• in CLP() is
• with constraint is not s.c.

• How can we express in CLP()?

## Logical Semantics (I)

• Two common logical semantics exist.
• The first one interprets a rule

as the logic formula

## Logical Semantics (II)

• The second one associates a logic formula to each predicate in
• If the set of rules of with in the head is:

then the formula associated with is:

• If does not occur in the head of a rule of , the formula is:

• The collection of all such formulas is the Clark completion of (denoted by )

• These two semantics differ on the treatment of the negation

## Logical Semantics (III)

• A valuation is a mapping from variables to , and the natural extension which maps terms to and formulas to closed -formulas.
• A -interpretation of a formula is an interpretation of the formula with the same domain as and the same interpretation for the symbols in as .
• It can be represented as a subset of where

• A -model of a closed formula is a -interpretation which is a model of the formula.
• The usual logical semantics is based on the -models of and the models of , .
• The least -model of a formula is denoted by .
• A solution to a query is a valuation such that .

## Fixpoint Semantics

• Based on one-step consequence operator (also called immediate consequence operator'').

• Take as semantics , where:

• Theorems:

## Top-Down Operational Semantics (I)

• General framework for operational semantics
• Formalized as a transition system on states
• State: a 3-tuple , or , where
• is a multiset of atoms and constraints,
• multiset of constraints,
• , active constraints (awake)
• , passive constraints (asleep)
• Computation and Selection rules depend on A
• Transition system: parameterized by a predicate and a function :
• checks the consistency of a constraint store
• Usually  iff '', but sometimes if then ''
• computes a new set of active and passive constraints

## Top-Down Operational Semantics (II)

• Transition : computation step; rewriting using user predicates

if , and and have the same predicate symbol, or

if there is no rule of such that and have the same predicate symbol ( is a set of argument-wise equations) if is a predicate symbol selected by the computation rule

• Transition : selects constraints

if is a constraint selected by the computation rule
• Transition : infers new constraints

• In particular, may turn passive constraints into active ones
• Transition : checks satisfiability

## Top-Down Operational Semantics (III)

• Initial state:
• Derivation:
• Final state:
• Successful derivation: final state
• A derivation flounders if finite and the final state is with
• A derivation is failed if it is finite and the final state is fail

• Answer: , where are the variables in the initial goal
• A derivation is fair if it is failed or, for every and every , is rewritten in a later transition
• A computation rule is fair if it gives rise only to fair derivations

## Top-Down Operational Semantics (IV)

• Computation tree for goal and program :
• Nodes labeled with states
• Edges labeled with , , or
• Root labeled by
• All sons of a given node have the same label
• Only one son with transitions , or
• A son per program clause with transition

## Computation Tree: Example

• Consider the program

and the goal
• A possible computation tree is:

• Dotted rectangle: previous state was final as well

## Types of CLP() Systems

• Quick-checking CLP() system: its operational semantics can be described by and
• I.e., always selects either an atom or a constraint, infers and checks consistency
• Progressive CLP system: for all with , every derivation from that state either fails or contains a or transition
• Ideal CLP system:
• Quick-checking
• Progressive
• holds iff

## Soundness and Completeness Results

• Success set: the set of queries plus constraints which have a successful derivation in the program:

• Consider a program in the CLP language determined by a 4-tuple and executing on an ideal CLP system. Then:

1. , where

2. (Soundness) if the goal has a successful derivation with answer constraint , then
3. (Completeness) if then there are derivations for the goal with answer constraints such that
4. Assume is satisfaction complete w.r.t. . Then the goal is finitely failed for iff .

## Negation in CLP()

• Most LP results can be lifted to CLP()
• In particular, negation as failure (à la SLDNF) is still valid using: