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
  for f being Function, x, y being set st x in dom f & y in dom f ex p
  being Permutation of dom f st f+*(x, f.y)+*(y, f.x) = f*p
proof
  let f be Function, x, y be set such that
A1: x in dom f and
A2: y in dom f;
  set i = id dom f;
  i.x = x & i.y = y by A1,A2,FUNCT_1:18;
  then reconsider p = i+*(x,y)+*(y,x) as Permutation of dom f by A1,A2,Th109;
  set pk = i+*(x, y);
  set fr = f*p;
  set fk = f+*(x, f.y);
  take p;
  set fl = fk+*(y, f.x);
A3: dom i = dom f;
A4: dom fk = dom fl by Th29;
A5: dom p = dom pk by Th29;
A6: dom pk = dom i by Th29;
A7: dom f = dom fk by Th29;
  now
    thus dom f = dom fl by A4,Th29;
    rng p = dom f by FUNCT_2:def 3;
    hence dom f = dom fr by A5,A6,RELAT_1:27;
    let z be object such that
A8: z in dom f;
    per cases;
    suppose
A9:   x <> y;
      thus fl.z = fr.z
      proof
        per cases;
        suppose
A10:      z = x;
          hence fl.z = fk.z by A9,Th31
            .= f.y by A8,A10,Th30
            .= f.(pk.x) by A1,A3,Th30
            .= f.(p.x) by A9,Th31
            .= fr.z by A5,A6,A8,A10,FUNCT_1:13;
        end;
        suppose
A11:      z = y;
          hence fl.z = f.x by A7,A8,Th30
            .= f.(p.y) by A2,A6,Th30
            .= fr.z by A5,A6,A8,A11,FUNCT_1:13;
        end;
        suppose
A12:      z <> x & z <> y;
          then
A13:      p.z = pk.z by Th31
            .= i.z by A12,Th31
            .= z by A8,FUNCT_1:18;
          thus fl.z = fk.z by A12,Th31
            .= f.(p.z) by A12,A13,Th31
            .= fr.z by A5,A6,A8,FUNCT_1:13;
        end;
      end;
    end;
    suppose
A14:  x = y;
A15:  x = i.x by A1,FUNCT_1:17;
      fk = f & i = i+*(x, i.y) by A14,Th34;
      hence fl.z = fr.z by A14,A15,RELAT_1:52;
    end;
  end;
  hence thesis;
end;
