src/HOL/RelPow.ML
author paulson
Thu Jan 08 18:10:34 1998 +0100 (1998-01-08)
changeset 4537 4e835bd9fada
parent 4089 96fba19bcbe2
child 4759 33a03e70e641
permissions -rw-r--r--
Expressed most Oops rules using Notes instead of Says, and other tidying
nipkow@1496
     1
(*  Title:      HOL/RelPow.ML
nipkow@1496
     2
    ID:         $Id$
nipkow@1496
     3
    Author:     Tobias Nipkow
nipkow@1496
     4
    Copyright   1996  TU Muenchen
nipkow@1496
     5
*)
nipkow@1496
     6
nipkow@1496
     7
open RelPow;
nipkow@1496
     8
paulson@3371
     9
goal RelPow.thy "!!R:: ('a*'a)set. R^1 = R";
pusch@2741
    10
by (Simp_tac 1);
nipkow@1693
    11
qed "rel_pow_1";
nipkow@1693
    12
Addsimps [rel_pow_1];
nipkow@1693
    13
nipkow@1496
    14
goal RelPow.thy "(x,x) : R^0";
paulson@1552
    15
by (Simp_tac 1);
nipkow@1496
    16
qed "rel_pow_0_I";
nipkow@1496
    17
nipkow@1496
    18
goal RelPow.thy "!!R. [| (x,y) : R^n; (y,z):R |] ==> (x,z):R^(Suc n)";
pusch@2741
    19
by (Simp_tac  1);
paulson@2922
    20
by (Blast_tac 1);
nipkow@1496
    21
qed "rel_pow_Suc_I";
nipkow@1496
    22
nipkow@1496
    23
goal RelPow.thy "!z. (x,y) : R --> (y,z):R^n -->  (x,z):R^(Suc n)";
paulson@1552
    24
by (nat_ind_tac "n" 1);
pusch@2741
    25
by (Simp_tac  1);
pusch@2741
    26
by (Asm_full_simp_tac 1);
paulson@2922
    27
by (Blast_tac 1);
nipkow@1496
    28
qed_spec_mp "rel_pow_Suc_I2";
nipkow@1496
    29
nipkow@1515
    30
goal RelPow.thy "!!R. [| (x,y) : R^0; x=y ==> P |] ==> P";
paulson@1552
    31
by (Asm_full_simp_tac 1);
nipkow@1515
    32
qed "rel_pow_0_E";
nipkow@1515
    33
nipkow@1515
    34
val [major,minor] = goal RelPow.thy
nipkow@1515
    35
  "[| (x,z) : R^(Suc n);  !!y. [| (x,y) : R^n; (y,z) : R |] ==> P |] ==> P";
paulson@1552
    36
by (cut_facts_tac [major] 1);
pusch@2741
    37
by (Asm_full_simp_tac  1);
wenzelm@4089
    38
by (blast_tac (claset() addIs [minor]) 1);
nipkow@1515
    39
qed "rel_pow_Suc_E";
nipkow@1515
    40
nipkow@1515
    41
val [p1,p2,p3] = goal RelPow.thy
nipkow@1515
    42
    "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;        \
nipkow@1515
    43
\       !!y m. [| n = Suc m; (x,y) : R^m; (y,z) : R |] ==> P  \
nipkow@1515
    44
\    |] ==> P";
paulson@1552
    45
by (res_inst_tac [("n","n")] natE 1);
paulson@1552
    46
by (cut_facts_tac [p1] 1);
wenzelm@4089
    47
by (asm_full_simp_tac (simpset() addsimps [p2]) 1);
paulson@1552
    48
by (cut_facts_tac [p1] 1);
paulson@1552
    49
by (Asm_full_simp_tac 1);
pusch@2741
    50
by (etac compEpair 1);
paulson@1552
    51
by (REPEAT(ares_tac [p3] 1));
nipkow@1515
    52
qed "rel_pow_E";
nipkow@1515
    53
nipkow@1496
    54
goal RelPow.thy "!x z. (x,z):R^(Suc n) --> (? y. (x,y):R & (y,z):R^n)";
paulson@1552
    55
