Clause

public struct Clause<Atom: Hashable>

A statement whose head is true given that its body is true. When the body is empty, a clause is commonly called a fact. Otherwise, it is called a rule. Clause is often used with unification variables such that conditional truths can be expressed, such as grandparent(A, B) :- parent(A, X), parent(X, B).

  • The term that is true conditional on all terms of the body being true.

    Declaration

    Swift

    public var head: Term<Atom>
  • The collection of terms that all must be true in order for head to be true.

    Declaration

    Swift

    public var body: [Term<Atom>]
  • Constructs a Clause that is always true.

    Declaration

    Swift

    public init(fact: Term<Atom>)
  • Constructs a Clause that defines a rule that is true given some set of conditions.

    Declaration

    Swift

    public init(rule: Term<Atom>, conditions: [Term<Atom>])
  • A textual description of self.

    Declaration

    Swift

    public var description: String
  • Constructs a Clause that defines a rule that is true given some set of conditions using the build closure that provides 0 unused bindings.

    Declaration

    Swift

    public init(build: () -> (rule: Term<Atom>, conditions: [Term<Atom>]))
  • Constructs a Clause that defines a rule that is true given some set of conditions using the build closure that provides 1 unused bindings.

    Declaration

    Swift

    public init(build: Binding<Term<Atom>> -> (rule: Term<Atom>, conditions: [Term<Atom>]))
  • Constructs a Clause that defines a fact using the build closure that provides 0 unused bindings.

    Declaration

    Swift

    public init(build: () -> Term<Atom>)
  • Copies this reusing any substructure that has already been copied within this context, and storing any newly generated substructure into the context.

    Declaration

    Swift

    public static func copy(this: Clause, withContext context: CopyContext) -> Clause