Skip to content

saw-script: Remove non-working command prove_by_bv_induction.#3159

Merged
brianhuffman merged 5 commits intomasterfrom
bh/no-bv-induction
May 5, 2026
Merged

saw-script: Remove non-working command prove_by_bv_induction.#3159
brianhuffman merged 5 commits intomasterfrom
bh/no-bv-induction

Conversation

@brianhuffman
Copy link
Copy Markdown
Contributor

Currently any non-trivial use of prove_by_induction fails with an internal SAWCore type error.

Instead of prove_by_bv_induction, tactic goal_apply should be used with a suitable induction rule.

Fixes #2770.

@brianhuffman
Copy link
Copy Markdown
Contributor Author

I would probably be good to add a regression test that proves a goal using some kind of induction rule over a bit vector type. The strong induction principle that was formerly hard-coded into prove_by_bv_induction does not work well, because its universally-quantified inductive hypothesis is not supported by any of our prover backends, nor can our rewriter make use of it. Something with 0 and n+1 cases should work well.

@sauclovian-g
Copy link
Copy Markdown
Contributor

Yeah, it would be good to have a test. We should probably have some kind of induction tactic that manages the proof state nicely... and I'm not sure we should close #2770 without one... but having a working example is an important step on the way there.

(I am, perhaps naively, assuming there's some complication such that it made sense to add prove_by_bv_induction in the first place; but maybe not...)

@brianhuffman brianhuffman marked this pull request as draft April 15, 2026 23:04
@brianhuffman
Copy link
Copy Markdown
Contributor Author

I'm converting to "draft" status until I come up with a good induction rule and example proof that uses it.

Currently any non-trivial use of `prove_by_induction` fails
with an internal SAWCore type error.

Instead of `prove_by_bv_induction`, tactic `goal_apply`
should be used with a suitable induction rule.

Fixes #2770.
@brianhuffman brianhuffman force-pushed the bh/no-bv-induction branch from d99ea40 to 22a94af Compare May 4, 2026 21:16
@brianhuffman
Copy link
Copy Markdown
Contributor Author

I added a regression test in 22a94af that defines a bit-vector induction principle in SAWCore and proves some non-trivial properties using it: I show that two different functions defined by primitive recursion are equivalent to closed-form non-recursive definitions.

I think this shows pretty convincingly that goal_apply is fit for purpose and that we don't need prove_by_bv_induction.

@brianhuffman brianhuffman marked this pull request as ready for review May 4, 2026 21:21
Comment thread intTests/test_bv_induction/test.saw Outdated
Comment thread intTests/test_bv_induction/test.saw Outdated
Comment on lines +4 to +7
axiom bvNat_Succ :
(n i : Nat) ->
Eq (Vec n Bool) (bvNat n (Succ i)) (bvAdd n (bvNat n i) (bvNat n 1));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems unfortunate that this is necessary... but on review it also seems like it just belongs in Prelude.sawcore. Any reason not to move it there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should probably figure out a minimal set of defining axioms for primitives like bvAdd and put those in the prelude.

An axiom like the following would let us prove bvNat_Succ and also the existing axioms bvAddZeroL and bvAddZeroR:

axiom bvNat_addNat:
  Eq (Vec n Bool)
  (bvNat n (addNat x y))
  (bvAdd.n (bvNat n x) (bvNat n y);

axiom bvAddZeroL : (n : Nat) -> (x : Vec n Bool) -> Eq (Vec n Bool) (bvAdd n (bvNat n 0) x) x;
axiom bvAddZeroR : (n : Nat) -> (x : Vec n Bool) -> Eq (Vec n Bool) (bvAdd n x (bvNat n 0)) x;

So maybe I'll update Prelude.sawcore accordingly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changing the set of axioms in the Prelude means figuring out how to map the new axioms into Rocq for the Rocq back-end, and that seems like a bit of mission creep for this PR. I'll open a ticket to remind us to move stuff into Prelude.sawcore later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I opened issue #3222 to track the SAWCore prelude updates.

brianhuffman and others added 3 commits May 4, 2026 17:05
Co-authored-by: David Holland <120141909+sauclovian-g@users.noreply.github.com>
Co-authored-by: David Holland <120141909+sauclovian-g@users.noreply.github.com>
The number of experimental SAW commands has changed.
@brianhuffman
Copy link
Copy Markdown
Contributor Author

The only test failure is the infamous test_timeout, so I'm going to go ahead and merge anyway.

@brianhuffman brianhuffman merged commit e8f7bdf into master May 5, 2026
36 of 37 checks passed
@brianhuffman brianhuffman deleted the bh/no-bv-induction branch May 5, 2026 17:18
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.

Replace prove_by_bv_induction with something simpler and more general

2 participants