Untyped Normalization-by-Evaluation Klaus Aehlig Felix - - PowerPoint PPT Presentation

untyped normalization by evaluation
SMART_READER_LITE
LIVE PREVIEW

Untyped Normalization-by-Evaluation Klaus Aehlig Felix - - PowerPoint PPT Presentation

Untyped Normalization-by-Evaluation Klaus Aehlig Felix Joachimski Mathematisches Institut LMU M unchen { aehlig , joachski } @mathematik.uni-muenchen.de Tallinn, 17.4.4 Klaus Aehlig and Felix Joachimski. Operational


slide-1
SLIDE 1

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 1

✤ ✣ ✜ ✢

Untyped Normalization-by-Evaluation

Klaus Aehlig Felix Joachimski Mathematisches Institut LMU M¨ unchen

{aehlig,joachski}@mathematik.uni-muenchen.de

Tallinn, 17.4.4

Klaus Aehlig and Felix Joachimski. Operational aspects of untyped normalization by evaluation. Accepted by Mathematical Structures in Computer Science, 2003. http://www.mathematik.uni-muenchen.de/˜aehlig

slide-2
SLIDE 2

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 2

Motivation

✬ ✫ ✩ ✪

[[·]]ξ : Terms − → Semantics (evaluation function) ↓ : Semantics − → Normal forms (inverse) ↑ : Variables − → Semantics (valuation) ✄ Soundness: r → s ⇒ [[r]]ξ = [[s]]ξ ✄ Reproduction: r in normal form ⇒ ↓[[r]]↑ = r

slide-3
SLIDE 3

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 2

Motivation

✬ ✫ ✩ ✪

[[·]]ξ : Terms − → Semantics (evaluation function) ↓ : Semantics − → Normal forms (inverse) ↑ : Variables − → Semantics (valuation) ✄ Soundness: r → s ⇒ [[r]]ξ = [[s]]ξ ✄ Reproduction: r in normal form ⇒ ↓[[r]]↑ = r r =β s ∈ NFβ

slide-4
SLIDE 4

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 2

Motivation

✬ ✫ ✩ ✪

[[·]]ξ : Terms − → Semantics (evaluation function) ↓ : Semantics − → Normal forms (inverse) ↑ : Variables − → Semantics (valuation) ✄ Soundness: r → s ⇒ [[r]]ξ = [[s]]ξ ✄ Reproduction: r in normal form ⇒ ↓[[r]]↑ = r r =β s ∈ NFβ = ⇒ r →∗ s

slide-5
SLIDE 5

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 2

Motivation

✬ ✫ ✩ ✪

[[·]]ξ : Terms − → Semantics (evaluation function) ↓ : Semantics − → Normal forms (inverse) ↑ : Variables − → Semantics (valuation) ✄ Soundness: r → s ⇒ [[r]]ξ = [[s]]ξ ✄ Reproduction: r in normal form ⇒ ↓[[r]]↑ = r r =β s ∈ NFβ = ⇒ r →∗ s = ⇒ ↓[[r]]↑

slide-6
SLIDE 6

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 2

Motivation

✬ ✫ ✩ ✪

[[·]]ξ : Terms − → Semantics (evaluation function) ↓ : Semantics − → Normal forms (inverse) ↑ : Variables − → Semantics (valuation) ✄ Soundness: r → s ⇒ [[r]]ξ = [[s]]ξ ✄ Reproduction: r in normal form ⇒ ↓[[r]]↑ = r r =β s ∈ NFβ = ⇒ r →∗ s = ⇒ ↓[[r]]↑ = ↓[[s]]↑

slide-7
SLIDE 7

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 2

Motivation

✬ ✫ ✩ ✪

[[·]]ξ : Terms − → Semantics (evaluation function) ↓ : Semantics − → Normal forms (inverse) ↑ : Variables − → Semantics (valuation) ✄ Soundness: r → s ⇒ [[r]]ξ = [[s]]ξ ✄ Reproduction: r in normal form ⇒ ↓[[r]]↑ = r r =β s ∈ NFβ = ⇒ r →∗ s = ⇒ ↓[[r]]↑ = ↓[[s]]↑ = s

