View Source Guesswork.Ast.Statement protocol (Guesswork v0.8.0)
A Statement is a semantically complete value. It is in no way required to be logically consistent.
Summary
Functions
Searches all clauses of the statement looking for values that match the predicate.
Takes a statement (ideally non-concrete) and a knowledge base and attempts to find any permutations of bindings for the variables that are true according to the knowledge base and statement.
Attempts to simplify the statement into a less nested operation and returns nil if the statement holds no logical information.
Takes an environment (a mapping of variables to entities) and substitutes the entities into any place the variable is.
Types
@type env() :: %{ required(Guesswork.Ast.Variable.t()) => Guesswork.Ast.Entity.t() | Guesswork.Ast.Variable.t() }
@type stream() :: Enumerable.t(Guesswork.Answer.t() | :halt)
@type t() :: term()
All the types that implement this protocol.
Functions
Searches all clauses of the statement looking for values that match the predicate.
@spec resolve(t(), Guesswork.Ast.Statement.Opts.t()) :: stream() | call()
Takes a statement (ideally non-concrete) and a knowledge base and attempts to find any permutations of bindings for the variables that are true according to the knowledge base and statement.
Either returns a stream of possible answer sets, or returns a closure that takes an environment and returns a stream of possible answer sets.
Attempts to simplify the statement into a less nested operation and returns nil if the statement holds no logical information.
Note that the only requirement for this function is that the input and output statements are logically equivalent, not that the result is the shallowest possible answer (in practice its quite 'greedy' so it is unlikely to produce the 'best' answer, just better).
Takes an environment (a mapping of variables to entities) and substitutes the entities into any place the variable is.