This site is for a previous version of RelationalAI.

# The Algebra Library (alglib)

Collection of algebraic operations.

## nullary_relation

View source
``nullary_relation(∼)``

`true` if `∼` is a relation of 0-arity.

Note: In case of `∼` is a operator, use space after `∼` as temporary workaround. eg., `nullary_relation(= )`

## unary_relation

View source
``unary_relation(∼)``

`true` if `∼` is a unary relation.

Note: In case of `∼` is a operator, use space after `∼` as temporary workaround. eg., `unary_relation(= )`

## binary_relation

View source
``binary_relation(∼)``

`true` if `∼` is a binary relation.

Note: In case of `∼` is a operator, use space after `∼` as temporary workaround. eg., `binary_relation(= )`

## ternary_relation

View source
``ternary_relation(∼)``

`true` if `∼` is a ternary relation.

Note: In case of `∼` is a operator, use space after `∼` as temporary workaround. eg., `ternary_relation(= )`

## irreflexive

View source
``irreflexive(D, ∼)``

A binary relation is irreflexive if `a ∼ a` is never true for all `a` in `D`.

## reflexive

View source
``reflexive(D, ∼)``

A binary relation is reflexive if `a ∼ a` is always true for all `a` in `D`.

## symmetric

View source
``symmetric(D, ∼)``

A binary relation is symmetric if for all `a` and `b` in `D`, whenever `a ∼ b` is true, then also `b ∼ a` is also true.

## antisymmetric

View source
``antisymmetric(D, ∼)``

A binary relation is antisymmetric if for all `a` and `b` in `D`, whenever `a ∼ b` and `b ∼ a` are true, then `b = a`.

## transitive

View source
``transitive(D, ∼)``

A binary relation is transitive if for all `a`, `b` and `c` in `D`, whenever `a ∼ b` and `b ∼ c` are true, then also `a ∼ c` is true.

## equivalence_relation

View source
``equivalence_relation(D, ∼)``

A binary relation is an equivalence_relation if it is reflexive, symmetric, and transitive

## unary_relation_substitution_laws

View source
``unary_relation_substitution_laws(D, R, ≈)``

A unary relation obeys substitution laws if the relation `R` produces the same results when values are substituted according to the binary relation `≈`.

For example, `unary_relation_substitution_laws({1; 2}, {1; 2}, (1, 2))` is true because the result of `R(1)` remains true when `1` is replaced by `2`.

## binary_relation_substitution_laws

View source
``binary_relation_substitution_laws(D, R, ≈)``

A binary relation obeys substitution laws if the relation `R` produces the same results when values are substituted according to the binary relation `≈`.

## preorder

View source
``preorder(D, ≼)``

A binary relation `≼` is a preorder if it is reflexive and transitive.

## partial_order

View source
``partial_order(D, ≼)``

A binary relation `≼` is a partial order if it is reflexive, antisymmetric, and transitive.

## strict_partial_order

View source
``strict_partial_order(D, ≺)``

A binary relation `≺` is a strict partial order if it is irreflexive, antisymmetric, and transitive. This is similar to a partial order, but is irreflexive rather than reflexive.

## comparable

View source
``comparable(a, b, ≼)``

Two elements `a` and `b` are comparable if either `a ≼ b` or `b ≼ a`.

## total_order

View source
``total_order(D, ≼)``

A binary relation `≼` is a total order if it is a partial order, and every element in `D` is comparable with every other element in `D` with respect to the partial order.

## strict_total_order

View source
``strict_total_order(D, ≺)``

A binary relation `≺` is a strict total order if it is a strict partial order, and every element in `D` is either comparable or equal to another element in `D`.

## maximal_element

View source
``maximal_element[D, ≼]``

The maximal element of a partial order `≼` is an element which is greater than all other elements in `D`.

## has_maximal_element

View source
``has_maximal_element(D, ≼)``

`true` if the partial order `≼` contains a maximal element.

## minimal_element

View source
``minimal_element[D, ≼]``

The minimal element of a partial order `≼` is an element which is less than all other elements in `D`.

## has_minimal_element

View source
``has_minimal_element(D, ≼)``

`true` if the partial order `≼` contains a minimal element.

## unary_operator

View source
``unary_operator(D, ⊙)``

A unary operator takes one argument and returns another argument of the same type, i.e., it can be represented as a binary relation.

## binary_operator

View source
``binary_operator(D, ⊙)``

A binary operator takes two arguments and returns another argument of the same type, i.e., it can be represented as a relation of arity 3.

## approximately_commutative

View source
``approximately_commutative(D, ⊙, ≈)``

A binary operator `⊙` is approximately commutative if `a ⊙ b` is approximately equal to `b ⊙ a` for all `a` and `b` in `D`, where approximately equal is defined by the binary relation `≈`.

## commutative

View source
``commutative(D, ⊙)``

