src/HOL/Import/HOL_Light/Compatibility.thy
author haftmann
Sat, 03 Mar 2012 23:49:54 +0100
changeset 46798 9ae5c21fc88c
parent 46796 81e5ec0a3cd0
child 46905 6b1c0a80a57a
permissions -rw-r--r--
generalized attribute name
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
     1
(*  Title:      HOL/Import/HOL_Light/Compatibility.thy
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
     2
    Author:     Steven Obua and Sebastian Skalberg, TU Muenchen
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
     3
    Author:     Cezary Kaliszyk
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
     4
*)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
     5
46785
150f37dad503 formal infrastructure for import sessions
haftmann
parents:
diff changeset
     6
theory Compatibility
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
     7
imports Main Fact Parity "~~/src/HOL/Library/Infinite_Set"
46796
81e5ec0a3cd0 one unified Importer theory
haftmann
parents: 46794
diff changeset
     8
  HOLLightList HOLLightReal HOLLightInt "~~/src/HOL/Import/Importer"
46785
150f37dad503 formal infrastructure for import sessions
haftmann
parents:
diff changeset
     9
begin
150f37dad503 formal infrastructure for import sessions
haftmann
parents:
diff changeset
    10
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    11
(* list *)
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
    12
lemmas [import_rew] = list_el_def member_def list_mem_def
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    13
(* int *)
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
    14
lemmas [import_rew] = int_coprime.simps int_gcd.simps hl_mod_def hl_div_def int_mod_def eqeq_def
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    15
(* real *)
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
    16
lemma [import_rew]:
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    17
  "real (0::nat) = 0" "real (1::nat) = 1" "real (2::nat) = 2"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    18
  by simp_all
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    19
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    20
lemma one:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    21
  "\<forall>v. v = ()"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    22
  by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    23
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    24
lemma num_Axiom:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    25
  "\<exists>!fn. fn 0 = e \<and> (\<forall>n. fn (Suc n) = f (fn n) n)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    26
  apply (rule ex1I[of _ "nat_rec e (%n e. f e n)"])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    27
  apply (auto simp add: fun_eq_iff)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    28
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    29
  apply simp_all
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    30
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    31
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    32
lemma SUC_INJ:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    33
  "\<forall>m n. Suc m = Suc n \<longleftrightarrow> m = n"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    34
  by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    35
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    36
lemma PAIR:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    37
  "(fst x, snd x) = x"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    38
  by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    39
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    40
lemma EXISTS_UNIQUE_THM:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    41
  "(Ex1 P) = (Ex P & (\<forall>x y. P x & P y --> (x = y)))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    42
  by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    43
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    44
lemma DEF__star_:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    45
  "op * = (SOME mult. (\<forall>n. mult 0 n = 0) \<and> (\<forall>m n. mult (Suc m) n = mult m n + n))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    46
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    47
  apply (auto simp add: fun_eq_iff)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    48
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    49
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    50
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    51
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    52
lemma DEF__slash__backslash_:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    53
  "(t1 \<and> t2) = ((\<lambda>f. f t1 t2 :: bool) = (\<lambda>f. f True True))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    54
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    55
  by (intro iffI, simp_all) (erule allE[of _ "(%a b. a \<and> b)"], simp)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    56
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    57
lemma DEF__lessthan__equal_:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    58
  "op \<le> = (SOME u. (\<forall>m. u m 0 = (m = 0)) \<and> (\<forall>m n. u m (Suc n) = (m = Suc n \<or> u m n)))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    59
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    60
  apply auto[1]
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    61
  apply (simp add: fun_eq_iff)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    62
  apply (intro allI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    63
  apply (induct_tac xa)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    64
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    65
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    66
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    67
lemma DEF__lessthan_:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    68
  "op < = (SOME u. (\<forall>m. u m 0 = False) \<and> (\<forall>m n. u m (Suc n) = (m = n \<or> u m n)))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    69
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    70
  apply auto[1]
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    71
  apply (simp add: fun_eq_iff)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    72
  apply (intro allI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    73
  apply (induct_tac xa)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    74
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    75
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    76
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    77
lemma DEF__greaterthan__equal_:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    78
  "(op \<ge>) = (%u ua. ua \<le> u)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    79
  by (simp)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    80
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    81
lemma DEF__greaterthan_:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    82
  "(op >) = (%u ua. ua < u)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    83
  by (simp)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    84
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    85
lemma DEF__equal__equal__greaterthan_:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    86
  "(t1 \<longrightarrow> t2) = ((t1 \<and> t2) = t1)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    87
  by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    88
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    89
lemma DEF_WF:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    90
  "wfP = (\<lambda>u. \<forall>P. (\<exists>x. P x) \<longrightarrow> (\<exists>x. P x \<and> (\<forall>y. u y x \<longrightarrow> \<not> P y)))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    91
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    92
proof (intro allI iffI impI wfI_min[to_pred], elim exE wfE_min[to_pred])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    93
  fix P :: "'a \<Rightarrow> bool" and xa :: "'a"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    94
  assume "P xa"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    95
  then show "xa \<in> Collect P" by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    96
next
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    97
  fix x P xa z
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    98
  assume "P xa" "z \<in> {a. P a}" "\<And>y. x y z \<Longrightarrow> y \<notin> {a. P a}"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
    99
  then show "\<exists>xa. P xa \<and> (\<forall>y. x y xa \<longrightarrow> \<not> P y)" by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   100
next
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   101
  fix x :: "'a \<Rightarrow> 'a \<Rightarrow> bool" and xa :: "'a" and Q
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   102
  assume a: "xa \<in> Q"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   103
  assume b: "\<forall>P. Ex P \<longrightarrow> (\<exists>xa. P xa \<and> (\<forall>y. x y xa \<longrightarrow> \<not> P y))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   104
  then have "Ex (\<lambda>x. x \<in> Q) \<longrightarrow> (\<exists>xa. (\<lambda>x. x \<in> Q) xa \<and> (\<forall>y. x y xa \<longrightarrow> \<not> (\<lambda>x. x \<in> Q) y))" by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   105
  then show "\<exists>z\<in>Q. \<forall>y. x y z \<longrightarrow> y \<notin> Q" using a by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   106
qed
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   107
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   108
lemma DEF_UNIV: "top = (%x. True)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   109
  by (rule ext) (simp add: top1I)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   110
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   111
lemma DEF_UNIONS:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   112
  "Sup = (\<lambda>u. {ua. \<exists>x. (\<exists>ua. ua \<in> u \<and> x \<in> ua) \<and> ua = x})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   113
  by (auto simp add: Union_eq)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   114
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   115
lemma DEF_UNION:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   116
  "op \<union> = (\<lambda>u ua. {ub. \<exists>x. (x \<in> u \<or> x \<in> ua) \<and> ub = x})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   117
  by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   118
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   119
lemma DEF_SUBSET: "op \<subseteq> = (\<lambda>u ua. \<forall>x. x \<in> u \<longrightarrow> x \<in> ua)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   120
  by (metis set_rev_mp subsetI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   121
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   122
lemma DEF_SND:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   123
  "snd = (\<lambda>p. SOME x. EX y. p = (y, x))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   124
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   125
  by (rule someI2) (auto intro: snd_conv[symmetric] someI2)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   126
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   127
definition [simp, import_rew]: "SETSPEC x P y \<longleftrightarrow> P & x = y"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   128
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   129
lemma DEF_PSUBSET: "op \<subset> = (\<lambda>u ua. u \<subseteq> ua & u \<noteq> ua)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   130
  by (metis psubset_eq)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   131
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   132
definition [import_rew]: "Pred n = n - (Suc 0)"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   133
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   134
lemma DEF_PRE: "Pred = (SOME PRE. PRE 0 = 0 & (\<forall>n. PRE (Suc n) = n))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   135
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   136
  apply (simp add: Pred_def)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   137
  apply (rule ext)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   138
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   139
  apply (auto simp add: Pred_def)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   140
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   141
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   142
lemma DEF_ONE_ONE:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   143
  "inj = (\<lambda>u. \<forall>x1 x2. u x1 = u x2 \<longrightarrow> x1 = x2)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   144
  by (simp add: inj_on_def)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   145
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   146
definition ODD'[import_rew]: "(ODD :: nat \<Rightarrow> bool) = odd"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   147
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   148
lemma DEF_ODD:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   149
  "odd = (SOME ODD. ODD 0 = False \<and> (\<forall>n. ODD (Suc n) = (\<not> ODD n)))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   150
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   151
  apply simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   152
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   153
  apply (intro allI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   154
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   155
  apply simp_all
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   156
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   157
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   158
definition [import_rew, simp]: "NUMERAL (x :: nat) = x"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   159
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   160
lemma DEF_MOD:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   161
  "op mod = (SOME r. \<forall>m n. if n = (0 :: nat) then m div n = 0 \<and>
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   162
     r m n = m else m = m div n * n + r m n \<and> r m n < n)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   163
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   164
  apply (auto simp add: fun_eq_iff)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   165
  apply (case_tac "xa = 0")
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   166
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   167
  apply (drule_tac x="x" in spec)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   168
  apply (drule_tac x="xa" in spec)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   169
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   170
  by (metis mod_less mod_mult_self2 nat_add_commute nat_mult_commute)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   171
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   172
definition "MEASURE = (%u x y. (u x :: nat) < u y)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   173
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   174
lemma [import_rew]:
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   175
  "MEASURE u = (%a b. (a, b) \<in> measure u)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   176
  unfolding MEASURE_def measure_def
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   177
  by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   178
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   179
definition
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   180
  "LET f s = f s"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   181
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   182
lemma [import_rew]:
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   183
  "LET f s = Let s f"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   184
  by (simp add: LET_def Let_def)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   185
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   186
lemma DEF_INTERS:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   187
  "Inter = (\<lambda>u. {ua. \<exists>x. (\<forall>ua. ua \<in> u \<longrightarrow> x \<in> ua) \<and> ua = x})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   188
  by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   189
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   190
lemma DEF_INTER:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   191
  "op \<inter> = (\<lambda>u ua. {ub. \<exists>x. (x \<in> u \<and> x \<in> ua) \<and> ub = x})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   192
  by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   193
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   194
lemma DEF_INSERT:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   195
  "insert = (\<lambda>u ua. {y. y \<in> ua | y = u})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   196
  by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   197
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   198
lemma DEF_IMAGE:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   199
  "op ` = (\<lambda>u ua. {ub. \<exists>y. (\<exists>x. x \<in> ua \<and> y = u x) \<and> ub = y})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   200
  by (simp add: fun_eq_iff image_def Bex_def)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   201
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   202
lemma DEF_GEQ:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   203
  "(op =) = (op =)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   204
  by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   205
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   206
lemma DEF_GABS:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   207
  "Eps = Eps"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   208
  by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   209
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   210
lemma DEF_FST:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   211
  "fst = (%p. SOME x. EX y. p = (x, y))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   212
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   213
  by (rule someI2) (auto intro: fst_conv[symmetric] someI2)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   214
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   215
lemma DEF_FINITE:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   216
  "finite = (\<lambda>a. \<forall>FP. (\<forall>a. a = {} \<or> (\<exists>x s. a = insert x s \<and> FP s) \<longrightarrow> FP a) \<longrightarrow> FP a)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   217
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   218
  apply (intro allI iffI impI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   219
  apply (erule finite_induct)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   220
  apply auto[2]
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   221
  apply (drule_tac x="finite" in spec)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   222
  by (metis finite_insert infinite_imp_nonempty infinite_super predicate1I)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   223
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   224
lemma DEF_FACT:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   225
  "fact = (SOME FACT. FACT 0 = 1 & (\<forall>n. FACT (Suc n) = Suc n * FACT n))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   226
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   227
  apply (simp_all)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   228
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   229
  apply (intro allI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   230
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   231
  apply simp_all
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   232
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   233
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   234
lemma DEF_EXP:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   235
  "power = (SOME EXP. (\<forall>m. EXP m 0 = 1) \<and> (\<forall>m n. EXP m (Suc n) = m * EXP m n))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   236
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   237
  apply (simp_all)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   238
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   239
  apply (intro allI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   240
  apply (induct_tac xa)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   241
  apply simp_all
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   242
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   243
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   244
lemma DEF_EVEN:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   245
  "even = (SOME EVEN. EVEN 0 = True \<and> (\<forall>n. EVEN (Suc n) = (\<not> EVEN n)))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   246
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   247
  apply simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   248
  unfolding fun_eq_iff
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   249
  apply (intro allI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   250
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   251
  apply simp_all
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   252
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   253
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   254
lemma DEF_EMPTY: "bot = (%x. False)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   255
  by (rule ext) auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   256
  
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   257
lemma DEF_DIV:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   258
  "op div = (SOME q. \<exists>r. \<forall>m n. if n = (0 :: nat) then q m n = 0 \<and> r m n = m
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   259
     else m = q m n * n + r m n \<and> r m n < n)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   260
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   261
  apply (rule_tac x="op mod" in exI)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   262
  apply (auto simp add: fun_eq_iff)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   263
  apply (case_tac "xa = 0")
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   264
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   265
  apply (drule_tac x="x" in spec)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   266
  apply (drule_tac x="xa" in spec)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   267
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   268
  by (metis div_mult_self2 gr_implies_not0 mod_div_trivial mod_less
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   269
      nat_add_commute nat_mult_commute plus_nat.add_0)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   270
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   271
definition [import_rew]: "DISJOINT a b \<longleftrightarrow> a \<inter> b = {}"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   272
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   273
lemma DEF_DISJOINT:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   274
  "DISJOINT = (%u ua. u \<inter> ua = {})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   275
  by (auto simp add: DISJOINT_def_raw)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   276
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   277
lemma DEF_DIFF:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   278
  "op - = (\<lambda>u ua. {ub. \<exists>x. (x \<in> u \<and> x \<notin> ua) \<and> ub = x})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   279
  by (metis set_diff_eq)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   280
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   281
definition [import_rew]: "DELETE s e = s - {e}"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   282
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   283
lemma DEF_DELETE:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   284
  "DELETE = (\<lambda>u ua. {ub. \<exists>y. (y \<in> u \<and> y \<noteq> ua) \<and> ub = y})"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   285
  by (auto simp add: DELETE_def_raw)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   286
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   287
lemma COND_DEF:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   288
  "(if b then t else f) = (SOME x. (b = True \<longrightarrow> x = t) \<and> (b = False \<longrightarrow> x = f))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   289
  by auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   290
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   291
definition [simp]: "NUMERAL_BIT1 n = n + (n + Suc 0)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   292
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   293
lemma BIT1_DEF:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   294
  "NUMERAL_BIT1 = (%u. Suc (2 * u))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   295
  by (auto)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   296
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   297
definition [simp]: "NUMERAL_BIT0 (n :: nat) = n + n"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   298
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   299
lemma BIT0_DEF:
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   300
  "NUMERAL_BIT0 = (SOME BIT0. BIT0 0 = 0 \<and> (\<forall>n. BIT0 (Suc n) = Suc (Suc (BIT0 n))))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   301
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   302
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   303
  apply (rule ext)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   304
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   305
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   306
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   307
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   308
lemma [import_rew]:
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   309
  "NUMERAL_BIT0 n = 2 * n"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   310
  "NUMERAL_BIT1 n = 2 * n + 1"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   311
  "2 * 0 = (0 :: nat)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   312
  "2 * 1 = (2 :: nat)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   313
  "0 + 1 = (1 :: nat)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   314
  by simp_all
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   315
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   316
lemma DEF_MINUS: "op - = (SOME sub. (\<forall>m. sub m 0 = m) & (\<forall>m n. sub m (Suc n) = sub m n - Suc 0))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   317
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   318
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   319
  apply (rule ext)+
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   320
  apply (induct_tac xa)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   321
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   322
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   323
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   324
lemma DEF_PLUS: "op + = (SOME add. (\<forall>n. add 0 n = n) & (\<forall>m n. add (Suc m) n = Suc (add m n)))"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   325
  apply (rule some_equality[symmetric])
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   326
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   327
  apply (rule ext)+
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   328
  apply (induct_tac x)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   329
  apply auto
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   330
  done
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   331
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   332
lemmas [import_rew] = id_apply
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   333
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   334
lemma DEF_CHOICE: "Eps = (%u. SOME x. u x)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   335
  by simp
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   336
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   337
definition dotdot :: "nat => nat => nat set"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   338
  where "dotdot u ua = {ub. EX x. (u <= x & x <= ua) & ub = x}"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   339
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   340
lemma [import_rew]: "dotdot a b = {a..b}"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   341
  unfolding fun_eq_iff atLeastAtMost_def atLeast_def atMost_def dotdot_def
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   342
  by (simp add: Collect_conj_eq)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   343
46798
9ae5c21fc88c generalized attribute name
haftmann
parents: 46796
diff changeset
   344
definition [import_rew,simp]: "INFINITE S \<longleftrightarrow> \<not> finite S"
46786
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   345
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   346
lemma DEF_INFINITE: "INFINITE = (\<lambda>u. \<not>finite u)"
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   347
  by (simp add: INFINITE_def_raw)
f0285e69d704 distribution of compatibility theories
haftmann
parents: 46785
diff changeset
   348
46785
150f37dad503 formal infrastructure for import sessions
haftmann
parents:
diff changeset
   349
end
46788
aefdc0095d7e tuned whitespace
haftmann
parents: 46786
diff changeset
   350