]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: check EJA properties with check=True.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 9 Nov 2020 11:46:15 +0000 (06:46 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 9 Nov 2020 11:46:15 +0000 (06:46 -0500)
mjo/eja/eja_algebra.py

index f327bf51aada40b33fd05fb0d1c38c124d4b545e..562797318646cb1dd837691f846fd114b44ec131 100644 (file)
@@ -96,9 +96,12 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
             category = MagmaticAlgebras(field).FiniteDimensional()
             category = category.WithBasis().Unital()
 
+        # The multiplication table had better be square
+        n = len(mult_table)
+
         fda = super(FiniteDimensionalEuclideanJordanAlgebra, self)
         fda.__init__(field,
-                     range(len(mult_table)),
+                     range(n),
                      prefix=prefix,
                      category=category)
         self.print_options(bracket='')
@@ -114,6 +117,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
             for ls in mult_table
         ]
 
+        if check:
+            if not self._is_commutative():
+                raise ValueError("algebra is not commutative")
+            if not self._is_jordanian():
+                raise ValueError("Jordan identity does not hold")
+            if not self._inner_product_is_associative():
+                raise ValueError("inner product is not associative")
 
     def _element_constructor_(self, elt):
         """
@@ -235,6 +245,55 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
     def product_on_basis(self, i, j):
         return self._multiplication_table[i][j]
 
+    def _is_commutative(self):
+        r"""
+        Whether or not this algebra's multiplication table is commutative.
+
+        This method should of course always return ``True``, unless
+        this algebra was constructed with ``check=False`` and passed
+        an invalid multiplication table.
+        """
+        return all( self.product_on_basis(i,j) == self.product_on_basis(i,j)
+                    for i in range(self.dimension())
+                    for j in range(self.dimension()) )
+
+    def _is_jordanian(self):
+        r"""
+        Whether or not this algebra's multiplication table respects the
+        Jordan identity `(x^{2})(xy) = x(x^{2}y)`.
+
+        We only check one arrangement of `x` and `y`, so for a
+        ``True`` result to be truly true, you should also check
+        :meth:`_is_commutative`. This method should of course always
+        return ``True``, unless this algebra was constructed with
+        ``check=False`` and passed an invalid multiplication table.
+        """
+        return all( (self.monomial(i)**2)*(self.monomial(i)*self.monomial(j))
+                    ==
+                    (self.monomial(i))*((self.monomial(i)**2)*self.monomial(j))
+                    for i in range(self.dimension())
+                    for j in range(self.dimension()) )
+
+    def _inner_product_is_associative(self):
+        r"""
+        Return whether or not this algebra's inner product `B` is
+        associative; that is, whether or not `B(xy,z) = B(x,yz)`.
+
+        This method should of course always return ``True``, unless
+        this algebra was constructed with ``check=False`` and passed
+        an invalid multiplication table.
+        """
+        for i in range(self.dimension()):
+            for j in range(self.dimension()):
+                for k in range(self.dimension()):
+                    x = self.monomial(i)
+                    y = self.monomial(j)
+                    z = self.monomial(k)
+                    if (x*y).inner_product(z) != x.inner_product(y*z):
+                        return False
+
+        return True
+
     @cached_method
     def characteristic_polynomial_of(self):
         """