src/HOL/WF_Rel.ML
author paulson
Thu Jan 08 18:10:34 1998 +0100 (1998-01-08)
changeset 4537 4e835bd9fada
parent 4089 96fba19bcbe2
child 4643 1b40fcac5a09
permissions -rw-r--r--
Expressed most Oops rules using Notes instead of Says, and other tidying
paulson@3193
     1
(*  Title: 	HOL/WF_Rel
paulson@3193
     2
    ID:         $Id$
paulson@3193
     3
    Author: 	Konrad Slind
paulson@3193
     4
    Copyright   1996  TU Munich
paulson@3193
     5
paulson@3296
     6
Derived WF relations: inverse image, lexicographic product, measure, ...
paulson@3193
     7
*)
paulson@3193
     8
paulson@3193
     9
open WF_Rel;
paulson@3193
    10
paulson@3193
    11
paulson@3193
    12
(*----------------------------------------------------------------------------
paulson@3237
    13
 * "Less than" on the natural numbers
paulson@3237
    14
 *---------------------------------------------------------------------------*)
paulson@3237
    15
paulson@3237
    16
goalw thy [less_than_def] "wf less_than"; 
paulson@3237
    17
by (rtac (wf_pred_nat RS wf_trancl) 1);
paulson@3237
    18
qed "wf_less_than";
paulson@3237
    19
AddIffs [wf_less_than];
paulson@3237
    20
paulson@3237
    21
goalw thy [less_than_def] "trans less_than"; 
paulson@3237
    22
by (rtac trans_trancl 1);
paulson@3237
    23
qed "trans_less_than";
paulson@3237
    24
AddIffs [trans_less_than];
paulson@3237
    25
paulson@3237
    26
goalw thy [less_than_def, less_def] "((x,y): less_than) = (x<y)"; 
paulson@3237
    27
by (Simp_tac 1);
paulson@3237
    28
qed "less_than_iff";
paulson@3237
    29
AddIffs [less_than_iff];
paulson@3237
    30
paulson@3237
    31
(*----------------------------------------------------------------------------
paulson@3193
    32
 * The inverse image into a wellfounded relation is wellfounded.
paulson@3193
    33
 *---------------------------------------------------------------------------*)
paulson@3193
    34
paulson@3193
    35
goal thy "!!r. wf(r) ==> wf(inv_image r (f::'a=>'b))"; 
wenzelm@4089
    36
by (full_simp_tac (simpset() addsimps [inv_image_def, wf_eq_minimal]) 1);
paulson@3718
    37
by (Clarify_tac 1);
paulson@3193
    38
by (subgoal_tac "? (w::'b). w : {w. ? (x::'a). x: Q & (f x = w)}" 1);
wenzelm@4089
    39
by (blast_tac (claset() delrules [allE]) 2);
paulson@3193
    40
by (etac allE 1);
paulson@3193
    41
by (mp_tac 1);
paulson@3193
    42
by (Blast_tac 1);
paulson@3193
    43
qed "wf_inv_image";
paulson@3193
    44
AddSIs [wf_inv_image];
paulson@3193
    45
paulson@3237
    46
goalw thy [trans_def,inv_image_def]
paulson@3237
    47
    "!!r. trans r ==> trans (inv_image r f)";
paulson@3237
    48
by (Simp_tac 1);
paulson@3237
    49
by (Blast_tac 1);
paulson@3237
    50
qed "trans_inv_image";
paulson@3237
    51
paulson@3237
    52
paulson@3193
    53
(*----------------------------------------------------------------------------
paulson@3193
    54
 * All measures are wellfounded.
paulson@3193
    55
 *---------------------------------------------------------------------------*)
paulson@3193
    56
paulson@3193
    57
goalw thy [measure_def] "wf (measure f)";
paulson@3237
    58
by (rtac (wf_less_than RS wf_inv_image) 1);
paulson@3193
    59
qed "wf_measure";
paulson@3193
    60
AddIffs [wf_measure];
paulson@3193
    61
paulson@3193
    62
(*----------------------------------------------------------------------------
paulson@3193
    63
 * Wellfoundedness of lexicographic combinations
paulson@3193
    64
 *---------------------------------------------------------------------------*)
paulson@3193
    65
paulson@3193
    66
val [wfa,wfb] = goalw thy [wf_def,lex_prod_def]
paulson@3193
    67
 "[| wf(ra); wf(rb) |] ==> wf(ra**rb)";
nipkow@3413
    68
by (EVERY1 [rtac allI,rtac impI]);
nipkow@3413
    69
by (simp_tac (HOL_basic_ss addsimps [split_paired_All]) 1);
paulson@3193
    70
by (rtac (wfa RS spec RS mp) 1);
paulson@3193
    71
by (EVERY1 [rtac allI,rtac impI]);
paulson@3193
    72
by (rtac (wfb RS spec RS mp) 1);
paulson@3193
    73
by (Blast_tac 1);
paulson@3193
    74
qed "wf_lex_prod";
paulson@3193
    75
