src/HOL/Orderings.thy
changeset 24422 c0b5ff9e9e4d
parent 24286 7619080e49f0
child 24641 448edc627ee4
equal deleted inserted replaced
24421:acfb2413faa3 24422:c0b5ff9e9e4d
   232 lemma split_max [noatp]:
   232 lemma split_max [noatp]:
   233   "P (max i j) \<longleftrightarrow> (i \<^loc>\<le> j \<longrightarrow> P j) \<and> (\<not> i \<^loc>\<le> j \<longrightarrow> P i)"
   233   "P (max i j) \<longleftrightarrow> (i \<^loc>\<le> j \<longrightarrow> P j) \<and> (\<not> i \<^loc>\<le> j \<longrightarrow> P i)"
   234 by (simp add: max_def)
   234 by (simp add: max_def)
   235 
   235 
   236 end
   236 end
   237 
       
   238 
       
   239 subsection {* Name duplicates *}
       
   240 
       
   241 lemmas order_less_le = less_le
       
   242 lemmas order_eq_refl = order_class.eq_refl
       
   243 lemmas order_less_irrefl = order_class.less_irrefl
       
   244 lemmas order_le_less = order_class.le_less
       
   245 lemmas order_le_imp_less_or_eq = order_class.le_imp_less_or_eq
       
   246 lemmas order_less_imp_le = order_class.less_imp_le
       
   247 lemmas order_less_imp_not_eq = order_class.less_imp_not_eq
       
   248 lemmas order_less_imp_not_eq2 = order_class.less_imp_not_eq2
       
   249 lemmas order_neq_le_trans = order_class.neq_le_trans
       
   250 lemmas order_le_neq_trans = order_class.le_neq_trans
       
   251 
       
   252 lemmas order_antisym = antisym
       
   253 lemmas order_less_not_sym = order_class.less_not_sym
       
   254 lemmas order_less_asym = order_class.less_asym
       
   255 lemmas order_eq_iff = order_class.eq_iff
       
   256 lemmas order_antisym_conv = order_class.antisym_conv
       
   257 lemmas order_less_trans = order_class.less_trans
       
   258 lemmas order_le_less_trans = order_class.le_less_trans
       
   259 lemmas order_less_le_trans = order_class.less_le_trans
       
   260 lemmas order_less_imp_not_less = order_class.less_imp_not_less
       
   261 lemmas order_less_imp_triv = order_class.less_imp_triv
       
   262 lemmas order_less_asym' = order_class.less_asym'
       
   263 
       
   264 lemmas linorder_linear = linear
       
   265 lemmas linorder_less_linear = linorder_class.less_linear
       
   266 lemmas linorder_le_less_linear = linorder_class.le_less_linear
       
   267 lemmas linorder_le_cases = linorder_class.le_cases
       
   268 lemmas linorder_not_less = linorder_class.not_less
       
   269 lemmas linorder_not_le = linorder_class.not_le
       
   270 lemmas linorder_neq_iff = linorder_class.neq_iff
       
   271 lemmas linorder_neqE = linorder_class.neqE
       
   272 lemmas linorder_antisym_conv1 = linorder_class.antisym_conv1
       
   273 lemmas linorder_antisym_conv2 = linorder_class.antisym_conv2
       
   274 lemmas linorder_antisym_conv3 = linorder_class.antisym_conv3
       
   275 
       
   276 lemmas min_le_iff_disj = linorder_class.min_le_iff_disj
       
   277 lemmas le_max_iff_disj = linorder_class.le_max_iff_disj
       
   278 lemmas min_less_iff_disj = linorder_class.min_less_iff_disj
       
   279 lemmas less_max_iff_disj = linorder_class.less_max_iff_disj
       
   280 lemmas min_less_iff_conj [simp] = linorder_class.min_less_iff_conj
       
   281 lemmas max_less_iff_conj [simp] = linorder_class.max_less_iff_conj
       
   282 lemmas split_min = linorder_class.split_min
       
   283 lemmas split_max = linorder_class.split_max
       
   284 
   237 
   285 
   238 
   286 subsection {* Reasoning tools setup *}
   239 subsection {* Reasoning tools setup *}
   287 
   240 
   288 ML {*
   241 ML {*
   334   val decomp_quasi = decomp_gen ["Orderings.preorder"];
   287   val decomp_quasi = decomp_gen ["Orderings.preorder"];
   335 end);*)
   288 end);*)
   336 
   289 
   337 structure Order_Tac = Order_Tac_Fun (
   290 structure Order_Tac = Order_Tac_Fun (
   338 struct
   291 struct
   339   val less_reflE = thm "order_less_irrefl" RS thm "notE";
   292   val less_reflE = @{thm less_irrefl} RS @{thm notE};
   340   val le_refl = thm "order_refl";
   293   val le_refl = @{thm order_refl};
   341   val less_imp_le = thm "order_less_imp_le";
   294   val less_imp_le = @{thm less_imp_le};
   342   val not_lessI = thm "linorder_not_less" RS thm "iffD2";
   295   val not_lessI = @{thm not_less} RS @{thm iffD2};
   343   val not_leI = thm "linorder_not_le" RS thm "iffD2";
   296   val not_leI = @{thm not_le} RS @{thm iffD2};
   344   val not_lessD = thm "linorder_not_less" RS thm "iffD1";
   297   val not_lessD = @{thm not_less} RS @{thm iffD1};
   345   val not_leD = thm "linorder_not_le" RS thm "iffD1";
   298   val not_leD = @{thm not_le} RS @{thm iffD1};
   346   val eqI = thm "order_antisym";
   299   val eqI = @{thm antisym};
   347   val eqD1 = thm "order_eq_refl";
   300   val eqD1 = @{thm eq_refl};
   348   val eqD2 = thm "sym" RS thm "order_eq_refl";
   301   val eqD2 = @{thm sym} RS @{thm eq_refl};
   349   val less_trans = thm "order_less_trans";
   302   val less_trans = @{thm less_trans};
   350   val less_le_trans = thm "order_less_le_trans";
   303   val less_le_trans = @{thm less_le_trans};
   351   val le_less_trans = thm "order_le_less_trans";
   304   val le_less_trans = @{thm le_less_trans};
   352   val le_trans = thm "order_trans";
   305   val le_trans = @{thm order_trans};
   353   val le_neq_trans = thm "order_le_neq_trans";
   306   val le_neq_trans = @{thm le_neq_trans};
   354   val neq_le_trans = thm "order_neq_le_trans";
   307   val neq_le_trans = @{thm neq_le_trans};
   355   val less_imp_neq = thm "less_imp_neq";
   308   val less_imp_neq = @{thm less_imp_neq};
   356   val eq_neq_eq_imp_neq = thm "eq_neq_eq_imp_neq";
   309   val eq_neq_eq_imp_neq = @{thm eq_neq_eq_imp_neq};
   357   val not_sym = thm "not_sym";
   310   val not_sym = @{thm not_sym};
   358   val decomp_part = decomp_gen ["Orderings.order"];
   311   val decomp_part = decomp_gen ["Orderings.order"];
   359   val decomp_lin = decomp_gen ["Orderings.linorder"];
   312   val decomp_lin = decomp_gen ["Orderings.linorder"];
   360 end);
   313 end);
   361 
   314 
   362 end;
   315 end;
   374   in case find_first (prp t) prems of
   327   in case find_first (prp t) prems of
   375        NONE =>
   328        NONE =>
   376          let val t = HOLogic.mk_Trueprop(HOLogic.Not $ (less $ r $ s))
   329          let val t = HOLogic.mk_Trueprop(HOLogic.Not $ (less $ r $ s))
   377          in case find_first (prp t) prems of
   330          in case find_first (prp t) prems of
   378               NONE => NONE
   331               NONE => NONE
   379             | SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_antisym_conv1}))
   332             | SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_class.antisym_conv1}))
   380          end
   333          end
   381      | SOME thm => SOME(mk_meta_eq(thm RS @{thm order_antisym_conv}))
   334      | SOME thm => SOME(mk_meta_eq(thm RS @{thm order_class.antisym_conv}))
   382   end
   335   end
   383   handle THM _ => NONE;
   336   handle THM _ => NONE;
   384 
   337 
   385 fun prove_antisym_less sg ss (NotC $ ((less as Const(_,T)) $ r $ s)) =
   338 fun prove_antisym_less sg ss (NotC $ ((less as Const(_,T)) $ r $ s)) =
   386   let val prems = prems_of_ss ss;
   339   let val prems = prems_of_ss ss;
   389   in case find_first (prp t) prems of
   342   in case find_first (prp t) prems of
   390        NONE =>
   343        NONE =>
   391          let val t = HOLogic.mk_Trueprop(NotC $ (less $ s $ r))
   344          let val t = HOLogic.mk_Trueprop(NotC $ (less $ s $ r))
   392          in case find_first (prp t) prems of
   345          in case find_first (prp t) prems of
   393               NONE => NONE
   346               NONE => NONE
   394             | SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_antisym_conv3}))
   347             | SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_class.antisym_conv3}))
   395          end
   348          end
   396      | SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_antisym_conv2}))
   349      | SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_class.antisym_conv2}))
   397   end
   350   end
   398   handle THM _ => NONE;
   351   handle THM _ => NONE;
   399 
   352 
   400 fun add_simprocs procs thy =
   353 fun add_simprocs procs thy =
   401   (Simplifier.change_simpset_of thy (fn ss => ss
   354   (Simplifier.change_simpset_of thy (fn ss => ss
   416      speed up, but the reasoning strength appears to be not higher (at least
   369      speed up, but the reasoning strength appears to be not higher (at least
   417      no breaking of additional proofs in the entire HOL distribution, as
   370      no breaking of additional proofs in the entire HOL distribution, as
   418      of 5 March 2004, was observed). *)
   371      of 5 March 2004, was observed). *)
   419 end
   372 end
   420 *}
   373 *}
       
   374 
       
   375 
       
   376 subsection {* Dense orders *}
       
   377 
       
   378 class dense_linear_order = linorder + 
       
   379   assumes gt_ex: "\<exists>y. x \<sqsubset> y" 
       
   380   and lt_ex: "\<exists>y. y \<sqsubset> x"
       
   381   and dense: "x \<sqsubset> y \<Longrightarrow> (\<exists>z. x \<sqsubset> z \<and> z \<sqsubset> y)"
       
   382   (*see further theory Dense_Linear_Order*)
       
   383 
       
   384 lemma interval_empty_iff:
       
   385   fixes x y z :: "'a\<Colon>dense_linear_order"
       
   386   shows "{y. x < y \<and> y < z} = {} \<longleftrightarrow> \<not> x < z"
       
   387   by (auto dest: dense)
       
   388 
       
   389 subsection {* Name duplicates *}
       
   390 
       
   391 lemmas order_less_le = less_le
       
   392 lemmas order_eq_refl = order_class.eq_refl
       
   393 lemmas order_less_irrefl = order_class.less_irrefl
       
   394 lemmas order_le_less = order_class.le_less
       
   395 lemmas order_le_imp_less_or_eq = order_class.le_imp_less_or_eq
       
   396 lemmas order_less_imp_le = order_class.less_imp_le
       
   397 lemmas order_less_imp_not_eq = order_class.less_imp_not_eq
       
   398 lemmas order_less_imp_not_eq2 = order_class.less_imp_not_eq2
       
   399 lemmas order_neq_le_trans = order_class.neq_le_trans
       
   400 lemmas order_le_neq_trans = order_class.le_neq_trans
       
   401 
       
   402 lemmas order_antisym = antisym
       
   403 lemmas order_less_not_sym = order_class.less_not_sym
       
   404 lemmas order_less_asym = order_class.less_asym
       
   405 lemmas order_eq_iff = order_class.eq_iff
       
   406 lemmas order_antisym_conv = order_class.antisym_conv
       
   407 lemmas order_less_trans = order_class.less_trans
       
   408 lemmas order_le_less_trans = order_class.le_less_trans
       
   409 lemmas order_less_le_trans = order_class.less_le_trans
       
   410 lemmas order_less_imp_not_less = order_class.less_imp_not_less
       
   411 lemmas order_less_imp_triv = order_class.less_imp_triv
       
   412 lemmas order_less_asym' = order_class.less_asym'
       
   413 
       
   414 lemmas linorder_linear = linear
       
   415 lemmas linorder_less_linear = linorder_class.less_linear
       
   416 lemmas linorder_le_less_linear = linorder_class.le_less_linear
       
   417 lemmas linorder_le_cases = linorder_class.le_cases
       
   418 lemmas linorder_not_less = linorder_class.not_less
       
   419 lemmas linorder_not_le = linorder_class.not_le
       
   420 lemmas linorder_neq_iff = linorder_class.neq_iff
       
   421 lemmas linorder_neqE = linorder_class.neqE
       
   422 lemmas linorder_antisym_conv1 = linorder_class.antisym_conv1
       
   423 lemmas linorder_antisym_conv2 = linorder_class.antisym_conv2
       
   424 lemmas linorder_antisym_conv3 = linorder_class.antisym_conv3
       
   425 
       
   426 lemmas min_le_iff_disj = linorder_class.min_le_iff_disj
       
   427 lemmas le_max_iff_disj = linorder_class.le_max_iff_disj
       
   428 lemmas min_less_iff_disj = linorder_class.min_less_iff_disj
       
   429 lemmas less_max_iff_disj = linorder_class.less_max_iff_disj
       
   430 lemmas min_less_iff_conj [simp] = linorder_class.min_less_iff_conj
       
   431 lemmas max_less_iff_conj [simp] = linorder_class.max_less_iff_conj
       
   432 lemmas split_min = linorder_class.split_min
       
   433 lemmas split_max = linorder_class.split_max
   421 
   434 
   422 
   435 
   423 subsection {* Bounded quantifiers *}
   436 subsection {* Bounded quantifiers *}
   424 
   437 
   425 syntax
   438 syntax
   752 
   765 
   753 instance bool :: order 
   766 instance bool :: order 
   754   le_bool_def: "P \<le> Q \<equiv> P \<longrightarrow> Q"
   767   le_bool_def: "P \<le> Q \<equiv> P \<longrightarrow> Q"
   755   less_bool_def: "P < Q \<equiv> P \<le> Q \<and> P \<noteq> Q"
   768   less_bool_def: "P < Q \<equiv> P \<le> Q \<and> P \<noteq> Q"
   756   by intro_classes (auto simp add: le_bool_def less_bool_def)
   769   by intro_classes (auto simp add: le_bool_def less_bool_def)
       
   770 lemmas [code func del] = le_bool_def less_bool_def
   757 
   771 
   758 lemma le_boolI: "(P \<Longrightarrow> Q) \<Longrightarrow> P \<le> Q"
   772 lemma le_boolI: "(P \<Longrightarrow> Q) \<Longrightarrow> P \<le> Q"
   759 by (simp add: le_bool_def)
   773 by (simp add: le_bool_def)
   760 
   774 
   761 lemma le_boolI': "P \<longrightarrow> Q \<Longrightarrow> P \<le> Q"
   775 lemma le_boolI': "P \<longrightarrow> Q \<Longrightarrow> P \<le> Q"