reserve D for non empty set,
  f for FinSequence of D,
  p, p1, p2, p3, q for Element of D,
  i, j, k, l, n for Nat;

theorem
  Swap(Swap(f,i,j),j,i) = f
proof
  per cases;
  suppose
A1: 1 <= i & i <= len f & 1 <= j & j <= len f;
A2: for k be Nat st 1 <= k & k <= len f holds f.k = Swap(Swap(f,i,j),j,i). k
    proof
A3:   i <= len Swap(f,i,j) by A1,Th18;
A4:   j <= len Swap(f,i,j) by A1,Th18;
      let k be Nat;
      assume that
A5:   1 <= k and
A6:   k <= len f;
A7:   k <= len Swap(f,i,j) by A6,Th18;
      now
        per cases;
        suppose
          i = k;
          then Swap(Swap(f,i,j),j,i).k = Swap(f,k,j).j by A1,A7,A4,Lm3;
          hence thesis by A1,A5,A6,Lm3;
        end;
        suppose
A8:       i <> k;
          now
            per cases;
            suppose
              j = k;
              then Swap(Swap(f,i,j),j,i).k = Swap(f,i,k).i by A1,A7,A3,Lm3;
              hence thesis by A1,A5,A6,Lm3;
            end;
            suppose
A9:           j <> k;
              set S = Swap(f,i,j);
              Swap(S,j,i).k = Replace(Replace(S,j,S/.i),i,S/.j).k by A1,A4,A3
,Def2
                .= Replace(S,j,S/.i).k by A8,FUNCT_7:32
                .= S.k by A9,FUNCT_7:32
                .= Replace(Replace(f,i,f/.j),j,f/.i).k by A1,Def2
                .= Replace(f,i,f/.j).k by A9,FUNCT_7:32;
              hence thesis by A8,FUNCT_7:32;
            end;
          end;
          hence thesis;
        end;
      end;
      hence thesis;
    end;
    len Swap(Swap(f,i,j),j,i) = len Swap(f,i,j) by Th18
      .= len f by Th18;
    hence thesis by A2;
  end;
  suppose
A10: not (1 <= i & i <= len f & 1 <= j & j <= len f);
    then Swap(Swap(f,i,j),j,i) = Swap(f,j,i) by Def2;
    hence thesis by A10,Def2;
  end;
end;
