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;
reserve O for connected non empty Poset;
reserve R,Q for array of O;
reserve T for non empty array of O;
reserve p,q,r,s for Element of dom T;

theorem Th78:
  for C being finite arr_computation of R
  holds last C is permutation of R &
  for a st a in dom C holds C.a is permutation of R
  proof
    let C be finite arr_computation of R;
    consider a,b such that
A1: dom C = a\b by Def1;
    consider n such that
A2: a = b+^n by A1,Th7;
    defpred P[Nat] means
    b+^$1 in dom C implies C.(b+^$1) is permutation of R;
A3: b+^(0 qua Ordinal) = b by ORDINAL2:27; then
    n <> 0 by A1,A2,XBOOLE_1:37; then
    consider m being Nat such that
A4: n = m+1 by NAT_1:6;
    n = Segm(m+1) by A4;
    then
A5: a = b+^succ Segm m by A2,NAT_1:38 .= succ(b+^m) by ORDINAL2:28; then
A6: b+^m = union a by ORDINAL2:2 .= union (a\b) by A1,Th6;
    C.(base-C) = R by Def14; then
    C.b = R by A1,Th23; then
A7: P[ 0] by A3,Th38;
A8: P[k] implies P[k+1]
    proof assume
A9:   P[k] & b+^(k+1) in dom C;
      Segm(k+1) = succ Segm k by NAT_1:38; then
A10:   b+^(k+1) = succ(b+^k) by ORDINAL2:28; then
      b+^k in b+^(k+1) & b+^(k+1) in a by A1,A9,ORDINAL1:6; then
A11:   b c= b+^k & b+^k in a by ORDINAL1:10,ORDINAL3:24; then
      b+^k in dom C by A1,ORDINAL6:5; then
      consider Q,x,y such that
A12:   [x,y] in inversions Q & C.(b+^k) = Q & C.(b+^(k+1)) = Swap(Q,x,y)
      by A9,A10,Def14;
      x in dom Q & y in dom Q by A12,Th46; then
      Swap(Q,x,y) is permutation of Q by Th43;
      hence thesis by A9,A1,A11,A12,Th40,ORDINAL6:5;
    end;
A13: P[k] from NAT_1:sch 2(A7,A8);
    b c= b+^m & b+^m in a by A5,ORDINAL1:6,ORDINAL3:24; then
    P[m] & b+^m in dom C by A1,A13,ORDINAL6:5;
    hence last C is permutation of R by A1,A6;
    let c; assume
A14: c in dom C; then
A15: b c= c & c in a by A1,ORDINAL6:5; then
    c = b+^(c-^b) by ORDINAL3:def 5; then
    c-^b in n by A2,A14,A1,ORDINAL3:22;
    then c-^b in Segm n;
    then reconsider k = c-^b as Nat;
    P[k] by A13;
    hence thesis by A14,A15,ORDINAL3:def 5;
  end;
