reserve x for set;
reserve i,j for Integer;
reserve n,n1,n2,n3 for Nat;
reserve K,K1,K2,K3 for Field;
reserve SK1,SK2 for Subfield of K;
reserve ek,ek1,ek2 for Element of K;
reserve p for Prime;
reserve a,b,c for Element of GF(p);
reserve F for FinSequence of GF(p);
reserve Px,Py,Pz for Element of GF(p);

theorem Th59:
  for p be Prime, a, b, d be Element of GF(p) st
  p > 3 & Disc(a,b,p) <> 0.GF(p) holds
  card ({Class(R_EllCur(a,b,p),[d,Y,1]) where Y is Element of GF(p)
  : [d,Y,1] in EC_SetProjCo(a,b,p) }) = 1 + Lege_p(d|^3 + a*d + b)
  proof
    let p be Prime, a,b,d be Element of GF(p);
    assume
    A1: p > 3 & Disc(a,b,p) <> 0.GF(p);
    set F = {Y where Y is Element of GF(p) : Y|^2= d|^3 + a*d + b};
    set G = {Class(R_EllCur(a,b,p),[d,Y,1])
    where Y is Element of GF(p) : [d,Y,1] in EC_SetProjCo(a,b,p) };
    per cases;
    suppose A2: F = {};
      A3: G ={}
      proof
        assume G <> {}; then
        consider z be object such that
    A4: z in G by XBOOLE_0:def 1;
        consider Y be Element of GF(p) such that
    A5: z= Class(R_EllCur(a,b,p),[d,Y,1])
        & [d,Y,1] in EC_SetProjCo(a,b,p) by A4;
        Y|^2= d|^3 + a*d + b by A5,Th43;
        then Y in F;
        hence contradiction by A2;
      end;
      2 < p by A1,XXREAL_0:2;
      hence thesis by A3,A2,Th39;
    end;
    suppose A6: F <> {};
      then consider z be object such that A7: z in F by XBOOLE_0:def 1;
      consider W be Element of GF(p)
      such that A8: z=W & W|^2= d|^3 + a*d + b by A7;
      [d,W,1] is Element of EC_SetProjCo(a,b,p) by A8,Th43; then
      A9: Class(R_EllCur(a,b,p),[d,W,1]) in G;
      consider I be Function of F,G such that
      A10: I is onto & I is one-to-one by A1,A6,Th58;
      A11: dom I = F by A9,FUNCT_2:def 1;
      A12: rng I = G by A10,FUNCT_2:def 3; then
      A13: card F c= card G by A10,A11,CARD_1:10;
      reconsider h=I" as Function of G,F by A10,A12,FUNCT_2:25;
      I"*I = id F & I*I" = id G by A10,A12,A9,FUNCT_2:29; then
      A14: h is onto & h is one-to-one by FUNCT_2:23; then
      A15:rng h = F by FUNCT_2:def 3;
      dom h = G by A6,FUNCT_2:def 1; then
      card G c= card F by A14,A15,CARD_1:10; then
      A16: card F = card G by A13,XBOOLE_0:def 10;
      2 < p by A1,XXREAL_0:2;
      hence thesis by A16,Th39;
    end;
  end;
