:: GRAPH_5 semantic presentation

theorem Th1: :: GRAPH_5:1
for b1 being finite Function holds card (rng b1) <= card (dom b1)
proof end;

theorem Th2: :: GRAPH_5:2
for b1 being set
for b2, b3 being Function st rng b2 c= rng b3 & b1 in dom b2 holds
ex b4 being set st
( b4 in dom b3 & b2 . b1 = b3 . b4 )
proof end;

scheme :: GRAPH_5:sch 1
s1{ F1() -> set , F2() -> set , F3( Element of F2()) -> set } :
ex b1 being Function st
( dom b1 = F1() & ( for b2 being Element of F2() st b2 in F1() holds
b1 . b2 = F3(b2) ) )
proof end;

theorem Th3: :: GRAPH_5:3
for b1 being finite set
for b2 being Nat
for b3 being set st b3 = { b4 where B is Element of b1 * : ( 1 <= len b4 & len b4 <= b2 ) } holds
b3 is finite
proof end;

theorem Th4: :: GRAPH_5:4
for b1 being finite set
for b2 being Nat
for b3 being set st b3 = { b4 where B is Element of b1 * : len b4 <= b2 } holds
b3 is finite
proof end;

theorem Th5: :: GRAPH_5:5
for b1 being finite set holds
( card b1 <> 0 iff b1 <> {} )
proof end;

theorem Th6: :: GRAPH_5:6
for b1 being finite set
for b2 being Nat st card b1 = b2 + 1 holds
ex b3 being Element of b1ex b4 being Subset of b1 st
( b1 = b4 \/ {b3} & card b4 = b2 )
proof end;

theorem Th7: :: GRAPH_5:7
for b1 being finite set st card b1 = 1 holds
ex b2 being Element of b1 st b1 = {b2}
proof end;

scheme :: GRAPH_5:sch 2
s2{ F1() -> non empty finite set , F2( Element of F1()) -> Real } :
ex b1 being Element of F1() st
for b2 being Element of F1() holds F2(b1) <= F2(b2)
proof end;

definition
let c1 be set ;
let c2 be non empty Subset of (c1 * );
redefine mode Element as Element of c2 -> FinSequence of a1;
coherence
for b1 being Element of c2 holds b1 is FinSequence of c1
proof end;
end;

theorem Th8: :: GRAPH_5:8
for b1 being FinSequence holds
( b1 <> {} iff len b1 >= 1 )
proof end;

Lemma9: for b1 being Nat
for b2, b3 being FinSequence st 1 <= b1 & b1 <= len b2 holds
b2 . b1 = (b2 ^ b3) . b1
proof end;

Lemma10: for b1 being Nat
for b2, b3 being FinSequence st 1 <= b1 & b1 <= len b2 holds
b2 . b1 = (b3 ^ b2) . ((len b3) + b1)
proof end;

theorem Th9: :: GRAPH_5:9
for b1 being FinSequence holds
( ( for b2, b3 being Nat st 1 <= b2 & b2 < b3 & b3 <= len b1 holds
b1 . b2 <> b1 . b3 ) iff b1 is one-to-one )
proof end;

theorem Th10: :: GRAPH_5:10
for b1 being FinSequence holds
( ( for b2, b3 being Nat st 1 <= b2 & b2 < b3 & b3 <= len b1 holds
b1 . b2 <> b1 . b3 ) iff card (rng b1) = len b1 )
proof end;

theorem Th11: :: GRAPH_5:11
for b1 being Nat
for b2 being Graph
for b3 being FinSequence of the Edges of b2 st b1 in dom b3 holds
( the Source of b2 . (b3 . b1) in the Vertices of b2 & the Target of b2 . (b3 . b1) in the Vertices of b2 )
proof end;

theorem Th12: :: GRAPH_5:12
for b1 being set
for b2, b3 being FinSequence st b2 ^ <*b1*> is one-to-one & rng (b2 ^ <*b1*>) c= rng b3 holds
ex b4, b5 being FinSequence st
( b3 = (b4 ^ <*b1*>) ^ b5 & rng b2 c= rng (b4 ^ b5) )
proof end;

theorem Th13: :: GRAPH_5:13
for b1, b2 being FinSequence
for b3 being Graph st b1 ^ b2 is Chain of b3 holds
( b1 is Chain of b3 & b2 is Chain of b3 )
proof end;

theorem Th14: :: GRAPH_5:14
for b1, b2 being FinSequence
for b3 being Graph st b1 ^ b2 is oriented Chain of b3 holds
( b1 is oriented Chain of b3 & b2 is oriented Chain of b3 )
proof end;

theorem Th15: :: GRAPH_5:15
for b1 being Graph
for b2, b3 being oriented Chain of b1 st the Target of b1 . (b2 . (len b2)) = the Source of b1 . (b3 . 1) holds
b2 ^ b3 is oriented Chain of b1
proof end;

theorem Th16: :: GRAPH_5:16
for b1 being Graph holds {} is oriented Simple Chain of b1
proof end;

theorem Th17: :: GRAPH_5:17
for b1, b2 being FinSequence
for b3 being Graph st b1 ^ b2 is oriented Simple Chain of b3 holds
( b1 is oriented Simple Chain of b3 & b2 is oriented Simple Chain of b3 )
proof end;

theorem Th18: :: GRAPH_5:18
for b1 being Graph
for b2 being FinSequence of the Edges of b1 st len b2 = 1 holds
b2 is oriented Simple Chain of b1
proof end;

theorem Th19: :: GRAPH_5:19
for b1 being Graph
for b2 being oriented Simple Chain of b1
for b3 being FinSequence of the Edges of b1 st len b2 >= 1 & len b3 = 1 & the Source of b1 . (b3 . 1) = the Target of b1 . (b2 . (len b2)) & the Source of b1 . (b2 . 1) <> the Target of b1 . (b2 . (len b2)) & ( for b4 being Nat holds
( not 1 <= b4 or not b4 <= len b2 or not the Target of b1 . (b2 . b4) = the Target of b1 . (b3 . 1) ) ) holds
b2 ^ b3 is oriented Simple Chain of b1
proof end;

theorem Th20: :: GRAPH_5:20
for b1 being Graph
for b2 being oriented Simple Chain of b1 holds b2 is one-to-one
proof end;

definition
let c1 be Graph;
let c2 be Element of the Edges of c1;
func vertices c2 -> set equals :: GRAPH_5:def 1
{(the Source of a1 . a2),(the Target of a1 . a2)};
coherence
{(the Source of c1 . c2),(the Target of c1 . c2)} is set
;
end;

:: deftheorem Def1 defines vertices GRAPH_5:def 1 :
for b1 being Graph
for b2 being Element of the Edges of b1 holds vertices b2 = {(the Source of b1 . b2),(the Target of b1 . b2)};

definition
let c1 be Graph;
let c2 be FinSequence of the Edges of c1;
func vertices c2 -> Subset of the Vertices of a1 equals :: GRAPH_5:def 2
{ b1 where B is Vertex of a1 : ex b1 being Nat st
( b2 in dom a2 & b1 in vertices (a2 /. b2) )
}
;
coherence
{ b1 where B is Vertex of c1 : ex b1 being Nat st
( b2 in dom c2 & b1 in vertices (c2 /. b2) )
}
is Subset of the Vertices of c1
proof end;
end;

:: deftheorem Def2 defines vertices GRAPH_5:def 2 :
for b1 being Graph
for b2 being FinSequence of the Edges of b1 holds vertices b2 = { b3 where B is Vertex of b1 : ex b1 being Nat st
( b4 in dom b2 & b3 in vertices (b2 /. b4) )
}
;

theorem Th21: :: GRAPH_5:21
for b1 being Graph
for b2, b3 being FinSequence of the Edges of b1
for b4 being oriented Simple Chain of b1 st b4 = b2 ^ b3 & len b2 >= 1 & len b3 >= 1 & the Source of b1 . (b4 . 1) <> the Target of b1 . (b4 . (len b4)) holds
( not the Source of b1 . (b4 . 1) in vertices b3 & not the Target of b1 . (b4 . (len b4)) in vertices b2 )
proof end;

theorem Th22: :: GRAPH_5:22
for b1 being set
for b2 being Graph
for b3 being FinSequence of the Edges of b2 holds
( vertices b3 c= b1 iff for b4 being Nat st b4 in dom b3 holds
vertices (b3 /. b4) c= b1 )
proof end;

theorem Th23: :: GRAPH_5:23
for b1 being set
for b2 being Graph
for b3 being FinSequence of the Edges of b2 st not vertices b3 c= b1 holds
ex b4 being Natex b5, b6 being FinSequence of the Edges of b2 st
( b4 + 1 <= len b3 & not vertices (b3 /. (b4 + 1)) c= b1 & len b5 = b4 & b3 = b5 ^ b6 & vertices b5 c= b1 )
proof end;

theorem Th24: :: GRAPH_5:24
for b1 being Graph
for b2, b3 being FinSequence of the Edges of b1 st rng b2 c= rng b3 holds
vertices b2 c= vertices b3
proof end;

theorem Th25: :: GRAPH_5:25
for b1, b2 being set
for b3 being Graph
for b4, b5 being FinSequence of the Edges of b3 st rng b4 c= rng b5 & (vertices b5) \ b1 c= b2 holds
(vertices b4) \ b1 c= b2
proof end;

theorem Th26: :: GRAPH_5:26
for b1, b2 being set
for b3 being Graph
for b4, b5 being FinSequence of the Edges of b3 st (vertices (b4 ^ b5)) \ b1 c= b2 holds
( (vertices b4) \ b1 c= b2 & (vertices b5) \ b1 c= b2 )
proof end;

theorem Th27: :: GRAPH_5:27
for b1 being Graph
for b2 being Element of the Vertices of b1
for b3 being Element of the Edges of b1 st ( b2 = the Source of b1 . b3 or b2 = the Target of b1 . b3 ) holds
b2 in vertices b3 by TARSKI:def 2;

theorem Th28: :: GRAPH_5:28
for b1 being Nat
for b2 being Graph
for b3 being FinSequence of the Edges of b2
for b4 being Element of the Vertices of b2 st b1 in dom b3 & ( b4 = the Source of b2 . (b3 . b1) or b4 = the Target of b2 . (b3 . b1) ) holds
b4 in vertices b3
proof end;

theorem Th29: :: GRAPH_5:29
for b1 being Graph
for b2 being FinSequence of the Edges of b1 st len b2 = 1 holds
vertices b2 = vertices (b2 /. 1)
proof end;

theorem Th30: :: GRAPH_5:30
for b1 being Graph
for b2, b3 being FinSequence of the Edges of b1 holds
( vertices b2 c= vertices (b2 ^ b3) & vertices b3 c= vertices (b2 ^ b3) )
proof end;

theorem Th31: :: GRAPH_5:31
for b1 being Graph
for b2 being FinSequence of the Edges of b1
for b3, b4 being oriented Chain of b1 st b3 = b4 ^ b2 & len b4 >= 1 & len b2 = 1 holds
vertices b3 = (vertices b4) \/ {(the Target of b1 . (b2 . 1))}
proof end;

theorem Th32: :: GRAPH_5:32
for b1 being Graph
for b2 being Element of the Vertices of b1
for b3 being oriented Chain of b1 st b2 <> the Source of b1 . (b3 . 1) & b2 in vertices b3 holds
ex b4 being Nat st
( 1 <= b4 & b4 <= len b3 & b2 = the Target of b1 . (b3 . b4) )
proof end;

definition
let c1 be Graph;
let c2 be oriented Chain of c1;
let c3, c4 be Element of the Vertices of c1;
pred c2 is_orientedpath_of c3,c4 means :Def3: :: GRAPH_5:def 3
( a2 <> {} & the Source of a1 . (a2 . 1) = a3 & the Target of a1 . (a2 . (len a2)) = a4 );
end;

:: deftheorem Def3 defines is_orientedpath_of GRAPH_5:def 3 :
for b1 being Graph
for b2 being oriented Chain of b1
for b3, b4 being Element of the Vertices of b1 holds
( b2 is_orientedpath_of b3,b4 iff ( b2 <> {} & the Source of b1 . (b2 . 1) = b3 & the Target of b1 . (b2 . (len b2)) = b4 ) );

definition
let c1 be Graph;
let c2, c3 be Element of the Vertices of c1;
let c4 be oriented Chain of c1;
let c5 be set ;
pred c4 is_orientedpath_of c2,c3,c5 means :Def4: :: GRAPH_5:def 4
( a4 is_orientedpath_of a2,a3 & (vertices a4) \ {a3} c= a5 );
end;

:: deftheorem Def4 defines is_orientedpath_of GRAPH_5:def 4 :
for b1 being Graph
for b2, b3 being Element of the Vertices of b1
for b4 being oriented Chain of b1
for b5 being set holds
( b4 is_orientedpath_of b2,b3,b5 iff ( b4 is_orientedpath_of b2,b3 & (vertices b4) \ {b3} c= b5 ) );

definition
let c1 be Graph;
let c2, c3 be Element of the Vertices of c1;
func OrientedPaths c2,c3 -> Subset of (the Edges of a1 * ) equals :: GRAPH_5:def 5
{ b1 where B is oriented Chain of a1 : b1 is_orientedpath_of a2,a3 } ;
coherence
{ b1 where B is oriented Chain of c1 : b1 is_orientedpath_of c2,c3 } is Subset of (the Edges of c1 * )
proof end;
end;

:: deftheorem Def5 defines OrientedPaths GRAPH_5:def 5 :
for b1 being Graph
for b2, b3 being Element of the Vertices of b1 holds OrientedPaths b2,b3 = { b4 where B is oriented Chain of b1 : b4 is_orientedpath_of b2,b3 } ;

theorem Th33: :: GRAPH_5:33
for b1 being Graph
for b2, b3 being Element of the Vertices of b1
for b4 being oriented Chain of b1 st b4 is_orientedpath_of b2,b3 holds
( b2 in vertices b4 & b3 in vertices b4 )
proof end;

theorem Th34: :: GRAPH_5:34
for b1 being set
for b2 being Graph
for b3, b4 being Element of the Vertices of b2 holds
( b1 in OrientedPaths b3,b4 iff ex b5 being oriented Chain of b2 st
( b5 = b1 & b5 is_orientedpath_of b3,b4 ) ) ;

theorem Th35: :: GRAPH_5:35
for b1 being set
for b2 being Graph
for b3, b4 being Element of the Vertices of b2
for b5 being oriented Chain of b2 st b5 is_orientedpath_of b3,b4,b1 & b3 <> b4 holds
b3 in b1
proof end;

theorem Th36: :: GRAPH_5:36
for b1, b2 being set
for b3 being Graph
for b4, b5 being Element of the Vertices of b3
for b6 being oriented Chain of b3 st b6 is_orientedpath_of b4,b5,b1 & b1 c= b2 holds
b6 is_orientedpath_of b4,b5,b2
proof end;

