Documentation

LeanPool.LeanQuantumAlg.Core.Cost

Trusted cost annotations #

This module connects Lean-QuantumAlg theorem endpoints to a small trusted cost interface. A value of Timed α returns an object of type α and carries a trusted natural-number cost annotation.

The cost annotation is intentionally not derived from the Lean evaluator or from matrix dimensions. Correctness is proved on .ret, while .time records the selected model. In the current quantum algorithm bridge, one unit means one oracle query for the single-query Walsh-Hadamard algorithms, and one good/bad-plane iterate for amplitude amplification and Grover.

This is an operator-level bridge over the existing pure-state and gate semantics. Fuller quantum program logics, such as density-operator or Hoare-style semantics for quantum while programs, are future extensions rather than prerequisites for this TimeM layer.

structure QuantumAlg.Timed (α : Type u) :

A computation result paired with a natural-number cost.

  • ret : α

    The trusted return value.

  • time :

    The trusted cost annotation.

Instances For
    def QuantumAlg.Timed.trusted {α : Type u} (cost : ) (ret : α) :

    Attach a trusted cost to a return value.

    Equations
    Instances For
      @[simp]
      theorem QuantumAlg.Timed.trusted_ret {α : Type u} (cost : ) (ret : α) :
      (trusted cost ret).ret = ret
      @[simp]
      theorem QuantumAlg.Timed.trusted_time {α : Type u} (cost : ) (ret : α) :
      (trusted cost ret).time = cost

      A trusted resource profile for registered theorem endpoints.

      The fields are intentionally lightweight counters. They record the resource model claimed beside a correctness theorem, not a derivation from Lean evaluation.

      • oracleQueries :

        Number of oracle queries.

      • hadamardGates :

        Number of Hadamard gates.

      • elementaryGates :

        Number of non-oracle elementary gates.

      • classicalOps :

        Number of trusted classical operations.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          The empty resource profile.

          Equations
          Instances For

            Sequential composition adds every resource counter.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Tensor/parallel circuit composition uses the same additive counters.

              Equations
              Instances For
                def QuantumAlg.ResourceProfile.HasExactCounts (profile : ResourceProfile) (oracleQueries hadamardGates elementaryGates classicalOps : ) :

                Exact counter claim used by supporting public theorem statements.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Gate counts for fixed circuit statements with named gate families.

                  • hadamardGates :

                    Number of Hadamard gates.

                  • controlledPhaseGates :

                    Number of controlled phase gates.

                  • swapGates :

                    Number of swap gates.

                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def QuantumAlg.CircuitGateProfile.HasExactCounts (profile : CircuitGateProfile) (hadamardGates controlledPhaseGates swapGates : ) :

                      Exact fixed-circuit gate-count claim.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        structure QuantumAlg.Profiled (α : Type u) :

                        A return value paired with a trusted resource profile.

                        • ret : α

                          The returned value.

                        • resources : ResourceProfile

                          Trusted resource accounting attached to the value.

                        Instances For
                          def QuantumAlg.Profiled.trusted {α : Type u} (resources : ResourceProfile) (ret : α) :

                          Attach a trusted resource profile to a return value.

                          Equations
                          Instances For
                            @[simp]
                            theorem QuantumAlg.Profiled.trusted_ret {α : Type u} (resources : ResourceProfile) (ret : α) :
                            (trusted resources ret).ret = ret
                            @[simp]
                            theorem QuantumAlg.Profiled.trusted_resources {α : Type u} (resources : ResourceProfile) (ret : α) :
                            (trusted resources ret).resources = resources

                            Communication resources for protocol statements.

                            • classicalBits :

                              Number of classical bits communicated.

                            • transmittedQubits :

                              Number of qubits transmitted.

                            • bellPairs :

                              Number of Bell pairs consumed.

                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def QuantumAlg.CommunicationProfile.HasExactCounts (profile : CommunicationProfile) (classicalBits transmittedQubits bellPairs : ) :

                                Exact communication-resource claim for protocol supporting theorems.

                                Equations
                                Instances For
                                  @[simp]
                                  theorem QuantumAlg.CommunicationProfile.hasExactCounts_mk (classicalBits transmittedQubits bellPairs : ) :
                                  { classicalBits := classicalBits, transmittedQubits := transmittedQubits, bellPairs := bellPairs }.HasExactCounts classicalBits transmittedQubits bellPairs