src/HOL/Library/Order_Relation.thy
author haftmann
Wed, 25 Nov 2009 11:16:57 +0100
changeset 33959 2afc55e8ed27
parent 30661 54858c8ad226
child 39198 f967a16dfcdd
permissions -rw-r--r--
bootstrap datatype_rep_proofs in Datatype.thy (avoids unchecked dynamic name references)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30661
54858c8ad226 tuned header
haftmann
parents: 30198
diff changeset
     1
(* Author: Tobias Nipkow *)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     2
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     3
header {* Orders as Relations *}
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     4
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     5
theory Order_Relation
29859
33bff35f1335 Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents: 28952
diff changeset
     6
imports Main
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     7
begin
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     8
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
     9
subsection{* Orders on a set *}
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    10
30198
922f944f03b2 name changes
nipkow
parents: 29859
diff changeset
    11
definition "preorder_on A r \<equiv> refl_on A r \<and> trans r"
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    12
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    13
definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    14
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    15
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
    16
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    17
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
    18
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    19
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
    20
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    21
lemmas order_on_defs =
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    22
  preorder_on_def partial_order_on_def linear_order_on_def
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    23
  strict_linear_order_on_def well_order_on_def
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    24
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    25
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    26
lemma preorder_on_empty[simp]: "preorder_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    27
by(simp add:preorder_on_def trans_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    28
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    29
lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    30
by(simp add:partial_order_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    31
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    32
lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    33
by(simp add:linear_order_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    34
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    35
lemma well_order_on_empty[simp]: "well_order_on {} {}"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    36
by(simp add:well_order_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    37
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    38
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    39
lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    40
by (simp add:preorder_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    41
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    42
lemma partial_order_on_converse[simp]:
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    43
  "partial_order_on A (r^-1) = partial_order_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    44
by (simp add: partial_order_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    45
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    46
lemma linear_order_on_converse[simp]:
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    47
  "linear_order_on A (r^-1) = linear_order_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    48
by (simp add: linear_order_on_def)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    49
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    50
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    51
lemma strict_linear_order_on_diff_Id:
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    52
  "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    53
by(simp add: order_on_defs trans_diff_Id)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    54
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    55
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    56
subsection{* Orders on the field *}
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    57
30198
922f944f03b2 name changes
nipkow
parents: 29859
diff changeset
    58
abbreviation "Refl r \<equiv> refl_on (Field r) r"
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    59
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    60
abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    61
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    62
abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    63
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    64
abbreviation "Total r \<equiv> total_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    65
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    66
abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    67
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    68
abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    69
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    70
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    71
lemma subset_Image_Image_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    72
  "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    73
   r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
30198
922f944f03b2 name changes
nipkow
parents: 29859
diff changeset
    74
apply(auto simp add: subset_eq preorder_on_def refl_on_def Image_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    75
apply metis
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    76
by(metis trans_def)
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    77
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    78
lemma subset_Image1_Image1_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    79
  "\<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
    80
by(simp add:subset_Image_Image_iff)
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    81
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    82
lemma Refl_antisym_eq_Image1_Image1_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    83
  "\<lbrakk>Refl r; antisym r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
30198
922f944f03b2 name changes
nipkow
parents: 29859
diff changeset
    84
by(simp add: expand_set_eq antisym_def refl_on_def) metis
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    85
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    86
lemma Partial_order_eq_Image1_Image1_iff:
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    87
  "\<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
    88
by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    89
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    90
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    91
subsection{* Orders on a type *}
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    92
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    93
abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    94
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    95
abbreviation "linear_order \<equiv> linear_order_on UNIV"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    96
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    97
abbreviation "well_order r \<equiv> well_order_on UNIV"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    98
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    99
end