Calculus of constructions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

In mathematical logic and computer science, the calculus of constructions is a type theory created by Thierry Coquand. It can serve as both a typed programming language and as constructive foundation for mathematics. For this second reason, the CoC and its variants have been the basis for Rocq and other proof assistants.

Some of its variants include the calculus of inductive constructions (which adds inductive types), the calculus of (co)inductive constructions (which adds coinduction), and the predicative calculus of inductive constructions (which removes some impredicativity)[citation needed].

General traits

[edit | edit source]

The CoC is a higher-order typed lambda calculus, initially developed by Thierry Coquand. It is well known for being at the top of Barendregt's lambda cube. It is possible within CoC to define functions from terms to terms, as well as terms to types, types to types, and types to terms.

The CoC is strongly normalizing, and hence consistent.[1]

Usage

[edit | edit source]

The CoC has been developed alongside the Rocq proof assistant. As features were added (or possible liabilities removed) to the theory, they became available in Rocq.

Variants of the CoC are used in other proof assistants, such as Matita and Lean.

The basics of the calculus of constructions

[edit | edit source]

The calculus of constructions can be considered an extension of the Curry–Howard isomorphism. The Curry–Howard isomorphism associates a term in the simply typed lambda calculus with each natural-deduction proof in intuitionistic propositional logic. The calculus of constructions extends this isomorphism to proofs in the full intuitionistic predicate calculus, which includes proofs of quantified statements (which we will also call "propositions").

Terms

[edit | edit source]

A term in the calculus of constructions is constructed using the following rules:

  • 𝐓 is a term (also called type);
  • 𝐏 is a term (also called prop, the type of all propositions);
  • Variables (x,y,) are terms;
  • If A and B are terms, then so is (AB);
  • If A and B are terms and x is a variable, then the following are also terms:
    • (λx:A.B),
    • (x:A.B).

In other words, the term syntax, in Backus–Naur form, is then:

e::=𝐓𝐏xeeλx:e.ex:e.e

The calculus of constructions has five kinds of objects:

  1. proofs, which are terms whose types are propositions;
  2. propositions, which are also known as small types;
  3. predicates, which are functions that return propositions;
  4. large types, which are the types of predicates (𝐏 is an example of a large type);
  5. 𝐓 itself, which is the type of large types.

β-equivalence

[edit | edit source]

As with the untyped lambda calculus, the calculus of constructions uses a basic notion of equivalence of terms, known as β-equivalence. This captures the meaning of λ-abstraction:

  • (λx:A.B)N=βB(x:=N)

β-equivalence is a congruence relation for the calculus of constructions, in the sense that

  • If A=βB and M=βN, then AM=βBN.

Judgments

[edit | edit source]

The calculus of constructions allows proving typing judgments:

x1:A1,x2:A2,t:B,

which can be read as the implication

If variables x1,x2, have, respectively, types A1,A2,, then term t has type B.

The valid judgments for the calculus of constructions are derivable from a set of inference rules. In the following, we use Γ to mean a sequence of type assignments x1:A1,x2:A2,; A,B,C,D to mean terms; and K,L to mean either 𝐏 or 𝐓. We shall write B[x:=N] to mean the result of substituting the term N for the free variable x in the term B.

An inference rule is written in the form

ΓA:BΓC:D,

which means

if ΓA:B is a valid judgment, then so is ΓC:D.

Inference rules for the calculus of constructions

[edit | edit source]

1. Γ𝐏:𝐓

2. ΓA:KΓ,x:A,Γx:A

3. ΓA:KΓ,x:AB:LΓ(x:A.B):L

4. ΓA:KΓ,x:AN:BΓ(λx:A.N):(x:A.B)

5. ΓM:(x:A.B)ΓN:AΓMN:B[x:=N]

6. ΓM:AA=βBΓB:KΓM:B

Defining logical operators

[edit | edit source]

The calculus of constructions has very few basic operators: the only logical operator for forming propositions is . However, this one operator is sufficient to define all the other logical operators:

ABx:A.B(xB)ABC:𝐏.(ABC)CABC:𝐏.(AC)(BC)C¬AC:𝐏.(AC)x:A.BC:𝐏.(x:A.(BC))C

Defining data types

[edit | edit source]

The basic data types used in computer science can be defined within the calculus of constructions:

Booleans
A:𝐏.AAA
Naturals
A:𝐏.(AA)AA
Product A×B
AB
Disjoint union A+B
AB

Note that Booleans and Naturals are defined in the same way as in Church encoding. However, additional problems arise from propositional extensionality and proof irrelevance.[2]

See also

[edit | edit source]

References

[edit | edit source]
  1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).

Sources

[edit | edit source]
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    • Also available freely accessible online: Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
      Note terminology is rather different. For instance, (x:A.B) is written [x : A] B.
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). — An application of the CoC