Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
×
P. 1
Prolog Lab Manual

# Prolog Lab Manual

Ratings: 0|Views: 8,975|Likes:

### Availability:

See More
See less

12/24/2012

pdf

text

original

Prolog Experiments inDiscrete Mathematics,Logic, and Computability
James L. Hein
Portland State University
January 2005

2
Contents
Preface
.............................................................................................................................4
1Introduction to Prolog
.....................................................................................71.1Getting Started...........................................................................................71.2An Introductory Example........................................................................81.3Some Programming Tools......................................................................11
2Beginning Experiments
................................................................................142.1Variables, Predicates, and Clauses......................................................142.2Equality, Unification, and Computation............................................182.3Numeric Computations..........................................................................212.4Type Checking..........................................................................................222.5Family Trees.............................................................................................232.6Interactive Reading and Writing.........................................................252.7Adding New Clauses...............................................................................272.8Modifying Clauses...................................................................................282.9Deleting Clauses......................................................................................30
3Recursive Techniques
....................................................................................333.1The Ancestor Problem.............................................................................333.2Writing and Summing............................................................................353.3Switching Pays.........................................................................................383.4Inductively Defined Sets........................................................................40
4Logic
......................................................................................................................444.1Negation and Inference Rules...............................................................444.2The Blocks World.....................................................................................464.3Verifying Arguments in First-Order Logic........................................484.4Equality Axioms.......................................................................................504.5SLD-Resolution........................................................................................514.6The Cut Operation...................................................................................53
5List Structures
..................................................................................................565.1List and String Notation........................................................................565.2Sets and Bags of Solutions to a Query................................................585.3List Membership and Set Operations.................................................625.4List Operations.........................................................................................66

Contents
3
6List Applications
..............................................................................................706.1Binary Trees..............................................................................................706.2Arranging Objects....................................................................................726.3Simple Ciphers.........................................................................................756.4The Birthday Problem............................................................................786.5Predicates as Variables..........................................................................796.6Mapping Numeric Functions................................................................816.7Mapping Predicates.................................................................................826.8Comparing Numeric Functions............................................................846.9Comparing Predicates.............................................................................86
7Languages and Expressions
........................................................................887.1Grammar and Parsing............................................................................887.2A Parsing Macro.......................................................................................897.3Programming Language Parsing.........................................................917.4Arithmetic Expression Evaluation......................................................92
8Computability
....................................................................................................968.1Deterministic Finite Automata............................................................968.2Nondeterministic Finite Automata......................................................988.3Mealy Machines.....................................................................................1018.4Moore Machines.....................................................................................1048.5Pushdown Automata.............................................................................1068.6Turing Machines....................................................................................1088.7Markov Algorithms................................................................................1128.8Post Algorithms......................................................................................114
9Problems and Projects
.................................................................................1189.1Lambda Closure.....................................................................................1189.2Transforming an NFA into a DFA.....................................................1209.3Minimum-State DFA............................................................................1269.4Defining Operations..............................................................................1309.5Tautology Tester....................................................................................1329.6CNF Generator.......................................................................................1369.7Resolution Theorem Prover for Propositions...................................137
10Logic Programming Theory
......................................................................14210.1The Immediate Consequence Operator............................................14210.2Negation as Failure...............................................................................14310.3SLDNF-Resolution................................................................................145
...................................................................147
Index
.............................................................................................................................158

## Activity (6)

### Showing

AllMost RecentReviewsAll NotesLikes