🤖 AI Summary
How to quantify substantive semantic differences among algorithms? This problem is critical in applications such as code clone detection and program synthesis, yet has long lacked practical, computable metrics due to undecidability and ambiguity in similarity definitions. To address this, we propose EMOC—a novel framework that enables computable embedding of algorithm implementations along four orthogonal dimensions: behavioral equivalence, memory access patterns, operation sequences, and computational complexity. We further introduce PACD, the first publicly available dataset explicitly designed for algorithm-level similarity assessment. EMOC integrates static and dynamic program analysis for robust feature extraction and supports downstream tasks including clustering, classification, and quantification of LLM-generated program diversity. Extensive experiments demonstrate that EMOC significantly outperforms state-of-the-art baselines across algorithm categorization, approximate clone detection, and generated-program divergence evaluation. All code and data are publicly released.
📝 Abstract
Given two algorithms for the same problem, can we determine whether they are meaningfully different? In full generality, the question is uncomputable, and empirically it is muddied by competing notions of similarity. Yet, in many applications (such as clone detection or program synthesis) a pragmatic and consistent similarity metric is necessary. We review existing equivalence and similarity notions and introduce EMOC: An Evaluation-Memory-Operations-Complexity framework that embeds algorithm implementations into a feature space suitable for downstream tasks. We compile PACD, a curated dataset of verified Python implementations across three problems, and show that EMOC features support clustering and classification of algorithm types, detection of near-duplicates, and quantification of diversity in LLM-generated programs. Code, data, and utilities for computing EMOC embeddings are released to facilitate reproducibility and future work on algorithm similarity.