View Source Guesswork.Ast.Statement protocol (Guesswork v0.4.4)
A Statement is a semantically complete value. It is in no way required to be logically consistent.
Summary
Functions
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.Term.entity() | Guesswork.Ast.Variable.t() }
@type t() :: term()
All the types that implement this protocol.
Functions
@spec resolve(t(), boolean(), Guesswork.Ast.Statement.Opts.t()) :: Enumerable.t(Guesswork.Answer.t())
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.
The function also tracks the 'negated' state of the clause it is on, or if the variables it is handling are notted or not.
This function should always return a stream.
The options passed to this function do not have to be used by all implementations, but should always be passed on so that deeper statements can access them.
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 equitant, 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.