Graphs.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 03 Jun 2014 15:00:12 +0100
changeset 40 0781a2fc93f1
child 41 66ed924aaa5c
permissions -rw-r--r--
added a library about graphs
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
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
lemma trancl_split: 
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
  "(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
    12
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
    13
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
lemma unique_minus:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
  assumes unique: "\<And> a b c. \<lbrakk>(a, b) \<in> r; (a, c) \<in> r\<rbrakk> \<Longrightarrow> b = c"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
  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
    17
  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
    18
  and neq: "y \<noteq> z"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
  shows "(y, z) \<in> r^+"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
by (metis converse_tranclE neq unique xy xz)
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
lemma unique_base:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
  assumes unique: "\<And> a b c. \<lbrakk>(a, b) \<in> r; (a, c) \<in> r\<rbrakk> \<Longrightarrow> b = c"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
  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
    25
  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
    26
  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
    27
  shows "(y, z) \<in> r^+"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
by (metis neq_yz unique unique_minus xy xz)
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
lemma unique_chain_star:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
  assumes unique: "\<And> a b c. \<lbrakk>(a, b) \<in> r; (a, c) \<in> r\<rbrakk> \<Longrightarrow> b = c"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
  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
    33
  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
    34
  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
    35
thm single_valued_confluent single_valued_def unique xy xz
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
by (metis single_valued_confluent single_valued_def unique xy xz)
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
lemma unique_chain:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
  assumes unique: "\<And> a b c. \<lbrakk>(a, b) \<in> r; (a, c) \<in> r\<rbrakk> \<Longrightarrow> b = c"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
  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
    41
  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
    42
  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
    43
  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
    44
proof -
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
  have xy_star: "(x, y) \<in> r^*"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
  and  xz_star: "(x, z) \<in> r^*" using xy xz by simp_all
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
  from unique_chain_star[OF unique xy_star xz_star]
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
  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
    49
  with neq_yz
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
  show ?thesis by(auto)
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
qed
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
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
    54
   "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
    55
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
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
    57
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
    58
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
lemma funof_Pair_in:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
     "[|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
    61
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
    62
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
lemma funof_in:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
     "[|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
    65
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
    66
 
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
lemma single_valuedP_update:
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
  shows "single_valuedP r \<Longrightarrow> single_valuedP (r(x := y))"
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
oops
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
0781a2fc93f1 added a library about graphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
end