theorem Th37: :: GRAPH_5:37
for b1 being Graph
for b2 being FinSequence of the Edges of b1
for b3, b4, b5 being Element of the Vertices of b1
for b6 being oriented Chain of b1 st len b6 >= 1 & b6 is_orientedpath_of b3,b4 & b2 . 1 orientedly_joins b4,b5 & len b2 = 1 holds
ex b7 being oriented Chain of b1 st
( b7 = b6 ^ b2 & b7 is_orientedpath_of b3,b5 )
proof end;

theorem Th38: :: GRAPH_5:38
for b1 being set
for b2 being Graph
for b3 being FinSequence of the Edges of b2
for b4, b5, b6 being Element of the Vertices of b2
for b7, b8 being oriented Chain of b2 st b7 = b8 ^ b3 & len b8 >= 1 & len b3 = 1 & b8 is_orientedpath_of b4,b5,b1 & b3 . 1 orientedly_joins b5,b6 holds
b7 is_orientedpath_of b4,b6,b1 \/ {b5}
proof end;

definition
let c1 be Graph;
let c2 be oriented Chain of c1;
let c3, c4 be Element of the Vertices of c1;
pred c2 is_acyclicpath_of c3,c4 means :Def6: :: GRAPH_5:def 6
( a2 is Simple & a2 is_orientedpath_of a3,a4 );
end;

:: deftheorem Def6 defines is_acyclicpath_of GRAPH_5:def 6 :
for b1 being Graph
for b2 being oriented Chain of b1
for b3, b4 being Element of the Vertices of b1 holds
( b2 is_acyclicpath_of b3,b4 iff ( b2 is Simple & b2 is_orientedpath_of b3,b4 ) );

definition
let c1 be Graph;
let c2 be oriented Chain of c1;
let c3, c4 be Element of the Vertices of c1;
let c5 be set ;
pred c2 is_acyclicpath_of c3,c4,c5 means :Def7: :: GRAPH_5:def 7
( a2 is Simple & a2 is_orientedpath_of a3,a4,a5 );
end;

:: deftheorem Def7 defines is_acyclicpath_of GRAPH_5:def 7 :
for b1 being Graph
for b2 being oriented Chain of b1
for b3, b4 being Element of the Vertices of b1
for b5 being set holds
( b2 is_acyclicpath_of b3,b4,b5 iff ( b2 is Simple & b2 is_orientedpath_of b3,b4,b5 ) );

definition
let c1 be Graph;
let c2, c3 be Element of the Vertices of c1;
func AcyclicPaths c2,c3 -> Subset of (the Edges of a1 * ) equals :: GRAPH_5:def 8
{ b1 where B is oriented Simple Chain of a1 : b1 is_acyclicpath_of a2,a3 } ;
coherence
{ b1 where B is oriented Simple Chain of c1 : b1 is_acyclicpath_of c2,c3 } is Subset of (the Edges of c1 * )
proof end;
end;

:: deftheorem Def8 defines AcyclicPaths GRAPH_5:def 8 :
for b1 being Graph
for b2, b3 being Element of the Vertices of b1 holds AcyclicPaths b2,b3 = { b4 where B is oriented Simple Chain of b1 : b4 is_acyclicpath_of b2,b3 } ;

definition
let c1 be Graph;
let c2, c3 be Element of the Vertices of c1;
let c4 be set ;
func AcyclicPaths c2,c3,c4 -> Subset of (the Edges of a1 * ) equals :: GRAPH_5:def 9
{ b1 where B is oriented Simple Chain of a1 : b1 is_acyclicpath_of a2,a3,a4 } ;
coherence
{ b1 where B is oriented Simple Chain of c1 : b1 is_acyclicpath_of c2,c3,c4 } is Subset of (the Edges of c1 * )
proof end;
end;

:: deftheorem Def9 defines AcyclicPaths GRAPH_5:def 9 :
for b1 being Graph
for b2, b3 being Element of the Vertices of b1
for b4 being set holds AcyclicPaths b2,b3,b4 = { b5 where B is oriented Simple Chain of b1 : b5 is_acyclicpath_of b2,b3,b4 } ;

definition
let c1 be Graph;
let c2 be oriented Chain of c1;
func AcyclicPaths c2 -> Subset of (the Edges of a1 * ) equals :: GRAPH_5:def 10
{ b1 where B is oriented Simple Chain of a1 : ( b1 <> {} & the Source of a1 . (b1 . 1) = the Source of a1 . (a2 . 1) & the Target of a1 . (b1 . (len b1)) = the Target of a1 . (a2 . (len a2)) & rng b1 c= rng a2 ) } ;
coherence
{ b1 where B is oriented Simple Chain of c1 : ( b1 <> {} & the Source of c1 . (b1 . 1) = the Source of c1 . (c2 . 1) & the Target of c1 . (b1 . (len b1)) = the Target of c1 . (c2 . (len c2)) & rng b1 c= rng c2 ) } is Subset of (the Edges of c1 * )
proof end;
end;

