Full Reduction in Open Strict Calculus Alvaro Garc a IMDEA - - PowerPoint PPT Presentation

full reduction in open strict calculus
SMART_READER_LITE
LIVE PREVIEW

Full Reduction in Open Strict Calculus Alvaro Garc a IMDEA - - PowerPoint PPT Presentation

Full Reduction in Open Strict Calculus Alvaro Garc a IMDEA Software 2011 1 / 1 Motivation Typing rules for dependent type systems: = t : (cons) t : 2 / 1 Motivation Typing rules for


slide-1
SLIDE 1

Full Reduction in Open Strict Calculus

´ Alvaro Garc´ ıa IMDEA Software 2011

1 / 1

slide-2
SLIDE 2

Motivation

◮ Typing rules for dependent type systems:

Γ ⊢ t : τ τ =β τ ′ Γ ⊢ t : τ ′

(cons)

2 / 1

slide-3
SLIDE 3

Motivation

◮ Typing rules for dependent type systems:

Γ ⊢ t : τ τ =β τ ′ Γ ⊢ t : τ ′

(cons)

◮ Usually by-value (strict) semantics.

2 / 1

slide-4
SLIDE 4

Target Strategies

Full-reducing strategies in open strict calculus:

◮ Full normal forms (NF).

3 / 1

slide-5
SLIDE 5

Target Strategies

Full-reducing strategies in open strict calculus:

◮ Full normal forms (NF). ◮ Free variables.

3 / 1

slide-6
SLIDE 6

Target Strategies

Full-reducing strategies in open strict calculus:

◮ Full normal forms (NF). ◮ Free variables. ◮ By-value semantics.

3 / 1

slide-7
SLIDE 7

Plotkin’s theory λN

β (λx.B) N ⊲ [N/x]B

4 / 1

slide-8
SLIDE 8

Plotkin’s theory λN

β (λx.B) N ⊲ [N/x]B µ

M ⊲ M′ M N ⊲ M′ N

ν

N ⊲ N′ M N ⊲ M N′

ξ

B ⊲ B′ λx.B ⊲ λx.B′

4 / 1

slide-9
SLIDE 9

Plotkin’s theory λN

β (λx.B) N ⊲ [N/x]B µ

M ⊲ M′ M N ⊲ M′ N

ν

N ⊲ N′ M N ⊲ M N′

ξ

B ⊲ B′ λx.B ⊲ λx.B′

ρ M ⊲ M τ M ⊲ N

N ⊲ P M ⊲ P

4 / 1

slide-10
SLIDE 10

Plotkin’s theory λN

β (λx.B) N = [N/x]B µ

M = M′ M N = M′ N

ν

N = N′ M N = M N′

ξ

B = B′ λx.B = λx.B′

ρ M = M τ M = N

N = P M = P

σ M = N

N = M

4 / 1

slide-11
SLIDE 11

Plotkin’s theory λV

βV (λx.B) N ⊲ [N/x]B (N ∈ Val)

5 / 1

slide-12
SLIDE 12

Plotkin’s theory λV

βV (λx.B) N ⊲ [N/x]B (N ∈ Val) µ

M ⊲ M′ M N ⊲ M′ N

ν

N ⊲ N′ M N ⊲ M N′

ξ

B ⊲ B′ λx.B ⊲ λx.B′

5 / 1

slide-13
SLIDE 13

Plotkin’s theory λV

βV (λx.B) N ⊲ [N/x]B (N ∈ Val) µ

M ⊲ M′ M N ⊲ M′ N

ν

N ⊲ N′ M N ⊲ M N′

ξ

B ⊲ B′ λx.B ⊲ λx.B′

ρ M ⊲ M τ M ⊲ N

N ⊲ P M ⊲ P

5 / 1

slide-14
SLIDE 14

Plotkin’s theory λV

βV (λx.B) N = [N/x]B (N ∈ Val) µ

M = M′ M N = M′ N

ν

N = N′ M N = M N′

ξ

B = B′ λx.B = λx.B′

ρ M = M τ M = N

N = P M = P

σ M = N

N = M

5 / 1

slide-15
SLIDE 15

Values and Irreducible Forms (I)

◮ Values:

Val ::= x | λx.B

6 / 1

slide-16
SLIDE 16

Values and Irreducible Forms (I)

◮ Values:

Val ::= x | λx.B

◮ Weak normal forms in λV :

WNF V ::= λx.B | StuckW StuckW ::= x WNF ∗ | ((λx.B) StuckW ) WNF ∗

