src/HOL/Hilbert_Choice.thy
changeset 14208 144f45277d5a
parent 14115 65ec3f73d00b
child 14399 dc677b35e54f
equal deleted inserted replaced
14207:f20fbb141673 14208:144f45277d5a
    70 lemma LeastMI2:
    70 lemma LeastMI2:
    71   "P x ==> (!!y. P y ==> m x <= m y)
    71   "P x ==> (!!y. P y ==> m x <= m y)
    72     ==> (!!x. P x ==> \<forall>y. P y --> m x \<le> m y ==> Q x)
    72     ==> (!!x. P x ==> \<forall>y. P y --> m x \<le> m y ==> Q x)
    73     ==> Q (LeastM m P)"
    73     ==> Q (LeastM m P)"
    74   apply (unfold LeastM_def)
    74   apply (unfold LeastM_def)
    75   apply (rule someI2_ex)
    75   apply (rule someI2_ex, blast, blast)
    76    apply blast
       
    77   apply blast
       
    78   done
    76   done
    79 
    77 
    80 lemma LeastM_equality:
    78 lemma LeastM_equality:
    81   "P k ==> (!!x. P x ==> m k <= m x)
    79   "P k ==> (!!x. P x ==> m k <= m x)
    82     ==> m (LEAST x WRT m. P x) = (m k::'a::order)"
    80     ==> m (LEAST x WRT m. P x) = (m k::'a::order)"
    83   apply (rule LeastMI2)
    81   apply (rule LeastMI2, assumption, blast)
    84     apply assumption
       
    85    apply blast
       
    86   apply (blast intro!: order_antisym)
    82   apply (blast intro!: order_antisym)
    87   done
    83   done
    88 
    84 
    89 lemma wf_linord_ex_has_least:
    85 lemma wf_linord_ex_has_least:
    90   "wf r ==> ALL x y. ((x,y):r^+) = ((y,x)~:r^*) ==> P k
    86   "wf r ==> ALL x y. ((x,y):r^+) = ((y,x)~:r^*) ==> P k
    91     ==> EX x. P x & (!y. P y --> (m x,m y):r^*)"
    87     ==> EX x. P x & (!y. P y --> (m x,m y):r^*)"
    92   apply (drule wf_trancl [THEN wf_eq_minimal [THEN iffD1]])
    88   apply (drule wf_trancl [THEN wf_eq_minimal [THEN iffD1]])
    93   apply (drule_tac x = "m`Collect P" in spec)
    89   apply (drule_tac x = "m`Collect P" in spec, force)
    94   apply force
       
    95   done
    90   done
    96 
    91 
    97 lemma ex_has_least_nat:
    92 lemma ex_has_least_nat:
    98     "P k ==> EX x. P x & (ALL y. P y --> m x <= (m y::nat))"
    93     "P k ==> EX x. P x & (ALL y. P y --> m x <= (m y::nat))"
    99   apply (simp only: pred_nat_trancl_eq_le [symmetric])
    94   apply (simp only: pred_nat_trancl_eq_le [symmetric])
   100   apply (rule wf_pred_nat [THEN wf_linord_ex_has_least])
    95   apply (rule wf_pred_nat [THEN wf_linord_ex_has_least])
   101    apply (simp add: less_eq not_le_iff_less pred_nat_trancl_eq_le)
    96    apply (simp add: less_eq not_le_iff_less pred_nat_trancl_eq_le, assumption)
   102   apply assumption
       
   103   done
    97   done
   104 
    98 
   105 lemma LeastM_nat_lemma:
    99 lemma LeastM_nat_lemma:
   106     "P k ==> P (LeastM m P) & (ALL y. P y --> m (LeastM m P) <= (m y::nat))"
   100     "P k ==> P (LeastM m P) & (ALL y. P y --> m (LeastM m P) <= (m y::nat))"
   107   apply (unfold LeastM_def)
   101   apply (unfold LeastM_def)
   110   done
   104   done
   111 
   105 
   112 lemmas LeastM_natI = LeastM_nat_lemma [THEN conjunct1, standard]
   106 lemmas LeastM_natI = LeastM_nat_lemma [THEN conjunct1, standard]
   113 
   107 
   114 lemma LeastM_nat_le: "P x ==> m (LeastM m P) <= (m x::nat)"
   108 lemma LeastM_nat_le: "P x ==> m (LeastM m P) <= (m x::nat)"
   115   apply (rule LeastM_nat_lemma [THEN conjunct2, THEN spec, THEN mp])
   109 by (rule LeastM_nat_lemma [THEN conjunct2, THEN spec, THEN mp], assumption, assumption)
   116    apply assumption
       
   117   apply assumption
       
   118   done
       
   119 
   110 
   120 
   111 
   121 subsection {* Greatest value operator *}
   112 subsection {* Greatest value operator *}
   122 
   113 
   123 constdefs
   114 constdefs
   137 lemma GreatestMI2:
   128 lemma GreatestMI2:
   138   "P x ==> (!!y. P y ==> m y <= m x)
   129   "P x ==> (!!y. P y ==> m y <= m x)
   139     ==> (!!x. P x ==> \<forall>y. P y --> m y \<le> m x ==> Q x)
   130     ==> (!!x. P x ==> \<forall>y. P y --> m y \<le> m x ==> Q x)
   140     ==> Q (GreatestM m P)"
   131     ==> Q (GreatestM m P)"
   141   apply (unfold GreatestM_def)
   132   apply (unfold GreatestM_def)
   142   apply (rule someI2_ex)
   133   apply (rule someI2_ex, blast, blast)
   143    apply blast
       
   144   apply blast
       
   145   done
   134   done
   146 
   135 
   147 lemma GreatestM_equality:
   136 lemma GreatestM_equality:
   148  "P k ==> (!!x. P x ==> m x <= m k)
   137  "P k ==> (!!x. P x ==> m x <= m k)
   149     ==> m (GREATEST x WRT m. P x) = (m k::'a::order)"
   138     ==> m (GREATEST x WRT m. P x) = (m k::'a::order)"
   150   apply (rule_tac m = m in GreatestMI2)
   139   apply (rule_tac m = m in GreatestMI2, assumption, blast)
   151     apply assumption
       
   152    apply blast
       
   153   apply (blast intro!: order_antisym)
   140   apply (blast intro!: order_antisym)
   154   done
   141   done
   155 
   142 
   156 lemma Greatest_equality:
   143 lemma Greatest_equality:
   157   "P (k::'a::order) ==> (!!x. P x ==> x <= k) ==> (GREATEST x. P x) = k"
   144   "P (k::'a::order) ==> (!!x. P x ==> x <= k) ==> (GREATEST x. P x) = k"
   158   apply (unfold Greatest_def)
   145   apply (unfold Greatest_def)
   159   apply (erule GreatestM_equality)
   146   apply (erule GreatestM_equality, blast)
   160   apply blast
       
   161   done
   147   done
   162 
   148 
   163 lemma ex_has_greatest_nat_lemma:
   149 lemma ex_has_greatest_nat_lemma:
   164   "P k ==> ALL x. P x --> (EX y. P y & ~ ((m y::nat) <= m x))
   150   "P k ==> ALL x. P x --> (EX y. P y & ~ ((m y::nat) <= m x))
   165     ==> EX y. P y & ~ (m y < m k + n)"
   151     ==> EX y. P y & ~ (m y < m k + n)"
   166   apply (induct_tac n)
   152   apply (induct_tac n, force)
   167    apply force
       
   168   apply (force simp add: le_Suc_eq)
   153   apply (force simp add: le_Suc_eq)
   169   done
   154   done
   170 
   155 
   171 lemma ex_has_greatest_nat:
   156 lemma ex_has_greatest_nat:
   172   "P k ==> ALL y. P y --> m y < b
   157   "P k ==> ALL y. P y --> m y < b
   173     ==> EX x. P x & (ALL y. P y --> (m y::nat) <= m x)"
   158     ==> EX x. P x & (ALL y. P y --> (m y::nat) <= m x)"
   174   apply (rule ccontr)
   159   apply (rule ccontr)
   175   apply (cut_tac P = P and n = "b - m k" in ex_has_greatest_nat_lemma)
   160   apply (cut_tac P = P and n = "b - m k" in ex_has_greatest_nat_lemma)
   176     apply (subgoal_tac [3] "m k <= b")
   161     apply (subgoal_tac [3] "m k <= b", auto)
   177      apply auto
       
   178   done
   162   done
   179 
   163 
   180 lemma GreatestM_nat_lemma:
   164 lemma GreatestM_nat_lemma:
   181   "P k ==> ALL y. P y --> m y < b
   165   "P k ==> ALL y. P y --> m y < b
   182     ==> P (GreatestM m P) & (ALL y. P y --> (m y::nat) <= m (GreatestM m P))"
   166     ==> P (GreatestM m P) & (ALL y. P y --> (m y::nat) <= m (GreatestM m P))"
   183   apply (unfold GreatestM_def)
   167   apply (unfold GreatestM_def)
   184   apply (rule someI_ex)
   168   apply (rule someI_ex)
   185   apply (erule ex_has_greatest_nat)
   169   apply (erule ex_has_greatest_nat, assumption)
   186   apply assumption
       
   187   done
   170   done
   188 
   171 
   189 lemmas GreatestM_natI = GreatestM_nat_lemma [THEN conjunct1, standard]
   172 lemmas GreatestM_natI = GreatestM_nat_lemma [THEN conjunct1, standard]
   190 
   173 
   191 lemma GreatestM_nat_le:
   174 lemma GreatestM_nat_le:
   197 
   180 
   198 text {* \medskip Specialization to @{text GREATEST}. *}
   181 text {* \medskip Specialization to @{text GREATEST}. *}
   199 
   182 
   200 lemma GreatestI: "P (k::nat) ==> ALL y. P y --> y < b ==> P (GREATEST x. P x)"
   183 lemma GreatestI: "P (k::nat) ==> ALL y. P y --> y < b ==> P (GREATEST x. P x)"
   201   apply (unfold Greatest_def)
   184   apply (unfold Greatest_def)
   202   apply (rule GreatestM_natI)
   185   apply (rule GreatestM_natI, auto)
   203    apply auto
       
   204   done
   186   done
   205 
   187 
   206 lemma Greatest_le:
   188 lemma Greatest_le:
   207     "P x ==> ALL y. P y --> y < b ==> (x::nat) <= (GREATEST x. P x)"
   189     "P x ==> ALL y. P y --> y < b ==> (x::nat) <= (GREATEST x. P x)"
   208   apply (unfold Greatest_def)
   190   apply (unfold Greatest_def)
   209   apply (rule GreatestM_nat_le)
   191   apply (rule GreatestM_nat_le, auto)
   210    apply auto
       
   211   done
   192   done
   212 
   193 
   213 
   194 
   214 subsection {* The Meson proof procedure *}
   195 subsection {* The Meson proof procedure *}
   215 
   196