:: deftheorem Def10 defines AcyclicPaths GRAPH_5:def 10 :
for b1 being Graph
for b2 being oriented Chain of b1 holds AcyclicPaths b2 = { b3 where B is oriented Simple Chain of b1 : ( b3 <> {} & the Source of b1 . (b3 . 1) = the Source of b1 . (b2 . 1) & the Target of b1 . (b3 . (len b3)) = the Target of b1 . (b2 . (len b2)) & rng b3 c= rng b2 ) } ;

definition
let c1 be Graph;
func AcyclicPaths c1 -> Subset of (the Edges of a1 * ) equals :: GRAPH_5:def 11
{ b1 where B is oriented Simple Chain of a1 : verum } ;
coherence
{ b1 where B is oriented Simple Chain of c1 : verum } is Subset of (the Edges of c1 * )
proof end;
end;

:: deftheorem Def11 defines AcyclicPaths GRAPH_5:def 11 :
for b1 being Graph holds AcyclicPaths b1 = { b2 where B is oriented Simple Chain of b1 : verum } ;

theorem Th39: :: GRAPH_5:39
for b1 being Graph
for b2, b3 being Element of the Vertices of b1
for b4 being oriented Chain of b1 st b4 = {} holds
not b4 is_acyclicpath_of b2,b3
proof end;

theorem Th40: :: GRAPH_5:40
for b1 being Graph
for b2, b3 being Element of the Vertices of b1
for b4 being oriented Chain of b1 st b4 is_acyclicpath_of b2,b3 holds
b4 is_orientedpath_of b2,b3 by Def6;

theorem Th41: :: GRAPH_5:41
for b1 being Graph
for b2, b3 being Element of the Vertices of b1 holds AcyclicPaths b2,b3 c= OrientedPaths b2,b3
proof end;

theorem Th42: :: GRAPH_5:42
for b1 being Graph
for b2 being oriented Chain of b1 holds AcyclicPaths b2 c= AcyclicPaths b1
proof end;

theorem Th43: :: GRAPH_5:43
for b1 being Graph
for b2, b3 being Element of the Vertices of b1 holds AcyclicPaths b2,b3 c= AcyclicPaths b1
proof end;

theorem Th44: :: GRAPH_5:44
for b1 being Graph
for b2, b3 being Element of the Vertices of b1
for b4 being oriented Chain of b1 st b4 is_orientedpath_of b2,b3 holds
AcyclicPaths b4 c= AcyclicPaths b2,b3
proof end;

theorem Th45: :: GRAPH_5:45
for b1 being set
for b2 being Graph
for b3, b4 being Element of the Vertices of b2
for b5 being oriented Chain of b2 st b5 is_orientedpath_of b3,b4,b1 holds
AcyclicPaths b5 c= AcyclicPaths b3,b4,b1
proof end;

theorem Th46: :: GRAPH_5:46
for b1 being Graph
for b2, b3 being oriented Chain of b1 st b2 in AcyclicPaths b3 holds
len b2 <= len b3
proof end;

theorem Th47: :: GRAPH_5:47
for b1 being Graph
for b2, b3 being Element of the Vertices of b1
for b4 being oriented Chain of b1 st b4 is_orientedpath_of b2,b3 holds
( AcyclicPaths b4 <> {} & AcyclicPaths b2,b3 <> {} )
proof end;

theorem Th48: :: GRAPH_5:48
for b1 being set
for b2 being Graph
for b3, b4 being Element of the Vertices of b2
for b5 being oriented Chain of b2 st b5 is_orientedpath_of b3,b4,b1 holds
( AcyclicPaths b5 <> {} & AcyclicPaths b3,b4,b1 <> {} )
proof end;

theorem Th49: :: GRAPH_5:49
for b1 being set
for b2 being Graph
for b3, b4 being Element of the Vertices of b2 holds AcyclicPaths b3,b4,b1 c= AcyclicPaths b2
proof end;

definition
func Real>=0 -> Subset of REAL equals :: GRAPH_5:def 12
{ b1 where B is Real : b1 >= 0 } ;
coherence
{ b1 where B is Real : b1 >= 0 } is Subset of REAL
proof end;
end;

:: deftheorem Def12 defines Real>=0 GRAPH_5:def 12 :
Real>=0 = { b1 where B is Real : b1 >= 0 } ;

registration
cluster Real>=0 -> non empty ;
coherence
not Real>=0 is empty
proof end;
end;

definition
let c1 be Graph;
let c2 be Function;
pred c2 is_weight>=0of c1 means :Def13: :: GRAPH_5:def 13
a2 is Function of the Edges of a1, Real>=0 ;
end;

:: deftheorem Def13 defines is_weight>=0of GRAPH_5:def 13 :
for b1 being Graph
for b2 being Function holds
( b2 is_weight>=0of b1 iff b2 is Function of the Edges of b1, Real>=0 );

definition
let c1 be Graph;
let c2 be Function;
pred c2 is_weight_of c1 means :Def14: :: GRAPH_5:def 14
a2 is Function of the Edges of a1, REAL ;
end;

