Lm1:
for n being Nat
for p, q being FinSequence st 1 <= n & n <= len p holds
p . n = (p ^ q) . n
Lm2:
for n being Nat
for p, q being FinSequence st 1 <= n & n <= len q holds
q . n = (p ^ q) . ((len p) + n)
theorem Th9:
for
G being
Graph for
p,
q being
oriented Chain of
G for
W being
Function for
V being
set for
v1,
v2 being
Vertex of
G st
p is_shortestpath_of v1,
v2,
V,
W &
q is_shortestpath_of v1,
v2,
V,
W holds
cost (
p,
W)
= cost (
q,
W)
Lm3:
for i being Nat
for G being Graph
for pe being FinSequence of the carrier' of G st 1 <= i & i <= len pe holds
( the Source of G . (pe . i) in the carrier of G & the Target of G . (pe . i) in the carrier of G )
Lm4:
for i being Nat
for G being Graph
for pe being FinSequence of the carrier' of G
for v1 being Vertex of G st 1 <= i & i <= len pe & ( v1 = the Source of G . (pe . i) or v1 = the Target of G . (pe . i) ) holds
v1 in vertices pe
theorem Th13:
for
W being
Function for
V being
set for
G being
finite Graph for
P,
Q being
oriented Chain of
G for
v1,
v2,
v3 being
Vertex of
G st
W is_weight>=0of G &
P is_shortestpath_of v1,
v2,
V,
W &
v1 <> v2 &
v1 <> v3 &
Q is_shortestpath_of v1,
v3,
V,
W & ( for
e being
set holds
( not
e in the
carrier' of
G or not
e orientedly_joins v2,
v3 ) ) &
P islongestInShortestpath V,
v1,
W holds
Q is_shortestpath_of v1,
v3,
V \/ {v2},
W
theorem Th15:
for
V,
e being
set for
G being
oriented finite Graph for
P,
Q being
oriented Chain of
G for
W being
Function of the
carrier' of
G,
Real>=0 for
v1,
v2,
v3 being
Vertex of
G st
e in the
carrier' of
G &
P is_shortestpath_of v1,
v2,
V,
W &
v1 <> v3 &
Q = P ^ <*e*> &
e orientedly_joins v2,
v3 &
v1 in V & ( for
v4 being
Vertex of
G st
v4 in V holds
for
ee being
set holds
( not
ee in the
carrier' of
G or not
ee orientedly_joins v4,
v3 ) ) holds
Q is_shortestpath_of v1,
v3,
V \/ {v2},
W
theorem Th16:
for
U,
V being
set for
G being
oriented finite Graph for
P being
oriented Chain of
G for
W being
Function of the
carrier' of
G,
Real>=0 for
v1,
v2 being
Vertex of
G st the
carrier of
G = U \/ V &
v1 in U & ( for
v3,
v4 being
Vertex of
G st
v3 in U &
v4 in V holds
for
e being
set holds
( not
e in the
carrier' of
G or not
e orientedly_joins v3,
v4 ) ) holds
(
P is_shortestpath_of v1,
v2,
U,
W iff
P is_shortestpath_of v1,
v2,
W )
Lm5:
for X being set
for f being Element of Funcs (X,X) holds dom f = X
definition
let f be
Element of
Funcs (
(REAL *),
(REAL *));
let n be
Nat;
existence
ex b1 being Element of Funcs ((REAL *),(REAL *)) st
( dom b1 = REAL * & ( for h being Element of REAL * holds b1 . h = ((repeat f) . (LifeSpan (f,h,n))) . h ) )
uniqueness
for b1, b2 being Element of Funcs ((REAL *),(REAL *)) st dom b1 = REAL * & ( for h being Element of REAL * holds b1 . h = ((repeat f) . (LifeSpan (f,h,n))) . h ) & dom b2 = REAL * & ( for h being Element of REAL * holds b2 . h = ((repeat f) . (LifeSpan (f,h,n))) . h ) holds
b1 = b2
end;
definition
let n be
Nat;
existence
ex b1 being Element of Funcs ((REAL *),(REAL *)) st
( dom b1 = REAL * & ( for f being Element of REAL * holds b1 . f = (f,(((n * n) + (3 * n)) + 1)) := ((Argmin ((OuterVx (f,n)),f,n)),(- 1)) ) )
uniqueness
for b1, b2 being Element of Funcs ((REAL *),(REAL *)) st dom b1 = REAL * & ( for f being Element of REAL * holds b1 . f = (f,(((n * n) + (3 * n)) + 1)) := ((Argmin ((OuterVx (f,n)),f,n)),(- 1)) ) & dom b2 = REAL * & ( for f being Element of REAL * holds b2 . f = (f,(((n * n) + (3 * n)) + 1)) := ((Argmin ((OuterVx (f,n)),f,n)),(- 1)) ) holds
b1 = b2
end;
reconsider jj = 1 as Real ;
Lm6:
for k, n being Nat st k >= 1 holds
n <= k * n
Lm7:
for n being Nat holds
( 3 * n < ((n * n) + (3 * n)) + 1 & n < ((n * n) + (3 * n)) + 1 & 2 * n < ((n * n) + (3 * n)) + 1 )
Lm8:
for k, n being Nat holds
( ( n < k & k <= 2 * n implies ( ( not 2 * n < k or not k <= 3 * n ) & not k <= n & not k > 3 * n ) ) & ( ( k <= n or k > 3 * n ) implies ( ( not 2 * n < k or not k <= 3 * n ) & ( not n < k or not k <= 2 * n ) ) ) & ( 2 * n < k & k <= 3 * n implies ( ( not n < k or not k <= 2 * n ) & not k <= n & not k > 3 * n ) ) )
definition
let f be
Element of
REAL * ;
let n be
Nat;
existence
ex b1 being Element of REAL * st
( dom b1 = dom f & ( for k being Nat st k in dom f holds
( ( n < k & k <= 2 * n implies ( ( f hasBetterPathAt n,k -' n implies b1 . k = f /. (((n * n) + (3 * n)) + 1) ) & ( not f hasBetterPathAt n,k -' n implies b1 . k = f . k ) ) ) & ( 2 * n < k & k <= 3 * n implies ( ( f hasBetterPathAt n,k -' (2 * n) implies b1 . k = newpathcost (f,n,(k -' (2 * n))) ) & ( not f hasBetterPathAt n,k -' (2 * n) implies b1 . k = f . k ) ) ) & ( ( k <= n or k > 3 * n ) implies b1 . k = f . k ) ) ) )
uniqueness
for b1, b2 being Element of REAL * st dom b1 = dom f & ( for k being Nat st k in dom f holds
( ( n < k & k <= 2 * n implies ( ( f hasBetterPathAt n,k -' n implies b1 . k = f /. (((n * n) + (3 * n)) + 1) ) & ( not f hasBetterPathAt n,k -' n implies b1 . k = f . k ) ) ) & ( 2 * n < k & k <= 3 * n implies ( ( f hasBetterPathAt n,k -' (2 * n) implies b1 . k = newpathcost (f,n,(k -' (2 * n))) ) & ( not f hasBetterPathAt n,k -' (2 * n) implies b1 . k = f . k ) ) ) & ( ( k <= n or k > 3 * n ) implies b1 . k = f . k ) ) ) & dom b2 = dom f & ( for k being Nat st k in dom f holds
( ( n < k & k <= 2 * n implies ( ( f hasBetterPathAt n,k -' n implies b2 . k = f /. (((n * n) + (3 * n)) + 1) ) & ( not f hasBetterPathAt n,k -' n implies b2 . k = f . k ) ) ) & ( 2 * n < k & k <= 3 * n implies ( ( f hasBetterPathAt n,k -' (2 * n) implies b2 . k = newpathcost (f,n,(k -' (2 * n))) ) & ( not f hasBetterPathAt n,k -' (2 * n) implies b2 . k = f . k ) ) ) & ( ( k <= n or k > 3 * n ) implies b2 . k = f . k ) ) ) holds
b1 = b2
end;
theorem Th39:
for
i,
k,
n being
Nat for
f,
g,
h being
Element of
REAL * st
g = ((repeat ((Relax n) * (findmin n))) . i) . f &
h = ((repeat ((Relax n) * (findmin n))) . (i + 1)) . f &
k = Argmin (
(OuterVx (g,n)),
g,
n) &
OuterVx (
g,
n)
<> {} holds
(
UsedVx (
h,
n)
= (UsedVx (g,n)) \/ {k} & not
k in UsedVx (
g,
n) )
Lm9:
for k, n being Nat holds n - k <= n
Lm10:
for p, q being FinSequence of NAT
for f being Element of REAL *
for i, n being Element of NAT st ( for k being Nat st 1 <= k & k < len p holds
p . ((len p) - k) = f . ((p /. (((len p) - k) + 1)) + n) ) & ( for k being Nat st 1 <= k & k < len q holds
q . ((len q) - k) = f . ((q /. (((len q) - k) + 1)) + n) ) & len p <= len q & p . (len p) = q . (len q) holds
for k being Nat st 1 <= k & k < len p holds
p . ((len p) - k) = q . ((len q) - k)
Lm11:
for i, n being Nat st 1 <= i & i <= n holds
( 1 < (2 * n) + i & (2 * n) + i < ((n * n) + (3 * n)) + 1 & i < (2 * n) + i )
Lm12:
for i, n being Nat st 1 <= i & i <= n holds
( 1 < n + i & n + i <= 2 * n & n + i < ((n * n) + (3 * n)) + 1 )
Lm13:
for i, j, n being Nat st 1 <= i & i <= n & j <= n holds
( 1 < ((2 * n) + (n * i)) + j & i < ((2 * n) + (n * i)) + j & ((2 * n) + (n * i)) + j < ((n * n) + (3 * n)) + 1 )
Lm14:
for i, j, n being Nat st 1 <= i & i <= n & 1 <= j & j <= n holds
( (3 * n) + 1 <= ((2 * n) + (n * i)) + j & ((2 * n) + (n * i)) + j <= (n * n) + (3 * n) )
Lm15:
for n being Nat
for f, h being Element of REAL *
for G being oriented finite Graph
for W being Function of the carrier' of G,Real>=0
for v1 being Vertex of G st f is_Input_of_Dijkstra_Alg G,n,W & v1 = 1 & n >= 1 & h = ((repeat ((Relax n) * (findmin n))) . 1) . f holds
( ( for v3 being Vertex of G
for j being Nat st v3 <> v1 & v3 = j & h . (n + j) <> - 1 holds
ex p being FinSequence of NAT ex P being oriented Chain of G st
( p is_simple_vertex_seq_at h,j,n & ( for i being Nat st 1 <= i & i < len p holds
p . i in UsedVx (h,n) ) & P is_oriented_edge_seq_of p & P is_shortestpath_of v1,v3, UsedVx (h,n),W & cost (P,W) = h . ((2 * n) + j) & ( not v3 in UsedVx (h,n) implies P islongestInShortestpath UsedVx (h,n),v1,W ) ) ) & ( for m, j being Nat st h . (n + j) = - 1 & 1 <= j & j <= n & m in UsedVx (h,n) holds
f . (((2 * n) + (n * m)) + j) = - 1 ) & ( for m being Nat st m in UsedVx (h,n) holds
h . (n + m) <> - 1 ) )
Lm16:
for i, k, n being Nat
for f, g, h being Element of REAL * st g = ((repeat ((Relax n) * (findmin n))) . k) . f & h = ((repeat ((Relax n) * (findmin n))) . (k + 1)) . f & OuterVx (g,n) <> {} & i in UsedVx (g,n) & len f = ((n * n) + (3 * n)) + 1 holds
h . (n + i) = g . (n + i)
Lm17:
for j, k, n being Nat
for f, g, h being Element of REAL *
for p being FinSequence of NAT st g = ((repeat ((Relax n) * (findmin n))) . k) . f & h = ((repeat ((Relax n) * (findmin n))) . (k + 1)) . f & OuterVx (g,n) <> {} & len f = ((n * n) + (3 * n)) + 1 & p is_simple_vertex_seq_at g,j,n & g . (n + j) = h . (n + j) & ( for i being Nat st 1 <= i & i < len p holds
p . i in UsedVx (g,n) ) holds
p is_simple_vertex_seq_at h,j,n
Lm18:
for j, k, m, n being Nat
for f, g, h being Element of REAL *
for p being FinSequence of NAT st g = ((repeat ((Relax n) * (findmin n))) . k) . f & h = ((repeat ((Relax n) * (findmin n))) . (k + 1)) . f & OuterVx (g,n) <> {} & len f = ((n * n) + (3 * n)) + 1 & p is_simple_vertex_seq_at g,m,n & m = h . (n + j) & g . (n + m) = h . (n + m) & m <> j & not j in UsedVx (g,n) & ( for i being Nat st 1 <= i & i < len p holds
p . i in UsedVx (g,n) ) holds
for q being FinSequence of NAT st q = p ^ <*j*> holds
q is_simple_vertex_seq_at h,j,n
Lm19:
for i, n being Nat
for V being set
for f, g being Element of REAL *
for G being oriented finite Graph
for P being oriented Chain of G
for W being Function of the carrier' of G,Real>=0
for v1, v2 being Vertex of G st f is_Input_of_Dijkstra_Alg G,n,W & W is_weight>=0of G & v2 = i & v1 <> v2 & 1 <= i & i <= n & P is_shortestpath_of v1,v2,V,W & ( for m, j being Nat st g . (n + j) = - 1 & 1 <= j & j <= n & m in V holds
f . (((2 * n) + (n * m)) + j) = - 1 ) holds
g . (n + i) <> - 1
Lm20:
for k, n being Nat
for f, g, h being Element of REAL *
for G being oriented finite Graph
for W being Function of the carrier' of G,Real>=0
for v1 being Vertex of G st f is_Input_of_Dijkstra_Alg G,n,W & v1 = 1 & n >= 1 & g = ((repeat ((Relax n) * (findmin n))) . k) . f & h = ((repeat ((Relax n) * (findmin n))) . (k + 1)) . f & OuterVx (g,n) <> {} & 1 in UsedVx (g,n) & ( for v3 being Vertex of G
for j being Nat st v3 <> v1 & v3 = j & g . (n + j) <> - 1 holds
ex p being FinSequence of NAT ex P being oriented Chain of G st
( p is_simple_vertex_seq_at g,j,n & ( for i being Nat st 1 <= i & i < len p holds
p . i in UsedVx (g,n) ) & P is_oriented_edge_seq_of p & P is_shortestpath_of v1,v3, UsedVx (g,n),W & cost (P,W) = g . ((2 * n) + j) & ( not v3 in UsedVx (g,n) implies P islongestInShortestpath UsedVx (g,n),v1,W ) ) ) & ( for m, j being Nat st g . (n + j) = - 1 & 1 <= j & j <= n & m in UsedVx (g,n) holds
f . (((2 * n) + (n * m)) + j) = - 1 ) & ( for m being Nat st m in UsedVx (g,n) holds
g . (n + m) <> - 1 ) holds
( ( for v3 being Vertex of G
for j being Nat st v3 <> v1 & v3 = j & h . (n + j) <> - 1 holds
ex p being FinSequence of NAT ex P being oriented Chain of G st
( p is_simple_vertex_seq_at h,j,n & ( for i being Nat st 1 <= i & i < len p holds
p . i in UsedVx (h,n) ) & P is_oriented_edge_seq_of p & P is_shortestpath_of v1,v3, UsedVx (h,n),W & cost (P,W) = h . ((2 * n) + j) & ( not v3 in UsedVx (h,n) implies P islongestInShortestpath UsedVx (h,n),v1,W ) ) ) & ( for m, j being Nat st h . (n + j) = - 1 & 1 <= j & j <= n & m in UsedVx (h,n) holds
f . (((2 * n) + (n * m)) + j) = - 1 ) & ( for m being Nat st m in UsedVx (h,n) holds
h . (n + m) <> - 1 ) )
theorem
for
i,
n being
Nat for
f,
g being
Element of
REAL * for
G being
oriented finite Graph for
W being
Function of the
carrier' of
G,
Real>=0 for
v1,
v2 being
Vertex of
G st
f is_Input_of_Dijkstra_Alg G,
n,
W &
v1 = 1 & 1
<> v2 &
v2 = i &
n >= 1 &
g = (DijkstraAlgorithm n) . f holds
( the
carrier of
G = (UsedVx (g,n)) \/ (UnusedVx (g,n)) & (
v2 in UsedVx (
g,
n) implies ex
p being
FinSequence of
NAT ex
P being
oriented Chain of
G st
(
p is_simple_vertex_seq_at g,
i,
n &
P is_oriented_edge_seq_of p &
P is_shortestpath_of v1,
v2,
W &
cost (
P,
W)
= g . ((2 * n) + i) ) ) & (
v2 in UnusedVx (
g,
n) implies for
Q being
oriented Chain of
G holds not
Q is_orientedpath_of v1,
v2 ) )
:: 1 1 or -1 1 -1 if node v1 is used
:: 2 1 or -1 1 -1 if node v2 is used
:: : : : :
:: n 1 or -1 1 -1 if node vn is used
:: n+1 0 0 preceding-node of v1 toward v1
:: n+2 -1 or Node No. -1 preceding-node of v2 toward v1
:: : : : :
:: 2*n -1 or Node No. -1 preceding-node of vn toward v1
:: 2*n+1 0 0 cost from v1 to v1
:: 2*n+2 >=0 0 minimum cost from v2 to v1
:: : : : :
:: 3*n >=0 0 minimum cost from vn to v1
:: 3*n+1 weight(v1,v1) the weight of edge(v1,v1)
:: 3*n+2 weight(v1,v2) the weight of edge(v1,v2)
:: : : :
:: 4*n weight(v1,vn) the weight of edge(v1,vn)
:: : : :
:: n*n+3*n weight(vn,vn) the weight of edge(vn,vn)
:: n*n+3n+1 Node No. current node with the shortest path