270 likes | 404 Views
The I-Test. Group - 6. Manish Gupta - 05305006 Santosh Kumar - 05305003 Soumitra Pal - 05305015. Agenda. Introduction Definitions Theorems Algorithm Conclusion. Introduction. a 1 I 1 + a 2 I 2 + … + a n I n = a 0 M k ≤ I k ≤ N k , 1 ≤ k ≤ n
E N D
The I-Test Group - 6 Manish Gupta - 05305006Santosh Kumar - 05305003Soumitra Pal - 05305015
Agenda • Introduction • Definitions • Theorems • Algorithm • Conclusion
Introduction a1I1 + a2I2 + … + anIn = a0 Mk≤ Ik≤ Nk , 1 ≤ k ≤ n Mk & Nk can be * or integers
Introduction (2) • GCD-Test • Considers integrality • Ignores limits • Banerjee-Test • Considers limits • Ignores integrality, checks for real solution • Not applicable if some limits are unknown • How about considering both?
Definition - Solvability a1I1 + a2I2 + … + anIn = a0 is (M1,N1; M2,N2; …; Mn,Nn) integer solvable n > 0 • If there exists j1, j2 .. jn s.t.a1j1 + a2j2 + … + anjn = a0 • For each k, 1 ≤ k ≤ n: if Mk and Nk are integers then Mk ≤ jk ≤ Nk If Mk is an integer and Nk = * then Mk ≤ jk If Nk is an integer and Mk = * then jk ≤ Nk n = 0 • if a0=0
Definition - Interval Equation a1I1 + a2I2 + … + anIn = [L,U] --------- (1)L ,U integers. Mk ≤ Ik ≤ Nk , 1 ≤ k ≤ n It is a set of these equations a1I1 + a2I2 + … + anIn = L a1I1 + a2I2 + … + anIn = L+1 …. a1I1 + a2I2 + … + anIn = U
Solvability of Interval Equation • Eq(1) is (M1,N1; M2,N2; …; Mn,Nn) integer solvable • n>0, if at least 1 from the above set is integer solvable. • n=0, if L ≤ 0 ≤ U • a1I1 + a2I2 + … + anIn = a0can be written as an interval equation as follows: a1I1 + a2I2 + … + anIn = [a0 , a0]
Theorem 1 GCD test for Interval Equation a1I1 + a2I2 + … + anIn = [ L, U ] Has integer solution if and only ifL ≤ d* ceil(L/d) ≤ UWhere d = gcd(a1, a2, .., an) e.g. 4x + 6y = [9,12] 9≤10≤12 So, solution exists
Lemma 2a Shift 1 variable to right If an ≤ U-L+1, and an>0 a1I1 + a2I2 + … + anIn = [ L, U ] is (M1,N1; M2,N2; …; Mn,Nn) integer solvable iffa1I1 + a2I2 + … + an-1In-1= [ L - anNn, U - anMn]is (M1,N1; M2,N2; …; Mn-1,Nn-1) integer solvable.
Lemma 2b Shift 1 variable to right If -an ≤ U-L+1, and an< 0 a1I1 + a2I2 + … + anIn = [ L, U ] is (M1,N1; M2,N2; …; Mn,Nn) integer solvable iffa1I1 + a2I2 + … + an-1In-1 = [ L - anMn, U - anNn]is (M1,N1; M2,N2; …; Mn-1,Nn-1) integer solvable.
Theorem 2 Shift 1 variable to right If |an| ≤ U-L+1a1I1 + a2I2 + … + anIn = [ L, U ] is (M1,N1; M2,N2; …; Mn,Nn) integer solvable iffa1I1 + a2I2 + … + an-1In-1 = [ L - an+Nn + an-Mn, U - an+Mn + an-Nn ]is (M1,N1; M2,N2; …; Mn-1,Nn-1) integer solvable.
Example Usage of Theorem 2 x – 3y + 7z = 8 1≤x≤3; 1≤y≤2; 1≤z ≤ 4 gcd(1, -3, 7) = 1 GCD test says “solution may exist” Interval equation: x -3y +7z = [ 8,8] By result in the previous slidean+ = 1, an- = 0, Mn = 1, Nn =3 -3y + 7z = [ 8 - 1.3 + 0.1, 8 - 1.1 + 0.3 ] Limits for Banerjee 2≤8≤28 Banerjee test says “solution may exist” And then 7z = [5+3, 7+6] So, 7z = [8, 13] Which is impossible So, I – test says no solution.
Theorem 3 If |an| ≤ U-L+1 and the IEa1I1 + a2I2 + … + anIn = [ L, U ] is integer solvable but a1I1 + a2I2 + … + an-1In-1 = [ L - an+Nn + an-Mn, U - an+Mn + an-Nn ] is not integer solvable, then solution of In is outside [Mn, Nn]
Motivation for Theorem 4 • To apply Theorem 2, |an| ≤ U-L+1 • Can we do something if the above does not hold?
Theorem 4 Reduce both sides a1I1 + a2I2 + … + anIn = [ L, U ] is (M1,N1; M2,N2; …; Mn,Nn) integer solvable, iff (a1/d)I1 + (a2/d)I2 + … + (an/d)In = [ceil(L/d), floor(U/d) ] is (M1,N1; M2,N2; …; Mn,Nn) integer solvable Note that a1/d, a2/d, …, an/d are integers.
Example Usage of Theorem 4 2x -6y +14z =16 1≤x≤3;1≤y≤2;1≤z≤4 Both GCD and Banerjee say “maybe” Consider IE, 2x -6y +14z = [16,16] Theorem 2 is inapplicable because coefficients are greater than (U-L+1)=1 Using Theorem 4, x-3y+7z = [8,8] This we have seen before.
Theorem 5 • Analogous to Theorem 3 • Combined with result of Theorem 4
Theorem 6 Handle unknown limits when gcd = 1 If Mi=Ni=* for 1≤i≤k and gcd(a1,a2,..ak) = 1 a1I1 + a2I2 +… + ak+1Ik+1 + … + anIn = [L,U] is ( *(1),*(1); *(2),*(2) ; … ; *(k),*(k); Mk+1,Nk+1; …; Mn,Nn) integer solvable for any Mk+1,Nk+1,..,Mn,Nn. This shows if both the limits are unknown for >=1 variables and if gcd of the coefficients of those variables is 1 then no need of Theorem 2 or 4, a1I1 + a2I2 +… + ak+1Ik+1 + … + anIn = [L,U] is definitely integer solvable
Theorem 7 Handle unknown limits when gcd > 1 If Mi=Ni=* for 1≤i≤k and gcd(a1,a2,..ak) = d a1I1 + a2I2 + … + ak+1Ik+1 + … + anIn = [L,U] is (*(1),*(1); *(2),*(2) ; … ; *(k),*(k); Mk+1,Nk+1; …; Mn,Nn) integer solvable iff dI + ak+1Ik+1 + … + anIn = [L,U] is (*,*; Mk+1,Nk+1; …; Mn,Nn) is integer solvable. This shows that the set of variables with both limits unknown can be compressed into 1 variable, to reduce bookkeeping when theorem 2 and 4 are applied later.
I – Test algorithm Input: a0,a1,a2,..,an,M1,N1,…Mn,Nn Output: no,yes,maybe Algorithm: 1. If there are some unknown bounds d = gcd of coefficients of variables with unknown bounds If d is 1, apply theorem 6. Else apply theorem 7.
I – Test algorithm (2) 2. While (1) While theorem 2 is applicable apply theorem 2 if there are no more coefficients on LHS if L <= 0 <= U return yes else return no Find gcd of the coefficients in the LHS list Perform the interval-equation GCD test. If GCD test says “no” then return no If gcd != 1 apply theorem 4 else return maybe.
Example for Algo - 1 3I1 + 5I2 + a3I3 + a4I4 = a0 1 ≤ a3,a4 ≤ 5 gcd (3, 5) = 1 algo returns ‘yes’ using theorem 6
Example for Algo - 2 • 120I1 + 180I2 + 2I3 + 4I4 + 6I5 = 81 ≤ a3,a4,a5 ≤ 5 • IE: 120I1 + 180I2 + 2I3 + 4I4 + 6I5 = [8, 8] • Bounds for I1 & I2 are unknown gcd(120,180) = 60 ≠ 1, apply theorem 7 • 60I + 2I3 + 4I4 + 6I5 = [8, 8] => L=U=8 • U-L+1 = 1, all coeffs > 1, can’t apply thm 2 • apply theorem 4 30I + I3 + 2I4 + 3I5 = [4, 4] => L=U=4 • can apply theorem 2 for I3
Example for Algo – 2 (2) • a3+=1, a3-=0, [U,L] = [4, 4] theorem 2 new [U,L] = [4 - 1.5 - 0.1, 4 - 1.1 + 0.5] = [-1, 3] • 30I + 2I4 + 3I5 = [-1, 3] • again theorem 2 applicable for I4, 2 ≤ 3 - (-1) + 1 • 30I + 3I5 = [-1-2.5+0.1, 3-2.1+0.5] = [-11, 1] • Apply theorem 2 for I5 that gives, 30I = [-11-3.5+0.1, 1-3.1+0.5] = [-26, -2] • Now control comes out of the inner while loop • Interval GCD test applied, says no. • Algo returns no.
Discussion on the algorithm • Accurate when returns ‘yes’ or ‘no’ • Returns ‘maybe’ when the equation has a solution which satisfies limits • Not only on all variables that I-test could move to RHS • But also may be on the rest of the variables. • In case of ‘maybe’ (coefficients too big to apply Theorem 2 and none of the remaining limits are *) • then apply complete “step by step Banerjee test”. • [Lban, Uban] ∩ [L,U] = ø
Conclusion : Cost & Benefits • Banerjee bound computation component is same as the Banerjee test (or less if it finishes before all terms are moved to the RHS). • In worst case, I-test needs n GCD tests but practically it uses no more than 1 GCD test. • Extends the range of applicability of Banerjee test • Distinguishes “definite” yes from “tentative” Banerjee yes