Oooh, scary! wren ng thornton wrnthorn@indiana.edu Cognitive - - PowerPoint PPT Presentation

oooh scary
SMART_READER_LITE
LIVE PREVIEW

Oooh, scary! wren ng thornton wrnthorn@indiana.edu Cognitive - - PowerPoint PPT Presentation

Monads Oooh, scary! wren ng thornton wrnthorn@indiana.edu Cognitive Science & Computational Linguistics Indiana University Bloomington wren ng thornton Probability Smoothing for NLP p. 1/7 Outline of the talk Categories


slide-1
SLIDE 1

Monads

Oooh, scary!

wren ng thornton

wrnthorn@indiana.edu

Cognitive Science & Computational Linguistics Indiana University Bloomington

wren ng thornton Probability Smoothing for NLP – p. 1/7

slide-2
SLIDE 2

Outline of the talk

  • Categories
  • Functors
  • Monads

wren ng thornton Probability Smoothing for NLP – p. 2/7

slide-3
SLIDE 3

Categories

  • Objects (e.g., types)
  • Int, Bool, Int×Int, . . .
  • Morphisms (e.g., functions)
  • f :Char → Int, . . .
  • Composition
  • ∀ f :A → B. ∀g:B → C. ∃ g◦ f :A → C
  • Identity morphisms
  • ∀A. ∃idA : A → A such that

∀ f :A → B. f ◦idA = f ∀ f :B → A. idA ◦f = f

wren ng thornton Probability Smoothing for NLP – p. 3/7

slide-4
SLIDE 4

Functors

  • A map F :C → D from category C to category D
  • Let’s assume C = D
  • F takes C-objects to D-objects
  • data List A = Nil | Cons A (List A)
  • data Maybe A = Nothing | Just A
  • data Tree A = Tip A | Bin (Tree A) (Tree A)
  • F takes C-morphisms to D-morphisms
  • mapList :(A → B) → (List A → List B)
  • mapMaybe :(A → B) → (Maybe A → Maybe B)
  • mapTree :(A → B) → (Tree A → Tree B)
  • And follows some laws
  • ∀A.

F (idA) = id(F A)

  • ∀ f. ∀g.

(F f)◦(F g) = F (f ◦g)

wren ng thornton Probability Smoothing for NLP – p. 4/7

slide-5
SLIDE 5

Monads

  • A functor T with some extra stuff
  • A “unit” natural transformation (aka pure, return, point,. . . )
  • η :Id ˙

→T . . . What?!

  • ∀A. ηA :A → T A

. . . not quite

  • η :∀A. A → T A
  • And a “join” natural transformation (or “bind” (>

> =) instead)

  • µ :T ◦T ˙

→ T

  • concat:∀A. List (List A) → List A
  • Following some laws
  • µA ◦ηA = idA
  • µA ◦T ηA = idA
  • µA ◦T µA = µT A ◦ µA

wren ng thornton Probability Smoothing for NLP – p. 5/7

slide-6
SLIDE 6

Monads

wren ng thornton Probability Smoothing for NLP – p. 6/7

slide-7
SLIDE 7

∼fin.

wren ng thornton Probability Smoothing for NLP – p. 7/7