src/ZF/OrderArith.thy
author wenzelm
Wed, 27 Mar 2013 16:38:25 +0100
changeset 51553 63327f679cff
parent 46953 2b6e55924af3
child 58871 c399ae4b836f
permissions -rw-r--r--
more ambitious Goal.skip_proofs: covers Goal.prove forms as well, and do not insist in quick_and_dirty (for the sake of Isabelle/jEdit);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     1
(*  Title:      ZF/OrderArith.thy
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
     3
    Copyright   1994  University of Cambridge
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
     4
*)
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
     5
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
     6
header{*Combining Orderings: Foundations of Ordinal Arithmetic*}
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14171
diff changeset
     8
theory OrderArith imports Order Sum Ordinal begin
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
     9
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    10
definition
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
    11
  (*disjoint sum of two relations; underlies ordinal addition*)
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    12
  radd    :: "[i,i,i,i]=>i"  where
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    13
    "radd(A,r,B,s) ==
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    14
                {z: (A+B) * (A+B).
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    15
                    (\<exists>x y. z = <Inl(x), Inr(y)>)   |
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    16
                    (\<exists>x' x. z = <Inl(x'), Inl(x)> & <x',x>:r)   |
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
    17
                    (\<exists>y' y. z = <Inr(y'), Inr(y)> & <y',y>:s)}"
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
    18
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    19
definition
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
    20
  (*lexicographic product of two relations; underlies ordinal multiplication*)
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    21
  rmult   :: "[i,i,i,i]=>i"  where
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    22
    "rmult(A,r,B,s) ==
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    23
                {z: (A*B) * (A*B).
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    24
                    \<exists>x' y' x y. z = <<x',y'>, <x,y>> &
1155
928a16e02f9f removed \...\ inside strings
clasohm
parents: 753
diff changeset
    25
                       (<x',x>: r | (x'=x & <y',y>: s))}"
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
    26
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    27
definition
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
    28
  (*inverse image of a relation*)
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    29
  rvimage :: "[i,i,i]=>i"  where
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    30
    "rvimage(A,f,r) == {z \<in> A*A. \<exists>x y. z = <x,y> & <f`x,f`y>: r}"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    31
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    32
definition
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
    33
  measure :: "[i, i\<Rightarrow>i] \<Rightarrow> i"  where
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    34
    "measure(A,f) == {<x,y>: A*A. f(x) < f(y)}"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    35
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    36
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
    37
subsection{*Addition of Relations -- Disjoint Sum*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    38
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
    39
subsubsection{*Rewrite rules.  Can be used to obtain introduction rules*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    40
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    41
lemma radd_Inl_Inr_iff [iff]:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    42
    "<Inl(a), Inr(b)> \<in> radd(A,r,B,s)  \<longleftrightarrow>  a \<in> A & b \<in> B"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
    43
by (unfold radd_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    44
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    45
lemma radd_Inl_iff [iff]:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    46
    "<Inl(a'), Inl(a)> \<in> radd(A,r,B,s)  \<longleftrightarrow>  a':A & a \<in> A & <a',a>:r"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
    47
by (unfold radd_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    48
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    49
lemma radd_Inr_iff [iff]:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    50
    "<Inr(b'), Inr(b)> \<in> radd(A,r,B,s) \<longleftrightarrow>  b':B & b \<in> B & <b',b>:s"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
    51
by (unfold radd_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    52
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    53
lemma radd_Inr_Inl_iff [simp]:
46821
ff6b0c1087f2 Using mathematical notation for <-> and cardinal arithmetic
paulson
parents: 46820
diff changeset
    54
    "<Inr(b), Inl(a)> \<in> radd(A,r,B,s) \<longleftrightarrow> False"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
    55
by (unfold radd_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    56
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    57
declare radd_Inr_Inl_iff [THEN iffD1, dest!]
13823
d49ffd9f9662 fixed anomalies in the installed classical rules
paulson
parents: 13784
diff changeset
    58
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
    59
subsubsection{*Elimination Rule*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    60
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    61
lemma raddE:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    62
    "[| <p',p> \<in> radd(A,r,B,s);
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    63
        !!x y. [| p'=Inl(x); x \<in> A; p=Inr(y); y \<in> B |] ==> Q;
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    64
        !!x' x. [| p'=Inl(x'); p=Inl(x); <x',x>: r; x':A; x \<in> A |] ==> Q;
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    65
        !!y' y. [| p'=Inr(y'); p=Inr(y); <y',y>: s; y':B; y \<in> B |] ==> Q
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    66
     |] ==> Q"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    67
by (unfold radd_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    68
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
    69
subsubsection{*Type checking*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    70
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
    71
lemma radd_type: "radd(A,r,B,s) \<subseteq> (A+B) * (A+B)"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    72
apply (unfold radd_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    73
apply (rule Collect_subset)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    74
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    75
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    76
lemmas field_radd = radd_type [THEN field_rel_subset]
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    77
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
    78
subsubsection{*Linearity*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    79
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    80
lemma linear_radd:
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    81
    "[| linear(A,r);  linear(B,s) |] ==> linear(A+B,radd(A,r,B,s))"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    82
by (unfold linear_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    83
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    84
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
    85
subsubsection{*Well-foundedness*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    86
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    87
lemma wf_on_radd: "[| wf[A](r);  wf[B](s) |] ==> wf[A+B](radd(A,r,B,s))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    88
apply (rule wf_onI2)
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
    89
apply (subgoal_tac "\<forall>x\<in>A. Inl (x) \<in> Ba")
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
    90
 --{*Proving the lemma, which is needed twice!*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    91
 prefer 2
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
    92
 apply (erule_tac V = "y \<in> A + B" in thin_rl)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    93
 apply (rule_tac ballI)
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13634
diff changeset
    94
 apply (erule_tac r = r and a = x in wf_on_induct, assumption)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    95
 apply blast
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
    96
txt{*Returning to main part of proof*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    97
apply safe
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
    98
apply blast
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
    99
apply (erule_tac r = s and a = ya in wf_on_induct, assumption, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   100
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   101
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   102
lemma wf_radd: "[| wf(r);  wf(s) |] ==> wf(radd(field(r),r,field(s),s))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   103
apply (simp add: wf_iff_wf_on_field)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   104
apply (rule wf_on_subset_A [OF _ field_radd])
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   105
apply (blast intro: wf_on_radd)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   106
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   107
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   108
lemma well_ord_radd:
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   109
     "[| well_ord(A,r);  well_ord(B,s) |] ==> well_ord(A+B, radd(A,r,B,s))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   110
apply (rule well_ordI)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   111
apply (simp add: well_ord_def wf_on_radd)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   112
apply (simp add: well_ord_def tot_ord_def linear_radd)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   113
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   114
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   115
subsubsection{*An @{term ord_iso} congruence law*}
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
   116
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   117
lemma sum_bij:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   118
     "[| f \<in> bij(A,C);  g \<in> bij(B,D) |]
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   119
      ==> (\<lambda>z\<in>A+B. case(%x. Inl(f`x), %y. Inr(g`y), z)) \<in> bij(A+B, C+D)"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   120
apply (rule_tac d = "case (%x. Inl (converse(f)`x), %y. Inr(converse(g)`y))"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   121
       in lam_bijective)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   122
apply (typecheck add: bij_is_inj inj_is_fun)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   123
apply (auto simp add: left_inverse_bij right_inverse_bij)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   124
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   125
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   126
lemma sum_ord_iso_cong:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   127
    "[| f \<in> ord_iso(A,r,A',r');  g \<in> ord_iso(B,s,B',s') |] ==>
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   128
            (\<lambda>z\<in>A+B. case(%x. Inl(f`x), %y. Inr(g`y), z))
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   129
            \<in> ord_iso(A+B, radd(A,r,B,s), A'+B', radd(A',r',B',s'))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   130
apply (unfold ord_iso_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   131
apply (safe intro!: sum_bij)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   132
(*Do the beta-reductions now*)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   133
apply (auto cong add: conj_cong simp add: bij_is_fun [THEN apply_type])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   134
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   135
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   136
(*Could we prove an ord_iso result?  Perhaps
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   137
     ord_iso(A+B, radd(A,r,B,s), A \<union> B, r \<union> s) *)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   138
lemma sum_disjoint_bij: "A \<inter> B = 0 ==>
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   139
            (\<lambda>z\<in>A+B. case(%x. x, %y. y, z)) \<in> bij(A+B, A \<union> B)"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   140
apply (rule_tac d = "%z. if z \<in> A then Inl (z) else Inr (z) " in lam_bijective)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   141
apply auto
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   142
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   143
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   144
subsubsection{*Associativity*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   145
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   146
lemma sum_assoc_bij:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   147
     "(\<lambda>z\<in>(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z))
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   148
      \<in> bij((A+B)+C, A+(B+C))"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   149
apply (rule_tac d = "case (%x. Inl (Inl (x)), case (%x. Inl (Inr (x)), Inr))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   150
       in lam_bijective)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   151
apply auto
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   152
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   153
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   154
lemma sum_assoc_ord_iso:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   155
     "(\<lambda>z\<in>(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z))
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   156
      \<in> ord_iso((A+B)+C, radd(A+B, radd(A,r,B,s), C, t),
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   157
                A+(B+C), radd(A, r, B+C, radd(B,s,C,t)))"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   158
by (rule sum_assoc_bij [THEN ord_isoI], auto)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   159
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   160
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   161
subsection{*Multiplication of Relations -- Lexicographic Product*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   162
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   163
subsubsection{*Rewrite rule.  Can be used to obtain introduction rules*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   164
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   165
lemma  rmult_iff [iff]:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   166
    "<<a',b'>, <a,b>> \<in> rmult(A,r,B,s) \<longleftrightarrow>
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   167
            (<a',a>: r  & a':A & a \<in> A & b': B & b \<in> B) |
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   168
            (<b',b>: s  & a'=a & a \<in> A & b': B & b \<in> B)"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   169
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   170
by (unfold rmult_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   171
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   172
lemma rmultE:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   173
    "[| <<a',b'>, <a,b>> \<in> rmult(A,r,B,s);
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   174
        [| <a',a>: r;  a':A;  a \<in> A;  b':B;  b \<in> B |] ==> Q;
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   175
        [| <b',b>: s;  a \<in> A;  a'=a;  b':B;  b \<in> B |] ==> Q
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   176
     |] ==> Q"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   177
by blast
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   178
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   179
subsubsection{*Type checking*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   180
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   181
lemma rmult_type: "rmult(A,r,B,s) \<subseteq> (A*B) * (A*B)"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   182
by (unfold rmult_def, rule Collect_subset)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   183
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   184
lemmas field_rmult = rmult_type [THEN field_rel_subset]
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   185
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   186
subsubsection{*Linearity*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   187
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   188
lemma linear_rmult:
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   189
    "[| linear(A,r);  linear(B,s) |] ==> linear(A*B,rmult(A,r,B,s))"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   190
by (simp add: linear_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   191
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   192
subsubsection{*Well-foundedness*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   193
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   194
lemma wf_on_rmult: "[| wf[A](r);  wf[B](s) |] ==> wf[A*B](rmult(A,r,B,s))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   195
apply (rule wf_onI2)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   196
apply (erule SigmaE)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   197
apply (erule ssubst)
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   198
apply (subgoal_tac "\<forall>b\<in>B. <x,b>: Ba", blast)
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13634
diff changeset
   199
apply (erule_tac a = x in wf_on_induct, assumption)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   200
apply (rule ballI)
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13634
diff changeset
   201
apply (erule_tac a = b in wf_on_induct, assumption)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   202
apply (best elim!: rmultE bspec [THEN mp])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   203
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   204
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   205
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   206
lemma wf_rmult: "[| wf(r);  wf(s) |] ==> wf(rmult(field(r),r,field(s),s))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   207
apply (simp add: wf_iff_wf_on_field)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   208
apply (rule wf_on_subset_A [OF _ field_rmult])
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   209
apply (blast intro: wf_on_rmult)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   210
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   211
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   212
lemma well_ord_rmult:
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   213
     "[| well_ord(A,r);  well_ord(B,s) |] ==> well_ord(A*B, rmult(A,r,B,s))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   214
apply (rule well_ordI)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   215
apply (simp add: well_ord_def wf_on_rmult)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   216
apply (simp add: well_ord_def tot_ord_def linear_rmult)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   217
done
9883
c1c8647af477 a number of new theorems
paulson
parents: 1478
diff changeset
   218
c1c8647af477 a number of new theorems
paulson
parents: 1478
diff changeset
   219
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   220
subsubsection{*An @{term ord_iso} congruence law*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   221
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   222
lemma prod_bij:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   223
     "[| f \<in> bij(A,C);  g \<in> bij(B,D) |]
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   224
      ==> (lam <x,y>:A*B. <f`x, g`y>) \<in> bij(A*B, C*D)"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   225
apply (rule_tac d = "%<x,y>. <converse (f) `x, converse (g) `y>"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   226
       in lam_bijective)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   227
apply (typecheck add: bij_is_inj inj_is_fun)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   228
apply (auto simp add: left_inverse_bij right_inverse_bij)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   229
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   230
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   231
lemma prod_ord_iso_cong:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   232
    "[| f \<in> ord_iso(A,r,A',r');  g \<in> ord_iso(B,s,B',s') |]
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   233
     ==> (lam <x,y>:A*B. <f`x, g`y>)
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   234
         \<in> ord_iso(A*B, rmult(A,r,B,s), A'*B', rmult(A',r',B',s'))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   235
apply (unfold ord_iso_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   236
apply (safe intro!: prod_bij)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   237
apply (simp_all add: bij_is_fun [THEN apply_type])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   238
apply (blast intro: bij_is_inj [THEN inj_apply_equality])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   239
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   240
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   241
lemma singleton_prod_bij: "(\<lambda>z\<in>A. <x,z>) \<in> bij(A, {x}*A)"
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13634
diff changeset
   242
by (rule_tac d = snd in lam_bijective, auto)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   243
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   244
(*Used??*)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   245
lemma singleton_prod_ord_iso:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   246
     "well_ord({x},xr) ==>
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   247
          (\<lambda>z\<in>A. <x,z>) \<in> ord_iso(A, r, {x}*A, rmult({x}, xr, A, r))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   248
apply (rule singleton_prod_bij [THEN ord_isoI])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   249
apply (simp (no_asm_simp))
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   250
apply (blast dest: well_ord_is_wf [THEN wf_on_not_refl])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   251
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   252
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   253
(*Here we build a complicated function term, then simplify it using
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   254
  case_cong, id_conv, comp_lam, case_case.*)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   255
lemma prod_sum_singleton_bij:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   256
     "a\<notin>C ==>
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   257
       (\<lambda>x\<in>C*B + D. case(%x. x, %y.<a,y>, x))
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   258
       \<in> bij(C*B + D, C*B \<union> {a}*D)"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   259
apply (rule subst_elem)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   260
apply (rule id_bij [THEN sum_bij, THEN comp_bij])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   261
apply (rule singleton_prod_bij)
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13140
diff changeset
   262
apply (rule sum_disjoint_bij, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   263
apply (simp (no_asm_simp) cong add: case_cong)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   264
apply (rule comp_lam [THEN trans, symmetric])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   265
apply (fast elim!: case_type)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   266
apply (simp (no_asm_simp) add: case_case)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   267
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   268
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   269
lemma prod_sum_singleton_ord_iso:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   270
 "[| a \<in> A;  well_ord(A,r) |] ==>
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   271
    (\<lambda>x\<in>pred(A,a,r)*B + pred(B,b,s). case(%x. x, %y.<a,y>, x))
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   272
    \<in> ord_iso(pred(A,a,r)*B + pred(B,b,s),
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   273
                  radd(A*B, rmult(A,r,B,s), B, s),
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   274
              pred(A,a,r)*B \<union> {a}*pred(B,b,s), rmult(A,r,B,s))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   275
apply (rule prod_sum_singleton_bij [THEN ord_isoI])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   276
apply (simp (no_asm_simp) add: pred_iff well_ord_is_wf [THEN wf_on_not_refl])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   277
apply (auto elim!: well_ord_is_wf [THEN wf_on_asym] predE)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   278
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   279
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   280
subsubsection{*Distributive law*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   281
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   282
lemma sum_prod_distrib_bij:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   283
     "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x))
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   284
      \<in> bij((A+B)*C, (A*C)+(B*C))"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   285
by (rule_tac d = "case (%<x,y>.<Inl (x),y>, %<x,y>.<Inr (x),y>) "
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   286
    in lam_bijective, auto)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   287
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   288
lemma sum_prod_distrib_ord_iso:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   289
 "(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x))
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   290
  \<in> ord_iso((A+B)*C, rmult(A+B, radd(A,r,B,s), C, t),
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   291
            (A*C)+(B*C), radd(A*C, rmult(A,r,C,t), B*C, rmult(B,s,C,t)))"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   292
by (rule sum_prod_distrib_bij [THEN ord_isoI], auto)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   293
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   294
subsubsection{*Associativity*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   295
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   296
lemma prod_assoc_bij:
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   297
     "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>) \<in> bij((A*B)*C, A*(B*C))"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   298
by (rule_tac d = "%<x, <y,z>>. <<x,y>, z>" in lam_bijective, auto)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   299
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   300
lemma prod_assoc_ord_iso:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   301
 "(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   302
  \<in> ord_iso((A*B)*C, rmult(A*B, rmult(A,r,B,s), C, t),
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   303
            A*(B*C), rmult(A, r, B*C, rmult(B,s,C,t)))"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   304
by (rule prod_assoc_bij [THEN ord_isoI], auto)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   305
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   306
subsection{*Inverse Image of a Relation*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   307
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   308
subsubsection{*Rewrite rule*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   309
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   310
lemma rvimage_iff: "<a,b> \<in> rvimage(A,f,r)  \<longleftrightarrow>  <f`a,f`b>: r & a \<in> A & b \<in> A"
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13140
diff changeset
   311
by (unfold rvimage_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   312
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   313
subsubsection{*Type checking*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   314
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   315
lemma rvimage_type: "rvimage(A,f,r) \<subseteq> A*A"
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13634
diff changeset
   316
by (unfold rvimage_def, rule Collect_subset)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   317
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   318
lemmas field_rvimage = rvimage_type [THEN field_rel_subset]
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   319
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   320
lemma rvimage_converse: "rvimage(A,f, converse(r)) = converse(rvimage(A,f,r))"
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13140
diff changeset
   321
by (unfold rvimage_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   322
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   323
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   324
subsubsection{*Partial Ordering Properties*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   325
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   326
lemma irrefl_rvimage:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   327
    "[| f \<in> inj(A,B);  irrefl(B,r) |] ==> irrefl(A, rvimage(A,f,r))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   328
apply (unfold irrefl_def rvimage_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   329
apply (blast intro: inj_is_fun [THEN apply_type])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   330
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   331
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   332
lemma trans_on_rvimage:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   333
    "[| f \<in> inj(A,B);  trans[B](r) |] ==> trans[A](rvimage(A,f,r))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   334
apply (unfold trans_on_def rvimage_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   335
apply (blast intro: inj_is_fun [THEN apply_type])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   336
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   337
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   338
lemma part_ord_rvimage:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   339
    "[| f \<in> inj(A,B);  part_ord(B,r) |] ==> part_ord(A, rvimage(A,f,r))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   340
apply (unfold part_ord_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   341
apply (blast intro!: irrefl_rvimage trans_on_rvimage)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   342
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   343
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   344
subsubsection{*Linearity*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   345
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   346
lemma linear_rvimage:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   347
    "[| f \<in> inj(A,B);  linear(B,r) |] ==> linear(A,rvimage(A,f,r))"
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   348
apply (simp add: inj_def linear_def rvimage_iff)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   349
apply (blast intro: apply_funtype)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   350
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   351
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   352
lemma tot_ord_rvimage:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   353
    "[| f \<in> inj(A,B);  tot_ord(B,r) |] ==> tot_ord(A, rvimage(A,f,r))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   354
apply (unfold tot_ord_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   355
apply (blast intro!: part_ord_rvimage linear_rvimage)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   356
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   357
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   358
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   359
subsubsection{*Well-foundedness*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   360
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   361
lemma wf_rvimage [intro!]: "wf(r) ==> wf(rvimage(A,f,r))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   362
apply (simp (no_asm_use) add: rvimage_def wf_eq_minimal)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   363
apply clarify
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   364
apply (subgoal_tac "\<exists>w. w \<in> {w: {f`x. x \<in> Q}. \<exists>x. x \<in> Q & (f`x = w) }")
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   365
 apply (erule allE)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   366
 apply (erule impE)
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13140
diff changeset
   367
 apply assumption
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   368
 apply blast
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   369
apply blast
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   370
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   371
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   372
text{*But note that the combination of @{text wf_imp_wf_on} and
22710
f44439cdce77 read prop as prop, not term;
wenzelm
parents: 16417
diff changeset
   373
 @{text wf_rvimage} gives @{prop "wf(r) ==> wf[C](rvimage(A,f,r))"}*}
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   374
lemma wf_on_rvimage: "[| f \<in> A->B;  wf[B](r) |] ==> wf[A](rvimage(A,f,r))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   375
apply (rule wf_onI2)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   376
apply (subgoal_tac "\<forall>z\<in>A. f`z=f`y \<longrightarrow> z \<in> Ba")
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   377
 apply blast
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   378
apply (erule_tac a = "f`y" in wf_on_induct)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   379
 apply (blast intro!: apply_funtype)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   380
apply (blast intro!: apply_funtype dest!: rvimage_iff [THEN iffD1])
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   381
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   382
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   383
(*Note that we need only wf[A](...) and linear(A,...) to get the result!*)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   384
lemma well_ord_rvimage:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   385
     "[| f \<in> inj(A,B);  well_ord(B,r) |] ==> well_ord(A, rvimage(A,f,r))"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   386
apply (rule well_ordI)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   387
apply (unfold well_ord_def tot_ord_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   388
apply (blast intro!: wf_on_rvimage inj_is_fun)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   389
apply (blast intro!: linear_rvimage)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   390
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   391
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   392
lemma ord_iso_rvimage:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   393
    "f \<in> bij(A,B) ==> f \<in> ord_iso(A, rvimage(A,f,s), B, s)"
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   394
apply (unfold ord_iso_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   395
apply (simp add: rvimage_iff)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   396
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   397
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   398
lemma ord_iso_rvimage_eq:
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   399
    "f \<in> ord_iso(A,r, B,s) ==> rvimage(A,f,s) = r \<inter> A*A"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   400
by (unfold ord_iso_def rvimage_def, blast)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   401
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   402
13634
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   403
subsection{*Every well-founded relation is a subset of some inverse image of
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   404
      an ordinal*}
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   405
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   406
lemma wf_rvimage_Ord: "Ord(i) \<Longrightarrow> wf(rvimage(A, f, Memrel(i)))"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   407
by (blast intro: wf_rvimage wf_Memrel)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   408
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   409
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
   410
definition
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
   411
  wfrank :: "[i,i]=>i"  where
13634
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   412
    "wfrank(r,a) == wfrec(r, a, %x f. \<Union>y \<in> r-``{x}. succ(f`y))"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   413
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
   414
definition
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 22710
diff changeset
   415
  wftype :: "i=>i"  where
13634
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   416
    "wftype(r) == \<Union>y \<in> range(r). succ(wfrank(r,y))"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   417
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   418
lemma wfrank: "wf(r) ==> wfrank(r,a) = (\<Union>y \<in> r-``{a}. succ(wfrank(r,y)))"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   419
by (subst wfrank_def [THEN def_wfrec], simp_all)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   420
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   421
lemma Ord_wfrank: "wf(r) ==> Ord(wfrank(r,a))"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   422
apply (rule_tac a=a in wf_induct, assumption)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   423
apply (subst wfrank, assumption)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   424
apply (rule Ord_succ [THEN Ord_UN], blast)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   425
done
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   426
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   427
lemma wfrank_lt: "[|wf(r); <a,b> \<in> r|] ==> wfrank(r,a) < wfrank(r,b)"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   428
apply (rule_tac a1 = b in wfrank [THEN ssubst], assumption)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   429
apply (rule UN_I [THEN ltI])
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   430
apply (simp add: Ord_wfrank vimage_iff)+
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   431
done
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   432
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   433
lemma Ord_wftype: "wf(r) ==> Ord(wftype(r))"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   434
by (simp add: wftype_def Ord_wfrank)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   435
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   436
lemma wftypeI: "\<lbrakk>wf(r);  x \<in> field(r)\<rbrakk> \<Longrightarrow> wfrank(r,x) \<in> wftype(r)"
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   437
apply (simp add: wftype_def)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   438
apply (blast intro: wfrank_lt [THEN ltD])
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   439
done
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   440
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   441
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   442
lemma wf_imp_subset_rvimage:
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   443
     "[|wf(r); r \<subseteq> A*A|] ==> \<exists>i f. Ord(i) & r \<subseteq> rvimage(A, f, Memrel(i))"
13634
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   444
apply (rule_tac x="wftype(r)" in exI)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   445
apply (rule_tac x="\<lambda>x\<in>A. wfrank(r,x)" in exI)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   446
apply (simp add: Ord_wftype, clarify)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   447
apply (frule subsetD, assumption, clarify)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   448
apply (simp add: rvimage_iff wfrank_lt [THEN ltD])
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   449
apply (blast intro: wftypeI)
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   450
done
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   451
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   452
theorem wf_iff_subset_rvimage:
46821
ff6b0c1087f2 Using mathematical notation for <-> and cardinal arithmetic
paulson
parents: 46820
diff changeset
   453
  "relation(r) ==> wf(r) \<longleftrightarrow> (\<exists>i f A. Ord(i) & r \<subseteq> rvimage(A, f, Memrel(i)))"
13634
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   454
by (blast dest!: relation_field_times_field wf_imp_subset_rvimage
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   455
          intro: wf_rvimage_Ord [THEN wf_subset])
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   456
99a593b49b04 Re-organization of Constructible theories
paulson
parents: 13544
diff changeset
   457
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   458
subsection{*Other Results*}
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   459
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   460
lemma wf_times: "A \<inter> B = 0 ==> wf(A*B)"
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   461
by (simp add: wf_def, blast)
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   462
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   463
text{*Could also be used to prove @{text wf_radd}*}
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   464
lemma wf_Un:
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   465
     "[| range(r) \<inter> domain(s) = 0; wf(r);  wf(s) |] ==> wf(r \<union> s)"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   466
apply (simp add: wf_def, clarify)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   467
apply (rule equalityI)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   468
 prefer 2 apply blast
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   469
apply clarify
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   470
apply (drule_tac x=Z in spec)
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   471
apply (drule_tac x="Z \<inter> domain(s)" in spec)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   472
apply simp
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   473
apply (blast intro: elim: equalityE)
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   474
done
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   475
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   476
subsubsection{*The Empty Relation*}
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   477
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   478
lemma wf0: "wf(0)"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   479
by (simp add: wf_def, blast)
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   480
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   481
lemma linear0: "linear(0,0)"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   482
by (simp add: linear_def)
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   483
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   484
lemma well_ord0: "well_ord(0,0)"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   485
by (blast intro: wf_imp_wf_on well_ordI wf0 linear0)
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   486
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   487
subsubsection{*The "measure" relation is useful with wfrec*}
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   488
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   489
lemma measure_eq_rvimage_Memrel:
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   490
     "measure(A,f) = rvimage(A,Lambda(A,f),Memrel(Collect(RepFun(A,f),Ord)))"
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   491
apply (simp (no_asm) add: measure_def rvimage_def Memrel_iff)
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13140
diff changeset
   492
apply (rule equalityI, auto)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   493
apply (auto intro: Ord_in_Ord simp add: lt_def)
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   494
done
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   495
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   496
lemma wf_measure [iff]: "wf(measure(A,f))"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   497
by (simp (no_asm) add: measure_eq_rvimage_Memrel wf_Memrel wf_rvimage)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   498
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   499
lemma measure_iff [iff]: "<x,y> \<in> measure(A,f) \<longleftrightarrow> x \<in> A & y \<in> A & f(x)<f(y)"
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13269
diff changeset
   500
by (simp (no_asm) add: measure_def)
13140
6d97dbb189a9 converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents: 9883
diff changeset
   501
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   502
lemma linear_measure:
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   503
 assumes Ordf: "!!x. x \<in> A ==> Ord(f(x))"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   504
     and inj:  "!!x y. [|x \<in> A; y \<in> A; f(x) = f(y) |] ==> x=y"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   505
 shows "linear(A, measure(A,f))"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   506
apply (auto simp add: linear_def)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   507
apply (rule_tac i="f(x)" and j="f(y)" in Ord_linear_lt)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   508
    apply (simp_all add: Ordf)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   509
apply (blast intro: inj)
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   510
done
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   511
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   512
lemma wf_on_measure: "wf[B](measure(A,f))"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   513
by (rule wf_imp_wf_on [OF wf_measure])
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   514
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   515
lemma well_ord_measure:
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   516
 assumes Ordf: "!!x. x \<in> A ==> Ord(f(x))"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   517
     and inj:  "!!x y. [|x \<in> A; y \<in> A; f(x) = f(y) |] ==> x=y"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   518
 shows "well_ord(A, measure(A,f))"
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   519
apply (rule well_ordI)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   520
apply (rule wf_on_measure)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   521
apply (blast intro: linear_measure Ordf inj)
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   522
done
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   523
46820
c656222c4dc1 mathematical symbols instead of ASCII
paulson
parents: 35762
diff changeset
   524
lemma measure_type: "measure(A,f) \<subseteq> A*A"
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   525
by (auto simp add: measure_def)
895994073bdf various new lemmas for Constructible
paulson
parents: 13512
diff changeset
   526
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   527
subsubsection{*Well-foundedness of Unions*}
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   528
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   529
lemma wf_on_Union:
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   530
 assumes wfA: "wf[A](r)"
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   531
     and wfB: "!!a. a\<in>A ==> wf[B(a)](s)"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   532
     and ok: "!!a u v. [|<u,v> \<in> s; v \<in> B(a); a \<in> A|]
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   533
                       ==> (\<exists>a'\<in>A. <a',a> \<in> r & u \<in> B(a')) | u \<in> B(a)"
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   534
 shows "wf[\<Union>a\<in>A. B(a)](s)"
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   535
apply (rule wf_onI2)
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   536
apply (erule UN_E)
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   537
apply (subgoal_tac "\<forall>z \<in> B(a). z \<in> Ba", blast)
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   538
apply (rule_tac a = a in wf_on_induct [OF wfA], assumption)
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   539
apply (rule ballI)
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   540
apply (rule_tac a = z in wf_on_induct [OF wfB], assumption, assumption)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   541
apply (rename_tac u)
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   542
apply (drule_tac x=u in bspec, blast)
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   543
apply (erule mp, clarify)
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   544
apply (frule ok, assumption+, blast)
13512
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   545
done
80edb859fd24 tweaks and new lemmas
paulson
parents: 13356
diff changeset
   546
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   547
subsubsection{*Bijections involving Powersets*}
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   548
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   549
lemma Pow_sum_bij:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   550
    "(\<lambda>Z \<in> Pow(A+B). <{x \<in> A. Inl(x) \<in> Z}, {y \<in> B. Inr(y) \<in> Z}>)
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   551
     \<in> bij(Pow(A+B), Pow(A)*Pow(B))"
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   552
apply (rule_tac d = "%<X,Y>. {Inl (x). x \<in> X} \<union> {Inr (y). y \<in> Y}"
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   553
       in lam_bijective)
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   554
apply force+
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   555
done
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   556
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   557
text{*As a special case, we have @{term "bij(Pow(A*B), A -> Pow(B))"} *}
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   558
lemma Pow_Sigma_bij:
46953
2b6e55924af3 replacing ":" by "\<in>"
paulson
parents: 46821
diff changeset
   559
    "(\<lambda>r \<in> Pow(Sigma(A,B)). \<lambda>x \<in> A. r``{x})
14171
0cab06e3bbd0 Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents: 14120
diff changeset
   560
     \<in> bij(Pow(Sigma(A,B)), \<Pi> x \<in> A. Pow(B(x)))"
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   561
apply (rule_tac d = "%f. \<Union>x \<in> A. \<Union>y \<in> f`x. {<x,y>}" in lam_bijective)
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   562
apply (blast intro: lam_type)
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   563
apply (blast dest: apply_type, simp_all)
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   564
apply fast (*strange, but blast can't do it*)
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   565
apply (rule fun_extension, auto)
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   566
by blast
3a73850c6c7d Tidied some examples
paulson
parents: 13823
diff changeset
   567
437
435875e4b21d modifications for cardinal arithmetic
lcp
parents:
diff changeset
   568
end