src/HOL/Hilbert_Choice.thy
author paulson
Wed Jul 25 17:58:26 2001 +0200 (2001-07-25)
changeset 11454 7514e5e21cb8
parent 11451 8abfb4f7bd02
child 11506 244a02a2968b
permissions -rw-r--r--
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson@11451
     1
(*  Title:      HOL/Hilbert_Choice.thy
paulson@11451
     2
    ID:         $Id$
paulson@11451
     3
    Author:     Lawrence C Paulson
paulson@11451
     4
    Copyright   2001  University of Cambridge
paulson@11451
     5
paulson@11451
     6
Hilbert's epsilon-operator and everything to do with the Axiom of Choice
paulson@11451
     7
*)
paulson@11451
     8
paulson@11451
     9
theory Hilbert_Choice = NatArith
paulson@11451
    10
files ("Hilbert_Choice_lemmas.ML") ("meson_lemmas.ML") ("Tools/meson.ML"):
paulson@11451
    11
paulson@11451
    12
consts
paulson@11451
    13
  Eps           :: "('a => bool) => 'a"
paulson@11451
    14
paulson@11451
    15
paulson@11451
    16
syntax (input)
paulson@11451
    17
  "_Eps"        :: "[pttrn, bool] => 'a"                 ("(3\\<epsilon>_./ _)" [0, 10] 10)
paulson@11451
    18
paulson@11451
    19
syntax (HOL)
paulson@11451
    20
  "_Eps"        :: "[pttrn, bool] => 'a"                 ("(3@ _./ _)" [0, 10] 10)
paulson@11451
    21
paulson@11451
    22
syntax
paulson@11451
    23
  "_Eps"        :: "[pttrn, bool] => 'a"                 ("(3SOME _./ _)" [0, 10] 10)
paulson@11451
    24
paulson@11451
    25
translations
paulson@11451
    26
  "SOME x. P"             == "Eps (%x. P)"
paulson@11451
    27
paulson@11451
    28
axioms  
paulson@11451
    29
  someI:        "P (x::'a) ==> P (SOME x. P x)"
paulson@11451
    30
paulson@11451
    31
paulson@11454
    32
(*used in TFL*)
paulson@11454
    33
lemma tfl_some: "\\<forall>P x. P x --> P (Eps P)"
paulson@11454
    34
  by (blast intro: someI)
paulson@11454
    35
paulson@11454
    36
paulson@11451
    37
constdefs  
paulson@11451
    38
  inv :: "('a => 'b) => ('b => 'a)"
paulson@11451
    39
    "inv(f::'a=>'b) == % y. @x. f(x)=y"
paulson@11451
    40
paulson@11451
    41
  Inv :: "['a set, 'a => 'b] => ('b => 'a)"
paulson@11451
    42
    "Inv A f == (% x. (@ y. y : A & f y = x))"
paulson@11451
    43
paulson@11451
    44
paulson@11451
    45
use "Hilbert_Choice_lemmas.ML"
paulson@11451
    46
paulson@11451
    47
paulson@11451
    48
(** Least value operator **)
paulson@11451
    49
paulson@11451
    50
constdefs
paulson@11451
    51
  LeastM   :: "['a => 'b::ord, 'a => bool] => 'a"
paulson@11451
    52
              "LeastM m P == @x. P x & (ALL y. P y --> m x <= m y)"
paulson@11451
    53
paulson@11451
    54
syntax
paulson@11451
    55
 "@LeastM" :: "[pttrn, 'a=>'b::ord, bool] => 'a" ("LEAST _ WRT _. _" [0,4,10]10)
paulson@11451
    56
paulson@11451
    57
translations
paulson@11451
    58
                "LEAST x WRT m. P" == "LeastM m (%x. P)"
paulson@11451
    59
paulson@11451
    60
lemma LeastMI2:
paulson@11451
    61
  "[| P x; !!y. P y ==> m x <= m y;
paulson@11451
    62
           !!x. [| P x; \\<forall>y. P y --> m x \\<le> m y |] ==> Q x |]
paulson@11451
    63
   ==> Q (LeastM m P)";
paulson@11451
    64
apply (unfold LeastM_def)
paulson@11451
    65
apply (rule someI2_ex)
paulson@11451
    66
apply  blast
paulson@11451
    67
apply blast
paulson@11451
    68
done
paulson@11451
    69
paulson@11451
    70
lemma LeastM_equality:
paulson@11451
    71
 "[| P k; !!x. P x ==> m k <= m x |] ==> m (LEAST x WRT m. P x) = 
