§
    ¹³ÙgÖ  ã                   óp   — d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
  eddd	¬
¦  «        d„ ¦   «         ZdS )uH  
====================================================================
ClassicalFunction compiler (:mod:`qiskit.circuit.classicalfunction`)
====================================================================

.. currentmodule:: qiskit.circuit.classicalfunction

Overview
========

.. warning::
    
    This module is deprecated as of Qiskit 1.4.0. It will be removed in the Qiskit 2.0 release.

The classical function compiler provides the necessary tools to map a classical
potentially irreversible functions into quantum circuits.  Below is a simple example of
how to synthesize a simple boolean function defined using Python into a
QuantumCircuit:

   .. code-block::

      from qiskit.circuit.classicalfunction import classical_function
      from qiskit.circuit.classicalfunction.types import Int1

      @classical_function
      def grover_oracle(a: Int1, b: Int1, c: Int1, d: Int1) -> Int1:
          return (not a and b and not c and d)

      quantum_circuit = grover_oracle.synth(registerless=False)
      quantum_circuit.draw('text')

           a: â”€â”€oâ”€â”€
                â”‚
           b: â”€â”€â– â”€â”€
                â”‚
           c: â”€â”€oâ”€â”€
                â”‚
           d: â”€â”€â– â”€â”€
              â”Œâ”€â”´â”€â”�
      return: â”¤ X â”œ
              â””â”€â”€â”€â”˜

Following Qiskit's little-endian bit ordering convention, the left-most bit (``a``) is the most
significant bit and the right-most bit (``d``) is the least significant bit.

.. warning::

    The functionality of `qiskit.circuit.classicalfunction` requires `tweedledum`, 
    which isn't available on all platforms (up to Python version 3.11).
    See `tweedledum installation guide 
    <https://github.com/boschmitt/tweedledum/tree/master?tab=readme-ov-file#installation>`_ 
    for more details.

Supplementary Information
=========================

Tweedledum
----------

Tweedledum is a C++-17 header-only library that implements a large set of
reversible (and quantum) synthesis, optimization, and mapping algorithms.
The classical function compiler relies on it and its dependencies to both represent logic
networks and synthesize them into quantum circuits.

ClassicalFunction data types
----------------------------

At the moment, the only type supported by the classical_function compilers is
``qiskit.circuit.classicalfunction.types.Int1``. The classical function function
to parse *must* include type hints (just ``Int1`` for now). The resulting gate
will be a gate in the size of the sum of all the parameters and the return.

The type ``Int1`` means the classical function will only operate at bit level.


ClassicalFunction compiler API
==============================

classical_function
------------------

Decorator for a classical function that returns a `ClassicalFunction` object.

.. autofunction:: classical_function

ClassicalFunction
-----------------

.. autosummary::
   :toctree: ../stubs/

   ClassicalFunction
   BooleanExpression

Exceptions
----------

.. autosummary::
   :toctree: ../stubs/

   ClassicalFunctionCompilerTypeError
   ClassicalFunctionParseError
   ClassicalFunctionCompilerTypeError

é    )Údeprecate_funcé   )ÚClassicalFunction)ÚClassicalFunctionParseErrorÚClassicalFunctionCompilerErrorÚ"ClassicalFunctionCompilerTypeError)ÚBooleanExpressionz1.4zin Qiskit 2.0zÌUse `PhaseOracle` instead, which can be turned into a bit-flip oracle by applying Hadamard gates on the target qubit before and after the instruction, and conditioning.the instruction on the target qubit.)ÚsinceÚremoval_timelineÚadditional_msgc                 ó~   — ddl }ddlm}  ||                     | ¦  «        ¦  «        }t	          || j        ¬¦  «        S )a‚  
    Parses and type checks the callable ``func`` to compile it into an ``ClassicalFunction``
    that can be synthesized into a ``QuantumCircuit``.

    Args:
        func (callable): A callable (with type hints) to compile into an ``ClassicalFunction``.

    Returns:
        ClassicalFunction: An object that can synthesis into a QuantumCircuit (via ``synth()``
        method).
    r   N)Údedent)Úname)ÚinspectÚtextwrapr   Ú	getsourcer   Ú__name__)Úfuncr   r   Úsources       ú_/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/classicalfunction/__init__.pyÚclassical_functionr   €   sQ   € ð( €N€N€NØÐÐÐÐÐàˆV�G×%Ò% dÑ+Ô+Ñ,Ô,€FÝ˜V¨$¬-Ð8Ñ8Ô8Ð8ó    N)Ú__doc__Úqiskit.utils.deprecationr   Úclassicalfunctionr   Ú
exceptionsr   r   r   Úboolean_expressionr	   r   © r   r   ú<module>r      sÂ   ððhð hðR 4Ð 3Ð 3Ð 3Ð 3Ð 3Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0ðð ð ð ð ð ð ð ð ð ð
 2Ð 1Ð 1Ð 1Ð 1Ð 1ð €Ø
Ø$ð+ðñ ô ð9ð 9ñô ð9ð 9ð 9r   