Cat::Set

Category of sets of complex numbers

Description

Cat::Set represents the category of subsets of the complex numbers.

Sets of this category allow set-theoretic operations as well as pointwise arithmetical operations.

The main feature of Cat::Set is a particular overloading mechanism. It provides n-ary operators that can handle operands from different domains of category Cat::Set, as well as mixed input where some operands are of types not belonging to Cat::Set. Hence, in the methods of Cat::Set, operands of arbitrary type are allowed.

There are three kinds of operators: n-ary (associative and commutative), binary (not assumed to be commutative), and unary (mapping a function). Cat::Set provides generic methods for generating these kinds of operators, and uses them to define default methods overloading the common set-theoretic and arithmetical functions.

By default, any operation of sets is defined, but returns unevaluated since the arithmetical or set-theoretic expression cannot be simplified. Each domain of type Cat::Set must provide particular slots and tables in order to achieve simplifications in certain special cases.

Arithmetical operations are defined pointwise. It is not an error if some operation is not defined for all elements of a set.

Cat::Set is mainly used by domains of sets returned by solve.

Methods

expand all

Mathematical Methods

commassop — Return an n-ary commutative and associative operator for sets

commassop(operatorname)

The returned procedure first sorts its operands (which it may do because of commutativity). Those operands not belonging to a domain of category Cat::Set are handled by the usual overloading mechanism, i.e. by the slot operatorname of one of their domains. Out of the others, several operands belonging to the same domain are handled by the slot "homog".operatorname of that domain. Finally, the returned method tries to combine each possible pair of operands. If they are from the same domain, "bin".operatorname is called for them. The following is done if the operands are from different domains: let T1 and T2 be their types; then their "inhomog".operatorname slots are used. If such a slot exists in the domain T1, it must contain a table indexed by possible types T2, and the entry at that index must be a procedure that carries out the operation for exactly two arguments, the first being a T1, the second being a T2. Conversely, if such a slot exists in the domain T2, it must contain a table indexed by possible types T1, and the entry at that index must be a procedure that carries out the operation for exactly two arguments, the first being a T2, the second being a T1.

The slot "homog".operatorname, or a table entry in the slot "inhomog".operatorname, may return FAIL in order to indicate that it could not simplify its input; if they are missing, this indicates that a simplification is generally not possible for input of this type. In these cases, the returned procedure proceeds by trying to combine another two of the given arguments.

A slot "bin".operatorname usually won't exist, except for the case that there is no "homog".operatorname; usually the latter can also take care for the case of exactly two operands.

The whole process is repeated over and over until no new simplifications occur or only one operand is left. If no more simplifications occur, an unevaluated call to the operator is returned, the arguments being all remaining operands that could not be combined further.

binop — Return a binary operator for sets

binop(operatorname)

The returned procedure uses the slot "bin".operatorname of its first argument if both arguments are of the same type. Otherwise it uses the slot "inhomogleft".operatorname of its first argument; if that fails, it uses the slot "inhomogright".operatorname of its second argument; each of these slots, if it exists, must contain tables, indexed by the type of the other argument, such that slot(T1, "inhomogleft".operatorname)[T2] and slot(T2, "inhomogright".operatorname)[T1] carry out the operation for objects of type T1 and T2, in this order.

No commutativity of the operation is assumed.

If the slots or table entries do not exist or return FAIL, an unevaluated call to the operator is returned.

_union — Union of sets

_union(S1, …)

_plus — Set of sums of set elements

_plus(S1, …)

The sum of sets is computed by the commutative-associative operator generated by "commassop", using the slots "homog_plus" and "inhomog_plus" of the domains of its operands.

_mult — Set of product of set elements

_mult(S1, …)

The product of sets is computed by the commutative-associative operator generated by "commassop", using the slots "homog_mult" and "inhomog_mult of the domains of its operands.

_power — Pointwise power

_power(S1, S2)

The power of sets is computed by the binary operator generated by "binop", using the slots "homog_power", "inhomogleft_power", and "inhomogright_power" of its operands.

map — Map an operation to a set

map(S, f)

By overloading this method in a particular domain, the behavior of sets changes whenever a special function is applied to them.

Was this topic helpful?