reserve i for object, I for set,
  f for Function,
  x, x1, x2, y, A, B, X, Y, Z for ManySortedSet of I;

theorem     :: Tarski:4 a
  (for x holds x in X iff x = x1 or x = x2) implies X = { x1,x2 }
proof
  assume
A1: for x holds x in X iff x = x1 or x = x2;
  then
A2: x1 in X;
A3: x2 in X by A1;
  now
    let i be object such that
A4: i in I;
    now
      let a be object;
      thus a in X.i iff a = x1.i or a = x2.i
      proof
        thus a in X.i implies a = x1.i or a = x2.i
        proof
          assume that
A5:       a in X.i and
A6:       a <> x1.i;
A7:       dom (i .--> a) = {i};
          dom (x2 +* (i .--> a)) = I by A4,Th1;
          then reconsider k2 = x2 +* (i .--> a) as ManySortedSet of I
          by PARTFUN1:def 2,RELAT_1:def 18;
          i in {i} by TARSKI:def 1;
          then
A8:       k2.i = (i .--> a).i by A7,FUNCT_4:13
            .= a by FUNCOP_1:72;
          k2 in X
          proof
            let q be object such that
A9:         q in I;
            per cases;
            suppose i = q;
              hence thesis by A5,A8;
            end;
            suppose i <> q;
              then not q in dom (i .--> a) by TARSKI:def 1;
              then k2.q = x2.q by FUNCT_4:11;
              hence thesis by A3,A9;
            end;
          end;
          hence thesis by A1,A6,A8;
        end;
        assume
A10:    a = x1.i or a = x2.i;
        per cases by A10;
        suppose a = x1.i;
          hence thesis by A2,A4;
        end;
        suppose a = x2.i;
          hence thesis by A3,A4;
        end;
      end;
    end;
    then X.i = {x1.i,x2.i} by TARSKI:def 2;
    hence X.i = { x1,x2 }.i by A4,Def2;
  end;
  hence thesis;
end;