slide-8
SLIDE 8

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types

slide-9
SLIDE 9

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]]

slide-10
SLIDE 10

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X

slide-11
SLIDE 11

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new

slide-12
SLIDE 12

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR

slide-13
SLIDE 13

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx)

slide-14
SLIDE 14

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]).

slide-15
SLIDE 15

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S

slide-16
SLIDE 16

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S = (λ λX ↑σ(r↓ρX))S

slide-17
SLIDE 17

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S = (λ λX ↑σ(r↓ρX))S = ↑σ(r↓ρS).

slide-18
SLIDE 18

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S = (λ λX ↑σ(r↓ρX))S = ↑σ(r↓ρS). ↓ι↑ιr

slide-19
SLIDE 19

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 3

Example — The typed λ-calculus

✄ Terms: Λ with simple types ✄ Semantics: [[ι]] := NFι, [[ρ → σ]] := [[ρ]] → [[σ]] ✄ Evaluation: [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λ λX[[r]]ξ,x:=X ✄ ↑ρ : {x r | r normal} → [[ρ]] and ↓ρ : [[ρ]] → NFρ

★ ✧ ✥ ✦

↑ιr := r, ↑ρ→σr := λ λX ↑σ(r ↓ρX), ↓ιr := r, ↓ρ→σR := λx ↓σ(R ↑ρx), x new ✄ Properties: ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S = (λ λX ↑σ(r↓ρX))S = ↑σ(r↓ρS). ↓ι↑ιr = r.

slide-20
SLIDE 20

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 4

From properties to axioms

✄ Properties. ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S = (λ λX ↑σ(r↓ρX))S = ↑σ(r↓ρS). ↓ι↑ιr = r.

slide-21
SLIDE 21

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 4

From properties to axioms

✄ Properties. ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S = (λ λX ↑σ(r↓ρX))S = ↑σ(r↓ρS). ↓ι↑ιr = r.

✓ ✒ ✏ ✑

Discard types — we only need to know whether function or not

slide-22
SLIDE 22

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 4

From properties to axioms

✄ Properties. ↓ρ→σλ λXR = λx ↓σ( (λ λXR)↑ρx) = λx ↓σ(R[X := ↑ρx]). (↑ρ→σr)S = (λ λX ↑σ(r↓ρX))S = ↑σ(r↓ρS). ↓ι↑ιr = r.

✓ ✒ ✏ ✑

Discard types — we only need to know whether function or not ✄ Axioms. ↓λ λXR = λx ↓(R[X := ↑x]). (↑r)S = ↑(r↓S). ↓↑r = r.

slide-23
SLIDE 23

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 5

(Just another) 2-level-calculus

✄ Terms. Λ ∋ r, s, t ::= x | rs | λxr,

slide-24
SLIDE 24

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 5

(Just another) 2-level-calculus

✄ Terms. Λ ∋ r, s, t ::= x | rs | λxr, Λ1 ∋ r, s, t ::= x | rs | λxr

slide-25
SLIDE 25

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 5

(Just another) 2-level-calculus

✄ Terms. Λ ∋ r, s, t ::= x | rs | λxr, Λ1 ∋ r, s, t ::= x | rs | λxr | ↓R

slide-26
SLIDE 26

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 5

(Just another) 2-level-calculus

✄ Terms. Λ ∋ r, s, t ::= x | rs | λxr, Λ1 ∋ r, s, t ::= x | rs | λxr | ↓R Λ2 ∋ R, S, T ::= X | RS | λXR

slide-27
SLIDE 27

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 5

(Just another) 2-level-calculus

✄ Terms. Λ ∋ r, s, t ::= x | rs | λxr, Λ1 ∋ r, s, t ::= x | rs | λxr | ↓R Λ2 ∋ R, S, T ::= X | RS | λXR | ↑r

slide-28
SLIDE 28

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 5

(Just another) 2-level-calculus

✄ Terms. Λ ∋ r, s, t ::= x | rs | λxr, Λ1 ∋ r, s, t ::= x | rs | λxr | ↓R Λ2 ∋ R, S, T ::= X | RS | λXR | ↑r ✄ Reductions. (λXR)S →β R[X := S] (↑r)S →a ↑(r↓S) ↓λXR →d λx↓(R[X := ↑x]), x new ↓↑r →d r

slide-29
SLIDE 29

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 5

(Just another) 2-level-calculus

✄ Terms. Λ ∋ r, s, t ::= x | rs | λxr, Λ1 ∋ r, s, t ::= x | rs | λxr | ↓R Λ2 ∋ R, S, T ::= X | RS | λXR | ↑r ✄ Reductions. (λXR)S →β R[X := S] (↑r)S →a ↑(r↓S) ↓λXR →d λx↓(R[X := ↑x]), x new ↓↑r →d r ✄ This yields an orthogonal higher order rewrite system ⇒ confluence.

slide-30
SLIDE 30

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X.

slide-31
SLIDE 31

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ.

slide-32
SLIDE 32

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ

slide-33
SLIDE 33

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ]

slide-34
SLIDE 34

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ

slide-35
SLIDE 35

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ

slide-36
SLIDE 36

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑

slide-37
SLIDE 37

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑)

slide-38
SLIDE 38

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑)

slide-39
SLIDE 39

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑

slide-40
SLIDE 40

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑ →∗

s x

r.

slide-41
SLIDE 41

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑ →∗

s x

r. ↓[[λxr]]↑

slide-42
SLIDE 42

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑ →∗

s x

r. ↓[[λxr]]↑ = ↓λX.[[r]]↑,x:=X

slide-43
SLIDE 43

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑ →∗

s x

r. ↓[[λxr]]↑ = ↓λX.[[r]]↑,x:=X →d λx↓[[r]]↑,x:=X[X := ↑x]

slide-44
SLIDE 44

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑ →∗

s x

r. ↓[[λxr]]↑ = ↓λX.[[r]]↑,x:=X →d λx↓[[r]]↑,x:=X[X := ↑x] = λx↓[[r]]↑

slide-45
SLIDE 45

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑ →∗

s x

r. ↓[[λxr]]↑ = ↓λX.[[r]]↑,x:=X →d λx↓[[r]]↑,x:=X[X := ↑x] = λx↓[[r]]↑ →∗

s λxr.

slide-46
SLIDE 46

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 6

Evaluation

✄ Definition. [[x]]ξ := ξx, [[rs]]ξ := [[r]]ξ[[s]]ξ, [[λxr]]ξ := λX.[[r]]ξ,x:=X. ✄ Simulation. r →β s = ⇒ [[r]]ξ →β [[s]]ξ. [[(λxr)s]]ξ = (λX[[r]]ξ,x:=X)[[s]]ξ →β [[r]]ξ,x:=X[X := [[s]]ξ] = [[r]]ξ,x:=[[s]]ξ = [[r[x := s]]]ξ ✄ Reproduction. ↓[[r]]↑ = r for normal forms r. ↓[[x r ]]↑ = ↓((↑x)[[ r ]]↑) →∗

a ↓↑(x↓[[

r ]]↑) →d x↓[[ r ]]↑ →∗

s x

r. ↓[[λxr]]↑ = ↓λX.[[r]]↑,x:=X →d λx↓[[r]]↑,x:=X[X := ↑x] = λx↓[[r]]↑ →∗

s λxr.

✄ Corollary. r =β s ∈ NFβ = ⇒ ↓[[r]]↑ →∗ s.

slide-47
SLIDE 47

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 7

Implementation: Object calculus

slide-48
SLIDE 48

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 7

Implementation: Object calculus

Choose de Bruijn terms for simplicity.

data Term = Var Integer | App Term Term | Abs Term deriving Show

slide-49
SLIDE 49

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 7

Implementation: Object calculus

Choose de Bruijn terms for simplicity.

data Term = Var Integer | App Term Term | Abs Term deriving Show

An interface to make lifting easy:

type TERM = Integer -> Term inspect :: TERM -> Term inspect f = f 0 freevar k = \ n -> Var (n + k) boundvar k = \ n -> Var (n - k - 1) apply r s = \ n -> App (r n) (s n) bind f = \ n -> Abs (f (boundvar n) (n + 1))

slide-50
SLIDE 50

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 8

Implementation — Metalevel calculus

Terms. ↑r | λXR | RS | X

slide-51
SLIDE 51

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 8

Implementation — Metalevel calculus

Terms. ↑r | λXR | RS | X

data LAM = Up TERM | ABS (LAM -> LAM)

slide-52
SLIDE 52

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 8

Implementation — Metalevel calculus

Terms. ↑r | λXR | RS | X

data LAM = Up TERM | ABS (LAM -> LAM)

Reductions for ↓: ↓↑r →d r ↓λXR →d λx↓(R[X := ↑x])

slide-53
SLIDE 53

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 8

Implementation — Metalevel calculus

Terms. ↑r | λXR | RS | X

data LAM = Up TERM | ABS (LAM -> LAM)

Reductions for ↓: ↓↑r →d r ↓λXR →d λx↓(R[X := ↑x])

down :: LAM -> TERM

  • - the d-rules

down (ABS f) = bind (\ x -> (down (f (Up x)))) down (Up r) = r

slide-54
SLIDE 54

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 8

Implementation — Metalevel calculus

Terms. ↑r | λXR | RS | X

data LAM = Up TERM | ABS (LAM -> LAM)

Reductions for ↓: ↓↑r →d r ↓λXR →d λx↓(R[X := ↑x])

down :: LAM -> TERM

  • - the d-rules

down (ABS f) = bind (\ x -> (down (f (Up x)))) down (Up r) = r

Reductions for application: (λXR)S →β R[X := S] (↑r)S →a ↑(r↓S)

slide-55
SLIDE 55

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 8

Implementation — Metalevel calculus

Terms. ↑r | λXR | RS | X

data LAM = Up TERM | ABS (LAM -> LAM)

Reductions for ↓: ↓↑r →d r ↓λXR →d λx↓(R[X := ↑x])

down :: LAM -> TERM

  • - the d-rules

down (ABS f) = bind (\ x -> (down (f (Up x)))) down (Up r) = r

Reductions for application: (λXR)S →β R[X := S] (↑r)S →a ↑(r↓S)

app :: LAM -> LAM -> LAM app (ABS f) r = f r

  • - the beta-rule

app (Up r) s = Up (apply r (down s))

  • - the a-rule
slide-56
SLIDE 56

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 9

Implementation — Evaluation

type Valuation = Integer -> LAM comma :: Valuation -> LAM -> Valuation comma xi r n = if n == 0 then r else xi (n - 1)

ξ, x := R

eval :: Term -> Valuation -> LAM eval (Var n) xi = xi n

ξx

eval (Abs r) xi = ABS (\ a -> eval r (xi ‘comma‘ a))

λX.[[r]]ξ,x:=X

eval (App r s) xi = (eval r xi) ‘app‘ (eval s xi)

[[r]]ξ[[s]]ξ

nbe r = inspect (down (eval r (Up . freevar)))

↓[[r]]↑

= (down (eval r (Up . freevar))) 0

slide-57
SLIDE 57

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 10

Implementation — Examples

k = Abs (Abs (Var 1))

k = λλ1

s = Abs (Abs (Abs (Var 2 ‘App‘ (Var 0) ‘App‘ (Var 1 ‘App‘ (Var 0))))) i = s ‘App‘ k ‘App‘ k

s = λλλ.20(10)

  • mega

= Abs (Var 0 ‘App‘ (Var 0))

ω = λ.00

  • omega = omega ‘App‘ omega

Ω = ωω

slide-58
SLIDE 58

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 10

Implementation — Examples

k = Abs (Abs (Var 1))

k = λλ1

s = Abs (Abs (Abs (Var 2 ‘App‘ (Var 0) ‘App‘ (Var 1 ‘App‘ (Var 0))))) i = s ‘App‘ k ‘App‘ k

s = λλλ.20(10)

  • mega

= Abs (Var 0 ‘App‘ (Var 0))

ω = λ.00

  • omega = omega ‘App‘ omega

Ω = ωω

Main> nbe k Abs (Abs (Var 1))

slide-59
SLIDE 59

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 10

Implementation — Examples

k = Abs (Abs (Var 1))

k = λλ1

s = Abs (Abs (Abs (Var 2 ‘App‘ (Var 0) ‘App‘ (Var 1 ‘App‘ (Var 0))))) i = s ‘App‘ k ‘App‘ k

s = λλλ.20(10)

  • mega

= Abs (Var 0 ‘App‘ (Var 0))

ω = λ.00

  • omega = omega ‘App‘ omega

Ω = ωω

Main> nbe k Abs (Abs (Var 1)) Main> nbe i Abs (Var 0)

slide-60
SLIDE 60

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 10

Implementation — Examples

k = Abs (Abs (Var 1))

k = λλ1

s = Abs (Abs (Abs (Var 2 ‘App‘ (Var 0) ‘App‘ (Var 1 ‘App‘ (Var 0))))) i = s ‘App‘ k ‘App‘ k

s = λλλ.20(10)

  • mega

= Abs (Var 0 ‘App‘ (Var 0))

ω = λ.00

  • omega = omega ‘App‘ omega

Ω = ωω

Main> nbe k Abs (Abs (Var 1)) Main> nbe i Abs (Var 0) Main> nbe (k ‘App‘ i ‘App‘ oomega) Abs (Var 0)

slide-61
SLIDE 61

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 11

Standardization

✄ Standard reduction. Head redexes are executed first or never.

slide-62
SLIDE 62

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 11

Standardization

✄ Standard reduction. Head redexes are executed first or never. ✄ Theorem. Reduction sequences can be standardized.

slide-63
SLIDE 63

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 11

Standardization

✄ Standard reduction. Head redexes are executed first or never. ✄ Theorem. Reduction sequences can be standardized. ✄ Corollary. Normalization (= reduction to normal form)

  • need not reduce under meta-abstractions,
  • may follow a call-by-name strategy.
slide-64
SLIDE 64

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 11

Standardization

✄ Standard reduction. Head redexes are executed first or never. ✄ Theorem. Reduction sequences can be standardized. ✄ Corollary. Normalization (= reduction to normal form)

  • need not reduce under meta-abstractions,
  • may follow a call-by-name strategy.

✄ Corollary. We can compute (the defined parts of) B¨

  • hm trees —

normalization for diverging terms.

slide-65
SLIDE 65

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 12

  • hm trees — Examples

pair = Abs (Abs (Abs (Var 0 ‘App‘ Var 2 ‘App‘ Var 1))) swap = Abs (Abs (Abs (Var 0 ‘App‘ Var 1 ‘App‘ Var 2)))

slide-66
SLIDE 66

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 12

  • hm trees — Examples

pair = Abs (Abs (Abs (Var 0 ‘App‘ Var 2 ‘App‘ Var 1))) swap = Abs (Abs (Abs (Var 0 ‘App‘ Var 1 ‘App‘ Var 2))) Main> nbe (pair ‘App‘ i ‘App‘ oomega) Abs (App (App (Var 0) (Abs (Var 0))) {Interrupted!}

slide-67
SLIDE 67

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 12

  • hm trees — Examples

pair = Abs (Abs (Abs (Var 0 ‘App‘ Var 2 ‘App‘ Var 1))) swap = Abs (Abs (Abs (Var 0 ‘App‘ Var 1 ‘App‘ Var 2))) Main> nbe (pair ‘App‘ i ‘App‘ oomega) Abs (App (App (Var 0) (Abs (Var 0))) {Interrupted!} Main> cut (nbe (pair ‘App‘ i ‘App‘ oomega)) ["01"] Abs (App (App (Var 0) (Abs (Var 0))) (Var (-1)))

slide-68
SLIDE 68

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 12

  • hm trees — Examples

pair = Abs (Abs (Abs (Var 0 ‘App‘ Var 2 ‘App‘ Var 1))) swap = Abs (Abs (Abs (Var 0 ‘App‘ Var 1 ‘App‘ Var 2))) Main> nbe (pair ‘App‘ i ‘App‘ oomega) Abs (App (App (Var 0) (Abs (Var 0))) {Interrupted!} Main> cut (nbe (pair ‘App‘ i ‘App‘ oomega)) ["01"] Abs (App (App (Var 0) (Abs (Var 0))) (Var (-1))) Main> nbe (pair ‘App‘ i ‘App‘ oomega ‘App‘ swap) Abs (App (App (Var 0) {Interrupted!}

slide-69
SLIDE 69

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 12

  • hm trees — Examples

pair = Abs (Abs (Abs (Var 0 ‘App‘ Var 2 ‘App‘ Var 1))) swap = Abs (Abs (Abs (Var 0 ‘App‘ Var 1 ‘App‘ Var 2))) Main> nbe (pair ‘App‘ i ‘App‘ oomega) Abs (App (App (Var 0) (Abs (Var 0))) {Interrupted!} Main> cut (nbe (pair ‘App‘ i ‘App‘ oomega)) ["01"] Abs (App (App (Var 0) (Abs (Var 0))) (Var (-1))) Main> nbe (pair ‘App‘ i ‘App‘ oomega ‘App‘ swap) Abs (App (App (Var 0) {Interrupted!} Main> cut (nbe (pair ‘App‘ i ‘App‘ oomega ‘App‘ swap)) ["001"] Abs (App (App (Var 0) (Var (-1))) (Abs (Var 0)))

slide-70
SLIDE 70

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 13

Types — Computing η-long normal forms

slide-71
SLIDE 71

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 13

Types — Computing η-long normal forms

✄ Head expansion. Instead of ↓↑r →d r define ↓↑rρ →d ηρr with ηιr := r and ηρ→σr := λx.ησ(rηρx).

slide-72
SLIDE 72

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 13

Types — Computing η-long normal forms

✄ Head expansion. Instead of ↓↑r →d r define ↓↑rρ →d ηρr with ηιr := r and ηρ→σr := λx.ησ(rηρx). ✄ Theorem. On typed terms → is SN and computes η-long normal forms. ✄ Corollary. Typed NBE (as defined in the beginning) is a model.

slide-73
SLIDE 73

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 14

Conclusions

✄ Normalization by Evaluation needs no types — the information of whether a function or not suffices. ✄ Non-termination: (partial) normal forms are found whenever they exist. ✄ Use Haskell for normalization (= doing the substitutions). ✄ Type-directed NBE as an example.

slide-74
SLIDE 74

Motivation Example Axioms 2-level Evaluation Object Meta eval skk Standardization B¨

  • hm Types Conclusions

Untyped Normalization by Evaluation Tallinn 17.4.4 15

Technical details

Theorem. r =β λ x(x r) & s →∗ ↓[[r]] = ⇒ ∃ t, s.s ։ λ x(x s ) & r =β t & s →∗ ↓[[ t ]]. Proof. r →∗

β λ

x(x t ) ∗

β← λ

x(x r ) by the Church-Rosser prop. of →β, s →∗ ↓[[r]] →∗ λ x(x↓[[ t ]]) s ❀ λ x(x↓[[ t ]]) by standardization, s ։ λ x(x s ) →∗ λ x(x↓[[ t ]]) property of ։.

  • Theorem. ↓[[t]] →∗ λ

x(x R) = ⇒ t →∗ λ x(x t ).