6 / 1

slide-17
SLIDE 17

Values and Irreducible Forms (I)

◮ Values:

Val ::= x | λx.B

◮ Weak normal forms in λV :

WNF V ::= λx.B | StuckW StuckW ::= x WNF ∗ | ((λx.B) StuckW ) WNF ∗ Note that Val = (WNF V − StuckW ) ∪ {x}.

6 / 1

slide-18
SLIDE 18

Values and Irreducible Forms (II)

◮ Normal forms in λV :

NF V ::= λx.NF V | StuckV StuckV ::= x NF V

| ((λx.NF V ) StuckV ) NF V

7 / 1

slide-19
SLIDE 19

Values and Irreducible Forms (II)

◮ Normal forms in λV :

NF V ::= λx.NF V | StuckV StuckV ::= x NF V

| ((λx.NF V ) StuckV ) NF V

Note that Val = (NF V − StuckV ) ∪ {x}.

7 / 1

slide-20
SLIDE 20

Call-by-value Strategy (cbv)

Uniform standard strategy in λV :

var x → x

8 / 1

slide-21
SLIDE 21

Call-by-value Strategy (cbv)

Uniform standard strategy in λV :

var x → x abs λx.B → λx.B

8 / 1

slide-22
SLIDE 22

Call-by-value Strategy (cbv)

Uniform standard strategy in λV :

var x → x abs λx.B → λx.B red M → λx.B

N → N′ [N′/x]B → B′ M N → B′

8 / 1

slide-23
SLIDE 23

Call-by-value Strategy (cbv)

Uniform standard strategy in λV :

var x → x abs λx.B → λx.B red M → λx.B

N → N′ [N′/x]B → B′ M N → B′

app M → M′ ≡ λx.B

N → N′ M N → M′ N′

8 / 1

slide-24
SLIDE 24

Standardisation Theorem

Theorem

λV ⊢ M ⊲ N iff s.r. M ⊲1 . . . ⊲1 N

9 / 1

slide-25
SLIDE 25

Standardisation Theorem

Theorem

λV ⊢ M ⊲ N iff s.r. M ⊲1 . . . ⊲1 N

Corolary

λV ⊢ M ⊲ N, N ∈ Val iff M

cbv

→ N′, N′ ∈ Val

9 / 1

slide-26
SLIDE 26

Standardisation Theorem

Theorem

λV ⊢ M ⊲ N iff s.r. M ⊲1 . . . ⊲1 N

Corolary

λV ⊢ M ⊲ N, N ∈ Val iff M

cbv

→ N′, N′ ∈ Val Weak reduction is not enoguh for implementing joinability!

9 / 1

slide-27
SLIDE 27

Full Reduction and Confluence

◮ Restricting NF’s as arguments breaks Church-Rosser:

M ≡ (λx.(λy.z) (x (λx.x x))) (λx.x x)

10 / 1

slide-28
SLIDE 28

Hybrid Strategies

Example: call-by-name and normal order in λN.

11 / 1

slide-29
SLIDE 29

Hybrid Strategies

Example: call-by-name and normal order in λN. Call-by-name (cbn): x

cbn

→ x λx.B

cbn

→ λx.B

  • M

cbn

→ M′ ≡ λx.B [N/x]B

cbn

→ S M N

cbn

→ S

  • M

cbn

→ M′ ≡ λx.B M N

cbn

→ M′ N

11 / 1

slide-30
SLIDE 30

Hybrid Strategies

Example: call-by-name and normal order in λN. Call-by-name (cbn): Normal order (nor): x

cbn

→ x x

nor

→ x λx.B

cbn

→ λx.B B

nor

→ B′ λx.B

nor

→ λx.B′

  • M

cbn

→ M′ ≡ λx.B [N/x]B

cbn

→ S M N

cbn

→ S

  • M

cbn

→ M′ ≡ λx.B [N/x]B

nor

→ S M N

nor

→ S

  • M

cbn

→ M′ ≡ λx.B M N

cbn

→ M′ N

  • M

cbn

→ M′ ≡ λx.B M′ nor → M′′ N

nor

→ N′′ M N

nor

→ M′′ N′′ Subsidiary Hybrid

11 / 1

slide-31
SLIDE 31

Hybrid Strategies

Example: call-by-name and normal order in λN. Call-by-name (cbn): Normal order (nor): x

cbn

→ x x

nor

→ x λx.B

cbn

→ λx.B B

nor

→ B′ λx.B

