More from Tom MacWright
In October I rode the Green Mountain Gravel Growler route in Vermont with a few close friends. It’s a route curated by bikepacking.com that consists of back roads, dirt roads, and single track trails. It wasn’t as blissfully car-free as the C&O Canal or the loop around Lake Konstanz that I rode earlier this year, but in exchange for sharing the road occasionally, we got loads of variety and beautiful hills to climb up and coast down. As the name implies, the route is structured around breweries. We only did half because vacation time is scarce, but still managed to hit some good ones. The first night’s, in Burlington, was Foam Brewers. I had the “Tally Mark” altbier, which tasted like a cigar, in a good way. We didn’t get much time to explore Burlington. We did see the world’s tallest filing cabinet. The first day of riding was from Burlington to Stowe, with stops at The Bidwell for food, The Tropic for a mid-ride drink, and ending at The Alchemist. About 50 miles, and 3,700 feet of climbing. Places like The Alchemist are impossibly nice: sunshine, babies and puppies crawling in the grass, happy people playing corn hole. The delirious happiness of finishing a long day in the saddle makes it all even more saturated and exuberant. I was feeling pretty good on the bike, most of the ergonomics were working. The only gear tweak that this trip will inspire is sticking to fancy cycling bibs (shorts): Ornot, to be specific, instead of trying to scrape by with the cheap stuff, which for me is The Black Bibs. The Alchemist’s “Heady Topper” is like drinking a flat white made out of hops. .up{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;line-height:0} Weather was perfect for almost the entire trip, and the route was pretty clear and empty. We mostly encountered locals riding casually, casually passing us on the way up some big trail. Vermonters are strong riders. The second day would be about 44 miles of riding and well over 4,200 feet of elevation. At this point everyone was feeling it: we’re New Yorkers and a lot of the biggest rides up till this point have been pretty flat. The total elevation change for the C&O Canal ride we did was 605 feet over 185 miles. Riding Bear Mountain and the Goldens Bridge loop helped with training, but nothing near the city can match the relentless climbing in Vermont. I expect hills to crest when there’s a turn in the road, but Vermont doesn’t follow that rule. But, every hill ends eventually. I only had to walk up one, and that was because it was so steep that I couldn’t get traction and not wheelie at the same time. To make this all easier, we weren’t camping at all, just staying at nice places and sleeping in real beds. With the quickly changing weather, camping in the cold would’ve been pretty tough. So that meant more room for changes of clothes and creature comforts. Places to stay in Burlington, Stowe, Hardwick, and Montpelier are pretty scarce though, and tended to be at the very top of hills. Seemed like everything was at the top of the hill, especially… Where The Alchemist was a casual, hippie-inflected destination, Hill Farmstead was like an elusive vineyard that happened to brew beer. And it’s at the top of a hill, of course. Like everywhere else, there were a few other people who had also biked to the hill, and lots of families, dogs, and fleece jackets. They had a food truck outside which whipped up an excellent, fairly spicy vegan burrito for me. Timing for this trip was tight, and rushing to arrive at a brewery before close had a kind of reality-TV greatest race feel to it. We were going to Hill Farmstead on a Sunday, and their hours on Sundays are 11:30-3pm. They close at three! And they don’t re-open, that’s just it. The rest of the week the bar closes at 5: it’s an exclusively day-drinking oriented outlet. But we made it, and made it to Hardwick, where the local Positive Pie location had a spectacular beer selection and surprisingly vegan-friendly menu. This was my first time in Vermont, encountering its specific brand of rural living. Many people were so open and welcoming to us, asking about the route and complimenting our endurance like proud parents. This, even though it was nearly peak tourist season and they probably get plenty of other people following the same directions. One stop in particular, sticks in my memory, the Maple Corner Community Store. If you look at the full span here: this place is a grocery store, deli, coffee shop, live music venue, bar, as well as the post office. Plus it has a little free library out front, and carries a selection of books written by local authors and signs for plays written by local playwrights that are performed nearby. It’s hard to even comprehend the level of integrated community-hub joy in this place. And, for me, they had a world-class selection of vegan snacks. The few odd interactions with Vermonters were all about land: their private land, and that we should stay off it. Not that we ever were on it - we were staying in houses and riding on public roads. But still we got reminded not to veer off and ride through apple orchards or lawns. In one sense this is a funny inverse of cities, where people control such little territory, but here the average homeowner has acres upon acres. But land rules in Vermont are very unusual: the constitution allows people to hunt, fish, and trap on other people’s private land unless it’s posted that the land doesn’t permit it, and the rules around posting are contentious. I’d be watchful too if people could just hike to my backyard and kill a deer. Then we were headed back on the Amtrak from Montpelier. It’s such a perk to be able to do this kind of trip without renting or using a car at all, just riding to and from train stations. Amtrak’s train ticket guarantees a spot for the bike, but it is always stressful and rushed getting bikes on & off. We only completed the first half of this trip - Burlington-Stowe-Hardwick-Montpelier, so there’s another Vermont trip in the future. Maybe next year! It was really spectacular. The hills were tough, but it was all worth it.
September was another big month for my life, mostly for me offline. Another good month for bicycle riding, seeing more of the trails on Randalls and Wards Islands. The New York area has taught me a few things about islands and one of them is that they're very fungible. On a map, Randalls and Wards Islands look one one island because they're "conjoined". They were conjoined on purpose: they used to be two, with a bridge and everything. But then in 1955 the government announced they wanted to join up the islands "by allowing private contractors to dump debris within Little Hell Gate for free" (!) Photo from From City of New York Department of Parks: 28 Years of Progress, scanned by Erica Fischer (!) CC BY SA 2.0 The opposite happened with Fire Island: it was one island for a while until 2012, and Hurricane Sandy broke it back into two. Photo from USGS, PD Dump trash to combine islands, dump water from the sky to divide them. That's just how life is. .two-up{display:grid;grid-template-columns:1fr 1fr;gap:10px} Listening I watched Magnolia this month and finally got the hype around Aimee Mann. It's a little frustrating that the songs from the film aren't on And a throwback: Dusty Springfield's version of When the Love Light Starts Shining Through His Eyes. Originally recorded by the Supremes and forgive me for highlighting the blue-eyed soul version of this song but it's so driving and urgent in a way that most of the other versions aren't, it's such a good slice of that very particular rushing rhythm of the era. Reading On a meta-level: I'm getting pulled back to Instapaper from Readeck, because I rely on offline reading so often and unfortunately the Readeck iOS offline mode is unreliable. It is open source and I should contribute and in all likelihood the issue will get fixed, but in the meantime I need something to look at on the subway. Reading: I enjoyed Spiral's launch post a lot, as well as turbopuffer's post about their refactoring. Database companies in the AI-adjacent space are a nice hybrid kind of reading, still concerned with architecture and a little more grounded than a lot of the "big idea" or marketing-centric stuff that I read from AI labs. I also liked Charles Broskoski's "Personal Business" essay (one of the are.na founders). And I've been really liking reading Work by Bud Smith. Review of that soon. Otherwise The end of October will be even more packed than September for me, so if I don't post, don't worry, I'm not dead, I'm partying.
I skipped August's Recently because this summer has been relentless, mostly in the positive sense. July and August were filled with bike rides, 5K races, friends in town, life changes and logistics. For a friend's birthday, we rode the rickety Coney Island Cyclone, which was faster and more intense than I remembered it. But it's been 18 years since the last injury on the coaster, and the rider was partly at fault: good enough for me. .two-up{display:grid;grid-template-columns:1fr 1fr;gap:10px} I rode my first proper randonneuring ride: 200km (124mi) to all of the beaches around Brooklyn. It was pretty challenging, as you'd expect, but I didn't 'find my limit' for endurance, but I did find my limit in terms of how many gels & ride-nutrition packets I could consume before sugar becomes repulsive. I do still heartily endorse maple syrup packets for ride nutrition: compared to the space-age fuels that all taste like fruit or coffee, it's an identifiable substance that tastes like you'd expect. And, not pictured, but I ran a bunch of 5Ks. Haven't hit my goal this year of going sub-20, but got close in the last one - 20:15. I'm not giving up yet, because the weather is getting better and Brooklyn has a lot of 5K options. Listening Hot Creek by Duffy x Uhlmann Duffy x Uhlmann has been in my rotation for a year now and the new album has all the things I like from the combination. This and Shrunken Elvis go along well together and both have been hits at dinner parties. This album from Frances Quinlan, the frontperson of Hop Along, went under the radar, but it's so good. I've also been playing Hop Along's send album Get Disowned. I really like everything that this band has put out. It's a product of Philadelphia but I hear some of the elements that drew me to DC post-punk in the turn-on-a-dime songwriting. Get Disowned by Hop Along Watching This video, 'The surprising truth about what motivates us', is kind of an artifact of the 'Obamaverse', as one of my friends would put it. It's by Daniel Pink, a writer-speaker-self-help kind of guy, and it's accompanied by one of those realtime hand-illustrations. There are lots of reasons to tune it out as YouTube filler. Still, I thought it was pretty cool for two reasons: first, it connected directly with Andrew Kelley's video, which is the next one. And it connects with my feelings about incentives and how most simple incentives are counterproductive. And second, the drawing is real. I'm so used to the artificial version of this visual style that it took a minutes to realize that the it wasn't AI or some 'drawing hand' style of video essay, it was a real person making quite nice illustrations: specifically Andrew Park. Found myself nodding along to every bit of this interview with Andrew Kelley. His values and motivation are so nice to encounter in this current phase of tech. He's kind of a role model, which is something that I used to find trite in my early career but I'm coming around to. As Adam Neely pointed out in his video, a lot of the people heavily using Suno (an AI music tool) could not cite any role models, and defaulted to a sort of enclosed, self-centered stance. I see this with engineering too: it's hard to discern what values or talents the people at 'the forefront of the industry' have that I want. Finding personal qualities as something to imitate instead of desires and possessions (cue the segue into Girard's Memetic theory) seems like a better way to live. Reading What strengthens a relationship? Almost always, it is personal investment. Perhaps an AI agent might be better at predicting what my father will want for his birthday than I am, but it definitionally cannot give him my time and consideration. Love is not just a feeling; it is a way of paying attention. Elizabeth Lopatto in The Verge picks apart Mark Zuckerberg's weird, sad view of humanity. It's worth a read even just for the incredible opening anecdote. Home of the titular 100 foot waves. Which existed when I was a kid of course, but the larger world didn’t know about them yet. They were our secret. My grandfather and I would walk to the lighthouse and watch the waves hitting against the cliffs and he’d tell me that these were the biggest waves in the world. I didn’t believe him, of course. I thought it was standard grandpa hyperbole. But I also didn’t want to believe that I was seeing the biggest of anything. Not yet. I wanted the really great things to be in the future. Something to aim for. Which means I missed out on some great things that were right in front of me. Mike Monteiro's newsletter is always beautiful and melancholy, and this is a really nice edition of it. I read and highlighted a few other articles but they were all saying things about AI, mostly about how it makes the world worse and makes people feel bad. I won't add those to the pile because I don't want that kind of content to dominate what I mention, even if it does dominate what I read. Elsewhere For the Val Town blog, I wrote about our experience with the bug bounty program. It's been a very interesting experience. Val Town has a pretty difficult security surface: in contrast to Mapbox, which was mostly a read-only API, it's a very read-write system with many access controls. At the center of the product is a sandbox that we want to keep secure. And because we're living in the AI age, a single bit of functionality can be exposed via REST API, React Router loaders, tRPC, and MCP. Building a model layer and a shared authorization layer - modeled after Oso - has helped a bit. But the reports still come in. It's pretty wild how AI factors into it: I'd say that 100% of the vulnerability reports used AI to write the report itself. From the best reporters, the vulnerabilities come with screen recordings and evidence, and it's clearly not all-robot. But - I suspect that other people manning help desks & bug bounty programs know this experience - it's jarring to go three replies into an email conversation with someone and they suddenly stop using an LLM to write their emails and the voice completely changes, from hyper-literate to abbreviated and misspelled. I also wrote about our new authentication scheme that makes vals require login and makes it possible to manage permissions to val applications, not just their code. It was pretty fun to implement, and the sixth or seventh time working with HMAC schemes I'm starting to get a natural grasp on them.
June was a big month: I went to Porto & Lisbon, and had a lot of life stuff happen. I'll get into the trip once I get my rolls of film developed. Three rolls at a new photo developing place: fingers crossed! Reading I finished reading Intermezzo (of the bag) and it was fantastic. I've always liked Sally Rooney's books but this was the one where the writing style really clicked. Also, The Vegan. Meh. I read Patricia Lockwood's 'A Tradcath Wedding' via Perfect Sentences but found an additional sentence to be perfect: Whenever they rang the chimes, which seemed to be every four seconds or so, a toddler screamed ‘WOW A BELL!’ to the visible displeasure of the celebrants – though isn’t the entire point of the ritual that you’re supposed to be that awestruck every time? Patricia Lockwood is the funniest writer I've read. You cannot grow a pumpkin, but you can improve the odds. Taylor's 'You Cannot Grow a Pumpkin' is a fantastic little prose poem of sorts. Watching I'm always trying to find a 'romp' when it comes to movies. Something lighthearted, pretty easy to watch, so on. We watched The Pink Panther this month and it is a perfect example of the genre. The inspiration for the watch came from the hamburger scene: But there's so much more of this kind of thing in the movie, little bits and physical comedy. Oh, and I also watched The Departed, which everyone says is good and is good. Elsewhere I wrote Accidental Anonymity on the micro blog, and it stirred up some discussion on Bluesky as well as at least one blog response. It was kind of an angry piece, as I said at the start. I will keep trying to stay out of the trap of writing about that topic all the time. Listening The only album I bought this month was Songs of Her's by Her's, which is fine. I wish I had something more profound to say about it given how the band met an unbelievably tragic end. Maybe more influential than that was Know Your Enemy's recent podcasts, especially this one about the pope's encyclical. I've really grown to love that podcast, and it has been part of me intellectually reconnecting with, but not readopting, Catholicism. Art Here's some art I really liked this month: This Hockney piece called 'Picture Emphasizing Stillness' from 1962 was at the MAC/CCB museum in Lisbon. Via Tim Babb, I enjoyed finding Tomás Sánchez's work.
More in programming
The US is updating its primary spatial reference system, replacing NAD 83 with NATRF 2022 and other systems.
by Terence Eden Here's a fun little historic mystery for HTML nerds. Most websites report the language they're written in using the lang attribute. <html lang="en-GB"> But on the <meta> element, it's common to see: <meta content="en_GB" property="og:locale"> Why does that use an underscore rather than a hyphen? What is a language anyway? Here's how the lang attribute works: 3.2.6.2 The lang and xml:lang attributes OK, so what is a valid BCP 47 language tag? Language tags permit only the characters A-Z, a-z, 0-9, and HYPHEN-MINUS (%x2D). 6. Character Set Consideration For example, en is English. en-GB is British English and en-CA is Canadian English. The two parts are separated by a hyphen. Where else is language specificity useful? That's not the only way language tags can appear in HTML. If you want your web page to show a little preview when you share it - perhaps on social media or a messaging app - you can use Open Graph Protocol. og:locale - The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US. Optional Metadata - Open Graph Protocol (Hurrah for American hegemony!) Here's the example it gives: <meta property="og:description" content="Sean Connery found fame and fortune as the suave, sophisticated British agent, James Bond." /> <meta property="og:locale" content="en_GB" /> That says the locale of the tags, not the page, is British English. So you could have a page in the Japanese language but OGP tags written in Cherokee. Now I have two questions. Why doesn't this use the lang attribute? Why does this use an underscore rather than a hyphen? For example, this is valid HTML: <meta property="og:site_name" content="Les Misérables" lang="fr"> <meta property="og:description" content="A book by Victor Hugo." lang="en-GB"> That says the site's name is in French but the description is in English. That will parse perfectly. What's going on with OGP? As I've ranted before, development of Open Graph Protocol is dead. Facebook, who run it, recently reopened their GitHub repo - but only to add a proposed tag. Their discussion forum is full of spam. There's no history of the development, no rationale for why things were chosen, just Facebook's edict. The nearest I can find to an explanation is this Pull Request which references an obsolete page of Facebook's locales. Despite Facebook removing the page, it lives on! Take a look at the documentation for embedded posts. It says: When you load the SDK, change the value of js.src to use your locale. Replace en_US with your locale, e.g., fr_FR for French (France): 'https://connect.facebook.net/fr_FR/sdk.js Which, I think, leads us to the answer. An answer which was hidden in the question the whole time. A language is not the same as a locale. A language only tells you about the language. A locale, by contrast, tells you about the user's preferences. A locale comprises the language, territory, and code set combination used to identify a set of language conventions. These conventions include information on collation, case conversion, and character classification, the language of message catalogs, date-and-time representation, the monetary symbol, and numeric representation. Understanding locale - IBM Do you know if 10/08/12 is the 10th of August or the 8th of October? Is 5.99 describing the cost in a mark, a yen, a buck, or a pound? If you know the locale, you do. So a locale can be more useful than just a plain language. OK, but why does it use an underscore? As far as I can tell, POSIX standardised it in ISO/IEC 15897. It built on a number of older standards. And, for whatever reason, they used the underscore. My final question before I let you get on with your lives - is a locale useful? OGP defines several data types. The date is always in ISO8601 format, so no need for a locale there. Bools, strings, and enums don't benefit from a locale in any way that I can see. What about the new payment property? A locale might be useful there to show currency. Except the specification has: payment:currency - string - The currency code ISO 4217 of the payment. The only thing I can see a locale being useful for is numbers. The thousand separator and decimal mark are different depending on the locale. So it might be useful to display "5,99" or "10.000,32" depending on the page's intended audience. If Facebook were still interested in maintaining OGP, I think that asking them to deprecate og:locale and replace it with lang on specific meta elements would be sensible. So there you have it. A language is not the same as a locale, and an underscore is not the same as a hyphen, and a Facebook recommendation is not the same as a living standard. Right, that's enough yak shaving. I'm sure I was meant to be doing something important… Oh! Yes! Welcome to HTMHell 🎅
For many course creators, the Black Friday holiday period is when we offer the biggest discounts of the year, which means it’s a great time to pick up some of the web development courses you’ve had your eye on! This post is a quick round-up of my top 10 picks.
Without wasting your time, here it is: Any edge not shown goes to an error state. If you can start in ACC, follow the edges for each byte in your input and end up back in ACC, your string is valid UTF-8. Some C code implementing the above DFA is as follows. It highlights some of the neat features that our new automaton supports, namely quick branchless transitions as a shift-DFA, trivial parallel evaluation, and instant error recovery. #include <stddef.h> #include <stdint.h> enum { DFA_ACCEPT = 2, DFA_SYNC = 16 }; static const uint32_t DFA[256] = { [0x00 ... 0x7f] = 0xcae2bb8a, [0x80 ... 0x8f] = 0xaef05f22, [0x90 ... 0x9f] = 0xbff05f22, [0xa0 ... 0xbf] = 0xbf905f22, [0xc0 ... 0xc1] = 0xc6318cbb, [0xc2 ... 0xdf] = 0xcb8dc637, [0xe0] = 0xc6565dd9, [0xe1 ... 0xec] = 0xc8c7771d, [0xed] = 0xc63318cc, [0xee ... 0xef] = 0xc8c7771d, [0xf0] = 0xcbbaeeeb, [0xf1 ... 0xf3] = 0xc8c97725, [0xf4] = 0xc6546551, [0xf5 ... 0xff] = 0xc6318cbb, }; uint32_t step(uint32_t s, uint8_t b) { return DFA[b] >> (s & 31); } int is_error(uint32_t s) { return !((0x4459a285 >> (s & 31)) & 1); } int partial(uint32_t s) { return (0x92283845 >> ((s + 12) & 31)) & 3; } size_t utf8_valid_up_to(const uint8_t *buf, size_t len) { uint32_t s = DFA_ACCEPT, t; size_t i = 0; for (; i + 32 <= len; i += 32) { uint32_t s1 = s, s2 = DFA_SYNC; for (int j = 0; j < 18; j++) { s1 = step(s1, buf[i + j]); s2 = step(s2, buf[i + j + 14]); } if (is_error(s1) | is_error(s2)) break; s = s2; } for (; i < len && !is_error(t = step(s, buf[i])); i++) s = t; return i - partial(s); } Note that a proper UTF-8 validation routine should at the very least have hot paths for ASCII, this is just an example. And while the above definitely doesn’t beat simdutf, it runs only ~2.5x slower on my Apple M5 laptop when validating Chinese, which isn’t bad for ~30 lines of scalar code. Compared to Björn Höhrmann’s minimal C UTF-8 validator, the above runs 9 times faster in the same benchmark. State machine Our state machine isn’t minimal, but that’s on purpose. It has three nice properties: Like Per Vognsen’s shift-DFA, this state machine can be encoded so each transition is a byte lookup into an array of magic constants followed by a bit shift. Their original implementation packed the constants as uint64_ts, this one fits them in uint32_ts through the use of a SAT solver and overlapping the constants, reducing the lookup table from 2 → 1 KiB. Because we do not merge states which have consumed a different number of bytes of a partial codepoint, error recovery is trivial. In case of an error we can directly read off from the state machine how many bytes we consumed, go back that much, and insert a replacement character if desired. An extra SYNC state is added to the state machine, which absorbs continuation bytes. This makes it super easy to do parallel validation, allowing the shift-DFA to run almost twice as fast as previous shift-DFA UTF-8 validators due to instruction-level parallelism. The trick is to overlap the end of one chunk of bytes with the start of the next chunk by 4 bytes (since no valid codepoint can be > 4 bytes). The first parallel run will validate the overlap, and the second can synchronize on it. If there was an error in these four bytes the second DFA’s state will be nonsense, but the first will catch the error safely. Shift-DFA I would highly recommend reading Per Vognsen’s original shift-DFA exposition, but in short, if you have a finite automaton with a limited number of states and symbols, you can store a transition table. It seems natural to store per state what transition to take for each symbol: $$(\mathrm{State} \times \mathrm{Symbol}) \to \mathrm{State},$$ but if you have a very small number of states it is actually more efficient to store for each symbol how each state transitions: $$\mathrm{Symbol} \to (\mathrm{State} \to \mathrm{State}).$$ This is for two reasons: The memory lookups can all be done in parallel, off the critical dependency chain, as each lookup only depends on its symbol, not the previous state. All the information needed for a $\mathrm{State} \to \mathrm{State}$ function can be stored in one register (naive encoding is $n \cdot \lceil \log_2 n \rceil$ bits for $n$ states). If you choose your state indices cleverly, doing a state transition can even be a single operation after the lookup, e.g. for at most 32 states: state = table[symbol] >> (state % 32) On most hardware shift counts automatically wrap around, making the mod free, as long as it’s 32 or 64. I’m not clever enough, so a SAT solver was used to pack the shift-DFA transition table into uint32_t magic constants. It is somewhat surprising this fit at all, since we have thirteen states, meaning we need 4 bits to encode a transition target, and ${13 \times 4 = 52}$ bits to store it naively. Worse still, since we want to target uint32_t magic constants, our natural modulo is 32, meaning five bits define a state. Luckily we can overlap the bits of neighboring states, if the start of one matches the end of another. To make it fit I still had to be a bit creative: there isn’t a single error state. Instead, we have 32 possible states, of which 12 are valid and 20 are invalid. The only requirement on the invalid states is that they remain invalid on every transition. Luckily checking if a state is valid can still be done with just one shift into a bit vector. What follows is the Z3 code to find our magic DFA constants, it runs in ~15 minutes on my machine. from z3 import * STATES = 'ACC SYNC 1/2 1/3 2/3 1/4 2/4 3/4 E0 ED F0 F4'.split() CONT = {'SYNC': 'SYNC', '1/2': 'ACC', '1/3': '2/3', '2/3': 'ACC', '1/4': '2/4', '2/4': '3/4', '3/4': 'ACC'} CLASSES = { '00-7f': {'ACC': 'ACC', 'SYNC': 'ACC'}, '80-8f': {**CONT, 'ED': '2/3', 'F4': '2/4'}, '90-9f': {**CONT, 'ED': '2/3', 'F0': '2/4'}, 'a0-bf': {**CONT, 'E0': '2/3', 'F0': '2/4'}, 'c0-c1 f5-ff': {}, 'c2-df': {'ACC': '1/2', 'SYNC': '1/2'}, 'e0': {'ACC': 'E0', 'SYNC': 'E0'}, 'e1-ec ee-ef': {'ACC': '1/3', 'SYNC': '1/3'}, 'ed': {'ACC': 'ED', 'SYNC': 'ED'}, 'f0': {'ACC': 'F0', 'SYNC': 'F0'}, 'f1-f3': {'ACC': '1/4', 'SYNC': '1/4'}, 'f4': {'ACC': 'F4', 'SYNC': 'F4'}, } # The offset of valid state s, and the word of class c. off = {s: BitVec(s, 32) for s in STATES} word = {c: BitVec(c, 32) for c in CLASSES} valid = lambda x: Or([x == o for o in off.values()]) # Each state has a unique offset below 32. solver = Solver() solver.add(*[ULT(o, 32) for o in off.values()]) solver.add(Distinct(*off.values())) for c, trans in CLASSES.items(): step = lambda o: LShR(word[c], o) & 31 # State s should go to its target state or error. for s in STATES: if s in trans: solver.add(step(off[s]) == off[trans[s]]) else: solver.add(Not(valid(step(off[s])))) # Error states only transition to error states. for e in range(32): e = BitVecVal(e, 32) solver.add(Or(valid(e), Not(valid(step(e))))) solver.check() model = solver.model() for s in STATES: print(s, model[off[s]]) for c in CLASSES: print(c, f'{model[word[c]].as_long():08x}') Acknowledgements I’d like to thank Thom Chiovoloni for their discussions and their earlier work on packing the lookup tables using Z3, and Max Hollmann for bringing shift-DFA UTF-8 validation to my attention at RustWeek 2026 and exchanging further thoughts.