On this page:
amb  Kanren:   mini  Kanren Based on amb
9.3

ambKanren: miniKanren Based on amb🔗ℹ

ambKanren compares amb with the books’ streams and tests the resulting behavior. The three implementations documented below follow miniKanren-typed, keeping the non-search code the same while replacing streams with amb.

Its search uses the ambiguous operator amb of the typed/amb library. A goal is an ordinary function from substitutions to substitutions (from states to states, in microKanren). A goal with several answers chooses one of them with amb; a goal with none calls (amb-fail). run collects the answers with amb-generate*.

The search strategy is the merger of amb, the value of current-amb-merger. The default merger, amb-append, is depth-first. In microKanren, Zzz and the forms that use it pause before running a goal. In the second edition, defrel pauses at each call to the relation. Use amb-interleave to give another branch a turn at these pauses when an infinite branch would otherwise keep it from producing an answer. The first edition’s interleaving forms choose their own merger and interleave at answers.

The package provides one module for each language it implements:

    1 microKanren

      1.1 From Streams to amb

        1.1.1 Suspension and the Order of Answers

      1.2 Types

      1.3 The Core

      1.4 User-Level Forms

    2 First Edition

      2.1 Implementation Basis

      2.2 Types

      2.3 Running Programs

      2.4 Goals

        2.4.1 Interleaving

      2.5 Substitutions and Unification

    3 Second Edition

      3.1 Implementation Basis

        3.1.1 Order of Answers

      3.2 Types

      3.3 Running Programs

      3.4 Goals and Relations

      3.5 Substitutions and Unification

    4 Performance