eutaxy 0.17.2 → 0.19.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 (74) hide show
  1. package/README.md +15 -12
  2. package/dist/aws.d.mts +2 -2
  3. package/dist/aws.mjs +3 -2
  4. package/dist/aws.mjs.map +1 -1
  5. package/dist/bin.mjs +1 -1
  6. package/dist/check-zkHLdWyf.mjs +1281 -0
  7. package/dist/check-zkHLdWyf.mjs.map +1 -0
  8. package/dist/cli-CNAKqV9R.mjs +297 -0
  9. package/dist/cli-CNAKqV9R.mjs.map +1 -0
  10. package/dist/cli.d.mts.map +1 -1
  11. package/dist/cli.mjs +1 -1
  12. package/dist/cloudflare.d.mts +56 -5
  13. package/dist/cloudflare.d.mts.map +1 -1
  14. package/dist/cloudflare.mjs +6417 -3
  15. package/dist/cloudflare.mjs.map +1 -0
  16. package/dist/{delivery-invariants-DO3j1mmD.mjs → delivery-invariants-BJDck0K8.mjs} +2 -2
  17. package/dist/{delivery-invariants-DO3j1mmD.mjs.map → delivery-invariants-BJDck0K8.mjs.map} +1 -1
  18. package/dist/{delivery-invariants-D7DI7i8x.d.mts → delivery-invariants-C3GXJIbg.d.mts} +2 -2
  19. package/dist/{delivery-invariants-D7DI7i8x.d.mts.map → delivery-invariants-C3GXJIbg.d.mts.map} +1 -1
  20. package/dist/draft-DEUDffHa.mjs +467 -0
  21. package/dist/draft-DEUDffHa.mjs.map +1 -0
  22. package/dist/{src-fxWc6oGc.mjs → generate-TBJM3-2P.mjs} +3 -574
  23. package/dist/generate-TBJM3-2P.mjs.map +1 -0
  24. package/dist/index.d.mts +45 -37
  25. package/dist/index.d.mts.map +1 -1
  26. package/dist/index.mjs +7 -4
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/install-DkzpGA5D.mjs +611 -0
  29. package/dist/install-DkzpGA5D.mjs.map +1 -0
  30. package/dist/{explore-CkKiOuz6.d.mts → ir-KpC2epGn.d.mts} +88 -53
  31. package/dist/ir-KpC2epGn.d.mts.map +1 -0
  32. package/dist/keys-xtanNmuR.mjs +111 -0
  33. package/dist/keys-xtanNmuR.mjs.map +1 -0
  34. package/dist/mcp-B64Ko6y7.mjs +539 -0
  35. package/dist/mcp-B64Ko6y7.mjs.map +1 -0
  36. package/dist/{platform-D4hlJjm3.d.mts → platform-Cs9V9t2k.d.mts} +92 -11
  37. package/dist/platform-Cs9V9t2k.d.mts.map +1 -0
  38. package/dist/pool-CXN4CwGY.mjs +61 -0
  39. package/dist/pool-CXN4CwGY.mjs.map +1 -0
  40. package/dist/{provers-DS44OeEm.mjs → provers-D8VaY_OM.mjs} +18 -2
  41. package/dist/provers-D8VaY_OM.mjs.map +1 -0
  42. package/dist/reader-B9FSoEYW.mjs +1 -0
  43. package/dist/reader-Cz6_bLf6.mjs +3774 -0
  44. package/dist/reader-Cz6_bLf6.mjs.map +1 -0
  45. package/dist/report-_Vzavqg0.mjs +310 -0
  46. package/dist/report-_Vzavqg0.mjs.map +1 -0
  47. package/dist/src-B2DpVbMN.mjs +2 -0
  48. package/dist/src-BFGTvuA_.mjs +1235 -0
  49. package/dist/src-BFGTvuA_.mjs.map +1 -0
  50. package/dist/src-BtLZPRyG.mjs +120 -0
  51. package/dist/src-BtLZPRyG.mjs.map +1 -0
  52. package/dist/src-CB8DcvsK.mjs +1 -0
  53. package/dist/src-COuquJvI.mjs +269 -0
  54. package/dist/src-COuquJvI.mjs.map +1 -0
  55. package/dist/src-Chn-m_r1.mjs +1082 -0
  56. package/dist/src-Chn-m_r1.mjs.map +1 -0
  57. package/dist/src-DwYD3QQJ.mjs +346 -0
  58. package/dist/src-DwYD3QQJ.mjs.map +1 -0
  59. package/dist/{src-D_hHC_-3.mjs → src-Dx4QvrQb.mjs} +945 -548
  60. package/dist/src-Dx4QvrQb.mjs.map +1 -0
  61. package/dist/toolchain-DWfymxAJ.mjs +80 -0
  62. package/dist/toolchain-DWfymxAJ.mjs.map +1 -0
  63. package/dist/verdict-evEM5Gxx.mjs +12 -0
  64. package/dist/verdict-evEM5Gxx.mjs.map +1 -0
  65. package/package.json +4 -1
  66. package/dist/cli-B0Gs2mhT.mjs +0 -9445
  67. package/dist/cli-B0Gs2mhT.mjs.map +0 -1
  68. package/dist/explore-CkKiOuz6.d.mts.map +0 -1
  69. package/dist/platform-D4hlJjm3.d.mts.map +0 -1
  70. package/dist/provers-DS44OeEm.mjs.map +0 -1
  71. package/dist/src-D_hHC_-3.mjs.map +0 -1
  72. package/dist/src-fxWc6oGc.mjs.map +0 -1
  73. package/dist/workerd-DhrzU6AZ.mjs +0 -6300
  74. package/dist/workerd-DhrzU6AZ.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-Chn-m_r1.mjs","names":[],"sources":["../../prover-smt/src/emit.ts","../../prover-smt/src/z3.ts","../../prover-smt/src/prove.ts"],"sourcesContent":["/**\n * SMT-LIB 2 for a module in the subset and the properties on it, as Z3\n * reads it. `number` is the IEEE double (the floating-point theory, so\n * NaN, the infinities and -0 are in every binder's domain and `===` is\n * `fp.eq`, as in JavaScript), `string` a sequence of 16-bit code units,\n * `boolean` Bool, a record a datatype with one constructor, a tagged\n * union a datatype with one constructor per member holding that member's\n * record (so a record may be a member of several unions: a member is\n * wrapped where one of its unions is expected, and unwrapped where a test\n * of the tag narrows the union to it), a nullable type an\n * option datatype (`none`, `some`), with a name narrowed by a null check\n * bound to its value in the branch the check guards. Each property is one\n * script: the definitions, the binders as constants with what their\n * TypeScript types say beyond their sorts, the precondition asserted, the\n * claim's negation asserted, `check-sat`; an `unsat` is a proof, a model\n * is a candidate counterexample. Values in Z3's models are decoded back to\n * JavaScript values by this module too.\n */\n\nimport {\n type BinderRule,\n type Expr,\n isListExpr,\n OutsideSubset,\n type RecordType,\n readArrowBody,\n readBinderType,\n renameVars,\n type SubsetFunction,\n type SubsetModule,\n type SubsetType,\n type TypeContext,\n typeOf,\n} from \"@eutaxy/prover/reader\";\nimport type { Arrow, Property, SpecType } from \"@eutaxy/spec\";\n\nexport const F64 = \"(_ FloatingPoint 11 53)\";\nexport const STR = \"(Seq (_ BitVec 16))\";\n\n/** A name as an SMT-LIB symbol: simple when it can be, quoted with | otherwise. */\nexport function symbol(name: string): string {\n // A quoted symbol may hold anything but `|` and `\\`: those are escaped as `%7c` and `%5c`, with `%`\n // itself as `%25` first, in every name, so two names never meet in one symbol (a quoted symbol and\n // a simple one spelled alike are the same symbol; a record is named as the compiler prints its\n // type, which may spell any of them).\n const escaped = name.replace(/%/g, \"%25\").replace(/\\\\/g, \"%5c\").replace(/\\|/g, \"%7c\");\n return /^[A-Za-z~!@$%^&*_+=<>.?/-][A-Za-z0-9~!@$%^&*_+=<>.?/-]*$/.test(escaped)\n ? escaped\n : `|${escaped}|`;\n}\n\n/** TypeScript names as SMT symbols that cannot clash with each other or with the theories' names. */\nexport const ident = {\n fn: (name: string) => symbol(`f_${name}`),\n /** The datatype of a record, or of a union. */\n record: (name: string) => symbol(`R_${name}`),\n constructor: (name: string) => symbol(`mk_${name}`),\n /** A union's constructor for one member, holding the member's record, and its selector. */\n inject: (union: string, member: string) => symbol(`in.${union}.${member}`),\n project: (union: string, member: string) => symbol(`out.${union}.${member}`),\n // A dot, which no TypeScript identifier holds, so selectors of different records never coincide.\n field: (record: string, field: string) => symbol(`fld.${record}.${field}`),\n variable: (name: string) => symbol(`v_${name}`),\n /** The option datatype over a sort, and its constructors and selector. */\n option: (base: string) => symbol(`Opt.${base}`),\n none: (base: string) => symbol(`none.${base}`),\n some: (base: string) => symbol(`some.${base}`),\n val: (base: string) => symbol(`val.${base}`),\n};\n\n/** The short name a sort has inside option names: `Opt.F64`, `Opt.R_X`. */\nexport function sortName(t: SubsetType, module: SubsetModule): string {\n if (t.kind === \"list\" || t.kind === \"nothing\") return fail(listsOutside);\n switch (t.kind) {\n case \"int\":\n return \"F64\";\n case \"bool\":\n return \"Bool\";\n case \"string\":\n return \"Str\";\n case \"record\":\n case \"union\":\n return ident.record(t.name);\n case \"nullable\":\n return ident.option(sortName(t.inner, module));\n case \"null\":\n return fail(\"null has no sort of its own\");\n }\n}\n\nexport function sort(t: SubsetType, module: SubsetModule): string {\n if (t.kind === \"list\" || t.kind === \"nothing\") return fail(listsOutside);\n switch (t.kind) {\n case \"int\":\n return F64;\n case \"bool\":\n return \"Bool\";\n case \"string\":\n return STR;\n case \"record\":\n case \"union\":\n case \"nullable\":\n return sortName(t, module);\n case \"null\":\n return fail(\"null has no sort of its own\");\n }\n}\n\n/** A constructor applied: a bare symbol when there are no arguments. */\nfunction construct(name: string, values: readonly string[]): string {\n return values.length === 0\n ? ident.constructor(name)\n : `(${ident.constructor(name)} ${values.join(\" \")})`;\n}\n\n/** A double as a floating-point literal. */\nexport function numberTerm(n: number): string {\n if (Number.isNaN(n)) return \"(_ NaN 11 53)\";\n if (n === Number.POSITIVE_INFINITY) return \"(_ +oo 11 53)\";\n if (n === Number.NEGATIVE_INFINITY) return \"(_ -oo 11 53)\";\n if (Object.is(n, -0)) return \"(_ -zero 11 53)\";\n if (n === 0) return \"(_ +zero 11 53)\";\n // Exact bits, so a value round-trips whatever its magnitude.\n const view = new DataView(new ArrayBuffer(8));\n view.setFloat64(0, n);\n const bits = view.getBigUint64(0);\n const sign = (bits >> 63n) & 1n;\n const exponent = (bits >> 52n) & 0x7ffn;\n const significand = bits & ((1n << 52n) - 1n);\n return `(fp #b${sign} #b${exponent.toString(2).padStart(11, \"0\")} #b${significand.toString(2).padStart(52, \"0\")})`;\n}\n\n/** A JavaScript string as a sequence of its UTF-16 code units. */\nexport function stringTerm(s: string): string {\n if (s.length === 0) return `(as seq.empty ${STR})`;\n const units: string[] = [];\n for (let i = 0; i < s.length; i++)\n units.push(`(seq.unit #x${s.charCodeAt(i).toString(16).padStart(4, \"0\")})`);\n return units.length === 1 ? (units[0] as string) : `(seq.++ ${units.join(\" \")})`;\n}\n\ninterface Env {\n readonly module: SubsetModule;\n readonly ctx: TypeContext;\n /** Each node's type per scope, computed once: emission asks for types at every level. */\n readonly types: WeakMap<Expr, Map<string, SubsetType>>;\n}\n\nfunction env(module: SubsetModule): Env {\n return {\n module,\n types: new WeakMap(),\n ctx: {\n records: new Map(module.records.map((r) => [r.name, r])),\n unions: module.unions,\n signatures: new Map(\n module.functions.map((f) => [f.name, { params: f.params, returns: f.returns }]),\n ),\n },\n };\n}\n\n/** Why a list, or an operation on one, is refused here. */\nconst listsOutside = \"arrays are not in this engine's subset (the Lean engine takes them)\";\n\nconst fail: (message: string) => never = (message) => {\n throw new OutsideSubset(message, 0);\n};\n\n/** `Number.isInteger(x)`: finite and equal to its truncation. */\nfunction isIntegerTerm(x: string): string {\n return `(and (not (fp.isNaN ${x})) (not (fp.isInfinite ${x})) (fp.eq ${x} (fp.roundToIntegral RTZ ${x})))`;\n}\n\n/** The members of a union, as records, in declaration order. */\nfunction membersOf(union: string, env: Env): RecordType[] {\n const u = env.module.unions.find((x) => x.name === union) ?? fail(`no union ${union}`);\n return u.members.map((m) => env.ctx.records.get(m.record) ?? fail(`no record ${m.record}`));\n}\n\nconst tester = (constructorSymbol: string): string =>\n constructorSymbol.startsWith(\"|\")\n ? `|is-${constructorSymbol.slice(1)}`\n : `is-${constructorSymbol}`;\n\n/** `===` of two terms of a type, as JavaScript has it. */\nfunction sameAs(a: string, b: string, t: SubsetType, env: Env): string {\n if (t.kind === \"list\" || t.kind === \"nothing\") return fail(listsOutside);\n switch (t.kind) {\n case \"int\":\n return `(fp.eq ${a} ${b})`;\n case \"bool\":\n case \"string\":\n return `(= ${a} ${b})`;\n case \"nullable\": {\n const base = sortName(t.inner, env.module);\n return `(ite (and (${tester(ident.some(base))} ${a}) (${tester(ident.some(base))} ${b})) ${sameAs(`(${ident.val(base)} ${a})`, `(${ident.val(base)} ${b})`, t.inner, env)} (and (${tester(ident.none(base))} ${a}) (${tester(ident.none(base))} ${b})))`;\n }\n case \"record\":\n case \"union\":\n case \"null\":\n return fail(\"=== on records compares references in JavaScript; compare their fields instead\");\n }\n}\n\n/**\n * A term of type `actual` as a value of type `want`: a member record\n * wrapped in the union's constructor for it, a value wrapped in `some`\n * where a nullable is wanted, a nullable member mapped into the nullable\n * union. Anything else is already of the sort wanted.\n */\nfunction lift(inner: string, actual: SubsetType, want: SubsetType, module: SubsetModule): string {\n if (want.kind === \"union\" && actual.kind === \"record\")\n return `(${ident.inject(want.name, actual.name)} ${inner})`;\n if (want.kind !== \"nullable\") return inner;\n if (actual.kind === \"null\") return inner;\n if (actual.kind === \"nullable\") {\n if (want.inner.kind !== \"union\" || actual.inner.kind !== \"record\") return inner;\n const from = sortName(actual.inner, module);\n const to = sortName(want.inner, module);\n return `(ite (${tester(ident.none(from))} ${inner}) ${ident.none(to)} (${ident.some(to)} ${lift(`(${ident.val(from)} ${inner})`, actual.inner, want.inner, module)}))`;\n }\n return `(${ident.some(sortName(want.inner, module))} ${lift(inner, actual, want.inner, module)})`;\n}\n\n/**\n * A term of the expression's type, or of `expected` where one is given:\n * `null` and a non-null value become the option's constructors where a\n * nullable is expected, and a member record its union's where the union is.\n */\nexport function term(\n e: Expr,\n scope: ReadonlyMap<string, SubsetType>,\n env: Env,\n expected?: SubsetType,\n): string {\n const t = (x: Expr, want?: SubsetType) => term(x, scope, env, want);\n if (isListExpr(e)) return fail(listsOutside);\n // A node's type depends on the scope it is typed in (narrowing), so the memo is keyed by both.\n const typed = (x: Expr): SubsetType => {\n const key = JSON.stringify([...scope]);\n let byScope = env.types.get(x);\n if (!byScope) {\n byScope = new Map();\n env.types.set(x, byScope);\n }\n let found = byScope.get(key);\n if (!found) {\n found = typeOf(x, scope, env.ctx, fail);\n byScope.set(key, found);\n }\n return found;\n };\n // A value where `want` is expected: a conditional, a let or a narrowing produce the expected sort\n // themselves; anything else is lifted to it (`lift`).\n const coerceIn = (x: Expr, want: SubsetType, sc: ReadonlyMap<string, SubsetType>): string => {\n if (\n x.kind === \"cond\" ||\n x.kind === \"let\" ||\n x.kind === \"narrow\" ||\n x.kind === \"narrowTag\" ||\n x.kind === \"null\"\n )\n return term(x, sc, env, want);\n const actual = sc === scope ? typed(x) : typeOf(x, sc, env.ctx, fail);\n return lift(term(x, sc, env, want), actual, want, env.module);\n };\n const coerce = (x: Expr, want: SubsetType): string => coerceIn(x, want, scope);\n // A narrowed body is a value where the narrowing stands: coerced to what is expected there.\n const narrowed = (body: Expr, inner: ReadonlyMap<string, SubsetType>): string =>\n expected ? coerceIn(body, expected, inner) : term(body, inner, env);\n switch (e.kind) {\n case \"int\":\n return numberTerm(Number(e.value));\n case \"bool\":\n return e.value ? \"true\" : \"false\";\n case \"string\":\n return stringTerm(e.value);\n case \"null\":\n if (expected?.kind !== \"nullable\") fail(\"null where no nullable type is expected\");\n return ident.none(sortName(expected.inner, env.module));\n case \"var\":\n return ident.variable(e.name);\n case \"narrow\": {\n const nt = scope.get(e.name);\n if (nt?.kind !== \"nullable\") fail(`${e.name} is narrowed but is not a nullable`);\n const base = sortName(nt.inner, env.module);\n const inner = new Map(scope);\n inner.set(e.name, nt.inner);\n return `(let ((${ident.variable(e.name)} (${ident.val(base)} ${ident.variable(e.name)}))) ${narrowed(e.body, inner)})`;\n }\n case \"narrowTag\": {\n // The name is bound to the member's record inside the union's value (the guard the node sits\n // under makes the constructor the right one), typed as the member in the body.\n const nt = scope.get(e.name);\n if (nt?.kind !== \"union\") fail(`${e.name} is narrowed by a tag but is not a union`);\n const inner = new Map(scope);\n inner.set(e.name, { kind: \"record\", name: e.member });\n const v = ident.variable(e.name);\n return `(let ((${v} (${ident.project(nt.name, e.member)} ${v}))) ${narrowed(e.body, inner)})`;\n }\n case \"neg\":\n return `(fp.neg ${t(e.operand)})`;\n case \"not\":\n return `(not ${t(e.operand)})`;\n case \"isInteger\":\n return isIntegerTerm(t(e.operand));\n case \"floor\":\n // Math.floor: toward negative infinity, -0, NaN and the infinities kept, as IEEE 754 rounds.\n return `(fp.roundToIntegral RTN ${t(e.operand)})`;\n case \"binary\": {\n const lt = typed(e.left);\n const rt = typed(e.right);\n switch (e.op) {\n case \"+\":\n return lt.kind === \"string\"\n ? `(seq.++ ${t(e.left)} ${t(e.right)})`\n : `(fp.add RNE ${t(e.left)} ${t(e.right)})`;\n case \"-\":\n return `(fp.sub RNE ${t(e.left)} ${t(e.right)})`;\n case \"*\":\n return `(fp.mul RNE ${t(e.left)} ${t(e.right)})`;\n case \"/\":\n return `(fp.div RNE ${t(e.left)} ${t(e.right)})`;\n case \"<\":\n return `(fp.lt ${t(e.left)} ${t(e.right)})`;\n case \"<=\":\n return `(fp.leq ${t(e.left)} ${t(e.right)})`;\n case \">\":\n return `(fp.gt ${t(e.left)} ${t(e.right)})`;\n case \">=\":\n return `(fp.geq ${t(e.left)} ${t(e.right)})`;\n case \"===\":\n case \"!==\": {\n let eq: string;\n if (lt.kind === \"null\" || rt.kind === \"null\") {\n // Against null: whether the nullable side is none.\n const side = lt.kind === \"null\" ? e.right : e.left;\n const st = lt.kind === \"null\" ? rt : lt;\n if (st.kind !== \"nullable\")\n fail(\"a comparison with null of something that is not nullable\");\n eq = `(${tester(ident.none(sortName(st.inner, env.module)))} ${t(side)})`;\n } else if (lt.kind === \"nullable\" && rt.kind !== \"nullable\") {\n const base = sortName(lt.inner, env.module);\n eq = `(and (${tester(ident.some(base))} ${t(e.left)}) ${sameAs(`(${ident.val(base)} ${t(e.left)})`, t(e.right), lt.inner, env)})`;\n } else if (rt.kind === \"nullable\" && lt.kind !== \"nullable\") {\n const base = sortName(rt.inner, env.module);\n eq = `(and (${tester(ident.some(base))} ${t(e.right)}) ${sameAs(t(e.left), `(${ident.val(base)} ${t(e.right)})`, rt.inner, env)})`;\n } else eq = sameAs(t(e.left), t(e.right), lt, env);\n return e.op === \"===\" ? eq : `(not ${eq})`;\n }\n case \"&&\":\n return `(and ${t(e.left)} ${t(e.right)})`;\n case \"||\":\n return `(or ${t(e.left)} ${t(e.right)})`;\n }\n break;\n }\n case \"cond\": {\n // Both branches of one sort: the expected one, or what the branches share.\n const want = expected ?? typed(e);\n return `(ite ${t(e.test)} ${coerce(e.ifTrue, want)} ${coerce(e.ifFalse, want)})`;\n }\n case \"call\": {\n const sig = env.ctx.signatures.get(e.callee) ?? fail(`no signature for ${e.callee}`);\n const args = e.args.map((a, i) =>\n coerce(a, (sig.params[i] as (typeof sig.params)[number]).type),\n );\n return args.length === 0 ? ident.fn(e.callee) : `(${ident.fn(e.callee)} ${args.join(\" \")})`;\n }\n case \"field\": {\n const o = typed(e.object);\n const obj = t(e.object);\n if (o.kind === \"union\") {\n // The field every member has: read from whichever member the value is.\n const members = membersOf(o.name, env);\n return members.reduceRight<string | undefined>((rest, m) => {\n const read = `(${ident.field(m.name, e.field)} (${ident.project(o.name, m.name)} ${obj}))`;\n return rest === undefined\n ? read\n : `(ite (${tester(ident.inject(o.name, m.name))} ${obj}) ${read} ${rest})`;\n }, undefined) as string;\n }\n if (o.kind !== \"record\") fail(`field ${e.field} read from a ${o.kind}`);\n return `(${ident.field(o.name, e.field)} ${obj})`;\n }\n case \"record\": {\n const type = typed(e);\n if (type.kind !== \"record\") fail(\"a record literal of no record type\");\n const rec = env.ctx.records.get(type.name) ?? fail(`no record ${type.name}`);\n // Fields in the declaration's order, whatever order the literal wrote them in.\n const values = rec.fields.map((f) => {\n const given =\n e.fields.find((x) => x.name === f.name) ?? fail(`${type.name} literal without ${f.name}`);\n return coerce(given.value, f.type);\n });\n return construct(type.name, values);\n }\n case \"let\": {\n const inner = new Map(scope);\n const bound = e.type ?? typed(e.value);\n inner.set(e.name, bound);\n const value = e.type ? coerce(e.value, e.type) : t(e.value);\n // The body is the let's value: lifted to what is expected where the let stands.\n return `(let ((${ident.variable(e.name)} ${value})) ${narrowed(e.body, inner)})`;\n }\n }\n}\n\nexport function emitFunction(f: SubsetFunction, module: SubsetModule): string {\n const e = env(module);\n const scope = new Map(f.params.map((p) => [p.name, p.type]));\n const params = f.params\n .map((p) => `(${ident.variable(p.name)} ${sort(p.type, module)})`)\n .join(\" \");\n // The body as a value of the declared return type (`coerce` is local to `term`; the rule is repeated).\n const body = (() => {\n const b = f.body;\n if (\n b.kind === \"cond\" ||\n b.kind === \"let\" ||\n b.kind === \"narrow\" ||\n b.kind === \"narrowTag\" ||\n b.kind === \"null\"\n )\n return term(b, scope, e, f.returns);\n return lift(term(b, scope, e, f.returns), typeOf(b, scope, e.ctx, fail), f.returns, module);\n })();\n return `(define-fun ${ident.fn(f.name)} (${params}) ${sort(f.returns, module)}\\n ${body})`;\n}\n\n/**\n * An option sort over every sort the module could mention: the primitives,\n * every record, every union. A body may join a\n * value with `null` in a `const` that no signature shows, so nothing is\n * left to discovery.\n */\nfunction optionSorts(module: SubsetModule): Map<string, SubsetType> {\n const out = new Map<string, SubsetType>();\n const bases: SubsetType[] = [\n { kind: \"int\" },\n { kind: \"bool\" },\n { kind: \"string\" },\n ...module.records.map((r): SubsetType => ({ kind: \"record\", name: r.name })),\n ...module.unions.map((u): SubsetType => ({ kind: \"union\", name: u.name })),\n ];\n for (const b of bases) out.set(sortName(b, module), b);\n return out;\n}\n\n/**\n * Every datatype in one declaration, so records, unions and options may\n * refer to one another in any order: a record is one constructor, a union\n * one per member holding its record, an option `none` and `some` over its\n * base sort.\n */\nexport function emitDatatypes(module: SubsetModule): string {\n const plain = module.records;\n const unions = module.unions;\n const options = optionSorts(module);\n const names = [\n ...plain.map((r) => ident.record(r.name)),\n ...unions.map((u) => ident.record(u.name)),\n ...[...options.keys()].map((base) => ident.option(base)),\n ];\n if (names.length === 0) return \"\";\n const constructorOf = (r: RecordType): string =>\n `(${ident.constructor(r.name)}${r.fields.map((f) => ` (${ident.field(r.name, f.name)} ${sort(f.type, module)})`).join(\"\")})`;\n const bodies = [\n ...plain.map((r) => `(${constructorOf(r)})`),\n ...unions.map(\n (u) =>\n `(${u.members.map((m) => `(${ident.inject(u.name, m.record)} (${ident.project(u.name, m.record)} ${ident.record(m.record)}))`).join(\" \")})`,\n ),\n ...[...options].map(\n ([base, inner]) =>\n `((${ident.none(base)}) (${ident.some(base)} (${ident.val(base)} ${sort(inner, module)})))`,\n ),\n ];\n return `(declare-datatypes (${names.map((n) => `(${n} 0)`).join(\" \")}) (${bodies.join(\" \")}))`;\n}\n\n/** What this engine does not take of binder types: arrays, which the Lean engine takes. */\nexport const binderRule: BinderRule = { array: \"arrays are not in the engine's subset yet\" };\n\n/**\n * The subset type a binder ranges over, or `OutsideSubset`: `number` is\n * the double, a union of string literals is a string (constrained to the\n * literals in the script), a record is the module's datatype of that\n * name, `T | null` the option over `T`, a union of records the declared\n * union whose members match. Bigint and what the reader could not read\n * are outside. Read by the reader's `readBinderType` under `binderRule`.\n */\nexport function binderType(name: string, t: SpecType, module: SubsetModule): SubsetType {\n return readBinderType(name, t, module, binderRule);\n}\n\n/**\n * What a binder's subset type says that its sort does not: a union's\n * members carry their tags, and so on\n * into fields and under an option. Undefined when the sort says it all.\n */\nexport function wellFormed(\n target: string,\n t: SubsetType,\n module: SubsetModule,\n): string | undefined {\n switch (t.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n case \"null\":\n return undefined;\n case \"nullable\": {\n const base = sortName(t.inner, module);\n const inner = wellFormed(`(${ident.val(base)} ${target})`, t.inner, module);\n return inner === undefined\n ? undefined\n : `(or (${tester(ident.none(base))} ${target}) ${inner})`;\n }\n case \"record\": {\n const rec = module.records.find((r) => r.name === t.name);\n if (!rec) return undefined;\n const parts: string[] = [];\n for (const f of rec.fields) {\n const read = `(${ident.field(rec.name, f.name)} ${target})`;\n if (f.literal !== undefined)\n parts.push(\n typeof f.literal === \"string\"\n ? `(= ${read} ${stringTerm(f.literal)})`\n : `(= ${read} ${f.literal ? \"true\" : \"false\"})`,\n );\n const inner = wellFormed(read, f.type, module);\n if (inner !== undefined) parts.push(inner);\n }\n return parts.length === 0\n ? undefined\n : parts.length === 1\n ? parts[0]\n : `(and ${parts.join(\" \")})`;\n }\n case \"union\": {\n const u = module.unions.find((x) => x.name === t.name);\n if (!u) return undefined;\n const cases = u.members.map((m) => {\n const is = `(${tester(ident.inject(u.name, m.record))} ${target})`;\n const inner = wellFormed(\n `(${ident.project(u.name, m.record)} ${target})`,\n { kind: \"record\", name: m.record },\n module,\n );\n return inner === undefined ? is : `(and ${is} ${inner})`;\n });\n return `(or ${cases.join(\" \")})`;\n }\n }\n}\n\n/**\n * What a binder's TypeScript type says beyond its sort: a literal, or a\n * union of literals (with or without null), admits only those values,\n * which the solver must be told, since the sort alone would let it pick\n * any string or number.\n */\nexport function domainConstraint(\n symbolName: string,\n t: SpecType,\n subset: SubsetType,\n module: SubsetModule,\n): string | undefined {\n const literal = (target: string, v: string | number | boolean): string =>\n typeof v === \"string\"\n ? `(= ${target} ${stringTerm(v)})`\n : typeof v === \"number\"\n ? `(fp.eq ${target} ${numberTerm(v)})`\n : `(= ${target} ${v ? \"true\" : \"false\"})`;\n const literals: (string | number | boolean)[] = [];\n let withNull = false;\n if (t.kind === \"literal\") literals.push(t.value);\n else if (t.kind === \"union\") {\n for (const m of t.members) {\n if (m.kind === \"literal\") literals.push(m.value);\n else if (m.kind === \"null\") withNull = true;\n else return undefined;\n }\n } else return undefined;\n if (literals.length === 0) return undefined;\n const over = (target: string) => {\n const alternatives = literals.map((v) => literal(target, v));\n return alternatives.length === 1\n ? (alternatives[0] as string)\n : `(or ${alternatives.join(\" \")})`;\n };\n if (subset.kind === \"nullable\") {\n const base = sortName(subset.inner, module);\n const some = `(and (${tester(ident.some(base))} ${symbolName}) ${over(`(${ident.val(base)} ${symbolName})`)})`;\n return withNull ? `(or (${tester(ident.none(base))} ${symbolName}) ${some})` : some;\n }\n return over(symbolName);\n}\n\n/** An arrow of the spec file as a Bool term over the binders, its own parameter names renamed to theirs. */\nfunction arrowTerm(\n arrow: Arrow,\n what: \"when\" | \"ensures\",\n property: Property,\n types: readonly SubsetType[],\n e: Env,\n): string {\n try {\n const binders = property.binders;\n const scope = new Map<string, SubsetType>();\n const names = new Map<string, string>();\n arrow.params.forEach((p, i) => {\n const binder = binders[i];\n const type = types[i];\n if (p === null) fail(`a destructured parameter in ${what}`);\n if (!binder || !type) fail(`${what} takes more parameters than the function has`);\n scope.set(p, type);\n names.set(p, binder.name);\n });\n const aliases = new Map(property.imports.map((i) => [i.local, i.fn]));\n const read = readArrowBody(arrow, scope, e.module, aliases);\n const t = typeOf(read, scope, e.ctx, fail);\n if (t.kind !== \"bool\")\n fail(`${what} is not boolean (a ${t.kind === \"record\" ? t.name : t.kind})`);\n const renamed = renameVars(read, names);\n const binderScope = new Map(binders.map((b, i) => [b.name, types[i] as SubsetType]));\n return term(renamed, binderScope, e);\n } catch (err) {\n if (!(err instanceof OutsideSubset)) throw err;\n throw new OutsideSubset(`${what} (spec file line ${arrow.line}): ${err.message}`, arrow.line);\n }\n}\n\n/** The definitions every script of the module starts with: datatypes, then functions, callees first. */\nexport function prelude(module: SubsetModule): string {\n const datatypes = emitDatatypes(module);\n return [\n \";; Generated by Eutaxy's first-party SMT engine from the module and its spec file.\",\n \"(set-option :produce-models true)\",\n ...(datatypes === \"\" ? [] : [datatypes]),\n ...module.functions.map((f) => emitFunction(f, module)),\n ].join(\"\\n\");\n}\n\nexport interface PropertyScript {\n readonly script: string;\n /** The binders' SMT names and types, in order, for reading a model back. */\n readonly binders: readonly {\n readonly name: string;\n readonly symbol: string;\n readonly type: SubsetType;\n }[];\n}\n\n/**\n * One property's script: the binders as constants, what their types say\n * beyond their sorts, the precondition asserted, the claim's negation\n * asserted. `unsat` proves the claim; `sat` comes with the binders' values.\n * `definitions` is the module's `prelude`, when the caller already has it.\n */\nexport function propertyScript(\n property: Property,\n module: SubsetModule,\n definitions: string = prelude(module),\n): PropertyScript {\n if (property.kind !== \"forall\" || !property.ensures) fail(\"not a forall property\");\n const e = env(module);\n const types = property.binders.map((b) => binderType(b.name, b.type, module));\n const binders = property.binders.map((b, i) => ({\n name: b.name,\n symbol: ident.variable(b.name),\n type: types[i] as SubsetType,\n }));\n const lines = [\n definitions,\n ...binders.map((b) => `(declare-const ${b.symbol} ${sort(b.type, module)})`),\n // What a binder's subset type says that its sort does not: which member of a union, which tags.\n ...binders.flatMap((b) => {\n const c = wellFormed(b.symbol, b.type, module);\n return c === undefined ? [] : [`(assert ${c})`];\n }),\n ...property.binders.flatMap((b, i) => {\n const c = domainConstraint(\n (binders[i] as (typeof binders)[number]).symbol,\n b.type,\n types[i] as SubsetType,\n module,\n );\n return c === undefined ? [] : [`(assert ${c})`];\n }),\n ...(property.when ? [`(assert ${arrowTerm(property.when, \"when\", property, types, e)})`] : []),\n `(assert (not ${arrowTerm(property.ensures, \"ensures\", property, types, e)}))`,\n \"(check-sat)\",\n ...(binders.length > 0 ? [`(get-value (${binders.map((b) => b.symbol).join(\" \")}))`] : []),\n \"(get-info :reason-unknown)\",\n ];\n return { script: `${lines.join(\"\\n\")}\\n`, binders };\n}\n\n/** A TypeScript value of a subset type as a term, for translation checks. */\nexport function value(v: unknown, t: SubsetType, module: SubsetModule): string {\n if (t.kind === \"list\" || t.kind === \"nothing\") return fail(listsOutside);\n switch (t.kind) {\n case \"int\":\n if (typeof v !== \"number\") fail(`${String(v)} is not a number`);\n return numberTerm(v);\n case \"bool\":\n if (typeof v !== \"boolean\") fail(`${String(v)} is not a boolean`);\n return v ? \"true\" : \"false\";\n case \"string\":\n if (typeof v !== \"string\") fail(`${String(v)} is not a string`);\n return stringTerm(v);\n case \"nullable\": {\n const base = sortName(t.inner, module);\n return v === null ? ident.none(base) : `(${ident.some(base)} ${value(v, t.inner, module)})`;\n }\n case \"union\": {\n const u = module.unions.find((x) => x.name === t.name) ?? fail(`no union ${t.name}`);\n if (typeof v !== \"object\" || v === null) fail(`${String(v)} is not a ${t.name}`);\n const tag = (v as Record<string, unknown>)[u.tag];\n const member =\n u.members.find((m) => m.tag === tag) ?? fail(`${t.name} value with tag ${String(tag)}`);\n return `(${ident.inject(u.name, member.record)} ${value(v, { kind: \"record\", name: member.record }, module)})`;\n }\n case \"record\": {\n const rec = module.records.find((r) => r.name === t.name) ?? fail(`no record ${t.name}`);\n if (typeof v !== \"object\" || v === null) fail(`${String(v)} is not a record`);\n const o = v as Record<string, unknown>;\n const extra = Object.keys(o).filter((k) => !rec.fields.some((f) => f.name === k));\n if (extra.length > 0) fail(`${t.name} value has unexpected fields ${extra.join(\", \")}`);\n return construct(\n t.name,\n rec.fields.map((f) => value(o[f.name], f.type, module)),\n );\n }\n case \"null\":\n return fail(\"a value of type null\");\n }\n}\n\n/** Equality of two terms of a type, as JavaScript would have it: `fp.eq` on numbers, field by field on records. */\nexport function equal(a: string, b: string, t: SubsetType, module: SubsetModule): string {\n if (t.kind === \"list\" || t.kind === \"nothing\") return fail(listsOutside);\n switch (t.kind) {\n case \"int\":\n return `(fp.eq ${a} ${b})`;\n case \"bool\":\n case \"string\":\n return `(= ${a} ${b})`;\n case \"nullable\": {\n const base = sortName(t.inner, module);\n return `(ite (and (${tester(ident.some(base))} ${a}) (${tester(ident.some(base))} ${b})) ${equal(`(${ident.val(base)} ${a})`, `(${ident.val(base)} ${b})`, t.inner, module)} (and (${tester(ident.none(base))} ${a}) (${tester(ident.none(base))} ${b})))`;\n }\n case \"union\": {\n const u = module.unions.find((x) => x.name === t.name) ?? fail(`no union ${t.name}`);\n const cases = u.members.map((m) => {\n const is = tester(ident.inject(u.name, m.record));\n const out = ident.project(u.name, m.record);\n return `(and (${is} ${a}) (${is} ${b}) ${equal(`(${out} ${a})`, `(${out} ${b})`, { kind: \"record\", name: m.record }, module)})`;\n });\n return `(or ${cases.join(\" \")})`;\n }\n case \"record\": {\n const rec = module.records.find((r) => r.name === t.name) ?? fail(`no record ${t.name}`);\n const fields = rec.fields.map((f) =>\n equal(\n `(${ident.field(t.name, f.name)} ${a})`,\n `(${ident.field(t.name, f.name)} ${b})`,\n f.type,\n module,\n ),\n );\n if (fields.length === 0) return \"true\";\n return fields.length === 1 ? (fields[0] as string) : `(and ${fields.join(\" \")})`;\n }\n case \"null\":\n return fail(\"equality at type null\");\n }\n}\n\n// ---------------------------------------------------------------------------\n// Reading Z3's answers.\n\nexport type SExpr = string | readonly SExpr[];\n\n/** Z3's output as S-expressions and atoms, in order. */\nexport function parseSExprs(text: string): SExpr[] {\n const out: SExpr[] = [];\n const stack: SExpr[][] = [];\n let i = 0;\n const push = (x: SExpr) => {\n const top = stack[stack.length - 1];\n if (top) top.push(x);\n else out.push(x);\n };\n while (i < text.length) {\n const c = text[i] as string;\n if (/\\s/.test(c)) {\n i++;\n continue;\n }\n if (c === \";\") {\n while (i < text.length && text[i] !== \"\\n\") i++;\n continue;\n }\n if (c === \"(\") {\n stack.push([]);\n i++;\n continue;\n }\n if (c === \")\") {\n const done = stack.pop();\n if (done) push(done);\n i++;\n continue;\n }\n if (c === '\"') {\n let j = i + 1;\n let s = \"\";\n while (j < text.length) {\n if (text[j] === '\"' && text[j + 1] === '\"') {\n s += '\"';\n j += 2;\n } else if (text[j] === '\"') break;\n else s += text[j++];\n }\n push(`\"${s}\"`);\n i = j + 1;\n continue;\n }\n if (c === \"|\") {\n const j = text.indexOf(\"|\", i + 1);\n push(text.slice(i, j < 0 ? text.length : j + 1));\n i = j < 0 ? text.length : j + 1;\n continue;\n }\n let j = i;\n while (j < text.length && !/[\\s()]/.test(text[j] as string)) j++;\n push(text.slice(i, j));\n i = j;\n }\n while (stack.length > 0) {\n const done = stack.pop();\n if (done) push(done);\n }\n return out;\n}\n\n/** Thrown when a model value is not of the shape the type calls for. */\nexport class UnreadableModel extends Error {}\n\nconst bitsOf = (atom: string): bigint =>\n atom.startsWith(\"#b\") ? BigInt(`0b${atom.slice(2)}`) : BigInt(`0x${atom.slice(2)}`);\n\n/** A model value of the type as a JavaScript value. */\nexport function decode(x: SExpr, t: SubsetType, module: SubsetModule): unknown {\n switch (t.kind) {\n case \"bool\":\n if (x === \"true\") return true;\n if (x === \"false\") return false;\n throw new UnreadableModel(`not a boolean: ${show(x)}`);\n case \"int\": {\n if (Array.isArray(x) && x[0] === \"_\") {\n const special = x[1];\n if (special === \"NaN\") return Number.NaN;\n if (special === \"+oo\") return Number.POSITIVE_INFINITY;\n if (special === \"-oo\") return Number.NEGATIVE_INFINITY;\n if (special === \"+zero\") return 0;\n if (special === \"-zero\") return -0;\n }\n if (Array.isArray(x) && x[0] === \"fp\" && x.length === 4) {\n const sign = bitsOf(x[1] as string);\n const exponent = bitsOf(x[2] as string);\n const significand = bitsOf(x[3] as string);\n const view = new DataView(new ArrayBuffer(8));\n view.setBigUint64(0, (sign << 63n) | (exponent << 52n) | significand);\n return view.getFloat64(0);\n }\n throw new UnreadableModel(`not a double: ${show(x)}`);\n }\n case \"string\":\n return decodeString(x);\n case \"nullable\": {\n const base = sortName(t.inner, module);\n if (x === ident.none(base)) return null;\n if (Array.isArray(x) && x[0] === ident.some(base) && x.length === 2)\n return decode(x[1] as SExpr, t.inner, module);\n throw new UnreadableModel(`not a ${describeSubset(t)}: ${show(x)}`);\n }\n case \"union\": {\n const u = module.unions.find((y) => y.name === t.name);\n if (!u) throw new UnreadableModel(`no union ${t.name}`);\n const head = Array.isArray(x) ? x[0] : x;\n const member = u.members.find((m) => ident.inject(u.name, m.record) === head);\n if (!member || !Array.isArray(x) || x.length !== 2)\n throw new UnreadableModel(`not a ${t.name}: ${show(x)}`);\n return decode(x[1] as SExpr, { kind: \"record\", name: member.record }, module);\n }\n case \"record\": {\n const rec = module.records.find((r) => r.name === t.name);\n if (!rec) throw new UnreadableModel(`no record ${t.name}`);\n if (rec.fields.length === 0 && x === ident.constructor(t.name)) return {};\n if (\n !Array.isArray(x) ||\n x[0] !== ident.constructor(t.name) ||\n x.length !== rec.fields.length + 1\n )\n throw new UnreadableModel(`not a ${t.name}: ${show(x)}`);\n const out: Record<string, unknown> = {};\n rec.fields.forEach((f, i) => {\n out[f.name] = decode(x[i + 1] as SExpr, f.type, module);\n });\n return out;\n }\n case \"null\":\n throw new UnreadableModel(\"a value of type null\");\n }\n}\n\nfunction describeSubset(t: SubsetType): string {\n return t.kind === \"nullable\"\n ? `${describeSubset(t.inner)} | null`\n : t.kind === \"record\" || t.kind === \"union\"\n ? t.name\n : t.kind;\n}\n\nfunction decodeString(x: SExpr): string {\n if (Array.isArray(x)) {\n if (x[0] === \"seq.unit\" && typeof x[1] === \"string\")\n return String.fromCharCode(Number(bitsOf(x[1])));\n if (x[0] === \"seq.++\") return x.slice(1).map(decodeString).join(\"\");\n if (x[0] === \"as\" && x[1] === \"seq.empty\") return \"\";\n if (x[0] === \"_\" && x[1] === \"seq.empty\") return \"\";\n }\n throw new UnreadableModel(`not a string: ${show(x)}`);\n}\n\nfunction show(x: SExpr): string {\n return typeof x === \"string\" ? x : `(${x.map(show).join(\" \")})`;\n}\n\nexport interface Answer {\n readonly result: \"sat\" | \"unsat\" | \"unknown\" | \"error\";\n /** The binders' values when `sat`, by SMT symbol. */\n readonly values: ReadonlyMap<string, SExpr>;\n readonly reason: string;\n /** Every `(error …)` Z3 printed, except the one for a model asked after `unsat`, which the script expects. */\n readonly errors: readonly string[];\n}\n\n/** What a property's script came back with. */\nexport function readAnswer(output: string): Answer {\n const parts = parseSExprs(output);\n const first = parts.find((p) => p === \"sat\" || p === \"unsat\" || p === \"unknown\");\n const errors = parts\n .filter((p): p is readonly SExpr[] => Array.isArray(p) && p[0] === \"error\")\n .map((e) => show(e))\n .filter((e) => !/model is not available/.test(e));\n const values = new Map<string, SExpr>();\n let reason = \"\";\n for (const p of parts) {\n if (!Array.isArray(p)) continue;\n if (p[0] === \":reason-unknown\" && typeof p[1] === \"string\") reason = p[1].replace(/^\"|\"$/g, \"\");\n if (p.every((x) => Array.isArray(x) && x.length === 2 && typeof x[0] === \"string\"))\n for (const pair of p as readonly (readonly [string, SExpr])[]) values.set(pair[0], pair[1]);\n }\n if (first === undefined)\n return { result: \"error\", values, reason: errors.join(\"; \") || output.trim(), errors };\n return { result: first as Answer[\"result\"], values, reason, errors };\n}\n","/**\n * Running Z3 over a process boundary. The engine is pinned to one Z3\n * release, looked for in Eutaxy's cache first (where `eutaxy prover install\n * smt` puts the upstream release named in `z3Downloads`), then as a `z3`\n * on the PATH (or in Homebrew's and the usual local prefixes) that must\n * report that version. Nothing is downloaded during a check; a missing\n * solver is `unavailable`, with how to install it. Every\n * run carries a resource limit, Z3's own machine-independent budget, so\n * the same script gives the same outcome on every machine; a wall-clock\n * timeout is only the safety net.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { type Host, host, installed, type Toolchain } from \"@eutaxy/prover/toolchain\";\n\n/** The Z3 release the engine's contract corpus is checked against. */\nexport const z3Version = \"5.3.2\";\n/** How to put the pinned solver on this machine. */\nexport const installHint = `run: eutaxy prover install smt (or put Z3 ${z3Version} on the PATH, from https://github.com/Z3Prover/z3/releases/tag/z3-${z3Version} or Homebrew: brew install z3)`;\n\nconst z3Release = `https://github.com/Z3Prover/z3/releases/download/z3-${z3Version}`;\n/** The files the solver needs on Linux and macOS: the executable, which links only system libraries. */\nconst unixFiles = [\"bin/z3\"];\n/**\n * On Windows the executable also needs the Visual C++ runtime, which a fresh\n * Windows may lack; the release ships it beside `z3.exe`, and Windows loads\n * a DLL from the executable's own directory first.\n */\nconst windowsFiles = [\n \"bin/z3.exe\",\n \"bin/msvcp140.dll\",\n \"bin/vcruntime140.dll\",\n \"bin/vcruntime140_1.dll\",\n];\nconst z3File = (name: string, sha256: string, bytes: number, files: readonly string[]) => ({\n file: name,\n url: `${z3Release}/${name}`,\n sha256,\n bytes,\n // Each release puts everything under one directory named like the file.\n entries: Object.fromEntries(files.map((f) => [`${name.replace(/\\.zip$/, \"\")}/${f}`, f])),\n});\n/**\n * The upstream release files `eutaxy prover install smt` downloads, one per\n * platform, as published on Z3's GitHub release with the checksums it\n * reports, and the files taken from each (the rest of the zip, bindings for\n * other languages, headers and the shared library, is not unpacked); the\n * file names carry the version, and a test holds them to `z3Version`. The\n * Linux builds need glibc 2.39 (x64) or 2.38 (arm64).\n */\nexport const z3Downloads: Toolchain = {\n name: \"smt\",\n version: z3Version,\n executable: \"bin/z3\",\n files: {\n \"linux-x64\": z3File(\n \"z3-5.3.2-x64-glibc-2.39.zip\",\n \"26d463cddad3901cbf86e3868c784914539f4e3f9b4de1a0b8dc2969806d60e2\",\n 69479256,\n unixFiles,\n ),\n \"linux-arm64\": z3File(\n \"z3-5.3.2-arm64-glibc-2.38.zip\",\n \"30b6a718a6cfe1b2db056038cc32eda5410f6d02e5937622b5238645347f59d5\",\n 64803341,\n unixFiles,\n ),\n \"darwin-x64\": z3File(\n \"z3-5.3.2-x64-osx-13.3.zip\",\n \"b911dc193f7447a14fba001e8e8a0c2866a544274bb003e76a9e864f03b4d557\",\n 54270076,\n unixFiles,\n ),\n \"darwin-arm64\": z3File(\n \"z3-5.3.2-arm64-osx-13.3.zip\",\n \"524290057c943a044ec3d1372db65a9c93f333d9817d58191154c4719ff7f8ad\",\n 53576249,\n unixFiles,\n ),\n \"win32-x64\": z3File(\n \"z3-5.3.2-x64-win.zip\",\n \"a75aa2b0383a8ee355387a54daad796911d6a965076751eea18d21a27f38e983\",\n 70867398,\n windowsFiles,\n ),\n },\n};\n/** The resource budget a check runs under (Z3's `rlimit`, in its own units), unless configured. */\nexport const defaultResourceLimit = 50_000_000;\n\nexport interface Z3Run {\n readonly code: number | null;\n readonly stdout: string;\n readonly stderr: string;\n readonly timedOut: boolean;\n}\n\nexport interface Z3Solver {\n readonly command: string;\n readonly version: string;\n}\n\nfunction run(\n command: string,\n args: readonly string[],\n options: { readonly cwd?: string; readonly timeoutMs: number },\n): Promise<Z3Run> {\n return new Promise((resolve) => {\n let child: ReturnType<typeof spawn>;\n try {\n child = spawn(command, args, { cwd: options.cwd, stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n } catch (err) {\n resolve({ code: null, stdout: \"\", stderr: String(err), timedOut: false });\n return;\n }\n let stdout = \"\";\n let stderr = \"\";\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGKILL\");\n }, options.timeoutMs);\n child.stdout?.on(\"data\", (d: Buffer) => {\n stdout += d.toString();\n });\n child.stderr?.on(\"data\", (d: Buffer) => {\n stderr += d.toString();\n });\n child.on(\"error\", (err) => {\n clearTimeout(timer);\n resolve({ code: null, stdout, stderr: `${stderr}${String(err)}`, timedOut });\n });\n child.on(\"close\", (code) => {\n clearTimeout(timer);\n resolve({ code, stdout, stderr, timedOut });\n });\n });\n}\n\n/**\n * Candidates for the `z3` executable: the one `eutaxy prover install smt`\n * put in the cache, `EUTAXY_Z3`, the PATH, then the prefixes package\n * managers install into.\n */\nexport function candidates(h: Host = host()): string[] {\n const fromEnv = h.env[\"EUTAXY_Z3\"];\n const fromCache = installed(z3Downloads, h);\n return [\n ...(fromCache ? [fromCache.executable] : []),\n ...(fromEnv ? [fromEnv] : []),\n \"z3\",\n \"/opt/homebrew/bin/z3\",\n \"/usr/local/bin/z3\",\n \"/usr/bin/z3\",\n ];\n}\n\n/**\n * The pinned solver if it is installed: a `z3` of exactly that version,\n * wherever among the candidates it is; another version is reported only\n * when no candidate is the pinned one.\n */\nexport async function findZ3(\n where: readonly string[] = candidates(),\n): Promise<Z3Solver | { readonly unavailable: string }> {\n let other: string | undefined;\n for (const z3 of where) {\n const v = await run(z3, [\"--version\"], { timeoutMs: 20_000 });\n if (v.code !== 0) continue;\n const m = /Z3 version (\\S+)/.exec(v.stdout);\n if (m?.[1] === z3Version) return { command: z3, version: z3Version };\n other ??= m?.[1] ?? \"of unknown version\";\n }\n if (other !== undefined)\n return {\n unavailable: `z3 ${other} found, but the engine is pinned to ${z3Version}; ${installHint}`,\n };\n return { unavailable: `no z3 found; ${installHint}` };\n}\n\nexport interface SolvedScript {\n readonly run: Z3Run;\n /** Whether Z3 reported the resource limit exceeded. */\n readonly resourceLimit: boolean;\n}\n\n/** Write the script to a scratch file and run Z3 on it under the resource limit. */\nexport async function solve(\n solver: Z3Solver,\n script: string,\n options: {\n readonly timeoutMs?: number;\n readonly resourceLimit?: number;\n readonly keep?: boolean;\n } = {},\n): Promise<SolvedScript> {\n const dir = mkdtempSync(join(tmpdir(), \"eutaxy-smt-\"));\n try {\n const file = join(dir, \"property.smt2\");\n writeFileSync(file, script);\n const result = await run(\n solver.command,\n [`rlimit=${options.resourceLimit ?? defaultResourceLimit}`, \"-smt2\", file],\n { cwd: dir, timeoutMs: options.timeoutMs ?? 120_000 },\n );\n return { run: result, resourceLimit: /resource limit/i.test(result.stdout) };\n } finally {\n if (!options.keep) rmSync(dir, { recursive: true, force: true });\n }\n}\n","/**\n * The engine: a module's functions through the subset reader, the emitter\n * and Z3, one script per property, and each property's outcome back. An\n * `unsat` is `PROVEN` under the engine's models of the language. A model\n * is a candidate counterexample, never a verdict: the engine runs the\n * spec file's own `when` and `ensures` on it, and only a claim that fails\n * on the real function is `REFUTED`, with the input shrunk as the TESTED\n * rung shrinks; a model the function does not confirm is a modelling gap,\n * `UNKNOWN` (`unsupported`) with the input. A resource limit reached is\n * `gave_up`; a function or property outside the subset is `unsupported`;\n * no pinned solver is `unavailable`.\n */\n\nimport { existsSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { availableParallelism } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n conforms,\n evaluate,\n inPool,\n type ModuleProofs,\n type ProofOutcome,\n type PropertyProof,\n type Prover,\n type ProveInput as ProverInput,\n proofsOf,\n render,\n shrinkRefutation,\n unknownOutcome,\n} from \"@eutaxy/prover\";\nimport {\n builtinsAssumption,\n engineGap,\n listKinds,\n OutsideSubset,\n outsideProofs,\n readForEngine,\n type SubsetModule,\n} from \"@eutaxy/prover/reader\";\nimport { type Fn, type Forall, type FunctionSpec, isSpec, type Property } from \"@eutaxy/spec\";\nimport {\n decode,\n equal,\n type PropertyScript,\n prelude,\n propertyScript,\n readAnswer,\n UnreadableModel,\n} from \"./emit.ts\";\nimport { findZ3, solve, z3Version } from \"./z3.ts\";\n\nexport const engineName = \"smt\";\n\nexport interface ProveInput extends ProverInput {\n /** Extra Bool terms over the module's definitions that must hold (translation checks): each is checked unsatisfiable when negated. */\n readonly extra?: readonly string[];\n /** Z3's resource budget per property, in its own units. */\n readonly resourceLimit?: number;\n}\n\n/** This engine's report, with the definitions it ran. */\nexport interface SmtModuleProofs extends ModuleProofs {\n /** The prelude shared by every script, when any function was in the subset. */\n readonly smt?: string;\n}\n\n/** What every PROVEN verdict of this engine rests on. */\nexport const engineAssumptions: readonly string[] = [\n \"number is modelled as the IEEE double (the floating-point theory): NaN, the infinities and -0 are in every binder's domain, and === is fp.eq\",\n \"string is modelled as a sequence of 16-bit code units, as JavaScript holds it\",\n \"the function and its callees are pure and total: the module's own, or generic or imported ones read at each call from their own files; nothing else is modelled\",\n builtinsAssumption,\n `Z3 ${z3Version} found the claim's negation unsatisfiable under a resource limit; no proof object was checked by a kernel`,\n];\n\nconst proven: Extract<ProofOutcome, { kind: \"PROVEN\" }> = {\n kind: \"PROVEN\",\n engine: { name: engineName, version: z3Version },\n assumptions: engineAssumptions,\n};\n\nconst unknown = unknownOutcome;\n\n/** The scripts for the module's functions in the subset, and the functions with specs outside it with why. */\nexport interface Prepared {\n readonly module: SubsetModule;\n readonly fns: readonly FunctionSpec[];\n readonly outside: ReadonlyMap<string, string>;\n /** One script per statable forall property. */\n readonly scripts: ReadonlyMap<string, PropertyScript>;\n /** Properties the emitter could not state, with why. */\n readonly skipped: ReadonlyMap<string, string>;\n readonly prelude: string;\n}\n\nconst key = (fn: string, property: string): string => `${fn}\\u0000${property}`;\n\n/** Read and emit: every function the subset takes, and a script per property of the ones with specs. */\nexport function prepare(input: ProveInput): Prepared {\n // Lists are read, but this engine does not take them: functions using one are outside here, so the\n // prelude never meets them and the module's other functions still go through.\n const read = readForEngine(input, [\n {\n takes: (t) => t.kind !== \"list\" && t.kind !== \"nothing\",\n reason: \"arrays are not in this engine's subset (the Lean engine takes them)\",\n bodies: listKinds,\n },\n ]);\n const { module, fns, outside } = read;\n const scripts = new Map<string, PropertyScript>();\n const skipped = new Map<string, string>();\n let pre = \"\";\n try {\n pre = prelude(module);\n for (const fn of fns) {\n if (outside.has(fn.name)) continue;\n for (const property of fn.properties) {\n if (property.kind !== \"forall\") continue;\n try {\n scripts.set(key(fn.name, property.name), propertyScript(property, module, pre));\n } catch (err) {\n if (!(err instanceof OutsideSubset)) throw err;\n skipped.set(key(fn.name, property.name), err.message);\n }\n }\n }\n } catch (err) {\n // The emitter refusing something the reader let through is an engine gap: every function is unsupported, none guessed.\n if (!(err instanceof OutsideSubset)) throw err;\n engineGap(read, err.message);\n scripts.clear();\n }\n return { module, fns, outside, scripts, skipped, prelude: pre };\n}\n\n/**\n * The spec file as a module. A relative import written without `.ts`\n * (`./domain`, `./domain.js`), which the simulator's loader resolves and\n * Node does not, is completed in a sibling copy that is imported and then\n * removed, so the copy's own relative imports still resolve.\n */\n/** Names each sibling copy apart from another made in the same millisecond. */\nlet copies = 0;\n\nasync function importSpecFile(specPath: string): Promise<Record<string, unknown>> {\n try {\n return (await import(pathToFileURL(specPath).href)) as Record<string, unknown>;\n } catch (err) {\n const code = (err as { code?: string }).code;\n if (code !== \"ERR_MODULE_NOT_FOUND\" && code !== \"ERR_UNSUPPORTED_DIR_IMPORT\") throw err;\n const source = readFileSync(specPath, \"utf8\");\n const dir = dirname(specPath);\n const rewritten = source.replace(\n /(from\\s*[\"'])(\\.{1,2}\\/[^\"']+?)(\\.js)?([\"'])/g,\n (whole, pre: string, rel: string, _js: string | undefined, post: string) =>\n existsSync(join(dir, `${rel}.ts`)) ? `${pre}${rel}.ts${post}` : whole,\n );\n if (rewritten === source) throw err;\n const copy = join(dir, `.eutaxy-replay-${process.pid}-${Date.now()}-${copies++}.props.ts`);\n writeFileSync(copy, rewritten);\n try {\n return (await import(pathToFileURL(copy).href)) as Record<string, unknown>;\n } finally {\n rmSync(copy, { force: true });\n }\n }\n}\n\n/**\n * The spec file, imported once per proof of a module: every counterexample\n * that module's solves turn up is replayed through the same import (the\n * solves run side by side, and a sibling copy each would be one import\n * removing another's file mid-import).\n */\ntype SpecLoader = (specPath: string) => Promise<Record<string, unknown>>;\n\nfunction specLoader(): SpecLoader {\n const loaded = new Map<string, Promise<Record<string, unknown>>>();\n return (specPath) => {\n let ns = loaded.get(specPath);\n if (ns === undefined) {\n ns = importSpecFile(specPath);\n loaded.set(specPath, ns);\n }\n return ns;\n };\n}\n\n/** The spec file's export for a property, loaded for replay, or why it could not be. */\nasync function loadSpec(\n load: SpecLoader,\n specPath: string | undefined,\n property: Property,\n fn: string,\n): Promise<Forall<Fn> | string> {\n if (specPath === undefined)\n return \"the engine was not given the spec file's path to replay the counterexample\";\n let ns: Record<string, unknown>;\n try {\n ns = await load(specPath);\n } catch (err) {\n return `the spec file could not be loaded to replay the counterexample: ${String(err)}`;\n }\n const exported = Object.hasOwn(ns, property.name) ? ns[property.name] : undefined;\n if (!isSpec(exported) || exported.kind !== \"forall\")\n return `the spec file exports no forall named ${property.name} to replay the counterexample with`;\n if (typeof exported.fn !== \"function\" || exported.fn.name !== fn)\n return `the spec file's ${property.name} is not on ${fn}`;\n return exported;\n}\n\n/** Prove a module's properties with the pinned Z3. */\nexport async function proveModule(input: ProveInput): Promise<SmtModuleProofs> {\n const { fns, outside, scripts, skipped, module, prelude: smt } = prepare(input);\n const specErrors = input.specs.errors;\n const inSubset = fns.filter((f) => !outside.has(f.name));\n const results: PropertyProof[] = outsideProofs(fns, outside);\n if (inSubset.length === 0) return { results, specErrors };\n const allWith = (outcome: ProofOutcome): SmtModuleProofs => ({\n results: [...results, ...proofsOf(inSubset, outcome)],\n smt,\n specErrors,\n });\n const solver = await findZ3();\n if (\"unavailable\" in solver) return allWith(unknown(\"unavailable\", solver.unavailable));\n const options = {\n ...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),\n ...(input.resourceLimit === undefined ? {} : { resourceLimit: input.resourceLimit }),\n };\n // Translation checks first: a definition that does not compute what the TypeScript computes is an engine gap.\n if (input.extra && input.extra.length > 0) {\n const script = [\n smt,\n ...input.extra.flatMap((x) => [\"(push)\", `(assert (not ${x}))`, \"(check-sat)\", \"(pop)\"]),\n \"\",\n ].join(\"\\n\");\n const checked = await solve(solver, script, options);\n const answers = checked.run.stdout\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter((l) => /^(sat|unsat|unknown)$/.test(l));\n if (checked.run.timedOut)\n return allWith(unknown(\"gave_up\", \"Z3 did not finish the translation checks in time\"));\n // The budget ran out on a check: nothing is known about the definitions, and nothing is claimed.\n if (answers.includes(\"unknown\"))\n return allWith(unknown(\"gave_up\", \"Z3 reached its resource limit on a translation check\"));\n const failed = answers.findIndex((a) => a !== \"unsat\");\n const errors = readAnswer(checked.run.stdout).errors;\n if (\n checked.run.code !== 0 ||\n errors.length > 0 ||\n answers.length !== input.extra.length ||\n failed >= 0\n )\n return allWith(\n unknown(\n \"unsupported\",\n `the emitted SMT failed a translation check${failed >= 0 ? ` (${input.extra[failed]})` : \"\"}: ${errors[0] ?? (checked.run.stderr || checked.run.stdout).trim().split(\"\\n\")[0] ?? \"\"}`,\n ),\n );\n }\n // One Z3 process per property, several at once (no more than the machine's cores, so each run keeps\n // about a core): each outcome rests on Z3's resource limit, with the wall-clock timeout a backstop far\n // above what a property takes, and the results keep the properties' order. (Not one process with\n // push/pop: incremental mode can answer differently.)\n const load = specLoader();\n const jobs = inSubset.flatMap((fn) => fn.properties.map((property) => ({ fn, property })));\n const proofs = await inPool(\n jobs,\n Math.min(8, availableParallelism()),\n async ({ fn, property }): Promise<PropertyProof | undefined> => {\n if (property.kind === \"total\")\n return {\n function: fn.name,\n property: property.name,\n outcome: unknown(\n \"unsupported\",\n \"total is not decided by this engine (Lean proves it by acceptance)\",\n ),\n };\n const k = key(fn.name, property.name);\n const why = skipped.get(k);\n if (why !== undefined)\n return { function: fn.name, property: property.name, outcome: unknown(\"unsupported\", why) };\n const script = scripts.get(k);\n if (!script) return undefined;\n const solved = await solve(solver, script.script, options);\n return {\n function: fn.name,\n property: property.name,\n outcome: await outcomeOf(solved, script, module, property, fn.name, input, load),\n };\n },\n );\n for (const proof of proofs) if (proof) results.push(proof);\n return { results, smt, specErrors };\n}\n\nasync function outcomeOf(\n solved: Awaited<ReturnType<typeof solve>>,\n script: PropertyScript,\n module: SubsetModule,\n property: Property,\n fn: string,\n input: ProveInput,\n load: SpecLoader,\n): Promise<ProofOutcome> {\n if (solved.run.timedOut)\n return unknown(\"gave_up\", `Z3 did not finish within ${input.timeoutMs ?? 120_000} ms`);\n if (solved.run.code === null)\n return unknown(\"unavailable\", `Z3 could not be run: ${solved.run.stderr.trim()}`);\n const answer = readAnswer(solved.run.stdout);\n // An error Z3 printed means a command was dropped; whatever verdict line followed is not about the\n // claim. (The exit code says nothing here: Z3 exits non-zero for the model asked after `unsat` too.)\n if (answer.errors.length > 0)\n return unknown(\"unsupported\", `the emitted SMT did not run: ${answer.errors[0]}`);\n if (answer.result === \"unsat\") return proven;\n if (answer.result === \"unknown\")\n return unknown(\n \"gave_up\",\n solved.resourceLimit\n ? `Z3 reached its resource limit${answer.reason ? ` (${answer.reason})` : \"\"}`\n : `Z3 gave up: ${answer.reason || \"unknown\"}`,\n );\n if (answer.result === \"error\")\n return unknown(\"unsupported\", `the emitted SMT did not run: ${answer.reason}`);\n // sat: a candidate counterexample, replayed through the spec file's own claim.\n let values: unknown[];\n try {\n values = script.binders.map((b) => {\n const v = answer.values.get(b.symbol);\n if (v === undefined) throw new UnreadableModel(`no value for ${b.name} in the model`);\n return decode(v, b.type, module);\n });\n } catch (err) {\n if (!(err instanceof UnreadableModel)) throw err;\n return unknown(\"unsupported\", `Z3's model could not be read: ${err.message}`);\n }\n const rendered = property.binders.map((b, i) => `${b.name} = ${render(values[i])}`).join(\", \");\n // The solver saw the sorts; the claim quantifies over the TypeScript types, which may be narrower.\n if (!property.binders.every((b, i) => conforms(b.type, values[i])))\n return unknown(\n \"unsupported\",\n `Z3's model lies outside the parameter types (${rendered}): the engine's model of the types is wider than the types`,\n );\n const spec = await loadSpec(load, input.specPath, property, fn);\n if (typeof spec === \"string\") return unknown(\"unsupported\", `${spec} (the model: ${rendered})`);\n const evaluation = evaluate(spec, values);\n if (\"malformed\" in evaluation)\n return unknown(\n \"unsupported\",\n `the property could not be evaluated on the model (${rendered}): ${evaluation.malformed}`,\n );\n if (evaluation.outcome !== \"refuted\")\n return unknown(\n \"unsupported\",\n `the claim ${evaluation.outcome === \"held\" ? \"held\" : \"was outside its precondition\"} on the model Z3 gave (${rendered}): the engine's model of the language differs from the runtime here`,\n );\n const smallest = shrinkRefutation(spec, property.binders, values, evaluation);\n return {\n kind: \"REFUTED\",\n engine: { name: engineName, version: z3Version },\n counterexample: {\n binders: property.binders.map((b, i) => ({\n name: b.name,\n value: render(smallest.values[i]),\n })),\n ...(smallest.error === undefined ? {} : { error: smallest.error }),\n },\n assumptions: [\n \"found as a model of the claim's negation by Z3, confirmed by running the spec on it, then shrunk\",\n ],\n };\n}\n\n/** The engine as a `Prover`: available when the pinned solver is installed. */\nexport const smtProver: Prover = {\n name: engineName,\n async available() {\n const solver = await findZ3();\n return \"unavailable\" in solver ? solver : { version: solver.version };\n },\n prove: (input) => proveModule(input),\n};\n\nexport { equal };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,MAAM;AACnB,MAAa,MAAM;;AAGnB,SAAgB,OAAO,MAAsB;CAK3C,MAAM,UAAU,KAAK,QAAQ,MAAM,KAAK,CAAC,CAAC,QAAQ,OAAO,KAAK,CAAC,CAAC,QAAQ,OAAO,KAAK;CACpF,OAAO,2DAA2D,KAAK,OAAO,IAC1E,UACA,IAAI,QAAQ;AAClB;;AAGA,MAAa,QAAQ;CACnB,KAAK,SAAiB,OAAO,KAAK,MAAM;;CAExC,SAAS,SAAiB,OAAO,KAAK,MAAM;CAC5C,cAAc,SAAiB,OAAO,MAAM,MAAM;;CAElD,SAAS,OAAe,WAAmB,OAAO,MAAM,MAAM,GAAG,QAAQ;CACzE,UAAU,OAAe,WAAmB,OAAO,OAAO,MAAM,GAAG,QAAQ;CAE3E,QAAQ,QAAgB,UAAkB,OAAO,OAAO,OAAO,GAAG,OAAO;CACzE,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,OAAO,SAAS,OAAO,EAAE;GAClC,EAAE;GACF,GAAI,SAAS,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,SAAS,MAAM;EAClE;EACA,aAAa,CACX,kGACF;CACF;AACF;;AAGA,MAAa,YAAoB;CAC/B,MAAA;CACA,MAAM,YAAY;EAChB,MAAM,SAAS,MAAM,OAAO;EAC5B,OAAO,iBAAiB,SAAS,SAAS,EAAE,SAAS,OAAO,QAAQ;CACtE;CACA,QAAQ,UAAU,YAAY,KAAK;AACrC"}
