Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for epsilon stack moves in PDAs #236

Open
Muon opened this issue Oct 2, 2024 · 2 comments
Open

No support for epsilon stack moves in PDAs #236

Muon opened this issue Oct 2, 2024 · 2 comments

Comments

@Muon
Copy link

Muon commented Oct 2, 2024

The way Sipser's textbook defines PDAs, they can have epsilon stack moves. So for example "a, eps -> x" says "read a, push x" and "a, eps -> eps" says just "read a". These are compatible with the Hopcroft and Ullman definition which is used here. (Just a slight extension!) Could support for them please be added? Sipser's textbook is very popular and I just had to post this workaround to my class:

def fill_in_epsilon_stack_moves(stack_alphabet, table):
    """Convert a Sipser-style transition table to a Hopcroft-Ullman-style transition table.

    Table is modified in-place, and returned from this function."""
    for f in table.values():
        for g in f.values():
            if '' not in g:
                continue
            for b in stack_alphabet:
                new_transitions = set()
                for (q, s) in g['']:
                    if s == '':
                        new_transitions.add((q, b))
                    else:
                        new_transitions.add((q, (s, b)))
                if b in g:
                    g[b] |= new_transitions
                else:
                    g[b] = new_transitions
            del g['']
    return table
@caleb531
Copy link
Owner

caleb531 commented Oct 4, 2024

@eliotwrobson Do you have any thoughts on this? I can't say I'm too familiar with the specific algorithms, but adding support for this seems like a reasonable idea to me.

@eliotwrobson
Copy link
Collaborator

This seems like a reasonable thing to add! I think this just generalizes the definition of PDAs. There aren't too many algorithms implemented for those, so should be a straightforward change to add. I'm swamped with other projects now, but @Muon if you or someone else were to implement this change, I could definitely review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants