A circuit rewriting based inverse computation method
Patent Information
- Application Number
- CN202610890089.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-18
- Publication Date
- 2026-09-29
AI Technical Summary
现有基于静态类型系统的方法通常难以表达脏比特在计算过程中的动态状态变化;现有基于电路图与依赖关系跟踪的方法则主要关注量子门操作之间的结构依赖关系,缺乏对脏比特借用、转换、恢复及复用过程的精确建模
[0020]与现有技术相比,本发明至少具有以下有益效果。
Smart Images

Figure CN122840285A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of quantum computing technology, specifically relating to an inverse computation method based on circuit rewriting. Background Technology
[0002] When implementing complex quantum circuits, the computation process generates many intermediate results. However, these intermediate results cannot directly overwrite the main computation qubits; typically, additional ancilla qubits are introduced to temporarily store the intermediate results. These ancilla qubits must be restored after the computation is complete to avoid residual entanglement affecting the final measurement results or subsequent computations. Specifically, if the ancilla qubits remain entangled with the main register after the computation, the following problems will occur.
[0003] • Disrupts the coherence of the main register: Any measurement or decoherence of the auxiliary bits will momentarily affect the main register that is entangled with them, leading to errors in the calculation results or the collapse of the entire quantum state.
[0004] • Hinders qubit reuse: In large-scale quantum computing, qubit resources are precious. If an auxiliary bit is in an unknown entangled state after use, it cannot be safely reused by subsequent computing modules.
[0005] • Impact on subsequent computations: If the algorithm involves multiple steps, unrecovered auxiliary bits can act like "ghosts" to interfere with subsequent quantum operations, rendering the entire computation process invalid.
[0006] Therefore, this recovery operation, or inverse computation, is extremely necessary and is widely used in quantum algorithm design, quantum programming language compilers, quantum circuit synthesis and optimization tools, and quantum encryption algorithms.
[0007] For example, when managing auxiliary qubits, quantum encryption algorithms typically employ methods based on static type systems and methods based on quantum circuit diagrams and dependency tracking. The former usually involves pre-defining the type, scope, and lifetime constraints of the qubits to perform static checks on the allocation and release of auxiliary qubits; the latter analyzes quantum gate operations, quantum circuit structures, and dependencies between qubits to determine the usage status and reuse conditions of the auxiliary qubits.
[0008] However, both existing methods struggle to effectively address the core issue of dirty qubits and their state transitions. A dirty qubit refers to an auxiliary qubit whose initial quantum state is unknown or uncertain, but which can be temporarily borrowed during quantum computation and restored to its original state after use. Compared to clean auxiliary qubits initialized with a definite quantum state, the use of dirty qubits is subject to stricter reversibility and state restoration constraints. Existing methods based on statically typed systems often fail to express the dynamic state changes of dirty qubits during computation; existing methods based on circuit diagrams and dependency tracking primarily focus on the structural dependencies between quantum gate operations, lacking precise modeling of the borrowing, transformation, restoration, and reuse processes of dirty qubits.
[0009] Therefore, in scenarios involving state transitions between dirty qubits and clean auxiliary qubits, temporary borrowing of dirty qubits, release of dirty qubits, and reuse of auxiliary qubits in quantum encryption algorithms, existing technologies are prone to problems such as auxiliary qubit state recovery errors, quantum state contamination, resource reuse conflicts, quantum gate sequence redundancy, and increased circuit depth. These issues reduce the correctness of quantum encryption algorithm execution, the efficiency of auxiliary qubit utilization, and the optimization effect of quantum circuits. Summary of the Invention
[0010] To address the aforementioned problems, this invention discloses an inverse computation method based on circuit rewriting, used to automate the management and recycling of auxiliary qubits, thereby improving the utilization efficiency of quantum resources. Furthermore, when applied to quantum encryption algorithms, it can enhance the execution correctness of the algorithm, the utilization efficiency of auxiliary qubits, and the optimization effect of quantum circuits.
[0011] To achieve the above objectives, the technical solution of the present invention includes the following:
[0012] A method for inverse computation based on circuit rewriting, the method comprising: Transform a given reversible Boolean circuit into a regular form circuit, which is equivalent to the given reversible Boolean circuit on all working bits, and the structural feature of the regular form circuit is that all quantum gates that use auxiliary bits as target bits or control bits and change the state of auxiliary bits are clustered into a continuous suffix segment in the gate sequence. To meet the inverse computation requirements of clean auxiliary bits, all quantum gates in the suffix segment that involve auxiliary bits as target bits participating in gate operations are identified and removed, resulting in the inverse computation circuit of clean auxiliary bits. To address the inverse computation requirement of dirty auxiliary bits, based on the inverse computation circuit of clean auxiliary bits, all quantum gates involving auxiliary bits as control bits participating in gate operations are identified and removed, resulting in the inverse computation circuit of dirty auxiliary bits.
[0013] Furthermore, transforming a given reversible Boolean circuit into a regular form circuit includes: Check whether all gates in the given reversible Boolean circuit are within the specified set of available gates; wherein the specified set of available gates includes NOT gates, controlled NOT gates, Tolff gates, and multi-controlled Tolff gates; If all gates in the given reversible Boolean circuit are within the specified set of available gates, then search for specific patterns that appear in the given reversible Boolean circuit, the specific patterns including: a gate targeting an auxiliary bit is immediately followed by a gate not targeting an auxiliary bit; If a specific pattern is found that matches a circuit normalization rewriting rule, the given reversible Boolean circuit is rewritten based on the circuit normalization rewriting rule; wherein, the circuit normalization rewriting rule is to perform sequential exchange or structural recombination of multi-control quantum gates that satisfy preset topological conditions without changing the overall input-output semantics of the circuit. Repeat the steps of searching for a specific pattern in the given reversible Boolean circuit until no specific pattern can be found.
[0014] Furthermore, the circuit normalization rewrite rules include: When two multi-controlled Toffee gates share only a portion of their control bits and there is no cross-dependency, the order of operation of the two multi-controlled Toffee gates can be directly swapped without changing the circuit semantics. When the control bit set of the second gate includes auxiliary bits If the target bit of the second gate does not belong to the control bit set of the first gate, then while swapping the operation order of the two gates, an additional first multi-controlled Toffee gate is introduced into the swapped gate sequence. This first multi-controlled Toffee gate has the same target bit as the original second gate, and its control bit set is obtained by unioning the control bit sets of the two gates, with auxiliary bits further removed. ; When the target bit of the second gate belongs to the control bit set of the first gate, and the auxiliary bits If the control bit set does not belong to the second gate, then while swapping the operation order of the two gates, an additional second multi-control Tolford gate is introduced into the swapped gate sequence; wherein, the second multi-control Tolford gate has the same target bit as the original first gate, and the control bit set of the second multi-control Tolford gate is obtained by the union of the control bit sets of the two gates, and the target bit of the second gate is further removed.
[0015] A quantum encryption method, wherein when the management of auxiliary qubits is involved, the quantum encryption method performs inverse computation based on the circuit rewriting-based inverse computation method described in any of the preceding claims.
[0016] A circuit rewriting-based inverse computation system, the system comprising: A transformation module is used to transform a given reversible Boolean circuit into a regular form circuit, which is equivalent to the given reversible Boolean circuit on all working bits, and the structural feature of the regular form circuit is that all quantum gates that use auxiliary bits as target bits or control bits and change the state of auxiliary bits are clustered into a continuous suffix segment in the gate sequence. The first processing module is used to identify and remove all quantum gates in the suffix segment that involve auxiliary bits as target bits participating in gate operations, in order to meet the inverse calculation requirements of clean auxiliary bits, and obtain the inverse calculation circuit of clean auxiliary bits. The second processing module is used to address the inverse computation requirements of dirty auxiliary bits. Based on the inverse computation circuit of clean auxiliary bits, it identifies and removes all quantum gates that involve auxiliary bits as control bits participating in gate operations, thus obtaining the inverse computation circuit of dirty auxiliary bits.
[0017] An electronic device, characterized in that the electronic device comprises: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the circuit rewriting-based inverse computation method or the quantum encryption method described above.
[0018] A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the circuit rewriting-based inverse computation method or the quantum encryption method described above.
[0019] A computer program product, characterized in that, when the computer program product is run on a computer device, it causes the computer device to execute the circuit rewriting-based inverse computation method or the quantum encryption method described above.
[0020] Compared with the prior art, the present invention has at least the following beneficial effects.
[0021] 1. This invention proposes a set of systematic gate rewriting rules to legally transform the order of quantum gates without changing the overall semantics of the circuit, laying the foundation for subsequent circuit normalization.
[0022] 2. This invention utilizes the above-mentioned gate rewriting rules to systematically transform any given reversible circuit into a standardized regular form, so that all quantum gates affecting the state of auxiliary bits are moved to the end of the circuit.
[0023] 3. This invention is based on direct inverse computation of the normal form. After obtaining the circuit in the normal form, the inverse computation of the auxiliary bits is directly realized by reversing the operation of all gates that change the auxiliary bits at the end. There is no need for dynamic dependency tracking, which simplifies the algorithm complexity and improves the success rate.
[0024] 4. Based on the structural characteristics of normalized circuits, this invention automatically identifies and deletes all gates that use auxiliary bits as control bits, thereby safely transforming the circuit from an implementation using clean bits to a functionally equivalent implementation using dirty bits, ensuring accurate recovery after the use of dirty bits.
[0025] 5. This invention can improve the execution correctness of the quantum encryption algorithm, the utilization efficiency of auxiliary qubits, and the optimization effect of quantum circuits. Attached Figure Description
[0026] Figure 1 This is a flowchart of the inverse calculation method based on circuit rewriting.
[0027] Figure 2 This is a flowchart of a quantum circuit normalization algorithm.
[0028] Figure 3 It is an instance of rewriting rule 2.
[0029] Figure 4 It is an example of rewriting rule 3.
[0030] Figure 5 This is a comparison of the success rates of the present invention and the reqomp algorithm on randomly generated test circuit sets. Detailed Implementation
[0031] The system will now be described in further detail with reference to the accompanying drawings. The examples given are for illustrative purposes only and are not intended to limit the scope of the system.
[0032] Because existing techniques can only handle the inverse computation of clean bits, and their applicability is very narrow. Even in the classical subset of quantum circuits—reversible Boolean circuits—existing techniques can only handle some special cases, and cannot solve the problem of automatic inverse computation of clean and dirty auxiliary bits in reversible Boolean circuits, or the problem of how to convert a reversible Boolean circuit from a clean auxiliary bit version to a dirty auxiliary bit version.
[0033] The inverse computation method based on circuit rewriting provided by this invention, such as Figure 1 As shown, it includes the following steps.
[0034] Step S1: Transform the given reversible Boolean circuit into a regular form circuit.
[0035] The regular form circuit disclosed in this invention is equivalent to the given reversible Boolean circuit on all working bits, and the structural feature of the regular form circuit is that all quantum gates that take the auxiliary bit as the target bit or control bit and change the state of the auxiliary bit are clustered into a continuous suffix segment in the gate sequence.
[0036] like Figure 2 As shown, the process of transforming a given reversible Boolean circuit into a regular form circuit includes the following sub-steps.
[0037] 1) Input Check: Using the input circuit as the current circuit, check whether all gates in the input circuit are within the specified set of available gates, i.e., NOT gates, controlled NOT gates, Tolff gates, and multi-controlled Tolff gates. a) If there exists a gate that is not in the specified gate set, the algorithm fails. b) If all doors are within the specified door set, continue with the subsequent steps.
[0038] 2) Repeat the following steps: The search circuit exhibits a pattern of "gates targeting auxiliary bits, followed by gates not targeting auxiliary bits". If a pattern is found, and if the found pattern matches the circuit normalization rewriting rules (i.e., the left side of the three inequalities below), then the corresponding equality rewriting is applied to gradually shift the gate targeting the auxiliary bit to the right; if it does not match any of the circuit normalization rewriting rules, then the algorithm fails.
[0039] If not found, exit the loop.
[0040] 3) When no more gate pairs that meet the conditions can be found, the current circuit is in normal form.
[0041] In a preferred embodiment, to transform a given circuit into its normal form (the normal form of a given circuit is another circuit that is equivalent to the original circuit on all working bits, and all gates targeting auxiliary bits are on the rightmost side of the circuit), the circuit normalization rewriting rules are as follows: 1. 2. 3. In the above rewriting rules, let and Represents a quantum register. Represents auxiliary qubits, This represents a non-auxiliary qubit (working bit). These represent the union and difference operations on sets, respectively. These represent whether an element "belongs to" or "does not belong to" a set, respectively. The logical conjunction "and" indicates This indicates the number of control bits for a multi-controller gate. This represents a multi-control Tolff gate with m control bits, acting on the set of control bits. and target bits Above. The symbol ";" is used to indicate the cascading (sequential combination) of quantum gates / circuits: for two quantum gates / circuits... ,remember Apply first Apply after The circuit is described above. In the rewriting rules, the left and right sides are connected by "≡", which means that the circuits on the left and right sides are functionally semantically equivalent / unitary equivalent: that is, they produce the same output (or correspond to the same unitary transformation) on the same input quantum state. The rightmost end of each rule is its own conditional statement. Therefore, the left gate sequence can be replaced (rewritten) with the right gate sequence without changing the circuit function.
[0042] Therefore, each rewriting rule describes the following equivalent transformation: a gate sequence that "changes the auxiliary bits first, then the other bits" is equivalently rewritten as a gate sequence that "changes the other bits first, then the auxiliary bits." It is important to emphasize that the left side of the equation always presents the transformation "with the auxiliary bits..." "Multi-controller welfare gate for target bits" followed by "with a certain working bit" "Multi-control Towel gate for target bits"; and the right side of the equation is adjusted accordingly to act first on The door, and then acted upon The door (in some cases, an additional multi-control Towel door will be introduced on the right).
[0043] Specifically: 1. First equation (direct exchange): When two multi-controlled Torvé gates share only a portion of the control bits and there is no cross-dependency such as "the target bit of one gate appears in the control bits of another gate", the two gates can directly exchange their order of operation without changing the circuit semantics.
[0044] 2. Second equation (commutation + introduction of additional gate): Suppose that the control bit set of the second gate includes auxiliary bits. If the target bit of the second gate does not belong to the control bit set of the first gate, then the order of the two gates can be swapped. Simultaneously, an additional multi-controlled Tolley gate is introduced into the swapped gate sequence. This additional gate has the same target bit as the original second gate, and its control bit set is obtained by unioning the control bit sets of the two gates, further removing auxiliary bits. Corresponding examples are as follows: Figure 3 As shown.
[0045] 3. Third equation (commutation + introduction of additional gates): Suppose that the target bit of the second gate belongs to the control bit set of the first gate, and the auxiliary bits... If the control bits do not belong to the control bit set of the second gate, then the order of the two gates can be swapped. Simultaneously, an additional multi-control Tolff gate is introduced into the swapped gate sequence. This additional gate has the same target bit as the original first gate, and its control bit set is obtained by the union of the control bit sets of the two gates, further removing the target bit of the second gate. A corresponding example is shown below. Figure 4 As shown.
[0046] Step S2: To meet the inverse computation requirements of clean auxiliary bits, identify and remove all quantum gates in the suffix segment that involve auxiliary bits as target bits participating in gate operations, and obtain the circuit after inverse computation of clean auxiliary bits.
[0047] For the inverse computation of clean auxiliary bits, all quantum gates in the suffix segment that target auxiliary bits can be directly removed to obtain the circuit after inverse computation. Since the removed gates only act on auxiliary bits and not on non-auxiliary bits (including those not targeting non-auxiliary bits), the removal operation does not change the computational semantics on the working bits, ensuring that the circuit after inverse computation is functionally equivalent to the original circuit in terms of non-auxiliary bit functionality. Furthermore, the circuit after removal no longer contains any quantum gates that would change the state of the auxiliary bits. Further, since the clean auxiliary bits are in a predetermined initial state before entering the circuit (e.g., ...), ... Furthermore, it does not become entangled with the non-auxiliary bit, and no altering operation is applied to it in the circuit after inverse computation. Therefore, the clean auxiliary bit remains unentangled and its state remains unchanged during execution (equivalently, it can be regarded as being restored to its initial state).
[0048] Step S3: To meet the inverse computation requirements of dirty auxiliary bits, based on the inverse computation circuit of clean auxiliary bits, identify and remove all quantum gates that involve auxiliary bits as control bits participating in gate operations, and obtain the inverse computation circuit of dirty auxiliary bits.
[0049] For the inverse calculation of dirty auxiliary bits, this invention, based on the above-described inverse calculation of clean auxiliary bits, further removes all quantum gates in the circuit that involve auxiliary bits. "Involving" includes auxiliary bits participating in gate operations as either control bits or target bits (based on the above processing, only the case where auxiliary bits are used as control bits remains). Through this processing, the circuit after inverse calculation no longer contains any operations for reading or writing dirty auxiliary bits. Therefore, dirty auxiliary bits are not used during circuit execution, and their quantum state remains the original state before entering the circuit, thus achieving the recovery of dirty auxiliary bits.
[0050] In another embodiment of the present invention, the above-described inverse computation method can be applied to a quantum encryption method so that the quantum encryption method can manage auxiliary qubits through the inverse computation method.
[0051] The technical effects of the present invention will be further illustrated below through comparative experiments.
[0052] like Figure 5 As shown, the method described in this invention was compared with the existing reqomp method on a randomly generated circuit test set. The test results show that, under different circuit widths and gate counts, the method described in this invention achieves a higher success rate in completing clean bit inverse calculations than the reqomp method, demonstrating stronger applicability and inverse calculation capabilities. Specifically, Figure 5 The diagram includes four sub-graphs, each corresponding to a different circuit width. The top-left sub-graph corresponds to 5 working bits and 5 auxiliary bits, the top-right sub-graph to 40 working bits and 40 auxiliary bits, the bottom-left sub-graph to 80 working bits and 80 auxiliary bits, and the bottom-right sub-graph to 200 working bits and 200 auxiliary bits. In each sub-graph, the horizontal axis represents the number of gates in the circuit, and the vertical axis represents the success rate of clean bit inverse computation; a higher success rate indicates better inverse computation performance. The blue curve represents the method described in this invention, and the red curve represents the reqomp method.
[0053] In summary, this invention addresses the limitations of existing technologies in the field of automatic inverse computation of quantum circuits, particularly the inability to simultaneously support clean and dirty bits, the difficulty in guaranteeing the correctness of inverse computation under complex dependencies, and the inability to achieve automated conversion of auxiliary bits. This invention proposes a novel and unified technical solution.
[0054] This invention proposes a set of circuit equivalence transformation rules as a basic operational tool. These rules can safely swap the positions of "gates targeting auxiliary bits" and "gates targeting working bits but not the auxiliary bits" within a local range. This approach theoretically guarantees that each transformation does not change the overall function of the circuit across all working bits (i.e., maintaining unitary equivalence), providing a solid mathematical foundation for subsequent automated processing. This fundamentally overcomes the risk of errors introduced by some existing methods that rely on heuristic strategies or approximations, laying the cornerstone for achieving highly reliable automatic inverse computation.
[0055] By systematically and repeatedly applying the aforementioned equivalent transformation rules, the normalization algorithm of this invention can gradually shift all scattered gates in the input circuit that target auxiliary bits to the right, eventually clustering them at the end of the circuit to form a structurally regular normalized form. This rule-based rewriting strategy makes the algorithm far superior to existing techniques (such as Unqomp and Reqomp) when dealing with circuits with complex dependencies (such as nonlinear interactions). Experiments show that on a large set of reversible Boolean circuit test cases, the normalization success rate of this method is significantly higher than that of existing schemes, solving their fundamental deficiency of "only being able to handle some special cases".
[0056] This invention leverages the properties of regular forms, requiring only the reverse cancellation of gates targeting auxiliary bits at the end to complete the inverse calculation of clean bits. This method linearizes and structures the inverse calculation process, avoiding complex circuit analysis. Compared to methods like Unqomp and Reqomp, this invention guarantees successful inverse calculation in most scenarios, theoretically solving the problem of limited success rates in existing technologies.
[0057] This invention achieves, for the first time, the automatic conversion from clean bit to dirty bit version, unlocking a crucial resource optimization capability. If the circuit has been normalized and the clean bit inverse calculation has been completed, the corresponding dirty bit version can be obtained by removing all gates involving auxiliary bits. This is a capability completely absent in existing technologies. This function allows programmers to always design algorithms in the more intuitive clean bit mode, while the compiler automatically handles the conversion to the more resource-efficient dirty bit version. This significantly reduces the consumption of precious qubit resources and is a key optimization technique towards realizing large-scale quantum algorithms, possessing significant practical value.
[0058] This invention is the first to address the inverse computation problems of clean and dirty bits within the same theoretical framework and algorithmic flow. Normalization is the first step in this unification process; subsequent processing (removing the last gate or removing all gates) are simply different output options within the same framework. This unification solves the problem of existing bit management schemes being fragmented and incompatible. It simplifies compiler design and provides a clear and scalable foundation for exploring more complex hybrid bit management strategies in the future.
[0059] Although specific embodiments of the system have been disclosed for illustrative purposes to aid in understanding and implementing the system, those skilled in the art will understand that various substitutions, variations, and modifications are possible without departing from the spirit and scope of the system and the appended claims. Therefore, the system should not be limited to the content disclosed in the preferred embodiments, and the scope of protection claimed by the system is determined by the scope defined in the claims.
Claims
1. A reverse computation method based on circuit rewriting, characterized in that, The method includes: Transform a given reversible Boolean circuit into a regular form circuit, which is equivalent to the given reversible Boolean circuit on all working bits, and the structural feature of the regular form circuit is that all quantum gates that use auxiliary bits as target bits or control bits and change the state of auxiliary bits are clustered into a continuous suffix segment in the gate sequence. To meet the inverse computation requirements of clean auxiliary bits, all quantum gates in the suffix segment that involve auxiliary bits as target bits participating in gate operations are identified and removed, resulting in the inverse computation circuit of clean auxiliary bits. To address the inverse computation requirement of dirty auxiliary bits, based on the inverse computation circuit of clean auxiliary bits, all quantum gates involving auxiliary bits as control bits participating in gate operations are identified and removed, resulting in the inverse computation circuit of dirty auxiliary bits.
2. The method according to claim 1, characterized in that, Transforming a given reversible Boolean circuit into its regular form includes: Check whether all gates in the given reversible Boolean circuit are within the specified set of available gates; wherein the specified set of available gates includes NOT gates, controlled NOT gates, Tolff gates, and multi-controlled Tolff gates; If all gates in the given reversible Boolean circuit are within the specified set of available gates, then search for specific patterns that appear in the given reversible Boolean circuit, the specific patterns including: a gate targeting an auxiliary bit is immediately followed by a gate not targeting an auxiliary bit; If a specific pattern is found that matches a circuit normalization rewriting rule, the given reversible Boolean circuit is rewritten based on the circuit normalization rewriting rule; wherein, the circuit normalization rewriting rule is to perform sequential exchange or structural recombination of multi-control quantum gates that satisfy preset topological conditions without changing the overall input-output semantics of the circuit. Repeat the steps of searching for a specific pattern in the given reversible Boolean circuit until no specific pattern can be found.
3. The method according to claim 2, characterized in that, The circuit normalization rewriting rules include: When two multi-controlled Toffee gates share only a portion of their control bits and there is no cross-dependency, the order of operation of the two multi-controlled Toffee gates can be directly swapped without changing the circuit semantics. When the control bit set of the second gate includes auxiliary bits If the target bit of the second gate does not belong to the control bit set of the first gate, then while swapping the operation order of the two gates, an additional first multi-controlled Toffee gate is introduced into the swapped gate sequence. This first multi-controlled Toffee gate has the same target bit as the original second gate, and its control bit set is obtained by unioning the control bit sets of the two gates, with auxiliary bits further removed. ; When the target bit of the second gate belongs to the control bit set of the first gate, and the auxiliary bits If the control bit set does not belong to the second gate, then while swapping the operation order of the two gates, an additional second multi-control Tolford gate is introduced into the swapped gate sequence; wherein, the second multi-control Tolford gate has the same target bit as the original first gate, and the control bit set of the second multi-control Tolford gate is obtained by the union of the control bit sets of the two gates, and the target bit of the second gate is further removed.
4. A quantum encryption method, characterized in that, When the quantum encryption method involves the management of auxiliary qubits, it is based on the circuit rewriting-based inverse computation method according to any one of claims 1 to 3.
5. A reverse computation system based on circuit rewriting, characterized in that, The system includes: A transformation module is used to transform a given reversible Boolean circuit into a regular form circuit, which is equivalent to the given reversible Boolean circuit on all working bits, and the structural feature of the regular form circuit is that all quantum gates that use auxiliary bits as target bits or control bits and change the state of auxiliary bits are clustered into a continuous suffix segment in the gate sequence. The first processing module is used to identify and remove all quantum gates in the suffix segment that involve auxiliary bits as target bits participating in gate operations, in order to meet the inverse calculation requirements of clean auxiliary bits, and obtain the inverse calculation circuit of clean auxiliary bits. The second processing module is used to address the inverse computation requirements of dirty auxiliary bits. Based on the inverse computation circuit of clean auxiliary bits, it identifies and removes all quantum gates that involve auxiliary bits as control bits participating in gate operations, thus obtaining the inverse computation circuit of dirty auxiliary bits.
6. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the circuit rewriting-based inverse computation method or the quantum encryption method as described in any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the circuit rewriting-based inverse computation method or the quantum encryption method as described in any one of claims 1-4.
8. A computer program product, characterized in that, When the computer program product is run on a computer device, it causes the computer device to perform the circuit rewriting-based inverse computation method or quantum encryption method as described in any one of claims 1-4.