nor

→ λx.B′

  • M

cbn

→ M′ ≡ λx.B [N/x]B

cbn

→ S M N

cbn

→ S

  • M

cbn

→ M′ ≡ λx.B [N/x]B

nor

→ S M N

nor

→ S

  • M

cbn

→ M′ ≡ λx.B M N

cbn

→ M′ N

  • M

cbn

→ M′ ≡ λx.B M′ nor → M′′ N

nor

→ N′′ M N

nor

→ M′′ N′′ Subsidiary Hybrid

11 / 1

slide-32
SLIDE 32

Rule Template

var x → x

12 / 1

slide-33
SLIDE 33

Rule Template

var x → x abs

B

la

→ B′ λx.B → λx.B′

12 / 1

slide-34
SLIDE 34

Rule Template

var x → x abs

B

la

→ B′ λx.B → λx.B′

red M → λx.B

N

ar1

→ N′ [N′/x]B → B′ M N → B′

12 / 1

slide-35
SLIDE 35

Rule Template

var x → x abs

B

la

→ B′ λx.B → λx.B′

red M → λx.B

N

ar1

→ N′ [N′/x]B → B′ M N → B′

app M → M′ ≡ λx.B

N

ar2

→ N′ M N → M′ N′

12 / 1

slide-36
SLIDE 36

The Beta Cube

Booleans la, ar1 and ar2 encode the occurrence of the coloured premises in the rule template.

13 / 1

slide-37
SLIDE 37

The Beta Cube

Booleans la, ar1 and ar2 encode the occurrence of the coloured premises in the rule template. (⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • la
  • ar1
  • ar2
  • 13 / 1
slide-38
SLIDE 38

The Beta Cube

Booleans la, ar1 and ar2 encode the occurrence of the coloured premises in the rule template. (⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • la
  • 0 weakness

1 fullness ar1

  • 0 non-strictness

1 strictness ar2

  • 0 headness

1 non-headness

13 / 1

slide-39
SLIDE 39

The Beta Cube

Booleans la, ar1 and ar2 encode the occurrence of the coloured premises in the rule template. (⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • la
  • 0 weakness

1 fullness ar1

  • 0 non-strictness

1 strictness ar2

  • 0 headness

1 non-headness

nf wnf

  • hnf
  • whnf
  • 13 / 1
slide-40
SLIDE 40

Hybridisation Operator

x

sub

→ x B

sub

→ B′ λx.B

sub

→ λx.B′

  • M

sub

→ λx.B N

sub

→ N′ [N′/x]B

sub

→ S M N

sub

→ S

  • M

sub

→ M′ ≡ λx.B N

sub

→ N′ M N

sub

→ M′ N′ Subsidiary

14 / 1

slide-41
SLIDE 41

Hybridisation Operator

x

sub

→ x x

hyb

→ x B

sub

→ B′ λx.B

sub

→ λx.B′ B

hyb

→ B′ λx.B

hyb

→ λx.B′

  • M

sub

→ λx.B N

sub

→ N′ [N′/x]B

sub

→ S M N

sub

→ S

  • M

sub

→ λx.B N

hyb

→ N′ [N′/x]B

hyb

→ S M N

hyb

→ S

  • M

sub

→ M′ ≡ λx.B N

sub

→ N′ M N

sub

→ M′ N′

  • M

sub

→ M′ ≡ λx.B M′ hyb → M′′ N

hyb

→ N′ M N

hyb

→ M′′ N′ Subsidiary Hybrid

14 / 1

slide-42
SLIDE 42

Hybrids in the Non-strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • nor

= hyb(101, cbn)

15 / 1

slide-43
SLIDE 43

Hybrids in the Non-strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • nor

= hyb(101, cbn) hn = hyb(101, he)

15 / 1

slide-44
SLIDE 44

Hybrids in the Non-strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • nor

= hyb(101, cbn) hn = hyb(101, he) hr = hyb(he, cbn)

15 / 1

slide-45
SLIDE 45

Hybrids in the Non-strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • nor

= hyb(101, cbn) hn = hyb(101, he) hr = hyb(he, cbn)

Conjecture

nor = hn = hyb(101, 001)

15 / 1

slide-46
SLIDE 46

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv)

16 / 1

slide-47
SLIDE 47

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv) ha is not standard in λV !

16 / 1

slide-48
SLIDE 48

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv) ha is not standard in λV ! M N

16 / 1

slide-49
SLIDE 49

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv) ha is not standard in λV ! M N

