Computation with Logic
We can use Prolog for much more than just a silly example like family-relationship inferences. In Prolog, using nothing but logical inference, we can implement programs to perform any computation that we could implement in a more traditional programming language. To see how we can do that, we’ll look at two examples of how you write more realistic computations in Prolog. First, we’ll pull out Peano arithmetic, which we talked about back in 1, Natural Numbers, and implement it in Prolog. Then we’ll take the most widely used sorting algorithm in modern software and look at how it appears in Prolog.
Peano Arithmetic in Prolog
As we saw back toward the beginning of this book, Peano arithmetic is a formal, axiomatic way ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access