src/HOLCF/Porder.thy
author huffman
Tue, 18 Dec 2007 19:15:31 +0100
changeset 25695 7025a263aa49
parent 25131 2c8caac48ade
child 25773 0d585d756745
permissions -rw-r--r--
rearrange into subsections
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15600
a59f07556a8d fixed filename in header
huffman
parents: 15587
diff changeset
     1
(*  Title:      HOLCF/Porder.thy
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     2
    ID:         $Id$
1479
21eb5e156d91 expanded tabs
clasohm
parents: 1274
diff changeset
     3
    Author:     Franz Regensburger
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     4
*)
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     5
15587
f363e6e080e7 added subsections and text for document generation
huffman
parents: 15577
diff changeset
     6
header {* Partial orders *}
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
     7
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     8
theory Porder
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23284
diff changeset
     9
imports Datatype Finite_Set
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    10
begin
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    11
15587
f363e6e080e7 added subsections and text for document generation
huffman
parents: 15577
diff changeset
    12
subsection {* Type class for partial orders *}
f363e6e080e7 added subsections and text for document generation
huffman
parents: 15577
diff changeset
    13
23284
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    14
class sq_ord = type +
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    15
  fixes sq_le :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    16
23284
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    17
notation
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    18
  sq_le (infixl "<<" 55)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    19
23284
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    20
notation (xsymbols)
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    21
  sq_le (infixl "\<sqsubseteq>" 55)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    22
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    23
axclass po < sq_ord
23284
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    24
  refl_less [iff]: "x \<sqsubseteq> x"
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    25
  antisym_less:    "\<lbrakk>x \<sqsubseteq> y; y \<sqsubseteq> x\<rbrakk> \<Longrightarrow> x = y"
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    26
  trans_less:      "\<lbrakk>x \<sqsubseteq> y; y \<sqsubseteq> z\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    27
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    28
text {* minimal fixes least element *}
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    29
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    30
lemma minimal2UU[OF allI] : "\<forall>x::'a::po. uu \<sqsubseteq> x \<Longrightarrow> uu = (THE u. \<forall>y. u \<sqsubseteq> y)"
15930
145651bc64a8 Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents: 15600
diff changeset
    31
by (blast intro: theI2 antisym_less)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    32
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    33
text {* the reverse law of anti-symmetry of @{term "op <<"} *}
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    34
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    35
lemma antisym_less_inverse: "(x::'a::po) = y \<Longrightarrow> x \<sqsubseteq> y \<and> y \<sqsubseteq> x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    36
by simp
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    37
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    38
lemma box_less: "\<lbrakk>(a::'a::po) \<sqsubseteq> b; c \<sqsubseteq> a; b \<sqsubseteq> d\<rbrakk> \<Longrightarrow> c \<sqsubseteq> d"
18088
e5b23b85e932 cleaned up
huffman
parents: 18071
diff changeset
    39
by (rule trans_less [OF trans_less])
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    40
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    41
lemma po_eq_conv: "((x::'a::po) = y) = (x \<sqsubseteq> y \<and> y \<sqsubseteq> x)"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    42
by (fast elim!: antisym_less_inverse intro!: antisym_less)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    43
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    44
lemma rev_trans_less: "\<lbrakk>(y::'a::po) \<sqsubseteq> z; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    45
by (rule trans_less)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    46
18647
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    47
lemma sq_ord_less_eq_trans: "\<lbrakk>a \<sqsubseteq> b; b = c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> c"
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    48
by (rule subst)
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    49
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    50
lemma sq_ord_eq_less_trans: "\<lbrakk>a = b; b \<sqsubseteq> c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> c"
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    51
by (rule ssubst)
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    52
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    53
lemmas HOLCF_trans_rules [trans] =
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    54
  trans_less
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    55
  antisym_less
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    56
  sq_ord_less_eq_trans
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    57
  sq_ord_eq_less_trans
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    58
25695
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
    59
