Skip to content

Conversation

@brianhuffman
Copy link
Contributor

@brianhuffman brianhuffman commented Sep 27, 2025

This PR removes the TermModel backend from the SAWCore simulator. This was a backend that used the SAWCore Term type itself as the value type, implementing a sort of partial evaluator for SAWCore terms.

TermModel primarily existed to support the MRSolver tactic, which has now been removed (#2576).
As it turns out, a lot of extra plumbing within the SAWCore simulator was only there to support TermModel, so the removal enables much simplification of SAWCore code. In particular, removing the extra type information from the simulator unblocks further reforms to the recursor implementation (which will be a follow-on to #2429 to solve #2358).

Removing TermModel necessitated the removal of the experimental SAWScript extract_uninterp command, which was not used in any of our regression tests or examples. Commands normalize_term_opaque (also unused in our tests/examples) and goal_normalize were previously implemented using TermModel; these are still in place but are now implemented instead using scUnfoldConstantSet and scTypeCheckWHNF.

@brianhuffman brianhuffman force-pushed the bh/no-term-model branch 2 times, most recently from 7d0218f to ffac933 Compare September 28, 2025 14:04
@brianhuffman brianhuffman marked this pull request as ready for review September 28, 2025 18:19
@brianhuffman brianhuffman requested review from RyanGlScott and sauclovian-g and removed request for RyanGlScott September 29, 2025 15:31
, "for the function."
]

, prim "extract_uninterp" "[String] -> [String] -> Term -> TopLevel (Term, [(String,[(Term, Term)])])"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please note this function's removal in the SAW changelog.

Comment on lines 573 to +584
normalize_term_opaque :: [Text] -> TypedTerm -> TopLevel TypedTerm
normalize_term_opaque opaque tt =
do sc <- getSharedContext
modmap <- io (scGetModuleMap sc)
idxs <- mconcat <$> mapM (resolveName sc) opaque
let opaqueSet = Set.fromList idxs
tm' <- io (TM.normalizeSharedTerm sc modmap mempty mempty opaqueSet (ttTerm tt))
tm' <- io (scTypeCheckWHNF sc =<< scUnfoldConstantSet sc False opaqueSet (ttTerm tt))
pure tt{ ttTerm = tm' }

goal_normalize :: [Text] -> ProofScript ()
goal_normalize opaque =
execTactic $ tacticChange $ \goal ->
do sc <- getSharedContext
idxs <- mconcat <$> mapM (resolveName sc) opaque
modmap <- io (scGetModuleMap sc)
let opaqueSet = Set.fromList idxs
sqt' <- io $ traverseSequentWithFocus (normalizeProp sc modmap opaqueSet) (goalSequent goal)
sqt' <- io $ traverseSequentWithFocus (normalizeProp sc opaqueSet) (goalSequent goal)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you expect there to be any subtle differences in behavior in the normalize_term_opaque/goal_normalize functions as a result of these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there will be differences. The new implementation will (by definition) always return a normalized term that is convertible (according to the type checker) with the input term. This was not the case with normalizeSharedTerm (see #2552).

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. To be on the safe side, it would be worth mentioning this in the changelog as well.

@brianhuffman brianhuffman merged commit 3aae335 into master Sep 29, 2025
14 checks passed
@brianhuffman brianhuffman deleted the bh/no-term-model branch September 29, 2025 17:32
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.

3 participants