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

4--9 домашняя работа по формальным языкам #8

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

IThror10
Copy link
Owner

No description provided.

@IThror10 IThror10 requested a review from WoWaster May 29, 2024 20:07
@WoWaster WoWaster changed the title 9 домашняя работа по формальным языкам 4--9 домашняя работа по формальным языкам May 30, 2024
Copy link

@WoWaster WoWaster left a comment

Choose a reason for hiding this comment

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

Засчитано всё, кроме 4 :)

Comment on lines +4 to +25
def reachability_with_constraints(
fa: FiniteAutomaton, constraints_fa: FiniteAutomaton
) -> dict[int, set[int]]:
intersection = intersect_automata(fa, constraints_fa, lbl=False)
res = {state: set() for state in fa.start_states}

if intersection.is_empty():
return res

from_states, to_states = intersection.get_transitive_closure().nonzero()
n = len(constraints_fa)

for from_state, to_state in zip(from_states, to_states):
if (
from_state in intersection.start_states
and to_state in intersection.final_states
):
res[fa.get_state_by_index(from_state // n)].add(
fa.get_state_by_index(to_state // n)
)

return res

Choose a reason for hiding this comment

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

Можете объяснить почему эта функция крайне похожа на paths_ends?

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