reserve
  a for natural Number,
  k,l,m,n,k1,b,c,i for Nat,
  x,y,z,y1,y2 for object,
  X,Y for set,
  f,g for Function;
reserve p,q,r,s,t for FinSequence;
reserve D for set;

theorem :: FINSET_1:def 1
  D is finite iff ex p st D = rng p
proof
  thus D is finite implies ex p st D = rng p
  proof
    given g being Function such that
A1: rng g = D and
A2: dom g in omega;
    reconsider n = dom g as Element of NAT by A2;
    defpred R[object,object] means P[$2,$1];
A3: for x being object st x in Seg n ex y being object st R[x,y]
    proof
      let x be object;
      assume
A4:   x in Seg n;
      then reconsider x as Element of NAT;
      x >= 1 by A4,Th1;
      then ex k be Nat st x = 1+k by NAT_1:10;
      hence thesis;
    end;
    consider f such that
A5: dom f = Seg n and
A6: for x being object st x in Seg n holds R[x,f.x] from CLASSES1:sch 1(A3);
A7: rng f = dom g
    proof
A8:   n = { k where k is Nat: k < n } by AXIOMS:4;
      thus rng f c= dom g
      proof
        let x be object;
        assume x in rng f;
        then consider y being object such that
A9:     y in dom f and
A10:    x = f.y by FUNCT_1:def 3;
        consider k such that
A11:    x = k and
A12:    y = k+1 by A5,A6,A9,A10;
        k + 1 <= n by A5,A9,A12,Th1;
        then k < n by NAT_1:13;
        hence thesis by A8,A11;
      end;
      let x be object;
      assume x in dom g;
      then consider k being Nat such that
A13:  x = k and
A14:  k < n by A8;
      1 <= k+1 & k+1 <= n by A14,NAT_1:11,13;
      then
A15:  k+1 in Seg n;
      then ex k1 st f.(k+1) = k1 & k+1 = k1+1 by A6;
      hence thesis by A5,A13,A15,FUNCT_1:def 3;
    end;
    then dom(g*f) = Seg n by A5,RELAT_1:27;
    then reconsider p = g*f as FinSequence by Def2;
    take p;
    thus thesis by A1,A7,RELAT_1:28;
  end;
  given p such that
A16: D = rng p;
  consider n such that
A17: dom p = Seg n by Def2;
A18: n = { k where k is Nat: k < n } by AXIOMS:4;
A19: for x being object st x in n ex y being object st P[x,y]
  proof
    let x be object;
    assume x in n;
    then ex k being Nat st x = k & k < n by A18;
    then reconsider k = x as Nat;
    take k+1;
    thus thesis;
  end;
  consider f such that
A20: dom f = n and
A21: for x being object st x in n holds P[x,f.x] from CLASSES1:sch 1(A19);
  take p*f;
A22: rng f = dom p
  proof
    thus rng f c= dom p
    proof
      let x be object;
      assume x in rng f;
      then consider y being object such that
A23:  y in dom f and
A24:  x = f.y by FUNCT_1:def 3;
      consider k such that
A25:  y = k and
A26:  x = k+1 by A20,A21,A23,A24;
      ex m being Nat st k = m & m < n by A18,A20,A23,A25;
      then 1 <= k+1 & k+1 <= n by NAT_1:11,13;
      hence thesis by A17,A26;
    end;
    let x be object;
    assume
A27: x in dom p;
    then reconsider x as Element of NAT;
    1 <= x by A17,A27,Th1;
    then consider m be Nat such that
A28: x = 1+m by NAT_1:10;
    x <= n by A17,A27,Th1;
    then m < n by A28,NAT_1:13;
    then
A29: m in n by A18;
    then ex k st m = k & f.m = k+1 by A21;
    hence thesis by A20,A28,A29,FUNCT_1:def 3;
  end;
  hence rng(p*f) = D by A16,RELAT_1:28;
  dom(p*f) = dom f by A22,RELAT_1:27;
  hence thesis by A20,ORDINAL1:def 12;
end;
