reserve i,j,k,l,m,n for Nat,
  D for non empty set,
  f for FinSequence of D;
reserve X for compact Subset of TOP-REAL 2;
reserve r for Real;
reserve f for non trivial FinSequence of TOP-REAL 2;
reserve f for non constant standard special_circular_sequence;

theorem Th51:
  (N-min L~f)`1 < (N-max L~f)`1
proof
  set p = N-min L~f, i = p..f;
A1: len f > 3+1 by GOBOARD7:34;
A2: len f >= 1+1 by GOBOARD7:34,XXREAL_0:2;
A3: p in rng f by Th39;
  then
A4: i in dom f by FINSEQ_4:20;
  then
A5: 1 <= i & i <= len f by FINSEQ_3:25;
A6: p = f.i by A3,FINSEQ_4:19
    .= f/.i by A4,PARTFUN1:def 6;
A7: p`2 = N-bound L~f by EUCLID:52;
  per cases by A5,XXREAL_0:1;
  suppose
A8: i = 1 or i = len f;
    then p = f/.1 by A6,FINSEQ_6:def 1;
    then
A9: p in LSeg(f,1) by A2,TOPREAL1:21;
A10: 1+1 in dom f by A2,FINSEQ_3:25;
    then
A11: f/.(1+1) in L~f by A1,GOBOARD1:1,XXREAL_0:2;
A12: f/.(1+1) in LSeg(f,1) by A2,TOPREAL1:21;
A13: len f -' 1+1 = len f by A1,XREAL_1:235,XXREAL_0:2;
    then len f -' 1 > 3 by A1,XREAL_1:6;
    then
A14: len f -' 1 > 1 by XXREAL_0:2;
    then
A15: f/.(len f -' 1) in LSeg(f,len f -' 1) by A13,TOPREAL1:21;
    len f -' 1 <= len f by A13,NAT_1:11;
    then
A16: len f -' 1 in dom f by A14,FINSEQ_3:25;
    then
A17: f/.(len f -' 1) in L~f by A1,GOBOARD1:1,XXREAL_0:2;
A18: f/.1 = f/.len f by FINSEQ_6:def 1;
    then
A19: p in LSeg(f,len f -' 1) by A6,A8,A13,A14,TOPREAL1:21;
A20: 1 in dom f by FINSEQ_5:6;
    then
A21: p <> f/.(1+1) by A6,A8,A18,A10,GOBOARD7:29;
A22: len f in dom f by FINSEQ_5:6;
    then
A23: p <> f/.(len f -' 1) by A6,A8,A18,A13,A16,GOBOARD7:29;
A24: not(LSeg(f,len f -' 1) is vertical & LSeg(f,1) is vertical)
    proof
      assume LSeg(f,len f -' 1) is vertical & LSeg(f,1) is vertical;
      then
A25:  p`1 = (f/.(1+1))`1 & p`1 = (f/.(len f -' 1))`1 by A19,A9,A15,A12,
SPPOL_1:def 3;
A26:  (f/.(1+1))`2 <= (f/.(len f -' 1))`2 or (f/.(1+1))`2 >= (f/.(len f
      -' 1))`2;
A27:  p`2 >= (f/.(1+1))`2 & p`2 >= (f/.(len f -' 1))`2 by A7,A17,A11,
PSCOMP_1:24;
      LSeg(f,1) = LSeg(f/.1,f/.(1+1)) & LSeg(f,len f -' 1) = LSeg(f/.1,f
      /.(len f -' 1)) by A2,A18,A13,A14,TOPREAL1:def 3;
      then f/.(len f -' 1) in LSeg(f,1) or f/.(1+1) in LSeg(f,len f -' 1) by A6
,A8,A18,A25,A27,A26,GOBOARD7:7;
      then f/.(len f -' 1) in LSeg(f,len f -' 1) /\ LSeg(f,1) or f/.(1+1) in
      LSeg(f,len f -' 1) /\ LSeg(f,1) by A15,A12,XBOOLE_0:def 4;
      then
A28:  LSeg(f,len f -' 1) /\ LSeg(f,1) <> {f/.1} by A6,A8,A18,A23,A21,
TARSKI:def 1;
      f.1 = f/.1 by A20,PARTFUN1:def 6;
      hence contradiction by A28,JORDAN4:42;
    end;
    now
      per cases by A24,SPPOL_1:19;
      suppose
        LSeg(f,len f -' 1) is horizontal;
        then
A29:    p`2 = (f/.(len f -' 1))`2 by A19,A15,SPPOL_1:def 2;
        then
A30:    f/.(len f -' 1) in N-most L~f by A2,A7,A16,Th10,GOBOARD1:1;
        then
A31:    (f/.(len f -' 1))`1 >= p`1 by PSCOMP_1:39;
        (f/.(len f -' 1))`1 <> p`1 by A6,A8,A22,A18,A13,A16,A29,GOBOARD7:29
,TOPREAL3:6;
        then
A32:    (f/.(len f -' 1))`1 > p`1 by A31,XXREAL_0:1;
        (f/.(len f -' 1))`1 <= (N-max L~f)`1 by A30,PSCOMP_1:39;
        hence thesis by A32,XXREAL_0:2;
      end;
      suppose
        LSeg(f,1) is horizontal;
        then
A33:    p`2 = (f/.(1+1))`2 by A9,A12,SPPOL_1:def 2;
        then
A34:    f/.(1+1) in N-most L~f by A2,A7,A10,Th10,GOBOARD1:1;
        then
A35:    (f/.(1+1))`1 >= p`1 by PSCOMP_1:39;
        (f/.(1+1))`1 <> p`1 by A6,A8,A20,A18,A10,A33,GOBOARD7:29,TOPREAL3:6;
        then
A36:    (f/.(1+1))`1 > p`1 by A35,XXREAL_0:1;
        (f/.(1+1))`1 <= (N-max L~f)`1 by A34,PSCOMP_1:39;
        hence thesis by A36,XXREAL_0:2;
      end;
    end;
    hence thesis;
  end;
  suppose that
A37: 1 < i and
A38: i < len f;
A39: i-'1+1 = i by A37,XREAL_1:235;
    then
A40: i-'1 >= 1 by A37,NAT_1:13;
    then
A41: f/.(i-'1) in LSeg(f,i-'1) by A38,A39,TOPREAL1:21;
    i-'1 <= i by A39,NAT_1:11;
    then i-'1 <= len f by A38,XXREAL_0:2;
    then
A42: i-'1 in dom f by A40,FINSEQ_3:25;
    then
A43: f/.(i-'1) in L~f by A1,GOBOARD1:1,XXREAL_0:2;
A44: i+1 <= len f by A38,NAT_1:13;
    then
A45: f/.(i+1) in LSeg(f,i) by A37,TOPREAL1:21;
    i+1 >= 1 by NAT_1:11;
    then
A46: i+1 in dom f by A44,FINSEQ_3:25;
    then
A47: f/.(i+1) in L~f by A1,GOBOARD1:1,XXREAL_0:2;
A48: p <> f/.(i+1) by A3,A6,A46,FINSEQ_4:20,GOBOARD7:29;
A49: p in LSeg(f,i) by A6,A37,A44,TOPREAL1:21;
A50: p in LSeg(f,i-'1) by A6,A38,A39,A40,TOPREAL1:21;
A51: p <> f/.(i-'1) by A4,A6,A39,A42,GOBOARD7:29;
A52: not(LSeg(f,i-'1) is vertical & LSeg(f,i) is vertical)
    proof
      assume LSeg(f,i-'1) is vertical & LSeg(f,i) is vertical;
      then
A53:  p`1 = (f/.(i+1))`1 & p`1 = (f/.(i-'1))`1 by A50,A49,A41,A45,SPPOL_1:def 3
;
A54:  (f/.(i+1))`2 <= (f/.(i-'1))`2 or (f/.(i+1))`2 >= (f/.(i-'1))`2;
A55:  p`2 >= (f/.(i+1))`2 & p`2 >= (f/.(i-'1))`2 by A7,A43,A47,PSCOMP_1:24;
      LSeg(f,i) = LSeg(f/.i,f/.(i+1)) & LSeg(f,i-'1) = LSeg(f/.i,f/.(i-'1
      )) by A37,A38,A39,A40,A44,TOPREAL1:def 3;
      then f/.(i-'1) in LSeg(f,i) or f/.(i+1) in LSeg(f,i-'1) by A6,A53,A55,A54
,GOBOARD7:7;
      then f/.(i-'1) in LSeg(f,i-'1) /\ LSeg(f,i) or f/.(i+1) in LSeg(f,i-'1)
      /\ LSeg(f,i) by A41,A45,XBOOLE_0:def 4;
      then i-'1+1+1 = i-'1+(1+1) & LSeg(f,i-'1) /\ LSeg(f,i) <> {f/.i} by A6
,A51,A48,TARSKI:def 1;
      hence contradiction by A39,A40,A44,TOPREAL1:def 6;
    end;
    now
      per cases by A52,SPPOL_1:19;
      suppose
        LSeg(f,i-'1) is horizontal;
        then
A56:    p`2 = (f/.(i-'1))`2 by A50,A41,SPPOL_1:def 2;
        then
A57:    f/.(i-'1) in N-most L~f by A2,A7,A42,Th10,GOBOARD1:1;
        then
A58:    (f/.(i-'1))`1 >= p`1 by PSCOMP_1:39;
        (f/.(i-'1))`1 <> p`1 by A4,A6,A39,A42,A56,GOBOARD7:29,TOPREAL3:6;
        then
A59:    (f/.(i-'1))`1 > p`1 by A58,XXREAL_0:1;
        (f/.(i-'1))`1 <= (N-max L~f)`1 by A57,PSCOMP_1:39;
        hence thesis by A59,XXREAL_0:2;
      end;
      suppose
        LSeg(f,i) is horizontal;
        then
A60:    p`2 = (f/.(i+1))`2 by A49,A45,SPPOL_1:def 2;
        then
A61:    f/.(i+1) in N-most L~f by A2,A7,A46,Th10,GOBOARD1:1;
        then
A62:    (f/.(i+1))`1 >= p`1 by PSCOMP_1:39;
        (f/.(i+1))`1 <> p`1 by A4,A6,A46,A60,GOBOARD7:29,TOPREAL3:6;
        then
A63:    (f/.(i+1))`1 > p`1 by A62,XXREAL_0:1;
        (f/.(i+1))`1 <= (N-max L~f)`1 by A61,PSCOMP_1:39;
        hence thesis by A63,XXREAL_0:2;
      end;
    end;
    hence thesis;
  end;
end;
