Alcides Fonseca.AI & Programming Languages researcher
40.197958, -8.408312

Making intelligent software
more reliable.

I work on the intersection of AI, Software Engineering and Programming Languages. Currently, I am applying Formal Methods to Agents, towards AI Safety.

Program synthesisLiquid typesReliable AIGuardrailsEvals

Wanted: an elegant solution for breadth-first iteration of a tree structure.

While working on the enumerative feature of GeneticEngine, I wanted to recursively explore all the instances of a grammar, ideally using cache.

My first solution ended up being DFS as I used Python generators to yield all possible options on sum types and recursively iterating through all arguments in product types.

I’ve written this proof of concept pt implement breadth-first iteration in a generic tree structure that yields the right order. However, I find the extra argument a bit ugly, and I would like a more elegant solution. If you happen to know it, I’m all ears!

Read next