reserve A for RelStr;
reserve X for non empty set;
reserve PX,PY,PZ,Y,a,b,c,x,y for set;
reserve S1,S2 for Subset of Y;

theorem Th18:
  for h being non empty set st h c= X for Pmax being a_partition
of X st ( (ex hy be set st hy in Pmax & hy c= h) & for x st x in Pmax holds (x
c= h or h c= x or h misses x)) for Pb be set st (for x holds x in Pb iff (x in
Pmax & x misses h)) holds Pb \/ {h} is a_partition of X & Pmax is_finer_than (
  Pb \/ {h})& for Pmin being a_partition of X st Pmax is_finer_than Pmin for hw
  being set st hw in Pmin & h c= hw holds (Pb \/ {h}) is_finer_than Pmin
proof
  let h be non empty set such that
A1: h c= X;
A2: {h} c= bool X
  proof
    let s be object;
    assume s in {h};
    then s = h by TARSKI:def 1;
    hence thesis by A1;
  end;
A3: h in {h} by TARSKI:def 1;
  let Pmax be a_partition of X such that
A4: ex hy be set st hy in Pmax & hy c= h and
A5: for x st x in Pmax holds (x c= h or h c= x or h misses x);
A6: now
    let s be set such that
A7: s in Pmax and
A8: h c= s;
    consider hy be set such that
A9: hy in Pmax and
A10: hy c= h by A4;
    hy <> {} by A9,EQREL_1:def 4;
    then hy meets s by A8,A10,Lm5,XBOOLE_1:1;
    then s = hy by A7,A9,EQREL_1:def 4;
    hence h = s by A8,A10,XBOOLE_0:def 10;
  end;
  let Pb be set such that
A11: for x holds x in Pb iff x in Pmax & x misses h;
  set P = Pb \/ {h};
A12: Pb c= P by XBOOLE_1:7;
A13: Pb c= Pmax
  by A11;
A14: now
    let A be Subset of X such that
A15: A in P;
    now
      per cases by A15,XBOOLE_0:def 3;
      suppose
        A in Pb;
        then A in Pmax by A11;
        hence A <> {} by EQREL_1:def 4;
      end;
      suppose
        A in {h};
        hence A <> {} by TARSKI:def 1;
      end;
    end;
    hence A<>{};
    thus for B be Subset of X st B in P holds A = B or A misses B
    proof
      let B be Subset of X such that
A16:  B in P;
      per cases by A15,XBOOLE_0:def 3;
      suppose
A17:    A in Pb;
        per cases by A16,XBOOLE_0:def 3;
        suppose
          B in Pb;
          hence thesis by A13,A17,EQREL_1:def 4;
        end;
        suppose
          B in {h};
          then B = h by TARSKI:def 1;
          hence thesis by A11,A17;
        end;
      end;
      suppose
A18:    A in {h};
        per cases by A16,XBOOLE_0:def 3;
        suppose
A19:      B in Pb;
          A = h by A18,TARSKI:def 1;
          hence thesis by A11,A19;
        end;
        suppose
          B in {h};
          then B = h by TARSKI:def 1;
          hence thesis by A18,TARSKI:def 1;
        end;
      end;
    end;
  end;
A20: {h} c= P by XBOOLE_1:7;
A21: union Pmax = X by EQREL_1:def 4;
A22: X c= union P
  proof
    let s be object;
    assume s in X;
    then consider t be set such that
A23: s in t and
A24: t in Pmax by A21,TARSKI:def 4;
    per cases;
    suppose
      t in Pb;
      hence thesis by A12,A23,TARSKI:def 4;
    end;
    suppose
      not t in Pb;
      then
A25:  t meets h by A11,A24;
      per cases by A5,A24,A25;
      suppose
        h c= t;
        then t = h by A6,A24;
        hence thesis by A3,A20,A23,TARSKI:def 4;
      end;
      suppose
A26:    t c= h;
        h in {h} by TARSKI:def 1;
        hence thesis by A20,A23,A26,TARSKI:def 4;
      end;
    end;
  end;
  Pb c= bool X by A13,XBOOLE_1:1;
  then
A27: P c= bool X by A2,XBOOLE_1:8;
  union P c= X
  proof
    let s be object;
    assume s in union P;
    then ex t be set st s in t & t in P by TARSKI:def 4;
    hence thesis by A27;
  end;
  then union P = X by A22,XBOOLE_0:def 10;
  hence Pb \/ {h} is a_partition of X by A27,A14,EQREL_1:def 4;
  thus Pmax is_finer_than (Pb \/ {h})
  proof
    let x be set such that
A28: x in Pmax;
    per cases;
    suppose
      x c= h;
      hence thesis by A3,A20;
    end;
    suppose
A29:  not x c= h;
      per cases by A5,A28,A29;
      suppose
        h c= x;
        then h = x by A6,A28;
        hence thesis by A3,A20;
      end;
      suppose
        h misses x;
        then x in Pb by A11,A28;
        hence thesis by A12;
      end;
    end;
  end;
  let Pmin be a_partition of X such that
A30: Pmax is_finer_than Pmin;
  let hw be set such that
A31: hw in Pmin and
A32: h c= hw;
  let s be set such that
A33: s in P;
  per cases by A33,XBOOLE_0:def 3;
  suppose
    s in Pb;
    then s in Pmax by A11;
    hence thesis by A30;
  end;
  suppose
    s in {h};
    then s = h by TARSKI:def 1;
    hence thesis by A31,A32;
  end;
end;
