reserve a,x,y for object, A,B for set,
  l,m,n for Nat;
reserve X,Y for set, x for object,
  p,q for Function-yielding FinSequence,
  f,g,h for Function;
reserve m,n,k for Nat, R for Relation;
reserve i,j for Nat;
reserve F for Function,
  e,x,y,z for object;

theorem Th109:
  for X being set, p being Permutation of X, x, y being Element
  of X holds p+*(x, p.y)+*(y, p.x) is Permutation of X
proof
  let X be set, p be Permutation of X, x, y be Element of X;
  set p1 = p+*(x, p.y);
  set p2 = p1+*(y, p.x);
A1: dom p2 = dom p1 by Th29;
A2: dom p1 = dom p by Th29;
A3: X = {} implies X = {};
  then
A4: dom p = X by FUNCT_2:def 1;
  per cases;
  suppose
    X is empty;
    then p2 = {};
    hence thesis by A3;
  end;
  suppose
A5: X is non empty;
A6: rng p = X by FUNCT_2:def 3;
    then
A7: p.x in X by A4,A5,FUNCT_1:def 3;
    thus p+*(x, p.y)+*(y, p.x) is Permutation of X
    proof
      per cases;
      suppose
A8:     x = y;
        then p2 = p1 by Th34
          .= p by A8,Th34;
        hence thesis;
      end;
      suppose
A9:     x <> y;
        then
A10:    p2.x = p1.x by Th31
          .= p.y by A4,A5,Th30;
A11:    now
          let z be set such that
          z in X and
A12:      z <> x and
A13:      z <> y;
          thus p2.z = p1.z by A13,Th31
            .= p.z by A12,Th31;
        end;
A14:    p2.y = p.x by A2,A4,A5,Th30;
A15:    now
          let pz be object;
          hereby
            assume pz in rng p2;
            then consider z being object such that
A16:        z in dom p2 and
A17:        pz = p2.z by FUNCT_1:def 3;
A18:        p.z in X by A1,A2,A6,A16,FUNCT_1:def 3;
            per cases;
            suppose
              z = x;
              hence pz in X by A4,A5,A6,A10,A17,FUNCT_1:def 3;
            end;
            suppose
              z = y;
              hence pz in X by A2,A4,A7,A17,Th30;
            end;
            suppose
              z <> x & z <> y;
              hence pz in X by A1,A2,A11,A16,A17,A18;
            end;
          end;
          assume pz in X;
          then consider z being object such that
A19:      z in dom p and
A20:      pz = p.z by A6,FUNCT_1:def 3;
          per cases;
          suppose
            z = x;
            hence pz in rng p2 by A1,A2,A4,A14,A19,A20,FUNCT_1:def 3;
          end;
          suppose
            z = y;
            hence pz in rng p2 by A1,A2,A4,A10,A19,A20,FUNCT_1:def 3;
          end;
          suppose
            z <> x & z <> y;
            then p2.z = p.z by A11,A19;
            hence pz in rng p2 by A1,A2,A19,A20,FUNCT_1:def 3;
          end;
        end;
        then rng p2 = X by TARSKI:2;
        then reconsider p2 as Function of X, X by A1,A2,A4,A5,FUNCT_2:def 1
,RELSET_1:4;
        now
          let z1, z2 be object such that
A21:      z1 in X and
A22:      z2 in X and
A23:      p2.z1 = p2.z2 and
A24:      z1 <> z2;
          per cases;
          suppose
            z1 = x & z2 = y;
            hence contradiction by A5,A9,A10,A14,A23,FUNCT_2:19;
          end;
          suppose
            z1 = y & z2 = x;
            hence contradiction by A5,A9,A10,A14,A23,FUNCT_2:19;
          end;
          suppose
A25:        z1 = x & z2 <> y;
            then p2.z2 = p.z2 by A11,A22,A24;
            hence contradiction by A10,A22,A23,A25,FUNCT_2:19;
          end;
          suppose
A26:        z1 <> x & z2 = y;
            then p2.z1 = p.z1 by A11,A21,A24;
            hence contradiction by A14,A21,A23,A26,FUNCT_2:19;
          end;
          suppose
A27:        z1 = y & z2 <> x;
            then p2.z2 = p.z2 by A11,A22,A24;
            hence contradiction by A14,A22,A23,A27,FUNCT_2:19;
          end;
          suppose
A28:        z1 <> y & z2 = x;
            then p2.z1 = p.z1 by A11,A21,A24;
            hence contradiction by A10,A21,A23,A28,FUNCT_2:19;
          end;
          suppose
            z1 <> y & z2 <> x & z1 <> x & z2 <> y;
            then p2.z1 = p.z1 & p2.z2 = p.z2 by A11,A21,A22;
            hence contradiction by A21,A22,A23,A24,FUNCT_2:19;
          end;
        end;
        then
A29:    p2 is one-to-one by A5,FUNCT_2:19;
        rng p2 = X by A15,TARSKI:2;
        then p2 is onto by FUNCT_2:def 3;
        hence thesis by A29;
      end;
    end;
  end;
end;
