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