src/HOL/RelPow.ML
author wenzelm
Thu Jan 23 14:19:16 1997 +0100 (1997-01-23)
changeset 2545 d10abc8c11fb
parent 2056 93c093620c28
child 2741 2b7f72cbe51f
permissions -rw-r--r--
added AxClasses test;
     1 (*  Title:      HOL/RelPow.ML
     2     ID:         $Id$
     3     Author:     Tobias Nipkow
     4     Copyright   1996  TU Muenchen
     5 *)
     6 
     7 open RelPow;
     8 
     9 val [rel_pow_0, rel_pow_Suc] = nat_recs rel_pow_def;
    10 Addsimps [rel_pow_0];
    11 
    12 goal RelPow.thy "R^1 = R";
    13 by (simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
    14 qed "rel_pow_1";
    15 Addsimps [rel_pow_1];
    16 
    17 goal RelPow.thy "(x,x) : R^0";
    18 by (Simp_tac 1);
    19 qed "rel_pow_0_I";
    20 
    21 goal RelPow.thy "!!R. [| (x,y) : R^n; (y,z):R |] ==> (x,z):R^(Suc n)";
    22 by (simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
    23 by (Fast_tac 1);
    24 qed "rel_pow_Suc_I";
    25 
    26 goal RelPow.thy "!z. (x,y) : R --> (y,z):R^n -->  (x,z):R^(Suc n)";
    27 by (nat_ind_tac "n" 1);
    28 by (simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
    29 by (asm_full_simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
    30 by (Fast_tac 1);
    31 qed_spec_mp "rel_pow_Suc_I2";
    32 
    33 goal RelPow.thy "!!R. [| (x,y) : R^0; x=y ==> P |] ==> P";
    34 by (Asm_full_simp_tac 1);
    35 qed "rel_pow_0_E";
    36 
    37 val [major,minor] = goal RelPow.thy
    38   "[| (x,z) : R^(Suc n);  !!y. [| (x,y) : R^n; (y,z) : R |] ==> P |] ==> P";
    39 by (cut_facts_tac [major] 1);
    40 by (asm_full_simp_tac (!simpset addsimps [rel_pow_Suc]) 1);
    41 by (fast_tac (!claset addIs [minor]) 1);
    42 qed "rel_pow_Suc_E";
    43 
    44 val [p1,p2,p3] = goal RelPow.thy
    45     "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;        \
    46 \       !!y m. [| n = Suc m; (x,y) : R^m; (y,z) : R |] ==> P  \
    47 \    |] ==> P";
    48 by (res_inst_tac [("n","n")] natE 1);
    49 by (cut_facts_tac [p1] 1);
    50 by (asm_full_simp_tac (!simpset addsimps [p2]) 1);
    51 by (cut_facts_tac [p1] 1);
    52 by (Asm_full_simp_tac 1);
    53 by (etac rel_pow_Suc_E 1);
    54 by (REPEAT(ares_tac [p3] 1));
    55 qed "rel_pow_E";
    56 
    57 goal RelPow.thy "!x z. (x,z):R^(Suc n) --> (? y. (x,y):R & (y,z):R^n)";
    58 by (nat_ind_tac "n" 1);
    59 by (fast_tac (!claset addIs [rel_pow_0_I] addEs [rel_pow_0_E,rel_pow_Suc_E]) 1);
    60 by (fast_tac (!claset addIs [rel_pow_Suc_I] addEs[rel_pow_0_E,rel_pow_Suc_E]) 1);
    61 qed_spec_mp "rel_pow_Suc_D2";
    62 
    63 val [p1,p2,p3] = goal RelPow.thy
    64     "[| (x,z) : R^n;  [| n=0; x = z |] ==> P;        \
    65 \       !!y m. [| n = Suc m; (x,y) : R; (y,z) : R^m |] ==> P  \
    66 \    |] ==> P";
    67 by (res_inst_tac [("n","n")] natE 1);
    68 by (cut_facts_tac [p1] 1);
    69 by (asm_full_simp_tac (!simpset addsimps [p2]) 1);
    70 by (cut_facts_tac [p1] 1);
    71 by (Asm_full_simp_tac 1);
    72 by (dtac rel_pow_Suc_D2 1);
    73 by (etac exE 1);
    74 by (etac p3 1);
    75 by (etac conjunct1 1);
    76 by (etac conjunct2 1);
    77 qed "rel_pow_E2";
    78 
    79 goal RelPow.thy "!!p. p:R^* ==> p : (UN n. R^n)";
    80 by (split_all_tac 1);
    81 by (etac rtrancl_induct 1);
    82 by (ALLGOALS (fast_tac (!claset addIs [rel_pow_0_I,rel_pow_Suc_I])));
    83 qed "rtrancl_imp_UN_rel_pow";
    84 
    85 goal RelPow.thy "!y. (x,y):R^n --> (x,y):R^*";
    86 by (nat_ind_tac "n" 1);
    87 by (fast_tac (!claset addIs [rtrancl_refl] addEs [rel_pow_0_E]) 1);
    88 by (fast_tac (!claset addEs [rel_pow_Suc_E,rtrancl_into_rtrancl]) 1);
    89 val lemma = result() RS spec RS mp;
    90 
    91 goal RelPow.thy "!!p. p:R^n ==> p:R^*";
    92 by (split_all_tac 1);
    93 by (etac lemma 1);
    94 qed "rel_pow_imp_rtrancl";
    95 
    96 goal RelPow.thy "R^* = (UN n. R^n)";
    97 by (fast_tac (!claset addIs [rtrancl_imp_UN_rel_pow,rel_pow_imp_rtrancl]) 1);
    98 qed "rtrancl_is_UN_rel_pow";