@@ -0,0 +1,346 @@
1
+ import { i as seedPrng } from "./src-BtLZPRyG.mjs";
2
+ import { n as isSpec } from "./combinators-CLfsPfhT.mjs";
3
+ import { a as edgeLists, c as generateAssignment, d as render, i as edgeAssignmentCount, l as shrinkCandidates, n as conforms, r as edgeAssignment, t as CannotGenerate, u as copy } from "./generate-TBJM3-2P.mjs";
4
+ // packages/prover/src/checked.ts
5
+ /**
6
+ * One assignment through a spec. The precondition decides whether the
7
+ * assignment is inside the claim; a precondition that throws or does not
8
+ * answer a boolean is a malformed property, since it cannot tell. The
9
+ * claim then holds, or is false, or throws: a throw from the claim, the
10
+ * function's own included, means the claim is not true there. A claim
11
+ * that returns something other than a boolean is malformed.
12
+ */
13
+ function evaluate(spec, values, copied = false) {
14
+ const fresh = () => copied ? copy(values) : values;
15
+ if (spec.when) {
16
+ let inside;
17
+ try {
18
+ inside = spec.when(...fresh());
19
+ } catch (err) {
20
+ return { malformed: `the precondition threw ${String(err)}` };
21
+ }
22
+ if (typeof inside !== "boolean") return { malformed: `the precondition returned ${render(inside)}, not a boolean` };
23
+ if (!inside) return { outcome: "discarded" };
24
+ }
25
+ let claim;
26
+ try {
27
+ claim = spec.ensures(...fresh());
28
+ } catch (err) {
29
+ return {
30
+ outcome: "refuted",
31
+ error: String(err)
32
+ };
33
+ }
34
+ if (typeof claim !== "boolean") return { malformed: `the claim returned ${render(claim)}, not a boolean` };
35
+ return { outcome: claim ? "held" : "refuted" };
36
+ }
37
+ /** How every rung words an `UNKNOWN` for a property that cannot be evaluated; the ladder recognizes it. */
38
+ const malformedReason = (detail) => `the property could not be evaluated: ${detail}`;
39
+ /** The `CHECKED` rung: evaluate the property on every distinct input the simulator passed the function. */
40
+ function checkedRung(input) {
41
+ const { module, fn, property } = input;
42
+ const base = {
43
+ module,
44
+ function: fn.name,
45
+ property: property.name,
46
+ text: property.text
47
+ };
48
+ const unknown = (cause, reason) => ({
49
+ ...base,
50
+ kind: "UNKNOWN",
51
+ cause,
52
+ reason,
53
+ assumptions: []
54
+ });
55
+ if (property.kind === "total") return unknown("unsupported", "termination is not observable on the inputs the simulator passed; total needs a prover");
56
+ if (input.unobservable) return unknown("unavailable", `calls to ${fn.name} could not be observed: ${input.unobservable}`);
57
+ const spec = input.spec;
58
+ if (!spec) return unknown("unavailable", `the spec file's export ${property.name} was not loaded`);
59
+ const binders = property.binders;
60
+ const seen = /* @__PURE__ */ new Set();
61
+ let held = 0;
62
+ let discarded = 0;
63
+ for (const call of input.calls) {
64
+ const values = binders.map((_, i) => call.args[i]);
65
+ const key = values.map(render).join(", ");
66
+ if (seen.has(key)) continue;
67
+ seen.add(key);
68
+ if (!binders.every((b, i) => conforms(b.type, values[i]))) {
69
+ discarded++;
70
+ continue;
71
+ }
72
+ const counterexample = (error) => ({
73
+ binders: binders.map((b, i) => ({
74
+ name: b.name,
75
+ value: render(values[i])
76
+ })),
77
+ call: `${fn.name}(${call.args.map(render).join(", ")})`,
78
+ ...error === void 0 ? {} : { error }
79
+ });
80
+ const result = evaluate(spec, values);
81
+ if ("malformed" in result) return unknown("unsupported", malformedReason(result.malformed));
82
+ if (result.outcome === "refuted") return {
83
+ ...base,
84
+ kind: "REFUTED",
85
+ rung: "CHECKED",
86
+ counterexample: counterexample(result.error),
87
+ assumptions: []
88
+ };
89
+ if (result.outcome === "discarded") discarded++;
90
+ else held++;
91
+ }
92
+ 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 (the precondition)`);
93
+ return {
94
+ ...base,
95
+ kind: "CHECKED",
96
+ inputs: held,
97
+ discarded,
98
+ assumptions: [`held on the ${held} distinct input(s) the simulator passed to ${fn.name}; inputs it never passed are not covered`]
99
+ };
100
+ }
101
+ // packages/prover/src/shrink.ts
102
+ /** How many evaluations shrinking may spend on one counterexample. */
103
+ const shrinkBudget = 500;
104
+ function shrinkRefutation(spec, binders, start, startEvaluation) {
105
+ let values = [...start];
106
+ let error = refutes(startEvaluation) ?? {};
107
+ let spent = 0;
108
+ let progress = true;
109
+ while (progress && spent < shrinkBudget) {
110
+ progress = false;
111
+ for (let i = 0; i < binders.length && spent < shrinkBudget; i++) {
112
+ const b = binders[i];
113
+ let moved = true;
114
+ while (moved && spent < shrinkBudget) {
115
+ moved = false;
116
+ for (const candidate of shrinkCandidates(b, values[i])) {
117
+ if (spent >= shrinkBudget) break;
118
+ spent++;
119
+ const trial = values.with(i, candidate);
120
+ if (spec.sample && !inSample(spec, trial)) continue;
121
+ const still = refutes(evaluate(spec, trial, true));
122
+ if (still === void 0) continue;
123
+ values = trial;
124
+ error = still;
125
+ moved = true;
126
+ progress = true;
127
+ break;
128
+ }
129
+ }
130
+ }
131
+ }
132
+ return error.error === void 0 ? { values } : {
133
+ values,
134
+ error: error.error
135
+ };
136
+ }
137
+ /** Whether an evaluation still refutes: an object (holding the error text, if any), or undefined. */
138
+ function refutes(e) {
139
+ if ("malformed" in e || e.outcome !== "refuted") return void 0;
140
+ return "error" in e && e.error !== void 0 ? { error: e.error } : {};
141
+ }
142
+ /** Whether the spec's sample holds of the values (a sample that throws or answers other than true does not). */
143
+ function inSample(spec, values) {
144
+ try {
145
+ return spec.sample?.(...copy(values)) === true;
146
+ } catch {
147
+ return false;
148
+ }
149
+ }
150
+ // packages/prover/src/tested.ts
151
+ /**
152
+ * The `TESTED` rung: a property evaluated on assignments drawn from its
153
+ * binders' types, steered by the precondition's hints, with a seed, so the
154
+ * same seed draws the same assignments everywhere. An assignment where the
155
+ * claim is false is shrunk toward smaller values that still break it and
156
+ * reported as a counterexample. Holding on every drawn assignment is
157
+ * `TESTED`: evidence from sampling, which says nothing about the inputs
158
+ * never drawn.
159
+ */
160
+ /** The `TESTED` rung: evaluate the property on inputs generated from its binders' domains, drawn from the seed. */
161
+ function testedRung(input) {
162
+ const { module, fn, property } = input;
163
+ const base = {
164
+ module,
165
+ function: fn.name,
166
+ property: property.name,
167
+ text: property.text
168
+ };
169
+ const unknown = (cause, reason) => ({
170
+ ...base,
171
+ kind: "UNKNOWN",
172
+ cause,
173
+ reason,
174
+ assumptions: []
175
+ });
176
+ if (property.kind === "total") return unknown("unsupported", "termination is not observable on generated inputs; total needs a prover");
177
+ const spec = input.spec;
178
+ if (!spec) return unknown("unavailable", `the spec file's export ${property.name} was not loaded`);
179
+ const binders = property.binders;
180
+ const wanted = input.inputs ?? 100;
181
+ if (!Number.isInteger(wanted) || wanted < 1) throw new RangeError(`inputs must be a positive integer, got ${String(input.inputs)}`);
182
+ const seed = `${input.seed}:${module}:${fn.name}:${property.name}`;
183
+ let state = seedPrng(seed);
184
+ let held = 0;
185
+ let discarded = 0;
186
+ let sampledOut = 0;
187
+ const seen = /* @__PURE__ */ new Set();
188
+ const counterexample = (values, error) => ({
189
+ binders: binders.map((b, i) => ({
190
+ name: b.name,
191
+ value: render(values[i])
192
+ })),
193
+ ...error === void 0 ? {} : { error }
194
+ });
195
+ const edges = edgeLists(binders);
196
+ const edgeTotal = edgeAssignmentCount(edges);
197
+ const randomWanted = Math.ceil(wanted / 2);
198
+ let randomHeld = 0;
199
+ for (let draws = 0; draws < edgeTotal || (held < wanted || randomHeld < randomWanted) && draws < edgeTotal + wanted * 20; draws++) {
200
+ let values;
201
+ try {
202
+ [values, state] = (draws < edgeTotal ? edgeAssignment(binders, edges, draws, state) : void 0) ?? generateAssignment(binders, state);
203
+ } catch (err) {
204
+ if (err instanceof CannotGenerate) return unknown(err.why, err.message);
205
+ throw err;
206
+ }
207
+ const key = values.map(render).join(", ");
208
+ if (seen.has(key)) continue;
209
+ seen.add(key);
210
+ if (spec.sample) {
211
+ let inSample;
212
+ try {
213
+ inSample = spec.sample(...copy(values));
214
+ } catch (err) {
215
+ return unknown("unsupported", malformedReason(`the sample threw ${String(err)}`));
216
+ }
217
+ if (typeof inSample !== "boolean") return unknown("unsupported", malformedReason(`the sample returned ${render(inSample)}, not a boolean`));
218
+ if (!inSample) {
219
+ sampledOut++;
220
+ continue;
221
+ }
222
+ }
223
+ const result = evaluate(spec, values, true);
224
+ if ("malformed" in result) return unknown("unsupported", malformedReason(result.malformed));
225
+ if (result.outcome === "discarded") {
226
+ discarded++;
227
+ continue;
228
+ }
229
+ if (result.outcome === "refuted") {
230
+ const smallest = shrinkRefutation(spec, binders, values, result);
231
+ return {
232
+ ...base,
233
+ kind: "REFUTED",
234
+ rung: "TESTED",
235
+ counterexample: counterexample(smallest.values, smallest.error),
236
+ assumptions: [`found on an input generated with seed ${input.seed}, then shrunk`]
237
+ };
238
+ }
239
+ held++;
240
+ if (draws >= edgeTotal) randomHeld++;
241
+ }
242
+ if (held === 0) return unknown("gave_up", sampledOut > 0 && discarded === 0 ? `all ${sampledOut} distinct generated inputs were outside the sample: it admits too few of the parameter types to draw` : `all ${discarded + sampledOut} distinct generated inputs were outside the claim or the sample: its precondition admits too few of the parameter types to sample`);
243
+ return {
244
+ ...base,
245
+ kind: "TESTED",
246
+ inputs: held,
247
+ discarded,
248
+ seed: input.seed,
249
+ assumptions: [
250
+ `held on ${held} distinct input(s) generated from the parameter types with seed ${input.seed}; inputs never drawn are not covered`,
251
+ `${fn.name} was called on generated inputs outside the simulator, so it is assumed pure`,
252
+ ...spec.sample ? [`drawn only where the sample holds${property.sample ? ` (${property.sample.body.replace(/\s+/g, " ").trim()})` : ""}; the claim itself is not limited to it`] : []
253
+ ]
254
+ };
255
+ }
256
+ // packages/prover/src/ladder.ts
257
+ /** One property through the ladder's rungs. */
258
+ function specLadder(input, options = {}) {
259
+ if (options.checked === false) {
260
+ if (!options.tested) throw new RangeError("a ladder without CHECKED needs the TESTED rung");
261
+ return testedRung({
262
+ module: input.module,
263
+ fn: input.fn,
264
+ property: input.property,
265
+ spec: input.spec,
266
+ ...options.tested
267
+ });
268
+ }
269
+ const checked = checkedRung(input);
270
+ if (checked.kind === "REFUTED" || options.tested === false || options.tested === void 0) return checked;
271
+ if (input.property.kind === "total") return checked;
272
+ if (checked.kind === "UNKNOWN" && checked.reason.startsWith(malformedReason(""))) return checked;
273
+ const tested = testedRung({
274
+ module: input.module,
275
+ fn: input.fn,
276
+ property: input.property,
277
+ spec: input.spec,
278
+ ...options.tested
279
+ });
280
+ if (tested.kind === "REFUTED") return tested;
281
+ if (tested.kind === "UNKNOWN" && tested.reason.startsWith(malformedReason(""))) return tested;
282
+ if (tested.kind === "TESTED") {
283
+ if (checked.kind !== "CHECKED") return {
284
+ ...tested,
285
+ assumptions: [...tested.assumptions, reason(checked)]
286
+ };
287
+ return {
288
+ ...tested,
289
+ checked: checked.inputs,
290
+ assumptions: [...tested.assumptions, ...checked.assumptions]
291
+ };
292
+ }
293
+ if (checked.kind !== "UNKNOWN") return {
294
+ ...checked,
295
+ assumptions: [...checked.assumptions, `not TESTED: ${reason(tested)}`]
296
+ };
297
+ if (reason(tested) === checked.reason) return checked;
298
+ return {
299
+ ...checked,
300
+ reason: `${checked.reason}; generated inputs: ${reason(tested)}`
301
+ };
302
+ }
303
+ function reason(v) {
304
+ return v.kind === "UNKNOWN" ? v.reason : v.kind;
305
+ }
306
+ /**
307
+ * Every spec verdict for one module: each property through the ladder.
308
+ * `props` is the spec file's namespace, `namespace` the module's (after
309
+ * observation ended, so it holds the functions themselves); a spec whose
310
+ * function is not the module's export of that name is not evaluated.
311
+ */
312
+ function checkSpecModule(module, specs, props, namespace, observed, options = {}) {
313
+ return specs.functions.flatMap((fn) => {
314
+ const calls = observed.calls.filter((c) => c.function === fn.name);
315
+ const unobservable = Object.hasOwn(observed.unobservable, fn.name) ? observed.unobservable[fn.name] : void 0;
316
+ return fn.properties.map((property) => {
317
+ const exported = Object.hasOwn(props, property.name) ? props[property.name] : void 0;
318
+ let spec;
319
+ let mismatch;
320
+ if (!isSpec(exported)) mismatch = `the spec file exports no spec named ${property.name}`;
321
+ else if (exported.fn !== namespace[fn.name]) mismatch = `${property.name} names a function that is not the module's export ${fn.name}`;
322
+ else if (exported.kind === "forall") spec = exported;
323
+ if (mismatch !== void 0) return {
324
+ module,
325
+ function: fn.name,
326
+ property: property.name,
327
+ text: property.text,
328
+ kind: "UNKNOWN",
329
+ cause: "unavailable",
330
+ reason: mismatch,
331
+ assumptions: []
332
+ };
333
+ return specLadder({
334
+ module,
335
+ fn,
336
+ property,
337
+ calls,
338
+ spec,
339
+ ...unobservable === void 0 ? {} : { unobservable }
340
+ }, options);
341
+ });
342
+ });
343
+ }
344
+ export { checkedRung as a, shrinkRefutation as i, specLadder as n, evaluate as o, testedRung as r, checkSpecModule as t };
345
+
346
+ //# sourceMappingURL=src-DwYD3QQJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-DwYD3QQJ.mjs","names":[],"sources":["../../prover/src/checked.ts","../../prover/src/shrink.ts","../../prover/src/tested.ts","../../prover/src/ladder.ts"],"sourcesContent":["/**\n * The `CHECKED` rung: a property evaluated on every input the simulator\n * actually passed to its function. Binders are the function's parameters,\n * so each recorded call is one assignment; one failing the precondition is\n * outside the claim and discarded. One assignment where the claim is false\n * refutes the property. Holding on all of them is `CHECKED`, which says\n * nothing about inputs the simulator never passed.\n */\n\nimport type { Counterexample, SpecVerdict } from \"@eutaxy/core\";\nimport type { Fn, Forall, FunctionSpec, Property } from \"@eutaxy/spec\";\nimport { conforms } from \"./generate.ts\";\nimport { copy, render } from \"./render.ts\";\n\nexport { render } from \"./render.ts\";\n\n/** What evaluating a spec on one assignment came to. */\nexport type PredicateOutcome = \"held\" | \"discarded\" | \"refuted\";\n\nexport type Evaluation =\n | { readonly outcome: \"held\" | \"discarded\" }\n | { readonly outcome: \"refuted\"; readonly error?: string }\n /** The property, not the function, is at fault: it cannot be evaluated at any rung. */\n | { readonly malformed: string };\n\n/**\n * One assignment through a spec. The precondition decides whether the\n * assignment is inside the claim; a precondition that throws or does not\n * answer a boolean is a malformed property, since it cannot tell. The\n * claim then holds, or is false, or throws: a throw from the claim, the\n * function's own included, means the claim is not true there. A claim\n * that returns something other than a boolean is malformed.\n */\nexport function evaluate(\n spec: Forall<Fn>,\n values: readonly unknown[],\n /** For generated inputs: each arrow gets its own copy of their plain data (`copy`). */\n copied = false,\n): Evaluation {\n const fresh = (): never[] => (copied ? copy(values) : values) as never[];\n if (spec.when) {\n let inside: unknown;\n try {\n inside = spec.when(...fresh());\n } catch (err) {\n return { malformed: `the precondition threw ${String(err)}` };\n }\n if (typeof inside !== \"boolean\")\n return { malformed: `the precondition returned ${render(inside)}, not a boolean` };\n if (!inside) return { outcome: \"discarded\" };\n }\n let claim: unknown;\n try {\n claim = spec.ensures(...fresh());\n } catch (err) {\n return { outcome: \"refuted\", error: String(err) };\n }\n if (typeof claim !== \"boolean\")\n return { malformed: `the claim returned ${render(claim)}, not a boolean` };\n return { outcome: claim ? \"held\" : \"refuted\" };\n}\n\n/** How every rung words an `UNKNOWN` for a property that cannot be evaluated; the ladder recognizes it. */\nexport const malformedReason = (detail: string): string =>\n `the property could not be evaluated: ${detail}`;\n\nexport interface CheckedInput {\n readonly module: string;\n readonly fn: FunctionSpec;\n readonly property: Property;\n /** The calls the simulator made, with their arguments. */\n readonly calls: readonly { readonly args: readonly unknown[] }[];\n /** The spec file's export, or undefined when it could not be loaded. */\n readonly spec: Forall<Fn> | undefined;\n /** Why the function's calls could not be observed, when they could not. */\n readonly unobservable?: string;\n}\n\n/** The `CHECKED` rung: evaluate the property on every distinct input the simulator passed the function. */\nexport function checkedRung(input: CheckedInput): SpecVerdict {\n const { module, fn, property } = input;\n const base = { module, function: fn.name, property: property.name, text: property.text };\n const unknown = (\n cause: \"gave_up\" | \"unsupported\" | \"unavailable\",\n reason: string,\n ): SpecVerdict => ({ ...base, kind: \"UNKNOWN\", cause, reason, assumptions: [] });\n if (property.kind === \"total\")\n return unknown(\n \"unsupported\",\n \"termination is not observable on the inputs the simulator passed; total needs a prover\",\n );\n if (input.unobservable)\n return unknown(\n \"unavailable\",\n `calls to ${fn.name} could not be observed: ${input.unobservable}`,\n );\n const spec = input.spec;\n if (!spec)\n return unknown(\"unavailable\", `the spec file's export ${property.name} was not loaded`);\n const binders = property.binders;\n const seen = new Set<string>();\n let held = 0;\n let discarded = 0;\n for (const call of input.calls) {\n const values = binders.map((_, i) => call.args[i]);\n const key = values.map(render).join(\", \");\n if (seen.has(key)) continue;\n seen.add(key);\n // The claim quantifies over the parameter types; a call with an argument of another type\n // (a shell passing a string where a number is declared) is outside it, not a counterexample.\n if (!binders.every((b, i) => conforms(b.type, values[i]))) {\n discarded++;\n continue;\n }\n const counterexample = (error?: string): Counterexample => ({\n binders: binders.map((b, i) => ({ name: b.name, value: render(values[i]) })),\n call: `${fn.name}(${call.args.map(render).join(\", \")})`,\n ...(error === undefined ? {} : { error }),\n });\n const result = evaluate(spec, values);\n if (\"malformed\" in result) return unknown(\"unsupported\", malformedReason(result.malformed));\n if (result.outcome === \"refuted\")\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"CHECKED\",\n counterexample: counterexample(result.error),\n assumptions: [],\n };\n if (result.outcome === \"discarded\") discarded++;\n else held++;\n }\n if (held === 0)\n return unknown(\n \"gave_up\",\n input.calls.length === 0\n ? `the simulator never called ${fn.name}`\n : `none of the ${seen.size} distinct input(s) the simulator passed is inside the claim (the precondition)`,\n );\n return {\n ...base,\n kind: \"CHECKED\",\n inputs: held,\n discarded,\n assumptions: [\n `held on the ${held} distinct input(s) the simulator passed to ${fn.name}; inputs it never passed are not covered`,\n ],\n };\n}\n","/**\n * A refuting assignment made as small as the candidates allow, one binder\n * at a time, while the property still fails: what the TESTED rung reports,\n * and what an engine reports after replaying a solver's model.\n */\n\nimport type { Binder, Fn, Forall } from \"@eutaxy/spec\";\nimport { type Evaluation, evaluate } from \"./checked.ts\";\nimport { shrinkCandidates } from \"./generate.ts\";\nimport { copy } from \"./render.ts\";\n\n/** How many evaluations shrinking may spend on one counterexample. */\nconst shrinkBudget = 500;\n\nexport function shrinkRefutation(\n spec: Forall<Fn>,\n binders: readonly Binder[],\n start: readonly unknown[],\n startEvaluation: Evaluation,\n): { readonly values: readonly unknown[]; readonly error?: string } {\n let values = [...start];\n let error: { readonly error?: string } = refutes(startEvaluation) ?? {};\n let spent = 0;\n let progress = true;\n while (progress && spent < shrinkBudget) {\n progress = false;\n for (let i = 0; i < binders.length && spent < shrinkBudget; i++) {\n const b = binders[i] as Binder;\n let moved = true;\n while (moved && spent < shrinkBudget) {\n moved = false;\n for (const candidate of shrinkCandidates(b, values[i])) {\n if (spent >= shrinkBudget) break;\n spent++;\n const trial = values.with(i, candidate);\n // Inside the sample only: it bounds what an evaluation may cost, shrinking included.\n if (spec.sample && !inSample(spec, trial)) continue;\n const still = refutes(evaluate(spec, trial, true));\n if (still === undefined) continue;\n values = trial;\n error = still;\n moved = true;\n progress = true;\n break;\n }\n }\n }\n }\n return error.error === undefined ? { values } : { values, error: error.error };\n}\n\n/** Whether an evaluation still refutes: an object (holding the error text, if any), or undefined. */\nexport function refutes(e: Evaluation): { readonly error?: string } | undefined {\n if (\"malformed\" in e || e.outcome !== \"refuted\") return undefined;\n return \"error\" in e && e.error !== undefined ? { error: e.error } : {};\n}\n\n/** Whether the spec's sample holds of the values (a sample that throws or answers other than true does not). */\nfunction inSample(spec: Forall<Fn>, values: readonly unknown[]): boolean {\n try {\n return spec.sample?.(...(copy(values) as never[])) === true;\n } catch {\n return false;\n }\n}\n","/**\n * The `TESTED` rung: a property evaluated on assignments drawn from its\n * binders' types, steered by the precondition's hints, with a seed, so the\n * same seed draws the same assignments everywhere. An assignment where the\n * claim is false is shrunk toward smaller values that still break it and\n * reported as a counterexample. Holding on every drawn assignment is\n * `TESTED`: evidence from sampling, which says nothing about the inputs\n * never drawn.\n */\n\nimport { type Counterexample, type PrngState, type SpecVerdict, seedPrng } from \"@eutaxy/core\";\nimport type { Fn, Forall, FunctionSpec, Property } from \"@eutaxy/spec\";\nimport { evaluate, malformedReason, render } from \"./checked.ts\";\nimport {\n CannotGenerate,\n edgeAssignment,\n edgeAssignmentCount,\n edgeLists,\n generateAssignment,\n} from \"./generate.ts\";\nimport { copy } from \"./render.ts\";\nimport { shrinkRefutation } from \"./shrink.ts\";\n\n/** The `TESTED` rung's seed, and how many distinct generated inputs a property must hold on (default 100). */\nexport interface TestedOptions {\n /** The check's seed; each property derives its own stream from it and its name. */\n readonly seed: string;\n /** Distinct assignments the property must hold on; default 100. Drawing stops after 20 times as many draws, whatever they were. */\n readonly inputs?: number;\n}\n\nexport interface TestedInput extends TestedOptions {\n readonly module: string;\n readonly fn: FunctionSpec;\n readonly property: Property;\n /** The spec file's export, or undefined when it could not be loaded. */\n readonly spec: Forall<Fn> | undefined;\n}\n\n/** The `TESTED` rung: evaluate the property on inputs generated from its binders' domains, drawn from the seed. */\nexport function testedRung(input: TestedInput): SpecVerdict {\n const { module, fn, property } = input;\n const base = { module, function: fn.name, property: property.name, text: property.text };\n const unknown = (\n cause: \"gave_up\" | \"unsupported\" | \"unavailable\",\n reason: string,\n ): SpecVerdict => ({ ...base, kind: \"UNKNOWN\", cause, reason, assumptions: [] });\n if (property.kind === \"total\")\n return unknown(\n \"unsupported\",\n \"termination is not observable on generated inputs; total needs a prover\",\n );\n const spec = input.spec;\n if (!spec)\n return unknown(\"unavailable\", `the spec file's export ${property.name} was not loaded`);\n const binders = property.binders;\n const wanted = input.inputs ?? 100;\n if (!Number.isInteger(wanted) || wanted < 1)\n throw new RangeError(`inputs must be a positive integer, got ${String(input.inputs)}`);\n const seed = `${input.seed}:${module}:${fn.name}:${property.name}`;\n let state: PrngState = seedPrng(seed);\n let held = 0;\n let discarded = 0;\n let sampledOut = 0;\n // Distinct assignments only, as the CHECKED rung counts them: two booleans are two inputs, not a hundred.\n const seen = new Set<string>();\n const counterexample = (values: readonly unknown[], error?: string): Counterexample => ({\n binders: binders.map((b, i) => ({ name: b.name, value: render(values[i]) })),\n ...(error === undefined ? {} : { error }),\n });\n // Every edge assignment is tried, however many there are (a union of a hundred literals has a\n // hundred); then random draws until the budget is met, and at least half of it random, so many\n // edges never crowd out the values between them.\n const edges = edgeLists(binders);\n const edgeTotal = edgeAssignmentCount(edges);\n const randomWanted = Math.ceil(wanted / 2);\n let randomHeld = 0;\n for (\n let draws = 0;\n draws < edgeTotal ||\n ((held < wanted || randomHeld < randomWanted) && draws < edgeTotal + wanted * 20);\n draws++\n ) {\n let values: unknown[];\n try {\n // The edges first, every one of them, then random draws.\n [values, state] =\n (draws < edgeTotal ? edgeAssignment(binders, edges, draws, state) : undefined) ??\n generateAssignment(binders, state);\n } catch (err) {\n if (err instanceof CannotGenerate) return unknown(err.why, err.message);\n throw err;\n }\n const key = values.map(render).join(\", \");\n if (seen.has(key)) continue;\n seen.add(key);\n // Outside the sample is not drawn at all: neither inside nor outside the claim, just not tried.\n if (spec.sample) {\n let inSample: unknown;\n try {\n inSample = spec.sample(...(copy(values) as never[]));\n } catch (err) {\n return unknown(\"unsupported\", malformedReason(`the sample threw ${String(err)}`));\n }\n if (typeof inSample !== \"boolean\")\n return unknown(\n \"unsupported\",\n malformedReason(`the sample returned ${render(inSample)}, not a boolean`),\n );\n if (!inSample) {\n sampledOut++;\n continue;\n }\n }\n const result = evaluate(spec, values, true);\n if (\"malformed\" in result) return unknown(\"unsupported\", malformedReason(result.malformed));\n if (result.outcome === \"discarded\") {\n discarded++;\n continue;\n }\n if (result.outcome === \"refuted\") {\n const smallest = shrinkRefutation(spec, binders, values, result);\n return {\n ...base,\n kind: \"REFUTED\",\n rung: \"TESTED\",\n counterexample: counterexample(smallest.values, smallest.error),\n assumptions: [`found on an input generated with seed ${input.seed}, then shrunk`],\n };\n }\n held++;\n if (draws >= edgeTotal) randomHeld++;\n }\n if (held === 0)\n return unknown(\n \"gave_up\",\n sampledOut > 0 && discarded === 0\n ? `all ${sampledOut} distinct generated inputs were outside the sample: it admits too few of the parameter types to draw`\n : `all ${discarded + sampledOut} distinct generated inputs were outside the claim or the sample: its precondition admits too few of the parameter types to sample`,\n );\n return {\n ...base,\n kind: \"TESTED\",\n inputs: held,\n discarded,\n seed: input.seed,\n assumptions: [\n `held on ${held} distinct input(s) generated from the parameter types with seed ${input.seed}; inputs never drawn are not covered`,\n `${fn.name} was called on generated inputs outside the simulator, so it is assumed pure`,\n ...(spec.sample\n ? [\n `drawn only where the sample holds${property.sample ? ` (${property.sample.body.replace(/\\s+/g, \" \").trim()})` : \"\"}; the claim itself is not limited to it`,\n ]\n : []),\n ],\n };\n}\n","/**\n * The spec ladder, as far as it goes without an engine: `CHECKED` on the\n * inputs the simulator passed, then `TESTED` on generated ones. A\n * counterexample at either rung is `REFUTED`; otherwise the verdict is the\n * highest rung that decided, with the lower one's evidence kept beside it.\n */\n\nimport type { SpecVerdict } from \"@eutaxy/core\";\nimport { type Fn, type Forall, isSpec, type ModuleSpecs } from \"@eutaxy/spec\";\nimport { type CheckedInput, checkedRung, malformedReason } from \"./checked.ts\";\nimport { type TestedOptions, testedRung } from \"./tested.ts\";\n\n/** How far `specLadder` climbs: the `TESTED` rung's options (or none), and whether a scenario ran for `CHECKED`. */\nexport interface LadderOptions {\n /** Run the `TESTED` rung with these options; `false` stops the ladder at `CHECKED`. */\n readonly tested?: TestedOptions | false;\n /** `false` when no scenario ran (`eutaxy report`): the ladder starts at `TESTED`, which it then needs. */\n readonly checked?: false;\n}\n\n/** One property through the ladder's rungs. */\nexport function specLadder(input: CheckedInput, options: LadderOptions = {}): SpecVerdict {\n if (options.checked === false) {\n if (!options.tested) throw new RangeError(\"a ladder without CHECKED needs the TESTED rung\");\n return testedRung({\n module: input.module,\n fn: input.fn,\n property: input.property,\n spec: input.spec,\n ...options.tested,\n });\n }\n const checked = checkedRung(input);\n if (checked.kind === \"REFUTED\" || options.tested === false || options.tested === undefined)\n return checked;\n if (input.property.kind === \"total\") return checked;\n // A property that could not be evaluated on an input the simulator passed is malformed: sampling\n // that happens to miss the input must not make it look sound.\n if (checked.kind === \"UNKNOWN\" && checked.reason.startsWith(malformedReason(\"\"))) return checked;\n const tested = testedRung({\n module: input.module,\n fn: input.fn,\n property: input.property,\n spec: input.spec,\n ...options.tested,\n });\n if (tested.kind === \"REFUTED\") return tested;\n // The same holds the other way round: a generated input that shows the property malformed outranks CHECKED.\n if (tested.kind === \"UNKNOWN\" && tested.reason.startsWith(malformedReason(\"\"))) return tested;\n if (tested.kind === \"TESTED\") {\n if (checked.kind !== \"CHECKED\")\n // Why there is no `checked` count stays visible: the simulator never called the function, say.\n return { ...tested, assumptions: [...tested.assumptions, reason(checked)] };\n return {\n ...tested,\n checked: checked.inputs,\n assumptions: [...tested.assumptions, ...checked.assumptions],\n };\n }\n if (checked.kind !== \"UNKNOWN\")\n return { ...checked, assumptions: [...checked.assumptions, `not TESTED: ${reason(tested)}`] };\n // Neither rung decided: say why for both, once when it is the same reason.\n if (reason(tested) === checked.reason) return checked;\n return { ...checked, reason: `${checked.reason}; generated inputs: ${reason(tested)}` };\n}\n\nfunction reason(v: SpecVerdict): string {\n return v.kind === \"UNKNOWN\" ? v.reason : v.kind;\n}\n\n/**\n * Every spec verdict for one module: each property through the ladder.\n * `props` is the spec file's namespace, `namespace` the module's (after\n * observation ended, so it holds the functions themselves); a spec whose\n * function is not the module's export of that name is not evaluated.\n */\nexport function checkSpecModule(\n module: string,\n specs: ModuleSpecs,\n props: Readonly<Record<string, unknown>>,\n namespace: Readonly<Record<string, unknown>>,\n observed: {\n readonly calls: readonly { readonly function: string; readonly args: readonly unknown[] }[];\n readonly unobservable: { readonly [fn: string]: string };\n },\n options: LadderOptions = {},\n): SpecVerdict[] {\n return specs.functions.flatMap((fn) => {\n const calls = observed.calls.filter((c) => c.function === fn.name);\n // Own properties only: a function named toString must not find Object.prototype's.\n const unobservable = Object.hasOwn(observed.unobservable, fn.name)\n ? observed.unobservable[fn.name]\n : undefined;\n return fn.properties.map((property) => {\n const exported = Object.hasOwn(props, property.name) ? props[property.name] : undefined;\n let spec: Forall<Fn> | undefined;\n let mismatch: string | undefined;\n if (!isSpec(exported)) mismatch = `the spec file exports no spec named ${property.name}`;\n else if (exported.fn !== namespace[fn.name])\n mismatch = `${property.name} names a function that is not the module's export ${fn.name}`;\n else if (exported.kind === \"forall\") spec = exported;\n if (mismatch !== undefined)\n return {\n module,\n function: fn.name,\n property: property.name,\n text: property.text,\n kind: \"UNKNOWN\",\n cause: \"unavailable\",\n reason: mismatch,\n assumptions: [],\n };\n return specLadder(\n {\n module,\n fn,\n property,\n calls,\n spec,\n ...(unobservable === undefined ? {} : { unobservable }),\n },\n options,\n );\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;AAiCA,SAAgB,SACd,MACA,QAEA,SAAS,OACG;CACZ,MAAM,cAAwB,SAAS,KAAK,MAAM,IAAI;CACtD,IAAI,KAAK,MAAM;EACb,IAAI;EACJ,IAAI;GACF,SAAS,KAAK,KAAK,GAAG,MAAM,CAAC;EAC/B,SAAS,KAAK;GACZ,OAAO,EAAE,WAAW,0BAA0B,OAAO,GAAG,IAAI;EAC9D;EACA,IAAI,OAAO,WAAW,WACpB,OAAO,EAAE,WAAW,6BAA6B,OAAO,MAAM,EAAE,iBAAiB;EACnF,IAAI,CAAC,QAAQ,OAAO,EAAE,SAAS,YAAY;CAC7C;CACA,IAAI;CACJ,IAAI;EACF,QAAQ,KAAK,QAAQ,GAAG,MAAM,CAAC;CACjC,SAAS,KAAK;EACZ,OAAO;GAAE,SAAS;GAAW,OAAO,OAAO,GAAG;EAAE;CAClD;CACA,IAAI,OAAO,UAAU,WACnB,OAAO,EAAE,WAAW,sBAAsB,OAAO,KAAK,EAAE,iBAAiB;CAC3E,OAAO,EAAE,SAAS,QAAQ,SAAS,UAAU;AAC/C;;AAGA,MAAa,mBAAmB,WAC9B,w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