1 / 46

# TYPE THEORY * - PowerPoint PPT Presentation

TYPE THEORY *. Zoltán Csörnyei Eötvös University Department of General Computer Science Budapest, Hungary csz@inf.elte.hu * Supported by OTKA T037742. Preliminaries I. LOGIC • Aristotle (384 BC – 322 BC). Aristotle.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'TYPE THEORY *' - cadee

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### TYPE THEORY *

Zoltán Csörnyei

Eötvös University

Department of General Computer Science

Budapest, Hungary

csz@inf.elte.hu

* Supported by OTKA T037742

LOGIC

• Aristotle (384 BC – 322 BC)

Aristotle proposed the now famous Aristotelian syllogistic, form of argument consisting of two premises and a conclusion. His example is:

(i)Every Greek is a person.

(ii) Every person is mortal.

(iii) Every Greek is mortal.

Ockham's Razor:

• Frustra fit per plura, quod fieri potest per pauciora.It is vain to do with more what can be done with less.orEssentia non sunt multiplicanda praeter necessitatem.Entities should not be multiplied unnecessarily.

• He considered a three valued logic where propositions can take one of three truth values. This became important for mathematics in the 20th Century but it is remarkable that it was first studied by Ockham 600 years earlier.

• one of the founders of modern symbolic logic

He was the first to fully develop the main thesis of logicism, that mathematics is reducible to logic.

( The Russell paradox gave contradiction in Frege's system of axioms. )

• Axioms

1. |- A  A

2. |- A  (B  A)

3. |- (A  (BC))  ((A B)  A  C))

4. |- A  B |- A

---------------------

|- B

• He introduced the notion of

'logical consequence'

B1, B2, …, B n |- A

• Natural deduction

• Sequent calculus

• Derivation tree

• The foundations of intuitionism.

• Judgements about statements are based on the existence of a proof or construction of that statements.

• There are two irrational numbers x and y, such that xy is rational.

• The untyped combinatory logics

Schönfinkel, 1924

• The untyped lambda calculus

Church, 1934

• Turing machines

Turing, 1936

• expr ::= var

| K | S

| ( expr expr )

• reductions

K x y  x

S x y z  x z ( y z )

• normal form

• True K

false  K I I  S K K

• if E F G  E F G

and E F  E F false

or E F  E true F

not E  E false true

• natural numbers

n  ( S B )n ( K I ) B E F G  E (F G)

• succ  S B C E F G  E G F

zero  C (CI ( true false))true

• add E F  S’ B’ E F S’CEFG  C(EG)(FG)

mul E F  B’ E F B’CEFG  CE(FG)

exp E F  F E

• Definable functions:

partial recursive numerical function

(Kleene, 1936.)

• expr ::= var

| λ var . expr

| ( expr expr )

• reductions

(λ x . E1) E2β E1 [ x := E2 ]

λ x . Eλ y . E [ x := y]

λ x . E x E

• true λ xy.x

false  λ xy.y

• if  λ xyz.xyz

and λ xy.xy false

or λ xy.x true y

not λ x.x false true

• natural numbers

n  λ fx . f n(x)

• succ λ nfx . f ( nfx )

zero  λ x . x ( true false ) true

• add λ xypq . xp ( ypq )

mul  λ xyp . x ( yp )

exp  λ xy . yx

• Definable functions:

partial recursive numerical function

(undefinedunsolvable)

solvable: F, (λ x.E) F = I

(Kleene, 1936., Wadsworth, 1971.)

• Turing Theorem (1936.)

combinatory logics 

lambda calculus 

Turing machine

• Formal Type System: ( S, J, R )

S syntax, J judgements, R rules

• Type environment Γ

• Rule

Γ |- I1 … Γ |- In

---------------------------

Γ |- I

• type ::= basic_type

| type  type

• expr ::= var

| λvar : type . expr

| ( expr expr )

„type checking”

(Pascal, C++, …)

Rules ( F1 )

Γ , x:A , Γ’ |- wf

• ------------------------- [Val x]

Γ , x:A , Γ’ |- x:A

Γ , x:A |- E : B

• ----------------------------- [Val Fun]

Γ |- λ:A . E : A  B

Γ |- E : A  B Γ |- F : A

• ------------------------------------- [Val Appl]

Γ |- E F : B

Theorems ( F1 )

• Type preservation

If E : A and E ->> F then F : A .

• Type unumbigouos

If Γ|- E : A andΓ|- E : B then A  B .

• Finite reductions

thereisno infinite reduction sequence.

• (Schwichtenberg, 1976.)

The lambda definable functions are

exactly the extended polinomials.

• constant functions, projections, signum

(Type System F1 / Curry)

• type ::= type_var

| type  type

• expr ::= var

| λvar . expr

| ( expr expr )

„type inference”

• Id-Nat λx : Nat . x

Id-Bool λx : Bool . x

Id-Int λx : Int. x

• Id-λx :  . x

Id  . λx :  . x polimorphic function

• Id :  .  type ofpolimorphic function

Type System F2 II.

• type ::= type_var

| type  type

| type_var. type

• expr ::= var

| var : type . expr

| ( expr expr )

|  type_var. expr

| ( expr ) [ type ]

Type System F2 III.

• Id [ Nat ]  (. x :  . x)[ Nat ] β

x : Nat . x : NatNat

• Type of Id [ Nat ] ?

 .  

• type of type-expression kind

• *  type of types of expressions

• kind ::= *

| (*  kind )

• type ::= type_var

| type  type

| type_var: kind . type

| type_var: kind . type

| ( type type )

Type System F4,F5,...

• F4 kind ::= *

| (*  kind )

| ( kind  *)

• F5 kind ::= *

| (*  kind )

| ( kind  *)

| ((*  * ) kind )

• F =  Fi

• kind ::= *

| ( kind  kind )

Extension of Type System, F I.

• F (F-omega-sub)

subtyping

• Top

• type  Top

• type_var type . expr

Extension of Type System, F II.

• Subtyping

Γ |- E : A Γ |- A  B

• -------------------------------- [Subsumption]

Γ |- E : B

Γ |- A  BΓ |- C  D

• ------------------------------------- [Sub Arrow]

Γ |- B  C  A  D

Extension of Type System, F III.

• Existential type

• .A

pack, unpack (open)

• Recursive type

• .A

fold, unfold

• class of functions definiable in F

is much larger than the primitive recursive

functions.

• Ackermann’s function is definiable.

• Isomorphism between

combinators Hilbert’s axioms

1. x.x |- A  A

2. xy.x |- A  (B  A)

3. xyz.xz(yz) |- (A(BC))((AB)(AC))

4. function |- A  B |- A

application --------------------

|- B

The Curry-Howard isomorphism(Howard, 1959.)

• isomorphism between

lambda calculus intuitive prop.logic

term variable assumption

term proof

type formula

type constructor connective

reduction normalization

… …