Graphs.thy
author xingyuan zhang <xingyuanzhang@126.com>
Fri, 30 Oct 2015 20:40:11 +0800
changeset 55 b85cfbd58f59
parent 41 66ed924aaa5c
child 127 38c6acf03f68
permissions -rw-r--r--
Comments for Set-operation finished
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
theory Graphs
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
imports Main
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
begin
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
lemma rtrancl_eq_trancl [simp]:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
  assumes "x \<noteq> y"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
  shows "(x, y) \<in> r\<^sup>* \<longleftrightarrow> (x, y) \<in> r\<^sup>+"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
using assms by (metis rtrancl_eq_or_trancl) 
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    10
(* NOT NEEDED : FIXME *)
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
lemma trancl_split: 
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
  "(a, b) \<in> r^+ \<Longrightarrow> \<exists> c. (a, c) \<in> r"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
by (induct rule:trancl_induct, auto)
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    15
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    16
section {* Single_Valuedness *}
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    17
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    18
lemma single_valued_Collect:
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    19
  assumes "single_valuedP r"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    20
  and "inj f"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    21
  shows "single_valued {(f x, g y) | x y. r x y}"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    22
using assms
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    23
unfolding single_valued_def inj_on_def
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    24
apply(auto)
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    25
done
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    27
lemma single_valued_union:
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    28
  assumes "single_valued r" "single_valued q"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    29
  and "Domain r \<inter> Domain q = {}"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    30
  shows "single_valued (r \<union> q)"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    31
using assms
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    32
unfolding single_valued_def
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    33
by auto
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    35
lemma single_valuedP_update:
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    36
  assumes "single_valuedP r"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    37
  shows "single_valuedP (r(x := y))"
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    38
using assms
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    39
oops
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    41
lemma single_valued_confluent2:
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    42
  assumes unique: "single_valued r"
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
  and xy: "(x, y) \<in> r^+"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
  and xz: "(x, z) \<in> r^+"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
  and neq_yz: "y \<noteq> z"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
  shows "(y, z) \<in> r^+ \<or> (z, y) \<in> r^+"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
proof -
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    48
  have "(x, y) \<in> r^*" "(x, z) \<in> r^*" using xy xz by simp_all
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    49
  with single_valued_confluent[OF unique]
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
  have "(y, z) \<in> r\<^sup>* \<or> (z, y) \<in> r\<^sup>*" by auto
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
  with neq_yz
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    52
  show "(y, z) \<in> r^+ \<or> (z, y) \<in> r^+" by simp
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
qed
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    55
lemmas unique_chain = single_valued_confluent2
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    56
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    57
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    58
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
definition funof :: "[('a * 'b)set, 'a] => 'b" where
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
   "funof r == (\<lambda>x. THE y. (x, y) \<in> r)"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
lemma funof_eq: "[|single_valued r; (x, y) \<in> r|] ==> funof r x = y"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
by (simp add: funof_def single_valued_def, blast)
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
lemma funof_Pair_in:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
     "[|single_valued r; x \<in> Domain r|] ==> (x, funof r x) \<in> r"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
by (force simp add: funof_eq) 
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
lemma funof_in:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
     "[|r `` {x} \<subseteq> A; single_valued r; x \<in> Domain r|] ==> funof r x \<in> A" 
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
by (force simp add: funof_eq)
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
 
41
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    73
66ed924aaa5c added another book that makes the error, some more proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 40
diff changeset
    74
40
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
end