lawspec 0.31.0 → 0.31.3
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/CHANGELOG.md +116 -1
- package/README.md +86 -4
- package/api.mjs +14 -9
- package/authoring.mjs +899 -0
- package/beam-coverage.mjs +190 -65
- package/beam-doctor.mjs +343 -124
- package/bin/lawspec.mjs +1955 -657
- package/build.json +135 -129
- package/component-packages.mjs +662 -176
- package/component.d.ts +82 -20
- package/component.mjs +317 -94
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -5
- package/doctor.mjs +558 -299
- package/examples-command.mjs +44 -23
- package/failure-database.mjs +60 -17
- package/files.mjs +122 -62
- package/index.d.ts +585 -312
- package/input-files.mjs +90 -25
- package/launcher.mjs +72 -31
- package/learn/adapters.mjs +226 -0
- package/learn/app.mjs +1279 -0
- package/learn/assert.mjs +33 -0
- package/learn/assets.mjs +15 -0
- package/learn/browser-runtime.mjs +58 -0
- package/learn/bundle.mjs +118 -0
- package/learn/compile-worker.mjs +106 -0
- package/learn/compiler.mjs +230 -0
- package/learn/coverage.json +8259 -0
- package/learn/curriculum.json +2955 -0
- package/learn/fantomas-worker.mjs +25 -0
- package/learn/format-worker.mjs +148 -0
- package/learn/fsharp.mjs +83 -0
- package/learn/harness-host.mjs +22 -0
- package/learn/index.html +326 -0
- package/learn/lawspec-core.mjs +223 -0
- package/learn/lawspec-language.mjs +69 -0
- package/learn/node-test.mjs +11 -0
- package/learn/presentation.mjs +73 -0
- package/learn/runner.mjs +72 -0
- package/learn/sandbox-frame.html +34 -0
- package/learn/sandbox.mjs +91 -0
- package/learn/store.mjs +141 -0
- package/learn/story.mjs +42 -0
- package/learn/style-options.json +16 -0
- package/learn/style.css +1023 -0
- package/learn/theme.js +77 -0
- package/learn/typescript.mjs +53 -0
- package/learn/vendor/@fontsource-atkinson-hyperlegible-LICENSE.txt +93 -0
- package/learn/vendor/@fontsource-atkinson-hyperlegible-mono-LICENSE.txt +93 -0
- package/learn/vendor/@fontsource-overpass-LICENSE.txt +93 -0
- package/learn/vendor/assemblies.json +1 -0
- package/learn/vendor/editor-worker.js +30 -0
- package/learn/vendor/editor.css +1 -0
- package/learn/vendor/editor.mjs +931 -0
- package/learn/vendor/esbuild-wasm-LICENSE.txt +21 -0
- package/learn/vendor/esbuild.mjs +2683 -0
- package/learn/vendor/esbuild.wasm +0 -0
- package/learn/vendor/fable-library/Array.js +1347 -0
- package/learn/vendor/fable-library/Async.js +134 -0
- package/learn/vendor/fable-library/AsyncBuilder.js +183 -0
- package/learn/vendor/fable-library/BigInt.js +306 -0
- package/learn/vendor/fable-library/BitConverter.js +138 -0
- package/learn/vendor/fable-library/Boolean.js +22 -0
- package/learn/vendor/fable-library/CHANGELOG.md +242 -0
- package/learn/vendor/fable-library/Char.js +202 -0
- package/learn/vendor/fable-library/Choice.js +184 -0
- package/learn/vendor/fable-library/CollectionUtil.js +182 -0
- package/learn/vendor/fable-library/ConditionalWeakTable.js +21 -0
- package/learn/vendor/fable-library/Date.js +841 -0
- package/learn/vendor/fable-library/DateOffset.js +261 -0
- package/learn/vendor/fable-library/DateOnly.js +124 -0
- package/learn/vendor/fable-library/Decimal.js +238 -0
- package/learn/vendor/fable-library/Double.js +47 -0
- package/learn/vendor/fable-library/Encoding.js +185 -0
- package/learn/vendor/fable-library/Event.js +93 -0
- package/learn/vendor/fable-library/FSharp.Collections.js +45 -0
- package/learn/vendor/fable-library/FSharp.Core.CompilerServices.js +27 -0
- package/learn/vendor/fable-library/FSharp.Core.js +156 -0
- package/learn/vendor/fable-library/Global.js +29 -0
- package/learn/vendor/fable-library/Guid.js +161 -0
- package/learn/vendor/fable-library/Int32.js +135 -0
- package/learn/vendor/fable-library/List.js +1323 -0
- package/learn/vendor/fable-library/Long.js +47 -0
- package/learn/vendor/fable-library/MailboxProcessor.js +94 -0
- package/learn/vendor/fable-library/Map.js +1396 -0
- package/learn/vendor/fable-library/MapUtil.js +130 -0
- package/learn/vendor/fable-library/MutableMap.js +339 -0
- package/learn/vendor/fable-library/MutableSet.js +233 -0
- package/learn/vendor/fable-library/Native.js +14 -0
- package/learn/vendor/fable-library/Numeric.js +75 -0
- package/learn/vendor/fable-library/Observable.js +113 -0
- package/learn/vendor/fable-library/Option.js +104 -0
- package/learn/vendor/fable-library/README.md +3 -0
- package/learn/vendor/fable-library/Random.js +172 -0
- package/learn/vendor/fable-library/Range.js +45 -0
- package/learn/vendor/fable-library/Reflection.js +479 -0
- package/learn/vendor/fable-library/RegExp.js +141 -0
- package/learn/vendor/fable-library/Result.js +165 -0
- package/learn/vendor/fable-library/Seq.js +1417 -0
- package/learn/vendor/fable-library/Seq2.js +111 -0
- package/learn/vendor/fable-library/Set.js +1816 -0
- package/learn/vendor/fable-library/String.js +674 -0
- package/learn/vendor/fable-library/System.Collections.Generic.js +333 -0
- package/learn/vendor/fable-library/System.Text.js +200 -0
- package/learn/vendor/fable-library/System.js +289 -0
- package/learn/vendor/fable-library/TimeOnly.js +122 -0
- package/learn/vendor/fable-library/TimeSpan.js +180 -0
- package/learn/vendor/fable-library/Timer.js +67 -0
- package/learn/vendor/fable-library/Types.js +198 -0
- package/learn/vendor/fable-library/Unicode.13.0.0.js +4 -0
- package/learn/vendor/fable-library/Uri.js +165 -0
- package/learn/vendor/fable-library/Util.js +796 -0
- package/learn/vendor/fable-library/big.d.ts +338 -0
- package/learn/vendor/fable-library/lib/big.js +825 -0
- package/learn/vendor/fable-library/package.json +24 -0
- package/learn/vendor/fable-library/quotation.js +618 -0
- package/learn/vendor/fable.js +430 -0
- package/learn/vendor/fantomas/FSharp.Core.uawo19tl4c.wasm +0 -0
- package/learn/vendor/fantomas/Fantomas.Core.stnanlnpyw.wasm +0 -0
- package/learn/vendor/fantomas/Fantomas.FCS.lqohfu5o9y.wasm +0 -0
- package/learn/vendor/fantomas/LawSpec.Learn.Formatter.poiijdbsl9.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.CSharp.mp8lhr6rez.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.VisualBasic.0e5fchkecn.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.VisualBasic.Core.17wn27qal2.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.Win32.Primitives.9d566sle9e.wasm +0 -0
- package/learn/vendor/fantomas/Microsoft.Win32.Registry.52dy96yk8i.wasm +0 -0
- package/learn/vendor/fantomas/System.AppContext.jwujeh069z.wasm +0 -0
- package/learn/vendor/fantomas/System.Buffers.y0isk1x97h.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.Concurrent.x5koi7bzem.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.Immutable.diwg7advch.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.NonGeneric.4089xs440e.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.Specialized.hj81u7zblb.wasm +0 -0
- package/learn/vendor/fantomas/System.Collections.nvrdeoknr1.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.Annotations.yatcnfjeuk.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.DataAnnotations.led9l5awu3.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.EventBasedAsync.hpvp6cf4de.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.Primitives.v7cajwpaqo.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.TypeConverter.xk1hnyt762.wasm +0 -0
- package/learn/vendor/fantomas/System.ComponentModel.rrnda1lucx.wasm +0 -0
- package/learn/vendor/fantomas/System.Configuration.bn9vghjcq8.wasm +0 -0
- package/learn/vendor/fantomas/System.Console.09ajpiafhz.wasm +0 -0
- package/learn/vendor/fantomas/System.Core.wc649o5mw9.wasm +0 -0
- package/learn/vendor/fantomas/System.Data.Common.s4cowzd9a9.wasm +0 -0
- package/learn/vendor/fantomas/System.Data.DataSetExtensions.5fm360ikxl.wasm +0 -0
- package/learn/vendor/fantomas/System.Data.fsu4j4t4jw.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Contracts.p74re5oxzn.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Debug.622sixg49n.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.DiagnosticSource.2j35bc2g2b.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.FileVersionInfo.7n0wdvltaa.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Process.8iffh49mew.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.StackTrace.1yz88vico8.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.TextWriterTraceListener.ua8iuh2vhj.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Tools.roy5445ugj.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.TraceSource.6qx1ldzz7g.wasm +0 -0
- package/learn/vendor/fantomas/System.Diagnostics.Tracing.b4799zpaas.wasm +0 -0
- package/learn/vendor/fantomas/System.Drawing.8gcjjqj0pu.wasm +0 -0
- package/learn/vendor/fantomas/System.Drawing.Primitives.y2uveru2yk.wasm +0 -0
- package/learn/vendor/fantomas/System.Dynamic.Runtime.023zrvzh9x.wasm +0 -0
- package/learn/vendor/fantomas/System.Formats.Asn1.znpklkbgqv.wasm +0 -0
- package/learn/vendor/fantomas/System.Formats.Tar.5yybjepfi2.wasm +0 -0
- package/learn/vendor/fantomas/System.Globalization.Calendars.10g6hyjy3k.wasm +0 -0
- package/learn/vendor/fantomas/System.Globalization.Extensions.hrinfrismg.wasm +0 -0
- package/learn/vendor/fantomas/System.Globalization.uvs4rah8fk.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.4j645gw40d.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.2z7vdt6tfb.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.Brotli.fv80xs79j3.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.FileSystem.88jdddz3sw.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Compression.ZipFile.jkn9avr4vo.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.AccessControl.yme0uhbu37.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.DriveInfo.qas7wf73rs.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.Primitives.d1jmhkzu0e.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.Watcher.z570derp0d.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.FileSystem.o6jtz51fup.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.IsolatedStorage.hqyeyb5ipe.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.MemoryMappedFiles.zhamjnusxd.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Pipelines.wrmw5vws31.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Pipes.AccessControl.qcancj8gj2.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.Pipes.zhcyguvwkr.wasm +0 -0
- package/learn/vendor/fantomas/System.IO.UnmanagedMemoryStream.o8cpjnlard.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.AsyncEnumerable.hyc0b7okjw.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.Expressions.ldibvm0efj.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.Parallel.2buevezvch.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.Queryable.cvq43g1awj.wasm +0 -0
- package/learn/vendor/fantomas/System.Linq.lz6mvi0hm2.wasm +0 -0
- package/learn/vendor/fantomas/System.Memory.3jekerw0ga.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Http.Json.8k237kkwec.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Http.cityx2bvcl.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.HttpListener.s1jreclykx.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Mail.cmlj4c0gto.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.NameResolution.q3gf18q13l.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.NetworkInformation.xaz5tjw7d0.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Ping.a40atim1h0.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Primitives.i88i20r8sr.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Quic.hx06eo5xkj.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Requests.hkjxlfe5f5.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Security.ch34yya69o.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.ServerSentEvents.0u7o0jk3p1.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.ServicePoint.xbhxnytx4l.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.Sockets.hzgzlvkc9l.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebClient.84i8nwzbgu.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebHeaderCollection.326nl7s9g3.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebProxy.oq3mgkkqef.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebSockets.2cx1v74vg8.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.WebSockets.Client.rafzkktw8j.wasm +0 -0
- package/learn/vendor/fantomas/System.Net.w1hpj3bo6r.wasm +0 -0
- package/learn/vendor/fantomas/System.Numerics.Vectors.oyv7biw9ux.wasm +0 -0
- package/learn/vendor/fantomas/System.Numerics.lyu36wqn19.wasm +0 -0
- package/learn/vendor/fantomas/System.ObjectModel.kxu80demuu.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.CoreLib.1vy46s12u6.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.DataContractSerialization.ao8k9iu77a.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.Uri.itn0n2zjd0.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.Xml.19nzpxrx8w.wasm +0 -0
- package/learn/vendor/fantomas/System.Private.Xml.Linq.tw5eq1hjvo.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.DispatchProxy.7lajnj8s8c.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Emit.7liz9zln06.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Emit.ILGeneration.1ut3qgacw8.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Emit.Lightweight.d0gvllb1jj.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Extensions.zr5bhwfczd.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Metadata.ff6np6mz2j.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.Primitives.igpmvwv78c.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.TypeExtensions.qouojzlnp9.wasm +0 -0
- package/learn/vendor/fantomas/System.Reflection.mk3jyxvh13.wasm +0 -0
- package/learn/vendor/fantomas/System.Resources.Reader.41ppfyz2vc.wasm +0 -0
- package/learn/vendor/fantomas/System.Resources.ResourceManager.sfwvfmw1ea.wasm +0 -0
- package/learn/vendor/fantomas/System.Resources.Writer.3uvs9tp38z.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.CompilerServices.Unsafe.puz1xm53oc.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.CompilerServices.VisualC.9qdau315py.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Extensions.i7gntui96b.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Handles.00oxj4o6ov.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.InteropServices.JavaScript.9kq1vofond.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.InteropServices.RuntimeInformation.my7qeqbhfh.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.InteropServices.vqp80tnwc7.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Intrinsics.u0samjybfo.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Loader.n6zxw1b98a.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Numerics.o40sjhz59x.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Formatters.1esvva4te3.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Json.4n7u09advh.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Primitives.xs2bo91wvk.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.Xml.ny21jmziti.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.Serialization.qcxaur5wqs.wasm +0 -0
- package/learn/vendor/fantomas/System.Runtime.odq454d6j9.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.AccessControl.8yfnzmqzaq.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Claims.8ogy0860de.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Algorithms.8zijp1svfw.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Cng.yxagtt77no.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Csp.uhfbvvau84.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Encoding.2ywrusvy8q.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.OpenSsl.oa268u7i92.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.Primitives.5uhvqe8puk.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.X509Certificates.6i7pxilopt.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Cryptography.d0quqk1iyr.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Principal.Windows.gpqua4rz29.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.Principal.i20kfklf3g.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.SecureString.x2y8tzci3c.wasm +0 -0
- package/learn/vendor/fantomas/System.Security.e83vvh6sl2.wasm +0 -0
- package/learn/vendor/fantomas/System.ServiceModel.Web.poglliv2no.wasm +0 -0
- package/learn/vendor/fantomas/System.ServiceProcess.yro5uj2opo.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encoding.CodePages.2wchx40i7z.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encoding.Extensions.8utaw61kn5.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encoding.cxdyfepnpj.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Encodings.Web.37ehbi7cye.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.Json.ixiaa8hd3h.wasm +0 -0
- package/learn/vendor/fantomas/System.Text.RegularExpressions.2fhfmkk6vf.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.6pry74a050.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.AccessControl.76zfdfy8go.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Channels.gpxnr01lmp.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Overlapped.aqpl8tzdyc.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.Dataflow.ytwttt7fzh.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.Extensions.0deavcb00v.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.Parallel.tjwtxugso0.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Tasks.fu4qd5h3qy.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Thread.klaua2by9m.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.ThreadPool.mkzm212njz.wasm +0 -0
- package/learn/vendor/fantomas/System.Threading.Timer.yp49llu5h2.wasm +0 -0
- package/learn/vendor/fantomas/System.Transactions.Local.vz6cgeh4w7.wasm +0 -0
- package/learn/vendor/fantomas/System.Transactions.ipwm3rsy66.wasm +0 -0
- package/learn/vendor/fantomas/System.ValueTuple.7ol6ljuhx8.wasm +0 -0
- package/learn/vendor/fantomas/System.Web.HttpUtility.itlvncjd96.wasm +0 -0
- package/learn/vendor/fantomas/System.Web.np8uzzakvl.wasm +0 -0
- package/learn/vendor/fantomas/System.Windows.18nzio44t3.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.45jprtg1pa.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.Linq.v9v8udncm1.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.ReaderWriter.a9mr08uzci.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.Serialization.03juoguwgc.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XDocument.c9dhjnzqjb.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XPath.XDocument.138b12i1pm.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XPath.pvxm9341ce.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XmlDocument.450wsyxvl0.wasm +0 -0
- package/learn/vendor/fantomas/System.Xml.XmlSerializer.y3t2n0tce7.wasm +0 -0
- package/learn/vendor/fantomas/System.gjriafnqmz.wasm +0 -0
- package/learn/vendor/fantomas/WindowsBase.8zsce9qxfb.wasm +0 -0
- package/learn/vendor/fantomas/cs/FSharp.Core.resources.9ehmavdel7.wasm +0 -0
- package/learn/vendor/fantomas/de/FSharp.Core.resources.2ofmxloa01.wasm +0 -0
- package/learn/vendor/fantomas/dotnet.js +1233 -0
- package/learn/vendor/fantomas/dotnet.native.b6l13xorvf.js +16 -0
- package/learn/vendor/fantomas/dotnet.native.rw4kynp763.wasm +0 -0
- package/learn/vendor/fantomas/dotnet.runtime.v06hirbjsv.js +4 -0
- package/learn/vendor/fantomas/es/FSharp.Core.resources.hkr5ggb4tr.wasm +0 -0
- package/learn/vendor/fantomas/fr/FSharp.Core.resources.43soen28ow.wasm +0 -0
- package/learn/vendor/fantomas/icudt_CJK.tjcz0u77k5.dat +0 -0
- package/learn/vendor/fantomas/icudt_EFIGS.tptq2av103.dat +0 -0
- package/learn/vendor/fantomas/icudt_no_CJK.lfu7j35m59.dat +0 -0
- package/learn/vendor/fantomas/it/FSharp.Core.resources.m60n5ls7oq.wasm +0 -0
- package/learn/vendor/fantomas/ja/FSharp.Core.resources.o6oof69v14.wasm +0 -0
- package/learn/vendor/fantomas/ko/FSharp.Core.resources.q6l4snlu9o.wasm +0 -0
- package/learn/vendor/fantomas/mscorlib.8ptuc08eli.wasm +0 -0
- package/learn/vendor/fantomas/netstandard.eymp85mooh.wasm +0 -0
- package/learn/vendor/fantomas/pl/FSharp.Core.resources.8bni0w6j8b.wasm +0 -0
- package/learn/vendor/fantomas/pt-BR/FSharp.Core.resources.k849vqm41u.wasm +0 -0
- package/learn/vendor/fantomas/ru/FSharp.Core.resources.jz9rhhtsla.wasm +0 -0
- package/learn/vendor/fantomas/tr/FSharp.Core.resources.wn6vbvjm1u.wasm +0 -0
- package/learn/vendor/fantomas/zh-Hans/FSharp.Core.resources.z7zzbso094.wasm +0 -0
- package/learn/vendor/fantomas/zh-Hant/FSharp.Core.resources.iammfsi7ls.wasm +0 -0
- package/learn/vendor/fast-check-LICENSE.txt +21 -0
- package/learn/vendor/fast-check.mjs +37 -0
- package/learn/vendor/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
- package/learn/vendor/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
- package/learn/vendor/fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2 +0 -0
- package/learn/vendor/fonts/overpass-latin-600-normal.woff2 +0 -0
- package/learn/vendor/fonts/overpass-latin-700-normal.woff2 +0 -0
- package/learn/vendor/formatter-licenses/DotNet-LICENSE.txt +23 -0
- package/learn/vendor/formatter-licenses/DotNet-THIRD-PARTY-NOTICES.txt +1418 -0
- package/learn/vendor/formatter-licenses/FSharp-LICENSE.txt +23 -0
- package/learn/vendor/formatter-licenses/Fantomas-LICENSE.txt +202 -0
- package/learn/vendor/formatter-licenses/README.md +12 -0
- package/learn/vendor/manifest.json +1354 -0
- package/learn/vendor/metadata/Browser.Blob.dll +0 -0
- package/learn/vendor/metadata/Browser.Dom.dll +0 -0
- package/learn/vendor/metadata/Browser.Event.dll +0 -0
- package/learn/vendor/metadata/Browser.Gamepad.dll +0 -0
- package/learn/vendor/metadata/Browser.WebGL.dll +0 -0
- package/learn/vendor/metadata/Browser.WebStorage.dll +0 -0
- package/learn/vendor/metadata/FSharp.Core.dll +0 -0
- package/learn/vendor/metadata/Fable.Core.dll +0 -0
- package/learn/vendor/metadata/Fable.Repl.Lib.dll +0 -0
- package/learn/vendor/metadata/System.Collections.Concurrent.dll +0 -0
- package/learn/vendor/metadata/System.Collections.dll +0 -0
- package/learn/vendor/metadata/System.ComponentModel.Primitives.dll +0 -0
- package/learn/vendor/metadata/System.ComponentModel.TypeConverter.dll +0 -0
- package/learn/vendor/metadata/System.ComponentModel.dll +0 -0
- package/learn/vendor/metadata/System.Console.dll +0 -0
- package/learn/vendor/metadata/System.Core.dll +0 -0
- package/learn/vendor/metadata/System.Diagnostics.Debug.dll +0 -0
- package/learn/vendor/metadata/System.Diagnostics.Tools.dll +0 -0
- package/learn/vendor/metadata/System.Diagnostics.Tracing.dll +0 -0
- package/learn/vendor/metadata/System.Globalization.dll +0 -0
- package/learn/vendor/metadata/System.IO.dll +0 -0
- package/learn/vendor/metadata/System.Net.Requests.dll +0 -0
- package/learn/vendor/metadata/System.Net.WebClient.dll +0 -0
- package/learn/vendor/metadata/System.Numerics.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.Extensions.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.Metadata.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.Primitives.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.TypeExtensions.dll +0 -0
- package/learn/vendor/metadata/System.Reflection.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.Extensions.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.InteropServices.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.Numerics.dll +0 -0
- package/learn/vendor/metadata/System.Runtime.dll +0 -0
- package/learn/vendor/metadata/System.Text.Encoding.Extensions.dll +0 -0
- package/learn/vendor/metadata/System.Text.Encoding.dll +0 -0
- package/learn/vendor/metadata/System.Text.RegularExpressions.dll +0 -0
- package/learn/vendor/metadata/System.Threading.Tasks.dll +0 -0
- package/learn/vendor/metadata/System.Threading.Thread.dll +0 -0
- package/learn/vendor/metadata/System.Threading.dll +0 -0
- package/learn/vendor/metadata/System.ValueTuple.dll +0 -0
- package/learn/vendor/metadata/System.dll +0 -0
- package/learn/vendor/metadata/mscorlib.dll +0 -0
- package/learn/vendor/metadata/netstandard.dll +0 -0
- package/learn/vendor/monaco-editor-LICENSE.txt +21 -0
- package/learn/vendor/prettier/babel.mjs +16 -0
- package/learn/vendor/prettier/brace-style.mjs +376 -0
- package/learn/vendor/prettier/estree.mjs +44 -0
- package/learn/vendor/prettier/standalone.mjs +29 -0
- package/learn/vendor/prettier/typescript.mjs +22 -0
- package/learn/vendor/prettier-LICENSE.txt +7 -0
- package/learn/vendor/prettier-plugin-brace-style-LICENSE.txt +21 -0
- package/learn/vendor/typescript-LICENSE.txt +55 -0
- package/learn/vendor/typescript-libs.json +1 -0
- package/learn/vendor/typescript.mjs +451 -0
- package/learn/vendor/zod-LICENSE.txt +21 -0
- package/learn/web-format.mjs +8 -0
- package/learn.mjs +126 -0
- package/lsp.mjs +444 -133
- package/mcp.mjs +250 -0
- package/native-evidence.mjs +668 -182
- package/native-examples.mjs +56 -19
- package/native-host.mjs +136 -42
- package/native-parsers/clojure.LICENSE +121 -0
- package/native-parsers/clojure.wasm +0 -0
- package/native-parsers/csharp.LICENSE +21 -0
- package/native-parsers/csharp.wasm +0 -0
- package/native-parsers/elixir.LICENSE +176 -0
- package/native-parsers/elixir.wasm +0 -0
- package/native-parsers/erlang.LICENSE +201 -0
- package/native-parsers/erlang.wasm +0 -0
- package/native-parsers/fsharp.LICENSE +21 -0
- package/native-parsers/fsharp.wasm +0 -0
- package/native-parsers/gleam.LICENSE +202 -0
- package/native-parsers/gleam.wasm +0 -0
- package/native-parsers/go.LICENSE +21 -0
- package/native-parsers/go.wasm +0 -0
- package/native-parsers/groovy.LICENSE +21 -0
- package/native-parsers/groovy.wasm +0 -0
- package/native-parsers/haskell.LICENSE +21 -0
- package/native-parsers/haskell.wasm +0 -0
- package/native-parsers/java.LICENSE +21 -0
- package/native-parsers/java.wasm +0 -0
- package/native-parsers/javascript.LICENSE +21 -0
- package/native-parsers/javascript.wasm +0 -0
- package/native-parsers/kotlin.LICENSE +9 -0
- package/native-parsers/kotlin.wasm +0 -0
- package/native-parsers/lock.json +114 -0
- package/native-parsers/prolog.LICENSE +21 -0
- package/native-parsers/prolog.wasm +0 -0
- package/native-parsers/python.LICENSE +21 -0
- package/native-parsers/python.wasm +0 -0
- package/native-parsers/rust.LICENSE +21 -0
- package/native-parsers/rust.wasm +0 -0
- package/native-parsers/scala.LICENSE +21 -0
- package/native-parsers/scala.wasm +0 -0
- package/native-parsers/swift.LICENSE +21 -0
- package/native-parsers/swift.wasm +0 -0
- package/native-parsers/typescript.LICENSE +21 -0
- package/native-parsers/typescript.wasm +0 -0
- package/node-events-reporter.mjs +41 -17
- package/package.json +5 -3
- package/project.mjs +338 -0
- package/proof.d.ts +93 -19
- package/proof.mjs +1538 -447
- package/read-only-hpack.mjs +6 -5
- package/scala-build-state.mjs +131 -41
- package/scala-coverage.mjs +57 -34
- package/scalars.mjs +23 -8
- package/templates.mjs +566 -617
- package/test-command.mjs +1671 -521
package/proof.mjs
CHANGED
|
@@ -2,110 +2,248 @@
|
|
|
2
2
|
// Host execution of compiler-produced tasks. The browser/WASM compiler stays
|
|
3
3
|
// pure; this Node host invokes Z3's SMT-LIB interface without a shell.
|
|
4
4
|
import {spawn} from 'node:child_process';
|
|
5
|
-
import {createHash,randomUUID} from 'node:crypto';
|
|
6
|
-
import {
|
|
5
|
+
import {createHash, randomUUID} from 'node:crypto';
|
|
6
|
+
import {
|
|
7
|
+
access,
|
|
8
|
+
mkdir,
|
|
9
|
+
readFile,
|
|
10
|
+
realpath,
|
|
11
|
+
rename,
|
|
12
|
+
rm,
|
|
13
|
+
writeFile,
|
|
14
|
+
} from 'node:fs/promises';
|
|
7
15
|
import {constants} from 'node:fs';
|
|
8
16
|
import path from 'node:path';
|
|
9
17
|
|
|
10
|
-
const hash=value=>createHash('sha256').update(value).digest('hex');
|
|
11
|
-
const frame=value=>Buffer.byteLength(value,'utf8')+':'+value;
|
|
12
|
-
const fingerprint=values=>hash(values.map(frame).join(''));
|
|
18
|
+
const hash = value => createHash('sha256').update(value).digest('hex');
|
|
19
|
+
const frame = value => Buffer.byteLength(value, 'utf8') + ':' + value;
|
|
20
|
+
const fingerprint = values => hash(values.map(frame).join(''));
|
|
13
21
|
// A task names its encoding; tasks that need later features are v2.
|
|
14
|
-
const encodings=['lawspec-smtlib-v1','lawspec-smtlib-v2'];
|
|
22
|
+
const encodings = ['lawspec-smtlib-v1', 'lawspec-smtlib-v2'];
|
|
15
23
|
|
|
16
|
-
export function proofTaskFingerprint(task)
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
export function proofTaskFingerprint(task)
|
|
25
|
+
{
|
|
26
|
+
return fingerprint([
|
|
27
|
+
task.encoding,
|
|
28
|
+
task.lawFingerprint,
|
|
29
|
+
String(task.machineBits),
|
|
30
|
+
task.owner,
|
|
31
|
+
task.declaration,
|
|
32
|
+
task.script,
|
|
33
|
+
]);
|
|
19
34
|
}
|
|
20
35
|
|
|
21
|
-
function optionsWithDefaults(options)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
function optionsWithDefaults(options)
|
|
37
|
+
{
|
|
38
|
+
const config = {
|
|
39
|
+
binary: options.binary ?? 'z3',
|
|
40
|
+
timeoutMs: options.timeoutMs ?? 5000,
|
|
41
|
+
memoryMb: options.memoryMb ?? 512,
|
|
42
|
+
resourceLimit: options.resourceLimit ?? 0,
|
|
43
|
+
seed: options.seed ?? 0,
|
|
44
|
+
maxOutputBytes: options.maxOutputBytes ?? 1048576,
|
|
45
|
+
};
|
|
46
|
+
for (const [key, maximum] of [
|
|
47
|
+
['timeoutMs', 600000],
|
|
48
|
+
['memoryMb', 65536],
|
|
49
|
+
['resourceLimit', 2147483647],
|
|
50
|
+
['seed', 2147483647],
|
|
51
|
+
['maxOutputBytes', 16777216],
|
|
52
|
+
])
|
|
53
|
+
{
|
|
54
|
+
const minimum = ['resourceLimit', 'seed'].includes(key) ? 0 : 1;
|
|
55
|
+
if (
|
|
56
|
+
!Number.isSafeInteger(config[key]) ||
|
|
57
|
+
config[key] < minimum ||
|
|
58
|
+
config[key] > maximum
|
|
59
|
+
)
|
|
29
60
|
throw new TypeError(`Invalid Z3 ${key}`);
|
|
30
61
|
}
|
|
31
|
-
if
|
|
62
|
+
if (
|
|
63
|
+
typeof config.binary !== 'string' ||
|
|
64
|
+
!config.binary ||
|
|
65
|
+
config.binary.includes('\0')
|
|
66
|
+
)
|
|
32
67
|
throw new TypeError('Invalid Z3 executable');
|
|
33
68
|
return config;
|
|
34
69
|
}
|
|
35
70
|
|
|
36
|
-
async function executable(binary)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
71
|
+
async function executable(binary)
|
|
72
|
+
{
|
|
73
|
+
const candidates =
|
|
74
|
+
path.isAbsolute(binary) || binary.includes('/') || binary.includes('\\')
|
|
75
|
+
? [path.resolve(binary)]
|
|
76
|
+
: (process.env.PATH ?? '')
|
|
77
|
+
.split(path.delimiter)
|
|
78
|
+
.map(folder => path.resolve(folder, binary));
|
|
79
|
+
for (const candidate of candidates)
|
|
80
|
+
{
|
|
81
|
+
try
|
|
82
|
+
{
|
|
83
|
+
await access(candidate, constants.X_OK);
|
|
84
|
+
return await realpath(candidate);
|
|
85
|
+
}
|
|
86
|
+
catch (error)
|
|
87
|
+
{
|
|
88
|
+
if (!['ENOENT', 'EACCES', 'ENOTDIR'].includes(error.code)) throw error;
|
|
89
|
+
}
|
|
43
90
|
}
|
|
44
|
-
throw Object.assign(new Error(`Z3 executable is unavailable: ${binary}`),{
|
|
91
|
+
throw Object.assign(new Error(`Z3 executable is unavailable: ${binary}`), {
|
|
92
|
+
code: 'ENOENT',
|
|
93
|
+
});
|
|
45
94
|
}
|
|
46
95
|
|
|
47
96
|
// Only the first response line is a protocol token. Models and unknown reasons
|
|
48
97
|
// remain raw prover output; this host does not implement another SMT parser.
|
|
49
|
-
const followUp=token=>
|
|
50
|
-
token===
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
const followUp = token =>
|
|
99
|
+
token === 'sat'
|
|
100
|
+
? '(get-model)\n(exit)\n'
|
|
101
|
+
: token === 'unknown'
|
|
102
|
+
? '(get-info :reason-unknown)\n(exit)\n'
|
|
103
|
+
: '(exit)\n';
|
|
104
|
+
function execute(
|
|
105
|
+
binary,
|
|
106
|
+
args,
|
|
107
|
+
initial,
|
|
108
|
+
config,
|
|
109
|
+
interactive = false,
|
|
110
|
+
finishFor = followUp,
|
|
111
|
+
)
|
|
112
|
+
{
|
|
113
|
+
return new Promise(resolve =>
|
|
114
|
+
{
|
|
115
|
+
const started = performance.now();
|
|
116
|
+
const child = spawn(binary, args, {
|
|
117
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
118
|
+
shell: false,
|
|
119
|
+
});
|
|
120
|
+
child.stdout.setEncoding('utf8');
|
|
121
|
+
child.stderr.setEncoding('utf8');
|
|
122
|
+
let stdout = '',
|
|
123
|
+
stderr = '',
|
|
124
|
+
input = initial,
|
|
125
|
+
bytes = 0,
|
|
126
|
+
outcome = null,
|
|
127
|
+
error = null;
|
|
128
|
+
let timeout = false,
|
|
129
|
+
outputLimit = false,
|
|
130
|
+
answered = false,
|
|
131
|
+
closed = false;
|
|
132
|
+
const timer = setTimeout(() =>
|
|
133
|
+
{
|
|
134
|
+
timeout = true;
|
|
135
|
+
child.kill('SIGKILL');
|
|
136
|
+
}, config.timeoutMs);
|
|
137
|
+
const append = (which, chunk) =>
|
|
138
|
+
{
|
|
139
|
+
bytes += Buffer.byteLength(chunk, 'utf8');
|
|
140
|
+
if (bytes > config.maxOutputBytes)
|
|
141
|
+
{
|
|
142
|
+
outputLimit = true;
|
|
143
|
+
child.kill('SIGKILL');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (which === 'stdout') stdout += chunk;
|
|
147
|
+
else stderr += chunk;
|
|
148
|
+
if (interactive && !answered && stdout.includes('\n'))
|
|
149
|
+
{
|
|
150
|
+
answered = true;
|
|
151
|
+
const token = stdout.slice(0, stdout.indexOf('\n')).trim();
|
|
152
|
+
if (['sat', 'unsat', 'unknown'].includes(token)) outcome = token;
|
|
153
|
+
else error = 'unexpected Z3 protocol response';
|
|
154
|
+
const finish = finishFor(token);
|
|
155
|
+
input += finish;
|
|
70
156
|
child.stdin.end(finish);
|
|
71
157
|
}
|
|
72
158
|
};
|
|
73
|
-
child.stdout.on('data',chunk=>append('stdout',chunk));
|
|
74
|
-
child.stderr.on('data',chunk=>append('stderr',chunk));
|
|
75
|
-
child.stdin.on('error',problem=>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
159
|
+
child.stdout.on('data', chunk => append('stdout', chunk));
|
|
160
|
+
child.stderr.on('data', chunk => append('stderr', chunk));
|
|
161
|
+
child.stdin.on('error', problem =>
|
|
162
|
+
{
|
|
163
|
+
if (problem.code !== 'EPIPE') error = problem.message;
|
|
164
|
+
});
|
|
165
|
+
child.on('error', problem =>
|
|
166
|
+
{
|
|
167
|
+
error = problem.message;
|
|
82
168
|
});
|
|
83
|
-
|
|
169
|
+
child.on('close', (exitCode, signal) =>
|
|
170
|
+
{
|
|
171
|
+
if (closed) return;
|
|
172
|
+
closed = true;
|
|
173
|
+
clearTimeout(timer);
|
|
174
|
+
resolve({
|
|
175
|
+
stdout,
|
|
176
|
+
stderr,
|
|
177
|
+
input,
|
|
178
|
+
outcome,
|
|
179
|
+
error,
|
|
180
|
+
timeout,
|
|
181
|
+
outputLimit,
|
|
182
|
+
exitCode,
|
|
183
|
+
signal,
|
|
184
|
+
elapsedMs: performance.now() - started,
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
if (interactive) child.stdin.write(initial);
|
|
188
|
+
else child.stdin.end(initial);
|
|
84
189
|
});
|
|
85
190
|
}
|
|
86
191
|
|
|
87
|
-
const versionProbeMs=30000;
|
|
88
|
-
async function prover(config)
|
|
89
|
-
|
|
90
|
-
const
|
|
192
|
+
const versionProbeMs = 30000;
|
|
193
|
+
async function prover(config)
|
|
194
|
+
{
|
|
195
|
+
const binary = await executable(config.binary);
|
|
196
|
+
const binaryFingerprint = hash(await readFile(binary));
|
|
91
197
|
// The identity probe has its own bound: the task limit is for a solver's
|
|
92
198
|
// work on a task, and the probe does none.
|
|
93
|
-
const versionRun=await execute(binary,['-version'],'',{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
199
|
+
const versionRun = await execute(binary, ['-version'], '', {
|
|
200
|
+
...config,
|
|
201
|
+
timeoutMs: versionProbeMs,
|
|
202
|
+
});
|
|
203
|
+
const version = versionRun.stdout.trim();
|
|
204
|
+
if (
|
|
205
|
+
versionRun.exitCode !== 0 ||
|
|
206
|
+
versionRun.error ||
|
|
207
|
+
versionRun.timeout ||
|
|
208
|
+
versionRun.outputLimit ||
|
|
209
|
+
!/^Z3 version [0-9]+\.[0-9]+/.test(version)
|
|
210
|
+
)
|
|
211
|
+
throw Object.assign(
|
|
212
|
+
new Error(
|
|
213
|
+
'The selected executable did not return a successful Z3 version response',
|
|
214
|
+
),
|
|
215
|
+
{outcome: versionRun.timeout ? 'timeout' : 'failed'},
|
|
216
|
+
);
|
|
217
|
+
const args = [
|
|
218
|
+
'-in',
|
|
219
|
+
'-smt2',
|
|
220
|
+
`-t:${config.timeoutMs}`,
|
|
221
|
+
`-memory:${config.memoryMb}`,
|
|
222
|
+
];
|
|
223
|
+
const identity = fingerprint([
|
|
224
|
+
binaryFingerprint,
|
|
225
|
+
version,
|
|
226
|
+
JSON.stringify(args),
|
|
227
|
+
JSON.stringify(config),
|
|
228
|
+
]);
|
|
229
|
+
return {binary, binaryFingerprint, version, args, fingerprint: identity};
|
|
102
230
|
}
|
|
103
231
|
|
|
104
|
-
function validTask(task)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
232
|
+
function validTask(task)
|
|
233
|
+
{
|
|
234
|
+
return (
|
|
235
|
+
encodings.includes(task.encoding) &&
|
|
236
|
+
[32, 64].includes(task.machineBits) &&
|
|
237
|
+
[
|
|
238
|
+
'owner',
|
|
239
|
+
'declaration',
|
|
240
|
+
'lawFingerprint',
|
|
241
|
+
'script',
|
|
242
|
+
'taskFingerprint',
|
|
243
|
+
].every(key => typeof task[key] === 'string') &&
|
|
244
|
+
/^[0-9a-f]{64}$/.test(task.lawFingerprint) &&
|
|
245
|
+
proofTaskFingerprint(task) === task.taskFingerprint
|
|
246
|
+
);
|
|
109
247
|
}
|
|
110
248
|
|
|
111
249
|
// A semantic receipt may be reused after the compiler has admitted and
|
|
@@ -114,47 +252,127 @@ function validTask(task) {
|
|
|
114
252
|
// cache has the same trust boundary as the compiler's other persisted memos.
|
|
115
253
|
// Only completed unsat laws are reused. Counterexamples must be replayed by
|
|
116
254
|
// the current evaluator, and unknown/unsupported/incomplete work is retried.
|
|
117
|
-
async function receiptCache(request,selected)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
255
|
+
async function receiptCache(request, selected)
|
|
256
|
+
{
|
|
257
|
+
if (
|
|
258
|
+
typeof request.cacheDirectory !== 'string' ||
|
|
259
|
+
!request.cacheDirectory ||
|
|
260
|
+
selected.error
|
|
261
|
+
)
|
|
262
|
+
return null;
|
|
263
|
+
try
|
|
264
|
+
{
|
|
265
|
+
const build = await readFile(new URL('./build.json', import.meta.url));
|
|
266
|
+
const host = await readFile(new URL('./proof.mjs', import.meta.url));
|
|
267
|
+
return {
|
|
268
|
+
folder: path.join(request.cacheDirectory, 'solver-goals-v1'),
|
|
269
|
+
identity: fingerprint([
|
|
270
|
+
'lawspec.solver-cache.v1',
|
|
271
|
+
hash(build),
|
|
272
|
+
hash(host),
|
|
273
|
+
selected.fingerprint,
|
|
274
|
+
]),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
catch
|
|
278
|
+
{
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
125
281
|
}
|
|
126
282
|
|
|
127
|
-
async function cachedSolve(task,selected,config,cache)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
283
|
+
async function cachedSolve(task, selected, config, cache)
|
|
284
|
+
{
|
|
285
|
+
if (!cache || task.status !== 'ready' || !validTask(task))
|
|
286
|
+
return solve(task, selected, config);
|
|
287
|
+
const key = fingerprint([
|
|
288
|
+
cache.identity,
|
|
289
|
+
task.encoding,
|
|
290
|
+
task.lawFingerprint,
|
|
291
|
+
String(task.machineBits),
|
|
292
|
+
]);
|
|
293
|
+
const filename = path.join(cache.folder, key + '.json');
|
|
294
|
+
try
|
|
295
|
+
{
|
|
296
|
+
const saved = JSON.parse(await readFile(filename, 'utf8'));
|
|
297
|
+
const receipt = saved.receipt;
|
|
298
|
+
const complete =
|
|
299
|
+
saved.version === 1 &&
|
|
300
|
+
saved.key === key &&
|
|
301
|
+
validTask(saved.task) &&
|
|
302
|
+
saved.task.lawFingerprint === task.lawFingerprint &&
|
|
303
|
+
saved.task.encoding === task.encoding &&
|
|
304
|
+
saved.task.machineBits === task.machineBits &&
|
|
305
|
+
receipt?.status === 'proved' &&
|
|
306
|
+
receipt.outcome === 'unsat' &&
|
|
307
|
+
receipt.exitCode === 0 &&
|
|
308
|
+
receipt.lawFingerprint === task.lawFingerprint &&
|
|
309
|
+
/^[0-9a-f]{64}$/.test(receipt.runFingerprint ?? '') &&
|
|
310
|
+
receipt.prover?.fingerprint === selected.fingerprint &&
|
|
311
|
+
saved.digest === hash(JSON.stringify([saved.task, receipt]));
|
|
312
|
+
if (
|
|
313
|
+
complete &&
|
|
314
|
+
hash(await readFile(selected.binary)) === selected.binaryFingerprint
|
|
315
|
+
)
|
|
316
|
+
return {
|
|
317
|
+
...receipt,
|
|
318
|
+
owner: task.owner,
|
|
319
|
+
declaration: task.declaration,
|
|
320
|
+
at: task.at,
|
|
321
|
+
currentTaskFingerprint: task.taskFingerprint,
|
|
322
|
+
...(receipt.induction && task.induction
|
|
323
|
+
? {
|
|
324
|
+
currentInduction: {
|
|
325
|
+
on: task.induction.on,
|
|
326
|
+
using: task.induction.using,
|
|
327
|
+
},
|
|
328
|
+
}
|
|
329
|
+
: {}),
|
|
330
|
+
reused: {
|
|
331
|
+
key,
|
|
332
|
+
owner: saved.task.owner,
|
|
333
|
+
declaration: saved.task.declaration,
|
|
334
|
+
taskFingerprint: receipt.taskFingerprint,
|
|
335
|
+
runFingerprint: receipt.runFingerprint,
|
|
336
|
+
},
|
|
337
|
+
reason:
|
|
338
|
+
receipt.reason +
|
|
339
|
+
'; reused a completed semantic proof receipt; no new solver task ran',
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
catch
|
|
343
|
+
{}
|
|
344
|
+
const receipt = await solve(task, selected, config);
|
|
345
|
+
if (
|
|
346
|
+
receipt.status === 'proved' &&
|
|
347
|
+
receipt.outcome === 'unsat' &&
|
|
348
|
+
receipt.exitCode === 0
|
|
349
|
+
)
|
|
350
|
+
{
|
|
351
|
+
const temporary = filename + '.' + randomUUID() + '.tmp';
|
|
352
|
+
try
|
|
353
|
+
{
|
|
354
|
+
await mkdir(cache.folder, {recursive: true});
|
|
355
|
+
await writeFile(
|
|
356
|
+
temporary,
|
|
357
|
+
JSON.stringify({
|
|
358
|
+
version: 1,
|
|
359
|
+
key,
|
|
360
|
+
task,
|
|
361
|
+
receipt,
|
|
362
|
+
digest: hash(JSON.stringify([task, receipt])),
|
|
363
|
+
}) + '\n',
|
|
364
|
+
{mode: 0o600},
|
|
365
|
+
);
|
|
366
|
+
await rename(temporary, filename);
|
|
367
|
+
}
|
|
368
|
+
catch
|
|
369
|
+
{
|
|
370
|
+
}
|
|
371
|
+
finally
|
|
372
|
+
{
|
|
373
|
+
await rm(temporary, {force: true}).catch(() =>
|
|
374
|
+
{});
|
|
375
|
+
}
|
|
158
376
|
}
|
|
159
377
|
return receipt;
|
|
160
378
|
}
|
|
@@ -164,53 +382,163 @@ async function cachedSolve(task,selected,config,cache) {
|
|
|
164
382
|
// original ordered constant names, to the compiler for positional decoding
|
|
165
383
|
// and full validation against the current binders/claim. The host never
|
|
166
384
|
// rewrites solver/model text. Only compiler-confirmed outcomes are saved.
|
|
167
|
-
function queryFingerprint(row,task)
|
|
168
|
-
|
|
385
|
+
function queryFingerprint(row, task)
|
|
386
|
+
{
|
|
387
|
+
return row.kind === 'model'
|
|
388
|
+
? hash(row.declaration + '\0' + task.kind + '\0' + task.script)
|
|
389
|
+
: fingerprint([row.declaration, row.stage, task.script]);
|
|
169
390
|
}
|
|
170
|
-
async function analysisQuery(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
391
|
+
async function analysisQuery(
|
|
392
|
+
cache,
|
|
393
|
+
row,
|
|
394
|
+
task,
|
|
395
|
+
selected,
|
|
396
|
+
executeQuery,
|
|
397
|
+
fresh = false,
|
|
398
|
+
)
|
|
399
|
+
{
|
|
400
|
+
const eligible =
|
|
401
|
+
cache &&
|
|
402
|
+
/^[0-9a-f]{64}$/.test(task.semanticFingerprint ?? '') &&
|
|
403
|
+
task.fingerprint === queryFingerprint(row, task);
|
|
404
|
+
const key = eligible
|
|
405
|
+
? fingerprint([
|
|
406
|
+
cache.identity,
|
|
407
|
+
row.kind === 'model' ? 'model' : 'analysis',
|
|
408
|
+
row.kind === 'model' ? '' : row.stage,
|
|
409
|
+
task.semanticFingerprint,
|
|
410
|
+
])
|
|
411
|
+
: null;
|
|
412
|
+
const filename = eligible ? path.join(cache.folder, key + '.json') : null;
|
|
413
|
+
if (eligible && !fresh)
|
|
414
|
+
try
|
|
415
|
+
{
|
|
416
|
+
const saved = JSON.parse(await readFile(filename, 'utf8'));
|
|
417
|
+
const record = saved.record;
|
|
418
|
+
if (
|
|
419
|
+
saved.version === 1 &&
|
|
420
|
+
saved.key === key &&
|
|
421
|
+
saved.digest === hash(JSON.stringify(record)) &&
|
|
422
|
+
record?.semanticFingerprint === task.semanticFingerprint &&
|
|
423
|
+
record.solverFingerprint === selected.fingerprint &&
|
|
424
|
+
['sat', 'unsat'].includes(record.outcome) &&
|
|
425
|
+
record.completed === true &&
|
|
426
|
+
record.run?.exitCode === 0 &&
|
|
427
|
+
record.taskFingerprint ===
|
|
428
|
+
queryFingerprint(record, {
|
|
429
|
+
kind: record.taskKind,
|
|
430
|
+
script: record.script,
|
|
431
|
+
}) &&
|
|
432
|
+
hash(await readFile(selected.binary)) === selected.binaryFingerprint
|
|
433
|
+
)
|
|
434
|
+
return {
|
|
435
|
+
...record,
|
|
436
|
+
row,
|
|
437
|
+
cacheFile: filename,
|
|
438
|
+
reused: {
|
|
439
|
+
key,
|
|
440
|
+
owner: record.owner,
|
|
441
|
+
declaration: record.declaration,
|
|
442
|
+
taskFingerprint: record.taskFingerprint,
|
|
443
|
+
runFingerprint: record.runFingerprint,
|
|
444
|
+
},
|
|
445
|
+
rerun: () =>
|
|
446
|
+
analysisQuery(cache, row, task, selected, executeQuery, true),
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
catch
|
|
450
|
+
{}
|
|
451
|
+
const done = await executeQuery();
|
|
452
|
+
return {
|
|
453
|
+
...done,
|
|
454
|
+
row,
|
|
455
|
+
inputs: task.inputs,
|
|
456
|
+
...(eligible
|
|
457
|
+
? {
|
|
458
|
+
pendingCache: {
|
|
459
|
+
filename,
|
|
460
|
+
key,
|
|
461
|
+
record: {
|
|
462
|
+
kind: row.kind,
|
|
463
|
+
taskKind: task.kind,
|
|
464
|
+
owner: row.owner,
|
|
465
|
+
declaration: row.declaration,
|
|
466
|
+
stage: row.stage,
|
|
467
|
+
taskFingerprint: task.fingerprint,
|
|
468
|
+
semanticFingerprint: task.semanticFingerprint,
|
|
469
|
+
script: task.script,
|
|
470
|
+
solverFingerprint: selected.fingerprint,
|
|
471
|
+
inputs: task.inputs,
|
|
472
|
+
outcome: done.outcome,
|
|
473
|
+
values: done.values,
|
|
474
|
+
invariant: done.invariant,
|
|
475
|
+
run: done.run,
|
|
476
|
+
runFingerprint: done.runFingerprint,
|
|
477
|
+
completed: true,
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
}
|
|
481
|
+
: {}),
|
|
482
|
+
};
|
|
194
483
|
}
|
|
195
484
|
|
|
196
|
-
async function saveQuery(done)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
485
|
+
async function saveQuery(done)
|
|
486
|
+
{
|
|
487
|
+
if (
|
|
488
|
+
!done.pendingCache ||
|
|
489
|
+
!['sat', 'unsat'].includes(done.outcome) ||
|
|
490
|
+
done.run?.exitCode !== 0
|
|
491
|
+
)
|
|
492
|
+
return;
|
|
493
|
+
const {filename, key, record} = done.pendingCache;
|
|
494
|
+
const temporary = filename + '.' + randomUUID() + '.tmp';
|
|
495
|
+
try
|
|
496
|
+
{
|
|
497
|
+
await mkdir(path.dirname(filename), {recursive: true});
|
|
498
|
+
await writeFile(
|
|
499
|
+
temporary,
|
|
500
|
+
JSON.stringify({
|
|
501
|
+
version: 1,
|
|
502
|
+
key,
|
|
503
|
+
record,
|
|
504
|
+
digest: hash(JSON.stringify(record)),
|
|
505
|
+
}) + '\n',
|
|
506
|
+
{mode: 0o600},
|
|
507
|
+
);
|
|
508
|
+
await rename(temporary, filename);
|
|
509
|
+
}
|
|
510
|
+
catch
|
|
511
|
+
{
|
|
512
|
+
}
|
|
513
|
+
finally
|
|
514
|
+
{
|
|
515
|
+
await rm(temporary, {force: true}).catch(() =>
|
|
516
|
+
{});
|
|
517
|
+
}
|
|
205
518
|
}
|
|
206
519
|
|
|
207
520
|
// Law-set and model tasks need the same process and executable checks as
|
|
208
521
|
// ordinary laws; a protocol token alone is not a completed solver run.
|
|
209
|
-
async function verifiedOutcome(run,selected)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
522
|
+
async function verifiedOutcome(run, selected)
|
|
523
|
+
{
|
|
524
|
+
if (run.timeout) return 'timeout';
|
|
525
|
+
let unchanged = false;
|
|
526
|
+
try
|
|
527
|
+
{
|
|
528
|
+
unchanged =
|
|
529
|
+
hash(await readFile(selected.binary)) === selected.binaryFingerprint;
|
|
530
|
+
}
|
|
531
|
+
catch
|
|
532
|
+
{}
|
|
533
|
+
if (
|
|
534
|
+
!unchanged ||
|
|
535
|
+
run.outputLimit ||
|
|
536
|
+
run.error ||
|
|
537
|
+
run.exitCode !== 0 ||
|
|
538
|
+
!run.outcome ||
|
|
539
|
+
run.stdout.includes('(error ')
|
|
540
|
+
)
|
|
541
|
+
return 'failed';
|
|
214
542
|
return run.outcome;
|
|
215
543
|
}
|
|
216
544
|
|
|
@@ -222,369 +550,1132 @@ async function verifiedOutcome(run,selected) {
|
|
|
222
550
|
// the same encodings, and the law is proved only when every case is. The
|
|
223
551
|
// evidence records which encoding proved the law, and every attempt.
|
|
224
552
|
// Programmers read plain words; the IR keeps the SMT names.
|
|
225
|
-
const recursionName=
|
|
226
|
-
recursion?.encoding==='
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
553
|
+
const recursionName = recursion =>
|
|
554
|
+
recursion?.encoding === 'guarded-axioms'
|
|
555
|
+
? `unfolding step by step up to ${recursion.fuel} times`
|
|
556
|
+
: recursion?.encoding === 'define-fun-rec'
|
|
557
|
+
? 'solver recursion'
|
|
558
|
+
: '';
|
|
559
|
+
async function solve(task, selected, config)
|
|
560
|
+
{
|
|
561
|
+
const first = await attempt(
|
|
562
|
+
task,
|
|
563
|
+
task.script,
|
|
564
|
+
task.taskFingerprint,
|
|
565
|
+
selected,
|
|
566
|
+
config,
|
|
567
|
+
);
|
|
568
|
+
if (!task.recursion && !task.induction) return first;
|
|
569
|
+
if (
|
|
570
|
+
first.status === 'unsupported' ||
|
|
571
|
+
(first.status === 'incomplete' &&
|
|
572
|
+
first.outcome === 'failed' &&
|
|
573
|
+
!first.prover)
|
|
574
|
+
)
|
|
575
|
+
return first;
|
|
576
|
+
const tried = [
|
|
577
|
+
{
|
|
578
|
+
recursion: task.recursion,
|
|
579
|
+
taskFingerprint: task.taskFingerprint,
|
|
580
|
+
outcome: first.outcome,
|
|
581
|
+
runFingerprint: first.runFingerprint,
|
|
582
|
+
elapsedMs: first.elapsedMs,
|
|
583
|
+
},
|
|
584
|
+
];
|
|
585
|
+
if (first.outcome === 'unsat')
|
|
586
|
+
return {
|
|
587
|
+
...first,
|
|
588
|
+
recursion: task.recursion,
|
|
589
|
+
attempts: tried,
|
|
590
|
+
reason:
|
|
591
|
+
first.reason +
|
|
592
|
+
(task.recursion ? '; by ' + recursionName(task.recursion) : ''),
|
|
593
|
+
};
|
|
594
|
+
let best = {...first, recursion: task.recursion, attempts: tried};
|
|
595
|
+
const alternative = task.alternative;
|
|
596
|
+
if (alternative && !selected.error)
|
|
597
|
+
{
|
|
598
|
+
if (
|
|
599
|
+
typeof alternative.script !== 'string' ||
|
|
600
|
+
proofTaskFingerprint({...task, script: alternative.script}) !==
|
|
601
|
+
alternative.taskFingerprint
|
|
602
|
+
)
|
|
603
|
+
return {
|
|
604
|
+
...best,
|
|
605
|
+
reason:
|
|
606
|
+
first.reason + "; the alternative encoding's binding is invalid",
|
|
607
|
+
};
|
|
608
|
+
const second = await attempt(
|
|
609
|
+
task,
|
|
610
|
+
alternative.script,
|
|
611
|
+
alternative.taskFingerprint,
|
|
612
|
+
selected,
|
|
613
|
+
config,
|
|
614
|
+
);
|
|
615
|
+
tried.push({
|
|
616
|
+
recursion: alternative.recursion,
|
|
617
|
+
taskFingerprint: alternative.taskFingerprint,
|
|
618
|
+
outcome: second.outcome,
|
|
619
|
+
runFingerprint: second.runFingerprint,
|
|
620
|
+
elapsedMs: second.elapsedMs,
|
|
621
|
+
});
|
|
622
|
+
if (second.outcome === 'unsat')
|
|
623
|
+
return {
|
|
624
|
+
...second,
|
|
625
|
+
taskFingerprint: alternative.taskFingerprint,
|
|
626
|
+
recursion: alternative.recursion,
|
|
627
|
+
attempts: tried,
|
|
628
|
+
reason:
|
|
629
|
+
second.reason +
|
|
630
|
+
'; by ' +
|
|
631
|
+
recursionName(alternative.recursion) +
|
|
632
|
+
' after ' +
|
|
633
|
+
recursionName(task.recursion) +
|
|
634
|
+
' gave ' +
|
|
635
|
+
first.outcome,
|
|
636
|
+
};
|
|
637
|
+
best = {
|
|
638
|
+
...best,
|
|
639
|
+
reason:
|
|
640
|
+
first.reason +
|
|
641
|
+
'; ' +
|
|
642
|
+
recursionName(alternative.recursion) +
|
|
643
|
+
' gave ' +
|
|
644
|
+
second.outcome,
|
|
645
|
+
};
|
|
246
646
|
}
|
|
247
|
-
const induction=task.induction;
|
|
248
|
-
if(!induction||selected.error)return best;
|
|
249
|
-
if(induction.status!=='ready')
|
|
250
|
-
return {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
647
|
+
const induction = task.induction;
|
|
648
|
+
if (!induction || selected.error) return best;
|
|
649
|
+
if (induction.status !== 'ready')
|
|
650
|
+
return {
|
|
651
|
+
...best,
|
|
652
|
+
induction: {on: induction.on, using: induction.using, cases: []},
|
|
653
|
+
reason:
|
|
654
|
+
best.reason +
|
|
655
|
+
'; induction on ' +
|
|
656
|
+
induction.on +
|
|
657
|
+
' is unsupported: ' +
|
|
658
|
+
induction.reason,
|
|
659
|
+
};
|
|
660
|
+
const cases = [];
|
|
661
|
+
for (const item of induction.cases)
|
|
662
|
+
{
|
|
663
|
+
const bound = caseTask =>
|
|
664
|
+
proofTaskFingerprint({...task, script: caseTask.script}) ===
|
|
665
|
+
caseTask.taskFingerprint;
|
|
666
|
+
if (typeof item.script !== 'string' || !bound(item))
|
|
667
|
+
{
|
|
668
|
+
cases.push({
|
|
669
|
+
case: item.case,
|
|
670
|
+
outcome: 'failed',
|
|
671
|
+
reason: "the case's binding is invalid",
|
|
672
|
+
});
|
|
673
|
+
continue;
|
|
256
674
|
}
|
|
257
|
-
const runs=[
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
675
|
+
const runs = [
|
|
676
|
+
{
|
|
677
|
+
recursion: item.recursion,
|
|
678
|
+
script: item.script,
|
|
679
|
+
taskFingerprint: item.taskFingerprint,
|
|
680
|
+
},
|
|
681
|
+
...(item.alternative &&
|
|
682
|
+
typeof item.alternative.script === 'string' &&
|
|
683
|
+
bound(item.alternative)
|
|
684
|
+
? [
|
|
685
|
+
{
|
|
686
|
+
recursion: item.alternative.recursion,
|
|
687
|
+
script: item.alternative.script,
|
|
688
|
+
taskFingerprint: item.alternative.taskFingerprint,
|
|
689
|
+
},
|
|
690
|
+
]
|
|
691
|
+
: []),
|
|
692
|
+
];
|
|
693
|
+
const receipt = {case: item.case, attempts: []};
|
|
694
|
+
for (const run of runs)
|
|
695
|
+
{
|
|
696
|
+
const done = await attempt(
|
|
697
|
+
task,
|
|
698
|
+
run.script,
|
|
699
|
+
run.taskFingerprint,
|
|
700
|
+
selected,
|
|
701
|
+
config,
|
|
702
|
+
item.inputs,
|
|
703
|
+
);
|
|
704
|
+
receipt.attempts.push({
|
|
705
|
+
recursion: run.recursion,
|
|
706
|
+
taskFingerprint: run.taskFingerprint,
|
|
707
|
+
outcome: done.outcome,
|
|
708
|
+
runFingerprint: done.runFingerprint,
|
|
709
|
+
elapsedMs: done.elapsedMs,
|
|
710
|
+
});
|
|
711
|
+
Object.assign(receipt, {
|
|
712
|
+
outcome: done.outcome,
|
|
713
|
+
recursion: run.recursion,
|
|
714
|
+
taskFingerprint: run.taskFingerprint,
|
|
715
|
+
runFingerprint: done.runFingerprint,
|
|
716
|
+
});
|
|
717
|
+
if (done.values && !receipt.values) receipt.values = done.values;
|
|
718
|
+
if (done.outcome === 'unsat') break;
|
|
268
719
|
}
|
|
269
720
|
cases.push(receipt);
|
|
270
721
|
}
|
|
271
|
-
const record={
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
722
|
+
const record = {
|
|
723
|
+
on: induction.on,
|
|
724
|
+
using: induction.using,
|
|
725
|
+
asked: induction.asked,
|
|
726
|
+
cases,
|
|
727
|
+
};
|
|
728
|
+
if (cases.every(c => c.outcome === 'unsat'))
|
|
729
|
+
return {
|
|
730
|
+
...best,
|
|
731
|
+
status: 'proved',
|
|
732
|
+
outcome: 'unsat',
|
|
733
|
+
induction: record,
|
|
734
|
+
model: undefined,
|
|
735
|
+
modelValidated: undefined,
|
|
736
|
+
reason:
|
|
737
|
+
'Z3 established this law by induction on ' +
|
|
738
|
+
induction.on +
|
|
739
|
+
', every case: ' +
|
|
740
|
+
cases
|
|
741
|
+
.map(c => c.case + ' by ' + recursionName(c.recursion))
|
|
742
|
+
.join(', ') +
|
|
743
|
+
(induction.using.length
|
|
744
|
+
? '; citing ' +
|
|
745
|
+
induction.using.map(law => law.split('::law::').pop()).join(', ')
|
|
746
|
+
: '') +
|
|
747
|
+
'; trusts the typed translation and selected solver, without a kernel-checked certificate',
|
|
748
|
+
};
|
|
749
|
+
const open = cases.filter(c => c.outcome !== 'unsat');
|
|
750
|
+
return {
|
|
751
|
+
...best,
|
|
752
|
+
induction: record,
|
|
753
|
+
reason:
|
|
754
|
+
best.reason +
|
|
755
|
+
'; induction on ' +
|
|
756
|
+
induction.on +
|
|
757
|
+
': ' +
|
|
758
|
+
open.map(c => 'case ' + c.case + ' gave ' + c.outcome).join(', '),
|
|
759
|
+
};
|
|
279
760
|
}
|
|
280
761
|
|
|
281
|
-
async function attempt(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
762
|
+
async function attempt(
|
|
763
|
+
task,
|
|
764
|
+
script,
|
|
765
|
+
taskFingerprint,
|
|
766
|
+
selected,
|
|
767
|
+
config,
|
|
768
|
+
names = null,
|
|
769
|
+
)
|
|
770
|
+
{
|
|
771
|
+
const common = {
|
|
772
|
+
owner: task.owner,
|
|
773
|
+
declaration: task.declaration,
|
|
774
|
+
at: task.at,
|
|
775
|
+
lawFingerprint: task.lawFingerprint,
|
|
776
|
+
taskFingerprint: task.taskFingerprint,
|
|
777
|
+
encoding: task.encoding,
|
|
778
|
+
machineBits: task.machineBits,
|
|
779
|
+
configuration: config,
|
|
780
|
+
};
|
|
781
|
+
if (task.status === 'unsupported')
|
|
782
|
+
return {
|
|
783
|
+
...common,
|
|
784
|
+
status: 'unsupported',
|
|
785
|
+
outcome: 'unsupported',
|
|
786
|
+
reason: task.reason,
|
|
787
|
+
};
|
|
788
|
+
if (task.status !== 'ready' || !validTask(task))
|
|
789
|
+
return {
|
|
790
|
+
...common,
|
|
791
|
+
status: 'incomplete',
|
|
792
|
+
outcome: 'failed',
|
|
793
|
+
reason: 'Compiler proof task binding is invalid',
|
|
794
|
+
};
|
|
795
|
+
if (selected.error)
|
|
796
|
+
return {
|
|
797
|
+
...common,
|
|
798
|
+
status: 'incomplete',
|
|
799
|
+
outcome: selected.outcome,
|
|
800
|
+
reason: selected.error,
|
|
801
|
+
};
|
|
802
|
+
const input =
|
|
803
|
+
`(set-option :print-success false)\n(set-option :produce-models true)\n` +
|
|
804
|
+
`(set-option :random-seed ${config.seed})\n(set-option :rlimit ${config.resourceLimit})\n` +
|
|
805
|
+
script +
|
|
806
|
+
'(check-sat)\n';
|
|
292
807
|
// An induction case asks for the law's inputs, so its model can be
|
|
293
808
|
// checked as the law's counterexample.
|
|
294
|
-
const run=await execute(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
809
|
+
const run = await execute(
|
|
810
|
+
selected.binary,
|
|
811
|
+
selected.args,
|
|
812
|
+
input,
|
|
813
|
+
config,
|
|
814
|
+
true,
|
|
815
|
+
names?.length
|
|
816
|
+
? token =>
|
|
817
|
+
token === 'sat'
|
|
818
|
+
? `(get-value (${names.join(' ')}))\n(exit)\n`
|
|
819
|
+
: followUp(token)
|
|
820
|
+
: followUp,
|
|
821
|
+
);
|
|
822
|
+
let unchanged = false;
|
|
823
|
+
try
|
|
824
|
+
{
|
|
825
|
+
unchanged =
|
|
826
|
+
hash(await readFile(selected.binary)) === selected.binaryFingerprint;
|
|
827
|
+
}
|
|
828
|
+
catch
|
|
829
|
+
{}
|
|
830
|
+
const metadata = {
|
|
831
|
+
...common,
|
|
832
|
+
prover: {
|
|
833
|
+
name: 'z3',
|
|
834
|
+
version: selected.version,
|
|
835
|
+
binary: selected.binary,
|
|
836
|
+
binaryFingerprint: selected.binaryFingerprint,
|
|
837
|
+
fingerprint: selected.fingerprint,
|
|
838
|
+
arguments: selected.args,
|
|
839
|
+
},
|
|
840
|
+
configuration: config,
|
|
841
|
+
runFingerprint: fingerprint([
|
|
842
|
+
taskFingerprint,
|
|
843
|
+
selected.fingerprint,
|
|
844
|
+
run.input,
|
|
845
|
+
]),
|
|
846
|
+
elapsedMs: run.elapsedMs,
|
|
847
|
+
exitCode: run.exitCode,
|
|
848
|
+
signal: run.signal,
|
|
849
|
+
stdout: run.stdout,
|
|
850
|
+
stderr: run.stderr,
|
|
851
|
+
};
|
|
852
|
+
let outcome = run.outcome,
|
|
853
|
+
reason;
|
|
854
|
+
if (!unchanged)
|
|
855
|
+
{
|
|
856
|
+
outcome = 'failed';
|
|
857
|
+
reason = 'Z3 executable changed during execution';
|
|
858
|
+
}
|
|
859
|
+
else if (run.timeout)
|
|
860
|
+
{
|
|
861
|
+
outcome = 'timeout';
|
|
862
|
+
reason = 'Z3 exceeded the host wall-clock limit';
|
|
863
|
+
}
|
|
864
|
+
else if (run.outputLimit)
|
|
865
|
+
{
|
|
866
|
+
outcome = 'failed';
|
|
867
|
+
reason = 'Z3 exceeded the output limit';
|
|
868
|
+
}
|
|
869
|
+
else if (
|
|
870
|
+
run.exitCode !== 0 &&
|
|
871
|
+
/out of memory|out_of_memory/i.test(run.stdout + '\n' + run.stderr)
|
|
872
|
+
)
|
|
873
|
+
{
|
|
874
|
+
outcome = 'out-of-memory';
|
|
875
|
+
reason = 'Z3 reported memory exhaustion';
|
|
876
|
+
}
|
|
877
|
+
else if (
|
|
878
|
+
run.error ||
|
|
879
|
+
run.exitCode !== 0 ||
|
|
880
|
+
!outcome ||
|
|
881
|
+
run.stdout.includes('(error ')
|
|
882
|
+
)
|
|
883
|
+
{
|
|
884
|
+
outcome = 'failed';
|
|
885
|
+
reason = run.error ?? 'Z3 did not complete the task protocol successfully';
|
|
886
|
+
}
|
|
887
|
+
else if (outcome === 'unsat')
|
|
888
|
+
reason =
|
|
889
|
+
'Z3 established this law, including required definedness; trusts the typed translation and selected solver, without a kernel-checked certificate';
|
|
890
|
+
else if (outcome === 'sat')
|
|
891
|
+
reason =
|
|
892
|
+
'Z3 returned a satisfying model for the negated proof task; it has not been validated as a LawSpec counterexample';
|
|
893
|
+
else
|
|
894
|
+
{
|
|
895
|
+
reason =
|
|
896
|
+
'Z3 could not decide this task: ' +
|
|
897
|
+
run.stdout.slice(run.stdout.indexOf('\n') + 1).trim();
|
|
898
|
+
if (/:reason-unknown\s+"timeout"/.test(run.stdout)) outcome = 'timeout';
|
|
899
|
+
else if (
|
|
900
|
+
/:reason-unknown\s+"max\. resource limit exceeded"/.test(run.stdout)
|
|
901
|
+
)
|
|
902
|
+
outcome = 'resource-limit';
|
|
318
903
|
}
|
|
319
|
-
const model=
|
|
320
|
-
|
|
321
|
-
|
|
904
|
+
const model =
|
|
905
|
+
run.outcome === 'sat'
|
|
906
|
+
? run.stdout.slice(run.stdout.indexOf('\n') + 1).trim()
|
|
907
|
+
: null;
|
|
908
|
+
return {
|
|
909
|
+
...metadata,
|
|
910
|
+
status: outcome === 'unsat' ? 'proved' : 'incomplete',
|
|
911
|
+
outcome,
|
|
912
|
+
reason,
|
|
913
|
+
...(model !== null && !names?.length ? {model, modelValidated: false} : {}),
|
|
914
|
+
...(model !== null && names?.length ? {values: model} : {}),
|
|
915
|
+
};
|
|
322
916
|
}
|
|
323
917
|
|
|
324
918
|
// A satisfiable task's model is not a counterexample. Z3 runs the task's
|
|
325
919
|
// counterexample query (lawspec-smtlib-v2) and gives the values of the law's
|
|
326
920
|
// outer inputs; the compiler, not this host, reads them and re-checks the law
|
|
327
921
|
// at them with its reference evaluator.
|
|
328
|
-
async function counterexampleValues(task,selected,config)
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if(
|
|
332
|
-
query
|
|
333
|
-
|
|
922
|
+
async function counterexampleValues(task, selected, config)
|
|
923
|
+
{
|
|
924
|
+
const query = task.counterexample;
|
|
925
|
+
if (
|
|
926
|
+
!query ||
|
|
927
|
+
typeof query.script !== 'string' ||
|
|
928
|
+
!Array.isArray(query.inputs)
|
|
929
|
+
)
|
|
930
|
+
return null;
|
|
931
|
+
if (
|
|
932
|
+
fingerprint([
|
|
933
|
+
'lawspec-smtlib-v2',
|
|
934
|
+
task.lawFingerprint,
|
|
935
|
+
String(task.machineBits),
|
|
936
|
+
task.owner,
|
|
937
|
+
task.declaration,
|
|
938
|
+
query.script,
|
|
939
|
+
]) !== query.fingerprint
|
|
940
|
+
)
|
|
941
|
+
return null;
|
|
942
|
+
const names = query.inputs.map(input => input.name);
|
|
334
943
|
// A law with no inputs needs no search: the evaluator decides it.
|
|
335
|
-
if(!names.length)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
944
|
+
if (!names.length)
|
|
945
|
+
return {
|
|
946
|
+
outcome: 'sat',
|
|
947
|
+
values: '()',
|
|
948
|
+
fingerprint: query.fingerprint,
|
|
949
|
+
runFingerprint: null,
|
|
950
|
+
};
|
|
951
|
+
const input =
|
|
952
|
+
`(set-option :print-success false)\n(set-option :produce-models true)\n` +
|
|
953
|
+
`(set-option :random-seed ${config.seed})\n(set-option :rlimit ${config.resourceLimit})\n` +
|
|
954
|
+
query.script +
|
|
955
|
+
'(check-sat)\n';
|
|
956
|
+
const run = await execute(
|
|
957
|
+
selected.binary,
|
|
958
|
+
selected.args,
|
|
959
|
+
input,
|
|
960
|
+
config,
|
|
961
|
+
true,
|
|
962
|
+
token =>
|
|
963
|
+
token === 'sat' && names.length
|
|
964
|
+
? `(get-value (${names.join(' ')}))\n(exit)\n`
|
|
965
|
+
: '(exit)\n',
|
|
966
|
+
);
|
|
967
|
+
if (
|
|
968
|
+
run.outcome !== 'sat' ||
|
|
969
|
+
run.timeout ||
|
|
970
|
+
run.outputLimit ||
|
|
971
|
+
run.error ||
|
|
972
|
+
run.exitCode !== 0
|
|
973
|
+
)
|
|
974
|
+
return {outcome: run.outcome ?? 'failed', stdout: run.stdout};
|
|
975
|
+
return {
|
|
976
|
+
outcome: 'sat',
|
|
977
|
+
values: names.length
|
|
978
|
+
? run.stdout.slice(run.stdout.indexOf('\n') + 1).trim()
|
|
979
|
+
: '()',
|
|
980
|
+
fingerprint: query.fingerprint,
|
|
981
|
+
runFingerprint: fingerprint([
|
|
982
|
+
query.fingerprint,
|
|
983
|
+
selected.fingerprint,
|
|
984
|
+
run.input,
|
|
985
|
+
]),
|
|
986
|
+
};
|
|
345
987
|
}
|
|
346
988
|
|
|
347
989
|
// Tasks always come freshly from the compiler for the supplied source request.
|
|
348
990
|
// An imported JSON solver report cannot upgrade a law's evidence through here.
|
|
349
|
-
export async function proveWithZ3(compiler,request,options={})
|
|
350
|
-
|
|
991
|
+
export async function proveWithZ3(compiler, request, options = {})
|
|
992
|
+
{
|
|
993
|
+
const config = optionsWithDefaults(options);
|
|
351
994
|
// Settlement answers belong to this execution. A caller's imported
|
|
352
995
|
// answers must never upgrade a law before the host invokes its solver.
|
|
353
|
-
request={...request};
|
|
354
|
-
for(const key of ['analysisResults','modelResults','proofCounterexamples'])
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
996
|
+
request = {...request};
|
|
997
|
+
for (const key of ['analysisResults', 'modelResults', 'proofCounterexamples'])
|
|
998
|
+
delete request[key];
|
|
999
|
+
const result = await compiler.proofTasks(request);
|
|
1000
|
+
if (result.diagnostics?.length) return {...result, solverEvidence: []};
|
|
1001
|
+
const tasks = result.proofTasks ?? [];
|
|
1002
|
+
let selected = {};
|
|
1003
|
+
const analysis = result.analysisTasks ?? [];
|
|
1004
|
+
const modelTasks = result.modelTasks ?? [];
|
|
1005
|
+
if (
|
|
1006
|
+
tasks.some(task => task.status === 'ready') ||
|
|
1007
|
+
analysis.some(row => row.status === 'ready') ||
|
|
1008
|
+
modelTasks.some(law => law.tasks.length)
|
|
1009
|
+
)
|
|
1010
|
+
{
|
|
1011
|
+
try
|
|
1012
|
+
{
|
|
1013
|
+
selected = await prover(config);
|
|
1014
|
+
}
|
|
1015
|
+
catch (error)
|
|
1016
|
+
{
|
|
1017
|
+
selected = {
|
|
1018
|
+
error: error.message,
|
|
1019
|
+
outcome:
|
|
1020
|
+
error.code === 'ENOENT' ? 'unavailable' : (error.outcome ?? 'failed'),
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
364
1023
|
}
|
|
365
|
-
const solverEvidence=[];
|
|
366
|
-
const cache=await receiptCache(request,selected);
|
|
367
|
-
for(const task of tasks)
|
|
368
|
-
|
|
1024
|
+
const solverEvidence = [];
|
|
1025
|
+
const cache = await receiptCache(request, selected);
|
|
1026
|
+
for (const task of tasks)
|
|
1027
|
+
solverEvidence.push(await cachedSolve(task, selected, config, cache));
|
|
1028
|
+
const diagnostics = [...(result.diagnostics ?? [])];
|
|
369
1029
|
// Values to check as each unproved law's counterexample: the
|
|
370
1030
|
// counterexample query's (run whenever a law's task was satisfiable, and
|
|
371
1031
|
// for every unproved law over recursive definitions, since Z3 unfolds
|
|
372
1032
|
// freely there), then each induction case's model.
|
|
373
|
-
const searched=[];
|
|
374
|
-
for(const [index,item] of solverEvidence.entries())
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if(item.
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
1033
|
+
const searched = [];
|
|
1034
|
+
for (const [index, item] of solverEvidence.entries())
|
|
1035
|
+
{
|
|
1036
|
+
const task = tasks[index];
|
|
1037
|
+
if (['proved', 'unsupported'].includes(item.status) || selected.error)
|
|
1038
|
+
continue;
|
|
1039
|
+
if (item.outcome === 'sat' || task.recursion)
|
|
1040
|
+
{
|
|
1041
|
+
const found = await counterexampleValues(task, selected, config);
|
|
1042
|
+
if (found?.outcome === 'sat') searched.push({index, found});
|
|
1043
|
+
else if (found && item.outcome === 'sat')
|
|
1044
|
+
solverEvidence[index] = {
|
|
1045
|
+
...solverEvidence[index],
|
|
1046
|
+
reason:
|
|
1047
|
+
item.reason +
|
|
1048
|
+
'; the counterexample query gave no values (' +
|
|
1049
|
+
found.outcome +
|
|
1050
|
+
')',
|
|
1051
|
+
};
|
|
381
1052
|
}
|
|
382
|
-
for(const c of item.induction?.cases??[])
|
|
383
|
-
if(c.outcome==='sat'&&c.values)
|
|
1053
|
+
for (const c of item.induction?.cases ?? [])
|
|
1054
|
+
if (c.outcome === 'sat' && c.values)
|
|
1055
|
+
searched.push({
|
|
1056
|
+
index,
|
|
1057
|
+
found: {
|
|
1058
|
+
outcome: 'sat',
|
|
1059
|
+
values: c.values,
|
|
1060
|
+
fingerprint: c.taskFingerprint,
|
|
1061
|
+
runFingerprint: c.runFingerprint,
|
|
1062
|
+
},
|
|
1063
|
+
inductionCase: c.case,
|
|
1064
|
+
});
|
|
384
1065
|
}
|
|
385
|
-
if(searched.length)
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
1066
|
+
if (searched.length)
|
|
1067
|
+
{
|
|
1068
|
+
const checked = await compiler.proofTasks({
|
|
1069
|
+
...request,
|
|
1070
|
+
proofCounterexamples: searched.map(({index, found}) => ({
|
|
1071
|
+
owner: solverEvidence[index].owner,
|
|
1072
|
+
declaration: solverEvidence[index].declaration,
|
|
1073
|
+
taskFingerprint: tasks[index].taskFingerprint,
|
|
1074
|
+
values: found.values,
|
|
1075
|
+
})),
|
|
1076
|
+
});
|
|
1077
|
+
const checks = checked.counterexampleChecks ?? [];
|
|
1078
|
+
searched.forEach(({index, found, inductionCase}, position) =>
|
|
1079
|
+
{
|
|
1080
|
+
const item = solverEvidence[index],
|
|
1081
|
+
check = checks[position];
|
|
1082
|
+
if (
|
|
1083
|
+
!check ||
|
|
1084
|
+
check.owner !== item.owner ||
|
|
1085
|
+
check.declaration !== item.declaration ||
|
|
1086
|
+
item.status === 'refuted'
|
|
1087
|
+
)
|
|
1088
|
+
return;
|
|
1089
|
+
const counterexample = {
|
|
1090
|
+
inputs: check.inputs ?? [],
|
|
1091
|
+
values: found.values,
|
|
1092
|
+
fingerprint: found.fingerprint,
|
|
1093
|
+
runFingerprint: found.runFingerprint,
|
|
1094
|
+
check: check.status,
|
|
1095
|
+
};
|
|
1096
|
+
if (check.status === 'refuted')
|
|
1097
|
+
{
|
|
1098
|
+
const shown = (check.inputs ?? [])
|
|
1099
|
+
.map(input => input.name + ' = ' + input.value)
|
|
1100
|
+
.join(', ');
|
|
1101
|
+
solverEvidence[index] = {
|
|
1102
|
+
...item,
|
|
1103
|
+
status: 'refuted',
|
|
1104
|
+
modelValidated: true,
|
|
1105
|
+
counterexample,
|
|
1106
|
+
reason:
|
|
1107
|
+
(found.runFingerprint ? 'Z3 found ' : 'the law has no inputs; ') +
|
|
1108
|
+
(shown ? 'the input ' + shown : 'that the law fails') +
|
|
1109
|
+
(inductionCase
|
|
1110
|
+
? ' in case ' + inductionCase + ' of the induction'
|
|
1111
|
+
: '') +
|
|
1112
|
+
'; the reference evaluator confirms it: ' +
|
|
1113
|
+
check.reason,
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
else if (inductionCase && check.status === 'model-not-confirmed')
|
|
1117
|
+
{
|
|
401
1118
|
// Why3's SW: the case fails only under its hypothesis, not the law.
|
|
402
|
-
solverEvidence[index]={
|
|
403
|
-
|
|
404
|
-
|
|
1119
|
+
solverEvidence[index] = {
|
|
1120
|
+
...item,
|
|
1121
|
+
counterexample,
|
|
1122
|
+
reason:
|
|
1123
|
+
item.reason +
|
|
1124
|
+
'; in case ' +
|
|
1125
|
+
inductionCase +
|
|
1126
|
+
" the induction hypothesis is too weak: the law holds at Z3's input, " +
|
|
1127
|
+
check.reason,
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
else if (
|
|
1131
|
+
check.status === 'model-not-confirmed' &&
|
|
1132
|
+
(item.recursion || tasks[index].recursion)
|
|
1133
|
+
)
|
|
1134
|
+
{
|
|
405
1135
|
// Unfolding may stop early, so such a model need not be one of the
|
|
406
1136
|
// real definitions: incomplete, not a translation error.
|
|
407
|
-
solverEvidence[index]={
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
1137
|
+
solverEvidence[index] = {
|
|
1138
|
+
...item,
|
|
1139
|
+
counterexample,
|
|
1140
|
+
reason:
|
|
1141
|
+
item.reason +
|
|
1142
|
+
'; Z3 gave a model the reference evaluator does not confirm, after unfolding that may have stopped early: ' +
|
|
1143
|
+
check.reason,
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
else if (check.status === 'model-not-confirmed')
|
|
1147
|
+
{
|
|
1148
|
+
solverEvidence[index] = {
|
|
1149
|
+
...item,
|
|
1150
|
+
counterexample,
|
|
1151
|
+
reason:
|
|
1152
|
+
'Z3 gave a model the reference evaluator does not confirm: ' +
|
|
1153
|
+
check.reason,
|
|
1154
|
+
};
|
|
1155
|
+
diagnostics.push({
|
|
1156
|
+
code: 'proof-translation',
|
|
1157
|
+
message: `Z3's model for ${item.declaration} is not a counterexample: ${check.reason}`,
|
|
1158
|
+
at: item.at,
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
else if (item.outcome === 'sat')
|
|
1162
|
+
solverEvidence[index] = {
|
|
1163
|
+
...item,
|
|
1164
|
+
counterexample,
|
|
1165
|
+
reason: item.reason + '; ' + check.reason,
|
|
1166
|
+
};
|
|
412
1167
|
});
|
|
413
1168
|
}
|
|
414
1169
|
// A law proved by induction rests on the laws it cites: while one of them
|
|
415
1170
|
// is not proved (or checked on every input), neither is the law.
|
|
416
|
-
const current=new Map();
|
|
417
|
-
for(const row of result.evidence??[])
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
1171
|
+
const current = new Map();
|
|
1172
|
+
for (const row of result.evidence ?? [])
|
|
1173
|
+
if (row.stage === 'law') current.set(row.declaration, row.status);
|
|
1174
|
+
for (const item of solverEvidence)
|
|
1175
|
+
if (item.declaration && !item.kind)
|
|
1176
|
+
current.set(
|
|
1177
|
+
item.declaration,
|
|
1178
|
+
item.status === 'proved'
|
|
1179
|
+
? 'proved'
|
|
1180
|
+
: ['proved', 'exhaustively-checked'].includes(
|
|
1181
|
+
current.get(item.declaration),
|
|
1182
|
+
)
|
|
1183
|
+
? current.get(item.declaration)
|
|
1184
|
+
: item.status,
|
|
1185
|
+
);
|
|
1186
|
+
let changed = true;
|
|
1187
|
+
while (changed)
|
|
1188
|
+
{
|
|
1189
|
+
changed = false;
|
|
1190
|
+
solverEvidence.forEach((item, index) =>
|
|
1191
|
+
{
|
|
1192
|
+
const cited = (item.currentInduction ?? item.induction)?.using ?? [];
|
|
1193
|
+
if (item.status !== 'proved' || !cited.length) return;
|
|
1194
|
+
const open = cited.filter(
|
|
1195
|
+
law => !['proved', 'exhaustively-checked'].includes(current.get(law)),
|
|
1196
|
+
);
|
|
1197
|
+
if (!open.length) return;
|
|
1198
|
+
solverEvidence[index] = {
|
|
1199
|
+
...item,
|
|
1200
|
+
status: 'incomplete',
|
|
1201
|
+
reason:
|
|
1202
|
+
item.reason +
|
|
1203
|
+
'; it cites ' +
|
|
1204
|
+
open
|
|
1205
|
+
.map(
|
|
1206
|
+
law =>
|
|
1207
|
+
law.split('::law::').pop() +
|
|
1208
|
+
', which is ' +
|
|
1209
|
+
(current.get(law) ?? 'not proved'),
|
|
1210
|
+
)
|
|
1211
|
+
.join(', '),
|
|
1212
|
+
};
|
|
1213
|
+
current.set(item.declaration, 'incomplete');
|
|
1214
|
+
changed = true;
|
|
431
1215
|
});
|
|
432
1216
|
}
|
|
433
|
-
const evidence=(result.evidence??[]).map(row=>
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
1217
|
+
const evidence = (result.evidence ?? []).map(row =>
|
|
1218
|
+
{
|
|
1219
|
+
const found = solverEvidence.find(
|
|
1220
|
+
item => item.owner === row.owner && item.declaration === row.declaration,
|
|
1221
|
+
);
|
|
1222
|
+
if (row.stage !== 'law' || !found) return row;
|
|
1223
|
+
if (found.status !== 'proved')
|
|
1224
|
+
{
|
|
1225
|
+
if (
|
|
1226
|
+
[
|
|
1227
|
+
'proved',
|
|
1228
|
+
'exhaustively-checked',
|
|
1229
|
+
'known-discrepancy',
|
|
1230
|
+
'skipped',
|
|
1231
|
+
'flaky',
|
|
1232
|
+
].includes(row.status)
|
|
1233
|
+
)
|
|
1234
|
+
return row;
|
|
1235
|
+
return {
|
|
1236
|
+
...row,
|
|
1237
|
+
status:
|
|
1238
|
+
found.status === 'unsupported'
|
|
1239
|
+
? 'unsupported'
|
|
1240
|
+
: found.status === 'refuted'
|
|
1241
|
+
? 'refuted'
|
|
1242
|
+
: 'incomplete',
|
|
1243
|
+
reason: found.reason,
|
|
1244
|
+
};
|
|
439
1245
|
}
|
|
440
|
-
if(row.status==='known-discrepancy')
|
|
441
|
-
|
|
1246
|
+
if (row.status === 'known-discrepancy')
|
|
1247
|
+
{
|
|
1248
|
+
diagnostics.push({
|
|
1249
|
+
code: 'harness',
|
|
1250
|
+
message: `Z3 proved ${row.declaration}; its harness cannot mark it as a known discrepancy`,
|
|
1251
|
+
at: found.at,
|
|
1252
|
+
});
|
|
442
1253
|
return row;
|
|
443
1254
|
}
|
|
444
|
-
return {
|
|
1255
|
+
return {
|
|
1256
|
+
...row,
|
|
1257
|
+
status: 'proved',
|
|
1258
|
+
reason: found.reason + `; task ${found.taskFingerprint}`,
|
|
1259
|
+
};
|
|
445
1260
|
});
|
|
446
1261
|
// The law-set checks the compiler left undecided (completeness, overlap,
|
|
447
1262
|
// conflict, vacuity): Z3 runs each task, and the compiler confirms every
|
|
448
1263
|
// model with its reference evaluator before a check is refuted.
|
|
449
|
-
let settled=evidence,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
1264
|
+
let settled = evidence,
|
|
1265
|
+
found = diagnostics;
|
|
1266
|
+
if (analysis.length)
|
|
1267
|
+
{
|
|
1268
|
+
let answers = [];
|
|
1269
|
+
const ran = new Map();
|
|
1270
|
+
for (const row of analysis)
|
|
1271
|
+
{
|
|
1272
|
+
if (row.status !== 'ready')
|
|
1273
|
+
{
|
|
1274
|
+
solverEvidence.push({
|
|
1275
|
+
owner: row.owner,
|
|
1276
|
+
declaration: row.declaration,
|
|
1277
|
+
stage: row.stage,
|
|
1278
|
+
kind: 'analysis',
|
|
1279
|
+
encoding: 'lawspec-smtlib-v2',
|
|
1280
|
+
status: 'unsupported',
|
|
1281
|
+
outcome: 'unsupported',
|
|
1282
|
+
reason: row.reason,
|
|
1283
|
+
configuration: config,
|
|
1284
|
+
});
|
|
457
1285
|
continue;
|
|
458
1286
|
}
|
|
459
|
-
for(const task of row.tasks)
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
1287
|
+
for (const task of row.tasks)
|
|
1288
|
+
{
|
|
1289
|
+
if (selected.error)
|
|
1290
|
+
{
|
|
1291
|
+
ran.set(task.fingerprint, {
|
|
1292
|
+
row,
|
|
1293
|
+
outcome: selected.outcome,
|
|
1294
|
+
error: selected.error,
|
|
1295
|
+
});
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1298
|
+
const executeQuery = async () =>
|
|
1299
|
+
{
|
|
1300
|
+
const input =
|
|
1301
|
+
`(set-option :print-success false)\n(set-option :produce-models true)\n` +
|
|
1302
|
+
`(set-option :random-seed ${config.seed})\n(set-option :rlimit ${config.resourceLimit})\n` +
|
|
1303
|
+
task.script +
|
|
1304
|
+
'(check-sat)\n';
|
|
1305
|
+
const run = await execute(
|
|
1306
|
+
selected.binary,
|
|
1307
|
+
selected.args,
|
|
1308
|
+
input,
|
|
1309
|
+
config,
|
|
1310
|
+
true,
|
|
1311
|
+
token =>
|
|
1312
|
+
token === 'sat' && task.inputs.length
|
|
1313
|
+
? `(get-value (${task.inputs.join(' ')}))\n(exit)\n`
|
|
1314
|
+
: '(exit)\n',
|
|
1315
|
+
);
|
|
1316
|
+
const outcome = await verifiedOutcome(run, selected);
|
|
1317
|
+
const values =
|
|
1318
|
+
outcome === 'sat' && task.inputs.length
|
|
1319
|
+
? run.stdout.slice(run.stdout.indexOf('\n') + 1).trim()
|
|
1320
|
+
: '';
|
|
1321
|
+
return {
|
|
1322
|
+
outcome,
|
|
1323
|
+
run,
|
|
1324
|
+
values,
|
|
1325
|
+
runFingerprint: fingerprint([
|
|
1326
|
+
task.fingerprint,
|
|
1327
|
+
selected.fingerprint,
|
|
1328
|
+
run.input,
|
|
1329
|
+
]),
|
|
1330
|
+
};
|
|
469
1331
|
};
|
|
470
|
-
const done=await analysisQuery(
|
|
471
|
-
|
|
472
|
-
|
|
1332
|
+
const done = await analysisQuery(
|
|
1333
|
+
cache,
|
|
1334
|
+
row,
|
|
1335
|
+
task,
|
|
1336
|
+
selected,
|
|
1337
|
+
executeQuery,
|
|
1338
|
+
);
|
|
1339
|
+
ran.set(task.fingerprint, done);
|
|
1340
|
+
answers.push({
|
|
1341
|
+
fingerprint: task.fingerprint,
|
|
1342
|
+
outcome: done.outcome,
|
|
1343
|
+
values: done.values,
|
|
1344
|
+
inputs: done.inputs,
|
|
1345
|
+
});
|
|
473
1346
|
}
|
|
474
1347
|
}
|
|
475
|
-
let checked=answers.length
|
|
1348
|
+
let checked = answers.length
|
|
1349
|
+
? await compiler.proofTasks({...request, analysisResults: answers})
|
|
1350
|
+
: {};
|
|
476
1351
|
// A stored SAT model can stop decoding after a public constructor rename.
|
|
477
1352
|
// Revalidation fails closed; retry that query once with the current names.
|
|
478
|
-
let retried=false;
|
|
479
|
-
for(const verdict of checked.analysisChecks??[])
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
1353
|
+
let retried = false;
|
|
1354
|
+
for (const verdict of checked.analysisChecks ?? [])
|
|
1355
|
+
{
|
|
1356
|
+
const done = ran.get(verdict.fingerprint);
|
|
1357
|
+
if (verdict.status === 'incomplete' && done?.reused && done.rerun)
|
|
1358
|
+
{
|
|
1359
|
+
await rm(done.cacheFile, {force: true}).catch(() =>
|
|
1360
|
+
{});
|
|
1361
|
+
ran.set(verdict.fingerprint, await done.rerun());
|
|
1362
|
+
retried = true;
|
|
484
1363
|
}
|
|
485
1364
|
}
|
|
486
|
-
if(retried)
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
1365
|
+
if (retried)
|
|
1366
|
+
{
|
|
1367
|
+
answers = answers.map(answer =>
|
|
1368
|
+
{
|
|
1369
|
+
const done = ran.get(answer.fingerprint);
|
|
1370
|
+
return {
|
|
1371
|
+
...answer,
|
|
1372
|
+
outcome: done.outcome,
|
|
1373
|
+
values: done.values,
|
|
1374
|
+
inputs: done.inputs,
|
|
1375
|
+
};
|
|
1376
|
+
});
|
|
1377
|
+
checked = await compiler.proofTasks({
|
|
1378
|
+
...request,
|
|
1379
|
+
analysisResults: answers,
|
|
1380
|
+
});
|
|
490
1381
|
}
|
|
491
|
-
const rows=new Map(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
1382
|
+
const rows = new Map(
|
|
1383
|
+
(checked.analysisEvidence ?? []).map(row => [
|
|
1384
|
+
row.declaration + '\u0000' + row.stage,
|
|
1385
|
+
row,
|
|
1386
|
+
]),
|
|
1387
|
+
);
|
|
1388
|
+
settled = evidence.map(
|
|
1389
|
+
row => rows.get(row.declaration + '\u0000' + row.stage) ?? row,
|
|
1390
|
+
);
|
|
1391
|
+
found = [
|
|
1392
|
+
...diagnostics,
|
|
1393
|
+
...(checked.diagnostics ?? []).filter(row => row.code === 'refuted'),
|
|
1394
|
+
];
|
|
1395
|
+
for (const verdict of checked.analysisChecks ?? [])
|
|
1396
|
+
{
|
|
1397
|
+
const done = ran.get(verdict.fingerprint) ?? {};
|
|
1398
|
+
if (['proved', 'refuted', 'exempted'].includes(verdict.status))
|
|
1399
|
+
await saveQuery(done);
|
|
1400
|
+
solverEvidence.push({
|
|
1401
|
+
owner: verdict.owner,
|
|
1402
|
+
declaration: verdict.declaration,
|
|
1403
|
+
stage: verdict.stage,
|
|
1404
|
+
kind: 'analysis',
|
|
1405
|
+
encoding: 'lawspec-smtlib-v2',
|
|
1406
|
+
taskFingerprint: done.reused?.taskFingerprint ?? verdict.fingerprint,
|
|
1407
|
+
status: verdict.status,
|
|
1408
|
+
...(done.reused
|
|
1409
|
+
? {currentTaskFingerprint: verdict.fingerprint, reused: done.reused}
|
|
1410
|
+
: {}),
|
|
1411
|
+
outcome: done.outcome ?? 'failed',
|
|
1412
|
+
reason:
|
|
1413
|
+
verdict.reason +
|
|
1414
|
+
(done.reused
|
|
1415
|
+
? '; reused a completed query; model revalidated by the current evaluator'
|
|
1416
|
+
: ''),
|
|
1417
|
+
check: verdict.check,
|
|
1418
|
+
configuration: config,
|
|
1419
|
+
...(done.run
|
|
1420
|
+
? {
|
|
1421
|
+
prover: {
|
|
1422
|
+
name: 'z3',
|
|
1423
|
+
version: selected.version,
|
|
1424
|
+
binary: selected.binary,
|
|
1425
|
+
binaryFingerprint: selected.binaryFingerprint,
|
|
1426
|
+
fingerprint: selected.fingerprint,
|
|
1427
|
+
arguments: selected.args,
|
|
1428
|
+
},
|
|
1429
|
+
runFingerprint: done.runFingerprint,
|
|
1430
|
+
elapsedMs: done.run.elapsedMs,
|
|
1431
|
+
exitCode: done.run.exitCode,
|
|
1432
|
+
stdout: done.run.stdout,
|
|
1433
|
+
stderr: done.run.stderr,
|
|
1434
|
+
}
|
|
1435
|
+
: {}),
|
|
1436
|
+
});
|
|
505
1437
|
}
|
|
506
|
-
for(const [fingerprintOf,done] of ran)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
1438
|
+
for (const [fingerprintOf, done] of ran)
|
|
1439
|
+
if (
|
|
1440
|
+
done.error &&
|
|
1441
|
+
!(checked.analysisChecks ?? []).some(
|
|
1442
|
+
v => v.fingerprint === fingerprintOf,
|
|
1443
|
+
)
|
|
1444
|
+
)
|
|
1445
|
+
solverEvidence.push({
|
|
1446
|
+
kind: 'analysis',
|
|
1447
|
+
owner: done.row.owner,
|
|
1448
|
+
declaration: done.row.declaration,
|
|
1449
|
+
stage: done.row.stage,
|
|
1450
|
+
taskFingerprint: fingerprintOf,
|
|
1451
|
+
encoding: 'lawspec-smtlib-v2',
|
|
1452
|
+
status: 'incomplete',
|
|
1453
|
+
outcome: done.outcome,
|
|
1454
|
+
reason: done.error,
|
|
1455
|
+
configuration: config,
|
|
1456
|
+
});
|
|
510
1457
|
}
|
|
511
1458
|
// Model laws the compiler's own search left open: induction, Spacer (its
|
|
512
1459
|
// invariant goes back to the compiler, which asks for plain re-checks),
|
|
513
1460
|
// and a bounded run search the compiler replays. Rounds repeat while the
|
|
514
1461
|
// compiler asks for new tasks.
|
|
515
|
-
if(modelTasks.length&&selected.error)
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
1462
|
+
if (modelTasks.length && selected.error)
|
|
1463
|
+
{
|
|
1464
|
+
for (const law of modelTasks)
|
|
1465
|
+
for (const task of law.tasks)
|
|
1466
|
+
solverEvidence.push({
|
|
1467
|
+
kind: 'model',
|
|
1468
|
+
owner: law.owner,
|
|
1469
|
+
declaration: law.declaration,
|
|
1470
|
+
task: task.kind,
|
|
1471
|
+
taskFingerprint: task.fingerprint,
|
|
1472
|
+
encoding: 'lawspec-smtlib-v2',
|
|
1473
|
+
status: 'incomplete',
|
|
1474
|
+
outcome: selected.outcome,
|
|
1475
|
+
reason: selected.error,
|
|
1476
|
+
configuration: config,
|
|
1477
|
+
});
|
|
520
1478
|
}
|
|
521
|
-
if(modelTasks.length
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
1479
|
+
if (modelTasks.length && !selected.error)
|
|
1480
|
+
{
|
|
1481
|
+
const answered = new Map(),
|
|
1482
|
+
modelAnswers = [],
|
|
1483
|
+
modelRows = new Map(),
|
|
1484
|
+
runs = new Map();
|
|
1485
|
+
let pending = modelTasks;
|
|
1486
|
+
for (let round = 0; round < 4; round++)
|
|
1487
|
+
{
|
|
1488
|
+
let fresh = 0;
|
|
1489
|
+
for (const law of pending)
|
|
1490
|
+
for (const task of law.tasks)
|
|
1491
|
+
{
|
|
1492
|
+
if (answered.has(task.fingerprint)) continue;
|
|
1493
|
+
fresh++;
|
|
1494
|
+
const executeQuery = async () =>
|
|
1495
|
+
{
|
|
1496
|
+
const input =
|
|
1497
|
+
`(set-option :print-success false)\n(set-option :produce-models true)\n` +
|
|
1498
|
+
`(set-option :random-seed ${config.seed})\n(set-option :rlimit ${config.resourceLimit})\n` +
|
|
1499
|
+
task.script +
|
|
1500
|
+
'(check-sat)\n';
|
|
1501
|
+
const run = await execute(
|
|
1502
|
+
selected.binary,
|
|
1503
|
+
selected.args,
|
|
1504
|
+
input,
|
|
1505
|
+
config,
|
|
1506
|
+
true,
|
|
1507
|
+
token =>
|
|
1508
|
+
token !== 'sat'
|
|
1509
|
+
? '(exit)\n'
|
|
1510
|
+
: task.kind === 'spacer'
|
|
1511
|
+
? '(get-model)\n(exit)\n'
|
|
1512
|
+
: task.inputs.length
|
|
1513
|
+
? `(get-value (${task.inputs.join(' ')}))\n(exit)\n`
|
|
1514
|
+
: '(exit)\n',
|
|
1515
|
+
);
|
|
1516
|
+
const outcome = await verifiedOutcome(run, selected);
|
|
1517
|
+
const body =
|
|
1518
|
+
outcome === 'sat'
|
|
1519
|
+
? run.stdout.slice(run.stdout.indexOf('\n') + 1)
|
|
1520
|
+
: '';
|
|
1521
|
+
let invariant = '';
|
|
1522
|
+
if (task.kind === 'spacer' && outcome === 'sat')
|
|
1523
|
+
{
|
|
1524
|
+
const at = body.indexOf('(define-fun Inv ');
|
|
1525
|
+
if (at >= 0)
|
|
1526
|
+
{
|
|
1527
|
+
let depth = 0;
|
|
1528
|
+
for (let i = at; i < body.length; i++)
|
|
1529
|
+
{
|
|
1530
|
+
if (body[i] === '(') depth++;
|
|
1531
|
+
if (body[i] === ')')
|
|
1532
|
+
{
|
|
1533
|
+
depth--;
|
|
1534
|
+
if (depth === 0)
|
|
1535
|
+
{
|
|
1536
|
+
invariant = body.slice(at, i + 1);
|
|
1537
|
+
break;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
541
1543
|
|
|
542
|
-
|
|
543
|
-
|
|
1544
|
+
return {
|
|
1545
|
+
run,
|
|
1546
|
+
outcome,
|
|
1547
|
+
values: task.kind === 'spacer' ? '' : body.trim(),
|
|
1548
|
+
invariant,
|
|
1549
|
+
runFingerprint: fingerprint([
|
|
1550
|
+
task.fingerprint,
|
|
1551
|
+
selected.fingerprint,
|
|
1552
|
+
run.input,
|
|
1553
|
+
]),
|
|
1554
|
+
};
|
|
1555
|
+
};
|
|
1556
|
+
const row = {
|
|
1557
|
+
kind: 'model',
|
|
1558
|
+
owner: law.owner,
|
|
1559
|
+
declaration: law.declaration,
|
|
1560
|
+
stage: task.kind,
|
|
1561
|
+
};
|
|
1562
|
+
const done = await analysisQuery(
|
|
1563
|
+
cache,
|
|
1564
|
+
row,
|
|
1565
|
+
task,
|
|
1566
|
+
selected,
|
|
1567
|
+
executeQuery,
|
|
1568
|
+
);
|
|
1569
|
+
const answer = {
|
|
1570
|
+
fingerprint: task.fingerprint,
|
|
1571
|
+
outcome: done.outcome,
|
|
1572
|
+
values: done.values,
|
|
1573
|
+
invariant: done.invariant ?? '',
|
|
1574
|
+
inputs: done.inputs ?? task.inputs,
|
|
1575
|
+
};
|
|
1576
|
+
answered.set(task.fingerprint, answer);
|
|
1577
|
+
modelAnswers.push(answer);
|
|
1578
|
+
runs.set(task.fingerprint, {row, task, done});
|
|
1579
|
+
}
|
|
1580
|
+
if (!fresh) break;
|
|
1581
|
+
let checked = await compiler.proofTasks({
|
|
1582
|
+
...request,
|
|
1583
|
+
modelResults: modelAnswers,
|
|
1584
|
+
});
|
|
1585
|
+
let retry = false;
|
|
1586
|
+
for (const check of checked.modelChecks ?? [])
|
|
1587
|
+
{
|
|
1588
|
+
const observation = runs.get(check.fingerprint);
|
|
1589
|
+
if (
|
|
1590
|
+
check.status !== 'model-not-confirmed' ||
|
|
1591
|
+
!observation?.done.reused ||
|
|
1592
|
+
!observation.done.rerun
|
|
1593
|
+
)
|
|
1594
|
+
continue;
|
|
1595
|
+
await rm(observation.done.cacheFile, {force: true}).catch(() =>
|
|
1596
|
+
{});
|
|
1597
|
+
observation.done = await observation.done.rerun();
|
|
1598
|
+
const {task, done} = observation;
|
|
1599
|
+
const answer = {
|
|
1600
|
+
fingerprint: task.fingerprint,
|
|
1601
|
+
outcome: done.outcome,
|
|
1602
|
+
values: done.values,
|
|
1603
|
+
invariant: done.invariant ?? '',
|
|
1604
|
+
inputs: done.inputs ?? task.inputs,
|
|
544
1605
|
};
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
let checked=await compiler.proofTasks({...request,modelResults:modelAnswers});
|
|
553
|
-
let retry=false;
|
|
554
|
-
for(const check of checked.modelChecks??[]){
|
|
555
|
-
const observation=runs.get(check.fingerprint);
|
|
556
|
-
if(check.status!=='model-not-confirmed'||!observation?.done.reused||!observation.done.rerun)continue;
|
|
557
|
-
await rm(observation.done.cacheFile,{force:true}).catch(()=>{});
|
|
558
|
-
observation.done=await observation.done.rerun();
|
|
559
|
-
const {task,done}=observation;
|
|
560
|
-
const answer={fingerprint:task.fingerprint,outcome:done.outcome,values:done.values,
|
|
561
|
-
invariant:done.invariant??'',inputs:done.inputs??task.inputs};
|
|
562
|
-
answered.set(task.fingerprint,answer);
|
|
563
|
-
modelAnswers[modelAnswers.findIndex(value=>value.fingerprint===task.fingerprint)]=answer;
|
|
564
|
-
retry=true;
|
|
1606
|
+
answered.set(task.fingerprint, answer);
|
|
1607
|
+
modelAnswers[
|
|
1608
|
+
modelAnswers.findIndex(
|
|
1609
|
+
value => value.fingerprint === task.fingerprint,
|
|
1610
|
+
)
|
|
1611
|
+
] = answer;
|
|
1612
|
+
retry = true;
|
|
565
1613
|
}
|
|
566
|
-
if(retry)
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
1614
|
+
if (retry)
|
|
1615
|
+
checked = await compiler.proofTasks({
|
|
1616
|
+
...request,
|
|
1617
|
+
modelResults: modelAnswers,
|
|
1618
|
+
});
|
|
1619
|
+
for (const row of checked.modelEvidence ?? [])
|
|
1620
|
+
modelRows.set(row.declaration, row);
|
|
1621
|
+
for (const d of checked.diagnostics ?? [])
|
|
1622
|
+
if (d.code === 'refuted' && !found.some(e => e.message === d.message))
|
|
1623
|
+
found = [...found, d];
|
|
1624
|
+
pending = checked.modelTasks ?? [];
|
|
570
1625
|
}
|
|
571
|
-
for(const {row,task,done} of runs.values())
|
|
1626
|
+
for (const {row, task, done} of runs.values())
|
|
1627
|
+
{
|
|
572
1628
|
// Current model settlement still checks every proof/replay obligation.
|
|
573
1629
|
// A reused raw query never substitutes for that compiler decision.
|
|
574
|
-
if
|
|
1630
|
+
if (
|
|
1631
|
+
task.kind !== 'bounded search' ||
|
|
1632
|
+
done.outcome !== 'sat' ||
|
|
1633
|
+
modelRows.get(row.declaration)?.status === 'refuted'
|
|
1634
|
+
)
|
|
575
1635
|
await saveQuery(done);
|
|
576
|
-
const run=done.run,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
1636
|
+
const run = done.run,
|
|
1637
|
+
outcome = done.outcome;
|
|
1638
|
+
solverEvidence.push({
|
|
1639
|
+
kind: 'model',
|
|
1640
|
+
owner: row.owner,
|
|
1641
|
+
declaration: row.declaration,
|
|
1642
|
+
task: task.kind,
|
|
1643
|
+
taskFingerprint: done.reused?.taskFingerprint ?? task.fingerprint,
|
|
1644
|
+
...(done.reused
|
|
1645
|
+
? {currentTaskFingerprint: task.fingerprint, reused: done.reused}
|
|
1646
|
+
: {}),
|
|
1647
|
+
encoding: 'lawspec-smtlib-v2',
|
|
1648
|
+
status: outcome === 'unsat' ? 'proved' : 'incomplete',
|
|
1649
|
+
outcome,
|
|
1650
|
+
reason:
|
|
1651
|
+
task.kind +
|
|
1652
|
+
': ' +
|
|
1653
|
+
outcome +
|
|
1654
|
+
(done.reused
|
|
1655
|
+
? '; reused original solver query; current compiler rechecks the model evidence'
|
|
1656
|
+
: ''),
|
|
1657
|
+
prover: {
|
|
1658
|
+
name: 'z3',
|
|
1659
|
+
version: selected.version,
|
|
1660
|
+
binary: selected.binary,
|
|
1661
|
+
binaryFingerprint: selected.binaryFingerprint,
|
|
1662
|
+
fingerprint: selected.fingerprint,
|
|
1663
|
+
arguments: selected.args,
|
|
1664
|
+
},
|
|
1665
|
+
runFingerprint: done.runFingerprint,
|
|
1666
|
+
elapsedMs: run.elapsedMs,
|
|
1667
|
+
exitCode: run.exitCode,
|
|
1668
|
+
signal: run.signal,
|
|
1669
|
+
stdout: run.stdout,
|
|
1670
|
+
stderr: run.stderr,
|
|
1671
|
+
configuration: config,
|
|
1672
|
+
});
|
|
586
1673
|
}
|
|
587
|
-
settled=settled.map(row=>
|
|
1674
|
+
settled = settled.map(row =>
|
|
1675
|
+
row.stage === 'law' && modelRows.has(row.declaration)
|
|
1676
|
+
? {...row, ...modelRows.get(row.declaration)}
|
|
1677
|
+
: row,
|
|
1678
|
+
);
|
|
588
1679
|
}
|
|
589
|
-
return {...result,diagnostics:found,evidence:settled,solverEvidence};
|
|
1680
|
+
return {...result, diagnostics: found, evidence: settled, solverEvidence};
|
|
590
1681
|
}
|