src/HOL/RelPow.ML
author paulson
Wed, 13 Nov 1996 10:47:08 +0100
changeset 2183 8d42a7bccf0b
parent 2056 93c093620c28
child 2741 2b7f72cbe51f
permissions -rw-r--r--
Updated version and date
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/RelPow.ML
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     4
    Copyright   1996  TU Muenchen
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     5
*)
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     6
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     7
open RelPow;
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     8
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
     9
val [rel_pow_0, rel_pow_Suc] = nat_recs rel_pow_def;
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    10
Addsimps [rel_pow_0];
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    11
1693
7083f6b05423 Added R^1 = R
nipkow
parents: 1552
diff changeset
    12
goal RelPow.thy "R^1 = R";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1760
diff changeset
    13
by (simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
1693
7083f6b05423 Added R^1 = R
nipkow
parents: 1552
diff changeset
    14
qed "rel_pow_1";
7083f6b05423 Added R^1 = R
nipkow
parents: 1552
diff changeset
    15
Addsimps [rel_pow_1];
7083f6b05423 Added R^1 = R
nipkow
parents: 1552
diff changeset
    16
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    17
goal RelPow.thy "(x,x) : R^0";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    18
by (Simp_tac 1);
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    19
qed "rel_pow_0_I";
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    20
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    21
goal RelPow.thy "!!R. [| (x,y) : R^n; (y,z):R |] ==> (x,z):R^(Suc n)";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    22
by (simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    23
by (Fast_tac 1);
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    24
qed "rel_pow_Suc_I";
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    25
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    26
goal RelPow.thy "!z. (x,y) : R --> (y,z):R^n -->  (x,z):R^(Suc n)";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    27
by (nat_ind_tac "n" 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    28
by (simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    29
by (asm_full_simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    30
by (Fast_tac 1);
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    31
qed_spec_mp "rel_pow_Suc_I2";
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    32
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    33
goal RelPow.thy "!!R. [| (x,y) : R^0; x=y ==> P |] ==> P";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    34
by (Asm_full_simp_tac 1);
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    35
qed "rel_pow_0_E";
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    36
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    37
val [major,minor] = goal RelPow.thy
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    38
  "[| (x,z) : R^(Suc n);  !!y. [| (x,y) : R^n; (y,z) : R |] ==> P |] ==> P";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    39
by (cut_facts_tac [major] 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    40
by (asm_full_simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    41
by (fast_tac (!claset addIs [minor]) 1);
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    42
qed "rel_pow_Suc_E";
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    43
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    44
val [p1,p2,p3] = goal RelPow.thy
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    45
    "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;        \
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    46
\       !!y m. [| n = Suc m; (x,y) : R^m; (y,z) : R |] ==> P  \
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    47
\    |] ==> P";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    48
by (res_inst_tac [("n","n")] natE 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    49
by (cut_facts_tac [p1] 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    50
by (asm_full_simp_tac (!simpset addsimps [p2]) 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    51
by (cut_facts_tac [p1] 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    52
by (Asm_full_simp_tac 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    53
by (etac rel_pow_Suc_E 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    54
by (REPEAT(ares_tac [p3] 1));
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    55
qed "rel_pow_E";
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    56
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    57
goal RelPow.thy "!x z. (x,z):R^(Suc n) --> (? y. (x,y):R & (y,z):R^n)";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    58
by (nat_ind_tac "n" 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    59
by (fast_tac (!claset addIs [rel_pow_0_I] addEs [rel_pow_0_E,rel_pow_Suc_E]) 1);
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    60
by (fast_tac (!claset addIs [rel_pow_Suc_I] addEs[rel_pow_0_E,rel_pow_Suc_E]) 1);
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    61
qed_spec_mp "rel_pow_Suc_D2";
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    62
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    63
val [p1,p2,p3] = goal RelPow.thy
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    64
    "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;        \
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    65
\       !!y m. [| n = Suc m; (x,y) : R; (y,z) : R^m |] ==> P  \
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    66
\    |] ==> P";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    67
by (res_inst_tac [("n","n")] natE 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    68
by (cut_facts_tac [p1] 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    69
by (asm_full_simp_tac (!simpset addsimps [p2]) 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    70
by (cut_facts_tac [p1] 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    71
by (Asm_full_simp_tac 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    72
by (dtac rel_pow_Suc_D2 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    73
by (etac exE 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    74
by (etac p3 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    75
by (etac conjunct1 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    76
by (etac conjunct2 1);
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    77
qed "rel_pow_E2";
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    78
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    79
goal RelPow.thy "!!p. p:R^* ==> p : (UN n. R^n)";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    80
by (split_all_tac 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    81
by (etac rtrancl_induct 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    82
by (ALLGOALS (fast_tac (!claset addIs [rel_pow_0_I,rel_pow_Suc_I])));
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    83
qed "rtrancl_imp_UN_rel_pow";
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    84
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    85
goal RelPow.thy "!y. (x,y):R^n --> (x,y):R^*";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    86
by (nat_ind_tac "n" 1);
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    87
by (fast_tac (!claset addIs [rtrancl_refl] addEs [rel_pow_0_E]) 1);
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    88
by (fast_tac (!claset addEs [rel_pow_Suc_E,rtrancl_into_rtrancl]) 1);
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    89
val lemma = result() RS spec RS mp;
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    90
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    91
goal RelPow.thy "!!p. p:R^n ==> p:R^*";
1552
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    92
by (split_all_tac 1);
6f71b5d46700 Ran expandshort
paulson
parents: 1515
diff changeset
    93
by (etac lemma 1);
1515
4ed79ebab64d Introduced normalize_thm into HOL.ML
nipkow
parents: 1496
diff changeset
    94
qed "rel_pow_imp_rtrancl";
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    95
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    96
goal RelPow.thy "R^* = (UN n. R^n)";
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1693
diff changeset
    97
by (fast_tac (!claset addIs [rtrancl_imp_UN_rel_pow,rel_pow_imp_rtrancl]) 1);
1496
c443b2adaf52 Added a few thms and the new theory RelPow.
nipkow
parents:
diff changeset
    98
qed "rtrancl_is_UN_rel_pow";