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 Th54:
  [x,y] in inversions R implies
  ([z,x] in inversions R iff z in x & [z,y] 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
      [z,x] in inversions R; then
A3:   z in dom R & z in x & R/.z > R/.x by Th46; then
A4:   z in y by A1,ORDINAL1:10;
      Swap(R,x,y)/.y = R/.x & Swap(R,x,y)/.z = R/.z
      by A1,A3,Th32,Th34;
      hence z in x & [z,y] in inversions Swap(R,x,y) by A1,A2,A3,A4;
    end;
    assume
A5: z in x & [z,y] in inversions Swap(R,x,y); then
A6: z in dom R & z in y & Swap(R,x,y)/.z > Swap(R,x,y)/.y by A2,Th46; then
    z <> x & z <> y by A5; then
    Swap(R,x,y)/.y = R/.x & Swap(R,x,y)/.z = R/.z by A1,A6,Th32,Th34;
    hence [z,x] in inversions R by A1,A6,A5;
  end;
