reserve X,Y for set,
  x,x1,x2,y,y1,y2,z for set,
  f,g,h for Function;
reserve M for non empty set;
reserve D for non empty set;
reserve P for Relation;
reserve O for Order of X;
reserve R,P for Relation,
  X,X1,X2,Y,Z,x,y,z,u for set,
  g,h for Function,
  O for Order of X,
  D for non empty set,
  d,d1,d2 for Element of D,
  A1,A2,B for Ordinal,
  L,L1,L2 for Sequence;
reserve A,C for Ordinal;

theorem Th66:
  for X st X <> {} & for Z st Z c= X & Z is c=-linear ex Y st Y
in X & for X1 st X1 in Z holds Y c= X1 ex Y st Y in X & for Z st Z in X & Z <>
  Y holds not Z c= Y
proof
  let X;
  assume that
A1: X <> {} and
A2: for Z st Z c= X & Z is c=-linear ex Y st Y in X & for X1 st X1 in Z
  holds Y c= X1;
  reconsider D = X as non empty set by A1;
  set R = (RelIncl D)~;
A3: x in D implies [x,x] in R
  proof
    x in D implies [x,x] in RelIncl D by WELLORD2:def 1;
    hence thesis by RELAT_1:def 7;
  end;
A4: D has_upper_Zorn_property_wrt R
  proof
    let Z;
    assume that
A5: Z c= D and
A6: R|_2 Z is being_linear-order;
    set Q = R|_2 Z;
A7: Z c= field(R|_2 Z)
    proof
      let x be object;
      assume
A8:   x in Z;
      then
A9:   [x,x] in [:Z,Z:] by ZFMISC_1:87;
      [x,x] in R by A3,A5,A8;
      then [x,x] in R|_2 Z by A9,XBOOLE_0:def 4;
      hence thesis by RELAT_1:15;
    end;
    R|_2 Z is connected by A6;
    then
A10: R|_2 Z is_connected_in field(R|_2 Z);
    Z is c=-linear
    proof
      let X1,X2;
      assume that
A11:  X1 in Z and
A12:  X2 in Z;
      X1 <> X2 implies [X1,X2] in Q or [X2,X1] in Q by A10,A7,A11,A12;
      then X1 <> X2 implies [X1,X2] in R or [X2,X1] in R by XBOOLE_0:def 4;
      then X1 <> X2 implies [X1,X2] in RelIncl D or [X2,X1] in RelIncl D by
RELAT_1:def 7;
      hence X1 c= X2 or X2 c= X1 by A5,A11,A12,WELLORD2:def 1;
    end;
    then consider Y such that
A13: Y in X and
A14: for X1 st X1 in Z holds Y c= X1 by A2,A5;
    take x = Y;
    thus x in D by A13;
    let y;
    assume
A15: y in Z;
    then Y c= y by A14;
    then [Y,y] in RelIncl D by A5,A13,A15,WELLORD2:def 1;
    hence thesis by RELAT_1:def 7;
  end;
A16: field R = field RelIncl D by RELAT_1:21
    .= D by WELLORD2:def 1;
A17: field RelIncl D = D by WELLORD2:def 1;
  RelIncl D is_antisymmetric_in D by A17,RELAT_2:def 12;
  then
A18: R is_antisymmetric_in D by Lm14;
  RelIncl D is_transitive_in D by A17,RELAT_2:def 16;
  then
A19: R is_transitive_in D by Lm13;
  RelIncl D is_reflexive_in D by A17,RELAT_2:def 9;
  then R is_reflexive_in D by Lm12;
  then R partially_orders D by A19,A18;
  then consider x such that
A20: x is_maximal_in R by A16,A4,Th63;
  take Y = x;
A21: Y in field R by A20;
  thus Y in X by A16,A20;
  let Z;
  assume that
A22: Z in X and
A23: Z <> Y;
  not [Y,Z] in R by A16,A20,A22,A23;
  then not [Z,Y] in RelIncl D by RELAT_1:def 7;
  hence thesis by A16,A21,A22,WELLORD2:def 1;
end;
