Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
4541949
Ported type family removal pass from MIL
DCupello1 Sep 30, 2025
8def55f
Generated projection functions for each type family instance.
DCupello1 Oct 1, 2025
0022a6b
Created chains that lead from the real type to the expected type. Imp…
DCupello1 Oct 3, 2025
8f073e8
Refactor: simplified exp transformation by making it only do conversi…
DCupello1 Oct 3, 2025
3454ac5
Made family constructors actually expose the binded variables as case…
DCupello1 Oct 3, 2025
d834aae
Some more cleanup. Made it so generation of conversion functions is d…
DCupello1 Oct 3, 2025
ddcf475
Fixed potential issue with families with one instance being applied o…
DCupello1 Oct 5, 2025
b502003
Added a simplification operation to the conversion chain.
DCupello1 Oct 5, 2025
b3baeb4
Fixed simplification to now work both ways. Move generation of projec…
DCupello1 Oct 5, 2025
0c213c3
Some extra fixes on iteration typing to make rocq code compile.
DCupello1 Oct 6, 2025
27adcb7
Cleanup and added description to pass.
DCupello1 Oct 7, 2025
dd677fa
Added small totalize fix to make wasm 2.0 validate.
DCupello1 Oct 7, 2025
0aa54d4
Improved naming of constructor and projection functions to use the ca…
DCupello1 Oct 7, 2025
502a325
Renaming some functions and types.
DCupello1 Oct 7, 2025
730503d
Small tweak on BinE and UnE real types.
DCupello1 Oct 8, 2025
26d354c
Modifying Pnn and Inn to be aliases of packtype and addrtype, respect…
DCupello1 Oct 8, 2025
2192553
fix test.md
DCupello1 Oct 8, 2025
3f8737f
Update check_type
f52985 Oct 13, 2025
e948b47
fix TEST.md for other tests
DCupello1 Oct 13, 2025
7b93476
Merge branch 'main' into typefamily-removal-pass
DCupello1 Oct 13, 2025
d6b06e7
Merge pull request #186 from DCupello1/typefamily-removal-pass
rossberg Oct 17, 2025
1e6c562
Revive else pass.
DCupello1 Oct 27, 2025
1788ba4
Fix test.md
DCupello1 Oct 27, 2025
3eabe83
Undep pass enabled
DCupello1 Oct 27, 2025
1da609c
fix test.md
DCupello1 Oct 27, 2025
2d165d2
Slight comment change
DCupello1 Oct 27, 2025
fbde36b
Merge pull request #187 from DCupello1/else-pass
DCupello1 Oct 30, 2025
b46e48d
Merge pull request #188 from DCupello1/undep-pass
DCupello1 Nov 4, 2025
181cd3a
Ported new changes to sub pass and enabled it once again. Also reenab…
DCupello1 Nov 4, 2025
53e4551
Ported uncase-removal pass
DCupello1 Nov 4, 2025
55edd95
Remove sideconditions change
DCupello1 Nov 5, 2025
aa05d84
fix TEST.md
DCupello1 Nov 5, 2025
11245bd
Merge pull request #189 from Wasm-DSL/sub-pass
DCupello1 Nov 5, 2025
19d66f5
Merge branch 'sub-pass' into uncase-removal-pass
DCupello1 Nov 5, 2025
597b7e2
comment on uncaseremoval added
DCupello1 Nov 5, 2025
6c6d752
fix TEST.md
DCupello1 Nov 5, 2025
2188ff3
refactor: small list function change due to version mismatch
DCupello1 Nov 5, 2025
530a969
small change again
DCupello1 Nov 5, 2025
7c34091
Start on sub expansion pass. Validates up to 2.0.
DCupello1 Nov 12, 2025
b68dd90
Improved handling of generated binds, and removed boilerplate code.
DCupello1 Nov 12, 2025
255e13e
Added type family sub expansion support, and comment description of pass
DCupello1 Nov 12, 2025
66b12dc
small fix on name generation.
DCupello1 Nov 12, 2025
75b49fa
Improved bind handling: each case carries its own binds now.
DCupello1 Nov 12, 2025
5974062
Further improvement on bind handling: now handles clauses as well. Li…
DCupello1 Nov 12, 2025
a3195aa
Refactor middle end tests (#194)
nomeata Nov 12, 2025
25cee09
Add alias-demut pass (#193)
nomeata Nov 13, 2025
e44b624
Bump ocaml compiler (#196)
nomeata Nov 13, 2025
4f0d226
Merge branch 'main' into uncase-removal-pass
DCupello1 Nov 13, 2025
c9755ef
Merge branch 'uncase-removal-pass' into sub-expansion-pass
DCupello1 Nov 13, 2025
798b0e5
Generated projection function hints
DCupello1 Nov 13, 2025
bfad604
Focus on disambiguating ids instead of prefixing type constructors.
DCupello1 Nov 13, 2025
80d9091
update tests
DCupello1 Nov 13, 2025
5e31286
spec changes
DCupello1 Nov 13, 2025
c2aaaff
Update tests
DCupello1 Nov 13, 2025
942de10
Merge pull request #201 from Wasm-DSL/small-spec-changes
DCupello1 Nov 13, 2025
efd54e6
Removed params for family projection functions.
DCupello1 Nov 14, 2025
aa293d4
remove wf_preds for binds that appear in func args, and remove args e…
DCupello1 Nov 14, 2025
8112a80
[spec] Fix typo in rule
rossberg Nov 19, 2025
2c87e88
fix bracket parsing
zilinc Nov 19, 2025
a20bba5
[spectec] Fix bracket recognition for variants
rossberg Nov 19, 2025
c19d2d5
Merge branch 'main' into undep-fix
DCupello1 Nov 21, 2025
104edd0
Update tests
DCupello1 Nov 21, 2025
0c0eced
remove to_list and use elements.
DCupello1 Nov 21, 2025
938f2db
Add IfE constuctor to IL AST (#210)
nomeata Dec 1, 2025
b3bff17
test-middlend: do not require copying pass names in dune files (#200)
nomeata Dec 3, 2025
d2fdd73
Add if-then-else introduction IL pass (#211)
nomeata Dec 3, 2025
9c69350
refactor projection function creation.
DCupello1 Dec 3, 2025
7f8103c
Merge branch 'main' into uncase-removal-pass
DCupello1 Dec 3, 2025
93b7a35
Merge pull request #191 from Wasm-DSL/uncase-removal-pass
DCupello1 Dec 3, 2025
3e673fc
Merge branch 'main' into sub-expansion-pass
DCupello1 Dec 3, 2025
0308a06
Merge pull request #195 from Wasm-DSL/sub-expansion-pass
DCupello1 Dec 4, 2025
12459ce
Merge branch 'main' into improve-ids-pass
DCupello1 Dec 8, 2025
eee6937
Added IfE traversal to uncaseremoval, subexpansion, and improveids
DCupello1 Dec 8, 2025
8587f1e
Fix tests
DCupello1 Dec 8, 2025
2ec9f83
Make sure no holes are left in mixops
DCupello1 Dec 8, 2025
0582fc4
Remove old test file
DCupello1 Dec 8, 2025
5e70e47
Made transform, collect, exists and forall traversal
DCupello1 Dec 15, 2025
2831186
Merged list, forall, exists into one collect traversal.
DCupello1 Dec 16, 2025
30d16a5
extended transform traversal to go through the whole AST (except hints)
DCupello1 Dec 16, 2025
46b6066
Simplified 5 passes with new transformer approach
DCupello1 Dec 16, 2025
b452996
Small fix on walk making collector only work on lists. Made so custom…
DCupello1 Dec 18, 2025
dbf74d2
Fix tests (this change is due to small bug on uncase with introductio…
DCupello1 Dec 18, 2025
41dd386
Adapted sideconditions to utilize the new traversal method. Found iss…
DCupello1 Jan 7, 2026
9fe0bce
Small fix on walk.ml to allow paths to also traverse their note.
DCupello1 Jan 7, 2026
8dffda9
Adapted undep to also follow new traversals approach
DCupello1 Jan 7, 2026
1f67f9c
Merge pull request #212 from Wasm-DSL/il-transformers
DCupello1 Jan 8, 2026
ba5ca79
Merge branch 'main' into undep-fix
DCupello1 Jan 8, 2026
9df1008
Merge pull request #205 from Wasm-DSL/undep-fix
DCupello1 Jan 8, 2026
2f94367
Merge branch 'main' into improve-ids-pass
DCupello1 Jan 8, 2026
589bccc
Let introduction pass
DCupello1 Jan 13, 2026
6bd6632
Fix on improve ids related to let premise
DCupello1 Jan 13, 2026
5a6957b
Fix tests
DCupello1 Jan 13, 2026
ab78b4d
Merge pull request #198 from Wasm-DSL/improve-ids-pass
DCupello1 Jan 19, 2026
30526ce
Merge remote-tracking branch 'upstream/main' into sync2
rossberg Jan 20, 2026
03c378b
Merge remote-tracking branch 'upstream/main'
rossberg Feb 12, 2026
dc04802
Make middlend passes compile
rossberg Feb 12, 2026
defa80f
[Type family removal] changes to mixop and dependent tuple handling.
DCupello1 Feb 16, 2026
dc57778
[Undep] Changes to mixop and quant handling
DCupello1 Feb 16, 2026
f92f383
Merge pull request #220 from Wasm-DSL/merge-deptup-tf-fixes
rossberg Feb 16, 2026
41736ab
Merge IL changes from upstream (#218)
rossberg Feb 16, 2026
e064890
Merge remote-tracking branch 'upstream/main'
rossberg Feb 16, 2026
e0b87d9
Fix ci-spectec.yml
rossberg Feb 16, 2026
939e2c5
Spec changes that fixes some non-exhaustive pattern matching
DCupello1 Feb 19, 2026
0528be4
Merge branch 'main' into letintro-pass
DCupello1 Feb 19, 2026
a69fc48
Else simplification pass in progress
DCupello1 Jan 14, 2026
16e2521
exposing hints from else and wf relations
DCupello1 Jan 14, 2026
b1322d5
Modification to else relation removal, only removes if there are no u…
DCupello1 Jan 15, 2026
0dba31a
fix tests
DCupello1 Jan 15, 2026
5b748cb
Changed generated otherwise to be conjunction instead of disjunction.
DCupello1 Jan 20, 2026
790a15d
fix tests
DCupello1 Jan 20, 2026
925694c
Once again, turning premises of an else relation into disjunction, an…
DCupello1 Jan 26, 2026
bb53950
CR changes: made more functions partial instead of adding cases. Subs…
DCupello1 Feb 19, 2026
a9ba228
[spectec] Fix matching against CvtE
rossberg Feb 23, 2026
0fd8ed6
[spectec] Add missing reduction rules for paths and iters to IL seman…
rossberg Feb 23, 2026
662dde5
[spectec] Minor renaming of rule
rossberg Feb 23, 2026
ddc1ee9
Append missing iter variable for IterN
f52985 Feb 24, 2026
f93c275
Simplify error message upon free variable exception
f52985 Feb 24, 2026
3a3d0da
Print more helpful error message for the MatchE failure
f52985 Feb 27, 2026
ab1b082
Manually insert unified variable for minus_set function
f52985 Feb 27, 2026
1889959
Merge remote-tracking branch 'upstream/main'
rossberg Mar 1, 2026
f3abd6b
Reverted subst change due to hints
DCupello1 Mar 3, 2026
34cc42d
Fix tests
DCupello1 Mar 3, 2026
b6c8e50
Merge pull request #221 from Wasm-DSL/partial-func-changes
DCupello1 Mar 3, 2026
fddc2cc
Fix partial functions being called on the body of partial functions.
DCupello1 Mar 2, 2026
c230bff
Fixed an issue with partial functions calls having partial functions …
DCupello1 Mar 2, 2026
99ed21b
catch all check now checks premises as well
DCupello1 Mar 2, 2026
54ea232
Now returns an error if a partial function call has a partial functio…
DCupello1 Mar 3, 2026
8239ccb
Fix tests
DCupello1 Mar 4, 2026
354b440
Fix tests with new main changes
DCupello1 Mar 4, 2026
12b79f6
Merge pull request #223 from Wasm-DSL/totalize-transfer-partiality
DCupello1 Mar 4, 2026
4c627b9
Merge remote-tracking branch 'upstream/main'
rossberg Mar 9, 2026
d9ce1c0
[spectec] Middlend test expects
rossberg Mar 9, 2026
8504684
Merge remote-tracking branch 'upstream/main'
rossberg Mar 23, 2026
0875b92
Merge remote-tracking branch 'upstream/main'
rossberg Apr 2, 2026
1a12418
Sync from upstream main branch 'spec/main'
zilinc Apr 24, 2026
84d9baa
[sub elimination] Now support iteration types (must have same iterati…
DCupello1 Apr 24, 2026
2582320
[undep] Definite iteration wf premises now preserve the iteration whe…
DCupello1 Apr 24, 2026
8278245
Fix tests
DCupello1 Apr 24, 2026
a76a831
Merge pull request #228 from Wasm-DSL/undep-sub-fixes
zilinc Apr 28, 2026
ec17c32
Merge branch 'main' into zilinc/sync
zilinc Apr 28, 2026
0a43a1e
update test expects
zilinc Apr 28, 2026
5cb2657
Merge pull request #227
zilinc Apr 28, 2026
7550a9a
[spec/spectec] Fix prose title of if instruction (#2154)
f52985 Apr 24, 2026
67c4f81
[spec] Fix rendering of Expand
rossberg Apr 24, 2026
48fd5a0
[spectec] Automate extraction of validation rules for prose generatio…
f52985 Apr 27, 2026
4ff4b73
[spectec] Split def of context's RECS field; make struct extension wo…
rossberg Apr 27, 2026
2c73e97
[spec] Tweaks
rossberg Apr 27, 2026
570fa5a
[spec] Port Soundness Appendix to SpecTec, pt. 1 (rules for types)
rossberg Apr 27, 2026
4e8b20d
[spectec] Sync diff
rossberg Apr 27, 2026
946524c
[spectec] Add documentation about subscripted infix operators and the…
rossberg Apr 28, 2026
8f94883
[ci] Test exepcts
rossberg Apr 28, 2026
d764712
[spectec] Formalise binding semantics for let premises (#2109)
rossberg Apr 28, 2026
aec4069
Middlend test expects
rossberg Apr 28, 2026
ae6d0d2
Merge upstream
rossberg Apr 28, 2026
6e90ec8
[spectec] Fix let scoping in type family removal
rossberg Apr 28, 2026
fcc59cb
[spectec] Fix let scoping in type family removal (#230)
rossberg Apr 29, 2026
f281b56
Merge branch 'upstream'
rossberg May 13, 2026
f026d2f
Put a restriction on else simplification for rules that have quantifi…
DCupello1 May 18, 2026
8a20c9a
Let introduction pass
DCupello1 Jan 13, 2026
0852474
Fix on improve ids related to let premise
DCupello1 Jan 13, 2026
b935d50
Fix tests
DCupello1 Jan 13, 2026
a3a7429
Merge pull request #213 from Wasm-DSL/letintro-pass
DCupello1 May 20, 2026
0635d45
Merge branch 'main' into else-simp-pass
DCupello1 May 20, 2026
93314fc
Remove letintro (left by accident during merge - kept letintromech)
DCupello1 May 20, 2026
811f5a4
Add description to MLI file
DCupello1 May 20, 2026
415f273
Merge pull request #214 from Wasm-DSL/else-simp-pass
DCupello1 May 20, 2026
fd3d126
Move descriptions to MLI file and update some of them.
DCupello1 May 20, 2026
f2738a2
Merge pull request #231 from Wasm-DSL/update-desc-middlend
DCupello1 May 20, 2026
e3fdbce
Backporting soundness spec
DCupello1 May 25, 2026
b9826d8
Fix on tableinst ok
DCupello1 May 25, 2026
7304a31
Added resulttype to relation signature of config ok + made config ok …
DCupello1 May 26, 2026
a666b3f
Small typo on frame_ok
DCupello1 May 26, 2026
e22af5c
Fix parens for state.
DCupello1 May 26, 2026
6eb3acf
Merge pull request #232 from Wasm-DSL/backport-soundness-spec
DCupello1 May 26, 2026
0f45b30
Merge branch 'spec/main'
zilinc May 29, 2026
e3db73c
update test expects
zilinc May 29, 2026
acc6e83
Sync with upstream
zilinc May 29, 2026
3964d54
Merge branch 'upstream'
rossberg Oct 13, 2026
e36f6af
Bunch of fixes related to having inaccurate e.note types.
DCupello1 Oct 15, 2026
2b15d9a
Minor rename
rossberg Oct 15, 2026
8486037
Fixed if then else pass to not optimize if there are partial construc…
DCupello1 Nov 23, 2026
1c8a0af
fix middlend tests
DCupello1 Nov 23, 2026
e140141
Merge remote-tracking branch 'upstream/main' into merge-upstream
rossberg Nov 26, 2026
f7d2773
Merge upstream (#245)
rossberg Nov 26, 2026
3490d16
Port over 2.0 and 3.0 changes from mechanization backend.
DCupello1 Nov 27, 2026
bb9ee10
Remove mech-specific hints
DCupello1 Nov 27, 2026
9fe751e
Port changes to 1.0 as well.
DCupello1 Nov 27, 2026
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
1 change: 0 additions & 1 deletion .github/workflows/ci-spectec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
paths: [ spectec/**, document/** ]

pull_request:
branches: [ main ]
paths: [ spectec/**, document/** ]

# Allows you to run this workflow manually from the Actions tab
Expand Down
2 changes: 1 addition & 1 deletion specification/wasm-1.0/0-aux.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def $sum(n n'*) = $(n + $sum(n'*))

;; General sequence functions

def $opt_(syntax X, X*) : X? hint(show %2)
def $opt_(syntax X, X*) : X? hint(show %2) hint(partial)
def $opt_(syntax X, eps) = eps
def $opt_(syntax X, w) = w

Expand Down
21 changes: 16 additions & 5 deletions specification/wasm-1.0/1-syntax.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ var b : byte

;; Floating-point

def $signif(N) : nat
def $signif(N) : nat hint(partial)
def $signif(32) = 23
def $signif(64) = 52

def $expon(N) : nat
def $expon(N) : nat hint(partial)
def $expon(32) = 8
def $expon(64) = 11

Expand Down Expand Up @@ -178,8 +178,19 @@ syntax relop_(Inn) =
syntax relop_(Fnn) =
| EQ | NE | LT | GT | LE | GE

syntax cvtop =
| EXTEND sx | WRAP | CONVERT sx | TRUNC sx | PROMOTE | DEMOTE | REINTERPRET
syntax cvtop__(valtype_1, valtype_2)
syntax cvtop__(Inn_1, Inn_2) =
| EXTEND sx -- if $size(Inn_1) < $size(Inn_2)
| WRAP -- if $size(Inn_1) > $size(Inn_2)
syntax cvtop__(Inn_1, Fnn_2) =
| CONVERT sx
| REINTERPRET -- if $size(Inn_1) = $size(Fnn_2)
syntax cvtop__(Fnn_1, Inn_2) =
| TRUNC sx
| REINTERPRET -- if $size(Fnn_1) = $size(Inn_2)
syntax cvtop__(Fnn_1, Fnn_2) =
| PROMOTE -- if $size(Fnn_1) < $size(Fnn_2)
| DEMOTE -- if $size(Fnn_1) > $size(Fnn_2)


;; Memory operators
Expand Down Expand Up @@ -229,7 +240,7 @@ syntax instr/num hint(desc "numeric instruction") = ...
| BINOP valtype binop_(valtype) hint(show %.%)
| TESTOP valtype testop_(valtype) hint(show %.%)
| RELOP valtype relop_(valtype) hint(show %.%)
| CVTOP valtype_1 valtype_2 cvtop hint(show %1.%3#_#%2)
| CVTOP valtype_1 valtype_2 cvtop__(valtype_2, valtype_1) hint(show %1.##%3#_#%2)
-- if valtype_1 =/= valtype_2
| ...

Expand Down
6 changes: 3 additions & 3 deletions specification/wasm-1.0/3-numerics.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def $testop_(valtype, testop_(valtype), val_(valtype)) : val_(I32)
hint(show %2#$_(%1)#((%3)))
def $relop_(valtype, relop_(valtype), val_(valtype), val_(valtype)) : val_(I32)
hint(show %2#$_(%1)#(%3, %4))
def $cvtop__(valtype_1, valtype_2, cvtop, val_(valtype_1)) : val_(valtype_2)*
def $cvtop__(valtype_1, valtype_2, cvtop__(valtype_1, valtype_2), val_(valtype_1)) : val_(valtype_2)*
hint(show %3#$__(%1,%2)#((%4)))

def $wrap__(M, N, iN(M)) : iN(N)
Expand Down Expand Up @@ -79,8 +79,8 @@ def $inot_(N, iN(N)) : iN(N)
def $iand_(N, iN(N), iN(N)) : iN(N)
def $ior_(N, iN(N), iN(N)) : iN(N)
def $ixor_(N, iN(N), iN(N)) : iN(N)
def $ishl_(N, iN(N), u32) : iN(N)
def $ishr_(N, sx, iN(N), u32) : iN(N) hint(show $ishr_(%)^(%)#((%,%)))
def $ishl_(N, iN(N), iN(N)) : iN(N)
def $ishr_(N, sx, iN(N), iN(N)) : iN(N) hint(show $ishr_(%)^(%)#((%,%)))
def $irotl_(N, iN(N), iN(N)) : iN(N)
def $irotr_(N, iN(N), iN(N)) : iN(N)
def $iclz_(N, iN(N)) : iN(N)
Expand Down
8 changes: 1 addition & 7 deletions specification/wasm-1.0/6-typing.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,7 @@ rule Instr_ok/testop:
rule Instr_ok/relop:
C |- RELOP t relop_t : t t -> I32


;; TODO: move side conditions to syntax
rule Instr_ok/cvtop-reinterpret:
C |- CVTOP nt_1 nt_2 REINTERPRET : nt_2 -> nt_1
-- if $size(nt_1) = $size(nt_2)

rule Instr_ok/cvtop-convert:
rule Instr_ok/cvtop:
C |- CVTOP nt_1 nt_2 cvtop : nt_2 -> nt_1


Expand Down
13 changes: 7 additions & 6 deletions specification/wasm-1.0/8-reduction.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ rule Step_pure/label-vals:

;; TODO: may want a label context instead of bubbling up
rule Step_pure/br-zero:
(LABEL_ n `{instr'*} val'* val^n (BR 0) instr*) ~> val^n instr'*
(LABEL_ n `{instr'*} val'* val^n (BR 0) admininstr*) ~> val^n instr'*

rule Step_pure/br-succ:
(LABEL_ n `{instr'*} val* (BR $(l+1)) instr*) ~> val* (BR l)
(LABEL_ n `{instr'*} val* (BR $(l+1)) admininstr*) ~> val* (BR l)


rule Step_pure/br_if-true:
Expand Down Expand Up @@ -133,17 +133,17 @@ rule Step_pure/frame-vals:
(FRAME_ n `{f} val^n) ~> val^n

rule Step_pure/return-frame:
(FRAME_ n `{f} val'* val^n RETURN instr*) ~> val^n
(FRAME_ n `{f} val'* val^n RETURN admininstr*) ~> val^n

rule Step_pure/return-label:
(LABEL_ n `{instr'*} val* RETURN instr*) ~> val* RETURN
(LABEL_ n `{instr'*} val* RETURN admininstr*) ~> val* RETURN


;; Traps

rule Step_pure/trap-vals:
val* TRAP instr* ~> TRAP
-- if val* =/= eps \/ instr* =/= eps
val* TRAP admininstr* ~> TRAP
-- if val* =/= eps \/ admininstr* =/= eps

rule Step_pure/trap-label:
(LABEL_ n `{instr'*} TRAP) ~> TRAP
Expand All @@ -167,6 +167,7 @@ rule Step/ctxt-instrs:
-- Step: z; admininstr* ~> z'; admininstr'*
-- if val* =/= eps \/ admininstr_1* =/= eps


;; Numeric instructions

rule Step_pure/unop-val:
Expand Down
229 changes: 229 additions & 0 deletions specification/wasm-1.0/B-soundness.spectec
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
;; Contexts

relation Context_ok: |- context : OK hint(macro "%context")

rule Context_ok:
|- C : OK
-- if C =
{ TYPES ft*,
FUNCS ft_2*,
GLOBALS gt*,
MEMS mt*,
TABLES tt*,
LOCALS lct*,
LABELS rt*,
RETURN rt'?,
}
-- (Functype_ok: |- ft : OK)*
-- (Globaltype_ok: |- gt : OK)*
-- (Memtype_ok: |- mt : OK)*
-- (Tabletype_ok: |- tt : OK)*
-- (Functype_ok: |- ft_2 : OK)*


;; Value types

relation Val_ok: |- val : valtype

rule Val_ok:
|- CONST t c_t : t


;; Result types

relation Result_ok: |- result : valtype*

rule Result_ok/result:
|- _VALS v* : t*
-- (Val_ok: |- v : t)*

rule Result_ok/trap:
|- TRAP : t*


;; Administrative instructions

syntax adminexpr = admininstr*

relation Instr_ok2: store; context |- admininstr : functype
hint(prose "%3 is valid with %4")
relation Instrs_ok2: store; context |- admininstr* : functype
hint(prose "%3 is valid with %4")
relation Expr_ok2: store; context |- adminexpr : resulttype
hint(prose "%3 is valid with %4")

rule Instr_ok2/plain:
s; C |- instr : t_1* -> t_2*
-- Instr_ok: C |- instr : t_1* -> t_2*

rule Instr_ok2/label:
s; C |- LABEL_ n `{instr'*} admininstr* : eps -> t?
-- if |t'?| = n
-- Instrs_ok2: s; C |- instr'* : t'? -> t?
-- Instrs_ok2: s; {LABELS (t'?)} ++ C |- admininstr* : eps -> t?

rule Instr_ok2/frame:
s; C |- FRAME_ n `{f} admininstr* : eps -> t?
-- if |t?| = n
-- Frame_ok: s |- f : C'
-- Expr_ok2: s; {RETURN t?} ++ C' |- admininstr* : t?

rule Instr_ok2/call_addr:
s; C |- CALL_ADDR funcaddr : t_1* -> t_2*
-- Externaddr_ok: s |- FUNC funcaddr: FUNC (t_1* -> t_2*)

rule Instr_ok2/trap:
s; C |- TRAP : t_1* -> t_2*


rule Instrs_ok2/empty:
s; C |- eps : eps -> eps

rule Instrs_ok2/instr:
s; C |- admininstr : t_1* -> t_2*
-- Instr_ok2: s; C |- admininstr : t_1* -> t_2*

rule Instrs_ok2/seq:
s; C |- admininstr_1* admininstr_2* : t_1* -> t_3*
-- Instrs_ok2: s; C |- admininstr_1* : t_1* -> t_2*
-- Instrs_ok2: s; C |- admininstr_2* : t_2* -> t_3*

rule Instrs_ok2/frame:
s; C |- admininstr* : t* t_1* -> t* t_2*
-- Instrs_ok2: s; C |- admininstr* : t_1* -> t_2*

rule Expr_ok2:
s; C |- admininstr* : t?
-- Instrs_ok2: s; C |- admininstr* : eps -> t?


;; Instances

relation Globalinst_ok: store |- globalinst : globaltype
relation Meminst_ok: store |- meminst : memtype
relation Tableinst_ok: store |- tableinst : tabletype
relation Funcinst_ok: store |- funcinst : functype
relation Exportinst_ok: store |- exportinst : OK

rule Globalinst_ok:
s |- {TYPE mut t, VALUE val} : mut t
-- Globaltype_ok: |- mut t : OK
-- Val_ok: |- val : t

rule Meminst_ok:
s |- {TYPE `[n..m?], BYTES b*} : `[n..m?]
-- Memtype_ok: |- `[n..m?] : OK
-- if |b*| = $(n * $($(64 * $Ki)))

rule Tableinst_ok:
s |- {TYPE `[n..m?] , REFS (fa?)*} : `[n..m?]
-- Tabletype_ok: |- `[n..m?] : OK
-- ((Externaddr_ok: s |- FUNC fa : FUNC ft)?)*
-- if |(fa?)*| = n

rule Funcinst_ok:
s |- {TYPE ft, MODULE moduleinst, CODE func} : ft
-- Functype_ok: |- ft : OK
-- Moduleinst_ok: s |- moduleinst : C
-- Func_ok: C |- func : ft

rule Exportinst_ok:
s |- {NAME nm, ADDR xa} : OK
-- Externaddr_ok: s |- xa : xt


;; Modules

relation Moduleinst_ok: store |- moduleinst : context

rule Moduleinst_ok:
s |- { TYPES functype*,
GLOBALS globaladdr*,
MEMS memaddr*,
TABLES tableaddr*,
FUNCS funcaddr*,
EXPORTS exportinst* } :
{ TYPES functype*,
GLOBALS globaltype*,
MEMS memtype*,
TABLES tabletype*,
FUNCS functype_F*,
}
-- (Functype_ok: |- functype : OK)*
-- (Externaddr_ok: s |- GLOBAL globaladdr : GLOBAL globaltype)*
-- (Externaddr_ok: s |- FUNC funcaddr : FUNC functype_F)*
-- (Externaddr_ok: s |- MEM memaddr : MEM memtype)*
-- (Externaddr_ok: s |- TABLE tableaddr : TABLE tabletype)*
-- (Exportinst_ok: s |- exportinst : OK)*
----
-- if $disjoint_(name, (exportinst.NAME)*)
-- (if exportinst.ADDR <- (GLOBAL globaladdr)* (MEM memaddr)* (TABLE tableaddr)* (FUNC funcaddr)*)*


;; Stores

relation Store_ok: |- store : OK

rule Store_ok:
|- s : OK
-- (Globalinst_ok: s |- globalinst : globaltype)*
-- (Meminst_ok: s |- meminst : memtype)*
-- (Tableinst_ok: s |- tableinst : tabletype)*
-- (Funcinst_ok: s |- funcinst : functype)*
----
-- if s = {GLOBALS globalinst*, MEMS meminst*, TABLES tableinst*, FUNCS funcinst*}


;; Store extension

relation Extend_globalinst: globalinst `<= globalinst
relation Extend_meminst: meminst `<= meminst
relation Extend_tableinst: tableinst `<= tableinst
relation Extend_funcinst: funcinst `<= funcinst
relation Extend_store: store `<= store

rule Extend_globalinst:
{TYPE mut t, VALUE val} `<= {TYPE mut t, VALUE val'}
-- if mut = MUT \/ val = val'

rule Extend_meminst:
{TYPE `[n..m?], BYTES b*} `<= {TYPE `[n'..m?], BYTES b'*}
-- if n <= n'
-- if |b*| <= |b'*|

rule Extend_tableinst:
{TYPE `[n..m?], REFS ref*} `<= {TYPE `[n'..m?], REFS ref'*}
-- if n <= n'
-- if |ref*| <= |ref'*|

rule Extend_funcinst:
{TYPE ft, MODULE mm, CODE fc} `<= {TYPE ft, MODULE mm, CODE fc}

rule Extend_store:
s `<= s'
-- (Extend_globalinst: s.GLOBALS[a] `<= s'.GLOBALS[a] )^(a<|s.GLOBALS|)
-- (Extend_meminst: s.MEMS[a] `<= s'.MEMS[a] )^(a<|s.MEMS|)
-- (Extend_tableinst: s.TABLES[a] `<= s'.TABLES[a] )^(a<|s.TABLES|)
-- (Extend_funcinst: s.FUNCS[a] `<= s'.FUNCS[a] )^(a<|s.FUNCS|)


;; Configurations

relation Frame_ok: store |- frame : context
relation State_ok: |- state : context
relation Config_ok: |- config : resulttype

rule Frame_ok:
s |- {LOCALS val*, MODULE moduleinst} : C ++ {LOCALS t*}
-- Moduleinst_ok: s |- moduleinst : C
-- (Val_ok: |- val : t)*

rule State_ok:
|- s; f : C
-- Store_ok: |- s : OK
-- Frame_ok: s |- f : C

rule Config_ok:
|- s; f; admininstr* : t?
-- State_ok: |- s; f : C
-- Expr_ok2: s; C |- admininstr* : t?
Loading
Loading