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

sawcore imports don't work correctly #1112

Open
weaversa opened this issue Mar 6, 2021 · 2 comments
Open

sawcore imports don't work correctly #1112

weaversa opened this issue Mar 6, 2021 · 2 comments
Labels
subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem type: bug Issues reporting bugs or unexpected/unwanted behavior
Milestone

Comments

@weaversa
Copy link
Contributor

weaversa commented Mar 6, 2021

This may be a bit related to #1044.

Basically, saw seems to know that symbol names exist in imported saw core files, but it doesn't act on them. For example:

f : [32] -> [32]
f x = g x + 1

g : [32] -> [32]
g x = 0
import "unint.cry";

print_term (unfold_term ["f"] {{ \x -> f x > 0 }});

r <- prove (w4_unint_yices ["g"]) {{ \x -> f x > 0 }};
print r;

write_core "unint.core" {{ \x -> f x > 0 }};

prop <- read_core "unint.core";

print_term (unfold_term ["g"] {{ \x -> prop x }});

r <- prove (w4_unint_yices ["g"]) {{ \x -> prop x }};
print r;
$ saw $(pwd)/unint.saw
[15:35:38.479] Loading file "unint.saw"
[15:35:38.513] let { x@1 = Prelude.Vec 32 Prelude.Bool
      x@2 = Cryptol.TCNum 32
      x@3 = Cryptol.PLiteralSeqBool x@2
    }
 in \(x : x@1) ->
      Cryptol.ecGt x@1 (Cryptol.PCmpSeqBool x@2)
	((\(x' : x@1) ->
            Cryptol.ecPlus x@1 (Cryptol.PRingSeqBool x@2)
              (cryptol:/Main/g x')
              (Cryptol.ecNumber (Cryptol.TCNum 1) x@1 x@3))
           x)
	(Cryptol.ecNumber (Cryptol.TCNum 0) x@1 x@3)
Calling Yices to check sat
Running check sat
[15:35:38.581] prove: 1 unsolved subgoal(s)
[15:35:38.581] Invalid: [x = 0]
[15:35:38.614] let { x@1 = Prelude.Vec 32 Prelude.Bool
      x@2 = Cryptol.TCNum 32
    }
 in \(x : x@1) ->
      (\(x' : x@1) ->
         Cryptol.ecGt x@1 (Cryptol.PCmpSeqBool x@2) (cryptol:/Main/f x')
           (Cryptol.ecNumber (Cryptol.TCNum 0) x@1
              (Cryptol.PLiteralSeqBool x@2)))
        x
Calling Yices to check sat
Running check sat
[15:35:38.649] Valid

Both of these calls to yices should produce a counter example because we uninterpreted g in both. We know saw knows that g exists because saw would otherwise complain saying "Could not resolve name: g", but this does not happen. However, saw does not uninterpret g, nor does it unfold f when we try to print the term.

@atomb atomb self-assigned this Mar 12, 2021
@brianhuffman brianhuffman added the subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem label Apr 29, 2021
@brianhuffman
Copy link
Contributor

I suspect that the naming environment is getting screwed up when we import an external saw-core file. I don't quite understand what's going on here yet, but something is definitely wrong under the surface. We should probably add some code (at least temporarily) to check and enforce the intended invariants on our naming environment.

@brianhuffman
Copy link
Contributor

I think #1257 is also related; in that thread I mentioned some design questions about how should we handle re-import of external saw-core files that contain defined constants.

@atomb atomb removed their assignment Oct 19, 2021
@sauclovian-g sauclovian-g added the type: bug Issues reporting bugs or unexpected/unwanted behavior label Oct 30, 2024
@sauclovian-g sauclovian-g added this to the Someday milestone Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

No branches or pull requests

4 participants