Created
September 14, 2022 19:02
-
-
Save samth/de1f79321c029838d63e4d6a914939fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang rosette/safe | |
(require rosette/lib/synthax) ; Require the sketching library. | |
(define-grammar (bsl-nums x) ; Grammar of int32 expressions over two inputs: | |
[expr | |
(choose x (?? integer?) #;(/ (?? integer?) (?? integer?)) ; <expr> := x | y | <32-bit integer constant> | | |
((bop) (expr) (expr)) ; (<bop> <expr> <expr>) | | |
((uop) (expr)))] ; (<uop> <expr>) | |
[bop | |
(choose + - * /)] ; bvlshr | bvashr | |
[uop | |
(choose -)]) ; <uop> := bvneg | bvnot | |
(define (bsl-sketch lo) | |
(bsl-nums lo #:depth 2)) | |
(define-symbolic l h integer?) | |
(define (check-ctok impl l) | |
(assert (= (impl 0) 273)) | |
(assert (= (impl 100) 373))) | |
(define (check-ftoc impl) | |
(assert (= (impl 32) 0)) | |
(assert (= (impl -40) -40))) | |
(define sol | |
(synthesize | |
#:forall (list l) | |
#:guarantee (check-ftoc bsl-sketch))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment