• Aucun résultat trouvé

Exercises on λ -calculus and Deduction Systems

N/A
N/A
Protected

Academic year: 2022

Partager "Exercises on λ -calculus and Deduction Systems"

Copied!
7
0
0

Texte intégral

(1)

Exercises on λ -calculus and Deduction Systems

Akim Demaille akim@lrde.epita.fr

EPITA — École Pour l’Informatique et les Techniques Avancées

June 14, 2016

Exercises on λ-calculus and Deduction Systems

1

λ-calculus

2

Deduction Systems

A. Demaille Exercises onλ-calculus and Deduction Systems 2 / 27

λ-calculus

1

λ-calculus

Untyped λ-calculus Simply Typed λ-calculus

2

Deduction Systems

Untyped λ-calculus

1

λ-calculus

Untyped λ-calculus Simply Typed λ-calculus

2

Deduction Systems

(2)

Substitutions

[λz · zz/x]λy · xy ≡ λy · (λz · zz)y [yy /z ](λxy · zy ) ≡ λxu · yyu

A. Demaille Exercises onλ-calculus and Deduction Systems 5 / 27

β -Reductions

(λx · xyx)λz · z → (λz · z )y(λz · z ) (λx · x)((λy · y )x ) → (λx · x)(x) (λx · x)((λy · y )x ) → ((λy · y)x) (λx · x)((λy · y )x ) →

x

(λx · xx )((λx · xx )y ) →

yy (yy ) (λx · xx )((λx · x )y ) →

yy (λx · x)((λx · xx )y ) →

yy

A. Demaille Exercises onλ-calculus and Deduction Systems 6 / 27

Simply Typed λ-calculus

1

λ-calculus

Untyped λ-calculus Simply Typed λ-calculus

2

Deduction Systems

A. Demaille Exercises onλ-calculus and Deduction Systems 7 / 27

Simply Typed λ-calculus

Type derivations are trees built from the following nodes.

M : σ → τ N : σ MN : τ

[x : σ]

·· · M : τ λx · M : σ → τ

A. Demaille Exercises onλ-calculus and Deduction Systems 8 / 27

(3)

Type Statements

Typeλfx·f(fx)

` λfx · f (fx ) : (σ → σ) → σ → σ

[f : σ → σ]

(2)

[f : σ → σ]

(2)

[x : σ]

(1)

fx : σ

f (fx) : σ λx · f (fx ) : σ → σ (1) λfx · f (fx ) : (σ → σ) → σ → σ (2)

A. Demaille Exercises onλ-calculus and Deduction Systems 9 / 27

Type Statements

Typeλxy·x

` λxy · x : σ → τ → σ

[x : σ]

(1)

λy · x : τ → σ λxy · x : σ → τ → σ (1)

A. Demaille Exercises onλ-calculus and Deduction Systems 10 / 27

Deduction Systems

1

λ-calculus

2

Deduction Systems Natural Deduction Sequent Calculus

Natural Deduction

1

λ-calculus

2

Deduction Systems

Natural Deduction

Sequent Calculus

(4)

Intuitionistic Natural Deduction

[A] ·· ·

B ⇒I A ⇒ B

A A ⇒ B B ⇒E

⊥ ⊥E

A ¬ A := A ⇒ ⊥

A B ∧I A ∧ B

A ∧ B

∧ l E A

A ∧ B

∧ r E B

A ∨ l I A ∨ B

B ∨ r I

A ∨ B A ∨ B [A] ·· ·

C

[B] ·· ·

C ∨E C

A. Demaille Exercises onλ-calculus and Deduction Systems 13 / 27

Prove A ∧ B ⇒ B ∧ A

[A ∧ B ]

1

∧ r E B

[A ∧ B]

1

∧ l E A ∧I B ∧ A

⇒I

1

A ∧ B ⇒ B ∧ A

A. Demaille Exercises onλ-calculus and Deduction Systems 14 / 27

Prove A ∧ (B ∨ C ) ` (A ∧ B ) ∨ (A ∧ C )

A∧(B∨C)

∧rE B∨C

A∧(B∨C)

∧lE A [B]1

A∧B ∧I

∨lI (A∧B)∨(A∧C)

A∧(B∨C)

∧lE

A [C]1

A∧C ∧I

∨rI (A∧B)∨(A∧C)

∨E

1

(A ∧ B) ∨ (A ∧ C )

A. Demaille Exercises onλ-calculus and Deduction Systems 15 / 27

Prove (A ⇒ A) ⇒ A ⇒ A (LOFO-2005)

Remember, ⇒ is right-associative.

[A]

2

[A ⇒ A]

1

A ⇒E

⇒I

2

A ⇒ A

⇒I

1

(A ⇒ A) ⇒ A ⇒ A

[A]

1

⇒I

1

A ⇒ A (A ⇒ A) ⇒ A ⇒ A ⇒I

[A ⇒ A]

1

⇒I

1

(A ⇒ A) ⇒ A ⇒ A

A. Demaille Exercises onλ-calculus and Deduction Systems 16 / 27

(5)

Prove A ⇒ B , B ⇒ C ` A ⇒ (B ∧ C ) (LOFO-2005)

[A]

1

A ⇒ B B ⇒E

[A]

1

A ⇒ B

B ⇒E B ⇒ C

C ⇒E B ∧ C ∧I

