
theorem CBPOW1:
  for a,m,i be Nat, A be sequence of NAT st
  A.0 = a mod m & (for j be Nat holds A.(j+1) = (A.j)*(A.j) mod m)
  holds A.i = a to_power (2 to_power i) mod m
  proof
    let a,m,i be Nat, A be sequence of NAT;
    assume
    AS0: A.0 = a mod m & (for i be Nat holds A.(i+1) = (A.i)*(A.i) mod m );
    defpred P[Nat] means A.($1) = a to_power (2 to_power $1) mod m;
    a to_power (2 to_power 0) mod m = a to_power 1 mod m by POWER:24
    .= a mod m; then
    L1: P[0] by AS0;
    L2: for i be Nat st P[i] holds P[i+1]
    proof
      let i be Nat;
      assume P[i]; then
      (A.i)*(A.i) mod m = a|^((2 to_power 1)*(2 to_power i)) mod m by NAT_4:11
      .= a to_power (2 to_power (i+1)) mod m by POWER:27;
      hence thesis by AS0;
    end;
    for i be Nat holds P[i] from NAT_1:sch 2(L1,L2);
    hence thesis;
  end;
