Implementing a symbolic string capitalization method #49
Replies: 2 comments
-
Very exciting. I've got a few thoughts for you, but this approach is a good start. May I assume that you're interested in this work partly as a learning experience? If so, I think I should hold back and let you explore the problem a little first. First, some related links: 1, 2, 3. (note you'll find stuff sometimes with the python API and sometimes in SMTLIB format; you can generally call A few tempting things that I recommend you avoid: (1) quantifiers, that is At any rate, your starting code looks good to me, and I think some of those links above will give you ideas about how to implement |
Beta Was this translation helpful? Give feedback.
-
A minor update for folks stumbling upon this discussion: CrossHair now supports all case-changing methods, albeit slowly, even over unicode. |
Beta Was this translation helpful? Give feedback.
-
This is a follow-up to #39 and the goal of this thread is to brainstorm a design to implement capitalization as a symbolic string method.
So, if we assume that we already have a symbolic version of
upper
implemented, we can probably implementcapitalize
as follows:Assuming this is more-or-less correct, all it means is that we need to implement
upper
. To implement upper, I see two options:(1) We could create a dictionary of the english alphabet that maps lowercase letters to their uppercase variants. A failed index to this dictionary would return the input itself (this would occur, say, if you were trying to uppercase a string representing a number)
(2) Extracting the ASCII-number out of the symbolic string and adding 32 so long as the ASCII number is between [32, and 96]. All other inputs would remain unchanged. Now I'm unsure if we can even access the numeric representation of a z3 string so maybe this is a dead end...
The first case seems easiest to me, although I'm unsure if there are performance implications to it. I would love to hear y'alls thoughs, maybe there's something I haven't thought about. If all looks good, I'll go ahead and implement upper using approach (1) and then use that as the backbone for
capitalize
.Thanks again!
Beta Was this translation helpful? Give feedback.
All reactions