AFTD Auto-Formalizing Theoretical Domains

Cslib.FreeM.Interprets

structureimported Lean

A predicate stating that interp : FreeM F α → m α is an interpreter for the effect handler handler : ∀ {α}, F α → m α. This means that interp is a monad morphism from the free monad FreeM F to the monad m, and that it extends the interpretation of individual operations given by f. Formally, interp satisfies the two equations: - interp (pure a) = pure a - interp (liftBind op k) = handler op >>= fun x => interp (k x)

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
universe u v w w' w'' in
variable {F : Type u → Type v} {ι : Type u} {α : Type w} {β : Type w'} {γ : Type w''} in
variable {m : Type u → Type w} [Monad m] {α β : Type u} in
structure Cslib.FreeM.Interprets (handler : {ι : Type u} → F ι → m ι) (interp : FreeM F α → m α) : Prop
Defined in
CSLib, `Cslib.FreeM.Interprets`
Lean proof
By Tanner Duve, Eric Wieser, from github.com/leanprover/cslib at 3951377e5a3f (Copyright (c) 2025 Tanner Duve. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.33.0.
Verified
08 Oct 2026
Axioms
none listed
Built on 26
Used by 7

Lean source view module on GitHub

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
universe u v w w' w'' in
variable {F : Type u → Type v} {ι : Type u} {α : Type w} {β : Type w'} {γ : Type w''} in
variable {m : Type u → Type w} [Monad m] {α β : Type u} in
/-- A predicate stating that `interp : FreeM F α → m α` is an interpreter for the effect handler `handler : ∀ {α}, F α → m α`. This means that `interp` is a monad morphism from the free monad `FreeM F` to the monad `m`, and that it extends the interpretation of individual operations given by `f`. Formally, `interp` satisfies the two equations: - `interp (pure a) = pure a` - `interp (liftBind op k) = handler op >>= fun x => interp (k x)` -/
structure Cslib.FreeM.Interprets (handler : {ι : Type u} → F ι → m ι) (interp : FreeM F α → m α) : Prop where
  apply_pure (a : α) : interp (.pure a) = pure a
  apply_lift_bind {ι : Type u} (op : F ι) (cont : ι → FreeM F α) :
    interp (lift op >>= cont) = handler op >>= fun x => interp (cont x)
See it in the graphDiscuss this resultChallenge it