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

theorem Th25: ::3.12 (1-2), p.70
  for l holds l is prime iff for x being set, f being Function of
  L,BoolePoset {x} st (for p be Element of L holds f.p = {} iff p <= l) holds f
  is meet-preserving join-preserving
proof
  let l;
  thus l is prime implies for x being set, f being Function of L,BoolePoset {x
  } st (for p be Element of L holds f.p = {} iff p <= l) holds f is
  meet-preserving join-preserving
  proof
    assume
A1: l is prime;
    let x be set, f be Function of L,BoolePoset {x};
    assume
A2: for p be Element of L holds f.p = {} iff p <= l;
A3: the carrier of BoolePoset {x} = the carrier of InclPoset bool {x} by
YELLOW_1:4
      .= bool {x} by YELLOW_1:1
      .= { {} , {x}} by ZFMISC_1:24;
A4: dom f = the carrier of L by FUNCT_2:def 1;
    for z,y being Element of L holds f preserves_inf_of {z,y}
    proof
      let z,y be Element of L;
A5:   f.:{z,y} = {f.z,f.y} by A4,FUNCT_1:60;
      then
A6:   ex_inf_of {z,y},L implies ex_inf_of f.:{z,y},BoolePoset {x} by
YELLOW_0:21;
A7:   now
        per cases by A3,TARSKI:def 2;
        suppose
A8:       f.z = {} & f.y = {};
          then z "/\" y <= z & z <= l by A2,YELLOW_0:23;
          then
