reserve a,a1,a2,b,c,d for Ordinal,
  n,m,k for Nat,
  x,y,z,t,X,Y,Z for set;
reserve f,g for Function;
reserve A,B,C for array;

theorem Th27:
  for f being Sequence st f is descending & f.0 is finite
  holds f is finite
  proof let f be Sequence;
    assume
A1: f is descending;
    assume
A2: f.0 is finite;
    deffunc G(set) = card (f.$1);
    consider g being Sequence such that
A3: dom g = dom f & for a st a in dom f holds g.a = G(a)
    from ORDINAL2:sch 2;
    defpred P[set] means f.$1 is finite;
A4: P[0] by A2;
A5: P[a] implies P[succ a]
    proof
      per cases;
      suppose succ a nin dom f;
        hence thesis by FUNCT_1:def 2;
      end;
      suppose
A6:     succ a in dom f;
A7:     a in succ a by ORDINAL1:6; then
        a in dom f by A6,ORDINAL1:10; then
        f.succ a c< f.a by A1,A6,A7; then
        f.succ a c= f.a;
        hence thesis;
      end;
    end;
A8: for a st a <> 0 & a is limit_ordinal & for b st b in a holds P[b]
    holds P[a]
    proof let a;
      assume a <> 0; then
A9:   0 in a by ORDINAL3:8;
      per cases;
      suppose a in dom f; then
        0 in dom f & a in dom f by ORDINAL3:8; then
        f.a c< f.0 by A1,A9; then
        f.a c= f.0;
        hence thesis by A2;
      end;
      suppose a nin dom f;
        hence thesis by FUNCT_1:def 2;
      end;
    end;
A10: P[a] from ORDINAL2:sch 1(A4,A5,A8);
    g is decreasing
    proof
      let a,b; assume
A11:   a in b & b in dom g; then
      a in dom f by A3,ORDINAL1:10; then
A12:      g.a = G(a) & f.a is finite & f.b c< f.a & g.b = G(b) & f.b is finite
      by A1,A3,A11,A10;
       reconsider ga = g.a as Nat by A12;
       g.b in Segm ga by CARD_2:48,A12;
      hence g.b in g.a;
    end;
    hence f is finite by A3,FINSET_1:10;
  end;
