eutaxy 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +96 -12
  2. package/dist/aws.mjs +5 -5
  3. package/dist/bin.mjs +2 -2
  4. package/dist/{checksum-DhS6ofSm.mjs → checksum-DHr5qb3Y.mjs} +2 -2
  5. package/dist/{checksum-DhS6ofSm.mjs.map → checksum-DHr5qb3Y.mjs.map} +1 -1
  6. package/dist/cli-CsiVEsS-.mjs +2 -0
  7. package/dist/cli.d.mts.map +1 -1
  8. package/dist/cli.mjs +2 -2
  9. package/dist/cloudflare.d.mts +2 -4
  10. package/dist/cloudflare.d.mts.map +1 -1
  11. package/dist/cloudflare.mjs +2 -2
  12. package/dist/{delivery-invariants-Cuxdna28.mjs → delivery-invariants-hmhwh_qD.mjs} +2 -2
  13. package/dist/{delivery-invariants-Cuxdna28.mjs.map → delivery-invariants-hmhwh_qD.mjs.map} +1 -1
  14. package/dist/{event-streams-BANyO9xt.mjs → event-streams-i8OGzuFN.mjs} +2 -2
  15. package/dist/{event-streams-BANyO9xt.mjs.map → event-streams-i8OGzuFN.mjs.map} +1 -1
  16. package/dist/{checked-CGpA2-F0.d.mts → explore-CDpJA9zX.d.mts} +118 -61
  17. package/dist/explore-CDpJA9zX.d.mts.map +1 -0
  18. package/dist/index.d.mts +76 -20
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +19 -20
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/{src-Bqc9Eyb1.mjs → src-BO7I3f-1.mjs} +2 -2
  23. package/dist/{src-Bqc9Eyb1.mjs.map → src-BO7I3f-1.mjs.map} +1 -1
  24. package/dist/{src-DKb-fkdb.mjs → src-C43iUZgr.mjs} +1650 -10
  25. package/dist/src-C43iUZgr.mjs.map +1 -0
  26. package/dist/{src-Dxl9ZlKn.mjs → src-Cs4Mg55e.mjs} +957 -37
  27. package/dist/src-Cs4Mg55e.mjs.map +1 -0
  28. package/package.json +16 -1
  29. package/dist/checked-CGpA2-F0.d.mts.map +0 -1
  30. package/dist/cli-IJrKkeYS.mjs +0 -2
  31. package/dist/src-DKb-fkdb.mjs.map +0 -1
  32. package/dist/src-Dxl9ZlKn.mjs.map +0 -1
@@ -1,4 +1,13 @@
1
- import { S as canonicalJson } from "./src-Bqc9Eyb1.mjs";
1
+ import { C as nextU32, E as canonicalJson, S as nextInt, w as seedPrng, x as nextFloat } from "./src-BO7I3f-1.mjs";
2
+ // packages/core/src/verdict.ts
3
+ /** One line per verdict, for error messages; full rendering lives in `report`. */
4
+ function describeVerdict(v) {
5
+ switch (v.kind) {
6
+ case "VIOLATED": return `VIOLATED ${v.scenario}: ${v.violation.message} (seed ${v.schedule.seed}, ${v.reached.runs} run(s))`;
7
+ case "BOUNDED": return `BOUNDED ${v.scenario}: no violation in ${v.reached.runs} run(s), ${v.reached.effectPoints} effect point(s), ${v.reached.faultsInjected} fault(s)`;
8
+ case "UNSUPPORTED": return `UNSUPPORTED ${v.scenario}: ${v.cause}: ${v.reason}`;
9
+ }
10
+ }
2
11
  // packages/spec/src/ir.ts
3
12
  const domains = [
4
13
  "int",
@@ -207,7 +216,7 @@ function scan(text, start, options) {
207
216
  }
208
217
  if (c === "/" && text[i + 1] === "/") {
209
218
  const from = i;
210
- while (i < text.length && text[i] !== "\n") i++;
219
+ while (i < text.length && !/[\n\r\u2028\u2029]/u.test(text[i])) i++;
211
220
  push("comment", from, i);
212
221
  continue;
213
222
  }
@@ -1002,7 +1011,8 @@ function extractSpecs(source) {
1002
1011
  ensures,
1003
1012
  total: found.some((t) => t.name === "total"),
1004
1013
  throws: found.some((t) => t.name === "throws"),
1005
- line: lineOf(code[decl.open].start)
1014
+ line: lineOf(code[decl.open].start),
1015
+ offset: code[decl.open].start
1006
1016
  });
1007
1017
  });
1008
1018
  return {
@@ -1429,10 +1439,35 @@ function render(value) {
1429
1439
  return String(value);
1430
1440
  }
1431
1441
  }
1442
+ /**
1443
+ * One assignment through a predicate. An atom that is not a boolean, or a
1444
+ * name nothing defines, is a malformed property. Any other throw, the
1445
+ * function's own included (JSON.parse's SyntaxError, say), means the claim
1446
+ * is not true there. A ReferenceError counts as malformed: compiled
1447
+ * TypeScript under test hardly throws one, a name the property's scope
1448
+ * analysis missed does, and that must never pass for a refutation.
1449
+ */
1450
+ function evaluate(predicate, values) {
1451
+ try {
1452
+ return { outcome: predicate(...values) };
1453
+ } catch (err) {
1454
+ if (err instanceof AtomNotBoolean || err instanceof ReferenceError) return { malformed: String(err) };
1455
+ return {
1456
+ outcome: "refuted",
1457
+ error: String(err)
1458
+ };
1459
+ }
1460
+ }
1461
+ /** A finite integer endpoint's value, exact: underscores and the `n` suffix dropped. */
1462
+ function endpointBigInt(value) {
1463
+ return BigInt(value.replace(/_/g, "").replace(/n$/, ""));
1464
+ }
1432
1465
  function bound(value, integral) {
1433
- if (integral && !value.endsWith("∞")) return BigInt(value.replace(/_/g, "").replace(/n$/, ""));
1466
+ if (integral && !value.endsWith("∞")) return endpointBigInt(value);
1434
1467
  return endpointNumber(value);
1435
1468
  }
1469
+ /** How every rung words an `UNKNOWN` for a property that cannot be evaluated; the ladder recognizes it. */
1470
+ const malformedReason = (detail) => `the property could not be evaluated: ${detail}`;
1436
1471
  /** Whether a value lies in a binder's domain and guard. */
