 reserve U for set,
         X, Y for Subset of U;
 reserve U for non empty set,
         A, B, C for non empty IntervalSet of U;

theorem Th38:
  for U being non empty set,
      A,B being non empty ordered Subset-Family of U holds
    DIFFERENCE (A,B) = {C where C is Subset of U :
      min A \ max B c= C & C c= max A \ min B}
  proof
    let U be non empty set;
    let A,B be non empty ordered Subset-Family of U;
    set A1 = min A, B1 = min B, A2 = max A, B2 = max B;
A1: DIFFERENCE (A,B) c= {C where C is Subset of U :
      min A \ max B c= C & C c= max A \ min B}
    proof
      let x be object;
      assume A2: x in DIFFERENCE (A,B); then
      consider Y,Z being set such that A3: Y in A & Z in B & x = Y \ Z
        by SETFAM_1:def 6;
      DIFFERENCE (A,B) is Subset-Family of U by Th37; then
      reconsider x as Subset of U by A2;
      A1 c= Y & Y c= A2 & B1 c= Z & Z c= B2 by A3,Th28; then
      A1 \ B2 c= x & x c= A2 \ B1 by A3,XBOOLE_1:35;
      hence thesis;
    end;
    {C where C is Subset of U : min A \ max B c= C & C c= max A \ min B}
      c= DIFFERENCE (A,B)
    proof
      let x be object;
      assume x in {C where C is Subset of U :
        min A \ max B c= C & C c= max A \ min B}; then
      consider x9 being Subset of U such that
A4:   x9 = x & min A \ max B c= x9 & x9 c= max A \ min B;
      set A1 = min A, A2 = max A, B1 = min B, B2 = max B;
      set z1 = (x9 \/ A1) /\ A2;
      set z2 = ((x9 \/ B2`) /\ B1`)`;
      B1 c= B2 by Lm2; then
A5:   B2` c= B1` by SUBSET_1:12;
      (x9 \/ B2`) /\ B1` = (x9 /\ B1`) \/ (B2` /\ B1`) by XBOOLE_1:23
        .= (x9 /\ B1`) \/ B2` by A5,XBOOLE_1:28; then
A6:   B2` c= (x9 \/ B2`) /\ B1` by XBOOLE_1:7;
      (x9 \/ B2`) /\ B1` c= B1` by XBOOLE_1:17; then
A7:   ((x9 \/ B2`) /\ B1`)` c= B2`` &
        B1`` c= ((x9 \/ B2`) /\ B1`)` by A6,SUBSET_1:12;
      z1 = (x9 /\ A2) \/ (A1 /\ A2) by XBOOLE_1:23
        .= (x9 /\ A2) \/ A1 by SETFAM_1:2,XBOOLE_1:28; then
      A1 c= z1 & z1 c= A2 by XBOOLE_1:7,17; then
A8:   z1 in A & z2 in B by Th28,A7;
A9:   (x9 \/ (A1 \ B2)) /\ (A2 \ B1) = x9 /\ (A2 \ B1) by A4,XBOOLE_1:12
        .= x9 by A4,XBOOLE_1:28;
      z1 \ z2 = z1 /\ z2` by SUBSET_1:13
          .= (x9 \/ A1) /\ (A2 /\ ((x9 \/ B2`) /\ B1`)) by XBOOLE_1:16
          .= (x9 \/ A1) /\ ((x9 \/ B2`) /\ (B1` /\ A2)) by XBOOLE_1:16
          .= (x9 \/ A1) /\ ((x9 \/ B2`) /\ (A2 \ B1)) by SUBSET_1:13
          .= ((x9 \/ A1) /\ (x9 \/ B2`)) /\ (A2 \ B1) by XBOOLE_1:16
          .= (x9 \/ (A1 /\ B2`)) /\ (A2 \ B1) by XBOOLE_1:24
          .= x9 by A9,SUBSET_1:13;
      hence thesis by A4,A8,SETFAM_1:def 6;
    end;
    hence thesis by A1;
  end;
