Download Matita Tutorial - Dipartimento di Informatica
Transcript
· 190 9. A. Asperti and W. Ricciotti and C. Sacerdoti Coen LOGICAL RESTRICTIONS In this section we shall discuss some of the logical restrictions of the logical system required for preserving consistency. At the same time, we shall provide a more detailed and precise exposition of the Calculus of Inductive Constructions. In order to fully understand all nuances of the type system, the reader is invited to read the description of the Matita kernel in [5]. 9.1 Positivity in inductive definitions Not every inductive definition is accepted by Matita. The following is a typical example: inductive D : Type[0] := lam: (D → D) → D. which is rejected by the system with the following error message: Error: Non positive occurence in ((D → D) → D). The definition of D should be quite familiar: for instance, in order to build a model for the λ-calculus, one needs a domain D that is isomorphic to its own function space D → D (each term is also a function), and one could be tempted to simply define it as the smallest type D for which there exists an embedding (D → D) → D. Suppose we accept such a definition. We would then expect to be able to reason by case-analysis on an object d:D. In particular, d must reduce to the form lam f for some function f and we would expect to be able to extract this information out of d by means of the usual pattern matching operation. This is all we need to write a function that, given two terms in D, interprets the first as a function (i.e. unboxes the embedded function) and applies it to the second. definition app : D → D → D :=λd,e. match d with [lam f ⇒ f e]. At this point it should be clear that what we are really doing is embedding the λcalculus into CIC. More importantly, our embedding reuses the binding structures of CIC to express binding in the object calculus. For instance, we can easily express the familiar duplicator term of the λ-calculus (i.e. λx.x x) as follows: definition dup : D :=lam (λx:D. app x x). However, our embedding goes beyond that: we can even reuse reduction in CIC to express reduction in the object λ-calculus. Since the λ-calculus admits nonterminating terms, making the definition of D legal has surreptitiously added nonterminating computations into CIC as well. Let for example: definition omega : D :=app dup dup. Then, omega = app dup dup = (λx:D.app x x) dup = app dup dup = omega hence omega would reduce to itself, resulting in a non-terminating computation! So, what is so dangerous with non-termination? Consider for instance the following definitions: Journal of Formalized Reasoning Vol. 7, No. 2, 2014.