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

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

t()

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

Functions

get_metadata(rule)

@spec get_metadata(t()) :: Guesswork.Ast.Fact.metadata()

new(header, definition)

simplify_definition(rule)

@spec simplify_definition(t()) :: t()

substitute(rule, fact)

@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.