Logical programming language
Logical programming language
Logic Programming
Languages
ISBN 0-321-49362-1
Chapter 16 Topics
• Introduction
• A Brief Introduction to Predicate Calculus
• Predicate Calculus and Proving Theorems
• An Overview of Logic Programming
• The Origins of Prolog
• The Basic Elements of Prolog
• Deficiencies of Prolog
• Applications of Logic Programming
negation a not a
disjunction ab a or b
• Declarative semantics
– There is a simple way to determine the
meaning of each statement
– Simpler than the semantics of imperative
languages
• Programming is nonprocedural
– Programs do not state now a result is to be
computed, but rather the form of the result
• University of Aix-Marseille
– Natural language processing
• University of Edinburgh
– Automated theorem proving
• Edinburgh Syntax
• Term: a constant, variable, or structure
• Constant: an atom or an integer
• Atom: symbolic value of Prolog
• Atom consists of either:
– a string of letters, digits, and underscores
beginning with a lowercase letter
– a string of printable ASCII characters delimited
by apostrophes
ancestor(mary,shelley):- mother(mary,shelley).
speed(ford,100).
speed(chevy,105).
speed(dodge,95).
speed(volvo,80).
time(ford,20).
time(chevy,21).
time(dodge,24).
time(volvo,24).
distance(X,Y) :- speed(X,Speed),
time(X,Time),
Y is Speed * Time.
likes(jake,chocolate).
likes(jake,apricots).
likes(darcie,licorice).
likes(darcie,apricots).
trace.
likes(jake,X),
likes(darcie,X).
reverse([], []).
reverse([Head | Tail], List) :-
reverse (Tail, Result),
append (Result, [Head], List).