Last active
December 3, 2022 16:35
-
-
Save cdiggins/001524a5cb28edec0dc955b4b7de27d5 to your computer and use it in GitHub Desktop.
Work in progress of expressing algebraic concepts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Plato; | |
#region Groups | |
// https://en.wikipedia.org/wiki/Algebraic_group | |
interface IGroup<T> | |
where T : IGroup<T> | |
{ | |
T GroupOperation(T x); | |
} | |
// https://en.wikipedia.org/wiki/Abelian_group | |
interface IAbelianGroup<T> | |
: IGroup<T> | |
where T : IAbelianGroup<T> | |
{ | |
T GroupOperation(T x); | |
} | |
// https://en.wikipedia.org/wiki/Group_(mathematics) | |
// Technically a commutative Abelian group over addition | |
[Concept] | |
interface IAdditiveGroup<T> | |
: IAbelianGroup<T> | |
where T : IAdditiveGroup<T> | |
{ | |
T Add(T x); | |
T Zero { get; } // AKA Additive Identity | |
T Negate(); // AKA Additive Inverse | |
//T Subtract(T x); Trivially derived. = Add(x.Negate()) | |
// NOTE: Operator = Add | |
} | |
// https://en.wikipedia.org/wiki/Multiplicative_group | |
// Technically a multiplicative group is not necessarily an additive group BUT | |
[Concept] | |
interface IMultiplicativeGroup<T> | |
: IAbelianGroup<T> | |
where T : IMultiplicativeGroup<T> | |
{ | |
T Multiply(T x); | |
T Unit { get; } // AKA Multiplicative Identity | |
// NOTE: Operator = Multiply | |
} | |
#endregion | |
#region Rings | |
// https://en.wikipedia.org/wiki/Ring_(mathematics) | |
// Rings do not necessarily have a multiplicative inverse, so divide is not necessarily well-defined | |
[Concept] | |
interface IRing<T> | |
: IAdditiveGroup<T>, IMultiplicativeGroup<T> | |
where T : IRing<T> | |
{ | |
} | |
// https://en.wikipedia.org/wiki/Division_ring | |
[Concept] | |
interface IDivisionRing<T> | |
: IRing<T> | |
where T : IDivisionRing<T> | |
{ | |
T Divide(T x); | |
T Reciprocal(); // AKA Multiplicative Inverse | |
} | |
// https://en.wikipedia.org/wiki/Division_ring | |
interface ICommutativeDivisionRing<T> | |
: IDivisionRing<T> | |
where T : ICommutativeDivisionRing<T> | |
{ | |
} | |
// https://en.wikipedia.org/wiki/Quaternion | |
// Quaternions are non-commutative division rings | |
[Concept] | |
interface IQuaternion<T, TElement> : IDivisionRing<T> | |
where T : IQuaternion<T, TElement> | |
where TElement : IReal<TElement> | |
{ | |
TElement A { get; } | |
TElement B { get; } | |
TElement C { get; } | |
TElement D { get; } | |
IQuaternion<T, TElement> BasisI { get; } | |
IQuaternion<T, TElement> BasisJ { get; } | |
IQuaternion<T, TElement> BasisK { get; } } | |
#endregion | |
#region Fields | |
// https://en.wikipedia.org/wiki/Field_(mathematics) | |
// Fields support commutative division | |
[Concept] | |
interface IField<T> | |
: ICommutativeDivisionRing<T> | |
where T : IField<T> | |
{ | |
} | |
[Concept] | |
interface IStrictOrder<T> | |
where T : IStrictOrder<T> | |
{ | |
bool LessThan(T x, T y); | |
} | |
// https://en.wikipedia.org/wiki/Ordered_field | |
[Concept] | |
interface IOrderedField<T> | |
: IField<T>, IStrictOrder<T> | |
where T : IOrderedField<T> | |
{ | |
} | |
// https://en.wikipedia.org/wiki/Real_number | |
[Concept] | |
interface IReal<T> | |
: IOrderedField<T> | |
where T : IReal<T> | |
{ | |
} | |
// https://en.wikipedia.org/wiki/Rational_number | |
[Concept] | |
interface IRational<T, TInteger> | |
: IField<T> | |
where T : IRational<T, TInteger> | |
{ | |
TInteger Numerator { get; } | |
TInteger Denominator { get; } | |
} | |
// https://en.wikipedia.org/wiki/Complex_number | |
[Concept] | |
interface IComplex<T, TElement> | |
: IField<T>, IVector<T, TElement> | |
where T : IComplex<T, TElement> | |
where TElement : IReal<TElement> | |
{ | |
TElement A { get; } | |
TElement B { get; } | |
IComplex<T, TElement> BasisI { get; } | |
} | |
#endregion | |
#region ordering and lattices | |
// https://en.wikipedia.org/wiki/Partially_ordered_group | |
[Concept] | |
interface IPartiallyOrdered<T> : IAdditiveGroup<T> | |
where T : IPartiallyOrdered<T> | |
{ | |
bool LessThanOrEqualTo(T x); | |
// bool Positive() => Zero.LessThanOrEqualTo(self); | |
// bool Negative() => self.LessThanOrEqualTo(self.Zero); | |
} | |
// https://en.wikipedia.org/wiki/Lattice_(order) | |
[Concept] | |
interface ILattice<T> where T : ILattice<T> | |
{ | |
T LeastUpperBound(T other); | |
T GreatestLowerBOund(T other); | |
} | |
#endregion | |
#region modules and vector space | |
[Concept] | |
interface IScalable<T, TScalar> | |
where T : IScalable<T, TScalar> | |
{ | |
T Multiply(TScalar scalar); | |
T Divide(TScalar scalar); | |
} | |
// https://en.wikipedia.org/wiki/Module_(mathematics) | |
[Concept] | |
interface IModule<T, TElement> | |
: IAdditiveGroup<T>, IScalable<T, TElement> | |
where T : IModule<T, TElement> | |
where TElement : IRing<TElement> | |
{ | |
int Dimensionality(T x); | |
} | |
[Concept] | |
// https://en.wikipedia.org/wiki/Vector_space | |
interface IVector<T, TScalar> | |
: IModule<T, TScalar> | |
where T : IVector<T, TScalar> | |
where TScalar : IField<TScalar> | |
{ | |
T DotProduct(T x); | |
TScalar Length { get; } | |
T Normal { get; } | |
IArray<T> CanonicalBasis { get; } | |
} | |
[Concept] | |
interface IVector3<T, TScalar> | |
: IModule<T, TScalar> | |
where T : IVector<T, TScalar> | |
where TScalar : IField<TScalar> | |
{ | |
T CrossProduct(T other); | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment