src/CCL/Type.thy
author paulson
Mon, 26 Aug 2024 22:14:19 +0100
changeset 80778 94bc8f62c835
parent 80761 bc936d3d8b45
child 80914 d97fdabd9e2b
permissions -rw-r--r--
merged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 14765
diff changeset
     1
(*  Title:      CCL/Type.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    Author:     Martin Coen
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
     6
section \<open>Types in CCL are defined as sets of terms\<close>
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 14765
diff changeset
     7
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 14765
diff changeset
     8
theory Type
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 14765
diff changeset
     9
imports Term
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 14765
diff changeset
    10
begin
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    12
definition Subtype :: "['a set, 'a \<Rightarrow> o] \<Rightarrow> 'a set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    13
  where "Subtype(A, P) == {x. x:A \<and> P(x)}"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
14765
bafb24c150c1 proper use of 'syntax';
wenzelm
parents: 3837
diff changeset
    15
syntax
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    16
  "_Subtype" :: "[idt, 'a set, o] \<Rightarrow> 'a set"  ("(1{_: _ ./ _})")
80761
bc936d3d8b45 tuned, following be8c0e039a5e;
wenzelm
parents: 80754
diff changeset
    17
syntax_consts
bc936d3d8b45 tuned, following be8c0e039a5e;
wenzelm
parents: 80754
diff changeset
    18
  "_Subtype" == Subtype
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    19
translations
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    20
  "{x: A. B}" == "CONST Subtype(A, \<lambda>x. B)"
999
9bf3816298d0 Gave tighter priorities to SUM and PROD to reduce ambiguities.
lcp
parents: 22
diff changeset
    21
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    22
definition Unit :: "i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    23
  where "Unit == {x. x=one}"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    24
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    25
definition Bool :: "i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    26
  where "Bool == {x. x=true | x=false}"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    27
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    28
definition Plus :: "[i set, i set] \<Rightarrow> i set"  (infixr "+" 55)
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    29
  where "A+B == {x. (EX a:A. x=inl(a)) | (EX b:B. x=inr(b))}"
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 14765
diff changeset
    30
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    31
definition Pi :: "[i set, i \<Rightarrow> i set] \<Rightarrow> i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    32
  where "Pi(A,B) == {x. EX b. x=lam x. b(x) \<and> (ALL x:A. b(x):B(x))}"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    33
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    34
definition Sigma :: "[i set, i \<Rightarrow> i set] \<Rightarrow> i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    35
  where "Sigma(A,B) == {x. EX a:A. EX b:B(a).x=<a,b>}"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    37
syntax
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    38
  "_Pi" :: "[idt, i set, i set] \<Rightarrow> i set"  ("(3PROD _:_./ _)" [0,0,60] 60)
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    39
  "_Sigma" :: "[idt, i set, i set] \<Rightarrow> i set"  ("(3SUM _:_./ _)" [0,0,60] 60)
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    40
  "_arrow" :: "[i set, i set] \<Rightarrow> i set"  ("(_ ->/ _)"  [54, 53] 53)
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    41
  "_star"  :: "[i set, i set] \<Rightarrow> i set"  ("(_ */ _)" [56, 55] 55)
80761
bc936d3d8b45 tuned, following be8c0e039a5e;
wenzelm
parents: 80754
diff changeset
    42
syntax_consts
bc936d3d8b45 tuned, following be8c0e039a5e;
wenzelm
parents: 80754
diff changeset
    43
  "_Pi" "_arrow" \<rightleftharpoons> Pi and
bc936d3d8b45 tuned, following be8c0e039a5e;
wenzelm
parents: 80754
diff changeset
    44
  "_Sigma" "_star" \<rightleftharpoons> Sigma
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
translations
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    46
  "PROD x:A. B" \<rightharpoonup> "CONST Pi(A, \<lambda>x. B)"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    47
  "A -> B" \<rightharpoonup> "CONST Pi(A, \<lambda>_. B)"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    48
  "SUM x:A. B" \<rightharpoonup> "CONST Sigma(A, \<lambda>x. B)"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    49
  "A * B" \<rightharpoonup> "CONST Sigma(A, \<lambda>_. B)"
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
    50
print_translation \<open>
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 62143
diff changeset
    51
 [(\<^const_syntax>\<open>Pi\<close>,
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 62143
diff changeset
    52
    fn _ => Syntax_Trans.dependent_tr' (\<^syntax_const>\<open>_Pi\<close>, \<^syntax_const>\<open>_arrow\<close>)),
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 62143
diff changeset
    53
  (\<^const_syntax>\<open>Sigma\<close>,
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 62143
diff changeset
    54
    fn _ => Syntax_Trans.dependent_tr' (\<^syntax_const>\<open>_Sigma\<close>, \<^syntax_const>\<open>_star\<close>))]
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
    55
\<close>
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    57
definition Nat :: "i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    58
  where "Nat == lfp(\<lambda>X. Unit + X)"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    59
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    60
definition List :: "i set \<Rightarrow> i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    61
  where "List(A) == lfp(\<lambda>X. Unit + A*X)"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    62
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    63
definition Lists :: "i set \<Rightarrow> i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    64
  where "Lists(A) == gfp(\<lambda>X. Unit + A*X)"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    65
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    66
definition ILists :: "i set \<Rightarrow> i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    67
  where "ILists(A) == gfp(\<lambda>X.{} + A*X)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    69
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    70
definition TAll :: "(i set \<Rightarrow> i set) \<Rightarrow> i set"  (binder "TALL " 55)
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    71
  where "TALL X. B(X) == Inter({X. EX Y. X=B(Y)})"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    73
definition TEx :: "(i set \<Rightarrow> i set) \<Rightarrow> i set"  (binder "TEX " 55)
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    74
  where "TEX X. B(X) == Union({X. EX Y. X=B(Y)})"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    76
definition Lift :: "i set \<Rightarrow> i set"  ("(3[_])")
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    77
  where "[A] == A Un {bot}"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    78
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    79
definition SPLIT :: "[i, [i, i] \<Rightarrow> i set] \<Rightarrow> i set"
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    80
  where "SPLIT(p,B) == Union({A. EX x y. p=<x,y> \<and> A=B(x,y)})"
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 14765
diff changeset
    81
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    82
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    83
lemmas simp_type_defs =
62143
3c9a0985e6be eliminated old defs;
wenzelm
parents: 62020
diff changeset
    84
    Subtype_def Unit_def Bool_def Plus_def Sigma_def Pi_def Lift_def TAll_def TEx_def
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    85
  and ind_type_defs = Nat_def List_def
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    86
  and simp_data_defs = one_def inl_def inr_def
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    87
  and ind_data_defs = zero_def succ_def nil_def cons_def
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    88
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
    89
lemma subsetXH: "A <= B \<longleftrightarrow> (ALL x. x:A \<longrightarrow> x:B)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    90
  by blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    91
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    92
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
    93
subsection \<open>Exhaustion Rules\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
    94
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
    95
lemma EmptyXH: "\<And>a. a : {} \<longleftrightarrow> False"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
    96
  and SubtypeXH: "\<And>a A P. a : {x:A. P(x)} \<longleftrightarrow> (a:A \<and> P(a))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
    97
  and UnitXH: "\<And>a. a : Unit          \<longleftrightarrow> a=one"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
    98
  and BoolXH: "\<And>a. a : Bool          \<longleftrightarrow> a=true | a=false"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
    99
  and PlusXH: "\<And>a A B. a : A+B           \<longleftrightarrow> (EX x:A. a=inl(x)) | (EX x:B. a=inr(x))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   100
  and PiXH: "\<And>a A B. a : PROD x:A. B(x) \<longleftrightarrow> (EX b. a=lam x. b(x) \<and> (ALL x:A. b(x):B(x)))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   101
  and SgXH: "\<And>a A B. a : SUM x:A. B(x)  \<longleftrightarrow> (EX x:A. EX y:B(x).a=<x,y>)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   102
  unfolding simp_type_defs by blast+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   103
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   104
lemmas XHs = EmptyXH SubtypeXH UnitXH BoolXH PlusXH PiXH SgXH
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   105
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   106
lemma LiftXH: "a : [A] \<longleftrightarrow> (a=bot | a:A)"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   107
  and TallXH: "a : TALL X. B(X) \<longleftrightarrow> (ALL X. a:B(X))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   108
  and TexXH: "a : TEX X. B(X) \<longleftrightarrow> (EX X. a:B(X))"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   109
  unfolding simp_type_defs by blast+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   110
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   111
ML \<open>ML_Thms.bind_thms ("case_rls", XH_to_Es @{thms XHs})\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   112
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   113
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   114
subsection \<open>Canonical Type Rules\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   115
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   116
lemma oneT: "one : Unit"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   117
  and trueT: "true : Bool"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   118
  and falseT: "false : Bool"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   119
  and lamT: "\<And>b B. (\<And>x. x:A \<Longrightarrow> b(x):B(x)) \<Longrightarrow> lam x. b(x) : Pi(A,B)"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   120
  and pairT: "\<And>b B. \<lbrakk>a:A; b:B(a)\<rbrakk> \<Longrightarrow> <a,b>:Sigma(A,B)"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   121
  and inlT: "a:A \<Longrightarrow> inl(a) : A+B"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   122
  and inrT: "b:B \<Longrightarrow> inr(b) : A+B"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   123
  by (blast intro: XHs [THEN iffD2])+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   124
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   125
lemmas canTs = oneT trueT falseT pairT lamT inlT inrT
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   126
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   127
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   128
subsection \<open>Non-Canonical Type Rules\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   129
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   130
lemma lem: "\<lbrakk>a:B(u); u = v\<rbrakk> \<Longrightarrow> a : B(v)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   131
  by blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   132
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   133
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   134
ML \<open>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   135
fun mk_ncanT_tac top_crls crls =
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   136
  SUBPROOF (fn {context = ctxt, prems = major :: prems, ...} =>
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58977
diff changeset
   137
    resolve_tac ctxt ([major] RL top_crls) 1 THEN
59499
14095f771781 misc tuning;
wenzelm
parents: 59498
diff changeset
   138
    REPEAT_SOME (eresolve_tac ctxt (crls @ @{thms exE bexE conjE disjE})) THEN
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 42814
diff changeset
   139
    ALLGOALS (asm_simp_tac ctxt) THEN
59499
14095f771781 misc tuning;
wenzelm
parents: 59498
diff changeset
   140
    ALLGOALS (assume_tac ctxt ORELSE' resolve_tac ctxt (prems RL [@{thm lem}])
14095f771781 misc tuning;
wenzelm
parents: 59498
diff changeset
   141
      ORELSE' eresolve_tac ctxt @{thms bspec}) THEN
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42480
diff changeset
   142
    safe_tac (ctxt addSIs prems))
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   143
\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   144
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   145
method_setup ncanT = \<open>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   146
  Scan.succeed (SIMPLE_METHOD' o mk_ncanT_tac @{thms case_rls} @{thms case_rls})
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   147
\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   148
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   149
lemma ifT: "\<lbrakk>b:Bool; b=true \<Longrightarrow> t:A(true); b=false \<Longrightarrow> u:A(false)\<rbrakk> \<Longrightarrow> if b then t else u : A(b)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   150
  by ncanT
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   151
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   152
lemma applyT: "\<lbrakk>f : Pi(A,B); a:A\<rbrakk> \<Longrightarrow> f ` a : B(a)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   153
  by ncanT
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   154
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   155
lemma splitT: "\<lbrakk>p:Sigma(A,B); \<And>x y. \<lbrakk>x:A; y:B(x); p=<x,y>\<rbrakk> \<Longrightarrow> c(x,y):C(<x,y>)\<rbrakk> \<Longrightarrow> split(p,c):C(p)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   156
  by ncanT
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   157
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   158
lemma whenT:
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   159
  "\<lbrakk>p:A+B;
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   160
    \<And>x. \<lbrakk>x:A; p=inl(x)\<rbrakk> \<Longrightarrow> a(x):C(inl(x));
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   161
    \<And>y. \<lbrakk>y:B;  p=inr(y)\<rbrakk> \<Longrightarrow> b(y):C(inr(y))\<rbrakk> \<Longrightarrow> when(p,a,b) : C(p)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   162
  by ncanT
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   163
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   164
lemmas ncanTs = ifT applyT splitT whenT
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   165
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   166
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   167
subsection \<open>Subtypes\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   168
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   169
lemma SubtypeD1: "a : Subtype(A, P) \<Longrightarrow> a : A"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   170
  and SubtypeD2: "a : Subtype(A, P) \<Longrightarrow> P(a)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   171
  by (simp_all add: SubtypeXH)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   172
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   173
lemma SubtypeI: "\<lbrakk>a:A; P(a)\<rbrakk> \<Longrightarrow> a : {x:A. P(x)}"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   174
  by (simp add: SubtypeXH)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   175
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   176
lemma SubtypeE: "\<lbrakk>a : {x:A. P(x)}; \<lbrakk>a:A; P(a)\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   177
  by (simp add: SubtypeXH)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   178
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   179
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   180
subsection \<open>Monotonicity\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   181
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   182
lemma idM: "mono (\<lambda>X. X)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   183
  apply (rule monoI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   184
  apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   185
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   186
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   187
lemma constM: "mono(\<lambda>X. A)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   188
  apply (rule monoI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   189
  apply (rule subset_refl)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   190
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   191
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   192
lemma "mono(\<lambda>X. A(X)) \<Longrightarrow> mono(\<lambda>X.[A(X)])"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   193
  apply (rule subsetI [THEN monoI])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   194
  apply (drule LiftXH [THEN iffD1])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   195
  apply (erule disjE)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   196
   apply (erule disjI1 [THEN LiftXH [THEN iffD2]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   197
  apply (rule disjI2 [THEN LiftXH [THEN iffD2]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   198
  apply (drule (1) monoD)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   199
  apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   200
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   201
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   202
lemma SgM:
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   203
  "\<lbrakk>mono(\<lambda>X. A(X)); \<And>x X. x:A(X) \<Longrightarrow> mono(\<lambda>X. B(X,x))\<rbrakk> \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   204
    mono(\<lambda>X. Sigma(A(X),B(X)))"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   205
  by (blast intro!: subsetI [THEN monoI] canTs elim!: case_rls
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   206
    dest!: monoD [THEN subsetD])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   207
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   208
lemma PiM: "(\<And>x. x:A \<Longrightarrow> mono(\<lambda>X. B(X,x))) \<Longrightarrow> mono(\<lambda>X. Pi(A,B(X)))"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   209
  by (blast intro!: subsetI [THEN monoI] canTs elim!: case_rls
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   210
    dest!: monoD [THEN subsetD])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   211
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   212
lemma PlusM: "\<lbrakk>mono(\<lambda>X. A(X)); mono(\<lambda>X. B(X))\<rbrakk> \<Longrightarrow> mono(\<lambda>X. A(X)+B(X))"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   213
  by (blast intro!: subsetI [THEN monoI] canTs elim!: case_rls
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   214
    dest!: monoD [THEN subsetD])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   215
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   216
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   217
subsection \<open>Recursive types\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   218
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   219
subsubsection \<open>Conversion Rules for Fixed Points via monotonicity and Tarski\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   220
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   221
lemma NatM: "mono(\<lambda>X. Unit+X)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   222
  apply (rule PlusM constM idM)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   223
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   224
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   225
lemma def_NatB: "Nat = Unit + Nat"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   226
  apply (rule def_lfp_Tarski [OF Nat_def])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   227
  apply (rule NatM)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   228
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   229
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   230
lemma ListM: "mono(\<lambda>X.(Unit+Sigma(A,\<lambda>y. X)))"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   231
  apply (rule PlusM SgM constM idM)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   232
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   233
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   234
lemma def_ListB: "List(A) = Unit + A * List(A)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   235
  apply (rule def_lfp_Tarski [OF List_def])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   236
  apply (rule ListM)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   237
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   238
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   239
lemma def_ListsB: "Lists(A) = Unit + A * Lists(A)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   240
  apply (rule def_gfp_Tarski [OF Lists_def])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   241
  apply (rule ListM)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   242
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   243
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   244
lemma IListsM: "mono(\<lambda>X.({} + Sigma(A,\<lambda>y. X)))"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   245
  apply (rule PlusM SgM constM idM)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   246
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   247
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   248
lemma def_IListsB: "ILists(A) = {} + A * ILists(A)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   249
  apply (rule def_gfp_Tarski [OF ILists_def])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   250
  apply (rule IListsM)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   251
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   252
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   253
lemmas ind_type_eqs = def_NatB def_ListB def_ListsB def_IListsB
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   254
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   255
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   256
subsection \<open>Exhaustion Rules\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   257
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   258
lemma NatXH: "a : Nat \<longleftrightarrow> (a=zero | (EX x:Nat. a=succ(x)))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   259
  and ListXH: "a : List(A) \<longleftrightarrow> (a=[] | (EX x:A. EX xs:List(A).a=x$xs))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   260
  and ListsXH: "a : Lists(A) \<longleftrightarrow> (a=[] | (EX x:A. EX xs:Lists(A).a=x$xs))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   261
  and IListsXH: "a : ILists(A) \<longleftrightarrow> (EX x:A. EX xs:ILists(A).a=x$xs)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   262
  unfolding ind_data_defs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   263
  by (rule ind_type_eqs [THEN XHlemma1], blast intro!: canTs elim!: case_rls)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   264
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   265
lemmas iXHs = NatXH ListXH
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   266
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   267
ML \<open>ML_Thms.bind_thms ("icase_rls", XH_to_Es @{thms iXHs})\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   268
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   269
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   270
subsection \<open>Type Rules\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   271
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   272
lemma zeroT: "zero : Nat"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   273
  and succT: "n:Nat \<Longrightarrow> succ(n) : Nat"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   274
  and nilT: "[] : List(A)"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   275
  and consT: "\<lbrakk>h:A; t:List(A)\<rbrakk> \<Longrightarrow> h$t : List(A)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   276
  by (blast intro: iXHs [THEN iffD2])+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   277
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   278
lemmas icanTs = zeroT succT nilT consT
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   279
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   280
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   281
method_setup incanT = \<open>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   282
  Scan.succeed (SIMPLE_METHOD' o mk_ncanT_tac @{thms icase_rls} @{thms case_rls})
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   283
\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   284
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   285
lemma ncaseT: "\<lbrakk>n:Nat; n=zero \<Longrightarrow> b:C(zero); \<And>x. \<lbrakk>x:Nat; n=succ(x)\<rbrakk> \<Longrightarrow> c(x):C(succ(x))\<rbrakk>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   286
    \<Longrightarrow> ncase(n,b,c) : C(n)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   287
  by incanT
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   288
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   289
lemma lcaseT: "\<lbrakk>l:List(A); l = [] \<Longrightarrow> b:C([]); \<And>h t. \<lbrakk>h:A; t:List(A); l=h$t\<rbrakk> \<Longrightarrow> c(h,t):C(h$t)\<rbrakk>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   290
    \<Longrightarrow> lcase(l,b,c) : C(l)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   291
  by incanT
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   292
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   293
lemmas incanTs = ncaseT lcaseT
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   294
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   295
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   296
subsection \<open>Induction Rules\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   297
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   298
lemmas ind_Ms = NatM ListM
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   299
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   300
lemma Nat_ind: "\<lbrakk>n:Nat; P(zero); \<And>x. \<lbrakk>x:Nat; P(x)\<rbrakk> \<Longrightarrow> P(succ(x))\<rbrakk> \<Longrightarrow> P(n)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   301
  apply (unfold ind_data_defs)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   302
  apply (erule def_induct [OF Nat_def _ NatM])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   303
  apply (blast intro: canTs elim!: case_rls)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   304
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   305
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   306
lemma List_ind: "\<lbrakk>l:List(A); P([]); \<And>x xs. \<lbrakk>x:A; xs:List(A); P(xs)\<rbrakk> \<Longrightarrow> P(x$xs)\<rbrakk> \<Longrightarrow> P(l)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   307
  apply (unfold ind_data_defs)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   308
  apply (erule def_induct [OF List_def _ ListM])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   309
  apply (blast intro: canTs elim!: case_rls)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   310
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   311
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   312
lemmas inds = Nat_ind List_ind
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   313
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   314
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   315
subsection \<open>Primitive Recursive Rules\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   316
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   317
lemma nrecT: "\<lbrakk>n:Nat; b:C(zero); \<And>x g. \<lbrakk>x:Nat; g:C(x)\<rbrakk> \<Longrightarrow> c(x,g):C(succ(x))\<rbrakk>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   318
    \<Longrightarrow> nrec(n,b,c) : C(n)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   319
  by (erule Nat_ind) auto
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   320
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   321
lemma lrecT: "\<lbrakk>l:List(A); b:C([]); \<And>x xs g. \<lbrakk>x:A; xs:List(A); g:C(xs)\<rbrakk> \<Longrightarrow> c(x,xs,g):C(x$xs) \<rbrakk>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   322
    \<Longrightarrow> lrec(l,b,c) : C(l)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   323
  by (erule List_ind) auto
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   324
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   325
lemmas precTs = nrecT lrecT
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   326
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   327
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   328
subsection \<open>Theorem proving\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   329
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   330
lemma SgE2: "\<lbrakk><a,b> : Sigma(A,B); \<lbrakk>a:A; b:B(a)\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   331
  unfolding SgXH by blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   332
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   333
(* General theorem proving ignores non-canonical term-formers,             *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   334
(*         - intro rules are type rules for canonical terms                *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   335
(*         - elim rules are case rules (no non-canonical terms appear)     *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   336
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   337
ML \<open>ML_Thms.bind_thms ("XHEs", XH_to_Es @{thms XHs})\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   338
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   339
lemmas [intro!] = SubtypeI canTs icanTs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   340
  and [elim!] = SubtypeE XHEs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   341
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   342
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   343
subsection \<open>Infinite Data Types\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   344
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   345
lemma lfp_subset_gfp: "mono(f) \<Longrightarrow> lfp(f) <= gfp(f)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   346
  apply (rule lfp_lowerbound [THEN subset_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   347
   apply (erule gfp_lemma3)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   348
  apply (rule subset_refl)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   349
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   350
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   351
lemma gfpI:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   352
  assumes "a:A"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   353
    and "\<And>x X. \<lbrakk>x:A; ALL y:A. t(y):X\<rbrakk> \<Longrightarrow> t(x) : B(X)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   354
  shows "t(a) : gfp(B)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   355
  apply (rule coinduct)
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   356
   apply (rule_tac P = "\<lambda>x. EX y:A. x=t (y)" in CollectI)
41526
54b4686704af eliminated global prems;
wenzelm
parents: 39159
diff changeset
   357
   apply (blast intro!: assms)+
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   358
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   359
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   360
lemma def_gfpI: "\<lbrakk>C == gfp(B); a:A; \<And>x X. \<lbrakk>x:A; ALL y:A. t(y):X\<rbrakk> \<Longrightarrow> t(x) : B(X)\<rbrakk> \<Longrightarrow> t(a) : C"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   361
  apply unfold
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   362
  apply (erule gfpI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   363
  apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   364
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   365
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   366
(* EG *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   367
lemma "letrec g x be zero$g(x) in g(bot) : Lists(Nat)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   368
  apply (rule refl [THEN UnitXH [THEN iffD2], THEN Lists_def [THEN def_gfpI]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   369
  apply (subst letrecB)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   370
  apply (unfold cons_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   371
  apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   372
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   373
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   374
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 60770
diff changeset
   375
subsection \<open>Lemmas and tactics for using the rule \<open>coinduct3\<close> on \<open>[=\<close> and \<open>=\<close>\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   376
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   377
lemma lfpI: "\<lbrakk>mono(f); a : f(lfp(f))\<rbrakk> \<Longrightarrow> a : lfp(f)"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   378
  apply (erule lfp_Tarski [THEN ssubst])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   379
  apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   380
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   381
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   382
lemma ssubst_single: "\<lbrakk>a = a'; a' : A\<rbrakk> \<Longrightarrow> a : A"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   383
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   384
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   385
lemma ssubst_pair: "\<lbrakk>a = a'; b = b'; <a',b'> : A\<rbrakk> \<Longrightarrow> <a,b> : A"
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   386
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   387
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   388
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   389
ML \<open>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   390
  val coinduct3_tac = SUBPROOF (fn {context = ctxt, prems = mono :: prems, ...} =>
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42480
diff changeset
   391
    fast_tac (ctxt addIs (mono RS @{thm coinduct3_mono_lemma} RS @{thm lfpI}) :: prems) 1);
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   392
\<close>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   393
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   394
method_setup coinduct3 = \<open>Scan.succeed (SIMPLE_METHOD' o coinduct3_tac)\<close>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   395
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   396
lemma ci3_RI: "\<lbrakk>mono(Agen); a : R\<rbrakk> \<Longrightarrow> a : lfp(\<lambda>x. Agen(x) Un R Un A)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   397
  by coinduct3
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   398
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   399
lemma ci3_AgenI: "\<lbrakk>mono(Agen); a : Agen(lfp(\<lambda>x. Agen(x) Un R Un A))\<rbrakk> \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   400
    a : lfp(\<lambda>x. Agen(x) Un R Un A)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   401
  by coinduct3
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   402
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   403
lemma ci3_AI: "\<lbrakk>mono(Agen); a : A\<rbrakk> \<Longrightarrow> a : lfp(\<lambda>x. Agen(x) Un R Un A)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   404
  by coinduct3
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   405
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   406
ML \<open>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   407
fun genIs_tac ctxt genXH gen_mono =
60754
02924903a6fd prefer tactics with explicit context;
wenzelm
parents: 59499
diff changeset
   408
  resolve_tac ctxt [genXH RS @{thm iffD2}] THEN'
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 42814
diff changeset
   409
  simp_tac ctxt THEN'
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42480
diff changeset
   410
  TRY o fast_tac
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42480
diff changeset
   411
    (ctxt addIs [genXH RS @{thm iffD2}, gen_mono RS @{thm coinduct3_mono_lemma} RS @{thm lfpI}])
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   412
\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   413
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   414
method_setup genIs = \<open>
42814
5af15f1e2ef6 simplified/unified method_setup/attribute_setup;
wenzelm
parents: 42793
diff changeset
   415
  Attrib.thm -- Attrib.thm >>
5af15f1e2ef6 simplified/unified method_setup/attribute_setup;
wenzelm
parents: 42793
diff changeset
   416
    (fn (genXH, gen_mono) => fn ctxt => SIMPLE_METHOD' (genIs_tac ctxt genXH gen_mono))
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   417
\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   418
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   419
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   420
subsection \<open>POgen\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   421
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   422
lemma PO_refl: "<a,a> : PO"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   423
  by (rule po_refl [THEN PO_iff [THEN iffD1]])
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   424
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   425
lemma POgenIs:
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   426
  "<true,true> : POgen(R)"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   427
  "<false,false> : POgen(R)"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   428
  "\<lbrakk><a,a'> : R; <b,b'> : R\<rbrakk> \<Longrightarrow> <<a,b>,<a',b'>> : POgen(R)"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   429
  "\<And>b b'. (\<And>x. <b(x),b'(x)> : R) \<Longrightarrow> <lam x. b(x),lam x. b'(x)> : POgen(R)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   430
  "<one,one> : POgen(R)"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   431
  "<a,a'> : lfp(\<lambda>x. POgen(x) Un R Un PO) \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   432
    <inl(a),inl(a')> : POgen(lfp(\<lambda>x. POgen(x) Un R Un PO))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   433
  "<b,b'> : lfp(\<lambda>x. POgen(x) Un R Un PO) \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   434
    <inr(b),inr(b')> : POgen(lfp(\<lambda>x. POgen(x) Un R Un PO))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   435
  "<zero,zero> : POgen(lfp(\<lambda>x. POgen(x) Un R Un PO))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   436
  "<n,n'> : lfp(\<lambda>x. POgen(x) Un R Un PO) \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   437
    <succ(n),succ(n')> : POgen(lfp(\<lambda>x. POgen(x) Un R Un PO))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   438
  "<[],[]> : POgen(lfp(\<lambda>x. POgen(x) Un R Un PO))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   439
  "\<lbrakk><h,h'> : lfp(\<lambda>x. POgen(x) Un R Un PO);  <t,t'> : lfp(\<lambda>x. POgen(x) Un R Un PO)\<rbrakk>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   440
    \<Longrightarrow> <h$t,h'$t'> : POgen(lfp(\<lambda>x. POgen(x) Un R Un PO))"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   441
  unfolding data_defs by (genIs POgenXH POgen_mono)+
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   442
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   443
ML \<open>
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   444
fun POgen_tac ctxt (rla, rlb) i =
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42480
diff changeset
   445
  SELECT_GOAL (safe_tac ctxt) i THEN
60754
02924903a6fd prefer tactics with explicit context;
wenzelm
parents: 59499
diff changeset
   446
  resolve_tac ctxt [rlb RS (rla RS @{thm ssubst_pair})] i THEN
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58977
diff changeset
   447
  (REPEAT (resolve_tac ctxt
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   448
      (@{thms POgenIs} @ [@{thm PO_refl} RS (@{thm POgen_mono} RS @{thm ci3_AI})] @
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   449
        (@{thms POgenIs} RL [@{thm POgen_mono} RS @{thm ci3_AgenI}]) @
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   450
        [@{thm POgen_mono} RS @{thm ci3_RI}]) i))
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   451
\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   452
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   453
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   454
subsection \<open>EQgen\<close>
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   455
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   456
lemma EQ_refl: "<a,a> : EQ"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   457
  by (rule refl [THEN EQ_iff [THEN iffD1]])
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   458
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   459
lemma EQgenIs:
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   460
  "<true,true> : EQgen(R)"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   461
  "<false,false> : EQgen(R)"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   462
  "\<lbrakk><a,a'> : R; <b,b'> : R\<rbrakk> \<Longrightarrow> <<a,b>,<a',b'>> : EQgen(R)"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   463
  "\<And>b b'. (\<And>x. <b(x),b'(x)> : R) \<Longrightarrow> <lam x. b(x),lam x. b'(x)> : EQgen(R)"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   464
  "<one,one> : EQgen(R)"
58977
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   465
  "<a,a'> : lfp(\<lambda>x. EQgen(x) Un R Un EQ) \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   466
    <inl(a),inl(a')> : EQgen(lfp(\<lambda>x. EQgen(x) Un R Un EQ))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   467
  "<b,b'> : lfp(\<lambda>x. EQgen(x) Un R Un EQ) \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   468
    <inr(b),inr(b')> : EQgen(lfp(\<lambda>x. EQgen(x) Un R Un EQ))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   469
  "<zero,zero> : EQgen(lfp(\<lambda>x. EQgen(x) Un R Un EQ))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   470
  "<n,n'> : lfp(\<lambda>x. EQgen(x) Un R Un EQ) \<Longrightarrow>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   471
    <succ(n),succ(n')> : EQgen(lfp(\<lambda>x. EQgen(x) Un R Un EQ))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   472
  "<[],[]> : EQgen(lfp(\<lambda>x. EQgen(x) Un R Un EQ))"
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   473
  "\<lbrakk><h,h'> : lfp(\<lambda>x. EQgen(x) Un R Un EQ); <t,t'> : lfp(\<lambda>x. EQgen(x) Un R Un EQ)\<rbrakk>
9576b510f6a2 more symbols;
wenzelm
parents: 58976
diff changeset
   474
    \<Longrightarrow> <h$t,h'$t'> : EQgen(lfp(\<lambda>x. EQgen(x) Un R Un EQ))"
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   475
  unfolding data_defs by (genIs EQgenXH EQgen_mono)+
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   476
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   477
ML \<open>
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58977
diff changeset
   478
fun EQgen_raw_tac ctxt i =
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58977
diff changeset
   479
  (REPEAT (resolve_tac ctxt (@{thms EQgenIs} @
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   480
        [@{thm EQ_refl} RS (@{thm EQgen_mono} RS @{thm ci3_AI})] @
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   481
        (@{thms EQgenIs} RL [@{thm EQgen_mono} RS @{thm ci3_AgenI}]) @
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   482
        [@{thm EQgen_mono} RS @{thm ci3_RI}]) i))
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   483
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   484
(* Goals of the form R <= EQgen(R) - rewrite elements <a,b> : EQgen(R) using rews and *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   485
(* then reduce this to a goal <a',b'> : R (hopefully?)                                *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   486
(*      rews are rewrite rules that would cause looping in the simpifier              *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   487
23894
1a4167d761ac tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents: 20140
diff changeset
   488
fun EQgen_tac ctxt rews i =
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17782
diff changeset
   489
 SELECT_GOAL
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42480
diff changeset
   490
   (TRY (safe_tac ctxt) THEN
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58977
diff changeset
   491
    resolve_tac ctxt ((rews @ [@{thm refl}]) RL ((rews @ [@{thm refl}]) RL [@{thm ssubst_pair}])) i THEN
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 42814
diff changeset
   492
    ALLGOALS (simp_tac ctxt) THEN
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 58977
diff changeset
   493
    ALLGOALS (EQgen_raw_tac ctxt)) i
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   494
\<close>
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   495
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   496
method_setup EQgen = \<open>
58971
8c9a319821b3 more Isar proof methods;
wenzelm
parents: 58889
diff changeset
   497
  Attrib.thms >> (fn ths => fn ctxt => SIMPLE_METHOD' (EQgen_tac ctxt ths))
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 60754
diff changeset
   498
\<close>
58971
8c9a319821b3 more Isar proof methods;
wenzelm
parents: 58889
diff changeset
   499
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   500
end