reserve X,x,y,z for set;
reserve n,m,k,k9,d9 for Nat;
reserve d for non zero Nat;
reserve i,i0,i1 for Element of Seg d;
reserve l,r,l9,r9,l99,r99,x,x9,l1,r1,l2,r2 for Element of REAL d;
reserve Gi for non trivial finite Subset of REAL;
reserve li,ri,li9,ri9,xi,xi9 for Real;
reserve G for Grating of d;

theorem Th52:
  for G being Grating of d, B being Cell of (0 + 1),G holds card(del {B}) = 2
proof
A1: 0 + 1 <= d by Def2;
  let G be Grating of d, B be Cell of (0 + 1),G;
  consider l,r,i0 such that
A2: B = cell(l,r) and
A3: l.i0 < r.i0 or d = 1 & r.i0 < l.i0 and
A4: [l.i0,r.i0] is Gap of G.i0 and
A5: for i st i <> i0 holds l.i = r.i & l.i in G.i by Th40;
  ex A1,A2 being set st A1 in del {B} & A2 in del {B} & A1 <> A2 &
  for A being set st A in del {B} holds A = A1 or A = A2
  proof
    for i holds l.i in G.i & r.i in G.i by A1,A2,Th32;
    then reconsider A1 = cell(l,l), A2 = cell(r,r) as Cell of 0,G by Th35;
    take A1,A2;
A6: A1 = {l} by Th24;
A7: A2 = {r} by Th24;
A8: l in B by A2,Th23;
A9: r in B by A2,Th23;
A10: {l} c= B by A8,ZFMISC_1:31;
    {r} c= B by A9,ZFMISC_1:31;
    hence A1 in del {B} & A2 in del {B} by A1,A6,A7,A10,Th50;
    thus A1 <> A2 by A3,A6,A7,ZFMISC_1:3;
    let A be set;
    assume
A11: A in del {B};
    then reconsider A as Cell of 0,G;
A12: A c= B by A1,A11,Th50;
    consider x such that
A13: A = cell(x,x) and
A14: for i holds x.i in G.i by Th34;
A15: x in A by A13,Th23;
    per cases by A3;
    suppose
A16:  l.i0 < r.i0;
A17:  now
        let i;
        i = i0 or i <> i0;
        hence l.i <= r.i by A5,A16;
      end;
A18:  x.i0 in G.i0 by A14;
A19:  l.i0 <= x.i0 by A2,A12,A15,A17,Th21;
A20:  x.i0 <= r.i0 by A2,A12,A15,A17,Th21;
A21:  not (l.i0 < x.i0 & x.i0 < r.i0) by A4,A18,Th13;
A22:  now
        let i;
        assume i <> i0;
        then
A23:    l.i = r.i by A5;
A24:    l.i <= x.i by A2,A12,A15,A17,Th21;
        x.i <= r.i by A2,A12,A15,A17,Th21;
        hence x.i = l.i & x.i = r.i by A23,A24,XXREAL_0:1;
      end;
      thus thesis
      proof
        per cases by A19,A20,A21,XXREAL_0:1;
        suppose
A25:      x.i0 = l.i0;
          reconsider x,l as Function of Seg d,REAL by Def3;
          now
            let i;
            i = i0 or i <> i0;
            hence x.i = l.i by A22,A25;
          end;
          then x = l by FUNCT_2:63;
          hence thesis by A13;
        end;
        suppose
A26:      x.i0 = r.i0;
          reconsider x,r as Function of Seg d,REAL by Def3;
          now
            let i;
            i = i0 or i <> i0;
            hence x.i = r.i by A22,A26;
          end;
          then x = r by FUNCT_2:63;
          hence thesis by A13;
        end;
      end;
    end;
    suppose
A27:  d = 1 & r.i0 < l.i0;
A28:  for i holds i = i0
      proof
        let i;
A29:    1 <= i by FINSEQ_1:1;
A30:    i <= d by FINSEQ_1:1;
A31:    1 <= i0 by FINSEQ_1:1;
A32:    i0 <= d by FINSEQ_1:1;
        i = 1 by A27,A29,A30,XXREAL_0:1;
        hence thesis by A27,A31,A32,XXREAL_0:1;
      end;
      consider i1 such that
      r.i1 < l.i1 and
A33:  x.i1 <= r.i1 or l.i1 <= x.i1 by A2,A12,A15,A27,Th22;
A34:  i1 = i0 by A28;
A35:  x.i0 in G.i0 by A14;
      then
A36:  not x.i0 < r.i0 by A4,A27,Th13;
A37:  not l.i0 < x.i0 by A4,A27,A35,Th13;
      thus thesis
      proof
        per cases by A33,A34,A36,A37,XXREAL_0:1;
        suppose
A38:      x.i0 = r.i0;
          reconsider x,r as Function of Seg d,REAL by Def3;
          now
            let i;
            i = i0 by A28;
            hence x.i = r.i by A38;
          end;
          then x = r by FUNCT_2:63;
          hence thesis by A13;
        end;
        suppose
A39:      x.i0 = l.i0;
          reconsider x,l as Function of Seg d,REAL by Def3;
          now
            let i;
            i = i0 by A28;
            hence x.i = l.i by A39;
          end;
          then x = l by FUNCT_2:63;
          hence thesis by A13;
        end;
      end;
    end;
  end;
  hence thesis by Th5;
end;
