arabelatso/semantic-equivalence-verifier
Analyzes and verifies semantic equivalence between two functions, classes, or modules by examining control flow, data flow, and observable behavior. Use when comparing code implementations (refactored vs original, different implementations of same functionality, migration verification), determining if two code artifacts produce identical behavior, identifying behavioral differences between code versions, or validating that code changes preserve semantics. Supports formal reasoning and symbolic execution approaches.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill semantic-equivalence-verifier
This skill enables rigorous analysis of semantic equivalence between two code artifacts (functions, classes, or modules). It systematically compares control flow, data flow, and observable behavior to determine if implementations are functionally identical, and provides actionable guidance for achieving equivalence when differences exist.
Clearly identify the two code artifacts to compare:
Artifact A: [function/class/module name and location]
Artifact B: [function/class/module name and location]
Specify the equivalence scope:
Perform systematic static analysis on both artifacts:
Control Flow Analysis:
Data Flow Analysis:
x*2 vs x+x)Signature Analysis:
Analyze runtime behavior and observable effects:
Input-Output Mapping:
Side Effects:
Performance Characteristics:
For rigorous verification, apply formal methods:
Symbolic Execution:
Formal Proof:
Equivalence Checking:
Generate a comprehensive equivalence report using the template in assets/equivalence_report_template.md:
If Equivalent:
If Not Equivalent:
Different languages require adapted analysis approaches:
Statically Typed (Java, C++, Rust):
Dynamically Typed (Python, JavaScript):
Functional (Haskell, OCaml):
Refactoring Patterns:
temp=x; return temp ≡ return xOptimization Patterns:
x*0 ≡ 0Algorithm Substitution:
pow(x,2) ≡ x*xExample 1: Simple Function Comparison
# Artifact A
def sum_squares(n):
total = 0
for i in range(1, n+1):
total += i * i
return total
# Artifact B
def sum_squares(n):
return n * (n + 1) * (2*n + 1) // 6
Analysis: Mathematically equivalent for all non-negative integers. Different algorithms, same result.
Example 2: Class Refactoring
// Artifact A
class Calculator {
int add(int a, int b) { return a + b; }
int multiply(int a, int b) { return a * b; }
}
// Artifact B
class Calculator {
int add(int a, int b) { return a + b; }
int multiply(int a, int b) {
int result = 0;
for(int i = 0; i < b; i++) result += a;
return result;
}
}
Analysis: Not strictly equivalent - Artifact B fails for negative b. Partial equivalence for b >= 0.
For detailed guidance on specific analysis techniques:
references/formal_verification.mdreferences/symbolic_execution.mdreferences/language_patterns.mdTake arabelatso/semantic-equivalence-verifier from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.