reserve i,j for Nat;
reserve x,y for set;
reserve A for non empty set;
reserve c for Element of StandardStackSystem A;
reserve m for stack of StandardStackSystem A;
reserve X for non empty non void StackSystem;
reserve s,s1,s2 for stack of X;
reserve e,e1,e2 for Element of X;
reserve X for StackAlgebra;
reserve s,s1,s2,s3 for stack of X;
reserve e,e1,e2,e3 for Element of X;
reserve X1,X2,X3 for StackAlgebra;
reserve F,F1,F2,G,G1,G2 for Function;

theorem Th48:
  for X being proper-for-identity StackAlgebra holds
  ex G st (for s being stack of X holds G.s = |.s.|) &
  id the carrier of X, G form_isomorphism_between
  X, StandardStackSystem the carrier of X
  proof
    let X be proper-for-identity StackAlgebra;
    deffunc F(stack of X) = |.$1.|;
    consider G being Function of the carrier' of X, (the carrier of X)* such
    that
A1: for s being stack of X holds G.s = F(s) from FUNCT_2:sch 4;
    take G;
    thus for s being stack of X holds G.s = |.s.| by A1;
    set F = id the carrier of X;
    set X2 = StandardStackSystem the carrier of X;
    set A = the carrier of X;
A2: the carrier of X2 = A &
    the carrier' of X2 = A* &
    for s being stack of X2 holds
    (emp s iff s is empty) &
    for g being FinSequence st g = s holds
    (not emp s implies top s = g.1 & pop s = Del(g,1)) &
    (emp s implies top s = the Element of X2 & pop s = {}) &
    for e being Element of X2 holds push(e,s) = <*e*>^g by Def7;
    thus dom F = the carrier of X & rng F = the carrier of X2 & F is one-to-one
    by A2;
    thus
A3: dom G = the carrier' of X by FUNCT_2:def 1;
    thus rng G = the carrier' of X2
    proof
      thus rng G c= the carrier' of X2 by A2;
      let x be object; assume x in the carrier' of X2; then
      reconsider x as Element of A* by Def7;
      consider s being stack of X such that
A4:   |.s.| = x by Th12;
      x = G.s by A1,A4;
      hence thesis by A3,FUNCT_1:def 3;
    end;
    thus G is one-to-one
    proof
      let x,y be object; assume x in dom G & y in dom G; then
      reconsider s1 = x, s2 = y as stack of X;
      assume G.x = G.y; then
      |.s1.| = G.y by A1 .= |.s2.| by A1; then
      s1 == s2;
      hence x = y by Def15;
    end;
    let s1 be stack of X, s2 be stack of X2; assume
    s2 = G.s1; then
A5: s2 = |.s1.| by A1;
    hereby assume emp s1; then
      |.s1.| = {} by Th5;
      hence emp s2 by A5,Def7;
    end;
    thus
A6: now assume emp s2; then
      s2 = {} by Def7;
      hence emp s1 by A5,Th10;
    end;
    hereby assume
A7:   not emp s1;
      hence pop s2 = Del(s2,1) by A6,Def7
      .= |.pop s1.| by A5,A7,Th7 .= G.pop s1 by A1;
      thus top s2 = s2.1 by A7,A6,Def7
      .= top s1 by A5,A7,Th9 .= F.top s1;
    end;
    let e1 be Element of X, e2 be Element of X2; assume e2 = F.e1;
    hence push(e2,s2) = <*F.e1*>^s2 by Def7 .= <*e1*>^s2
    .= |.push(e1,s1).| by A5,Th8 .= G.push(e1,s1) by A1;
  end;
