-
Notifications
You must be signed in to change notification settings - Fork 166
Description
cv compute currently has excellent support for num-keyed finite maps via sptrees (cv_stdScript.sml:432-495), with operations like FEMPTY, FLOOKUP, FUPDATE, and DOMSUB translated to efficient cv_insert/cv_lookup/cv_delete operations.
However, there is no corresponding support for string-keyed finite maps (:string |-> 'a). This would be useful for applications that naturally use string keys (e.g., symbol tables, environments in language semantics, configuration maps).
Current infrastructure that might help:
from_char/to_charexist (cv_typeScript.sml), so strings (char list) can be representedalist_treeprovides generic sorted association list operations with any ordered key type
Possible approaches:
- Trie/Patricia trie for strings: Most efficient for lookup, but would need new theory and cv translations
- Sorted association lists: Could leverage
alist_treemachinery with string comparison; less efficient than tries but simpler to implement - Encode strings as numbers: Use existing sptree infrastructure with some bijection (like treating strings as base-256 numbers); may be inefficient for long strings
Use case: The vyper-hol project currently uses the string-to-number encoding workaround to work with cv compute. Native string-keyed finite map support would provide a cleaner and potentially more efficient solution.
🤖 Generated with Claude Code