diff --git a/.github/lexlean-revision b/.github/lexlean-revision index 016afb7..f165d70 100644 --- a/.github/lexlean-revision +++ b/.github/lexlean-revision @@ -1 +1 @@ -b0e40add3b573a7040d27a6dd67858db89838199 +15c667bd36604c94c28e39502edec3fcad38e0ce diff --git a/AGENTS.md b/AGENTS.md index c309713..6a38fce 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -120,6 +120,11 @@ converter (`rule30-api/src/Convert.lex.tex`), the engine's learning rule and sch (`Engine.lex.tex`), the relation and recurrence engines (`Discovery.lex.tex`), all with certified rust-std roots. +The tool supervisor reads the monotonic host clock before spawning. Spawn replies +carry a process ID, which is never used as time; spawn latency counts against +the job budget. Normal completion releases direct-child ownership, while failed +cleanup retains it. + The research execution modules are authored directly in LexLean: `ResearchExecution` supervises one local tool through `LexLeanStd.Host`, and `ResearchRunner` connects its lifecycle to `Research`. A process exit is not a @@ -134,8 +139,9 @@ answers; submit constructed candidates through `Event.candidate`. `ResearchCandidate` owns the local `lexlean snapshot` process and output read, reconstructs the full compiler IR with `CompilerSnapshot`, derives verification pins and preflights the exact goal before entering `ResearchProof`. Snapshot -metadata is not a proof. Its caller still owns candidate term selection, the -isolated project and imported library snapshot. `Event.proof` remains the +metadata is not a proof. Its caller selects candidate terms. `ResearchSession` and `ResearchProject` +own its isolated project; `ResearchWorkspace` checks out and builds the exact +requested library tree at a pinned Git revision. `Event.proof` remains the internal typed entry for already-owned candidate data. The binding schema distinguishes inspected premises from named closed propositions. For premises it encodes the source type and closed target as core arenas; source inspection must establish their origin and snapshot before dispatch. Closed goals @@ -144,12 +150,32 @@ have no telescope and designate the exact registered source constant. LexLean 1.2 notation. Its output remains a candidate until owned verification succeeds. Its fixed module prefix is `Rule30Candidate`, module `Candidate`, theorem `proof`. -The caller owns the isolated project and imported library; exact name matching -does not establish the identity of an arbitrary imported environment. +`ResearchSession` owns preparation, verification, evidence retention and release. +Its only events are host replies and cancellation. `ResearchRecord` captures the +exact inputs and report reads; `ResearchEvidence` retains both the library commit +and canonical proof record under verified Git references before workspace removal. +Only then can the session return a checked answer. A stored record itself confers +no proof authority. Failed archival or cleanup retains the workspace. Stopped or +signalled tools also retain it: direct-child cleanup does not establish that all +descendants have terminated. Exact name matching alone does not establish the +identity of an arbitrary imported environment. Maintenance reports have a separate result kind. Cancellation consumes the outstanding host reply before issuing stop; failed cleanup retains ownership -and halts dispatch. Native application wiring, source inspection, strategy planner and -publication path still need completion; these modules do not replace the +and halts dispatch. `ResearchCommand.step` now provides the native Host executable for one structured +attempt. `ResearchInput` admits the complete `r30/research-attempt/1` request; +`r30/research-result/1` output carries the session outcome and evidence identity. +The command accepts no receipt, selects no strategy, and publishes no claim. +`ResearchCohortCommand.step` runs at most 64 supplied candidates sequentially +against one owned library. `ResearchCohortInput` checks shared configuration and +distinct serials before effects. Borrowed projects retain individual request and +evidence identities; only the cohort releases the shared library. Tracked sources +are rechecked between attempts. Ordinary candidate failure permits continuation; +uncertain execution retains the library and stops the cohort. Its +`r30/research-cohort-result/1` report preserves individual outcomes, and exit 0 +requires all checked results and no cancellation. Cohort execution is bounded +reuse, not durable recovery or automatic strategy selection. +Source inspection, strategy scheduling, durable failure diagnostics, recovery, +and claim publication still need completion; these modules do not replace the legacy engine yet. Add every new application or library module and its modeled features to `ResearchCatalog`, and add behavioral evidence for the capability; a module-count theorem alone does not establish feature completeness. diff --git a/README.md b/README.md index 200a4fa..46bdb49 100644 --- a/README.md +++ b/README.md @@ -332,14 +332,23 @@ UTF-8 chunk, parser-state and SHA-256 block facts keep the complete report acceptance proof compositional; lifecycle traces reuse that checked receipt and verify rejection, cancellation, ownership and terminal behavior. +The tool supervisor reads the monotonic host clock before spawning. Spawn replies +carry a process ID, which is never used as time; spawn latency counts against +the job budget. Normal completion releases direct-child ownership, while failed +cleanup retains it. + `rule30-api/production/research-request.json` exports the research controller, -catalog initializer, and runner `begin`/`step` component libraries. +catalog initializer, candidate source constructor and runner component libraries, +plus the native `ResearchCommand.step` and `ResearchCohortCommand.step` executables. +Session operations remain executable internal components; their behavior is +certified through these command roots without duplicate standalone exports. `CandidateSource.construct` emits one unverified `.lex.tex` native-core theorem for the selected goal, with explicit imports, universe parameters and an exact axiom policy. It uses native LexLean 1.2 notation and a fixed candidate theorem name; the local compiler checks the proposed term. The output budget includes -the complete document. The caller still owns the isolated project and file writes. +the complete document. `ResearchProject` supplies an isolated project and owns +its source writes, fixed manifests, pinned toolchain and locally generated lock. Closed goals and conditional premises have separate request identities. For the six open claims with defined propositions, the catalog constructs the @@ -347,10 +356,62 @@ canonical named goal, including the prize kit's `Problem1`; mismatched register metadata blocks the task without changing its target. A closed proof has no extra assumptions, and a closed refutation must prove that exact proposition implies `False`. Dependency changes reopen the same goal for verification. -This binding relies on the caller's ownership of the pinned imported library; -a matching constant name alone does not establish that library's identity. - -Native application wiring, source inspection into the binding schema, -strategy search, owned candidate workspaces and durable publication are still required for -the new runner to replace the legacy engine. CI and runtime -use deterministic local tools and no remote models. +`ResearchWorkspace` checks out a fresh detached worktree at a full revision, +compares its tree with the requested library snapshot, builds the retained +library, and checks tracked sources again before making the workspace ready. + +`ResearchSession` owns one candidate attempt through preparation, snapshot, +verification, evidence retention and release. It captures the exact report +reads consumed by verification. `ResearchRecord` retains the request, source, +project inputs, linked IR, lexicon closure, tool identities and reports. +`ResearchEvidence` stores canonical evidence in Git, retains the library commit +under `refs/r30/libraries/`, and checks both the library reference and +`refs/r30/evidence/` before completion. Existing identical references +are idempotent. A record is replay input; reading it grants no proof authority. +A standalone checked answer is delivered only after retention and workspace removal. +Failed archival, failed cleanup, or interrupted tools retain the workspace for +recovery. Direct-child cleanup does not establish that tool descendants have +stopped. Cancellation drains outstanding replies and suppresses checked results. + +`ResearchCommand.step` is the native Host entry for one owned attempt. The generated +`rule30_research_command` executable accepts one request file (or `--help`). +`ResearchInput` admits the exact `r30/research-attempt/1` JSON schema: the complete +controller request, repository and full revision, output/error paths, four tool +digests, core arena and proof node, imports, universe levels, axioms, and bounds. +The task must be ready and its prove/refute intent must agree with its purpose. +The snapshot carries the library tree and compiler/model digests. Admission +checks JSON shape and budgets; it grants no premise provenance or proof authority. +The process environment is supplied by the native Host. Paths and environment +values must use printable ASCII for lossless conversion by the current adapter; +log parent directories must already exist. The input parser admits at most 8 MiB; +the underlying Host file read itself is not size-limited. + +The command drives the session through actual Host replies and emits +`r30/research-result/1` JSON. Exit 0 means a checked answer with retained evidence +and completed workspace removal; nonzero attempt outcomes carry their status, +and blocked operations include the retained workspace location. Optional evidence +and recovery paths use an empty string when absent, so output remains compatible +with the project's canonical JSON profile. Input errors +exit 2 and host protocol errors exit 70. Receipt injection and restarting a +terminal command are rejected. The command does not select a proof strategy or +publish a claim. Source inspection into the binding schema, strategy scheduling, +durable failure diagnostics, recovery, and publication into the claim register +remain required for the new components to replace the legacy engine. + +`ResearchCohortCommand.step` provides the `rule30_research_cohort` executable for +up to 64 sequential attempts sharing one prepared library. Its input is +`{"spec":"r30/research-cohort/1","first":,"rest":[,...]}`; +each attempt uses the complete schema above. All attempts must share the library, +tool identities, environment, logs and workspace execution bounds, and must have +distinct serials. Each keeps its own candidate request, project directory and +proof evidence. The first request owns the library; subsequent requests borrow +it. Tracked library sources are checked again between attempts without rebuilding. + +An ordinary failed candidate permits the next attempt. Interrupted or uncertain +operations stop the cohort and retain its library for recovery. Borrowed sessions +return retained evidence without removing the shared library; the cohort removes +it once all attempts finish. `r30/research-cohort-result/1` reports every completed +attempt separately. A completed cohort can contain failed candidates: exit 0 +requires every result to be checked, with no cancellation. This bounded executor +does not add automatic candidate generation or durable restart recovery. +CI and runtime use deterministic local tools and no remote models. diff --git a/Rule30-Core.pdf b/Rule30-Core.pdf index 05556d5..11a6f96 100644 Binary files a/Rule30-Core.pdf and b/Rule30-Core.pdf differ diff --git a/Rule30-Observations.pdf b/Rule30-Observations.pdf index 2d97ad6..cf04926 100644 Binary files a/Rule30-Observations.pdf and b/Rule30-Observations.pdf differ diff --git a/Rule30-Paper.pdf b/Rule30-Paper.pdf index 809763d..570bb31 100644 Binary files a/Rule30-Paper.pdf and b/Rule30-Paper.pdf differ diff --git a/pdf-manifest.json b/pdf-manifest.json index 87edf44..ce911b6 100644 --- a/pdf-manifest.json +++ b/pdf-manifest.json @@ -1,18 +1,18 @@ { "documents": { "Core": { - "pdf_sha256": "f18f351d340e4dc248ab46461e4497ae0807d913210120d6ed7bc182f3be74d4", + "pdf_sha256": "7edc0ca14d99f2a38fdd2aca0cbb3fc49e722d0ade2438054262dcf6b791814b", "tex_sha256": "a7cd1807077baa1d1ca34015faf500a24477991859427f4db646e5f230fe54e2" }, "Observations": { - "pdf_sha256": "d03f8f3471ba0bc5e5bd39679375e59cadc5922f809a02b6e3db92cd1d907a51", + "pdf_sha256": "546ece7c7940dff740a3c363fa0b4a97f5039f004778419782592dbd49990ecc", "tex_sha256": "056820f37ac40133e341f46ad6c81125e35981150a1cc86f2063faad3f26fbd4" }, "Paper": { - "pdf_sha256": "dbe005b9305b8d6d1a10bc12710a11212dc6ca06d62bf321bb9aeda69613a6b5", + "pdf_sha256": "7b26ea7d21633bcd1558fb9f1aebb05fefe7b69fdd5e9751c54c01027c8aec36", "tex_sha256": "000f988561d9621f9ba2f9a99aba971670864367ebd336e6fbad0e1f71da01cb" } }, - "generated_at_utc": "2026-11-05T03:37:21.903592+00:00", - "source_digest": "ca394c3b6671e1ffbbdc80adc372e8899b19c0762086391e6bf07dc9d356ec86" + "generated_at_utc": "2026-11-10T08:55:13.323604+00:00", + "source_digest": "f6d01f309566246abfbb67955c780d59384720b6cf13e064cf74654dc0eb4121" } diff --git a/rule30-api/lexlean.lock b/rule30-api/lexlean.lock index 762d4ad..08be2ea 100644 --- a/rule30-api/lexlean.lock +++ b/rule30-api/lexlean.lock @@ -1,7 +1,7 @@ spec = "lexlean/lock/2" language = "1.2" -compiler_semantics = "b9816b388a3eb1800179f96aa9bc789620a46d7a7132f1b52ee9fa404c2092f7" -project_config_sha256 = "14a4245f2aaeec6585ffd57636e5858abf4e2a3e9ecd172c1b35abdff858513c" +compiler_semantics = "601e9f4a1824bb6aacf7c3c2243d4b33aaa315abdebd5ceaf920d178e196019e" +project_config_sha256 = "eff28cd4fd2d3f9d355c0b525998776e84859ebac586ac3704e2598b8ec8a495" lean_toolchain = "leanprover/lean4:v4.32.1" [[workspace_file]] diff --git a/rule30-api/lexlean.toml b/rule30-api/lexlean.toml index fab9887..9cb7dd0 100644 --- a/rule30-api/lexlean.toml +++ b/rule30-api/lexlean.toml @@ -3,7 +3,7 @@ name = "rule30-api" language = "1.2" module_prefix = "Rule30Api" source_roots = ["src", "stdlib"] -entrypoints = ["src/Api.lex.tex", "src/Application.lex.tex", "src/Architecture.lex.tex", "src/ArtifactIdentity.lex.tex", "src/ArtifactIdentityTraces.lex.tex", "src/Audit.lex.tex", "src/BindingFixture.lex.tex", "src/CandidateBinding.lex.tex", "src/CandidateBindingTraces.lex.tex", "src/CandidateSource.lex.tex", "src/CandidateSourceTraces.lex.tex", "src/ClosedBindingFixture.lex.tex", "src/ClosedGoalTraces.lex.tex", "src/CompilerSnapshot.lex.tex", "src/CompilerSnapshotTraces.lex.tex", "src/Convert.lex.tex", "src/CoreBinding.lex.tex", "src/CoreBindingTraces.lex.tex", "src/CoreNotation.lex.tex", "src/CoreNotationTraces.lex.tex", "src/Discovery.lex.tex", "src/Engine.lex.tex", "src/Host.lex.tex", "src/Hypotheses.lex.tex", "src/Json.lex.tex", "src/JsonCanonical.lex.tex", "src/JsonCanonicalTraces.lex.tex", "src/JsonTraces.lex.tex", "src/Observer.lex.tex", "src/Presentation.lex.tex", "src/R30.lex.tex", "src/R30Traces.lex.tex", "src/R30TracesClaims.lex.tex", "src/R30TracesForms.lex.tex", "src/R30TracesRegister.lex.tex", "src/Register.lex.tex", "src/Research.lex.tex", "src/ResearchCandidate.lex.tex", "src/ResearchCandidateTraces.lex.tex", "src/ResearchCatalog.lex.tex", "src/ResearchExecution.lex.tex", "src/ResearchExecutionTraces.lex.tex", "src/ResearchProof.lex.tex", "src/ResearchProofTraces.lex.tex", "src/ResearchRunner.lex.tex", "src/ResearchRunnerTraces.lex.tex", "src/ResearchTraces.lex.tex", "src/ResearchVerification.lex.tex", "src/ResearchVerificationTraces.lex.tex", "src/Rule30Core.lex.tex", "src/Sequences.lex.tex", "src/Standards.lex.tex", "src/Toml.lex.tex", "src/VerificationCommandFixtures.lex.tex", "src/VerificationHashFixtures.lex.tex", "src/VerificationJsonData.lex.tex", "src/VerificationJsonFixtures.lex.tex", "src/VerificationJsonSteps0.lex.tex", "src/VerificationJsonSteps1.lex.tex", "src/VerificationJsonSteps2.lex.tex", "src/VerificationJsonSteps3.lex.tex", "src/VerificationReport.lex.tex", "src/VerificationReportTraces.lex.tex", "src/VerificationUtf8Fixtures.lex.tex"] +entrypoints = ["src/Api.lex.tex", "src/Application.lex.tex", "src/Architecture.lex.tex", "src/ArtifactIdentity.lex.tex", "src/ArtifactIdentityTraces.lex.tex", "src/Audit.lex.tex", "src/BindingFixture.lex.tex", "src/CandidateBinding.lex.tex", "src/CandidateBindingTraces.lex.tex", "src/CandidateSource.lex.tex", "src/CandidateSourceTraces.lex.tex", "src/ClosedBindingFixture.lex.tex", "src/ClosedGoalTraces.lex.tex", "src/CompilerSnapshot.lex.tex", "src/CompilerSnapshotTraces.lex.tex", "src/Convert.lex.tex", "src/CoreBinding.lex.tex", "src/CoreBindingTraces.lex.tex", "src/CoreNotation.lex.tex", "src/CoreNotationTraces.lex.tex", "src/Discovery.lex.tex", "src/Engine.lex.tex", "src/Host.lex.tex", "src/Hypotheses.lex.tex", "src/Json.lex.tex", "src/JsonCanonical.lex.tex", "src/JsonCanonicalTraces.lex.tex", "src/JsonTraces.lex.tex", "src/Observer.lex.tex", "src/Presentation.lex.tex", "src/R30.lex.tex", "src/R30Traces.lex.tex", "src/R30TracesClaims.lex.tex", "src/R30TracesForms.lex.tex", "src/R30TracesRegister.lex.tex", "src/Register.lex.tex", "src/Research.lex.tex", "src/ResearchCandidate.lex.tex", "src/ResearchCandidateTraces.lex.tex", "src/ResearchCatalog.lex.tex", "src/ResearchCohort.lex.tex", "src/ResearchCohortCommand.lex.tex", "src/ResearchCohortInput.lex.tex", "src/ResearchCohortTraces.lex.tex", "src/ResearchCommand.lex.tex", "src/ResearchCommandTraces.lex.tex", "src/ResearchEvidence.lex.tex", "src/ResearchEvidenceTraces.lex.tex", "src/ResearchExecution.lex.tex", "src/ResearchExecutionTraces.lex.tex", "src/ResearchInput.lex.tex", "src/ResearchInputTraces.lex.tex", "src/ResearchProject.lex.tex", "src/ResearchProjectTraces.lex.tex", "src/ResearchProof.lex.tex", "src/ResearchProofTraces.lex.tex", "src/ResearchRecord.lex.tex", "src/ResearchRunner.lex.tex", "src/ResearchRunnerTraces.lex.tex", "src/ResearchSession.lex.tex", "src/ResearchSessionTraces.lex.tex", "src/ResearchTraces.lex.tex", "src/ResearchVerification.lex.tex", "src/ResearchVerificationTraces.lex.tex", "src/ResearchWorkspace.lex.tex", "src/ResearchWorkspaceTraces.lex.tex", "src/Rule30Core.lex.tex", "src/Sequences.lex.tex", "src/Standards.lex.tex", "src/Toml.lex.tex", "src/VerificationCommandFixtures.lex.tex", "src/VerificationHashFixtures.lex.tex", "src/VerificationJsonData.lex.tex", "src/VerificationJsonFixtures.lex.tex", "src/VerificationJsonSteps0.lex.tex", "src/VerificationJsonSteps1.lex.tex", "src/VerificationJsonSteps2.lex.tex", "src/VerificationJsonSteps3.lex.tex", "src/VerificationReport.lex.tex", "src/VerificationReportTraces.lex.tex", "src/VerificationUtf8Fixtures.lex.tex"] build_root = ".lexlean" lockfile = "lexlean.lock" lean_workspace = "." @@ -34,8 +34,8 @@ kind = "path" path = "lexlean-stdlib" [limits] -max_file_bytes = 8388608 -max_total_source_bytes = 67108864 +max_file_bytes = 16777216 +max_total_source_bytes = 100663296 max_primitive_atoms = 2000000 max_token_lattice_edges = 4000000 max_parse_states = 4000000 diff --git a/rule30-api/model/dependencies.toml b/rule30-api/model/dependencies.toml index 46fcc17..d6403c8 100644 --- a/rule30-api/model/dependencies.toml +++ b/rule30-api/model/dependencies.toml @@ -4,7 +4,7 @@ spec = "prismpm/dependencies/1" id = "lexlean" version = "0.4.0" language = "1.2" -revision = "b9816b388a3eb1800179f96aa9bc789620a46d7a7132f1b52ee9fa404c2092f7" +revision = "601e9f4a1824bb6aacf7c3c2243d4b33aaa315abdebd5ceaf920d178e196019e" source = "pinned-binary" role = "compiler" path = ".local/bin/lexlean" diff --git a/rule30-api/model/standards.toml b/rule30-api/model/standards.toml index a6cec7c..3c8412f 100644 --- a/rule30-api/model/standards.toml +++ b/rule30-api/model/standards.toml @@ -261,7 +261,7 @@ release_scope = true id = "lexlean" name = "UOR-Foundation/LexLean (closed-lexicon LaTeX to Lean 4)" authority = "https://github.com/UOR-Foundation/LexLean" -version = "0.4.0, language 1.2, compiler semantics b9816b388a3e" +version = "0.4.0, language 1.2, compiler semantics 601e9f4a1824" scope = "The authoring surface: the paper, the register and these API modules are LexLean modules verified by lexlean; the production roots export to certified Rust." realized_by = ["Api", "Register", "Architecture", "Presentation", "Application", "Observer", "Convert", "Standards", "Rule30Core", "Sequences", "Discovery", "verify", "check", "api_sync", "api_check", "api_production"] conformance = "bin/r30 verify api; bin/r30 check api; bin/r30 api check" diff --git a/rule30-api/production/research-request.json b/rule30-api/production/research-request.json index 82c5101..35418e8 100644 --- a/rule30-api/production/research-request.json +++ b/rule30-api/production/research-request.json @@ -29,6 +29,16 @@ "package": {"name": "rule30_candidate_source", "version": "0.1.0"}, "root": "Rule30Api.CandidateSource.construct", "targets": [{"digest": "0f5802ea18121b6a7a0d03e999589ce4e5ae812dc2a358432c1bf024a8e53f9f", "id": "rust-std"}] + }, + { + "package": {"name": "rule30_research_command", "version": "0.1.0"}, + "root": "Rule30Api.ResearchCommand.step", + "targets": [{"digest": "0f5802ea18121b6a7a0d03e999589ce4e5ae812dc2a358432c1bf024a8e53f9f", "id": "rust-std"}] + }, + { + "package": {"name": "rule30_research_cohort", "version": "0.1.0"}, + "root": "Rule30Api.ResearchCohortCommand.step", + "targets": [{"digest": "0f5802ea18121b6a7a0d03e999589ce4e5ae812dc2a358432c1bf024a8e53f9f", "id": "rust-std"}] } ], "spec": "lexlean/production-request/1" diff --git a/rule30-api/src/ResearchCandidateTraces.lex.tex b/rule30-api/src/ResearchCandidateTraces.lex.tex index 409d079..44b1cea 100644 --- a/rule30-api/src/ResearchCandidateTraces.lex.tex +++ b/rule30-api/src/ResearchCandidateTraces.lex.tex @@ -31,8 +31,8 @@ name: began, parameters: [], result: (ResearchCandidate::State * ResearchProof::Emission), - body: (ResearchCandidate::begin (context (ResearchVerificationTraces::settings))), - axioms: [propext] + body: (ResearchCandidate::step (first (ResearchCandidate::begin (context (ResearchVerificationTraces::settings)))) (ctor ResearchVerification::Event.host (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))), + axioms: [Quot.sound, propext] } definition{ @@ -230,7 +230,7 @@ name: runnerStarted, parameters: [], result: (ResearchRunner::State * ResearchRunner::Action), - body: (ResearchRunner::step (first (ResearchRunner::begin (research))) (ctor ResearchRunner::Event.candidate (context (ResearchVerificationTraces::settings)))), + body: (ResearchRunner::step (first (ResearchRunner::step (first (ResearchRunner::begin (research))) (ctor ResearchRunner::Event.candidate (context (ResearchVerificationTraces::settings))))) (ctor ResearchRunner::Event.host (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))), axioms: [Quot.sound, propext] } diff --git a/rule30-api/src/ResearchCatalog.lex.tex b/rule30-api/src/ResearchCatalog.lex.tex index b026c52..186774c 100644 --- a/rule30-api/src/ResearchCatalog.lex.tex +++ b/rule30-api/src/ResearchCatalog.lex.tex @@ -24,6 +24,17 @@ \importmodule{CandidateBinding} \importmodule{VerificationReport} \importmodule{ResearchVerification} +\importmodule{ResearchWorkspace} +\importmodule{ResearchEvidence} +\importmodule{ResearchProject} +\importmodule{ResearchRecord} +\importmodule{ResearchSession} +\importmodule{ResearchInput} +\importmodule{ResearchCommand} +\importmodule{ResearchCohort} +\importmodule{ResearchCohortInput} +\importmodule{ResearchCohortCommand} +\importmodule{ResearchExecution} \title{Boolean} \begin{semanticmodule} structure{ @@ -44,7 +55,7 @@ name: moduleScopes, parameters: [], result: (List Scope), - body: (cons (unitScope 0x6d6f64756c652f436f72654e6f746174696f6e547261636573 "CoreNotationTraces") (cons (unitScope 0x6d6f64756c652f436f72654e6f746174696f6e "CoreNotation") (cons (unitScope 0x6d6f64756c652f43616e646964617465536f75726365 "CandidateSource") (cons (unitScope 0x6d6f64756c652f43616e646964617465536f75726365547261636573 "CandidateSourceTraces") (cons (unitScope 0x6d6f64756c652f436c6f736564476f616c547261636573 "ClosedGoalTraces") (cons (unitScope 0x6d6f64756c652f436c6f73656442696e64696e6746697874757265 "ClosedBindingFixture") (cons (unitScope 0x6d6f64756c652f436f6d70696c6572536e617073686f74 "CompilerSnapshot") (cons (unitScope 0x6d6f64756c652f436f6d70696c6572536e617073686f74547261636573 "CompilerSnapshotTraces") (cons (unitScope 0x6d6f64756c652f526573656172636843616e646964617465 "ResearchCandidate") (cons (unitScope 0x6d6f64756c652f526573656172636843616e646964617465547261636573 "ResearchCandidateTraces") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66547261636573 "ResearchProofTraces") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67547261636573 "CandidateBindingTraces") (cons (unitScope 0x6d6f64756c652f42696e64696e6746697874757265 "BindingFixture") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66 "ResearchProof") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67 "CandidateBinding") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479547261636573 "ArtifactIdentityTraces") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479 "ArtifactIdentity") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67547261636573 "CoreBindingTraces") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67 "CoreBinding") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c547261636573 "JsonCanonicalTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c "JsonCanonical") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e557466384669787475726573 "VerificationUtf8Fixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e436f6d6d616e644669787475726573 "VerificationCommandFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e44617461 "VerificationJsonData") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707330 "VerificationJsonSteps0") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707331 "VerificationJsonSteps1") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707332 "VerificationJsonSteps2") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707333 "VerificationJsonSteps3") (cons (unitScope 0x6d6f64756c652f417069 "Api") (cons (unitScope 0x6d6f64756c652f4170706c69636174696f6e "Application") (cons (unitScope 0x6d6f64756c652f417263686974656374757265 "Architecture") (cons (unitScope 0x6d6f64756c652f4175646974 "Audit") (cons (unitScope 0x6d6f64756c652f436f6e76657274 "Convert") (cons (unitScope 0x6d6f64756c652f446973636f76657279 "Discovery") (cons (unitScope 0x6d6f64756c652f456e67696e65 "Engine") (cons (unitScope 0x6d6f64756c652f486f7374 "Host") (cons (unitScope 0x6d6f64756c652f4879706f746865736573 "Hypotheses") (cons (unitScope 0x6d6f64756c652f4f62736572766572 "Observer") (cons (unitScope 0x6d6f64756c652f50726573656e746174696f6e "Presentation") (cons (unitScope 0x6d6f64756c652f523330 "R30") (cons (unitScope 0x6d6f64756c652f523330547261636573 "R30Traces") (cons (unitScope 0x6d6f64756c652f523330547261636573436c61696d73 "R30TracesClaims") (cons (unitScope 0x6d6f64756c652f523330547261636573466f726d73 "R30TracesForms") (cons (unitScope 0x6d6f64756c652f5233305472616365735265676973746572 "R30TracesRegister") (cons (unitScope 0x6d6f64756c652f5265676973746572 "Register") (cons (unitScope 0x6d6f64756c652f5265736561726368 "Research") (cons (unitScope 0x6d6f64756c652f5265736561726368436174616c6f67 "ResearchCatalog") (cons (unitScope 0x6d6f64756c652f5265736561726368547261636573 "ResearchTraces") (cons (unitScope 0x6d6f64756c652f52756c653330436f7265 "Rule30Core") (cons (unitScope 0x6d6f64756c652f53657175656e636573 "Sequences") (cons (unitScope 0x6d6f64756c652f5374616e6461726473 "Standards") (cons (unitScope 0x6d6f64756c652f546f6d6c "Toml") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e41726368 "Foundation.Arch") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e5175616c "Foundation.Qual") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e427566666572 "LexLeanStd.Buffer") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e54657874 "LexLeanStd.Text") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e536861323536 "LexLeanStd.Sha256") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e486f7374 "LexLeanStd.Host") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e "ResearchExecution") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e547261636573 "ResearchExecutionTraces") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572 "ResearchRunner") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572547261636573 "ResearchRunnerTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e "Json") (cons (unitScope 0x6d6f64756c652f4a736f6e547261636573 "JsonTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274 "VerificationReport") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274547261636573 "VerificationReportTraces") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e "ResearchVerification") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e547261636573 "ResearchVerificationTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e4669787475726573 "VerificationJsonFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e486173684669787475726573 "VerificationHashFixtures") (nil Scope))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))), + body: (cons (unitScope 0x6d6f64756c652f5265736561726368436f686f7274436f6d6d616e64 "ResearchCohortCommand") (cons (unitScope 0x6d6f64756c652f5265736561726368436f686f7274496e707574 "ResearchCohortInput") (cons (unitScope 0x6d6f64756c652f5265736561726368436f686f7274547261636573 "ResearchCohortTraces") (cons (unitScope 0x6d6f64756c652f5265736561726368436f686f7274 "ResearchCohort") (cons (unitScope 0x6d6f64756c652f5265736561726368496e707574 "ResearchInput") (cons (unitScope 0x6d6f64756c652f5265736561726368496e707574547261636573 "ResearchInputTraces") (cons (unitScope 0x6d6f64756c652f5265736561726368436f6d6d616e64 "ResearchCommand") (cons (unitScope 0x6d6f64756c652f5265736561726368436f6d6d616e64547261636573 "ResearchCommandTraces") (cons (unitScope 0x6d6f64756c652f5265736561726368576f726b7370616365 "ResearchWorkspace") (cons (unitScope 0x6d6f64756c652f5265736561726368576f726b7370616365547261636573 "ResearchWorkspaceTraces") (cons (unitScope 0x6d6f64756c652f526573656172636845766964656e6365 "ResearchEvidence") (cons (unitScope 0x6d6f64756c652f526573656172636845766964656e6365547261636573 "ResearchEvidenceTraces") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6a656374 "ResearchProject") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6a656374547261636573 "ResearchProjectTraces") (cons (unitScope 0x6d6f64756c652f52657365617263685265636f7264 "ResearchRecord") (cons (unitScope 0x6d6f64756c652f526573656172636853657373696f6e "ResearchSession") (cons (unitScope 0x6d6f64756c652f526573656172636853657373696f6e547261636573 "ResearchSessionTraces") (cons (unitScope 0x6d6f64756c652f436f72654e6f746174696f6e547261636573 "CoreNotationTraces") (cons (unitScope 0x6d6f64756c652f436f72654e6f746174696f6e "CoreNotation") (cons (unitScope 0x6d6f64756c652f43616e646964617465536f75726365 "CandidateSource") (cons (unitScope 0x6d6f64756c652f43616e646964617465536f75726365547261636573 "CandidateSourceTraces") (cons (unitScope 0x6d6f64756c652f436c6f736564476f616c547261636573 "ClosedGoalTraces") (cons (unitScope 0x6d6f64756c652f436c6f73656442696e64696e6746697874757265 "ClosedBindingFixture") (cons (unitScope 0x6d6f64756c652f436f6d70696c6572536e617073686f74 "CompilerSnapshot") (cons (unitScope 0x6d6f64756c652f436f6d70696c6572536e617073686f74547261636573 "CompilerSnapshotTraces") (cons (unitScope 0x6d6f64756c652f526573656172636843616e646964617465 "ResearchCandidate") (cons (unitScope 0x6d6f64756c652f526573656172636843616e646964617465547261636573 "ResearchCandidateTraces") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66547261636573 "ResearchProofTraces") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67547261636573 "CandidateBindingTraces") (cons (unitScope 0x6d6f64756c652f42696e64696e6746697874757265 "BindingFixture") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66 "ResearchProof") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67 "CandidateBinding") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479547261636573 "ArtifactIdentityTraces") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479 "ArtifactIdentity") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67547261636573 "CoreBindingTraces") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67 "CoreBinding") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c547261636573 "JsonCanonicalTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c "JsonCanonical") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e557466384669787475726573 "VerificationUtf8Fixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e436f6d6d616e644669787475726573 "VerificationCommandFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e44617461 "VerificationJsonData") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707330 "VerificationJsonSteps0") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707331 "VerificationJsonSteps1") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707332 "VerificationJsonSteps2") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707333 "VerificationJsonSteps3") (cons (unitScope 0x6d6f64756c652f417069 "Api") (cons (unitScope 0x6d6f64756c652f4170706c69636174696f6e "Application") (cons (unitScope 0x6d6f64756c652f417263686974656374757265 "Architecture") (cons (unitScope 0x6d6f64756c652f4175646974 "Audit") (cons (unitScope 0x6d6f64756c652f436f6e76657274 "Convert") (cons (unitScope 0x6d6f64756c652f446973636f76657279 "Discovery") (cons (unitScope 0x6d6f64756c652f456e67696e65 "Engine") (cons (unitScope 0x6d6f64756c652f486f7374 "Host") (cons (unitScope 0x6d6f64756c652f4879706f746865736573 "Hypotheses") (cons (unitScope 0x6d6f64756c652f4f62736572766572 "Observer") (cons (unitScope 0x6d6f64756c652f50726573656e746174696f6e "Presentation") (cons (unitScope 0x6d6f64756c652f523330 "R30") (cons (unitScope 0x6d6f64756c652f523330547261636573 "R30Traces") (cons (unitScope 0x6d6f64756c652f523330547261636573436c61696d73 "R30TracesClaims") (cons (unitScope 0x6d6f64756c652f523330547261636573466f726d73 "R30TracesForms") (cons (unitScope 0x6d6f64756c652f5233305472616365735265676973746572 "R30TracesRegister") (cons (unitScope 0x6d6f64756c652f5265676973746572 "Register") (cons (unitScope 0x6d6f64756c652f5265736561726368 "Research") (cons (unitScope 0x6d6f64756c652f5265736561726368436174616c6f67 "ResearchCatalog") (cons (unitScope 0x6d6f64756c652f5265736561726368547261636573 "ResearchTraces") (cons (unitScope 0x6d6f64756c652f52756c653330436f7265 "Rule30Core") (cons (unitScope 0x6d6f64756c652f53657175656e636573 "Sequences") (cons (unitScope 0x6d6f64756c652f5374616e6461726473 "Standards") (cons (unitScope 0x6d6f64756c652f546f6d6c "Toml") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e41726368 "Foundation.Arch") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e5175616c "Foundation.Qual") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e427566666572 "LexLeanStd.Buffer") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e54657874 "LexLeanStd.Text") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e536861323536 "LexLeanStd.Sha256") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e486f7374 "LexLeanStd.Host") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e "ResearchExecution") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e547261636573 "ResearchExecutionTraces") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572 "ResearchRunner") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572547261636573 "ResearchRunnerTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e "Json") (cons (unitScope 0x6d6f64756c652f4a736f6e547261636573 "JsonTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274 "VerificationReport") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274547261636573 "VerificationReportTraces") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e "ResearchVerification") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e547261636573 "ResearchVerificationTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e4669787475726573 "VerificationJsonFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e486173684669787475726573 "VerificationHashFixtures") (nil Scope)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))), axioms: [] } @@ -52,7 +63,7 @@ name: facetScopes, parameters: [], result: (List Scope), - body: (cons (record Scope {id := 0x636f72652d6e6f746174696f6e, module := "CoreNotation", features := (CoreNotation::features)}) (cons (record Scope {id := 0x63616e6469646174652d736f75726365, module := "CandidateSource", features := (CandidateSource::features)}) (cons (record Scope {id := 0x726567697374657265642d636c6f7365642d676f616c73, module := "ResearchCatalog", features := (cons "registered-closed-proposition-goals" (cons "canonical-prize-goal" (cons "block-goal-redirection" (nil String))))}) (cons (record Scope {id := 0x636f6d70696c65722d736e617073686f74, module := "CompilerSnapshot", features := (CompilerSnapshot::features)}) (cons (record Scope {id := 0x72657365617263682d63616e646964617465, module := "ResearchCandidate", features := (ResearchCandidate::features)}) (cons (record Scope {id := 0x70726f6f662d766572696669636174696f6e, module := "ResearchProof", features := (ResearchProof::features)}) (cons (record Scope {id := 0x63616e6469646174652d62696e64696e67, module := "CandidateBinding", features := (CandidateBinding::features)}) (cons (record Scope {id := 0x61727469666163742d6964656e74697479, module := "ArtifactIdentity", features := (ArtifactIdentity::features)}) (cons (record Scope {id := 0x636f72652d62696e64696e67, module := "CoreBinding", features := (CoreBinding::features)}) (cons (record Scope {id := 0x63616e6f6e6963616c2d6a736f6e, module := "JsonCanonical", features := (JsonCanonical::features)}) (cons (record Scope {id := 0x617069, module := "Api", features := (Architecture::commandNames (Api::commands))}) + body: (cons (record Scope {id := 0x5265736561726368436f686f7274436f6d6d616e64, module := "ResearchCohortCommand", features := (ResearchCohortCommand::features)}) (cons (record Scope {id := 0x5265736561726368436f686f7274496e707574, module := "ResearchCohortInput", features := (ResearchCohortInput::features)}) (cons (record Scope {id := 0x72657365617263682d636f686f7274, module := "ResearchCohort", features := (ResearchCohort::features)}) (cons (record Scope {id := 0x72657365617263682d696e707574, module := "ResearchInput", features := (ResearchInput::features)}) (cons (record Scope {id := 0x72657365617263682d636f6d6d616e64, module := "ResearchCommand", features := (ResearchCommand::features)}) (cons (record Scope {id := 0x72657365617263682d657865637574696f6e, module := "ResearchExecution", features := (ResearchExecution::features)}) (cons (record Scope {id := 0x72657365617263682d776f726b7370616365, module := "ResearchWorkspace", features := (ResearchWorkspace::features)}) (cons (record Scope {id := 0x72657365617263682d65766964656e6365, module := "ResearchEvidence", features := (ResearchEvidence::features)}) (cons (record Scope {id := 0x72657365617263682d70726f6a656374, module := "ResearchProject", features := (ResearchProject::features)}) (cons (record Scope {id := 0x72657365617263682d7265636f7264, module := "ResearchRecord", features := (ResearchRecord::features)}) (cons (record Scope {id := 0x72657365617263682d73657373696f6e, module := "ResearchSession", features := (ResearchSession::features)}) (cons (record Scope {id := 0x636f72652d6e6f746174696f6e, module := "CoreNotation", features := (CoreNotation::features)}) (cons (record Scope {id := 0x63616e6469646174652d736f75726365, module := "CandidateSource", features := (CandidateSource::features)}) (cons (record Scope {id := 0x726567697374657265642d636c6f7365642d676f616c73, module := "ResearchCatalog", features := (cons "registered-closed-proposition-goals" (cons "canonical-prize-goal" (cons "block-goal-redirection" (nil String))))}) (cons (record Scope {id := 0x636f6d70696c65722d736e617073686f74, module := "CompilerSnapshot", features := (CompilerSnapshot::features)}) (cons (record Scope {id := 0x72657365617263682d63616e646964617465, module := "ResearchCandidate", features := (ResearchCandidate::features)}) (cons (record Scope {id := 0x70726f6f662d766572696669636174696f6e, module := "ResearchProof", features := (ResearchProof::features)}) (cons (record Scope {id := 0x63616e6469646174652d62696e64696e67, module := "CandidateBinding", features := (CandidateBinding::features)}) (cons (record Scope {id := 0x61727469666163742d6964656e74697479, module := "ArtifactIdentity", features := (ArtifactIdentity::features)}) (cons (record Scope {id := 0x636f72652d62696e64696e67, module := "CoreBinding", features := (CoreBinding::features)}) (cons (record Scope {id := 0x63616e6f6e6963616c2d6a736f6e, module := "JsonCanonical", features := (JsonCanonical::features)}) (cons (record Scope {id := 0x617069, module := "Api", features := (Architecture::commandNames (Api::commands))}) (cons (record Scope {id := 0x636c61696d73, module := "Register", features := (Register::idsOf (Register::claims))}) (cons (record Scope {id := 0x7374616b65686f6c64657273, module := "Architecture", features := (Architecture::stakeholderIds (Architecture::stakeholders))}) (cons (record Scope {id := 0x636f6e6365726e73, module := "Architecture", features := (Architecture::concernIds (Architecture::concerns))}) @@ -71,7 +82,7 @@ (cons (record Scope {id := 0x706f7274666f6c696f, module := "Engine", features := (Engine::strategyIdsOf (Engine::portfolio))}) (cons (record Scope {id := 0x7265616c697a657273, module := "Standards", features := (Standards::declaredIds)}) (cons (record Scope {id := 0x7374646c6962, module := "Research", features := (cons "Foundation.Arch" (cons "Foundation.Qual" (cons "LexLeanStd.Buffer" (cons "LexLeanStd.Text" (cons "LexLeanStd.Sha256" (cons "LexLeanStd.Host" (nil String)))))))}) - (cons (record Scope {id := 0x6a736f6e, module := "Json", features := (Json::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d7265706f727473, module := "VerificationReport", features := (VerificationReport::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d657865637574696f6e, module := "ResearchVerification", features := (ResearchVerification::features)}) (nil Scope))))))))))))))))))))))))))))))))), + (cons (record Scope {id := 0x6a736f6e, module := "Json", features := (Json::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d7265706f727473, module := "VerificationReport", features := (VerificationReport::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d657865637574696f6e, module := "ResearchVerification", features := (ResearchVerification::features)}) (nil Scope)))))))))))))))))))))))))))))))))))))))))))), axioms: [] } diff --git a/rule30-api/src/ResearchCohort.lex.tex b/rule30-api/src/ResearchCohort.lex.tex new file mode 100644 index 0000000..483f6ae --- /dev/null +++ b/rule30-api/src/ResearchCohort.lex.tex @@ -0,0 +1,198 @@ +\begin{lexlean}{ResearchCohort} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchProject} +\importmodule{ResearchWorkspace} +\importmodule{ResearchSession} +\importmodule{ResearchCandidate} +\importmodule{ResearchExecution} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} +definition{ + name: contract, + parameters: [], + result: String, + body: "Run at most 64 distinct candidate attempts sequentially against one owned pinned library. Admission requires identical library configuration, tool identities and snapshots. Each candidate retains its own request, source directory, verification and evidence record. A normally completed failed candidate permits the next attempt; a blocked or interrupted attempt stops the cohort and retains the library for recovery. Cancellation drains the outstanding host reply before library release. Only the cohort releases the shared library, after all active candidate work has completed. Completion reports per-attempt outcomes and does not imply that every candidate was proved. This bounded executor consumes supplied candidates; it does not generate strategies or provide durable restart recovery.", + axioms: [], + executable: true +} +inductive{ + name: Phase, + type_parameters: [], + parameters: [], + constructors: [{name: preparing, fields: []}, {name: advancing, fields: []}, {name: attempting, fields: []}, {name: releasing, fields: []}, {name: ended, fields: []}, {name: blocked, fields: []}] +} +structure{ + name: State, + type_parameters: [], + parameters: [], + fields: [{name: owner, type: (Option ResearchWorkspace::State)}, {name: active, type: (Option ResearchSession::State)}, {name: pending, type: (List ResearchProject::Config)}, {name: results, type: (List (Research::Answer * Bytes))}, {name: phase, type: Phase}, {name: cancelled, type: Bool}] +} +inductive{ + name: Event, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Event]}, {name: cancel, fields: []}] +} +inductive{ + name: Emission, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Request]}, {name: awaiting, fields: []}, {name: complete, fields: [(List (Research::Answer * Bytes))]}, {name: blocked, fields: [String]}] +} +definition{ + name: sameTools, + parameters: [left : ResearchCandidate::Tools, right : ResearchCandidate::Tools], + result: Bool, + body: ((Toml::sameBytes (project left lexlean) (project right lexlean)) && ((Toml::sameBytes (project left lean) (project right lean)) && ((Toml::sameBytes (project left lake) (project right lake)) && (Toml::sameBytes (project left checker) (project right checker))))), + executable: true +} +definition{ + name: freshSerial, + parameters: [serial : Nat, seen : (List Nat)], + result: Bool, + body: (match seen | List.nil => true | List.cons head tail => ((not (serial =? head)) && (freshSerial serial tail))), + recursive_argument: seen, + executable: true +} +definition{ + name: compatible, + parameters: [base : ResearchProject::Config, pending : (List ResearchProject::Config), seen : (List Nat)], + result: Bool, + body: (match pending | List.nil => true | List.cons head tail => ((ResearchProject::sameWorkspace (project base workspace) (project head workspace)) && ((sameTools (project base tools) (project head tools)) && ((Research::sameSnapshot (project (project head request) snapshot) (project (project (project base workspace) request) snapshot)) && ((freshSerial (project (project head request) serial) seen) && (compatible base tail (cons (project (project head request) serial) seen))))))), + recursive_argument: pending, + executable: true +} +definition{ + name: phase, + parameters: [state : State, next : Phase], + result: State, + body: (record State {owner := (project state owner), active := (project state active), pending := (project state pending), results := (project state results), phase := next, cancelled := (project state cancelled)}), + executable: true +} +definition{ + name: blocked, + parameters: [state : State, reason : String], + result: (State * Emission), + body: ((phase state (ctor Phase.blocked)), (ctor Emission.blocked reason)), + executable: true +} +definition{ + name: finish, + parameters: [state : State], + result: (State * Emission), + body: ((phase state (ctor Phase.ended)), (ctor Emission.complete (project state results))), + executable: true +} +definition{ + name: markCancelled, + parameters: [state : State], + result: State, + body: (record State {owner := (project state owner), active := (project state active), pending := (project state pending), results := (project state results), phase := (project state phase), cancelled := true}), + executable: true +} +definition{ + name: advanceLater, + parameters: [state : State], + result: (State * Emission), + body: ((phase state (ctor Phase.advancing)), (ctor Emission.host (ctor LexLeanStd.Host::Request.wait (nil Nat) 0))), + executable: true +} +definition{ + name: ownerResult, + parameters: [state : State, result : (ResearchWorkspace::State * ResearchWorkspace::Emission)], + result: (State * Emission), + body: (let next : State := (record State {owner := (ctor Option.some [ResearchWorkspace::State] (first result)), active := (project state active), pending := (project state pending), results := (project state results), phase := (project state phase), cancelled := (project state cancelled)}); (match (second result) | ResearchWorkspace::Emission.host request => (next, (ctor Emission.host request)) | ResearchWorkspace::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchWorkspace::Emission.ready path => (advanceLater next) | ResearchWorkspace::Emission.complete kind => (match kind | ResearchExecution::EndKind.succeeded => (finish next) | ResearchExecution::EndKind.cut => (finish (markCancelled next)) | ResearchExecution::EndKind.failed => (blocked next "library preparation or release failed") | ResearchExecution::EndKind.unavailable => (blocked next "library tool unavailable") | ResearchExecution::EndKind.protocol => (blocked next "library protocol failure") | ResearchExecution::EndKind.cleanupFailed => (blocked next "library cleanup uncertain") | ResearchExecution::EndKind.refused => (blocked next "library request refused")) | ResearchWorkspace::Emission.blocked reason => (blocked next reason) | ResearchWorkspace::Emission.refused => (blocked next "library operation refused"))), + axioms: [], + executable: true +} +definition{ + name: release, + parameters: [state : State], + result: (State * Emission), + body: (match (project state owner) | Option.none => (finish state) | Option.some owner => (ownerResult (phase state (ctor Phase.releasing)) (ResearchWorkspace::step owner (ctor ResearchWorkspace::Event.release)))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: recheck, + parameters: [state : State], + result: (State * Emission), + body: (if (project state cancelled) then (advanceLater state) else (match (project state pending) | List.nil => (advanceLater state) | List.cons head tail => (match (project state owner) | Option.none => (blocked state "missing library owner after candidate") | Option.some owner => (ownerResult (phase state (ctor Phase.preparing)) (ResearchWorkspace::launch owner (ctor ResearchWorkspace::Operation.finalize)))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: attemptResult, + parameters: [state : State, result : (ResearchSession::State * ResearchSession::Emission)], + result: (State * Emission), + body: (let next : State := (record State {owner := (project state owner), active := (ctor Option.some [ResearchSession::State] (first result)), pending := (project state pending), results := (project state results), phase := (ctor Phase.attempting), cancelled := (project state cancelled)}); (match (second result) | ResearchSession::Emission.host request => (next, (ctor Emission.host request)) | ResearchSession::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchSession::Emission.blocked reason => (blocked next reason) | ResearchSession::Emission.complete answer evidence => (recheck (record State {owner := (project state owner), active := (ctor Option.none [ResearchSession::State]), pending := (project state pending), results := (prim append (project state results) (cons (answer, evidence) (nil (Research::Answer * Bytes))) : (List (Research::Answer * Bytes))), phase := (ctor Phase.advancing), cancelled := (project state cancelled)})))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: advance, + parameters: [state : State], + result: (State * Emission), + body: (if (project state cancelled) then (release state) else (match (project state pending) | List.nil => (release state) | List.cons head tail => (match (project state owner) | Option.none => (blocked state "missing library owner") | Option.some owner => (attemptResult (record State {owner := (project state owner), active := (ctor Option.none [ResearchSession::State]), pending := tail, results := (project state results), phase := (ctor Phase.attempting), cancelled := false}) (ResearchSession::beginPrepared head owner))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: begin, + parameters: [candidates : (List ResearchProject::Config)], + result: (State * Emission), + body: (let state : State := (record State {owner := (ctor Option.none [ResearchWorkspace::State]), active := (ctor Option.none [ResearchSession::State]), pending := candidates, results := (nil (Research::Answer * Bytes)), phase := (ctor Phase.preparing), cancelled := false}); (match candidates | List.nil => (finish state) | List.cons head tail => (if (((prim length candidates : Nat) <=? 64) && (compatible head candidates (nil Nat))) then (ownerResult state (ResearchWorkspace::begin (project head workspace))) else (blocked state "cohort requires at most 64 distinct attempts sharing one library configuration and tool identity")))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: host, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (project state phase) + | Phase.preparing => (match (project state owner) | Option.none => (blocked state "missing preparing owner") | Option.some owner => (ownerResult state (ResearchWorkspace::step owner (ctor ResearchWorkspace::Event.host event)))) + | Phase.releasing => (match (project state owner) | Option.none => (blocked state "missing releasing owner") | Option.some owner => (ownerResult state (ResearchWorkspace::step owner (ctor ResearchWorkspace::Event.host event)))) + | Phase.attempting => (match (project state active) | Option.none => (blocked state "missing candidate owner") | Option.some active => (attemptResult state (ResearchSession::step active (ctor ResearchSession::Event.host event)))) + | Phase.advancing => (match (ResearchExecution::asWaited event) | Option.none => (blocked state "unexpected cohort continuation reply") | Option.some outcome => (match outcome | Result.error failure => (blocked state "cohort continuation unavailable") | Result.ok reply => (match (project reply finished) | List.nil => (advance state) | List.cons head tail => (blocked state "unowned child in cohort continuation")))) + | Phase.ended => (finish state) + | Phase.blocked => (blocked state "cohort retained for recovery")), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: cancel, + parameters: [state : State], + result: (State * Emission), + body: (let next : State := (markCancelled state); (match (project state phase) + | Phase.preparing => (match (project state owner) | Option.none => (blocked next "missing preparing owner") | Option.some owner => (ownerResult next (ResearchWorkspace::step owner (ctor ResearchWorkspace::Event.cancel)))) + | Phase.attempting => (match (project state active) | Option.none => (blocked next "missing candidate owner") | Option.some active => (attemptResult next (ResearchSession::step active (ctor ResearchSession::Event.cancel)))) + | Phase.advancing => (next, (ctor Emission.awaiting)) + | Phase.releasing => (next, (ctor Emission.awaiting)) + | Phase.ended => (finish state) + | Phase.blocked => (blocked next "cohort retained for recovery"))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: step, + parameters: [state : State, event : Event], + result: (State * Emission), + body: (match event | Event.host reply => (host state reply) | Event.cancel => (cancel state)), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "one-library-owner-per-cohort" (cons "bounded-distinct-candidate-attempts" (cons "exact-shared-configuration" (cons "per-candidate-source-and-evidence" (cons "drain-before-cancel" (cons "retain-library-on-uncertain-attempt" (cons "recheck-tracked-library-between-attempts" (nil String)))))))), + executable: true +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCohortCommand.lex.tex b/rule30-api/src/ResearchCohortCommand.lex.tex new file mode 100644 index 0000000..1cb6a36 --- /dev/null +++ b/rule30-api/src/ResearchCohortCommand.lex.tex @@ -0,0 +1,128 @@ +\begin{lexlean}{ResearchCohortCommand} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchCohort} +\importmodule{ResearchCohortInput} +\importmodule{ResearchCommand} +\importmodule{ResearchRecord} +\importmodule{ResearchSession} +\importmodule{ResearchWorkspace} +\importmodule{Json} +\importmodule{JsonCanonical} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} +inductive{ + name: State, + type_parameters: [], + parameters: [], + constructors: [{name: reading, fields: [(List (Bytes * Bytes))]}, {name: active, fields: [ResearchCohort::State]}, {name: ended, fields: [(Option ResearchCohort::State)]}] +} +definition{ + name: usage, + parameters: [], + result: Bytes, + body: 0x75736167653a207233302d72657365617263682d636f686f727420524551554553542e6a736f6e0a0a52756e20757020746f203634206c6f63616c6c792076657269666965642063616e64696461746520617474656d7074732073686172696e67206f6e65207072657061726564206c6962726172792e0a496e7075743a207233302f72657365617263682d636f686f72742f31207769746820666972737420616e6420726573742066756c6c20617474656d70742072657175657374732e0a417474656d707473206d757374207368617265206c6962726172792c20746f6f6c732c20656e7669726f6e6d656e7420616e6420776f726b7370616365206c6f6720636f6e66696775726174696f6e2c0a776974682064697374696e63742073657269616c732e205065722d617474656d707420726573756c74732072657461696e2074686569722070726f6f66207374617475732e0a, + executable: true +} +definition{ + name: recoveryPath, + parameters: [cohort : (Option ResearchCohort::State)], + result: Json::Value, + body: (match cohort | Option.none => (ctor Json::Value.string 0x) | Option.some active => (match (project active owner) | Option.none => (ctor Json::Value.string 0x) | Option.some owner => (if (project owner owned) then (ctor Json::Value.string (prim utf8_encode (ResearchWorkspace::path (project owner config)) : Bytes)) else (match (project owner phase) | ResearchWorkspace::Phase.blocked => (ctor Json::Value.string (prim utf8_encode (ResearchWorkspace::path (project owner config)) : Bytes)) | ResearchWorkspace::Phase.checking => (ctor Json::Value.string 0x) | ResearchWorkspace::Phase.executing => (ctor Json::Value.string 0x) | ResearchWorkspace::Phase.reading => (ctor Json::Value.string 0x) | ResearchWorkspace::Phase.ready => (ctor Json::Value.string 0x) | ResearchWorkspace::Phase.ended => (ctor Json::Value.string 0x))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: finish, + parameters: [session : (Option ResearchCohort::State), exitStatus : UInt8, document : Json::Value], + result: (State * LexLeanStd.Host::Request), + body: ((ctor State.ended session), (match (JsonCanonical::file document 8388608 16777216) | Option.some data => (ctor LexLeanStd.Host::Request.exit exitStatus data 0x) | Option.none => (ctor LexLeanStd.Host::Request.exit (70 : UInt8) 0x 0x726573656172636820726573756c74206578636565647320656e636f64696e67206c696d6974730a))), + axioms: [propext], + executable: true +} +definition{ + name: results, + parameters: [answers : (List (Research::Answer * Bytes))], + result: (List Json::Value), + body: (match answers | List.nil => (nil Json::Value) | List.cons head tail => (cons (ctor Json::Value.object (cons (0x72657175657374, (ResearchRecord::request (project (first head) request))) (cons (0x737461747573, (ResearchCommand::status (project (first head) result))) (cons (0x64657461696c, (ResearchCommand::detail (project (first head) result))) (cons (0x65766964656e6365, (ctor Json::Value.string (second head))) (nil (Bytes * Json::Value))))))) (results tail))), + recursive_argument: answers, + executable: true +} +definition{ + name: allChecked, + parameters: [answers : (List (Research::Answer * Bytes))], + result: Bool, + body: (match answers | List.nil => true | List.cons head tail => ((ResearchSession::isChecked (first head)) && (allChecked tail))), + recursive_argument: answers, + executable: true +} +definition{ + name: error, + parameters: [cohort : (Option ResearchCohort::State), exitStatus : UInt8, reason : Bytes], + result: (State * LexLeanStd.Host::Request), + body: (finish cohort exitStatus (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d636f686f72742d726573756c742f31)) (cons (0x737461747573, (ctor Json::Value.string 0x6661696c6564)) (cons (0x726561736f6e, (ctor Json::Value.string reason)) (cons (0x7265636f766572795f776f726b7370616365, (recoveryPath cohort)) (cons (0x726573756c7473, (ctor Json::Value.array (match cohort | Option.none => (nil Json::Value) | Option.some state => (results (project state results))))) (nil (Bytes * Json::Value))))))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: complete, + parameters: [cohort : ResearchCohort::State, answers : (List (Research::Answer * Bytes))], + result: (State * LexLeanStd.Host::Request), + body: (finish (ctor Option.some [ResearchCohort::State] cohort) (if ((not (project cohort cancelled)) && (allChecked answers)) then (0 : UInt8) else (1 : UInt8)) (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d636f686f72742d726573756c742f31)) (cons (0x737461747573, (ctor Json::Value.string (if (project cohort cancelled) then 0x637574 else 0x636f6d706c65746564))) (cons (0x726573756c7473, (ctor Json::Value.array (results answers))) (nil (Bytes * Json::Value))))))), + axioms: [propext], + executable: true +} +definition{ + name: advanceCohort, + parameters: [result : (ResearchCohort::State * ResearchCohort::Emission)], + result: (State * LexLeanStd.Host::Request), + body: (match (second result) | ResearchCohort::Emission.host request => ((ctor State.active (first result)), request) | ResearchCohort::Emission.complete answers => (complete (first result) answers) | ResearchCohort::Emission.blocked reason => (error (ctor Option.some [ResearchCohort::State] (first result)) (1 : UInt8) (prim utf8_encode reason : Bytes)) | ResearchCohort::Emission.awaiting => (error (ctor Option.some [ResearchCohort::State] (first result)) (70 : UInt8) 0x636f686f727420686173206e6f2070656e64696e6720686f73742072657175657374)), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: readResult, + parameters: [env : (List (Bytes * Bytes)), event : LexLeanStd.Host::Event], + result: (State * LexLeanStd.Host::Request), + body: (match (Host::asRead event) | Option.none => (error (ctor Option.none [ResearchCohort::State]) (70 : UInt8) 0x657870656374656420617474656d707420726571756573742072656164) | Option.some response => (match response | Result.error failure => (error (ctor Option.none [ResearchCohort::State]) (1 : UInt8) (project failure message)) | Result.ok data => (match (ResearchCohortInput::decode data env) | Option.none => (error (ctor Option.none [ResearchCohort::State]) (2 : UInt8) 0x617474656d70742072657175657374206f7220656e7669726f6e6d656e74206973206f757473696465207468652061646d697474656420736368656d6120616e6420626f756e6473) | Option.some config => (advanceCohort (ResearchCohort::begin config))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: help, + parameters: [], + result: (State * LexLeanStd.Host::Request), + body: ((ctor State.ended (ctor Option.none [ResearchCohort::State])), (ctor LexLeanStd.Host::Request.exit (0 : UInt8) (usage) 0x)), + axioms: [], + executable: true +} +definition{ + name: start, + parameters: [incoming : LexLeanStd.Host::Start], + result: (State * LexLeanStd.Host::Request), + body: (match (project incoming arguments) | List.nil => (help) | List.cons path rest => (match rest | List.cons extra more => (error (ctor Option.none [ResearchCohort::State]) (2 : UInt8) 0x65787065637465642065786163746c79206f6e6520617474656d707420726571756573742066696c65) | List.nil => (if ((Toml::sameBytes path 0x2d2d68656c70) || (Toml::sameBytes path 0x2d68)) then (help) else (if ((0 (match (Host::asStart event) | Option.none => (error (ctor Option.none [ResearchCohort::State]) (70 : UInt8) 0x6578706563746564206e617469766520686f7374207374617274) | Option.some initialStart => (start initialStart)) | Option.some active => (match active | State.reading env => (readResult env event) | State.active session => (advanceCohort (ResearchCohort::step session (ctor ResearchCohort::Event.host event))) | State.ended session => (error session (70 : UInt8) 0x636f6d706c6574656420726573656172636820636f6d6d616e642063616e6e6f742072657374617274))), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, files, overflow, process, recursion], targets: [rust-std]} +} +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "native-owned-cohort-entry" (cons "per-attempt-verified-outcomes" (cons "shared-library-release-after-attempts" (cons "terminal-command-cannot-restart" (nil String))))), + executable: true +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCohortInput.lex.tex b/rule30-api/src/ResearchCohortInput.lex.tex new file mode 100644 index 0000000..e4fe42a --- /dev/null +++ b/rule30-api/src/ResearchCohortInput.lex.tex @@ -0,0 +1,61 @@ +\begin{lexlean}{ResearchCohortInput} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{ResearchCohort} +\importmodule{ResearchInput} +\importmodule{ResearchProject} +\importmodule{ResearchWorkspace} +\importmodule{Research} +\importmodule{CoreNotation} +\importmodule{CoreBinding} +\importmodule{Json} +\title{Boolean} +\begin{semanticmodule} +definition{ + name: libraryOwner, + parameters: [base : ResearchWorkspace::Config, candidate : ResearchWorkspace::Config], + result: ResearchWorkspace::Config, + body: (record ResearchWorkspace::Config {request := (project base request), repository := (project candidate repository), revision := (project candidate revision), environment := (project candidate environment), output := (project candidate output), errors := (project candidate errors), allowance := (project candidate allowance), quantum := (project candidate quantum), polls := (project candidate polls)}), + executable: true +} +definition{ + name: share, + parameters: [base : ResearchProject::Config, candidate : ResearchProject::Config], + result: (Option ResearchProject::Config), + body: (if ((ResearchProject::sameWorkspace (project base workspace) (libraryOwner (project base workspace) (project candidate workspace))) && ((ResearchCohort::sameTools (project base tools) (project candidate tools)) && (Research::sameSnapshot (project (project base request) snapshot) (project (project candidate request) snapshot)))) then (ctor Option.some [ResearchProject::Config] (record ResearchProject::Config {request := (project candidate request), workspace := (project base workspace), tools := (project candidate tools), arena := (project candidate arena), proof := (project candidate proof), imports := (project candidate imports), levels := (project candidate levels), axioms := (project candidate axioms), maxBytes := (project candidate maxBytes), maxDepth := (project candidate maxDepth), maxSteps := (project candidate maxSteps)})) else (ctor Option.none [ResearchProject::Config])), + executable: true +} +definition{ + name: rest, + parameters: [base : ResearchProject::Config, values : (List Json::Value), environment : (List (String * String))], + result: (Option (List ResearchProject::Config)), + body: (match values | List.nil => (ctor Option.some [(List ResearchProject::Config)] (nil ResearchProject::Config)) | List.cons head tail => (match (ResearchInput::config head environment) | Option.none => (ctor Option.none [(List ResearchProject::Config)]) | Option.some candidate => (match (share base candidate) | Option.none => (ctor Option.none [(List ResearchProject::Config)]) | Option.some shared => (match (rest base tail environment) | Option.none => (ctor Option.none [(List ResearchProject::Config)]) | Option.some more => (ctor Option.some [(List ResearchProject::Config)] (cons shared more)))))), + recursive_argument: values, + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: config, + parameters: [value : Json::Value, environment : (List (String * String))], + result: (Option (List ResearchProject::Config)), + body: (if ((CoreNotation::shape value (cons 0x73706563 (cons 0x6669727374 (cons 0x72657374 (nil Bytes))))) && (ResearchInput::stringIs (CoreBinding::get value 0x73706563) 0x7233302f72657365617263682d636f686f72742f31)) then (match (ResearchInput::config (CoreBinding::get value 0x6669727374) environment) | Option.none => (ctor Option.none [(List ResearchProject::Config)]) | Option.some base => (match (ResearchInput::array (CoreBinding::get value 0x72657374)) | Option.none => (ctor Option.none [(List ResearchProject::Config)]) | Option.some values => (if ((prim length values : Nat) <=? 63) then (match (rest base values environment) | Option.none => (ctor Option.none [(List ResearchProject::Config)]) | Option.some more => (let candidates : (List ResearchProject::Config) := (cons base more); (if (ResearchCohort::compatible base candidates (nil Nat)) then (ctor Option.some [(List ResearchProject::Config)] candidates) else (ctor Option.none [(List ResearchProject::Config)])))) else (ctor Option.none [(List ResearchProject::Config)])))) else (ctor Option.none [(List ResearchProject::Config)])), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: decode, + parameters: [data : Bytes, environment : (List (Bytes * Bytes))], + result: (Option (List ResearchProject::Config)), + body: (match (Json::parse data 8388608 96) | Result.error problem => (ctor Option.none [(List ResearchProject::Config)]) | Result.ok document => (match (ResearchInput::environment environment) | Option.none => (ctor Option.none [(List ResearchProject::Config)]) | Option.some admitted => (config document admitted))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "bounded-cohort-json" (cons "shared-owner-explicit-normalization" (cons "unchanged-tools-environment-and-library" (cons "unique-attempt-serials-before-effects" (nil String))))), + executable: true +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCohortTraces.lex.tex b/rule30-api/src/ResearchCohortTraces.lex.tex new file mode 100644 index 0000000..24c3db2 --- /dev/null +++ b/rule30-api/src/ResearchCohortTraces.lex.tex @@ -0,0 +1,152 @@ +\begin{lexlean}{ResearchCohortTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{ResearchCohort} +\importmodule{ResearchCohortInput} +\importmodule{ResearchCohortCommand} +\importmodule{Json} +\importmodule{CoreBinding} +\importmodule{ResearchInput} +\importmodule{ResearchInputTraces} +\importmodule{ResearchProject} +\importmodule{ResearchWorkspace} +\importmodule{ResearchSession} +\importmodule{ResearchExecution} +\importmodule{Research} +\importmodule{LexLeanStd.Host} +\title{Boolean} +\begin{semanticmodule} +definition{ + name: blocked, + parameters: [result : (ResearchCohort::State * ResearchCohort::Emission)], + result: Bool, + body: (match (second result) | ResearchCohort::Emission.blocked reason => true | ResearchCohort::Emission.host request => false | ResearchCohort::Emission.awaiting => false | ResearchCohort::Emission.complete answers => false) +} +theorem{ + name: emptyCohortPerformsNoEffects, + parameters: [], + statement: ((match (second (ResearchCohort::begin (nil ResearchProject::Config))) | ResearchCohort::Emission.complete answers => ((prim length answers : Nat) =? 0) | ResearchCohort::Emission.blocked reason => false | ResearchCohort::Emission.host request => false | ResearchCohort::Emission.awaiting => false) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: duplicateAttemptCannotReuseCandidateDirectory, + parameters: [], + statement: ((match (ResearchInput::config (ResearchInputTraces::fixtureDocument) (nil (String * String))) | Option.none => false | Option.some config => (blocked (ResearchCohort::begin (cons config (cons config (nil ResearchProject::Config)))))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +definition{ + name: readyOwner, + parameters: [config : ResearchProject::Config], + result: ResearchWorkspace::State, + body: (record ResearchWorkspace::State {config := (project config workspace), operation := (ctor ResearchWorkspace::Operation.finalize), phase := (ctor ResearchWorkspace::Phase.ready), execution := (ctor Option.none [ResearchExecution::State]), owned := true, cancelled := false, result := (ctor ResearchExecution::EndKind.succeeded), detail := ""}) +} +theorem{ + name: readyLibrarySkipsCheckoutAndBuild, + parameters: [], + statement: ((match (ResearchInput::config (ResearchInputTraces::fixtureDocument) (nil (String * String))) | Option.none => false | Option.some config => (match (second (ResearchProject::beginPrepared config (readyOwner config))) | ResearchProject::Emission.host request => (match request | LexLeanStd.Host::Request.stat path => true | LexLeanStd.Host::Request.read path => false | LexLeanStd.Host::Request.write path data => false | LexLeanStd.Host::Request.createDir path => false | LexLeanStd.Host::Request.removeFile path => false | LexLeanStd.Host::Request.removeTree path => false | LexLeanStd.Host::Request.rename source target => false | LexLeanStd.Host::Request.lock path => false | LexLeanStd.Host::Request.list path => false | LexLeanStd.Host::Request.canonical path => false | LexLeanStd.Host::Request.spawn job => false | LexLeanStd.Host::Request.wait children delay => false | LexLeanStd.Host::Request.stop child => false | LexLeanStd.Host::Request.exit code output errors => false) | ResearchProject::Emission.awaiting => false | ResearchProject::Emission.ready context => false | ResearchProject::Emission.complete kind => false | ResearchProject::Emission.blocked reason => false | ResearchProject::Emission.refused => false)) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: borrowedProjectDoesNotReleaseLibrary, + parameters: [config : ResearchProject::Config, owner : ResearchWorkspace::State, source : Bytes], + statement: ((match (second (ResearchProject::step (record ResearchProject::State {borrowed := true, config := config, source := source, workspace := (ctor Option.some [ResearchWorkspace::State] owner), execution := (ctor Option.none [ResearchExecution::State]), operation := (ctor ResearchProject::Operation.lock), phase := (ctor ResearchProject::Phase.ready), cancelled := false, result := (ctor ResearchExecution::EndKind.succeeded)}) (ctor ResearchProject::Event.release))) | ResearchProject::Emission.complete kind => true | ResearchProject::Emission.host request => false | ResearchProject::Emission.awaiting => false | ResearchProject::Emission.ready context => false | ResearchProject::Emission.blocked reason => false | ResearchProject::Emission.refused => false) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: advancing, + parameters: [], + result: ResearchCohort::State, + body: (record ResearchCohort::State {owner := (ctor Option.none [ResearchWorkspace::State]), active := (ctor Option.none [ResearchSession::State]), pending := (nil ResearchProject::Config), results := (nil (Research::Answer * Bytes)), phase := (ctor ResearchCohort::Phase.advancing), cancelled := false}) +} +theorem{ + name: cancellationDrainsContinuationBeforeRelease, + parameters: [], + statement: ((match (second (ResearchCohort::cancel (advancing))) | ResearchCohort::Emission.awaiting => true | ResearchCohort::Emission.complete answers => false | ResearchCohort::Emission.host request => false | ResearchCohort::Emission.blocked reason => false) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: document, + parameters: [initial : Json::Value, rest : (List Json::Value)], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d636f686f72742f31)) (cons (0x6669727374, initial) (cons (0x72657374, (ctor Json::Value.array rest)) (nil (Bytes * Json::Value)))))) +} +definition{ + name: secondAttempt, + parameters: [], + result: Json::Value, + body: (ResearchInputTraces::put (ResearchInputTraces::fixtureDocument) 0x72657175657374 (ResearchInputTraces::put (ResearchInputTraces::requestDocument) 0x73657269616c (ctor Json::Value.number 0x34))), + axioms: [propext] +} +theorem{ + name: candidateSerialIsIndependentOfLibraryOwner, + parameters: [], + statement: ((match (ResearchCohortInput::config (document (ResearchInputTraces::fixtureDocument) (cons (secondAttempt) (nil Json::Value))) (nil (String * String))) | Option.none => false | Option.some candidates => (match candidates | List.nil => false | List.cons initial rest => (match rest | List.nil => false | List.cons subsequent more => ((((project (project subsequent request) serial) =? 4) && ((project (project (project subsequent workspace) request) serial) =? 3)) && ((prim length more : Nat) =? 0))))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: duplicateSerialRejectedByInputBeforeAnyEffects, + parameters: [], + statement: ((match (ResearchCohortInput::config (document (ResearchInputTraces::fixtureDocument) (cons (ResearchInputTraces::fixtureDocument) (nil Json::Value))) (nil (String * String))) | Option.none => true | Option.some candidates => false) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: differingWorkspaceLogsCannotBeSilentlyRebound, + parameters: [], + statement: ((match (ResearchCohortInput::config (document (ResearchInputTraces::fixtureDocument) (cons (ResearchInputTraces::put (secondAttempt) 0x6f7574707574 (ctor Json::Value.string 0x2f6f74686572)) (nil Json::Value))) (nil (String * String))) | Option.none => true | Option.some candidates => false) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: endedLibraryCannotBeBorrowed, + parameters: [], + statement: ((match (ResearchInput::config (ResearchInputTraces::fixtureDocument) (nil (String * String))) | Option.none => false | Option.some config => (not (ResearchProject::preparedFor config (ResearchWorkspace::withPhase (readyOwner config) (ctor ResearchWorkspace::Phase.ended))))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: changedToolIdentityCannotBorrowLibrary, + parameters: [], + statement: ((match (ResearchCohortInput::config (document (ResearchInputTraces::fixtureDocument) (cons (ResearchInputTraces::put (secondAttempt) 0x746f6f6c73 (ResearchInputTraces::put (CoreBinding::get (secondAttempt) 0x746f6f6c73) 0x6c65786c65616e (ctor Json::Value.string 0x65656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565656565))) (nil Json::Value))) (nil (String * String))) | Option.none => true | Option.some candidates => false) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: completedCohortDoesNotReleaseTwice, + parameters: [owner : (Option ResearchWorkspace::State), answers : (List (Research::Answer * Bytes)), event : LexLeanStd.Host::Event], + statement: ((match (second (ResearchCohort::host (record ResearchCohort::State {owner := owner, active := (ctor Option.none [ResearchSession::State]), pending := (nil ResearchProject::Config), results := answers, phase := (ctor ResearchCohort::Phase.ended), cancelled := false}) event)) | ResearchCohort::Emission.complete results => true | ResearchCohort::Emission.host request => false | ResearchCohort::Emission.awaiting => false | ResearchCohort::Emission.blocked reason => false) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: libraryTimeoutCannotReportEmptySuccess, + parameters: [state : ResearchCohort::State, owner : ResearchWorkspace::State], + statement: ((project (first (ResearchCohort::ownerResult state (owner, (ctor ResearchWorkspace::Emission.complete (ctor ResearchExecution::EndKind.cut))))) cancelled) = true), + proof: reflexivity{}, + axioms: [] +} +theorem{ + name: failedAttemptPreventsAggregateSuccess, + parameters: [request : Research::Request, reason : Bytes, evidence : Bytes, tail : (List (Research::Answer * Bytes))], + statement: ((ResearchCohortCommand::allChecked (cons ((record Research::Answer {request := request, result := (ctor Research::ResultKind.failed reason)}), evidence) tail)) = false), + proof: reflexivity{}, + axioms: [] +} +theorem{ + name: completedCommandCannotStartAnotherCohort, + parameters: [cohort : (Option ResearchCohort::State), event : LexLeanStd.Host::Event], + statement: ((ResearchCohortCommand::step (ctor Option.some [ResearchCohortCommand::State] (ctor ResearchCohortCommand::State.ended cohort)) event) = (ResearchCohortCommand::error cohort (70 : UInt8) 0x636f6d706c6574656420726573656172636820636f6d6d616e642063616e6e6f742072657374617274)), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCommand.lex.tex b/rule30-api/src/ResearchCommand.lex.tex new file mode 100644 index 0000000..de8624c --- /dev/null +++ b/rule30-api/src/ResearchCommand.lex.tex @@ -0,0 +1,154 @@ +\begin{lexlean}{ResearchCommand} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchInput} +\importmodule{ResearchSession} +\importmodule{ResearchWorkspace} +\importmodule{ResearchProject} +\importmodule{ResearchRecord} +\importmodule{CandidateSource} +\importmodule{Json} +\importmodule{JsonCanonical} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} + +inductive{ + name: State, + type_parameters: [], + parameters: [], + constructors: [{name: reading, fields: [(List (Bytes * Bytes))]}, {name: active, fields: [ResearchSession::State]}, {name: ended, fields: [(Option ResearchSession::State)]}] +} + +definition{ + name: usage, + parameters: [], + result: Bytes, + body: 0x75736167653a207233302d726573656172636820524551554553542e6a736f6e0a0a52756e206f6e65206c6f63616c6c792076657269666965642063616e64696461746520617474656d7074207573696e6720746865207233302f72657365617263682d617474656d70742f31204150492e0a5468652072657175657374206964656e7469666965732069747320657861637420676f616c2c2070696e6e6564206c69627261727920616e6420746f6f6c732c2063616e646964617465207465726d2c0a6c6f6720706174687320616e64207265736f7572636520626f756e64732e204f75747075742075736573207233302f72657365617263682d726573756c742f312e0a412073746f726564207265636f7264206973207265706c617920696e7075743b20697420646f6573206e6f74207075626c697368206120636c61696d206f72206c61756e6368207374726174656779207365617263682e0a, + axioms: [], + executable: true +} + +definition{ + name: recoveryPath, + parameters: [session : (Option ResearchSession::State)], + result: Json::Value, + body: (match session | Option.none => (ctor Json::Value.string 0x) | Option.some active => (match (project active phase) | ResearchSession::Phase.blocked => (ctor Json::Value.string (prim utf8_encode (ResearchWorkspace::path (project (ResearchSession::sessionConfig active) workspace)) : Bytes)) | ResearchSession::Phase.preparing => (ctor Json::Value.string 0x) | ResearchSession::Phase.readingLock => (ctor Json::Value.string 0x) | ResearchSession::Phase.readingManifest => (ctor Json::Value.string 0x) | ResearchSession::Phase.verifying => (ctor Json::Value.string 0x) | ResearchSession::Phase.archiving => (ctor Json::Value.string 0x) | ResearchSession::Phase.releasing => (ctor Json::Value.string 0x) | ResearchSession::Phase.ended => (ctor Json::Value.string 0x))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: finish, + parameters: [session : (Option ResearchSession::State), exitStatus : UInt8, document : Json::Value], + result: (State * LexLeanStd.Host::Request), + body: ((ctor State.ended session), (match (JsonCanonical::file document 8388608 16777216) | Option.some data => (ctor LexLeanStd.Host::Request.exit exitStatus data 0x) | Option.none => (ctor LexLeanStd.Host::Request.exit (70 : UInt8) 0x 0x726573656172636820726573756c74206578636565647320656e636f64696e67206c696d6974730a))), + axioms: [propext], + executable: true +} + +definition{ + name: error, + parameters: [session : (Option ResearchSession::State), exitStatus : UInt8, reason : Bytes], + result: (State * LexLeanStd.Host::Request), + body: (finish session exitStatus (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d726573756c742f31)) (cons (0x737461747573, (ctor Json::Value.string 0x6661696c6564)) (cons (0x726561736f6e, (ctor Json::Value.string reason)) (cons (0x7265636f766572795f776f726b7370616365, (recoveryPath session)) (nil (Bytes * Json::Value)))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: status, + parameters: [result : Research::ResultKind], + result: Json::Value, + body: (match result | Research::ResultKind.checked goal theorem axioms => (ctor Json::Value.string 0x636865636b6564) | Research::ResultKind.failed reason => (ctor Json::Value.string 0x6661696c6564) | Research::ResultKind.cut => (ctor Json::Value.string 0x637574) | Research::ResultKind.unavailable => (ctor Json::Value.string 0x756e617661696c61626c65) | Research::ResultKind.inspected goal => (ctor Json::Value.string 0x756e6578706563746564) | Research::ResultKind.maintained sources evidence => (ctor Json::Value.string 0x756e6578706563746564)), + axioms: [], + executable: true +} + +definition{ + name: detail, + parameters: [result : Research::ResultKind], + result: Json::Value, + body: (match result | Research::ResultKind.checked goal theorem axioms => (ctor Json::Value.object (cons (0x676f616c, (ResearchRecord::sequent goal)) (cons (0x7468656f72656d, (ctor Json::Value.string theorem)) (cons (0x6178696f6d73, (ctor Json::Value.array (CandidateSource::axiomStrings axioms))) (nil (Bytes * Json::Value)))))) | Research::ResultKind.failed reason => (ctor Json::Value.string reason) | Research::ResultKind.cut => (ctor Json::Value.string 0x) | Research::ResultKind.unavailable => (ctor Json::Value.string 0x) | Research::ResultKind.inspected goal => (ctor Json::Value.string 0x) | Research::ResultKind.maintained sources evidence => (ctor Json::Value.string 0x)), + axioms: [], + executable: true +} + +definition{ + name: complete, + parameters: [session : ResearchSession::State, answer : Research::Answer, identity : Bytes], + result: (State * LexLeanStd.Host::Request), + body: (finish (ctor Option.some [ResearchSession::State] session) (if (ResearchSession::isChecked answer) then (0 : UInt8) else (1 : UInt8)) (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d726573756c742f31)) (cons (0x737461747573, (status (project answer result))) (cons (0x72657175657374, (ResearchRecord::request (project answer request))) (cons (0x65766964656e6365, (if ((prim length identity : Nat) =? 0) then (ctor Json::Value.string 0x) else (ctor Json::Value.string identity))) (cons (0x64657461696c, (detail (project answer result))) (nil (Bytes * Json::Value))))))))), + axioms: [propext], + executable: true +} + +definition{ + name: advanceSession, + parameters: [result : (ResearchSession::State * ResearchSession::Emission)], + result: (State * LexLeanStd.Host::Request), + body: (match (second result) | ResearchSession::Emission.host request => ((ctor State.active (first result)), request) | ResearchSession::Emission.complete answer identity => (complete (first result) answer identity) | ResearchSession::Emission.blocked reason => (error (ctor Option.some [ResearchSession::State] (first result)) (1 : UInt8) (prim utf8_encode reason : Bytes)) | ResearchSession::Emission.awaiting => (error (ctor Option.some [ResearchSession::State] (first result)) (70 : UInt8) 0x726573656172636820636f6d6d616e6420686173206e6f206f75747374616e64696e6720686f73742072657175657374)), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: readResult, + parameters: [env : (List (Bytes * Bytes)), event : LexLeanStd.Host::Event], + result: (State * LexLeanStd.Host::Request), + body: (match (Host::asRead event) | Option.none => (error (ctor Option.none [ResearchSession::State]) (70 : UInt8) 0x657870656374656420617474656d707420726571756573742072656164) | Option.some response => (match response | Result.error failure => (error (ctor Option.none [ResearchSession::State]) (1 : UInt8) (project failure message)) | Result.ok data => (match (ResearchInput::decode data env) | Option.none => (error (ctor Option.none [ResearchSession::State]) (2 : UInt8) 0x617474656d70742072657175657374206f7220656e7669726f6e6d656e74206973206f757473696465207468652061646d697474656420736368656d6120616e6420626f756e6473) | Option.some config => (advanceSession (ResearchSession::begin config))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: help, + parameters: [], + result: (State * LexLeanStd.Host::Request), + body: ((ctor State.ended (ctor Option.none [ResearchSession::State])), (ctor LexLeanStd.Host::Request.exit (0 : UInt8) (usage) 0x)), + axioms: [], + executable: true +} + +definition{ + name: start, + parameters: [incoming : LexLeanStd.Host::Start], + result: (State * LexLeanStd.Host::Request), + body: (match (project incoming arguments) | List.nil => (help) | List.cons path rest => (match rest | List.cons extra more => (error (ctor Option.none [ResearchSession::State]) (2 : UInt8) 0x65787065637465642065786163746c79206f6e6520617474656d707420726571756573742066696c65) | List.nil => (if ((Toml::sameBytes path 0x2d2d68656c70) || (Toml::sameBytes path 0x2d68)) then (help) else (if ((0 (match (Host::asStart event) | Option.none => (error (ctor Option.none [ResearchSession::State]) (70 : UInt8) 0x6578706563746564206e617469766520686f7374207374617274) | Option.some initialStart => (start initialStart)) | Option.some active => (match active | State.reading env => (readResult env event) | State.active session => (advanceSession (ResearchSession::step session (ctor ResearchSession::Event.host event))) | State.ended session => (error session (70 : UInt8) 0x636f6d706c6574656420726573656172636820636f6d6d616e642063616e6e6f742072657374617274))), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, files, overflow, process, recursion], targets: [rust-std]} +} + +definition{ + name: contract, + parameters: [], + result: String, + body: "A native Host command entry for one structured candidate attempt. It reads exactly one request file, admits its data without proof authority, and drives ResearchSession solely through actual Host replies. Checked output requires the session to retain proof evidence and release its workspace. A blocked attempt reports its recovery location. Terminal state cannot start another attempt. This command does not import receipts, publish claims, inspect premise provenance, or choose proof strategies. The caller supplies the pinned environment, repository and existing log parent directories.", + axioms: [], + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "native-host-entry" (cons "bounded-request-admission" (cons "owned-session-dispatch" (cons "structured-attempt-results" (cons "checked-output-after-retention" (cons "recovery-location-reporting" (cons "terminal-no-restart" (nil String)))))))), + axioms: [], + executable: true +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCommandTraces.lex.tex b/rule30-api/src/ResearchCommandTraces.lex.tex new file mode 100644 index 0000000..d53c33d --- /dev/null +++ b/rule30-api/src/ResearchCommandTraces.lex.tex @@ -0,0 +1,95 @@ +\begin{lexlean}{ResearchCommandTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{ResearchCommand} +\importmodule{ResearchInput} +\importmodule{ResearchInputTraces} +\importmodule{ResearchSession} +\importmodule{ResearchSessionTraces} +\importmodule{ResearchWorkspaceTraces} +\importmodule{ResearchRecord} +\importmodule{Json} +\importmodule{JsonCanonical} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} +definition{ + name: exitCode, + parameters: [result : (ResearchCommand::State * LexLeanStd.Host::Request)], + result: UInt8, + body: (match (second result) | LexLeanStd.Host::Request.read path => (255 : UInt8) | LexLeanStd.Host::Request.write path contents => (255 : UInt8) | LexLeanStd.Host::Request.list path => (255 : UInt8) | LexLeanStd.Host::Request.stat path => (255 : UInt8) | LexLeanStd.Host::Request.createDir path => (255 : UInt8) | LexLeanStd.Host::Request.removeFile path => (255 : UInt8) | LexLeanStd.Host::Request.removeTree path => (255 : UInt8) | LexLeanStd.Host::Request.rename source target => (255 : UInt8) | LexLeanStd.Host::Request.canonical path => (255 : UInt8) | LexLeanStd.Host::Request.lock path => (255 : UInt8) | LexLeanStd.Host::Request.spawn child => (255 : UInt8) | LexLeanStd.Host::Request.wait children duration => (255 : UInt8) | LexLeanStd.Host::Request.stop child => (255 : UInt8) | LexLeanStd.Host::Request.exit code output errors => code), + axioms: [] +} +definition{ + name: reading, + parameters: [result : (ResearchCommand::State * LexLeanStd.Host::Request)], + result: Bool, + body: (match (second result) | LexLeanStd.Host::Request.read path => (prim equal path "attempt.json" : Bool) | LexLeanStd.Host::Request.write path contents => false | LexLeanStd.Host::Request.list path => false | LexLeanStd.Host::Request.stat path => false | LexLeanStd.Host::Request.createDir path => false | LexLeanStd.Host::Request.removeFile path => false | LexLeanStd.Host::Request.removeTree path => false | LexLeanStd.Host::Request.rename source target => false | LexLeanStd.Host::Request.canonical path => false | LexLeanStd.Host::Request.lock path => false | LexLeanStd.Host::Request.spawn child => false | LexLeanStd.Host::Request.wait children duration => false | LexLeanStd.Host::Request.stop child => false | LexLeanStd.Host::Request.exit code output errors => false), + axioms: [] +} +definition{ + name: started, + parameters: [arguments : (List Bytes)], + result: LexLeanStd.Host::Event, + body: (ctor LexLeanStd.Host::Event.start (record LexLeanStd.Host::Start {arguments := arguments, directory := (ctor Result.ok [Bytes, LexLeanStd.Host::Failure] 0x2f776f726b), executable := (ctor Result.ok [Bytes, LexLeanStd.Host::Failure] 0x2f776f726b2f62696e2f723330), environment := (nil (Bytes * Bytes)), terminal := false})), + axioms: [] +} +definition{ + name: start, + parameters: [arguments : (List Bytes)], + result: (ResearchCommand::State * LexLeanStd.Host::Request), + body: (ResearchCommand::step (ctor Option.none [ResearchCommand::State]) (started arguments)), + axioms: [Quot.sound, propext] +} +theorem{ + name: helpHasNoSideEffects, + parameters: [], + statement: ((prim equal (exitCode (start (cons 0x2d2d68656c70 (nil Bytes)))) (0 : UInt8) : Bool) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: oneRequestStartsWithRead, + parameters: [], + statement: ((reading (start (cons 0x617474656d70742e6a736f6e (nil Bytes)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: extraArgumentRejected, + parameters: [], + statement: ((prim equal (exitCode (start (cons 0x617474656d70742e6a736f6e (cons 0x78 (nil Bytes))))) (2 : UInt8) : Bool) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: nonAsciiPathRejected, + parameters: [], + statement: ((prim equal (exitCode (start (cons 0xcebb2e6a736f6e (nil Bytes)))) (2 : UInt8) : Bool) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: malformedInputCannotSpawn, + parameters: [], + statement: ((prim equal (exitCode (ResearchCommand::readResult (nil (Bytes * Bytes)) (ResearchWorkspaceTraces::readEvent 0x7b))) (2 : UInt8) : Bool) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: wrongReadEventIsProtocolFailure, + parameters: [], + statement: ((prim equal (exitCode (ResearchCommand::readResult (nil (Bytes * Bytes)) (started (nil Bytes)))) (70 : UInt8) : Bool) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: terminalCannotRestart, + parameters: [], + statement: ((prim equal (exitCode (ResearchCommand::step (ctor Option.some [ResearchCommand::State] (ctor ResearchCommand::State.ended (ctor Option.none [ResearchSession::State]))) (started (cons 0x617474656d70742e6a736f6e (nil Bytes))))) (70 : UInt8) : Bool) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchEvidence.lex.tex b/rule30-api/src/ResearchEvidence.lex.tex new file mode 100644 index 0000000..d7a2f2c --- /dev/null +++ b/rule30-api/src/ResearchEvidence.lex.tex @@ -0,0 +1,283 @@ +\begin{lexlean}{ResearchEvidence} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{LexLeanStd.Sha256} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchExecution} +\importmodule{ResearchVerification} +\importmodule{ResearchWorkspace} +\importmodule{Json} +\importmodule{JsonCanonical} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: contract, + parameters: [], + result: String, + body: "Persist canonical evidence as a Git blob retained by a content-addressed ref. The caller owns the private record path and workspace; this component writes the exact record, hashes it locally, checks the stored blob before publication, retains the exact library commit under its own compare-and-swap ref and verifies that ref, creates the evidence ref with compare-and-swap against absence, and reads the published blob back byte for byte. An already published identical record is idempotent; another body or failed read is not success. Cancellation drains replies and supervises owned children. A blocked child or protocol failure retains recovery state. Storage is not proof verification: only the enclosing owned research session may promote verified evidence after persistence and workspace release.", + axioms: [], + executable: true +} + +structure{ + name: Config, + type_parameters: [], + parameters: [], + fields: [{name: request, type: Research::Request}, {name: repository, type: String}, {name: recordPath, type: String}, {name: environment, type: (List (String * String))}, {name: output, type: String}, {name: errors, type: String}, {name: maxBytes, type: Nat}, {name: maxSteps, type: Nat}, {name: allowance, type: Nat}, {name: quantum, type: Nat}, {name: polls, type: Nat}, {name: revision, type: Bytes}] +} + +inductive{ + name: Operation, + type_parameters: [], + parameters: [], + constructors: [{name: hash, fields: []}, {name: publish, fields: []}, {name: read, fields: []}, {name: inspect, fields: []}, {name: retainLibrary, fields: []}, {name: inspectLibrary, fields: []}] +} + +inductive{ + name: Phase, + type_parameters: [], + parameters: [], + constructors: [{name: writing, fields: []}, {name: executing, fields: []}, {name: readingHash, fields: []}, {name: readingRecord, fields: []}, {name: readingBlob, fields: []}, {name: ended, fields: []}, {name: blocked, fields: []}, {name: readingLibrary, fields: []}] +} + +structure{ + name: State, + type_parameters: [], + parameters: [], + fields: [{name: config, type: Config}, {name: body, type: Bytes}, {name: identity, type: Bytes}, {name: blob, type: Bytes}, {name: operation, type: Operation}, {name: phase, type: Phase}, {name: execution, type: (Option ResearchExecution::State)}, {name: cancelled, type: Bool}] +} + +inductive{ + name: Event, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Event]}, {name: cancel, fields: []}] +} + +inductive{ + name: Emission, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Request]}, {name: awaiting, fields: []}, {name: complete, fields: [Bytes]}, {name: failed, fields: [String]}, {name: cut, fields: []}, {name: blocked, fields: [String]}] +} + +definition{ + name: referencePath, + parameters: [state : State], + result: String, + body: (ResearchVerification::concat "refs/r30/evidence/" (Host::textOf (project state identity))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: libraryReference, + parameters: [state : State], + result: String, + body: (ResearchVerification::concat "refs/r30/libraries/" (Host::textOf (project (project state config) revision))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: zeroObject, + parameters: [blob : Bytes], + result: String, + body: (if ((prim length blob : Nat) =? 40) then "0000000000000000000000000000000000000000" else "0000000000000000000000000000000000000000000000000000000000000000"), + axioms: [], + executable: true +} + +definition{ + name: arguments, + parameters: [state : State, operation : Operation], + result: (List String), + body: (match operation | Operation.retainLibrary => (cons "update-ref" (cons (libraryReference state) (cons (Host::textOf (project (project state config) revision)) (cons (zeroObject (project (project state config) revision)) (nil String))))) | Operation.inspectLibrary => (cons "rev-parse" (cons "--verify" (cons (ResearchVerification::concat (libraryReference state) "^{commit}") (nil String)))) | Operation.hash => (cons "hash-object" (cons "-w" (cons "--" (cons (project (project state config) recordPath) (nil String))))) | Operation.publish => (cons "update-ref" (cons (referencePath state) (cons (Host::textOf (project state blob)) (cons (zeroObject (project state blob)) (nil String))))) | Operation.inspect => (cons "cat-file" (cons "blob" (cons (Host::textOf (project state blob)) (nil String)))) | Operation.read => (cons "cat-file" (cons "blob" (cons (referencePath state) (nil String))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: job, + parameters: [state : State, operation : Operation], + result: ResearchExecution::Job, + body: (record ResearchExecution::Job {request := (project (project state config) request), tool := (ctor ResearchExecution::Tool.git), arguments := (arguments state operation), directory := (project (project state config) repository), environment := (project (project state config) environment), output := (project (project state config) output), errors := (project (project state config) errors), allowance := (project (project state config) allowance), quantum := (project (project state config) quantum), polls := (project (project state config) polls)}), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: finish, + parameters: [state : State, emission : Emission], + result: (State * Emission), + body: ((record State {config := (project state config), body := (project state body), identity := (project state identity), blob := (project state blob), operation := (project state operation), phase := (ctor Phase.ended), execution := (ctor Option.none [ResearchExecution::State]), cancelled := (project state cancelled)}), emission), + axioms: [], + executable: true +} + +definition{ + name: blocked, + parameters: [state : State, reason : String], + result: (State * Emission), + body: ((record State {config := (project state config), body := (project state body), identity := (project state identity), blob := (project state blob), operation := (project state operation), phase := (ctor Phase.blocked), execution := (project state execution), cancelled := (project state cancelled)}), (ctor Emission.blocked reason)), + axioms: [], + executable: true +} + +definition{ + name: launch, + parameters: [state : State, operation : Operation], + result: (State * Emission), + body: (let result : (ResearchExecution::State * ResearchExecution::Emission) := (ResearchExecution::begin (job state operation)); (let next : State := (record State {config := (project state config), body := (project state body), identity := (project state identity), blob := (project state blob), operation := operation, phase := (ctor Phase.executing), execution := (ctor Option.some [ResearchExecution::State] (first result)), cancelled := (project state cancelled)}); (match (second result) | ResearchExecution::Emission.host request => (next, (ctor Emission.host request)) | ResearchExecution::Emission.awaiting => (blocked next "evidence job did not spawn") | ResearchExecution::Emission.complete completion => (blocked next "evidence job was refused")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: read, + parameters: [state : State, phase : Phase], + result: (State * Emission), + body: ((record State {config := (project state config), body := (project state body), identity := (project state identity), blob := (project state blob), operation := (project state operation), phase := phase, execution := (ctor Option.none [ResearchExecution::State]), cancelled := (project state cancelled)}), (ctor Emission.host (ctor LexLeanStd.Host::Request.read (project (project state config) output)))), + axioms: [], + executable: true +} + +definition{ + name: succeeded, + parameters: [state : State], + result: (State * Emission), + body: (match (project state operation) | Operation.retainLibrary => (launch state (ctor Operation.inspectLibrary)) | Operation.inspectLibrary => (read state (ctor Phase.readingLibrary)) | Operation.hash => (read state (ctor Phase.readingHash)) | Operation.inspect => (read state (ctor Phase.readingBlob)) | Operation.publish => (launch state (ctor Operation.read)) | Operation.read => (read state (ctor Phase.readingRecord))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: failed, + parameters: [state : State], + result: (State * Emission), + body: (match (project state operation) | Operation.retainLibrary => (launch state (ctor Operation.inspectLibrary)) | Operation.inspectLibrary => (finish state (ctor Emission.failed "library revision retention could not be verified")) | Operation.publish => (launch state (ctor Operation.read)) | Operation.hash => (finish state (ctor Emission.failed "evidence blob write failed")) | Operation.inspect => (finish state (ctor Emission.failed "written evidence blob read failed")) | Operation.read => (finish state (ctor Emission.failed "published evidence read failed"))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: completed, + parameters: [state : State, completion : ResearchExecution::Completion], + result: (State * Emission), + body: (if (ResearchExecution::resumeAllowed completion) then (if (project state cancelled) then (finish state (ctor Emission.cut)) else (if (ResearchWorkspace::exitedNormally completion) then (match (project completion kind) + | ResearchExecution::EndKind.succeeded => (succeeded state) + | ResearchExecution::EndKind.failed => (failed state) + | ResearchExecution::EndKind.cut => (finish state (ctor Emission.cut)) + | ResearchExecution::EndKind.unavailable => (finish state (ctor Emission.failed "evidence tool unavailable")) + | ResearchExecution::EndKind.protocol => (blocked state "evidence execution protocol failure") + | ResearchExecution::EndKind.cleanupFailed => (blocked state "evidence child cleanup failed") + | ResearchExecution::EndKind.refused => (blocked state "evidence execution refused")) else (blocked state "interrupted evidence tool retains workspace until descendant cleanup is established"))) else (blocked state "evidence child remains owned or protocol failed")), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: executionResult, + parameters: [state : State, result : (ResearchExecution::State * ResearchExecution::Emission)], + result: (State * Emission), + body: (let next : State := (record State {config := (project state config), body := (project state body), identity := (project state identity), blob := (project state blob), operation := (project state operation), phase := (ctor Phase.executing), execution := (ctor Option.some [ResearchExecution::State] (first result)), cancelled := (project state cancelled)}); (match (second result) | ResearchExecution::Emission.host request => (next, (ctor Emission.host request)) | ResearchExecution::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchExecution::Emission.complete completion => (completed next completion))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: finishedResponse, + parameters: [event : LexLeanStd.Host::Event], + result: (Option (Result Unit LexLeanStd.Host::Failure)), + body: (match event | LexLeanStd.Host::Event.start value => (ctor Option.none [(Result Unit LexLeanStd.Host::Failure)]) | LexLeanStd.Host::Event.read value => (ctor Option.none [(Result Unit LexLeanStd.Host::Failure)]) | LexLeanStd.Host::Event.finished value => (ctor Option.some [(Result Unit LexLeanStd.Host::Failure)] value) | LexLeanStd.Host::Event.listed value => (ctor Option.none [(Result Unit LexLeanStd.Host::Failure)]) | LexLeanStd.Host::Event.stat value => (ctor Option.none [(Result Unit LexLeanStd.Host::Failure)]) | LexLeanStd.Host::Event.canonical value => (ctor Option.none [(Result Unit LexLeanStd.Host::Failure)]) | LexLeanStd.Host::Event.spawned value => (ctor Option.none [(Result Unit LexLeanStd.Host::Failure)]) | LexLeanStd.Host::Event.waited value => (ctor Option.none [(Result Unit LexLeanStd.Host::Failure)])), + axioms: [], + executable: true +} + +definition{ + name: written, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (finishedResponse event) | Option.none => (blocked state "unexpected evidence write reply") | Option.some result => (if (project state cancelled) then (finish state (ctor Emission.cut)) else (match result | Result.error failure => (finish state (ctor Emission.failed "evidence record write failed")) | Result.ok unit => (launch state (ctor Operation.hash))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: hashRead, + parameters: [state : State, data : Bytes], + result: (State * Emission), + body: (let size : Nat := (prim length data : Nat); (if ((size =? 41) || (size =? 65)) then (let blob : Bytes := (Toml::sliceOr data 0 (prim subtract size 1 : Nat)); (if ((ResearchWorkspace::objectId blob) && (Toml::byteIs data (prim subtract size 1 : Nat) (10 : UInt8))) then (launch (record State {config := (project state config), body := (project state body), identity := (project state identity), blob := blob, operation := (project state operation), phase := (project state phase), execution := (project state execution), cancelled := (project state cancelled)}) (ctor Operation.inspect)) else (finish state (ctor Emission.failed "invalid evidence blob identity")))) else (finish state (ctor Emission.failed "invalid evidence blob identity")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: readResult, + parameters: [state : State, event : LexLeanStd.Host::Event, isHash : Bool], + result: (State * Emission), + body: (match (Host::asRead event) | Option.none => (blocked state "unexpected evidence read reply") | Option.some result => (if (project state cancelled) then (finish state (ctor Emission.cut)) else (match result | Result.error failure => (finish state (ctor Emission.failed "evidence output read failed")) | Result.ok data => (if isHash then (hashRead state data) else (if (Toml::sameBytes data (project state body)) then (match (project state phase) | Phase.readingBlob => (launch state (ctor Operation.retainLibrary)) | Phase.readingRecord => (finish state (ctor Emission.complete (project state identity))) | Phase.readingLibrary => (blocked state "unexpected evidence data phase") | Phase.writing => (blocked state "unexpected evidence data phase") | Phase.executing => (blocked state "unexpected evidence data phase") | Phase.readingHash => (blocked state "unexpected evidence data phase") | Phase.ended => (blocked state "unexpected evidence data phase") | Phase.blocked => (blocked state "unexpected evidence data phase")) else (finish state (ctor Emission.failed "stored evidence bytes differ"))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: cancel, + parameters: [state : State], + result: (State * Emission), + body: (let next : State := (record State {config := (project state config), body := (project state body), identity := (project state identity), blob := (project state blob), operation := (project state operation), phase := (project state phase), execution := (project state execution), cancelled := true}); (match (project state phase) | Phase.writing => (next, (ctor Emission.awaiting)) | Phase.readingHash => (next, (ctor Emission.awaiting)) | Phase.readingRecord => (next, (ctor Emission.awaiting)) | Phase.readingBlob => (next, (ctor Emission.awaiting)) | Phase.readingLibrary => (next, (ctor Emission.awaiting)) | Phase.executing => (match (project state execution) | Option.none => (blocked next "missing evidence child owner") | Option.some active => (executionResult next (ResearchExecution::cancel active))) | Phase.ended => (state, (ctor Emission.awaiting)) | Phase.blocked => (state, (ctor Emission.blocked "evidence lifecycle remains blocked")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: valid, + parameters: [state : State], + result: Bool, + body: ((ResearchWorkspace::objectId (project (project state config) revision)) && ((ResearchExecution::validJob (job state (ctor Operation.hash))) && ((ResearchVerification::nonempty (project (project state config) recordPath)) && ((not (prim equal (project (project state config) recordPath) (project (project state config) output) : Bool)) && ((not (prim equal (project (project state config) recordPath) (project (project state config) errors) : Bool)) && ((0 (finish state (ctor Emission.failed "evidence exceeds encoding limits")) | Option.some data => (let next : State := (record State {config := (project state config), body := data, identity := (LexLeanStd.Sha256::sha256Hex data), blob := (project state blob), operation := (project state operation), phase := (project state phase), execution := (project state execution), cancelled := (project state cancelled)}); (next, (ctor Emission.host (ctor LexLeanStd.Host::Request.write (project config recordPath) data))))) else (finish state (ctor Emission.failed "invalid evidence configuration")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: libraryRead, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (Host::asRead event) | Option.none => (blocked state "unexpected library reference reply") | Option.some result => (if (project state cancelled) then (finish state (ctor Emission.cut)) else (match result | Result.error failure => (finish state (ctor Emission.failed "library reference read failed")) | Result.ok data => (if (Toml::sameBytes data (prim append (project (project state config) revision) 0x0a : Bytes)) then (launch state (ctor Operation.publish)) else (finish state (ctor Emission.failed "retained library revision differs")))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: step, + parameters: [state : State, event : Event], + result: (State * Emission), + body: (match event | Event.cancel => (cancel state) | Event.host response => (match (project state phase) | Phase.writing => (written state response) | Phase.readingHash => (readResult state response true) | Phase.readingRecord => (readResult state response false) | Phase.readingBlob => (readResult state response false) | Phase.readingLibrary => (libraryRead state response) | Phase.executing => (match (project state execution) | Option.none => (blocked state "missing evidence child owner") | Option.some active => (executionResult state (ResearchExecution::step active response))) | Phase.ended => (state, (ctor Emission.awaiting)) | Phase.blocked => (state, (ctor Emission.blocked "evidence lifecycle remains blocked")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "normal-exit-before-retention" (cons "library-revision-gc-retention" (cons "canonical-evidence-record" (cons "content-addressed-retention" (cons "compare-and-swap-publication" (cons "readback-before-completion" (cons "idempotent-identical-record" (cons "drain-before-cancellation" (cons "storage-is-not-proof" (nil String)))))))))), + axioms: [], + executable: true +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchEvidenceTraces.lex.tex b/rule30-api/src/ResearchEvidenceTraces.lex.tex new file mode 100644 index 0000000..bc321d5 --- /dev/null +++ b/rule30-api/src/ResearchEvidenceTraces.lex.tex @@ -0,0 +1,319 @@ +\begin{lexlean}{ResearchEvidenceTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{ResearchEvidence} +\importmodule{ResearchWorkspaceTraces} +\importmodule{ResearchWorkspace} +\importmodule{ResearchExecution} +\importmodule{ResearchExecutionTraces} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: config, + parameters: [], + result: ResearchEvidence::Config, + body: (record ResearchEvidence::Config {request := (project (ResearchWorkspaceTraces::config) request), repository := "/research", recordPath := "/research/.r30/private/evidence.json", environment := (nil (String * String)), output := "/research/.r30/evidence.out", errors := "/research/.r30/evidence.err", maxBytes := 4096, maxSteps := 1024, allowance := 1000, quantum := 10, polls := 100, revision := (ResearchWorkspaceTraces::tree)}), + axioms: [] +} + +definition{ + name: writing, + parameters: [], + result: ResearchEvidence::State, + body: (record ResearchEvidence::State {config := (config), body := 0x7b7d0a, identity := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161, blob := 0x, operation := (ctor ResearchEvidence::Operation.hash), phase := (ctor ResearchEvidence::Phase.writing), execution := (ctor Option.none [ResearchExecution::State]), cancelled := false}), + axioms: [] +} + +definition{ + name: host, + parameters: [state : ResearchEvidence::State, event : LexLeanStd.Host::Event], + result: (ResearchEvidence::State * ResearchEvidence::Emission), + body: (ResearchEvidence::step state (ctor ResearchEvidence::Event.host event)), + axioms: [Quot.sound, propext] +} + +definition{ + name: written, + parameters: [], + result: LexLeanStd.Host::Event, + body: (ctor LexLeanStd.Host::Event.finished (ctor Result.ok [Unit, LexLeanStd.Host::Failure] ())), + axioms: [] +} + +definition{ + name: spawned, + parameters: [state : ResearchEvidence::State], + result: ResearchEvidence::State, + body: (first (host (first (host state (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100))))), + axioms: [Quot.sound, propext] +} + +definition{ + name: finishJob, + parameters: [state : ResearchEvidence::State, code : Int32], + result: (ResearchEvidence::State * ResearchEvidence::Emission), + body: (host (spawned state) (ResearchExecutionTraces::exitEvent 7 (ctor Option.some [Int32] code) 101)), + axioms: [Quot.sound, propext] +} + +definition{ + name: hashing, + parameters: [], + result: ResearchEvidence::State, + body: (first (host (writing) (written))), + axioms: [Quot.sound, propext] +} + +definition{ + name: readingHash, + parameters: [], + result: ResearchEvidence::State, + body: (first (finishJob (hashing) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: hashReply, + parameters: [], + result: LexLeanStd.Host::Event, + body: (ResearchWorkspaceTraces::readEvent (prim append (ResearchWorkspaceTraces::tree) 0x0a : Bytes)), + axioms: [] +} + +definition{ + name: readingBlob, + parameters: [], + result: ResearchEvidence::State, + body: (first (finishJob (first (host (readingHash) (hashReply))) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: retainingLibrary, + parameters: [], + result: ResearchEvidence::State, + body: (first (host (readingBlob) (ResearchWorkspaceTraces::readEvent 0x7b7d0a))), + axioms: [Quot.sound, propext] +} + +definition{ + name: readingLibrary, + parameters: [retainExit : Int32], + result: ResearchEvidence::State, + body: (first (finishJob (first (finishJob (retainingLibrary) retainExit)) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: publishing, + parameters: [], + result: ResearchEvidence::State, + body: (first (host (readingLibrary (0 : Int32)) (hashReply))), + axioms: [Quot.sound, propext] +} + +definition{ + name: readingPublished, + parameters: [publishExit : Int32], + result: ResearchEvidence::State, + body: (first (finishJob (first (finishJob (publishing) publishExit)) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: complete, + parameters: [result : (ResearchEvidence::State * ResearchEvidence::Emission)], + result: Bool, + body: (match (second result) | ResearchEvidence::Emission.complete identity => (Toml::sameBytes identity (project (writing) identity)) | ResearchEvidence::Emission.host request => false | ResearchEvidence::Emission.awaiting => false | ResearchEvidence::Emission.failed reason => false | ResearchEvidence::Emission.cut => false | ResearchEvidence::Emission.blocked reason => false), + axioms: [] +} + +definition{ + name: failed, + parameters: [result : (ResearchEvidence::State * ResearchEvidence::Emission)], + result: Bool, + body: (match (second result) | ResearchEvidence::Emission.complete identity => false | ResearchEvidence::Emission.host request => false | ResearchEvidence::Emission.awaiting => false | ResearchEvidence::Emission.failed reason => true | ResearchEvidence::Emission.cut => false | ResearchEvidence::Emission.blocked reason => false), + axioms: [] +} + +definition{ + name: cut, + parameters: [result : (ResearchEvidence::State * ResearchEvidence::Emission)], + result: Bool, + body: (match (second result) | ResearchEvidence::Emission.complete identity => false | ResearchEvidence::Emission.host request => false | ResearchEvidence::Emission.awaiting => false | ResearchEvidence::Emission.failed reason => false | ResearchEvidence::Emission.cut => true | ResearchEvidence::Emission.blocked reason => false), + axioms: [] +} + +definition{ + name: blocked, + parameters: [result : (ResearchEvidence::State * ResearchEvidence::Emission)], + result: Bool, + body: (match (second result) | ResearchEvidence::Emission.complete identity => false | ResearchEvidence::Emission.host request => false | ResearchEvidence::Emission.awaiting => false | ResearchEvidence::Emission.failed reason => false | ResearchEvidence::Emission.cut => false | ResearchEvidence::Emission.blocked reason => true), + axioms: [] +} + +theorem{ + name: publishedBytesCompleteStorage, + parameters: [], + statement: ((complete (host (readingPublished (0 : Int32)) (ResearchWorkspaceTraces::readEvent 0x7b7d0a))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: identicalExistingRecordIsIdempotent, + parameters: [], + statement: ((complete (host (readingPublished (1 : Int32)) (ResearchWorkspaceTraces::readEvent 0x7b7d0a))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: changedPrivateBlobIsRefusedBeforePublication, + parameters: [], + statement: ((failed (host (readingBlob) (ResearchWorkspaceTraces::readEvent 0x77726f6e67))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: changedPublishedRecordCannotComplete, + parameters: [], + statement: ((failed (host (readingPublished (0 : Int32)) (ResearchWorkspaceTraces::readEvent 0x77726f6e67))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedPublicationWithoutReadableRecordCannotComplete, + parameters: [], + statement: ((failed (finishJob (first (finishJob (publishing) (1 : Int32))) (1 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: invalidObjectIdentityIsRefused, + parameters: [], + statement: ((failed (host (readingHash) (ResearchWorkspaceTraces::readEvent 0x2d2d0a))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledWriteDrainsWithoutStartingGit, + parameters: [], + statement: ((cut (host (first (ResearchEvidence::step (writing) (ctor ResearchEvidence::Event.cancel))) (written))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledHashReadDoesNotPublish, + parameters: [], + statement: ((cut (host (first (ResearchEvidence::step (readingHash) (ctor ResearchEvidence::Event.cancel))) (hashReply))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledReadbackCannotComplete, + parameters: [], + statement: ((cut (host (first (ResearchEvidence::step (readingPublished (0 : Int32)) (ctor ResearchEvidence::Event.cancel))) (ResearchWorkspaceTraces::readEvent 0x7b7d0a))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: wrongWriteReplyBlocks, + parameters: [], + statement: ((blocked (host (writing) (ResearchWorkspaceTraces::readEvent 0x7b7d0a))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: cancelledChild, + parameters: [], + result: ResearchEvidence::State, + body: (first (host (first (ResearchEvidence::step (spawned (hashing)) (ctor ResearchEvidence::Event.cancel))) (ResearchExecutionTraces::waitEvent 101 (nil (Nat * (Option Int32)))))), + axioms: [Quot.sound, propext] +} + +definition{ + name: ownsChild, + parameters: [state : ResearchEvidence::State], + result: Bool, + body: (match (project state execution) | Option.none => false | Option.some active => (match (project active owner) | Option.none => false | Option.some owner => (owner =? 7))), + axioms: [] +} + +definition{ + name: failedCleanup, + parameters: [], + result: (ResearchEvidence::State * ResearchEvidence::Emission), + body: (host (cancelledChild) (ctor LexLeanStd.Host::Event.finished (ctor Result.error [Unit, LexLeanStd.Host::Failure] (ResearchExecutionTraces::failedHost)))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedCleanupRetainsChild, + parameters: [], + statement: (((blocked (failedCleanup)) && (ownsChild (first (failedCleanup)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: substitutedLibraryRevisionPreventsPublication, + parameters: [], + statement: ((failed (host (readingLibrary (0 : Int32)) (ResearchWorkspaceTraces::readEvent 0x77726f6e670a))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: identicalRetainedLibraryIsIdempotent, + parameters: [], + statement: ((match (project (first (host (readingLibrary (1 : Int32)) (hashReply))) operation) | ResearchEvidence::Operation.publish => true | ResearchEvidence::Operation.hash => false | ResearchEvidence::Operation.read => false | ResearchEvidence::Operation.inspect => false | ResearchEvidence::Operation.retainLibrary => false | ResearchEvidence::Operation.inspectLibrary => false) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledLibraryReadCannotPublishProof, + parameters: [], + statement: ((cut (host (first (ResearchEvidence::step (readingLibrary (0 : Int32)) (ctor ResearchEvidence::Event.cancel))) (hashReply))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + + +theorem{ + name: signalledBlobWriteBlocks, + parameters: [], + statement: ((blocked (host (spawned (hashing)) (ResearchExecutionTraces::exitEvent 7 (ctor Option.none [Int32]) 101))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: signalledLibraryRetentionBlocks, + parameters: [], + statement: ((blocked (host (spawned (retainingLibrary)) (ResearchExecutionTraces::exitEvent 7 (ctor Option.none [Int32]) 101))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: signalledPublicationCannotProceedToReadback, + parameters: [], + statement: ((blocked (host (spawned (publishing)) (ResearchExecutionTraces::exitEvent 7 (ctor Option.none [Int32]) 101))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchExecution.lex.tex b/rule30-api/src/ResearchExecution.lex.tex index faaf55a..ad0a148 100644 --- a/rule30-api/src/ResearchExecution.lex.tex +++ b/rule30-api/src/ResearchExecution.lex.tex @@ -9,7 +9,7 @@ name: boundary, parameters: [], result: String, - body: "This supervisor performs one local tool job through LexLeanStd.Host. A completion is process evidence, never a Research checked result. The caller must validate the tool's report, exact contextual target, kernel replay, axiom policy and snapshot before constructing a proof answer. The driver must honor timed waits and stop ownership; a failed stop blocks further work. Poll fuel also bounds a host clock that stops advancing. Tool executables resolve in the caller's pinned tool environment. No model service is a tool.", + body: "This supervisor performs one local tool job through LexLeanStd.Host. A completion is process evidence, never a Research checked result. The caller must validate the tool's report, exact contextual target, kernel replay, axiom policy and snapshot before constructing a proof answer. The driver must honor timed waits and stop ownership; a failed stop blocks further work. Before spawning, an empty zero-budget wait obtains the monotonic host clock. The second spawn result is an OS process ID, never a timestamp. Spawn latency counts against the job allowance. Cancellation drains the initial clock read before any spawn. Poll fuel also bounds a host clock that stops advancing. Tool executables resolve in the caller's pinned tool environment. No model service is a tool.", executable: true } @@ -53,7 +53,7 @@ name: Phase, type_parameters: [], parameters: [], - constructors: [{name: spawning, fields: []}, {name: cancelledSpawn, fields: []}, {name: cancelledWait, fields: [Nat, Nat]}, {name: waiting, fields: [Nat, Nat, Nat, Nat]}, {name: stopping, fields: [EndKind, Nat, Bytes]}, {name: ended, fields: [Completion]}] + constructors: [{name: spawning, fields: [Nat]}, {name: cancelledSpawn, fields: [Nat]}, {name: cancelledWait, fields: [Nat, Nat]}, {name: waiting, fields: [Nat, Nat, Nat, Nat]}, {name: stopping, fields: [EndKind, Nat, Bytes]}, {name: ended, fields: [Completion]}, {name: clock, fields: []}, {name: cancelledClock, fields: []}] } structure{ @@ -86,11 +86,19 @@ executable: true } +definition{ + name: spawn, + parameters: [job : Job, started : Nat], + result: (State * Emission), + body: ((record State {job := job, phase := (ctor Phase.spawning started), owner := (ctor Option.none [Nat])}), (ctor Emission.host (ctor LexLeanStd.Host::Request.spawn (record LexLeanStd.Host::Child {program := (program (project job tool)), arguments := (project job arguments), directory := (project job directory), environment := (project job environment), output := (project job output), errors := (project job errors)})))), + executable: true +} + definition{ name: begin, parameters: [job : Job], result: (State * Emission), - body: (if (validJob job) then ((record State {job := job, phase := (ctor Phase.spawning), owner := (ctor Option.none [Nat])}), (ctor Emission.host (ctor LexLeanStd.Host::Request.spawn (record LexLeanStd.Host::Child {program := (program (project job tool)), arguments := (project job arguments), directory := (project job directory), environment := (project job environment), output := (project job output), errors := (project job errors)})))) else (finish job (ctor EndKind.refused) (ctor Option.none [Int32]) 0 0x696e76616c6964206a6f62)), + body: (if (validJob job) then ((record State {job := job, phase := (ctor Phase.clock), owner := (ctor Option.none [Nat])}), (ctor Emission.host (ctor LexLeanStd.Host::Request.wait (nil Nat) 0))) else (finish job (ctor EndKind.refused) (ctor Option.none [Int32]) 0 0x696e76616c6964206a6f62)), axioms: [], executable: true, production: {effects: [allocation, overflow, process, recursion], targets: [rust-std]} @@ -167,11 +175,11 @@ definition{ name: spawned, - parameters: [job : Job, outcome : (Result (Nat * Nat) LexLeanStd.Host::Failure)], + parameters: [job : Job, started : Nat, outcome : (Result (Nat * Nat) LexLeanStd.Host::Failure)], result: (State * Emission), body: (match outcome - | Result.error failure => (finish job (ctor EndKind.unavailable) (ctor Option.none [Int32]) 0 (project failure message)) - | Result.ok child => (waitFor job (first child) (second child) (second child) (project job polls))), + | Result.error failure => (finish job (ctor EndKind.unavailable) (ctor Option.none [Int32]) started (project failure message)) + | Result.ok child => (waitFor job (first child) started started (project job polls))), executable: true } @@ -233,22 +241,32 @@ executable: true } +definition{ + name: clocked, + parameters: [job : Job, cancelled : Bool, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (asWaited event) | Option.none => (finish job (ctor EndKind.protocol) (ctor Option.none [Int32]) 0 0x657870656374656420636c6f636b) | Option.some outcome => (match outcome | Result.error failure => (finish job (if cancelled then (ctor EndKind.cut) else (ctor EndKind.unavailable)) (ctor Option.none [Int32]) 0 (project failure message)) | Result.ok response => (match (project response finished) | List.nil => (if cancelled then (finish job (ctor EndKind.cut) (ctor Option.none [Int32]) (project response clock) 0x63616e63656c6c6564) else (spawn job (project response clock))) | List.cons head rest => (finish job (ctor EndKind.protocol) (ctor Option.none [Int32]) (project response clock) 0x756e657870656374656420636c6f636b206368696c64)))), + executable: true +} + definition{ name: advance, parameters: [state : State, event : LexLeanStd.Host::Event], result: (State * Emission), body: (let job : Job := (project state job); (match (project state phase) | Phase.ended result => (state, (ctor Emission.complete result)) - | Phase.cancelledSpawn => (match (asSpawned event) + | Phase.clock => (clocked job false event) + | Phase.cancelledClock => (clocked job true event) + | Phase.cancelledSpawn started => (match (asSpawned event) | Option.some outcome => (match outcome - | Result.ok child => (stopFor job (first child) (second child) (ctor EndKind.cut) 0x63616e63656c6c6564) + | Result.ok child => (stopFor job (first child) started (ctor EndKind.cut) 0x63616e63656c6c6564) | Result.error failure => (finish job (ctor EndKind.cut) (ctor Option.none [Int32]) 0 (project failure message))) | Option.none => (finish job (ctor EndKind.protocol) (ctor Option.none [Int32]) 0 0x657870656374656420737061776e)) | Phase.cancelledWait child clock => (match (asWaited event) | Option.some outcome => (cancelledReply job child clock outcome) | Option.none => (stopFor job child clock (ctor EndKind.protocol) 0x65787065637465642077616974)) - | Phase.spawning => (match (asSpawned event) - | Option.some outcome => (spawned job outcome) + | Phase.spawning started => (match (asSpawned event) + | Option.some outcome => (spawned job started outcome) | Option.none => (finish job (ctor EndKind.protocol) (ctor Option.none [Int32]) 0 0x657870656374656420737061776e)) | Phase.waiting child started previous polls => (match (asWaited event) | Option.some outcome => (waited job child started previous polls outcome) @@ -258,11 +276,27 @@ | Option.none => (finish job (ctor EndKind.cleanupFailed) (ctor Option.none [Int32]) clock 0x65787065637465642073746f70)))), executable: true } +definition{ + name: resumeAllowed, + parameters: [completion : Completion], + result: Bool, + body: (match (project completion kind) + | EndKind.succeeded => true + | EndKind.failed => true + | EndKind.cut => true + | EndKind.unavailable => true + | EndKind.protocol => false + | EndKind.cleanupFailed => false + | EndKind.refused => false), + executable: true +} + + definition{ name: step, parameters: [state : State, event : LexLeanStd.Host::Event], result: (State * Emission), - body: (let result : (State * Emission) := (advance state event); ((record State {job := (project (first result) job), phase := (project (first result) phase), owner := (match (project (first result) owner) | Option.some child => (ctor Option.some [Nat] child) | Option.none => (project state owner))}), (second result))), + body: (let result : (State * Emission) := (advance state event); (let next : State := (first result); (let held : (Option Nat) := (match (project next owner) | Option.some child => (ctor Option.some [Nat] child) | Option.none => (project state owner)); ((record State {job := (project next job), phase := (project next phase), owner := (match (project next phase) | Phase.ended completion => (if (resumeAllowed completion) then (ctor Option.none [Nat]) else held) | Phase.clock => held | Phase.cancelledClock => held | Phase.spawning started => held | Phase.cancelledSpawn started => held | Phase.waiting child started clock polls => held | Phase.cancelledWait child clock => held | Phase.stopping kind clock detail => held)}), (second result))))), axioms: [], executable: true, production: {effects: [allocation, overflow, process, recursion], targets: [rust-std]} @@ -273,8 +307,10 @@ parameters: [state : State], result: (State * Emission), body: (match (project state phase) - | Phase.spawning => ((record State {job := (project state job), phase := (ctor Phase.cancelledSpawn), owner := (project state owner)}), (ctor Emission.awaiting)) - | Phase.cancelledSpawn => (state, (ctor Emission.awaiting)) + | Phase.clock => ((record State {job := (project state job), phase := (ctor Phase.cancelledClock), owner := (project state owner)}), (ctor Emission.awaiting)) + | Phase.cancelledClock => (state, (ctor Emission.awaiting)) + | Phase.spawning started => ((record State {job := (project state job), phase := (ctor Phase.cancelledSpawn started), owner := (project state owner)}), (ctor Emission.awaiting)) + | Phase.cancelledSpawn started => (state, (ctor Emission.awaiting)) | Phase.waiting child started clock polls => ((record State {job := (project state job), phase := (ctor Phase.cancelledWait child clock), owner := (project state owner)}), (ctor Emission.awaiting)) | Phase.cancelledWait child clock => (state, (ctor Emission.awaiting)) | Phase.stopping reason clock detail => (state, (ctor Emission.awaiting)) @@ -282,20 +318,6 @@ executable: true } -definition{ - name: resumeAllowed, - parameters: [completion : Completion], - result: Bool, - body: (match (project completion kind) - | EndKind.succeeded => true - | EndKind.failed => true - | EndKind.cut => true - | EndKind.unavailable => true - | EndKind.protocol => false - | EndKind.cleanupFailed => false - | EndKind.refused => false), - executable: true -} theorem{ name: completionKeepsRequestCustody, @@ -310,5 +332,14 @@ statement: ((resumeAllowed (record Completion {request := request, kind := (ctor EndKind.cleanupFailed), code := code, clock := clock, output := output, errors := errors, detail := detail})) = false), proof: reflexivity{} } +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "clock-before-spawn" (cons "process-id-is-not-time" (cons "spawn-latency-budget" (cons "bounded-timed-wait" (cons "drain-before-stop" (cons "terminal-child-ownership" (cons "cleanup-failure-retention" (nil String)))))))), + axioms: [], + executable: true +} + \end{semanticmodule} \end{lexlean} diff --git a/rule30-api/src/ResearchExecutionTraces.lex.tex b/rule30-api/src/ResearchExecutionTraces.lex.tex index ed970c3..7512af7 100644 --- a/rule30-api/src/ResearchExecutionTraces.lex.tex +++ b/rule30-api/src/ResearchExecutionTraces.lex.tex @@ -3,16 +3,22 @@ \useglossary{lexlean.std.nat@1.2.0} \importmodule{LexLeanStd.Host} \importmodule{Research} -\importmodule{ResearchTraces} \importmodule{ResearchExecution} \title{Boolean} \begin{semanticmodule} +definition{ + name: fixtureRequest, + parameters: [], + result: Research::Request, + body: (record Research::Request {serial := 1, snapshot := (record Research::Snapshot {library := 0x6c, compiler := 0x63, model := 0x6d}), task := (record Research::Task {id := 0x61, purpose := (ctor Research::Purpose.prove), intent := (ctor Research::Purpose.prove), status := (ctor Research::Status.ready), component := "deduction", sources := (cons 0x74 (nil Bytes)), schema := 0x73, sequent := (record Research::Sequent {origin := 0x74, theorem := 0x74, premise := 0, telescope := 0x47, target := 0x4861, kind := (ctor Research::GoalKind.premise)}), age := 0, weight := 8})}), + axioms: [] +} definition{ name: job, parameters: [allowance : Nat, quantum : Nat, polls : Nat], result: ResearchExecution::Job, - body: (record ResearchExecution::Job {request := (ResearchTraces::request (ctor Research::Purpose.prove)), tool := (ctor ResearchExecution::Tool.lean), arguments := (cons "Candidate.lean" (nil String)), directory := "/research", environment := (nil (String * String)), output := "attempt.out", errors := "attempt.err", allowance := allowance, quantum := quantum, polls := polls}) + body: (record ResearchExecution::Job {request := (fixtureRequest), tool := (ctor ResearchExecution::Tool.lean), arguments := (cons "Candidate.lean" (nil String)), directory := "/research", environment := (nil (String * String)), output := "attempt.out", errors := "attempt.err", allowance := allowance, quantum := quantum, polls := polls}) } definition{ @@ -26,7 +32,7 @@ name: active, parameters: [allowance : Nat, quantum : Nat, polls : Nat], result: ResearchExecution::State, - body: (first (ResearchExecution::spawned (job allowance quantum polls) (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100)))) + body: (first (ResearchExecution::spawned (job allowance quantum polls) 100 (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 99999)))) } definition{ @@ -123,21 +129,21 @@ theorem{ name: spawnFailureIsUnavailable, parameters: [], - statement: ((kindOf (ResearchExecution::spawned (job 10 4 3) (ctor Result.error [(Nat * Nat), LexLeanStd.Host::Failure] (failedHost)))) = 3), + statement: ((kindOf (ResearchExecution::spawned (job 10 4 3) 100 (ctor Result.error [(Nat * Nat), LexLeanStd.Host::Failure] (failedHost)))) = 3), proof: decide{} } theorem{ name: waitNeverExceedsBudget, parameters: [], - statement: ((waitDuration (ResearchExecution::spawned (job 10 100 3) (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100)))) = 10), + statement: ((waitDuration (ResearchExecution::spawned (job 10 100 3) 100 (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 99999)))) = 10), proof: decide{} } theorem{ name: relativeBudgetNeedsNoClockAddition, parameters: [], - statement: ((waitDuration (ResearchExecution::spawned (job 10 100 3) (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 18446744073709551610)))) = 10), + statement: ((waitDuration (ResearchExecution::spawned (job 10 100 3) 18446744073709551610 (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 99999)))) = 10), proof: decide{} } @@ -235,7 +241,7 @@ theorem{ name: aDelayedSpawnAfterCancellationIsStopped, parameters: [], - statement: ((stopTarget (ResearchExecution::step (first (ResearchExecution::cancel (first (ResearchExecution::begin (job 10 4 3))))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100))))) = 7), + statement: ((stopTarget (ResearchExecution::step (first (ResearchExecution::cancel (first (ResearchExecution::spawn (job 10 4 3) 100)))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 99999))))) = 7), proof: decide{} } @@ -263,7 +269,42 @@ theorem{ name: completedJobCannotBeRestartedByAnEvent, parameters: [], - statement: ((kindOf (ResearchExecution::step (first (ResearchExecution::step (active 10 4 3) (exitEvent 7 (ctor Option.some [Int32] (0 : Int32)) 105))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100))))) = 0), + statement: ((kindOf (ResearchExecution::step (first (ResearchExecution::step (active 10 4 3) (exitEvent 7 (ctor Option.some [Int32] (0 : Int32)) 105))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 99999))))) = 0), + proof: decide{} +} + +theorem{ + name: processIdIsNotUsedAsAClock, + parameters: [], + statement: ((ResearchExecution::spawned (job 10 4 3) 100 (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 99999))) = (ResearchExecution::waitFor (job 10 4 3) 7 100 100 3)), + proof: reflexivity{} +} + +theorem{ + name: beginReadsClockBeforeSpawning, + parameters: [], + statement: ((second (ResearchExecution::begin (job 10 4 3))) = (ctor ResearchExecution::Emission.host (ctor LexLeanStd.Host::Request.wait (nil Nat) 0))), + proof: reflexivity{} +} + +theorem{ + name: cancelledInitialClockNeverSpawns, + parameters: [], + statement: ((kindOf (ResearchExecution::step (first (ResearchExecution::cancel (first (ResearchExecution::begin (job 10 4 3))))) (waitEvent 100 (nil (Nat * (Option Int32)))))) = 2), + proof: decide{} +} + +theorem{ + name: unsolicitedChildOnClockReadIsRefused, + parameters: [], + statement: ((kindOf (ResearchExecution::step (first (ResearchExecution::begin (job 10 4 3))) (exitEvent 7 (ctor Option.some [Int32] (0 : Int32)) 100))) = 4), + proof: decide{} +} + +theorem{ + name: normalExitReleasesDirectChildOwnership, + parameters: [], + statement: ((project (first (ResearchExecution::step (active 10 4 3) (exitEvent 7 (ctor Option.some [Int32] (0 : Int32)) 105))) owner) = (ctor Option.none [Nat])), proof: decide{} } diff --git a/rule30-api/src/ResearchInput.lex.tex b/rule30-api/src/ResearchInput.lex.tex new file mode 100644 index 0000000..6cfc757 --- /dev/null +++ b/rule30-api/src/ResearchInput.lex.tex @@ -0,0 +1,226 @@ +\begin{lexlean}{ResearchInput} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchWorkspace} +\importmodule{ResearchProject} +\importmodule{ResearchCandidate} +\importmodule{CoreBinding} +\importmodule{CoreNotation} +\importmodule{Json} +\importmodule{VerificationReport} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: bytes, + parameters: [value : Json::Value], + result: (Option Bytes), + body: (match value | Json::Value.null => (ctor Option.none [Bytes]) | Json::Value.boolean b => (ctor Option.none [Bytes]) | Json::Value.number n => (ctor Option.none [Bytes]) | Json::Value.string s => (ctor Option.some [Bytes] s) | Json::Value.array a => (ctor Option.none [Bytes]) | Json::Value.object o => (ctor Option.none [Bytes])), + axioms: [], + executable: true +} + +definition{ + name: stringIs, + parameters: [value : Json::Value, expected : Bytes], + result: Bool, + body: (match (bytes value) | Option.none => false | Option.some data => (Toml::sameBytes data expected)), + axioms: [], + executable: true +} + +definition{ + name: array, + parameters: [value : Json::Value], + result: (Option (List Json::Value)), + body: (match value | Json::Value.null => (ctor Option.none [(List Json::Value)]) | Json::Value.boolean b => (ctor Option.none [(List Json::Value)]) | Json::Value.number n => (ctor Option.none [(List Json::Value)]) | Json::Value.string s => (ctor Option.none [(List Json::Value)]) | Json::Value.array a => (ctor Option.some [(List Json::Value)] a) | Json::Value.object o => (ctor Option.none [(List Json::Value)])), + axioms: [], + executable: true +} + +definition{ + name: text, + parameters: [value : Json::Value], + result: (Option String), + body: (match (bytes value) | Option.none => (ctor Option.none [String]) | Option.some data => (if (ResearchWorkspace::asciiPath data 0 (prim length data : Nat)) then (ctor Option.some [String] (Host::textOf data)) else (ctor Option.none [String]))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: byteItems, + parameters: [values : (List Json::Value)], + result: (Option (List Bytes)), + body: (match values | List.nil => (ctor Option.some [(List Bytes)] (nil Bytes)) | List.cons head tail => (match (bytes head) | Option.none => (ctor Option.none [(List Bytes)]) | Option.some item => (match (byteItems tail) | Option.none => (ctor Option.none [(List Bytes)]) | Option.some rest => (ctor Option.some [(List Bytes)] (cons item rest))))), + axioms: [], + recursive_argument: values, + executable: true +} + +definition{ + name: byteList, + parameters: [value : Json::Value], + result: (Option (List Bytes)), + body: (match (array value) | Option.none => (ctor Option.none [(List Bytes)]) | Option.some values => (byteItems values)), + axioms: [], + executable: true +} + +definition{ + name: textItems, + parameters: [values : (List Json::Value)], + result: (Option (List String)), + body: (match values | List.nil => (ctor Option.some [(List String)] (nil String)) | List.cons head tail => (match (text head) | Option.none => (ctor Option.none [(List String)]) | Option.some item => (match (textItems tail) | Option.none => (ctor Option.none [(List String)]) | Option.some rest => (ctor Option.some [(List String)] (cons item rest))))), + axioms: [Quot.sound, propext], + recursive_argument: values, + executable: true +} + +definition{ + name: textList, + parameters: [value : Json::Value], + result: (Option (List String)), + body: (match (array value) | Option.none => (ctor Option.none [(List String)]) | Option.some values => (textItems values)), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: environment, + parameters: [values : (List (Bytes * Bytes))], + result: (Option (List (String * String))), + body: (match values | List.nil => (ctor Option.some [(List (String * String))] (nil (String * String))) | List.cons head tail => (if ((ResearchWorkspace::asciiPath (first head) 0 (prim length (first head) : Nat)) && (ResearchWorkspace::asciiPath (second head) 0 (prim length (second head) : Nat))) then (match (environment tail) | Option.none => (ctor Option.none [(List (String * String))]) | Option.some rest => (ctor Option.some [(List (String * String))] (cons ((Host::textOf (first head)), (Host::textOf (second head))) rest))) else (ctor Option.none [(List (String * String))]))), + axioms: [Quot.sound, propext], + recursive_argument: values, + executable: true +} + +definition{ + name: purposeOf, + parameters: [value : Json::Value], + result: (Option Research::Purpose), + body: (if (stringIs value 0x70726f7665) then (ctor Option.some [Research::Purpose] (ctor Research::Purpose.prove)) else (if (stringIs value 0x726566757465) then (ctor Option.some [Research::Purpose] (ctor Research::Purpose.refute)) else (ctor Option.none [Research::Purpose]))), + axioms: [], + executable: true +} + +definition{ + name: goalKind, + parameters: [value : Json::Value], + result: (Option Research::GoalKind), + body: (if (stringIs value 0x636c6f736564) then (ctor Option.some [Research::GoalKind] (ctor Research::GoalKind.closed)) else (if (stringIs value 0x7072656d697365) then (ctor Option.some [Research::GoalKind] (ctor Research::GoalKind.premise)) else (ctor Option.none [Research::GoalKind]))), + axioms: [], + executable: true +} + +definition{ + name: snapshot, + parameters: [value : Json::Value], + result: (Option Research::Snapshot), + body: (if (CoreNotation::shape value (cons 0x6c696272617279 (cons 0x636f6d70696c6572 (cons 0x6d6f64656c (nil Bytes))))) then (if ((VerificationReport::digest (VerificationReport::bytes (CoreBinding::get value 0x636f6d70696c6572))) && (VerificationReport::digest (VerificationReport::bytes (CoreBinding::get value 0x6d6f64656c)))) then (match (bytes (CoreBinding::get value 0x6c696272617279)) | Option.none => (ctor Option.none [Research::Snapshot]) | Option.some library => (match (bytes (CoreBinding::get value 0x636f6d70696c6572)) | Option.none => (ctor Option.none [Research::Snapshot]) | Option.some compiler => (match (bytes (CoreBinding::get value 0x6d6f64656c)) | Option.none => (ctor Option.none [Research::Snapshot]) | Option.some model => (ctor Option.some [Research::Snapshot] (record Research::Snapshot {library := library, compiler := compiler, model := model}))))) else (ctor Option.none [Research::Snapshot])) else (ctor Option.none [Research::Snapshot])), + axioms: [propext], + executable: true +} + +definition{ + name: sequent, + parameters: [value : Json::Value], + result: (Option Research::Sequent), + body: (if (CoreNotation::shape value (cons 0x6f726967696e (cons 0x7468656f72656d (cons 0x7072656d697365 (cons 0x74656c6573636f7065 (cons 0x746172676574 (cons 0x6b696e64 (nil Bytes)))))))) then (match (bytes (CoreBinding::get value 0x6f726967696e)) | Option.none => (ctor Option.none [Research::Sequent]) | Option.some origin => (match (bytes (CoreBinding::get value 0x7468656f72656d)) | Option.none => (ctor Option.none [Research::Sequent]) | Option.some theorem => (match (Json::natural (CoreBinding::get value 0x7072656d697365) 2000000) | Option.none => (ctor Option.none [Research::Sequent]) | Option.some premise => (match (bytes (CoreBinding::get value 0x74656c6573636f7065)) | Option.none => (ctor Option.none [Research::Sequent]) | Option.some telescope => (match (bytes (CoreBinding::get value 0x746172676574)) | Option.none => (ctor Option.none [Research::Sequent]) | Option.some target => (match (goalKind (CoreBinding::get value 0x6b696e64)) | Option.none => (ctor Option.none [Research::Sequent]) | Option.some kind => (ctor Option.some [Research::Sequent] (record Research::Sequent {origin := origin, theorem := theorem, premise := premise, telescope := telescope, target := target, kind := kind})))))))) else (ctor Option.none [Research::Sequent])), + axioms: [], + executable: true +} + +definition{ + name: task, + parameters: [value : Json::Value], + result: (Option Research::Task), + body: (if (CoreNotation::shape value (cons 0x6964 (cons 0x707572706f7365 (cons 0x696e74656e74 (cons 0x737461747573 (cons 0x636f6d706f6e656e74 (cons 0x736f7572636573 (cons 0x736368656d61 (cons 0x73657175656e74 (cons 0x616765 (cons 0x776569676874 (nil Bytes)))))))))))) then (if ((stringIs (CoreBinding::get value 0x737461747573) 0x7265616479) && (Toml::sameBytes (VerificationReport::bytes (CoreBinding::get value 0x707572706f7365)) (VerificationReport::bytes (CoreBinding::get value 0x696e74656e74)))) then (match (bytes (CoreBinding::get value 0x6964)) | Option.none => (ctor Option.none [Research::Task]) | Option.some taskId => (match (purposeOf (CoreBinding::get value 0x707572706f7365)) | Option.none => (ctor Option.none [Research::Task]) | Option.some purpose => (match (purposeOf (CoreBinding::get value 0x696e74656e74)) | Option.none => (ctor Option.none [Research::Task]) | Option.some intent => (match (text (CoreBinding::get value 0x636f6d706f6e656e74)) | Option.none => (ctor Option.none [Research::Task]) | Option.some component => (match (byteList (CoreBinding::get value 0x736f7572636573)) | Option.none => (ctor Option.none [Research::Task]) | Option.some sources => (match (bytes (CoreBinding::get value 0x736368656d61)) | Option.none => (ctor Option.none [Research::Task]) | Option.some schema => (match (sequent (CoreBinding::get value 0x73657175656e74)) | Option.none => (ctor Option.none [Research::Task]) | Option.some goalData => (match (Json::natural (CoreBinding::get value 0x616765) 9223372036854775807) | Option.none => (ctor Option.none [Research::Task]) | Option.some age => (match (Json::natural (CoreBinding::get value 0x776569676874) 9223372036854775807) | Option.none => (ctor Option.none [Research::Task]) | Option.some weight => (ctor Option.some [Research::Task] (record Research::Task {id := taskId, purpose := purpose, intent := intent, status := (ctor Research::Status.ready), component := component, sources := sources, schema := schema, sequent := goalData, age := age, weight := weight}))))))))))) else (ctor Option.none [Research::Task])) else (ctor Option.none [Research::Task])), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: request, + parameters: [value : Json::Value], + result: (Option Research::Request), + body: (if (CoreNotation::shape value (cons 0x73657269616c (cons 0x736e617073686f74 (cons 0x7461736b (nil Bytes))))) then (match (Json::natural (CoreBinding::get value 0x73657269616c) 9223372036854775807) | Option.none => (ctor Option.none [Research::Request]) | Option.some serial => (match (snapshot (CoreBinding::get value 0x736e617073686f74)) | Option.none => (ctor Option.none [Research::Request]) | Option.some snapshotData => (match (task (CoreBinding::get value 0x7461736b)) | Option.none => (ctor Option.none [Research::Request]) | Option.some taskData => (ctor Option.some [Research::Request] (record Research::Request {serial := serial, snapshot := snapshotData, task := taskData}))))) else (ctor Option.none [Research::Request])), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: tools, + parameters: [value : Json::Value], + result: (Option ResearchCandidate::Tools), + body: (if ((VerificationReport::digest (VerificationReport::bytes (CoreBinding::get value 0x6c65786c65616e))) && ((VerificationReport::digest (VerificationReport::bytes (CoreBinding::get value 0x6c65616e))) && ((VerificationReport::digest (VerificationReport::bytes (CoreBinding::get value 0x6c616b65))) && (VerificationReport::digest (VerificationReport::bytes (CoreBinding::get value 0x636865636b6572)))))) then (if (CoreNotation::shape value (cons 0x6c65786c65616e (cons 0x6c65616e (cons 0x6c616b65 (cons 0x636865636b6572 (nil Bytes)))))) then (match (bytes (CoreBinding::get value 0x6c65786c65616e)) | Option.none => (ctor Option.none [ResearchCandidate::Tools]) | Option.some lexlean => (match (bytes (CoreBinding::get value 0x6c65616e)) | Option.none => (ctor Option.none [ResearchCandidate::Tools]) | Option.some lean => (match (bytes (CoreBinding::get value 0x6c616b65)) | Option.none => (ctor Option.none [ResearchCandidate::Tools]) | Option.some lake => (match (bytes (CoreBinding::get value 0x636865636b6572)) | Option.none => (ctor Option.none [ResearchCandidate::Tools]) | Option.some checker => (ctor Option.some [ResearchCandidate::Tools] (record ResearchCandidate::Tools {lexlean := lexlean, lean := lean, lake := lake, checker := checker})))))) else (ctor Option.none [ResearchCandidate::Tools])) else (ctor Option.none [ResearchCandidate::Tools])), + axioms: [propext], + executable: true +} + +definition{ + name: arena, + parameters: [value : Json::Value], + result: (Option CoreBinding::Goal), + body: (if (CoreNotation::shape value (cons 0x6e6f646573 (cons 0x726f6f74 (nil Bytes)))) then (match (array (CoreBinding::get value 0x6e6f646573)) | Option.none => (ctor Option.none [CoreBinding::Goal]) | Option.some nodes => (match (Json::natural (CoreBinding::get value 0x726f6f74) 2000000) | Option.none => (ctor Option.none [CoreBinding::Goal]) | Option.some root => (ctor Option.some [CoreBinding::Goal] (record CoreBinding::Goal {nodes := nodes, root := root})))) else (ctor Option.none [CoreBinding::Goal])), + axioms: [], + executable: true +} + +structure{ + name: Bounds, + type_parameters: [], + parameters: [], + fields: [{name: maxBytes, type: Nat}, {name: maxDepth, type: Nat}, {name: maxSteps, type: Nat}, {name: allowance, type: Nat}, {name: quantum, type: Nat}, {name: polls, type: Nat}] +} + +definition{ + name: bounds, + parameters: [value : Json::Value], + result: (Option Bounds), + body: (if (CoreNotation::shape value (cons 0x6d61785f6279746573 (cons 0x6d61785f6465707468 (cons 0x6d61785f7374657073 (cons 0x616c6c6f77616e6365 (cons 0x7175616e74756d (cons 0x706f6c6c73 (nil Bytes)))))))) then (match (Json::natural (CoreBinding::get value 0x6d61785f6279746573) 8388608) | Option.none => (ctor Option.none [Bounds]) | Option.some maxBytes => (match (Json::natural (CoreBinding::get value 0x6d61785f6465707468) 120) | Option.none => (ctor Option.none [Bounds]) | Option.some maxDepth => (match (Json::natural (CoreBinding::get value 0x6d61785f7374657073) 16777216) | Option.none => (ctor Option.none [Bounds]) | Option.some maxSteps => (match (Json::natural (CoreBinding::get value 0x616c6c6f77616e6365) 86400000) | Option.none => (ctor Option.none [Bounds]) | Option.some allowance => (match (Json::natural (CoreBinding::get value 0x7175616e74756d) 60000) | Option.none => (ctor Option.none [Bounds]) | Option.some quantum => (match (Json::natural (CoreBinding::get value 0x706f6c6c73) 86400000) | Option.none => (ctor Option.none [Bounds]) | Option.some polls => (ctor Option.some [Bounds] (record Bounds {maxBytes := maxBytes, maxDepth := maxDepth, maxSteps := maxSteps, allowance := allowance, quantum := quantum, polls := polls})))))))) else (ctor Option.none [Bounds])), + axioms: [], + executable: true +} + +definition{ + name: config, + parameters: [value : Json::Value, env : (List (String * String))], + result: (Option ResearchProject::Config), + body: (if (CoreNotation::shape value (cons 0x73706563 (cons 0x72657175657374 (cons 0x7265706f7369746f7279 (cons 0x7265766973696f6e (cons 0x6f7574707574 (cons 0x6572726f7273 (cons 0x746f6f6c73 (cons 0x6172656e61 (cons 0x70726f6f66 (cons 0x696d706f727473 (cons 0x6c6576656c73 (cons 0x6178696f6d73 (cons 0x626f756e6473 (nil Bytes))))))))))))))) then (if (stringIs (CoreBinding::get value 0x73706563) 0x7233302f72657365617263682d617474656d70742f31) then (match (request (CoreBinding::get value 0x72657175657374)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some ownedRequest => (match (bytes (CoreBinding::get value 0x7265706f7369746f7279)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some repository => (match (bytes (CoreBinding::get value 0x7265766973696f6e)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some revision => (match (text (CoreBinding::get value 0x6f7574707574)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some output => (match (text (CoreBinding::get value 0x6572726f7273)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some errors => (match (tools (CoreBinding::get value 0x746f6f6c73)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some toolData => (match (arena (CoreBinding::get value 0x6172656e61)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some termArena => (match (Json::natural (CoreBinding::get value 0x70726f6f66) 2000000) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some proof => (match (byteList (CoreBinding::get value 0x696d706f727473)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some imports => (match (byteList (CoreBinding::get value 0x6c6576656c73)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some levels => (match (textList (CoreBinding::get value 0x6178696f6d73)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some axioms => (match (bounds (CoreBinding::get value 0x626f756e6473)) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some limits => (ctor Option.some [ResearchProject::Config] (record ResearchProject::Config {request := ownedRequest, workspace := (record ResearchWorkspace::Config {request := ownedRequest, repository := repository, revision := revision, environment := env, output := output, errors := errors, allowance := (project limits allowance), quantum := (project limits quantum), polls := (project limits polls)}), tools := toolData, arena := termArena, proof := proof, imports := imports, levels := levels, axioms := axioms, maxBytes := (project limits maxBytes), maxDepth := (project limits maxDepth), maxSteps := (project limits maxSteps)})))))))))))))) else (ctor Option.none [ResearchProject::Config])) else (ctor Option.none [ResearchProject::Config])), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: decode, + parameters: [data : Bytes, env : (List (Bytes * Bytes))], + result: (Option ResearchProject::Config), + body: (match (Json::parse data 8388608 96) | Result.error problem => (ctor Option.none [ResearchProject::Config]) | Result.ok value => (match (environment env) | Option.none => (ctor Option.none [ResearchProject::Config]) | Option.some admitted => (config value admitted))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: contract, + parameters: [], + result: String, + body: "Decode a bounded structured candidate-attempt request without performing effects. Exact object fields, JSON types, goal kind, numeric bounds and lossless ASCII conversion are required. The caller owns the environment, input file, repository and log paths. Admission establishes data shape, not provenance, premise inspection, a proof, or permission to publish a claim. ResearchSession constructs and verifies the candidate in its owned pinned workspace.", + axioms: [], + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "tool-digests-before-effects" (cons "bounded-attempt-json" (cons "exact-field-admission" (cons "explicit-goal-kind" (cons "no-receipt-input" (cons "lossless-ascii-environment" (cons "decode-is-not-proof" (nil String)))))))), + axioms: [], + executable: true +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchInputTraces.lex.tex b/rule30-api/src/ResearchInputTraces.lex.tex new file mode 100644 index 0000000..b13b8c4 --- /dev/null +++ b/rule30-api/src/ResearchInputTraces.lex.tex @@ -0,0 +1,177 @@ +\begin{lexlean}{ResearchInputTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{ResearchInput} +\importmodule{ResearchProject} +\importmodule{ResearchWorkspace} +\importmodule{Research} +\importmodule{ResearchRecord} +\importmodule{CoreBinding} +\importmodule{ResearchCandidate} +\importmodule{CoreNotation} +\importmodule{Json} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} +definition{ + name: putFields, + parameters: [fields : (List (Bytes * Json::Value)), key : Bytes, value : Json::Value], + result: (List (Bytes * Json::Value)), + body: (match fields | List.nil => (nil (Bytes * Json::Value)) | List.cons head tail => (cons (if (Toml::sameBytes (first head) key) then (key, value) else head) (putFields tail key value))), + axioms: [], + recursive_argument: fields +} +definition{ + name: put, + parameters: [document : Json::Value, key : Bytes, value : Json::Value], + result: Json::Value, + body: (match document | Json::Value.object fields => (ctor Json::Value.object (putFields fields key value)) | Json::Value.null => document | Json::Value.boolean data => document | Json::Value.number data => document | Json::Value.string data => document | Json::Value.array data => document), + axioms: [] +} +definition{ + name: request, + parameters: [], + result: Research::Request, + body: (record Research::Request {serial := 3, snapshot := (record Research::Snapshot {library := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161, compiler := 0x62626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262, model := 0x63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363}), task := (record Research::Task {id := 0x67, purpose := (ctor Research::Purpose.prove), intent := (ctor Research::Purpose.prove), status := (ctor Research::Status.ready), component := "deduction", sources := (cons 0x54727565 (nil Bytes)), schema := 0x67, sequent := (record Research::Sequent {origin := 0x54727565, theorem := 0x54727565, premise := 0, telescope := 0x, target := (match (CoreBinding::encodeGoal (CoreBinding::namedGoal 0x54727565) 2048 256) | Option.none => 0x | Option.some value => value), kind := (ctor Research::GoalKind.closed)}), age := 0, weight := 8})}), + axioms: [propext] +} +definition{ + name: requestDocument, + parameters: [], + result: Json::Value, + body: (put (ResearchRecord::request (request)) 0x7461736b (put (ResearchRecord::task (project (request) task)) 0x636f6d706f6e656e74 (ctor Json::Value.string 0x646564756374696f6e))), + axioms: [propext] +} +definition{ + name: truth, + parameters: [], + result: CoreBinding::Goal, + body: (record CoreBinding::Goal {nodes := (prim append (project (CoreBinding::namedGoal 0x54727565) nodes) (project (CoreBinding::namedGoal 0x547275652e696e74726f) nodes) : (List Json::Value)), root := 0}), + axioms: [] +} +definition{ + name: fixtureDocument, + parameters: [], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d617474656d70742f31)) (cons (0x72657175657374, (requestDocument)) (cons (0x7265706f7369746f7279, (ctor Json::Value.string 0x2f7265736561726368)) (cons (0x7265766973696f6e, (ctor Json::Value.string 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161)) (cons (0x6f7574707574, (ctor Json::Value.string 0x2f72657365617263682f6f7574707574)) (cons (0x6572726f7273, (ctor Json::Value.string 0x2f72657365617263682f6572726f7273)) (cons (0x746f6f6c73, (ctor Json::Value.object (cons (0x6c65786c65616e, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (cons (0x6c65616e, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (cons (0x6c616b65, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (cons (0x636865636b6572, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (nil (Bytes * Json::Value)))))))) (cons (0x6172656e61, (ctor Json::Value.object (cons (0x6e6f646573, (ctor Json::Value.array (project (truth) nodes))) (cons (0x726f6f74, (ctor Json::Value.number 0x30)) (nil (Bytes * Json::Value)))))) (cons (0x70726f6f66, (ctor Json::Value.number 0x31)) (cons (0x696d706f727473, (ctor Json::Value.array (cons (ctor Json::Value.string 0x496e6974) (nil Json::Value)))) (cons (0x6c6576656c73, (ctor Json::Value.array (nil Json::Value))) (cons (0x6178696f6d73, (ctor Json::Value.array (nil Json::Value))) (cons (0x626f756e6473, (ctor Json::Value.object (cons (0x6d61785f6279746573, (ctor Json::Value.number 0x34303936)) (cons (0x6d61785f6465707468, (ctor Json::Value.number 0x3332)) (cons (0x6d61785f7374657073, (ctor Json::Value.number 0x31303234)) (cons (0x616c6c6f77616e6365, (ctor Json::Value.number 0x31303030)) (cons (0x7175616e74756d, (ctor Json::Value.number 0x3130)) (cons (0x706f6c6c73, (ctor Json::Value.number 0x313030)) (nil (Bytes * Json::Value)))))))))) (nil (Bytes * Json::Value)))))))))))))))), + axioms: [propext] +} +definition{ + name: admitted, + parameters: [document : Json::Value], + result: Bool, + body: (match (ResearchInput::config document (nil (String * String))) | Option.none => false | Option.some config => true), + axioms: [Quot.sound, propext] +} +theorem{ + name: admitsStructuredClosedGoal, + parameters: [], + statement: ((admitted (fixtureDocument)) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: preservesRequestAndCandidate, + parameters: [], + statement: ((match (ResearchInput::config (fixtureDocument) (nil (String * String))) | Option.none => false | Option.some config => (((project config proof) =? 1) && (Research::sameRequest (project (project config workspace) request) (request)))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: unknownSchemaRejected, + parameters: [], + statement: ((not (admitted (put (fixtureDocument) 0x73706563 (ctor Json::Value.string 0x7233302f72657365617263682d617474656d70742f32)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: wrongProofTypeRejected, + parameters: [], + statement: ((not (admitted (put (fixtureDocument) 0x70726f6f66 (ctor Json::Value.string 0x31)))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: proofBoundEnforced, + parameters: [], + statement: ((not (admitted (put (fixtureDocument) 0x70726f6f66 (ctor Json::Value.number 0x32303030303031)))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: nonAsciiLogPathRejected, + parameters: [], + statement: ((not (admitted (put (fixtureDocument) 0x6f7574707574 (ctor Json::Value.string 0x2f72657365617263682fcebb)))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: unexpectedReceiptRejected, + parameters: [], + statement: ((not (admitted (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d617474656d70742f31)) (cons (0x72657175657374, (requestDocument)) (cons (0x7265706f7369746f7279, (ctor Json::Value.string 0x2f7265736561726368)) (cons (0x7265766973696f6e, (ctor Json::Value.string 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161)) (cons (0x6f7574707574, (ctor Json::Value.string 0x2f72657365617263682f6f7574707574)) (cons (0x6572726f7273, (ctor Json::Value.string 0x2f72657365617263682f6572726f7273)) (cons (0x746f6f6c73, (ctor Json::Value.object (cons (0x6c65786c65616e, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (cons (0x6c65616e, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (cons (0x6c616b65, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (cons (0x636865636b6572, (ctor Json::Value.string 0x64646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464)) (nil (Bytes * Json::Value)))))))) (cons (0x6172656e61, (ctor Json::Value.object (cons (0x6e6f646573, (ctor Json::Value.array (project (truth) nodes))) (cons (0x726f6f74, (ctor Json::Value.number 0x30)) (nil (Bytes * Json::Value)))))) (cons (0x70726f6f66, (ctor Json::Value.number 0x31)) (cons (0x696d706f727473, (ctor Json::Value.array (cons (ctor Json::Value.string 0x496e6974) (nil Json::Value)))) (cons (0x6c6576656c73, (ctor Json::Value.array (nil Json::Value))) (cons (0x6178696f6d73, (ctor Json::Value.array (nil Json::Value))) (cons (0x626f756e6473, (ctor Json::Value.object (cons (0x6d61785f6279746573, (ctor Json::Value.number 0x34303936)) (cons (0x6d61785f6465707468, (ctor Json::Value.number 0x3332)) (cons (0x6d61785f7374657073, (ctor Json::Value.number 0x31303234)) (cons (0x616c6c6f77616e6365, (ctor Json::Value.number 0x31303030)) (cons (0x7175616e74756d, (ctor Json::Value.number 0x3130)) (cons (0x706f6c6c73, (ctor Json::Value.number 0x313030)) (nil (Bytes * Json::Value)))))))))) (cons (0x72656365697074, (ctor Json::Value.string 0x756e74727573746564)) (nil (Bytes * Json::Value))))))))))))))))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: environmentConversionIsLossless, + parameters: [], + statement: ((match (ResearchInput::environment (cons (0x50415448, 0x2f62696e) (nil (Bytes * Bytes)))) | Option.none => false | Option.some env => true) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: nonAsciiEnvironmentRejected, + parameters: [], + statement: ((match (ResearchInput::environment (cons (0x50415448, 0x2fcebb) (nil (Bytes * Bytes)))) | Option.none => true | Option.some env => false) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: duplicateJsonKeysRejected, + parameters: [], + statement: ((match (ResearchInput::decode 0x7b2273706563223a2261222c2273706563223a2262227d (nil (Bytes * Bytes))) | Option.none => true | Option.some config => false) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: maintenanceCannotBecomeCandidate, + parameters: [], + statement: ((match (ResearchInput::purposeOf (ctor Json::Value.string 0x6d61696e7461696e)) | Option.none => true | Option.some purpose => false) = true), + proof: decide{}, + axioms: [] +} +theorem{ + name: unknownGoalKindRejected, + parameters: [], + statement: ((match (ResearchInput::goalKind (ctor Json::Value.string 0x617373756d6564)) | Option.none => true | Option.some kind => false) = true), + proof: decide{}, + axioms: [] +} + +theorem{ + name: mismatchedPurposeAndIntentRejected, + parameters: [], + statement: ((match (ResearchInput::task (put (ResearchRecord::task (project (request) task)) 0x696e74656e74 (ctor Json::Value.string 0x726566757465))) | Option.none => true | Option.some candidate => false) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: completedTaskCannotBecomeAttempt, + parameters: [], + statement: ((match (ResearchInput::task (put (ResearchRecord::task (project (request) task)) 0x737461747573 (ctor Json::Value.string 0x65737461626c6973686564))) | Option.none => true | Option.some candidate => false) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + + +theorem{ + name: malformedToolIdentityIsRejectedBeforeExecution, + parameters: [], + statement: ((match (ResearchInput::tools (put (CoreBinding::get (fixtureDocument) 0x746f6f6c73) 0x6c65786c65616e (ctor Json::Value.string 0x6e6f742d612d646967657374))) | Option.none => true | Option.some toolPins => false) = true), + proof: decide{}, + axioms: [propext] +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchProject.lex.tex b/rule30-api/src/ResearchProject.lex.tex new file mode 100644 index 0000000..59c85b0 --- /dev/null +++ b/rule30-api/src/ResearchProject.lex.tex @@ -0,0 +1,327 @@ +\begin{lexlean}{ResearchProject} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchExecution} +\importmodule{ResearchVerification} +\importmodule{ResearchCandidate} +\importmodule{ResearchWorkspace} +\importmodule{ResearchEvidence} +\importmodule{CandidateSource} +\importmodule{CoreBinding} +\importmodule{Toml} +\importmodule{Hypotheses} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: contract, + parameters: [], + result: String, + body: "Construct exact-goal candidate source in an isolated serial-addressed project. Ordinary begin owns a fresh pinned library worktree. beginPrepared borrows a ready owned library with the same workspace configuration and snapshot; only its enclosing cohort may release that library. A ready project has a checked library tree, locally built imports, a fresh private source directory, fixed LexLean and Lake manifests, the exact pinned Lean toolchain, and a locally generated lock. Readiness is not a proof. Only host replies, cancellation and release are events; callers cannot replace the source, context or project paths after begin. The enclosing session must finish candidate processes and preserve successful evidence before release. Preparation failure releases only an owned workspace. A borrowed project never releases the library; cleanup or protocol uncertainty blocks the enclosing cohort and retains ownership.", + axioms: [], + executable: true +} + +structure{ + name: Config, + type_parameters: [], + parameters: [], + fields: [{name: request, type: Research::Request}, {name: workspace, type: ResearchWorkspace::Config}, {name: tools, type: ResearchCandidate::Tools}, {name: arena, type: CoreBinding::Goal}, {name: proof, type: Nat}, {name: imports, type: (List Bytes)}, {name: levels, type: (List Bytes)}, {name: axioms, type: (List String)}, {name: maxBytes, type: Nat}, {name: maxDepth, type: Nat}, {name: maxSteps, type: Nat}] +} + +inductive{ + name: Operation, + type_parameters: [], + parameters: [], + constructors: [{name: update, fields: []}, {name: lock, fields: []}] +} + +inductive{ + name: Phase, + type_parameters: [], + parameters: [], + constructors: [{name: workspace, fields: []}, {name: checking, fields: []}, {name: directory, fields: []}, {name: toolchain, fields: []}, {name: writing, fields: [Nat]}, {name: executing, fields: []}, {name: ready, fields: []}, {name: releasing, fields: []}, {name: ended, fields: []}, {name: blocked, fields: []}] +} + +structure{ + name: State, + type_parameters: [], + parameters: [], + fields: [{name: borrowed, type: Bool}, {name: config, type: Config}, {name: source, type: Bytes}, {name: workspace, type: (Option ResearchWorkspace::State)}, {name: execution, type: (Option ResearchExecution::State)}, {name: operation, type: Operation}, {name: phase, type: Phase}, {name: cancelled, type: Bool}, {name: result, type: ResearchExecution::EndKind}] +} + +inductive{ + name: Event, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Event]}, {name: cancel, fields: []}, {name: release, fields: []}] +} + +inductive{ + name: Emission, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Request]}, {name: awaiting, fields: []}, {name: ready, fields: [ResearchCandidate::Context]}, {name: complete, fields: [ResearchExecution::EndKind]}, {name: blocked, fields: [String]}, {name: refused, fields: []}] +} + +definition{ + name: directory, + parameters: [config : Config], + result: String, + body: (ResearchVerification::concat (ResearchWorkspace::path (project config workspace)) (ResearchVerification::concat "/.r30/candidate-" (ResearchWorkspace::text (Hypotheses::decimal (project (project config request) serial))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: path, + parameters: [config : Config, suffix : String], + result: String, + body: (ResearchVerification::concat (directory config) suffix), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: toolchain, + parameters: [], + result: Bytes, + body: 0x6c65616e70726f7665722f6c65616e343a76342e33322e310a, + axioms: [], + executable: true +} + +definition{ + name: manifest, + parameters: [], + result: Bytes, + body: 0x73706563203d20226c65786c65616e2f70726f6a6563742f31220a6e616d65203d202272756c6533302d72657365617263682d63616e646964617465220a6c616e6775616765203d2022312e32220a6d6f64756c655f707265666978203d202252756c65333043616e646964617465220a736f757263655f726f6f7473203d205b22737263225d0a656e747279706f696e7473203d205b227372632f43616e6469646174652e6c65782e746578225d0a6275696c645f726f6f74203d20222e6c65786c65616e220a6c6f636b66696c65203d20226c65786c65616e2e6c6f636b220a6c65616e5f776f726b7370616365203d20222e220a6c65616e5f746f6f6c636861696e203d20226c65616e70726f7665722f6c65616e343a76342e33322e31220a0a5b5b6c657869636f6e5f736f757263655d5d0a7061636b616765203d20226c65786c65616e2e7374642e626f6f6c220a6b696e64203d20226275696c74696e220a0a5b6c696d6974735d0a6d61785f66696c655f6279746573203d20383338383630380a6d61785f746f74616c5f736f757263655f6279746573203d2031363737373231360a6d61785f7072696d69746976655f61746f6d73203d20323030303030300a6d61785f746f6b656e5f6c6174746963655f6564676573203d20343030303030300a6d61785f70617273655f737461746573203d20343030303030300a6d61785f69725f6e6f646573203d20323030303030300a6d61785f73636f70655f6465707468203d20313032340a6d61785f696d706f72745f6465707468203d203132380a6d61785f646961676e6f7374696373203d203235360a6d61785f6368696c645f6f75747075745f6279746573203d2031363737373231360a6368696c645f74696d656f75745f6d73203d203630303030300a, + axioms: [], + executable: true +} + +definition{ + name: lakefile, + parameters: [], + result: Bytes, + body: 0x6e616d65203d202272756c6533302d72657365617263682d63616e646964617465220a76657273696f6e203d2022302e312e30220a0a5b5b726571756972655d5d0a6e616d65203d202272756c653330636f7265220a70617468203d20222e2e2f2e2e2f72756c6533302d636f72652d6c65616e220a, + axioms: [], + executable: true +} + +definition{ + name: verificationConfig, + parameters: [config : Config], + result: ResearchVerification::Config, + body: (record ResearchVerification::Config {project := (path config "/lexlean.toml"), moduleSource := "src/Candidate.lex.tex", directory := (directory config), environment := (project (project config workspace) environment), output := (project (project config workspace) output), errors := (project (project config workspace) errors), verifiedRoot := (path config "/.lexlean/verified"), maxBytes := (project config maxBytes), allowance := (project (project config workspace) allowance), quantum := (project (project config workspace) quantum), polls := (project (project config workspace) polls)}), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: context, + parameters: [config : Config], + result: ResearchCandidate::Context, + body: (record ResearchCandidate::Context {request := (project config request), config := (verificationConfig config), tools := (project config tools), module := 0x52756c65333043616e6469646174652e43616e646964617465, theorem := 0x52756c65333043616e6469646174652e43616e6469646174652e70726f6f66, maxDepth := (project config maxDepth), maxSteps := (project config maxSteps)}), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: job, + parameters: [config : Config, operation : Operation], + result: ResearchExecution::Job, + body: (record ResearchExecution::Job {request := (project config request), tool := (match operation | Operation.update => (ctor ResearchExecution::Tool.lake) | Operation.lock => (ctor ResearchExecution::Tool.lexlean)), arguments := (match operation | Operation.update => (cons "update" (nil String)) | Operation.lock => (cons "--project=lexlean.toml" (cons "lock" (nil String)))), directory := (directory config), environment := (project (project config workspace) environment), output := (project (project config workspace) output), errors := (project (project config workspace) errors), allowance := (project (project config workspace) allowance), quantum := (project (project config workspace) quantum), polls := (project (project config workspace) polls)}), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: blocked, + parameters: [state : State, reason : String], + result: (State * Emission), + body: ((record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (project state execution), operation := (project state operation), phase := (ctor Phase.blocked), cancelled := (project state cancelled), result := (project state result)}), (ctor Emission.blocked reason)), + axioms: [], + executable: true +} + +definition{ + name: finish, + parameters: [state : State, result : ResearchExecution::EndKind], + result: (State * Emission), + body: ((record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (ctor Option.none [ResearchExecution::State]), operation := (project state operation), phase := (ctor Phase.ended), cancelled := (project state cancelled), result := result}), (ctor Emission.complete result)), + axioms: [], + executable: true +} + +definition{ + name: workspaceResult, + parameters: [state : State, result : (ResearchWorkspace::State * ResearchWorkspace::Emission)], + result: (State * Emission), + body: (let next : State := (record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (ctor Option.some [ResearchWorkspace::State] (first result)), execution := (project state execution), operation := (project state operation), phase := (project state phase), cancelled := (project state cancelled), result := (project state result)}); (match (second result) | ResearchWorkspace::Emission.host request => (next, (ctor Emission.host request)) | ResearchWorkspace::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchWorkspace::Emission.blocked reason => (blocked next reason) | ResearchWorkspace::Emission.refused => (blocked next "workspace operation refused") | ResearchWorkspace::Emission.ready ownedPath => ((record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (ctor Option.some [ResearchWorkspace::State] (first result)), execution := (project state execution), operation := (project state operation), phase := (ctor Phase.checking), cancelled := (project state cancelled), result := (project state result)}), (ctor Emission.host (ctor LexLeanStd.Host::Request.stat (directory (project state config))))) | ResearchWorkspace::Emission.complete kind => (match (project state phase) | Phase.releasing => (finish next (if (project state cancelled) then (ctor ResearchExecution::EndKind.cut) else (project state result))) | Phase.workspace => (finish next kind) | Phase.checking => (blocked next "unexpected workspace completion") | Phase.directory => (blocked next "unexpected workspace completion") | Phase.toolchain => (blocked next "unexpected workspace completion") | Phase.writing index => (blocked next "unexpected workspace completion") | Phase.executing => (blocked next "unexpected workspace completion") | Phase.ready => (blocked next "unexpected workspace completion") | Phase.ended => (blocked next "unexpected workspace completion") | Phase.blocked => (blocked next "unexpected workspace completion")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: release, + parameters: [state : State, result : ResearchExecution::EndKind], + result: (State * Emission), + body: (if (project state borrowed) then (finish state result) else (match (project state workspace) | Option.none => (finish state result) | Option.some owned => (workspaceResult (record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (ctor Option.none [ResearchExecution::State]), operation := (project state operation), phase := (ctor Phase.releasing), cancelled := (project state cancelled), result := result}) (ResearchWorkspace::step owned (ctor ResearchWorkspace::Event.release))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: launch, + parameters: [state : State, operation : Operation], + result: (State * Emission), + body: (let result : (ResearchExecution::State * ResearchExecution::Emission) := (ResearchExecution::begin (job (project state config) operation)); (let next : State := (record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (ctor Option.some [ResearchExecution::State] (first result)), operation := operation, phase := (ctor Phase.executing), cancelled := (project state cancelled), result := (project state result)}); (match (second result) | ResearchExecution::Emission.host request => (next, (ctor Emission.host request)) | ResearchExecution::Emission.awaiting => (blocked next "project job did not spawn") | ResearchExecution::Emission.complete completion => (blocked next "project job refused")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: write, + parameters: [state : State, index : Nat], + result: (State * Emission), + body: ((record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (project state execution), operation := (project state operation), phase := (ctor Phase.writing index), cancelled := (project state cancelled), result := (project state result)}), (ctor Emission.host (ctor LexLeanStd.Host::Request.write (path (project state config) (if (index =? 0) then "/lexlean.toml" else (if (index =? 1) then "/lakefile.toml" else (if (index =? 2) then "/lean-toolchain" else "/src/Candidate.lex.tex")))) (if (index =? 0) then (manifest) else (if (index =? 1) then (lakefile) else (if (index =? 2) then (toolchain) else (project state source))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: checkedPath, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (Host::asStated event) | Option.none => (blocked state "unexpected candidate path reply") | Option.some result => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut)) else (match result | Result.ok entry => (release state (ctor ResearchExecution::EndKind.refused)) | Result.error failure => (match (project failure kind) | LexLeanStd.Host::FailureKind.notFound => ((record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (project state execution), operation := (project state operation), phase := (ctor Phase.directory), cancelled := (project state cancelled), result := (project state result)}), (ctor Emission.host (ctor LexLeanStd.Host::Request.createDir (path (project state config) "/src")))) | LexLeanStd.Host::FailureKind.alreadyExists => (release state (ctor ResearchExecution::EndKind.failed)) | LexLeanStd.Host::FailureKind.denied => (release state (ctor ResearchExecution::EndKind.failed)) | LexLeanStd.Host::FailureKind.other => (release state (ctor ResearchExecution::EndKind.failed)))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: directoryMade, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (ResearchEvidence::finishedResponse event) | Option.none => (blocked state "unexpected candidate directory reply") | Option.some result => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut)) else (match result | Result.error failure => (release state (ctor ResearchExecution::EndKind.failed)) | Result.ok unit => ((record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (project state execution), operation := (project state operation), phase := (ctor Phase.toolchain), cancelled := (project state cancelled), result := (project state result)}), (ctor Emission.host (ctor LexLeanStd.Host::Request.read (ResearchVerification::concat (ResearchWorkspace::path (project (project state config) workspace)) "/rule30-core-lean/lean-toolchain"))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: toolchainRead, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (Host::asRead event) | Option.none => (blocked state "unexpected toolchain read reply") | Option.some result => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut)) else (match result | Result.error failure => (release state (ctor ResearchExecution::EndKind.failed)) | Result.ok data => (if (Toml::sameBytes data (toolchain)) then (write state 0) else (release state (ctor ResearchExecution::EndKind.refused)))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: written, + parameters: [state : State, index : Nat, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (ResearchEvidence::finishedResponse event) | Option.none => (blocked state "unexpected candidate write reply") | Option.some result => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut)) else (match result | Result.error failure => (release state (ctor ResearchExecution::EndKind.failed)) | Result.ok unit => (if (index (match (project state operation) | Operation.update => (launch state (ctor Operation.lock)) | Operation.lock => ((record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (ctor Option.none [ResearchExecution::State]), operation := (project state operation), phase := (ctor Phase.ready), cancelled := (project state cancelled), result := (project state result)}), (ctor Emission.ready (context (project state config))))) | ResearchExecution::EndKind.failed => (release state (ctor ResearchExecution::EndKind.failed)) | ResearchExecution::EndKind.cut => (release state (ctor ResearchExecution::EndKind.cut)) | ResearchExecution::EndKind.unavailable => (release state (ctor ResearchExecution::EndKind.unavailable)) | ResearchExecution::EndKind.protocol => (blocked state "candidate preparation protocol failure") | ResearchExecution::EndKind.cleanupFailed => (blocked state "candidate preparation cleanup failed") | ResearchExecution::EndKind.refused => (blocked state "candidate preparation refused"))) else (blocked state "candidate preparation child remains owned or was interrupted; retain workspace until descendants are accounted for")), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: executionResult, + parameters: [state : State, result : (ResearchExecution::State * ResearchExecution::Emission)], + result: (State * Emission), + body: (let next : State := (record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (ctor Option.some [ResearchExecution::State] (first result)), operation := (project state operation), phase := (project state phase), cancelled := (project state cancelled), result := (project state result)}); (match (second result) | ResearchExecution::Emission.host request => (next, (ctor Emission.host request)) | ResearchExecution::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchExecution::Emission.complete completion => (completed next completion))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: cancel, + parameters: [state : State], + result: (State * Emission), + body: (let next : State := (record State {borrowed := (project state borrowed), config := (project state config), source := (project state source), workspace := (project state workspace), execution := (project state execution), operation := (project state operation), phase := (project state phase), cancelled := true, result := (project state result)}); (match (project state phase) | Phase.workspace => (match (project state workspace) | Option.none => (blocked next "missing workspace owner") | Option.some owned => (workspaceResult next (ResearchWorkspace::step owned (ctor ResearchWorkspace::Event.cancel)))) | Phase.checking => (next, (ctor Emission.awaiting)) | Phase.directory => (next, (ctor Emission.awaiting)) | Phase.toolchain => (next, (ctor Emission.awaiting)) | Phase.writing index => (next, (ctor Emission.awaiting)) | Phase.executing => (match (project state execution) | Option.none => (blocked next "missing candidate preparation owner") | Option.some active => (executionResult next (ResearchExecution::cancel active))) | Phase.ready => (release next (ctor ResearchExecution::EndKind.cut)) | Phase.releasing => (next, (ctor Emission.awaiting)) | Phase.ended => (state, (ctor Emission.refused)) | Phase.blocked => (state, (ctor Emission.blocked "candidate project remains blocked")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: host, + parameters: [state : State, response : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (project state phase) | Phase.workspace => (match (project state workspace) | Option.none => (blocked state "missing workspace owner") | Option.some owned => (workspaceResult state (ResearchWorkspace::step owned (ctor ResearchWorkspace::Event.host response)))) | Phase.releasing => (match (project state workspace) | Option.none => (blocked state "missing workspace owner during release") | Option.some owned => (workspaceResult state (ResearchWorkspace::step owned (ctor ResearchWorkspace::Event.host response)))) | Phase.checking => (checkedPath state response) | Phase.directory => (directoryMade state response) | Phase.toolchain => (toolchainRead state response) | Phase.writing index => (written state index response) | Phase.executing => (match (project state execution) | Option.none => (blocked state "missing candidate preparation owner") | Option.some active => (executionResult state (ResearchExecution::step active response))) | Phase.ready => (state, (ctor Emission.refused)) | Phase.ended => (state, (ctor Emission.refused)) | Phase.blocked => (state, (ctor Emission.blocked "candidate project remains blocked"))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: begin, + parameters: [config : Config], + result: (State * Emission), + body: (let state : State := (record State {borrowed := false, config := config, source := 0x, workspace := (ctor Option.none [ResearchWorkspace::State]), execution := (ctor Option.none [ResearchExecution::State]), operation := (ctor Operation.update), phase := (ctor Phase.workspace), cancelled := false, result := (ctor ResearchExecution::EndKind.succeeded)}); (if ((Research::sameRequest (project config request) (project (project config workspace) request)) && (((project config maxBytes) <=? 8388608) && ((ResearchWorkspace::valid (project config workspace)) && (ResearchCandidate::valid (context config))))) then (match (CandidateSource::construct (project config request) (project config arena) (project config proof) (project config imports) (project config levels) (project config axioms) (project config maxBytes) (project config maxDepth) (project config maxSteps)) | Option.none => (finish state (ctor ResearchExecution::EndKind.refused)) | Option.some data => (workspaceResult (record State {borrowed := (project state borrowed), config := (project state config), source := data, workspace := (project state workspace), execution := (project state execution), operation := (project state operation), phase := (project state phase), cancelled := (project state cancelled), result := (project state result)}) (ResearchWorkspace::begin (project config workspace)))) else (finish state (ctor ResearchExecution::EndKind.refused)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: step, + parameters: [state : State, event : Event], + result: (State * Emission), + body: (match event | Event.host response => (host state response) | Event.cancel => (cancel state) | Event.release => (match (project state phase) | Phase.ready => (release state (ctor ResearchExecution::EndKind.succeeded)) | Phase.workspace => (state, (ctor Emission.refused)) | Phase.checking => (state, (ctor Emission.refused)) | Phase.directory => (state, (ctor Emission.refused)) | Phase.toolchain => (state, (ctor Emission.refused)) | Phase.writing index => (state, (ctor Emission.refused)) | Phase.executing => (state, (ctor Emission.refused)) | Phase.releasing => (state, (ctor Emission.refused)) | Phase.ended => (state, (ctor Emission.refused)) | Phase.blocked => (state, (ctor Emission.blocked "candidate project remains blocked")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "borrowed-prepared-library" (cons "separate-attempt-and-library-requests" (cons "pinned-owned-library" (cons "exact-goal-source-construction" (cons "fresh-candidate-project" (cons "fixed-local-project-manifests" (cons "exact-toolchain-source" (cons "local-dependency-resolution" (cons "owned-lock-generation" (cons "drain-before-workspace-release" (nil String))))))))))), + axioms: [], + executable: true +} + + +definition{ + name: sameEnvironment, + parameters: [left : (List (String * String)), right : (List (String * String))], + result: Bool, + body: (match left | List.nil => (match right | List.nil => true | List.cons head tail => false) | List.cons head tail => (match right | List.nil => false | List.cons other rest => (((prim equal (first head) (first other) : Bool) && (prim equal (second head) (second other) : Bool)) && (sameEnvironment tail rest)))), + recursive_argument: left, + executable: true +} +definition{ + name: sameWorkspace, + parameters: [left : ResearchWorkspace::Config, right : ResearchWorkspace::Config], + result: Bool, + body: ((Research::sameRequest (project left request) (project right request)) && ((Toml::sameBytes (project left repository) (project right repository)) && ((Toml::sameBytes (project left revision) (project right revision)) && ((sameEnvironment (project left environment) (project right environment)) && ((prim equal (project left output) (project right output) : Bool) && ((prim equal (project left errors) (project right errors) : Bool) && (((project left allowance) =? (project right allowance)) && (((project left quantum) =? (project right quantum)) && ((project left polls) =? (project right polls)))))))))), + executable: true +} +definition{ + name: preparedFor, + parameters: [config : Config, owner : ResearchWorkspace::State], + result: Bool, + body: ((project owner owned) && ((not (project owner cancelled)) && ((match (project owner phase) | ResearchWorkspace::Phase.ready => true | ResearchWorkspace::Phase.checking => false | ResearchWorkspace::Phase.executing => false | ResearchWorkspace::Phase.reading => false | ResearchWorkspace::Phase.ended => false | ResearchWorkspace::Phase.blocked => false) && ((sameWorkspace (project config workspace) (project owner config)) && (Research::sameSnapshot (project (project config request) snapshot) (project (project (project owner config) request) snapshot)))))), + executable: true +} +definition{ + name: beginPrepared, + parameters: [config : Config, owner : ResearchWorkspace::State], + result: (State * Emission), + body: (let state : State := (record State {borrowed := true, config := config, source := 0x, workspace := (ctor Option.some [ResearchWorkspace::State] owner), execution := (ctor Option.none [ResearchExecution::State]), operation := (ctor Operation.update), phase := (ctor Phase.checking), cancelled := false, result := (ctor ResearchExecution::EndKind.succeeded)}); (if ((preparedFor config owner) && (((project config maxBytes) <=? 8388608) && (ResearchCandidate::valid (context config)))) then (match (CandidateSource::construct (project config request) (project config arena) (project config proof) (project config imports) (project config levels) (project config axioms) (project config maxBytes) (project config maxDepth) (project config maxSteps)) | Option.none => (finish state (ctor ResearchExecution::EndKind.refused)) | Option.some data => ((record State {borrowed := true, config := config, source := data, workspace := (ctor Option.some [ResearchWorkspace::State] owner), execution := (ctor Option.none [ResearchExecution::State]), operation := (ctor Operation.update), phase := (ctor Phase.checking), cancelled := false, result := (ctor ResearchExecution::EndKind.succeeded)}), (ctor Emission.host (ctor LexLeanStd.Host::Request.stat (directory config))))) else (finish state (ctor ResearchExecution::EndKind.refused)))), + axioms: [Quot.sound, propext], + executable: true +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchProjectTraces.lex.tex b/rule30-api/src/ResearchProjectTraces.lex.tex new file mode 100644 index 0000000..c5269e2 --- /dev/null +++ b/rule30-api/src/ResearchProjectTraces.lex.tex @@ -0,0 +1,281 @@ +\begin{lexlean}{ResearchProjectTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Research} +\importmodule{ResearchProject} +\importmodule{ResearchCandidate} +\importmodule{ResearchWorkspace} +\importmodule{ResearchWorkspaceTraces} +\importmodule{ResearchEvidenceTraces} +\importmodule{ResearchExecution} +\importmodule{ResearchExecutionTraces} +\importmodule{ResearchInputTraces} +\importmodule{CoreBinding} +\title{Boolean} +\begin{semanticmodule} +definition{ + name: sourceRequest, + parameters: [], + result: Research::Request, + body: (record Research::Request {serial := 1, snapshot := (record Research::Snapshot {library := 0x6c, compiler := 0x63, model := 0x6d}), task := (record Research::Task {id := 0x67, purpose := (ctor Research::Purpose.prove), intent := (ctor Research::Purpose.prove), status := (ctor Research::Status.waiting), component := "deduction", sources := (cons 0x54727565 (nil Bytes)), schema := 0x67, sequent := (record Research::Sequent {origin := 0x54727565, theorem := 0x54727565, premise := 0, telescope := 0x, target := (match (CoreBinding::encodeGoal (CoreBinding::namedGoal 0x54727565) 2048 256) | Option.none => 0x | Option.some value => value), kind := (ctor Research::GoalKind.closed)}), age := 0, weight := 8})}), + axioms: [propext] +} + +definition{ + name: config, + parameters: [], + result: ResearchProject::Config, + body: (record ResearchProject::Config {request := (record Research::Request {serial := 3, snapshot := (record Research::Snapshot {library := (ResearchWorkspaceTraces::tree), compiler := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161, model := 0x6d}), task := (project (sourceRequest) task)}), workspace := (record ResearchWorkspace::Config {request := (record Research::Request {serial := 3, snapshot := (record Research::Snapshot {library := (ResearchWorkspaceTraces::tree), compiler := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161, model := 0x6d}), task := (project (sourceRequest) task)}), repository := 0x2f7265736561726368, revision := (ResearchWorkspaceTraces::tree), environment := (nil (String * String)), output := "/research/.r30/project.out", errors := "/research/.r30/project.err", allowance := 1000, quantum := 10, polls := 100}), tools := (record ResearchCandidate::Tools {lexlean := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161, lean := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161, lake := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161, checker := 0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161}), arena := (ResearchInputTraces::truth), proof := 1, imports := (cons 0x496e6974 (nil Bytes)), levels := (nil Bytes), axioms := (nil String), maxBytes := 4096, maxDepth := 32, maxSteps := 1024}), + axioms: [propext] +} + +definition{ + name: host, + parameters: [state : ResearchProject::State, event : LexLeanStd.Host::Event], + result: (ResearchProject::State * ResearchProject::Emission), + body: (ResearchProject::step state (ctor ResearchProject::Event.host event)), + axioms: [Quot.sound, propext] +} + +definition{ + name: spawned, + parameters: [state : ResearchProject::State], + result: ResearchProject::State, + body: (first (host (first (host state (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100))))), + axioms: [Quot.sound, propext] +} + +definition{ + name: finishJob, + parameters: [state : ResearchProject::State, code : Int32], + result: (ResearchProject::State * ResearchProject::Emission), + body: (host (spawned state) (ResearchExecutionTraces::exitEvent 7 (ctor Option.some [Int32] code) 101)), + axioms: [Quot.sound, propext] +} + +definition{ + name: readingIdentity, + parameters: [], + result: ResearchProject::State, + body: (first (finishJob (first (finishJob (first (host (first (ResearchProject::begin (config))) (ResearchWorkspaceTraces::absent))) (0 : Int32))) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: checking, + parameters: [], + result: ResearchProject::State, + body: (first (finishJob (first (finishJob (first (finishJob (first (finishJob (first (finishJob (first (host (readingIdentity) (ResearchWorkspaceTraces::exactIdentity))) (0 : Int32))) (0 : Int32))) (0 : Int32))) (0 : Int32))) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: directory, + parameters: [], + result: ResearchProject::State, + body: (first (host (checking) (ResearchWorkspaceTraces::absent))), + axioms: [Quot.sound, propext] +} + +definition{ + name: toolchain, + parameters: [], + result: ResearchProject::State, + body: (first (host (directory) (ResearchEvidenceTraces::written))), + axioms: [Quot.sound, propext] +} + +definition{ + name: writing, + parameters: [], + result: ResearchProject::State, + body: (first (host (toolchain) (ResearchWorkspaceTraces::readEvent (ResearchProject::toolchain)))), + axioms: [Quot.sound, propext] +} + +definition{ + name: updating, + parameters: [], + result: ResearchProject::State, + body: (first (host (first (host (first (host (first (host (writing) (ResearchEvidenceTraces::written))) (ResearchEvidenceTraces::written))) (ResearchEvidenceTraces::written))) (ResearchEvidenceTraces::written))), + axioms: [Quot.sound, propext] +} + +definition{ + name: locking, + parameters: [], + result: ResearchProject::State, + body: (first (finishJob (updating) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: ready, + parameters: [], + result: (ResearchProject::State * ResearchProject::Emission), + body: (finishJob (locking) (0 : Int32)), + axioms: [Quot.sound, propext] +} + +definition{ + name: isReady, + parameters: [result : (ResearchProject::State * ResearchProject::Emission)], + result: Bool, + body: (match (second result) | ResearchProject::Emission.host request => false | ResearchProject::Emission.awaiting => false | ResearchProject::Emission.ready context => true | ResearchProject::Emission.complete kind => false | ResearchProject::Emission.blocked reason => false | ResearchProject::Emission.refused => false), + axioms: [] +} + +definition{ + name: isBlocked, + parameters: [result : (ResearchProject::State * ResearchProject::Emission)], + result: Bool, + body: (match (second result) | ResearchProject::Emission.host request => false | ResearchProject::Emission.awaiting => false | ResearchProject::Emission.ready context => false | ResearchProject::Emission.complete kind => false | ResearchProject::Emission.blocked reason => true | ResearchProject::Emission.refused => false), + axioms: [] +} + +definition{ + name: isRefused, + parameters: [result : (ResearchProject::State * ResearchProject::Emission)], + result: Bool, + body: (match (second result) | ResearchProject::Emission.host request => false | ResearchProject::Emission.awaiting => false | ResearchProject::Emission.ready context => false | ResearchProject::Emission.complete kind => false | ResearchProject::Emission.blocked reason => false | ResearchProject::Emission.refused => true), + axioms: [] +} + +definition{ + name: ownsWorkspace, + parameters: [state : ResearchProject::State], + result: Bool, + body: (match (project state workspace) | Option.none => false | Option.some owned => (project owned owned)), + axioms: [] +} + +definition{ + name: ended, + parameters: [result : (ResearchProject::State * ResearchProject::Emission)], + result: Bool, + body: ((not (ownsWorkspace (first result))) && (match (second result) | ResearchProject::Emission.complete kind => true | ResearchProject::Emission.host request => false | ResearchProject::Emission.awaiting => false | ResearchProject::Emission.ready context => false | ResearchProject::Emission.blocked reason => false | ResearchProject::Emission.refused => false)), + axioms: [] +} + +theorem{ + name: completePreparationOwnsReadyProject, + parameters: [], + statement: (((isReady (ready)) && (ownsWorkspace (first (ready)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: existingPrivateProjectIsNotOverwritten, + parameters: [], + statement: ((ended (finishJob (first (host (checking) (ResearchWorkspaceTraces::existing))) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: wrongToolchainReleasesWorkspace, + parameters: [], + statement: ((ended (finishJob (first (host (toolchain) (ResearchWorkspaceTraces::readEvent 0x77726f6e67))) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: writeFailure, + parameters: [], + result: LexLeanStd.Host::Event, + body: (ctor LexLeanStd.Host::Event.finished (ctor Result.error [Unit, LexLeanStd.Host::Failure] (ResearchExecutionTraces::failedHost))), + axioms: [] +} + +theorem{ + name: writeFailureReleasesWorkspace, + parameters: [], + statement: ((ended (finishJob (first (host (writing) (writeFailure))) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedLockCannotBecomeReady, + parameters: [], + statement: ((ended (finishJob (first (finishJob (locking) (1 : Int32))) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: releaseDuringPreparationIsRefused, + parameters: [], + statement: ((isRefused (ResearchProject::step (updating) (ctor ResearchProject::Event.release))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledWriteDrainsBeforeRelease, + parameters: [], + statement: ((ended (finishJob (first (host (first (ResearchProject::step (writing) (ctor ResearchProject::Event.cancel))) (ResearchEvidenceTraces::written))) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: readyProjectReleasesOwnedWorkspace, + parameters: [], + statement: ((ended (finishJob (first (ResearchProject::step (first (ready)) (ctor ResearchProject::Event.release))) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: failedCleanup, + parameters: [], + result: (ResearchProject::State * ResearchProject::Emission), + body: (host (first (host (first (ResearchProject::step (spawned (updating)) (ctor ResearchProject::Event.cancel))) (ResearchExecutionTraces::waitEvent 101 (nil (Nat * (Option Int32)))))) (writeFailure)), + axioms: [Quot.sound, propext] +} + +definition{ + name: ownsChild, + parameters: [state : ResearchProject::State], + result: Bool, + body: (match (project state execution) | Option.none => false | Option.some active => (match (project active owner) | Option.none => false | Option.some owner => (owner =? 7))), + axioms: [] +} + +theorem{ + name: failedChildCleanupRetainsChildAndWorkspace, + parameters: [], + statement: (((isBlocked (failedCleanup)) && ((ownsChild (first (failedCleanup))) && (ownsWorkspace (first (failedCleanup))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedWorkspaceRemovalKeepsOwnership, + parameters: [], + statement: (((isBlocked (finishJob (first (ResearchProject::step (first (ready)) (ctor ResearchProject::Event.release))) (1 : Int32))) && (ownsWorkspace (first (finishJob (first (ResearchProject::step (first (ready)) (ctor ResearchProject::Event.release))) (1 : Int32))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +definition{ + name: stoppedUpdate, + parameters: [], + result: (ResearchProject::State * ResearchProject::Emission), + body: (host (first (host (first (ResearchProject::step (spawned (updating)) (ctor ResearchProject::Event.cancel))) (ResearchExecutionTraces::waitEvent 101 (nil (Nat * (Option Int32)))))) (ResearchExecutionTraces::stopOk)), + axioms: [Quot.sound, propext] +} + +theorem{ + name: stoppedProjectToolRetainsWorkspace, + parameters: [], + statement: (((isBlocked (stoppedUpdate)) && (ownsWorkspace (first (stoppedUpdate)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchProofTraces.lex.tex b/rule30-api/src/ResearchProofTraces.lex.tex index d3abae1..1797918 100644 --- a/rule30-api/src/ResearchProofTraces.lex.tex +++ b/rule30-api/src/ResearchProofTraces.lex.tex @@ -50,11 +50,19 @@ axioms: [Quot.sound, propext] } +definition{ + name: launching, + parameters: [], + result: (ResearchRunner::State * ResearchRunner::Action), + body: (ResearchRunner::step (first (started)) (ctor ResearchRunner::Event.host (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))), + axioms: [Quot.sound, propext] +} + definition{ name: cancelled, parameters: [], result: (ResearchRunner::State * ResearchRunner::Action), - body: (ResearchRunner::step (first (started)) (ctor ResearchRunner::Event.cancel)), + body: (ResearchRunner::step (first (launching)) (ctor ResearchRunner::Event.cancel)), axioms: [Quot.sound, propext] } @@ -166,7 +174,7 @@ name: changed, parameters: [], result: (ResearchRunner::State * ResearchRunner::Action), - body: (ResearchRunner::step (first (started)) (ctor ResearchRunner::Event.changed (ResearchTraces::otherSnapshot) (ResearchTraces::components) (cons "stdlib" (nil String)))), + body: (ResearchRunner::step (first (launching)) (ctor ResearchRunner::Event.changed (ResearchTraces::otherSnapshot) (ResearchTraces::components) (cons "stdlib" (nil String)))), axioms: [Quot.sound, propext] } diff --git a/rule30-api/src/ResearchRecord.lex.tex b/rule30-api/src/ResearchRecord.lex.tex new file mode 100644 index 0000000..dc0f3a1 --- /dev/null +++ b/rule30-api/src/ResearchRecord.lex.tex @@ -0,0 +1,152 @@ +\begin{lexlean}{ResearchRecord} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{Research} +\importmodule{ResearchProject} +\importmodule{ResearchWorkspace} +\importmodule{ResearchCandidate} +\importmodule{ResearchProof} +\importmodule{ResearchVerification} +\importmodule{VerificationReport} +\importmodule{CandidateBinding} +\importmodule{CandidateSource} +\importmodule{CoreBinding} +\importmodule{Json} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: contract, + parameters: [], + result: String, + body: "A replay record retains the owned candidate source, exact local project inputs, full request and library revision, compiler and tool identities, linked candidate IR, lexicon closure and the command and attestation bytes consumed by verification. The enclosing session alone establishes custody and decides when a checked result may be archived. Constructing or reading this JSON confers no proof authority; replay must again validate the pinned library, source and proof.", + axioms: [], + executable: true +} + +structure{ + name: Files, + type_parameters: [], + parameters: [], + fields: [{name: lock, type: Bytes}, {name: lakeManifest, type: Bytes}, {name: command, type: Bytes}, {name: attestation, type: Bytes}] +} + +definition{ + name: emptyFiles, + parameters: [], + result: Files, + body: (record Files {lock := 0x, lakeManifest := 0x, command := 0x, attestation := 0x}), + axioms: [], + executable: true +} + +definition{ + name: purpose, + parameters: [value : Research::Purpose], + result: Json::Value, + body: (match value | Research::Purpose.inspect => (ctor Json::Value.string 0x696e7370656374) | Research::Purpose.prove => (ctor Json::Value.string 0x70726f7665) | Research::Purpose.refute => (ctor Json::Value.string 0x726566757465) | Research::Purpose.maintain => (ctor Json::Value.string 0x6d61696e7461696e)), + axioms: [], + executable: true +} + +definition{ + name: status, + parameters: [value : Research::Status], + result: Json::Value, + body: (match value | Research::Status.ready => (ctor Json::Value.string 0x7265616479) | Research::Status.waiting => (ctor Json::Value.string 0x77616974696e67) | Research::Status.blocked => (ctor Json::Value.string 0x626c6f636b6564) | Research::Status.established => (ctor Json::Value.string 0x65737461626c6973686564) | Research::Status.exhausted => (ctor Json::Value.string 0x657868617573746564)), + axioms: [], + executable: true +} + +definition{ + name: sequent, + parameters: [value : Research::Sequent], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x6f726967696e, (ctor Json::Value.string (project value origin))) (cons (0x7468656f72656d, (ctor Json::Value.string (project value theorem))) (cons (0x74656c6573636f7065, (ctor Json::Value.string (project value telescope))) (cons (0x746172676574, (ctor Json::Value.string (project value target))) (cons (0x7072656d697365, (CoreBinding::number (project value premise))) (cons (0x6b696e64, (match (project value kind) | Research::GoalKind.premise => (ctor Json::Value.string 0x7072656d697365) | Research::GoalKind.closed => (ctor Json::Value.string 0x636c6f736564))) (nil (Bytes * Json::Value))))))))), + axioms: [], + executable: true +} + +definition{ + name: snapshot, + parameters: [value : Research::Snapshot], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x6c696272617279, (ctor Json::Value.string (project value library))) (cons (0x636f6d70696c6572, (ctor Json::Value.string (project value compiler))) (cons (0x6d6f64656c, (ctor Json::Value.string (project value model))) (nil (Bytes * Json::Value)))))), + axioms: [], + executable: true +} + +definition{ + name: task, + parameters: [value : Research::Task], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x6964, (ctor Json::Value.string (project value id))) (cons (0x707572706f7365, (purpose (project value purpose))) (cons (0x696e74656e74, (purpose (project value intent))) (cons (0x737461747573, (status (project value status))) (cons (0x636f6d706f6e656e74, (ctor Json::Value.string (prim utf8_encode (project value component) : Bytes))) (cons (0x736f7572636573, (ctor Json::Value.array (CandidateSource::strings (project value sources)))) (cons (0x736368656d61, (ctor Json::Value.string (project value schema))) (cons (0x73657175656e74, (sequent (project value sequent))) (cons (0x616765, (CoreBinding::number (project value age))) (cons (0x776569676874, (CoreBinding::number (project value weight))) (nil (Bytes * Json::Value))))))))))))), + axioms: [], + executable: true +} + +definition{ + name: request, + parameters: [value : Research::Request], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x73657269616c, (CoreBinding::number (project value serial))) (cons (0x736e617073686f74, (snapshot (project value snapshot))) (cons (0x7461736b, (task (project value task))) (nil (Bytes * Json::Value)))))), + axioms: [], + executable: true +} + +definition{ + name: pins, + parameters: [value : VerificationReport::Pins], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x736f75726365, (ctor Json::Value.string (project value source))) (cons (0x73656d616e746963, (ctor Json::Value.string (project value semantic))) (cons (0x636f6d70696c6572, (ctor Json::Value.string (project value compiler))) (cons (0x6c65786c65616e, (ctor Json::Value.string (project value lexlean))) (cons (0x6c65616e, (ctor Json::Value.string (project value lean))) (cons (0x6c616b65, (ctor Json::Value.string (project value lake))) (cons (0x636865636b6572, (ctor Json::Value.string (project value checker))) (cons (0x7468656f72656d, (ctor Json::Value.string (project value theorem))) (cons (0x6d6f64756c65, (ctor Json::Value.string (project value module))) (nil (Bytes * Json::Value)))))))))))), + axioms: [], + executable: true +} + +definition{ + name: receipt, + parameters: [value : VerificationReport::Receipt], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x736f75726365, (ctor Json::Value.string (project value source))) (cons (0x73656d616e746963, (ctor Json::Value.string (project value semantic))) (cons (0x6275696c64, (ctor Json::Value.string (project value build))) (cons (0x6174746573746174696f6e, (ctor Json::Value.string (project value attestation))) (cons (0x7468656f72656d, (ctor Json::Value.string (project value theorem))) (cons (0x6d6f64756c65, (ctor Json::Value.string (project value module))) (cons (0x6178696f6d73, (ctor Json::Value.array (CandidateSource::axiomStrings (project value axioms)))) (nil (Bytes * Json::Value)))))))))), + axioms: [], + executable: true +} + +definition{ + name: files, + parameters: [projectState : ResearchProject::State, captured : Files], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x7372632f43616e6469646174652e6c65782e746578, (ctor Json::Value.string (project projectState source))) (cons (0x6c65786c65616e2e746f6d6c, (ctor Json::Value.string (ResearchProject::manifest))) (cons (0x6c616b6566696c652e746f6d6c, (ctor Json::Value.string (ResearchProject::lakefile))) (cons (0x6c65616e2d746f6f6c636861696e, (ctor Json::Value.string (ResearchProject::toolchain))) (cons (0x6c65786c65616e2e6c6f636b, (ctor Json::Value.string (project captured lock))) (cons (0x6c616b652d6d616e69666573742e6a736f6e, (ctor Json::Value.string (project captured lakeManifest))) (nil (Bytes * Json::Value))))))))), + axioms: [], + executable: true +} + +definition{ + name: document, + parameters: [projectState : ResearchProject::State, proof : ResearchProof::State, verified : VerificationReport::Receipt, captured : Files], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x7233302f72657365617263682d70726f6f662f31)) (cons (0x72657175657374, (request (project verified request))) (cons (0x7265766973696f6e, (ctor Json::Value.string (project (project (project projectState config) workspace) revision))) (cons (0x70696e73, (pins (project (project proof verification) pins))) (cons (0x72656365697074, (receipt verified)) (cons (0x66696c6573, (files projectState captured)) (cons (0x6c696e6b6564, (project (project proof binding) linked)) (cons (0x6c657869636f6e, (project (project proof binding) lexicon)) (cons (0x636f6d6d616e64, (ctor Json::Value.string (project captured command))) (cons (0x6174746573746174696f6e, (ctor Json::Value.string (project captured attestation))) (nil (Bytes * Json::Value))))))))))))), + axioms: [], + executable: true +} + +definition{ + name: fromCandidate, + parameters: [projectState : ResearchProject::State, candidate : ResearchCandidate::State, captured : Files], + result: (Option Json::Value), + body: (match (project candidate phase) | ResearchCandidate::Phase.running => (ctor Option.none [Json::Value]) | ResearchCandidate::Phase.reading => (ctor Option.none [Json::Value]) | ResearchCandidate::Phase.verifying => (ctor Option.none [Json::Value]) | ResearchCandidate::Phase.ended => (match (project candidate proof) | Option.none => (ctor Option.none [Json::Value]) | Option.some proof => (match (project (project proof verification) outcome) | Option.none => (ctor Option.none [Json::Value]) | Option.some outcome => (match outcome | ResearchVerification::Outcome.accepted verified => (if ((not (project candidate cancelled)) && ((Research::sameRequest (project verified request) (project (project projectState config) request)) && ((0 (ctor Option.none [Json::Value]) | ResearchVerification::Outcome.rejected reason => (ctor Option.none [Json::Value]) | ResearchVerification::Outcome.cancelled => (ctor Option.none [Json::Value]))))), + axioms: [], + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "full-request-replay-record" (cons "owned-project-source-retention" (cons "pinned-library-and-tool-identities" (cons "same-read-verification-reports" (cons "linked-ir-and-lexicon-retention" (cons "records-require-kernel-replay" (nil String))))))), + axioms: [], + executable: true +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchRunnerTraces.lex.tex b/rule30-api/src/ResearchRunnerTraces.lex.tex index fa9ad01..47d74f0 100644 --- a/rule30-api/src/ResearchRunnerTraces.lex.tex +++ b/rule30-api/src/ResearchRunnerTraces.lex.tex @@ -22,7 +22,7 @@ name: launch, parameters: [], result: (ResearchRunner::State * ResearchRunner::Action), - body: (ResearchRunner::step (first (initial)) (ctor ResearchRunner::Event.job (ResearchExecutionTraces::job 10 4 3))), + body: (ResearchRunner::step (first (ResearchRunner::step (first (initial)) (ctor ResearchRunner::Event.job (ResearchExecutionTraces::job 10 4 3)))) (ctor ResearchRunner::Event.host (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))), axioms: [Quot.sound, propext] } diff --git a/rule30-api/src/ResearchSession.lex.tex b/rule30-api/src/ResearchSession.lex.tex new file mode 100644 index 0000000..ffeac3c --- /dev/null +++ b/rule30-api/src/ResearchSession.lex.tex @@ -0,0 +1,317 @@ +\begin{lexlean}{ResearchSession} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchProject} +\importmodule{ResearchWorkspace} +\importmodule{ResearchEvidence} +\importmodule{ResearchRecord} +\importmodule{ResearchCandidate} +\importmodule{ResearchProof} +\importmodule{ResearchExecution} +\importmodule{ResearchVerification} +\importmodule{VerificationReport} +\importmodule{Json} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: contract, + parameters: [], + result: String, + body: "Own one candidate attempt from exact-goal construction through verification and proof retention. Ordinary begin owns library checkout and release. beginPrepared borrows a ready library from a cohort and returns ownership to that cohort without removing it. Host replies and cancellation are the only inputs after begin. The session captures the same command and attestation reads the verifier consumes; no external receipt or checked answer can enter. A checked answer leaves the session only after exact evidence readback and completion of its project lifecycle. The cohort releases a borrowed library after all attempts finish. Failed archival of a checked proof retains its workspace for recovery. Cancellation drains outstanding replies. Normally exited tools permit cleanup; interrupted tools retain the workspace because descendant termination is not established by direct-child cleanup; cancellation during proof archival stops owned work and retains unarchived evidence. Strategy selection, attempt scheduling, source inspection and publication into the claim register remain enclosing application responsibilities.", + axioms: [], + executable: true +} + +inductive{ + name: Phase, + type_parameters: [], + parameters: [], + constructors: [{name: preparing, fields: []}, {name: readingLock, fields: []}, {name: readingManifest, fields: []}, {name: verifying, fields: []}, {name: archiving, fields: []}, {name: releasing, fields: []}, {name: ended, fields: []}, {name: blocked, fields: []}] +} + +structure{ + name: State, + type_parameters: [], + parameters: [], + fields: [{name: project, type: ResearchProject::State}, {name: candidate, type: (Option ResearchCandidate::State)}, {name: evidence, type: (Option ResearchEvidence::State)}, {name: phase, type: Phase}, {name: files, type: ResearchRecord::Files}, {name: pending, type: (Option Research::Answer)}, {name: retained, type: Bytes}, {name: cancelled, type: Bool}] +} + +inductive{ + name: Event, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Event]}, {name: cancel, fields: []}] +} + +inductive{ + name: Emission, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Request]}, {name: awaiting, fields: []}, {name: complete, fields: [Research::Answer, Bytes]}, {name: blocked, fields: [String]}] +} + +definition{ + name: sessionConfig, + parameters: [state : State], + result: ResearchProject::Config, + body: (project (project state project) config), + axioms: [], + executable: true +} + +definition{ + name: ownedRequest, + parameters: [state : State], + result: Research::Request, + body: (project (sessionConfig state) request), + axioms: [], + executable: true +} + +definition{ + name: answer, + parameters: [state : State, result : Research::ResultKind], + result: Research::Answer, + body: (record Research::Answer {request := (ownedRequest state), result := result}), + axioms: [], + executable: true +} + +definition{ + name: blocked, + parameters: [state : State, reason : String], + result: (State * Emission), + body: ((record State {project := (project state project), candidate := (project state candidate), evidence := (project state evidence), phase := (ctor Phase.blocked), files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}), (ctor Emission.blocked reason)), + axioms: [], + executable: true +} + +definition{ + name: finish, + parameters: [state : State, outcome : Research::Answer], + result: (State * Emission), + body: ((record State {project := (project state project), candidate := (project state candidate), evidence := (project state evidence), phase := (ctor Phase.ended), files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}), (ctor Emission.complete outcome (project state retained))), + axioms: [], + executable: true +} + +definition{ + name: isChecked, + parameters: [outcome : Research::Answer], + result: Bool, + body: (match (project outcome result) | Research::ResultKind.checked goal theorem axioms => true | Research::ResultKind.inspected goal => false | Research::ResultKind.maintained sources evidence => false | Research::ResultKind.failed reason => false | Research::ResultKind.cut => false | Research::ResultKind.unavailable => false), + axioms: [], + executable: true +} + +definition{ + name: finishPending, + parameters: [state : State], + result: (State * Emission), + body: (if (project state cancelled) then (finish state (answer state (ctor Research::ResultKind.cut))) else (match (project state pending) | Option.none => (blocked state "workspace released without an attempt result") | Option.some outcome => (if ((isChecked outcome) && ((prim length (project state retained) : Nat) =? 0)) then (blocked state "checked proof has no retained evidence") else (finish state outcome)))), + axioms: [], + executable: true +} + +definition{ + name: preparationResult, + parameters: [state : State, kind : ResearchExecution::EndKind], + result: (State * Emission), + body: (finish state (answer state (match kind | ResearchExecution::EndKind.cut => (ctor Research::ResultKind.cut) | ResearchExecution::EndKind.unavailable => (ctor Research::ResultKind.unavailable) | ResearchExecution::EndKind.succeeded => (ctor Research::ResultKind.failed 0x7072657061726174696f6e20656e64656420776974686f757420612063616e646964617465) | ResearchExecution::EndKind.failed => (ctor Research::ResultKind.failed 0x63616e646964617465207072657061726174696f6e206661696c6564) | ResearchExecution::EndKind.protocol => (ctor Research::ResultKind.failed 0x63616e646964617465207072657061726174696f6e2070726f746f636f6c206661696c757265) | ResearchExecution::EndKind.cleanupFailed => (ctor Research::ResultKind.failed 0x63616e646964617465207072657061726174696f6e20636c65616e7570206661696c757265) | ResearchExecution::EndKind.refused => (ctor Research::ResultKind.failed 0x63616e646964617465207072657061726174696f6e2072656675736564)))), + axioms: [], + executable: true +} + +definition{ + name: projectResult, + parameters: [state : State, result : (ResearchProject::State * ResearchProject::Emission)], + result: (State * Emission), + body: (let next : State := (record State {project := (first result), candidate := (project state candidate), evidence := (project state evidence), phase := (project state phase), files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}); (match (second result) | ResearchProject::Emission.host request => (next, (ctor Emission.host request)) | ResearchProject::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchProject::Emission.blocked reason => (blocked next reason) | ResearchProject::Emission.refused => (blocked next "owned project operation refused") | ResearchProject::Emission.ready context => ((record State {project := (first result), candidate := (project state candidate), evidence := (project state evidence), phase := (ctor Phase.readingLock), files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}), (ctor Emission.host (ctor LexLeanStd.Host::Request.read (ResearchProject::path (sessionConfig next) "/lexlean.lock")))) | ResearchProject::Emission.complete kind => (match (project state phase) | Phase.releasing => (match kind | ResearchExecution::EndKind.succeeded => (finishPending next) | ResearchExecution::EndKind.cut => (if (project next cancelled) then (finishPending next) else (blocked next "unexpected cut during workspace release")) | ResearchExecution::EndKind.failed => (blocked next "workspace release failed") | ResearchExecution::EndKind.unavailable => (blocked next "workspace release unavailable") | ResearchExecution::EndKind.protocol => (blocked next "workspace release protocol failure") | ResearchExecution::EndKind.cleanupFailed => (blocked next "workspace release cleanup failure") | ResearchExecution::EndKind.refused => (blocked next "workspace release refused")) | Phase.preparing => (preparationResult next kind) | Phase.readingLock => (blocked next "unexpected project completion") | Phase.readingManifest => (blocked next "unexpected project completion") | Phase.verifying => (blocked next "unexpected project completion") | Phase.archiving => (blocked next "unexpected project completion") | Phase.ended => (blocked next "unexpected project completion") | Phase.blocked => (blocked next "unexpected project completion")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: release, + parameters: [state : State, outcome : Research::Answer], + result: (State * Emission), + body: (let next : State := (record State {project := (project state project), candidate := (project state candidate), evidence := (project state evidence), phase := (ctor Phase.releasing), files := (project state files), pending := (ctor Option.some [Research::Answer] outcome), retained := (project state retained), cancelled := (project state cancelled)}); (projectResult next (ResearchProject::step (project state project) (ctor ResearchProject::Event.release)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: evidenceConfig, + parameters: [state : State], + result: ResearchEvidence::Config, + body: (let config : ResearchProject::Config := (sessionConfig state); (let workspace : ResearchWorkspace::Config := (project config workspace); (record ResearchEvidence::Config {request := (ownedRequest state), repository := (ResearchWorkspace::path workspace), recordPath := (ResearchProject::path config "/evidence.json"), environment := (project workspace environment), output := (ResearchProject::path config "/evidence.out"), errors := (ResearchProject::path config "/evidence.err"), maxBytes := (project config maxBytes), maxSteps := (project config maxSteps), allowance := (project workspace allowance), quantum := (project workspace quantum), polls := (project workspace polls), revision := (project workspace revision)}))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: evidenceResult, + parameters: [state : State, result : (ResearchEvidence::State * ResearchEvidence::Emission)], + result: (State * Emission), + body: (let next : State := (record State {project := (project state project), candidate := (project state candidate), evidence := (ctor Option.some [ResearchEvidence::State] (first result)), phase := (project state phase), files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}); (match (second result) | ResearchEvidence::Emission.host request => (next, (ctor Emission.host request)) | ResearchEvidence::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchEvidence::Emission.blocked reason => (blocked next reason) | ResearchEvidence::Emission.failed reason => (blocked next reason) | ResearchEvidence::Emission.cut => (blocked next "cancelled archival retains the verified candidate workspace") | ResearchEvidence::Emission.complete identity => (match (project next pending) | Option.none => (blocked next "evidence stored without a checked attempt") | Option.some outcome => (release (record State {project := (project state project), candidate := (project state candidate), evidence := (ctor Option.some [ResearchEvidence::State] (first result)), phase := (project state phase), files := (project state files), pending := (project state pending), retained := identity, cancelled := (project state cancelled)}) outcome)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: archive, + parameters: [state : State, outcome : Research::Answer], + result: (State * Emission), + body: (match (project state candidate) | Option.none => (blocked state "checked answer has no owned candidate") | Option.some candidate => (match (ResearchRecord::fromCandidate (project state project) candidate (project state files)) | Option.none => (blocked state "checked candidate has incomplete replay evidence") | Option.some document => (evidenceResult (record State {project := (project state project), candidate := (project state candidate), evidence := (project state evidence), phase := (ctor Phase.archiving), files := (project state files), pending := (ctor Option.some [Research::Answer] outcome), retained := (project state retained), cancelled := (project state cancelled)}) (ResearchEvidence::begin (evidenceConfig state) document)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: executionEndedNormally, + parameters: [execution : ResearchExecution::State], + result: Bool, + body: (match (project execution phase) | ResearchExecution::Phase.ended completion => (ResearchWorkspace::exitedNormally completion) | ResearchExecution::Phase.clock => false | ResearchExecution::Phase.cancelledClock => false | ResearchExecution::Phase.spawning started => false | ResearchExecution::Phase.cancelledSpawn started => false | ResearchExecution::Phase.cancelledWait child clock => false | ResearchExecution::Phase.waiting child started previous polls => false | ResearchExecution::Phase.stopping kind clock detail => false), + axioms: [], + executable: true +} + +definition{ + name: candidateEndedNormally, + parameters: [candidate : ResearchCandidate::State], + result: Bool, + body: ((match (project candidate execution) | Option.none => true | Option.some execution => (executionEndedNormally execution)) && (match (project candidate proof) | Option.none => true | Option.some proof => (executionEndedNormally (project (project proof verification) execution)))), + axioms: [], + executable: true +} + +definition{ + name: candidateResult, + parameters: [state : State, result : (ResearchCandidate::State * ResearchProof::Emission)], + result: (State * Emission), + body: (let next : State := (record State {project := (project state project), candidate := (ctor Option.some [ResearchCandidate::State] (first result)), evidence := (project state evidence), phase := (project state phase), files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}); (match (second result) | ResearchProof::Emission.host request => (next, (ctor Emission.host request)) | ResearchProof::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchProof::Emission.blocked completion => (blocked next "candidate child or verification protocol remains blocked") | ResearchProof::Emission.complete outcome => (if (candidateEndedNormally (first result)) then (if (isChecked outcome) then (archive next outcome) else (release next outcome)) else (blocked next "interrupted candidate retains workspace until descendant cleanup is established")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: captureBytes, + parameters: [state : State, data : Bytes, command : Bool], + result: State, + body: (record State {project := (project state project), candidate := (project state candidate), evidence := (project state evidence), phase := (project state phase), files := (record ResearchRecord::Files {lock := (project (project state files) lock), lakeManifest := (project (project state files) lakeManifest), command := (if command then data else (project (project state files) command)), attestation := (if command then (project (project state files) attestation) else data)}), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}), + axioms: [], + executable: true +} + +definition{ + name: capture, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: State, + body: (match (Host::asRead event) | Option.none => state | Option.some response => (match response | Result.error failure => state | Result.ok data => (match (project state candidate) | Option.none => state | Option.some candidate => (match (project candidate phase) | ResearchCandidate::Phase.running => state | ResearchCandidate::Phase.reading => state | ResearchCandidate::Phase.ended => state | ResearchCandidate::Phase.verifying => (match (project candidate proof) | Option.none => state | Option.some proof => (match (project (project proof verification) phase) | ResearchVerification::Phase.running => state | ResearchVerification::Phase.command => (captureBytes state data true) | ResearchVerification::Phase.attestation commandBytes => (captureBytes state data false) | ResearchVerification::Phase.ended => state)))))), + axioms: [], + executable: true +} + +definition{ + name: inputRead, + parameters: [state : State, event : LexLeanStd.Host::Event, lockFile : Bool], + result: (State * Emission), + body: (match (Host::asRead event) | Option.none => (blocked state "unexpected replay input read") | Option.some response => (if (project state cancelled) then (release state (answer state (ctor Research::ResultKind.cut))) else (match response | Result.error failure => (release state (answer state (ctor Research::ResultKind.failed 0x63616e6469646174652070726f6a65637420696e7075742072656164206661696c6564))) | Result.ok data => (if ((0 (projectResult state (ResearchProject::step (project state project) (ctor ResearchProject::Event.host event))) | Phase.releasing => (projectResult state (ResearchProject::step (project state project) (ctor ResearchProject::Event.host event))) | Phase.readingLock => (inputRead state event true) | Phase.readingManifest => (inputRead state event false) | Phase.verifying => (match (project state candidate) | Option.none => (blocked state "missing candidate lifecycle") | Option.some candidate => (candidateResult (capture state event) (ResearchCandidate::step candidate (ctor ResearchVerification::Event.host event)))) | Phase.archiving => (match (project state evidence) | Option.none => (blocked state "missing evidence lifecycle") | Option.some evidence => (evidenceResult state (ResearchEvidence::step evidence (ctor ResearchEvidence::Event.host event)))) | Phase.ended => (state, (ctor Emission.awaiting)) | Phase.blocked => (state, (ctor Emission.blocked "research session remains blocked"))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: cancel, + parameters: [state : State], + result: (State * Emission), + body: (let next : State := (record State {project := (project state project), candidate := (project state candidate), evidence := (project state evidence), phase := (project state phase), files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := true}); (match (project state phase) | Phase.preparing => (projectResult next (ResearchProject::step (project state project) (ctor ResearchProject::Event.cancel))) | Phase.releasing => (projectResult next (ResearchProject::step (project state project) (ctor ResearchProject::Event.cancel))) | Phase.readingLock => (next, (ctor Emission.awaiting)) | Phase.readingManifest => (next, (ctor Emission.awaiting)) | Phase.verifying => (match (project state candidate) | Option.none => (blocked next "missing candidate during cancellation") | Option.some candidate => (candidateResult next (ResearchCandidate::step candidate (ctor ResearchVerification::Event.cancel)))) | Phase.archiving => (match (project state evidence) | Option.none => (blocked next "missing evidence during cancellation") | Option.some evidence => (evidenceResult next (ResearchEvidence::step evidence (ctor ResearchEvidence::Event.cancel)))) | Phase.ended => (state, (ctor Emission.awaiting)) | Phase.blocked => (state, (ctor Emission.blocked "research session remains blocked")))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: begin, + parameters: [config : ResearchProject::Config], + result: (State * Emission), + body: (let started : (ResearchProject::State * ResearchProject::Emission) := (ResearchProject::begin config); (let state : State := (record State {project := (first started), candidate := (ctor Option.none [ResearchCandidate::State]), evidence := (ctor Option.none [ResearchEvidence::State]), phase := (ctor Phase.preparing), files := (ResearchRecord::emptyFiles), pending := (ctor Option.none [Research::Answer]), retained := 0x, cancelled := false}); (projectResult state started))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: beginPrepared, + parameters: [config : ResearchProject::Config, owner : ResearchWorkspace::State], + result: (State * Emission), + body: (let started : (ResearchProject::State * ResearchProject::Emission) := (ResearchProject::beginPrepared config owner); (let state : State := (record State {project := (first started), candidate := (ctor Option.none [ResearchCandidate::State]), evidence := (ctor Option.none [ResearchEvidence::State]), phase := (ctor Phase.preparing), files := (ResearchRecord::emptyFiles), pending := (ctor Option.none [Research::Answer]), retained := 0x, cancelled := false}); (projectResult state started))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: withPhase, + parameters: [state : State, phase : Phase], + result: State, + body: (record State {project := (project state project), candidate := (project state candidate), evidence := (project state evidence), phase := phase, files := (project state files), pending := (project state pending), retained := (project state retained), cancelled := (project state cancelled)}), + axioms: [], + executable: true +} + +definition{ + name: dispatchEvent, + parameters: [state : State, event : Event], + result: (State * Emission), + body: (match event | Event.host response => (host state response) | Event.cancel => (cancel state)), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: step, + parameters: [state : State, event : Event], + result: (State * Emission), + body: (match (project state phase) | Phase.ended => (state, (ctor Emission.awaiting)) | Phase.blocked => (state, (ctor Emission.blocked "research session remains blocked")) | Phase.preparing => (dispatchEvent state event) | Phase.readingLock => (dispatchEvent state event) | Phase.readingManifest => (dispatchEvent state event) | Phase.verifying => (dispatchEvent state event) | Phase.archiving => (dispatchEvent state event) | Phase.releasing => (dispatchEvent state event)), + axioms: [Quot.sound, propext], + executable: true +} + +theorem{ + name: endedSessionCannotIssueAnotherRequest, + parameters: [state : State, event : Event], + statement: ((step (withPhase state (ctor Phase.ended)) event) = ((withPhase state (ctor Phase.ended)), (ctor Emission.awaiting))), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: blockedSessionCannotResume, + parameters: [state : State, event : Event], + statement: ((step (withPhase state (ctor Phase.blocked)) event) = ((withPhase state (ctor Phase.blocked)), (ctor Emission.blocked "research session remains blocked"))), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "terminal-session-silence" (cons "blocked-session-retention" (cons "owned-candidate-attempt" (cons "same-read-report-capture" (cons "replay-input-retention" (cons "durability-before-checked-answer" (cons "cleanup-before-result-delivery" (cons "unarchived-proof-workspace-retention" (cons "no-external-receipt-event" (cons "cancellation-suppresses-checked-result" (nil String))))))))))), + axioms: [], + executable: true +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchSessionTraces.lex.tex b/rule30-api/src/ResearchSessionTraces.lex.tex new file mode 100644 index 0000000..c065d59 --- /dev/null +++ b/rule30-api/src/ResearchSessionTraces.lex.tex @@ -0,0 +1,242 @@ +\begin{lexlean}{ResearchSessionTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Research} +\importmodule{ResearchSession} +\importmodule{ResearchRecord} +\importmodule{ResearchProject} +\importmodule{ResearchProjectTraces} +\importmodule{ResearchWorkspace} +\importmodule{ResearchWorkspaceTraces} +\importmodule{ResearchEvidence} +\importmodule{ResearchEvidenceTraces} +\importmodule{ResearchCandidate} +\importmodule{ResearchProof} +\importmodule{ResearchVerification} +\importmodule{VerificationReport} +\importmodule{CandidateBinding} +\importmodule{Json} +\importmodule{ResearchExecution} +\importmodule{ResearchExecutionTraces} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: checkedAnswer, + parameters: [], + result: Research::Answer, + body: (let request : Research::Request := (project (project (ResearchProjectTraces::config) workspace) request); (record Research::Answer {request := request, result := (ctor Research::ResultKind.checked (project (project request task) sequent) 0x70726f6f66 (nil String))})), + axioms: [propext] +} + +definition{ + name: archiving, + parameters: [], + result: ResearchSession::State, + body: (record ResearchSession::State {project := (first (ResearchProjectTraces::ready)), candidate := (ctor Option.none [ResearchCandidate::State]), evidence := (ctor Option.some [ResearchEvidence::State] (ResearchEvidenceTraces::writing)), phase := (ctor ResearchSession::Phase.archiving), files := (ResearchRecord::emptyFiles), pending := (ctor Option.some [Research::Answer] (checkedAnswer)), retained := 0x, cancelled := false}), + axioms: [Quot.sound, propext] +} + +definition{ + name: blocked, + parameters: [result : (ResearchSession::State * ResearchSession::Emission)], + result: Bool, + body: (match (second result) | ResearchSession::Emission.blocked reason => true | ResearchSession::Emission.host request => false | ResearchSession::Emission.awaiting => false | ResearchSession::Emission.complete answer identity => false), + axioms: [] +} + +definition{ + name: completeChecked, + parameters: [result : (ResearchSession::State * ResearchSession::Emission)], + result: Bool, + body: (match (second result) | ResearchSession::Emission.complete answer identity => ((ResearchSession::isChecked answer) && (Toml::sameBytes identity 0x6964)) | ResearchSession::Emission.host request => false | ResearchSession::Emission.awaiting => false | ResearchSession::Emission.blocked reason => false), + axioms: [] +} + +definition{ + name: completeCut, + parameters: [result : (ResearchSession::State * ResearchSession::Emission)], + result: Bool, + body: (match (second result) | ResearchSession::Emission.complete answer identity => (match (project answer result) | Research::ResultKind.cut => true | Research::ResultKind.checked goal theorem axioms => false | Research::ResultKind.inspected goal => false | Research::ResultKind.maintained sources evidence => false | Research::ResultKind.failed reason => false | Research::ResultKind.unavailable => false) | ResearchSession::Emission.host request => false | ResearchSession::Emission.awaiting => false | ResearchSession::Emission.blocked reason => false), + axioms: [] +} + +definition{ + name: ownsWorkspace, + parameters: [value : ResearchSession::State], + result: Bool, + body: (ResearchProjectTraces::ownsWorkspace (project value project)), + axioms: [] +} + +definition{ + name: host, + parameters: [value : ResearchSession::State, event : LexLeanStd.Host::Event], + result: (ResearchSession::State * ResearchSession::Emission), + body: (ResearchSession::step value (ctor ResearchSession::Event.host event)), + axioms: [Quot.sound, propext] +} + +definition{ + name: finishJob, + parameters: [value : ResearchSession::State, code : Int32], + result: (ResearchSession::State * ResearchSession::Emission), + body: (host (first (host (first (host value (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100))))) (ResearchExecutionTraces::exitEvent 7 (ctor Option.some [Int32] code) 101)), + axioms: [Quot.sound, propext] +} + +definition{ + name: releasing, + parameters: [], + result: ResearchSession::State, + body: (first (ResearchSession::evidenceResult (archiving) ((ResearchEvidenceTraces::writing), (ctor ResearchEvidence::Emission.complete 0x6964)))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: checkedAnswerWithoutRetentionIsBlocked, + parameters: [], + statement: ((blocked (ResearchSession::finishPending (archiving))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: storedEvidenceWaitsForWorkspaceRemoval, + parameters: [], + statement: (((ownsWorkspace (releasing)) && (not (completeChecked (ResearchSession::evidenceResult (archiving) ((ResearchEvidenceTraces::writing), (ctor ResearchEvidence::Emission.complete 0x6964)))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cleanupThenDeliversCheckedAnswerAndRecord, + parameters: [], + statement: ((completeChecked (finishJob (releasing) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledCleanupSuppressesCheckedAnswer, + parameters: [], + statement: ((completeCut (finishJob (first (ResearchSession::step (releasing) (ctor ResearchSession::Event.cancel))) (0 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedRemovalCannotDeliverCheckedAnswer, + parameters: [], + statement: (((blocked (finishJob (releasing) (1 : Int32))) && (ownsWorkspace (first (finishJob (releasing) (1 : Int32))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: failedArchive, + parameters: [], + result: (ResearchSession::State * ResearchSession::Emission), + body: (ResearchSession::evidenceResult (archiving) ((ResearchEvidenceTraces::writing), (ctor ResearchEvidence::Emission.failed "storage unavailable"))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedArchiveRetainsTheOnlyVerifiedSource, + parameters: [], + statement: (((blocked (failedArchive)) && (ownsWorkspace (first (failedArchive)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: cancelledArchive, + parameters: [], + result: (ResearchSession::State * ResearchSession::Emission), + body: (host (first (ResearchSession::step (archiving) (ctor ResearchSession::Event.cancel))) (ResearchEvidenceTraces::written)), + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledArchiveRetainsUnpublishedProof, + parameters: [], + statement: (((blocked (cancelledArchive)) && (ownsWorkspace (first (cancelledArchive)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: checkedAnswerWithoutCandidateStateCannotArchive, + parameters: [], + statement: ((blocked (ResearchSession::archive (archiving) (checkedAnswer))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: captureVerification, + parameters: [phase : ResearchVerification::Phase], + result: ResearchVerification::State, + body: (let config : ResearchVerification::Config := (ResearchProject::verificationConfig (ResearchProjectTraces::config)); (let pins : VerificationReport::Pins := (record VerificationReport::Pins {request := (project (ResearchProjectTraces::config) request), source := 0x, semantic := 0x, compiler := 0x, lexlean := 0x, lean := 0x, lake := 0x, checker := 0x, theorem := 0x, module := 0x}); (record ResearchVerification::State {pins := pins, config := config, execution := (record ResearchExecution::State {job := (ResearchVerification::job pins config), phase := (ctor ResearchExecution::Phase.clock), owner := (ctor Option.none [Nat])}), phase := phase, cancelled := false, outcome := (ctor Option.none [ResearchVerification::Outcome])}))), + axioms: [Quot.sound, propext] +} + +definition{ + name: capturing, + parameters: [phase : ResearchVerification::Phase], + result: ResearchSession::State, + body: (let value : ResearchSession::State := (archiving); (record ResearchSession::State {project := (project value project), candidate := (ctor Option.some [ResearchCandidate::State] (record ResearchCandidate::State {context := (ResearchProject::context (ResearchProjectTraces::config)), execution := (ctor Option.none [ResearchExecution::State]), proof := (ctor Option.some [ResearchProof::State] (record ResearchProof::State {verification := (captureVerification phase), binding := (record CandidateBinding::Input {linked := (ctor Json::Value.null), lexicon := (ctor Json::Value.null)}), maxDepth := 32, maxSteps := 1024})), phase := (ctor ResearchCandidate::Phase.verifying), cancelled := false})), evidence := (project value evidence), phase := (ctor ResearchSession::Phase.verifying), files := (project value files), pending := (project value pending), retained := (project value retained), cancelled := (project value cancelled)})), + axioms: [Quot.sound, propext] +} + +theorem{ + name: captureOwnedCommandBytes, + parameters: [], + statement: ((Toml::sameBytes (project (project (ResearchSession::capture (capturing (ctor ResearchVerification::Phase.command)) (ResearchWorkspaceTraces::readEvent 0x636f6d6d616e64)) files) command) 0x636f6d6d616e64) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: captureOwnedAttestationBytes, + parameters: [], + statement: ((Toml::sameBytes (project (project (ResearchSession::capture (capturing (ctor ResearchVerification::Phase.attestation 0x636f6d6d616e64)) (ResearchWorkspaceTraces::readEvent 0x6174746573746174696f6e)) files) attestation) 0x6174746573746174696f6e) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: processOutputBeforeVerificationIsNotCaptured, + parameters: [], + statement: ((Toml::sameBytes (project (project (ResearchSession::capture (capturing (ctor ResearchVerification::Phase.running)) (ResearchWorkspaceTraces::readEvent 0x66616b65)) files) command) 0x) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +definition{ + name: verifyingCandidate, + parameters: [], + result: ResearchSession::State, + body: (let value : ResearchSession::State := (archiving); (record ResearchSession::State {project := (project value project), candidate := (ctor Option.some [ResearchCandidate::State] (first (ResearchCandidate::begin (ResearchProject::context (ResearchProjectTraces::config))))), evidence := (ctor Option.none [ResearchEvidence::State]), phase := (ctor ResearchSession::Phase.verifying), files := (ResearchRecord::emptyFiles), pending := (ctor Option.none [Research::Answer]), retained := 0x, cancelled := false})), + axioms: [Quot.sound, propext] +} + +definition{ + name: stoppedCandidate, + parameters: [], + result: (ResearchSession::State * ResearchSession::Emission), + body: (let active : ResearchSession::State := (first (host (first (host (verifyingCandidate) (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100))))); (let cancelled : ResearchSession::State := (first (ResearchSession::step active (ctor ResearchSession::Event.cancel))); (let stopping : ResearchSession::State := (first (host cancelled (ResearchExecutionTraces::waitEvent 101 (nil (Nat * (Option Int32)))))); (host stopping (ResearchExecutionTraces::stopOk))))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: interruptedCandidateRetainsWorkspace, + parameters: [], + statement: (((blocked (stoppedCandidate)) && (ownsWorkspace (first (stoppedCandidate)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchTraces.lex.tex b/rule30-api/src/ResearchTraces.lex.tex index e35327a..2eb9f42 100644 --- a/rule30-api/src/ResearchTraces.lex.tex +++ b/rule30-api/src/ResearchTraces.lex.tex @@ -345,7 +345,7 @@ theorem{ name: everyApplicationAndLibraryModuleGetsOneMaintenanceTask, parameters: [], - statement: ((prim length (ResearchCatalog::maintenanceTasks (ResearchCatalog::registeredScopes)) : Nat) = 70), + statement: ((prim length (ResearchCatalog::maintenanceTasks (ResearchCatalog::registeredScopes)) : Nat) = 87), proof: decide{} } definition{ diff --git a/rule30-api/src/ResearchVerification.lex.tex b/rule30-api/src/ResearchVerification.lex.tex index 88e99ca..abdaa86 100644 --- a/rule30-api/src/ResearchVerification.lex.tex +++ b/rule30-api/src/ResearchVerification.lex.tex @@ -174,7 +174,7 @@ name: begin, parameters: [pins : VerificationReport::Pins, config : Config], result: (State * Emission), - body: (let initial : ResearchExecution::State := (record ResearchExecution::State {job := (job pins config), phase := (ctor ResearchExecution::Phase.spawning), owner := (ctor Option.none [Nat])}); (let state : State := (record State {pins := pins, config := config, execution := initial, phase := (ctor Phase.running), cancelled := false, outcome := (ctor Option.none [Outcome])}); (if (validConfig pins config) then (executionResult state (ResearchExecution::begin (job pins config))) else (finish state (ctor Outcome.rejected "invalid verification plan"))))), + body: (let initial : ResearchExecution::State := (record ResearchExecution::State {job := (job pins config), phase := (ctor ResearchExecution::Phase.clock), owner := (ctor Option.none [Nat])}); (let state : State := (record State {pins := pins, config := config, execution := initial, phase := (ctor Phase.running), cancelled := false, outcome := (ctor Option.none [Outcome])}); (if (validConfig pins config) then (executionResult state (ResearchExecution::begin (job pins config))) else (finish state (ctor Outcome.rejected "invalid verification plan"))))), axioms: [propext], executable: true, production: {effects: [allocation, files, overflow, process, recursion], targets: [rust-std]} diff --git a/rule30-api/src/ResearchVerificationTraces.lex.tex b/rule30-api/src/ResearchVerificationTraces.lex.tex index efeecd8..027083e 100644 --- a/rule30-api/src/ResearchVerificationTraces.lex.tex +++ b/rule30-api/src/ResearchVerificationTraces.lex.tex @@ -31,8 +31,8 @@ name: begin, parameters: [], result: (ResearchVerification::State * ResearchVerification::Emission), - body: (ResearchVerification::begin (VerificationReportTraces::pins) (settings)), - axioms: [propext] + body: (ResearchVerification::step (first (ResearchVerification::begin (VerificationReportTraces::pins) (settings))) (ctor ResearchVerification::Event.host (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))), + axioms: [Quot.sound, propext] } definition{ @@ -61,7 +61,7 @@ name: completedExecution, parameters: [], result: ResearchExecution::State, - body: (let finished : ResearchExecution::State := (first (ResearchExecution::finish (ResearchVerification::job (VerificationReportTraces::pins) (settings)) (ctor ResearchExecution::EndKind.succeeded) (ctor Option.some [Int32] (0 : Int32)) 101 0x)); (record ResearchExecution::State {job := (project finished job), phase := (project finished phase), owner := (ctor Option.some [Nat] 7)})), + body: (first (ResearchExecution::finish (ResearchVerification::job (VerificationReportTraces::pins) (settings)) (ctor ResearchExecution::EndKind.succeeded) (ctor Option.some [Int32] (0 : Int32)) 101 0x)), axioms: [propext] } @@ -237,7 +237,7 @@ parameters: [], statement: ((program (begin)) = "lexlean"), proof: decide{}, - axioms: [propext] + axioms: [Quot.sound, propext] } theorem{ @@ -245,7 +245,7 @@ parameters: [], statement: ((argumentCount (begin)) = 5), proof: decide{}, - axioms: [propext] + axioms: [Quot.sound, propext] } theorem{ diff --git a/rule30-api/src/ResearchWorkspace.lex.tex b/rule30-api/src/ResearchWorkspace.lex.tex new file mode 100644 index 0000000..b1571d4 --- /dev/null +++ b/rule30-api/src/ResearchWorkspace.lex.tex @@ -0,0 +1,314 @@ +\begin{lexlean}{ResearchWorkspace} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Host} +\importmodule{Research} +\importmodule{ResearchExecution} +\importmodule{ResearchVerification} +\importmodule{VerificationReport} +\importmodule{Hypotheses} +\importmodule{Toml} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: contract, + parameters: [], + result: String, + body: "Own a fresh detached Git worktree for one research request. Its full revision is immutable and its observed tree must equal the request library snapshot before a local library build. Tracked sources are checked again after the build before readiness. Existing paths are refused. Readiness grants an owned prepared workspace, never proof evidence. The caller owns the parent checkout and pinned tool environment. Repository paths must be absolute printable ASCII, which the admitted Host text adapter represents exactly. Cancellation drains pending host replies; uncertainty during creation or failed removal blocks reuse and retains recovery state. Only successful owned creation authorizes removal. A stopped or signalled tool has no normal exit code; its workspace is retained because direct-child cleanup does not establish descendant termination. Ready workspaces must be released after their candidate lifecycle ends.", + axioms: [], + executable: true +} + +structure{ + name: Config, + type_parameters: [], + parameters: [], + fields: [{name: request, type: Research::Request}, {name: repository, type: Bytes}, {name: revision, type: Bytes}, {name: environment, type: (List (String * String))}, {name: output, type: String}, {name: errors, type: String}, {name: allowance, type: Nat}, {name: quantum, type: Nat}, {name: polls, type: Nat}] +} +inductive{ + name: Operation, + type_parameters: [], + parameters: [], + constructors: [{name: create, fields: []}, {name: identify, fields: []}, {name: clean, fields: []}, {name: build, fields: []}, {name: remove, fields: []}, {name: runtime, fields: []}, {name: laws, fields: []}, {name: finalize, fields: []}] +} +inductive{ + name: Phase, + type_parameters: [], + parameters: [], + constructors: [{name: checking, fields: []}, {name: executing, fields: []}, {name: reading, fields: []}, {name: ready, fields: []}, {name: ended, fields: []}, {name: blocked, fields: []}] +} +structure{ + name: State, + type_parameters: [], + parameters: [], + fields: [{name: config, type: Config}, {name: operation, type: Operation}, {name: phase, type: Phase}, {name: execution, type: (Option ResearchExecution::State)}, {name: owned, type: Bool}, {name: cancelled, type: Bool}, {name: result, type: ResearchExecution::EndKind}, {name: detail, type: String}] +} +inductive{ + name: Event, + type_parameters: [], + parameters: [], + constructors: [{name: host, fields: [LexLeanStd.Host::Event]}, {name: cancel, fields: []}, {name: release, fields: []}] +} +inductive{ + name: Emission, + type_parameters: [], + parameters: [], + constructors: [{name: awaiting, fields: []}, {name: host, fields: [LexLeanStd.Host::Request]}, {name: ready, fields: [String]}, {name: complete, fields: [ResearchExecution::EndKind]}, {name: blocked, fields: [String]}, {name: refused, fields: []}] +} + +definition{ + name: text, + parameters: [data : Bytes], + result: String, + body: (Host::textOf data), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: path, + parameters: [config : Config], + result: String, + body: (ResearchVerification::concat (text (project config repository)) (ResearchVerification::concat "/.r30/research/" (ResearchVerification::concat (text (project config revision)) (ResearchVerification::concat "-" (text (Hypotheses::decimal (project (project config request) serial))))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: objectId, + parameters: [value : Bytes], + result: Bool, + body: ((((prim length value : Nat) =? 40) || ((prim length value : Nat) =? 64)) && (VerificationReport::hexFrom value 0 (prim length value : Nat))), + axioms: [propext], + executable: true +} +definition{ + name: arguments, + parameters: [config : Config, operation : Operation], + result: (List String), + body: (match operation + | Operation.create => (cons "-c" (cons "core.hooksPath=/dev/null" (cons "worktree" (cons "add" (cons "--detach" (cons "--" (cons (path config) (cons (text (project config revision)) (nil String))))))))) + | Operation.identify => (cons "rev-parse" (cons "--verify" (cons "HEAD^{tree}" (nil String)))) + | Operation.finalize => (cons "diff" (cons "--exit-code" (cons "HEAD" (cons "--" (nil String))))) + | Operation.clean => (cons "diff" (cons "--exit-code" (cons "HEAD" (cons "--" (nil String))))) + | Operation.build => (cons "build" (cons "Rule30UOR" (nil String))) + | Operation.runtime => (cons "build" (cons "LexLeanRuntime" (nil String))) + | Operation.laws => (cons "env" (cons "lean" (cons "-R" (cons "." (cons "-o" (cons ".lake/build/lib/lean/LexLeanRuntime/Laws.olean" (cons "-i" (cons ".lake/build/lib/lean/LexLeanRuntime/Laws.ilean" (cons "LexLeanRuntime/Laws.lean" (nil String)))))))))) + | Operation.remove => (cons "worktree" (cons "remove" (cons "--force" (cons "--" (cons (path config) (nil String))))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: job, + parameters: [config : Config, operation : Operation], + result: ResearchExecution::Job, + body: (record ResearchExecution::Job {request := (project config request), tool := (match operation | Operation.build => (ctor ResearchExecution::Tool.lake) | Operation.runtime => (ctor ResearchExecution::Tool.lake) | Operation.laws => (ctor ResearchExecution::Tool.lake) | Operation.create => (ctor ResearchExecution::Tool.git) | Operation.identify => (ctor ResearchExecution::Tool.git) | Operation.clean => (ctor ResearchExecution::Tool.git) | Operation.finalize => (ctor ResearchExecution::Tool.git) | Operation.remove => (ctor ResearchExecution::Tool.git)), arguments := (arguments config operation), directory := (match operation | Operation.create => (text (project config repository)) | Operation.remove => (text (project config repository)) | Operation.identify => (path config) | Operation.clean => (path config) | Operation.finalize => (path config) | Operation.build => (ResearchVerification::concat (path config) "/rule30-core-lean") | Operation.runtime => (ResearchVerification::concat (path config) "/rule30-core-lean") | Operation.laws => (ResearchVerification::concat (path config) "/rule30-core-lean")), environment := (project config environment), output := (project config output), errors := (project config errors), allowance := (project config allowance), quantum := (project config quantum), polls := (project config polls)}), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: asciiPath, + parameters: [data : Bytes, position : Nat, fuel : Nat], + result: Bool, + body: (match fuel | Nat.zero => (position =? (prim length data : Nat)) | Nat.succ more => (match (prim index data position : (Option UInt8)) | Option.none => false | Option.some byte => ((Toml::between byte (32 : UInt8) (126 : UInt8)) && (asciiPath data (position + 1) more)))), + axioms: [propext], + recursive_argument: fuel, + executable: true +} +definition{ + name: valid, + parameters: [config : Config], + result: Bool, + body: ((objectId (project config revision)) && ((objectId (project (project (project config request) snapshot) library)) && (((Host::sameByteAt (project config repository) 0 0x2f 0) && (asciiPath (project config repository) 0 (prim length (project config repository) : Nat))) && (ResearchExecution::validJob (job config (ctor Operation.create)))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: withPhase, + parameters: [state : State, phase : Phase], + result: State, + body: (record State {config := (project state config), operation := (project state operation), phase := phase, execution := (project state execution), owned := (project state owned), cancelled := (project state cancelled), result := (project state result), detail := (project state detail)}), + axioms: [], + executable: true +} +definition{ + name: blocked, + parameters: [state : State, reason : String], + result: (State * Emission), + body: ((record State {config := (project state config), operation := (project state operation), phase := (ctor Phase.blocked), execution := (project state execution), owned := (project state owned), cancelled := (project state cancelled), result := (project state result), detail := reason}), (ctor Emission.blocked reason)), + axioms: [], + executable: true +} +definition{ + name: finish, + parameters: [state : State, result : ResearchExecution::EndKind], + result: (State * Emission), + body: ((record State {config := (project state config), operation := (project state operation), phase := (ctor Phase.ended), execution := (ctor Option.none [ResearchExecution::State]), owned := false, cancelled := (project state cancelled), result := result, detail := (project state detail)}), (ctor Emission.complete result)), + axioms: [], + executable: true +} + +definition{ + name: launch, + parameters: [state : State, operation : Operation], + result: (State * Emission), + body: (let started : (ResearchExecution::State * ResearchExecution::Emission) := (ResearchExecution::begin (job (project state config) operation)); (let next : State := (record State {config := (project state config), operation := operation, phase := (ctor Phase.executing), execution := (ctor Option.some [ResearchExecution::State] (first started)), owned := (project state owned), cancelled := (project state cancelled), result := (project state result), detail := (project state detail)}); (match (second started) | ResearchExecution::Emission.host request => (next, (ctor Emission.host request)) | ResearchExecution::Emission.awaiting => (blocked next "workspace job did not spawn") | ResearchExecution::Emission.complete completion => (blocked next "workspace job was refused")))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: release, + parameters: [state : State, result : ResearchExecution::EndKind, detail : String], + result: (State * Emission), + body: (let next : State := (record State {config := (project state config), operation := (project state operation), phase := (project state phase), execution := (project state execution), owned := (project state owned), cancelled := (project state cancelled), result := result, detail := detail}); (if (project state owned) then (launch next (ctor Operation.remove)) else (finish next result))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: created, + parameters: [state : State], + result: (State * Emission), + body: (let next : State := (record State {config := (project state config), operation := (project state operation), phase := (project state phase), execution := (project state execution), owned := true, cancelled := (project state cancelled), result := (project state result), detail := (project state detail)}); (if (project state cancelled) then (release next (ctor ResearchExecution::EndKind.cut) "cancelled after checkout") else (launch next (ctor Operation.identify)))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: succeeded, + parameters: [state : State], + result: (State * Emission), + body: (match (project state operation) + | Operation.create => (created state) + | Operation.remove => (finish state (project state result)) + | Operation.identify => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut) "cancelled before identity read") else ((withPhase state (ctor Phase.reading)), (ctor Emission.host (ctor LexLeanStd.Host::Request.read (project (project state config) output))))) + | Operation.clean => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut) "cancelled before build") else (launch state (ctor Operation.runtime))) + | Operation.runtime => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut) "cancelled after runtime build") else (launch state (ctor Operation.laws))) + | Operation.laws => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut) "cancelled after law build") else (launch state (ctor Operation.build))) + | Operation.build => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut) "cancelled after build") else (launch state (ctor Operation.finalize))) + | Operation.finalize => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut) "cancelled after final source check") else ((withPhase state (ctor Phase.ready)), (ctor Emission.ready (path (project state config)))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: failed, + parameters: [state : State, result : ResearchExecution::EndKind], + result: (State * Emission), + body: (match (project state operation) + | Operation.create => (blocked state "checkout did not complete; workspace ownership is uncertain") + | Operation.remove => (blocked state "owned workspace removal did not complete") + | Operation.identify => (release state result "workspace identity command failed") + | Operation.clean => (release state result "workspace has changed tracked sources") + | Operation.finalize => (release state result "library build changed tracked sources") + | Operation.runtime => (release state result "pinned runtime build failed") + | Operation.laws => (release state result "pinned runtime law build failed") + | Operation.build => (release state result "pinned local library build failed")), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: exitedNormally, + parameters: [completion : ResearchExecution::Completion], + result: Bool, + body: (match (project completion code) | Option.none => false | Option.some code => true), + axioms: [], + executable: true +} + +definition{ + name: completed, + parameters: [state : State, completion : ResearchExecution::Completion], + result: (State * Emission), + body: (if ((ResearchExecution::resumeAllowed completion) && (exitedNormally completion)) then (match (project completion kind) + | ResearchExecution::EndKind.succeeded => (succeeded state) + | ResearchExecution::EndKind.failed => (failed state (if (project state cancelled) then (ctor ResearchExecution::EndKind.cut) else (ctor ResearchExecution::EndKind.failed))) + | ResearchExecution::EndKind.cut => (failed state (ctor ResearchExecution::EndKind.cut)) + | ResearchExecution::EndKind.unavailable => (failed state (ctor ResearchExecution::EndKind.unavailable)) + | ResearchExecution::EndKind.protocol => (blocked state "workspace execution protocol failure") + | ResearchExecution::EndKind.cleanupFailed => (blocked state "workspace child cleanup failed") + | ResearchExecution::EndKind.refused => (blocked state "workspace execution refused")) else (blocked state "workspace child remains owned, was interrupted, or its protocol failed; retain files until descendants are accounted for")), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: executionResult, + parameters: [state : State, result : (ResearchExecution::State * ResearchExecution::Emission)], + result: (State * Emission), + body: (let next : State := (record State {config := (project state config), operation := (project state operation), phase := (ctor Phase.executing), execution := (ctor Option.some [ResearchExecution::State] (first result)), owned := (project state owned), cancelled := (project state cancelled), result := (project state result), detail := (project state detail)}); (match (second result) | ResearchExecution::Emission.host request => (next, (ctor Emission.host request)) | ResearchExecution::Emission.awaiting => (next, (ctor Emission.awaiting)) | ResearchExecution::Emission.complete completion => (completed next completion))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: begin, + parameters: [config : Config], + result: (State * Emission), + body: (let state : State := (record State {config := config, operation := (ctor Operation.create), phase := (ctor Phase.checking), execution := (ctor Option.none [ResearchExecution::State]), owned := false, cancelled := false, result := (ctor ResearchExecution::EndKind.succeeded), detail := ""}); (if (valid config) then (state, (ctor Emission.host (ctor LexLeanStd.Host::Request.stat (path config)))) else (finish state (ctor ResearchExecution::EndKind.refused)))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: checkedPath, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (Host::asStated event) | Option.none => (blocked state "unexpected workspace stat reply") | Option.some outcome => (if (project state cancelled) then (finish state (ctor ResearchExecution::EndKind.cut)) else (match outcome | Result.ok entry => (finish state (ctor ResearchExecution::EndKind.refused)) | Result.error failure => (match (project failure kind) + | LexLeanStd.Host::FailureKind.notFound => (launch state (ctor Operation.create)) + | LexLeanStd.Host::FailureKind.alreadyExists => (finish state (ctor ResearchExecution::EndKind.unavailable)) + | LexLeanStd.Host::FailureKind.denied => (finish state (ctor ResearchExecution::EndKind.unavailable)) + | LexLeanStd.Host::FailureKind.other => (finish state (ctor ResearchExecution::EndKind.unavailable)))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: readIdentity, + parameters: [state : State, event : LexLeanStd.Host::Event], + result: (State * Emission), + body: (match (Host::asRead event) | Option.none => (blocked state "unexpected workspace identity reply") | Option.some outcome => (if (project state cancelled) then (release state (ctor ResearchExecution::EndKind.cut) "cancelled during identity read") else (match outcome | Result.error failure => (release state (ctor ResearchExecution::EndKind.failed) "workspace identity read failed") | Result.ok data => (if (Toml::sameBytes data (prim append (project (project (project (project state config) request) snapshot) library) 0x0a : Bytes)) then (launch state (ctor Operation.clean)) else (release state (ctor ResearchExecution::EndKind.failed) "workspace tree differs from requested library"))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: cancel, + parameters: [state : State], + result: (State * Emission), + body: (let next : State := (record State {config := (project state config), operation := (project state operation), phase := (project state phase), execution := (project state execution), owned := (project state owned), cancelled := true, result := (project state result), detail := (project state detail)}); (match (project state phase) + | Phase.checking => (next, (ctor Emission.awaiting)) + | Phase.reading => (next, (ctor Emission.awaiting)) + | Phase.ready => (release next (ctor ResearchExecution::EndKind.cut) "cancelled ready workspace") + | Phase.ended => (state, (ctor Emission.refused)) + | Phase.blocked => (state, (ctor Emission.blocked (project state detail))) + | Phase.executing => (match (project state operation) + | Operation.remove => (state, (ctor Emission.awaiting)) + | Operation.create => (match (project state execution) | Option.none => (blocked next "missing owned workspace execution") | Option.some active => (executionResult next (ResearchExecution::cancel active))) + | Operation.identify => (match (project state execution) | Option.none => (blocked next "missing owned workspace execution") | Option.some active => (executionResult next (ResearchExecution::cancel active))) + | Operation.clean => (match (project state execution) | Option.none => (blocked next "missing owned workspace execution") | Option.some active => (executionResult next (ResearchExecution::cancel active))) + | Operation.runtime => (match (project state execution) | Option.none => (blocked next "missing owned workspace execution") | Option.some active => (executionResult next (ResearchExecution::cancel active))) + | Operation.laws => (match (project state execution) | Option.none => (blocked next "missing owned workspace execution") | Option.some active => (executionResult next (ResearchExecution::cancel active))) + | Operation.finalize => (match (project state execution) | Option.none => (blocked next "missing owned workspace execution") | Option.some active => (executionResult next (ResearchExecution::cancel active))) + | Operation.build => (match (project state execution) | Option.none => (blocked next "missing owned workspace execution") | Option.some active => (executionResult next (ResearchExecution::cancel active)))))), + axioms: [Quot.sound, propext], + executable: true +} +definition{ + name: step, + parameters: [state : State, event : Event], + result: (State * Emission), + body: (match (project state phase) + | Phase.blocked => (state, (ctor Emission.blocked (project state detail))) + | Phase.ended => (state, (ctor Emission.refused)) + | Phase.ready => (match event | Event.cancel => (cancel state) | Event.release => (release state (ctor ResearchExecution::EndKind.succeeded) "released prepared workspace") | Event.host response => (state, (ctor Emission.refused))) + | Phase.checking => (match event | Event.cancel => (cancel state) | Event.release => (state, (ctor Emission.refused)) | Event.host response => (checkedPath state response)) + | Phase.reading => (match event | Event.cancel => (cancel state) | Event.release => (state, (ctor Emission.refused)) | Event.host response => (readIdentity state response)) + | Phase.executing => (match event | Event.cancel => (cancel state) | Event.release => (state, (ctor Emission.refused)) | Event.host response => (match (project state execution) | Option.none => (blocked state "missing owned workspace execution") | Option.some active => (executionResult state (ResearchExecution::step active response))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "interrupted-tool-workspace-retention" (cons "post-build-source-integrity" (cons "owned-detached-worktree" (cons "exact-library-tree" (cons "fresh-path-required" (cons "local-library-build" (cons "drain-before-cleanup" (cons "retain-uncertain-ownership" (nil String))))))))), + axioms: [], + executable: true +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchWorkspaceTraces.lex.tex b/rule30-api/src/ResearchWorkspaceTraces.lex.tex new file mode 100644 index 0000000..00dc910 --- /dev/null +++ b/rule30-api/src/ResearchWorkspaceTraces.lex.tex @@ -0,0 +1,285 @@ +\begin{lexlean}{ResearchWorkspaceTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Research} +\importmodule{ResearchExecution} +\importmodule{ResearchExecutionTraces} +\importmodule{ResearchWorkspace} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: tree, + parameters: [], + result: Bytes, + body: 0x30313233343536373839616263646566303132333435363738396162636465663031323334353637, + axioms: [] +} +definition{ + name: config, + parameters: [], + result: ResearchWorkspace::Config, + body: (record ResearchWorkspace::Config {request := (record Research::Request {serial := 3, snapshot := (record Research::Snapshot {library := (tree), compiler := 0x63, model := 0x6d}), task := (project (ResearchExecutionTraces::fixtureRequest) task)}), repository := 0x2f7265736561726368, revision := (tree), environment := (nil (String * String)), output := "/research/.r30/workspace.out", errors := "/research/.r30/workspace.err", allowance := 1000, quantum := 10, polls := 100}), + axioms: [] +} +definition{ + name: absent, + parameters: [], + result: LexLeanStd.Host::Event, + body: (ctor LexLeanStd.Host::Event.stat (ctor Result.error [LexLeanStd.Host::Entry, LexLeanStd.Host::Failure] (record LexLeanStd.Host::Failure {kind := (ctor LexLeanStd.Host::FailureKind.notFound), message := 0x6d697373696e67}))), + axioms: [] +} +definition{ + name: existing, + parameters: [], + result: LexLeanStd.Host::Event, + body: (ctor LexLeanStd.Host::Event.stat (ctor Result.ok [LexLeanStd.Host::Entry, LexLeanStd.Host::Failure] (record LexLeanStd.Host::Entry {kind := (ctor LexLeanStd.Host::EntryKind.directory), size := 0, identity := (ctor Option.none [(Nat * Nat)])}))), + axioms: [] +} +definition{ + name: host, + parameters: [state : ResearchWorkspace::State, event : LexLeanStd.Host::Event], + result: (ResearchWorkspace::State * ResearchWorkspace::Emission), + body: (ResearchWorkspace::step state (ctor ResearchWorkspace::Event.host event)), + axioms: [Quot.sound, propext] +} +definition{ + name: spawned, + parameters: [state : ResearchWorkspace::State], + result: ResearchWorkspace::State, + body: (first (host (first (host state (ResearchExecutionTraces::waitEvent 100 (nil (Nat * (Option Int32)))))) (ctor LexLeanStd.Host::Event.spawned (ctor Result.ok [(Nat * Nat), LexLeanStd.Host::Failure] (7, 100))))), + axioms: [Quot.sound, propext] +} +definition{ + name: finishJob, + parameters: [state : ResearchWorkspace::State, code : Int32], + result: (ResearchWorkspace::State * ResearchWorkspace::Emission), + body: (host (spawned state) (ResearchExecutionTraces::exitEvent 7 (ctor Option.some [Int32] code) 101)), + axioms: [Quot.sound, propext] +} +definition{ + name: creating, + parameters: [], + result: ResearchWorkspace::State, + body: (first (host (first (ResearchWorkspace::begin (config))) (absent))), + axioms: [Quot.sound, propext] +} +definition{ + name: reading, + parameters: [], + result: ResearchWorkspace::State, + body: (first (finishJob (first (finishJob (creating) (0 : Int32))) (0 : Int32))), + axioms: [Quot.sound, propext] +} +definition{ + name: readEvent, + parameters: [data : Bytes], + result: LexLeanStd.Host::Event, + body: (ctor LexLeanStd.Host::Event.read (ctor Result.ok [Bytes, LexLeanStd.Host::Failure] data)), + axioms: [] +} +definition{ + name: exactIdentity, + parameters: [], + result: LexLeanStd.Host::Event, + body: (readEvent (prim append (tree) 0x0a : Bytes)), + axioms: [] +} +definition{ + name: ready, + parameters: [], + result: ResearchWorkspace::State, + body: (first (finishJob (first (finishJob (first (finishJob (first (finishJob (first (finishJob (first (host (reading) (exactIdentity))) (0 : Int32))) (0 : Int32))) (0 : Int32))) (0 : Int32))) (0 : Int32))), + axioms: [Quot.sound, propext] +} +definition{ + name: isReady, + parameters: [state : ResearchWorkspace::State], + result: Bool, + body: ((project state owned) && (match (project state phase) | ResearchWorkspace::Phase.ready => true | ResearchWorkspace::Phase.checking => false | ResearchWorkspace::Phase.executing => false | ResearchWorkspace::Phase.reading => false | ResearchWorkspace::Phase.ended => false | ResearchWorkspace::Phase.blocked => false)), + axioms: [] +} +definition{ + name: isBlocked, + parameters: [result : (ResearchWorkspace::State * ResearchWorkspace::Emission)], + result: Bool, + body: (match (second result) | ResearchWorkspace::Emission.blocked reason => true | ResearchWorkspace::Emission.awaiting => false | ResearchWorkspace::Emission.host request => false | ResearchWorkspace::Emission.ready directory => false | ResearchWorkspace::Emission.complete kind => false | ResearchWorkspace::Emission.refused => false), + axioms: [] +} +definition{ + name: endedAs, + parameters: [result : (ResearchWorkspace::State * ResearchWorkspace::Emission), expected : ResearchExecution::EndKind], + result: Bool, + body: ((not (project (first result) owned)) && (match (second result) | ResearchWorkspace::Emission.complete kind => (match kind | ResearchExecution::EndKind.succeeded => (match expected | ResearchExecution::EndKind.succeeded => true | ResearchExecution::EndKind.failed => false | ResearchExecution::EndKind.cut => false | ResearchExecution::EndKind.unavailable => false | ResearchExecution::EndKind.protocol => false | ResearchExecution::EndKind.cleanupFailed => false | ResearchExecution::EndKind.refused => false) | ResearchExecution::EndKind.failed => (match expected | ResearchExecution::EndKind.succeeded => false | ResearchExecution::EndKind.failed => true | ResearchExecution::EndKind.cut => false | ResearchExecution::EndKind.unavailable => false | ResearchExecution::EndKind.protocol => false | ResearchExecution::EndKind.cleanupFailed => false | ResearchExecution::EndKind.refused => false) | ResearchExecution::EndKind.cut => (match expected | ResearchExecution::EndKind.succeeded => false | ResearchExecution::EndKind.failed => false | ResearchExecution::EndKind.cut => true | ResearchExecution::EndKind.unavailable => false | ResearchExecution::EndKind.protocol => false | ResearchExecution::EndKind.cleanupFailed => false | ResearchExecution::EndKind.refused => false) | ResearchExecution::EndKind.refused => (match expected | ResearchExecution::EndKind.succeeded => false | ResearchExecution::EndKind.failed => false | ResearchExecution::EndKind.cut => false | ResearchExecution::EndKind.unavailable => false | ResearchExecution::EndKind.protocol => false | ResearchExecution::EndKind.cleanupFailed => false | ResearchExecution::EndKind.refused => true) | ResearchExecution::EndKind.unavailable => false | ResearchExecution::EndKind.protocol => false | ResearchExecution::EndKind.cleanupFailed => false) | ResearchWorkspace::Emission.awaiting => false | ResearchWorkspace::Emission.host request => false | ResearchWorkspace::Emission.ready directory => false | ResearchWorkspace::Emission.blocked reason => false | ResearchWorkspace::Emission.refused => false)), + axioms: [] +} + +theorem{ + name: preparedWorkspaceRemainsOwned, + parameters: [], + statement: ((isReady (ready)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: existingPathIsRefused, + parameters: [], + statement: ((endedAs (host (first (ResearchWorkspace::begin (config))) (existing)) (ctor ResearchExecution::EndKind.refused)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: mismatchedLibraryIsRemoved, + parameters: [], + statement: ((endedAs (finishJob (first (host (reading) (readEvent 0x77726f6e670a))) (0 : Int32)) (ctor ResearchExecution::EndKind.failed)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: releaseClearsOwnershipAfterRemoval, + parameters: [], + statement: ((endedAs (finishJob (first (ResearchWorkspace::step (ready) (ctor ResearchWorkspace::Event.release))) (0 : Int32)) (ctor ResearchExecution::EndKind.succeeded)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: failedRemovalBlocks, + parameters: [], + statement: ((isBlocked (finishJob (first (ResearchWorkspace::step (ready) (ctor ResearchWorkspace::Event.release))) (1 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: failedRemovalRetainsWorkspace, + parameters: [], + statement: ((project (first (finishJob (first (ResearchWorkspace::step (ready) (ctor ResearchWorkspace::Event.release))) (1 : Int32))) owned) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: failedCreationIsNotAssumedAbsent, + parameters: [], + statement: ((isBlocked (finishJob (creating) (1 : Int32))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: cancelledStatDoesNotCreate, + parameters: [], + statement: ((endedAs (host (first (ResearchWorkspace::step (first (ResearchWorkspace::begin (config))) (ctor ResearchWorkspace::Event.cancel))) (absent)) (ctor ResearchExecution::EndKind.cut)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: cancelledIdentityDrainsThenRemoves, + parameters: [], + statement: ((endedAs (finishJob (first (host (first (ResearchWorkspace::step (reading) (ctor ResearchWorkspace::Event.cancel))) (exactIdentity))) (0 : Int32)) (ctor ResearchExecution::EndKind.cut)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: unrelatedIdentityReplyRetainsOwnership, + parameters: [], + statement: (((isBlocked (host (reading) (existing))) && (project (first (host (reading) (existing))) owned)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: failedRuntimeBuildIsRemoved, + parameters: [], + statement: ((endedAs (finishJob (first (finishJob (first (finishJob (first (host (reading) (exactIdentity))) (0 : Int32))) (1 : Int32))) (0 : Int32)) (ctor ResearchExecution::EndKind.failed)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: cancelledCreate, + parameters: [], + result: ResearchWorkspace::State, + body: (first (host (first (ResearchWorkspace::step (spawned (creating)) (ctor ResearchWorkspace::Event.cancel))) (ResearchExecutionTraces::waitEvent 101 (nil (Nat * (Option Int32)))))), + axioms: [Quot.sound, propext] +} + +definition{ + name: ownsChild, + parameters: [state : ResearchWorkspace::State], + result: Bool, + body: (match (project state execution) | Option.none => false | Option.some active => (match (project active owner) | Option.none => false | Option.some child => (child =? 7))), + axioms: [] +} + +theorem{ + name: cancelledCheckoutRetainsUncertainWorkspace, + parameters: [], + statement: ((isBlocked (host (cancelledCreate) (ResearchExecutionTraces::stopOk))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedChildCleanupRetainsChildOwnership, + parameters: [], + statement: ((let result : (ResearchWorkspace::State * ResearchWorkspace::Emission) := (host (cancelledCreate) (ctor LexLeanStd.Host::Event.finished (ctor Result.error [Unit, LexLeanStd.Host::Failure] (ResearchExecutionTraces::failedHost)))); ((isBlocked result) && (ownsChild (first result)))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cleanupCannotBeCancelledHalfway, + parameters: [], + statement: ((endedAs (finishJob (first (ResearchWorkspace::step (first (ResearchWorkspace::step (ready) (ctor ResearchWorkspace::Event.release))) (ctor ResearchWorkspace::Event.cancel))) (0 : Int32)) (ctor ResearchExecution::EndKind.succeeded)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: dirtyTrackedSourcesAreRemovedBeforeReadiness, + parameters: [], + statement: ((endedAs (finishJob (first (finishJob (first (host (reading) (exactIdentity))) (1 : Int32))) (0 : Int32)) (ctor ResearchExecution::EndKind.failed)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: blockedWorkspaceCannotResume, + parameters: [state : ResearchWorkspace::State, event : ResearchWorkspace::Event], + statement: ((ResearchWorkspace::step (ResearchWorkspace::withPhase state (ctor ResearchWorkspace::Phase.blocked)) event) = ((ResearchWorkspace::withPhase state (ctor ResearchWorkspace::Phase.blocked)), (ctor ResearchWorkspace::Emission.blocked (project state detail)))), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: runtimeBuilding, + parameters: [], + result: ResearchWorkspace::State, + body: (first (finishJob (first (host (reading) (exactIdentity))) (0 : Int32))), + axioms: [Quot.sound, propext] +} + +definition{ + name: stoppedRuntime, + parameters: [], + result: (ResearchWorkspace::State * ResearchWorkspace::Emission), + body: (host (first (host (first (ResearchWorkspace::step (spawned (runtimeBuilding)) (ctor ResearchWorkspace::Event.cancel))) (ResearchExecutionTraces::waitEvent 101 (nil (Nat * (Option Int32)))))) (ResearchExecutionTraces::stopOk)), + axioms: [Quot.sound, propext] +} + +theorem{ + name: stoppedLibraryToolRetainsWorkspace, + parameters: [], + statement: (((isBlocked (stoppedRuntime)) && (project (first (stoppedRuntime)) owned)) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: signalledLibraryToolRetainsWorkspace, + parameters: [], + statement: ((let result : (ResearchWorkspace::State * ResearchWorkspace::Emission) := (host (spawned (runtimeBuilding)) (ResearchExecutionTraces::exitEvent 7 (ctor Option.none [Int32]) 101)); ((isBlocked result) && (project (first result) owned))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/Standards.lex.tex b/rule30-api/src/Standards.lex.tex index 02e6654..aec3e17 100644 --- a/rule30-api/src/Standards.lex.tex +++ b/rule30-api/src/Standards.lex.tex @@ -26,7 +26,7 @@ name: standards, parameters: [], result: (List Standard), - body: (cons (record Standard {id := "iso-42010", name := "ISO/IEC/IEEE 42010:2022, Architecture description", authority := "https://www.iso.org/standard/74393.html", version := "2022", scope := "Stakeholders, concerns, viewpoints and views of the proof effort on Foundation.Arch; every panel of the site is governed by a viewpoint.", realizedBy := (cons "Architecture" (cons "architecture-module" (cons "Presentation" (nil String)))), conformance := "bin/r30 verify api: everyConcernFramed, viewpointsFrameHeldConcerns, everyViewpointGovernsAView (Architecture), panelsGovernedByViewpoints (Presentation)", coverage := "implemented"}) (cons (record Standard {id := "iso-25010", name := "ISO/IEC 25010:2023, Product quality model", authority := "https://www.iso.org/standard/78176.html", version := "2023", scope := "What an optimal implementation is here: characteristics, subcharacteristics, requirements and measures with thresholds on Foundation.Qual, each measure naming the command that reports it.", realizedBy := (cons "Architecture" (cons "quality" (cons "architecture-module" (cons "api_check" (cons "check" (cons "choice_audit" (cons "frontier_check" (cons "gate" (cons "verify" (cons "view_render" (nil String))))))))))), conformance := "bin/r30 verify api: everyRequirementMeasured, everyMeasureCommandExists (Architecture), publicationWithinBudget (Application)", coverage := "implemented"}) (cons (record Standard {id := "wcag-2.2", name := "W3C WCAG 2.2, Web Content Accessibility Guidelines", authority := "https://www.w3.org/TR/WCAG22/", version := "2.2 (Recommendation, 2023-10-05)", scope := "The site at level AA: 4.5:1 text contrast in both themes, one visible focus ring, a skip link, reduced motion honoured, keyboard operation of every control and step.", realizedBy := (cons "site" (cons "picture" (cons "explainer" (cons "reduction-tree" (cons "register" (cons "open-leaves" (cons "paper" (cons "obligation" (cons "refutations" (cons "interface-sheets" (cons "modules" (cons "quality" (cons "sitemap" (cons "verify" (cons "standards" (cons "model" (cons "design" (cons "viz-triangle" (cons "viz-tower" (cons "viz-ledger" (cons "viz-rays" (cons "viz-defects" (cons "viz-dyadic" (cons "nav-primary" (cons "nav-breadcrumb" (cons "nav-stepper" (nil String))))))))))))))))))))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.AccessibilityTests (contrast measured from the stylesheet, landmarks, focus, motion, keyboard)", coverage := "implemented"}) (cons (record Standard {id := "wai-aria-1.2", name := "W3C WAI-ARIA 1.2 and the ARIA Authoring Practices Guide", authority := "https://www.w3.org/TR/wai-aria-1.2/", version := "1.2 (Recommendation, 2023-06-06); APG patterns", scope := "The navigation of the site: the primary navigation, the breadcrumb and the stepper follow the APG patterns (roles, aria-current, arrow keys), the status region is live.", realizedBy := (cons "site" (cons "nav-primary" (cons "nav-breadcrumb" (cons "nav-stepper" (nil String))))), conformance := "python3 -m unittest scripts.tests.test_r30.AccessibilityTests (role, aria-current, aria-pressed, role=status, arrow keys)", coverage := "implemented"}) (cons (record Standard {id := "html-living-standard", name := "WHATWG HTML Living Standard", authority := "https://html.spec.whatwg.org/multipage/", version := "living standard", scope := "The page's landmarks (header, nav, main, footer), the one-document site with its data in a JSON script element and its metadata in the head.", realizedBy := (cons "site" (cons "nav-primary" (cons "nav-breadcrumb" (cons "nav-stepper" (nil String))))), conformance := "python3 -m unittest scripts.tests.test_r30.AccessibilityTests.test_landmarks_focus_motion_and_keyboard", coverage := "implemented"}) (cons (record Standard {id := "svg-2", name := "W3C SVG 2", authority := "https://www.w3.org/TR/SVG2/", version := "2 (Candidate Recommendation, 2018-10-04)", scope := "The Rule 30 picture, the logo and the visualizations are SVG documents with a title and a description, crisp cells, colours from the page's tokens.", realizedBy := (cons "picture" (cons "logo" (cons "viz-triangle" (cons "viz-tower" (cons "viz-ledger" (cons "viz-rays" (cons "viz-defects" (cons "viz-dyadic" (nil String))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.SiteTests.test_rule30_rows_and_logo (parsed as SVG, no script)", coverage := "implemented"}) (cons (record Standard {id := "wai-aria-graphics-1.0", name := "W3C WAI-ARIA Graphics Module 1.0", authority := "https://www.w3.org/TR/graphics-aria-1.0/", version := "1.0 (Recommendation, 2018-10-02)", scope := "Every drawing carries role=img with aria-labelledby pointing at its title and description; the interactive visualizations use graphics-document and graphics-symbol.", realizedBy := (cons "picture" (cons "logo" (cons "viz-triangle" (cons "viz-tower" (cons "viz-ledger" (cons "viz-rays" (cons "viz-defects" (cons "viz-dyadic" (nil String))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.SiteTests.test_statements_picture_and_explainer_artifacts (role=img, aria-labelledby)", coverage := "implemented"}) (cons (record Standard {id := "schema-org", name := "schema.org vocabulary (JSON-LD)", authority := "https://schema.org/", version := "current release (https://schema.org/docs/releases.html)", scope := "A LearningResource for every pedagogical step of every journey, the paper as ScholarlyArticle, the repository as SoftwareSourceCode, the register as Dataset, embedded in the page and published as schema.json.", realizedBy := (cons "jsonld" (cons "site" (cons "paper-pdf" (cons "register-json" (cons "readme" (cons "prize-review" (cons "research-session" (cons "reading" (cons "stdlib-feedback" (cons "mathematics" (cons "first-visit" (nil String)))))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_schema_org_describes_every_step_the_paper_the_repository_and_the_register", coverage := "implemented"}) (cons (record Standard {id := "json-ld-1.1", name := "W3C JSON-LD 1.1", authority := "https://www.w3.org/TR/json-ld11/", version := "1.1 (Recommendation, 2020-07-16)", scope := "The serialization of the schema.org and PROV-O graphs: a @context, a @graph, ids under the published URL.", realizedBy := (cons "jsonld" (cons "provenance" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests (both documents parse and carry @context and @graph)", coverage := "implemented"}) (cons (record Standard {id := "prov-o", name := "W3C PROV-O, the PROV Ontology", authority := "https://www.w3.org/TR/prov-o/", version := "Recommendation, 2013-04-30", scope := "Provenance of every claim: a proved claim prov:wasDerivedFrom its Lean theorem and prov:wasAttributedTo the Lean kernel, attested by the paper's LexLean attestation and the module's kappa-label; the view prov:wasGeneratedBy the render of this commit under the view workflow.", realizedBy := (cons "provenance" (cons "view-workflow" (cons "view_render" (cons "frontier_check" (cons "kappa" (cons "verify" (nil String))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_provenance_derives_every_proved_claim_from_its_theorem", coverage := "implemented"}) (cons (record Standard {id := "json-schema-2020-12", name := "JSON Schema 2020-12", authority := "https://json-schema.org/draft/2020-12/schema", version := "2020-12", scope := "The closed schemas of register.json, the interface sheets, standards.json and the --json reports (rule30-api/schemas), validated by the tests and referenced from openapi.json.", realizedBy := (cons "register-json" (cons "standards" (cons "openapi" (cons "api_check" (cons "api_production" (cons "brief" (cons "chain" (cons "claim" (cons "deduce" (cons "discover" (cons "engine_prune" (cons "engine_status" (cons "engine_tick" (cons "frontier_list" (cons "interface" (cons "kappa" (cons "sequences" (cons "status" (nil String))))))))))))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.ResultSchemaTests; bin/r30 api check", coverage := "implemented"}) (cons (record Standard {id := "openapi-3.1", name := "OpenAPI Specification 3.1", authority := "https://spec.openapis.org/oas/v3.1.1", version := "3.1.1 (2024-10-24)", scope := "The r30 command surface as an API description: one path per command of the parser, its arguments as parameters, its responses from the result schemas, the same leaves as Api.lex.tex and the MCP tools.", realizedBy := (prim append (cons "openapi" (cons "status" (cons "brief" (cons "chain" (cons "api_sync" (cons "api_check" (cons "api_production" (cons "view_render" (cons "interface" (cons "claim" (cons "audit" (cons "gate" (cons "lexicon_search" (cons "lexicon_show" (cons "lexicon_packages" (cons "sig" (cons "mentions" (cons "theorem_preview" (cons "theorem_add" (cons "theorem_remove" (cons "define" (cons "check" (cons "unpublished" (cons "selfcheck" (cons "verify" (cons "probe" (cons "axioms" (cons "choice_audit" (cons "frontier_list" (cons "frontier_add" (cons "frontier_set" (cons "frontier_check" (cons "frontier_render" (cons "commit" (cons "module_list" (cons "module_add" (cons "module_build" (cons "consolidate" (cons "kappa" (cons "sequences" (nil String))))))))))))))))))))))))))))))))))))))))) (cons "discover" (cons "deduce" (cons "engine_tick" (cons "engine_status" (cons "engine_hypotheses" (cons "engine_prune" (cons "experiment_list" (cons "experiment_run" (nil String))))))))) : (List String)), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_openapi_describes_the_command_surface; bin/r30 api check (Api.lex.tex)", coverage := "implemented"}) (cons (record Standard {id := "gherkin", name := "Gherkin (Cucumber reference)", authority := "https://cucumber.io/docs/gherkin/reference/", version := "Gherkin reference (current)", scope := "One scenario per conformance id in features/suites, tagged with the id and its honesty level, generated with the registers.", realizedBy := (cons "api_sync" (cons "api_check" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.ConformanceTests; bin/r30 api check", coverage := "implemented"}) (cons (record Standard {id := "citation-cff", name := "Citation File Format 1.2.0", authority := "https://citation-file-format.github.io/", version := "1.2.0", scope := "CITATION.cff at the repository root (and copied into the view): the author, the title of the paper, the repository and the published view.", realizedBy := (cons "citation" (cons "readme" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_citation_file_names_the_author_the_title_and_the_repository", coverage := "implemented"}) (cons (record Standard {id := "spdx", name := "SPDX License Expressions (SPDX 2.3, ISO/IEC 5962:2021)", authority := "https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/", version := "2.3", scope := "License identifiers of the vendored sources: the repository is MIT (LICENSE at the root, `license: MIT` in CITATION.cff); the prism-stdlib register carries the SPDX expression of its vendored license files.", realizedBy := (cons "stdlib-package" (cons "citation" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_spdx_expressions_are_well_formed", coverage := "implemented"}) (cons (record Standard {id := "sitemap-protocol", name := "Sitemaps XML protocol 0.9", authority := "https://www.sitemaps.org/protocol.html", version := "0.9", scope := "sitemap.xml: the page and the deep link of every step of every journey; robots.txt names the sitemap.", realizedBy := (cons "sitemap" (cons "robots" (cons "site" (cons "prize-review" (cons "research-session" (cons "reading" (cons "stdlib-feedback" (cons "mathematics" (cons "first-visit" (nil String)))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_sitemap_lists_every_step_deep_link", coverage := "implemented"}) (cons (record Standard {id := "open-graph", name := "The Open Graph protocol", authority := "https://ogp.me/", version := "ogp.me (2014-10)", scope := "og:title, og:type, og:url, og:description and og:image in the page's head, injected with the JSON-LD at render.", realizedBy := (cons "site" (cons "logo" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_site_head_carries_json_ld_and_open_graph", coverage := "implemented"}) (cons (record Standard {id := "rfc-8785", name := "RFC 8785, JSON Canonicalization Scheme (JCS)", authority := "https://www.rfc-editor.org/rfc/rfc8785", version := "2020-06", scope := "The identity of the published JSON contracts (sha256-canonical-json in contracts.toml) and the canonical JSON of the LexLean attestations; uor-addr labels JSON under JCS.", realizedBy := (cons "register-json" (cons "statements" (cons "kappa" (nil String)))), conformance := "python3 -m unittest scripts.tests.test_kappa (the no-prefix rule on the JCS vector)", coverage := "implemented"}) (cons (record Standard {id := "rivest-csexp", name := "Rivest, S-Expressions (canonical form, section 4.3)", authority := "https://people.csail.mit.edu/rivest/Sexp.txt", version := "draft-rivest-sexp-00, 1997-05-04", scope := "The kappa-label of a research module: the SHA-256 of the canonical S-expression of the declarations the kernel replays, as UOR-Foundation/uor-addr mints labels; the key of the replay receipts. The same canonical form labels the sequences of the basis, (sequence ), their transforms and the relations the discovery engines find, (relation ).", realizedBy := (cons "kappa" (cons "provenance" (cons "sequences" (cons "discover" (cons "Sequences" (cons "Discovery" (nil String))))))), conformance := "python3 -m unittest scripts.tests.test_kappa; bin/r30 kappa ; bin/r30 api check (sequences)", coverage := "implemented"}) (cons (record Standard {id := "in-toto-statement-v1", name := "in-toto Attestation Framework, Statement v1", authority := "https://github.com/in-toto/attestation/blob/main/spec/v1/statement.md", version := "v1", scope := "attestations.intoto.json: a Statement whose subjects are the attested PDFs and the paper's sources with their SHA-256 digests and whose predicate is the paper's LexLean attestation.", realizedBy := (cons "attestations" (cons "pdf-manifest" (cons "verify" (cons "paper-pdf" (cons "observations-pdf" (cons "core-pdf" (nil String))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_in_toto_statement_subjects_are_the_attested_documents", coverage := "implemented"}) (cons (record Standard {id := "oci-distribution", name := "OCI Distribution Specification", authority := "https://github.com/opencontainers/distribution-spec/blob/main/spec.md", version := "1.1.0 (2024-02)", scope := "Planned: a kappa-registry serving the replay receipts and certified bundles by content address; today only the kappa-labels that would address them exist.", realizedBy := (cons "kappa" (nil String)), conformance := "bin/r30 kappa (the labels); no registry runs yet", coverage := "planned"}) (cons (record Standard {id := "iana-media-types", name := "IANA Media Types (RFC 6838)", authority := "https://www.iana.org/assignments/media-types/", version := "RFC 6838 (2013-01)", scope := "Every published artifact declares its media type in Presentation.lex.tex; the contracts register declares the vendor types of the JSON reports.", realizedBy := (prim append (cons "chain" (cons "register-json" (cons "register-text" (cons "frontier" (cons "interfaces" (cons "statements" (cons "explainer" (cons "picture" (cons "paper-pdf" (cons "observations-pdf" (cons "core-pdf" (cons "pdf-manifest" (cons "api-module" (cons "register-module" (cons "architecture-module" (cons "presentation-module" (cons "application-module" (cons "core-vectors" (cons "frontier-module" (cons "agents" (cons "round-workflow" (cons "strategy" (cons "readme" (cons "logo" (cons "standards" (cons "standards-module" (cons "openapi" (cons "sitemap" (cons "robots" (cons "provenance" (cons "jsonld" (cons "attestations" (cons "citation" (cons "observer-module" (cons "tokens" (cons "site" (cons "viz-core-js" (cons "viz-triangle-js" (cons "viz-tower-js" (cons "viz-ledger-js" (nil String))))))))))))))))))))))))))))))))))))))))) (cons "viz-rays-js" (cons "viz-defects-js" (cons "viz-dyadic-js" (nil String)))) : (List String)), conformance := "bin/r30 verify api: artifactPathsDistinct, panelsReadArtifacts (Presentation); python3 -m unittest scripts.tests.test_r30.StandardsTests", coverage := "implemented"}) (cons (record Standard {id := "lean-4", name := "Lean 4 (the kernel)", authority := "https://github.com/leanprover/lean4", version := "leanprover/lean4:v4.32.1", scope := "Every proved claim names a theorem the Lean kernel checked under propext and Quot.sound; the research modules are kernel-replayed with leanchecker.", realizedBy := (cons "Register" (cons "axioms" (cons "choice_audit" (cons "frontier_check" (cons "kappa" (cons "module_build" (nil String))))))), conformance := "bin/r30 frontier check; bin/r30 axioms ; bin/r30 choice-audit", coverage := "implemented"}) (cons (record Standard {id := "lexlean", name := "UOR-Foundation/LexLean (closed-lexicon LaTeX to Lean 4)", authority := "https://github.com/UOR-Foundation/LexLean", version := "0.4.0, language 1.2, compiler semantics b9816b388a3e", scope := "The authoring surface: the paper, the register and these API modules are LexLean modules verified by lexlean; the production roots export to certified Rust.", realizedBy := (cons "Api" (cons "Register" (cons "Architecture" (cons "Presentation" (cons "Application" (cons "Observer" (cons "Convert" (cons "Standards" (cons "Rule30Core" (cons "Sequences" (cons "Discovery" (cons "verify" (cons "check" (cons "api_sync" (cons "api_check" (cons "api_production" (nil String))))))))))))))))), conformance := "bin/r30 verify api; bin/r30 check api; bin/r30 api check", coverage := "implemented"}) (nil Standard))))))))))))))))))))))))), + body: (cons (record Standard {id := "iso-42010", name := "ISO/IEC/IEEE 42010:2022, Architecture description", authority := "https://www.iso.org/standard/74393.html", version := "2022", scope := "Stakeholders, concerns, viewpoints and views of the proof effort on Foundation.Arch; every panel of the site is governed by a viewpoint.", realizedBy := (cons "Architecture" (cons "architecture-module" (cons "Presentation" (nil String)))), conformance := "bin/r30 verify api: everyConcernFramed, viewpointsFrameHeldConcerns, everyViewpointGovernsAView (Architecture), panelsGovernedByViewpoints (Presentation)", coverage := "implemented"}) (cons (record Standard {id := "iso-25010", name := "ISO/IEC 25010:2023, Product quality model", authority := "https://www.iso.org/standard/78176.html", version := "2023", scope := "What an optimal implementation is here: characteristics, subcharacteristics, requirements and measures with thresholds on Foundation.Qual, each measure naming the command that reports it.", realizedBy := (cons "Architecture" (cons "quality" (cons "architecture-module" (cons "api_check" (cons "check" (cons "choice_audit" (cons "frontier_check" (cons "gate" (cons "verify" (cons "view_render" (nil String))))))))))), conformance := "bin/r30 verify api: everyRequirementMeasured, everyMeasureCommandExists (Architecture), publicationWithinBudget (Application)", coverage := "implemented"}) (cons (record Standard {id := "wcag-2.2", name := "W3C WCAG 2.2, Web Content Accessibility Guidelines", authority := "https://www.w3.org/TR/WCAG22/", version := "2.2 (Recommendation, 2023-10-05)", scope := "The site at level AA: 4.5:1 text contrast in both themes, one visible focus ring, a skip link, reduced motion honoured, keyboard operation of every control and step.", realizedBy := (cons "site" (cons "picture" (cons "explainer" (cons "reduction-tree" (cons "register" (cons "open-leaves" (cons "paper" (cons "obligation" (cons "refutations" (cons "interface-sheets" (cons "modules" (cons "quality" (cons "sitemap" (cons "verify" (cons "standards" (cons "model" (cons "design" (cons "viz-triangle" (cons "viz-tower" (cons "viz-ledger" (cons "viz-rays" (cons "viz-defects" (cons "viz-dyadic" (cons "nav-primary" (cons "nav-breadcrumb" (cons "nav-stepper" (nil String))))))))))))))))))))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.AccessibilityTests (contrast measured from the stylesheet, landmarks, focus, motion, keyboard)", coverage := "implemented"}) (cons (record Standard {id := "wai-aria-1.2", name := "W3C WAI-ARIA 1.2 and the ARIA Authoring Practices Guide", authority := "https://www.w3.org/TR/wai-aria-1.2/", version := "1.2 (Recommendation, 2023-06-06); APG patterns", scope := "The navigation of the site: the primary navigation, the breadcrumb and the stepper follow the APG patterns (roles, aria-current, arrow keys), the status region is live.", realizedBy := (cons "site" (cons "nav-primary" (cons "nav-breadcrumb" (cons "nav-stepper" (nil String))))), conformance := "python3 -m unittest scripts.tests.test_r30.AccessibilityTests (role, aria-current, aria-pressed, role=status, arrow keys)", coverage := "implemented"}) (cons (record Standard {id := "html-living-standard", name := "WHATWG HTML Living Standard", authority := "https://html.spec.whatwg.org/multipage/", version := "living standard", scope := "The page's landmarks (header, nav, main, footer), the one-document site with its data in a JSON script element and its metadata in the head.", realizedBy := (cons "site" (cons "nav-primary" (cons "nav-breadcrumb" (cons "nav-stepper" (nil String))))), conformance := "python3 -m unittest scripts.tests.test_r30.AccessibilityTests.test_landmarks_focus_motion_and_keyboard", coverage := "implemented"}) (cons (record Standard {id := "svg-2", name := "W3C SVG 2", authority := "https://www.w3.org/TR/SVG2/", version := "2 (Candidate Recommendation, 2018-10-04)", scope := "The Rule 30 picture, the logo and the visualizations are SVG documents with a title and a description, crisp cells, colours from the page's tokens.", realizedBy := (cons "picture" (cons "logo" (cons "viz-triangle" (cons "viz-tower" (cons "viz-ledger" (cons "viz-rays" (cons "viz-defects" (cons "viz-dyadic" (nil String))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.SiteTests.test_rule30_rows_and_logo (parsed as SVG, no script)", coverage := "implemented"}) (cons (record Standard {id := "wai-aria-graphics-1.0", name := "W3C WAI-ARIA Graphics Module 1.0", authority := "https://www.w3.org/TR/graphics-aria-1.0/", version := "1.0 (Recommendation, 2018-10-02)", scope := "Every drawing carries role=img with aria-labelledby pointing at its title and description; the interactive visualizations use graphics-document and graphics-symbol.", realizedBy := (cons "picture" (cons "logo" (cons "viz-triangle" (cons "viz-tower" (cons "viz-ledger" (cons "viz-rays" (cons "viz-defects" (cons "viz-dyadic" (nil String))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.SiteTests.test_statements_picture_and_explainer_artifacts (role=img, aria-labelledby)", coverage := "implemented"}) (cons (record Standard {id := "schema-org", name := "schema.org vocabulary (JSON-LD)", authority := "https://schema.org/", version := "current release (https://schema.org/docs/releases.html)", scope := "A LearningResource for every pedagogical step of every journey, the paper as ScholarlyArticle, the repository as SoftwareSourceCode, the register as Dataset, embedded in the page and published as schema.json.", realizedBy := (cons "jsonld" (cons "site" (cons "paper-pdf" (cons "register-json" (cons "readme" (cons "prize-review" (cons "research-session" (cons "reading" (cons "stdlib-feedback" (cons "mathematics" (cons "first-visit" (nil String)))))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_schema_org_describes_every_step_the_paper_the_repository_and_the_register", coverage := "implemented"}) (cons (record Standard {id := "json-ld-1.1", name := "W3C JSON-LD 1.1", authority := "https://www.w3.org/TR/json-ld11/", version := "1.1 (Recommendation, 2020-07-16)", scope := "The serialization of the schema.org and PROV-O graphs: a @context, a @graph, ids under the published URL.", realizedBy := (cons "jsonld" (cons "provenance" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests (both documents parse and carry @context and @graph)", coverage := "implemented"}) (cons (record Standard {id := "prov-o", name := "W3C PROV-O, the PROV Ontology", authority := "https://www.w3.org/TR/prov-o/", version := "Recommendation, 2013-04-30", scope := "Provenance of every claim: a proved claim prov:wasDerivedFrom its Lean theorem and prov:wasAttributedTo the Lean kernel, attested by the paper's LexLean attestation and the module's kappa-label; the view prov:wasGeneratedBy the render of this commit under the view workflow.", realizedBy := (cons "provenance" (cons "view-workflow" (cons "view_render" (cons "frontier_check" (cons "kappa" (cons "verify" (nil String))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_provenance_derives_every_proved_claim_from_its_theorem", coverage := "implemented"}) (cons (record Standard {id := "json-schema-2020-12", name := "JSON Schema 2020-12", authority := "https://json-schema.org/draft/2020-12/schema", version := "2020-12", scope := "The closed schemas of register.json, the interface sheets, standards.json and the --json reports (rule30-api/schemas), validated by the tests and referenced from openapi.json.", realizedBy := (cons "register-json" (cons "standards" (cons "openapi" (cons "api_check" (cons "api_production" (cons "brief" (cons "chain" (cons "claim" (cons "deduce" (cons "discover" (cons "engine_prune" (cons "engine_status" (cons "engine_tick" (cons "frontier_list" (cons "interface" (cons "kappa" (cons "sequences" (cons "status" (nil String))))))))))))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.ResultSchemaTests; bin/r30 api check", coverage := "implemented"}) (cons (record Standard {id := "openapi-3.1", name := "OpenAPI Specification 3.1", authority := "https://spec.openapis.org/oas/v3.1.1", version := "3.1.1 (2024-10-24)", scope := "The r30 command surface as an API description: one path per command of the parser, its arguments as parameters, its responses from the result schemas, the same leaves as Api.lex.tex and the MCP tools.", realizedBy := (prim append (cons "openapi" (cons "status" (cons "brief" (cons "chain" (cons "api_sync" (cons "api_check" (cons "api_production" (cons "view_render" (cons "interface" (cons "claim" (cons "audit" (cons "gate" (cons "lexicon_search" (cons "lexicon_show" (cons "lexicon_packages" (cons "sig" (cons "mentions" (cons "theorem_preview" (cons "theorem_add" (cons "theorem_remove" (cons "define" (cons "check" (cons "unpublished" (cons "selfcheck" (cons "verify" (cons "probe" (cons "axioms" (cons "choice_audit" (cons "frontier_list" (cons "frontier_add" (cons "frontier_set" (cons "frontier_check" (cons "frontier_render" (cons "commit" (cons "module_list" (cons "module_add" (cons "module_build" (cons "consolidate" (cons "kappa" (cons "sequences" (nil String))))))))))))))))))))))))))))))))))))))))) (cons "discover" (cons "deduce" (cons "engine_tick" (cons "engine_status" (cons "engine_hypotheses" (cons "engine_prune" (cons "experiment_list" (cons "experiment_run" (nil String))))))))) : (List String)), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_openapi_describes_the_command_surface; bin/r30 api check (Api.lex.tex)", coverage := "implemented"}) (cons (record Standard {id := "gherkin", name := "Gherkin (Cucumber reference)", authority := "https://cucumber.io/docs/gherkin/reference/", version := "Gherkin reference (current)", scope := "One scenario per conformance id in features/suites, tagged with the id and its honesty level, generated with the registers.", realizedBy := (cons "api_sync" (cons "api_check" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.ConformanceTests; bin/r30 api check", coverage := "implemented"}) (cons (record Standard {id := "citation-cff", name := "Citation File Format 1.2.0", authority := "https://citation-file-format.github.io/", version := "1.2.0", scope := "CITATION.cff at the repository root (and copied into the view): the author, the title of the paper, the repository and the published view.", realizedBy := (cons "citation" (cons "readme" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_citation_file_names_the_author_the_title_and_the_repository", coverage := "implemented"}) (cons (record Standard {id := "spdx", name := "SPDX License Expressions (SPDX 2.3, ISO/IEC 5962:2021)", authority := "https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/", version := "2.3", scope := "License identifiers of the vendored sources: the repository is MIT (LICENSE at the root, `license: MIT` in CITATION.cff); the prism-stdlib register carries the SPDX expression of its vendored license files.", realizedBy := (cons "stdlib-package" (cons "citation" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_spdx_expressions_are_well_formed", coverage := "implemented"}) (cons (record Standard {id := "sitemap-protocol", name := "Sitemaps XML protocol 0.9", authority := "https://www.sitemaps.org/protocol.html", version := "0.9", scope := "sitemap.xml: the page and the deep link of every step of every journey; robots.txt names the sitemap.", realizedBy := (cons "sitemap" (cons "robots" (cons "site" (cons "prize-review" (cons "research-session" (cons "reading" (cons "stdlib-feedback" (cons "mathematics" (cons "first-visit" (nil String)))))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_sitemap_lists_every_step_deep_link", coverage := "implemented"}) (cons (record Standard {id := "open-graph", name := "The Open Graph protocol", authority := "https://ogp.me/", version := "ogp.me (2014-10)", scope := "og:title, og:type, og:url, og:description and og:image in the page's head, injected with the JSON-LD at render.", realizedBy := (cons "site" (cons "logo" (nil String))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_site_head_carries_json_ld_and_open_graph", coverage := "implemented"}) (cons (record Standard {id := "rfc-8785", name := "RFC 8785, JSON Canonicalization Scheme (JCS)", authority := "https://www.rfc-editor.org/rfc/rfc8785", version := "2020-06", scope := "The identity of the published JSON contracts (sha256-canonical-json in contracts.toml) and the canonical JSON of the LexLean attestations; uor-addr labels JSON under JCS.", realizedBy := (cons "register-json" (cons "statements" (cons "kappa" (nil String)))), conformance := "python3 -m unittest scripts.tests.test_kappa (the no-prefix rule on the JCS vector)", coverage := "implemented"}) (cons (record Standard {id := "rivest-csexp", name := "Rivest, S-Expressions (canonical form, section 4.3)", authority := "https://people.csail.mit.edu/rivest/Sexp.txt", version := "draft-rivest-sexp-00, 1997-05-04", scope := "The kappa-label of a research module: the SHA-256 of the canonical S-expression of the declarations the kernel replays, as UOR-Foundation/uor-addr mints labels; the key of the replay receipts. The same canonical form labels the sequences of the basis, (sequence ), their transforms and the relations the discovery engines find, (relation ).", realizedBy := (cons "kappa" (cons "provenance" (cons "sequences" (cons "discover" (cons "Sequences" (cons "Discovery" (nil String))))))), conformance := "python3 -m unittest scripts.tests.test_kappa; bin/r30 kappa ; bin/r30 api check (sequences)", coverage := "implemented"}) (cons (record Standard {id := "in-toto-statement-v1", name := "in-toto Attestation Framework, Statement v1", authority := "https://github.com/in-toto/attestation/blob/main/spec/v1/statement.md", version := "v1", scope := "attestations.intoto.json: a Statement whose subjects are the attested PDFs and the paper's sources with their SHA-256 digests and whose predicate is the paper's LexLean attestation.", realizedBy := (cons "attestations" (cons "pdf-manifest" (cons "verify" (cons "paper-pdf" (cons "observations-pdf" (cons "core-pdf" (nil String))))))), conformance := "python3 -m unittest scripts.tests.test_r30.StandardsTests.test_in_toto_statement_subjects_are_the_attested_documents", coverage := "implemented"}) (cons (record Standard {id := "oci-distribution", name := "OCI Distribution Specification", authority := "https://github.com/opencontainers/distribution-spec/blob/main/spec.md", version := "1.1.0 (2024-02)", scope := "Planned: a kappa-registry serving the replay receipts and certified bundles by content address; today only the kappa-labels that would address them exist.", realizedBy := (cons "kappa" (nil String)), conformance := "bin/r30 kappa (the labels); no registry runs yet", coverage := "planned"}) (cons (record Standard {id := "iana-media-types", name := "IANA Media Types (RFC 6838)", authority := "https://www.iana.org/assignments/media-types/", version := "RFC 6838 (2013-01)", scope := "Every published artifact declares its media type in Presentation.lex.tex; the contracts register declares the vendor types of the JSON reports.", realizedBy := (prim append (cons "chain" (cons "register-json" (cons "register-text" (cons "frontier" (cons "interfaces" (cons "statements" (cons "explainer" (cons "picture" (cons "paper-pdf" (cons "observations-pdf" (cons "core-pdf" (cons "pdf-manifest" (cons "api-module" (cons "register-module" (cons "architecture-module" (cons "presentation-module" (cons "application-module" (cons "core-vectors" (cons "frontier-module" (cons "agents" (cons "round-workflow" (cons "strategy" (cons "readme" (cons "logo" (cons "standards" (cons "standards-module" (cons "openapi" (cons "sitemap" (cons "robots" (cons "provenance" (cons "jsonld" (cons "attestations" (cons "citation" (cons "observer-module" (cons "tokens" (cons "site" (cons "viz-core-js" (cons "viz-triangle-js" (cons "viz-tower-js" (cons "viz-ledger-js" (nil String))))))))))))))))))))))))))))))))))))))))) (cons "viz-rays-js" (cons "viz-defects-js" (cons "viz-dyadic-js" (nil String)))) : (List String)), conformance := "bin/r30 verify api: artifactPathsDistinct, panelsReadArtifacts (Presentation); python3 -m unittest scripts.tests.test_r30.StandardsTests", coverage := "implemented"}) (cons (record Standard {id := "lean-4", name := "Lean 4 (the kernel)", authority := "https://github.com/leanprover/lean4", version := "leanprover/lean4:v4.32.1", scope := "Every proved claim names a theorem the Lean kernel checked under propext and Quot.sound; the research modules are kernel-replayed with leanchecker.", realizedBy := (cons "Register" (cons "axioms" (cons "choice_audit" (cons "frontier_check" (cons "kappa" (cons "module_build" (nil String))))))), conformance := "bin/r30 frontier check; bin/r30 axioms ; bin/r30 choice-audit", coverage := "implemented"}) (cons (record Standard {id := "lexlean", name := "UOR-Foundation/LexLean (closed-lexicon LaTeX to Lean 4)", authority := "https://github.com/UOR-Foundation/LexLean", version := "0.4.0, language 1.2, compiler semantics 601e9f4a1824", scope := "The authoring surface: the paper, the register and these API modules are LexLean modules verified by lexlean; the production roots export to certified Rust.", realizedBy := (cons "Api" (cons "Register" (cons "Architecture" (cons "Presentation" (cons "Application" (cons "Observer" (cons "Convert" (cons "Standards" (cons "Rule30Core" (cons "Sequences" (cons "Discovery" (cons "verify" (cons "check" (cons "api_sync" (cons "api_check" (cons "api_production" (nil String))))))))))))))))), conformance := "bin/r30 verify api; bin/r30 check api; bin/r30 api check", coverage := "implemented"}) (nil Standard))))))))))))))))))))))))), axioms: [] } @@ -281,7 +281,7 @@ theorem{ name: lexleanPinned, parameters: [], - statement: ((prim equal (standardVersion "lexlean" (standards)) "0.4.0, language 1.2, compiler semantics b9816b388a3e" : Bool) = true), + statement: ((prim equal (standardVersion "lexlean" (standards)) "0.4.0, language 1.2, compiler semantics 601e9f4a1824" : Bool) = true), proof: decide{}, axioms: [] } diff --git a/rule30-lexlean/Core.pdf b/rule30-lexlean/Core.pdf index 05556d5..11a6f96 100644 Binary files a/rule30-lexlean/Core.pdf and b/rule30-lexlean/Core.pdf differ diff --git a/rule30-lexlean/lexlean.lock b/rule30-lexlean/lexlean.lock index 366e112..3fdf5c9 100644 --- a/rule30-lexlean/lexlean.lock +++ b/rule30-lexlean/lexlean.lock @@ -1,6 +1,6 @@ spec = "lexlean/lock/2" language = "1.2" -compiler_semantics = "b9816b388a3eb1800179f96aa9bc789620a46d7a7132f1b52ee9fa404c2092f7" +compiler_semantics = "601e9f4a1824bb6aacf7c3c2243d4b33aaa315abdebd5ceaf920d178e196019e" project_config_sha256 = "19b484b35998550fc91a00820ee56382eaf79bbb39852dfb7d54e82018f0cd7b" lean_toolchain = "leanprover/lean4:v4.32.1" diff --git a/rule30-lexlean/pdf/Core.pdf b/rule30-lexlean/pdf/Core.pdf index 05556d5..11a6f96 100644 Binary files a/rule30-lexlean/pdf/Core.pdf and b/rule30-lexlean/pdf/Core.pdf differ diff --git a/rule30-paper/Observations.pdf b/rule30-paper/Observations.pdf index 2d97ad6..cf04926 100644 Binary files a/rule30-paper/Observations.pdf and b/rule30-paper/Observations.pdf differ diff --git a/rule30-paper/Paper.pdf b/rule30-paper/Paper.pdf index 809763d..570bb31 100644 Binary files a/rule30-paper/Paper.pdf and b/rule30-paper/Paper.pdf differ diff --git a/rule30-paper/lexlean.lock b/rule30-paper/lexlean.lock index 9c2bade..2cc0508 100644 --- a/rule30-paper/lexlean.lock +++ b/rule30-paper/lexlean.lock @@ -1,6 +1,6 @@ spec = "lexlean/lock/2" language = "1.2" -compiler_semantics = "b9816b388a3eb1800179f96aa9bc789620a46d7a7132f1b52ee9fa404c2092f7" +compiler_semantics = "601e9f4a1824bb6aacf7c3c2243d4b33aaa315abdebd5ceaf920d178e196019e" project_config_sha256 = "65f34bd573a071519ef77a8129d6aaba99072b7612e53043eac3033c4f4dfcbc" lean_toolchain = "leanprover/lean4:v4.32.1" diff --git a/rule30-paper/pdf/Observations.pdf b/rule30-paper/pdf/Observations.pdf index 2d97ad6..cf04926 100644 Binary files a/rule30-paper/pdf/Observations.pdf and b/rule30-paper/pdf/Observations.pdf differ diff --git a/rule30-paper/pdf/Paper.pdf b/rule30-paper/pdf/Paper.pdf index 809763d..570bb31 100644 Binary files a/rule30-paper/pdf/Paper.pdf and b/rule30-paper/pdf/Paper.pdf differ