reserve P for Subset of TOP-REAL 2,
  f,f1,f2,g for FinSequence of TOP-REAL 2,
  p,p1,p2,q,q1,q2 for Point of TOP-REAL 2,
  r1,r2,r19,r29 for Real,
  i,j,k,n for Nat;

theorem Th37:
  f is unfolded s.n.c. & p in LSeg(f,n) & not p in rng f implies
  Ins(f,n,p) is s.n.c.
proof
  assume that
A1: f is unfolded and
A2: f is s.n.c. and
A3: p in LSeg(f,n) and
A4: not p in rng f;
  set fp = Ins(f,n,p);
  let i,j be Nat such that
A5: i+1 < j;
  per cases;
  suppose
A6: i = 0 or j+1 > len fp;
    now
      per cases by A6;
      case
        i = 0;
        hence LSeg(fp,i) = {} by TOPREAL1:def 3;
      end;
      case
        j+1 > len fp;
        hence LSeg(fp,j) = {} by TOPREAL1:def 3;
      end;
    end;
    then LSeg(fp,i) /\ LSeg(fp,j) = {};
    hence thesis;
  end;
  suppose that
A7: i <> 0 and
A8: j+1 <= len fp;
A9: 1 <= i by A7,NAT_1:14;
    set f1 = f|n, g1 = f1^<*p*>, f2 = f/^n;
A10: fp = g1^f2 by FINSEQ_5:def 4;
    i <= i+1 by NAT_1:11;
    then
A11: i < j by A5,XXREAL_0:2;
A12: i+1 <= i+1+1 by NAT_1:11;
A13: len fp = len f + 1 by FINSEQ_5:69;
A14: 1 <= n by A3,TOPREAL1:def 3;
A15: n+1 <= len f by A3,TOPREAL1:def 3;
A16: len g1 = len f1 + 1 by FINSEQ_2:16;
    then
A17: g1/.len g1 = p by FINSEQ_4:67;
A18: n <= n+1 by NAT_1:11;
    then
A19: n <= len f by A15,XXREAL_0:2;
A20: len f1 = n by A15,A18,FINSEQ_1:59,XXREAL_0:2;
    i+1+1 <= j by A5,NAT_1:13;
    then i+1+1+1 <= j+1 by XREAL_1:6;
    then
A21: i+1+1+1 <= len f + 1 by A8,A13,XXREAL_0:2;
    then i+1+1 <= len f by XREAL_1:6;
    then
A22: i+1 <= len f by A12,XXREAL_0:2;
    now
      per cases;
      suppose
A23:    j+1 <= n;
        then
A24:    LSeg(fp,j) = LSeg(g1,j) by A10,A16,A18,A20,Th6,XXREAL_0:2
          .= LSeg(f1,j) by A20,A23,Th6
          .= LSeg(f,j) by A20,A23,Th3;
        j <= j+1 by NAT_1:11;
        then i < j+1 by A11,XXREAL_0:2;
        then i < n by A23,XXREAL_0:2;
        then
A25:    i+1 <= n by NAT_1:13;
        then LSeg(fp,i) = LSeg(g1,i) by A10,A16,A18,A20,Th6,XXREAL_0:2
          .= LSeg(f1,i) by A20,A25,Th6
          .= LSeg(f,i) by A20,A25,Th3;
        hence thesis by A2,A5,A24;
      end;
      suppose
        j+1 > n;
        then
A26:    n <= j by NAT_1:13;
        now
          per cases;
          suppose
A27:        i <= n+1;
A28:        1 <= n+1 by NAT_1:11;
            1 <= len f - n by A15,XREAL_1:19;
            then 1 <= len f2 by A19,RFINSEQ:def 1;
            then 1 in dom f2 by FINSEQ_3:25;
            then
A29:        f/.(n+1) = f2/.1 by FINSEQ_5:27;
            len g1 in dom g1 by FINSEQ_5:6;
            then
