25
The Semantics of Logic Programs
will be treated slightly differently, and we will return to this point later, see
the examples following Definition 2.1.6.
We illustrate Definition 2.1.1 with a number of example programs, to which
we will return frequently later. At all times, unless stated to the contrary,
we will adhere to the following notational conventions concerning programs:
constant, function, and predicate symbols start with a lowercase letter and
are set in typewriter font unless they consist of a single letter only; variable
symbols start with an uppercase letter.
2.1.2 Program (Tweety1) Let Tweety1
2 be the program consisting of the
following clauses.
penguin(tweety) ←
bird(bob) ←
bird(X) ← penguin(X)
flies(X) ← bird(X), ¬penguin(X)
Tweety1 is intended to represent the following knowledge: tweety is a penguin,
bob is a bird, all penguins are birds, and every bird which is not a penguin
can fly.
2.1.3 Program (Even) Let Even be the program consisting of the following
clauses.
even(a) ←
even(s(X)) ← ¬even(X)
The intended meaning of this program is as follows: a is the natural number
0, and s is the successor function on natural numbers. Thus, the program
represents the knowledge that 0 is even, and if some number is not even, then
its successor is even.
Many of our later examples will be variations of the Even program theme
and will employ the successor notation for natural numbers. Consider, for
example, the following program.
2.1.4 Program (Length) Let Length be the program consisting of the following clauses.
length([], a) ←
length([H|T ], s(X)) ← length(T, X)
Following Prolog conventions, [] denotes the empty list, and [ · | · ] denotes
2 We borrow Tweety programs, in which a penguin usually called Tweety appears, from
the literature discussing the semantics of non-monotonic reasoning.
The Semantics of Logic Programs
will be treated slightly differently, and we will return to this point later, see
the examples following Definition 2.1.6.
We illustrate Definition 2.1.1 with a number of example programs, to which
we will return frequently later. At all times, unless stated to the contrary,
we will adhere to the following notational conventions concerning programs:
constant, function, and predicate symbols start with a lowercase letter and
are set in typewriter font unless they consist of a single letter only; variable
symbols start with an uppercase letter.
2.1.2 Program (Tweety1) Let Tweety1
2 be the program consisting of the
following clauses.
penguin(tweety) ←
bird(bob) ←
bird(X) ← penguin(X)
flies(X) ← bird(X), ¬penguin(X)
Tweety1 is intended to represent the following knowledge: tweety is a penguin,
bob is a bird, all penguins are birds, and every bird which is not a penguin
can fly.
2.1.3 Program (Even) Let Even be the program consisting of the following
clauses.
even(a) ←
even(s(X)) ← ¬even(X)
The intended meaning of this program is as follows: a is the natural number
0, and s is the successor function on natural numbers. Thus, the program
represents the knowledge that 0 is even, and if some number is not even, then
its successor is even.
Many of our later examples will be variations of the Even program theme
and will employ the successor notation for natural numbers. Consider, for
example, the following program.
2.1.4 Program (Length) Let Length be the program consisting of the following clauses.
length([], a) ←
length([H|T ], s(X)) ← length(T, X)
Following Prolog conventions, [] denotes the empty list, and [ · | · ] denotes
2 We borrow Tweety programs, in which a penguin usually called Tweety appears, from
the literature discussing the semantics of non-monotonic reasoning.