A9:       z "/\" y <= l by ORDERS_2:3;
          thus f.z "/\" f.y = {} /\ {} by A8,YELLOW_1:17
            .= f.(z "/\" y) by A2,A9;
        end;
        suppose
A10:      f.z = {x} & f.y = {x};
          then ( not y <= l)& not z <= l by A2;
          then not z "/\" y <= l by A1;
          then
A11:      not f.(z "/\" y) = {} by A2;
          thus f.z "/\" f.y = {x} /\ {x} by A10,YELLOW_1:17
            .= f.(z "/\" y) by A3,A11,TARSKI:def 2;
        end;
        suppose
A12:      f.z = {} & f.y = {x};
          then z "/\" y <= z & z <= l by A2,YELLOW_0:23;
          then
A13:      z "/\" y <= l by ORDERS_2:3;
          thus f.z "/\" f.y = {} /\ {x} by A12,YELLOW_1:17
            .= f.(z "/\" y) by A2,A13;
        end;
        suppose
A14:      f.z = {x} & f.y = {};
          then z "/\" y <= y & y <= l by A2,YELLOW_0:23;
          then
A15:      z "/\" y <= l by ORDERS_2:3;
          thus f.z "/\" f.y = {x} /\ {} by A14,YELLOW_1:17
            .= f.(z "/\" y) by A2,A15;
        end;
      end;
      inf (f.:{z,y}) = f.z "/\" f.y by A5,YELLOW_0:40
        .= f.inf {z,y} by A7,YELLOW_0:40;
      hence thesis by A6;
    end;
    hence f is meet-preserving;
    for z,y being Element of L holds f preserves_sup_of {z,y}
    proof
      let z,y be Element of L;
A16:  f.:{z,y} = {f.z,f.y} by A4,FUNCT_1:60;
      then
A17:  ex_sup_of {z,y},L implies ex_sup_of f.:{z,y},BoolePoset {x} by
YELLOW_0:20;
A18:  now
        per cases by A3,TARSKI:def 2;
        suppose
A19:      f.z = {} & f.y = {};
          then z <= l & y <= l by A2;
          then
A20:      z "\/" y <= l by YELLOW_0:22;
          thus f.z "\/" f.y = {} \/ {} by A19,YELLOW_1:17
            .= f.(z "\/" y) by A2,A20;
        end;
        suppose
A21:      f.z = {x} & f.y = {x};
          then z "\/" y >= z & not z <= l by A2,YELLOW_0:22;
          then not z "\/" y <= l by ORDERS_2:3;
          then
A22:      not f.(z "\/" y) = {} by A2;
          thus f.z "\/" f.y = {x} \/ {x} by A21,YELLOW_1:17
            .= f.(z "\/" y) by A3,A22,TARSKI:def 2;
        end;
        suppose
A23:      f.z = {} & f.y = {x};
          then z "\/" y >= y & not y <= l by A2,YELLOW_0:22;
          then not z "\/" y <= l by ORDERS_2:3;
          then
A24:      not f.(z "\/" y) = {} by A2;
          thus f.z "\/" f.y = {} \/ {x} by A23,YELLOW_1:17
            .= f.(z "\/" y) by A3,A24,TARSKI:def 2;
        end;
        suppose
A25:      f.z = {x} & f.y = {};
          then z "\/" y >= z & not z <= l by A2,YELLOW_0:22;
          then not z "\/" y <= l by ORDERS_2:3;
          then
A26:      not f.(z "\/" y) = {} by A2;
          thus f.z "\/" f.y = {x} \/ {} by A25,YELLOW_1:17
            .= f.(z "\/" y) by A3,A26,TARSKI:def 2;
        end;
      end;
      sup (f.:{z,y}) = f.z "\/" f.y by A16,YELLOW_0:41
        .= f.sup {z,y} by A18,YELLOW_0:41;
      hence thesis by A17;
    end;
    hence thesis;
  end;
  thus (for x being set, f being Function of L,BoolePoset {x} st (for p be
  Element of L holds f.p = {} iff p <= l) holds f is meet-preserving
  join-preserving) implies l is prime
  proof
    defpred P[Element of L, set] means $1 <= l iff $2 = {};
    assume
A27: for x being set, f being Function of L,BoolePoset {x} st (for p
    be Element of L holds f.p = {} iff p <= l) holds f is meet-preserving
    join-preserving;
    let z,y be Element of L;
A28: the carrier of BoolePoset {{}} = the carrier of InclPoset bool {{}}
    by YELLOW_1:4
      .= bool {{}} by YELLOW_1:1
      .= { {} , {{}}} by ZFMISC_1:24;
A29: for a being Element of L ex b being Element of BoolePoset {{}} st P[a ,b]
    proof
      let a be Element of L;
      now
        per cases;
        suppose
A30:      a <= l;
          set b = {};
          reconsider b as Element of BoolePoset {{}} by A28,TARSKI:def 2;
          a <= l iff b = {} by A30;
          hence thesis;
        end;
        suppose
A31:      not a <= l;
          set b = {{}};
          reconsider b as Element of BoolePoset {{}} by A28,TARSKI:def 2;
          a <= l iff b = {} by A31;
          hence thesis;
        end;
      end;
      hence thesis;
    end;
    consider f being Function of L,BoolePoset {{}} such that
A32: for p be Element of L holds P[p, f.p] from FUNCT_2:sch 3(A29);
    f is meet-preserving by A27,A32;
    then
A33: ex_inf_of {z,y},L & f preserves_inf_of {z,y} by YELLOW_0:21;
    dom f = the carrier of L by FUNCT_2:def 1;
    then
A34: f.:{z,y} = {f.z,f.y} by FUNCT_1:60;
    assume z "/\" y <= l;
    then
A35: {} = f.(z "/\" y) by A32
      .= f.inf {z,y} by YELLOW_0:40
      .= inf({f.z,f.y}) by A34,A33
      .= f.z "/\" f.y by YELLOW_0:40
      .= f.z /\ f.y by YELLOW_1:17;
    now
      assume ( not f.z = {})& not f.y = {};
      then f.z = {{}} & f.y = {{}} by A28,TARSKI:def 2;
      hence contradiction by A35;
    end;
    hence z <= l or y <= l by A32;
  end;
end;
