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