On Continuous Normalization Klaus Aehlig Felix Joachimski - - PowerPoint PPT Presentation

on continuous normalization
SMART_READER_LITE
LIVE PREVIEW

On Continuous Normalization Klaus Aehlig Felix Joachimski - - PowerPoint PPT Presentation

On Continuous Normalization Klaus Aehlig Felix Joachimski Mathematisches Institut LMU M unchen { aehlig | joachski } @mathematik.uni-muenchen.de CSL 2002 http://www.mathematik.uni-muenchen.de/ { aehlig | joachski } On


slide-1
SLIDE 1

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 1

✤ ✣ ✜ ✢

On Continuous Normalization

Klaus Aehlig Felix Joachimski Mathematisches Institut LMU M¨ unchen

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

CSL 2002

http://www.mathematik.uni-muenchen.de/˜{aehlig|joachski}

slide-2
SLIDE 2

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 2

Some history

  • Cut-elimination: a cut ¬A ∨ ¬B

A ∧ B ⊥ is replaced by cuts on A and B.

  • This process is defined by induction on (semi-formal) derivations.
  • Want to separate the operational definition from the proof-theoretical analysis

(well-foundedness of the derivation involves ordinal notation systems and strong means).

  • In order to compute the normalized derivation in a primitive recursive way
  • Mints 1978 introduced repetition rule∗ Γ ⊢ A

Γ ⊢ A to compute the last rule of the normalized derivation (“Please wait; your proof will soon be computed (hopefully)”)

  • This procedure even applies to non-wellfounded derivations (it is continuous).

∗ which has the subformula property!

slide-3
SLIDE 3

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 3

Goal

  • Transfer ideas to λ-calculus (as Schwichtenberg 1998 and others did).
slide-4
SLIDE 4

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 3

Goal

  • Transfer ideas to λ-calculus (as Schwichtenberg 1998 and others did).
  • Interesting, because some λ-terms (like Y ) have infinite “normal forms”, or are

even diverging (like Ω).

slide-5
SLIDE 5

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 3

Goal

  • Transfer ideas to λ-calculus (as Schwichtenberg 1998 and others did).
  • Interesting, because some λ-terms (like Y ) have infinite “normal forms”, or are

even diverging (like Ω).

  • Need a coinductive λ-calculus to write out the normal forms!
slide-6
SLIDE 6

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 3

Goal

  • Transfer ideas to λ-calculus (as Schwichtenberg 1998 and others did).
  • Interesting, because some λ-terms (like Y ) have infinite “normal forms”, or are

even diverging (like Ω).

  • Need a coinductive λ-calculus to write out the normal forms!

✬ ✫ ✩ ✪

Thus: define and analyze a primitive recursive normalization function ( )β : Λ(co) → Λco

R

slide-7
SLIDE 7

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 3

Goal

  • Transfer ideas to λ-calculus (as Schwichtenberg 1998 and others did).
  • Interesting, because some λ-terms (like Y ) have infinite “normal forms”, or are

even diverging (like Ω).

  • Need a coinductive λ-calculus to write out the normal forms!

✬ ✫ ✩ ✪

Thus: define and analyze a primitive recursive normalization function ( )β : Λ(co) → Λco

R

In particular, explain why and how many repetition rules are needed.

slide-8
SLIDE 8

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr

slide-9
SLIDE 9

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr

slide-10
SLIDE 10

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr

slide-11
SLIDE 11

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr | βr

slide-12
SLIDE 12

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr | βr Λco

R

∋ r, s ::=co x | rs | λr | Rr | βr

slide-13
SLIDE 13

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr | βr Λco

R

∋ r, s ::=co x | rs | λr | Rr | βr Examples. Θ := tt with t = λλ.0.110

slide-14
SLIDE 14

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr | βr Λco

R

∋ r, s ::=co x | rs | λr | Rr | βr Examples. Θ := tt with t = λλ.0.110 = “λtλf(f(ttf))”

slide-15
SLIDE 15

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr | βr Λco

R

∋ r, s ::=co x | rs | λr | Rr | βr Examples. Θ := tt with t = λλ.0.110 = “λtλf(f(ttf))” Y := λ.(λ.1.00)(λ.1.00) = “λf.(λx(f(xx)))(λx(f(xx)))”

