CS-XXX: Graduate Programming Languages. Lecture 27 Higher-Order Polymorphism. Matthew Fluet 2012
|
|
- Νικίας Λύκος
- 5 χρόνια πριν
- Προβολές:
Transcript
1 CS-XXX: Graduate Programming Languages Lecture 27 Higher-Order Polymorphism Matthew Fluet 2012
2 Looking back, looking forward Have defined System F. Metatheory (what properties does it have) What (else) is it good for How/why ML is more restrictive and implicit Recursive types (also use type variables, but differently) Existential types (dual to universal types) Next: Type operators and type-level computations Matthew Fluet CS-XXX 2012, Lecture 27 2
3 System F with Recursive and Existential Types e cbv e e ::= c x λx:τ. e e e Λα. e e [τ ] pack α. τ (τ, e) unpack e as (α, x) in e roll µα. τ (e) unroll(e) v ::= c λx:τ. e Λα. e pack α. τ (τ, v) roll µα. τ (v) (λx: τ. e b ) v a cbv e b [v a/x] e f cbv e f e f e a cbv e f ea e a cbv ea v f e a cbv v f e a (Λα. e b ) [τ a] cbv e b [τ a/α] e f cbv e f e f [τ a] cbv e f [τa] e a cbv e a pack α. τ (τ w, e a) cbv pack α. τ (τ w, e a ) e a cbv e a unpack e a as (α, x) in e b cbv unpack e a as (α, x) in e b unpack pack α. τ (τ w, v a) as (α, x) in e b cbv e b [τ w/α][v a/x] e a cbv e a unroll(e a) cbv unroll(e a ) unroll(rollµα. τ (va)) cbv va Matthew Fluet CS-XXX 2012, Lecture 27 3
4 System F with Recursive and Existential Types τ ::= int τ τ α α. τ α. τ µα. τ ::=, α Γ ::= Γ, x:τ ; Γ e : τ ; Γ c : int Γ(x) = τ ; Γ x : τ τ a ; Γ, x : τ a e b : τ r ; Γ e f : τ a τ r ; Γ e a : τ a ; Γ λx:τ a. e b : τ a τ r ; Γ e f e a : τ r, α; Γ e b : τ r ; Γ e f : α. τ r τ a ; Γ Λα. e b : α. τ r ; Γ e f [τ a] : τ r[τ a/α] ; Γ e a : τ [τ w/α] ; Γ pack α. τ (τ w, e a) : α. τ ; Γ e a : τ [(µα. τ )/α] ; Γ roll µα. τ (e a) : µα. τ ; Γ e a : α. τ, α; Γ, x:τ e b : τ r τ r ; Γ unpack e a as (α, x) in e b : τ r ; Γ e a : µα. τ ; Γ unroll(e a) : τ [(µα. τ )/α] Matthew Fluet CS-XXX 2012, Lecture 27 4
5 Goal Understand what this interface means and why it matters: type 'a list val empty : 'a list val cons : 'a -> 'a list -> 'a list val unlist : 'a list -> (' a * 'a list ) option val size : 'a list -> int val map : (' a -> 'b) -> 'a list -> 'b list Story so far: Recursive types to define list data structure Universal types to keep element type abstract in library Existential types to keep list type abstract in client But, cheated when abstracting the list type in client: considered just intlist. Matthew Fluet CS-XXX 2012, Lecture 27 5
6 (Integer) List Library with List library is an existential package: pack(µξ. unit + (int ξ), list library) as L. {empty : L; cons : int L L; unlist : L unit + (int L); map : (int int) L L;...} The witness type is integer lists: µξ. unit + (int ξ). The existential type variable L represents integer lists. List operations are monomorphic in element type (int). The map function only allows mapping integer lists to integer lists. Matthew Fluet CS-XXX 2012, Lecture 27 6
7 (Polymorphic?) List Library with / List library is a type abstraction that yields an existential package: Λα. pack(µξ. unit + (α ξ), list library) as L. {empty : L; cons : α L L; unlist : L unit + (α L); map : (α α) L L;...} The witness type is α lists: µξ. unit + (α ξ). The existential type variable L represents α lists. List operations are monomorphic in element type (α). The map function only allows mapping α lists to α lists. Matthew Fluet CS-XXX 2012, Lecture 27 7
8 Type Abbreviations and Type Operators Reasonable enough to provide list type as a (parametric) type abbreviation: L α = µξ. unit + (α ξ) replace occurrences of L τ in programs with (µξ. unit + (α ξ))[τ /α] Gives an informal notion of functions at the type-level. But, doesn t help with with list library, because this exposes the definition of list type. How modular and safe are libraries built from cpp macros? Matthew Fluet CS-XXX 2012, Lecture 27 8
9 Type Abbreviations and Type Operators Instead, provide list type as a type operator: a function from types to types L = λα. µξ. unit + (α ξ) Gives a formal notion of functions at the type-level. abstraction and application at the type-level equivalence of type-level expressions well-formedness of type-level expressions List library will be an existential package that hides a type operator, (rather than a type). Matthew Fluet CS-XXX 2012, Lecture 27 9
10 Type-level Expressions Abstraction and application at the type level makes it possible to write the same type with different syntax. Id = λα. α int bool int Id bool Id int bool Id int Id bool Id (int bool) Id (Id (int bool))... Matthew Fluet CS-XXX 2012, Lecture 27 10
11 Type-level Expressions Abstraction and application at the type level makes it possible to write the same type with different syntax. Id = λα. α int bool int Id bool Id int bool Id int Id bool Id (int bool) Id (Id (int bool))... Require a precise definition of when two types are the same: τ τ... (λα. τ b ) τ a τ b [α/τ a ]... Matthew Fluet CS-XXX 2012, Lecture 27 10
12 Type-level Expressions Abstraction and application at the type level makes it possible to write the same type with different syntax. Id = λα. α int bool int Id bool Id int bool Id int Id bool Id (int bool) Id (Id (int bool))... Require a typing rule to exploit types that are the same: ; Γ e : τ... ; Γ e : τ τ τ ; Γ e : τ... Matthew Fluet CS-XXX 2012, Lecture 27 10
13 Type-level Expressions Abstraction and application at the type level makes it possible to write the same type with different syntax. Id = λα. α int bool int Id bool Id int bool Id int Id bool Id (int bool) Id (Id (int bool))... Admits wrong/bad/meaningless types:... bool int (Id bool) int bool (Id int)... Matthew Fluet CS-XXX 2012, Lecture 27 10
14 Type-level Expressions Abstraction and application at the type level makes it possible to write the same type with different syntax. Id = λα. α int bool int Id bool Id int bool Id int Id bool Id (int bool) Id (Id (int bool))... Require a type system for types: τ :: κ... τ f :: κ a κ r τ a :: κ a... τ f τ a :: κ r Matthew Fluet CS-XXX 2012, Lecture 27 10
15 Terms, Types, and Kinds, Oh My Matthew Fluet CS-XXX 2012, Lecture 27 11
16 Terms, Types, and Kinds, Oh My Terms: e ::= c x λx:τ. e e e Λα::κ. e e [τ ] v ::= c λx:τ. e Λα::κ. e atomic values (e.g., c) and operations (e.g., e + e) compound values (e.g., (v,v)) and operations (e.g., e.1) value abstraction and application type abstraction and application classified by types (but not all terms have a type) Matthew Fluet CS-XXX 2012, Lecture 27 11
17 Terms, Types, and Kinds, Oh My Terms: e ::= c x λx:τ. e e e Λα::κ. e e [τ ] v ::= c λx:τ. e Λα::κ. e atomic values (e.g., c) and operations (e.g., e + e) compound values (e.g., (v,v)) and operations (e.g., e.1) value abstraction and application type abstraction and application classified by types (but not all terms have a type) Types: τ ::= int τ τ α α::κ. τ λα::κ. τ τ τ atomic types (e.g., int) classify the terms that evaluate to atomic values compound types (e.g., τ τ ) classify the terms that evaluate to compound values function types τ τ classify the terms that evaluate to value abstractions universal types α. τ classify the terms that evaluate to type abstractions type abstraction and application type abstractions do not classify terms, but can be applied to type arguments to form types that do classify terms classified by kinds (but not all types have a kind) Matthew Fluet CS-XXX 2012, Lecture 27 11
18 Terms, Types, and Kinds, Oh My Types: τ ::= int τ τ α α::κ. τ λα::κ. τ τ τ atomic types (e.g., int) classify the terms that evaluate to atomic values compound types (e.g., τ τ ) classify the terms that evaluate to compound values function types τ τ classify the terms that evaluate to value abstractions universal types α. τ classify the terms that evaluate to type abstractions type abstraction and application type abstractions do not classify terms, but can be applied to type arguments to form types that do classify terms classified by kinds (but not all types have a kind) Matthew Fluet CS-XXX 2012, Lecture 27 11
19 Terms, Types, and Kinds, Oh My Types: τ ::= int τ τ α α::κ. τ λα::κ. τ τ τ atomic types (e.g., int) classify the terms that evaluate to atomic values compound types (e.g., τ τ ) classify the terms that evaluate to compound values function types τ τ classify the terms that evaluate to value abstractions universal types α. τ classify the terms that evaluate to type abstractions type abstraction and application type abstractions do not classify terms, but can be applied to type arguments to form types that do classify terms classified by kinds (but not all types have a kind) Kinds κ ::= κ κ kind of proper types classify the types (that are the same as the types) that classify terms arrow kinds κ κ classify the types (that are the same as the types) that are type abstractions Matthew Fluet CS-XXX 2012, Lecture 27 11
20 Kind Examples Matthew Fluet CS-XXX 2012, Lecture 27 12
21 Kind Examples the kind of proper types Bool, Bool Bool,... Matthew Fluet CS-XXX 2012, Lecture 27 12
22 Kind Examples the kind of proper types Bool, Bool Bool,... the kind of (unary) type operators List, Maybe,... Matthew Fluet CS-XXX 2012, Lecture 27 12
23 Kind Examples the kind of proper types Bool, Bool Bool, Maybe Bool, Maybe Bool Maybe Bool,... the kind of (unary) type operators List, Maybe,... Matthew Fluet CS-XXX 2012, Lecture 27 12
24 Kind Examples the kind of proper types Bool, Bool Bool, Maybe Bool, Maybe Bool Maybe Bool,... the kind of (unary) type operators List, Maybe,... the kind of (binary) type operators Either, Map,... Matthew Fluet CS-XXX 2012, Lecture 27 12
25 Kind Examples the kind of proper types Bool, Bool Bool, Maybe Bool, Maybe Bool Maybe Bool,... the kind of (unary) type operators List, Maybe, Map Int, Either (List Bool),... the kind of (binary) type operators Either, Map,... Matthew Fluet CS-XXX 2012, Lecture 27 12
26 Kind Examples the kind of proper types Bool, Bool Bool, Maybe Bool, Maybe Bool Maybe Bool,... the kind of (unary) type operators List, Maybe, Map Int, Either (List Bool),... the kind of (binary) type operators Either, Map,... ( ) the kind of higher-order type operators taking unary type operators to proper types???,... Matthew Fluet CS-XXX 2012, Lecture 27 12
27 Kind Examples the kind of proper types Bool, Bool Bool, Maybe Bool, Maybe Bool Maybe Bool,... the kind of (unary) type operators List, Maybe, Map Int, Either (List Bool),... the kind of (binary) type operators Either, Map,... ( ) the kind of higher-order type operators taking unary type operators to proper types???,... ( ) the kind of higher-order type operators taking unary type operators to unary type operators MaybeT, ListT,... Matthew Fluet CS-XXX 2012, Lecture 27 12
28 Kind Examples the kind of proper types Bool, Bool Bool, Maybe Bool, Maybe Bool Maybe Bool,... the kind of (unary) type operators List, Maybe, Map Int, Either (List Bool), ListT Maybe,... the kind of (binary) type operators Either, Map,... ( ) the kind of higher-order type operators taking unary type operators to proper types???,... ( ) the kind of higher-order type operators taking unary type operators to unary type operators MaybeT, ListT,... Matthew Fluet CS-XXX 2012, Lecture 27 12
29 System F ω : Syntax e ::= c x λx:τ. e e e Λα::κ. e e [τ ] v ::= c λx:τ. e Λα::κ. e Γ ::= Γ, x:τ τ ::= int τ τ α α::κ. τ λα::κ. τ τ τ ::=, α::κ κ ::= κ κ New things: Types: type abstraction and type application Kinds: the types of types : kind of proper types κa κ r : kind of type operators Matthew Fluet CS-XXX 2012, Lecture 27 13
30 System F ω : Operational Semantics Small-step, call-by-value (CBV), left-to-right operational semantics: e cbv e (λx: τ. e b ) v a cbv e b [v a /x] e f cbv e f e f e a cbv e f e a e a cbv e a v f e a cbv v f e a (Λα::κ a. e b ) [τ a ] cbv e b [τ a /α] e f cbv e f e f [τ a ] cbv e f [τ a] Unchanged! All of the new action is at the type-level. Matthew Fluet CS-XXX 2012, Lecture 27 14
31 System F ω : Type System, part 1 In the context the type τ has kind κ: τ :: κ int :: (α) = κ α :: κ τ a :: τ r :: τ a τ r ::, α :: κ a τ r :: α::κ a. τ r ::, α :: κ a τ b :: κ r λα::κ a. τ b :: κ a κ r τ f :: κ a κ r τ a :: κ a τ f τ a :: κ r Should look familiar: Matthew Fluet CS-XXX 2012, Lecture 27 15
32 System F ω : Type System, part 1 In the context the type τ has kind κ: τ :: κ int :: (α) = κ α :: κ τ a :: τ r :: τ a τ r ::, α :: κ a τ r :: α::κ a. τ r ::, α :: κ a τ b :: κ r λα::κ a. τ b :: κ a κ r τ f :: κ a κ r τ a :: κ a τ f τ a :: κ r Should look familiar: the typing rules of the Simply-Typed Lambda Calculus one level up Matthew Fluet CS-XXX 2012, Lecture 27 15
33 System F ω : Type System, part 2 Definitional Equivalence of τ and τ : τ τ τ τ τ 2 τ 1 τ 1 τ 2 τ 1 τ 2 τ 2 τ 3 τ 1 τ 3 τ a1 τ a2 τ r1 τ r2 τ r1 τ r2 τ a1 τ r1 τ a2 τ r2 α::κ a. τ r1 α::κ a. τ r2 τ b1 τ b2 λα::κ a. τ b1 λα::κ a. τ b2 τ f1 τ f2 τ a1 τ a2 τ f1 τ a1 τ f2 τ a2 (λα::κ a. τ b ) τ a τ b [α/τ a ] Should look familiar: Matthew Fluet CS-XXX 2012, Lecture 27 16
34 System F ω : Type System, part 2 Definitional Equivalence of τ and τ : τ τ τ τ τ 2 τ 1 τ 1 τ 2 τ 1 τ 2 τ 2 τ 3 τ 1 τ 3 τ a1 τ a2 τ r1 τ r2 τ r1 τ r2 τ a1 τ r1 τ a2 τ r2 α::κ a. τ r1 α::κ a. τ r2 τ b1 τ b2 λα::κ a. τ b1 λα::κ a. τ b2 τ f1 τ f2 τ a1 τ a2 τ f1 τ a1 τ f2 τ a2 (λα::κ a. τ b ) τ a τ b [α/τ a ] Should look familiar: the full reduction rules of the Lambda Calculus one level up Matthew Fluet CS-XXX 2012, Lecture 27 16
35 System F ω : Type System, part 3 In the contexts and Γ the expression e has type τ : ; Γ e : τ ; Γ c : int Γ(x) = τ ; Γ x : τ τ a :: ; Γ, x : τ a e b : τ r ; Γ e f : τ a τ r ; Γ e a : τ a ; Γ λx:τ a. e b : τ a τ r ; Γ e f e a : τ r, α :: κ a; Γ e b : τ r ; Γ e f : α::κ a. τ r τ a :: κ a ; Γ Λα. e b : α::κ a. τ r ; Γ e f [τ a] : τ r[τ a/α] ; Γ e : τ τ τ τ :: ; Γ e : τ Matthew Fluet CS-XXX 2012, Lecture 27 17
36 System F ω : Type System, part 3 In the contexts and Γ the expression e has type τ : ; Γ e : τ ; Γ c : int Γ(x) = τ ; Γ x : τ τ a :: ; Γ, x : τ a e b : τ r ; Γ e f : τ a τ r ; Γ e a : τ a ; Γ λx:τ a. e b : τ a τ r ; Γ e f e a : τ r, α :: κ a; Γ e b : τ r ; Γ e f : α::κ a. τ r τ a :: κ a ; Γ Λα. e b : α::κ a. τ r ; Γ e f [τ a] : τ r[τ a/α] ; Γ e : τ τ τ τ :: ; Γ e : τ Syntax and type system easily extended with recursive and existential types. Matthew Fluet CS-XXX 2012, Lecture 27 17
37 Polymorphic List Library with higher-order List library is an existential package: pack(λα::. µξ::. unit + (α ξ), list library) as L::. {empty : α::. L α; cons : α::. α L α L α; unlist : α::. L α unit + (α L α); map : α::. β::. (α β) L α L β;...} The witness type operator is poly.lists: λα::. µξ::. unit + (α ξ). The existential type operator variable L represents poly. lists. List operations are polymorphic in element type. The map function only allows mapping α lists to β lists. Matthew Fluet CS-XXX 2012, Lecture 27 18
38 Other Kinds of Kinds Kinding systems for checking and tracking properties of type expressions: Record kinds records at the type-level; define systems of mutually recursive types Polymorphic kinds kind abstraction and application in types; System F one level up Dependent kinds dependent types one level up Row kinds describe pieces of record types for record polymorphism Power kinds alternative presentation of subtyping Singleton kinds formalize module systems with type sharing Matthew Fluet CS-XXX 2012, Lecture 27 19
39 Metatheory System F ω is type safe. Matthew Fluet CS-XXX 2012, Lecture 27 20
40 Metatheory System F ω is type safe. Preservation: Induction on typing derivation, using substitution lemmas: Term Substitution: if 1, 2 ; Γ 1, x : τ x, Γ 2 e 1 : τ and 1 ; Γ 1 e 2 : τ x, then 1, 2 ; Γ 1, Γ 2 e 1 [e 2 /x] : τ. Type Substitution: if 1, α::κ α, 2 τ 1 :: κ and 1 τ 2 :: κ α, then 1, 2 τ 1 [τ 2 /α] :: κ. Type Substitution: if τ 1 τ 2, then τ 1 [τ /α] τ 2 [τ /α]. Type Substitution: if 1, α::κ α, 2 ; Γ 1, Γ 2 e 1 : τ and 1 τ 2 :: κ α, then 1, 2 ; Γ 1, Γ 2 [τ 2 /α] e 1 [τ 2 /α] : τ. All straightforward inductions, using various weakening and exchange lemmas. Matthew Fluet CS-XXX 2012, Lecture 27 20
41 Metatheory System F ω is type safe. Progress: Induction on typing derivation, using canonical form lemmas: If ; v : int, then v = c. If ; v : τa τ r, then v = λx:τ a. e b. If ; v : α::κa. τ r, then v = Λα::κ a. e b. Complicated by typing derivations that end with: ; Γ e : τ τ τ τ :: ; Γ e : τ (just like with subtyping and subsumption). Matthew Fluet CS-XXX 2012, Lecture 27 20
42 Definitional Equivalence and Parallel Reduction Parallel Reduction of τ to τ : τ τ τ τ τ a1 τ a2 τ r1 τ r2 τ r1 τ r2 τ a1 τ r1 τ a2 τ r2 α::κ a. τ r1 α::κ a. τ r2 τ b1 τ b2 λα::κ a. τ b1 λα::κ a. τ b2 τ f1 τ f2 τ a1 τ a2 τ f1 τ a1 τ f2 τ a2 τ b τ b τ a τ a (λα::κ a. τ b) τ a τ b[α/τ a] A more computational relation. Matthew Fluet CS-XXX 2012, Lecture 27 21
43 Definitional Equivalence and Parallel Reduction Key properties: Matthew Fluet CS-XXX 2012, Lecture 27 22
44 Definitional Equivalence and Parallel Reduction Key properties: Transitive and symmetric closure of parallel reduction and type equivalence coincide: τ τ iff τ τ Matthew Fluet CS-XXX 2012, Lecture 27 22
45 Definitional Equivalence and Parallel Reduction Key properties: Transitive and symmetric closure of parallel reduction and type equivalence coincide: τ τ iff τ τ Parallel reduction has the Church-Rosser property: If τ τ 1 and τ τ 2, then there exists τ such that τ 1 τ and τ 2 τ Matthew Fluet CS-XXX 2012, Lecture 27 22
46 Definitional Equivalence and Parallel Reduction Key properties: Transitive and symmetric closure of parallel reduction and type equivalence coincide: τ τ iff τ τ Parallel reduction has the Church-Rosser property: If τ τ 1 and τ τ 2, then there exists τ such that τ 1 τ and τ 2 τ Equivalent types share a common reduct: If τ 1 τ 2, then there exists τ such that τ 1 τ and τ 2 τ Matthew Fluet CS-XXX 2012, Lecture 27 22
47 Definitional Equivalence and Parallel Reduction Key properties: Transitive and symmetric closure of parallel reduction and type equivalence coincide: τ τ iff τ τ Parallel reduction has the Church-Rosser property: If τ τ 1 and τ τ 2, then there exists τ such that τ 1 τ and τ 2 τ Equivalent types share a common reduct: If τ 1 τ 2, then there exists τ such that τ 1 τ and τ 2 τ Reduction preserves shapes: If int τ, then τ = int If τa τ r τ, then τ = τ a τ r and τ a τ a and τ r τ r If α::κ a. τ r τ, then τ = α::κ a. τ r and τ r τ r Matthew Fluet CS-XXX 2012, Lecture 27 22
48 Canonical Forms If ; v : τ a τ r, then v = λx:τ a. e b. Proof: By cases on the form of v: Matthew Fluet CS-XXX 2012, Lecture 27 23
49 Canonical Forms If ; v : τ a τ r, then v = λx:τ a. e b. Proof: By cases on the form of v: v = λx:τ a. e b. We have that v = λx:τ a. e b. Matthew Fluet CS-XXX 2012, Lecture 27 23
50 Canonical Forms If ; v : τ a τ r, then v = λx:τ a. e b. Proof: By cases on the form of v: v = c. Derivation of ; v : τ a τ r must be of the form:. ; c : int int τ 1 ; c : τ 1. ; c : τ n 1 τ n 1 τ n ; c : τ n τ n τ a τ r ; c : τ a τ r Therefore, we can construct the derivation int τ a τ r. We can find a common reduct: int τ and τ a τ r τ. Reduction preserves shape: int τ implies τ = int. Reduction preserves shape: τ a τ r τ implies τ = τ a τ r. But, τ = int and τ = τ a τ r is a contradiction. Matthew Fluet CS-XXX 2012, Lecture 27 23
51 Canonical Forms If ; v : τ a τ r, then v = λx:τ a. e b. Proof: By cases on the form of v: v = Λα::κ a. e b. Derivation of ; v : τ a τ r must be of the form:. ; Λα::κ a. e b : α::κ a. τ z α::κ a. τ z τ 1 ; Λα::κ a. e b : τ 1. ; Λα::κ a. e b : τ n 1 τ n 1 τ n ; Λα::κ a. e b : τ n τ n τ a τ r ; Λα::κ a. e b : τ a τ r Therefore, we can construct the derivation α::κ a. τ z τ a τ r. We can find a common reduct: α::κ a. τ z τ and τ a τ r τ. Reduction preserves shape: α::κ a. τ z τ implies τ = α::κ a. τ z. Reduction preserves shape: τ a τ r τ implies τ = τ a τ r. But, τ = α::κ a. τ z and τ = τ a τ r is a contradiction. Matthew Fluet CS-XXX 2012, Lecture 27 23
52 Metatheory System F ω is type safe. Where was the τ :: κ judgement used in the proof? Matthew Fluet CS-XXX 2012, Lecture 27 24
53 Metatheory System F ω is type safe. Where was the τ :: κ judgement used in the proof? In Type Substitution lemmas, but only in an inessential way. Matthew Fluet CS-XXX 2012, Lecture 27 24
54 Metatheory System F ω is type safe. Where was the τ :: κ judgement used in the proof? In Type Substitution lemmas, but only in an inessential way. After weeks of thinking about type systems, kinding seems natural; but kinding is not required for type safety! Matthew Fluet CS-XXX 2012, Lecture 27 24
55 System F ω without Kinds / System F with Type-Level Abstraction and Application e ::= c x λx:τ. e e e Λα. e e [τ ] v ::= c λx:τ. e Λα. e τ ::= int τ τ α α. τ λα. τ τ τ Γ ::= Γ, x:τ ::=, α Matthew Fluet CS-XXX 2012, Lecture 27 25
56 System F ω without Kinds / System F with Type-Level Abstraction and Application e ::= c x λx:τ. e e e Λα. e e [τ ] v ::= c λx:τ. e Λα. e τ ::= int τ τ α α. τ λα. τ τ τ Γ ::= Γ, x:τ ::=, α e cbv e (λx: τ. e b) v a cbv e b[v a/x] e f cbv e f e a cbv e a e f e a cbv e f e a v f e a cbv v f e a (Λα. e b) [τ a] cbv e b[τ a/α] e f cbv e f e f [τ a] cbv e f [τ a] Matthew Fluet CS-XXX 2012, Lecture 27 25
57 System F ω without Kinds / System F with Type-Level Abstraction and Application e ::= c x λx:τ. e e e Λα. e e [τ ] v ::= c λx:τ. e Λα. e τ ::= int τ τ α α. τ λα. τ τ τ Γ ::= Γ, x:τ ::=, α τ :: int :: α α ::, α τ b :: λα. τ b :: τ a :: τ r :: τ a τ r ::, α τ r :: α. τ r :: τ f :: τ a :: τ f τ a :: Check that free type variables of τ are in, but nothing else. Matthew Fluet CS-XXX 2012, Lecture 27 25
58 System F ω without Kinds / System F with Type-Level Abstraction and Application e ::= c x λx:τ. e e e Λα. e e [τ ] v ::= c λx:τ. e Λα. e τ ::= int τ τ α α. τ λα. τ τ τ Γ ::= Γ, x:τ ::=, α τ τ τ τ τ 2 τ 1 τ 1 τ 2 τ 1 τ 2 τ 2 τ 3 τ 1 τ 3 τ a1 τ a2 τ r1 τ r2 τ r1 τ r2 τ a1 τ r1 τ a2 τ r2 α. τ r1 α. τ r2 τ b1 τ b2 λα. τ b1 λα. τ b2 τ f1 τ f2 τ a1 τ a2 τ f1 τ a1 τ f2 τ a2 (λα. τ b) τ a τ b[α/τ a] Matthew Fluet CS-XXX 2012, Lecture 27 25
59 System F ω without Kinds / System F with Type-Level Abstraction and Application e ::= c x λx:τ. e e e Λα. e e [τ ] v ::= c λx:τ. e Λα. e τ ::= int τ τ α α. τ λα. τ τ τ Γ ::= Γ, x:τ ::=, α ; Γ e : τ ; Γ c : int Γ(x) = τ ; Γ x : τ τ a :: ; Γ, x : τ a e b : τ r ; Γ e f : τ a τ r ; Γ e a : τ a ; Γ λx:τ a. e b : τ a τ r ; Γ e f e a : τ r, α; Γ e b : τ r ; Γ e f : α. τ r τ a :: ; Γ Λα. e b : α. τ r ; Γ e f [τ a] : τ r[τ a/α] ; Γ e : τ τ τ ; Γ e : τ Matthew Fluet CS-XXX 2012, Lecture 27 25
60 System F ω without Kinds / System F with Type-Level Abstraction and Application This language is type safe. Matthew Fluet CS-XXX 2012, Lecture 27 26
61 System F ω without Kinds / System F with Type-Level Abstraction and Application This language is type safe. Preservation: Induction on typing derivation, using substitution lemmas: Term Substitution: if 1, 2 ; Γ 1, x : τ x, Γ 2 e 1 : τ and 1 ; Γ 1 e 2 : τ x, then 1, 2 ; Γ 1, Γ 2 e 1 [e 2 /x] : τ. Type Substitution: if 1, α, 2 τ 1 :: and 1 τ 2 ::, then 1, 2 τ 1 [τ 2 /α] ::. Type Substitution: if τ 1 τ 2, then τ 1 [τ /α] τ 2 [τ /α]. Type Substitution: if 1, α, 2 ; Γ 1, Γ 2 e 1 : τ and 1 τ 2 ::, then 1, 2 ; Γ 1, Γ 2 [τ 2 /α] e 1 [τ 2 /α] : τ. All straightforward inductions, using various weakening and exchange lemmas. Matthew Fluet CS-XXX 2012, Lecture 27 26
62 System F ω without Kinds / System F with Type-Level Abstraction and Application This language is type safe. Progress: Induction on typing derivation, using canonical form lemmas: If ; v : int, then v = c. If ; v : τa τ r, then v = λx:τ a. e b. If ; v : α. τr, then v = Λα. e b. Using parallel reduction relation. Matthew Fluet CS-XXX 2012, Lecture 27 26
63 Why Kinds? Why aren t kinds required for type safety? Matthew Fluet CS-XXX 2012, Lecture 27 27
64 Why Kinds? Why aren t kinds required for type safety? Recall statement of type safety: If ; e : τ, then e does not get stuck. Matthew Fluet CS-XXX 2012, Lecture 27 27
65 Why Kinds? Why aren t kinds required for type safety? Recall statement of type safety: If ; e : τ, then e does not get stuck. The typing derivation ; e : τ includes definitional-equivalence sub-derivations τ τ, which are explicit evidence that τ and τ are the same. E.g., to show that the natural type of the function expression in an application is equivalent to an arrow type:. ; Γ e f : τ f. τ f τ a τ r ; Γ e f : τ a τ r ; Γ e f e a : τ r. ; Γ e a : τ a Matthew Fluet CS-XXX 2012, Lecture 27 27
66 Why Kinds? Why aren t kinds required for type safety? Recall statement of type safety: If ; e : τ, then e does not get stuck. The typing derivation ; e : τ includes definitional-equivalence sub-derivations τ τ, which are explicit evidence that τ and τ are the same. Definitional equivalence (τ τ ) and parallel reduction (τ τ ) do not require well-kinded types (although they preserve the kinds of well-kinded types). E.g., (λα. α α) (int int) (int int) (int int) Matthew Fluet CS-XXX 2012, Lecture 27 27
67 Why Kinds? Why aren t kinds required for type safety? Recall statement of type safety: If ; e : τ, then e does not get stuck. The typing derivation ; e : τ includes definitional-equivalence sub-derivations τ τ, which are explicit evidence that τ and τ are the same. Definitional equivalence (τ τ ) and parallel reduction (τ τ ) do not require well-kinded types (although they preserve the kinds of well-kinded types). Type (and kind) erasure means that wrong/bad/meaningless types do not affect run-time behavior. Ill-kinded types can t make well-typed terms get stuck. Matthew Fluet CS-XXX 2012, Lecture 27 27
68 Why Kinds? Kinds aren t for type safety: Because a typing derivation (even with ill-kinded types), carries enough evidence to guarantee that expressions don t get stuck. Matthew Fluet CS-XXX 2012, Lecture 27 28
69 Why Kinds? Kinds aren t for type safety: Because a typing derivation (even with ill-kinded types), carries enough evidence to guarantee that expressions don t get stuck. Kinds are for type checking: Because programmers write programs, not typing derivations. Because type checkers are algorithms. Matthew Fluet CS-XXX 2012, Lecture 27 28
70 Why Kinds? Kinds are for type checking: Because programmers write programs, not typing derivations. Because type checkers are algorithms. Matthew Fluet CS-XXX 2012, Lecture 27 28
71 Why Kinds? Kinds are for type checking: Because programmers write programs, not typing derivations. Because type checkers are algorithms. Recall the statement of type checking: Given, Γ, and e, does there exist τ such that ; Γ e : τ. Matthew Fluet CS-XXX 2012, Lecture 27 28
72 Why Kinds? Kinds are for type checking: Because programmers write programs, not typing derivations. Because type checkers are algorithms. Recall the statement of type checking: Given, Γ, and e, does there exist τ such that ; Γ e : τ. Two issues: ; Γ e : τ τ τ τ :: ; Γ e : τ is a non-syntax-directed rule τ τ is a non-syntax-directed relation One non-issue: τ :: κ is a syntax-directed relation (STLC one level up ) Matthew Fluet CS-XXX 2012, Lecture 27 28
73 Type Checking for System F ω Remove non-syntax-directed rules and relations: ; Γ e : τ ; Γ c : int Γ(x) = τ ; Γ x : τ τ a :: ; Γ, x : τ a e b : τ r, α::κ a; Γ e b : τ r ; Γ λx:τ a. e b : τ a τ r ; Γ Λα. e b : α::κ a. τ r ; Γ e f : τ f τ f τ f τ f = τ fa τ fr ; Γ e a : τ a τ a τ a τ fa = τ a ; Γ e f e a : τ fr ; Γ e f : τ f τ f τ f τ f = α::κ fa. τ fr τ a :: κ a κ fa = κ a ; Γ e f [τ a] : τ fr[τ a/α] Matthew Fluet CS-XXX 2012, Lecture 27 29
74 Type Checking for System F ω Kinds are for type checking. Given, Γ, and e, does there exist τ such that ; Γ e : τ. Metatheory for kind system: Matthew Fluet CS-XXX 2012, Lecture 27 30
75 Type Checking for System F ω Kinds are for type checking. Given, Γ, and e, does there exist τ such that ; Γ e : τ. Metatheory for kind system: Well-kinded types don t get stuck. If τ :: κ and τ τ, then either τ is in (weak-head) normal form (i.e., a type-level value ) or τ τ. Proofs by Progress and Preservation on kinding and parallel reduction derivations. Matthew Fluet CS-XXX 2012, Lecture 27 30
76 Type Checking for System F ω Kinds are for type checking. Given, Γ, and e, does there exist τ such that ; Γ e : τ. Metatheory for kind system: Well-kinded types don t get stuck. If τ :: κ and τ τ, then either τ is in (weak-head) normal form (i.e., a type-level value ) or τ τ. Proofs by Progress and Preservation on kinding and parallel reduction derivations. But, irrelevant for type checking of expressions. If τ f τ f gets stuck at a type τ f that is not an arrow type, then the application typing rule does not apply and a typing derivation does not exist. Matthew Fluet CS-XXX 2012, Lecture 27 30
77 Type Checking for System F ω Kinds are for type checking. Given, Γ, and e, does there exist τ such that ; Γ e : τ. Metatheory for kind system: Well-kinded types don t get stuck. If τ :: κ and τ τ, then either τ is in (weak-head) normal form (i.e., a type-level value ) or τ τ. But, irrelevant for type checking of expressions. Matthew Fluet CS-XXX 2012, Lecture 27 30
78 Type Checking for System F ω Kinds are for type checking. Given, Γ, and e, does there exist τ such that ; Γ e : τ. Metatheory for kind system: Well-kinded types don t get stuck. If τ :: κ and τ τ, then either τ is in (weak-head) normal form (i.e., a type-level value ) or τ τ. But, irrelevant for type checking of expressions. Well-kinded types terminate. If τ :: κ, then there exists τ such that τ τ. Proof is similar to that of termination of STLC. Matthew Fluet CS-XXX 2012, Lecture 27 30
79 Type Checking for System F ω Kinds are for type checking. Given, Γ, and e, does there exist τ such that ; Γ e : τ. Metatheory for kind system: Well-kinded types don t get stuck. If τ :: κ and τ τ, then either τ is in (weak-head) normal form (i.e., a type-level value ) or τ τ. But, irrelevant for type checking of expressions. Well-kinded types terminate. If τ :: κ, then there exists τ such that τ τ. Proof is similar to that of termination of STLC. Type checking for System F ω is decidable. Matthew Fluet CS-XXX 2012, Lecture 27 30
80 Going Further This is just the tip of an iceberg. Pure type systems Why stop at three levels of expressions (terms, types, and kinds)? Allow abstraction and application at the level of kinds, and introduce sorts to classify kinds. Why stop at four levels of expressions?... For programming languages, however, three levels have proved sufficient. Matthew Fluet CS-XXX 2012, Lecture 27 31
The Simply Typed Lambda Calculus
Type Inference Instead of writing type annotations, can we use an algorithm to infer what the type annotations should be? That depends on the type system. For simple type systems the answer is yes, and
Διαβάστε περισσότεραAbout these lecture notes. Simply Typed λ-calculus. Types
About these lecture notes Simply Typed λ-calculus Akim Demaille akim@lrde.epita.fr EPITA École Pour l Informatique et les Techniques Avancées Many of these slides are largely inspired from Andrew D. Ker
Διαβάστε περισσότεραC.S. 430 Assignment 6, Sample Solutions
C.S. 430 Assignment 6, Sample Solutions Paul Liu November 15, 2007 Note that these are sample solutions only; in many cases there were many acceptable answers. 1 Reynolds Problem 10.1 1.1 Normal-order
Διαβάστε περισσότεραderivation of the Laplacian from rectangular to spherical coordinates
derivation of the Laplacian from rectangular to spherical coordinates swapnizzle 03-03- :5:43 We begin by recognizing the familiar conversion from rectangular to spherical coordinates (note that φ is used
Διαβάστε περισσότερα2 Composition. Invertible Mappings
Arkansas Tech University MATH 4033: Elementary Modern Algebra Dr. Marcel B. Finan Composition. Invertible Mappings In this section we discuss two procedures for creating new mappings from old ones, namely,
Διαβάστε περισσότεραDynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Dynamic types, Lambda calculus machines Apr 21 22, 2016 1 Dynamic types and contracts (a) To make sure you understand the
Διαβάστε περισσότεραLecture 2. Soundness and completeness of propositional logic
Lecture 2 Soundness and completeness of propositional logic February 9, 2004 1 Overview Review of natural deduction. Soundness and completeness. Semantics of propositional formulas. Soundness proof. Completeness
Διαβάστε περισσότεραOrdinal Arithmetic: Addition, Multiplication, Exponentiation and Limit
Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit Ting Zhang Stanford May 11, 2001 Stanford, 5/11/2001 1 Outline Ordinal Classification Ordinal Addition Ordinal Multiplication Ordinal
Διαβάστε περισσότεραOverview. Transition Semantics. Configurations and the transition relation. Executions and computation
Overview Transition Semantics Configurations and the transition relation Executions and computation Inference rules for small-step structural operational semantics for the simple imperative language Transition
Διαβάστε περισσότεραChapter 3: Ordinal Numbers
Chapter 3: Ordinal Numbers There are two kinds of number.. Ordinal numbers (0th), st, 2nd, 3rd, 4th, 5th,..., ω, ω +,... ω2, ω2+,... ω 2... answers to the question What position is... in a sequence? What
Διαβάστε περισσότερα4.6 Autoregressive Moving Average Model ARMA(1,1)
84 CHAPTER 4. STATIONARY TS MODELS 4.6 Autoregressive Moving Average Model ARMA(,) This section is an introduction to a wide class of models ARMA(p,q) which we will consider in more detail later in this
Διαβάστε περισσότεραThe λ-calculus. Lecturer: John Wickerson. Phil Wadler
The λ-calculus Lecturer: John Wickerson Phil Wadler A tiny bit of Java expr ::= expr + expr expr < expr x n block ::= cmd { cmd... cmd } cmd ::= expr; if(cmd) block else block; if(cmd) block; try{cmd}
Διαβάστε περισσότεραNowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in
Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in : tail in X, head in A nowhere-zero Γ-flow is a Γ-circulation such that
Διαβάστε περισσότεραHOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:
HOMEWORK 4 Problem a For the fast loading case, we want to derive the relationship between P zz and λ z. We know that the nominal stress is expressed as: P zz = ψ λ z where λ z = λ λ z. Therefore, applying
Διαβάστε περισσότερα6.1. Dirac Equation. Hamiltonian. Dirac Eq.
6.1. Dirac Equation Ref: M.Kaku, Quantum Field Theory, Oxford Univ Press (1993) η μν = η μν = diag(1, -1, -1, -1) p 0 = p 0 p = p i = -p i p μ p μ = p 0 p 0 + p i p i = E c 2 - p 2 = (m c) 2 H = c p 2
Διαβάστε περισσότεραEE512: Error Control Coding
EE512: Error Control Coding Solution for Assignment on Finite Fields February 16, 2007 1. (a) Addition and Multiplication tables for GF (5) and GF (7) are shown in Tables 1 and 2. + 0 1 2 3 4 0 0 1 2 3
Διαβάστε περισσότεραEcon 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1
Eon : Fall 8 Suggested Solutions to Problem Set 8 Email questions or omments to Dan Fetter Problem. Let X be a salar with density f(x, θ) (θx + θ) [ x ] with θ. (a) Find the most powerful level α test
Διαβάστε περισσότερα3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β
3.4 SUM AND DIFFERENCE FORMULAS Page Theorem cos(αβ cos α cos β -sin α cos(α-β cos α cos β sin α NOTE: cos(αβ cos α cos β cos(α-β cos α -cos β Proof of cos(α-β cos α cos β sin α Let s use a unit circle
Διαβάστε περισσότεραLecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3
Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3 1 State vector space and the dual space Space of wavefunctions The space of wavefunctions is the set of all
Διαβάστε περισσότεραΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007
Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Αν κάπου κάνετε κάποιες υποθέσεις να αναφερθούν στη σχετική ερώτηση. Όλα τα αρχεία που αναφέρονται στα προβλήματα βρίσκονται στον ίδιο φάκελο με το εκτελέσιμο
Διαβάστε περισσότεραSection 8.3 Trigonometric Equations
99 Section 8. Trigonometric Equations Objective 1: Solve Equations Involving One Trigonometric Function. In this section and the next, we will exple how to solving equations involving trigonometric functions.
Διαβάστε περισσότεραΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ
ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ Ενότητα 12: Συνοπτική Παρουσίαση Ανάπτυξης Κώδικα με το Matlab Σαμαράς Νικόλαος Άδειες Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative Commons.
Διαβάστε περισσότεραStatistical Inference I Locally most powerful tests
Statistical Inference I Locally most powerful tests Shirsendu Mukherjee Department of Statistics, Asutosh College, Kolkata, India. shirsendu st@yahoo.co.in So far we have treated the testing of one-sided
Διαβάστε περισσότεραSection 9.2 Polar Equations and Graphs
180 Section 9. Polar Equations and Graphs In this section, we will be graphing polar equations on a polar grid. In the first few examples, we will write the polar equation in rectangular form to help identify
Διαβάστε περισσότεραSecond Order Partial Differential Equations
Chapter 7 Second Order Partial Differential Equations 7.1 Introduction A second order linear PDE in two independent variables (x, y Ω can be written as A(x, y u x + B(x, y u xy + C(x, y u u u + D(x, y
Διαβάστε περισσότεραCHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS
CHAPTER 5 SOLVING EQUATIONS BY ITERATIVE METHODS EXERCISE 104 Page 8 1. Find the positive root of the equation x + 3x 5 = 0, correct to 3 significant figures, using the method of bisection. Let f(x) =
Διαβάστε περισσότεραMatrices and Determinants
Matrices and Determinants SUBJECTIVE PROBLEMS: Q 1. For what value of k do the following system of equations possess a non-trivial (i.e., not all zero) solution over the set of rationals Q? x + ky + 3z
Διαβάστε περισσότεραA Lambda Model Characterizing Computational Behaviours of Terms
A Lambda Model Characterizing Computational Behaviours of Terms joint paper with Silvia Ghilezan RPC 01, Sendai, October 26, 2001 1 Plan of the talk normalization properties inverse limit model Stone dualities
Διαβάστε περισσότεραPartial Trace and Partial Transpose
Partial Trace and Partial Transpose by José Luis Gómez-Muñoz http://homepage.cem.itesm.mx/lgomez/quantum/ jose.luis.gomez@itesm.mx This document is based on suggestions by Anirban Das Introduction This
Διαβάστε περισσότεραPhys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)
Phys460.nb 81 ψ n (t) is still the (same) eigenstate of H But for tdependent H. The answer is NO. 5.5.5. Solution for the tdependent Schrodinger s equation If we assume that at time t 0, the electron starts
Διαβάστε περισσότεραConcrete Mathematics Exercises from 30 September 2016
Concrete Mathematics Exercises from 30 September 2016 Silvio Capobianco Exercise 1.7 Let H(n) = J(n + 1) J(n). Equation (1.8) tells us that H(2n) = 2, and H(2n+1) = J(2n+2) J(2n+1) = (2J(n+1) 1) (2J(n)+1)
Διαβάστε περισσότεραFinite Field Problems: Solutions
Finite Field Problems: Solutions 1. Let f = x 2 +1 Z 11 [x] and let F = Z 11 [x]/(f), a field. Let Solution: F =11 2 = 121, so F = 121 1 = 120. The possible orders are the divisors of 120. Solution: The
Διαβάστε περισσότεραHomework 3 Solutions
Homework 3 Solutions Igor Yanovsky (Math 151A TA) Problem 1: Compute the absolute error and relative error in approximations of p by p. (Use calculator!) a) p π, p 22/7; b) p π, p 3.141. Solution: For
Διαβάστε περισσότεραProblem Set 3: Solutions
CMPSCI 69GG Applied Information Theory Fall 006 Problem Set 3: Solutions. [Cover and Thomas 7.] a Define the following notation, C I p xx; Y max X; Y C I p xx; Ỹ max I X; Ỹ We would like to show that C
Διαβάστε περισσότεραAbstract Storage Devices
Abstract Storage Devices Robert König Ueli Maurer Stefano Tessaro SOFSEM 2009 January 27, 2009 Outline 1. Motivation: Storage Devices 2. Abstract Storage Devices (ASD s) 3. Reducibility 4. Factoring ASD
Διαβάστε περισσότεραFrom the finite to the transfinite: Λµ-terms and streams
From the finite to the transfinite: Λµ-terms and streams WIR 2014 Fanny He f.he@bath.ac.uk Alexis Saurin alexis.saurin@pps.univ-paris-diderot.fr 12 July 2014 The Λµ-calculus Syntax of Λµ t ::= x λx.t (t)u
Διαβάστε περισσότεραk A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +
Chapter 3. Fuzzy Arithmetic 3- Fuzzy arithmetic: ~Addition(+) and subtraction (-): Let A = [a and B = [b, b in R If x [a and y [b, b than x+y [a +b +b Symbolically,we write A(+)B = [a (+)[b, b = [a +b
Διαβάστε περισσότεραMath 6 SL Probability Distributions Practice Test Mark Scheme
Math 6 SL Probability Distributions Practice Test Mark Scheme. (a) Note: Award A for vertical line to right of mean, A for shading to right of their vertical line. AA N (b) evidence of recognizing symmetry
Διαβάστε περισσότεραEvery set of first-order formulas is equivalent to an independent set
Every set of first-order formulas is equivalent to an independent set May 6, 2008 Abstract A set of first-order formulas, whatever the cardinality of the set of symbols, is equivalent to an independent
Διαβάστε περισσότεραΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών
ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Ψηφιακή Οικονομία Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών Τέλος Ενότητας Χρηματοδότηση Το παρόν εκπαιδευτικό υλικό έχει αναπτυχθεί
Διαβάστε περισσότεραTMA4115 Matematikk 3
TMA4115 Matematikk 3 Andrew Stacey Norges Teknisk-Naturvitenskapelige Universitet Trondheim Spring 2010 Lecture 12: Mathematics Marvellous Matrices Andrew Stacey Norges Teknisk-Naturvitenskapelige Universitet
Διαβάστε περισσότεραMath221: HW# 1 solutions
Math: HW# solutions Andy Royston October, 5 7.5.7, 3 rd Ed. We have a n = b n = a = fxdx = xdx =, x cos nxdx = x sin nx n sin nxdx n = cos nx n = n n, x sin nxdx = x cos nx n + cos nxdx n cos n = + sin
Διαβάστε περισσότεραCRASH COURSE IN PRECALCULUS
CRASH COURSE IN PRECALCULUS Shiah-Sen Wang The graphs are prepared by Chien-Lun Lai Based on : Precalculus: Mathematics for Calculus by J. Stuwart, L. Redin & S. Watson, 6th edition, 01, Brooks/Cole Chapter
Διαβάστε περισσότεραExample Sheet 3 Solutions
Example Sheet 3 Solutions. i Regular Sturm-Liouville. ii Singular Sturm-Liouville mixed boundary conditions. iii Not Sturm-Liouville ODE is not in Sturm-Liouville form. iv Regular Sturm-Liouville note
Διαβάστε περισσότεραSection 7.6 Double and Half Angle Formulas
09 Section 7. Double and Half Angle Fmulas To derive the double-angles fmulas, we will use the sum of two angles fmulas that we developed in the last section. We will let α θ and β θ: cos(θ) cos(θ + θ)
Διαβάστε περισσότεραAssalamu `alaikum wr. wb.
LUMP SUM Assalamu `alaikum wr. wb. LUMP SUM Wassalamu alaikum wr. wb. Assalamu `alaikum wr. wb. LUMP SUM Wassalamu alaikum wr. wb. LUMP SUM Lump sum lump sum lump sum. lump sum fixed price lump sum lump
Διαβάστε περισσότεραST5224: Advanced Statistical Theory II
ST5224: Advanced Statistical Theory II 2014/2015: Semester II Tutorial 7 1. Let X be a sample from a population P and consider testing hypotheses H 0 : P = P 0 versus H 1 : P = P 1, where P j is a known
Διαβάστε περισσότερα5. Choice under Uncertainty
5. Choice under Uncertainty Daisuke Oyama Microeconomics I May 23, 2018 Formulations von Neumann-Morgenstern (1944/1947) X: Set of prizes Π: Set of probability distributions on X : Preference relation
Διαβάστε περισσότεραSCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions
SCHOOL OF MATHEMATICAL SCIENCES GLMA Linear Mathematics 00- Examination Solutions. (a) i. ( + 5i)( i) = (6 + 5) + (5 )i = + i. Real part is, imaginary part is. (b) ii. + 5i i ( + 5i)( + i) = ( i)( + i)
Διαβάστε περισσότεραNotes on the Open Economy
Notes on the Open Econom Ben J. Heijdra Universit of Groningen April 24 Introduction In this note we stud the two-countr model of Table.4 in more detail. restated here for convenience. The model is Table.4.
Διαβάστε περισσότεραΣυστήματα Διαχείρισης Βάσεων Δεδομένων
ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Συστήματα Διαχείρισης Βάσεων Δεδομένων Φροντιστήριο 9: Transactions - part 1 Δημήτρης Πλεξουσάκης Τμήμα Επιστήμης Υπολογιστών Tutorial on Undo, Redo and Undo/Redo
Διαβάστε περισσότεραdepartment listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι
She selects the option. Jenny starts with the al listing. This has employees listed within She drills down through the employee. The inferred ER sttricture relates this to the redcords in the databasee
Διαβάστε περισσότεραSequent Calculi for the Modal µ-calculus over S5. Luca Alberucci, University of Berne. Logic Colloquium Berne, July 4th 2008
Sequent Calculi for the Modal µ-calculus over S5 Luca Alberucci, University of Berne Logic Colloquium Berne, July 4th 2008 Introduction Koz: Axiomatisation for the modal µ-calculus over K Axioms: All classical
Διαβάστε περισσότεραPartial Differential Equations in Biology The boundary element method. March 26, 2013
The boundary element method March 26, 203 Introduction and notation The problem: u = f in D R d u = ϕ in Γ D u n = g on Γ N, where D = Γ D Γ N, Γ D Γ N = (possibly, Γ D = [Neumann problem] or Γ N = [Dirichlet
Διαβάστε περισσότεραOther Test Constructions: Likelihood Ratio & Bayes Tests
Other Test Constructions: Likelihood Ratio & Bayes Tests Side-Note: So far we have seen a few approaches for creating tests such as Neyman-Pearson Lemma ( most powerful tests of H 0 : θ = θ 0 vs H 1 :
Διαβάστε περισσότεραPractice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1
Conceptual Questions. State a Basic identity and then verify it. a) Identity: Solution: One identity is cscθ) = sinθ) Practice Exam b) Verification: Solution: Given the point of intersection x, y) of the
Διαβάστε περισσότεραInstruction Execution Times
1 C Execution Times InThisAppendix... Introduction DL330 Execution Times DL330P Execution Times DL340 Execution Times C-2 Execution Times Introduction Data Registers This appendix contains several tables
Διαβάστε περισσότεραInverse trigonometric functions & General Solution of Trigonometric Equations. ------------------ ----------------------------- -----------------
Inverse trigonometric functions & General Solution of Trigonometric Equations. 1. Sin ( ) = a) b) c) d) Ans b. Solution : Method 1. Ans a: 17 > 1 a) is rejected. w.k.t Sin ( sin ) = d is rejected. If sin
Διαβάστε περισσότεραProblem Set 9 Solutions. θ + 1. θ 2 + cotθ ( ) sinθ e iφ is an eigenfunction of the ˆ L 2 operator. / θ 2. φ 2. sin 2 θ φ 2. ( ) = e iφ. = e iφ cosθ.
Chemistry 362 Dr Jean M Standard Problem Set 9 Solutions The ˆ L 2 operator is defined as Verify that the angular wavefunction Y θ,φ) Also verify that the eigenvalue is given by 2! 2 & L ˆ 2! 2 2 θ 2 +
Διαβάστε περισσότεραApproximation of distance between locations on earth given by latitude and longitude
Approximation of distance between locations on earth given by latitude and longitude Jan Behrens 2012-12-31 In this paper we shall provide a method to approximate distances between two points on earth
Διαβάστε περισσότεραforms This gives Remark 1. How to remember the above formulas: Substituting these into the equation we obtain with
Week 03: C lassification of S econd- Order L inear Equations In last week s lectures we have illustrated how to obtain the general solutions of first order PDEs using the method of characteristics. We
Διαβάστε περισσότεραPARTIAL NOTES for 6.1 Trigonometric Identities
PARTIAL NOTES for 6.1 Trigonometric Identities tanθ = sinθ cosθ cotθ = cosθ sinθ BASIC IDENTITIES cscθ = 1 sinθ secθ = 1 cosθ cotθ = 1 tanθ PYTHAGOREAN IDENTITIES sin θ + cos θ =1 tan θ +1= sec θ 1 + cot
Διαβάστε περισσότεραSrednicki Chapter 55
Srednicki Chapter 55 QFT Problems & Solutions A. George August 3, 03 Srednicki 55.. Use equations 55.3-55.0 and A i, A j ] = Π i, Π j ] = 0 (at equal times) to verify equations 55.-55.3. This is our third
Διαβάστε περισσότεραChapter 6: Systems of Linear Differential. be continuous functions on the interval
Chapter 6: Systems of Linear Differential Equations Let a (t), a 2 (t),..., a nn (t), b (t), b 2 (t),..., b n (t) be continuous functions on the interval I. The system of n first-order differential equations
Διαβάστε περισσότεραΕργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο
Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων Εξάμηνο 7 ο Procedures and Functions Stored procedures and functions are named blocks of code that enable you to group and organize a series of SQL and PL/SQL
Διαβάστε περισσότεραCongruence Classes of Invertible Matrices of Order 3 over F 2
International Journal of Algebra, Vol. 8, 24, no. 5, 239-246 HIKARI Ltd, www.m-hikari.com http://dx.doi.org/.2988/ija.24.422 Congruence Classes of Invertible Matrices of Order 3 over F 2 Ligong An and
Διαβάστε περισσότεραANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?
Teko Classes IITJEE/AIEEE Maths by SUHAAG SIR, Bhopal, Ph (0755) 3 00 000 www.tekoclasses.com ANSWERSHEET (TOPIC DIFFERENTIAL CALCULUS) COLLECTION # Question Type A.Single Correct Type Q. (A) Sol least
Διαβάστε περισσότεραA Note on Intuitionistic Fuzzy. Equivalence Relation
International Mathematical Forum, 5, 2010, no. 67, 3301-3307 A Note on Intuitionistic Fuzzy Equivalence Relation D. K. Basnet Dept. of Mathematics, Assam University Silchar-788011, Assam, India dkbasnet@rediffmail.com
Διαβάστε περισσότεραFourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics
Fourier Series MATH 211, Calculus II J. Robert Buchanan Department of Mathematics Spring 2018 Introduction Not all functions can be represented by Taylor series. f (k) (c) A Taylor series f (x) = (x c)
Διαβάστε περισσότεραSolutions to Exercise Sheet 5
Solutions to Eercise Sheet 5 jacques@ucsd.edu. Let X and Y be random variables with joint pdf f(, y) = 3y( + y) where and y. Determine each of the following probabilities. Solutions. a. P (X ). b. P (X
Διαβάστε περισσότεραJesse Maassen and Mark Lundstrom Purdue University November 25, 2013
Notes on Average Scattering imes and Hall Factors Jesse Maassen and Mar Lundstrom Purdue University November 5, 13 I. Introduction 1 II. Solution of the BE 1 III. Exercises: Woring out average scattering
Διαβάστε περισσότεραCommutative Monoids in Intuitionistic Fuzzy Sets
Commutative Monoids in Intuitionistic Fuzzy Sets S K Mala #1, Dr. MM Shanmugapriya *2 1 PhD Scholar in Mathematics, Karpagam University, Coimbatore, Tamilnadu- 641021 Assistant Professor of Mathematics,
Διαβάστε περισσότεραSolutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz
Solutions to the Schrodinger equation atomic orbitals Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz ybridization Valence Bond Approach to bonding sp 3 (Ψ 2 s + Ψ 2 px + Ψ 2 py + Ψ 2 pz) sp 2 (Ψ 2 s + Ψ 2 px + Ψ 2 py)
Διαβάστε περισσότερα( ) 2 and compare to M.
Problems and Solutions for Section 4.2 4.9 through 4.33) 4.9 Calculate the square root of the matrix 3!0 M!0 8 Hint: Let M / 2 a!b ; calculate M / 2!b c ) 2 and compare to M. Solution: Given: 3!0 M!0 8
Διαβάστε περισσότεραFoundations of Computer Science ENGR 3520 Fall 2013 Thursday, Nov 21, 2013
Foundations of Computer Science Lecture Notes ENGR 3520 Fall 2013 Thursday, Nov 21, 2013 λ-calculus λ-terms. A λ-term is either: A variable x, y, z,... λx.m M N (M) (where x is a variable and M a λ-term)
Διαβάστε περισσότεραΑπόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.
Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο The time integral of a force is referred to as impulse, is determined by and is obtained from: Newton s 2 nd Law of motion states that the action
Διαβάστε περισσότεραBounding Nonsplitting Enumeration Degrees
Bounding Nonsplitting Enumeration Degrees Thomas F. Kent Andrea Sorbi Università degli Studi di Siena Italia July 18, 2007 Goal: Introduce a form of Σ 0 2-permitting for the enumeration degrees. Till now,
Διαβάστε περισσότεραMATH423 String Theory Solutions 4. = 0 τ = f(s). (1) dτ ds = dxµ dτ f (s) (2) dτ 2 [f (s)] 2 + dxµ. dτ f (s) (3)
1. MATH43 String Theory Solutions 4 x = 0 τ = fs). 1) = = f s) ) x = x [f s)] + f s) 3) equation of motion is x = 0 if an only if f s) = 0 i.e. fs) = As + B with A, B constants. i.e. allowe reparametrisations
Διαβάστε περισσότεραSpace-Time Symmetries
Chapter Space-Time Symmetries In classical fiel theory any continuous symmetry of the action generates a conserve current by Noether's proceure. If the Lagrangian is not invariant but only shifts by a
Διαβάστε περισσότεραSecond Order RLC Filters
ECEN 60 Circuits/Electronics Spring 007-0-07 P. Mathys Second Order RLC Filters RLC Lowpass Filter A passive RLC lowpass filter (LPF) circuit is shown in the following schematic. R L C v O (t) Using phasor
Διαβάστε περισσότεραThe challenges of non-stable predicates
The challenges of non-stable predicates Consider a non-stable predicate Φ encoding, say, a safety property. We want to determine whether Φ holds for our program. The challenges of non-stable predicates
Διαβάστε περισσότεραω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω
0 1 2 3 4 5 6 ω ω + 1 ω + 2 ω + 3 ω + 4 ω2 ω2 + 1 ω2 + 2 ω2 + 3 ω3 ω3 + 1 ω3 + 2 ω4 ω4 + 1 ω5 ω 2 ω 2 + 1 ω 2 + 2 ω 2 + ω ω 2 + ω + 1 ω 2 + ω2 ω 2 2 ω 2 2 + 1 ω 2 2 + ω ω 2 3 ω 3 ω 3 + 1 ω 3 + ω ω 3 +
Διαβάστε περισσότεραΧρειάζεται να φέρω μαζί μου τα πρωτότυπα έγγραφα ή τα αντίγραφα; Asking if you need to provide the original documents or copies Ποια είναι τα κριτήρια
- University Θα ήθελα να εγγραφώ σε πανεπιστήμιο. Stating that you want to enroll Θα ήθελα να γραφτώ για. Stating that you want to apply for a course ένα προπτυχιακό ένα μεταπτυχιακό ένα διδακτορικό πλήρους
Διαβάστε περισσότεραHomework 8 Model Solution Section
MATH 004 Homework Solution Homework 8 Model Solution Section 14.5 14.6. 14.5. Use the Chain Rule to find dz where z cosx + 4y), x 5t 4, y 1 t. dz dx + dy y sinx + 4y)0t + 4) sinx + 4y) 1t ) 0t + 4t ) sinx
Διαβάστε περισσότεραSUPERPOSITION, MEASUREMENT, NORMALIZATION, EXPECTATION VALUES. Reading: QM course packet Ch 5 up to 5.6
SUPERPOSITION, MEASUREMENT, NORMALIZATION, EXPECTATION VALUES Readig: QM course packet Ch 5 up to 5. 1 ϕ (x) = E = π m( a) =1,,3,4,5 for xa (x) = πx si L L * = πx L si L.5 ϕ' -.5 z 1 (x) = L si
Διαβάστε περισσότεραDESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.
DESIGN OF MACHINERY SOLUTION MANUAL -7-1! PROBLEM -7 Statement: Design a double-dwell cam to move a follower from to 25 6, dwell for 12, fall 25 and dwell for the remader The total cycle must take 4 sec
Διαβάστε περισσότεραChap. 6 Pushdown Automata
Chap. 6 Pushdown Automata 6.1 Definition of Pushdown Automata Example 6.1 L = {wcw R w (0+1) * } P c 0P0 1P1 1. Start at state q 0, push input symbol onto stack, and stay in q 0. 2. If input symbol is
Διαβάστε περισσότεραExercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.
Exercises 0 More exercises are available in Elementary Differential Equations. If you have a problem to solve any of them, feel free to come to office hour. Problem Find a fundamental matrix of the given
Διαβάστε περισσότερα[1] P Q. Fig. 3.1
1 (a) Define resistance....... [1] (b) The smallest conductor within a computer processing chip can be represented as a rectangular block that is one atom high, four atoms wide and twenty atoms long. One
Διαβάστε περισσότεραFinitary proof systems for Kozen s µ
Finitary proof systems for Kozen s µ Bahareh Afshari Graham Leigh TU Wien University of Gothenburg homc & cdps 16, Singapore 1 / 17 Modal µ-calculus Syntax: p p φ ψ φ ψ φ φ x µx φ νx φ Semantics: For Kripke
Διαβάστε περισσότεραFractional Colorings and Zykov Products of graphs
Fractional Colorings and Zykov Products of graphs Who? Nichole Schimanski When? July 27, 2011 Graphs A graph, G, consists of a vertex set, V (G), and an edge set, E(G). V (G) is any finite set E(G) is
Διαβάστε περισσότερα9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr
9.9 #. Area inside the oval limaçon r = + cos. To graph, start with = so r =. Compute d = sin. Interesting points are where d vanishes, or at =,,, etc. For these values of we compute r:,,, and the values
Διαβάστε περισσότεραλρ-calculus 1. each λ-variable is a λρ-term, called an atom or atomic term; 2. if M and N are λρ-term then (MN) is a λρ-term called an application;
λρ-calculus Yuichi Komori komori@math.s.chiba-u.ac.jp Department of Mathematics, Faculty of Sciences, Chiba University Arato Cho aratoc@g.math.s.chiba-u.ac.jp Department of Mathematics, Faculty of Sciences,
Διαβάστε περισσότεραΣυντακτικές λειτουργίες
2 Συντακτικές λειτουργίες (Syntactic functions) A. Πτώσεις και συντακτικές λειτουργίες (Cases and syntactic functions) The subject can be identified by asking ποιος (who) or τι (what) the sentence is about.
Διαβάστε περισσότεραProving with Computer Assistance Lecture 2. Herman Geuvers
Proving with Computer Assistance Lecture 2 Herman Geuvers 1 Typed λ calculus as the basis for a Proof Assistant (e.g. Coq) λ-term program proof type specification formula Integrated system for proving
Διαβάστε περισσότεραRewrite semantics for guarded recursion with universal quantification over clocks
Rewrite semantics for guarded recursion with universal quantification over clocks (Work in progress) Aleš Bizjak 1 Rasmus Møgelberg 2 1 Aarhus University 2 IT University of Copenhagen May 18, 2015 Overview
Διαβάστε περισσότεραNumerical Analysis FMN011
Numerical Analysis FMN011 Carmen Arévalo Lund University carmen@maths.lth.se Lecture 12 Periodic data A function g has period P if g(x + P ) = g(x) Model: Trigonometric polynomial of order M T M (x) =
Διαβάστε περισσότεραΕγχειρίδια Μαθηµατικών και Χταποδάκι στα Κάρβουνα
[ 1 ] Πανεπιστήµιο Κύπρου Εγχειρίδια Μαθηµατικών και Χταποδάκι στα Κάρβουνα Νίκος Στυλιανόπουλος, Πανεπιστήµιο Κύπρου Λευκωσία, εκέµβριος 2009 [ 2 ] Πανεπιστήµιο Κύπρου Πόσο σηµαντική είναι η απόδειξη
Διαβάστε περισσότεραTridiagonal matrices. Gérard MEURANT. October, 2008
Tridiagonal matrices Gérard MEURANT October, 2008 1 Similarity 2 Cholesy factorizations 3 Eigenvalues 4 Inverse Similarity Let α 1 ω 1 β 1 α 2 ω 2 T =......... β 2 α 1 ω 1 β 1 α and β i ω i, i = 1,...,
Διαβάστε περισσότερα