A binary operator `⊙` is commutative if `a ⊙ b` is equal to `b ⊙ a` for all `a` and `b` in `D`.

## approximately_associative

View source
``approximately_associative(D, ⊙, ≈)``

A binary operator `⊙` is approximately associative if `(a ⊙ b) ⊙ c` is approximately equal to `a ⊙ (b ⊙ c)` for all `a`, `b` and `c` in `D`, where approximately equal is defined by the binary relation `≈`.

## associative

View source
``associative(D, ⊙)``

A binary operator `⊙` is associative if `(a ⊙ b) ⊙ c` is equal to `a ⊙ (b ⊙ c)` for all `a`, `b` and `c` in `D`.

## idempotent

View source
``idempotent(D, ⊙, ≈)``

A binary operator `⊙` is idempotent if `a ⊙ a = a` for all `a` in `D`.

## left_identity

View source
``left_identity[D, ⊙]``

A left identity of a binary operator `⊙` is an element `i` such that `i ⊙ a = a` for all `a` in `D`.

## has_left_identity

View source
``has_left_identity(D, ⊙)``

`true` if `⊙` has a left identity.

## right_identity

View source
``right_identity[D, ⊙]``

A right identity of a binary operator `⊙` is an element `i` such that `a ⊙ i = a` for all `a` in `D`.

## has_right_identity

View source
``has_right_identity(D, ⊙)``

`true` if `⊙` has a right identity.

## identity

View source
``identity[D, ⊙]``

An identity of a binary operator `⊙` is both a left and right identity.

## has_identity

View source
``has_identity(D, ⊙)``

`true` if `⊙` has an identity.

## approximately_has_inverse

View source
``approximately_has_inverse(D, ⊙, N, ≈)``

For a binary relation `⊙`, an inverse of an element `a` is an element `b` such that `a ⊙ b` is approximately equal to the identity element. For `approximately_has_inverse`, the inverse operator is given as `N`, so the inverse of `a` is `N[a]`, and approximately equal to is defined by `≈`.

## left_zero

View source
``left_zero[D, ⊙]``

A left zero of a binary operator `⊙` is an element `z` such that `z ⊙ a = z` for all `a` in `D`.

## has_left_zero

View source
``has_left_zero(D, ⊙)``

`true` if `⊙` has a left zero.

## right_zero

View source
``right_zero[D, ⊙]``

A right zero of a binary operator `⊙` is an element `z` such that `z ⊙ a = z` for all `a` in `D`.

## has_right_zero

View source
``has_right_zero(D, ⊙)``

`true` if `⊙` has a right zero.

## approximately_left_distributive

View source
``approximately_left_distributive(D, ⊗, ⊕, ≈)``

A binary operator `⊗` is approximately left distributive over another binary operator `⊕` if `a ⊗ (b ⊕ c)` is approximately equal to `(a ⊗ b) ⊕ (a ⊗ c)` for all `a`, `b` and `c` in `D`.

## left_distributive

View source
``left_distributive(D, ⊗, ⊕)``

A binary operator `⊗` is left distributive over another binary operator `⊕` if `a ⊗ (b ⊕ c)` is equal to `(a ⊗ b) ⊕ (a ⊗ c)` for all `a`, `b` and `c` in `D`.

## approximately_right_distributive

View source
``approximately_right_distributive(D, ⊗, ⊕, ≈)``

A binary operator `⊗` is approximately right distributive over another binary operator `⊕` if `(a ⊕ b) ⊗ c` is approximately equal to `(a ⊗ c) ⊕ (b ⊗ c)` for all `a`, `b` and `c` in `D`.

## right_distributive

View source
``right_distributive(D, ⊗, ⊕, ≈)``

A binary operator `⊗` is right distributive over another binary operator `⊕` if `(a ⊕ b) ⊗ c` is equal to `(a ⊗ c) ⊕ (b ⊗ c)` for all `a`, `b` and `c` in `D`.

## approximately_distributive

View source
``approximately_distributive(D, ⊗, ⊕, ≈)``

A binary operator `⊗` is approximately distributive over another binary operator `⊕` if it is approximately both left and right distributive.

## distributive

View source
``distributive(D, ⊗, ⊕)``

A binary operator `⊗` is distributive over another binary operator `⊕` if it is both left and right distributive.

## absorption_laws

View source
``absorption_laws(D, ⊓, ⊔)``

Binary operator `⊓` and `⊔` obey absorption laws if `a ⊔ (a ⊓ b) = a = a ⊓ (a ⊔ b)` for all `a` and `b` in `D`. The absorption laws are one of the defining characteristics of the meet and join operations of a lattice.

## approximately_zero_annihilation

View source
``approximately_zero_annihilation(D, ⊙, ≈)``

A binary relation `⊙` obeys approximate zero annihilation if there exists an element that is approximately both a left and right zero.

