0% found this document useful (0 votes)
25 views4 pages

Clause and Effect

Uploaded by

rouboudoux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views4 pages

Clause and Effect

Uploaded by

rouboudoux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

William F.

Clocksin

Clause
and Effect
Prolog Programming
for the Working Programmer

Springer
Table of Contents

1. Getting Started 1
1.1 Syntax 2
1.2 Programs 6
1.3 Unification 7
1.4 Execution Model 9
Worksheet 1: Party Pairs 12
Worksheet 2: Drinking Pairs 13
Worksheet 3: Affordable Journeys 14
Worksheet 4: Acyclic Directed Graph 16

2. Data Structures 17
2.1 Square Bracket Notation 19
Worksheet 5: Member.: 20
2.2 Arithmetic 21
Worksheet 6: Length of a List 22
Worksheet 7: Inner Product 23
Worksheet 8: Maximum of a List 24
Worksheet 9: Searching a Cyclic Graph 25

3. Mapping 27
Worksheet 10: Full Maps 30
Worksheet 11: Multiple Choices 31
Worksheet 12: Partial Maps 32
Worksheet 13: Removing Duplicates 33
Worksheet 14: Partial Maps with a Parameter 34
Worksheet 15: Multiple Disjoint Partial Maps 35
Worksheet 16: Multiple Disjoint Partial Maps 36
Worksheet 17: Full Maps with State 37
Worksheet 18: Sequential Maps with State 38
Worksheet 19: Scattered Maps with State 39
viii Table of Contents

4. Choice and Commitment 41


4.1 The'Cut' 41
4.2 A Disjoint Partial Map with Cut 43
Worksheet 20: Multiple Choices with Cut 46
Worksheet 22: Ordered Search Trees 47
Worksheet 23: Frequency Distribution 49
4.3 Taming Cut 50
4.4 Cut and Negation-as-Failure 50
4.5 Negation-as-Failure Can Be Misleading 51
Worksheet 24: Negation-as-Failure 53

5. Difference Structures 55
Worksheet 25: Concatenating Lists 56
Worksheet 26: Rotations of a List 57
Worksheet 27: Linearising 58
5.1 Difference Lists 59
Worksheet 28: Linearising Efficiently 62
Worksheet 29: Linearising Trees 63
Worksheet 30: Difference Structures 64
Worksheet 31: Rotation Revisited 65
Worksheet 32: Max Tree 66
5.2 Solution to Max Tree 67

6. Case Study: Term Rewriting 69


6.1 Symbolic Differentiation 69
6.2 Matrix Products by Symbolic Algebra 70
6.3 The Simplifier 72

7. Case Study: Manipulation of Combinational Circuits 75


7.1 Representing Circuits 75
7.2 Simulation of Circuits.. 79
7.3 Sums and Products 79
7.4 Simplifying SOP Expressions 82
7.5 Alternative Representation 83
Table of Contents ix

8. Case Study: Clocked Sequential Circuits 85


8.1 Divide-by-Two Pulse Divider 86
8.2 Sequential Parity Checker 86
8.3 Four-Stage Shift Register 87
8.4 Gray Code Counter 89
8.5 Specification of Cascaded Components 90

9. Case Study: A Compiler forThree Model Computers 93


9.1 The Register Machine 97
9.2 The Single-Accumulator Machine 102
9.3 The Stack Machine 107
9.4 Optimisation: Preprocessing the Syntax Tree 110
9.5 Peephole Optimisation 113

10. Case Study: The Fast Fourier Transform in Prolog 115


10.1 Introduction 115
10.2 Notation for Polynomials 116
10.3 The DFT 117
10.4 Example: 8-point DFT 117
10.5 Naive Implementation of the DFT 119
10.6 From DFT to FFT 120
10.7 Merging Common Subexpressions 121
10.8 The Graph Generator 123
10.9 Example Run: 8-point FFT 124
10.10 Bibliographic Notes 126

11. Case Study: Higher-Order Functional Programming 127


11.1 Introduction 127
11.2 A Notation for Functions 129
11.3 The Evaluator 131
11.4 Using Higher-Order Functions 136
11.5 Discussion 138
11.6 Bibliographic Notes 139

Index 141

You might also like