A method and system for exploiting isomorphism in quantum programs to facilitate confident verification
By defining tracking points and hypothesis-guaranteed assertions, quantum evolution isomorphism is used to construct approximate functions to verify the correctness of quantum programs, solving the problem of low confidence in quantum program verification in the existing technology and achieving efficient and low-cost verification. method.
Patent Information
- Application Number
- CN202410418927.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-09
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-04-09
AI Technical Summary
Existing quantum program verification methods cannot effectively verify the overall correctness of the quantum program because the superposition state expands the search space for errors. Moreover, runtime assertions have poor generalization in the input space and cannot support independent verification of inputs, resulting in low confidence.
Specify the range and relationship of qubit states by defining tracking points and hypothesis-guaranteed assertions, use quantum evolution isomorphism to construct approximate functions, package assertions and approximation functions into constrained maximization problems for global search, and verify the correctness of quantum programs .
It improves the efficiency and expressiveness of quantum program verification, reduces computational costs, achieves high-confidence verification, and can output counterexamples and estimate the confidence of verification.
Smart Images

Figure CN118333181B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of quantum computing technology, and in particular relates to a method and system for utilizing isomorphism in quantum programs to promote confident verification. Background Art
[0002] Quantum computing is a promising technology that enables low power consumption and low computational complexity. Quantum programs consist of a series of quantum instructions that use quantum superposition and entanglement to accelerate computation. Similar to classical programs, quantum programs inevitably suffer from many computational defects. Therefore, there is a strong motivation to develop advanced verification tools to debug quantum programs. However, the inherent mechanisms of quantum computing hinder the verification of quantum programs. Specifically, superposition states expand the search space for errors, while non-reproducibility leads to a large number of program executions to probe the program state.
[0003] Quantum program verification (QPV) is mainly performed via deductive verification and runtime assertions. Deductive verification relies on a rigorous representation of program behavior, whose correctness can be compiled into a set of verification conditions. However, reasoning about correctness relies on: (1) solving the verification conditions via classical computers, which is subject to significant computational cost; and (2) human expertise, such as finding inductive invariants, which limits the degree of automation. On the other hand, runtime assertions are a lightweight approach to testing programs under different inputs. Assertions are defined as predicates on properties of the program state that should be true if there are no errors. Assertions are verified in three steps: a) assertion statement; b) program analysis; and c) assertion verification, which checks whether the analysis results satisfy the assertion predicate.
[0004] Confidence is a key metric for evaluating QPV, defined as the probability that the verification result is true for all inputs. Existing assertion works show low confidence in verifying the overall correctness of the program. This limitation stems from the fact that they verify the assertions under a small number of test inputs and cannot generalize the verification results to the entire input space. To improve confidence, some works exhaustively test a large number of inputs to cover the search space, but considering the continuous Hilbert space, this is still insufficient.
[0005] Fundamentally, the current implementation of the assert method cannot support the restriction of each of the following steps with independent validation of the input:
[0006] a) Assertion statements. The predicate of current assertions only includes a single program state and cannot check the relationship between states at different points in time. For example, the assertions of Li et al. and Liu et al. only check whether the qubit is in a specified set of states. This set of states must be restated for different inputs. b) Program analysis. Current techniques cannot characterize the relationship between states, resulting in the need to repeatedly test the execution of the program under each input. In addition, due to the quantum collapse after measurement, they can only detect limited features of the state. c) Verification model. Current methods cannot aggregate the results of various test inputs for overall verification. Summary of the invention
[0007] In view of the above, an object of the present invention is to provide a method and system for utilizing the isomorphism in quantum programs to promote confident verification, thereby improving the confidence of quantum program verification.
[0008] To achieve the above-mentioned object of the invention, an embodiment provides a method for utilizing isomorphism in quantum programs to promote confident verification, characterized in that it includes the following steps:
[0009] Assertion statements: define tracking points and use them to mark the quantum bit states of the quantum program at different times, define assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multiple quantum quantized quantum bit states;
[0010] Program analysis: Based on quantum evolution isomorphism, an approximate function of the true relationship between the input qubit state and the qubit state of the tracking point is constructed;
[0011] Assertion verification: Package the assumption-guarantee assertions in the quantum program and the constructed approximation function into a constraint maximization problem for global search and solution to verify the correctness of the quantum program.
[0012] Preferably, each tracking point is defined to record time and qubits, and a tag is compiled to label the qubit state in the quantum program.
[0013] Preferably, defining assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multi-quantum qubit states includes:
[0014] Through a predicate P k To describe the range of single quantum bit states, the predicate P k is an inequality or objective function that takes as input a single density matrix representing the qubit state if and only if the predicate P k When true, the objective function satisfies P k ≤0;
[0015] Through another predicate P sTo describe the relationship between multiple quantum bit states, the predicate P s is an inequality or objective function with multiple density matrices representing the quantum bit states as input. When multiple single quantum bit states satisfy their respective predicates P k When the relationship between the states of multiple quantum bits should satisfy the predicate P s .
[0016] Preferably, the construction process of the approximate function is:
[0017] The input quantum bit state ρ in It is expressed as a linear combination of the sampled inputs, that is, ρ in =∑ i α i σ in,i , σ in,i represents the quantum bit state of the i-th sample input, α i is the real value to be solved;
[0018] Based on the quantum evolution isomorphism and parameter α i , construct the quantum bit state ρ of the tracking point T The approximate function F between the input quantum bit state is:
[0019]
[0020] σ T,i represents the quantum bit state of the i-th sampling tracking point.
[0021] Preferably, the method further includes: Case 1: For a in =∑ i α i σ in,i The accuracy of the quantum bit state of the tracking point solved by constructing an approximate function is 100%; Case 2: For the quantum bit state that cannot be decomposed into ρ in =∑ i α i σ in,i The average accuracy of the quantum bit state at the tracking point is Among them, N sample is the number of sample inputs, N in The number of qubits given as input to the program;
[0022] When constructing an approximate function, the accuracy of solving the quantum bit state of the tracking point through the approximate function is improved by increasing the number of sampling inputs. Preferably, for case one, the sampling input is increased by an exponential sampling method, and for case two, the sampling input is increased by a linear increase method.
[0023] Preferably, when constructing the approximate function, the following three strategies are used for sampling input:
[0024] Strategy 1: Customize the sampling input, including: applying eigendecomposition to the sample data, and taking the first K eigenvectors with large eigenvalues selected based on the eigendecomposition as the sampling input;
[0025] Strategy 2: Set part of the input qubit state to a constant;
[0026] Strategy 3: Check a single attribute rather than the entire density function corresponding to the quantum bit state, where the single attribute is the attribute that satisfies the quantum evolution isomorphism and needs to be asserted and verified.
[0027] Preferably, the assumption-guarantee assertions in the quantum program and the constructed approximation function are packaged into a constraint maximization problem for global search and solution to verify the correctness of the quantum program, including:
[0028] Bring the approximation function into the assumption-guarantee assertion, and transform the assumption-guarantee assertion into a constrained optimization problem. Solve the parameter α in the approximation function by direct optimization. i To find the maximum value that makes the assumption-guarantee assertion true. If it can be found, then the assumption-guarantee assertion is true and the quantum program is correct.
[0029] Preferably, the method further comprises: when the quantum program verification is incorrect, the input quantum bit state is a counterexample that causes the error;
[0030] When a quantum program verifies correctness, the confidence level is estimated based on the accuracy of the analysis. acc represents accuracy, ∈ represents the accuracy threshold, P(acc<∈) represents the probability distribution of acc<∈, N c-e Represents the number of counterexamples.
[0031] To achieve the above-mentioned invention object, an embodiment further provides a system for utilizing isomorphism in quantum programs to promote confident verification, including:
[0032] Assertion statement module, which is used to define tracking points and mark the quantum bit states of quantum programs at different times through tracking points, and define assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multi-quantum qubit states;
[0033] Program analysis, which is used to construct an approximate function of the true relationship between the input qubit state and the qubit state of the tracking point based on quantum evolution isomorphism;
[0034] Assertion verification is used to package the assumption-guarantee assertions in the quantum program and the constructed approximation function into a constraint maximization problem for global search and solution to verify the correctness of the quantum program.
[0035] To achieve the above-mentioned purpose of the invention, an embodiment further provides a computing device, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the above-mentioned method of utilizing the isomorphism in quantum programs to promote confident verification.
[0036] Compared with the prior art, the present invention has the following beneficial effects:
[0037] The method of the present invention can promote reliable verification based on assertions. The proposed multi-state assertion is used to describe the relationship between a series of quantum states at different time points, which improves the efficiency and expressiveness of program verification; the proposed approximation technique is used to calculate the runtime state without executing the program, and this approximation captures the program behavior with a relatively small computational cost; the proposed input-independent verification method is used for assertions, which can output counterexamples and estimate the confidence of verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0039] Figure 1 This is an example diagram of the limitations of assertion methods in the prior art in verifying quantum programs;
[0040] Figure 2 is a flow chart of the method of the present invention provided by an embodiment;
[0041] Figure 3 It is a schematic diagram of the process of the method of the present invention provided in the embodiment;
[0042] Figure 4 It is an example of quantum transmission in the assertion statement of the method of the present invention provided in the embodiment;
[0043] Figure 5 is a visualization example of a single quantum bit program in the method of the present invention provided in the embodiment;
[0044] Figure 6 It is a schematic diagram of the structure of the system of the present invention provided in an embodiment. DETAILED DESCRIPTION
[0045] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.
[0046] In quantum programs, information is encoded in the state of quantum bits. For an n-qubit system, its quantum state is accurately described by the density matrix ρ. Quantum states can be divided into pure states and mixed states. The density matrix ρ of the mixed state is a linear combination of the density matrices of the pure states, expressed as ρ = ∑ i p i |ψ i ><ψ i |. Among them p i is the probability, p i |ψ i ><ψ i | is the density matrix of the pure state. All properties of the quantum state can be analyzed from its density matrix. The quantum state in the present invention is also represented as a density matrix.
[0047] Figure 1 (a) A quantum lock program is shown to illustrate the limitations of the existing assertion methods described in the background in quantum program verification. The quantum lock is used as an important module to encrypt the output of the quantum program. It encodes a binary key, for example, Figure 1 001 in (a). The program outputs |1> only when the input is equal to the key, i.e., 001→|1>, otherwise →|0>. The bug in the program refers to an unexpected key 110 in the program. When the bug exists, the program also outputs |1> when this key is input, i.e., 110→|1>. When making assertion statements, current works require different assertions (output = |1> and output = |0>) for different inputs (key and other). In analysis, these works exhaustively test the inputs until the unexpected key is found. In verification, they cannot generalize the execution results of some inputs to other inputs. For example, they cannot use the results of inputs 010 and 101 to verify input 110. Figure 1 (b) shows the confidence in the overall correctness of the method proposed by Liu et al. (Systematic approaches for precise and approximate quantum state runtime assertion). For a 15-qubit quantum lock program, the confidence is only 0.006%, and after one test, the confidence reaches 50% after testing 1.5×104 inputs.
[0048] Based on the above existing assertion methods, they show low confidence in verifying the overall correctness of quantum programs. The present invention provides a confident verification method with the least number of program executions. The key insight is to exploit the isomorphism of the program, which indicates that a structural relationship is maintained between the input and the runtime state of the program. Based on this isomorphism, the program behavior under certain inputs is used to describe the behavior under other inputs, which helps to extend the verification results to the entire input space. In order to achieve 100% confidence verification, the method of the present invention is characterized by requiring only twice the effort of classical program verification, which is very impressive considering the exponentially increased space of quantum states.
[0049] like Figure 2 As shown, the method provided by the embodiment for utilizing the isomorphism in the quantum program to facilitate confident verification includes the following steps:
[0050] S1, assertion statement: define tracking points and mark the quantum bit states of the quantum program at different times through tracking points, define assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multi-quantum quantized quantum bit states.
[0051] The present invention specifies the relationship between quantum bit states by introducing assertions, which are intended to describe the unified program behavior under various inputs. By defining tracking points to mark the quantum bit states of the quantum program at different times, the quantum bit states marked by the tracking points are then used to describe the expected program behavior. Tracking point T i is defined as the recording time and quantum bit, expressed as:
[0052] T i ≡({Q i},time i ),Q i ∈Q(1)
[0053] where Q is the set of qubits of the quantum program. i is to obtain the quantum bit Q i The density matrix ρ Ti The trace point is declared as a compilation tag in the QASM language. The compilation tag labels the quantum bit state in the quantum program. The specific compilation tag is defined as "T index q[qubits]". For example:
[0054] 1h q[1]; / / add h gate to qubit 1;
[0055] 2cx q[1],q[2]; / / add cx gate to qubit 1,2;
[0056] 3T1 q[1,2]; / / Add tracking point T1 to qubits 1,2;
[0057] 4cx q[2],q[3] / / add cx gate to qubit 2,3;
[0058] At time1=3, the trace point T1 is inserted into the GHZ circuit.
[0059] The present invention defines an assumption-guarantee assertion using predicates to specify: a) the range of single-qubit states that are described by an objective function (e.g., Figure 3 In and ); b) relations between at least two qubit states, which are described as objective functions involving multiple qubit states (e.g., P3(ρ T1 ,ρ T2 )). Specifically, the Assume-Guarantee assertion is defined as:
[0060]
[0061] Here, assert means assertion, assume means assumption, and guarantee means guarantee. The predicate P describing the range of the state of a single quantum bit is k (·) is an inequality or objective function with a density matrix as input, and another predicate P describing the relationship between multiple quantum bit states s (·,·) is also an inequality or objective function with multiple density matrices representing the states of qubits as input. k When true, the objective function satisfies P k ≤0. This assertion is intended to ensure that the program always satisfies the following condition: and When predicates P1 and P2 are satisfied, they should satisfy another predicate P3. In other words, if there is a state that satisfies P1 and P2 but violates P3, the assertion fails. The rules for predicates P1 and P2 are determined by the input format of the subsequent optimization-based verifier. The theoretical model of the present invention allows the use of predicates of arbitrary mathematical forms because the density matrix of the assertion state is obtained on a classical computer.
[0062] The assertion definition of the present invention is inspired by the classical assumption-guarantee assertions, which are used to identify deadlocks and concurrency anomalies in classical parallelized programs. Considering that quantum programs are naturally parallel, the assertions of the present invention can describe in detail the amplitude transformations of the basis in the program. In addition, compared with classical assertions, the assumptions in the present invention are guaranteed conditions, which filter the input space that needs to be verified. This provides two advantages for debugging quantum programs. First, this makes it possible to debug programs with intermediate measurements, assuming that the asserted state is equal to the collapsed state after the measurement. Second, it helps to prune the input space and optimize overhead. The present invention can use multiple assumption-guarantee assertions to describe the functionality of the program in detail.
[0063] Figure 4 An example of quantum transmission is shown to illustrate the assertion statement of the present invention. The transmission expectation is to transfer q Alice The input state is transmitted to q Bob The trace points T1 and T2 are injected to mark the input state and output state. Using the notation in equation (1), T1 = ({q Alice},1), T2=({q Bob},10). The expected program behavior is: when both the input and output are pure states, the input state is equal to the output state, which can be expressed as:
[0064]
[0065] S2, Program Analysis: Construct an approximate function of the true relationship between the input qubit state and the qubit state of the tracking point based on quantum evolution isomorphism.
[0066] The present invention analyzes the real relationship between states in a program by running the program on quantum hardware. The analysis starts with a single input sampling and records the labeled states under various inputs. By utilizing the quantum evolution isomorphism and constructing an approximate function (e.g., ρ) based on the sampling results, the approximate relationship between states in the program can be analyzed. T1 =f1(ρ in )), indicating the relationship between input and marked state.
[0067] Specifically, each trace point is introduced for analysis. The analysis of each trace point aims to capture the program input ρ in and the state of the trace point during execution ρ T The true relationship between , which is formulated as an approximate function, namely ρ T =f(ρ in ).
[0068] The analysis starts with input sampling, which is used to initialize the approximate function, where the program is run under various inputs and the tracepoint states are tomographed. These inputs are carefully designed to ensure high-precision characterization. Specifically, the input states should be orthogonal and cover more eigenstates to maximize their variation. In addition, it is expected that the inputs are easy to prepare. Based on this goal, circuits of orthogonal Clifford groups (Bravyi S, Maslov D. Hadamard-free circuits expose the structure of the Clifford group [J]. IEEE Transactions on Information Theory, 2021, 67 (7): 4546-4563.) are used to prepare these inputs.
[0069] The quantum evolution in the quantum program is isomorphic, and therefore has additive and homogeneous properties. The present invention uses this quantum evolution isomorphism to construct an approximation function. Specifically, in the program, ρ in and ρ T The true relationship between has the following properties. The input qubit state ρ in It is expressed as a linear combination of sampled inputs, namely:
[0070] ρ in =∑ i α i σ in,i (4)
[0071] The parameter α i is a real value, the tracking point state ρ under this input T It is expressed as:
[0072] ρ T =∑ i α i ρ T,i (5)
[0073] This is because for the function F(ρ in )=ρ T The actual relationships are:
[0074] F(ρ in )=F(∑ i α i σ in,i )=∑ i α i F(σ in,i )=∑ i α i σ T,i =ρ T (6)
[0075] This comes from additivity and homogeneity. Since these two states are collected from real program execution, F(σ in,i )=σ T,i is correct.
[0076] Based on this relationship, all possible inputs to the program can be divided into two parts. The first part includes inputs that can be decomposed into equation (4). The tracking point state at these inputs is accurately calculated by equation (5). The second part includes inputs that cannot be decomposed. However, the present invention can approximate them by equation (4). The tracking point state under these inputs can be approximated by equation (5). In general, the following function can be constructed to obtain the approximate tracking point state for any input.
[0077] Theorem 1 (approximate function): Function ρ T =f(ρ in ) is the input ρ in and tracking point state ρ T An under-approximation of the true relationship between . This approximate function is calculated in two steps:
[0078] 1. For input ρ in , first approximate ρ by equation (4) in To obtain the parameters {α i};
[0079] 2. Then use the parameter {α i}, output the tracking point state ρ through equation 5 T ;
[0080] Note that the parameter α i Mathematically equal to the sampled input σ in,i Upper input ρ in expected value.
[0081] The approximation can be applied to programs with non-overlapping qubits in the input and tracepoints. The approximation also applies to programs with intermediate measurements and simple feedback, where the relations between the qubit states are not isomorphic.
[0082] Figure 5 A visualization example of a single-qubit program is shown. In input sampling, three orthogonal input states σ are performed in,1 =|+>(on the x-axis of the Bloch sphere), σ in,2 =|+i> (on the y-axis), and σ in,3 =|1> (on the z-axis). The tracking point state is recorded as σ T,1 , σ T,2 and σ T,3 Given an input state ρ in, the first step is to approximate according to equation (4):
[0083] ρ in =α1|+>+α2|+i>+α3|1> (7)
[0084] α1=E |+> [ρ in ],α2=E |+i> [ρ in ],α3=E |1> [ρ in ] (8)
[0085] In the second step, the tracking point state under this input is calculated according to equation (5):
[0086] ρ T =α1σ T,1 +α2σ T,2 +α3σ T,3 (9)
[0087] Note that in this example, the approximation of the input state and the tracking point state has 100% accuracy because the input can be exactly represented by Equation 4.
[0088] Approximation error occurs when the input cannot be decomposed into a linear combination of the sampled inputs. More sampling ensures that the number of uncovered eigenstates in the sampled input is smaller, thereby improving accuracy. The present invention quantitatively analyzes this trade-off. Specifically, the approximation accuracy depends on the number of bits N of the state. in and the number of samples N of the input samples sample .
[0089] Theorem 2 (Approximation Accuracy): For different sampling inputs, there are two cases:
[0090] 1. The accuracy of the quantum bit state of the tracking point solved by constructing an approximate function for the sampled input that can be exactly represented as equation (4) is 100% accurate;
[0091] 2. For sampled inputs with eigenstates that cannot be represented by equation (4), the average accuracy of the qubit state at the tracking point is
[0092] When the number of samples When , the approximation accuracy is 100% for any input. In other words, the state of the approximated trace is always the same as the tomography. Here, the accuracy acc is defined as the approximation ρ T and the real ρ obtained by executing the quantum program T The Hilbert–Schmidt inner product between .
[0093] Theorem 2 shows that the inaccuracy comes from the space that the sampled input cannot represent (Eq. (4)). By increasing the number of sampled inputs N sample To improve the accuracy of solving the qubit state of the tracking point through the approximate function, it can exponentially increase the space of case 1 and linearly increase the accuracy of case 2. Case 1 is the most accurate verification. For case 2, when an error occurs, the incorrect state is usually significantly different from the expected state and can be identified with a certain accuracy threshold.
[0094] The accuracy of the approximation increases linearly with the number of sampled inputs. The present invention further proposes three strategies to prune the sample space during the analysis process.
[0095] Strategy 1 (Adaptive): Adaptively determine the sampling input. The input of the program is usually a subspace of the entire quantum state, which can be represented by fewer orthogonal states. The present invention can reduce the number of sampling inputs by eigendecomposing the input space. Sampling only uses eigenvectors with large eigenvalues as program input. For example, when verifying a 5-qubit quantum neural network program for classifying handwritten digits, the present invention can apply eigendecomposition to the training data set and use the first K eigenvectors with large eigenvalues as sampling input.
[0096] Strategy 2 (Constant): Set part of the input state to a constant. The input of the program may consist of multiple partial quantum bits representing different data. The present invention can set the state of certain input quantum bits to constants to reduce the size of the input space. For example, a quantum adder program has two parts of input |x> and |y>, expressed as f(|x>,|y>)=|x+y> (for example, f(|01>,|10>)=|11>). By keeping |x> constant, the sample space is pruned and focused on verifying the program under different |y> states.
[0097] Strategy 3 (attribute): Check a single attribute instead of the entire density matrix corresponding to the quantum bit state. Typically, only a limited number of attributes of the state are checked (e.g., probability distribution, expected value, and purity), which also satisfy additivity and homogeneity. The present invention can reduce the complexity of tomography by measuring only the specific attributes verified in the assertion, that is, the single attribute checked is the one that satisfies the quantum evolution isomorphism and needs to be verified by the assertion.
[0098] S3, packages the assumption-guarantee assertions in the quantum program and the constructed approximation function into a constraint maximization problem for global search and solution to verify the correctness of the quantum program.
[0099] The present invention verifies assertions without specifying test inputs. It formulates the characteristic relationship between assertions and states as a constrained optimization problem. When errors are found, verification can provide counterexamples or estimate confidence when the program is correct.
[0100] For assertion assert(T1,T2), an optimization-based approach is used to verify the assertion. That is, check the function represented (e.g. Whether the predicate of the assertion is satisfied. If not, the verification model will output a counterexample that causes the assertion to fail.
[0101] According to the definition of the Assume-Guarantee assertion, the predicate P k is defined as an inequality or objective function. This inequality can also be transformed into an objective function. The objective function satisfies P if and only if the predicate is true. k < 0. Therefore, the assertion verification is transformed into a constrained optimization problem:
[0102]
[0103] Where P3 is a guarantee, P1 and P2 are assumptions. and replace and To check if the runtime state satisfies the assertion:
[0104]
[0105] P2(f2(ρ in ))≤0,
[0106] Since ρ in In the approximate function, the parameters {α i} indicates that. Direct optimization {α i} to find the maximum value. The correctness of the assertion is equivalent to:
[0107] assert(T1,T2)≡if max[P3({α})]≤0→true (12)
[0108] >0→false.
[0109] This optimization problem can be efficiently solved by current state-of-the-art optimizers, such as stochastic gradient descent, genetic algorithms, and quadratic programming.
[0110] The approximation accuracy may not be sufficient to distinguish errors in edge cases, making the verification results invalid for all inputs of the program. This inaccuracy can be mitigated by sampling more inputs. This paper proposes a quantitative method to analyze the relationship between confidence and the number of samples, which helps programmers estimate the additional overhead required to achieve the desired confidence.
[0111] Confidence is mainly determined by the approximation precision and the accuracy threshold ∈ defined to identify counterexamples. Confidence measures the probability that the verification result is valid for all inputs. In contrast, 1-confidence is the probability that at least one counterexample exists but is not identified because their approximation precision is less than the accuracy threshold ∈.
[0112] Theorem 3 (Confidence). When no counterexample occurs in the verification, the confidence that the program is correct is:
[0113] confidence=1-P(acc<∈) (13)
[0114] In general, here we assume that the program has only one counterexample to simplify the estimation. A wrong program usually has many more counterexamples. Therefore, the true confidence is higher because it is equal to the probability that the accuracy of all these counterexamples is below the threshold, that is, N c-e is the number of counterexamples. Therefore, the present invention provides a lower bound estimate of the confidence level.
[0115] Experiments using the above method showed that MorphQPV reduced the number of program executions by 107.9 times when verifying a 27-qubit quantum lock algorithm, and increased the success probability by 3.3 to 9.9 times when debugging five benchmarks.
[0116] like Figure 6 As shown, the present invention also provides a system 60 for promoting confident verification by utilizing the isomorphism in quantum programs, including: an assertion statement module 61, a program analysis module 62, and an assertion verification module 63, wherein the assertion statement module 61 is used to define tracking points and mark the quantum bit states of the quantum program at different times through the tracking points, and define assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multi-quantum quantized quantum bit states; the program analysis module 62 is used to construct an approximate function of the true relationship between the input quantum bit state and the quantum bit state of the tracking point based on the quantum evolution isomorphism; the assertion verification module 63 is used to package the assumption-guarantee assertions in the quantum program and the constructed approximation function into a constraint maximization problem for global search and solution to verify the correctness of the quantum program.
[0117] It should be noted that, when performing program verification, the system provided in the above embodiment should be illustrated by the division of the above functional modules, and the above functions can be assigned to different functional modules as needed, that is, the internal structure of the terminal or server is divided into different functional modules to complete all or part of the functions described above. In addition, the system provided in the above embodiment and the embodiment of the method of the present invention belong to the same concept, and the specific implementation process is detailed in the embodiment of the method of the present invention, which will not be repeated here.
[0118] Based on the same inventive concept, an embodiment further provides a computing device, including a memory and one or more processors, wherein executable code is stored in the memory, and when the one or more processors execute the executable code, a method for utilizing isomorphism in a quantum program to promote confident verification is implemented, specifically including the following steps:
[0119] S1, assertion statement: define tracking points and mark the quantum bit states of the quantum program at different times through tracking points, define assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multi-quantum quantized quantum bit states;
[0120] S2, program analysis: construct an approximate function of the true relationship between the input qubit state and the qubit state of the tracking point based on quantum evolution isomorphism;
[0121] S3, assertion verification: Package the assumption-guarantee assertions in the quantum program and the constructed approximation function into a constraint maximization problem for global search and solution to verify the correctness of the quantum program.
[0122] The computing device provided in the embodiment, in addition to the processor and memory, also includes hardware required for other services such as internal bus, network interface, memory, etc. at the hardware level. The memory is a non-volatile memory, and the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the program verification method described in S1-S3 above. Of course, in addition to the software implementation, the present invention does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0123] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for exploiting isomorphism in quantum programs to facilitate confident verification, characterized in that The following steps are involved: Assertion statement: define tracking points as recording time and quantum bits, label the quantum bit states in the quantum program by editing tags, and mark the quantum bit states of the quantum program at different times by tracking points; define assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multiple quantum quantized quantum bit states, including: To describe the range of single-qubit states, the predicate is an inequality or objective function that takes as input a single density matrix representing the qubit states if and only if the predicate When true, the objective function satisfies ; through another predicate To describe the relationship between multiple quantum bit states, the predicate is an inequality or objective function that takes multiple density matrices representing quantum bit states as input. When multiple single quantum bit states satisfy their respective predicates When the relationship between the states of multiple quantum bits should satisfy the predicate ; Program analysis: Based on quantum evolution isomorphism, an approximate function of the true relationship between the input quantum bit state and the quantum bit state of the tracking point is constructed, including: the input quantum bit state It is expressed as a linear combination of sampled inputs, that is, , Indicates i The quantum bit states of the sampled inputs, is the real value to be solved; based on the quantum evolution isomorphism and parameters , construct the quantum bit state of the tracking point The approximate function between the input quantum bit state F for: ; Indicates i The quantum bit state of each sampling tracking point; Case 1: For The accuracy of the quantum bit state of the tracking point solved by constructing an approximate function is 100% for the sampled input; Case 2: For the state that cannot be decomposed into The average accuracy of the quantum bit state at the tracking point is ,in, is the number of sampled inputs, The number of bits of input to the program; when building an approximate function, the accuracy of the quantum bit state of the tracking point solved by the approximate function is improved by increasing the number of sampled inputs; When building the approximate function, the following three strategies are used to sample the input; Strategy 1: Customize the sampling input, including: applying eigendecomposition to the sample data, and taking the first K eigenvectors with large eigenvalues selected based on the eigendecomposition as the sampling input; Strategy 2: Set part of the input qubit state to a constant; Strategy 3: Check a single attribute instead of the entire density function corresponding to the quantum bit state, where the single attribute is the attribute that satisfies the quantum evolution isomorphism and needs to be asserted and verified; Assertion verification: Package the assumption-guarantee assertions in the quantum program and the constructed approximation function into a constrained maximization problem for global search and solution to verify the correctness of the quantum program. Specifically, it includes: bringing the approximation function into the assumption-guarantee assertion, and converting the assumption-guarantee assertion into a constrained optimization problem, and solving the parameters in the approximation function by direct optimization. To find the maximum value that makes the assumption-guarantee assertion true. If it can be found, then the assumption-guarantee assertion is true and the quantum program is correct; When the quantum program is verified incorrectly, the input qubit state is the counterexample that caused the error; when the quantum program is verified correctly, the confidence is estimated based on the accuracy of the analysis , Indicates accuracy, represents the accuracy threshold, express The probability distribution of Represents the number of counterexamples.
2. The method of claim 1 for utilizing isomorphism in quantum programs to facilitate confident verification, characterized in that: For case 1, an exponential sampling method is used to increase the sampling input, and for case 2, a linear increase method is used to increase the sampling input.
3. A system for exploiting isomorphism in quantum programs to facilitate confident verification, characterized in that include: Assertion statement module, which is used to define tracking points as recording time and quantum bits, label the quantum bit states in the quantum program by editing tags, and mark the quantum bit states of the quantum program at different times by tracking points; define assumption-guarantee assertions to specify the range of single quantum bit states and the relationship between multiple quantum quantized quantum bit states, specifically including: through a predicate To describe the range of single-qubit states, the predicate is an inequality or objective function that takes as input a single density matrix representing the qubit states if and only if the predicate When true, the objective function satisfies ; through another predicate To describe the relationship between multiple quantum bit states, the predicate is an inequality or objective function that takes multiple density matrices representing quantum bit states as input. When multiple single quantum bit states satisfy their respective predicates When the relationship between the states of multiple quantum bits should satisfy the predicate ; The program analysis module is used to construct an approximate function of the real relationship between the input quantum bit state and the quantum bit state of the tracking point based on quantum evolution isomorphism, specifically including: the input quantum bit state It is expressed as a linear combination of sampled inputs, that is, , Indicates i The quantum bit states of the sampled inputs, is the real value to be solved; based on the quantum evolution isomorphism and parameters , construct the quantum bit state of the tracking point The approximate function between the input quantum bit state F for: ; Indicates i The quantum bit state of each sampling tracking point; Case 1: For The accuracy of the quantum bit state of the tracking point solved by constructing an approximate function is 100% for the sampled input; Case 2: For the state that cannot be decomposed into The average accuracy of the quantum bit state at the tracking point is ,in, is the number of sampled inputs, The number of bits of input to the program; when building an approximate function, the accuracy of the quantum bit state of the tracking point solved by the approximate function is improved by increasing the number of sampled inputs; When building the approximate function, the following three strategies are used to sample the input; Strategy 1: Customize the sampling input, including: applying eigendecomposition to the sample data, and taking the first K eigenvectors with large eigenvalues selected based on the eigendecomposition as the sampling input; Strategy 2: Set part of the input qubit state to a constant; Strategy 3: Check a single attribute instead of the entire density function corresponding to the quantum bit state, where the single attribute is the attribute that satisfies the quantum evolution isomorphism and needs to be asserted and verified; Assertion verification module, which is used to package the assumption-guarantee assertion in the quantum program and the constructed approximation function into a constraint maximization problem for global search and solution to verify the correctness of the quantum program. Specifically, it includes: bringing the approximation function into the assumption-guarantee assertion, and converting the assumption-guarantee assertion into a constrained optimization problem, and solving the parameters in the approximation function by directly optimizing To find the maximum value that makes the assumption-guarantee assertion true. If it can be found, then the assumption-guarantee assertion is true and the quantum program is correct; When the quantum program is verified incorrectly, the input qubit state is the counterexample that caused the error; when the quantum program is verified correctly, the confidence is estimated based on the accuracy of the analysis , Indicates accuracy, represents the accuracy threshold, express The probability distribution of Represents the number of counterexamples.
4. A computing device comprising a memory and one or more processors, wherein the memory stores executable code, characterized in that: When the one or more processors execute the executable code, they are used to implement the method of utilizing isomorphism in quantum programs to facilitate confident verification as described in claim 1 or 2.
