diff --git a/.github/bdd-parts.json b/.github/bdd-parts.json index 4ce6f4315e..55aadea418 100644 --- a/.github/bdd-parts.json +++ b/.github/bdd-parts.json @@ -301,6 +301,9 @@ ], "bootstrap-semantic-reasoning": [ "BS-72" + ], + "bootstrap-semantic-decode": [ + "BS-73" ] }, "targets": { diff --git a/.github/intel-host-lanes.json b/.github/intel-host-lanes.json index e71e2d7bb8..536c56d1a4 100644 --- a/.github/intel-host-lanes.json +++ b/.github/intel-host-lanes.json @@ -2,7 +2,7 @@ "producer": ["honesty"], "lanes": { "lower": ["bootstrap-lower", "bootstrap-lexicon-lse", "bootstrap-lexicon-lre", "bootstrap-surface-module", "bootstrap-diagnostics", "bootstrap-cli-output"], - "print": ["bootstrap-print", "bootstrap-bodies", "bootstrap-succeed", "bootstrap-loops", "bootstrap-assemble", "bootstrap-package", "bootstrap-check", "bootstrap-gnaf", "bootstrap-runtime", "bootstrap-terms", "bootstrap-tooling-latex", "bootstrap-structural-grammar", "bootstrap-surface-lex", "bootstrap-surface-doc", "bootstrap-surface-generic", "bootstrap-surface-tooling", "bootstrap-lock-text", "bootstrap-content-id", "bootstrap-project-text", "bootstrap-manifest-text", "bootstrap-ir-term", "bootstrap-ir-proof", "bootstrap-ir-document", "bootstrap-semantic-types", "bootstrap-semantic-terms", "bootstrap-semantic-decls", "bootstrap-semantic-models", "bootstrap-semantic-reasoning"], + "print": ["bootstrap-print", "bootstrap-bodies", "bootstrap-succeed", "bootstrap-loops", "bootstrap-assemble", "bootstrap-package", "bootstrap-check", "bootstrap-gnaf", "bootstrap-runtime", "bootstrap-terms", "bootstrap-tooling-latex", "bootstrap-structural-grammar", "bootstrap-surface-lex", "bootstrap-surface-doc", "bootstrap-surface-generic", "bootstrap-surface-tooling", "bootstrap-lock-text", "bootstrap-content-id", "bootstrap-project-text", "bootstrap-manifest-text", "bootstrap-ir-term", "bootstrap-ir-proof", "bootstrap-ir-document", "bootstrap-semantic-types", "bootstrap-semantic-terms", "bootstrap-semantic-decls", "bootstrap-semantic-models", "bootstrap-semantic-reasoning", "bootstrap-semantic-decode"], "validate": ["bootstrap-validate", "compiler", "preservation", "preservation-lists", "preservation-runtime", "preservation-support", "preservation-prims", "preservation-std", "production"], "moves": ["bootstrap-moves", "verification", "rest"] } diff --git a/.github/vv-rows.json b/.github/vv-rows.json index fc3b3b8d9a..9b90f307f8 100644 --- a/.github/vv-rows.json +++ b/.github/vv-rows.json @@ -430,5 +430,14 @@ "width": "", "memory_kib": "", "hints": "" + }, + { + "part": "bdd-bootstrap-semantic-decode", + "recipes": "bdd", + "examples_part": "", + "bdd_part": "bootstrap-semantic-decode", + "width": "", + "memory_kib": "", + "hints": "" } ] diff --git a/.github/workflows/regenerate.yml b/.github/workflows/regenerate.yml index 2b1fb67b43..1e93c99731 100755 --- a/.github/workflows/regenerate.yml +++ b/.github/workflows/regenerate.yml @@ -91,6 +91,13 @@ jobs: sudo mkswap "$RUNNER_TEMP/lexlean-regenerate.swap" sudo swapon "$RUNNER_TEMP/lexlean-regenerate.swap" sudo sysctl vm.swappiness=10 + - name: Refresh the project locks + shell: bash + run: | + set -euo pipefail + cargo build -q -p lexlean + L="$PWD/target/debug/lexlean" + for p in bootstrap stdlib compiler; do (cd "$p" && "$L" lock); done - name: Run the write recipes shell: bash env: @@ -114,6 +121,11 @@ jobs: set -euo pipefail mkdir -p "$RUNNER_TEMP/part" git add --all + # Every writer refreshes the locks, because its recipes read them; one + # writer reports them, or `combine` sees three parts write one path. + if [ "${{ matrix.writer }}" != production-export ]; then + git reset -q -- bootstrap/lexlean.lock stdlib/lexlean.lock compiler/lexlean.lock + fi git diff --cached --binary > "$RUNNER_TEMP/part/${{ matrix.writer }}.patch" git diff --cached --name-only | tee "$RUNNER_TEMP/part/${{ matrix.writer }}.files" echo "${{ matrix.writer }}: $(wc -l < "$RUNNER_TEMP/part/${{ matrix.writer }}.files") paths" >> "$GITHUB_STEP_SUMMARY" diff --git a/CHANGELOG.md b/CHANGELOG.md index a2cb3c0762..f406f1364b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,19 @@ workspace carried at those versions without a tag. version, the changelog's `## Unreleased` heading, and `Cargo.lock`), opens the pull request, and regenerates it; `tag.yml` tags the merge once its gate passes, dispatches `release.yml`, and opens the pull request into `main`. +- The bootstrap project configures `max_file_bytes = 25165824` (SPEC.md + §17.23, the maintainer's decision): with `BS-73` a part of its certificate is + 12,928,150 bytes, beyond the 6,291,456 it configured. A semantic input, so its + lock and every package move. + +- The bootstrap project configures `child_timeout_ms = 900000` (SPEC.md + §17.23, the maintainer's decision): verifying `BS-73`, the certificate of a + production root (`LexLeanPreserve.Cf85a168f307e9378e5b0df3a87d82042.R62`, + the root's own name is being identified) took `lean` past the 300,000 ms + default, observed at 300,004 ms (run 43531029081, r14). `compiler` and + `stdlib` keep the default. A semantic input, so its lock and every package + move. + - Decision regions (SPEC.md §17.12, `PF-24`, UOR-Foundation/PrismPM#605; no new diagnostic code; changes the language-1.2 identity). The runtime gains a sixth native module, `LexLeanRuntime.Regions`: a checker of local box @@ -58,6 +71,11 @@ workspace carried at those versions without a tag. A landing that moves the language-1.2 ID now also updates the constant; `RP-10` names the new value when it is stale. +- Decoding a semantic module from its canonical JSON as language-1.2 source, ninth slice + of the typed IR (SPEC.md §17.23, §17.12, `BS-73`, #269; no new diagnostic code, no change + to the language-1.2 identity). `decodeSemanticModule` of `SemanticDecode` returns what + `SemanticModule::parse` decodes, or the decoding rejection it reports, for every committed + semantic module and for mutated ones. The register is 505 IDs. - The declarations of reasoning and text components, and semantic modules of every kind, as language-1.2 source, eighth slice of the typed IR (SPEC.md §17.23, §17.12, `BS-72`, #269; no new diagnostic code, no change to the language-1.2 identity). diff --git a/README.md b/README.md index fb32e722de..751bd674dd 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ just vv # the complete normative acceptance gate (SPEC.md §9.2) just release # vv, then the §30 release criterion; refused until 1.0.0 ``` -All 504 registered conformance IDs have their named tests; `just vv` checks them with the pinned toolchain installed. +All 505 registered conformance IDs have their named tests; `just vv` checks them with the pinned toolchain installed. The differential against the independent generator `lean4-prod` (SPEC.md §17.19, `OR-01`..`OR-08`) acquires it at its pinned commit: from the checkout `LEXLEAN_ORACLE_DIR` names, or by fetching the commit with `git` into the Cargo target directory (`LEXLEAN_ORACLE_CACHE` overrides), and builds it with the pinned Lean and Rust toolchains. It is validation evidence only and no input to any identity. An oracle that cannot be acquired, is not the pinned files, or fails is unavailable: that fails the gate on Linux x86-64 and is printed as `NOT VALIDATED` elsewhere, and is never reported as agreement. @@ -197,7 +197,7 @@ Every row is validated by `just vv`; the IDs link the claim to its register row, | The language-1.2 authoring notation: a readable `.lex.tex` text for a semantic module, in bijection with its canonical JSON, whose every position and variant is read from the schema, with readable forms for types and terms and a generic form for every other value, formatted canonically by `fmt` failing closed, the only form in which a language-1.2 source of the product is written (the data form is refused under language 1.2, and `lexlean::sdk` is the explicit conversion), the same for the compiler-tooling modules in the generic notation, with no compiler-semantics ID that depends on which form an embedded module is written in, with no product source owned by a generator but five named records, read and written by programs only through the authoring API (`lexlean::sdk`), and, for a native core module, a readable program over the shared table of kernel terms whose numbering is the order of its text | `AU-01`..`AU-13` | `build` | | The runtime of generated Lean as native modules: the portable, collection, model, and reasoning runtimes of language 1.2 are LexLean source that every generated module imports, migrated losslessly and audited against their exact axioms, the released runtime text of languages 1.0 and 1.1 is frozen data equal to their released output, and no other Lean runtime text remains in the compiler but the decoder of core module 2 | `RT-01`..`RT-04` | `build` | | The standard library: language-1.2 source beside the compiler whose members are certified production roots, each validated against its oracle by a seeded differential of its evaluator and rustc realizations; bytes and text over `Bytes`, an output buffer of a given capacity written in order; decimal and hexadecimal; the byte order and stable sorts over it; canonical JSON reading and writing; maps and sets over byte keys; SHA-256 against FIPS 180-4, the NIST CAVP vectors, and the `sha2` crate; and the `std-models` and `std-reasoning` source packages, generic over types, whose laws are kernel-checked theorems and whose application is the `helpdesk` example | `SL-01`, `SL-02`, `SL-03`, `SL-04`, `SL-05`, `SL-09`, `SL-10`, `SL-11`, `SL-13`, `SL-14` | `build` | -| The bootstrap project: the compiler's own components as language-1.2 source compiled by LexLean's production pipeline to certified Rust packages, the exact axiom-output parser and its closed Lean-name check, the primitive scanner of §12.2, the preservation lexer and token audit, the target calculus's checker, the Rust crate validator, the Rust printer, the runtime syntax validator, the failure typing and the types of the Rust lowering, its last-use moves, its literal values and its terms, the package renderer, the GNAF request validation, the LaTeX of a tooling module, the structural grammar, the lexer of the authoring notation, its layout algebra, its generic notation, the notation of a tooling module, the reader and printer of LexLean Semantic Expressions, the reader of LexLean Rendering Expressions, where the module of a source is, the canonical diagnostic and its terminal output, the canonical text of the lock file and of the project manifest, the hash recipes of content identity, and the build manifest, each held to the Rust it replaces (the stage-0 oracle) by the committed vectors and a seeded differential of its evaluator and rustc realizations, with planted defects detected and the production export committed | `BS-01`..`BS-72` | `build` | +| The bootstrap project: the compiler's own components as language-1.2 source compiled by LexLean's production pipeline to certified Rust packages, the exact axiom-output parser and its closed Lean-name check, the primitive scanner of §12.2, the preservation lexer and token audit, the target calculus's checker, the Rust crate validator, the Rust printer, the runtime syntax validator, the failure typing and the types of the Rust lowering, its last-use moves, its literal values and its terms, the package renderer, the GNAF request validation, the LaTeX of a tooling module, the structural grammar, the lexer of the authoring notation, its layout algebra, its generic notation, the notation of a tooling module, the reader and printer of LexLean Semantic Expressions, the reader of LexLean Rendering Expressions, where the module of a source is, the canonical diagnostic and its terminal output, the canonical text of the lock file and of the project manifest, the hash recipes of content identity, and the build manifest, each held to the Rust it replaces (the stage-0 oracle) by the committed vectors and a seeded differential of its evaluator and rustc realizations, with planted defects detected and the production export committed | `BS-01`..`BS-73` | `build` | | Source packages: a language-1.2 project imports the modules of a locked, content-addressed package of its workspace: `[[source_package]]` and `lexlean-workspace.toml`, the pins in `lexlean.lock` recomputed by every command, imports closed at link, no re-export of a package's production roots, and the package's modules replayed by the importer's `verify` with their origin in the records | `PK-01`..`PK-05` | `build` | | The literal `nat-add-zero` example, the Lean-verified feature examples, and the complete negative fixture suite | `EX-01`..`EX-09` | `build` | | Language-1.2 text components: tokenizers and their round-trip laws, with the laws carried as one native core module the generated modules import rather than authored Lean text | `LM-01`, `LM-02`, `LM-03`, `LM-13` | `build` | diff --git a/SPEC.md b/SPEC.md index e9efe585c7..f3b7c3e1ed 100644 --- a/SPEC.md +++ b/SPEC.md @@ -8853,7 +8853,17 @@ took the export past that, to 135,273,215 bytes, so the project now configures further components of the driver. With the driver's cases in `RuntimeValidate` (`RB-24`), Lean's extraction of the project writes more than the 33,554,432 bytes of output a child process may produce, so the project configures `max_child_output_bytes = 268435456` -(the maintainer's decision), with room for the slices of the typed IR. +(the maintainer's decision), with room for the slices of the typed IR. With +the ninth slice, `BS-73`, a part of its certificate is 12,928,150 bytes, beyond +the 6,291,456 bytes the project configured, so the project configures +`max_file_bytes = 25165824` (the maintainer's decision), with room for the +further slices of the typed IR. Verifying that slice, the certificate of the +production root `LexLeanPreserve.Cf85a168f307e9378e5b0df3a87d82042.R62` (the +root's own name is being identified) took `lean` past the `child_timeout_ms` +default: 300,004 ms observed against 300,000 configured (run 43531029081, +r14). The project therefore configures `child_timeout_ms = 900000` for +`bootstrap` alone (the maintainer's decision); `compiler` and `stdlib` stay +at the default. `BS-16` holds `validateRequest` of `GnafValidate` to `gnaf::validate` (§17.15). The root takes the projection of a request that validation reads, as first-order data: the length of the domain, the machine (its capacity, @@ -9210,6 +9220,19 @@ and `SemanticTypes`, with two production roots for `rust-std`: With this module every semantic module the linked IR embeds is written by source, and the module and the case's encoders and examples are generated from one description of the oracle's types. Both roots admit `recursion`. Reading declarations and modules from JSON stays in the host. +Decoding a semantic module from its canonical JSON is the ninth component of the typed IR as +source (`BS-73`, issue 269), the module `SemanticDecode` over `SemanticReasoning`, `SemanticModels`, +`SemanticDecls`, `SemanticTerms`, `SemanticTypes`, and the standard library's JSON reader, with one +production root for `rust-std`: + +| Root | Takes | Returns | Oracle | +| --- | --- | --- | --- | +| `LexLeanBoot.SemanticDecode.decodeSemanticModule` | a text | the module's specification and declarations, or the first decoding rejection it meets: invalid semantic-module JSON, JSON that is not canonical, or a member outside the closed schema with its path | the decoding half of `ir::semantic::SemanticModule::parse` | + +The module reads JSON text as serde does, with whitespace, members in any order, and every escape, +and its decoders are generated from the description of the oracle's types that writes `BS-71` and +`BS-72`; each recurses on a count of the document's values, and serde's nesting limit is checked as +the document's depth. The root admits `recursion`. Validating a decoded module stays in the host. The authoring notation of a tooling module (§17.20, §17.21) is the fifth component of the front end (`BS-27`, issue 269), the module `SurfaceTooling` over the generic notation of @@ -12277,6 +12300,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `BS-70` | `bootstrap` | The ordinary declarations of the semantic module language of SPEC.md §17.11 and §17.12 and the module that holds them (`ir::semantic::SemanticDeclaration` for structures, classes, instances, inductives, definitions, and theorems, and `SemanticModule`, in the serde form the linked IR embeds, written as canonical JSON: each declaration tagged by its `kind`, its parameters, fields, constructors, and assignments in order, and a definition's or a theorem's type parameters, recursive argument, axioms, executable flag, mutual group, termination, and production, and an inductive's mutual group, left out exactly where the oracle's serde attributes skip them; and a module's specification and declarations in order) is language-1.2 source in the `bootstrap/` project, as two production roots of `SemanticDecls` over `SemanticTerms` and `SemanticTypes`: `semanticDeclarationText` and `semanticModuleText`, each eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator on the shorter modules, agree with the oracle to the byte on hand-built declarations, which reach every kind and every optional member both present and absent, on every distinct ordinary declaration of every committed semantic module that links and on every such module whose declarations are all ordinary, among them every module of the `bootstrap/` project and the standard library, and on seeded declarations; each planted defect in the source is detected by the root and the one vector it names, and the certified packages the production export publishes for the project are the committed ones; the declarations of models, reasoning, and text components, and reading declarations from JSON, are outside the claim. | §17.11, §17.12, §17.23 | | `BS-71` | `bootstrap` | The declarations of artifacts, contracts, realizations, evidence, and models of the semantic module language of SPEC.md §17.12 (those variants of `ir::semantic::SemanticDeclaration`, with the artifact roles and schemas, binders, states, validators, uses, rules, the deterministic, rule, statistical, neural, and composite realization descriptors with their layers, decoders, forms, and junctions, and the evidence claims they hold, in the serde form the linked IR embeds, written as canonical JSON: each tagged variant by its `kind`, each closed name as the oracle serializes it, and each optional member left out exactly where the oracle's serde attributes skip it) is language-1.2 source in the `bootstrap/` project, as the production root `modelDeclarationText` of `SemanticModels` over `SemanticTerms` and `SemanticTypes`, generated with the case's encoders and examples from one description of the oracle's types, eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and with no part of its certificate beyond 3,145,728 bytes; its rendered `rust-std` package under the pinned rustc, and on the normative host its lowered program under the calculus evaluator, agree with the oracle to the byte on examples that reach every variant, every optional member present and absent, and every list empty and not, on every distinct such declaration of every committed semantic module that links, and on seeded examples; each planted defect, a misspelled kind or name, is detected by the first example that holds it, and the certified packages the production export publishes for the project are the committed ones; reading declarations from JSON is outside the claim. | §17.12, §17.23 | | `BS-72` | `bootstrap` | The declarations of logics, inference rules, verifiers, reasoners, tokenizers, context windows, text generators, and text classifiers of the semantic module language of SPEC.md §17.12, and the semantic module of declarations of every kind (those variants of `ir::semantic::SemanticDeclaration`, with the invariants, bindings, answers, search orders, strategies, claims, tokenizer schemes, overflow dispositions, and generation policies they hold, and `SemanticModule`, in the serde form the linked IR embeds, written as canonical JSON: each tagged variant by its `kind`, each closed name as the oracle serializes it, each optional member left out exactly where the oracle's serde attributes skip it, and a module's specification and declarations in order, its ordinary declarations through `SemanticDecls` and its model declarations through `SemanticModels`) is language-1.2 source in the `bootstrap/` project, as two production roots of `SemanticReasoning`, generated with the case's encoders and examples from one description of the oracle's types: `reasoningDeclarationText` and `wholeSemanticModuleText`, each eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator on the shorter modules, agree with the oracle to the byte on examples that reach every variant, every optional member present and absent, and every list empty and not, on every distinct such declaration and every distinct semantic module of every committed project that links, and on seeded examples; each planted defect, a misspelled kind or name, is detected by the first example that holds it, and the certified packages the production export publishes for the project are the committed ones; reading declarations and modules from JSON is outside the claim. | §17.12, §17.23 | +| `BS-73` | `bootstrap` | Decoding a semantic module of the semantic module language of SPEC.md §17.12 from its canonical JSON, as `ir::semantic::SemanticModule::parse` decodes it before it validates (serde's reading of the JSON text, with its whitespace, member order, and escapes, and its typed decoding of `SemanticModule` and every declaration, term, proof, and type it holds, with its rules for unknown, missing, duplicate, and defaulted members, tagged unit variants, and 128 levels of nesting; the comparison with the canonical form; and the closed schema, with the path of the first member outside it), is language-1.2 source in the `bootstrap/` project, as the production root `decodeSemanticModule` of `SemanticDecode`, its decoders generated from the description of the oracle's types that `BS-71` and `BS-72` write from, which returns the module's specification and declarations or which of the three decoding rejections the text meets first: eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and with no part of its certificate beyond 3,145,728 bytes; its rendered `rust-std` package under the pinned rustc, and on the normative host its lowered program under the calculus evaluator on the shorter modules, agree with the oracle on every distinct semantic module of every committed project that links, on modules of examples that reach every model, reasoning, and text variant, on modules nested to the deepest level serde admits and one level deeper, and on mutations of these modules that remove a member, repeat one, add an unknown one, write out an omitted default, rename a kind, change a value's type, or leave the canonical form, among texts the canonical JSON parser accepts or serde rejects first; each planted defect, a weakened decoding rule, is detected by those runs, and the certified packages the production export publishes for the project are the committed ones; validating a decoded module is outside the claim. | §17.12, §17.23 | | `PK-01` | `packages` | A language-1.2 project that declares a source package by its identifier, version, kind `path`, and the member directory a `lexlean-workspace.toml` lists locks it by the tree digest of its manifest and source files, its manifest digest, its version, its module prefix, and its own packages, and the configuration and the lock read back to the bytes written; a project without a source package keeps its bytes, and a package of another kind, a source package in another language, a changed byte or version (LLC0105), an undeclared package (LLC0106), a module prefix claimed twice (LLC0107), a project or a package outside the workspace (LLC0108), a path that escapes it, and a symlink (LLS8001) are each refused with the named code. | §10.5, §11.1, §25.1 | | `PK-02` | `packages` | A module of a project imports only modules of its own project and modules of the packages the project declares, and a module of a package only modules of itself and of the packages its own manifest declares: a package module is a module of the importing project under its own module prefix, a module of a package the project does not declare fails with LLR3009, and an import cycle through a package fails with LLR3003. | §10.5, §15.1 | | `PK-03` | `packages` | An importing project builds and verifies under the pinned Lean offline, and its package modules are generated, elaborated, replayed with `leanchecker`, and audited for their exact axioms under the package's module prefix with the package as their origin in the records; the source ID of the project changes with the pins, and no file of the package is written by `fmt`, `build`, or `verify`. | §10.5, §21.3, §22 | @@ -12293,7 +12317,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `LM-09` | `language-models` | No prompt is code: no member of the closed language maps `string` or `bytes` to a function, a term, or source — every operation of the primitive registry that takes a `string` or `bytes` operand is classified by the audit with a data result, the registry's schema enumeration and the production registry's primitive rows equal one another and equal that classified set, and the text declarations of `lexlean/semantic-module/2` state no `string`-typed member, so a prompt reaches a model only as the tokens `encodeText` makes of it; a planted operation or text member of that shape is caught by the audit with its name. | §17.12 | | `LM-13` | `language-models` | The text laws a tokenizer elaborates through are LexLean source and not authored text: the module that states them is one language-1.2 native core module of the embedded `language/text-1.2` project, the project holds no file of Lean source, no independently authored Lean file anywhere in the release tree declares the `LexLeanText` namespace or lies under its module root, and the one-time migration input is absent; the registry lists only that module, the declarations and their exact axiom policies are read from its native data, which the compiler embeds and hashes into the language-1.2 semantics, and a module that declares a text component imports the generated module rather than splicing any Lean text. | §17.10, §17.12 | -**Total required capability IDs:** 504. +**Total required capability IDs:** 505. No row may be downgraded to `some-true` or `open`. Upstream Lean facts are ledger/authority rows, not substitutions for these build behaviors. diff --git a/VERIFICATION.md b/VERIFICATION.md index 762b4edc5a..a632131dff 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12019,6 +12019,86 @@ Measured with the compiler binary of this tree's compiler sources: `lexlean check` of the `bootstrap/` project passes, with each root eligible for `rust-std` with exactly its declared effects, and `lexlean fmt --check` passes. +### decoding a semantic module from JSON is source (BS-73) + +The regeneration of the typed-IR stack at this slice's tip (run 43481945154, +r9) stopped bootstrap's production export at `LLS8002`: a part of its +certificate is 12,928,150 bytes, beyond the 6,291,456 bytes the project let +one file hold. The project now configures `max_file_bytes = 25165824` (the +maintainer's decision, 2026-11-13; a semantic input, so the lock and every +package move at the landing), which leaves room for the further slices of the +typed IR. Which root the oversized part belongs to, and whether it has a +structural fix as `RB-24`'s validator twin did, is open; the raise unblocks +the batch and is not the end of the matter. + +With the fourteen axioms restored (below), the next regeneration (run +43531029081, r14) stopped at a second `LLS8002`: `lean` exceeded +`child_timeout_ms` checking the certificate of a production root, +`LexLeanPreserve.Cf85a168f307e9378e5b0df3a87d82042.R62` (the root's own name +is being identified), 300,004 ms observed against the 300,000 ms default. +The project now configures `child_timeout_ms = 900000` for `bootstrap` alone +(the maintainer's decision, 2026-11-13); `compiler` and `stdlib` keep the +default. Whether the slow certificate has a structural fix, in the style of +`RB-24`'s table-to-`inList` restructuring, is open and tracked separately +from the raise that unblocks the batch. + +Once that export ran, the gate caught `LLV7005` on three of the module's +hand-written helpers (`oneByte`, `trailing`, `utf8Of`, the loose JSON +reader): each declared the axioms its own proof never uses (run 43498736513, +r10, `observed []`). They were copied from the standard library's reader +this one is modelled on, and `LLV7005` catches an unused axiom only when a +root's own proof is examined, so a reader built from an existing one +inherits axioms it never needs until its own root is checked. The first fix +swept all seventeen of the module's loose-JSON-reader helpers to no axioms, +past the three the gate had actually named; the next regeneration (run +43509954359, r13) caught the opposite violation on the other fourteen +(`byteAt`, `digitAt`, `digitsUntil`, `hexAt`, `looseAdvance`, `looseEscape`, +`looseInteger`, `looseKeyAt`, `looseStep`, `looseString`, `looseStringStep`, +`looseValueAt`, `readLoose`, `unicodeEscape`): their own proofs do use +`[Quot.sound, propext]`, so the sweep had removed axioms fourteen of the +seventeen genuinely need. Only `oneByte`, `trailing`, and `utf8Of` declare +none; every other helper but the root, `decodeSemanticModule`, declares +`[Quot.sound, propext]`. + +`BS-73` holds the production root `decodeSemanticModule` of +`LexLeanBoot.SemanticDecode` (`bootstrap/src/SemanticDecode.lex.tex`) to the +decoding half of `lexlean::ir::semantic::SemanticModule::parse`: serde's typed +decoding of the module and everything it holds, the comparison with the +canonical form, and the closed-schema walk that names the first member serde +ignored. The standard library's reader takes canonical text only, so the +module reads JSON text as serde does: whitespace between tokens, members in any +order and repeated, every escape including surrogate pairs, and integers +without fractions or exponents. The root returns the module's specification and declarations, in the +representation `SemanticReasoning` (`BS-72`) writes, or the rejection the parser +reports first. The decoders are generated from the description of the oracle's +types that writes `BS-71` and `BS-72`; each recurses on a count of the +document's values, and serde's nesting limit is checked as the document's +depth. The root admits exactly `allocation`, `overflow`, and `recursion`. The +oracle is the existing public code of `semantic.rs`; no Rust outside the case +changes. + +The case's domain is the texts that the canonical JSON parser accepts or that +serde rejects first, since a text serde decodes and the canonical parser then +rejects fails for a reason outside decoding. A text the parser decodes and then +fails to validate decodes; validation is outside the claim. The runs are every +distinct semantic module of every committed project that links, modules of the +`BS-71` and `BS-72` examples, a module nested 127 levels and one nested 128, and +mutations of ten example modules and twenty short committed modules: a member +removed, a member repeated, an unknown member with the value `0`, `false`, or `[]`, an omitted +default written out, a kind renamed, a string or count of another type, a +negative count, an array replaced by an object, and texts out of canonical +form (whitespace, members out of order, an escaped key). The case asserts that every outcome occurs among them. The evaluator takes +the committed modules whose JSON is at most 16,384 bytes and the rendered package +all of them. Each planted defect weakens one decoding rule (the nesting limit, +the canonical comparison, the unit-variant rule, either omitted default, the +unknown-member and duplicate-member rules, negative counts, one kind, and the +path's index syntax, whitespace, and `\u` escapes), and the runs detect it; the case asserts that the site of +each plant occurs once. The row's statement carries no counts. + +Measured with the compiler binary of this tree's compiler sources: `lexlean +check` of the `bootstrap/` project passes, with the root eligible for `rust-std` +with exactly its declared effects, and `lexlean fmt --check` passes. + ## The `bdd` recipe as the parts of one run (Issue #131) With UOR Atlas verified as the parts of one run, the `rest` leg became the diff --git a/bootstrap/README.md b/bootstrap/README.md index 166070a862..a9ad8990ee 100644 --- a/bootstrap/README.md +++ b/bootstrap/README.md @@ -79,3 +79,6 @@ realizations, evidence, and models as the linked IR embeds them. `src/SemanticReasoning.lex.tex` (SPEC.md §17.23, `BS-72`) imports `SemanticDecls`, `SemanticModels`, `SemanticTerms`, `SemanticTypes`, and the standard library's `Json` and `Order`, and writes the declarations of reasoning and text components and semantic modules of every kind. +`src/SemanticDecode.lex.tex` (SPEC.md §17.23, `BS-73`) imports `SemanticDecls`, `SemanticModels`, +`SemanticReasoning`, `SemanticTerms`, `SemanticTypes`, and the standard library's `Json`, `JsonRead`, +`Numeral`, and `Order`, and decodes a semantic module from its canonical JSON. diff --git a/bootstrap/lexlean.lock b/bootstrap/lexlean.lock index b58107830e..4944fb60ef 100644 --- a/bootstrap/lexlean.lock +++ b/bootstrap/lexlean.lock @@ -1,7 +1,7 @@ spec = "lexlean/lock/2" language = "1.2" -compiler_semantics = "635a25acb886587f8777525e778092e9599d1f2df26da59403ee39e9e299151a" -project_config_sha256 = "a70abffbcaf11f4e2ff847cc53d831bf5d295570d380e0f5dbc0f946ff44fa4e" +compiler_semantics = "a82990b56aa082f57e3bf3e2d6494d75a8170f26e269448de19110f5459655ad" +project_config_sha256 = "c93d59a6aae354319641e065d1999d70d11ea874de2e37aed9b3be0c88594103" lean_toolchain = "leanprover/lean4:v4.32.1" [[workspace_file]] diff --git a/bootstrap/lexlean.toml b/bootstrap/lexlean.toml index 29177bbb13..f93c3c8e9b 100644 --- a/bootstrap/lexlean.toml +++ b/bootstrap/lexlean.toml @@ -3,7 +3,7 @@ name = "bootstrap" language = "1.2" module_prefix = "LexLeanBoot" source_roots = ["src"] -entrypoints = ["src/AxiomOutput.lex.tex", "src/CalculusCheck.lex.tex", "src/CliOutput.lex.tex", "src/ContentId.lex.tex", "src/Diagnostics.lex.tex", "src/GnafValidate.lex.tex", "src/IrDocument.lex.tex", "src/IrProof.lex.tex", "src/IrTerm.lex.tex", "src/LexiconLre.lex.tex", "src/LexiconLse.lex.tex", "src/LockText.lex.tex", "src/ManifestText.lex.tex", "src/PrimitiveScan.lex.tex", "src/ProjectText.lex.tex", "src/RuntimeValidate.lex.tex", "src/RustAssemble.lex.tex", "src/RustAst.lex.tex", "src/RustBodies.lex.tex", "src/RustLoops.lex.tex", "src/RustLower.lex.tex", "src/RustMoves.lex.tex", "src/RustPackage.lex.tex", "src/RustPrint.lex.tex", "src/RustSucceed.lex.tex", "src/RustTerms.lex.tex", "src/RustValidate.lex.tex", "src/SemanticDecls.lex.tex", "src/SemanticModels.lex.tex", "src/SemanticReasoning.lex.tex", "src/SemanticTerms.lex.tex", "src/SemanticTypes.lex.tex", "src/StructuralGrammar.lex.tex", "src/SurfaceDoc.lex.tex", "src/SurfaceGeneric.lex.tex", "src/SurfaceLex.lex.tex", "src/SurfaceModule.lex.tex", "src/SurfaceTooling.lex.tex", "src/TokenAudit.lex.tex", "src/ToolingAst.lex.tex", "src/ToolingLatex.lex.tex"] +entrypoints = ["src/AxiomOutput.lex.tex", "src/CalculusCheck.lex.tex", "src/CliOutput.lex.tex", "src/ContentId.lex.tex", "src/Diagnostics.lex.tex", "src/GnafValidate.lex.tex", "src/IrDocument.lex.tex", "src/IrProof.lex.tex", "src/IrTerm.lex.tex", "src/LexiconLre.lex.tex", "src/LexiconLse.lex.tex", "src/LockText.lex.tex", "src/ManifestText.lex.tex", "src/PrimitiveScan.lex.tex", "src/ProjectText.lex.tex", "src/RuntimeValidate.lex.tex", "src/RustAssemble.lex.tex", "src/RustAst.lex.tex", "src/RustBodies.lex.tex", "src/RustLoops.lex.tex", "src/RustLower.lex.tex", "src/RustMoves.lex.tex", "src/RustPackage.lex.tex", "src/RustPrint.lex.tex", "src/RustSucceed.lex.tex", "src/RustTerms.lex.tex", "src/RustValidate.lex.tex", "src/SemanticDecls.lex.tex", "src/SemanticDecode.lex.tex", "src/SemanticModels.lex.tex", "src/SemanticReasoning.lex.tex", "src/SemanticTerms.lex.tex", "src/SemanticTypes.lex.tex", "src/StructuralGrammar.lex.tex", "src/SurfaceDoc.lex.tex", "src/SurfaceGeneric.lex.tex", "src/SurfaceLex.lex.tex", "src/SurfaceModule.lex.tex", "src/SurfaceTooling.lex.tex", "src/TokenAudit.lex.tex", "src/ToolingAst.lex.tex", "src/ToolingLatex.lex.tex"] build_root = ".lexlean" lockfile = "lexlean.lock" lean_workspace = "." @@ -20,7 +20,7 @@ kind = "path" path = "stdlib" [limits] -max_file_bytes = 6291456 +max_file_bytes = 25165824 max_total_source_bytes = 536870912 max_primitive_atoms = 2000000 max_token_lattice_edges = 4000000 @@ -30,4 +30,4 @@ max_scope_depth = 1024 max_import_depth = 128 max_diagnostics = 256 max_child_output_bytes = 268435456 -child_timeout_ms = 300000 +child_timeout_ms = 900000 diff --git a/bootstrap/src/SemanticDecode.lex.tex b/bootstrap/src/SemanticDecode.lex.tex new file mode 100644 index 0000000000..00854c821b --- /dev/null +++ b/bootstrap/src/SemanticDecode.lex.tex @@ -0,0 +1,4266 @@ +\begin{lexlean}{SemanticDecode} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{SemanticDecls} +\importmodule{SemanticModels} +\importmodule{SemanticReasoning} +\importmodule{SemanticTerms} +\importmodule{SemanticTypes} +\importmodule{LexLeanStd.Json} +\importmodule{LexLeanStd.Numeral} +\importmodule{LexLeanStd.Order} +\importmodule{LexLeanStd.Text} +\title{Natural number addition} +\begin{semanticmodule} +inductive{ + name: LooseFrame, + type_parameters: [], + parameters: [], + constructors: [ + {name: LooseArr, fields: [LexLeanStd.Json::Json]}, + {name: LooseObj, fields: [Bytes, LexLeanStd.Json::Json]} + ] +} + +inductive{ + name: LooseReading, + type_parameters: [], + parameters: [], + constructors: [{name: LooseRead, fields: [Nat, Nat, (List LooseFrame), LexLeanStd.Json::Json]}] +} + +definition{ + name: byteAt, + parameters: [text : Bytes, position : Nat], + result: Nat, + body: (match (prim index text position : (Option UInt8)) + | Option.some byte => (prim to_nat byte : Nat) + | Option.none => 256), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: isDigit, + parameters: [value : Nat], + result: Bool, + body: ((47 (digitAt text position)) ((prim length text : Nat) + 1) start : (Nat * Bool))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: looseInteger, + parameters: [text : Bytes, position : Nat], + result: (Option (Nat * LexLeanStd.Json::Json)), + body: (let negative : Bool := ((byteAt text position) =? 45); (let start : Nat := (if negative then (position + 1) else position); (let stop : Nat := (digitsUntil text start); (let next : Nat := (byteAt text stop); (if ((stop =? start) || ((((byteAt text start) =? 48) && (1 (ctor Option.some [(Nat * LexLeanStd.Json::Json)] (stop, (ctor LexLeanStd.Json::Json.JInt (if (magnitude =? 0) then false else negative) magnitude))) + | Option.none => (ctor Option.none [(Nat * LexLeanStd.Json::Json)]))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: hexDigit, + parameters: [value : Nat], + result: Nat, + body: (if (isDigit value) then (prim subtract value 48 : Nat) else (if ((64 (ctor Option.none [(Nat * Bytes)]) + | Option.some high => (if ((55295 (ctor Option.none [(Nat * Bytes)]) + | Option.some low => (if ((56319 (ctor Option.some [(Nat * (Bytes * Nat))] ((first decoded), ((prim append out (second decoded) : Bytes), 0))) + | Option.none => (ctor Option.some [(Nat * (Bytes * Nat))] (position, (out, 2)))) else (let piece : Bytes := (plainEscape letter); (if (prim equal piece 0x : Bool) then (ctor Option.some [(Nat * (Bytes * Nat))] (position, (out, 2))) else (ctor Option.some [(Nat * (Bytes * Nat))] ((position + 2), ((prim append out piece : Bytes), 0))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: looseStringStep, + parameters: [text : Bytes, state : (Nat * (Bytes * Nat))], + result: (Option (Nat * (Bytes * Nat))), + body: (let position : Nat := (first state); (let out : Bytes := (first (second state)); (if ((second (second state)) =? 0) then (let byte : Nat := (byteAt text position); (if (byte =? 34) then (ctor Option.some [(Nat * (Bytes * Nat))] ((position + 1), (out, 1))) else (if (byte =? 92) then (looseEscape text position out) else (if ((byte (looseStringStep text state)) ((prim length text : Nat) + 1) (start, (0x, 0)) : ((Nat * (Bytes * Nat)) * Bool)); (if ((second (second (first done))) =? 1) then (ctor Option.some [(Nat * Bytes)] ((first (first done)), (first (second (first done))))) else (ctor Option.none [(Nat * Bytes)]))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: spineStep, + parameters: [state : (LexLeanStd.Json::Json * LexLeanStd.Json::Json)], + result: (Option (LexLeanStd.Json::Json * LexLeanStd.Json::Json)), + body: (match (first state) + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)]) + | LexLeanStd.Json::Json.JArr inner => (ctor Option.none [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)]) + | LexLeanStd.Json::Json.JObj inner => (ctor Option.none [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.some [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)] (rest, (ctor LexLeanStd.Json::Json.JItem element (second state)))) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.some [(LexLeanStd.Json::Json * LexLeanStd.Json::Json)] (rest, (ctor LexLeanStd.Json::Json.JMember key inner (second state))))), + executable: true +} + +definition{ + name: reversedSpine, + parameters: [spine : LexLeanStd.Json::Json, fuel : Nat], + result: LexLeanStd.Json::Json, + body: (second (first (prim iterate_until (fun (state : (LexLeanStd.Json::Json * LexLeanStd.Json::Json)) => (spineStep state)) fuel (spine, (ctor LexLeanStd.Json::Json.JNil)) : ((LexLeanStd.Json::Json * LexLeanStd.Json::Json) * Bool)))), + executable: true +} + +definition{ + name: looseBroken, + parameters: [position : Nat], + result: LooseReading, + body: (ctor LooseReading.LooseRead position 9 (nil LooseFrame) (ctor LexLeanStd.Json::Json.JNil)), + executable: true +} + +definition{ + name: looseComplete, + parameters: [position : Nat, stack : (List LooseFrame), value : LexLeanStd.Json::Json], + result: LooseReading, + body: (match stack + | List.nil => (ctor LooseReading.LooseRead position 7 (nil LooseFrame) value) + | List.cons top below => (match top + | LooseFrame.LooseArr acc => (ctor LooseReading.LooseRead position 5 (cons (ctor LooseFrame.LooseArr (ctor LexLeanStd.Json::Json.JItem value acc)) below) (ctor LexLeanStd.Json::Json.JNil)) + | LooseFrame.LooseObj key acc => (ctor LooseReading.LooseRead position 5 (cons (ctor LooseFrame.LooseObj 0x (ctor LexLeanStd.Json::Json.JMember key value acc)) below) (ctor LexLeanStd.Json::Json.JNil)))), + executable: true +} + +definition{ + name: looseClose, + parameters: [text : Bytes, position : Nat, stack : (List LooseFrame)], + result: LooseReading, + body: (match stack + | List.nil => (looseBroken position) + | List.cons top below => (match top + | LooseFrame.LooseArr acc => (looseComplete (position + 1) below (ctor LexLeanStd.Json::Json.JArr (reversedSpine acc ((prim length text : Nat) + 1)))) + | LooseFrame.LooseObj key acc => (looseComplete (position + 1) below (ctor LexLeanStd.Json::Json.JObj (reversedSpine acc ((prim length text : Nat) + 1)))))), + executable: true +} + +definition{ + name: looseValueAt, + parameters: [text : Bytes, position : Nat, mode : Nat, stack : (List LooseFrame), byte : Nat], + result: LooseReading, + body: (if (byte =? 34) then (match (looseString text (position + 1)) + | Option.some scanned => (looseComplete (first scanned) stack (ctor LexLeanStd.Json::Json.JStr (second scanned))) + | Option.none => (looseBroken position)) else (if (byte =? 116) then (if (prim equal (LexLeanStd.Text::sliceOr text position 4) 0x74727565 : Bool) then (looseComplete (position + 4) stack (ctor LexLeanStd.Json::Json.JBool true)) else (looseBroken position)) else (if (byte =? 102) then (if (prim equal (LexLeanStd.Text::sliceOr text position 5) 0x66616c7365 : Bool) then (looseComplete (position + 5) stack (ctor LexLeanStd.Json::Json.JBool false)) else (looseBroken position)) else (if (byte =? 91) then (ctor LooseReading.LooseRead (position + 1) 1 (cons (ctor LooseFrame.LooseArr (ctor LexLeanStd.Json::Json.JNil)) stack) (ctor LexLeanStd.Json::Json.JNil)) else (if (byte =? 123) then (ctor LooseReading.LooseRead (position + 1) 3 (cons (ctor LooseFrame.LooseObj 0x (ctor LexLeanStd.Json::Json.JNil)) stack) (ctor LexLeanStd.Json::Json.JNil)) else (if ((byte =? 93) && (mode =? 1)) then (looseClose text position stack) else (if ((byte =? 45) || (isDigit byte)) then (match (looseInteger text position) + | Option.some read => (looseComplete (first read) stack (second read)) + | Option.none => (looseBroken position)) else (looseBroken position)))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: looseKeyAt, + parameters: [text : Bytes, position : Nat, mode : Nat, stack : (List LooseFrame), byte : Nat], + result: LooseReading, + body: (if (byte =? 34) then (match (looseString text (position + 1)) + | Option.some scanned => (match stack + | List.nil => (looseBroken position) + | List.cons top below => (match top + | LooseFrame.LooseArr acc => (looseBroken position) + | LooseFrame.LooseObj pending acc => (ctor LooseReading.LooseRead (first scanned) 4 (cons (ctor LooseFrame.LooseObj (second scanned) acc) below) (ctor LexLeanStd.Json::Json.JNil)))) + | Option.none => (looseBroken position)) else (if ((byte =? 125) && (mode =? 3)) then (looseClose text position stack) else (looseBroken position))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: looseAfterAt, + parameters: [text : Bytes, position : Nat, stack : (List LooseFrame), byte : Nat], + result: LooseReading, + body: (match stack + | List.nil => (looseBroken position) + | List.cons top below => (match top + | LooseFrame.LooseArr acc => (if (byte =? 44) then (ctor LooseReading.LooseRead (position + 1) 0 stack (ctor LexLeanStd.Json::Json.JNil)) else (if (byte =? 93) then (looseClose text position stack) else (looseBroken position))) + | LooseFrame.LooseObj key acc => (if (byte =? 44) then (ctor LooseReading.LooseRead (position + 1) 2 stack (ctor LexLeanStd.Json::Json.JNil)) else (if (byte =? 125) then (looseClose text position stack) else (looseBroken position))))), + executable: true +} + +definition{ + name: isSpace, + parameters: [byte : Nat], + result: Bool, + body: ((byte =? 32) || ((byte =? 10) || ((byte =? 13) || (byte =? 9)))), + executable: true +} + +definition{ + name: looseAdvance, + parameters: [ + text : Bytes, + position : Nat, + mode : Nat, + stack : (List LooseFrame), + done : LexLeanStd.Json::Json + ], + result: LooseReading, + body: (let byte : Nat := (byteAt text position); (if (isSpace byte) then (ctor LooseReading.LooseRead (position + 1) mode stack done) else (if (mode =? 7) then (ctor LooseReading.LooseRead position (if (byte =? 256) then 8 else 9) stack done) else (if (byte =? 256) then (looseBroken position) else (if ((mode =? 0) || (mode =? 1)) then (looseValueAt text position mode stack byte) else (if ((mode =? 2) || (mode =? 3)) then (looseKeyAt text position mode stack byte) else (if (mode =? 4) then (if (byte =? 58) then (ctor LooseReading.LooseRead (position + 1) 0 stack done) else (looseBroken position)) else (looseAfterAt text position stack byte)))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: looseStep, + parameters: [text : Bytes, state : LooseReading], + result: (Option LooseReading), + body: (match state + | LooseReading.LooseRead position mode stack done => (if (8 <=? mode) then (ctor Option.none [LooseReading]) else (ctor Option.some [LooseReading] (looseAdvance text position mode stack done)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: readLoose, + parameters: [text : Bytes], + result: (Option LexLeanStd.Json::Json), + body: (match (first (prim iterate_until (fun [text] (state : LooseReading) => (looseStep text state)) ((prim length text : Nat) + 3) (ctor LooseReading.LooseRead 0 0 (nil LooseFrame) (ctor LexLeanStd.Json::Json.JNil)) : (LooseReading * Bool))) + | LooseReading.LooseRead position mode stack done => (if (mode =? 8) then (ctor Option.some [LexLeanStd.Json::Json] done) else (ctor Option.none [LexLeanStd.Json::Json]))), + axioms: [Quot.sound, propext], + executable: true +} + +structure{ + name: KeyCheck, + type_parameters: [], + parameters: [], + fields: [{name: seen, type: (List Bytes)}, {name: valid, type: Bool}] +} + +definition{ + name: lit, + parameters: [literal : String], + result: Bytes, + body: (prim utf8_encode literal : Bytes), + executable: true +} + +definition{ + name: decStr, + parameters: [value : LexLeanStd.Json::Json], + result: (Option Bytes), + body: (match value + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.some [Bytes] text) + | LexLeanStd.Json::Json.JArr items => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [Bytes])), + executable: true +} + +definition{ + name: decBool, + parameters: [value : LexLeanStd.Json::Json], + result: (Option Bool), + body: (match value + | LexLeanStd.Json::Json.JBool flag => (ctor Option.some [Bool] flag) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [Bool]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [Bool]) + | LexLeanStd.Json::Json.JArr items => (ctor Option.none [Bool]) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [Bool]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [Bool]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [Bool]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [Bool])), + executable: true +} + +definition{ + name: decNat, + parameters: [value : LexLeanStd.Json::Json], + result: (Option Nat), + body: (match value + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [Nat]) + | LexLeanStd.Json::Json.JInt negative magnitude => (if negative then (ctor Option.none [Nat]) else (if (9223372036854775807 (ctor Option.none [Nat]) + | LexLeanStd.Json::Json.JArr items => (ctor Option.none [Nat]) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [Nat]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [Nat]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [Nat]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [Nat])), + executable: true +} + +definition{ + name: decNatFuel, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option Nat), + body: (decNat value), + executable: true +} + +definition{ + name: lookup, + parameters: [members : LexLeanStd.Json::Json, wanted : Bytes], + result: (Option LexLeanStd.Json::Json), + body: (match members + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JArr items => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JObj nested => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JMember key inner rest => (if (prim equal key wanted : Bool) then (ctor Option.some [LexLeanStd.Json::Json] inner) else (lookup rest wanted))), + executable: true, + recursive_argument: members +} + +definition{ + name: keyList, + parameters: [members : LexLeanStd.Json::Json], + result: (List Bytes), + body: (match members + | LexLeanStd.Json::Json.JBool flag => (nil Bytes) + | LexLeanStd.Json::Json.JInt negative magnitude => (nil Bytes) + | LexLeanStd.Json::Json.JStr text => (nil Bytes) + | LexLeanStd.Json::Json.JArr items => (nil Bytes) + | LexLeanStd.Json::Json.JObj nested => (nil Bytes) + | LexLeanStd.Json::Json.JNil => (nil Bytes) + | LexLeanStd.Json::Json.JItem element rest => (nil Bytes) + | LexLeanStd.Json::Json.JMember key inner rest => (cons key (keyList rest))), + executable: true, + recursive_argument: members +} + +definition{ + name: listed, + parameters: [names : (List Bytes), wanted : Bytes], + result: Bool, + body: (prim list_fold (fun [wanted] (found : Bool) (candidate : Bytes) => (if found then true else (prim equal candidate wanted : Bool))) false names : Bool), + executable: true +} + +definition{ + name: countOf, + parameters: [names : (List Bytes), wanted : Bytes], + result: Nat, + body: (prim list_fold (fun [wanted] (count : Nat) (candidate : Bytes) => (if (prim equal candidate wanted : Bool) then (count + 1) else count)) 0 names : Nat), + executable: true +} + +definition{ + name: checkKey, + parameters: [allowed : (List Bytes), state : KeyCheck, key : Bytes], + result: KeyCheck, + body: (if (project state valid) then (if (listed allowed key) then (if (listed (project state seen) key) then (record KeyCheck {seen := (project state seen), valid := false}) else (record KeyCheck {seen := (cons key (project state seen)), valid := true})) else (record KeyCheck {seen := (project state seen), valid := false})) else state), + executable: true +} + +definition{ + name: closedKeys, + parameters: [members : LexLeanStd.Json::Json, allowed : (List Bytes)], + result: Bool, + body: (project (prim list_fold (fun [allowed] (state : KeyCheck) (key : Bytes) => (checkKey allowed state key)) (record KeyCheck {seen := (nil Bytes), valid := true}) (keyList members) : KeyCheck) valid), + executable: true +} + +definition{ + name: kindOf, + parameters: [members : LexLeanStd.Json::Json], + result: (Option Bytes), + body: (if (1 (decStr found) + | Option.none => (ctor Option.none [Bytes]))), + executable: true +} + +definition{ + name: strItems, + parameters: [items : LexLeanStd.Json::Json], + result: (Option (List Bytes)), + body: (match items + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JArr nested => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List Bytes)] (nil Bytes)) + | LexLeanStd.Json::Json.JItem element rest => (match (decStr element) + | Option.none => (ctor Option.none [(List Bytes)]) + | Option.some head => (match (strItems rest) + | Option.none => (ctor Option.none [(List Bytes)]) + | Option.some tail => (ctor Option.some [(List Bytes)] (cons head tail)))) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [(List Bytes)])), + executable: true, + recursive_argument: items +} + +definition{ + name: decNames, + parameters: [value : LexLeanStd.Json::Json], + result: (Option (List Bytes)), + body: (match value + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JArr items => (strItems items) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [(List Bytes)]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [(List Bytes)])), + executable: true +} + +definition{ + name: allListed, + parameters: [names : (List Bytes), allowed : (List Bytes)], + result: Bool, + body: (prim list_fold (fun [allowed] (valid : Bool) (named : Bytes) => (if valid then (listed allowed named) else false)) true names : Bool), + executable: true +} + +definition{ + name: decChecks, + parameters: [value : LexLeanStd.Json::Json], + result: (Option (List Bytes)), + body: (match (decNames value) + | Option.none => (ctor Option.none [(List Bytes)]) + | Option.some names => (if (allListed names (cons (lit "input_invariant") (cons (lit "output_invariant") (cons (lit "postcondition") (cons (lit "precondition") (nil Bytes)))))) then (ctor Option.some [(List Bytes)] names) else (ctor Option.none [(List Bytes)]))), + executable: true +} + +definition{ + name: decComparison, + parameters: [value : LexLeanStd.Json::Json], + result: (Option Bytes), + body: (match (decStr value) + | Option.none => (ctor Option.none [Bytes]) + | Option.some text => (if (listed (cons (lit "nat_beq") (cons (lit "nat_blt") (nil Bytes))) text) then (ctor Option.some [Bytes] text) else (ctor Option.none [Bytes]))), + executable: true +} + +definition{ + name: decInteger, + parameters: [value : LexLeanStd.Json::Json], + result: (Option SemanticTypes::SemanticInteger), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticTypes::SemanticInteger]) + | Option.some text => (if (prim equal text (lit "int") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IInt)) else (if (prim equal text (lit "int8") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IInt8)) else (if (prim equal text (lit "int16") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IInt16)) else (if (prim equal text (lit "int32") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IInt32)) else (if (prim equal text (lit "int64") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IInt64)) else (if (prim equal text (lit "uint8") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IUInt8)) else (if (prim equal text (lit "uint16") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IUInt16)) else (if (prim equal text (lit "uint32") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IUInt32)) else (if (prim equal text (lit "uint64") : Bool) then (ctor Option.some [SemanticTypes::SemanticInteger] (ctor SemanticTypes::SemanticInteger.IUInt64)) else (ctor Option.none [SemanticTypes::SemanticInteger]))))))))))), + executable: true +} + +definition{ + name: decPrimitive, + parameters: [value : LexLeanStd.Json::Json], + result: (Option SemanticTypes::SemanticPrimitive), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticTypes::SemanticPrimitive]) + | Option.some text => (if (prim equal text (lit "subtract") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSubtract)) else (if (prim equal text (lit "multiply") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMultiply)) else (if (prim equal text (lit "quotient") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PQuotient)) else (if (prim equal text (lit "remainder") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PRemainder)) else (if (prim equal text (lit "negate") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PNegate)) else (if (prim equal text (lit "checked_convert") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PCheckedConvert)) else (if (prim equal text (lit "checked_add") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PCheckedAdd)) else (if (prim equal text (lit "checked_subtract") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PCheckedSubtract)) else (if (prim equal text (lit "checked_multiply") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PCheckedMultiply)) else (if (prim equal text (lit "checked_negate") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PCheckedNegate)) else (if (prim equal text (lit "checked_quotient") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PCheckedQuotient)) else (if (prim equal text (lit "bit_and") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PBitAnd)) else (if (prim equal text (lit "bit_or") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PBitOr)) else (if (prim equal text (lit "bit_xor") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PBitXor)) else (if (prim equal text (lit "bit_not") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PBitNot)) else (if (prim equal text (lit "shift_left") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PShiftLeft)) else (if (prim equal text (lit "shift_right") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PShiftRight)) else (if (prim equal text (lit "append") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PAppend)) else (if (prim equal text (lit "length") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PLength)) else (if (prim equal text (lit "index") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PIndex)) else (if (prim equal text (lit "slice") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSlice)) else (if (prim equal text (lit "utf8_encode") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PUtf8Encode)) else (if (prim equal text (lit "utf8_decode") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PUtf8Decode)) else (if (prim equal text (lit "compare_bytes") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PCompareBytes)) else (if (prim equal text (lit "equal") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PEqual)) else (if (prim equal text (lit "split_exact") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSplitExact)) else (if (prim equal text (lit "join") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PJoin)) else (if (prim equal text (lit "parse_decimal") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PParseDecimal)) else (if (prim equal text (lit "format_decimal") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PFormatDecimal)) else (if (prim equal text (lit "map_insert") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapInsert)) else (if (prim equal text (lit "map_remove") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapRemove)) else (if (prim equal text (lit "map_lookup") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapLookup)) else (if (prim equal text (lit "map_contains") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapContains)) else (if (prim equal text (lit "map_size") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapSize)) else (if (prim equal text (lit "map_keys") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapKeys)) else (if (prim equal text (lit "map_values") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapValues)) else (if (prim equal text (lit "map_entries") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapEntries)) else (if (prim equal text (lit "map_fold") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PMapFold)) else (if (prim equal text (lit "set_insert") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetInsert)) else (if (prim equal text (lit "set_remove") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetRemove)) else (if (prim equal text (lit "set_contains") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetContains)) else (if (prim equal text (lit "set_size") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetSize)) else (if (prim equal text (lit "set_elements") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetElements)) else (if (prim equal text (lit "set_union") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetUnion)) else (if (prim equal text (lit "set_intersection") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetIntersection)) else (if (prim equal text (lit "set_difference") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetDifference)) else (if (prim equal text (lit "set_fold") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PSetFold)) else (if (prim equal text (lit "list_fold") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PListFold)) else (if (prim equal text (lit "iterate") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PIterate)) else (if (prim equal text (lit "iterate_until") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PIterateUntil)) else (if (prim equal text (lit "graph_successors") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PGraphSuccessors)) else (if (prim equal text (lit "graph_reachable") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PGraphReachable)) else (if (prim equal text (lit "graph_topological") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PGraphTopological)) else (if (prim equal text (lit "less_than") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PLessThan)) else (if (prim equal text (lit "to_int") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PToInt)) else (if (prim equal text (lit "to_nat") : Bool) then (ctor Option.some [SemanticTypes::SemanticPrimitive] (ctor SemanticTypes::SemanticPrimitive.PToNat)) else (ctor Option.none [SemanticTypes::SemanticPrimitive])))))))))))))))))))))))))))))))))))))))))))))))))))))))))), + executable: true +} + +definition{ + name: decProduction, + parameters: [value : LexLeanStd.Json::Json], + result: (Option ((List Bytes) * (List Bytes))), + body: (match value + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [((List Bytes) * (List Bytes))]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [((List Bytes) * (List Bytes))]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [((List Bytes) * (List Bytes))]) + | LexLeanStd.Json::Json.JArr items => (ctor Option.none [((List Bytes) * (List Bytes))]) + | LexLeanStd.Json::Json.JObj members => (if (closedKeys members (cons (lit "effects") (cons (lit "targets") (nil Bytes)))) then (match (lookup members (lit "targets")) + | Option.none => (ctor Option.none [((List Bytes) * (List Bytes))]) + | Option.some targets => (match (lookup members (lit "effects")) + | Option.none => (ctor Option.none [((List Bytes) * (List Bytes))]) + | Option.some effects => (match (decNames targets) + | Option.none => (ctor Option.none [((List Bytes) * (List Bytes))]) + | Option.some named => (match (decNames effects) + | Option.none => (ctor Option.none [((List Bytes) * (List Bytes))]) + | Option.some effected => (ctor Option.some [((List Bytes) * (List Bytes))] (named, effected)))))) else (ctor Option.none [((List Bytes) * (List Bytes))])) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [((List Bytes) * (List Bytes))]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [((List Bytes) * (List Bytes))]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [((List Bytes) * (List Bytes))])), + executable: true +} + +definition{ + name: larger, + parameters: [left : Nat, right : Nat], + result: Nat, + body: (if (left 0 + | LexLeanStd.Json::Json.JInt negative magnitude => 0 + | LexLeanStd.Json::Json.JStr text => 0 + | LexLeanStd.Json::Json.JArr items => (1 + (depthOf items)) + | LexLeanStd.Json::Json.JObj members => (1 + (depthOf members)) + | LexLeanStd.Json::Json.JNil => 0 + | LexLeanStd.Json::Json.JItem element rest => (larger (depthOf element) (depthOf rest)) + | LexLeanStd.Json::Json.JMember key inner rest => (larger (depthOf inner) (depthOf rest))), + executable: true, + recursive_argument: value +} + +definition{ + name: nodesOf, + parameters: [value : LexLeanStd.Json::Json], + result: Nat, + body: (match value + | LexLeanStd.Json::Json.JBool flag => 1 + | LexLeanStd.Json::Json.JInt negative magnitude => 1 + | LexLeanStd.Json::Json.JStr text => 1 + | LexLeanStd.Json::Json.JArr items => (1 + (nodesOf items)) + | LexLeanStd.Json::Json.JObj members => (1 + (nodesOf members)) + | LexLeanStd.Json::Json.JNil => 1 + | LexLeanStd.Json::Json.JItem element rest => ((1 + (nodesOf element)) + (nodesOf rest)) + | LexLeanStd.Json::Json.JMember key inner rest => ((1 + (nodesOf inner)) + (nodesOf rest))), + executable: true, + recursive_argument: value +} + +definition{ + name: decArtifactRole, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ArtifactRole), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticModels::ArtifactRole]) + | Option.some text => (if (prim equal text (lit "parameters") : Bool) then (ctor Option.some [SemanticModels::ArtifactRole] (ctor SemanticModels::ArtifactRole.ArtifactRoleParameters)) else (if (prim equal text (lit "vocabulary") : Bool) then (ctor Option.some [SemanticModels::ArtifactRole] (ctor SemanticModels::ArtifactRole.ArtifactRoleVocabulary)) else (if (prim equal text (lit "dataset") : Bool) then (ctor Option.some [SemanticModels::ArtifactRole] (ctor SemanticModels::ArtifactRole.ArtifactRoleDataset)) else (if (prim equal text (lit "table") : Bool) then (ctor Option.some [SemanticModels::ArtifactRole] (ctor SemanticModels::ArtifactRole.ArtifactRoleTable)) else (if (prim equal text (lit "binary") : Bool) then (ctor Option.some [SemanticModels::ArtifactRole] (ctor SemanticModels::ArtifactRole.ArtifactRoleBinary)) else (ctor Option.none [SemanticModels::ArtifactRole]))))))), + executable: true +} + +definition{ + name: decTensorElement, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::TensorElement), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticModels::TensorElement]) + | Option.some text => (if (prim equal text (lit "int8") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementInt8)) else (if (prim equal text (lit "int16") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementInt16)) else (if (prim equal text (lit "int32") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementInt32)) else (if (prim equal text (lit "int64") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementInt64)) else (if (prim equal text (lit "uint8") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementUInt8)) else (if (prim equal text (lit "uint16") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementUInt16)) else (if (prim equal text (lit "uint32") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementUInt32)) else (if (prim equal text (lit "uint64") : Bool) then (ctor Option.some [SemanticModels::TensorElement] (ctor SemanticModels::TensorElement.TensorElementUInt64)) else (ctor Option.none [SemanticModels::TensorElement])))))))))), + executable: true +} + +definition{ + name: decContractPredicate, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ContractPredicate), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticModels::ContractPredicate]) + | Option.some text => (if (prim equal text (lit "invariant") : Bool) then (ctor Option.some [SemanticModels::ContractPredicate] (ctor SemanticModels::ContractPredicate.ContractPredicateInvariant)) else (if (prim equal text (lit "postcondition") : Bool) then (ctor Option.some [SemanticModels::ContractPredicate] (ctor SemanticModels::ContractPredicate.ContractPredicatePostcondition)) else (if (prim equal text (lit "precondition") : Bool) then (ctor Option.some [SemanticModels::ContractPredicate] (ctor SemanticModels::ContractPredicate.ContractPredicatePrecondition)) else (ctor Option.none [SemanticModels::ContractPredicate]))))), + executable: true +} + +definition{ + name: decStatisticalScheme, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::StatisticalScheme), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticModels::StatisticalScheme]) + | Option.some text => (if (prim equal text (lit "linear_scoring") : Bool) then (ctor Option.some [SemanticModels::StatisticalScheme] (ctor SemanticModels::StatisticalScheme.StatisticalSchemeLinearScoring)) else (ctor Option.none [SemanticModels::StatisticalScheme]))), + executable: true +} + +definition{ + name: decNeuralArchitecture, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::NeuralArchitecture), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticModels::NeuralArchitecture]) + | Option.some text => (if (prim equal text (lit "integer_feedforward") : Bool) then (ctor Option.some [SemanticModels::NeuralArchitecture] (ctor SemanticModels::NeuralArchitecture.NeuralArchitectureIntegerFeedforward)) else (ctor Option.none [SemanticModels::NeuralArchitecture]))), + executable: true +} + +definition{ + name: decSearchOrder, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::SearchOrder), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticReasoning::SearchOrder]) + | Option.some text => (if (prim equal text (lit "breadth_first") : Bool) then (ctor Option.some [SemanticReasoning::SearchOrder] (ctor SemanticReasoning::SearchOrder.SearchOrderBreadthFirst)) else (if (prim equal text (lit "depth_first") : Bool) then (ctor Option.some [SemanticReasoning::SearchOrder] (ctor SemanticReasoning::SearchOrder.SearchOrderDepthFirst)) else (ctor Option.none [SemanticReasoning::SearchOrder])))), + executable: true +} + +definition{ + name: decTokenizerScheme, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::TokenizerScheme), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticReasoning::TokenizerScheme]) + | Option.some text => (if (prim equal text (lit "byte_level") : Bool) then (ctor Option.some [SemanticReasoning::TokenizerScheme] (ctor SemanticReasoning::TokenizerScheme.TokenizerSchemeByteLevel)) else (if (prim equal text (lit "longest_match") : Bool) then (ctor Option.some [SemanticReasoning::TokenizerScheme] (ctor SemanticReasoning::TokenizerScheme.TokenizerSchemeLongestMatch)) else (ctor Option.none [SemanticReasoning::TokenizerScheme])))), + executable: true +} + +definition{ + name: decOverflowDisposition, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::OverflowDisposition), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticReasoning::OverflowDisposition]) + | Option.some text => (if (prim equal text (lit "refuse") : Bool) then (ctor Option.some [SemanticReasoning::OverflowDisposition] (ctor SemanticReasoning::OverflowDisposition.OverflowDispositionRefuse)) else (if (prim equal text (lit "keep_last") : Bool) then (ctor Option.some [SemanticReasoning::OverflowDisposition] (ctor SemanticReasoning::OverflowDisposition.OverflowDispositionKeepLast)) else (ctor Option.none [SemanticReasoning::OverflowDisposition])))), + executable: true +} + +definition{ + name: decSamplingGenerator, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::SamplingGenerator), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticReasoning::SamplingGenerator]) + | Option.some text => (if (prim equal text (lit "xorshift32") : Bool) then (ctor Option.some [SemanticReasoning::SamplingGenerator] (ctor SemanticReasoning::SamplingGenerator.SamplingGeneratorXorshift32)) else (ctor Option.none [SemanticReasoning::SamplingGenerator]))), + executable: true +} + +definition{ + name: decSamplingDistribution, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::SamplingDistribution), + body: (match (decStr value) + | Option.none => (ctor Option.none [SemanticReasoning::SamplingDistribution]) + | Option.some text => (if (prim equal text (lit "proportional") : Bool) then (ctor Option.some [SemanticReasoning::SamplingDistribution] (ctor SemanticReasoning::SamplingDistribution.SamplingDistributionProportional)) else (ctor Option.none [SemanticReasoning::SamplingDistribution]))), + executable: true +} + +definition{ + name: decMember, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option ((Option Bytes) * Bytes)), + body: (match fuel + | Nat.zero => (ctor Option.none [((Option Bytes) * Bytes)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [((Option Bytes) * Bytes)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [((Option Bytes) * Bytes)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [((Option Bytes) * Bytes)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [((Option Bytes) * Bytes)]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "module") (cons (lit "name") (nil Bytes)))) then (let decoded0 : (Option (Option Bytes)) := (match (lookup members (lit "module")) + | Option.some found => (match (decStr found) + | Option.some present => (ctor Option.some [(Option Bytes)] (ctor Option.some [Bytes] present)) + | Option.none => (ctor Option.none [(Option Bytes)])) + | Option.none => (ctor Option.some [(Option Bytes)] (ctor Option.none [Bytes]))); (match decoded0 + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)]) + | Option.some field1 => (ctor Option.some [((Option Bytes) * Bytes)] (field0, field1)))))) else (ctor Option.none [((Option Bytes) * Bytes)]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [((Option Bytes) * Bytes)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [((Option Bytes) * Bytes)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [((Option Bytes) * Bytes)]))), + executable: true +} + +definition{ + name: decType, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTypes::SemanticType), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTypes::SemanticType]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some tag => (if (prim equal tag (lit "type") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SType)) else (if (prim equal tag (lit "nat") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNat)) else (if (prim equal tag (lit "bool") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SBool)) else (if (prim equal tag (lit "prop") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SProp)) else (if (prim equal tag (lit "unit") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SUnit)) else (if (prim equal tag (lit "int") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SInt)) else (if (prim equal tag (lit "int8") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SInt8)) else (if (prim equal tag (lit "int16") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SInt16)) else (if (prim equal tag (lit "int32") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SInt32)) else (if (prim equal tag (lit "int64") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SInt64)) else (if (prim equal tag (lit "uint8") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SUInt8)) else (if (prim equal tag (lit "uint16") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SUInt16)) else (if (prim equal tag (lit "uint32") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SUInt32)) else (if (prim equal tag (lit "uint64") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SUInt64)) else (if (prim equal tag (lit "string") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SString)) else (if (prim equal tag (lit "bytes") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SBytes)) else (if (prim equal tag (lit "ordering") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SOrdering)) else (if (prim equal tag (lit "contract_violation") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SContractViolation)) else (if (prim equal tag (lit "reasoning_failure") : Bool) then (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SReasoningFailure)) else (if (prim equal tag (lit "parameter") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SParameter field0)))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "option") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "value")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SOption field0)))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "result") : Bool) then (if (closedKeys members (cons (lit "ok") (cons (lit "error") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "ok")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "error")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field1 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SResult field0 field1)))))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "list") : Bool) then (if (closedKeys members (cons (lit "element") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "element")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SList field0)))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "named") : Bool) then (if (closedKeys members (cons (lit "member") (cons (lit "arguments") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "member")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field1 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNamed (first field0) (second field0) field1)))))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "product") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "left")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "right")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field1 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SProduct field0 field1)))))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "function") : Bool) then (if (closedKeys members (cons (lit "parameters") (cons (lit "result") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "parameters")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "result")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field1 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SFunction field0 field1)))))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "map") : Bool) then (if (closedKeys members (cons (lit "key") (cons (lit "value") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "key")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "value")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field1 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SMap field0 field1)))))) else (ctor Option.none [SemanticTypes::SemanticType])) else (if (prim equal tag (lit "set") : Bool) then (if (closedKeys members (cons (lit "element") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "element")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some field0 => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SSet field0)))) else (ctor Option.none [SemanticTypes::SemanticType])) else (ctor Option.none [SemanticTypes::SemanticType]))))))))))))))))))))))))))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTypes::SemanticType]))), + executable: true, + mutual: Decode, + recursive_argument: fuel +} + +definition{ + name: decTypeChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTypes::SemanticType), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTypes::SemanticType]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JArr part0 => (decTypeChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTypes::SemanticType]))), + executable: true, + mutual: Decode, + recursive_argument: fuel +} + +definition{ + name: decTypeChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTypes::SemanticType), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTypes::SemanticType]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTypes::SemanticType]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticTypes::SemanticType) := (decType budget part0); (match head + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some headValue => (let tail : (Option SemanticTypes::SemanticType) := (decTypeChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTypes::SemanticType]) + | Option.some tailValue => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SItem headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTypes::SemanticType]))), + executable: true, + mutual: Decode, + recursive_argument: fuel +} + +definition{ + name: decParam, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (Bytes * SemanticTypes::SemanticType)), + body: (match fuel + | Nat.zero => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "type") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | Option.some field1 => (ctor Option.some [(Bytes * SemanticTypes::SemanticType)] (field0, field1)))))) else (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]))), + executable: true +} + +definition{ + name: decParamsItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List (Bytes * SemanticTypes::SemanticType))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List (Bytes * SemanticTypes::SemanticType))] (nil (Bytes * SemanticTypes::SemanticType))) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (Bytes * SemanticTypes::SemanticType)) := (decParam budget part0); (match head + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Option.some headValue => (let tail : (Option (List (Bytes * SemanticTypes::SemanticType))) := (decParamsItems budget part1); (match tail + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Option.some tailValue => (ctor Option.some [(List (Bytes * SemanticTypes::SemanticType))] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decParams, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List (Bytes * SemanticTypes::SemanticType))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JArr part0 => (decParamsItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]))), + executable: true +} + +definition{ + name: decTerm, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some tag => (if (prim equal tag (lit "var") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TVar field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "nat") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "value")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TNat field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "integer") : Bool) then (if (closedKeys members (cons (lit "representation") (cons (lit "value") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTypes::SemanticInteger) := (match (lookup members (lit "representation")) + | Option.some found => (decInteger found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticInteger])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "value")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TInteger field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "string") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "value")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TString field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "bytes") : Bool) then (if (closedKeys members (cons (lit "hex") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "hex")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TBytes field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "primitive") : Bool) then (if (closedKeys members (cons (lit "operation") (cons (lit "arguments") (cons (lit "result") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option SemanticTypes::SemanticPrimitive) := (match (lookup members (lit "operation")) + | Option.some found => (decPrimitive found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticPrimitive])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "arguments")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "result")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TPrimitive field0 field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "bool") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option Bool) := (match (lookup members (lit "value")) + | Option.some found => (decBool found) + | Option.none => (ctor Option.none [Bool])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TBool field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "unit") : Bool) then (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TUnit)) else (if (prim equal tag (lit "nil") : Bool) then (if (closedKeys members (cons (lit "element") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "element")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TNil field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "cons") : Bool) then (if (closedKeys members (cons (lit "head") (cons (lit "tail") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "head")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "tail")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TCons field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "record") : Bool) then (if (closedKeys members (cons (lit "type") (cons (lit "type_arguments") (cons (lit "fields") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "type")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "fields")) + | Option.some found => (decAssignChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TRecord (first field0) (second field0) field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "constructor") : Bool) then (if (closedKeys members (cons (lit "constructor") (cons (lit "type_arguments") (cons (lit "arguments") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "constructor")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "arguments")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TConstructor (first field0) (second field0) field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "instance_value") : Bool) then (if (closedKeys members (cons (lit "class") (cons (lit "arguments") (cons (lit "resolved") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "class")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "resolved")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TInstanceValue (first field0) (second field0) field1 (first field2) (second field2))))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "project") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "field") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "field")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TProject field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "call") : Bool) then (if (closedKeys members (cons (lit "function") (cons (lit "type_arguments") (cons (lit "arguments") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "function")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "arguments")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TCall (first field0) (second field0) field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "if") : Bool) then (if (closedKeys members (cons (lit "condition") (cons (lit "then_value") (cons (lit "else_value") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "condition")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "then_value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "else_value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TIf field0 field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "match") : Bool) then (if (closedKeys members (cons (lit "scrutinee") (cons (lit "branches") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "scrutinee")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "branches")) + | Option.some found => (decBranchChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TMatch field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "eq") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TEq field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "le") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TLe field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "lt") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TLt field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "add") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TAdd field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "beq") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TBeq field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "ble") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TBle field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "blt") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TBlt field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "and") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TAnd field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "prop_and") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TPropAnd field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "or") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TOr field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "not") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TNot field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "implies") : Bool) then (if (closedKeys members (cons (lit "premise") (cons (lit "conclusion") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "premise")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "conclusion")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TImplies field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "iff") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TIff field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "forall") : Bool) then (if (closedKeys members (cons (lit "binder") (cons (lit "body") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option (Bytes * SemanticTypes::SemanticType)) := (match (lookup members (lit "binder")) + | Option.some found => (decParam budget found) + | Option.none => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "body")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TForall (first field0) (second field0) field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "let") : Bool) then (if (closedKeys members (cons (lit "binder") (cons (lit "value") (cons (lit "body") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option (Bytes * SemanticTypes::SemanticType)) := (match (lookup members (lit "binder")) + | Option.some found => (decParam budget found) + | Option.none => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "body")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TLet (first field0) (second field0) field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "pair") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "left")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "right")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TPair field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "first") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TFirst field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "second") : Bool) then (if (closedKeys members (cons (lit "value") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TSecond field0)))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "lambda") : Bool) then (if (closedKeys members (cons (lit "parameters") (cons (lit "captures") (cons (lit "body") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "parameters")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "captures")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.none [(List Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "body")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TLambda field0 field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "apply") : Bool) then (if (closedKeys members (cons (lit "function") (cons (lit "arguments") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "function")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "arguments")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TApply field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "function_ref") : Bool) then (if (closedKeys members (cons (lit "function") (cons (lit "type_arguments") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "function")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TFunctionRef (first field0) (second field0) field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "map_literal") : Bool) then (if (closedKeys members (cons (lit "key") (cons (lit "value") (cons (lit "entries") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "key")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "value")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "entries")) + | Option.some found => (decEntryChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TMapLiteral field0 field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "set_literal") : Bool) then (if (closedKeys members (cons (lit "element") (cons (lit "elements") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "element")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "elements")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TSetLiteral field0 field1)))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "graph_literal") : Bool) then (if (closedKeys members (cons (lit "node") (cons (lit "nodes") (cons (lit "edges") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "node")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "nodes")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "edges")) + | Option.some found => (decEdgeChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TGraphLiteral field0 field1 field2)))))))) else (ctor Option.none [SemanticTerms::STerm])) else (if (prim equal tag (lit "checked_apply") : Bool) then (if (closedKeys members (cons (lit "model") (cons (lit "type_arguments") (cons (lit "arguments") (cons (lit "checks") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "model")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "arguments")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field2 => (let decoded3 : (Option (List Bytes)) := (match (lookup members (lit "checks")) + | Option.some found => (decChecks found) + | Option.none => (ctor Option.none [(List Bytes)])); (match decoded3 + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some field3 => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.TCheckedApply (first field0) (second field0) field1 field2 field3)))))))))) else (ctor Option.none [SemanticTerms::STerm])) else (ctor Option.none [SemanticTerms::STerm]))))))))))))))))))))))))))))))))))))))))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decTermChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (decTermChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decTermChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticTerms::STerm) := (decTerm budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some headValue => (let tail : (Option SemanticTerms::STerm) := (decTermChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KItem headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decAssign, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (Bytes * SemanticTerms::STerm)), + body: (match fuel + | Nat.zero => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "field") (cons (lit "value") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "field")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | Option.some field1 => (ctor Option.some [(Bytes * SemanticTerms::STerm)] (field0, field1)))))) else (ctor Option.none [(Bytes * SemanticTerms::STerm)]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(Bytes * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(Bytes * SemanticTerms::STerm)]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decAssignChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (decAssignChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decAssignChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (Bytes * SemanticTerms::STerm)) := (decAssign budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some headValue => (let tail : (Option SemanticTerms::STerm) := (decAssignChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KAssign (first headValue) (second headValue) tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decBranch, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))), + body: (match fuel + | Nat.zero => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "constructor") (cons (lit "binders") (cons (lit "body") (nil Bytes))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "constructor")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "binders")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.none [(List Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "body")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | Option.some field2 => (ctor Option.some [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))] (field0, (field1, field2))))))))) else (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decBranchChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (decBranchChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decBranchChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (((Option Bytes) * Bytes) * ((List Bytes) * SemanticTerms::STerm))) := (decBranch budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some headValue => (let tail : (Option SemanticTerms::STerm) := (decBranchChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KBranch (first (first headValue)) (second (first headValue)) (first (second headValue)) (second (second headValue)) tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decEntry, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (SemanticTerms::STerm * SemanticTerms::STerm)), + body: (match fuel + | Nat.zero => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "key") (cons (lit "value") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "key")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | Option.some field1 => (ctor Option.some [(SemanticTerms::STerm * SemanticTerms::STerm)] (field0, field1)))))) else (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decEntryChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (decEntryChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decEntryChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (SemanticTerms::STerm * SemanticTerms::STerm)) := (decEntry budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some headValue => (let tail : (Option SemanticTerms::STerm) := (decEntryChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KEntry (first headValue) (second headValue) tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decEdge, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (SemanticTerms::STerm * SemanticTerms::STerm)), + body: (match fuel + | Nat.zero => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "source") (cons (lit "target") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "source")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "target")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | Option.some field1 => (ctor Option.some [(SemanticTerms::STerm * SemanticTerms::STerm)] (field0, field1)))))) else (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(SemanticTerms::STerm * SemanticTerms::STerm)]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decEdgeChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (decEdgeChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decEdgeChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::STerm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::STerm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::STerm]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (SemanticTerms::STerm * SemanticTerms::STerm)) := (decEdge budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some headValue => (let tail : (Option SemanticTerms::STerm) := (decEdgeChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::STerm]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::STerm] (ctor SemanticTerms::STerm.KEdge (first headValue) (second headValue) tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::STerm]))), + executable: true, + mutual: Decode2, + recursive_argument: fuel +} + +definition{ + name: decMembersItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List ((Option Bytes) * Bytes))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List ((Option Bytes) * Bytes))] (nil ((Option Bytes) * Bytes))) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option ((Option Bytes) * Bytes)) := (decMember budget part0); (match head + | Option.none => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Option.some headValue => (let tail : (Option (List ((Option Bytes) * Bytes))) := (decMembersItems budget part1); (match tail + | Option.none => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Option.some tailValue => (ctor Option.some [(List ((Option Bytes) * Bytes))] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List ((Option Bytes) * Bytes))]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decMembers, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List ((Option Bytes) * Bytes))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JArr part0 => (decMembersItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List ((Option Bytes) * Bytes))]))), + executable: true +} + +definition{ + name: decReflectedField, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (Bytes * Bytes)), + body: (match fuel + | Nat.zero => (ctor Option.none [(Bytes * Bytes)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(Bytes * Bytes)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(Bytes * Bytes)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(Bytes * Bytes)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(Bytes * Bytes)]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "field") (cons (lit "expected") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "field")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [(Bytes * Bytes)]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "expected")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [(Bytes * Bytes)]) + | Option.some field1 => (ctor Option.some [(Bytes * Bytes)] (field0, field1)))))) else (ctor Option.none [(Bytes * Bytes)]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(Bytes * Bytes)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(Bytes * Bytes)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(Bytes * Bytes)]))), + executable: true +} + +definition{ + name: decReflectedItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List (Bytes * Bytes))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List (Bytes * Bytes))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List (Bytes * Bytes))] (nil (Bytes * Bytes))) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (Bytes * Bytes)) := (decReflectedField budget part0); (match head + | Option.none => (ctor Option.none [(List (Bytes * Bytes))]) + | Option.some headValue => (let tail : (Option (List (Bytes * Bytes))) := (decReflectedItems budget part1); (match tail + | Option.none => (ctor Option.none [(List (Bytes * Bytes))]) + | Option.some tailValue => (ctor Option.some [(List (Bytes * Bytes))] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List (Bytes * Bytes))]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decReflected, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List (Bytes * Bytes))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List (Bytes * Bytes))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JArr part0 => (decReflectedItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List (Bytes * Bytes))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List (Bytes * Bytes))]))), + executable: true +} + +definition{ + name: decReflection, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::Reflection), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::Reflection]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::Reflection]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::Reflection]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::Reflection]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::Reflection]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some tag => (if (prim equal tag (lit "list") : Bool) then (if (closedKeys members (cons (lit "parameter") (cons (lit "values") (cons (lit "boolean_definition") (cons (lit "proposition_definition") (cons (lit "comparison") (cons (lit "kind") (nil Bytes)))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "parameter")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "values")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "boolean_definition")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field2 => (let decoded3 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "proposition_definition")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded3 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field3 => (let decoded4 : (Option Bytes) := (match (lookup members (lit "comparison")) + | Option.some found => (decComparison found) + | Option.none => (ctor Option.none [Bytes])); (match decoded4 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field4 => (ctor Option.some [SemanticTerms::Reflection] (ctor SemanticTerms::Reflection.RList field0 field1 (first field2) (second field2) (first field3) (second field3) field4)))))))))))) else (ctor Option.none [SemanticTerms::Reflection])) else (if (prim equal tag (lit "record") : Bool) then (if (closedKeys members (cons (lit "record") (cons (lit "boolean_definition") (cons (lit "proposition_definition") (cons (lit "fields") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "record")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "boolean_definition")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "proposition_definition")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field2 => (let decoded3 : (Option (List (Bytes * Bytes))) := (match (lookup members (lit "fields")) + | Option.some found => (decReflected budget found) + | Option.none => (ctor Option.none [(List (Bytes * Bytes))])); (match decoded3 + | Option.none => (ctor Option.none [SemanticTerms::Reflection]) + | Option.some field3 => (ctor Option.some [SemanticTerms::Reflection] (ctor SemanticTerms::Reflection.RRecord field0 (first field1) (second field1) (first field2) (second field2) field3)))))))))) else (ctor Option.none [SemanticTerms::Reflection])) else (ctor Option.none [SemanticTerms::Reflection]))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::Reflection]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::Reflection]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::Reflection]))), + executable: true +} + +definition{ + name: decProof, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::SProof), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::SProof]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some tag => (if (prim equal tag (lit "reflexivity") : Bool) then (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PReflexivity)) else (if (prim equal tag (lit "decide") : Bool) then (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PDecide)) else (if (prim equal tag (lit "linear_arithmetic") : Bool) then (if (closedKeys members (cons (lit "definitions") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option (List ((Option Bytes) * Bytes))) := (match (lookup members (lit "definitions")) + | Option.some found => (decMembers budget found) + | Option.none => (ctor Option.some [(List ((Option Bytes) * Bytes))] (nil ((Option Bytes) * Bytes)))); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PLinearArithmetic field0)))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "simplify") : Bool) then (if (closedKeys members (cons (lit "definitions") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option (List ((Option Bytes) * Bytes))) := (match (lookup members (lit "definitions")) + | Option.some found => (decMembers budget found) + | Option.none => (ctor Option.none [(List ((Option Bytes) * Bytes))])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PSimplify field0)))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "constructor") : Bool) then (if (closedKeys members (cons (lit "branches") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::SProof) := (match (lookup members (lit "branches")) + | Option.some found => (decProofChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PConstructor field0)))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "cases") : Bool) then (if (closedKeys members (cons (lit "scrutinee") (cons (lit "branches") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "scrutinee")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::SProof) := (match (lookup members (lit "branches")) + | Option.some found => (decPBranchChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field1 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PCases field0 field1)))))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "term_cases") : Bool) then (if (closedKeys members (cons (lit "scrutinee") (cons (lit "definitions") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "scrutinee")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (let decoded1 : (Option (List ((Option Bytes) * Bytes))) := (match (lookup members (lit "definitions")) + | Option.some found => (decMembers budget found) + | Option.none => (ctor Option.none [(List ((Option Bytes) * Bytes))])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field1 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PTermCases field0 field1)))))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "induction") : Bool) then (if (closedKeys members (cons (lit "scrutinee") (cons (lit "generalizing") (cons (lit "branches") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "scrutinee")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "generalizing")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::SProof) := (match (lookup members (lit "branches")) + | Option.some found => (decPBranchChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field2 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PInduction field0 field1 field2)))))))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "nested_induction") : Bool) then (if (closedKeys members (cons (lit "scrutinee") (cons (lit "branches") (cons (lit "members") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "scrutinee")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::SProof) := (match (lookup members (lit "branches")) + | Option.some found => (decPBranchChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::SProof) := (match (lookup members (lit "members")) + | Option.some found => (decPMemberChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field2 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PNestedInduction field0 field1 field2)))))))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "congruence") : Bool) then (if (prim equal tag (lit "region_check") : Bool) then (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PRegionCheck)) else (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PCongruence))) else (if (prim equal tag (lit "boolean_reflection") : Bool) then (if (closedKeys members (cons (lit "reflection") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::Reflection) := (match (lookup members (lit "reflection")) + | Option.some found => (decReflection budget found) + | Option.none => (ctor Option.none [SemanticTerms::Reflection])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PBooleanReflection field0)))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "law") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_arguments") (cons (lit "arguments") (cons (lit "premises") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "arguments")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field2 => (let decoded3 : (Option (List ((Option Bytes) * Bytes))) := (match (lookup members (lit "premises")) + | Option.some found => (decMembers budget found) + | Option.none => (ctor Option.some [(List ((Option Bytes) * Bytes))] (nil ((Option Bytes) * Bytes)))); (match decoded3 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field3 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PLaw field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticTerms::SProof])) else (if (prim equal tag (lit "apply") : Bool) then (if (closedKeys members (cons (lit "theorem") (cons (lit "type_arguments") (cons (lit "arguments") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.some [SemanticTypes::SemanticType] (ctor SemanticTypes::SemanticType.SNil))); (match decoded1 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "arguments")) + | Option.some found => (decTermChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some field2 => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.PApply (first field0) (second field0) field1 field2)))))))) else (ctor Option.none [SemanticTerms::SProof])) else (ctor Option.none [SemanticTerms::SProof])))))))))))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::SProof]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decProofChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::SProof), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::SProof]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JArr part0 => (decProofChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::SProof]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decProofChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::SProof), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::SProof]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.QEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticTerms::SProof) := (decProof budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some headValue => (let tail : (Option SemanticTerms::SProof) := (decProofChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.QItem headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::SProof]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decPBranch, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (Bytes * ((List Bytes) * SemanticTerms::SProof))), + body: (match fuel + | Nat.zero => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "constructor") (cons (lit "binders") (cons (lit "proof") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "constructor")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "binders")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.none [(List Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::SProof) := (match (lookup members (lit "proof")) + | Option.some found => (decProof budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded2 + | Option.none => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | Option.some field2 => (ctor Option.some [(Bytes * ((List Bytes) * SemanticTerms::SProof))] (field0, (field1, field2))))))))) else (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(Bytes * ((List Bytes) * SemanticTerms::SProof))]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decPBranchChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::SProof), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::SProof]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JArr part0 => (decPBranchChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::SProof]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decPBranchChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::SProof), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::SProof]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.QEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (Bytes * ((List Bytes) * SemanticTerms::SProof))) := (decPBranch budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some headValue => (let tail : (Option SemanticTerms::SProof) := (decPBranchChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.QBranch (first headValue) (first (second headValue)) (second (second headValue)) tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::SProof]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decPMember, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))), + body: (match fuel + | Nat.zero => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "type") (cons (lit "binder") (cons (lit "statement") (cons (lit "branches") (nil Bytes)))))) then (let decoded0 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded0 + | Option.none => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "binder")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "statement")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | Option.some field2 => (let decoded3 : (Option SemanticTerms::SProof) := (match (lookup members (lit "branches")) + | Option.some found => (decPBranchChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded3 + | Option.none => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | Option.some field3 => (ctor Option.some [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))] (field0, (field1, (field2, field3)))))))))))) else (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decPMemberChain, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::SProof), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::SProof]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JArr part0 => (decPMemberChainItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::SProof]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decPMemberChainItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticTerms::SProof), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticTerms::SProof]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [SemanticTerms::SProof]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.QEnd)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (SemanticTypes::SemanticType * (Bytes * (SemanticTerms::STerm * SemanticTerms::SProof)))) := (decPMember budget part0); (match head + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some headValue => (let tail : (Option SemanticTerms::SProof) := (decPMemberChainItems budget part1); (match tail + | Option.none => (ctor Option.none [SemanticTerms::SProof]) + | Option.some tailValue => (ctor Option.some [SemanticTerms::SProof] (ctor SemanticTerms::SProof.QMember (first headValue) (first (second headValue)) (first (second (second headValue))) (second (second (second headValue))) tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticTerms::SProof]))), + executable: true, + mutual: Decode3, + recursive_argument: fuel +} + +definition{ + name: decConstructor, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (Bytes * SemanticTypes::SemanticType)), + body: (match fuel + | Nat.zero => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "fields") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "fields")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | Option.some field1 => (ctor Option.some [(Bytes * SemanticTypes::SemanticType)] (field0, field1)))))) else (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(Bytes * SemanticTypes::SemanticType)]))), + executable: true +} + +definition{ + name: decConstructorsItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List (Bytes * SemanticTypes::SemanticType))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List (Bytes * SemanticTypes::SemanticType))] (nil (Bytes * SemanticTypes::SemanticType))) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option (Bytes * SemanticTypes::SemanticType)) := (decConstructor budget part0); (match head + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Option.some headValue => (let tail : (Option (List (Bytes * SemanticTypes::SemanticType))) := (decConstructorsItems budget part1); (match tail + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Option.some tailValue => (ctor Option.some [(List (Bytes * SemanticTypes::SemanticType))] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decConstructors, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List (Bytes * SemanticTypes::SemanticType))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JArr part0 => (decConstructorsItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))]))), + executable: true +} + +definition{ + name: decTermination, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))), + body: (match fuel + | Nat.zero => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "measure") (cons (lit "evidence") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "measure")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | Option.some field0 => (let decoded1 : (Option (List ((Option Bytes) * Bytes))) := (match (lookup members (lit "evidence")) + | Option.some found => (decMembers budget found) + | Option.none => (ctor Option.none [(List ((Option Bytes) * Bytes))])); (match decoded1 + | Option.none => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | Option.some field1 => (ctor Option.some [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))] (field0, field1)))))) else (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]))), + executable: true +} + +definition{ + name: decOrdinary, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticDecls::SDecl), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticDecls::SDecl]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticDecls::SDecl]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticDecls::SDecl]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticDecls::SDecl]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticDecls::SDecl]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some tag => (if (prim equal tag (lit "structure") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "parameters") (cons (lit "fields") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.none [(List Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field1 => (let decoded2 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "parameters")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded2 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field2 => (let decoded3 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "fields")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded3 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field3 => (ctor Option.some [SemanticDecls::SDecl] (ctor SemanticDecls::SDecl.DStructure field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticDecls::SDecl])) else (if (prim equal tag (lit "class") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "parameters") (cons (lit "fields") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.none [(List Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field1 => (let decoded2 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "parameters")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded2 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field2 => (let decoded3 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "fields")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded3 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field3 => (ctor Option.some [SemanticDecls::SDecl] (ctor SemanticDecls::SDecl.DClass field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticDecls::SDecl])) else (if (prim equal tag (lit "instance") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "class") (cons (lit "arguments") (cons (lit "priority") (cons (lit "fields") (cons (lit "kind") (nil Bytes)))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "class")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field1 => (let decoded2 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "arguments")) + | Option.some found => (decTypeChain budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded2 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field2 => (let decoded3 : (Option Nat) := (match (lookup members (lit "priority")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded3 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field3 => (let decoded4 : (Option SemanticTerms::STerm) := (match (lookup members (lit "fields")) + | Option.some found => (decAssignChain budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded4 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field4 => (ctor Option.some [SemanticDecls::SDecl] (ctor SemanticDecls::SDecl.DInstance field0 (first field1) (second field1) field2 field3 field4)))))))))))) else (ctor Option.none [SemanticDecls::SDecl])) else (if (prim equal tag (lit "inductive") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "parameters") (cons (lit "constructors") (cons (lit "mutual") (cons (lit "kind") (nil Bytes)))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.none [(List Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field1 => (let decoded2 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "parameters")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded2 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field2 => (let decoded3 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "constructors")) + | Option.some found => (decConstructors budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded3 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field3 => (let decoded4 : (Option (Option Bytes)) := (match (lookup members (lit "mutual")) + | Option.some found => (match (decStr found) + | Option.some present => (ctor Option.some [(Option Bytes)] (ctor Option.some [Bytes] present)) + | Option.none => (ctor Option.none [(Option Bytes)])) + | Option.none => (ctor Option.some [(Option Bytes)] (ctor Option.none [Bytes]))); (match decoded4 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field4 => (ctor Option.some [SemanticDecls::SDecl] (ctor SemanticDecls::SDecl.DInductive field0 field1 field2 field3 field4)))))))))))) else (ctor Option.none [SemanticDecls::SDecl])) else (if (prim equal tag (lit "definition") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "parameters") (cons (lit "result") (cons (lit "recursive_argument") (cons (lit "body") (cons (lit "axioms") (cons (lit "executable") (cons (lit "mutual") (cons (lit "termination") (cons (lit "production") (cons (lit "kind") (nil Bytes)))))))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field1 => (let decoded2 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "parameters")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded2 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field2 => (let decoded3 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "result")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded3 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field3 => (let decoded4 : (Option (Option Bytes)) := (match (lookup members (lit "recursive_argument")) + | Option.some found => (match (decStr found) + | Option.some present => (ctor Option.some [(Option Bytes)] (ctor Option.some [Bytes] present)) + | Option.none => (ctor Option.none [(Option Bytes)])) + | Option.none => (ctor Option.some [(Option Bytes)] (ctor Option.none [Bytes]))); (match decoded4 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field4 => (let decoded5 : (Option SemanticTerms::STerm) := (match (lookup members (lit "body")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded5 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field5 => (let decoded6 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded6 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field6 => (let decoded7 : (Option Bool) := (match (lookup members (lit "executable")) + | Option.some found => (decBool found) + | Option.none => (ctor Option.some [Bool] false)); (match decoded7 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field7 => (let decoded8 : (Option (Option Bytes)) := (match (lookup members (lit "mutual")) + | Option.some found => (match (decStr found) + | Option.some present => (ctor Option.some [(Option Bytes)] (ctor Option.some [Bytes] present)) + | Option.none => (ctor Option.none [(Option Bytes)])) + | Option.none => (ctor Option.some [(Option Bytes)] (ctor Option.none [Bytes]))); (match decoded8 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field8 => (let decoded9 : (Option (Option (SemanticTerms::STerm * (List ((Option Bytes) * Bytes))))) := (match (lookup members (lit "termination")) + | Option.some found => (match (decTermination budget found) + | Option.some present => (ctor Option.some [(Option (SemanticTerms::STerm * (List ((Option Bytes) * Bytes))))] (ctor Option.some [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))] present)) + | Option.none => (ctor Option.none [(Option (SemanticTerms::STerm * (List ((Option Bytes) * Bytes))))])) + | Option.none => (ctor Option.some [(Option (SemanticTerms::STerm * (List ((Option Bytes) * Bytes))))] (ctor Option.none [(SemanticTerms::STerm * (List ((Option Bytes) * Bytes)))]))); (match decoded9 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field9 => (let decoded10 : (Option (Option ((List Bytes) * (List Bytes)))) := (match (lookup members (lit "production")) + | Option.some found => (match (decProduction found) + | Option.some present => (ctor Option.some [(Option ((List Bytes) * (List Bytes)))] (ctor Option.some [((List Bytes) * (List Bytes))] present)) + | Option.none => (ctor Option.none [(Option ((List Bytes) * (List Bytes)))])) + | Option.none => (ctor Option.some [(Option ((List Bytes) * (List Bytes)))] (ctor Option.none [((List Bytes) * (List Bytes))]))); (match decoded10 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field10 => (ctor Option.some [SemanticDecls::SDecl] (ctor SemanticDecls::SDecl.DDefinition field0 field1 field2 field3 field4 field5 field6 field7 field8 field9 field10)))))))))))))))))))))))) else (ctor Option.none [SemanticDecls::SDecl])) else (if (prim equal tag (lit "theorem") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "parameters") (cons (lit "statement") (cons (lit "proof") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field1 => (let decoded2 : (Option (List (Bytes * SemanticTypes::SemanticType))) := (match (lookup members (lit "parameters")) + | Option.some found => (decParams budget found) + | Option.none => (ctor Option.none [(List (Bytes * SemanticTypes::SemanticType))])); (match decoded2 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field2 => (let decoded3 : (Option SemanticTerms::STerm) := (match (lookup members (lit "statement")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded3 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field3 => (let decoded4 : (Option SemanticTerms::SProof) := (match (lookup members (lit "proof")) + | Option.some found => (decProof budget found) + | Option.none => (ctor Option.none [SemanticTerms::SProof])); (match decoded4 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field4 => (let decoded5 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded5 + | Option.none => (ctor Option.none [SemanticDecls::SDecl]) + | Option.some field5 => (ctor Option.some [SemanticDecls::SDecl] (ctor SemanticDecls::SDecl.DTheorem field0 field1 field2 field3 field4 field5)))))))))))))) else (ctor Option.none [SemanticDecls::SDecl])) else (ctor Option.none [SemanticDecls::SDecl]))))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticDecls::SDecl]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticDecls::SDecl]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticDecls::SDecl]))), + executable: true +} + +definition{ + name: decListNatItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List Nat)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List Nat)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List Nat)] (nil Nat)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option Nat) := (decNatFuel budget part0); (match head + | Option.none => (ctor Option.none [(List Nat)]) + | Option.some headValue => (let tail : (Option (List Nat)) := (decListNatItems budget part1); (match tail + | Option.none => (ctor Option.none [(List Nat)]) + | Option.some tailValue => (ctor Option.some [(List Nat)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List Nat)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListNat, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List Nat)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List Nat)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JArr part0 => (decListNatItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List Nat)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List Nat)]))), + executable: true +} + +definition{ + name: decArtifactSchema, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ArtifactSchema), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::ArtifactSchema]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::ArtifactSchema]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::ArtifactSchema]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::ArtifactSchema]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::ArtifactSchema]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::ArtifactSchema]) + | Option.some tag => (if (prim equal tag (lit "bytes") : Bool) then (ctor Option.some [SemanticModels::ArtifactSchema] (ctor SemanticModels::ArtifactSchema.ArtifactSchemaBytes)) else (if (prim equal tag (lit "int_tensor") : Bool) then (if (closedKeys members (cons (lit "element") (cons (lit "shape") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticModels::TensorElement) := (match (lookup members (lit "element")) + | Option.some found => (decTensorElement budget found) + | Option.none => (ctor Option.none [SemanticModels::TensorElement])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ArtifactSchema]) + | Option.some field0 => (let decoded1 : (Option (List Nat)) := (match (lookup members (lit "shape")) + | Option.some found => (decListNat budget found) + | Option.none => (ctor Option.none [(List Nat)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ArtifactSchema]) + | Option.some field1 => (ctor Option.some [SemanticModels::ArtifactSchema] (ctor SemanticModels::ArtifactSchema.ArtifactSchemaIntTensor field0 field1)))))) else (ctor Option.none [SemanticModels::ArtifactSchema])) else (if (prim equal tag (lit "utf8_lines") : Bool) then (ctor Option.some [SemanticModels::ArtifactSchema] (ctor SemanticModels::ArtifactSchema.ArtifactSchemaUtf8Lines)) else (ctor Option.none [SemanticModels::ArtifactSchema])))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::ArtifactSchema]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::ArtifactSchema]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::ArtifactSchema]))), + executable: true +} + +definition{ + name: decModelBinder, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ModelBinder), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::ModelBinder]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::ModelBinder]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::ModelBinder]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::ModelBinder]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::ModelBinder]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "type") (nil Bytes)))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ModelBinder]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ModelBinder]) + | Option.some field1 => (ctor Option.some [SemanticModels::ModelBinder] (ctor SemanticModels::ModelBinder.ModelBinderOf field0 field1)))))) else (ctor Option.none [SemanticModels::ModelBinder]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::ModelBinder]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::ModelBinder]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::ModelBinder]))), + executable: true +} + +definition{ + name: decContractState, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ContractState), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::ContractState]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::ContractState]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::ContractState]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::ContractState]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::ContractState]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "next") (cons (lit "type") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ContractState]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "next")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ContractState]) + | Option.some field1 => (let decoded2 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::ContractState]) + | Option.some field2 => (ctor Option.some [SemanticModels::ContractState] (ctor SemanticModels::ContractState.ContractStateOf field0 field1 field2)))))))) else (ctor Option.none [SemanticModels::ContractState]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::ContractState]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::ContractState]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::ContractState]))), + executable: true +} + +definition{ + name: decContractValidator, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ContractValidator), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::ContractValidator]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::ContractValidator]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::ContractValidator]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::ContractValidator]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::ContractValidator]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "predicate") (cons (lit "validator") (cons (lit "sound") (cons (lit "complete") (nil Bytes)))))) then (let decoded0 : (Option SemanticModels::ContractPredicate) := (match (lookup members (lit "predicate")) + | Option.some found => (decContractPredicate budget found) + | Option.none => (ctor Option.none [SemanticModels::ContractPredicate])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ContractValidator]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "validator")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ContractValidator]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "sound")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::ContractValidator]) + | Option.some field2 => (let decoded3 : (Option (Option ((Option Bytes) * Bytes))) := (match (lookup members (lit "complete")) + | Option.some found => (match (decMember budget found) + | Option.some present => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.some [((Option Bytes) * Bytes)] present)) + | Option.none => (ctor Option.none [(Option ((Option Bytes) * Bytes))])) + | Option.none => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.none [((Option Bytes) * Bytes)]))); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::ContractValidator]) + | Option.some field3 => (ctor Option.some [SemanticModels::ContractValidator] (ctor SemanticModels::ContractValidator.ContractValidatorOf field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticModels::ContractValidator]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::ContractValidator]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::ContractValidator]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::ContractValidator]))), + executable: true +} + +definition{ + name: decListTypeItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticTypes::SemanticType)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticTypes::SemanticType)] (nil SemanticTypes::SemanticType)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticTypes::SemanticType) := (decType budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | Option.some headValue => (let tail : (Option (List SemanticTypes::SemanticType)) := (decListTypeItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | Option.some tailValue => (ctor Option.some [(List SemanticTypes::SemanticType)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticTypes::SemanticType)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListType, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticTypes::SemanticType)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JArr part0 => (decListTypeItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticTypes::SemanticType)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticTypes::SemanticType)]))), + executable: true +} + +definition{ + name: decModelUse, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ModelUse), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::ModelUse]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::ModelUse]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::ModelUse]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::ModelUse]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::ModelUse]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "member") (cons (lit "type_arguments") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "member")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ModelUse]) + | Option.some field0 => (let decoded1 : (Option (List SemanticTypes::SemanticType)) := (match (lookup members (lit "type_arguments")) + | Option.some found => (decListType budget found) + | Option.none => (ctor Option.some [(List SemanticTypes::SemanticType)] (nil SemanticTypes::SemanticType))); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ModelUse]) + | Option.some field1 => (ctor Option.some [SemanticModels::ModelUse] (ctor SemanticModels::ModelUse.ModelUseOf field0 field1)))))) else (ctor Option.none [SemanticModels::ModelUse]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::ModelUse]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::ModelUse]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::ModelUse]))), + executable: true +} + +definition{ + name: decRealizationState, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::RealizationState), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::RealizationState]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::RealizationState]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::RealizationState]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::RealizationState]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::RealizationState]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "type") (cons (lit "initial") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::RealizationState]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::RealizationState]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "initial")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::RealizationState]) + | Option.some field2 => (ctor Option.some [SemanticModels::RealizationState] (ctor SemanticModels::RealizationState.RealizationStateOf field0 field1 field2)))))))) else (ctor Option.none [SemanticModels::RealizationState]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::RealizationState]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::RealizationState]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::RealizationState]))), + executable: true +} + +definition{ + name: decRealizationRule, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::RealizationRule), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::RealizationRule]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::RealizationRule]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::RealizationRule]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::RealizationRule]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::RealizationRule]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "guard") (cons (lit "action") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::RealizationRule]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "guard")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::RealizationRule]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "action")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::RealizationRule]) + | Option.some field2 => (ctor Option.some [SemanticModels::RealizationRule] (ctor SemanticModels::RealizationRule.RealizationRuleOf field0 field1 field2)))))))) else (ctor Option.none [SemanticModels::RealizationRule]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::RealizationRule]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::RealizationRule]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::RealizationRule]))), + executable: true +} + +definition{ + name: decNeuralLayer, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::NeuralLayer), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::NeuralLayer]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::NeuralLayer]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::NeuralLayer]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::NeuralLayer]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::NeuralLayer]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some tag => (if (prim equal tag (lit "dense") : Bool) then (if (closedKeys members (cons (lit "inputs") (cons (lit "outputs") (cons (lit "weights") (cons (lit "bias") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option Nat) := (match (lookup members (lit "inputs")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some field0 => (let decoded1 : (Option Nat) := (match (lookup members (lit "outputs")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "weights")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some field2 => (let decoded3 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "bias")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some field3 => (ctor Option.some [SemanticModels::NeuralLayer] (ctor SemanticModels::NeuralLayer.NeuralLayerDense field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticModels::NeuralLayer])) else (if (prim equal tag (lit "relu") : Bool) then (ctor Option.some [SemanticModels::NeuralLayer] (ctor SemanticModels::NeuralLayer.NeuralLayerRelu)) else (if (prim equal tag (lit "requantize") : Bool) then (if (closedKeys members (cons (lit "shift") (cons (lit "minimum") (cons (lit "maximum") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option Nat) := (match (lookup members (lit "shift")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some field0 => (let decoded1 : (Option Bytes) := (match (lookup members (lit "minimum")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some field1 => (let decoded2 : (Option Bytes) := (match (lookup members (lit "maximum")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::NeuralLayer]) + | Option.some field2 => (ctor Option.some [SemanticModels::NeuralLayer] (ctor SemanticModels::NeuralLayer.NeuralLayerRequantize field0 field1 field2)))))))) else (ctor Option.none [SemanticModels::NeuralLayer])) else (ctor Option.none [SemanticModels::NeuralLayer])))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::NeuralLayer]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::NeuralLayer]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::NeuralLayer]))), + executable: true +} + +definition{ + name: decListTermItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticTerms::STerm)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticTerms::STerm)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticTerms::STerm)] (nil SemanticTerms::STerm)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticTerms::STerm) := (decTerm budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticTerms::STerm)]) + | Option.some headValue => (let tail : (Option (List SemanticTerms::STerm)) := (decListTermItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticTerms::STerm)]) + | Option.some tailValue => (ctor Option.some [(List SemanticTerms::STerm)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticTerms::STerm)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListTerm, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticTerms::STerm)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticTerms::STerm)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JArr part0 => (decListTermItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticTerms::STerm)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticTerms::STerm)]))), + executable: true +} + +definition{ + name: decNeuralDecoder, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::NeuralDecoder), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::NeuralDecoder]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::NeuralDecoder]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::NeuralDecoder]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::NeuralDecoder]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::NeuralDecoder]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::NeuralDecoder]) + | Option.some tag => (if (prim equal tag (lit "argmax") : Bool) then (if (closedKeys members (cons (lit "labels") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option (List SemanticTerms::STerm)) := (match (lookup members (lit "labels")) + | Option.some found => (decListTerm budget found) + | Option.none => (ctor Option.none [(List SemanticTerms::STerm)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::NeuralDecoder]) + | Option.some field0 => (ctor Option.some [SemanticModels::NeuralDecoder] (ctor SemanticModels::NeuralDecoder.NeuralDecoderArgmax field0)))) else (ctor Option.none [SemanticModels::NeuralDecoder])) else (if (prim equal tag (lit "function") : Bool) then (if (closedKeys members (cons (lit "binder") (cons (lit "body") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "binder")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::NeuralDecoder]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "body")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::NeuralDecoder]) + | Option.some field1 => (ctor Option.some [SemanticModels::NeuralDecoder] (ctor SemanticModels::NeuralDecoder.NeuralDecoderFunction field0 field1)))))) else (ctor Option.none [SemanticModels::NeuralDecoder])) else (ctor Option.none [SemanticModels::NeuralDecoder]))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::NeuralDecoder]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::NeuralDecoder]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::NeuralDecoder]))), + executable: true +} + +definition{ + name: decCompositeJunction, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::CompositeJunction), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::CompositeJunction]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::CompositeJunction]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::CompositeJunction]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::CompositeJunction]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::CompositeJunction]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::CompositeJunction]) + | Option.some tag => (if (prim equal tag (lit "unconditional") : Bool) then (ctor Option.some [SemanticModels::CompositeJunction] (ctor SemanticModels::CompositeJunction.CompositeJunctionUnconditional)) else (if (prim equal tag (lit "proved") : Bool) then (if (closedKeys members (cons (lit "evidence") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "evidence")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::CompositeJunction]) + | Option.some field0 => (ctor Option.some [SemanticModels::CompositeJunction] (ctor SemanticModels::CompositeJunction.CompositeJunctionProved field0)))) else (ctor Option.none [SemanticModels::CompositeJunction])) else (if (prim equal tag (lit "checked") : Bool) then (ctor Option.some [SemanticModels::CompositeJunction] (ctor SemanticModels::CompositeJunction.CompositeJunctionChecked)) else (ctor Option.none [SemanticModels::CompositeJunction])))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::CompositeJunction]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::CompositeJunction]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::CompositeJunction]))), + executable: true +} + +definition{ + name: decListCompositeJunctionItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::CompositeJunction)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticModels::CompositeJunction)] (nil SemanticModels::CompositeJunction)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticModels::CompositeJunction) := (decCompositeJunction budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | Option.some headValue => (let tail : (Option (List SemanticModels::CompositeJunction)) := (decListCompositeJunctionItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | Option.some tailValue => (ctor Option.some [(List SemanticModels::CompositeJunction)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::CompositeJunction)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListCompositeJunction, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::CompositeJunction)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JArr part0 => (decListCompositeJunctionItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticModels::CompositeJunction)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::CompositeJunction)]))), + executable: true +} + +definition{ + name: decListModelUseItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::ModelUse)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::ModelUse)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticModels::ModelUse)] (nil SemanticModels::ModelUse)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticModels::ModelUse) := (decModelUse budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticModels::ModelUse)]) + | Option.some headValue => (let tail : (Option (List SemanticModels::ModelUse)) := (decListModelUseItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticModels::ModelUse)]) + | Option.some tailValue => (ctor Option.some [(List SemanticModels::ModelUse)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::ModelUse)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListModelUse, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::ModelUse)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::ModelUse)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JArr part0 => (decListModelUseItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticModels::ModelUse)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::ModelUse)]))), + executable: true +} + +definition{ + name: decCompositeForm, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::CompositeForm), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::CompositeForm]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::CompositeForm]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::CompositeForm]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::CompositeForm]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::CompositeForm]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some tag => (if (prim equal tag (lit "sequence") : Bool) then (if (closedKeys members (cons (lit "stages") (cons (lit "junctions") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option (List SemanticModels::ModelUse)) := (match (lookup members (lit "stages")) + | Option.some found => (decListModelUse budget found) + | Option.none => (ctor Option.none [(List SemanticModels::ModelUse)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field0 => (let decoded1 : (Option (List SemanticModels::CompositeJunction)) := (match (lookup members (lit "junctions")) + | Option.some found => (decListCompositeJunction budget found) + | Option.none => (ctor Option.none [(List SemanticModels::CompositeJunction)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field1 => (ctor Option.some [SemanticModels::CompositeForm] (ctor SemanticModels::CompositeForm.CompositeFormSequence field0 field1)))))) else (ctor Option.none [SemanticModels::CompositeForm])) else (if (prim equal tag (lit "fanout") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "left")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field0 => (let decoded1 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "right")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field1 => (ctor Option.some [SemanticModels::CompositeForm] (ctor SemanticModels::CompositeForm.CompositeFormFanout field0 field1)))))) else (ctor Option.none [SemanticModels::CompositeForm])) else (if (prim equal tag (lit "product") : Bool) then (if (closedKeys members (cons (lit "left") (cons (lit "right") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "left")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field0 => (let decoded1 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "right")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field1 => (ctor Option.some [SemanticModels::CompositeForm] (ctor SemanticModels::CompositeForm.CompositeFormProduct field0 field1)))))) else (ctor Option.none [SemanticModels::CompositeForm])) else (if (prim equal tag (lit "branch") : Bool) then (if (closedKeys members (cons (lit "guard") (cons (lit "then") (cons (lit "else") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "guard")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field0 => (let decoded1 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "then")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "else")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field2 => (ctor Option.some [SemanticModels::CompositeForm] (ctor SemanticModels::CompositeForm.CompositeFormBranch field0 field1 field2)))))))) else (ctor Option.none [SemanticModels::CompositeForm])) else (if (prim equal tag (lit "scan") : Bool) then (if (closedKeys members (cons (lit "stage") (cons (lit "junction") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "stage")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field0 => (let decoded1 : (Option SemanticModels::CompositeJunction) := (match (lookup members (lit "junction")) + | Option.some found => (decCompositeJunction budget found) + | Option.none => (ctor Option.none [SemanticModels::CompositeJunction])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::CompositeForm]) + | Option.some field1 => (ctor Option.some [SemanticModels::CompositeForm] (ctor SemanticModels::CompositeForm.CompositeFormScan field0 field1)))))) else (ctor Option.none [SemanticModels::CompositeForm])) else (ctor Option.none [SemanticModels::CompositeForm])))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::CompositeForm]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::CompositeForm]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::CompositeForm]))), + executable: true +} + +definition{ + name: decListNeuralLayerItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::NeuralLayer)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticModels::NeuralLayer)] (nil SemanticModels::NeuralLayer)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticModels::NeuralLayer) := (decNeuralLayer budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | Option.some headValue => (let tail : (Option (List SemanticModels::NeuralLayer)) := (decListNeuralLayerItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | Option.some tailValue => (ctor Option.some [(List SemanticModels::NeuralLayer)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::NeuralLayer)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListNeuralLayer, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::NeuralLayer)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JArr part0 => (decListNeuralLayerItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticModels::NeuralLayer)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::NeuralLayer)]))), + executable: true +} + +definition{ + name: decListRealizationRuleItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::RealizationRule)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticModels::RealizationRule)] (nil SemanticModels::RealizationRule)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticModels::RealizationRule) := (decRealizationRule budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | Option.some headValue => (let tail : (Option (List SemanticModels::RealizationRule)) := (decListRealizationRuleItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | Option.some tailValue => (ctor Option.some [(List SemanticModels::RealizationRule)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::RealizationRule)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListRealizationRule, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::RealizationRule)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JArr part0 => (decListRealizationRuleItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticModels::RealizationRule)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::RealizationRule)]))), + executable: true +} + +definition{ + name: decRealizationDescriptor, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::RealizationDescriptor), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some tag => (if (prim equal tag (lit "deterministic") : Bool) then (if (closedKeys members (cons (lit "body") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "body")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field0 => (ctor Option.some [SemanticModels::RealizationDescriptor] (ctor SemanticModels::RealizationDescriptor.RealizationDescriptorDeterministic field0)))) else (ctor Option.none [SemanticModels::RealizationDescriptor])) else (if (prim equal tag (lit "rule") : Bool) then (if (closedKeys members (cons (lit "rules") (cons (lit "default") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option (List SemanticModels::RealizationRule)) := (match (lookup members (lit "rules")) + | Option.some found => (decListRealizationRule budget found) + | Option.none => (ctor Option.none [(List SemanticModels::RealizationRule)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "default")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field1 => (ctor Option.some [SemanticModels::RealizationDescriptor] (ctor SemanticModels::RealizationDescriptor.RealizationDescriptorRule field0 field1)))))) else (ctor Option.none [SemanticModels::RealizationDescriptor])) else (if (prim equal tag (lit "statistical") : Bool) then (if (closedKeys members (cons (lit "scheme") (cons (lit "features") (cons (lit "width") (cons (lit "width_evidence") (cons (lit "weights") (cons (lit "bias") (cons (lit "labels") (cons (lit "kind") (nil Bytes)))))))))) then (let decoded0 : (Option SemanticModels::StatisticalScheme) := (match (lookup members (lit "scheme")) + | Option.some found => (decStatisticalScheme budget found) + | Option.none => (ctor Option.none [SemanticModels::StatisticalScheme])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "features")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field1 => (let decoded2 : (Option Nat) := (match (lookup members (lit "width")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field2 => (let decoded3 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "width_evidence")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field3 => (let decoded4 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "weights")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field4 => (let decoded5 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "bias")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field5 => (let decoded6 : (Option (List SemanticTerms::STerm)) := (match (lookup members (lit "labels")) + | Option.some found => (decListTerm budget found) + | Option.none => (ctor Option.none [(List SemanticTerms::STerm)])); (match decoded6 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field6 => (ctor Option.some [SemanticModels::RealizationDescriptor] (ctor SemanticModels::RealizationDescriptor.RealizationDescriptorStatistical field0 field1 field2 field3 field4 field5 field6)))))))))))))))) else (ctor Option.none [SemanticModels::RealizationDescriptor])) else (if (prim equal tag (lit "neural") : Bool) then (if (closedKeys members (cons (lit "architecture") (cons (lit "encoder") (cons (lit "width") (cons (lit "width_evidence") (cons (lit "layers") (cons (lit "decoder") (cons (lit "kind") (nil Bytes))))))))) then (let decoded0 : (Option SemanticModels::NeuralArchitecture) := (match (lookup members (lit "architecture")) + | Option.some found => (decNeuralArchitecture budget found) + | Option.none => (ctor Option.none [SemanticModels::NeuralArchitecture])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field0 => (let decoded1 : (Option SemanticTerms::STerm) := (match (lookup members (lit "encoder")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field1 => (let decoded2 : (Option Nat) := (match (lookup members (lit "width")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field2 => (let decoded3 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "width_evidence")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field3 => (let decoded4 : (Option (List SemanticModels::NeuralLayer)) := (match (lookup members (lit "layers")) + | Option.some found => (decListNeuralLayer budget found) + | Option.none => (ctor Option.none [(List SemanticModels::NeuralLayer)])); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field4 => (let decoded5 : (Option SemanticModels::NeuralDecoder) := (match (lookup members (lit "decoder")) + | Option.some found => (decNeuralDecoder budget found) + | Option.none => (ctor Option.none [SemanticModels::NeuralDecoder])); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field5 => (ctor Option.some [SemanticModels::RealizationDescriptor] (ctor SemanticModels::RealizationDescriptor.RealizationDescriptorNeural field0 field1 field2 field3 field4 field5)))))))))))))) else (ctor Option.none [SemanticModels::RealizationDescriptor])) else (if (prim equal tag (lit "composite") : Bool) then (if (closedKeys members (cons (lit "form") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option SemanticModels::CompositeForm) := (match (lookup members (lit "form")) + | Option.some found => (decCompositeForm budget found) + | Option.none => (ctor Option.none [SemanticModels::CompositeForm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | Option.some field0 => (ctor Option.some [SemanticModels::RealizationDescriptor] (ctor SemanticModels::RealizationDescriptor.RealizationDescriptorComposite field0)))) else (ctor Option.none [SemanticModels::RealizationDescriptor])) else (ctor Option.none [SemanticModels::RealizationDescriptor])))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::RealizationDescriptor]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::RealizationDescriptor]))), + executable: true +} + +definition{ + name: decEvidenceClaim, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::EvidenceClaim), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::EvidenceClaim]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::EvidenceClaim]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::EvidenceClaim]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::EvidenceClaim]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some tag => (if (prim equal tag (lit "dataset_agreement") : Bool) then (if (closedKeys members (cons (lit "dataset") (cons (lit "comparison") (cons (lit "comparison_sound") (cons (lit "examples") (cons (lit "agreements") (cons (lit "theorem") (cons (lit "kind") (nil Bytes))))))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "dataset")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "comparison")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "comparison_sound")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field2 => (let decoded3 : (Option Nat) := (match (lookup members (lit "examples")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field3 => (let decoded4 : (Option Nat) := (match (lookup members (lit "agreements")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field4 => (let decoded5 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field5 => (ctor Option.some [SemanticModels::EvidenceClaim] (ctor SemanticModels::EvidenceClaim.EvidenceClaimDatasetAgreement field0 field1 field2 field3 field4 field5)))))))))))))) else (ctor Option.none [SemanticModels::EvidenceClaim])) else (if (prim equal tag (lit "equivalent_to") : Bool) then (if (closedKeys members (cons (lit "reference") (cons (lit "theorem") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "reference")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field1 => (ctor Option.some [SemanticModels::EvidenceClaim] (ctor SemanticModels::EvidenceClaim.EvidenceClaimEquivalentTo field0 field1)))))) else (ctor Option.none [SemanticModels::EvidenceClaim])) else (if (prim equal tag (lit "initial_invariant") : Bool) then (if (closedKeys members (cons (lit "theorem") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field0 => (ctor Option.some [SemanticModels::EvidenceClaim] (ctor SemanticModels::EvidenceClaim.EvidenceClaimInitialInvariant field0)))) else (ctor Option.none [SemanticModels::EvidenceClaim])) else (if (prim equal tag (lit "preserves_invariant") : Bool) then (if (closedKeys members (cons (lit "theorem") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field0 => (ctor Option.some [SemanticModels::EvidenceClaim] (ctor SemanticModels::EvidenceClaim.EvidenceClaimPreservesInvariant field0)))) else (ctor Option.none [SemanticModels::EvidenceClaim])) else (if (prim equal tag (lit "satisfies_contract") : Bool) then (if (closedKeys members (cons (lit "theorem") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::EvidenceClaim]) + | Option.some field0 => (ctor Option.some [SemanticModels::EvidenceClaim] (ctor SemanticModels::EvidenceClaim.EvidenceClaimSatisfiesContract field0)))) else (ctor Option.none [SemanticModels::EvidenceClaim])) else (ctor Option.none [SemanticModels::EvidenceClaim])))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::EvidenceClaim]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::EvidenceClaim]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::EvidenceClaim]))), + executable: true +} + +definition{ + name: decListContractValidatorItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::ContractValidator)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticModels::ContractValidator)] (nil SemanticModels::ContractValidator)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticModels::ContractValidator) := (decContractValidator budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | Option.some headValue => (let tail : (Option (List SemanticModels::ContractValidator)) := (decListContractValidatorItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | Option.some tailValue => (ctor Option.some [(List SemanticModels::ContractValidator)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::ContractValidator)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListContractValidator, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::ContractValidator)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JArr part0 => (decListContractValidatorItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticModels::ContractValidator)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::ContractValidator)]))), + executable: true +} + +definition{ + name: decListEvidenceClaimItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::EvidenceClaim)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticModels::EvidenceClaim)] (nil SemanticModels::EvidenceClaim)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticModels::EvidenceClaim) := (decEvidenceClaim budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | Option.some headValue => (let tail : (Option (List SemanticModels::EvidenceClaim)) := (decListEvidenceClaimItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | Option.some tailValue => (ctor Option.some [(List SemanticModels::EvidenceClaim)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListEvidenceClaim, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticModels::EvidenceClaim)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JArr part0 => (decListEvidenceClaimItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticModels::EvidenceClaim)]))), + executable: true +} + +definition{ + name: decListMemberItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List ((Option Bytes) * Bytes))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List ((Option Bytes) * Bytes))] (nil ((Option Bytes) * Bytes))) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option ((Option Bytes) * Bytes)) := (decMember budget part0); (match head + | Option.none => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Option.some headValue => (let tail : (Option (List ((Option Bytes) * Bytes))) := (decListMemberItems budget part1); (match tail + | Option.none => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Option.some tailValue => (ctor Option.some [(List ((Option Bytes) * Bytes))] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List ((Option Bytes) * Bytes))]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListMember, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List ((Option Bytes) * Bytes))), + body: (match fuel + | Nat.zero => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JArr part0 => (decListMemberItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List ((Option Bytes) * Bytes))]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List ((Option Bytes) * Bytes))]))), + executable: true +} + +definition{ + name: decModelDeclaration, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticModels::ModelDeclaration), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticModels::ModelDeclaration]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticModels::ModelDeclaration]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticModels::ModelDeclaration]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticModels::ModelDeclaration]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some tag => (if (prim equal tag (lit "artifact") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "role") (cons (lit "sha256") (cons (lit "length") (cons (lit "schema") (cons (lit "type") (cons (lit "axioms") (cons (lit "kind") (nil Bytes)))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field0 => (let decoded1 : (Option SemanticModels::ArtifactRole) := (match (lookup members (lit "role")) + | Option.some found => (decArtifactRole budget found) + | Option.none => (ctor Option.none [SemanticModels::ArtifactRole])); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field1 => (let decoded2 : (Option Bytes) := (match (lookup members (lit "sha256")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field2 => (let decoded3 : (Option Nat) := (match (lookup members (lit "length")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field3 => (let decoded4 : (Option SemanticModels::ArtifactSchema) := (match (lookup members (lit "schema")) + | Option.some found => (decArtifactSchema budget found) + | Option.none => (ctor Option.none [SemanticModels::ArtifactSchema])); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field4 => (let decoded5 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field5 => (let decoded6 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded6 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field6 => (ctor Option.some [SemanticModels::ModelDeclaration] (ctor SemanticModels::ModelDeclaration.ModelDeclarationArtifact field0 field1 field2 field3 field4 field5 field6)))))))))))))))) else (ctor Option.none [SemanticModels::ModelDeclaration])) else (if (prim equal tag (lit "contract") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "input") (cons (lit "output") (cons (lit "state") (cons (lit "precondition") (cons (lit "postcondition") (cons (lit "invariant") (cons (lit "validators") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelBinder) := (match (lookup members (lit "input")) + | Option.some found => (decModelBinder budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelBinder])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticModels::ModelBinder) := (match (lookup members (lit "output")) + | Option.some found => (decModelBinder budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelBinder])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field3 => (let decoded4 : (Option (Option SemanticModels::ContractState)) := (match (lookup members (lit "state")) + | Option.some found => (match (decContractState budget found) + | Option.some present => (ctor Option.some [(Option SemanticModels::ContractState)] (ctor Option.some [SemanticModels::ContractState] present)) + | Option.none => (ctor Option.none [(Option SemanticModels::ContractState)])) + | Option.none => (ctor Option.some [(Option SemanticModels::ContractState)] (ctor Option.none [SemanticModels::ContractState]))); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field4 => (let decoded5 : (Option (Option ((Option Bytes) * Bytes))) := (match (lookup members (lit "precondition")) + | Option.some found => (match (decMember budget found) + | Option.some present => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.some [((Option Bytes) * Bytes)] present)) + | Option.none => (ctor Option.none [(Option ((Option Bytes) * Bytes))])) + | Option.none => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.none [((Option Bytes) * Bytes)]))); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field5 => (let decoded6 : (Option (Option ((Option Bytes) * Bytes))) := (match (lookup members (lit "postcondition")) + | Option.some found => (match (decMember budget found) + | Option.some present => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.some [((Option Bytes) * Bytes)] present)) + | Option.none => (ctor Option.none [(Option ((Option Bytes) * Bytes))])) + | Option.none => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.none [((Option Bytes) * Bytes)]))); (match decoded6 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field6 => (let decoded7 : (Option (Option ((Option Bytes) * Bytes))) := (match (lookup members (lit "invariant")) + | Option.some found => (match (decMember budget found) + | Option.some present => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.some [((Option Bytes) * Bytes)] present)) + | Option.none => (ctor Option.none [(Option ((Option Bytes) * Bytes))])) + | Option.none => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.none [((Option Bytes) * Bytes)]))); (match decoded7 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field7 => (let decoded8 : (Option (List SemanticModels::ContractValidator)) := (match (lookup members (lit "validators")) + | Option.some found => (decListContractValidator budget found) + | Option.none => (ctor Option.some [(List SemanticModels::ContractValidator)] (nil SemanticModels::ContractValidator))); (match decoded8 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field8 => (let decoded9 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded9 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field9 => (ctor Option.some [SemanticModels::ModelDeclaration] (ctor SemanticModels::ModelDeclaration.ModelDeclarationContract field0 field1 field2 field3 field4 field5 field6 field7 field8 field9)))))))))))))))))))))) else (ctor Option.none [SemanticModels::ModelDeclaration])) else (if (prim equal tag (lit "realization") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "input") (cons (lit "output") (cons (lit "state") (cons (lit "descriptor") (cons (lit "executable") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelBinder) := (match (lookup members (lit "input")) + | Option.some found => (decModelBinder budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelBinder])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "output")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field3 => (let decoded4 : (Option (Option SemanticModels::RealizationState)) := (match (lookup members (lit "state")) + | Option.some found => (match (decRealizationState budget found) + | Option.some present => (ctor Option.some [(Option SemanticModels::RealizationState)] (ctor Option.some [SemanticModels::RealizationState] present)) + | Option.none => (ctor Option.none [(Option SemanticModels::RealizationState)])) + | Option.none => (ctor Option.some [(Option SemanticModels::RealizationState)] (ctor Option.none [SemanticModels::RealizationState]))); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field4 => (let decoded5 : (Option SemanticModels::RealizationDescriptor) := (match (lookup members (lit "descriptor")) + | Option.some found => (decRealizationDescriptor budget found) + | Option.none => (ctor Option.none [SemanticModels::RealizationDescriptor])); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field5 => (let decoded6 : (Option Bool) := (match (lookup members (lit "executable")) + | Option.some found => (decBool found) + | Option.none => (ctor Option.some [Bool] false)); (match decoded6 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field6 => (let decoded7 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded7 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field7 => (ctor Option.some [SemanticModels::ModelDeclaration] (ctor SemanticModels::ModelDeclaration.ModelDeclarationRealization field0 field1 field2 field3 field4 field5 field6 field7)))))))))))))))))) else (ctor Option.none [SemanticModels::ModelDeclaration])) else (if (prim equal tag (lit "evidence") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "contract") (cons (lit "realization") (cons (lit "claims") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "contract")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "realization")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field3 => (let decoded4 : (Option (List SemanticModels::EvidenceClaim)) := (match (lookup members (lit "claims")) + | Option.some found => (decListEvidenceClaim budget found) + | Option.none => (ctor Option.none [(List SemanticModels::EvidenceClaim)])); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field4 => (let decoded5 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field5 => (ctor Option.some [SemanticModels::ModelDeclaration] (ctor SemanticModels::ModelDeclaration.ModelDeclarationEvidence field0 field1 field2 field3 field4 field5)))))))))))))) else (ctor Option.none [SemanticModels::ModelDeclaration])) else (if (prim equal tag (lit "model") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "contract") (cons (lit "realization") (cons (lit "evidence") (cons (lit "entry") (cons (lit "axioms") (cons (lit "kind") (nil Bytes)))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "contract")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded2 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "realization")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded3 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field3 => (let decoded4 : (Option (List SemanticModels::ModelUse)) := (match (lookup members (lit "evidence")) + | Option.some found => (decListModelUse budget found) + | Option.none => (ctor Option.some [(List SemanticModels::ModelUse)] (nil SemanticModels::ModelUse))); (match decoded4 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field4 => (let decoded5 : (Option (List ((Option Bytes) * Bytes))) := (match (lookup members (lit "entry")) + | Option.some found => (decListMember budget found) + | Option.none => (ctor Option.some [(List ((Option Bytes) * Bytes))] (nil ((Option Bytes) * Bytes)))); (match decoded5 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field5 => (let decoded6 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded6 + | Option.none => (ctor Option.none [SemanticModels::ModelDeclaration]) + | Option.some field6 => (ctor Option.some [SemanticModels::ModelDeclaration] (ctor SemanticModels::ModelDeclaration.ModelDeclarationModel field0 field1 field2 field3 field4 field5 field6)))))))))))))))) else (ctor Option.none [SemanticModels::ModelDeclaration])) else (ctor Option.none [SemanticModels::ModelDeclaration])))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticModels::ModelDeclaration]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticModels::ModelDeclaration]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticModels::ModelDeclaration]))), + executable: true +} + +definition{ + name: decLogicInvariant, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::LogicInvariant), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "predicate") (cons (lit "preserves") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "predicate")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "preserves")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | Option.some field1 => (ctor Option.some [SemanticReasoning::LogicInvariant] (ctor SemanticReasoning::LogicInvariant.LogicInvariantOf field0 field1)))))) else (ctor Option.none [SemanticReasoning::LogicInvariant]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticReasoning::LogicInvariant]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticReasoning::LogicInvariant]))), + executable: true +} + +definition{ + name: decRuleBinding, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::RuleBinding), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticReasoning::RuleBinding]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticReasoning::RuleBinding]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticReasoning::RuleBinding]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticReasoning::RuleBinding]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticReasoning::RuleBinding]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "type") (cons (lit "candidates") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::RuleBinding]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::RuleBinding]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "candidates")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::RuleBinding]) + | Option.some field2 => (ctor Option.some [SemanticReasoning::RuleBinding] (ctor SemanticReasoning::RuleBinding.RuleBindingOf field0 field1 field2)))))))) else (ctor Option.none [SemanticReasoning::RuleBinding]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticReasoning::RuleBinding]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticReasoning::RuleBinding]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticReasoning::RuleBinding]))), + executable: true +} + +definition{ + name: decReasoningAnswer, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::ReasoningAnswer), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (if (closedKeys members (cons (lit "name") (cons (lit "type") (cons (lit "value") (nil Bytes))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | Option.some field0 => (let decoded1 : (Option SemanticTypes::SemanticType) := (match (lookup members (lit "type")) + | Option.some found => (decType budget found) + | Option.none => (ctor Option.none [SemanticTypes::SemanticType])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | Option.some field1 => (let decoded2 : (Option SemanticTerms::STerm) := (match (lookup members (lit "value")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | Option.some field2 => (ctor Option.some [SemanticReasoning::ReasoningAnswer] (ctor SemanticReasoning::ReasoningAnswer.ReasoningAnswerOf field0 field1 field2)))))))) else (ctor Option.none [SemanticReasoning::ReasoningAnswer]))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningAnswer]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticReasoning::ReasoningAnswer]))), + executable: true +} + +definition{ + name: decReasoningStrategy, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::ReasoningStrategy), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some tag => (if (prim equal tag (lit "forward") : Bool) then (if (closedKeys members (cons (lit "fuel") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option (Option SemanticTerms::STerm)) := (match (lookup members (lit "fuel")) + | Option.some found => (match (decTerm budget found) + | Option.some present => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.some [SemanticTerms::STerm] present)) + | Option.none => (ctor Option.none [(Option SemanticTerms::STerm)])) + | Option.none => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.none [SemanticTerms::STerm]))); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some field0 => (ctor Option.some [SemanticReasoning::ReasoningStrategy] (ctor SemanticReasoning::ReasoningStrategy.ReasoningStrategyForward field0)))) else (ctor Option.none [SemanticReasoning::ReasoningStrategy])) else (if (prim equal tag (lit "search") : Bool) then (if (closedKeys members (cons (lit "order") (cons (lit "fuel") (cons (lit "frontier") (cons (lit "deduplicate") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option SemanticReasoning::SearchOrder) := (match (lookup members (lit "order")) + | Option.some found => (decSearchOrder budget found) + | Option.none => (ctor Option.none [SemanticReasoning::SearchOrder])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some field0 => (let decoded1 : (Option (Option SemanticTerms::STerm)) := (match (lookup members (lit "fuel")) + | Option.some found => (match (decTerm budget found) + | Option.some present => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.some [SemanticTerms::STerm] present)) + | Option.none => (ctor Option.none [(Option SemanticTerms::STerm)])) + | Option.none => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.none [SemanticTerms::STerm]))); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some field1 => (let decoded2 : (Option (Option SemanticTerms::STerm)) := (match (lookup members (lit "frontier")) + | Option.some found => (match (decTerm budget found) + | Option.some present => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.some [SemanticTerms::STerm] present)) + | Option.none => (ctor Option.none [(Option SemanticTerms::STerm)])) + | Option.none => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.none [SemanticTerms::STerm]))); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some field2 => (let decoded3 : (Option Bool) := (match (lookup members (lit "deduplicate")) + | Option.some found => (decBool found) + | Option.none => (ctor Option.some [Bool] false)); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some field3 => (ctor Option.some [SemanticReasoning::ReasoningStrategy] (ctor SemanticReasoning::ReasoningStrategy.ReasoningStrategySearch field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticReasoning::ReasoningStrategy])) else (if (prim equal tag (lit "generate_and_verify") : Bool) then (if (closedKeys members (cons (lit "generator") (cons (lit "budget") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticTerms::STerm) := (match (lookup members (lit "generator")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some field0 => (let decoded1 : (Option (Option SemanticTerms::STerm)) := (match (lookup members (lit "budget")) + | Option.some found => (match (decTerm budget found) + | Option.some present => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.some [SemanticTerms::STerm] present)) + | Option.none => (ctor Option.none [(Option SemanticTerms::STerm)])) + | Option.none => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.none [SemanticTerms::STerm]))); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | Option.some field1 => (ctor Option.some [SemanticReasoning::ReasoningStrategy] (ctor SemanticReasoning::ReasoningStrategy.ReasoningStrategyGenerateAndVerify field0 field1)))))) else (ctor Option.none [SemanticReasoning::ReasoningStrategy])) else (ctor Option.none [SemanticReasoning::ReasoningStrategy])))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningStrategy]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticReasoning::ReasoningStrategy]))), + executable: true +} + +definition{ + name: decReasoningClaim, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::ReasoningClaim), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Option.some tag => (if (prim equal tag (lit "initial_invariant") : Bool) then (if (closedKeys members (cons (lit "theorem") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Option.some field0 => (ctor Option.some [SemanticReasoning::ReasoningClaim] (ctor SemanticReasoning::ReasoningClaim.ReasoningClaimInitialInvariant field0)))) else (ctor Option.none [SemanticReasoning::ReasoningClaim])) else (if (prim equal tag (lit "terminates") : Bool) then (if (closedKeys members (cons (lit "theorem") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Option.some field0 => (ctor Option.some [SemanticReasoning::ReasoningClaim] (ctor SemanticReasoning::ReasoningClaim.ReasoningClaimTerminates field0)))) else (ctor Option.none [SemanticReasoning::ReasoningClaim])) else (if (prim equal tag (lit "observation_invariant") : Bool) then (if (closedKeys members (cons (lit "predicate") (cons (lit "initial") (cons (lit "preserved") (cons (lit "kind") (nil Bytes)))))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "predicate")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "initial")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "preserved")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Option.some field2 => (ctor Option.some [SemanticReasoning::ReasoningClaim] (ctor SemanticReasoning::ReasoningClaim.ReasoningClaimObservationInvariant field0 field1 field2)))))))) else (ctor Option.none [SemanticReasoning::ReasoningClaim])) else (if (prim equal tag (lit "answer_correct") : Bool) then (if (closedKeys members (cons (lit "theorem") (cons (lit "kind") (nil Bytes)))) then (let decoded0 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "theorem")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | Option.some field0 => (ctor Option.some [SemanticReasoning::ReasoningClaim] (ctor SemanticReasoning::ReasoningClaim.ReasoningClaimAnswerCorrect field0)))) else (ctor Option.none [SemanticReasoning::ReasoningClaim])) else (ctor Option.none [SemanticReasoning::ReasoningClaim]))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningClaim]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticReasoning::ReasoningClaim]))), + executable: true +} + +definition{ + name: decGenerationPolicy, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::GenerationPolicy), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | Option.some tag => (if (prim equal tag (lit "greedy") : Bool) then (ctor Option.some [SemanticReasoning::GenerationPolicy] (ctor SemanticReasoning::GenerationPolicy.GenerationPolicyGreedy)) else (if (prim equal tag (lit "sample") : Bool) then (if (closedKeys members (cons (lit "generator") (cons (lit "distribution") (cons (lit "kind") (nil Bytes))))) then (let decoded0 : (Option SemanticReasoning::SamplingGenerator) := (match (lookup members (lit "generator")) + | Option.some found => (decSamplingGenerator budget found) + | Option.none => (ctor Option.none [SemanticReasoning::SamplingGenerator])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | Option.some field0 => (let decoded1 : (Option SemanticReasoning::SamplingDistribution) := (match (lookup members (lit "distribution")) + | Option.some found => (decSamplingDistribution budget found) + | Option.none => (ctor Option.none [SemanticReasoning::SamplingDistribution])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | Option.some field1 => (ctor Option.some [SemanticReasoning::GenerationPolicy] (ctor SemanticReasoning::GenerationPolicy.GenerationPolicySample field0 field1)))))) else (ctor Option.none [SemanticReasoning::GenerationPolicy])) else (ctor Option.none [SemanticReasoning::GenerationPolicy]))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticReasoning::GenerationPolicy]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticReasoning::GenerationPolicy]))), + executable: true +} + +definition{ + name: decListReasoningClaimItems, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticReasoning::ReasoningClaim)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.some [(List SemanticReasoning::ReasoningClaim)] (nil SemanticReasoning::ReasoningClaim)) + | LexLeanStd.Json::Json.JItem part0 part1 => (let head : (Option SemanticReasoning::ReasoningClaim) := (decReasoningClaim budget part0); (match head + | Option.none => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | Option.some headValue => (let tail : (Option (List SemanticReasoning::ReasoningClaim)) := (decListReasoningClaimItems budget part1); (match tail + | Option.none => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | Option.some tailValue => (ctor Option.some [(List SemanticReasoning::ReasoningClaim)] (cons headValue tailValue)))))) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]))), + executable: true, + recursive_argument: fuel +} + +definition{ + name: decListReasoningClaim, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (List SemanticReasoning::ReasoningClaim)), + body: (match fuel + | Nat.zero => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JArr part0 => (decListReasoningClaimItems budget part0) + | LexLeanStd.Json::Json.JObj part0 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [(List SemanticReasoning::ReasoningClaim)]))), + executable: true +} + +definition{ + name: decReasoningDeclaration, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::ReasoningDeclaration), + body: (match fuel + | Nat.zero => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Nat.succ budget => (match value + | LexLeanStd.Json::Json.JBool part0 => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | LexLeanStd.Json::Json.JInt part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | LexLeanStd.Json::Json.JStr part0 => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | LexLeanStd.Json::Json.JArr part0 => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | LexLeanStd.Json::Json.JObj part0 => (let members : LexLeanStd.Json::Json := part0; (match (kindOf members) + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some tag => (if (prim equal tag (lit "logic") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "state") (cons (lit "relation") (cons (lit "invariant") (cons (lit "ranking") (cons (lit "axioms") (cons (lit "kind") (nil Bytes)))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ContractState) := (match (lookup members (lit "state")) + | Option.some found => (decContractState budget found) + | Option.none => (ctor Option.none [SemanticModels::ContractState])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "relation")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (let decoded4 : (Option (Option SemanticReasoning::LogicInvariant)) := (match (lookup members (lit "invariant")) + | Option.some found => (match (decLogicInvariant budget found) + | Option.some present => (ctor Option.some [(Option SemanticReasoning::LogicInvariant)] (ctor Option.some [SemanticReasoning::LogicInvariant] present)) + | Option.none => (ctor Option.none [(Option SemanticReasoning::LogicInvariant)])) + | Option.none => (ctor Option.some [(Option SemanticReasoning::LogicInvariant)] (ctor Option.none [SemanticReasoning::LogicInvariant]))); (match decoded4 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field4 => (let decoded5 : (Option (Option ((Option Bytes) * Bytes))) := (match (lookup members (lit "ranking")) + | Option.some found => (match (decMember budget found) + | Option.some present => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.some [((Option Bytes) * Bytes)] present)) + | Option.none => (ctor Option.none [(Option ((Option Bytes) * Bytes))])) + | Option.none => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.none [((Option Bytes) * Bytes)]))); (match decoded5 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field5 => (let decoded6 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded6 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field6 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationLogic field0 field1 field2 field3 field4 field5 field6)))))))))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (if (prim equal tag (lit "inference_rule") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "logic") (cons (lit "binding") (cons (lit "guard") (cons (lit "conclusion") (cons (lit "soundness") (cons (lit "progress") (cons (lit "executable") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "logic")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option (Option SemanticReasoning::RuleBinding)) := (match (lookup members (lit "binding")) + | Option.some found => (match (decRuleBinding budget found) + | Option.some present => (ctor Option.some [(Option SemanticReasoning::RuleBinding)] (ctor Option.some [SemanticReasoning::RuleBinding] present)) + | Option.none => (ctor Option.none [(Option SemanticReasoning::RuleBinding)])) + | Option.none => (ctor Option.some [(Option SemanticReasoning::RuleBinding)] (ctor Option.none [SemanticReasoning::RuleBinding]))); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (let decoded4 : (Option SemanticTerms::STerm) := (match (lookup members (lit "guard")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded4 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field4 => (let decoded5 : (Option SemanticTerms::STerm) := (match (lookup members (lit "conclusion")) + | Option.some found => (decTerm budget found) + | Option.none => (ctor Option.none [SemanticTerms::STerm])); (match decoded5 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field5 => (let decoded6 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "soundness")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded6 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field6 => (let decoded7 : (Option (Option ((Option Bytes) * Bytes))) := (match (lookup members (lit "progress")) + | Option.some found => (match (decMember budget found) + | Option.some present => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.some [((Option Bytes) * Bytes)] present)) + | Option.none => (ctor Option.none [(Option ((Option Bytes) * Bytes))])) + | Option.none => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.none [((Option Bytes) * Bytes)]))); (match decoded7 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field7 => (let decoded8 : (Option Bool) := (match (lookup members (lit "executable")) + | Option.some found => (decBool found) + | Option.none => (ctor Option.some [Bool] false)); (match decoded8 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field8 => (let decoded9 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded9 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field9 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationInferenceRule field0 field1 field2 field3 field4 field5 field6 field7 field8 field9)))))))))))))))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (if (prim equal tag (lit "verifier") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "subject") (cons (lit "candidate") (cons (lit "specification") (cons (lit "check") (cons (lit "sound") (cons (lit "complete") (cons (lit "axioms") (cons (lit "kind") (nil Bytes)))))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelBinder) := (match (lookup members (lit "subject")) + | Option.some found => (decModelBinder budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelBinder])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticModels::ModelBinder) := (match (lookup members (lit "candidate")) + | Option.some found => (decModelBinder budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelBinder])); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (let decoded4 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "specification")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded4 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field4 => (let decoded5 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "check")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded5 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field5 => (let decoded6 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "sound")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded6 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field6 => (let decoded7 : (Option (Option ((Option Bytes) * Bytes))) := (match (lookup members (lit "complete")) + | Option.some found => (match (decMember budget found) + | Option.some present => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.some [((Option Bytes) * Bytes)] present)) + | Option.none => (ctor Option.none [(Option ((Option Bytes) * Bytes))])) + | Option.none => (ctor Option.some [(Option ((Option Bytes) * Bytes))] (ctor Option.none [((Option Bytes) * Bytes)]))); (match decoded7 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field7 => (let decoded8 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded8 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field8 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationVerifier field0 field1 field2 field3 field4 field5 field6 field7 field8)))))))))))))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (if (prim equal tag (lit "reasoner") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "logic") (cons (lit "observation") (cons (lit "observe") (cons (lit "rules") (cons (lit "strategy") (cons (lit "answer") (cons (lit "verifier") (cons (lit "claims") (cons (lit "executable") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option (Option SemanticModels::ModelUse)) := (match (lookup members (lit "logic")) + | Option.some found => (match (decModelUse budget found) + | Option.some present => (ctor Option.some [(Option SemanticModels::ModelUse)] (ctor Option.some [SemanticModels::ModelUse] present)) + | Option.none => (ctor Option.none [(Option SemanticModels::ModelUse)])) + | Option.none => (ctor Option.some [(Option SemanticModels::ModelUse)] (ctor Option.none [SemanticModels::ModelUse]))); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticModels::ModelBinder) := (match (lookup members (lit "observation")) + | Option.some found => (decModelBinder budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelBinder])); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (let decoded4 : (Option (Option SemanticTerms::STerm)) := (match (lookup members (lit "observe")) + | Option.some found => (match (decTerm budget found) + | Option.some present => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.some [SemanticTerms::STerm] present)) + | Option.none => (ctor Option.none [(Option SemanticTerms::STerm)])) + | Option.none => (ctor Option.some [(Option SemanticTerms::STerm)] (ctor Option.none [SemanticTerms::STerm]))); (match decoded4 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field4 => (let decoded5 : (Option (List SemanticModels::ModelUse)) := (match (lookup members (lit "rules")) + | Option.some found => (decListModelUse budget found) + | Option.none => (ctor Option.none [(List SemanticModels::ModelUse)])); (match decoded5 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field5 => (let decoded6 : (Option SemanticReasoning::ReasoningStrategy) := (match (lookup members (lit "strategy")) + | Option.some found => (decReasoningStrategy budget found) + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningStrategy])); (match decoded6 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field6 => (let decoded7 : (Option (Option SemanticReasoning::ReasoningAnswer)) := (match (lookup members (lit "answer")) + | Option.some found => (match (decReasoningAnswer budget found) + | Option.some present => (ctor Option.some [(Option SemanticReasoning::ReasoningAnswer)] (ctor Option.some [SemanticReasoning::ReasoningAnswer] present)) + | Option.none => (ctor Option.none [(Option SemanticReasoning::ReasoningAnswer)])) + | Option.none => (ctor Option.some [(Option SemanticReasoning::ReasoningAnswer)] (ctor Option.none [SemanticReasoning::ReasoningAnswer]))); (match decoded7 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field7 => (let decoded8 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "verifier")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded8 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field8 => (let decoded9 : (Option (List SemanticReasoning::ReasoningClaim)) := (match (lookup members (lit "claims")) + | Option.some found => (decListReasoningClaim budget found) + | Option.none => (ctor Option.some [(List SemanticReasoning::ReasoningClaim)] (nil SemanticReasoning::ReasoningClaim))); (match decoded9 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field9 => (let decoded10 : (Option Bool) := (match (lookup members (lit "executable")) + | Option.some found => (decBool found) + | Option.none => (ctor Option.some [Bool] false)); (match decoded10 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field10 => (let decoded11 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded11 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field11 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationReasoner field0 field1 field2 field3 field4 field5 field6 field7 field8 field9 field10 field11)))))))))))))))))))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (if (prim equal tag (lit "tokenizer") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "type_parameters") (cons (lit "scheme") (cons (lit "vocabulary") (cons (lit "axioms") (cons (lit "kind") (nil Bytes)))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option (List Bytes)) := (match (lookup members (lit "type_parameters")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticReasoning::TokenizerScheme) := (match (lookup members (lit "scheme")) + | Option.some found => (decTokenizerScheme budget found) + | Option.none => (ctor Option.none [SemanticReasoning::TokenizerScheme])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "vocabulary")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (let decoded4 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded4 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field4 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationTokenizer field0 field1 field2 field3 field4)))))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (if (prim equal tag (lit "context_window") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "capacity") (cons (lit "overflow") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option Nat) := (match (lookup members (lit "capacity")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticReasoning::OverflowDisposition) := (match (lookup members (lit "overflow")) + | Option.some found => (decOverflowDisposition budget found) + | Option.none => (ctor Option.none [SemanticReasoning::OverflowDisposition])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationContextWindow field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (if (prim equal tag (lit "text_generator") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "tokenizer") (cons (lit "window") (cons (lit "scorer") (cons (lit "max_tokens") (cons (lit "stop") (cons (lit "policy") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "tokenizer")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "window")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "scorer")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (let decoded4 : (Option Nat) := (match (lookup members (lit "max_tokens")) + | Option.some found => (decNat found) + | Option.none => (ctor Option.none [Nat])); (match decoded4 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field4 => (let decoded5 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "stop")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded5 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field5 => (let decoded6 : (Option SemanticReasoning::GenerationPolicy) := (match (lookup members (lit "policy")) + | Option.some found => (decGenerationPolicy budget found) + | Option.none => (ctor Option.none [SemanticReasoning::GenerationPolicy])); (match decoded6 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field6 => (let decoded7 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded7 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field7 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationTextGenerator field0 field1 field2 field3 field4 field5 field6 field7)))))))))))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (if (prim equal tag (lit "text_classifier") : Bool) then (if (closedKeys members (cons (lit "name") (cons (lit "tokenizer") (cons (lit "model") (cons (lit "axioms") (cons (lit "kind") (nil Bytes))))))) then (let decoded0 : (Option Bytes) := (match (lookup members (lit "name")) + | Option.some found => (decStr found) + | Option.none => (ctor Option.none [Bytes])); (match decoded0 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field0 => (let decoded1 : (Option ((Option Bytes) * Bytes)) := (match (lookup members (lit "tokenizer")) + | Option.some found => (decMember budget found) + | Option.none => (ctor Option.none [((Option Bytes) * Bytes)])); (match decoded1 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field1 => (let decoded2 : (Option SemanticModels::ModelUse) := (match (lookup members (lit "model")) + | Option.some found => (decModelUse budget found) + | Option.none => (ctor Option.none [SemanticModels::ModelUse])); (match decoded2 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field2 => (let decoded3 : (Option (List Bytes)) := (match (lookup members (lit "axioms")) + | Option.some found => (decNames found) + | Option.none => (ctor Option.some [(List Bytes)] (nil Bytes))); (match decoded3 + | Option.none => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | Option.some field3 => (ctor Option.some [SemanticReasoning::ReasoningDeclaration] (ctor SemanticReasoning::ReasoningDeclaration.ReasoningDeclarationTextClassifier field0 field1 field2 field3)))))))))) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration])) else (ctor Option.none [SemanticReasoning::ReasoningDeclaration]))))))))))) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | LexLeanStd.Json::Json.JItem part0 part1 => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]) + | LexLeanStd.Json::Json.JMember part0 part1 part2 => (ctor Option.none [SemanticReasoning::ReasoningDeclaration]))), + executable: true +} + +definition{ + name: itemList, + parameters: [items : LexLeanStd.Json::Json], + result: (List LexLeanStd.Json::Json), + body: (match items + | LexLeanStd.Json::Json.JBool flag => (nil LexLeanStd.Json::Json) + | LexLeanStd.Json::Json.JInt negative magnitude => (nil LexLeanStd.Json::Json) + | LexLeanStd.Json::Json.JStr text => (nil LexLeanStd.Json::Json) + | LexLeanStd.Json::Json.JArr inner => (nil LexLeanStd.Json::Json) + | LexLeanStd.Json::Json.JObj inner => (nil LexLeanStd.Json::Json) + | LexLeanStd.Json::Json.JNil => (nil LexLeanStd.Json::Json) + | LexLeanStd.Json::Json.JItem element rest => (cons element (itemList rest)) + | LexLeanStd.Json::Json.JMember key inner rest => (nil LexLeanStd.Json::Json)), + executable: true, + recursive_argument: items +} + +definition{ + name: objectMembers, + parameters: [value : LexLeanStd.Json::Json], + result: (Option LexLeanStd.Json::Json), + body: (match value + | LexLeanStd.Json::Json.JObj members => (ctor Option.some [LexLeanStd.Json::Json] members) + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JArr items => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [LexLeanStd.Json::Json])), + executable: true +} + +definition{ + name: arrayItems, + parameters: [value : LexLeanStd.Json::Json], + result: (Option LexLeanStd.Json::Json), + body: (match value + | LexLeanStd.Json::Json.JArr items => (ctor Option.some [LexLeanStd.Json::Json] items) + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [LexLeanStd.Json::Json]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [LexLeanStd.Json::Json])), + executable: true +} + +definition{ + name: isDefault, + parameters: [value : LexLeanStd.Json::Json], + result: Bool, + body: (match value + | LexLeanStd.Json::Json.JBool flag => (if flag then false else true) + | LexLeanStd.Json::Json.JArr items => (match items + | LexLeanStd.Json::Json.JNil => true + | LexLeanStd.Json::Json.JBool flag => false + | LexLeanStd.Json::Json.JInt negative magnitude => false + | LexLeanStd.Json::Json.JStr text => false + | LexLeanStd.Json::Json.JArr inner => false + | LexLeanStd.Json::Json.JObj inner => false + | LexLeanStd.Json::Json.JItem element rest => false + | LexLeanStd.Json::Json.JMember key inner rest => false) + | LexLeanStd.Json::Json.JInt negative magnitude => false + | LexLeanStd.Json::Json.JStr text => false + | LexLeanStd.Json::Json.JObj members => false + | LexLeanStd.Json::Json.JNil => false + | LexLeanStd.Json::Json.JItem element rest => false + | LexLeanStd.Json::Json.JMember key inner rest => false), + executable: true +} + +definition{ + name: unitVariant, + parameters: [members : LexLeanStd.Json::Json], + result: Bool, + body: (match (keyList members) + | List.nil => false + | List.cons head rest => match{ + branches: [ + {body: (prim equal head (lit "kind") : Bool), binders: [], constructor: List.nil}, + {body: false, binders: [second, more], constructor: List.cons} + ], + scrutinee: rest + }), + executable: true +} + +definition{ + name: ignoredValue, + parameters: [ + fuel : Nat, + source : LexLeanStd.Json::Json, + typed : LexLeanStd.Json::Json, + path : Bytes + ], + result: (Option Bytes), + body: (match fuel + | Nat.zero => (ctor Option.none [Bytes]) + | Nat.succ budget => (match (objectMembers source) + | Option.some members => (match (objectMembers typed) + | Option.some kept => (ignoredMembers budget members kept (unitVariant kept) path) + | Option.none => (ctor Option.none [Bytes])) + | Option.none => (match (arrayItems source) + | Option.some items => (match (arrayItems typed) + | Option.some kept => (ignoredItems budget items kept path 0) + | Option.none => (ctor Option.none [Bytes])) + | Option.none => (ctor Option.none [Bytes])))), + executable: true, + mutual: Ignore, + recursive_argument: fuel +} + +definition{ + name: ignoredMembers, + parameters: [ + fuel : Nat, + members : LexLeanStd.Json::Json, + kept : LexLeanStd.Json::Json, + unit : Bool, + path : Bytes + ], + result: (Option Bytes), + body: (match fuel + | Nat.zero => (ctor Option.none [Bytes]) + | Nat.succ budget => (match members + | LexLeanStd.Json::Json.JMember key inner rest => (let child : Bytes := (prim append (prim append path (lit ".") : Bytes) key : Bytes); (match (lookup kept key) + | Option.some typed => (match (ignoredValue budget inner typed child) + | Option.some found => (ctor Option.some [Bytes] found) + | Option.none => (ignoredMembers budget rest kept unit path)) + | Option.none => (if (if unit then true else (if (isDefault inner) then false else true)) then (ctor Option.some [Bytes] child) else (ignoredMembers budget rest kept unit path)))) + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JArr items => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JObj inner => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JItem element rest => (ctor Option.none [Bytes]))), + executable: true, + mutual: Ignore, + recursive_argument: fuel +} + +definition{ + name: ignoredItems, + parameters: [ + fuel : Nat, + items : LexLeanStd.Json::Json, + kept : LexLeanStd.Json::Json, + path : Bytes, + index : Nat + ], + result: (Option Bytes), + body: (match fuel + | Nat.zero => (ctor Option.none [Bytes]) + | Nat.succ budget => (match items + | LexLeanStd.Json::Json.JItem element rest => (match kept + | LexLeanStd.Json::Json.JItem typed more => (match (ignoredValue budget element typed (prim append (prim append (prim append path (lit "[") : Bytes) (LexLeanStd.Numeral::decimal index) : Bytes) (lit "]") : Bytes)) + | Option.some found => (ctor Option.some [Bytes] found) + | Option.none => (ignoredItems budget rest more path (index + 1))) + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JArr inner => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JMember key inner more => (ctor Option.none [Bytes])) + | LexLeanStd.Json::Json.JBool flag => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JInt negative magnitude => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JStr text => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JArr inner => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JObj members => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JNil => (ctor Option.none [Bytes]) + | LexLeanStd.Json::Json.JMember key inner rest => (ctor Option.none [Bytes]))), + executable: true, + mutual: Ignore, + recursive_argument: fuel +} + +definition{ + name: decAny, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option SemanticReasoning::AnyDeclaration), + body: (match (objectMembers value) + | Option.none => (ctor Option.none [SemanticReasoning::AnyDeclaration]) + | Option.some members => (match (kindOf members) + | Option.none => (ctor Option.none [SemanticReasoning::AnyDeclaration]) + | Option.some tag => (if (listed (cons (lit "structure") (cons (lit "class") (cons (lit "instance") (cons (lit "inductive") (cons (lit "definition") (cons (lit "theorem") (nil Bytes))))))) tag) then (match (decOrdinary fuel value) + | Option.some declared => (ctor Option.some [SemanticReasoning::AnyDeclaration] (ctor SemanticReasoning::AnyDeclaration.AnyOrdinary declared)) + | Option.none => (ctor Option.none [SemanticReasoning::AnyDeclaration])) else (if (listed (cons (lit "artifact") (cons (lit "contract") (cons (lit "realization") (cons (lit "evidence") (cons (lit "model") (nil Bytes)))))) tag) then (match (decModelDeclaration fuel value) + | Option.some declared => (ctor Option.some [SemanticReasoning::AnyDeclaration] (ctor SemanticReasoning::AnyDeclaration.AnyModel declared)) + | Option.none => (ctor Option.none [SemanticReasoning::AnyDeclaration])) else (match (decReasoningDeclaration fuel value) + | Option.some declared => (ctor Option.some [SemanticReasoning::AnyDeclaration] (ctor SemanticReasoning::AnyDeclaration.AnyReasoning declared)) + | Option.none => (ctor Option.none [SemanticReasoning::AnyDeclaration])))))), + executable: true +} + +definition{ + name: decModuleValue, + parameters: [fuel : Nat, value : LexLeanStd.Json::Json], + result: (Option (Bytes * (List SemanticReasoning::AnyDeclaration))), + body: (match (objectMembers value) + | Option.none => (ctor Option.none [(Bytes * (List SemanticReasoning::AnyDeclaration))]) + | Option.some members => (if (closedKeys members (cons (lit "declarations") (cons (lit "spec") (nil Bytes)))) then (match (lookup members (lit "spec")) + | Option.none => (ctor Option.none [(Bytes * (List SemanticReasoning::AnyDeclaration))]) + | Option.some specValue => (match (decStr specValue) + | Option.none => (ctor Option.none [(Bytes * (List SemanticReasoning::AnyDeclaration))]) + | Option.some spec => (match (lookup members (lit "declarations")) + | Option.none => (ctor Option.none [(Bytes * (List SemanticReasoning::AnyDeclaration))]) + | Option.some declared => (match (arrayItems declared) + | Option.none => (ctor Option.none [(Bytes * (List SemanticReasoning::AnyDeclaration))]) + | Option.some items => (match (prim list_fold (fun [fuel] (acc : (Option (List SemanticReasoning::AnyDeclaration))) (item : LexLeanStd.Json::Json) => (match acc + | Option.none => (ctor Option.none [(List SemanticReasoning::AnyDeclaration)]) + | Option.some done => (match (decAny fuel item) + | Option.none => (ctor Option.none [(List SemanticReasoning::AnyDeclaration)]) + | Option.some decoded => (ctor Option.some [(List SemanticReasoning::AnyDeclaration)] (cons decoded done))))) (ctor Option.some [(List SemanticReasoning::AnyDeclaration)] (nil SemanticReasoning::AnyDeclaration)) (itemList items) : (Option (List SemanticReasoning::AnyDeclaration))) + | Option.none => (ctor Option.none [(Bytes * (List SemanticReasoning::AnyDeclaration))]) + | Option.some reversed => (ctor Option.some [(Bytes * (List SemanticReasoning::AnyDeclaration))] (spec, (LexLeanStd.Order::reverseList [SemanticReasoning::AnyDeclaration] reversed)))))))) else (ctor Option.none [(Bytes * (List SemanticReasoning::AnyDeclaration))]))), + executable: true +} + +definition{ + name: typedJson, + parameters: [spec : Bytes, declarations : (List SemanticReasoning::AnyDeclaration)], + result: LexLeanStd.Json::Json, + body: (ctor LexLeanStd.Json::Json.JObj (ctor LexLeanStd.Json::Json.JMember (lit "spec") (ctor LexLeanStd.Json::Json.JStr spec) (ctor LexLeanStd.Json::Json.JMember (lit "declarations") (ctor LexLeanStd.Json::Json.JArr (SemanticTerms::chainOf (prim list_fold (fun (acc : (List LexLeanStd.Json::Json)) (declared : SemanticReasoning::AnyDeclaration) => (cons (SemanticReasoning::anyDeclarationJson declared) acc)) (nil LexLeanStd.Json::Json) (LexLeanStd.Order::reverseList [SemanticReasoning::AnyDeclaration] declarations) : (List LexLeanStd.Json::Json)))) (ctor LexLeanStd.Json::Json.JNil)))), + executable: true +} + +inductive{ + name: Decoded, + type_parameters: [], + parameters: [], + constructors: [ + {name: DOk, fields: [Bytes, (List SemanticReasoning::AnyDeclaration)]}, + {name: DInvalid, fields: []}, + {name: DNotCanonical, fields: []}, + {name: DOutside, fields: [Bytes]} + ] +} + +definition{ + name: decodeSemanticModule, + parameters: [text : Bytes], + result: Decoded, + body: (match (readLoose text) + | Option.none => (ctor Decoded.DInvalid) + | Option.some json => (if (127 (ctor Decoded.DInvalid) + | Option.some decoded => (if (prim equal (LexLeanStd.Json::writeJson json) text : Bool) then (match (ignoredValue fuel json (typedJson (first decoded) (second decoded)) (lit "$")) + | Option.some found => (ctor Decoded.DOutside found) + | Option.none => (ctor Decoded.DOk (first decoded) (second decoded))) else (ctor Decoded.DNotCanonical)))))), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, overflow, recursion], targets: [rust-std]} +} +\end{semanticmodule} +\end{lexlean} diff --git a/crates/conformance/src/cases/bootstrap.rs b/crates/conformance/src/cases/bootstrap.rs index 45db006510..8b5467ce53 100644 --- a/crates/conformance/src/cases/bootstrap.rs +++ b/crates/conformance/src/cases/bootstrap.rs @@ -46,6 +46,7 @@ mod rust_terms; mod rust_validate; mod scan; mod semantic_decls; +mod semantic_decode; mod semantic_models; mod semantic_reasoning; mod semantic_terms; @@ -2590,6 +2591,7 @@ fn case(id: &str) { "BS-70" => semantic_decls::case(), "BS-71" => semantic_models::case(), "BS-72" => semantic_reasoning::case(), + "BS-73" => semantic_decode::case(), other => panic!("no bootstrap case is wired for {other}"), } } diff --git a/crates/conformance/src/cases/bootstrap/semantic_decode.rs b/crates/conformance/src/cases/bootstrap/semantic_decode.rs new file mode 100644 index 0000000000..028d470a62 --- /dev/null +++ b/crates/conformance/src/cases/bootstrap/semantic_decode.rs @@ -0,0 +1,665 @@ +//! `BS-73` (SPEC.md §17.23, §17.12): decoding a semantic module from its +//! canonical JSON, as language-1.2 source, `LexLeanBoot.SemanticDecode`, held +//! to the decoding half of `lexlean::ir::semantic::SemanticModule::parse`. +//! +//! `decodeSemanticModule` reads a text and returns the module's discriminator +//! and declarations, or which of the parser's three decoding rejections the +//! text meets first: invalid semantic-module JSON (serde's reading of the +//! text, with whitespace, members in any order, and every escape, and its +//! typed decoding, +//! with its unknown-member, missing-field, duplicate-field and 128-level +//! nesting rules), JSON that is not canonical, or a member outside the closed +//! schema, with its path. The domain is the texts that the canonical JSON +//! parser accepts or that serde rejects first; a text the parser decodes and +//! then fails to validate decodes. The decoders are generated from the same +//! description of the oracle's types as the writers of `BS-68`..`BS-72`. +//! +//! Every semantic module of every committed project that links is a run, and +//! so are modules of examples reaching every model, reasoning and text +//! variant, a module nested to the 127 levels serde admits and one nested to +//! the 128 it rejects, and mutations of these modules: a member removed, an +//! unknown member added (with a value of `0`, `false`, or `[]`), an omitted +//! default written out, a kind renamed, a value of another type, a negative +//! count, and texts out of canonical form. +//! +//! Each planted defect weakens one decoding rule and is detected by those runs. + +use std::collections::{BTreeMap, BTreeSet}; +use std::sync::OnceLock; + +use lexlean::artifact::canonical_json::Json; +use lexlean::calculus::Value; +use lexlean::ir::semantic::model::ArtifactStore; +use lexlean::ir::semantic::SemanticModule; +use serde_json::Value as Json2; + +use super::ir_document::linked_projects; +use super::rust_validate::{eligibility_of, rustc_differential}; +use super::semantic_models::example_model_declaration; +use super::semantic_reasoning::{enc_any, example_reasoning_declaration}; +use super::semantic_types::canonical; +use super::{list, text, Run}; +use crate::production_export as harness; +use crate::support::{self, repo_root}; + +const MODULE: &str = "LexLeanBoot.SemanticDecode"; +const SOURCE: &str = "bootstrap/src/SemanticDecode.lex.tex"; +const ROOTS: [(&str, &[&str]); 1] = [( + "decodeSemanticModule", + &["allocation", "overflow", "recursion"], +)]; +/// A committed module whose JSON is longer decodes under rustc only. +const EVALUATOR_BYTES: usize = 16_384; +/// The most a part of a certificate of a root may be, as the row states. +const CERTIFICATE_BUDGET: u64 = 3_145_728; +/// The example modules: one per step, each holding a model and a reasoning +/// example declaration of that step. +const EXAMPLES: usize = 60; +/// The objects of a base module that are mutated, at most. +const MUTATED_OBJECTS: usize = 12; +/// The members of an object that are removed one at a time, at most. +const REMOVED_MEMBERS: usize = 4; +/// Defaults serialization omits, written out by a mutation where absent. +const DEFAULTS: &[(&str, bool)] = &[ + ("axioms", false), + ("executable", true), + ("type_parameters", false), + ("type_arguments", false), + ("definitions", false), + ("generalizing", false), + ("premises", false), +]; + +// ---------------------------------------------------------------- the sorts + +fn constructors(sort: &str) -> &'static Vec { + static TABLES: OnceLock>> = OnceLock::new(); + let tables = TABLES.get_or_init(|| { + let source = std::fs::read_to_string(repo_root().join(SOURCE).as_std_path()) + .expect("the module's source"); + let mut out = BTreeMap::new(); + for block in source.split("inductive{").skip(1) { + let block = block.split("\n}\n").next().expect("a block"); + let name = block + .split("name: ") + .nth(1) + .and_then(|rest| rest.split(',').next()) + .expect("the inductive's name") + .trim() + .to_owned(); + let names: Vec = block + .split("constructors:") + .nth(1) + .expect("the constructors") + .split("name: ") + .skip(1) + .map(|rest| { + rest.split([',', '\n']) + .next() + .expect("a constructor") + .trim() + .to_owned() + }) + .collect(); + out.insert(name, names); + } + out + }); + tables + .get(sort) + .unwrap_or_else(|| panic!("the module has no inductive `{sort}`")) +} + +fn decoded(constructor: &str, fields: Vec) -> Value { + let found = constructors("Decoded") + .iter() + .position(|name| name == constructor) + .unwrap_or_else(|| panic!("`Decoded` has no constructor `{constructor}`")); + Value::Adt { + constructor: u64::try_from(found).expect("an index"), + fields, + } +} + +// --------------------------------------------------------------- the oracle + +/// What the parser makes of a text, as the value the root returns, or `None` +/// for a text outside the domain: one serde decodes but the canonical JSON +/// parser rejects. +fn oracle(source: &str) -> Option { + let store = ArtifactStore::new(u64::MAX, u64::MAX); + let reason = match SemanticModule::parse(source, "1.2", "", &[], &BTreeMap::new(), &store) { + Ok(_) => None, + Err(failure) => Some(failure.reason), + }; + if let Some(reason) = &reason { + if reason.starts_with("invalid semantic-module JSON") { + return Some(decoded("DInvalid", Vec::new())); + } + if reason == "semantic-module JSON is not canonical" { + return Some(decoded("DNotCanonical", Vec::new())); + } + if let Some(rest) = reason.strip_prefix("semantic-module JSON member `") { + let path = rest + .strip_suffix("` is outside the closed schema") + .expect("the closed-schema rejection names a path"); + return Some(decoded("DOutside", vec![text(path)])); + } + Json::parse(source.as_bytes()).ok()?; + } + let module: SemanticModule = serde_json::from_str(source).expect("the parser decoded it"); + Some(decoded( + "DOk", + vec![ + text(&module.spec), + list(module.declarations.iter().map(enc_any).collect()), + ], + )) +} + +/// A run of a text in the domain, with the constructor of its outcome. +fn run(source: &str) -> Option<(Run, u64)> { + let outcome = oracle(source)?; + let constructor = match &outcome { + Value::Adt { constructor, .. } => *constructor, + _ => u64::MAX, + }; + Some(( + ( + vec![text(source)], + serde_json::to_value(outcome).expect("a value is JSON"), + ), + constructor, + )) +} + +// ---------------------------------------------------------------- the texts + +/// Every distinct semantic module of every committed project that links, as +/// its canonical JSON. +fn committed_modules() -> Vec { + let mut out = BTreeSet::new(); + for project in linked_projects() { + for module in project.modules.values() { + if let Some(semantic) = &module.semantic { + out.insert(canonical(semantic)); + } + } + } + out.into_iter().collect() +} + +fn module_value(spec: &str, declarations: Vec) -> Json2 { + serde_json::json!({ "spec": spec, "declarations": declarations }) +} + +fn canonical_text(value: &Json2) -> String { + canonical(value) +} + +fn example_modules(spec: &str) -> Vec { + (0..EXAMPLES) + .map(|step| { + module_value( + spec, + vec![ + serde_json::to_value(example_model_declaration(step)).expect("JSON"), + serde_json::to_value(example_reasoning_declaration(step)).expect("JSON"), + ], + ) + }) + .collect() +} + +/// A module of one definition whose body nests `levels` objects deep, so the +/// text nests `levels + 3` deep. +fn nested_module(spec: &str, levels: usize) -> String { + let mut body = serde_json::json!({ "kind": "var", "name": "x" }); + for _ in 1..levels { + body = serde_json::json!({ "kind": "not", "value": body }); + } + let declaration = serde_json::json!({ + "kind": "definition", + "name": "deep", + "parameters": [{ "name": "x", "type": { "kind": "bool" } }], + "result": { "kind": "bool" }, + "body": body, + }); + // `canonical` parses under serde's own nesting limit, so the deep text is + // written by hand: the members of each object are already sorted. + let mut text = String::from("{\"kind\":\"var\",\"name\":\"x\"}"); + for _ in 1..levels { + text = format!("{{\"kind\":\"not\",\"value\":{text}}}"); + } + let shell = canonical_text(&module_value( + spec, + vec![declaration_without_body(&declaration)], + )); + shell.replacen("\"body\":0", &format!("\"body\":{text}"), 1) +} + +fn declaration_without_body(declaration: &Json2) -> Json2 { + let mut out = declaration.clone(); + out["body"] = serde_json::json!(0); + out +} + +/// The JSON pointers of every object of a value, in document order. +fn objects(value: &Json2, pointer: &str, out: &mut Vec) { + match value { + Json2::Object(members) => { + out.push(pointer.to_owned()); + for (key, item) in members { + objects(item, &format!("{pointer}/{key}"), out); + } + } + Json2::Array(items) => { + for (index, item) in items.iter().enumerate() { + objects(item, &format!("{pointer}/{index}"), out); + } + } + _ => {} + } +} + +/// The mutations of one module: each a canonical text of a changed value, +/// and two texts out of canonical form. +fn mutations(base: &Json2) -> Vec { + let mut pointers = Vec::new(); + objects(base, "", &mut pointers); + let stride = pointers.len().div_ceil(MUTATED_OBJECTS).max(1); + let mut out = Vec::new(); + let mut changed = |change: &dyn Fn(&mut serde_json::Map), pointer: &str| { + let mut value = base.clone(); + let object = value + .pointer_mut(pointer) + .and_then(Json2::as_object_mut) + .expect("an object"); + change(object); + out.push(canonical_text(&value)); + }; + for pointer in pointers.iter().step_by(stride) { + let object = base + .pointer(pointer) + .and_then(Json2::as_object) + .expect("an object"); + for key in object.keys().take(REMOVED_MEMBERS) { + changed( + &|members| { + members.remove(key); + }, + pointer, + ); + } + for extra in [ + serde_json::json!(0), + serde_json::json!(false), + serde_json::json!([]), + ] { + changed( + &|members| { + members.insert("zz".to_owned(), extra.clone()); + }, + pointer, + ); + } + for (key, flag) in DEFAULTS { + if !object.contains_key(*key) { + let written = if *flag { + serde_json::json!(false) + } else { + serde_json::json!([]) + }; + changed( + &|members| { + members.insert((*key).to_owned(), written.clone()); + }, + pointer, + ); + } + } + if object.contains_key("kind") { + changed( + &|members| { + members.insert("kind".to_owned(), serde_json::json!("zz")); + }, + pointer, + ); + } + if let Some((key, _)) = object + .iter() + .find(|(key, item)| item.is_string() && key.as_str() != "kind") + { + changed( + &|members| { + members.insert(key.clone(), serde_json::json!(7)); + }, + pointer, + ); + } + if let Some((key, _)) = object.iter().find(|(_, item)| item.is_u64()) { + changed( + &|members| { + members.insert(key.clone(), serde_json::json!(-1)); + }, + pointer, + ); + changed( + &|members| { + members.insert(key.clone(), serde_json::json!("1")); + }, + pointer, + ); + } + if let Some((key, _)) = object.iter().find(|(_, item)| item.is_array()) { + changed( + &|members| { + members.insert(key.clone(), serde_json::json!({})); + }, + pointer, + ); + } + } + let text = canonical_text(base); + out.push(text.replacen(':', ": ", 1)); + out.push(format!(" {text}\n")); + out.push(text.replacen("\"spec\"", "\"\\u0073pec\"", 1)); + out.push(text.replacen("\"kind\":\"", "\"kind\":\"\\/", 1)); + // Repeated members: serde rejects a repeated field or tag. + for key in ["spec", "name", "kind"] { + let member = format!("\"{key}\":\""); + out.push(text.replacen(&member, &format!("{member}zz\",{member}"), 1)); + } + out.push(format!( + "{{\"spec\":{},\"declarations\":{}}}", + canonical_text(&base["spec"]), + canonical_text(&base["declarations"]) + )); + out +} + +// ------------------------------------------------------------------- plants + +/// Each plant weakens one decoding rule: its site, its replacement. +const PLANTS: &[(&str, &str, &str)] = &[ + ( + "serde's nesting limit is one level deeper", + "(127 true", + "| LexLeanStd.Json::Json.JNil => false", + ), + ( + "`false` is no omitted default", + "(if flag then false else true)", + "(if flag then false else false)", + ), + ( + "an unknown member is admitted", + "(if (listed allowed key) then", + "(if true then", + ), + ( + "a duplicate member is admitted", + "(if (listed (project state seen) key) then", + "(if false then", + ), + ( + "a negative count decodes", + "(if negative then (ctor Option.none [Nat])", + "(if false then (ctor Option.none [Nat])", + ), + ( + "the kind `definition` is misspelled", + "(prim equal tag (lit \"definition\") : Bool)", + "(prim equal tag (lit \"definitionx\") : Bool)", + ), + ( + "an array index is written in parentheses", + "(lit \"[\")", + "(lit \"(\")", + ), + ( + "whitespace between tokens is refused", + "(if (isSpace byte) then", + "(if false then", + ), + ( + "a `\\u` escape is refused", + "(if (letter =? 117) then (match (unicodeEscape text position)", + "(if false then (match (unicodeEscape text position)", + ), +]; + +fn plants(runs: &[Run]) -> usize { + let mut missed = Vec::new(); + for (label, site, replacement) in PLANTS { + let planted = support::P::bootstrap(); + let source = planted.read_raw("src/SemanticDecode.lex.tex"); + assert_eq!( + source.matches(site).count(), + 1, + "{label}: the plant site occurs once" + ); + planted.write( + "src/SemanticDecode.lex.tex", + &source.replacen(site, replacement, 1), + ); + let checked = support::checked_project(&planted); + let low = super::lower(&checked, &planted, MODULE, ROOTS[0].0); + match super::evaluate(&low, runs, 1).first() { + Some(first) => eprintln!( + "BS-73: plant detected: {label}: {}", + first.chars().take(120).collect::() + ), + None => missed.push((*label).to_owned()), + } + } + assert!( + missed.is_empty(), + "planted defects the runs do not detect: {missed:?}" + ); + PLANTS.len() +} + +fn export(lowered: &BTreeMap<&str, super::Lowered>) { + let exported = harness::exported("bootstrap"); + let bundle = exported.bundle(); + let mut realized = 0usize; + for exported_root in &exported.output.result.roots { + let Some((member, low)) = exported_root + .root + .strip_prefix(&format!("{MODULE}.")) + .and_then(|member| lowered.get(member).map(|low| (member, low))) + else { + continue; + }; + let largest = exported_root + .outputs + .iter() + .flat_map(|output| &output.certification.certificates) + .map(|certificate| certificate.file.byte_length) + .max() + .expect("a certificate"); + eprintln!( + "BS-73: {}: largest certificate part {largest} bytes", + exported_root.root + ); + assert!( + largest <= CERTIFICATE_BUDGET, + "{}: a certificate part of {largest} bytes is beyond {CERTIFICATE_BUDGET}", + exported_root.root + ); + for output in &exported_root.outputs { + let package: Json2 = serde_json::from_slice( + &std::fs::read( + bundle + .join(&output.package.directory) + .join("package.json") + .as_std_path(), + ) + .expect("package.json"), + ) + .expect("package JSON"); + assert_eq!( + package["program"], + serde_json::to_value(&low.program).expect("a program is JSON"), + "{member}: the exported package realizes the program the differential ran" + ); + realized += 1; + } + } + assert_eq!(realized, ROOTS.len(), "one certified package per root"); + let packages = harness::tree(&bundle.join("packages")); + let committed_packages = harness::tree(&harness::fixture_dir("bootstrap").join("packages")); + assert_eq!( + packages.keys().collect::>(), + committed_packages.keys().collect::>(), + "the exported package files are the committed ones" + ); + for (relative, content) in &packages { + assert!( + committed_packages.get(relative) == Some(content), + "packages/{relative} differs from the committed package" + ); + } +} + +pub(super) fn case() { + let started = std::time::Instant::now(); + let project = support::P::bootstrap(); + let checked_units = project.check_ok(); + assert!( + checked_units.units.contains_key("SemanticDecode"), + "SemanticDecode is a linked module of the project" + ); + eligibility_of(&project, "SemanticDecode", MODULE, &ROOTS); + + let committed = committed_modules(); + assert!( + committed.len() >= 100, + "the committed projects carry {} distinct semantic modules", + committed.len() + ); + let spec: String = serde_json::from_str::(&committed[0]).expect("JSON")["spec"] + .as_str() + .expect("a discriminator") + .to_owned(); + let examples = example_modules(&spec); + let small: Vec = committed + .iter() + .filter(|module| module.len() <= 2_048) + .take(20) + .map(|module| serde_json::from_str(module).expect("JSON")) + .collect(); + let mut texts: Vec = examples.iter().map(canonical_text).collect(); + texts.push(nested_module(&spec, 124)); + texts.push(nested_module(&spec, 125)); + let mut mutated = Vec::new(); + for base in examples.iter().take(10).chain(&small) { + mutated.extend(mutations(base)); + } + let distinct: BTreeSet = mutated.iter().cloned().collect(); + let classified: Vec<(Run, u64)> = texts + .iter() + .chain(&distinct) + .filter_map(|source| run(source)) + .collect(); + let outside = texts.len() + distinct.len() - classified.len(); + let mut by_outcome: BTreeMap = BTreeMap::new(); + for (_, constructor) in &classified { + *by_outcome.entry(*constructor).or_default() += 1; + } + let runs: Vec = classified.into_iter().map(|(run, _)| run).collect(); + let corpus: Vec = committed + .iter() + .filter_map(|source| run(source).map(|(run, _)| run)) + .collect(); + assert_eq!( + corpus.len(), + committed.len(), + "every committed module is in the domain" + ); + eprintln!( + "BS-73: {} committed modules, {} example and nested modules, {} distinct mutations, {} texts outside the domain, runs by outcome constructor {by_outcome:?} ({:?})", + committed.len(), + texts.len(), + distinct.len(), + outside, + started.elapsed() + ); + for constructor in ["DOk", "DInvalid", "DNotCanonical", "DOutside"] { + let index = constructors("Decoded") + .iter() + .position(|name| name == constructor) + .expect("a constructor"); + assert!( + by_outcome + .get(&u64::try_from(index).expect("an index")) + .copied() + .unwrap_or(0) + >= 2, + "the runs reach `{constructor}`" + ); + } + + let checked = support::checked_project(&project); + let root = ROOTS[0].0; + let lowered: BTreeMap<&str, super::Lowered> = + BTreeMap::from([(root, super::lower(&checked, &project, MODULE, root))]); + let normative = support::normative_host(); + if normative { + let mut evaluated = runs.clone(); + evaluated.extend( + committed + .iter() + .filter(|source| source.len() <= EVALUATOR_BYTES) + .filter_map(|source| run(source).map(|(run, _)| run)), + ); + let disagreements = super::evaluate(&lowered[root], &evaluated, 5); + assert!( + disagreements.is_empty(), + "{root} and the Rust oracle disagree: {disagreements:?}" + ); + eprintln!( + "BS-73: {root}: the evaluator agrees on {} runs ({:?})", + evaluated.len(), + started.elapsed() + ); + let planted = plants(&runs); + eprintln!( + "BS-73: {planted} planted defects detected ({:?})", + started.elapsed() + ); + } else { + eprintln!("BS-73: platform-bound host: the evaluator and the planted defects run on the normative host"); + } + + let mut compiled = runs; + compiled.extend(corpus); + let total = rustc_differential( + "BS-73", + &[(root, &lowered[root], compiled.as_slice())], + "oracle", + ); + eprintln!("BS-73: {total} rustc runs agree ({:?})", started.elapsed()); + + if !support::lean_backed("BS-73") { + return; + } + export(&lowered); + eprintln!("BS-73: passed in {:?}", started.elapsed()); +} diff --git a/crates/conformance/src/cases/bootstrap/semantic_reasoning.rs b/crates/conformance/src/cases/bootstrap/semantic_reasoning.rs index 006e66aac9..3ce9df865e 100755 --- a/crates/conformance/src/cases/bootstrap/semantic_reasoning.rs +++ b/crates/conformance/src/cases/bootstrap/semantic_reasoning.rs @@ -827,7 +827,7 @@ fn is_reasoning(declaration: &SemanticDeclaration) -> bool { !is_ordinary(declaration) && !is_model(declaration) } -fn enc_any(declaration: &SemanticDeclaration) -> Value { +pub(super) fn enc_any(declaration: &SemanticDeclaration) -> Value { if is_ordinary(declaration) { adt( "AnyDeclaration", diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index 96819c44e7..1f30094ab2 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -1091,7 +1091,7 @@ pub(crate) fn run(id: &str) { let model = repo_model::Model::load(&root.join("model").into_std_path_buf()) .expect("the model loads"); let table = spec_table(); - assert_eq!(table.len(), 504, "§31 has 504 rows"); + assert_eq!(table.len(), 505, "§31 has 505 rows"); assert_eq!(model.ids.id.len(), table.len(), "register row count"); for ((spec_id, spec_suite, spec_statement), row) in table.iter().zip(model.ids.id.iter()) diff --git a/crates/conformance/tests/conformance.rs b/crates/conformance/tests/conformance.rs index 0c1bac7219..1b99ac4061 100644 --- a/crates/conformance/tests/conformance.rs +++ b/crates/conformance/tests/conformance.rs @@ -2450,6 +2450,11 @@ fn conformance_bs_72() { repo_conformance::cases::run("BS-72"); } +#[test] +fn conformance_bs_73() { + repo_conformance::cases::run("BS-73"); +} + #[test] fn conformance_pk_01() { repo_conformance::cases::run("PK-01"); diff --git a/features/suites/bootstrap.feature b/features/suites/bootstrap.feature index d469f3567e..05c4919638 100644 --- a/features/suites/bootstrap.feature +++ b/features/suites/bootstrap.feature @@ -256,3 +256,9 @@ Feature: bootstrap When the project is checked and built, and the lowered program and the rendered package of each root are run on those inputs Then each root is eligible for rust-std with exactly its declared effects, no certificate part is beyond 3,145,728 bytes, and the two roots equal the canonical JSON of the serde form of the declaration and of `SemanticModule` on every run And every planted defect is detected by the first example that holds it, and the exported packages are byte-identical to the committed packages and realize the programs the differential ran + @BS-73 @build + Scenario: Decoding a semantic module of the semantic module language of SPEC.md §17.12 from its canonical JSON, as `ir::semantic::SemanticModule::parse` decodes it before it validates (serde's reading of the JSON text, with its whitespace, member order, and escapes, and its typed decoding of `SemanticModule` and every declaration, term, proof, and type it holds, with its rules for unknown, missing, duplicate, and defaulted members, tagged unit variants, and 128 levels of nesting; the comparison with the canonical form; and the closed schema, with the path of the first member outside it), is language-1.2 source in the `bootstrap/` project, as the production root `decodeSemanticModule` of `SemanticDecode`, its decoders generated from the description of the oracle's types that `BS-71` and `BS-72` write from, which returns the module's specification and declarations or which of the three decoding rejections the text meets first: eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and with no part of its certificate beyond 3,145,728 bytes; its rendered `rust-std` package under the pinned rustc, and on the normative host its lowered program under the calculus evaluator on the shorter modules, agree with the oracle on every distinct semantic module of every committed project that links, on modules of examples that reach every model, reasoning, and text variant, on modules nested to the deepest level serde admits and one level deeper, and on mutations of these modules that remove a member, repeat one, add an unknown one, write out an omitted default, rename a kind, change a value's type, or leave the canonical form, among texts the canonical JSON parser accepts or serde rejects first; each planted defect, a weakened decoding rule, is detected by those runs, and the certified packages the production export publishes for the project are the committed ones; validating a decoded module is outside the claim. + Given the committed `bootstrap` project, every semantic module of the committed projects that link, modules of examples that reach every model, reasoning, and text variant, modules nested to the deepest level serde admits and one level deeper, and mutations of these modules + When the project is checked and built, and the lowered program and the rendered package of the root are run on those texts + Then the root is eligible for rust-std with exactly its declared effects, no certificate part is beyond 3,145,728 bytes, and the root returns what `SemanticModule::parse` decodes or the decoding rejection it reports on every run + And every planted defect is detected by those runs, and the exported packages are byte-identical to the committed packages and realize the programs the differential ran diff --git a/model/ids.toml b/model/ids.toml index 598c68dd7c..f9006347a8 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -2942,6 +2942,12 @@ level = "build" suite = "bootstrap" statement = "The declarations of logics, inference rules, verifiers, reasoners, tokenizers, context windows, text generators, and text classifiers of the semantic module language of SPEC.md §17.12, and the semantic module of declarations of every kind (those variants of `ir::semantic::SemanticDeclaration`, with the invariants, bindings, answers, search orders, strategies, claims, tokenizer schemes, overflow dispositions, and generation policies they hold, and `SemanticModule`, in the serde form the linked IR embeds, written as canonical JSON: each tagged variant by its `kind`, each closed name as the oracle serializes it, each optional member left out exactly where the oracle's serde attributes skip it, and a module's specification and declarations in order, its ordinary declarations through `SemanticDecls` and its model declarations through `SemanticModels`) is language-1.2 source in the `bootstrap/` project, as two production roots of `SemanticReasoning`, generated with the case's encoders and examples from one description of the oracle's types: `reasoningDeclarationText` and `wholeSemanticModuleText`, each eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator on the shorter modules, agree with the oracle to the byte on examples that reach every variant, every optional member present and absent, and every list empty and not, on every distinct such declaration and every distinct semantic module of every committed project that links, and on seeded examples; each planted defect, a misspelled kind or name, is detected by the first example that holds it, and the certified packages the production export publishes for the project are the committed ones; reading declarations and modules from JSON is outside the claim." +[[id]] +id = "BS-73" +level = "build" +suite = "bootstrap" +statement = "Decoding a semantic module of the semantic module language of SPEC.md §17.12 from its canonical JSON, as `ir::semantic::SemanticModule::parse` decodes it before it validates (serde's reading of the JSON text, with its whitespace, member order, and escapes, and its typed decoding of `SemanticModule` and every declaration, term, proof, and type it holds, with its rules for unknown, missing, duplicate, and defaulted members, tagged unit variants, and 128 levels of nesting; the comparison with the canonical form; and the closed schema, with the path of the first member outside it), is language-1.2 source in the `bootstrap/` project, as the production root `decodeSemanticModule` of `SemanticDecode`, its decoders generated from the description of the oracle's types that `BS-71` and `BS-72` write from, which returns the module's specification and declarations or which of the three decoding rejections the text meets first: eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and with no part of its certificate beyond 3,145,728 bytes; its rendered `rust-std` package under the pinned rustc, and on the normative host its lowered program under the calculus evaluator on the shorter modules, agree with the oracle on every distinct semantic module of every committed project that links, on modules of examples that reach every model, reasoning, and text variant, on modules nested to the deepest level serde admits and one level deeper, and on mutations of these modules that remove a member, repeat one, add an unknown one, write out an omitted default, rename a kind, change a value's type, or leave the canonical form, among texts the canonical JSON parser accepts or serde rejects first; each planted defect, a weakened decoding rule, is detected by those runs, and the certified packages the production export publishes for the project are the committed ones; validating a decoded module is outside the claim." + [[id]] id = "PK-01" level = "build" diff --git a/tests/production-export/bootstrap/roots.json b/tests/production-export/bootstrap/roots.json index 3672f67f7a..66b5cd14dc 100644 --- a/tests/production-export/bootstrap/roots.json +++ b/tests/production-export/bootstrap/roots.json @@ -671,6 +671,14 @@ "rust-std" ], "version": "1.0.0" + }, + { + "name": "decode_semantic_module", + "root": "LexLeanBoot.SemanticDecode.decodeSemanticModule", + "targets": [ + "rust-std" + ], + "version": "1.0.0" } ] } diff --git a/tests/stack-bounds.json b/tests/stack-bounds.json index 3d711f6ee4..e66660ddc0 100644 --- a/tests/stack-bounds.json +++ b/tests/stack-bounds.json @@ -51,6 +51,9 @@ "bootstrap/dead_functions": { "debug": 5701632 }, + "bootstrap/declaration_text": { + "debug": 4521984 + }, "bootstrap/eq_key": { "debug": 1835008 }, @@ -66,6 +69,9 @@ "bootstrap/function_shells": { "debug": 3080192 }, + "bootstrap/linked_text": { + "debug": 4128768 + }, "bootstrap/loop_function": { "debug": 2818048 }, @@ -81,6 +87,12 @@ "bootstrap/lower_value_at": { "debug": 4390912 }, + "bootstrap/model_declaration_text": { + "debug": 5505024 + }, + "bootstrap/module_text": { + "debug": 4128768 + }, "bootstrap/node_count": { "debug": 1835008 }, @@ -102,9 +114,30 @@ "bootstrap/print_tooling_module": { "debug": 1179648 }, + "bootstrap/project_semantic_id": { + "debug": 4128768 + }, + "bootstrap/proof_text": { + "debug": 2097152 + }, + "bootstrap/reasoning_declaration_text": { + "debug": 6094848 + }, "bootstrap/render_tooling_latex": { "debug": 3342336 }, + "bootstrap/semantic_declaration_text": { + "debug": 6553600 + }, + "bootstrap/semantic_module_text": { + "debug": 16515072 + }, + "bootstrap/semantic_proof_text": { + "debug": 2162688 + }, + "bootstrap/semantic_term_text": { + "debug": 6553600 + }, "bootstrap/site_trees": { "debug": 6029312 }, @@ -117,6 +150,12 @@ "bootstrap/term_text": { "debug": 1835008 }, + "bootstrap/type_spelling": { + "debug": 1310720 + }, + "bootstrap/type_text": { + "debug": 1310720 + }, "bootstrap/use_trees": { "debug": 1572864 }, @@ -126,6 +165,9 @@ "bootstrap/validate_runtime": { "debug": 4259840 }, + "bootstrap/whole_semantic_module_text": { + "debug": 16580608 + }, "stdlib/write_json": { "debug": 1245184 }, diff --git a/xtask/src/spec_links.rs b/xtask/src/spec_links.rs index 9ac7d83ca8..3c79b6a78b 100644 --- a/xtask/src/spec_links.rs +++ b/xtask/src/spec_links.rs @@ -61,8 +61,8 @@ fn parse_table(spec: &str) -> Result, Fail> { pub fn validate(root: &Path) -> Result<(), Fail> { let spec = std::fs::read_to_string(root.join("SPEC.md"))?; let rows = parse_table(&spec)?; - if rows.len() != 504 { - return Err(format!("RP-07: the §31 table has {} rows, not 504", rows.len()).into()); + if rows.len() != 505 { + return Err(format!("RP-07: the §31 table has {} rows, not 505", rows.len()).into()); } // The prose total under the table is part of the contract a reader // relies on; a row added without it would leave §31 contradicting itself.