Skip to content

Conversation

@pazz
Copy link
Collaborator

@pazz pazz commented May 12, 2025

This adds two methods to NFA,

  • is_complete to check if the NFA is complete
  • complete to turn it into a complete NFA.

The latter accepts an Option, which is the sink to be used in new
transitions. If None, self-loops will be added, otherwise new steps
point ot the given (sing) state.

New unit tests are included.

This adds two methods to NFA,
- is_complete to check if the NFA is complete
- complete to turn it into a complete NFA.

The latter accepts an Option<State>, which is the sink to be used in new
transitions. If None, self-loops will be added, otherwise new steps
point ot the given (sing) state.

New unit tests are included.
@pazz
Copy link
Collaborator Author

pazz commented May 12, 2025

implementing this was challenging, because the alphaben needs to be computed lots as it is not explicitly represented in the NFA struct.

questions that came up while touching this code:

  • why is NFA.states a vector of strings, not HashSet<State>?

@pazz pazz requested a review from Copilot May 21, 2025 13:49
Copy link
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

Adds methods to verify and enforce completeness of NFAs, along with supporting helper and tests

  • Implements is_complete to check that every state has an outgoing transition for each symbol in the alphabet
  • Implements complete to fill in missing transitions with either self-loops or a designated sink state
  • Adds get_alphabet helper and new unit tests covering both methods
Comments suppressed due to low confidence (1)

src/nfa.rs:62

  • Comparing state_actions (Vec) with letters (Vec<&str>) will not compile due to a type mismatch. Consider converting one side to match the other (e.g., map letters to String).
if state_actions != letters {

Copilot found some typos in doc strings

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pazz pazz requested a review from Copilot May 21, 2025 14:14
Copy link
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

Adds functionality to check whether an NFA is complete over its alphabet and to complete it by filling in missing transitions, along with tests.

  • Introduce is_complete to verify that each state has transitions for every symbol.
  • Introduce complete to add missing transitions, optionally targeting a sink state.
  • Add unit tests for completeness checking and completion behavior.

@pazz pazz merged commit db5803b into main May 21, 2025
4 checks passed
@pazz pazz deleted the complete branch May 21, 2025 14:23
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