src/CCL/ccl.thy
author wenzelm
Mon, 25 Feb 2002 20:46:09 +0100
changeset 12936 84eb6c75cfe3
parent 283 76caebd18756
permissions -rw-r--r--
clarify module dependencies;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	CCL/ccl.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Martin Coen
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Classical Computational Logic for Untyped Lambda Calculus with reduction to 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
weak head-normal form.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
Based on FOL extended with set collection, a primitive higher-order logic.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
HOL is too strong - descriptions prevent a type of programs being defined
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
which contains only executable terms.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
CCL = Gfp +
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
classes prog < term
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
default prog
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
283
76caebd18756 new type declaration syntax instead of numbers
lcp
parents: 0
diff changeset
    20
types i
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
arities 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
      i          :: prog
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
      fun        :: (prog,prog)prog
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
consts
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
  (*** Evaluation Judgement ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
  "--->"      ::       "[i,i]=>prop"          (infixl 20)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
  (*** Bisimulations for pre-order and equality ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
  "[="        ::       "['a,'a]=>o"           (infixl 50)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
  SIM         ::       "[i,i,i set]=>o"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
  POgen,EQgen ::       "i set => i set"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  PO,EQ       ::       "i set"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
  (*** Term Formers ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
  true,false  ::       "i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
  pair        ::       "[i,i]=>i"             ("(1<_,/_>)")
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
  lambda      ::       "(i=>i)=>i"            (binder "lam " 55)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
  case        ::       "[i,i,i,[i,i]=>i,(i=>i)=>i]=>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
  "`"         ::       "[i,i]=>i"             (infixl 56)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
  bot         ::       "i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
  fix         ::       "(i=>i)=>i"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
  (*** Defined Predicates ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
  Trm,Dvg     ::       "i => o"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
rules
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
  (******* EVALUATION SEMANTICS *******)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
  (**  This is the evaluation semantics from which the axioms below were derived.  **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
  (**  It is included here just as an evaluator for FUN and has no influence on    **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
  (**  inference in the theory CCL.                                                **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
  trueV       "true ---> true"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
  falseV      "false ---> false"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
  pairV       "<a,b> ---> <a,b>"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
  lamV        "lam x.b(x) ---> lam x.b(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
  caseVtrue   "[| t ---> true;  d ---> c |] ==> case(t,d,e,f,g) ---> c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
  caseVfalse  "[| t ---> false;  e ---> c |] ==> case(t,d,e,f,g) ---> c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
  caseVpair   "[| t ---> <a,b>;  f(a,b) ---> c |] ==> case(t,d,e,f,g) ---> c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
  caseVlam    "[| t ---> lam x.b(x);  g(b) ---> c |] ==> case(t,d,e,f,g) ---> c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
  (*** Properties of evaluation: note that "t ---> c" impies that c is canonical ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
  canonical  "[| t ---> c; c==true ==> u--->v; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
\                          c==false ==> u--->v; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
\                    !!a b.c==<a,b> ==> u--->v; \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
\                      !!f.c==lam x.f(x) ==> u--->v |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
\             u--->v"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
  (* Should be derivable - but probably a bitch! *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
  substitute "[| a==a'; t(a)--->c(a) |] ==> t(a')--->c(a')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
  (************** LOGIC ***************)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
  (*** Definitions used in the following rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
  apply_def     "f ` t == case(f,bot,bot,%x y.bot,%u.u(t))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
  bot_def         "bot == (lam x.x`x)`(lam x.x`x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
  fix_def      "fix(f) == (lam x.f(x`x))`(lam x.f(x`x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
  (*  The pre-order ([=) is defined as a simulation, and behavioural equivalence (=) *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
  (*  as a bisimulation.  They can both be expressed as (bi)simulations up to        *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
  (*  behavioural equivalence (ie the relations PO and EQ defined below).            *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
  SIM_def
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
  "SIM(t,t',R) ==  (t=true & t'=true) | (t=false & t'=false) | \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
\                  (EX a a' b b'.t=<a,b> & t'=<a',b'> & <a,a'> : R & <b,b'> : R) | \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
\                  (EX f f'.t=lam x.f(x) & t'=lam x.f'(x) & (ALL x.<f(x),f'(x)> : R))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
  POgen_def  "POgen(R) == {p. EX t t'. p=<t,t'> & (t = bot | SIM(t,t',R))}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
  EQgen_def  "EQgen(R) == {p. EX t t'. p=<t,t'> & (t = bot & t' = bot | SIM(t,t',R))}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
  PO_def    "PO == gfp(POgen)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
  EQ_def    "EQ == gfp(EQgen)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
  (*** Rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
  (** Partial Order **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
  po_refl        "a [= a"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
  po_trans       "[| a [= b;  b [= c |] ==> a [= c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
  po_cong        "a [= b ==> f(a) [= f(b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
  (* Extend definition of [= to program fragments of higher type *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
  po_abstractn   "(!!x. f(x) [= g(x)) ==> (%x.f(x)) [= (%x.g(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
  (** Equality - equivalence axioms inherited from FOL.thy   **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
  (**          - congruence of "=" is axiomatised implicitly **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
  eq_iff         "t = t' <-> t [= t' & t' [= t"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
  (** Properties of canonical values given by greatest fixed point definitions **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
  PO_iff         "t [= t' <-> <t,t'> : PO"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
  EQ_iff         "t =  t' <-> <t,t'> : EQ"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
  (** Behaviour of non-canonical terms (ie case) given by the following beta-rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
  caseBtrue            "case(true,d,e,f,g) = d"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
  caseBfalse          "case(false,d,e,f,g) = e"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
  caseBpair           "case(<a,b>,d,e,f,g) = f(a,b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
  caseBlam       "case(lam x.b(x),d,e,f,g) = g(b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
  caseBbot              "case(bot,d,e,f,g) = bot"            (* strictness *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
  (** The theory is non-trivial **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
  distinctness   "~ lam x.b(x) = bot"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
  (*** Definitions of Termination and Divergence ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
  Dvg_def  "Dvg(t) == t = bot"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
  Trm_def  "Trm(t) == ~ Dvg(t)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
end
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
(*
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
Would be interesting to build a similar theory for a typed programming language:
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
    ie.     true :: bool,      fix :: ('a=>'a)=>'a  etc......
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
This is starting to look like LCF.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
What are the advantages of this approach?   
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
        - less axiomatic                                            
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
        - wfd induction / coinduction and fixed point induction available
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
           
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
*)