-
Notifications
You must be signed in to change notification settings - Fork 28
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
[CN] Pure term (partial) evaluation #447
base: master
Are you sure you want to change the base?
Conversation
It would be useful if you could explain why as well as what. I'm off on holiday for until 12th, so I'll let Christopher handle this. |
backend/cn/lib/eval.ml
Outdated
let eval_num_binop = eval_num_binop eval_aux bt here in | ||
match t_ with | ||
| Const _ -> return it | ||
| Sym x -> Result.error (Sym.pp_string x ^ " is free") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to be able to use eval
to simplify quantified constraints or assertions, then it can't crash on free variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't crash, it returns Error
, which partial_eval
accounts for (and is what would be used for simplification).
9c55130
to
27590d7
Compare
27590d7
to
9733f6f
Compare
9733f6f
to
f872a72
Compare
(match it' with | ||
| IT (Const (Bits ((sgn, bits), n)), bt, _) -> | ||
let open Int64 in | ||
let reverse_bits (n : Z.t) : Z.t = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this does the right thing, at least for bitvector sizes larger than 64?
Aside from the inline comments, three general points:
|
Yes, it won't be evaluated. The goal here is just to do evaluation, which should be fairly simple/clear. For a term simplifier, you'd just call
The lazy evaluation is the one I plan to use, and shouldn't diverge. Partial evaluation could, which is why we special-case it to fully evaluate arguments before application. It should also simplify more than the strict version.
I removed the QCheck/OUnit tests I used to check them, to simplify the PR, but I can add them back and see if I missed any operations.
This is what the QCheck/OUnit tests were doing, and then seeing if |
Tests are good, but really the question is what the correctness argument is wrt the SMT mapping. For instance, in the SMT mapping CN Div turns into either an SMT
... Given the question about the relationship between the SMT semantics and the partial evaluator's implementation, would the evaluator be fast enough if we replaced its bitvector logic with a call into the SMT solver's evaluator (i.e. whenever a unary or binary operation is applied to a bitvector constant, simply asking the SMT solver to evaluate it for us)? |
Will eventually be pulled out to be more generally usable, see rems-project#447
Will eventually be pulled out to be more generally usable, see #447
Evaluates terms (
IndexTerms.t
). Can be used for term simplification.It is needed to evaluate terms when generating test cases in OCaml-land.
Potential issues
List.combine
)Other