I want to restrict the outputs of Solve/Reduce/FindInstanceSolve/Reduce/FindInstance, etc. to "simple" rationals, which I define as rationals of the form:
$\pm \dfrac{a}{b}$, where a, b = {1, 2, 3, 4, 5, 6}$$\pm \dfrac{a}{b}\; \text{ where } \; a, b \in \{1, 2, 3, 4, 5, 6\},$$
e.g., $ \dfrac{3}{5}$$ \tfrac{3}{5}$, $5$, $- \dfrac{4}{3}$$-\tfrac{4}{3}$, etc.
...I I believe restrictions on rationals can be represented as follows:
However, SolveSolve, ReduceReduce, and FindInstanceFindInstance don't recognize this.
For example:
exprA = p + \[Rho]ρ + \[Sigma]σ == 0 && -p + r + 2 \[Nu]ν - 3 \[Rho]ρ == 0 && -2 p - \[Nu]ν - 2 \[Sigma]σ == 1 FindInstance[ exprA && -6 <= Numerator@\[Sigma]Numerator@σ <= 6 && 1 <= Denominator@\[Sigma]Denominator@σ <= 6 && -6 <= Numerator@\[Nu]Numerator@ν <= 6 && 1 <= Denominator@\[Nu]Denominator@ν <= 6 && -6 <= Numerator@r <= 6 && 1 <= Denominator@r <= 6 && -6 <= Numerator@p <= 6 && 1 <= Denominator@p <= 6 && -6 <= Numerator@\[Rho]Numerator@ρ <= 6 && 1 <= Denominator@\[Rho]Denominator@ρ <= 6, {\[Sigma]σ, \[Nu]ν, r, p, \[Rho]ρ}, Rationals, 2] With fewer variables (say, 3 instead of 5), I could instead brute-force the restriction by explicitly reformatting each variable as the ratio of sub-variables, applying value and domain restrictions to each—e.g., replacing the variable $r$ with $\frac{r1}{r2}$$\frac{r_1}{r_2}$, where $-6 <= r1 <= 6$$-6 \leq r_1 \leq 6$, $1 <= r2<= 6$$1 \leq r_2 \leq 6$, $r1\in \mathbb{Z}$$r_1\in \mathbb{Z}$ and $r2\in \mathbb{Z}$$r_2\in \mathbb{Z}$. One can then use TableTable or MapMap to recombine the sub-variables in the output into rational solutions for the variables, and delete the duplicates. E.g.:
exprB = -((3 r1)/r2) - \[Nu]1ν1/\[Nu]2ν2 + \[Sigma]1σ1/\[Sigma]2σ2 == 0 && r1/r2 + \[Nu]1ν1/\[Nu]2ν2 == 0 && -((2 \[Nu]1ν1)/\[Nu]2ν2) == 1 soln = Solve[ exprB && {\[Sigma]1σ1, \[Sigma]2σ2, \[Nu]1ν1, \[Nu]2ν2, r1, r2} \[Element] ∈ Integers && And @@ Thread[-6 <= {\[Sigma]1σ1, \[Sigma]2σ2, \[Nu]1ν1, \[Nu]2ν2, r1, r2} <= 6], {\[Sigma]1σ1, \[Sigma]2σ2, \[Nu]1ν1, \[Nu]2ν2, r1, r2}]; tab = DeleteDuplicates@ Table[soln[[j, i, 2]]/soln[[j, i + 1, 2]], {j, 1, Length@soln}, {i, 1, Length@soln[[1]] - 1, 2}]; TableForm[tab, TableHeadings -> {None, {"\[Sigma]""σ", "\[Nu]""ν", "r"}}] However, this method doesn't work with exprAexprA, since its five variables become 10, making the calculation take too long. [I stopped the following after it ran for 24 hours on my 2019 i9 iMac without producing a result.] Thus it would be nice if there were a way to apply the restrictions directly to the original rational-valued variables, rather than transforming them to ratios of integer-valued variables and thus doubling their number:
exprC = exprA /. {\[Sigma]σ -> (\[Sigma]1σ1/\[Sigma]2σ2), \[Nu]ν -> (\[Nu]1ν1/\[Nu]2ν2), r -> (r1/r2), p -> (p1/p2), \[Rho]ρ -> (\[Rho]1ρ1/\[Rho]2ρ2)} soln = Solve[ exprC && And @@ Thread[-6 <= {\[Sigma]1σ1, \[Sigma]2σ2, \[Nu]1ν1, \[Nu]2ν2, r1, r2, p1, p2, \[Rho]1ρ1, \[Rho]2ρ2} <= 6] && {\[Sigma]1σ1, \[Sigma]2σ2, \[Nu]1ν1, \[Nu]2ν2, r1, r2, p1, p2, \[Rho]1ρ1, \[Rho]2ρ2} \[Element]∈ Integers, {\[Sigma]1σ1, \[Sigma]2σ2, \[Nu]1ν1, \[Nu]2ν2, r1, r2, p1, p2, \[Rho]1ρ1, \[Rho]2ρ2}] tab = DeleteDuplicates@ Table[soln[[j, i, 2]]/soln[[j, i + 1, 2]], {j, 1, Length@soln}, {i, 1, Length@soln[[1]] - 1, 2}]; TableForm[tab, TableHeadings -> {None, {"\[Sigma]""σ", "\[Nu]""ν", "r", "p", "\[Rho]""ρ"}}]