algebraic effects and handlers in natural language
play

Algebraic Effects and Handlers in Natural Language Interpretation - PowerPoint PPT Presentation

Algebraic Effects and Handlers in Natural Language Interpretation Ji r Mar s k and Maxime Amblard LORIA, UMR 7503, Universit e de Lorraine, CNRS, Inria, Campus Scientifique, F-54506 Vanduvre-l` es-Nancy, France July 17,


  1. Algebraic Effects and Handlers in Natural Language Interpretation Jiˇ r´ ı Marˇ s´ ık and Maxime Amblard LORIA, UMR 7503, Universit´ e de Lorraine, CNRS, Inria, Campus Scientifique, F-54506 Vandœuvre-l` es-Nancy, France July 17, 2014 1/19

  2. Objectives 1. Detailed semantics for a large-scale grammar of a natural language 2. Capturing the interactions of non-local (i.e. non-compositional) semantic phenomena ◮ anaphora ◮ in-situ quantification ◮ event arguments ◮ presupposition ◮ intensionalization ◮ extraction ◮ . . . 3. Multiple semantic phenomena in a single treatment without overly complicated types and terms 2/19

  3. In-situ quantification Barker (2002) Mary read every book. ∀ x . book ( x ) → read ( Mary , x ) � s � = o � np � = ( ι → o ) → o � read � : � np � → � np � → � s � � read � : (( ι → o ) → o ) → (( ι → o ) → o ) → o � read � = λ so . s ( λ x . o ( λ y . read ( x , y ))) 3/19

  4. Anaphora de Groote (2006) Mary 1 read her 1 favorite book. read ( Mary , favorite-book ( Mary )) � s � = o = γ → ( γ → o ) → o � np � = ( ι → o ) → o = ( ι → γ → ( γ → o ) → o ) → γ → ( γ → o ) → o � read � : � np � → � np � → � s � � read � : (( ι → o ) → o ) → (( ι → o ) → o ) → o � read � : (( ι → γ → ( γ → o ) → o ) → γ → ( γ → o ) → o ) → (( ι → γ → ( γ → o ) → o ) → γ → ( γ → o ) → o ) → γ → ( γ → o ) → o � read � = λ so . s ( λ x . o ( λ ye φ. read ( x , y ) ∧ φ e )) 4/19

  5. Motivation ◮ non-local phenomena + compositionality = generalizing meaning (often by abstracting over some new parameter) ◮ more non-local phenomena ⇒ more parameters ⇒ more complexity ◮ most research focuses on single phenomena 5/19

  6. Effects in Interpretation semantic generalizations ≈ monads (Shan 2002) Montague’s PTQ ≈ evaluation order + continuations (Barker 2002) non-local phenomena ≈ computational effects ⇒ elegant explanation of their interactions (Kiselyov 2008; Shan 2005) 6/19

  7. Effects and Handlers Introduction ◮ Effectful operation: throws an exception containing the supplied argument and the current continuation ◮ Handlers: capture the exceptions to implement the operations ◮ e.g. just by applying the continuation to some result ◮ Type-and-effect system: like Java’s checked exceptions ( op : A → B ) ∈ E Γ ⊢ V : A Γ , x : B ⊢ E M : C Γ ⊢ E op V ( λ x . M ) : C (Kammar, Lindley, and Oury 2013) 7/19

  8. Effects and Handlers Advantages ◮ Easier to combine multiple effects in a single semantics (Cartwright and Felleisen 1994) (Kiselyov, Sabry, and Swords 2013) � A × � C E � B � C E � = C + ( op : A → B ) ∈ E “effects + handlers” : “delimited continuations” = “while” : “goto” (Bauer and Pretnar 2012) 8/19

  9. Translating Dynamic Logic Effects and Handlers ◮ Effectful operations get : 1 → γ { get } fresh : 1 → ι { fresh } assert : o → 1 { assert } scope over : (( ι → o ) → o ) → ι { scope over } move : 1 → ι { move } ◮ Handlers drs : γ → ( o { get ; fresh ; assert | ρ } ⇒ o ρ ) tensed clause : o { scope over | ρ } ⇒ o ρ extract : α { move | ρ } ⇒ ( ι → α ρ ) 9/19

  10. Translating Dynamic Logic Logical Connectives ∃ P = λ e φ. ∃ x . Px ( x :: e ) φ ¬ A = λ e φ. ¬ ( Ae ( λ e ′ . ⊤ )) ∧ φ e A ∧ B = λ e φ. Ae ( λ e ′ . Be ′ φ ) 10/19

  11. Translating Dynamic Logic Logical Connectives ∃ P = λ e φ. ∃ x . Px ( x :: e ) φ ∃ P = P ( fresh ()) ¬ A = λ e φ. ¬ ( Ae ( λ e ′ . ⊤ )) ∧ φ e ¬ A = ¬ ( with drs ( get ()) handle A ) A ∧ B = λ e φ. Ae ( λ e ′ . Be ′ φ ) A ∧ B = A ∧ B 10/19

  12. Translating Dynamic Logic Logical Connectives ∃ P = λ e φ. ∃ x . Px ( x :: e ) φ ∃ P = P ( fresh ()) ¬ A = λ e φ. ¬ ( Ae ( λ e ′ . ⊤ )) ∧ φ e ¬ A = ¬ ( with drs ( get ()) handle A ) A ∧ B = λ e φ. Ae ( λ e ′ . Be ′ φ ) A ∧ B = A ∧ B A → B = ¬ ( A ∧ ¬ B ) ∀ P = ¬ ∃ x . ¬ Px 10/19

  13. Translating Dynamic Logic Lexical Items � she � = λ ke φ. k ( sel she ( e )) e φ � something � = λ k . ∃ x . ( k x ) = λ ke φ. ∃ x . kx ( x :: e ) φ � every � = λ nk . ∀ x . ( n x ) → ( k x ) � read � = λ SO . S ( λ s . O ( λ oe φ. read ( s , o ) ∧ φ e )) 11/19

  14. Translating Dynamic Logic Lexical Items � she � = λ ke φ. k ( sel she ( e )) e φ � she � = λ k . k ( sel she ( get ())) � something � = λ k . ∃ x . ( k x ) = λ ke φ. ∃ x . kx ( x :: e ) φ � something � = λ k . ∃ x . ( k x ) = λ k . k ( fresh ()) � every � = λ nk . ∀ x . ( n x ) → ( k x ) � every � = λ nk . ∀ x . ( n x ) → ( k x ) � read � = λ SO . S ( λ s . O ( λ oe φ. read ( s , o ) ∧ φ e )) � read � = λ SO . S ( λ s . O ( λ o . read ( s , o ))) 11/19

  15. Translating Dynamic Logic Lexical Items � she � = λ ke φ. k ( sel she ( e )) e φ � she � = λ k . k ( sel she ( get ())) � she � = { sel she ( get ()) } � something � = λ k . ∃ x . ( k x ) = λ ke φ. ∃ x . kx ( x :: e ) φ � something � = λ k . ∃ x . ( k x ) = λ k . k ( fresh ()) � something � = { fresh () } � every � = λ nk . ∀ x . ( n x ) → ( k x ) � every � = λ nk . ∀ x . ( n x ) → ( k x ) � every � = λ n . { scope over ( λ k . ∀ x . ( n x ) → ( k x )) } � read � = λ SO . S ( λ s . O ( λ oe φ. read ( s , o ) ∧ φ e )) � read � = λ SO . S ( λ s . O ( λ o . read ( s , o ))) � read � = λ s t o t . { with tensed clause handle read ( s t ! , o t !) } 11/19

  16. Translating Dynamic Logic Lexical Items (cont’d) � some � = λ nk . ∃ x . ( n x ) ∧ ( k x ) � who � = λ rnx . nx ∧ r ( λ k . kx ) 12/19

  17. Translating Dynamic Logic Lexical Items (cont’d) � some � = λ nk . ∃ x . ( n x ) ∧ ( k x ) � some � = λ nk . ∃ x . ( n x ) ∧ ( k x ) = λ nk . k ( let x = fresh () in let () = assert ( n x ) in x ) � who � = λ rnx . nx ∧ r ( λ k . kx ) � who � = λ rnx . nx ∧ r ( λ k . kx ) 12/19

  18. Translating Dynamic Logic Lexical Items (cont’d) � some � = λ nk . ∃ x . ( n x ) ∧ ( k x ) � some � = λ nk . ∃ x . ( n x ) ∧ ( k x ) = λ nk . k ( let x = fresh () in let () = assert ( n x ) in x ) � some � = λ n . { scope over ( λ k . ∃ x . ( n x ) ∧ ( k x )) } = λ n . { let x = fresh () in let () = assert ( n x ) in x } � who � = λ rnx . nx ∧ r ( λ k . kx ) � who � = λ rnx . nx ∧ r ( λ k . kx ) � who � = λ rnx . nx ∧ rx 12/19

  19. Treating Extraction as an Effect � who � : � s � { move | ρ } → � n � → � n � ρ � who � = λ r t n .λ x . let r = with extract handle r t ! in ( n x ) ∧ ( r x ) r t : o { move | ρ } r : ι → o ρ n : ι → o x : ι � ǫ � : � np � { move } � ǫ � = { move () } 13/19

  20. Example - Syntax Every farmer who owns a donkey beats it. 14/19

  21. Example - Semantics Every farmer who owns a donkey beats it. 15/19

  22. Conclusion We have: ◮ motivated the use of algebraic effects and handlers in semantics. ◮ translated de Groote’s continuation-based dynamic logic (de Groote 2006) to effects, reconstructing notions from DRT. ◮ treated extraction as an effect in interpretation instead of using hypothetical reasoning and lambda abstractions in the syntax. 16/19

  23. Future Work We would like to: ◮ show how effects and handlers apply to the other non-local phenomena (presupposition, event arguments, optional items, intensionalization). ◮ build a fragment that combines all of these. ◮ design a calculus with algebraic effects and handlers and a suitable evaluation order (CBV vs CBN). 17/19

  24. Thank You Questions? Would you like to know more? http://jirka.marsik.me/research/ algebraic-effects-and-handlers-in-natural-language-interpretation 18/19

  25. References Barker, Chris (2002). “Continuations and the nature of quantification”. Bauer, Andrej and Matija Pretnar (2012). “Programming with algebraic effects and handlers”. Cartwright, Robert and Matthias Felleisen (1994). “Extensible denotational language specifications”. de Groote, Philippe (2006). “Towards a montagovian account of dynamics”. Kammar, Ohad, Sam Lindley, and Nicolas Oury (2013). “Handlers in action”. Kiselyov, Oleg (2008). “Call-by-name linguistic side effects”. Kiselyov, Oleg, Amr Sabry, and Cameron Swords (2013). “Extensible effects: an alternative to monad transformers”. Shan, Chung-chieh (2002). “Monads for natural language semantics”. Shan, Chung-chieh (2005). “Linguistic Side Effects”. 19/19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend