reserve X for set;
reserve a,b,c,k,m,n for Nat;
reserve i for Integer;
reserve r for Real;
reserve p for Prime;

theorem Th22:
  for p being odd Prime st p|^(k+1) divides a|^(p|^k) + 1 holds
  p|^(k+2) divides a|^(p|^(k+1)) + 1
  proof
    let p be odd Prime such that
A1: p|^(k+1) divides a|^(p|^k) + 1;
    set b = a|^(p|^k);
    b,-1 are_congruent_mod p|^(k+1) by A1;
    then
A2: b,-1 are_congruent_mod p by Th6;
A3: for L being Nat holds b|^(2*L),1 are_congruent_mod p
    proof
      let L be Nat;
      b|^(2*L),(-1)|^(2*L) are_congruent_mod p by A2,GR_CY_3:34;
      hence b|^(2*L),1 are_congruent_mod p;
    end;
A4: for L being Nat holds b|^(2*L+1),-1 are_congruent_mod p
    proof
      let L be Nat;
      b|^(2*L+1),(-1)|^(2*L+1) are_congruent_mod p by A2,GR_CY_3:34;
      hence b|^(2*L+1),-1 are_congruent_mod p;
    end;
    p|^(k+1) = p*p|^k by NEWTON:6;
    then
A5: a|^(p|^(k+1)) = b|^p by NEWTON:9;
    reconsider F = OddEvenPowers(b,p) as INT-valued FinSequence;
    reconsider M = F mod p as INT-valued FinSequence;
A6: for x being Nat st 1 <= x <= len F holds M.x = 1
    proof
      let x be Nat such that
A7:   1 <= x <= len F;
      x in dom F by A7,FINSEQ_3:25;
      then
A8:   M.x = (F.x) mod p by EULER_2:def 1;
A9:  len F = p by Def3;
      then reconsider m = p-x as Element of NAT by A7,INT_1:5;
A10:  1 mod p = 1;
      per cases;
      suppose
A11:    x is odd;
        then
A12:    m is even;
        F.x = b|^m by A7,A9,A11,Def3;
        hence thesis by A3,A8,A10,A12,NAT_D:64;
      end;
      suppose
A13:    x is even;
        then ex L being Nat st m = 2*L+1 by ABIAN:9;
        then
A14:    (-1)*b|^m,(-1)*(-1) are_congruent_mod p by A4,INT_4:11;
        F.x = -b|^m by A7,A9,A13,Def3;
        hence thesis by A8,A10,A14,NAT_D:64;
      end;
    end;
    set P = p|->1;
A15: len F = p by Def3;
    dom M = dom F by EULER_2:def 1;
    then
A16: len M = len F by FINSEQ_3:29;
    then
A17: dom M = Seg p by A15,FINSEQ_1:def 3;
    for k st k in dom P holds M.k = P.k
    proof
      let k such that
A18:  k in dom P;
      1 <= k <= p by A15,A16,A17,A18,FINSEQ_3:25;
      hence M.k = 1 by A6,A15
      .= P.k by A18,FINSEQ_2:57;
    end;
    then M = P by A17,FINSEQ_1:13;
    then Sum M = p*1 by RVSUM_1:80;
    then
A19: Sum M,0 are_congruent_mod p;
A20: ex z being Nat st p = 2*z+1 by ABIAN:9;
    Sum F, Sum M are_congruent_mod p by Th10;
    then Sum F, 0 are_congruent_mod p by A19,INT_1:15;
    then
A21: p*p|^(k+1) divides (b+1)*Sum F by A1,NEWTON02:2;
    p|^(k+1+1) = p*p|^(k+1) by NEWTON:6;
    hence p|^(k+2) divides a|^(p|^(k+1)) + 1 by A5,A20,A21,Th21;
  end;
