# Typed variables

Anonymous

I want Sage to solve equations in Zmod(n) for a fixed n. To state the equations i declare variables with var, so they are in SR instead of Zmod(n). The domain keyword only allows a small set of possible domains (as strings). Is there a way to declare the type of a variable besides the domain parameter?

edit retag close merge delete

Equations in how many variables? Is n prime by any chance? The usual approach is to work with ideals and varieties, but this is best supported over fields.

( 2020-06-10 14:28:22 +0200 )edit

The first application that came to mind was to show that there are no ISBN10 numbers where swaps of (non-identical) consequitive digits result the same checksum digit. That would be nine or ten variables in Zmod(10). But it would be of general interest to know if variables in sage necessarily can only have a handful of types (the strings allowed for the domain keyword).

( 2020-06-10 16:53:15 +0200 )edit

So the question is rather... "is there a way to declare the type of variables inside var, so that even solve understands them..."?! Well, yes, just extend the sage code to work for the own purposes.

Instead, why not use sage with the given functionality? Zmod(10) is a finite ring, and a small number of digits can be easily parsed and accepted / rejected based on some special conditions (given by the equations in the OP).

(Asking as Anonymous is not really a good way...)

( 2020-06-12 14:28:33 +0200 )edit