Skip to content

Add prime-or-square-or-semiprime-window procedural heuristic and metadata#26

Merged
GISMO-1 merged 1 commit into
mainfrom
gismo/implement-combined-procedural-heuristic-for-primes
Mar 2, 2026
Merged

Add prime-or-square-or-semiprime-window procedural heuristic and metadata#26
GISMO-1 merged 1 commit into
mainfrom
gismo/implement-combined-procedural-heuristic-for-primes

Conversation

@GISMO-1

@GISMO-1 GISMO-1 commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Reduce expanded-case churn by combining the existing prime/square fast-path with an SPF-gated semiprime escalation so non-prime/non-square candidates that look semiprime can take the semiprime action.
  • Provide richer diagnostics for exported expanded-case metadata to record which gating stage applied and SPF diagnostics for post-hoc analysis.

Description

  • Add a new procedural heuristic prime-or-square-or-semiprime-window in src/strausforge/identities.py that preserves prime-or-square-window behavior for primes/squares and otherwise applies semiprime gating (bounded SPF) to choose the semiprime action (128 initial window) or default (8).
  • Register the new option in PROC_HEURISTIC_CHOICES and update CLI help/error strings in src/strausforge/cli.py so all relevant commands accept and document the new heuristic.
  • Use semiprime_window_trigger in src/strausforge/hardness_core.py when emitting expanded-case metadata and add proc_stage (one of "prime"|"square"|"semiprime"|"none"), semiprime_triggered (bool), and spf_bound_used (int) to exported records.
  • Add tests in tests/test_identities_verify.py and update tests/test_factor_meta.py to exercise combined-heuristic parity with POSW on prime/square inputs and semiprime triggering behavior, and to assert the new proc_stage field is present.

Testing

  • Installed dev deps with python -m pip install -e '.[dev]' and ran linting with ruff to validate formatting and imports, which passed after formatting fixes.
  • Ran targeted tests pytest -q tests/test_identities_verify.py tests/test_factor_meta.py tests/test_cli.py and the full suite pytest -q, with all tests passing (final run: 77 passed, 1 skipped).
  • Performed the acceptance-style check by calling run_hardness over 22_000_00023_000_000 with proc_heuristic='prime-or-square-window' and proc_heuristic='prime-or-square-or-semiprime-window'; the results were: POSW expanded = 10, combined expanded = 0, and combined expanded_primes = 0.

Codex Task

@GISMO-1 GISMO-1 merged commit 6223fa5 into main Mar 2, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant