Strong Normalization by HOAS Andrei Popescu Joint work with Elsa - - PowerPoint PPT Presentation

strong normalization by hoas
SMART_READER_LITE
LIVE PREVIEW

Strong Normalization by HOAS Andrei Popescu Joint work with Elsa - - PowerPoint PPT Presentation

Strong Normalization by HOAS Andrei Popescu Joint work with Elsa Gunter Simply-typed -calculus - Syntax First-order syntax (up to ): Curry-style: no type annotations Data variables x, y, z, data terms X,Y, Z, data abstractions A,


slide-1
SLIDE 1

Strong Normalization by HOAS

Andrei Popescu Joint work with Elsa Gunter

slide-2
SLIDE 2

Simply-typed λ-calculus - Syntax

First-order syntax (up to α):

  • Curry-style: no type annotations
  • Data variables x, y, z, data terms X,Y, Z,

data abstractions A, B X ::= x | App X Y | Lam A A ::= x . X

  • Type variables tx, ty, tz, type terms tX, tY,

tZ, type abstractions tA, tB tX ::= tx | Arr tX tY

slide-3
SLIDE 3

β-reduction (of untyped λ-calculus)

App (Lam (x . Y)) X ~~> Y [X / x] (Beta) Y ~~> Y’

  • ---------------------------------------(Xi)

Lam (x . Y) ~~> Lam (x . Y’) X ~~> X’

  • -------------------------------(App-Left)

App X Y ~~> App X’ Y

slide-4
SLIDE 4

Typing

. Γ |- Y : tY

  • ------------------------- [x fresh Γ] -------------------------------[x fresh Γ]

Γ, x : tX |- x : tX (Asm) Γ, x : tX |- Y : tY (Weak)

Γ, x : tX |- Y : tY

  • --------------------------------------------- [x fresh Γ]

Γ |- Lam (x . Y) : Arr tX tY (Arr-I) Γ |- Z : Arr tX tY Γ |- X : tX

  • -----------------------------------------(Arr-E)

Γ |- App Z X : tY

slide-5
SLIDE 5

Abstractions as functions

  • FOAS definition/construction: A = (x . X)
  • HOAS treatment: A _ Y = A applied to Y,

defined to be X [Y / x]

  • May regard abstractions as forming a

subspace of Term  Term

  • This view accommodates a certain way to

represent inference relations

slide-6
SLIDE 6

HOAS representation of β-reduction

App (Lam (x . Y)) X ~~> Y [X / x] (Beta-FOAS) App (Lam A) X ~~> A _ X (Beta-HOAS) Y ~~> Y’

  • -------------------------------------(Xi-FOAS)

Lam (x . Y) ~~> Lam (x . Y’) ∀ X. A _ X ~~> A’ _ X

  • -----------------------------(Xi-HOAS)

Lam A ~~> Lam A’

slide-7
SLIDE 7

HOAS representation of typing

∀Γ - (typing) context, i.e., list of pairs (data variable, type term): x1 : tX1, …, xn : tXn

∀∆ - HOAS context, i.e., list of pairs

(data term, type term): X1 : tX1, …, Xn : tXn

  • Note: we close under substitution
slide-8
SLIDE 8

HOAS representation of typing

Γ, x : tX |- Y : tZ

  • ---------------------------------- [x fresh for Γ]

Γ |- Lam (x . Y) : Arr tX tZ (Arr-I-FOAS) ∀ X. ∆, X : tX ||- A _ X : tZ

  • ------------------------------------(Arr-I-HOAS)

∆ ||- Lam A : Arr tX tZ

slide-9
SLIDE 9

HOAS representation of typing

.

  • ------------------------- (Asm)

∆, X : tX ||- X : tX ∆ ||- Y : tY

  • -----------------------------(Weak)

∆, X : tX ||- Y : tY ∆ ||- Z : Arr tX tY ∆ ||- X : tX

  • ------------------------------------------(Arr-E)

∆ ||- App Z X : tY

slide-10
SLIDE 10

“Context-free” induction principle for typing

If H : data-term → type-term → bool s.t.:

∀ X. H X tX ⇒ H (A _ X) tZ

  • ----------------------------------------(ArrI-H)

H (Lam A) (Arr tX tZ)

etc., then ∀ X tX. [] ||- X : tX ⇒ H X tX (Higher degree of HOAS – not only bindings and substitution, but also inference contexts are pushed to the meta-level )

slide-11
SLIDE 11

Strong normalization

  • Termination: X is strongly terminating = all

reduction sequences X ~~> X’ ~~> X’’ ~~> … are finite

  • If confluence holds, then strongly terminating

means the existence of a unique normal form, hence the phrase strongly normalizating

  • The strong normalization property:

∀X. X typable ⇒ X strongly normalizing (X ∈ SN)

slide-12
SLIDE 12

Proof of strong normalization

Γ |- X : tX ⇒ X ∈ SN

slide-13
SLIDE 13

Proof of strong normalization

Difficulty Γ |- X : tX ⇒ X ∈ SN

slide-14
SLIDE 14

Proof of strong normalization

Difficulty Γ |- X : tX ⇒ X ∈ SN

Solution:

  • Strengthen the rhs of the goal
  • Integrate contexts into the goal’s statement
  • Give an SN-semantic interpretation to the

relation |-

  • Close everything under substitution in arbitrary

environments

slide-15
SLIDE 15

FOAS proof

  • Define [ _ ] : Tterm  P(SN)

– [ tX ] = SN – [ Arr tX tY ] = {Z. ∀ X ∈ [tX]. App Z X ∈ [tY] }

  • Define Γ |= X : tX to mean:

∀ ρ : Dvar  P(SN). (∀ (y : tY) ∈ Γ. ρ y ∈ [tY]) ⇒ ρ X ∈ [ρ tX]

  • Prove, by rule induction

Γ |- X : tX ⇒ Γ |= X : tX

slide-16
SLIDE 16

FOAS proof

  • Want: Γ, x : tX ||- Y : tY
  • -----------------------------------------[x fresh Γ]

Γ ||- Lam (x . Y) : Arr tX tY Assume the upper side. Fix ρ. Assume Γ ||- ρ. Want ρ (Lam (x . Y)) ∈ [Arr tX tY], i.e., Lam (x . ρ [x  x] Y) ∈ [Arr tX tY]. Fix X ∈ [tX]. Want App (Lam (x . ρ [x  x] Y)) X ∈ [tY] Since x fresh Γ, have Γ, x : tX ||- ρ[x  ρ X] . With IH, have ρ[x  ρ X] Y ∈ [ tY ], i.e., (ρ[x  x] Y) [X / x]) ∈ [ tY ].

slide-17
SLIDE 17

FOAS proof

  • Discovered: would suffice that:

Y [X / x] ∈ [ tY ] ⇒ App (Lam (x . Y)) X ∈ [tY]

  • A stronger version of this follows by

induction on the definition of [ _ ]

slide-18
SLIDE 18

HOAS proof

= Still define [ _ ] : Tterm  P(SN) + No environments, no typing contexts, no semantic consequence relation Want: ∀ X. X ∈ [tX] ⇒ A _ X ∈ [tY]

  • Lam A ∈ [Arr tX tY]

+ Discovered immediately: would suffice that:

A _ X ∈ [ tY ] ⇒ App (Lam A) X ∈ [tY]

= Again, a stronger version of this follows by induction on the definition of [ _ ]

  • Only in empty contexts proved (but extension immediate)