Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 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
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
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
5 changes: 4 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 All @@ -21,7 +20,11 @@ jobs:
- name: Setup OCaml
uses: ocaml/setup-ocaml@v3
with:
<<<<<<< HEAD
ocaml-compiler: 5.3.x
=======
ocaml-compiler: 5.04.x
>>>>>>> upstream/main
- name: Setup Dune
run: opam install --yes dune menhir mdx zarith
- name: Setup Latex
Expand Down
21 changes: 13 additions & 8 deletions specification/wasm-1.0/8-reduction.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ relation Step_read: config ~> admininstr* hint(show "E") hint(tabular)
relation Steps: config ~>* config hint(show "E") hint(tabular)

rule Step/pure:
z; instr* ~> z; instr'*
-- Step_pure: instr* ~> instr'*
z; admininstr* ~> z; admininstr'*
-- Step_pure: admininstr* ~> admininstr'*

rule Step/read:
z; instr* ~> z; instr'*
-- Step_read: z; instr* ~> instr'*
z; admininstr* ~> z; admininstr'*
-- Step_read: z; admininstr* ~> admininstr'*

rule Steps/refl:
z; admininstr* ~>* z; admininstr*
Expand Down Expand Up @@ -155,12 +155,17 @@ rule Step_pure/trap-frame:
;; Context

