Packages

Guesswork is a logic programming library for Elixir. It is heavily inspired by Prolog, but attempts to use idiomatic Elixir when expressing problems and their solutions.

Current section

Files

Jump to
guesswork lib guesswork.ex
Raw

lib/guesswork.ex

defmodule Guesswork do
@moduledoc """
Guesswork allows the creation of logical statements and knowledge databases
which then can be used together to figure out answers to questions stated
in those logical systems.
"""
alias Guesswork.Ast.Statement
alias Guesswork.Ast.Statement.Opts
alias Guesswork.Answer
alias Guesswork.Answer.Result
alias Guesswork.Query
defmodule EmptyCollection do
@moduledoc """
A collection with no facts, falsehoods, or rules.
"""
use Guesswork.KnowledgeBase.Collection
end
@doc """
Takes a logical statement, a knowledge base, and a target number of answer sets,
and then returns all entity bindings for which the statement is true, according
to the knowledge base.
Available Options:
#{NimbleOptions.docs(Opts.schema())}
"""
@spec query(Statement.t(), integer(), Opts.opts_list()) :: Enumerable.t(Answer.t())
def query(statement, n, opts \\ []) do
Query.new(statement, opts)
|> Result.run(n)
end
end