Ask Your Question

a1846583's profile - activity

2016-06-17 03:03:41 -0500 received badge  Famous Question (source)
2015-12-14 11:02:24 -0500 received badge  Notable Question (source)
2015-10-26 01:05:37 -0500 received badge  Popular Question (source)
2014-12-02 04:09:13 -0500 received badge  Self-Learner (source)
2014-12-02 04:09:13 -0500 received badge  Teacher (source)
2014-12-02 00:09:45 -0500 received badge  Editor (source)
2014-12-02 00:09:22 -0500 commented answer Declaring variable to be in a particular field/ring/group

Some more head-smacking revealed I can take a quotient to get what I wanted; see my self-answer above. Thanks again for your feedback!

2014-12-02 00:07:43 -0500 answered a question Declaring variable to be in a particular field/ring/group

I think I found a workaround: make x not be the variable of the polynomial ring but rather that of the quotient of that ring by the ideal generated by z^2-z. In other words:

var('X'); x=PolynomialRing(Integers(3), 'X').quotient([X^2-1], 'x').gens()[0]
print x^3==x and x^2==1 and 3*x==0

evals to True

2014-12-01 11:52:34 -0500 received badge  Student (source)
2014-11-29 17:32:26 -0500 received badge  Scholar (source)
2014-11-29 17:32:24 -0500 commented answer Declaring variable to be in a particular field/ring/group

Thanks for your answer. I guess there are two issues here: 1) the feature request you point out as #9935 to make mod work with symbolic expressions; and 2) that sage should know that PolynomialRing(Integers(3)) doesn't need to track powers higher than 2 (and generally that PR(I(p)) doesn't need to track powers higher than p-1). Is that natural fallout from #9935 or do you think that deserves its own feature request?

At any rate, it seems the short answer to my original question is "it's not possible (yet)". Unless you can think of a workaround?

2014-11-28 10:44:44 -0500 asked a question Declaring variable to be in a particular field/ring/group

Is it possible to have Sage symbolically simplify expressions involving variables subject to the assumption that the variables take values in a defined domain (field/ring/group/etc)?

The closest I've gotten is to declare a dummy polynomial ring over my domain of interest so that its variable has some notion of the domain, e.g.:

Z3=Integers(3)
Dummy.<x> = PolynomialRing(Z3)
3*x

evaluates to "0" as I'd expect, but sage fails to simplify "x^3" to "x", which ISTM should be doable if it really understood that x is a variable in Z/3Z.

Related things I've found in my searches that haven't panned out:
1. var('x', domain=foo) -- apparently foo can only be one of real/complex/positive (where I'd like to be able to say 'Z3' in the example above)
2. assume('x is Z3') - doesn't seem to have any effect.