rule Step/ctxt-label:
z; (LABEL_ n `{instr_0*} instr*) ~> z'; (LABEL_ n `{instr_0*} instr'*)
-- Step: z; instr* ~> z'; instr'*
z; (LABEL_ n `{instr_0*} admininstr*) ~> z'; (LABEL_ n `{instr_0*} admininstr'*)
-- Step: z; admininstr* ~> z'; admininstr'*

rule Step/ctxt-frame:
s; f; (FRAME_ n `{f'} instr*) ~> s'; f; (FRAME_ n `{f'} instr'*)
-- Step: s; f'; instr* ~> s'; f'; instr'*
s; f; (FRAME_ n `{f'} admininstr*) ~> s'; f; (FRAME_ n `{f''} admininstr'*)
-- Step: s; f'; admininstr* ~> s'; f''; admininstr'*

rule Step/ctxt-instrs:
z; val* admininstr* admininstr_1* ~> z'; val* admininstr'* admininstr_1*
-- Step: z; admininstr* ~> z'; admininstr'*
-- if val* =/= eps \/ admininstr_1* =/= eps


;; Numeric instructions
Expand Down
6 changes: 3 additions & 3 deletions specification/wasm-2.0/1-syntax.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ syntax valtype hint(desc "value type") =

syntax Inn hint(show I#n) = I32 | I64
syntax Fnn hint(show F#n) = F32 | F64
syntax Vnn hint(show V#n) = V128
syntax Vnn hint(show V#n) = vectype


syntax resulttype hint(desc "result type") =
Expand All @@ -152,9 +152,9 @@ syntax resulttype hint(desc "result type") =
syntax packtype hint(desc "packed type") = I8 | I16
syntax lanetype hint(desc "lane type") = numtype | packtype

syntax Pnn hint(show I#n) = I8 | I16
syntax Pnn hint(show I#n) = packtype
syntax Jnn hint(show I#n) = Inn | Pnn
syntax Lnn hint(show I#n) = Inn | Fnn | Pnn
syntax Lnn hint(show I#n) = lanetype


;; External types
Expand Down
20 changes: 12 additions & 8 deletions specification/wasm-2.0/8-reduction.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ relation Step_read: config ~> admininstr* hint(show "E") hint(tabular)
relation Steps: config ~>* config hint(show "E") hint(tabular)

rule Step/pure:
z; instr* ~> z; instr'*
-- Step_pure: instr* ~> instr'*
z; admininstr* ~> z; admininstr'*
-- Step_pure: admininstr* ~> admininstr'*

rule Step/read:
z; instr* ~> z; instr'*
-- Step_read: z; instr* ~> instr'*
z; admininstr* ~> z; admininstr'*
-- Step_read: z; admininstr* ~> admininstr'*

rule Steps/refl:
z; admininstr* ~>* z; admininstr*
Expand Down Expand Up @@ -161,13 +161,17 @@ rule Step_pure/trap-frame:
;; Context

rule Step/ctxt-label:
z; (LABEL_ n `{instr_0*} instr*) ~> z'; (LABEL_ n `{instr_0*} instr'*)
-- Step: z; instr* ~> z'; instr'*
z; (LABEL_ n `{instr_0*} admininstr*) ~> z'; (LABEL_ n `{instr_0*} admininstr'*)
-- Step: z; admininstr* ~> z'; admininstr'*

rule Step/ctxt-frame:
s; f; (FRAME_ n `{f'} instr*) ~> s'; f; (FRAME_ n `{f'} instr'*)
-- Step: s; f'; instr* ~> s'; f'; instr'*
s; f; (FRAME_ n `{f'} admininstr*) ~> s'; f; (FRAME_ n `{f''} admininstr'*)
-- Step: s; f'; admininstr* ~> s'; f''; admininstr'*

rule Step/ctxt-instrs:
z; val* admininstr* admininstr_1* ~> z'; val* admininstr'* admininstr_1*
-- Step: z; admininstr* ~> z'; admininstr'*
-- if val* =/= eps \/ admininstr_1* =/= eps

;; Numeric instructions

Expand Down
6 changes: 3 additions & 3 deletions specification/wasm-3.0/1.2-syntax.types.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ syntax valtype/sem =
| ... | BOT


syntax Inn hint(show I#N) hint(macro "nt%") = I32 | I64
syntax Inn hint(show I#N) hint(macro "nt%") = addrtype
syntax Fnn hint(show F#N) hint(macro "nt%") = F32 | F64
syntax Vnn hint(show V#N) hint(macro "nt%") = V128
syntax Vnn hint(show V#N) hint(macro "nt%") = vectype
syntax Cnn hint(show t) = Inn | Fnn | Vnn


Expand Down Expand Up @@ -94,7 +94,7 @@ syntax storagetype hint(desc "storage type") = valtype | packtype

syntax Pnn hint(show I#N) hint(macro "nt%") = packtype
syntax Jnn hint(show I#N) hint(macro "nt%") = Inn | Pnn
syntax Lnn hint(show I#N) hint(macro "nt%") = Inn | Fnn | Pnn
syntax Lnn hint(show I#N) hint(macro "nt%") = lanetype


;; Result types
Expand Down
Binary file modified spectec/doc/example/output/NanoWasm.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions spectec/src/backend-ast/print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ and exp e =
| CatE (e1, e2) -> Node ("cat", [exp e1; exp e2])
| CvtE (e1, nt1, nt2) -> Node ("cvt", [numtyp nt1; numtyp nt2; exp e1])
| SubE (e1, t1, t2) -> Node ("sub", [typ t1; typ t2; exp e1])
| IfE (e1, e2, e3) -> Node ("if", [exp e1; exp e2; exp e3])

and expfield (at, e) =
Node ("field", [mixop (Mixop.Atom at); exp e])
Expand Down Expand Up @@ -165,6 +166,7 @@ and prem pr =
| LetPr (e1, e2, _xs) -> Node ("let", [exp e1; exp e2])
| ElsePr -> Atom "else"
| IterPr (pr1, it) -> Node ("iter", [prem pr1] @ iterexp it)
| NegPr pr1 -> Node ("neg", [prem pr1])


(* Definitions *)
Expand Down
2 changes: 1 addition & 1 deletion spectec/src/backend-interpreter/interpreter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ and check_type ty v expr =
boolV (ty = "val")
(* numtype *)
| CaseV (nt, []) when List.mem nt inn_types ->
boolV (ty = "Inn" || ty = "Jnn" || ty = "numtype" || ty = "valtype" || ty = "consttype")
boolV (ty = "Inn" || ty = "Jnn" || ty = "numtype" || ty = "valtype" || ty = "consttype" || ty = "addrtype")
| CaseV (nt, []) when List.mem nt fnn_types ->
boolV (ty = "Fnn" || ty = "numtype" || ty = "valtype" || ty = "consttype")
| CaseV (vt, []) when List.mem vt vnn_types ->
Expand Down
65 changes: 63 additions & 2 deletions spectec/src/exe-spectec/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,35 @@ type pass =
| Totalize
| Unthe
| Sideconditions
| TypeFamilyRemoval
| Else
| Undep
| SubExpansion
| Uncaseremoval
| AliasDemut
| ImproveIds
| Ite

(* This list declares the intended order of passes.
Because passes have dependencies, and because some flags enable multiple
passers (--all-passes, some targets), we do _not_ want to use the order of
flags on the command line.
*)
let _skip_passes = [ Sub; Unthe ] (* Not clear how to extend them to indexed types *)
let all_passes = [ Totalize; Sideconditions ]
let _skip_passes = [ Unthe ] (* Not clear how to extend them to indexed types *)
let all_passes = [
Ite;
TypeFamilyRemoval;
Undep;
Totalize;
Else;
Uncaseremoval;
Sideconditions;
SubExpansion;
Sub;
AliasDemut;
ImproveIds
]

type file_kind =
| Spec
Expand All @@ -53,6 +73,7 @@ let print_el = ref false
let print_elab_il = ref false
let print_final_il = ref false
let print_all_il = ref false
let print_all_il_to = ref ""
let print_al = ref false
let print_al_o = ref ""
let print_no_pos = ref false
Expand All @@ -65,6 +86,16 @@ let enable_pass pass = selected_passes := PS.add pass !selected_passes
let print_il il =
Printf.printf "%s\n%!" (Il.Print.string_of_script ~suppress_pos:(!print_no_pos) il)

let print_il_to pass_name pass_count il =
let pass_name = if pass_name = "" then "elab" else pass_name in
let pass_name = Printf.sprintf "%02d-%s" pass_count pass_name in
if !print_all_il_to <> "" then
let filename = Str.replace_first (Str.regexp "%s") pass_name !print_all_il_to in
Out_channel.with_open_text filename (fun oc ->
Out_channel.output_string oc (Il.Print.string_of_script ~suppress_pos:(!print_no_pos) il);
Out_channel.output_string oc "\n"
)


(* Il pass metadata *)

Expand All @@ -73,18 +104,43 @@ let pass_flag = function
| Totalize -> "totalize"
| Unthe -> "the-elimination"
| Sideconditions -> "sideconditions"
| TypeFamilyRemoval -> "typefamily-removal"
| AliasDemut -> "alias-demut"
| Else -> "else"
| Undep -> "remove-indexed-types"
| SubExpansion -> "sub-expansion"
| Uncaseremoval -> "uncase-removal"
| ImproveIds -> "improve-ids"
| Ite -> "ite"

let pass_desc = function
| Sub -> "Synthesize explicit subtype coercions"
| Totalize -> "Run function totalization"
| Unthe -> "Eliminate the ! operator in relations"
| Sideconditions -> "Infer side conditions"
| TypeFamilyRemoval -> "Transform Type families into sum types"
| Else -> "Eliminate the otherwise premise in relations"
| Undep -> "Transform indexed types into types with well-formedness predicates"
| SubExpansion -> "Expands subtype matching"
| Uncaseremoval -> "Eliminate the uncase expression"
| AliasDemut -> "Lifts type aliases out of mutual groups"
| ImproveIds -> "Disambiguates ids used from each other"
| Ite -> "If-then-else introduction"


let run_pass : pass -> Il.Ast.script -> Il.Ast.script = function
| Sub -> Middlend.Sub.transform
| Totalize -> Middlend.Totalize.transform
| Unthe -> Middlend.Unthe.transform
| Sideconditions -> Middlend.Sideconditions.transform
| TypeFamilyRemoval -> Middlend.Typefamilyremoval.transform
| Else -> Middlend.Else.transform
| Undep -> Middlend.Undep.transform
| SubExpansion -> Middlend.Subexpansion.transform
| Uncaseremoval -> Middlend.Uncaseremoval.transform
| AliasDemut -> Middlend.AliasDemut.transform
| ImproveIds -> Middlend.Improveids.transform
| Ite -> Middlend.Ite.transform


(* Argument parsing *)
Expand Down Expand Up @@ -150,6 +206,7 @@ let argspec = Arg.align (
"--print-il", Arg.Set print_elab_il, " Print IL (after elaboration)";
"--print-final-il", Arg.Set print_final_il, " Print final IL";
"--print-all-il", Arg.Set print_all_il, " Print IL after each step";
"--print-all-il-to", Arg.Set_string print_all_il_to, " Print IL after each step to file (with %s replaced by pass numer and name)";
"--print-al", Arg.Set print_al, " Print al";
"--print-al-o", Arg.Set_string print_al_o, " Print al with given name";
"--print-il-notes", Arg.Set Il.Print.print_notes, " Print IL with type annotations";
Expand All @@ -171,6 +228,7 @@ let log s = if !logging then Printf.printf "== %s\n%!" s
let () =
Printexc.record_backtrace true;
let last_pass = ref "" in
let pass_count = ref 0 in
try
Arg.parse argspec add_arg usage;
log "Parsing...";
Expand All @@ -180,6 +238,7 @@ let () =
log "Elaboration...";
let il, elab_env = Frontend.Elab.elab el in
if !print_elab_il || !print_all_il then print_il il;
print_il_to !last_pass !pass_count il;
log "IL Validation...";
Il.Valid.valid il;

Expand All @@ -196,9 +255,11 @@ let () =
if not (PS.mem pass !selected_passes) then il else
(
last_pass := pass_flag pass;
pass_count := !pass_count + 1;
log ("Running pass " ^ pass_flag pass ^ "...");
let il = run_pass pass il in
if !print_all_il then print_il il;
print_il_to !last_pass !pass_count il;
log ("IL Validation after pass " ^ pass_flag pass ^ "...");
Il.Valid.valid il;
il
Expand Down
6 changes: 3 additions & 3 deletions spectec/src/frontend/det.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ and det_exp e =
) @@ fun _ ->
match e.it with
| VarE x -> bound_varid x
| BoolE _ | NumE _ | TextE _ -> empty
| BoolE _ | NumE _ | TextE _ | IfE _ -> empty
(* We consider arithmetic expressions determinate,
* since we sometimes need to use invertible formulas. *)
| CvtE (e1, _, _) | UnE (#Xl.Num.unop, _, e1) | TheE e1 | LiftE e1
Expand Down Expand Up @@ -121,7 +121,7 @@ and det_quant_exp e =
) @@ fun _ ->
match e.it with
| VarE x -> bound_varid x
| BoolE _ | NumE _ | TextE _ -> empty
| BoolE _ | NumE _ | TextE _ | IfE _ -> empty
| UnE (_, _, e1) | ProjE (e1, _) | TheE e1 | LiftE e1 | LenE e1
| CvtE (e1, _, _) | SubE (e1, _, _) ->
det_quant_exp e1
Expand Down Expand Up @@ -189,7 +189,7 @@ and det_prem pr =
| RulePr (_x, _as, _mixop, e) -> det_exp e
| IfPr e -> det_cond_exp e
| LetPr (e1, _e2, _xs) -> det_exp e1
| ElsePr -> empty
| ElsePr | NegPr _ -> empty
| IterPr (pr1, ite) -> det_iterexp (det_prem pr1) ite


Expand Down
13 changes: 12 additions & 1 deletion spectec/src/frontend/dim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ and check_exp dims ctx e =
| CompE (e1, e2) ->
check_exp dims ctx e1;
check_exp dims ctx e2
| SliceE (e1, e2, e3) ->
| SliceE (e1, e2, e3)
| IfE (e1, e2, e3) ->
check_exp dims ctx e1;
check_exp dims ctx e2;
check_exp dims ctx e3
Expand Down Expand Up @@ -265,6 +266,8 @@ and check_prem dims ctx prem =
check_exp dims ctx e2
| IterPr (prem1, ite) ->
check_iterexp dims ctx check_prem prem1 ite
| NegPr prem1 ->
check_prem dims ctx prem1

and check_arg dims ctx a =
match a.it with
Expand Down Expand Up @@ -567,6 +570,11 @@ and annot_exp side dims e : exp * occur =
| CaseE (atom, e1) ->
let e1', occur1 = annot_exp side dims e1 in
CaseE (atom, e1'), occur1
| IfE (e1, e2, e3) ->
let e1', occur1 = annot_exp side dims e1 in
let e2', occur2 = annot_exp side dims e2 in
let e3', occur3 = annot_exp side dims e3 in
IfE (e1', e2', e3'), union occur1 (union occur2 occur3)
| CvtE (e1, nt1, nt2) ->
let e1', occur1 = annot_exp side dims e1 in
CvtE (e1', nt1, nt2), occur1
Expand Down Expand Up @@ -688,6 +696,9 @@ and annot_prem dims prem : prem * occur =
let prem1', occur1 = annot_prem dims prem1 in
let iter', occur' = annot_iterexp `Rhs dims occur1 iter prem.at in
IterPr (prem1', iter'), occur'
| NegPr prem1 ->
let prem1', occur1 = annot_prem dims prem1 in
NegPr prem1', occur1
in {prem with it}, occur

(*
Expand Down
2 changes: 2 additions & 0 deletions spectec/src/il/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ and exp' =
| SliceE of exp * exp * exp (* exp[exp : exp] *)
| UpdE of exp * path * exp (* exp[path = exp] *)
| ExtE of exp * path * exp (* exp[path =.. exp] *)
| IfE of exp * exp * exp (* `if` exp exp exp *)
| CallE of id * arg list (* defid( arg* ) *)
| IterE of exp * iterexp (* exp iter *)
| CvtE of exp * numtyp * numtyp (* exp : typ1 <:> typ2 *)
Expand Down Expand Up @@ -159,6 +160,7 @@ and prem' =
| LetPr of exp * exp * string list (* binding *)
| ElsePr (* otherwise *)
| IterPr of prem * iterexp (* iteration *)
| NegPr of prem (* negated premise *)

and hintdef = hintdef' phrase
and hintdef' =
Expand Down
2 changes: 1 addition & 1 deletion spectec/src/il/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(library
(name il)
(libraries util zarith xl el)
(modules ast eq free fresh subst iter env eval print debug valid)
(modules ast eq free fresh subst iter walk env eval print debug valid)
)
Loading
Loading