AFTD Auto-Formalizing Theoretical Domains

Cslib.FreeM.foldFreeM_unique

theoremverifiedformalizationimported Lean

Universal Property: If h : FreeM F α → β satisfies: * h (pure a) = onValue a * h ((lift op).bind k) = onEffect op (fun x => h (k x)) then h is equal to foldFreeM onValue onEffect.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
universe u v w w' in
variable {F : Type u → Type v} {ι : Type u} {α : Type w} {β : Type w'} in
theorem Cslib.FreeM.foldFreeM_unique
    (onValue : α → β)
    (onEffect : {ι : Type u} → F ι → (ι → β) → β)
    (h : FreeM F α → β)
    (h_pure : ∀ a, h (pure a) = onValue a)
    (h_liftBind : ∀ {ι} (op : F ι) (k : ι → FreeM F α),
      h ((lift op).bind k) = onEffect op (fun x => h (k x))) :
    h = foldFreeM onValue onEffect
Formalizes
CSLib, `Cslib.FreeM.foldFreeM_unique`
Lean proof
By Tanner Duve, 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
Classical.choiceQuot.soundpropext
Built on 33

Lean source view module on GitHub

set_option autoImplicit true inset_option relaxedAutoImplicit true inuniverse u v w w' invariable {F : Type u → Type v} {ι : Type u} {α : Type w} {β : Type w'} in/-- **Universal Property**: If `h : FreeM F α → β` satisfies: * `h (pure a) = onValue a` * `h ((lift op).bind k) = onEffect op (fun x => h (k x))` then `h` is equal to `foldFreeM onValue onEffect`. -/theorem Cslib.FreeM.foldFreeM_unique    (onValue : α → β)    (onEffect : {ι : Type u} → F ι → (ι → β) → β)    (h : FreeM F α → β)    (h_pure : ∀ a, h (pure a) = onValue a)    (h_liftBind : ∀ {ι} (op : F ι) (k : ι → FreeM F α),      h ((lift op).bind k) = onEffect op (fun x => h (k x))) :    h = foldFreeM onValue onEffect := by  funext x  induction x with  | pure a =>    rw [foldFreeM_pure, h_pure]  | lift_bind op k ih =>    rw [foldFreeM_lift_bind, h_liftBind]    grind
See it in the graphDiscuss this resultChallenge it