
We shall introduce in a uniform way the eight Lambda calculi typed a la Church Lambda Calculus λ →, λ2, λω, λω, λP, λPω, and λPω. Part III Typing a la Church The last one is often called λ C the calculus of constructions. The eight systems form a cube as Based on materials provided by H. P. Barendregt follows: Lambda calculus 3 1 Lambda calculus 3 2 Each edge → represents the inclusion ⊆ . This cube will be referred to as the λ-cube. λω λPω As we have seen, the systems λ → and λ 2 can be given also a la Curry. A Curry version exists also for λω λ2 λP2 and something similar can be probably given for its weaker version λω. λω λPω On the other hand, no natural Curry versions of the systems λ P , λ P 2 , λ P ω and λ C seem possible. λ → λP Lambda calculus 3 3 Lambda calculus 3 4 λ → Before we define the systems of the λ-cube in a uniform way, we introduce the systems λ → λ in the similar way as the Curry (x : A)∈ Γ and 2 (start rule) systems have been presented. Then it turns out that two of the systems Γ | − x : A of the λ-cube are equivalent to them. Γ | − M : (A → B) Γ | − N : A (→ −elimination) Γ | − (MN) : B Definition. λ → − Church . T = V | T → T •Types Γ, x : A | − M : B Λ = Λ Λ λ Λ (→ −introduction) •Pseudoterms T V | T T | V : T. Γ | − (λx : A.M ) : (A → B) Γ = •Bases { x 1 : A 1 , K , xn : An } with all x i ∈ distinct and all Ai T. λ → = •Contraction Rule ( x : A.M )N β M[x : N] Where the basis Γ , x : A stands for Γ ∪ { x : A } and it is •Type assignment Γ | − M : A is defined as follows: necessary that the variable x does not occur in Γ. The letters A, B denote arbitrary types and M,N arbitrary pseudoterms. Lambda calculus 3 5 Lambda calculus 3 6 The system λ2-Church Examples. •Types T = V | T → T | ∀VT | − (λa : A.a) : (A → A) Λ = Λ Λ Λ λ Λ Λ Λ b : B | − (λa : A.b) : (A → B) •Pseudoterms T V | T T | TT | V : T T | V T b : A | − ((λa : A.a)b) : A c : A,b : B | − (λa : A.b)c : B Γ = •Bases { x 1 : A 1 , K , xn : An } with all | − (λa : A.λb : B.a) : (A → B → A) A ∈ T xi distinct and i •Contraction rules (λa : A.M )N →β M[a := N] (Λα.M )A →β M[α := A] •Type assignment Γ | − M : A is defined as follows : Lambda calculus 3 7 Lambda calculus 3 8 λ2 Examples. (x : A)∈ Γ | − (λa : α.a) : (α → α) (start rule) Γ | − x : A | − (Λαλa : α.a) : (∀α.α → α) − Λαλ α → Γ | − M : (A → B) Γ | − N : A | ( a : .a)A : (A A) (→ −elimination) − Λαλ α Γ | − (MN) : B b : A | − (Λαλa : α.a)Ab : A Γ, x : A | − M : B (→ −introduction) For more advanced,check that the following reduction holds Γ | − (λx : A.M ) : (A → B) | − (Λαλαλa : α.a)Ab → (λa : A.a)b → b Γ | − M : (∀α.A) | − (Λβλa : (∀α.α).a((∀α.α) → β)a) : (∀β.(∀α.α) → β) (∀ − elimination) B ∈ T Γ | − MB : A[α := B] For less advanced − Λββλλ ∀α α αβ ∀β ∀α α → β Γ | − M : A | ( a : ( . ). ) : ( .( . ) ) (∀ − introduction) α ∉ FV (Γ) Γ | − (Λα.M ) : (∀α.A) Without a proof: Church-Rosser property holds for the reduction of pseudoterms in λ2. Lambda calculus 3 9 Lambda calculus 3 10 Dependency. In λ → and λ 2 one has also function abstraction for the two types of Types are dependent on terms and vice versa. There are four cases: dependence. For the two examples above terms depending on terms λm : A.Fm : A → B terms depending on types types depending on terms Λα.Gα : ∀α.α → α types depending on types The systems λ ω and λP. The first two sorts of dependency are presented in λ → and λ2. In λ → , we have We shall show the remaining two dependencies: in particular with → F : A B M : A ⇒ FM : B types FA in λ ω depending on types and FM in λ P depending on Here FM is a term depending on a term, in particular on M. terms. In λ , we have 2 We will also have function abstractions for these dependencies both ∀α α → α → G : . A a type ⇒ GA : A A in λ ω and λ P . Hence for G ≡ Λ αλα λ a : α . a , we have GA a term depending on the type A. Lambda calculus 3 11 Lambda calculus 3 12 The system λ ω : Types depending on types. ≡ λα ∗ α → α α → α Now, we can write f : . for the f above. But we is a natural example of a type depending on a type α. have to ask, where this f live. Neither on the level of terms, nor We would like to define a term f = λα ∈ T.α → α with a new among the types. form of abstraction such that f ( α ) = α → α . This will be possible in λ ω . To do this, it is not possible to define types in an It is necessary to introduce a new class K, the elements of which are informal metalanguage as we have done so far. It is necessary called kinds. generate the type by the system itself. K = ∗ |K → K Hence Kinds and constructors. ∗, ∗ → ∗, ∗ → ∗ → ∗,K are kinds and Informally, take a constant ∗ such that σ :∗ corresponds to σ ∈ T. K = {∗, ∗ → ∗, ∗ → ∗ → ∗,K } The informal statement α,β∈ T ⇒ (α → β)∈ T It is necessary to introduce one more class such that k : corresponds to k ∈ K . If | − k : and | − F : k , then F is called a constructor of Now be comes the formal kind k. Each element of T will be a constructor of kind ∗. α :∗, β :∗ | −(α → β) :∗ Lambda calculus 3 13 Lambda calculus 3 14 Example. We shall show later on that Definition. Types and terms of λω : | − (λα :∗.α → α) : (∗ → ∗) 1424 434 f •Sorts ∗ , two constants selected from C. Hence the above function f is a constructor of kind ∗ → ∗ . •Class K = ∗ | K → K the elements are called kinds. •A set of pseudoexpressions T Although the types and terms can be kept separate, we will T = V | C |TT | λV :T |T → T consider them as a subset of one general set T of pseudo- expressions. where V is an infinite collection of variables and C of constants. Lambda calculus 3 15 Lambda calculus 3 16 Statements, bases - a motivation Definition. Contexts for λω. As terms and types belong to the same set T , the definition of statement is modified accordingly, bases have both types of variables (i) A statement of λ ω is of form M : A with M , A∈T. as subjects and have to become linearly ordered. That is why we call them contexts. (ii) A context is a finite linearly ordered set of statements with distinct variables as subjects. We shall denote them by Γ, ∆. The reason is that in λ ω one wants to derive K α :∗, x : α | − x : α (iii) <> denotes the empty context. If Γ = < x : A , , x : A > α :∗ | − (λx : α.x) : (α → α) 1 1 K n n then Γ = < > , y : B x1 : A1 ,K, xn : An , y : B But not x : α, α :∗ | − x : α Γ − x : α | − (λα :∗.x) : (∗ → α) (iv) The (type) assignment | λ ω M : A is derived by the following axioms and rules. The letter s ranges over sorts. in which α occurs both free and bound. Lambda calculus 3 17 Lambda calculus 3 18 λω <>| − ∗ : (axiom) Γ | − A : s x ∉Γ Examples. (start rule) Γ, x : A | −x : A α ∗ β ∗ − α → β ∗ Γ | − A : B Γ | − C : s : , : | λω : (weakening rule) x ∉ Γ Γ, x : C | − A : B α :∗,β :∗, x : (α → β) | −λω x : (α → β) α ∗ β ∗ − λ α → β α → β → α → β Γ | − A : s Γ | − B : s : , : | λω ( x : ( ).x) : (( ) ( )) (type/kind formation) Γ | − (A → B) : s Γ | − F : (A → B) Γ | − a : A (application rule) ≡ λβ ∗ β → β Γ | − Fa : B Put D : . Then the following hold. Γ, x : A | − b : B Γ | − (A → B) : s (abstraction rule) − ∗ → ∗ Γ | − (λx : A.b) : (A → B) | λω D : ( ) α :∗ | −λω (λx : Dα.x) : D(Dα) Γ | − A : B Γ | − B´: s B = B´ (conversion rule) β Γ | − A : B´ Lambda calculus 3 19 Lambda calculus 3 20 Cartesian products. Suppose that for each a:A a type B is given such that there is The system λP: Types depending on terms. a an element b a : B a . Then we may want to form the function n λ A → B is an intuitive example of a type depending on a term. In a : A.ba order to formalize this dependence in λP, we need to extend the class K of kinds as follows: that should have as a type the cartesian product if A is a type and k ∈ K then A → k ∈ K. ∏ a : A.Ba of types B ´s. In particular A → ∗ is a kind and if f : A → ∗ and a ∈ A, a one has fa :∗. Once these product types are allowed, the type constructor → can be eliminated. We can write The expression fa is a type depending on a term. Moreover, we (A → B) ≡ ∏ a : A.B have function abstraction for this dependency. where a is a variable not occuring in B.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages20 Page
-
File Size-