maciej-bendkowski / boltzmann-brain

Analytic sampler compiler for combinatorial systems
BSD 3-Clause "New" or "Revised" License
30 stars 5 forks source link

What is the syntax for rational grammars? #21

Open Kerl13 opened 4 years ago

Kerl13 commented 4 years ago

I don't understand the syntax of rational grammars from the examples. How should I write the specification for aaabb or aa*bb* for instance ?

I tried writing them in the algebraic format but then paganini cannot tune the system (I guess it runs the singular tuner).

maciej-bendkowski commented 4 years ago

The syntax is meant to follow the construction of NFA. For instance, for the simple language aaabb we need two things. First, we need to specify the alphabet { a, b }. Secondly, we need to define the automaton:

State_1 -> State_2 (a)
State_2 -> State_3 (a)
State_3 -> State_4 (a)
State_4 -> State_5 (b)
State_5 -> State_6 (b)
State_6 -> _

and define, in the header of the file

@generate State_1

The above rule define transitions in form of <state> -> <state> (letter). Optionally, you can use the underscore _ to denote an epsilon (think of it as an epsilon transition to some implicit final state). If you need more rules for a single state, say for a* you can write something like:

State -> State (a)
          | _

Regarding the remark of singular tuning, I think that boltzmann-brain should perhaps drop it's use entirely. Actual, singular tuners are a rare phenomenon (usually we can just approximate them). A better interface might just specify the target size and assume an implicit size, say size = 1, 000, 000, to be a reasonable approximation of a singular tuner. That also would be a nice feature to have. Sadly, I cannot guarantee when it's going to be implemented, though.

Kerl13 commented 3 years ago

Oh I understand, I failed to recognize that this was an automaton description, everything is clearer now. Maybe it would be nice to write this in the README.

Concerning singular sampling, I guess you're right. From a practical point of view, targeting a specific size seems more convenient and reliable.

maciej-bendkowski commented 3 years ago

FYI: Most recent changes of boltzmann-brain drop rational input specifications and, consequently, rational grammars. It should, however, be easier to implement ad-hoc sampler generators using boltzmann-brain as a tuning tool.

Kerl13 commented 3 years ago

Ahah I see that my answer is so late that the initial question is already out-dated ^^