You get a bonus - 1 coin for daily activity. Now you have 1 coin

Type Theory, Basic Computational Formalisms, and Semantic Styles

Lecture



In mathematics, logic, and computer science, type theory refers to any formal system that serves as an alternative to naive set theory, accompanied by a classification of the elements of such a system by means of types forming a certain hierarchy. The term type theory is also used to refer to the study of such formalisms.

Type theory — a mathematically formalized foundation for designing, analyzing, and studying data type systems in the theory of programming languages (a branch of computer science). Many programmers use this term to refer to any analytical work that studies type systems in programming languages. In academic circles, type theory most often refers to a narrower branch of discrete mathematics, in particular the typed λ-calculus.

Modern type theory was developed in part while resolving Russell's paradox, and it is largely based on the work of Bertrand Russell and Alfred Whitehead, «Principia Mathematica» .

Type Theory, Basic Computational Formalisms, and Semantic Styles

trinitarianism 1 (fig. 3), so that logical concepts,
homotopical concepts and algebraic structures are connected to one another

Figure 1 Homotopy trinitarianism as a connection between logical concepts, homotopical concepts and algebraic structures

History of the emergence of type theory

  • 1901 — Russell's paradox

  • 1908 — the first theory of types (Russell, Whitehead)

  • 1900-1930 Set theory and vicious circles. The problem of impredicativity.

  • 1925 — Ramsey's simple theory of types, systems of “simple types” (simply typed lambda calculus)

  • 1930-1950 The Curry-Howard correspondence

  • 1940 — the simply typed λ-calculus

  • 1950-1970 Dependent types. De Bruijn's Automath.

  • 1973 — constructive type theory (Martin-Löf)

  • 1980s Calculus of constructions. Numerous works on type theory
  • 1990s Lambda cube (pure type systems)

Type Theory, Basic Computational Formalisms, and Semantic Styles

The doctrine of types

The doctrine of types goes back to B. Russell, according to whom every type is regarded as the range of significance of a propositional function. It is also held that every function has a type (its domain, its region of definition). The doctrine of types observes the principle of substituting a type (proposition) with a definitionally equivalent type (proposition).

Type theory in logic

This theory is based on the principle of hierarchy. This means that logical concepts — propositions, individuals, propositional functions — are arranged into a hierarchy of types. It is essential that an arbitrary function takes as its arguments only those concepts that precede it in the hierarchy.

A certain type theory

By a certain type theory one usually means a higher-order applied logic in which there is a type N of natural numbers, and in which the axioms of Peano arithmetic hold

Ramified theory of types

Historically the first type theory to be proposed (during the period from 1902 to 1913) is the Ramified Theory of Types (RTT), constructed by Whitehead and Russell, and finally formulated in the foundational work «Principia Mathematica». This theory is based on the principle of limiting the number of cases in which objects belong to a single type. Eight such cases are explicitly declared, and two hierarchies of types are distinguished: (simple) «types» and «orders». At the same time, the notation for «type» itself is not defined, and there are a number of other imprecisions, since the main intention was to declare unequal the types of functions of different numbers of arguments or of arguments of different types . An integral part of the theory is the axiom of reducibility.

Simple type theory

In the 1920s, Chwistek and Ramsey proposed an unramified theory of types, now known as the «Theory of Simple Types» or Simple Type Theory (Simple Type Theory), which collapses the hierarchy of types, eliminating the need for the axiom of reducibility.

Simple type theory resolved the set-theoretic paradoxes, but the second group of semantic paradoxes, the Grelling-Nelson paradoxes
and so on, remained unresolved, and it was for these that Russell and Whitehead developed the ramified theory of types within the Principia Mathematica system.

Intuitionistic type theory

Intuitionistic type theory (Intuitionistic Type Theory, ITT) was constructed by Per Martin-Löf.

Intuitionistic type theory (also known as constructive type theory or Martin-Löf type theory) is a type theory and an alternative foundation for mathematics. Intuitionistic type theory was created by Per Martin-Löf, a Swedish mathematician and philosopher, who first published it in 1972. There are several versions of the theory of types: Martin-Löf proposed both intensional and extensional variants of the theory, and the early impredicative versions, whose inconsistency was proved by Girard's paradox, gave way to a predicative version. However, all versions preserve the basic construction of constructive logic using dependent types.

Martin-Löf developed the theory of types on the principles of mathematical constructivism. Constructivism requires that any existence proof contain a «witness». Thus, any proof that «there exists a prime number greater than 1000» must identify a specific number that is both prime and greater than 1000. Intuitionistic type theory achieved this design goal by adopting the BHK interpretation. An interesting consequence is that proofs become mathematical objects that can be examined, compared, and manipulated.

The type constructors in intuitionistic type theory were built so as to follow a one-to-one correspondence with logical connectives. For example, the logical connective called implication ( Type Theory, Basic Computational Formalisms, and Semantic Styles) corresponds to the function type ( Type Theory, Basic Computational Formalisms, and Semantic Styles). This correspondence is called the Curry–Howard isomorphism. Earlier theories of types also followed this isomorphism, but Martin-Löf was the first to extend it to predicate logic by introducing dependent types.

Intuitionistic logic. There is no law of the excluded middle. Any proof must be presented in general form

Type theory

In intuitionistic type theory there are 3 finite types, which are then composed using 5 different type constructors. Unlike set theories, type theories are not built on a Frege-like logic. So, every feature of type theory performs a dual function, as a property of both mathematics and logic.

If you are not familiar with type theory but are familiar with set theory, here is a brief summary: Types contain terms in the same way that sets contain elements. Terms belong to one and only one type. Terms such as Type Theory, Basic Computational Formalisms, and Semantic Styles as well as Type Theory, Basic Computational Formalisms, and Semantic Stylescompute ("reduce") to canonical terms, for example 4. See the article on type theory for more details.

Type 0, type 1, and type 2

There are 3 finite types: Type 0 contains 0 terms. Type 1 contains 1 canonical term. And type 2 contains 2 canonical terms.

Since type 0 contains 0 terms, it is also called the empty type. It is used to denote anything that cannot exist. It is also written as Type Theory, Basic Computational Formalisms, and Semantic Stylesand represents something unprovable. (That is, a proof of it cannot exist.) As a result, negation is defined as a function with respect to it: Type Theory, Basic Computational Formalisms, and Semantic Styles.

Similarly, type 1 contains 1 canonical term and represents existence. It is also called the unit type. It often represents statements that can be proven, and so it is sometimes written as Type Theory, Basic Computational Formalisms, and Semantic Styles.

Finally, type 2 contains 2 canonical terms. It represents a definite choice between two values. It is used for boolean values, but not for propositions. Propositions are considered to be of type 1, and it can be proven that they will never have a proof (type 0), or they may fail to be proven in any case. (The law of excluded middle does not apply to propositions in intuitionistic type theory.)

Pure type systems

The theory of pure type systems (PTS) generalizes all the calculi of the lambda cube and formulates rules that allow them to be computed as special cases. It was independently constructed by Berardi and Terlouw. Pure type systems operate only with the concept of type, treating all the concepts of other calculi solely as types — which is why they are called «pure». No distinction is made between terms and types, between different layers (i.e. the kinds of types are also called types, only belonging to a different universe), and even the layers themselves are not called sorts but types (more precisely, universes of types). In general form, a pure type system is given by the notion of a specification, five rigid rules, and two flexible ones (which vary from system to system). The specification of a pure type system is a triple (S,A,R), where S — the set of sorts (Sorts), A — the set of axioms (Axioms) over these sorts, and R — the set of rules (Rules).

Multidimensional type theories

Higher-dimensional type theories or simply higher type theories (HTT) generalize traditional type theories by allowing nontrivial equality relations to be established between types. For example, if we take the set of pairs (Cartesian products) of natural numbers nat × nat and the set of functions returning a natural number nat -> nat, we cannot claim that the elements of these sets are pairwise equal, but we can claim that these sets are equivalent. Isomorphisms between types are studied in two-dimensional, three-dimensional, and so on type theories. The whole necessary basis for formulating these theories was laid by Girard — Reynolds, but the theories themselves were formulated much later.

Homotopy type theory

Homotopy type theory (HoTT) generalizes multidimensional theories by establishing type equalities at the level of topologies. In multidimensional theories, the notions of «type equivalence» and «type equality» are considered distinct. A radical innovation of homotopy type theory is the univalence axiom, which postulates that if types are topologically equivalent, then they are topologically equal.


Basic computational formalisms and semantic styles

  • λ-calculus (functions)
  • ζ-calculus (objects)
  • π-calculus (processes)
  • Operational semantics

1) λ-calculus

Lambda calculus (λ-calculus) — a formal system developed by American mathematician Alonzo Church to formalize and analyze the notion of computability.

