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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions crates/clazel-js-vm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "clazel-js-vm"
version = "0.0.0"
edition.workspace = true
license.workspace = true
publish.workspace = true
description = "The JavaScript engine's bytecode and its semantics for Clazel's Phase 7 browser (phase-7.md item 7.4): the instruction set, NaN-boxed values, and `spec fn step`."

[dependencies]
vstd = "=0.0.0-2026-10-04-0306"

# Verification tier (docs/VERIFICATION.md). `tier` is what is proven about the
# shipped code today: nothing, since this crate holds only the specification
# of item 7.4 (the handlers, compiler and interpreter loop come later, in 7.7
# and 7.8). `target-tier` is 0 for the shipped code, as the Crates table of
# phase-7.md states; the spec itself is written to Tier 2 standards (Verus
# checks it and the lemmas in src/lemmas.rs), because the JIT's front-end
# proofs (jit.md J.10) refine `step`.
[package.metadata.clazel]
tier = 0
target-tier = 0

[package.metadata.verus]
verify = true

[lints]
workspace = true
43 changes: 43 additions & 0 deletions crates/clazel-js-vm/mutations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"mutations": [
{
"id": "multiply-neg-zero-left-positive",
"file": "src/spec.rs",
"find": "else { 0x8000_0000_0000_0000 } // 4.b.",
"replace": "else { 0 } // 4.b.",
"expect": "killed",
"reason": "Returns +0 instead of -0 for `-0 × y` with y positive (§6.1.6.1.4 step 4.b): example_multiply_zero_signs is false.",
"certificate": {
"file": "src/lemmas.rs",
"lemma": "crate::examples::example_multiply_zero_signs()",
"witness": "number_multiply(0x8000_0000_0000_0000u64, 0x4014_0000_0000_0000u64) == 0u64"
}
},
{
"id": "multiply-neg-zero-right-positive",
"file": "src/spec.rs",
"find": "else { 0x8000_0000_0000_0000 } // 5.b.",
"replace": "else { 0 } // 5.b.",
"expect": "killed",
"reason": "Returns +0 instead of -0 for `x × -0` with x positive (§6.1.6.1.4 step 5.b): example_multiply_zero_signs is false.",
"certificate": {
"file": "src/lemmas.rs",
"lemma": "crate::examples::example_multiply_zero_signs()",
"witness": "number_multiply(0x4014_0000_0000_0000u64, 0x8000_0000_0000_0000u64) == 0u64"
}
},
{
"id": "multiply-pos-zero-ignores-sign",
"file": "src/spec.rs",
"find": "(f64_sign(x) ^ f64_sign(y)) << 63",
"replace": "0",
"expect": "killed",
"reason": "Drops the step 5a erratum's sign, so `+0 × -5` would be +0 where every engine and IEEE 754 give -0: example_multiply_zero_signs is false.",
"certificate": {
"file": "src/lemmas.rs",
"lemma": "crate::examples::example_multiply_zero_signs()",
"witness": "number_multiply(0u64, 0xC014_0000_0000_0000u64) == 0u64"
}
}
]
}
32 changes: 32 additions & 0 deletions crates/clazel-js-vm/src/examples.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! The standard's results, evaluated on the spec with `compute_only`. Kept
//! apart from [`super::lemmas`] so that a mutant that breaks one of them does
//! not stop Verus before it checks a kill certificate there
//! (`mutations.json`).
//!
//! - [`example_multiply_zero_signs`]: the sign of a zero product (steps 4
//! and 5 and the step 5a erratum of Number::multiply).

#[allow(unused_imports)]
use super::spec::*;
#[allow(unused_imports)]
use vstd::prelude::*;

verus! {

/// The sign of a zero product, §6.1.6.1.4: `-0 × 5` is `-0` (step 4.b),
/// `5 × -0` is `-0` (step 5.b), `-0 × -5` is `+0` (step 4.a), and `+0 × -5`
/// is `-0` (the step 5a erratum, docs/ERRATA.md).
pub proof fn example_multiply_zero_signs()
ensures
number_multiply(0x8000_0000_0000_0000u64, 0x4014_0000_0000_0000u64) == 0x8000_0000_0000_0000u64,
number_multiply(0x4014_0000_0000_0000u64, 0x8000_0000_0000_0000u64) == 0x8000_0000_0000_0000u64,
number_multiply(0x8000_0000_0000_0000u64, 0xC014_0000_0000_0000u64) == 0u64,
number_multiply(0u64, 0xC014_0000_0000_0000u64) == 0x8000_0000_0000_0000u64,
{
assert(number_multiply(0x8000_0000_0000_0000u64, 0x4014_0000_0000_0000u64) == 0x8000_0000_0000_0000u64) by (compute_only);
assert(number_multiply(0x4014_0000_0000_0000u64, 0x8000_0000_0000_0000u64) == 0x8000_0000_0000_0000u64) by (compute_only);
assert(number_multiply(0x8000_0000_0000_0000u64, 0xC014_0000_0000_0000u64) == 0u64) by (compute_only);
assert(number_multiply(0u64, 0xC014_0000_0000_0000u64) == 0x8000_0000_0000_0000u64) by (compute_only);
}

} // verus!
Loading
Loading