Computations with Oracle Access #
OracleComp spec α represents computations with oracle access to oracles in spec,
where the final return value has type α, represented as a free monad over the PFunctor
corresponding to spec.
Equations
- OracleComp spec = spec.toPFunctor.FreeM
Instances For
Equations
- OracleComp.instMonad spec = inferInstanceAs (Monad spec.toPFunctor.FreeM)
Equations
Manually lift an OracleQuery to an OracleComp.
Equations
- OracleComp.lift q = liftM q
Instances For
coin is the computation representing a coin flip, given a coin flipping oracle.
Equations
Instances For
Nicer induction rule for OracleComp that uses monad notation.
Allows inductive definitions on compuations by considering the three cases:
return x/pure xfor anyxdo let u ← query i t; oa u(with inductive results foroa u) SeeoracleComp_emptySpec_equivfor an example of using this in a proof. If the final result needs to be aTypeand not aProp, seeOracleComp.construct.
Equations
- ⋯ = ⋯
Instances For
Version of OracleComp.inductionOn that includes an OptionT in the monad stack
and requires an explicit case to handle failure.
Equations
- ⋯ = ⋯
Instances For
Version of OracleComp.inductionOn with the computation at the start.
Equations
- ⋯ = ⋯
Instances For
Version of OracleComp.inductionOnOptional with the computation at the start.
Equations
- ⋯ = ⋯
Instances For
Version of construct with automatic induction on the query in when defining the
query_bind case. Can be useful with spec.DecidableEq and spec.FiniteRange.
mapM/simulateQ is usually preferable to this if the object being constructed is a monad.
Equations
- OracleComp.construct pure query_bind oa = PFunctor.FreeM.construct pure query_bind oa
Instances For
Returns true for computations that don't query any oracles or fail, else false.
Equations
Instances For
Given a computation oa : OracleComp spec α, construct a value x : α,
by assuming each query returns the default value given by the Inhabited instance.
Returns none if the default path would lead to failure.
Equations
- oa.defaultResult = PFunctor.FreeM.mapM (fun (x : spec.toPFunctor.A) => default) oa
Instances For
Total number of queries in a computation across all possible execution paths.
Can be a helpful alternative to sizeOf when proving recursive calls terminate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Two pure computations are equal iff they return the same value.
Binding two computations gives a pure operation iff the first computation is pure and the second computation does something pure with the result.
Binding two computations gives a pure operation iff the first computation is pure and the second computation does something pure with the result.
Alias of the reverse direction of OracleComp.bind_eq_pure_iff.
Binding two computations gives a pure operation iff the first computation is pure and the second computation does something pure with the result.
Alias of the reverse direction of OracleComp.pure_eq_bind_iff.
Binding two computations gives a pure operation iff the first computation is pure and the second computation does something pure with the result.