natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism = propositions as types +programs as proofs +relation type theory/category theory
basic constructions:
strong axioms
A logical framework is a formal metalanguage for deductive systems, such as logic, natural deduction, type theories, sequent calculus, etc. Of course, like any formal system, these systems can be described in any sufficiently stong metalanguage. However, all logical systems of this type share certain distinguishing features, so it is helpful to have a particular metalanguage which is well-adapted to describing systems with those features.
Much of the description below is taken from (Harper).
The sentences of a logical framework are called judgments. It turns out that in deductive systems, there are two kinds of non-basic forms that arise very commonly, which we may call
These two forms turn out to have many parallel features, e.g. reflexivity and transitivity of hypothetical judgments correspond to variable-use and substitution in generic judgments. Appealing to the propositions as types principle, therefore, it is convenient to describe a system in which they are actually both instances of the same thing. That is, we identify the notion of evidence for a judgment with the notion of object of a syntactic category.
This leads to a notion that we will call an LF-type. Thus we will have types such as
We will also have some general type-forming operations. Perhaps surprisingly, it turns out that
are all that we need.
There is a potential confusion of terminology, because these LF-types in a logical framework (being itself a type theory) are distinct from the objects that may be called “types” in any particular logic we might be talking about inside the logical framework. Thus, for instance, when formalizing Martin-Lof type theory in a logical framework, there is an “LF-type” which is the type of objects of the syntactic category of MLTT-types. This is furthermore distinct from a type of types, which is itself an object of the syntactic category of MLTT-types, i.e. a term belonging to the LF-type of such.
Once we have set up the logical framework as a language, there are then two ways to describe a given logic inside of it. See (Harper), and the other references, for more details.
In a synthetic presentation, there is an LF-type for every judgment of the object theory. Thus, if the object theory is a type theory, then in LF we have things like:
Note that we do not have to explicitly carry around an ambient context, as we sometimes do when presenting type theories in a more explicit style of a deductive system. This is because the notions of hypothetical and generic judgments are built into the logical framework and handled automatically by its contexts.
Synthetic presentations are very flexible, but do not make maximal use of the framework in the case when the object-theory is also a type theory whose judgments are “analytic”.
An analytic presentation is only possible for certain kinds of object-theories, generally those which are type theories similar to LF itself. In this case, we represent object-theory types by LF-types themselves. Thus instead of the LF-type $tm$ of terms and the dependent LF-type $of$ above, we have
which assigns to each object-theory type, the LF-type of its elements.
In an analytic presentation of a logic, in addition to merely giving “axioms” such as $tp$ and $el$, we must give equations representing the rules of the object-theory as equalities in the logical framework. For instance, we must have a beta-reduction rule such as
app A B (lam A B F) M = F M
From a practical point-of-view, rather than extending the logical framework with ad hoc definitional equalities to represent a particular object-theory, often what is actually done is that equality is defined as another type family with explicitly-introduced constructors. For example, in Twelf, the above equation could be represented by first introducing the type family
eq : {A:tp} el A -> el A -> type
(Twelf uses braces as notation for the dependent product), and then postulating a constant
beta : {A:tp} {B:tp} eq (app A B (lam A B F)) (F M)
in addition to the other axioms of equality.
In both synthetic and analytic presentations, we use higher-order abstract syntax? (HOAS). Roughly, this means that variables in the object-theory are not terms of some LF-type, but are represented by actual LF-variables. For instance, when describing a type theory containing function types synthetically, we would have
The point is that the argument of $lam$ (the “body” of the lambda abstraction) is not a “term containing a free variable $x$” but rather an LF-function from object-theory terms to object-theory terms. This is intended to be the function “substitute” which knows about the body of the lambda-abstraction, and when given an argument it substitutes it for the variable in that body and returns the result.
This approach completely avoids dealing with the problems of variable binding and substitution in the object language, by making use of the binding and substitution in the metalanguage LF. One might say that the variables in LF are the “universal notion of variable” which is merely reused by all object-theories.
It may be tempting to think of the LF-types such as $tp$ and $tm$ as inductively defined by their specified constructors (such as $arr$ for $tp$, and $app$ and $lam$ for $tm$). However, this is incorrect; LF does not have inductive types. In fact, this weakness is essential in order to guarantee “adequacy” of the HOAS encoding.
Suppose, for instance, that $tm$ were inductively defined inside of LF. Then we could define a function $tm\to tm$ by pattern-matching on the structure of $tm$, doing one thing if $tm$ were a lambda-abstraction and another thing if it were a function application. But such a function is definitely not the sort of thing that we want to be able to pass to the LF-function $lam$! By disallowing such matching, though, we can guarantee that the only functions $tm\to tm$ we can define and pass to $lam$ correspond to “substituting in a fixed term” as we intended.
As an even simpler example, suppose we consider an object-theory containing just one LF-type $nat$ together with constructors $z : nat$ and $s : nat \to nat$. Although we would like to think of $nat$ as representing the natural numbers, because of the lack of an induction principle, the LF-type $nat \to nat$ certainly cannot be shown to contain all the functions from natural numbers to natural numbers (essentially, we can only construct the constant functions and those incrementing their argument by a fixed constant). On the other hand, to some extent it is possible to get around this restriction by taking a relational rather than a functional point-of-view. For example, addition of natural numbers can be defined as a type family
add : nat -> nat -> nat -> type
together with a pair of constructors
add/z : {N:nat} add z N N.
add/s : {M:nat}{N:nat}{P:nat} add M N P -> add (s M) N (s P).
Now, it is still not possible to prove inside LF that $add$ is a total functional relation (i.e., that for all M:nat
and N:nat
there exists a unique P:nat
such that add M N P
). However, in this case that is certainly easy to verify by inspection, and the Twelf proof assistant has facilities for verifying such properties automatically (though in general checking totality is better supported than checking uniqueness).
One of the uses of a logical framework is that as a type theory itself, it can be implemented in a computer. This provides a convenient system in which one can “program” the rules of any other specific type theory or logic which one wants to study.
For a list of logical framework implementations, see Specific logical Frameworks and Implementations.
Historically, the first logical framework implementation was Automath. The goal of the Automath project was to provide a tool for the formalization of mathematics without foundational prejudice. Many modern logical frameworks carry influences of this.
Then inspired by the development of Martin-Löf dependent type theory was the Edinburgh Logical Framework (ELF). The logic and type theory-approaches were later combined in the Elf language. This gave rise to Twelf.
Frank Pfenning, Logical frameworks – a brief introduction (pdf)
Frank Pfenning, Logical frameworks In Alan Robinson and Andrei Voronkov (eds.) Handbook of Automated Reasoning, chapter 17, pages 1063–1147. Elsevier Science Publishers, 1999. (ps).
Frank Pfenning, Logical frameworks (web)
Randy Pollack, Some recent logical frameworks (2010) (pdf)