View Source Guesswork.Ast.Fact (Guesswork v0.4.4)
A fact is just a relationship (string) and some entities (concrete or non-concrete) and states that the relationship hold for those values in that order.
Summary
Functions
Extracts the relationship name and arity.
Takes two facts and attempt to 'match' them by ensuring that their relationships match, all concrete terms match, and then binding any variables to the opposite entity. Returns nil if the match fails, an answer set if it succeeds.
Attempts to substitute the values in the second fact for any variables in the first. Returns nil if the relation doesn't match, any concrete entities don't match, or if the second fact attempts to substitute a variable for a concrete value.
Types
@type t() :: %Guesswork.Ast.Fact{ args: [Guesswork.Ast.Term.entity() | Guesswork.Ast.Variable.t()], arity: integer(), relationship: String.t() }
Functions
Extracts the relationship name and arity.
@spec match(t(), t(), String.t()) :: nil | Guesswork.Answer.t()
Takes two facts and attempt to 'match' them by ensuring that their relationships match, all concrete terms match, and then binding any variables to the opposite entity. Returns nil if the match fails, an answer set if it succeeds.
Note that the same concrete fact matched on itself will result in an empty answer set, and that variables cannot match variables.
@spec new(String.t(), [Guesswork.Ast.Term.entity() | Guesswork.Ast.Variable.t()]) :: t()
@spec substitute(t(), t()) :: Guesswork.Ast.Statement.env() | nil
Attempts to substitute the values in the second fact for any variables in the first. Returns nil if the relation doesn't match, any concrete entities don't match, or if the second fact attempts to substitute a variable for a concrete value.