Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · First-year graduate

Monads

Name: ______________________

Date: ______________________

You will learn to

  • Verify the monad laws for the list, power-set and maybe monads on Set\cat{Set}, and identify their algebras (monoids, complete join-semilattices, pointed sets)
  • Prove that every adjunction F⊣GF \dashv G induces a monad GFGF, and construct the Kleisli and Eilenberg–Moore adjunctions that recover any monad
  • Construct the comparison functors and show that the Kleisli and Eilenberg–Moore categories need not be equivalent
  • State Beck's monadicity theorem, show that Grp\cat{Grp} is monadic over Set\cat{Set} and Top\cat{Top} is not
  • Explain how monads model computational effects and probabilistic transitions
  1. 1.

    The maybe monad on Set\mathbf{Set} has TX=X⊔{⊥}TX = X \sqcup \{\bot\}, ηX(x)=x\eta_X(x) = x, and μX\mu_X collapsing the two copies of ⊥\bot. What is a TT-algebra (A,a)(A, a)?

    • A.A set AA with a chosen element a(⊥)∈Aa(\bot) \in A (a pointed set)
    • B.A monoid
    • C.A set with an idempotent map e:A→Ae : A \to A
    • D.Any set, with no extra structure
  2. 2.

    How many algebra structures a:PA→Aa : \mathcal{P}A \to A for the power-set monad are there on the three-element set A={p,q,r}A = \{p, q, r\}?

  3. 3.

    In the Kleisli category of the list monad, let f(n)=[n,n+1]f(n) = [n, n + 1] and g(n)=[10n]g(n) = [10n] (both from Z\mathbb{Z} to List(Z)\mathrm{List}(\mathbb{Z})). What is (g∘Tf)(1)=μ(Tg(f(1)))(g \circ_T f)(1) = \mu(Tg(f(1)))?

    • A.[10,20][10, 20]
    • B.[[10],[20]][[10], [20]]
    • C.[10,11][10, 11]
    • D.[10][10]
  4. 4.

    Let F⊣GF \dashv G with F:C→DF : \mathcal{C} \to \mathcal{D}, unit η\eta and counit ε\varepsilon. The induced monad is T=GFT = GF on C\mathcal{C}. What is its multiplication μX:GFGFX→GFX\mu_X : GFGFX \to GFX?

    • A.G(εFX)G(\varepsilon_{FX})
    • B.ηGFX\eta_{GFX}
    • C.F(ηGX)F(\eta_{GX})
    • D.εFGFX\varepsilon_{FGFX}
  5. 5.

    In proving that ηA\eta_A is a right identity in the Kleisli category, we write, for f:A→TBf : A \to TB,

    f∘TηA=μB∘Tf∘ηA=μB∘ηTB∘f=f.f \circ_T \eta_A = \mu_B \circ Tf \circ \eta_A = \mu_B \circ \eta_{TB} \circ f = f.

    Which two facts justify the second and third equalities, in order?

    • A.Naturality of η\eta; then the left unit law μ∘ηT=id\mu \circ \eta T = \mathrm{id}
    • B.The right unit law μ∘Tη=id\mu \circ T\eta = \mathrm{id}; then associativity
    • C.Naturality of μ\mu; then naturality of η\eta
    • D.The two triangle identities of an adjunction
  6. 6.

    For the list monad TT on Set\mathbf{Set}, SetT≃Mon\mathbf{Set}^T \simeq \mathbf{Mon}. Which argument shows that the Kleisli category SetT\mathbf{Set}_T is not equivalent to Mon\mathbf{Mon}?

    • A.Z/2\mathbb{Z}/2 has exactly two monoid endomorphisms, but every object of SetT\mathbf{Set}_T has either one or infinitely many endomorphisms.
    • B.Mon\mathbf{Mon} has more objects than SetT\mathbf{Set}_T.
    • C.Mon\mathbf{Mon} has a zero object and SetT\mathbf{Set}_T does not.
    • D.The comparison functor SetT→SetT\mathbf{Set}_T \to \mathbf{Set}^T is not full.
  7. 7.

    Which forgetful functors to Set\mathbf{Set} are monadic? (Choose all that apply.)

    • A.Grp→Set\mathbf{Grp} \to \mathbf{Set}
    • B.Ring→Set\mathbf{Ring} \to \mathbf{Set}
    • C.Compact Hausdorff spaces →Set\to \mathbf{Set}
    • D.Top→Set\mathbf{Top} \to \mathbf{Set}
    • E.Posets →Set\to \mathbf{Set}
  8. 8.

    In the Lean file, a list algebra on X has act : List X → X. Which field states the associativity law a∘Ta=a∘μAa \circ Ta = a \circ \mu_A?

    • A.∀ xss : List (List X), act (xss.map act) = act xss.flatten
    • B.∀ x : X, act [x] = x
    • C.∀ x y : X, act [x, y] = act [y, x]
    • D.∀ xss : List (List X), act xss = act xss.flatten
  9. 9.

    Write kleisli(f, g) returning the Kleisli composite (first f, then g) for the list monad: f and g are Python functions returning lists, and the composite applies g to every output of f and concatenates. Also write unit(x) returning [x]. The tests check the Kleisli category laws on examples.

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0