CHAPTER 15
INTRODUCTION
·
Programming
that uses a for of symbolic logic as a programming language is often called logic
programming, and languages based on symbolic logic are called declarative
languages.
·
The
syntax of logic programming languages is remarkably different from that of the
imperative and functional languages; the semantics also bear little
resemblance.
A
BREIF INTRODUCTION TO PREDICATE CALCULUS
·
A
proposition can be thought of as a logical statement that may or may not be
true.
·
Symbolic logic can be used to express
propositions, to express the relationships between propositions, and to
describe how new propositions can be inferred from other propositions that are
assumed to be true.
·
The
particular form of symbolic logic that is used for logic programming is called predicate
calculus.
PROPOSITIONS
·
The
simplest propositions, which are called atomic propositions, consist of
compound terms.
· A compound term is written in the form of a mathematical function notation.
Ex. man(jack).
AN OVERVIEW OF LOGIC PROGRAMMING
· Languages used for logic programming are called declarative because programs consist of declarations rather than assignments and control flow statements.
· Declarative semantics is considerably simpler than the semantics of the imperative languages.
· The best form of a logic language may not have yet been determined, and good methods of creating programming in logic programming languages for large problem have not been devolved.
THE ORIGINS OF PROLOG
· Developed by Alain Colmerauer, Phillippe Roussell, and Robert Kowlalski.
BASIC ELEMENTS OF PROLOG
· A prolog term is a constantan, a variable, or a structure.
· A fact statement is simply a proposition that is assumed to be true.
Ex. female(Shelly). – note: every statement is terminated by a period.
· Rule statements state rules of implication between propositions.
Ex. parent(X, Y): - mother(X, Y). This means that if x is a mother of y then x is the parent of y.
· A goal statement is one that which requests an answer; the syntactic form of fact statements and goal statements are identical
Ex. father(X, mike). This asks the question “who is the father of mike?”.