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

Laziness in Cryptol missing in SAW #284

Open
weaversa opened this issue May 22, 2018 · 3 comments
Open

Laziness in Cryptol missing in SAW #284

weaversa opened this issue May 22, 2018 · 3 comments

Comments

@weaversa
Copy link
Contributor

The following works fine in cryptol (d67f6de), but hangs in saw (5ef5ca0)

sawscript> let {{ [a, b] = take ([0..]:[_][32]) }}
sawscript> print {{ a }}
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^Csaw: too many pending signals
Cryptol> let [a, b] = take ([0..]:[_][32])
Cryptol> a
0x00000000
@brianhuffman
Copy link
Contributor

The problem here is the data structure that saw uses to represent finite sequences. You're making a sequence with type [4294967296][32], and I believe saw uses ordinary Haskell arrays or vectors for all finite vector sizes. Allocating and initializing one with 2^32 elements takes a long time. Here's another example that will produce the same result:

sawscript> print {{ (zero : [4294967296][32]) @ 0 }}

Cryptol has some special clever representations for sequences that are really large but still finite. We should probably adapt saw to use the same representation.

@jpziegler
Copy link

For completeness I'll add that, at least in the case of the example above, you can use ... to get around this bug. Using ... generates an infinite sequence, so SAW has no choice but to be lazy!

sawscript> let {{ [a,b] = take ([0...]:[_][32]) }}
sawscript> print {{ a }}
0

I will say that the .. versus ... question continues to confuse Cryptol users both new and old. Might not be anything to do to resolve that, but there it is. (I personally like having both.)

@atomb atomb added this to the 1.0 milestone Apr 30, 2019
@atomb atomb modified the milestones: 0.5, 0.6 Apr 9, 2020
@atomb atomb modified the milestones: 0.6, 0.7 Aug 13, 2020
@atomb atomb removed this from the 0.7 milestone Oct 16, 2020
@brianhuffman
Copy link
Contributor

We are going to try to rework the saw-core interpreter to reuse more code from the Cryptol interpreter. Problems like this should be taken care of as a side effect of that effort. (See e.g. GaloisInc/cryptol#651)

@atomb atomb added the tech-debt label Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants