tla-ts 0.0.10-dev.a4b81b6d0 → 0.0.10-dev.a5705bfbf
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.
- package/dist/deciders.cjs +31 -31
- package/dist/deciders.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +42 -42
- package/dist/prove.js +30 -30
- package/dist/run.cjs +42 -42
- package/dist/run.js +42 -42
- package/dist/transfer.cjs +31 -29
- package/dist/transfer.js +43 -41
- package/dist/worker.cjs +4 -4
- package/dist/worker.js +4 -4
- package/package.json +1 -1
- package/src/ast.ts +10 -1
- package/src/check-failure.ts +5 -6
- package/src/check-trace.ts +4 -4
- package/src/check.ts +78 -90
- package/src/cli/tlc-output.ts +16 -2
- package/src/cli/tlc.ts +2 -2
- package/src/codegen.ts +10 -16
- package/src/coverage.ts +190 -1
- package/src/dependencies.ts +14 -2
- package/src/dfid.ts +80 -27
- package/src/environment.ts +30 -1
- package/src/evaluate.ts +223 -47
- package/src/exit-codes.ts +3 -4
- package/src/instances.ts +11 -1
- package/src/levels.ts +48 -7
- package/src/liveness-checker.ts +123 -70
- package/src/liveness.ts +4 -1
- package/src/obligations/source.ts +2 -0
- package/src/parser.ts +3 -0
- package/src/prover/smt/solver/card2bv.ts +7 -4
- package/src/prover/smt/solver/context.ts +20 -4
- package/src/prover/smt/solver/dependent-expr-state.ts +18 -12
- package/src/prover/smt/solver/dt2bv-tactic.ts +36 -20
- package/src/prover/smt/solver/fd-solver.ts +146 -39
- package/src/prover/smt/solver/maxcore.ts +2 -1
- package/src/prover/smt/solver/maxsmt-base.ts +1 -0
- package/src/prover/smt/solver/model-checker.ts +1 -1
- package/src/prover/smt/solver/muz/dl-context.ts +12 -40
- package/src/prover/smt/solver/muz/dl-mk-coi-filter.ts +1 -1
- package/src/prover/smt/solver/muz/dl-rule.ts +6 -7
- package/src/prover/smt/solver/muz/hnf.ts +2 -2
- package/src/prover/smt/solver/muz/horn-tactic.ts +14 -1
- package/src/prover/smt/solver/muz/rule-properties.ts +22 -0
- package/src/prover/smt/solver/muz/spacer-prop-solver.ts +1 -1
- package/src/prover/smt/solver/opt-context.ts +1 -0
- package/src/prover/smt/solver/opt-solver.ts +1 -1
- package/src/prover/smt/solver/parallel-tactic.ts +1 -1
- package/src/prover/smt/solver/qsat.ts +7 -2
- package/src/prover/smt/solver/rewriter-tpl.ts +7 -6
- package/src/prover/smt/solver/sat/inc-sat-solver.ts +45 -26
- package/src/prover/smt/solver/sat/sat-tactic.ts +4 -2
- package/src/prover/smt/solver/sat/sat2goal.ts +10 -7
- package/src/prover/smt/solver/smt-consequences.ts +1 -1
- package/src/prover/smt/solver/smt-kernel.ts +9 -2
- package/src/prover/smt/solver/smtlib-parser.ts +6 -2
- package/src/prover/smt/solver/smtlib-script.ts +197 -73
- package/src/prover/smt/solver/tactic.ts +64 -37
- package/src/resolve.ts +143 -39
- package/src/sany/generator-expressions.ts +2 -0
- package/src/sany/generator-proofs.ts +1 -0
- package/src/search.ts +109 -23
- package/src/simulate.ts +114 -124
- package/src/spec-description.ts +3 -0
- package/src/subexpressions.ts +168 -63
- package/src/successors.ts +30 -10
- package/src/tlc/replay.ts +45 -29
- package/src/trace-liveness.ts +529 -0
- package/src/typed-tier.ts +14 -4
- package/src/values.ts +15 -1
package/dist/worker.cjs
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>({branches:e.branches,solutions:e.solutions,addInitialState:
|
|
9
|
+
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>({branches:e.branches,solutions:e.solutions,addInitialState:e.addInitialState,addState:(t,n,r,i)=>o(()=>e.addState(t,n,r,i)),storeState:e.storeState,getStateCounts:e.getStateCounts,findViolation:()=>o(()=>e.findViolation()),getViolatedProperties:(t,n)=>o(()=>e.getViolatedProperties(t,n))}),ee=e=>{let t=o(e);return t&&s(t)},c=e=>{let t=o(e);return t&&{solutions:t.solutions,findTraceViolation:(e,n)=>o(()=>t.findTraceViolation(e,n))}},l=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,u=l(`java.lang.RuntimeException`),d=l(`tlc2.tool.EvalException`),te=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`||e instanceof SyntaxError&&e.message.endsWith(`: Stack overflow`);var f=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},p=class extends f{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},m=class extends p{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},h=class extends m{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const g=(e,t=!1,n,r=[])=>new p(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
10
|
|
|
11
11
|
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),_=(e,t)=>g([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),v=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
-
`)}`,y=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,
|
|
12
|
+
`)}`,y=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,b=(e,t)=>g([{location:y(t),message:e}]);var x=class extends f{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},S=class extends f{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const C=`This was a Java StackOverflowError. It was probably the result
|
|
13
13
|
of an incorrect recursive function definition that caused TLC to enter
|
|
14
14
|
an infinite loop when trying to compute the function or its application
|
|
15
|
-
to an element in its putative domain.`;var
|
|
15
|
+
to an element in its putative domain.`;var w=class extends S{constructor(){super(C)}};const T=()=>i(new w,e.error);var E=class extends S{},D=class extends S{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},O=class extends S{variable;constructor(e,t){super(e),this.variable=t}},k=class extends S{exitCode;constructor(t,n=e.error){super(t),this.exitCode=n}},A=class extends S{constructor(t){super(t),i(this,e.error)}},j=class extends E{constructor(){super(`PickSuccessor reached the end of standard input without an answer whether to extend the behavior.`)}},M=class extends S{constructor(t){super(`The directory ${t} holds no checkpoint to recover from.`),i(this,e.error)}},N=class extends S{},P=class extends S{};const F=`Too many possible next states for the last state in the trace.`;var I=class extends S{constructor(){super(F)}},L=class extends S{code;constructor(e,t){super(t),this.code=e}},R=class extends S{state;constructor(e){super(`current state is not a legal state`),this.state=e}},z=class extends f{failure;exception;locus;constructor(e,t={}){super(e),this.locus=t.locus,this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},B=class extends z{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e})}},V=class extends f{constructor(e,t){super(e,t),this.name=`TlaProverError`}},H=class extends V{locus;constructor(e,t){super(e),this.name=`TlaMethodError`,this.locus=t}},ne=class extends f{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},U=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}};const W=(e,t)=>e instanceof U&&e.exception===t;var G=class extends f{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},K=class extends f{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},q=class extends f{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},J=class extends f{constructor(e){super(e),this.name=`SmtDefaultError`}},Y=class extends f{constructor(e){super(e),this.name=`SmtInvariantError`}},X=class extends f{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},Z=class extends f{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},re=class extends f{line;column;constructor(e,t){super(e),this.name=`SmtParseError`,this.line=t.line,this.column=t.column}},ie=class extends G{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const ae=t=>a(t)??(t instanceof p?e.specParseError:t instanceof x?e.configParseError:t instanceof S?e.specEvaluationFailure:e.error);var oe=class extends f{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},se=class extends f{constructor(e){super(e),this.name=`PcalRuntimeError`}},Q=class extends f{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}},ce=class extends f{constructor(e,t){let n=t?.getSourceFile(),r=n?.getLineAndCharacterOfPosition(t?.getStart()??0);super(n===void 0||r===void 0?e:`${n.fileName}:${r.line+1}:${r.character+1} ${e}`),this.name=`TlaTypeScriptError`}};const $=`node:worker_threads`,le=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,ue=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
16
|
/* @vite-ignore */
|
|
17
17
|
/* webpackIgnore: true */
|
|
18
18
|
$))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},de=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
@@ -21,4 +21,4 @@ $))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.po
|
|
|
21
21
|
$)).parentPort,fe=()=>{let e=`Bun`in globalThis?import(
|
|
22
22
|
/* @vite-ignore */
|
|
23
23
|
/* webpackIgnore: true */
|
|
24
|
-
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return
|
|
24
|
+
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return O}});
|
package/dist/worker.js
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>({branches:e.branches,solutions:e.solutions,addInitialState:
|
|
9
|
+
const e={success:0,abort:1,assumptionViolation:10,deadlock:11,safetyViolation:12,livenessViolation:13,assertViolation:14,specEvaluationFailure:75,safetyEvaluationFailure:76,livenessEvaluationFailure:77,specParseError:150,configParseError:151,error:255},t=new Map([...[...Array.from({length:24},(e,t)=>2222+t),2272,2273,2274,2280,2281,...Array.from({length:7},(e,t)=>5001+t)].map(t=>[t,e.configParseError]),[2253,e.livenessEvaluationFailure],[2109,e.specEvaluationFailure],[2115,e.specEvaluationFailure],[2103,e.specEvaluationFailure],[2147,e.specEvaluationFailure],[2111,e.safetyEvaluationFailure],[2146,e.safetyEvaluationFailure],[2107,e.safetyViolation],[2110,e.safetyViolation],[2112,e.livenessViolation],[2113,e.livenessViolation],[2116,e.livenessViolation],[2108,e.livenessViolation],[2114,e.deadlock],[2104,e.assumptionViolation],[2105,e.assumptionViolation],[2404,e.assumptionViolation],[2405,e.assumptionViolation],[2780,e.assumptionViolation],[2132,e.assertViolation],[2171,e.specParseError],[3002,e.specParseError]]),n=n=>t.get(n)??e.error,r=/* @__PURE__ */ new WeakMap,i=(e,t)=>(e instanceof Error&&!r.has(e)&&r.set(e,t),e),a=e=>r.get(e),o=t=>{try{return t()}catch(t){throw i(t,e.error)}},s=e=>({branches:e.branches,solutions:e.solutions,addInitialState:e.addInitialState,addState:(t,n,r,i)=>o(()=>e.addState(t,n,r,i)),storeState:e.storeState,getStateCounts:e.getStateCounts,findViolation:()=>o(()=>e.findViolation()),getViolatedProperties:(t,n)=>o(()=>e.getViolatedProperties(t,n))}),ee=e=>{let t=o(e);return t&&s(t)},c=e=>{let t=o(e);return t&&{solutions:t.solutions,findTraceViolation:(e,n)=>o(()=>t.findTraceViolation(e,n))}},l=e=>`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${e}\n: `,u=l(`java.lang.RuntimeException`),d=l(`tlc2.tool.EvalException`),te=e=>e instanceof RangeError&&e.message===`Maximum call stack size exceeded`||e instanceof SyntaxError&&e.message.endsWith(`: Stack overflow`);var f=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`TlaError`}},p=class extends f{failure;sany;constructor(e,t,n,r){super(e,t),this.name=`TlaSyntaxError`,this.failure=n,this.sany=r}},m=class extends p{location;parseError;constructor(e,t,n){super(e),this.location=t,this.parseError=n}},h=class extends m{constructor(e,t,n=!0){super(`Cannot find source file for module ${e} imported in module ${t}.`,n?t:void 0)}};const g=(e,t=!1,n,r=[])=>new p(e.map(e=>`${e.location}\n\n${e.message}`).join(`
|
|
10
10
|
|
|
11
11
|
`),void 0,void 0,{errors:e,warnings:r,isFatal:t,parseError:n}),_=(e,t)=>g([{location:`In module ${t}`,message:`Cannot find source file for module ${e} imported in module ${t}.`}],!0),v=e=>`*** Warnings: ${e.length}\n\n${e.map(e=>`${e.location}\n\n${e.message}\n\n\n`).join(`
|
|
12
|
-
`)}`,y=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,
|
|
12
|
+
`)}`,y=e=>`line ${e.start.line}, col ${e.start.column} to line ${e.end.line}, col ${e.end.column} of module ${e.module}`,b=(e,t)=>g([{location:y(t),message:e}]);var x=class extends f{constructor(e,t){super(e,t),this.name=`TlaConfigError`}},S=class extends f{constructor(e,t){super(e,t),this.name=`TlaEvaluationError`}};const C=`This was a Java StackOverflowError. It was probably the result
|
|
13
13
|
of an incorrect recursive function definition that caused TLC to enter
|
|
14
14
|
an infinite loop when trying to compute the function or its application
|
|
15
|
-
to an element in its putative domain.`;var
|
|
15
|
+
to an element in its putative domain.`;var w=class extends S{constructor(){super(C)}};const T=()=>i(new w,e.error);var E=class extends S{},D=class extends S{state;action;variables;constructor(e,t,n,r){super(e),this.state=t,this.action=n,this.variables=r}},O=class extends S{variable;constructor(e,t){super(e),this.variable=t}},k=class extends S{exitCode;constructor(t,n=e.error){super(t),this.exitCode=n}},A=class extends S{constructor(t){super(t),i(this,e.error)}},j=class extends E{constructor(){super(`PickSuccessor reached the end of standard input without an answer whether to extend the behavior.`)}},M=class extends S{constructor(t){super(`The directory ${t} holds no checkpoint to recover from.`),i(this,e.error)}},N=class extends S{},P=class extends S{};const F=`Too many possible next states for the last state in the trace.`;var I=class extends S{constructor(){super(F)}},L=class extends S{code;constructor(e,t){super(t),this.code=e}},R=class extends S{state;constructor(e){super(`current state is not a legal state`),this.state=e}},z=class extends f{failure;exception;locus;constructor(e,t={}){super(e),this.locus=t.locus,this.name=`TlaProofError`,this.failure=t.exception===void 0?t.failure??e:void 0,this.exception=t.exception??`Failure(${JSON.stringify(this.failure)})`}},B=class extends z{constructor(e=`Assert_failure`){super(`Oops, this seems to be a bug in TLAPM.`,{exception:e})}},V=class extends f{constructor(e,t){super(e,t),this.name=`TlaProverError`}},H=class extends V{locus;constructor(e,t){super(e),this.name=`TlaMethodError`,this.locus=t}},ne=class extends f{constructor(e,t){super(e,t),this.name=`TlaZenonError`}},U=class{name=`TlaIsabelleError`;exception;message;constructor(e,t){this.exception=e,this.message=t}};const W=(e,t)=>e instanceof U&&e.exception===t;var G=class extends f{constructor(e,t){super(e,t),this.name=`TlaUnsupportedError`}},K=class extends f{constructor(e,t){super(e,t),this.name=`SmtUnsupportedError`}},q=class extends f{constructor(){super(`the SMT solver was canceled`),this.name=`SmtCanceledError`}},J=class extends f{constructor(e){super(e),this.name=`SmtDefaultError`}},Y=class extends f{constructor(e){super(e),this.name=`SmtInvariantError`}},X=class extends f{constructor(e){super(`nlsat does not implement ${e}`),this.name=`NlsatUnsupportedError`}},Z=class extends f{constructor(){super(`the pdd manager ran out of nodes`),this.name=`PddMemoryOutError`}},re=class extends f{line;column;constructor(e,t){super(e),this.name=`SmtParseError`,this.line=t.line,this.column=t.column}},ie=class extends G{unwound;constructor(e,t){super(e),this.name=`TlaJavaException`,this.unwound=t}};const ae=t=>a(t)??(t instanceof p?e.specParseError:t instanceof x?e.configParseError:t instanceof S?e.specEvaluationFailure:e.error);var oe=class extends f{node;constructor(e,t){super(e),this.name=`PcalError`,this.node=t}},se=class extends f{constructor(e){super(e),this.name=`PcalRuntimeError`}},Q=class extends f{constructor(e){super(`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${e}.`),this.name=`PcalBugError`}},ce=class extends f{constructor(e,t){let n=t?.getSourceFile(),r=n?.getLineAndCharacterOfPosition(t?.getStart()??0);super(n===void 0||r===void 0?e:`${n.fileName}:${r.line+1}:${r.character+1} ${e}`),this.name=`TlaTypeScriptError`}};const $=`node:worker_threads`,le=()=>typeof Worker==`function`||typeof process<`u`&&process.versions?.node!==void 0,ue=async(e,t,n)=>{if(typeof Worker==`function`){let r=new Worker(e,{type:`module`});return r.addEventListener(`message`,e=>t(e.data)),r.addEventListener(`error`,n),r}let r=new(await(import(
|
|
16
16
|
/* @vite-ignore */
|
|
17
17
|
/* webpackIgnore: true */
|
|
18
18
|
$))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.postMessage(e,t),terminate:()=>void r.terminate()}},de=async()=>typeof globalThis.postMessage==`function`?globalThis:(await import(
|
|
@@ -21,4 +21,4 @@ $))).Worker(e);return r.on(`message`,t),r.on(`error`,n),{postMessage:(e,t)=>r.po
|
|
|
21
21
|
$)).parentPort,fe=()=>{let e=`Bun`in globalThis?import(
|
|
22
22
|
/* @vite-ignore */
|
|
23
23
|
/* webpackIgnore: true */
|
|
24
|
-
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};export{ae as $,
|
|
24
|
+
`bun:jsc`):void 0;return async()=>{(await e)?.edenGC(),await new Promise(e=>typeof setImmediate==`function`?setImmediate(e):setTimeout(e,0))}};export{ae as $,k as A,E as B,R as C,H as D,ie as E,w as F,d as G,L as H,p as I,g as J,u as K,I as L,V as M,m as N,M as O,P,v as Q,ce as R,A as S,U as T,ne as U,G as V,B as W,T as X,b as Y,y as Z,N as _,X as a,n as at,f as b,se as c,ee as ct,q as d,l as et,J as f,F as g,K as h,ue as i,a as it,z as j,h as k,Z as l,re as m,de as n,te as nt,Q as o,i as ot,Y as p,_ as q,le as r,e as rt,oe as s,c as st,fe as t,W as tt,C as u,x as v,D as w,S as x,j as y,O as z};
|
package/package.json
CHANGED
package/src/ast.ts
CHANGED
|
@@ -307,6 +307,12 @@ interface SubexpressionExpression {
|
|
|
307
307
|
location: SourceLocation;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
interface SelectionExpression {
|
|
311
|
+
kind: "Selection";
|
|
312
|
+
expression: Expression;
|
|
313
|
+
location: SourceLocation;
|
|
314
|
+
}
|
|
315
|
+
|
|
310
316
|
export type Expression =
|
|
311
317
|
| NumberExpression
|
|
312
318
|
| DecimalExpression
|
|
@@ -342,7 +348,8 @@ export type Expression =
|
|
|
342
348
|
| ActionExpression
|
|
343
349
|
| FairnessExpression
|
|
344
350
|
| LabelExpression
|
|
345
|
-
| SubexpressionExpression
|
|
351
|
+
| SubexpressionExpression
|
|
352
|
+
| SelectionExpression;
|
|
346
353
|
|
|
347
354
|
export interface OperatorParam {
|
|
348
355
|
name: string;
|
|
@@ -601,6 +608,8 @@ export const getChildren = (expression: Expression): Expression[] => {
|
|
|
601
608
|
return [expression.body];
|
|
602
609
|
case "Subexpression":
|
|
603
610
|
return expression.selectors.flatMap((selector) => ("args" in selector ? selector.args : []));
|
|
611
|
+
case "Selection":
|
|
612
|
+
return [expression.expression];
|
|
604
613
|
}
|
|
605
614
|
};
|
|
606
615
|
|
package/src/check-failure.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./evaluate";
|
|
9
9
|
import { EXIT_STATUS, getExitCode, getMessageExitStatus } from "./exit-codes";
|
|
10
10
|
import type { TraceFailure } from "./check";
|
|
11
|
-
import { getCodedMessage } from "./tlc/messages";
|
|
11
|
+
import { getCodedMessage, isEvalException } from "./tlc/messages";
|
|
12
12
|
import { getFingerprintError, getHeldValues, markFingerprinted, type Value } from "./values";
|
|
13
13
|
|
|
14
14
|
export interface ReplayFailure {
|
|
@@ -30,11 +30,10 @@ export interface FailureOptions {
|
|
|
30
30
|
|
|
31
31
|
const getInitialExitCode = (error: TlaEvaluationError) => {
|
|
32
32
|
const coded = getCodedMessage(error.message);
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
getMessageExitStatus(coded.code)
|
|
36
|
-
|
|
37
|
-
: getErrorExitCode(error);
|
|
33
|
+
return (
|
|
34
|
+
getExitCode(error) ??
|
|
35
|
+
(coded && !isEvalException(error) ? getMessageExitStatus(coded.code) : EXIT_STATUS.error)
|
|
36
|
+
);
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
const getReplayExitCode = (error: TlaEvaluationError): number => {
|
package/src/check-trace.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface TraceOptions {
|
|
|
17
17
|
loopStart?: number;
|
|
18
18
|
known?: number;
|
|
19
19
|
incomplete?: State;
|
|
20
|
-
|
|
20
|
+
isPrintedOnly?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
interface RebuiltState {
|
|
@@ -98,7 +98,7 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
98
98
|
runtime.getBehavior = searchBehavior;
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
// Deviation from TLC: TLCTrace#printTrace
|
|
101
|
+
// Deviation from TLC: TLCTrace#printTrace and Worker#doPostCondition rebuild a step with the generator that already drew for its state, so they miss it; printTrace leaks a NullPointerException and doPostCondition skips the postcondition.
|
|
102
102
|
const rebuildFrom = (state: Value[], level: number) => {
|
|
103
103
|
current.rebuilt = { state, level };
|
|
104
104
|
runtime.reseedRandom();
|
|
@@ -134,7 +134,7 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
134
134
|
const known = traceOptions.known ?? 1;
|
|
135
135
|
const loopStart = traceOptions.loopStart;
|
|
136
136
|
const rebuilt = is174 && loopStart !== undefined ? loopStart + 1 : steps.length - known;
|
|
137
|
-
const isRebuiltAgain = known > 0 && !is174 && !traceOptions.
|
|
137
|
+
const isRebuiltAgain = known > 0 && !is174 && !traceOptions.isPrintedOnly;
|
|
138
138
|
const initialOutput =
|
|
139
139
|
known === 0 || (steps.length > 1 && (rebuilt > 0 || isRebuiltAgain || is174))
|
|
140
140
|
? captureOutput(context.getInitialStates).lines
|
|
@@ -272,7 +272,7 @@ export const createTraceBuilder = (context: TraceContext) => {
|
|
|
272
272
|
const getStateTrace = (index: number, traceOptions: TraceOptions = {}): Behavior => {
|
|
273
273
|
if (context.parents[index] !== -1) return getTrace(index, undefined, traceOptions);
|
|
274
274
|
const traceOutput =
|
|
275
|
-
is174 || traceOptions.
|
|
275
|
+
is174 || traceOptions.isPrintedOnly ? [] : captureOutput(context.getInitialStates).lines;
|
|
276
276
|
const state = states[index];
|
|
277
277
|
if (traceOptions.incomplete !== undefined) {
|
|
278
278
|
return {
|
package/src/check.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { Expression } from "./ast";
|
|
2
2
|
import { parseConfig, type ModelConfig } from "./config";
|
|
3
3
|
import {
|
|
4
|
-
addCoverageRelation,
|
|
5
|
-
buildCoverage,
|
|
6
4
|
countCoverageVariables,
|
|
7
5
|
createCoverage,
|
|
8
|
-
|
|
6
|
+
createCoverageEnvironment,
|
|
9
7
|
getCoverageReport,
|
|
10
8
|
type CoverageReport,
|
|
11
9
|
} from "./coverage";
|
|
@@ -25,8 +23,8 @@ import {
|
|
|
25
23
|
describeRange,
|
|
26
24
|
getDefinition,
|
|
27
25
|
type CallStack,
|
|
28
|
-
type Environment,
|
|
29
26
|
type FingerprintFailure,
|
|
27
|
+
type State,
|
|
30
28
|
} from "./evaluate";
|
|
31
29
|
import { EXIT_STATUS, setExitCode, withLivenessExitCode } from "./exit-codes";
|
|
32
30
|
import {
|
|
@@ -58,6 +56,7 @@ import {
|
|
|
58
56
|
type LiveSuccessor,
|
|
59
57
|
} from "./liveness-checker";
|
|
60
58
|
import {
|
|
59
|
+
addActionCoverage,
|
|
61
60
|
createCheckEnvironment,
|
|
62
61
|
createMissingOperatorError,
|
|
63
62
|
createSearch,
|
|
@@ -65,7 +64,10 @@ import {
|
|
|
65
64
|
findAssumptionViolation,
|
|
66
65
|
reportInitialStatesProgress,
|
|
67
66
|
reportStartup,
|
|
67
|
+
STOP_WALK,
|
|
68
|
+
walkCoveredSuccessors,
|
|
68
69
|
withNextStateExitCode,
|
|
70
|
+
type CoveredAction,
|
|
69
71
|
} from "./search";
|
|
70
72
|
import {
|
|
71
73
|
getActionLabel,
|
|
@@ -83,6 +85,7 @@ import {
|
|
|
83
85
|
type StateWriter,
|
|
84
86
|
} from "./state-graph";
|
|
85
87
|
import {
|
|
88
|
+
createIncompleteSuccessorError,
|
|
86
89
|
forEachInitialState,
|
|
87
90
|
forEachSuccessor,
|
|
88
91
|
getInitialStates,
|
|
@@ -102,12 +105,7 @@ import {
|
|
|
102
105
|
import { createTautologyError } from "./liveness";
|
|
103
106
|
import { KEY_SEPARATOR } from "./resolve";
|
|
104
107
|
import { writeTraceSpec } from "./tlc/trace-spec";
|
|
105
|
-
import {
|
|
106
|
-
getPrimedRanges,
|
|
107
|
-
replayInitialStates,
|
|
108
|
-
replaySuccessors,
|
|
109
|
-
walkSuccessors,
|
|
110
|
-
} from "./tlc/replay";
|
|
108
|
+
import { replayInitialStates, replaySuccessors, walkSuccessors } from "./tlc/replay";
|
|
111
109
|
import { getFingerprintDistance, OUT_DEGREE_BUCKETS } from "./tlc/summary";
|
|
112
110
|
import {
|
|
113
111
|
createActionRecord,
|
|
@@ -329,10 +327,6 @@ export interface CheckResult {
|
|
|
329
327
|
coverage?: CoverageReport;
|
|
330
328
|
}
|
|
331
329
|
|
|
332
|
-
interface CoveredAction extends SpecAction {
|
|
333
|
-
node: number;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
330
|
interface ReportedViolation extends Omit<Violation, "loopStart"> {
|
|
337
331
|
loopStart?: number;
|
|
338
332
|
}
|
|
@@ -362,7 +356,6 @@ const getTraceFailure = (error: TlaEvaluationError, output: OutputLine[]): Trace
|
|
|
362
356
|
});
|
|
363
357
|
|
|
364
358
|
const STOP_REPLAY = new Error("The replay stopped");
|
|
365
|
-
const STOP_WALK = new Error("The walk stopped");
|
|
366
359
|
|
|
367
360
|
export const checkSequentially = (options: CheckOptions): CheckResult => {
|
|
368
361
|
const stateWriter =
|
|
@@ -409,14 +402,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
409
402
|
options.coverage === undefined
|
|
410
403
|
? undefined
|
|
411
404
|
: createCoverage(specification.environment.variables.length);
|
|
412
|
-
const environment
|
|
413
|
-
?
|
|
414
|
-
...specification.environment,
|
|
415
|
-
evaluators: new WeakMap(),
|
|
416
|
-
entryEvaluators: new WeakMap(),
|
|
417
|
-
definitionEvaluators: new WeakMap(),
|
|
418
|
-
coverage,
|
|
419
|
-
}
|
|
405
|
+
const environment = coverage
|
|
406
|
+
? createCoverageEnvironment(specification.environment, coverage)
|
|
420
407
|
: specification.environment;
|
|
421
408
|
const runtime = environment.runtime;
|
|
422
409
|
const is174 = runtime.version === "1.7.4";
|
|
@@ -599,49 +586,9 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
599
586
|
const getFingerprintState = search.getFingerprintState;
|
|
600
587
|
// Tool's constructor splits the next-state relation into actions before TLC checks anything.
|
|
601
588
|
const nextActions = getDescription().actions;
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
node: coverage
|
|
606
|
-
? addCoverageRelation(
|
|
607
|
-
coverage,
|
|
608
|
-
kind,
|
|
609
|
-
getCoverageLabel(action.name, action.expression, environment),
|
|
610
|
-
action.expression,
|
|
611
|
-
action.scope,
|
|
612
|
-
)
|
|
613
|
-
: -1,
|
|
614
|
-
}));
|
|
615
|
-
const coverageInits = addCoverageRelations("init", coverage ? getDescription().inits : []);
|
|
616
|
-
const coverageActions = addCoverageRelations("next", coverage ? nextActions : []);
|
|
617
|
-
if (coverage) buildCoverage(coverage, environment, getPrimedRanges(coverageActions, environment));
|
|
618
|
-
const walkCoveredSuccessors = (
|
|
619
|
-
action: CoveredAction,
|
|
620
|
-
state: Value[],
|
|
621
|
-
onState: (successor: Value[]) => void,
|
|
622
|
-
) =>
|
|
623
|
-
walkSuccessors(
|
|
624
|
-
action,
|
|
625
|
-
action.node,
|
|
626
|
-
state,
|
|
627
|
-
environment,
|
|
628
|
-
(successor) => {
|
|
629
|
-
if (coverage) coverage.primary[action.node]++;
|
|
630
|
-
onState(successor);
|
|
631
|
-
},
|
|
632
|
-
(partial) => {
|
|
633
|
-
if (coverage) coverage.primary[action.node]++;
|
|
634
|
-
const missing = environment.variables.filter(
|
|
635
|
-
(_variable, index) => partial[index] === undefined,
|
|
636
|
-
);
|
|
637
|
-
throw new TlaIncompleteSuccessorError(
|
|
638
|
-
`Successor state is not completely specified by action ${action.name}. The following variables are not assigned: ${missing.join(", ")}`,
|
|
639
|
-
partial,
|
|
640
|
-
action.name,
|
|
641
|
-
missing,
|
|
642
|
-
);
|
|
643
|
-
},
|
|
644
|
-
);
|
|
589
|
+
const covered = coverage && addActionCoverage(coverage, environment, getDescription());
|
|
590
|
+
const coverageInits = covered?.inits ?? [];
|
|
591
|
+
const coverageActions = covered?.actions ?? [];
|
|
645
592
|
const hasCoveredIncompleteSuccessor = (action: CoveredAction, state: Value[]) => {
|
|
646
593
|
let complete = 0;
|
|
647
594
|
let incomplete = 0;
|
|
@@ -659,17 +606,16 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
659
606
|
if (coverage) coverage.primary[action.node] += complete + incomplete;
|
|
660
607
|
return incomplete > 0;
|
|
661
608
|
};
|
|
662
|
-
const getCoveredSuccessors = (action: CoveredAction, state: Value[]) => {
|
|
663
|
-
const successors: Successor[] = [];
|
|
664
|
-
walkCoveredSuccessors(action, state, (successor) =>
|
|
665
|
-
successors.push({ state: successor, action: action.name }),
|
|
666
|
-
);
|
|
667
|
-
return successors;
|
|
668
|
-
};
|
|
669
609
|
// TLC generates the successors of each action again, which its coverage counts.
|
|
670
610
|
const findSuccessorAction = (state: Value[], isMatch: (successor: Successor) => boolean) =>
|
|
671
611
|
coverage
|
|
672
|
-
? coverageActions.find((item) =>
|
|
612
|
+
? coverageActions.find((item) => {
|
|
613
|
+
const successors: Successor[] = [];
|
|
614
|
+
walkCoveredSuccessors(coverage, item, state, environment, (successor) =>
|
|
615
|
+
successors.push({ state: successor, action: item.name }),
|
|
616
|
+
);
|
|
617
|
+
return successors.some(isMatch);
|
|
618
|
+
})
|
|
673
619
|
: nextActions.find((item) =>
|
|
674
620
|
getSuccessors(item.expression, state, environment, item.scope).some(isMatch),
|
|
675
621
|
);
|
|
@@ -774,6 +720,15 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
774
720
|
isConstrained: search.isConstrained,
|
|
775
721
|
});
|
|
776
722
|
}
|
|
723
|
+
let liveState: Value[] = [];
|
|
724
|
+
const addIncomplete = (successor: State, action: string | undefined) => {
|
|
725
|
+
if (
|
|
726
|
+
search.satisfiesConstraints(successor, liveState) &&
|
|
727
|
+
search.satisfiesActionConstraints(liveState, successor)
|
|
728
|
+
) {
|
|
729
|
+
throw createIncompleteSuccessorError(successor, action, environment);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
777
732
|
const liveness = withLivenessExitCode(() =>
|
|
778
733
|
withUnexpectedException(() =>
|
|
779
734
|
createLivenessChecker(search.properties.liveness, spec.temporals, environment, {
|
|
@@ -781,7 +736,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
781
736
|
(tlcFingerprints[successor.index] ??= Number(
|
|
782
737
|
BigInt.asIntN(32, runtime.getFingerprint(successor.state)),
|
|
783
738
|
)),
|
|
784
|
-
forEachActionSuccessors: (source, state, onSuccessors) => {
|
|
739
|
+
forEachActionSuccessors: (source, state, onSuccessors, replay) => {
|
|
740
|
+
liveState = state;
|
|
785
741
|
let successors: LiveSuccessor[] = [];
|
|
786
742
|
const addSuccessor = (successor: Value[]) => {
|
|
787
743
|
canonicalizeState(successor);
|
|
@@ -807,9 +763,22 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
807
763
|
const livenessSource = current.livenessSource;
|
|
808
764
|
current.livenessSource = source;
|
|
809
765
|
try {
|
|
810
|
-
// TLC's coverage counts the successors of each action the graph generates again.
|
|
811
766
|
if (coverage) {
|
|
812
|
-
|
|
767
|
+
// TLC's coverage counts the successors of each action the graph generates again.
|
|
768
|
+
walkCoveredSuccessors(
|
|
769
|
+
coverage,
|
|
770
|
+
coverageActions[position],
|
|
771
|
+
state,
|
|
772
|
+
replay ?? environment,
|
|
773
|
+
addSuccessor,
|
|
774
|
+
addIncomplete,
|
|
775
|
+
);
|
|
776
|
+
} else if (replay) {
|
|
777
|
+
const action = nextActions[position];
|
|
778
|
+
walkSuccessors(action, -1, state, replay, addSuccessor, (partial) => {
|
|
779
|
+
addIncomplete(partial, action.name);
|
|
780
|
+
return true;
|
|
781
|
+
});
|
|
813
782
|
} else {
|
|
814
783
|
const action = nextActions[position];
|
|
815
784
|
forEachSuccessor(
|
|
@@ -818,6 +787,9 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
818
787
|
environment,
|
|
819
788
|
visitSuccessor,
|
|
820
789
|
action.scope,
|
|
790
|
+
undefined,
|
|
791
|
+
undefined,
|
|
792
|
+
addIncomplete,
|
|
821
793
|
);
|
|
822
794
|
}
|
|
823
795
|
} finally {
|
|
@@ -944,7 +916,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
944
916
|
options.version,
|
|
945
917
|
);
|
|
946
918
|
const live = captureOutput(() => addFailedLiveState(index, liveSuccessors));
|
|
947
|
-
const trace = traces.getStateTrace(index, {
|
|
919
|
+
const trace = traces.getStateTrace(index, {
|
|
920
|
+
incomplete: error.state,
|
|
921
|
+
isPrintedOnly: true,
|
|
922
|
+
}).trace;
|
|
948
923
|
const checked = checkFailedTrace(
|
|
949
924
|
appendTraceOutput(
|
|
950
925
|
{
|
|
@@ -1228,15 +1203,20 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1228
1203
|
if (!found.isSeen) {
|
|
1229
1204
|
try {
|
|
1230
1205
|
const violated = search.findViolatedInvariant(successor.state, state);
|
|
1231
|
-
const violation = violated && {
|
|
1206
|
+
const violation = violated && {
|
|
1207
|
+
name: violated.name,
|
|
1208
|
+
...traces.getTrace(index, successor, { isPrintedOnly: options.isContinued }),
|
|
1209
|
+
};
|
|
1232
1210
|
if (violation && !options.isContinued) {
|
|
1233
1211
|
return withOutDegrees(reportViolation("invariant-violation", violation));
|
|
1234
1212
|
}
|
|
1235
1213
|
if (violation) reportContinuedViolation("invariant-violation", violation);
|
|
1236
1214
|
} catch (error) {
|
|
1237
1215
|
if (isStackOverflow(error)) throw error;
|
|
1238
|
-
const behavior = traces.getTrace(index, successor, {
|
|
1239
|
-
const replay =
|
|
1216
|
+
const behavior = traces.getTrace(index, successor, { isPrintedOnly: true });
|
|
1217
|
+
const replay = is174
|
|
1218
|
+
? captureOutput(() => replayNext(index))
|
|
1219
|
+
: replayFailedNext(index, liveSuccessors);
|
|
1240
1220
|
return createFailureResult(
|
|
1241
1221
|
error,
|
|
1242
1222
|
appendTraceOutput(behavior, replay.lines),
|
|
@@ -1247,7 +1227,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1247
1227
|
const violatedProperty = search.findViolatedActionProperty(state, successor.state);
|
|
1248
1228
|
const propertyViolation = violatedProperty && {
|
|
1249
1229
|
name: violatedProperty.name,
|
|
1250
|
-
...traces.getTrace(index, successor),
|
|
1230
|
+
...traces.getTrace(index, successor, { isPrintedOnly: options.isContinued }),
|
|
1251
1231
|
};
|
|
1252
1232
|
if (propertyViolation && !options.isContinued) {
|
|
1253
1233
|
return withOutDegrees(reportViolation("liveness-violation", propertyViolation));
|
|
@@ -1439,7 +1419,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1439
1419
|
try {
|
|
1440
1420
|
coverageActions.forEach((action) => {
|
|
1441
1421
|
coveredNode = action.node;
|
|
1442
|
-
walkCoveredSuccessors(action, state, (successor) => {
|
|
1422
|
+
walkCoveredSuccessors(coverage, action, state, environment, (successor) => {
|
|
1443
1423
|
successorCount++;
|
|
1444
1424
|
if (onSuccessor({ state: successor, action: action.name }, action)) throw STOP_WALK;
|
|
1445
1425
|
});
|
|
@@ -1494,6 +1474,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1494
1474
|
return undefined;
|
|
1495
1475
|
} catch (error) {
|
|
1496
1476
|
if (!(error instanceof TlaEvaluationError)) throw error;
|
|
1477
|
+
// TLC fails to fingerprint an incomplete successor with an exception Worker#doNextCheckLiveness doesn't rerun for a call stack.
|
|
1478
|
+
if (error instanceof TlaIncompleteSuccessorError) return undefined;
|
|
1497
1479
|
return getLiveCallStack(index, liveSuccessors);
|
|
1498
1480
|
}
|
|
1499
1481
|
};
|
|
@@ -1509,7 +1491,10 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1509
1491
|
return { result, lines: [...live.lines, ...replay.lines] };
|
|
1510
1492
|
};
|
|
1511
1493
|
const getNextFailureTrace = (index: number, counterExample?: CounterExampleOptions) =>
|
|
1512
|
-
checkFailedTrace(
|
|
1494
|
+
checkFailedTrace(
|
|
1495
|
+
traces.getStateTrace(index, { isPrintedOnly: !counterExample }),
|
|
1496
|
+
counterExample,
|
|
1497
|
+
);
|
|
1513
1498
|
const reportNextStateOverflow = (index: number, counterExample?: CounterExampleOptions) => {
|
|
1514
1499
|
const checked = getNextFailureTrace(index, counterExample);
|
|
1515
1500
|
return createFailureResult(
|
|
@@ -1520,6 +1505,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1520
1505
|
);
|
|
1521
1506
|
};
|
|
1522
1507
|
// Deviation from TLC: under -continue, TLC's Worker reports a state whose next-state relation failed as deadlocked, or else reports the failure twice as its replay fails again.
|
|
1508
|
+
// Deviation from TLC: under -continue, ModelChecker#doNextEvalFailed rethrows a failed invariant to Worker#doNextFailed, which reports it again with the code of its error.
|
|
1523
1509
|
const reportNextStateFailure = (
|
|
1524
1510
|
error: unknown,
|
|
1525
1511
|
index: number,
|
|
@@ -1620,8 +1606,8 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1620
1606
|
? error
|
|
1621
1607
|
: undefined;
|
|
1622
1608
|
const behavior = traceError
|
|
1623
|
-
? traces.getStateTrace(index, {
|
|
1624
|
-
: traces.getTrace(index, successor, {
|
|
1609
|
+
? traces.getStateTrace(index, { isPrintedOnly: true })
|
|
1610
|
+
: traces.getTrace(index, successor, { isPrintedOnly: true });
|
|
1625
1611
|
const traceFailure =
|
|
1626
1612
|
traceError &&
|
|
1627
1613
|
getTraceFailure(
|
|
@@ -1665,9 +1651,11 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1665
1651
|
...traces.getStateTrace(index),
|
|
1666
1652
|
});
|
|
1667
1653
|
const live = addReportedLiveState(index, liveSuccessors, source);
|
|
1668
|
-
const reported =
|
|
1669
|
-
|
|
1670
|
-
: deadlock
|
|
1654
|
+
const reported = {
|
|
1655
|
+
...deadlock,
|
|
1656
|
+
violation: deadlock.violation && appendTraceOutput(deadlock.violation, live.lines),
|
|
1657
|
+
coverage: getCoverage(),
|
|
1658
|
+
};
|
|
1671
1659
|
const counted = withOutDegrees(
|
|
1672
1660
|
reported,
|
|
1673
1661
|
live.result.isFailed ? getFailureOutDegrees() : getPartialOutDegrees(),
|
|
@@ -1689,7 +1677,7 @@ const searchStates = (options: CheckOptions, stateWriter: StateWriter | undefine
|
|
|
1689
1677
|
const replay = getReplayFailure(environment, (tracing) =>
|
|
1690
1678
|
liveness?.addState(index, state, liveSuccessors, tracing),
|
|
1691
1679
|
);
|
|
1692
|
-
const behavior = traces.getStateTrace(index, {
|
|
1680
|
+
const behavior = traces.getStateTrace(index, { isPrintedOnly: true });
|
|
1693
1681
|
const replayed = captureOutput(() => replayNext(index));
|
|
1694
1682
|
return createFailureResult(error, appendTraceOutput(behavior, replayed.lines), {
|
|
1695
1683
|
outDegrees: getFailureOutDegrees(),
|
package/src/cli/tlc-output.ts
CHANGED
|
@@ -472,7 +472,11 @@ const printSuccess = (printer: MessagePrinter, optimistic: number, actual: numbe
|
|
|
472
472
|
].join("\n"),
|
|
473
473
|
);
|
|
474
474
|
|
|
475
|
-
export const printDepthFirst = (
|
|
475
|
+
export const printDepthFirst = (
|
|
476
|
+
printer: MessagePrinter,
|
|
477
|
+
output: DepthFirstOutput,
|
|
478
|
+
startTime: number,
|
|
479
|
+
) => {
|
|
476
480
|
switch (output.kind) {
|
|
477
481
|
case "message":
|
|
478
482
|
printer.print(
|
|
@@ -481,6 +485,9 @@ export const printDepthFirst = (printer: MessagePrinter, output: DepthFirstOutpu
|
|
|
481
485
|
printer.isTool ? output.toolMessage : output.message,
|
|
482
486
|
);
|
|
483
487
|
return;
|
|
488
|
+
case "coverage":
|
|
489
|
+
printCoverage(printer, output.coverage, startTime);
|
|
490
|
+
return;
|
|
484
491
|
case "behavior":
|
|
485
492
|
output.states.forEach((state, index) =>
|
|
486
493
|
output.isInvariant
|
|
@@ -635,7 +642,11 @@ export const printStartupBanner = (printer: MessagePrinter, args: TlcArguments)
|
|
|
635
642
|
);
|
|
636
643
|
};
|
|
637
644
|
|
|
638
|
-
export const printSimulation = (
|
|
645
|
+
export const printSimulation = (
|
|
646
|
+
printer: MessagePrinter,
|
|
647
|
+
output: SimulationOutput,
|
|
648
|
+
startTime: number,
|
|
649
|
+
) => {
|
|
639
650
|
const print = printer.print;
|
|
640
651
|
switch (output.kind) {
|
|
641
652
|
case "message":
|
|
@@ -645,6 +656,9 @@ export const printSimulation = (printer: MessagePrinter, output: SimulationOutpu
|
|
|
645
656
|
printer.isTool ? output.toolMessage : output.message,
|
|
646
657
|
);
|
|
647
658
|
return;
|
|
659
|
+
case "coverage":
|
|
660
|
+
printCoverage(printer, output.coverage, startTime);
|
|
661
|
+
return;
|
|
648
662
|
case "behavior": {
|
|
649
663
|
const last = output.trace[output.trace.length - 1];
|
|
650
664
|
if (!output.isLastStateOnly) {
|
package/src/cli/tlc.ts
CHANGED
|
@@ -440,7 +440,7 @@ const checkSpec = async (
|
|
|
440
440
|
aril: args.aril,
|
|
441
441
|
isGenerating: args.mode === "generate",
|
|
442
442
|
scheduler: args.scheduler,
|
|
443
|
-
onSimulation: (output) => printSimulation(printer, output),
|
|
443
|
+
onSimulation: (output) => printSimulation(printer, output, timing.startTime),
|
|
444
444
|
});
|
|
445
445
|
printFinished();
|
|
446
446
|
return status;
|
|
@@ -449,7 +449,7 @@ const checkSpec = async (
|
|
|
449
449
|
const status = checkDepthFirst({
|
|
450
450
|
...options,
|
|
451
451
|
maxDepth: args.dfidDepth,
|
|
452
|
-
onOutput: (output) => printDepthFirst(printer, output),
|
|
452
|
+
onOutput: (output) => printDepthFirst(printer, output, timing.startTime),
|
|
453
453
|
});
|
|
454
454
|
printFinished();
|
|
455
455
|
return status;
|