theorem Th40:
  for S being stack of X/== st S = Class(==_X, s) & not emp s holds
  top S = top s
  proof set t = the s_top of X;
    set A = the s_empty of X;
    set e = the Element of the carrier of X;
    let S be stack of X/==;
    assume
A1: S = Class(==_X, s);
    assume
A2: not emp s; then
    not emp S by A1,Th36; then
A3: S <> A by Th37;
    set f = the Choice_Function of Class(==_X);
A4: S in Class(==_X) & {} nin Class(==_X)
    by A1,EQREL_1:def 3; then
A5: f.S in S by ORDERS_1:89; then
    reconsider x = f.S as stack of X by A1;
    [s,x] in ==_X by A1,A5,EQREL_1:18; then
A6: s == x by Def16;
A7: dom f = Class(==_X) by A4,RLVECT_3:28;
    the s_top of X/== = (t*f)+*(A,e) by Def20;
    hence top S = (t*f).S by A3,FUNCT_7:32
    .= top x by A4,A7,FUNCT_1:13
    .= top s by A6,A2,Th18;
  end;
