Solving Regex Crosswords with Z3 - Made of Bugs
For a while now, I’ve been fascinated by Z3 and by SMT solving more broadly. While on pat leave recently, I was reminded of the existence of regular-expression crossword puzzles, and allowed myself to get nerdsniped by writing a Z3-backed solver. I expected to spend perhaps an afternoon cranking out a quick solver; I ended up getting sucked into understanding and debugging Z3 performance, and learning far more about Z3 and about SMT than I expected. In this post, I’ll describe my approach and my initial solver, and then dive into some of the improvements and variations I explored. All of my code is available on github, if you want to follow along or check out my final results. To briefly recap: A regular-expression crossword consists of a grid of (unknown) characters, which are to-be-determined. These characters are constrained by a set of given regular expressions, which must match a given row or column, once filled in. I chose to solve the regexle variant, specifically, which uses a
For a while now, I've been fascinated by Z3 and by SMT solving more broadly. While on pat leave recently, I was reminded of the existence of regular-expression crossword puzzles , and allowed myself to get nerdsniped by writing a Z3-backed solver. I expected to spend perhaps an afternoon cranking out a quick solver; I ended up getting sucked into understanding and debugging Z3 performance, and learning far more about Z3 and about SMT than I expected. In this post, I'll describe my approach and my initial solver, and then dive into some of the improvements and variations I explored. All of my c
saved by
related reading
- A Dumb Introduction to z3ar-ms.me
- Z3 Internals (Draft)z3prover.github.io
- the-illusion-of-thinking.pdfml-site.cdn-apple.com
- GitHub - google/re2: RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.github.com
- Thompson's construction - Wikipediaen.wikipedia.org
- ZK-Friendly Hash Functions | Zellic — Researchzellic.io
- The Regular Expression Denial of Service (ReDoS) cheat-sheet | by James Davis | Level Up Codinglevelup.gitconnected.com
- cs.stanford.edu/~knuth/papers/claude-cycles.pdfcs.stanford.edu
- GitHub - kyx0r/pikevm: Russ Cox/Rob Pike pikevm regex implementationgithub.com
- Regular expression - Wikipediaen.wikipedia.org
- Regular Expression Matching with a Trigram Indexswtch.com
- Fast regex search: indexing text for agent tools · Cursorcursor.com