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

theorem Th17: ::3.9 (1-4), p.70
  for L be up-complete lower-bounded LATTICE, X be Subset of L
holds X is order-generating iff for l1,l2 be Element of L st not l2 <= l1 ex p
  be Element of L st p in X & l1 <= p & not l2 <= p
proof
  let L be up-complete lower-bounded LATTICE, X be Subset of L;
  thus X is order-generating implies for l1,l2 be Element of L st not l2 <= l1
  ex p be Element of L st p in X & l1 <= p & not l2 <= p
  proof
    assume
A1: X is order-generating;
    let l1,l2 be Element of L;
    consider P be Subset of X such that
A2: l1 = "/\" (P,L) by A1,Th15;
    assume
A3: not l2 <= l1;
    now
      assume for p be Element of L st p in P holds l2 <= p;
      then l2 is_<=_than P;
      hence contradiction by A3,A2,YELLOW_0:33;
    end;
    then consider p be Element of L such that
A4: p in P & not l2 <= p;
    take p;
    l1 is_<=_than P by A2,YELLOW_0:33;
    hence thesis by A4;
  end;
  thus (for l1,l2 be Element of L st not l2 <= l1 ex p be Element of L st p in
  X & l1 <= p & not l2 <= p) implies X is order-generating
  proof
    assume
A5: for l1,l2 be Element of L st not l2 <= l1 ex p be Element of L st
    p in X & l1 <= p & not l2 <= p;
    let l be Element of L;
    set y = inf ((uparrow l) /\ X);
    thus ex_inf_of (uparrow l) /\ X,L by YELLOW_0:17;
A6: y is_<=_than ((uparrow l) /\ X ) by YELLOW_0:33;
    now
      l is_<=_than ((uparrow l) /\ X )
      proof
        let b be Element of L;
        assume b in ((uparrow l) /\ X );
        then b in (uparrow l) by XBOOLE_0:def 4;
        hence thesis by WAYBEL_0:18;
      end;
      then l <= y by YELLOW_0:33;
      then
A7:   not y < l by ORDERS_2:6;
      assume
A8:   y <> l;
      now
        per cases by A7,ORDERS_2:def 6;
        suppose
          not y <= l;
          then consider p be Element of L such that
A9:       p in X and
A10:      l <= p and
A11:      not y <= p by A5;
          p in (uparrow l) by A10,WAYBEL_0:18;
          then p in (uparrow l) /\ X by A9,XBOOLE_0:def 4;
          hence contradiction by A6,A11;
        end;
        suppose
          y = l;
          hence contradiction by A8;
        end;
      end;
      hence contradiction;
    end;
    hence thesis;
  end;
end;
