$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
One Stop Computer Science
1 Jan // php the_time('Y') ?>
Introduction
–Only specification of results are stated (not detailed procedures for producing them)
Compound Terms
–Mathematical function is a mapping
–Can be written as a table
–Functor: function symbol that names the relationship
–Ordered list of parameters (tuple)
student(jon)
like(seth, OSX)
like(nick, windows)
like(jim, linux)
Logical Operators
Name | Symbol | Example | Meaning |
negation | Ø | Ø a | not a |
conjunction | Ç | a Ç b | a and b |
disjunction | È | a È b | a or b |
equivalence | º | a º b | a is equivalent to b |
implication | É
Ì |
a É b
a Ì b |
a implies b
b implies a |
Quantifiers
Name | Example | Meaning |
universal | “X.P | For all X, P is true |
existential | $X.P | There exists a value of X such that P is true |
Terms
–a string of letters, digits, and underscores beginning with a lowercase letter
–a string of printable ASCII characters delimited by apostrophes
–Lasts only as long as it takes to satisfy one complete goal
functor(parameter list)
Overview of Logic Programming
–There is a simple way to determine the meaning of each statement
–Simpler than the semantics of imperative languages
–Programs do not state now a result is to be computed, but rather the form of the result
Rule Statements
–May be single term or conjunction
–Must be single term
Goal Statements
man(fred)
father(X, mike)
Approaches
Subgoal Strategies
–Depth-first search: find a complete proof for the first subgoal before working on others
–Breadth-first search: work on all subgoals in parallel
–Can be done with fewer computer resources
Backtracking
Trace
–Call (beginning of attempt to satisfy goal)
–Exit (when a goal has been satisfied)
–Redo (when backtrack occurs)
–Fail (when goal fails)
List Structures
[apple, prune, grape, kumquat]
[] (empty list)
[X | Y] (head X and tail Y)
Deficiencies of Prolog
–In a pure logic programming environment, the order of attempted matches is nondeterministic and all matches would be attempted concurrently
–The only knowledge is what is in the database
–Anything not stated in the database is assumed to be false
–It is easy to state a sort process in logic, but difficult to actually do—it doesn’t know how to sort
Recent Comments