Introduction On the reduction of the type-free computational λ -calculus Ugo de’Liguoro,Riccardo Treglia University of Turin IWC 2020 30/06/2020 Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 1 / 18
Introduction Overview Moggi Computational Monad via Wadler 1 s definition Computational λ ´ calculus Syntax Semantics Calculus Intersection type assignment Reduction relation Subject convertibility Contexts Monadic Interpretation Confluence D 8 model Factorization Soundness and Completeness via filter model We study a notion of reduction and prove it is confluent and factorizes ; also we relate our calculus to the original work by Moggi. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 1 / 18
Introduction Computational Monads (after Wadler) A monad is a triple p T , unit , ‹q Types D is the type of values; TD is the type of computations (with effects ) over D . Operators unit D : D Ñ TD (Haskell: return ); ‹ D , E : TD Ñ p D Ñ TE q Ñ TE (Haskell: ąą“ ). Axioms p unit d q ‹ f “ f d a ‹ unit “ a λ d . p f d ‹ g q p a ‹ f q ‹ g “ a ‹ λ Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 2 / 18
Calculus Untyped computational λ -calculus: λ u c We consider Moggi’s call-by-value reflexive object: D “ D Ñ TD hence there are two types, D and TD , and two kinds of terms: Val : V , W :: “ x | λ x . M (values) Com : L , M , N :: “ unit V | M ‹ V (computations) having types: x : D $ M : TD x : D $ x : D $ λ x . M : D Ñ TD “ D $ V : D $ M : TD $ V : D “ D Ñ TD $ unit V : TD $ M ‹ V : TD Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 3 / 18
Calculus Reduction Orienting monad axioms we get Ý Ñ Ď Com ˆ Com as the compatible closure of: unit V ‹ p λ x . M q Ý Ñ M r V { x s β c id M ‹ λ x . unit x Ý Ñ M ass p L ‹ λ x . M q ‹ λ y . N Ý Ñ L ‹ λ x . p M ‹ λ y . N q for x R FV p N q where M r V { x s denotes the capture avoiding substitution of V for all free occurrences of x in M . To have extensionality we add: p η c q unit λ x . p unit x ‹ V q Ý Ñ unit V if x R FV p V q Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 4 / 18
wrt Moggi’s calculus λ u c versus type free λ c : translation let is definable: let x “ M in N ” M ‹ λ x . N No primitive functional application but p λ x . M q V ” p unit V q ‹ p λ x . M q VM ” M ‹ V MN ” M ‹ λ z . p N ‹ z q for some fresh z By this we retrieve ordinary call-by-value reduction rule: p β v q p λ x . M q V ” p unit V q ‹ p λ x . M q Ý Ñ β c M r V { x s Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 5 / 18
wrt Moggi’s calculus λ u c versus type free λ c : translation let is definable: let x “ M in N ” M ‹ λ x . N No primitive functional application but p λ x . M q V ” p unit V q ‹ p λ x . M q VM ” M ‹ V MN ” M ‹ λ z . p N ‹ z q for some fresh z Bonus track: shuffling calculus V pp λ x . L q N q ÞÑ σ 3 p λ x . VL q N that translated p N ‹ λ x . L q ‹ V ÞÑ σ 3 N ‹ λ x . p L ‹ V q and p N ‹ λ x . L q ‹ V ÞÑ ass N ‹ λ x . p L ‹ V q if V is a variable Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 5 / 18
wrt Moggi’s calculus λ u c versus type free λ c : mutual interpretation Theorem There exists an interpretation z ¨ { from λ C into λ u c that preserves reductions . There exists an interpretation x ¨ y from λ u c into λ C that preserves the convertibility relation . The reduction relation λ C is confluent . This has been shown by Makoto Hamana, Polymorphic Rewrite Rules: Confluence, Type Inference, and Instance Validation , 2018. It is done by checking critical pair using his tool. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 6 / 18
Confluence Confluence M ˚ ˚ ✛ ✲ N L ✲ ✛ ˚ ˚ D P Reduction in λ u c has three basic rules whose left-hand sides may overlap (not orthogonal). We split the proof in three steps: 1+2. proving confluence of β c Y id and ass separately, 3. eventually combining by means of the commutativity of these relations. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 7 / 18
Confluence Confluence M ˚ ˚ ✛ ✲ N L ✲ ✛ ˚ ˚ D P Reduction in λ u c has three basic rules whose left-hand sides may overlap (not orthogonal). We split the proof in three steps: 1+2. proving confluence of β c Y id and ass separately, 3. eventually combining by means of the commutativity of these relations. Adopted strategy: call-by-need calculi with the let construct (see [2, 6]) variant of call-by-value λ -calculus in [5], Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 7 / 18
Confluence Ñ β c , id confluence Ý Define the following relation Ý ˝ Ñ , as in the book [7] ch. 10. Definition The relation Ý ˝ Ñ Ď Term ˆ Term is inductively defined by: x Ý ˝ Ñ x 1 M Ý ˝ Ñ N ñ λ x . M Ý ˝ Ñ λ x . N 2 Ñ V 1 ñ unit V V Ý ˝ Ý ˝ Ñ unit V 1 3 Ñ M 1 and V Ñ V 1 ñ M ‹ V Ñ M 1 ‹ V 1 Ý ˝ Ý ˝ Ý ˝ M 4 Ñ M 1 and V Ñ V 1 ñ unit V ‹ λ x . M M Ý ˝ Ý ˝ Ý ˝ Ñ M 1 r V 1 { x s 5 Ñ M 1 ñ M ‹ λ x . unit x Ý ˝ Ý ˝ Ñ M 1 M 6 Lemma (Substitutivity lemma) For M , M 1 P Com and V , V 1 P Val and every variable x, Ñ M 1 and V if M Ý ˝ Ý ˝ Ñ V 1 , then M r V { x s Ý ˝ Ñ M 1 r V 1 { x s . Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 8 / 18
Confluence Ñ β c , id confluence Ý Define the following relation Ý ˝ Ñ , as in the book [7] ch. 10. Definition The relation Ý ˝ Ñ Ď Term ˆ Term is inductively defined by: x Ý ˝ Ñ x 1 M Ý ˝ Ñ N ñ λ x . M Ý ˝ Ñ λ x . N 2 Ñ V 1 ñ unit V V Ý ˝ Ý ˝ Ñ unit V 1 3 Ñ M 1 and V Ñ V 1 ñ M ‹ V Ñ M 1 ‹ V 1 Ý ˝ Ý ˝ Ý ˝ M 4 Ñ M 1 and V Ñ V 1 ñ unit V ‹ λ x . M M Ý ˝ Ý ˝ Ý ˝ Ñ M 1 r V 1 { x s 5 Ñ M 1 ñ M ‹ λ x . unit x Ý ˝ Ý ˝ Ñ M 1 M 6 Lemma (Substitutivity lemma) For M , M 1 P Com and V , V 1 P Val and every variable x, Ñ M 1 and V if M Ý ˝ Ý ˝ Ñ V 1 , then M r V { x s Ý ˝ Ñ M 1 r V 1 { x s . ˚ Ý Ñ β c , id Ď ˝ Ý Ñ Ď Ý Ñ β c , id Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 8 / 18
Confluence Ñ β c , id confluence Ý The next step in the proof is to show that TP implies the diamond property the relation Ý ˝ Ñ satisfies the triangle property TP : P P ✛ ✲ ✛ N L Q ✲ ✛ ✲ ❄ D P 1 D P ˚ In fact, if TP holds then we can take P 1 ” P ˚ in DP , since the latter only depends on P . We then define P ˚ in terms of P as defining an adapted version of Takahashi translation. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 9 / 18
Confluence Ñ β c , id confluence Ý The next step in the proof is to show that TP implies the diamond property the relation Ý ˝ Ñ satisfies the triangle property TP : P P ✛ ✲ ✛ N L Q ✲ ✛ ✲ ❄ D P 1 D P ˚ In fact, if TP holds then we can take P 1 ” P ˚ in DP , since the latter only depends on P . We then define P ˚ in terms of P as defining an adapted version of Takahashi translation. Lemma For all P , Q P Term, if P Ý ˝ Ñ Q then Q Ý ˝ Ñ P ˚ , namely Ý ˝ Ñ satisfies TP. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 9 / 18
Confluence Ñ β c , id confluence Ý The next step in the proof is to show that TP implies the diamond property the relation Ý ˝ Ñ satisfies the triangle property TP : P P ✛ ✲ ✛ N L Q ✲ ✛ ✲ ❄ D P 1 D P ˚ In fact, if TP holds then we can take P 1 ” P ˚ in DP , since the latter only depends on P . We then define P ˚ in terms of P as defining an adapted version of Takahashi translation. Proposition Ý Ñ β c , id is confluent. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 9 / 18
Confluence ass confluence To prove confluence of ass , we use Newman Lemma (see [4], Prop. 3.1.24). A notion of reduction R is weakly Church-Rosser , shortly WCR , if M ✛ ✲ N L ✲ ✛ ˚ ˚ D P Lemma The notion of reduction ass is WCR. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 10 / 18
Confluence ass confluence Recall that a notion of reduction R is strongly normalizing , shortly SN , if there exists no infinite reduction M Ý Ñ R M 1 Ý Ñ R M 2 Ý Ñ R ¨ ¨ ¨ out of any M P Com . Lemma The notion of reduction ass is SN. Ugo de’Liguoro,Riccardo Treglia (University of Turin) On the reduction of Comp. λ -Calc. IWC 2020 11 / 18
Recommend
More recommend