Mathematics =========== Implements a rudimentary symbolic mathematical model. The entities of the model are termed operations. A system of operations is termed a program. .. cpp:namespace:: hysj .. cpp:namespace-push:: mathematics In namespace :cpp:any:`mathematics`: Operations ---------- :cpp:include:`#include` Datum ^^^^^ .. cpp:enum-class:: datum .. rest-script:: from hysj import mathematics Enum = mathematics.Datum for e in Enum.__members__.values(): print(f'.. cpp:enumerator:: {e.name}') | Enum for representing symbolic constants. | Operation ^^^^^^^^^ The operation is the building blocks of our mathematical model. .. cpp:enum-class:: operation_tag .. rest-script:: from hysj import mathematics Enum = mathematics.OperationTag for e in Enum.__members__.values(): print(f'.. cpp:enumerator:: {e.name}') | Names the different types of operations. | .. cpp:struct:: template operation_id .. cpp:member:: static constexpr operation_tag tag = t .. cpp:member:: natural number | Each operation has a unique id consiting of a tag which denotes the type of operation, and an number which is unique to all operation ids of that type. *Shorthands* .. rest-script:: from hysj import mathematics Enum = mathematics.OperationTag for e in Enum.__members__.values(): print(f'.. cpp:type:: {e.name}_id = operation_id') | .. cpp:type:: template operation_ids = std::vector> | Alias template for list of operation ids. *Shorthands* .. rest-script:: from hysj import mathematics Enum = mathematics.OperationTag for e in Enum.__members__.values(): print(f'.. cpp:type:: {e.name}_ids = operation_ids') Groups ^^^^^^ .. cpp:enum-class:: operation_group_tag .. rest-script:: from hysj import mathematics Enum = mathematics.OperationGroupTag for e in Enum.__members__.values(): print(f'.. cpp:enumerator:: {e.name}') | Names the different types of operation-groups. | .. cpp:var:: template unspecified operation_group_members .. rest-script:: from hysj import mathematics Enum = mathematics.OperationGroupTag print('| An operation group is defined in terms of a tuple of :cpp:type:`operation_tag`-constants, with:') for e in Enum.__members__.values(): members = mathematics.operation_group_members[e.value] print(f'| {e.name} :math:`\\rightarrow` {", ".join([m.name for m in members])}') | .. cpp:struct:: template operation_group_id .. cpp:member:: unspecified operation | A group-id holds a variant over the operation-ids of its member-operations. *Shorthands* .. rest-script:: from hysj import mathematics Enum = mathematics.OperationGroupTag for e in Enum.__members__.values(): print(f'.. cpp:type:: {e.name}_id = operation_group_id') | .. cpp:type:: template operation_group_ids = std::vector> | List of operation group ids. *Shorthands* .. rest-script:: from hysj import mathematics Enum = mathematics.OperationGroupTag for e in Enum.__members__.values(): print(f'.. cpp:type:: {e.name}_ids = operation_group_ids') Operands ^^^^^^^^ .. cpp:struct:: template operation_operands | Models the operands of an operation. The primary template is an empty struct, and signifies a nullary operator. Its members are operation-ids, operation-group-ids or list of these. *Specializations* .. rest-script:: import inspect from hysj import mathematics Enum = mathematics.OperationTag for e in Enum.__members__.values(): print(f'.. cpp:struct:: template<> operation_operands') print('') OperandsType = mathematics.operation_operand_types[e.value] for m in inspect.getmembers(OperandsType,lambda m:isinstance(m,property)): print(f' .. cpp:member:: unspecified {m[0]}') Infos ^^^^^ Some operations have semantics beyond operand-relations. This information is taken care of by a operation-type specific operation info-type. .. cpp:var:: unspecified operation_info_type | Function mapping from operation-tag to the operation-info-type. | The only operations with a non :cpp:type:`nothing` info-type are: | Constants :math:`\rightarrow` :cpp:expr:`std::variant` | Booleans :math:`\rightarrow` :cpp:expr:`bool` | Symbols :math:`\rightarrow` :cpp:expr:`natural` | Programs -------- :cpp:include:`#include` .. cpp:struct:: program | A program represents a system of operations. This system consists of a set of operations for each type, the operation infos and operands. .. cpp:member:: unspecified counts Maintains the arity of the operation-sets. .. cpp:member:: unspecified graph Models operand-relations between operations. .. cpp:member:: unspecified vertex_map Mapping between :cpp:type:`operation_id` and :cpp:member:`graph` vertex. .. cpp:member:: unspecified infos Mapping between :cpp:type:`operation_id` and :cpp:member:`operation_info` vertex. .. cpp:namespace-pop::