Documentation

VCVio.OracleComp.OracleSpec

Specifications of Available Oracles #

def OracleSpec (ι : Type u) :
Type (max u (v + 1))

An OracleSpec ι is specieifes a set of oracles indexed by ι. Defined as a map from each input to the type of the oracle's output.

Equations
    Instances For
      Equations
        Instances For
          @[reducible, inline]
          Equations
            Instances For
              @[simp]
              theorem OracleSpec.ofPFunctor_toPFunctor {ι : Type u} (spec : OracleSpec ι) :
              @[reducible, inline]
              abbrev OracleSpec.Domain {ι : Type u} (_spec : OracleSpec ι) :
              Equations
                Instances For
                  @[reducible, inline]
                  abbrev OracleSpec.Range {ι : Type u} (spec : OracleSpec ι) (t : ι) :
                  Type u_1
                  Equations
                    Instances For
                      class OracleSpec.Fintype {ι : Type u} (spec : OracleSpec ι) extends spec.toPFunctor.Fintype :
                      Type (max u u_1)
                      Instances
                        instance OracleSpec.instFintypeRangeOfFintype {ι : Type u} {spec : OracleSpec ι} [h : spec.Fintype] (t : spec.Domain) :
                        Fintype (spec.Range t)
                        Equations
                          class OracleSpec.Inhabited {ι : Type u} (spec : OracleSpec ι) extends spec.toPFunctor.Inhabited :
                          Type (max u u_1)
                          Instances
                            instance OracleSpec.instInhabitedRangeOfInhabited {ι : Type u} {spec : OracleSpec ι} [h : spec.Inhabited] (t : spec.Domain) :
                            Inhabited (spec.Range t)
                            Equations
                              class OracleSpec.DecidableEq {ι : Type u} (spec : OracleSpec ι) extends spec.toPFunctor.DecidableEq :
                              Type (max u u_1)
                              Instances
                                instance OracleSpec.instDecidableEqRangeOfDecidableEq {ι : Type u} {spec : OracleSpec ι} [h : spec.DecidableEq] (t : spec.Domain) :
                                Equations
                                  class OracleSpec.IsProbSpec {ι : Type u} (spec : OracleSpec ι) [spec.Inhabited] [spec.Fintype] :

                                  Type-class gadget to enable probability notation for computation over an OracleSpec. Can be defined for any spec with spec.Range finite and inhabited, but generally should only be instantied for things like coinSpec or unifSpec. dtumad: we should examine if this should be used more strictly in evalDist stuff. We could require computations without this tag to provide their own PMF embedding, even if it can be inferred implicitly.

                                    Instances
                                      @[reducible, always_inline]
                                      def OracleSpec.ofFn {ι : Type u} (F : ιType v) :
                                      Equations
                                        Instances For
                                          instance OracleSpec.instFintypeOfFnOfFintype {ι : Type u} (F : ιType v) [h : (i : ι) → Fintype (F i)] :
                                          Equations
                                            instance OracleSpec.instDecidableEqOfFnOfDecidableEq {ι : Type u} (F : ιType v) [h : DecidableEq ι] [h' : (i : ι) → DecidableEq (F i)] :
                                            Equations
                                              instance OracleSpec.instInhabitedOfFnOfInhabited {ι : Type u} (F : ιType v) [h : (i : ι) → Inhabited (F i)] :
                                              Equations
                                                instance OracleSpec.instHAddSum {ι : Type u_1} {ι' : Type u_2} :
                                                HAdd (OracleSpec ι) (OracleSpec ι') (OracleSpec (ι ι'))

                                                spec₁ + spec₂ specifies access to oracles in both spec₁ and spec₂. The input is split as a sum type of the two original input sets. This corresponds exactly to addition of the corresponding PFunctor.

                                                Equations
                                                  theorem OracleSpec.add_def {ι : Type u_1} {ι' : Type u_2} (spec : OracleSpec ι) (spec' : OracleSpec ι') :
                                                  spec + spec' = Sum.elim spec spec'
                                                  @[simp]
                                                  theorem OracleSpec.add_apply_inl {ι : Type u_1} {ι' : Type u_2} (spec : OracleSpec ι) (spec' : OracleSpec ι') (t : ι) :
                                                  (spec + spec') (Sum.inl t) = spec t
                                                  @[simp]
                                                  theorem OracleSpec.add_apply_inr {ι : Type u_1} {ι' : Type u_2} (spec : OracleSpec ι) (spec' : OracleSpec ι') (t : ι') :
                                                  (spec + spec') (Sum.inr t) = spec' t
                                                  @[simp]
                                                  theorem OracleSpec.toPFunctor_add {ι ι' : Type (max u_1 u_2)} (spec : OracleSpec ι) (spec' : OracleSpec ι') :
                                                  (spec + spec').toPFunctor = spec.toPFunctor + spec'.toPFunctor
                                                  instance OracleSpec.instFintypeSumHAdd {ι : Type u_1} {ι' : Type u_2} (spec : OracleSpec ι) (spec' : OracleSpec ι') [h : spec.Fintype] [h' : spec'.Fintype] :
                                                  (spec + spec').Fintype
                                                  Equations
                                                    instance OracleSpec.instDecidableEqSumHAdd {ι : Type u_1} {ι' : Type u_2} (spec : OracleSpec ι) (spec' : OracleSpec ι') [h : spec.DecidableEq] [h' : spec'.DecidableEq] :
                                                    (spec + spec').DecidableEq
                                                    Equations
                                                      instance OracleSpec.instInhabitedSumHAdd {ι : Type u_1} {ι' : Type u_2} (spec : OracleSpec ι) (spec' : OracleSpec ι') [h : spec.Inhabited] [h' : spec'.Inhabited] :
                                                      (spec + spec').Inhabited
                                                      Equations
                                                        def OracleSpec.sigma {ι : Type u_1} {τ : ιType u_2} (specs : (i : ι) → OracleSpec (τ i)) :
                                                        OracleSpec ((i : ι) × (specs i).Domain)

                                                        Given an indexed set of OracleSpec, specifiy access to all of the oracles, by requiring an index into the corresponding oracle in the input.

                                                        Equations
                                                          Instances For
                                                            @[simp]
                                                            theorem OracleSpec.sigma_apply {ι : Type u_1} {τ : ιType u_2} (specs : (i : ι) → OracleSpec (τ i)) (t : (i : ι) × (specs i).Domain) :
                                                            OracleSpec.sigma specs t = specs t.fst t.snd
                                                            @[simp]
                                                            theorem OracleSpec.toPFunctor_sigma {ι : Type u_1} {τ : ιType u_2} (specs : (i : ι) → OracleSpec (τ i)) :
                                                            (OracleSpec.sigma specs).toPFunctor = PFunctor.sigma fun (i : ι) => (specs i).toPFunctor
                                                            @[simp]
                                                            instance OracleSpec.instHMulProd {ι : Type u_1} {ι' : Type u_2} :
                                                            HMul (OracleSpec ι) (OracleSpec ι') (OracleSpec (ι × ι'))

                                                            spec₁ * spec₂ represents an oracle that takes in a pair of inputs for each set, and returns an element in the output of one oracle or the other. The corresponds exactly to multiplication in PFunctor.

                                                            Equations
                                                              @[simp]
                                                              theorem OracleSpec.mul_apply {ι : Type u_1} {ι' : Type u_2} (spec : OracleSpec ι) (spec' : OracleSpec ι') (t : ι × ι') :
                                                              (spec * spec').Range t = (spec.Range t.1 spec'.Range t.2)
                                                              @[simp]
                                                              theorem OracleSpec.toPFunctor_mul {ι ι' : Type (max u_1 u_2)} (spec : OracleSpec ι) (spec' : OracleSpec ι') :
                                                              (spec * spec').toPFunctor = spec.toPFunctor * spec'.toPFunctor
                                                              def OracleSpec.pi {ι : Type u_1} {τ : ιType u_2} (specs : (i : ι) → OracleSpec (τ i)) :
                                                              OracleSpec ((i : ι) → (specs i).Domain)

                                                              Given an indexed set of OracleSpec, specifiy access to an oracle that given an input to the oracle for each index returns an index and an ouptut for that index.

                                                              Equations
                                                                Instances For
                                                                  @[simp]
                                                                  theorem OracleSpec.pi_apply {ι : Type u_1} {τ : ιType u_2} (specs : (i : ι) → OracleSpec (τ i)) (t : (i : ι) → (specs i).Domain) :
                                                                  OracleSpec.pi specs t = ((i : ι) × specs i (t i))
                                                                  @[simp]
                                                                  theorem OracleSpec.toPFunctor_pi {ι : Type u_1} {τ : ιType u_2} (specs : (i : ι) → OracleSpec (τ i)) :
                                                                  (OracleSpec.pi specs).toPFunctor = PFunctor.pi fun (i : ι) => (specs i).toPFunctor
                                                                  @[simp]
                                                                  theorem OracleSpec.ofPFunctor_pi {ι : Type u_1} (P : ιPFunctor.{u_2, u_3}) :
                                                                  ofPFunctor (PFunctor.pi P) = OracleSpec.pi fun (i : ι) => ofPFunctor (P i)
                                                                  @[reducible]

                                                                  Specifies access to no oracles, using the empty type as the indexing type.

                                                                  Equations
                                                                    Instances For
                                                                      @[reducible]

                                                                      Access to a coin flipping oracle. Because of termination rules in Lean this is slightly weaker than unifSpec, as we have only finitely many coin flips.

                                                                      Equations
                                                                        Instances For
                                                                          @[reducible, inline]

                                                                          Access to oracles for uniformly selecting from Fin (n + 1) for arbitrary n : ℕ. By adding 1 to the index we avoid selection from the empty type Fin 0 ≃ empty.

                                                                          Equations
                                                                            Instances For
                                                                              @[reducible, inline]

                                                                              dt: should or shouldn't we switch to this. Compare to (· + m) <$> $[0..n]. One question is that we may have empty selection Select uniformly from a range (not starting from zero).

                                                                              Equations
                                                                                Instances For