YukonModule.VCVio.OracleComp.HasQuery.Morphism.part0
DefinitionYukon_e3fd5de4db781670631c9e44better-codes
Source module VCVio.OracleComp.HasQuery.Morphism.
Definition code
/-
Copyright (c) 2026 Quang Dao. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Quang Dao
-/
module
public import Definitions.Def_Yukon_0c415a7ac30982e40294fe41
public import Definitions.Def_Yukon_3ca8dea642d23c4bd0e25cee
public import Definitions.Def_Yukon_2a6b3412af2af8cd7980168b
public import Mathlib.CategoryTheory.Monad.Types
public import Mathlib.Order.CompleteLattice.Basic
public import Init
public import Mathlib.Probability.ProbabilityMassFunction.Monad
public import Batteries.Control.OptionT
public import Mathlib.Probability.Distributions.Uniform
public import Mathlib.Data.Vector.Defs
public import Mathlib.Data.Finset.Card
public import Batteries.Control.AlternativeMonad
public import Mathlib.Data.PFunctor.Multivariate.Basic
public import Mathlib.Data.PFunctor.Univariate.Basic
public import Mathlib.Tactic.Common
public import Mathlib.Init
public import Lean.Message
public import Batteries.Tactic.Lint.Basic
public import Batteries.Tactic.Lint
public import Mathlib.Algebra.Polynomial.Eval.Defs
public import Mathlib.Algebra.MvPolynomial.Eval
meta import Definitions.Def_Yukon_2a6b3412af2af8cd7980168b
meta import Definitions.Def_Yukon_0c415a7ac30982e40294fe41
meta import Definitions.Def_Yukon_3ca8dea642d23c4bd0e25cee
set_option backward.isDefEq.respectTransparency.types false
/-!
# Morphisms of `HasQuery` Monads
This module contains the heavier `HasQuery` naturality layer.
It imports `ProbComp` and monad homomorphisms, so files that only need the
basic query capability should import `VCVio.OracleComp.HasQuery.Basic`
instead.
Use this module for proofs that a monad morphism preserves oracle queries, or
that it commutes with the canonical lift of public randomness.
-/
@[expose] public section
universe u v w x
namespace HasQuery
variable {ι : Type u} {spec : OracleSpec.{u, v} ι}
{m : Type v → Type w} [Monad m] [HasQuery spec m]
{n : Type v → Type x} [Monad n] [HasQuery spec n]
/-- A `QueryHom spec m n` is a monad morphism `m →ᵐ n` that also preserves the distinguished
oracle-query capability for `spec`. This is the right notion of morphism for proving that a
construction generic over `HasQuery spec` is natural in the chosen oracle semantics. -/
structure QueryHom (spec : OracleSpec.{u, v} ι)
(m : Type v → Type w) [Monad m] [HasQuery spec m]
(n : Type v → Type x) [Monad n] [HasQuery spec n]
extends m →ᵐ n where
map_query' (t : spec.Domain) :
toFun _ (HasQuery.query (spec := spec) (m := m) t) =
HasQuery.query (spec := spec) (m := n) t
/-- A monad morphism preserves public randomness when it commutes with the distinguished lifting
of plain probabilistic computations into the ambient monad. -/
def PreservesProbCompLift
{m : Type → Type w} [Monad m] [MonadLiftT ProbComp m]
{n : Type → Type x} [Monad n] [MonadLiftT ProbComp n]
(F : m →ᵐ n) : Prop :=
∀ {α : Type} (oa : ProbComp α), F (liftM oa : m α) = (liftM oa : n α)
@[simp]
lemma map_query (F : QueryHom spec m n) (t : spec.Domain) :
F.toMonadHom (HasQuery.query (spec := spec) (m := m) t) =
HasQuery.query (spec := spec) (m := n) t :=
F.map_query' t
end HasQuery
Source