:: GRAPH_3 semantic presentation

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

registration
let c1, c2 be even Integer;
cluster a1 - a2 -> even ;
coherence
c1 - c2 is even
proof end;
end;

theorem Th1: :: GRAPH_3:1
for b1, b2 being Integer holds
( ( b1 is even iff b2 is even ) iff b1 - b2 is even )
proof end;

theorem Th2: :: GRAPH_3:2
for b1 being FinSequence
for b2, b3, b4 being Nat st b4 in dom (b2,b3 -cut b1) holds
ex b5 being Nat st
( b5 in dom b1 & b1 . b5 = (b2,b3 -cut b1) . b4 & b5 + 1 = b2 + b4 & b2 <= b5 & b5 <= b3 )
proof end;

definition
let c1 be Graph;
mode Vertex of a1 is Element of the Vertices of a1;
end;

theorem Th3: :: GRAPH_3:3
for b1 being Graph
for b2 being Chain of b1
for b3 being FinSequence of the Vertices of b1 st b3 is_vertex_seq_of b2 holds
not b3 is empty
proof end;

Lemma4: for b1 being Graph
for b2 being Path of b1
for b3, b4 being Nat st 1 <= b3 & b3 <= len b2 & 1 <= b4 & b4 <= len b2 & b3 <> b4 holds
b2 . b3 <> b2 . b4
proof end;

theorem Th4: :: GRAPH_3:4
canceled;

theorem Th5: :: GRAPH_3:5
canceled;

theorem Th6: :: GRAPH_3:6
canceled;

theorem Th7: :: GRAPH_3:7
for b1 being Graph
for b2 being set st b2 in the Edges of b1 holds
<*b2*> is Path of b1
proof end;

theorem Th8: :: GRAPH_3:8
for b1 being Graph
for b2 being Path of b1
for b3, b4 being Nat holds b3,b4 -cut b2 is Path of b1
proof end;

theorem Th9: :: GRAPH_3:9
for b1 being Graph
for b2, b3 being Path of b1
for b4, b5 being FinSequence of the Vertices of b1 st rng b2 misses rng b3 & b4 is_vertex_seq_of b2 & b5 is_vertex_seq_of b3 & b4 . (len b4) = b5 . 1 holds
b2 ^ b3 is Path of b1
proof end;

theorem Th10: :: GRAPH_3:10
canceled;

theorem Th11: :: GRAPH_3:11
canceled;

theorem Th12: :: GRAPH_3:12
for b1 being Graph
for b2 being Chain of b1 st b2 = {} holds
b2 is cyclic
proof end;

registration
let c1 be Graph;
cluster cyclic Chain of a1;
existence
ex b1 being Path of c1 st b1 is cyclic
proof end;
end;

theorem Th13: :: GRAPH_3:13
for b1 being Graph
for b2 being Nat
for b3 being cyclic Path of b1 holds ((b2 + 1),(len b3) -cut b3) ^ (1,b2 -cut b3) is cyclic Path of b1
proof end;

theorem Th14: :: GRAPH_3:14
for b1 being Graph
for b2 being Path of b1
for b3 being Nat st b3 + 1 in dom b2 holds
( len (((b3 + 1),(len b2) -cut b2) ^ (1,b3 -cut b2)) = len b2 & rng (((b3 + 1),(len b2) -cut b2) ^ (1,b3 -cut b2)) = rng b2 & (((b3 + 1),(len b2) -cut b2) ^ (1,b3 -cut b2)) . 1 = b2 . (b3 + 1) )
proof end;

theorem Th15: :: GRAPH_3:15
for b1 being Graph
for b2 being Nat
for b3 being cyclic Path of b1 st b2 in dom b3 holds
ex b4 being cyclic Path of b1 st
( b4 . 1 = b3 . b2 & len b4 = len b3 & rng b4 = rng b3 )
proof end;

theorem Th16: :: GRAPH_3:16
for b1 being Graph
for b2 being set
for b3, b4 being Vertex of b1 st b3 = the Source of b1 . b2 & b4 = the Target of b1 . b2 holds
<*b4,b3*> is_vertex_seq_of <*b2*>
proof end;

theorem Th17: :: GRAPH_3:17
for b1 being Graph
for b2 being Chain of b1
for b3 being FinSequence of the Vertices of b1
for b4 being set st b4 in the Edges of b1 & b3 is_vertex_seq_of b2 & b3 . (len b3) = the Source of b1 . b4 holds
( b2 ^ <*b4*> is Chain of b1 & ex b5 being FinSequence of the Vertices of b1 st
( b5 = b3 ^' <*(the Source of b1 . b4),(the Target of b1 . b4)*> & b5 is_vertex_seq_of b2 ^ <*b4*> & b5 . 1 = b3 . 1 & b5 . (len b5) = the Target of b1 . b4 ) )
proof end;

theorem Th18: :: GRAPH_3:18
for b1 being Graph
for b2 being Chain of b1
for b3 being FinSequence of the Vertices of b1
for b4 being set st b4 in the Edges of b1 & b3 is_vertex_seq_of b2 & b3 . (len b3) = the Target of b1 . b4 holds
( b2 ^ <*b4*> is Chain of b1 & ex b5 being FinSequence of the Vertices of b1 st
( b5 = b3 ^' <*(the Target of b1 . b4),(the Source of b1 . b4)*> & b5 is_vertex_seq_of b2 ^ <*b4*> & b5 . 1 = b3 . 1 & b5 . (len b5) = the Source of b1 . b4 ) )
proof end;

Lemma15: for b1 being Graph
for b2 being Chain of b1
for b3 being FinSequence of the Vertices of b1 st b3 is_vertex_seq_of b2 holds
for b4 being Nat st 1 <= b4 & b4 <= len b2 holds
( 1 <= b4 & b4 <= len b3 & 1 <= b4 + 1 & b4 + 1 <= len b3 & ( ( b3 . b4 = the Target of b1 . (b2 . b4) & b3 . (b4 + 1) = the Source of b1 . (b2 . b4) ) or ( b3 . b4 = the Source of b1 . (b2 . b4) & b3 . (b4 + 1) = the Target of b1 . (b2 . b4) ) ) )
proof end;

theorem Th19: :: GRAPH_3:19
for b1 being Graph
for b2 being Chain of b1
for b3 being FinSequence of the Vertices of b1 st b3 is_vertex_seq_of b2 holds
for b4 being Nat holds
( not b4 in dom b2 or ( b3 . b4 = the Target of b1 . (b2 . b4) & b3 . (b4 + 1) = the Source of b1 . (b2 . b4) ) or ( b3 . b4 = the Source of b1 . (b2 . b4) & b3 . (b4 + 1) = the Target of b1 . (b2 . b4) ) )
proof end;

theorem Th20: :: GRAPH_3:20
for b1 being Graph
for b2 being Chain of b1
for b3 being FinSequence of the Vertices of b1
for b4 being set st b3 is_vertex_seq_of b2 & b4 in rng b2 holds
( the Target of b1 . b4 in rng b3 & the Source of b1 . b4 in rng b3 )
proof end;

definition
let c1 be Graph;
let c2 be set ;
redefine func -VSet as c1 -VSet c2 -> Subset of the Vertices of a1;
coherence
c1 -VSet c2 is Subset of the Vertices of c1
proof end;
end;

theorem Th21: :: GRAPH_3:21
for b1 being Graph holds b1 -VSet {} = {}
proof end;

theorem Th22: :: GRAPH_3:22
for b1 being Graph
for b2, b3 being set st b2 in the Edges of b1 & b2 in b3 holds
not b1 -VSet b3 is empty
proof end;

theorem Th23: :: GRAPH_3:23
for b1 being Graph holds
( b1 is connected iff for b2, b3 being Vertex of b1 st b2 <> b3 holds
ex b4 being Chain of b1ex b5 being FinSequence of the Vertices of b1 st
( not b4 is empty & b5 is_vertex_seq_of b4 & b5 . 1 = b2 & b5 . (len b5) = b3 ) )
proof end;

theorem Th24: :: GRAPH_3:24
for b1 being connected Graph
for b2 being set
for b3 being Vertex of b1 st b2 meets the Edges of b1 & not b3 in b1 -VSet b2 holds
ex b4 being Vertex of b1ex b5 being Element of the Edges of b1 st
( b4 in b1 -VSet b2 & not b5 in b2 & ( b4 = the Target of b1 . b5 or b4 = the Source of b1 . b5 ) )
proof end;

definition
let c1 be Graph;
let c2 be Vertex of c1;
let c3 be set ;
func Edges_In c2,c3 -> Subset of the Edges of a1 means :Def1: :: GRAPH_3:def 1
for b1 being set holds
( b1 in a4 iff ( b1 in the Edges of a1 & b1 in a3 & the Target of a1 . b1 = a2 ) );
existence
ex b1 being Subset of the Edges of c1 st
for b2 being set holds
( b2 in b1 iff ( b2 in the Edges of c1 & b2 in c3 & the Target of c1 . b2 = c2 ) )
proof end;
uniqueness
for b1, b2 being Subset of the Edges of c1 st ( for b3 being set holds
( b3 in b1 iff ( b3 in the Edges of c1 & b3 in c3 & the Target of c1 . b3 = c2 ) ) ) & ( for b3 being set holds
( b3 in b2 iff ( b3 in the Edges of c1 & b3 in c3 & the Target of c1 . b3 = c2 ) ) ) holds
b1 = b2
proof end;
func Edges_Out c2,c3 -> Subset of the Edges of a1 means :Def2: :: GRAPH_3:def 2
for b1 being set holds
( b1 in a4 iff ( b1 in the Edges of a1 & b1 in a3 & the Source of a1 . b1 = a2 ) );
existence
ex b1 being Subset of the Edges of c1 st
for b2 being set holds
( b2 in b1 iff ( b2 in the Edges of c1 & b2 in c3 & the Source of c1 . b2 = c2 ) )
proof end;
uniqueness
for b1, b2 being Subset of the Edges of c1 st ( for b3 being set holds
( b3 in b1 iff ( b3 in the Edges of c1 & b3 in c3 & the Source of c1 . b3 = c2 ) ) ) & ( for b3 being set holds
( b3 in b2 iff ( b3 in the Edges of c1 & b3 in c3 & the Source of c1 . b3 = c2 ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def1 defines Edges_In GRAPH_3:def 1 :
for b1 being Graph
for b2 being Vertex of b1
for b3 being set
for b4 being Subset of the Edges of b1 holds
( b4 = Edges_In b2,b3 iff for b5 being set holds
( b5 in b4 iff ( b5 in the Edges of b1 & b5 in b3 & the Target of b1 . b5 = b2 ) ) );

:: deftheorem Def2 defines Edges_Out GRAPH_3:def 2 :
for b1 being Graph
for b2 being Vertex of b1
for b3 being set
for b4 being Subset of the Edges of b1 holds
( b4 = Edges_Out b2,b3 iff for b5 being set holds
( b5 in b4 iff ( b5 in the Edges of b1 & b5 in b3 & the Source of b1 . b5 = b2 ) ) );

definition
let c1 be Graph;
let c2 be Vertex of c1;
let c3 be set ;
func Edges_At c2,c3 -> Subset of the Edges of a1 equals :: GRAPH_3:def 3
(Edges_In a2,a3) \/ (Edges_Out a2,a3);
correctness
coherence
(Edges_In c2,c3) \/ (Edges_Out c2,c3) is Subset of the Edges of c1
;
;
end;

:: deftheorem Def3 defines Edges_At GRAPH_3:def 3 :
for b1 being Graph
for b2 being Vertex of b1
for b3 being set holds Edges_At b2,b3 = (Edges_In b2,b3) \/ (Edges_Out b2,b3);

registration
let c1 be finite Graph;
let c2 be Vertex of c1;
let c3 be set ;
cluster Edges_In a2,a3 -> finite ;
correctness
coherence
Edges_In c2,c3 is finite
;
proof end;
cluster Edges_Out a2,a3 -> finite ;
correctness
coherence
Edges_Out c2,c3 is finite
;
proof end;
cluster Edges_At a2,a3 -> finite ;
correctness
coherence
Edges_At c2,c3 is finite
;
;
end;

registration
let c1 be Graph;
let c2 be Vertex of c1;
let c3 be empty set ;
cluster Edges_In a2,a3 -> empty ;
correctness
coherence
Edges_In c2,c3 is empty
;
proof end;
cluster Edges_Out a2,a3 -> empty ;
correctness
coherence
Edges_Out c2,c3 is empty
;
proof end;
cluster Edges_At a2,a3 -> empty ;
correctness
coherence
Edges_At c2,c3 is empty
;
;
end;

definition
let c1 be Graph;
let c2 be Vertex of c1;
func Edges_In c2 -> Subset of the Edges of a1 equals :: GRAPH_3:def 4
Edges_In a2,the Edges of a1;
correctness
coherence
Edges_In c2,the Edges of c1 is Subset of the Edges of c1
;
;
func Edges_Out c2 -> Subset of the Edges of a1 equals :: GRAPH_3:def 5
Edges_Out a2,the Edges of a1;
correctness
coherence
Edges_Out c2,the Edges of c1 is Subset of the Edges of c1
;
;
end;

:: deftheorem Def4 defines Edges_In GRAPH_3:def 4 :
for b1 being Graph
for b2 being Vertex of b1 holds Edges_In b2 = Edges_In b2,the Edges of b1;

:: deftheorem Def5 defines Edges_Out GRAPH_3:def 5 :
for b1 being Graph
for b2 being Vertex of b1 holds Edges_Out b2 = Edges_Out b2,the Edges of b1;

theorem Th25: :: GRAPH_3:25
for b1 being Graph
for b2 being Vertex of b1
for b3 being set holds Edges_In b2,b3 c= Edges_In b2
proof end;

theorem Th26: :: GRAPH_3:26
for b1 being Graph
for b2 being Vertex of b1
for b3 being set holds Edges_Out b2,b3 c= Edges_Out b2
proof end;

registration
let c1 be finite Graph;
let c2 be Vertex of c1;
cluster Edges_In a2 -> finite ;
correctness
coherence
Edges_In c2 is finite
;
;
cluster Edges_Out a2 -> finite ;
correctness
coherence
Edges_Out c2 is finite
;
;
end;

theorem Th27: :: GRAPH_3:27
for b1 being finite Graph
for b2 being Vertex of b1 holds card (Edges_In b2) = EdgesIn b2
proof end;

theorem Th28: :: GRAPH_3:28
for b1 being finite Graph
for b2 being Vertex of b1 holds card (Edges_Out b2) = EdgesOut b2
proof end;

definition
let c1 be finite Graph;
let c2 be Vertex of c1;
let c3 be set ;
func Degree c2,c3 -> Nat equals :: GRAPH_3:def 6
(card (Edges_In a2,a3)) + (card (Edges_Out a2,a3));
correctness
coherence
(card (Edges_In c2,c3)) + (card (Edges_Out c2,c3)) is Nat
;
;
end;

:: deftheorem Def6 defines Degree GRAPH_3:def 6 :
for b1 being finite Graph
for b2 being Vertex of b1
for b3 being set holds Degree b2,b3 = (card (Edges_In b2,b3)) + (card (Edges_Out b2,b3));

theorem Th29: :: GRAPH_3:29
for b1 being finite Graph
for b2 being Vertex of b1 holds Degree b2 = Degree b2,the Edges of b1
proof end;

theorem Th30: :: GRAPH_3:30
for b1 being set
for b2 being finite Graph
for b3 being Vertex of b2 st Degree b3,b1 <> 0 holds
not Edges_At b3,b1 is empty
proof end;

theorem Th31: :: GRAPH_3:31
for b1, b2 being set
for b3 being finite Graph
for b4 being Vertex of b3 st b1 in the Edges of b3 & not b1 in b2 & ( b4 = the Target of b3 . b1 or b4 = the Source of b3 . b1 ) holds
Degree b4 <> Degree b4,b2
proof end;

theorem Th32: :: GRAPH_3:32
for b1 being finite Graph
for b2 being Vertex of b1
for b3, b4 being set st b3 c= b4 holds
card (Edges_In b2,(b4 \ b3)) = (card (Edges_In b2,b4)) - (card (Edges_In b2,b3))
proof end;

theorem Th33: :: GRAPH_3:33
for b1 being finite Graph
for b2 being Vertex of b1
for b3, b4 being set st b3 c= b4 holds
card (Edges_Out b2,(b4 \ b3)) = (card (Edges_Out b2,b4)) - (card (Edges_Out b2,b3))
proof end;

theorem Th34: :: GRAPH_3:34
for b1 being finite Graph
for b2 being Vertex of b1
for b3, b4 being set st b3 c= b4 holds
Degree b2,(b4 \ b3) = (Degree b2,b4) - (Degree b2,b3)
proof end;

theorem Th35: :: GRAPH_3:35
for b1 being set
for b2 being finite Graph
for b3 being Vertex of b2 holds
( Edges_In b3,b1 = Edges_In b3,(b1 /\ the Edges of b2) & Edges_Out b3,b1 = Edges_Out b3,(b1 /\ the Edges of b2) )
proof end;

theorem Th36: :: GRAPH_3:36
for b1 being set
for b2 being finite Graph
for b3 being Vertex of b2 holds Degree b3,b1 = Degree b3,(b1 /\ the Edges of b2)
proof end;

theorem Th37: :: GRAPH_3:37
for b1 being finite Graph
for b2 being Vertex of b1
for b3 being Chain of b1
for b4 being FinSequence of the Vertices of b1 st not b3 is empty & b4 is_vertex_seq_of b3 holds
( b2 in rng b4 iff Degree b2,(rng b3) <> 0 )
proof end;

theorem Th38: :: GRAPH_3:38
for b1 being connected finite non empty Graph
for b2 being Vertex of b1 holds Degree b2 <> 0
proof end;

definition
let c1 be Graph;
let c2, c3 be Vertex of c1;
func AddNewEdge c2,c3 -> strict Graph means :Def7: :: GRAPH_3:def 7
( the Vertices of a4 = the Vertices of a1 & the Edges of a4 = the Edges of a1 \/ {the Edges of a1} & the Source of a4 = the Source of a1 +* (the Edges of a1 .--> a2) & the Target of a4 = the Target of a1 +* (the Edges of a1 .--> a3) );
existence
ex b1 being strict Graph st
( the Vertices of b1 = the Vertices of c1 & the Edges of b1 = the Edges of c1 \/ {the Edges of c1} & the Source of b1 = the Source of c1 +* (the Edges of c1 .--> c2) & the Target of b1 = the Target of c1 +* (the Edges of c1 .--> c3) )
proof end;
uniqueness
for b1, b2 being strict Graph st the Vertices of b1 = the Vertices of c1 & the Edges of b1 = the Edges of c1 \/ {the Edges of c1} & the Source of b1 = the Source of c1 +* (the Edges of c1 .--> c2) & the Target of b1 = the Target of c1 +* (the Edges of c1 .--> c3) & the Vertices of b2 = the Vertices of c1 & the Edges of b2 = the Edges of c1 \/ {the Edges of c1} & the Source of b2 = the Source of c1 +* (the Edges of c1 .--> c2) & the Target of b2 = the Target of c1 +* (the Edges of c1 .--> c3) holds
b1 = b2
;
end;

:: deftheorem Def7 defines AddNewEdge GRAPH_3:def 7 :
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being strict Graph holds
( b4 = AddNewEdge b2,b3 iff ( the Vertices of b4 = the Vertices of b1 & the Edges of b4 = the Edges of b1 \/ {the Edges of b1} & the Source of b4 = the Source of b1 +* (the Edges of b1 .--> b2) & the Target of b4 = the Target of b1 +* (the Edges of b1 .--> b3) ) );

registration
let c1 be finite Graph;
let c2, c3 be Vertex of c1;
cluster AddNewEdge a2,a3 -> strict finite ;
coherence
AddNewEdge c2,c3 is finite
proof end;
end;

theorem Th39: :: GRAPH_3:39
for b1 being Graph
for b2, b3 being Vertex of b1 holds
( the Edges of b1 in the Edges of (AddNewEdge b2,b3) & the Edges of b1 = the Edges of (AddNewEdge b2,b3) \ {the Edges of b1} & the Source of (AddNewEdge b2,b3) . the Edges of b1 = b2 & the Target of (AddNewEdge b2,b3) . the Edges of b1 = b3 )
proof end;

theorem Th40: :: GRAPH_3:40
for b1 being set
for b2 being Graph
for b3, b4 being Vertex of b2 st b1 in the Edges of b2 holds
( the Source of (AddNewEdge b3,b4) . b1 = the Source of b2 . b1 & the Target of (AddNewEdge b3,b4) . b1 = the Target of b2 . b1 )
proof end;

theorem Th41: :: GRAPH_3:41
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being Chain of b1
for b5 being FinSequence of the Vertices of b1
for b6 being FinSequence of the Vertices of (AddNewEdge b2,b3) st b6 = b5 & b5 is_vertex_seq_of b4 holds
b6 is_vertex_seq_of b4
proof end;

theorem Th42: :: GRAPH_3:42
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being Chain of b1 holds b4 is Chain of AddNewEdge b2,b3
proof end;

theorem Th43: :: GRAPH_3:43
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being Path of b1 holds b4 is Path of AddNewEdge b2,b3 by Th42;

theorem Th44: :: GRAPH_3:44
for b1 being set
for b2 being Graph
for b3, b4 being Vertex of b2
for b5 being Vertex of (AddNewEdge b3,b4) st b5 = b3 & b3 <> b4 holds
Edges_In b5,b1 = Edges_In b3,b1
proof end;

theorem Th45: :: GRAPH_3:45
for b1 being set
for b2 being Graph
for b3, b4 being Vertex of b2
for b5 being Vertex of (AddNewEdge b4,b3) st b5 = b3 & b4 <> b3 holds
Edges_Out b5,b1 = Edges_Out b3,b1
proof end;

theorem Th46: :: GRAPH_3:46
for b1 being set
for b2 being Graph
for b3, b4 being Vertex of b2
for b5 being Vertex of (AddNewEdge b3,b4) st b5 = b3 & b3 <> b4 & the Edges of b2 in b1 holds
( Edges_Out b5,b1 = (Edges_Out b3,b1) \/ {the Edges of b2} & Edges_Out b3,b1 misses {the Edges of b2} )
proof end;

theorem Th47: :: GRAPH_3:47
for b1 being set
for b2 being Graph
for b3, b4 being Vertex of b2
for b5 being Vertex of (AddNewEdge b4,b3) st b5 = b3 & b4 <> b3 & the Edges of b2 in b1 holds
( Edges_In b5,b1 = (Edges_In b3,b1) \/ {the Edges of b2} & Edges_In b3,b1 misses {the Edges of b2} )
proof end;

theorem Th48: :: GRAPH_3:48
for b1 being set
for b2 being Graph
for b3, b4, b5 being Vertex of b2
for b6 being Vertex of (AddNewEdge b4,b5) st b6 = b3 & b3 <> b4 & b3 <> b5 holds
Edges_In b6,b1 = Edges_In b3,b1
proof end;

theorem Th49: :: GRAPH_3:49
for b1 being set
for b2 being Graph
for b3, b4, b5 being Vertex of b2
for b6 being Vertex of (AddNewEdge b4,b5) st b6 = b3 & b3 <> b4 & b3 <> b5 holds
Edges_Out b6,b1 = Edges_Out b3,b1
proof end;

theorem Th50: :: GRAPH_3:50
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being Path of AddNewEdge b2,b3 st not the Edges of b1 in rng b4 holds
b4 is Path of b1
proof end;

theorem Th51: :: GRAPH_3:51
for b1 being Graph
for b2, b3 being Vertex of b1
for b4 being FinSequence of the Vertices of b1
for b5 being Path of AddNewEdge b2,b3
for b6 being FinSequence of the Vertices of (AddNewEdge b2,b3) st not the Edges of b1 in rng b5 & b4 = b6 & b6 is_vertex_seq_of b5 holds
b4 is_vertex_seq_of b5
proof end;

registration
let c1 be connected Graph;
let c2, c3 be Vertex of c1;
cluster AddNewEdge a2,a3 -> strict connected ;
coherence
AddNewEdge c2,c3 is connected
proof end;
end;

theorem Th52: :: GRAPH_3:52
for b1 being set
for b2 being finite Graph
for b3, b4, b5 being Vertex of b2
for b6 being Vertex of (AddNewEdge b4,b5) st b6 = b3 & b4 <> b5 & ( b3 = b4 or b3 = b5 ) & the Edges of b2 in b1 holds
Degree b6,b1 = (Degree b3,b1) + 1
proof end;

theorem Th53: :: GRAPH_3:53
for b1 being set
for b2 being finite Graph
for b3, b4, b5 being Vertex of b2
for b6 being Vertex of (AddNewEdge b4,b5) st b6 = b3 & b3 <> b4 & b3 <> b5 holds
Degree b6,b1 = Degree b3,b1
proof end;

Lemma52: for b1 being finite Graph
for b2 being cyclic Path of b1
for b3 being FinSequence of the Vertices of b1
for b4 being Vertex of b1 st b3 is_vertex_seq_of b2 & b4 in rng b3 holds
Degree b4,(rng b2) is even
proof end;

theorem Th54: :: GRAPH_3:54
for b1 being finite Graph
for b2 being Vertex of b1
for b3 being cyclic Path of b1 holds Degree b2,(rng b3) is even
proof end;

theorem Th55: :: GRAPH_3:55
for b1 being finite Graph
for b2 being Vertex of b1
for b3 being FinSequence of the Vertices of b1
for b4 being Path of b1 st not b4 is cyclic & b3 is_vertex_seq_of b4 holds
( Degree b2,(rng b4) is even iff ( b2 <> b3 . 1 & b2 <> b3 . (len b3) ) )
proof end;

definition
let c1 be Graph;
func c1 -CycleSet -> FinSequence-DOMAIN of the Edges of a1 means :Def8: :: GRAPH_3:def 8
for b1 being set holds
( b1 in a2 iff b1 is cyclic Path of a1 );
existence
ex b1 being FinSequence-DOMAIN of the Edges of c1 st
for b2 being set holds
( b2 in b1 iff b2 is cyclic Path of c1 )
proof end;
uniqueness
for b1, b2 being FinSequence-DOMAIN of the Edges of c1 st ( for b3 being set holds
( b3 in b1 iff b3 is cyclic Path of c1 ) ) & ( for b3 being set holds
( b3 in b2 iff b3 is cyclic Path of c1 ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def8 defines -CycleSet GRAPH_3:def 8 :
for b1 being Graph
for b2 being FinSequence-DOMAIN of the Edges of b1 holds
( b2 = b1 -CycleSet iff for b3 being set holds
( b3 in b2 iff b3 is cyclic Path of b1 ) );

theorem Th56: :: GRAPH_3:56
for b1 being Graph holds {} is Element of b1 -CycleSet
proof end;

theorem Th57: :: GRAPH_3:57
for b1 being Graph
for b2 being Vertex of b1
for b3 being Element of b1 -CycleSet st b2 in b1 -VSet (rng b3) holds
{ b4 where B is Element of b1 -CycleSet : ( rng b4 = rng b3 & ex b1 being FinSequence of the Vertices of b1 st
( b5 is_vertex_seq_of b4 & b5 . 1 = b2 ) )
}
is non empty Subset of (b1 -CycleSet )
proof end;

definition
let c1 be Graph;
let c2 be Vertex of c1;
let c3 be Element of c1 -CycleSet ;
assume E58: c2 in c1 -VSet (rng c3) ;
func Rotate c3,c2 -> Element of a1 -CycleSet equals :Def9: :: GRAPH_3:def 9
choose { b1 where B is Element of a1 -CycleSet : ( rng b1 = rng a3 & ex b1 being FinSequence of the Vertices of a1 st
( b2 is_vertex_seq_of b1 & b2 . 1 = a2 ) )
}
;
coherence
choose { b1 where B is Element of c1 -CycleSet : ( rng b1 = rng c3 & ex b1 being FinSequence of the Vertices of c1 st
( b2 is_vertex_seq_of b1 & b2 . 1 = c2 ) )
}
is Element of c1 -CycleSet
proof end;
end;

:: deftheorem Def9 defines Rotate GRAPH_3:def 9 :
for b1 being Graph
for b2 being Vertex of b1
for b3 being Element of b1 -CycleSet st b2 in b1 -VSet (rng b3) holds
Rotate b3,b2 = choose { b4 where B is Element of b1 -CycleSet : ( rng b4 = rng b3 & ex b1 being FinSequence of the Vertices of b1 st
( b5 is_vertex_seq_of b4 & b5 . 1 = b2 ) )
}
;

Lemma59: for b1 being Graph
for b2 being Element of b1 -CycleSet
for b3 being Vertex of b1 st b3 in b1 -VSet (rng b2) holds
rng (Rotate b2,b3) = rng b2
proof end;

definition
let c1 be Graph;
let c2, c3 be Element of c1 -CycleSet ;
assume that
E60: c1 -VSet (rng c2) meets c1 -VSet (rng c3) and
E61: rng c2 misses rng c3 ;
func CatCycles c2,c3 -> Element of a1 -CycleSet means :Def10: :: GRAPH_3:def 10
ex b1 being Vertex of a1 st
( b1 = choose ((a1 -VSet (rng a2)) /\ (a1 -VSet (rng a3))) & a4 = (Rotate a2,b1) ^ (Rotate a3,b1) );
existence
ex b1 being Element of c1 -CycleSet ex b2 being Vertex of c1 st
( b2 = choose ((c1 -VSet (rng c2)) /\ (c1 -VSet (rng c3))) & b1 = (Rotate c2,b2) ^ (Rotate c3,b2) )
proof end;
correctness
uniqueness
for b1, b2 being Element of c1 -CycleSet st ex b3 being Vertex of c1 st
( b3 = choose ((c1 -VSet (rng c2)) /\ (c1 -VSet (rng c3))) & b1 = (Rotate c2,b3) ^ (Rotate c3,b3) ) & ex b3 being Vertex of c1 st
( b3 = choose ((c1 -VSet (rng c2)) /\ (c1 -VSet (rng c3))) & b2 = (Rotate c2,b3) ^ (Rotate c3,b3) ) holds
b1 = b2
;
;
end;

:: deftheorem Def10 defines CatCycles GRAPH_3:def 10 :
for b1 being Graph
for b2, b3 being Element of b1 -CycleSet st b1 -VSet (rng b2) meets b1 -VSet (rng b3) & rng b2 misses rng b3 holds
for b4 being Element of b1 -CycleSet holds
( b4 = CatCycles b2,b3 iff ex b5 being Vertex of b1 st
( b5 = choose ((b1 -VSet (rng b2)) /\ (b1 -VSet (rng b3))) & b4 = (Rotate b2,b5) ^ (Rotate b3,b5) ) );

theorem Th58: :: GRAPH_3:58
for b1 being Graph
for b2, b3 being Element of b1 -CycleSet st b1 -VSet (rng b2) meets b1 -VSet (rng b3) & rng b2 misses rng b3 & ( b2 <> {} or b3 <> {} ) holds
not CatCycles b2,b3 is empty
proof end;

definition
let c1 be finite Graph;
let c2 be Vertex of c1;
let c3 be set ;
assume E62: Degree c2,c3 <> 0 ;
func c3 -PathSet c2 -> FinSequence-DOMAIN of the Edges of a1 equals :Def11: :: GRAPH_3:def 11
{ b1 where B is Element of a3 * : ( b1 is Path of a1 & not b1 is empty & ex b1 being FinSequence of the Vertices of a1 st
( b2 is_vertex_seq_of b1 & b2 . 1 = a2 ) )
}
;
coherence
{ b1 where B is Element of c3 * : ( b1 is Path of c1 & not b1 is empty & ex b1 being FinSequence of the Vertices of c1 st
( b2 is_vertex_seq_of b1 & b2 . 1 = c2 ) )
}
is FinSequence-DOMAIN of the Edges of c1
proof end;
end;

:: deftheorem Def11 defines -PathSet GRAPH_3:def 11 :
for b1 being finite Graph
for b2 being Vertex of b1
for b3 being set st Degree b2,b3 <> 0 holds
b3 -PathSet b2 = { b4 where B is Element of b3 * : ( b4 is Path of b1 & not b4 is empty & ex b1 being FinSequence of the Vertices of b1 st
( b5 is_vertex_seq_of b4 & b5 . 1 = b2 ) )
}
;

theorem Th59: :: GRAPH_3:59
for b1 being set
for b2 being finite Graph
for b3 being Vertex of b2
for b4 being Element of b1 -PathSet b3
for b5 being finite set st b5 = the Edges of b2 & Degree b3,b1 <> 0 holds
len b4 <= card b5
proof end;

definition
let c1 be finite Graph;
let c2 be Vertex of c1;
let c3 be set ;
assume that
E64: for b1 being Vertex of c1 holds Degree b1,c3 is even and
E65: Degree c2,c3 <> 0 ;
func c3 -CycleSet c2 -> non empty Subset of (a1 -CycleSet ) equals :Def12: :: GRAPH_3:def 12
{ b1 where B is Element of a1 -CycleSet : ( rng b1 c= a3 & not b1 is empty & ex b1 being FinSequence of the Vertices of a1 st
( b2 is_vertex_seq_of b1 & b2 . 1 = a2 ) )
}
;
coherence
{ b1 where B is Element of c1 -CycleSet : ( rng b1 c= c3 & not b1 is empty & ex b1 being FinSequence of the Vertices of c1 st
( b2 is_vertex_seq_of b1 & b2 . 1 = c2 ) )
}
is non empty Subset of (c1 -CycleSet )
proof end;
end;

:: deftheorem Def12 defines -CycleSet GRAPH_3:def 12 :
for b1 being finite Graph
for b2 being Vertex of b1
for b3 being set st ( for b4 being Vertex of b1 holds Degree b4,b3 is even ) & Degree b2,b3 <> 0 holds
b3 -CycleSet b2 = { b4 where B is Element of b1 -CycleSet : ( rng b4 c= b3 & not b4 is empty & ex b1 being FinSequence of the Vertices of b1 st
( b5 is_vertex_seq_of b4 & b5 . 1 = b2 ) )
}
;

theorem Th60: :: GRAPH_3:60
for b1 being set
for b2 being finite Graph
for b3 being Vertex of b2 st Degree b3,b1 <> 0 & ( for b4 being Vertex of b2 holds Degree b4,b1 is even ) holds
for b4 being Element of b1 -CycleSet b3 holds
( not b4 is empty & rng b4 c= b1 & b3 in b2 -VSet (rng b4) )
proof end;

theorem Th61: :: GRAPH_3:61
for b1 being connected finite Graph
for b2 being Element of b1 -CycleSet st rng b2 <> the Edges of b1 & not b2 is empty holds
{ b3 where B is Vertex of b1 : ( b3 in b1 -VSet (rng b2) & Degree b3 <> Degree b3,(rng b2) ) } is non empty Subset of the Vertices of b1
proof end;

definition
let c1 be connected finite Graph;
let c2 be Element of c1 -CycleSet ;
assume that
E67: rng c2 <> the Edges of c1 and
E68: not c2 is empty ;
func ExtendCycle c2 -> Element of a1 -CycleSet means :Def13: :: GRAPH_3:def 13
ex b1 being Element of a1 -CycleSet ex b2 being Vertex of a1 st
( b2 = choose { b3 where B is Vertex of a1 : ( b3 in a1 -VSet (rng a2) & Degree b3 <> Degree b3,(rng a2) ) } & b1 = choose ((the Edges of a1 \ (rng a2)) -CycleSet b2) & a3 = CatCycles a2,b1 );
existence
ex b1, b2 being Element of c1 -CycleSet ex b3 being Vertex of c1 st
( b3 = choose { b4 where B is Vertex of c1 : ( b4 in c1 -VSet (rng c2) & Degree b4 <> Degree b4,(rng c2) ) } & b2 = choose ((the Edges of c1 \ (rng c2)) -CycleSet b3) & b1 = CatCycles c2,b2 )
proof end;
uniqueness
for b1, b2 being Element of c1 -CycleSet st ex b3 being Element of c1 -CycleSet ex b4 being Vertex of c1 st
( b4 = choose { b5 where B is Vertex of c1 : ( b5 in c1 -VSet (rng c2) & Degree b5 <> Degree b5,(rng c2) ) } & b3 = choose ((the Edges of c1 \ (rng c2)) -CycleSet b4) & b1 = CatCycles c2,b3 ) & ex b3 being Element of c1 -CycleSet ex b4 being Vertex of c1 st
( b4 = choose { b5 where B is Vertex of c1 : ( b5 in c1 -VSet (rng c2) & Degree b5 <> Degree b5,(rng c2) ) } & b3 = choose ((the Edges of c1 \ (rng c2)) -CycleSet b4) & b2 = CatCycles c2,b3 ) holds
b1 = b2
;
end;

:: deftheorem Def13 defines ExtendCycle GRAPH_3:def 13 :
for b1 being connected finite Graph
for b2 being Element of b1 -CycleSet st rng b2 <> the Edges of b1 & not b2 is empty holds
for b3 being Element of b1 -CycleSet holds
( b3 = ExtendCycle b2 iff ex b4 being Element of b1 -CycleSet ex b5 being Vertex of b1 st
( b5 = choose { b6 where B is Vertex of b1 : ( b6 in b1 -VSet (rng b2) & Degree b6 <> Degree b6,(rng b2) ) } & b4 = choose ((the Edges of b1 \ (rng b2)) -CycleSet b5) & b3 = CatCycles b2,b4 ) );

theorem Th62: :: GRAPH_3:62
for b1 being connected finite Graph
for b2 being Element of b1 -CycleSet st rng b2 <> the Edges of b1 & not b2 is empty & ( for b3 being Vertex of b1 holds Degree b3 is even ) holds
( not ExtendCycle b2 is empty & card (rng b2) < card (rng (ExtendCycle b2)) )
proof end;

definition
let c1 be Graph;
let c2 be Path of c1;
attr a2 is Eulerian means :Def14: :: GRAPH_3:def 14
rng a2 = the Edges of a1;
end;

:: deftheorem Def14 defines Eulerian GRAPH_3:def 14 :
for b1 being Graph
for b2 being Path of b1 holds
( b2 is Eulerian iff rng b2 = the Edges of b1 );

theorem Th63: :: GRAPH_3:63
for b1 being connected Graph
for b2 being Path of b1
for b3 being FinSequence of the Vertices of b1 st b2 is Eulerian & b3 is_vertex_seq_of b2 holds
rng b3 = the Vertices of b1
proof end;

theorem Th64: :: GRAPH_3:64
for b1 being connected finite Graph holds
( ex b2 being cyclic Path of b1 st b2 is Eulerian iff for b2 being Vertex of b1 holds Degree b2 is even )
proof end;

theorem Th65: :: GRAPH_3:65
for b1 being connected finite Graph holds
( ex b2 being Path of b1 st
( not b2 is cyclic & b2 is Eulerian ) iff ex b2, b3 being Vertex of b1 st
( b2 <> b3 & ( for b4 being Vertex of b1 holds
( Degree b4 is even iff ( b4 <> b2 & b4 <> b3 ) ) ) ) )
proof end;