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