src/HOL/Library/Order_Relation.thy
author nipkow
Mon, 17 Mar 2008 16:47:45 +0100
changeset 26298 53e382ccf71f
parent 26295 afc43168ed85
child 26806 40b411ec05aa
permissions -rw-r--r--
reorganization
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     1
(*  ID          : $Id$
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     2
    Author      : Tobias Nipkow
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     3
*)
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     4
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     5
header {* Orders as Relations *}
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     6
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     7
theory Order_Relation
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     8
imports ATP_Linkup Hilbert_Choice
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     9
begin
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    10
26298
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
    11
text{* This prelude could be moved to theory Relation: *}
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    12
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    13
definition "irrefl r \<equiv> \<forall>x. (x,x) \<notin> r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    14
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    15
definition "total_on A r \<equiv> \<forall>x\<in>A.\<forall>y\<in>A. x\<noteq>y \<longrightarrow> (x,y)\<in>r \<or> (y,x)\<in>r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    16
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    17
abbreviation "total \<equiv> total_on UNIV"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    18
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    19
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    20
lemma total_on_empty[simp]: "total_on {} r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    21
by(simp add:total_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    22
26298
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
    23
lemma refl_on_converse[simp]: "refl A (r^-1) = refl A r"
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
    24
by(auto simp add:refl_def)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    25
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    26
lemma total_on_converse[simp]: "total_on A (r^-1) = total_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    27
by (auto simp: total_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    28
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    29
lemma irrefl_diff_Id[simp]: "irrefl(r-Id)"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    30
by(simp add:irrefl_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    31
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    32
declare [[simp_depth_limit = 2]]
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    33
lemma trans_diff_Id: " trans r \<Longrightarrow> antisym r \<Longrightarrow> trans (r-Id)"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    34
by(simp add: antisym_def trans_def) blast
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    35
declare [[simp_depth_limit = 50]]
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    36
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    37
lemma total_on_diff_Id[simp]: "total_on A (r-Id) = total_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    38
by(simp add: total_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    39
26298
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
    40
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    41
subsection{* Orders on a set *}
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    42
26298
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
    43
definition "preorder_on A r \<equiv> refl A r \<and> trans r"
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    44
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    45
definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    46
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    47
definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    48
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    49
definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    50
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    51
definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    52
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    53
lemmas order_on_defs =
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    54
  preorder_on_def partial_order_on_def linear_order_on_def
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    55
  strict_linear_order_on_def well_order_on_def
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    56
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    57
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    58
lemma preorder_on_empty[simp]: "preorder_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    59
by(simp add:preorder_on_def trans_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    60
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    61
lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    62
by(simp add:partial_order_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    63
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    64
lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    65
by(simp add:linear_order_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    66
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    67
lemma well_order_on_empty[simp]: "well_order_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    68
by(simp add:well_order_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    69
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    70
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    71
lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    72
by (simp add:preorder_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    73
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    74
lemma partial_order_on_converse[simp]:
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    75
  "partial_order_on A (r^-1) = partial_order_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    76
by (simp add: partial_order_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    77
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    78
lemma linear_order_on_converse[simp]:
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    79
  "linear_order_on A (r^-1) = linear_order_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    80
by (simp add: linear_order_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    81
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    82
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    83
lemma strict_linear_order_on_diff_Id:
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    84
  "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    85
by(simp add: order_on_defs trans_diff_Id)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    86
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    87
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    88
subsection{* Orders on the field *}
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    89
26298
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
    90
abbreviation "Refl r \<equiv> refl (Field r) r"
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    91
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    92
abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    93
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    94
abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    95
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    96
abbreviation "Total r \<equiv> total_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    97
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    98
abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    99
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   100
abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   101
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   102
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   103
lemma subset_Image_Image_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   104
  "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   105
   r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
26298
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
   106
apply(auto simp add:subset_def preorder_on_def refl_def Image_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   107
apply metis
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   108
by(metis trans_def)
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   109
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   110
lemma subset_Image1_Image1_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   111
  "\<lbrakk> Preorder r; a : Field r; b : Field r\<rbrakk> \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b,a):r"
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   112
by(simp add:subset_Image_Image_iff)
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   113
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   114
lemma Refl_antisym_eq_Image1_Image1_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   115
  "\<lbrakk>Refl r; antisym r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
26298
53e382ccf71f reorganization
nipkow
parents: 26295
diff changeset
   116
by(simp add: expand_set_eq antisym_def refl_def) metis
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   117
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   118
lemma Partial_order_eq_Image1_Image1_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   119
  "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   120
by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   121
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   122
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   123
subsection{* Orders on a type *}
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   124
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   125
abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   126
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   127
abbreviation "linear_order \<equiv> linear_order_on UNIV"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   128
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   129
abbreviation "well_order r \<equiv> well_order_on UNIV"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   130
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   131
end