Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

The conceptual mutator deterministically selected the first applicable mutation site, preventing generation of diverse mutants. For G((X a) -> (G b)), only ((X a) -> (G b)) was produced, never (G((X a) -> b)).

Changes

  • New applyTilFirstRandom: Collects all applicable mutation paths via DFS, randomly selects one
  • New collectAllMutationLocations: Returns list of paths ['operand'], ['left', 'operand'], etc. to mutation sites
  • New applyMutationAtPath: Traverses path, applies mutation function, threads result back through parent nodes
  • Selective application: Only ImplicitG and ImplicitF use random selection; complex mutations like BadStateIndex retain first-match behavior to preserve atomic transformations

Example

# Before: Always removes outer G
applyMisconception(parse("G((X a) -> (G b))"), ImplicitG)
# => "((X a) -> (G b))"  (100% of attempts)

# After: Randomly selects between removal sites
applyMisconception(parse("G((X a) -> (G b))"), ImplicitG)
# => "((X a) -> (G b))"  (~50%)
# => "(G((X a) -> b))"   (~50%)

Tested with formulas containing 2-3 mutation sites; distributions are approximately uniform. Existing tests pass without modification.

Original prompt

This section details on the original issue you should resolve

<issue_title>Conceptual mutator improvements</issue_title>
<issue_description>The conceptual mutator could be BETTER about generating more diverse candidates by running through more interesting ways of implementing the rewrite rules. For instance, for the formula G ( (X a) -> (G b)), we could potentially have two different implicit G mutants: ( (X a) -> (G b)) and G ( (X a) -> (b)). While its fine for the mutator to produce either one of them, I think we predictably always produce one of them every time.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits November 23, 2025 16:07
- Add applyTilFirstRandom function to randomly select from all possible mutation locations
- Use new function for ImplicitG and ImplicitF to enable diverse mutations
- Keep applyTilFirst for complex mutations like BadStateIndex that need atomic application
- Add diversity tests to verify multiple variants are produced

Co-authored-by: sidprasad <6439400+sidprasad@users.noreply.github.com>
- Refactor collectAllMutationLocations to store paths only, not pre-computed results
- Apply mutation function at traversal time in applyMutationAtPath
- This ensures correct tree reconstruction when mutations are applied at nested levels

Co-authored-by: sidprasad <6439400+sidprasad@users.noreply.github.com>
- Change path=[] to path=None with proper initialization
- Prevents potential issues with mutable default arguments being shared across calls

Co-authored-by: sidprasad <6439400+sidprasad@users.noreply.github.com>
- Fix docstring to correctly describe return type (list of lists, not tuples)
- Add clarifying comments about the node threading pattern in applyMutationAtPath
- Fix parameter order consistency in applyMutationAtPath call

Co-authored-by: sidprasad <6439400+sidprasad@users.noreply.github.com>
- Clarify docstring about independent path copies
- Replace silent error return with descriptive exception for invalid paths
- Extract magic number NUM_DIVERSITY_ITERATIONS as a constant in tests

Co-authored-by: sidprasad <6439400+sidprasad@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve diversity in conceptual mutator output Add random selection across mutation locations for ImplicitG/ImplicitF Nov 23, 2025
Copilot finished work on behalf of sidprasad November 23, 2025 16:19
Copilot AI requested a review from sidprasad November 23, 2025 16:19
@sidprasad sidprasad marked this pull request as ready for review November 29, 2025 18:58
@sidprasad sidprasad merged commit 4c682e0 into main Nov 29, 2025
1 check 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.

Conceptual mutator improvements

2 participants