slide-16
SLIDE 16

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr | βr Λco

R

∋ r, s ::=co x | rs | λr | Rr | βr Examples. Θ := tt with t = λλ.0.110 = “λtλf(f(ttf))” Y := λ.(λ.1.00)(λ.1.00) = “λf.(λx(f(xx)))(λx(f(xx)))” Y co

r

:= rY co

r

= r(r(r . . .

slide-17
SLIDE 17

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 4

Terms

  • Terms. Inductive and coinductive λ-calculus in de Bruijn-notation (x ∈ N).

Λ ∋ r, s ::= x | rs | λr Λco ∋ r, s ::=co x | rs | λr ΛR ∋ r, s ::= x | rs | λr | Rr | βr Λco

R

∋ r, s ::=co x | rs | λr | Rr | βr Examples. Θ := tt with t = λλ.0.110 = “λtλf(f(ttf))” Y := λ.(λ.1.00)(λ.1.00) = “λf.(λx(f(xx)))(λx(f(xx)))” Y co

r

:= rY co

r

= r(r(r . . . Observational equality. r ≃k s iff the outermost k constructors are identical. E.g., 1λλ0 ≃2 1λ(0 2).

  • Equality. r = s iff r ≃k s for all k.
slide-18
SLIDE 18

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 5

Continuous normalization

  • Substitution. r[s] is well-defined
slide-19
SLIDE 19

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 5

Continuous normalization

  • Substitution. r[s] is well-defined and continuous with identity as modulus of

continuity, i.e., r ≃k r′ ∧ s ≃k s′ ⇒ r[s] ≃k r′[s′].

slide-20
SLIDE 20

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 5

Continuous normalization

  • Substitution. r[s] is well-defined and continuous with identity as modulus of

continuity, i.e., r ≃k r′ ∧ s ≃k s′ ⇒ r[s] ≃k r′[s′].

  • Reduction. → is the compatible closure of (λr)s → r[s].
slide-21
SLIDE 21

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 5

Continuous normalization

  • Substitution. r[s] is well-defined and continuous with identity as modulus of

continuity, i.e., r ≃k r′ ∧ s ≃k s′ ⇒ r[s] ≃k r′[s′].

  • Reduction. → is the compatible closure of (λr)s → r[s].

Normal forms. NF ∋ r, s ::=co x r | λr | Rr | βr.

slide-22
SLIDE 22

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 5

Continuous normalization

  • Substitution. r[s] is well-defined and continuous with identity as modulus of

continuity, i.e., r ≃k r′ ∧ s ≃k s′ ⇒ r[s] ≃k r′[s′].

  • Reduction. → is the compatible closure of (λr)s → r[s].

Normal forms. NF ∋ r, s ::=co x r | λr | Rr | βr. Continuous normalization. rβ := r@ε where for r, s ∈ Λco we define r@ s ∈ NF by

✬ ✫ ✩ ✪

(rs)@ s := R.r@(s, s ) x@ s := x s β (λr)@ε := λrβ (λr)@(s, s ) := β.r[s]@ s

slide-23
SLIDE 23

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1.

slide-24
SLIDE 24

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK

slide-25
SLIDE 25

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0)

slide-26
SLIDE 26

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

slide-27
SLIDE 27

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get
slide-28
SLIDE 28

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . .

slide-29
SLIDE 29

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . . Note that Θf

slide-30
SLIDE 30

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . . Note that Θf = (λx, f.f(xxf))(λx, f.f(xxf))f

slide-31
SLIDE 31

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . . Note that Θf = (λx, f.f(xxf))(λx, f.f(xxf))f → (λf.f(Θf))f

slide-32
SLIDE 32

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . . Note that Θf = (λx, f.f(xxf))(λx, f.f(xxf))f → (λf.f(Θf))f → f(Θf)

slide-33
SLIDE 33

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . . Note that Θf = (λx, f.f(xxf))(λx, f.f(xxf))f → (λf.f(Θf))f → f(Θf) while Yf

slide-34
SLIDE 34

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . . Note that Θf = (λx, f.f(xxf))(λx, f.f(xxf))f → (λf.f(Θf))f → f(Θf) while Yf := (λx.f(xx))(λx.f(xx))

slide-35
SLIDE 35

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 6

Examples

  • (SKK)β = RRββλRRββ0

with S := λλλ.2 0 .1 0, K := λλ1. Note that SKK →2 λ.K0(K0) →2 λ0.

  • For Θ = tt with t = λλ.0.110 and Y = λ.(λ.1.00)(λ.1.00) we get

nf Θ = nf Y = λ. 0( 0( 0(. . . Θβ = Rβλ.R(0(RRββR(0(RRββR(0(. . . Y β = λ.RβR(0( Rβ R(0( Rβ R(0(. . . Note that Θf = (λx, f.f(xxf))(λx, f.f(xxf))f → (λf.f(Θf))f → f(Θf) while Yf := (λx.f(xx))(λx.f(xx)) → fYf.

slide-36
SLIDE 36

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 7

Properties

  • Continuity: r ≃k r′ ∧

s ≃k s′ = ⇒ r@ s ≃k r′@ s′. In particular rβ ≃k r′β for r ≃k r′.

slide-37
SLIDE 37

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 7

Properties

  • Continuity: r ≃k r′ ∧

s ≃k s′ = ⇒ r@ s ≃k r′@ s′. In particular rβ ≃k r′β for r ≃k r′.

  • Soundness: r ∈ Λ ∧ rβ ∈ ΛR =

⇒ r →∗ rβ∗ where r∗ is r without β and R (for r ∈ ΛR).

slide-38
SLIDE 38

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 7

Properties

  • Continuity: r ≃k r′ ∧

s ≃k s′ = ⇒ r@ s ≃k r′@ s′. In particular rβ ≃k r′β for r ≃k r′.

  • Soundness: r ∈ Λ ∧ rβ ∈ ΛR =

⇒ r →∗ rβ∗ where r∗ is r without β and R (for r ∈ ΛR).

  • Continuous normal forms: ∃s ∈ Λco.sβ = r iff ⊢ r with

s, s ⊢ r

  • s ⊢ Rr

⊢ r

  • r ⊢ x

r ⊢ r ⊢ λr

  • s ⊢ r

s, s ⊢ βr

slide-39
SLIDE 39

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 7

Properties

  • Continuity: r ≃k r′ ∧

s ≃k s′ = ⇒ r@ s ≃k r′@ s′. In particular rβ ≃k r′β for r ≃k r′.

  • Soundness: r ∈ Λ ∧ rβ ∈ ΛR =

⇒ r →∗ rβ∗ where r∗ is r without β and R (for r ∈ ΛR).

  • Continuous normal forms: ∃s ∈ Λco.sβ = r iff ⊢ r with

s, s ⊢ r

  • s ⊢ Rr

⊢ r

  • r ⊢ x

r ⊢ r ⊢ λr

  • s ⊢ r

s, s ⊢ βr

  • Analysis: A R is justified by a β or an application:

⊢ s = ⇒ Rζs ≥ βζs + Aζs with = for complete paths ζ

slide-40
SLIDE 40

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 8

Counting reductions

in the leftmost-outermost reduction strategy

slide-41
SLIDE 41

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 8

Counting reductions

in the leftmost-outermost reduction strategy Standardization.

slide-42
SLIDE 42

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 8

Counting reductions

in the leftmost-outermost reduction strategy

  • Standardization. If r →∗ s ∈ NF ∩ Λ then r ❀ s, given by
  • r ❀

n

s x r ❀Σ

n x

s r ❀n s λr ❀n λs r[s] s ❀n t (λr)s s ❀n+1 t

slide-43
SLIDE 43

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 8

Counting reductions

in the leftmost-outermost reduction strategy

  • Standardization. If r →∗ s ∈ NF ∩ Λ then r ❀ s, given by
  • r ❀

n

s x r ❀Σ

n x

s r ❀n s λr ❀n λs r[s] s ❀n t (λr)s s ❀n+1 t

  • Lemma. r ❀n s =

⇒ rβ ✄n

n sβ

where ✄k

n removes n occurrences of β and k occurences of R.

slide-44
SLIDE 44

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 8

Counting reductions

in the leftmost-outermost reduction strategy

  • Standardization. If r →∗ s ∈ NF ∩ Λ then r ❀ s, given by
  • r ❀

n

s x r ❀Σ

n x

s r ❀n s λr ❀n λs r[s] s ❀n t (λr)s s ❀n+1 t

  • Lemma. r ❀n s =

⇒ rβ ✄n

n sβ

where ✄k

n removes n occurrences of β and k occurences of R.

  • Theorem. r ❀n s ∈ NF ∩ Λ =

⇒ rβ ✄n+|s|

n

s where |s| is the number of applications in s.

slide-45
SLIDE 45

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 9

Conclusions and further work

  • Defined and analyzed a primitive recursive normalization function in the

coinductive λ-calculus with repetition rule R.

  • Explained the use of R, using auxiliary constructor β. This gives information
  • n the normalization process.
  • Can be extended to calculi with infinitary branching rules, such as (ω).
  • Straightforward implementation in Haskell:

beta :: Term -> Term beta r = app r [] app :: Term -> [Term] -> Term app (Lam r) (s:l) = Bet (app (subst r s 0) l) app (Lam r) [] = Lam (beta r) app (Var k) l = foldl App (Var k) (map beta l) app (App r s) l = Rep (app r (s:l))

slide-46
SLIDE 46

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 10

Examples in Haskell

s = Lam (Lam (Lam (Var 2 ‘App‘ (Var 0) ‘App‘ (Var 1 ‘App‘ (Var 0))))) k = Lam (Lam (Var 1)) y = Lam (Lam (Var 1 ‘App‘ (Var 0 ‘App‘ (Var 0))) ‘App‘ (Lam (Var 1 ‘App‘ (Var 0 ‘App‘ (Var 0))))) yco r = r ‘App‘ (yco r) theta = Lam (Lam (Var 0 ‘App‘ (Var 1 ‘App‘ (Var 1) ‘App‘ (Var 0)))) ‘App‘ Lam (Lam (Var 0 ‘App‘ (Var 1 ‘App‘ (Var 1) ‘App‘ (Var 0)))) church n = Lam (Lam (iterate (App (Var 1)) (Var 0) !! n))

Test runs:

Main> beta (s ‘App‘ k ‘App‘ k) Rep (Rep (Bet (Bet (Lam (Rep (Rep (Bet (Bet (Var 0))))))))) Main> beta (yco k) Rep (Bet (Lam (Rep (Bet (Lam (Rep (Bet (Lam (Rep (Bet (Lam (Rep (Bet (Lam (Rep (Bet (Lam (Rep {Interrupted!} Main> beta (y ‘App‘ k) Rep (Bet (Rep (Bet (Rep (Bet (Lam (Rep (Bet (Rep (Bet (Lam (Rep (Bet (Rep (Bet (Lam (Rep (Bet (Rep {Interrupted!} Main> beta (theta ‘App‘ k) Rep (Rep (Bet (Bet (Rep (Bet (Lam (Rep (Rep (Bet (Bet (Rep (Bet (Lam (Rep (Rep (Bet (Bet (Rep (Bet (Lam {Interrupted!}

slide-47
SLIDE 47

History – Goal – Terms – Normalization – Examples – Properties – Counting – Conclusions On Continuous Normalization CSL 2002 11

More test runs

Main> beta (church 2 ‘App‘ (church 3)) Rep (Bet (Lam (Rep (Bet (Lam (Rep (Rep (Bet (Bet (Rep (App (Var 1) (Rep (App (Var 1) (Rep (App (Var 1) (Rep (Rep (Bet (Bet (Rep (App (Var 1) (Rep (App (Var 1) (Rep (App (Var 1) (Rep (Rep (Bet (Bet (Rep (App (Var 1) (Rep (App (Var 1) (Rep (App (Var 1) (Var 0))) [..]) Main> beta (church 3 ‘App‘ (church 2)) Rep (Bet (Lam (Rep (Bet (Lam (Rep (Rep (Bet (Bet (Rep (Rep (Bet (Bet (Rep (App (Var 1) (Rep (App (Var 1) (Rep (Rep (Bet (Bet (Rep (App (Var 1) (Rep (App (Var 1) (Rep (Rep (Bet (Bet (Rep (Rep (Bet (Bet (Rep (App (Var 1) (Rep (App (Var 1) (Rep (Rep (Bet (Bet (Rep (App (Var 1) (Rep (App (Var 1) (Var 0))) [..] )