Aunsiels / pyformlang

A python library to manipulate formal languages and various automata
https://pypi.org/project/pyformlang/
MIT License
45 stars 10 forks source link

Bug with to_normal_form() function #6

Closed vadyushkins closed 3 years ago

vadyushkins commented 3 years ago

Hi, @Aunsiels! First of all, thanks a lot for the wonderful library! I was translating the context-free grammar into the Chomsky normal form by using to_normal_form() function and noticed this strange bug.

>>> from pyformlang.cfg import CFG
>>> cfg = CFG.from_text("S -> a S b S")
>>> cnf = cfg.to_normal_form()
>>> cnf.productions
set()

However, I was expecting to see something like this.

S -> S0 S
S0 -> S2 S1
S1 -> b
S2 -> S3 S
S3 -> a

Environment

vadyushkins commented 3 years ago

Sorry, I didn't notice that this grammar specifies an empty language.

Aunsiels commented 3 years ago

No problem :)