Skip to content

Conversation

brianhuffman
Copy link
Contributor

@brianhuffman brianhuffman commented Oct 2, 2025

This PR removes de Bruijn indices from SAWCore, replacing them with named variables in all SAWCore binding constructs. Fixes #2328.

@brianhuffman brianhuffman force-pushed the bh/no-de-bruijn branch 4 times, most recently from fa53dc4 to aa1c14c Compare October 3, 2025 19:19
@brianhuffman
Copy link
Contributor Author

Apparently there is just a single failure left in the integration test suite: test_solver_cache. The function mkSolverCacheKey in SAWCentral.SolverCache is supposed to compute a hash from a SAWCore term in such a way that any two alpha-equivalent terms will get the same hash. The current method of stripping binder names from a string generated by SAWCore.ExternalFormat worked for fully-hash-consed de Bruijn terms, but won't work now. We'll need to come up with a different approach.

@brianhuffman brianhuffman marked this pull request as ready for review October 6, 2025 16:16
@brianhuffman brianhuffman force-pushed the bh/no-de-bruijn branch 3 times, most recently from 1cec68d to 13b8e59 Compare October 6, 2025 16:51
As a result, many other functions now have pure types,
including ones in SAWCore.Rewriter and SAWCore.Term.CtxTerm.
Copy link
Contributor

@sauclovian-g sauclovian-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable although I'm not sure I'd notice if there were problems...

Lambda _ t1 _ | not doBinders -> [t1]
Pi _ t1 _ | not doBinders -> [t1]
Constant{} -> []
Variable{} -> []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some initial confusion I'm on board with this change, but I don't think the commit message accurately describes it. I think it actually avoids printing let bindings for subterms that are never printed, such as Variable types, which I believe is what was happening in test2049. Do you have a different understanding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoiding the let on terms like \(x : t) -> x was the reason why I created the commit in the first place, and it's what the commit message is based on. I also included the change to test2049 output because I noticed the test failure; I actually don't know why a let was printed on that one in the first place, because by my count there should only have been one occurrence of the type there.

With the switch to named variables, the SolverCache finger-
print computed from the external format file no longer
respects alpha-equivalence. It should still register cache
hits if the same SAW proof script is run more than once.
@brianhuffman
Copy link
Contributor Author

To fix the test_solver_cache failure, I pushed 2f3d4d2 which changes the expected cache stats. This is not a good long-term solution, so I opened #2681 to remind us to fix the problem properly at some point.

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.

Bound variables in saw-core: Remove de Bruijn indices in favor of names
4 participants