src/HOL/Order_Relation.thy
author blanchet
Thu Nov 21 21:33:34 2013 +0100 (2013-11-21)
changeset 54552 5d57cbec0f0f
parent 54551 src/HOL/Library/Order_Relation.thy@4cd6deb430c3
child 55026 258fa7b5a621
permissions -rw-r--r--
moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
blanchet@54552
     1
(*  Title:      HOL/Order_Relation.thy
blanchet@54552
     2
    Author:     Tobias Nipkow
blanchet@54552
     3
*)
nipkow@26273
     4
nipkow@26273
     5
header {* Orders as Relations *}
nipkow@26273
     6
nipkow@26273
     7
theory Order_Relation
blanchet@54552
     8
imports Wellfounded
nipkow@26273
     9
begin
nipkow@26273
    10
nipkow@26295
    11
subsection{* Orders on a set *}
nipkow@26295
    12
nipkow@30198
    13
definition "preorder_on A r \<equiv> refl_on A r \<and> trans r"
nipkow@26295
    14
nipkow@26295
    15
definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
nipkow@26273
    16
nipkow@26295
    17
definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r"
nipkow@26295
    18
nipkow@26295
    19
definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r"
nipkow@26295
    20
nipkow@26295
    21
definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)"
nipkow@26273
    22
nipkow@26295
    23
lemmas order_on_defs =
nipkow@26295
    24
  preorder_on_def partial_order_on_def linear_order_on_def
nipkow@26295
    25
  strict_linear_order_on_def well_order_on_def
nipkow@26295
    26
nipkow@26273
    27
nipkow@26295
    28
lemma preorder_on_empty[simp]: "preorder_on {} {}"
nipkow@26295
    29
by(simp add:preorder_on_def trans_def)
nipkow@26295
    30
nipkow@26295
    31
lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
nipkow@26295
    32
by(simp add:partial_order_on_def)
nipkow@26273
    33
nipkow@26295
    34
lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
nipkow@26295
    35
by(simp add:linear_order_on_def)
nipkow@26295
    36
nipkow@26295
    37
lemma well_order_on_empty[simp]: "well_order_on {} {}"
nipkow@26295
    38
by(simp add:well_order_on_def)
nipkow@26295
    39
nipkow@26273
    40
nipkow@26295
    41
lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
nipkow@26295
    42
by (simp add:preorder_on_def)
nipkow@26295
    43
nipkow@26295
    44
lemma partial_order_on_converse[simp]:
nipkow@26295
    45
  "partial_order_on A (r^-1) = partial_order_on A r"
nipkow@26295
    46
by (simp add: partial_order_on_def)
nipkow@26273
    47
nipkow@26295
    48
lemma linear_order_on_converse[simp]:
nipkow@26295
    49
  "linear_order_on A (r^-1) = linear_order_on A r"
nipkow@26295
    50
by (simp add: linear_order_on_def)
nipkow@26295
    51
nipkow@26273
    52
nipkow@26295
    53
lemma strict_linear_order_on_diff_Id:
nipkow@26295
    54
  "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
nipkow@26295
    55
by(simp add: order_on_defs trans_diff_Id)
nipkow@26295
    56
nipkow@26295
    57
nipkow@26295
    58
subsection{* Orders on the field *}
nipkow@26273
    59
nipkow@30198
    60
abbreviation "Refl r \<equiv> refl_on (Field r) r"
nipkow@26295
    61
nipkow@26295
    62
abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
nipkow@26295
    63
nipkow@26295
    64
abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
nipkow@26273
    65
nipkow@26295
    66
abbreviation "Total r \<equiv> total_on (Field r) r"
nipkow@26295
    67
nipkow@26295
    68
abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
nipkow@26295
    69
nipkow@26295
    70
abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
nipkow@26295
    71
nipkow@26273
    72
nipkow@26273
    73
lemma subset_Image_Image_iff:
nipkow@26273
    74
  "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
nipkow@26273
    75
   r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
blanchet@48750
    76
unfolding preorder_on_def refl_on_def Image_def
blanchet@48750
    77
apply (simp add: subset_eq)
blanchet@48750
    78
unfolding trans_def by fast
nipkow@26273
    79
nipkow@26273
    80
lemma subset_Image1_Image1_iff:
nipkow@26273
    81
  "\<lbrakk> Preorder r; a : Field r; b : Field r\<rbrakk> \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b,a):r"
nipkow@26273
    82
by(simp add:subset_Image_Image_iff)
nipkow@26273
    83
nipkow@26273
    84
lemma Refl_antisym_eq_Image1_Image1_iff:
blanchet@54552
    85
  assumes r: "Refl r" and as: "antisym r" and abf: "a \<in> Field r" "b \<in> Field r"
blanchet@54552
    86
  shows "r `` {a} = r `` {b} \<longleftrightarrow> a = b"
blanchet@54552
    87
proof
blanchet@54552
    88
  assume "r `` {a} = r `` {b}"
blanchet@54552
    89
  hence e: "\<And>x. (a, x) \<in> r \<longleftrightarrow> (b, x) \<in> r" by (simp add: set_eq_iff)
blanchet@54552
    90
  have "(a, a) \<in> r" "(b, b) \<in> r" using r abf by (simp_all add: refl_on_def)
blanchet@54552
    91
  hence "(a, b) \<in> r" "(b, a) \<in> r" using e[of a] e[of b] by simp_all
blanchet@54552
    92
  thus "a = b" using as[unfolded antisym_def] by blast
blanchet@54552
    93
qed fast
nipkow@26273
    94
nipkow@26273
    95
lemma Partial_order_eq_Image1_Image1_iff:
nipkow@26273
    96
  "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
nipkow@26295
    97
by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
nipkow@26295
    98
popescua@52182
    99
lemma Total_Id_Field:
popescua@52182
   100
assumes TOT: "Total r" and NID: "\<not> (r <= Id)"
popescua@52182
   101
shows "Field r = Field(r - Id)"
popescua@52182
   102
using mono_Field[of "r - Id" r] Diff_subset[of r Id]
popescua@52182
   103
proof(auto)
popescua@52182
   104
  have "r \<noteq> {}" using NID by fast
blanchet@54482
   105
  then obtain b and c where "b \<noteq> c \<and> (b,c) \<in> r" using NID by auto
popescua@52182
   106
  hence 1: "b \<noteq> c \<and> {b,c} \<le> Field r" by (auto simp: Field_def)
blanchet@54552
   107
popescua@52182
   108
  fix a assume *: "a \<in> Field r"
popescua@52182
   109
  obtain d where 2: "d \<in> Field r" and 3: "d \<noteq> a"
popescua@52182
   110
  using * 1 by auto
popescua@52182
   111
  hence "(a,d) \<in> r \<or> (d,a) \<in> r" using * TOT
popescua@52182
   112
  by (simp add: total_on_def)
popescua@52182
   113
  thus "a \<in> Field(r - Id)" using 3 unfolding Field_def by blast
popescua@52182
   114
qed
popescua@52182
   115
nipkow@26295
   116
nipkow@26295
   117
subsection{* Orders on a type *}
nipkow@26295
   118
nipkow@26295
   119
abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
nipkow@26295
   120
nipkow@26295
   121
abbreviation "linear_order \<equiv> linear_order_on UNIV"
nipkow@26295
   122
blanchet@54551
   123
abbreviation "well_order \<equiv> well_order_on UNIV"
nipkow@26273
   124
nipkow@26273
   125
end