:: On the Order on a Special Polygon
:: by Andrzej Trybulec and Yatsuka Nakamura
::
:: Received November 30, 1997
:: Copyright (c) 1997-2012 Association of Mizar Users


begin

theorem Th1: :: SPRECT_2:1
for i, j, k being Element of NAT
for D being non empty set
for f being FinSequence of D st i <= j & i in dom f & j in dom f & k in dom (mid (f,i,j)) holds
(k + i) -' 1 in dom f
proof end;

theorem Th2: :: SPRECT_2:2
for i, j, k being Element of NAT
for D being non empty set
for f being FinSequence of D st i > j & i in dom f & j in dom f & k in dom (mid (f,i,j)) holds
(i -' k) + 1 in dom f
proof end;

theorem Th3: :: SPRECT_2:3
for i, j, k being Element of NAT
for D being non empty set
for f being FinSequence of D st i <= j & i in dom f & j in dom f & k in dom (mid (f,i,j)) holds
(mid (f,i,j)) /. k = f /. ((k + i) -' 1)
proof end;

theorem Th4: :: SPRECT_2:4
for i, j, k being Element of NAT
for D being non empty set
for f being FinSequence of D st i > j & i in dom f & j in dom f & k in dom (mid (f,i,j)) holds
(mid (f,i,j)) /. k = f /. ((i -' k) + 1)
proof end;

theorem Th5: :: SPRECT_2:5
for i, j being Element of NAT
for D being non empty set
for f being FinSequence of D st i in dom f & j in dom f holds
len (mid (f,i,j)) >= 1
proof end;

theorem Th6: :: SPRECT_2:6
for i, j being Element of NAT
for D being non empty set
for f being FinSequence of D st i in dom f & j in dom f & len (mid (f,i,j)) = 1 holds
i = j
proof end;

theorem Th7: :: SPRECT_2:7
for i, j being Element of NAT
for D being non empty set
for f being FinSequence of D st i in dom f & j in dom f holds
not mid (f,i,j) is empty
proof end;

theorem Th8: :: SPRECT_2:8
for i, j being Element of NAT
for D being non empty set
for f being FinSequence of D st i in dom f & j in dom f holds
(mid (f,i,j)) /. 1 = f /. i
proof end;

theorem Th9: :: SPRECT_2:9
for i, j being Element of NAT
for D being non empty set
for f being FinSequence of D st i in dom f & j in dom f holds
(mid (f,i,j)) /. (len (mid (f,i,j))) = f /. j
proof end;

begin

theorem Th10: :: SPRECT_2:10
for X being compact Subset of (TOP-REAL 2)
for p being Point of (TOP-REAL 2) st p in X & p `2 = N-bound X holds
p in N-most X
proof end;

theorem Th11: :: SPRECT_2:11
for X being compact Subset of (TOP-REAL 2)
for p being Point of (TOP-REAL 2) st p in X & p `2 = S-bound X holds
p in S-most X
proof end;

theorem Th12: :: SPRECT_2:12
for X being compact Subset of (TOP-REAL 2)
for p being Point of (TOP-REAL 2) st p in X & p `1 = W-bound X holds
p in W-most X
proof end;

theorem Th13: :: SPRECT_2:13
for X being compact Subset of (TOP-REAL 2)
for p being Point of (TOP-REAL 2) st p in X & p `1 = E-bound X holds
p in E-most X
proof end;

begin

theorem Th14: :: SPRECT_2:14
for i, j being Element of NAT
for f being FinSequence of (TOP-REAL 2) st 1 <= i & i <= j & j <= len f holds
L~ (mid (f,i,j)) = union { (LSeg (f,k)) where k is Element of NAT : ( i <= k & k < j ) }
proof end;

theorem Th15: :: SPRECT_2:15
for f being FinSequence of (TOP-REAL 2) holds dom (X_axis f) = dom f
proof end;

theorem Th16: :: SPRECT_2:16
for f being FinSequence of (TOP-REAL 2) holds dom (Y_axis f) = dom f
proof end;

theorem Th17: :: SPRECT_2:17
for a, b, c being Point of (TOP-REAL 2) st b in LSeg (a,c) & a `1 <= b `1 & c `1 <= b `1 & not a = b & not b = c holds
( a `1 = b `1 & c `1 = b `1 )
proof end;

theorem Th18: :: SPRECT_2:18
for a, b, c being Point of (TOP-REAL 2) st b in LSeg (a,c) & a `2 <= b `2 & c `2 <= b `2 & not a = b & not b = c holds
( a `2 = b `2 & c `2 = b `2 )
proof end;

theorem Th19: :: SPRECT_2:19
for a, b, c being Point of (TOP-REAL 2) st b in LSeg (a,c) & a `1 >= b `1 & c `1 >= b `1 & not a = b & not b = c holds
( a `1 = b `1 & c `1 = b `1 )
proof end;

theorem Th20: :: SPRECT_2:20
for a, b, c being Point of (TOP-REAL 2) st b in LSeg (a,c) & a `2 >= b `2 & c `2 >= b `2 & not a = b & not b = c holds
( a `2 = b `2 & c `2 = b `2 )
proof end;

begin

definition
let f, g be FinSequence of (TOP-REAL 2);
pred g is_in_the_area_of f means :Def1: :: SPRECT_2:def 1
for n being Element of NAT st n in dom g holds
( W-bound (L~ f) <= (g /. n) `1 & (g /. n) `1 <= E-bound (L~ f) & S-bound (L~ f) <= (g /. n) `2 & (g /. n) `2 <= N-bound (L~ f) );
end;

:: deftheorem Def1 defines is_in_the_area_of SPRECT_2:def 1 :
for f, g being FinSequence of (TOP-REAL 2) holds
( g is_in_the_area_of f iff for n being Element of NAT st n in dom g holds
( W-bound (L~ f) <= (g /. n) `1 & (g /. n) `1 <= E-bound (L~ f) & S-bound (L~ f) <= (g /. n) `2 & (g /. n) `2 <= N-bound (L~ f) ) );

theorem Th21: :: SPRECT_2:21
for f being non trivial FinSequence of (TOP-REAL 2) holds f is_in_the_area_of f
proof end;

theorem Th22: :: SPRECT_2:22
for f, g being FinSequence of (TOP-REAL 2) st g is_in_the_area_of f holds
for i, j being Element of NAT st i in dom g & j in dom g holds
mid (g,i,j) is_in_the_area_of f
proof end;

theorem :: SPRECT_2:23
for f being non trivial FinSequence of (TOP-REAL 2)
for i, j being Element of NAT st i in dom f & j in dom f holds
mid (f,i,j) is_in_the_area_of f by Th21, Th22;

theorem Th24: :: SPRECT_2:24
for f, g, h being FinSequence of (TOP-REAL 2) st g is_in_the_area_of f & h is_in_the_area_of f holds
g ^ h is_in_the_area_of f
proof end;

theorem Th25: :: SPRECT_2:25
for f being non trivial FinSequence of (TOP-REAL 2) holds <*(NE-corner (L~ f))*> is_in_the_area_of f
proof end;

theorem Th26: :: SPRECT_2:26
for f being non trivial FinSequence of (TOP-REAL 2) holds <*(NW-corner (L~ f))*> is_in_the_area_of f
proof end;

theorem Th27: :: SPRECT_2:27
for f being non trivial FinSequence of (TOP-REAL 2) holds <*(SE-corner (L~ f))*> is_in_the_area_of f
proof end;

theorem Th28: :: SPRECT_2:28
for f being non trivial FinSequence of (TOP-REAL 2) holds <*(SW-corner (L~ f))*> is_in_the_area_of f
proof end;

begin

definition
let f, g be FinSequence of (TOP-REAL 2);
pred g is_a_h.c._for f means :Def2: :: SPRECT_2:def 2
( g is_in_the_area_of f & (g /. 1) `1 = W-bound (L~ f) & (g /. (len g)) `1 = E-bound (L~ f) );
pred g is_a_v.c._for f means :Def3: :: SPRECT_2:def 3
( g is_in_the_area_of f & (g /. 1) `2 = S-bound (L~ f) & (g /. (len g)) `2 = N-bound (L~ f) );
end;

:: deftheorem Def2 defines is_a_h.c._for SPRECT_2:def 2 :
for f, g being FinSequence of (TOP-REAL 2) holds
( g is_a_h.c._for f iff ( g is_in_the_area_of f & (g /. 1) `1 = W-bound (L~ f) & (g /. (len g)) `1 = E-bound (L~ f) ) );

:: deftheorem Def3 defines is_a_v.c._for SPRECT_2:def 3 :
for f, g being FinSequence of (TOP-REAL 2) holds
( g is_a_v.c._for f iff ( g is_in_the_area_of f & (g /. 1) `2 = S-bound (L~ f) & (g /. (len g)) `2 = N-bound (L~ f) ) );

theorem Th29: :: SPRECT_2:29
for f being FinSequence of (TOP-REAL 2)
for g, h being one-to-one special FinSequence of (TOP-REAL 2) st 2 <= len g & 2 <= len h & g is_a_h.c._for f & h is_a_v.c._for f holds
L~ g meets L~ h
proof end;

begin

definition
let f be FinSequence of (TOP-REAL 2);
attr f is clockwise_oriented means :Def4: :: SPRECT_2:def 4
(Rotate (f,(N-min (L~ f)))) /. 2 in N-most (L~ f);
end;

:: deftheorem Def4 defines clockwise_oriented SPRECT_2:def 4 :
for f being FinSequence of (TOP-REAL 2) holds
( f is clockwise_oriented iff (Rotate (f,(N-min (L~ f)))) /. 2 in N-most (L~ f) );

theorem Th30: :: SPRECT_2:30
for f being non constant standard special_circular_sequence st f /. 1 = N-min (L~ f) holds
( f is clockwise_oriented iff f /. 2 in N-most (L~ f) )
proof end;

registration
cluster R^2-unit_square -> compact ;
coherence
R^2-unit_square is compact
by TOPREAL2:2;
end;

theorem Th31: :: SPRECT_2:31
N-bound R^2-unit_square = 1
proof end;

theorem Th32: :: SPRECT_2:32
W-bound R^2-unit_square = 0
proof end;

theorem Th33: :: SPRECT_2:33
E-bound R^2-unit_square = 1
proof end;

theorem :: SPRECT_2:34
S-bound R^2-unit_square = 0
proof end;

theorem Th35: :: SPRECT_2:35
N-most R^2-unit_square = LSeg (|[0,1]|,|[1,1]|)
proof end;

theorem :: SPRECT_2:36
N-min R^2-unit_square = |[0,1]|
proof end;

registration
let X be non empty compact non horizontal non vertical Subset of (TOP-REAL 2);
cluster SpStSeq X -> clockwise_oriented ;
coherence
SpStSeq X is clockwise_oriented
proof end;
end;

registration
cluster non empty non trivial V13() V16( NAT ) V17( the carrier of (TOP-REAL 2)) Function-like non constant V26() FinSequence-like FinSubsequence-like circular special unfolded s.c.c. standard clockwise_oriented for FinSequence of the carrier of (TOP-REAL 2);
existence
ex b1 being non constant standard special_circular_sequence st b1 is clockwise_oriented
proof end;
end;

theorem Th37: :: SPRECT_2:37
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i > j & ( ( 1 < j & i <= len f ) or ( 1 <= j & i < len f ) ) holds
mid (f,i,j) is S-Sequence_in_R2
proof end;

theorem Th38: :: SPRECT_2:38
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i < j & ( ( 1 < i & j <= len f ) or ( 1 <= i & j < len f ) ) holds
mid (f,i,j) is S-Sequence_in_R2
proof end;

theorem Th39: :: SPRECT_2:39
for f being non trivial FinSequence of (TOP-REAL 2) holds N-min (L~ f) in rng f
proof end;

theorem Th40: :: SPRECT_2:40
for f being non trivial FinSequence of (TOP-REAL 2) holds N-max (L~ f) in rng f
proof end;

theorem Th41: :: SPRECT_2:41
for f being non trivial FinSequence of (TOP-REAL 2) holds S-min (L~ f) in rng f
proof end;

theorem Th42: :: SPRECT_2:42
for f being non trivial FinSequence of (TOP-REAL 2) holds S-max (L~ f) in rng f
proof end;

theorem Th43: :: SPRECT_2:43
for f being non trivial FinSequence of (TOP-REAL 2) holds W-min (L~ f) in rng f
proof end;

theorem Th44: :: SPRECT_2:44
for f being non trivial FinSequence of (TOP-REAL 2) holds W-max (L~ f) in rng f
proof end;

theorem Th45: :: SPRECT_2:45
for f being non trivial FinSequence of (TOP-REAL 2) holds E-min (L~ f) in rng f
proof end;

theorem Th46: :: SPRECT_2:46
for f being non trivial FinSequence of (TOP-REAL 2) holds E-max (L~ f) in rng f
proof end;

theorem Th47: :: SPRECT_2:47
for i, j, m, n being Element of NAT
for f being non constant standard special_circular_sequence st 1 <= i & i <= j & j < m & m <= n & n <= len f & ( 1 < i or n < len f ) holds
L~ (mid (f,i,j)) misses L~ (mid (f,m,n))
proof end;

theorem Th48: :: SPRECT_2:48
for i, j, m, n being Element of NAT
for f being non constant standard special_circular_sequence st 1 <= i & i <= j & j < m & m <= n & n <= len f & ( 1 < i or n < len f ) holds
L~ (mid (f,i,j)) misses L~ (mid (f,n,m))
proof end;

theorem Th49: :: SPRECT_2:49
for i, j, m, n being Element of NAT
for f being non constant standard special_circular_sequence st 1 <= i & i <= j & j < m & m <= n & n <= len f & ( 1 < i or n < len f ) holds
L~ (mid (f,j,i)) misses L~ (mid (f,n,m))
proof end;

theorem Th50: :: SPRECT_2:50
for i, j, m, n being Element of NAT
for f being non constant standard special_circular_sequence st 1 <= i & i <= j & j < m & m <= n & n <= len f & ( 1 < i or n < len f ) holds
L~ (mid (f,j,i)) misses L~ (mid (f,m,n))
proof end;

theorem Th51: :: SPRECT_2:51
for f being non constant standard special_circular_sequence holds (N-min (L~ f)) `1 < (N-max (L~ f)) `1
proof end;

theorem Th52: :: SPRECT_2:52
for f being non constant standard special_circular_sequence holds N-min (L~ f) <> N-max (L~ f)
proof end;

theorem Th53: :: SPRECT_2:53
for f being non constant standard special_circular_sequence holds (E-min (L~ f)) `2 < (E-max (L~ f)) `2
proof end;

theorem :: SPRECT_2:54
for f being non constant standard special_circular_sequence holds E-min (L~ f) <> E-max (L~ f)
proof end;

theorem Th55: :: SPRECT_2:55
for f being non constant standard special_circular_sequence holds (S-min (L~ f)) `1 < (S-max (L~ f)) `1
proof end;

theorem Th56: :: SPRECT_2:56
for f being non constant standard special_circular_sequence holds S-min (L~ f) <> S-max (L~ f)
proof end;

theorem Th57: :: SPRECT_2:57
for f being non constant standard special_circular_sequence holds (W-min (L~ f)) `2 < (W-max (L~ f)) `2
proof end;

theorem Th58: :: SPRECT_2:58
for f being non constant standard special_circular_sequence holds W-min (L~ f) <> W-max (L~ f)
proof end;

theorem Th59: :: SPRECT_2:59
for f being non constant standard special_circular_sequence holds LSeg ((NW-corner (L~ f)),(N-min (L~ f))) misses LSeg ((N-max (L~ f)),(NE-corner (L~ f)))
proof end;

theorem Th60: :: SPRECT_2:60
for f being FinSequence of (TOP-REAL 2)
for p being Point of (TOP-REAL 2) st f is being_S-Seq & p <> f /. 1 & ( p `1 = (f /. 1) `1 or p `2 = (f /. 1) `2 ) & (LSeg (p,(f /. 1))) /\ (L~ f) = {(f /. 1)} holds
<*p*> ^ f is S-Sequence_in_R2
proof end;

theorem Th61: :: SPRECT_2:61
for f being FinSequence of (TOP-REAL 2)
for p being Point of (TOP-REAL 2) st f is being_S-Seq & p <> f /. (len f) & ( p `1 = (f /. (len f)) `1 or p `2 = (f /. (len f)) `2 ) & (LSeg (p,(f /. (len f)))) /\ (L~ f) = {(f /. (len f))} holds
f ^ <*p*> is S-Sequence_in_R2
proof end;

begin

theorem Th62: :: SPRECT_2:62
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. j = N-max (L~ f) & N-max (L~ f) <> NE-corner (L~ f) holds
(mid (f,i,j)) ^ <*(NE-corner (L~ f))*> is S-Sequence_in_R2
proof end;

theorem :: SPRECT_2:63
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. j = E-max (L~ f) & E-max (L~ f) <> NE-corner (L~ f) holds
(mid (f,i,j)) ^ <*(NE-corner (L~ f))*> is S-Sequence_in_R2
proof end;

theorem Th64: :: SPRECT_2:64
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. j = S-max (L~ f) & S-max (L~ f) <> SE-corner (L~ f) holds
(mid (f,i,j)) ^ <*(SE-corner (L~ f))*> is S-Sequence_in_R2
proof end;

theorem Th65: :: SPRECT_2:65
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. j = E-max (L~ f) & E-max (L~ f) <> NE-corner (L~ f) holds
(mid (f,i,j)) ^ <*(NE-corner (L~ f))*> is S-Sequence_in_R2
proof end;

theorem Th66: :: SPRECT_2:66
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. i = N-min (L~ f) & N-min (L~ f) <> NW-corner (L~ f) holds
<*(NW-corner (L~ f))*> ^ (mid (f,i,j)) is S-Sequence_in_R2
proof end;

theorem Th67: :: SPRECT_2:67
for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. i = W-min (L~ f) & W-min (L~ f) <> SW-corner (L~ f) holds
<*(SW-corner (L~ f))*> ^ (mid (f,i,j)) is S-Sequence_in_R2
proof end;

Lm1: for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. i = N-min (L~ f) & N-min (L~ f) <> NW-corner (L~ f) & f /. j = N-max (L~ f) & N-max (L~ f) <> NE-corner (L~ f) holds
(<*(NW-corner (L~ f))*> ^ (mid (f,i,j))) ^ <*(NE-corner (L~ f))*> is S-Sequence_in_R2

proof end;

registration
let f be non constant standard special_circular_sequence;
cluster L~ f -> being_simple_closed_curve ;
coherence
L~ f is being_simple_closed_curve
by JORDAN4:51;
end;

Lm2: for f being non constant standard special_circular_sequence holds LSeg ((S-max (L~ f)),(SE-corner (L~ f))) misses LSeg ((NW-corner (L~ f)),(N-min (L~ f)))
proof end;

Lm3: for f being non constant standard special_circular_sequence
for i, j being Element of NAT st i in dom f & j in dom f & mid (f,i,j) is S-Sequence_in_R2 & f /. i = N-min (L~ f) & N-min (L~ f) <> NW-corner (L~ f) & f /. j = S-max (L~ f) & S-max (L~ f) <> SE-corner (L~ f) holds
(<*(NW-corner (L~ f))*> ^ (mid (f,i,j))) ^ <*(SE-corner (L~ f))*> is S-Sequence_in_R2

proof end;

begin

theorem Th68: :: SPRECT_2:68
for f being non constant standard special_circular_sequence st f /. 1 = N-min (L~ f) holds
(N-min (L~ f)) .. f < (N-max (L~ f)) .. f
proof end;

theorem :: SPRECT_2:69
for f being non constant standard special_circular_sequence st f /. 1 = N-min (L~ f) holds
(N-max (L~ f)) .. f > 1
proof end;

Lm4: for f being non constant standard special_circular_sequence st f /. 1 = N-min (L~ f) holds
(N-min (L~ f)) .. f < (E-max (L~ f)) .. f

proof end;

Lm5: for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(N-max (L~ z)) .. z < (S-max (L~ z)) .. z

proof end;

Lm6: for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(N-max (L~ z)) .. z < (S-min (L~ z)) .. z

proof end;

theorem :: SPRECT_2:70
for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) & N-max (L~ z) <> E-max (L~ z) holds
(N-max (L~ z)) .. z < (E-max (L~ z)) .. z
proof end;

Lm7: for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(E-max (L~ z)) .. z < (S-max (L~ z)) .. z

proof end;

Lm8: for f being non constant standard special_circular_sequence holds (LSeg ((N-min (L~ f)),(NW-corner (L~ f)))) /\ (LSeg ((NE-corner (L~ f)),(E-max (L~ f)))) = {}
proof end;

theorem :: SPRECT_2:71
for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(E-max (L~ z)) .. z < (E-min (L~ z)) .. z
proof end;

theorem Th72: :: SPRECT_2:72
for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) & E-min (L~ z) <> S-max (L~ z) holds
(E-min (L~ z)) .. z < (S-max (L~ z)) .. z
proof end;

theorem Th73: :: SPRECT_2:73
for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(S-max (L~ z)) .. z < (S-min (L~ z)) .. z
proof end;

Lm9: for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(E-min (L~ z)) .. z < (S-min (L~ z)) .. z

proof end;

Lm10: for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) & N-min (L~ z) <> W-max (L~ z) holds
(E-min (L~ z)) .. z < (W-max (L~ z)) .. z

proof end;

Lm11: for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(E-min (L~ z)) .. z < (W-min (L~ z)) .. z

proof end;

theorem :: SPRECT_2:74
for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) & S-min (L~ z) <> W-min (L~ z) holds
(S-min (L~ z)) .. z < (W-min (L~ z)) .. z
proof end;

theorem Th75: :: SPRECT_2:75
for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) & N-min (L~ z) <> W-max (L~ z) holds
(W-min (L~ z)) .. z < (W-max (L~ z)) .. z
proof end;

theorem :: SPRECT_2:76
for z being non constant standard clockwise_oriented special_circular_sequence st z /. 1 = N-min (L~ z) holds
(W-min (L~ z)) .. z < len z
proof end;

theorem :: SPRECT_2:77
for f being non constant standard special_circular_sequence st f /. 1 = N-min (L~ f) holds
(W-max (L~ f)) .. f < len f
proof end;