Package: egga
E-Graph Geometric Algebra (EGGA)SymbolicGeometric AlgebrawithE-GraphsThings you can do with this librarySimplify expressionsProve equalitiesSolve for variablesThings that are supportedAny signatureArbitrary number of basis vectorsSymplectic Geometric Algebra (aka Weyl Algebras)DerivativesAdd your own expression types and rules (with egglog)Based on thePython bindingsforegglogSetupSupports Python 3.8 and higher.pip install eggaUsageThe first step is to create aGeometricAlgebraobject with a given signature.
You can then use its basis vectors as well as functions exposed by it. Use the utility methods provided to do things like simplification and
equation solving. In some cases you might need to interface with egglog directly. Below are
some examples for common use-cases.Simplificationfromegga.geometric_algebraimportGeometricAlgebrafromegga.utilsimportsimplifyga=GeometricAlgebra(signature=[1.0,1.0])e_0,e_1=ga.basis_vectorse_01=e_0*e_1# Build an expression to simplifyexpr=e_01*e_0*~e_01# Prints Simplified: -e("0")print("Simplified:",simplify(ga,expr))Equation solvingfromegglogimportunionfromegga.geometric_algebraimportGeometricAlgebrafromegga.utilsimportsimplify# Pass eq_solve=True to enable the equation solving rules.# Add a cost to variable to it gets rewritten to something else.ga=GeometricAlgebra(signature=[1.0,1.0],eq_solve=True,costs={"variable":1_000})e_0,e_1=ga.basis_vectorse_01=e_0*e_1# Solve e_01 * x * ~e_01 = e_0 for xx=ga.expr_cls.variable("x")lhs=e_01*x*~e_01rhs=-e_0# Make LHS equal to RHSga.egraph.register(union(lhs).with_(rhs))assertstr(simplify(ga,x))==str(ga.expr_cls.e("0"))Equality checkfromegga.geometric_algebraimportGeometricAlgebrafromegga.utilsimportcheck_equalityga=GeometricAlgebra(signature=[1.0,1.0])e_0,e_1=ga.basis_vectorse_01=e_0*e_1# Build an lhs to check for equality to an rhslhs=e_01*e_01rhs=ga.expr_cls.scalar_literal(-1.0)assertcheck_equality(ga,lhs,rhs)The/examplesas well as the/testsdirectories contain more examples.List of expressionsOperatorsCodeDescriptionx_1 + x_2Addition of x_1 and x_2x_1 - x_2Subtraction of x_1 and x_2x_1 * x_2Multiplication of x_1 and x_2 (aka the Geometric Product)x_1 ^ x_2Wedge / exterior / outer product of x_1 and x_2x_1 | x_2Inner ("fat dot") product of x_1 and x_2-x_1Negation of x_1~x_1Reversion of x_1x_1 ** x_2x_1 to the power of x_2x_1 / x_2x_1 divided by x_2 (more generally, x_1 right-multiplied by the inverse of x_2)FunctionsCodeDescriptioninverse(x)Multiplicative inverse of xgrade_involution(x)Grade involutionof xclifford_conjugation(x)Clifford conjugateof xscalar(x)Mark x as a scalarscalar_literal(f)Create a scalar constantscalar_variable(s)Create a scalar variablee(s)Basis vectore2(s_1, s_2)Basis bivectore3(s_1, s_2, s_3)Basis trivectorvariable(s)Create a variablecos(x)Cos of xsin(x)Sin of xcosh(x)Cosh of xsinh(x)Sinh of xexp(x)Exponential function of xgrade(x)Grade of xmix_grades(x_1, x_2)Represents the mixture of two grades. If x_1 and x_2 are the same, this will be simplified tox_1.select_grade(x_1, x_2)Selects the grade x_2 part of x_1abs(x)Absolute value of xrotor(x_1, x_2)Shorthand forexp(scalar_literal(-0.5) * scalar(x_2) * x_1)sandwich(x_1, x_2)Shorthand forx_1 * x_2 * ~x_1diff(x_1, x_2)Derivative of x_1 with respect to x_2Unsupported but exists, might or might not workCodeDescriptionboolean(x)Mark x as a booleanx_1.equal(x_2)Whether x_1 equals x_2x_1.not_equal(x_2)Whether x_1 does not equal x_2CaveatsEgraphs are bad with associativity (combined with commutativity?) so things can blow upMost operations aren't "fully" implemented (eg.powonly supports powers of two right now)ContributingCode contributions as well as suggestions and comments about things that don't work yet are appreciated.
You can reach me by email attora@warlock.aior in theBivector Discord.