
theorem Th40:
for F be FinSequence of bool REAL,k be Nat st
  (for n be Nat st n in dom F holds F.n is open_interval Subset of REAL)
& (for n be Nat st 1 <= n < len F holds union rng(F|n) meets F.(n+1))
holds union rng(F|k) is open_interval Subset of REAL
proof
    let F be FinSequence of bool REAL,k be Nat;
    assume that
A1:  for n be Nat st n in dom F holds F.n is open_interval Subset of REAL and
A2:  for n be Nat st 1 <= n < len F holds union rng(F|n) meets F.(n+1);

A3: now let k be Nat;
     assume k = 0; then
     union rng(F|k) = {} by ZFMISC_1:2;
     hence union rng(F|k) is open_interval Subset of REAL;
    end;

    defpred P[Nat] means union rng(F|$1) is open_interval Subset of REAL;
A4: P[0] by A3;
A5: for k be Nat st P[k] holds P[k+1]
    proof
     let k be Nat;
     assume A6: P[k];
     per cases;
     suppose A7: 1 <= k+1 <= len F; then
A8:   k < len F by NAT_1:13;
A9:   1 <= len F by A7,XXREAL_0:2;
A10:  F.(k+1) is open_interval Subset of REAL by A1,A7,FINSEQ_3:25;
A11:  F <> {} by A7;

      per cases;
      suppose k = 0; then
       F|(k+1) = <*F.1*> by A11,FINSEQ_5:20; then
       rng(F|(k+1)) = {F.1} by FINSEQ_1:38;
       hence union rng(F|(k+1)) is open_interval Subset of REAL
         by A1,A9,FINSEQ_3:25;
      end;
      suppose k <> 0; then
A12:   1 <= k by NAT_1:14;
       F|(k+1) = F|k ^ <*F.(k+1)*> by A7,NAT_1:13,FINSEQ_5:83; then
       rng(F|(k+1)) = rng(F|k) \/ rng <*F.(k+1)*> by FINSEQ_1:31
        .= rng(F|k) \/ {F.(k+1)} by FINSEQ_1:38; then
       union rng(F|(k+1)) = union rng(F|k) \/ union {F.(k+1)} by ZFMISC_1:78;
       hence union rng(F|(k+1)) is open_interval Subset of REAL
         by A12,A2,A6,A8,A10,Th2;
      end;
     end;
     suppose k+1 < 1 or len F < k+1; then
      k+1 = 0 or (F|(k+1) = F & len F <= k) by NAT_1:13,14,FINSEQ_1:58;
      hence union rng(F|(k+1)) is open_interval Subset of REAL
        by A6,FINSEQ_1:58;
     end;
    end;

    for k be Nat holds P[k] from NAT_1:sch 2(A4,A5);
    hence union rng(F|k) is open_interval Subset of REAL;
end;
