Computational Logic
 Logic Programming: Model and Fixpoint Semantics

## Towards the Model and Fixpoint Semantics

• We have seen previously the operational semantics (SLD-resolution).
• We now present the (declarative) Model Semantics:
• We define our semantic domain (Herbrand interpretations).
• We introduce the Minimal Herbrand Model.
• And the (also declarative) Fixpoint Semantics.
• We recall some basic fixpoint theory.
• Present the operator and the classic fixpoint semantics.

## Declarative Semantics - Herbrand Base and Universe

• Given a first-order language , with a non-empty set of variables, constants, function symbols, relation symbols, connectives, quantifiers, etc. and given a syntactic object ,

i.e. the set of all ground instances'' of .

• Given , (Herbrand universe) is the set of all ground terms of .

• (Herbrand Base) is the set of all ground atoms of .

• Similarly, for the language associated with a given program we define , and .

## Declarative Semantics - Herbrand Base and Universe (example)

• Program:


}


• Herbrand universe:

• Herbrand base:

## Herbrand Interpretations and Models

• A Herbrand Interpretation is a subset of , i.e. the set of all Herbrand interpretations .

(Note that forms a complete lattice under - important for fixpoint operations to be introduced later).

• In previous example:

all subsets of

• A Herbrand Model is a Herbrand interpretation which contains all logical consequences of the program.

• The Minimal Herbrand Model is the smallest Herbrand interpretation which contains all logical consequences of the program. (Theorem: it is unique.)

• Example:

## Declarative Semantics, Completeness, Correctness

• Declarative semantics of a logic program :
the set of ground facts which are logical consequences of the program (i.e., ).
(I.e., the Minimal Herbrand model (or least model'') of ).

• Intended meaning of a logic program :
the set of ground facts that the user expects to be logical consequences of the program.

• A logic program is correct if .

• A logic program is complete if .

• Example:
father(john,peter).
father(john,mary).
mother(mary,mike).
grandfather(X,Y) father(X,Z), father(Z,Y).

with the usual intended meaning is correct but incomplete.

## Towards a Fixpoint Semantics for LP - Fixpoint Basics

• A fixpoint for an operator is an element of such that .

• If is a poset, is monotonic if

• If is a complete lattice and is monotonic the set of fixpoints of is also a complete lattice [Tarski]

• The least element of the lattice is the least fixpoint of , denoted

• Powers of a monotonic operator (successive applications):

We abbreviate as

• There is some such that . The sequence is the Kleene sequence for

• In a finite lattice the Kleene sequence for a monotonic operator is finite

## Towards a Fixpoint Semantics for LP - Fixpoint Basics (Contd.)

• A subset of a poset is an (ascending) chain iff

• A complete lattice is ascending chain finite (or Noetherian) if all ascending chains are finite

• In an ascending chain finite lattice the Kleene sequence for a monotonic operator is finite

## A Fixpoint Semantics for Logic Programs

• Semantic domain: .

• I.e., the elements of the semantic domain and interpretations
(subsets of the Herbrand base).

• Semantic operator (defined on programs):
the immediate consequences operator, :

• is a mapping: defined by:

(in particular, if , then every element of is in , ).

• is monotonic, so:
• it has a least fixpoint so that ,
• this fixpoint can be obtained by applying iteratively starting from the bottom element of the lattice (the empty interpretation).

## A Fixpoint Semantics for Logic Programs: Example 1 (finite)



}





all subsets of

## A Fixpoint Semantics for Logic Programs: Example 2 (infinite)



}


all subsets of

where we define to be nested times and then applied to .
(i.e., )

## A Fixpoint Semantics for Logic Programs: Example 3 (infinite)

• Example:


}


(i.e., ).

(i.e., ).

## A Fixpoint Semantics for Logic Programs: Example 3 (infinite, cont.)

Constructing the least fixpoint of the operator:


=

=

=

=

...

=


where we define to be nested times and then applied to .

## Semantics - Equivalences

• (Characterization Theorem) [Van Emden and Kowalski]
A program has a Herbrand model such that :
• is the least Herbrand Model of .
• is the least fixpoint of ().
• .

I.e., least model semantics () fixpoint semantics ()

• In addition, there is also an equivalence with the operational semantics (SLD-resolution):
• SLD-resolution answers yes'' to .

• Because it gives us a way to directly build (for finite models), the least fixpoint semantics can in some cases also be an operational semantics (e.g., for datalog in deductive databases).

Last modification: Wed Jan 3 19:10:57 CET 2007 <webmaster@clip.dia.fi.upm.es>