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

Cryptol translation is broken for terms using Arith and Cmp operations #178

Closed
brianhuffman opened this issue Mar 3, 2017 · 1 comment
Closed
Assignees

Comments

@brianhuffman
Copy link
Contributor

In the saw-script REPL, simple prove commands are now failing:

prove z3 {{ \(x:[8]) -> x == x }}
prove: 1 unsolved subgoal(s)
Invalid: [x = 255, _ = 0]
sawscript> prove z3 {{ \(x:[8]) -> x != x + 1 }}
"prove" (<stdin>:1:1):
"z3" (<stdin>:1:7):
valRecordSelect: Not a record value: ("add",<<bitvector>>)

It turns out that terms involving Arith and Cmp are now being translated incorrectly, as we can see:

sawscript> print_term (rewrite (cryptol_ss()) {{ \(x:[8]) -> x == x }})
let { x0 = Prelude.Vec 8 Prelude.Bool;
    }
 in \(x::x0) -> Prelude.eq x0 x
sawscript> print_term (rewrite (cryptol_ss()) {{ \(x:[8]) -> x + 1 }})
\(x::Prelude.Vec 8 Prelude.Bool) ->
  x.add (Prelude.bvNat 8 1)

The current translator maps Cryptol props Arith and Cmp to dictionaries (i.e. records of functions) in SAW. (Other props like "m >= n" that have no computational content are erased.) This worked before, but since the merge of the wip/solver branch of Cryptol, type substitution automatically rewrites e.g. "Cmp [8]" to "True", so the translator doesn't know to create the dictionaries it needs.

@brianhuffman brianhuffman self-assigned this Mar 3, 2017
@brianhuffman
Copy link
Contributor Author

I have an idea for a fix that only involves the cryptol-verifier package (no modifications to Cryptol will be required). Basically, we will have a single dictionary type that includes all of the Arith, Cmp, and logical operations; we will construct and apply an appropriate dictionary on every type application.

brianhuffman pushed a commit to GaloisInc/cryptol-verifier that referenced this issue Mar 6, 2017
…pes.

The syntactic type representation `KType` and the dependent function
`ty` have been removed; polymorphic Cryptol values now take both a type
argument and a separate dictionary argument.

This fixes most of GaloisInc/saw-script#178.
brianhuffman pushed a commit that referenced this issue Apr 26, 2021
add scTypeCheckComplete, scCheckSubtype
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

1 participant