In mathematical logic, category theory, andcomputer science, kappa calculus is aformal system for defining first-orderfunctions.
Unlike lambda calculus, kappa calculus has nohigher-order functions; its functions arenot first class objects. Kappa-calculus can beregarded as "a reformulation of the first-order fragment of typedlambda calculus".
Because its functions are not first-class objects, evaluation of kappacalculus expressions does not requireclosures.
The definition below has been adapted from the diagrams on pages 205 and 207 of Hasegawa.
Kappa calculus consists of types and expressions, given by thegrammar below:
\tau= 1\mid \tau x \tau\mid \ldots
e= x\mid id\tau\mid !\tau\mid \operatorname{lift}\tau(e)\mid e\circe\mid \kappax:1{\to}\tau.e
In other words,
\tau1
\tau2
\tau1 x \tau2
id\tau
!\tau
\operatorname{lift}\tau(e)
e1
e2
e1\circe2
\kappax{:}1{\to}\tau . e
The
:1{\to}\tau
\operatorname{lift}
Juxtaposition is often used as an abbreviation for a combination of
\operatorname{lift}
e1e2 \overset\operatorname{def}{=} e1\circ\operatorname{lift}(e2)
The presentation here uses sequents (
\Gamma\vdashe:\tau
In kappa calculus an expression has two types: the type of its source and the type of its target. The notation
e:\tau1{\to}\tau2
{\tau1}
{\tau2}
Expressions in kappa calculus are assigned types according to the following rules:
{x{:}1{\to}\tau \in \Gamma}\over{\Gamma\vdashx:1{\to}\tau} | (Var) | ||||
{}\over{\vdashid\tau : \tau\to\tau} | (Id) | ||||
{}\over{\vdash!\tau : \tau\to1} | (Bang) | ||||
{\Gamma\vdashe1{:}\tau1{\to}\tau2 \Gamma\vdashe2{:}\tau2{\to}\tau3 }\over{\Gamma\vdashe2\circe1:\tau1{\to}\tau3} | (Comp) | ||||
{\Gamma\vdashe{:}1{\to}\tau1} \over {\Gamma\vdash
(e) : \tau2\to(\tau1 x \tau2)} | (Lift) | ||||
{\Gamma, x{:}1{\to}\tau1 \vdash e:\tau2{\to}\tau3} \over {\Gamma\vdash\kappax{:}1{\to}\tau1.e : \tau1 x \tau2\to\tau3} | (Kappa) |
In other words,
x:1{\to}\tau
x:1{\to}\tau
id\tau:\tau{\to}\tau
!\tau:\tau{\to}1
e1
e2
e2\circe1
e1
e2
e:1{\to}\tau1
\operatorname{lift} | |
\tau2 |
(e):\tau2{\to}(\tau1 x \tau2)
e:\tau2\to\tau3
x:1{\to}\tau1
\kappax{:}1{\to}\tau1.e : \tau1 x \tau2\to\tau3
Kappa calculus obeys the following equalities:
f:\tau1{\to}\tau2
f{\circ}id | |
\tau1 |
=f
f=id | |
\tau2 |
{\circ}f
f:\tau1{\to}\tau2
g:\tau2{\to}\tau3
h:\tau3{\to}\tau4
(h{\circ}g){\circ}f=h{\circ}(g{\circ}f)
f{:}\tau{\to}1
g{:}\tau{\to}1
f=g
(\kappax.f)\circ\operatorname{lift}\tau(c)=f[c/x]
\kappax.(h\circ\operatorname{lift}\tau(x))=h
The last two equalities are reduction rules for the calculus,rewriting from left to right.
The type can be regarded as the unit type. Because of this, any two functions whose argument type is the same and whose result type is should be equal – since there is only a single value of type both functions must return that value for every argument (Terminality).
Expressions with type
1{\to}\tau
1{\to}\tau
Kappa calculus is intended to be the internal language ofcontextually complete categories.
Expressions with multiple arguments have source types which are"right-imbalanced" binary trees. For example, a function f with threearguments of types A, B, and C and result type D will have type
f:A x (B x (C x 1))\toD
If we define left-associative juxtaposition
f c
(f\circ\operatorname{lift}(c))
a:1{\to}A
b:1{\to}B
c:1{\to}C
f a b c : 1\toD
Since the expression
f a b c
g:(D x E){\to}F
g (f a b c) : E\toF
Much like a curried function of type
A{\to}(B{\to}(C{\to}D))
f a : B x (C x 1)\toD
However no higher types (i.e.
(\tau{\to}\tau){\to}\tau
h (f a)
Because successive application is used for multiplearguments it is not necessary to know the arity of a function inorder to determine its typing; for example, if we know that
c:1{\to}C
is well-typed as long as has type
(C x \alpha){\to}\beta
Barendregt originally introduced the term"functional completeness" in the context of combinatory algebra.Kappa calculus arose out of efforts by Lambek to formulate an appropriate analogue of functionalcompleteness for arbitrary categories (see Hermida and Jacobs, section 1). Hasegawa later developed kappacalculus into a usable (though simple) programming language includingarithmetic over natural numbers and primitive recursion. Connections to arrowswere later investigated by Power, Thielecke, and others.
It is possible to explore versions of kappa calculus withsubstructural types such as linear, affine,and ordered types. These extensions require eliminating orrestricting the
!\tau