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 Th13:
  [li,ri] is Gap of Gi iff li in Gi & ri in Gi &
  ((li < ri & for xi st xi in Gi holds not (li < xi & xi < ri)) or
  (ri < li & for xi st xi in Gi holds not (li < xi or xi < ri)))
proof
  thus [li,ri] is Gap of Gi implies li in Gi & ri in Gi &
  ((li < ri & for xi st xi in Gi holds not (li < xi & xi < ri)) or
  (ri < li & for xi st xi in Gi holds not (li < xi or xi < ri)))
  proof
    assume [li,ri] is Gap of Gi;
    then consider li9,ri9 such that
A1: [li,ri] = [li9,ri9] and
A2: li9 in Gi and
A3: ri9 in Gi and
A4: (li9 < ri9 & for xi st xi in Gi holds not (li9 < xi & xi < ri9)) or
    (ri9 < li9 & for xi st xi in Gi holds not (li9 < xi or xi < ri9))
    by Def5;
A5: li9 = li by A1,XTUPLE_0:1;
    ri9 = ri by A1,XTUPLE_0:1;
    hence thesis by A2,A3,A4,A5;
  end;
   li in REAL & ri in REAL by XREAL_0:def 1;
   then [li,ri] in [:REAL,REAL:] by ZFMISC_1:87;
  hence thesis by Def5;
end;