1437
1472
  function inDomain(b, v) {
1438
1473
  switch (b.domain) {
@@ -1509,27 +1544,16 @@ function checkedRung(input) {
1509
1544
  call: `${fn.name}(${call.args.map(render).join(", ")})`,
1510
1545
  ...error === void 0 ? {} : { error }
1511
1546
  });
1512
- let outcome;
1513
- try {
1514
- outcome = predicate(...values);
1515
- } catch (err) {
1516
- if (err instanceof AtomNotBoolean || err instanceof ReferenceError) return unknown("unsupported", `the property could not be evaluated: ${String(err)}`);
1517
- return {
1518
- ...base,
1519
- kind: "REFUTED",
1520
- rung: "CHECKED",
1521
- counterexample: counterexample(String(err)),
1522
- assumptions: []
1523
- };
1524
- }
1525
- if (outcome === "refuted") return {
1547
+ const result = evaluate(predicate, values);
1548
+ if ("malformed" in result) return unknown("unsupported", malformedReason(result.malformed));
1549
+ if (result.outcome === "refuted") return {
1526
1550
  ...base,
1527
1551
  kind: "REFUTED",
1528
1552
  rung: "CHECKED",
1529
- counterexample: counterexample(),
1553
+ counterexample: counterexample("error" in result ? result.error : void 0),
1530
1554
  assumptions: []
1531
1555
  };
1532
- if (outcome === "discarded") discarded++;
1556
+ if (result.outcome === "discarded") discarded++;
1533
1557
  else held++;
1534
1558
  }
1535
1559
  if (held === 0) return unknown("gave_up", input.calls.length === 0 ? `the simulator never called ${fn.name}` : `none of the ${seen.size} distinct input(s) the simulator passed is inside the claim (domains, guards, preconditions)`);
@@ -1567,30 +1591,912 @@ function markerVerdicts(module, fn) {
1567
1591
  });
1568
1592
  return out;
1569
1593
  }
