# Solving a system of linear equations with constraints

I tried to look for questions similar to mine but I couldn't find any.

My goal is to solve the following system of equations:

\begin{align*} -3a+\frac12 b+\frac32 c+\frac94&=p\\ -\frac12 a-\frac14 b-\frac34 c&=q\\ \frac12 a+\frac14 b+\frac34 c+\frac32&=r\\ -\frac12 a-\frac14 b-\frac34 c+\frac14&=s\\ -\frac12 a-\frac14 b-\frac34 c+\frac34&=t \end{align*}

With $a, b, c$ non-negative integers and $p,q,r,s,t$ rationals non-integers.

My attempt to tackle the problem was the following:

Reduce[-3*a + b/2 + 3*c/2 + 9/4 == p
&& -a/2 - b/4 - 3*c/4 == q
&& 3/2 + a/2 + b/4 + 3*c/4 == r
&& 1/4 - a/2 - b/4 - 3*c/4 == s
&& 3/4 - a/2 - b/4 - 3*c/4 == t
&& Element[a, Integers]
&& Element[b, Integers]
&& Element[c, Integers]
&& NotElement[p, Integers]
&& NotElement[q, Integers]
&& NotElement[r, Integers]
&& NotElement[s, Integers]
&& NotElement[t, Integers]
&& a >= 0
&& 0 <= b
&& 0 <= c,
{a, b, c, p, q, r, s, t}, Rationals]


But the result I get is just a rewriting of the same equations without any explicit constraints.

The point is that I have reasons to believe that there are no solutions to this system but then I would have expected the answer: False.

Therefore I would like to know if I wrote down the code correctly and if there is a way to understand if there are solutions to the system.

• It's overdetermined (five equations vs. three unknowns), no? – J. M. will be back soon Aug 6 '17 at 17:35
• actually also the p, q, r, s, t are free, so is more like five equations eight unknowns – popoolmica Aug 6 '17 at 17:44
• As far as I can tell there are no solutions that meet you constraints that all of p, q, r, s, t be non-integers. If you allow at least one of them to be an integers there seem to infinitely many solutions. – m_goldberg Aug 6 '17 at 18:02
• That is exactly my point. But I would like to be sure of it. – popoolmica Aug 6 '17 at 18:10
• To be more clear. I have a priori reasons to think that there are no solutions if I put all of those constraints. Moreover, I tried some do cycles as a check and it seems that an integer always pops out. However even if I'm pretty convinced of the absence of the solutions I don't know how to prove it and I was hoping that mathematica could provide me an answer. – popoolmica Aug 6 '17 at 18:14

Start with a straightforward Solve:

firstsol =
FullSimplify[
Solve[-3*a + b/2 + 3*c/2 + 9/4 == p && -a/2 - b/4 - 3*c/4 == q &&
3/2 + a/2 + b/4 + 3*c/4 == r && 1/4 - a/2 - b/4 - 3*c/4 == s &&
3/4 - a/2 - b/4 - 3*c/4 == t && Element[a, Integers] &&
Element[b, Integers] && Element[c, Integers] &&
NotElement[p, Integers] && NotElement[q, Integers] &&
NotElement[r, Integers] && NotElement[s, Integers] &&
NotElement[t, Integers] && a >= 0 && 0 <= b && 0 <= c, {a, b, c,
p, q, r, s, t}, Rationals],
Element[(a | b | c), Integers] && a >= 0 && b >= 0 && c >= 0]


which gives you an error telling you that you have more unknowns than equations, along with

(*
{{p -> ConditionalExpression[1/4 (9 - 12 a + 2 b + 6 c),
1/4 (-2 a - b - 3 c) \[NotElement] Integers &&
1/4 (1 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (3 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (6 + 2 a + b + 3 c) \[NotElement] Integers &&
1/4 (9 - 12 a + 2 b + 6 c) \[NotElement] Integers],
q -> ConditionalExpression[1/4 (-2 a - b - 3 c),
1/4 (-2 a - b - 3 c) \[NotElement] Integers &&
1/4 (1 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (3 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (6 + 2 a + b + 3 c) \[NotElement] Integers &&
1/4 (9 - 12 a + 2 b + 6 c) \[NotElement] Integers],
r -> ConditionalExpression[1/4 (6 + 2 a + b + 3 c),
1/4 (-2 a - b - 3 c) \[NotElement] Integers &&
1/4 (1 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (3 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (6 + 2 a + b + 3 c) \[NotElement] Integers &&
1/4 (9 - 12 a + 2 b + 6 c) \[NotElement] Integers],
s -> ConditionalExpression[1/4 (1 - 2 a - b - 3 c),
1/4 (-2 a - b - 3 c) \[NotElement] Integers &&
1/4 (1 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (3 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (6 + 2 a + b + 3 c) \[NotElement] Integers &&
1/4 (9 - 12 a + 2 b + 6 c) \[NotElement] Integers],
t -> ConditionalExpression[1/4 (3 - 2 a - b - 3 c),
1/4 (-2 a - b - 3 c) \[NotElement] Integers &&
1/4 (1 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (3 - 2 a - b - 3 c) \[NotElement] Integers &&
1/4 (6 + 2 a + b + 3 c) \[NotElement] Integers &&
1/4 (9 - 12 a + 2 b + 6 c) \[NotElement] Integers]}}
*)


The conditions in these ConditionalExpressions are the same for each variable

SameQ @@ firstsol[[1, ;; , 2, 2]]
(* True *)


So let's see if we can find some integers a, b and c that satisfy them

FindInstance[firstsol[[1, 1, 2, 2]], {a, b, c}, Integers]

(* {} *)


No we can't. Therefore, there are no solutions.