☰
↑
←
→
🔍
TOC
A "Hands-on" Introduction to
Pure Logic Programming (Pure Prolog)
»
Table of Contents
Table of Contents
Syntax
Terms: variables, constants and structures (Slide 2)
More on terms (Slide 3)
Operators
Rules and facts (clauses) (Slide 4)
Predicates, programs and queries (Slide 5)
Queries
The declarative meaning of facts and rules (Slide 6)
The declarative meaning of predicates and queries (Slide 7)
"Execution" and semantics (Slide 8)
The program running
Running programs, and the top-down operational meaning (Slides 9–10)
Unification
Unification: one operation with many uses (Slide 11)
Unification, more formally (Slide 12)
When it does not work
The most general unifier (Slide 13)
The unification algorithm (Slide 14)
The unification algorithm: worked examples (Slide 15)
Execution, search, and control
A schematic interpreter (SLD-resolution) (Slide 16)
The algorithm, run by hand
The choices made in standard Prolog (Slide 17)
Search rule and computation rule (Slide 18)
Alternative execution paths, and the "normal programming" view (Slides 19–21)
Comparison with imperative and functional languages: continuations (Slide 22)
Programs with and without search (Slide 23)
The search tree (Slide 24)
Characterizing the search tree (Slide 25)
Depth-first, breadth-first, and choosing between them (Slides 26–28)
Control of search: clause and goal order (Slides 29–30)
1. The order of the literals in the body of a clause
2. The order of the clauses in a predicate
3. The pruning operators
The role of unification in execution (Slide 31)
A worked example
"Modes" (Slide 32)
Pure logic programs: an overview (Slide 34)
Programming with data
Database programming (Slides 35–36)
Exercises
Structured data, data abstraction, and
=
(Slides 37–40)
Logic programs and the relational database model (Slides 41–42)
Deductive databases, Datalog and ASP (Slide 43)
Recursion
Recursive programming (Slide 45)
Exercises
What about "not equal"? (Slides 46–47)
Types, and recursive types (Slides 48–49)
Recursive types
What does it cost?
Arithmetic, the pure way (Slides 50–53)
The order relation
Addition
The remainder: writing the specification
Functions as predicates: Ackermann's function
Exercises
Functional syntax (Slides 54–57)
Exercises
Lists
Lists as a recursive type (Slides 58–59)
The two layers of syntactic sugar
Unification on lists
The type definition
Membership in a list (Slide 60)
Length, sum, and typed lists (Slide 61)
One way to understand recursive programs (Slide 62)
Append (Slides 63–65)
Reverse, and the cost of getting it wrong (Slides 66–67)
Why the naive version is slow
The accumulating parameter
Measuring the difference
Exercises
Trees, symbols and graphs
Binary trees (Slides 68–69)
Exercises
Polymorphism (Slide 70)
Recognizing (and generating) polynomials (Slide 71)
Symbolic differentiation (Slide 72)
Exercises
Graphs (Slides 73–74)
Exercises
Automata as graphs (Slide 75)
Adding a stack: pushdown automata (Slide 76)
The Towers of Hanoi (Slides 77–79)
Learning to compose recursive programs (Slide 80)