Pure λ-calculus, whose terms, also called objects («obs»), or λ-terms, are built exclusively from variables by applying application and abstraction. Initially, no constants are assumed to exist.

Lambda calculus – the simplest and most elegant algorithmically complete programming language.

  • What is the meaning of a program?
  • What does it mean for two programs to be equal/equivalent?
  • A set of (technically) complex theories (Scott domains, Böhm trees, etc.)
  • How can these theories be implemented (programmed)?

Simply typed lambda calculus. Algorithmically incomplete. Any term (including one with free variables) has a normal (canonical, “computed”) form.

Syntax of the λ-calculus

t ::= terms:
x variable
λx. t abstraction
t t application

Examples

(λx.x) z

(λx.x) ((λx.x) (λz. (λx.x) z))

Computation (β-reduction)

(λx.x) ((λx.x) (λz. (λx.x) z))

id (id (λz. id z))

→ id (id (λz.z))

→ id (λz.z)

→ λz.z

Type Theory, Basic Computational Formalisms, and Semantic Styles

Encoding in terms of λ-calculus

  • Functions with multiple arguments (currying)
  • Boolean constants
  • Pairs
  • Church numerals
  • Recursion using a fixed-point combinator

α-equivalence

The primary form of equivalence defined on lambda terms is alpha-equivalence. For example, Type Theory, Basic Computational Formalisms, and Semantic Styles and Type Theory, Basic Computational Formalisms, and Semantic Styles: are alpha-equivalent lambda terms, and both represent the same function (the identity function). The terms Type Theory, Basic Computational Formalisms, and Semantic Styles and Type Theory, Basic Computational Formalisms, and Semantic Styles are not alpha-equivalent, since they are not within a lambda abstraction.

β-reduction

Since the expression Type Theory, Basic Computational Formalisms, and Semantic Styles denotes a function that maps each Type Theory, Basic Computational Formalisms, and Semantic Styles to the value Type Theory, Basic Computational Formalisms, and Semantic Styles, to compute the expression

Type Theory, Basic Computational Formalisms, and Semantic Styles,

which contains both application and abstraction, it is necessary to substitute the number 3 into the term Type Theory, Basic Computational Formalisms, and Semantic Styles in place of the variable Type Theory, Basic Computational Formalisms, and Semantic Styles. This yields Type Theory, Basic Computational Formalisms, and Semantic Styles. In general form, this reasoning is written as

Type Theory, Basic Computational Formalisms, and Semantic Styles

and is called β-reduction. An expression of the form Type Theory, Basic Computational Formalisms, and Semantic Styles, that is, the application of an abstraction to some term, is called a redex. Although β-reduction is essentially the only «essential» axiom of λ-calculus, it leads to a very rich and complex theory. Together with it, λ-calculus is Turing complete and, therefore, constitutes the simplest programming language.

η-conversion

Type Theory, Basic Computational Formalisms, and Semantic Styles-conversion expresses the idea that two functions are identical if and only if, when applied to any argument, they give the same results. Type Theory, Basic Computational Formalisms, and Semantic Styles-conversion converts the formulas Type Theory, Basic Computational Formalisms, and Semantic Styles and Type Theory, Basic Computational Formalisms, and Semantic Styles into one another (only if Type Theory, Basic Computational Formalisms, and Semantic Styles has no free occurrences in {\displaystyle f}Type Theory, Basic Computational Formalisms, and Semantic Styles: otherwise, the free variable Type Theory, Basic Computational Formalisms, and Semantic Styles would become bound by the outer abstraction after conversion, or vice versa).

2) ζ-calculus (objects) Abadi and Cardelli's object calculus

Syntax of the ζ-calculus

b ::= terms:
x variable
[li = ζ(xi)bi] objects
b.l method invocation
b1.l⇐ ζ(x)b2 method update
clone(b) cloning
let x=b1 in b2 local declaration

3) π-calculus (Pi-calculus) (processes)

Type Theory, Basic Computational Formalisms, and Semantic Styles-calculus in theoretical computer science — a process calculus, originally developed by Robin Milner, Joachim Parrow and David Walker as a continuation of work on the calculus of communicating systems. The goal of the Type Theory, Basic Computational Formalisms, and Semantic Styles-calculus is to be able to describe concurrent computations, whose configuration can change over the course of the computation.

