reserve p for Point of TOP-REAL 2,
  f,f1,f2,g for FinSequence of TOP-REAL 2,
  v, v1,v2 for FinSequence of REAL,
  r,s for Real,
  n,m,i,j,k for Nat,
  x for set;
reserve G for Go-board;
reserve D for set,
  f for FinSequence of D,
  M for Matrix of D;
reserve f for FinSequence of TOP-REAL 2;

theorem Th21:
  1<=len f & f/.len f in rng Line(G,len G) & f is_sequence_on G &
i in dom G & i+1 in dom G & m in dom f & f/.m in rng Line(G,i) & (for k st k in
  dom f & f/.k in rng Line(G,i) holds k<=m) implies m+1 in dom f & f/.(m+1) in
  rng Line(G,i+1)
proof
  assume that
A1: 1<=len f and
A2: f/.len f in rng Line(G,len G) and
A3: f is_sequence_on G and
A4: i in dom G and
A5: i+1 in dom G and
A6: m in dom f and
A7: f/.m in rng Line(G,i) and
A8: for k st k in dom f & f/.k in rng Line(G,i) holds k<=m;
  reconsider p=f/.len f, q=f/.m as Point of TOP-REAL 2;
  defpred P[Nat,set] means $2 in dom G & for k st k=$2 holds f/.$1 in rng Line
  (G,k);
A9: for n st n in dom f holds ex k st k in dom G & f/.n in rng Line(G,k)
  proof
    assume not thesis;
    then consider n such that
A10: n in dom f and
A11: for k st k in dom G holds not f/.n in rng Line(G,k);
    consider i,j such that
A12: [i,j] in Indices G and
A13: f/.n = G*(i,j) by A3,A10;
A14: [i,j] in [:dom G, Seg width G:] by A12,MATRIX_0:def 4;
    then i in dom G by ZFMISC_1:87;
    then
A15: not f/.n in rng Line(G,i) by A11;
A16: j in Seg width G by A14,ZFMISC_1:87;
    then j in Seg len Line(G,i) by MATRIX_0:def 7;
    then
A17: j in dom Line(G,i) by FINSEQ_1:def 3;
    (Line(G,i)).j = G*(i,j) by A16,MATRIX_0:def 7;
    hence contradiction by A13,A15,A17,FUNCT_1:def 3;
  end;
A18: for n be Nat st n in Seg len f ex r being Element of REAL st P[n,r]
  proof
    let n be Nat;
    assume n in Seg len f;
    then n in dom f by FINSEQ_1:def 3;
    then consider k such that
A19: k in dom G and
A20: f/.n in rng Line(G,k) by A9;
     reconsider r=k as Element of REAL by XREAL_0:def 1;
    take r;
    thus r in dom G by A19;
    let m;
    assume m=r;
    hence thesis by A20;
  end;
  consider v such that
A21: dom v = Seg len f and
A22: for n be Nat st n in Seg len f holds P[n,v.n] from FINSEQ_1:sch 5(A18);
A23: dom f = Seg len f by FINSEQ_1:def 3;
A24: for k st k in dom v & v.k = i holds k<=m
  proof
    let k;
    assume that
A25: k in dom v and
A26: v.k=i;
    f/.k in rng Line(G,i) by A21,A22,A25,A26;
    hence thesis by A8,A21,A23,A25;
  end;
A27: rng v c= dom G
  proof
    let x be object;
    assume x in rng v;
    then ex y be Nat st y in dom v & v.y=x by FINSEQ_2:10;
    hence thesis by A21,A22;
  end;
A28: len v = len f by A21,FINSEQ_1:def 3;
A29: for k st 1<=k & k<=len v - 1 holds for r,s st r = v.k & s = v.(k+1)
  holds |.r-s.| = 1 or r=s
  proof
    let k;
    assume that
A30: 1<=k and
A31: k<=len v - 1;
A32: k+1<=len v by A31,XREAL_1:19;
    let r,s;
    assume that
A33: r = v.k and
A34: s = v.(k+1);
    1<=k+1 by NAT_1:11;
    then
A35: k+1 in dom f by A28,A32,FINSEQ_3:25;
    then
A36: s in rng v by A21,A23,A34,FUNCT_1:def 3;
    then
A37: s in dom G by A27;
    k<=k+1 by NAT_1:11;
    then k<=len f by A28,A32,XXREAL_0:2;
    then
A38: k in dom f by A30,FINSEQ_3:25;
    then
A39: r in rng v by A21,A23,A33,FUNCT_1:def 3;
    then r in dom G by A27;
    then reconsider n1=r, n2=s as Element of NAT by A37;
    set L1 = Line(G,n1), L2 = Line(G,n2);
    f/.k in rng L1 by A22,A23,A38,A33;
    then consider x be Nat such that
A40: x in dom L1 and
A41: L1.x = f/.k by FINSEQ_2:10;
A42: dom L1 = Seg len L1 & len L1 = width G by FINSEQ_1:def 3,MATRIX_0:def 7;
    then
A43: f/.k = G*(n1,x) by A40,A41,MATRIX_0:def 7;
    f/.(k+1) in rng L2 by A22,A23,A35,A34;
    then consider y be Nat such that
A44: y in dom L2 and
A45: L2.y = f/.(k+1) by FINSEQ_2:10;
    reconsider x,y as Element of NAT by ORDINAL1:def 12;
    [n1,x] in [:dom G,Seg width G:] by A27,A39,A40,A42,ZFMISC_1:87;
    then
A46: [n1,x] in Indices G by MATRIX_0:def 4;
A47: Seg len L2 = dom L2 & len L2 = width G by FINSEQ_1:def 3,MATRIX_0:def 7;
    then [n2,y] in [:dom G,Seg width G:] by A27,A36,A44,ZFMISC_1:87;
    then
A48: [n2,y] in Indices G by MATRIX_0:def 4;
    f/.(k+1) = G*(n2,y) by A47,A44,A45,MATRIX_0:def 7;
    then |.n1-n2.|+|.x-y.|= 1 by A3,A38,A35,A43,A46,A48;
    hence thesis by SEQM_3:42;
  end;
A49: v.m = i
  proof
A50: v.m in dom G by A6,A22,A23;
    then reconsider k=v.m as Element of NAT;
    assume
A51: v.m <> i;
    q in rng Line(G,k) by A6,A22,A23;
    hence contradiction by A4,A7,A51,A50,Th2;
  end;
  1<=m & m<=len f by A6,FINSEQ_3:25;
  then 1<=len f by XXREAL_0:2;
  then
A52: len f in dom f by FINSEQ_3:25;
A53: v.(len v) = len G
  proof
    0<len G by MATRIX_0:44;
    then 0+1<=len G by NAT_1:13;
    then
A54: len G in dom G by FINSEQ_3:25;
A55: v.(len v) in dom G by A22,A28,A23,A52;
    then reconsider k=v.(len v) as Element of NAT;
    assume
A56: v.(len v) <> len G;
    p in rng Line(G,k) by A22,A28,A23,A52;
    hence contradiction by A2,A56,A55,A54,Th2;
  end;
A57: dom G = Seg len G & v<>{} by A1,A21,FINSEQ_1:def 3;
  hence m+1 in dom f by A4,A5,A6,A21,A23,A27,A53,A29,A49,A24,SEQM_3:45;
  m+1 in dom v & v.(m+1)=i+1 by A4,A5,A6,A21,A23,A57,A27,A53,A29,A49,A24,
SEQM_3:45;
  hence thesis by A21,A22;
end;
