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 dependent type systems: τ = β τ ′ Γ ⊢ t : τ (cons) Γ ⊢ t : τ ′ ◮ Usually by-value (strict) semantics. 2 / 1
Target Strategies Full-reducing strategies in open strict calculus: ◮ Full normal forms (NF). 3 / 1
Target Strategies Full-reducing strategies in open strict calculus: ◮ Full normal forms (NF). ◮ Free variables. 3 / 1
Target Strategies Full-reducing strategies in open strict calculus: ◮ Full normal forms (NF). ◮ Free variables. ◮ By-value semantics. 3 / 1
Plotkin’s theory λ N β ( λ x . B ) N ⊲ [ N / x ] B 4 / 1
Plotkin’s theory λ N β ( λ x . B ) N ⊲ [ N / x ] B M ⊲ M ′ N ⊲ N ′ B ⊲ B ′ µ ν ξ M N ⊲ M ′ N M N ⊲ M N ′ λ x . B ⊲ λ x . B ′ 4 / 1
Plotkin’s theory λ N β ( λ x . B ) N ⊲ [ N / x ] B M ⊲ M ′ N ⊲ N ′ B ⊲ B ′ µ ν ξ M N ⊲ M ′ N M N ⊲ M N ′ λ x . B ⊲ λ x . B ′ τ M ⊲ N N ⊲ P ρ M ⊲ M M ⊲ P 4 / 1
Plotkin’s theory λ N β ( λ x . B ) N = [ N / x ] B M = M ′ N = N ′ B = B ′ µ ν ξ M N = M ′ N M N = M N ′ λ x . B = λ x . B ′ τ M = N N = P σ M = N ρ M = M M = P N = M 4 / 1
Plotkin’s theory λ V β V ( λ x . B ) N ⊲ [ N / x ] B ( N ∈ Val ) 5 / 1
Plotkin’s theory λ V β V ( λ x . B ) N ⊲ [ N / x ] B ( N ∈ Val ) M ⊲ M ′ N ⊲ N ′ B ⊲ B ′ µ ν ξ M N ⊲ M ′ N M N ⊲ M N ′ λ x . B ⊲ λ x . B ′ 5 / 1
Plotkin’s theory λ V β V ( λ x . B ) N ⊲ [ N / x ] B ( N ∈ Val ) M ⊲ M ′ N ⊲ N ′ B ⊲ B ′ µ ν ξ M N ⊲ M ′ N M N ⊲ M N ′ λ x . B ⊲ λ x . B ′ τ M ⊲ N N ⊲ P ρ M ⊲ M M ⊲ P 5 / 1
Plotkin’s theory λ V β V ( λ x . B ) N = [ N / x ] B ( N ∈ Val ) M = M ′ N = N ′ B = B ′ µ ν ξ M N = M ′ N M N = M N ′ λ x . B = λ x . B ′ τ M = N N = P σ M = N ρ M = M M = P N = M 5 / 1
Values and Irreducible Forms (I) ◮ Values: ::= Val x | λ x . B 6 / 1
Values and Irreducible Forms (I) ◮ Values: ::= Val x | λ x . B ◮ Weak normal forms in λ V : ::= λ x . B WNF V | Stuck W x WNF ∗ Stuck W ::= (( λ x . B ) Stuck W ) WNF ∗ | 6 / 1
Values and Irreducible Forms (I) ◮ Values: ::= Val x | λ x . B ◮ Weak normal forms in λ V : ::= λ x . B WNF V | Stuck W x WNF ∗ Stuck W ::= (( λ x . B ) Stuck W ) WNF ∗ | Note that Val = ( WNF V − Stuck W ) ∪ { x } . 6 / 1
Values and Irreducible Forms (II) ◮ Normal forms in λ V : NF V ::= λ x . NF V | Stuck V ∗ Stuck V ::= x NF V ∗ | (( λ x . NF V ) Stuck V ) NF V 7 / 1
Values and Irreducible Forms (II) ◮ Normal forms in λ V : NF V ::= λ x . NF V | Stuck V ∗ Stuck V ::= x NF V ∗ | (( λ x . NF V ) Stuck V ) NF V Note that Val � = ( NF V − Stuck V ) ∪ { x } . 7 / 1
Call-by-value Strategy (cbv) Uniform standard strategy in λ V : var x → x 8 / 1
Call-by-value Strategy (cbv) Uniform standard strategy in λ V : var x → x abs λ x . B → λ x . B 8 / 1
Call-by-value Strategy (cbv) Uniform standard strategy in λ V : var x → x abs λ x . B → λ x . B N → N ′ [ N ′ / x ] B → B ′ red M → λ x . B M N → B ′ 8 / 1
Call-by-value Strategy (cbv) Uniform standard strategy in λ V : var x → x abs λ x . B → λ x . B N → N ′ [ N ′ / x ] B → B ′ red M → λ x . B M N → B ′ app M → M ′ �≡ λ x . B N → N ′ M N → M ′ N ′ 8 / 1
Standardisation Theorem Theorem λ V ⊢ M ⊲ N iff s.r. M ⊲ 1 . . . ⊲ 1 N 9 / 1
Standardisation Theorem Theorem λ V ⊢ M ⊲ N iff s.r. M ⊲ 1 . . . ⊲ 1 N Corolary → N ′ , N ′ ∈ Val cbv λ V ⊢ M ⊲ N , N ∈ Val iff M 9 / 1
Standardisation Theorem Theorem λ V ⊢ M ⊲ N iff s.r. M ⊲ 1 . . . ⊲ 1 N Corolary → N ′ , N ′ ∈ Val cbv λ V ⊢ M ⊲ N , N ∈ Val iff M Weak reduction is not enoguh for implementing joinability! 9 / 1
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
Hybrid Strategies Example: call-by-name and normal order in λ N . 11 / 1
Hybrid Strategies Example: call-by-name and normal order in λ N . Call-by-name (cbn): cbn x → x cbn λ x . B → λ x . B �� �� �� �� cbn → M ′ ≡ λ x . B cbn [ N / x ] B → S M cbn M N → S �� �� �� �� → M ′ �≡ λ x . B cbn M → M ′ N cbn M N 11 / 1
Hybrid Strategies Example: call-by-name and normal order in λ N . Call-by-name (cbn): Normal order (nor): nor cbn → x x x → x nor → B ′ B nor cbn → λ x . B ′ λ x . B λ x . B → λ x . B �� �� �� �� �� �� �� �� cbn → M ′ ≡ λ x . B cbn → M ′ ≡ λ x . B cbn nor [ N / x ] B → S [ N / x ] B → S M M nor cbn M N → S M N → S �� �� �� �� �� �� �� �� → M ′ �≡ λ x . B → M ′ �≡ λ x . B cbn cbn M ′ nor nor → M ′′ → N ′′ M M N → M ′′ N ′′ nor → M ′ N cbn M N M N Subsidiary Hybrid 11 / 1
Hybrid Strategies Example: call-by-name and normal order in λ N . Call-by-name (cbn): Normal order (nor): nor cbn → x x x → x nor → B ′ B nor cbn → λ x . B ′ λ x . B λ x . B → λ x . B �� �� �� �� �� �� �� �� cbn → M ′ ≡ λ x . B cbn → M ′ ≡ λ x . B cbn nor [ N / x ] B → S [ N / x ] B → S M M nor cbn M N → S M N → S �� �� �� �� �� �� �� �� → M ′ �≡ λ x . B → M ′ �≡ λ x . B cbn cbn M ′ nor nor → M ′′ → N ′′ M M N → M ′′ N ′′ nor → M ′ N cbn M N M N Subsidiary Hybrid 11 / 1
Rule Template var x → x 12 / 1
Rule Template la → B ′ B var x → x abs λ x . B → λ x . B ′ 12 / 1
Rule Template la → B ′ B var x → x abs λ x . B → λ x . B ′ ar 1 → N ′ [ N ′ / x ] B → B ′ red M → λ x . B N M N → B ′ 12 / 1
Rule Template la → B ′ B var x → x abs λ x . B → λ x . B ′ ar 1 → N ′ [ N ′ / x ] B → B ′ red M → λ x . B N M N → B ′ app M → M ′ �≡ λ x . B ar 2 → N ′ N M N → M ′ N ′ 12 / 1
The Beta Cube Booleans la , ar 1 and ar 2 encode the occurrence of the coloured premises in the rule template. 13 / 1
� � � � � � � � � � The Beta Cube Booleans la , ar 1 and ar 2 encode the occurrence of the coloured premises in the rule template. la AOR CBV � � � � � � � � � � ar 1 � � � � 101 001 ( ⊑ ) � � � 110 010 ar 2 � � � � � � � � � � HE CBN 13 / 1
� � � � � � � � � � The Beta Cube Booleans la , ar 1 and ar 2 encode the occurrence of the coloured premises in the rule template. la 0 weakness 1 fullness AOR CBV � � � � � � � � � � ar 1 � � � � 0 non-strictness 1 strictness 101 001 ( ⊑ ) � � � 110 010 ar 2 0 headness 1 non-headness � � � � � � � � � � HE CBN 13 / 1
� � � � � � � � � � � � � � The Beta Cube Booleans la , ar 1 and ar 2 encode the occurrence of the coloured premises in the rule template. la 0 weakness 1 fullness AOR CBV � � � � � � � � � � ar 1 � � � � 0 non-strictness 1 strictness 101 001 ( ⊑ ) � � � 110 010 ar 2 0 headness 1 non-headness � � � � � � � � � � HE CBN nf wnf hnf whnf 13 / 1
Hybridisation Operator sub x → x sub → B ′ B sub → λ x . B ′ λ x . B �� �� �� �� sub sub sub → N ′ [ N ′ / x ] B M → λ x . B N → S sub M N → S �� �� �� �� → M ′ �≡ λ x . B sub sub M → N ′ N → M ′ N ′ sub M N Subsidiary 14 / 1
Hybridisation Operator sub hyb x → x x → x sub hyb → B ′ → B ′ B B sub hyb → λ x . B ′ → λ x . B ′ λ x . B λ x . B �� �� �� �� �� �� �� �� sub sub sub sub hyb hyb → N ′ [ N ′ / x ] B [ N ′ / x ] B M → λ x . B N → S M → λ x . B N → N ′ → S sub hyb M N → S M N → S �� �� �� �� �� �� �� �� → M ′ �≡ λ x . B → M ′ �≡ λ x . B sub sub sub M ′ hyb hyb M → N ′ M → M ′′ → N ′ N N → M ′ N ′ → M ′′ N ′ sub hyb M N M N Subsidiary Hybrid 14 / 1
� � � � � � � � Hybrids in the Non-strict Face of the Cube nor = hyb ( 101 , cbn ) AOR CBV � � � � � � � � � � 101 001 ( ⊑ ) 110 010 � � � � � � � � � � HE CBN 15 / 1
Recommend
More recommend