Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Term utilities #1698

Merged
merged 6 commits into from
Jul 26, 2022
Merged

Term utilities #1698

merged 6 commits into from
Jul 26, 2022

Conversation

robdockins
Copy link
Contributor

Some utilities for constructing SAWCore terms.

The term_apply primitive gives a way to combine terms by application, which was missing previously. The congruence_for is a convenience that tries to automatically build the statement of a congruence lemma for a term. This statement can then be proved and applied as a lemma.

@robdockins robdockins marked this pull request as ready for review July 6, 2022 23:04
@robdockins robdockins requested a review from chameco July 6, 2022 23:05
applyTypedTerm sc (TypedTerm _tp t1) (TypedTerm _ t2) =
do trm <- scApply sc t1 t2
ty <- scTypeCheckError sc trm
ct <- scCryptolType sc ty
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC scCryptolType can be a bit weird sometimes due to the lack of an injective mapping from Cryptol types to SAWCore types. I think this might present some unintuitive behavior when (e.g.) the Term applied is a Cryptol function returning a tuple or record. I don't think this is a blocker, but it might be worth mentioning in the docs for term_apply or even just as a comment here.

src/SAWScript/Builtins.hs Show resolved Hide resolved
and automatically builds the statement of an equality congruence
lemma for that function.  The generated statement can then
be passed to `prove_extcore` to get a congruence lemma
that can be used in proofs.
we can now construct integer and natural number terms directly
from SAWCore `Int` values, or `TCNum` values from Cryptol
sizes. In addition, there is now a `term_apply` operation which
will construct application terms.
This can be used to prove lemmas regarding the one-step
unrolling of Cryptol definitions.

Also, prove an "inverse eta rule", which is really just states
that applying equal functions to an argument yields equal results.
@robdockins robdockins added PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run and removed PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run labels Jul 25, 2022
@robdockins robdockins added the PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run label Jul 26, 2022
@robdockins robdockins merged commit 172c0ce into master Jul 26, 2022
@mergify mergify bot deleted the rwd/congruence branch July 26, 2022 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants