Conversation
I tried to do this as fast as I could, not trying to clean anything up after the transition, and just get the replacement done as quickly as possible. (And it still took me about 3 hours.) The main work, of course, is replacing all the raw string manipulation (mainly `format!` calls) with S-expression builder calls.
There is a lot of typing to be done here!
| } | ||
|
|
||
| let assumption_str = format!("(and {})", assumptions.join(" ")); | ||
| let assumption_conjunction = solver.and_many(assumptions); |
I'm trying to get to a place where the crate compiles, even though the encoded ops don't work at all.
|
As we discussed synchronously today, I've mucked things up so that our crate builds. That meant temporarily:
It works! I haven't tried running any tests, because I don't feel qualified to know which tests should be runnable in this semi-broken state. (I could probably figure that out, but I'm going to move on to trying to rewrite the encoded ops stuff instead of spending time on that.) |
Now using the builder to construct contexts. And there's a cool new `numeral` helper for building number literals of all kinds!
| } | ||
|
|
||
| pub fn vir_to_rsmt2_constant_ty(&self, ty: &Type) -> String { | ||
| pub fn vir_to_rsmt2_constant_ty(&self, ty: &Type) -> SExpr { |
There was a problem hiding this comment.
Thanks; addressed!
Apparently, `findall` returns a list of strings (not tuples) when there is only one subgroup.
To match clz*.
|
Other important TODO before this becomes the default: |
|
^ Doing a pass to add |
| } | ||
| Type::Int => i.to_string(), | ||
| Type::Int => self.smt.numeral(i), | ||
| Type::Bool => { |
There was a problem hiding this comment.
Aha, I think this is causing the failing tests! Will fix.
There was a problem hiding this comment.
Oh Lordy, that is obviously wrong!! Nice catch!
Based on @mpardeshi's advice, this is just a copy of `rev32` but with an extra extract at the top. I hope this works.
That's the last one, hopefully!
|
Ok, I think the |
|
|
||
| (assert (= y1_{id} (bvlshr x2_{id} #x0001))) | ||
| (assert (ite (not (= y1_{id} (_ bv0 16))) (= ret5_{id} ret4_{id}) (= ret5_{id} (bvadd ret4_{id} (_ bv1 16))))) | ||
| (assert (ite (not (= y1_{id} (_ bv0 16))) (= x1_{id} y1_{id}) (= x1_{id} x2_{id}))) |
There was a problem hiding this comment.
after this line, try adding
; last round
(declare-fun ret6_{id} () (_ BitVec 16))
(assert (ite (not (= x1_{id} (_ bv0 16))) (= ret6_{id} ret5_{id}) (= ret6_{id} (bvadd ret5_{id} (_ bv1 16)))))
and then regenerating?
There was a problem hiding this comment.
Aha, good catch! Trying this now
|
|
||
| (assert (= y1_{id} (bvlshr x2_{id} #x00000001))) | ||
| (assert (ite (not (= y1_{id} (_ bv0 32))) (= ret5_{id} ret4_{id}) (= ret5_{id} (bvadd ret4_{id} (_ bv1 32))))) | ||
| (assert (ite (not (= y1_{id} (_ bv0 32))) (= x1_{id} y1_{id}) (= x1_{id} x2_{id}))) |
There was a problem hiding this comment.
after this line try adding:
; last round
(declare-fun ret6_{id} () (_ BitVec 32))
(assert (ite (not (= x1_{id} (_ bv0 32))) (= ret6_{id} ret5_{id}) (= ret6_{id} (bvadd ret5_{id} (_ bv1 32)))))
and then regenerating?
|
|
||
| (assert (= y1_{id} (bvlshr x2_{id} #x0000000000000001))) | ||
| (assert (ite (not (= y1_{id} (_ bv0 64))) (= ret6_{id} ret5_{id}) (= ret6_{id} (bvadd ret5_{id} (_ bv1 64))))) | ||
| (assert (ite (not (= y1_{id} (_ bv0 64))) (= x1_{id} y1_{id}) (= x1_{id} x2_{id}))) |
There was a problem hiding this comment.
after this line try adding
; last round
(declare-fun ret7_{id} () (_ BitVec 64))
(assert (ite (not (= x1_{id} (_ bv0 64))) (= ret7_{id} ret6_{id}) (= ret7_{id} (bvadd ret6_{id} (_ bv1 64)))))
and then regenerating?
* implement `wasi-filesystem::readdir` and related functions This adds a `directory_list` test and provides the required host implementation. I've also added a file length check to the `file_read` test, just to cover a bit more of the API. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix memory corruption in `fd_readdir` polyfill We were copying `name.len() * 256` bytes instead of just `name.len()` bytes, which was overwriting other parts of `State` and causing untold havoc. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * check type of entry in `Table::delete` Signed-off-by: Joel Dice <joel.dice@fermyon.com> Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* implement `wasi-filesystem::readdir` and related functions This adds a `directory_list` test and provides the required host implementation. I've also added a file length check to the `file_read` test, just to cover a bit more of the API. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix memory corruption in `fd_readdir` polyfill We were copying `name.len() * 256` bytes instead of just `name.len()` bytes, which was overwriting other parts of `State` and causing untold havoc. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * check type of entry in `Table::delete` Signed-off-by: Joel Dice <joel.dice@fermyon.com> Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Add support for fetching models containing unspecified values. With the addition of declared sorts in bytecodealliance#141, this broke the code that parses constants from SMT models. The backend solvers differ on how they implement this. This PR deals with the CVC5 format only, in which unspecified values are represented as something like `(as @Unspecified_0 Unspecified)`. Updates avanhatt#45
Since the addition of enum type instantiations bytecodealliance#167 the counter-example printing is bloated with a lot of enum variants. These convey little information if they are constants (unit enums). This PR skips them in printing. Updates avanhatt#45
Since the addition of enum type instantiations bytecodealliance#167 the counter-example printing is bloated with a lot of enum variants. These convey little information if they are constants (unit enums). This PR skips them in printing. Updates avanhatt#45
As discussed on Slack, here's a first attempt to move from rsmt2 to easy-smt. Here are the high-level takeaways:
SExprtype.I got everything in
solver.rsconverted, including all the SMT generation and the interaction with the solver. This took me about 3 hours to move everything over—almost all of that was replacing calls toformat!with explicit S-expression construction calls. It's not exactly fun, but it's not exactly hard either.There is more drudgery ahead: the files in
encoded_opshave a lot of raw SMT strings in them and will be a lot of work to convert.There is a chance I have made a terrible mistake and I should not have tried to do all this annoying conversion at all: instead, we could try to parse the strings we're already generating and turn them into
SExprs. Or we could attempt to hackeasy-smtto allow us to shove strings directly into the solver, which it doesn't currently allow (you have to provide anSExpr). Both of those seem very reasonable in retrospect, but now I wonder if either of them would be simpler than just forging ahead and finishing the conversion. I'd be interested in others' opinions, given what the code looks like insolver.rsafter the conversion.