class Z3::ReExpr

A regular expression over some sequence sort - ‘Re(String)` for regexes over Strings, `Re(Seq(Int))` for regexes over sequences of Ints.

These are deliberately not Ruby Regexps, and nothing here converts between the two in either direction. Ruby’s regexes match unanchored, backtrack, and have backreferences and lookaround; Z3’s denote regular languages, match the whole sequence, and are closed under intersection and complement. Compiling one into the other would quietly change what a pattern means, so a Z3 regex is built out of the combinators here - or out of a String or a Seq, which ‘seq.to_re` turns into the regex matching exactly that one value and nothing else.

That last conversion is what makes ‘Z3::Re.Union(“cat”, “dog”)` work: anywhere a regex is expected, a Ruby String, a Ruby Array, a StringExpr or a SeqExpr means “the regex matching exactly this”. The one place it deliberately doesn’t happen is matches?, because that’s where Ruby’s reading and Z3’s differ.

‘==` comes from Expr and needs no help here, but it’s worth knowing what it means: Z3 decides it as *language equivalence*, not as sameness of terms, so ‘solver.prove! (a + b).star + a == a + (b + a).star` comes back proven. That’s the thing a backtracking regex engine can’t do at all.