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;

theorem Th58:
  [x,y] in inversions R implies
  (y in z & [x,z] in inversions R iff [y,z] in inversions Swap(R,x,y))
  proof assume
    [x,y] in inversions R; then
A1: x in dom R & y in dom R & x in y & R/.x > R/.y by Th46;
A2: dom Swap(R,x,y) = dom R by FUNCT_7:99;
    hereby assume
A3:   y in z & [x,z] in inversions R; then
A4:   z in dom R & x in z & R/.z < R/.x by Th46; then
      z <> x & z <> y by A3; then
      Swap(R,x,y)/.y = R/.x & Swap(R,x,y)/.z = R/.z by A1,A4,Th32,Th34;
      hence [y,z] in inversions Swap(R,x,y) by A1,A2,A4,A3;
    end;
    assume
    [y,z] in inversions Swap(R,x,y); then
A5: z in dom R & y in z & Swap(R,x,y)/.y > Swap(R,x,y)/.z by A2,Th46; then
A6: x in z by A1,ORDINAL1:10;
    Swap(R,x,y)/.y = R/.x & Swap(R,x,y)/.z = R/.z by A1,Th32,Th34,A5;
    hence thesis by A1,A5,A6;
  end;
