+
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions specification/wasm-3.0/0.2-aux.num.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def $min(nat, nat) : nat
def $min(i, j) = i -- if $(i <= j)
def $min(i, j) = j -- otherwise

def $max(nat, nat) : nat
def $max(i, j) = i -- if $(i >= j)
def $max(i, j) = j -- otherwise

def $sum(nat*) : nat hint(show (+) %) hint(macro none)
def $sum(eps) = 0
def $sum(n n'*) = $(n + $sum(n'*))
Expand Down
52 changes: 50 additions & 2 deletions specification/wasm-3.0/0.3-aux.seq.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,62 @@ def $opt_(syntax X, w) = w

;; Concatenation

def $concat_(syntax X, (X*)*) : X* hint(show (++) %2)
def $concat_(syntax X, (X*)*) : X* hint(show (++) %2) hint(inverse $invconcat_)
def $concat_(syntax X, eps) = eps
def $concat_(syntax X, (w*) (w'*)*) = w* ++ $concat_(X, (w'*)*)

def $concatn_(syntax X, (X*)*, nat) : X* hint(show (++) %2)
def $concatn_(syntax X, (X*)*, nat) : X* hint(show (++) %2) hint(inverse $invconcatn_)
def $concatn_(syntax X, eps, n) = eps
def $concatn_(syntax X, (w^n) (w'^n)*, n) = w^n $concatn_(X, (w'^n)*, n)

def $invconcat_(syntax X, X*) : (X*)* hint(builtin "inverse_of_concat")
def $invconcatn_(syntax X, nat, X*) : (X*)* hint(builtin "inverse_of_concatn")


;; List manipulation


;; This version might be easier to define in theorem provers (eyeball close)
def $rev_(syntax X, X*) : X*
def $rev_(syntax X, []) = []
def $rev_(syntax X, w_0 w*) = $rev_(X, w*) w_0

;; This version is more succinct in SpecTec.
def $rev'_(syntax X, X*) : X*
def $rev'_(syntax X, w^N) = (w^N[N-1-i])^(i < N)

def $filter_(syntax X, def $p(X) : bool, X*) : X*
def $filter_(syntax X, $p, []) = []
def $filter_(syntax X, $p, w_0 w*) = w_0 $filter_(X, $p, w*) -- if $p(w_0)
def $filter_(syntax X, $p, w_0 w*) = $filter_(X, $p, w*) -- otherwise


def $take_(syntax X, nat, X*) : X*
def $take_(syntax X, 0, w*) = []
def $take_(syntax X, n, []) = []
def $take_(syntax X, n, w w'*) = w $take_(X, $(n-1), w'*) -- if n > 0

def $take'_(syntax X, nat, X*) : X*
def $take'_(syntax X, n, w^n') = w^n' -- if n' < n
def $take'_(syntax X, n, w^n w'*) = w^n

def $takeWhile_(syntax X, def $p(X) : bool, X*) : X*
def $takeWhile_(syntax X, $p, []) = []
def $takeWhile_(syntax X, $p, w_0 w*) = w_0 $takeWhile_(X, $p, w*) -- if $p(w_0)
def $takeWhile_(syntax X, $p, w_0 w*) = [] -- otherwise


def $drop_(syntax X, nat, X*) : X*
def $drop_(syntax X, 0, w*) = w*
def $drop_(syntax X, n, []) = []
def $drop_(syntax X, n, w w'*) = $drop_(X, $(n-1), w'*) -- if n > 0

;; Doesn't work with the interpreter backend
def $drop'_(syntax X, nat, X*) : X*
def $drop'_(syntax X, n, w^n') = [] -- if n' < n
def $drop'_(syntax X, n, w^n w'*) = w'*



;; Set functions

Expand Down
1 change: 1 addition & 0 deletions specification/wasm-3.0/1.1-syntax.values.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ syntax u64 = uN(64)
syntax u128 = uN(128)
syntax s33 = sN(33)

var d : bit
var b : byte


Expand Down
14 changes: 10 additions & 4 deletions specification/wasm-3.0/1.2-syntax.types.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,15 @@ def $JN(64) = I64

;; Size

def $size(numtype) : nat hint(show |%|)
def $size(numtype) : nat hint(show |%|) hint(inverse $invsize)
def $vsize(vectype) : nat hint(show |%|)
def $psize(packtype) : nat hint(show |%|)
def $lsize(lanetype) : nat hint(show |%|)
def $lsize(lanetype) : nat hint(show |%|) hint(inverse $invlsize)
def $zsize(storagetype) : nat hint(show |%|)

def $invsize(nat) : numtype hint(builtin "inverse_of_size")
def $invlsize(nat) : lanetype hint(builtin "inverse_of_lsize")

def $size(I32) = 32
def $size(I64) = 64
def $size(F32) = 32
Expand All @@ -228,7 +231,7 @@ def $zsize(packtype) = $psize(packtype)


;; TODO(2, rossberg): get rid of these terrible hacks by defining $Inn(nat) hint(show I#%)
def $sizenn(numtype) : nat hint(show N) hint(macro none) ;; HACK!
def $sizenn(numtype) : nat hint(show N) hint(macro none) hint(inverse $invsizenn) ;; HACK!
def $sizenn1(numtype) : nat hint(show N_1) hint(macro none) ;; HACK!
def $sizenn2(numtype) : nat hint(show N_2) hint(macro none) ;; HACK!
def $sizenn(nt) = $size(nt)
Expand All @@ -241,13 +244,16 @@ def $vsizenn(vt) = $vsize(vt)
def $psizenn(packtype) : nat hint(show N) hint(macro none) ;; HACK!
def $psizenn(pt) = $psize(pt)

def $lsizenn(lanetype) : nat hint(show N) hint(macro none) ;; HACK!
def $lsizenn(lanetype) : nat hint(show N) hint(macro none) hint(inverse $invlsizenn) ;; HACK!
def $lsizenn1(lanetype) : nat hint(show N_1) hint(macro none) ;; HACK!
def $lsizenn2(lanetype) : nat hint(show N_2) hint(macro none) ;; HACK!
def $lsizenn(lt) = $lsize(lt)
def $lsizenn1(lt) = $lsize(lt)
def $lsizenn2(lt) = $lsize(lt)

def $invsizenn(nat) : numtype hint(builtin "inverse_of_sizenn")
def $invlsizenn(nat) : lanetype hint(builtin "inverse_of_lsizenn")


;; Unpacking

Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载