Operation traits

Traits describe algebraic structure of operation heads — associativity and commutativity change how pattern children match subject arguments; identity_element supplies the element a segment binds under an "empty" capture where the head has one.

MatchMaker.identity_element — Function
identity_element(f, _::DataType) -> Any

An e such that f(e, x) ≡ x for result symtype ST, or nothing if none is declared. Used for singleton-subject coercion (DESIGN.md §4.6).

source
MatchMaker.OperationTraitsCtx — Type
OperationTraitsCtx

Metadata context key (a DataType, per the SymbolicUtils metadata convention) under which an OperationTraits value is stored on a symbolic head Sym. This is the only channel that can mark a symbolic function as associative/commutative (DESIGN.md §3.5).

source
MatchMaker.set_operation_traits — Function
set_operation_traits(
    f::SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal};
    associative,
    commutative,
    identity
) -> SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymReal}

Attach an OperationTraits entry to the symbolic head f (must be a function symbolic — FnType symtype) and return it. The returned Sym is used as the operation in patterns/subjects; trait lookups read its metadata. With all-default flags f is returned unchanged.

source