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