⇒I

1

A ⇒ (B ∧ C )

A. Demaille Exercises onλ-calculus and Deduction Systems 17 / 27

Prove A ∨ B , ¬ B ` A (Intuitionistic) (LOFO-2005)

Recall that ¬ B := B ⇒ ⊥ .

A ∨ B [A]

1

[B ]

1

B ⇒ ⊥

⊥ ⇒E A ⊥E

∨E

1

A

A. Demaille Exercises onλ-calculus and Deduction Systems 18 / 27

Sequent Calculus

1

λ-calculus

2

Deduction Systems Natural Deduction Sequent Calculus

Classical Sequent Calculus

Γ`∆

`X Γ`τ(∆)

Γ`∆ X`

σ(Γ)`∆

Γ`∆

`W Γ`A,∆

Γ`∆ W` Γ,A`∆

Γ`A,A,∆

`C Γ`A,∆

Γ,A,A`∆ C` Γ,A`∆

Id F `F

Γ`A,∆ Γ0,A`∆0 Cut Γ,Γ0`∆,∆0 Γ,A`∆

` ¬ Γ` ¬A,∆

Γ`A,∆

¬ ` Γ,¬A`∆ Γ`A,∆ Γ`B,∆

` ∧ Γ`A∧B,∆

Γ,A`∆ l∧ ` Γ,A∧B`∆

Γ,B`∆ r∧ ` Γ,A∧B`∆ Γ`A,∆ Γ`B,∆ Γ,A`∆ Γ,B`∆

(6)

Prove A ∧ B ` A ∧ B

A ` A l ∧`

A ∧ B ` A

B ` B

r ∧`

A ∧ B ` B A ∧ B ` A ∧ B `∧

A. Demaille Exercises onλ-calculus and Deduction Systems 21 / 27

Prove A ∧ B ` A ∨ B

A ` A l ∧`

A ∧ B ` A

` r ∨ A ∧ B ` A ∨ B

A. Demaille Exercises onλ-calculus and Deduction Systems 22 / 27

Prove A ∨ B ` A ∨ B

A ` A

` l ∨ A ` A ∨ B

B ` B

` r ∨ B ` A ∨ B A ∨ B ` A ∨ B ∨`

A. Demaille Exercises onλ-calculus and Deduction Systems 23 / 27

Prove (F ∧ G ) ⇒ H ` (F ⇒ H ) ∨ (G ⇒ H )

F ` F W ` F , G ` F

G ` G W ` F , G ` G

F , G ` F ∧ G `∧ H ` H F, G , (F ∧ G ) ⇒ H ` H ⇒`

` W F , G , (F ∧ G ) ⇒ H ` H, H F , (F ∧ G ) ⇒ H ` H , G ⇒ H `⇒

(F ∧ G ) ⇒ H ` F ⇒ H, G ⇒ H `⇒

` r ∨ (F ∧ G ) ⇒ H ` (F ⇒ H) ∨ (G ⇒ H), G ⇒ H

` l ∨ (F ∧ G ) ⇒ H ` (F ⇒ H) ∨ (G ⇒ H), (F ⇒ H) ∨ (G ⇒ H)

` C (F ∧ G ) ⇒ H ` (F ⇒ H) ∨ (G ⇒ H )

A. Demaille Exercises onλ-calculus and Deduction Systems 24 / 27

(7)

Prove (A ⇒ A) ⇒ A ⇒ A (LOFO-2005)

A ` A A ` A A, A ⇒ A ` A ⇒`

A ⇒ A ` A ⇒ A `⇒

` (A ⇒ A) ⇒ A ⇒ A `⇒

A. Demaille Exercises onλ-calculus and Deduction Systems 25 / 27

Prove A ⇒ B , B ⇒ C ` A ⇒ (B ∧ C ) (LOFO-2005)

A ` A B ` B A, A ⇒ B ` B ⇒`

W ` A, A ⇒ B , B ⇒ C ` B

A ` A C ` C A, B ⇒ C ` C ⇒`

W ` A, A ⇒ B, B ⇒ C ` C A, A ⇒ B, A, B ⇒ C ` B ∧ C ∧`

C ` A, A ⇒ B , B ⇒ C ` B ∧ C

A. Demaille Exercises onλ-calculus and Deduction Systems 26 / 27

Prove A ∨ B , ¬ B ` A (Classical) (LOFO-2005)

A ` A W ` A, ¬ B ` A

B ` B

` W B ` B, A B , ¬ B ` A `¬

A ∨ B, ¬ B ` A ∨`

Références

Documents relatifs

Stop considering anything can be applied to anything A function and its argument have different

EPITA — École Pour l’Informatique et les Techniques Avancées. June

Stop considering anything can be applied to anything A function and its argument have different behaviors.. Demaille Simply Typed λ-Calculus 12

EPITA — École Pour l’Informatique et les Techniques Avancées.. June

2. A crucial tool, in this approach, is the notion of storage operator, to be defined later. As is well known, in call-by-name λ-calculus, a function must compute its argument

Abstraction is always binary: the names (or atoms) a that appear on the left-hand side are bound, and their scope is the expression e that appears on the right-hand side.... A

We then gave a type system that enables the static inference of the trustworthiness of values and the type system was proved to have the Subject Reduction property with respect to

Success approaches: normalisation by evaluation and category-theoretic models of