src/HOL/Transitive_Closure.thy
author berghofe
Tue, 22 May 2001 15:12:11 +0200
changeset 11327 cd2c27a23df1
parent 11115 285b31e9e026
child 12428 f3033eed309a
permissions -rw-r--r--
Transitive closure is now defined via "inductive".
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Transitive_Closure.thy
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     2
    ID:         $Id$
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     5
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     6
Relfexive and Transitive closure of a relation
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     7
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     8
rtrancl is reflexive/transitive closure;
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     9
trancl  is transitive closure
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    10
reflcl  is reflexive closure
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    11
10331
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    12
These postfix operators have MAXIMUM PRIORITY, forcing their operands
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    13
to be atomic.
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    14
*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    15
11327
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    16
theory Transitive_Closure = Inductive
10980
0a45f2efaaec Transitive_Closure turned into new-style theory;
wenzelm
parents: 10827
diff changeset
    17
files ("Transitive_Closure_lemmas.ML"):
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    18
11327
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    19
consts
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    20
  rtrancl :: "('a * 'a) set => ('a * 'a) set"    ("(_^*)" [1000] 999)
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    21
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    22
inductive "r^*"
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    23
intros
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    24
  rtrancl_refl [intro!, simp]: "(a, a) : r^*"
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    25
  rtrancl_into_rtrancl:        "[| (a,b) : r^*; (b,c) : r |] ==> (a,c) : r^*"
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    26
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    27
constdefs
10331
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    28
  trancl :: "('a * 'a) set => ('a * 'a) set"    ("(_^+)" [1000] 999)
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    29
  "r^+ ==  r O rtrancl r"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    30
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    31
syntax
10331
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    32
  "_reflcl" :: "('a * 'a) set => ('a * 'a) set"    ("(_^=)" [1000] 999)
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    33
translations
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    34
  "r^=" == "r Un Id"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    35
10827
a7ac8e1e024b syntax (xsymbols);
wenzelm
parents: 10565
diff changeset
    36
syntax (xsymbols)
10331
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    37
  rtrancl :: "('a * 'a) set => ('a * 'a) set"    ("(_\\<^sup>*)" [1000] 999)
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    38
  trancl :: "('a * 'a) set => ('a * 'a) set"    ("(_\\<^sup>+)" [1000] 999)
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    39
  "_reflcl" :: "('a * 'a) set => ('a * 'a) set"    ("(_\\<^sup>=)" [1000] 999)
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10213
diff changeset
    40
10980
0a45f2efaaec Transitive_Closure turned into new-style theory;
wenzelm
parents: 10827
diff changeset
    41
use "Transitive_Closure_lemmas.ML"
0a45f2efaaec Transitive_Closure turned into new-style theory;
wenzelm
parents: 10827
diff changeset
    42
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    43
11090
wenzelm
parents: 11084
diff changeset
    44
lemma reflcl_trancl [simp]: "(r^+)^= = r^*"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    45
  apply safe
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    46
  apply (erule trancl_into_rtrancl)
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    47
  apply (blast elim: rtranclE dest: rtrancl_into_trancl1)
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    48
  done
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    49
11090
wenzelm
parents: 11084
diff changeset
    50
lemma trancl_reflcl [simp]: "(r^=)^+ = r^*"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    51
  apply safe
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    52
   apply (drule trancl_into_rtrancl)
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    53
   apply simp
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    54
  apply (erule rtranclE)
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    55
   apply safe
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    56
   apply (rule r_into_trancl)
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    57
   apply simp
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    58
  apply (rule rtrancl_into_trancl1)
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    59
   apply (erule rtrancl_reflcl [THEN equalityD2, THEN subsetD])
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    60
  apply fast
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    61
  done
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    62
11090
wenzelm
parents: 11084
diff changeset
    63
lemma trancl_empty [simp]: "{}^+ = {}"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    64
  by (auto elim: trancl_induct)
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    65
11090
wenzelm
parents: 11084
diff changeset
    66
lemma rtrancl_empty [simp]: "{}^* = Id"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    67
  by (rule subst [OF reflcl_trancl]) simp
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    68
11090
wenzelm
parents: 11084
diff changeset
    69
lemma rtranclD: "(a, b) \<in> R^* ==> a = b \<or> a \<noteq> b \<and> (a, b) \<in> R^+"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    70
  by (force simp add: reflcl_trancl [symmetric] simp del: reflcl_trancl)
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    71
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    72
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    73
(* should be merged with the main body of lemmas: *)
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    74
11090
wenzelm
parents: 11084
diff changeset
    75
lemma Domain_rtrancl [simp]: "Domain (R^*) = UNIV"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    76
  by blast
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    77
11090
wenzelm
parents: 11084
diff changeset
    78
lemma Range_rtrancl [simp]: "Range (R^*) = UNIV"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    79
  by blast
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    80
11090
wenzelm
parents: 11084
diff changeset
    81
lemma rtrancl_Un_subset: "(R^* \<union> S^*) \<subseteq> (R Un S)^*"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    82
  by (rule rtrancl_Un_rtrancl [THEN subst]) fast
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    83
11090
wenzelm
parents: 11084
diff changeset
    84
lemma in_rtrancl_UnI: "x \<in> R^* \<or> x \<in> S^* ==> x \<in> (R \<union> S)^*"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    85
  by (blast intro: subsetD [OF rtrancl_Un_subset])
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    86
11090
wenzelm
parents: 11084
diff changeset
    87
lemma trancl_domain [simp]: "Domain (r^+) = Domain r"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    88
  by (unfold Domain_def) (blast dest: tranclD)
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    89
11090
wenzelm
parents: 11084
diff changeset
    90
lemma trancl_range [simp]: "Range (r^+) = Range r"
11084
32c1deea5bcd unsymbolized;
wenzelm
parents: 10996
diff changeset
    91
  by (simp add: Range_def trancl_converse [symmetric])
10996
74e970389def Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
nipkow
parents: 10980
diff changeset
    92
11115
285b31e9e026 a new theorem from Bryan Ford
paulson
parents: 11090
diff changeset
    93
lemma Not_Domain_rtrancl:
285b31e9e026 a new theorem from Bryan Ford
paulson
parents: 11090
diff changeset
    94
	"x ~: Domain R ==> ((x, y) : R^*) = (x = y)"
285b31e9e026 a new theorem from Bryan Ford
paulson
parents: 11090
diff changeset
    95
 apply (auto)
285b31e9e026 a new theorem from Bryan Ford
paulson
parents: 11090
diff changeset
    96
 by (erule rev_mp, erule rtrancl_induct, auto)
11327
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    97
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    98
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
    99
declare rtrancl_induct [induct set: rtrancl]
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
   100
declare rtranclE [cases set: rtrancl]
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
   101
declare trancl_induct [induct set: trancl]
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
   102
declare tranclE [cases set: trancl]
cd2c27a23df1 Transitive closure is now defined via "inductive".
berghofe
parents: 11115
diff changeset
   103
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   104
end