src/CCL/CCL.thy
author wenzelm
Tue, 26 Apr 2011 22:18:07 +0200
changeset 42480 f4f011d1bf0b
parent 42156 df219e736a5d
child 42814 5af15f1e2ef6
permissions -rw-r--r--
proper antiquotations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
     1
(*  Title:      CCL/CCL.thy
1474
3f7d67927fe2 expanded tabs
clasohm
parents: 1149
diff changeset
     2
    Author:     Martin Coen
0
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
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
     6
header {* Classical Computational Logic for Untyped Lambda Calculus
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
     7
  with reduction to weak head-normal form *}
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
     9
theory CCL
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    10
imports Gfp
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    11
begin
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    13
text {*
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    14
  Based on FOL extended with set collection, a primitive higher-order
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    15
  logic.  HOL is too strong - descriptions prevent a type of programs
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    16
  being defined which contains only executable terms.
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    17
*}
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    19
classes prog < "term"
36452
d37c6eed8117 renamed command 'defaultsort' to 'default_sort';
wenzelm
parents: 35409
diff changeset
    20
default_sort prog
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    21
24825
c4f13ab78f9d avoid unnamed infixes;
wenzelm
parents: 20140
diff changeset
    22
arities "fun" :: (prog, prog) prog
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    23
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    24
typedecl i
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    25
arities i :: prog
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    26
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
consts
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
  (*** Evaluation Judgement ***)
24825
c4f13ab78f9d avoid unnamed infixes;
wenzelm
parents: 20140
diff changeset
    30
  Eval      ::       "[i,i]=>prop"          (infixl "--->" 20)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
  (*** Bisimulations for pre-order and equality ***)
24825
c4f13ab78f9d avoid unnamed infixes;
wenzelm
parents: 20140
diff changeset
    33
  po          ::       "['a,'a]=>o"           (infixl "[=" 50)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  SIM         ::       "[i,i,i set]=>o"
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    35
  POgen       ::       "i set => i set"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    36
  EQgen       ::       "i set => i set"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    37
  PO          ::       "i set"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    38
  EQ          ::       "i set"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
  (*** Term Formers ***)
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    41
  true        ::       "i"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    42
  false       ::       "i"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
  pair        ::       "[i,i]=>i"             ("(1<_,/_>)")
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
  lambda      ::       "(i=>i)=>i"            (binder "lam " 55)
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    45
  "case"      ::       "[i,i,i,[i,i]=>i,(i=>i)=>i]=>i"
24825
c4f13ab78f9d avoid unnamed infixes;
wenzelm
parents: 20140
diff changeset
    46
  "apply"     ::       "[i,i]=>i"             (infixl "`" 56)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
  bot         ::       "i"
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    48
  "fix"       ::       "(i=>i)=>i"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
  (*** Defined Predicates ***)
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    51
  Trm         ::       "i => o"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    52
  Dvg         ::       "i => o"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    54
axioms
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
  (******* EVALUATION SEMANTICS *******)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
  (**  This is the evaluation semantics from which the axioms below were derived.  **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
  (**  It is included here just as an evaluator for FUN and has no influence on    **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
  (**  inference in the theory CCL.                                                **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    62
  trueV:       "true ---> true"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    63
  falseV:      "false ---> false"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    64
  pairV:       "<a,b> ---> <a,b>"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    65
  lamV:        "lam x. b(x) ---> lam x. b(x)"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    66
  caseVtrue:   "[| t ---> true;  d ---> c |] ==> case(t,d,e,f,g) ---> c"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    67
  caseVfalse:  "[| t ---> false;  e ---> c |] ==> case(t,d,e,f,g) ---> c"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    68
  caseVpair:   "[| t ---> <a,b>;  f(a,b) ---> c |] ==> case(t,d,e,f,g) ---> c"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    69
  caseVlam:    "[| t ---> lam x. b(x);  g(b) ---> c |] ==> case(t,d,e,f,g) ---> c"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
  (*** Properties of evaluation: note that "t ---> c" impies that c is canonical ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    73
  canonical:  "[| t ---> c; c==true ==> u--->v;
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    74
                          c==false ==> u--->v;
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    75
                    !!a b. c==<a,b> ==> u--->v;
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    76
                      !!f. c==lam x. f(x) ==> u--->v |] ==>
1149
5750eba8820d removed \...\ inside strings
clasohm
parents: 283
diff changeset
    77
             u--->v"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
  (* Should be derivable - but probably a bitch! *)
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    80
  substitute: "[| a==a'; t(a)--->c(a) |] ==> t(a')--->c(a')"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
  (************** LOGIC ***************)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
  (*** Definitions used in the following rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    86
  apply_def:     "f ` t == case(f,bot,bot,%x y. bot,%u. u(t))"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    87
  bot_def:         "bot == (lam x. x`x)`(lam x. x`x)"
42156
df219e736a5d modernized specifications -- less axioms;
wenzelm
parents: 40844
diff changeset
    88
df219e736a5d modernized specifications -- less axioms;
wenzelm
parents: 40844
diff changeset
    89
defs
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    90
  fix_def:      "fix(f) == (lam x. f(x`x))`(lam x. f(x`x))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
  (*  The pre-order ([=) is defined as a simulation, and behavioural equivalence (=) *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
  (*  as a bisimulation.  They can both be expressed as (bi)simulations up to        *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
  (*  behavioural equivalence (ie the relations PO and EQ defined below).            *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    96
  SIM_def:
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    97
  "SIM(t,t',R) ==  (t=true & t'=true) | (t=false & t'=false) |
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
    98
                  (EX a a' b b'. t=<a,b> & t'=<a',b'> & <a,a'> : R & <b,b'> : R) |
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1474
diff changeset
    99
                  (EX f f'. t=lam x. f(x) & t'=lam x. f'(x) & (ALL x.<f(x),f'(x)> : R))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   101
  POgen_def:  "POgen(R) == {p. EX t t'. p=<t,t'> & (t = bot | SIM(t,t',R))}"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   102
  EQgen_def:  "EQgen(R) == {p. EX t t'. p=<t,t'> & (t = bot & t' = bot | SIM(t,t',R))}"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   104
  PO_def:    "PO == gfp(POgen)"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   105
  EQ_def:    "EQ == gfp(EQgen)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
  (*** Rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
  (** Partial Order **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
42156
df219e736a5d modernized specifications -- less axioms;
wenzelm
parents: 40844
diff changeset
   111
axioms
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   112
  po_refl:        "a [= a"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   113
  po_trans:       "[| a [= b;  b [= c |] ==> a [= c"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   114
  po_cong:        "a [= b ==> f(a) [= f(b)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
  (* Extend definition of [= to program fragments of higher type *)
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   117
  po_abstractn:   "(!!x. f(x) [= g(x)) ==> (%x. f(x)) [= (%x. g(x))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
  (** Equality - equivalence axioms inherited from FOL.thy   **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
  (**          - congruence of "=" is axiomatised implicitly **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   122
  eq_iff:         "t = t' <-> t [= t' & t' [= t"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
  (** Properties of canonical values given by greatest fixed point definitions **)
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   125
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   126
  PO_iff:         "t [= t' <-> <t,t'> : PO"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   127
  EQ_iff:         "t =  t' <-> <t,t'> : EQ"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
  (** Behaviour of non-canonical terms (ie case) given by the following beta-rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   131
  caseBtrue:            "case(true,d,e,f,g) = d"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   132
  caseBfalse:          "case(false,d,e,f,g) = e"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   133
  caseBpair:           "case(<a,b>,d,e,f,g) = f(a,b)"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   134
  caseBlam:       "case(lam x. b(x),d,e,f,g) = g(b)"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   135
  caseBbot:              "case(bot,d,e,f,g) = bot"            (* strictness *)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
  (** The theory is non-trivial **)
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   138
  distinctness:   "~ lam x. b(x) = bot"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
  (*** Definitions of Termination and Divergence ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
42156
df219e736a5d modernized specifications -- less axioms;
wenzelm
parents: 40844
diff changeset
   142
defs
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   143
  Dvg_def:  "Dvg(t) == t = bot"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   144
  Trm_def:  "Trm(t) == ~ Dvg(t)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   146
text {*
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
Would be interesting to build a similar theory for a typed programming language:
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
    ie.     true :: bool,      fix :: ('a=>'a)=>'a  etc......
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
This is starting to look like LCF.
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   151
What are the advantages of this approach?
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   152
        - less axiomatic
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
        - wfd induction / coinduction and fixed point induction available
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   154
*}
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   155
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   156
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   157
lemmas ccl_data_defs = apply_def fix_def
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   158
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   159
declare po_refl [simp]
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   160
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   161
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   162
subsection {* Congruence Rules *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   163
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   164
(*similar to AP_THM in Gordon's HOL*)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   165
lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   166
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   167
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   168
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   169
lemma arg_cong: "x=y ==> f(x)=f(y)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   170
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   171
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   172
lemma abstractn: "(!!x. f(x) = g(x)) ==> f = g"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   173
  apply (simp add: eq_iff)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   174
  apply (blast intro: po_abstractn)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   175
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   176
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   177
lemmas caseBs = caseBtrue caseBfalse caseBpair caseBlam caseBbot
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   178
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   179
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   180
subsection {* Termination and Divergence *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   181
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   182
lemma Trm_iff: "Trm(t) <-> ~ t = bot"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   183
  by (simp add: Trm_def Dvg_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   184
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   185
lemma Dvg_iff: "Dvg(t) <-> t = bot"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   186
  by (simp add: Trm_def Dvg_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   187
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   188
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   189
subsection {* Constructors are injective *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   190
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   191
lemma eq_lemma: "[| x=a;  y=b;  x=y |] ==> a=b"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   192
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   193
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   194
ML {*
32154
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   195
  fun inj_rl_tac ctxt rews i =
24825
c4f13ab78f9d avoid unnamed infixes;
wenzelm
parents: 20140
diff changeset
   196
    let
c4f13ab78f9d avoid unnamed infixes;
wenzelm
parents: 20140
diff changeset
   197
      fun mk_inj_lemmas r = [@{thm arg_cong}] RL [r RS (r RS @{thm eq_lemma})]
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   198
      val inj_lemmas = maps mk_inj_lemmas rews
32154
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   199
    in
35409
5c5bb83f2bae more antiquotations;
wenzelm
parents: 32175
diff changeset
   200
      CHANGED (REPEAT (ares_tac [@{thm iffI}, @{thm allI}, @{thm conjI}] i ORELSE
32154
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   201
        eresolve_tac inj_lemmas i ORELSE
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   202
        asm_simp_tac (simpset_of ctxt addsimps rews) i))
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   203
    end;
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   204
*}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   205
32154
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   206
method_setup inj_rl = {*
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   207
  Attrib.thms >> (fn rews => fn ctxt => SIMPLE_METHOD' (inj_rl_tac ctxt rews))
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   208
*} ""
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   209
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   210
lemma ccl_injs:
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   211
  "<a,b> = <a',b'> <-> (a=a' & b=b')"
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   212
  "!!b b'. (lam x. b(x) = lam x. b'(x)) <-> ((ALL z. b(z)=b'(z)))"
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   213
  by (inj_rl caseBs)
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   214
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   215
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   216
lemma pair_inject: "<a,b> = <a',b'> \<Longrightarrow> (a = a' \<Longrightarrow> b = b' \<Longrightarrow> R) \<Longrightarrow> R"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   217
  by (simp add: ccl_injs)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   218
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   219
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   220
subsection {* Constructors are distinct *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   221
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   222
lemma lem: "t=t' ==> case(t,b,c,d,e) = case(t',b,c,d,e)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   223
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   224
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   225
ML {*
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   226
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   227
local
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   228
  fun pairs_of f x [] = []
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   229
    | pairs_of f x (y::ys) = (f x y) :: (f y x) :: (pairs_of f x ys)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   230
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   231
  fun mk_combs ff [] = []
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   232
    | mk_combs ff (x::xs) = (pairs_of ff x xs) @ mk_combs ff xs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   233
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   234
  (* Doesn't handle binder types correctly *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   235
  fun saturate thy sy name =
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   236
       let fun arg_str 0 a s = s
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   237
         | arg_str 1 a s = "(" ^ a ^ "a" ^ s ^ ")"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   238
         | arg_str n a s = arg_str (n-1) a ("," ^ a ^ (chr((ord "a")+n-1)) ^ s)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   239
           val T = Sign.the_const_type thy (Sign.intern_const thy sy);
40844
5895c525739d more direct use of binder_types/body_type;
wenzelm
parents: 39159
diff changeset
   240
           val arity = length (binder_types T)
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   241
       in sy ^ (arg_str arity name "") end
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   242
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   243
  fun mk_thm_str thy a b = "~ " ^ (saturate thy a "a") ^ " = " ^ (saturate thy b "b")
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   244
39159
0dec18004e75 more antiquotations;
wenzelm
parents: 36452
diff changeset
   245
  val lemma = @{thm lem};
0dec18004e75 more antiquotations;
wenzelm
parents: 36452
diff changeset
   246
  val eq_lemma = @{thm eq_lemma};
0dec18004e75 more antiquotations;
wenzelm
parents: 36452
diff changeset
   247
  val distinctness = @{thm distinctness};
42480
f4f011d1bf0b proper antiquotations;
wenzelm
parents: 42156
diff changeset
   248
  fun mk_lemma (ra,rb) =
f4f011d1bf0b proper antiquotations;
wenzelm
parents: 42156
diff changeset
   249
    [lemma] RL [ra RS (rb RS eq_lemma)] RL
f4f011d1bf0b proper antiquotations;
wenzelm
parents: 42156
diff changeset
   250
    [distinctness RS @{thm notE}, @{thm sym} RS (distinctness RS @{thm notE})]
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   251
in
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   252
  fun mk_lemmas rls = maps mk_lemma (mk_combs pair rls)
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   253
  fun mk_dstnct_rls thy xs = mk_combs (mk_thm_str thy) xs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   254
end
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   255
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   256
*}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   257
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   258
ML {*
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   259
32010
cb1a1c94b4cd more antiquotations;
wenzelm
parents: 27239
diff changeset
   260
val caseB_lemmas = mk_lemmas @{thms caseBs}
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   261
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   262
val ccl_dstncts =
32175
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   263
  let
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   264
    fun mk_raw_dstnct_thm rls s =
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   265
      Goal.prove_global @{theory} [] [] (Syntax.read_prop_global @{theory} s)
35409
5c5bb83f2bae more antiquotations;
wenzelm
parents: 32175
diff changeset
   266
        (fn _=> rtac @{thm notI} 1 THEN eresolve_tac rls 1)
32175
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   267
  in map (mk_raw_dstnct_thm caseB_lemmas)
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   268
    (mk_dstnct_rls @{theory} ["bot","true","false","pair","lambda"]) end
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   269
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   270
fun mk_dstnct_thms thy defs inj_rls xs =
32175
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   271
  let
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   272
    fun mk_dstnct_thm rls s =
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   273
      Goal.prove_global thy [] [] (Syntax.read_prop_global thy s)
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   274
        (fn _ =>
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   275
          rewrite_goals_tac defs THEN
a89979440d2c eliminated OldGoals.prove_goal;
wenzelm
parents: 32174
diff changeset
   276
          simp_tac (global_simpset_of thy addsimps (rls @ inj_rls)) 1)
32149
ef59550a55d3 renamed simpset_of to global_simpset_of, and local_simpset_of to simpset_of -- same for claset and clasimpset;
wenzelm
parents: 32010
diff changeset
   277
  in map (mk_dstnct_thm ccl_dstncts) (mk_dstnct_rls thy xs) end
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   278
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   279
fun mkall_dstnct_thms thy defs i_rls xss = maps (mk_dstnct_thms thy defs i_rls) xss
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   280
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   281
(*** Rewriting and Proving ***)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   282
42480
f4f011d1bf0b proper antiquotations;
wenzelm
parents: 42156
diff changeset
   283
fun XH_to_I rl = rl RS @{thm iffD2}
f4f011d1bf0b proper antiquotations;
wenzelm
parents: 42156
diff changeset
   284
fun XH_to_D rl = rl RS @{thm iffD1}
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   285
val XH_to_E = make_elim o XH_to_D
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   286
val XH_to_Is = map XH_to_I
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   287
val XH_to_Ds = map XH_to_D
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   288
val XH_to_Es = map XH_to_E;
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   289
32154
9721e8e4d48c eliminated adhoc ML code;
wenzelm
parents: 32153
diff changeset
   290
bind_thms ("ccl_rews", @{thms caseBs} @ @{thms ccl_injs} @ ccl_dstncts);
42480
f4f011d1bf0b proper antiquotations;
wenzelm
parents: 42156
diff changeset
   291
bind_thms ("ccl_dstnctsEs", ccl_dstncts RL [@{thm notE}]);
32010
cb1a1c94b4cd more antiquotations;
wenzelm
parents: 27239
diff changeset
   292
bind_thms ("ccl_injDs", XH_to_Ds @{thms ccl_injs});
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   293
*}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   294
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   295
lemmas [simp] = ccl_rews
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   296
  and [elim!] = pair_inject ccl_dstnctsEs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   297
  and [dest!] = ccl_injDs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   298
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   299
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   300
subsection {* Facts from gfp Definition of @{text "[="} and @{text "="} *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   301
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   302
lemma XHlemma1: "[| A=B;  a:B <-> P |] ==> a:A <-> P"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   303
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   304
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   305
lemma XHlemma2: "(P(t,t') <-> Q) ==> (<t,t'> : {p. EX t t'. p=<t,t'> &  P(t,t')} <-> Q)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   306
  by blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   307
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   308
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   309
subsection {* Pre-Order *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   310
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   311
lemma POgen_mono: "mono(%X. POgen(X))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   312
  apply (unfold POgen_def SIM_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   313
  apply (rule monoI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   314
  apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   315
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   316
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   317
lemma POgenXH: 
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   318
  "<t,t'> : POgen(R) <-> t= bot | (t=true & t'=true)  | (t=false & t'=false) |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   319
           (EX a a' b b'. t=<a,b> &  t'=<a',b'>  & <a,a'> : R & <b,b'> : R) |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   320
           (EX f f'. t=lam x. f(x) &  t'=lam x. f'(x) & (ALL x. <f(x),f'(x)> : R))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   321
  apply (unfold POgen_def SIM_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   322
  apply (rule iff_refl [THEN XHlemma2])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   323
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   324
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   325
lemma poXH: 
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   326
  "t [= t' <-> t=bot | (t=true & t'=true) | (t=false & t'=false) |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   327
                 (EX a a' b b'. t=<a,b> &  t'=<a',b'>  & a [= a' & b [= b') |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   328
                 (EX f f'. t=lam x. f(x) &  t'=lam x. f'(x) & (ALL x. f(x) [= f'(x)))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   329
  apply (simp add: PO_iff del: ex_simps)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   330
  apply (rule POgen_mono
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   331
    [THEN PO_def [THEN def_gfp_Tarski], THEN XHlemma1, unfolded POgen_def SIM_def])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   332
  apply (rule iff_refl [THEN XHlemma2])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   333
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   334
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   335
lemma po_bot: "bot [= b"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   336
  apply (rule poXH [THEN iffD2])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   337
  apply simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   338
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   339
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   340
lemma bot_poleast: "a [= bot ==> a=bot"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   341
  apply (drule poXH [THEN iffD1])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   342
  apply simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   343
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   344
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   345
lemma po_pair: "<a,b> [= <a',b'> <->  a [= a' & b [= b'"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   346
  apply (rule poXH [THEN iff_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   347
  apply simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   348
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   349
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   350
lemma po_lam: "lam x. f(x) [= lam x. f'(x) <-> (ALL x. f(x) [= f'(x))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   351
  apply (rule poXH [THEN iff_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   352
  apply fastsimp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   353
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   354
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   355
lemmas ccl_porews = po_bot po_pair po_lam
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   356
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   357
lemma case_pocong:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   358
  assumes 1: "t [= t'"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   359
    and 2: "a [= a'"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   360
    and 3: "b [= b'"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   361
    and 4: "!!x y. c(x,y) [= c'(x,y)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   362
    and 5: "!!u. d(u) [= d'(u)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   363
  shows "case(t,a,b,c,d) [= case(t',a',b',c',d')"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   364
  apply (rule 1 [THEN po_cong, THEN po_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   365
  apply (rule 2 [THEN po_cong, THEN po_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   366
  apply (rule 3 [THEN po_cong, THEN po_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   367
  apply (rule 4 [THEN po_abstractn, THEN po_abstractn, THEN po_cong, THEN po_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   368
  apply (rule_tac f1 = "%d. case (t',a',b',c',d)" in
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   369
    5 [THEN po_abstractn, THEN po_cong, THEN po_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   370
  apply (rule po_refl)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   371
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   372
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   373
lemma apply_pocong: "[| f [= f';  a [= a' |] ==> f ` a [= f' ` a'"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   374
  unfolding ccl_data_defs
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   375
  apply (rule case_pocong, (rule po_refl | assumption)+)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   376
  apply (erule po_cong)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   377
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   378
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   379
lemma npo_lam_bot: "~ lam x. b(x) [= bot"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   380
  apply (rule notI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   381
  apply (drule bot_poleast)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   382
  apply (erule distinctness [THEN notE])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   383
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   384
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   385
lemma po_lemma: "[| x=a;  y=b;  x[=y |] ==> a[=b"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   386
  by simp
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   387
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   388
lemma npo_pair_lam: "~ <a,b> [= lam x. f(x)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   389
  apply (rule notI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   390
  apply (rule npo_lam_bot [THEN notE])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   391
  apply (erule case_pocong [THEN caseBlam [THEN caseBpair [THEN po_lemma]]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   392
  apply (rule po_refl npo_lam_bot)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   393
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   394
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   395
lemma npo_lam_pair: "~ lam x. f(x) [= <a,b>"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   396
  apply (rule notI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   397
  apply (rule npo_lam_bot [THEN notE])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   398
  apply (erule case_pocong [THEN caseBpair [THEN caseBlam [THEN po_lemma]]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   399
  apply (rule po_refl npo_lam_bot)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   400
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   401
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   402
lemma npo_rls1:
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   403
  "~ true [= false"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   404
  "~ false [= true"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   405
  "~ true [= <a,b>"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   406
  "~ <a,b> [= true"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   407
  "~ true [= lam x. f(x)"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   408
  "~ lam x. f(x) [= true"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   409
  "~ false [= <a,b>"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   410
  "~ <a,b> [= false"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   411
  "~ false [= lam x. f(x)"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   412
  "~ lam x. f(x) [= false"
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   413
  by (tactic {*
35409
5c5bb83f2bae more antiquotations;
wenzelm
parents: 32175
diff changeset
   414
    REPEAT (rtac @{thm notI} 1 THEN
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   415
      dtac @{thm case_pocong} 1 THEN
35409
5c5bb83f2bae more antiquotations;
wenzelm
parents: 32175
diff changeset
   416
      etac @{thm rev_mp} 5 THEN
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   417
      ALLGOALS (simp_tac @{simpset}) THEN
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   418
      REPEAT (resolve_tac [@{thm po_refl}, @{thm npo_lam_bot}] 1)) *})
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   419
32153
a0e57fb1b930 misc modernization: proper method setup instead of adhoc ML proofs;
wenzelm
parents: 32149
diff changeset
   420
lemmas npo_rls = npo_pair_lam npo_lam_pair npo_rls1
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   421
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   422
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   423
subsection {* Coinduction for @{text "[="} *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   424
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   425
lemma po_coinduct: "[|  <t,u> : R;  R <= POgen(R) |] ==> t [= u"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   426
  apply (rule PO_def [THEN def_coinduct, THEN PO_iff [THEN iffD2]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   427
   apply assumption+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   428
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   429
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   430
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   431
subsection {* Equality *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   432
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   433
lemma EQgen_mono: "mono(%X. EQgen(X))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   434
  apply (unfold EQgen_def SIM_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   435
  apply (rule monoI)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   436
  apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   437
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   438
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   439
lemma EQgenXH: 
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   440
  "<t,t'> : EQgen(R) <-> (t=bot & t'=bot)  | (t=true & t'=true)  |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   441
                                             (t=false & t'=false) |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   442
                 (EX a a' b b'. t=<a,b> &  t'=<a',b'>  & <a,a'> : R & <b,b'> : R) |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   443
                 (EX f f'. t=lam x. f(x) &  t'=lam x. f'(x) & (ALL x.<f(x),f'(x)> : R))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   444
  apply (unfold EQgen_def SIM_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   445
  apply (rule iff_refl [THEN XHlemma2])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   446
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   447
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   448
lemma eqXH: 
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   449
  "t=t' <-> (t=bot & t'=bot)  | (t=true & t'=true)  | (t=false & t'=false) |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   450
                     (EX a a' b b'. t=<a,b> &  t'=<a',b'>  & a=a' & b=b') |  
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   451
                     (EX f f'. t=lam x. f(x) &  t'=lam x. f'(x) & (ALL x. f(x)=f'(x)))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   452
  apply (subgoal_tac "<t,t'> : EQ <-> (t=bot & t'=bot) | (t=true & t'=true) | (t=false & t'=false) | (EX a a' b b'. t=<a,b> & t'=<a',b'> & <a,a'> : EQ & <b,b'> : EQ) | (EX f f'. t=lam x. f (x) & t'=lam x. f' (x) & (ALL x. <f (x) ,f' (x) > : EQ))")
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   453
  apply (erule rev_mp)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   454
  apply (simp add: EQ_iff [THEN iff_sym])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   455
  apply (rule EQgen_mono [THEN EQ_def [THEN def_gfp_Tarski], THEN XHlemma1,
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   456
    unfolded EQgen_def SIM_def])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   457
  apply (rule iff_refl [THEN XHlemma2])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   458
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   459
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   460
lemma eq_coinduct: "[|  <t,u> : R;  R <= EQgen(R) |] ==> t = u"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   461
  apply (rule EQ_def [THEN def_coinduct, THEN EQ_iff [THEN iffD2]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   462
   apply assumption+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   463
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   464
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   465
lemma eq_coinduct3:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   466
  "[|  <t,u> : R;  R <= EQgen(lfp(%x. EQgen(x) Un R Un EQ)) |] ==> t = u"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   467
  apply (rule EQ_def [THEN def_coinduct3, THEN EQ_iff [THEN iffD2]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   468
  apply (rule EQgen_mono | assumption)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   469
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   470
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   471
ML {*
27239
f2f42f9fa09d pervasive RuleInsts;
wenzelm
parents: 27208
diff changeset
   472
  fun eq_coinduct_tac ctxt s i = res_inst_tac ctxt [(("R", 0), s)] @{thm eq_coinduct} i
f2f42f9fa09d pervasive RuleInsts;
wenzelm
parents: 27208
diff changeset
   473
  fun eq_coinduct3_tac ctxt s i = res_inst_tac ctxt [(("R", 0), s)] @{thm eq_coinduct3} i
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   474
*}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   475
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   476
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   477
subsection {* Untyped Case Analysis and Other Facts *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   478
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   479
lemma cond_eta: "(EX f. t=lam x. f(x)) ==> t = lam x.(t ` x)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   480
  by (auto simp: apply_def)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   481
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   482
lemma exhaustion: "(t=bot) | (t=true) | (t=false) | (EX a b. t=<a,b>) | (EX f. t=lam x. f(x))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   483
  apply (cut_tac refl [THEN eqXH [THEN iffD1]])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   484
  apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   485
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   486
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   487
lemma term_case:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   488
  "[| P(bot);  P(true);  P(false);  !!x y. P(<x,y>);  !!b. P(lam x. b(x)) |] ==> P(t)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   489
  using exhaustion [of t] by blast
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   490
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 3837
diff changeset
   491
end