subsection {* Least upper bounds *}
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
    60
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    61
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    62
  is_ub :: "['a set, 'a::po] \<Rightarrow> bool"  (infixl "<|" 55)  where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    63
  "(S <| x) = (\<forall>y. y \<in> S \<longrightarrow> y \<sqsubseteq> x)"
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
    64
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    65
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    66
  is_lub :: "['a set, 'a::po] \<Rightarrow> bool"  (infixl "<<|" 55)  where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    67
  "(S <<| x) = (S <| x \<and> (\<forall>u. S <| u \<longrightarrow> x \<sqsubseteq> u))"
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
    68
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    69
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    70
  lub :: "'a set \<Rightarrow> 'a::po" where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    71
  "lub S = (THE x. S <<| x)"
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    72
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
    73
abbreviation
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
    74
  Lub  (binder "LUB " 10) where
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
    75
  "LUB n. t n == lub (range t)"
2394
91d8abf108be adaptions for symbol font
oheimb
parents: 2291
diff changeset
    76
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
    77
notation (xsymbols)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
    78
  Lub  (binder "\<Squnion> " 10)
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    79
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    80
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    81
text {* lubs are unique *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    82
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    83
lemma unique_lub: "\<lbrakk>S <<| x; S <<| y\<rbrakk> \<Longrightarrow> x = y"
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    84
apply (unfold is_lub_def is_ub_def)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    85
apply (blast intro: antisym_less)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    86
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    87
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    88
text {* technical lemmas about @{term lub} and @{term is_lub} *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    89
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    90
lemma lubI: "M <<| x \<Longrightarrow> M <<| lub M"
15930
145651bc64a8 Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents: 15600
diff changeset
    91
apply (unfold lub_def)
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    92
apply (rule theI)
15930
145651bc64a8 Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents: 15600
diff changeset
    93
apply assumption
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    94
apply (erule (1) unique_lub)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    95
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    96
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    97
lemma thelubI: "M <<| l \<Longrightarrow> lub M = l"
18088
e5b23b85e932 cleaned up
huffman
parents: 18071
diff changeset
    98
by (rule unique_lub [OF lubI])
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
    99
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   100
lemma lub_singleton [simp]: "lub {x} = x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   101
by (simp add: thelubI is_lub_def is_ub_def)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   102
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   103
text {* access to some definition as inference rule *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   104
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   105
lemma is_lubD1: "S <<| x \<Longrightarrow> S <| x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   106
by (unfold is_lub_def, simp)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   107
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   108
lemma is_lub_lub: "\<lbrakk>S <<| x; S <| u\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   109
by (unfold is_lub_def, simp)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   110
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   111
lemma is_lubI: "\<lbrakk>S <| x; \<And>u. S <| u \<Longrightarrow> x \<sqsubseteq> u\<rbrakk> \<Longrightarrow> S <<| x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   112
by (unfold is_lub_def, fast)
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
   113
25695
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   114
subsection {* Countable chains *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   115
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   116
definition
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   117
  -- {* Here we use countable chains and I prefer to code them as functions! *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   118
  chain :: "(nat \<Rightarrow> 'a::po) \<Rightarrow> bool" where
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   119
  "chain F = (\<forall>i. F i \<sqsubseteq> F (Suc i))"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   120
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   121
text {* chains are monotone functions *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   122
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   123
lemma chain_mono [rule_format]: "chain F \<Longrightarrow> x < y \<longrightarrow> F x \<sqsubseteq> F y"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   124
apply (unfold chain_def)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   125
apply (induct_tac y)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   126
apply simp
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   127
apply (blast elim: less_SucE intro: trans_less)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   128
done
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   129
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   130
lemma chain_mono3: "\<lbrakk>chain F; x \<le> y\<rbrakk> \<Longrightarrow> F x \<sqsubseteq> F y"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   131
apply (drule le_imp_less_or_eq)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   132
apply (blast intro: chain_mono)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   133
done
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   134
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   135
lemma chainE: "chain F \<Longrightarrow> F i \<sqsubseteq> F (Suc i)"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   136
by (unfold chain_def, simp)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   137
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   138
lemma chainI: "(\<And>i. F i \<sqsubseteq> F (Suc i)) \<Longrightarrow> chain F"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   139
by (unfold chain_def, simp)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   140
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   141
lemma chain_shift: "chain Y \<Longrightarrow> chain (\<lambda>i. Y (i + j))"
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   142
apply (rule chainI)
16318
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   143
apply simp
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   144
apply (erule chainE)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   145
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   146
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   147
text {* technical lemmas about (least) upper bounds of chains *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   148
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   149
lemma ub_rangeD: "range S <| x \<Longrightarrow> S i \<sqsubseteq> x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   150
by (unfold is_ub_def, simp)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   151
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   152
lemma ub_rangeI: "(\<And>i. S i \<sqsubseteq> x) \<Longrightarrow> range S <| x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   153
by (unfold is_ub_def, fast)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   154
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   155
lemma is_ub_lub: "range S <<| x \<Longrightarrow> S i \<sqsubseteq> x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   156
by (rule is_lubD1 [THEN ub_rangeD])
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   157
16318
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   158
lemma is_ub_range_shift:
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   159
  "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <| x = range S <| x"
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   160
apply (rule iffI)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   161
apply (rule ub_rangeI)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   162
apply (rule_tac y="S (i + j)" in trans_less)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   163
apply (erule chain_mono3)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   164
apply (rule le_add1)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   165
apply (erule ub_rangeD)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   166
apply (rule ub_rangeI)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   167
apply (erule ub_rangeD)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   168
done
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   169
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   170
lemma is_lub_range_shift:
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   171
  "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <<| x = range S <<| x"
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   172
by (simp add: is_lub_def is_ub_range_shift)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   173
25695
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   174
text {* the lub of a constant chain is the constant *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   175
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   176
lemma chain_const [simp]: "chain (\<lambda>i. c)"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   177
by (simp add: chainI)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   178
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   179
lemma lub_const: "range (\<lambda>x. c) <<| c"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   180
by (blast dest: ub_rangeD intro: is_lubI ub_rangeI)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   181
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   182
lemma thelub_const [simp]: "(\<Squnion>i. c) = c"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   183
by (rule lub_const [THEN thelubI])
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   184
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   185
subsection {* Totally ordered sets *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   186
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   187
definition
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   188
  -- {* Arbitrary chains are total orders *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   189
  tord :: "'a::po set \<Rightarrow> bool" where
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   190
  "tord S = (\<forall>x y. x \<in> S \<and> y \<in> S \<longrightarrow> (x \<sqsubseteq> y \<or> y \<sqsubseteq> x))"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   191
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   192
text {* The range of a chain is a totally ordered *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   193
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   194
lemma chain_tord: "chain F \<Longrightarrow> tord (range F)"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   195
apply (unfold tord_def, clarify)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   196
apply (rule nat_less_cases)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   197
apply (fast intro: chain_mono)+
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   198
done
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   199
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   200
lemma finite_tord_has_max [rule_format]:
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   201
  "finite S \<Longrightarrow> S \<noteq> {} \<longrightarrow> tord S \<longrightarrow> (\<exists>y\<in>S. \<forall>x\<in>S. x \<sqsubseteq> y)"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   202
 apply (erule finite_induct, simp)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   203
 apply (rename_tac a S, clarify)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   204
 apply (case_tac "S = {}", simp)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   205
 apply (drule (1) mp)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   206
 apply (drule mp, simp add: tord_def)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   207
 apply (erule bexE, rename_tac z)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   208
 apply (subgoal_tac "a \<sqsubseteq> z \<or> z \<sqsubseteq> a")
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   209
  apply (erule disjE)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   210
   apply (rule_tac x="z" in bexI, simp, simp)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   211
  apply (rule_tac x="a" in bexI)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   212
   apply (clarsimp elim!: rev_trans_less)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   213
  apply simp
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   214
 apply (simp add: tord_def)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   215
done
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   216
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   217
subsection {* Finite chains *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   218
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   219
definition
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   220
  -- {* finite chains, needed for monotony of continuous functions *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   221
  max_in_chain :: "[nat, nat \<Rightarrow> 'a::po] \<Rightarrow> bool" where
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   222
  "max_in_chain i C = (\<forall>j. i \<le> j \<longrightarrow> C i = C j)"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   223
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   224
definition
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   225
  finite_chain :: "(nat \<Rightarrow> 'a::po) \<Rightarrow> bool" where
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   226
  "finite_chain C = (chain C \<and> (\<exists>i. max_in_chain i C))"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   227
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   228
text {* results about finite chains *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   229
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   230
lemma lub_finch1: "\<lbrakk>chain C; max_in_chain i C\<rbrakk> \<Longrightarrow> range C <<| C i"
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   231
apply (unfold max_in_chain_def)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   232
apply (rule is_lubI)
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   233
apply (rule ub_rangeI, rename_tac j)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   234
apply (rule_tac x=i and y=j in linorder_le_cases)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   235
apply simp
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   236
apply (erule (1) chain_mono3)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   237
apply (erule ub_rangeD)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   238
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   239
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
   240
lemma lub_finch2:
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   241
        "finite_chain C \<Longrightarrow> range C <<| C (LEAST i. max_in_chain i C)"
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   242
apply (unfold finite_chain_def)
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   243
apply (erule conjE)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   244
apply (erule LeastI2_ex)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   245
apply (erule (1) lub_finch1)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   246
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   247
19621
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   248
lemma finch_imp_finite_range: "finite_chain Y \<Longrightarrow> finite (range Y)"
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   249
 apply (unfold finite_chain_def, clarify)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   250
 apply (rule_tac f="Y" and n="Suc i" in nat_seg_image_imp_finite)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   251
 apply (rule equalityI)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   252
  apply (rule subsetI)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   253
  apply (erule rangeE, rename_tac j)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   254
  apply (rule_tac x=i and y=j in linorder_le_cases)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   255
   apply (subgoal_tac "Y j = Y i", simp)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   256
   apply (simp add: max_in_chain_def)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   257
  apply simp
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   258
 apply fast
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   259
done
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   260
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   261
lemma finite_range_imp_finch:
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   262
  "\<lbrakk>chain Y; finite (range Y)\<rbrakk> \<Longrightarrow> finite_chain Y"
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   263
 apply (subgoal_tac "\<exists>y\<in>range Y. \<forall>x\<in>range Y. x \<sqsubseteq> y")
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   264
  apply (clarsimp, rename_tac i)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   265
  apply (subgoal_tac "max_in_chain i Y")
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   266
   apply (simp add: finite_chain_def exI)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   267
  apply (simp add: max_in_chain_def po_eq_conv chain_mono3)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   268
 apply (erule finite_tord_has_max, simp)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   269
 apply (erule chain_tord)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   270
done
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   271
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   272
lemma bin_chain: "x \<sqsubseteq> y \<Longrightarrow> chain (\<lambda>i. if i=0 then x else y)"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   273
by (rule chainI, simp)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   274
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   275
lemma bin_chainmax:
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   276
  "x \<sqsubseteq> y \<Longrightarrow> max_in_chain (Suc 0) (\<lambda>i. if i=0 then x else y)"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   277
by (unfold max_in_chain_def, simp)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   278
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   279
lemma lub_bin_chain:
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   280
  "x \<sqsubseteq> y \<Longrightarrow> range (\<lambda>i::nat. if i=0 then x else y) <<| y"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   281
apply (frule bin_chain)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   282
apply (drule bin_chainmax)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   283
apply (drule (1) lub_finch1)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   284
apply simp
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   285
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   286
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   287
text {* the maximal element in a chain is its lub *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   288
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   289
lemma lub_chain_maxelem: "\<lbrakk>Y i = c; \<forall>i. Y i \<sqsubseteq> c\<rbrakk> \<Longrightarrow> lub (range Y) = c"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   290
by (blast dest: ub_rangeD intro: thelubI is_lubI ub_rangeI)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   291
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
   292
end