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

Improve Python bindings #39

Closed
Sh4rK opened this issue Apr 13, 2015 · 6 comments
Closed

Improve Python bindings #39

Sh4rK opened this issue Apr 13, 2015 · 6 comments
Assignees

Comments

@Sh4rK
Copy link

Sh4rK commented Apr 13, 2015

Hi!
I just played a little with the FP support in the unstable branch (in Python), and while doing so, I noticed some things that I think could be improved:

  • the fpTo* functions that convert FP values to something else return FPRefs instead of what they convert to. This is a problem because some functions and operators don't work correctly this way if for example both of their arguments are fpToIEEEBV(foo)
  • there are fpTo* functions that actually convert from something to FP (like fpToFPUnsigned) and the naming makes this pretty confusing (something like UBVToFp would be much clearer, mirroring fpToUBV)
  • this is mostly the expansion of the previous item; it would be nice if all the conversion functions would be consistently named.

That is all for now, If I notice anything else I'll add it. If I'm wrong about something, please do tell me :)

@wintersteiger
Copy link
Contributor

Thanks for the feedback, it's good to see that people are starting to use floats!

The expression types in fpTo* were indeed wrong, this is now fixed in unstable.

Regarding the naming scheme: "fp" is a general prefix for all floating-point things, avoiding possible clashes with other theories (e.g., fpAdd vs bvAdd vs "+"). The idea was to be mimic the function names defined in the SMT theory FP, in the case of to_fp this is consistent, but indeed a bit unfortunate.

@Sh4rK
Copy link
Author

Sh4rK commented Apr 15, 2015

Thanks for the fix.
As for the conversions, there could be a higher-level api, like the operators are overloaded too for the different types. I'm thinking of methods on the different Ref types, for example foo.toSBV(). What do you think about that?

@wintersteiger
Copy link
Contributor

That sounds like a good idea. Does Python support operator overloading of this kind so that expressions are converted automagically? The conversion functions are global because that's the convention that was used for all the other theories (see e.g., ToReal, ToInt, BV2Int), so I'd rather keep that global too, but if think automatic casting would be a nice feature.

@Sh4rK
Copy link
Author

Sh4rK commented Apr 18, 2015

I'm not talking about "automagical" stuff, just having methods on the types. The global functions wouldn't change anything, this would be just an addition, a (in my opinion) more pleasant way to do these conversions (for all types, not only for FP).

@wintersteiger
Copy link
Contributor

Aha, I see! Are there Python editors that pop up a list of members e.g., like in Visual Studio or Eclipse?

@Sh4rK
Copy link
Author

Sh4rK commented Apr 27, 2015

There's PyCharm which does pretty much everything, but I think there are others too.

@wintersteiger wintersteiger self-assigned this Apr 29, 2015
NikolajBjorner added a commit to NikolajBjorner/z3 that referenced this issue Dec 19, 2016
* local changes

Signed-off-by: Nikolaj Bjorner <[email protected]>

* add bound extraction for variables

Signed-off-by: Nikolaj Bjorner <[email protected]>

* adding fixed equality propagation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* adding fixed equality propagation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* adding fixed equality propagation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* adding bounds propagation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* add eager bounds propagation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* add configuration parameters for LP solver

Signed-off-by: Nikolaj Bjorner <[email protected]>

* remove wrong assert

Signed-off-by: Nikolaj Bjorner <[email protected]>

* fix wrong assert

Signed-off-by: Nikolaj Bjorner <[email protected]>

* add timeout, signals to interface

Signed-off-by: Nikolaj Bjorner <[email protected]>

* add stats

Signed-off-by: Nikolaj Bjorner <[email protected]>

* getting rid of typename

Signed-off-by: Nikolaj Bjorner <[email protected]>

* outline compound bound propagation functionality

Signed-off-by: Nikolaj Bjorner <[email protected]>

* disable repropagation on pop

Signed-off-by: Nikolaj Bjorner <[email protected]>

* add compound bound propagation code, remains disabled

Signed-off-by: Nikolaj Bjorner <[email protected]>

* stronger ad-hoc bounds propagation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* stronger ad-hoc bounds propagation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* merge

Signed-off-by: Nikolaj Bjorner <[email protected]>

* adding validation

Signed-off-by: Nikolaj Bjorner <[email protected]>

* check assignments and conflicts

Signed-off-by: Nikolaj Bjorner <[email protected]>

* check assignments and conflicts

Signed-off-by: Nikolaj Bjorner <[email protected]>

* relax assertion check to take care of cancellation

Signed-off-by: Nikolaj Bjorner <[email protected]>
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

No branches or pull requests

2 participants