reserve k, l, m, n, i, j for Nat,
  K, N for non empty Subset of NAT,
  Ke, Ne, Me for Subset of NAT,
  X,Y for set;
reserve f for Function of Segm n,Segm k;

theorem Th23:
  (n=0 iff k=0) & n>=k implies
  ex f be Function of Segm n,Segm k st f is onto "increasing
proof
  assume that
A1: n=0 iff k=0 and
A2: n>=k;
  now
    per cases;
    suppose
A3:   n=0;
      set f={};
A4:   dom f = n by A3;
      rng f= k by A1,A3;
      then reconsider f as Function of Segm n,Segm k by A4,FUNCT_2:1;
      f is onto "increasing by A1,Th15;
      hence thesis;
    end;
    suppose
A5:   n>0;
      then reconsider k1=k-1 as Element of NAT by A1,NAT_1:20;
      reconsider k,n as non zero Element of NAT by A1,A5,ORDINAL1:def 12;
      defpred F[Element of Segm n,Element of Segm k] means $2=min($1,k1);
A6:   for x be Element of Segm n ex y be Element of Segm k st F[x,y]
      proof
        let x be Element of Segm n;
A7:     k1<k1+1 by NAT_1:13;
        min(x,k1)<=k1 by XXREAL_0:17;
        then min(x,k1)<k by A7,XXREAL_0:2;
        then min(x,k1) in Segm k by NAT_1:44;
        hence thesis;
      end;
      consider f be Function of Segm n,Segm k such that
A8:   for m be Element of Segm n holds
        F[m,f.m qua Element of Segm k] from FUNCT_2:sch 3(A6);
      now
        let m9 be object such that
A9:     m9 in Segm k;
        reconsider m=m9 as Element of NAT by A9;
A10:    m<k1+1 by A9,NAT_1:44;
        then m <n by A2,XXREAL_0:2;
        then
A11:    m in Segm n by NAT_1:44;
        then
A12:    m in dom f by FUNCT_2:def 1;
        m<=k1 by A10,NAT_1:13;
        then min(m,k1)=m by XXREAL_0:def 9;
        then f.m=m by A8,A11;
        hence m9 in rng f by A12,FUNCT_1:def 3;
      end;
      then k c= rng f;
      then k=rng f;
      then
A13:  f is onto by FUNCT_2:def 3;
A14:  for m st m in rng f holds min* f"{m} =m
      proof
        let m;
        assume m in rng f;
        then
A15:    m<k1+1 by NAT_1:44;
        then
A16:    m<=k1 by NAT_1:13;
        m <n by A2,A15,XXREAL_0:2;
        then
A17:    m in Segm n by NAT_1:44;
        then
A18:    m in dom f by FUNCT_2:def 1;
        m<=k1 by A15,NAT_1:13;
        then min(m,k1)=m by XXREAL_0:def 9;
        then f.m=m by A8,A17;
        then
A19:    f.m in {m} by TARSKI:def 1;
        then
A20:    m in f"{m} by A18,FUNCT_1:def 7;
A21:    f"{m} is non empty by A19,A18,FUNCT_1:def 7;
        now
          per cases by A16,XXREAL_0:1;
          suppose
A22:        m<k1;
            now
A23:          n is Subset of NAT by Th8;
              let l9 be object such that
A24:          l9 in f"{m};
              l9 in dom f by A24,FUNCT_1:def 7;
              then l9 in n;
              then reconsider l=l9 as Element of NAT by A23;
              f.l in {m} by A24,FUNCT_1:def 7;
              then
A25:          f.l=m by TARSKI:def 1;
              l in dom f by A24,FUNCT_1:def 7;
              then min(l,k1)=m by A8,A25;
              then l=m by A22,XXREAL_0:15;
              hence l9 in {m} by TARSKI:def 1;
            end;
            then
A26:        f"{m} c= {m};
            min* f"{m} in f"{m} by A21,NAT_1:def 1;
            hence thesis by A26,TARSKI:def 1;
          end;
          suppose
A27:        m=k1;
            for l be Nat st l in f"{m} holds m <= l
            proof
              let l be Nat such that
A28:          l in f"{m};
              f.l in {m} by A28,FUNCT_1:def 7;
              then
A29:          f.l=m by TARSKI:def 1;
              l in dom f by A28,FUNCT_1:def 7;
              then f.l=min(l,m) by A8,A27;
              hence thesis by A29,XXREAL_0:def 9;
            end;
            hence thesis by A20,NAT_1:def 1;
          end;
        end;
        hence thesis;
      end;
      now
        let l,m such that
A30:    l in rng f and
A31:    m in rng f and
A32:    l < m;
        min* f"{l}=l by A14,A30;
        hence min* f"{l} < min* f"{m} by A14,A31,A32;
      end;
      then f is "increasing;
      hence thesis by A13;
    end;
  end;
  hence thesis;
end;
