Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Ty.RoundFpToDynBv Bug #18

Open
jkwoods opened this issue Dec 8, 2020 · 5 comments
Open

Ty.RoundFpToDynBv Bug #18

jkwoods opened this issue Dec 8, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@jkwoods
Copy link
Collaborator

jkwoods commented Dec 8, 2020

Code that casts from a double/float, like this:

int main(void) {
   int r = (int) 4.2;
   return(r);
}

is "checked" correctly, and will pass tests, but will not compile to constraints.

Error here: "Cannot translate RoundFpToDynBv <expression...>'

@jkwoods
Copy link
Collaborator Author

jkwoods commented Dec 28, 2020

I fixed this by implementing RoundFpToDynBv in ToPf.hs. I don't know if you guys want my fix or have a plan in mind for that stuff in the future?

@jkwoods jkwoods added the bug Something isn't working label Dec 28, 2020
@alex-ozdemir
Copy link
Collaborator

Interesting. Certainly the code would go in ToPf.hs.

However, I have to ask first: it seems that before one embeds RoundFpToDynBv in R1CS, one must be able to embed floating point terms in R1CS. Have you already done that? If so, that's really cool and I'd love to hear more about it.

@jkwoods
Copy link
Collaborator Author

jkwoods commented Dec 29, 2020

I don't have floating points in the general case. Basically just Fp64Lits, Fp32Lits, RoundFpToDynBv - just what you would need for casting doubles/floats to the fixed point implementation. (So the user can write fixed point terms as decimals/"floating points".) I used the asBits method from TySMT.

I was under the impression we wanted to make fixed point work first/instead. This just allows the user to write fixed point stuff in a natural way. I'd be willing to do the rest of floating point at some point.

@alex-ozdemir
Copy link
Collaborator

alex-ozdemir commented Dec 29, 2020

I was under the impression we wanted to make fixed point work first/instead. This just allows the user to write fixed point stuff in a natural way. I'd be willing to do the rest of floating point at some point.

This is certainly the right approach!

Basically just Fp64Lits, Fp32Lits, RoundFpToDynBv - just what you would need for casting doubles/floats to the fixed point implementation.

I see. Okay, now I think I understand better.

I fixed this by implementing RoundFpToDynBv in ToPf.hs. I don't know if you guys want my fix or have a plan in mind for that stuff in the future?

I think the right strategy here would be to merge the entire fix-point implementation (when it's ready), rather than merging the changes one at a time. I'm happy to talk about doing that whenever you feel the implementation is ready.

@jkwoods
Copy link
Collaborator Author

jkwoods commented Dec 29, 2020

Ok, cool. Ready very soon. I think it will need some revamping in line with your most recent pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants