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
  cell(l,r) in cells(1,G) iff
  ex i0 st (l.i0 < r.i0 or d = 1 & r.i0 < l.i0) & [l.i0,r.i0] is Gap of G.i0 &
  for i st i <> i0 holds l.i = r.i & l.i in G.i
proof
  hereby
    assume cell(l,r) in cells(1,G);
    then consider l9,r9,i0 such that
A1: cell(l,r) = cell(l9,r9) and
A2: l9.i0 < r9.i0 or d = 1 & r9.i0 < l9.i0 and
A3: [l9.i0,r9.i0] is Gap of G.i0 and
A4: for i st i <> i0 holds l9.i = r9.i & l9.i in G.i by Th40;
A5: (for i holds l9.i <= r9.i) or for i holds r9.i < l9.i
    proof
      per cases by A2;
      suppose
A6:     l9.i0 < r9.i0;
        now
          let i;
          i = i0 or i <> i0;
          hence l9.i <= r9.i by A4,A6;
        end;
        hence thesis;
      end;
      suppose
A7:     d = 1 & r9.i0 < l9.i0;
        now
          let i;
A8:       1 <= i by FINSEQ_1:1;
A9:       i <= d by FINSEQ_1:1;
A10:      1 <= i0 by FINSEQ_1:1;
A11:      i0 <= d by FINSEQ_1:1;
A12:      i = 1 by A7,A8,A9,XXREAL_0:1;
          i0 = 1 by A7,A10,A11,XXREAL_0:1;
          hence r9.i < l9.i by A7,A12;
        end;
        hence thesis;
      end;
    end;
    then
A13: l = l9 by A1,Th28;
    r = r9 by A1,A5,Th28;
    hence ex i0 st (l.i0 < r.i0 or d = 1 & r.i0 < l.i0) &
    [l.i0,r.i0] is Gap of G.i0 &
    for i st i <> i0 holds l.i = r.i & l.i in G.i by A2,A3,A4,A13;
  end;
  thus thesis by Th40;
end;
