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

C++ support for unconstrained ints #1259

Open
robin-aws opened this issue Jun 22, 2021 · 6 comments
Open

C++ support for unconstrained ints #1259

robin-aws opened this issue Jun 22, 2021 · 6 comments
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny lang: c++ Dafny's C++ transpiler and its runtime misc: update Updates to a Dafny dependency part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag

Comments

@robin-aws
Copy link
Member

There is no real standard for "big integers" in C++ AFAIK, so the current compiler only supports constrained subset types like uint32.

This is the main gap blocking running many existing tests in the test suite against the C++ compiler, so it's making it difficult to measure just how complete the C++ compiler is. I'd be happy with even just the incremental step of depending on a big integer library only when running the Dafny test suite.

cc @parno

@robin-aws robin-aws added lang: c++ Dafny's C++ transpiler and its runtime part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag misc: update Updates to a Dafny dependency labels Jun 22, 2021
@parno
Copy link
Collaborator

parno commented Jun 23, 2021

Can you clarify what you have in mind for depending on a big integer library only when running the test suite?

@robin-aws
Copy link
Member Author

I'm just suggesting that if we are nervous about picking a big integer implementation as an official dependency, it might be possible to pick one and make it clear that it's only to unblock more general C++ compiler testing and not production ready. Heck, perhaps we could even embed a really simple, inefficient version in DafnyRuntime.h for that purpose?

@parno
Copy link
Collaborator

parno commented Jun 25, 2021

Ah, I see. Thanks for the clarification. If I find a motivated student, I'll see what we can do :)

@robin-aws
Copy link
Member Author

@parno: just had a thought that we could build a simple, inefficient (but formally-verified!) big integer implementation based on the positional natural numbers library under review here: dafny-lang/libraries#15 That would provide a great default backend for int for all new compilers, as long as there was an easy way to replace it with a much more performant version when available.

@parno
Copy link
Collaborator

parno commented Sep 12, 2021

Interesting, so you're imagining a two-stage compilation process, where we first compile the big-integer library, and then we compile subsequent Dafny programs, assuming the compiled big-integer library is available?

@robin-aws
Copy link
Member Author

Exactly. I'd love for more of the Dafny runtime code for the various target languages to be compiled from Dafny itself, based on a smaller kernel for each language. The implementations of seq<T> in C# and Java, for example, look very similar, and could be implemented instead as a reflective Dafny trait with multiple classes implementing it, so that other runtimes (current and future) could take advantage of that optimization.

@keyboardDrummer keyboardDrummer added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny and removed kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label labels Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny lang: c++ Dafny's C++ transpiler and its runtime misc: update Updates to a Dafny dependency part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag
Projects
None yet
Development

No branches or pull requests

3 participants