src/HOL/Finite_Set.thy
changeset 22425 c252770ae2d0
parent 22398 dfe146d65b14
child 22451 989182f660e0
equal deleted inserted replaced
22424:8a5412121687 22425:c252770ae2d0
  2445   shows "finite A \<Longrightarrow> A \<noteq> {} \<Longrightarrow> Max A \<in> A"
  2445   shows "finite A \<Longrightarrow> A \<noteq> {} \<Longrightarrow> Max A \<in> A"
  2446 using max.fold1_in
  2446 using max.fold1_in
  2447 by(fastsimp simp: Max_def max_def)
  2447 by(fastsimp simp: Max_def max_def)
  2448 
  2448 
  2449 lemma Min_antimono: "\<lbrakk> M \<subseteq> N; M \<noteq> {}; finite N \<rbrakk> \<Longrightarrow> Min N \<le> Min M"
  2449 lemma Min_antimono: "\<lbrakk> M \<subseteq> N; M \<noteq> {}; finite N \<rbrakk> \<Longrightarrow> Min N \<le> Min M"
  2450 by(simp add:Finite_Set.Min_def min.fold1_antimono)
  2450   by (simp add: Min_def min.fold1_antimono)
  2451 
  2451 
  2452 lemma Max_mono: "\<lbrakk> M \<subseteq> N; M \<noteq> {}; finite N \<rbrakk> \<Longrightarrow> Max M \<le> Max N"
  2452 lemma Max_mono: "\<lbrakk> M \<subseteq> N; M \<noteq> {}; finite N \<rbrakk> \<Longrightarrow> Max M \<le> Max N"
  2453 by(simp add:Max_def max.fold1_antimono)
  2453   by (simp add: Max_def max.fold1_antimono)
  2454 
  2454 
  2455 lemma Min_le [simp]: "\<lbrakk> finite A; A \<noteq> {}; x \<in> A \<rbrakk> \<Longrightarrow> Min A \<le> x"
  2455 lemma Min_le [simp]: "\<lbrakk> finite A; A \<noteq> {}; x \<in> A \<rbrakk> \<Longrightarrow> Min A \<le> x"
  2456 by(simp add: Min_def min.fold1_belowI)
  2456 by(simp add: Min_def min.fold1_belowI)
  2457 
  2457 
  2458 lemma Max_ge [simp]: "\<lbrakk> finite A; A \<noteq> {}; x \<in> A \<rbrakk> \<Longrightarrow> x \<le> Max A"
  2458 lemma Max_ge [simp]: "\<lbrakk> finite A; A \<noteq> {}; x \<in> A \<rbrakk> \<Longrightarrow> x \<le> Max A"
  2500 
  2500 
  2501 
  2501 
  2502 lemma hom_Min_commute:
  2502 lemma hom_Min_commute:
  2503  "(!!x y::'a::linorder. h(min x y) = min (h x) (h y::'a))
  2503  "(!!x y::'a::linorder. h(min x y) = min (h x) (h y::'a))
  2504   \<Longrightarrow> finite N \<Longrightarrow> N \<noteq> {} \<Longrightarrow> h(Min N) = Min(h ` N)"
  2504   \<Longrightarrow> finite N \<Longrightarrow> N \<noteq> {} \<Longrightarrow> h(Min N) = Min(h ` N)"
  2505 by(simp add:Finite_Set.Min_def min.hom_fold1_commute)
  2505   by (simp add: Min_def min.hom_fold1_commute)
  2506 
  2506 
  2507 lemma hom_Max_commute:
  2507 lemma hom_Max_commute:
  2508  "(!!x y::'a::linorder. h(max x y) = max (h x) (h y::'a))
  2508  "(!!x y::'a::linorder. h(max x y) = max (h x) (h y::'a))
  2509   \<Longrightarrow> finite N \<Longrightarrow> N \<noteq> {} \<Longrightarrow> h(Max N) = Max(h ` N)"
  2509   \<Longrightarrow> finite N \<Longrightarrow> N \<noteq> {} \<Longrightarrow> h(Max N) = Max(h ` N)"
  2510 by(simp add:Max_def max.hom_fold1_commute)
  2510   by( simp add: Max_def max.hom_fold1_commute)
  2511 
  2511 
  2512 
  2512 
  2513 lemma add_Min_commute: fixes k::"'a::{pordered_ab_semigroup_add,linorder}"
  2513 lemma add_Min_commute: fixes k::"'a::{pordered_ab_semigroup_add,linorder}"
  2514  shows "finite N \<Longrightarrow> N \<noteq> {} \<Longrightarrow> k + Min N = Min {k+m|m. m \<in> N}"
  2514  shows "finite N \<Longrightarrow> N \<noteq> {} \<Longrightarrow> k + Min N = Min {k+m|m. m \<in> N}"
  2515 apply(subgoal_tac "!!x y. k + min x y = min (k + x) (k + y)")
  2515 apply(subgoal_tac "!!x y. k + min x y = min (k + x) (k + y)")
  2626     show "inj ?graph" by (rule inj_graph)
  2626     show "inj ?graph" by (rule inj_graph)
  2627   qed
  2627   qed
  2628 qed
  2628 qed
  2629 
  2629 
  2630 
  2630 
  2631 subsection {* Equality on functions *}
  2631 subsection {* Equality and order on functions *}
  2632 
  2632 
  2633 instance "fun" :: (finite, eq) eq ..
  2633 instance "fun" :: (finite, eq) eq ..
  2634 
  2634 
  2635 lemma eq_fun [code func]:
  2635 lemma eq_fun [code func]:
  2636   "f = g \<longleftrightarrow> (\<forall>x\<Colon>'a\<Colon>finite \<in> UNIV. (f x \<Colon> 'b\<Colon>eq) = g x)"
  2636   "f = g \<longleftrightarrow> (\<forall>x\<Colon>'a\<Colon>finite \<in> UNIV. (f x \<Colon> 'b\<Colon>eq) = g x)"
  2637   unfolding expand_fun_eq by auto
  2637   unfolding expand_fun_eq by auto
  2638 
  2638 
       
  2639 lemma order_fun [code func]:
       
  2640   "f \<le> g \<longleftrightarrow> (\<forall>x\<Colon>'a\<Colon>finite \<in> UNIV. (f x \<Colon> 'b\<Colon>order) \<le> g x)"
       
  2641   "f < g \<longleftrightarrow> f \<le> g \<and> (\<exists>x\<Colon>'a\<Colon>finite \<in> UNIV. (f x \<Colon> 'b\<Colon>order) < g x)"
       
  2642   unfolding le_fun_def less_fun_def less_le
       
  2643   by (auto simp add: expand_fun_eq)
       
  2644 
  2639 end
  2645 end