MyNixOS website logo
Description

A fast-foward-based planner.

An implementation of the fast-forward planner, as a quasi-quoter.

Huff

Huff is an implementation of the fast-forward forward-chaining planner in Haskell. The main interface is the quasi-quoter huff, which allows the user to define re-usable domains that can be used with the planner to solve different problems.

Example

Consider the blocks world planning domain from Chapter 11 of "Artificial Intelligence: A Modern Approach". The domain includes two actions, Move and MoveToTable, four objects, A, B, C, Table, and two predicates, On and Clear. Embedding the domain in Haskell using huff looks like this:

module Main where

import Huff

[huff|

  domain BlocksWorld {
    object Obj = A | B | C | Table

    predicate on(Obj,Obj), clear(Obj)

    operator Move(b: Obj, x: Obj, y: Obj) {
      requires: on(b,x), clear(b), clear(y)
      effect:   on(b,y), clear(x), !clear(y)
    }

    operator MoveToTable(b: Obj, x: Obj) {
      requires: on(b,x), clear(b)
      effect:   on(b,Table), clear(x)
    }
  }

|]

The quasi-quoter will introduce the following declarations:

  • A data declaration for the Obj object
  • A data declaration for the BlocksWorld domain, that will consist of two constructors Move :: Obj -> Obj -> Obj -> BlocksWorld and MoveToTable :: Obj -> Obj -> BlocksWorld
  • Two classes called Has_on and Has_clear, that define the on and clear functions, respectively
  • Instances of the two Has classes for Literal and Term
  • The blocksWorld function of the type [Literal] -> [Term] -> Spec BlocksWorld

The blocksWorld function accepts the initial state and goal, and produces a Spec BlocksWorld value that can be used in conjunction with the findPlan function to attempt to find a plan. For example, the problem specified in chapter 11 Russel and Norvig can be solved as follows:

main =
  do mb <- findPlan $ blocksWorld [ on A Table, on B Table, on C Table, clear A
                                  , clear B, clear C ]
                                  [on A B, n B C]
     print mb

Running the example will produce the output:

$ find dist-newstyle -name blocksWorld -type f -exec {} \;
Just [MoveTo B Table C, MoveTo A Table B]
Metadata

Version

0.1.0.1

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows