Let
C = weight of Chester
A = weight of Ally
From the information given,
Both dogs weigh 40 pounds. Therefore,
C + A = 40 --- (1)
In addition, Chester weighs 4 pounds more than Ally. Therefore,
C = A + 4 ---- (2)
Substituting for C from equation (2) in equation (1);
A + 4 + A = 40
2A + 4 = 40
2A = 40 -4 = 36
2A = 36
A = 36/2
A = 18 pounds
Therefore, Ally weighs 18 pounds.