Skip to content

Conversation

@xrchz
Copy link
Member

@xrchz xrchz commented Jan 10, 2026

This is an addition to #1764 that makes more significant design decisions on how to handle the fact that compsets, even with a functional computeLib API, are still mutable. See discussion on that PR.

xrchz and others added 6 commits January 10, 2026 11:40
Compsets now support a "sealed" flag that prevents mutation of existing
constant entries while still allowing new constants to be added. This
enables base compsets (like bool_compset) to be safely shared as values
rather than generated fresh via unit -> compset functions.

Key changes:
- Add sealed flag to compset datatype
- seal: marks a compset as sealed
- copy: creates an unsealed copy with fresh refs for all constants
- assoc_clause raises an exception when trying to add rules for an
  existing constant in a sealed compset

Most operations that produce a new compset (add_thms, add_conv, etc.)
produce an unsealed compset. The seal operation protects against
accidental pollution of shared base compsets. When you need to extend
rules for existing constants in a sealed compset, use copy first to get
a modifiable compset.

Selftests added to verify:
- Sealed compsets reject additions to existing constants
- Sealed compsets accept additions for new constants
- Copy creates a modifiable compset with same evaluation behavior
- bool_compset is properly sealed

Co-Authored-By: Claude <[email protected]>
The previous code was too aggressive, preventing merely reading existing
constants. And some of the previous tests were using the wrong constant.

Co-Authored-By: Claude <[email protected]>
@xrchz xrchz changed the base branch from develop to fcompute January 10, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants