## Clause and Effect: Prolog Programming for the Working ProgrammerThis book is for people who have done some programming, either in Prolog or in a language other than Prolog, and who can find their way around a reference manual. The emphasis of this book is on a simplified and disciplined methodology for discerning the mathematical structures related to a problem, and then turning these structures into Prolog programs. This book is therefore not concerned about the particular features of the language nor about Prolog programming skills or techniques in general. A relatively pure subset of Prolog is used, which includes the 'cut', but no input/output, no assert/retract, no syntactic extensions such as if then-else and grammar rules, and hardly any built-in predicates apart from arithmetic operations. I trust that practitioners of Prolog program ming who have a particular interest in the finer details of syntactic style and language features will understand my purposes in not discussing these matters. The presentation, which I believe is novel for a Prolog programming text, is in terms of an outline of basic concepts interleaved with worksheets. The idea is that worksheets are rather like musical exercises. Carefully graduated in scope, each worksheet introduces only a limited number of new ideas, and gives some guidance for practising them. The principles introduced in the worksheets are then applied to extended examples in the form of case studies. |

### What people are saying - Write a review

#### LibraryThing Review

User Review - nillacat - LibraryThingHow to think in Prolog. Covers various idioms of logic programming. Written as a series of worksheets, a couple of pages each, describing a technique and setting an exercise. Recommended. Read full review

User Review - Flag as inappropriate

book is quit good if you want relevent and concise information.

### Contents

Getting Started | 1 |

11 Syntax | 2 |

12 Programs | 6 |

13 Unification | 7 |

14 Execution Model | 9 |

Party Pairs | 12 |

Drinking Pairs | 13 |

Affordable Journeys | 14 |

Linearising Efficiently | 62 |

Linearising Trees | 63 |

Difference Structures | 64 |

Rotation Revisited | 65 |

Max Tree | 66 |

52 Solution to Max Tree | 67 |

Case Study Term Rewriting | 69 |

62 Matrix Products by Symbolic Algebra | 70 |

Acyclic Directed Graph | 16 |

Data Structures | 17 |

21 Square Bracket Notation | 19 |

Member | 20 |

22 Arithmetic | 21 |

Length of a List | 22 |

Inner Product | 23 |

Maximum of a List | 24 |

Searching a Cyclic Graph | 25 |

Mapping | 27 |

Full Maps | 30 |

Multiple Choices | 31 |

Partial Maps | 32 |

Removing Duplicates | 33 |

Partial Maps with a Parameter | 34 |

Multiple Disjoint Partial Maps | 35 |

Multiple Disjoint Partial Maps | 36 |

Full Maps with State | 37 |

Sequential Maps with State | 38 |

Scattered Maps with State | 39 |

Choice and Commitment | 41 |

42 A Disjoint Partial Map with Cut | 43 |

Multiple Choices with Cut | 46 |

Ordered Search Trees | 47 |

Frequency Distribution | 49 |

43 Taming Cut | 50 |

45 NegationasFailure Can Be Misleading | 51 |

NegationasFailure | 53 |

Difference Structures | 55 |

Concatenating Lists | 56 |

Rotations of a List | 57 |

Linearising | 58 |

51 Difference Lists | 59 |

63 The Simplifier | 72 |

Case Study Manipulation of Combinational Circuits | 75 |

72 Simulation of Circuits | 79 |

74 Simplifying SOP Expressions | 82 |

75 Alternative Representation | 83 |

Case Study Manipulation of Clocked Sequential Circuits | 85 |

81 DividebyTwo Pulse Divider | 86 |

83 FourStage Shift Register | 87 |

84 Gray Code Counter | 89 |

85 Specification of Cascaded Components | 90 |

Case Study A Compiler for Three Model Computers | 93 |

91 The Register Machine | 97 |

92 The SingleAccumulator Machine | 102 |

93 The Stack Machine | 107 |

Preprocessing the Syntax Tree | 110 |

95 Peephole Optimisation | 113 |

Case Study The Fast Fourier Transform in Prolog | 115 |

102 Notation for Polynomials | 116 |

103 The DFT | 117 |

105 Naive Implementation of the DFT | 119 |

106 From DFT to FFT | 120 |

107 Merging Common Subexpressions | 121 |

108 The Graph Generator | 123 |

8point FFT | 124 |

1010 Bibliographic Notes | 126 |

Case Study HigherOrder Functional Programming | 127 |

112 A Notation for Functions | 129 |

113 The Evaluator | 131 |

114 Using HigherOrder Functions | 136 |

115 Discussion | 138 |

116 Bibliographic Notes | 139 |

141 | |

### Other editions - View all

Clause and Effect: Prolog Programming for the Working Programmer William F. Clocksin Limited preview - 2012 |

### Common terms and phrases

accumulator append application arithmetic arity atom backtracking binary branch built-in functions called cg(X clock pulse co-refer compilation component compound term concatenating consider constant construct cos(phi cos(theta Danielson-Lanczos lemma data structures definition denote difference lists element eval evaluate example Fast Fourier Transform flattened foldl following goals full map functional programming functor given graph Gray code higher-order functional infix infix operator initialised inner product input list insert(l instantiated integer integer(X lambda expression language Linearising matrix member(X membercheck(X negation node notation nth roots null list output list pair(X parameter Peephole Optimisation polynomial Practice procedure programming in Prolog Prolog program Prolog system query recursive descent represented result root of unity rotation second argument second clause sequence sequential circuits simplified simply sin(phi sin(theta solution SOP expression specified split(T stack machine subgoal succeeds syntax tree tail third clause Transform unify Worksheet written