Skip to content

Add support for real, bv8, bv16, bv32, bv64#8

Merged
atomb merged 3 commits into
mainfrom
real-bv-types
Jul 29, 2025
Merged

Add support for real, bv8, bv16, bv32, bv64#8
atomb merged 3 commits into
mainfrom
real-bv-types

Conversation

@atomb
Copy link
Copy Markdown
Contributor

@atomb atomb commented Jul 25, 2025

A fully-parameterized bit vector type doesn't work well at all stages of the pipeline at the moment, but could potentially in the future. The Lambda dialect, at least, has a .bitvec n constructor in LMonoTy, but most of the rest of the pipeline treats each bit vector type entirely independently.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@shigoel
Copy link
Copy Markdown
Contributor

shigoel commented Jul 27, 2025

LGTM, thanks!

I'm curious about the scope of a possible full parameterization of the bitvec type. Does this refer to DDM support to allow the use of a bitvec n type for a specific n, obviating the need to pre-define specific instantiations like bv8, bv16, etc.? Or does this involve support for type families that'd allow defining functions that are parametric in the bitvector width (e.g., add : bitvec n -> bitvec n -> bitvec n instead of bv8.add : bv8 -> bv8 -> bv8)?

I'm guessing it's the former. The latter would require non-trivial changes to Lambda's type system, which -- like vanilla OCaml -- doesn't support type families.

{ name := "Bv8.Add",
inputs := [("x", mty[bv8]), ("y", mty[bv8])],
output := mty[bv8],
denote := none },
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.

Perhaps out of scope for this PR, but would be good to add denotation functions for bitvecs to allow constant folding/concrete evaluation.

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.

Yeah, I definitely want to add those, but I figured I'd keep the first PR simple.

| _ => none

/--
If `e` is an `LExpr` real, then denote that into a Lean `String`.
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.

Nit: worth noting this denotation into a String is intentional because we don't import reals from Mathlib (yet?).

Copy link
Copy Markdown
Contributor Author

@atomb atomb Jul 28, 2025

Choose a reason for hiding this comment

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

Yep, exactly. I suspect we should support reals more thoroughly, but I think we should have a design discussion about exactly how. For now, strings allow us to send constants through the verification pipeline.

@atomb
Copy link
Copy Markdown
Contributor Author

atomb commented Jul 28, 2025

LGTM, thanks!

I'm curious about the scope of a possible full parameterization of the bitvec type. Does this refer to DDM support to allow the use of a bitvec n type for a specific n, obviating the need to pre-define specific instantiations like bv8, bv16, etc.? Or does this involve support for type families that'd allow defining functions that are parametric in the bitvector width (e.g., add : bitvec n -> bitvec n -> bitvec n instead of bv8.add : bv8 -> bv8 -> bv8)?

I'm guessing it's the former. The latter would require non-trivial changes to Lambda's type system, which -- like vanilla OCaml -- doesn't support type families.

Yeah, I mean the former primarily. The latter would be cool, but I expect more work than it's worth.

atomb added 3 commits July 28, 2025 11:07
A fully-parameterized bit vector type doesn't work well at all stages of
the pipeline at the moment, but could potentially in the future. The
Lambda dialect, at least, has a `.bitvec n` constructor in `LMonoTy`,
but most of the rest of the pipeline treats each bit vector type
entirely independently.
Also make sure other examples are included in the build.
@atomb atomb added this pull request to the merge queue Jul 29, 2025
Merged via the queue into main with commit ae30af7 Jul 29, 2025
6 checks passed
@atomb atomb deleted the real-bv-types branch July 29, 2025 15:45
kondylidou added a commit to kondylidou/Strata that referenced this pull request May 19, 2026
…nat support) status

Gap strata-org#6: mark BV→int (`e as_int`) as implemented; note int→BV and
centralized coercion pass as remaining work.
Gap strata-org#8: mark `type nat := int` synonym + auto non-negativity axioms
as partially implemented; document the mixed-type datatype limitation
and point to nat_axiom_discussion.lean for design alternatives.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
kondylidou added a commit to kondylidou/Strata that referenced this pull request May 19, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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