Type Theory, Basic Computational Formalisms, and Semantic Styles-calculus belongs to the family of process calculi. In fact, the {\displaystyle \pi }Type Theory, Basic Computational Formalisms, and Semantic Styles-calculus, like λ-calculus, is so minimal that it contains no primitives such as numbers, boolean expressions, data structures, variables, functions or control flow operators (for example, if-then-else, while).

Components of the π-calculus

  • Channel
  • Process
  • Sending a message
  • Receiving a message

Syntax of the π-calculus

P, Q, R ::= terms:
0 idle process
x(y).P receiving y from channel x and executing P
xy.P sending y on channel x and executing P
P|Q parallel execution
(νx)P channel creation
!P replication

4) Operational semantics

Operational semantics describes a sequential process of state changes — an abstract machine.


Subtyping

  • Subtyping relation (type, type)
  • Width subtyping
  • Depth subtyping
  • Behavior of extensions of typed λ-calculus when
  • inheritance is introduced
  • Multiplicity of term types

Polymorphism

Polymorphism — is the use of a single piece of program code with different types in different contexts.
Kinds of polymorphism

  • Universal polymorphism
    • parametric (templates)
    • subtype polymorphism
  • «Ad-hoc» (overloading)
  • Universal types (universality)
  • Existential types (information hiding)
  • Bounded quantification

Higher-order type systems

  • Type operators and «types of types»
  • Higher-order polymorphism
  • Higher-order subtyping

Ideas for type systems

  • Linear types (references without aliases)
  • Process types (deadlock control)
  • Generic programming (types at runtime)
  • Types in low-level languages

Difference from set theory

There are many different set theories and many different type theory systems, so everything that follows is a generalization.

  • Set theory is built on logic. This requires a separate system, such as predicate logic. In type theory, notions such as «and» and «or» can be encoded as types within the type theory itself.
  • In set theory, an element is not restricted to a single set. In type theory, terms (generally) belong to only one type. (Where a subset would be used, type theory tends to use a predicate function that returns true if the term is in the subset, and returns false if it is not. The union of two types can be defined as a new type, called a sum type, which contains the new terms.)
  • Set theory usually encodes numbers as sets. (0 is the empty set, 1 is the set containing the empty set, and so on. See the set-theoretic definition of the natural numbers.) Type theory can encode numbers as functions using Church encoding, or, more naturally, as inductive types. Inductive types create new constants for the successor function and zero, which closely resembles the Peano axioms.
  • Type theory has a simple relation to constructive mathematics via the BHK interpretation. This can be related to logic through the Curry–Howard isomorphism. And some type theories are closely related to category theory.

Relation to category theory

Although the original motivation for category theory was far from foundationalism, it turned out that the two fields have a deep connection. As John Lane Bell writes: «In fact, categories themselves can be regarded as type theories of a certain kind; this fact alone indicates that type theory is much more closely related to category theory than to set theory». In short, a category can be viewed as a type theory by treating its objects as types (or sorts), i.e. «roughly speaking, a category can be regarded as a type theory stripped of its syntax». Thus, a number of important results follow:

  • cartesian closed categories correspond to typed λ-calculus (Lambek, 1970);
  • C-monoids (categories with products, exponentials, and one nonterminal object) correspond to untyped λ-calculus (independently observed by Lambek and Dana Scott around 1980);
  • locally cartesian closed categories correspond to Martin-Löf type theories (Seely, 1984).

This interaction, known as categorical logic, has since become the subject of active research; see, for example, the monograph by Jacobs (1999).

See also

  • Type system
  • Type safety
  • Logicism
  • Many-sorted logic
  • Data type for specific data types in programming
  • Domain theory
  • Type (model theory)
  • Type system for a more practical discussion of type systems for programming languages
  • Universal foundations
  • Applicative computing systems
  • Typed λ-calculus
  • Combinatory logic
  • Functional programming
  • Anonymous function
  • Algebraic data type, data constructor, type constructor
  • Recursive data type
  • Subtype
  • Function type
  • Type polymorphism and type variable
  • Type class
  • Type theory
  • Kind (type theory)
  • Abstract data type
  • data structures [[b4380]]
  • [[b4403]]
  • [[b9803]]
  • [[b3764]]
  • [[b9144]]
  • [[b5775]]
  • [[b5301]]
  • variable

See also

created: 2020-12-04
updated: 2026-03-09
323



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Structures and data processing algorithms."

Terms: Structures and data processing algorithms.