Slides

advertisement
By: Cory Canter
CSC 415
Programming Languages
PROLOG
History
 Created by Alain Colmerauer, Phillipe Roussel
and Robert Kowalski in 1971
 Started as a natural language processing
project for French
 Test version released in 1971, full version
released in 1972
History
 First compiler developed by artificial
intelligence professor David H.D. Warren in
the Warren Abstract Machine
 Quickly became popular in Europe and Asia
 Used in the Fifth Generation Computer
Systems Initiative
 Prolog continues to expand with the latest
release of Visual Prolog 7.5 on July 23rd, 2014
Terms
 All statements comprised of terms
 Term = constant, variable or structure
 Constant = atom or integer
 Atom = string of letters, digits and
underscores beginning with a lowercase
letter or a string enclosed in apostrophes
 Examples of atoms: taco17, bell, dog_ ,
‘Apple’
Variables
 Unlike variables in imperative languages
 Variable = any string of letters, digits and
underscores that begins with an uppercase
letter or underscore
 Binding of a value to a variable is called
instantiation which occurs in the resolution
process
Variables
 Unassigned variables = uninstantiated
 Instantiations are unique to each goal
 Examples of Variables: _pear, Microsoft
Structures
 Functor(parameter list)
 Functor = atom and name of structure
 Contain several arguments (integers,
variables, atoms or other structures) divided
by commas and enclosed in parentheses
 Specify facts
 Relationships among terms
 Predicate to a query
Fact Statements
Examples:
male(gavin).
female(karris).
father(gavin, karris).
Rule Statements
 consequence :- antecedent_expression.
 State rules of implications between
propositions
 examples:
tired(gavin) :- ran(gavin, maration).
tired(a) :- ran(A, B).
Goal Statements
 The system will reply to a goal with either yes
or no based on the database
 yes means it has proved the goal was true
and no means it has proved it to be false or
was unable to prove it.
Goal Statements
examples:
male(gavin).
female(karris).
father(gavin, karris).
male(gavin).
yes
male(karris).
no
Inferring
 Forward Chaining
 Backward Chaining
 Depth-first
 Breadth-first
 Backtracking
Arithmetic
 Original done with functors
Example:
+(4, a)
 is operator
example:
X is Y * 20 + Z.
 is does not equal =
example:
Sum is Sum + Number
Problems
 Closed world problem
 Negation problem
 Fundamental goal
Readability
 Easy to read with some experience
 Similar to a complex math equation
 Read and understood logically
Writability
 Difficult to write in without a lot of practice
 Very different from most other languages
 Requires a lot of specifics to detail
 Does not flow
 Not near basic language structure
Reliability
 Decently reliable
 Attempting to add redundancy
 Inherent reliability
 Backtracking
Cost
 Low compared to other logic languages
 Moderate compared to procedural languages
 Specific training cost
 High maintainability
 Reliable
Download