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

Two merged dfa must have the same alphabets #5

Open
Devorein opened this issue Nov 13, 2021 · 0 comments
Open

Two merged dfa must have the same alphabets #5

Devorein opened this issue Nov 13, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Devorein
Copy link
Member

Devorein commented Nov 13, 2021

const { DeterministicFiniteAutomaton } = require('fauton');

const DivisibleBy3DFA = new DeterministicFiniteAutomaton(
	(randomBinaryString) => {
		return parseInt(randomBinaryString, 2) % 3 === 0;
	},
	{
		label: 'DFA 1',
		alphabets: ['1', '0'],
		description: 'Divisible by 3',
		final_states: ['A'],
		start_state: 'A',
		states: ['A', 'B', 'C'],
		transitions: {
			A: ['A', 'B'],
			B: ['C', 'A'],
			C: ['B', 'C'],
		},
	}
);

const startsWithBC = new DeterministicFiniteAutomaton(
	(inputString) => inputString.startsWith('bc'),
	{
		alphabets: ['a', 'b', 'c'],
		description: 'Starts with bc',
		final_states: ['Q3'],
		label: 'starts_with_bc',
		start_state: 'Q0',
		states: ['Q0', 'Q1', 'Q2', 'Q3'],
		transitions: {
			Q0: ['Q2', 'Q1', 'Q2'],
			Q1: ['Q2', 'Q2', 'Q3'],
			Q2: 'loop',
			Q3: 'loop',
		},
	}
);

const DivisibleBy3OrStartsWithBC= DivisibleBy2DFA.OR(startsWithBC );

This should fail with an appropriate message, but the error message generated is extremely vague and difficult to decipher.

@Devorein Devorein added the bug Something isn't working label Nov 13, 2021
@Devorein Devorein self-assigned this Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant