src/HOL/Relation_Power.thy
author webertj
Mon Mar 07 19:30:53 2005 +0100 (2005-03-07)
changeset 15584 3478bb4f93ff
parent 15410 18914688a5fd
child 18049 156bba334c12
permissions -rw-r--r--
refute_params: default value itself=1 added (for type classes)
nipkow@10213
     1
(*  Title:      HOL/Relation_Power.thy
nipkow@10213
     2
    ID:         $Id$
nipkow@10213
     3
    Author:     Tobias Nipkow
nipkow@10213
     4
    Copyright   1996  TU Muenchen
paulson@15410
     5
*)
nipkow@11306
     6
paulson@15410
     7
header{*Powers of Relations and Functions*}
nipkow@10213
     8
nipkow@15131
     9
theory Relation_Power
nipkow@15140
    10
imports Nat
nipkow@15131
    11
begin
nipkow@10213
    12
nipkow@10213
    13
instance
paulson@15410
    14
  set :: (type) power ..  
paulson@15410
    15
      --{* only type @{typ "('a * 'a) set"} should be in class @{text power}!*}
nipkow@10213
    16
paulson@15410
    17
(*R^n = R O ... O R, the n-fold composition of R*)
nipkow@10213
    18
primrec (relpow)
nipkow@10213
    19
  "R^0 = Id"
nipkow@10213
    20
  "R^(Suc n) = R O (R^n)"
nipkow@10213
    21
nipkow@11305
    22
nipkow@11306
    23
instance
paulson@15410
    24
  fun :: (type, type) power ..
paulson@15410
    25
      --{* only type @{typ "'a => 'a"} should be in class @{text power}!*}
nipkow@11305
    26
paulson@15410
    27
(*f^n = f o ... o f, the n-fold composition of f*)
nipkow@11305
    28
primrec (funpow)
nipkow@11305
    29
  "f^0 = id"
nipkow@11305
    30
  "f^(Suc n) = f o (f^n)"
nipkow@11305
    31
paulson@15410
    32
text{*WARNING: due to the limits of Isabelle's type classes, exponentiation on
paulson@15410
    33
functions and relations has too general a domain, namely @{typ "('a * 'b)set"}
paulson@15410
    34
and @{typ "'a => 'b"}.  Explicit type constraints may therefore be necessary.
paulson@15410
    35
For example, @{term "range(f^n) = A"} and @{term "Range(R^n) = B"} need
paulson@15410
    36
constraints.*}
paulson@15410
    37
nipkow@15112
    38
lemma funpow_add: "f ^ (m+n) = f^m o f^n"
nipkow@15112
    39
by(induct m) simp_all
nipkow@15112
    40
paulson@15410
    41
lemma rel_pow_1: "!!R:: ('a*'a)set. R^1 = R"
paulson@15410
    42
by simp
paulson@15410
    43
declare rel_pow_1 [simp]
paulson@15410
    44
paulson@15410
    45
lemma rel_pow_0_I: "(x,x) : R^0"
paulson@15410
    46
by simp
paulson@15410
    47
paulson@15410
    48
lemma rel_pow_Suc_I: "[| (x,y) : R^n; (y,z):R |] ==> (x,z):R^(Suc n)"
paulson@15410
    49
apply (auto ); 
paulson@15410
    50
done
paulson@15410
    51
paulson@15410
    52
lemma rel_pow_Suc_I2 [rule_format]:
paulson@15410
    53
     "\<forall>z. (x,y) : R --> (y,z):R^n -->  (x,z):R^(Suc n)"
paulson@15410
    54
apply (induct_tac "n", simp_all)
paulson@15410
    55
apply blast
paulson@15410
    56
done
paulson@15410
    57
paulson@15410
    58
lemma rel_pow_0_E: "[| (x,y) : R^0; x=y ==> P |] ==> P"
paulson@15410
    59
by simp
paulson@15410
    60
paulson@15410
    61
lemma rel_pow_Suc_E: 
paulson@15410
    62
     "[| (x,z) : R^(Suc n);  !!y. [| (x,y) : R^n; (y,z) : R |] ==> P |] ==> P"
paulson@15410
    63
by auto
paulson@15410
    64
paulson@15410
    65
lemma rel_pow_E: 
paulson@15410
    66
    "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;         
paulson@15410
    67
        !!y m. [| n = Suc m; (x,y) : R^m; (y,z) : R |] ==> P   
paulson@15410
    68
     |] ==> P"
paulson@15410
    69
by (case_tac "n", auto)
paulson@15410
    70
paulson@15410
    71
lemma rel_pow_Suc_D2 [rule_format]:
paulson@15410
    72
     "\<forall>x z. (x,z):R^(Suc n) --> (\<exists>y. (x,y):R & (y,z):R^n)"
paulson@15410
    73
apply (induct_tac "n")
paulson@15410
    74
apply (blast intro: rel_pow_0_I elim: rel_pow_0_E rel_pow_Suc_E)
paulson@15410
    75
apply (blast intro: rel_pow_Suc_I elim: rel_pow_0_E rel_pow_Suc_E)
paulson@15410
    76
done
paulson@15410
    77
paulson@15410
    78
paulson@15410
    79
lemma rel_pow_Suc_D2':
paulson@15410
    80
     "\<forall>x y z. (x,y) : R^n & (y,z) : R --> (\<exists>w. (x,w) : R & (w,z) : R^n)"
paulson@15410
    81
by (induct_tac "n", simp_all, blast)
paulson@15410
    82
paulson@15410
    83
lemma rel_pow_E2: 
paulson@15410
    84
    "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;         
paulson@15410
    85
        !!y m. [| n = Suc m; (x,y) : R; (y,z) : R^m |] ==> P   
paulson@15410
    86
     |] ==> P"
paulson@15410
    87
apply (case_tac "n", simp) 
paulson@15410
    88
apply (cut_tac n=nat and R=R in rel_pow_Suc_D2', simp, blast) 
paulson@15410
    89
done
paulson@15410
    90
paulson@15410
    91
lemma rtrancl_imp_UN_rel_pow: "!!p. p:R^* ==> p : (UN n. R^n)"
paulson@15410
    92
apply (simp only: split_tupled_all)
paulson@15410
    93
apply (erule rtrancl_induct)
paulson@15410
    94
apply (blast intro: rel_pow_0_I rel_pow_Suc_I)+
paulson@15410
    95
done
paulson@15410
    96
paulson@15410
    97
lemma rel_pow_imp_rtrancl: "!!p. p:R^n ==> p:R^*"
paulson@15410
    98
apply (simp only: split_tupled_all)
paulson@15410
    99
apply (induct "n")
paulson@15410
   100
apply (blast intro: rtrancl_refl elim: rel_pow_0_E)
paulson@15410
   101
apply (blast elim: rel_pow_Suc_E intro: rtrancl_into_rtrancl)
paulson@15410
   102
done
paulson@15410
   103
paulson@15410
   104
lemma rtrancl_is_UN_rel_pow: "R^* = (UN n. R^n)"
paulson@15410
   105
by (blast intro: rtrancl_imp_UN_rel_pow rel_pow_imp_rtrancl)
paulson@15410
   106
paulson@15410
   107
paulson@15410
   108
lemma single_valued_rel_pow [rule_format]:
paulson@15410
   109
     "!!r::('a * 'a)set. single_valued r ==> single_valued (r^n)"
paulson@15410
   110
apply (rule single_valuedI)
paulson@15410
   111
apply (induct_tac "n", simp)
paulson@15410
   112
apply (fast dest: single_valuedD elim: rel_pow_Suc_E)
paulson@15410
   113
done
paulson@15410
   114
paulson@15410
   115
ML
paulson@15410
   116
{*
paulson@15410
   117
val funpow_add = thm "funpow_add";
paulson@15410
   118
val rel_pow_1 = thm "rel_pow_1";
paulson@15410
   119
val rel_pow_0_I = thm "rel_pow_0_I";
paulson@15410
   120
val rel_pow_Suc_I = thm "rel_pow_Suc_I";
paulson@15410
   121
val rel_pow_Suc_I2 = thm "rel_pow_Suc_I2";
paulson@15410
   122
val rel_pow_0_E = thm "rel_pow_0_E";
paulson@15410
   123
val rel_pow_Suc_E = thm "rel_pow_Suc_E";
paulson@15410
   124
val rel_pow_E = thm "rel_pow_E";
paulson@15410
   125
val rel_pow_Suc_D2 = thm "rel_pow_Suc_D2";
paulson@15410
   126
val rel_pow_Suc_D2 = thm "rel_pow_Suc_D2";
paulson@15410
   127
val rel_pow_E2 = thm "rel_pow_E2";
paulson@15410
   128
val rtrancl_imp_UN_rel_pow = thm "rtrancl_imp_UN_rel_pow";
paulson@15410
   129
val rel_pow_imp_rtrancl = thm "rel_pow_imp_rtrancl";
paulson@15410
   130
val rtrancl_is_UN_rel_pow = thm "rtrancl_is_UN_rel_pow";
paulson@15410
   131
val single_valued_rel_pow = thm "single_valued_rel_pow";
paulson@15410
   132
*}
paulson@15410
   133
nipkow@10213
   134
end