Skip to content

Two merged dfa must have the same alphabets #5

@Devorein

Description

@Devorein
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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions