Symbolic expressions in positive characteristic

asked 2023-08-15 09:12:22 +0100

Andrei Smolensky gravatar image

Is there a way to work with symbolic expressions in positive characteristic? I know that the standard answer is to convert everything into polynomials ovef GF(p), however, this does not work when an expression features a custom function, say:

a, b = var('a, b')
foo = function('foo', nargs=1)
expr = 3 * a**3 + 5 * foo(b**2 + 2 * a)

What I really need is something similar to Maple's expr mod p;, which reduces the expression expr modulo p. It cannot be implemented by a simple rewriting, because one cannot just replace every integer in an expression by its remainder mod p (mind the powers!).

I tried taking R = SR.quotient_ring(SR.ideal(2)) and using R(expr), but this does not seem to have any effect. Using RingConverter was not a success either.

If this simplifies things, I do not need the reduction to work inside the function arguments, so simply reducing 3 * a**3 + 5 * foo(b**2 + 2 * a) to a**3 + foo(b**2 + 2 * a) would suffice.

edit retag flag offensive close merge delete

Comments

What is the end goal here? This sounds like an XY problem. You might use an ExpressionTreeWalker to solve this problem Y.

rburing gravatar imagerburing ( 2023-08-15 09:36:28 +0100 )edit

@rburing The goal is to simplify expressions with an assumption of positive characteristic. Say, in char=2 one gets (3a+b)/(a+b) = 1, but without first reducing the numerator and the denominator modulo 2 one cannot apply simplify_rational().

Andrei Smolensky gravatar imageAndrei Smolensky ( 2023-08-15 10:26:48 +0100 )edit

Perhaps, the simplest approach would be splitting the expression into subexpressions - those outside the function and those that are function arguments.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-08-16 18:42:15 +0100 )edit