by (nat_ind_tac "n" 1);
wenzelm@4089
    56
by (blast_tac (claset() addIs [rel_pow_0_I] addEs [rel_pow_0_E,rel_pow_Suc_E]) 1);
wenzelm@4089
    57
by (blast_tac (claset() addIs [rel_pow_Suc_I] addEs[rel_pow_0_E,rel_pow_Suc_E]) 1);
nipkow@1515
    58
qed_spec_mp "rel_pow_Suc_D2";
nipkow@1496
    59
pusch@2741
    60
pusch@2741
    61
goal RelPow.thy
pusch@2741
    62
"!x y z. (x,y) : R^n & (y,z) : R --> (? w. (x,w) : R & (w,z) : R^n)";
pusch@2741
    63
by (nat_ind_tac "n" 1);
wenzelm@4089
    64
by (fast_tac (claset() addss (simpset())) 1);
wenzelm@4089
    65
by (fast_tac (claset() addss (simpset())) 1);
pusch@2741
    66
qed_spec_mp "rel_pow_Suc_D2'";
pusch@2741
    67
nipkow@1496
    68
val [p1,p2,p3] = goal RelPow.thy
nipkow@1496
    69
    "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;        \
nipkow@1496
    70
\       !!y m. [| n = Suc m; (x,y) : R; (y,z) : R^m |] ==> P  \
nipkow@1496
    71
\    |] ==> P";
paulson@1552
    72
by (res_inst_tac [("n","n")] natE 1);
paulson@1552
    73
by (cut_facts_tac [p1] 1);
wenzelm@4089
    74
by (asm_full_simp_tac (simpset() addsimps [p2]) 1);
paulson@1552
    75
by (cut_facts_tac [p1] 1);
paulson@1552
    76
by (Asm_full_simp_tac 1);
paulson@3023
    77
by (etac compEpair 1);
pusch@2741
    78
by (dtac (conjI RS rel_pow_Suc_D2') 1);
paulson@3023
    79
by (assume_tac 1);
paulson@1552
    80
by (etac exE 1);
paulson@1552
    81
by (etac p3 1);
paulson@1552
    82
by (etac conjunct1 1);
paulson@1552
    83
by (etac conjunct2 1);
nipkow@1515
    84
qed "rel_pow_E2";
nipkow@1496
    85
nipkow@1496
    86
goal RelPow.thy "!!p. p:R^* ==> p : (UN n. R^n)";
paulson@1552
    87
by (split_all_tac 1);
paulson@1552
    88
by (etac rtrancl_induct 1);
wenzelm@4089
    89
by (ALLGOALS (blast_tac (claset() addIs [rel_pow_0_I,rel_pow_Suc_I])));
nipkow@1496
    90
qed "rtrancl_imp_UN_rel_pow";
nipkow@1496
    91
nipkow@1496
    92
goal RelPow.thy "!y. (x,y):R^n --> (x,y):R^*";
paulson@1552
    93
by (nat_ind_tac "n" 1);
wenzelm@4089
    94
by (blast_tac (claset() addIs [rtrancl_refl] addEs [rel_pow_0_E]) 1);
wenzelm@4089
    95
by (blast_tac (claset() addEs [rel_pow_Suc_E]
paulson@3023
    96
                       addIs [rtrancl_into_rtrancl]) 1);
nipkow@1496
    97
val lemma = result() RS spec RS mp;
nipkow@1496
    98
nipkow@1496
    99
goal RelPow.thy "!!p. p:R^n ==> p:R^*";
paulson@1552
   100
by (split_all_tac 1);
paulson@1552
   101
by (etac lemma 1);
nipkow@1515
   102
qed "rel_pow_imp_rtrancl";
nipkow@1496
   103
nipkow@1496
   104
goal RelPow.thy "R^* = (UN n. R^n)";
wenzelm@4089
   105
by (blast_tac (claset() addIs [rtrancl_imp_UN_rel_pow, rel_pow_imp_rtrancl]) 1);
nipkow@1496
   106
qed "rtrancl_is_UN_rel_pow";
pusch@2741
   107
pusch@2741
   108
pusch@2741
   109