src/HOL/Set_Interval.thy
changeset 51334 fd531bd984d8
parent 51329 4a3c453f99a1
child 52380 3cc46b8cca5e
equal deleted inserted replaced
51333:2cfd028a2fd9 51334:fd531bd984d8
     2     Author:     Tobias Nipkow
     2     Author:     Tobias Nipkow
     3     Author:     Clemens Ballarin
     3     Author:     Clemens Ballarin
     4     Author:     Jeremy Avigad
     4     Author:     Jeremy Avigad
     5 
     5 
     6 lessThan, greaterThan, atLeast, atMost and two-sided intervals
     6 lessThan, greaterThan, atLeast, atMost and two-sided intervals
       
     7 
       
     8 Modern convention: Ixy stands for an interval where x and y
       
     9 describe the lower and upper bound and x,y : {c,o,i}
       
    10 where c = closed, o = open, i = infinite.
       
    11 Examples: Ico = {_ ..< _} and Ici = {_ ..}
     7 *)
    12 *)
     8 
    13 
     9 header {* Set intervals *}
    14 header {* Set intervals *}
    10 
    15 
    11 theory Set_Interval
    16 theory Set_Interval
   253 
   258 
   254 lemma atLeastatMost_psubset_iff:
   259 lemma atLeastatMost_psubset_iff:
   255   "{a..b} < {c..d} \<longleftrightarrow>
   260   "{a..b} < {c..d} \<longleftrightarrow>
   256    ((~ a <= b) | c <= a & b <= d & (c < a | b < d))  &  c <= d"
   261    ((~ a <= b) | c <= a & b <= d & (c < a | b < d))  &  c <= d"
   257 by(simp add: psubset_eq set_eq_iff less_le_not_le)(blast intro: order_trans)
   262 by(simp add: psubset_eq set_eq_iff less_le_not_le)(blast intro: order_trans)
       
   263 
       
   264 lemma Icc_eq_Icc[simp]:
       
   265   "{l..h} = {l'..h'} = (l=l' \<and> h=h' \<or> \<not> l\<le>h \<and> \<not> l'\<le>h')"
       
   266 by(simp add: order_class.eq_iff)(auto intro: order_trans)
   258 
   267 
   259 lemma atLeastAtMost_singleton_iff[simp]:
   268 lemma atLeastAtMost_singleton_iff[simp]:
   260   "{a .. b} = {c} \<longleftrightarrow> a = b \<and> b = c"
   269   "{a .. b} = {c} \<longleftrightarrow> a = b \<and> b = c"
   261 proof
   270 proof
   262   assume "{a..b} = {c}"
   271   assume "{a..b} = {c}"
   263   hence "\<not> (\<not> a \<le> b)" unfolding atLeastatMost_empty_iff[symmetric] by simp
   272   hence "\<not> (\<not> a \<le> b)" unfolding atLeastatMost_empty_iff[symmetric] by simp
   264   moreover with `{a..b} = {c}` have "c \<le> a \<and> b \<le> c" by auto
   273   moreover with `{a..b} = {c}` have "c \<le> a \<and> b \<le> c" by auto
   265   ultimately show "a = b \<and> b = c" by auto
   274   ultimately show "a = b \<and> b = c" by auto
   266 qed simp
   275 qed simp
   267 
   276 
       
   277 lemma Icc_subset_Ici_iff[simp]:
       
   278   "{l..h} \<subseteq> {l'..} = (~ l\<le>h \<or> l\<ge>l')"
       
   279 by(auto simp: subset_eq intro: order_trans)
       
   280 
       
   281 lemma Icc_subset_Iic_iff[simp]:
       
   282   "{l..h} \<subseteq> {..h'} = (~ l\<le>h \<or> h\<le>h')"
       
   283 by(auto simp: subset_eq intro: order_trans)
       
   284 
       
   285 lemma not_Ici_eq_empty[simp]: "{l..} \<noteq> {}"
       
   286 by(auto simp: set_eq_iff)
       
   287 
       
   288 lemma not_Iic_eq_empty[simp]: "{..h} \<noteq> {}"
       
   289 by(auto simp: set_eq_iff)
       
   290 
       
   291 lemmas not_empty_eq_Ici_eq_empty[simp] = not_Ici_eq_empty[symmetric]
       
   292 lemmas not_empty_eq_Iic_eq_empty[simp] = not_Iic_eq_empty[symmetric]
       
   293 
   268 end
   294 end
       
   295 
       
   296 context no_top
       
   297 begin
       
   298 
       
   299 (* also holds for no_bot but no_top should suffice *)
       
   300 lemma not_UNIV_le_Icc[simp]: "\<not> UNIV \<subseteq> {l..h}"
       
   301 using gt_ex[of h] by(auto simp: subset_eq less_le_not_le)
       
   302 
       
   303 lemma not_UNIV_le_Iic[simp]: "\<not> UNIV \<subseteq> {..h}"
       
   304 using gt_ex[of h] by(auto simp: subset_eq less_le_not_le)
       
   305 
       
   306 lemma not_Ici_le_Icc[simp]: "\<not> {l..} \<subseteq> {l'..h'}"
       
   307 using gt_ex[of h']
       
   308 by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans)
       
   309 
       
   310 lemma not_Ici_le_Iic[simp]: "\<not> {l..} \<subseteq> {..h'}"
       
   311 using gt_ex[of h']
       
   312 by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans)
       
   313 
       
   314 end
       
   315 
       
   316 context no_bot
       
   317 begin
       
   318 
       
   319 lemma not_UNIV_le_Ici[simp]: "\<not> UNIV \<subseteq> {l..}"
       
   320 using lt_ex[of l] by(auto simp: subset_eq less_le_not_le)
       
   321 
       
   322 lemma not_Iic_le_Icc[simp]: "\<not> {..h} \<subseteq> {l'..h'}"
       
   323 using lt_ex[of l']
       
   324 by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans)
       
   325 
       
   326 lemma not_Iic_le_Ici[simp]: "\<not> {..h} \<subseteq> {l'..}"
       
   327 using lt_ex[of l']
       
   328 by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans)
       
   329 
       
   330 end
       
   331 
       
   332 
       
   333 context no_top
       
   334 begin
       
   335 
       
   336 (* also holds for no_bot but no_top should suffice *)
       
   337 lemma not_UNIV_eq_Icc[simp]: "\<not> UNIV = {l'..h'}"
       
   338 using gt_ex[of h'] by(auto simp: set_eq_iff  less_le_not_le)
       
   339 
       
   340 lemmas not_Icc_eq_UNIV[simp] = not_UNIV_eq_Icc[symmetric]
       
   341 
       
   342 lemma not_UNIV_eq_Iic[simp]: "\<not> UNIV = {..h'}"
       
   343 using gt_ex[of h'] by(auto simp: set_eq_iff  less_le_not_le)
       
   344 
       
   345 lemmas not_Iic_eq_UNIV[simp] = not_UNIV_eq_Iic[symmetric]
       
   346 
       
   347 lemma not_Icc_eq_Ici[simp]: "\<not> {l..h} = {l'..}"
       
   348 unfolding atLeastAtMost_def using not_Ici_le_Iic[of l'] by blast
       
   349 
       
   350 lemmas not_Ici_eq_Icc[simp] = not_Icc_eq_Ici[symmetric]
       
   351 
       
   352 (* also holds for no_bot but no_top should suffice *)
       
   353 lemma not_Iic_eq_Ici[simp]: "\<not> {..h} = {l'..}"
       
   354 using not_Ici_le_Iic[of l' h] by blast
       
   355 
       
   356 lemmas not_Ici_eq_Iic[simp] = not_Iic_eq_Ici[symmetric]
       
   357 
       
   358 end
       
   359 
       
   360 context no_bot
       
   361 begin
       
   362 
       
   363 lemma not_UNIV_eq_Ici[simp]: "\<not> UNIV = {l'..}"
       
   364 using lt_ex[of l'] by(auto simp: set_eq_iff  less_le_not_le)
       
   365 
       
   366 lemmas not_Ici_eq_UNIV[simp] = not_UNIV_eq_Ici[symmetric]
       
   367 
       
   368 lemma not_Icc_eq_Iic[simp]: "\<not> {l..h} = {..h'}"
       
   369 unfolding atLeastAtMost_def using not_Iic_le_Ici[of h'] by blast
       
   370 
       
   371 lemmas not_Iic_eq_Icc[simp] = not_Icc_eq_Iic[symmetric]
       
   372 
       
   373 end
       
   374 
   269 
   375 
   270 context inner_dense_linorder
   376 context inner_dense_linorder
   271 begin
   377 begin
   272 
   378 
   273 lemma greaterThanLessThan_empty_iff[simp]:
   379 lemma greaterThanLessThan_empty_iff[simp]:
   311 end
   417 end
   312 
   418 
   313 context no_top
   419 context no_top
   314 begin
   420 begin
   315 
   421 
   316 lemma greaterThan_non_empty: "{x <..} \<noteq> {}"
   422 lemma greaterThan_non_empty[simp]: "{x <..} \<noteq> {}"
   317   using gt_ex[of x] by auto
   423   using gt_ex[of x] by auto
   318 
   424 
   319 end
   425 end
   320 
   426 
   321 context no_bot
   427 context no_bot
   322 begin
   428 begin
   323 
   429 
   324 lemma lessThan_non_empty: "{..< x} \<noteq> {}"
   430 lemma lessThan_non_empty[simp]: "{..< x} \<noteq> {}"
   325   using lt_ex[of x] by auto
   431   using lt_ex[of x] by auto
   326 
   432 
   327 end
   433 end
   328 
   434 
   329 lemma (in linorder) atLeastLessThan_subset_iff:
   435 lemma (in linorder) atLeastLessThan_subset_iff:
   344   fixes a b c d :: "'a::linorder"
   450   fixes a b c d :: "'a::linorder"
   345   assumes "a < b" "c < d"
   451   assumes "a < b" "c < d"
   346   shows "{a ..< b} = {c ..< d} \<longleftrightarrow> a = c \<and> b = d"
   452   shows "{a ..< b} = {c ..< d} \<longleftrightarrow> a = c \<and> b = d"
   347   using atLeastLessThan_inj assms by auto
   453   using atLeastLessThan_inj assms by auto
   348 
   454 
   349 context complete_lattice
   455 lemma (in bot) atLeast_eq_UNIV_iff: "{x..} = UNIV \<longleftrightarrow> x = bot"
   350 begin
   456 by (auto simp: set_eq_iff intro: le_bot)
   351 
   457 
   352 lemma atLeast_eq_UNIV_iff: "{x..} = UNIV \<longleftrightarrow> x = bot"
   458 lemma (in top) atMost_eq_UNIV_iff: "{..x} = UNIV \<longleftrightarrow> x = top"
   353   by (auto simp: set_eq_iff intro: le_bot)
   459 by (auto simp: set_eq_iff intro: top_le)
   354 
   460 
   355 lemma atMost_eq_UNIV_iff: "{..x} = UNIV \<longleftrightarrow> x = top"
   461 lemma (in bounded_lattice) atLeastAtMost_eq_UNIV_iff:
   356   by (auto simp: set_eq_iff intro: top_le)
   462   "{x..y} = UNIV \<longleftrightarrow> (x = bot \<and> y = top)"
   357 
   463 by (auto simp: set_eq_iff intro: top_le le_bot)
   358 lemma atLeastAtMost_eq_UNIV_iff: "{x..y} = UNIV \<longleftrightarrow> (x = bot \<and> y = top)"
   464 
   359   by (auto simp: set_eq_iff intro: top_le le_bot)
       
   360 
       
   361 end
       
   362 
   465 
   363 subsubsection {* Intersection *}
   466 subsubsection {* Intersection *}
   364 
   467 
   365 context linorder
   468 context linorder
   366 begin
   469 begin