reserve x,y,z for set;
reserve f,f1,f2,f3 for FinSequence,
  p,p1,p2,p3 for set,
  i,k for Nat;
reserve D for non empty set,
  p,p1,p2,p3 for Element of D,
  f,f1,f2 for FinSequence of D;
reserve D for non empty set;
reserve p, q for FinSequence,
  X, Y, x, y for set,
  D for non empty set,
  i, j, k, l, m, n, r for Nat;

theorem Th19:
  p is TwoValued iff len p >1 & ex x,y being object st x<>y & rng p = {x, y}
proof
  hereby
    assume p is TwoValued;
    then card rng p = 2;
    then consider x,y being object such that
A1: x<>y and
A2: rng p={x,y} by CARD_2:60;
    thus len p >1
    proof
      set l=len p;
      assume
A3:   len p<=1;
      per cases by A3,NAT_1:25;
      suppose
        l=0;
        then p={};
        hence contradiction by A2;
      end;
      suppose
A4:     l=1;
        then 1 in dom p by FINSEQ_3:25;
        then consider z being object such that
A5:     [1,z] in p by XTUPLE_0:def 12;
        z=p.1 by A5,FUNCT_1:1;
        then p=<*z*> by A4,FINSEQ_1:40;
        then
A6:     rng p = {z} by FINSEQ_1:39;
        then z=x by A2,ZFMISC_1:4;
        hence contradiction by A1,A2,A6,ZFMISC_1:4;
      end;
    end;
    thus ex x,y being object st x<>y & rng p ={x, y} by A1,A2;
  end;
  assume len p >1;
  given x, y being object such that
A7: x<>y and
A8: rng p = {x, y};
  card rng p = 2 by A7,A8,CARD_2:57;
  hence thesis;
end;
