reserve x,y,Y,Z for set,
  L for LATTICE,
  l for Element of L;

theorem Th9: ::3.4, p.69
  for L being complete LATTICE, X being Open upper Subset of L
holds for x being Element of L st x in (X`) ex m being Element of L st x <= m &
  m is_maximal_in (X`)
proof
  let L be complete LATTICE, X be Open upper Subset of L;
  let x be Element of L;
  set A = {C where C is Chain of L : C c= (X`) & x in C};
  reconsider x1 = {x} as Chain of L by ORDERS_2:8;
A1: for Z be set st Z <> {} & Z c= A & Z is c=-linear holds union Z in A
  proof
    let Z be set;
    assume that
A2: Z <> {} and
A3: Z c= A and
A4: Z is c=-linear;
    now
      let Y;
      assume Y in Z;
      then Y in A by A3;
      then ex C be Chain of L st Y = C & C c= (X`) & x in C;
      hence Y c= the carrier of L;
    end;
    then reconsider UZ = union Z as Subset of L by ZFMISC_1:76;
    the InternalRel of L is_strongly_connected_in UZ
    proof
      let a,b be object;
      assume that
A5:   a in UZ and
A6:   b in UZ;
      consider az be set such that
A7:   a in az and
A8:   az in Z by A5,TARSKI:def 4;
      consider bz be set such that
A9:   b in bz and
A10:  bz in Z by A6,TARSKI:def 4;
      az, bz are_c=-comparable by A4,A8,A10;
      then
A11:  az c= bz or bz c= az;
      bz in A by A3,A10;
      then
A12:  ex C be Chain of L st bz = C & C c= (X`) & x in C;
      az in A by A3,A8;
      then
A13:  ex C be Chain of L st az = C & C c= (X`) & x in C;
      reconsider bz as Chain of L by A12;
      reconsider az as Chain of L by A13;
      the InternalRel of L is_strongly_connected_in az & the InternalRel
      of L is_strongly_connected_in bz by ORDERS_2:def 7;
      hence thesis by A7,A9,A11;
    end;
    then reconsider UZ as Chain of L by ORDERS_2:def 7;
A14: now
      let Y;
      assume Y in Z;
      then Y in A by A3;
      then ex C be Chain of L st Y = C & C c= (X`) & x in C;
      hence Y c= (X`);
    end;
    set Y = the Element of Z;
    Y in Z by A2;
    then Y in A by A3;
    then ex C be Chain of L st Y = C & C c= (X`) & x in C;
    then
A15: x in UZ by A2,TARSKI:def 4;
    UZ c= (X`) by A14,ZFMISC_1:76;
    hence thesis by A15;
  end;
  assume x in (X`);
  then
A16: x1 c= (X`) by ZFMISC_1:31;
  x in x1 by ZFMISC_1:31;
  then x1 in A by A16;
  then consider Y1 be set such that
A17: Y1 in A and
A18: for Z st Z in A & Z <> Y1 holds not Y1 c= Z by A1,ORDERS_1:67;
  consider Y be Chain of L such that
A19: Y = Y1 and
A20: Y c= (X`) and
A21: x in Y by A17;
  set m = sup Y;
  m is_>=_than Y by YELLOW_0:32;
  then
A22: x <= m by A21;
A23: m is_>=_than Y by YELLOW_0:32;
A24: now
    given y being Element of L such that
A25: y in (X`) and
A26: y > m;
A27: not y in Y by A26,ORDERS_2:6,A23;
    set Y2 = Y \/ {y};
A28: m <= y by A26,ORDERS_2:def 6;
    the InternalRel of L is_strongly_connected_in Y2
    proof
      let a,b be object;
      assume
A29:  a in Y2 & b in Y2;
      per cases by A29,XBOOLE_0:def 3;
      suppose
A30:    a in Y & b in Y;
        the InternalRel of L is_strongly_connected_in Y by ORDERS_2:def 7;
        hence thesis by A30;
      end;
      suppose
A31:    a in Y & b in {y};
        then reconsider a1 = a as Element of L;
        reconsider b1 = b as Element of L by A31;
        b1 = y & a1 <= m by A23,A31,TARSKI:def 1;
        then a1 <= b1 by A28,ORDERS_2:3;
        hence thesis by ORDERS_2:def 5;
      end;
      suppose
A32:    a in {y} & b in Y;
        then reconsider a1 = b as Element of L;
        reconsider b1 = a as Element of L by A32;
        b1 = y & a1 <= m by A23,A32,TARSKI:def 1;
        then a1 <= b1 by A28,ORDERS_2:3;
        hence thesis by ORDERS_2:def 5;
      end;
      suppose
A33:    a in {y} & b in {y};
        then reconsider a1 = a as Element of L;
A34:    a1 <= a1;
        a = y & b = y by A33,TARSKI:def 1;
        hence thesis by A34,ORDERS_2:def 5;
      end;
    end;
    then reconsider Y2 as Chain of L by ORDERS_2:def 7;
    {y} c= (X`) by A25,ZFMISC_1:31;
    then
A35: Y2 c= (X`) by A20,XBOOLE_1:8;
    y in {y} by TARSKI:def 1;
    then
A36: y in Y2 by XBOOLE_0:def 3;
    x in Y2 by A21,XBOOLE_0:def 3;
    then Y2 in A by A35;
    hence contradiction by A18,A19,A27,A36,XBOOLE_1:7;
  end;
  now
    assume m in X;
    then consider y be Element of L such that
A37: y in X and
A38: y << m by Def1;
    consider d being Element of L such that
A39: d in Y and
A40: y <= d by A21,A38,WAYBEL_3:def 1;
    d in X by A37,A40,WAYBEL_0:def 20;
    hence contradiction by A20,A39,XBOOLE_0:def 5;
  end;
  then m in (X`) by XBOOLE_0:def 5;
  then m is_maximal_in (X`) by A24,WAYBEL_4:55;
  hence thesis by A22;
end;
