|
The Reasoned Schemer | 
| Authors: Daniel P. Friedman, William E. Byrd, Oleg Kiselyov Publisher: The MIT Press Category: Book
List Price: $28.00 Buy New: $13.75 You Save: $14.25 (51%)
New (23) Used (11) from $13.75
Rating: 4 reviews Sales Rank: 358727
Media: Paperback Pages: 176 Number Of Items: 1 Shipping Weight (lbs): 0.7 Dimensions (in): 8.9 x 6.9 x 0.5
ISBN: 0262562146 Dewey Decimal Number: 005.133 EAN: 9780262562140 ASIN: 0262562146
Publication Date: July 1, 2005 Availability: Usually ships in 1-2 business days
| |
| Similar Items:
|
| Editorial Reviews:
Product Description The goal of The Reasoned Schemer is to help the functional programmer think logically and the logic programmer think functionally. The authors of The Reasoned Schemer believe that logic programming is a natural extension of functional programming, and they demonstrate this by extending the functional language Scheme with logical constructs?thereby combining the benefits of both styles. The extension encapsulates most of the ideas in the logic programming language Prolog. The pedagogical method of The Reasoned Schemer is a series of questions and answers, which proceed with the characteristic humor that marked The Little Schemer and The Seasoned Schmer. Familiarity with a functional language or with the first eight chapters of The Little Schemer is assumed. Adding logic capabilities required the introduction of new forms. The authors' goal is to show to what extent writing logic programs is the same as writing functional programs using these forms. In this way, the reader of The Reasoned Schemer will come to understand how simple logic programming is and how easy it is to define functions that behave like relations.
|
| Customer Reviews:
Better go to the Source August 1, 2008 autodidact 1 out of 2 found this review helpful
I guess this book is OK, but it could really be written in all of about 5 to 10 pages of text with half a page of implementation code - in Haskell.
Main idea: use (potentially) infinite lists to represent (potentially) infinite streams of solutions to a problem. Have "goals" as procedures that work on (partial) solutions, producing new lists (empty/singleton/plural) of (more complete) solutions for each solution processed. Have a mechanism of combining these solutions streams. Now AND is just a sequential combinator and goal applicator; OR is a sequential combinator for parallel application; OR/i (for interleaving) combines its result streams in an interleaving fashion.
It suffices to have these combinators binary, because any type of COND is anyhow broken down to these binary combinations, as in a typical COND rewrite with IFs - and that's what the book itself does too, in a somewhat complex Scheme macro syntax. Expressed in Haskell, the intent is clear and the meaning is immediately obvious:
Sequential stream combination ("mplus" of the book): (1) [] ++: ys = ys (2) (x:xs) ++: ys = x:(xs ++: ys)
Alternating stream combination ("mplus/i"): (3) [] ++/ ys = ys (4) (x:xs) ++/ ys = x:(ys ++/ xs)
Sequential feed ("bind"): (5) [] >>: g = [] (6) (x:xs) >>: g = g x ++: (xs >>: g)
Alternating feed ("bind/i"): (7) [] >>/ g = [] (8) (x:xs) >>/ g = g x ++/ (xs >>/ g)
"OR" goal combination ("cond/e"): (9) (f ||: g) x = f x ++: g x
"Alternating OR" goal combination ("cond/i"): (10) (f ||/ g) x = f x ++/ g x
"AND" goal combination ("all"): (11) (f &&: g) x = f x >>: g
"Alternating AND" goal combination ("all/i" of the book): (12) (f &&/ g) x = f x >>/ g
That's about all there is to it. If you're unfamiliar with Haskell, it's a type-inferencing, auto-currying LISP with unparenthesised syntax where "f x" stands for functional application, "[]" stands for empty list, "x:xs" for cons cell (x . xs), and parentheses are used for grouping of expressions. It is non-strict, so lazy lists are used throughout, and _everything_ is a delayed lambda, calculated on "as-needed" basis. Having finally produced a stream of solutions, we rely on Haskell to only calculate as much of it as is actually requested by a user (usually one by one, as in Prolog), thus in effect performing depth-first search of a problem space.
It should be clear now that the actual nature of our solutions should be regarded quite apart from the mechanism of producing, combining and managing these infinite streams. Unification can then be viewed as just another "knowledge-enhancing" goal capable of rejecting the solution it's supplied with, by producing an empty list, or updating it, by producing a new list containing an updated solution(s). These solutions can be of any type, whether built-in or user-defined native Haskell type, and not just general symbolic structure capable of representing a kind of symbolic terms Prolog has, which is what's done in the book - where everything is represented through this symbolic structure, even numbers.
Implementing arithmetical relations on top of that is a standard exercise in hopeless inefficiency. The book wants to add logic programming capabilities to the existing Scheme system. Surely we don't have to reinvent numbers for this, and in such an incredibly inefficient way at that!
Instead of reusing blind structural unification of Prolog, the authors could discuss how it can be seen as creating equality constraints, then proceed to implement _them_ thus having truly added the relational capabilities ON TOP of the existing Scheme system, with its numeric functions working for us directly, hopefully.
If this book had THAT, THEN it would have been a great book.
Alas, no. The authors decided instead to stay at a fairly rudimental level, and be very verbose and inexplicit at the same time. And here I come to a point about their whole methodology in this as in their other books of this series, of presenting their material by examples only, making it unnecessarily obscure for a reader. It seems to me they've gone to the other extreme here from the pseudo-scientific type of dry presentation full of abstruse terminology. The golden path, as always, may lie somewhere in the middle - first presenting the material through examples and just playing with it (like they do here), but then proceeding to more precise formulation and discussion of the issues.
This book is long on promise, but short on clarity and depth.
fascinating and challenging February 5, 2007 Michael Vanier (Pasadena, CA) 9 out of 9 found this review helpful
As the saying goes, if you like this sort of thing, this is the sort of thing you'll like. The authors have extended the approach of their classic book _The Little Schemer_ to encompass what is usually called logic programming, but which they refer to as "relational programming" (a much better name, in my opinion). They extend the Scheme language with relational analogues of many constructs, notably lambda and cond (in many, many variations), and also provide extended versions of standard Scheme operations like cons, car, and cdr. Basically, the relational approach involves taking the result of a function call and making it just another argument, but a special argument that can get assigned to as the result of the computation. Big deal, so what? you ask. The important thing is that _all_ of the function arguments behave this way, so that you can specify the result of a function (relation) and ask the system to generate the arguments. For instance, instead of saying 2 + 2 = X and figuring out what X is, you can say X + 2 = 4 and the system will figure out what X has to be (in this case... ummm... oh yeah, 2). To do this, the system uses a mechanism called "backtracking" which systematically tries alternatives until it either finds the answer, gives up, or (if you didn't program the search right) goes on forever. If you haven't seen this style of programming before, this book will definitely open your eyes.
The relational/logic programming style is usually learned by studying the Prolog language, which is how I learned it (though I'm no expert). Having a knowledge of Prolog will definitely make this book easier to understand, although the approach given here is more modern than Prolog in several ways. For one thing, the named relations of Prolog are replaced here by anonymous relations (analogous to lambda expressions being anonymous functions), and for another, the (somewhat brutal) "cut" operator of Prolog, which is used to control backtracking, is ignored in favor of more subtle approaches involving interleaving solutions and giving up after single results are found.
I think the approach of learning-by-pattern-recognition that all the "Little X" books use is fairly effective here, though I think a lot of readers (meaning me) wouldn't mind a more extended discussion of the mechanics of the system.
All in all, if you liked _The Little Schemer_ and are curious about new ways of programming, you should definitely pick up a copy of this book. It will stretch your mind like a Slinky, and when you're done you'll have learned a new way of looking at programming.
elegant and powerful Prolog January 5, 2006 W Boudville (Terra, Sol 3) 8 out of 13 found this review helpful
This is a sequel to "The Little Schemer". It goes further into demonstrating why relational programming can be elegant and powerful. You would also benefit by having some previous knowledge of Prolog, for the text expresses its ideas in the framework of this language.
Relational programming is shown to be a very different beast from procedural/OO programming. Beautiful and concise notation. Especially if you try to imagine expressing some of the book's examples in conventional C or Java. A programmer harking from that background might have an impedance mismatch. But upon reflection, perhaps it is especially for such a reader that the authors are writing.
Mind-Blowing Book October 22, 2005 Conrad Barski (Minneapolis, MN) 35 out of 37 found this review helpful
I'm a long-time fan of the "Schemer" series of books and was excited to receive my preordered copy of "The Reasoned Schemer" yesterday- It was supposed to be published in July but must have been held up until now...
I have no relationship with any of the authors and just want to put my $0.02 in on it, since not many others may have a copy yet- I think it is absolutely FANTASTIC so far!
The book itself is very much in the same style as the rest of the "Schemers"- A Q&A style of exposition that helps your brain to absorb most of the essence of a new programming style without having to spend the time to write tons of actual code yourself to learn the basic philosophy.
The main purpose of the book is to attach a set of logic programming commands to the core R5RS scheme that allow you to implement all kinds of cool things, such as constraint programming, pattern matching, nondeterministic programming, and PROLOG-like logical reasoning. The material covered is not too dissimilar from the material in the back of "On Lisp" or some parts of SICP. What distinguishes it is that the implementation used has been widdled down to its bare essence and uses a syntax modeled on standard FP scheme syntax. Plus, the subject matter is treated with a certain academic rigor that gives these new commands the feeling of a practical toolset instead of just a clever novelty. I could imagine incorporating these commands into my regular scheme code...
As I mentioned, there is a list of new mysterious scheme commands that enable the logic reasoning abilities- They look superficially like the standard FP commands in scheme, but behave slightly different- They have names such as "conde", "caro", etc. There are also a couple of commands with no FP scheme analogue, such as "run" and "fresh". Using these new commands, logical reasoning can be mixed with standard FP scheme pretty seamlessly. An appendix at the end of the book implements the full set of commands- It totals about 150 LOC in length.
I'm still only partially into the book, but just wanted to let folks know that this book has some really mind-blowing ideas and may be the answer to those, like me, who are still searching for a resource that will allow them to "get" PROLOG-like languages and want to learn how to incorporate such techniques into their programming projects with the least amount of fuss possible. [...]
|
|
|
Can't find the right gift? Try a Gift Certificate
| |