AddSIs [wf_lex_prod];
paulson@3193
    76
paulson@3193
    77
(*---------------------------------------------------------------------------
paulson@3193
    78
 * Transitivity of WF combinators.
paulson@3193
    79
 *---------------------------------------------------------------------------*)
paulson@3193
    80
goalw thy [trans_def, lex_prod_def]
paulson@3193
    81
    "!!R1 R2. [| trans R1; trans R2 |] ==> trans (R1 ** R2)";
paulson@3193
    82
by (Simp_tac 1);
paulson@3193
    83
by (Blast_tac 1);
paulson@3193
    84
qed "trans_lex_prod";
paulson@3193
    85
AddSIs [trans_lex_prod];
paulson@3193
    86
paulson@3193
    87
paulson@3193
    88
(*---------------------------------------------------------------------------
paulson@3193
    89
 * Wellfoundedness of proper subset on finite sets.
paulson@3193
    90
 *---------------------------------------------------------------------------*)
paulson@3193
    91
goalw thy [finite_psubset_def] "wf(finite_psubset)";
paulson@3193
    92
by (rtac (wf_measure RS wf_subset) 1);
wenzelm@4089
    93
by (simp_tac (simpset() addsimps [measure_def, inv_image_def, less_than_def,
paulson@3237
    94
				 symmetric less_def])1);
wenzelm@4089
    95
by (fast_tac (claset() addSIs [psubset_card]) 1);
paulson@3193
    96
qed "wf_finite_psubset";
paulson@3193
    97
paulson@3237
    98
goalw thy [finite_psubset_def, trans_def] "trans finite_psubset";
wenzelm@4089
    99
by (simp_tac (simpset() addsimps [psubset_def]) 1);
paulson@3237
   100
by (Blast_tac 1);
paulson@3237
   101
qed "trans_finite_psubset";
paulson@3193
   102
nipkow@3413
   103
(*---------------------------------------------------------------------------
nipkow@3413
   104
 * Wellfoundedness of finite acyclic relations
nipkow@3413
   105
 * Cannot go into WF because it needs Finite
nipkow@3413
   106
 *---------------------------------------------------------------------------*)
nipkow@3413
   107
nipkow@3413
   108
goal thy "!!r. finite r ==> acyclic r --> wf r";
paulson@3457
   109
by (etac finite_induct 1);
paulson@3457
   110
 by (Blast_tac 1);
paulson@3457
   111
by (split_all_tac 1);
paulson@3457
   112
by (Asm_full_simp_tac 1);
nipkow@3413
   113
qed_spec_mp "finite_acyclic_wf";
nipkow@3413
   114
nipkow@3413
   115
goal thy "!!r. finite r ==> wf r = acyclic r";
wenzelm@4089
   116
by (blast_tac (claset() addIs [finite_acyclic_wf,wf_acyclic]) 1);
nipkow@3413
   117
qed "wf_iff_acyclic_if_finite";
nipkow@3413
   118
nipkow@3413
   119
nipkow@3413
   120
(*---------------------------------------------------------------------------
nipkow@3413
   121
 * A relation is wellfounded iff it has no infinite descending chain
nipkow@3413
   122
 *---------------------------------------------------------------------------*)
nipkow@3413
   123
nipkow@3413
   124
goalw thy [wf_eq_minimal RS eq_reflection]
nipkow@3413
   125
  "wf r = (~(? f. !i. (f(Suc i),f i) : r))";
paulson@3457
   126
by (rtac iffI 1);
paulson@3457
   127
 by (rtac notI 1);
paulson@3457
   128
 by (etac exE 1);
paulson@3457
   129
 by (eres_inst_tac [("x","{w. ? i. w=f i}")] allE 1);
paulson@3457
   130
 by (Blast_tac 1);
paulson@3457
   131
by (etac swap 1);
paulson@3446
   132
by (Asm_full_simp_tac 1);
paulson@3718
   133
by (Clarify_tac 1);
paulson@3457
   134
by (subgoal_tac "!n. nat_rec x (%i y. @z. z:Q & (z,y):r) n : Q" 1);
nipkow@3436
   135
 by (res_inst_tac[("x","nat_rec x (%i y. @z. z:Q & (z,y):r)")]exI 1);
paulson@3457
   136
 by (rtac allI 1);
paulson@3457
   137
 by (Simp_tac 1);
paulson@3457
   138
 by (rtac selectI2EX 1);
paulson@3457
   139
  by (Blast_tac 1);
paulson@3457
   140
 by (Blast_tac 1);
paulson@3457
   141
by (rtac allI 1);
paulson@3457
   142
by (induct_tac "n" 1);
paulson@3457
   143
 by (Asm_simp_tac 1);
paulson@3457
   144
by (Simp_tac 1);
paulson@3457
   145
by (rtac selectI2EX 1);
paulson@3457
   146
 by (Blast_tac 1);
paulson@3457
   147
by (Blast_tac 1);
nipkow@3413
   148
qed "wf_iff_no_infinite_down_chain";