Distribution Semantics for Computations with Lists and Vectors #
This file contains lemmas for probEvent and probOutput of computations involving List.
We also include Vector as a related case.
All lemmas are generic over any monad m with [HasEvalSPMF m].
theorem
cons_mem_finSupport_seq_map_cons_iff
{α : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
[LawfulMonad m]
[HasEvalFinset m]
[DecidableEq α]
(mx : m α)
(my : m (List α))
(x : α)
(xs : List α)
:
@[simp]
theorem
probOutput_map_append_left
{α : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
[LawfulMonad m]
[DecidableEq α]
(xs : List α)
(mx : m (List α))
(ys : List α)
:
@[simp]
theorem
probOutput_list_mapM_loop
{α β : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
[DecidableEq β]
(xs : List α)
(f : α → m β)
(ys zs : List β)
:
@[simp]
@[simp]
theorem
probOutput_list_mapM'
{α β : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
[LawfulMonad m]
(xs : List α)
(f : α → m β)
(ys : List β)
:
@[simp]
theorem
support_seq_map_vector_cons
{α : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
{n : ℕ}
(mx : m α)
(my : m (List.Vector α n))
[LawfulMonad m]
:
@[simp]
theorem
probOutput_seq_map_vector_cons_eq_mul
{α : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
{n : ℕ}
(mx : m α)
(my : m (List.Vector α n))
[LawfulMonad m]
(xs : List.Vector α (n + 1))
:
@[simp]
theorem
probOutput_seq_map_vector_cons_eq_mul'
{α : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
{n : ℕ}
(mx : m α)
(my : m (List.Vector α n))
[LawfulMonad m]
(xs : List.Vector α (n + 1))
:
@[simp]
theorem
probOutput_vector_toList
{α : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
{n : ℕ}
[LawfulMonad m]
(mx' : m (List.Vector α n))
(xs : List α)
:
@[simp]
theorem
neverFail_list_vector_mmap
{α β : Type v}
{m : Type v → Type u_1}
[Monad m]
[HasEvalSPMF m]
{n : ℕ}
{f : α → m β}
{as : List.Vector α n}
(h : ∀ x ∈ as.toList, NeverFail (f x))
:
NeverFail (List.Vector.mmap f as)
NeverFail lemmas for list monadic operations #
@[simp]
theorem
neverFail_list_mapM
{α : Type u_1}
{β : Type u_2}
{m : Type u_2 → Type u_3}
[Monad m]
[LawfulMonad m]
[HasEvalSPMF m]
{f : α → m β}
{as : List α}
(h : ∀ x ∈ as, NeverFail (f x))
:
@[simp]
theorem
neverFail_list_mapM'
{α : Type u_1}
{β : Type u_2}
{m : Type u_2 → Type u_3}
[Monad m]
[HasEvalSPMF m]
{f : α → m β}
{as : List α}
(h : ∀ x ∈ as, NeverFail (f x))
:
NeverFail (List.mapM' f as)
@[simp]
theorem
neverFail_list_flatMapM
{α : Type u_1}
{β : Type u_2}
{m : Type u_2 → Type u_3}
[Monad m]
[LawfulMonad m]
[HasEvalSPMF m]
{f : α → m (List β)}
{as : List α}
(h : ∀ x ∈ as, NeverFail (f x))
:
NeverFail (List.flatMapM f as)
@[simp]
theorem
neverFail_list_filterMapM
{α : Type u_1}
{β : Type u_2}
{m : Type u_2 → Type u_3}
[Monad m]
[LawfulMonad m]
[HasEvalSPMF m]
{f : α → m (Option β)}
{as : List α}
(h : ∀ x ∈ as, NeverFail (f x))
:
NeverFail (List.filterMapM f as)
@[simp]
theorem
neverFail_list_foldlM
{α : Type u_1}
{m : Type u_3 → Type u_4}
[Monad m]
[HasEvalSPMF m]
{s : Type u_3}
{f : s → α → m s}
{init : s}
{as : List α}
(h : ∀ (i : s), ∀ x ∈ as, NeverFail (f i x))
:
NeverFail (List.foldlM f init as)
@[simp]
theorem
neverFail_list_foldrM
{α : Type u_1}
{m : Type u_3 → Type u_4}
[Monad m]
[LawfulMonad m]
[HasEvalSPMF m]
{s : Type u_3}
{f : α → s → m s}
{init : s}
{as : List α}
(h : ∀ (i : s), ∀ x ∈ as, NeverFail (f x i))
:
NeverFail (List.foldrM f init as)