Mathematics

Implements a rudimentary symbolic mathematical model. The entities of the model are termed operations. A system of operations is termed a program.

In namespace mathematics:

Operations

#include<hysj/mathematics/operations.hpp>

Datum

enum class datum
enumerator zero
enumerator one
enumerator minus_one
enumerator two
enumerator infinity
enumerator pi
enumerator e
Enum for representing symbolic constants.

Operation

The operation is the building blocks of our mathematical model.

enum class operation_tag
enumerator constant
enumerator negation
enumerator sign
enumerator addition
enumerator subtraction
enumerator multiplication
enumerator division
enumerator power
enumerator logarithm
enumerator differentiation
enumerator symbol
enumerator sine
enumerator equality
enumerator inequality
enumerator strict_inequality
enumerator boolean
enumerator assertion
enumerator complement
enumerator conjunction
enumerator disjunction
Names the different types of operations.

template<operation_tag t>
struct operation_id
static constexpr operation_tag tag = t
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

using constant_id = operation_id<operation_tag::constant>
using negation_id = operation_id<operation_tag::negation>
using sign_id = operation_id<operation_tag::sign>
using addition_id = operation_id<operation_tag::addition>
using subtraction_id = operation_id<operation_tag::subtraction>
using multiplication_id = operation_id<operation_tag::multiplication>
using division_id = operation_id<operation_tag::division>
using power_id = operation_id<operation_tag::power>
using logarithm_id = operation_id<operation_tag::logarithm>
using differentiation_id = operation_id<operation_tag::differentiation>
using symbol_id = operation_id<operation_tag::symbol>
using sine_id = operation_id<operation_tag::sine>
using equality_id = operation_id<operation_tag::equality>
using inequality_id = operation_id<operation_tag::inequality>
using strict_inequality_id = operation_id<operation_tag::strict_inequality>
using boolean_id = operation_id<operation_tag::boolean>
using assertion_id = operation_id<operation_tag::assertion>
using complement_id = operation_id<operation_tag::complement>
using conjunction_id = operation_id<operation_tag::conjunction>
using disjunction_id = operation_id<operation_tag::disjunction>

template<operation_tag i>
using operation_ids = std::vector<operation_id<i>>
Alias template for list of operation ids.

Shorthands

using constant_ids = operation_ids<operation_tag::constant>
using negation_ids = operation_ids<operation_tag::negation>
using sign_ids = operation_ids<operation_tag::sign>
using addition_ids = operation_ids<operation_tag::addition>
using subtraction_ids = operation_ids<operation_tag::subtraction>
using multiplication_ids = operation_ids<operation_tag::multiplication>
using division_ids = operation_ids<operation_tag::division>
using power_ids = operation_ids<operation_tag::power>
using logarithm_ids = operation_ids<operation_tag::logarithm>
using differentiation_ids = operation_ids<operation_tag::differentiation>
using symbol_ids = operation_ids<operation_tag::symbol>
using sine_ids = operation_ids<operation_tag::sine>
using equality_ids = operation_ids<operation_tag::equality>
using inequality_ids = operation_ids<operation_tag::inequality>
using strict_inequality_ids = operation_ids<operation_tag::strict_inequality>
using boolean_ids = operation_ids<operation_tag::boolean>
using assertion_ids = operation_ids<operation_tag::assertion>
using complement_ids = operation_ids<operation_tag::complement>
using conjunction_ids = operation_ids<operation_tag::conjunction>
using disjunction_ids = operation_ids<operation_tag::disjunction>

Groups

enum class operation_group_tag
enumerator expression
enumerator equation
enumerator logical_expression
Names the different types of operation-groups.

template<operation_group_tag G>
unspecified operation_group_members
An operation group is defined in terms of a tuple of operation_tag-constants, with:
expression \(\rightarrow\) constant, sign, negation, addition, subtraction, multiplication, division, power, logarithm, differentiation, sine, symbol
equation \(\rightarrow\) equality, inequality, strict_inequality
logical_expression \(\rightarrow\) boolean, symbol, assertion, complement, conjunction, disjunction

template<operation_group_tag>
struct operation_group_id
unspecified operation
A group-id holds a variant over the operation-ids of its member-operations.

Shorthands

using expression_id = operation_group_id<operation_group_tag::expression>
using equation_id = operation_group_id<operation_group_tag::equation>
using logical_expression_id = operation_group_id<operation_group_tag::logical_expression>

template<operation_group_tag g>
using operation_group_ids = std::vector<operation_group_id<g>>
List of operation group ids.

Shorthands

using expression_ids = operation_group_ids<operation_group_tag::expression>
using equation_ids = operation_group_ids<operation_group_tag::equation>
using logical_expression_ids = operation_group_ids<operation_group_tag::logical_expression>

Operands

template<operation_tag>
struct 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

template<>
struct operation_operands<operation_tag::constant>
template<>
struct operation_operands<operation_tag::negation>
unspecified expression
template<>
struct operation_operands<operation_tag::sign>
unspecified expression
template<>
struct operation_operands<operation_tag::addition>
unspecified terms
template<>
struct operation_operands<operation_tag::subtraction>
unspecified terms
template<>
struct operation_operands<operation_tag::multiplication>
unspecified factors
template<>
struct operation_operands<operation_tag::division>
unspecified dividend
unspecified divisor
template<>
struct operation_operands<operation_tag::power>
unspecified base
unspecified exponent
template<>
struct operation_operands<operation_tag::logarithm>
unspecified base
unspecified exponent
template<>
struct operation_operands<operation_tag::differentiation>
unspecified expression
unspecified variables
template<>
struct operation_operands<operation_tag::symbol>
template<>
struct operation_operands<operation_tag::sine>
unspecified angle
template<>
struct operation_operands<operation_tag::equality>
unspecified lhs
unspecified rhs
template<>
struct operation_operands<operation_tag::inequality>
unspecified lhs
unspecified rhs
template<>
struct operation_operands<operation_tag::strict_inequality>
unspecified lhs
unspecified rhs
template<>
struct operation_operands<operation_tag::boolean>
template<>
struct operation_operands<operation_tag::assertion>
unspecified equation
template<>
struct operation_operands<operation_tag::complement>
unspecified expression
template<>
struct operation_operands<operation_tag::conjunction>
unspecified expressions
template<>
struct operation_operands<operation_tag::disjunction>
unspecified expressions

Infos

Some operations have semantics beyond operand-relations. This information is taken care of by a operation-type specific operation info-type.

unspecified operation_info_type
Function mapping from operation-tag to the operation-info-type.
The only operations with a non nothing info-type are:
Constants \(\rightarrow\) std::variant<datum, integer, real>
Booleans \(\rightarrow\) bool
Symbols \(\rightarrow\) natural

Programs

#include<hysj/mathematics/programs.hpp>

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.
unspecified counts

Maintains the arity of the operation-sets.

unspecified graph

Models operand-relations between operations.

unspecified vertex_map

Mapping between operation_id and graph vertex.

unspecified infos

Mapping between operation_id and operation_info vertex.