All proofs
Project-declaredLean 4.31.0 · null

Foldl M of assoc some

List.foldlM_of_assoc_some

Project documentation

our own variant of map_congr, for mapM -/ public theorem mapM_congr [Monad m] [LawfulMonad m] {f g : α → m β} : ∀ {l : List α}, (∀ x ∈ l, f x = g x) → mapM f l = mapM g l := by intro l rw [← mapM'_eq_mapM, ← mapM'_eq_mapM] exact mapM'_congr public theorem to_option_distr_mapM' {α β ε} {l : List α} {f: α → Except ε β} : (List.mapM' f l).toOption = (List.ma...

Exact Lean statement

public theorem foldlM_of_assoc_some (f : α → α → Option α) (x₀ x₁ x₂ x₃ : α) (xs : List α)
  (h₁ : ∀ x₁ x₂ x₃,
    (do let x₄ ← f x₁ x₂ ; f x₄ x₃) =
    (do let x₄ ← f x₂ x₃ ; f x₁ x₄))
  (h₂ : f x₀ x₁ = some x₂)
  (h₃ : List.foldlM f x₂ xs = some x₃):
  (do let y ← List.foldlM f x₁ xs ; f x₀ y) = some x₃

Formal artifact

Lean source

Canonical source
Full Lean sourceLean 4
public theorem foldlM_of_assoc_some (f : α  α  Option α) (x₀ x₁ x₂ x₃ : α) (xs : List α)  (h₁ :  x₁ x₂ x₃,    (do let x₄  f x₁ x₂ ; f x₄ x₃) =    (do let x₄  f x₂ x₃ ; f x₁ x₄))  (h₂ : f x₀ x₁ = some x₂)  (h₃ : List.foldlM f x₂ xs = some x₃):  (do let y  List.foldlM f x₁ xs ; f x₀ y) = some x₃:= by  cases xs  case nil =>    simp only [Option.bind_eq_bind, List.foldlM, pure, Option.some.injEq, Option.bind_some_fun] at *    subst h₃; exact h₂  case cons hd tl =>    simp only [Option.bind_eq_bind, List.foldlM, Option.bind_eq_some_iff] at *    cases h₄ : f x₂ hd <;> simp only [h₄, false_and, exists_false, Option.some.injEq, exists_eq_left', reduceCtorEq] at h₃    case some x₄ =>    have h₅ := h₁ x₀ x₁ hd    simp only [h₂, h₄, Option.bind_some] at h₅    cases h₆ : f x₁ hd <;> simp only [h₆, Option.bind_some, Option.bind_none, reduceCtorEq] at h₅    case some x₅ =>    have h₇ := List.foldlM_of_assoc_some f x₂ hd x₄ x₃ tl h₁ h₄ h₃    cases h₈ : List.foldlM f hd tl <;> simp only [h₈, Option.bind_some_fun, Option.bind_none_fun, reduceCtorEq] at h₇    case some x₆ =>    rw [eq_comm] at h₅    cases h₉ : List.foldlM f x₅ tl <;> simp only [h₉, Option.some.injEq, exists_eq_left']    case none =>      have h₁₀ := List.foldlM_of_assoc_some f x₀ x₅ x₄ x₃ tl h₁ h₅ h₃      simp [h₉] at h₁₀    case some x₇ =>      have h₁₀ := List.foldlM_of_assoc_some f x₁ hd x₅ x₇ tl h₁ h₆ h₉      simp only [h₈, Option.bind_some_fun] at h₁₀      specialize h₁ x₀ x₁ x₆      simp only [h₂, h₁₀, Option.bind_some] at h₁      simp [h₁, h₇]
Project
Cedar Specification
License
Apache-2.0
Commit
3f093947b8ae
Source
cedar-lean/Cedar/Thm/Data/List/Lemmas.lean:1316-1349

Reuse this declaration

Bring the exact result into your workflow

The import identifies the source module. Your project still needs the pinned package dependency shown on this page.

What this badge means

This completion status comes from the project or community source. It has not yet been represented here as an independent rebuild and axiom audit.

Continue in this project

Related declarations

Project-declaredLean 4.31.0

Find? ext

Cedar.Data.Map.find?_ext

Plain-language statement

Two well-formed maps are equal if they have the same find? for every key.

authorizationprogram verificationsemantics

Source project: Cedar Specification

Person-level attribution pending.

View proof record
Project-declaredLean 4.31.0

Find? notmem keys

Cedar.Data.Map.find?_notmem_keys

Plain-language statement

Inverse of find?_mem_toList, except that this requires wf

authorizationprogram verificationsemantics

Source project: Cedar Specification

Person-level attribution pending.

View proof record
Project-declaredLean 4.31.0

Find? some iff in values

Cedar.Data.Map.find?_some_iff_in_values

Plain-language statement

The mp direction of this does not need the wf precondition and, in fact, is available separately as find?_some_implies_in_values above

authorizationprogram verificationsemantics

Source project: Cedar Specification

Person-level attribution pending.

View proof record