A30:        fp/.(n+1) = g1/.len g1 by A10,A16,A20,FINSEQ_4:68;
Z1:         n+1 in dom f by A15,A28,FINSEQ_3:25;
Z2:         n+1+1 >= 1 by NAT_1:11;
            n+1+1 <= len f + 1 by A15,XREAL_1:6; then 
            n+1+1 <= len fp by A13; then
            n+1+1 in dom fp by Z2,FINSEQ_3:25; then
A31:        fp/.(n+1+1) = fp.(n+1+1) by PARTFUN1:def 6
                .= f.(n+1) by A15,FINSEQ_5:74
                .= f/.(n+1) by Z1,PARTFUN1:def 6;
A32:        n in dom f1 by A14,A20,FINSEQ_3:25;
            then
A33:        f/.n = f1/.len f1 by A20,FINSEQ_4:70;
            n+1+1 <= len fp by A13,A15,XREAL_1:6;
            then
A34:        LSeg(fp,n+1) = LSeg(p,f2/.1) by A17,A29,A31,A28,A30,TOPREAL1:def 3;
A35:        f1/.len f1 = g1/.len f1 by A20,A32,FINSEQ_4:68;
A36:        LSeg(fp,n) = LSeg(g1,n) by A10,A16,A20,Th6
              .= LSeg(f1/.len f1,p) by A16,A17,A14,A20,A35,TOPREAL1:def 3;
A37:        LSeg(f,n) = LSeg(f/.n,f/.(n+1)) by A14,A15,TOPREAL1:def 3;
            then
A38:        LSeg(f1/.len f1,p) \/ LSeg(g1/.len g1,f2/.1) = LSeg(f1/.len
            f1,f2/.1) by A3,A17,A33,A29,TOPREAL1:5;
A39:        LSeg(f1/.len f1,p) /\ LSeg(p,f2/.1) = {p} by A3,A37,A33,A29,
TOPREAL1:8;
            now
              per cases by XXREAL_0:1;
              suppose
                i < n;
                then
A40:            i+1 <= n by NAT_1:13;
                then
A41:            LSeg(fp,i) = LSeg(g1,i) by A10,A16,A18,A20,Th6,XXREAL_0:2
                  .= LSeg(f1,i) by A20,A40,Th6
                  .= LSeg(f,i) by A20,A40,Th3;
                now
                  per cases;
                  suppose
A42:                j = n;
                    then
A43:                LSeg(f,i) misses LSeg(f,n) by A2,A5;
                    LSeg(fp,i) /\ LSeg(fp,j) c= LSeg(f,i) /\ LSeg(f,n) by A37
,A33,A29,A38,A36,A41,A42,XBOOLE_1:7,26;
                    then LSeg(fp,i) /\ LSeg(fp,j) c= {} by A43;
                    then LSeg(fp,i) /\ LSeg(fp,j) = {} by XBOOLE_1:3;
                    hence thesis;
                  end;
                  suppose
                    j <> n;
                    then n < j by A26,XXREAL_0:1;
                    then
A44:                n+1 <= j by NAT_1:13;
                    now
                      per cases;
                      suppose
A45:                    j = n+1;
                        now
                          per cases;
                          suppose
A46:                        i+1 = n;
A47:                        i+(1+1) <= len f by A21,XREAL_1:6;
                            LSeg(fp,i) = LSeg( g1,i) by A10,A16,A20,A46,Th6,
NAT_1:11
                              .= LSeg(f1,i) by A20,A46,Th6
                              .= LSeg(f,i) by A20,A46,Th3;
                            then
A48:                        LSeg(fp,i) /\ LSeg (f,n) = {f/.n} by A1,A9,A46,A47;
                            assume not thesis;
                            then consider x being object such that
A49:                        x in LSeg(fp,i) /\ LSeg(fp,j) by XBOOLE_0:4;
A50:                        x in LSeg(fp,i) by A49,XBOOLE_0:def 4;
A51:                        x in LSeg(fp,j) by A49,XBOOLE_0:def 4;
                            then
                            x in LSeg(f,n) by A17,A37,A33,A29,A38,A34,A45,
XBOOLE_0:def 3;
                            then x in {f/.n} by A48,A50,XBOOLE_0:def 4;
                            then
