tla-ts 0.0.9-dev.4ce0657 → 0.0.9-dev.7fe4429

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/run.cjs CHANGED
@@ -6,7 +6,7 @@
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=require("./worker.cjs"),t=require("./transfer.cjs"),n=require("./prove.cjs"),r=require("./tlapm.cjs");let i=require("node:path"),a=require("node:fs"),o=require("node:url"),s=require("node:os"),c=require("node:v8");const l=`META-INF/MANIFEST.MF`,u=async e=>{if(e===void 0||!(0,a.existsSync)(e))return`master`;let t=await import(`fflate`),n=t.unzipSync((0,a.readFileSync)(e),{filter:e=>e.name===l})[l];return(n&&/^X-Git-Tag: *(\S*)/m.exec(t.strFromU8(n))?.[1])===`v1.7.4`?`1.7.4`:`master`},d=/[*?[{]/,f=e=>e.flatMap(e=>d.test(e)?(0,a.globSync)(e).sort().map(e=>({path:e,isGlobbed:!0})):[{path:e,isGlobbed:!1}]),p=(e,t)=>e.map(e=>(0,i.join)(e,`${t}.tla`)).find(a.existsSync),m=e=>t=>{let n=p(e,t);return n===void 0?void 0:(0,a.readFileSync)(n,`utf8`)},h=(e,t,n)=>console.error(`File does not exist: ${e}/${t} while looking in these directories: ${e}, ${n.join(`, `)}, classpath:/tla2sany/StandardModules, classpath:/`),g=e=>`jar:file:${(0,o.pathToFileURL)((0,i.resolve)(e)).pathname}!/tla2sany/StandardModules/`,_=(n,r)=>{if(n instanceof e.h||n instanceof e._){let e=t.vt(n.message),i=e&&!e.isEvalException?e.code:t.dt.general;return r.print(i,t.ft.error,t.mt(i,n.message,r.isTool))}console.error(`${n.name}: ${n.message}`)},v=async(n,r=t.pt(!1))=>{try{return await n()}catch(t){if(!(t instanceof e.g))throw t;return _(t,r),e.H(t)}},y=(e,t,n)=>console.error(`File does not exist: ${(0,i.isAbsolute)(e)?e:`${process.cwd()}/${e}`} while looking in these directories: ${[...t,...n===void 0?[]:[g(n)]].join(`, `)}`),b=e=>e.endsWith(`/`)?e:`${e}/`,x=(e,n)=>r=>{let i=e(r);return i===void 0&&!t.I.has(r)&&n(`${r}.tla`),i},S=e=>e.classPath?.split(i.delimiter).find(e=>e.endsWith(`.jar`));var C=`0.0.9-dev.4ce0657`;const w=2224400062,T={int8:0,int16:1,int32:2,shared8:4,shared16:5,shared32:6,block32:8,string8:9,string32:10,doubleLittle:12},E={smallInt:64,smallString:32,smallBlock:128},D=(e,...t)=>({tag:e,fields:t}),O=e=>typeof e==`object`&&`tag`in e,ee=(t,n)=>{let r=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length<n+20||r.getUint32(n)!==w)throw new e.w(`corrupted fingerprint file`);let i=n+20+r.getUint32(n+4),a=[],o={position:n+20},s=t=>{let n=o.position;if(o.position+=t,o.position>i)throw new e.w(`corrupted fingerprint file`);return n},c=new TextDecoder,l=e=>{let n=s(e),r=c.decode(t.subarray(n,n+e));return a.push(r),r},u=(e,t)=>{let n=D(e);t>0&&a.push(n);for(let e=0;e<t;e++)n.fields.push(f());return n},d=e=>a[a.length-e],f=()=>{let n=t[s(1)];if(n>=E.smallBlock)return u(n&15,n>>4&7);if(n>=E.smallInt)return n&63;if(n>=E.smallString)return l(n&31);switch(n){case T.int8:return r.getInt8(s(1));case T.int16:return r.getInt16(s(2));case T.int32:return r.getInt32(s(4));case T.shared8:return d(r.getUint8(s(1)));case T.shared16:return d(r.getUint16(s(2)));case T.shared32:return d(r.getUint32(s(4)));case T.block32:{let e=r.getUint32(s(4));return u(e&255,e>>>10)}case T.string8:return l(r.getUint8(s(1)));case T.string32:return l(r.getUint32(s(4)));case T.doubleLittle:{let e={float:r.getFloat64(s(8),!0)};return a.push(e),e}}throw new e.w(`corrupted fingerprint file`)};return{value:f(),next:i}},te=e=>{let t=[],n={objects:0,words32:0,words64:0},r=(e,n)=>{for(let r=(n-1)*8;r>=0;r-=8)t.push(e>>>r&255)},i=new TextEncoder,a=e=>{if(typeof e==`number`)return e>=0&&e<64?t.push(E.smallInt+e):e>=-128&&e<128?t.push(T.int8,e&255):e>=-32768&&e<32768?(t.push(T.int16),r(e,2)):(t.push(T.int32),r(e,4));if(n.objects++,typeof e==`string`){let a=i.encode(e);a.length<32?t.push(E.smallString+a.length):a.length<256?t.push(T.string8,a.length):(t.push(T.string32),r(a.length,4)),t.push(...a),n.words32+=1+Math.floor((a.length+4)/4),n.words64+=1+Math.floor((a.length+8)/8);return}if(!O(e)){let r=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));r.setFloat64(0,e.float,!0),t.push(T.doubleLittle,...new Uint8Array(r.buffer)),n.words32+=3,n.words64+=2;return}let o=e.fields.length;o===0?n.objects--:(n.words32+=1+o,n.words64+=1+o),e.tag<16&&o<8?t.push(E.smallBlock+e.tag+(o<<4)):(t.push(T.block32),r(o*1024+e.tag,4)),e.fields.forEach(a)};a(e);let o=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(20));return[w,t.length,n.objects,n.words32,n.words64].forEach((e,t)=>o.setUint32(t*4,e)),new Uint8Array([...new Uint8Array(o.buffer),...t])},k=20210223,A={zenon:{field:1,tag:1},isabelle:{field:2,tag:0},smt:{field:10,tag:8},z3:{field:11,tag:9},ls4:{field:17,tag:16}},j=[`false`,`timeout`],ne=`tla-ts ${C}`,re=/* @__PURE__ */ new Map([[A.zenon.field,3],[A.isabelle.field,4]]),M=(e,t)=>e!==void 0&&O(e)?e.fields[t]:void 0,ie=e=>e!==void 0&&typeof e==`object`&&`float`in e?e.float:1/0,N=e=>{let t=new TextEncoder().encode(e),n=(e,t)=>e<<t|e>>>32-t,r=Array.from({length:Math.ceil(t.length/4)},(e,n)=>t[n*4]|t[n*4+1]<<8|t[n*4+2]<<16|t[n*4+3]<<24).reduce((e,t)=>{let r=Math.imul(n(Math.imul(t,3432918353),15),461845907);return Math.imul(n(e^r,13),5)+3864292196|0},0),i=Math.imul(r^t.length^(r^t.length)>>>16,2246822507),a=Math.imul(i^i>>>13,3266489909);return(a^a>>>16)&1073741823},ae=e=>e!==void 0&&O(e)?[[e.fields[0],e.fields[1]],...ae(e.fields[2])]:[],oe=(t,n,r)=>{let i=(0,a.readFileSync)(n),o=ee(i,0),s=ee(i,o.next).value;if(o.value!==k||!O(s)||s.tag!==0)throw new e.w(`corrupted fingerprint file`);let c=M(M(s,0),1),l=(e,t)=>{let n=re.get(t);return!r||n===void 0||M(M(e,0),n)===ne};t.clear(),(c!==void 0&&O(c)?c.fields:[]).flatMap(e=>ae(e).toReversed()).forEach(([n,r])=>{if(typeof n!=`string`||!O(r))throw new e.w(`corrupted fingerprint file`);t.set(n,r.fields.map((e,t)=>l(e,t)?e:0))})},se=(e,t)=>{let n=M(t,0),r=M(n,0),i=M(M(n,1),0);if(r===void 0||r===1)return;let a=ie(M(e===`isabelle`?M(i,0):i,0)),o=e===`isabelle`?M(i,1):void 0,s=M(M(r,0),0);return{method:{prover:e,timeLimitMs:a*1e3,...typeof o==`string`&&{tactic:o}},isProved:r===0,isReused:!1,...s!==void 0&&{reason:typeof s==`number`?j[s]:String(M(s,0))}}},ce=e=>{let t=/* @__PURE__ */ new Date,n=e.method,r={float:n.rlimit??n.timeLimitMs/1e3},i=n.prover===`zenon`?D(0,r,5):n.prover===`isabelle`?D(0,D(0,r),n.tactic??`auto`):D(0,r),a=j.indexOf(e.reason??``),o=e.reason===void 0?0:D(0,a===-1?D(0,e.reason):a);return D(0,D(0,D(0,e.isProved?0:D(0,o),D(A[n.prover].tag,i)),D(0,t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()),ne,ne,ne))},le=e=>{let t=2**Math.max(9,Math.ceil(Math.log2(e.size/2))),n=Array.from({length:t},()=>0);return e.forEach((e,r)=>{let i=N(r)&t-1;n[i]=D(0,r,D(0,...e),n[i])}),D(0,D(0,e.size,D(0,...n),0,512))},ue=e=>String(e).padStart(2,`0`),de=(e,t)=>{let n=/* @__PURE__ */ new Date,r=`${e}.history`,o=(0,i.join)(r,`${n.getFullYear()}-${ue(n.getMonth()+1)}-${ue(n.getDate())}_${ue(n.getHours())}_${ue(n.getMinutes())}_${ue(n.getSeconds())}`);(0,a.mkdirSync)(o,{recursive:!0}),[e,...t].filter(e=>(0,a.existsSync)(e)).forEach(e=>(0,a.cpSync)(e,(0,i.join)(o,(0,i.basename)(e)),{preserveTimestamps:!0})),(0,a.readdirSync)(r).map(e=>(0,i.join)(r,e)).sort((e,t)=>(0,a.statSync)(t).mtimeMs-(0,a.statSync)(e).mtimeMs).slice(10).forEach(e=>(0,a.rmSync)(e,{recursive:!0,force:!0}))},fe=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=new Map([...e].map(([e,r])=>{let i=new Map(Object.entries(A).flatMap(([e,n])=>{let i=se(e,M(r[n.field],0));return i?(t.set(i,r[n.field]),[[e,i]]):[]}));return n.set(i,r),[e,i]}));return{results:r,save:i=>{e.clear(),r.forEach((r,i)=>{let a=[...n.get(r)??Array(23).fill(0)];r.forEach((e,n)=>{a[A[n].field]=t.get(e)??ce(e)}),e.set(i,a)}),(0,a.writeFileSync)(`${i}.tmp`,Buffer.concat([te(k),te(le(e))])),(0,a.renameSync)(`${i}.tmp`,i)}}},pe=(e,t)=>{let n=new Map(t.map(e=>{let[t,...n]=e.flag.split(` `);return[t,e.getArity??(()=>n.length)]}));return{usage:e.replace(`{options}`,t.map(e=>`[${e.flag}]${e.isRepeatable?`...`:``}`).join(` `)),parse:e=>{let t=[],r=[],i=[],a=[];for(let o=0;o<e.length;o++){let s=n.get(e[o]);if(s===void 0){(e[o].startsWith(`-`)?i:r).push(e[o]);continue}let c=s(e.slice(o+1)),l={name:e[o],values:e.slice(o+1,o+1+c)};t.push(l),l.values.length<c&&a.push(l),o+=c}return{options:t,positionals:r,unknown:i,incomplete:a[0],has:e=>t.some(t=>t.name===e),get:e=>t.findLast(t=>t.name===e)?.values}}}},me=pe(`tla-ts <Spec.tla|Spec.cfg|spec.ts|glob>... {options}`,[{flag:`-config <Spec.cfg>`},{flag:`-continue`},{flag:`-deadlock`},{flag:`-dump [<format>] <file>`,getArity:e=>e.length>1&&e[0].startsWith(`dot`)?2:1},{flag:`-fp <num>`},{flag:`-lncheck <final|default>`},{flag:`-metadir <directory>`},{flag:`-nowarning`},{flag:`-seed <num>`},{flag:`-tool`},{flag:`-workers <count|auto>`}]),P=pe(`tla-ts tlapm {options} <Module.tla|glob>...`,[{flag:`-N`},{flag:`--summary`},{flag:`--strict`},{flag:`--toolbox <start> <end>`},{flag:`--line <num>`},{flag:`--printallobs`},{flag:`--threads <num>`},{flag:`--version`},{flag:`-I <directory>`,isRepeatable:!0},{flag:`-k`},{flag:`--noproving`},{flag:`--nofp`},{flag:`--nofpl <start> <end>`},{flag:`--safefp`},{flag:`--cleanfp`},{flag:`--usefp <file>`},{flag:`--cache-dir <directory>`}]),F=[`Usage: ${me.usage}`,` ${P.usage}`,` tla-ts [<JVM option>]... tlc2.TLC <TLC option>... <Spec>`,` (-cp tla2tools.jar or -Dtla-ts.tlc=1.7.4 picks the TLC to reproduce)`,` tla-ts [<JVM option>]... tla2sany.xml.XMLExporter [-I <directory>]... [-o] [-t] [-r] [-u] <Module.tla>`].join(`
9
+ const e=require("./worker.cjs"),t=require("./transfer.cjs"),n=require("./prove.cjs"),r=require("./tlapm.cjs");let i=require("node:path"),a=require("node:fs"),o=require("node:url"),s=require("node:os"),c=require("node:v8");const l=`META-INF/MANIFEST.MF`,u=async e=>{if(e===void 0||!(0,a.existsSync)(e))return`master`;let t=await import(`fflate`),n=t.unzipSync((0,a.readFileSync)(e),{filter:e=>e.name===l})[l];return(n&&/^X-Git-Tag: *(\S*)/m.exec(t.strFromU8(n))?.[1])===`v1.7.4`?`1.7.4`:`master`},d=/[*?[{]/,f=e=>e.flatMap(e=>d.test(e)?(0,a.globSync)(e).sort().map(e=>({path:e,isGlobbed:!0})):[{path:e,isGlobbed:!1}]),p=(e,t)=>e.map(e=>(0,i.join)(e,`${t}.tla`)).find(a.existsSync),m=e=>t=>{let n=p(e,t);return n===void 0?void 0:(0,a.readFileSync)(n,`utf8`)},h=(e,t,n)=>console.error(`File does not exist: ${e}/${t} while looking in these directories: ${e}, ${n.join(`, `)}, classpath:/tla2sany/StandardModules, classpath:/`),g=e=>`jar:file:${(0,o.pathToFileURL)((0,i.resolve)(e)).pathname}!/tla2sany/StandardModules/`,_=(n,r)=>{if(n instanceof e.h||n instanceof e._){let e=t.vt(n.message),i=e&&!e.isEvalException?e.code:t.dt.general;return r.print(i,t.ft.error,t.mt(i,n.message,r.isTool))}console.error(`${n.name}: ${n.message}`)},v=async(n,r=t.pt(!1))=>{try{return await n()}catch(t){if(!(t instanceof e.g))throw t;return _(t,r),e.H(t)}},y=(e,t,n)=>console.error(`File does not exist: ${(0,i.isAbsolute)(e)?e:`${process.cwd()}/${e}`} while looking in these directories: ${[...t,...n===void 0?[]:[g(n)]].join(`, `)}`),b=e=>e.endsWith(`/`)?e:`${e}/`,x=(e,n)=>r=>{let i=e(r);return i===void 0&&!t.I.has(r)&&n(`${r}.tla`),i},S=e=>e.classPath?.split(i.delimiter).find(e=>e.endsWith(`.jar`));var C=`0.0.9-dev.7fe4429`;const w=2224400062,T={int8:0,int16:1,int32:2,shared8:4,shared16:5,shared32:6,block32:8,string8:9,string32:10,doubleLittle:12},E={smallInt:64,smallString:32,smallBlock:128},D=(e,...t)=>({tag:e,fields:t}),O=e=>typeof e==`object`&&`tag`in e,ee=(t,n)=>{let r=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length<n+20||r.getUint32(n)!==w)throw new e.w(`corrupted fingerprint file`);let i=n+20+r.getUint32(n+4),a=[],o={position:n+20},s=t=>{let n=o.position;if(o.position+=t,o.position>i)throw new e.w(`corrupted fingerprint file`);return n},c=new TextDecoder,l=e=>{let n=s(e),r=c.decode(t.subarray(n,n+e));return a.push(r),r},u=(e,t)=>{let n=D(e);t>0&&a.push(n);for(let e=0;e<t;e++)n.fields.push(f());return n},d=e=>a[a.length-e],f=()=>{let n=t[s(1)];if(n>=E.smallBlock)return u(n&15,n>>4&7);if(n>=E.smallInt)return n&63;if(n>=E.smallString)return l(n&31);switch(n){case T.int8:return r.getInt8(s(1));case T.int16:return r.getInt16(s(2));case T.int32:return r.getInt32(s(4));case T.shared8:return d(r.getUint8(s(1)));case T.shared16:return d(r.getUint16(s(2)));case T.shared32:return d(r.getUint32(s(4)));case T.block32:{let e=r.getUint32(s(4));return u(e&255,e>>>10)}case T.string8:return l(r.getUint8(s(1)));case T.string32:return l(r.getUint32(s(4)));case T.doubleLittle:{let e={float:r.getFloat64(s(8),!0)};return a.push(e),e}}throw new e.w(`corrupted fingerprint file`)};return{value:f(),next:i}},te=e=>{let t=[],n={objects:0,words32:0,words64:0},r=(e,n)=>{for(let r=(n-1)*8;r>=0;r-=8)t.push(e>>>r&255)},i=new TextEncoder,a=e=>{if(typeof e==`number`)return e>=0&&e<64?t.push(E.smallInt+e):e>=-128&&e<128?t.push(T.int8,e&255):e>=-32768&&e<32768?(t.push(T.int16),r(e,2)):(t.push(T.int32),r(e,4));if(n.objects++,typeof e==`string`){let a=i.encode(e);a.length<32?t.push(E.smallString+a.length):a.length<256?t.push(T.string8,a.length):(t.push(T.string32),r(a.length,4)),t.push(...a),n.words32+=1+Math.floor((a.length+4)/4),n.words64+=1+Math.floor((a.length+8)/8);return}if(!O(e)){let r=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));r.setFloat64(0,e.float,!0),t.push(T.doubleLittle,...new Uint8Array(r.buffer)),n.words32+=3,n.words64+=2;return}let o=e.fields.length;o===0?n.objects--:(n.words32+=1+o,n.words64+=1+o),e.tag<16&&o<8?t.push(E.smallBlock+e.tag+(o<<4)):(t.push(T.block32),r(o*1024+e.tag,4)),e.fields.forEach(a)};a(e);let o=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(20));return[w,t.length,n.objects,n.words32,n.words64].forEach((e,t)=>o.setUint32(t*4,e)),new Uint8Array([...new Uint8Array(o.buffer),...t])},k=20210223,A={zenon:{field:1,tag:1},isabelle:{field:2,tag:0},smt:{field:10,tag:8},z3:{field:11,tag:9},ls4:{field:17,tag:16}},j=[`false`,`timeout`],ne=`tla-ts ${C}`,re=/* @__PURE__ */ new Map([[A.zenon.field,3],[A.isabelle.field,4]]),M=(e,t)=>e!==void 0&&O(e)?e.fields[t]:void 0,ie=e=>e!==void 0&&typeof e==`object`&&`float`in e?e.float:1/0,N=e=>{let t=new TextEncoder().encode(e),n=(e,t)=>e<<t|e>>>32-t,r=Array.from({length:Math.ceil(t.length/4)},(e,n)=>t[n*4]|t[n*4+1]<<8|t[n*4+2]<<16|t[n*4+3]<<24).reduce((e,t)=>{let r=Math.imul(n(Math.imul(t,3432918353),15),461845907);return Math.imul(n(e^r,13),5)+3864292196|0},0),i=Math.imul(r^t.length^(r^t.length)>>>16,2246822507),a=Math.imul(i^i>>>13,3266489909);return(a^a>>>16)&1073741823},ae=e=>e!==void 0&&O(e)?[[e.fields[0],e.fields[1]],...ae(e.fields[2])]:[],oe=(t,n,r)=>{let i=(0,a.readFileSync)(n),o=ee(i,0),s=ee(i,o.next).value;if(o.value!==k||!O(s)||s.tag!==0)throw new e.w(`corrupted fingerprint file`);let c=M(M(s,0),1),l=(e,t)=>{let n=re.get(t);return!r||n===void 0||M(M(e,0),n)===ne};t.clear(),(c!==void 0&&O(c)?c.fields:[]).flatMap(e=>ae(e).toReversed()).forEach(([n,r])=>{if(typeof n!=`string`||!O(r))throw new e.w(`corrupted fingerprint file`);t.set(n,r.fields.map((e,t)=>l(e,t)?e:0))})},se=(e,t)=>{let n=M(t,0),r=M(n,0),i=M(M(n,1),0);if(r===void 0||r===1)return;let a=ie(M(e===`isabelle`?M(i,0):i,0)),o=e===`isabelle`?M(i,1):void 0,s=M(M(r,0),0);return{method:{prover:e,timeLimitMs:a*1e3,...typeof o==`string`&&{tactic:o}},isProved:r===0,isReused:!1,...s!==void 0&&{reason:typeof s==`number`?j[s]:String(M(s,0))}}},ce=e=>{let t=/* @__PURE__ */ new Date,n=e.method,r={float:n.rlimit??n.timeLimitMs/1e3},i=n.prover===`zenon`?D(0,r,5):n.prover===`isabelle`?D(0,D(0,r),n.tactic??`auto`):D(0,r),a=j.indexOf(e.reason??``),o=e.reason===void 0?0:D(0,a===-1?D(0,e.reason):a);return D(0,D(0,D(0,e.isProved?0:D(0,o),D(A[n.prover].tag,i)),D(0,t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()),ne,ne,ne))},le=e=>{let t=2**Math.max(9,Math.ceil(Math.log2(e.size/2))),n=Array.from({length:t},()=>0);return e.forEach((e,r)=>{let i=N(r)&t-1;n[i]=D(0,r,D(0,...e),n[i])}),D(0,D(0,e.size,D(0,...n),0,512))},ue=e=>String(e).padStart(2,`0`),de=(e,t)=>{let n=/* @__PURE__ */ new Date,r=`${e}.history`,o=(0,i.join)(r,`${n.getFullYear()}-${ue(n.getMonth()+1)}-${ue(n.getDate())}_${ue(n.getHours())}_${ue(n.getMinutes())}_${ue(n.getSeconds())}`);(0,a.mkdirSync)(o,{recursive:!0}),[e,...t].filter(e=>(0,a.existsSync)(e)).forEach(e=>(0,a.cpSync)(e,(0,i.join)(o,(0,i.basename)(e)),{preserveTimestamps:!0})),(0,a.readdirSync)(r).map(e=>(0,i.join)(r,e)).sort((e,t)=>(0,a.statSync)(t).mtimeMs-(0,a.statSync)(e).mtimeMs).slice(10).forEach(e=>(0,a.rmSync)(e,{recursive:!0,force:!0}))},fe=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=new Map([...e].map(([e,r])=>{let i=new Map(Object.entries(A).flatMap(([e,n])=>{let i=se(e,M(r[n.field],0));return i?(t.set(i,r[n.field]),[[e,i]]):[]}));return n.set(i,r),[e,i]}));return{results:r,save:i=>{e.clear(),r.forEach((r,i)=>{let a=[...n.get(r)??Array(23).fill(0)];r.forEach((e,n)=>{a[A[n].field]=t.get(e)??ce(e)}),e.set(i,a)}),(0,a.writeFileSync)(`${i}.tmp`,Buffer.concat([te(k),te(le(e))])),(0,a.renameSync)(`${i}.tmp`,i)}}},pe=(e,t)=>{let n=new Map(t.map(e=>{let[t,...n]=e.flag.split(` `);return[t,e.getArity??(()=>n.length)]}));return{usage:e.replace(`{options}`,t.map(e=>`[${e.flag}]${e.isRepeatable?`...`:``}`).join(` `)),parse:e=>{let t=[],r=[],i=[],a=[];for(let o=0;o<e.length;o++){let s=n.get(e[o]);if(s===void 0){(e[o].startsWith(`-`)?i:r).push(e[o]);continue}let c=s(e.slice(o+1)),l={name:e[o],values:e.slice(o+1,o+1+c)};t.push(l),l.values.length<c&&a.push(l),o+=c}return{options:t,positionals:r,unknown:i,incomplete:a[0],has:e=>t.some(t=>t.name===e),get:e=>t.findLast(t=>t.name===e)?.values}}}},me=pe(`tla-ts <Spec.tla|Spec.cfg|spec.ts|glob>... {options}`,[{flag:`-config <Spec.cfg>`},{flag:`-continue`},{flag:`-deadlock`},{flag:`-dump [<format>] <file>`,getArity:e=>e.length>1&&e[0].startsWith(`dot`)?2:1},{flag:`-fp <num>`},{flag:`-lncheck <final|default>`},{flag:`-metadir <directory>`},{flag:`-nowarning`},{flag:`-seed <num>`},{flag:`-tool`},{flag:`-workers <count|auto>`}]),P=pe(`tla-ts tlapm {options} <Module.tla|glob>...`,[{flag:`-N`},{flag:`--summary`},{flag:`--strict`},{flag:`--toolbox <start> <end>`},{flag:`--line <num>`},{flag:`--printallobs`},{flag:`--threads <num>`},{flag:`--version`},{flag:`-I <directory>`,isRepeatable:!0},{flag:`-k`},{flag:`--noproving`},{flag:`--nofp`},{flag:`--nofpl <start> <end>`},{flag:`--safefp`},{flag:`--cleanfp`},{flag:`--usefp <file>`},{flag:`--cache-dir <directory>`}]),F=[`Usage: ${me.usage}`,` ${P.usage}`,` tla-ts [<JVM option>]... tlc2.TLC <TLC option>... <Spec>`,` (-cp tla2tools.jar or -Dtla-ts.tlc=1.7.4 picks the TLC to reproduce)`,` tla-ts [<JVM option>]... tla2sany.xml.XMLExporter [-I <directory>]... [-o] [-t] [-r] [-u] <Module.tla>`].join(`
10
10
  `),he=/* @__PURE__ */ new Set([`--toolbox`,`--line`,`--threads`,`--nofpl`]),ge=e=>[`.`,...r.t().map(e=>(0,i.join)((0,i.dirname)((0,i.dirname)((0,a.realpathSync)(e))),`lib/tlapm/stdlib`)).filter(e=>(0,a.existsSync)(e)).slice(0,1),...e.options.flatMap(e=>e.name===`-I`?e.values:[]).toReversed()],_e=e=>console.error(`@!!BEGIN\n${e.map(e=>`@!!${e}\n`).join(``)}@!!END\n`),ve=(e,t,n)=>_e([`type:obligation`,`id:${e.id}`,`loc:${e.location}`,`status:${t}`,...n]),ye=`9ed0376`,be=e=>/^[+,\-./0-9:=@A-Z_a-z]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`,xe={failed:10,incomplete:11,emptyTarget:12},Se=(e,t,r)=>{let i=e.summary;r||(i.absent.forEach(e=>console.error(`Missing proof at ${n.p(e)}`)),i.omitted.forEach(e=>console.error(`Omitted proof at ${n.p(e)}`)));let a=i.absent.length+i.omitted.length>0;a&&console.error(`${n.f(e.location)}[ERROR]: Proof incomplete in module ${JSON.stringify(e.name)}: ${i.absent.length} missing, ${i.omitted.length} omitted proof step(s).`);let o=t&&e.obligations.length===0;return o&&console.error(`${n.f(e.location)}[ERROR]: No proof obligation found for the selected target.`),[...a?[xe.incomplete]:[],...o?[xe.emptyTarget]:[]]},Ce=t=>{try{return t()}catch(t){if(!(t instanceof e.w))throw t;console.error(` tlapm ending abnormally with ${t.exception}\n`);return}},we=(e,t)=>{let r=t.method.timeLimitMs,i=t.timeUsedMs===void 0?``:`; time-used: ${(t.timeUsedMs/1e3).toFixed(1)} (${Math.round(100*t.timeUsedMs/r)}%)`,a=r===0?``:`time-limit: ${r===1/0?`inf`:Number((r/1e3).toPrecision(6))}${i}`,o=[t.method.tactic,a].filter(Boolean).join(`; `),s=(t.method.prover===`smt`||t.method.prover===`z3`)&&t.reason===`false`&&t.verdict?`(* SMT failed with status = ${t.verdict}\n *)\n`:``;ve(e,t.isProved?`proved`:`failed`,[`prover:${t.method.prover}`,...o===``?[]:[`meth:${o}`],...t.reason===void 0?[]:[`reason:${t.reason}`],`already:${t.isReused}`,...t.isProved?[]:[`obl:${t.isReused?``:`\n${s}`}${n.n(e,t.isReused)}`]])},Te=(e,t)=>ve(e,`failed`,[`prover:fail`,`meth:time-limit: inf`,`reason:${t}`,`already:false`,`obl:${e.text}`]),Ee=async(e,t,r,i)=>{let o=fe(i.fingerprints),s=await n.i(e.obligations,{workers:i.workers,results:o.results,isFingerprinted:i.isFingerprinted,isProving:i.isProving,onReport:(e,t)=>{if(i.isToolbox){if(e.obligation.status===`trivial`)return ve(t,`trivial`,[`prover:tlapm`,`already:false`]);if(t.kind.kind===`Error`)return Te(t,`user error`);e.attempts.forEach(e=>we(t,e))}}});if((0,a.writeFileSync)(t,n.t(e.name,s,e.obligations)),console.log(`(* created new ${JSON.stringify(t)} *)`),o.save(r),console.log(`(* fingerprints written in ${JSON.stringify(r)} *)`),!i.isProving)return!1;let c=s.flatMap((t,n)=>`reason`in t.obligation?[{report:t,obligation:e.obligations[n]}]:[]);i.isToolbox&&c.filter(e=>e.report.attempts.length===0&&e.obligation.kind.kind!==`Error`).forEach(e=>Te(e.obligation,`unexpected error`)),c.toReversed().forEach(e=>console.error(`${n.f(e.obligation.locus)}${n.d(n.u(`[ERROR]: @[<v2>Could not prove or check:@,%a@]`,n.l(e.obligation.sequent)),35)}`));let l=`${e.obligations.length} obligation${e.obligations.length>1?`s`:``}`;return console.error(c.length===0?`${n.f(e.location)}[INFO]: All ${l} proved.`:`${n.f(e.location)}[ERROR]: ${c.length}/${l} failed.\nThere were backend errors processing module \`${JSON.stringify(e.name)}\`.`),c.length>0},De=async r=>{let o=P.parse(r),c=!o.has(`-N`)&&!o.has(`--summary`),l=o.unknown[0]??(c&&o.has(`--printallobs`)?`--printallobs`:void 0);if(l!==void 0)return console.error(`Error: tla-ts tlapm does not support the tlapm option ${l}.`),1;if(o.incomplete)return console.error(`Error: option '${o.incomplete.name}' needs an argument.`),1;let u=o.options.find(e=>he.has(e.name)&&e.values.some(e=>!/^-?\d+$/.test(e)));if(u)return console.error(`Error: option '${u.name}' expects an integer.`),1;if(o.has(`--version`))return console.log(ye),e.G.success;let d=f(o.positionals).map(e=>e.path),p=d.map(e=>e.endsWith(`.tla`)?e:`${e}.tla`);if(p.length===0)return console.error(F),1;let m=o.has(`--toolbox`)||o.has(`--line`);m&&console.log(`\n\\* TLAPM version ${ye}\n\\* launched at ${t.gt(/* @__PURE__ */ new Date)} with command line:\n\\* ${[`tla-ts`,`tlapm`,...r].map(be).join(` `)}\n`);let h=o.options.reduce((e,t)=>{let[r,i]=t.values.map(Number);return t.name===`--toolbox`?{start:r,end:i===0?1/0:i}:t.name===`--line`?r===0?n.o:{start:r,end:r}:e},n.o),g=p.reduce((e,t)=>e.includes((0,i.dirname)(t))?e:[(0,i.dirname)(t),...e],ge(o)),_=/* @__PURE__ */ new Set,v=Ce(()=>{let t=p.findIndex(e=>!(0,a.existsSync)(e));if(t!==-1){let n=d[t];throw console.error(`File "<unknown>":\nError: File ${JSON.stringify(n)} not found`),new e.w(`File ${n} not found`,{failure:`Module.Parser.parse_file`})}return n.c(p.map(e=>({file:`./${e}`,source:(0,a.readFileSync)(e,`utf8`)})),e=>{_.add(e);let t=g.map(t=>`${t}/${e}.tla`).find(e=>(0,a.existsSync)(e));return t===void 0?e===`TLAPS`?{file:`TLAPS.tla`,source:n.a}:void 0:{file:t,source:(0,a.readFileSync)(t,`utf8`)}},{lines:h,onWarning:e=>{if(e.channel===`stdout`)return console.log(e.text);let t=e.channel===`toolbox`||e.channel===`toolboxOnly`;if(m&&t)return _e([`type:warning`,`msg:${e.text}`]);e.channel!==`toolboxOnly`&&console.error(e.text)}})});if(!v)return 3;let y=o.get(`--cache-dir`)?.[0]??process.env.TLAPM_CACHE_DIR??`.tlacache`,b=o.get(`--nofpl`)?.map(Number)??[0,0],x={isToolbox:m,isProving:!o.has(`--noproving`),workers:Math.max(1,Number(o.get(`--threads`)?.[0]??(0,s.availableParallelism)())),isFingerprinted:e=>!o.has(`--nofp`)&&!(e.locus&&e.locus.startLine>=b[0]&&e.locus.endLine<=b[1]),fingerprints:/* @__PURE__ */ new Map},S=[];for(let[e,t]of v.entries()){let r=`${y}/${t.name}.tlaps`,i=`${r}/fingerprints`,s=o.get(`--usefp`)?.[0]??i;if((0,a.mkdirSync)(r,{recursive:!0}),o.has(`--cleanfp`)&&(0,a.existsSync)(i)&&((0,a.rmSync)(i),console.log(`(* fingerprints file ${JSON.stringify(i)} removed *)`)),!o.has(`--cleanfp`)&&(0,a.existsSync)(s)&&t.summary.total!==0&&(console.log(o.has(`--nofp`)?`(* will not use fingerprints (because of option \`--nofp\`), but will now load fingerprints from the file \`${s}\`, in order to overwrite with the new fingerprints, and then save the results at the end. *)`:`(* loading fingerprints in ${JSON.stringify(s)} *)`),oe(x.fingerprints,s,o.has(`--safefp`))),o.has(`--summary`)&&console.log(n.s(t)),m&&(t.obligations.forEach(e=>ve(e,`to be proved`,o.has(`--printallobs`)?[`obl:${e.text}`]:[])),_e([`type:obligationsnumber`,`count:${t.obligations.length}`])),o.has(`--strict`)&&S.push(...Se(t,h.start>0||h.end<1/0,o.has(`--summary`))),!c)continue;de(i,[..._,...v.slice(0,e+1).map(e=>e.name)].map(e=>`${e}.tla`));let l=await Ee(t,`${r}/${t.name}.thy`,i,x);if(l&&o.has(`--strict`)&&S.push(xe.failed),l&&!o.has(`--strict`)&&!m)return console.error(` tlapm ending abnormally with Failure("backend errors: there are unproved obligations")
11
11
  Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
12
12
  Called from Tlapm_lib.process_module in file "src/tlapm_lib.ml", lines 492-493, characters 12-37
@@ -35,7 +35,7 @@ the name of a theorem, assumption, or step.`)),{...H(l()),kind:`UseOrHide`,facts
35
35
  Temporal formula used as set.`)),Hr(e,e.set)),e.levelCorrect;case`AssumeProve`:return e.levelChecked>=t||(e.levelChecked=t,e.levelCorrect=!0,e.assumptions.forEach(r=>{X(r,t,n)||(e.levelCorrect=!1)}),X(e.goal,t,n),e.level=e.assumptions.reduce((e,t)=>Math.max(e,t.level),e.goal.level),[e.goal,...e.assumptions].forEach(t=>Ur(e,t)),e.levelCorrect&&e.levelParams.forEach(t=>{t.kind===`OpDecl`&&t.declKind===2&&Lr(e.levelConstraints,t,2)})),e.levelCorrect}},yi=e=>{switch(e.kind){case`OpAppl`:return[...e.ranges,...e.operands];case`OpDef`:case`ThmOrAssumpDef`:case`Label`:return[e.body];case`LetIn`:return[...e.opDefs,...e.instances,e.body];case`SubstIn`:case`APSubstIn`:return[e.body,...e.substs.map(e=>e.expr)];case`Instance`:return e.substs.map(e=>e.expr);case`AssumeProve`:return[...e.assumptions,e.goal];case`NewSymb`:return[e.set];default:return[]}},bi=/* @__PURE__ */ new Map([[`Integers`,`Int`],[`Naturals`,`Nat`],[`Reals`,`Reals`]]),xi=e=>{let t=/* @__PURE__ */ new Set,n=e=>{if(e===void 0||t.has(e))return!1;if(t.add(e),e.kind===`OpAppl`){let t=e.operator;if(t.kind===`OpDecl`||t.kind===`FormalParam`)return!0;if(t.kind===`OpDef`){if(t.name===`BOOLEAN`)return!0;let e=t.module?.name;if(e!==void 0&&bi.get(e)===t.name||n(t))return!0}}return yi(e).some(n)};return n(e)},Si=e=>e.operands.filter(e=>e?.kind===`OpAppl`),Ci=e=>{let t=e.operands[0];return t?.kind===`String`?t:void 0},wi=e=>JSON.stringify([e.operands.length,...Si(e).map(e=>Ci(e)?.value).sort()]),Ti=(e,t=/* @__PURE__ */ new Set)=>(e.extendees.forEach(e=>{t.has(e)||(t.add(e),Ti(e,t))}),t),Ei=e=>{let t=e.records.map(t=>({domain:wi(t),warnings:Si(t).flatMap(t=>{let n=Ci(t),r=n&&Mn(e.context,n.value);return n===void 0||r===void 0?[]:[{location:n.location,text:`The field name "${n.value}" in the record constructor is identical to the existing definition or declaration\nnamed ${n.value}, located at ${yn(r.location)}.\nThe field in the record will not take the value of the ${n.value} definition or declaration.\nIn TLA+, field names in records are strings, regardless of any similarly named declarations or definitions.\nTherefore, DOMAIN [${n.value} |-> ...] = {"${n.value}"} holds true.`,isWarning:!0}]})})),n=new Set(t.flatMap(e=>e.warnings.length>0?[e.domain]:[])),r=/* @__PURE__ */ new Set;return[...[...Ti(e)].flatMap(e=>e.records),...e.records].forEach(e=>{let t=wi(e);n.has(t)&&!r.has(t)&&Si(e).some(xi)&&r.add(t)}),t.flatMap(e=>r.has(e.domain)?[]:e.warnings)},Di=e=>`${yn(e.location)}\n\n${e.text}`,Oi=e=>{let t=e.filter(e=>!e.isWarning),n=e.filter(e=>e.isWarning);return[t.length>0?`*** Errors: ${t.length}\n\n`:``,...t.map(e=>`${Di(e)}\n\n\n`),n.length>0?`*** Warnings: ${n.length}\n\n`:``,...n.map(e=>`${Di(e)}\n\n\n`)].join(``)},ki=/* @__PURE__ */ new Set([`FiniteSets`,`Sequences`,`Bags`,`Naturals`,`Integers`,`Reals`,`RealTime`,`Randomization`,`TLC`]),Ai=e=>{let t=/* @__PURE__ */ new Set,n=[],r=e=>{t.add(e.name),n.push(...e.extends),e.modules.forEach(r)};return r(e),n.filter(e=>!t.has(e))},ji=n=>{try{return t.H(sr(n))}catch(t){if(t instanceof e.O)return;throw t}},Mi=(e,n)=>n===`1.7.4`&&t.Kt(e)!==void 0?void 0:ji(e)?.name,Ni=(n,r,o={})=>{let s=(0,i.basename)(n,`.tla`),c=t.R(o.version),l=o.fileName??s,u=(0,a.existsSync)(n)?(0,a.readFileSync)(n,`utf8`):c.get(s),d=[],f=e=>{d.push(e),o.onPrint?.(e)},p=e=>f(`${e}\n`),m=o.version===`1.7.4`,h=m&&o.isXmlExport,g=e=>{o.isXmlExport||p(e)},_=o.describeFile,v=/* @__PURE__ */ new Map([[s,(0,a.existsSync)(n)?`file`:`standard`]]),y={value:!1},b=[],x={isReported:!1,isAborted:!1},S=mt(Oe(),p),C=/* @__PURE__ */ new Map,w=[],T=()=>w.splice(0).forEach(e=>e.isError?o.onPrintError?.(`${e.text}\n`):p(e.text)),E=e=>{let t=C.get(e),n=t?.module.location.range;if(t===void 0||n===void 0)return;let r=t.text.split(/\r\n|\r|\n/),i=mn(S,r.slice(n.start.line-1,n.end.line),o.version),a=i.has(`TLA_DIVERGENCE_EXISTS`),s=i.has(`PCAL_DIVERGENCE_EXISTS`),c=a===s?void 0:`The ${a?`TLA+ translation`:`PlusCal algorithm`} in module ${e} has changed since its last translation.`;if(m){let t=a&&s?`The PlusCal algorithm and its TLA+ translation in module ${e} filename since the last translation.`:c;t===void 0?i.has(`ERROR_ENCOUNTERED`)&&w.push({text:`A unexpected problem was encountered attempting to validate the specification for ${e}`,isError:!0}):w.push({text:`!! WARNING: ${t}`,isError:!1});return}let l=a&&s?`Both the PlusCal algorithm and its TLA+ translation in module ${e} have changed since the last translation.`:c??(i.has(`ERROR_ENCOUNTERED`)?`An unexpected problem was encountered attempting to validate the specification for ${e}`:void 0);if(l===void 0)return;let u=!i.has(`ERROR_ENCOUNTERED`)||a||s;b.some(e=>e.text===l)||b.push({location:e,text:l,isWarning:u})},D=(e,t)=>{if(o.isXmlExport||C.has(e))return;let n=ji(t);if(n===void 0||n.name!==e)return;let r=[...C.values()].filter(t=>Ai(t.module).includes(e));C.set(e,{text:t,module:n}),r.forEach(()=>E(e)),Ai(n).filter(t=>t!==e&&C.has(t)).forEach(E)},O=()=>{if(T(),x.isReported)return;x.isReported=!0;let e=b.filter(e=>e.isWarning);e.length>0&&(g(`Warnings (${e.length}) during syntax parsing of ${l}:\n\n`),e.forEach(e=>g(`${Di(e)}\n\n\n`))),e.length!==b.length&&(p(Oi(b)),y.value=!0,x.isAborted=!0)},ee=e=>{let n=c.get(e),i=r(e),a=i===void 0&&n===void 0&&u!==void 0&&!m?t.B(u,e):void 0,o=i??a;return v.set(e,i===void 0?a===void 0?`standard`:`root file`:`file`),o!==void 0&&D(e,o),o??n},te=(()=>{try{if(u===void 0)throw new e.E(`Cannot find source file for module ${l}`,void 0);return D(s,u),Nr(u,ee,{rootFileName:s,rootFilePath:o.isXmlExport?`${l.replace(/\.tla$/,``)}.tla`:void 0,version:o.version,rootExtendees:o.rootExtendees,onParse:e=>{_&&p(`Parsing file ${_(e,v.get(e)??`file`)}`),e===s&&E(s),T()},onAnalyze:e=>{O(),(_||h)&&!x.isAborted&&p(`Semantic processing of module ${e}`)},onModule:(e,t)=>{if(x.isAborted||(t.every(e=>e.isWarning)&&hi(e,{messages:t,isTlc174:m}),t.length===0))return;if(t.some(e=>!e.isWarning)&&(y.value=!0),m)return p(`Semantic errors:\n\n${Oi(t)}`);let n=t.filter(e=>e.isWarning);n.length>0&&(g(`*** Warnings: ${n.length}\n`),n.forEach(e=>g(`${Di(e)}\n\n\n`)));let r=t.filter(e=>!e.isWarning);r.length!==0&&(p(`Semantic errors:\n\n*** Errors: ${r.length}\n`),r.forEach(e=>p(`${Di(e)}\n\n`)))}})}catch(t){if(y.value=!0,t instanceof e.c){p(`\nFatal errors while parsing TLA+ spec in file ${l}\n`),p(t.message),p(Oi(b));return}if(!(t instanceof e.E))throw t;let n={location:t.location,text:t.message,isWarning:!1},r=m&&t.parseError?.includes(` and token "" `);if(t.parseError!==void 0&&!r&&!h&&p(t.parseError),p(`\nFatal errors while parsing TLA+ spec in file ${l}\n`),r){p(`java.lang.NullPointerException: Cannot invoke "String.length()" because "str" is null`);return}if(m){p(`tla2sany.semantic.AbortException`),f(`*** Abort messages: 1\n\n${Di(n)}\n\n\n`);return}p(Di(n)),p(Oi(x.isReported?[n]:[...b,n]))}})();if(te!==void 0&&O(),te!==void 0&&!y.value&&!o.isXmlExport&&!m){let e=te.modules.filter(e=>!ki.has(e.name));_&&e.forEach(e=>p(`Linting of module ${e.name}`)),e.flatMap(Ei).forEach(e=>p(`${Di(e)}\n\n\n`))}return{text:d.join(``),isFailed:y.value,specification:x.isAborted?void 0:te}},Pi=async t=>{let n=(await Promise.resolve().then(()=>require("./compile.cjs"))).compile((0,a.readFileSync)(t,`utf8`),t),r=`\\* Generated by tla-ts from ${(0,i.basename)(t)}. Edit ${(0,i.basename)(t)} instead.`,o=(0,i.join)((0,i.dirname)(t),`${n.name}.tla`),s=(0,i.join)((0,i.dirname)(t),`${n.name}.cfg`);for(let n of[o,s])if((0,a.existsSync)(n)&&!(0,a.readFileSync)(n,`utf8`).startsWith(r))throw new e.k(`${n} already exists, and tla-ts didn't generate it from ${t}`);return(0,a.writeFileSync)(o,`${r}\n${n.source}\n`),(0,a.writeFileSync)(s,`${r}\n${n.config}\n`),o},Fi={success:e.G.success,"assumption-violation":e.G.assumptionViolation,deadlock:e.G.deadlock,"invariant-violation":e.G.safetyViolation,"property-violation":e.G.safetyViolation,"liveness-violation":e.G.livenessViolation,"postcondition-violation":e.G.assumptionViolation,error:e.G.error},Ii=e=>/^[+-]?\d+$/.test(e)&&BigInt.asIntN(64,BigInt(e))===BigInt(e),Li=e=>e?e[0]===`auto`?(0,s.availableParallelism)():Math.max(1,Number.parseInt(e[0],10)||1):1,Ri=[`constrained`,`stuttering`,`strict`],zi=(e,t)=>e.endsWith(t)?e:`${e}${t}`,Bi=e=>{if(e.length===1)return{path:zi(e[0],`.dump`)};let t=e[0].toLowerCase();return{path:zi(e[1],`.dot`),dot:!0,colorize:t.includes(`colorize`),actionLabels:t.includes(`actionlabels`),snapshot:t.includes(`snapshot`)}},Vi=(e,n)=>e.print(t.dt.computingInitProgress,t.ft.none,`Computed ${n} initial states...`),Hi=(e,n)=>e===`invariant-violation`?{code:t.dt.invariantViolatedInitial,text:`Invariant ${n} is violated by the initial state:`}:{code:t.dt.propertyViolatedInitial,text:`Property ${n} is violated by the initial state:`},Ui=(e,n)=>n?.forEach(n=>{if(typeof n==`string`)return console.log(n);if(n.kind===`initial-states-progress`)return Vi(e,n.count);let r=Hi(n.status,n.name);e.print(r.code,t.ft.error,`${r.text}\n${t.At(n.state)}`)}),Wi=(e,n,r={code:t.dt.behaviorUpToThisPoint,text:`The behavior up to this point is:`},i=!1)=>{n.length>0&&e.print(r.code,t.ft.error,r.text),n.forEach((n,r)=>{(r>0||i)&&Ui(e,n.output),e.print(t.dt.statePrint2,t.ft.state,`${r+1}: <${n.label??n.action??`Initial predicate`}>\n${t.At(n.state)}`)})},Gi={code:t.dt.counterExample,text:`The following behavior constitutes a counter-example:
36
36
  `},Ki=(e,t)=>t===`1.7.4`||e.length===0?`Temporal properties were violated.
37
37
  `:e.length===1?`Temporal property ${e[0]} was violated.\n`:`Temporal properties ${e.slice(0,-1).join(`, `)}${e.length>2?`,`:``} and ${e[e.length-1]} were violated.\n`,qi=e=>e.filter((t,n)=>t!==e[n-1]).map((e,n)=>`${n}) ${t.Y(e)}\n`).toReversed().join(``),Ji=e=>{if(e.length===0)return` The error call stack is empty.
38
- `;let t=[];return e.forEach((n,r)=>{let i=n.location.range;n!==e[r-1]&&i&&t.push(`${t.length}. Line ${i.start.line}, column ${i.start.column} to line ${i.end.line}, column ${i.end.column} in ${i.module}\n`)}),`${t.join(``)}\n`},Yi=(e,n)=>{let r=n.generated,i=n.distinct,a=t.gt(/* @__PURE__ */ new Date);r===i?e.print(t.dt.initGenerated1,t.ft.none,`Finished computing initial states: ${i} distinct state${i===1?``:`s`} generated at ${a}.`):e.print(t.dt.initGenerated2,t.ft.none,`Finished computing initial states: ${r} state${r===1?``:`s`} generated, with ${i} of them distinct at ${a}.`)},Xi=(e,n,r)=>{let i=Math.max(Date.now()-(r??0),1)/6e4,a=e=>e.toLocaleString(`en-US`),o=(e,t)=>r===void 0?``:` (${a(Math.floor(e/i))} ${t}/min)`;e.print(t.dt.progress,t.ft.none,`Progress(${Math.max(n.depth,1)}) at ${t.gt(/* @__PURE__ */ new Date)}: ${a(n.generatedStates)} states generated${o(n.generatedStates,`s`)}, ${a(n.distinctStates)} distinct states found${o(n.distinctStates,`ds`)}, ${a(n.queuedStates)} states left on queue.`)},Zi=(e,t)=>(0,i.join)(e,`${t}.class`),Qi=(e,n,r,a)=>{let s=e.print;switch(n.kind){case`parsed`:r.isParsed=!0,e.isTool&&s(t.dt.sanyFinished,t.ft.none,`SANY finished.`),s(t.dt.starting,t.ft.none,`Starting... (${t.gt(/* @__PURE__ */ new Date)})`);return;case`constant-level-invariant`:if(e.version===`1.7.4`)return;s(t.dt.constantLevelInvariant,t.ft.warning,`The invariant ${n.name} is a constant-level formula (i.e., it contains no variables, primes, or temporal operators) and evaluates to TRUE. To assert constant-level formulas in your spec, use ASSUME ConstInv. If you optionally want to give the assumption a name, write ASSUME YourAssumption == ConstInv instead. See https://explain.tlapl.us/assumptions-and-invariants for additional details.`);return;case`state-level-property`:if(e.version===`1.7.4`)return;s(t.dt.stateLevelProperty,t.ft.warning,`The formula ${n.name} is a state-level formula, but it was used as a PROPERTY (or PROPERTIES), where a temporal formula is typically expected. State-level formulas used as PROPERTY or PROPERTIES are only checked in the initial state. To verify that the formula ${n.name} holds in all states of every behavior, use INVARIANT ${n.name} instead. Alternatively, applying the "always" temporal operator ([]) to the state-level formula ${n.name} changes it into a temporal formula, asserting that ${n.name} holds in all states of every behavior. See https://explain.tlapl.us/invariants-and-properties for additional details.`);return;case`liveness-initializing`:n.isSymmetric&&s(t.dt.livenessSymmetry,t.ft.warning,`Declaring symmetry during liveness checking is dangerous. It might cause TLC to miss violations of the stated liveness properties. Please check liveness without symmetry defined.`),n.isConstrained&&e.version===`1.7.4`&&s(t.dt.livenessConstraints,t.ft.warning,`Declaring state or action constraints during liveness checking is dangerous: Please read section 14.3.5 on page 247 of Specifying Systems (https://lamport.azurewebsites.net/tla/book.html) and optionally the discussion at https://discuss.tlapl.us/msg00994.html for more details.`);return;case`liveness-prepared`:s(t.dt.temporalBranches,t.ft.none,`Implied-temporal checking--satisfiability problem has ${n.branches} branches.`);return;case`java-override`:{let e=(0,o.pathToFileURL)((0,i.resolve)(Zi(a,n.module))).href;s(n.isMatched?t.dt.javaOverrideLoaded:t.dt.javaOverrideMismatch,n.isMatched?t.ft.none:t.ft.warning,`${n.isMatched?`Loading`:`Failed to match`} ${n.operator} operator override from ${e.replace(`file:///`,`file:/`)} with signature: <Java Method: ${n.signature}>.`);return}case`initial-states-started`:s(t.dt.computingInit,t.ft.none,`Computing initial states...`);return;case`initial-states-progress`:Vi(e,n.count);return;case`initial-states-computed`:Yi(e,n.initialStates);return;case`progress`:Xi(e,n.statistics,r.startTime);return;case`liveness-started`:{r.livenessStartTime=Date.now(),n.isComplete&&Xi(e,n.statistics);let i=n.branches>1?`${n.branches} branches of `:``,a=n.branches*n.states;s(t.dt.checkingTemporal,t.ft.none,`Checking ${i}temporal properties for the ${n.isComplete?`complete`:`current`} state space with ${a} total distinct states at (${t.gt(/* @__PURE__ */ new Date)})`);return}case`liveness-finished`:$i(e,r);return;case`sequential-fallback`:process.stderr.write(`Warning: the search created the string ${JSON.stringify(n.string)}, so tla-ts checks the model again with one worker. Workers agree on the order of strings only when the strings exist before the search.\n`);return;case`warning`:s(n.code,t.ft.warning,n.text);return;case`violation`:ea(n.status,n.violation,e)}},$i=(e,n)=>{n.livenessStartTime!==void 0&&(e.print(t.dt.checkingTemporalEnd,t.ft.none,`Finished checking temporal properties in ${t._t(Date.now()-n.livenessStartTime)} at ${t.gt(/* @__PURE__ */ new Date)}`),n.livenessStartTime=void 0)},ea=(e,n,r)=>{let i=r.print,a=n.name,o=n.loopStart,s=o===void 0&&n.trace.length===1&&(e===`invariant-violation`||e===`liveness-violation`),c={code:t.dt.temporalPropertyViolated,text:Ki(n.properties??[a],r.version)},l={success:void 0,error:void 0,"assumption-violation":n.message?{code:t.dt.assumptionEvaluationError,text:t.mt(t.dt.assumptionEvaluationError,`Evaluating assumption ${a} failed.\n${n.message}`,r.isTool)}:{code:t.dt.assumptionFalse,text:`Assumption ${a} is false.`},deadlock:{code:t.dt.deadlockReached,text:`Deadlock reached.`},"invariant-violation":s?Hi(`invariant-violation`,a):{code:t.dt.invariantViolatedBehavior,text:`Invariant ${a} is violated.`},"property-violation":c,"liveness-violation":o===void 0?s?Hi(`liveness-violation`,a):{code:t.dt.actionPropertyViolatedBehavior,text:`Action property ${a} is violated.`}:c,"postcondition-violation":{code:n.postcondition?.code??t.dt.general,text:n.message??`Postcondition ${a} is false.`}}[e],u=e===`property-violation`,d=o!==void 0&&!u,f=u||d,p=f&&r.version!==`1.7.4`;if(p&&Ui(r,n.trace[0]?.output),n.counts&&console.log(n.counts),l){let e=s?`${l.text}\n${t.At(n.trace[0].state)}`:l.text;i(l.code,t.ft.error,e)}if(s||(f||Ui(r,n.trace[0]?.output),Wi(r,n.trace,f?Gi:void 0,f&&!p),Ui(r,n.traceOutput)),d){let e=n.loopLabel;o===n.trace.length-1?i(t.dt.statePrint3,t.ft.state,`${o+2}: Stuttering`):r.isTool?i(t.dt.backToState,t.ft.state,`${o+1}: Back to state${e?`: <${e}>\n`:``}`):console.log(`Back to state ${o+1}${e?`: <${e}>\n`:``}`)}n.warning&&r.version!==`1.7.4`&&i(n.warning.code,t.ft.warning,n.warning.text);let m=n.unwitnessed??(e===`postcondition-violation`?void 0:n.postcondition);return m?.counts&&console.log(m.counts),m&&i(m.code,t.ft.error,m.message),!s&&e!==`assumption-violation`},ta=(e,n)=>e.print(t.dt.nestedExpression,t.ft.error,`The error occurred when TLC was evaluating the nested\nexpressions at the following positions:\n${Ji(n)}`),na=(n,r,i)=>{let a=r.print;if(n.failure){let i=n.failure,o=r.isTool?i.toolMessage:i.message,s=()=>{let e=i.fingerprint;if(e){let n=i.callStack?.length&&r.version!==`1.7.4`?Ji(i.callStack):qi(e.sources);a(t.dt.fingerprintFailed,t.ft.error,`TLC was unable to fingerprint.\n\nFingerprint Stack Trace:\n${n}\nReason:\n${t.ht(e.reason,r.isTool)}`)}else i.callStack&&ta(r,i.callStack)};i.isCallStackFirst&&s();let c=i.initialState&&(()=>{try{return`While working on the initial state:\n${t.At(i.initialState)}`}catch(t){throw t instanceof e._?e.q(new e._(`${e.F}${t.message}`),e.G.error):t}})();a(c?t.dt.initialState:i.code,t.ft.error,c?`${o}\n${c}`:o),Ui(r,i.trace[0]?.output),Wi(r,i.trace);let l=i.traceFailure;l&&a(l.code,t.ft.error,r.isTool?l.toolMessage:l.message),Ui(r,i.traceOutput);let u=i.postcondition;u?.counts&&console.log(u.counts),u&&a(u.code,t.ft.error,u.message),i.isCallStackFirst||s()}else if(n.violation){if(!ea(n.status,n.violation,r))return;let e=n.additionalViolation;e&&ea(`property-violation`,e,r),n.liveCallStack&&ta(r,n.liveCallStack)}else{$i(r,i);let e=t.f(n.distinctStates,n.generatedStates),o=n.fingerprintDistance===void 0?[]:[` based on the actual fingerprints: val = ${t.l(t.u(n.fingerprintDistance))}`];a(t.dt.success,t.ft.none,[`Model checking completed. No error has been found.`,` Estimates of the probability that TLC did not check all reachable states`,` because two distinct states had the same fingerprint:`,` calculated (optimistic): val = ${t.l(e)}`,...o].join(`
38
+ `;let t=[];return e.forEach((n,r)=>{let i=n.location.range;n!==e[r-1]&&i&&t.push(`${t.length}. Line ${i.start.line}, column ${i.start.column} to line ${i.end.line}, column ${i.end.column} in ${i.module}\n`)}),`${t.join(``)}\n`},Yi=(e,n)=>{let r=n.generated,i=n.distinct,a=t.gt(/* @__PURE__ */ new Date);r===i?e.print(t.dt.initGenerated1,t.ft.none,`Finished computing initial states: ${i} distinct state${i===1?``:`s`} generated at ${a}.`):e.print(t.dt.initGenerated2,t.ft.none,`Finished computing initial states: ${r} state${r===1?``:`s`} generated, with ${i} of them distinct at ${a}.`)},Xi=(e,n,r)=>{let i=Math.max(Date.now()-(r??0),1)/6e4,a=e=>e.toLocaleString(`en-US`),o=(e,t)=>r===void 0?``:` (${a(Math.floor(e/i))} ${t}/min)`;e.print(t.dt.progress,t.ft.none,`Progress(${Math.max(n.depth,1)}) at ${t.gt(/* @__PURE__ */ new Date)}: ${a(n.generatedStates)} states generated${o(n.generatedStates,`s`)}, ${a(n.distinctStates)} distinct states found${o(n.distinctStates,`ds`)}, ${a(n.queuedStates)} states left on queue.`)},Zi=(e,t)=>(0,i.join)(e,`${t}.class`),Qi=(e,n,r,a)=>{let s=e.print;switch(n.kind){case`parsed`:r.isParsed=!0,e.isTool&&s(t.dt.sanyFinished,t.ft.none,`SANY finished.`),s(t.dt.starting,t.ft.none,`Starting... (${t.gt(/* @__PURE__ */ new Date)})`);return;case`constant-level-invariant`:if(e.version===`1.7.4`)return;s(t.dt.constantLevelInvariant,t.ft.warning,`The invariant ${n.name} is a constant-level formula (i.e., it contains no variables, primes, or temporal operators) and evaluates to TRUE. To assert constant-level formulas in your spec, use ASSUME ConstInv. If you optionally want to give the assumption a name, write ASSUME YourAssumption == ConstInv instead. See https://explain.tlapl.us/assumptions-and-invariants for additional details.`);return;case`state-level-property`:if(e.version===`1.7.4`)return;s(t.dt.stateLevelProperty,t.ft.warning,`The formula ${n.name} is a state-level formula, but it was used as a PROPERTY (or PROPERTIES), where a temporal formula is typically expected. State-level formulas used as PROPERTY or PROPERTIES are only checked in the initial state. To verify that the formula ${n.name} holds in all states of every behavior, use INVARIANT ${n.name} instead. Alternatively, applying the "always" temporal operator ([]) to the state-level formula ${n.name} changes it into a temporal formula, asserting that ${n.name} holds in all states of every behavior. See https://explain.tlapl.us/invariants-and-properties for additional details.`);return;case`liveness-initializing`:n.isSymmetric&&s(t.dt.livenessSymmetry,t.ft.warning,`Declaring symmetry during liveness checking is dangerous. It might cause TLC to miss violations of the stated liveness properties. Please check liveness without symmetry defined.`),n.isConstrained&&e.version===`1.7.4`&&s(t.dt.livenessConstraints,t.ft.warning,`Declaring state or action constraints during liveness checking is dangerous: Please read section 14.3.5 on page 247 of Specifying Systems (https://lamport.azurewebsites.net/tla/book.html) and optionally the discussion at https://discuss.tlapl.us/msg00994.html for more details.`);return;case`liveness-prepared`:s(t.dt.temporalBranches,t.ft.none,`Implied-temporal checking--satisfiability problem has ${n.branches} branches.`);return;case`java-override`:{let e=(0,o.pathToFileURL)((0,i.resolve)(Zi(a,n.module))).href;s(n.isMatched?t.dt.javaOverrideLoaded:t.dt.javaOverrideMismatch,n.isMatched?t.ft.none:t.ft.warning,`${n.isMatched?`Loading`:`Failed to match`} ${n.operator} operator override from ${e.replace(`file:///`,`file:/`)} with signature: <Java Method: ${n.signature}>.`);return}case`initial-states-started`:s(t.dt.computingInit,t.ft.none,`Computing initial states...`);return;case`initial-states-progress`:Vi(e,n.count);return;case`initial-states-computed`:Yi(e,n.initialStates);return;case`progress`:Xi(e,n.statistics,r.startTime);return;case`liveness-started`:{r.livenessStartTime=Date.now(),n.isComplete&&Xi(e,n.statistics);let i=n.branches>1?`${n.branches} branches of `:``,a=n.branches*n.states;s(t.dt.checkingTemporal,t.ft.none,`Checking ${i}temporal properties for the ${n.isComplete?`complete`:`current`} state space with ${a} total distinct states at (${t.gt(/* @__PURE__ */ new Date)})`);return}case`liveness-finished`:$i(e,r);return;case`sequential-fallback`:process.stderr.write(`Warning: the search ordered the string ${JSON.stringify(n.string)} against another string it created, so tla-ts checks the model again with one worker. Workers don't agree on the order of strings the search creates.\n`);return;case`warning`:s(n.code,t.ft.warning,n.text);return;case`violation`:ea(n.status,n.violation,e)}},$i=(e,n)=>{n.livenessStartTime!==void 0&&(e.print(t.dt.checkingTemporalEnd,t.ft.none,`Finished checking temporal properties in ${t._t(Date.now()-n.livenessStartTime)} at ${t.gt(/* @__PURE__ */ new Date)}`),n.livenessStartTime=void 0)},ea=(e,n,r)=>{let i=r.print,a=n.name,o=n.loopStart,s=o===void 0&&n.trace.length===1&&(e===`invariant-violation`||e===`liveness-violation`),c={code:t.dt.temporalPropertyViolated,text:Ki(n.properties??[a],r.version)},l={success:void 0,error:void 0,"assumption-violation":n.message?{code:t.dt.assumptionEvaluationError,text:t.mt(t.dt.assumptionEvaluationError,`Evaluating assumption ${a} failed.\n${n.message}`,r.isTool)}:{code:t.dt.assumptionFalse,text:`Assumption ${a} is false.`},deadlock:{code:t.dt.deadlockReached,text:`Deadlock reached.`},"invariant-violation":s?Hi(`invariant-violation`,a):{code:t.dt.invariantViolatedBehavior,text:`Invariant ${a} is violated.`},"property-violation":c,"liveness-violation":o===void 0?s?Hi(`liveness-violation`,a):{code:t.dt.actionPropertyViolatedBehavior,text:`Action property ${a} is violated.`}:c,"postcondition-violation":{code:n.postcondition?.code??t.dt.general,text:n.message??`Postcondition ${a} is false.`}}[e],u=e===`property-violation`,d=o!==void 0&&!u,f=u||d,p=f&&r.version!==`1.7.4`;if(p&&Ui(r,n.trace[0]?.output),n.counts&&console.log(n.counts),l){let e=s?`${l.text}\n${t.At(n.trace[0].state)}`:l.text;i(l.code,t.ft.error,e)}if(s||(f||Ui(r,n.trace[0]?.output),Wi(r,n.trace,f?Gi:void 0,f&&!p),Ui(r,n.traceOutput)),d){let e=n.loopLabel;o===n.trace.length-1?i(t.dt.statePrint3,t.ft.state,`${o+2}: Stuttering`):r.isTool?i(t.dt.backToState,t.ft.state,`${o+1}: Back to state${e?`: <${e}>\n`:``}`):console.log(`Back to state ${o+1}${e?`: <${e}>\n`:``}`)}n.warning&&r.version!==`1.7.4`&&i(n.warning.code,t.ft.warning,n.warning.text);let m=n.unwitnessed??(e===`postcondition-violation`?void 0:n.postcondition);return m?.counts&&console.log(m.counts),m&&i(m.code,t.ft.error,m.message),!s&&e!==`assumption-violation`},ta=(e,n)=>e.print(t.dt.nestedExpression,t.ft.error,`The error occurred when TLC was evaluating the nested\nexpressions at the following positions:\n${Ji(n)}`),na=(n,r,i)=>{let a=r.print;if(n.failure){let i=n.failure,o=r.isTool?i.toolMessage:i.message,s=()=>{let e=i.fingerprint;if(e){let n=i.callStack?.length&&r.version!==`1.7.4`?Ji(i.callStack):qi(e.sources);a(t.dt.fingerprintFailed,t.ft.error,`TLC was unable to fingerprint.\n\nFingerprint Stack Trace:\n${n}\nReason:\n${t.ht(e.reason,r.isTool)}`)}else i.callStack&&ta(r,i.callStack)};i.isCallStackFirst&&s();let c=i.initialState&&(()=>{try{return`While working on the initial state:\n${t.At(i.initialState)}`}catch(t){throw t instanceof e._?e.q(new e._(`${e.F}${t.message}`),e.G.error):t}})();a(c?t.dt.initialState:i.code,t.ft.error,c?`${o}\n${c}`:o),Ui(r,i.trace[0]?.output),Wi(r,i.trace);let l=i.traceFailure;l&&a(l.code,t.ft.error,r.isTool?l.toolMessage:l.message),Ui(r,i.traceOutput);let u=i.postcondition;u?.counts&&console.log(u.counts),u&&a(u.code,t.ft.error,u.message),i.isCallStackFirst||s()}else if(n.violation){if(!ea(n.status,n.violation,r))return;let e=n.additionalViolation;e&&ea(`property-violation`,e,r),n.liveCallStack&&ta(r,n.liveCallStack)}else{$i(r,i);let e=t.f(n.distinctStates,n.generatedStates),o=n.fingerprintDistance===void 0?[]:[` based on the actual fingerprints: val = ${t.l(t.u(n.fingerprintDistance))}`];a(t.dt.success,t.ft.none,[`Model checking completed. No error has been found.`,` Estimates of the probability that TLC did not check all reachable states`,` because two distinct states had the same fingerprint:`,` calculated (optimistic): val = ${t.l(e)}`,...o].join(`
39
39
  `))}if(n.failure?.isWithoutStatistics)return;n.status!==`success`&&$i(r,i),r.isTool&&Xi(r,n,i.startTime),a(t.dt.stats,t.ft.none,`${n.generatedStates} states generated, ${n.distinctStates} distinct states found, ${n.queuedStates} states left on queue.`);let o=r.version===`1.7.4`,s=o?n.outDegrees??n.violationOutDegrees:n.outDegrees;(!o||s)&&a(t.dt.searchDepth,t.ft.none,`The depth of the complete state graph search is ${o?Math.max(n.depth,1):n.depth}.`);let c=s&&t.p(s);c&&a(t.dt.stateGraphOutdegree,t.ft.none,c)},ra=e=>t.z([e]).toString(),ia=(e,t,n,r,o)=>{let c=n.temporaryDirectory??(0,s.tmpdir)(),l=(0,a.existsSync)(c)?(0,a.realpathSync)(c):(0,i.resolve)(c),u=(0,i.join)(l,`tlc-${ra((0,i.resolve)(e))}`),d=S(n);return(n,s)=>{let c=`${n}.tla`;if(s===`file`)return(0,a.realpathSync)(p(t,n)??e);if(o===`1.7.4`)return(0,i.join)(l,c);if(s===`root file`){let t=r===void 0?l:(0,i.resolve)(r),o=(0,a.realpathSync)(e);return`${(0,i.join)(t,ra(`${o} ${n}`),c)} (${o})`}let f=(0,i.join)(u,c);return d===void 0?f:`${f} (${g(d)}${c})`}},aa=e=>e.print(t.dt.version,t.ft.none,`TLC2 Version ${C} (rev: tla-ts)`),oa=(e,n)=>(aa(e),e.print(t.dt.commandLineError,t.ft.error,`${n}\nUsage: java tlc2.TLC [-help] [-option] inputfile`),1),sa=(e,n,r)=>e.print(t.dt.modelChecking,t.ft.none,`Running breadth-first search Model-Checking with fp 0 and seed ${BigInt(n)} with ${r} worker${r===1?``:`s`} on ${(0,s.availableParallelism)()} cores with ${Math.floor((0,c.getHeapStatistics)().heap_size_limit/1024/1024)}MB heap and 0MB offheap memory [pid: ${process.pid}] (${(0,s.type)()} ${(0,s.release)()} ${(0,s.arch)()}, Node.js ${process.versions.node} ${process.arch.endsWith(`64`)?64:32}bit, MemFPSet, MemStateQueue).`),ca=(e,t)=>{let n=[...e.unknown,...e.options.map(e=>e.name)],r=(e,t=e)=>n.some(n=>n===e||n.toLowerCase()===t.toLowerCase()),i=r(`-generateSpecTE`)||!r(`-noGenerateSpecTE`,`-noTE`)&&!r(`-tool`)&&!r(`-continue`);return t!==`1.7.4`&&i&&!r(`-noGenerateSpecTEBin`,`-noTEBin`)},la=async(r,o,s,c)=>{let l=o.has(`-seed`)?o.get(`-seed`)?.[0]:`0`;if(l===void 0)return oa(c,`Error: seed required.`);if(!Ii(l))return oa(c,`Error: An integer for seed required. But encountered ${l}`);let u=o.has(`-lncheck`)?o.get(`-lncheck`)?.[0]?.toLowerCase():`default`;if(u===void 0)return oa(c,`Error: expect a strategy such as final for -lncheck option.`);let d=o.get(`-dump`);if(d?.length===0)return oa(c,`Error: A file name for dumping states required.`);let f=d?.length===2&&Ri.find(e=>d[0].toLowerCase().includes(e));if(f)return console.error(`Error: tla-ts does not support the -dump format ${f}.`),1;let p=o.get(`-fp`)?.[0];if(p!==void 0&&Number(p)!==0)return console.error(`Error: tla-ts fingerprints states as TLC does with -fp 0, not -fp ${p}.`),1;let g=Li(o.get(`-workers`)),v=c.version;aa(c),sa(c,l,g);let y=o.get(`-config`)?.[0]??(o.has(`-config`)?void 0:r.replace(/\.tla$/,`.cfg`));if(!y||!(0,a.existsSync)(y))return c.print(t.dt.configFileError,t.ft.error,`TLC encountered the following error when trying to read the configuration file ${y??``}:\nFile not found.`),e.G.configParseError;let b=(0,i.basename)(r,`.tla`),C={startTime:Date.now(),livenessStartTime:void 0,isParsed:!1},w=()=>{let e=Date.now()-C.startTime;c.print(t.dt.finished,t.ft.none,`Finished in ${c.isTool?`${e}ms`:t._t(e)} at (${t.gt(/* @__PURE__ */ new Date)})`)},T=()=>c.print(t.dt.parsingFailed,t.ft.error,`Parsing or semantic analysis failed.`),E=t=>(t instanceof e.O?T():_(t,c),w(),e.H(t)),D=(()=>{try{return n.h((0,a.readFileSync)(y,`utf8`),v)}catch(t){if(!(t instanceof e.h))throw t;return t}})();if(D instanceof e.h&&v===`1.7.4`)return c.print(t.dt.general,t.ft.error,`${e.U(`tlc2.tool.ConfigFileException`)}${t.ht(D.message,c.isTool)}`),w(),e.G.error;if(D instanceof e.h)return E(D);o.has(`-deadlock`)&&(D.checkDeadlock=!1);let O=(0,i.dirname)(r),ee=[O,...s.libraries],te=m(ee),k=ca(o,v);c.isTool&&c.print(t.dt.startingSany,t.ft.none,`Starting SANY...`);let A=(0,i.isAbsolute)(r),j=A?b:r.replace(/\.tla$/,``),ne=S(s),re=v===`1.7.4`?fa(r,s,ne):void 0;if(re?!(0,a.existsSync)(r)&&!t.I.has(b)&&re(`${b}.tla`):!(0,a.existsSync)(r)&&!t.L.has(b)&&h(A?O:process.cwd(),A?`${b}.tla`:`./${j}.tla`,[...A||O===`.`?[]:[O],...s.libraries]),Ni(r,re?x(te,re):te,{fileName:j,describeFile:ia(r,ee,s,o.get(`-metadir`)?.[0],v),version:v,rootExtendees:k?[`_TLCTrace`]:void 0,onPrint:e=>process.stdout.write(e),onPrintError:e=>process.stderr.write(e)}).isFailed)return Qi(c,{kind:`parsed`},C,O),T(),w(),e.G.specParseError;try{let s=(0,a.readFileSync)(r,`utf8`),f=t.V(s).name;if(f!==b)throw new e.E(`File name '${b}' does not match the name '${f}' of the top level module it contains.`,void 0);let p=await n.m({workers:g,livenessCheck:[`final`,`seqfinal`,`off`].includes(u)?`final`:`default`,seed:BigInt(l),dump:d&&Bi(d),isTool:c.isTool,isContinued:o.has(`-continue`),isTraceRecorded:k,isSanyReported:!0,isWarningEnabled:!o.has(`-nowarning`),version:v,onProgress:e=>Qi(c,e,C,O),source:s,config:D,onPause:()=>(0,a.readSync)(0,Buffer.alloc(1)),loadModule:te,loadClass:e=>{let t=Zi(O,e);return(0,a.existsSync)(t)?(0,a.readFileSync)(t):void 0},readFile:e=>(0,a.existsSync)(e)?(0,a.readFileSync)(e,`utf8`):void 0,writeFile:(e,t)=>{(0,a.mkdirSync)((0,i.dirname)((0,i.resolve)(e)),{recursive:!0}),(0,a.writeFileSync)(e,t)}});return na(p,c,C),w(),p.failure?.exitCode??Fi[p.status]}catch(t){if(!(t instanceof e.g))throw t;return t instanceof e.O&&console.log(ua(t,b)),C.isParsed||Qi(c,{kind:`parsed`},C,O),E(t)}},ua=(t,n)=>{let r=t instanceof e.E;if(!r&&!t.failure)return`Semantic errors:\n\n*** Errors: 1\n\n${t.message}\n\n`;let i=r?t.location===void 0?`Unknown location\n\n${t.message}`:`In module ${t.location}\n\n${t.message}`:`In module ${n}\n\nCould not parse module ${n} from file ${n}.tla`;return`${t.failure?`***Parse Error***\n${t.message}\n\n`:``}\nFatal errors while parsing TLA+ spec in file ${n}\n\n${i}\n*** Errors: 1\n\n${i}\n\n\n`},da=async(n,r)=>{let o=me.parse(n),s=f(o.positionals),c=o.has(`-config`),l=s.map(e=>({...e,path:e.isGlobbed||/\.(tla|cfg|ts)$/.test(e.path)?e.path.replace(/\.cfg$/,`.tla`):`${e.path}.tla`})).filter(e=>e.path.endsWith(`.ts`)||e.path.endsWith(`.tla`)&&(!e.isGlobbed||c||(0,a.existsSync)(e.path.replace(/\.tla$/,`.cfg`)))).map(e=>e.path);if(l.length===0)return console.error(F),1;if(c&&l.length>1)return console.error(`Error: -config applies to one specification, but several were given.`),1;let u=[...new Set(l.map(e=>(0,a.existsSync)(e)||(0,i.isAbsolute)(e)?e:r.libraries.map(t=>(0,i.join)(t,e)).find(a.existsSync)??e))],d=[];for(let[e,n]of u.entries()){e>0&&console.log(``);let a=t.pt(o.has(`-tool`),!o.has(`-nowarning`),r.tlcVersion??`master`);d.push(await v(async()=>{let e=n.endsWith(`.ts`)?await Pi(n):n;return u.length>1&&console.log(`Checking ${(0,i.basename)(e)} with ${(0,i.basename)(e,`.tla`)}.cfg`),la(e,o,r,a)},a))}return d.find(t=>t!==e.G.success)??e.G.success},fa=(e,t,n)=>{let r=e.slice(0,e.lastIndexOf(`/`)+1),a=(!(0,i.isAbsolute)(e)&&r!==``?[r]:t.libraries).map(b),o=a.length>0?a[a.length-1]:(0,i.isAbsolute)(e)?r:``;return e=>y(`${o}${e}`,a,n)},pa={uncaughtException:1,argsParsingFailure:1,specParsingFailure:2,unrepresentableCharacter:7},ma=e=>`java.lang.IllegalArgumentException: unsupported kind: ${e} in xml export`,Z=(e,t=[])=>({tag:e,children:t}),Q=(e,t)=>({tag:e,text:String(t),children:[]}),ha={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,"\r":`&#13;`},ga=e=>e.replace(/[&<>\r]|[\u{10000}-\u{10FFFF}]/gu,e=>e.length===2?`&#${e.codePointAt(0)};`:ha[e]),_a=/[^\t\n\r\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/u,va=e=>{let t=(e.cdata??e.text)?.match(_a)?.[0];if(t!==void 0)return{tag:e.tag,character:t};for(let t of e.children){let e=va(t);if(e)return e}},ya=(e,t,n,r)=>{let i=` `.repeat(t*n);if(e.cdata){let t=e.cdata.replaceAll(`]]>`,`]]]]><![CDATA[>`);r.push(`${i}<${e.tag}><![CDATA[${t}]]></${e.tag}>`)}else if(e.text)r.push(`${i}<${e.tag}>${ga(e.text)}</${e.tag}>`);else if(e.children.length===0)r.push(`${i}<${e.tag}/>`);else{r.push(`${i}<${e.tag}>`);for(let i of e.children)ya(i,t+1,n,r);r.push(`${i}</${e.tag}>`)}},ba=e=>Z(`location`,[Z(`column`,[Q(`begin`,e.beginColumn),Q(`end`,e.endColumn)]),Z(`line`,[Q(`begin`,e.beginLine),Q(`end`,e.endLine)]),Q(`filename`,e.file)]),xa=e=>{switch(e.kind){case`FormalParam`:return`FormalParamNodeRef`;case`OpDecl`:return`OpDeclNodeRef`;case`Module`:return`ModuleNodeRef`;case`Theorem`:return`TheoremNodeRef`;case`Assume`:return`AssumeNodeRef`;case`ThmOrAssumpDef`:return e.isTheorem?`TheoremDefRef`:`AssumeDefRef`;case`OpDef`:return e.defKind===`UserDefined`?`UserDefinedOpKindRef`:e.defKind===`BuiltIn`?`BuiltInKindRef`:`ModuleInstanceKindRef`}},$={main:{at:`xml.XMLExporter.main(XMLExporter.java:145)`},constant:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1228)`},variable:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1236)`},definition:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1244)`},topLevel:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1268)`},body:{at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1392)`,nullType:`ExprNode`,nullValue:`"this.body"`},param:{at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1397)`},builtInParam:{at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1413)`},theoremDefinitionBody:{at:`semantic.ThmOrAssumpDefNode.getSymbolElement(ThmOrAssumpDefNode.java:663)`,nullType:`LevelNode`,nullValue:`"this.body"`},theoremDefinition:{at:`semantic.TheoremNode.getLevelElement(TheoremNode.java:439)`},theorem:{at:`semantic.TheoremNode.getLevelElement(TheoremNode.java:444)`,nullType:`LevelNode`,nullValue:`the return value of "tla2sany.semantic.TheoremNode.getTheorem()"`},proof:{at:`semantic.TheoremNode.getLevelElement(TheoremNode.java:447)`},assumeDefinition:{at:`semantic.AssumeNode.getLevelElement(AssumeNode.java:249)`},assume:{at:`semantic.AssumeNode.getLevelElement(AssumeNode.java:254)`,nullType:`ExprNode`,nullValue:`the return value of "tla2sany.semantic.AssumeNode.getAssume()"`},operator:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1315)`},operand:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1326)`,nullType:`ExprOrOpArgNode`,nullValue:`"this.operands[i]"`},unbound:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1337)`},bound:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1347)`},range:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1349)`,nullType:`ExprNode`,nullValue:`"this.ranges[i]"`},letBody:{at:`semantic.LetInNode.getLevelElement(LetInNode.java:301)`,nullType:`ExprNode`,nullValue:`"this.body"`},letDefinition:{at:`semantic.LetInNode.getLevelElement(LetInNode.java:303)`},labelBody:{at:`semantic.LabelNode.getLevelElement(LabelNode.java:341)`,nullType:`LevelNode`,nullValue:`"this.body"`},labelParam:{at:`semantic.LabelNode.getLevelElement(LabelNode.java:343)`},argument:{at:`semantic.OpArgNode.getLevelElement(OpArgNode.java:150)`},exceptObject:{at:`semantic.AtNode.getLevelElement(AtNode.java:180)`},exceptComponents:{at:`semantic.AtNode.getLevelElement(AtNode.java:181)`},substOperator:{at:`semantic.Subst.export(Subst.java:258)`},substExpression:{at:`semantic.Subst.export(Subst.java:259)`,nullType:`ExprOrOpArgNode`,nullValue:`"this.expr"`},instanceSubst:{at:`semantic.InstanceNode.getLevelElement(InstanceNode.java:447)`},instanceParam:{at:`semantic.InstanceNode.getLevelElement(InstanceNode.java:452)`},useFact:{at:`semantic.UseOrHideNode.getLevelElement(UseOrHideNode.java:175)`,nullType:`LevelNode`,nullValue:`"this.facts[i]"`},useDefinition:{at:`semantic.UseOrHideNode.getLevelElement(UseOrHideNode.java:176)`},newDeclaration:{at:`semantic.NewSymbNode.getLevelElement(NewSymbNode.java:202)`},newSet:{at:`semantic.NewSymbNode.getLevelElement(NewSymbNode.java:204)`},assumption:{at:`semantic.AssumeProveNode.getLevelElement(AssumeProveNode.java:404)`,nullType:`SemanticNode`,nullValue:`"assumes[i]"`},goal:{at:`semantic.AssumeProveNode.getLevelElement(AssumeProveNode.java:406)`,nullType:`ExprNode`,nullValue:`the return value of "tla2sany.semantic.AssumeProveNode.getProve()"`},byFact:{at:`semantic.LeafProofNode.getLevelElement(LeafProofNode.java:154)`,nullType:`LevelNode`,nullValue:`"this.facts[i]"`},byDefinition:{at:`semantic.LeafProofNode.getLevelElement(LeafProofNode.java:155)`},step:{at:`semantic.NonLeafProofNode.getLevelElement(NonLeafProofNode.java:228)`,nullType:`LevelNode`,nullValue:`"this.steps[i]"`},defStep:{at:`semantic.DefStepNode.getLevelElement(DefStepNode.java:99)`}},Sa={SubstIn:{subst:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:530)`},body:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:533)`,nullType:`ExprNode`,nullValue:`"this.body"`},from:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:536)`},to:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:540)`}},APSubstIn:{subst:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:460)`},body:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:463)`,nullType:`LevelNode`,nullValue:`"this.body"`},from:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:466)`},to:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:470)`}}},Ca={at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1424)`},wa=yn(`--TLA+ BUILTINS--`),Ta=(e,t)=>{let[n,r,i]=e===`Theorem`?[`TheoremNode.export(TheoremNode.java:456)`,70,`TheoremNode.exportDefinition(TheoremNode.java:404)`]:e===`Assume`?[`AssumeNode.export(AssumeNode.java:263)`,80,`AssumeNode.exportDefinition(AssumeNode.java:207)`]:[e===`ThmOrAssumpDef`?`ThmOrAssumpDefNode.export(ThmOrAssumpDefNode.java:671)`:`SymbolNode.export(SymbolNode.java:177)`,60,`SymbolNode.exportDefinition(SymbolNode.java:138)`];return[{at:`semantic.${n}`},{at:`xml.SymbolContext.put(SymbolContext.java:${r})`},{at:`semantic.${i}`,failedFor:t}]},Ea=(e,t=16)=>e>t*.75?Ea(e,t*2):t,Da=(e,t)=>(e^e>>>16)&t-1,Oa=e=>{let t=e.split(/\r?\n/);for(;t.at(-1)===``;)t.pop();return t},ka=e=>e.replace(/^[\0-\x20]+|[\0-\x20]+$/g,``),Aa=/[\t-\r\x1C-\x20\u1680\u2000-\u2006\u2008-\u200A\u2028\u2029\u205F\u3000]+$/,ja=e=>{let t=e.indexOf(`(**`),n=e.lastIndexOf(`**)`);if(t<0||n<=t)return e;let r=Oa(e),i=r.findIndex(e=>e.includes(`(**`)),a=r.findLastIndex(e=>e.includes(`**)`));return i<0||i>=a?e:r.slice(i+1,a).map(e=>{let t=e.indexOf(`(*`),n=e.indexOf(`*)`);return t<0||n<=t?e:e.slice(t+3,Math.max(t+3,n)).replace(Aa,``)}).join(`
40
40
  `)},Ma=e=>{let t=Oa(e),n=e=>ka(e).startsWith(`\\*`);return t.filter(n).length<Math.floor(t.length/2)?e:t.map(e=>{if(!n(e))return e;let t=e.indexOf(`\\*`)+2;return e.slice(e[t]===` `?t+1:t)}).join(`
41
41
  `)},Na=(t,n,r)=>{let i=r.version===`1.7.4`,a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Map,s={isSet:!1},c=[],l=(e,t)=>{if(!i)return t();c.push(...e);let n=t();return c.length-=e.length,n},u=(t,n)=>{let r=[...c,...n].reverse(),i=[t,...r.map(e=>`\tat tla2sany.${e.at}`)].join(`
package/dist/run.js CHANGED
@@ -6,7 +6,7 @@
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
- import{t as e}from"./tlapm.js";import{E as t,F as n,G as r,H as i,O as a,S as o,U as s,_ as c,c as l,g as u,h as d,j as f,k as p,o as m,q as h,s as g,w as _,x as v}from"./worker.js";import{At as y,B as b,G as x,H as S,I as C,Kt as ee,L as te,R as w,Ut as T,V as E,W as ne,Xt as D,Y as O,Zt as k,_t as re,dt as A,f as ie,ft as j,gt as M,ht as ae,l as N,mt as oe,p as se,pt as ce,qt as le,u as ue,vt as de,z as fe}from"./transfer.js";import{a as pe,c as me,d as he,f as ge,h as P,i as _e,l as ve,m as ye,n as be,o as xe,p as Se,s as Ce,t as we,u as Te}from"./prove.js";import{basename as Ee,delimiter as De,dirname as Oe,isAbsolute as ke,join as Ae,resolve as je}from"node:path";import{cpSync as Me,existsSync as F,globSync as Ne,mkdirSync as Pe,readFileSync as Fe,readSync as Ie,readdirSync as Le,realpathSync as Re,renameSync as ze,rmSync as Be,statSync as Ve,writeFileSync as He}from"node:fs";import{pathToFileURL as Ue}from"node:url";import{arch as We,availableParallelism as Ge,release as Ke,tmpdir as qe,type as Je}from"node:os";import{getHeapStatistics as Ye}from"node:v8";const Xe=`META-INF/MANIFEST.MF`,Ze=async e=>{if(e===void 0||!F(e))return`master`;let t=await import(`fflate`),n=t.unzipSync(Fe(e),{filter:e=>e.name===Xe})[Xe];return(n&&/^X-Git-Tag: *(\S*)/m.exec(t.strFromU8(n))?.[1])===`v1.7.4`?`1.7.4`:`master`},Qe=/[*?[{]/,$e=e=>e.flatMap(e=>Qe.test(e)?Ne(e).sort().map(e=>({path:e,isGlobbed:!0})):[{path:e,isGlobbed:!1}]),et=(e,t)=>e.map(e=>Ae(e,`${t}.tla`)).find(F),tt=e=>t=>{let n=et(e,t);return n===void 0?void 0:Fe(n,`utf8`)},nt=(e,t,n)=>console.error(`File does not exist: ${e}/${t} while looking in these directories: ${e}, ${n.join(`, `)}, classpath:/tla2sany/StandardModules, classpath:/`),rt=e=>`jar:file:${Ue(je(e)).pathname}!/tla2sany/StandardModules/`,it=(e,t)=>{if(e instanceof d||e instanceof c){let n=de(e.message),r=n&&!n.isEvalException?n.code:A.general;return t.print(r,j.error,oe(r,e.message,t.isTool))}console.error(`${e.name}: ${e.message}`)},at=async(e,t=ce(!1))=>{try{return await e()}catch(e){if(!(e instanceof u))throw e;return it(e,t),i(e)}},ot=(e,t,n)=>console.error(`File does not exist: ${ke(e)?e:`${process.cwd()}/${e}`} while looking in these directories: ${[...t,...n===void 0?[]:[rt(n)]].join(`, `)}`),st=e=>e.endsWith(`/`)?e:`${e}/`,ct=(e,t)=>n=>{let r=e(n);return r===void 0&&!C.has(n)&&t(`${n}.tla`),r},lt=e=>e.classPath?.split(De).find(e=>e.endsWith(`.jar`));var ut=`0.0.9-dev.4ce0657`;const dt=2224400062,I={int8:0,int16:1,int32:2,shared8:4,shared16:5,shared32:6,block32:8,string8:9,string32:10,doubleLittle:12},ft={smallInt:64,smallString:32,smallBlock:128},L=(e,...t)=>({tag:e,fields:t}),pt=e=>typeof e==`object`&&`tag`in e,mt=(e,t)=>{let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<t+20||n.getUint32(t)!==dt)throw new _(`corrupted fingerprint file`);let r=t+20+n.getUint32(t+4),i=[],a={position:t+20},o=e=>{let t=a.position;if(a.position+=e,a.position>r)throw new _(`corrupted fingerprint file`);return t},s=new TextDecoder,c=t=>{let n=o(t),r=s.decode(e.subarray(n,n+t));return i.push(r),r},l=(e,t)=>{let n=L(e);t>0&&i.push(n);for(let e=0;e<t;e++)n.fields.push(d());return n},u=e=>i[i.length-e],d=()=>{let t=e[o(1)];if(t>=ft.smallBlock)return l(t&15,t>>4&7);if(t>=ft.smallInt)return t&63;if(t>=ft.smallString)return c(t&31);switch(t){case I.int8:return n.getInt8(o(1));case I.int16:return n.getInt16(o(2));case I.int32:return n.getInt32(o(4));case I.shared8:return u(n.getUint8(o(1)));case I.shared16:return u(n.getUint16(o(2)));case I.shared32:return u(n.getUint32(o(4)));case I.block32:{let e=n.getUint32(o(4));return l(e&255,e>>>10)}case I.string8:return c(n.getUint8(o(1)));case I.string32:return c(n.getUint32(o(4)));case I.doubleLittle:{let e={float:n.getFloat64(o(8),!0)};return i.push(e),e}}throw new _(`corrupted fingerprint file`)};return{value:d(),next:r}},ht=e=>{let t=[],n={objects:0,words32:0,words64:0},r=(e,n)=>{for(let r=(n-1)*8;r>=0;r-=8)t.push(e>>>r&255)},i=new TextEncoder,a=e=>{if(typeof e==`number`)return e>=0&&e<64?t.push(ft.smallInt+e):e>=-128&&e<128?t.push(I.int8,e&255):e>=-32768&&e<32768?(t.push(I.int16),r(e,2)):(t.push(I.int32),r(e,4));if(n.objects++,typeof e==`string`){let a=i.encode(e);a.length<32?t.push(ft.smallString+a.length):a.length<256?t.push(I.string8,a.length):(t.push(I.string32),r(a.length,4)),t.push(...a),n.words32+=1+Math.floor((a.length+4)/4),n.words64+=1+Math.floor((a.length+8)/8);return}if(!pt(e)){let r=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));r.setFloat64(0,e.float,!0),t.push(I.doubleLittle,...new Uint8Array(r.buffer)),n.words32+=3,n.words64+=2;return}let o=e.fields.length;o===0?n.objects--:(n.words32+=1+o,n.words64+=1+o),e.tag<16&&o<8?t.push(ft.smallBlock+e.tag+(o<<4)):(t.push(I.block32),r(o*1024+e.tag,4)),e.fields.forEach(a)};a(e);let o=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(20));return[dt,t.length,n.objects,n.words32,n.words64].forEach((e,t)=>o.setUint32(t*4,e)),new Uint8Array([...new Uint8Array(o.buffer),...t])},gt=20210223,_t={zenon:{field:1,tag:1},isabelle:{field:2,tag:0},smt:{field:10,tag:8},z3:{field:11,tag:9},ls4:{field:17,tag:16}},vt=[`false`,`timeout`],yt=`tla-ts ${ut}`,bt=/* @__PURE__ */ new Map([[_t.zenon.field,3],[_t.isabelle.field,4]]),xt=(e,t)=>e!==void 0&&pt(e)?e.fields[t]:void 0,St=e=>e!==void 0&&typeof e==`object`&&`float`in e?e.float:1/0,Ct=e=>{let t=new TextEncoder().encode(e),n=(e,t)=>e<<t|e>>>32-t,r=Array.from({length:Math.ceil(t.length/4)},(e,n)=>t[n*4]|t[n*4+1]<<8|t[n*4+2]<<16|t[n*4+3]<<24).reduce((e,t)=>{let r=Math.imul(n(Math.imul(t,3432918353),15),461845907);return Math.imul(n(e^r,13),5)+3864292196|0},0),i=Math.imul(r^t.length^(r^t.length)>>>16,2246822507),a=Math.imul(i^i>>>13,3266489909);return(a^a>>>16)&1073741823},wt=e=>e!==void 0&&pt(e)?[[e.fields[0],e.fields[1]],...wt(e.fields[2])]:[],Tt=(e,t,n)=>{let r=Fe(t),i=mt(r,0),a=mt(r,i.next).value;if(i.value!==gt||!pt(a)||a.tag!==0)throw new _(`corrupted fingerprint file`);let o=xt(xt(a,0),1),s=(e,t)=>{let r=bt.get(t);return!n||r===void 0||xt(xt(e,0),r)===yt};e.clear(),(o!==void 0&&pt(o)?o.fields:[]).flatMap(e=>wt(e).toReversed()).forEach(([t,n])=>{if(typeof t!=`string`||!pt(n))throw new _(`corrupted fingerprint file`);e.set(t,n.fields.map((e,t)=>s(e,t)?e:0))})},Et=(e,t)=>{let n=xt(t,0),r=xt(n,0),i=xt(xt(n,1),0);if(r===void 0||r===1)return;let a=St(xt(e===`isabelle`?xt(i,0):i,0)),o=e===`isabelle`?xt(i,1):void 0,s=xt(xt(r,0),0);return{method:{prover:e,timeLimitMs:a*1e3,...typeof o==`string`&&{tactic:o}},isProved:r===0,isReused:!1,...s!==void 0&&{reason:typeof s==`number`?vt[s]:String(xt(s,0))}}},Dt=e=>{let t=/* @__PURE__ */ new Date,n=e.method,r={float:n.rlimit??n.timeLimitMs/1e3},i=n.prover===`zenon`?L(0,r,5):n.prover===`isabelle`?L(0,L(0,r),n.tactic??`auto`):L(0,r),a=vt.indexOf(e.reason??``),o=e.reason===void 0?0:L(0,a===-1?L(0,e.reason):a);return L(0,L(0,L(0,e.isProved?0:L(0,o),L(_t[n.prover].tag,i)),L(0,t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()),yt,yt,yt))},Ot=e=>{let t=2**Math.max(9,Math.ceil(Math.log2(e.size/2))),n=Array.from({length:t},()=>0);return e.forEach((e,r)=>{let i=Ct(r)&t-1;n[i]=L(0,r,L(0,...e),n[i])}),L(0,L(0,e.size,L(0,...n),0,512))},kt=e=>String(e).padStart(2,`0`),At=(e,t)=>{let n=/* @__PURE__ */ new Date,r=`${e}.history`,i=Ae(r,`${n.getFullYear()}-${kt(n.getMonth()+1)}-${kt(n.getDate())}_${kt(n.getHours())}_${kt(n.getMinutes())}_${kt(n.getSeconds())}`);Pe(i,{recursive:!0}),[e,...t].filter(e=>F(e)).forEach(e=>Me(e,Ae(i,Ee(e)),{preserveTimestamps:!0})),Le(r).map(e=>Ae(r,e)).sort((e,t)=>Ve(t).mtimeMs-Ve(e).mtimeMs).slice(10).forEach(e=>Be(e,{recursive:!0,force:!0}))},jt=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=new Map([...e].map(([e,r])=>{let i=new Map(Object.entries(_t).flatMap(([e,n])=>{let i=Et(e,xt(r[n.field],0));return i?(t.set(i,r[n.field]),[[e,i]]):[]}));return n.set(i,r),[e,i]}));return{results:r,save:i=>{e.clear(),r.forEach((r,i)=>{let a=[...n.get(r)??Array(23).fill(0)];r.forEach((e,n)=>{a[_t[n].field]=t.get(e)??Dt(e)}),e.set(i,a)}),He(`${i}.tmp`,Buffer.concat([ht(gt),ht(Ot(e))])),ze(`${i}.tmp`,i)}}},Mt=(e,t)=>{let n=new Map(t.map(e=>{let[t,...n]=e.flag.split(` `);return[t,e.getArity??(()=>n.length)]}));return{usage:e.replace(`{options}`,t.map(e=>`[${e.flag}]${e.isRepeatable?`...`:``}`).join(` `)),parse:e=>{let t=[],r=[],i=[],a=[];for(let o=0;o<e.length;o++){let s=n.get(e[o]);if(s===void 0){(e[o].startsWith(`-`)?i:r).push(e[o]);continue}let c=s(e.slice(o+1)),l={name:e[o],values:e.slice(o+1,o+1+c)};t.push(l),l.values.length<c&&a.push(l),o+=c}return{options:t,positionals:r,unknown:i,incomplete:a[0],has:e=>t.some(t=>t.name===e),get:e=>t.findLast(t=>t.name===e)?.values}}}},Nt=Mt(`tla-ts <Spec.tla|Spec.cfg|spec.ts|glob>... {options}`,[{flag:`-config <Spec.cfg>`},{flag:`-continue`},{flag:`-deadlock`},{flag:`-dump [<format>] <file>`,getArity:e=>e.length>1&&e[0].startsWith(`dot`)?2:1},{flag:`-fp <num>`},{flag:`-lncheck <final|default>`},{flag:`-metadir <directory>`},{flag:`-nowarning`},{flag:`-seed <num>`},{flag:`-tool`},{flag:`-workers <count|auto>`}]),Pt=Mt(`tla-ts tlapm {options} <Module.tla|glob>...`,[{flag:`-N`},{flag:`--summary`},{flag:`--strict`},{flag:`--toolbox <start> <end>`},{flag:`--line <num>`},{flag:`--printallobs`},{flag:`--threads <num>`},{flag:`--version`},{flag:`-I <directory>`,isRepeatable:!0},{flag:`-k`},{flag:`--noproving`},{flag:`--nofp`},{flag:`--nofpl <start> <end>`},{flag:`--safefp`},{flag:`--cleanfp`},{flag:`--usefp <file>`},{flag:`--cache-dir <directory>`}]),Ft=[`Usage: ${Nt.usage}`,` ${Pt.usage}`,` tla-ts [<JVM option>]... tlc2.TLC <TLC option>... <Spec>`,` (-cp tla2tools.jar or -Dtla-ts.tlc=1.7.4 picks the TLC to reproduce)`,` tla-ts [<JVM option>]... tla2sany.xml.XMLExporter [-I <directory>]... [-o] [-t] [-r] [-u] <Module.tla>`].join(`
9
+ import{t as e}from"./tlapm.js";import{E as t,F as n,G as r,H as i,O as a,S as o,U as s,_ as c,c as l,g as u,h as d,j as f,k as p,o as m,q as h,s as g,w as _,x as v}from"./worker.js";import{At as y,B as b,G as x,H as S,I as C,Kt as ee,L as te,R as w,Ut as T,V as E,W as ne,Xt as D,Y as O,Zt as k,_t as re,dt as A,f as ie,ft as j,gt as M,ht as ae,l as N,mt as oe,p as se,pt as ce,qt as le,u as ue,vt as de,z as fe}from"./transfer.js";import{a as pe,c as me,d as he,f as ge,h as P,i as _e,l as ve,m as ye,n as be,o as xe,p as Se,s as Ce,t as we,u as Te}from"./prove.js";import{basename as Ee,delimiter as De,dirname as Oe,isAbsolute as ke,join as Ae,resolve as je}from"node:path";import{cpSync as Me,existsSync as F,globSync as Ne,mkdirSync as Pe,readFileSync as Fe,readSync as Ie,readdirSync as Le,realpathSync as Re,renameSync as ze,rmSync as Be,statSync as Ve,writeFileSync as He}from"node:fs";import{pathToFileURL as Ue}from"node:url";import{arch as We,availableParallelism as Ge,release as Ke,tmpdir as qe,type as Je}from"node:os";import{getHeapStatistics as Ye}from"node:v8";const Xe=`META-INF/MANIFEST.MF`,Ze=async e=>{if(e===void 0||!F(e))return`master`;let t=await import(`fflate`),n=t.unzipSync(Fe(e),{filter:e=>e.name===Xe})[Xe];return(n&&/^X-Git-Tag: *(\S*)/m.exec(t.strFromU8(n))?.[1])===`v1.7.4`?`1.7.4`:`master`},Qe=/[*?[{]/,$e=e=>e.flatMap(e=>Qe.test(e)?Ne(e).sort().map(e=>({path:e,isGlobbed:!0})):[{path:e,isGlobbed:!1}]),et=(e,t)=>e.map(e=>Ae(e,`${t}.tla`)).find(F),tt=e=>t=>{let n=et(e,t);return n===void 0?void 0:Fe(n,`utf8`)},nt=(e,t,n)=>console.error(`File does not exist: ${e}/${t} while looking in these directories: ${e}, ${n.join(`, `)}, classpath:/tla2sany/StandardModules, classpath:/`),rt=e=>`jar:file:${Ue(je(e)).pathname}!/tla2sany/StandardModules/`,it=(e,t)=>{if(e instanceof d||e instanceof c){let n=de(e.message),r=n&&!n.isEvalException?n.code:A.general;return t.print(r,j.error,oe(r,e.message,t.isTool))}console.error(`${e.name}: ${e.message}`)},at=async(e,t=ce(!1))=>{try{return await e()}catch(e){if(!(e instanceof u))throw e;return it(e,t),i(e)}},ot=(e,t,n)=>console.error(`File does not exist: ${ke(e)?e:`${process.cwd()}/${e}`} while looking in these directories: ${[...t,...n===void 0?[]:[rt(n)]].join(`, `)}`),st=e=>e.endsWith(`/`)?e:`${e}/`,ct=(e,t)=>n=>{let r=e(n);return r===void 0&&!C.has(n)&&t(`${n}.tla`),r},lt=e=>e.classPath?.split(De).find(e=>e.endsWith(`.jar`));var ut=`0.0.9-dev.7fe4429`;const dt=2224400062,I={int8:0,int16:1,int32:2,shared8:4,shared16:5,shared32:6,block32:8,string8:9,string32:10,doubleLittle:12},ft={smallInt:64,smallString:32,smallBlock:128},L=(e,...t)=>({tag:e,fields:t}),pt=e=>typeof e==`object`&&`tag`in e,mt=(e,t)=>{let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<t+20||n.getUint32(t)!==dt)throw new _(`corrupted fingerprint file`);let r=t+20+n.getUint32(t+4),i=[],a={position:t+20},o=e=>{let t=a.position;if(a.position+=e,a.position>r)throw new _(`corrupted fingerprint file`);return t},s=new TextDecoder,c=t=>{let n=o(t),r=s.decode(e.subarray(n,n+t));return i.push(r),r},l=(e,t)=>{let n=L(e);t>0&&i.push(n);for(let e=0;e<t;e++)n.fields.push(d());return n},u=e=>i[i.length-e],d=()=>{let t=e[o(1)];if(t>=ft.smallBlock)return l(t&15,t>>4&7);if(t>=ft.smallInt)return t&63;if(t>=ft.smallString)return c(t&31);switch(t){case I.int8:return n.getInt8(o(1));case I.int16:return n.getInt16(o(2));case I.int32:return n.getInt32(o(4));case I.shared8:return u(n.getUint8(o(1)));case I.shared16:return u(n.getUint16(o(2)));case I.shared32:return u(n.getUint32(o(4)));case I.block32:{let e=n.getUint32(o(4));return l(e&255,e>>>10)}case I.string8:return c(n.getUint8(o(1)));case I.string32:return c(n.getUint32(o(4)));case I.doubleLittle:{let e={float:n.getFloat64(o(8),!0)};return i.push(e),e}}throw new _(`corrupted fingerprint file`)};return{value:d(),next:r}},ht=e=>{let t=[],n={objects:0,words32:0,words64:0},r=(e,n)=>{for(let r=(n-1)*8;r>=0;r-=8)t.push(e>>>r&255)},i=new TextEncoder,a=e=>{if(typeof e==`number`)return e>=0&&e<64?t.push(ft.smallInt+e):e>=-128&&e<128?t.push(I.int8,e&255):e>=-32768&&e<32768?(t.push(I.int16),r(e,2)):(t.push(I.int32),r(e,4));if(n.objects++,typeof e==`string`){let a=i.encode(e);a.length<32?t.push(ft.smallString+a.length):a.length<256?t.push(I.string8,a.length):(t.push(I.string32),r(a.length,4)),t.push(...a),n.words32+=1+Math.floor((a.length+4)/4),n.words64+=1+Math.floor((a.length+8)/8);return}if(!pt(e)){let r=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));r.setFloat64(0,e.float,!0),t.push(I.doubleLittle,...new Uint8Array(r.buffer)),n.words32+=3,n.words64+=2;return}let o=e.fields.length;o===0?n.objects--:(n.words32+=1+o,n.words64+=1+o),e.tag<16&&o<8?t.push(ft.smallBlock+e.tag+(o<<4)):(t.push(I.block32),r(o*1024+e.tag,4)),e.fields.forEach(a)};a(e);let o=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(20));return[dt,t.length,n.objects,n.words32,n.words64].forEach((e,t)=>o.setUint32(t*4,e)),new Uint8Array([...new Uint8Array(o.buffer),...t])},gt=20210223,_t={zenon:{field:1,tag:1},isabelle:{field:2,tag:0},smt:{field:10,tag:8},z3:{field:11,tag:9},ls4:{field:17,tag:16}},vt=[`false`,`timeout`],yt=`tla-ts ${ut}`,bt=/* @__PURE__ */ new Map([[_t.zenon.field,3],[_t.isabelle.field,4]]),xt=(e,t)=>e!==void 0&&pt(e)?e.fields[t]:void 0,St=e=>e!==void 0&&typeof e==`object`&&`float`in e?e.float:1/0,Ct=e=>{let t=new TextEncoder().encode(e),n=(e,t)=>e<<t|e>>>32-t,r=Array.from({length:Math.ceil(t.length/4)},(e,n)=>t[n*4]|t[n*4+1]<<8|t[n*4+2]<<16|t[n*4+3]<<24).reduce((e,t)=>{let r=Math.imul(n(Math.imul(t,3432918353),15),461845907);return Math.imul(n(e^r,13),5)+3864292196|0},0),i=Math.imul(r^t.length^(r^t.length)>>>16,2246822507),a=Math.imul(i^i>>>13,3266489909);return(a^a>>>16)&1073741823},wt=e=>e!==void 0&&pt(e)?[[e.fields[0],e.fields[1]],...wt(e.fields[2])]:[],Tt=(e,t,n)=>{let r=Fe(t),i=mt(r,0),a=mt(r,i.next).value;if(i.value!==gt||!pt(a)||a.tag!==0)throw new _(`corrupted fingerprint file`);let o=xt(xt(a,0),1),s=(e,t)=>{let r=bt.get(t);return!n||r===void 0||xt(xt(e,0),r)===yt};e.clear(),(o!==void 0&&pt(o)?o.fields:[]).flatMap(e=>wt(e).toReversed()).forEach(([t,n])=>{if(typeof t!=`string`||!pt(n))throw new _(`corrupted fingerprint file`);e.set(t,n.fields.map((e,t)=>s(e,t)?e:0))})},Et=(e,t)=>{let n=xt(t,0),r=xt(n,0),i=xt(xt(n,1),0);if(r===void 0||r===1)return;let a=St(xt(e===`isabelle`?xt(i,0):i,0)),o=e===`isabelle`?xt(i,1):void 0,s=xt(xt(r,0),0);return{method:{prover:e,timeLimitMs:a*1e3,...typeof o==`string`&&{tactic:o}},isProved:r===0,isReused:!1,...s!==void 0&&{reason:typeof s==`number`?vt[s]:String(xt(s,0))}}},Dt=e=>{let t=/* @__PURE__ */ new Date,n=e.method,r={float:n.rlimit??n.timeLimitMs/1e3},i=n.prover===`zenon`?L(0,r,5):n.prover===`isabelle`?L(0,L(0,r),n.tactic??`auto`):L(0,r),a=vt.indexOf(e.reason??``),o=e.reason===void 0?0:L(0,a===-1?L(0,e.reason):a);return L(0,L(0,L(0,e.isProved?0:L(0,o),L(_t[n.prover].tag,i)),L(0,t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()),yt,yt,yt))},Ot=e=>{let t=2**Math.max(9,Math.ceil(Math.log2(e.size/2))),n=Array.from({length:t},()=>0);return e.forEach((e,r)=>{let i=Ct(r)&t-1;n[i]=L(0,r,L(0,...e),n[i])}),L(0,L(0,e.size,L(0,...n),0,512))},kt=e=>String(e).padStart(2,`0`),At=(e,t)=>{let n=/* @__PURE__ */ new Date,r=`${e}.history`,i=Ae(r,`${n.getFullYear()}-${kt(n.getMonth()+1)}-${kt(n.getDate())}_${kt(n.getHours())}_${kt(n.getMinutes())}_${kt(n.getSeconds())}`);Pe(i,{recursive:!0}),[e,...t].filter(e=>F(e)).forEach(e=>Me(e,Ae(i,Ee(e)),{preserveTimestamps:!0})),Le(r).map(e=>Ae(r,e)).sort((e,t)=>Ve(t).mtimeMs-Ve(e).mtimeMs).slice(10).forEach(e=>Be(e,{recursive:!0,force:!0}))},jt=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=new Map([...e].map(([e,r])=>{let i=new Map(Object.entries(_t).flatMap(([e,n])=>{let i=Et(e,xt(r[n.field],0));return i?(t.set(i,r[n.field]),[[e,i]]):[]}));return n.set(i,r),[e,i]}));return{results:r,save:i=>{e.clear(),r.forEach((r,i)=>{let a=[...n.get(r)??Array(23).fill(0)];r.forEach((e,n)=>{a[_t[n].field]=t.get(e)??Dt(e)}),e.set(i,a)}),He(`${i}.tmp`,Buffer.concat([ht(gt),ht(Ot(e))])),ze(`${i}.tmp`,i)}}},Mt=(e,t)=>{let n=new Map(t.map(e=>{let[t,...n]=e.flag.split(` `);return[t,e.getArity??(()=>n.length)]}));return{usage:e.replace(`{options}`,t.map(e=>`[${e.flag}]${e.isRepeatable?`...`:``}`).join(` `)),parse:e=>{let t=[],r=[],i=[],a=[];for(let o=0;o<e.length;o++){let s=n.get(e[o]);if(s===void 0){(e[o].startsWith(`-`)?i:r).push(e[o]);continue}let c=s(e.slice(o+1)),l={name:e[o],values:e.slice(o+1,o+1+c)};t.push(l),l.values.length<c&&a.push(l),o+=c}return{options:t,positionals:r,unknown:i,incomplete:a[0],has:e=>t.some(t=>t.name===e),get:e=>t.findLast(t=>t.name===e)?.values}}}},Nt=Mt(`tla-ts <Spec.tla|Spec.cfg|spec.ts|glob>... {options}`,[{flag:`-config <Spec.cfg>`},{flag:`-continue`},{flag:`-deadlock`},{flag:`-dump [<format>] <file>`,getArity:e=>e.length>1&&e[0].startsWith(`dot`)?2:1},{flag:`-fp <num>`},{flag:`-lncheck <final|default>`},{flag:`-metadir <directory>`},{flag:`-nowarning`},{flag:`-seed <num>`},{flag:`-tool`},{flag:`-workers <count|auto>`}]),Pt=Mt(`tla-ts tlapm {options} <Module.tla|glob>...`,[{flag:`-N`},{flag:`--summary`},{flag:`--strict`},{flag:`--toolbox <start> <end>`},{flag:`--line <num>`},{flag:`--printallobs`},{flag:`--threads <num>`},{flag:`--version`},{flag:`-I <directory>`,isRepeatable:!0},{flag:`-k`},{flag:`--noproving`},{flag:`--nofp`},{flag:`--nofpl <start> <end>`},{flag:`--safefp`},{flag:`--cleanfp`},{flag:`--usefp <file>`},{flag:`--cache-dir <directory>`}]),Ft=[`Usage: ${Nt.usage}`,` ${Pt.usage}`,` tla-ts [<JVM option>]... tlc2.TLC <TLC option>... <Spec>`,` (-cp tla2tools.jar or -Dtla-ts.tlc=1.7.4 picks the TLC to reproduce)`,` tla-ts [<JVM option>]... tla2sany.xml.XMLExporter [-I <directory>]... [-o] [-t] [-r] [-u] <Module.tla>`].join(`
10
10
  `),It=/* @__PURE__ */ new Set([`--toolbox`,`--line`,`--threads`,`--nofpl`]),Lt=t=>[`.`,...e().map(e=>Ae(Oe(Oe(Re(e))),`lib/tlapm/stdlib`)).filter(e=>F(e)).slice(0,1),...t.options.flatMap(e=>e.name===`-I`?e.values:[]).toReversed()],Rt=e=>console.error(`@!!BEGIN\n${e.map(e=>`@!!${e}\n`).join(``)}@!!END\n`),zt=(e,t,n)=>Rt([`type:obligation`,`id:${e.id}`,`loc:${e.location}`,`status:${t}`,...n]),Bt=`9ed0376`,Vt=e=>/^[+,\-./0-9:=@A-Z_a-z]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`,Ht={failed:10,incomplete:11,emptyTarget:12},Ut=(e,t,n)=>{let r=e.summary;n||(r.absent.forEach(e=>console.error(`Missing proof at ${Se(e)}`)),r.omitted.forEach(e=>console.error(`Omitted proof at ${Se(e)}`)));let i=r.absent.length+r.omitted.length>0;i&&console.error(`${ge(e.location)}[ERROR]: Proof incomplete in module ${JSON.stringify(e.name)}: ${r.absent.length} missing, ${r.omitted.length} omitted proof step(s).`);let a=t&&e.obligations.length===0;return a&&console.error(`${ge(e.location)}[ERROR]: No proof obligation found for the selected target.`),[...i?[Ht.incomplete]:[],...a?[Ht.emptyTarget]:[]]},Wt=e=>{try{return e()}catch(e){if(!(e instanceof _))throw e;console.error(` tlapm ending abnormally with ${e.exception}\n`);return}},Gt=(e,t)=>{let n=t.method.timeLimitMs,r=t.timeUsedMs===void 0?``:`; time-used: ${(t.timeUsedMs/1e3).toFixed(1)} (${Math.round(100*t.timeUsedMs/n)}%)`,i=n===0?``:`time-limit: ${n===1/0?`inf`:Number((n/1e3).toPrecision(6))}${r}`,a=[t.method.tactic,i].filter(Boolean).join(`; `),o=(t.method.prover===`smt`||t.method.prover===`z3`)&&t.reason===`false`&&t.verdict?`(* SMT failed with status = ${t.verdict}\n *)\n`:``;zt(e,t.isProved?`proved`:`failed`,[`prover:${t.method.prover}`,...a===``?[]:[`meth:${a}`],...t.reason===void 0?[]:[`reason:${t.reason}`],`already:${t.isReused}`,...t.isProved?[]:[`obl:${t.isReused?``:`\n${o}`}${be(e,t.isReused)}`]])},Kt=(e,t)=>zt(e,`failed`,[`prover:fail`,`meth:time-limit: inf`,`reason:${t}`,`already:false`,`obl:${e.text}`]),qt=async(e,t,n,r)=>{let i=jt(r.fingerprints),a=await _e(e.obligations,{workers:r.workers,results:i.results,isFingerprinted:r.isFingerprinted,isProving:r.isProving,onReport:(e,t)=>{if(r.isToolbox){if(e.obligation.status===`trivial`)return zt(t,`trivial`,[`prover:tlapm`,`already:false`]);if(t.kind.kind===`Error`)return Kt(t,`user error`);e.attempts.forEach(e=>Gt(t,e))}}});if(He(t,we(e.name,a,e.obligations)),console.log(`(* created new ${JSON.stringify(t)} *)`),i.save(n),console.log(`(* fingerprints written in ${JSON.stringify(n)} *)`),!r.isProving)return!1;let o=a.flatMap((t,n)=>`reason`in t.obligation?[{report:t,obligation:e.obligations[n]}]:[]);r.isToolbox&&o.filter(e=>e.report.attempts.length===0&&e.obligation.kind.kind!==`Error`).forEach(e=>Kt(e.obligation,`unexpected error`)),o.toReversed().forEach(e=>console.error(`${ge(e.obligation.locus)}${he(Te(`[ERROR]: @[<v2>Could not prove or check:@,%a@]`,ve(e.obligation.sequent)),35)}`));let s=`${e.obligations.length} obligation${e.obligations.length>1?`s`:``}`;return console.error(o.length===0?`${ge(e.location)}[INFO]: All ${s} proved.`:`${ge(e.location)}[ERROR]: ${o.length}/${s} failed.\nThere were backend errors processing module \`${JSON.stringify(e.name)}\`.`),o.length>0},Jt=async e=>{let t=Pt.parse(e),n=!t.has(`-N`)&&!t.has(`--summary`),i=t.unknown[0]??(n&&t.has(`--printallobs`)?`--printallobs`:void 0);if(i!==void 0)return console.error(`Error: tla-ts tlapm does not support the tlapm option ${i}.`),1;if(t.incomplete)return console.error(`Error: option '${t.incomplete.name}' needs an argument.`),1;let a=t.options.find(e=>It.has(e.name)&&e.values.some(e=>!/^-?\d+$/.test(e)));if(a)return console.error(`Error: option '${a.name}' expects an integer.`),1;if(t.has(`--version`))return console.log(Bt),r.success;let o=$e(t.positionals).map(e=>e.path),s=o.map(e=>e.endsWith(`.tla`)?e:`${e}.tla`);if(s.length===0)return console.error(Ft),1;let c=t.has(`--toolbox`)||t.has(`--line`);c&&console.log(`\n\\* TLAPM version ${Bt}\n\\* launched at ${M(/* @__PURE__ */ new Date)} with command line:\n\\* ${[`tla-ts`,`tlapm`,...e].map(Vt).join(` `)}\n`);let l=t.options.reduce((e,t)=>{let[n,r]=t.values.map(Number);return t.name===`--toolbox`?{start:n,end:r===0?1/0:r}:t.name===`--line`?n===0?xe:{start:n,end:n}:e},xe),u=s.reduce((e,t)=>e.includes(Oe(t))?e:[Oe(t),...e],Lt(t)),d=/* @__PURE__ */ new Set,f=Wt(()=>{let e=s.findIndex(e=>!F(e));if(e!==-1){let t=o[e];throw console.error(`File "<unknown>":\nError: File ${JSON.stringify(t)} not found`),new _(`File ${t} not found`,{failure:`Module.Parser.parse_file`})}return me(s.map(e=>({file:`./${e}`,source:Fe(e,`utf8`)})),e=>{d.add(e);let t=u.map(t=>`${t}/${e}.tla`).find(e=>F(e));return t===void 0?e===`TLAPS`?{file:`TLAPS.tla`,source:pe}:void 0:{file:t,source:Fe(t,`utf8`)}},{lines:l,onWarning:e=>{if(e.channel===`stdout`)return console.log(e.text);let t=e.channel===`toolbox`||e.channel===`toolboxOnly`;if(c&&t)return Rt([`type:warning`,`msg:${e.text}`]);e.channel!==`toolboxOnly`&&console.error(e.text)}})});if(!f)return 3;let p=t.get(`--cache-dir`)?.[0]??process.env.TLAPM_CACHE_DIR??`.tlacache`,m=t.get(`--nofpl`)?.map(Number)??[0,0],h={isToolbox:c,isProving:!t.has(`--noproving`),workers:Math.max(1,Number(t.get(`--threads`)?.[0]??Ge())),isFingerprinted:e=>!t.has(`--nofp`)&&!(e.locus&&e.locus.startLine>=m[0]&&e.locus.endLine<=m[1]),fingerprints:/* @__PURE__ */ new Map},g=[];for(let[e,r]of f.entries()){let i=`${p}/${r.name}.tlaps`,a=`${i}/fingerprints`,o=t.get(`--usefp`)?.[0]??a;if(Pe(i,{recursive:!0}),t.has(`--cleanfp`)&&F(a)&&(Be(a),console.log(`(* fingerprints file ${JSON.stringify(a)} removed *)`)),!t.has(`--cleanfp`)&&F(o)&&r.summary.total!==0&&(console.log(t.has(`--nofp`)?`(* will not use fingerprints (because of option \`--nofp\`), but will now load fingerprints from the file \`${o}\`, in order to overwrite with the new fingerprints, and then save the results at the end. *)`:`(* loading fingerprints in ${JSON.stringify(o)} *)`),Tt(h.fingerprints,o,t.has(`--safefp`))),t.has(`--summary`)&&console.log(Ce(r)),c&&(r.obligations.forEach(e=>zt(e,`to be proved`,t.has(`--printallobs`)?[`obl:${e.text}`]:[])),Rt([`type:obligationsnumber`,`count:${r.obligations.length}`])),t.has(`--strict`)&&g.push(...Ut(r,l.start>0||l.end<1/0,t.has(`--summary`))),!n)continue;At(a,[...d,...f.slice(0,e+1).map(e=>e.name)].map(e=>`${e}.tla`));let s=await qt(r,`${i}/${r.name}.thy`,a,h);if(s&&t.has(`--strict`)&&g.push(Ht.failed),s&&!t.has(`--strict`)&&!c)return console.error(` tlapm ending abnormally with Failure("backend errors: there are unproved obligations")
11
11
  Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
12
12
  Called from Tlapm_lib.process_module in file "src/tlapm_lib.ml", lines 492-493, characters 12-37
@@ -35,7 +35,7 @@ the name of a theorem, assumption, or step.`)),{...H(u()),kind:`UseOrHide`,facts
35
35
  Temporal formula used as set.`)),da(e,e.set)),e.levelCorrect;case`AssumeProve`:return e.levelChecked>=t||(e.levelChecked=t,e.levelCorrect=!0,e.assumptions.forEach(r=>{X(r,t,n)||(e.levelCorrect=!1)}),X(e.goal,t,n),e.level=e.assumptions.reduce((e,t)=>Math.max(e,t.level),e.goal.level),[e.goal,...e.assumptions].forEach(t=>fa(e,t)),e.levelCorrect&&e.levelParams.forEach(t=>{t.kind===`OpDecl`&&t.declKind===2&&oa(e.levelConstraints,t,2)})),e.levelCorrect}},Ha=e=>{switch(e.kind){case`OpAppl`:return[...e.ranges,...e.operands];case`OpDef`:case`ThmOrAssumpDef`:case`Label`:return[e.body];case`LetIn`:return[...e.opDefs,...e.instances,e.body];case`SubstIn`:case`APSubstIn`:return[e.body,...e.substs.map(e=>e.expr)];case`Instance`:return e.substs.map(e=>e.expr);case`AssumeProve`:return[...e.assumptions,e.goal];case`NewSymb`:return[e.set];default:return[]}},Ua=/* @__PURE__ */ new Map([[`Integers`,`Int`],[`Naturals`,`Nat`],[`Reals`,`Reals`]]),Wa=e=>{let t=/* @__PURE__ */ new Set,n=e=>{if(e===void 0||t.has(e))return!1;if(t.add(e),e.kind===`OpAppl`){let t=e.operator;if(t.kind===`OpDecl`||t.kind===`FormalParam`)return!0;if(t.kind===`OpDef`){if(t.name===`BOOLEAN`)return!0;let e=t.module?.name;if(e!==void 0&&Ua.get(e)===t.name||n(t))return!0}}return Ha(e).some(n)};return n(e)},Ga=e=>e.operands.filter(e=>e?.kind===`OpAppl`),Ka=e=>{let t=e.operands[0];return t?.kind===`String`?t:void 0},qa=e=>JSON.stringify([e.operands.length,...Ga(e).map(e=>Ka(e)?.value).sort()]),Ja=(e,t=/* @__PURE__ */ new Set)=>(e.extendees.forEach(e=>{t.has(e)||(t.add(e),Ja(e,t))}),t),Ya=e=>{let t=e.records.map(t=>({domain:qa(t),warnings:Ga(t).flatMap(t=>{let n=Ka(t),r=n&&ti(e.context,n.value);return n===void 0||r===void 0?[]:[{location:n.location,text:`The field name "${n.value}" in the record constructor is identical to the existing definition or declaration\nnamed ${n.value}, located at ${Hr(r.location)}.\nThe field in the record will not take the value of the ${n.value} definition or declaration.\nIn TLA+, field names in records are strings, regardless of any similarly named declarations or definitions.\nTherefore, DOMAIN [${n.value} |-> ...] = {"${n.value}"} holds true.`,isWarning:!0}]})})),n=new Set(t.flatMap(e=>e.warnings.length>0?[e.domain]:[])),r=/* @__PURE__ */ new Set;return[...[...Ja(e)].flatMap(e=>e.records),...e.records].forEach(e=>{let t=qa(e);n.has(t)&&!r.has(t)&&Ga(e).some(Wa)&&r.add(t)}),t.flatMap(e=>r.has(e.domain)?[]:e.warnings)},Xa=e=>`${Hr(e.location)}\n\n${e.text}`,Za=e=>{let t=e.filter(e=>!e.isWarning),n=e.filter(e=>e.isWarning);return[t.length>0?`*** Errors: ${t.length}\n\n`:``,...t.map(e=>`${Xa(e)}\n\n\n`),n.length>0?`*** Warnings: ${n.length}\n\n`:``,...n.map(e=>`${Xa(e)}\n\n\n`)].join(``)},Qa=/* @__PURE__ */ new Set([`FiniteSets`,`Sequences`,`Bags`,`Naturals`,`Integers`,`Reals`,`RealTime`,`Randomization`,`TLC`]),$a=e=>{let t=/* @__PURE__ */ new Set,n=[],r=e=>{t.add(e.name),n.push(...e.extends),e.modules.forEach(r)};return r(e),n.filter(e=>!t.has(e))},eo=e=>{try{return S(Ai(e))}catch(e){if(e instanceof a)return;throw e}},to=(e,t)=>t===`1.7.4`&&ee(e)!==void 0?void 0:eo(e)?.name,no=(e,n,r={})=>{let i=Ee(e,`.tla`),a=w(r.version),o=r.fileName??i,s=F(e)?Fe(e,`utf8`):a.get(i),c=[],u=e=>{c.push(e),r.onPrint?.(e)},d=e=>u(`${e}\n`),f=r.version===`1.7.4`,p=f&&r.isXmlExport,m=e=>{r.isXmlExport||d(e)},h=r.describeFile,g=/* @__PURE__ */ new Map([[i,F(e)?`file`:`standard`]]),_={value:!1},v=[],y={isReported:!1,isAborted:!1},x=Rn(Xt(),d),S=/* @__PURE__ */ new Map,C=[],ee=()=>C.splice(0).forEach(e=>e.isError?r.onPrintError?.(`${e.text}\n`):d(e.text)),te=e=>{let t=S.get(e),n=t?.module.location.range;if(t===void 0||n===void 0)return;let i=t.text.split(/\r\n|\r|\n/),a=Lr(x,i.slice(n.start.line-1,n.end.line),r.version),o=a.has(`TLA_DIVERGENCE_EXISTS`),s=a.has(`PCAL_DIVERGENCE_EXISTS`),c=o===s?void 0:`The ${o?`TLA+ translation`:`PlusCal algorithm`} in module ${e} has changed since its last translation.`;if(f){let t=o&&s?`The PlusCal algorithm and its TLA+ translation in module ${e} filename since the last translation.`:c;t===void 0?a.has(`ERROR_ENCOUNTERED`)&&C.push({text:`A unexpected problem was encountered attempting to validate the specification for ${e}`,isError:!0}):C.push({text:`!! WARNING: ${t}`,isError:!1});return}let l=o&&s?`Both the PlusCal algorithm and its TLA+ translation in module ${e} have changed since the last translation.`:c??(a.has(`ERROR_ENCOUNTERED`)?`An unexpected problem was encountered attempting to validate the specification for ${e}`:void 0);if(l===void 0)return;let u=!a.has(`ERROR_ENCOUNTERED`)||o||s;v.some(e=>e.text===l)||v.push({location:e,text:l,isWarning:u})},T=(e,t)=>{if(r.isXmlExport||S.has(e))return;let n=eo(t);if(n===void 0||n.name!==e)return;let i=[...S.values()].filter(t=>$a(t.module).includes(e));S.set(e,{text:t,module:n}),i.forEach(()=>te(e)),$a(n).filter(t=>t!==e&&S.has(t)).forEach(te)},E=()=>{if(ee(),y.isReported)return;y.isReported=!0;let e=v.filter(e=>e.isWarning);e.length>0&&(m(`Warnings (${e.length}) during syntax parsing of ${o}:\n\n`),e.forEach(e=>m(`${Xa(e)}\n\n\n`))),e.length!==v.length&&(d(Za(v)),_.value=!0,y.isAborted=!0)},ne=e=>{let t=a.get(e),r=n(e),i=r===void 0&&t===void 0&&s!==void 0&&!f?b(s,e):void 0,o=r??i;return g.set(e,r===void 0?i===void 0?`standard`:`root file`:`file`),o!==void 0&&T(e,o),o??t},D=(()=>{try{if(s===void 0)throw new t(`Cannot find source file for module ${o}`,void 0);return T(i,s),na(s,ne,{rootFileName:i,rootFilePath:r.isXmlExport?`${o.replace(/\.tla$/,``)}.tla`:void 0,version:r.version,rootExtendees:r.rootExtendees,onParse:e=>{h&&d(`Parsing file ${h(e,g.get(e)??`file`)}`),e===i&&te(i),ee()},onAnalyze:e=>{E(),(h||p)&&!y.isAborted&&d(`Semantic processing of module ${e}`)},onModule:(e,t)=>{if(y.isAborted||(t.every(e=>e.isWarning)&&Ra(e,{messages:t,isTlc174:f}),t.length===0))return;if(t.some(e=>!e.isWarning)&&(_.value=!0),f)return d(`Semantic errors:\n\n${Za(t)}`);let n=t.filter(e=>e.isWarning);n.length>0&&(m(`*** Warnings: ${n.length}\n`),n.forEach(e=>m(`${Xa(e)}\n\n\n`)));let r=t.filter(e=>!e.isWarning);r.length!==0&&(d(`Semantic errors:\n\n*** Errors: ${r.length}\n`),r.forEach(e=>d(`${Xa(e)}\n\n`)))}})}catch(e){if(_.value=!0,e instanceof l){d(`\nFatal errors while parsing TLA+ spec in file ${o}\n`),d(e.message),d(Za(v));return}if(!(e instanceof t))throw e;let n={location:e.location,text:e.message,isWarning:!1},r=f&&e.parseError?.includes(` and token "" `);if(e.parseError!==void 0&&!r&&!p&&d(e.parseError),d(`\nFatal errors while parsing TLA+ spec in file ${o}\n`),r){d(`java.lang.NullPointerException: Cannot invoke "String.length()" because "str" is null`);return}if(f){d(`tla2sany.semantic.AbortException`),u(`*** Abort messages: 1\n\n${Xa(n)}\n\n\n`);return}d(Xa(n)),d(Za(y.isReported?[n]:[...v,n]))}})();if(D!==void 0&&E(),D!==void 0&&!_.value&&!r.isXmlExport&&!f){let e=D.modules.filter(e=>!Qa.has(e.name));h&&e.forEach(e=>d(`Linting of module ${e.name}`)),e.flatMap(Ya).forEach(e=>d(`${Xa(e)}\n\n\n`))}return{text:c.join(``),isFailed:_.value,specification:y.isAborted?void 0:D}},ro=async e=>{let t=(await import(`./compile.js`)).compile(Fe(e,`utf8`),e),n=`\\* Generated by tla-ts from ${Ee(e)}. Edit ${Ee(e)} instead.`,r=Ae(Oe(e),`${t.name}.tla`),i=Ae(Oe(e),`${t.name}.cfg`);for(let t of[r,i])if(F(t)&&!Fe(t,`utf8`).startsWith(n))throw new p(`${t} already exists, and tla-ts didn't generate it from ${e}`);return He(r,`${n}\n${t.source}\n`),He(i,`${n}\n${t.config}\n`),r},io={success:r.success,"assumption-violation":r.assumptionViolation,deadlock:r.deadlock,"invariant-violation":r.safetyViolation,"property-violation":r.safetyViolation,"liveness-violation":r.livenessViolation,"postcondition-violation":r.assumptionViolation,error:r.error},ao=e=>/^[+-]?\d+$/.test(e)&&BigInt.asIntN(64,BigInt(e))===BigInt(e),oo=e=>e?e[0]===`auto`?Ge():Math.max(1,Number.parseInt(e[0],10)||1):1,so=[`constrained`,`stuttering`,`strict`],co=(e,t)=>e.endsWith(t)?e:`${e}${t}`,lo=e=>{if(e.length===1)return{path:co(e[0],`.dump`)};let t=e[0].toLowerCase();return{path:co(e[1],`.dot`),dot:!0,colorize:t.includes(`colorize`),actionLabels:t.includes(`actionlabels`),snapshot:t.includes(`snapshot`)}},uo=(e,t)=>e.print(A.computingInitProgress,j.none,`Computed ${t} initial states...`),fo=(e,t)=>e===`invariant-violation`?{code:A.invariantViolatedInitial,text:`Invariant ${t} is violated by the initial state:`}:{code:A.propertyViolatedInitial,text:`Property ${t} is violated by the initial state:`},po=(e,t)=>t?.forEach(t=>{if(typeof t==`string`)return console.log(t);if(t.kind===`initial-states-progress`)return uo(e,t.count);let n=fo(t.status,t.name);e.print(n.code,j.error,`${n.text}\n${y(t.state)}`)}),mo=(e,t,n={code:A.behaviorUpToThisPoint,text:`The behavior up to this point is:`},r=!1)=>{t.length>0&&e.print(n.code,j.error,n.text),t.forEach((t,n)=>{(n>0||r)&&po(e,t.output),e.print(A.statePrint2,j.state,`${n+1}: <${t.label??t.action??`Initial predicate`}>\n${y(t.state)}`)})},ho={code:A.counterExample,text:`The following behavior constitutes a counter-example:
36
36
  `},go=(e,t)=>t===`1.7.4`||e.length===0?`Temporal properties were violated.
37
37
  `:e.length===1?`Temporal property ${e[0]} was violated.\n`:`Temporal properties ${e.slice(0,-1).join(`, `)}${e.length>2?`,`:``} and ${e[e.length-1]} were violated.\n`,_o=e=>e.filter((t,n)=>t!==e[n-1]).map((e,t)=>`${t}) ${O(e)}\n`).toReversed().join(``),vo=e=>{if(e.length===0)return` The error call stack is empty.
38
- `;let t=[];return e.forEach((n,r)=>{let i=n.location.range;n!==e[r-1]&&i&&t.push(`${t.length}. Line ${i.start.line}, column ${i.start.column} to line ${i.end.line}, column ${i.end.column} in ${i.module}\n`)}),`${t.join(``)}\n`},yo=(e,t)=>{let n=t.generated,r=t.distinct,i=M(/* @__PURE__ */ new Date);n===r?e.print(A.initGenerated1,j.none,`Finished computing initial states: ${r} distinct state${r===1?``:`s`} generated at ${i}.`):e.print(A.initGenerated2,j.none,`Finished computing initial states: ${n} state${n===1?``:`s`} generated, with ${r} of them distinct at ${i}.`)},bo=(e,t,n)=>{let r=Math.max(Date.now()-(n??0),1)/6e4,i=e=>e.toLocaleString(`en-US`),a=(e,t)=>n===void 0?``:` (${i(Math.floor(e/r))} ${t}/min)`;e.print(A.progress,j.none,`Progress(${Math.max(t.depth,1)}) at ${M(/* @__PURE__ */ new Date)}: ${i(t.generatedStates)} states generated${a(t.generatedStates,`s`)}, ${i(t.distinctStates)} distinct states found${a(t.distinctStates,`ds`)}, ${i(t.queuedStates)} states left on queue.`)},xo=(e,t)=>Ae(e,`${t}.class`),So=(e,t,n,r)=>{let i=e.print;switch(t.kind){case`parsed`:n.isParsed=!0,e.isTool&&i(A.sanyFinished,j.none,`SANY finished.`),i(A.starting,j.none,`Starting... (${M(/* @__PURE__ */ new Date)})`);return;case`constant-level-invariant`:if(e.version===`1.7.4`)return;i(A.constantLevelInvariant,j.warning,`The invariant ${t.name} is a constant-level formula (i.e., it contains no variables, primes, or temporal operators) and evaluates to TRUE. To assert constant-level formulas in your spec, use ASSUME ConstInv. If you optionally want to give the assumption a name, write ASSUME YourAssumption == ConstInv instead. See https://explain.tlapl.us/assumptions-and-invariants for additional details.`);return;case`state-level-property`:if(e.version===`1.7.4`)return;i(A.stateLevelProperty,j.warning,`The formula ${t.name} is a state-level formula, but it was used as a PROPERTY (or PROPERTIES), where a temporal formula is typically expected. State-level formulas used as PROPERTY or PROPERTIES are only checked in the initial state. To verify that the formula ${t.name} holds in all states of every behavior, use INVARIANT ${t.name} instead. Alternatively, applying the "always" temporal operator ([]) to the state-level formula ${t.name} changes it into a temporal formula, asserting that ${t.name} holds in all states of every behavior. See https://explain.tlapl.us/invariants-and-properties for additional details.`);return;case`liveness-initializing`:t.isSymmetric&&i(A.livenessSymmetry,j.warning,`Declaring symmetry during liveness checking is dangerous. It might cause TLC to miss violations of the stated liveness properties. Please check liveness without symmetry defined.`),t.isConstrained&&e.version===`1.7.4`&&i(A.livenessConstraints,j.warning,`Declaring state or action constraints during liveness checking is dangerous: Please read section 14.3.5 on page 247 of Specifying Systems (https://lamport.azurewebsites.net/tla/book.html) and optionally the discussion at https://discuss.tlapl.us/msg00994.html for more details.`);return;case`liveness-prepared`:i(A.temporalBranches,j.none,`Implied-temporal checking--satisfiability problem has ${t.branches} branches.`);return;case`java-override`:{let e=Ue(je(xo(r,t.module))).href;i(t.isMatched?A.javaOverrideLoaded:A.javaOverrideMismatch,t.isMatched?j.none:j.warning,`${t.isMatched?`Loading`:`Failed to match`} ${t.operator} operator override from ${e.replace(`file:///`,`file:/`)} with signature: <Java Method: ${t.signature}>.`);return}case`initial-states-started`:i(A.computingInit,j.none,`Computing initial states...`);return;case`initial-states-progress`:uo(e,t.count);return;case`initial-states-computed`:yo(e,t.initialStates);return;case`progress`:bo(e,t.statistics,n.startTime);return;case`liveness-started`:{n.livenessStartTime=Date.now(),t.isComplete&&bo(e,t.statistics);let r=t.branches>1?`${t.branches} branches of `:``,a=t.branches*t.states;i(A.checkingTemporal,j.none,`Checking ${r}temporal properties for the ${t.isComplete?`complete`:`current`} state space with ${a} total distinct states at (${M(/* @__PURE__ */ new Date)})`);return}case`liveness-finished`:Co(e,n);return;case`sequential-fallback`:process.stderr.write(`Warning: the search created the string ${JSON.stringify(t.string)}, so tla-ts checks the model again with one worker. Workers agree on the order of strings only when the strings exist before the search.\n`);return;case`warning`:i(t.code,j.warning,t.text);return;case`violation`:wo(t.status,t.violation,e)}},Co=(e,t)=>{t.livenessStartTime!==void 0&&(e.print(A.checkingTemporalEnd,j.none,`Finished checking temporal properties in ${re(Date.now()-t.livenessStartTime)} at ${M(/* @__PURE__ */ new Date)}`),t.livenessStartTime=void 0)},wo=(e,t,n)=>{let r=n.print,i=t.name,a=t.loopStart,o=a===void 0&&t.trace.length===1&&(e===`invariant-violation`||e===`liveness-violation`),s={code:A.temporalPropertyViolated,text:go(t.properties??[i],n.version)},c={success:void 0,error:void 0,"assumption-violation":t.message?{code:A.assumptionEvaluationError,text:oe(A.assumptionEvaluationError,`Evaluating assumption ${i} failed.\n${t.message}`,n.isTool)}:{code:A.assumptionFalse,text:`Assumption ${i} is false.`},deadlock:{code:A.deadlockReached,text:`Deadlock reached.`},"invariant-violation":o?fo(`invariant-violation`,i):{code:A.invariantViolatedBehavior,text:`Invariant ${i} is violated.`},"property-violation":s,"liveness-violation":a===void 0?o?fo(`liveness-violation`,i):{code:A.actionPropertyViolatedBehavior,text:`Action property ${i} is violated.`}:s,"postcondition-violation":{code:t.postcondition?.code??A.general,text:t.message??`Postcondition ${i} is false.`}}[e],l=e===`property-violation`,u=a!==void 0&&!l,d=l||u,f=d&&n.version!==`1.7.4`;if(f&&po(n,t.trace[0]?.output),t.counts&&console.log(t.counts),c){let e=o?`${c.text}\n${y(t.trace[0].state)}`:c.text;r(c.code,j.error,e)}if(o||(d||po(n,t.trace[0]?.output),mo(n,t.trace,d?ho:void 0,d&&!f),po(n,t.traceOutput)),u){let e=t.loopLabel;a===t.trace.length-1?r(A.statePrint3,j.state,`${a+2}: Stuttering`):n.isTool?r(A.backToState,j.state,`${a+1}: Back to state${e?`: <${e}>\n`:``}`):console.log(`Back to state ${a+1}${e?`: <${e}>\n`:``}`)}t.warning&&n.version!==`1.7.4`&&r(t.warning.code,j.warning,t.warning.text);let p=t.unwitnessed??(e===`postcondition-violation`?void 0:t.postcondition);return p?.counts&&console.log(p.counts),p&&r(p.code,j.error,p.message),!o&&e!==`assumption-violation`},To=(e,t)=>e.print(A.nestedExpression,j.error,`The error occurred when TLC was evaluating the nested\nexpressions at the following positions:\n${vo(t)}`),Eo=(e,t,i)=>{let a=t.print;if(e.failure){let i=e.failure,o=t.isTool?i.toolMessage:i.message,s=()=>{let e=i.fingerprint;if(e){let n=i.callStack?.length&&t.version!==`1.7.4`?vo(i.callStack):_o(e.sources);a(A.fingerprintFailed,j.error,`TLC was unable to fingerprint.\n\nFingerprint Stack Trace:\n${n}\nReason:\n${ae(e.reason,t.isTool)}`)}else i.callStack&&To(t,i.callStack)};i.isCallStackFirst&&s();let l=i.initialState&&(()=>{try{return`While working on the initial state:\n${y(i.initialState)}`}catch(e){throw e instanceof c?h(new c(`${n}${e.message}`),r.error):e}})();a(l?A.initialState:i.code,j.error,l?`${o}\n${l}`:o),po(t,i.trace[0]?.output),mo(t,i.trace);let u=i.traceFailure;u&&a(u.code,j.error,t.isTool?u.toolMessage:u.message),po(t,i.traceOutput);let d=i.postcondition;d?.counts&&console.log(d.counts),d&&a(d.code,j.error,d.message),i.isCallStackFirst||s()}else if(e.violation){if(!wo(e.status,e.violation,t))return;let n=e.additionalViolation;n&&wo(`property-violation`,n,t),e.liveCallStack&&To(t,e.liveCallStack)}else{Co(t,i);let n=ie(e.distinctStates,e.generatedStates),r=e.fingerprintDistance===void 0?[]:[` based on the actual fingerprints: val = ${N(ue(e.fingerprintDistance))}`];a(A.success,j.none,[`Model checking completed. No error has been found.`,` Estimates of the probability that TLC did not check all reachable states`,` because two distinct states had the same fingerprint:`,` calculated (optimistic): val = ${N(n)}`,...r].join(`
38
+ `;let t=[];return e.forEach((n,r)=>{let i=n.location.range;n!==e[r-1]&&i&&t.push(`${t.length}. Line ${i.start.line}, column ${i.start.column} to line ${i.end.line}, column ${i.end.column} in ${i.module}\n`)}),`${t.join(``)}\n`},yo=(e,t)=>{let n=t.generated,r=t.distinct,i=M(/* @__PURE__ */ new Date);n===r?e.print(A.initGenerated1,j.none,`Finished computing initial states: ${r} distinct state${r===1?``:`s`} generated at ${i}.`):e.print(A.initGenerated2,j.none,`Finished computing initial states: ${n} state${n===1?``:`s`} generated, with ${r} of them distinct at ${i}.`)},bo=(e,t,n)=>{let r=Math.max(Date.now()-(n??0),1)/6e4,i=e=>e.toLocaleString(`en-US`),a=(e,t)=>n===void 0?``:` (${i(Math.floor(e/r))} ${t}/min)`;e.print(A.progress,j.none,`Progress(${Math.max(t.depth,1)}) at ${M(/* @__PURE__ */ new Date)}: ${i(t.generatedStates)} states generated${a(t.generatedStates,`s`)}, ${i(t.distinctStates)} distinct states found${a(t.distinctStates,`ds`)}, ${i(t.queuedStates)} states left on queue.`)},xo=(e,t)=>Ae(e,`${t}.class`),So=(e,t,n,r)=>{let i=e.print;switch(t.kind){case`parsed`:n.isParsed=!0,e.isTool&&i(A.sanyFinished,j.none,`SANY finished.`),i(A.starting,j.none,`Starting... (${M(/* @__PURE__ */ new Date)})`);return;case`constant-level-invariant`:if(e.version===`1.7.4`)return;i(A.constantLevelInvariant,j.warning,`The invariant ${t.name} is a constant-level formula (i.e., it contains no variables, primes, or temporal operators) and evaluates to TRUE. To assert constant-level formulas in your spec, use ASSUME ConstInv. If you optionally want to give the assumption a name, write ASSUME YourAssumption == ConstInv instead. See https://explain.tlapl.us/assumptions-and-invariants for additional details.`);return;case`state-level-property`:if(e.version===`1.7.4`)return;i(A.stateLevelProperty,j.warning,`The formula ${t.name} is a state-level formula, but it was used as a PROPERTY (or PROPERTIES), where a temporal formula is typically expected. State-level formulas used as PROPERTY or PROPERTIES are only checked in the initial state. To verify that the formula ${t.name} holds in all states of every behavior, use INVARIANT ${t.name} instead. Alternatively, applying the "always" temporal operator ([]) to the state-level formula ${t.name} changes it into a temporal formula, asserting that ${t.name} holds in all states of every behavior. See https://explain.tlapl.us/invariants-and-properties for additional details.`);return;case`liveness-initializing`:t.isSymmetric&&i(A.livenessSymmetry,j.warning,`Declaring symmetry during liveness checking is dangerous. It might cause TLC to miss violations of the stated liveness properties. Please check liveness without symmetry defined.`),t.isConstrained&&e.version===`1.7.4`&&i(A.livenessConstraints,j.warning,`Declaring state or action constraints during liveness checking is dangerous: Please read section 14.3.5 on page 247 of Specifying Systems (https://lamport.azurewebsites.net/tla/book.html) and optionally the discussion at https://discuss.tlapl.us/msg00994.html for more details.`);return;case`liveness-prepared`:i(A.temporalBranches,j.none,`Implied-temporal checking--satisfiability problem has ${t.branches} branches.`);return;case`java-override`:{let e=Ue(je(xo(r,t.module))).href;i(t.isMatched?A.javaOverrideLoaded:A.javaOverrideMismatch,t.isMatched?j.none:j.warning,`${t.isMatched?`Loading`:`Failed to match`} ${t.operator} operator override from ${e.replace(`file:///`,`file:/`)} with signature: <Java Method: ${t.signature}>.`);return}case`initial-states-started`:i(A.computingInit,j.none,`Computing initial states...`);return;case`initial-states-progress`:uo(e,t.count);return;case`initial-states-computed`:yo(e,t.initialStates);return;case`progress`:bo(e,t.statistics,n.startTime);return;case`liveness-started`:{n.livenessStartTime=Date.now(),t.isComplete&&bo(e,t.statistics);let r=t.branches>1?`${t.branches} branches of `:``,a=t.branches*t.states;i(A.checkingTemporal,j.none,`Checking ${r}temporal properties for the ${t.isComplete?`complete`:`current`} state space with ${a} total distinct states at (${M(/* @__PURE__ */ new Date)})`);return}case`liveness-finished`:Co(e,n);return;case`sequential-fallback`:process.stderr.write(`Warning: the search ordered the string ${JSON.stringify(t.string)} against another string it created, so tla-ts checks the model again with one worker. Workers don't agree on the order of strings the search creates.\n`);return;case`warning`:i(t.code,j.warning,t.text);return;case`violation`:wo(t.status,t.violation,e)}},Co=(e,t)=>{t.livenessStartTime!==void 0&&(e.print(A.checkingTemporalEnd,j.none,`Finished checking temporal properties in ${re(Date.now()-t.livenessStartTime)} at ${M(/* @__PURE__ */ new Date)}`),t.livenessStartTime=void 0)},wo=(e,t,n)=>{let r=n.print,i=t.name,a=t.loopStart,o=a===void 0&&t.trace.length===1&&(e===`invariant-violation`||e===`liveness-violation`),s={code:A.temporalPropertyViolated,text:go(t.properties??[i],n.version)},c={success:void 0,error:void 0,"assumption-violation":t.message?{code:A.assumptionEvaluationError,text:oe(A.assumptionEvaluationError,`Evaluating assumption ${i} failed.\n${t.message}`,n.isTool)}:{code:A.assumptionFalse,text:`Assumption ${i} is false.`},deadlock:{code:A.deadlockReached,text:`Deadlock reached.`},"invariant-violation":o?fo(`invariant-violation`,i):{code:A.invariantViolatedBehavior,text:`Invariant ${i} is violated.`},"property-violation":s,"liveness-violation":a===void 0?o?fo(`liveness-violation`,i):{code:A.actionPropertyViolatedBehavior,text:`Action property ${i} is violated.`}:s,"postcondition-violation":{code:t.postcondition?.code??A.general,text:t.message??`Postcondition ${i} is false.`}}[e],l=e===`property-violation`,u=a!==void 0&&!l,d=l||u,f=d&&n.version!==`1.7.4`;if(f&&po(n,t.trace[0]?.output),t.counts&&console.log(t.counts),c){let e=o?`${c.text}\n${y(t.trace[0].state)}`:c.text;r(c.code,j.error,e)}if(o||(d||po(n,t.trace[0]?.output),mo(n,t.trace,d?ho:void 0,d&&!f),po(n,t.traceOutput)),u){let e=t.loopLabel;a===t.trace.length-1?r(A.statePrint3,j.state,`${a+2}: Stuttering`):n.isTool?r(A.backToState,j.state,`${a+1}: Back to state${e?`: <${e}>\n`:``}`):console.log(`Back to state ${a+1}${e?`: <${e}>\n`:``}`)}t.warning&&n.version!==`1.7.4`&&r(t.warning.code,j.warning,t.warning.text);let p=t.unwitnessed??(e===`postcondition-violation`?void 0:t.postcondition);return p?.counts&&console.log(p.counts),p&&r(p.code,j.error,p.message),!o&&e!==`assumption-violation`},To=(e,t)=>e.print(A.nestedExpression,j.error,`The error occurred when TLC was evaluating the nested\nexpressions at the following positions:\n${vo(t)}`),Eo=(e,t,i)=>{let a=t.print;if(e.failure){let i=e.failure,o=t.isTool?i.toolMessage:i.message,s=()=>{let e=i.fingerprint;if(e){let n=i.callStack?.length&&t.version!==`1.7.4`?vo(i.callStack):_o(e.sources);a(A.fingerprintFailed,j.error,`TLC was unable to fingerprint.\n\nFingerprint Stack Trace:\n${n}\nReason:\n${ae(e.reason,t.isTool)}`)}else i.callStack&&To(t,i.callStack)};i.isCallStackFirst&&s();let l=i.initialState&&(()=>{try{return`While working on the initial state:\n${y(i.initialState)}`}catch(e){throw e instanceof c?h(new c(`${n}${e.message}`),r.error):e}})();a(l?A.initialState:i.code,j.error,l?`${o}\n${l}`:o),po(t,i.trace[0]?.output),mo(t,i.trace);let u=i.traceFailure;u&&a(u.code,j.error,t.isTool?u.toolMessage:u.message),po(t,i.traceOutput);let d=i.postcondition;d?.counts&&console.log(d.counts),d&&a(d.code,j.error,d.message),i.isCallStackFirst||s()}else if(e.violation){if(!wo(e.status,e.violation,t))return;let n=e.additionalViolation;n&&wo(`property-violation`,n,t),e.liveCallStack&&To(t,e.liveCallStack)}else{Co(t,i);let n=ie(e.distinctStates,e.generatedStates),r=e.fingerprintDistance===void 0?[]:[` based on the actual fingerprints: val = ${N(ue(e.fingerprintDistance))}`];a(A.success,j.none,[`Model checking completed. No error has been found.`,` Estimates of the probability that TLC did not check all reachable states`,` because two distinct states had the same fingerprint:`,` calculated (optimistic): val = ${N(n)}`,...r].join(`
39
39
  `))}if(e.failure?.isWithoutStatistics)return;e.status!==`success`&&Co(t,i),t.isTool&&bo(t,e,i.startTime),a(A.stats,j.none,`${e.generatedStates} states generated, ${e.distinctStates} distinct states found, ${e.queuedStates} states left on queue.`);let o=t.version===`1.7.4`,s=o?e.outDegrees??e.violationOutDegrees:e.outDegrees;(!o||s)&&a(A.searchDepth,j.none,`The depth of the complete state graph search is ${o?Math.max(e.depth,1):e.depth}.`);let l=s&&se(s);l&&a(A.stateGraphOutdegree,j.none,l)},Do=e=>fe([e]).toString(),Oo=(e,t,n,r,i)=>{let a=n.temporaryDirectory??qe(),o=F(a)?Re(a):je(a),s=Ae(o,`tlc-${Do(je(e))}`),c=lt(n);return(n,a)=>{let l=`${n}.tla`;if(a===`file`)return Re(et(t,n)??e);if(i===`1.7.4`)return Ae(o,l);if(a===`root file`){let t=r===void 0?o:je(r),i=Re(e);return`${Ae(t,Do(`${i} ${n}`),l)} (${i})`}let u=Ae(s,l);return c===void 0?u:`${u} (${rt(c)}${l})`}},ko=e=>e.print(A.version,j.none,`TLC2 Version ${ut} (rev: tla-ts)`),Ao=(e,t)=>(ko(e),e.print(A.commandLineError,j.error,`${t}\nUsage: java tlc2.TLC [-help] [-option] inputfile`),1),jo=(e,t,n)=>e.print(A.modelChecking,j.none,`Running breadth-first search Model-Checking with fp 0 and seed ${BigInt(t)} with ${n} worker${n===1?``:`s`} on ${Ge()} cores with ${Math.floor(Ye().heap_size_limit/1024/1024)}MB heap and 0MB offheap memory [pid: ${process.pid}] (${Je()} ${Ke()} ${We()}, Node.js ${process.versions.node} ${process.arch.endsWith(`64`)?64:32}bit, MemFPSet, MemStateQueue).`),Mo=(e,t)=>{let n=[...e.unknown,...e.options.map(e=>e.name)],r=(e,t=e)=>n.some(n=>n===e||n.toLowerCase()===t.toLowerCase()),i=r(`-generateSpecTE`)||!r(`-noGenerateSpecTE`,`-noTE`)&&!r(`-tool`)&&!r(`-continue`);return t!==`1.7.4`&&i&&!r(`-noGenerateSpecTEBin`,`-noTEBin`)},No=async(e,n,o,c)=>{let l=n.has(`-seed`)?n.get(`-seed`)?.[0]:`0`;if(l===void 0)return Ao(c,`Error: seed required.`);if(!ao(l))return Ao(c,`Error: An integer for seed required. But encountered ${l}`);let f=n.has(`-lncheck`)?n.get(`-lncheck`)?.[0]?.toLowerCase():`default`;if(f===void 0)return Ao(c,`Error: expect a strategy such as final for -lncheck option.`);let p=n.get(`-dump`);if(p?.length===0)return Ao(c,`Error: A file name for dumping states required.`);let m=p?.length===2&&so.find(e=>p[0].toLowerCase().includes(e));if(m)return console.error(`Error: tla-ts does not support the -dump format ${m}.`),1;let h=n.get(`-fp`)?.[0];if(h!==void 0&&Number(h)!==0)return console.error(`Error: tla-ts fingerprints states as TLC does with -fp 0, not -fp ${h}.`),1;let g=oo(n.get(`-workers`)),_=c.version;ko(c),jo(c,l,g);let v=n.get(`-config`)?.[0]??(n.has(`-config`)?void 0:e.replace(/\.tla$/,`.cfg`));if(!v||!F(v))return c.print(A.configFileError,j.error,`TLC encountered the following error when trying to read the configuration file ${v??``}:\nFile not found.`),r.configParseError;let y=Ee(e,`.tla`),b={startTime:Date.now(),livenessStartTime:void 0,isParsed:!1},x=()=>{let e=Date.now()-b.startTime;c.print(A.finished,j.none,`Finished in ${c.isTool?`${e}ms`:re(e)} at (${M(/* @__PURE__ */ new Date)})`)},S=()=>c.print(A.parsingFailed,j.error,`Parsing or semantic analysis failed.`),ee=e=>(e instanceof a?S():it(e,c),x(),i(e)),w=(()=>{try{return P(Fe(v,`utf8`),_)}catch(e){if(!(e instanceof d))throw e;return e}})();if(w instanceof d&&_===`1.7.4`)return c.print(A.general,j.error,`${s(`tlc2.tool.ConfigFileException`)}${ae(w.message,c.isTool)}`),x(),r.error;if(w instanceof d)return ee(w);n.has(`-deadlock`)&&(w.checkDeadlock=!1);let T=Oe(e),ne=[T,...o.libraries],D=tt(ne),O=Mo(n,_);c.isTool&&c.print(A.startingSany,j.none,`Starting SANY...`);let k=ke(e),ie=k?y:e.replace(/\.tla$/,``),N=lt(o),oe=_===`1.7.4`?Io(e,o,N):void 0;if(oe?!F(e)&&!C.has(y)&&oe(`${y}.tla`):!F(e)&&!te.has(y)&&nt(k?T:process.cwd(),k?`${y}.tla`:`./${ie}.tla`,[...k||T===`.`?[]:[T],...o.libraries]),no(e,oe?ct(D,oe):D,{fileName:ie,describeFile:Oo(e,ne,o,n.get(`-metadir`)?.[0],_),version:_,rootExtendees:O?[`_TLCTrace`]:void 0,onPrint:e=>process.stdout.write(e),onPrintError:e=>process.stderr.write(e)}).isFailed)return So(c,{kind:`parsed`},b,T),S(),x(),r.specParseError;try{let r=Fe(e,`utf8`),i=E(r).name;if(i!==y)throw new t(`File name '${y}' does not match the name '${i}' of the top level module it contains.`,void 0);let a=await ye({workers:g,livenessCheck:[`final`,`seqfinal`,`off`].includes(f)?`final`:`default`,seed:BigInt(l),dump:p&&lo(p),isTool:c.isTool,isContinued:n.has(`-continue`),isTraceRecorded:O,isSanyReported:!0,isWarningEnabled:!n.has(`-nowarning`),version:_,onProgress:e=>So(c,e,b,T),source:r,config:w,onPause:()=>Ie(0,Buffer.alloc(1)),loadModule:D,loadClass:e=>{let t=xo(T,e);return F(t)?Fe(t):void 0},readFile:e=>F(e)?Fe(e,`utf8`):void 0,writeFile:(e,t)=>{Pe(Oe(je(e)),{recursive:!0}),He(e,t)}});return Eo(a,c,b),x(),a.failure?.exitCode??io[a.status]}catch(e){if(!(e instanceof u))throw e;return e instanceof a&&console.log(Po(e,y)),b.isParsed||So(c,{kind:`parsed`},b,T),ee(e)}},Po=(e,n)=>{let r=e instanceof t;if(!r&&!e.failure)return`Semantic errors:\n\n*** Errors: 1\n\n${e.message}\n\n`;let i=r?e.location===void 0?`Unknown location\n\n${e.message}`:`In module ${e.location}\n\n${e.message}`:`In module ${n}\n\nCould not parse module ${n} from file ${n}.tla`;return`${e.failure?`***Parse Error***\n${e.message}\n\n`:``}\nFatal errors while parsing TLA+ spec in file ${n}\n\n${i}\n*** Errors: 1\n\n${i}\n\n\n`},Fo=async(e,t)=>{let n=Nt.parse(e),i=$e(n.positionals),a=n.has(`-config`),o=i.map(e=>({...e,path:e.isGlobbed||/\.(tla|cfg|ts)$/.test(e.path)?e.path.replace(/\.cfg$/,`.tla`):`${e.path}.tla`})).filter(e=>e.path.endsWith(`.ts`)||e.path.endsWith(`.tla`)&&(!e.isGlobbed||a||F(e.path.replace(/\.tla$/,`.cfg`)))).map(e=>e.path);if(o.length===0)return console.error(Ft),1;if(a&&o.length>1)return console.error(`Error: -config applies to one specification, but several were given.`),1;let s=[...new Set(o.map(e=>F(e)||ke(e)?e:t.libraries.map(t=>Ae(t,e)).find(F)??e))],c=[];for(let[e,r]of s.entries()){e>0&&console.log(``);let i=ce(n.has(`-tool`),!n.has(`-nowarning`),t.tlcVersion??`master`);c.push(await at(async()=>{let e=r.endsWith(`.ts`)?await ro(r):r;return s.length>1&&console.log(`Checking ${Ee(e)} with ${Ee(e,`.tla`)}.cfg`),No(e,n,t,i)},i))}return c.find(e=>e!==r.success)??r.success},Io=(e,t,n)=>{let r=e.slice(0,e.lastIndexOf(`/`)+1),i=(!ke(e)&&r!==``?[r]:t.libraries).map(st),a=i.length>0?i[i.length-1]:ke(e)?r:``;return e=>ot(`${a}${e}`,i,n)},Lo={uncaughtException:1,argsParsingFailure:1,specParsingFailure:2,unrepresentableCharacter:7},Ro=e=>`java.lang.IllegalArgumentException: unsupported kind: ${e} in xml export`,Z=(e,t=[])=>({tag:e,children:t}),Q=(e,t)=>({tag:e,text:String(t),children:[]}),zo={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,"\r":`&#13;`},Bo=e=>e.replace(/[&<>\r]|[\u{10000}-\u{10FFFF}]/gu,e=>e.length===2?`&#${e.codePointAt(0)};`:zo[e]),Vo=/[^\t\n\r\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/u,Ho=e=>{let t=(e.cdata??e.text)?.match(Vo)?.[0];if(t!==void 0)return{tag:e.tag,character:t};for(let t of e.children){let e=Ho(t);if(e)return e}},Uo=(e,t,n,r)=>{let i=` `.repeat(t*n);if(e.cdata){let t=e.cdata.replaceAll(`]]>`,`]]]]><![CDATA[>`);r.push(`${i}<${e.tag}><![CDATA[${t}]]></${e.tag}>`)}else if(e.text)r.push(`${i}<${e.tag}>${Bo(e.text)}</${e.tag}>`);else if(e.children.length===0)r.push(`${i}<${e.tag}/>`);else{r.push(`${i}<${e.tag}>`);for(let i of e.children)Uo(i,t+1,n,r);r.push(`${i}</${e.tag}>`)}},Wo=e=>Z(`location`,[Z(`column`,[Q(`begin`,e.beginColumn),Q(`end`,e.endColumn)]),Z(`line`,[Q(`begin`,e.beginLine),Q(`end`,e.endLine)]),Q(`filename`,e.file)]),Go=e=>{switch(e.kind){case`FormalParam`:return`FormalParamNodeRef`;case`OpDecl`:return`OpDeclNodeRef`;case`Module`:return`ModuleNodeRef`;case`Theorem`:return`TheoremNodeRef`;case`Assume`:return`AssumeNodeRef`;case`ThmOrAssumpDef`:return e.isTheorem?`TheoremDefRef`:`AssumeDefRef`;case`OpDef`:return e.defKind===`UserDefined`?`UserDefinedOpKindRef`:e.defKind===`BuiltIn`?`BuiltInKindRef`:`ModuleInstanceKindRef`}},$={main:{at:`xml.XMLExporter.main(XMLExporter.java:145)`},constant:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1228)`},variable:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1236)`},definition:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1244)`},topLevel:{at:`semantic.ModuleNode.getSymbolElement(ModuleNode.java:1268)`},body:{at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1392)`,nullType:`ExprNode`,nullValue:`"this.body"`},param:{at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1397)`},builtInParam:{at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1413)`},theoremDefinitionBody:{at:`semantic.ThmOrAssumpDefNode.getSymbolElement(ThmOrAssumpDefNode.java:663)`,nullType:`LevelNode`,nullValue:`"this.body"`},theoremDefinition:{at:`semantic.TheoremNode.getLevelElement(TheoremNode.java:439)`},theorem:{at:`semantic.TheoremNode.getLevelElement(TheoremNode.java:444)`,nullType:`LevelNode`,nullValue:`the return value of "tla2sany.semantic.TheoremNode.getTheorem()"`},proof:{at:`semantic.TheoremNode.getLevelElement(TheoremNode.java:447)`},assumeDefinition:{at:`semantic.AssumeNode.getLevelElement(AssumeNode.java:249)`},assume:{at:`semantic.AssumeNode.getLevelElement(AssumeNode.java:254)`,nullType:`ExprNode`,nullValue:`the return value of "tla2sany.semantic.AssumeNode.getAssume()"`},operator:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1315)`},operand:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1326)`,nullType:`ExprOrOpArgNode`,nullValue:`"this.operands[i]"`},unbound:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1337)`},bound:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1347)`},range:{at:`semantic.OpApplNode.getLevelElement(OpApplNode.java:1349)`,nullType:`ExprNode`,nullValue:`"this.ranges[i]"`},letBody:{at:`semantic.LetInNode.getLevelElement(LetInNode.java:301)`,nullType:`ExprNode`,nullValue:`"this.body"`},letDefinition:{at:`semantic.LetInNode.getLevelElement(LetInNode.java:303)`},labelBody:{at:`semantic.LabelNode.getLevelElement(LabelNode.java:341)`,nullType:`LevelNode`,nullValue:`"this.body"`},labelParam:{at:`semantic.LabelNode.getLevelElement(LabelNode.java:343)`},argument:{at:`semantic.OpArgNode.getLevelElement(OpArgNode.java:150)`},exceptObject:{at:`semantic.AtNode.getLevelElement(AtNode.java:180)`},exceptComponents:{at:`semantic.AtNode.getLevelElement(AtNode.java:181)`},substOperator:{at:`semantic.Subst.export(Subst.java:258)`},substExpression:{at:`semantic.Subst.export(Subst.java:259)`,nullType:`ExprOrOpArgNode`,nullValue:`"this.expr"`},instanceSubst:{at:`semantic.InstanceNode.getLevelElement(InstanceNode.java:447)`},instanceParam:{at:`semantic.InstanceNode.getLevelElement(InstanceNode.java:452)`},useFact:{at:`semantic.UseOrHideNode.getLevelElement(UseOrHideNode.java:175)`,nullType:`LevelNode`,nullValue:`"this.facts[i]"`},useDefinition:{at:`semantic.UseOrHideNode.getLevelElement(UseOrHideNode.java:176)`},newDeclaration:{at:`semantic.NewSymbNode.getLevelElement(NewSymbNode.java:202)`},newSet:{at:`semantic.NewSymbNode.getLevelElement(NewSymbNode.java:204)`},assumption:{at:`semantic.AssumeProveNode.getLevelElement(AssumeProveNode.java:404)`,nullType:`SemanticNode`,nullValue:`"assumes[i]"`},goal:{at:`semantic.AssumeProveNode.getLevelElement(AssumeProveNode.java:406)`,nullType:`ExprNode`,nullValue:`the return value of "tla2sany.semantic.AssumeProveNode.getProve()"`},byFact:{at:`semantic.LeafProofNode.getLevelElement(LeafProofNode.java:154)`,nullType:`LevelNode`,nullValue:`"this.facts[i]"`},byDefinition:{at:`semantic.LeafProofNode.getLevelElement(LeafProofNode.java:155)`},step:{at:`semantic.NonLeafProofNode.getLevelElement(NonLeafProofNode.java:228)`,nullType:`LevelNode`,nullValue:`"this.steps[i]"`},defStep:{at:`semantic.DefStepNode.getLevelElement(DefStepNode.java:99)`}},Ko={SubstIn:{subst:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:530)`},body:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:533)`,nullType:`ExprNode`,nullValue:`"this.body"`},from:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:536)`},to:{at:`semantic.SubstInNode.getLevelElement(SubstInNode.java:540)`}},APSubstIn:{subst:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:460)`},body:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:463)`,nullType:`LevelNode`,nullValue:`"this.body"`},from:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:466)`},to:{at:`semantic.APSubstInNode.getLevelElement(APSubstInNode.java:470)`}}},qo={at:`semantic.OpDefNode.getSymbolElement(OpDefNode.java:1424)`},Jo=Hr(`--TLA+ BUILTINS--`),Yo=(e,t)=>{let[n,r,i]=e===`Theorem`?[`TheoremNode.export(TheoremNode.java:456)`,70,`TheoremNode.exportDefinition(TheoremNode.java:404)`]:e===`Assume`?[`AssumeNode.export(AssumeNode.java:263)`,80,`AssumeNode.exportDefinition(AssumeNode.java:207)`]:[e===`ThmOrAssumpDef`?`ThmOrAssumpDefNode.export(ThmOrAssumpDefNode.java:671)`:`SymbolNode.export(SymbolNode.java:177)`,60,`SymbolNode.exportDefinition(SymbolNode.java:138)`];return[{at:`semantic.${n}`},{at:`xml.SymbolContext.put(SymbolContext.java:${r})`},{at:`semantic.${i}`,failedFor:t}]},Xo=(e,t=16)=>e>t*.75?Xo(e,t*2):t,Zo=(e,t)=>(e^e>>>16)&t-1,Qo=e=>{let t=e.split(/\r?\n/);for(;t.at(-1)===``;)t.pop();return t},$o=e=>e.replace(/^[\0-\x20]+|[\0-\x20]+$/g,``),es=/[\t-\r\x1C-\x20\u1680\u2000-\u2006\u2008-\u200A\u2028\u2029\u205F\u3000]+$/,ts=e=>{let t=e.indexOf(`(**`),n=e.lastIndexOf(`**)`);if(t<0||n<=t)return e;let r=Qo(e),i=r.findIndex(e=>e.includes(`(**`)),a=r.findLastIndex(e=>e.includes(`**)`));return i<0||i>=a?e:r.slice(i+1,a).map(e=>{let t=e.indexOf(`(*`),n=e.indexOf(`*)`);return t<0||n<=t?e:e.slice(t+3,Math.max(t+3,n)).replace(es,``)}).join(`
40
40
  `)},ns=e=>{let t=Qo(e),n=e=>$o(e).startsWith(`\\*`);return t.filter(n).length<Math.floor(t.length/2)?e:t.map(e=>{if(!n(e))return e;let t=e.indexOf(`\\*`)+2;return e.slice(e[t]===` `?t+1:t)}).join(`
41
41
  `)},rs=(e,t,n)=>{let r=n.version===`1.7.4`,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Map,o={isSet:!1},s=[],c=(e,t)=>{if(!r)return t();s.push(...e);let n=t();return s.length-=e.length,n},l=(e,t)=>{let n=[...s,...t].reverse(),r=[e,...n.map(e=>`\tat tla2sany.${e.at}`)].join(`