-
Notifications
You must be signed in to change notification settings - Fork 1
/
graph.v
52 lines (40 loc) · 1.34 KB
/
graph.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Set Implicit Arguments.
Unset Strict Implicit.
Require Export utils1.
Module Graph.
Inductive is_graph : EP :=
| graph_is_graph : forall v e, relates e v v -> is_graph (pair v e).
Definition vertices := P. Definition edges := Q.
Lemma graph_relates : forall g, is_graph g -> relates (edges g) (vertices g) (vertices g).
Proof.
ir. nin H. uf edges;uf vertices. clpr. am.
Qed.
Inductive exists_path : E3P :=
| path_edge : forall g x y, R (edges g) x y -> exists_path g x y
| path_trans : forall g x y, R (edges g) x y -> forall z, exists_path g y z -> exists_path g x z
.
Inductive is_path : E4P :=
| path_one : forall g x y, R (edges g) x y -> is_path g x y (econs x (econs y enil))
| path_next : forall g x y, R (edges g) x y -> forall z p, is_path g y z p -> is_path g x z (econs x p)
.
Lemma exists_path_rw : forall g x y, exists_path g x y = ex (is_path g x y).
Proof.
ir;ap iff_eq. ir. nin H.
exists (econs x (econs y enil)). constructor. am.
nin IHexists_path. exists (econs x x0).
eapply path_next. am. am.
ir. destruct H as [p H]. nin H.
ap path_edge. am.
eapply path_trans. am. am.
Qed.
Lemma path_list : forall g x y l, is_path g x y l -> is_elist l.
Proof.
ir;nin H.
lSolve. lSolve.
Qed.
Lemma path_ev_0 : forall g x y l, is_path g x y l -> ev l n0 = x.
Proof.
ir;nin H.
rw econs_0. tv. lSolve.
rw econs_0. tv. eapply path_list. am.
Qed.