src/HOL/Lambda/Lambda.thy
author clasohm
Fri, 01 Dec 1995 12:03:13 +0100
changeset 1376 92f83b9d17e1
parent 1269 ee011b365770
child 1789 aade046ec6d5
permissions -rw-r--r--
removed quotes from consts and syntax sections
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1269
ee011b365770 New version with eta reduction.
nipkow
parents: 1153
diff changeset
     1
(*  Title:      HOL/Lambda/Lambda.thy
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     4
    Copyright   1995 TU Muenchen
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     5
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     6
Lambda-terms in de Bruijn notation,
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     7
substitution and beta-reduction.
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     8
*)
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     9
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    10
Lambda = Arith +
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    11
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    12
datatype db = Var nat | "@" db db (infixl 200) | Fun db
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    13
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    14
consts
1376
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1269
diff changeset
    15
  subst  :: [db,db,nat]=>db ("_[_'/_]" [300,0,0] 300)
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1269
diff changeset
    16
  lift   :: [db,nat] => db
1153
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    17
  (* optimized versions *)
1376
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1269
diff changeset
    18
  substn :: [db,db,nat] => db
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1269
diff changeset
    19
  liftn  :: [nat,db,nat] => db
1153
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    20
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    21
primrec lift db
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    22
  lift_Var "lift (Var i) k = (if i < k then Var i else Var(Suc i))"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    23
  lift_App "lift (s @ t) k = (lift s k) @ (lift t k)"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    24
  lift_Fun "lift (Fun s) k = Fun(lift s (Suc k))"
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    25
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    26
primrec subst db
1153
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    27
  subst_Var "(Var i)[s/k] = (if k < i then Var(pred i)
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    28
                            else if i = k then s else Var i)"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    29
  subst_App "(t @ u)[s/k] = t[s/k] @ u[s/k]"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    30
  subst_Fun "(Fun t)[s/k] = Fun (t[lift s 0 / Suc k])"
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    31
1153
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    32
primrec liftn db
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    33
  liftn_Var "liftn n (Var i) k = (if i < k then Var i else Var(i+n))"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    34
  liftn_App "liftn n (s @ t) k = (liftn n s k) @ (liftn n t k)"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    35
  liftn_Fun "liftn n (Fun s) k = Fun(liftn n s (Suc k))"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    36
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    37
primrec substn db
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    38
  substn_Var "substn (Var i) s k = (if k < i then Var(pred i)
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    39
                                    else if i = k then liftn k s 0 else Var i)"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    40
  substn_App "substn (t @ u) s k = (substn t s k) @ (substn u s k)"
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    41
  substn_Fun "substn (Fun t) s k = Fun (substn t s (Suc k))"
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    42
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    43
consts  beta :: "(db * db) set"
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    44
1376
92f83b9d17e1 removed quotes from consts and syntax sections
clasohm
parents: 1269
diff changeset
    45
syntax  "->", "->>" :: [db,db] => bool (infixl 50)
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    46
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    47
translations
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    48
  "s -> t"  == "(s,t) : beta"
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    49
  "s ->> t" == "(s,t) : beta^*"
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    50
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    51
inductive "beta"
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    52
intrs
1124
a6233ea105a4 Polished the presentation making it completely definitional.
nipkow
parents: 1120
diff changeset
    53
   beta  "(Fun s) @ t -> s[t/0]"
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    54
   appL  "s -> t ==> s@u -> t@u"
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    55
   appR  "s -> t ==> u@s -> u@t"
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    56
   abs   "s -> t ==> Fun s -> Fun t"
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    57
end