paulson@11451
    72
     (m k::'a::order)";
paulson@11451
    73
apply (rule LeastMI2)
paulson@11451
    74
apply   assumption
paulson@11451
    75
apply  blast
paulson@11451
    76
apply (blast intro!: order_antisym) 
paulson@11451
    77
done
paulson@11451
    78
paulson@11454
    79
lemma wf_linord_ex_has_least:
paulson@11454
    80
     "[|wf r;  ALL x y. ((x,y):r^+) = ((y,x)~:r^*);  P k|]  \
paulson@11454
    81
\     ==> EX x. P x & (!y. P y --> (m x,m y):r^*)" 
paulson@11454
    82
apply (drule wf_trancl [THEN wf_eq_minimal [THEN iffD1]])
paulson@11454
    83
apply (drule_tac x = "m`Collect P" in spec)
paulson@11454
    84
apply force
paulson@11454
    85
done
paulson@11454
    86
paulson@11454
    87
(* successor of obsolete nonempty_has_least *)
paulson@11454
    88
lemma ex_has_least_nat:
paulson@11454
    89
     "P k ==> EX x. P x & (ALL y. P y --> m x <= (m y::nat))"
paulson@11454
    90
apply (simp only: pred_nat_trancl_eq_le [symmetric])
paulson@11454
    91
apply (rule wf_pred_nat [THEN wf_linord_ex_has_least])
paulson@11454
    92
apply (simp (no_asm) add: less_eq not_le_iff_less pred_nat_trancl_eq_le)
paulson@11454
    93
apply assumption
paulson@11454
    94
done
paulson@11454
    95
paulson@11454
    96
lemma LeastM_nat_lemma: 
paulson@11454
    97
  "P k ==> P (LeastM m P) & (ALL y. P y --> m (LeastM m P) <= (m y::nat))"
paulson@11454
    98
apply (unfold LeastM_def)
paulson@11454
    99
apply (rule someI_ex)
paulson@11454
   100
apply (erule ex_has_least_nat)
paulson@11454
   101
done
paulson@11454
   102
paulson@11454
   103
lemmas LeastM_natI = LeastM_nat_lemma [THEN conjunct1, standard]
paulson@11454
   104
paulson@11454
   105
lemma LeastM_nat_le: "P x ==> m (LeastM m P) <= (m x::nat)"
paulson@11454
   106
apply (rule LeastM_nat_lemma [THEN conjunct2, THEN spec, THEN mp])
paulson@11454
   107
apply assumption
paulson@11454
   108
apply assumption
paulson@11454
   109
done
paulson@11454
   110
paulson@11451
   111
paulson@11451
   112
(** Greatest value operator **)
paulson@11451
   113
paulson@11451
   114
constdefs
paulson@11451
   115
  GreatestM   :: "['a => 'b::ord, 'a => bool] => 'a"
paulson@11451
   116
              "GreatestM m P == @x. P x & (ALL y. P y --> m y <= m x)"
paulson@11451
   117
  
paulson@11451
   118
  Greatest    :: "('a::ord => bool) => 'a"         (binder "GREATEST " 10)
paulson@11451
   119
              "Greatest     == GreatestM (%x. x)"
paulson@11451
   120
paulson@11451
   121
syntax
paulson@11451
   122
 "@GreatestM" :: "[pttrn, 'a=>'b::ord, bool] => 'a"
paulson@11451
   123
                                        ("GREATEST _ WRT _. _" [0,4,10]10)
paulson@11451
   124
paulson@11451
   125
translations
paulson@11451
   126
              "GREATEST x WRT m. P" == "GreatestM m (%x. P)"
paulson@11451
   127
paulson@11451
   128
lemma GreatestMI2:
paulson@11451
   129
     "[| P x;
paulson@11451
   130
	 !!y. P y ==> m y <= m x;
paulson@11451
   131
         !!x. [| P x; \\<forall>y. P y --> m y \\<le> m x |] ==> Q x |]
paulson@11451
   132
      ==> Q (GreatestM m P)";
paulson@11451
   133
apply (unfold GreatestM_def)
paulson@11451
   134
apply (rule someI2_ex)
paulson@11451
   135
apply  blast
paulson@11451
   136
apply blast
paulson@11451
   137
done
paulson@11451
   138
paulson@11451
   139
lemma GreatestM_equality:
paulson@11451
   140
 "[| P k;  !!x. P x ==> m x <= m k |]
