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.is_associative — Function
is_associative(f, _::DataType) -> Bool
Whether f(x, f(y, z)) ≡ f(f(x, y), z) for calls whose result symtype is ST. Extension point: add methods for your own functions. For symbolic heads, traits come from OperationTraitsCtx metadata on the head Sym — see set_operation_traits.
MatchMaker.is_commutative — Function
is_commutative(f, _::DataType) -> Bool
Whether f(x, y) ≡ f(y, x) for calls whose result symtype is ST. See is_associative.
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).
MatchMaker.OperationTraits — Type
Value stored under OperationTraitsCtx on a symbolic head: associativity/commutativity flags and an optional identity element used for singleton-subject coercion (DESIGN.md §4.6).
MatchMaker.OperationTraitsCtx — Type
OperationTraitsCtxMetadata 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).
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.