help;<RETURN>
for information about available commands.
switch tm u;<RETURN>
.
The syntax for untyped terms is as follows:
calculus | interpreter input |
---|---|
x |
|
\x.t |
|
t1 t2 |
Let's look at some examples:
(\x.x) (\x.x) (\x.x)
We can also bind the identity function to the identifier and apply the identifiers several times. This is shown in figure 1.
As you probably noticed there are to binding constructs, namely def
and rdef
.
The first one only binds a term to an identifier whereas the second one performs -reduction
before binding.
def tru = \t.\f.t |
|
def fls = \t.\f.f |
|
def test = \l.\m.\n. l m n |
On the left hand side you can see the conventional definition in the untyped -calculus and on the right hand side there is the corresponding interpreter input. We use these definitions in the following examples:
- def v = \x.x; > def v = <fun> : * - def w = \x.\y.x; > def w = <fun> : * - test tru v w; > def it = v : * - rdef result = test fls v w; > def result = w : *
def Fix = \f.(\x.\y.f (x x) y) (\x.\y.f (x x) y)
If you are not convinced that it works, conduct the following test:
def gauss_sum = Fix (\f.\x.if x<=0 then 0 else x+f(x-1));<RETURN> gauss_sum 6;<RETURN>
You should get def it = 26
.
3+(\x.x)
). Therefore types are introduced. The syntax looks as follows:
calculus | interpreter input |
---|---|
x |
|
\x:T.t |
|
t1 t2 |
|
T->T |
|
Int |
The -abstraction needs a type annotation. Types can be built with ->
. Int
is the
base type for integers. For a full overview about the syntax look at 5.1.
The interpreter is started in simply typed mode at the beginning. You can also change the mode on-the-fly by
typing switch tm s;<RETURN>
.
Let's look at some basic examples:
\f:Int->Int.\x:Int.f x
def T = Int -> Int; def f = \g:T.\x:Int.g x
This concludes the short overview about the base calculi. The following sections describe the usage of Cubint in more detail. All available interpreter commands and syntactic entities are listed. If you need more examples, use the tests library.
Christian Müller 2004-11-09