Daily Shaarli

All links of one day in a single page.

August 2, 2024

Enumerating a context-free language « Luke Palmer
pairs = [ (x,y) | x <- [0..], y <- [0..] ]

This program doesn't really enumerate all "valid" pairs in finite time. For example (0, 1) is never reached because the list will not halt traversing the first component. How can we enumerate the space of all indexable pairs of integers? Moreover, given a recursive context-free grammar, how to write a program that enumerates all valid expressions?

This type of enumeration problems is where the Omega Monad can be useful. It acts like a "breadth-first" search for list comprehension. I recall finding the conde primitive (sometimes known as condi) from miniKanren fascinating. Now I learned the Omega Monad is exactly the same thing.