 reserve x,y,z for object, X for set,
         i,k,n,m for Nat,
         R for Relation,
         P for finite Relation,
         p,q for FinSequence;
reserve FSG for Friendship_Graph;

theorem Th12:
  FSG is without_universal_friend & x in field FSG
    implies card field FSG = 1 + card Im(FSG,x) * (card Im(FSG,x)-1)
proof
  defpred FSGR[object,object] means for x,y st $1=[x,y] holds $2=y;
  assume that
     A1: FSG is without_universal_friend and
     A2: x in field FSG;
  set I=Im(FSG,x),F=field FSG, FI=F\({x}\/I);
  defpred R[object,object] means
     $1 in I & [$1,$2] in FSG & not [x,$2] in FSG;
  consider RR be Relation such that
    A3:for y,z being object holds [y,z] in RR iff y in I & z in FI & R[y,z]
    from RELAT_1:sch 1;
  card I > 2 by Th10,A1,A2;
  then reconsider cI=card I-2 as Element of NAT by NAT_1:21;
  for y st y in I holds card Im(RR,y)=cI
  proof
    let y be object;
    x in {x} by TARSKI:def 1;
    then x in {x}\/I by XBOOLE_0:def 3;
    then not x in FI by XBOOLE_0:def 5;
    then A4: not [y,x] in RR by A3;
    assume A5:y in I;
    then A6:[x,y] in FSG by RELAT_1:169;
    then A7: x<>y by Lm2;
    y in F by A6,RELAT_1:15;
    then consider z being object such that
      A8:I/\Coim(FSG,y) = {z} by A7,Def3,A2;
    A9: z in {z} by TARSKI:def 1;
    then A10: z in I by XBOOLE_0:def 4, A8;
    then A11: [x,z] in FSG by RELAT_1:169;
    Coim(FSG,y) = Im(FSG,y) by Th2;
    then A12: z in Im(FSG,y) by A9,XBOOLE_0:def 4, A8;
    then A13: [y,z] in FSG by RELAT_1:169;
    A14: Im(FSG,y)\{z,x} c= Im(RR,y)
    proof
      let d be object;
      assume A15: d in Im(FSG,y)\{z,x};
      then A16: not d in {z,x} by XBOOLE_0:def 5;
      A17: [y,d] in FSG by A15,RELAT_1:169;
      then A18: d in F by RELAT_1:15;
      A19: not d in I
      proof
        A20: [d,y] in FSG & [z,y] in FSG by A17,Lm3, A13;
        assume d in I;
        then [x,d] in FSG by RELAT_1:169;
        then d = z by A20, A11,Lm5,A7;
        hence thesis by A16,TARSKI:def 2;
      end;
      A21: not [x,d] in FSG
      proof
        assume A22: [x,d] in FSG;
        A23: [d,y] in FSG & [x,z] in FSG by A17,Lm3, A10,RELAT_1:169;
        [z,y] in FSG by A13,Lm3;
        then d=z by A22,A23,Lm5,A7;
        hence thesis by A16,TARSKI:def 2;
      end;
      d<>x by A16,TARSKI:def 2;
      then not d in {x} by TARSKI:def 1;
      then not d in I\/{x} by A19,XBOOLE_0:def 3;
      then d in FI by A18,XBOOLE_0:def 5;
      then [y,d] in RR by A3, A21,A5, A15,RELAT_1:169;
      hence thesis by RELAT_1:169;
    end;
     A24: not [y,z] in RR by A11,A3;
     Im(RR,y) c= Im(FSG,y)\{x,z}
     proof
       let d be object;
       assume
           A25:d in Im(RR,y);
       then [y,d] in RR by RELAT_1:169;
       then [y,d] in FSG by A3;
       then A26: d in Im(FSG,y) by RELAT_1:169;
        d<>x & d<>z by A25, A4,RELAT_1:169, A24;
       then not d in {x,z} by TARSKI:def 2;
       hence thesis by A26,XBOOLE_0:def 5;
      end;
    then A27:Im(RR,y) = Im(FSG,y)\{x,z} by A14;
    y in F by A6,RELAT_1:15;
    then A28: card Im(FSG,x) = card Im(FSG,y) by A1,A2,Th11;
    [y,x] in FSG by A6,Lm3;
    then x in Im(FSG,y) by RELAT_1:169;
    then A29: card (Im(FSG,y)\{x,z}) = card Im(FSG,y) - card {x,z}
      by ZFMISC_1:32,A12,CARD_2:44;
    x<>z by A11,Lm2;
    hence thesis by A28,A27,A29,CARD_2:57;
  end;
  then A30:card RR = card(RR| (dom RR\I)) +` cI*`card I by SIMPLEX1:1;
  dom RR c= I
  proof
    let y be object;
    assume y in dom RR;
    then ex z being object st [y,z] in RR by XTUPLE_0:def 12;
    hence thesis by A3;
  end;
  then (dom RR)\I={} by XBOOLE_1:37;
  then card(RR| (dom RR\I))=0;
  then A31:card RR = cI*`card I by A30,CARD_2:18
       .= cI*card I by Lm1;
  A32:for y being object st y in RR ex z being object st FSGR[y,z]
  proof
    let y being object such that A33:y in RR;
    consider z,t be object such that
      A34:[z,t] =y by A33,RELAT_1:def 1;
    take t;
    thus thesis by XTUPLE_0:1,A34;
  end;
  consider pr be Function such that
A35: dom pr = RR & for x being object st x in RR holds FSGR[x,pr.x]
     from CLASSES1:sch 1 (A32);
   A36: pr is one-to-one
   proof
     let x1,x2 be object;
     assume that
           A37: x1 in dom pr
       and A38: x2 in dom pr
       and A39: pr.x1=pr.x2;
     consider y1,t1 be object such that
       A40: x1=[y1,t1] by A37,A35,RELAT_1:def 1;
     t1 in FI by A40,A35,A37,A3;
     then not t1 in {x}\/I by XBOOLE_0:def 5;
     then not t1 in {x} by XBOOLE_0:def 3;
     then A41: t1<>x by TARSKI:def 1;
     consider y2,t2 be object such that
       A42: x2=[y2,t2] by A35,RELAT_1:def 1,A38;
     A43: t1=pr.x1 & [y1,t1] in FSG by A37,A40,A35,A3;
     A44: t2 = pr.x2 & [y2,t2] in FSG by A38,A42,A35,A3;
     y2 in I by A42,A35,A38,A3;
     then A45: [x,y2] in FSG by RELAT_1:169;
     y1 in I by A40,A35,A37,A3;
     then [x,y1] in FSG by RELAT_1:169;
     hence thesis by A41,A39,A43,A44,A45,Lm5,A40,A42;
   end;
   A46: FI c= rng pr
   proof
     let z be object;
     assume A47:z in FI;
     then A48: not z in {x}\/I by XBOOLE_0:def 5;
     then A49: not z in I by XBOOLE_0:def 3;
     not z in {x} by A48,XBOOLE_0:def 3;
     then z<>x by TARSKI:def 1;
     then consider t be object such that
       A50:I/\Coim(FSG,z) = {t} by A2, A47,Def3;
     A51: t in {t} by TARSKI:def 1;
     Coim(FSG,z)=Im(FSG,z) by Th2;
     then t in Im(FSG,z) by A51,A50,XBOOLE_0:def 4;
     then [z,t] in FSG by RELAT_1:169;
     then R[t,z] by A49,RELAT_1:169,Lm3, A51,A50,XBOOLE_0:def 4;
     then [t,z] in RR & pr.[t,z] = z by A3,A47,A35;
     hence thesis by A35,FUNCT_1:def 3;
   end;
   rng pr c= FI
   proof
     let z be object;
     assume z in rng pr;
     then consider t be object such that
           A52: t in dom pr
       and A53: pr.t=z by FUNCT_1:def 3;
     consider t1,t2 be object such that
       A54:t=[t1,t2] by A52,A35,RELAT_1:def 1;
     pr.t = t2 by A52,A54,A35;
     hence thesis by A52,A54,A35,A3,A53;
   end;
   then rng pr = FI by A46;
   then A55:cI*card I = card FI by WELLORD2:def 4,A36,A35,CARD_1:5, A31;
   A56: I c= F
   proof
     let z be object;
     assume z in I;
     then [x,z] in FSG by RELAT_1:169;
     hence thesis by RELAT_1:15;
   end;
   not [x,x] in FSG by Lm2;
   then A57: card ({x}\/I) = card I+1 by RELAT_1:169,CARD_2:41;
   {x} c= F by A2,ZFMISC_1:31;
   then cI*card I=card F -card ({x}\/I) by A56,XBOOLE_1:8,CARD_2:44,A55;
   then card F = cI*card I + (card I+1) by A57;
   hence thesis;
end;
