Kappa Calculus
   HOME

TheInfoList



OR:

In
mathematical logic Mathematical logic is the study of formal logic within mathematics. Major subareas include model theory, proof theory, set theory, and recursion theory. Research in mathematical logic commonly addresses the mathematical properties of formal ...
, category theory, and
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includi ...
, kappa calculus is a
formal system A formal system is an abstract structure used for inferring theorems from axioms according to a set of rules. These rules, which are used for carrying out the inference of theorems from axioms, are the logical calculus of the formal system. A form ...
for defining
first-order In mathematics and other formal sciences, first-order or first order most often means either: * "linear" (a polynomial of degree at most one), as in first-order approximation and other calculus uses, where it is contrasted with "polynomials of high ...
functions. Unlike lambda calculus, kappa calculus has no higher-order functions; its functions are not first class objects. Kappa-calculus can be regarded as "a reformulation of the first-order fragment of typed lambda calculus". Because its functions are not first-class objects, evaluation of kappa calculus expressions does not require closures.


Definition

''The definition below has been adapted from the diagrams on pages 205 and 207 of Hasegawa.''


Grammar

Kappa calculus consists of ''types'' and ''expressions,'' given by the grammar below: : \tau = 1 \mid \tau\times\tau \mid \ldots : e = x \mid id_\tau \mid !_\tau \mid \operatorname_\tau(e) \mid e \circ e \mid \kappa x:1\tau . e In other words, * 1 is a type * If \tau_1 and \tau_2 are types then \tau_1\times\tau_2 is a type. * Every variable is an expression * If is a type then id_\tau is an expression * If is a type then !_\tau is an expression * If is a type and e is an expression then \operatorname_\tau(e) is an expression * If e_1 and e_2 are expressions then e_1\circ e_2 is an expression * If x is a variable, is a type, and e is an expression, then \kappa x1\tau\;.\;e is an expression The :1\tau and the subscripts of , , and \operatorname are sometimes omitted when they can be unambiguously determined from the context. Juxtaposition is often used as an abbreviation for a combination of \operatorname and composition: : e_1 e_2\ \overset\operatorname\ e_1 \circ \operatorname(e_2)


Typing rules

''The presentation here uses sequents (\Gamma\vdash e:\tau) rather than hypothetical judgments in order to ease comparison with the simply typed lambda calculus. This requires the additional Var rule, which does not appear in Hasegawa'' In kappa calculus an expression has two types: the type of its ''source'' and the type of its ''target''. The notation e:\tau_1\tau_2 is used to indicate that expression e has source type and target type . Expressions in kappa calculus are assigned types according to the following rules: : In other words, * Var: assuming x:1\tau lets you conclude that x:1\tau * Id: for any type , id_\tau:\tau\tau * Bang: for any type , !_\tau:\tau1 * Comp: if the target type of e_1 matches the source type of e_2 they may be composed to form an expression e_2\circ e_1 with the source type of e_1 and target type of e_2 * Lift: if e:1\tau_1, then \operatorname_(e):\tau_2(\tau_1\times\tau_2) * Kappa: if we can conclude that e:\tau_2\to\tau_3 under the assumption that x:1\tau_1, then we may conclude ''without that assumption'' that \kappa x1\tau_1\,.\,e\;:\;\tau_1\times\tau_2\to\tau_3


Equalities

Kappa calculus obeys the following equalities: * Neutrality: If f:\tau_1\tau_2 then fid_=f and f=id_f * Associativity: If f:\tau_1\tau_2, g:\tau_2\tau_3, and h:\tau_3\tau_4, then (hg)f = h(gf). * Terminality: If f\tau1 and g\tau1 then f=g * Lift-Reduction: (\kappa x.f)\circ \operatorname_\tau(c) = f /x/math> * Kappa-Reduction: \kappa x. (h\circ \operatorname_\tau(x)) = h if x is not free in h The last two equalities are reduction rules for the calculus, rewriting from left to right.


Properties

The type can be regarded as the
unit type In the area of mathematical logic and computer science known as type theory, a unit type is a type that allows only one value (and thus can hold no information). The carrier (underlying set) associated with a unit type can be any singleton set. ...
. 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\tau can be regarded as "constants" or values of "ground type"; this is because is the unit type, and so a function from this type is necessarily a constant function. Note that the kappa rule allows abstractions only when the variable being abstracted has the type 1\tau for some . This is the basic mechanism which ensures that all functions are first-order.


Categorical semantics

Kappa calculus is intended to be the internal language of ''contextually complete'' categories.


Examples

Expressions with multiple arguments have source types which are "right-imbalanced" binary trees. For example, a function f with three arguments of types A, B, and C and result type D will have type : f : A\times (B\times (C\times 1)) \to D If we define left-associative juxtaposition f\;c as an abbreviation for (f\circ \operatorname(c)), then – assuming that a:1A, b:1B, and c:1C – we can apply this function: : f\;a\;b\;c\;:\;1 \to D Since the expression f\;a\;b\;c has source type , it is a "ground value" and may be passed as an argument to another function. If g:(D\times E)F, then : g\;(f\;a\;b\;c)\;:\;E \to F Much like a curried function of type A(B(CD)) in lambda calculus, partial application is possible: : f\;a\;:\;B\times (C\times 1) \to D However no higher types (i.e. (\tau\tau)\tau) are involved. Note that because the source type of is not , the following expression cannot be well-typed under the assumptions mentioned so far: : h\;(f\;a) Because successive application is used for multiple arguments it is not necessary to know the arity of a function in order to determine its typing; for example, if we know that c:1C then the expression : is well-typed as long as has type : (C\times\alpha)\beta for some and . This property is important when calculating the principal type of an expression, something which can be difficult when attempting to exclude higher-order functions from typed lambda calculi by restricting the grammar of types.


History

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 functional completeness for arbitrary categories (see Hermida and Jacobs, section 1). Hasegawa later developed kappa calculus into a usable (though simple) programming language including arithmetic over natural numbers and primitive recursion. Connections to arrows were later investigated by Power, Thielecke, and others.


Variants

It is possible to explore versions of kappa calculus with substructural types such as
linear Linearity is the property of a mathematical relationship ('' function'') that can be graphically represented as a straight line. Linearity is closely related to '' proportionality''. Examples in physics include rectilinear motion, the linear ...
,
affine Affine may describe any of various topics concerned with connections or affinities. It may refer to: * Affine, a relative by marriage in law and anthropology * Affine cipher, a special case of the more general substitution cipher * Affine comb ...
, and ordered types. These extensions require eliminating or restricting the !_\tau expression. In such circumstances the type operator is not a true cartesian product, and is generally written to make this clear.


References

* * {{cite book , author1-last = Power , author1-first = John , author2-last = Thielecke , author2-first = Hayo , year = 1999 , editor1-last = Wiedermann , editor1-first = Jiří , editor2-last = van Emde Boas , editor2-first = Peter , editor2-link = Peter van Emde Boas , editor3-last = Nielsen , editor3-first = Mogens , title = Closed Freyd- and {{mvar, κ-Categories , journal = Automata, Languages and Programming: 26th International Colloquium, ICALP'99 Prague, Czech Republic, July 11–15, 1999 Proceedings , series = Lecture Notes in Computer Science , publisher = Springer-Verlag Berlin Heidelberg , volume = 1644 , pages = 625–634 , doi = 10.1007/3-540-48523-6_59 , isbn = 978-3-540-66224-2 , issn = 0302-9743, citeseerx = 10.1.1.42.2151 Logical calculi