The Reasoned Schemer (MIT Press) (The MIT Press) (英語) ペーパーバック – 2018/3/2
Kindle 端末は必要ありません。無料 Kindle アプリのいずれかをダウンロードすると、スマートフォン、タブレットPCで Kindle 本をお読みいただけます。
A new edition of a book, written in a humorous question-and-answer style, that shows how to implement and use an elegant little programming language for logic programming.
The goal of this book is to show the beauty and elegance of relational programming, which captures the essence of logic programming. The book shows how to implement a relational programming language in Scheme, or in any other functional language, and demonstrates the remarkable flexibility of the resulting relational programs. As in the first edition, the pedagogical method is a series of questions and answers, which proceed with the characteristic humor that marked The Little Schemer and The Seasoned Schemer. Familiarity with a functional language or with the first five chapters of The Little Schemer is assumed.
For this second edition, the authors have greatly simplified the programming language used in the book, as well as the implementation of the language. In addition to revising the text extensively, and simplifying and revising the “Laws” and “Commandments,” they have added explicit “Translation” rules to ease translation of Scheme functions into relations.
"The Little books are unique in the way they combine deep and subtle ideas with hands-on humorous presentation. "The Reasoned Schemer, " the latest book in the series, is no exception. Friedman, Byrd, and Kiselyov provide a unique presentation of many of the ideas behind logic programming, which is developed as a natural--though subtle--extension of functional programming. For perfecting your programming skills and style you cannot do better than sit at the feet of Friedman and Kiselyov."--Ehud Lamm, Founder of 'Lambda the Ultimate, ' the programming languages weblog
"Contrary to popular belief, logic programming doesn't always mean programming in Prolog. In this groundbreaking book, Friedman and Kiselyov extend Scheme to form a completely new kind of logic programming system, one which is in many ways even more elegant than Prolog. Written in the same classic question-and-answer format as the authors' previous book "The Little Schemer, The Reasoned Schemer" covers goals, first-class relations, interleaved and non-interleaved backtracking, the relationship between relational and functional programming, and much more. Reading this book will not only cause your geek rating to skyrocket and impress all the Cool Kids, it will also open your eyes to a paradigm of programming which most programmers are completely unaware of, but which will undoubtedly play a significant role in the programming systems of the future. More importantly, though, this book is great fun to read and will make you a better programmer."--Michael Vanier, Caltech
"Some programmers are particularly fascinated by new ways of thinking about programming and computation. But few programmers have much experience with logic programming, and fewer still understand its essence. There has never been a more engaging presentation of this material, or a clearer view all the way to the bottom. Like the other Little books, this book is sure to broaden your horizons. And in fact, this one has the broadest horizons yet."--Matt Hellige, Researcher, Accenture Technology Labs
Daniel P. Friedman is Professor of Computer Science in the School of Informatics, Computing, and Engineering at Indiana University and is the author of many books published by the MIT Press, including The Little Schemer and The Seasoned Schemer (with Matthias Felleisen); The Little Prover (with Carl Eastlund); and The Reasoned Schemer (with William E. Byrd, Oleg Kiselyov, and Jason Hemann).
読者として２つのグループを想定しているようです。ひとつは miniKANREN 上のプログラミングを通して論理型プログラミングを学ぶグループです。もうひとつは巻末の miniKANREN 作成から処理系の作成を学ぶグループです。前者の場合には予備知識は不要ですが、後者の場合にはマクロ等に関する深い知識が必要です。 SICP や On Lisp を読み終わっているぐらいの知識が必要だと思います。
自分のスキルアップとともに読み取れる内容がどんどん深くなっていくのが処理系作成の醍醐味です。自分の Scheme のスキルを確認するために何度か読み返してみると新しい発見ができる面白い本だと思います。Clause and Effect と一緒に読むと Prolog を学びやすいのでお勧めです。
Non logic programming basically works from the notion of imperative data flow. This is generally represented by the concept of a function. A function takes a argument and returns a value, it takes input variables and returns output variables. A logic program creates a relation (not a function) between a set of variables. If you had a two input function, with one output, you could represent this as a logic program relation of three variables. Two of those relation variables would be what were the two inputs to the function, the third variable would be the output of the function. Here is the kicker though. You can provide concrete values for any number of those variable in any order and ask the relation what the other variables might be. At the simplest level, this means that you might run your function "backwards" (from the output to the input). But really, it means that you can ask any question relating to those variables (conceptually). Now, realistically, it is not as easy as that. Some relations may never terminate (return a answer), some grow too large and barf (overflow), some may not complete for various other reasons. It can be more complex to actually write a logical relation than a function, this must be balanced against the fact that the relation is far more powerful than the function.
If you want a primer for logical programing, this book is probably worth your time. It takes you through writing many of the fundamental parts of a logical relation. The only thing I think it really skips is the actual unification (= x y) primitive itself, which I believe it uses as a given. You can learn quite a bit by reading this code slowly and carefully. Note however, that you must complete every step of the question/answer pairings! Skimming this book will not work (unless you already know it). Really, these concepts build on each other. It is a rather small (page number and physically) book, but it will take far more time to really go through then its size would suggest. Read and work through for the purpose of understanding, and I think you will really get a good backing in logic programming, and probably enjoy yourself as well!
Note: The above statements applied to the paper edition.
The Kindle version of this Book is pure garbage. Here I am, on a 2016 Macbook Pro with a Retina Display and I can barely read the damn thing. I tried reading on my Android, just awful. I tried on my Windows PC, same. A good deal of the information in this book is communicated by bolding and italics. These are incredibly difficult to see in the Kindle version. Shame on the publisher for releasing such an inferior thing to the public. Disappointed in Amazon for not enforcing minimum legibility standards on non free Kindle books. DO NOT EVEN CONSIDER BUYING THE KINDLE EDITION!
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.