Partial Equivalence Verification for Source Code Refactoring
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing equivalence verification methods, such as those described in Non-Patent Literature 1, fail to accurately judge function equivalence due to requiring identical output values for all input values, leading to wide ranges of inequivalence judgments and increased manual bug analysis time, and are limited by complex variable expressions and large numbers, as seen in Patent Literature 1.
Innovation Solution
An equivalence verification apparatus that includes a unit to judge function equivalence through partial verification by excluding inequivalent paths and performing equivalence verification on corresponding combinations of functions in pre-change and post-change source code, allowing for partial equivalence judgment.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If exhaustive equivalence verification is performed for every input value, then verification completeness is improved, but verification time and analysis scope increase significantly
Solution Approach 1:
The patent segments the verification process by dividing functions into equivalence classes based on their behavior characteristics. Instead of verifying every function individually against all input values, functions are grouped into classes (e.g., linear functions, constant functions, identity functions) and verified representativeatively. This segmentation reduces the verification scope while maintaining completeness for each class.
Solution Approach 2:
The patent changes the verification parameter from individual input values to function behavior patterns. By analyzing the mathematical properties and transformation patterns of functions (such as whether they preserve equality, reverse equality, or transform values in specific ways), the verification shifts from exhaustive input testing to pattern-based classification, significantly reducing time while maintaining reliability.
2Measurement precision
If strict equivalence judgment is applied requiring identical output values for all input values, then verification accuracy is improved, but the judgment range becomes too narrow and rejects partially equivalent functions
Solution Approach 1:
The patent applies local quality by allowing different equivalence criteria for different function types. Instead of a uniform strict equivalence standard, the system defines multiple equivalence relations tailored to specific function categories (e.g., strict equality preservation for some functions, reverse equality for others, or equivalence under specific transformations). This enables partially equivalent functions to be recognized while maintaining high accuracy for each function type.
Solution Approach 2:
The patent introduces dynamic equivalence judgment that adapts the equivalence criteria based on the function's behavior pattern. The equivalence relation is not fixed but determined dynamically through analysis of the function's mathematical properties and transformation characteristics. This allows the verification system to flexibly adjust the equivalence standard to match the function's actual behavior, expanding the judgment range while preserving accuracy.
3Ease of manufacture
If refactoring is performed to improve software quality, then software maintainability is improved, but the substance of logical operations may be unintentionally changed
Solution Approach 1:
The patent implements feedback-based verification where the equivalence verification results are fed back to validate whether refactoring preserved the original logical operations. The system automatically compares the refactored code against the original code using the defined equivalence relations, providing feedback on whether the refactoring was successful or introduced unintended changes. This feedback mechanism ensures maintainability improvements do not compromise logical correctness.
Data Source
AI summary
An equivalence verification unit (130) judges through equivalence verification, for each of corresponding combinations which are each a combination of a function included in pre-change source code and a function included in post-change source code, whether the functions included in the corresponding combination are equivalent to each other. A partial verification judgment unit (150) judges, for each of inequivalent ones of the corresponding combinations, whether the corresponding combination is a partial verification combination including a function where an inequivalent path, in which an inequivalent function is called, and a non-inequivalent path, in which a non-inequivalent function is called, are both included. A partial verification unit (160) judges, for each of the partial verification combinations, whether the functions included in the partial verification combination are partially equivalent to each other by excluding the inequivalent path and performing the equivalence verification.