ha

→∗ (λx.B) N

16 / 1

slide-50
SLIDE 50

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv) ha is not standard in λV ! M N

ha

→∗ (λx.B) N

ha

→∗ (λx.B) NV

16 / 1

slide-51
SLIDE 51

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv) ha is not standard in λV ! M N

ha

→∗ (λx.B) N

ha

→∗ (λx.B) NV

16 / 1

slide-52
SLIDE 52

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv) ha is not standard in λV ! M N

ha

→∗ (λx.B) N

ha

→∗ (λx.B) NV

ha

→∗ (λx.B) NNF

16 / 1

slide-53
SLIDE 53

Hybrids in the Strict Face of the Cube

(⊑)

AOR CBV

  • 101
  • 001
  • 110
  • 010
  • HE
  • CBN
  • ha

= hyb(aor, cbv) ha is not standard in λV ! M N

ha

→∗ (λx.B) N

ha

→∗ (λx.B) NV

ha

→∗ (λx.B) NNF

ha

→1 [NNF/x]B

16 / 1

slide-54
SLIDE 54

Standard Hybridisation Operator

x

sub

→ x B

sub

→ B′ λx.B

sub

→ λx.B′

  • M

sub

→ λx.B N

sub

→ N′ [N′/x]B

sub

→ S M N

sub

→ S

  • M

sub

→ M′ ≡ λx.B N

sub

→ N′ M N

sub

→ M′ N′ Subsidiary

17 / 1

slide-55
SLIDE 55

Standard Hybridisation Operator

x

sub

→ x x

hyb

→ x B

sub

→ B′ λx.B

sub

→ λx.B′ B

hyb

→ B′ λx.B

hyb

→ λx.B′

  • M

sub

→ λx.B N

sub

→ N′ [N′/x]B

sub

→ S M N

sub

→ S

  • M

sub

→ λx.B N

sub

→ N′ [N′/x]B

hyb

→ S M N

hyb

→ S

  • M

sub

→ M′ ≡ λx.B N

sub

→ N′ M N

sub

→ M′ N′

  • M

sub

→ M′ ≡ λx.B M′ hyb → M′′ N

hyb

→ N′ M N

hyb

→ M′′ N′ Subsidiary Hybrid

17 / 1

slide-56
SLIDE 56

Standard Hybridisation Operator

x

sub

→ x x

hyb

→ x B

sub

→ B′ λx.B

sub

→ λx.B′ B

hyb

→ B′ λx.B

hyb

→ λx.B′

  • M

sub

→ λx.B N

sub

→ N′ [N′/x]B

sub

→ S M N

sub

→ S

  • M

sub

→ λx.B N

sub

→ N′ [N′/x]B

hyb

→ S M N

hyb

→ S

  • M

sub

→ M′ ≡ λx.B N

sub

→ N′ M N

sub

→ M′ N′

  • M

sub

→ M′ ≡ λx.B M′ hyb → M′′ N

hyb

→ N′ M N

hyb

→ M′′ N′ Subsidiary Hybrid

17 / 1

slide-57
SLIDE 57

Strict Face with Open terms

◮ Cbv is not correct with respect to λV :

18 / 1

slide-58
SLIDE 58

Strict Face with Open terms

◮ Cbv is not correct with respect to λV :

(λx.B) (y z)

cbv

→1 [(y z)/x]B

18 / 1

slide-59
SLIDE 59

Strict Face with Open terms

◮ Cbv is not correct with respect to λV :

(λx.B) (y z)

cbv

→1 [(y z)/x]B (y z) is a stuck term, not a value!

18 / 1

slide-60
SLIDE 60

Strict Face with Open terms

◮ Cbv is not correct with respect to λV :

(λx.B) (y z)

cbv

→1 [(y z)/x]B (y z) is a stuck term, not a value!

◮ Do we really need open terms?

18 / 1

slide-61
SLIDE 61

Strict Face with Open terms

◮ Cbv is not correct with respect to λV :

(λx.B) (y z)

cbv

→1 [(y z)/x]B (y z) is a stuck term, not a value!

◮ Do we really need open terms?

◮ Open terms may occur as subterms of well-formed (closed) terms

when performing full reduction.

18 / 1

slide-62
SLIDE 62

Rule Template for Open Terms

var x → x

19 / 1

slide-63
SLIDE 63

Rule Template for Open Terms

var x → x abs

B

la

→ B′ λx.B → λx.B′

19 / 1

slide-64
SLIDE 64

Rule Template for Open Terms

var x → x abs

B

la

→ B′ λx.B → λx.B′

red M → λx.B

N

ar1

→ N′ ∈ Val [N′/x]B → B′ M N → B′

19 / 1

slide-65
SLIDE 65

Rule Template for Open Terms

var x → x abs

B

la

→ B′ λx.B → λx.B′

red M → λx.B

N

ar1

→ N′ ∈ Val [N′/x]B → B′ M N → B′

nred M → λx.B

N

ar1

→ N′ ∈ Val M N → M′ N′

19 / 1

slide-66
SLIDE 66

Rule Template for Open Terms

var x → x abs

B

la

→ B′ λx.B → λx.B′

red M → λx.B

N

ar1

→ N′ ∈ Val [N′/x]B → B′ M N → B′

nred M → λx.B

N

ar1

→ N′ ∈ Val M N → M′ N′

app M → M′ ≡ λx.B

N

ar2

→ N′ M N → M′ N′

19 / 1

slide-67
SLIDE 67

Cube and Hybridisation for Open Terms

Extending the cube and the standard hybridisation operator with the new rule is trivial.

20 / 1

slide-68
SLIDE 68

Strict Normal Order Strategy

Standard normalising strategy in λV :

var

x

snor

→ x

21 / 1

slide-69
SLIDE 69

Strict Normal Order Strategy

Standard normalising strategy in λV :

var

x

snor

→ x

abs

B

snor

→ B′ λx.B

snor

→ λx.B′

21 / 1

slide-70
SLIDE 70

Strict Normal Order Strategy

Standard normalising strategy in λV :

var

x

snor

→ x

abs

B

snor

→ B′ λx.B

snor

→ λx.B′

red M

cbvO

→ λx.B N

cbvO

→ N′ ∈ Val [N′/x]B

snor

→ B′ M N

snor

→ B′

21 / 1

slide-71
SLIDE 71

Strict Normal Order Strategy

Standard normalising strategy in λV :

var

x

snor

→ x

abs

B

snor

→ B′ λx.B

snor

→ λx.B′

red M

cbvO

→ λx.B N

cbvO

→ N′ ∈ Val [N′/x]B

snor

→ B′ M N

snor

→ B′

nred M

cbvO

→ λx.B N

cbvO

→ N′ ∈ Val M′ snor → M′′ N′ snor → N′′ M N

snor

→ M′′ N′′

21 / 1

slide-72
SLIDE 72

Strict Normal Order Strategy

Standard normalising strategy in λV :

var

x

snor

→ x

abs

B

snor

→ B′ λx.B

snor

→ λx.B′

red M

cbvO

→ λx.B N

cbvO

→ N′ ∈ Val [N′/x]B

snor

→ B′ M N

snor

→ B′

nred M

cbvO

→ λx.B N

cbvO

→ N′ ∈ Val M′ snor → M′′ N′ snor → N′′ M N

snor

→ M′′ N′′

app M

cbvO

→ M′ ≡ λx.B M′ snor → M′′ N

snor

→ N′ M N

snor

→ M′ N′

21 / 1

slide-73
SLIDE 73

Previous work

◮ Plotkin 1974: accounts for standardisation and confluence, but not

for full reduction

22 / 1

slide-74
SLIDE 74

Previous work

◮ Plotkin 1974: accounts for standardisation and confluence, but not

for full reduction

◮ Sestoft 2002: accounts for full reduction, but doesn’t account for

standardisation.

22 / 1

slide-75
SLIDE 75

Previous work

◮ Plotkin 1974: accounts for standardisation and confluence, but not

for full reduction

◮ Sestoft 2002: accounts for full reduction, but doesn’t account for

standardisation.

◮ Leroy and Gregoire 2002: accounts for full reduction and

standardisation, but doesn’t account for confluence in λV .

22 / 1

slide-76
SLIDE 76

Conclusions

◮ Strict normal order: accounts for full reduction, standardisation and

confluence in λV .

23 / 1

slide-77
SLIDE 77

Conclusions

◮ Strict normal order: accounts for full reduction, standardisation and

confluence in λV .

◮ Beta Cube and hybridisation to articulate strategies space.

23 / 1

slide-78
SLIDE 78

Conclusions

◮ Strict normal order: accounts for full reduction, standardisation and

confluence in λV .

◮ Beta Cube and hybridisation to articulate strategies space. ◮ Plotkin’s meta-theory leads the improvements in cube and

hybridisation.

23 / 1