src/HOL/Orderings.thy
changeset 61824 dcbe9f756ae0
parent 61799 4cf66f21b764
child 61955 e96292f32c3c
equal deleted inserted replaced
61823:5daa82ba4078 61824:dcbe9f756ae0
    80 
    80 
    81 lemma not_eq_extremum:
    81 lemma not_eq_extremum:
    82   "a \<noteq> top \<longleftrightarrow> a \<prec> top"
    82   "a \<noteq> top \<longleftrightarrow> a \<prec> top"
    83   by (auto simp add: order_iff_strict intro: not_eq_order_implies_strict extremum)
    83   by (auto simp add: order_iff_strict intro: not_eq_order_implies_strict extremum)
    84 
    84 
    85 end  
    85 end
    86 
    86 
    87 
    87 
    88 subsection \<open>Syntactic orders\<close>
    88 subsection \<open>Syntactic orders\<close>
    89 
    89 
    90 class ord =
    90 class ord =
    95 notation
    95 notation
    96   less_eq  ("op <=") and
    96   less_eq  ("op <=") and
    97   less_eq  ("(_/ <= _)" [51, 51] 50) and
    97   less_eq  ("(_/ <= _)" [51, 51] 50) and
    98   less  ("op <") and
    98   less  ("op <") and
    99   less  ("(_/ < _)"  [51, 51] 50)
    99   less  ("(_/ < _)"  [51, 51] 50)
   100   
   100 
   101 notation (xsymbols)
   101 notation (xsymbols)
   102   less_eq  ("op \<le>") and
   102   less_eq  ("op \<le>") and
   103   less_eq  ("(_/ \<le> _)"  [51, 51] 50)
   103   less_eq  ("(_/ \<le> _)"  [51, 51] 50)
   104 
   104 
   105 abbreviation (input)
   105 abbreviation (input)
   147 
   147 
   148 
   148 
   149 text \<open>Transitivity.\<close>
   149 text \<open>Transitivity.\<close>
   150 
   150 
   151 lemma less_trans: "x < y \<Longrightarrow> y < z \<Longrightarrow> x < z"
   151 lemma less_trans: "x < y \<Longrightarrow> y < z \<Longrightarrow> x < z"
   152 by (auto simp add: less_le_not_le intro: order_trans) 
   152 by (auto simp add: less_le_not_le intro: order_trans)
   153 
   153 
   154 lemma le_less_trans: "x \<le> y \<Longrightarrow> y < z \<Longrightarrow> x < z"
   154 lemma le_less_trans: "x \<le> y \<Longrightarrow> y < z \<Longrightarrow> x < z"
   155 by (auto simp add: less_le_not_le intro: order_trans) 
   155 by (auto simp add: less_le_not_le intro: order_trans)
   156 
   156 
   157 lemma less_le_trans: "x < y \<Longrightarrow> y \<le> z \<Longrightarrow> x < z"
   157 lemma less_le_trans: "x < y \<Longrightarrow> y \<le> z \<Longrightarrow> x < z"
   158 by (auto simp add: less_le_not_le intro: order_trans) 
   158 by (auto simp add: less_le_not_le intro: order_trans)
   159 
   159 
   160 
   160 
   161 text \<open>Useful for simplification, but too risky to include by default.\<close>
   161 text \<open>Useful for simplification, but too risky to include by default.\<close>
   162 
   162 
   163 lemma less_imp_not_less: "x < y \<Longrightarrow> (\<not> y < x) \<longleftrightarrow> True"
   163 lemma less_imp_not_less: "x < y \<Longrightarrow> (\<not> y < x) \<longleftrightarrow> True"
   358 unfolding not_less .
   358 unfolding not_less .
   359 
   359 
   360 lemma leD: "y \<le> x \<Longrightarrow> \<not> x < y"
   360 lemma leD: "y \<le> x \<Longrightarrow> \<not> x < y"
   361 unfolding not_less .
   361 unfolding not_less .
   362 
   362 
   363 (*FIXME inappropriate name (or delete altogether)*)
   363 lemma not_le_imp_less: "\<not> y \<le> x \<Longrightarrow> x < y"
   364 lemma not_leE: "\<not> y \<le> x \<Longrightarrow> x < y"
       
   365 unfolding not_le .
   364 unfolding not_le .
   366 
   365 
   367 text \<open>Dual order\<close>
   366 text \<open>Dual order\<close>
   368 
   367 
   369 lemma dual_linorder:
   368 lemma dual_linorder:
   514 
   513 
   515 (* The type constraint on @{term op =} below is necessary since the operation
   514 (* The type constraint on @{term op =} below is necessary since the operation
   516    is not a parameter of the locale. *)
   515    is not a parameter of the locale. *)
   517 
   516 
   518 declare less_irrefl [THEN notE, order add less_reflE: order "op = :: 'a \<Rightarrow> 'a \<Rightarrow> bool" "op <=" "op <"]
   517 declare less_irrefl [THEN notE, order add less_reflE: order "op = :: 'a \<Rightarrow> 'a \<Rightarrow> bool" "op <=" "op <"]
   519   
   518 
   520 declare order_refl  [order add le_refl: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   519 declare order_refl  [order add le_refl: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   521   
   520 
   522 declare less_imp_le [order add less_imp_le: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   521 declare less_imp_le [order add less_imp_le: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   523   
   522 
   524 declare antisym [order add eqI: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   523 declare antisym [order add eqI: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   525 
   524 
   526 declare eq_refl [order add eqD1: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   525 declare eq_refl [order add eqD1: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   527 
   526 
   528 declare sym [THEN eq_refl, order add eqD2: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   527 declare sym [THEN eq_refl, order add eqD2: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   529 
   528 
   530 declare less_trans [order add less_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   529 declare less_trans [order add less_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   531   
   530 
   532 declare less_le_trans [order add less_le_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   531 declare less_le_trans [order add less_le_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   533   
   532 
   534 declare le_less_trans [order add le_less_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   533 declare le_less_trans [order add le_less_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   535 
   534 
   536 declare order_trans [order add le_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   535 declare order_trans [order add le_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   537 
   536 
   538 declare le_neq_trans [order add le_neq_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   537 declare le_neq_trans [order add le_neq_trans: order "op = :: 'a => 'a => bool" "op <=" "op <"]
   948   "(x::'a::order) >= y ==> y > z ==> x > z"
   947   "(x::'a::order) >= y ==> y > z ==> x > z"
   949   "(a::'a::order) > b ==> b > a ==> P"
   948   "(a::'a::order) > b ==> b > a ==> P"
   950   "(x::'a::order) > y ==> y > z ==> x > z"
   949   "(x::'a::order) > y ==> y > z ==> x > z"
   951   "(a::'a::order) >= b ==> a ~= b ==> a > b"
   950   "(a::'a::order) >= b ==> a ~= b ==> a > b"
   952   "(a::'a::order) ~= b ==> a >= b ==> a > b"
   951   "(a::'a::order) ~= b ==> a >= b ==> a > b"
   953   "a = f b ==> b > c ==> (!!x y. x > y ==> f x > f y) ==> a > f c" 
   952   "a = f b ==> b > c ==> (!!x y. x > y ==> f x > f y) ==> a > f c"
   954   "a > b ==> f b = c ==> (!!x y. x > y ==> f x > f y) ==> f a > c"
   953   "a > b ==> f b = c ==> (!!x y. x > y ==> f x > f y) ==> f a > c"
   955   "a = f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
   954   "a = f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
   956   "a >= b ==> f b = c ==> (!! x y. x >= y ==> f x >= f y) ==> f a >= c"
   955   "a >= b ==> f b = c ==> (!! x y. x >= y ==> f x >= f y) ==> f a >= c"
   957   by auto
   956   by auto
   958 
   957 
   988     (!!x y. x > y ==> f x > f y) ==> f a > c"
   987     (!!x y. x > y ==> f x > f y) ==> f a > c"
   989 by (subgoal_tac "f a > f b", force, force)
   988 by (subgoal_tac "f a > f b", force, force)
   990 
   989 
   991 lemmas xtrans = xt1 xt2 xt3 xt4 xt5 xt6 xt7 xt8 xt9
   990 lemmas xtrans = xt1 xt2 xt3 xt4 xt5 xt6 xt7 xt8 xt9
   992 
   991 
   993 (* 
   992 (*
   994   Since "a >= b" abbreviates "b <= a", the abbreviation "..." stands
   993   Since "a >= b" abbreviates "b <= a", the abbreviation "..." stands
   995   for the wrong thing in an Isar proof.
   994   for the wrong thing in an Isar proof.
   996 
   995 
   997   The extra transitivity rules can be used as follows: 
   996   The extra transitivity rules can be used as follows:
   998 
   997 
   999 lemma "(a::'a::order) > z"
   998 lemma "(a::'a::order) > z"
  1000 proof -
   999 proof -
  1001   have "a >= b" (is "_ >= ?rhs")
  1000   have "a >= b" (is "_ >= ?rhs")
  1002     sorry
  1001     sorry
  1143     assume "\<not> x \<le> y" then have "y < x" by simp
  1142     assume "\<not> x \<le> y" then have "y < x" by simp
  1144     with assms strict_monoD have "f y < f x" by auto
  1143     with assms strict_monoD have "f y < f x" by auto
  1145     with \<open>f x \<le> f y\<close> show False by simp
  1144     with \<open>f x \<le> f y\<close> show False by simp
  1146   qed
  1145   qed
  1147 qed
  1146 qed
  1148   
  1147 
  1149 lemma strict_mono_less:
  1148 lemma strict_mono_less:
  1150   assumes "strict_mono f"
  1149   assumes "strict_mono f"
  1151   shows "f x < f y \<longleftrightarrow> x < y"
  1150   shows "f x < f y \<longleftrightarrow> x < y"
  1152   using assms
  1151   using assms
  1153     by (auto simp add: less_le Orderings.less_le strict_mono_eq strict_mono_less_eq)
  1152     by (auto simp add: less_le Orderings.less_le strict_mono_eq strict_mono_less_eq)
  1315   qed
  1314   qed
  1316 qed
  1315 qed
  1317 
  1316 
  1318 end
  1317 end
  1319 
  1318 
  1320 class no_top = order + 
  1319 class no_top = order +
  1321   assumes gt_ex: "\<exists>y. x < y"
  1320   assumes gt_ex: "\<exists>y. x < y"
  1322 
  1321 
  1323 class no_bot = order + 
  1322 class no_bot = order +
  1324   assumes lt_ex: "\<exists>y. y < x"
  1323   assumes lt_ex: "\<exists>y. y < x"
  1325 
  1324 
  1326 class unbounded_dense_linorder = dense_linorder + no_top + no_bot
  1325 class unbounded_dense_linorder = dense_linorder + no_top + no_bot
  1327 
  1326 
  1328 
  1327