View Source Guesswork.Ast.Rule (Guesswork v0.4.4)

A rule maps a (ideally non-concrete) fact to a defining statement.

Summary

Functions

Attempts to substitute the values in the fact for any variables in the rule's header. Returns nil if the relation doesn't match, any concrete entities don't match, or if attempting to substitute a variable for a concrete value.

Types

@type t() :: %Guesswork.Ast.Rule{
  definition: Guesswork.Ast.Statement.t(),
  header: Guesswork.Ast.Fact.t()
}

Functions

@spec get_metadata(t()) :: Guesswork.Ast.Fact.metadata()
Link to this function

simplify_definition(rule)

View Source
@spec simplify_definition(t()) :: t()
@spec substitute(t(), Guesswork.Ast.Fact.t()) :: Guesswork.Ast.Statement.t() | nil

Attempts to substitute the values in the fact for any variables in the rule's header. Returns nil if the relation doesn't match, any concrete entities don't match, or if attempting to substitute a variable for a concrete value.