Skip to content

Add guards for metavariable occurence, and sorting rule candidates by n constants#27

Merged
psaegert merged 2 commits into
mainfrom
dev
Apr 6, 2026
Merged

Add guards for metavariable occurence, and sorting rule candidates by n constants#27
psaegert merged 2 commits into
mainfrom
dev

Conversation

@psaegert
Copy link
Copy Markdown
Owner

@psaegert psaegert commented Apr 6, 2026

… n constants

Copilot AI review requested due to automatic review settings April 6, 2026 15:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds termination/pruning guards around rule discovery and maintenance in SimpliPy, aiming to avoid non-terminating metavariable expansions and reduce redundant explicit rules.

Changes:

  • Add violates_wildcard_multiplicity(...) and use it during rule discovery to filter unsafe candidates, while also preferring candidates with fewer '<constant>' tokens.
  • Introduce SimpliPyEngine.prune_redundant_rules() and invoke it after rule discovery; add a CLI prune-rules command.
  • Update tests for pruning/multiplicity behavior and bump project version to 0.2.15.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_engine_simplification.py Adds tests for rule pruning and wildcard multiplicity guard.
src/simplipy/utils.py Adds wildcard multiplicity checker helper.
src/simplipy/engine.py Adds redundant-rule pruning, integrates multiplicity guard + candidate sorting in rule finder, and runs pruning after rule discovery.
src/simplipy/__main__.py Adds prune-rules CLI command.
README.md Version bump to 0.2.15.
pyproject.toml Version bump to 0.2.15.
.gitignore Ignore .vscode/.
.github/copilot-instructions.md Removes Copilot instruction file.
Comments suppressed due to low confidence (1)

tests/test_engine_simplification.py:120

  • Lines 117–124 are indented as part of the TestPruneRedundantRules class body but are not inside a test_... method. This will execute at import/class-definition time and will likely break test collection (and/or perform a networked SimpliPyEngine.load(...) during import). Wrap this block in a test function/method (e.g. def test_repeated_addition_...) and ensure the indentation is correct so it’s not executed at class scope.
        assert len(engine.simplification_rules) == 2
    engine = SimpliPyEngine.load("dev_7-3", install=True)
    expr = " + ".join(["x"] * 14)

    simplified = engine.simplify(expr, max_iter=1, verbose=False)

Comment thread src/simplipy/utils.py Outdated
Comment thread src/simplipy/engine.py Outdated
Comment thread src/simplipy/__main__.py
Comment thread src/simplipy/engine.py
@psaegert psaegert merged commit c84741f into main Apr 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants