src/HOL/Wellfounded_Relations.ML
author nipkow
Wed, 13 Dec 2000 09:32:55 +0100
changeset 10653 55f33da63366
parent 10231 178a272bceeb
child 10996 74e970389def
permissions -rw-r--r--
small mods.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     1
(*  Title: 	HOL/Wellfounded_Relations
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     2
    ID:         $Id$
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     3
    Author: 	Konrad Slind
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     4
    Copyright   1996  TU Munich
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     5
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     6
Derived WF relations: inverse image, lexicographic product, measure, ...
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     7
*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     8
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     9
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    10
(*----------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    11
 * "Less than" on the natural numbers
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    12
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    13
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    14
Goalw [less_than_def] "wf less_than"; 
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    15
by (rtac (wf_pred_nat RS wf_trancl) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    16
qed "wf_less_than";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    17
AddIffs [wf_less_than];
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    18
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    19
Goalw [less_than_def] "trans less_than"; 
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    20
by (rtac trans_trancl 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    21
qed "trans_less_than";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    22
AddIffs [trans_less_than];
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    23
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    24
Goalw [less_than_def, less_def] "((x,y): less_than) = (x<y)"; 
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    25
by (Simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    26
qed "less_than_iff";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    27
AddIffs [less_than_iff];
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    28
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    29
Goal "(!!n. (ALL m. Suc m <= n --> P m) ==> P n) ==> P n";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    30
by (rtac (wf_less_than RS wf_induct) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    31
by (resolve_tac (premises()) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    32
by Auto_tac;
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    33
qed_spec_mp "full_nat_induct";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    34
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    35
(*----------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    36
 * The inverse image into a wellfounded relation is wellfounded.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    37
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    38
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    39
Goal "wf(r) ==> wf(inv_image r (f::'a=>'b))"; 
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    40
by (full_simp_tac (simpset() addsimps [inv_image_def, wf_eq_minimal]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    41
by (Clarify_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    42
by (subgoal_tac "EX (w::'b). w : {w. EX (x::'a). x: Q & (f x = w)}" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    43
by (blast_tac (claset() delrules [allE]) 2);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    44
by (etac allE 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    45
by (mp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    46
by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    47
qed "wf_inv_image";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    48
AddSIs [wf_inv_image];
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    49
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    50
Goalw [trans_def,inv_image_def]
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    51
    "!!r. trans r ==> trans (inv_image r f)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    52
by (Simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    53
by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    54
qed "trans_inv_image";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    55
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    56
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    57
(*----------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    58
 * All measures are wellfounded.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    59
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    60
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    61
Goalw [measure_def] "wf (measure f)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    62
by (rtac (wf_less_than RS wf_inv_image) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    63
qed "wf_measure";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    64
AddIffs [wf_measure];
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    65
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    66
val measure_induct = standard
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    67
    (asm_full_simplify (simpset() addsimps [measure_def,inv_image_def])
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    68
      (wf_measure RS wf_induct));
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    69
bind_thm ("measure_induct", measure_induct);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    70
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    71
(*----------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    72
 * Wellfoundedness of lexicographic combinations
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    73
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    74
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    75
val [wfa,wfb] = goalw (the_context ()) [wf_def,lex_prod_def]
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    76
 "[| wf(ra); wf(rb) |] ==> wf(ra <*lex*> rb)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    77
by (EVERY1 [rtac allI,rtac impI]);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    78
by (simp_tac (HOL_basic_ss addsimps [split_paired_All]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    79
by (rtac (wfa RS spec RS mp) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    80
by (EVERY1 [rtac allI,rtac impI]);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    81
by (rtac (wfb RS spec RS mp) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    82
by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    83
qed "wf_lex_prod";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    84
AddSIs [wf_lex_prod];
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    85
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    86
(*---------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    87
 * Transitivity of WF combinators.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    88
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    89
Goalw [trans_def, lex_prod_def]
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    90
    "!!R1 R2. [| trans R1; trans R2 |] ==> trans (R1 <*lex*> R2)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    91
by (Simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    92
by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    93
qed "trans_lex_prod";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    94
AddSIs [trans_lex_prod];
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    95
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    96
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    97
(*---------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    98
 * Wellfoundedness of proper subset on finite sets.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    99
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   100
Goalw [finite_psubset_def] "wf(finite_psubset)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   101
by (rtac (wf_measure RS wf_subset) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   102
by (simp_tac (simpset() addsimps [measure_def, inv_image_def, less_than_def,
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   103
				 symmetric less_def])1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   104
by (fast_tac (claset() addSEs [psubset_card_mono]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   105
qed "wf_finite_psubset";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   106
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   107
Goalw [finite_psubset_def, trans_def] "trans finite_psubset";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   108
by (simp_tac (simpset() addsimps [psubset_def]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   109
by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   110
qed "trans_finite_psubset";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   111
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   112
(*---------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   113
 * Wellfoundedness of finite acyclic relations
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   114
 * Cannot go into WF because it needs Finite.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   115
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   116
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   117
Goal "finite r ==> acyclic r --> wf r";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   118
by (etac finite_induct 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   119
 by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   120
by (split_all_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   121
by (Asm_full_simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   122
qed_spec_mp "finite_acyclic_wf";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   123
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   124
Goal "[|finite r; acyclic r|] ==> wf (r^-1)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   125
by (etac (finite_converse RS iffD2 RS finite_acyclic_wf) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   126
by (etac (acyclic_converse RS iffD2) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   127
qed "finite_acyclic_wf_converse";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   128
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   129
Goal "finite r ==> wf r = acyclic r";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   130
by (blast_tac (claset() addIs [finite_acyclic_wf,wf_acyclic]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   131
qed "wf_iff_acyclic_if_finite";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   132
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   133
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   134
(*---------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   135
 * A relation is wellfounded iff it has no infinite descending chain
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   136
 * Cannot go into WF because it needs type nat.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   137
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   138
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   139
Goalw [wf_eq_minimal RS eq_reflection]
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   140
  "wf r = (~(EX f. ALL i. (f(Suc i),f i) : r))";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   141
by (rtac iffI 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   142
 by (rtac notI 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   143
 by (etac exE 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   144
 by (eres_inst_tac [("x","{w. EX i. w=f i}")] allE 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   145
 by (Blast_tac 1);
10231
178a272bceeb renaming of contrapos rules
paulson
parents: 10213
diff changeset
   146
by (etac contrapos_np 1);
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   147
by (Asm_full_simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   148
by (Clarify_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   149
by (subgoal_tac "ALL n. nat_rec x (%i y. @z. z:Q & (z,y):r) n : Q" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   150
 by (res_inst_tac[("x","nat_rec x (%i y. @z. z:Q & (z,y):r)")]exI 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   151
 by (rtac allI 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   152
 by (Simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   153
 by (rtac someI2_ex 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   154
  by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   155
 by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   156
by (rtac allI 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   157
by (induct_tac "n" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   158
 by (Asm_simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   159
by (Simp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   160
by (rtac someI2_ex 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   161
 by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   162
by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   163
qed "wf_iff_no_infinite_down_chain";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   164
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   165
(*----------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   166
 * Weakly decreasing sequences (w.r.t. some well-founded order) stabilize.
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   167
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   168
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   169
Goal "[| ALL i. (f (Suc i), f i) : r^* |] ==> (f (i+k), f i) : r^*";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   170
by (induct_tac "k" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   171
 by (ALLGOALS Simp_tac);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   172
by (blast_tac (claset() addIs [rtrancl_trans]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   173
val lemma = result();
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   174
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   175
Goal "[| ALL i. (f (Suc i), f i) : r^*; wf (r^+) |] \
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   176
\     ==> ALL m. f m = x --> (EX i. ALL k. f (m+i+k) = f (m+i))";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   177
by (etac wf_induct 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   178
by (Clarify_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   179
by (case_tac "EX j. (f (m+j), f m) : r^+" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   180
 by (Clarify_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   181
 by (subgoal_tac "EX i. ALL k. f ((m+j)+i+k) = f ((m+j)+i)" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   182
  by (Clarify_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   183
  by (res_inst_tac [("x","j+i")] exI 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   184
  by (asm_full_simp_tac (simpset() addsimps add_ac) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   185
 by (Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   186
by (res_inst_tac [("x","0")] exI 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   187
by (Clarsimp_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   188
by (dres_inst_tac [("i","m"), ("k","k")] lemma 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   189
by (blast_tac (claset() addEs [rtranclE] addDs [rtrancl_into_trancl1]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   190
val lemma = result();
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   191
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   192
Goal "[| ALL i. (f (Suc i), f i) : r^*; wf (r^+) |] \
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   193
\     ==> EX i. ALL k. f (i+k) = f i";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   194
by (dres_inst_tac [("x","0")] (lemma RS spec) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   195
by Auto_tac;
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   196
qed "wf_weak_decr_stable";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   197
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   198
(* special case: <= *)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   199
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   200
Goal "(m, n) : pred_nat^* = (m <= n)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   201
by (simp_tac (simpset() addsimps [less_eq, reflcl_trancl RS sym] 
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   202
                        delsimps [reflcl_trancl]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   203
by (arith_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   204
qed "le_eq";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   205
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   206
Goal "ALL i. f (Suc i) <= ((f i)::nat) ==> EX i. ALL k. f (i+k) = f i";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   207
by (res_inst_tac [("r","pred_nat")] wf_weak_decr_stable 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   208
by (asm_simp_tac (simpset() addsimps [le_eq]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   209
by (REPEAT (resolve_tac [wf_trancl,wf_pred_nat] 1));
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   210
qed "weak_decr_stable";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   211
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   212
(*----------------------------------------------------------------------------
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   213
 * Wellfoundedness of same_fst
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   214
 *---------------------------------------------------------------------------*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   215
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   216
val prems = goalw thy [same_fst_def]
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   217
  "(!!x. P x ==> wf(R x)) ==> wf(same_fst P R)";
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   218
by(full_simp_tac (simpset() delcongs [imp_cong] addsimps [wf_def]) 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   219
by(strip_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   220
by(rename_tac "a b" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   221
by(case_tac "wf(R a)" 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   222
 by (eres_inst_tac [("a","b")] wf_induct 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   223
 by (EVERY1[etac allE, etac allE, etac mp, rtac allI, rtac allI]);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   224
 by(Blast_tac 1);
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   225
by(blast_tac (claset() addIs prems) 1);
10653
55f33da63366 small mods.
nipkow
parents: 10231
diff changeset
   226
qed "wf_same_fst";