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