README.md in mini_kraken-0.2.04 vs README.md in mini_kraken-0.3.00

- old
+ new

@@ -2,38 +2,38 @@ [![Build Status](https://travis-ci.org/famished-tiger/mini_kraken.svg?branch=master)](https://travis-ci.org/famished-tiger/mini_kraken) [![Gem Version](https://badge.fury.io/rb/mini_kraken.svg)](https://badge.fury.io/rb/mini_kraken) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/famished-tiger/mini_kraken/blob/master/LICENSE.txt) ### What is __mini_kraken__ ? -A library containing an implementation of the [miniKanren](http://minikanren.org/) -relational programming language in Ruby. -*miniKanren* is a small language for relational (logic) programming. -Based on the reference implementation, in Scheme from the "The Reasoned Schemer" book. +A library containing an implementation in Ruby of the [miniKanren](http://minikanren.org/) + language. +*miniKanren* is a small language for relational (logic) programming as defined in the "The Reasoned Schemer" book. Daniel P. Friedman, William E. Byrd, Oleg Kiselyov, and Jason Hemann: "The Reasoned Schemer", Second Edition, ISBN: 9780262535519, (2018), MIT Press. ### Features - Pure Ruby implementation, not a port from another language - Object-Oriented design - No runtime dependencies +- Test suite patterned on the examples from the reference book. ### miniKanren Features - [X] == - [X] run\* - [X] fresh - [X] conde - [X] conj2 - [X] disj2 - [X] defrel -- [X] caro +- [X] caro +- [X] cdro ### TODO - [ ] Occurs check -List-centric relations from Chapter 2 -- [ ] cdro +List-centric relations from Chapter 2 - [ ] conso - [ ] nullo - [ ] pairo - [ ] singletono @@ -63,11 +63,11 @@ ```ruby require 'mini_kraken' # Load MiniKraken library extend(MiniKraken::Glue::DSL) # Add DSL method to self (object in context) -result = run_star('q', equals(q, :pea)) +result = run_star('q', unify(q, :pea)) puts result # => (:pea) ``` The two first lines in the above code snippet are pretty standard: - The first line loads the `mini_kraken` library. @@ -77,15 +77,15 @@ The aim of a `miniKanren` program is to find one or more solutions involving the given logical variable(s) and satisfying one or more goals to the `run_star method. In our example, the `run_star` method instructs `MiniKraken` to find all solutions, knowing that each successful solution: - binds a value to the provided variable `q` and -- meets the goal `equals(q, :pea)`. +- meets the goal `unify(q, :pea)`. -The goal `equals(q, :pea)` succeeds because the logical variable `q` is _fresh_ (that is, +The goal `unify(q, :pea)` succeeds because the logical variable `q` is _fresh_ (that is, not yet bound to a value) and will be bound to the symbol `:pea` as a side effect - of the goal `equals`. + of the goal `unify`. So the above program succeeds and the only found solution is obtained by binding the variable `q` to the value :pea. Hence the result of the `puts` method. ### Example 2 @@ -95,36 +95,36 @@ require 'mini_kraken' # Load MiniKraken library extend(MiniKraken::Glue::DSL) # Add DSL method to self (object in context) # Following miniKanren program fails - result = run_star('q', [equals(q, :pea), equals(q, :pod)]) + result = run_star('q', [unify(q, :pea), unify(q, :pod)]) puts result # => () ``` In this example, we learn that `run_star` can take multiple goals placed in an array. -The program fails to find a solution since it is not possible to satisfy the two `equals` goals simultaneously. +The program fails to find a solution since it is not possible to satisfy the two `unify` goals simultaneously. In case of failure, the `run_star` returns an empty list represented as `()` in the output. ### Example 3 The next example shows the use two logical variables. ```ruby # In this example and following, one assumes that DSL is loaded as shown in Example 1 -result = run_star(['x', 'y'], [equals(:hello, x), equals(y, :world)]) +result = run_star(['x', 'y'], [unify(:hello, x), unify(y, :world)]) puts result # => ((:hello :world)) ``` This time, `run_star` takes two logical variables -`x` and `y`- and successfully finds the solution `x = :hello, y = :world`. ### Example 4 The next example shows the use of `disj2` goals. ```ruby result = run_star(['x', 'y'], [ - disj2(equals(x, :blue), equals(x, :red)), - disj2(equals(y, :sea), equals(:mountain, y)) + disj2(unify(x, :blue), unify(x, :red)), + disj2(unify(y, :sea), unify(:mountain, y)) ]) puts result # => ((:blue :sea) (:blue :mountain) (:red :sea) (:red :mountain)) ``` Here, `run_star` takes two logical variables and two `disj2` goals.