paulson@11451
   141
  ==> m (GREATEST x WRT m. P x) = (m k::'a::order)";
paulson@11451
   142
apply (rule_tac m=m in GreatestMI2)
paulson@11451
   143
apply   assumption
paulson@11451
   144
apply  blast
paulson@11451
   145
apply (blast intro!: order_antisym) 
paulson@11451
   146
done
paulson@11451
   147
paulson@11451
   148
lemma Greatest_equality:
paulson@11451
   149
  "[| P (k::'a::order); !!x. P x ==> x <= k |] ==> (GREATEST x. P x) = k";
paulson@11451
   150
apply (unfold Greatest_def)
paulson@11451
   151
apply (erule GreatestM_equality)
paulson@11451
   152
apply blast
paulson@11451
   153
done
paulson@11451
   154
paulson@11451
   155
lemma ex_has_greatest_nat_lemma:
paulson@11451
   156
     "[|P k;  ALL x. P x --> (EX y. P y & ~ ((m y::nat) <= m x))|]  
paulson@11451
   157
      ==> EX y. P y & ~ (m y < m k + n)"
paulson@11451
   158
apply (induct_tac "n")
paulson@11451
   159
apply force
paulson@11451
   160
(*ind step*)
paulson@11451
   161
apply (force simp add: le_Suc_eq)
paulson@11451
   162
done
paulson@11451
   163
paulson@11451
   164
lemma ex_has_greatest_nat: "[|P k;  ! y. P y --> m y < b|]  
paulson@11451
   165
      ==> ? x. P x & (! y. P y --> (m y::nat) <= m x)"
paulson@11451
   166
apply (rule ccontr)
paulson@11451
   167
apply (cut_tac P = "P" and n = "b - m k" in ex_has_greatest_nat_lemma)
paulson@11451
   168
apply (subgoal_tac [3] "m k <= b")
paulson@11451
   169
apply auto
paulson@11451
   170
done
paulson@11451
   171
paulson@11451
   172
lemma GreatestM_nat_lemma: 
paulson@11451
   173
     "[|P k;  ! y. P y --> m y < b|]  
paulson@11451
   174
      ==> P (GreatestM m P) & (!y. P y --> (m y::nat) <= m (GreatestM m P))"
paulson@11451
   175
apply (unfold GreatestM_def)
paulson@11451
   176
apply (rule someI_ex)
paulson@11451
   177
apply (erule ex_has_greatest_nat)
paulson@11451
   178
apply assumption
paulson@11451
   179
done
paulson@11451
   180
paulson@11451
   181
lemmas GreatestM_natI = GreatestM_nat_lemma [THEN conjunct1, standard]
paulson@11451
   182
paulson@11451
   183
lemma GreatestM_nat_le: "[|P x;  ! y. P y --> m y < b|]  
paulson@11451
   184
      ==> (m x::nat) <= m (GreatestM m P)"
paulson@11451
   185
apply (blast dest: GreatestM_nat_lemma [THEN conjunct2, THEN spec]) 
paulson@11451
   186
done
paulson@11451
   187
paulson@11451
   188
(** Specialization to GREATEST **)
paulson@11451
   189
paulson@11451
   190
lemma GreatestI: 
paulson@11451
   191
     "[|P (k::nat);  ! y. P y --> y < b|] ==> P (GREATEST x. P x)"
paulson@11451
   192
paulson@11451
   193
apply (unfold Greatest_def)
paulson@11451
   194
apply (rule GreatestM_natI)
paulson@11451
   195
apply auto
paulson@11451
   196
done
paulson@11451
   197
paulson@11451
   198
lemma Greatest_le: 
paulson@11451
   199
     "[|P x;  ! y. P y --> y < b|] ==> (x::nat) <= (GREATEST x. P x)"
paulson@11451
   200
apply (unfold Greatest_def)
paulson@11451
   201
apply (rule GreatestM_nat_le)
paulson@11451
   202
apply auto
paulson@11451
   203
done
paulson@11451
   204
paulson@11451
   205
paulson@11451
   206
ML {*
paulson@11451
   207
val LeastMI2 = thm "LeastMI2";
paulson@11451
   208
val LeastM_equality = thm "LeastM_equality";
paulson@11451
   209
val GreatestM_def = thm "GreatestM_def";
paulson@11451
   210
val GreatestMI2 = thm "GreatestMI2";
paulson@11451
   211
val GreatestM_equality = thm "GreatestM_equality";
paulson@11451
   212
val Greatest_def = thm "Greatest_def";
paulson@11451
   213
val Greatest_equality = thm "Greatest_equality";
paulson@11451
   214
val GreatestM_natI = thm "GreatestM_natI";
paulson@11451
   215
val GreatestM_nat_le = thm "GreatestM_nat_le";
paulson@11451
   216
val GreatestI = thm "GreatestI";
paulson@11451
   217
val Greatest_le = thm "Greatest_le";
paulson@11451
   218
*}
paulson@11451
   219
paulson@11451
   220
use "meson_lemmas.ML"
paulson@11451
   221
use "Tools/meson.ML"
paulson@11451
   222
setup meson_setup
paulson@11451
   223
paulson@11451
   224
end