Case Studies (benchmarks/cases.md)
The Alnoms Case Study suite consists of foundational demonstrations designed to test the limits of static analysis and empirical scaling. These cases represent the most frequent "Silent Traps" encountered in modern software engineering and research.
🏗️ 1. The Core Demonstration Suite (Demos 1–9)
The following cases are used to validate the engine's detection and remediation logic. These are the canonical examples for identifying quadratic and cubic growth in Python scripts.
| Case | File | Focus | Primary Remedy |
|---|---|---|---|
| 01 | 1_cubic_matrix.py |
Triple-nested loops (Cubic complexity) | Hardware Vectorization / Pruning |
| 02 | 2_quadratic_duplicates.py |
Pairwise Comparison via nested loops | Hash-based Deduplication |
| 03 | 3_nested_membership.py |
Membership test (in) inside a loop |
SeparateChainingHashST |
| 04 | 4_concat_in_loop.py |
String/List concatenation inside loops | List Accumulation + .join() |
| 05 | 5_list_extend_vs_append.py |
Inefficient list building patterns | Batch extend operations |
| 06 | 6_redundant_sort.py |
Sorting inside loops (Hoisting check) | MergeSort / Logic Hoisting |
| 07 | 7_manual_bubble_sort.py |
Manual \(O(N^2)\) sort detection | MergeSort / QuickSort |
| 08 | 8_linear_search_in_loop.py |
Repeated linear search anti-pattern | Indexing / Hashing |
| 09 | 9_naive_find.py |
Sequential scanning patterns | Binary Search / Hash Lookup |
🔬 2. Advanced Structural Analysis (Demos 10–11)
Alnoms goes beyond simple loops to identify complex pointer and graph-based patterns.
Case 10: Graph-like Traversal (10_dfs_like_loop.py)
Objective: Detect stack-based iteration that mimics Depth-First Search (DFS).
* Code Intent: Iterative DFS using a manual stack and a visited set.
* Metadata Impact: Mapped to \(O(V+E)\) complexity in the Sovereign Registry.
* Governance Value: Ensures that traversals do not accidentally degrade into quadratic behavior due to inefficient neighbor lookups.
Case 11: Pointer-based Patterns (11_cycle_detection_manual.py)
Objective: Identify manual implementations of Floyd’s Cycle-Finding Algorithm.
* Code Intent: "Slow" and "Fast" pointer traversal to detect cycles in linked structures.
* Recommendation: Alnoms identifies this as a candidate for the has_cycle sovereign implementation, reducing the "cognitive tax" of maintaining manual pointer logic.
📈 3. Empirical Scaling Contracts (Demo 12)
Case 12: Execution Entrypoints (12_execution_entrypoint.py)
Objective: Test the engine's ability to handle production-style scripts with if __name__ == "__main__": blocks.
* Verification: The Analyzer isolates the target function and subjects it to the Doubling Test even when wrapped in a standard entrypoint.
* Result: Proves that Alnoms can audit scripts without requiring the user to rewrite their code specifically for the engine.
🧭 4. Design Principles for Case Studies
- Real and Practical: Every case study is based on common engineering mistakes rather than abstract puzzles.
- Evidence-Based: Every case is accompanied by a
run_demoscript that produces a full Performance Report as proof of detection. - Reproducibility: Users can run
python run_demos_1_to_12.pyto see the engine execute the full audit pipeline across all cases in real-time.
Note: For the full source code and runnable scripts, please explore the
examples/alnoms/directory.
👉 Next Step: See the End-to-End Runs for a deep dive into the specific report output generated by these cases.