## zero_of_operator

View source
``zero_of_operator[D, ⊙]``

A zero of a binary operator `⊙` is an element that is both a left and right zero.

## zero_annihilation

View source
``zero_annihilation(D, ⊙)``

A binary relation `⊙` obeys zero annihilation if there exists an element that is both a left and right zero.

## semilattice

View source
``semilattice(D, ⊓)``

A semilattice is a set `D`, with an operator `⊓`, such that `⊓` is commutative, associative, and idempotent. The classic example of a semilattice is a set of subsets with the intersection operator.

## bounded_semilattice

View source
``bounded_semilattice(D, ⊓)``

A bounded semilattice is a semilattice with a maximal element. Equivalently, a semilattice is bounded if it is an idempotent commutative monoid.

## lattice

View source
``lattice(D, ⊓, ⊔)``

A lattice is a set `D` with two operators, `⊓` and `⊔`, usually denoted `join` and `meet` respectively, such that `(D, ⊓)` and `(D, ⊔)` are semilattices, and the operators `⊓` and `⊔` obey absorption laws.

## meet_bounded_lattice

View source
``meet_bounded_lattice(D, ⊓, ⊔)``

A lattice is meet bounded if the meet operator `⊓` forms a bounded semilattice.

## join_bounded_lattice

View source
``join_bounded_lattice(D, ⊓, ⊔)``

A lattice is join bounded if the join operator `⊔` forms a bounded semilattice.

## bounded_lattice

View source
``bounded_lattice(D, ⊓, ⊔)``

A lattice is bounded if both the meet and join operators form bounded semilattices.

## partial_order_and_lattice

View source
``partial_order_and_lattice(D, ≼, ⊓, ⊔)``

A lattice is partially ordered if it has an operator `≼` defining a partial order, such that `a ≼ b` if and only if `(a ⊓ b) = a`, and `(a ⊔ b) = b`.

## partial_order_and_meet_bounded_lattice

View source
``partial_order_and_meet_bounded_lattice(D, ≼, ⊓, ⊔)``

A partially ordered lattice is meet bounded if the meet operator `⊓` forms a bounded semilattice, and the identity of `⊓` is the maximal element of `≼`.

## partial_order_and_join_bounded_lattice

View source
``partial_order_and_join_bounded_lattice(D, ≼, ⊓, ⊔)``

A partially ordered lattice is join bounded if the join operator `⊔` forms a bounded semilattice, and the identity of `⊔` is the minimal element of `≼`.

## partial_order_and_bounded_lattice

View source
``partial_order_and_bounded_lattice(D, ≼, ⊓, ⊔)``

A partially ordered lattice is bounded if is both meet and join bounded.

## approximate_monoid

View source
``approximate_monoid(D, ⊙, ≈)``

An approximate monoid is a set `D` with a binary operator `⊙` that is approximately associative and has an identity element.

## monoid

View source
``monoid(D, ⊙)``

A monoid is a set `D` with a binary operator `⊙` that is associative and has an identity element.

## approximate_commutative_monoid

View source
``approximate_commutative_monoid(D, ⊙, ≈)``

An approximate commutative monoid is an approximate monoid where the operator `⊙` is approximately commutative.

## commutative_monoid

View source
``commutative_monoid(D, ⊙)``

A commutative monoid is a monoid where the operator `⊙` is commutative.

## approximate_group

View source
``approximate_group(D, ⊙, N, ≈)``

An approximate group is an approximate monoid where the operator `⊙` has approximate inverses defined by `N`.

## group

View source
``group(D, ⊙, N)``

A group is a monoid where the operator `⊙` has inverses defined by `N`.

## approximate_abelian_group

View source
``approximate_abelian_group(D, ⊙, N, ≈)``

An approximate abelian group is an approximate commutative monoid where the operator `⊙` has approximate inverses defined by `N`.

## abelian_group

View source
``abelian_group(D, ⊙, N)``

An abelian group is a commutative monoid where the operator `⊙` has inverses defined by `N`.

## approximate_semiring

View source
``approximate_semiring(D, ⊕, ⊙, ≈)``

An approximate semiring is a set `D` with two operators, `⊕` and `⊙`, where `⊕` forms an approximate commutative monoid, `⊙` forms an approximate monoid and has an approximate zero, `⊙` distributes over `⊕`, and the identity of `⊕` is approximately equal to the zero of `⊙`.

## semiring

View source
``semiring(D, ⊕, ⊙)``

A semiring is an approximate semiring with equality defined as `=`.

## approximate_ring

View source
``approximate_ring(D, ⊕, N, ⊙, ≈)``

An approximate ring is an approximate semiring where the `⊕` operator has inverses defined by `N`.

## ring

View source
``ring(D, ⊕, N, ⊙)``

A ring is a semiring where the `⊕` operator has inverses.