A52:                        x = f/.n by TARSKI:def 1;
                            then x in LSeg(fp,n) by A33,A36,RLTOPSP1:68;
                            then x in LSeg(fp,n) /\ LSeg(fp,n+1) by A45,A51,
XBOOLE_0:def 4;
                            then
A53:                        p = f/.n by A36,A34,A39,A52,TARSKI:def 1;
                            n in dom f by A14,A15,SEQ_4:134;
                            hence contradiction by A4,A53,PARTFUN2:2;
                          end;
                          suppose
                            i+1 <> n;
                            then i+1 < n by A40,XXREAL_0:1;
                            then
A54:                        LSeg(f,i) misses LSeg(f,n) by A2;
                            LSeg(fp,i) /\ LSeg(fp,j) c= LSeg(f,i) /\ LSeg
(f,n) by A17,A37,A33,A29,A38,A34,A41,A45,XBOOLE_1:7,26;
                            then LSeg(fp,i) /\ LSeg(fp,j) c= {} by A54;
                            then LSeg(fp,i) /\ LSeg(fp,j) = {} by XBOOLE_1:3;
                            hence thesis;
                          end;
                        end;
                        hence thesis;
                      end;
                      suppose
A55:                    j <> n+1;
                        reconsider nj = j-(n+1) as Element of NAT by A44,
INT_1:5;
A56:                    n+1 < j by A44,A55,XXREAL_0:1;
                        then n+1+1 <= j by NAT_1:13;
                        then
A57:                    1 <= nj by XREAL_1:19;
                        reconsider j9 = j - 1 as Element of NAT by A9,A11,
INT_1:5,XXREAL_0:2;
A58:                    n+nj = j9;
                        i+1+1 <= n+1 by A40,XREAL_1:6;
                        then i+1+1 < j by A56,XXREAL_0:2;
                        then
A59:                    i+1 < j9 by XREAL_1:20;
                        j = nj+(n+1);
                        then LSeg(fp,j) = LSeg(f2,nj) by A10,A16,A20,A57,Th7
                          .= LSeg(f,j9) by A19,A57,A58,Th4;
                        hence thesis by A2,A41,A59;
                      end;
                    end;
                    hence thesis;
                  end;
                end;
                hence thesis;
              end;
              suppose
A60:            i = n;
                then reconsider nj = j-(n+1) as Element of NAT by A5,INT_1:5;
A61:            n+1+1 <= j by A5,A60,NAT_1:13;
                then
A62:            1 <= nj by XREAL_1:19;
                reconsider j9 = j - 1 as Element of NAT by A9,A11,INT_1:5
,XXREAL_0:2;
A63:            n+nj = j9;
                j = nj+(n+1);
                then
A64:            LSeg(fp,j) = LSeg(f2,nj) by A10,A16,A20,A62,Th7
                  .= LSeg(f,j9) by A19,A62,A63,Th4;
                now
                  per cases;
                  suppose
                    j <> n+1+1;
                    then n+1+1 < j by A61,XXREAL_0:1;
                    then i+1 < j9 by A60,XREAL_1:20;
                    then
A65:                LSeg(f,i) misses LSeg(f,j9) by A2;
                    LSeg(fp,i) /\ LSeg(fp,j) c= LSeg(f,i) /\ LSeg(f,j9)
                    by A37,A33,A29,A38,A36,A60,A64,XBOOLE_1:7,26;
                    then LSeg(fp,i) /\ LSeg(fp,j) c= {} by A65;
                    then LSeg(fp,i) /\ LSeg(fp,j) = {} by XBOOLE_1:3;
                    hence thesis;
                  end;
                  suppose
A66:                j = n+1+1;
                    then n+(1+1) <= len f by A8,A13,XREAL_1:6;
                    then
A67:                LSeg(f,n) /\ LSeg(f,j9) = {f/.j9} by A1,A14,A66;
                    assume not thesis;
                    then consider x being object such that
