From fe80ad7c920dd59bbfe5f836c805504a4e4b531b Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Sat, 8 Apr 2023 21:56:17 +0200 Subject: [PATCH 1/3] Il.Eq improvements --- spectec/src/il/eq.ml | 16 ++++++++++++++-- spectec/src/il/eq.mli | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/spectec/src/il/eq.ml b/spectec/src/il/eq.ml index 8e10ac8877..5853720947 100644 --- a/spectec/src/il/eq.ml +++ b/spectec/src/il/eq.ml @@ -51,7 +51,7 @@ and eq_typ t1 t2 = and eq_exp e1 e2 = e1.it = e2.it || match e1.it, e2.it with - | VarE id1, VarE id2 -> id1.it = id2.it + | VarE id1, VarE id2 -> eq_id id1 id2 | UnE (op1, e11), UnE (op2, e21) -> op1 = op2 && eq_exp e11 e21 | BinE (op1, e11, e12), BinE (op2, e21, e22) -> op1 = op2 && eq_exp e11 e21 && eq_exp e12 e22 @@ -72,10 +72,11 @@ and eq_exp e1 e2 = | DotE (t1, e11, atom1), DotE (t2, e21, atom2) -> eq_typ t1 t2 && eq_exp e11 e21 && atom1 = atom2 | MixE (op1, e1), MixE (op2, e2) -> op1 = op2 && eq_exp e1 e2 - | CallE (id1, e1), CallE (id2, e2) -> id1 = id2 && eq_exp e1 e2 + | CallE (id1, e1), CallE (id2, e2) -> eq_id id1 id2 && eq_exp e1 e2 | IterE (e11, iter1), IterE (e21, iter2) -> eq_exp e11 e21 && eq_iterexp iter1 iter2 | OptE eo1, OptE eo2 -> eq_opt eq_exp eo1 eo2 + | TheE e1, TheE e2 -> eq_exp e1 e2 | CaseE (atom1, e1, t1), CaseE (atom2, e2, t2) -> atom1 = atom2 && eq_exp e1 e2 && eq_typ t1 t2 | SubE (e1, t11, t12), SubE (e2, t21, t22) -> @@ -94,3 +95,14 @@ and eq_path p1 p2 = and eq_iterexp (iter1, ids1) (iter2, ids2) = eq_iter iter1 iter2 && eq_list eq_id ids1 ids2 + +let rec eq_prem prem1 prem2 = + prem1.it = prem2.it || + match prem1.it, prem2.it with + | RulePr (id1, op1, e1), RulePr (id2, op2, e2) -> + eq_id id1 id2 && op1 = op2 && eq_exp e1 e2 + | IfPr e1, IfPr e2 -> eq_exp e1 e2 + | ElsePr, ElsePr -> true + | IterPr (prem1, iterexp1), IterPr (prem2, iterexp2) -> + eq_prem prem1 prem2 && eq_iterexp iterexp1 iterexp2 + | _, _ -> false diff --git a/spectec/src/il/eq.mli b/spectec/src/il/eq.mli index f93fec6167..e045a14257 100644 --- a/spectec/src/il/eq.mli +++ b/spectec/src/il/eq.mli @@ -1,5 +1,7 @@ open Ast +val eq_id : id -> id -> bool val eq_iter : iter -> iter -> bool val eq_typ : typ -> typ -> bool val eq_exp : exp -> exp -> bool +val eq_prem : premise -> premise -> bool From 4fba8fc7811338b2c94a2d7d602b47f89f5de5ed Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Thu, 13 Apr 2023 14:08:37 +0200 Subject: [PATCH 2/3] Il-to-IL pass: Infer sideconditions This transformation make explicit the following implicit side conditions of terms in premises and conclusions: * Array access a[i] i < |a| * Joint iteration e*{v1,v2} |v1*| = |v2*| * Option projection !(e) e =!= null Depends upon #6 and #5. --- spectec/src/exe-watsup/main.ml | 11 + spectec/src/middlend/dune | 2 +- spectec/src/middlend/sideconditions.ml | 126 + spectec/src/middlend/sideconditions.mli | 1 + spectec/src/util/lib.ml | 4 + spectec/src/util/lib.mli | 1 + spectec/test-frontend/TEST.md | 3451 +---------------------- spectec/test-middlend/TEST.md | 1560 +++++++++- 8 files changed, 1706 insertions(+), 3450 deletions(-) create mode 100644 spectec/src/middlend/sideconditions.ml create mode 100644 spectec/src/middlend/sideconditions.mli diff --git a/spectec/src/exe-watsup/main.ml b/spectec/src/exe-watsup/main.ml index 7e2d2a2099..3782a8bf6b 100644 --- a/spectec/src/exe-watsup/main.ml +++ b/spectec/src/exe-watsup/main.ml @@ -30,6 +30,7 @@ let print_final_il = ref false let print_all_il = ref false let pass_totalize = ref false +let pass_sideconditions = ref false (* Argument parsing *) @@ -55,6 +56,7 @@ let argspec = Arg.align "--print-all-il", Arg.Set print_all_il, "Print il after each step"; "--totalize", Arg.Set pass_totalize, "Run function totalization"; + "--sideconditions", Arg.Set pass_sideconditions, "Infer side conditoins"; "--check-only", Arg.Unit (fun () -> target := None), " No output (just checking)"; "--latex", Arg.Unit (fun () -> target := Latex Backend_latex.Config.latex), " Use Latex settings (default)"; @@ -91,6 +93,15 @@ let () = il end else il in + let il = if !pass_sideconditions then begin + log "Side condition inference"; + let il = Middlend.Sideconditions.transform il in + if !print_all_il then Printf.printf "%s\n%!" (Il.Print.string_of_script il); + log "IL Validation..."; + Il.Validation.valid il; + il + end else il in + if !print_final_il && not !print_all_il then Printf.printf "%s\n%!" (Il.Print.string_of_script il); begin match !target with diff --git a/spectec/src/middlend/dune b/spectec/src/middlend/dune index 4a0111ab9f..3ea277d1b2 100644 --- a/spectec/src/middlend/dune +++ b/spectec/src/middlend/dune @@ -1,5 +1,5 @@ (library (name middlend) (libraries util il) - (modules totalize) + (modules totalize sideconditions) ) diff --git a/spectec/src/middlend/sideconditions.ml b/spectec/src/middlend/sideconditions.ml new file mode 100644 index 0000000000..7aefd0bf2a --- /dev/null +++ b/spectec/src/middlend/sideconditions.ml @@ -0,0 +1,126 @@ +(* +This transformation make explicit the following implicit side conditions +of terms in premises and conclusions: + + * Array access a[i] i < |a| + * Joint iteration e*{v1,v2} |v1*| = |v2*| + * Option projection !(e) e =!= null + +(The option projection would probably be nicer by rewriting !(e) to a fresh +variable x and require e=?x. Maybe later.) +*) + +open Util +open Source +open Il.Ast + +(* Errors *) + +let _error at msg = Source.error at "sideconditions" msg + +let is_null e = CmpE (EqOp, e, OptE None $ no_region) $ no_region +let iffE e1 e2 = IfPr (BinE (EquivOp, e1, e2) $ no_region) $ no_region +let same_len e1 e2 = IfPr (CmpE (EqOp, LenE e1 $ no_region, LenE e2 $ no_region) $ no_region) $ no_region +let has_len ne e = IfPr (CmpE (EqOp, LenE e $ no_region, ne) $ no_region) $ no_region + +let iter_side_conditions ((iter, vs) : iterexp) : premise list = + let ves = List.map (fun v -> IterE (VarE v $ no_region, (iter, [v])) $ no_region) vs in + match iter, ves with + | _, [] -> [] + | Opt, (e::es) -> List.map (fun e' -> iffE (is_null e) (is_null e')) es + | (List|List1), (e::es) -> List.map (same_len e) es + | ListN ne, es -> List.map (has_len ne) es + +(* Expr traversal *) +let rec t_exp e : premise list = + (* First the conditions to be generated here *) + begin match e.it with + | IdxE (exp1, exp2) -> + [IfPr (CmpE (LtOp, exp2, LenE exp1 $ no_region) $ no_region) $ no_region] + | TheE exp -> + [IfPr (CmpE (NeOp, exp, OptE None $ no_region) $ no_region) $ no_region] + | IterE (_exp, iterexp) -> iter_side_conditions iterexp + | _ -> [] + end @ + (* And now descend *) + match e.it with + | VarE _ | BoolE _ | NatE _ | TextE _ | OptE None + -> [] + | UnE (_, exp) + | DotE (_, exp, _) + | LenE exp + | MixE (_, exp) + | CallE (_, exp) + | OptE (Some exp) + | TheE exp + | CaseE (_, exp, _) + | SubE (exp, _, _) + -> t_exp exp + | BinE (_, exp1, exp2) + | CmpE (_, exp1, exp2) + | IdxE (exp1, exp2) + | CompE (exp1, exp2) + | CatE (exp1, exp2) + -> t_exp exp1 @ t_exp exp2 + | SliceE (exp1, exp2, exp3) + -> t_exp exp1 @ t_exp exp2 @ t_exp exp3 + | UpdE (exp1, path, exp2) + | ExtE (exp1, path, exp2) + -> t_exp exp1 @ t_path path @ t_exp exp2 + | StrE fields + -> List.concat_map (fun (_, e) -> t_exp e) fields + | TupE es | ListE es + -> List.concat_map t_exp es + | IterE (e, iterexp) + -> List.map (fun pr -> IterPr (pr, iterexp) $ no_region) (t_exp e) @ t_iterexp iterexp + +and t_iterexp (iter, _) = t_iter iter + +and t_iter = function + | ListN e -> t_exp e + | _ -> [] + +and t_path path = match path.it with + | RootP -> [] + | IdxP (path, e) -> t_path path @ t_exp e + | DotP (path, _) -> t_path path + + +let rec t_prem prem = match prem.it with + | RulePr (_, _, exp) -> t_exp exp + | IfPr e -> t_exp e + | ElsePr -> [] + | IterPr (prem, iterexp) + -> iter_side_conditions iterexp @ + List.map (fun pr -> IterPr (pr, iterexp) $ no_region) (t_prem prem) @ t_iterexp iterexp + +let t_prems = List.concat_map t_prem + +(* Does prem1 obviously imply prem2? *) +let rec implies prem1 prem2 = Il.Eq.eq_prem prem1 prem2 || + match prem2.it with + | IterPr (prem2', _) -> implies prem1 prem2' + | _ -> false + + +let t_rule' = function + | RuleD (id, binds, mixop, exp, prems) -> + let extra_prems = t_prems prems @ t_exp exp in + let prems' = Util.Lib.List.nub implies (extra_prems @ prems) in + RuleD (id, binds, mixop, exp, prems') + +let t_rule x = { x with it = t_rule' x.it } + +let t_rules = List.map t_rule + +let rec t_def' = function + | RecD defs -> RecD (List.map t_def defs) + | RelD (id, mixop, typ, rules, hints) -> + RelD (id, mixop, typ, t_rules rules, hints) + | def -> def + +and t_def x = { x with it = t_def' x.it } + +let transform (defs : script) = + List.map t_def defs + diff --git a/spectec/src/middlend/sideconditions.mli b/spectec/src/middlend/sideconditions.mli new file mode 100644 index 0000000000..542bbf8052 --- /dev/null +++ b/spectec/src/middlend/sideconditions.mli @@ -0,0 +1 @@ +val transform : Il.Ast.script -> Il.Ast.script diff --git a/spectec/src/util/lib.ml b/spectec/src/util/lib.ml index 3fbb4cd8f4..e681b2beef 100644 --- a/spectec/src/util/lib.ml +++ b/spectec/src/util/lib.ml @@ -10,6 +10,10 @@ struct | x::[] -> [], x | x::xs -> let ys, y = split_last xs in x::ys, y | [] -> failwith "split_last" + + let rec nub pred = function + | [] -> [] + | x::xs -> x :: nub pred (List.filter (fun y -> not (pred x y)) xs) end module String = diff --git a/spectec/src/util/lib.mli b/spectec/src/util/lib.mli index 69f0b55445..873e2e9f3c 100644 --- a/spectec/src/util/lib.mli +++ b/spectec/src/util/lib.mli @@ -4,6 +4,7 @@ module List : sig val split_hd : 'a list -> 'a * 'a list (* raises Failure *) val split_last : 'a list -> 'a list * 'a (* raises Failure *) + val nub : ('a -> 'a -> bool) -> 'a list -> 'a list end module String : diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index ef9234c587..e911641a8d 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -2,3452 +2,7 @@ ```sh $ (cd ../spec && dune exec ../src/exe-watsup/main.exe -- *.watsup -v -l --print-il) -watsup 0.3 generator -== Parsing... -== Elaboration... - -;; 1-syntax.watsup:3.1-3.15 -syntax n = nat - -;; 1-syntax.watsup:9.1-9.37 -syntax name = text - -;; 1-syntax.watsup:14.1-14.36 -syntax byte = nat - -;; 1-syntax.watsup:15.1-15.45 -syntax u32 = nat - -;; 1-syntax.watsup:22.1-22.36 -syntax idx = nat - -;; 1-syntax.watsup:23.1-23.49 -syntax funcidx = idx - -;; 1-syntax.watsup:24.1-24.49 -syntax globalidx = idx - -;; 1-syntax.watsup:25.1-25.47 -syntax tableidx = idx - -;; 1-syntax.watsup:26.1-26.46 -syntax memidx = idx - -;; 1-syntax.watsup:27.1-27.45 -syntax elemidx = idx - -;; 1-syntax.watsup:28.1-28.45 -syntax dataidx = idx - -;; 1-syntax.watsup:29.1-29.47 -syntax labelidx = idx - -;; 1-syntax.watsup:30.1-30.47 -syntax localidx = idx - -;; 1-syntax.watsup:39.1-40.22 -syntax numtype = - | I32 - | I64 - | F32 - | F64 - -;; 1-syntax.watsup:41.1-42.5 -syntax vectype = - | V128 - -;; 1-syntax.watsup:43.1-44.20 -syntax reftype = - | FUNCREF - | EXTERNREF - -;; 1-syntax.watsup:45.1-46.34 -syntax valtype = - | I32 - | I64 - | F32 - | F64 - | V128 - | FUNCREF - | EXTERNREF - | BOT - -;; 1-syntax.watsup:48.1-48.39 -syntax in = - | I32 - | I64 - -;; 1-syntax.watsup:49.1-49.39 -syntax fn = - | F32 - | F64 - -;; 1-syntax.watsup:56.1-57.11 -syntax resulttype = valtype* - -;; 1-syntax.watsup:59.1-60.16 -syntax limits = `[%..%]`(u32, u32) - -;; 1-syntax.watsup:61.1-62.15 -syntax globaltype = `MUT%?%`(()?, valtype) - -;; 1-syntax.watsup:63.1-64.27 -syntax functype = `%->%`(resulttype, resulttype) - -;; 1-syntax.watsup:65.1-66.17 -syntax tabletype = `%%`(limits, reftype) - -;; 1-syntax.watsup:67.1-68.12 -syntax memtype = `%I8`(limits) - -;; 1-syntax.watsup:69.1-70.10 -syntax elemtype = reftype - -;; 1-syntax.watsup:71.1-72.5 -syntax datatype = OK - -;; 1-syntax.watsup:73.1-74.69 -syntax externtype = - | GLOBAL(globaltype) - | FUNC(functype) - | TABLE(tabletype) - | MEMORY(memtype) - -;; 1-syntax.watsup:86.1-86.44 -syntax sx = - | U - | S - -;; 1-syntax.watsup:88.1-88.39 -syntax unop_IXX = - | CLZ - | CTZ - | POPCNT - -;; 1-syntax.watsup:89.1-89.70 -syntax unop_FXX = - | ABS - | NEG - | SQRT - | CEIL - | FLOOR - | TRUNC - | NEAREST - -;; 1-syntax.watsup:91.1-93.62 -syntax binop_IXX = - | ADD - | SUB - | MUL - | DIV(sx) - | REM(sx) - | AND - | OR - | XOR - | SHL - | SHR(sx) - | ROTL - | ROTR - -;; 1-syntax.watsup:94.1-94.66 -syntax binop_FXX = - | ADD - | SUB - | MUL - | DIV - | MIN - | MAX - | COPYSIGN - -;; 1-syntax.watsup:96.1-96.26 -syntax testop_IXX = - | EQZ - -;; 1-syntax.watsup:97.1-97.22 -syntax testop_FXX = - | - -;; 1-syntax.watsup:99.1-100.108 -syntax relop_IXX = - | EQ - | NE - | LT(sx) - | GT(sx) - | LE(sx) - | GE(sx) - -;; 1-syntax.watsup:101.1-101.49 -syntax relop_FXX = - | EQ - | NE - | LT - | GT - | LE - | GE - -;; 1-syntax.watsup:103.1-103.50 -syntax unop_numtype = - | _I(unop_IXX) - | _F(unop_FXX) - -;; 1-syntax.watsup:104.1-104.53 -syntax binop_numtype = - | _I(binop_IXX) - | _F(binop_FXX) - -;; 1-syntax.watsup:105.1-105.56 -syntax testop_numtype = - | _I(testop_IXX) - | _F(testop_FXX) - -;; 1-syntax.watsup:106.1-106.53 -syntax relop_numtype = - | _I(relop_IXX) - | _F(relop_FXX) - -;; 1-syntax.watsup:107.1-107.39 -syntax cvtop = - | CONVERT - | REINTERPRET - -;; 1-syntax.watsup:117.1-117.23 -syntax c_numtype = nat - -;; 1-syntax.watsup:118.1-118.23 -syntax c_vectype = nat - -;; 1-syntax.watsup:121.1-121.52 -syntax blocktype = functype - -;; 1-syntax.watsup:156.1-177.55 -rec { - -;; 1-syntax.watsup:156.1-177.55 -syntax instr = - | UNREACHABLE - | NOP - | DROP - | SELECT(valtype?) - | BLOCK(blocktype, instr*) - | LOOP(blocktype, instr*) - | IF(blocktype, instr*, instr*) - | BR(labelidx) - | BR_IF(labelidx) - | BR_TABLE(labelidx*, labelidx) - | CALL(funcidx) - | CALL_INDIRECT(tableidx, functype) - | RETURN - | CONST(numtype, c_numtype) - | UNOP(numtype, unop_numtype) - | BINOP(numtype, binop_numtype) - | TESTOP(numtype, testop_numtype) - | RELOP(numtype, relop_numtype) - | EXTEND(numtype, n) - | CVTOP(numtype, cvtop, numtype, sx?) - | REF.NULL(reftype) - | REF.FUNC(funcidx) - | REF.IS_NULL - | LOCAL.GET(localidx) - | LOCAL.SET(localidx) - | LOCAL.TEE(localidx) - | GLOBAL.GET(globalidx) - | GLOBAL.SET(globalidx) - | TABLE.GET(tableidx) - | TABLE.SET(tableidx) - | TABLE.SIZE(tableidx) - | TABLE.GROW(tableidx) - | TABLE.FILL(tableidx) - | TABLE.COPY(tableidx, tableidx) - | TABLE.INIT(tableidx, elemidx) - | ELEM.DROP(elemidx) - | MEMORY.SIZE - | MEMORY.GROW - | MEMORY.FILL - | MEMORY.COPY - | MEMORY.INIT(dataidx) - | DATA.DROP(dataidx) - | LOAD(numtype, (n, sx)?, nat, nat) - | STORE(numtype, n?, nat, nat) -} - -;; 1-syntax.watsup:179.1-180.9 -syntax expr = instr* - -;; 1-syntax.watsup:185.1-185.50 -syntax elemmode = - | TABLE(tableidx, expr) - | DECLARE - -;; 1-syntax.watsup:186.1-186.39 -syntax datamode = - | MEMORY(memidx, expr) - -;; 1-syntax.watsup:188.1-189.30 -syntax func = `FUNC%%*%`(functype, valtype*, expr) - -;; 1-syntax.watsup:190.1-191.25 -syntax global = GLOBAL(globaltype, expr) - -;; 1-syntax.watsup:192.1-193.18 -syntax table = TABLE(tabletype) - -;; 1-syntax.watsup:194.1-195.17 -syntax mem = MEMORY(memtype) - -;; 1-syntax.watsup:196.1-197.31 -syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) - -;; 1-syntax.watsup:198.1-199.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) - -;; 1-syntax.watsup:200.1-201.16 -syntax start = START(funcidx) - -;; 1-syntax.watsup:203.1-204.65 -syntax externuse = - | FUNC(funcidx) - | GLOBAL(globalidx) - | TABLE(tableidx) - | MEMORY(memidx) - -;; 1-syntax.watsup:205.1-206.24 -syntax export = EXPORT(name, externuse) - -;; 1-syntax.watsup:207.1-208.30 -syntax import = IMPORT(name, name, externtype) - -;; 1-syntax.watsup:210.1-211.70 -syntax module = `MODULE%*%*%*%*%*%*%*%*%*`(import*, func*, global*, table*, mem*, elem*, data*, start*, export*) - -;; 2-aux.watsup:5.1-5.55 -def size : valtype -> nat - ;; 2-aux.watsup:6.1-6.20 - def size(I32_valtype) = 32 - ;; 2-aux.watsup:7.1-7.20 - def size(I64_valtype) = 64 - ;; 2-aux.watsup:8.1-8.20 - def size(F32_valtype) = 32 - ;; 2-aux.watsup:9.1-9.20 - def size(F64_valtype) = 64 - ;; 2-aux.watsup:10.1-10.22 - def size(V128_valtype) = 128 - -;; 2-aux.watsup:15.1-15.40 -def test_sub_ATOM_22 : n -> nat - ;; 2-aux.watsup:16.1-16.38 - def {n_3_ATOM_y : n} test_sub_ATOM_22(n_3_ATOM_y) = 0 - -;; 2-aux.watsup:18.1-18.26 -def curried_ : (n, n) -> nat - ;; 2-aux.watsup:19.1-19.39 - def {n_1 : n, n_2 : n} curried_(n_1, n_2) = (n_1 + n_2) - -;; 2-aux.watsup:21.1-30.39 -syntax testfuse = - | AB_(nat, nat, nat) - | CD(nat, nat, nat) - | EF(nat, nat, nat) - | GH(nat, nat, nat) - | IJ(nat, nat, nat) - | KL(nat, nat, nat) - | MN(nat, nat, nat) - | OP(nat, nat, nat) - | QR(nat, nat, nat) - -;; 3-typing.watsup:3.1-6.60 -syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memtype*, ELEM elemtype*, DATA datatype*, LOCAL valtype*, LABEL resulttype*, RETURN resulttype?} - -;; 3-typing.watsup:14.1-14.66 -relation Limits_ok: `|-%:%`(limits, nat) - ;; 3-typing.watsup:22.1-24.24 - rule _ {k : nat, n_1 : n, n_2 : n}: - `|-%:%`(`[%..%]`(n_1, n_2), k) - -- if ((n_1 <= n_2) /\ (n_2 <= k)) - -;; 3-typing.watsup:15.1-15.64 -relation Functype_ok: `|-%:OK`(functype) - ;; 3-typing.watsup:26.1-27.13 - rule _ {ft : functype}: - `|-%:OK`(ft) - -;; 3-typing.watsup:16.1-16.66 -relation Globaltype_ok: `|-%:OK`(globaltype) - ;; 3-typing.watsup:29.1-30.13 - rule _ {gt : globaltype}: - `|-%:OK`(gt) - -;; 3-typing.watsup:17.1-17.65 -relation Tabletype_ok: `|-%:OK`(tabletype) - ;; 3-typing.watsup:32.1-34.35 - rule _ {lim : limits, rt : reftype}: - `|-%:OK`(`%%`(lim, rt)) - -- Limits_ok: `|-%:%`(lim, ((2 ^ 32) - 1)) - -;; 3-typing.watsup:18.1-18.63 -relation Memtype_ok: `|-%:OK`(memtype) - ;; 3-typing.watsup:36.1-38.33 - rule _ {lim : limits}: - `|-%:OK`(`%I8`(lim)) - -- Limits_ok: `|-%:%`(lim, (2 ^ 16)) - -;; 3-typing.watsup:19.1-19.66 -relation Externtype_ok: `|-%:OK`(externtype) - ;; 3-typing.watsup:41.1-43.35 - rule func {functype : functype}: - `|-%:OK`(FUNC_externtype(functype)) - -- Functype_ok: `|-%:OK`(functype) - - ;; 3-typing.watsup:45.1-47.39 - rule global {globaltype : globaltype}: - `|-%:OK`(GLOBAL_externtype(globaltype)) - -- Globaltype_ok: `|-%:OK`(globaltype) - - ;; 3-typing.watsup:49.1-51.37 - rule table {tabletype : tabletype}: - `|-%:OK`(TABLE_externtype(tabletype)) - -- Tabletype_ok: `|-%:OK`(tabletype) - - ;; 3-typing.watsup:53.1-55.33 - rule mem {memtype : memtype}: - `|-%:OK`(MEMORY_externtype(memtype)) - -- Memtype_ok: `|-%:OK`(memtype) - -;; 3-typing.watsup:61.1-61.65 -relation Valtype_sub: `|-%<:%`(valtype, valtype) - ;; 3-typing.watsup:64.1-65.12 - rule refl {t : valtype}: - `|-%<:%`(t, t) - - ;; 3-typing.watsup:67.1-68.14 - rule bot {t : valtype}: - `|-%<:%`(BOT_valtype, t) - -;; 3-typing.watsup:62.1-62.72 -relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) - ;; 3-typing.watsup:70.1-72.35 - rule _ {t_1* : valtype*, t_2* : valtype*}: - `|-%*<:%*`(t_1*{t_1}, t_2*{t_2}) - -- (Valtype_sub: `|-%<:%`(t_1, t_2))*{t_1 t_2} - -;; 3-typing.watsup:75.1-75.75 -relation Limits_sub: `|-%<:%`(limits, limits) - ;; 3-typing.watsup:83.1-86.21 - rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: - `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) - -- if (n_11 >= n_21) - -- if (n_12 <= n_22) - -;; 3-typing.watsup:76.1-76.73 -relation Functype_sub: `|-%<:%`(functype, functype) - ;; 3-typing.watsup:88.1-89.14 - rule _ {ft : functype}: - `|-%<:%`(ft, ft) - -;; 3-typing.watsup:77.1-77.75 -relation Globaltype_sub: `|-%<:%`(globaltype, globaltype) - ;; 3-typing.watsup:91.1-92.14 - rule _ {gt : globaltype}: - `|-%<:%`(gt, gt) - -;; 3-typing.watsup:78.1-78.74 -relation Tabletype_sub: `|-%<:%`(tabletype, tabletype) - ;; 3-typing.watsup:94.1-96.35 - rule _ {lim_1 : limits, lim_2 : limits, rt : reftype}: - `|-%<:%`(`%%`(lim_1, rt), `%%`(lim_2, rt)) - -- Limits_sub: `|-%<:%`(lim_1, lim_2) - -;; 3-typing.watsup:79.1-79.72 -relation Memtype_sub: `|-%<:%`(memtype, memtype) - ;; 3-typing.watsup:98.1-100.35 - rule _ {lim_1 : limits, lim_2 : limits}: - `|-%<:%`(`%I8`(lim_1), `%I8`(lim_2)) - -- Limits_sub: `|-%<:%`(lim_1, lim_2) - -;; 3-typing.watsup:80.1-80.75 -relation Externtype_sub: `|-%<:%`(externtype, externtype) - ;; 3-typing.watsup:103.1-105.35 - rule func {ft_1 : functype, ft_2 : functype}: - `|-%<:%`(FUNC_externtype(ft_1), FUNC_externtype(ft_2)) - -- Functype_sub: `|-%<:%`(ft_1, ft_2) - - ;; 3-typing.watsup:107.1-109.37 - rule global {gt_1 : globaltype, gt_2 : globaltype}: - `|-%<:%`(GLOBAL_externtype(gt_1), GLOBAL_externtype(gt_2)) - -- Globaltype_sub: `|-%<:%`(gt_1, gt_2) - - ;; 3-typing.watsup:111.1-113.36 - rule table {tt_1 : tabletype, tt_2 : tabletype}: - `|-%<:%`(TABLE_externtype(tt_1), TABLE_externtype(tt_2)) - -- Tabletype_sub: `|-%<:%`(tt_1, tt_2) - - ;; 3-typing.watsup:115.1-117.34 - rule mem {mt_1 : memtype, mt_2 : memtype}: - `|-%<:%`(MEMORY_externtype(mt_1), MEMORY_externtype(mt_2)) - -- Memtype_sub: `|-%<:%`(mt_1, mt_2) - -;; 3-typing.watsup:172.1-172.76 -relation Blocktype_ok: `%|-%:%`(context, blocktype, functype) - ;; 3-typing.watsup:174.1-176.29 - rule _ {C : context, ft : functype}: - `%|-%:%`(C, ft, ft) - -- Functype_ok: `|-%:OK`(ft) - -;; 3-typing.watsup:123.1-124.67 -rec { - -;; 3-typing.watsup:123.1-123.66 -relation Instr_ok: `%|-%:%`(context, instr, functype) - ;; 3-typing.watsup:153.1-154.34 - rule unreachable {C : context, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, UNREACHABLE_instr, `%->%`(t_1*{t_1}, t_2*{t_2})) - - ;; 3-typing.watsup:156.1-157.32 - rule nop {C : context}: - `%|-%:%`(C, NOP_instr, `%->%`([], [])) - - ;; 3-typing.watsup:159.1-160.27 - rule drop {C : context, t : valtype}: - `%|-%:%`(C, DROP_instr, `%->%`([t], [])) - - ;; 3-typing.watsup:163.1-164.31 - rule select-expl {C : context, t : valtype}: - `%|-%:%`(C, SELECT_instr(?(t)), `%->%`([t t I32_valtype], [t])) - - ;; 3-typing.watsup:166.1-169.37 - rule select-impl {C : context, numtype : numtype, t : valtype, t' : valtype, vectype : vectype}: - `%|-%:%`(C, SELECT_instr(?()), `%->%`([t t I32_valtype], [t])) - -- Valtype_sub: `|-%<:%`(t, t') - -- if ((t' = (numtype <: valtype)) \/ (t' = (vectype <: valtype))) - - ;; 3-typing.watsup:178.1-181.57 - rule block {C : context, bt : blocktype, instr* : instr*, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, BLOCK_instr(bt, instr*{instr}), `%->%`(t_1*{t_1}, t_2*{t_2})) - -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) - -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) - - ;; 3-typing.watsup:183.1-186.57 - rule loop {C : context, bt : blocktype, instr* : instr*, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, LOOP_instr(bt, instr*{instr}), `%->%`(t_1*{t_1}, t_2*{t_2})) - -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) - -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_1]*{t_1}, RETURN ?()}, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) - - ;; 3-typing.watsup:188.1-192.59 - rule if {C : context, bt : blocktype, instr_1* : instr*, instr_2* : instr*, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, IF_instr(bt, instr_1*{instr_1}, instr_2*{instr_2}), `%->%`(t_1*{t_1}, t_2*{t_2})) - -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) - -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr_1*{instr_1}, `%->%`(t_1*{t_1}, t_2*{t_2})) - -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr_2*{instr_2}, `%->%`(t_1*{t_1}, t_2*{t_2})) - - ;; 3-typing.watsup:195.1-197.24 - rule br {C : context, l : labelidx, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, BR_instr(l), `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) - -- if (C.LABEL_context[l] = t*{t}) - - ;; 3-typing.watsup:199.1-201.24 - rule br_if {C : context, l : labelidx, t* : valtype*}: - `%|-%:%`(C, BR_IF_instr(l), `%->%`(t*{t} :: [I32_valtype], t*{t})) - -- if (C.LABEL_context[l] = t*{t}) - - ;; 3-typing.watsup:203.1-206.42 - rule br_table {C : context, l* : labelidx*, l' : labelidx, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, BR_TABLE_instr(l*{l}, l'), `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) - -- (Resulttype_sub: `|-%*<:%*`(t*{t}, C.LABEL_context[l]))*{l} - -- Resulttype_sub: `|-%*<:%*`(t*{t}, C.LABEL_context[l']) - - ;; 3-typing.watsup:208.1-210.24 - rule return {C : context, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, RETURN_instr, `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) - -- if (C.RETURN_context = ?(t*{t})) - - ;; 3-typing.watsup:212.1-214.33 - rule call {C : context, t_1* : valtype*, t_2* : valtype*, x : idx}: - `%|-%:%`(C, CALL_instr(x), `%->%`(t_1*{t_1}, t_2*{t_2})) - -- if (C.FUNC_context[x] = `%->%`(t_1*{t_1}, t_2*{t_2})) - - ;; 3-typing.watsup:216.1-219.26 - rule call_indirect {C : context, ft : functype, lim : limits, t_1* : valtype*, t_2* : valtype*, x : idx}: - `%|-%:%`(C, CALL_INDIRECT_instr(x, ft), `%->%`(t_1*{t_1} :: [I32_valtype], t_2*{t_2})) - -- if (C.TABLE_context[x] = `%%`(lim, FUNCREF_reftype)) - -- if (ft = `%->%`(t_1*{t_1}, t_2*{t_2})) - - ;; 3-typing.watsup:222.1-223.37 - rule const {C : context, c_nt : c_numtype, nt : numtype}: - `%|-%:%`(C, CONST_instr(nt, c_nt), `%->%`([], [(nt <: valtype)])) - - ;; 3-typing.watsup:225.1-226.31 - rule unop {C : context, nt : numtype, unop : unop_numtype}: - `%|-%:%`(C, UNOP_instr(nt, unop), `%->%`([(nt <: valtype)], [(nt <: valtype)])) - - ;; 3-typing.watsup:228.1-229.36 - rule binop {C : context, binop : binop_numtype, nt : numtype}: - `%|-%:%`(C, BINOP_instr(nt, binop), `%->%`([(nt <: valtype) (nt <: valtype)], [(nt <: valtype)])) - - ;; 3-typing.watsup:231.1-232.36 - rule testop {C : context, nt : numtype, testop : testop_numtype}: - `%|-%:%`(C, TESTOP_instr(nt, testop), `%->%`([(nt <: valtype)], [I32_valtype])) - - ;; 3-typing.watsup:234.1-235.37 - rule relop {C : context, nt : numtype, relop : relop_numtype}: - `%|-%:%`(C, RELOP_instr(nt, relop), `%->%`([(nt <: valtype) (nt <: valtype)], [I32_valtype])) - - ;; 3-typing.watsup:238.1-240.23 - rule extend {C : context, n : n, nt : numtype}: - `%|-%:%`(C, EXTEND_instr(nt, n), `%->%`([(nt <: valtype)], [(nt <: valtype)])) - -- if (n <= $size(nt <: valtype)) - - ;; 3-typing.watsup:242.1-245.34 - rule reinterpret {C : context, nt_1 : numtype, nt_2 : numtype}: - `%|-%:%`(C, CVTOP_instr(nt_1, REINTERPRET_cvtop, nt_2, ?()), `%->%`([(nt_2 <: valtype)], [(nt_1 <: valtype)])) - -- if (nt_1 =/= nt_2) - -- if ($size(nt_1 <: valtype) = $size(nt_2 <: valtype)) - - ;; 3-typing.watsup:247.1-250.52 - rule convert-i {C : context, in_1 : in, in_2 : in, sx? : sx?}: - `%|-%:%`(C, CVTOP_instr((in_1 <: numtype), CONVERT_cvtop, (in_2 <: numtype), sx?{sx}), `%->%`([(in_2 <: valtype)], [(in_1 <: valtype)])) - -- if (in_1 =/= in_2) - -- if ((sx?{sx} = ?()) <=> ($size(in_1 <: valtype) > $size(in_2 <: valtype))) - - ;; 3-typing.watsup:252.1-254.22 - rule convert-f {C : context, fn_1 : fn, fn_2 : fn}: - `%|-%:%`(C, CVTOP_instr((fn_1 <: numtype), CONVERT_cvtop, (fn_2 <: numtype), ?()), `%->%`([(fn_2 <: valtype)], [(fn_1 <: valtype)])) - -- if (fn_1 =/= fn_2) - - ;; 3-typing.watsup:257.1-258.35 - rule ref.null {C : context, rt : reftype}: - `%|-%:%`(C, REF.NULL_instr(rt), `%->%`([], [(rt <: valtype)])) - - ;; 3-typing.watsup:260.1-262.23 - rule ref.func {C : context, ft : functype, x : idx}: - `%|-%:%`(C, REF.FUNC_instr(x), `%->%`([], [FUNCREF_valtype])) - -- if (C.FUNC_context[x] = ft) - - ;; 3-typing.watsup:264.1-265.31 - rule ref.is_null {C : context, rt : reftype}: - `%|-%:%`(C, REF.IS_NULL_instr, `%->%`([(rt <: valtype)], [I32_valtype])) - - ;; 3-typing.watsup:268.1-270.23 - rule local.get {C : context, t : valtype, x : idx}: - `%|-%:%`(C, LOCAL.GET_instr(x), `%->%`([], [t])) - -- if (C.LOCAL_context[x] = t) - - ;; 3-typing.watsup:272.1-274.23 - rule local.set {C : context, t : valtype, x : idx}: - `%|-%:%`(C, LOCAL.SET_instr(x), `%->%`([t], [])) - -- if (C.LOCAL_context[x] = t) - - ;; 3-typing.watsup:276.1-278.23 - rule local.tee {C : context, t : valtype, x : idx}: - `%|-%:%`(C, LOCAL.TEE_instr(x), `%->%`([t], [t])) - -- if (C.LOCAL_context[x] = t) - - ;; 3-typing.watsup:281.1-283.29 - rule global.get {C : context, t : valtype, x : idx}: - `%|-%:%`(C, GLOBAL.GET_instr(x), `%->%`([], [t])) - -- if (C.GLOBAL_context[x] = `MUT%?%`(()?{}, t)) - - ;; 3-typing.watsup:285.1-287.28 - rule global.set {C : context, t : valtype, x : idx}: - `%|-%:%`(C, GLOBAL.SET_instr(x), `%->%`([t], [])) - -- if (C.GLOBAL_context[x] = `MUT%?%`(?(()), t)) - - ;; 3-typing.watsup:290.1-292.28 - rule table.get {C : context, lim : limits, rt : reftype, x : idx}: - `%|-%:%`(C, TABLE.GET_instr(x), `%->%`([I32_valtype], [(rt <: valtype)])) - -- if (C.TABLE_context[x] = `%%`(lim, rt)) - - ;; 3-typing.watsup:294.1-296.28 - rule table.set {C : context, lim : limits, rt : reftype, x : idx}: - `%|-%:%`(C, TABLE.SET_instr(x), `%->%`([I32_valtype (rt <: valtype)], [])) - -- if (C.TABLE_context[x] = `%%`(lim, rt)) - - ;; 3-typing.watsup:298.1-300.24 - rule table.size {C : context, tt : tabletype, x : idx}: - `%|-%:%`(C, TABLE.SIZE_instr(x), `%->%`([], [I32_valtype])) - -- if (C.TABLE_context[x] = tt) - - ;; 3-typing.watsup:302.1-304.28 - rule table.grow {C : context, lim : limits, rt : reftype, x : idx}: - `%|-%:%`(C, TABLE.GROW_instr(x), `%->%`([(rt <: valtype) I32_valtype], [I32_valtype])) - -- if (C.TABLE_context[x] = `%%`(lim, rt)) - - ;; 3-typing.watsup:306.1-308.28 - rule table.fill {C : context, lim : limits, rt : reftype, x : idx}: - `%|-%:%`(C, TABLE.FILL_instr(x), `%->%`([I32_valtype (rt <: valtype) I32_valtype], [])) - -- if (C.TABLE_context[x] = `%%`(lim, rt)) - - ;; 3-typing.watsup:310.1-313.32 - rule table.copy {C : context, lim_1 : limits, lim_2 : limits, rt : reftype, x_1 : idx, x_2 : idx}: - `%|-%:%`(C, TABLE.COPY_instr(x_1, x_2), `%->%`([I32_valtype I32_valtype I32_valtype], [])) - -- if (C.TABLE_context[x_1] = `%%`(lim_1, rt)) - -- if (C.TABLE_context[x_2] = `%%`(lim_2, rt)) - - ;; 3-typing.watsup:315.1-318.25 - rule table.init {C : context, lim : limits, rt : reftype, x_1 : idx, x_2 : idx}: - `%|-%:%`(C, TABLE.INIT_instr(x_1, x_2), `%->%`([I32_valtype I32_valtype I32_valtype], [])) - -- if (C.TABLE_context[x_1] = `%%`(lim, rt)) - -- if (C.ELEM_context[x_2] = rt) - - ;; 3-typing.watsup:320.1-322.23 - rule elem.drop {C : context, rt : reftype, x : idx}: - `%|-%:%`(C, ELEM.DROP_instr(x), `%->%`([], [])) - -- if (C.ELEM_context[x] = rt) - - ;; 3-typing.watsup:325.1-327.22 - rule memory.size {C : context, mt : memtype}: - `%|-%:%`(C, MEMORY.SIZE_instr, `%->%`([], [I32_valtype])) - -- if (C.MEM_context[0] = mt) - - ;; 3-typing.watsup:329.1-331.22 - rule memory.grow {C : context, mt : memtype}: - `%|-%:%`(C, MEMORY.GROW_instr, `%->%`([I32_valtype], [I32_valtype])) - -- if (C.MEM_context[0] = mt) - - ;; 3-typing.watsup:333.1-335.22 - rule memory.fill {C : context, mt : memtype}: - `%|-%:%`(C, MEMORY.FILL_instr, `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) - -- if (C.MEM_context[0] = mt) - - ;; 3-typing.watsup:337.1-339.22 - rule memory.copy {C : context, mt : memtype}: - `%|-%:%`(C, MEMORY.COPY_instr, `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) - -- if (C.MEM_context[0] = mt) - - ;; 3-typing.watsup:341.1-344.23 - rule memory.init {C : context, mt : memtype, x : idx}: - `%|-%:%`(C, MEMORY.INIT_instr(x), `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) - -- if (C.MEM_context[0] = mt) - -- if (C.DATA_context[x] = OK) - - ;; 3-typing.watsup:346.1-348.23 - rule data.drop {C : context, x : idx}: - `%|-%:%`(C, DATA.DROP_instr(x), `%->%`([], [])) - -- if (C.DATA_context[x] = OK) - - ;; 3-typing.watsup:350.1-355.32 - rule load {C : context, in : in, mt : memtype, n? : n?, n_A : n, n_O : n, nt : numtype, sx? : sx?}: - `%|-%:%`(C, LOAD_instr(nt, (n, sx)?{n sx}, n_A, n_O), `%->%`([I32_valtype], [(nt <: valtype)])) - -- if (C.MEM_context[0] = mt) - -- if ((2 ^ n_A) <= ($size(nt <: valtype) / 8)) - -- (if (((2 ^ n_A) <= (n / 8)) /\ ((n / 8) < ($size(nt <: valtype) / 8))))?{n} - -- if ((n?{n} = ?()) \/ (nt = (in <: numtype))) - - ;; 3-typing.watsup:357.1-362.32 - rule store {C : context, in : in, mt : memtype, n? : n?, n_A : n, n_O : n, nt : numtype}: - `%|-%:%`(C, STORE_instr(nt, n?{n}, n_A, n_O), `%->%`([I32_valtype (nt <: valtype)], [])) - -- if (C.MEM_context[0] = mt) - -- if ((2 ^ n_A) <= ($size(nt <: valtype) / 8)) - -- (if (((2 ^ n_A) <= (n / 8)) /\ ((n / 8) < ($size(nt <: valtype) / 8))))?{n} - -- if ((n?{n} = ?()) \/ (nt = (in <: numtype))) - -;; 3-typing.watsup:124.1-124.67 -relation InstrSeq_ok: `%|-%*:%`(context, instr*, functype) - ;; 3-typing.watsup:133.1-134.36 - rule empty {C : context}: - `%|-%*:%`(C, [], `%->%`([], [])) - - ;; 3-typing.watsup:136.1-139.46 - rule seq {C : context, instr_1 : instr, instr_2 : instr, t_1* : valtype*, t_2* : valtype*, t_3* : valtype*}: - `%|-%*:%`(C, [instr_1] :: instr_2*{}, `%->%`(t_1*{t_1}, t_3*{t_3})) - -- Instr_ok: `%|-%:%`(C, instr_1, `%->%`(t_1*{t_1}, t_2*{t_2})) - -- InstrSeq_ok: `%|-%*:%`(C, [instr_2], `%->%`(t_2*{t_2}, t_3*{t_3})) - - ;; 3-typing.watsup:141.1-146.38 - rule weak {C : context, instr* : instr*, t'_1 : valtype, t'_2* : valtype*, t_1* : valtype*, t_2* : valtype*}: - `%|-%*:%`(C, instr*{instr}, `%->%`([t'_1], t'_2*{t'_2})) - -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) - -- Resulttype_sub: `|-%*<:%*`(t'_1*{}, t_1*{t_1}) - -- Resulttype_sub: `|-%*<:%*`(t_2*{t_2}, t'_2*{t'_2}) - - ;; 3-typing.watsup:148.1-150.45 - rule frame {C : context, instr* : instr*, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: - `%|-%*:%`(C, instr*{instr}, `%->%`(t*{t} :: t_1*{t_1}, t*{t} :: t_2*{t_2})) - -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) -} - -;; 3-typing.watsup:125.1-125.71 -relation Expr_ok: `%|-%:%`(context, expr, resulttype) - ;; 3-typing.watsup:128.1-130.46 - rule _ {C : context, instr* : instr*, t* : valtype*}: - `%|-%:%`(C, instr*{instr}, t*{t}) - -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`([], t*{t})) - -;; 3-typing.watsup:367.1-367.78 -relation Instr_const: `%|-%CONST`(context, instr) - ;; 3-typing.watsup:371.1-372.26 - rule const {C : context, c : c_numtype, nt : numtype}: - `%|-%CONST`(C, CONST_instr(nt, c)) - - ;; 3-typing.watsup:374.1-375.27 - rule ref.null {C : context, rt : reftype}: - `%|-%CONST`(C, REF.NULL_instr(rt)) - - ;; 3-typing.watsup:377.1-378.26 - rule ref.func {C : context, x : idx}: - `%|-%CONST`(C, REF.FUNC_instr(x)) - - ;; 3-typing.watsup:380.1-382.32 - rule global.get {C : context, t : valtype, x : idx}: - `%|-%CONST`(C, GLOBAL.GET_instr(x)) - -- if (C.GLOBAL_context[x] = `MUT%?%`(?(), t)) - -;; 3-typing.watsup:368.1-368.77 -relation Expr_const: `%|-%CONST`(context, expr) - ;; 3-typing.watsup:385.1-386.38 - rule _ {C : context, instr* : instr*}: - `%|-%CONST`(C, instr*{instr}) - -- (Instr_const: `%|-%CONST`(C, instr))*{instr} - -;; 3-typing.watsup:369.1-369.78 -relation Expr_ok_const: `%|-%:%CONST`(context, expr, valtype) - ;; 3-typing.watsup:389.1-392.33 - rule _ {C : context, expr : expr, t : valtype}: - `%|-%:%CONST`(C, expr, t) - -- Expr_ok: `%|-%:%`(C, expr, [t]) - -- Expr_const: `%|-%CONST`(C, expr) - -;; 3-typing.watsup:397.1-397.73 -relation Func_ok: `%|-%:%`(context, func, functype) - ;; 3-typing.watsup:408.1-412.75 - rule _ {C : context, expr : expr, ft : functype, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: - `%|-%:%`(C, `FUNC%%*%`(ft, t*{t}, expr), ft) - -- if (ft = `%->%`(t_1*{t_1}, t_2*{t_2})) - -- Functype_ok: `|-%:OK`(ft) - -- Expr_ok: `%|-%:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL t_1*{t_1} :: t*{t}, LABEL [], RETURN ?()} ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2*{t_2}], RETURN ?()} ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [], RETURN ?(t_2*{t_2})}, expr, t_2*{t_2}) - -;; 3-typing.watsup:398.1-398.75 -relation Global_ok: `%|-%:%`(context, global, globaltype) - ;; 3-typing.watsup:414.1-418.40 - rule _ {C : context, expr : expr, gt : globaltype, t : valtype}: - `%|-%:%`(C, GLOBAL(gt, expr), gt) - -- Globaltype_ok: `|-%:OK`(gt) - -- if (gt = `MUT%?%`(()?{}, t)) - -- Expr_ok_const: `%|-%:%CONST`(C, expr, t) - -;; 3-typing.watsup:399.1-399.74 -relation Table_ok: `%|-%:%`(context, table, tabletype) - ;; 3-typing.watsup:420.1-422.30 - rule _ {C : context, tt : tabletype}: - `%|-%:%`(C, TABLE(tt), tt) - -- Tabletype_ok: `|-%:OK`(tt) - -;; 3-typing.watsup:400.1-400.72 -relation Mem_ok: `%|-%:%`(context, mem, memtype) - ;; 3-typing.watsup:424.1-426.28 - rule _ {C : context, mt : memtype}: - `%|-%:%`(C, MEMORY(mt), mt) - -- Memtype_ok: `|-%:OK`(mt) - -;; 3-typing.watsup:403.1-403.77 -relation Elemmode_ok: `%|-%:%`(context, elemmode, reftype) - ;; 3-typing.watsup:437.1-440.45 - rule active {C : context, expr : expr, lim : limits, rt : reftype, x : idx}: - `%|-%:%`(C, TABLE_elemmode(x, expr), rt) - -- if (C.TABLE_context[x] = `%%`(lim, rt)) - -- (Expr_ok_const: `%|-%:%CONST`(C, expr, I32_valtype))*{} - - ;; 3-typing.watsup:442.1-443.20 - rule declare {C : context, rt : reftype}: - `%|-%:%`(C, DECLARE_elemmode, rt) - -;; 3-typing.watsup:401.1-401.73 -relation Elem_ok: `%|-%:%`(context, elem, reftype) - ;; 3-typing.watsup:428.1-431.40 - rule _ {C : context, elemmode? : elemmode?, expr* : expr*, rt : reftype}: - `%|-%:%`(C, `ELEM%%*%?`(rt, expr*{expr}, elemmode?{elemmode}), rt) - -- (Expr_ok: `%|-%:%`(C, expr, [(rt <: valtype)]))*{expr} - -- (Elemmode_ok: `%|-%:%`(C, elemmode, rt))?{elemmode} - -;; 3-typing.watsup:404.1-404.77 -relation Datamode_ok: `%|-%:OK`(context, datamode) - ;; 3-typing.watsup:445.1-448.45 - rule _ {C : context, expr : expr, mt : memtype}: - `%|-%:OK`(C, MEMORY_datamode(0, expr)) - -- if (C.MEM_context[0] = mt) - -- (Expr_ok_const: `%|-%:%CONST`(C, expr, I32_valtype))*{} - -;; 3-typing.watsup:402.1-402.73 -relation Data_ok: `%|-%:OK`(context, data) - ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) - -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} - -;; 3-typing.watsup:405.1-405.74 -relation Start_ok: `%|-%:OK`(context, start) - ;; 3-typing.watsup:450.1-452.39 - rule _ {C : context, x : idx}: - `%|-%:OK`(C, START(x)) - -- if (C.FUNC_context[x] = `%->%`([], [])) - -;; 3-typing.watsup:455.1-455.80 -relation Import_ok: `%|-%:%`(context, import, externtype) - ;; 3-typing.watsup:459.1-461.31 - rule _ {C : context, name_1 : name, name_2 : name, xt : externtype}: - `%|-%:%`(C, IMPORT(name_1, name_2, xt), xt) - -- Externtype_ok: `|-%:OK`(xt) - -;; 3-typing.watsup:457.1-457.83 -relation Externuse_ok: `%|-%:%`(context, externuse, externtype) - ;; 3-typing.watsup:467.1-469.23 - rule func {C : context, ft : functype, x : idx}: - `%|-%:%`(C, FUNC_externuse(x), FUNC_externtype(ft)) - -- if (C.FUNC_context[x] = ft) - - ;; 3-typing.watsup:471.1-473.25 - rule global {C : context, gt : globaltype, x : idx}: - `%|-%:%`(C, GLOBAL_externuse(x), GLOBAL_externtype(gt)) - -- if (C.GLOBAL_context[x] = gt) - - ;; 3-typing.watsup:475.1-477.24 - rule table {C : context, tt : tabletype, x : idx}: - `%|-%:%`(C, TABLE_externuse(x), TABLE_externtype(tt)) - -- if (C.TABLE_context[x] = tt) - - ;; 3-typing.watsup:479.1-481.22 - rule mem {C : context, mt : memtype, x : idx}: - `%|-%:%`(C, MEMORY_externuse(x), MEMORY_externtype(mt)) - -- if (C.MEM_context[x] = mt) - -;; 3-typing.watsup:456.1-456.80 -relation Export_ok: `%|-%:%`(context, export, externtype) - ;; 3-typing.watsup:463.1-465.39 - rule _ {C : context, externuse : externuse, name : name, xt : externtype}: - `%|-%:%`(C, EXPORT(name, externuse), xt) - -- Externuse_ok: `%|-%:%`(C, externuse, xt) - -;; 3-typing.watsup:484.1-484.62 -relation Module_ok: `|-%:OK`(module) - ;; 3-typing.watsup:486.1-501.22 - rule _ {C : context, data^n : data^n, elem* : elem*, export* : export*, ft* : functype*, func* : func*, global* : global*, gt* : globaltype*, import* : import*, mem* : mem*, mt* : memtype*, n : n, rt* : reftype*, start* : start*, table* : table*, tt* : tabletype*}: - `|-%:OK`(`MODULE%*%*%*%*%*%*%*%*%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data^n{data}, start*{start}, export*{export})) - -- if (C = {FUNC ft*{ft}, GLOBAL gt*{gt}, TABLE tt*{tt}, MEM mt*{mt}, ELEM rt*{rt}, DATA OK^n{}, LOCAL [], LABEL [], RETURN ?()}) - -- (Func_ok: `%|-%:%`(C, func, ft))*{ft func} - -- (Global_ok: `%|-%:%`(C, global, gt))*{global gt} - -- (Table_ok: `%|-%:%`(C, table, tt))*{table tt} - -- (Mem_ok: `%|-%:%`(C, mem, mt))*{mem mt} - -- (Elem_ok: `%|-%:%`(C, elem, rt))*{elem rt} - -- (Data_ok: `%|-%:OK`(C, data))^n{data} - -- (Start_ok: `%|-%:OK`(C, start))*{start} - -- if (|mem*{mem}| <= 1) - -- if (|start*{start}| <= 1) - -;; 4-runtime.watsup:3.1-3.39 -syntax addr = nat - -;; 4-runtime.watsup:4.1-4.53 -syntax funcaddr = addr - -;; 4-runtime.watsup:5.1-5.53 -syntax globaladdr = addr - -;; 4-runtime.watsup:6.1-6.51 -syntax tableaddr = addr - -;; 4-runtime.watsup:7.1-7.50 -syntax memaddr = addr - -;; 4-runtime.watsup:8.1-8.49 -syntax elemaddr = addr - -;; 4-runtime.watsup:9.1-9.49 -syntax dataaddr = addr - -;; 4-runtime.watsup:10.1-10.51 -syntax labeladdr = addr - -;; 4-runtime.watsup:11.1-11.49 -syntax hostaddr = addr - -;; 4-runtime.watsup:24.1-25.24 -syntax num = - | CONST(numtype, c_numtype) - -;; 4-runtime.watsup:26.1-27.67 -syntax ref = - | REF.NULL(reftype) - | REF.FUNC_ADDR(funcaddr) - | REF.HOST_ADDR(hostaddr) - -;; 4-runtime.watsup:28.1-29.10 -syntax val = - | CONST(numtype, c_numtype) - | REF.NULL(reftype) - | REF.FUNC_ADDR(funcaddr) - | REF.HOST_ADDR(hostaddr) - -;; 4-runtime.watsup:31.1-32.18 -syntax result = - | _VALS(val*) - | TRAP - -;; 4-runtime.watsup:38.1-39.66 -syntax externval = - | FUNC(funcaddr) - | GLOBAL(globaladdr) - | TABLE(tableaddr) - | MEM(memaddr) - -;; 4-runtime.watsup:44.1-44.44 -def default_ : valtype -> val - ;; 4-runtime.watsup:45.1-45.35 - def default_(I32_valtype) = CONST_val(I32_numtype, 0) - ;; 4-runtime.watsup:46.1-46.35 - def default_(I64_valtype) = CONST_val(I64_numtype, 0) - ;; 4-runtime.watsup:47.1-47.35 - def default_(F32_valtype) = CONST_val(F32_numtype, 0) - ;; 4-runtime.watsup:48.1-48.35 - def default_(F64_valtype) = CONST_val(F64_numtype, 0) - ;; 4-runtime.watsup:49.1-49.34 - def {rt : reftype} default_(rt <: valtype) = REF.NULL_val(rt) - -;; 4-runtime.watsup:60.1-60.71 -syntax exportinst = EXPORT(name, externval) - -;; 4-runtime.watsup:70.1-77.25 -syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} - -;; 4-runtime.watsup:54.1-54.66 -syntax funcinst = `%;%`(moduleinst, func) - -;; 4-runtime.watsup:55.1-55.53 -syntax globalinst = val - -;; 4-runtime.watsup:56.1-56.52 -syntax tableinst = ref* - -;; 4-runtime.watsup:57.1-57.52 -syntax meminst = byte* - -;; 4-runtime.watsup:58.1-58.53 -syntax eleminst = ref* - -;; 4-runtime.watsup:59.1-59.51 -syntax datainst = byte* - -;; 4-runtime.watsup:62.1-68.21 -syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} - -;; 4-runtime.watsup:79.1-81.24 -syntax frame = {LOCAL val*, MODULE moduleinst} - -;; 4-runtime.watsup:82.1-82.47 -syntax state = `%;%`(store, frame) - -;; 4-runtime.watsup:139.1-146.5 -rec { - -;; 4-runtime.watsup:139.1-146.5 -syntax admininstr = - | UNREACHABLE - | NOP - | DROP - | SELECT(valtype?) - | BLOCK(blocktype, instr*) - | LOOP(blocktype, instr*) - | IF(blocktype, instr*, instr*) - | BR(labelidx) - | BR_IF(labelidx) - | BR_TABLE(labelidx*, labelidx) - | CALL(funcidx) - | CALL_INDIRECT(tableidx, functype) - | RETURN - | CONST(numtype, c_numtype) - | UNOP(numtype, unop_numtype) - | BINOP(numtype, binop_numtype) - | TESTOP(numtype, testop_numtype) - | RELOP(numtype, relop_numtype) - | EXTEND(numtype, n) - | CVTOP(numtype, cvtop, numtype, sx?) - | REF.NULL(reftype) - | REF.FUNC(funcidx) - | REF.IS_NULL - | LOCAL.GET(localidx) - | LOCAL.SET(localidx) - | LOCAL.TEE(localidx) - | GLOBAL.GET(globalidx) - | GLOBAL.SET(globalidx) - | TABLE.GET(tableidx) - | TABLE.SET(tableidx) - | TABLE.SIZE(tableidx) - | TABLE.GROW(tableidx) - | TABLE.FILL(tableidx) - | TABLE.COPY(tableidx, tableidx) - | TABLE.INIT(tableidx, elemidx) - | ELEM.DROP(elemidx) - | MEMORY.SIZE - | MEMORY.GROW - | MEMORY.FILL - | MEMORY.COPY - | MEMORY.INIT(dataidx) - | DATA.DROP(dataidx) - | LOAD(numtype, (n, sx)?, nat, nat) - | STORE(numtype, n?, nat, nat) - | REF.FUNC_ADDR(funcaddr) - | REF.HOST_ADDR(hostaddr) - | CALL_ADDR(funcaddr) - | LABEL_(n, instr*, admininstr*) - | FRAME_(n, frame, admininstr*) - | TRAP -} - -;; 4-runtime.watsup:83.1-83.62 -syntax config = `%;%*`(state, admininstr*) - -;; 4-runtime.watsup:101.1-101.59 -def funcaddr : state -> funcaddr* - ;; 4-runtime.watsup:102.1-102.38 - def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst - -;; 4-runtime.watsup:104.1-104.52 -def funcinst : state -> funcinst* - ;; 4-runtime.watsup:105.1-105.31 - def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store - -;; 4-runtime.watsup:107.1-107.67 -def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:115.1-115.48 - def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] - -;; 4-runtime.watsup:108.1-108.69 -def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:116.1-116.54 - def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] - -;; 4-runtime.watsup:109.1-109.68 -def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:117.1-117.51 - def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] - -;; 4-runtime.watsup:110.1-110.66 -def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:118.1-118.45 - def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] - -;; 4-runtime.watsup:111.1-111.67 -def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:119.1-119.48 - def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] - -;; 4-runtime.watsup:112.1-112.67 -def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:120.1-120.48 - def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] - -;; 4-runtime.watsup:113.1-113.68 -def local : (state, localidx) -> val - ;; 4-runtime.watsup:121.1-121.35 - def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] - -;; 4-runtime.watsup:124.1-124.78 -def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:130.1-130.52 - def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL[x] = v]) - -;; 4-runtime.watsup:125.1-125.79 -def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:131.1-131.71 - def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) - -;; 4-runtime.watsup:126.1-126.81 -def with_table : (state, tableidx, n, ref) -> state - ;; 4-runtime.watsup:132.1-132.74 - def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) - -;; 4-runtime.watsup:127.1-127.80 -def with_tableext : (state, tableidx, ref*) -> state - ;; 4-runtime.watsup:133.1-133.75 - def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) - -;; 4-runtime.watsup:128.1-128.77 -def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:134.1-134.69 - def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]] = r*{r}], f) - -;; 4-runtime.watsup:148.1-151.21 -rec { - -;; 4-runtime.watsup:148.1-151.21 -syntax E = - | _HOLE - | _SEQ(val*, E, instr*) - | LABEL_(n, instr*, E) -} - -;; 5-numerics.watsup:3.1-3.76 -def unop : (unop_numtype, numtype, c_numtype) -> c_numtype* - -;; 5-numerics.watsup:4.1-4.79 -def binop : (binop_numtype, numtype, c_numtype, c_numtype) -> c_numtype* - -;; 5-numerics.watsup:5.1-5.76 -def testop : (testop_numtype, numtype, c_numtype) -> c_numtype - -;; 5-numerics.watsup:6.1-6.79 -def relop : (relop_numtype, numtype, c_numtype, c_numtype) -> c_numtype - -;; 5-numerics.watsup:8.1-8.84 -def ext : (nat, nat, sx, c_numtype) -> c_numtype - -;; 5-numerics.watsup:9.1-9.84 -def cvtop : (numtype, cvtop, numtype, sx?, c_numtype) -> c_numtype* - -;; 6-reduction.watsup:4.1-4.63 -relation Step_pure: `%*~>%*`(admininstr*, admininstr*) - ;; 6-reduction.watsup:16.1-17.24 - rule unreachable: - `%*~>%*`([UNREACHABLE_admininstr], [TRAP_admininstr]) - - ;; 6-reduction.watsup:19.1-20.19 - rule nop: - `%*~>%*`([NOP_admininstr], []) - - ;; 6-reduction.watsup:22.1-23.24 - rule drop {val : val}: - `%*~>%*`([(val <: admininstr) DROP_admininstr], []) - - ;; 6-reduction.watsup:26.1-28.16 - rule select-true {c : c_numtype, t? : valtype?, val_1 : val, val_2 : val}: - `%*~>%*`([(val_1 <: admininstr) (val_2 <: admininstr) CONST_admininstr(I32_numtype, c) SELECT_admininstr(t?{t})], [(val_1 <: admininstr)]) - -- if (c =/= 0) - - ;; 6-reduction.watsup:30.1-32.14 - rule select-false {c : c_numtype, t? : valtype?, val_1 : val, val_2 : val}: - `%*~>%*`([(val_1 <: admininstr) (val_2 <: admininstr) CONST_admininstr(I32_numtype, c) SELECT_admininstr(t?{t})], [(val_2 <: admininstr)]) - -- if (c = 0) - - ;; 6-reduction.watsup:35.1-37.28 - rule block {bt : blocktype, instr* : instr*, k : nat, n : n, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k}: - `%*~>%*`((val <: admininstr)^k{val} :: [BLOCK_admininstr(bt, instr*{instr})], [LABEL__admininstr(n, [], (val <: admininstr)^k{val} :: (instr <: admininstr)*{instr})]) - -- if (bt = `%->%`(t_1^k{t_1}, t_2^n{t_2})) - - ;; 6-reduction.watsup:39.1-41.28 - rule loop {bt : blocktype, instr* : instr*, k : nat, n : n, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k}: - `%*~>%*`((val <: admininstr)^k{val} :: [LOOP_admininstr(bt, instr*{instr})], [LABEL__admininstr(n, [LOOP_instr(bt, instr*{instr})], (val <: admininstr)^k{val} :: (instr <: admininstr)*{instr})]) - -- if (bt = `%->%`(t_1^k{t_1}, t_2^n{t_2})) - - ;; 6-reduction.watsup:43.1-45.16 - rule if-true {bt : blocktype, c : c_numtype, instr_1* : instr*, instr_2* : instr*}: - `%*~>%*`([CONST_admininstr(I32_numtype, c) IF_admininstr(bt, instr_1*{instr_1}, instr_2*{instr_2})], [BLOCK_admininstr(bt, instr_1*{instr_1})]) - -- if (c =/= 0) - - ;; 6-reduction.watsup:47.1-49.14 - rule if-false {bt : blocktype, c : c_numtype, instr_1* : instr*, instr_2* : instr*}: - `%*~>%*`([CONST_admininstr(I32_numtype, c) IF_admininstr(bt, instr_1*{instr_1}, instr_2*{instr_2})], [BLOCK_admininstr(bt, instr_2*{instr_2})]) - -- if (c = 0) - - ;; 6-reduction.watsup:52.1-53.38 - rule label-vals {instr* : instr*, n : n, val* : val*}: - `%*~>%*`([LABEL__admininstr(n, instr*{instr}, (val <: admininstr)*{val})], (val <: admininstr)*{val}) - - ;; 6-reduction.watsup:57.1-58.69 - rule br-zero {instr* : instr*, instr'* : instr*, n : n, val^n : val^n, val'* : val*}: - `%*~>%*`([LABEL__admininstr(n, instr'*{instr'}, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [BR_admininstr(0)] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val} :: (instr' <: admininstr)*{instr'}) - - ;; 6-reduction.watsup:60.1-61.65 - rule br-succ {instr* : instr*, instr'* : instr*, l : labelidx, n : n, val* : val*}: - `%*~>%*`([LABEL__admininstr(n, instr'*{instr'}, (val <: admininstr)*{val} :: [BR_admininstr(l + 1)] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [BR_admininstr(l)]) - - ;; 6-reduction.watsup:64.1-66.16 - rule br_if-true {c : c_numtype, l : labelidx}: - `%*~>%*`([CONST_admininstr(I32_numtype, c) BR_IF_admininstr(l)], [BR_admininstr(l)]) - -- if (c =/= 0) - - ;; 6-reduction.watsup:68.1-70.14 - rule br_if-false {c : c_numtype, l : labelidx}: - `%*~>%*`([CONST_admininstr(I32_numtype, c) BR_IF_admininstr(l)], []) - -- if (c = 0) - - ;; 6-reduction.watsup:73.1-75.17 - rule br_table-lt {i : nat, l* : labelidx*, l' : labelidx}: - `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l*{l}[i])]) - -- if (i < |l*{l}|) - - ;; 6-reduction.watsup:77.1-79.18 - rule br_table-ge {i : nat, l* : labelidx*, l' : labelidx}: - `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) - -- if (i >= |l*{l}|) - - ;; 6-reduction.watsup:100.1-101.35 - rule frame-vals {f : frame, n : n, val^n : val^n}: - `%*~>%*`([FRAME__admininstr(n, f, (val <: admininstr)^n{val})], (val <: admininstr)^n{val}) - - ;; 6-reduction.watsup:103.1-104.55 - rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: - `%*~>%*`([FRAME__admininstr(n, f, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val}) - - ;; 6-reduction.watsup:106.1-107.60 - rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: - `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, (val <: admininstr)*{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [RETURN_admininstr]) - - ;; 6-reduction.watsup:110.1-112.33 - rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: - `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) - -- if ($unop(unop, nt, c_1) = [c]) - - ;; 6-reduction.watsup:114.1-116.39 - rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: - `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) - -- if ($unop(unop, nt, c_1) = []) - - ;; 6-reduction.watsup:119.1-121.40 - rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: - `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) - -- if ($binop(binop, nt, c_1, c_2) = [c]) - - ;; 6-reduction.watsup:123.1-125.46 - rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: - `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) - -- if ($binop(binop, nt, c_1, c_2) = []) - - ;; 6-reduction.watsup:128.1-130.37 - rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: - `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) - -- if (c = $testop(testop, nt, c_1)) - - ;; 6-reduction.watsup:132.1-134.40 - rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: - `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) - -- if (c = $relop(relop, nt, c_1, c_2)) - - ;; 6-reduction.watsup:137.1-138.70 - rule extend {c : c_numtype, n : n, nt : numtype}: - `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), S_sx, c))]) - - ;; 6-reduction.watsup:141.1-143.48 - rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt : numtype, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: - `%*~>%*`([CONST_admininstr(nt, c_1) CVTOP_admininstr(nt_1, cvtop, nt_2, sx?{sx})], [CONST_admininstr(nt, c)]) - -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) - - ;; 6-reduction.watsup:145.1-147.54 - rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt : numtype, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: - `%*~>%*`([CONST_admininstr(nt, c_1) CVTOP_admininstr(nt_1, cvtop, nt_2, sx?{sx})], [TRAP_admininstr]) - -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) - - ;; 6-reduction.watsup:154.1-156.28 - rule ref.is_null-true {rt : reftype, val : val}: - `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) - -- if (val = REF.NULL_val(rt)) - - ;; 6-reduction.watsup:158.1-160.15 - rule ref.is_null-false {val : val}: - `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) - -- otherwise - - ;; 6-reduction.watsup:169.1-170.47 - rule local.tee {val : val, x : idx}: - `%*~>%*`([(val <: admininstr) LOCAL.TEE_admininstr(x)], [(val <: admininstr) (val <: admininstr) LOCAL.SET_admininstr(x)]) - -;; 6-reduction.watsup:5.1-5.63 -relation Step_read: `%~>%*`(config, admininstr*) - ;; 6-reduction.watsup:82.1-83.47 - rule call {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) - - ;; 6-reduction.watsup:85.1-88.34 - rule call_indirect-call {a : addr, ft : functype, func : func, i : nat, m : moduleinst, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) - -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) - -- if ($funcinst(z)[a] = `%;%`(m, func)) - - ;; 6-reduction.watsup:90.1-92.15 - rule call_indirect-trap {ft : functype, i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) - -- otherwise - - ;; 6-reduction.watsup:94.1-97.52 - rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: - `%~>%*`(`%;%*`(z, (val <: admininstr)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], (instr <: admininstr)*{instr})])]) - -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) - -- if (f = {LOCAL val^k{val} :: $default_(t)*{t}, MODULE m}) - - ;; 6-reduction.watsup:150.1-151.53 - rule ref.func {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) - - ;; 6-reduction.watsup:163.1-164.37 - rule local.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [($local(z, x) <: admininstr)]) - - ;; 6-reduction.watsup:173.1-174.39 - rule global.get {x : idx, z : state}: - `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [($global(z, x) <: admininstr)]) - - ;; 6-reduction.watsup:180.1-182.28 - rule table.get-trap {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) - - ;; 6-reduction.watsup:184.1-186.27 - rule table.get-val {i : nat, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [($table(z, x)[i] <: admininstr)]) - -- if (i < |$table(z, x)|) - - ;; 6-reduction.watsup:188.1-190.28 - rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) - -- if (i >= |$table(z, x)|) - - ;; 6-reduction.watsup:197.1-199.27 - rule table.size {n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) - -- if (|$table(z, x)| = n) - - ;; 6-reduction.watsup:205.1-206.57 - rule table.grow-fail {n : n, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), [CONST_admininstr(I32_numtype, - 1)]) - - ;; 6-reduction.watsup:209.1-211.34 - rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) - -- if ((i + n) > |$table(z, x)|) - - ;; 6-reduction.watsup:213.1-216.14 - rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) - -- otherwise - -- if (n = 0) - - ;; 6-reduction.watsup:218.1-222.15 - rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) - -- otherwise - - ;; 6-reduction.watsup:225.1-227.63 - rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) - - ;; 6-reduction.watsup:229.1-232.14 - rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) - -- otherwise - -- if (n = 0) - - ;; 6-reduction.watsup:234.1-239.15 - rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) - -- otherwise - -- if (j <= i) - - ;; 6-reduction.watsup:241.1-245.15 - rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) - -- otherwise - - ;; 6-reduction.watsup:248.1-250.62 - rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) - -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) - - ;; 6-reduction.watsup:252.1-255.14 - rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) - -- otherwise - -- if (n = 0) - - ;; 6-reduction.watsup:257.1-261.15 - rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: - `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y)[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) - -- otherwise - -;; 6-reduction.watsup:3.1-3.63 -relation Step: `%~>%`(config, config) - ;; 6-reduction.watsup:7.1-9.34 - rule pure {instr* : instr*, instr'* : instr*, z : state}: - `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) - -- Step_pure: `%*~>%*`((instr <: admininstr)*{instr}, (instr' <: admininstr)*{instr'}) - - ;; 6-reduction.watsup:11.1-13.37 - rule read {instr* : instr*, instr'* : instr*, z : state}: - `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) - -- Step_read: `%~>%*`(`%;%*`(z, (instr <: admininstr)*{instr}), (instr' <: admininstr)*{instr'}) - - ;; 6-reduction.watsup:166.1-167.60 - rule local.set {val : val, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(val <: admininstr) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) - - ;; 6-reduction.watsup:176.1-177.62 - rule global.set {val : val, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(val <: admininstr) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) - - ;; 6-reduction.watsup:192.1-194.27 - rule table.set-val {i : nat, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) - -- if (i < |$table(z, x)|) - - ;; 6-reduction.watsup:202.1-203.102 - rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: - `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) - - ;; 6-reduction.watsup:264.1-265.59 - rule elem.drop {x : idx, z : state}: - `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) - -== IL Validation... -== Latex Generation... -$$ -\begin{array}{@{}lrrl@{}} -& \mathit{n} &::=& \mathit{nat} \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(name)} & \mathit{name} &::=& \mathit{text} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(byte)} & \mathit{byte} &::=& \mathit{nat} \\ -\mbox{(32-bit integer)} & \mathit{u{\scriptstyle32}} &::=& \mathit{nat} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(index)} & \mathit{idx} &::=& \mathit{nat} \\ -\mbox{(function index)} & \mathit{funcidx} &::=& \mathit{idx} \\ -\mbox{(global index)} & \mathit{globalidx} &::=& \mathit{idx} \\ -\mbox{(table index)} & \mathit{tableidx} &::=& \mathit{idx} \\ -\mbox{(memory index)} & \mathit{memidx} &::=& \mathit{idx} \\ -\mbox{(elem index)} & \mathit{elemidx} &::=& \mathit{idx} \\ -\mbox{(data index)} & \mathit{dataidx} &::=& \mathit{idx} \\ -\mbox{(label index)} & \mathit{labelidx} &::=& \mathit{idx} \\ -\mbox{(local index)} & \mathit{localidx} &::=& \mathit{idx} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(number type)} & \mathit{numtype} &::=& \mathsf{i{\scriptstyle32}} ~|~ \mathsf{i{\scriptstyle64}} ~|~ \mathsf{f{\scriptstyle32}} ~|~ \mathsf{f{\scriptstyle64}} \\ -\mbox{(vector type)} & \mathit{vectype} &::=& \mathsf{v{\scriptstyle128}} \\ -\mbox{(reference type)} & \mathit{reftype} &::=& \mathsf{funcref} ~|~ \mathsf{externref} \\ -\mbox{(value type)} & \mathit{valtype} &::=& \mathit{numtype} ~|~ \mathit{vectype} ~|~ \mathit{reftype} ~|~ \mathsf{bot} \\ -& {\mathsf{i}}{\mathit{n}} &::=& \mathsf{i{\scriptstyle32}} ~|~ \mathsf{i{\scriptstyle64}} \\ -& {\mathsf{f}}{\mathit{n}} &::=& \mathsf{f{\scriptstyle32}} ~|~ \mathsf{f{\scriptstyle64}} \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(result type)} & \mathit{resulttype} &::=& {\mathit{valtype}^\ast} \\ -\mbox{(limits)} & \mathit{limits} &::=& [\mathit{u{\scriptstyle32}} .. \mathit{u{\scriptstyle32}}] \\ -\mbox{(global type)} & \mathit{globaltype} &::=& {\mathsf{mut}^?}~\mathit{valtype} \\ -\mbox{(function type)} & \mathit{functype} &::=& \mathit{resulttype} \rightarrow \mathit{resulttype} \\ -\mbox{(table type)} & \mathit{tabletype} &::=& \mathit{limits}~\mathit{reftype} \\ -\mbox{(memory type)} & \mathit{memtype} &::=& \mathit{limits}~\mathsf{i{\scriptstyle8}} \\ -\mbox{(element type)} & \mathit{elemtype} &::=& \mathit{reftype} \\ -\mbox{(data type)} & \mathit{datatype} &::=& \mathsf{ok} \\ -\mbox{(external type)} & \mathit{externtype} &::=& \mathsf{global}~\mathit{globaltype} ~|~ \mathsf{func}~\mathit{functype} ~|~ \mathsf{table}~\mathit{tabletype} ~|~ \mathsf{memory}~\mathit{memtype} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(signedness)} & \mathit{sx} &::=& \mathsf{u} ~|~ \mathsf{s} \\ -& \mathit{unop}_{\mathsf{ixx}} &::=& \mathsf{clz} ~|~ \mathsf{ctz} ~|~ \mathsf{popcnt} \\ -& \mathit{unop}_{\mathsf{fxx}} &::=& \mathsf{abs} ~|~ \mathsf{neg} ~|~ \mathsf{sqrt} ~|~ \mathsf{ceil} ~|~ \mathsf{floor} ~|~ \mathsf{trunc} ~|~ \mathsf{nearest} \\ -& \mathit{binop}_{\mathsf{ixx}} &::=& \mathsf{add} ~|~ \mathsf{sub} ~|~ \mathsf{mul} ~|~ {\mathsf{div\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{rem\_}}{\mathsf{\mathit{sx}}} \\ &&|& -\mathsf{and} ~|~ \mathsf{or} ~|~ \mathsf{xor} ~|~ \mathsf{shl} ~|~ {\mathsf{shr\_}}{\mathsf{\mathit{sx}}} ~|~ \mathsf{rotl} ~|~ \mathsf{rotr} \\ -& \mathit{binop}_{\mathsf{fxx}} &::=& \mathsf{add} ~|~ \mathsf{sub} ~|~ \mathsf{mul} ~|~ \mathsf{div} ~|~ \mathsf{min} ~|~ \mathsf{max} ~|~ \mathsf{copysign} \\ -& \mathit{testop}_{\mathsf{ixx}} &::=& \mathsf{eqz} \\ -& \mathit{testop}_{\mathsf{fxx}} &::=& \\ -& \mathit{relop}_{\mathsf{ixx}} &::=& \mathsf{eq} ~|~ \mathsf{ne} ~|~ {\mathsf{lt\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{gt\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{le\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{ge\_}}{\mathsf{\mathit{sx}}} \\ -& \mathit{relop}_{\mathsf{fxx}} &::=& \mathsf{eq} ~|~ \mathsf{ne} ~|~ \mathsf{lt} ~|~ \mathsf{gt} ~|~ \mathsf{le} ~|~ \mathsf{ge} \\ -& \mathit{unop}_{\mathit{numtype}} &::=& \mathit{unop}_{\mathsf{ixx}} ~|~ \mathit{unop}_{\mathsf{fxx}} \\ -& \mathit{binop}_{\mathit{numtype}} &::=& \mathit{binop}_{\mathsf{ixx}} ~|~ \mathit{binop}_{\mathsf{fxx}} \\ -& \mathit{testop}_{\mathit{numtype}} &::=& \mathit{testop}_{\mathsf{ixx}} ~|~ \mathit{testop}_{\mathsf{fxx}} \\ -& \mathit{relop}_{\mathit{numtype}} &::=& \mathit{relop}_{\mathsf{ixx}} ~|~ \mathit{relop}_{\mathsf{fxx}} \\ -& \mathit{cvtop} &::=& \mathsf{convert} ~|~ \mathsf{reinterpret} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -& \mathit{c}_{\mathit{numtype}} &::=& \mathit{nat} \\ -& \mathit{c}_{\mathit{vectype}} &::=& \mathit{nat} \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(block type)} & \mathit{blocktype} &::=& \mathit{functype} \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lrrl@{}} -& \mathit{instr} &::=& \mathsf{unreachable} \\ &&|& -\mathsf{nop} \\ &&|& -\mathsf{drop} \\ &&|& -\mathsf{select}~{\mathit{valtype}^?} \\ &&|& -\mathsf{block}~\mathit{blocktype}~{\mathit{instr}^\ast} \\ &&|& -\mathsf{loop}~\mathit{blocktype}~{\mathit{instr}^\ast} \\ &&|& -\mathsf{if}~\mathit{blocktype}~{\mathit{instr}^\ast}~\mathsf{else}~{\mathit{instr}^\ast} \\ &&|& -\mathsf{br}~\mathit{labelidx} \\ &&|& -\mathsf{br\_if}~\mathit{labelidx} \\ &&|& -\mathsf{br\_table}~{\mathit{labelidx}^\ast}~\mathit{labelidx} \\ &&|& -\mathsf{call}~\mathit{funcidx} \\ &&|& -\mathsf{call\_indirect}~\mathit{tableidx}~\mathit{functype} \\ &&|& -\mathsf{return} \\ &&|& -\mathsf{\mathit{numtype}}.\mathsf{const}~\mathsf{\mathit{c}\_{\mathit{numtype}}} \\ &&|& -\mathsf{\mathit{numtype}} . \mathsf{\mathit{unop}\_{\mathit{numtype}}} \\ &&|& -\mathsf{\mathit{numtype}} . \mathsf{\mathit{binop}\_{\mathit{numtype}}} \\ &&|& -\mathsf{\mathit{numtype}} . \mathsf{\mathit{testop}\_{\mathit{numtype}}} \\ &&|& -\mathsf{\mathit{numtype}} . \mathsf{\mathit{relop}\_{\mathit{numtype}}} \\ &&|& -{\mathsf{\mathit{numtype}}.\mathsf{extend}}{\mathsf{\mathit{n}}} \\ &&|& -\mathsf{\mathit{numtype}} . {{{{\mathsf{\mathit{cvtop}}}{\mathsf{\_}}}{\mathsf{\mathit{numtype}}}}{\mathsf{\_}}}{\mathsf{{\mathit{sx}^?}}} \\ &&|& -\mathsf{ref.null}~\mathit{reftype} \\ &&|& -\mathsf{ref.func}~\mathit{funcidx} \\ &&|& -\mathsf{ref.is\_null} \\ &&|& -\mathsf{local.get}~\mathit{localidx} \\ &&|& -\mathsf{local.set}~\mathit{localidx} \\ &&|& -\mathsf{local.tee}~\mathit{localidx} \\ &&|& -\mathsf{global.get}~\mathit{globalidx} \\ &&|& -\mathsf{global.set}~\mathit{globalidx} \\ &&|& -\mathsf{table.get}~\mathit{tableidx} \\ &&|& -\mathsf{table.set}~\mathit{tableidx} \\ &&|& -\mathsf{table.size}~\mathit{tableidx} \\ &&|& -\mathsf{table.grow}~\mathit{tableidx} \\ &&|& -\mathsf{table.fill}~\mathit{tableidx} \\ &&|& -\mathsf{table.copy}~\mathit{tableidx}~\mathit{tableidx} \\ &&|& -\mathsf{table.init}~\mathit{tableidx}~\mathit{elemidx} \\ &&|& -\mathsf{elem.drop}~\mathit{elemidx} \\ &&|& -\mathsf{memory.size} \\ &&|& -\mathsf{memory.grow} \\ &&|& -\mathsf{memory.fill} \\ &&|& -\mathsf{memory.copy} \\ &&|& -\mathsf{memory.init}~\mathit{dataidx} \\ &&|& -\mathsf{data.drop}~\mathit{dataidx} \\ &&|& -{\mathsf{\mathit{numtype}}.\mathsf{load}}{\mathsf{{(\mathit{n}~\mathit{sx})^?}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& -{\mathsf{\mathit{numtype}}.\mathsf{store}}{\mathsf{{\mathit{n}^?}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ -\mbox{(expression)} & \mathit{expr} &::=& {\mathit{instr}^\ast} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -& \mathit{elemmode} &::=& \mathsf{table}~\mathit{tableidx}~\mathit{expr} ~|~ \mathsf{declare} \\ -& \mathit{datamode} &::=& \mathsf{memory}~\mathit{memidx}~\mathit{expr} \\ -\mbox{(function)} & \mathit{func} &::=& \mathsf{func}~\mathit{functype}~{\mathit{valtype}^\ast}~\mathit{expr} \\ -\mbox{(global)} & \mathit{global} &::=& \mathsf{global}~\mathit{globaltype}~\mathit{expr} \\ -\mbox{(table)} & \mathit{table} &::=& \mathsf{table}~\mathit{tabletype} \\ -\mbox{(memory)} & \mathit{mem} &::=& \mathsf{memory}~\mathit{memtype} \\ -\mbox{(table segment)} & \mathit{elem} &::=& \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~{\mathit{elemmode}^?} \\ -\mbox{(memory segment)} & \mathit{data} &::=& \mathsf{data}~{({\mathit{byte}^\ast})^\ast}~{\mathit{datamode}^?} \\ -\mbox{(start function)} & \mathit{start} &::=& \mathsf{start}~\mathit{funcidx} \\ -\mbox{(external use)} & \mathit{externuse} &::=& \mathsf{func}~\mathit{funcidx} ~|~ \mathsf{global}~\mathit{globalidx} ~|~ \mathsf{table}~\mathit{tableidx} ~|~ \mathsf{memory}~\mathit{memidx} \\ -\mbox{(export)} & \mathit{export} &::=& \mathsf{export}~\mathit{name}~\mathit{externuse} \\ -\mbox{(import)} & \mathit{import} &::=& \mathsf{import}~\mathit{name}~\mathit{name}~\mathit{externtype} \\ -\mbox{(module)} & \mathit{module} &::=& \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{start}^\ast}~{\mathit{export}^\ast} \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{|\mathsf{i{\scriptstyle32}}|} &=& 32 & \\ -{|\mathsf{i{\scriptstyle64}}|} &=& 64 & \\ -{|\mathsf{f{\scriptstyle32}}|} &=& 32 & \\ -{|\mathsf{f{\scriptstyle64}}|} &=& 64 & \\ -{|\mathsf{v{\scriptstyle128}}|} &=& 128 & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lcl@{}l@{}} -\mathrm{test}_{\mathit{sub}_{\mathsf{atom}_{22}}}(\mathit{n}_{3_{\mathsf{atom}_{\mathit{y}}}}) &=& 0 & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{\mathrm{curried}}_{\mathit{n}_{1}}(\mathit{n}_{2}) &=& \mathit{n}_{1} + \mathit{n}_{2} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lrrl@{}} -& \mathit{testfuse} &::=& {\mathsf{ab}}_{\mathit{nat}}\,\,\mathit{nat}~\mathit{nat} \\ &&|& -{\mathsf{cd}}_{\mathsf{\mathit{nat}}}\,\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}} \\ &&|& -{\mathsf{ef\_}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& -{{\mathsf{gh}}_{\mathsf{\mathit{nat}}}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& -{{\mathsf{ij}}_{\mathsf{\mathit{nat}}}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& -{\mathsf{kl\_ab}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& -{\mathsf{mn\_}}{\mathsf{ab}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& -{{\mathsf{op\_}}{\mathsf{ab}}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& -{{\mathsf{qr}}_{\mathsf{\mathit{nat}}}}{\mathsf{ab}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ -\mbox{(context)} & \mathit{context} &::=& \{\; \begin{array}[t]{@{}l@{}} -\mathsf{func}~{\mathit{functype}^\ast},\; \mathsf{global}~{\mathit{globaltype}^\ast},\; \mathsf{table}~{\mathit{tabletype}^\ast},\; \mathsf{mem}~{\mathit{memtype}^\ast},\; \\ - \mathsf{elem}~{\mathit{elemtype}^\ast},\; \mathsf{data}~{\mathit{datatype}^\ast},\; \\ - \mathsf{local}~{\mathit{valtype}^\ast},\; \mathsf{label}~{\mathit{resulttype}^\ast},\; \mathsf{return}~{\mathit{resulttype}^?} \;\}\end{array} \\ -\end{array} -$$ - -\vspace{1ex} - -$\boxed{{ \vdash }\;\mathit{limits} : \mathit{nat}}$ - -$\boxed{{ \vdash }\;\mathit{functype} : \mathsf{ok}}$ - -$\boxed{{ \vdash }\;\mathit{globaltype} : \mathsf{ok}}$ - -$\boxed{{ \vdash }\;\mathit{tabletype} : \mathsf{ok}}$ - -$\boxed{{ \vdash }\;\mathit{memtype} : \mathsf{ok}}$ - -$\boxed{{ \vdash }\;\mathit{externtype} : \mathsf{ok}}$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{n}_{1} \leq \mathit{n}_{2} \leq \mathit{k} -}{ -{ \vdash }\;[\mathit{n}_{1} .. \mathit{n}_{2}] : \mathit{k} -} \, {[\textsc{\scriptsize K{-}limits}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -{ \vdash }\;\mathit{ft} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -{ \vdash }\;\mathit{gt} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}global}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{lim} : {2^{32}} - 1 -}{ -{ \vdash }\;\mathit{lim}~\mathit{rt} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}table}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{lim} : {2^{16}} -}{ -{ \vdash }\;\mathit{lim}~\mathsf{i{\scriptstyle8}} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}mem}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{functype} : \mathsf{ok} -}{ -{ \vdash }\;\mathsf{func}~\mathit{functype} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}extern{-}func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{globaltype} : \mathsf{ok} -}{ -{ \vdash }\;\mathsf{global}~\mathit{globaltype} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}extern{-}global}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{tabletype} : \mathsf{ok} -}{ -{ \vdash }\;\mathsf{table}~\mathit{tabletype} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}extern{-}table}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{memtype} : \mathsf{ok} -}{ -{ \vdash }\;\mathsf{memory}~\mathit{memtype} : \mathsf{ok} -} \, {[\textsc{\scriptsize K{-}extern{-}mem}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{{ \vdash }\;\mathit{valtype} \leq \mathit{valtype}}$ - -$\boxed{{ \vdash }\;{\mathit{valtype}^\ast} \leq {\mathit{valtype}^\ast}}$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -{ \vdash }\;\mathit{t} \leq \mathit{t} -} \, {[\textsc{\scriptsize S{-}refl}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -{ \vdash }\;\mathsf{bot} \leq \mathit{t} -} \, {[\textsc{\scriptsize S{-}bot}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -({ \vdash }\;\mathit{t}_{1} \leq \mathit{t}_{2})^\ast -}{ -{ \vdash }\;{\mathit{t}_{1}^\ast} \leq {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize S{-}result}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{{ \vdash }\;\mathit{limits} \leq \mathit{limits}}$ - -$\boxed{{ \vdash }\;\mathit{functype} \leq \mathit{functype}}$ - -$\boxed{{ \vdash }\;\mathit{globaltype} \leq \mathit{globaltype}}$ - -$\boxed{{ \vdash }\;\mathit{tabletype} \leq \mathit{tabletype}}$ - -$\boxed{{ \vdash }\;\mathit{memtype} \leq \mathit{memtype}}$ - -$\boxed{{ \vdash }\;\mathit{externtype} \leq \mathit{externtype}}$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{n}_{11} \geq \mathit{n}_{21} - \qquad -\mathit{n}_{12} \leq \mathit{n}_{22} -}{ -{ \vdash }\;[\mathit{n}_{11} .. \mathit{n}_{12}] \leq [\mathit{n}_{21} .. \mathit{n}_{22}] -} \, {[\textsc{\scriptsize S{-}limits}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -{ \vdash }\;\mathit{ft} \leq \mathit{ft} -} \, {[\textsc{\scriptsize S{-}func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -{ \vdash }\;\mathit{gt} \leq \mathit{gt} -} \, {[\textsc{\scriptsize S{-}global}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{lim}_{1} \leq \mathit{lim}_{2} -}{ -{ \vdash }\;\mathit{lim}_{1}~\mathit{rt} \leq \mathit{lim}_{2}~\mathit{rt} -} \, {[\textsc{\scriptsize S{-}table}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{lim}_{1} \leq \mathit{lim}_{2} -}{ -{ \vdash }\;\mathit{lim}_{1}~\mathsf{i{\scriptstyle8}} \leq \mathit{lim}_{2}~\mathsf{i{\scriptstyle8}} -} \, {[\textsc{\scriptsize S{-}mem}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{ft}_{1} \leq \mathit{ft}_{2} -}{ -{ \vdash }\;\mathsf{func}~\mathit{ft}_{1} \leq \mathsf{func}~\mathit{ft}_{2} -} \, {[\textsc{\scriptsize S{-}extern{-}func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{gt}_{1} \leq \mathit{gt}_{2} -}{ -{ \vdash }\;\mathsf{global}~\mathit{gt}_{1} \leq \mathsf{global}~\mathit{gt}_{2} -} \, {[\textsc{\scriptsize S{-}extern{-}global}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{tt}_{1} \leq \mathit{tt}_{2} -}{ -{ \vdash }\;\mathsf{table}~\mathit{tt}_{1} \leq \mathsf{table}~\mathit{tt}_{2} -} \, {[\textsc{\scriptsize S{-}extern{-}table}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{mt}_{1} \leq \mathit{mt}_{2} -}{ -{ \vdash }\;\mathsf{memory}~\mathit{mt}_{1} \leq \mathsf{memory}~\mathit{mt}_{2} -} \, {[\textsc{\scriptsize S{-}extern{-}mem}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{\mathit{context} \vdash \mathit{instr} : \mathit{functype}}$ - -$\boxed{\mathit{context} \vdash {\mathit{instr}^\ast} : \mathit{functype}}$ - -$\boxed{\mathit{context} \vdash \mathit{expr} : \mathit{resulttype}}$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash {\mathit{instr}^\ast} : \epsilon \rightarrow {\mathit{t}^\ast} -}{ -\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}^\ast} -} \, {[\textsc{\scriptsize T{-}expr}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \epsilon : \epsilon \rightarrow \epsilon -} \, {[\textsc{\scriptsize T*{-}empty}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash \mathit{instr}_{1} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} - \qquad -\mathit{C} \vdash \mathit{instr}_{2} : {\mathit{t}_{2}^\ast} \rightarrow {\mathit{t}_{3}^\ast} -}{ -\mathit{C} \vdash \mathit{instr}_{1}~{\mathit{instr}_{2}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{3}^\ast} -} \, {[\textsc{\scriptsize T*{-}seq}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\begin{array}{@{}c@{}} -\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} - \\ -{ \vdash }\;{{\mathit{t}'}_{1}^\ast} \leq {\mathit{t}_{1}^\ast} - \qquad -{ \vdash }\;{\mathit{t}_{2}^\ast} \leq {{\mathit{t}'}_{2}^\ast} -\end{array} -}{ -\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}'}_{1} \rightarrow {{\mathit{t}'}_{2}^\ast} -} \, {[\textsc{\scriptsize T*{-}weak}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -}{ -\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}^\ast}~{\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}^\ast}~{\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T*{-}frame}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathsf{unreachable} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}unreachable}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathsf{nop} : \epsilon \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}nop}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathsf{drop} : \mathit{t} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}drop}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathsf{select}~\mathit{t} : \mathit{t}~\mathit{t}~\mathsf{i{\scriptstyle32}} \rightarrow \mathit{t} -} \, {[\textsc{\scriptsize T{-}select{-}expl}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{t} \leq {\mathit{t}'} - \qquad -{\mathit{t}'} = \mathit{numtype} \lor {\mathit{t}'} = \mathit{vectype} -}{ -\mathit{C} \vdash \mathsf{select} : \mathit{t}~\mathit{t}~\mathsf{i{\scriptstyle32}} \rightarrow \mathit{t} -} \, {[\textsc{\scriptsize T{-}select{-}impl}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{\mathit{context} \vdash \mathit{blocktype} : \mathit{functype}}$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{ft} : \mathsf{ok} -}{ -\mathit{C} \vdash \mathit{ft} : \mathit{ft} -} \, {[\textsc{\scriptsize K{-}block}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash \mathit{bt} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} - \qquad -\mathit{C}, \mathsf{label}~{\mathit{t}_{2}^\ast} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -}{ -\mathit{C} \vdash \mathsf{block}~\mathit{bt}~{\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}block}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash \mathit{bt} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} - \qquad -\mathit{C}, \mathsf{label}~{\mathit{t}_{1}^\ast} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -}{ -\mathit{C} \vdash \mathsf{loop}~\mathit{bt}~{\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}loop}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash \mathit{bt} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} - \qquad -\mathit{C}, \mathsf{label}~{\mathit{t}_{2}^\ast} \vdash {\mathit{instr}_{1}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} - \qquad -\mathit{C}, \mathsf{label}~{\mathit{t}_{2}^\ast} \vdash {\mathit{instr}_{2}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -}{ -\mathit{C} \vdash \mathsf{if}~\mathit{bt}~{\mathit{instr}_{1}^\ast}~\mathsf{else}~{\mathit{instr}_{2}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}if}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{label}[\mathit{l}] = {\mathit{t}^\ast} -}{ -\mathit{C} \vdash \mathsf{br}~\mathit{l} : {\mathit{t}_{1}^\ast}~{\mathit{t}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}br}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{label}[\mathit{l}] = {\mathit{t}^\ast} -}{ -\mathit{C} \vdash \mathsf{br\_if}~\mathit{l} : {\mathit{t}^\ast}~\mathsf{i{\scriptstyle32}} \rightarrow {\mathit{t}^\ast} -} \, {[\textsc{\scriptsize T{-}br\_if}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -({ \vdash }\;{\mathit{t}^\ast} \leq \mathit{C}.\mathsf{label}[\mathit{l}])^\ast - \qquad -{ \vdash }\;{\mathit{t}^\ast} \leq \mathit{C}.\mathsf{label}[{\mathit{l}'}] -}{ -\mathit{C} \vdash \mathsf{br\_table}~{\mathit{l}^\ast}~{\mathit{l}'} : {\mathit{t}_{1}^\ast}~{\mathit{t}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}br\_table}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{return} = ({\mathit{t}^\ast}) -}{ -\mathit{C} \vdash \mathsf{return} : {\mathit{t}_{1}^\ast}~{\mathit{t}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}return}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{func}[\mathit{x}] = {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -}{ -\mathit{C} \vdash \mathsf{call}~\mathit{x} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}call}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathsf{funcref} - \qquad -\mathit{ft} = {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} -}{ -\mathit{C} \vdash \mathsf{call\_indirect}~\mathit{x}~\mathit{ft} : {\mathit{t}_{1}^\ast}~\mathsf{i{\scriptstyle32}} \rightarrow {\mathit{t}_{2}^\ast} -} \, {[\textsc{\scriptsize T{-}call\_indirect}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathit{nt}.\mathsf{const}~\mathit{c}_{\mathit{nt}} : \epsilon \rightarrow \mathit{nt} -} \, {[\textsc{\scriptsize T{-}const}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathit{nt} . \mathit{unop} : \mathit{nt} \rightarrow \mathit{nt} -} \, {[\textsc{\scriptsize T{-}unop}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathit{nt} . \mathit{binop} : \mathit{nt}~\mathit{nt} \rightarrow \mathit{nt} -} \, {[\textsc{\scriptsize T{-}binop}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathit{nt} . \mathit{testop} : \mathit{nt} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}testop}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathit{nt} . \mathit{relop} : \mathit{nt}~\mathit{nt} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}relop}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{n} \leq {|\mathit{nt}|} -}{ -\mathit{C} \vdash {\mathit{nt}.\mathsf{extend}}{\mathit{n}} : \mathit{nt} \rightarrow \mathit{nt} -} \, {[\textsc{\scriptsize T{-}extend}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{nt}_{1} \neq \mathit{nt}_{2} - \qquad -{|\mathit{nt}_{1}|} = {|\mathit{nt}_{2}|} -}{ -\mathit{C} \vdash \mathsf{cvtop}~\mathit{nt}_{1}~\mathsf{reinterpret}~\mathit{nt}_{2} : \mathit{nt}_{2} \rightarrow \mathit{nt}_{1} -} \, {[\textsc{\scriptsize T{-}reinterpret}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{\mathsf{i}}{\mathit{n}}_{1} \neq {\mathsf{i}}{\mathit{n}}_{2} - \qquad -{\mathit{sx}^?} = \epsilon \Leftrightarrow {|{\mathsf{i}}{\mathit{n}}_{1}|} > {|{\mathsf{i}}{\mathit{n}}_{2}|} -}{ -\mathit{C} \vdash {\mathsf{i}}{\mathit{n}}_{1} . {{{{\mathsf{convert}}{\mathsf{\_}}}{{\mathsf{i}}{\mathit{n}}_{2}}}{\mathsf{\_}}}{{\mathit{sx}^?}} : {\mathsf{i}}{\mathit{n}}_{2} \rightarrow {\mathsf{i}}{\mathit{n}}_{1} -} \, {[\textsc{\scriptsize T{-}convert{-}i}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{\mathsf{f}}{\mathit{n}}_{1} \neq {\mathsf{f}}{\mathit{n}}_{2} -}{ -\mathit{C} \vdash \mathsf{cvtop}~{\mathsf{f}}{\mathit{n}}_{1}~\mathsf{convert}~{\mathsf{f}}{\mathit{n}}_{2} : {\mathsf{f}}{\mathit{n}}_{2} \rightarrow {\mathsf{f}}{\mathit{n}}_{1} -} \, {[\textsc{\scriptsize T{-}convert{-}f}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathsf{ref.null}~\mathit{rt} : \epsilon \rightarrow \mathit{rt} -} \, {[\textsc{\scriptsize T{-}ref.null}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{func}[\mathit{x}] = \mathit{ft} -}{ -\mathit{C} \vdash \mathsf{ref.func}~\mathit{x} : \epsilon \rightarrow \mathsf{funcref} -} \, {[\textsc{\scriptsize T{-}ref.func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathsf{ref.is\_null} : \mathit{rt} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}ref.is\_null}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{local}[\mathit{x}] = \mathit{t} -}{ -\mathit{C} \vdash \mathsf{local.get}~\mathit{x} : \epsilon \rightarrow \mathit{t} -} \, {[\textsc{\scriptsize T{-}local.get}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{local}[\mathit{x}] = \mathit{t} -}{ -\mathit{C} \vdash \mathsf{local.set}~\mathit{x} : \mathit{t} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}local.set}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{local}[\mathit{x}] = \mathit{t} -}{ -\mathit{C} \vdash \mathsf{local.tee}~\mathit{x} : \mathit{t} \rightarrow \mathit{t} -} \, {[\textsc{\scriptsize T{-}local.tee}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{global}[\mathit{x}] = {\mathsf{mut}^?}~\mathit{t} -}{ -\mathit{C} \vdash \mathsf{global.get}~\mathit{x} : \epsilon \rightarrow \mathit{t} -} \, {[\textsc{\scriptsize T{-}global.get}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{global}[\mathit{x}] = \mathsf{mut}~\mathit{t} -}{ -\mathit{C} \vdash \mathsf{global.set}~\mathit{x} : \mathit{t} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}global.set}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} -}{ -\mathit{C} \vdash \mathsf{table.get}~\mathit{x} : \mathsf{i{\scriptstyle32}} \rightarrow \mathit{rt} -} \, {[\textsc{\scriptsize T{-}table.get}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} -}{ -\mathit{C} \vdash \mathsf{table.set}~\mathit{x} : \mathsf{i{\scriptstyle32}}~\mathit{rt} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}table.set}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{tt} -}{ -\mathit{C} \vdash \mathsf{table.size}~\mathit{x} : \epsilon \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}table.size}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} -}{ -\mathit{C} \vdash \mathsf{table.grow}~\mathit{x} : \mathit{rt}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}table.grow}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} -}{ -\mathit{C} \vdash \mathsf{table.fill}~\mathit{x} : \mathsf{i{\scriptstyle32}}~\mathit{rt}~\mathsf{i{\scriptstyle32}} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}table.fill}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}_{1}] = \mathit{lim}_{1}~\mathit{rt} - \qquad -\mathit{C}.\mathsf{table}[\mathit{x}_{2}] = \mathit{lim}_{2}~\mathit{rt} -}{ -\mathit{C} \vdash \mathsf{table.copy}~\mathit{x}_{1}~\mathit{x}_{2} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}table.copy}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}_{1}] = \mathit{lim}~\mathit{rt} - \qquad -\mathit{C}.\mathsf{elem}[\mathit{x}_{2}] = \mathit{rt} -}{ -\mathit{C} \vdash \mathsf{table.init}~\mathit{x}_{1}~\mathit{x}_{2} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}table.init}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{elem}[\mathit{x}] = \mathit{rt} -}{ -\mathit{C} \vdash \mathsf{elem.drop}~\mathit{x} : \epsilon \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}elem.drop}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} -}{ -\mathit{C} \vdash \mathsf{memory.size} : \epsilon \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}memory.size}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} -}{ -\mathit{C} \vdash \mathsf{memory.grow} : \mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}memory.grow}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} -}{ -\mathit{C} \vdash \mathsf{memory.fill} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}memory.fill}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} -}{ -\mathit{C} \vdash \mathsf{memory.copy} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}memory.copy}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} - \qquad -\mathit{C}.\mathsf{data}[\mathit{x}] = \mathsf{ok} -}{ -\mathit{C} \vdash \mathsf{memory.init}~\mathit{x} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} -} \, {[\textsc{\scriptsize T{-}memory.init}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{data}[\mathit{x}] = \mathsf{ok} -}{ -\mathit{C} \vdash \mathsf{data.drop}~\mathit{x} : \epsilon \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}data.drop}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} - \qquad -{2^{\mathit{n}_{\mathsf{a}}}} \leq {|\mathit{nt}|} / 8 - \qquad -({2^{\mathit{n}_{\mathsf{a}}}} \leq \mathit{n} / 8 < {|\mathit{nt}|} / 8)^? - \qquad -{\mathit{n}^?} = \epsilon \lor \mathit{nt} = {\mathsf{i}}{\mathit{n}} -}{ -\mathit{C} \vdash {\mathit{nt}.\mathsf{load}}{{(\mathit{n}~\mathit{sx})^?}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}} : \mathsf{i{\scriptstyle32}} \rightarrow \mathit{nt} -} \, {[\textsc{\scriptsize T{-}load}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} - \qquad -{2^{\mathit{n}_{\mathsf{a}}}} \leq {|\mathit{nt}|} / 8 - \qquad -({2^{\mathit{n}_{\mathsf{a}}}} \leq \mathit{n} / 8 < {|\mathit{nt}|} / 8)^? - \qquad -{\mathit{n}^?} = \epsilon \lor \mathit{nt} = {\mathsf{i}}{\mathit{n}} -}{ -\mathit{C} \vdash {\mathit{nt}.\mathsf{store}}{{\mathit{n}^?}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}} : \mathsf{i{\scriptstyle32}}~\mathit{nt} \rightarrow \epsilon -} \, {[\textsc{\scriptsize T{-}store}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{\mathit{context} \vdash \mathit{instr}~\mathsf{const}}$ - -$\boxed{\mathit{context} \vdash \mathit{expr}~\mathsf{const}}$ - -$\boxed{\mathit{context} \vdash \mathit{expr} : \mathit{valtype}~\mathsf{const}}$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash (\mathit{nt}.\mathsf{const}~\mathit{c})~\mathsf{const} -} \, {[\textsc{\scriptsize C{-}instr{-}const}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash (\mathsf{ref.null}~\mathit{rt})~\mathsf{const} -} \, {[\textsc{\scriptsize C{-}instr{-}ref.null}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash (\mathsf{ref.func}~\mathit{x})~\mathsf{const} -} \, {[\textsc{\scriptsize C{-}instr{-}ref.func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{global}[\mathit{x}] = \epsilon~\mathit{t} -}{ -\mathit{C} \vdash (\mathsf{global.get}~\mathit{x})~\mathsf{const} -} \, {[\textsc{\scriptsize C{-}instr{-}global.get}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -(\mathit{C} \vdash \mathit{instr}~\mathsf{const})^\ast -}{ -\mathit{C} \vdash {\mathit{instr}^\ast}~\mathsf{const} -} \, {[\textsc{\scriptsize C{-}expr}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash \mathit{expr} : \mathit{t} - \qquad -\mathit{C} \vdash \mathit{expr}~\mathsf{const} -}{ -\mathit{C} \vdash \mathit{expr} : \mathit{t}~\mathsf{const} -} \, {[\textsc{\scriptsize TC{-}expr}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{\mathit{context} \vdash \mathit{func} : \mathit{functype}}$ - -$\boxed{\mathit{context} \vdash \mathit{global} : \mathit{globaltype}}$ - -$\boxed{\mathit{context} \vdash \mathit{table} : \mathit{tabletype}}$ - -$\boxed{\mathit{context} \vdash \mathit{mem} : \mathit{memtype}}$ - -$\boxed{\mathit{context} \vdash \mathit{elem} : \mathit{reftype}}$ - -$\boxed{\mathit{context} \vdash \mathit{data} : \mathsf{ok}}$ - -$\boxed{\mathit{context} \vdash \mathit{elemmode} : \mathit{reftype}}$ - -$\boxed{\mathit{context} \vdash \mathit{datamode} : \mathsf{ok}}$ - -$\boxed{\mathit{context} \vdash \mathit{start} : \mathsf{ok}}$ - -\vspace{1ex} - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{ft} = {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} - \qquad -{ \vdash }\;\mathit{ft} : \mathsf{ok} - \qquad -\mathit{C}, \mathsf{local}~{\mathit{t}_{1}^\ast}~{\mathit{t}^\ast}, \mathsf{label}~({\mathit{t}_{2}^\ast}), \mathsf{return}~({\mathit{t}_{2}^\ast}) \vdash \mathit{expr} : {\mathit{t}_{2}^\ast} -}{ -\mathit{C} \vdash \mathsf{func}~\mathit{ft}~{\mathit{t}^\ast}~\mathit{expr} : \mathit{ft} -} \, {[\textsc{\scriptsize T{-}func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{gt} : \mathsf{ok} - \qquad -\mathit{gt} = {\mathsf{mut}^?}~\mathit{t} - \qquad -\mathit{C} \vdash \mathit{expr} : \mathit{t}~\mathsf{const} -}{ -\mathit{C} \vdash \mathsf{global}~\mathit{gt}~\mathit{expr} : \mathit{gt} -} \, {[\textsc{\scriptsize T{-}global}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{tt} : \mathsf{ok} -}{ -\mathit{C} \vdash \mathsf{table}~\mathit{tt} : \mathit{tt} -} \, {[\textsc{\scriptsize T{-}table}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{mt} : \mathsf{ok} -}{ -\mathit{C} \vdash \mathsf{memory}~\mathit{mt} : \mathit{mt} -} \, {[\textsc{\scriptsize T{-}mem}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -(\mathit{C} \vdash \mathit{expr} : \mathit{rt})^\ast - \qquad -(\mathit{C} \vdash \mathit{elemmode} : \mathit{rt})^? -}{ -\mathit{C} \vdash \mathsf{elem}~\mathit{rt}~{\mathit{expr}^\ast}~{\mathit{elemmode}^?} : \mathit{rt} -} \, {[\textsc{\scriptsize T{-}elem}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -(\mathit{C} \vdash \mathit{datamode} : \mathsf{ok})^? -}{ -\mathit{C} \vdash \mathsf{data}~{({\mathit{b}^\ast})^\ast}~{\mathit{datamode}^?} : \mathsf{ok} -} \, {[\textsc{\scriptsize T{-}data}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} - \qquad -(\mathit{C} \vdash \mathit{expr} : \mathsf{i{\scriptstyle32}}~\mathsf{const})^\ast -}{ -\mathit{C} \vdash \mathsf{table}~\mathit{x}~\mathit{expr} : \mathit{rt} -} \, {[\textsc{\scriptsize T{-}elemmode{-}active}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -}{ -\mathit{C} \vdash \mathsf{declare} : \mathit{rt} -} \, {[\textsc{\scriptsize T{-}elemmode{-}declare}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[0] = \mathit{mt} - \qquad -(\mathit{C} \vdash \mathit{expr} : \mathsf{i{\scriptstyle32}}~\mathsf{const})^\ast -}{ -\mathit{C} \vdash \mathsf{memory}~0~\mathit{expr} : \mathsf{ok} -} \, {[\textsc{\scriptsize T{-}datamode}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{func}[\mathit{x}] = \epsilon \rightarrow \epsilon -}{ -\mathit{C} \vdash \mathsf{start}~\mathit{x} : \mathsf{ok} -} \, {[\textsc{\scriptsize T{-}start}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{\mathit{context} \vdash \mathit{import} : \mathit{externtype}}$ - -$\boxed{\mathit{context} \vdash \mathit{export} : \mathit{externtype}}$ - -$\boxed{\mathit{context} \vdash \mathit{externuse} : \mathit{externtype}}$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -{ \vdash }\;\mathit{xt} : \mathsf{ok} -}{ -\mathit{C} \vdash \mathsf{import}~\mathit{name}_{1}~\mathit{name}_{2}~\mathit{xt} : \mathit{xt} -} \, {[\textsc{\scriptsize T{-}import}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C} \vdash \mathit{externuse} : \mathit{xt} -}{ -\mathit{C} \vdash \mathsf{export}~\mathit{name}~\mathit{externuse} : \mathit{xt} -} \, {[\textsc{\scriptsize T{-}export}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{func}[\mathit{x}] = \mathit{ft} -}{ -\mathit{C} \vdash \mathsf{func}~\mathit{x} : \mathsf{func}~\mathit{ft} -} \, {[\textsc{\scriptsize T{-}externuse{-}func}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{global}[\mathit{x}] = \mathit{gt} -}{ -\mathit{C} \vdash \mathsf{global}~\mathit{x} : \mathsf{global}~\mathit{gt} -} \, {[\textsc{\scriptsize T{-}externuse{-}global}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{tt} -}{ -\mathit{C} \vdash \mathsf{table}~\mathit{x} : \mathsf{table}~\mathit{tt} -} \, {[\textsc{\scriptsize T{-}externuse{-}table}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\mathit{C}.\mathsf{mem}[\mathit{x}] = \mathit{mt} -}{ -\mathit{C} \vdash \mathsf{memory}~\mathit{x} : \mathsf{memory}~\mathit{mt} -} \, {[\textsc{\scriptsize T{-}externuse{-}mem}]} -\qquad -\end{array} -$$ - -\vspace{1ex} - -$\boxed{{ \vdash }\;\mathit{module} : \mathsf{ok}}$ - -$$ -\begin{array}{@{}c@{}}\displaystyle -\frac{ -\begin{array}{@{}c@{}} -\mathit{C} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{func}~{\mathit{ft}^\ast},\; \mathsf{global}~{\mathit{gt}^\ast},\; \mathsf{table}~{\mathit{tt}^\ast},\; \mathsf{mem}~{\mathit{mt}^\ast},\; \mathsf{elem}~{\mathit{rt}^\ast},\; \mathsf{data}~{\mathsf{ok}^{\mathit{n}}} \}\end{array} - \\ -(\mathit{C} \vdash \mathit{func} : \mathit{ft})^\ast - \qquad -(\mathit{C} \vdash \mathit{global} : \mathit{gt})^\ast - \qquad -(\mathit{C} \vdash \mathit{table} : \mathit{tt})^\ast - \qquad -(\mathit{C} \vdash \mathit{mem} : \mathit{mt})^\ast - \\ -(\mathit{C} \vdash \mathit{elem} : \mathit{rt})^\ast - \qquad -(\mathit{C} \vdash \mathit{data} : \mathsf{ok})^{\mathit{n}} - \qquad -(\mathit{C} \vdash \mathit{start} : \mathsf{ok})^\ast - \\ -{|{\mathit{mem}^\ast}|} \leq 1 - \qquad -{|{\mathit{start}^\ast}|} \leq 1 -\end{array} -}{ -{ \vdash }\;\mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^{\mathit{n}}}~{\mathit{start}^\ast}~{\mathit{export}^\ast} : \mathsf{ok} -} \, {[\textsc{\scriptsize T{-}module}]} -\qquad -\end{array} -$$ - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(address)} & \mathit{addr} &::=& \mathit{nat} \\ -\mbox{(function address)} & \mathit{funcaddr} &::=& \mathit{addr} \\ -\mbox{(global address)} & \mathit{globaladdr} &::=& \mathit{addr} \\ -\mbox{(table address)} & \mathit{tableaddr} &::=& \mathit{addr} \\ -\mbox{(memory address)} & \mathit{memaddr} &::=& \mathit{addr} \\ -\mbox{(elem address)} & \mathit{elemaddr} &::=& \mathit{addr} \\ -\mbox{(data address)} & \mathit{dataaddr} &::=& \mathit{addr} \\ -\mbox{(label address)} & \mathit{labeladdr} &::=& \mathit{addr} \\ -\mbox{(host address)} & \mathit{hostaddr} &::=& \mathit{addr} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(number)} & \mathit{num} &::=& \mathsf{\mathit{numtype}}.\mathsf{const}~\mathsf{\mathit{c}\_{\mathit{numtype}}} \\ -\mbox{(reference)} & \mathit{ref} &::=& \mathsf{ref.null}~\mathit{reftype} ~|~ \mathsf{ref.func}~\mathsf{\mathit{funcaddr}} ~|~ \mathsf{ref.extern}~\mathsf{\mathit{hostaddr}} \\ -\mbox{(value)} & \mathit{val} &::=& \mathit{num} ~|~ \mathit{ref} \\ -\mbox{(result)} & \mathit{result} &::=& {\mathit{val}^\ast} ~|~ \mathsf{trap} \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(external value)} & \mathit{externval} &::=& \mathsf{func}~\mathit{funcaddr} ~|~ \mathsf{global}~\mathit{globaladdr} ~|~ \mathsf{table}~\mathit{tableaddr} ~|~ \mathsf{mem}~\mathit{memaddr} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lcl@{}l@{}} -{\mathrm{default}}_{\mathsf{i{\scriptstyle32}}} &=& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~0) & \\ -{\mathrm{default}}_{\mathsf{i{\scriptstyle64}}} &=& (\mathsf{i{\scriptstyle64}}.\mathsf{const}~0) & \\ -{\mathrm{default}}_{\mathsf{f{\scriptstyle32}}} &=& (\mathsf{f{\scriptstyle32}}.\mathsf{const}~0) & \\ -{\mathrm{default}}_{\mathsf{f{\scriptstyle64}}} &=& (\mathsf{f{\scriptstyle64}}.\mathsf{const}~0) & \\ -{\mathrm{default}}_{\mathit{rt}} &=& (\mathsf{ref.null}~\mathit{rt}) & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(function instance)} & \mathit{funcinst} &::=& \mathit{moduleinst} ; \mathit{func} \\ -\mbox{(global instance)} & \mathit{globalinst} &::=& \mathit{val} \\ -\mbox{(table instance)} & \mathit{tableinst} &::=& {\mathit{ref}^\ast} \\ -\mbox{(memory instance)} & \mathit{meminst} &::=& {\mathit{byte}^\ast} \\ -\mbox{(element instance)} & \mathit{eleminst} &::=& {\mathit{ref}^\ast} \\ -\mbox{(data instance)} & \mathit{datainst} &::=& {\mathit{byte}^\ast} \\ -\mbox{(export instance)} & \mathit{exportinst} &::=& \mathsf{export}~\mathit{name}~\mathit{externval} \\ -\mbox{(store)} & \mathit{store} &::=& \{\; \begin{array}[t]{@{}l@{}} -\mathsf{func}~{\mathit{funcinst}^\ast},\; \\ - \mathsf{global}~{\mathit{globalinst}^\ast},\; \\ - \mathsf{table}~{\mathit{tableinst}^\ast},\; \\ - \mathsf{mem}~{\mathit{meminst}^\ast},\; \\ - \mathsf{elem}~{\mathit{eleminst}^\ast},\; \\ - \mathsf{data}~{\mathit{datainst}^\ast} \;\}\end{array} \\ -\mbox{(module instance)} & \mathit{moduleinst} &::=& \{\; \begin{array}[t]{@{}l@{}} -\mathsf{func}~{\mathit{funcaddr}^\ast},\; \\ - \mathsf{global}~{\mathit{globaladdr}^\ast},\; \\ - \mathsf{table}~{\mathit{tableaddr}^\ast},\; \\ - \mathsf{mem}~{\mathit{memaddr}^\ast},\; \\ - \mathsf{elem}~{\mathit{elemaddr}^\ast},\; \\ - \mathsf{data}~{\mathit{dataaddr}^\ast},\; \\ - \mathsf{export}~{\mathit{exportinst}^\ast} \;\}\end{array} \\ -\mbox{(frame)} & \mathit{frame} &::=& \{\; \begin{array}[t]{@{}l@{}} -\mathsf{local}~{\mathit{val}^\ast},\; \\ - \mathsf{module}~\mathit{moduleinst} \;\}\end{array} \\ -\mbox{(state)} & \mathit{state} &::=& \mathit{store} ; \mathit{frame} \\ -\mbox{(configuration)} & \mathit{config} &::=& \mathit{state} ; {\mathit{instr}^\ast} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f}).\mathsf{module}.\mathsf{func} &=& \mathit{f}.\mathsf{module}.\mathsf{func} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f}).\mathsf{func} &=& \mathit{s}.\mathsf{func} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{(\mathit{s} ; \mathit{f}).\mathsf{func}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{func}[\mathit{f}.\mathsf{module}.\mathsf{func}[\mathit{x}]] & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{(\mathit{s} ; \mathit{f}).\mathsf{global}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{global}[\mathit{f}.\mathsf{module}.\mathsf{global}[\mathit{x}]] & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{(\mathit{s} ; \mathit{f}).\mathsf{table}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{(\mathit{s} ; \mathit{f}).\mathsf{mem}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]] & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{(\mathit{s} ; \mathit{f}).\mathsf{elem}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{elem}[\mathit{f}.\mathsf{module}.\mathsf{elem}[\mathit{x}]] & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{(\mathit{s} ; \mathit{f}).\mathsf{data}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{data}[\mathit{f}.\mathsf{module}.\mathsf{data}[\mathit{x}]] & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -{(\mathit{s} ; \mathit{f}).\mathsf{local}}{[\mathit{x}]} &=& \mathit{f}.\mathsf{local}[\mathit{x}] & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{local}[\mathit{x}] = \mathit{v}] &=& \mathit{s} ; \mathit{f}[\mathsf{local}[\mathit{x}] = \mathit{v}] & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{global}[\mathit{x}] = \mathit{v}] &=& \mathit{s}[\mathsf{global}[\mathit{f}.\mathsf{module}.\mathsf{global}[\mathit{x}]] = \mathit{v}] ; \mathit{f} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}][\mathit{i}] = \mathit{r}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]][\mathit{i}] = \mathit{r}] ; \mathit{f} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}] = ..{\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] = ..{\mathit{r}^\ast}] ; \mathit{f} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}lcl@{}l@{}} -(\mathit{s} ; \mathit{f})[\mathsf{elem}[\mathit{x}] = {\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] = {\mathit{r}^\ast}] ; \mathit{f} & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}lrrl@{}} -\mbox{(administrative instruction)} & \mathit{instr} &::=& \mathit{instr} \\ &&|& -\mathsf{ref.func}~\mathsf{\mathit{funcaddr}} \\ &&|& -\mathsf{ref.extern}~\mathsf{\mathit{hostaddr}} \\ &&|& -\mathsf{call}~\mathsf{\mathit{funcaddr}} \\ &&|& -{{\mathsf{label}}_{\mathsf{\mathit{n}}}}{\mathsf{\{{\mathit{instr}^\ast}\}}~\mathsf{{\mathit{instr}^\ast}}} \\ &&|& -{{\mathsf{frame}}_{\mathsf{\mathit{n}}}}{\mathsf{\{\mathit{frame}\}}~\mathsf{{\mathit{instr}^\ast}}} \\ &&|& -\mathsf{trap} \\ -\mbox{(evaluation context)} & \mathit{E} &::=& [\mathsf{\_}] \\ &&|& -{\mathit{val}^\ast}~\mathit{E}~{\mathit{instr}^\ast} \\ &&|& -{{\mathsf{label}}_{\mathsf{\mathit{n}}}}{\mathsf{\{{\mathit{instr}^\ast}\}}~\mathsf{\mathit{e}}} \\ -\end{array} -$$ - -$\boxed{\mathit{config} \hookrightarrow \mathit{config}}$ - -$\boxed{{\mathit{instr}^\ast} \hookrightarrow {\mathit{instr}^\ast}}$ - -$\boxed{\mathit{config} \hookrightarrow {\mathit{instr}^\ast}}$ - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}pure}]} \quad & \mathit{z} ; {\mathit{instr}^\ast} &\hookrightarrow& \mathit{z} ; {{\mathit{instr}'}^\ast} &\quad - \mbox{if}~{\mathit{instr}^\ast} \hookrightarrow {{\mathit{instr}'}^\ast} \\ -{[\textsc{\scriptsize E{-}read}]} \quad & \mathit{z} ; {\mathit{instr}^\ast} &\hookrightarrow& \mathit{z} ; {{\mathit{instr}'}^\ast} &\quad - \mbox{if}~\mathit{z} ; {\mathit{instr}^\ast} \hookrightarrow {{\mathit{instr}'}^\ast} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}unreachable}]} \quad & \mathsf{unreachable} &\hookrightarrow& \mathsf{trap} & \\ -{[\textsc{\scriptsize E{-}nop}]} \quad & \mathsf{nop} &\hookrightarrow& \epsilon & \\ -{[\textsc{\scriptsize E{-}drop}]} \quad & \mathit{val}~\mathsf{drop} &\hookrightarrow& \epsilon & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}select{-}true}]} \quad & \mathit{val}_{1}~\mathit{val}_{2}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{select}~{\mathit{t}^?}) &\hookrightarrow& \mathit{val}_{1} &\quad - \mbox{if}~\mathit{c} \neq 0 \\ -{[\textsc{\scriptsize E{-}select{-}false}]} \quad & \mathit{val}_{1}~\mathit{val}_{2}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{select}~{\mathit{t}^?}) &\hookrightarrow& \mathit{val}_{2} &\quad - \mbox{if}~\mathit{c} = 0 \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}block}]} \quad & {\mathit{val}^{\mathit{k}}}~(\mathsf{block}~\mathit{bt}~{\mathit{instr}^\ast}) &\hookrightarrow& ({{\mathsf{label}}_{\mathit{n}}}{\{\epsilon\}~{\mathit{val}^{\mathit{k}}}~{\mathit{instr}^\ast}}) &\quad - \mbox{if}~\mathit{bt} = {\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}} \\ -{[\textsc{\scriptsize E{-}loop}]} \quad & {\mathit{val}^{\mathit{k}}}~(\mathsf{loop}~\mathit{bt}~{\mathit{instr}^\ast}) &\hookrightarrow& ({{\mathsf{label}}_{\mathit{n}}}{\{\mathsf{loop}~\mathit{bt}~{\mathit{instr}^\ast}\}~{\mathit{val}^{\mathit{k}}}~{\mathit{instr}^\ast}}) &\quad - \mbox{if}~\mathit{bt} = {\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}} \\ -{[\textsc{\scriptsize E{-}if{-}true}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{if}~\mathit{bt}~{\mathit{instr}_{1}^\ast}~\mathsf{else}~{\mathit{instr}_{2}^\ast}) &\hookrightarrow& (\mathsf{block}~\mathit{bt}~{\mathit{instr}_{1}^\ast}) &\quad - \mbox{if}~\mathit{c} \neq 0 \\ -{[\textsc{\scriptsize E{-}if{-}false}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{if}~\mathit{bt}~{\mathit{instr}_{1}^\ast}~\mathsf{else}~{\mathit{instr}_{2}^\ast}) &\hookrightarrow& (\mathsf{block}~\mathit{bt}~{\mathit{instr}_{2}^\ast}) &\quad - \mbox{if}~\mathit{c} = 0 \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}label{-}vals}]} \quad & ({{\mathsf{label}}_{\mathit{n}}}{\{{\mathit{instr}^\ast}\}~{\mathit{val}^\ast}}) &\hookrightarrow& {\mathit{val}^\ast} & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}br{-}zero}]} \quad & ({{\mathsf{label}}_{\mathit{n}}}{\{{{\mathit{instr}'}^\ast}\}~{{\mathit{val}'}^\ast}~{\mathit{val}^{\mathit{n}}}~(\mathsf{br}~0)~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^{\mathit{n}}}~{{\mathit{instr}'}^\ast} & \\ -{[\textsc{\scriptsize E{-}br{-}succ}]} \quad & ({{\mathsf{label}}_{\mathit{n}}}{\{{{\mathit{instr}'}^\ast}\}~{\mathit{val}^\ast}~(\mathsf{br}~\mathit{l} + 1)~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^\ast}~(\mathsf{br}~\mathit{l}) & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}br\_if{-}true}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{br\_if}~\mathit{l}) &\hookrightarrow& (\mathsf{br}~\mathit{l}) &\quad - \mbox{if}~\mathit{c} \neq 0 \\ -{[\textsc{\scriptsize E{-}br\_if{-}false}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{br\_if}~\mathit{l}) &\hookrightarrow& \epsilon &\quad - \mbox{if}~\mathit{c} = 0 \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}br\_table{-}lt}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{br\_table}~{\mathit{l}^\ast}~{\mathit{l}'}) &\hookrightarrow& (\mathsf{br}~{\mathit{l}^\ast}[\mathit{i}]) &\quad - \mbox{if}~\mathit{i} < {|{\mathit{l}^\ast}|} \\ -{[\textsc{\scriptsize E{-}br\_table{-}ge}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{br\_table}~{\mathit{l}^\ast}~{\mathit{l}'}) &\hookrightarrow& (\mathsf{br}~{\mathit{l}'}) &\quad - \mbox{if}~\mathit{i} \geq {|{\mathit{l}^\ast}|} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}call}]} \quad & \mathit{z} ; (\mathsf{call}~\mathit{x}) &\hookrightarrow& (\mathsf{call}~\mathit{z}.\mathsf{module}.\mathsf{func}[\mathit{x}]) & \\ -{[\textsc{\scriptsize E{-}call\_indirect{-}call}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{call\_indirect}~\mathit{x}~\mathit{ft}) &\hookrightarrow& (\mathsf{call}~\mathit{a}) &\quad - \mbox{if}~{\mathit{z}.\mathsf{table}}{[\mathit{x}]}[\mathit{i}] = (\mathsf{ref.func}~\mathit{a}) \\ - &&&&\quad {\land}~\mathit{z}.\mathsf{func}[\mathit{a}] = \mathit{m} ; \mathit{func} \\ -{[\textsc{\scriptsize E{-}call\_indirect{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{call\_indirect}~\mathit{x}~\mathit{ft}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{otherwise} \\ -{[\textsc{\scriptsize E{-}call\_addr}]} \quad & \mathit{z} ; {\mathit{val}^{\mathit{k}}}~(\mathsf{call}~\mathit{a}) &\hookrightarrow& ({{\mathsf{frame}}_{\mathit{n}}}{\{\mathit{f}\}~({{\mathsf{label}}_{\mathit{n}}}{\{\epsilon\}~{\mathit{instr}^\ast}})}) &\quad - \mbox{if}~\mathit{z}.\mathsf{func}[\mathit{a}] = \mathit{m} ; \mathsf{func}~({\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}})~{\mathit{t}^\ast}~{\mathit{instr}^\ast} \\ - &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} -\mathsf{local}~{\mathit{val}^{\mathit{k}}}~{({\mathrm{default}}_{\mathit{t}})^\ast},\; \mathsf{module}~\mathit{m} \}\end{array} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}frame{-}vals}]} \quad & ({{\mathsf{frame}}_{\mathit{n}}}{\{\mathit{f}\}~{\mathit{val}^{\mathit{n}}}}) &\hookrightarrow& {\mathit{val}^{\mathit{n}}} & \\ -{[\textsc{\scriptsize E{-}return{-}frame}]} \quad & ({{\mathsf{frame}}_{\mathit{n}}}{\{\mathit{f}\}~{{\mathit{val}'}^\ast}~{\mathit{val}^{\mathit{n}}}~\mathsf{return}~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^{\mathit{n}}} & \\ -{[\textsc{\scriptsize E{-}return{-}label}]} \quad & ({{\mathsf{label}}_{\mathit{k}}}{\{{{\mathit{instr}'}^\ast}\}~{\mathit{val}^\ast}~\mathsf{return}~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^\ast}~\mathsf{return} & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}unop{-}val}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt} . \mathit{unop}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~\mathit{c}) &\quad - \mbox{if}~{\mathit{unop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1})} = \mathit{c} \\ -{[\textsc{\scriptsize E{-}unop{-}trap}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt} . \mathit{unop}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~{\mathit{unop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1})} = \epsilon \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}binop{-}val}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}.\mathsf{const}~\mathit{c}_{2})~(\mathit{nt} . \mathit{binop}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~\mathit{c}) &\quad - \mbox{if}~{\mathit{binop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1},\, \mathit{c}_{2})} = \mathit{c} \\ -{[\textsc{\scriptsize E{-}binop{-}trap}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}.\mathsf{const}~\mathit{c}_{2})~(\mathit{nt} . \mathit{binop}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~{\mathit{binop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1},\, \mathit{c}_{2})} = \epsilon \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}testop}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt} . \mathit{testop}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c}) &\quad - \mbox{if}~\mathit{c} = {\mathit{testop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1})} \\ -{[\textsc{\scriptsize E{-}relop}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}.\mathsf{const}~\mathit{c}_{2})~(\mathit{nt} . \mathit{relop}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c}) &\quad - \mbox{if}~\mathit{c} = {\mathit{relop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1},\, \mathit{c}_{2})} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}extend}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c})~({\mathit{nt}.\mathsf{extend}}{\mathit{n}}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~{{\mathrm{ext}}_{\mathit{n}}({|\mathit{nt}|})^{\mathsf{s}}}~(\mathit{c})) & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}cvtop{-}val}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}_{1} . {{{{\mathit{cvtop}}{\mathsf{\_}}}{\mathit{nt}_{2}}}{\mathsf{\_}}}{{\mathit{sx}^?}}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~\mathit{c}) &\quad - \mbox{if}~\mathrm{cvtop}(\mathit{nt}_{1},\, \mathit{cvtop},\, \mathit{nt}_{2},\, {\mathit{sx}^?},\, \mathit{c}_{1}) = \mathit{c} \\ -{[\textsc{\scriptsize E{-}cvtop{-}trap}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}_{1} . {{{{\mathit{cvtop}}{\mathsf{\_}}}{\mathit{nt}_{2}}}{\mathsf{\_}}}{{\mathit{sx}^?}}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathrm{cvtop}(\mathit{nt}_{1},\, \mathit{cvtop},\, \mathit{nt}_{2},\, {\mathit{sx}^?},\, \mathit{c}_{1}) = \epsilon \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}ref.func}]} \quad & \mathit{z} ; (\mathsf{ref.func}~\mathit{x}) &\hookrightarrow& (\mathsf{ref.func}~\mathit{z}.\mathsf{module}.\mathsf{func}[\mathit{x}]) & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}ref.is\_null{-}true}]} \quad & \mathit{val}~\mathsf{ref.is\_null} &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~1) &\quad - \mbox{if}~\mathit{val} = (\mathsf{ref.null}~\mathit{rt}) \\ -{[\textsc{\scriptsize E{-}ref.is\_null{-}false}]} \quad & \mathit{val}~\mathsf{ref.is\_null} &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~0) &\quad - \mbox{otherwise} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}local.get}]} \quad & \mathit{z} ; (\mathsf{local.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{local}}{[\mathit{x}]} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}local.set}]} \quad & \mathit{z} ; \mathit{val}~(\mathsf{local.set}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{local}[\mathit{x}] = \mathit{val}] ; \epsilon & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}local.tee}]} \quad & \mathit{val}~(\mathsf{local.tee}~\mathit{x}) &\hookrightarrow& \mathit{val}~\mathit{val}~(\mathsf{local.set}~\mathit{x}) & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}global.get}]} \quad & \mathit{z} ; (\mathsf{global.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{global}}{[\mathit{x}]} & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}global.set}]} \quad & \mathit{z} ; \mathit{val}~(\mathsf{global.set}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{global}[\mathit{x}] = \mathit{val}] ; \epsilon & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.get{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -{[\textsc{\scriptsize E{-}table.get{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{table}}{[\mathit{x}]}[\mathit{i}] &\quad - \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -{[\textsc{\scriptsize E{-}table.set{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{ref}~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -\end{array} -$$ - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.set{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{ref}~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}][\mathit{i}] = \mathit{ref}] ; \epsilon &\quad - \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.size}]} \quad & \mathit{z} ; (\mathsf{table.size}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n}) &\quad - \mbox{if}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} = \mathit{n} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}] = ..{\mathit{ref}^{\mathit{n}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|}) & \\ -\end{array} -$$ - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.fill{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -{[\textsc{\scriptsize E{-}table.fill{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& \epsilon &\quad - \mbox{otherwise, if}~\mathit{n} = 0 \\ -{[\textsc{\scriptsize E{-}table.fill{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.fill}~\mathit{x}) &\quad - \mbox{otherwise} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.copy{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{y}]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -{[\textsc{\scriptsize E{-}table.copy{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& \epsilon &\quad - \mbox{otherwise, if}~\mathit{n} = 0 \\ -{[\textsc{\scriptsize E{-}table.copy{-}le}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{y})~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\quad - \mbox{otherwise, if}~\mathit{j} \leq \mathit{i} \\ -{[\textsc{\scriptsize E{-}table.copy{-}gt}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + \mathit{n} - 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + \mathit{n} - 1)~(\mathsf{table.get}~\mathit{y})~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\quad - \mbox{otherwise} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}table.init{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& \mathsf{trap} &\quad - \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ -{[\textsc{\scriptsize E{-}table.init{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& \epsilon &\quad - \mbox{otherwise, if}~\mathit{n} = 0 \\ -{[\textsc{\scriptsize E{-}table.init{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}[\mathit{i}]~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\quad - \mbox{otherwise} \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\begin{array}{@{}l@{}lcl@{}l@{}} -{[\textsc{\scriptsize E{-}elem.drop}]} \quad & \mathit{z} ; (\mathsf{elem.drop}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{elem}[\mathit{x}] = \epsilon] ; \epsilon & \\ -\end{array} -$$ - -\vspace{1ex} - - -== Complete. +Error: A running dune (pid: 950144) instance has locked the build directory. +If this is not the case, please delete _build/.lock +[1] ``` diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 2c2756073f..9a27075543 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1,7 +1,7 @@ # Preview ```sh -$ (cd ../spec && ../src/exe-watsup/main.exe *.watsup -l --print-all-il --totalize --check-only) +$ (cd ../spec && ../src/exe-watsup/main.exe *.watsup -l --print-all-il --totalize --sideconditions --check-only) == Parsing... == Elaboration... @@ -2966,6 +2966,1564 @@ relation Step: `%~>%`(config, config) rule elem.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) +== IL Validation... +== Side condition inference + +;; 1-syntax.watsup:3.1-3.15 +syntax n = nat + +;; 1-syntax.watsup:9.1-9.37 +syntax name = text + +;; 1-syntax.watsup:14.1-14.36 +syntax byte = nat + +;; 1-syntax.watsup:15.1-15.45 +syntax u32 = nat + +;; 1-syntax.watsup:22.1-22.36 +syntax idx = nat + +;; 1-syntax.watsup:23.1-23.49 +syntax funcidx = idx + +;; 1-syntax.watsup:24.1-24.49 +syntax globalidx = idx + +;; 1-syntax.watsup:25.1-25.47 +syntax tableidx = idx + +;; 1-syntax.watsup:26.1-26.46 +syntax memidx = idx + +;; 1-syntax.watsup:27.1-27.45 +syntax elemidx = idx + +;; 1-syntax.watsup:28.1-28.45 +syntax dataidx = idx + +;; 1-syntax.watsup:29.1-29.47 +syntax labelidx = idx + +;; 1-syntax.watsup:30.1-30.47 +syntax localidx = idx + +;; 1-syntax.watsup:39.1-40.22 +syntax numtype = + | I32 + | I64 + | F32 + | F64 + +;; 1-syntax.watsup:41.1-42.5 +syntax vectype = + | V128 + +;; 1-syntax.watsup:43.1-44.20 +syntax reftype = + | FUNCREF + | EXTERNREF + +;; 1-syntax.watsup:45.1-46.34 +syntax valtype = + | I32 + | I64 + | F32 + | F64 + | V128 + | FUNCREF + | EXTERNREF + | BOT + +;; 1-syntax.watsup:48.1-48.39 +syntax in = + | I32 + | I64 + +;; 1-syntax.watsup:49.1-49.39 +syntax fn = + | F32 + | F64 + +;; 1-syntax.watsup:56.1-57.11 +syntax resulttype = valtype* + +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) + +;; 1-syntax.watsup:61.1-62.15 +syntax globaltype = `MUT%?%`(()?, valtype) + +;; 1-syntax.watsup:63.1-64.27 +syntax functype = `%->%`(resulttype, resulttype) + +;; 1-syntax.watsup:65.1-66.17 +syntax tabletype = `%%`(limits, reftype) + +;; 1-syntax.watsup:67.1-68.12 +syntax memtype = `%I8`(limits) + +;; 1-syntax.watsup:69.1-70.10 +syntax elemtype = reftype + +;; 1-syntax.watsup:71.1-72.5 +syntax datatype = OK + +;; 1-syntax.watsup:73.1-74.69 +syntax externtype = + | GLOBAL(globaltype) + | FUNC(functype) + | TABLE(tabletype) + | MEMORY(memtype) + +;; 1-syntax.watsup:86.1-86.44 +syntax sx = + | U + | S + +;; 1-syntax.watsup:88.1-88.39 +syntax unop_IXX = + | CLZ + | CTZ + | POPCNT + +;; 1-syntax.watsup:89.1-89.70 +syntax unop_FXX = + | ABS + | NEG + | SQRT + | CEIL + | FLOOR + | TRUNC + | NEAREST + +;; 1-syntax.watsup:91.1-93.62 +syntax binop_IXX = + | ADD + | SUB + | MUL + | DIV(sx) + | REM(sx) + | AND + | OR + | XOR + | SHL + | SHR(sx) + | ROTL + | ROTR + +;; 1-syntax.watsup:94.1-94.66 +syntax binop_FXX = + | ADD + | SUB + | MUL + | DIV + | MIN + | MAX + | COPYSIGN + +;; 1-syntax.watsup:96.1-96.26 +syntax testop_IXX = + | EQZ + +;; 1-syntax.watsup:97.1-97.22 +syntax testop_FXX = + | + +;; 1-syntax.watsup:99.1-100.108 +syntax relop_IXX = + | EQ + | NE + | LT(sx) + | GT(sx) + | LE(sx) + | GE(sx) + +;; 1-syntax.watsup:101.1-101.49 +syntax relop_FXX = + | EQ + | NE + | LT + | GT + | LE + | GE + +;; 1-syntax.watsup:103.1-103.50 +syntax unop_numtype = + | _I(unop_IXX) + | _F(unop_FXX) + +;; 1-syntax.watsup:104.1-104.53 +syntax binop_numtype = + | _I(binop_IXX) + | _F(binop_FXX) + +;; 1-syntax.watsup:105.1-105.56 +syntax testop_numtype = + | _I(testop_IXX) + | _F(testop_FXX) + +;; 1-syntax.watsup:106.1-106.53 +syntax relop_numtype = + | _I(relop_IXX) + | _F(relop_FXX) + +;; 1-syntax.watsup:107.1-107.39 +syntax cvtop = + | CONVERT + | REINTERPRET + +;; 1-syntax.watsup:117.1-117.23 +syntax c_numtype = nat + +;; 1-syntax.watsup:118.1-118.23 +syntax c_vectype = nat + +;; 1-syntax.watsup:121.1-121.52 +syntax blocktype = functype + +;; 1-syntax.watsup:156.1-177.55 +rec { + +;; 1-syntax.watsup:156.1-177.55 +syntax instr = + | UNREACHABLE + | NOP + | DROP + | SELECT(valtype?) + | BLOCK(blocktype, instr*) + | LOOP(blocktype, instr*) + | IF(blocktype, instr*, instr*) + | BR(labelidx) + | BR_IF(labelidx) + | BR_TABLE(labelidx*, labelidx) + | CALL(funcidx) + | CALL_INDIRECT(tableidx, functype) + | RETURN + | CONST(numtype, c_numtype) + | UNOP(numtype, unop_numtype) + | BINOP(numtype, binop_numtype) + | TESTOP(numtype, testop_numtype) + | RELOP(numtype, relop_numtype) + | EXTEND(numtype, n) + | CVTOP(numtype, cvtop, numtype, sx?) + | REF.NULL(reftype) + | REF.FUNC(funcidx) + | REF.IS_NULL + | LOCAL.GET(localidx) + | LOCAL.SET(localidx) + | LOCAL.TEE(localidx) + | GLOBAL.GET(globalidx) + | GLOBAL.SET(globalidx) + | TABLE.GET(tableidx) + | TABLE.SET(tableidx) + | TABLE.SIZE(tableidx) + | TABLE.GROW(tableidx) + | TABLE.FILL(tableidx) + | TABLE.COPY(tableidx, tableidx) + | TABLE.INIT(tableidx, elemidx) + | ELEM.DROP(elemidx) + | MEMORY.SIZE + | MEMORY.GROW + | MEMORY.FILL + | MEMORY.COPY + | MEMORY.INIT(dataidx) + | DATA.DROP(dataidx) + | LOAD(numtype, (n, sx)?, nat, nat) + | STORE(numtype, n?, nat, nat) +} + +;; 1-syntax.watsup:179.1-180.9 +syntax expr = instr* + +;; 1-syntax.watsup:185.1-185.50 +syntax elemmode = + | TABLE(tableidx, expr) + | DECLARE + +;; 1-syntax.watsup:186.1-186.39 +syntax datamode = + | MEMORY(memidx, expr) + +;; 1-syntax.watsup:188.1-189.30 +syntax func = `FUNC%%*%`(functype, valtype*, expr) + +;; 1-syntax.watsup:190.1-191.25 +syntax global = GLOBAL(globaltype, expr) + +;; 1-syntax.watsup:192.1-193.18 +syntax table = TABLE(tabletype) + +;; 1-syntax.watsup:194.1-195.17 +syntax mem = MEMORY(memtype) + +;; 1-syntax.watsup:196.1-197.31 +syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) + +;; 1-syntax.watsup:198.1-199.26 +syntax data = `DATA(*)%*%?`(byte**, datamode?) + +;; 1-syntax.watsup:200.1-201.16 +syntax start = START(funcidx) + +;; 1-syntax.watsup:203.1-204.65 +syntax externuse = + | FUNC(funcidx) + | GLOBAL(globalidx) + | TABLE(tableidx) + | MEMORY(memidx) + +;; 1-syntax.watsup:205.1-206.24 +syntax export = EXPORT(name, externuse) + +;; 1-syntax.watsup:207.1-208.30 +syntax import = IMPORT(name, name, externtype) + +;; 1-syntax.watsup:210.1-211.70 +syntax module = `MODULE%*%*%*%*%*%*%*%*%*`(import*, func*, global*, table*, mem*, elem*, data*, start*, export*) + +;; 2-aux.watsup:5.1-5.55 +def size : valtype -> nat? + ;; 2-aux.watsup:6.1-6.20 + def size(I32_valtype) = ?(32) + ;; 2-aux.watsup:7.1-7.20 + def size(I64_valtype) = ?(64) + ;; 2-aux.watsup:8.1-8.20 + def size(F32_valtype) = ?(32) + ;; 2-aux.watsup:9.1-9.20 + def size(F64_valtype) = ?(64) + ;; 2-aux.watsup:10.1-10.22 + def size(V128_valtype) = ?(128) + ;; + def {x : valtype} size(x) = ?() + +;; 2-aux.watsup:15.1-15.40 +def test_sub_ATOM_22 : n -> nat + ;; 2-aux.watsup:16.1-16.38 + def {n_3_ATOM_y : n} test_sub_ATOM_22(n_3_ATOM_y) = 0 + +;; 2-aux.watsup:18.1-18.26 +def curried_ : (n, n) -> nat + ;; 2-aux.watsup:19.1-19.39 + def {n_1 : n, n_2 : n} curried_(n_1, n_2) = (n_1 + n_2) + +;; 2-aux.watsup:21.1-30.39 +syntax testfuse = + | AB_(nat, nat, nat) + | CD(nat, nat, nat) + | EF(nat, nat, nat) + | GH(nat, nat, nat) + | IJ(nat, nat, nat) + | KL(nat, nat, nat) + | MN(nat, nat, nat) + | OP(nat, nat, nat) + | QR(nat, nat, nat) + +;; 3-typing.watsup:3.1-6.60 +syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memtype*, ELEM elemtype*, DATA datatype*, LOCAL valtype*, LABEL resulttype*, RETURN resulttype?} + +;; 3-typing.watsup:14.1-14.66 +relation Limits_ok: `|-%:%`(limits, nat) + ;; 3-typing.watsup:22.1-24.24 + rule _ {k : nat, n_1 : n, n_2 : n}: + `|-%:%`(`[%..%]`(n_1, n_2), k) + -- if ((n_1 <= n_2) /\ (n_2 <= k)) + +;; 3-typing.watsup:15.1-15.64 +relation Functype_ok: `|-%:OK`(functype) + ;; 3-typing.watsup:26.1-27.13 + rule _ {ft : functype}: + `|-%:OK`(ft) + +;; 3-typing.watsup:16.1-16.66 +relation Globaltype_ok: `|-%:OK`(globaltype) + ;; 3-typing.watsup:29.1-30.13 + rule _ {gt : globaltype}: + `|-%:OK`(gt) + +;; 3-typing.watsup:17.1-17.65 +relation Tabletype_ok: `|-%:OK`(tabletype) + ;; 3-typing.watsup:32.1-34.35 + rule _ {lim : limits, rt : reftype}: + `|-%:OK`(`%%`(lim, rt)) + -- Limits_ok: `|-%:%`(lim, ((2 ^ 32) - 1)) + +;; 3-typing.watsup:18.1-18.63 +relation Memtype_ok: `|-%:OK`(memtype) + ;; 3-typing.watsup:36.1-38.33 + rule _ {lim : limits}: + `|-%:OK`(`%I8`(lim)) + -- Limits_ok: `|-%:%`(lim, (2 ^ 16)) + +;; 3-typing.watsup:19.1-19.66 +relation Externtype_ok: `|-%:OK`(externtype) + ;; 3-typing.watsup:41.1-43.35 + rule func {functype : functype}: + `|-%:OK`(FUNC_externtype(functype)) + -- Functype_ok: `|-%:OK`(functype) + + ;; 3-typing.watsup:45.1-47.39 + rule global {globaltype : globaltype}: + `|-%:OK`(GLOBAL_externtype(globaltype)) + -- Globaltype_ok: `|-%:OK`(globaltype) + + ;; 3-typing.watsup:49.1-51.37 + rule table {tabletype : tabletype}: + `|-%:OK`(TABLE_externtype(tabletype)) + -- Tabletype_ok: `|-%:OK`(tabletype) + + ;; 3-typing.watsup:53.1-55.33 + rule mem {memtype : memtype}: + `|-%:OK`(MEMORY_externtype(memtype)) + -- Memtype_ok: `|-%:OK`(memtype) + +;; 3-typing.watsup:61.1-61.65 +relation Valtype_sub: `|-%<:%`(valtype, valtype) + ;; 3-typing.watsup:64.1-65.12 + rule refl {t : valtype}: + `|-%<:%`(t, t) + + ;; 3-typing.watsup:67.1-68.14 + rule bot {t : valtype}: + `|-%<:%`(BOT_valtype, t) + +;; 3-typing.watsup:62.1-62.72 +relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) + ;; 3-typing.watsup:70.1-72.35 + rule _ {t_1* : valtype*, t_2* : valtype*}: + `|-%*<:%*`(t_1*{t_1}, t_2*{t_2}) + -- if (|t_1*{t_1}| = |t_2*{t_2}|) + -- (Valtype_sub: `|-%<:%`(t_1, t_2))*{t_1 t_2} + +;; 3-typing.watsup:75.1-75.75 +relation Limits_sub: `|-%<:%`(limits, limits) + ;; 3-typing.watsup:83.1-86.21 + rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + -- if (n_11 >= n_21) + -- if (n_12 <= n_22) + +;; 3-typing.watsup:76.1-76.73 +relation Functype_sub: `|-%<:%`(functype, functype) + ;; 3-typing.watsup:88.1-89.14 + rule _ {ft : functype}: + `|-%<:%`(ft, ft) + +;; 3-typing.watsup:77.1-77.75 +relation Globaltype_sub: `|-%<:%`(globaltype, globaltype) + ;; 3-typing.watsup:91.1-92.14 + rule _ {gt : globaltype}: + `|-%<:%`(gt, gt) + +;; 3-typing.watsup:78.1-78.74 +relation Tabletype_sub: `|-%<:%`(tabletype, tabletype) + ;; 3-typing.watsup:94.1-96.35 + rule _ {lim_1 : limits, lim_2 : limits, rt : reftype}: + `|-%<:%`(`%%`(lim_1, rt), `%%`(lim_2, rt)) + -- Limits_sub: `|-%<:%`(lim_1, lim_2) + +;; 3-typing.watsup:79.1-79.72 +relation Memtype_sub: `|-%<:%`(memtype, memtype) + ;; 3-typing.watsup:98.1-100.35 + rule _ {lim_1 : limits, lim_2 : limits}: + `|-%<:%`(`%I8`(lim_1), `%I8`(lim_2)) + -- Limits_sub: `|-%<:%`(lim_1, lim_2) + +;; 3-typing.watsup:80.1-80.75 +relation Externtype_sub: `|-%<:%`(externtype, externtype) + ;; 3-typing.watsup:103.1-105.35 + rule func {ft_1 : functype, ft_2 : functype}: + `|-%<:%`(FUNC_externtype(ft_1), FUNC_externtype(ft_2)) + -- Functype_sub: `|-%<:%`(ft_1, ft_2) + + ;; 3-typing.watsup:107.1-109.37 + rule global {gt_1 : globaltype, gt_2 : globaltype}: + `|-%<:%`(GLOBAL_externtype(gt_1), GLOBAL_externtype(gt_2)) + -- Globaltype_sub: `|-%<:%`(gt_1, gt_2) + + ;; 3-typing.watsup:111.1-113.36 + rule table {tt_1 : tabletype, tt_2 : tabletype}: + `|-%<:%`(TABLE_externtype(tt_1), TABLE_externtype(tt_2)) + -- Tabletype_sub: `|-%<:%`(tt_1, tt_2) + + ;; 3-typing.watsup:115.1-117.34 + rule mem {mt_1 : memtype, mt_2 : memtype}: + `|-%<:%`(MEMORY_externtype(mt_1), MEMORY_externtype(mt_2)) + -- Memtype_sub: `|-%<:%`(mt_1, mt_2) + +;; 3-typing.watsup:172.1-172.76 +relation Blocktype_ok: `%|-%:%`(context, blocktype, functype) + ;; 3-typing.watsup:174.1-176.29 + rule _ {C : context, ft : functype}: + `%|-%:%`(C, ft, ft) + -- Functype_ok: `|-%:OK`(ft) + +;; 3-typing.watsup:123.1-124.67 +rec { + +;; 3-typing.watsup:123.1-123.66 +relation Instr_ok: `%|-%:%`(context, instr, functype) + ;; 3-typing.watsup:153.1-154.34 + rule unreachable {C : context, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, UNREACHABLE_instr, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:156.1-157.32 + rule nop {C : context}: + `%|-%:%`(C, NOP_instr, `%->%`([], [])) + + ;; 3-typing.watsup:159.1-160.27 + rule drop {C : context, t : valtype}: + `%|-%:%`(C, DROP_instr, `%->%`([t], [])) + + ;; 3-typing.watsup:163.1-164.31 + rule select-expl {C : context, t : valtype}: + `%|-%:%`(C, SELECT_instr(?(t)), `%->%`([t t I32_valtype], [t])) + + ;; 3-typing.watsup:166.1-169.37 + rule select-impl {C : context, numtype : numtype, t : valtype, t' : valtype, vectype : vectype}: + `%|-%:%`(C, SELECT_instr(?()), `%->%`([t t I32_valtype], [t])) + -- Valtype_sub: `|-%<:%`(t, t') + -- if ((t' = (numtype <: valtype)) \/ (t' = (vectype <: valtype))) + + ;; 3-typing.watsup:178.1-181.57 + rule block {C : context, bt : blocktype, instr* : instr*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, BLOCK_instr(bt, instr*{instr}), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:183.1-186.57 + rule loop {C : context, bt : blocktype, instr* : instr*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, LOOP_instr(bt, instr*{instr}), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_1]*{t_1}, RETURN ?()}, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:188.1-192.59 + rule if {C : context, bt : blocktype, instr_1* : instr*, instr_2* : instr*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, IF_instr(bt, instr_1*{instr_1}, instr_2*{instr_2}), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr_1*{instr_1}, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr_2*{instr_2}, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:195.1-197.24 + rule br {C : context, l : labelidx, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, BR_instr(l), `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) + -- if (l < |C.LABEL_context|) + -- if (C.LABEL_context[l] = t*{t}) + + ;; 3-typing.watsup:199.1-201.24 + rule br_if {C : context, l : labelidx, t* : valtype*}: + `%|-%:%`(C, BR_IF_instr(l), `%->%`(t*{t} :: [I32_valtype], t*{t})) + -- if (l < |C.LABEL_context|) + -- if (C.LABEL_context[l] = t*{t}) + + ;; 3-typing.watsup:203.1-206.42 + rule br_table {C : context, l* : labelidx*, l' : labelidx, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, BR_TABLE_instr(l*{l}, l'), `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) + -- (if (l < |C.LABEL_context|))*{l} + -- if (l' < |C.LABEL_context|) + -- (Resulttype_sub: `|-%*<:%*`(t*{t}, C.LABEL_context[l]))*{l} + -- Resulttype_sub: `|-%*<:%*`(t*{t}, C.LABEL_context[l']) + + ;; 3-typing.watsup:208.1-210.24 + rule return {C : context, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, RETURN_instr, `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) + -- if (C.RETURN_context = ?(t*{t})) + + ;; 3-typing.watsup:212.1-214.33 + rule call {C : context, t_1* : valtype*, t_2* : valtype*, x : idx}: + `%|-%:%`(C, CALL_instr(x), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- if (x < |C.FUNC_context|) + -- if (C.FUNC_context[x] = `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:216.1-219.26 + rule call_indirect {C : context, ft : functype, lim : limits, t_1* : valtype*, t_2* : valtype*, x : idx}: + `%|-%:%`(C, CALL_INDIRECT_instr(x, ft), `%->%`(t_1*{t_1} :: [I32_valtype], t_2*{t_2})) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = `%%`(lim, FUNCREF_reftype)) + -- if (ft = `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:222.1-223.37 + rule const {C : context, c_nt : c_numtype, nt : numtype}: + `%|-%:%`(C, CONST_instr(nt, c_nt), `%->%`([], [(nt <: valtype)])) + + ;; 3-typing.watsup:225.1-226.31 + rule unop {C : context, nt : numtype, unop : unop_numtype}: + `%|-%:%`(C, UNOP_instr(nt, unop), `%->%`([(nt <: valtype)], [(nt <: valtype)])) + + ;; 3-typing.watsup:228.1-229.36 + rule binop {C : context, binop : binop_numtype, nt : numtype}: + `%|-%:%`(C, BINOP_instr(nt, binop), `%->%`([(nt <: valtype) (nt <: valtype)], [(nt <: valtype)])) + + ;; 3-typing.watsup:231.1-232.36 + rule testop {C : context, nt : numtype, testop : testop_numtype}: + `%|-%:%`(C, TESTOP_instr(nt, testop), `%->%`([(nt <: valtype)], [I32_valtype])) + + ;; 3-typing.watsup:234.1-235.37 + rule relop {C : context, nt : numtype, relop : relop_numtype}: + `%|-%:%`(C, RELOP_instr(nt, relop), `%->%`([(nt <: valtype) (nt <: valtype)], [I32_valtype])) + + ;; 3-typing.watsup:238.1-240.23 + rule extend {C : context, n : n, nt : numtype}: + `%|-%:%`(C, EXTEND_instr(nt, n), `%->%`([(nt <: valtype)], [(nt <: valtype)])) + -- if ($size(nt <: valtype) =/= ?()) + -- if (n <= !($size(nt <: valtype))) + + ;; 3-typing.watsup:242.1-245.34 + rule reinterpret {C : context, nt_1 : numtype, nt_2 : numtype}: + `%|-%:%`(C, CVTOP_instr(nt_1, REINTERPRET_cvtop, nt_2, ?()), `%->%`([(nt_2 <: valtype)], [(nt_1 <: valtype)])) + -- if ($size(nt_1 <: valtype) =/= ?()) + -- if ($size(nt_2 <: valtype) =/= ?()) + -- if (nt_1 =/= nt_2) + -- if (!($size(nt_1 <: valtype)) = !($size(nt_2 <: valtype))) + + ;; 3-typing.watsup:247.1-250.52 + rule convert-i {C : context, in_1 : in, in_2 : in, sx? : sx?}: + `%|-%:%`(C, CVTOP_instr((in_1 <: numtype), CONVERT_cvtop, (in_2 <: numtype), sx?{sx}), `%->%`([(in_2 <: valtype)], [(in_1 <: valtype)])) + -- if ($size(in_1 <: valtype) =/= ?()) + -- if ($size(in_2 <: valtype) =/= ?()) + -- if (in_1 =/= in_2) + -- if ((sx?{sx} = ?()) <=> (!($size(in_1 <: valtype)) > !($size(in_2 <: valtype)))) + + ;; 3-typing.watsup:252.1-254.22 + rule convert-f {C : context, fn_1 : fn, fn_2 : fn}: + `%|-%:%`(C, CVTOP_instr((fn_1 <: numtype), CONVERT_cvtop, (fn_2 <: numtype), ?()), `%->%`([(fn_2 <: valtype)], [(fn_1 <: valtype)])) + -- if (fn_1 =/= fn_2) + + ;; 3-typing.watsup:257.1-258.35 + rule ref.null {C : context, rt : reftype}: + `%|-%:%`(C, REF.NULL_instr(rt), `%->%`([], [(rt <: valtype)])) + + ;; 3-typing.watsup:260.1-262.23 + rule ref.func {C : context, ft : functype, x : idx}: + `%|-%:%`(C, REF.FUNC_instr(x), `%->%`([], [FUNCREF_valtype])) + -- if (x < |C.FUNC_context|) + -- if (C.FUNC_context[x] = ft) + + ;; 3-typing.watsup:264.1-265.31 + rule ref.is_null {C : context, rt : reftype}: + `%|-%:%`(C, REF.IS_NULL_instr, `%->%`([(rt <: valtype)], [I32_valtype])) + + ;; 3-typing.watsup:268.1-270.23 + rule local.get {C : context, t : valtype, x : idx}: + `%|-%:%`(C, LOCAL.GET_instr(x), `%->%`([], [t])) + -- if (x < |C.LOCAL_context|) + -- if (C.LOCAL_context[x] = t) + + ;; 3-typing.watsup:272.1-274.23 + rule local.set {C : context, t : valtype, x : idx}: + `%|-%:%`(C, LOCAL.SET_instr(x), `%->%`([t], [])) + -- if (x < |C.LOCAL_context|) + -- if (C.LOCAL_context[x] = t) + + ;; 3-typing.watsup:276.1-278.23 + rule local.tee {C : context, t : valtype, x : idx}: + `%|-%:%`(C, LOCAL.TEE_instr(x), `%->%`([t], [t])) + -- if (x < |C.LOCAL_context|) + -- if (C.LOCAL_context[x] = t) + + ;; 3-typing.watsup:281.1-283.29 + rule global.get {C : context, t : valtype, x : idx}: + `%|-%:%`(C, GLOBAL.GET_instr(x), `%->%`([], [t])) + -- if (x < |C.GLOBAL_context|) + -- if (C.GLOBAL_context[x] = `MUT%?%`(()?{}, t)) + + ;; 3-typing.watsup:285.1-287.28 + rule global.set {C : context, t : valtype, x : idx}: + `%|-%:%`(C, GLOBAL.SET_instr(x), `%->%`([t], [])) + -- if (x < |C.GLOBAL_context|) + -- if (C.GLOBAL_context[x] = `MUT%?%`(?(()), t)) + + ;; 3-typing.watsup:290.1-292.28 + rule table.get {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.GET_instr(x), `%->%`([I32_valtype], [(rt <: valtype)])) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:294.1-296.28 + rule table.set {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.SET_instr(x), `%->%`([I32_valtype (rt <: valtype)], [])) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:298.1-300.24 + rule table.size {C : context, tt : tabletype, x : idx}: + `%|-%:%`(C, TABLE.SIZE_instr(x), `%->%`([], [I32_valtype])) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = tt) + + ;; 3-typing.watsup:302.1-304.28 + rule table.grow {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.GROW_instr(x), `%->%`([(rt <: valtype) I32_valtype], [I32_valtype])) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:306.1-308.28 + rule table.fill {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.FILL_instr(x), `%->%`([I32_valtype (rt <: valtype) I32_valtype], [])) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:310.1-313.32 + rule table.copy {C : context, lim_1 : limits, lim_2 : limits, rt : reftype, x_1 : idx, x_2 : idx}: + `%|-%:%`(C, TABLE.COPY_instr(x_1, x_2), `%->%`([I32_valtype I32_valtype I32_valtype], [])) + -- if (x_1 < |C.TABLE_context|) + -- if (x_2 < |C.TABLE_context|) + -- if (C.TABLE_context[x_1] = `%%`(lim_1, rt)) + -- if (C.TABLE_context[x_2] = `%%`(lim_2, rt)) + + ;; 3-typing.watsup:315.1-318.25 + rule table.init {C : context, lim : limits, rt : reftype, x_1 : idx, x_2 : idx}: + `%|-%:%`(C, TABLE.INIT_instr(x_1, x_2), `%->%`([I32_valtype I32_valtype I32_valtype], [])) + -- if (x_1 < |C.TABLE_context|) + -- if (x_2 < |C.ELEM_context|) + -- if (C.TABLE_context[x_1] = `%%`(lim, rt)) + -- if (C.ELEM_context[x_2] = rt) + + ;; 3-typing.watsup:320.1-322.23 + rule elem.drop {C : context, rt : reftype, x : idx}: + `%|-%:%`(C, ELEM.DROP_instr(x), `%->%`([], [])) + -- if (x < |C.ELEM_context|) + -- if (C.ELEM_context[x] = rt) + + ;; 3-typing.watsup:325.1-327.22 + rule memory.size {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.SIZE_instr, `%->%`([], [I32_valtype])) + -- if (0 < |C.MEM_context|) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:329.1-331.22 + rule memory.grow {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.GROW_instr, `%->%`([I32_valtype], [I32_valtype])) + -- if (0 < |C.MEM_context|) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:333.1-335.22 + rule memory.fill {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.FILL_instr, `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) + -- if (0 < |C.MEM_context|) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:337.1-339.22 + rule memory.copy {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.COPY_instr, `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) + -- if (0 < |C.MEM_context|) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:341.1-344.23 + rule memory.init {C : context, mt : memtype, x : idx}: + `%|-%:%`(C, MEMORY.INIT_instr(x), `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) + -- if (0 < |C.MEM_context|) + -- if (x < |C.DATA_context|) + -- if (C.MEM_context[0] = mt) + -- if (C.DATA_context[x] = OK) + + ;; 3-typing.watsup:346.1-348.23 + rule data.drop {C : context, x : idx}: + `%|-%:%`(C, DATA.DROP_instr(x), `%->%`([], [])) + -- if (x < |C.DATA_context|) + -- if (C.DATA_context[x] = OK) + + ;; 3-typing.watsup:350.1-355.32 + rule load {C : context, in : in, mt : memtype, n? : n?, n_A : n, n_O : n, nt : numtype, sx? : sx?}: + `%|-%:%`(C, LOAD_instr(nt, (n, sx)?{n sx}, n_A, n_O), `%->%`([I32_valtype], [(nt <: valtype)])) + -- if (0 < |C.MEM_context|) + -- if ($size(nt <: valtype) =/= ?()) + -- if ((n?{n} = ?()) <=> (sx?{sx} = ?())) + -- if (C.MEM_context[0] = mt) + -- if ((2 ^ n_A) <= (!($size(nt <: valtype)) / 8)) + -- (if (((2 ^ n_A) <= (n / 8)) /\ ((n / 8) < (!($size(nt <: valtype)) / 8))))?{n} + -- if ((n?{n} = ?()) \/ (nt = (in <: numtype))) + + ;; 3-typing.watsup:357.1-362.32 + rule store {C : context, in : in, mt : memtype, n? : n?, n_A : n, n_O : n, nt : numtype}: + `%|-%:%`(C, STORE_instr(nt, n?{n}, n_A, n_O), `%->%`([I32_valtype (nt <: valtype)], [])) + -- if (0 < |C.MEM_context|) + -- if ($size(nt <: valtype) =/= ?()) + -- if (C.MEM_context[0] = mt) + -- if ((2 ^ n_A) <= (!($size(nt <: valtype)) / 8)) + -- (if (((2 ^ n_A) <= (n / 8)) /\ ((n / 8) < (!($size(nt <: valtype)) / 8))))?{n} + -- if ((n?{n} = ?()) \/ (nt = (in <: numtype))) + +;; 3-typing.watsup:124.1-124.67 +relation InstrSeq_ok: `%|-%*:%`(context, instr*, functype) + ;; 3-typing.watsup:133.1-134.36 + rule empty {C : context}: + `%|-%*:%`(C, [], `%->%`([], [])) + + ;; 3-typing.watsup:136.1-139.46 + rule seq {C : context, instr_1 : instr, instr_2 : instr, t_1* : valtype*, t_2* : valtype*, t_3* : valtype*}: + `%|-%*:%`(C, [instr_1] :: instr_2*{}, `%->%`(t_1*{t_1}, t_3*{t_3})) + -- Instr_ok: `%|-%:%`(C, instr_1, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C, [instr_2], `%->%`(t_2*{t_2}, t_3*{t_3})) + + ;; 3-typing.watsup:141.1-146.38 + rule weak {C : context, instr* : instr*, t'_1 : valtype, t'_2* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%*:%`(C, instr*{instr}, `%->%`([t'_1], t'_2*{t'_2})) + -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Resulttype_sub: `|-%*<:%*`(t'_1*{}, t_1*{t_1}) + -- Resulttype_sub: `|-%*<:%*`(t_2*{t_2}, t'_2*{t'_2}) + + ;; 3-typing.watsup:148.1-150.45 + rule frame {C : context, instr* : instr*, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%*:%`(C, instr*{instr}, `%->%`(t*{t} :: t_1*{t_1}, t*{t} :: t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) +} + +;; 3-typing.watsup:125.1-125.71 +relation Expr_ok: `%|-%:%`(context, expr, resulttype) + ;; 3-typing.watsup:128.1-130.46 + rule _ {C : context, instr* : instr*, t* : valtype*}: + `%|-%:%`(C, instr*{instr}, t*{t}) + -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`([], t*{t})) + +;; 3-typing.watsup:367.1-367.78 +relation Instr_const: `%|-%CONST`(context, instr) + ;; 3-typing.watsup:371.1-372.26 + rule const {C : context, c : c_numtype, nt : numtype}: + `%|-%CONST`(C, CONST_instr(nt, c)) + + ;; 3-typing.watsup:374.1-375.27 + rule ref.null {C : context, rt : reftype}: + `%|-%CONST`(C, REF.NULL_instr(rt)) + + ;; 3-typing.watsup:377.1-378.26 + rule ref.func {C : context, x : idx}: + `%|-%CONST`(C, REF.FUNC_instr(x)) + + ;; 3-typing.watsup:380.1-382.32 + rule global.get {C : context, t : valtype, x : idx}: + `%|-%CONST`(C, GLOBAL.GET_instr(x)) + -- if (x < |C.GLOBAL_context|) + -- if (C.GLOBAL_context[x] = `MUT%?%`(?(), t)) + +;; 3-typing.watsup:368.1-368.77 +relation Expr_const: `%|-%CONST`(context, expr) + ;; 3-typing.watsup:385.1-386.38 + rule _ {C : context, instr* : instr*}: + `%|-%CONST`(C, instr*{instr}) + -- (Instr_const: `%|-%CONST`(C, instr))*{instr} + +;; 3-typing.watsup:369.1-369.78 +relation Expr_ok_const: `%|-%:%CONST`(context, expr, valtype) + ;; 3-typing.watsup:389.1-392.33 + rule _ {C : context, expr : expr, t : valtype}: + `%|-%:%CONST`(C, expr, t) + -- Expr_ok: `%|-%:%`(C, expr, [t]) + -- Expr_const: `%|-%CONST`(C, expr) + +;; 3-typing.watsup:397.1-397.73 +relation Func_ok: `%|-%:%`(context, func, functype) + ;; 3-typing.watsup:408.1-412.75 + rule _ {C : context, expr : expr, ft : functype, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, `FUNC%%*%`(ft, t*{t}, expr), ft) + -- if (ft = `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Functype_ok: `|-%:OK`(ft) + -- Expr_ok: `%|-%:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL t_1*{t_1} :: t*{t}, LABEL [], RETURN ?()} ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2*{t_2}], RETURN ?()} ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [], RETURN ?(t_2*{t_2})}, expr, t_2*{t_2}) + +;; 3-typing.watsup:398.1-398.75 +relation Global_ok: `%|-%:%`(context, global, globaltype) + ;; 3-typing.watsup:414.1-418.40 + rule _ {C : context, expr : expr, gt : globaltype, t : valtype}: + `%|-%:%`(C, GLOBAL(gt, expr), gt) + -- Globaltype_ok: `|-%:OK`(gt) + -- if (gt = `MUT%?%`(()?{}, t)) + -- Expr_ok_const: `%|-%:%CONST`(C, expr, t) + +;; 3-typing.watsup:399.1-399.74 +relation Table_ok: `%|-%:%`(context, table, tabletype) + ;; 3-typing.watsup:420.1-422.30 + rule _ {C : context, tt : tabletype}: + `%|-%:%`(C, TABLE(tt), tt) + -- Tabletype_ok: `|-%:OK`(tt) + +;; 3-typing.watsup:400.1-400.72 +relation Mem_ok: `%|-%:%`(context, mem, memtype) + ;; 3-typing.watsup:424.1-426.28 + rule _ {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY(mt), mt) + -- Memtype_ok: `|-%:OK`(mt) + +;; 3-typing.watsup:403.1-403.77 +relation Elemmode_ok: `%|-%:%`(context, elemmode, reftype) + ;; 3-typing.watsup:437.1-440.45 + rule active {C : context, expr : expr, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE_elemmode(x, expr), rt) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + -- (Expr_ok_const: `%|-%:%CONST`(C, expr, I32_valtype))*{} + + ;; 3-typing.watsup:442.1-443.20 + rule declare {C : context, rt : reftype}: + `%|-%:%`(C, DECLARE_elemmode, rt) + +;; 3-typing.watsup:401.1-401.73 +relation Elem_ok: `%|-%:%`(context, elem, reftype) + ;; 3-typing.watsup:428.1-431.40 + rule _ {C : context, elemmode? : elemmode?, expr* : expr*, rt : reftype}: + `%|-%:%`(C, `ELEM%%*%?`(rt, expr*{expr}, elemmode?{elemmode}), rt) + -- (Expr_ok: `%|-%:%`(C, expr, [(rt <: valtype)]))*{expr} + -- (Elemmode_ok: `%|-%:%`(C, elemmode, rt))?{elemmode} + +;; 3-typing.watsup:404.1-404.77 +relation Datamode_ok: `%|-%:OK`(context, datamode) + ;; 3-typing.watsup:445.1-448.45 + rule _ {C : context, expr : expr, mt : memtype}: + `%|-%:OK`(C, MEMORY_datamode(0, expr)) + -- if (0 < |C.MEM_context|) + -- if (C.MEM_context[0] = mt) + -- (Expr_ok_const: `%|-%:%CONST`(C, expr, I32_valtype))*{} + +;; 3-typing.watsup:402.1-402.73 +relation Data_ok: `%|-%:OK`(context, data) + ;; 3-typing.watsup:433.1-435.40 + rule _ {C : context, b** : byte**, datamode? : datamode?}: + `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} + +;; 3-typing.watsup:405.1-405.74 +relation Start_ok: `%|-%:OK`(context, start) + ;; 3-typing.watsup:450.1-452.39 + rule _ {C : context, x : idx}: + `%|-%:OK`(C, START(x)) + -- if (x < |C.FUNC_context|) + -- if (C.FUNC_context[x] = `%->%`([], [])) + +;; 3-typing.watsup:455.1-455.80 +relation Import_ok: `%|-%:%`(context, import, externtype) + ;; 3-typing.watsup:459.1-461.31 + rule _ {C : context, name_1 : name, name_2 : name, xt : externtype}: + `%|-%:%`(C, IMPORT(name_1, name_2, xt), xt) + -- Externtype_ok: `|-%:OK`(xt) + +;; 3-typing.watsup:457.1-457.83 +relation Externuse_ok: `%|-%:%`(context, externuse, externtype) + ;; 3-typing.watsup:467.1-469.23 + rule func {C : context, ft : functype, x : idx}: + `%|-%:%`(C, FUNC_externuse(x), FUNC_externtype(ft)) + -- if (x < |C.FUNC_context|) + -- if (C.FUNC_context[x] = ft) + + ;; 3-typing.watsup:471.1-473.25 + rule global {C : context, gt : globaltype, x : idx}: + `%|-%:%`(C, GLOBAL_externuse(x), GLOBAL_externtype(gt)) + -- if (x < |C.GLOBAL_context|) + -- if (C.GLOBAL_context[x] = gt) + + ;; 3-typing.watsup:475.1-477.24 + rule table {C : context, tt : tabletype, x : idx}: + `%|-%:%`(C, TABLE_externuse(x), TABLE_externtype(tt)) + -- if (x < |C.TABLE_context|) + -- if (C.TABLE_context[x] = tt) + + ;; 3-typing.watsup:479.1-481.22 + rule mem {C : context, mt : memtype, x : idx}: + `%|-%:%`(C, MEMORY_externuse(x), MEMORY_externtype(mt)) + -- if (x < |C.MEM_context|) + -- if (C.MEM_context[x] = mt) + +;; 3-typing.watsup:456.1-456.80 +relation Export_ok: `%|-%:%`(context, export, externtype) + ;; 3-typing.watsup:463.1-465.39 + rule _ {C : context, externuse : externuse, name : name, xt : externtype}: + `%|-%:%`(C, EXPORT(name, externuse), xt) + -- Externuse_ok: `%|-%:%`(C, externuse, xt) + +;; 3-typing.watsup:484.1-484.62 +relation Module_ok: `|-%:OK`(module) + ;; 3-typing.watsup:486.1-501.22 + rule _ {C : context, data^n : data^n, elem* : elem*, export* : export*, ft* : functype*, func* : func*, global* : global*, gt* : globaltype*, import* : import*, mem* : mem*, mt* : memtype*, n : n, rt* : reftype*, start* : start*, table* : table*, tt* : tabletype*}: + `|-%:OK`(`MODULE%*%*%*%*%*%*%*%*%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data^n{data}, start*{start}, export*{export})) + -- if (|ft*{ft}| = |func*{func}|) + -- if (|global*{global}| = |gt*{gt}|) + -- if (|table*{table}| = |tt*{tt}|) + -- if (|mem*{mem}| = |mt*{mt}|) + -- if (|elem*{elem}| = |rt*{rt}|) + -- if (|data^n{data}| = n) + -- if (C = {FUNC ft*{ft}, GLOBAL gt*{gt}, TABLE tt*{tt}, MEM mt*{mt}, ELEM rt*{rt}, DATA OK^n{}, LOCAL [], LABEL [], RETURN ?()}) + -- (Func_ok: `%|-%:%`(C, func, ft))*{ft func} + -- (Global_ok: `%|-%:%`(C, global, gt))*{global gt} + -- (Table_ok: `%|-%:%`(C, table, tt))*{table tt} + -- (Mem_ok: `%|-%:%`(C, mem, mt))*{mem mt} + -- (Elem_ok: `%|-%:%`(C, elem, rt))*{elem rt} + -- (Data_ok: `%|-%:OK`(C, data))^n{data} + -- (Start_ok: `%|-%:OK`(C, start))*{start} + -- if (|mem*{mem}| <= 1) + -- if (|start*{start}| <= 1) + +;; 4-runtime.watsup:3.1-3.39 +syntax addr = nat + +;; 4-runtime.watsup:4.1-4.53 +syntax funcaddr = addr + +;; 4-runtime.watsup:5.1-5.53 +syntax globaladdr = addr + +;; 4-runtime.watsup:6.1-6.51 +syntax tableaddr = addr + +;; 4-runtime.watsup:7.1-7.50 +syntax memaddr = addr + +;; 4-runtime.watsup:8.1-8.49 +syntax elemaddr = addr + +;; 4-runtime.watsup:9.1-9.49 +syntax dataaddr = addr + +;; 4-runtime.watsup:10.1-10.51 +syntax labeladdr = addr + +;; 4-runtime.watsup:11.1-11.49 +syntax hostaddr = addr + +;; 4-runtime.watsup:24.1-25.24 +syntax num = + | CONST(numtype, c_numtype) + +;; 4-runtime.watsup:26.1-27.67 +syntax ref = + | REF.NULL(reftype) + | REF.FUNC_ADDR(funcaddr) + | REF.HOST_ADDR(hostaddr) + +;; 4-runtime.watsup:28.1-29.10 +syntax val = + | CONST(numtype, c_numtype) + | REF.NULL(reftype) + | REF.FUNC_ADDR(funcaddr) + | REF.HOST_ADDR(hostaddr) + +;; 4-runtime.watsup:31.1-32.18 +syntax result = + | _VALS(val*) + | TRAP + +;; 4-runtime.watsup:38.1-39.66 +syntax externval = + | FUNC(funcaddr) + | GLOBAL(globaladdr) + | TABLE(tableaddr) + | MEM(memaddr) + +;; 4-runtime.watsup:44.1-44.44 +def default_ : valtype -> val? + ;; 4-runtime.watsup:45.1-45.35 + def default_(I32_valtype) = ?(CONST_val(I32_numtype, 0)) + ;; 4-runtime.watsup:46.1-46.35 + def default_(I64_valtype) = ?(CONST_val(I64_numtype, 0)) + ;; 4-runtime.watsup:47.1-47.35 + def default_(F32_valtype) = ?(CONST_val(F32_numtype, 0)) + ;; 4-runtime.watsup:48.1-48.35 + def default_(F64_valtype) = ?(CONST_val(F64_numtype, 0)) + ;; 4-runtime.watsup:49.1-49.34 + def {rt : reftype} default_(rt <: valtype) = ?(REF.NULL_val(rt)) + ;; + def {x : valtype} default_(x) = ?() + +;; 4-runtime.watsup:60.1-60.71 +syntax exportinst = EXPORT(name, externval) + +;; 4-runtime.watsup:70.1-77.25 +syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} + +;; 4-runtime.watsup:54.1-54.66 +syntax funcinst = `%;%`(moduleinst, func) + +;; 4-runtime.watsup:55.1-55.53 +syntax globalinst = val + +;; 4-runtime.watsup:56.1-56.52 +syntax tableinst = ref* + +;; 4-runtime.watsup:57.1-57.52 +syntax meminst = byte* + +;; 4-runtime.watsup:58.1-58.53 +syntax eleminst = ref* + +;; 4-runtime.watsup:59.1-59.51 +syntax datainst = byte* + +;; 4-runtime.watsup:62.1-68.21 +syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} + +;; 4-runtime.watsup:79.1-81.24 +syntax frame = {LOCAL val*, MODULE moduleinst} + +;; 4-runtime.watsup:82.1-82.47 +syntax state = `%;%`(store, frame) + +;; 4-runtime.watsup:139.1-146.5 +rec { + +;; 4-runtime.watsup:139.1-146.5 +syntax admininstr = + | UNREACHABLE + | NOP + | DROP + | SELECT(valtype?) + | BLOCK(blocktype, instr*) + | LOOP(blocktype, instr*) + | IF(blocktype, instr*, instr*) + | BR(labelidx) + | BR_IF(labelidx) + | BR_TABLE(labelidx*, labelidx) + | CALL(funcidx) + | CALL_INDIRECT(tableidx, functype) + | RETURN + | CONST(numtype, c_numtype) + | UNOP(numtype, unop_numtype) + | BINOP(numtype, binop_numtype) + | TESTOP(numtype, testop_numtype) + | RELOP(numtype, relop_numtype) + | EXTEND(numtype, n) + | CVTOP(numtype, cvtop, numtype, sx?) + | REF.NULL(reftype) + | REF.FUNC(funcidx) + | REF.IS_NULL + | LOCAL.GET(localidx) + | LOCAL.SET(localidx) + | LOCAL.TEE(localidx) + | GLOBAL.GET(globalidx) + | GLOBAL.SET(globalidx) + | TABLE.GET(tableidx) + | TABLE.SET(tableidx) + | TABLE.SIZE(tableidx) + | TABLE.GROW(tableidx) + | TABLE.FILL(tableidx) + | TABLE.COPY(tableidx, tableidx) + | TABLE.INIT(tableidx, elemidx) + | ELEM.DROP(elemidx) + | MEMORY.SIZE + | MEMORY.GROW + | MEMORY.FILL + | MEMORY.COPY + | MEMORY.INIT(dataidx) + | DATA.DROP(dataidx) + | LOAD(numtype, (n, sx)?, nat, nat) + | STORE(numtype, n?, nat, nat) + | REF.FUNC_ADDR(funcaddr) + | REF.HOST_ADDR(hostaddr) + | CALL_ADDR(funcaddr) + | LABEL_(n, instr*, admininstr*) + | FRAME_(n, frame, admininstr*) + | TRAP +} + +;; 4-runtime.watsup:83.1-83.62 +syntax config = `%;%*`(state, admininstr*) + +;; 4-runtime.watsup:101.1-101.59 +def funcaddr : state -> funcaddr* + ;; 4-runtime.watsup:102.1-102.38 + def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst + +;; 4-runtime.watsup:104.1-104.52 +def funcinst : state -> funcinst* + ;; 4-runtime.watsup:105.1-105.31 + def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store + +;; 4-runtime.watsup:107.1-107.67 +def func : (state, funcidx) -> funcinst + ;; 4-runtime.watsup:115.1-115.48 + def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] + +;; 4-runtime.watsup:108.1-108.69 +def global : (state, globalidx) -> globalinst + ;; 4-runtime.watsup:116.1-116.54 + def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] + +;; 4-runtime.watsup:109.1-109.68 +def table : (state, tableidx) -> tableinst + ;; 4-runtime.watsup:117.1-117.51 + def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] + +;; 4-runtime.watsup:110.1-110.66 +def mem : (state, memidx) -> meminst + ;; 4-runtime.watsup:118.1-118.45 + def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] + +;; 4-runtime.watsup:111.1-111.67 +def elem : (state, tableidx) -> eleminst + ;; 4-runtime.watsup:119.1-119.48 + def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] + +;; 4-runtime.watsup:112.1-112.67 +def data : (state, dataidx) -> datainst + ;; 4-runtime.watsup:120.1-120.48 + def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] + +;; 4-runtime.watsup:113.1-113.68 +def local : (state, localidx) -> val + ;; 4-runtime.watsup:121.1-121.35 + def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] + +;; 4-runtime.watsup:124.1-124.78 +def with_local : (state, localidx, val) -> state + ;; 4-runtime.watsup:130.1-130.52 + def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL[x] = v]) + +;; 4-runtime.watsup:125.1-125.79 +def with_global : (state, globalidx, val) -> state + ;; 4-runtime.watsup:131.1-131.71 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + +;; 4-runtime.watsup:126.1-126.81 +def with_table : (state, tableidx, n, ref) -> state + ;; 4-runtime.watsup:132.1-132.74 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + +;; 4-runtime.watsup:127.1-127.80 +def with_tableext : (state, tableidx, ref*) -> state + ;; 4-runtime.watsup:133.1-133.75 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + +;; 4-runtime.watsup:128.1-128.77 +def with_elem : (state, elemidx, ref*) -> state + ;; 4-runtime.watsup:134.1-134.69 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]] = r*{r}], f) + +;; 4-runtime.watsup:148.1-151.21 +rec { + +;; 4-runtime.watsup:148.1-151.21 +syntax E = + | _HOLE + | _SEQ(val*, E, instr*) + | LABEL_(n, instr*, E) +} + +;; 5-numerics.watsup:3.1-3.76 +def unop : (unop_numtype, numtype, c_numtype) -> c_numtype* + +;; 5-numerics.watsup:4.1-4.79 +def binop : (binop_numtype, numtype, c_numtype, c_numtype) -> c_numtype* + +;; 5-numerics.watsup:5.1-5.76 +def testop : (testop_numtype, numtype, c_numtype) -> c_numtype + +;; 5-numerics.watsup:6.1-6.79 +def relop : (relop_numtype, numtype, c_numtype, c_numtype) -> c_numtype + +;; 5-numerics.watsup:8.1-8.84 +def ext : (nat, nat, sx, c_numtype) -> c_numtype + +;; 5-numerics.watsup:9.1-9.84 +def cvtop : (numtype, cvtop, numtype, sx?, c_numtype) -> c_numtype* + +;; 6-reduction.watsup:4.1-4.63 +relation Step_pure: `%*~>%*`(admininstr*, admininstr*) + ;; 6-reduction.watsup:16.1-17.24 + rule unreachable: + `%*~>%*`([UNREACHABLE_admininstr], [TRAP_admininstr]) + + ;; 6-reduction.watsup:19.1-20.19 + rule nop: + `%*~>%*`([NOP_admininstr], []) + + ;; 6-reduction.watsup:22.1-23.24 + rule drop {val : val}: + `%*~>%*`([(val <: admininstr) DROP_admininstr], []) + + ;; 6-reduction.watsup:26.1-28.16 + rule select-true {c : c_numtype, t? : valtype?, val_1 : val, val_2 : val}: + `%*~>%*`([(val_1 <: admininstr) (val_2 <: admininstr) CONST_admininstr(I32_numtype, c) SELECT_admininstr(t?{t})], [(val_1 <: admininstr)]) + -- if (c =/= 0) + + ;; 6-reduction.watsup:30.1-32.14 + rule select-false {c : c_numtype, t? : valtype?, val_1 : val, val_2 : val}: + `%*~>%*`([(val_1 <: admininstr) (val_2 <: admininstr) CONST_admininstr(I32_numtype, c) SELECT_admininstr(t?{t})], [(val_2 <: admininstr)]) + -- if (c = 0) + + ;; 6-reduction.watsup:35.1-37.28 + rule block {bt : blocktype, instr* : instr*, k : nat, n : n, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k}: + `%*~>%*`((val <: admininstr)^k{val} :: [BLOCK_admininstr(bt, instr*{instr})], [LABEL__admininstr(n, [], (val <: admininstr)^k{val} :: (instr <: admininstr)*{instr})]) + -- if (|t_1^k{t_1}| = k) + -- if (|t_2^n{t_2}| = n) + -- if (|val^k{val}| = k) + -- if (bt = `%->%`(t_1^k{t_1}, t_2^n{t_2})) + + ;; 6-reduction.watsup:39.1-41.28 + rule loop {bt : blocktype, instr* : instr*, k : nat, n : n, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k}: + `%*~>%*`((val <: admininstr)^k{val} :: [LOOP_admininstr(bt, instr*{instr})], [LABEL__admininstr(n, [LOOP_instr(bt, instr*{instr})], (val <: admininstr)^k{val} :: (instr <: admininstr)*{instr})]) + -- if (|t_1^k{t_1}| = k) + -- if (|t_2^n{t_2}| = n) + -- if (|val^k{val}| = k) + -- if (bt = `%->%`(t_1^k{t_1}, t_2^n{t_2})) + + ;; 6-reduction.watsup:43.1-45.16 + rule if-true {bt : blocktype, c : c_numtype, instr_1* : instr*, instr_2* : instr*}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) IF_admininstr(bt, instr_1*{instr_1}, instr_2*{instr_2})], [BLOCK_admininstr(bt, instr_1*{instr_1})]) + -- if (c =/= 0) + + ;; 6-reduction.watsup:47.1-49.14 + rule if-false {bt : blocktype, c : c_numtype, instr_1* : instr*, instr_2* : instr*}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) IF_admininstr(bt, instr_1*{instr_1}, instr_2*{instr_2})], [BLOCK_admininstr(bt, instr_2*{instr_2})]) + -- if (c = 0) + + ;; 6-reduction.watsup:52.1-53.38 + rule label-vals {instr* : instr*, n : n, val* : val*}: + `%*~>%*`([LABEL__admininstr(n, instr*{instr}, (val <: admininstr)*{val})], (val <: admininstr)*{val}) + + ;; 6-reduction.watsup:57.1-58.69 + rule br-zero {instr* : instr*, instr'* : instr*, n : n, val^n : val^n, val'* : val*}: + `%*~>%*`([LABEL__admininstr(n, instr'*{instr'}, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [BR_admininstr(0)] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val} :: (instr' <: admininstr)*{instr'}) + -- if (|val^n{val}| = n) + + ;; 6-reduction.watsup:60.1-61.65 + rule br-succ {instr* : instr*, instr'* : instr*, l : labelidx, n : n, val* : val*}: + `%*~>%*`([LABEL__admininstr(n, instr'*{instr'}, (val <: admininstr)*{val} :: [BR_admininstr(l + 1)] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [BR_admininstr(l)]) + + ;; 6-reduction.watsup:64.1-66.16 + rule br_if-true {c : c_numtype, l : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) BR_IF_admininstr(l)], [BR_admininstr(l)]) + -- if (c =/= 0) + + ;; 6-reduction.watsup:68.1-70.14 + rule br_if-false {c : c_numtype, l : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) BR_IF_admininstr(l)], []) + -- if (c = 0) + + ;; 6-reduction.watsup:73.1-75.17 + rule br_table-lt {i : nat, l* : labelidx*, l' : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l*{l}[i])]) + -- if (i < |l*{l}|) + + ;; 6-reduction.watsup:77.1-79.18 + rule br_table-ge {i : nat, l* : labelidx*, l' : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) + -- if (i >= |l*{l}|) + + ;; 6-reduction.watsup:100.1-101.35 + rule frame-vals {f : frame, n : n, val^n : val^n}: + `%*~>%*`([FRAME__admininstr(n, f, (val <: admininstr)^n{val})], (val <: admininstr)^n{val}) + -- if (|val^n{val}| = n) + + ;; 6-reduction.watsup:103.1-104.55 + rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: + `%*~>%*`([FRAME__admininstr(n, f, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val}) + -- if (|val^n{val}| = n) + + ;; 6-reduction.watsup:106.1-107.60 + rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: + `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, (val <: admininstr)*{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [RETURN_admininstr]) + + ;; 6-reduction.watsup:110.1-112.33 + rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) + -- if ($unop(unop, nt, c_1) = [c]) + + ;; 6-reduction.watsup:114.1-116.39 + rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) + -- if ($unop(unop, nt, c_1) = []) + + ;; 6-reduction.watsup:119.1-121.40 + rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) + -- if ($binop(binop, nt, c_1, c_2) = [c]) + + ;; 6-reduction.watsup:123.1-125.46 + rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) + -- if ($binop(binop, nt, c_1, c_2) = []) + + ;; 6-reduction.watsup:128.1-130.37 + rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) + -- if (c = $testop(testop, nt, c_1)) + + ;; 6-reduction.watsup:132.1-134.40 + rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) + -- if (c = $relop(relop, nt, c_1, c_2)) + + ;; 6-reduction.watsup:137.1-138.70 + rule extend {c : c_numtype, n : n, nt : numtype}: + `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, !($size(nt <: valtype)), S_sx, c))]) + -- if ($size(nt <: valtype) =/= ?()) + + ;; 6-reduction.watsup:141.1-143.48 + rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt : numtype, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: + `%*~>%*`([CONST_admininstr(nt, c_1) CVTOP_admininstr(nt_1, cvtop, nt_2, sx?{sx})], [CONST_admininstr(nt, c)]) + -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) + + ;; 6-reduction.watsup:145.1-147.54 + rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt : numtype, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: + `%*~>%*`([CONST_admininstr(nt, c_1) CVTOP_admininstr(nt_1, cvtop, nt_2, sx?{sx})], [TRAP_admininstr]) + -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) + + ;; 6-reduction.watsup:154.1-156.28 + rule ref.is_null-true {rt : reftype, val : val}: + `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) + -- if (val = REF.NULL_val(rt)) + + ;; 6-reduction.watsup:158.1-160.15 + rule ref.is_null-false {val : val}: + `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) + -- otherwise + + ;; 6-reduction.watsup:169.1-170.47 + rule local.tee {val : val, x : idx}: + `%*~>%*`([(val <: admininstr) LOCAL.TEE_admininstr(x)], [(val <: admininstr) (val <: admininstr) LOCAL.SET_admininstr(x)]) + +;; 6-reduction.watsup:5.1-5.63 +relation Step_read: `%~>%*`(config, admininstr*) + ;; 6-reduction.watsup:82.1-83.47 + rule call {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) + -- if (x < |$funcaddr(z)|) + + ;; 6-reduction.watsup:85.1-88.34 + rule call_indirect-call {a : addr, ft : functype, func : func, i : nat, m : moduleinst, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) + -- if (i < |$table(z, x)|) + -- if (a < |$funcinst(z)|) + -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a] = `%;%`(m, func)) + + ;; 6-reduction.watsup:90.1-92.15 + rule call_indirect-trap {ft : functype, i : nat, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) + -- otherwise + + ;; 6-reduction.watsup:94.1-97.52 + rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: + `%~>%*`(`%;%*`(z, (val <: admininstr)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], (instr <: admininstr)*{instr})])]) + -- if (a < |$funcinst(z)|) + -- if (|t_1^k{t_1}| = k) + -- if (|t_2^n{t_2}| = n) + -- if (|val^k{val}| = k) + -- (if ($default_(t) =/= ?()))*{t} + -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if (f = {LOCAL val^k{val} :: !($default_(t))*{t}, MODULE m}) + + ;; 6-reduction.watsup:150.1-151.53 + rule ref.func {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) + -- if (x < |$funcaddr(z)|) + + ;; 6-reduction.watsup:163.1-164.37 + rule local.get {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [($local(z, x) <: admininstr)]) + + ;; 6-reduction.watsup:173.1-174.39 + rule global.get {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [($global(z, x) <: admininstr)]) + + ;; 6-reduction.watsup:180.1-182.28 + rule table.get-trap {i : nat, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) + -- if (i >= |$table(z, x)|) + + ;; 6-reduction.watsup:184.1-186.27 + rule table.get-val {i : nat, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [($table(z, x)[i] <: admininstr)]) + -- if (i < |$table(z, x)|) + + ;; 6-reduction.watsup:188.1-190.28 + rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) + -- if (i >= |$table(z, x)|) + + ;; 6-reduction.watsup:197.1-199.27 + rule table.size {n : n, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) + -- if (|$table(z, x)| = n) + + ;; 6-reduction.watsup:205.1-206.57 + rule table.grow-fail {n : n, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), [CONST_admininstr(I32_numtype, - 1)]) + + ;; 6-reduction.watsup:209.1-211.34 + rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) + -- if ((i + n) > |$table(z, x)|) + + ;; 6-reduction.watsup:213.1-216.14 + rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) + -- otherwise + -- if (n = 0) + + ;; 6-reduction.watsup:218.1-222.15 + rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) + -- otherwise + + ;; 6-reduction.watsup:225.1-227.63 + rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) + -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + + ;; 6-reduction.watsup:229.1-232.14 + rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) + -- otherwise + -- if (n = 0) + + ;; 6-reduction.watsup:234.1-239.15 + rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) + -- otherwise + -- if (j <= i) + + ;; 6-reduction.watsup:241.1-245.15 + rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) + -- otherwise + + ;; 6-reduction.watsup:248.1-250.62 + rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) + -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + + ;; 6-reduction.watsup:252.1-255.14 + rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) + -- otherwise + -- if (n = 0) + + ;; 6-reduction.watsup:257.1-261.15 + rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y)[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + -- if (i < |$elem(z, y)|) + -- otherwise + +;; 6-reduction.watsup:3.1-3.63 +relation Step: `%~>%`(config, config) + ;; 6-reduction.watsup:7.1-9.34 + rule pure {instr* : instr*, instr'* : instr*, z : state}: + `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) + -- Step_pure: `%*~>%*`((instr <: admininstr)*{instr}, (instr' <: admininstr)*{instr'}) + + ;; 6-reduction.watsup:11.1-13.37 + rule read {instr* : instr*, instr'* : instr*, z : state}: + `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) + -- Step_read: `%~>%*`(`%;%*`(z, (instr <: admininstr)*{instr}), (instr' <: admininstr)*{instr'}) + + ;; 6-reduction.watsup:166.1-167.60 + rule local.set {val : val, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(val <: admininstr) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) + + ;; 6-reduction.watsup:176.1-177.62 + rule global.set {val : val, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(val <: admininstr) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) + + ;; 6-reduction.watsup:192.1-194.27 + rule table.set-val {i : nat, ref : ref, x : idx, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) + -- if (i < |$table(z, x)|) + + ;; 6-reduction.watsup:202.1-203.102 + rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + + ;; 6-reduction.watsup:264.1-265.59 + rule elem.drop {x : idx, z : state}: + `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) + == IL Validation... == Complete. ``` From 2992a7a2f9592cedd7132c8438761f657d7eacb5 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Thu, 13 Apr 2023 14:17:23 +0200 Subject: [PATCH 3/3] Fix test output --- spectec/test-frontend/TEST.md | 3451 ++++++++++++++++++++++++++++++++- 1 file changed, 3448 insertions(+), 3 deletions(-) diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index e911641a8d..ef9234c587 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -2,7 +2,3452 @@ ```sh $ (cd ../spec && dune exec ../src/exe-watsup/main.exe -- *.watsup -v -l --print-il) -Error: A running dune (pid: 950144) instance has locked the build directory. -If this is not the case, please delete _build/.lock -[1] +watsup 0.3 generator +== Parsing... +== Elaboration... + +;; 1-syntax.watsup:3.1-3.15 +syntax n = nat + +;; 1-syntax.watsup:9.1-9.37 +syntax name = text + +;; 1-syntax.watsup:14.1-14.36 +syntax byte = nat + +;; 1-syntax.watsup:15.1-15.45 +syntax u32 = nat + +;; 1-syntax.watsup:22.1-22.36 +syntax idx = nat + +;; 1-syntax.watsup:23.1-23.49 +syntax funcidx = idx + +;; 1-syntax.watsup:24.1-24.49 +syntax globalidx = idx + +;; 1-syntax.watsup:25.1-25.47 +syntax tableidx = idx + +;; 1-syntax.watsup:26.1-26.46 +syntax memidx = idx + +;; 1-syntax.watsup:27.1-27.45 +syntax elemidx = idx + +;; 1-syntax.watsup:28.1-28.45 +syntax dataidx = idx + +;; 1-syntax.watsup:29.1-29.47 +syntax labelidx = idx + +;; 1-syntax.watsup:30.1-30.47 +syntax localidx = idx + +;; 1-syntax.watsup:39.1-40.22 +syntax numtype = + | I32 + | I64 + | F32 + | F64 + +;; 1-syntax.watsup:41.1-42.5 +syntax vectype = + | V128 + +;; 1-syntax.watsup:43.1-44.20 +syntax reftype = + | FUNCREF + | EXTERNREF + +;; 1-syntax.watsup:45.1-46.34 +syntax valtype = + | I32 + | I64 + | F32 + | F64 + | V128 + | FUNCREF + | EXTERNREF + | BOT + +;; 1-syntax.watsup:48.1-48.39 +syntax in = + | I32 + | I64 + +;; 1-syntax.watsup:49.1-49.39 +syntax fn = + | F32 + | F64 + +;; 1-syntax.watsup:56.1-57.11 +syntax resulttype = valtype* + +;; 1-syntax.watsup:59.1-60.16 +syntax limits = `[%..%]`(u32, u32) + +;; 1-syntax.watsup:61.1-62.15 +syntax globaltype = `MUT%?%`(()?, valtype) + +;; 1-syntax.watsup:63.1-64.27 +syntax functype = `%->%`(resulttype, resulttype) + +;; 1-syntax.watsup:65.1-66.17 +syntax tabletype = `%%`(limits, reftype) + +;; 1-syntax.watsup:67.1-68.12 +syntax memtype = `%I8`(limits) + +;; 1-syntax.watsup:69.1-70.10 +syntax elemtype = reftype + +;; 1-syntax.watsup:71.1-72.5 +syntax datatype = OK + +;; 1-syntax.watsup:73.1-74.69 +syntax externtype = + | GLOBAL(globaltype) + | FUNC(functype) + | TABLE(tabletype) + | MEMORY(memtype) + +;; 1-syntax.watsup:86.1-86.44 +syntax sx = + | U + | S + +;; 1-syntax.watsup:88.1-88.39 +syntax unop_IXX = + | CLZ + | CTZ + | POPCNT + +;; 1-syntax.watsup:89.1-89.70 +syntax unop_FXX = + | ABS + | NEG + | SQRT + | CEIL + | FLOOR + | TRUNC + | NEAREST + +;; 1-syntax.watsup:91.1-93.62 +syntax binop_IXX = + | ADD + | SUB + | MUL + | DIV(sx) + | REM(sx) + | AND + | OR + | XOR + | SHL + | SHR(sx) + | ROTL + | ROTR + +;; 1-syntax.watsup:94.1-94.66 +syntax binop_FXX = + | ADD + | SUB + | MUL + | DIV + | MIN + | MAX + | COPYSIGN + +;; 1-syntax.watsup:96.1-96.26 +syntax testop_IXX = + | EQZ + +;; 1-syntax.watsup:97.1-97.22 +syntax testop_FXX = + | + +;; 1-syntax.watsup:99.1-100.108 +syntax relop_IXX = + | EQ + | NE + | LT(sx) + | GT(sx) + | LE(sx) + | GE(sx) + +;; 1-syntax.watsup:101.1-101.49 +syntax relop_FXX = + | EQ + | NE + | LT + | GT + | LE + | GE + +;; 1-syntax.watsup:103.1-103.50 +syntax unop_numtype = + | _I(unop_IXX) + | _F(unop_FXX) + +;; 1-syntax.watsup:104.1-104.53 +syntax binop_numtype = + | _I(binop_IXX) + | _F(binop_FXX) + +;; 1-syntax.watsup:105.1-105.56 +syntax testop_numtype = + | _I(testop_IXX) + | _F(testop_FXX) + +;; 1-syntax.watsup:106.1-106.53 +syntax relop_numtype = + | _I(relop_IXX) + | _F(relop_FXX) + +;; 1-syntax.watsup:107.1-107.39 +syntax cvtop = + | CONVERT + | REINTERPRET + +;; 1-syntax.watsup:117.1-117.23 +syntax c_numtype = nat + +;; 1-syntax.watsup:118.1-118.23 +syntax c_vectype = nat + +;; 1-syntax.watsup:121.1-121.52 +syntax blocktype = functype + +;; 1-syntax.watsup:156.1-177.55 +rec { + +;; 1-syntax.watsup:156.1-177.55 +syntax instr = + | UNREACHABLE + | NOP + | DROP + | SELECT(valtype?) + | BLOCK(blocktype, instr*) + | LOOP(blocktype, instr*) + | IF(blocktype, instr*, instr*) + | BR(labelidx) + | BR_IF(labelidx) + | BR_TABLE(labelidx*, labelidx) + | CALL(funcidx) + | CALL_INDIRECT(tableidx, functype) + | RETURN + | CONST(numtype, c_numtype) + | UNOP(numtype, unop_numtype) + | BINOP(numtype, binop_numtype) + | TESTOP(numtype, testop_numtype) + | RELOP(numtype, relop_numtype) + | EXTEND(numtype, n) + | CVTOP(numtype, cvtop, numtype, sx?) + | REF.NULL(reftype) + | REF.FUNC(funcidx) + | REF.IS_NULL + | LOCAL.GET(localidx) + | LOCAL.SET(localidx) + | LOCAL.TEE(localidx) + | GLOBAL.GET(globalidx) + | GLOBAL.SET(globalidx) + | TABLE.GET(tableidx) + | TABLE.SET(tableidx) + | TABLE.SIZE(tableidx) + | TABLE.GROW(tableidx) + | TABLE.FILL(tableidx) + | TABLE.COPY(tableidx, tableidx) + | TABLE.INIT(tableidx, elemidx) + | ELEM.DROP(elemidx) + | MEMORY.SIZE + | MEMORY.GROW + | MEMORY.FILL + | MEMORY.COPY + | MEMORY.INIT(dataidx) + | DATA.DROP(dataidx) + | LOAD(numtype, (n, sx)?, nat, nat) + | STORE(numtype, n?, nat, nat) +} + +;; 1-syntax.watsup:179.1-180.9 +syntax expr = instr* + +;; 1-syntax.watsup:185.1-185.50 +syntax elemmode = + | TABLE(tableidx, expr) + | DECLARE + +;; 1-syntax.watsup:186.1-186.39 +syntax datamode = + | MEMORY(memidx, expr) + +;; 1-syntax.watsup:188.1-189.30 +syntax func = `FUNC%%*%`(functype, valtype*, expr) + +;; 1-syntax.watsup:190.1-191.25 +syntax global = GLOBAL(globaltype, expr) + +;; 1-syntax.watsup:192.1-193.18 +syntax table = TABLE(tabletype) + +;; 1-syntax.watsup:194.1-195.17 +syntax mem = MEMORY(memtype) + +;; 1-syntax.watsup:196.1-197.31 +syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) + +;; 1-syntax.watsup:198.1-199.26 +syntax data = `DATA(*)%*%?`(byte**, datamode?) + +;; 1-syntax.watsup:200.1-201.16 +syntax start = START(funcidx) + +;; 1-syntax.watsup:203.1-204.65 +syntax externuse = + | FUNC(funcidx) + | GLOBAL(globalidx) + | TABLE(tableidx) + | MEMORY(memidx) + +;; 1-syntax.watsup:205.1-206.24 +syntax export = EXPORT(name, externuse) + +;; 1-syntax.watsup:207.1-208.30 +syntax import = IMPORT(name, name, externtype) + +;; 1-syntax.watsup:210.1-211.70 +syntax module = `MODULE%*%*%*%*%*%*%*%*%*`(import*, func*, global*, table*, mem*, elem*, data*, start*, export*) + +;; 2-aux.watsup:5.1-5.55 +def size : valtype -> nat + ;; 2-aux.watsup:6.1-6.20 + def size(I32_valtype) = 32 + ;; 2-aux.watsup:7.1-7.20 + def size(I64_valtype) = 64 + ;; 2-aux.watsup:8.1-8.20 + def size(F32_valtype) = 32 + ;; 2-aux.watsup:9.1-9.20 + def size(F64_valtype) = 64 + ;; 2-aux.watsup:10.1-10.22 + def size(V128_valtype) = 128 + +;; 2-aux.watsup:15.1-15.40 +def test_sub_ATOM_22 : n -> nat + ;; 2-aux.watsup:16.1-16.38 + def {n_3_ATOM_y : n} test_sub_ATOM_22(n_3_ATOM_y) = 0 + +;; 2-aux.watsup:18.1-18.26 +def curried_ : (n, n) -> nat + ;; 2-aux.watsup:19.1-19.39 + def {n_1 : n, n_2 : n} curried_(n_1, n_2) = (n_1 + n_2) + +;; 2-aux.watsup:21.1-30.39 +syntax testfuse = + | AB_(nat, nat, nat) + | CD(nat, nat, nat) + | EF(nat, nat, nat) + | GH(nat, nat, nat) + | IJ(nat, nat, nat) + | KL(nat, nat, nat) + | MN(nat, nat, nat) + | OP(nat, nat, nat) + | QR(nat, nat, nat) + +;; 3-typing.watsup:3.1-6.60 +syntax context = {FUNC functype*, GLOBAL globaltype*, TABLE tabletype*, MEM memtype*, ELEM elemtype*, DATA datatype*, LOCAL valtype*, LABEL resulttype*, RETURN resulttype?} + +;; 3-typing.watsup:14.1-14.66 +relation Limits_ok: `|-%:%`(limits, nat) + ;; 3-typing.watsup:22.1-24.24 + rule _ {k : nat, n_1 : n, n_2 : n}: + `|-%:%`(`[%..%]`(n_1, n_2), k) + -- if ((n_1 <= n_2) /\ (n_2 <= k)) + +;; 3-typing.watsup:15.1-15.64 +relation Functype_ok: `|-%:OK`(functype) + ;; 3-typing.watsup:26.1-27.13 + rule _ {ft : functype}: + `|-%:OK`(ft) + +;; 3-typing.watsup:16.1-16.66 +relation Globaltype_ok: `|-%:OK`(globaltype) + ;; 3-typing.watsup:29.1-30.13 + rule _ {gt : globaltype}: + `|-%:OK`(gt) + +;; 3-typing.watsup:17.1-17.65 +relation Tabletype_ok: `|-%:OK`(tabletype) + ;; 3-typing.watsup:32.1-34.35 + rule _ {lim : limits, rt : reftype}: + `|-%:OK`(`%%`(lim, rt)) + -- Limits_ok: `|-%:%`(lim, ((2 ^ 32) - 1)) + +;; 3-typing.watsup:18.1-18.63 +relation Memtype_ok: `|-%:OK`(memtype) + ;; 3-typing.watsup:36.1-38.33 + rule _ {lim : limits}: + `|-%:OK`(`%I8`(lim)) + -- Limits_ok: `|-%:%`(lim, (2 ^ 16)) + +;; 3-typing.watsup:19.1-19.66 +relation Externtype_ok: `|-%:OK`(externtype) + ;; 3-typing.watsup:41.1-43.35 + rule func {functype : functype}: + `|-%:OK`(FUNC_externtype(functype)) + -- Functype_ok: `|-%:OK`(functype) + + ;; 3-typing.watsup:45.1-47.39 + rule global {globaltype : globaltype}: + `|-%:OK`(GLOBAL_externtype(globaltype)) + -- Globaltype_ok: `|-%:OK`(globaltype) + + ;; 3-typing.watsup:49.1-51.37 + rule table {tabletype : tabletype}: + `|-%:OK`(TABLE_externtype(tabletype)) + -- Tabletype_ok: `|-%:OK`(tabletype) + + ;; 3-typing.watsup:53.1-55.33 + rule mem {memtype : memtype}: + `|-%:OK`(MEMORY_externtype(memtype)) + -- Memtype_ok: `|-%:OK`(memtype) + +;; 3-typing.watsup:61.1-61.65 +relation Valtype_sub: `|-%<:%`(valtype, valtype) + ;; 3-typing.watsup:64.1-65.12 + rule refl {t : valtype}: + `|-%<:%`(t, t) + + ;; 3-typing.watsup:67.1-68.14 + rule bot {t : valtype}: + `|-%<:%`(BOT_valtype, t) + +;; 3-typing.watsup:62.1-62.72 +relation Resulttype_sub: `|-%*<:%*`(valtype*, valtype*) + ;; 3-typing.watsup:70.1-72.35 + rule _ {t_1* : valtype*, t_2* : valtype*}: + `|-%*<:%*`(t_1*{t_1}, t_2*{t_2}) + -- (Valtype_sub: `|-%<:%`(t_1, t_2))*{t_1 t_2} + +;; 3-typing.watsup:75.1-75.75 +relation Limits_sub: `|-%<:%`(limits, limits) + ;; 3-typing.watsup:83.1-86.21 + rule _ {n_11 : n, n_12 : n, n_21 : n, n_22 : n}: + `|-%<:%`(`[%..%]`(n_11, n_12), `[%..%]`(n_21, n_22)) + -- if (n_11 >= n_21) + -- if (n_12 <= n_22) + +;; 3-typing.watsup:76.1-76.73 +relation Functype_sub: `|-%<:%`(functype, functype) + ;; 3-typing.watsup:88.1-89.14 + rule _ {ft : functype}: + `|-%<:%`(ft, ft) + +;; 3-typing.watsup:77.1-77.75 +relation Globaltype_sub: `|-%<:%`(globaltype, globaltype) + ;; 3-typing.watsup:91.1-92.14 + rule _ {gt : globaltype}: + `|-%<:%`(gt, gt) + +;; 3-typing.watsup:78.1-78.74 +relation Tabletype_sub: `|-%<:%`(tabletype, tabletype) + ;; 3-typing.watsup:94.1-96.35 + rule _ {lim_1 : limits, lim_2 : limits, rt : reftype}: + `|-%<:%`(`%%`(lim_1, rt), `%%`(lim_2, rt)) + -- Limits_sub: `|-%<:%`(lim_1, lim_2) + +;; 3-typing.watsup:79.1-79.72 +relation Memtype_sub: `|-%<:%`(memtype, memtype) + ;; 3-typing.watsup:98.1-100.35 + rule _ {lim_1 : limits, lim_2 : limits}: + `|-%<:%`(`%I8`(lim_1), `%I8`(lim_2)) + -- Limits_sub: `|-%<:%`(lim_1, lim_2) + +;; 3-typing.watsup:80.1-80.75 +relation Externtype_sub: `|-%<:%`(externtype, externtype) + ;; 3-typing.watsup:103.1-105.35 + rule func {ft_1 : functype, ft_2 : functype}: + `|-%<:%`(FUNC_externtype(ft_1), FUNC_externtype(ft_2)) + -- Functype_sub: `|-%<:%`(ft_1, ft_2) + + ;; 3-typing.watsup:107.1-109.37 + rule global {gt_1 : globaltype, gt_2 : globaltype}: + `|-%<:%`(GLOBAL_externtype(gt_1), GLOBAL_externtype(gt_2)) + -- Globaltype_sub: `|-%<:%`(gt_1, gt_2) + + ;; 3-typing.watsup:111.1-113.36 + rule table {tt_1 : tabletype, tt_2 : tabletype}: + `|-%<:%`(TABLE_externtype(tt_1), TABLE_externtype(tt_2)) + -- Tabletype_sub: `|-%<:%`(tt_1, tt_2) + + ;; 3-typing.watsup:115.1-117.34 + rule mem {mt_1 : memtype, mt_2 : memtype}: + `|-%<:%`(MEMORY_externtype(mt_1), MEMORY_externtype(mt_2)) + -- Memtype_sub: `|-%<:%`(mt_1, mt_2) + +;; 3-typing.watsup:172.1-172.76 +relation Blocktype_ok: `%|-%:%`(context, blocktype, functype) + ;; 3-typing.watsup:174.1-176.29 + rule _ {C : context, ft : functype}: + `%|-%:%`(C, ft, ft) + -- Functype_ok: `|-%:OK`(ft) + +;; 3-typing.watsup:123.1-124.67 +rec { + +;; 3-typing.watsup:123.1-123.66 +relation Instr_ok: `%|-%:%`(context, instr, functype) + ;; 3-typing.watsup:153.1-154.34 + rule unreachable {C : context, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, UNREACHABLE_instr, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:156.1-157.32 + rule nop {C : context}: + `%|-%:%`(C, NOP_instr, `%->%`([], [])) + + ;; 3-typing.watsup:159.1-160.27 + rule drop {C : context, t : valtype}: + `%|-%:%`(C, DROP_instr, `%->%`([t], [])) + + ;; 3-typing.watsup:163.1-164.31 + rule select-expl {C : context, t : valtype}: + `%|-%:%`(C, SELECT_instr(?(t)), `%->%`([t t I32_valtype], [t])) + + ;; 3-typing.watsup:166.1-169.37 + rule select-impl {C : context, numtype : numtype, t : valtype, t' : valtype, vectype : vectype}: + `%|-%:%`(C, SELECT_instr(?()), `%->%`([t t I32_valtype], [t])) + -- Valtype_sub: `|-%<:%`(t, t') + -- if ((t' = (numtype <: valtype)) \/ (t' = (vectype <: valtype))) + + ;; 3-typing.watsup:178.1-181.57 + rule block {C : context, bt : blocktype, instr* : instr*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, BLOCK_instr(bt, instr*{instr}), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:183.1-186.57 + rule loop {C : context, bt : blocktype, instr* : instr*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, LOOP_instr(bt, instr*{instr}), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_1]*{t_1}, RETURN ?()}, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:188.1-192.59 + rule if {C : context, bt : blocktype, instr_1* : instr*, instr_2* : instr*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, IF_instr(bt, instr_1*{instr_1}, instr_2*{instr_2}), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Blocktype_ok: `%|-%:%`(C, bt, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr_1*{instr_1}, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2]*{t_2}, RETURN ?()}, instr_2*{instr_2}, `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:195.1-197.24 + rule br {C : context, l : labelidx, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, BR_instr(l), `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) + -- if (C.LABEL_context[l] = t*{t}) + + ;; 3-typing.watsup:199.1-201.24 + rule br_if {C : context, l : labelidx, t* : valtype*}: + `%|-%:%`(C, BR_IF_instr(l), `%->%`(t*{t} :: [I32_valtype], t*{t})) + -- if (C.LABEL_context[l] = t*{t}) + + ;; 3-typing.watsup:203.1-206.42 + rule br_table {C : context, l* : labelidx*, l' : labelidx, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, BR_TABLE_instr(l*{l}, l'), `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) + -- (Resulttype_sub: `|-%*<:%*`(t*{t}, C.LABEL_context[l]))*{l} + -- Resulttype_sub: `|-%*<:%*`(t*{t}, C.LABEL_context[l']) + + ;; 3-typing.watsup:208.1-210.24 + rule return {C : context, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, RETURN_instr, `%->%`(t_1*{t_1} :: t*{t}, t_2*{t_2})) + -- if (C.RETURN_context = ?(t*{t})) + + ;; 3-typing.watsup:212.1-214.33 + rule call {C : context, t_1* : valtype*, t_2* : valtype*, x : idx}: + `%|-%:%`(C, CALL_instr(x), `%->%`(t_1*{t_1}, t_2*{t_2})) + -- if (C.FUNC_context[x] = `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:216.1-219.26 + rule call_indirect {C : context, ft : functype, lim : limits, t_1* : valtype*, t_2* : valtype*, x : idx}: + `%|-%:%`(C, CALL_INDIRECT_instr(x, ft), `%->%`(t_1*{t_1} :: [I32_valtype], t_2*{t_2})) + -- if (C.TABLE_context[x] = `%%`(lim, FUNCREF_reftype)) + -- if (ft = `%->%`(t_1*{t_1}, t_2*{t_2})) + + ;; 3-typing.watsup:222.1-223.37 + rule const {C : context, c_nt : c_numtype, nt : numtype}: + `%|-%:%`(C, CONST_instr(nt, c_nt), `%->%`([], [(nt <: valtype)])) + + ;; 3-typing.watsup:225.1-226.31 + rule unop {C : context, nt : numtype, unop : unop_numtype}: + `%|-%:%`(C, UNOP_instr(nt, unop), `%->%`([(nt <: valtype)], [(nt <: valtype)])) + + ;; 3-typing.watsup:228.1-229.36 + rule binop {C : context, binop : binop_numtype, nt : numtype}: + `%|-%:%`(C, BINOP_instr(nt, binop), `%->%`([(nt <: valtype) (nt <: valtype)], [(nt <: valtype)])) + + ;; 3-typing.watsup:231.1-232.36 + rule testop {C : context, nt : numtype, testop : testop_numtype}: + `%|-%:%`(C, TESTOP_instr(nt, testop), `%->%`([(nt <: valtype)], [I32_valtype])) + + ;; 3-typing.watsup:234.1-235.37 + rule relop {C : context, nt : numtype, relop : relop_numtype}: + `%|-%:%`(C, RELOP_instr(nt, relop), `%->%`([(nt <: valtype) (nt <: valtype)], [I32_valtype])) + + ;; 3-typing.watsup:238.1-240.23 + rule extend {C : context, n : n, nt : numtype}: + `%|-%:%`(C, EXTEND_instr(nt, n), `%->%`([(nt <: valtype)], [(nt <: valtype)])) + -- if (n <= $size(nt <: valtype)) + + ;; 3-typing.watsup:242.1-245.34 + rule reinterpret {C : context, nt_1 : numtype, nt_2 : numtype}: + `%|-%:%`(C, CVTOP_instr(nt_1, REINTERPRET_cvtop, nt_2, ?()), `%->%`([(nt_2 <: valtype)], [(nt_1 <: valtype)])) + -- if (nt_1 =/= nt_2) + -- if ($size(nt_1 <: valtype) = $size(nt_2 <: valtype)) + + ;; 3-typing.watsup:247.1-250.52 + rule convert-i {C : context, in_1 : in, in_2 : in, sx? : sx?}: + `%|-%:%`(C, CVTOP_instr((in_1 <: numtype), CONVERT_cvtop, (in_2 <: numtype), sx?{sx}), `%->%`([(in_2 <: valtype)], [(in_1 <: valtype)])) + -- if (in_1 =/= in_2) + -- if ((sx?{sx} = ?()) <=> ($size(in_1 <: valtype) > $size(in_2 <: valtype))) + + ;; 3-typing.watsup:252.1-254.22 + rule convert-f {C : context, fn_1 : fn, fn_2 : fn}: + `%|-%:%`(C, CVTOP_instr((fn_1 <: numtype), CONVERT_cvtop, (fn_2 <: numtype), ?()), `%->%`([(fn_2 <: valtype)], [(fn_1 <: valtype)])) + -- if (fn_1 =/= fn_2) + + ;; 3-typing.watsup:257.1-258.35 + rule ref.null {C : context, rt : reftype}: + `%|-%:%`(C, REF.NULL_instr(rt), `%->%`([], [(rt <: valtype)])) + + ;; 3-typing.watsup:260.1-262.23 + rule ref.func {C : context, ft : functype, x : idx}: + `%|-%:%`(C, REF.FUNC_instr(x), `%->%`([], [FUNCREF_valtype])) + -- if (C.FUNC_context[x] = ft) + + ;; 3-typing.watsup:264.1-265.31 + rule ref.is_null {C : context, rt : reftype}: + `%|-%:%`(C, REF.IS_NULL_instr, `%->%`([(rt <: valtype)], [I32_valtype])) + + ;; 3-typing.watsup:268.1-270.23 + rule local.get {C : context, t : valtype, x : idx}: + `%|-%:%`(C, LOCAL.GET_instr(x), `%->%`([], [t])) + -- if (C.LOCAL_context[x] = t) + + ;; 3-typing.watsup:272.1-274.23 + rule local.set {C : context, t : valtype, x : idx}: + `%|-%:%`(C, LOCAL.SET_instr(x), `%->%`([t], [])) + -- if (C.LOCAL_context[x] = t) + + ;; 3-typing.watsup:276.1-278.23 + rule local.tee {C : context, t : valtype, x : idx}: + `%|-%:%`(C, LOCAL.TEE_instr(x), `%->%`([t], [t])) + -- if (C.LOCAL_context[x] = t) + + ;; 3-typing.watsup:281.1-283.29 + rule global.get {C : context, t : valtype, x : idx}: + `%|-%:%`(C, GLOBAL.GET_instr(x), `%->%`([], [t])) + -- if (C.GLOBAL_context[x] = `MUT%?%`(()?{}, t)) + + ;; 3-typing.watsup:285.1-287.28 + rule global.set {C : context, t : valtype, x : idx}: + `%|-%:%`(C, GLOBAL.SET_instr(x), `%->%`([t], [])) + -- if (C.GLOBAL_context[x] = `MUT%?%`(?(()), t)) + + ;; 3-typing.watsup:290.1-292.28 + rule table.get {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.GET_instr(x), `%->%`([I32_valtype], [(rt <: valtype)])) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:294.1-296.28 + rule table.set {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.SET_instr(x), `%->%`([I32_valtype (rt <: valtype)], [])) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:298.1-300.24 + rule table.size {C : context, tt : tabletype, x : idx}: + `%|-%:%`(C, TABLE.SIZE_instr(x), `%->%`([], [I32_valtype])) + -- if (C.TABLE_context[x] = tt) + + ;; 3-typing.watsup:302.1-304.28 + rule table.grow {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.GROW_instr(x), `%->%`([(rt <: valtype) I32_valtype], [I32_valtype])) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:306.1-308.28 + rule table.fill {C : context, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE.FILL_instr(x), `%->%`([I32_valtype (rt <: valtype) I32_valtype], [])) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + + ;; 3-typing.watsup:310.1-313.32 + rule table.copy {C : context, lim_1 : limits, lim_2 : limits, rt : reftype, x_1 : idx, x_2 : idx}: + `%|-%:%`(C, TABLE.COPY_instr(x_1, x_2), `%->%`([I32_valtype I32_valtype I32_valtype], [])) + -- if (C.TABLE_context[x_1] = `%%`(lim_1, rt)) + -- if (C.TABLE_context[x_2] = `%%`(lim_2, rt)) + + ;; 3-typing.watsup:315.1-318.25 + rule table.init {C : context, lim : limits, rt : reftype, x_1 : idx, x_2 : idx}: + `%|-%:%`(C, TABLE.INIT_instr(x_1, x_2), `%->%`([I32_valtype I32_valtype I32_valtype], [])) + -- if (C.TABLE_context[x_1] = `%%`(lim, rt)) + -- if (C.ELEM_context[x_2] = rt) + + ;; 3-typing.watsup:320.1-322.23 + rule elem.drop {C : context, rt : reftype, x : idx}: + `%|-%:%`(C, ELEM.DROP_instr(x), `%->%`([], [])) + -- if (C.ELEM_context[x] = rt) + + ;; 3-typing.watsup:325.1-327.22 + rule memory.size {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.SIZE_instr, `%->%`([], [I32_valtype])) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:329.1-331.22 + rule memory.grow {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.GROW_instr, `%->%`([I32_valtype], [I32_valtype])) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:333.1-335.22 + rule memory.fill {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.FILL_instr, `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:337.1-339.22 + rule memory.copy {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY.COPY_instr, `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) + -- if (C.MEM_context[0] = mt) + + ;; 3-typing.watsup:341.1-344.23 + rule memory.init {C : context, mt : memtype, x : idx}: + `%|-%:%`(C, MEMORY.INIT_instr(x), `%->%`([I32_valtype I32_valtype I32_valtype], [I32_valtype])) + -- if (C.MEM_context[0] = mt) + -- if (C.DATA_context[x] = OK) + + ;; 3-typing.watsup:346.1-348.23 + rule data.drop {C : context, x : idx}: + `%|-%:%`(C, DATA.DROP_instr(x), `%->%`([], [])) + -- if (C.DATA_context[x] = OK) + + ;; 3-typing.watsup:350.1-355.32 + rule load {C : context, in : in, mt : memtype, n? : n?, n_A : n, n_O : n, nt : numtype, sx? : sx?}: + `%|-%:%`(C, LOAD_instr(nt, (n, sx)?{n sx}, n_A, n_O), `%->%`([I32_valtype], [(nt <: valtype)])) + -- if (C.MEM_context[0] = mt) + -- if ((2 ^ n_A) <= ($size(nt <: valtype) / 8)) + -- (if (((2 ^ n_A) <= (n / 8)) /\ ((n / 8) < ($size(nt <: valtype) / 8))))?{n} + -- if ((n?{n} = ?()) \/ (nt = (in <: numtype))) + + ;; 3-typing.watsup:357.1-362.32 + rule store {C : context, in : in, mt : memtype, n? : n?, n_A : n, n_O : n, nt : numtype}: + `%|-%:%`(C, STORE_instr(nt, n?{n}, n_A, n_O), `%->%`([I32_valtype (nt <: valtype)], [])) + -- if (C.MEM_context[0] = mt) + -- if ((2 ^ n_A) <= ($size(nt <: valtype) / 8)) + -- (if (((2 ^ n_A) <= (n / 8)) /\ ((n / 8) < ($size(nt <: valtype) / 8))))?{n} + -- if ((n?{n} = ?()) \/ (nt = (in <: numtype))) + +;; 3-typing.watsup:124.1-124.67 +relation InstrSeq_ok: `%|-%*:%`(context, instr*, functype) + ;; 3-typing.watsup:133.1-134.36 + rule empty {C : context}: + `%|-%*:%`(C, [], `%->%`([], [])) + + ;; 3-typing.watsup:136.1-139.46 + rule seq {C : context, instr_1 : instr, instr_2 : instr, t_1* : valtype*, t_2* : valtype*, t_3* : valtype*}: + `%|-%*:%`(C, [instr_1] :: instr_2*{}, `%->%`(t_1*{t_1}, t_3*{t_3})) + -- Instr_ok: `%|-%:%`(C, instr_1, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C, [instr_2], `%->%`(t_2*{t_2}, t_3*{t_3})) + + ;; 3-typing.watsup:141.1-146.38 + rule weak {C : context, instr* : instr*, t'_1 : valtype, t'_2* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%*:%`(C, instr*{instr}, `%->%`([t'_1], t'_2*{t'_2})) + -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Resulttype_sub: `|-%*<:%*`(t'_1*{}, t_1*{t_1}) + -- Resulttype_sub: `|-%*<:%*`(t_2*{t_2}, t'_2*{t'_2}) + + ;; 3-typing.watsup:148.1-150.45 + rule frame {C : context, instr* : instr*, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%*:%`(C, instr*{instr}, `%->%`(t*{t} :: t_1*{t_1}, t*{t} :: t_2*{t_2})) + -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`(t_1*{t_1}, t_2*{t_2})) +} + +;; 3-typing.watsup:125.1-125.71 +relation Expr_ok: `%|-%:%`(context, expr, resulttype) + ;; 3-typing.watsup:128.1-130.46 + rule _ {C : context, instr* : instr*, t* : valtype*}: + `%|-%:%`(C, instr*{instr}, t*{t}) + -- InstrSeq_ok: `%|-%*:%`(C, instr*{instr}, `%->%`([], t*{t})) + +;; 3-typing.watsup:367.1-367.78 +relation Instr_const: `%|-%CONST`(context, instr) + ;; 3-typing.watsup:371.1-372.26 + rule const {C : context, c : c_numtype, nt : numtype}: + `%|-%CONST`(C, CONST_instr(nt, c)) + + ;; 3-typing.watsup:374.1-375.27 + rule ref.null {C : context, rt : reftype}: + `%|-%CONST`(C, REF.NULL_instr(rt)) + + ;; 3-typing.watsup:377.1-378.26 + rule ref.func {C : context, x : idx}: + `%|-%CONST`(C, REF.FUNC_instr(x)) + + ;; 3-typing.watsup:380.1-382.32 + rule global.get {C : context, t : valtype, x : idx}: + `%|-%CONST`(C, GLOBAL.GET_instr(x)) + -- if (C.GLOBAL_context[x] = `MUT%?%`(?(), t)) + +;; 3-typing.watsup:368.1-368.77 +relation Expr_const: `%|-%CONST`(context, expr) + ;; 3-typing.watsup:385.1-386.38 + rule _ {C : context, instr* : instr*}: + `%|-%CONST`(C, instr*{instr}) + -- (Instr_const: `%|-%CONST`(C, instr))*{instr} + +;; 3-typing.watsup:369.1-369.78 +relation Expr_ok_const: `%|-%:%CONST`(context, expr, valtype) + ;; 3-typing.watsup:389.1-392.33 + rule _ {C : context, expr : expr, t : valtype}: + `%|-%:%CONST`(C, expr, t) + -- Expr_ok: `%|-%:%`(C, expr, [t]) + -- Expr_const: `%|-%CONST`(C, expr) + +;; 3-typing.watsup:397.1-397.73 +relation Func_ok: `%|-%:%`(context, func, functype) + ;; 3-typing.watsup:408.1-412.75 + rule _ {C : context, expr : expr, ft : functype, t* : valtype*, t_1* : valtype*, t_2* : valtype*}: + `%|-%:%`(C, `FUNC%%*%`(ft, t*{t}, expr), ft) + -- if (ft = `%->%`(t_1*{t_1}, t_2*{t_2})) + -- Functype_ok: `|-%:OK`(ft) + -- Expr_ok: `%|-%:%`(C ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL t_1*{t_1} :: t*{t}, LABEL [], RETURN ?()} ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [t_2*{t_2}], RETURN ?()} ++ {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], LOCAL [], LABEL [], RETURN ?(t_2*{t_2})}, expr, t_2*{t_2}) + +;; 3-typing.watsup:398.1-398.75 +relation Global_ok: `%|-%:%`(context, global, globaltype) + ;; 3-typing.watsup:414.1-418.40 + rule _ {C : context, expr : expr, gt : globaltype, t : valtype}: + `%|-%:%`(C, GLOBAL(gt, expr), gt) + -- Globaltype_ok: `|-%:OK`(gt) + -- if (gt = `MUT%?%`(()?{}, t)) + -- Expr_ok_const: `%|-%:%CONST`(C, expr, t) + +;; 3-typing.watsup:399.1-399.74 +relation Table_ok: `%|-%:%`(context, table, tabletype) + ;; 3-typing.watsup:420.1-422.30 + rule _ {C : context, tt : tabletype}: + `%|-%:%`(C, TABLE(tt), tt) + -- Tabletype_ok: `|-%:OK`(tt) + +;; 3-typing.watsup:400.1-400.72 +relation Mem_ok: `%|-%:%`(context, mem, memtype) + ;; 3-typing.watsup:424.1-426.28 + rule _ {C : context, mt : memtype}: + `%|-%:%`(C, MEMORY(mt), mt) + -- Memtype_ok: `|-%:OK`(mt) + +;; 3-typing.watsup:403.1-403.77 +relation Elemmode_ok: `%|-%:%`(context, elemmode, reftype) + ;; 3-typing.watsup:437.1-440.45 + rule active {C : context, expr : expr, lim : limits, rt : reftype, x : idx}: + `%|-%:%`(C, TABLE_elemmode(x, expr), rt) + -- if (C.TABLE_context[x] = `%%`(lim, rt)) + -- (Expr_ok_const: `%|-%:%CONST`(C, expr, I32_valtype))*{} + + ;; 3-typing.watsup:442.1-443.20 + rule declare {C : context, rt : reftype}: + `%|-%:%`(C, DECLARE_elemmode, rt) + +;; 3-typing.watsup:401.1-401.73 +relation Elem_ok: `%|-%:%`(context, elem, reftype) + ;; 3-typing.watsup:428.1-431.40 + rule _ {C : context, elemmode? : elemmode?, expr* : expr*, rt : reftype}: + `%|-%:%`(C, `ELEM%%*%?`(rt, expr*{expr}, elemmode?{elemmode}), rt) + -- (Expr_ok: `%|-%:%`(C, expr, [(rt <: valtype)]))*{expr} + -- (Elemmode_ok: `%|-%:%`(C, elemmode, rt))?{elemmode} + +;; 3-typing.watsup:404.1-404.77 +relation Datamode_ok: `%|-%:OK`(context, datamode) + ;; 3-typing.watsup:445.1-448.45 + rule _ {C : context, expr : expr, mt : memtype}: + `%|-%:OK`(C, MEMORY_datamode(0, expr)) + -- if (C.MEM_context[0] = mt) + -- (Expr_ok_const: `%|-%:%CONST`(C, expr, I32_valtype))*{} + +;; 3-typing.watsup:402.1-402.73 +relation Data_ok: `%|-%:OK`(context, data) + ;; 3-typing.watsup:433.1-435.40 + rule _ {C : context, b** : byte**, datamode? : datamode?}: + `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} + +;; 3-typing.watsup:405.1-405.74 +relation Start_ok: `%|-%:OK`(context, start) + ;; 3-typing.watsup:450.1-452.39 + rule _ {C : context, x : idx}: + `%|-%:OK`(C, START(x)) + -- if (C.FUNC_context[x] = `%->%`([], [])) + +;; 3-typing.watsup:455.1-455.80 +relation Import_ok: `%|-%:%`(context, import, externtype) + ;; 3-typing.watsup:459.1-461.31 + rule _ {C : context, name_1 : name, name_2 : name, xt : externtype}: + `%|-%:%`(C, IMPORT(name_1, name_2, xt), xt) + -- Externtype_ok: `|-%:OK`(xt) + +;; 3-typing.watsup:457.1-457.83 +relation Externuse_ok: `%|-%:%`(context, externuse, externtype) + ;; 3-typing.watsup:467.1-469.23 + rule func {C : context, ft : functype, x : idx}: + `%|-%:%`(C, FUNC_externuse(x), FUNC_externtype(ft)) + -- if (C.FUNC_context[x] = ft) + + ;; 3-typing.watsup:471.1-473.25 + rule global {C : context, gt : globaltype, x : idx}: + `%|-%:%`(C, GLOBAL_externuse(x), GLOBAL_externtype(gt)) + -- if (C.GLOBAL_context[x] = gt) + + ;; 3-typing.watsup:475.1-477.24 + rule table {C : context, tt : tabletype, x : idx}: + `%|-%:%`(C, TABLE_externuse(x), TABLE_externtype(tt)) + -- if (C.TABLE_context[x] = tt) + + ;; 3-typing.watsup:479.1-481.22 + rule mem {C : context, mt : memtype, x : idx}: + `%|-%:%`(C, MEMORY_externuse(x), MEMORY_externtype(mt)) + -- if (C.MEM_context[x] = mt) + +;; 3-typing.watsup:456.1-456.80 +relation Export_ok: `%|-%:%`(context, export, externtype) + ;; 3-typing.watsup:463.1-465.39 + rule _ {C : context, externuse : externuse, name : name, xt : externtype}: + `%|-%:%`(C, EXPORT(name, externuse), xt) + -- Externuse_ok: `%|-%:%`(C, externuse, xt) + +;; 3-typing.watsup:484.1-484.62 +relation Module_ok: `|-%:OK`(module) + ;; 3-typing.watsup:486.1-501.22 + rule _ {C : context, data^n : data^n, elem* : elem*, export* : export*, ft* : functype*, func* : func*, global* : global*, gt* : globaltype*, import* : import*, mem* : mem*, mt* : memtype*, n : n, rt* : reftype*, start* : start*, table* : table*, tt* : tabletype*}: + `|-%:OK`(`MODULE%*%*%*%*%*%*%*%*%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data^n{data}, start*{start}, export*{export})) + -- if (C = {FUNC ft*{ft}, GLOBAL gt*{gt}, TABLE tt*{tt}, MEM mt*{mt}, ELEM rt*{rt}, DATA OK^n{}, LOCAL [], LABEL [], RETURN ?()}) + -- (Func_ok: `%|-%:%`(C, func, ft))*{ft func} + -- (Global_ok: `%|-%:%`(C, global, gt))*{global gt} + -- (Table_ok: `%|-%:%`(C, table, tt))*{table tt} + -- (Mem_ok: `%|-%:%`(C, mem, mt))*{mem mt} + -- (Elem_ok: `%|-%:%`(C, elem, rt))*{elem rt} + -- (Data_ok: `%|-%:OK`(C, data))^n{data} + -- (Start_ok: `%|-%:OK`(C, start))*{start} + -- if (|mem*{mem}| <= 1) + -- if (|start*{start}| <= 1) + +;; 4-runtime.watsup:3.1-3.39 +syntax addr = nat + +;; 4-runtime.watsup:4.1-4.53 +syntax funcaddr = addr + +;; 4-runtime.watsup:5.1-5.53 +syntax globaladdr = addr + +;; 4-runtime.watsup:6.1-6.51 +syntax tableaddr = addr + +;; 4-runtime.watsup:7.1-7.50 +syntax memaddr = addr + +;; 4-runtime.watsup:8.1-8.49 +syntax elemaddr = addr + +;; 4-runtime.watsup:9.1-9.49 +syntax dataaddr = addr + +;; 4-runtime.watsup:10.1-10.51 +syntax labeladdr = addr + +;; 4-runtime.watsup:11.1-11.49 +syntax hostaddr = addr + +;; 4-runtime.watsup:24.1-25.24 +syntax num = + | CONST(numtype, c_numtype) + +;; 4-runtime.watsup:26.1-27.67 +syntax ref = + | REF.NULL(reftype) + | REF.FUNC_ADDR(funcaddr) + | REF.HOST_ADDR(hostaddr) + +;; 4-runtime.watsup:28.1-29.10 +syntax val = + | CONST(numtype, c_numtype) + | REF.NULL(reftype) + | REF.FUNC_ADDR(funcaddr) + | REF.HOST_ADDR(hostaddr) + +;; 4-runtime.watsup:31.1-32.18 +syntax result = + | _VALS(val*) + | TRAP + +;; 4-runtime.watsup:38.1-39.66 +syntax externval = + | FUNC(funcaddr) + | GLOBAL(globaladdr) + | TABLE(tableaddr) + | MEM(memaddr) + +;; 4-runtime.watsup:44.1-44.44 +def default_ : valtype -> val + ;; 4-runtime.watsup:45.1-45.35 + def default_(I32_valtype) = CONST_val(I32_numtype, 0) + ;; 4-runtime.watsup:46.1-46.35 + def default_(I64_valtype) = CONST_val(I64_numtype, 0) + ;; 4-runtime.watsup:47.1-47.35 + def default_(F32_valtype) = CONST_val(F32_numtype, 0) + ;; 4-runtime.watsup:48.1-48.35 + def default_(F64_valtype) = CONST_val(F64_numtype, 0) + ;; 4-runtime.watsup:49.1-49.34 + def {rt : reftype} default_(rt <: valtype) = REF.NULL_val(rt) + +;; 4-runtime.watsup:60.1-60.71 +syntax exportinst = EXPORT(name, externval) + +;; 4-runtime.watsup:70.1-77.25 +syntax moduleinst = {FUNC funcaddr*, GLOBAL globaladdr*, TABLE tableaddr*, MEM memaddr*, ELEM elemaddr*, DATA dataaddr*, EXPORT exportinst*} + +;; 4-runtime.watsup:54.1-54.66 +syntax funcinst = `%;%`(moduleinst, func) + +;; 4-runtime.watsup:55.1-55.53 +syntax globalinst = val + +;; 4-runtime.watsup:56.1-56.52 +syntax tableinst = ref* + +;; 4-runtime.watsup:57.1-57.52 +syntax meminst = byte* + +;; 4-runtime.watsup:58.1-58.53 +syntax eleminst = ref* + +;; 4-runtime.watsup:59.1-59.51 +syntax datainst = byte* + +;; 4-runtime.watsup:62.1-68.21 +syntax store = {FUNC funcinst*, GLOBAL globalinst*, TABLE tableinst*, MEM meminst*, ELEM eleminst*, DATA datainst*} + +;; 4-runtime.watsup:79.1-81.24 +syntax frame = {LOCAL val*, MODULE moduleinst} + +;; 4-runtime.watsup:82.1-82.47 +syntax state = `%;%`(store, frame) + +;; 4-runtime.watsup:139.1-146.5 +rec { + +;; 4-runtime.watsup:139.1-146.5 +syntax admininstr = + | UNREACHABLE + | NOP + | DROP + | SELECT(valtype?) + | BLOCK(blocktype, instr*) + | LOOP(blocktype, instr*) + | IF(blocktype, instr*, instr*) + | BR(labelidx) + | BR_IF(labelidx) + | BR_TABLE(labelidx*, labelidx) + | CALL(funcidx) + | CALL_INDIRECT(tableidx, functype) + | RETURN + | CONST(numtype, c_numtype) + | UNOP(numtype, unop_numtype) + | BINOP(numtype, binop_numtype) + | TESTOP(numtype, testop_numtype) + | RELOP(numtype, relop_numtype) + | EXTEND(numtype, n) + | CVTOP(numtype, cvtop, numtype, sx?) + | REF.NULL(reftype) + | REF.FUNC(funcidx) + | REF.IS_NULL + | LOCAL.GET(localidx) + | LOCAL.SET(localidx) + | LOCAL.TEE(localidx) + | GLOBAL.GET(globalidx) + | GLOBAL.SET(globalidx) + | TABLE.GET(tableidx) + | TABLE.SET(tableidx) + | TABLE.SIZE(tableidx) + | TABLE.GROW(tableidx) + | TABLE.FILL(tableidx) + | TABLE.COPY(tableidx, tableidx) + | TABLE.INIT(tableidx, elemidx) + | ELEM.DROP(elemidx) + | MEMORY.SIZE + | MEMORY.GROW + | MEMORY.FILL + | MEMORY.COPY + | MEMORY.INIT(dataidx) + | DATA.DROP(dataidx) + | LOAD(numtype, (n, sx)?, nat, nat) + | STORE(numtype, n?, nat, nat) + | REF.FUNC_ADDR(funcaddr) + | REF.HOST_ADDR(hostaddr) + | CALL_ADDR(funcaddr) + | LABEL_(n, instr*, admininstr*) + | FRAME_(n, frame, admininstr*) + | TRAP +} + +;; 4-runtime.watsup:83.1-83.62 +syntax config = `%;%*`(state, admininstr*) + +;; 4-runtime.watsup:101.1-101.59 +def funcaddr : state -> funcaddr* + ;; 4-runtime.watsup:102.1-102.38 + def {f : frame, s : store} funcaddr(`%;%`(s, f)) = f.MODULE_frame.FUNC_moduleinst + +;; 4-runtime.watsup:104.1-104.52 +def funcinst : state -> funcinst* + ;; 4-runtime.watsup:105.1-105.31 + def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store + +;; 4-runtime.watsup:107.1-107.67 +def func : (state, funcidx) -> funcinst + ;; 4-runtime.watsup:115.1-115.48 + def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] + +;; 4-runtime.watsup:108.1-108.69 +def global : (state, globalidx) -> globalinst + ;; 4-runtime.watsup:116.1-116.54 + def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] + +;; 4-runtime.watsup:109.1-109.68 +def table : (state, tableidx) -> tableinst + ;; 4-runtime.watsup:117.1-117.51 + def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] + +;; 4-runtime.watsup:110.1-110.66 +def mem : (state, memidx) -> meminst + ;; 4-runtime.watsup:118.1-118.45 + def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] + +;; 4-runtime.watsup:111.1-111.67 +def elem : (state, tableidx) -> eleminst + ;; 4-runtime.watsup:119.1-119.48 + def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] + +;; 4-runtime.watsup:112.1-112.67 +def data : (state, dataidx) -> datainst + ;; 4-runtime.watsup:120.1-120.48 + def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] + +;; 4-runtime.watsup:113.1-113.68 +def local : (state, localidx) -> val + ;; 4-runtime.watsup:121.1-121.35 + def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] + +;; 4-runtime.watsup:124.1-124.78 +def with_local : (state, localidx, val) -> state + ;; 4-runtime.watsup:130.1-130.52 + def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL[x] = v]) + +;; 4-runtime.watsup:125.1-125.79 +def with_global : (state, globalidx, val) -> state + ;; 4-runtime.watsup:131.1-131.71 + def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL[f.MODULE_frame.GLOBAL_moduleinst[x]] = v], f) + +;; 4-runtime.watsup:126.1-126.81 +def with_table : (state, tableidx, n, ref) -> state + ;; 4-runtime.watsup:132.1-132.74 + def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]][i] = r], f) + +;; 4-runtime.watsup:127.1-127.80 +def with_tableext : (state, tableidx, ref*) -> state + ;; 4-runtime.watsup:133.1-133.75 + def {f : frame, r* : ref*, s : store, x : idx} with_tableext(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]] =.. r*{r}], f) + +;; 4-runtime.watsup:128.1-128.77 +def with_elem : (state, elemidx, ref*) -> state + ;; 4-runtime.watsup:134.1-134.69 + def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[TABLE[f.MODULE_frame.TABLE_moduleinst[x]] = r*{r}], f) + +;; 4-runtime.watsup:148.1-151.21 +rec { + +;; 4-runtime.watsup:148.1-151.21 +syntax E = + | _HOLE + | _SEQ(val*, E, instr*) + | LABEL_(n, instr*, E) +} + +;; 5-numerics.watsup:3.1-3.76 +def unop : (unop_numtype, numtype, c_numtype) -> c_numtype* + +;; 5-numerics.watsup:4.1-4.79 +def binop : (binop_numtype, numtype, c_numtype, c_numtype) -> c_numtype* + +;; 5-numerics.watsup:5.1-5.76 +def testop : (testop_numtype, numtype, c_numtype) -> c_numtype + +;; 5-numerics.watsup:6.1-6.79 +def relop : (relop_numtype, numtype, c_numtype, c_numtype) -> c_numtype + +;; 5-numerics.watsup:8.1-8.84 +def ext : (nat, nat, sx, c_numtype) -> c_numtype + +;; 5-numerics.watsup:9.1-9.84 +def cvtop : (numtype, cvtop, numtype, sx?, c_numtype) -> c_numtype* + +;; 6-reduction.watsup:4.1-4.63 +relation Step_pure: `%*~>%*`(admininstr*, admininstr*) + ;; 6-reduction.watsup:16.1-17.24 + rule unreachable: + `%*~>%*`([UNREACHABLE_admininstr], [TRAP_admininstr]) + + ;; 6-reduction.watsup:19.1-20.19 + rule nop: + `%*~>%*`([NOP_admininstr], []) + + ;; 6-reduction.watsup:22.1-23.24 + rule drop {val : val}: + `%*~>%*`([(val <: admininstr) DROP_admininstr], []) + + ;; 6-reduction.watsup:26.1-28.16 + rule select-true {c : c_numtype, t? : valtype?, val_1 : val, val_2 : val}: + `%*~>%*`([(val_1 <: admininstr) (val_2 <: admininstr) CONST_admininstr(I32_numtype, c) SELECT_admininstr(t?{t})], [(val_1 <: admininstr)]) + -- if (c =/= 0) + + ;; 6-reduction.watsup:30.1-32.14 + rule select-false {c : c_numtype, t? : valtype?, val_1 : val, val_2 : val}: + `%*~>%*`([(val_1 <: admininstr) (val_2 <: admininstr) CONST_admininstr(I32_numtype, c) SELECT_admininstr(t?{t})], [(val_2 <: admininstr)]) + -- if (c = 0) + + ;; 6-reduction.watsup:35.1-37.28 + rule block {bt : blocktype, instr* : instr*, k : nat, n : n, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k}: + `%*~>%*`((val <: admininstr)^k{val} :: [BLOCK_admininstr(bt, instr*{instr})], [LABEL__admininstr(n, [], (val <: admininstr)^k{val} :: (instr <: admininstr)*{instr})]) + -- if (bt = `%->%`(t_1^k{t_1}, t_2^n{t_2})) + + ;; 6-reduction.watsup:39.1-41.28 + rule loop {bt : blocktype, instr* : instr*, k : nat, n : n, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k}: + `%*~>%*`((val <: admininstr)^k{val} :: [LOOP_admininstr(bt, instr*{instr})], [LABEL__admininstr(n, [LOOP_instr(bt, instr*{instr})], (val <: admininstr)^k{val} :: (instr <: admininstr)*{instr})]) + -- if (bt = `%->%`(t_1^k{t_1}, t_2^n{t_2})) + + ;; 6-reduction.watsup:43.1-45.16 + rule if-true {bt : blocktype, c : c_numtype, instr_1* : instr*, instr_2* : instr*}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) IF_admininstr(bt, instr_1*{instr_1}, instr_2*{instr_2})], [BLOCK_admininstr(bt, instr_1*{instr_1})]) + -- if (c =/= 0) + + ;; 6-reduction.watsup:47.1-49.14 + rule if-false {bt : blocktype, c : c_numtype, instr_1* : instr*, instr_2* : instr*}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) IF_admininstr(bt, instr_1*{instr_1}, instr_2*{instr_2})], [BLOCK_admininstr(bt, instr_2*{instr_2})]) + -- if (c = 0) + + ;; 6-reduction.watsup:52.1-53.38 + rule label-vals {instr* : instr*, n : n, val* : val*}: + `%*~>%*`([LABEL__admininstr(n, instr*{instr}, (val <: admininstr)*{val})], (val <: admininstr)*{val}) + + ;; 6-reduction.watsup:57.1-58.69 + rule br-zero {instr* : instr*, instr'* : instr*, n : n, val^n : val^n, val'* : val*}: + `%*~>%*`([LABEL__admininstr(n, instr'*{instr'}, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [BR_admininstr(0)] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val} :: (instr' <: admininstr)*{instr'}) + + ;; 6-reduction.watsup:60.1-61.65 + rule br-succ {instr* : instr*, instr'* : instr*, l : labelidx, n : n, val* : val*}: + `%*~>%*`([LABEL__admininstr(n, instr'*{instr'}, (val <: admininstr)*{val} :: [BR_admininstr(l + 1)] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [BR_admininstr(l)]) + + ;; 6-reduction.watsup:64.1-66.16 + rule br_if-true {c : c_numtype, l : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) BR_IF_admininstr(l)], [BR_admininstr(l)]) + -- if (c =/= 0) + + ;; 6-reduction.watsup:68.1-70.14 + rule br_if-false {c : c_numtype, l : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, c) BR_IF_admininstr(l)], []) + -- if (c = 0) + + ;; 6-reduction.watsup:73.1-75.17 + rule br_table-lt {i : nat, l* : labelidx*, l' : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l*{l}[i])]) + -- if (i < |l*{l}|) + + ;; 6-reduction.watsup:77.1-79.18 + rule br_table-ge {i : nat, l* : labelidx*, l' : labelidx}: + `%*~>%*`([CONST_admininstr(I32_numtype, i) BR_TABLE_admininstr(l*{l}, l')], [BR_admininstr(l')]) + -- if (i >= |l*{l}|) + + ;; 6-reduction.watsup:100.1-101.35 + rule frame-vals {f : frame, n : n, val^n : val^n}: + `%*~>%*`([FRAME__admininstr(n, f, (val <: admininstr)^n{val})], (val <: admininstr)^n{val}) + + ;; 6-reduction.watsup:103.1-104.55 + rule return-frame {f : frame, instr* : instr*, n : n, val^n : val^n, val'* : val*}: + `%*~>%*`([FRAME__admininstr(n, f, (val' <: admininstr)*{val'} :: (val <: admininstr)^n{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)^n{val}) + + ;; 6-reduction.watsup:106.1-107.60 + rule return-label {instr* : instr*, instr'* : instr*, k : nat, val* : val*}: + `%*~>%*`([LABEL__admininstr(k, instr'*{instr'}, (val <: admininstr)*{val} :: [RETURN_admininstr] :: (instr <: admininstr)*{instr})], (val <: admininstr)*{val} :: [RETURN_admininstr]) + + ;; 6-reduction.watsup:110.1-112.33 + rule unop-val {c : c_numtype, c_1 : c_numtype, nt : numtype, unop : unop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [CONST_admininstr(nt, c)]) + -- if ($unop(unop, nt, c_1) = [c]) + + ;; 6-reduction.watsup:114.1-116.39 + rule unop-trap {c_1 : c_numtype, nt : numtype, unop : unop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) UNOP_admininstr(nt, unop)], [TRAP_admininstr]) + -- if ($unop(unop, nt, c_1) = []) + + ;; 6-reduction.watsup:119.1-121.40 + rule binop-val {binop : binop_numtype, c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [CONST_admininstr(nt, c)]) + -- if ($binop(binop, nt, c_1, c_2) = [c]) + + ;; 6-reduction.watsup:123.1-125.46 + rule binop-trap {binop : binop_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) BINOP_admininstr(nt, binop)], [TRAP_admininstr]) + -- if ($binop(binop, nt, c_1, c_2) = []) + + ;; 6-reduction.watsup:128.1-130.37 + rule testop {c : c_numtype, c_1 : c_numtype, nt : numtype, testop : testop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) TESTOP_admininstr(nt, testop)], [CONST_admininstr(I32_numtype, c)]) + -- if (c = $testop(testop, nt, c_1)) + + ;; 6-reduction.watsup:132.1-134.40 + rule relop {c : c_numtype, c_1 : c_numtype, c_2 : c_numtype, nt : numtype, relop : relop_numtype}: + `%*~>%*`([CONST_admininstr(nt, c_1) CONST_admininstr(nt, c_2) RELOP_admininstr(nt, relop)], [CONST_admininstr(I32_numtype, c)]) + -- if (c = $relop(relop, nt, c_1, c_2)) + + ;; 6-reduction.watsup:137.1-138.70 + rule extend {c : c_numtype, n : n, nt : numtype}: + `%*~>%*`([CONST_admininstr(nt, c) EXTEND_admininstr(nt, n)], [CONST_admininstr(nt, $ext(n, $size(nt <: valtype), S_sx, c))]) + + ;; 6-reduction.watsup:141.1-143.48 + rule cvtop-val {c : c_numtype, c_1 : c_numtype, cvtop : cvtop, nt : numtype, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: + `%*~>%*`([CONST_admininstr(nt, c_1) CVTOP_admininstr(nt_1, cvtop, nt_2, sx?{sx})], [CONST_admininstr(nt, c)]) + -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = [c]) + + ;; 6-reduction.watsup:145.1-147.54 + rule cvtop-trap {c_1 : c_numtype, cvtop : cvtop, nt : numtype, nt_1 : numtype, nt_2 : numtype, sx? : sx?}: + `%*~>%*`([CONST_admininstr(nt, c_1) CVTOP_admininstr(nt_1, cvtop, nt_2, sx?{sx})], [TRAP_admininstr]) + -- if ($cvtop(nt_1, cvtop, nt_2, sx?{sx}, c_1) = []) + + ;; 6-reduction.watsup:154.1-156.28 + rule ref.is_null-true {rt : reftype, val : val}: + `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 1)]) + -- if (val = REF.NULL_val(rt)) + + ;; 6-reduction.watsup:158.1-160.15 + rule ref.is_null-false {val : val}: + `%*~>%*`([(val <: admininstr) REF.IS_NULL_admininstr], [CONST_admininstr(I32_numtype, 0)]) + -- otherwise + + ;; 6-reduction.watsup:169.1-170.47 + rule local.tee {val : val, x : idx}: + `%*~>%*`([(val <: admininstr) LOCAL.TEE_admininstr(x)], [(val <: admininstr) (val <: admininstr) LOCAL.SET_admininstr(x)]) + +;; 6-reduction.watsup:5.1-5.63 +relation Step_read: `%~>%*`(config, admininstr*) + ;; 6-reduction.watsup:82.1-83.47 + rule call {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CALL_admininstr(x)]), [CALL_ADDR_admininstr($funcaddr(z)[x])]) + + ;; 6-reduction.watsup:85.1-88.34 + rule call_indirect-call {a : addr, ft : functype, func : func, i : nat, m : moduleinst, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [CALL_ADDR_admininstr(a)]) + -- if ($table(z, x)[i] = REF.FUNC_ADDR_ref(a)) + -- if ($funcinst(z)[a] = `%;%`(m, func)) + + ;; 6-reduction.watsup:90.1-92.15 + rule call_indirect-trap {ft : functype, i : nat, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) CALL_INDIRECT_admininstr(x, ft)]), [TRAP_admininstr]) + -- otherwise + + ;; 6-reduction.watsup:94.1-97.52 + rule call_addr {a : addr, f : frame, instr* : instr*, k : nat, m : moduleinst, n : n, t* : valtype*, t_1^k : valtype^k, t_2^n : valtype^n, val^k : val^k, z : state}: + `%~>%*`(`%;%*`(z, (val <: admininstr)^k{val} :: [CALL_ADDR_admininstr(a)]), [FRAME__admininstr(n, f, [LABEL__admininstr(n, [], (instr <: admininstr)*{instr})])]) + -- if ($funcinst(z)[a] = `%;%`(m, `FUNC%%*%`(`%->%`(t_1^k{t_1}, t_2^n{t_2}), t*{t}, instr*{instr}))) + -- if (f = {LOCAL val^k{val} :: $default_(t)*{t}, MODULE m}) + + ;; 6-reduction.watsup:150.1-151.53 + rule ref.func {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [REF.FUNC_admininstr(x)]), [REF.FUNC_ADDR_admininstr($funcaddr(z)[x])]) + + ;; 6-reduction.watsup:163.1-164.37 + rule local.get {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [LOCAL.GET_admininstr(x)]), [($local(z, x) <: admininstr)]) + + ;; 6-reduction.watsup:173.1-174.39 + rule global.get {x : idx, z : state}: + `%~>%*`(`%;%*`(z, [GLOBAL.GET_admininstr(x)]), [($global(z, x) <: admininstr)]) + + ;; 6-reduction.watsup:180.1-182.28 + rule table.get-trap {i : nat, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) + -- if (i >= |$table(z, x)|) + + ;; 6-reduction.watsup:184.1-186.27 + rule table.get-val {i : nat, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(x)]), [($table(z, x)[i] <: admininstr)]) + -- if (i < |$table(z, x)|) + + ;; 6-reduction.watsup:188.1-190.28 + rule table.set-trap {i : nat, ref : ref, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), [TRAP_admininstr]) + -- if (i >= |$table(z, x)|) + + ;; 6-reduction.watsup:197.1-199.27 + rule table.size {n : n, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [TABLE.SIZE_admininstr(x)]), [CONST_admininstr(I32_numtype, n)]) + -- if (|$table(z, x)| = n) + + ;; 6-reduction.watsup:205.1-206.57 + rule table.grow-fail {n : n, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), [CONST_admininstr(I32_numtype, - 1)]) + + ;; 6-reduction.watsup:209.1-211.34 + rule table.fill-trap {i : nat, n : n, val : val, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [TRAP_admininstr]) + -- if ((i + n) > |$table(z, x)|) + + ;; 6-reduction.watsup:213.1-216.14 + rule table.fill-zero {i : nat, n : n, val : val, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), []) + -- otherwise + -- if (n = 0) + + ;; 6-reduction.watsup:218.1-222.15 + rule table.fill-succ {i : nat, n : n, val : val, x : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (val <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.FILL_admininstr(x)]), [CONST_admininstr(I32_numtype, i) (val <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (i + 1)) (val <: admininstr) CONST_admininstr(I32_numtype, (n - 1)) TABLE.FILL_admininstr(x)]) + -- otherwise + + ;; 6-reduction.watsup:225.1-227.63 + rule table.copy-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [TRAP_admininstr]) + -- if (((i + n) > |$table(z, y)|) \/ ((j + n) > |$table(z, x)|)) + + ;; 6-reduction.watsup:229.1-232.14 + rule table.copy-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), []) + -- otherwise + -- if (n = 0) + + ;; 6-reduction.watsup:234.1-239.15 + rule table.copy-le {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) + -- otherwise + -- if (j <= i) + + ;; 6-reduction.watsup:241.1-245.15 + rule table.copy-gt {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.COPY_admininstr(x, y)]), [CONST_admininstr(I32_numtype, ((j + n) - 1)) CONST_admininstr(I32_numtype, ((i + n) - 1)) TABLE.GET_admininstr(y) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.COPY_admininstr(x, y)]) + -- otherwise + + ;; 6-reduction.watsup:248.1-250.62 + rule table.init-trap {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [TRAP_admininstr]) + -- if (((i + n) > |$elem(z, y)|) \/ ((j + n) > |$table(z, x)|)) + + ;; 6-reduction.watsup:252.1-255.14 + rule table.init-zero {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), []) + -- otherwise + -- if (n = 0) + + ;; 6-reduction.watsup:257.1-261.15 + rule table.init-succ {i : nat, j : nat, n : n, x : idx, y : idx, z : state}: + `%~>%*`(`%;%*`(z, [CONST_admininstr(I32_numtype, j) CONST_admininstr(I32_numtype, i) CONST_admininstr(I32_numtype, n) TABLE.INIT_admininstr(x, y)]), [CONST_admininstr(I32_numtype, j) ($elem(z, y)[i] <: admininstr) TABLE.SET_admininstr(x) CONST_admininstr(I32_numtype, (j + 1)) CONST_admininstr(I32_numtype, (i + 1)) CONST_admininstr(I32_numtype, (n - 1)) TABLE.INIT_admininstr(x, y)]) + -- otherwise + +;; 6-reduction.watsup:3.1-3.63 +relation Step: `%~>%`(config, config) + ;; 6-reduction.watsup:7.1-9.34 + rule pure {instr* : instr*, instr'* : instr*, z : state}: + `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) + -- Step_pure: `%*~>%*`((instr <: admininstr)*{instr}, (instr' <: admininstr)*{instr'}) + + ;; 6-reduction.watsup:11.1-13.37 + rule read {instr* : instr*, instr'* : instr*, z : state}: + `%~>%`(`%;%*`(z, (instr <: admininstr)*{instr}), `%;%*`(z, (instr' <: admininstr)*{instr'})) + -- Step_read: `%~>%*`(`%;%*`(z, (instr <: admininstr)*{instr}), (instr' <: admininstr)*{instr'}) + + ;; 6-reduction.watsup:166.1-167.60 + rule local.set {val : val, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(val <: admininstr) LOCAL.SET_admininstr(x)]), `%;%*`($with_local(z, x, val), [])) + + ;; 6-reduction.watsup:176.1-177.62 + rule global.set {val : val, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(val <: admininstr) GLOBAL.SET_admininstr(x)]), `%;%*`($with_global(z, x, val), [])) + + ;; 6-reduction.watsup:192.1-194.27 + rule table.set-val {i : nat, ref : ref, x : idx, z : state}: + `%~>%`(`%;%*`(z, [CONST_admininstr(I32_numtype, i) (ref <: admininstr) TABLE.GET_admininstr(x)]), `%;%*`($with_table(z, x, i, ref), [])) + -- if (i < |$table(z, x)|) + + ;; 6-reduction.watsup:202.1-203.102 + rule table.grow-succeed {n : n, ref : ref, x : idx, z : state}: + `%~>%`(`%;%*`(z, [(ref <: admininstr) CONST_admininstr(I32_numtype, n) TABLE.GROW_admininstr(x)]), `%;%*`($with_tableext(z, x, ref^n{}), [CONST_admininstr(I32_numtype, |$table(z, x)|)])) + + ;; 6-reduction.watsup:264.1-265.59 + rule elem.drop {x : idx, z : state}: + `%~>%`(`%;%*`(z, [ELEM.DROP_admininstr(x)]), `%;%*`($with_elem(z, x, []), [])) + +== IL Validation... +== Latex Generation... +$$ +\begin{array}{@{}lrrl@{}} +& \mathit{n} &::=& \mathit{nat} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(name)} & \mathit{name} &::=& \mathit{text} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(byte)} & \mathit{byte} &::=& \mathit{nat} \\ +\mbox{(32-bit integer)} & \mathit{u{\scriptstyle32}} &::=& \mathit{nat} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(index)} & \mathit{idx} &::=& \mathit{nat} \\ +\mbox{(function index)} & \mathit{funcidx} &::=& \mathit{idx} \\ +\mbox{(global index)} & \mathit{globalidx} &::=& \mathit{idx} \\ +\mbox{(table index)} & \mathit{tableidx} &::=& \mathit{idx} \\ +\mbox{(memory index)} & \mathit{memidx} &::=& \mathit{idx} \\ +\mbox{(elem index)} & \mathit{elemidx} &::=& \mathit{idx} \\ +\mbox{(data index)} & \mathit{dataidx} &::=& \mathit{idx} \\ +\mbox{(label index)} & \mathit{labelidx} &::=& \mathit{idx} \\ +\mbox{(local index)} & \mathit{localidx} &::=& \mathit{idx} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(number type)} & \mathit{numtype} &::=& \mathsf{i{\scriptstyle32}} ~|~ \mathsf{i{\scriptstyle64}} ~|~ \mathsf{f{\scriptstyle32}} ~|~ \mathsf{f{\scriptstyle64}} \\ +\mbox{(vector type)} & \mathit{vectype} &::=& \mathsf{v{\scriptstyle128}} \\ +\mbox{(reference type)} & \mathit{reftype} &::=& \mathsf{funcref} ~|~ \mathsf{externref} \\ +\mbox{(value type)} & \mathit{valtype} &::=& \mathit{numtype} ~|~ \mathit{vectype} ~|~ \mathit{reftype} ~|~ \mathsf{bot} \\ +& {\mathsf{i}}{\mathit{n}} &::=& \mathsf{i{\scriptstyle32}} ~|~ \mathsf{i{\scriptstyle64}} \\ +& {\mathsf{f}}{\mathit{n}} &::=& \mathsf{f{\scriptstyle32}} ~|~ \mathsf{f{\scriptstyle64}} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(result type)} & \mathit{resulttype} &::=& {\mathit{valtype}^\ast} \\ +\mbox{(limits)} & \mathit{limits} &::=& [\mathit{u{\scriptstyle32}} .. \mathit{u{\scriptstyle32}}] \\ +\mbox{(global type)} & \mathit{globaltype} &::=& {\mathsf{mut}^?}~\mathit{valtype} \\ +\mbox{(function type)} & \mathit{functype} &::=& \mathit{resulttype} \rightarrow \mathit{resulttype} \\ +\mbox{(table type)} & \mathit{tabletype} &::=& \mathit{limits}~\mathit{reftype} \\ +\mbox{(memory type)} & \mathit{memtype} &::=& \mathit{limits}~\mathsf{i{\scriptstyle8}} \\ +\mbox{(element type)} & \mathit{elemtype} &::=& \mathit{reftype} \\ +\mbox{(data type)} & \mathit{datatype} &::=& \mathsf{ok} \\ +\mbox{(external type)} & \mathit{externtype} &::=& \mathsf{global}~\mathit{globaltype} ~|~ \mathsf{func}~\mathit{functype} ~|~ \mathsf{table}~\mathit{tabletype} ~|~ \mathsf{memory}~\mathit{memtype} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(signedness)} & \mathit{sx} &::=& \mathsf{u} ~|~ \mathsf{s} \\ +& \mathit{unop}_{\mathsf{ixx}} &::=& \mathsf{clz} ~|~ \mathsf{ctz} ~|~ \mathsf{popcnt} \\ +& \mathit{unop}_{\mathsf{fxx}} &::=& \mathsf{abs} ~|~ \mathsf{neg} ~|~ \mathsf{sqrt} ~|~ \mathsf{ceil} ~|~ \mathsf{floor} ~|~ \mathsf{trunc} ~|~ \mathsf{nearest} \\ +& \mathit{binop}_{\mathsf{ixx}} &::=& \mathsf{add} ~|~ \mathsf{sub} ~|~ \mathsf{mul} ~|~ {\mathsf{div\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{rem\_}}{\mathsf{\mathit{sx}}} \\ &&|& +\mathsf{and} ~|~ \mathsf{or} ~|~ \mathsf{xor} ~|~ \mathsf{shl} ~|~ {\mathsf{shr\_}}{\mathsf{\mathit{sx}}} ~|~ \mathsf{rotl} ~|~ \mathsf{rotr} \\ +& \mathit{binop}_{\mathsf{fxx}} &::=& \mathsf{add} ~|~ \mathsf{sub} ~|~ \mathsf{mul} ~|~ \mathsf{div} ~|~ \mathsf{min} ~|~ \mathsf{max} ~|~ \mathsf{copysign} \\ +& \mathit{testop}_{\mathsf{ixx}} &::=& \mathsf{eqz} \\ +& \mathit{testop}_{\mathsf{fxx}} &::=& \\ +& \mathit{relop}_{\mathsf{ixx}} &::=& \mathsf{eq} ~|~ \mathsf{ne} ~|~ {\mathsf{lt\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{gt\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{le\_}}{\mathsf{\mathit{sx}}} ~|~ {\mathsf{ge\_}}{\mathsf{\mathit{sx}}} \\ +& \mathit{relop}_{\mathsf{fxx}} &::=& \mathsf{eq} ~|~ \mathsf{ne} ~|~ \mathsf{lt} ~|~ \mathsf{gt} ~|~ \mathsf{le} ~|~ \mathsf{ge} \\ +& \mathit{unop}_{\mathit{numtype}} &::=& \mathit{unop}_{\mathsf{ixx}} ~|~ \mathit{unop}_{\mathsf{fxx}} \\ +& \mathit{binop}_{\mathit{numtype}} &::=& \mathit{binop}_{\mathsf{ixx}} ~|~ \mathit{binop}_{\mathsf{fxx}} \\ +& \mathit{testop}_{\mathit{numtype}} &::=& \mathit{testop}_{\mathsf{ixx}} ~|~ \mathit{testop}_{\mathsf{fxx}} \\ +& \mathit{relop}_{\mathit{numtype}} &::=& \mathit{relop}_{\mathsf{ixx}} ~|~ \mathit{relop}_{\mathsf{fxx}} \\ +& \mathit{cvtop} &::=& \mathsf{convert} ~|~ \mathsf{reinterpret} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +& \mathit{c}_{\mathit{numtype}} &::=& \mathit{nat} \\ +& \mathit{c}_{\mathit{vectype}} &::=& \mathit{nat} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(block type)} & \mathit{blocktype} &::=& \mathit{functype} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lrrl@{}} +& \mathit{instr} &::=& \mathsf{unreachable} \\ &&|& +\mathsf{nop} \\ &&|& +\mathsf{drop} \\ &&|& +\mathsf{select}~{\mathit{valtype}^?} \\ &&|& +\mathsf{block}~\mathit{blocktype}~{\mathit{instr}^\ast} \\ &&|& +\mathsf{loop}~\mathit{blocktype}~{\mathit{instr}^\ast} \\ &&|& +\mathsf{if}~\mathit{blocktype}~{\mathit{instr}^\ast}~\mathsf{else}~{\mathit{instr}^\ast} \\ &&|& +\mathsf{br}~\mathit{labelidx} \\ &&|& +\mathsf{br\_if}~\mathit{labelidx} \\ &&|& +\mathsf{br\_table}~{\mathit{labelidx}^\ast}~\mathit{labelidx} \\ &&|& +\mathsf{call}~\mathit{funcidx} \\ &&|& +\mathsf{call\_indirect}~\mathit{tableidx}~\mathit{functype} \\ &&|& +\mathsf{return} \\ &&|& +\mathsf{\mathit{numtype}}.\mathsf{const}~\mathsf{\mathit{c}\_{\mathit{numtype}}} \\ &&|& +\mathsf{\mathit{numtype}} . \mathsf{\mathit{unop}\_{\mathit{numtype}}} \\ &&|& +\mathsf{\mathit{numtype}} . \mathsf{\mathit{binop}\_{\mathit{numtype}}} \\ &&|& +\mathsf{\mathit{numtype}} . \mathsf{\mathit{testop}\_{\mathit{numtype}}} \\ &&|& +\mathsf{\mathit{numtype}} . \mathsf{\mathit{relop}\_{\mathit{numtype}}} \\ &&|& +{\mathsf{\mathit{numtype}}.\mathsf{extend}}{\mathsf{\mathit{n}}} \\ &&|& +\mathsf{\mathit{numtype}} . {{{{\mathsf{\mathit{cvtop}}}{\mathsf{\_}}}{\mathsf{\mathit{numtype}}}}{\mathsf{\_}}}{\mathsf{{\mathit{sx}^?}}} \\ &&|& +\mathsf{ref.null}~\mathit{reftype} \\ &&|& +\mathsf{ref.func}~\mathit{funcidx} \\ &&|& +\mathsf{ref.is\_null} \\ &&|& +\mathsf{local.get}~\mathit{localidx} \\ &&|& +\mathsf{local.set}~\mathit{localidx} \\ &&|& +\mathsf{local.tee}~\mathit{localidx} \\ &&|& +\mathsf{global.get}~\mathit{globalidx} \\ &&|& +\mathsf{global.set}~\mathit{globalidx} \\ &&|& +\mathsf{table.get}~\mathit{tableidx} \\ &&|& +\mathsf{table.set}~\mathit{tableidx} \\ &&|& +\mathsf{table.size}~\mathit{tableidx} \\ &&|& +\mathsf{table.grow}~\mathit{tableidx} \\ &&|& +\mathsf{table.fill}~\mathit{tableidx} \\ &&|& +\mathsf{table.copy}~\mathit{tableidx}~\mathit{tableidx} \\ &&|& +\mathsf{table.init}~\mathit{tableidx}~\mathit{elemidx} \\ &&|& +\mathsf{elem.drop}~\mathit{elemidx} \\ &&|& +\mathsf{memory.size} \\ &&|& +\mathsf{memory.grow} \\ &&|& +\mathsf{memory.fill} \\ &&|& +\mathsf{memory.copy} \\ &&|& +\mathsf{memory.init}~\mathit{dataidx} \\ &&|& +\mathsf{data.drop}~\mathit{dataidx} \\ &&|& +{\mathsf{\mathit{numtype}}.\mathsf{load}}{\mathsf{{(\mathit{n}~\mathit{sx})^?}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& +{\mathsf{\mathit{numtype}}.\mathsf{store}}{\mathsf{{\mathit{n}^?}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ +\mbox{(expression)} & \mathit{expr} &::=& {\mathit{instr}^\ast} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +& \mathit{elemmode} &::=& \mathsf{table}~\mathit{tableidx}~\mathit{expr} ~|~ \mathsf{declare} \\ +& \mathit{datamode} &::=& \mathsf{memory}~\mathit{memidx}~\mathit{expr} \\ +\mbox{(function)} & \mathit{func} &::=& \mathsf{func}~\mathit{functype}~{\mathit{valtype}^\ast}~\mathit{expr} \\ +\mbox{(global)} & \mathit{global} &::=& \mathsf{global}~\mathit{globaltype}~\mathit{expr} \\ +\mbox{(table)} & \mathit{table} &::=& \mathsf{table}~\mathit{tabletype} \\ +\mbox{(memory)} & \mathit{mem} &::=& \mathsf{memory}~\mathit{memtype} \\ +\mbox{(table segment)} & \mathit{elem} &::=& \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~{\mathit{elemmode}^?} \\ +\mbox{(memory segment)} & \mathit{data} &::=& \mathsf{data}~{({\mathit{byte}^\ast})^\ast}~{\mathit{datamode}^?} \\ +\mbox{(start function)} & \mathit{start} &::=& \mathsf{start}~\mathit{funcidx} \\ +\mbox{(external use)} & \mathit{externuse} &::=& \mathsf{func}~\mathit{funcidx} ~|~ \mathsf{global}~\mathit{globalidx} ~|~ \mathsf{table}~\mathit{tableidx} ~|~ \mathsf{memory}~\mathit{memidx} \\ +\mbox{(export)} & \mathit{export} &::=& \mathsf{export}~\mathit{name}~\mathit{externuse} \\ +\mbox{(import)} & \mathit{import} &::=& \mathsf{import}~\mathit{name}~\mathit{name}~\mathit{externtype} \\ +\mbox{(module)} & \mathit{module} &::=& \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{start}^\ast}~{\mathit{export}^\ast} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{|\mathsf{i{\scriptstyle32}}|} &=& 32 & \\ +{|\mathsf{i{\scriptstyle64}}|} &=& 64 & \\ +{|\mathsf{f{\scriptstyle32}}|} &=& 32 & \\ +{|\mathsf{f{\scriptstyle64}}|} &=& 64 & \\ +{|\mathsf{v{\scriptstyle128}}|} &=& 128 & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{test}_{\mathit{sub}_{\mathsf{atom}_{22}}}(\mathit{n}_{3_{\mathsf{atom}_{\mathit{y}}}}) &=& 0 & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{\mathrm{curried}}_{\mathit{n}_{1}}(\mathit{n}_{2}) &=& \mathit{n}_{1} + \mathit{n}_{2} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lrrl@{}} +& \mathit{testfuse} &::=& {\mathsf{ab}}_{\mathit{nat}}\,\,\mathit{nat}~\mathit{nat} \\ &&|& +{\mathsf{cd}}_{\mathsf{\mathit{nat}}}\,\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}} \\ &&|& +{\mathsf{ef\_}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& +{{\mathsf{gh}}_{\mathsf{\mathit{nat}}}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& +{{\mathsf{ij}}_{\mathsf{\mathit{nat}}}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& +{\mathsf{kl\_ab}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& +{\mathsf{mn\_}}{\mathsf{ab}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& +{{\mathsf{op\_}}{\mathsf{ab}}}{\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ &&|& +{{\mathsf{qr}}_{\mathsf{\mathit{nat}}}}{\mathsf{ab}~\mathsf{\mathit{nat}}~\mathsf{\mathit{nat}}} \\ +\mbox{(context)} & \mathit{context} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{func}~{\mathit{functype}^\ast},\; \mathsf{global}~{\mathit{globaltype}^\ast},\; \mathsf{table}~{\mathit{tabletype}^\ast},\; \mathsf{mem}~{\mathit{memtype}^\ast},\; \\ + \mathsf{elem}~{\mathit{elemtype}^\ast},\; \mathsf{data}~{\mathit{datatype}^\ast},\; \\ + \mathsf{local}~{\mathit{valtype}^\ast},\; \mathsf{label}~{\mathit{resulttype}^\ast},\; \mathsf{return}~{\mathit{resulttype}^?} \;\}\end{array} \\ +\end{array} +$$ + +\vspace{1ex} + +$\boxed{{ \vdash }\;\mathit{limits} : \mathit{nat}}$ + +$\boxed{{ \vdash }\;\mathit{functype} : \mathsf{ok}}$ + +$\boxed{{ \vdash }\;\mathit{globaltype} : \mathsf{ok}}$ + +$\boxed{{ \vdash }\;\mathit{tabletype} : \mathsf{ok}}$ + +$\boxed{{ \vdash }\;\mathit{memtype} : \mathsf{ok}}$ + +$\boxed{{ \vdash }\;\mathit{externtype} : \mathsf{ok}}$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{n}_{1} \leq \mathit{n}_{2} \leq \mathit{k} +}{ +{ \vdash }\;[\mathit{n}_{1} .. \mathit{n}_{2}] : \mathit{k} +} \, {[\textsc{\scriptsize K{-}limits}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +{ \vdash }\;\mathit{ft} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +{ \vdash }\;\mathit{gt} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}global}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{lim} : {2^{32}} - 1 +}{ +{ \vdash }\;\mathit{lim}~\mathit{rt} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}table}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{lim} : {2^{16}} +}{ +{ \vdash }\;\mathit{lim}~\mathsf{i{\scriptstyle8}} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}mem}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{functype} : \mathsf{ok} +}{ +{ \vdash }\;\mathsf{func}~\mathit{functype} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}extern{-}func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{globaltype} : \mathsf{ok} +}{ +{ \vdash }\;\mathsf{global}~\mathit{globaltype} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}extern{-}global}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{tabletype} : \mathsf{ok} +}{ +{ \vdash }\;\mathsf{table}~\mathit{tabletype} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}extern{-}table}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{memtype} : \mathsf{ok} +}{ +{ \vdash }\;\mathsf{memory}~\mathit{memtype} : \mathsf{ok} +} \, {[\textsc{\scriptsize K{-}extern{-}mem}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{{ \vdash }\;\mathit{valtype} \leq \mathit{valtype}}$ + +$\boxed{{ \vdash }\;{\mathit{valtype}^\ast} \leq {\mathit{valtype}^\ast}}$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +{ \vdash }\;\mathit{t} \leq \mathit{t} +} \, {[\textsc{\scriptsize S{-}refl}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +{ \vdash }\;\mathsf{bot} \leq \mathit{t} +} \, {[\textsc{\scriptsize S{-}bot}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +({ \vdash }\;\mathit{t}_{1} \leq \mathit{t}_{2})^\ast +}{ +{ \vdash }\;{\mathit{t}_{1}^\ast} \leq {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize S{-}result}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{{ \vdash }\;\mathit{limits} \leq \mathit{limits}}$ + +$\boxed{{ \vdash }\;\mathit{functype} \leq \mathit{functype}}$ + +$\boxed{{ \vdash }\;\mathit{globaltype} \leq \mathit{globaltype}}$ + +$\boxed{{ \vdash }\;\mathit{tabletype} \leq \mathit{tabletype}}$ + +$\boxed{{ \vdash }\;\mathit{memtype} \leq \mathit{memtype}}$ + +$\boxed{{ \vdash }\;\mathit{externtype} \leq \mathit{externtype}}$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{n}_{11} \geq \mathit{n}_{21} + \qquad +\mathit{n}_{12} \leq \mathit{n}_{22} +}{ +{ \vdash }\;[\mathit{n}_{11} .. \mathit{n}_{12}] \leq [\mathit{n}_{21} .. \mathit{n}_{22}] +} \, {[\textsc{\scriptsize S{-}limits}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +{ \vdash }\;\mathit{ft} \leq \mathit{ft} +} \, {[\textsc{\scriptsize S{-}func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +{ \vdash }\;\mathit{gt} \leq \mathit{gt} +} \, {[\textsc{\scriptsize S{-}global}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{lim}_{1} \leq \mathit{lim}_{2} +}{ +{ \vdash }\;\mathit{lim}_{1}~\mathit{rt} \leq \mathit{lim}_{2}~\mathit{rt} +} \, {[\textsc{\scriptsize S{-}table}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{lim}_{1} \leq \mathit{lim}_{2} +}{ +{ \vdash }\;\mathit{lim}_{1}~\mathsf{i{\scriptstyle8}} \leq \mathit{lim}_{2}~\mathsf{i{\scriptstyle8}} +} \, {[\textsc{\scriptsize S{-}mem}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{ft}_{1} \leq \mathit{ft}_{2} +}{ +{ \vdash }\;\mathsf{func}~\mathit{ft}_{1} \leq \mathsf{func}~\mathit{ft}_{2} +} \, {[\textsc{\scriptsize S{-}extern{-}func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{gt}_{1} \leq \mathit{gt}_{2} +}{ +{ \vdash }\;\mathsf{global}~\mathit{gt}_{1} \leq \mathsf{global}~\mathit{gt}_{2} +} \, {[\textsc{\scriptsize S{-}extern{-}global}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{tt}_{1} \leq \mathit{tt}_{2} +}{ +{ \vdash }\;\mathsf{table}~\mathit{tt}_{1} \leq \mathsf{table}~\mathit{tt}_{2} +} \, {[\textsc{\scriptsize S{-}extern{-}table}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{mt}_{1} \leq \mathit{mt}_{2} +}{ +{ \vdash }\;\mathsf{memory}~\mathit{mt}_{1} \leq \mathsf{memory}~\mathit{mt}_{2} +} \, {[\textsc{\scriptsize S{-}extern{-}mem}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{\mathit{context} \vdash \mathit{instr} : \mathit{functype}}$ + +$\boxed{\mathit{context} \vdash {\mathit{instr}^\ast} : \mathit{functype}}$ + +$\boxed{\mathit{context} \vdash \mathit{expr} : \mathit{resulttype}}$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash {\mathit{instr}^\ast} : \epsilon \rightarrow {\mathit{t}^\ast} +}{ +\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}^\ast} +} \, {[\textsc{\scriptsize T{-}expr}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \epsilon : \epsilon \rightarrow \epsilon +} \, {[\textsc{\scriptsize T*{-}empty}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash \mathit{instr}_{1} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} + \qquad +\mathit{C} \vdash \mathit{instr}_{2} : {\mathit{t}_{2}^\ast} \rightarrow {\mathit{t}_{3}^\ast} +}{ +\mathit{C} \vdash \mathit{instr}_{1}~{\mathit{instr}_{2}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{3}^\ast} +} \, {[\textsc{\scriptsize T*{-}seq}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\begin{array}{@{}c@{}} +\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} + \\ +{ \vdash }\;{{\mathit{t}'}_{1}^\ast} \leq {\mathit{t}_{1}^\ast} + \qquad +{ \vdash }\;{\mathit{t}_{2}^\ast} \leq {{\mathit{t}'}_{2}^\ast} +\end{array} +}{ +\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}'}_{1} \rightarrow {{\mathit{t}'}_{2}^\ast} +} \, {[\textsc{\scriptsize T*{-}weak}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +}{ +\mathit{C} \vdash {\mathit{instr}^\ast} : {\mathit{t}^\ast}~{\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}^\ast}~{\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T*{-}frame}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathsf{unreachable} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}unreachable}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathsf{nop} : \epsilon \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}nop}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathsf{drop} : \mathit{t} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}drop}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathsf{select}~\mathit{t} : \mathit{t}~\mathit{t}~\mathsf{i{\scriptstyle32}} \rightarrow \mathit{t} +} \, {[\textsc{\scriptsize T{-}select{-}expl}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{t} \leq {\mathit{t}'} + \qquad +{\mathit{t}'} = \mathit{numtype} \lor {\mathit{t}'} = \mathit{vectype} +}{ +\mathit{C} \vdash \mathsf{select} : \mathit{t}~\mathit{t}~\mathsf{i{\scriptstyle32}} \rightarrow \mathit{t} +} \, {[\textsc{\scriptsize T{-}select{-}impl}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{\mathit{context} \vdash \mathit{blocktype} : \mathit{functype}}$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{ft} : \mathsf{ok} +}{ +\mathit{C} \vdash \mathit{ft} : \mathit{ft} +} \, {[\textsc{\scriptsize K{-}block}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash \mathit{bt} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} + \qquad +\mathit{C}, \mathsf{label}~{\mathit{t}_{2}^\ast} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +}{ +\mathit{C} \vdash \mathsf{block}~\mathit{bt}~{\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}block}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash \mathit{bt} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} + \qquad +\mathit{C}, \mathsf{label}~{\mathit{t}_{1}^\ast} \vdash {\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +}{ +\mathit{C} \vdash \mathsf{loop}~\mathit{bt}~{\mathit{instr}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}loop}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash \mathit{bt} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} + \qquad +\mathit{C}, \mathsf{label}~{\mathit{t}_{2}^\ast} \vdash {\mathit{instr}_{1}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} + \qquad +\mathit{C}, \mathsf{label}~{\mathit{t}_{2}^\ast} \vdash {\mathit{instr}_{2}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +}{ +\mathit{C} \vdash \mathsf{if}~\mathit{bt}~{\mathit{instr}_{1}^\ast}~\mathsf{else}~{\mathit{instr}_{2}^\ast} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}if}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{label}[\mathit{l}] = {\mathit{t}^\ast} +}{ +\mathit{C} \vdash \mathsf{br}~\mathit{l} : {\mathit{t}_{1}^\ast}~{\mathit{t}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}br}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{label}[\mathit{l}] = {\mathit{t}^\ast} +}{ +\mathit{C} \vdash \mathsf{br\_if}~\mathit{l} : {\mathit{t}^\ast}~\mathsf{i{\scriptstyle32}} \rightarrow {\mathit{t}^\ast} +} \, {[\textsc{\scriptsize T{-}br\_if}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +({ \vdash }\;{\mathit{t}^\ast} \leq \mathit{C}.\mathsf{label}[\mathit{l}])^\ast + \qquad +{ \vdash }\;{\mathit{t}^\ast} \leq \mathit{C}.\mathsf{label}[{\mathit{l}'}] +}{ +\mathit{C} \vdash \mathsf{br\_table}~{\mathit{l}^\ast}~{\mathit{l}'} : {\mathit{t}_{1}^\ast}~{\mathit{t}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}br\_table}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{return} = ({\mathit{t}^\ast}) +}{ +\mathit{C} \vdash \mathsf{return} : {\mathit{t}_{1}^\ast}~{\mathit{t}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}return}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{func}[\mathit{x}] = {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +}{ +\mathit{C} \vdash \mathsf{call}~\mathit{x} : {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}call}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathsf{funcref} + \qquad +\mathit{ft} = {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} +}{ +\mathit{C} \vdash \mathsf{call\_indirect}~\mathit{x}~\mathit{ft} : {\mathit{t}_{1}^\ast}~\mathsf{i{\scriptstyle32}} \rightarrow {\mathit{t}_{2}^\ast} +} \, {[\textsc{\scriptsize T{-}call\_indirect}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathit{nt}.\mathsf{const}~\mathit{c}_{\mathit{nt}} : \epsilon \rightarrow \mathit{nt} +} \, {[\textsc{\scriptsize T{-}const}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathit{nt} . \mathit{unop} : \mathit{nt} \rightarrow \mathit{nt} +} \, {[\textsc{\scriptsize T{-}unop}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathit{nt} . \mathit{binop} : \mathit{nt}~\mathit{nt} \rightarrow \mathit{nt} +} \, {[\textsc{\scriptsize T{-}binop}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathit{nt} . \mathit{testop} : \mathit{nt} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}testop}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathit{nt} . \mathit{relop} : \mathit{nt}~\mathit{nt} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}relop}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{n} \leq {|\mathit{nt}|} +}{ +\mathit{C} \vdash {\mathit{nt}.\mathsf{extend}}{\mathit{n}} : \mathit{nt} \rightarrow \mathit{nt} +} \, {[\textsc{\scriptsize T{-}extend}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{nt}_{1} \neq \mathit{nt}_{2} + \qquad +{|\mathit{nt}_{1}|} = {|\mathit{nt}_{2}|} +}{ +\mathit{C} \vdash \mathsf{cvtop}~\mathit{nt}_{1}~\mathsf{reinterpret}~\mathit{nt}_{2} : \mathit{nt}_{2} \rightarrow \mathit{nt}_{1} +} \, {[\textsc{\scriptsize T{-}reinterpret}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{\mathsf{i}}{\mathit{n}}_{1} \neq {\mathsf{i}}{\mathit{n}}_{2} + \qquad +{\mathit{sx}^?} = \epsilon \Leftrightarrow {|{\mathsf{i}}{\mathit{n}}_{1}|} > {|{\mathsf{i}}{\mathit{n}}_{2}|} +}{ +\mathit{C} \vdash {\mathsf{i}}{\mathit{n}}_{1} . {{{{\mathsf{convert}}{\mathsf{\_}}}{{\mathsf{i}}{\mathit{n}}_{2}}}{\mathsf{\_}}}{{\mathit{sx}^?}} : {\mathsf{i}}{\mathit{n}}_{2} \rightarrow {\mathsf{i}}{\mathit{n}}_{1} +} \, {[\textsc{\scriptsize T{-}convert{-}i}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{\mathsf{f}}{\mathit{n}}_{1} \neq {\mathsf{f}}{\mathit{n}}_{2} +}{ +\mathit{C} \vdash \mathsf{cvtop}~{\mathsf{f}}{\mathit{n}}_{1}~\mathsf{convert}~{\mathsf{f}}{\mathit{n}}_{2} : {\mathsf{f}}{\mathit{n}}_{2} \rightarrow {\mathsf{f}}{\mathit{n}}_{1} +} \, {[\textsc{\scriptsize T{-}convert{-}f}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathsf{ref.null}~\mathit{rt} : \epsilon \rightarrow \mathit{rt} +} \, {[\textsc{\scriptsize T{-}ref.null}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{func}[\mathit{x}] = \mathit{ft} +}{ +\mathit{C} \vdash \mathsf{ref.func}~\mathit{x} : \epsilon \rightarrow \mathsf{funcref} +} \, {[\textsc{\scriptsize T{-}ref.func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathsf{ref.is\_null} : \mathit{rt} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}ref.is\_null}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{local}[\mathit{x}] = \mathit{t} +}{ +\mathit{C} \vdash \mathsf{local.get}~\mathit{x} : \epsilon \rightarrow \mathit{t} +} \, {[\textsc{\scriptsize T{-}local.get}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{local}[\mathit{x}] = \mathit{t} +}{ +\mathit{C} \vdash \mathsf{local.set}~\mathit{x} : \mathit{t} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}local.set}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{local}[\mathit{x}] = \mathit{t} +}{ +\mathit{C} \vdash \mathsf{local.tee}~\mathit{x} : \mathit{t} \rightarrow \mathit{t} +} \, {[\textsc{\scriptsize T{-}local.tee}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{global}[\mathit{x}] = {\mathsf{mut}^?}~\mathit{t} +}{ +\mathit{C} \vdash \mathsf{global.get}~\mathit{x} : \epsilon \rightarrow \mathit{t} +} \, {[\textsc{\scriptsize T{-}global.get}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{global}[\mathit{x}] = \mathsf{mut}~\mathit{t} +}{ +\mathit{C} \vdash \mathsf{global.set}~\mathit{x} : \mathit{t} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}global.set}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} +}{ +\mathit{C} \vdash \mathsf{table.get}~\mathit{x} : \mathsf{i{\scriptstyle32}} \rightarrow \mathit{rt} +} \, {[\textsc{\scriptsize T{-}table.get}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} +}{ +\mathit{C} \vdash \mathsf{table.set}~\mathit{x} : \mathsf{i{\scriptstyle32}}~\mathit{rt} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}table.set}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{tt} +}{ +\mathit{C} \vdash \mathsf{table.size}~\mathit{x} : \epsilon \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}table.size}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} +}{ +\mathit{C} \vdash \mathsf{table.grow}~\mathit{x} : \mathit{rt}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}table.grow}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} +}{ +\mathit{C} \vdash \mathsf{table.fill}~\mathit{x} : \mathsf{i{\scriptstyle32}}~\mathit{rt}~\mathsf{i{\scriptstyle32}} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}table.fill}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}_{1}] = \mathit{lim}_{1}~\mathit{rt} + \qquad +\mathit{C}.\mathsf{table}[\mathit{x}_{2}] = \mathit{lim}_{2}~\mathit{rt} +}{ +\mathit{C} \vdash \mathsf{table.copy}~\mathit{x}_{1}~\mathit{x}_{2} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}table.copy}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}_{1}] = \mathit{lim}~\mathit{rt} + \qquad +\mathit{C}.\mathsf{elem}[\mathit{x}_{2}] = \mathit{rt} +}{ +\mathit{C} \vdash \mathsf{table.init}~\mathit{x}_{1}~\mathit{x}_{2} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}table.init}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{elem}[\mathit{x}] = \mathit{rt} +}{ +\mathit{C} \vdash \mathsf{elem.drop}~\mathit{x} : \epsilon \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}elem.drop}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} +}{ +\mathit{C} \vdash \mathsf{memory.size} : \epsilon \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}memory.size}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} +}{ +\mathit{C} \vdash \mathsf{memory.grow} : \mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}memory.grow}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} +}{ +\mathit{C} \vdash \mathsf{memory.fill} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}memory.fill}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} +}{ +\mathit{C} \vdash \mathsf{memory.copy} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}memory.copy}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} + \qquad +\mathit{C}.\mathsf{data}[\mathit{x}] = \mathsf{ok} +}{ +\mathit{C} \vdash \mathsf{memory.init}~\mathit{x} : \mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}}~\mathsf{i{\scriptstyle32}} \rightarrow \mathsf{i{\scriptstyle32}} +} \, {[\textsc{\scriptsize T{-}memory.init}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{data}[\mathit{x}] = \mathsf{ok} +}{ +\mathit{C} \vdash \mathsf{data.drop}~\mathit{x} : \epsilon \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}data.drop}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} + \qquad +{2^{\mathit{n}_{\mathsf{a}}}} \leq {|\mathit{nt}|} / 8 + \qquad +({2^{\mathit{n}_{\mathsf{a}}}} \leq \mathit{n} / 8 < {|\mathit{nt}|} / 8)^? + \qquad +{\mathit{n}^?} = \epsilon \lor \mathit{nt} = {\mathsf{i}}{\mathit{n}} +}{ +\mathit{C} \vdash {\mathit{nt}.\mathsf{load}}{{(\mathit{n}~\mathit{sx})^?}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}} : \mathsf{i{\scriptstyle32}} \rightarrow \mathit{nt} +} \, {[\textsc{\scriptsize T{-}load}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} + \qquad +{2^{\mathit{n}_{\mathsf{a}}}} \leq {|\mathit{nt}|} / 8 + \qquad +({2^{\mathit{n}_{\mathsf{a}}}} \leq \mathit{n} / 8 < {|\mathit{nt}|} / 8)^? + \qquad +{\mathit{n}^?} = \epsilon \lor \mathit{nt} = {\mathsf{i}}{\mathit{n}} +}{ +\mathit{C} \vdash {\mathit{nt}.\mathsf{store}}{{\mathit{n}^?}~\mathit{n}_{\mathsf{a}}~\mathit{n}_{\mathsf{o}}} : \mathsf{i{\scriptstyle32}}~\mathit{nt} \rightarrow \epsilon +} \, {[\textsc{\scriptsize T{-}store}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{\mathit{context} \vdash \mathit{instr}~\mathsf{const}}$ + +$\boxed{\mathit{context} \vdash \mathit{expr}~\mathsf{const}}$ + +$\boxed{\mathit{context} \vdash \mathit{expr} : \mathit{valtype}~\mathsf{const}}$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash (\mathit{nt}.\mathsf{const}~\mathit{c})~\mathsf{const} +} \, {[\textsc{\scriptsize C{-}instr{-}const}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash (\mathsf{ref.null}~\mathit{rt})~\mathsf{const} +} \, {[\textsc{\scriptsize C{-}instr{-}ref.null}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash (\mathsf{ref.func}~\mathit{x})~\mathsf{const} +} \, {[\textsc{\scriptsize C{-}instr{-}ref.func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{global}[\mathit{x}] = \epsilon~\mathit{t} +}{ +\mathit{C} \vdash (\mathsf{global.get}~\mathit{x})~\mathsf{const} +} \, {[\textsc{\scriptsize C{-}instr{-}global.get}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +(\mathit{C} \vdash \mathit{instr}~\mathsf{const})^\ast +}{ +\mathit{C} \vdash {\mathit{instr}^\ast}~\mathsf{const} +} \, {[\textsc{\scriptsize C{-}expr}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash \mathit{expr} : \mathit{t} + \qquad +\mathit{C} \vdash \mathit{expr}~\mathsf{const} +}{ +\mathit{C} \vdash \mathit{expr} : \mathit{t}~\mathsf{const} +} \, {[\textsc{\scriptsize TC{-}expr}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{\mathit{context} \vdash \mathit{func} : \mathit{functype}}$ + +$\boxed{\mathit{context} \vdash \mathit{global} : \mathit{globaltype}}$ + +$\boxed{\mathit{context} \vdash \mathit{table} : \mathit{tabletype}}$ + +$\boxed{\mathit{context} \vdash \mathit{mem} : \mathit{memtype}}$ + +$\boxed{\mathit{context} \vdash \mathit{elem} : \mathit{reftype}}$ + +$\boxed{\mathit{context} \vdash \mathit{data} : \mathsf{ok}}$ + +$\boxed{\mathit{context} \vdash \mathit{elemmode} : \mathit{reftype}}$ + +$\boxed{\mathit{context} \vdash \mathit{datamode} : \mathsf{ok}}$ + +$\boxed{\mathit{context} \vdash \mathit{start} : \mathsf{ok}}$ + +\vspace{1ex} + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{ft} = {\mathit{t}_{1}^\ast} \rightarrow {\mathit{t}_{2}^\ast} + \qquad +{ \vdash }\;\mathit{ft} : \mathsf{ok} + \qquad +\mathit{C}, \mathsf{local}~{\mathit{t}_{1}^\ast}~{\mathit{t}^\ast}, \mathsf{label}~({\mathit{t}_{2}^\ast}), \mathsf{return}~({\mathit{t}_{2}^\ast}) \vdash \mathit{expr} : {\mathit{t}_{2}^\ast} +}{ +\mathit{C} \vdash \mathsf{func}~\mathit{ft}~{\mathit{t}^\ast}~\mathit{expr} : \mathit{ft} +} \, {[\textsc{\scriptsize T{-}func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{gt} : \mathsf{ok} + \qquad +\mathit{gt} = {\mathsf{mut}^?}~\mathit{t} + \qquad +\mathit{C} \vdash \mathit{expr} : \mathit{t}~\mathsf{const} +}{ +\mathit{C} \vdash \mathsf{global}~\mathit{gt}~\mathit{expr} : \mathit{gt} +} \, {[\textsc{\scriptsize T{-}global}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{tt} : \mathsf{ok} +}{ +\mathit{C} \vdash \mathsf{table}~\mathit{tt} : \mathit{tt} +} \, {[\textsc{\scriptsize T{-}table}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{mt} : \mathsf{ok} +}{ +\mathit{C} \vdash \mathsf{memory}~\mathit{mt} : \mathit{mt} +} \, {[\textsc{\scriptsize T{-}mem}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +(\mathit{C} \vdash \mathit{expr} : \mathit{rt})^\ast + \qquad +(\mathit{C} \vdash \mathit{elemmode} : \mathit{rt})^? +}{ +\mathit{C} \vdash \mathsf{elem}~\mathit{rt}~{\mathit{expr}^\ast}~{\mathit{elemmode}^?} : \mathit{rt} +} \, {[\textsc{\scriptsize T{-}elem}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +(\mathit{C} \vdash \mathit{datamode} : \mathsf{ok})^? +}{ +\mathit{C} \vdash \mathsf{data}~{({\mathit{b}^\ast})^\ast}~{\mathit{datamode}^?} : \mathsf{ok} +} \, {[\textsc{\scriptsize T{-}data}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{lim}~\mathit{rt} + \qquad +(\mathit{C} \vdash \mathit{expr} : \mathsf{i{\scriptstyle32}}~\mathsf{const})^\ast +}{ +\mathit{C} \vdash \mathsf{table}~\mathit{x}~\mathit{expr} : \mathit{rt} +} \, {[\textsc{\scriptsize T{-}elemmode{-}active}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +}{ +\mathit{C} \vdash \mathsf{declare} : \mathit{rt} +} \, {[\textsc{\scriptsize T{-}elemmode{-}declare}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[0] = \mathit{mt} + \qquad +(\mathit{C} \vdash \mathit{expr} : \mathsf{i{\scriptstyle32}}~\mathsf{const})^\ast +}{ +\mathit{C} \vdash \mathsf{memory}~0~\mathit{expr} : \mathsf{ok} +} \, {[\textsc{\scriptsize T{-}datamode}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{func}[\mathit{x}] = \epsilon \rightarrow \epsilon +}{ +\mathit{C} \vdash \mathsf{start}~\mathit{x} : \mathsf{ok} +} \, {[\textsc{\scriptsize T{-}start}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{\mathit{context} \vdash \mathit{import} : \mathit{externtype}}$ + +$\boxed{\mathit{context} \vdash \mathit{export} : \mathit{externtype}}$ + +$\boxed{\mathit{context} \vdash \mathit{externuse} : \mathit{externtype}}$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +{ \vdash }\;\mathit{xt} : \mathsf{ok} +}{ +\mathit{C} \vdash \mathsf{import}~\mathit{name}_{1}~\mathit{name}_{2}~\mathit{xt} : \mathit{xt} +} \, {[\textsc{\scriptsize T{-}import}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C} \vdash \mathit{externuse} : \mathit{xt} +}{ +\mathit{C} \vdash \mathsf{export}~\mathit{name}~\mathit{externuse} : \mathit{xt} +} \, {[\textsc{\scriptsize T{-}export}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{func}[\mathit{x}] = \mathit{ft} +}{ +\mathit{C} \vdash \mathsf{func}~\mathit{x} : \mathsf{func}~\mathit{ft} +} \, {[\textsc{\scriptsize T{-}externuse{-}func}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{global}[\mathit{x}] = \mathit{gt} +}{ +\mathit{C} \vdash \mathsf{global}~\mathit{x} : \mathsf{global}~\mathit{gt} +} \, {[\textsc{\scriptsize T{-}externuse{-}global}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{table}[\mathit{x}] = \mathit{tt} +}{ +\mathit{C} \vdash \mathsf{table}~\mathit{x} : \mathsf{table}~\mathit{tt} +} \, {[\textsc{\scriptsize T{-}externuse{-}table}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\mathit{C}.\mathsf{mem}[\mathit{x}] = \mathit{mt} +}{ +\mathit{C} \vdash \mathsf{memory}~\mathit{x} : \mathsf{memory}~\mathit{mt} +} \, {[\textsc{\scriptsize T{-}externuse{-}mem}]} +\qquad +\end{array} +$$ + +\vspace{1ex} + +$\boxed{{ \vdash }\;\mathit{module} : \mathsf{ok}}$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +\begin{array}{@{}c@{}} +\mathit{C} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~{\mathit{ft}^\ast},\; \mathsf{global}~{\mathit{gt}^\ast},\; \mathsf{table}~{\mathit{tt}^\ast},\; \mathsf{mem}~{\mathit{mt}^\ast},\; \mathsf{elem}~{\mathit{rt}^\ast},\; \mathsf{data}~{\mathsf{ok}^{\mathit{n}}} \}\end{array} + \\ +(\mathit{C} \vdash \mathit{func} : \mathit{ft})^\ast + \qquad +(\mathit{C} \vdash \mathit{global} : \mathit{gt})^\ast + \qquad +(\mathit{C} \vdash \mathit{table} : \mathit{tt})^\ast + \qquad +(\mathit{C} \vdash \mathit{mem} : \mathit{mt})^\ast + \\ +(\mathit{C} \vdash \mathit{elem} : \mathit{rt})^\ast + \qquad +(\mathit{C} \vdash \mathit{data} : \mathsf{ok})^{\mathit{n}} + \qquad +(\mathit{C} \vdash \mathit{start} : \mathsf{ok})^\ast + \\ +{|{\mathit{mem}^\ast}|} \leq 1 + \qquad +{|{\mathit{start}^\ast}|} \leq 1 +\end{array} +}{ +{ \vdash }\;\mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^{\mathit{n}}}~{\mathit{start}^\ast}~{\mathit{export}^\ast} : \mathsf{ok} +} \, {[\textsc{\scriptsize T{-}module}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(address)} & \mathit{addr} &::=& \mathit{nat} \\ +\mbox{(function address)} & \mathit{funcaddr} &::=& \mathit{addr} \\ +\mbox{(global address)} & \mathit{globaladdr} &::=& \mathit{addr} \\ +\mbox{(table address)} & \mathit{tableaddr} &::=& \mathit{addr} \\ +\mbox{(memory address)} & \mathit{memaddr} &::=& \mathit{addr} \\ +\mbox{(elem address)} & \mathit{elemaddr} &::=& \mathit{addr} \\ +\mbox{(data address)} & \mathit{dataaddr} &::=& \mathit{addr} \\ +\mbox{(label address)} & \mathit{labeladdr} &::=& \mathit{addr} \\ +\mbox{(host address)} & \mathit{hostaddr} &::=& \mathit{addr} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(number)} & \mathit{num} &::=& \mathsf{\mathit{numtype}}.\mathsf{const}~\mathsf{\mathit{c}\_{\mathit{numtype}}} \\ +\mbox{(reference)} & \mathit{ref} &::=& \mathsf{ref.null}~\mathit{reftype} ~|~ \mathsf{ref.func}~\mathsf{\mathit{funcaddr}} ~|~ \mathsf{ref.extern}~\mathsf{\mathit{hostaddr}} \\ +\mbox{(value)} & \mathit{val} &::=& \mathit{num} ~|~ \mathit{ref} \\ +\mbox{(result)} & \mathit{result} &::=& {\mathit{val}^\ast} ~|~ \mathsf{trap} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(external value)} & \mathit{externval} &::=& \mathsf{func}~\mathit{funcaddr} ~|~ \mathsf{global}~\mathit{globaladdr} ~|~ \mathsf{table}~\mathit{tableaddr} ~|~ \mathsf{mem}~\mathit{memaddr} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +{\mathrm{default}}_{\mathsf{i{\scriptstyle32}}} &=& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~0) & \\ +{\mathrm{default}}_{\mathsf{i{\scriptstyle64}}} &=& (\mathsf{i{\scriptstyle64}}.\mathsf{const}~0) & \\ +{\mathrm{default}}_{\mathsf{f{\scriptstyle32}}} &=& (\mathsf{f{\scriptstyle32}}.\mathsf{const}~0) & \\ +{\mathrm{default}}_{\mathsf{f{\scriptstyle64}}} &=& (\mathsf{f{\scriptstyle64}}.\mathsf{const}~0) & \\ +{\mathrm{default}}_{\mathit{rt}} &=& (\mathsf{ref.null}~\mathit{rt}) & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(function instance)} & \mathit{funcinst} &::=& \mathit{moduleinst} ; \mathit{func} \\ +\mbox{(global instance)} & \mathit{globalinst} &::=& \mathit{val} \\ +\mbox{(table instance)} & \mathit{tableinst} &::=& {\mathit{ref}^\ast} \\ +\mbox{(memory instance)} & \mathit{meminst} &::=& {\mathit{byte}^\ast} \\ +\mbox{(element instance)} & \mathit{eleminst} &::=& {\mathit{ref}^\ast} \\ +\mbox{(data instance)} & \mathit{datainst} &::=& {\mathit{byte}^\ast} \\ +\mbox{(export instance)} & \mathit{exportinst} &::=& \mathsf{export}~\mathit{name}~\mathit{externval} \\ +\mbox{(store)} & \mathit{store} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{func}~{\mathit{funcinst}^\ast},\; \\ + \mathsf{global}~{\mathit{globalinst}^\ast},\; \\ + \mathsf{table}~{\mathit{tableinst}^\ast},\; \\ + \mathsf{mem}~{\mathit{meminst}^\ast},\; \\ + \mathsf{elem}~{\mathit{eleminst}^\ast},\; \\ + \mathsf{data}~{\mathit{datainst}^\ast} \;\}\end{array} \\ +\mbox{(module instance)} & \mathit{moduleinst} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{func}~{\mathit{funcaddr}^\ast},\; \\ + \mathsf{global}~{\mathit{globaladdr}^\ast},\; \\ + \mathsf{table}~{\mathit{tableaddr}^\ast},\; \\ + \mathsf{mem}~{\mathit{memaddr}^\ast},\; \\ + \mathsf{elem}~{\mathit{elemaddr}^\ast},\; \\ + \mathsf{data}~{\mathit{dataaddr}^\ast},\; \\ + \mathsf{export}~{\mathit{exportinst}^\ast} \;\}\end{array} \\ +\mbox{(frame)} & \mathit{frame} &::=& \{\; \begin{array}[t]{@{}l@{}} +\mathsf{local}~{\mathit{val}^\ast},\; \\ + \mathsf{module}~\mathit{moduleinst} \;\}\end{array} \\ +\mbox{(state)} & \mathit{state} &::=& \mathit{store} ; \mathit{frame} \\ +\mbox{(configuration)} & \mathit{config} &::=& \mathit{state} ; {\mathit{instr}^\ast} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{module}.\mathsf{func} &=& \mathit{f}.\mathsf{module}.\mathsf{func} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{func} &=& \mathit{s}.\mathsf{func} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{(\mathit{s} ; \mathit{f}).\mathsf{func}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{func}[\mathit{f}.\mathsf{module}.\mathsf{func}[\mathit{x}]] & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{(\mathit{s} ; \mathit{f}).\mathsf{global}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{global}[\mathit{f}.\mathsf{module}.\mathsf{global}[\mathit{x}]] & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{(\mathit{s} ; \mathit{f}).\mathsf{table}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{(\mathit{s} ; \mathit{f}).\mathsf{mem}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{mem}[\mathit{f}.\mathsf{module}.\mathsf{mem}[\mathit{x}]] & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{(\mathit{s} ; \mathit{f}).\mathsf{elem}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{elem}[\mathit{f}.\mathsf{module}.\mathsf{elem}[\mathit{x}]] & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{(\mathit{s} ; \mathit{f}).\mathsf{data}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{data}[\mathit{f}.\mathsf{module}.\mathsf{data}[\mathit{x}]] & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +{(\mathit{s} ; \mathit{f}).\mathsf{local}}{[\mathit{x}]} &=& \mathit{f}.\mathsf{local}[\mathit{x}] & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f})[\mathsf{local}[\mathit{x}] = \mathit{v}] &=& \mathit{s} ; \mathit{f}[\mathsf{local}[\mathit{x}] = \mathit{v}] & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f})[\mathsf{global}[\mathit{x}] = \mathit{v}] &=& \mathit{s}[\mathsf{global}[\mathit{f}.\mathsf{module}.\mathsf{global}[\mathit{x}]] = \mathit{v}] ; \mathit{f} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}][\mathit{i}] = \mathit{r}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]][\mathit{i}] = \mathit{r}] ; \mathit{f} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f})[\mathsf{table}[\mathit{x}] = ..{\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] = ..{\mathit{r}^\ast}] ; \mathit{f} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f})[\mathsf{elem}[\mathit{x}] = {\mathit{r}^\ast}] &=& \mathit{s}[\mathsf{table}[\mathit{f}.\mathsf{module}.\mathsf{table}[\mathit{x}]] = {\mathit{r}^\ast}] ; \mathit{f} & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lrrl@{}} +\mbox{(administrative instruction)} & \mathit{instr} &::=& \mathit{instr} \\ &&|& +\mathsf{ref.func}~\mathsf{\mathit{funcaddr}} \\ &&|& +\mathsf{ref.extern}~\mathsf{\mathit{hostaddr}} \\ &&|& +\mathsf{call}~\mathsf{\mathit{funcaddr}} \\ &&|& +{{\mathsf{label}}_{\mathsf{\mathit{n}}}}{\mathsf{\{{\mathit{instr}^\ast}\}}~\mathsf{{\mathit{instr}^\ast}}} \\ &&|& +{{\mathsf{frame}}_{\mathsf{\mathit{n}}}}{\mathsf{\{\mathit{frame}\}}~\mathsf{{\mathit{instr}^\ast}}} \\ &&|& +\mathsf{trap} \\ +\mbox{(evaluation context)} & \mathit{E} &::=& [\mathsf{\_}] \\ &&|& +{\mathit{val}^\ast}~\mathit{E}~{\mathit{instr}^\ast} \\ &&|& +{{\mathsf{label}}_{\mathsf{\mathit{n}}}}{\mathsf{\{{\mathit{instr}^\ast}\}}~\mathsf{\mathit{e}}} \\ +\end{array} +$$ + +$\boxed{\mathit{config} \hookrightarrow \mathit{config}}$ + +$\boxed{{\mathit{instr}^\ast} \hookrightarrow {\mathit{instr}^\ast}}$ + +$\boxed{\mathit{config} \hookrightarrow {\mathit{instr}^\ast}}$ + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}pure}]} \quad & \mathit{z} ; {\mathit{instr}^\ast} &\hookrightarrow& \mathit{z} ; {{\mathit{instr}'}^\ast} &\quad + \mbox{if}~{\mathit{instr}^\ast} \hookrightarrow {{\mathit{instr}'}^\ast} \\ +{[\textsc{\scriptsize E{-}read}]} \quad & \mathit{z} ; {\mathit{instr}^\ast} &\hookrightarrow& \mathit{z} ; {{\mathit{instr}'}^\ast} &\quad + \mbox{if}~\mathit{z} ; {\mathit{instr}^\ast} \hookrightarrow {{\mathit{instr}'}^\ast} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}unreachable}]} \quad & \mathsf{unreachable} &\hookrightarrow& \mathsf{trap} & \\ +{[\textsc{\scriptsize E{-}nop}]} \quad & \mathsf{nop} &\hookrightarrow& \epsilon & \\ +{[\textsc{\scriptsize E{-}drop}]} \quad & \mathit{val}~\mathsf{drop} &\hookrightarrow& \epsilon & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}select{-}true}]} \quad & \mathit{val}_{1}~\mathit{val}_{2}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{select}~{\mathit{t}^?}) &\hookrightarrow& \mathit{val}_{1} &\quad + \mbox{if}~\mathit{c} \neq 0 \\ +{[\textsc{\scriptsize E{-}select{-}false}]} \quad & \mathit{val}_{1}~\mathit{val}_{2}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{select}~{\mathit{t}^?}) &\hookrightarrow& \mathit{val}_{2} &\quad + \mbox{if}~\mathit{c} = 0 \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}block}]} \quad & {\mathit{val}^{\mathit{k}}}~(\mathsf{block}~\mathit{bt}~{\mathit{instr}^\ast}) &\hookrightarrow& ({{\mathsf{label}}_{\mathit{n}}}{\{\epsilon\}~{\mathit{val}^{\mathit{k}}}~{\mathit{instr}^\ast}}) &\quad + \mbox{if}~\mathit{bt} = {\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}} \\ +{[\textsc{\scriptsize E{-}loop}]} \quad & {\mathit{val}^{\mathit{k}}}~(\mathsf{loop}~\mathit{bt}~{\mathit{instr}^\ast}) &\hookrightarrow& ({{\mathsf{label}}_{\mathit{n}}}{\{\mathsf{loop}~\mathit{bt}~{\mathit{instr}^\ast}\}~{\mathit{val}^{\mathit{k}}}~{\mathit{instr}^\ast}}) &\quad + \mbox{if}~\mathit{bt} = {\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}} \\ +{[\textsc{\scriptsize E{-}if{-}true}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{if}~\mathit{bt}~{\mathit{instr}_{1}^\ast}~\mathsf{else}~{\mathit{instr}_{2}^\ast}) &\hookrightarrow& (\mathsf{block}~\mathit{bt}~{\mathit{instr}_{1}^\ast}) &\quad + \mbox{if}~\mathit{c} \neq 0 \\ +{[\textsc{\scriptsize E{-}if{-}false}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{if}~\mathit{bt}~{\mathit{instr}_{1}^\ast}~\mathsf{else}~{\mathit{instr}_{2}^\ast}) &\hookrightarrow& (\mathsf{block}~\mathit{bt}~{\mathit{instr}_{2}^\ast}) &\quad + \mbox{if}~\mathit{c} = 0 \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}label{-}vals}]} \quad & ({{\mathsf{label}}_{\mathit{n}}}{\{{\mathit{instr}^\ast}\}~{\mathit{val}^\ast}}) &\hookrightarrow& {\mathit{val}^\ast} & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}br{-}zero}]} \quad & ({{\mathsf{label}}_{\mathit{n}}}{\{{{\mathit{instr}'}^\ast}\}~{{\mathit{val}'}^\ast}~{\mathit{val}^{\mathit{n}}}~(\mathsf{br}~0)~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^{\mathit{n}}}~{{\mathit{instr}'}^\ast} & \\ +{[\textsc{\scriptsize E{-}br{-}succ}]} \quad & ({{\mathsf{label}}_{\mathit{n}}}{\{{{\mathit{instr}'}^\ast}\}~{\mathit{val}^\ast}~(\mathsf{br}~\mathit{l} + 1)~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^\ast}~(\mathsf{br}~\mathit{l}) & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}br\_if{-}true}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{br\_if}~\mathit{l}) &\hookrightarrow& (\mathsf{br}~\mathit{l}) &\quad + \mbox{if}~\mathit{c} \neq 0 \\ +{[\textsc{\scriptsize E{-}br\_if{-}false}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c})~(\mathsf{br\_if}~\mathit{l}) &\hookrightarrow& \epsilon &\quad + \mbox{if}~\mathit{c} = 0 \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}br\_table{-}lt}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{br\_table}~{\mathit{l}^\ast}~{\mathit{l}'}) &\hookrightarrow& (\mathsf{br}~{\mathit{l}^\ast}[\mathit{i}]) &\quad + \mbox{if}~\mathit{i} < {|{\mathit{l}^\ast}|} \\ +{[\textsc{\scriptsize E{-}br\_table{-}ge}]} \quad & (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{br\_table}~{\mathit{l}^\ast}~{\mathit{l}'}) &\hookrightarrow& (\mathsf{br}~{\mathit{l}'}) &\quad + \mbox{if}~\mathit{i} \geq {|{\mathit{l}^\ast}|} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}call}]} \quad & \mathit{z} ; (\mathsf{call}~\mathit{x}) &\hookrightarrow& (\mathsf{call}~\mathit{z}.\mathsf{module}.\mathsf{func}[\mathit{x}]) & \\ +{[\textsc{\scriptsize E{-}call\_indirect{-}call}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{call\_indirect}~\mathit{x}~\mathit{ft}) &\hookrightarrow& (\mathsf{call}~\mathit{a}) &\quad + \mbox{if}~{\mathit{z}.\mathsf{table}}{[\mathit{x}]}[\mathit{i}] = (\mathsf{ref.func}~\mathit{a}) \\ + &&&&\quad {\land}~\mathit{z}.\mathsf{func}[\mathit{a}] = \mathit{m} ; \mathit{func} \\ +{[\textsc{\scriptsize E{-}call\_indirect{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{call\_indirect}~\mathit{x}~\mathit{ft}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{otherwise} \\ +{[\textsc{\scriptsize E{-}call\_addr}]} \quad & \mathit{z} ; {\mathit{val}^{\mathit{k}}}~(\mathsf{call}~\mathit{a}) &\hookrightarrow& ({{\mathsf{frame}}_{\mathit{n}}}{\{\mathit{f}\}~({{\mathsf{label}}_{\mathit{n}}}{\{\epsilon\}~{\mathit{instr}^\ast}})}) &\quad + \mbox{if}~\mathit{z}.\mathsf{func}[\mathit{a}] = \mathit{m} ; \mathsf{func}~({\mathit{t}_{1}^{\mathit{k}}} \rightarrow {\mathit{t}_{2}^{\mathit{n}}})~{\mathit{t}^\ast}~{\mathit{instr}^\ast} \\ + &&&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~{\mathit{val}^{\mathit{k}}}~{({\mathrm{default}}_{\mathit{t}})^\ast},\; \mathsf{module}~\mathit{m} \}\end{array} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}frame{-}vals}]} \quad & ({{\mathsf{frame}}_{\mathit{n}}}{\{\mathit{f}\}~{\mathit{val}^{\mathit{n}}}}) &\hookrightarrow& {\mathit{val}^{\mathit{n}}} & \\ +{[\textsc{\scriptsize E{-}return{-}frame}]} \quad & ({{\mathsf{frame}}_{\mathit{n}}}{\{\mathit{f}\}~{{\mathit{val}'}^\ast}~{\mathit{val}^{\mathit{n}}}~\mathsf{return}~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^{\mathit{n}}} & \\ +{[\textsc{\scriptsize E{-}return{-}label}]} \quad & ({{\mathsf{label}}_{\mathit{k}}}{\{{{\mathit{instr}'}^\ast}\}~{\mathit{val}^\ast}~\mathsf{return}~{\mathit{instr}^\ast}}) &\hookrightarrow& {\mathit{val}^\ast}~\mathsf{return} & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}unop{-}val}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt} . \mathit{unop}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~\mathit{c}) &\quad + \mbox{if}~{\mathit{unop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1})} = \mathit{c} \\ +{[\textsc{\scriptsize E{-}unop{-}trap}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt} . \mathit{unop}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~{\mathit{unop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1})} = \epsilon \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}binop{-}val}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}.\mathsf{const}~\mathit{c}_{2})~(\mathit{nt} . \mathit{binop}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~\mathit{c}) &\quad + \mbox{if}~{\mathit{binop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1},\, \mathit{c}_{2})} = \mathit{c} \\ +{[\textsc{\scriptsize E{-}binop{-}trap}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}.\mathsf{const}~\mathit{c}_{2})~(\mathit{nt} . \mathit{binop}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~{\mathit{binop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1},\, \mathit{c}_{2})} = \epsilon \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}testop}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt} . \mathit{testop}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c}) &\quad + \mbox{if}~\mathit{c} = {\mathit{testop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1})} \\ +{[\textsc{\scriptsize E{-}relop}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}.\mathsf{const}~\mathit{c}_{2})~(\mathit{nt} . \mathit{relop}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{c}) &\quad + \mbox{if}~\mathit{c} = {\mathit{relop}}{{\mathsf{}}_{\mathit{nt}}\,(\mathit{c}_{1},\, \mathit{c}_{2})} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}extend}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c})~({\mathit{nt}.\mathsf{extend}}{\mathit{n}}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~{{\mathrm{ext}}_{\mathit{n}}({|\mathit{nt}|})^{\mathsf{s}}}~(\mathit{c})) & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}cvtop{-}val}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}_{1} . {{{{\mathit{cvtop}}{\mathsf{\_}}}{\mathit{nt}_{2}}}{\mathsf{\_}}}{{\mathit{sx}^?}}) &\hookrightarrow& (\mathit{nt}.\mathsf{const}~\mathit{c}) &\quad + \mbox{if}~\mathrm{cvtop}(\mathit{nt}_{1},\, \mathit{cvtop},\, \mathit{nt}_{2},\, {\mathit{sx}^?},\, \mathit{c}_{1}) = \mathit{c} \\ +{[\textsc{\scriptsize E{-}cvtop{-}trap}]} \quad & (\mathit{nt}.\mathsf{const}~\mathit{c}_{1})~(\mathit{nt}_{1} . {{{{\mathit{cvtop}}{\mathsf{\_}}}{\mathit{nt}_{2}}}{\mathsf{\_}}}{{\mathit{sx}^?}}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~\mathrm{cvtop}(\mathit{nt}_{1},\, \mathit{cvtop},\, \mathit{nt}_{2},\, {\mathit{sx}^?},\, \mathit{c}_{1}) = \epsilon \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}ref.func}]} \quad & \mathit{z} ; (\mathsf{ref.func}~\mathit{x}) &\hookrightarrow& (\mathsf{ref.func}~\mathit{z}.\mathsf{module}.\mathsf{func}[\mathit{x}]) & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}ref.is\_null{-}true}]} \quad & \mathit{val}~\mathsf{ref.is\_null} &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~1) &\quad + \mbox{if}~\mathit{val} = (\mathsf{ref.null}~\mathit{rt}) \\ +{[\textsc{\scriptsize E{-}ref.is\_null{-}false}]} \quad & \mathit{val}~\mathsf{ref.is\_null} &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~0) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}local.get}]} \quad & \mathit{z} ; (\mathsf{local.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{local}}{[\mathit{x}]} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}local.set}]} \quad & \mathit{z} ; \mathit{val}~(\mathsf{local.set}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{local}[\mathit{x}] = \mathit{val}] ; \epsilon & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}local.tee}]} \quad & \mathit{val}~(\mathsf{local.tee}~\mathit{x}) &\hookrightarrow& \mathit{val}~\mathit{val}~(\mathsf{local.set}~\mathit{x}) & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}global.get}]} \quad & \mathit{z} ; (\mathsf{global.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{global}}{[\mathit{x}]} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}global.set}]} \quad & \mathit{z} ; \mathit{val}~(\mathsf{global.set}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{global}[\mathit{x}] = \mathit{val}] ; \epsilon & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.get{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ +{[\textsc{\scriptsize E{-}table.get{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& {\mathit{z}.\mathsf{table}}{[\mathit{x}]}[\mathit{i}] &\quad + \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ +{[\textsc{\scriptsize E{-}table.set{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{ref}~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~\mathit{i} \geq {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.set{-}val}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{ref}~(\mathsf{table.get}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}][\mathit{i}] = \mathit{ref}] ; \epsilon &\quad + \mbox{if}~\mathit{i} < {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.size}]} \quad & \mathit{z} ; (\mathsf{table.size}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n}) &\quad + \mbox{if}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} = \mathit{n} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.grow{-}succeed}]} \quad & \mathit{z} ; \mathit{ref}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{table}[\mathit{x}] = ..{\mathit{ref}^{\mathit{n}}}] ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~{|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|}) & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.grow{-}fail}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.grow}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~-1) & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.fill{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ +{[\textsc{\scriptsize E{-}table.fill{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& \epsilon &\quad + \mbox{otherwise, if}~\mathit{n} = 0 \\ +{[\textsc{\scriptsize E{-}table.fill{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.fill}~\mathit{x}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~\mathit{val}~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~\mathit{val}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.fill}~\mathit{x}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.copy{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{y}]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ +{[\textsc{\scriptsize E{-}table.copy{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& \epsilon &\quad + \mbox{otherwise, if}~\mathit{n} = 0 \\ +{[\textsc{\scriptsize E{-}table.copy{-}le}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{table.get}~\mathit{y})~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\quad + \mbox{otherwise, if}~\mathit{j} \leq \mathit{i} \\ +{[\textsc{\scriptsize E{-}table.copy{-}gt}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + \mathit{n} - 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + \mathit{n} - 1)~(\mathsf{table.get}~\mathit{y})~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.copy}~\mathit{x}~\mathit{y}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}table.init{-}trap}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& \mathsf{trap} &\quad + \mbox{if}~\mathit{i} + \mathit{n} > {|{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}|} \lor \mathit{j} + \mathit{n} > {|{\mathit{z}.\mathsf{table}}{[\mathit{x}]}|} \\ +{[\textsc{\scriptsize E{-}table.init{-}zero}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& \epsilon &\quad + \mbox{otherwise, if}~\mathit{n} = 0 \\ +{[\textsc{\scriptsize E{-}table.init{-}succ}]} \quad & \mathit{z} ; (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\hookrightarrow& (\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j})~{\mathit{z}.\mathsf{elem}}{[\mathit{y}]}[\mathit{i}]~(\mathsf{table.set}~\mathit{x})~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{j} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{i} + 1)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n} - 1)~(\mathsf{table.init}~\mathit{x}~\mathit{y}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}l@{}lcl@{}l@{}} +{[\textsc{\scriptsize E{-}elem.drop}]} \quad & \mathit{z} ; (\mathsf{elem.drop}~\mathit{x}) &\hookrightarrow& \mathit{z}[\mathsf{elem}[\mathit{x}] = \epsilon] ; \epsilon & \\ +\end{array} +$$ + +\vspace{1ex} + + +== Complete. ```