Xref: utzoo sci.math:15816 comp.theory:1658 sci.crypt:4333 Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!csn!ccncsu!ld231782@longs.LANCE.ColoState.EDU From: ld231782@longs.LANCE.ColoState.EDU (L. Detweiler) Newsgroups: sci.math,comp.theory,sci.crypt Subject: Lankinen's recursive factoring algorithm Message-ID: <13559@ccncsu.ColoState.EDU> Date: 17 Mar 91 07:02:06 GMT Sender: news@ccncsu.ColoState.EDU Reply-To: ld231782@longs.LANCE.ColoState.EDU Lines: 270 Let f(u,v,b,n) := | [otherwise] | f(u+b,v,2b,(n-v)/2) or f(u,v+b,2b,(n-u)/2) if n odd | f(u,v,2b,n/2) or f(u+b,v+b,2b,(n-u-v-b)/2) if n even Thm: f(1,1,2,(m-1)/2) = (p,q) iff pq=m for odd m. --- Pf: -- Let the term `call' refer to any (recursive) instance of the function (including the `base case' of the thm above). More formally, if in the definition above `or' is taken as set union, and undefined cases as the empty set, then the range of the function f (when called in the specified way) is a set of pairs, and a pair (p,q) is contained in this set iff pq=m (the domains of all parameters are integers). For purposes of explanation let the term `return' informally denote this membership. Main Thm: -------- Then the thm becomes f returns (p,q) iff pq=m for odd m when called in the above form. That is, f returns the set of all factors of m. The pf will be established inductively. Inductive Hypotheses: -------------------- (i) f is called for all uv=m (mod b) with (ii) u,v odd, b even, u=0. Inductive Thm: ------------- The inductive thm to be established here is: If b>m, then f returns (u,v), otherwise f is called for all u'v'=m (mod b') with u',v' odd, b' even, u'=0, but the function is undefined when n'<0). Hence, for the inductive hypotheses and thm, the variables can be taken for those in any (recursive) instance of the function, where the `prime' variables denote the new values of the recursive call. Main Thm by Hypotheses: ---------------------- Proceeding, note that for all recursive calls in f, n'b, so eventually b>m or n<0. The case where n<0 is irrelevant to the question of what f returns (since it is undefined, it `doesn't return anything'). Otherwise, b>m. Since, by hypothesis, uv = m (mod b) (u mod b)(v mod b) mod b = m mod b Also, since u=0, b>m iff n=0 iff uv=m. this establishes the exact correspondence of the inductive thm, instances of the function, and the main thm above. It remains to establish that the inductive conditions hold in the recursive function calls. Inductive Conditions: -------------------- (ii) ---- For a convenient abbreviation, herein let the variable `z' designate `both u and v' or `either u or v' as determined by context. That is, whatever holds for z holds for both u and v, or either u or v, as the case may be. By hypothesis, z is odd, and all recursive calls have either z'=z or z'=z+b where b is even. Hence z' is always odd. Also, in all cases b'=2b, so b' is even (in fact it must be a power of two from the base case). For the inequalities, if z'=z then z'=0. (iv) ---- As noted, since the function is undefined when n<0 the case is inconsequential (it is automatically satisfied). (i) --- First the justification of the `all' qualifier will be postponed, so that it remains to show that u'v'=m (mod b'). All cases are established with m=nb+uv by hypothesis. When u'=u+b and v'=v, u'v' = m (mod b') (u + b)(v) = (nb + uv) (mod 2b) uv + vb = nb + uv (mod 2b) vb = nb (mod 2b) v = n (mod 2) which follows because v is odd by hypothesis and n is odd in this case. (``The reversion to synthesis is easy.'' --Fermat) By symmetry u'v'=m (mod b') holds for the other case of odd n. When u'=u and v'=v, u'v'= m (mod b') uv = m (mod 2b) uv = nb + uv (mod 2b) 0 = nb (mod 2b) 0 = n (mod 2) which follows because n is even in this case. Finally, when u'=u+b,v'=v+b, u'v' = m (mod b') (u + b)(v + b) = nb + uv (mod 2b) uv + ub + vb + b^2 = nb + uv (mod 2b) ub + vb + b^2 = nb (mod 2b) (u + v)b + b^2 = nb (mod 2b) u + v = n (mod 2) which follows because u and v are odd by hypothesis and n is even in this case. Finally, the `all' qualifier must be justified to hold as an inductive condition. It asserts that every case that satisfies all conditions (i)-(iv) is encompassed by the multiple recursive calls (as well as the base case). For this some additional notation will be introduced. For any pq=m let p - p mod b q - q mod b x = -----------, y = ----------- b b for each instance of the function (in every recursive call). With u