1570
- /** Every spec verdict for one module, from what was observed of its calls. */
1571
- function checkSpecModule(module, specs, predicates, observed) {
1594
+ // packages/prover/src/regex-gen.ts
1595
+ /**
1596
+ * Strings that match a regular expression, drawn with core's seeded
1597
+ * generator: the pattern is parsed into alternatives, sequences, classes
1598
+ * and quantified terms, and each draw walks that tree. The subset is what
1599
+ * guards use: literals, escapes, classes with ranges and negation, groups,
1600
+ * alternation, the usual quantifiers and anchors. Lookaround,
1601
+ * backreferences and Unicode property escapes are refused with
1602
+ * `UnsupportedRegex`, and the caller falls back to sampling. Every draw is
1603
+ * checked against the real `RegExp` by the caller, so a gap here can only
1604
+ * cost a draw, never admit a value outside the guard.
1605
+ */
1606
+ var UnsupportedRegex = class extends Error {};
1607
+ const digits$1 = [..."0123456789"];
1608
+ const word = [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"];
1609
+ const space = [..." \n\r\f\v"];
1610
+ /** What `.` and negated classes draw from: printable ASCII, a few others, no newline. */
1611
+ const anyChar = [..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~üß日"];
1612
+ /** A plentiful count for an unbounded quantifier: keeps drawn strings short. */
1613
+ const unboundedExtra = 4;
1614
+ /** The most a counted quantifier may ask for; a guard wanting more is left to sampling. */
1615
+ const maxRepeat = 1e3;
1616
+ /** The longest string one draw may build before it is given up. */
1617
+ const maxLength = 1e4;
1618
+ /** The most nodes one draw may visit: nested repetitions of empty matches multiply work without length. */
1619
+ const maxSteps = 1e5;
1620
+ /** A class node over the characters it can draw; negation is resolved here, once. */
1621
+ function classNode(chars, negated) {
1622
+ const pool = negated ? anyChar.filter((c) => !chars.includes(c)) : chars;
1623
+ if (pool.length === 0) throw new UnsupportedRegex("an empty class matches nothing");
1624
+ return {
1625
+ kind: "class",
1626
+ pool
1627
+ };
1628
+ }
1629
+ var Parser = class {
1630
+ at = 0;
1631
+ src;
1632
+ dotAll;
1633
+ unicode;
1634
+ constructor(src, flags) {
1635
+ this.src = src;
1636
+ this.dotAll = flags.includes("s");
1637
+ this.unicode = flags.includes("u");
1638
+ }
1639
+ parse() {
1640
+ const node = this.alternation();
1641
+ if (this.at < this.src.length) throw new UnsupportedRegex(`unexpected ${this.src[this.at]}`);
1642
+ return node;
1643
+ }
1644
+ peek() {
1645
+ return this.src[this.at];
1646
+ }
1647
+ take() {
1648
+ const c = this.src[this.at++];
1649
+ if (c === void 0) throw new UnsupportedRegex("pattern ends early");
1650
+ return c;
1651
+ }
1652
+ alternation() {
1653
+ const options = [this.sequence()];
1654
+ while (this.peek() === "|") {
1655
+ this.at++;
1656
+ options.push(this.sequence());
1657
+ }
1658
+ return options.length === 1 ? options[0] : {
1659
+ kind: "alt",
1660
+ options
1661
+ };
1662
+ }
1663
+ sequence() {
1664
+ const items = [];
1665
+ while (this.at < this.src.length && this.peek() !== "|" && this.peek() !== ")") {
1666
+ const atom = this.atom();
1667
+ items.push(this.quantified(atom));
1668
+ }
1669
+ return items.length === 1 ? items[0] : {
1670
+ kind: "seq",
1671
+ items
1672
+ };
1673
+ }
1674
+ quantified(atom) {
1675
+ const c = this.peek();
1676
+ let min;
1677
+ let max;
1678
+ if (c === "*") [min, max] = [0, unboundedExtra];
1679
+ else if (c === "+") [min, max] = [1, 5];
1680
+ else if (c === "?") [min, max] = [0, 1];
1681
+ else if (c === "{") {
1682
+ const m = /^\{(\d+)(,(\d*))?\}/.exec(this.src.slice(this.at));
1683
+ if (!m) return atom;
1684
+ min = Number(m[1]);
1685
+ max = m[2] === void 0 ? min : m[3] === "" || m[3] === void 0 ? min + unboundedExtra : Number(m[3]);
1686
+ if (max < min) throw new UnsupportedRegex(`quantifier {${min},${max}} is empty`);
1687
+ if (max > maxRepeat) throw new UnsupportedRegex(`quantifier {${min},${max}} repeats too much to draw`);
1688
+ this.at += m[0].length - 1;
1689
+ } else return atom;
1690
+ this.at++;
1691
+ if (this.peek() === "?") this.at++;
1692
+ return {
1693
+ kind: "repeat",
1694
+ item: atom,
1695
+ min,
1696
+ max
1697
+ };
1698
+ }
1699
+ atom() {
1700
+ const c = this.take();
1701
+ switch (c) {
1702
+ case "(": {
1703
+ if (this.src.startsWith("?:", this.at)) this.at += 2;
1704
+ else if (this.src.startsWith("?<", this.at) && !"=!".includes(this.src[this.at + 2] ?? "")) {
1705
+ const close = this.src.indexOf(">", this.at);
1706
+ if (close < 0) throw new UnsupportedRegex("unterminated group name");
1707
+ this.at = close + 1;
1708
+ } else if (this.peek() === "?") throw new UnsupportedRegex("lookaround or modifier group");
1709
+ const inner = this.alternation();
1710
+ if (this.take() !== ")") throw new UnsupportedRegex("unbalanced parenthesis");
1711
+ return inner;
1712
+ }
1713
+ case "[": return this.charClass();
1714
+ case ".": return classNode(this.dotAll ? [...anyChar, "\n"] : anyChar, false);
1715
+ case "^":
1716
+ case "$": return { kind: "empty" };
1717
+ case "\\": return this.escape(false);
1718
+ case ")":
1719
+ case "|":
1720
+ case "*":
1721
+ case "+":
1722
+ case "?": throw new UnsupportedRegex(`unexpected ${c}`);
1723
+ default: return {
1724
+ kind: "literal",
1725
+ text: c
1726
+ };
1727
+ }
1728
+ }
1729
+ /** An escape after `\`; inside a class, `\b` is a backspace. */
1730
+ escape(inClass) {
1731
+ const e = this.take();
1732
+ switch (e) {
1733
+ case "d": return classNode(digits$1, false);
1734
+ case "D": return classNode(digits$1, true);
1735
+ case "w": return classNode(word, false);
1736
+ case "W": return classNode(word, true);
1737
+ case "s": return classNode(space, false);
1738
+ case "S": return classNode(space, true);
1739
+ case "n": return {
1740
+ kind: "literal",
1741
+ text: "\n"
1742
+ };
1743
+ case "t": return {
1744
+ kind: "literal",
1745
+ text: " "
1746
+ };
1747
+ case "r": return {
1748
+ kind: "literal",
1749
+ text: "\r"
1750
+ };
1751
+ case "f": return {
1752
+ kind: "literal",
1753
+ text: "\f"
1754
+ };
1755
+ case "v": return {
1756
+ kind: "literal",
1757
+ text: "\v"
1758
+ };
1759
+ case "0": return {
1760
+ kind: "literal",
1761
+ text: "\0"
1762
+ };
1763
+ case "b":
1764
+ if (inClass) return {
1765
+ kind: "literal",
1766
+ text: "\b"
1767
+ };
1768
+ return { kind: "empty" };
1769
+ case "B": return { kind: "empty" };
1770
+ case "x": {
1771
+ const hex = this.src.slice(this.at, this.at + 2);
1772
+ if (!/^[0-9a-fA-F]{2}$/.test(hex)) throw new UnsupportedRegex("bad \\x escape");
1773
+ this.at += 2;
1774
+ return {
1775
+ kind: "literal",
1776
+ text: String.fromCharCode(Number.parseInt(hex, 16))
1777
+ };
1778
+ }
1779
+ case "u": {
1780
+ if (this.peek() === "{") {
1781
+ if (!this.unicode) throw new UnsupportedRegex("\\u{} without the u flag");
1782
+ const close = this.src.indexOf("}", this.at);
1783
+ const hex = this.src.slice(this.at + 1, close);
1784
+ if (close < 0 || !/^[0-9a-fA-F]{1,6}$/.test(hex)) throw new UnsupportedRegex("bad \\u escape");
1785
+ this.at = close + 1;
1786
+ return {
1787
+ kind: "literal",
1788
+ text: String.fromCodePoint(Number.parseInt(hex, 16))
1789
+ };
1790
+ }
1791
+ const hex = this.src.slice(this.at, this.at + 4);
1792
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) throw new UnsupportedRegex("bad \\u escape");
1793
+ this.at += 4;
1794
+ return {
1795
+ kind: "literal",
1796
+ text: String.fromCharCode(Number.parseInt(hex, 16))
1797
+ };
1798
+ }
1799
+ case "p":
1800
+ case "P":
1801
+ case "k":
1802
+ case "c": throw new UnsupportedRegex(`\\${e} escapes`);
1803
+ default:
1804
+ if (/[1-9]/.test(e)) throw new UnsupportedRegex("backreferences");
1805
+ return {
1806
+ kind: "literal",
1807
+ text: e
1808
+ };
1809
+ }
1810
+ }
1811
+ /** `[...]` after its opening bracket. `[]` is empty and `[]a]` is an empty class then `a]`, as in JavaScript. */
1812
+ charClass() {
1813
+ let negated = false;
1814
+ if (this.peek() === "^") {
1815
+ negated = true;
1816
+ this.at++;
1817
+ }
1818
+ const chars = /* @__PURE__ */ new Set();
1819
+ while (this.peek() !== "]") {
1820
+ const c = this.take();
1821
+ let member;
1822
+ if (c === "\\") {
1823
+ const node = this.escape(true);
1824
+ if (node.kind === "class") {
1825
+ for (const x of node.pool) chars.add(x);
1826
+ continue;
1827
+ }
1828
+ if (node.kind !== "literal") throw new UnsupportedRegex("escape in class");
1829
+ member = node.text;
1830
+ } else member = c;
1831
+ if (this.peek() === "-" && this.src[this.at + 1] !== "]" && this.src[this.at + 1] !== void 0) {
1832
+ this.at++;
1833
+ const to = this.take() === "\\" ? this.escape(true) : {
1834
+ kind: "literal",
1835
+ text: this.src[this.at - 1]
1836
+ };
1837
+ if (to.kind !== "literal") throw new UnsupportedRegex("range to a class");
1838
+ const lo = member.codePointAt(0);
1839
+ const hi = to.text.codePointAt(0);
1840
+ if (hi < lo) throw new UnsupportedRegex("range out of order");
1841
+ if (hi - lo > 8192) throw new UnsupportedRegex("range too wide to enumerate");
1842
+ for (let p = lo; p <= hi; p++) chars.add(String.fromCodePoint(p));
1843
+ continue;
1844
+ }
1845
+ chars.add(member);
1846
+ }
1847
+ this.at++;
1848
+ return classNode([...chars], negated);
1849
+ }
1850
+ };
1851
+ /** The pattern as a tree, or `UnsupportedRegex`. */
1852
+ function parseRegex(pattern, flags) {
1853
+ if (flags.includes("v")) throw new UnsupportedRegex("the v flag");
1854
+ return new Parser(pattern, flags).parse();
1855
+ }
1856
+ /** One string from the tree, with the state that follows. */
1857
+ function drawRegex(node, state) {
1858
+ let s = state;
1859
+ let steps = 0;
1860
+ const go = (n) => {
1861
+ if (++steps > maxSteps) throw new UnsupportedRegex("a draw visited more than 100000 nodes");
1862
+ switch (n.kind) {
1863
+ case "empty": return "";
1864
+ case "literal": return n.text;
1865
+ case "alt": {
1866
+ const [i, next] = nextInt(s, n.options.length);
1867
+ s = next;
1868
+ return go(n.options[i]);
1869
+ }
1870
+ case "seq": return n.items.map(go).join("");
1871
+ case "repeat": {
1872
+ const [extra, next] = nextInt(s, n.max - n.min + 1);
1873
+ s = next;
1874
+ let out = "";
1875
+ for (let i = 0; i < n.min + extra; i++) {
1876
+ out += go(n.item);
1877
+ if (out.length > maxLength) throw new UnsupportedRegex("a draw grew past 10000 characters");
1878
+ }
1879
+ return out;
1880
+ }
1881
+ case "class": {
1882
+ const [i, next] = nextInt(s, n.pool.length);
1883
+ s = next;
1884
+ return n.pool[i];
1885
+ }
1886
+ }
1887
+ };
1888
+ return [go(node), s];
1889
+ }
1890
+ // packages/prover/src/generate.ts
1891
+ /**
1892
+ * Inputs for the `TESTED` rung: values drawn from a binder's domain and
1893
+ * guard with core's seeded generator, and the smaller values a shrinker
1894
+ * tries in place of one that broke a property. Everything here is pure:
1895
+ * the same state draws the same value, so a `TESTED` verdict and its
1896
+ * counterexample come out the same on every machine.
1897
+ */
1898
+ /** Thrown when no value of a binder's domain could be drawn within the guard. */
1899
+ var CannotGenerate = class extends Error {};
1900
+ /** Integers are drawn as doubles, so they stay exact. */
1901
+ const safe = 2n ** 53n - 1n;
1902
+ /** How far an unguarded side of a bigint range reaches. */
1903
+ const bigintReach = 1n << 128n;
1904
+ /**
1905
+ * The closed integer interval a binder admits: within what a double holds
1906
+ * exactly for `int` and `nat`; for `bigint`, the guard's ends, an
1907
+ * unguarded side reaching 2^128 past the other. Undefined when no integer
1908
+ * lies in it, which the parser does not rule out (`int ∈ (0, 1)`).
1909
+ */
1910
+ function integerRange(b) {
1911
+ const g = b.guard?.kind === "interval" ? b.guard : void 0;
1912
+ const guardLo = g && !g.lower.value.endsWith("∞") ? endpointBigInt(g.lower.value) + (g.lower.inclusive ? 0n : 1n) : void 0;
1913
+ const guardHi = g && !g.upper.value.endsWith("∞") ? endpointBigInt(g.upper.value) - (g.upper.inclusive ? 0n : 1n) : void 0;
1914
+ let lo;
1915
+ let hi;
1916
+ if (b.domain === "bigint") {
1917
+ lo = guardLo ?? (guardHi === void 0 ? -bigintReach : min(-bigintReach, guardHi - bigintReach));
1918
+ hi = guardHi ?? (guardLo === void 0 ? bigintReach : max(bigintReach, guardLo + bigintReach));
1919
+ } else {
1920
+ lo = max(b.domain === "nat" ? 0n : -safe, guardLo ?? -safe);
1921
+ hi = min(safe, guardHi ?? safe);
1922
+ }
1923
+ return lo <= hi ? {
1924
+ lo,
1925
+ hi
1926
+ } : void 0;
1927
+ }
1928
+ const max = (a, b) => a > b ? a : b;
1929
+ const min = (a, b) => a < b ? a : b;
1930
+ /** Uniform in [lo, hi], however wide: enough 32-bit words, masked, rejected when past the span. */
1931
+ function uniformBigInt(lo, hi, state) {
1932
+ const span = hi - lo + 1n;
1933
+ if (span <= 0n) throw new RangeError(`empty integer interval [${lo}, ${hi}]`);
1934
+ if (span === 1n) return [lo, state];
1935
+ let bits = 0;
1936
+ for (let x = span - 1n; x > 0n; x >>= 1n) bits++;
1937
+ const words = Math.ceil(bits / 32);
1938
+ const mask = (1n << BigInt(bits)) - 1n;
1939
+ let s = state;
1940
+ for (;;) {
1941
+ let r = 0n;
1942
+ for (let i = 0; i < words; i++) {
1943
+ const [u, next] = nextU32(s);
1944
+ s = next;
1945
+ r = r << 32n | BigInt(u);
1946
+ }
1947
+ r &= mask;
1948
+ if (r < span) return [lo + r, s];
1949
+ }
1950
+ }
1951
+ /** One of a list, uniformly. */
1952
+ function pick(items, state) {
1953
+ const [i, s] = nextInt(state, items.length);
1954
+ return [items[i], s];
1955
+ }
1956
+ /**
1957
+ * An integer from the binder's range, biased: most draws are small, since
1958
+ * properties fail at boundaries and small cases far more often than deep in
1959
+ * the range, some are medium or large, and a few are the range's edges.
1960
+ */
1961
+ function drawInteger(b, state) {
1962
+ const range = integerRange(b);
1963
+ if (!range) throw new CannotGenerate(b.domain === "bigint" ? `no integer lies inside the guard of ${b.name}` : `no integer lies inside the guard of ${b.name} within ±2^53, which is as far as draws of ${b.domain} go`);
1964
+ const { lo, hi } = range;
1965
+ const [cls, s] = nextInt(state, 100);
1966
+ const within = (a, z) => {
1967
+ const l = max(lo, a);
1968
+ const h = min(hi, z);
1969
+ return l <= h ? [l, h] : void 0;
1970
+ };
1971
+ if (cls < 5) return pick([
1972
+ lo,
1973
+ hi,
1974
+ 0n,
1975
+ 1n,
1976
+ -1n,
1977
+ lo + 1n,
1978
+ hi - 1n
1979
+ ].filter((v) => v >= lo && v <= hi), s);
1980
+ const [l, h] = (cls < 55 ? within(-16n, 16n) : cls < 80 ? within(-(1n << 16n), 1n << 16n) : cls < 95 ? within(-(1n << 31n), 1n << 31n) : void 0) ?? [lo, hi];
1981
+ return uniformBigInt(l, h, s);
1982
+ }
1983
+ /** The double interval a `number` binder admits. */
1984
+ function numberRange(b) {
1985
+ const g = b.guard;
1986
+ if (g?.kind !== "interval") return {
1987
+ lo: Number.NEGATIVE_INFINITY,
1988
+ hi: Number.POSITIVE_INFINITY,
1989
+ guarded: false
1990
+ };
1991
+ return {
1992
+ lo: endpointNumber(g.lower.value),
1993
+ hi: endpointNumber(g.upper.value),
1994
+ guarded: true
1995
+ };
1996
+ }
1997
+ function drawNumber(b, state) {
1998
+ const { lo, hi, guarded } = numberRange(b);
1999
+ const [cls, s0] = nextInt(state, 100);
2000
+ if (cls < 8) {
2001
+ const edges = [
2002
+ 0,
2003
+ -0,
2004
+ 1,
2005
+ -1,
2006
+ .5,
2007
+ Number.MIN_VALUE,
2008
+ Number.EPSILON,
2009
+ Number.MAX_VALUE,
2010
+ -Number.MAX_VALUE,
2011
+ Number.POSITIVE_INFINITY,
2012
+ Number.NEGATIVE_INFINITY,
2013
+ ...guarded ? [lo, hi] : [NaN]
2014
+ ].filter((v) => inDomain(b, v));
2015
+ if (edges.length > 0) return pick(edges, s0);
2016
+ }
2017
+ if (cls < 35) {
2018
+ const [k, s1] = nextInt(s0, 33);
2019
+ return [k - 16, s1];
2020
+ }
2021
+ if (cls < 60) {
2022
+ const [d, s1] = pick([
2023
+ 2,
2024
+ 4,
2025
+ 8,
2026
+ 10,
2027
+ 100
2028
+ ], s0);
2029
+ const [k, s2] = nextInt(s1, 65);
2030
+ return [(k - 32) / d, s2];
2031
+ }
2032
+ if (cls < 80 && Number.isFinite(lo) && Number.isFinite(hi)) {
2033
+ const [f, s1] = nextFloat(s0);
2034
+ return [lo + f * (hi - lo), s1];
2035
+ }
2036
+ const [f, s1] = nextFloat(s0);
2037
+ const [e, s2] = nextInt(s1, 2100);
2038
+ const [neg, s3] = nextInt(s2, 2);
2039
+ return [(neg ? -1 : 1) * (1 + f) * 2 ** (e - 1074), s3];
2040
+ }
2041
+ const letters = "abcdefghijklmnopqrstuvwxyz";
2042
+ const digits = "0123456789";
2043
+ const plainAlphabet = [...`${letters}${letters.toUpperCase()}${digits} _-.,:/\n'"üß日😀`];
2044
+ const stringEdges = [
2045
+ "",
2046
+ " ",
2047
+ "a",
2048
+ "0",
2049
+ "-1",
2050
+ "\n",
2051
+ "\0",
2052
+ "ü",
2053
+ "😀",
2054
+ "a".repeat(100)
2055
+ ];
2056
+ /**
2057
+ * The characters a regex names: literals, the ranges and escapes of its
2058
+ * classes. Strings drawn from them match the pattern far more often than
2059
+ * strings drawn from everything, which is what the rejection below needs.
2060
+ */
2061
+ function regexAlphabet(pattern) {
2062
+ const chars = /* @__PURE__ */ new Set();
2063
+ const add = (s) => {
2064
+ for (const c of s) chars.add(c);
2065
+ };
2066
+ for (let i = 0; i < pattern.length; i++) {
2067
+ const c = pattern[i];
2068
+ if (c === "\\") {
2069
+ const e = pattern[++i];
2070
+ if (e === "d") add(digits);
2071
+ else if (e === "w") add(`${letters}${letters.toUpperCase()}${digits}_`);
2072
+ else if (e === "s") add(" ");
2073
+ else if (e === "n") add("\n");
2074
+ else if (e === "t") add(" ");
2075
+ else if (e !== void 0 && !/[DWSbBuxpP]/.test(e)) add(e);
2076
+ continue;
2077
+ }
2078
+ if (pattern[i + 1] === "-" && i + 2 < pattern.length && pattern[i + 2] !== "]") {
2079
+ const from = c.codePointAt(0);
2080
+ const to = pattern[i + 2].codePointAt(0);
2081
+ if (from < to && to - from <= 4096) for (let p = from; p <= to; p++) chars.add(String.fromCodePoint(p));
2082
+ i += 2;
2083
+ continue;
2084
+ }
2085
+ if (!"^$()[]{}|*+?.-".includes(c)) chars.add(c);
2086
+ }
2087
+ return [...chars];
2088
+ }
2089
+ /** A string of `length` characters from `alphabet`. */
2090
+ function drawChars(alphabet, length, state) {
2091
+ let s = state;
2092
+ let out = "";
2093
+ for (let i = 0; i < length; i++) {
2094
+ const [c, next] = pick(alphabet, s);
2095
+ s = next;
2096
+ out += c;
2097
+ }
2098
+ return [out, s];
2099
+ }
2100
+ function drawString(b, state) {
2101
+ const g = b.guard;
2102
+ if (g?.kind !== "regex") {
2103
+ const [cls, s0] = nextInt(state, 100);
2104
+ if (cls < 15) return pick(stringEdges, s0);
2105
+ const [length, s1] = nextInt(s0, 25);
2106
+ return drawChars(plainAlphabet, length, s1);
2107
+ }
2108
+ let s = state;
2109
+ let tree;
2110
+ try {
2111
+ tree = parseRegex(g.pattern, g.flags);
2112
+ } catch (err) {
2113
+ if (!(err instanceof UnsupportedRegex)) throw err;
2114
+ }
2115
+ for (let attempt = 0; tree && attempt < 16; attempt++) try {
2116
+ const [candidate, s1] = drawRegex(tree, s);
2117
+ s = s1;
2118
+ if (inDomain(b, candidate)) return [candidate, s];
2119
+ } catch (err) {
2120
+ if (!(err instanceof UnsupportedRegex)) throw err;
2121
+ break;
2122
+ }
2123
+ const fromPattern = regexAlphabet(g.pattern);
2124
+ const alphabet = fromPattern.length > 0 ? fromPattern : plainAlphabet;
2125
+ for (let attempt = 0; attempt < 64; attempt++) {
2126
+ const [length, s1] = nextInt(s, 13);
2127
+ const [candidate, s2] = drawChars(alphabet, length, s1);
2128
+ s = s2;
2129
+ if (inDomain(b, candidate)) return [candidate, s];
2130
+ }
2131
+ throw new CannotGenerate(`no string matching /${g.pattern}/${g.flags} was found in 64 draws over its characters`);
2132
+ }
2133
+ /** A value of the binder's domain within its guard. */
2134
+ function generate(b, state) {
2135
+ switch (b.domain) {
2136
+ case "boolean": {
2137
+ const [bit, s] = nextInt(state, 2);
2138
+ return [bit === 1, s];
2139
+ }
2140
+ case "int":
2141
+ case "nat": {
2142
+ const [v, s] = drawInteger(b, state);
2143
+ return [Number(v), s];
2144
+ }
2145
+ case "bigint": return drawInteger(b, state);
2146
+ case "number": {
2147
+ let s = state;
2148
+ for (let attempt = 0; attempt < 64; attempt++) {
2149
+ const [v, next] = drawNumber(b, s);
2150
+ s = next;
2151
+ if (inDomain(b, v)) return [v, s];
2152
+ }
2153
+ throw new CannotGenerate(`no number inside the guard of ${b.name} was found in 64 draws`);
2154
+ }
2155
+ case "string": return drawString(b, state);
2156
+ }
2157
+ }
2158
+ /** The integer nearest to zero in [lo, hi]. */
2159
+ function nearestZero(lo, hi) {
2160
+ return lo > 0n ? lo : hi < 0n ? hi : 0n;
2161
+ }
2162
+ /** Steps from `v` toward `target`: the target itself, then the halfway points back toward `v`. */
2163
+ function towards(v, target) {
2164
+ const out = [];
2165
+ if (v === target) return out;
2166
+ out.push(target);
2167
+ let d = (v - target) / 2n;
2168
+ while (d !== 0n) {
2169
+ out.push(v - d);
2170
+ d /= 2n;
2171
+ }
2172
+ return out;
2173
+ }
2174
+ /**
2175
+ * Smaller values to try in place of `v`, simplest first, all within the
2176
+ * binder's domain and guard and none equal to `v`. Numbers move toward
2177
+ * zero (or the guard's end nearest it), strings get shorter and plainer,
2178
+ * `true` becomes `false`.
2179
+ */
2180
+ function shrinkCandidates(b, v) {
2181
+ const keep = (xs) => {
2182
+ const seen = /* @__PURE__ */ new Set();
2183
+ return xs.filter((x) => {
2184
+ if (Object.is(x, v) || seen.has(x) || !inDomain(b, x)) return false;
2185
+ seen.add(x);
2186
+ return true;
2187
+ });
2188
+ };
2189
+ switch (b.domain) {
2190
+ case "boolean": return keep([false]);
2191
+ case "int":
2192
+ case "nat": {
2193
+ const range = integerRange(b);
2194
+ if (typeof v !== "number" || !Number.isInteger(v) || !range) return [];
2195
+ return keep(towards(BigInt(v), nearestZero(range.lo, range.hi)).map(Number));
2196
+ }
2197
+ case "bigint": {
2198
+ const range = integerRange(b);
2199
+ if (typeof v !== "bigint" || !range) return [];
2200
+ return keep(towards(v, nearestZero(range.lo, range.hi)));
2201
+ }
2202
+ case "number": {
2203
+ if (typeof v !== "number") return [];
2204
+ const { lo, hi } = numberRange(b);
2205
+ const target = lo > 0 ? lo : Math.min(hi, 0);
2206
+ if (!Number.isFinite(v)) return keep([
2207
+ target,
2208
+ 1,
2209
+ -1,
2210
+ Number.MAX_VALUE,
2211
+ -Number.MAX_VALUE
2212
+ ]);
2213
+ const out = [target, Math.trunc(v)];
2214
+ let d = (v - target) / 2;
2215
+ for (let i = 0; i < 24 && d !== 0; i++) {
2216
+ out.push(v - d);
2217
+ d /= 2;
2218
+ }
2219
+ return keep(out);
2220
+ }
2221
+ case "string": {
2222
+ if (typeof v !== "string") return [];
2223
+ const chars = [...v];
2224
+ const out = ["", chars.slice(0, Math.floor(chars.length / 2)).join("")];
2225
+ out.push(chars.slice(Math.ceil(chars.length / 2)).join(""));
2226
+ for (const at of [
2227
+ 0,
2228
+ chars.length - 1,
2229
+ Math.floor(chars.length / 2)
2230
+ ]) out.push([...chars.slice(0, at), ...chars.slice(at + 1)].join(""));
2231
+ const first = chars.findIndex((c) => c !== "a");
2232
+ if (first >= 0) out.push([
2233
+ ...chars.slice(0, first),
2234
+ "a",
2235
+ ...chars.slice(first + 1)
2236
+ ].join(""));
2237
+ return keep(out);
2238
+ }
2239
+ }
2240
+ }
2241
+ // packages/prover/src/tested.ts
2242
+ /**
2243
+ * The `TESTED` rung: a property evaluated on assignments drawn from its
2244
+ * binders' domains and guards, with a seed, so the same seed draws the same
2245
+ * assignments everywhere. An assignment where the claim is false is shrunk
2246
+ * toward smaller values that still break it and reported as a
2247
+ * counterexample. Holding on every drawn assignment is `TESTED`: evidence
2248
+ * from sampling, which says nothing about the inputs never drawn.
2249
+ */
2250
+ /** How many evaluations shrinking may spend on one counterexample. */
2251
+ const shrinkBudget = 500;
2252
+ function testedRung(input) {
2253
+ const { module, fn, property } = input;
2254
+ const base = {
2255
+ module,
2256
+ function: fn.name,
2257
+ property: property.name,
2258
+ text: property.text
2259
+ };
2260
+ const unknown = (cause, reason) => ({
2261
+ ...base,
2262
+ kind: "UNKNOWN",
2263
+ cause,
2264
+ reason,
2265
+ assumptions: []
2266
+ });
2267
+ const predicate = input.predicate;
2268
+ if (!predicate) return unknown("unavailable", "the property's predicate was not compiled");
2269
+ const binders = property.property.binders;
2270
+ const wanted = input.inputs ?? 100;
2271
+ if (!Number.isInteger(wanted) || wanted < 1) throw new RangeError(`inputs must be a positive integer, got ${String(input.inputs)}`);
2272
+ const seed = `${input.seed}:${module}:${fn.name}:${property.name}`;
2273
+ let state = seedPrng(seed);
2274
+ let held = 0;
2275
+ let discarded = 0;
2276
+ const seen = /* @__PURE__ */ new Set();
2277
+ const counterexample = (values, error) => ({
2278
+ binders: binders.map((b, i) => ({
2279
+ name: b.name,
2280
+ value: render(values[i])
2281
+ })),
2282
+ ...error === void 0 ? {} : { error }
2283
+ });
2284
+ for (let draws = 0; held < wanted && draws < wanted * 20; draws++) {
2285
+ const values = [];
2286
+ try {
2287
+ for (const b of binders) {
2288
+ const [v, next] = generate(b, state);
2289
+ state = next;
2290
+ values.push(v);
2291
+ }
2292
+ } catch (err) {
2293
+ if (err instanceof CannotGenerate) return unknown("gave_up", err.message);
2294
+ throw err;
2295
+ }
2296
+ const key = values.map(render).join(", ");
2297
+ if (seen.has(key)) continue;
2298
+ seen.add(key);
2299
+ const result = evaluate(predicate, values);
2300
+ if ("malformed" in result) return unknown("unsupported", malformedReason(result.malformed));
2301
+ if (result.outcome === "discarded") {
2302
+ discarded++;
2303
+ continue;
2304
+ }
2305
+ if (result.outcome === "refuted") {
2306
+ const smallest = shrink(predicate, binders, values, result);
2307
+ return {
2308
+ ...base,
2309
+ kind: "REFUTED",
2310
+ rung: "TESTED",
2311
+ counterexample: counterexample(smallest.values, smallest.error),
2312
+ assumptions: [`found on an input generated with seed ${input.seed}, then shrunk`]
2313
+ };
2314
+ }
2315
+ held++;
2316
+ }
2317
+ if (held === 0) return unknown("gave_up", `all ${discarded} distinct generated inputs were outside the claim: its preconditions admit too few of the binders' domains to sample`);
2318
+ return {
2319
+ ...base,
2320
+ kind: "TESTED",
2321
+ inputs: held,
2322
+ discarded,
2323
+ seed: input.seed,
2324
+ assumptions: [`held on ${held} distinct input(s) generated from the binders' domains with seed ${input.seed}; inputs never drawn are not covered`, `${fn.name} was called on generated inputs outside the simulator, so it is assumed pure`]
2325
+ };
2326
+ }
2327
+ /** The refuting assignment made as small as the candidates allow, one binder at a time. */
2328
+ function shrink(predicate, binders, start, startEvaluation) {
2329
+ let values = [...start];
2330
+ let error = refutes(startEvaluation) ?? {};
2331
+ let spent = 0;
2332
+ let progress = true;
2333
+ while (progress && spent < shrinkBudget) {
2334
+ progress = false;
2335
+ for (let i = 0; i < binders.length && spent < shrinkBudget; i++) {
2336
+ const b = binders[i];
2337
+ let moved = true;
2338
+ while (moved && spent < shrinkBudget) {
2339
+ moved = false;
2340
+ for (const candidate of shrinkCandidates(b, values[i])) {
2341
+ if (spent >= shrinkBudget) break;
2342
+ spent++;
2343
+ const trial = values.with(i, candidate);
2344
+ const still = refutes(evaluate(predicate, trial));
2345
+ if (still === void 0) continue;
2346
+ values = trial;
2347
+ error = still;
2348
+ moved = true;
2349
+ progress = true;
2350
+ break;
2351
+ }
2352
+ }
2353
+ }
2354
+ }
2355
+ return error.error === void 0 ? { values } : {
2356
+ values,
2357
+ error: error.error
2358
+ };
2359
+ }
2360
+ /** Whether an evaluation still refutes: an object (holding the error text, if any), or undefined. */
2361
+ function refutes(e) {
2362
+ if ("malformed" in e || e.outcome !== "refuted") return void 0;
2363
+ return "error" in e ? { error: e.error } : {};
2364
+ }
2365
+ // packages/prover/src/ladder.ts
2366
+ /** One property through the ladder's rungs. */
2367
+ function specLadder(input, options = {}) {
2368
+ const checked = checkedRung(input);
2369
+ if (checked.kind === "REFUTED" || options.tested === false || options.tested === void 0) return checked;
2370
+ if (checked.kind === "UNKNOWN" && checked.reason.startsWith(malformedReason(""))) return checked;
2371
+ const tested = testedRung({
2372
+ module: input.module,
2373
+ fn: input.fn,
2374
+ property: input.property,
2375
+ predicate: input.predicate,
2376
+ ...options.tested
2377
+ });
2378
+ if (tested.kind === "REFUTED") return tested;
2379
+ if (tested.kind === "UNKNOWN" && tested.reason.startsWith(malformedReason(""))) return tested;
2380
+ if (tested.kind === "TESTED") {
2381
+ if (checked.kind !== "CHECKED") return {
2382
+ ...tested,
2383
+ assumptions: [...tested.assumptions, reason(checked)]
2384
+ };
2385
+ return {
2386
+ ...tested,
2387
+ checked: checked.inputs,
2388
+ assumptions: [...tested.assumptions, ...checked.assumptions]
2389
+ };
2390
+ }
2391
+ if (checked.kind !== "UNKNOWN") return {
2392
+ ...checked,
2393
+ assumptions: [...checked.assumptions, `not TESTED: ${reason(tested)}`]
2394
+ };
2395
+ if (reason(tested) === checked.reason) return checked;
2396
+ return {
2397
+ ...checked,
2398
+ reason: `${checked.reason}; generated inputs: ${reason(tested)}`
2399
+ };
2400
+ }
2401
+ function reason(v) {
2402
+ return v.kind === "UNKNOWN" ? v.reason : v.kind;
2403
+ }
2404
+ /** Every spec verdict for one module: each property through the ladder, the markers as the rungs leave them. */
2405
+ function checkSpecModule(module, specs, predicates, observed, options = {}) {
1572
2406
  return specs.functions.flatMap((fn) => {
1573
2407
  const calls = observed.calls.filter((c) => c.function === fn.name);
1574
2408
  const unobservable = Object.hasOwn(observed.unobservable, fn.name) ? observed.unobservable[fn.name] : void 0;
1575
2409
  const own = Object.hasOwn(predicates, fn.name) ? predicates[fn.name] : void 0;
1576
- return [...fn.ensures.map((property) => checkedRung({
2410
+ return [...fn.ensures.map((property) => specLadder({
1577
2411
  module,
1578
2412
  fn,
1579
2413
  property,
1580
2414
  calls,
1581
2415
  predicate: own && Object.hasOwn(own, property.name) ? own[property.name] : void 0,
1582
2416
  ...unobservable === void 0 ? {} : { unobservable }
1583
- })), ...markerVerdicts(module, fn)];
2417
+ }, options)), ...markerVerdicts(module, fn)];
1584
2418
  });
1585
2419
  }
1586
- // packages/core/src/verdict.ts
1587
- /** One line per verdict, for error messages; full rendering lives in `report`. */
1588
- function describeVerdict(v) {
1589
- switch (v.kind) {
1590
- case "VIOLATED": return `VIOLATED ${v.scenario}: ${v.violation.message} (seed ${v.schedule.seed}, ${v.reached.runs} run(s))`;
1591
- case "BOUNDED": return `BOUNDED ${v.scenario}: no violation in ${v.reached.runs} run(s), ${v.reached.effectPoints} effect point(s), ${v.reached.faultsInjected} fault(s)`;
1592
- case "UNSUPPORTED": return `UNSUPPORTED ${v.scenario}: ${v.cause}: ${v.reason}`;
1593
- }
2420
+ // packages/prover/src/provers.ts
2421
+ /**
2422
+ * The simulator's verdicts for a module (CHECKED, TESTED, REFUTED, UNKNOWN,
2423
+ * markers included) combined with what the engines proved. A simulator
2424
+ * counterexample stands. One engine proving is `PROVEN`, the lower rungs'
2425
+ * counts kept beside it; an engine refuting where nothing else did is
2426
+ * `REFUTED` at the PROVEN rung; one proving and another refuting is
2427
+ * `CONFLICT`. An engine that gave up, could not run or does not take the
2428
+ * function leaves the verdict as it was, with why among the assumptions.
2429
+ * `@total` is proved by acceptance where the engine says so.
2430
+ */
2431
+ function aggregate(module, verdicts, reports) {
2432
+ return verdicts.map((v) => {
2433
+ if (v.module !== module) return v;
2434
+ const says = reports.map((r) => ({
2435
+ engine: r.engine,
2436
+ outcome: r.proofs.results.find((p) => p.function === v.function && p.property === v.property)?.outcome
2437
+ })).filter((x) => x.outcome !== void 0);
2438
+ if (says.length === 0) return v;
2439
+ const proven = says.find((x) => x.outcome.kind === "PROVEN");
2440
+ const refuted = says.find((x) => x.outcome.kind === "REFUTED");
2441
+ if (v.kind === "REFUTED" || v.kind === "CONFLICT") {
2442
+ if (v.kind === "REFUTED" && proven?.outcome.kind === "PROVEN") return {
2443
+ module: v.module,
2444
+ function: v.function,
2445
+ property: v.property,
2446
+ text: v.text,
2447
+ kind: "CONFLICT",
2448
+ proven: proven.outcome.engine,
2449
+ refuted: {
2450
+ name: "simulator",
2451
+ version: v.rung,
2452
+ counterexample: v.counterexample
2453
+ },
2454
+ assumptions: [...v.assumptions, ...proven.outcome.assumptions]
2455
+ };
2456
+ return v;
2457
+ }
2458
+ if (proven?.outcome.kind === "PROVEN" && refuted?.outcome.kind === "REFUTED") return {
2459
+ module: v.module,
2460
+ function: v.function,
2461
+ property: v.property,
2462
+ text: v.text,
2463
+ kind: "CONFLICT",
2464
+ proven: proven.outcome.engine,
2465
+ refuted: {
2466
+ name: refuted.outcome.engine.name,
2467
+ version: refuted.outcome.engine.version,
2468
+ ...refuted.outcome.counterexample ? { counterexample: refuted.outcome.counterexample } : {}
2469
+ },
2470
+ assumptions: [...proven.outcome.assumptions, ...refuted.outcome.assumptions]
2471
+ };
2472
+ if (refuted?.outcome.kind === "REFUTED") return {
2473
+ module: v.module,
2474
+ function: v.function,
2475
+ property: v.property,
2476
+ text: v.text,
2477
+ kind: "REFUTED",
2478
+ rung: "PROVEN",
2479
+ engine: refuted.outcome.engine,
2480
+ counterexample: refuted.outcome.counterexample ?? { binders: [] },
2481
+ assumptions: refuted.outcome.assumptions
2482
+ };
2483
+ if (proven?.outcome.kind === "PROVEN") return {
2484
+ module: v.module,
2485
+ function: v.function,
2486
+ property: v.property,
2487
+ text: v.text,
2488
+ kind: "PROVEN",
2489
+ engine: proven.outcome.engine,
2490
+ ...v.kind === "TESTED" ? { tested: v.inputs } : {},
2491
+ ...v.kind === "TESTED" && v.checked !== void 0 ? { checked: v.checked } : v.kind === "CHECKED" ? { checked: v.inputs } : {},
2492
+ assumptions: [...proven.outcome.assumptions, ...v.assumptions]
2493
+ };
2494
+ const notes = says.map((x) => x.outcome.kind === "UNKNOWN" ? `not PROVEN by ${x.engine}: ${x.outcome.cause}: ${x.outcome.reason}` : `${x.engine}: ${x.outcome.kind}`);
2495
+ return {
2496
+ ...v,
2497
+ assumptions: [...v.assumptions, ...notes]
2498
+ };
2499
+ });
1594
2500
  }
1595
2501
  // packages/report/src/regression.ts
1596
2502
  /**
@@ -1653,22 +2559,36 @@ function renderJson(verdict, specs = []) {
1653
2559
  /** Spec verdicts as text: one line each, a counterexample under a refutation. */
1654
2560
  function renderSpecs(specs) {
1655
2561
  if (specs.length === 0) return "";
1656
- const out = ["Specs (CHECKED means held on the inputs the simulator passed; it is not a proof)"];
2562
+ const out = ["Specs (CHECKED means held on the inputs the simulator passed, TESTED on generated ones too; neither is a proof. PROVEN is one, by the named engine)"];
1657
2563
  for (const v of specs) {
1658
2564
  const what = `${v.function} ${v.property}`;
1659
2565
  switch (v.kind) {
1660
2566
  case "CHECKED":
1661
2567
  out.push(` CHECKED ${what}: held on ${v.inputs} input(s)${v.discarded > 0 ? `, ${v.discarded} outside the claim` : ""}`);
1662
2568
  break;
2569
+ case "TESTED":
2570
+ out.push(` TESTED ${what}: held on ${v.inputs} generated input(s)${v.checked === void 0 ? "" : ` and ${v.checked} the simulator passed`}${v.discarded > 0 ? `, ${v.discarded} outside the claim` : ""}`);
2571
+ break;
2572
+ case "PROVEN": {
2573
+ const beside = [...v.tested === void 0 ? [] : [`${v.tested} generated input(s)`], ...v.checked === void 0 ? [] : [`${v.checked} the simulator passed`]];
2574
+ out.push(` PROVEN ${what}: by ${v.engine.name} ${v.engine.version}${beside.length > 0 ? `; also held on ${beside.join(" and ")}` : ""}`);
2575
+ break;
2576
+ }
2577
+ case "CONFLICT":
2578
+ out.push(` CONFLICT ${what}: ${v.proven.name} ${v.proven.version} proves it, ${v.refuted.name} ${v.refuted.version} refutes it; not resolved automatically`);
2579
+ if (v.refuted.counterexample) out.push(` ${v.refuted.counterexample.binders.map((b) => `${b.name} = ${b.value}`).join(", ")}`);
2580
+ break;
1663
2581
  case "REFUTED": {
1664
2582
  const c = v.counterexample;
1665
- out.push(` REFUTED ${what}: false at ${c.call}${c.error ? `, which threw ${c.error}` : ""}`);
1666
- out.push(` ${c.binders.map((b) => `${b.name} = ${b.value}`).join(", ")}`);
2583
+ const where = v.rung === "PROVEN" ? `by ${v.engine?.name ?? "an engine"}` : c.call === void 0 ? "on a generated input" : `at ${c.call}`;
2584
+ out.push(` REFUTED ${what}: false ${where}${c.error ? `, which threw ${c.error}` : ""}`);
2585
+ if (c.binders.length > 0) out.push(` ${c.binders.map((b) => `${b.name} = ${b.value}`).join(", ")}`);
1667
2586
  out.push(` ${v.text.replace(/\s+/g, " ")}`);
1668
2587
  break;
1669
2588
  }
1670
2589
  case "UNKNOWN": out.push(` UNKNOWN ${what}: ${v.cause}: ${v.reason}`);
1671
2590
  }
2591
+ for (const a of v.assumptions) if (v.kind === "PROVEN" || a.startsWith("not PROVEN by ")) out.push(` ${a}`);
1672
2592
  }
1673
2593
  return out.join("\n");
1674
2594
  }
@@ -1747,6 +2667,6 @@ function renderText(verdict) {
1747
2667
  for (const a of verdict.assumptions) out.push(` - ${a}`);
1748
2668
  return out.join("\n");
1749
2669
  }
1750
- export { emitRegressionTest as a, checkedRung as c, predicateSource as d, extractSpecs as f, renderTrace as i, lemmaBool as l, parseProperty as m, renderSpecs as n, describeVerdict as o, LemmaSyntaxError as p, renderText as r, checkSpecModule as s, renderJson as t, lemmaUnresolved as u };
2670
+ export { TokenizeError as _, emitRegressionTest as a, describeVerdict as b, specLadder as c, lemmaBool as d, lemmaUnresolved as f, parseProperty as g, LemmaSyntaxError as h, renderTrace as i, testedRung as l, extractSpecs as m, renderSpecs as n, aggregate as o, predicateSource as p, renderText as r, checkSpecModule as s, renderJson as t, checkedRung as u, templateSubstitutions as v, tokenize as y };
1751
2671
 
1752
- //# sourceMappingURL=src-Dxl9ZlKn.mjs.map
2672
+ //# sourceMappingURL=src-Cs4Mg55e.mjs.map