Evaluation Semantics for ReaderT #
This file provides monad homomorphisms for evaluating ReaderT ρ m computations
by fixing the environment parameter.
Unlike StateT, ReaderT evaluation at a fixed environment is a valid monad homomorphism
because the environment is read-only and doesn't change during computation.
Main definitions #
ReaderT.evalAt ρ0: Monad homomorphismReaderT ρ m →ᵐ mby evaluation atρ0HasEvalSPMF.readerAt ρ0: LiftHasEvalSPMF mthroughReaderTat fixedρ0HasEvalPMF.readerAt ρ0: LiftHasEvalPMF mthroughReaderTat fixedρ0
Design notes #
We do NOT provide global HasEvalSPMF (ReaderT ρ m) instances because there's no
canonical choice of environment. Instead, users explicitly provide the environment
when constructing the evaluation homomorphism.
For cryptographic games with random oracles, the typical pattern is:
- Generate oracle table with some distribution
- Use
readerAtto evaluate the protocol at that table - Compose with the table distribution to get overall game probability
Lift HasEvalSPMF m to a homomorphism ReaderT ρ m →ᵐ SPMF by fixing ρ0.
This allows evaluating reader computations to sub-probability distributions
when the base monad m has such an evaluation.
Equations
Instances For
Lift HasEvalPMF m to a homomorphism ReaderT ρ m →ᵐ PMF by fixing ρ0.
This allows evaluating reader computations to probability distributions
when the base monad m has such an evaluation.
Equations
Instances For
Evaluating pure x at any environment gives the same result as pure x in the base monad.
Evaluating a bind distributes through the monad homomorphism.
Optional: Instances with canonical environments #
If you have a canonical choice of environment (e.g., via [Inhabited ρ]),
you can uncomment these to get automatic HasEvalSPMF/PMF instances.
However, for most cryptographic use cases, it's better to keep the environment
explicit and use the readerAt homomorphisms directly.
noncomputable instance [HasEvalSPMF m] [Inhabited ρ] :
HasEvalSPMF (ReaderT ρ m) where
toSPMF := HasEvalSPMF.readerAt (m := m) default
noncomputable instance [HasEvalPMF m] [Inhabited ρ] :
HasEvalPMF (ReaderT ρ m) where
toPMF := HasEvalPMF.readerAt (m := m) default