:: deftheorem Def14 defines is_weight_of GRAPH_5:def 14 :
for b1 being Graph
for b2 being Function holds
( b2 is_weight_of b1 iff b2 is Function of the Edges of b1, REAL );

definition
let c1 be Graph;
let c2 be FinSequence of the Edges of c1;
let c3 be Function;
assume E53: c3 is_weight_of c1 ;
func RealSequence c2,c3 -> FinSequence of REAL means :Def15: :: GRAPH_5:def 15
( dom a2 = dom a4 & ( for b1 being Nat st b1 in dom a2 holds
a4 . b1 = a3 . (a2 . b1) ) );
existence
ex b1 being FinSequence of REAL st
( dom c2 = dom b1 & ( for b2 being Nat st b2 in dom c2 holds
b1 . b2 = c3 . (c2 . b2) ) )
proof end;
uniqueness
for b1, b2 being FinSequence of REAL st dom c2 = dom b1 & ( for b3 being Nat st b3 in dom c2 holds
b1 . b3 = c3 . (c2 . b3) ) & dom c2 = dom b2 & ( for b3 being Nat st b3 in dom c2 holds
b2 . b3 = c3 . (c2 . b3) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def15 defines RealSequence GRAPH_5:def 15 :
for b1 being Graph
for b2 being FinSequence of the Edges of b1
for b3 being Function st b3 is_weight_of b1 holds
for b4 being FinSequence of REAL holds
( b4 = RealSequence b2,b3 iff ( dom b2 = dom b4 & ( for b5 being Nat st b5 in dom b2 holds
b4 . b5 = b3 . (b2 . b5) ) ) );

definition
let c1 be Graph;
let c2 be FinSequence of the Edges of c1;
let c3 be Function;
func cost c2,c3 -> Real equals :: GRAPH_5:def 16
Sum (RealSequence a2,a3);
coherence
Sum (RealSequence c2,c3) is Real
;
end;

:: deftheorem Def16 defines cost GRAPH_5:def 16 :
for b1 being Graph
for b2 being FinSequence of the Edges of b1
for b3 being Function holds cost b2,b3 = Sum (RealSequence b2,b3);

theorem Th50: :: GRAPH_5:50
for b1 being Function
for b2 being Graph st b1 is_weight>=0of b2 holds
b1 is_weight_of b2
proof end;

theorem Th51: :: GRAPH_5:51
for b1 being Function
for b2 being Graph
for b3 being FinSequence of the Edges of b2
for b4 being FinSequence of REAL st b1 is_weight>=0of b2 & b4 = RealSequence b3,b1 holds
for b5 being Nat st b5 in dom b4 holds
b4 . b5 >= 0
proof end;

theorem Th52: :: GRAPH_5:52
for b1 being Nat
for b2 being Function
for b3 being Graph
for b4, b5 being FinSequence of the Edges of b3 st rng b4 c= rng b5 & b2 is_weight_of b3 & b1 in dom b4 holds
ex b6 being Nat st
( b6 in dom b5 & (RealSequence b5,b2) . b6 = (RealSequence b4,b2) . b1 )
proof end;

Lemma57: for b1 being FinSequence of REAL holds
( ( for b2 being Real st b2 in rng b1 holds
b2 >= 0 ) iff for b2 being Nat st b2 in dom b1 holds
b1 . b2 >= 0 )
proof end;

Lemma58: for b1, b2, b3 being FinSequence of REAL st b3 = b1 ^ b2 & ( for b4 being Real st b4 in rng b3 holds
b4 >= 0 ) holds
( ( for b4 being Nat st b4 in dom b1 holds
b1 . b4 >= 0 ) & ( for b4 being Nat st b4 in dom b2 holds
b2 . b4 >= 0 ) )
proof end;

theorem Th53: :: GRAPH_5:53
for b1 being Function
for b2 being Graph
for b3, b4 being FinSequence of the Edges of b2 st len b3 = 1 & rng b3 c= rng b4 & b1 is_weight>=0of b2 holds
cost b3,b1 <= cost b4,b1
proof end;

theorem Th54: :: GRAPH_5:54
for b1 being Function
for b2 being Graph
for b3 being FinSequence of the Edges of b2 st b1 is_weight>=0of b2 holds
cost b3,b1 >= 0
proof end;

theorem Th55: :: GRAPH_5:55
for b1 being Function
for b2 being Graph
for b3 being FinSequence of the Edges of b2 st b3 = {} & b1 is_weight_of b2 holds
cost b3,b1 = 0
proof end;

theorem Th56: :: GRAPH_5:56
for b1 being Function
for b2 being Graph
for b3, b4 being Element of the Vertices of b2
for b5 being non empty finite Subset of (the Edges of b2 * ) st b5 = AcyclicPaths b3,b4 holds
ex b6 being FinSequence of the Edges of b2 st
( b6 in b5 & ( for b7 being FinSequence of the Edges of b2 st b7 in b5 holds
cost b6,b1 <= cost b7,b1 ) )
proof end;

theorem Th57: :: GRAPH_5:57
for b1 being set
for b2 being Function
for b3 being Graph
for b4, b5 being Element of the Vertices of b3
for b6 being non empty finite Subset of (the Edges of b3 * ) st b6 = AcyclicPaths b4,b5,b1 holds
ex b7 being FinSequence of the Edges of b3 st
( b7 in b6 & ( for b8 being FinSequence of the Edges of b3 st b8 in b6 holds
cost b7,b2 <= cost b8,b2 ) )
proof end;

theorem Th58: :: GRAPH_5:58
for b1 being Function
for b2 being Graph
for b3, b4 being FinSequence of the Edges of b2 st b1 is_weight_of b2 holds
cost (b3 ^ b4),b1 = (cost b3,b1) + (cost b4,b1)
proof end;

theorem Th59: :: GRAPH_5:59
for b1 being Function
for b2 being Graph
for b3, b4 being FinSequence of the Edges of b2 st b3 is one-to-one & rng b3 c= rng b4 & b1 is_weight>=0of b2 holds
cost b3,b1 <= cost b4,b1
proof end;

theorem Th60: :: GRAPH_5:60
for b1 being Function
for b2 being Graph
for b3 being FinSequence of the Edges of b2
for b4 being oriented Chain of b2 st b3 in AcyclicPaths b4 & b1 is_weight>=0of b2 holds
cost b3,b1 <= cost b4,b1
proof end;

definition
let c1 be Graph;
let c2, c3 be Vertex of c1;
let c4 be oriented Chain of c1;
let c5 be Function;
pred c4 is_shortestpath_of c2,c3,c5 means :Def17: :: GRAPH_5:def 17
( a4 is_orientedpath_of a2,a3 & ( for b1 being oriented Chain of a1 st b1 is_orientedpath_of a2,a3 holds
cost a4,a5 <= cost b1,a5 ) );
end;

:: deftheorem Def17 defines is_shortestpath_of GRAPH_5:def 17 :
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being oriented Chain of b1
for b5 being Function holds
( b4 is_shortestpath_of b2,b3,b5 iff ( b4 is_orientedpath_of b2,b3 & ( for b6 being oriented Chain of b1 st b6 is_orientedpath_of b2,b3 holds
cost b4,b5 <= cost b6,b5 ) ) );

definition
let c1 be Graph;
let c2, c3 be Vertex of c1;
let c4 be oriented Chain of c1;
let c5 be set ;
let c6 be Function;
pred c4 is_shortestpath_of c2,c3,c5,c6 means :Def18: :: GRAPH_5:def 18
( a4 is_orientedpath_of a2,a3,a5 & ( for b1 being oriented Chain of a1 st b1 is_orientedpath_of a2,a3,a5 holds
cost a4,a6 <= cost b1,a6 ) );
end;

:: deftheorem Def18 defines is_shortestpath_of GRAPH_5:def 18 :
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being oriented Chain of b1
for b5 being set
for b6 being Function holds
( b4 is_shortestpath_of b2,b3,b5,b6 iff ( b4 is_orientedpath_of b2,b3,b5 & ( for b7 being oriented Chain of b1 st b7 is_orientedpath_of b2,b3,b5 holds
cost b4,b6 <= cost b7,b6 ) ) );

theorem Th61: :: GRAPH_5:61
for b1 being finite Graph
for b2 being oriented Simple Chain of b1 holds len b2 <= VerticesCount b1
proof end;

theorem Th62: :: GRAPH_5:62
for b1 being finite Graph
for b2 being oriented Simple Chain of b1 holds len b2 <= EdgesCount b1
proof end;

Lemma69: for b1 being finite Graph holds AcyclicPaths b1 is finite
proof end;

registration
let c1 be finite Graph;
cluster AcyclicPaths a1 -> finite ;
coherence
AcyclicPaths c1 is finite
by Lemma69;
end;

Lemma70: for b1 being finite Graph
for b2 being oriented Chain of b1 holds AcyclicPaths b2 is finite
proof end;

Lemma71: for b1 being finite Graph
for b2, b3 being Element of the Vertices of b1 holds AcyclicPaths b2,b3 is finite
proof end;

Lemma72: for b1 being set
for b2 being finite Graph
for b3, b4 being Element of the Vertices of b2 holds AcyclicPaths b3,b4,b1 is finite
proof end;

registration
let c1 be finite Graph;
let c2 be oriented Chain of c1;
cluster AcyclicPaths a2 -> finite ;
coherence
AcyclicPaths c2 is finite
by Lemma70;
end;

registration
let c1 be finite Graph;
let c2, c3 be Element of the Vertices of c1;
cluster AcyclicPaths a2,a3 -> finite ;
coherence
AcyclicPaths c2,c3 is finite
by Lemma71;
end;

registration
let c1 be finite Graph;
let c2, c3 be Element of the Vertices of c1;
let c4 be set ;
cluster AcyclicPaths a2,a3,a4 -> finite ;
coherence
AcyclicPaths c2,c3,c4 is finite
by Lemma72;
end;

theorem Th63: :: GRAPH_5:63
for b1 being Function
for b2 being finite Graph
for b3, b4 being Element of the Vertices of b2 st AcyclicPaths b3,b4 <> {} holds
ex b5 being FinSequence of the Edges of b2 st
( b5 in AcyclicPaths b3,b4 & ( for b6 being FinSequence of the Edges of b2 st b6 in AcyclicPaths b3,b4 holds
cost b5,b1 <= cost b6,b1 ) ) by Th56;

theorem Th64: :: GRAPH_5:64
for b1 being set
for b2 being Function
for b3 being finite Graph
for b4, b5 being Element of the Vertices of b3 st AcyclicPaths b4,b5,b1 <> {} holds
ex b6 being FinSequence of the Edges of b3 st
( b6 in AcyclicPaths b4,b5,b1 & ( for b7 being FinSequence of the Edges of b3 st b7 in AcyclicPaths b4,b5,b1 holds
cost b6,b2 <= cost b7,b2 ) ) by Th57;

theorem Th65: :: GRAPH_5:65
for b1 being Function
for b2 being finite Graph
for b3 being oriented Chain of b2
for b4, b5 being Element of the Vertices of b2 st b3 is_orientedpath_of b4,b5 & b1 is_weight>=0of b2 holds
ex b6 being oriented Simple Chain of b2 st b6 is_shortestpath_of b4,b5,b1
proof end;

theorem Th66: :: GRAPH_5:66
for b1 being set
for b2 being Function
for b3 being finite Graph
for b4 being oriented Chain of b3
for b5, b6 being Element of the Vertices of b3 st b4 is_orientedpath_of b5,b6,b1 & b2 is_weight>=0of b3 holds
ex b7 being oriented Simple Chain of b3 st b7 is_shortestpath_of b5,b6,b1,b2
proof end;

theorem Th67: :: GRAPH_5:67
for b1 being set
for b2 being Function
for b3 being finite Graph
for b4 being oriented Chain of b3
for b5, b6 being Element of the Vertices of b3 st b2 is_weight>=0of b3 & b4 is_shortestpath_of b5,b6,b1,b2 & b5 <> b6 & ( for b7 being oriented Chain of b3
for b8 being Element of the Vertices of b3 st not b8 in b1 & b7 is_shortestpath_of b5,b8,b1,b2 holds
cost b4,b2 <= cost b7,b2 ) holds
b4 is_shortestpath_of b5,b6,b2
proof end;

theorem Th68: :: GRAPH_5:68
for b1, b2 being set
for b3 being Function
for b4 being finite Graph
for b5 being oriented Chain of b4
for b6, b7 being Element of the Vertices of b4 st b3 is_weight>=0of b4 & b5 is_shortestpath_of b6,b7,b1,b3 & b6 <> b7 & b1 c= b2 & ( for b8 being oriented Chain of b4
for b9 being Element of the Vertices of b4 st not b9 in b1 & b8 is_shortestpath_of b6,b9,b1,b3 holds
cost b5,b3 <= cost b8,b3 ) holds
b5 is_shortestpath_of b6,b7,b2,b3
proof end;

definition
let c1 be Graph;
let c2 be FinSequence of the Edges of c1;
let c3 be set ;
let c4 be Vertex of c1;
let c5 be Function;
pred c2 islongestInShortestpath c3,c4,c5 means :Def19: :: GRAPH_5:def 19
for b1 being Vertex of a1 st b1 in a3 & b1 <> a4 holds
ex b2 being oriented Chain of a1 st
( b2 is_shortestpath_of a4,b1,a3,a5 & cost b2,a5 <= cost a2,a5 );
end;

:: deftheorem Def19 defines islongestInShortestpath GRAPH_5:def 19 :
for b1 being Graph
for b2 being FinSequence of the Edges of b1
for b3 being set
for b4 being Vertex of b1
for b5 being Function holds
( b2 islongestInShortestpath b3,b4,b5 iff for b6 being Vertex of b1 st b6 in b3 & b6 <> b4 holds
ex b7 being oriented Chain of b1 st
( b7 is_shortestpath_of b4,b6,b3,b5 & cost b7,b5 <= cost b2,b5 ) );

theorem Th69: :: GRAPH_5:69
for b1, b2 being set
for b3 being Function
for b4 being oriented finite Graph
for b5, b6, b7 being oriented Chain of b4
for b8, b9, b10 being Element of the Vertices of b4 st b1 in the Edges of b4 & b3 is_weight>=0of b4 & len b5 >= 1 & b5 is_shortestpath_of b8,b9,b2,b3 & b8 <> b9 & b8 <> b10 & b7 = b5 ^ <*b1*> & b6 is_shortestpath_of b8,b10,b2,b3 & b1 orientedly_joins b9,b10 & b5 islongestInShortestpath b2,b8,b3 holds
( ( cost b6,b3 <= cost b7,b3 implies b6 is_shortestpath_of b8,b10,b2 \/ {b9},b3 ) & ( cost b6,b3 >= cost b7,b3 implies b7 is_shortestpath_of b8,b10,b2 \/ {b9},b3 ) )
proof end;