A68:                x in LSeg(fp,i) /\ LSeg(fp,j) by XBOOLE_0:4;
A69:                x in LSeg(fp,j) by A68,XBOOLE_0:def 4;
A70:                x in LSeg(fp,i) by A68,XBOOLE_0:def 4;
                    then x in LSeg(f,n) by A37,A33,A29,A38,A36,A60,
XBOOLE_0:def 3;
                    then x in {f/.(n+1)} by A64,A66,A67,A69,XBOOLE_0:def 4;
                    then
A71:                x = f/.(n+1) by TARSKI:def 1;
                    then x in LSeg(fp,n+1) by A29,A34,RLTOPSP1:68;
                    then x in LSeg(fp,n) /\ LSeg(fp,n+1) by A60,A70,
XBOOLE_0:def 4;
                    then
A72:                p = f/.(n+1) by A36,A34,A39,A71,TARSKI:def 1;
                    n+1 in dom f by A14,A15,SEQ_4:134;
                    hence contradiction by A4,A72,PARTFUN2:2;
                  end;
                end;
                hence thesis;
              end;
              suppose
A73:            i>n;
                reconsider j9 = j - 1 as Element of NAT by A9,A11,INT_1:5
,XXREAL_0:2;
                i>=n+1 by A73,NAT_1:13;
                then
A74:            i = n+1 by A27,XXREAL_0:1;
                then n+1 < j9 by A5,XREAL_1:20;
                then
A75:            LSeg(f,n) misses LSeg(f,j9) by A2;
                n+1 <= n+1+1 by NAT_1:11;
                then reconsider nj = j-(n+1) as Element of NAT by A5,A74,
INT_1:5,XXREAL_0:2;
A76:            1 <= nj by A5,A74,XREAL_1:19;
A77:            n+nj = j9;
                j = nj+(n+1);
                then LSeg(fp,j) = LSeg(f2,nj) by A10,A16,A20,A76,Th7
                  .= LSeg(f,j9) by A19,A76,A77,Th4;
                then LSeg(fp,n+1) /\ LSeg(fp,j) c= LSeg(f,n) /\ LSeg(f,j9) by
A17,A37,A33,A29,A38,A34,XBOOLE_1:7,26;
                then LSeg(fp,n+1) /\ LSeg(fp,j) c= {} by A75;
                then LSeg(fp,n+1) /\ LSeg(fp,j) = {} by XBOOLE_1:3;
                hence thesis by A74;
              end;
            end;
            hence thesis;
          end;
          suppose
A78:        i > n+1;
            then reconsider nj = j-(n+1) as Element of NAT by A11,INT_1:5
,XXREAL_0:2;
            n+1 < j by A11,A78,XXREAL_0:2;
            then n+1+1 <= j by NAT_1:13;
            then
A79:        1 <= nj by XREAL_1:19;
            reconsider ni = i - (n+1) as Element of NAT by A78,INT_1:5;
            n+1+1 <= i by A78,NAT_1:13;
            then
A80:        1 <= ni by XREAL_1:19;
            len f <= len f+1 by NAT_1:11;
            then i+1 <= len f+1 by A22,XXREAL_0:2;
            then i+1-(n+1) <= len f+1- (n+1) by XREAL_1:9;
            then
A81:        ni+1 <= len f - n;
            reconsider i9 = i - 1 as Element of NAT by A7,INT_1:5,NAT_1:14;
            reconsider j9 = j - 1 as Element of NAT by A9,A11,INT_1:5
,XXREAL_0:2;
A82:        n+ni = i9;
            i+1-1 < j9 by A5,XREAL_1:9;
            then
A83:        i9+1 < j9;
A84:        n+nj = j9;
            j = nj+(n+1);
            then
A85:        LSeg(fp,j) = LSeg(f2,nj) by A10,A16,A20,A79,Th7
              .= LSeg(f,j9) by A19,A79,A84,Th4;
            i = ni+(n+1);
            then LSeg(fp,i) = LSeg(f2,ni) by A10,A16,A20,A80,Th7
              .= LSeg(f,i9) by A80,A81,A82,Th5;
            hence thesis by A2,A83,A85;
          end;
        end;
        hence thesis;
      end;
    end;
    hence thesis;
  end;
end;
