diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cb0fbdaa..de852172 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "UOR PrismPM SDK", - "image": "ghcr.io/afflom/prismpm-sdk-patched@sha256:c74e492aeac97208f83cfdddf40e1a43592b2280bd95f217255ac6bfbf7f8cd0", + "image": "ghcr.io/afflom/prismpm-sdk-patched@sha256:c1bfe8d5d3b3473a2c2ca6fdd417158a3e9f5fff3b24dcbf587fe21d6fd9b635", "containerUser": "root", "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind", "workspaceFolder": "${localWorkspaceFolder}", diff --git a/.github/workflows/certified.yml b/.github/workflows/certified.yml index e02c9ee3..2f520ef5 100644 --- a/.github/workflows/certified.yml +++ b/.github/workflows/certified.yml @@ -8,6 +8,14 @@ # commits (`just ratchet`), and the differential and fixpoint (`just # certified-gate`), whose outputs are compared by their κ, never by an exit # code. The last job requires both architectures' κ to be equal. +# +# On a branch, generate.yml dispatches this with land_branch only when it was +# itself dispatched there with `export` and the branch's translator has more +# uncertified functions than main's (no push to a pull request starts it): +# the export runs on the branch's head, the land takes it onto the branch +# merged onto main (scripts/ci/merge-main.sh) and pushes that merge to the +# branch (scripts/ci/push-branch.sh), never to main, then dispatches +# generate.yml on the branch, which regenerates and gates it. name: certified on: @@ -23,6 +31,11 @@ on: - 'Justfile' - '.github/workflows/certified.yml' workflow_dispatch: + inputs: + land_branch: + description: On a branch other than main, land the export on that branch as its merge onto main. + type: boolean + default: false permissions: contents: read @@ -31,8 +44,9 @@ permissions: # One run at a time, never cancelled: an export takes longer than main stays # still, so cancelling in progress meant no export ever finished. GitHub keeps # the newest waiting run; it runs next, on the newest main (as generate.yml). -# Each branch is its own queue, so a branch's export (which lands nothing) is -# never replaced by main's newer runs, nor holds them back. +# Each branch is its own queue, so a branch's export (which lands nothing +# unless it was dispatched with land_branch) is never replaced by main's +# newer runs, nor holds them back. concurrency: group: certified-${{ github.ref }} cancel-in-progress: false @@ -166,9 +180,11 @@ jobs: land: name: take the shards in and land the certified translator needs: [plan, export] - # Only main lands: a dispatch on another branch exports its shards for a - # local `just certified-sync` of that branch, and pushes nothing. - if: ${{ !cancelled() && needs.plan.result == 'success' && github.ref == 'refs/heads/main' }} + # main lands on main. A dispatch on another branch exports its shards for + # a local `just certified-sync` of that branch and pushes nothing, unless + # it was dispatched with land_branch: then it lands on that branch only + # (never a tag, never main). + if: ${{ !cancelled() && needs.plan.result == 'success' && (github.ref == 'refs/heads/main' || (inputs.land_branch && startsWith(github.ref, 'refs/heads/'))) }} runs-on: ubuntu-24.04 timeout-minutes: 60 permissions: @@ -192,6 +208,16 @@ jobs: with: pattern: shard-* path: target/uorust-certified + - name: Merge the branch onto main's head, where the sync takes the shards + if: github.ref != 'refs/heads/main' + shell: bash + env: + GH_TOKEN: ${{ github.token }} + BRANCH: ${{ github.ref_name }} + # A conflict in crates/certified takes main's: the sync rewrites it. + TAKE_CERTIFIED: '1' + # Status 2: the branch holds nothing main lacks, and nothing lands. + run: scripts/ci/merge-main.sh || [[ $? == 2 ]] - name: Take the shards into crates/certified through the locked SDK shell: bash run: scripts/ci/sdk.sh 'just certified-sync' @@ -220,6 +246,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} REBASE: '1' + BRANCH: ${{ github.ref_name }} INPUTS: 'crates/uorust/src/** crates/uorust/assets/** crates/uorust/Cargo.toml frontier.toml lift-verdicts.toml Cargo.lock rust-toolchain.toml prismpm.lock Justfile .github/workflows/certified.yml' run: scripts/ci/land-certified.sh "$((STARTED + LAND_BY_MINUTES * 60))" @@ -227,7 +254,9 @@ jobs: name: ratchet, differential and fixpoint / ${{ matrix.runner }} / run ${{ matrix.run }} needs: land # A shard that failed fails only its roots: the gate runs on what landed. - if: ${{ !cancelled() && needs.land.result == 'success' }} + # main's only: a branch's land is gated by the bootstrap run generate.yml + # dispatches on it, and its packages here when they land on main. + if: ${{ !cancelled() && needs.land.result == 'success' && github.ref == 'refs/heads/main' }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index dcdefa31..5f63ff51 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -9,6 +9,16 @@ # run re-decides the MIR path's translations (`uorust prove`) and publishes the # lift's honesty report: how many functions lifted, and the residue by the MIR # kind or obligation that stopped it. +# +# A branch of this repository gets the same writers only when a person +# dispatches this workflow on it (scripts/ci/generate-branch.sh): they run on +# the branch merged onto main, and what changed is pushed to the branch as +# that merge (first parent main), never to main or to a fork; the gate is +# dispatched on it, and the certified export too when `export` is given and +# the translator's uncertified functions outnumber main's. No push to a pull +# request starts it: these runs repeat every writer and every export whatever +# changed, so until each is an obligation keyed on its own inputs they are +# started on purpose, never by a push. name: generate on: @@ -17,7 +27,16 @@ on: # Hourly, so the brand follows uor.foundation without a push here. schedule: - cron: '41 * * * *' + # A dispatch on a branch (a person's, or certified.yml's land): gh workflow + # run generate.yml --ref , with -f export=true to also dispatch the + # certified export when the ratchet grows; the merge takes main's side of + # the generated files. workflow_dispatch: + inputs: + export: + description: On a branch other than main, also dispatch the certified export when the ratchet grows. + type: boolean + default: false permissions: contents: read @@ -26,8 +45,19 @@ permissions: # and only the newest of the pushes that land meanwhile runs next (GitHub # keeps one pending run per group). Cancelling in progress meant a steady # stream of pushes starved every run and nothing was ever regenerated. +# A pull request's branch is a queue of its own (its pushes and the runs +# dispatched on it), so it neither waits for main's nor replaces them. A +# pull request the job skips (from a fork, into another base, Dependabot's) +# gets a group of its own run, so it never replaces a branch's pending run. concurrency: - group: generate + group: >- + ${{ github.ref == 'refs/heads/main' && 'generate' || + (github.event_name == 'pull_request' && + (github.event.pull_request.head.repo.full_name != github.repository || + github.event.pull_request.base.ref != 'main' || + github.event.pull_request.user.login == 'dependabot[bot]')) && + format('generate-skipped-{0}', github.run_id) || + format('generate-branch-{0}', github.head_ref || github.ref_name) }} cancel-in-progress: false jobs: @@ -35,9 +65,19 @@ jobs: name: run every writer and push what changed runs-on: ubuntu-24.04 timeout-minutes: 120 + # Main; a pull request into main from a branch of this repository that a + # person (not Dependabot, whose token is read-only) opened; a dispatch. + if: >- + github.event_name != 'pull_request' || + (github.event.pull_request.head.repo.full_name == github.repository && + github.event.pull_request.base.ref == 'main' && + github.event.pull_request.user.login != 'dependabot[bot]') permissions: contents: write actions: write + env: + # What the writers write, which both steps commit. + WRITTEN: CONFORMANCE.md README.md app model brand crates xtask frontier.toml lift-verdicts.toml steps: - name: Check out the exact event revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 @@ -49,14 +89,28 @@ jobs: # main in this job (decided verdicts carry over), so what lands is # always the output of the tree it lands on and no push is lost. - name: Run every writer on main as it is, and push what changed + if: github.ref == 'refs/heads/main' shell: bash env: GH_TOKEN: ${{ github.token }} GENERATE_BUDGET: '4200' run: | scripts/ci/generate-loop.sh "Regenerate the generated files" \ - "CONFORMANCE.md README.md app model brand crates xtask frontier.toml lift-verdicts.toml" \ + "$WRITTEN" \ bootstrap.yml pages.yml certified.yml + # Never main: the scripts refuse BRANCH main, and push only to it. A + # dispatch on a tag runs neither step. + - name: Run every writer on the branch merged onto main, and push the merge to the branch + if: github.ref != 'refs/heads/main' && (github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/')) + shell: bash + env: + GH_TOKEN: ${{ github.token }} + BRANCH: ${{ github.head_ref || github.ref_name }} + EVENT: ${{ github.event_name }} + EXPORT: ${{ inputs.export == true }} + run: | + scripts/ci/generate-branch.sh "Regenerate the generated files" \ + "$WRITTEN" - name: Publish the lift's honesty report if: always() shell: bash diff --git a/.github/workflows/translator-pin.yml b/.github/workflows/translator-pin.yml index 9fd3da0b..61db3f5d 100644 --- a/.github/workflows/translator-pin.yml +++ b/.github/workflows/translator-pin.yml @@ -42,6 +42,9 @@ concurrency: jobs: pin: name: pin the translator holo app/ builds + # Not after a pull request's generate run: its head branch may be a + # fork's named main, which the branch filter above lets through. + if: github.event_name != 'workflow_run' || github.event.workflow_run.event != 'pull_request' runs-on: ubuntu-24.04 timeout-minutes: 90 permissions: diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 4fc5787d..b2a8473d 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -42,6 +42,12 @@ model does not sanction. | `UE-18` | `build` | The translator certifies itself: every function of uorust::mir, lift and lex the self register records as lifted is a production root of the self projection, `uorust certify production` exports them with `lexlean production build` (each root the compiler finds ineligible refused with its diagnostic) and replays the bundle with verify-artifact, `uorust certify sync` takes every certified package source into crates/certified byte for byte as the bundle records its SHA-256 with a manifest keying each root by the κ of the Rust function it certifies and the share of the translator reachable from the translate entry that is certified, a hand-written function runs its certified package in place of its body unless `--translator hand` is given, the core register and the self projection and register the certified and the hand-written translator write are required to have equal κ on amd64 and arm64, twice each, and a commit under which more translator functions are uncertified than under its parent is refused, naming each new one with its cause | | `UE-19` | `build` | Every body of core's MIR is embedded in LexLean: `uorust embed` writes each body, never refusing one, as a value of the MIR datatype that one fuel-indexed small-step evaluator over frames of values runs, with calls the linker resolves as data and a callee a trait bound leaves abstract named for the caller's dictionary; the constructs the evaluator does not define are read from its own source and every register row carries its embedding's digest and the constructs blocking it, ranked by the bodies they block; and core's stable scalar methods whose closure the evaluator defines are run on inputs drawn from their types' widths both by rustc's build of core and by the evaluator, a theorem per case that `lexlean verify` decides, so a disagreement fails naming its body | +## factory + +| ID | Level | Statement | +| --- | --- | --- | +| `UE-20` | `build` | The gate, the writers and the certified export are obligations of the upstream Prism factory installed under prism-factory/: its engine, standard library and identity protocol are upstream's at the revision prism-factory/upstream.toml names and an installed file that differs from what that record states is refused, the graph's one source is prism-factory/graph.toml with the Justfile's recipe bodies and a model text or table that differs from what graph.py writes from them is refused, no obligation reads the whole tree, one run in the SDK declares the lock that pins the image and the launcher, the certified plan routes each obligation proved, observe, refuted or blocked from receipts of its identity, a test target that names or a compiled source that embeds a tracked file its obligation does not declare is refused before the plan, each obligation runs in a closure that is its own repository whose parent holds exactly the base entries it declares, under a work directory no cargo or rustup configuration sits above, a command stopped by a signal leaves no receipt, and one run at a time holds the receipt store | + ## self-model | ID | Level | Statement | diff --git a/Justfile b/Justfile index 7d3c0a39..8b0bb0ec 100644 --- a/Justfile +++ b/Justfile @@ -202,15 +202,23 @@ certified-project: lexlean production targets --diagnostic-format json >crates/certified/targets.json # One export of the projection's roots, all of them or shard `I-N` (every Nth -# from the Ith), kept in target/uorust-certified for `certified-sync`. +# from the Ith), kept in target/uorust-certified for `certified-sync`. A root +# the prior manifest certified at its identity (the root's closure, the +# compiler, the descriptor, the project's configuration and linked packages) +# is carried from crates/certified byte for byte and never built again, once +# the project verifies: a build of this export that published verified it, or +# one verification with a single root marked does when none did. certified-export shard="" within="": rm -rf target/uorust-certify target/uorust-certified cargo run -q --locked -p uorust -- certify production --projection target/uorust-self --register frontier.toml --targets crates/certified/targets.json --out target/uorust-certify --kept target/uorust-certified --prior `ls target/certified-prior/manifest.toml 2>/dev/null || echo crates/certified/manifest.toml` --carry crates/certified {{ if within == "" { "" } else { "--within " + within } }} {{ if shard == "" { "" } else { "--shard " + replace_regex(shard, "-.*", "") + " --shards " + replace_regex(shard, ".*-", "") } }} # The shards a sharded export builds within `budget` seconds each, and the -# roots to diagnose, as JSON (certified.yml's plan job). +# roots to diagnose, as JSON (certified.yml's plan job), with the counts of +# roots carried, to build and refused. Without the self projection (the plan +# job has none) no identity is known: `carried` is null and every root not +# refused is planned as built. certified-plan budget: - cargo run -q --locked -p uorust -- certify plan --register frontier.toml --prior `ls target/certified-prior/manifest.toml 2>/dev/null || echo crates/certified/manifest.toml` --budget {{budget}} + cargo run -q --locked -p uorust -- certify plan --register frontier.toml --prior `ls target/certified-prior/manifest.toml 2>/dev/null || echo crates/certified/manifest.toml` --budget {{budget}} --carry crates/certified `test -d target/uorust-self && echo --projection target/uorust-self --targets crates/certified/targets.json || true` # Build one root alone and keep all lexlean prints of it in # target/certified-diagnose/build.log (certified.yml's diagnose job). @@ -294,6 +302,40 @@ certified-gate out="target/certified-gate": hooks: git config core.hooksPath scripts/hooks +# The factory (prism-factory/, the upstream Prism factory with this tool's +# graph): every part of the gate, every writer and the certified export is an +# obligation keyed on its declared inputs, and the certified core decides what +# is proved, what to run, what is refuted and what waits. These run on the +# machine that launches the SDK (prism-factory/sdk.sh), never inside it. +# FACTORY_RECEIPTS names the receipt store, a directory outside the worktree +# and the target directory, so receipts outlive both. + +# The factory-model obligation: the factory checks itself. +factory-model: + bash prism-factory/check.sh + +# The factory-upstream obligation: every installed file of prism-factory/ holds +# to upstream's at the revision prism-factory/upstream.toml names (it fetches it). +factory-upstream: + bash prism-factory/upstream.sh + +# Each obligation's route (proved, observe, refuted, blocked) and how many are left. +factory-plan: + prism-factory/factory.sh routes + +# Plan and run to the fixed point; a second run on the same tree runs nothing. +factory *only: + prism-factory/factory.sh run {{only}} + +# The same, detached: its log and its one-line status are kept beside the receipts. +factory-start *only: + prism-factory/factory.sh start {{only}} + +# The status of the last detached run: `running`, then `done ` or +# `interrupted ` and the counts; `stale` when its process is gone. +factory-status: + prism-factory/factory.sh status + # The content standard (scripts/content/standard.json) on an assembled site. content site="site": node scripts/content/enrich.mjs {{site}} diff --git a/app/src/Features.lex.tex b/app/src/Features.lex.tex index 643b4265..94240758 100644 --- a/app/src/Features.lex.tex +++ b/app/src/Features.lex.tex @@ -211,7 +211,7 @@ name: sourcesOfFeatures, parameters: [], result: (List Architecture::Source), - body: (cons (record Architecture::Source {record := "Features::callProject", path := "crates/uorust/src/main.rs", firstLine := 37, lastLine := 37, kappa := "c3b8885bfd1306a90c916b3f267289487ff750e69a70d64a846a06a337466c0e"}) (cons (record Architecture::Source {record := "Features::callProjectArguments", path := "crates/uorust/src/main.rs", firstLine := 379, lastLine := 408, kappa := "6b0aa0ec44938733d697a724ee99a679b73b4c352fdd8dc03cb68dcdea851e28"}) (cons (record Architecture::Source {record := "Features::callCheck", path := "crates/uorust/src/main.rs", firstLine := 39, lastLine := 39, kappa := "03ac534ece29b640314d385649de3bc8db0b719ca630180334b52c63754e212e"}) (cons (record Architecture::Source {record := "Features::callCheckArguments", path := "crates/uorust/src/main.rs", firstLine := 379, lastLine := 408, kappa := "6b0aa0ec44938733d697a724ee99a679b73b4c352fdd8dc03cb68dcdea851e28"}) (cons (record Architecture::Source {record := "Features::callRoutes", path := "crates/uorust/src/main.rs", firstLine := 75, lastLine := 75, kappa := "bec54c48be6c79a9880c0ace354baedbdc6f9039f3a8beeb88d72aae43ba3540"}) (cons (record Architecture::Source {record := "Features::callProjectWorkspace", path := "crates/uorust/src/lib.rs", firstLine := 49, lastLine := 49, kappa := "5b71df4e2cdc2983559ebad13b2b2a0eb1cef2f7ca5e50d8007f20f4edd32a86"}) (cons (record Architecture::Source {record := "Features::callRespond", path := "crates/uorust/src/route.rs", firstLine := 174, lastLine := 174, kappa := "d5c81a5b9f7a216f5bdf3d9ad4fa9d0dd36bf76df524ffa1e0e0d3a58d67f2a7"}) (cons (record Architecture::Source {record := "Features::acceptFixtureProjection", path := "model/ids.toml", firstLine := 65, lastLine := 65, kappa := "1c8113fdacb2b2ffc506ce327e49490b16e477b18191898b0933a8af0828b467"}) (cons (record Architecture::Source {record := "Features::acceptByteIdentical", path := "model/ids.toml", firstLine := 71, lastLine := 71, kappa := "ce3be3630d5760e4a82917cf2acd16fcb5068e52a2a4c05c3fc3e345e3d0b50f"}) (cons (record Architecture::Source {record := "Features::acceptTypedRefusals", path := "model/ids.toml", firstLine := 77, lastLine := 77, kappa := "5206d14ea60610b613787466024ceb31fe6940986c13d048cab8512308544a00"}) (cons (record Architecture::Source {record := "Features::acceptLift", path := "model/ids.toml", firstLine := 83, lastLine := 83, kappa := "d6ab6ce3b646e0e917e8e07fdf5024ca5274ad31ca167e4722b7f5cd57455de9"}) (cons (record Architecture::Source {record := "Features::acceptRouterConformance", path := "model/ids.toml", firstLine := 89, lastLine := 89, kappa := "bf2efbd58853ca2d8fee835c8387a66d1bb808466f63653f987c609dbb085421"}) (cons (record Architecture::Source {record := "Features::acceptTypedErrors", path := "model/ids.toml", firstLine := 95, lastLine := 95, kappa := "6f685a89e1a12e4d8f2800fa31df1adb8cc5c908d7bbf613e5abcbee258269a7"}) (cons (record Architecture::Source {record := "Features::acceptGate", path := "model/ids.toml", firstLine := 101, lastLine := 101, kappa := "5363e5d42c2234eace3c908143bdd675a8f34840aca2db7f2fb15a0cb747f3fe"}) (cons (record Architecture::Source {record := "Features::acceptRouteTheorems", path := "model/ids.toml", firstLine := 35, lastLine := 35, kappa := "028b8912c2d3362c8314f39ee4ea24420c0d9e4afe99adf0070be28e9f8ed74e"}) (cons (record Architecture::Source {record := "Features::featureProjectWorkspace", path := "crates/uorust/src/main.rs", firstLine := 36, lastLine := 36, kappa := "b0bd9684bd1ada3329ee1163494e43d94c5b7d00b4a518731a812893ee5cdbdb"}) (cons (record Architecture::Source {record := "Features::featureCheckProjection", path := "crates/uorust/src/main.rs", firstLine := 38, lastLine := 38, kappa := "14005137188e019ebac2db5ce52d803f9013f71fce1df16651ad71ea6ae5e27d"}) (cons (record Architecture::Source {record := "Features::featureRouteFacts", path := "crates/uorust/src/route.rs", firstLine := 1, lastLine := 2, kappa := "8e418eb8172505eb52f82e9275238ce6d3d274396e28bbc08acb1477d19663e1"}) (cons (record Architecture::Source {record := "Features::featureRefuseAmbiguity", path := "crates/uorust/src/admit.rs", firstLine := 1, lastLine := 2, kappa := "5738d758bec2b4cb7b803984d07daa63b11a36c4806a2f0f154ad486b63050f0"}) (cons (record Architecture::Source {record := "Features::featureLiftBehavior", path := "crates/uorust/src/lift.rs", firstLine := 1, lastLine := 1, kappa := "5abb1e3b8d573e2c0ccab24f3c1b1e69d0003c1b424229f80c90b4464bf07e75"}) (cons (record Architecture::Source {record := "Features::featureDeterministicOutput", path := "model/ids.toml", firstLine := 71, lastLine := 71, kappa := "ce3be3630d5760e4a82917cf2acd16fcb5068e52a2a4c05c3fc3e345e3d0b50f"}) (cons (record Architecture::Source {record := "Features::featureTypedErrors", path := "model/ids.toml", firstLine := 95, lastLine := 95, kappa := "6f685a89e1a12e4d8f2800fa31df1adb8cc5c908d7bbf613e5abcbee258269a7"}) (cons (record Architecture::Source {record := "Features::featureCheckedOutput", path := "model/ids.toml", firstLine := 101, lastLine := 101, kappa := "5363e5d42c2234eace3c908143bdd675a8f34840aca2db7f2fb15a0cb747f3fe"}) (cons (record Architecture::Source {record := "Features::featureSelfModel", path := "model/ids.toml", firstLine := 41, lastLine := 41, kappa := "22c1f30dba6208761f33364074c6cf4adad1c19ea2f0d324bba811e0e48d119d"}) (cons (record Architecture::Source {record := "Features::featureBrowserRoutes", path := "model/ids.toml", firstLine := 29, lastLine := 29, kappa := "693e628b7754ec4e9d7aa9ffed21a4e5f616b8ab4b173444768f6b4eccbc187a"}) (nil Architecture::Source)))))))))))))))))))))))))) + body: (cons (record Architecture::Source {record := "Features::callProject", path := "crates/uorust/src/main.rs", firstLine := 37, lastLine := 37, kappa := "c3b8885bfd1306a90c916b3f267289487ff750e69a70d64a846a06a337466c0e"}) (cons (record Architecture::Source {record := "Features::callProjectArguments", path := "crates/uorust/src/main.rs", firstLine := 492, lastLine := 521, kappa := "6b0aa0ec44938733d697a724ee99a679b73b4c352fdd8dc03cb68dcdea851e28"}) (cons (record Architecture::Source {record := "Features::callCheck", path := "crates/uorust/src/main.rs", firstLine := 39, lastLine := 39, kappa := "03ac534ece29b640314d385649de3bc8db0b719ca630180334b52c63754e212e"}) (cons (record Architecture::Source {record := "Features::callCheckArguments", path := "crates/uorust/src/main.rs", firstLine := 492, lastLine := 521, kappa := "6b0aa0ec44938733d697a724ee99a679b73b4c352fdd8dc03cb68dcdea851e28"}) (cons (record Architecture::Source {record := "Features::callRoutes", path := "crates/uorust/src/main.rs", firstLine := 75, lastLine := 75, kappa := "bec54c48be6c79a9880c0ace354baedbdc6f9039f3a8beeb88d72aae43ba3540"}) (cons (record Architecture::Source {record := "Features::callProjectWorkspace", path := "crates/uorust/src/lib.rs", firstLine := 50, lastLine := 50, kappa := "5b71df4e2cdc2983559ebad13b2b2a0eb1cef2f7ca5e50d8007f20f4edd32a86"}) (cons (record Architecture::Source {record := "Features::callRespond", path := "crates/uorust/src/route.rs", firstLine := 174, lastLine := 174, kappa := "d5c81a5b9f7a216f5bdf3d9ad4fa9d0dd36bf76df524ffa1e0e0d3a58d67f2a7"}) (cons (record Architecture::Source {record := "Features::acceptFixtureProjection", path := "model/ids.toml", firstLine := 65, lastLine := 65, kappa := "1c8113fdacb2b2ffc506ce327e49490b16e477b18191898b0933a8af0828b467"}) (cons (record Architecture::Source {record := "Features::acceptByteIdentical", path := "model/ids.toml", firstLine := 71, lastLine := 71, kappa := "ce3be3630d5760e4a82917cf2acd16fcb5068e52a2a4c05c3fc3e345e3d0b50f"}) (cons (record Architecture::Source {record := "Features::acceptTypedRefusals", path := "model/ids.toml", firstLine := 77, lastLine := 77, kappa := "5206d14ea60610b613787466024ceb31fe6940986c13d048cab8512308544a00"}) (cons (record Architecture::Source {record := "Features::acceptLift", path := "model/ids.toml", firstLine := 83, lastLine := 83, kappa := "d6ab6ce3b646e0e917e8e07fdf5024ca5274ad31ca167e4722b7f5cd57455de9"}) (cons (record Architecture::Source {record := "Features::acceptRouterConformance", path := "model/ids.toml", firstLine := 89, lastLine := 89, kappa := "bf2efbd58853ca2d8fee835c8387a66d1bb808466f63653f987c609dbb085421"}) (cons (record Architecture::Source {record := "Features::acceptTypedErrors", path := "model/ids.toml", firstLine := 95, lastLine := 95, kappa := "6f685a89e1a12e4d8f2800fa31df1adb8cc5c908d7bbf613e5abcbee258269a7"}) (cons (record Architecture::Source {record := "Features::acceptGate", path := "model/ids.toml", firstLine := 101, lastLine := 101, kappa := "5363e5d42c2234eace3c908143bdd675a8f34840aca2db7f2fb15a0cb747f3fe"}) (cons (record Architecture::Source {record := "Features::acceptRouteTheorems", path := "model/ids.toml", firstLine := 35, lastLine := 35, kappa := "028b8912c2d3362c8314f39ee4ea24420c0d9e4afe99adf0070be28e9f8ed74e"}) (cons (record Architecture::Source {record := "Features::featureProjectWorkspace", path := "crates/uorust/src/main.rs", firstLine := 36, lastLine := 36, kappa := "b0bd9684bd1ada3329ee1163494e43d94c5b7d00b4a518731a812893ee5cdbdb"}) (cons (record Architecture::Source {record := "Features::featureCheckProjection", path := "crates/uorust/src/main.rs", firstLine := 38, lastLine := 38, kappa := "14005137188e019ebac2db5ce52d803f9013f71fce1df16651ad71ea6ae5e27d"}) (cons (record Architecture::Source {record := "Features::featureRouteFacts", path := "crates/uorust/src/route.rs", firstLine := 1, lastLine := 2, kappa := "8e418eb8172505eb52f82e9275238ce6d3d274396e28bbc08acb1477d19663e1"}) (cons (record Architecture::Source {record := "Features::featureRefuseAmbiguity", path := "crates/uorust/src/admit.rs", firstLine := 1, lastLine := 2, kappa := "5738d758bec2b4cb7b803984d07daa63b11a36c4806a2f0f154ad486b63050f0"}) (cons (record Architecture::Source {record := "Features::featureLiftBehavior", path := "crates/uorust/src/lift.rs", firstLine := 1, lastLine := 1, kappa := "5abb1e3b8d573e2c0ccab24f3c1b1e69d0003c1b424229f80c90b4464bf07e75"}) (cons (record Architecture::Source {record := "Features::featureDeterministicOutput", path := "model/ids.toml", firstLine := 71, lastLine := 71, kappa := "ce3be3630d5760e4a82917cf2acd16fcb5068e52a2a4c05c3fc3e345e3d0b50f"}) (cons (record Architecture::Source {record := "Features::featureTypedErrors", path := "model/ids.toml", firstLine := 95, lastLine := 95, kappa := "6f685a89e1a12e4d8f2800fa31df1adb8cc5c908d7bbf613e5abcbee258269a7"}) (cons (record Architecture::Source {record := "Features::featureCheckedOutput", path := "model/ids.toml", firstLine := 101, lastLine := 101, kappa := "5363e5d42c2234eace3c908143bdd675a8f34840aca2db7f2fb15a0cb747f3fe"}) (cons (record Architecture::Source {record := "Features::featureSelfModel", path := "model/ids.toml", firstLine := 41, lastLine := 41, kappa := "22c1f30dba6208761f33364074c6cf4adad1c19ea2f0d324bba811e0e48d119d"}) (cons (record Architecture::Source {record := "Features::featureBrowserRoutes", path := "model/ids.toml", firstLine := 29, lastLine := 29, kappa := "693e628b7754ec4e9d7aa9ffed21a4e5f616b8ab4b173444768f6b4eccbc187a"}) (nil Architecture::Source)))))))))))))))))))))))))) } \end{semanticmodule} \end{lexlean} diff --git a/app/src/Quality.lex.tex b/app/src/Quality.lex.tex index 68733164..a35bccde 100644 --- a/app/src/Quality.lex.tex +++ b/app/src/Quality.lex.tex @@ -489,7 +489,7 @@ name: certifiedShare, parameters: [], result: CertifiedShare, - body: (record CertifiedShare {translator := 666, certified := 151, reachable := 0, reachableCertified := 0}) + body: (record CertifiedShare {translator := 675, certified := 167, reachable := 0, reachableCertified := 0}) } definition{ @@ -524,7 +524,7 @@ name: sourcesOfMeasures, parameters: [], result: (List Architecture::Source), - body: (cons (record Architecture::Source {record := "Quality::measureRoutedFactKinds", path := "model/routes.toml", firstLine := 42, lastLine := 249, kappa := "9c16688c0cc26c204bfac4e7016c149a3c6b3d5f2e4ddab9b49e2728e8878ca4"}) (cons (record Architecture::Source {record := "Quality::measureRouteVectors", path := "model/routes.toml", firstLine := 250, lastLine := 453, kappa := "9137d82a387d756967c8eddd89c978a414260dec23b36e4f2b6af22c41d5f730"}) (cons (record Architecture::Source {record := "Quality::measureMinimumRustMinor", path := "Cargo.toml", firstLine := 9, lastLine := 9, kappa := "e3391fe6467f403d0d0a6eae90ad847f2bd724d8043b3c21d24130b82c9dffec"}) (cons (record Architecture::Source {record := "Quality::measureSelfProjectionMillisecondsComparator", path := "model/comparators.toml", firstLine := 19, lastLine := 25, kappa := "54d5395492e9cfb0d7ec1eccdeb47c8834e1dbc018a80aa486aab455adfc788f"}) (cons (record Architecture::Source {record := "Quality::measureSelfProjectionMillisecondsObservation", path := "model/comparators.toml", firstLine := 27, lastLine := 33, kappa := "46b07a8e4b08a8d3055ef72bdab55ebc3c38a9bf512f561cf1bdf16edd6676f7"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/core/frontier.toml", firstLine := 2382, lastLine := 7884, kappa := "a286dd065bacdc3ebc04cd57904b7ee15ce531fef18063fb51c8db7bd0cebd5c"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/autocfg/frontier.toml", firstLine := 39, lastLine := 101, kappa := "7a61f0cac885f32b7b9a27f8ff62171fab44ead78225b5aabbdfca0112054a3a"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/base64/frontier.toml", firstLine := 63, lastLine := 281, kappa := "d7be96e18055a9cabce497639e8f3859acf56085cd22ef5d985750eb513089bf"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/bitflags/frontier.toml", firstLine := 34, lastLine := 96, kappa := "8ff501cd03a9dd7785483316b75b6a5dd0ad64c9c44feb7cd65eee1b67aee7ae"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/cc/frontier.toml", firstLine := 69, lastLine := 483, kappa := "997c7e91a77884f80b7f76005aa7b87b89854c4ea0770b0f9ca7159d15d55f2e"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/getrandom/frontier.toml", firstLine := 39, lastLine := 93, kappa := "52652693bb0c0385fbc448a09038c4a45209a06413954b0b8fc4e75d4facd093"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/hashbrown/frontier.toml", firstLine := 78, lastLine := 580, kappa := "190655e36269a994bdbdb83050c19d77740d6525157ac3e2ce3aca009a677bfa"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/heck/frontier.toml", firstLine := 64, lastLine := 118, kappa := "252cf050ae22c8cf1034bc2a6634f0db8e538e7ec8ad68c0d4c2f648582ea8ab"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/indexmap/frontier.toml", firstLine := 44, lastLine := 314, kappa := "7b88c0eac8a2e12b6ebbfce8f5a8eeba5c7f1e28ad4e1b0610c92abe00288a29"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/itertools/frontier.toml", firstLine := 259, lastLine := 1281, kappa := "f867b63ef3b5e7694656f7cba001aa7b80c7833a08cfcc2e153143a1ab88b9f5"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/itoa/frontier.toml", firstLine := 29, lastLine := 71, kappa := "14169946832e790b15e564ad2d026482e6b514ccb4b5e1b57961b2cbbfd24c9c"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/libc/frontier.toml", firstLine := 38, lastLine := 1964, kappa := "7565eec92ed0c9fe962057d4fb4844b09291111a8aa7fe426b84c8135845fb40"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/log/frontier.toml", firstLine := 29, lastLine := 127, kappa := "f8400bcdacfbf5bf8b600ec393dbe693ac02d98b410e164d0fa8f3fa57242e84"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/memchr/frontier.toml", firstLine := 53, lastLine := 675, kappa := "609e1895aca4ff592ac767862c9b2d14223c66c8d4e64ea660a9dca0f5950c22"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/once_cell/frontier.toml", firstLine := 39, lastLine := 149, kappa := "d4f9712f12b9b7baed22a1ac14a7ff5aeeda56c14342ca7f57fb08c3ea6788de"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/proc-macro2/frontier.toml", firstLine := 69, lastLine := 379, kappa := "214b58a1a0ac96f6f18da8cba71240d19dcbdf20bf073f02a7e3f73f8071aab1"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/quote/frontier.toml", firstLine := 44, lastLine := 142, kappa := "293536b554f3724a81fd3f97be56df38cec6fcf48aa7540d83c55f4bb00c4917"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/rand/frontier.toml", firstLine := 52, lastLine := 670, kappa := "136d42b5d4102ef013db3beddf039dfdda068bc0f07751aac781b78226f57a7b"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/rand_chacha/frontier.toml", firstLine := 29, lastLine := 139, kappa := "441bc1e20389826e5529d1f58370dd74dfbacf63d8e4c13aad3e8fd2fa097ab3"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/rand_core/frontier.toml", firstLine := 49, lastLine := 135, kappa := "356fd53829b7ffcf9528c4749ee536f8b38eccb37013bd57333313dd49203a9f"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/regex-syntax/frontier.toml", firstLine := 78, lastLine := 836, kappa := "3d83e5ea9ed6f95bc2cf808e2a15d93d31608c356407306015683cefa573bf6e"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/serde/frontier.toml", firstLine := 24, lastLine := 334, kappa := "23d17d983a087b60ffe51244e9e4198becbc91921808df6068ce45aae3c23b44"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/serde_derive/frontier.toml", firstLine := 74, lastLine := 336, kappa := "b054b8eec1df09062c1f52b26208f24fb2f3e20f9ce6c80678e00f380d560eb1"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/serde_json/frontier.toml", firstLine := 63, lastLine := 361, kappa := "18ae413ed54bb401b044f0139999d34e667bb4946f26889ea33eecd2e6a9116e"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/syn/frontier.toml", firstLine := 198, lastLine := 2096, kappa := "d6c58cffd5729fd3af2509a78dbb1c9c767ef1810f54000ed05b0c9a7e51fbaa"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/thiserror/frontier.toml", firstLine := 39, lastLine := 53, kappa := "e8beac0eec7a1f9667f5d2ab7e55c321d18e5f05c90a05786d2998874a79c3ea"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/thiserror-impl/frontier.toml", firstLine := 79, lastLine := 229, kappa := "9c4a918d12e1cbc3bbcaf5ce3825a8386ecdb10771af37e21170419cb49ebb79"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/unicode-ident/frontier.toml", firstLine := 29, lastLine := 31, kappa := "c52922c0e4396c336a20565a3784101d2ac5c4453bd097b7889ac45d2a518aed"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/windows-sys/frontier.toml", firstLine := 24, lastLine := 34, kappa := "9e21d35bc069fbade32785a2304884e6cae4862d8167faa524e7ffa28cf8750f"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/std/frontier.toml", firstLine := 268, lastLine := 3598, kappa := "0610dbc12a984796f76a5dfcdd8f6061f4b918100618eaf308161b59c157cef6"}) (cons (record Architecture::Source {record := "Quality::certifiedShare", path := "crates/certified/manifest.toml", firstLine := 10, lastLine := 14, kappa := "257f12d4b5b12a35cb7ca3ae1dc36045c9370f3d88d67e3870d8a886769c3397"}) (nil Architecture::Source))))))))))))))))))))))))))))))))))))) + body: (cons (record Architecture::Source {record := "Quality::measureRoutedFactKinds", path := "model/routes.toml", firstLine := 42, lastLine := 249, kappa := "9c16688c0cc26c204bfac4e7016c149a3c6b3d5f2e4ddab9b49e2728e8878ca4"}) (cons (record Architecture::Source {record := "Quality::measureRouteVectors", path := "model/routes.toml", firstLine := 250, lastLine := 453, kappa := "9137d82a387d756967c8eddd89c978a414260dec23b36e4f2b6af22c41d5f730"}) (cons (record Architecture::Source {record := "Quality::measureMinimumRustMinor", path := "Cargo.toml", firstLine := 9, lastLine := 9, kappa := "e3391fe6467f403d0d0a6eae90ad847f2bd724d8043b3c21d24130b82c9dffec"}) (cons (record Architecture::Source {record := "Quality::measureSelfProjectionMillisecondsComparator", path := "model/comparators.toml", firstLine := 19, lastLine := 25, kappa := "54d5395492e9cfb0d7ec1eccdeb47c8834e1dbc018a80aa486aab455adfc788f"}) (cons (record Architecture::Source {record := "Quality::measureSelfProjectionMillisecondsObservation", path := "model/comparators.toml", firstLine := 27, lastLine := 33, kappa := "46b07a8e4b08a8d3055ef72bdab55ebc3c38a9bf512f561cf1bdf16edd6676f7"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/core/frontier.toml", firstLine := 2382, lastLine := 7884, kappa := "a286dd065bacdc3ebc04cd57904b7ee15ce531fef18063fb51c8db7bd0cebd5c"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/autocfg/frontier.toml", firstLine := 39, lastLine := 101, kappa := "7a61f0cac885f32b7b9a27f8ff62171fab44ead78225b5aabbdfca0112054a3a"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/base64/frontier.toml", firstLine := 63, lastLine := 281, kappa := "d7be96e18055a9cabce497639e8f3859acf56085cd22ef5d985750eb513089bf"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/bitflags/frontier.toml", firstLine := 34, lastLine := 96, kappa := "8ff501cd03a9dd7785483316b75b6a5dd0ad64c9c44feb7cd65eee1b67aee7ae"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/cc/frontier.toml", firstLine := 69, lastLine := 483, kappa := "997c7e91a77884f80b7f76005aa7b87b89854c4ea0770b0f9ca7159d15d55f2e"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/getrandom/frontier.toml", firstLine := 39, lastLine := 93, kappa := "52652693bb0c0385fbc448a09038c4a45209a06413954b0b8fc4e75d4facd093"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/hashbrown/frontier.toml", firstLine := 78, lastLine := 580, kappa := "190655e36269a994bdbdb83050c19d77740d6525157ac3e2ce3aca009a677bfa"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/heck/frontier.toml", firstLine := 64, lastLine := 118, kappa := "252cf050ae22c8cf1034bc2a6634f0db8e538e7ec8ad68c0d4c2f648582ea8ab"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/indexmap/frontier.toml", firstLine := 44, lastLine := 314, kappa := "7b88c0eac8a2e12b6ebbfce8f5a8eeba5c7f1e28ad4e1b0610c92abe00288a29"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/itertools/frontier.toml", firstLine := 259, lastLine := 1281, kappa := "f867b63ef3b5e7694656f7cba001aa7b80c7833a08cfcc2e153143a1ab88b9f5"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/itoa/frontier.toml", firstLine := 29, lastLine := 71, kappa := "14169946832e790b15e564ad2d026482e6b514ccb4b5e1b57961b2cbbfd24c9c"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/libc/frontier.toml", firstLine := 38, lastLine := 1964, kappa := "7565eec92ed0c9fe962057d4fb4844b09291111a8aa7fe426b84c8135845fb40"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/log/frontier.toml", firstLine := 29, lastLine := 127, kappa := "f8400bcdacfbf5bf8b600ec393dbe693ac02d98b410e164d0fa8f3fa57242e84"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/memchr/frontier.toml", firstLine := 53, lastLine := 675, kappa := "609e1895aca4ff592ac767862c9b2d14223c66c8d4e64ea660a9dca0f5950c22"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/once_cell/frontier.toml", firstLine := 39, lastLine := 149, kappa := "d4f9712f12b9b7baed22a1ac14a7ff5aeeda56c14342ca7f57fb08c3ea6788de"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/proc-macro2/frontier.toml", firstLine := 69, lastLine := 379, kappa := "214b58a1a0ac96f6f18da8cba71240d19dcbdf20bf073f02a7e3f73f8071aab1"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/quote/frontier.toml", firstLine := 44, lastLine := 142, kappa := "293536b554f3724a81fd3f97be56df38cec6fcf48aa7540d83c55f4bb00c4917"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/rand/frontier.toml", firstLine := 52, lastLine := 670, kappa := "136d42b5d4102ef013db3beddf039dfdda068bc0f07751aac781b78226f57a7b"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/rand_chacha/frontier.toml", firstLine := 29, lastLine := 139, kappa := "441bc1e20389826e5529d1f58370dd74dfbacf63d8e4c13aad3e8fd2fa097ab3"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/rand_core/frontier.toml", firstLine := 49, lastLine := 135, kappa := "356fd53829b7ffcf9528c4749ee536f8b38eccb37013bd57333313dd49203a9f"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/regex-syntax/frontier.toml", firstLine := 78, lastLine := 836, kappa := "3d83e5ea9ed6f95bc2cf808e2a15d93d31608c356407306015683cefa573bf6e"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/serde/frontier.toml", firstLine := 24, lastLine := 334, kappa := "23d17d983a087b60ffe51244e9e4198becbc91921808df6068ce45aae3c23b44"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/serde_derive/frontier.toml", firstLine := 74, lastLine := 336, kappa := "b054b8eec1df09062c1f52b26208f24fb2f3e20f9ce6c80678e00f380d560eb1"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/serde_json/frontier.toml", firstLine := 63, lastLine := 361, kappa := "18ae413ed54bb401b044f0139999d34e667bb4946f26889ea33eecd2e6a9116e"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/syn/frontier.toml", firstLine := 198, lastLine := 2096, kappa := "d6c58cffd5729fd3af2509a78dbb1c9c767ef1810f54000ed05b0c9a7e51fbaa"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/thiserror/frontier.toml", firstLine := 39, lastLine := 53, kappa := "e8beac0eec7a1f9667f5d2ab7e55c321d18e5f05c90a05786d2998874a79c3ea"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/thiserror-impl/frontier.toml", firstLine := 79, lastLine := 229, kappa := "9c4a918d12e1cbc3bbcaf5ce3825a8386ecdb10771af37e21170419cb49ebb79"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/unicode-ident/frontier.toml", firstLine := 29, lastLine := 31, kappa := "c52922c0e4396c336a20565a3784101d2ac5c4453bd097b7889ac45d2a518aed"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/crates/windows-sys/frontier.toml", firstLine := 24, lastLine := 34, kappa := "9e21d35bc069fbade32785a2304884e6cae4862d8167faa524e7ffa28cf8750f"}) (cons (record Architecture::Source {record := "Quality::liftCauses", path := "crates/uorust/std/frontier.toml", firstLine := 268, lastLine := 3598, kappa := "0610dbc12a984796f76a5dfcdd8f6061f4b918100618eaf308161b59c157cef6"}) (cons (record Architecture::Source {record := "Quality::certifiedShare", path := "crates/certified/manifest.toml", firstLine := 11, lastLine := 15, kappa := "25f07d8caecfa9166055395b1ebbc1f5a897a9d7e9e7679703d3103d612d42b5"}) (nil Architecture::Source))))))))))))))))))))))))))))))))))))) } \end{semanticmodule} \end{lexlean} diff --git a/app/src/Security.lex.tex b/app/src/Security.lex.tex index 91383473..fae8d9f2 100644 --- a/app/src/Security.lex.tex +++ b/app/src/Security.lex.tex @@ -600,7 +600,7 @@ name: modeledControlNoBuildExecution, parameters: [], result: Production.ThreatModel::ModeledControl, - body: (record Production.ThreatModel::ModeledControl {control := "Security::controlNoBuildExecution", name := "No build of the subject but its MIR dump", text := "uorust project, check and prove read the workspace through cargo metadata and syn only and never compile the subject; uorust mir alone compiles it with cargo, running its build scripts and macros as any build of it does, to dump the MIR the lift translates, and it is run only on a workspace the reviewer would build.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "crates/uorust/src/ingest.rs:580 let parsed = match syn::parse_file(&text) {"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "crates/uorust/src/mir/mod.rs:212 .map_err(|e| tool(\"cargo rustc\", e.to_string()))?;"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "UE-01: uorust projects the fixture workspace into exactly the committed Prism project, which lexlean fmt, lexlean lock and prismpm check accept"}) (nil Production.ThreatModel::Evidence))))}) + body: (record Production.ThreatModel::ModeledControl {control := "Security::controlNoBuildExecution", name := "No build of the subject but its MIR dump", text := "uorust project, check and prove read the workspace through cargo metadata and syn only and never compile the subject; uorust mir alone compiles it with cargo, running its build scripts and macros as any build of it does, to dump the MIR the lift translates, and it is run only on a workspace the reviewer would build.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "crates/uorust/src/ingest.rs:438 read.push((path, rel_path, target, module, syn::parse_file(&text)));"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "crates/uorust/src/mir/mod.rs:212 .map_err(|e| tool(\"cargo rustc\", e.to_string()))?;"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "UE-01: uorust projects the fixture workspace into exactly the committed Prism project, which lexlean fmt, lexlean lock and prismpm check accept"}) (nil Production.ThreatModel::Evidence))))}) } definition{ @@ -670,7 +670,7 @@ name: modeledControlConfinedOutput, parameters: [], result: Production.ThreatModel::ModeledControl, - body: (record Production.ThreatModel::ModeledControl {control := "Security::controlConfinedOutput", name := "Confined output", text := "The emitter writes only relative paths it generated itself, each checked to stay below the output directory.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "crates/uorust/src/lib.rs:199 pub fn write(out: &Path, files: &BTreeMap>) -> Result<(), UorustError> {"}) (nil Production.ThreatModel::Evidence))}) + body: (record Production.ThreatModel::ModeledControl {control := "Security::controlConfinedOutput", name := "Confined output", text := "The emitter writes only relative paths it generated itself, each checked to stay below the output directory.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "crates/uorust/src/lib.rs:201 pub fn write(out: &Path, files: &BTreeMap>) -> Result<(), UorustError> {"}) (nil Production.ThreatModel::Evidence))}) } definition{ @@ -761,7 +761,7 @@ name: sourcesOfControls, parameters: [], result: (List Architecture::Source), - body: (cons (record Architecture::Source {record := "Security::modeledControlNoBuildExecution", path := "crates/uorust/src/ingest.rs", firstLine := 580, lastLine := 580, kappa := "47224bcd5a4544baba3f3fb8221e86a8a1e5db5fb825c17c2aaab6a7286edbe3"}) (cons (record Architecture::Source {record := "Security::modeledControlNoBuildExecution", path := "crates/uorust/src/mir/mod.rs", firstLine := 212, lastLine := 212, kappa := "63e1fa5c47af15f541ddd6c32f9c242dbc26886018e40d7868e5e00ddb090543"}) (cons (record Architecture::Source {record := "Security::modeledControlNoBuildExecution", path := "model/ids.toml", firstLine := 65, lastLine := 65, kappa := "1c8113fdacb2b2ffc506ce327e49490b16e477b18191898b0933a8af0828b467"}) (cons (record Architecture::Source {record := "Security::modeledControlBoundedIngest", path := "model/ids.toml", firstLine := 95, lastLine := 95, kappa := "6f685a89e1a12e4d8f2800fa31df1adb8cc5c908d7bbf613e5abcbee258269a7"}) (cons (record Architecture::Source {record := "Security::modeledControlRouterConformance", path := "model/ids.toml", firstLine := 89, lastLine := 89, kappa := "bf2efbd58853ca2d8fee835c8387a66d1bb808466f63653f987c609dbb085421"}) (cons (record Architecture::Source {record := "Security::modeledControlTypedRefusal", path := "model/ids.toml", firstLine := 77, lastLine := 77, kappa := "5206d14ea60610b613787466024ceb31fe6940986c13d048cab8512308544a00"}) (cons (record Architecture::Source {record := "Security::modeledControlDeterministicOutput", path := "model/ids.toml", firstLine := 71, lastLine := 71, kappa := "ce3be3630d5760e4a82917cf2acd16fcb5068e52a2a4c05c3fc3e345e3d0b50f"}) (cons (record Architecture::Source {record := "Security::modeledControlForbidUnsafe", path := "crates/uorust/src/main.rs", firstLine := 3, lastLine := 3, kappa := "5c41bfc9512e771a8435578a056b04de00cc0c60b808edbf0c5849bc7a1cf3c6"}) (cons (record Architecture::Source {record := "Security::modeledControlForbidUnsafe", path := "crates/uorust/src/lib.rs", firstLine := 12, lastLine := 12, kappa := "caace281f1dfad0670d746f803f71dc04a007c025be354f9725ed41ff615c35f"}) (cons (record Architecture::Source {record := "Security::modeledControlConfinedOutput", path := "crates/uorust/src/lib.rs", firstLine := 199, lastLine := 199, kappa := "5c72af9c07c68d0d98e2e839742750a256cf21ebb3f285ac0f009ff968a790cf"}) (nil Architecture::Source))))))))))) + body: (cons (record Architecture::Source {record := "Security::modeledControlNoBuildExecution", path := "crates/uorust/src/ingest.rs", firstLine := 438, lastLine := 438, kappa := "ed5bea4f5c0547ae2a0f63bedce3812df2f6141c1e30e09ad26f152552999804"}) (cons (record Architecture::Source {record := "Security::modeledControlNoBuildExecution", path := "crates/uorust/src/mir/mod.rs", firstLine := 212, lastLine := 212, kappa := "63e1fa5c47af15f541ddd6c32f9c242dbc26886018e40d7868e5e00ddb090543"}) (cons (record Architecture::Source {record := "Security::modeledControlNoBuildExecution", path := "model/ids.toml", firstLine := 65, lastLine := 65, kappa := "1c8113fdacb2b2ffc506ce327e49490b16e477b18191898b0933a8af0828b467"}) (cons (record Architecture::Source {record := "Security::modeledControlBoundedIngest", path := "model/ids.toml", firstLine := 95, lastLine := 95, kappa := "6f685a89e1a12e4d8f2800fa31df1adb8cc5c908d7bbf613e5abcbee258269a7"}) (cons (record Architecture::Source {record := "Security::modeledControlRouterConformance", path := "model/ids.toml", firstLine := 89, lastLine := 89, kappa := "bf2efbd58853ca2d8fee835c8387a66d1bb808466f63653f987c609dbb085421"}) (cons (record Architecture::Source {record := "Security::modeledControlTypedRefusal", path := "model/ids.toml", firstLine := 77, lastLine := 77, kappa := "5206d14ea60610b613787466024ceb31fe6940986c13d048cab8512308544a00"}) (cons (record Architecture::Source {record := "Security::modeledControlDeterministicOutput", path := "model/ids.toml", firstLine := 71, lastLine := 71, kappa := "ce3be3630d5760e4a82917cf2acd16fcb5068e52a2a4c05c3fc3e345e3d0b50f"}) (cons (record Architecture::Source {record := "Security::modeledControlForbidUnsafe", path := "crates/uorust/src/main.rs", firstLine := 3, lastLine := 3, kappa := "5c41bfc9512e771a8435578a056b04de00cc0c60b808edbf0c5849bc7a1cf3c6"}) (cons (record Architecture::Source {record := "Security::modeledControlForbidUnsafe", path := "crates/uorust/src/lib.rs", firstLine := 12, lastLine := 12, kappa := "caace281f1dfad0670d746f803f71dc04a007c025be354f9725ed41ff615c35f"}) (cons (record Architecture::Source {record := "Security::modeledControlConfinedOutput", path := "crates/uorust/src/lib.rs", firstLine := 201, lastLine := 201, kappa := "5c72af9c07c68d0d98e2e839742750a256cf21ebb3f285ac0f009ff968a790cf"}) (nil Architecture::Source))))))))))) } definition{ diff --git a/crates/certified/manifest.toml b/crates/certified/manifest.toml index 2f6fe0c3..3e3e7d0f 100644 --- a/crates/certified/manifest.toml +++ b/crates/certified/manifest.toml @@ -2,106 +2,121 @@ # every lifted translator function exported by `lexlean production` and # kernel-checked, keyed by the κ of the Rust function it certifies. schema = "uorust/certified/1" -result = "" +result = "c32516ef6b47674da2fadc6fa570525926d3dc80fa3b47185ea467e88cb0eb7c 3cfb1b1ef3ca0760729bcead45d6ba7caa6884fd6fd445e39dd7727a1f2a726d f18b4d1b95f08e4338a836963907b589349bd83f8ebebfabfbd5324ca10307a6 b8927a3f013bd8faecb96fe29d3448182f4b98666b9bf4bcc3f0807d6dbd8068 0b21ec6486b7cac0bcc903ab9bcf3b5dbe8c30ca295dcc0fb612664b0ae44ce3" compiler = "0.4.0" +project = "0e69f10d3f5a7c8c2e4c51c8948d02b7e9fbd8bdfedf7eff3faa148c8189c4f7" entry = "uorust::mir::core::core_shard" # The bootstrap: the share of the translator that runs certified. [share] -translator = 666 -certified = 151 +translator = 675 +certified = 167 reachable = 0 reachable_certified = 0 +# The build seconds per published root, which sizes the next export's shards. +[timing] +seconds_per_root = 391 + [[root]] function = "uorust::lift::Acc::all_axioms" kappa = "47282ab2904bdc549feac5b4ef4fb5bd50ef3a8b4b26715ea7f7c139f5a4c257" definition = "accAllAxioms" package = "uorust_certified_acc_all_axioms" -source = "665ddb8b9f570ee520be7edbdc3661d88dfaa660554b932aba6020b326ff38e3" +source = "94fbe3360d32eb2d3940ad52be764e3cd254e5a484817937c2834ec0623b4ce3" certification = "kernel-checked" -closure = "a998a14758dc463d1b501c6b2d6310196651a9c572d4f0218c2197c125004639" +closure = "3bbc1ee1107854f357cf7d9eaf81f28a7df89821fd7bd4a6942a9607b6104804" +edition = "2021" [[root]] function = "uorust::lift::Acc::apart" kappa = "741a3deaa502b11218727a1ec4a6b1a4e6a28d5556860e53c9be3bc53ab869c7" definition = "accApart" package = "uorust_certified_acc_apart" -source = "70b14a1ccc0e7c4c15fc6726ebfb66e5067033d440a070650ffdc63ebe46634f" +source = "4863afb5339c562e51338aa5de57934bdc2230cacc9aca13452bd82b2bb1c3d3" certification = "kernel-checked" -closure = "0fce738e503be417751ee2ecddebf97d4af09155c2509508418767eb1e06738f" +closure = "1acdddc1954c180b269cdb4c69649e06ee03fff481e0244bc29aa7f6180eb139" +edition = "2021" [[root]] function = "uorust::lift::Acc::axiom" kappa = "fc58076ed9e45b680a7f27579779bafaf70b16e2b43d5de335bf828782dfa395" definition = "accAxiom" package = "uorust_certified_acc_axiom" -source = "ba6a2d239e2722370b9e6befc119daf23c4f624732797e7a2131a5e6d4de5c28" +source = "d237c1c3c70b833b660d3300bad82069338f7b732dd618745d48ba518024ddc7" certification = "kernel-checked" -closure = "1f70b5ce8d0fe7229d9031022c45096c1f864ea3e0fb8549644e8c94eda42915" +closure = "dd489da9df1b915de9b377cee91075742ee394cfbf7338067748538c3b5ad6ad" +edition = "2021" [[root]] function = "uorust::lift::Acc::axioms_all" kappa = "f86640194e33078ede8e321e8345ad59769eee1897e5f5573047cd4ec45d2013" definition = "accAxiomsAll" package = "uorust_certified_acc_axioms_all" -source = "db0790ad5463e4ffaa3647afe723e44c334f39ee61d6ce2b175f4d47a9eedcef" +source = "9f2ea53164f771fad549237ad6f0c02fe832415e0e08d1ef3281f972d67d087a" certification = "kernel-checked" -closure = "31fef727ecbde0781f8d0ed18687f7e1e9051b34b2a371816ac34cee24ce99ad" +closure = "0d9f6a864e086cd2f2a39e2d73de1afb6664a8b6a09b6ab63043641252590aa1" +edition = "2021" [[root]] function = "uorust::lift::Acc::called" kappa = "c793df1c29a3fa4e371b4ddf412b9a96c784210dd5e4038e07e627398e9a8edf" definition = "accCalled" package = "uorust_certified_acc_called" -source = "b3b9ab7782ab1222176c42fbe94d77d6428c1f910d73533bf009bb7be07cc3f5" +source = "23aea5015eed17cd523381619a0af52021c96530b28a42bcbadcb21348fdecb0" certification = "kernel-checked" -closure = "2c55c6e731a4e86385514e343bd925ba44464b730ecc7840a62d7ec762d37ddb" +closure = "bc08c650932e8956f3301feb0848ae7d0a1bdbff38b65428d4cb481d62116bc9" +edition = "2021" [[root]] function = "uorust::lift::Acc::called_all" kappa = "e1c197b0fb6d63c2977ccf09071432f1b865d075de89336b9fafd32459fd4eb2" definition = "accCalledAll" package = "uorust_certified_acc_called_all" -source = "1423cef9d34d54bb07db5532f146b7954bf5d11328d752391be238ccfd79be42" +source = "b710f419e1175a02e117d5b1da444ac0e07df8a8da64ab30ea6a829d6db6db75" certification = "kernel-checked" -closure = "32d862fa9a81e688aa5afcf6cc5928a7998549f2d189f55050f7c8b025ad0eeb" +closure = "ae05edce197249300b6c733a462e4f8eadca6d4ab54bce81488cc42f092ff3af" +edition = "2021" [[root]] function = "uorust::lift::Acc::descended" kappa = "dbfd19ff6fdcba53babb2ea901920bf5abe89dcfb303fa6d77a5bd0a5169e99d" definition = "accDescended" package = "uorust_certified_acc_descended" -source = "90f75f476bb899de7d75a13bdf27ec6c938fd1860ed5b8293870a0ef16e4b908" +source = "a9b6e6e9ddc66c6551f2d4b872125c63bb9ed845985b10379b108f98ea00c45b" certification = "kernel-checked" -closure = "d2a03b200e1f673098230c28942cd543cb73a337f3135838679c7e60ab61129e" +closure = "4431884083230db20a7a7ac9b759865cd01a5840441c62dda5a81201322e34a0" +edition = "2021" [[root]] function = "uorust::lift::Acc::helper" kappa = "ab9964d870ab234f119534da803332743d26be997ce401e8c4d89d53f28aa583" definition = "accHelper" package = "uorust_certified_acc_helper" -source = "c458f241df024fb45dd3abcb772fb230fad341649d3cc4f73905ebc126b1ebef" +source = "837abbd61767d7e82e787d8d8830c7892b2edcad1ef5dd85b703ed92ae561850" certification = "kernel-checked" -closure = "1fbc735d047a7f261552215a4253670d01ac2aa0ad85d352069fea8d2df134fe" +closure = "37958ce3d338df0473d0ac8be14b39495d4893feac66d076fe975950ab79b895" +edition = "2021" [[root]] function = "uorust::lift::Acc::rejoin" kappa = "e9885374b0e490a68ccd996720600869104548c91c1d957c829da3b1580c35f8" definition = "accRejoin" package = "uorust_certified_acc_rejoin" -source = "d5cae6769681a525fdb232826f3d61448ecb0eeebce82ac740720e666d3989fc" +source = "3e6932a61bee628ef258244761fcb77660e9932118cb9a54b7f1a54504adba17" certification = "kernel-checked" -closure = "d476a8bff0dd2bf286c4250f21999a4199491d607c5ea0dd1429bd7bfe78e41c" +closure = "f8ee4f9a95a7638d6dea4c48cb5d2a84d177d64c05d996bb5febf3da1f964207" +edition = "2021" [[root]] function = "uorust::mir::lower::address" kappa = "c2e62bf6b25f9bf6791024740493769f9a10c1cc44a723ed30218308d2a058c7" definition = "address" package = "uorust_certified_address" -source = "c24dcf122c0ff393c6e0f6bcff8148034f56704d200eda04dcb900dceb34fbcd" +source = "4a4c347126f85ac6d132681f65d309fa8ed5b0183c6a1b8879ed7b8f5b904dd8" certification = "kernel-checked" -closure = "5ab0192d0551e95928dbe89129afc499ca975e047b11688362597955b423b1d0" +closure = "47aeb10e8070ff849fa490b20847dca47214efe597e770df062ae3c87f6e4df9" +edition = "2021" [[root]] function = "uorust::mir::coverage::aggregate" @@ -110,7 +125,8 @@ definition = "aggregate" package = "uorust_certified_aggregate" source = "44c8ee7cd4ff693d930944dc8bf7eedc1fc361af24bd3793d6b61126d87fa9b8" certification = "kernel-checked" -closure = "ba6508522bf31701ca2db6b653ef9ea0634a73f1bbe011138c4708278c491a3e" +closure = "a6ef138eec75819d29c8b533ca97452c7768ae532bb332a6c033d79152241a48" +edition = "2021" [[root]] function = "uorust::lift::apart" @@ -119,7 +135,8 @@ definition = "apart" package = "uorust_certified_apart" source = "38cc38b436c62898f11ce33a8a08cd21085e2bf08c81eb80a068ee8a8a5df8f2" certification = "kernel-checked" -closure = "f6e377d4f6df22d96b9b8c5b5c0a3b01c9943bc82332335bf76271d608dd84d0" +closure = "6da6907ac25ecfa4eaddc6c46de55790cc7d33f903fc2873c972a0c5bf9f8d61" +edition = "2021" [[root]] function = "uorust::mir::coverage::assert" @@ -128,7 +145,8 @@ definition = "assert" package = "uorust_certified_assert" source = "3ec8f3609d5dd37f5e4d79e4eb733b856f0398aac78ed5cf8522833bcf3c6bb2" certification = "kernel-checked" -closure = "e13b701094d8df8a0b8d658c8ecdcfc37eb7dcf6230753fc3344aa87ad07c02d" +closure = "753bf0a69b1c4b4bdc2ae115a58ffa2e5c5867e2a34075cc097d6e12ad58ca07" +edition = "2021" [[root]] function = "uorust::mir::parse::assert_kind" @@ -137,7 +155,18 @@ definition = "assertKind" package = "uorust_certified_assert_kind" source = "bdd74dca96a98ead8e13568f0effbe61f2709fdc6f905d25f877999e7fcb5393" certification = "kernel-checked" -closure = "7cfdf8d325cc1ba43672e35c53b5e5c4f00eb9e5ad4a692b722b761e82e04398" +closure = "ff71b8689aeb376923e6f6a96ef0cbf931b8ed753496e5ac8a7cda88b195c5d7" +edition = "2021" + +[[root]] +function = "uorust::lift::barred" +kappa = "c1789c511c30c52fd41fa4c730c25f096d93ce580fe74aea093b3d6435890168" +definition = "barred" +package = "uorust_certified_barred" +source = "194f39919f591c9ea6f82581e143b231d37490237b5b208b66afc6ce6b24470d" +certification = "kernel-checked" +closure = "a1f9dc12de2391e4aedfc8af37160d7340022aa0f7f28d04e34e723f7479c041" +edition = "2021" [[root]] function = "uorust::mir::coverage::binop" @@ -146,7 +175,8 @@ definition = "binop" package = "uorust_certified_binop" source = "69a99d175bd2254fac3d87068ddca03d1d8e74c4320cdd8c595b1192e6581ece" certification = "kernel-checked" -closure = "096ede93b393532866b4fb70bb3ef1f783d8e3f7e35eeb14e0af1117698bdf28" +closure = "954a710406c5d3c87b121cb0f05270b24478719541625b572434f4244c2b3510" +edition = "2021" [[root]] function = "uorust::mir::coverage::borrow" @@ -155,43 +185,58 @@ definition = "borrow" package = "uorust_certified_borrow" source = "84c21a6882ac3a3f0a72dbaf526582674808b0885ae136383f1ffc77ea7399b8" certification = "kernel-checked" -closure = "691a97e161a64e7b84a361ecee5408cbb9faa2a6d6a7d4d50ee6dfe575faa1f9" +closure = "7835803e77f21fa63e99ed6ed0bb9c41c634dddec9972f13002b28aa5ffd2924" +edition = "2021" [[root]] function = "uorust::mir::lower::Called::value" kappa = "b8fa093727ec6ac0f609f80d333b69e90b1287d2c92938dcc6ea05c579c49dbe" definition = "calledValue" package = "uorust_certified_called_value" -source = "5d79af403efbd9f59993b4ceecffbb3e04f3641bd98f5a742071e5f2019b9716" +source = "85222f1e7ed1f2514830eb92411b1dadada68b65bd2653c7059486d9e9477d0a" certification = "kernel-checked" -closure = "a3fa4aaa715d1a691e895abe51932146730463e2b917e4bb2fb19a0cbdba93a7" +closure = "dbf83546e947c8ea0732ffa2e490636cc817decabf40a50a0799d888b9a56367" +edition = "2021" + +[[root]] +function = "uorust::lex::camel" +kappa = "6b16217f511a471cd3b91013548b9c15ab3d9c9006b9c8176f6eca94e795b142" +definition = "camel" +package = "uorust_certified_camel" +source = "affcc7cfcc05973589b8437c63af5bc9b60fc724e7bcb2fbcb9ab35c74f16727" +certification = "kernel-checked" +closure = "9657d31c709cec6032d8282aa78a0995ae6b21c9c5c991d9e1b1f89e1531d03f" +edition = "2021" [[root]] function = "uorust::lift::captures" kappa = "fe30d6a8a06cecbbb0b628d0ab30994df543362259d12b73eb2141741a64ce49" definition = "captures" package = "uorust_certified_captures" -source = "17102b25f7cee89e41f6eb30033e80cf985e9b4e85c695f37eb0a750ee58f576" +source = "2f7a7696a7eb0c8a69caa9f64cf62a358d134ed692a56bcaa5d9b4f515564c95" certification = "kernel-checked" -closure = "18850db38ab6061cfa7248a7eda31c4aa450ba47cb1677e08ac0f237b686c9fd" +closure = "96661078412af459764fa24d084c32c521ac8b9f45c476f571b3938ab06cc974" +edition = "2021" [[root]] function = "uorust::lift::comb_collect" kappa = "c16b6607d082fc488e3f35126e25850d027bd2b8da729f5e8826eb9792c1c7f0" definition = "combCollect" package = "uorust_certified_comb_collect" -source = "0dc4496519ddc2994538ec3d35095a545e047ca6fba5773406b796dfe3511b16" +source = "ee652e10211cba46b3efea7be7932d73dc102ff790d3eca2aeec238e236537a5" certification = "kernel-checked" -closure = "b2dda5de8eb46dd8a48c1b924b3bdeeaa6be10aa22399dabec560583543dd6ad" +closure = "49f802219f060ef7bda4ab3a52e17806e6cfb29e888ff74b1275953885dc06e9" +edition = "2021" [[root]] function = "uorust::mir::core::const_marker" kappa = "d6a3a776487870d24a30efe1b7b9a73586bac7f15ebbc75d9404447ec906b958" definition = "constMarker" package = "uorust_certified_const_marker" -source = "95c1deab457377471b435af60f63f5e354742b70abd71f9f8f18d8a49c679d7c" +source = "2c16a803c5df53fdac0f06200c5d01751dcd4cff9542549645c9ef909b9da493" certification = "kernel-checked" -closure = "2452dfc747d64bd2c88d8b4973c583d9c00e0a6aeab3a6ed2b73e19c7c739b50" +closure = "5a387fab4d418383644c8f0a45182b75f26324e5d6d4aa3c049e46ed0b3f7e1b" +edition = "2021" [[root]] function = "uorust::mir::core::const_of_marker" @@ -200,7 +245,8 @@ definition = "constOfMarker" package = "uorust_certified_const_of_marker" source = "16d42ed885ecfe4b2479d6418f809016e8cc4bd74e5e89bf162c614e566ccc59" certification = "kernel-checked" -closure = "20c9db35d738068562acc70bc12ec22e790096a1288dbdc25d3c16806dd26d21" +closure = "10bbb877e04f06b18bb84f42b5aa68802b8e72756e154a6907b02da01e588320" +edition = "2021" [[root]] function = "uorust::mir::core::CoreShard::translated_count" @@ -209,7 +255,8 @@ definition = "coreShardTranslatedCount" package = "uorust_certified_core_shard_translated_count" source = "4131ca38c85b28eddc3799ece1724d825c76883e678138a236874e7b56e7edfd" certification = "kernel-checked" -closure = "d054fa7cb682f5b82e93a9796c731255e608f2134735b2cde03cfcf7492a60d0" +closure = "4cacf4c5a9608de78a01ffd13729822bcb9a4015ee95414e885666fd1bd529d6" +edition = "2021" [[root]] function = "uorust::mir::core::CoreStruct::name" @@ -218,70 +265,78 @@ definition = "coreStructName" package = "uorust_certified_core_struct_name" source = "e4425d2bba2bfdadd88aeaaf2228ca1374ed0decb87a1025e5c003c617fd075d" certification = "kernel-checked" -closure = "c8069588a675bdd9fa8f287f820eaf0478382d2c18592cbe5587cfbac43d342f" +closure = "96296729a35265741372ea0e9ec29fe8fff7624e58c689fe35ab9e6a74e8fb54" +edition = "2021" [[root]] function = "uorust::lift::ctor" -kappa = "5dad399fa122601107dc02d7d1afff4acbbb55adb684dadfc6ce78fc6a20c140" +kappa = "0662bfe272125b82ad1f8eafe42ee2e13096e04fd0e28bc9dac4aeaf1d786a9b" definition = "ctorValue" package = "uorust_certified_ctor_value" -source = "29b0570d0b51ca12db2e2d7213193c130dc615a494ea4a0f1963a047f1322b19" +source = "936026ace11ca91e02145a9d53f7ee6ea37a82f614fe545e6e35236fc55fb22b" certification = "kernel-checked" -closure = "e20014b3439cd2ba67caac66b52d454a680678c15a26b99af5a76b0d696de1c1" +closure = "dc83497fa38081cd3f06827450d40215956969250efc1b57d7b4a7a28fdb4b12" +edition = "2021" [[root]] function = "uorust::lift::Ctx::below" kappa = "e92d1a1a2cba572f6c6f6ecdfcd3924f83ccdf4e52d377123e3d629356cfc697" definition = "ctxBelow" package = "uorust_certified_ctx_below" -source = "0605acbc253367732c297f9dfddbcd46757815a47846b7dd53fcc77fa70df047" +source = "f142d4d06e27e40eec5880d96334fbb3fd04d16921a7a2fd413218f7de0977eb" certification = "kernel-checked" -closure = "387232b58169e9425f429466d6504c8feb7c01b6f6a18b6971c852f169c6b49c" +closure = "d50f7bf30b5f1ff0834954f64bdff16b3e95029134801f24e9f9ec9745afece1" +edition = "2021" [[root]] function = "uorust::lift::Ctx::fresh" kappa = "0e4386bd681545c827d009009122b9b7e201cf71a21ed9f41f544195a5743fd4" definition = "ctxFresh" package = "uorust_certified_ctx_fresh" -source = "92aa2b770b93f3eca9dbf803fc757f6b0824e02e586d766b23d74e79bb2231f5" +source = "1a05b06fe6b4999aaa1d1fc83b6dced26b99ef1f96441062df79ce4cb0944356" certification = "kernel-checked" -closure = "63b5f6b758bcb01f08f69541ebd42b20462370549d9540c22b09585df571c63c" +closure = "089d69f87bcec98d630a7c4a0e05867df3770041d224861d3fc0a45ac553ff28" +edition = "2021" [[root]] function = "uorust::lift::Ctx::helper_name" kappa = "63d8223842b11c5bda29d5ad277089f65ad81a73fd13078aaaed716063714be0" definition = "ctxHelperName" package = "uorust_certified_ctx_helper_name" -source = "b09dabf0be6d34931d56ed6ad21b203ce29bc05c65e0699d75c29759f0f989a2" +source = "eb676019defe61c763131f3f14c1784fb2127e7e972a813f0b7fbe5b3eebf117" certification = "kernel-checked" -closure = "f83b8e3baab9425241a4304fbd3e29cc47f134b3d6eddfca40a498bcddda7364" +closure = "64e40e75a5826558e8eecd23f499c1c9404c3bc4e21cc3105e8b3b08dcb44174" +edition = "2021" [[root]] function = "uorust::lift::Ctx::names_from" kappa = "77a32cbfef777373c3dc5d2790f142c4e4f47ed728867f5d23b0f1dbe4a790d1" definition = "ctxNamesFrom" package = "uorust_certified_ctx_names_from" -source = "21559ae88b7d65d0f470e9011bec7680e920dcc06620cead3d05244eba879b73" +source = "1f4069ae06383967dcc679889db9195d333e40190393ba1adbe5152786c5b65f" certification = "kernel-checked" -closure = "7100c60ffe8da99ffa500113817b1c8f705a7bb100c8d1cba5fddf5bdd8feb13" +closure = "a552bd31f4c181b76b157bb25b7078a91ef7a3b4cbe426f78965cd07570f876d" +edition = "2021" [[root]] function = "uorust::lift::Ctx::taken" kappa = "1b0e3e236514b792b904be5db153c4fefbd6755c917dc21c40fa8e7f2ce1717c" definition = "ctxTaken" package = "uorust_certified_ctx_taken" -source = "2aa70e0e0928c5ee1a34c5cd4f0009eb9df6853864a623c52a9d467d6acda31e" +source = "19dd26bd9d3febc53830bbb0a35a03e59f5d893ed8bc165b2becf62ae1d20b2f" certification = "kernel-checked" -closure = "205fadf1c08a11df505685efec36af0708b817784c85a65d022ed6205c3a0dde" +closure = "7cd38f358cad2a038e07176d3f8575920126303a94453375fe6dd9e5ef0e64bd" +edition = "2021" [[root]] function = "uorust::lift::data_variant" kappa = "7432c779cb0e30dea650bd249317392af35f8f7d1468f9054303cfbeeef6e0dc" definition = "dataVariant" package = "uorust_certified_data_variant" -source = "b498432614f4e28aeaa03ed90af1310e7bdbafcff9bce37e701a43d03a1ad0ae" +source = "909ca01d80576dfc980087ae43b4e8ff11b817d148c58491190afbb0d0942b50" certification = "kernel-checked" -closure = "f13f5dd5bd2a020a769b5612849c9cbcf6f92ff267790d5a0073907ee4d81c54" +closure = "61e92be42f52013cda6ae120897dcd2188b806f587a25be5d6071356e598eebd" +edition = "2021" [[root]] function = "uorust::lex::Decl::name" @@ -290,16 +345,18 @@ definition = "declName" package = "uorust_certified_decl_name" source = "38f65ff1b7aa201143d1f1000017c0779ae729de1a636e25b8dfe251e824e58c" certification = "kernel-checked" -closure = "b0fcf1b1dbb4dca6f83324bae85b48b49ac65626739d9469179e6bab456f6ab6" +closure = "2789fadf84a2027957af939ab79addbb9cb517a5f33d140935e84c7e07822a7d" +edition = "2021" [[root]] function = "uorust::mir::lower::decoded" kappa = "4313885baf18f2b56409edecc1caefd3afe88cfee95fcc6f0530fe7dd2e4c918" definition = "decoded" package = "uorust_certified_decoded" -source = "87f6593334e4aadbcfdb716c9d76ba015aeca930821876c6a669f3c41bfc2ebe" +source = "d3610efca88644c7b80f4412a9f0209757438055aa0ba1c16c1ebb98db2168b4" certification = "kernel-checked" -closure = "9ef4892e98ebe7cf68df12fcafc81f3be86ddca4d2d159dcead85dea8b4402e9" +closure = "8792b5b6c85c39610a60bc4a80f5d295c91894d027944b64966e9f4f747bbb4f" +edition = "2021" [[root]] function = "uorust::mir::memory::definition" @@ -308,16 +365,18 @@ definition = "definition" package = "uorust_certified_definition" source = "dbb1e565ac00330f5ce718e001004bbdc206bdb0f017a7f20ace09361304504a" certification = "kernel-checked" -closure = "31e810973b9a9aaf9ec202a3aae16c1f0c8f31f1c47cdcdc216db7019ea93295" +closure = "821e9381861016de948ce9357607f940e9b897322e212008ba2cb41d47193ad2" +edition = "2021" [[root]] function = "uorust::lift::equality" kappa = "0597311d641125a2e844618970045d61b8f2aed8b2ecb1bf9e67caa875e2ae93" definition = "equality" package = "uorust_certified_equality" -source = "4f2fa2ec6fe49d90bbe672b04b53c4b478359a9a9888801494d0395aa44a2600" +source = "686b8c554ec69fdeebfbe80b2e376fa9ea82d597b15d123364ff505d1523a60c" certification = "kernel-checked" -closure = "dc39d3413661f53feb00c1626cf9d0998ea866fcd14568c9c158a4eee5e04a8d" +closure = "008312bf0acffcdca2ee6a9bb95e599a9ca577359e3e4b8a54573cc7efcf98fb" +edition = "2021" [[root]] function = "uorust::lift::equality_name" @@ -326,7 +385,8 @@ definition = "equalityName" package = "uorust_certified_equality_name" source = "794afb6d4a19e30dcaf410578a366403e7679bce2a63f1b8d4984764c1d14d36" certification = "kernel-checked" -closure = "9a2a80bf22468e62d4cdb4de8ffc5ea73b5759424741320d1fd46cdaf84dd2b6" +closure = "93356ba10aeb4335a4e2edd3a9c950591e08dbafc57c480f045b39e86a6c5fde" +edition = "2021" [[root]] function = "uorust::lift::evidence_axioms" @@ -335,16 +395,18 @@ definition = "evidenceAxioms" package = "uorust_certified_evidence_axioms" source = "7e70a8ed0f3d9302729d40b810fa3e2b33c9fa032faf2f509410b907b51ff230" certification = "kernel-checked" -closure = "0be7dfb2b8cea54f442b81256c62f986f10fd5ec0ea774ed9bc9f63d48fbf59e" +closure = "d9df5af26ec0812802d291080acde3c26bdaa8a2d57dcab8c25011eee19cdef7" +edition = "2021" [[root]] function = "uorust::lift::evidence_proof" kappa = "cf666a1ac9924127fc1150fbed327bf537deb4c8ecf9f82b01a26f16179716da" definition = "evidenceProof" package = "uorust_certified_evidence_proof" -source = "1049b750a7e8e30b9d2c46a5f7f73f3d186d4e0cc696306fbca1e6cb815f77f1" +source = "6ffbf2f3984a09ff00f1faf783504ba657a7bdc0688c7d387c1ff1842e6a77ec" certification = "kernel-checked" -closure = "602273b374e39d9a2034c78f9e3ea021975b79cabd0b7f992e7f3e28e27de352" +closure = "adc1f0fc9dae6c90f6e0432726efbd7fa33e48cfd12fc09e93bcc66d5de2b410" +edition = "2021" [[root]] function = "uorust::lex::Expr::is_flat" @@ -353,16 +415,28 @@ definition = "exprIsFlat" package = "uorust_certified_expr_is_flat" source = "cbb0921e3ad824945e2e6ffcec28fd18aacb1993424d002f687a54c9e940127d" certification = "kernel-checked" -closure = "bdbdff95e0ebfefffa07be5f8c03720d4f0c3d440363ec84d2569870af1eb0a8" +closure = "7ad46a2abf0134b169fd5e5aeb4e66a709a3169269dfa17993ad4588d0070be0" +edition = "2021" [[root]] function = "uorust::lex::Expr::pieces" kappa = "fced59260d2d83ffe96831b36ef1affa94b1c712d9f3eb2d4585bd0f24a58b8d" definition = "exprPieces" package = "uorust_certified_expr_pieces" -source = "f0eade6a051d39a7e3bc7336eafd3c21b6ef84d0b4a9b5af2f82a3f4ff768152" +source = "763445f65962871fcb86a9c76c388e60ffdb0ed92e3ac54e03dea06161b90974" certification = "kernel-checked" -closure = "2282f752447a07be9db6888a502a0722930898ecc1b1bdb2547900fc39d64123" +closure = "c99491d1d7ec35ddd28cef8d2be08390154d9323464f00b47838d88944671b85" +edition = "2021" + +[[root]] +function = "uorust::lift::field_name" +kappa = "ad1b8db73c93fbca0f83f3fd853618b9d40a52b7a503507062098747923c77c3" +definition = "fieldName" +package = "uorust_certified_field_name" +source = "e34880c9713aad6fe48592e14c09a27c8bc46a8886817eaf6ab7fe7f4bf0aa10" +certification = "kernel-checked" +closure = "72edf9235848c7408e51bed9d99a2ce823d115cb5465a3a349565ccfac7585f6" +edition = "2021" [[root]] function = "uorust::lift::first_free" @@ -371,70 +445,78 @@ definition = "firstFree" package = "uorust_certified_first_free" source = "9e21a100e414ed671927424ac26a88dd824e436e390d160ba89119c2a8b1bac9" certification = "kernel-checked" -closure = "b2644dc8357bc4f190ab43dd4ccd220a68081893f98c1adec20da779d4a2d169" +closure = "04944c4c106f2e88f1661598381de35702cb4932081f4a28b67f4300b96795fc" +edition = "2021" [[root]] function = "uorust::mir::lower::fixed" kappa = "ffa8577e171fb76b3df744378c5a601e6afb9cb96b2c716b90d42543dca43601" definition = "fixed" package = "uorust_certified_fixed" -source = "dca81082ab75da6489e6c4a3eef2fd2381fc9dfa443e3374c82304cb76ef309a" +source = "67b607292b16a2c83e74e61179f1bf4a38e27314a89996939f553a07f78e5494" certification = "kernel-checked" -closure = "a4277105530d26fce0ab22d58696d05cc5c694c2be44cacc9cae1743a7d1f0a7" +closure = "731d6c875f8c577ab50e232c9f40cd80329c65bb223b665713cd8bdca4845eb4" +edition = "2021" [[root]] function = "uorust::lift::flat_lift" kappa = "c0d9b67db757c3077fc2558ba1ff0f6dbfde1be0e2904fbd03db05ea4954a9cf" definition = "flatLift" package = "uorust_certified_flat_lift" -source = "472f40ddddbfdb864211294abfcda3a650bd0b498584d055436c2506d08ce5f2" +source = "e98d917dfc14100520b7e5ff2c56590e4422102a918102a83b90a30eb7a1d369" certification = "kernel-checked" -closure = "4406f0dcfe73d9fb76dd14a234196e29d1827bad6fcb5cc4b30438f6a7ac9594" +closure = "0fa2612f326c053660a57506450fbb54a3e22e30bf4493c0d7b90ad9d2a776ff" +edition = "2021" [[root]] function = "uorust::lift::flat_some" kappa = "e4f32903da5cf0bee4eb265bc6ee99653e13bd13605f4b9d2dcc6c556d9cb466" definition = "flatSome" package = "uorust_certified_flat_some" -source = "439f6bf35cca4d7a0355ed4204badbf9aaf9167c0d8f711e536aa7bf7c66c882" +source = "2c45f941b2ce0902d31ccbc41d49c73976fcecbb5eb062952bcc5d696c2bb53d" certification = "kernel-checked" -closure = "fbb588caebfe0a324c035af8e3530910038ca6fedb5ff79e2d14e029a3389a6c" +closure = "c73d251851f5190284054e81db44d6e7d09e23c3a405021e1f7296ad472659b6" +edition = "2021" [[root]] function = "uorust::mir::lower::holds_no_pointer" kappa = "2d57d8527fe3b0c5e296d86c69a6bac89fde4d3b28af2aa1797be22362f0cd1c" definition = "holdsNoPointer" package = "uorust_certified_holds_no_pointer" -source = "6022d5c58043b2db83603d1f2aae4a74f1ed62e87b87692a514e40c03159e34e" +source = "8800450e97be5b0945c510150d063cafefea9c796e20d4769c218c2781d2e726" certification = "kernel-checked" -closure = "058760a7c4532302f771925e4205b52a7c97ee1922197086442e0c94b614ccba" +closure = "069e9d0f3f01fdf8e7f1fb182aa8ecb9954ef2e8f46158039d67722a453296cf" +edition = "2021" [[root]] function = "uorust::mir::lower::hypotheses" kappa = "5e038dcc473e0db8901438b92c6606e645c0f7b83e1e7e7df854e66f8efe8d58" definition = "hypotheses" package = "uorust_certified_hypotheses" -source = "a0faaecb1d1c6382afdcc466d0ae457b1d65c1011f5a636ea94c039fbd27ecfb" +source = "193d053e5a6d3f5c1ebb8f9e5de0403566cf5a2f19c595fce105c935d2819cb8" certification = "kernel-checked" -closure = "571ff952a88bc3441277499565d61e3a29301289ee5aa11bd0baf81a3f417890" +closure = "b16a3f5b41ed7f003fe687fbf71e2f73048e03f2cc3b90390e13be3a6d662b81" +edition = "2021" [[root]] function = "uorust::mir::lower::implication" kappa = "e9a6b0ab4d0fe408c722416c5261e0aeb470406b6249354407ca6169d66a46ee" definition = "implication" package = "uorust_certified_implication" -source = "00804134a40e95ad4c1226155893e3174fb3c248b2796e79721ff499a425f978" +source = "abc8de8f75ae53b36890e2a30f0c182e22cf398dedce8d94eabeb80154aa134d" certification = "kernel-checked" -closure = "f9b3e4a93eed79efd237292e7d07a192fb72c79fe69c27183256095d0e5f24ad" +closure = "b796d7db8c09a23624672697e0f97744b43e354254a5fe3ba86d4ed5704b51c2" +edition = "2021" [[root]] function = "uorust::lift::insert_all" kappa = "77070144b985d40a851308affce21ca89665d8ac9ed66175f628da916d1dbc4f" definition = "insertAll" package = "uorust_certified_insert_all" -source = "6bbc66096b3ebb53e23a39fa094234d89b4af7d3b77439b4d0cdc6da7cbdcd71" +source = "d06b4316b3a02890ba1bbbe55b1016ea8b550d9b9e0eae5351d3bc7c298f3ebb" certification = "kernel-checked" -closure = "f7c02c19d808616e307f92c0cc291c1b97f15de16b29054d53a8f0f85046939a" +closure = "ee287b03766f833be6367532009bd12436b6271845c906bf9cfcdc50a6938d08" +edition = "2021" [[root]] function = "uorust::lift::int_literal" @@ -443,7 +525,8 @@ definition = "intLiteral" package = "uorust_certified_int_literal" source = "c92755d4000c7a7a87b1ae5ba09fb294df11ff9e7b998206ac55d7110a24f475" certification = "kernel-checked" -closure = "b8f80323a7d7b3703eca9de3239aba11ade845885c6b18a055f33c054bfeba9b" +closure = "ec9ae9e63aaff62a801bf882d3628fa0848bdb1361a59b7a1cdcc0d9873476c2" +edition = "2021" [[root]] function = "uorust::mir::lower::is_const_argument" @@ -452,70 +535,88 @@ definition = "isConstArgument" package = "uorust_certified_is_const_argument" source = "dee01f95c01537b3af87fcaa1e83338fc7da511a7d575e90212b273e6351e947" certification = "kernel-checked" -closure = "c1adc6925c2e2aaf54c53da987f158ec7a3a0075933c8adefa24ad83a904029f" +closure = "929dbb88a2e65922db51a2da2f249a4c12121ac523de1389d64478779b9a38cd" +edition = "2021" [[root]] function = "uorust::lift::is_enum_or_bool" kappa = "cc232825922d5f89341a3dc571df0a6496c70e77e0408093e63c6a26ccb62793" definition = "isEnumOrBool" package = "uorust_certified_is_enum_or_bool" -source = "a7a62318aadcd70b341c03c8fb15ab7496f9d8e6cf817d5efb298cf6af82ffad" +source = "b6280cb5eda6cc73ef0f6e5e0eebd0a6ce2b7766242a653b5df92d3068203515" +certification = "kernel-checked" +closure = "8388e637d7aca5e2157ec3849b4996a617cb161a2ae9d852ed384a0c368b47c7" +edition = "2021" + +[[root]] +function = "uorust::lift::is_lifetime" +kappa = "dab18735e7bcb5fe73fbec9a947b02223bfe65af9b4e2fb9a3d4f3bd76d73914" +definition = "isLifetime" +package = "uorust_certified_is_lifetime" +source = "6c352ee9918c43adad04fb28b2a415a6bb78b3526c9124b5f908983a7defe981" certification = "kernel-checked" -closure = "d2953bfbeabf2e3f4a61dd94a94bb4dee982e35c0f5dc3e067088fa1c9a3aa79" +closure = "abb816b5459fae2de6852cf0b5ab2fc51dbb774d790bdd5b7522a8e2560006f4" +edition = "2021" [[root]] function = "uorust::mir::lower::is_needs_address" kappa = "b0ef31af261fd30e930a917bb79bfbb63662731b6c40e9c44b50bd26a76f233f" definition = "isNeedsAddress" package = "uorust_certified_is_needs_address" -source = "9be06f7f34a49d8293642665d1d4a4b3e10b6bc70fa788892ce7f7537e9832a2" +source = "7ec2f80231e906b0d43735d7f4d5ab695d004b9d3fd3dcf5a087af48c33a672a" certification = "kernel-checked" -closure = "ab13b446129d399895a90989b8cec32240a4443f26d7e993a38eefe02cfc7dd1" +closure = "c887c0dcd5b8256d1f1b740aba4f5fb0ce1b9aeb0afc9095f89f8e8513b065eb" +edition = "2021" [[root]] function = "uorust::mir::lower::is_needs_memory" kappa = "43d3f99a3c42e8902480305132852fd85060a4d81549e5e464bfe8b3bc9648ff" definition = "isNeedsMemory" package = "uorust_certified_is_needs_memory" -source = "d2c054f519975c878f4e94dc28dd943e2ae466e131e18815261e6aaf98078cf5" +source = "2ec2afeaea2861325dece6440aa5a3ffb786a6f1e8083b13ff788aca378ed868" certification = "kernel-checked" -closure = "614aa160a137372d979c402ef792de317e54bdf49c998d6baa22054820cff924" +closure = "dd24b25dfd88b90a8c63ccfbc94490d488a064fc947fff9c704db591d8840402" +edition = "2021" [[root]] function = "uorust::mir::lower::is_pointer" kappa = "8c963215b6d53cb79bf74d28aeeec5dd6a9d9910ea4c29611ea56ef32a6dbe87" definition = "isPointer" package = "uorust_certified_is_pointer" -source = "82ea9267181f51f6525f3fe028f44066a1828f595b45b8c9adbe6b69a27d498c" +source = "f024bcb81a42d1295c16422042a80674e1654f1ee01a35ddb2f2ee805041de7c" certification = "kernel-checked" -closure = "a045d227a770a2cd89566cc47c290281f3bd60a414a48faaf6bfe5a8b1db7015" +closure = "a09a2880166c37962bafb9736626ce76bb818c874248fb251fc3abb9069c32d5" +edition = "2021" [[root]] function = "uorust::mir::lower::kind" kappa = "c220a113ae402aca6e483173af150f71c51c01c803b14444c11628d65fcecc80" definition = "kind" package = "uorust_certified_kind" -source = "7f61ac48759ff9d4f8873bc3deafef461ee79c6ff6b00eea5ee76d38b72ea670" +source = "9eb607a4cf3685a64ab918848c524453430f182819c0af087888560759902226" certification = "kernel-checked" -closure = "f0ba311e926226309187b6154e77efa24a472ea38a24a2e009895e7fda8ab7bd" +closure = "22867635961a82de5bd668546bbef9ef4ac15c4a7489d10184e864ec07e04d7d" +edition = "2021" [[root]] function = "uorust::lift::Lambda::wrap" kappa = "32b9019e9c10079884f7765c93ab19501db7a6029eee2e729c17b5fa86f66cb1" definition = "lambdaWrap" package = "uorust_certified_lambda_wrap" -source = "a91a671bd59adbde656ccd5cad17d549e40cc73365c0cf40c4e601ef9cbe53f6" +source = "3932e97f6fc95f1ca0be0266d73b2752102afc34db4881fafc5a3d7e27b64132" certification = "kernel-checked" -closure = "1496d46b5e66d0920272dc05eac44c95ef4ab95bbe4642754ee21573cd59e2dc" +closure = "ad29be4dd14b4c12bc7333019f8d9b130dfc2ce231f8a658f21dbb73393489f5" +edition = "2021" [[root]] function = "uorust::lift::Lambda::wrap_expr" kappa = "a2fb2628a838ae20c9720887e176e73e0f95006a2c558a5775d6b1b9da35133b" definition = "lambdaWrapExpr" package = "uorust_certified_lambda_wrap_expr" -source = "7451fe6a28f3d43221c8b2e09e9f1ec8dcf4ba138c3226afd8c4fbabd8f2661d" +source = "24ab696c25df7e85c672fd4b39fe81e9672674ec13811e8584e583260bd6c1c7" certification = "kernel-checked" -closure = "56fe0f524dd106a307ab7acda8b30f46c202ea6eb4f687da2e4df824744da65f" +closure = "bfbafab6d0030177d27106f1fb7fccbbc27497646bf27b81a6c80bd1a6541e30" +edition = "2021" [[root]] function = "uorust::lift::leaves" @@ -524,7 +625,8 @@ definition = "leaves" package = "uorust_certified_leaves" source = "debe0cd2ba407fd02a1f232c3d15470804da4bf76d4c6ade73f8a9167627fa7e" certification = "kernel-checked" -closure = "3b24b341819ada1eb6e55d4117ee5a498c915e2e79be67261ca41f1013a0fbaf" +closure = "303085ef4327c546b12f577ca09f3ef203dcb8c702579680be2c89df017a7602" +edition = "2021" [[root]] function = "uorust::lift::leaving_match" @@ -533,16 +635,18 @@ definition = "leavingMatch" package = "uorust_certified_leaving_match" source = "320f40b84dc2f17e76d4a919fba6ceb0c910da65a4b2bfc123a54acb50551546" certification = "kernel-checked" -closure = "623b8170bf109d5caaa98f1417cc9835319905b58e31ca9302f9329a3a503298" +closure = "bd7978be1301e5442c01684921c6d20aa869584d75ea819b12e4ca5c53052e4e" +edition = "2021" [[root]] function = "uorust::lift::leaving_value" kappa = "b6b13315b326cf8a47ca70d6b2eb800910e01fc609771e35aa743ac17da6e3f9" definition = "leavingValue" package = "uorust_certified_leaving_value" -source = "0f6ad49720b05665406cdd4da83da15354c6e66a9b8a5f3758cce430d47094b1" +source = "291f03a092d8f88a2be2e47d18692b33f468cacb696ab8aafadd931bd74d04dc" certification = "kernel-checked" -closure = "01468941675d5199c61fc0a69fcbe7ea4623e3423fea039a5bcfab871f5de474" +closure = "86684089042b391d32d4b16ebf1108f2d9f61805ee32c61dc30c1bc627f1ac69" +edition = "2021" [[root]] function = "uorust::lift::max_of" @@ -551,7 +655,8 @@ definition = "liftMaxOf" package = "uorust_certified_lift_max_of" source = "7d7821dd4eb798360225feba9ca9fe911d6e3b1f2cc4279b3d4cd2d15754067f" certification = "kernel-checked" -closure = "95f646ac1dac4f82b00ffa3a9dcd7c1949a2864fc5961105d639ac1ed5808984" +closure = "66f93acf992d82dff4d1607babaddeea77228752ce5aeef657f10480bea4d44b" +edition = "2021" [[root]] function = "uorust::lift::pow2" @@ -560,34 +665,48 @@ definition = "liftPow2" package = "uorust_certified_lift_pow2" source = "7c8cfde1440491f0b6fac0758a1fb395a821385ccba0756935e28ff0317d6cc3" certification = "kernel-checked" -closure = "ebba5fcfea6d40a5169bf76b5d5494cf6a07ed0369d7f50a50183c8eab2dd534" +closure = "dd9afe3ef36118f3cdf58ec4e058d8d19900a16cd91cb863d082c2fad286a613" +edition = "2021" + +[[root]] +function = "uorust::lift::local_name" +kappa = "0e97be65c6b9ad4c218ce327e3f6f2030810589ce9fde63a76cb6eaae9748b9a" +definition = "localName" +package = "uorust_certified_local_name" +source = "74973bcbdaa6f1715ece1ad2aa68ccef94bc0fdd8f6f5e4858e3c8dcaaeca7e5" +certification = "kernel-checked" +closure = "b733b1786402ad6eea50b9dfa9e1a9a7fb5436b2eb1a530c83051a19efca27e8" +edition = "2021" [[root]] function = "uorust::lex::members" kappa = "470e1241d4f458887ff8849572936d7c86194b80c15279f069f5cce2c08c862b" definition = "members" package = "uorust_certified_members" -source = "ed43e4506cf07103ec93cfa8114e0f513a64bc37def089d86d27a1922018e25e" +source = "55ad958b7926ec5f8b91d2afc04e346fb3fdd38074450f91163650e80cf8a64b" certification = "kernel-checked" -closure = "1fcd7838fd581bae8e5b5b4a766ab98006cd3958951a58a6b2c596d40937d19e" +closure = "65c44084b8aa185ce01d57e91a7c35be545bfbb0f302d482f7fe2a188a570a86" +edition = "2021" [[root]] function = "uorust::mir::memory::memory_fields" kappa = "a69810510a5ac698b8372f07db46f4e36ab28a45728eb56ea44e232225e80d81" definition = "memoryFields" package = "uorust_certified_memory_fields" -source = "4ed5ee17581f507713378ee9d6347f2655d5f95991c0a4b2a58804a3c0f4f65e" +source = "f20611f2ae1ca6be686b6e12428a2916f1e52147df6e789d948c732d28ca06e6" certification = "kernel-checked" -closure = "43eda6a502fb84a5a9188b00dd24182377efc9c083262e676d0a82ad216006ed" +closure = "7cfe42d89f433c587764a1288e394d6bfacce871b7ec6049559110a5a71b8b75" +edition = "2021" [[root]] function = "uorust::mir::memory::memory_ty" kappa = "847c4f46bbae77c17aaa5c68258aa70605185780abadd4b29980b289abf6d0f7" definition = "memoryTy" package = "uorust_certified_memory_ty" -source = "27a9a3ad50889d50c9f56d043400faaee513705534366cbf665605b4cb6e0e5d" +source = "6974a33eadc50d56212e1ab509c32d84bc8a180aa17115b3244b2a59de3d4cb7" certification = "kernel-checked" -closure = "3f2a7c3e6ddaa350a79cdb66ca059bcfcfba7c3989fe9c9cedc7dbb2312e857b" +closure = "77b13b695c07dfa7ead774fd2adf270a27e007a9bee52dace2e9db345dfcc305" +edition = "2021" [[root]] function = "uorust::lift::mentions_word" @@ -596,88 +715,98 @@ definition = "mentionsWord" package = "uorust_certified_mentions_word" source = "31456715f5a0a224e0e4d86dabee2db9223711227fbcae7534b65d707aaec374" certification = "kernel-checked" -closure = "2d27a86107784bb13948e1631c4808f2791b71f29888c7d299fcd47683d5243d" +closure = "ae5ef2d5739b069b550b2a495522e7dfad011c12544d63d2a3359565ac6f9671" +edition = "2021" [[root]] function = "uorust::lift::method_char_any" kappa = "cced37dc6c8d03f73b19bf9d796fec79affd5723e1c8959615c05eedbe1a2247" definition = "methodCharAny" package = "uorust_certified_method_char_any" -source = "b30d8523bd9122c1d4b81b96222c5e97779b732bb499d1cce51f049545a6dd0c" +source = "99556739c741f6dfb765959cf9ddde1398e54bcc7c03ca57e5704ac851b0f8a0" certification = "kernel-checked" -closure = "78608ffb073405fdc52bae55a8ddc3bb2c35c0a4767441ecf7cb74a616b05bbe" +closure = "05fb6b6c2f645fb94786aed098f8a8f2b28dbc577d5aba9930b8505be20560f6" +edition = "2021" [[root]] function = "uorust::lift::method_int_checked_neg" kappa = "b64fd2a58a6a44e2eb592c15652495ee70a5d1b8b1c73d22bff56a86c6120330" definition = "methodIntCheckedNeg" package = "uorust_certified_method_int_checked_neg" -source = "e3d8cb6dfe5afdc857198300ee169e5615168abcf65d81d2e26e2638625670a8" +source = "44d9b677684c0411a525aa6a6fa1c46f04fb1ce718db8ab854e60de8b1dfff8d" certification = "kernel-checked" -closure = "7ecb5516eea452c92777eb4fa56739f7d66a715e713093a1fb738ce5c5193ac3" +closure = "1d83c8f8c4139a17c2419699898ae9a76b31a3f2fee9658dadb62dba3606b144" +edition = "2021" [[root]] function = "uorust::lift::method_list_is_empty" kappa = "557cea6cc3c05c3ee2c3d217da40884f178a024524807fec915d6cda48a1afdd" definition = "methodListIsEmpty" package = "uorust_certified_method_list_is_empty" -source = "cc8d5ff6aa7930c2fadb74c497eea57541a3b2fa7cfc10b4b5a1d6e4a85fddb9" +source = "d9c4b8eb311b20d639cc6549b4f43fd030991fb9dc2b0bf72a39268c20499f0b" certification = "kernel-checked" -closure = "d4f938201b98a2e15f3b3ef85a38a56d63db0f92e4ca53481cb5c5b695dc91a2" +closure = "75b730dd8bf1495b0a3a505442cb4dc02d2407bfbd60786e97bee6a99dff156a" +edition = "2021" [[root]] function = "uorust::lift::method_list_len" kappa = "90cd2f082cc98fb8f6a788ce77515704e20ddcb964b6ed72b343ff14da318c9d" definition = "methodListLen" package = "uorust_certified_method_list_len" -source = "2e72fd112345a336d24df10374b82297fce191035096cfc6107fbb41089a8d32" +source = "a4af4ca69516e5d8e900e77257285a334146fd4f4627760086bede4b44a3bd24" certification = "kernel-checked" -closure = "2d49f69395633c33d62a6a246b45adeb30357d7556b817dc76cf81630b7ed8e7" +closure = "a6ff3214f0d3c54bd7bcc4cd06b5284d232990e12721b0a659df660f9bf50c0e" +edition = "2021" [[root]] function = "uorust::lift::method_option_is_some" kappa = "acbac7e641cd1ec3ce42b486c2e11d58b508c255212574e4274202b769bebe65" definition = "methodOptionIsSome" package = "uorust_certified_method_option_is_some" -source = "a6bdce016a754371dbe0d97332d81a4b070af03b7815f099dd5921c4bb9fd893" +source = "34e9bf50c967d147a10041bc2ebd48841ceed6b14f09a7ce37840d25e0413853" certification = "kernel-checked" -closure = "38089bbd6ff519c814c2691ad87ffef0f4781eec364bca7043afc8f4ca8963de" +closure = "1afa50dc214b18f95f84bd4f142b2594125ab648f1023bf9b1b280eb5c5321d5" +edition = "2021" [[root]] function = "uorust::lift::method_outcome_is_ok" kappa = "dec119780900d635acf7a0cbebbda250614da7a45822381e7f25dbc3ccd66620" definition = "methodOutcomeIsOk" package = "uorust_certified_method_outcome_is_ok" -source = "a777a0ba437fd17c1785c9015ac4b372cf1e849e683faa3ed42ec4bfc781787a" +source = "1b9ca9d67cf67d4685df9e7d027e0a0ee538d1045fe3c26f7c6b2c1ff2753f70" certification = "kernel-checked" -closure = "292fa213da56403a51ae594637745fa90c0c6cdffb0c887083c19b59a0cc4437" +closure = "8f0ee43527ae475f3a6b924bc6f872a70aac032133988877db41d57ea2fe5adb" +edition = "2021" [[root]] function = "uorust::lift::method_outcome_ok" kappa = "3671943f4abce17d6466590db8b3f1fd09bcb0c6a3295a6cff701ba6343b2523" definition = "methodOutcomeOk" package = "uorust_certified_method_outcome_ok" -source = "6fb481c96cb6b3bbf4f0f1b57be8500f57f702822c0b0c5a4f836d39b0f028de" +source = "e1a2e07c2a9593ca4c2a344ef63170f0498aaad7cd8f4d2618f65def9d04f30b" certification = "kernel-checked" -closure = "f6e34cde93387c12429a568fead70118b9383323313bde89e2dd8ac2b75fa8ad" +closure = "05ff6dc65b4b6a0c1da46488d3a25e9565434ec02c962c065122d709bd3d6050" +edition = "2021" [[root]] function = "uorust::lift::method_str_is_empty" kappa = "8e04562b4479ae16332927bf6429144db05ebdf798faff459c195e654e78d7f7" definition = "methodStrIsEmpty" package = "uorust_certified_method_str_is_empty" -source = "edf0265f53170113f2c4b63516063b14263446aed5f50675fae7b646f030aef7" +source = "e0ef999ea72cdb550c23064dc357e3d888ccc41f7f5462ff5325e1914eafee84" certification = "kernel-checked" -closure = "0cd416a1819805c1c2ad135d2939370dd6f1cc27b1dfa045f66c8ace5950e5fa" +closure = "466c300317a69168fe60e2e3e8e9a38667fbb2423258670941b5754ca9c38ea2" +edition = "2021" [[root]] function = "uorust::lift::method_str_to_string" kappa = "ac54614bf7f9d1c165bac4b45343fe4e3a970d5506774e995e3bc1373af5ec44" definition = "methodStrToString" package = "uorust_certified_method_str_to_string" -source = "4a767170512e8ed3bf521a665e345c067f641d982f3050cfdbf7cae1a74a0b90" +source = "ddf93d69c6feb2388f7bea0506aa32e1b5fe7b4bfa1b8b524174fc9882747b85" certification = "kernel-checked" -closure = "7f88c6589126600259a8d6ae734b690cdd205aff4ba70b69b8def001e55f6ee9" +closure = "6aecc15142c0d9b92b7f039c0750c89e3ab10e4d744716baaf355bb8ab5b5bb6" +edition = "2021" [[root]] function = "uorust::mir::spec::MirAggregateKind::path" @@ -686,7 +815,8 @@ definition = "mirAggregateKindPath" package = "uorust_certified_mir_aggregate_kind_path" source = "e60693b584c301b843ebc02d1269e705e55ff50d68a2fead6c706c0c2dfa46c5" certification = "kernel-checked" -closure = "1404870d5c9ac48dad0818a34894a1806fabcebe903a047b923daafaf9048c62" +closure = "655445718c0c7f8b7359086ee9724738bc5015cc5e29a8c89741b142d3091fd0" +edition = "2021" [[root]] function = "uorust::mir::spec::MirAssertKind::path" @@ -695,7 +825,8 @@ definition = "mirAssertKindPath" package = "uorust_certified_mir_assert_kind_path" source = "3b3457831f90c5b16fb27cd7e0e0fafd895f5e17ac6320d0c8d31774c71577a9" certification = "kernel-checked" -closure = "00db1897a7aba367c2e997a00e5e395220f323d94cc1203a665ee317c7b9d537" +closure = "e4f83327a0a6983ce8b701e6ecf88b432e6c46a0345b775b25b96d4e58876994" +edition = "2021" [[root]] function = "uorust::mir::spec::MirBinOp::path" @@ -704,7 +835,8 @@ definition = "mirBinOpPath" package = "uorust_certified_mir_bin_op_path" source = "d2f3e8629b53a9210a4081348dc79a951a78ec5425c9bf3693165ce093911865" certification = "kernel-checked" -closure = "bc967f526fd7d954c0bee3ff1e2cd1fdd2b7381d43edf26a7eb9a72f30415299" +closure = "3785f8ec2878bd0184b1c6bc1a4ecbccae808c31550722ca9b94e1832699b9b2" +edition = "2021" [[root]] function = "uorust::mir::spec::MirBorrowKind::path" @@ -713,7 +845,8 @@ definition = "mirBorrowKindPath" package = "uorust_certified_mir_borrow_kind_path" source = "b0a6505e2d3f0b0917c6a7da1dc6891189125274744c06333ea3b28a475dec86" certification = "kernel-checked" -closure = "50d57d7aa7b647c9f2c9cb5f1e262416e6efb845456f7400f77d48835e9a7b13" +closure = "bd2c49a352224e12334fac84051a510dc566784f8e2534480c976c24c97b4484" +edition = "2021" [[root]] function = "uorust::mir::spec::MirCastKind::path" @@ -722,7 +855,8 @@ definition = "mirCastKindPath" package = "uorust_certified_mir_cast_kind_path" source = "b6cc5d8338b8bd2b37043a4ee58abf32157acbdf18e8638165bf8c2c5867c4c7" certification = "kernel-checked" -closure = "c6bfd4770c7edccda3c95fb4454a02845d8a61322fcb9ae5e0306ced562dfec5" +closure = "e0130a68cef583b490e23d78284984d755f87f138d913a0ac2c4dd4d07b24667" +edition = "2021" [[root]] function = "uorust::mir::coverage::cast" @@ -731,7 +865,8 @@ definition = "mirCoverageCast" package = "uorust_certified_mir_coverage_cast" source = "d9c1960f40d3eaa606f3dcb9a8cb1dbbac72b25edea6459e3ee0402180add533" certification = "kernel-checked" -closure = "cd7bdd9877ded5209071acdda4bb6d3fb248876f9a38c89504e58a5c46a3d700" +closure = "6dba211aa9ffdc85596e513968e14272c54ccb8e42dd4fba8c6fc14ca9c264e7" +edition = "2021" [[root]] function = "uorust::mir::coverage::intrinsic" @@ -740,7 +875,8 @@ definition = "mirCoverageIntrinsic" package = "uorust_certified_mir_coverage_intrinsic" source = "da74df1004033c3a3e44f37e7825e1540098bf1b235822551ffd72fb09f94488" certification = "kernel-checked" -closure = "a7d12e0faf8c8503daffa97d958933ba78d39fd072279d8dab25d4cf61646d61" +closure = "13f2e42ca33884556e4fdd05d77e50671e685f1d3c54bc16fc0a4c4dc4c9227c" +edition = "2021" [[root]] function = "uorust::mir::coverage::operand" @@ -749,7 +885,8 @@ definition = "mirCoverageOperand" package = "uorust_certified_mir_coverage_operand" source = "69e9366d9cd869f8863acd7cda2c764ca1a02882660f6c2714bc17234d9a3618" certification = "kernel-checked" -closure = "0a3c09786d5364e23614bdc763213031d8ccee197307e328c2c1a6e6cfa844c5" +closure = "b3dba3d9af4c608e41da235c1f2eba61b8ca97a66b6e57ddbbbed86bd4cd8bb7" +edition = "2021" [[root]] function = "uorust::mir::coverage::rvalue" @@ -758,7 +895,8 @@ definition = "mirCoverageRvalue" package = "uorust_certified_mir_coverage_rvalue" source = "b59fadd2d988facd38248e8ebcd63ee79309e3bf1c2a886130a168777bbce7c8" certification = "kernel-checked" -closure = "207ef9ba442cc04c9c288ab366cf8c92455635f08a7d71da674bf9e8ef868bac" +closure = "0e80681d8192c3ad8ed155d5dcc6adf18624877cf5c1fdb749340a4adb12063d" +edition = "2021" [[root]] function = "uorust::mir::coverage::statement" @@ -767,7 +905,8 @@ definition = "mirCoverageStatement" package = "uorust_certified_mir_coverage_statement" source = "237c07560382a60fe16aae5c40e0ba0fbb1445da064e1ba46e5530ad0506237f" certification = "kernel-checked" -closure = "995735bac8f48fe177bc5a3f7d04a4c2c7b3822017c2139c70eaf916cc29ce1a" +closure = "5d5edb1122d15863d05e3bffd190438d3df2e880b689efff8f781e332c0e426c" +edition = "2021" [[root]] function = "uorust::mir::coverage::terminator" @@ -776,7 +915,8 @@ definition = "mirCoverageTerminator" package = "uorust_certified_mir_coverage_terminator" source = "c75e0a7ef5decc8df0f31419a3a645a710f1890b6e4c48d9eaeaf3cc9dfdac74" certification = "kernel-checked" -closure = "2131a602b8a24f3a8d23c6b21974abca6e7058fc6a23b1d0a46cbc916225e7d2" +closure = "c7edfbda8d68bff0b49f7d9d9381de8494a5f4a0b28347d2b1304855ec4a7ae2" +edition = "2021" [[root]] function = "uorust::mir::memory::axioms" @@ -785,7 +925,8 @@ definition = "mirMemoryAxioms" package = "uorust_certified_mir_memory_axioms" source = "7e70a8ed0f3d9302729d40b810fa3e2b33c9fa032faf2f509410b907b51ff230" certification = "kernel-checked" -closure = "79d1dfb5695888439fcc29a285cc6f8b6ba5d8babb33c1cd2db0c4eb607e0ed6" +closure = "35d958ccf3eec0f4df040bccb0f4809ebb8e52f606c537278eba6a1f0d1c84d2" +edition = "2021" [[root]] function = "uorust::mir::spec::MirNonDivergingIntrinsic::path" @@ -794,7 +935,8 @@ definition = "mirNonDivergingIntrinsicPath" package = "uorust_certified_mir_non_diverging_intrinsic_path" source = "224ff1666fb4e14f3228858eb7eff38b6e7a14c4188329885ac431114dbbb7bf" certification = "kernel-checked" -closure = "1042c8531162865c1e030a60ea82555874010a000803fb819a43d3095bdd9d98" +closure = "c57f8736fdeae4b05faa5aa0ae355dc5073b2fedb8eb31d96340ab84fec80b52" +edition = "2021" [[root]] function = "uorust::mir::spec::MirOperand::path" @@ -803,7 +945,8 @@ definition = "mirOperandPath" package = "uorust_certified_mir_operand_path" source = "790a0b04257c4de9723e75f384e40a43121d24e29368ff28a116bfaab4b77b60" certification = "kernel-checked" -closure = "fa63cc3d5fab40a98eeb4ffa5fcc3729debb5ea47e1974933a60f9228cfb3ee6" +closure = "08eb9c0162a7cde84a0b5dd3c9dcc9b7c9a60d2680aeac712951b2f51e2b9c0f" +edition = "2021" [[root]] function = "uorust::mir::spec::MirProjectionElem::path" @@ -812,7 +955,8 @@ definition = "mirProjectionElemPath" package = "uorust_certified_mir_projection_elem_path" source = "c63280560916f035c01aa8c5062dd0f8f6af2e5d3a68a27b23702621e9bff2bc" certification = "kernel-checked" -closure = "df9712ad1b721deb71dd2ab3ae96f12c027964335bb30a3805eb100b8d6b407c" +closure = "7bc143ba29377d9b9d5944ea9b73ac6385c6113c3ef7dd7ff22a2770a8f58ce4" +edition = "2021" [[root]] function = "uorust::mir::spec::MirRuntimeChecks::path" @@ -821,7 +965,8 @@ definition = "mirRuntimeChecksPath" package = "uorust_certified_mir_runtime_checks_path" source = "c45226e9740b682fa2524db3a1c77782cbc55141a31332702b9b9646e29d8f62" certification = "kernel-checked" -closure = "922019a38b343eda161f258922cccf2006f06a449571dcafc28eacb9e01b8e4b" +closure = "1e2e3c8322740cbae365f3722b336b2dd1cb4ec53c1bd1b9bcf24a1f0d2f363b" +edition = "2021" [[root]] function = "uorust::mir::spec::MirRvalue::path" @@ -830,7 +975,8 @@ definition = "mirRvaluePath" package = "uorust_certified_mir_rvalue_path" source = "3ce332c340d82a549df119f2b95f5e33519a571eca89457d5679ff3db16cb090" certification = "kernel-checked" -closure = "c597e031bea4db5441df9b0ace914424e74ae4748adbe5f04dd094ca3e60e5b7" +closure = "839fd32ed0685fb16c4e36c1c2e7d0eb1bc89a564a02dc4075ba4657dece1f7c" +edition = "2021" [[root]] function = "uorust::mir::spec::MirStatementKind::path" @@ -839,7 +985,8 @@ definition = "mirStatementKindPath" package = "uorust_certified_mir_statement_kind_path" source = "df6de68b18848fd37243d97a5886460dc1dbadd9ed0710002cc20250b34d0dd9" certification = "kernel-checked" -closure = "208300fbde170504f0d89edf800cf05ccde75dd9ae87cd2cb22bf3513402bab9" +closure = "65a623a382449107fae227a9a51acdb4935b946cfa2a0ef506f0f7ae36ac90cb" +edition = "2021" [[root]] function = "uorust::mir::spec::MirTerminatorKind::path" @@ -848,7 +995,8 @@ definition = "mirTerminatorKindPath" package = "uorust_certified_mir_terminator_kind_path" source = "315b764b8af467784b6a3698710b2a5049f11f60a57da59bbefe53a32f271b80" certification = "kernel-checked" -closure = "091084fb9d760a3ba111593412abe7ee9d195ed254aa289de296d5370709cf07" +closure = "f263bfa21e7a7c701195c8949c0ddcb22f17d351bb3b04d19f195188993914c2" +edition = "2021" [[root]] function = "uorust::mir::spec::MirUnOp::path" @@ -857,16 +1005,18 @@ definition = "mirUnOpPath" package = "uorust_certified_mir_un_op_path" source = "8ea84703ddbb73dea4b72287895dc1aec090bd72028fd617fbbd67ea1b89ba27" certification = "kernel-checked" -closure = "a3f436f1b77d782a997f6830bcc18e70f20e558378dca1d18083efee8334e077" +closure = "2518a314adba828bb5b2427923f6aa81283d3f9914f4bdd6c46d546fe7d667ef" +edition = "2021" [[root]] function = "uorust::lex::Module::path" kappa = "3b5b843d81bcdbe59266384d6ce729152de4484a5c5e03df2ceaa513d4d5cadd" definition = "modulePath" package = "uorust_certified_module_path" -source = "3780ac7720ef389ca25bae9c1e1fcb39682b620320d1a9ee8071ab4c65664a19" +source = "f92c6be4bbb96f8ba9881cac833bb761f6644b1a8894b5c762b669671ace6360" certification = "kernel-checked" -closure = "4e66f39aaf4925c3f4a75e8ef3b523df59662088312785ec34cd59dedc0158bf" +closure = "180eae7ac2531647bfba419523b97cb52964eb99e5b7b472036a52284dda25a3" +edition = "2021" [[root]] function = "uorust::mir::lower::mut_target" @@ -875,7 +1025,18 @@ definition = "mutTarget" package = "uorust_certified_mut_target" source = "41c940c1cf359e97df74012b9c5a977625f860cff2eb8b8639e04cf28904e0f0" certification = "kernel-checked" -closure = "3ea4278545a1c144cf1130abf3124c41e34abb252f8952c69db4f3342464e025" +closure = "7bd1ac3e99aba9019203c34a0f06588a0af9184dbead929cb69f66752de3b6fc" +edition = "2021" + +[[root]] +function = "uorust::lift::name_taken" +kappa = "7a1da87547a0501a5ab60a798e5956c7eafc2b5978fe7af4a157ee7795a64104" +definition = "nameTaken" +package = "uorust_certified_name_taken" +source = "9bd6ff7d238fbdf32a4b7985c1e07c70ea8eb36433800e9069beacf28827aac2" +certification = "kernel-checked" +closure = "0324e750f8f72b5523269156b4e9dc1eee18c665a3e108fe9a1a639ec2cfa72b" +edition = "2021" [[root]] function = "uorust::lift::named_field" @@ -884,115 +1045,138 @@ definition = "namedField" package = "uorust_certified_named_field" source = "123d6bdbaa30c3c0a6e54143df3c7de980db09c2c01aae8196769c542f582497" certification = "kernel-checked" -closure = "d0a284ab2d9d379d3e1d8bc18aae1479fa4914da89dbe640eb2849f69af19d72" +closure = "15402e0d1a716620fbaad70823ceb51413e665673f9c95d924afa14b9f40d62d" +edition = "2021" [[root]] function = "uorust::lift::named_in" kappa = "673cdbb5ad7f9344acbfbe2ef0a1450e9feaa5e71070d015d54f12e0ade9a6e4" definition = "namedIn" package = "uorust_certified_named_in" -source = "c27d895f20dd67a9bc7be307b076c48a70ebecf73c0e257495ddd03a27dd81da" +source = "5f62334596532a3aaccac24bd8a3f838c508581d9724d3233c865ec3a5aa4fc9" certification = "kernel-checked" -closure = "950283b493c1ff8fce1a5944b16732f8e85af43a5e3b5f12ce36fb989f7b4653" +closure = "4d6d7c990e42f98b621822609894ca806c9315662867a9bad63f5c9ea91380b0" +edition = "2021" [[root]] function = "uorust::mir::lower::needs_address" kappa = "3ba6543b3c24da1e772a69f2fb760c1d5dc78700835b276273033aef27139746" definition = "needsAddress" package = "uorust_certified_needs_address" -source = "76ac1d1c2e1c013223c3a837a8dff3e0afea8475a13837297885ef8b495b8956" +source = "2871427f4aa86b8f7b061fa0bcf76661c120f11f4d673a3f5c34acf432d215eb" certification = "kernel-checked" -closure = "c9fb58268bba9b441283e45cbbca78d783c227155f43bfff582ce1e28b60f15b" +closure = "2858107f43170795a41f202a9862f95d9de90a6346609bd1bdb82bcd39e0c0a3" +edition = "2021" [[root]] function = "uorust::mir::lower::needs_memory" kappa = "bde72c5383d8fb3e70aa51a52c13728981eb630ffe716ce2fa12cbf5a52fc2e8" definition = "needsMemory" package = "uorust_certified_needs_memory" -source = "e90a1f380260e6487686c72f9a45b252731ed94b51d5108944e6f012ad2cbba7" +source = "585f8448ead7c26a6c8adba4aa6e6330397ed0019a6dbc9bf1e036892dcfe895" certification = "kernel-checked" -closure = "7249d6d6b25f5b2f930a1b5f3d44d862e40182f96a4be9a18cb4b226c71c65e6" +closure = "e1ce0f22ef369d09ac2a1f0f0a4bed1dc16803f34df4f2b48804029eaaba5b57" +edition = "2021" [[root]] function = "uorust::lift::none_of" kappa = "160fa0308816df0b691741aa54ae358f63f18609cdee064c395c66bd4abb23d3" definition = "noneOf" package = "uorust_certified_none_of" -source = "5ca11a2069fd634fa51846cbfb9eca699fa80ba81b4e3d2a6abda19c0d2e59db" +source = "0117556ea23a9ddb05064ab14437a6ad31a4cd70a45ecb9fe08df13496e7adea" certification = "kernel-checked" -closure = "e7a2dcc5c383980a5bd9606589b166fc5b09e74048ea9b10cc79d73695b9b679" +closure = "b018cec122a4571e375ba4393a0ba7c172ce4db320aab58574be2f192e9c3a7b" +edition = "2021" [[root]] function = "uorust::mir::memory::of" kappa = "e83d1a3e8e8538c70fd7f676a0642097b35177d7941aba7928b22c755bd5e7ca" definition = "of" package = "uorust_certified_of" -source = "e9a9afc6fc7a7a81ab53345a69b78dc0e4824515deba322eeb55e07fbe71299d" +source = "5a392ffab0ba004a6e22556282c89a04c4dbaf0ce1818efee39b96e1ef034f83" certification = "kernel-checked" -closure = "a44f3e46bc89a2a121f948cf8bcbae36ce90f5134d67a3d2b95ea48626ec76c6" +closure = "5dd8e358434fe141df81d378909a6ae7d8c32e005c1a9f7ee47a275a9d28fcf8" +edition = "2021" [[root]] function = "uorust::lift::opt_of" kappa = "c1ff22086007cc3d71c18bc7bb8718d0f2f7c19dfc2dfc86a32d1bacc545ebe7" definition = "optOf" package = "uorust_certified_opt_of" -source = "51fedf6bd61cb0a4c5e86a697ff2044e9b58ea70a8524cb460227cb9dfbe5454" +source = "fb00a025fdddfa5e224e61444304b749c16d7e5c32c7d94a504fd17112f6d7ed" certification = "kernel-checked" -closure = "dcb9e11cf1ccb795aaa45c16d8023d3114a17010fae625e70978be5aa2af291f" +closure = "ef471d2d23187dd29262fb4401eb941ed7b54cd7547f8a9d17f4d8d26b91bec1" +edition = "2021" [[root]] function = "uorust::lex::params" kappa = "eed3bbb135ec803687ee54bb6f66a15301bf12c4ce907a632af0d0fd8381d8d8" definition = "params" package = "uorust_certified_params" -source = "afc3d2a2a27a91b5adaa4647610047bf46654343fe1ca9eb17049ea0b76250b1" +source = "8a37233ccecbdac9889a52a4e13c2ada78ba61327cba5c52c6ece079ea41e6dd" +certification = "kernel-checked" +closure = "83bae612a690775efbb636071695a3585100d3bcf96e09ef5287bd28d1de7f03" +edition = "2021" + +[[root]] +function = "uorust::lex::pascal" +kappa = "548a3c1396c0fe8b72fdda4ebb9f675442b958dc416743af9a50d0c3d416946b" +definition = "pascal" +package = "uorust_certified_pascal" +source = "ac247566cfbd25eb5fea5371aefeced42066a2d9ef732411ee05a4d6c024626a" certification = "kernel-checked" -closure = "6517db19a44e9d214bbf5069f253ffcf830486f8508bbf277c6a36cdbce208a3" +closure = "adec8ca0072b28c8334ba418f283eaafa43faddaade4bca38d27839b7e40cb0b" +edition = "2021" [[root]] function = "uorust::mir::lower::plain_cell" kappa = "70a5dc8bec23fe7b2456f7f72e21a06ae9def6df8dac10ffadf47797546368e8" definition = "plainCell" package = "uorust_certified_plain_cell" -source = "3a765e187981f7368194d8a2219995a2a12c16a36ff2c60e59d88f3c1f06a936" +source = "5c000133c9d0870bfa090d5dcb242289d41c6965679fd8e6a54af135abd6cff3" certification = "kernel-checked" -closure = "e20a1306e23c31cafaf0563761a9acc02876b82af54527f8ebe3c3ad3635d1d5" +closure = "4965daff4a5ea0a004e46475ff17454b44ef6044c00a691c33e82834b2e25683" +edition = "2021" [[root]] function = "uorust::mir::lower::pointer_fields" kappa = "73dc254259250ba33b656ff830f3fb89480246045c90efc8ce4081b7c431e996" definition = "pointerFields" package = "uorust_certified_pointer_fields" -source = "ef6c60f0bc2de555cd6c970db7eccc4f139401a8866b7ea5d2073be832fcda55" +source = "f30c2ab5c90a4e000f22f76b8b39c1cac8906712b1827e1930cd19535f48da00" certification = "kernel-checked" -closure = "170b6286321596df79acc207bcc8a227040a4193e86f9eaadb8d96fd6a0f1bcc" +closure = "75cffa11a2b68b1e77e05b1edfc236b472c17f9386f56d6d92400ced8f489e03" +edition = "2021" [[root]] function = "uorust::mir::lower::pointer_value" kappa = "8a14edbc109ac4c3d7d54a92fe50be1d1ce5c4c7876ee0084d86794d87a30896" definition = "pointerValue" package = "uorust_certified_pointer_value" -source = "8b3907876e65c59fc2bcfee9dc356660b69810272a1e9b7423d223b748885c65" +source = "73310eee73a574a6158603e724ef2530bd9f300dcf9e6159c25be8d99c2e2d34" certification = "kernel-checked" -closure = "c9ab21808251bb85bf14c5ab493131f1308269724c1db163c9113bde87b826c1" +closure = "39c5ac7104cd5f89070b5b3c84f82c936372c57523ecbbf095971ae7608da691" +edition = "2021" [[root]] function = "uorust::lift::pointer_width" kappa = "93f59d7433add38636a1fd1955b12e12f1558c4d69e33fc45ef6cbe3b3b8d834" definition = "pointerWidth" package = "uorust_certified_pointer_width" -source = "4b7ff194251577e82cbf2b43df047c7405156ff7d1d1b2c9c68486690490f6b3" +source = "78cca21bd9cb62dcf1362ff623d870bf022b2a931d78cc62d15a28e4bc1e5c1f" certification = "kernel-checked" -closure = "22614827d1ec3540811379749e481265d101c9a5f8a32107e335999d8a5fafab" +closure = "0b4656ce7ef7b88266d1f4ee0bec862d37fc776087c13c1548c9e79dc7cef833" +edition = "2021" [[root]] function = "uorust::lift::pointer_widths" kappa = "20bd5e218d21872edf3a0dad90b54c06cc6837e1acc4ac2b13de991826170660" definition = "pointerWidths" package = "uorust_certified_pointer_widths" -source = "2bb4a3256237bfda18cf4a45474764c325ce7a0b9e03ea912dfec93d7d248739" +source = "635551365d8189f8d81a14e8906670dd5df87758fc587ee0e17490cf0c20e661" certification = "kernel-checked" -closure = "d77e25383615bea1bd14c104945e51b05f9573e3871119e57b0f4fd9dd8aaada" +closure = "8acba02932ba9770609cf8a3631030f66357f2f7b06566a201c028a5b1f65ac2" +edition = "2021" [[root]] function = "uorust::mir::coverage::projection" @@ -1001,16 +1185,18 @@ definition = "projection" package = "uorust_certified_projection" source = "3c36310f1eb54129fe13e29f362715be2bd31d8af77e0c94b06900ebbebd532b" certification = "kernel-checked" -closure = "0d8d98d1bc0d047b6dc11d2ed4ca117ae6a53442c0b1104e63dd7870ab744e17" +closure = "9985cbb1e5aa8ee3d7d6be3f55114937882b5092b85fa2a9179d49899481683c" +edition = "2021" [[root]] function = "uorust::mir::layout::reason" kappa = "e04624761c8813403d0aa2c061d8d2b50c1453bfbc480bb446c8c634db66f38d" definition = "reason" package = "uorust_certified_reason" -source = "5d854303f603786c192be53d75b1d071ce34dd8c13ce40b6382cb306ebfb5e95" +source = "6b82265afef414bed09ef5e0bdacc5c0e513d61a5a9b99371ff67f5a68e2bee8" certification = "kernel-checked" -closure = "ada0193745f08b097e34743db7f77bedcc466f7efe4f66360920f62677e89f7e" +closure = "f63c185d6fd3e3fa7bbf3d1014037725cd651d9df757fcdab3f10ce88fe50174" +edition = "2021" [[root]] function = "uorust::mir::lower::referent" @@ -1019,7 +1205,18 @@ definition = "referent" package = "uorust_certified_referent" source = "0dcb52ec8c1240a5584343cb1673ce1b767b3ac58e16ab5b71deb5aeaf277088" certification = "kernel-checked" -closure = "6c95d81fbc5eb3d517575102bfece4ed8024208c76eec416f22be90353fc95ac" +closure = "eb304efa1060384e116bc7c20354c5a58f99252885edb0d10f45e8b602659c0a" +edition = "2021" + +[[root]] +function = "uorust::lift::refused" +kappa = "6de4c8ec05979ad95602c832c8f8adc48ad49cb8907800d2fa126bafb9ac19db" +definition = "refused" +package = "uorust_certified_refused" +source = "20ab532918365c0b4b5acdc6ef7ee7b74909767bf18d08d3759c596c467e1af0" +certification = "kernel-checked" +closure = "6689fc14fe74cee25295ebb284d971aae319c8270f3157cd097dfbedbca93da7" +edition = "2021" [[root]] function = "uorust::lift::Residue::code" @@ -1028,16 +1225,18 @@ definition = "residueCode" package = "uorust_certified_residue_code" source = "33cb6e6ea42ca12c1c1a158f751b6e9ad5a0352a9f1687c6d5d9c8ce209e6c59" certification = "kernel-checked" -closure = "28e28e5c0255132fe76c6bd67ac59f2e2dd5c6cc530ee0de6179f38af6114593" +closure = "b2bd16d913d11dc1b53712452a6a5baab06d4de0c719b54028eba5e504507db5" +edition = "2021" [[root]] function = "uorust::lift::Residue::detail" kappa = "931ce096e620cbc47dbe46390d3c15d8ac274f56fc564c3ba691d75dc0baaeb2" definition = "residueDetail" package = "uorust_certified_residue_detail" -source = "595212eb11d3cf46e611f0119dbf634b203765f71047a99e8639b27764374462" +source = "ab455e436ef5f32bedd57d1cfd69f2bd4af4e219291a94515e6de4ec4a7fc8dc" certification = "kernel-checked" -closure = "fe7c34134047e6c042ff24a1b710ebd9f724e49eb6ce58d86cbcb4e138a35b00" +closure = "db1dda258d6e36a4d65fae96dbc3185fc20e2bb52bccae239d82f38c67d6b05e" +edition = "2021" [[root]] function = "uorust::lift::returned" @@ -1046,7 +1245,8 @@ definition = "returned" package = "uorust_certified_returned" source = "772c132c272bc110e97ea534da8966eda4937ce0d313e5cad64cb49f86bf9e94" certification = "kernel-checked" -closure = "411e5d84be3d9ec6365d21d406551d2b240ecc6521280116a6047b2a8cc296b9" +closure = "eff36e75c5987b1202f024a1475c80b68edfaa34c3713ca3d4835e080b92ed9a" +edition = "2021" [[root]] function = "uorust::mir::coverage::runtime_checks" @@ -1055,25 +1255,28 @@ definition = "runtimeChecks" package = "uorust_certified_runtime_checks" source = "d2ec2b926c5773bdc89f646c670918e23e95ee162c6bfde645a483f74c524b6d" certification = "kernel-checked" -closure = "9662d086dfa02934b27fa1c4b47514ae68ecf30af81e03cfa1ad443d42304927" +closure = "be5f73dcdebf31f953d8d3cfcacf83b61858695ca62ba0b269b2d3eab3fa8ac6" +edition = "2021" [[root]] function = "uorust::lift::same_constructor" kappa = "201fd6f5370c2260d9e2118bce76a7aa5b20e6b2b22d18169537e4f77d93013e" definition = "sameConstructor" package = "uorust_certified_same_constructor" -source = "527f58836f0329165560db30f3186bd53f9056a619f6c23ce07ddd946fe550b5" +source = "dc24e62147436c62df12106519ad6025a5d8706ea79bddaf041325cbfe2a2741" certification = "kernel-checked" -closure = "bb5f2ef08c13972f7d637d269b555f3bf07e8ddd76360c77e6179932651ad0e1" +closure = "6364f684590f020efe97a424609e56256d5f14b855452a788876164e8b169d41" +edition = "2021" [[root]] function = "uorust::mir::lower::scalar_value" kappa = "658be6382910603f89063b2260891b4fbfb7aec293ba58a2d6f36cb8dda8c0e6" definition = "scalarValue" package = "uorust_certified_scalar_value" -source = "e316c59d1f15806328890b02f9a928a6ae49c5c8e32bfd5eb78b8ab170fdc5c8" +source = "bbd7582b514a349663811a827409766794bee3c54bfd799324e2c367e5a18af2" certification = "kernel-checked" -closure = "29287db994fbd4ad081ca4b66883da61aac786e2dd3d60b097f29d67d708671b" +closure = "39e5dffb17e59c4824b1a6d5fa2fdff85dcdaa55b5fe4859c25254ae14ead21f" +edition = "2021" [[root]] function = "uorust::lift::settled" @@ -1082,34 +1285,48 @@ definition = "settled" package = "uorust_certified_settled" source = "e77a06e9822b41c577c9f6e7e79a90b13b2cdf932183e87b46611bb0b1253621" certification = "kernel-checked" -closure = "76d4dfea833fa5ddc1fb4ab8f8f17dad1b4051ba69b61d3f7fc142e6052867e4" +closure = "693e6e28afc8d573440169fe24ee5b83ca6717c46cfec58d0e9bfa146b7da9b6" +edition = "2021" [[root]] function = "uorust::mir::lower::single_field" kappa = "ab8b087cdb28516ec99d3f174646addc96fb76d449f346c280dbe34e69da7101" definition = "singleField" package = "uorust_certified_single_field" -source = "90d87aeba30aa88c7ac5ed4eb9d5de11c8dc8f287e7a6ce599b5b1ef93fc58e1" +source = "82432eba744b0097700a50332e8d3ab5807c4818a94a36e6f263c67614526913" certification = "kernel-checked" -closure = "a6494579c00ef6c7405bee085a8112824044f177d89e0328ffcdf273197eab6f" +closure = "1b9c592d81f2df44d67b9d52902f9920ce78472c1dcf54b4bb1d82080f673a76" +edition = "2021" [[root]] function = "uorust::lift::size_suffix" kappa = "8a06236aca30e5c62bf58c0e3e026bc7c96baee8064e17aa23d111af5357a65f" definition = "sizeSuffix" package = "uorust_certified_size_suffix" -source = "3591d41f4e8b4182888edfe26d27cf19b41b823748685603ca35b0f64d851076" +source = "69fbb00db52fcc15f0cad884c092a7b020e64e7aad6e5196837cdaed3e78c2ab" certification = "kernel-checked" -closure = "dee12ba83f9bb418377322cc37b60affd81498927087d4b21c140b38fb46fe11" +closure = "f68552fe313ca33e11c5cd27aa437687f8d674cf547c5d525586d37d78bb4e44" +edition = "2021" [[root]] function = "uorust::lift::some_of" kappa = "469501c6bfa9bcb3867b0f2f0da862e7e47cbac21a9d1b6e1222140f05f4574e" definition = "someOf" package = "uorust_certified_some_of" -source = "6434b8e0c9e94bd77be5355acf126c18d12ea33da270ece72c1a3c86f803229f" +source = "b37b75408dcf67a140132adf6aa70a6613642f4aa3c4d3c2b06593a1ea87cd64" +certification = "kernel-checked" +closure = "eeb6128145e03629524533638abda1037fbd318a1ddffa9e476920effef2a7e6" +edition = "2021" + +[[root]] +function = "uorust::lift::some" +kappa = "4feab33361b371e47eb831675c36c6c5dbdaa8a3229aad69b870157fb2525228" +definition = "someValue" +package = "uorust_certified_some_value" +source = "6d4dca15067df227de6f27ac4174b919c8c59aea66875abba9a14a47769ebd80" certification = "kernel-checked" -closure = "dd2acdf0883b13fb1bdf61838c44871192a5e3c905db046b494d6937d17c3958" +closure = "dbd6415e50211f1605e1c63866b7e21aa6e1aa2b43ff5fc7e9a0882ae850cad6" +edition = "2021" [[root]] function = "uorust::lift::state_expr" @@ -1118,7 +1335,38 @@ definition = "stateExpr" package = "uorust_certified_state_expr" source = "dd0e66f81583d28bc97b533350ccf97ed5780be851ad61ffe0ee658f22d1e0fd" certification = "kernel-checked" -closure = "8e815c852771d831a7c389a25a1e1ed58e2096d2df87c0a1492635f3dd1b5fbb" +closure = "2a8c53508e7590c3058c31e7d6c9d2dbcedaf20a8500f67d239448a626306fbc" +edition = "2021" + +[[root]] +function = "uorust::lift::std_path" +kappa = "69dd66085c364077047e892eeddcb14faa11ea674ab5726f9ac92b7811defad7" +definition = "stdPath" +package = "uorust_certified_std_path" +source = "2ba8c173b781432178c4e85725da97b9a6564f967189822b580054ef62ec9a72" +certification = "kernel-checked" +closure = "97cf65b85bd8534015c668d8e283277cb8bb476a8353869ae980018a5893039c" +edition = "2021" + +[[root]] +function = "uorust::lift::struct_cells" +kappa = "92794968d3b2d1c0aca715a4299e5e9826f8b7dc181e5933f108dbf8ed84863f" +definition = "structCells" +package = "uorust_certified_struct_cells" +source = "189600c92214d91ca27738e788581278703c6ab3cae4837dfc26776b8668f057" +certification = "kernel-checked" +closure = "9ca86675552552be0777e0ea2ef29daa469313b6d1bb947e544c6fe94f68c66f" +edition = "2021" + +[[root]] +function = "uorust::lift::struct_value" +kappa = "ccbed5f276702aeb8a5a0a22cc077eff427ce371382dcb56548bac162d3033df" +definition = "structValue" +package = "uorust_certified_struct_value" +source = "980b4bb36d13dc434c5e7121f0b295fecfbafe9a736cb48f6004c38381580646" +certification = "kernel-checked" +closure = "bf5f303c1886839feae5ae3fde4d415be9893aade48959fdd0ba0ef7a7aac029" +edition = "2021" [[root]] function = "uorust::lift::then_rest" @@ -1127,16 +1375,18 @@ definition = "thenRest" package = "uorust_certified_then_rest" source = "bee24dd3c81856b475708876cf6b47ba391310fe445b9a7c4bed59c6180f875e" certification = "kernel-checked" -closure = "c34c67405113a3f66168aea1ccce2dbcad118fa136332d7ef0c84371bc119ffc" +closure = "caabe30ba760e5038acc7acd18414979ac7345f42f2f4de998cf2d5e117b2693" +edition = "2021" [[root]] function = "uorust::mir::lower::through_pointer" kappa = "3585dd6116cdeebce028dedbb5b88148b2d7440f69055645158db1c436677bed" definition = "throughPointer" package = "uorust_certified_through_pointer" -source = "f1fe6b2beac3a4e54844519d2a96dd87f69b130bc803230f853f2d166054cf6e" +source = "7893473a6eb9404d4de1782bc99226fa5e7ad73a3fad0f16da486f1c20742049" certification = "kernel-checked" -closure = "94cc8cc3d0a579a180afabec7e43ee3c57e5c43d53afe3ca0cfeae0b44285578" +closure = "ecae6be72a3eff75ea1d72d30f32f9d21838debe99f8ab16ae8074849338c521" +edition = "2021" [[root]] function = "uorust::mir::Trial::admits" @@ -1145,124 +1395,128 @@ definition = "trialAdmits" package = "uorust_certified_trial_admits" source = "72d85baca581f79c65c5844a18e565291b269101781ea301a74baa26186b5ad7" certification = "kernel-checked" -closure = "fd122f43688cfe5c10d4ba3a26229c0097e8552ed218837c0c06d479b2c903d5" +closure = "a1080383c2b9904d22b22da7fa61f8dcc1d2e9044c0c75959f2ea38f12f2b5ca" +edition = "2021" [[root]] function = "uorust::lift::tuple_item" kappa = "0bf991a1eea796ea190d1cfc9ff552271328ed4f949780744e5793b7233882cc" definition = "tupleItem" package = "uorust_certified_tuple_item" -source = "d3d6c92f96460d56190d9d1c44d502d3190a5df508ed3f8176ee87753349e312" +source = "bc1b9adce876ca73b9e60302824efa70ac13ce3529c736e03ed9071e10b3af8d" +certification = "kernel-checked" +closure = "d45f33572dc7b5a144fc3c5f9ceedb9aced1cca43eca3c7c5c343abaa1f75103" +edition = "2021" + +[[root]] +function = "uorust::lift::tuple_struct" +kappa = "199e15dc577b1d2e4baaf50c1a545f5ea261f84c5947e17f432f349e8fb97f9c" +definition = "tupleStruct" +package = "uorust_certified_tuple_struct" +source = "8bb4d3762f2f68d6ba900992c31fce24c29d8f85fd3f538a13a57eb1ade3fe30" certification = "kernel-checked" -closure = "d65dad9d8a6701ce795b82e34d138ca08f56f26a7a8431bc6744d190ad255381" +closure = "cf349f2ec544f66f8911db5b191787fd6e4dced18de2f5d88f0d26c3a9c9d7b7" +edition = "2021" [[root]] function = "uorust::lift::tuple_value" kappa = "6d597a25a6a1c39ba49293b3a48996aa1d811e342be8e319de27ff9811dc69b0" definition = "tupleValue" package = "uorust_certified_tuple_value" -source = "1a8b0138f6a17c111a4436f9a6a8e16cbd55ef2ad188787d650b40e4ac49726d" +source = "9e88a9f0b576a799c14866c33f493006d41674ea22b38933275fc946e0492b28" certification = "kernel-checked" -closure = "81826f5cb14e1b5b24db273d0d8dc9a55d1b49786ad30c830a45394fd4197056" - -[[root]] -function = "uorust::lift::Ty::entry" -kappa = "543f83e17ea3c7c7a0f72f577eaf755c827a71a6c0e25796b841ba79ded5eb75" -definition = "tyEntry" -package = "uorust_certified_ty_entry" -source = "f74487cbb8edf9876a2224bbfd5b71d5d3bce8048153db5dee2fc5ba6a429977" -certification = "kernel-checked" -closure = "e8aef887469a4cde1dfb6911848d8db402ff010d640aa0516ff217ce5cfc474b" - -[[root]] -function = "uorust::lift::Ty::render" -kappa = "f95f90aabcd550da6a694e5702eed73b44eca6e9d3ce71ab28060c92e791fd95" -definition = "tyRender" -package = "uorust_certified_ty_render" -source = "029e7ee631e7b7c0e10455e9589b40391cec758202f63af5eab9143b1d5a6948" -certification = "kernel-checked" -closure = "a24af0066ad57b00cfbc76f0a2bd333d71df17e131d12caf81a08c4fa5ab9082" - -[[root]] -function = "uorust::lift::Ty::same" -kappa = "7762a395a1911b2e3f3fc632c8ef5768390a6bad5ab7f1964c4e33dfe13f7468" -definition = "tySame" -package = "uorust_certified_ty_same" -source = "ff6da980035cad5e26b64429a72480eeeb229154e766bda81ed67ac2d8154c04" -certification = "kernel-checked" -closure = "37bb8feca49a16819418cb8ca71287ab37141a3b0fc2ec1d13d4165171e74aaa" - -[[root]] -function = "uorust::lift::Ty::tag" -kappa = "9d9512bf2c91b294cce1521ef4a120cfd1f2848575f1572a435b0b0b2092473f" -definition = "tyTag" -package = "uorust_certified_ty_tag" -source = "513e6126f8c62790f1d31fadb3e6f29fbd2d40577d5c20a49ddbfdfb7ab1d6d0" -certification = "kernel-checked" -closure = "4a5bb9ea9c850584c98f91ef2e4a57fad2822c9cd8317cd8ae50737b2322f931" +closure = "539a9641af5b7b0b97d8437051791964d57cb5a19a8fc25359f4a80d6776eef2" +edition = "2021" [[root]] function = "uorust::lift::Types::accessor" kappa = "5b1db3a24f0ce568624150909f94be0817b5fd53a27753653bf5b4cb0fe64f36" definition = "typesAccessor" package = "uorust_certified_types_accessor" -source = "9599520d04d0ed96ef3bba6f145e424a8107f6e987b8a33be16b62490d8b5c59" +source = "83b57d4f012ac2fbe05e3b1bdce5e2e38cdf1707cc6846275b9deff07bd58dfb" certification = "kernel-checked" -closure = "1eb70f784edd37a55f53413f674181c91caab1ff23f525dfc1452971e1427397" +closure = "fbe75fba845b5a6c192b48b6934eeeabd369292cdb554b935349f02d099e0212" +edition = "2021" [[root]] function = "uorust::lift::Types::boxed" kappa = "09f87861c9b064234e13a90b4a77b5de6a4d6d82d2b1b6a4cbcebfb94efc70f4" definition = "typesBoxed" package = "uorust_certified_types_boxed" -source = "61e122b364e7e4cf18681f51fd0c116eb48bc701a209510bbc9233181feb895d" +source = "27696a5f559ed3dd9251c9d9b65a0b5a8fe80e69ad2b61993a1ef2173813e986" +certification = "kernel-checked" +closure = "75c761b608b65a6ee131c12f09ccb7ddea70c1e4a48d08c00f8ea3af8bada77c" +edition = "2021" + +[[root]] +function = "uorust::lift::Types::declares" +kappa = "9c58e93380a2f4be8ff34f4701620549ec7eec65d403a7ee4e4d4090668d5ee7" +definition = "typesDeclares" +package = "uorust_certified_types_declares" +source = "336d6ae5361d598ea55da47c8e13586078adcdc13b25e23546e8f1e94077fcfa" certification = "kernel-checked" -closure = "8f2270bf4d71f5871e29e10656cb8e888f84878ec69494a7ca361690bbd8fb23" +closure = "3626439cbe1a9fd6082e72f2f55ef067dca05d30c1a677e4d294838454ac08fd" +edition = "2021" [[root]] function = "uorust::lift::Types::family_of" kappa = "c9aea8208e5215269776909f967196678adac819813f35afd74cd514dc41ef4b" definition = "typesFamilyOf" package = "uorust_certified_types_family_of" -source = "f0b8f6bf284846608773cea3a447b18cb98d14908f2a74ea2262a54365bc1553" +source = "5f5f64226e821ff3164cc161868393854e9e9e8bd330e29f15ce65ffa43d8628" certification = "kernel-checked" -closure = "1e7190d7c9a76edb818f558bf552ffbbba8306de85ac837e378b62248c6a3c48" +closure = "97205d6d7a8b6a27820ee12345e65e5abf3137d244764733eea2b8b21f424100" +edition = "2021" [[root]] function = "uorust::lift::types_has_data" kappa = "de2ca02eeaa740e42da48aa79a532dd978a33811a219054f4428d3c5c75563e0" definition = "typesHasData" package = "uorust_certified_types_has_data" -source = "f58cd405ab8d6d10c5e3db1d7d3c28ab21057bdbc194f1f61043a97f59f4e962" +source = "e934fefc8a4a1ab35873da9fc9b6be2a923158a0fb6323b2837d7c92c9cae615" certification = "kernel-checked" -closure = "ce1ab5ac06893ad680c4e512fcfab1b54ad9d98e9154e2f526dbabcbd3c509de" +closure = "945e649c33bd018adfca71598b919e09731c6d002f7fc76fbc60790b04864d6f" +edition = "2021" [[root]] function = "uorust::lift::Types::resolve" -kappa = "cbe30114b7921677e5d8f5eb5468566ccf1efb331eb748d5aee828f785bac773" +kappa = "271faa030f4563bcc2fdf6c5042a2a286f7f1c41ef94e24dbdb9cb4f5d10eccd" definition = "typesResolve" package = "uorust_certified_types_resolve" -source = "0163b1f239a872c9f8a06efb43d133adcbb04207db09ec70454db1b2580e5216" +source = "21dde66ddfefc1a28d2adfad877325f89f6015f19c527371be4464a93591809c" certification = "kernel-checked" -closure = "be88797007b5348da7da056280e834c8469711b914110e89cfae940c4a589729" +closure = "7e156ccb2f346855b16e8ada137a4397da08bf84f6035ad2c880ce3d9e270a8d" +edition = "2021" [[root]] function = "uorust::lift::Types::size_name" kappa = "ee7f8c251085eebc28a8d49f6f847463a5399c931b6255a50567071a43a7ef31" definition = "typesSizeName" package = "uorust_certified_types_size_name" -source = "70ac62e7b530d8d61bde38ba1871bf57b0fb5255b8e528e290c37acd6a2ee0c6" +source = "2f201716e3acf38575e3f229017000768765b65820fd71e1c2c74b33e07c93ad" +certification = "kernel-checked" +closure = "d03707c2d7c22204ea8366fa59251baef08e70d72a272fb7ecb95b41d64f630b" +edition = "2021" + +[[root]] +function = "uorust::lift::Types::unnamed" +kappa = "a94e9d0b9c8ac98c340478e94a6816620b90a9418098d24035b00ded25f71406" +definition = "typesUnnamed" +package = "uorust_certified_types_unnamed" +source = "ebb887f5cf94a74f606b459fdfd1dacf6e6626590a69ab12f3c928b86663dd5b" certification = "kernel-checked" -closure = "b50a799925861fe299973d376ce284fd89210959da304ad98d368a60c0b661a6" +closure = "734f92c81f8ef64eba550cd4b6b1a54e510135fc37f2ec2d79550d11c97e7651" +edition = "2021" [[root]] function = "uorust::lift::unicode_property" kappa = "24d859b19c5ef875d871a3f92bbf53f218072313fa2611ed4e7de0c8d826ecf8" definition = "unicodeProperty" package = "uorust_certified_unicode_property" -source = "3fb90f3e9cfe77c657901617dade99b052bca482ab31fcc24872ad6b117cd3dc" +source = "4ea68e98a816bca6f9e2f2634d858146fa0c192d5bd51cfc12d3e91deedb7feb" certification = "kernel-checked" -closure = "a7f06be2c76cab7e73311803e05019f304ab4dac4212e27c05aa34ccd492c2a2" +closure = "f898eed36c4eebbff18f0cc2db5f5b77a7ddd0ace562c5f78abee3ad6b294ad5" +edition = "2021" [[root]] function = "uorust::mir::lower::uninhabited" @@ -1271,7 +1525,8 @@ definition = "uninhabited" package = "uorust_certified_uninhabited" source = "d1592690054d900a109061d72be77c3fee1681fcb3be3a1496ef2d281155564e" certification = "kernel-checked" -closure = "efb0eff0ea65ff8a0939c9b4a4acbeedfcc3ddd5c26b19e335808aa1214fcea2" +closure = "4e2c3afcc03fa9adbb87b11905674badf3ef3b58120b4d9b23af246260234f48" +edition = "2021" [[root]] function = "uorust::mir::coverage::unop" @@ -1280,7 +1535,18 @@ definition = "unop" package = "uorust_certified_unop" source = "734625f90133eec015da9aaa38d6b7a1ee1ecb1cf74c0475349c88545817c957" certification = "kernel-checked" -closure = "8a8fbc717eb5bbba307f7b4ae09689b7f0250b2f5d91f0820a01f2bb1e8fa12d" +closure = "bbbb61c9155f5a040dd87d8bc2a7b8acb21ba06fe2e71b2577d773f906a20c20" +edition = "2021" + +[[root]] +function = "uorust::lift::unread_shape" +kappa = "76e3e6531070b60cc669ec718eed98f82b4dbce14e8c7285b601a9e93589551b" +definition = "unreadShape" +package = "uorust_certified_unread_shape" +source = "636500a7665e65961a3bef2876d1ed4102215531f72167301c71bb75023f8303" +certification = "kernel-checked" +closure = "f39f0e581f8ac84e814f2632332d48a56b52bd7f10f6cfa14bf9610b96280ca0" +edition = "2021" [[root]] function = "uorust::lift::untyped" @@ -1289,7 +1555,8 @@ definition = "untyped" package = "uorust_certified_untyped" source = "5e8f62d0124852636d016b2b2ae668e59d57c2a780574545dd6b4d593cebaf9c" certification = "kernel-checked" -closure = "75a850eea0ff5f71bc514852ba3e5f67bda922b18327ae04907413bb66a081c7" +closure = "13f47dce36be70ead3f9a842ac8346e81e8ddaea1695138807778486944c37c8" +edition = "2021" [[root]] function = "uorust::mir::int::helper" @@ -1298,7 +1565,48 @@ definition = "uorustHelper" package = "uorust_certified_uorust_helper" source = "2ba391ef93ebdd3fbe4934f3a6424318ed5cd85fc168e711f0bc00bd76c2d135" certification = "kernel-checked" -closure = "fb2f7f150960be1b92f5a381a7f74040f5443b0b79ed8425d1c863a567033717" +closure = "8150720b5845f008ccb940f83b1f128f509b06ae21b5728c8ece86cfd58409ad" +edition = "2021" + +[[root]] +function = "uorust::lift::Ty::entry" +kappa = "543f83e17ea3c7c7a0f72f577eaf755c827a71a6c0e25796b841ba79ded5eb75" +definition = "uorustLiftTyEntry" +package = "uorust_certified_uorust_lift_ty_entry" +source = "b314be9229c77222ac536d42f50212f7f10480b5b9cf756b53d422f531e9205d" +certification = "kernel-checked" +closure = "c78bc8cc05eaf9e8cbd0f5e37463341cc1de6e7d5414e2c9cb4aa4eb842eb947" +edition = "2021" + +[[root]] +function = "uorust::lift::Ty::render" +kappa = "1e56b6dd169d0468c1fb447754d8e854d1549da9abf3a9aa67c36fbe2fce465b" +definition = "uorustLiftTyRender" +package = "uorust_certified_uorust_lift_ty_render" +source = "b457d950b002bdceafb9268e38d4ee239fe395ac8c87ca7b3f77759110ecb725" +certification = "kernel-checked" +closure = "6a4916b7308e54a026885c2024a71974b9d3b973fd4148a615ec0e54be66ef4f" +edition = "2021" + +[[root]] +function = "uorust::lift::Ty::same" +kappa = "7762a395a1911b2e3f3fc632c8ef5768390a6bad5ab7f1964c4e33dfe13f7468" +definition = "uorustLiftTySame" +package = "uorust_certified_uorust_lift_ty_same" +source = "1b246df6d37eb8d8c529295052db3ebefcee8b14d3e3cc14b7c187097934a0f3" +certification = "kernel-checked" +closure = "94ed8878ba9451857577a22da942b9c430f904376457dc89c0fd32fa63789221" +edition = "2021" + +[[root]] +function = "uorust::lift::Ty::tag" +kappa = "85466712ddf48cd71077c88f5e758f4d27387e5f847f4ee2d3758a9a0a4d63c1" +definition = "uorustLiftTyTag" +package = "uorust_certified_uorust_lift_ty_tag" +source = "f43371d901d087bf6e39a3e013af8123e0c0dc1f43889f566ea6a9ef7a8b672d" +certification = "kernel-checked" +closure = "a12c25e426f14d0c3cf415c6d5f1e8b0832b5505eb450eb17190147f02f2b82b" +edition = "2021" [[root]] function = "uorust::mir::core::Scope::core" @@ -1307,7 +1615,8 @@ definition = "uorustMirCoreScopeCore" package = "uorust_certified_uorust_mir_core_scope_core" source = "33f4b25de44ec460e58e99d321a2a860bc336a7c3427474b8f6fa6237f5adae0" certification = "kernel-checked" -closure = "f400124caea50f2ace9921bf173fa6b0e20d065afb079bfcea421d55f41889ec" +closure = "eb9b9b1756d6c479aa1a6be286e3881f5478edf773f830cdc1d2f4fc1897de8e" +edition = "2021" [[root]] function = "uorust::mir::core::Scope::library" @@ -1316,43 +1625,48 @@ definition = "uorustMirCoreScopeLibrary" package = "uorust_certified_uorust_mir_core_scope_library" source = "5cd0127282b550e19e1f5799ddb347732d91ad1cf31ba61c3cb7f9154bd5d198" certification = "kernel-checked" -closure = "2cbaf847bf8e6583853be6a7bc9cb75e1db3e434aadc800d3f512031506a2b34" +closure = "d7d0e4327e6f8596fc146cd47d9bd7cb4e8516b6576666222f689d011f4b1945" +edition = "2021" [[root]] function = "uorust::mir::core::Scope::registry" kappa = "d93ee866e5746e929da97ea6dc939bf1db9975f1a9dda63a7041932cd5553e0b" definition = "uorustMirCoreScopeRegistry" package = "uorust_certified_uorust_mir_core_scope_registry" -source = "f5f86d011010c7d5077fa50f5a14d8acaef0a3a8cd2888a6e5665df18425fa57" +source = "9d9a0d850c1f4c0d7ef3381d195e0d5659ac35dab9cc8a27d1351b4838e82801" certification = "kernel-checked" -closure = "a245dc32e27e422f44a59a5f3fd2596d4a091336123a3b19dbada54256c2f69c" +closure = "c165f1b221e7f9dc50052073130ecd4d546a6b4b45f72823a3cb5c103771f6ab" +edition = "2021" [[root]] function = "uorust::mir::layout::Refusal::text" kappa = "1bc30116949784e7dd00e6a5c1df7be67a9a75166d1e47b65c75933e5af6462f" definition = "uorustMirLayoutRefusalText" package = "uorust_certified_uorust_mir_layout_refusal_text" -source = "c94f985ee974f415464b8ae5f87495ac14d6b3fc5e0d62314db825096887fd27" +source = "e95886eef556b4ea286ca033c57716258ef119249aa6d06e2718b07ad309c12e" certification = "kernel-checked" -closure = "546f7ae21ef1cc17a6163817e3b2fb8825c66ac5645b02e590dc3db367b46844" +closure = "4593dba0b9511e164d8f0fc7ff0bd54d98fc0c3dfd7e01ba3c33c8902ee6caba" +edition = "2021" [[root]] -function = "uorust::mir::generate::sha256" -kappa = "7940536b9d3c9d1a2739dabea275ea8063d89ca3b818fbc8c1f7841faf543450" -definition = "uorustSha256" -package = "uorust_certified_uorust_sha256" -source = "cb120d95dcc0c4e6fe5e969789c0b38e3ceb6376c62cc86c5085ca0e7104b8ff" +function = "uorust::lift::variant_field" +kappa = "1a59153d411d6fca562dde737dfcacefa42c3b467f0bace213f6cc6592661521" +definition = "variantField" +package = "uorust_certified_variant_field" +source = "3078860ec7ea79f70f66f7554d64d2f8ac71b45e31a64efc8f85a43d439f99f4" certification = "kernel-checked" -closure = "6752e29ab68121505b7277b1431be77c23aec24a1d55199e8836f4bdbb9199fa" +closure = "99bae8d3b52b15302c412467791a1445a3689cf7bdc720470942c3b1ff4348c1" +edition = "2021" [[root]] function = "uorust::lift::variant_owner" kappa = "e23985b01d982d7d49eb88cc3ae46d0222a96b23813655811c314b7aaa62c6b5" definition = "variantOwner" package = "uorust_certified_variant_owner" -source = "80f0569410a2e9ae0b39093538ce2aeb06e1cf8b1b2bec11b8f9b4c76968b354" +source = "e692ce33fab0a2dff4323b524df4ee9f1619dc2a38487e2f1004bf8480047ee8" certification = "kernel-checked" -closure = "3055c3d729af8b9f779ae0f19118b27ee7d63cdc80aebcce25b4ef3cf7c4848d" +closure = "e5ae197c753233a47722e19fae613d9d045a972b2e0df25e1e84d7189b8feffc" +edition = "2021" [[root]] function = "uorust::lift::word_char" @@ -1361,7 +1675,8 @@ definition = "wordChar" package = "uorust_certified_word_char" source = "2d9b5ed9d70b49a331c98cbcdd61fab08d257306e657e95a89cbac9ac37783f8" certification = "kernel-checked" -closure = "1a3b63765d360ad6a69d959c293af2dfae36363e3114d4f81f20732984859d6a" +closure = "d5775c24ba53601b29d5e1e03248503aa725706879dff827c2e95a0906b0f7a2" +edition = "2021" [[root]] function = "uorust::lift::wrap_lets" @@ -1370,7 +1685,8 @@ definition = "wrapLets" package = "uorust_certified_wrap_lets" source = "ac472f486bfe5d97f20c06d0d537b42c738f48e1bc06e580427fef277fe5a5b2" certification = "kernel-checked" -closure = "997b316ef8673f1b261fd34e1dfd661720baa50c368c06431277a594d22b8933" +closure = "609f7afd137b0e0a463685222a4d3a5e50ac85c870bfcb97bb1aa848e096621f" +edition = "2021" [[refused]] kappa = "0bd257c18e1a137976f064f13724a3ecaf23ca3e1d4e8bcef8056a06f9cfc4c6" diff --git a/crates/certified/roots/uorust_certified_acc_all_axioms.rs b/crates/certified/roots/uorust_certified_acc_all_axioms.rs index 04133867..ff149391 100644 --- a/crates/certified/roots/uorust_certified_acc_all_axioms.rs +++ b/crates/certified/roots/uorust_certified_acc_all_axioms.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -977,18 +978,20 @@ pub fn f2(v0: List) -> List { } pub fn f3() -> List { - List::cons(Str::lit("Classical.choice"), List::cons(Str::lit("Quot.sound"), List::cons(Str::lit("propext"), List::::nil()))) + let a9 = List::cons(Str::lit("Classical.choice"), List::::nil()); + let a10 = List::cons(Str::lit("Quot.sound"), List::cons(Str::lit("propext"), List::::nil())); + append_list(a9, a10) } -pub fn f4(p11: List, p12: List) -> List { - let m10 = (p11, p12); +pub fn f4(p13: List, p14: List) -> List { + let m12 = (p13, p14); { - let mut m10 = m10; + let mut m12 = m12; loop { let step = { - let (v0, v1) = m10; - let m9 = v0; - match m9.uncons() { + let (v0, v1) = m12; + let m11 = v0; + match m11.uncons() { None => { Err::<(List, List), List>(v1) } @@ -998,7 +1001,7 @@ pub fn f4(p11: List, p12: List) -> List { } }; match step { - Ok(next) => { m10 = next; } + Ok(next) => { m12 = next; } Err(done) => break done, } } @@ -1006,23 +1009,23 @@ pub fn f4(p11: List, p12: List) -> List { } pub fn f5(v0: List, v1: Str) -> List { - let m13 = v0; - match m13.uncons() { + let m15 = v0; + match m15.uncons() { None => { List::cons(v1, List::::nil()) } Some((v2, v3)) => { - let a14 = v1.clone(); - let a15 = v2.clone(); - if equal(a14, a15) { + let a16 = v1.clone(); + let a17 = v2.clone(); + if equal(a16, a17) { List::cons(v2, v3) } else { - let m18 = { - let a16 = v1.clone(); - let a17 = v2.clone(); - compare(a16, a17) + let m20 = { + let a18 = v1.clone(); + let a19 = v2.clone(); + compare(a18, a19) }; - if match m18 { + if match m20 { Ordering::Less => { true } diff --git a/crates/certified/roots/uorust_certified_acc_apart.rs b/crates/certified/roots/uorust_certified_acc_apart.rs index ee731b3e..d6010cc0 100644 --- a/crates/certified/roots/uorust_certified_acc_apart.rs +++ b/crates/certified/roots/uorust_certified_acc_apart.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_acc_axiom.rs b/crates/certified/roots/uorust_certified_acc_axiom.rs index cfb8b815..2869fb9d 100644 --- a/crates/certified/roots/uorust_certified_acc_axiom.rs +++ b/crates/certified/roots/uorust_certified_acc_axiom.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_acc_axioms_all.rs b/crates/certified/roots/uorust_certified_acc_axioms_all.rs index 64cffb5d..7c56148a 100644 --- a/crates/certified/roots/uorust_certified_acc_axioms_all.rs +++ b/crates/certified/roots/uorust_certified_acc_axioms_all.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_acc_called.rs b/crates/certified/roots/uorust_certified_acc_called.rs index 1bd4777d..55b30f4e 100644 --- a/crates/certified/roots/uorust_certified_acc_called.rs +++ b/crates/certified/roots/uorust_certified_acc_called.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_acc_called_all.rs b/crates/certified/roots/uorust_certified_acc_called_all.rs index 58d35e11..30f3948f 100644 --- a/crates/certified/roots/uorust_certified_acc_called_all.rs +++ b/crates/certified/roots/uorust_certified_acc_called_all.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_acc_descended.rs b/crates/certified/roots/uorust_certified_acc_descended.rs index f40155a0..26ded37a 100644 --- a/crates/certified/roots/uorust_certified_acc_descended.rs +++ b/crates/certified/roots/uorust_certified_acc_descended.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_acc_helper.rs b/crates/certified/roots/uorust_certified_acc_helper.rs index d0768aa1..d5d31990 100644 --- a/crates/certified/roots/uorust_certified_acc_helper.rs +++ b/crates/certified/roots/uorust_certified_acc_helper.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_acc_rejoin.rs b/crates/certified/roots/uorust_certified_acc_rejoin.rs index 01f691c5..7da84d81 100644 --- a/crates/certified/roots/uorust_certified_acc_rejoin.rs +++ b/crates/certified/roots/uorust_certified_acc_rejoin.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_address.rs b/crates/certified/roots/uorust_certified_address.rs index 0f64db67..9fe515f2 100644 --- a/crates/certified/roots/uorust_certified_address.rs +++ b/crates/certified/roots/uorust_certified_address.rs @@ -856,9 +856,13 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: Str) -> Str { - let a1 = List::cons(Str::lit("(project "), List::cons(v0, List::cons(Str::lit(" address)"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("(project "), List::::nil()); + let a2 = List::cons(v0, List::cons(Str::lit(" address)"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) } pub fn run(p0: Str) -> Str { diff --git a/crates/certified/roots/uorust_certified_barred.rs b/crates/certified/roots/uorust_certified_barred.rs new file mode 100644 index 00000000..c1a45534 --- /dev/null +++ b/crates/certified/roots/uorust_certified_barred.rs @@ -0,0 +1,1402 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(Str, Adt1), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(bool, std::rc::Rc), + C1(std::rc::Rc), + C2(std::rc::Rc, Str), + C3(List, std::rc::Rc), + C4(std::rc::Rc), + C5(List), + C6(bool, Adt3), + C7, +} + +#[derive(Clone)] +pub enum Adt3 { + C0(List, Str), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(Str, Adt5), +} + +#[derive(Clone)] +pub enum Adt5 { + C0, + C1(List), + C2, +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Adt1), + C1(Str), +} + +pub fn f0(v0: Str, v1: bool, v2: List, v3: List) -> Option { + let m1 = v3; + match m1.uncons() { + None => { + if f1(v0.clone(), v1) { + Some({ + let a4 = { + let a2 = List::cons(v0, List::::nil()); + let a3 = List::cons(Str::lit(": "), List::cons(f2(), List::::nil())); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + join(a4, a5) + }) + } else { + let m6 = f3(v2); + match m6 { + None => { + None:: + } + Some(v4) => { + Some({ + let a9 = { + let a7 = List::cons(v0, List::cons(Str::lit("::"), List::::nil())); + let a8 = List::cons(v4, List::cons(Str::lit(": "), List::cons(f4(), List::::nil()))); + append_list(a7, a8) + }; + let a10 = Str::lit(""); + join(a9, a10) + }) + } + } + } + } + Some((v5, v6)) => { + let m11 = v6; + match m11.uncons() { + None => { + let v7: Str = match v5.clone() { + Adt0::C0(h12, _) => { + h12 + } + }; + let v8: Adt1 = match v5 { + Adt0::C0(_, h13) => { + h13 + } + }; + let a14 = v7; + let a15 = Str::lit(""); + if equal(a14, a15) { + Some({ + let a18 = { + let a16 = List::cons(v0, List::::nil()); + let a17 = List::cons(Str::lit(": "), List::cons(f5(v8), List::::nil())); + append_list(a16, a17) + }; + let a19 = Str::lit(""); + join(a18, a19) + }) + } else { + if f1(v0.clone(), v1) { + Some({ + let a22 = { + let a20 = List::cons(v0, List::::nil()); + let a21 = List::cons(Str::lit(": "), List::cons(f2(), List::::nil())); + append_list(a20, a21) + }; + let a23 = Str::lit(""); + join(a22, a23) + }) + } else { + let m24 = f6(v2); + match m24 { + None => { + None:: + } + Some(v9) => { + Some({ + let a27 = { + let a25 = List::cons(v0, List::cons(Str::lit("::"), List::::nil())); + let a26 = List::cons(v9, List::cons(Str::lit(": "), List::cons(f4(), List::::nil()))); + append_list(a25, a26) + }; + let a28 = Str::lit(""); + join(a27, a28) + }) + } + } + } + } + } + Some((_, _)) => { + if f1(v0.clone(), v1) { + Some({ + let a31 = { + let a29 = List::cons(v0, List::::nil()); + let a30 = List::cons(Str::lit(": "), List::cons(f2(), List::::nil())); + append_list(a29, a30) + }; + let a32 = Str::lit(""); + join(a31, a32) + }) + } else { + let m33 = f7(v2); + match m33 { + None => { + None:: + } + Some(v12) => { + Some({ + let a36 = { + let a34 = List::cons(v0, List::cons(Str::lit("::"), List::::nil())); + let a35 = List::cons(v12, List::cons(Str::lit(": "), List::cons(f4(), List::::nil()))); + append_list(a34, a35) + }; + let a37 = Str::lit(""); + join(a36, a37) + }) + } + } + } + } + } + } + } +} + +pub fn f1(v0: Str, v1: bool) -> bool { + let v2: bool = if v1 { + f8(v0.clone(), Str::lit("Tuple")) + } else { + false + }; + if if f9(f10(), v0.clone()) { + true + } else { + f8(v0, Str::lit("LexLean")) + } { + true + } else { + v2 + } +} + +pub fn f2() -> Str { + Str::lit("a type named as LexLean or the projection names one of its own") +} + +pub fn f3(p40: List) -> Option { + let m39 = p40; + { + let mut m39 = m39; + loop { + let step = { + let v0 = m39; + let m38 = v0; + match m38.uncons() { + None => { + Err::, Option>(None::) + } + Some((v1, v2)) => { + if f11(f12(), v1.clone()) { + Err::, Option>(Some(v1)) + } else { + Ok::, Option>(v2) + } + } + } + }; + match step { + Ok(next) => { m39 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f4() -> Str { + Str::lit("a variant named as a word LexLean reserves") +} + +pub fn f5(v0: Adt1) -> Str { + let m41 = v0; + match m41 { + Adt1::C0(v1, _) => { + v1 + } + } +} + +pub fn f6(p44: List) -> Option { + let m43 = p44; + { + let mut m43 = m43; + loop { + let step = { + let v0 = m43; + let m42 = v0; + match m42.uncons() { + None => { + Err::, Option>(None::) + } + Some((v1, v2)) => { + if f13(f12(), v1.clone()) { + Err::, Option>(Some(v1)) + } else { + Ok::, Option>(v2) + } + } + } + }; + match step { + Ok(next) => { m43 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f7(p47: List) -> Option { + let m46 = p47; + { + let mut m46 = m46; + loop { + let step = { + let v0 = m46; + let m45 = v0; + match m45.uncons() { + None => { + Err::, Option>(None::) + } + Some((v1, v2)) => { + if f14(f12(), v1.clone()) { + Err::, Option>(Some(v1)) + } else { + Ok::, Option>(v2) + } + } + } + }; + match step { + Ok(next) => { m46 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f8(v0: Str, v1: Str) -> bool { + f15({ + let a48 = v0; + utf8_encode(a48) + }, 0u64, { + let a49 = v1; + utf8_encode(a49) + }) +} + +pub fn f9(p54: List, v1: Str) -> bool { + let m53 = p54; + { + let mut m53 = m53; + loop { + let step = { + let v0 = m53; + let m50 = v0; + match m50.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a51 = v2; + let a52 = v1.clone(); + if equal(a51, a52) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m53 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f10() -> List { + let a67 = { + let a59 = { + let a55 = List::cons(Str::lit("And"), List::cons(Str::lit("BitVec"), List::cons(Str::lit("Bool"), List::::nil()))); + let a56 = List::cons(Str::lit("ByteArray"), List::cons(Str::lit("ContractViolation"), List::cons(Str::lit("Except"), List::::nil()))); + append_list(a55, a56) + }; + let a60 = { + let a57 = List::cons(Str::lit("Iff"), List::cons(Str::lit("Int"), List::cons(Str::lit("Int16"), List::::nil()))); + let a58 = List::cons(Str::lit("Int32"), List::cons(Str::lit("Int64"), List::cons(Str::lit("Int8"), List::cons(Str::lit("List"), List::::nil())))); + append_list(a57, a58) + }; + append_list(a59, a60) + }; + let a68 = { + let a65 = { + let a61 = List::cons(Str::lit("Nat"), List::cons(Str::lit("Option"), List::cons(Str::lit("Ordering"), List::::nil()))); + let a62 = List::cons(Str::lit("Prod"), List::cons(Str::lit("Prop"), List::cons(Str::lit("ReasoningFailure"), List::cons(Str::lit("Result"), List::::nil())))); + append_list(a61, a62) + }; + let a66 = { + let a63 = List::cons(Str::lit("String"), List::cons(Str::lit("Type"), List::cons(Str::lit("UInt16"), List::::nil()))); + let a64 = List::cons(Str::lit("UInt32"), List::cons(Str::lit("UInt64"), List::cons(Str::lit("UInt8"), List::cons(Str::lit("Unit"), List::::nil())))); + append_list(a63, a64) + }; + append_list(a65, a66) + }; + append_list(a67, a68) +} + +pub fn f11(p73: List, v1: Str) -> bool { + let m72 = p73; + { + let mut m72 = m72; + loop { + let step = { + let v0 = m72; + let m69 = v0; + match m69.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a70 = v2; + let a71 = v1.clone(); + if equal(a70, a71) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m72 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f12() -> List { + let a102 = { + let a86 = { + let a78 = { + let a74 = List::cons(Str::lit("at"), List::cons(Str::lit("by"), List::cons(Str::lit("calc"), List::cons(Str::lit("def"), List::cons(Str::lit("do"), List::cons(Str::lit("else"), List::::nil())))))); + let a75 = List::cons(Str::lit("end"), List::cons(Str::lit("example"), List::cons(Str::lit("fun"), List::cons(Str::lit("have"), List::cons(Str::lit("if"), List::cons(Str::lit("in"), List::::nil())))))); + append_list(a74, a75) + }; + let a79 = { + let a76 = List::cons(Str::lit("instance"), List::cons(Str::lit("let"), List::cons(Str::lit("match"), List::cons(Str::lit("mut"), List::cons(Str::lit("nomatch"), List::cons(Str::lit("open"), List::::nil())))))); + let a77 = List::cons(Str::lit("prop"), List::cons(Str::lit("return"), List::cons(Str::lit("show"), List::cons(Str::lit("then"), List::cons(Str::lit("theorem"), List::cons(Str::lit("type"), List::cons(Str::lit("where"), List::::nil()))))))); + append_list(a76, a77) + }; + append_list(a78, a79) + }; + let a87 = { + let a84 = { + let a80 = List::cons(Str::lit("with"), List::cons(Str::lit("from"), List::cons(Str::lit("for"), List::cons(Str::lit("try"), List::cons(Str::lit("catch"), List::cons(Str::lit("break"), List::::nil())))))); + let a81 = List::cons(Str::lit("continue"), List::cons(Str::lit("unless"), List::cons(Str::lit("structure"), List::cons(Str::lit("inductive"), List::cons(Str::lit("class"), List::cons(Str::lit("namespace"), List::cons(Str::lit("section"), List::::nil()))))))); + append_list(a80, a81) + }; + let a85 = { + let a82 = List::cons(Str::lit("local"), List::cons(Str::lit("private"), List::cons(Str::lit("protected"), List::cons(Str::lit("partial"), List::cons(Str::lit("unsafe"), List::cons(Str::lit("macro"), List::::nil())))))); + let a83 = List::cons(Str::lit("syntax"), List::cons(Str::lit("import"), List::cons(Str::lit("export"), List::cons(Str::lit("axiom"), List::cons(Str::lit("abbrev"), List::cons(Str::lit("opaque"), List::cons(Str::lit("mutual"), List::::nil()))))))); + append_list(a82, a83) + }; + append_list(a84, a85) + }; + append_list(a86, a87) + }; + let a103 = { + let a100 = { + let a92 = { + let a88 = List::cons(Str::lit("variable"), List::cons(Str::lit("universe"), List::cons(Str::lit("deriving"), List::cons(Str::lit("extends"), List::cons(Str::lit("suffices"), List::cons(Str::lit("obtain"), List::::nil())))))); + let a89 = List::cons(Str::lit("record"), List::cons(Str::lit("ctor"), List::cons(Str::lit("prim"), List::cons(Str::lit("project"), List::cons(Str::lit("cons"), List::cons(Str::lit("nil"), List::::nil())))))); + append_list(a88, a89) + }; + let a93 = { + let a90 = List::cons(Str::lit("not"), List::cons(Str::lit("true"), List::cons(Str::lit("false"), List::cons(Str::lit("forall"), List::cons(Str::lit("first"), List::cons(Str::lit("second"), List::::nil())))))); + let a91 = List::cons(Str::lit("apply"), List::cons(Str::lit("ref"), List::cons(Str::lit("checked"), List::cons(Str::lit("self"), List::cons(Str::lit("noncomputable"), List::cons(Str::lit("termination_by"), List::cons(Str::lit("and_congr"), List::::nil()))))))); + append_list(a90, a91) + }; + append_list(a92, a93) + }; + let a101 = { + let a98 = { + let a94 = List::cons(Str::lit("and_true"), List::cons(Str::lit("beq_iff_eq"), List::cons(Str::lit("congr"), List::cons(Str::lit("decide"), List::cons(Str::lit("decide_eq_false_iff_not"), List::cons(Str::lit("decide_eq_true_eq"), List::::nil())))))); + let a95 = List::cons(Str::lit("id"), List::cons(Str::lit("reduceIte"), List::cons(Str::lit("rfl"), List::cons(Str::lit("true_and"), List::cons(Str::lit("isFalse"), List::cons(Str::lit("isTrue"), List::cons(Str::lit("none"), List::::nil()))))))); + append_list(a94, a95) + }; + let a99 = { + let a96 = List::cons(Str::lit("some"), List::cons(Str::lit("below"), List::cons(Str::lit("brecOn"), List::cons(Str::lit("casesOn"), List::cons(Str::lit("ctorElim"), List::cons(Str::lit("ctorElimType"), List::::nil())))))); + let a97 = List::cons(Str::lit("ctorIdx"), List::cons(Str::lit("mk"), List::cons(Str::lit("noConfusion"), List::cons(Str::lit("noConfusionType"), List::cons(Str::lit("rec"), List::cons(Str::lit("recOn"), List::cons(Str::lit("toCtorIdx"), List::::nil()))))))); + append_list(a96, a97) + }; + append_list(a98, a99) + }; + append_list(a100, a101) + }; + append_list(a102, a103) +} + +pub fn f13(p108: List, v1: Str) -> bool { + let m107 = p108; + { + let mut m107 = m107; + loop { + let step = { + let v0 = m107; + let m104 = v0; + match m104.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a105 = v2; + let a106 = v1.clone(); + if equal(a105, a106) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m107 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f14(p113: List, v1: Str) -> bool { + let m112 = p113; + { + let mut m112 = m112; + loop { + let step = { + let v0 = m112; + let m109 = v0; + match m109.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a110 = v2; + let a111 = v1.clone(); + if equal(a110, a111) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m112 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f15(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m118 = { + let a115 = v0; + let a116 = v1; + let a117 = { + let a114 = v2.clone(); + length_bytes(a114) + }; + slice_bytes(a115, a116, a117) + }; + match m118 { + None => { + false + } + Some(v3) => { + let a119 = v3; + let a120 = v2; + equal(a119, a120) + } + } +} + +pub fn run(p0: Str, p1: bool, p2: List, p3: List) -> Option { + f0(p0, p1, p2, p3) +} diff --git a/crates/certified/roots/uorust_certified_called_value.rs b/crates/certified/roots/uorust_certified_called_value.rs index c46a0ba2..a9e0c879 100644 --- a/crates/certified/roots/uorust_certified_called_value.rs +++ b/crates/certified/roots/uorust_certified_called_value.rs @@ -873,20 +873,21 @@ pub enum Adt2 { C3(u64), C4(Adt3), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_camel.rs b/crates/certified/roots/uorust_certified_camel.rs new file mode 100644 index 00000000..691d01e7 --- /dev/null +++ b/crates/certified/roots/uorust_certified_camel.rs @@ -0,0 +1,1499 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, bool, bool), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str, bool), +} + +pub fn f0(v0: List) -> R { + let a1 = f1(f2(f3(f4(v0)?)?, 0u64)?)?; + let a2 = Str::lit(""); + Ok(join(a1, a2)) +} + +pub fn f1(v0: List) -> R> { + let m3 = v0; + match m3.uncons() { + None => { + Ok(List::::nil()) + } + Some((v1, v2)) => { + let v3: u64 = match v1.clone() { + Adt0::C0(h4, _) => { + h4 + } + }; + let v4: Str = match v1 { + Adt0::C0(_, h5) => { + h5 + } + }; + Ok(List::cons({ + let a6 = v3; + let a7 = 0u64; + if nat_eq(a6, a7) { + f5(v4)? + } else { + v4 + } + }, f1(v2)?)) + } + } +} + +pub fn f2(v0: List, v1: u64) -> R> { + let m8 = v0; + match m8.uncons() { + None => { + Ok(List::::nil()) + } + Some((v2, v3)) => { + Ok(List::cons(Adt0::C0(v1, v2), f2(v3, { + let a9 = v1; + let a10 = 1u64; + nat_add(a9, a10)? + })?)) + } + } +} + +pub fn f3(v0: Str) -> R> { + let v1: Bytes = { + let a11 = v0; + utf8_encode(a11) + }; + f6({ + let a12 = v1.clone(); + length_bytes(a12) + }, v1, 0u64) +} + +pub fn f4(v0: List) -> R { + let v1: Str = Str::lit(""); + let v2: Str = f7(v0, v1)?; + if f8(v2.clone())? { + let a13 = List::cons(Str::lit("N"), List::cons(v2, List::::nil())); + let a14 = Str::lit(""); + Ok(join(a13, a14)) + } else { + Ok(v2) + } +} + +pub fn f5(v0: Str) -> R { + f9(v0, 65u64, Bytes::lit(&[0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a])) +} + +pub fn f6(v0: u64, v1: Bytes, v2: u64) -> R> { + let m15 = v0; + if m15 == 0 { + Ok(List::::nil()) + } else { + let v3 = m15 - 1; + let a17 = { + let a16 = v1.clone(); + length_bytes(a16) + }; + let a18 = v2; + if nat_le(a17, a18) { + Ok(List::::nil()) + } else { + let v4: u64 = f10(f11(v1.clone(), v2)?); + Ok(List::cons(f12(v1.clone(), v2, { + let a19 = v2; + let a20 = v4; + nat_add(a19, a20)? + }), f6(v3, v1, { + let a21 = v2; + let a22 = v4; + nat_add(a21, a22)? + })?)) + } + } +} + +pub fn f7(p28: List, p29: Str) -> R { + let m27 = (p28, p29); + { + let mut m27 = m27; + loop { + let step = { + let (v0, v1) = m27; + let m23 = v0; + match m23.uncons() { + None => { + Err::<(List, Str), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: bool = true; + let v5: bool = false; + let v6: Adt1 = f13(f3(v2)?, Adt1::C0(v1, v5, v4))?; + let v7: Str = match v6.clone() { + Adt1::C0(h24, _, _) => { + h24 + } + }; + let _: bool = match v6.clone() { + Adt1::C0(_, h25, _) => { + h25 + } + }; + let _: bool = match v6 { + Adt1::C0(_, _, h26) => { + h26 + } + }; + Ok::<(List, Str), R>((v3, v7)) + } + } + }; + match step { + Ok(next) => { m27 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f8(v0: Str) -> R { + let m32 = { + let a30 = f3(v0)?; + let a31 = 0u64; + index_list(a30, a31) + }; + match m32 { + None => { + Ok(false) + } + Some(v1) => { + f14(v1) + } + } +} + +pub fn f9(v0: Str, v1: u64, v2: Bytes) -> R { + let v3: Bytes = { + let a33 = v0.clone(); + utf8_encode(a33) + }; + let m37 = { + let a36 = f15({ + let a34 = v3.clone(); + length_bytes(a34) + }, v3, 0u64, v1, v2, { + let a35 = Str::lit(""); + utf8_encode(a35) + })?; + utf8_decode(a36) + }; + match m37 { + None => { + Ok(v0) + } + Some(v4) => { + Ok(v4) + } + } +} + +pub fn f10(v0: u64) -> u64 { + let a38 = v0; + let a39 = 128u64; + if nat_lt(a38, a39) { + 1u64 + } else { + let a40 = v0; + let a41 = 224u64; + if nat_lt(a40, a41) { + 2u64 + } else { + let a42 = v0; + let a43 = 240u64; + if nat_lt(a42, a43) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f11(v0: Bytes, v1: u64) -> R { + let m46 = { + let a44 = v0; + let a45 = v1; + index_bytes(a44, a45) + }; + match m46 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a91 = { + let a67 = { + let a55 = { + let a49 = { + let a47 = v3; + let a48 = 128u8; + fixed_u8::bit_and(a47, a48) + }; + let a50 = 128u8; + if equal(a49, a50) { + 128u64 + } else { + 0u64 + } + }; + let a56 = { + let a53 = { + let a51 = v3; + let a52 = 64u8; + fixed_u8::bit_and(a51, a52) + }; + let a54 = 64u8; + if equal(a53, a54) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a55, a56)? + }; + let a68 = { + let a65 = { + let a59 = { + let a57 = v3; + let a58 = 32u8; + fixed_u8::bit_and(a57, a58) + }; + let a60 = 32u8; + if equal(a59, a60) { + 32u64 + } else { + 0u64 + } + }; + let a66 = { + let a63 = { + let a61 = v3; + let a62 = 16u8; + fixed_u8::bit_and(a61, a62) + }; + let a64 = 16u8; + if equal(a63, a64) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a65, a66)? + }; + nat_add(a67, a68)? + }; + let a92 = { + let a89 = { + let a77 = { + let a71 = { + let a69 = v3; + let a70 = 8u8; + fixed_u8::bit_and(a69, a70) + }; + let a72 = 8u8; + if equal(a71, a72) { + 8u64 + } else { + 0u64 + } + }; + let a78 = { + let a75 = { + let a73 = v3; + let a74 = 4u8; + fixed_u8::bit_and(a73, a74) + }; + let a76 = 4u8; + if equal(a75, a76) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a77, a78)? + }; + let a90 = { + let a87 = { + let a81 = { + let a79 = v3; + let a80 = 2u8; + fixed_u8::bit_and(a79, a80) + }; + let a82 = 2u8; + if equal(a81, a82) { + 2u64 + } else { + 0u64 + } + }; + let a88 = { + let a85 = { + let a83 = v3; + let a84 = 1u8; + fixed_u8::bit_and(a83, a84) + }; + let a86 = 1u8; + if equal(a85, a86) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a87, a88)? + }; + nat_add(a89, a90)? + }; + nat_add(a91, a92) + } + } +} + +pub fn f12(v0: Bytes, v1: u64, v2: u64) -> Str { + let m98 = { + let a95 = v0; + let a96 = v1; + let a97 = { + let a93 = v2; + let a94 = v1; + nat_sub(a93, a94) + }; + slice_bytes(a95, a96, a97) + }; + match m98 { + None => { + Str::lit("") + } + Some(v3) => { + let m100 = { + let a99 = v3; + utf8_decode(a99) + }; + match m100 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f13(p116: List, p117: Adt1) -> R { + let m115 = (p116, p117); + { + let mut m115 = m115; + loop { + let step = { + let (v0, v1) = m115; + let m101 = v0; + match m101.uncons() { + None => { + Err::<(List, Adt1), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: Str = match v1.clone() { + Adt1::C0(h102, _, _) => { + h102 + } + }; + let v5: bool = match v1.clone() { + Adt1::C0(_, h103, _) => { + h103 + } + }; + let v6: bool = match v1 { + Adt1::C0(_, _, h104) => { + h104 + } + }; + let a105 = f16(v2.clone())?; + if bool_not(a105) { + let v7: bool = true; + let v8: bool = false; + Ok::<(List, Adt1), R>((v3, Adt1::C0(v4, v8, v7))) + } else { + let v14: Adt2 = if v6 { + let v9: Str = { + let a106 = List::cons(v4, List::cons(f17(v2.clone())?, List::::nil())); + let a107 = Str::lit(""); + join(a106, a107) + }; + let v10: bool = false; + Adt2::C0(v9, v10) + } else { + let v13: Str = if if f18(v2.clone())? { + let a108 = v5; + bool_not(a108) + } else { + false + } { + let v11: Str = { + let a109 = List::cons(v4, List::cons(f5(v2.clone())?, List::::nil())); + let a110 = Str::lit(""); + join(a109, a110) + }; + v11 + } else { + let v12: Str = { + let a111 = List::cons(v4, List::cons(v2.clone(), List::::nil())); + let a112 = Str::lit(""); + join(a111, a112) + }; + v12 + }; + Adt2::C0(v13, v6) + }; + let v15: Str = match v14.clone() { + Adt2::C0(h113, _) => { + h113 + } + }; + let v16: bool = match v14 { + Adt2::C0(_, h114) => { + h114 + } + }; + let v17: bool = if f19(v2.clone())? { + true + } else { + f14(v2)? + }; + Ok::<(List, Adt1), R>((v3, Adt1::C0(v15, v17, v16))) + } + } + } + }; + match step { + Ok(next) => { m115 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f14(v0: Str) -> R { + let v1: u64 = f20(v0)?; + let a118 = 48u64; + let a119 = v1; + if nat_le(a118, a119) { + let a120 = v1; + let a121 = 57u64; + Ok(nat_le(a120, a121)) + } else { + Ok(false) + } +} + +pub fn f15(p144: u64, v1: Bytes, p145: u64, v3: u64, v4: Bytes, p146: Bytes) -> R { + let m143 = (p144, (p145, p146)); + { + let mut m143 = m143; + loop { + let step = { + let (v0, (v2, v5)) = m143; + let m122 = v0; + if m122 == 0 { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } else { + let v6 = m122 - 1; + let m126 = { + let a123 = v1.clone(); + let a124 = v2; + let a125 = 1u64; + slice_bytes(a123, a124, a125) + }; + match m126 { + None => { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } + Some(v7) => { + let v8: u64 = f11(v1.clone(), v2)?; + let v10: Bytes = { + let a127 = v3; + let a128 = v8; + if if nat_le(a127, a128) { + let a131 = v8; + let a132 = { + let a129 = v3; + let a130 = 26u64; + nat_add(a129, a130)? + }; + nat_lt(a131, a132) + } else { + false + } { + let m138 = { + let a135 = v4.clone(); + let a136 = { + let a133 = v8; + let a134 = v3; + nat_sub(a133, a134) + }; + let a137 = 1u64; + slice_bytes(a135, a136, a137) + }; + match m138 { + None => { + v7 + } + Some(v9) => { + v9 + } + } + } else { + v7 + } + }; + Ok::<(u64, (u64, Bytes)), R>((v6, ({ + let a139 = v2; + let a140 = 1u64; + nat_add(a139, a140)? + }, { + let a141 = v5; + let a142 = v10; + append_bytes(a141, a142) + }))) + } + } + } + }; + match step { + Ok(next) => { m143 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f16(v0: Str) -> R { + if f21(v0.clone())? { + Ok(true) + } else { + f14(v0) + } +} + +pub fn f17(v0: Str) -> R { + f9(v0, 97u64, Bytes::lit(&[0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a])) +} + +pub fn f18(v0: Str) -> R { + let v1: u64 = f20(v0)?; + let a147 = 65u64; + let a148 = v1; + if nat_le(a147, a148) { + let a149 = v1; + let a150 = 90u64; + Ok(nat_le(a149, a150)) + } else { + Ok(false) + } +} + +pub fn f19(v0: Str) -> R { + let v1: u64 = f20(v0)?; + let a151 = 97u64; + let a152 = v1; + if nat_le(a151, a152) { + let a153 = v1; + let a154 = 122u64; + Ok(nat_le(a153, a154)) + } else { + Ok(false) + } +} + +pub fn f20(v0: Str) -> R { + f11({ + let a155 = v0; + utf8_encode(a155) + }, 0u64) +} + +pub fn f21(v0: Str) -> R { + if f18(v0.clone())? { + Ok(true) + } else { + f19(v0) + } +} + +pub fn run(p0: List) -> R { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_captures.rs b/crates/certified/roots/uorust_certified_captures.rs index 59dcaa14..74eb8483 100644 --- a/crates/certified/roots/uorust_certified_captures.rs +++ b/crates/certified/roots/uorust_certified_captures.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_comb_collect.rs b/crates/certified/roots/uorust_certified_comb_collect.rs index 4ba0cd91..be2e5fa9 100644 --- a/crates/certified/roots/uorust_certified_comb_collect.rs +++ b/crates/certified/roots/uorust_certified_comb_collect.rs @@ -1194,20 +1194,21 @@ pub enum Adt48 { C3(u64), C4(Adt49), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -1307,10 +1308,14 @@ pub fn f0(v0: Adt0, v1: Str, v2: Adt48, v3: Adt48, v4: Adt50) -> Result<(Option< } else { let v6: Adt50 = f3(v4, Str::lit("propext")); f4({ - let a2 = List::cons(Str::lit("(prim join "), List::cons(v1, List::cons(Str::lit(" \"\" : String)"), List::::nil()))); - let a3 = Str::lit(""); - join(a2, a3) - }, Adt48::C6, v6) + let a4 = { + let a2 = List::cons(Str::lit("(prim join "), List::::nil()); + let a3 = List::cons(v1, List::cons(Str::lit(" \"\" : String)"), List::::nil())); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + join(a4, a5) + }, Adt48::C7, v6) } } else { f4(v1, v3, v4) @@ -1318,27 +1323,27 @@ pub fn f0(v0: Adt0, v1: Str, v2: Adt48, v3: Adt48, v4: Adt50) -> Result<(Option< } pub fn f1(v0: Adt0) -> bool { - let m4 = f5(v0); - match m4 { + let m6 = f5(v0); + match m6 { None => { false } Some(v1) => { - let m5 = v1; - match m5.uncons() { + let m7 = v1; + match m7.uncons() { None => { false } Some((v2, v3)) => { - let m6 = v2; - match m6 { + let m8 = v2; + match m8 { Adt17::C0(v4) => { - let m7 = v3; - match m7.uncons() { + let m9 = v3; + match m9.uncons() { None => { - let a8 = f6(v4); - let a9 = Str::lit("String"); - equal(a8, a9) + let a10 = f6(v4); + let a11 = Str::lit("String"); + equal(a10, a11) } Some((_, _)) => { false @@ -1356,8 +1361,8 @@ pub fn f1(v0: Adt0) -> bool { } pub fn f2(v0: Adt48) -> bool { - let m10 = v0; - match m10 { + let m12 = v0; + match m12 { Adt48::C0 => { false } @@ -1376,14 +1381,14 @@ pub fn f2(v0: Adt48) -> bool { Adt48::C5(_) => { false } - Adt48::C6 => { - true + Adt48::C6(_) => { + false } Adt48::C7 => { true } Adt48::C8 => { - false + true } Adt48::C9 => { false @@ -1391,16 +1396,16 @@ pub fn f2(v0: Adt48) -> bool { Adt48::C10 => { false } - Adt48::C11(_) => { + Adt48::C11 => { false } Adt48::C12(_) => { false } - Adt48::C13(_, _) => { + Adt48::C13(_) => { false } - Adt48::C14(_) => { + Adt48::C14(_, _) => { false } Adt48::C15(_) => { @@ -1409,48 +1414,51 @@ pub fn f2(v0: Adt48) -> bool { Adt48::C16(_) => { false } - Adt48::C17(_, _, _) => { + Adt48::C17(_) => { false } - Adt48::C18(_, _) => { + Adt48::C18(_, _, _) => { false } Adt48::C19(_, _) => { false } + Adt48::C20(_, _) => { + false + } } } pub fn f3(v0: Adt50, v1: Str) -> Adt50 { let v2: List = match v0.clone() { - Adt50::C0(_, _, _, _, h11, _, _) => { - h11 + Adt50::C0(_, _, _, _, h13, _, _) => { + h13 } }; let v3: List = f7(v2, v1); Adt50::C0(match v0.clone() { - Adt50::C0(h12, _, _, _, _, _, _) => { - h12 + Adt50::C0(h14, _, _, _, _, _, _) => { + h14 } }, match v0.clone() { - Adt50::C0(_, h13, _, _, _, _, _) => { - h13 + Adt50::C0(_, h15, _, _, _, _, _) => { + h15 } }, match v0.clone() { - Adt50::C0(_, _, h14, _, _, _, _) => { - h14 + Adt50::C0(_, _, h16, _, _, _, _) => { + h16 } }, match v0.clone() { - Adt50::C0(_, _, _, h15, _, _, _) => { - h15 + Adt50::C0(_, _, _, h17, _, _, _) => { + h17 } }, v3, match v0.clone() { - Adt50::C0(_, _, _, _, _, h16, _) => { - h16 + Adt50::C0(_, _, _, _, _, h18, _) => { + h18 } }, match v0 { - Adt50::C0(_, _, _, _, _, _, h17) => { - h17 + Adt50::C0(_, _, _, _, _, _, h19) => { + h19 } }) } @@ -1460,8 +1468,8 @@ pub fn f4(v0: Str, v1: Adt48, v2: Adt50) -> Result<(Option<(Adt53, Adt48)>, Adt5 } pub fn f5(v0: Adt0) -> Option> { - let m18 = v0; - match m18 { + let m20 = v0; + match m20 { Adt0::C0(_, _, v3, _) => { v3 } @@ -1469,8 +1477,8 @@ pub fn f5(v0: Adt0) -> Option> { } pub fn f6(v0: Adt12) -> Str { - let m19 = v0; - match m19 { + let m21 = v0; + match m21 { Adt12::C0(v1, _) => { v1 } @@ -1478,23 +1486,23 @@ pub fn f6(v0: Adt12) -> Str { } pub fn f7(v0: List, v1: Str) -> List { - let m20 = v0; - match m20.uncons() { + let m22 = v0; + match m22.uncons() { None => { List::cons(v1, List::::nil()) } Some((v2, v3)) => { - let a21 = v1.clone(); - let a22 = v2.clone(); - if equal(a21, a22) { + let a23 = v1.clone(); + let a24 = v2.clone(); + if equal(a23, a24) { List::cons(v2, v3) } else { - let m25 = { - let a23 = v1.clone(); - let a24 = v2.clone(); - compare(a23, a24) + let m27 = { + let a25 = v1.clone(); + let a26 = v2.clone(); + compare(a25, a26) }; - if match m25 { + if match m27 { Ordering::Less => { true } diff --git a/crates/certified/roots/uorust_certified_const_marker.rs b/crates/certified/roots/uorust_certified_const_marker.rs index 6f40f1ea..b5e9a1e6 100644 --- a/crates/certified/roots/uorust_certified_const_marker.rs +++ b/crates/certified/roots/uorust_certified_const_marker.rs @@ -856,14 +856,18 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: Str, v1: Option) -> Str { - let a1 = List::cons(Str::lit("#"), List::cons(f1(v1), List::cons(Str::lit("_"), List::cons(v0, List::::nil())))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("#"), List::cons(f1(v1), List::::nil())); + let a2 = List::cons(Str::lit("_"), List::cons(v0, List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) } pub fn f1(v0: Option) -> Str { - let m3 = v0; - match m3 { + let m5 = v0; + match m5 { None => { Str::lit("") } diff --git a/crates/certified/roots/uorust_certified_ctor_value.rs b/crates/certified/roots/uorust_certified_ctor_value.rs index 0df67a1b..0c2ae84e 100644 --- a/crates/certified/roots/uorust_certified_ctor_value.rs +++ b/crates/certified/roots/uorust_certified_ctor_value.rs @@ -897,7 +897,7 @@ pub enum Adt5 { #[derive(Clone)] pub enum Adt6 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -918,20 +918,21 @@ pub enum Adt9 { C3(u64), C4(Adt10), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -974,76 +975,134 @@ pub enum Adt17 { C0(Str, List), } -pub fn f0(v0: Adt0, v1: Adt6) -> Option { +pub fn f0(v0: Adt0, v1: Adt6) -> R> { let v2: u64 = { let a1 = f1(v0.clone()); length_list(a1) }; let a2 = v2; - let a3 = 2u64; - if nat_lt(a2, a3) { - None:: - } else { - let v3: Str = f2(v1.clone(), f3(f4(v2, v0.clone()))); - let v4: Str = f3(f5(v2, v0)); - let v5: bool = if f6(v3.clone(), v1.clone(), v4.clone()) { - true + let a3 = 1u64; + if nat_eq(a2, a3) { + let v3: Str = f2(v1.clone(), f3(f4(v0)))?; + let v4: bool = f5(v3.clone(), v1); + if v4 { + Ok(Some(Adt11::C0(v3, f6()))) } else { - f7(v3.clone(), v1, v4.clone()) - }; - if v5 { - Some(Adt11::C0(v3, v4)) + Ok(None::) + } + } else { + let a4 = v2; + let a5 = 2u64; + if nat_lt(a4, a5) { + Ok(None::) } else { - None:: + let v5: Str = f2(v1.clone(), f3(f7(v2, v0.clone())))?; + let v6: Str = f3(f8(v2, v0)); + let v7: bool = if f9(v5.clone(), v1.clone(), v6.clone()) { + true + } else { + f10(v5.clone(), v1, v6.clone()) + }; + if v7 { + Ok(Some(Adt11::C0(v5, v6))) + } else { + Ok(None::) + } } } } pub fn f1(v0: Adt0) -> List { - let m4 = v0; - match m4 { + let m6 = v0; + match m6 { Adt0::C0(v1, _) => { v1 } } } -pub fn f2(v0: Adt6, v1: Str) -> Str { - let m6 = f8(match v0 { - Adt6::C0(_, _, h5, _, _, _, _, _, _, _, _, _) => { - h5 +pub fn f2(v0: Adt6, v1: Str) -> R { + let v2: Str = f11(v1)?; + let m8 = f12(match v0 { + Adt6::C0(_, _, h7, _, _, _, _, _, _, _, _, _, _) => { + h7 } - }, v1.clone()); - match m6 { + }, v2.clone()); + match m8 { None => { - v1 + Ok(v2) } - Some(v2) => { - v2 + Some(v3) => { + Ok(v3) } } } pub fn f3(v0: Adt1) -> Str { - let m7 = v0; - match m7 { + let m9 = v0; + match m9 { Adt1::C0(v1, _) => { v1 } } } -pub fn f4(v0: u64, v1: Adt0) -> Adt1 { +pub fn f4(v0: Adt0) -> Adt1 { let m12 = { - let a10 = f1(v1); - let a11 = { - let a8 = v0; - let a9 = 2u64; - nat_sub(a8, a9) - }; + let a10 = f1(v0); + let a11 = 0u64; index_list(a10, a11) }; match m12 { + None => { + Adt1::C0(Str::lit(""), Adt2::C0) + } + Some(v1) => { + v1 + } + } +} + +pub fn f5(v0: Str, v1: Adt6) -> bool { + let m14 = f13(match v1 { + Adt6::C0(h13, _, _, _, _, _, _, _, _, _, _, _, _) => { + h13 + } + }, v0); + match m14 { + None => { + false + } + Some(v2) => { + let a16 = { + let a15 = v2.clone(); + length_list(a15) + }; + let a17 = 1u64; + if nat_eq(a16, a17) { + f14(v2) + } else { + false + } + } + } +} + +pub fn f6() -> Str { + Str::lit("mk") +} + +pub fn f7(v0: u64, v1: Adt0) -> Adt1 { + let m22 = { + let a20 = f1(v1); + let a21 = { + let a18 = v0; + let a19 = 2u64; + nat_sub(a18, a19) + }; + index_list(a20, a21) + }; + match m22 { None => { Adt1::C0(Str::lit(""), Adt2::C0) } @@ -1053,17 +1112,17 @@ pub fn f4(v0: u64, v1: Adt0) -> Adt1 { } } -pub fn f5(v0: u64, v1: Adt0) -> Adt1 { - let m17 = { - let a15 = f1(v1); - let a16 = { - let a13 = v0; - let a14 = 1u64; - nat_sub(a13, a14) +pub fn f8(v0: u64, v1: Adt0) -> Adt1 { + let m27 = { + let a25 = f1(v1); + let a26 = { + let a23 = v0; + let a24 = 1u64; + nat_sub(a23, a24) }; - index_list(a15, a16) + index_list(a25, a26) }; - match m17 { + match m27 { None => { Adt1::C0(Str::lit(""), Adt2::C0) } @@ -1073,61 +1132,95 @@ pub fn f5(v0: u64, v1: Adt0) -> Adt1 { } } -pub fn f6(v0: Str, v1: Adt6, v2: Str) -> bool { - let m19 = f9(match v1 { - Adt6::C0(h18, _, _, _, _, _, _, _, _, _, _, _) => { - h18 +pub fn f9(v0: Str, v1: Adt6, v2: Str) -> bool { + let m29 = f15(match v1 { + Adt6::C0(h28, _, _, _, _, _, _, _, _, _, _, _, _) => { + h28 } }, v0); - match m19 { + match m29 { None => { false } Some(v3) => { - f10(v3, v2) + f16(v3, v2) } } } -pub fn f7(v0: Str, v1: Adt6, v2: Str) -> bool { - let m21 = f11(match v1 { - Adt6::C0(_, _, _, h20, _, _, _, _, _, _, _, _) => { - h20 +pub fn f10(v0: Str, v1: Adt6, v2: Str) -> bool { + let m31 = f17(match v1 { + Adt6::C0(_, _, _, h30, _, _, _, _, _, _, _, _, _) => { + h30 } }, v0); - match m21 { + match m31 { None => { false } Some(v3) => { - f12(v3, v2) + f18(v3, v2) } } } -pub fn f8(p28: List, v1: Str) -> Option { - let m27 = p28; +pub fn f11(v0: Str) -> R { + let m32 = f19(v0.clone())?; + match m32 { + None => { + Ok(v0) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt11::C0(h33, _) => { + h33 + } + }; + let v3: Str = match v1 { + Adt11::C0(_, h34) => { + h34 + } + }; + let m35 = f20(v3, Str::lit(">")); + match m35 { + None => { + Ok(v0) + } + Some(v4) => { + if f21(f22(v4, Str::lit(","))?)? { + f23(v2) + } else { + Ok(v0) + } + } + } + } + } +} + +pub fn f12(p42: List, v1: Str) -> Option { + let m41 = p42; { - let mut m27 = m27; + let mut m41 = m41; loop { let step = { - let v0 = m27; - let m22 = v0; - match m22.uncons() { + let v0 = m41; + let m36 = v0; + match m36.uncons() { None => { Err::, Option>(None::) } Some((v2, v3)) => { - let a24 = match v2.clone() { - Adt11::C0(h23, _) => { - h23 + let a38 = match v2.clone() { + Adt11::C0(h37, _) => { + h37 } }; - let a25 = v1.clone(); - if equal(a24, a25) { + let a39 = v1.clone(); + if equal(a38, a39) { Err::, Option>(Some(match v2 { - Adt11::C0(_, h26) => { - h26 + Adt11::C0(_, h40) => { + h40 } })) } else { @@ -1137,36 +1230,36 @@ pub fn f8(p28: List, v1: Str) -> Option { } }; match step { - Ok(next) => { m27 = next; } + Ok(next) => { m41 = next; } Err(done) => break done, } } } } -pub fn f9(p35: List, v1: Str) -> Option> { - let m34 = p35; +pub fn f13(p49: List, v1: Str) -> Option> { + let m48 = p49; { - let mut m34 = m34; + let mut m48 = m48; loop { let step = { - let v0 = m34; - let m29 = v0; - match m29.uncons() { + let v0 = m48; + let m43 = v0; + match m43.uncons() { None => { Err::, Option>>(None::>) } Some((v2, v3)) => { - let a31 = match v2.clone() { - Adt7::C0(h30, _) => { - h30 + let a45 = match v2.clone() { + Adt7::C0(h44, _) => { + h44 } }; - let a32 = v1.clone(); - if equal(a31, a32) { + let a46 = v1.clone(); + if equal(a45, a46) { Err::, Option>>(Some(match v2 { - Adt7::C0(_, h33) => { - h33 + Adt7::C0(_, h47) => { + h47 } })) } else { @@ -1176,29 +1269,99 @@ pub fn f9(p35: List, v1: Str) -> Option> { } }; match step { - Ok(next) => { m34 = next; } + Ok(next) => { m48 = next; } Err(done) => break done, } } } } -pub fn f10(p40: List, v1: Str) -> bool { - let m39 = p40; +pub fn f14(p54: List) -> bool { + let m53 = p54; { - let mut m39 = m39; + let mut m53 = m53; loop { let step = { - let v0 = m39; - let m36 = v0; - match m36.uncons() { + let v0 = m53; + let m50 = v0; + match m50.uncons() { + None => { + Err::, bool>(true) + } + Some((v1, v2)) => { + let a51 = v1; + let a52 = f6(); + if equal(a51, a52) { + Ok::, bool>(v2) + } else { + Err::, bool>(false) + } + } + } + }; + match step { + Ok(next) => { m53 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f15(p61: List, v1: Str) -> Option> { + let m60 = p61; + { + let mut m60 = m60; + loop { + let step = { + let v0 = m60; + let m55 = v0; + match m55.uncons() { + None => { + Err::, Option>>(None::>) + } + Some((v2, v3)) => { + let a57 = match v2.clone() { + Adt7::C0(h56, _) => { + h56 + } + }; + let a58 = v1.clone(); + if equal(a57, a58) { + Err::, Option>>(Some(match v2 { + Adt7::C0(_, h59) => { + h59 + } + })) + } else { + Ok::, Option>>(v3) + } + } + } + }; + match step { + Ok(next) => { m60 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f16(p66: List, v1: Str) -> bool { + let m65 = p66; + { + let mut m65 = m65; + loop { + let step = { + let v0 = m65; + let m62 = v0; + match m62.uncons() { None => { Err::, bool>(false) } Some((v2, v3)) => { - let a37 = v2; - let a38 = v1.clone(); - if equal(a37, a38) { + let a63 = v2; + let a64 = v1.clone(); + if equal(a63, a64) { Err::, bool>(true) } else { Ok::, bool>(v3) @@ -1207,36 +1370,36 @@ pub fn f10(p40: List, v1: Str) -> bool { } }; match step { - Ok(next) => { m39 = next; } + Ok(next) => { m65 = next; } Err(done) => break done, } } } } -pub fn f11(p47: List, v1: Str) -> Option, Adt9)>)>> { - let m46 = p47; +pub fn f17(p73: List, v1: Str) -> Option, Adt9)>)>> { + let m72 = p73; { - let mut m46 = m46; + let mut m72 = m72; loop { let step = { - let v0 = m46; - let m41 = v0; - match m41.uncons() { + let v0 = m72; + let m67 = v0; + match m67.uncons() { None => { Err::, Option, Adt9)>)>>>(None::, Adt9)>)>>) } Some((v2, v3)) => { - let a43 = match v2.clone() { - Adt12::C0(h42, _) => { - h42 + let a69 = match v2.clone() { + Adt12::C0(h68, _) => { + h68 } }; - let a44 = v1.clone(); - if equal(a43, a44) { + let a70 = v1.clone(); + if equal(a69, a70) { Err::, Option, Adt9)>)>>>(Some(match v2 { - Adt12::C0(_, h45) => { - h45 + Adt12::C0(_, h71) => { + h71 } })) } else { @@ -1246,43 +1409,43 @@ pub fn f11(p47: List, v1: Str) -> Option, Ad } }; match step { - Ok(next) => { m46 = next; } + Ok(next) => { m72 = next; } Err(done) => break done, } } } } -pub fn f12(p57: List<(Str, List<(Option, Adt9)>)>, v1: Str) -> bool { - let m56 = p57; +pub fn f18(p83: List<(Str, List<(Option, Adt9)>)>, v1: Str) -> bool { + let m82 = p83; { - let mut m56 = m56; + let mut m82 = m82; loop { let step = { - let v0 = m56; - let m48 = v0; - match m48.uncons() { + let v0 = m82; + let m74 = v0; + match m74.uncons() { None => { Err::, Adt9)>)>, bool>(false) } Some((v2, v3)) => { let v4: Str = { - let (h49, _) = v2; - h49 + let (h75, _) = v2; + h75 }; let v5: List<(Option, Adt9)> = { - let (_, h50) = v2; - h50 + let (_, h76) = v2; + h76 }; - let a51 = v4; - let a52 = v1.clone(); - if if equal(a51, a52) { - let a54 = { - let a53 = v5; - length_list(a53) + let a77 = v4; + let a78 = v1.clone(); + if if equal(a77, a78) { + let a80 = { + let a79 = v5; + length_list(a79) }; - let a55 = 0u64; - nat_eq(a54, a55) + let a81 = 0u64; + nat_eq(a80, a81) } else { false } { @@ -1294,13 +1457,867 @@ pub fn f12(p57: List<(Str, List<(Option, Adt9)>)>, v1: Str) -> bool { } }; match step { - Ok(next) => { m56 = next; } + Ok(next) => { m82 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f19(v0: Str) -> R> { + let m84 = f24(v0.clone(), Str::lit("<"))?; + match m84 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt11::C0(f25(v0.clone(), 0u64, v1), f25(v0.clone(), { + let a85 = v1; + let a86 = f26(Str::lit("<")); + nat_add(a85, a86)? + }, f26(v0))))) + } + } +} + +pub fn f20(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a87 = v0.clone(); + utf8_encode(a87) + }; + let v3: u64 = { + let a88 = v2.clone(); + length_bytes(a88) + }; + let v4: u64 = f26(v1.clone()); + if f27(v0, v1) { + Some(f28(v2, 0u64, { + let a89 = v3; + let a90 = v4; + nat_sub(a89, a90) + })) + } else { + None:: + } +} + +pub fn f21(p93: List) -> R { + let m92 = p93; + { + let mut m92 = m92; + loop { + let step = { + let v0 = m92; + let m91 = v0; + match m91.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + if f29(v1)? { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m92 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f22(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a94 = v0.clone(); + utf8_encode(a94) + }; + let v3: Bytes = { + let a95 = v1; + utf8_encode(a95) + }; + let a97 = { + let a96 = v3.clone(); + length_bytes(a96) + }; + let a98 = 0u64; + if nat_eq(a97, a98) { + Ok(List::cons(Str::lit(""), { + let a99 = f30(v0)?; + let a100 = List::cons(Str::lit(""), List::::nil()); + append_list(a99, a100) + })) + } else { + f31({ + let a102 = { + let a101 = v2.clone(); + length_bytes(a101) + }; + let a103 = 1u64; + nat_add(a102, a103)? + }, v2, v3, 0u64, 0u64) + } +} + +pub fn f23(v0: Str) -> R { + let v1: Bytes = { + let a104 = v0; + utf8_encode(a104) + }; + let v2: u64 = { + let a105 = v1.clone(); + length_bytes(a105) + }; + Ok(f28(v1.clone(), 0u64, f32(v2, v1, v2)?)) +} + +pub fn f24(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a106 = v0; + utf8_encode(a106) + }; + f33({ + let a108 = { + let a107 = v2.clone(); + length_bytes(a107) + }; + let a109 = 1u64; + nat_add(a108, a109)? + }, v2, { + let a110 = v1; + utf8_encode(a110) + }, 0u64) +} + +pub fn f25(v0: Str, v1: u64, v2: u64) -> Str { + f28({ + let a111 = v0; + utf8_encode(a111) + }, v1, v2) +} + +pub fn f26(v0: Str) -> u64 { + let a113 = { + let a112 = v0; + utf8_encode(a112) + }; + length_bytes(a113) +} + +pub fn f27(v0: Str, v1: Str) -> bool { + let v2: Bytes = { + let a114 = v0; + utf8_encode(a114) + }; + let v3: Bytes = { + let a115 = v1; + utf8_encode(a115) + }; + let v4: u64 = { + let a116 = v2.clone(); + length_bytes(a116) + }; + let v5: u64 = { + let a117 = v3.clone(); + length_bytes(a117) + }; + let a118 = v5; + let a119 = v4; + if nat_le(a118, a119) { + f34(v2, { + let a120 = v4; + let a121 = v5; + nat_sub(a120, a121) + }, v3) + } else { + false + } +} + +pub fn f28(v0: Bytes, v1: u64, v2: u64) -> Str { + let m127 = { + let a124 = v0; + let a125 = v1; + let a126 = { + let a122 = v2; + let a123 = v1; + nat_sub(a122, a123) + }; + slice_bytes(a124, a125, a126) + }; + match m127 { + None => { + Str::lit("") + } + Some(v3) => { + let m129 = { + let a128 = v3; + utf8_decode(a128) + }; + match m129 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f29(v0: Str) -> R { + let m130 = f35(f36(v0)?, Str::lit("'")); + match m130 { + None => { + Ok(false) + } + Some(v1) => { + let a131 = f37(v1, Str::lit("'"))?; + Ok(bool_not(a131)) + } + } +} + +pub fn f30(v0: Str) -> R> { + let v1: Bytes = { + let a132 = v0; + utf8_encode(a132) + }; + f38({ + let a133 = v1.clone(); + length_bytes(a133) + }, v1, 0u64) +} + +pub fn f31(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { + let m134 = v0; + if m134 == 0 { + Ok(List::cons(f28(v1.clone(), v3, { + let a135 = v1; + length_bytes(a135) + }), List::::nil())) + } else { + let v5 = m134 - 1; + let a140 = { + let a136 = v1.clone(); + length_bytes(a136) + }; + let a141 = { + let a138 = v4; + let a139 = { + let a137 = v2.clone(); + length_bytes(a137) + }; + nat_add(a138, a139)? + }; + if nat_lt(a140, a141) { + Ok(List::cons(f28(v1.clone(), v3, { + let a142 = v1; + length_bytes(a142) + }), List::::nil())) + } else { + if f34(v1.clone(), v4, v2.clone()) { + Ok(List::cons(f28(v1.clone(), v3, v4), f31(v5, v1, v2.clone(), { + let a144 = v4; + let a145 = { + let a143 = v2.clone(); + length_bytes(a143) + }; + nat_add(a144, a145)? + }, { + let a147 = v4; + let a148 = { + let a146 = v2; + length_bytes(a146) + }; + nat_add(a147, a148)? + })?)) + } else { + f31(v5, v1, v2, v3, { + let a149 = v4; + let a150 = 1u64; + nat_add(a149, a150)? + }) + } + } + } +} + +pub fn f32(p157: u64, v1: Bytes, p158: u64) -> R { + let m156 = (p157, p158); + { + let mut m156 = m156; + loop { + let step = { + let (v0, v2) = m156; + let m151 = v0; + if m151 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m151 - 1; + let v4: u64 = f39(v1.clone(), v2)?; + let a152 = v4; + let a153 = 0u64; + if nat_eq(a152, a153) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a154 = v2; + let a155 = v4; + nat_sub(a154, a155) + })) + } + } + }; + match step { + Ok(next) => { m156 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f33(p169: u64, v1: Bytes, v2: Bytes, p170: u64) -> R> { + let m168 = (p169, p170); + { + let mut m168 = m168; + loop { + let step = { + let (v0, v3) = m168; + let m159 = v0; + if m159 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m159 - 1; + let a164 = { + let a160 = v1.clone(); + length_bytes(a160) + }; + let a165 = { + let a162 = v3; + let a163 = { + let a161 = v2.clone(); + length_bytes(a161) + }; + nat_add(a162, a163)? + }; + if nat_lt(a164, a165) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f34(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a166 = v3; + let a167 = 1u64; + nat_add(a166, a167)? + })) + } + } + } + }; + match step { + Ok(next) => { m168 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f34(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m175 = { + let a172 = v0; + let a173 = v1; + let a174 = { + let a171 = v2.clone(); + length_bytes(a171) + }; + slice_bytes(a172, a173, a174) + }; + match m175 { + None => { + false + } + Some(v3) => { + let a176 = v3; + let a177 = v2; + equal(a176, a177) + } + } +} + +pub fn f35(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a178 = v0; + utf8_encode(a178) + }; + let v3: Bytes = { + let a179 = v1; + utf8_encode(a179) + }; + if f34(v2.clone(), 0u64, v3.clone()) { + Some(f28(v2.clone(), { + let a180 = v3; + length_bytes(a180) + }, { + let a181 = v2; + length_bytes(a181) + })) + } else { + None:: + } +} + +pub fn f36(v0: Str) -> R { + f23(f40(v0)?) +} + +pub fn f37(v0: Str, v1: Str) -> R { + let m182 = f24(v0, v1)?; + match m182 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f38(v0: u64, v1: Bytes, v2: u64) -> R> { + let m183 = v0; + if m183 == 0 { + Ok(List::::nil()) + } else { + let v3 = m183 - 1; + let a185 = { + let a184 = v1.clone(); + length_bytes(a184) + }; + let a186 = v2; + if nat_le(a185, a186) { + Ok(List::::nil()) + } else { + let v4: u64 = f41(f42(v1.clone(), v2)?); + Ok(List::cons(f28(v1.clone(), v2, { + let a187 = v2; + let a188 = v4; + nat_add(a187, a188)? + }), f38(v3, v1, { + let a189 = v2; + let a190 = v4; + nat_add(a189, a190)? + })?)) + } + } +} + +pub fn f39(v0: Bytes, v1: u64) -> R { + let a191 = v1; + let a192 = 0u64; + if nat_eq(a191, a192) { + Ok(0u64) + } else { + if f43(f42(v0.clone(), { + let a193 = v1; + let a194 = 1u64; + nat_sub(a193, a194) + })?) { + Ok(1u64) + } else { + let a195 = 2u64; + let a196 = v1; + if if nat_le(a195, a196) { + let a199 = f44(v0.clone(), { + let a197 = v1; + let a198 = 2u64; + nat_sub(a197, a198) + })?; + let a200 = 2u64; + nat_eq(a199, a200) + } else { + false + } { + Ok(2u64) + } else { + let a201 = 3u64; + let a202 = v1; + if if nat_le(a201, a202) { + let a205 = f44(v0, { + let a203 = v1; + let a204 = 3u64; + nat_sub(a203, a204) + })?; + let a206 = 3u64; + nat_eq(a205, a206) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f40(v0: Str) -> R { + let v1: Bytes = { + let a207 = v0; + utf8_encode(a207) + }; + let v2: u64 = { + let a208 = v1.clone(); + length_bytes(a208) + }; + Ok(f28(v1.clone(), f45(v2, v1, 0u64)?, v2)) +} + +pub fn f41(v0: u64) -> u64 { + let a209 = v0; + let a210 = 128u64; + if nat_lt(a209, a210) { + 1u64 + } else { + let a211 = v0; + let a212 = 224u64; + if nat_lt(a211, a212) { + 2u64 + } else { + let a213 = v0; + let a214 = 240u64; + if nat_lt(a213, a214) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f42(v0: Bytes, v1: u64) -> R { + let m217 = { + let a215 = v0; + let a216 = v1; + index_bytes(a215, a216) + }; + match m217 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a262 = { + let a238 = { + let a226 = { + let a220 = { + let a218 = v3; + let a219 = 128u8; + fixed_u8::bit_and(a218, a219) + }; + let a221 = 128u8; + if equal(a220, a221) { + 128u64 + } else { + 0u64 + } + }; + let a227 = { + let a224 = { + let a222 = v3; + let a223 = 64u8; + fixed_u8::bit_and(a222, a223) + }; + let a225 = 64u8; + if equal(a224, a225) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a226, a227)? + }; + let a239 = { + let a236 = { + let a230 = { + let a228 = v3; + let a229 = 32u8; + fixed_u8::bit_and(a228, a229) + }; + let a231 = 32u8; + if equal(a230, a231) { + 32u64 + } else { + 0u64 + } + }; + let a237 = { + let a234 = { + let a232 = v3; + let a233 = 16u8; + fixed_u8::bit_and(a232, a233) + }; + let a235 = 16u8; + if equal(a234, a235) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a236, a237)? + }; + nat_add(a238, a239)? + }; + let a263 = { + let a260 = { + let a248 = { + let a242 = { + let a240 = v3; + let a241 = 8u8; + fixed_u8::bit_and(a240, a241) + }; + let a243 = 8u8; + if equal(a242, a243) { + 8u64 + } else { + 0u64 + } + }; + let a249 = { + let a246 = { + let a244 = v3; + let a245 = 4u8; + fixed_u8::bit_and(a244, a245) + }; + let a247 = 4u8; + if equal(a246, a247) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a248, a249)? + }; + let a261 = { + let a258 = { + let a252 = { + let a250 = v3; + let a251 = 2u8; + fixed_u8::bit_and(a250, a251) + }; + let a253 = 2u8; + if equal(a252, a253) { + 2u64 + } else { + 0u64 + } + }; + let a259 = { + let a256 = { + let a254 = v3; + let a255 = 1u8; + fixed_u8::bit_and(a254, a255) + }; + let a257 = 1u8; + if equal(a256, a257) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a258, a259)? + }; + nat_add(a260, a261)? + }; + nat_add(a262, a263) + } + } +} + +pub fn f43(v0: u64) -> bool { + let a264 = v0; + let a265 = 32u64; + if nat_eq(a264, a265) { + true + } else { + let a266 = 9u64; + let a267 = v0; + if nat_le(a266, a267) { + let a268 = v0; + let a269 = 13u64; + nat_le(a268, a269) + } else { + false + } + } +} + +pub fn f44(v0: Bytes, v1: u64) -> R { + let v2: u64 = f42(v0.clone(), v1)?; + let v3: u64 = f42(v0.clone(), { + let a270 = v1; + let a271 = 1u64; + nat_add(a270, a271)? + })?; + let v4: u64 = f42(v0, { + let a272 = v1; + let a273 = 2u64; + nat_add(a272, a273)? + })?; + if f43(v2) { + Ok(1u64) + } else { + let a274 = v2; + let a275 = 194u64; + if nat_eq(a274, a275) { + let a276 = v3; + let a277 = 133u64; + if if nat_eq(a276, a277) { + true + } else { + let a278 = v3; + let a279 = 160u64; + nat_eq(a278, a279) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a280 = v2; + let a281 = 225u64; + if nat_eq(a280, a281) { + let a282 = v3; + let a283 = 154u64; + if if nat_eq(a282, a283) { + let a284 = v4; + let a285 = 128u64; + nat_eq(a284, a285) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a286 = v2; + let a287 = 226u64; + if nat_eq(a286, a287) { + let a288 = v3; + let a289 = 128u64; + if nat_eq(a288, a289) { + let a290 = 128u64; + let a291 = v4; + if if if nat_le(a290, a291) { + let a292 = v4; + let a293 = 138u64; + nat_le(a292, a293) + } else { + false + } { + true + } else { + let a294 = v4; + let a295 = 168u64; + if nat_eq(a294, a295) { + true + } else { + let a296 = v4; + let a297 = 169u64; + if nat_eq(a296, a297) { + true + } else { + let a298 = v4; + let a299 = 175u64; + nat_eq(a298, a299) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a300 = v3; + let a301 = 129u64; + if if nat_eq(a300, a301) { + let a302 = v4; + let a303 = 159u64; + nat_eq(a302, a303) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a304 = v2; + let a305 = 227u64; + if if nat_eq(a304, a305) { + let a306 = v3; + let a307 = 128u64; + if nat_eq(a306, a307) { + let a308 = v4; + let a309 = 128u64; + nat_eq(a308, a309) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f45(p316: u64, v1: Bytes, p317: u64) -> R { + let m315 = (p316, p317); + { + let mut m315 = m315; + loop { + let step = { + let (v0, v2) = m315; + let m310 = v0; + if m310 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m310 - 1; + let v4: u64 = f44(v1.clone(), v2)?; + let a311 = v4; + let a312 = 0u64; + if nat_eq(a311, a312) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a313 = v2; + let a314 = v4; + nat_add(a313, a314)? + })) + } + } + }; + match step { + Ok(next) => { m315 = next; } Err(done) => break done, } } } } -pub fn run(p0: Adt0, p1: Adt6) -> Option { +pub fn run(p0: Adt0, p1: Adt6) -> R> { f0(p0, p1) } diff --git a/crates/certified/roots/uorust_certified_ctx_below.rs b/crates/certified/roots/uorust_certified_ctx_below.rs index 35467c9a..8a3a0416 100644 --- a/crates/certified/roots/uorust_certified_ctx_below.rs +++ b/crates/certified/roots/uorust_certified_ctx_below.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_ctx_fresh.rs b/crates/certified/roots/uorust_certified_ctx_fresh.rs index 7d1c09ca..c0a4273e 100644 --- a/crates/certified/roots/uorust_certified_ctx_fresh.rs +++ b/crates/certified/roots/uorust_certified_ctx_fresh.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -1252,7 +1253,7 @@ pub enum Adt56 { #[derive(Clone)] pub enum Adt57 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_ctx_helper_name.rs b/crates/certified/roots/uorust_certified_ctx_helper_name.rs index a10648e9..55f13ede 100644 --- a/crates/certified/roots/uorust_certified_ctx_helper_name.rs +++ b/crates/certified/roots/uorust_certified_ctx_helper_name.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -1252,7 +1253,7 @@ pub enum Adt56 { #[derive(Clone)] pub enum Adt57 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_ctx_names_from.rs b/crates/certified/roots/uorust_certified_ctx_names_from.rs index 195f512d..33733ca9 100644 --- a/crates/certified/roots/uorust_certified_ctx_names_from.rs +++ b/crates/certified/roots/uorust_certified_ctx_names_from.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -1252,7 +1253,7 @@ pub enum Adt56 { #[derive(Clone)] pub enum Adt57 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_ctx_taken.rs b/crates/certified/roots/uorust_certified_ctx_taken.rs index 4a57961c..a3cfef1b 100644 --- a/crates/certified/roots/uorust_certified_ctx_taken.rs +++ b/crates/certified/roots/uorust_certified_ctx_taken.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -1252,7 +1253,7 @@ pub enum Adt56 { #[derive(Clone)] pub enum Adt57 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_data_variant.rs b/crates/certified/roots/uorust_certified_data_variant.rs index 089d7fe7..98f1f4a0 100644 --- a/crates/certified/roots/uorust_certified_data_variant.rs +++ b/crates/certified/roots/uorust_certified_data_variant.rs @@ -897,7 +897,7 @@ pub enum Adt5 { #[derive(Clone)] pub enum Adt6 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -918,20 +918,21 @@ pub enum Adt9 { C3(u64), C4(Adt10), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -979,7 +980,7 @@ pub enum Adt18 { C0(Str, Str, List<(Option, Adt9)>), } -pub fn f0(v0: Adt0, v1: Adt6) -> Option { +pub fn f0(v0: Adt0, v1: Adt6) -> R> { let v2: u64 = { let a1 = f1(v0.clone()); length_list(a1) @@ -987,24 +988,24 @@ pub fn f0(v0: Adt0, v1: Adt6) -> Option { let a2 = v2; let a3 = 2u64; if nat_lt(a2, a3) { - None:: + Ok(None::) } else { - let v3: Str = f2(v1.clone(), f3(f4(v2, v0.clone()))); + let v3: Str = f2(v1.clone(), f3(f4(v2, v0.clone())))?; let v4: Str = f3(f5(v2, v0)); let m5 = f6(match v1 { - Adt6::C0(_, _, _, h4, _, _, _, _, _, _, _, _) => { + Adt6::C0(_, _, _, h4, _, _, _, _, _, _, _, _, _) => { h4 } }, v3.clone()); match m5 { None => { - None:: + Ok(None::) } Some(v5) => { let m6 = f7(v5, v4.clone()); match m6 { None => { - None:: + Ok(None::) } Some(v6) => { let v7: (Str, List<(Option, Adt9)>) = v6; @@ -1016,7 +1017,7 @@ pub fn f0(v0: Adt0, v1: Adt6) -> Option { let (_, h8) = v7; h8 }; - Some(Adt18::C0(v3, v4, v9)) + Ok(Some(Adt18::C0(v3, v4, v9))) } } } @@ -1033,18 +1034,19 @@ pub fn f1(v0: Adt0) -> List { } } -pub fn f2(v0: Adt6, v1: Str) -> Str { - let m11 = f8(match v0 { - Adt6::C0(_, _, h10, _, _, _, _, _, _, _, _, _) => { +pub fn f2(v0: Adt6, v1: Str) -> R { + let v2: Str = f8(v1)?; + let m11 = f9(match v0 { + Adt6::C0(_, _, h10, _, _, _, _, _, _, _, _, _, _) => { h10 } - }, v1.clone()); + }, v2.clone()); match m11 { None => { - v1 + Ok(v2) } - Some(v2) => { - v2 + Some(v3) => { + Ok(v3) } } } @@ -1176,29 +1178,63 @@ pub fn f7(p36: List<(Str, List<(Option, Adt9)>)>, v1: Str) -> Option<(Str, } } -pub fn f8(p43: List, v1: Str) -> Option { - let m42 = p43; +pub fn f8(v0: Str) -> R { + let m37 = f10(v0.clone())?; + match m37 { + None => { + Ok(v0) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt11::C0(h38, _) => { + h38 + } + }; + let v3: Str = match v1 { + Adt11::C0(_, h39) => { + h39 + } + }; + let m40 = f11(v3, Str::lit(">")); + match m40 { + None => { + Ok(v0) + } + Some(v4) => { + if f12(f13(v4, Str::lit(","))?)? { + f14(v2) + } else { + Ok(v0) + } + } + } + } + } +} + +pub fn f9(p47: List, v1: Str) -> Option { + let m46 = p47; { - let mut m42 = m42; + let mut m46 = m46; loop { let step = { - let v0 = m42; - let m37 = v0; - match m37.uncons() { + let v0 = m46; + let m41 = v0; + match m41.uncons() { None => { Err::, Option>(None::) } Some((v2, v3)) => { - let a39 = match v2.clone() { - Adt11::C0(h38, _) => { - h38 + let a43 = match v2.clone() { + Adt11::C0(h42, _) => { + h42 } }; - let a40 = v1.clone(); - if equal(a39, a40) { + let a44 = v1.clone(); + if equal(a43, a44) { Err::, Option>(Some(match v2 { - Adt11::C0(_, h41) => { - h41 + Adt11::C0(_, h45) => { + h45 } })) } else { @@ -1208,13 +1244,867 @@ pub fn f8(p43: List, v1: Str) -> Option { } }; match step { - Ok(next) => { m42 = next; } + Ok(next) => { m46 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f10(v0: Str) -> R> { + let m48 = f15(v0.clone(), Str::lit("<"))?; + match m48 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt11::C0(f16(v0.clone(), 0u64, v1), f16(v0.clone(), { + let a49 = v1; + let a50 = f17(Str::lit("<")); + nat_add(a49, a50)? + }, f17(v0))))) + } + } +} + +pub fn f11(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a51 = v0.clone(); + utf8_encode(a51) + }; + let v3: u64 = { + let a52 = v2.clone(); + length_bytes(a52) + }; + let v4: u64 = f17(v1.clone()); + if f18(v0, v1) { + Some(f19(v2, 0u64, { + let a53 = v3; + let a54 = v4; + nat_sub(a53, a54) + })) + } else { + None:: + } +} + +pub fn f12(p57: List) -> R { + let m56 = p57; + { + let mut m56 = m56; + loop { + let step = { + let v0 = m56; + let m55 = v0; + match m55.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + if f20(v1)? { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m56 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f13(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a58 = v0.clone(); + utf8_encode(a58) + }; + let v3: Bytes = { + let a59 = v1; + utf8_encode(a59) + }; + let a61 = { + let a60 = v3.clone(); + length_bytes(a60) + }; + let a62 = 0u64; + if nat_eq(a61, a62) { + Ok(List::cons(Str::lit(""), { + let a63 = f21(v0)?; + let a64 = List::cons(Str::lit(""), List::::nil()); + append_list(a63, a64) + })) + } else { + f22({ + let a66 = { + let a65 = v2.clone(); + length_bytes(a65) + }; + let a67 = 1u64; + nat_add(a66, a67)? + }, v2, v3, 0u64, 0u64) + } +} + +pub fn f14(v0: Str) -> R { + let v1: Bytes = { + let a68 = v0; + utf8_encode(a68) + }; + let v2: u64 = { + let a69 = v1.clone(); + length_bytes(a69) + }; + Ok(f19(v1.clone(), 0u64, f23(v2, v1, v2)?)) +} + +pub fn f15(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a70 = v0; + utf8_encode(a70) + }; + f24({ + let a72 = { + let a71 = v2.clone(); + length_bytes(a71) + }; + let a73 = 1u64; + nat_add(a72, a73)? + }, v2, { + let a74 = v1; + utf8_encode(a74) + }, 0u64) +} + +pub fn f16(v0: Str, v1: u64, v2: u64) -> Str { + f19({ + let a75 = v0; + utf8_encode(a75) + }, v1, v2) +} + +pub fn f17(v0: Str) -> u64 { + let a77 = { + let a76 = v0; + utf8_encode(a76) + }; + length_bytes(a77) +} + +pub fn f18(v0: Str, v1: Str) -> bool { + let v2: Bytes = { + let a78 = v0; + utf8_encode(a78) + }; + let v3: Bytes = { + let a79 = v1; + utf8_encode(a79) + }; + let v4: u64 = { + let a80 = v2.clone(); + length_bytes(a80) + }; + let v5: u64 = { + let a81 = v3.clone(); + length_bytes(a81) + }; + let a82 = v5; + let a83 = v4; + if nat_le(a82, a83) { + f25(v2, { + let a84 = v4; + let a85 = v5; + nat_sub(a84, a85) + }, v3) + } else { + false + } +} + +pub fn f19(v0: Bytes, v1: u64, v2: u64) -> Str { + let m91 = { + let a88 = v0; + let a89 = v1; + let a90 = { + let a86 = v2; + let a87 = v1; + nat_sub(a86, a87) + }; + slice_bytes(a88, a89, a90) + }; + match m91 { + None => { + Str::lit("") + } + Some(v3) => { + let m93 = { + let a92 = v3; + utf8_decode(a92) + }; + match m93 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f20(v0: Str) -> R { + let m94 = f26(f27(v0)?, Str::lit("'")); + match m94 { + None => { + Ok(false) + } + Some(v1) => { + let a95 = f28(v1, Str::lit("'"))?; + Ok(bool_not(a95)) + } + } +} + +pub fn f21(v0: Str) -> R> { + let v1: Bytes = { + let a96 = v0; + utf8_encode(a96) + }; + f29({ + let a97 = v1.clone(); + length_bytes(a97) + }, v1, 0u64) +} + +pub fn f22(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { + let m98 = v0; + if m98 == 0 { + Ok(List::cons(f19(v1.clone(), v3, { + let a99 = v1; + length_bytes(a99) + }), List::::nil())) + } else { + let v5 = m98 - 1; + let a104 = { + let a100 = v1.clone(); + length_bytes(a100) + }; + let a105 = { + let a102 = v4; + let a103 = { + let a101 = v2.clone(); + length_bytes(a101) + }; + nat_add(a102, a103)? + }; + if nat_lt(a104, a105) { + Ok(List::cons(f19(v1.clone(), v3, { + let a106 = v1; + length_bytes(a106) + }), List::::nil())) + } else { + if f25(v1.clone(), v4, v2.clone()) { + Ok(List::cons(f19(v1.clone(), v3, v4), f22(v5, v1, v2.clone(), { + let a108 = v4; + let a109 = { + let a107 = v2.clone(); + length_bytes(a107) + }; + nat_add(a108, a109)? + }, { + let a111 = v4; + let a112 = { + let a110 = v2; + length_bytes(a110) + }; + nat_add(a111, a112)? + })?)) + } else { + f22(v5, v1, v2, v3, { + let a113 = v4; + let a114 = 1u64; + nat_add(a113, a114)? + }) + } + } + } +} + +pub fn f23(p121: u64, v1: Bytes, p122: u64) -> R { + let m120 = (p121, p122); + { + let mut m120 = m120; + loop { + let step = { + let (v0, v2) = m120; + let m115 = v0; + if m115 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m115 - 1; + let v4: u64 = f30(v1.clone(), v2)?; + let a116 = v4; + let a117 = 0u64; + if nat_eq(a116, a117) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a118 = v2; + let a119 = v4; + nat_sub(a118, a119) + })) + } + } + }; + match step { + Ok(next) => { m120 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f24(p133: u64, v1: Bytes, v2: Bytes, p134: u64) -> R> { + let m132 = (p133, p134); + { + let mut m132 = m132; + loop { + let step = { + let (v0, v3) = m132; + let m123 = v0; + if m123 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m123 - 1; + let a128 = { + let a124 = v1.clone(); + length_bytes(a124) + }; + let a129 = { + let a126 = v3; + let a127 = { + let a125 = v2.clone(); + length_bytes(a125) + }; + nat_add(a126, a127)? + }; + if nat_lt(a128, a129) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f25(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a130 = v3; + let a131 = 1u64; + nat_add(a130, a131)? + })) + } + } + } + }; + match step { + Ok(next) => { m132 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f25(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m139 = { + let a136 = v0; + let a137 = v1; + let a138 = { + let a135 = v2.clone(); + length_bytes(a135) + }; + slice_bytes(a136, a137, a138) + }; + match m139 { + None => { + false + } + Some(v3) => { + let a140 = v3; + let a141 = v2; + equal(a140, a141) + } + } +} + +pub fn f26(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a142 = v0; + utf8_encode(a142) + }; + let v3: Bytes = { + let a143 = v1; + utf8_encode(a143) + }; + if f25(v2.clone(), 0u64, v3.clone()) { + Some(f19(v2.clone(), { + let a144 = v3; + length_bytes(a144) + }, { + let a145 = v2; + length_bytes(a145) + })) + } else { + None:: + } +} + +pub fn f27(v0: Str) -> R { + f14(f31(v0)?) +} + +pub fn f28(v0: Str, v1: Str) -> R { + let m146 = f15(v0, v1)?; + match m146 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f29(v0: u64, v1: Bytes, v2: u64) -> R> { + let m147 = v0; + if m147 == 0 { + Ok(List::::nil()) + } else { + let v3 = m147 - 1; + let a149 = { + let a148 = v1.clone(); + length_bytes(a148) + }; + let a150 = v2; + if nat_le(a149, a150) { + Ok(List::::nil()) + } else { + let v4: u64 = f32(f33(v1.clone(), v2)?); + Ok(List::cons(f19(v1.clone(), v2, { + let a151 = v2; + let a152 = v4; + nat_add(a151, a152)? + }), f29(v3, v1, { + let a153 = v2; + let a154 = v4; + nat_add(a153, a154)? + })?)) + } + } +} + +pub fn f30(v0: Bytes, v1: u64) -> R { + let a155 = v1; + let a156 = 0u64; + if nat_eq(a155, a156) { + Ok(0u64) + } else { + if f34(f33(v0.clone(), { + let a157 = v1; + let a158 = 1u64; + nat_sub(a157, a158) + })?) { + Ok(1u64) + } else { + let a159 = 2u64; + let a160 = v1; + if if nat_le(a159, a160) { + let a163 = f35(v0.clone(), { + let a161 = v1; + let a162 = 2u64; + nat_sub(a161, a162) + })?; + let a164 = 2u64; + nat_eq(a163, a164) + } else { + false + } { + Ok(2u64) + } else { + let a165 = 3u64; + let a166 = v1; + if if nat_le(a165, a166) { + let a169 = f35(v0, { + let a167 = v1; + let a168 = 3u64; + nat_sub(a167, a168) + })?; + let a170 = 3u64; + nat_eq(a169, a170) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f31(v0: Str) -> R { + let v1: Bytes = { + let a171 = v0; + utf8_encode(a171) + }; + let v2: u64 = { + let a172 = v1.clone(); + length_bytes(a172) + }; + Ok(f19(v1.clone(), f36(v2, v1, 0u64)?, v2)) +} + +pub fn f32(v0: u64) -> u64 { + let a173 = v0; + let a174 = 128u64; + if nat_lt(a173, a174) { + 1u64 + } else { + let a175 = v0; + let a176 = 224u64; + if nat_lt(a175, a176) { + 2u64 + } else { + let a177 = v0; + let a178 = 240u64; + if nat_lt(a177, a178) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f33(v0: Bytes, v1: u64) -> R { + let m181 = { + let a179 = v0; + let a180 = v1; + index_bytes(a179, a180) + }; + match m181 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a226 = { + let a202 = { + let a190 = { + let a184 = { + let a182 = v3; + let a183 = 128u8; + fixed_u8::bit_and(a182, a183) + }; + let a185 = 128u8; + if equal(a184, a185) { + 128u64 + } else { + 0u64 + } + }; + let a191 = { + let a188 = { + let a186 = v3; + let a187 = 64u8; + fixed_u8::bit_and(a186, a187) + }; + let a189 = 64u8; + if equal(a188, a189) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a190, a191)? + }; + let a203 = { + let a200 = { + let a194 = { + let a192 = v3; + let a193 = 32u8; + fixed_u8::bit_and(a192, a193) + }; + let a195 = 32u8; + if equal(a194, a195) { + 32u64 + } else { + 0u64 + } + }; + let a201 = { + let a198 = { + let a196 = v3; + let a197 = 16u8; + fixed_u8::bit_and(a196, a197) + }; + let a199 = 16u8; + if equal(a198, a199) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a200, a201)? + }; + nat_add(a202, a203)? + }; + let a227 = { + let a224 = { + let a212 = { + let a206 = { + let a204 = v3; + let a205 = 8u8; + fixed_u8::bit_and(a204, a205) + }; + let a207 = 8u8; + if equal(a206, a207) { + 8u64 + } else { + 0u64 + } + }; + let a213 = { + let a210 = { + let a208 = v3; + let a209 = 4u8; + fixed_u8::bit_and(a208, a209) + }; + let a211 = 4u8; + if equal(a210, a211) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a212, a213)? + }; + let a225 = { + let a222 = { + let a216 = { + let a214 = v3; + let a215 = 2u8; + fixed_u8::bit_and(a214, a215) + }; + let a217 = 2u8; + if equal(a216, a217) { + 2u64 + } else { + 0u64 + } + }; + let a223 = { + let a220 = { + let a218 = v3; + let a219 = 1u8; + fixed_u8::bit_and(a218, a219) + }; + let a221 = 1u8; + if equal(a220, a221) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a222, a223)? + }; + nat_add(a224, a225)? + }; + nat_add(a226, a227) + } + } +} + +pub fn f34(v0: u64) -> bool { + let a228 = v0; + let a229 = 32u64; + if nat_eq(a228, a229) { + true + } else { + let a230 = 9u64; + let a231 = v0; + if nat_le(a230, a231) { + let a232 = v0; + let a233 = 13u64; + nat_le(a232, a233) + } else { + false + } + } +} + +pub fn f35(v0: Bytes, v1: u64) -> R { + let v2: u64 = f33(v0.clone(), v1)?; + let v3: u64 = f33(v0.clone(), { + let a234 = v1; + let a235 = 1u64; + nat_add(a234, a235)? + })?; + let v4: u64 = f33(v0, { + let a236 = v1; + let a237 = 2u64; + nat_add(a236, a237)? + })?; + if f34(v2) { + Ok(1u64) + } else { + let a238 = v2; + let a239 = 194u64; + if nat_eq(a238, a239) { + let a240 = v3; + let a241 = 133u64; + if if nat_eq(a240, a241) { + true + } else { + let a242 = v3; + let a243 = 160u64; + nat_eq(a242, a243) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a244 = v2; + let a245 = 225u64; + if nat_eq(a244, a245) { + let a246 = v3; + let a247 = 154u64; + if if nat_eq(a246, a247) { + let a248 = v4; + let a249 = 128u64; + nat_eq(a248, a249) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a250 = v2; + let a251 = 226u64; + if nat_eq(a250, a251) { + let a252 = v3; + let a253 = 128u64; + if nat_eq(a252, a253) { + let a254 = 128u64; + let a255 = v4; + if if if nat_le(a254, a255) { + let a256 = v4; + let a257 = 138u64; + nat_le(a256, a257) + } else { + false + } { + true + } else { + let a258 = v4; + let a259 = 168u64; + if nat_eq(a258, a259) { + true + } else { + let a260 = v4; + let a261 = 169u64; + if nat_eq(a260, a261) { + true + } else { + let a262 = v4; + let a263 = 175u64; + nat_eq(a262, a263) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a264 = v3; + let a265 = 129u64; + if if nat_eq(a264, a265) { + let a266 = v4; + let a267 = 159u64; + nat_eq(a266, a267) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a268 = v2; + let a269 = 227u64; + if if nat_eq(a268, a269) { + let a270 = v3; + let a271 = 128u64; + if nat_eq(a270, a271) { + let a272 = v4; + let a273 = 128u64; + nat_eq(a272, a273) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f36(p280: u64, v1: Bytes, p281: u64) -> R { + let m279 = (p280, p281); + { + let mut m279 = m279; + loop { + let step = { + let (v0, v2) = m279; + let m274 = v0; + if m274 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m274 - 1; + let v4: u64 = f35(v1.clone(), v2)?; + let a275 = v4; + let a276 = 0u64; + if nat_eq(a275, a276) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a277 = v2; + let a278 = v4; + nat_add(a277, a278)? + })) + } + } + }; + match step { + Ok(next) => { m279 = next; } Err(done) => break done, } } } } -pub fn run(p0: Adt0, p1: Adt6) -> Option { +pub fn run(p0: Adt0, p1: Adt6) -> R> { f0(p0, p1) } diff --git a/crates/certified/roots/uorust_certified_decoded.rs b/crates/certified/roots/uorust_certified_decoded.rs index bd626d80..1ba4899a 100644 --- a/crates/certified/roots/uorust_certified_decoded.rs +++ b/crates/certified/roots/uorust_certified_decoded.rs @@ -856,9 +856,13 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: Str) -> Str { - let a1 = List::cons(Str::lit("(match (prim utf8_decode "), List::cons(v0, List::cons(Str::lit(" : (Option String)) | Option.none => \"\" | Option.some text => text)"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("(match (prim utf8_decode "), List::::nil()); + let a2 = List::cons(v0, List::cons(Str::lit(" : (Option String)) | Option.none => \"\" | Option.some text => text)"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) } pub fn run(p0: Str) -> Str { diff --git a/crates/certified/roots/uorust_certified_equality.rs b/crates/certified/roots/uorust_certified_equality.rs index 2de1e975..7a49a8c3 100644 --- a/crates/certified/roots/uorust_certified_equality.rs +++ b/crates/certified/roots/uorust_certified_equality.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -895,16 +896,24 @@ pub fn f0(v0: Adt0, v1: Str, v2: Str) -> Option { } Adt0::C2(_) => { Some({ - let a2 = List::cons(Str::lit("("), List::cons(v1, List::cons(Str::lit(" =? "), List::cons(v2, List::cons(Str::lit(")"), List::::nil()))))); - let a3 = Str::lit(""); - join(a2, a3) + let a4 = { + let a2 = List::cons(Str::lit("("), List::cons(v1, List::::nil())); + let a3 = List::cons(Str::lit(" =? "), List::cons(v2, List::cons(Str::lit(")"), List::::nil()))); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + join(a4, a5) }) } Adt0::C3(_) => { Some({ - let a4 = List::cons(Str::lit("(prim equal "), List::cons(v1, List::cons(Str::lit(" "), List::cons(v2, List::cons(Str::lit(" : Bool)"), List::::nil()))))); - let a5 = Str::lit(""); - join(a4, a5) + let a8 = { + let a6 = List::cons(Str::lit("(prim equal "), List::cons(v1, List::::nil())); + let a7 = List::cons(Str::lit(" "), List::cons(v2, List::cons(Str::lit(" : Bool)"), List::::nil()))); + append_list(a6, a7) + }; + let a9 = Str::lit(""); + join(a8, a9) }) } Adt0::C4(_) => { @@ -913,22 +922,30 @@ pub fn f0(v0: Adt0, v1: Str, v2: Str) -> Option { Adt0::C5(_) => { None:: } - Adt0::C6 => { - Some({ - let a6 = List::cons(Str::lit("(prim equal "), List::cons(v1, List::cons(Str::lit(" "), List::cons(v2, List::cons(Str::lit(" : Bool)"), List::::nil()))))); - let a7 = Str::lit(""); - join(a6, a7) - }) + Adt0::C6(_) => { + None:: } Adt0::C7 => { Some({ - let a8 = List::cons(Str::lit("(prim equal "), List::cons(v1, List::cons(Str::lit(" "), List::cons(v2, List::cons(Str::lit(" : Bool)"), List::::nil()))))); - let a9 = Str::lit(""); - join(a8, a9) + let a12 = { + let a10 = List::cons(Str::lit("(prim equal "), List::cons(v1, List::::nil())); + let a11 = List::cons(Str::lit(" "), List::cons(v2, List::cons(Str::lit(" : Bool)"), List::::nil()))); + append_list(a10, a11) + }; + let a13 = Str::lit(""); + join(a12, a13) }) } Adt0::C8 => { - None:: + Some({ + let a16 = { + let a14 = List::cons(Str::lit("(prim equal "), List::cons(v1, List::::nil())); + let a15 = List::cons(Str::lit(" "), List::cons(v2, List::cons(Str::lit(" : Bool)"), List::::nil()))); + append_list(a14, a15) + }; + let a17 = Str::lit(""); + join(a16, a17) + }) } Adt0::C9 => { None:: @@ -936,16 +953,16 @@ pub fn f0(v0: Adt0, v1: Str, v2: Str) -> Option { Adt0::C10 => { None:: } - Adt0::C11(_) => { + Adt0::C11 => { None:: } Adt0::C12(_) => { None:: } - Adt0::C13(_, _) => { + Adt0::C13(_) => { None:: } - Adt0::C14(_) => { + Adt0::C14(_, _) => { None:: } Adt0::C15(_) => { @@ -954,15 +971,18 @@ pub fn f0(v0: Adt0, v1: Str, v2: Str) -> Option { Adt0::C16(_) => { None:: } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { None:: } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { None:: } Adt0::C19(_, _) => { None:: } + Adt0::C20(_, _) => { + None:: + } } } diff --git a/crates/certified/roots/uorust_certified_evidence_proof.rs b/crates/certified/roots/uorust_certified_evidence_proof.rs index 4f1081a7..ca8993d1 100644 --- a/crates/certified/roots/uorust_certified_evidence_proof.rs +++ b/crates/certified/roots/uorust_certified_evidence_proof.rs @@ -856,13 +856,17 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: List) -> Str { - let a3 = List::cons(Str::lit("linear_arithmetic{definitions: ["), List::cons({ - let a1 = v0; - let a2 = Str::lit(", "); - join(a1, a2) - }, List::cons(Str::lit("]}"), List::::nil()))); - let a4 = Str::lit(""); - join(a3, a4) + let a5 = { + let a3 = List::cons(Str::lit("linear_arithmetic{definitions: ["), List::::nil()); + let a4 = List::cons({ + let a1 = v0; + let a2 = Str::lit(", "); + join(a1, a2) + }, List::cons(Str::lit("]}"), List::::nil())); + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) } pub fn run(p0: List) -> Str { diff --git a/crates/certified/roots/uorust_certified_expr_pieces.rs b/crates/certified/roots/uorust_certified_expr_pieces.rs index 949dedb6..b0b8fc88 100644 --- a/crates/certified/roots/uorust_certified_expr_pieces.rs +++ b/crates/certified/roots/uorust_certified_expr_pieces.rs @@ -883,20 +883,32 @@ pub fn f0(v0: Adt0) -> List { Adt0::C1(_, _) => { List::::nil() } - Adt0::C2(r4, r5, r6) => { - let v4 = (*r4).clone(); - let v5 = (*r5).clone(); - let v6 = (*r6).clone(); - List::cons(Adt2::C0(Str::lit("(if ")), List::cons(Adt2::C1(v4), List::cons(Adt2::C0(Str::lit(" then ")), List::cons(Adt2::C1(v5), List::cons(Adt2::C0(Str::lit(" else ")), List::cons(Adt2::C1(v6), List::cons(Adt2::C0(Str::lit(")")), List::::nil()))))))) + Adt0::C2(r12, r13, r14) => { + let v4 = (*r12).clone(); + let v5 = (*r13).clone(); + let v6 = (*r14).clone(); + let a4 = List::cons(Adt2::C0(Str::lit("(if ")), List::cons(Adt2::C1(v4), List::cons(Adt2::C0(Str::lit(" then ")), List::::nil()))); + let a5 = { + let a2 = List::cons(Adt2::C1(v5), List::cons(Adt2::C0(Str::lit(" else ")), List::::nil())); + let a3 = List::cons(Adt2::C1(v6), List::cons(Adt2::C0(Str::lit(")")), List::::nil())); + append_list(a2, a3) + }; + append_list(a4, a5) } - Adt0::C3(v7, v8, r7, r8) => { - let v9 = (*r7).clone(); - let v10 = (*r8).clone(); - List::cons(Adt2::C0({ - let a2 = List::cons(Str::lit("(let "), List::cons(v7, List::cons(Str::lit(" : "), List::cons(v8, List::cons(Str::lit(" := "), List::::nil()))))); - let a3 = Str::lit(""); - join(a2, a3) - }), List::cons(Adt2::C1(v9), List::cons(Adt2::C0(Str::lit("; ")), List::cons(Adt2::C1(v10), List::cons(Adt2::C0(Str::lit(")")), List::::nil()))))) + Adt0::C3(v7, v8, r15, r16) => { + let v9 = (*r15).clone(); + let v10 = (*r16).clone(); + let a10 = List::cons(Adt2::C0({ + let a8 = { + let a6 = List::cons(Str::lit("(let "), List::cons(v7, List::::nil())); + let a7 = List::cons(Str::lit(" : "), List::cons(v8, List::cons(Str::lit(" := "), List::::nil()))); + append_list(a6, a7) + }; + let a9 = Str::lit(""); + join(a8, a9) + }), List::cons(Adt2::C1(v9), List::::nil())); + let a11 = List::cons(Adt2::C0(Str::lit("; ")), List::cons(Adt2::C1(v10), List::cons(Adt2::C0(Str::lit(")")), List::::nil()))); + append_list(a10, a11) } } } diff --git a/crates/certified/roots/uorust_certified_field_name.rs b/crates/certified/roots/uorust_certified_field_name.rs new file mode 100644 index 00000000..575b964b --- /dev/null +++ b/crates/certified/roots/uorust_certified_field_name.rs @@ -0,0 +1,1906 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0, + C1, + C2, + C3, +} + +#[derive(Clone)] +pub enum Adt1 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str, bool, bool), +} + +#[derive(Clone)] +pub enum Adt3 { + C0(Str, bool), +} + +pub fn f0(v0: Str) -> R { + let m1 = f1(v0.clone(), 4294967295u64)?; + match m1 { + Ok(v1) => { + let a2 = List::cons(Str::lit("item"), List::cons(f2(v1)?, List::::nil())); + let a3 = Str::lit(""); + Ok(join(a2, a3)) + } + Err(_) => { + f3(v0) + } + } +} + +pub fn f1(v0: Str, v1: u64) -> R> { + let v2: Bytes = { + let a4 = v0; + utf8_encode(a4) + }; + let v3: u64 = { + let a5 = v2.clone(); + length_bytes(a5) + }; + let a6 = v3; + let a7 = 0u64; + if nat_eq(a6, a7) { + Ok(Err::(Adt0::C0)) + } else { + let a8 = f4(v2.clone(), 0u64)?; + let a9 = 43u64; + if nat_eq(a8, a9) { + let a10 = v3; + let a11 = 1u64; + if nat_eq(a10, a11) { + Ok(Err::(Adt0::C1)) + } else { + f5(v3, v2, 1u64, 0u64, v1) + } + } else { + f5(v3, v2, 0u64, 0u64, v1) + } + } +} + +pub fn f2(v0: u64) -> R { + Ok(f6({ + let a12 = v0; + let a13 = 1u64; + nat_add(a12, a13)? + }, v0)) +} + +pub fn f3(v0: Str) -> R { + let v1: Str = f7(List::cons(f8(v0, Str::lit("r#"))?, List::::nil()))?; + let a14 = v1.clone(); + let a15 = Str::lit(""); + if if equal(a14, a15) { + true + } else { + f9(f10(), v1.clone()) + } { + let a16 = List::cons(v1, List::cons(Str::lit("Value"), List::::nil())); + let a17 = Str::lit(""); + Ok(join(a16, a17)) + } else { + Ok(v1) + } +} + +pub fn f4(v0: Bytes, v1: u64) -> R { + let m20 = { + let a18 = v0; + let a19 = v1; + index_bytes(a18, a19) + }; + match m20 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a65 = { + let a41 = { + let a29 = { + let a23 = { + let a21 = v3; + let a22 = 128u8; + fixed_u8::bit_and(a21, a22) + }; + let a24 = 128u8; + if equal(a23, a24) { + 128u64 + } else { + 0u64 + } + }; + let a30 = { + let a27 = { + let a25 = v3; + let a26 = 64u8; + fixed_u8::bit_and(a25, a26) + }; + let a28 = 64u8; + if equal(a27, a28) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a29, a30)? + }; + let a42 = { + let a39 = { + let a33 = { + let a31 = v3; + let a32 = 32u8; + fixed_u8::bit_and(a31, a32) + }; + let a34 = 32u8; + if equal(a33, a34) { + 32u64 + } else { + 0u64 + } + }; + let a40 = { + let a37 = { + let a35 = v3; + let a36 = 16u8; + fixed_u8::bit_and(a35, a36) + }; + let a38 = 16u8; + if equal(a37, a38) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a39, a40)? + }; + nat_add(a41, a42)? + }; + let a66 = { + let a63 = { + let a51 = { + let a45 = { + let a43 = v3; + let a44 = 8u8; + fixed_u8::bit_and(a43, a44) + }; + let a46 = 8u8; + if equal(a45, a46) { + 8u64 + } else { + 0u64 + } + }; + let a52 = { + let a49 = { + let a47 = v3; + let a48 = 4u8; + fixed_u8::bit_and(a47, a48) + }; + let a50 = 4u8; + if equal(a49, a50) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a51, a52)? + }; + let a64 = { + let a61 = { + let a55 = { + let a53 = v3; + let a54 = 2u8; + fixed_u8::bit_and(a53, a54) + }; + let a56 = 2u8; + if equal(a55, a56) { + 2u64 + } else { + 0u64 + } + }; + let a62 = { + let a59 = { + let a57 = v3; + let a58 = 1u8; + fixed_u8::bit_and(a57, a58) + }; + let a60 = 1u8; + if equal(a59, a60) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a61, a62)? + }; + nat_add(a63, a64)? + }; + nat_add(a65, a66) + } + } +} + +pub fn f5(p86: u64, v1: Bytes, p87: u64, p88: u64, v4: u64) -> R> { + let m85 = (p86, (p87, p88)); + { + let mut m85 = m85; + loop { + let step = { + let (v0, (v2, v3)) = m85; + let m67 = v0; + if m67 == 0 { + Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) + } else { + let v5 = m67 - 1; + let a69 = { + let a68 = v1.clone(); + length_bytes(a68) + }; + let a70 = v2; + if nat_le(a69, a70) { + Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) + } else { + let v6: u64 = f4(v1.clone(), v2)?; + let a71 = 48u64; + let a72 = v6; + if if nat_le(a71, a72) { + let a73 = v6; + let a74 = 57u64; + nat_le(a73, a74) + } else { + false + } { + let v7: u64 = { + let a79 = { + let a75 = v3; + let a76 = 10u64; + nat_mul(a75, a76)? + }; + let a80 = { + let a77 = v6; + let a78 = 48u64; + nat_sub(a77, a78) + }; + nat_add(a79, a80)? + }; + let a81 = v4; + let a82 = v7; + if nat_lt(a81, a82) { + Err::<(u64, (u64, u64)), R>>(Ok(Err::(Adt0::C2))) + } else { + Ok::<(u64, (u64, u64)), R>>((v5, ({ + let a83 = v2; + let a84 = 1u64; + nat_add(a83, a84)? + }, v7))) + } + } else { + Err::<(u64, (u64, u64)), R>>(Ok(Err::(Adt0::C1))) + } + } + } + }; + match step { + Ok(next) => { m85 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f6(v0: u64, v1: u64) -> Str { + let m89 = v0; + if m89 == 0 { + Str::lit("") + } else { + let v2 = m89 - 1; + let a90 = v1; + let a91 = 10u64; + if nat_lt(a90, a91) { + f11(v1) + } else { + let a98 = List::cons(f6(v2, { + let a92 = v1; + let a93 = 10u64; + let a94 = 0u64; + nat_quot(a92, a93, a94) + }), List::cons(f11({ + let a95 = v1; + let a96 = 10u64; + let a97 = 0u64; + nat_rem(a95, a96, a97) + }), List::::nil())); + let a99 = Str::lit(""); + join(a98, a99) + } + } +} + +pub fn f7(v0: List) -> R { + let a100 = f12(f13(f14(f15(v0)?)?, 0u64)?)?; + let a101 = Str::lit(""); + Ok(join(a100, a101)) +} + +pub fn f8(v0: Str, v1: Str) -> R { + let v2: Bytes = { + let a102 = v0.clone(); + utf8_encode(a102) + }; + let v3: Bytes = { + let a103 = v1; + utf8_encode(a103) + }; + let a105 = { + let a104 = v3.clone(); + length_bytes(a104) + }; + let a106 = 0u64; + if nat_eq(a105, a106) { + Ok(v0) + } else { + Ok(f16(v2.clone(), f17({ + let a107 = v2.clone(); + length_bytes(a107) + }, v2.clone(), v3, 0u64)?, { + let a108 = v2; + length_bytes(a108) + })) + } +} + +pub fn f9(p113: List, v1: Str) -> bool { + let m112 = p113; + { + let mut m112 = m112; + loop { + let step = { + let v0 = m112; + let m109 = v0; + match m109.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a110 = v2; + let a111 = v1.clone(); + if equal(a110, a111) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m112 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f10() -> List { + let a142 = { + let a126 = { + let a118 = { + let a114 = List::cons(Str::lit("at"), List::cons(Str::lit("by"), List::cons(Str::lit("calc"), List::cons(Str::lit("def"), List::cons(Str::lit("do"), List::cons(Str::lit("else"), List::::nil())))))); + let a115 = List::cons(Str::lit("end"), List::cons(Str::lit("example"), List::cons(Str::lit("fun"), List::cons(Str::lit("have"), List::cons(Str::lit("if"), List::cons(Str::lit("in"), List::::nil())))))); + append_list(a114, a115) + }; + let a119 = { + let a116 = List::cons(Str::lit("instance"), List::cons(Str::lit("let"), List::cons(Str::lit("match"), List::cons(Str::lit("mut"), List::cons(Str::lit("nomatch"), List::cons(Str::lit("open"), List::::nil())))))); + let a117 = List::cons(Str::lit("prop"), List::cons(Str::lit("return"), List::cons(Str::lit("show"), List::cons(Str::lit("then"), List::cons(Str::lit("theorem"), List::cons(Str::lit("type"), List::cons(Str::lit("where"), List::::nil()))))))); + append_list(a116, a117) + }; + append_list(a118, a119) + }; + let a127 = { + let a124 = { + let a120 = List::cons(Str::lit("with"), List::cons(Str::lit("from"), List::cons(Str::lit("for"), List::cons(Str::lit("try"), List::cons(Str::lit("catch"), List::cons(Str::lit("break"), List::::nil())))))); + let a121 = List::cons(Str::lit("continue"), List::cons(Str::lit("unless"), List::cons(Str::lit("structure"), List::cons(Str::lit("inductive"), List::cons(Str::lit("class"), List::cons(Str::lit("namespace"), List::cons(Str::lit("section"), List::::nil()))))))); + append_list(a120, a121) + }; + let a125 = { + let a122 = List::cons(Str::lit("local"), List::cons(Str::lit("private"), List::cons(Str::lit("protected"), List::cons(Str::lit("partial"), List::cons(Str::lit("unsafe"), List::cons(Str::lit("macro"), List::::nil())))))); + let a123 = List::cons(Str::lit("syntax"), List::cons(Str::lit("import"), List::cons(Str::lit("export"), List::cons(Str::lit("axiom"), List::cons(Str::lit("abbrev"), List::cons(Str::lit("opaque"), List::cons(Str::lit("mutual"), List::::nil()))))))); + append_list(a122, a123) + }; + append_list(a124, a125) + }; + append_list(a126, a127) + }; + let a143 = { + let a140 = { + let a132 = { + let a128 = List::cons(Str::lit("variable"), List::cons(Str::lit("universe"), List::cons(Str::lit("deriving"), List::cons(Str::lit("extends"), List::cons(Str::lit("suffices"), List::cons(Str::lit("obtain"), List::::nil())))))); + let a129 = List::cons(Str::lit("record"), List::cons(Str::lit("ctor"), List::cons(Str::lit("prim"), List::cons(Str::lit("project"), List::cons(Str::lit("cons"), List::cons(Str::lit("nil"), List::::nil())))))); + append_list(a128, a129) + }; + let a133 = { + let a130 = List::cons(Str::lit("not"), List::cons(Str::lit("true"), List::cons(Str::lit("false"), List::cons(Str::lit("forall"), List::cons(Str::lit("first"), List::cons(Str::lit("second"), List::::nil())))))); + let a131 = List::cons(Str::lit("apply"), List::cons(Str::lit("ref"), List::cons(Str::lit("checked"), List::cons(Str::lit("self"), List::cons(Str::lit("noncomputable"), List::cons(Str::lit("termination_by"), List::cons(Str::lit("and_congr"), List::::nil()))))))); + append_list(a130, a131) + }; + append_list(a132, a133) + }; + let a141 = { + let a138 = { + let a134 = List::cons(Str::lit("and_true"), List::cons(Str::lit("beq_iff_eq"), List::cons(Str::lit("congr"), List::cons(Str::lit("decide"), List::cons(Str::lit("decide_eq_false_iff_not"), List::cons(Str::lit("decide_eq_true_eq"), List::::nil())))))); + let a135 = List::cons(Str::lit("id"), List::cons(Str::lit("reduceIte"), List::cons(Str::lit("rfl"), List::cons(Str::lit("true_and"), List::cons(Str::lit("isFalse"), List::cons(Str::lit("isTrue"), List::cons(Str::lit("none"), List::::nil()))))))); + append_list(a134, a135) + }; + let a139 = { + let a136 = List::cons(Str::lit("some"), List::cons(Str::lit("below"), List::cons(Str::lit("brecOn"), List::cons(Str::lit("casesOn"), List::cons(Str::lit("ctorElim"), List::cons(Str::lit("ctorElimType"), List::::nil())))))); + let a137 = List::cons(Str::lit("ctorIdx"), List::cons(Str::lit("mk"), List::cons(Str::lit("noConfusion"), List::cons(Str::lit("noConfusionType"), List::cons(Str::lit("rec"), List::cons(Str::lit("recOn"), List::cons(Str::lit("toCtorIdx"), List::::nil()))))))); + append_list(a136, a137) + }; + append_list(a138, a139) + }; + append_list(a140, a141) + }; + append_list(a142, a143) +} + +pub fn f11(v0: u64) -> Str { + let a144 = v0; + let a145 = 0u64; + if nat_eq(a144, a145) { + Str::lit("0") + } else { + let a146 = v0; + let a147 = 1u64; + if nat_eq(a146, a147) { + Str::lit("1") + } else { + let a148 = v0; + let a149 = 2u64; + if nat_eq(a148, a149) { + Str::lit("2") + } else { + let a150 = v0; + let a151 = 3u64; + if nat_eq(a150, a151) { + Str::lit("3") + } else { + let a152 = v0; + let a153 = 4u64; + if nat_eq(a152, a153) { + Str::lit("4") + } else { + let a154 = v0; + let a155 = 5u64; + if nat_eq(a154, a155) { + Str::lit("5") + } else { + let a156 = v0; + let a157 = 6u64; + if nat_eq(a156, a157) { + Str::lit("6") + } else { + let a158 = v0; + let a159 = 7u64; + if nat_eq(a158, a159) { + Str::lit("7") + } else { + let a160 = v0; + let a161 = 8u64; + if nat_eq(a160, a161) { + Str::lit("8") + } else { + Str::lit("9") + } + } + } + } + } + } + } + } + } +} + +pub fn f12(v0: List) -> R> { + let m162 = v0; + match m162.uncons() { + None => { + Ok(List::::nil()) + } + Some((v1, v2)) => { + let v3: u64 = match v1.clone() { + Adt1::C0(h163, _) => { + h163 + } + }; + let v4: Str = match v1 { + Adt1::C0(_, h164) => { + h164 + } + }; + Ok(List::cons({ + let a165 = v3; + let a166 = 0u64; + if nat_eq(a165, a166) { + f18(v4)? + } else { + v4 + } + }, f12(v2)?)) + } + } +} + +pub fn f13(v0: List, v1: u64) -> R> { + let m167 = v0; + match m167.uncons() { + None => { + Ok(List::::nil()) + } + Some((v2, v3)) => { + Ok(List::cons(Adt1::C0(v1, v2), f13(v3, { + let a168 = v1; + let a169 = 1u64; + nat_add(a168, a169)? + })?)) + } + } +} + +pub fn f14(v0: Str) -> R> { + let v1: Bytes = { + let a170 = v0; + utf8_encode(a170) + }; + f19({ + let a171 = v1.clone(); + length_bytes(a171) + }, v1, 0u64) +} + +pub fn f15(v0: List) -> R { + let v1: Str = Str::lit(""); + let v2: Str = f20(v0, v1)?; + if f21(v2.clone())? { + let a172 = List::cons(Str::lit("N"), List::cons(v2, List::::nil())); + let a173 = Str::lit(""); + Ok(join(a172, a173)) + } else { + Ok(v2) + } +} + +pub fn f16(v0: Bytes, v1: u64, v2: u64) -> Str { + let m179 = { + let a176 = v0; + let a177 = v1; + let a178 = { + let a174 = v2; + let a175 = v1; + nat_sub(a174, a175) + }; + slice_bytes(a176, a177, a178) + }; + match m179 { + None => { + Str::lit("") + } + Some(v3) => { + let m181 = { + let a180 = v3; + utf8_decode(a180) + }; + match m181 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f17(p187: u64, v1: Bytes, v2: Bytes, p188: u64) -> R { + let m186 = (p187, p188); + { + let mut m186 = m186; + loop { + let step = { + let (v0, v3) = m186; + let m182 = v0; + if m182 == 0 { + Err::<(u64, u64), R>(Ok(v3)) + } else { + let v4 = m182 - 1; + if f22(v1.clone(), v3, v2.clone()) { + Ok::<(u64, u64), R>((v4, { + let a184 = v3; + let a185 = { + let a183 = v2.clone(); + length_bytes(a183) + }; + nat_add(a184, a185)? + })) + } else { + Err::<(u64, u64), R>(Ok(v3)) + } + } + }; + match step { + Ok(next) => { m186 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f18(v0: Str) -> R { + f23(v0, 65u64, Bytes::lit(&[0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a])) +} + +pub fn f19(v0: u64, v1: Bytes, v2: u64) -> R> { + let m189 = v0; + if m189 == 0 { + Ok(List::::nil()) + } else { + let v3 = m189 - 1; + let a191 = { + let a190 = v1.clone(); + length_bytes(a190) + }; + let a192 = v2; + if nat_le(a191, a192) { + Ok(List::::nil()) + } else { + let v4: u64 = f24(f4(v1.clone(), v2)?); + Ok(List::cons(f16(v1.clone(), v2, { + let a193 = v2; + let a194 = v4; + nat_add(a193, a194)? + }), f19(v3, v1, { + let a195 = v2; + let a196 = v4; + nat_add(a195, a196)? + })?)) + } + } +} + +pub fn f20(p202: List, p203: Str) -> R { + let m201 = (p202, p203); + { + let mut m201 = m201; + loop { + let step = { + let (v0, v1) = m201; + let m197 = v0; + match m197.uncons() { + None => { + Err::<(List, Str), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: bool = true; + let v5: bool = false; + let v6: Adt2 = f25(f14(v2)?, Adt2::C0(v1, v5, v4))?; + let v7: Str = match v6.clone() { + Adt2::C0(h198, _, _) => { + h198 + } + }; + let _: bool = match v6.clone() { + Adt2::C0(_, h199, _) => { + h199 + } + }; + let _: bool = match v6 { + Adt2::C0(_, _, h200) => { + h200 + } + }; + Ok::<(List, Str), R>((v3, v7)) + } + } + }; + match step { + Ok(next) => { m201 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f21(v0: Str) -> R { + let m206 = { + let a204 = f14(v0)?; + let a205 = 0u64; + index_list(a204, a205) + }; + match m206 { + None => { + Ok(false) + } + Some(v1) => { + f26(v1) + } + } +} + +pub fn f22(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m211 = { + let a208 = v0; + let a209 = v1; + let a210 = { + let a207 = v2.clone(); + length_bytes(a207) + }; + slice_bytes(a208, a209, a210) + }; + match m211 { + None => { + false + } + Some(v3) => { + let a212 = v3; + let a213 = v2; + equal(a212, a213) + } + } +} + +pub fn f23(v0: Str, v1: u64, v2: Bytes) -> R { + let v3: Bytes = { + let a214 = v0.clone(); + utf8_encode(a214) + }; + let m218 = { + let a217 = f27({ + let a215 = v3.clone(); + length_bytes(a215) + }, v3, 0u64, v1, v2, { + let a216 = Str::lit(""); + utf8_encode(a216) + })?; + utf8_decode(a217) + }; + match m218 { + None => { + Ok(v0) + } + Some(v4) => { + Ok(v4) + } + } +} + +pub fn f24(v0: u64) -> u64 { + let a219 = v0; + let a220 = 128u64; + if nat_lt(a219, a220) { + 1u64 + } else { + let a221 = v0; + let a222 = 224u64; + if nat_lt(a221, a222) { + 2u64 + } else { + let a223 = v0; + let a224 = 240u64; + if nat_lt(a223, a224) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f25(p240: List, p241: Adt2) -> R { + let m239 = (p240, p241); + { + let mut m239 = m239; + loop { + let step = { + let (v0, v1) = m239; + let m225 = v0; + match m225.uncons() { + None => { + Err::<(List, Adt2), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: Str = match v1.clone() { + Adt2::C0(h226, _, _) => { + h226 + } + }; + let v5: bool = match v1.clone() { + Adt2::C0(_, h227, _) => { + h227 + } + }; + let v6: bool = match v1 { + Adt2::C0(_, _, h228) => { + h228 + } + }; + let a229 = f28(v2.clone())?; + if bool_not(a229) { + let v7: bool = true; + let v8: bool = false; + Ok::<(List, Adt2), R>((v3, Adt2::C0(v4, v8, v7))) + } else { + let v14: Adt3 = if v6 { + let v9: Str = { + let a230 = List::cons(v4, List::cons(f29(v2.clone())?, List::::nil())); + let a231 = Str::lit(""); + join(a230, a231) + }; + let v10: bool = false; + Adt3::C0(v9, v10) + } else { + let v13: Str = if if f30(v2.clone())? { + let a232 = v5; + bool_not(a232) + } else { + false + } { + let v11: Str = { + let a233 = List::cons(v4, List::cons(f18(v2.clone())?, List::::nil())); + let a234 = Str::lit(""); + join(a233, a234) + }; + v11 + } else { + let v12: Str = { + let a235 = List::cons(v4, List::cons(v2.clone(), List::::nil())); + let a236 = Str::lit(""); + join(a235, a236) + }; + v12 + }; + Adt3::C0(v13, v6) + }; + let v15: Str = match v14.clone() { + Adt3::C0(h237, _) => { + h237 + } + }; + let v16: bool = match v14 { + Adt3::C0(_, h238) => { + h238 + } + }; + let v17: bool = if f31(v2.clone())? { + true + } else { + f26(v2)? + }; + Ok::<(List, Adt2), R>((v3, Adt2::C0(v15, v17, v16))) + } + } + } + }; + match step { + Ok(next) => { m239 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f26(v0: Str) -> R { + let v1: u64 = f32(v0)?; + let a242 = 48u64; + let a243 = v1; + if nat_le(a242, a243) { + let a244 = v1; + let a245 = 57u64; + Ok(nat_le(a244, a245)) + } else { + Ok(false) + } +} + +pub fn f27(p268: u64, v1: Bytes, p269: u64, v3: u64, v4: Bytes, p270: Bytes) -> R { + let m267 = (p268, (p269, p270)); + { + let mut m267 = m267; + loop { + let step = { + let (v0, (v2, v5)) = m267; + let m246 = v0; + if m246 == 0 { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } else { + let v6 = m246 - 1; + let m250 = { + let a247 = v1.clone(); + let a248 = v2; + let a249 = 1u64; + slice_bytes(a247, a248, a249) + }; + match m250 { + None => { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } + Some(v7) => { + let v8: u64 = f4(v1.clone(), v2)?; + let v10: Bytes = { + let a251 = v3; + let a252 = v8; + if if nat_le(a251, a252) { + let a255 = v8; + let a256 = { + let a253 = v3; + let a254 = 26u64; + nat_add(a253, a254)? + }; + nat_lt(a255, a256) + } else { + false + } { + let m262 = { + let a259 = v4.clone(); + let a260 = { + let a257 = v8; + let a258 = v3; + nat_sub(a257, a258) + }; + let a261 = 1u64; + slice_bytes(a259, a260, a261) + }; + match m262 { + None => { + v7 + } + Some(v9) => { + v9 + } + } + } else { + v7 + } + }; + Ok::<(u64, (u64, Bytes)), R>((v6, ({ + let a263 = v2; + let a264 = 1u64; + nat_add(a263, a264)? + }, { + let a265 = v5; + let a266 = v10; + append_bytes(a265, a266) + }))) + } + } + } + }; + match step { + Ok(next) => { m267 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f28(v0: Str) -> R { + if f33(v0.clone())? { + Ok(true) + } else { + f26(v0) + } +} + +pub fn f29(v0: Str) -> R { + f23(v0, 97u64, Bytes::lit(&[0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a])) +} + +pub fn f30(v0: Str) -> R { + let v1: u64 = f32(v0)?; + let a271 = 65u64; + let a272 = v1; + if nat_le(a271, a272) { + let a273 = v1; + let a274 = 90u64; + Ok(nat_le(a273, a274)) + } else { + Ok(false) + } +} + +pub fn f31(v0: Str) -> R { + let v1: u64 = f32(v0)?; + let a275 = 97u64; + let a276 = v1; + if nat_le(a275, a276) { + let a277 = v1; + let a278 = 122u64; + Ok(nat_le(a277, a278)) + } else { + Ok(false) + } +} + +pub fn f32(v0: Str) -> R { + f4({ + let a279 = v0; + utf8_encode(a279) + }, 0u64) +} + +pub fn f33(v0: Str) -> R { + if f30(v0.clone())? { + Ok(true) + } else { + f31(v0) + } +} + +pub fn run(p0: Str) -> R { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_fixed.rs b/crates/certified/roots/uorust_certified_fixed.rs index 85a2ec3a..515d3bf9 100644 --- a/crates/certified/roots/uorust_certified_fixed.rs +++ b/crates/certified/roots/uorust_certified_fixed.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -902,12 +903,12 @@ pub fn f0(v0: Adt0) -> Option { Adt0::C4(_) => { None:: } - Adt0::C5(v5) => { - v5 - } - Adt0::C6 => { + Adt0::C5(_) => { None:: } + Adt0::C6(v6) => { + v6 + } Adt0::C7 => { None:: } @@ -920,16 +921,16 @@ pub fn f0(v0: Adt0) -> Option { Adt0::C10 => { None:: } - Adt0::C11(_) => { + Adt0::C11 => { None:: } Adt0::C12(_) => { None:: } - Adt0::C13(_, _) => { + Adt0::C13(_) => { None:: } - Adt0::C14(_) => { + Adt0::C14(_, _) => { None:: } Adt0::C15(_) => { @@ -938,15 +939,18 @@ pub fn f0(v0: Adt0) -> Option { Adt0::C16(_) => { None:: } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { None:: } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { None:: } Adt0::C19(_, _) => { None:: } + Adt0::C20(_, _) => { + None:: + } } } diff --git a/crates/certified/roots/uorust_certified_flat_lift.rs b/crates/certified/roots/uorust_certified_flat_lift.rs index 10ce6331..d04e5ff2 100644 --- a/crates/certified/roots/uorust_certified_flat_lift.rs +++ b/crates/certified/roots/uorust_certified_flat_lift.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_flat_some.rs b/crates/certified/roots/uorust_certified_flat_some.rs index 0213b901..0037f129 100644 --- a/crates/certified/roots/uorust_certified_flat_some.rs +++ b/crates/certified/roots/uorust_certified_flat_some.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_holds_no_pointer.rs b/crates/certified/roots/uorust_certified_holds_no_pointer.rs index 3de4b550..37c0fb6d 100644 --- a/crates/certified/roots/uorust_certified_holds_no_pointer.rs +++ b/crates/certified/roots/uorust_certified_holds_no_pointer.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -903,58 +904,61 @@ pub fn f0(v0: Adt0) -> bool { true } Adt0::C5(_) => { - true + false } - Adt0::C6 => { + Adt0::C6(_) => { true } Adt0::C7 => { - false + true } Adt0::C8 => { - true + false } Adt0::C9 => { - false + true } Adt0::C10 => { false } - Adt0::C11(_) => { + Adt0::C11 => { + false + } + Adt0::C12(_) => { false } - Adt0::C12(r2) => { - let v6 = (*r2).clone(); - f0(v6) + Adt0::C13(r2) => { + let v7 = (*r2).clone(); + f0(v7) } - Adt0::C13(r3, r4) => { - let v7 = (*r3).clone(); - let v8 = (*r4).clone(); - if f0(v7) { - f0(v8) + Adt0::C14(r3, r4) => { + let v8 = (*r3).clone(); + let v9 = (*r4).clone(); + if f0(v8) { + f0(v9) } else { false } } - Adt0::C14(r5) => { - let v9 = (*r5).clone(); - f0(v9) - } - Adt0::C15(v10) => { - f1(v10) + Adt0::C15(r5) => { + let v10 = (*r5).clone(); + f0(v10) } Adt0::C16(v11) => { - f2(v11) + f1(v11) } - Adt0::C17(_, _, _) => { - false + Adt0::C17(v12) => { + f2(v12) } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { false } Adt0::C19(_, _) => { false } + Adt0::C20(_, _) => { + false + } } } diff --git a/crates/certified/roots/uorust_certified_hypotheses.rs b/crates/certified/roots/uorust_certified_hypotheses.rs index 14e2eb9e..56861f72 100644 --- a/crates/certified/roots/uorust_certified_hypotheses.rs +++ b/crates/certified/roots/uorust_certified_hypotheses.rs @@ -881,19 +881,27 @@ pub fn f2(v0: Adt0) -> Str { let m2 = v0; match m2 { Adt0::C0(v1, v2) => { - let a3 = List::cons(Str::lit("("), List::cons(v1, List::cons(Str::lit(" = "), List::cons(if v2 { - Str::lit("true") - } else { - Str::lit("false") - }, List::cons(Str::lit(")"), List::::nil()))))); - let a4 = Str::lit(""); - join(a3, a4) - } - Adt0::C1(v3, v4) => { - let a5 = List::cons(Str::lit("("), List::cons(v3, List::cons(Str::lit(" = "), List::cons(v4, List::cons(Str::lit(")"), List::::nil()))))); + let a5 = { + let a3 = List::cons(Str::lit("("), List::cons(v1, List::::nil())); + let a4 = List::cons(Str::lit(" = "), List::cons(if v2 { + Str::lit("true") + } else { + Str::lit("false") + }, List::cons(Str::lit(")"), List::::nil()))); + append_list(a3, a4) + }; let a6 = Str::lit(""); join(a5, a6) } + Adt0::C1(v3, v4) => { + let a9 = { + let a7 = List::cons(Str::lit("("), List::cons(v3, List::::nil())); + let a8 = List::cons(Str::lit(" = "), List::cons(v4, List::cons(Str::lit(")"), List::::nil()))); + append_list(a7, a8) + }; + let a10 = Str::lit(""); + join(a9, a10) + } } } diff --git a/crates/certified/roots/uorust_certified_implication.rs b/crates/certified/roots/uorust_certified_implication.rs index 699e9877..b50e1bc4 100644 --- a/crates/certified/roots/uorust_certified_implication.rs +++ b/crates/certified/roots/uorust_certified_implication.rs @@ -861,13 +861,13 @@ pub fn f0(v0: List, v1: Str) -> Str { v3 } -pub fn f1(p5: List, p6: Str) -> Str { - let m4 = (p5, p6); +pub fn f1(p7: List, p8: Str) -> Str { + let m6 = (p7, p8); { - let mut m4 = m4; + let mut m6 = m6; loop { let step = { - let (v0, v1) = m4; + let (v0, v1) = m6; let m1 = v0; match m1.uncons() { None => { @@ -875,16 +875,20 @@ pub fn f1(p5: List, p6: Str) -> Str { } Some((v2, v3)) => { let v4: Str = { - let a2 = List::cons(Str::lit("("), List::cons(v2, List::cons(Str::lit(" -> "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))))); - let a3 = Str::lit(""); - join(a2, a3) + let a4 = { + let a2 = List::cons(Str::lit("("), List::cons(v2, List::::nil())); + let a3 = List::cons(Str::lit(" -> "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + join(a4, a5) }; Ok::<(List, Str), Str>((v3, v4)) } } }; match step { - Ok(next) => { m4 = next; } + Ok(next) => { m6 = next; } Err(done) => break done, } } @@ -892,15 +896,15 @@ pub fn f1(p5: List, p6: Str) -> Str { } pub fn f2(v0: List) -> List { - let m7 = v0; - match m7.uncons() { + let m9 = v0; + match m9.uncons() { None => { List::::nil() } Some((v1, v2)) => { - let a8 = f2(v2); - let a9 = List::cons(v1, List::::nil()); - append_list(a8, a9) + let a10 = f2(v2); + let a11 = List::cons(v1, List::::nil()); + append_list(a10, a11) } } } diff --git a/crates/certified/roots/uorust_certified_insert_all.rs b/crates/certified/roots/uorust_certified_insert_all.rs index 1285edfe..a8fdb82c 100644 --- a/crates/certified/roots/uorust_certified_insert_all.rs +++ b/crates/certified/roots/uorust_certified_insert_all.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -891,7 +892,7 @@ pub enum Adt2 { #[derive(Clone)] pub enum Adt3 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -1402,24 +1403,40 @@ pub fn f0(v0: Adt0, v1: Adt0, v2: Str, v3: Adt2, v4: Adt16, v5: Adt69) -> R::nil())))); - let a10 = Str::lit(""); - join(a9, a10) - }, Adt71::C0({ - let a11 = List::cons(Str::lit("("), List::cons(v18.clone(), List::cons(Str::lit(" "), List::cons(v16, List::cons(Str::lit(" ("), List::cons(v2.clone(), List::cons(Str::lit(" "), List::cons(v7.clone(), List::cons(Str::lit(" "), List::cons(v13, List::cons(Str::lit("))"), List::::nil()))))))))))); + let a11 = { + let a9 = List::cons(Str::lit("List.cons "), List::cons(v13.clone(), List::::nil())); + let a10 = List::cons(Str::lit(" "), List::cons(v16.clone(), List::::nil())); + append_list(a9, a10) + }; let a12 = Str::lit(""); join(a11, a12) + }, Adt71::C0({ + let a19 = { + let a17 = { + let a13 = List::cons(Str::lit("("), List::cons(v18.clone(), List::::nil())); + let a14 = List::cons(Str::lit(" "), List::cons(v16, List::cons(Str::lit(" ("), List::::nil()))); + append_list(a13, a14) + }; + let a18 = { + let a15 = List::cons(v2.clone(), List::cons(Str::lit(" "), List::cons(v7.clone(), List::::nil()))); + let a16 = List::cons(Str::lit(" "), List::cons(v13, List::cons(Str::lit("))"), List::::nil()))); + append_list(a15, a16) + }; + append_list(a17, a18) + }; + let a20 = Str::lit(""); + join(a19, a20) })), List::::nil()))); let v20: List = f3(v17.clone(), v2.clone()); let v21: Adt69 = f4(v17, Adt70::C0(v18.clone(), List::cons(Adt6::C0(v10, f5(v1)), List::cons(Adt6::C0(v7, f5(v0.clone())), List::::nil())), f5(v0), v19, f6(List::cons({ - let a13 = List::cons(Str::lit("#"), List::cons(v2, List::::nil())); - let a14 = Str::lit(""); - join(a13, a14) + let a21 = List::cons(Str::lit("#"), List::cons(v2, List::::nil())); + let a22 = Str::lit(""); + join(a21, a22) }, List::::nil()), List::::nil()), v20, true, false, None::<(Str, List)>)); let v22: Adt69 = f7(v21, { - let a15 = List::cons(Str::lit("#"), List::cons(v18.clone(), List::::nil())); - let a16 = Str::lit(""); - join(a15, a16) + let a23 = List::cons(Str::lit("#"), List::cons(v18.clone(), List::::nil())); + let a24 = Str::lit(""); + join(a23, a24) }); Ok(Adt74::C0(v18, v22)) } @@ -1427,63 +1444,63 @@ pub fn f0(v0: Adt0, v1: Adt0, v2: Str, v3: Adt2, v4: Adt16, v5: Adt69) -> R R { let v4: Str = f8(v3.clone(), f9(v0, v1, v2.clone(), v3, List::::nil()))?; let v5: List = match v2.clone() { - Adt69::C0(_, _, h17, _, _, _, _) => { - h17 + Adt69::C0(_, _, h25, _, _, _, _) => { + h25 } }; let v6: List = { - let a18 = v5; - let a19 = List::cons(v4.clone(), List::::nil()); - append_list(a18, a19) + let a26 = v5; + let a27 = List::cons(v4.clone(), List::::nil()); + append_list(a26, a27) }; Ok(Adt74::C0(v4, Adt69::C0(match v2.clone() { - Adt69::C0(h20, _, _, _, _, _, _) => { - h20 + Adt69::C0(h28, _, _, _, _, _, _) => { + h28 } }, match v2.clone() { - Adt69::C0(_, h21, _, _, _, _, _) => { - h21 + Adt69::C0(_, h29, _, _, _, _, _) => { + h29 } }, v6, match v2.clone() { - Adt69::C0(_, _, _, h22, _, _, _) => { - h22 + Adt69::C0(_, _, _, h30, _, _, _) => { + h30 } }, match v2.clone() { - Adt69::C0(_, _, _, _, h23, _, _) => { - h23 + Adt69::C0(_, _, _, _, h31, _, _) => { + h31 } }, match v2.clone() { - Adt69::C0(_, _, _, _, _, h24, _) => { - h24 + Adt69::C0(_, _, _, _, _, h32, _) => { + h32 } }, match v2 { - Adt69::C0(_, _, _, _, _, _, h25) => { - h25 + Adt69::C0(_, _, _, _, _, _, h33) => { + h33 } }))) } pub fn f2(v0: Adt16, v1: Adt2, v2: Adt69, v3: Str) -> R { let v4: Str = { - let a27 = List::cons(match v0.clone() { - Adt16::C0(_, _, _, h26, _, _, _, _, _, _, _, _, _, _, _, _, _) => { - h26 + let a35 = List::cons(match v0.clone() { + Adt16::C0(_, _, _, h34, _, _, _, _, _, _, _, _, _, _, _, _, _) => { + h34 } }, List::cons(v3, List::::nil())); - let a28 = Str::lit(""); - join(a27, a28) + let a36 = Str::lit(""); + join(a35, a36) }; let v5: List = f10(match v2.clone() { - Adt69::C0(_, _, _, _, _, h29, _) => { - h29 + Adt69::C0(_, _, _, _, _, h37, _) => { + h37 } }); f8(v4.clone(), f9(v0, v1, v2, v4, v5)) } pub fn f3(v0: Adt69, v1: Str) -> List { - let m30 = f11(v0, v1); - match m30 { + let m38 = f11(v0, v1); + match m38 { None => { List::::nil() } @@ -1495,45 +1512,45 @@ pub fn f3(v0: Adt69, v1: Str) -> List { pub fn f4(v0: Adt69, v1: Adt70) -> Adt69 { let v2: List = match v0.clone() { - Adt69::C0(_, _, _, _, _, h31, _) => { - h31 + Adt69::C0(_, _, _, _, _, h39, _) => { + h39 } }; let v3: List = { - let a32 = v2; - let a33 = List::cons(v1, List::::nil()); - append_list(a32, a33) + let a40 = v2; + let a41 = List::cons(v1, List::::nil()); + append_list(a40, a41) }; Adt69::C0(match v0.clone() { - Adt69::C0(h34, _, _, _, _, _, _) => { - h34 + Adt69::C0(h42, _, _, _, _, _, _) => { + h42 } }, match v0.clone() { - Adt69::C0(_, h35, _, _, _, _, _) => { - h35 + Adt69::C0(_, h43, _, _, _, _, _) => { + h43 } }, match v0.clone() { - Adt69::C0(_, _, h36, _, _, _, _) => { - h36 + Adt69::C0(_, _, h44, _, _, _, _) => { + h44 } }, match v0.clone() { - Adt69::C0(_, _, _, h37, _, _, _) => { - h37 + Adt69::C0(_, _, _, h45, _, _, _) => { + h45 } }, match v0.clone() { - Adt69::C0(_, _, _, _, h38, _, _) => { - h38 + Adt69::C0(_, _, _, _, h46, _, _) => { + h46 } }, v3, match v0 { - Adt69::C0(_, _, _, _, _, _, h39) => { - h39 + Adt69::C0(_, _, _, _, _, _, h47) => { + h47 } }) } pub fn f5(v0: Adt0) -> Str { - let m40 = v0; - match m40 { + let m48 = v0; + match m48 { Adt0::C0 => { Str::lit("Unit") } @@ -1550,102 +1567,133 @@ pub fn f5(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + Str::lit("Int") } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - let a41 = List::cons(f12(), List::cons(Str::lit("::ParseIntError"), List::::nil())); - let a42 = Str::lit(""); - join(a41, a42) + Str::lit("Nat") } Adt0::C10 => { - let a43 = List::cons(f12(), List::cons(Str::lit("::FilePath"), List::::nil())); - let a44 = Str::lit(""); - join(a43, a44) - } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r67) => { - let v6 = (*r67).clone(); - let a45 = List::cons(Str::lit("(Option "), List::cons(f5(v6), List::cons(Str::lit(")"), List::::nil()))); - let a46 = Str::lit(""); - join(a45, a46) - } - Adt0::C13(r68, r69) => { - let v7 = (*r68).clone(); - let v8 = (*r69).clone(); - let a47 = List::cons(Str::lit("(Result "), List::cons(f5(v7), List::cons(Str::lit(" "), List::cons(f5(v8), List::cons(Str::lit(")"), List::::nil()))))); - let a48 = Str::lit(""); - join(a47, a48) - } - Adt0::C14(r70) => { - let v9 = (*r70).clone(); - let a49 = List::cons(Str::lit("(List "), List::cons(f5(v9), List::cons(Str::lit(")"), List::::nil()))); + let a49 = List::cons(f12(), List::cons(Str::lit("::ParseIntError"), List::::nil())); let a50 = Str::lit(""); join(a49, a50) } - Adt0::C15(v10) => { - let a53 = List::cons(Str::lit("Tuple"), List::cons({ - let a51 = f13(v10); - let a52 = Str::lit(""); - join(a51, a52) - }, List::::nil())); - let a54 = Str::lit(""); - join(a53, a54) + Adt0::C11 => { + let a51 = List::cons(f12(), List::cons(Str::lit("::FilePath"), List::::nil())); + let a52 = Str::lit(""); + join(a51, a52) } - Adt0::C16(v11) => { - let a57 = List::cons(Str::lit("("), List::cons({ - let a55 = f14(v11); - let a56 = Str::lit(" * "); - join(a55, a56) - }, List::cons(Str::lit(")"), List::::nil()))); - let a58 = Str::lit(""); - join(a57, a58) - } - Adt0::C17(r71, r72, _) => { - let v12 = (*r71).clone(); - let v13 = (*r72).clone(); - let a59 = List::cons(Str::lit("(List Tuple"), List::cons(f15(v12), List::cons(f15(v13), List::cons(Str::lit(")"), List::::nil())))); + Adt0::C12(v6) => { + v6 + } + Adt0::C13(r89) => { + let v7 = (*r89).clone(); + let a55 = { + let a53 = List::cons(Str::lit("(Option "), List::::nil()); + let a54 = List::cons(f5(v7), List::cons(Str::lit(")"), List::::nil())); + append_list(a53, a54) + }; + let a56 = Str::lit(""); + join(a55, a56) + } + Adt0::C14(r90, r91) => { + let v8 = (*r90).clone(); + let v9 = (*r91).clone(); + let a59 = { + let a57 = List::cons(Str::lit("(Result "), List::cons(f5(v8), List::::nil())); + let a58 = List::cons(Str::lit(" "), List::cons(f5(v9), List::cons(Str::lit(")"), List::::nil()))); + append_list(a57, a58) + }; let a60 = Str::lit(""); join(a59, a60) } - Adt0::C18(r73, _) => { - let v15 = (*r73).clone(); - let a61 = List::cons(Str::lit("(List "), List::cons(f5(v15), List::cons(Str::lit(")"), List::::nil()))); - let a62 = Str::lit(""); - join(a61, a62) + Adt0::C15(r92) => { + let v10 = (*r92).clone(); + let a63 = { + let a61 = List::cons(Str::lit("(List "), List::::nil()); + let a62 = List::cons(f5(v10), List::cons(Str::lit(")"), List::::nil())); + append_list(a61, a62) + }; + let a64 = Str::lit(""); + join(a63, a64) } - Adt0::C19(v17, r74) => { - let v18 = (*r74).clone(); - let a65 = List::cons(Str::lit("(Fn ("), List::cons({ - let a63 = f16(v17); - let a64 = Str::lit(" "); - join(a63, a64) - }, List::cons(Str::lit(") "), List::cons(f5(v18), List::cons(Str::lit(")"), List::::nil()))))); - let a66 = Str::lit(""); - join(a65, a66) + Adt0::C16(v11) => { + let a67 = List::cons(Str::lit("Tuple"), List::cons({ + let a65 = f13(v11); + let a66 = Str::lit(""); + join(a65, a66) + }, List::::nil())); + let a68 = Str::lit(""); + join(a67, a68) + } + Adt0::C17(v12) => { + let a73 = { + let a71 = List::cons(Str::lit("("), List::::nil()); + let a72 = List::cons({ + let a69 = f14(v12); + let a70 = Str::lit(" * "); + join(a69, a70) + }, List::cons(Str::lit(")"), List::::nil())); + append_list(a71, a72) + }; + let a74 = Str::lit(""); + join(a73, a74) + } + Adt0::C18(r93, r94, _) => { + let v13 = (*r93).clone(); + let v14 = (*r94).clone(); + let a77 = { + let a75 = List::cons(Str::lit("(List Tuple"), List::cons(f15(v13), List::::nil())); + let a76 = List::cons(f15(v14), List::cons(Str::lit(")"), List::::nil())); + append_list(a75, a76) + }; + let a78 = Str::lit(""); + join(a77, a78) + } + Adt0::C19(r95, _) => { + let v16 = (*r95).clone(); + let a81 = { + let a79 = List::cons(Str::lit("(List "), List::::nil()); + let a80 = List::cons(f5(v16), List::cons(Str::lit(")"), List::::nil())); + append_list(a79, a80) + }; + let a82 = Str::lit(""); + join(a81, a82) + } + Adt0::C20(v18, r96) => { + let v19 = (*r96).clone(); + let a87 = { + let a85 = List::cons(Str::lit("(Fn ("), List::cons({ + let a83 = f16(v18); + let a84 = Str::lit(" "); + join(a83, a84) + }, List::::nil())); + let a86 = List::cons(Str::lit(") "), List::cons(f5(v19), List::cons(Str::lit(")"), List::::nil()))); + append_list(a85, a86) + }; + let a88 = Str::lit(""); + join(a87, a88) } } } -pub fn f6(p77: List, p78: List) -> List { - let m76 = (p77, p78); +pub fn f6(p99: List, p100: List) -> List { + let m98 = (p99, p100); { - let mut m76 = m76; + let mut m98 = m98; loop { let step = { - let (v0, v1) = m76; - let m75 = v0; - match m75.uncons() { + let (v0, v1) = m98; + let m97 = v0; + match m97.uncons() { None => { Err::<(List, List), List>(v1) } @@ -1655,7 +1703,7 @@ pub fn f6(p77: List, p78: List) -> List { } }; match step { - Ok(next) => { m76 = next; } + Ok(next) => { m98 = next; } Err(done) => break done, } } @@ -1664,72 +1712,72 @@ pub fn f6(p77: List, p78: List) -> List { pub fn f7(v0: Adt69, v1: Str) -> Adt69 { let v2: List = match v0.clone() { - Adt69::C0(_, h79, _, _, _, _, _) => { - h79 + Adt69::C0(_, h101, _, _, _, _, _) => { + h101 } }; let v3: List = f18(v2, v1); Adt69::C0(match v0.clone() { - Adt69::C0(h80, _, _, _, _, _, _) => { - h80 + Adt69::C0(h102, _, _, _, _, _, _) => { + h102 } }, v3, match v0.clone() { - Adt69::C0(_, _, h81, _, _, _, _) => { - h81 + Adt69::C0(_, _, h103, _, _, _, _) => { + h103 } }, match v0.clone() { - Adt69::C0(_, _, _, h82, _, _, _) => { - h82 + Adt69::C0(_, _, _, h104, _, _, _) => { + h104 } }, match v0.clone() { - Adt69::C0(_, _, _, _, h83, _, _) => { - h83 + Adt69::C0(_, _, _, _, h105, _, _) => { + h105 } }, match v0.clone() { - Adt69::C0(_, _, _, _, _, h84, _) => { - h84 + Adt69::C0(_, _, _, _, _, h106, _) => { + h106 } }, match v0 { - Adt69::C0(_, _, _, _, _, _, h85) => { - h85 + Adt69::C0(_, _, _, _, _, _, h107) => { + h107 } }) } pub fn f8(v0: Str, v1: List) -> R { let v2: u64 = f19(f20(f21(v1.clone(), v0.clone()))?, 0u64); - let m92 = { - let a88 = { - let a86 = v2; - let a87 = 1u64; - nat_add(a86, a87)? + let m114 = { + let a110 = { + let a108 = v2; + let a109 = 1u64; + nat_add(a108, a109)? }; - let a89 = 4294967296u64; - if nat_lt(a88, a89) { + let a111 = 4294967296u64; + if nat_lt(a110, a111) { Some({ - let a90 = v2; - let a91 = 1u64; - nat_add(a90, a91)? + let a112 = v2; + let a113 = 1u64; + nat_add(a112, a113)? }) } else { None:: } }; - match m92 { + match m114 { None => { - let m98 = f22(f23(f24(1u64, { - let a96 = { - let a94 = { - let a93 = v1.clone(); - length_list(a93) + let m120 = f22(f23(f24(1u64, { + let a118 = { + let a116 = { + let a115 = v1.clone(); + length_list(a115) }; - let a95 = 2u64; - nat_add(a94, a95)? + let a117 = 2u64; + nat_add(a116, a117)? }; - let a97 = 1u64; - nat_sub(a96, a97) + let a119 = 1u64; + nat_sub(a118, a119) })?, v0)?, v1); - match m98 { + match m120 { None => { Ok(Str::lit("")) } @@ -1739,67 +1787,67 @@ pub fn f8(v0: Str, v1: List) -> R { } } Some(v4) => { - let a99 = List::cons(v0, List::cons(f25(v4)?, List::::nil())); - let a100 = Str::lit(""); - Ok(join(a99, a100)) + let a121 = List::cons(v0, List::cons(f25(v4)?, List::::nil())); + let a122 = Str::lit(""); + Ok(join(a121, a122)) } } } pub fn f9(v0: Adt16, v1: Adt2, v2: Adt69, v3: Str, v4: List) -> List { f26({ - let a114 = { - let a112 = { - let a109 = { - let a106 = { - let a103 = f27(f28(match v0.clone() { - Adt16::C0(_, _, _, _, h101, _, _, _, _, _, _, _, _, _, _, _, _) => { - h101 + let a136 = { + let a134 = { + let a131 = { + let a128 = { + let a125 = f27(f28(match v0.clone() { + Adt16::C0(_, _, _, _, h123, _, _, _, _, _, _, _, _, _, _, _, _) => { + h123 } })); - let a104 = match v0 { - Adt16::C0(_, _, _, _, _, _, _, _, h102, _, _, _, _, _, _, _, _) => { - h102 + let a126 = match v0 { + Adt16::C0(_, _, _, _, _, _, _, _, h124, _, _, _, _, _, _, _, _) => { + h124 } }; - append_list(a103, a104) + append_list(a125, a126) }; - let a107 = f29(f30(match v1.clone() { - Adt2::C0(_, h105, _, _) => { - h105 + let a129 = f29(f30(match v1.clone() { + Adt2::C0(_, h127, _, _) => { + h127 } })); - append_list(a106, a107) + append_list(a128, a129) }; - let a110 = match v1 { - Adt2::C0(_, _, _, h108) => { - h108 + let a132 = match v1 { + Adt2::C0(_, _, _, h130) => { + h130 } }; - append_list(a109, a110) + append_list(a131, a132) }; - let a113 = match v2 { - Adt69::C0(_, _, h111, _, _, _, _) => { - h111 + let a135 = match v2 { + Adt69::C0(_, _, h133, _, _, _, _) => { + h133 } }; - append_list(a112, a113) + append_list(a134, a135) }; - let a115 = v4; - append_list(a114, a115) + let a137 = v4; + append_list(a136, a137) }, v3) } pub fn f10(v0: List) -> List { - let m116 = v0; - match m116.uncons() { + let m138 = v0; + match m138.uncons() { None => { List::::nil() } Some((v1, v2)) => { List::cons(match v1 { - Adt70::C0(h117, _, _, _, _, _, _, _, _) => { - h117 + Adt70::C0(h139, _, _, _, _, _, _, _, _) => { + h139 } }, f10(v2)) } @@ -1807,19 +1855,19 @@ pub fn f10(v0: List) -> List { } pub fn f11(v0: Adt69, v1: Str) -> Option> { - let m119 = f31(match v0 { - Adt69::C0(_, _, _, _, _, h118, _) => { - h118 + let m141 = f31(match v0 { + Adt69::C0(_, _, _, _, _, h140, _) => { + h140 } }, v1); - match m119 { + match m141 { None => { None::> } Some(v2) => { Some(match v2 { - Adt70::C0(_, _, _, _, _, h120, _, _, _) => { - h120 + Adt70::C0(_, _, _, _, _, h142, _, _, _) => { + h142 } }) } @@ -1831,8 +1879,8 @@ pub fn f12() -> Str { } pub fn f13(v0: List) -> List { - let m121 = v0; - match m121.uncons() { + let m143 = v0; + match m143.uncons() { None => { List::::nil() } @@ -1843,8 +1891,8 @@ pub fn f13(v0: List) -> List { } pub fn f14(v0: List) -> List { - let m122 = v0; - match m122.uncons() { + let m144 = v0; + match m144.uncons() { None => { List::::nil() } @@ -1855,8 +1903,8 @@ pub fn f14(v0: List) -> List { } pub fn f15(v0: Adt0) -> Str { - let m123 = v0; - match m123 { + let m145 = v0; + match m145 { Adt0::C0 => { Str::lit("Unit") } @@ -1873,92 +1921,107 @@ pub fn f15(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f32() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { + Str::lit("ParseIntError") + } + Adt0::C11 => { Str::lit("FilePath") } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r146) => { - let v6 = (*r146).clone(); - let a124 = List::cons(Str::lit("Option"), List::cons(f15(v6), List::::nil())); - let a125 = Str::lit(""); - join(a124, a125) - } - Adt0::C13(r147, r148) => { - let v7 = (*r147).clone(); - let v8 = (*r148).clone(); - let a126 = List::cons(Str::lit("Result"), List::cons(f15(v7), List::cons(f15(v8), List::::nil()))); - let a127 = Str::lit(""); - join(a126, a127) - } - Adt0::C14(r149) => { - let v9 = (*r149).clone(); - let a128 = List::cons(Str::lit("List"), List::cons(f15(v9), List::::nil())); - let a129 = Str::lit(""); - join(a128, a129) - } - Adt0::C15(v10) => { - let a132 = List::cons(Str::lit("Tuple"), List::cons({ - let a130 = f32(v10); - let a131 = Str::lit(""); - join(a130, a131) - }, List::::nil())); - let a133 = Str::lit(""); - join(a132, a133) + Adt0::C12(v6) => { + v6 + } + Adt0::C13(r174) => { + let v7 = (*r174).clone(); + let a146 = List::cons(Str::lit("Option"), List::cons(f15(v7), List::::nil())); + let a147 = Str::lit(""); + join(a146, a147) + } + Adt0::C14(r175, r176) => { + let v8 = (*r175).clone(); + let v9 = (*r176).clone(); + let a150 = { + let a148 = List::cons(Str::lit("Result"), List::::nil()); + let a149 = List::cons(f15(v8), List::cons(f15(v9), List::::nil())); + append_list(a148, a149) + }; + let a151 = Str::lit(""); + join(a150, a151) + } + Adt0::C15(r177) => { + let v10 = (*r177).clone(); + let a152 = List::cons(Str::lit("List"), List::cons(f15(v10), List::::nil())); + let a153 = Str::lit(""); + join(a152, a153) } Adt0::C16(v11) => { - let a136 = List::cons(Str::lit("Pair"), List::cons({ - let a134 = f33(v11); - let a135 = Str::lit(""); - join(a134, a135) + let a156 = List::cons(Str::lit("Tuple"), List::cons({ + let a154 = f33(v11); + let a155 = Str::lit(""); + join(a154, a155) }, List::::nil())); - let a137 = Str::lit(""); - join(a136, a137) - } - Adt0::C17(r150, r151, _) => { - let v12 = (*r150).clone(); - let v13 = (*r151).clone(); - let a138 = List::cons(Str::lit("ListTuple"), List::cons(f15(v12), List::cons(f15(v13), List::::nil()))); - let a139 = Str::lit(""); - join(a138, a139) - } - Adt0::C18(r152, _) => { - let v15 = (*r152).clone(); - let a140 = List::cons(Str::lit("List"), List::cons(f15(v15), List::::nil())); - let a141 = Str::lit(""); - join(a140, a141) - } - Adt0::C19(v17, r153) => { - let v18 = (*r153).clone(); - let a144 = List::cons(Str::lit("Fn"), List::cons({ - let a142 = f34(v17); - let a143 = Str::lit(""); - join(a142, a143) - }, List::cons(Str::lit("To"), List::cons(f15(v18), List::::nil())))); - let a145 = Str::lit(""); - join(a144, a145) + let a157 = Str::lit(""); + join(a156, a157) + } + Adt0::C17(v12) => { + let a160 = List::cons(Str::lit("Pair"), List::cons({ + let a158 = f34(v12); + let a159 = Str::lit(""); + join(a158, a159) + }, List::::nil())); + let a161 = Str::lit(""); + join(a160, a161) + } + Adt0::C18(r178, r179, _) => { + let v13 = (*r178).clone(); + let v14 = (*r179).clone(); + let a164 = { + let a162 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a163 = List::cons(f15(v13), List::cons(f15(v14), List::::nil())); + append_list(a162, a163) + }; + let a165 = Str::lit(""); + join(a164, a165) + } + Adt0::C19(r180, _) => { + let v16 = (*r180).clone(); + let a166 = List::cons(Str::lit("List"), List::cons(f15(v16), List::::nil())); + let a167 = Str::lit(""); + join(a166, a167) + } + Adt0::C20(v18, r181) => { + let v19 = (*r181).clone(); + let a172 = { + let a170 = List::cons(Str::lit("Fn"), List::cons({ + let a168 = f35(v18); + let a169 = Str::lit(""); + join(a168, a169) + }, List::::nil())); + let a171 = List::cons(Str::lit("To"), List::cons(f15(v19), List::::nil())); + append_list(a170, a171) + }; + let a173 = Str::lit(""); + join(a172, a173) } } } pub fn f16(v0: List) -> List { - let m154 = v0; - match m154.uncons() { + let m182 = v0; + match m182.uncons() { None => { List::::nil() } @@ -1969,23 +2032,23 @@ pub fn f16(v0: List) -> List { } pub fn f17(v0: List, v1: Str) -> List { - let m155 = v0; - match m155.uncons() { + let m183 = v0; + match m183.uncons() { None => { List::cons(v1, List::::nil()) } Some((v2, v3)) => { - let a156 = v1.clone(); - let a157 = v2.clone(); - if equal(a156, a157) { + let a184 = v1.clone(); + let a185 = v2.clone(); + if equal(a184, a185) { List::cons(v2, v3) } else { - let m160 = { - let a158 = v1.clone(); - let a159 = v2.clone(); - compare(a158, a159) + let m188 = { + let a186 = v1.clone(); + let a187 = v2.clone(); + compare(a186, a187) }; - if match m160 { + if match m188 { Ordering::Less => { true } @@ -2006,23 +2069,23 @@ pub fn f17(v0: List, v1: Str) -> List { } pub fn f18(v0: List, v1: Str) -> List { - let m161 = v0; - match m161.uncons() { + let m189 = v0; + match m189.uncons() { None => { List::cons(v1, List::::nil()) } Some((v2, v3)) => { - let a162 = v1.clone(); - let a163 = v2.clone(); - if equal(a162, a163) { + let a190 = v1.clone(); + let a191 = v2.clone(); + if equal(a190, a191) { List::cons(v2, v3) } else { - let m166 = { - let a164 = v1.clone(); - let a165 = v2.clone(); - compare(a164, a165) + let m194 = { + let a192 = v1.clone(); + let a193 = v2.clone(); + compare(a192, a193) }; - if match m166 { + if match m194 { Ordering::Less => { true } @@ -2042,23 +2105,23 @@ pub fn f18(v0: List, v1: Str) -> List { } } -pub fn f19(p171: List, p172: u64) -> u64 { - let m170 = (p171, p172); +pub fn f19(p199: List, p200: u64) -> u64 { + let m198 = (p199, p200); { - let mut m170 = m170; + let mut m198 = m198; loop { let step = { - let (v0, v1) = m170; - let m167 = v0; - match m167.uncons() { + let (v0, v1) = m198; + let m195 = v0; + match m195.uncons() { None => { Err::<(List, u64), u64>(v1) } Some((v2, v3)) => { Ok::<(List, u64), u64>((v3, { - let a168 = v1; - let a169 = v2; - if nat_le(a168, a169) { + let a196 = v1; + let a197 = v2; + if nat_le(a196, a197) { v2 } else { v1 @@ -2068,7 +2131,7 @@ pub fn f19(p171: List, p172: u64) -> u64 { } }; match step { - Ok(next) => { m170 = next; } + Ok(next) => { m198 = next; } Err(done) => break done, } } @@ -2076,14 +2139,14 @@ pub fn f19(p171: List, p172: u64) -> u64 { } pub fn f20(v0: List) -> R> { - let m173 = v0; - match m173.uncons() { + let m201 = v0; + match m201.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { - let m174 = f35(v1)?; - match m174 { + let m202 = f36(v1)?; + match m202 { None => { f20(v2) } @@ -2096,14 +2159,14 @@ pub fn f20(v0: List) -> R> { } pub fn f21(v0: List, v1: Str) -> List { - let m175 = v0; - match m175.uncons() { + let m203 = v0; + match m203.uncons() { None => { List::::nil() } Some((v2, v3)) => { - let m176 = f36(v2, v1.clone()); - match m176 { + let m204 = f37(v2, v1.clone()); + match m204 { None => { f21(v3, v1) } @@ -2115,21 +2178,21 @@ pub fn f21(v0: List, v1: Str) -> List { } } -pub fn f22(p180: List, v1: List) -> Option { - let m179 = p180; +pub fn f22(p208: List, v1: List) -> Option { + let m207 = p208; { - let mut m179 = m179; + let mut m207 = m207; loop { let step = { - let v0 = m179; - let m177 = v0; - match m177.uncons() { + let v0 = m207; + let m205 = v0; + match m205.uncons() { None => { Err::, Option>(None::) } Some((v2, v3)) => { - let a178 = f37(v1.clone(), v2.clone()); - if bool_not(a178) { + let a206 = f38(v1.clone(), v2.clone()); + if bool_not(a206) { Err::, Option>(Some(v2)) } else { Ok::, Option>(v3) @@ -2138,7 +2201,7 @@ pub fn f22(p180: List, v1: List) -> Option { } }; match step { - Ok(next) => { m179 = next; } + Ok(next) => { m207 = next; } Err(done) => break done, } } @@ -2146,51 +2209,51 @@ pub fn f22(p180: List, v1: List) -> Option { } pub fn f23(v0: List, v1: Str) -> R> { - let m181 = v0; - match m181.uncons() { + let m209 = v0; + match m209.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons({ - let a182 = List::cons(v1.clone(), List::cons(f25(v2)?, List::::nil())); - let a183 = Str::lit(""); - join(a182, a183) + let a210 = List::cons(v1.clone(), List::cons(f25(v2)?, List::::nil())); + let a211 = Str::lit(""); + join(a210, a211) }, f23(v3, v1)?)) } } } pub fn f24(v0: u64, v1: u64) -> R> { - let m184 = v1; - if m184 == 0 { + let m212 = v1; + if m212 == 0 { Ok(List::::nil()) } else { - let v2 = m184 - 1; + let v2 = m212 - 1; Ok(List::cons(v0, f24({ - let a185 = v0; - let a186 = 1u64; - nat_add(a185, a186)? + let a213 = v0; + let a214 = 1u64; + nat_add(a213, a214)? }, v2)?)) } } pub fn f25(v0: u64) -> R { - Ok(f38({ - let a187 = v0; - let a188 = 1u64; - nat_add(a187, a188)? + Ok(f39({ + let a215 = v0; + let a216 = 1u64; + nat_add(a215, a216)? }, v0)) } pub fn f26(v0: List, v1: Str) -> List { - let m189 = v0; - match m189.uncons() { + let m217 = v0; + match m217.uncons() { None => { List::::nil() } Some((v2, v3)) => { - if f39(v2.clone(), v1.clone()) { + if f40(v2.clone(), v1.clone()) { List::cons(v2, f26(v3, v1)) } else { f26(v3, v1) @@ -2200,19 +2263,19 @@ pub fn f26(v0: List, v1: Str) -> List { } pub fn f27(v0: List<(Str, Adt0)>) -> List { - let m190 = v0; - match m190.uncons() { + let m218 = v0; + match m218.uncons() { None => { List::::nil() } Some((v1, v2)) => { let v3: Str = { - let (h191, _) = v1; - h191 + let (h219, _) = v1; + h219 }; let _: Adt0 = { - let (_, h192) = v1; - h192 + let (_, h220) = v1; + h220 }; List::cons(v3, f27(v2)) } @@ -2220,15 +2283,15 @@ pub fn f27(v0: List<(Str, Adt0)>) -> List { } pub fn f28(v0: List) -> List<(Str, Adt0)> { - let m193 = v0; - match m193.uncons() { + let m221 = v0; + match m221.uncons() { None => { List::<(Str, Adt0)>::nil() } Some((v1, v2)) => { List::cons(match v1 { - Adt17::C0(_, h194) => { - h194 + Adt17::C0(_, h222) => { + h222 } }, f28(v2)) } @@ -2236,15 +2299,15 @@ pub fn f28(v0: List) -> List<(Str, Adt0)> { } pub fn f29(v0: List) -> List { - let m195 = v0; - match m195.uncons() { + let m223 = v0; + match m223.uncons() { None => { List::::nil() } Some((v1, v2)) => { List::cons(match v1 { - Adt14::C0(h196, _, _) => { - h196 + Adt14::C0(h224, _, _) => { + h224 } }, f29(v2)) } @@ -2252,41 +2315,41 @@ pub fn f29(v0: List) -> List { } pub fn f30(v0: List) -> List { - let m197 = v0; - match m197.uncons() { + let m225 = v0; + match m225.uncons() { None => { List::::nil() } Some((v1, v2)) => { List::cons(match v1 { - Adt13::C0(_, h198) => { - h198 + Adt13::C0(_, h226) => { + h226 } }, f30(v2)) } } } -pub fn f31(p204: List, v1: Str) -> Option { - let m203 = p204; +pub fn f31(p232: List, v1: Str) -> Option { + let m231 = p232; { - let mut m203 = m203; + let mut m231 = m231; loop { let step = { - let v0 = m203; - let m199 = v0; - match m199.uncons() { + let v0 = m231; + let m227 = v0; + match m227.uncons() { None => { Err::, Option>(None::) } Some((v2, v3)) => { - let a201 = match v2.clone() { - Adt70::C0(h200, _, _, _, _, _, _, _, _) => { - h200 + let a229 = match v2.clone() { + Adt70::C0(h228, _, _, _, _, _, _, _, _) => { + h228 } }; - let a202 = v1.clone(); - if equal(a201, a202) { + let a230 = v1.clone(); + if equal(a229, a230) { Err::, Option>(Some(v2)) } else { Ok::, Option>(v3) @@ -2295,52 +2358,56 @@ pub fn f31(p204: List, v1: Str) -> Option { } }; match step { - Ok(next) => { m203 = next; } + Ok(next) => { m231 = next; } Err(done) => break done, } } } } -pub fn f32(v0: List) -> List { - let m205 = v0; - match m205.uncons() { +pub fn f32() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f33(v0: List) -> List { + let m233 = v0; + match m233.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f15(v1), f32(v2)) + List::cons(f15(v1), f33(v2)) } } } -pub fn f33(v0: List) -> List { - let m206 = v0; - match m206.uncons() { +pub fn f34(v0: List) -> List { + let m234 = v0; + match m234.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f15(v1), f33(v2)) + List::cons(f15(v1), f34(v2)) } } } -pub fn f34(v0: List) -> List { - let m207 = v0; - match m207.uncons() { +pub fn f35(v0: List) -> List { + let m235 = v0; + match m235.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f15(v1), f34(v2)) + List::cons(f15(v1), f35(v2)) } } } -pub fn f35(v0: Str) -> R> { - let m208 = f40(v0, 4294967295u64)?; - match m208 { +pub fn f36(v0: Str) -> R> { + let m236 = f41(v0, 4294967295u64)?; + match m236 { Ok(v1) => { Ok(Some(v1)) } @@ -2350,44 +2417,44 @@ pub fn f35(v0: Str) -> R> { } } -pub fn f36(v0: Str, v1: Str) -> Option { +pub fn f37(v0: Str, v1: Str) -> Option { let v2: Bytes = { - let a209 = v0; - utf8_encode(a209) + let a237 = v0; + utf8_encode(a237) }; let v3: Bytes = { - let a210 = v1; - utf8_encode(a210) + let a238 = v1; + utf8_encode(a238) }; - if f41(v2.clone(), 0u64, v3.clone()) { - Some(f42(v2.clone(), { - let a211 = v3; - length_bytes(a211) + if f42(v2.clone(), 0u64, v3.clone()) { + Some(f43(v2.clone(), { + let a239 = v3; + length_bytes(a239) }, { - let a212 = v2; - length_bytes(a212) + let a240 = v2; + length_bytes(a240) })) } else { None:: } } -pub fn f37(p217: List, v1: Str) -> bool { - let m216 = p217; +pub fn f38(p245: List, v1: Str) -> bool { + let m244 = p245; { - let mut m216 = m216; + let mut m244 = m244; loop { let step = { - let v0 = m216; - let m213 = v0; - match m213.uncons() { + let v0 = m244; + let m241 = v0; + match m241.uncons() { None => { Err::, bool>(false) } Some((v2, v3)) => { - let a214 = v2; - let a215 = v1.clone(); - if equal(a214, a215) { + let a242 = v2; + let a243 = v1.clone(); + if equal(a242, a243) { Err::, bool>(true) } else { Ok::, bool>(v3) @@ -2396,124 +2463,124 @@ pub fn f37(p217: List, v1: Str) -> bool { } }; match step { - Ok(next) => { m216 = next; } + Ok(next) => { m244 = next; } Err(done) => break done, } } } } -pub fn f38(v0: u64, v1: u64) -> Str { - let m218 = v0; - if m218 == 0 { +pub fn f39(v0: u64, v1: u64) -> Str { + let m246 = v0; + if m246 == 0 { Str::lit("") } else { - let v2 = m218 - 1; - let a219 = v1; - let a220 = 10u64; - if nat_lt(a219, a220) { - f43(v1) + let v2 = m246 - 1; + let a247 = v1; + let a248 = 10u64; + if nat_lt(a247, a248) { + f44(v1) } else { - let a227 = List::cons(f38(v2, { - let a221 = v1; - let a222 = 10u64; - let a223 = 0u64; - nat_quot(a221, a222, a223) - }), List::cons(f43({ - let a224 = v1; - let a225 = 10u64; - let a226 = 0u64; - nat_rem(a224, a225, a226) + let a255 = List::cons(f39(v2, { + let a249 = v1; + let a250 = 10u64; + let a251 = 0u64; + nat_quot(a249, a250, a251) + }), List::cons(f44({ + let a252 = v1; + let a253 = 10u64; + let a254 = 0u64; + nat_rem(a252, a253, a254) }), List::::nil())); - let a228 = Str::lit(""); - join(a227, a228) + let a256 = Str::lit(""); + join(a255, a256) } } } -pub fn f39(v0: Str, v1: Str) -> bool { - f41({ - let a229 = v0; - utf8_encode(a229) +pub fn f40(v0: Str, v1: Str) -> bool { + f42({ + let a257 = v0; + utf8_encode(a257) }, 0u64, { - let a230 = v1; - utf8_encode(a230) + let a258 = v1; + utf8_encode(a258) }) } -pub fn f40(v0: Str, v1: u64) -> R> { +pub fn f41(v0: Str, v1: u64) -> R> { let v2: Bytes = { - let a231 = v0; - utf8_encode(a231) + let a259 = v0; + utf8_encode(a259) }; let v3: u64 = { - let a232 = v2.clone(); - length_bytes(a232) + let a260 = v2.clone(); + length_bytes(a260) }; - let a233 = v3; - let a234 = 0u64; - if nat_eq(a233, a234) { + let a261 = v3; + let a262 = 0u64; + if nat_eq(a261, a262) { Ok(Err::(Adt75::C0)) } else { - let a235 = f44(v2.clone(), 0u64)?; - let a236 = 43u64; - if nat_eq(a235, a236) { - let a237 = v3; - let a238 = 1u64; - if nat_eq(a237, a238) { + let a263 = f45(v2.clone(), 0u64)?; + let a264 = 43u64; + if nat_eq(a263, a264) { + let a265 = v3; + let a266 = 1u64; + if nat_eq(a265, a266) { Ok(Err::(Adt75::C1)) } else { - f45(v3, v2, 1u64, 0u64, v1) + f46(v3, v2, 1u64, 0u64, v1) } } else { - f45(v3, v2, 0u64, 0u64, v1) + f46(v3, v2, 0u64, 0u64, v1) } } } -pub fn f41(v0: Bytes, v1: u64, v2: Bytes) -> bool { - let m243 = { - let a240 = v0; - let a241 = v1; - let a242 = { - let a239 = v2.clone(); - length_bytes(a239) +pub fn f42(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m271 = { + let a268 = v0; + let a269 = v1; + let a270 = { + let a267 = v2.clone(); + length_bytes(a267) }; - slice_bytes(a240, a241, a242) + slice_bytes(a268, a269, a270) }; - match m243 { + match m271 { None => { false } Some(v3) => { - let a244 = v3; - let a245 = v2; - equal(a244, a245) + let a272 = v3; + let a273 = v2; + equal(a272, a273) } } } -pub fn f42(v0: Bytes, v1: u64, v2: u64) -> Str { - let m251 = { - let a248 = v0; - let a249 = v1; - let a250 = { - let a246 = v2; - let a247 = v1; - nat_sub(a246, a247) +pub fn f43(v0: Bytes, v1: u64, v2: u64) -> Str { + let m279 = { + let a276 = v0; + let a277 = v1; + let a278 = { + let a274 = v2; + let a275 = v1; + nat_sub(a274, a275) }; - slice_bytes(a248, a249, a250) + slice_bytes(a276, a277, a278) }; - match m251 { + match m279 { None => { Str::lit("") } Some(v3) => { - let m253 = { - let a252 = v3; - utf8_decode(a252) + let m281 = { + let a280 = v3; + utf8_decode(a280) }; - match m253 { + match m281 { None => { Str::lit("") } @@ -2525,50 +2592,50 @@ pub fn f42(v0: Bytes, v1: u64, v2: u64) -> Str { } } -pub fn f43(v0: u64) -> Str { - let a254 = v0; - let a255 = 0u64; - if nat_eq(a254, a255) { +pub fn f44(v0: u64) -> Str { + let a282 = v0; + let a283 = 0u64; + if nat_eq(a282, a283) { Str::lit("0") } else { - let a256 = v0; - let a257 = 1u64; - if nat_eq(a256, a257) { + let a284 = v0; + let a285 = 1u64; + if nat_eq(a284, a285) { Str::lit("1") } else { - let a258 = v0; - let a259 = 2u64; - if nat_eq(a258, a259) { + let a286 = v0; + let a287 = 2u64; + if nat_eq(a286, a287) { Str::lit("2") } else { - let a260 = v0; - let a261 = 3u64; - if nat_eq(a260, a261) { + let a288 = v0; + let a289 = 3u64; + if nat_eq(a288, a289) { Str::lit("3") } else { - let a262 = v0; - let a263 = 4u64; - if nat_eq(a262, a263) { + let a290 = v0; + let a291 = 4u64; + if nat_eq(a290, a291) { Str::lit("4") } else { - let a264 = v0; - let a265 = 5u64; - if nat_eq(a264, a265) { + let a292 = v0; + let a293 = 5u64; + if nat_eq(a292, a293) { Str::lit("5") } else { - let a266 = v0; - let a267 = 6u64; - if nat_eq(a266, a267) { + let a294 = v0; + let a295 = 6u64; + if nat_eq(a294, a295) { Str::lit("6") } else { - let a268 = v0; - let a269 = 7u64; - if nat_eq(a268, a269) { + let a296 = v0; + let a297 = 7u64; + if nat_eq(a296, a297) { Str::lit("7") } else { - let a270 = v0; - let a271 = 8u64; - if nat_eq(a270, a271) { + let a298 = v0; + let a299 = 8u64; + if nat_eq(a298, a299) { Str::lit("8") } else { Str::lit("9") @@ -2583,197 +2650,197 @@ pub fn f43(v0: u64) -> Str { } } -pub fn f44(v0: Bytes, v1: u64) -> R { - let m274 = { - let a272 = v0; - let a273 = v1; - index_bytes(a272, a273) +pub fn f45(v0: Bytes, v1: u64) -> R { + let m302 = { + let a300 = v0; + let a301 = v1; + index_bytes(a300, a301) }; - match m274 { + match m302 { None => { Ok(256u64) } Some(v2) => { let v3: u8 = v2; - let a319 = { - let a295 = { - let a283 = { - let a277 = { - let a275 = v3; - let a276 = 128u8; - fixed_u8::bit_and(a275, a276) + let a347 = { + let a323 = { + let a311 = { + let a305 = { + let a303 = v3; + let a304 = 128u8; + fixed_u8::bit_and(a303, a304) }; - let a278 = 128u8; - if equal(a277, a278) { + let a306 = 128u8; + if equal(a305, a306) { 128u64 } else { 0u64 } }; - let a284 = { - let a281 = { - let a279 = v3; - let a280 = 64u8; - fixed_u8::bit_and(a279, a280) + let a312 = { + let a309 = { + let a307 = v3; + let a308 = 64u8; + fixed_u8::bit_and(a307, a308) }; - let a282 = 64u8; - if equal(a281, a282) { + let a310 = 64u8; + if equal(a309, a310) { 64u64 } else { 0u64 } }; - nat_add(a283, a284)? + nat_add(a311, a312)? }; - let a296 = { - let a293 = { - let a287 = { - let a285 = v3; - let a286 = 32u8; - fixed_u8::bit_and(a285, a286) + let a324 = { + let a321 = { + let a315 = { + let a313 = v3; + let a314 = 32u8; + fixed_u8::bit_and(a313, a314) }; - let a288 = 32u8; - if equal(a287, a288) { + let a316 = 32u8; + if equal(a315, a316) { 32u64 } else { 0u64 } }; - let a294 = { - let a291 = { - let a289 = v3; - let a290 = 16u8; - fixed_u8::bit_and(a289, a290) + let a322 = { + let a319 = { + let a317 = v3; + let a318 = 16u8; + fixed_u8::bit_and(a317, a318) }; - let a292 = 16u8; - if equal(a291, a292) { + let a320 = 16u8; + if equal(a319, a320) { 16u64 } else { 0u64 } }; - nat_add(a293, a294)? + nat_add(a321, a322)? }; - nat_add(a295, a296)? + nat_add(a323, a324)? }; - let a320 = { - let a317 = { - let a305 = { - let a299 = { - let a297 = v3; - let a298 = 8u8; - fixed_u8::bit_and(a297, a298) + let a348 = { + let a345 = { + let a333 = { + let a327 = { + let a325 = v3; + let a326 = 8u8; + fixed_u8::bit_and(a325, a326) }; - let a300 = 8u8; - if equal(a299, a300) { + let a328 = 8u8; + if equal(a327, a328) { 8u64 } else { 0u64 } }; - let a306 = { - let a303 = { - let a301 = v3; - let a302 = 4u8; - fixed_u8::bit_and(a301, a302) + let a334 = { + let a331 = { + let a329 = v3; + let a330 = 4u8; + fixed_u8::bit_and(a329, a330) }; - let a304 = 4u8; - if equal(a303, a304) { + let a332 = 4u8; + if equal(a331, a332) { 4u64 } else { 0u64 } }; - nat_add(a305, a306)? + nat_add(a333, a334)? }; - let a318 = { - let a315 = { - let a309 = { - let a307 = v3; - let a308 = 2u8; - fixed_u8::bit_and(a307, a308) + let a346 = { + let a343 = { + let a337 = { + let a335 = v3; + let a336 = 2u8; + fixed_u8::bit_and(a335, a336) }; - let a310 = 2u8; - if equal(a309, a310) { + let a338 = 2u8; + if equal(a337, a338) { 2u64 } else { 0u64 } }; - let a316 = { - let a313 = { - let a311 = v3; - let a312 = 1u8; - fixed_u8::bit_and(a311, a312) + let a344 = { + let a341 = { + let a339 = v3; + let a340 = 1u8; + fixed_u8::bit_and(a339, a340) }; - let a314 = 1u8; - if equal(a313, a314) { + let a342 = 1u8; + if equal(a341, a342) { 1u64 } else { 0u64 } }; - nat_add(a315, a316)? + nat_add(a343, a344)? }; - nat_add(a317, a318)? + nat_add(a345, a346)? }; - nat_add(a319, a320) + nat_add(a347, a348) } } } -pub fn f45(p340: u64, v1: Bytes, p341: u64, p342: u64, v4: u64) -> R> { - let m339 = (p340, (p341, p342)); +pub fn f46(p368: u64, v1: Bytes, p369: u64, p370: u64, v4: u64) -> R> { + let m367 = (p368, (p369, p370)); { - let mut m339 = m339; + let mut m367 = m367; loop { let step = { - let (v0, (v2, v3)) = m339; - let m321 = v0; - if m321 == 0 { + let (v0, (v2, v3)) = m367; + let m349 = v0; + if m349 == 0 { Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) } else { - let v5 = m321 - 1; - let a323 = { - let a322 = v1.clone(); - length_bytes(a322) + let v5 = m349 - 1; + let a351 = { + let a350 = v1.clone(); + length_bytes(a350) }; - let a324 = v2; - if nat_le(a323, a324) { + let a352 = v2; + if nat_le(a351, a352) { Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) } else { - let v6: u64 = f44(v1.clone(), v2)?; - let a325 = 48u64; - let a326 = v6; - if if nat_le(a325, a326) { - let a327 = v6; - let a328 = 57u64; - nat_le(a327, a328) + let v6: u64 = f45(v1.clone(), v2)?; + let a353 = 48u64; + let a354 = v6; + if if nat_le(a353, a354) { + let a355 = v6; + let a356 = 57u64; + nat_le(a355, a356) } else { false } { let v7: u64 = { - let a333 = { - let a329 = v3; - let a330 = 10u64; - nat_mul(a329, a330)? + let a361 = { + let a357 = v3; + let a358 = 10u64; + nat_mul(a357, a358)? }; - let a334 = { - let a331 = v6; - let a332 = 48u64; - nat_sub(a331, a332) + let a362 = { + let a359 = v6; + let a360 = 48u64; + nat_sub(a359, a360) }; - nat_add(a333, a334)? + nat_add(a361, a362)? }; - let a335 = v4; - let a336 = v7; - if nat_lt(a335, a336) { + let a363 = v4; + let a364 = v7; + if nat_lt(a363, a364) { Err::<(u64, (u64, u64)), R>>(Ok(Err::(Adt75::C2))) } else { Ok::<(u64, (u64, u64)), R>>((v5, ({ - let a337 = v2; - let a338 = 1u64; - nat_add(a337, a338)? + let a365 = v2; + let a366 = 1u64; + nat_add(a365, a366)? }, v7))) } } else { @@ -2783,7 +2850,7 @@ pub fn f45(p340: u64, v1: Bytes, p341: u64, p342: u64, v4: u64) -> R { m339 = next; } + Ok(next) => { m367 = next; } Err(done) => break done, } } diff --git a/crates/certified/roots/uorust_certified_is_enum_or_bool.rs b/crates/certified/roots/uorust_certified_is_enum_or_bool.rs index 1cf114aa..982f4d78 100644 --- a/crates/certified/roots/uorust_certified_is_enum_or_bool.rs +++ b/crates/certified/roots/uorust_certified_is_enum_or_bool.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -891,7 +892,7 @@ pub enum Adt2 { #[derive(Clone)] pub enum Adt3 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -975,7 +976,7 @@ pub fn f0(v0: Adt0, v1: Adt2) -> bool { Adt0::C5(_) => { false } - Adt0::C6 => { + Adt0::C6(_) => { false } Adt0::C7 => { @@ -990,7 +991,10 @@ pub fn f0(v0: Adt0, v1: Adt2) -> bool { Adt0::C10 => { false } - Adt0::C11(v6) => { + Adt0::C11 => { + false + } + Adt0::C12(v7) => { f1({ let m4 = match v1 { Adt2::C0(h3, _, _, _) => { @@ -998,19 +1002,16 @@ pub fn f0(v0: Adt0, v1: Adt2) -> bool { } }; match m4 { - Adt3::C0(h2, _, _, _, _, _, _, _, _, _, _, _) => { + Adt3::C0(h2, _, _, _, _, _, _, _, _, _, _, _, _) => { h2 } } - }, v6) - } - Adt0::C12(_) => { - false + }, v7) } - Adt0::C13(_, _) => { + Adt0::C13(_) => { false } - Adt0::C14(_) => { + Adt0::C14(_, _) => { false } Adt0::C15(_) => { @@ -1019,15 +1020,18 @@ pub fn f0(v0: Adt0, v1: Adt2) -> bool { Adt0::C16(_) => { false } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { false } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { false } Adt0::C19(_, _) => { false } + Adt0::C20(_, _) => { + false + } } } diff --git a/crates/certified/roots/uorust_certified_is_lifetime.rs b/crates/certified/roots/uorust_certified_is_lifetime.rs new file mode 100644 index 00000000..0e6c04b9 --- /dev/null +++ b/crates/certified/roots/uorust_certified_is_lifetime.rs @@ -0,0 +1,1456 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn f0(v0: Str) -> R { + let m1 = f1(f2(v0)?, Str::lit("'")); + match m1 { + None => { + Ok(false) + } + Some(v1) => { + let a2 = f3(v1, Str::lit("'"))?; + Ok(bool_not(a2)) + } + } +} + +pub fn f1(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a3 = v0; + utf8_encode(a3) + }; + let v3: Bytes = { + let a4 = v1; + utf8_encode(a4) + }; + if f4(v2.clone(), 0u64, v3.clone()) { + Some(f5(v2.clone(), { + let a5 = v3; + length_bytes(a5) + }, { + let a6 = v2; + length_bytes(a6) + })) + } else { + None:: + } +} + +pub fn f2(v0: Str) -> R { + f6(f7(v0)?) +} + +pub fn f3(v0: Str, v1: Str) -> R { + let m7 = f8(v0, v1)?; + match m7 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f4(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m12 = { + let a9 = v0; + let a10 = v1; + let a11 = { + let a8 = v2.clone(); + length_bytes(a8) + }; + slice_bytes(a9, a10, a11) + }; + match m12 { + None => { + false + } + Some(v3) => { + let a13 = v3; + let a14 = v2; + equal(a13, a14) + } + } +} + +pub fn f5(v0: Bytes, v1: u64, v2: u64) -> Str { + let m20 = { + let a17 = v0; + let a18 = v1; + let a19 = { + let a15 = v2; + let a16 = v1; + nat_sub(a15, a16) + }; + slice_bytes(a17, a18, a19) + }; + match m20 { + None => { + Str::lit("") + } + Some(v3) => { + let m22 = { + let a21 = v3; + utf8_decode(a21) + }; + match m22 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f6(v0: Str) -> R { + let v1: Bytes = { + let a23 = v0; + utf8_encode(a23) + }; + let v2: u64 = { + let a24 = v1.clone(); + length_bytes(a24) + }; + Ok(f5(v1.clone(), 0u64, f9(v2, v1, v2)?)) +} + +pub fn f7(v0: Str) -> R { + let v1: Bytes = { + let a25 = v0; + utf8_encode(a25) + }; + let v2: u64 = { + let a26 = v1.clone(); + length_bytes(a26) + }; + Ok(f5(v1.clone(), f10(v2, v1, 0u64)?, v2)) +} + +pub fn f8(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a27 = v0; + utf8_encode(a27) + }; + f11({ + let a29 = { + let a28 = v2.clone(); + length_bytes(a28) + }; + let a30 = 1u64; + nat_add(a29, a30)? + }, v2, { + let a31 = v1; + utf8_encode(a31) + }, 0u64) +} + +pub fn f9(p38: u64, v1: Bytes, p39: u64) -> R { + let m37 = (p38, p39); + { + let mut m37 = m37; + loop { + let step = { + let (v0, v2) = m37; + let m32 = v0; + if m32 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m32 - 1; + let v4: u64 = f12(v1.clone(), v2)?; + let a33 = v4; + let a34 = 0u64; + if nat_eq(a33, a34) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a35 = v2; + let a36 = v4; + nat_sub(a35, a36) + })) + } + } + }; + match step { + Ok(next) => { m37 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f10(p46: u64, v1: Bytes, p47: u64) -> R { + let m45 = (p46, p47); + { + let mut m45 = m45; + loop { + let step = { + let (v0, v2) = m45; + let m40 = v0; + if m40 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m40 - 1; + let v4: u64 = f13(v1.clone(), v2)?; + let a41 = v4; + let a42 = 0u64; + if nat_eq(a41, a42) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a43 = v2; + let a44 = v4; + nat_add(a43, a44)? + })) + } + } + }; + match step { + Ok(next) => { m45 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f11(p58: u64, v1: Bytes, v2: Bytes, p59: u64) -> R> { + let m57 = (p58, p59); + { + let mut m57 = m57; + loop { + let step = { + let (v0, v3) = m57; + let m48 = v0; + if m48 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m48 - 1; + let a53 = { + let a49 = v1.clone(); + length_bytes(a49) + }; + let a54 = { + let a51 = v3; + let a52 = { + let a50 = v2.clone(); + length_bytes(a50) + }; + nat_add(a51, a52)? + }; + if nat_lt(a53, a54) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f4(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a55 = v3; + let a56 = 1u64; + nat_add(a55, a56)? + })) + } + } + } + }; + match step { + Ok(next) => { m57 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f12(v0: Bytes, v1: u64) -> R { + let a60 = v1; + let a61 = 0u64; + if nat_eq(a60, a61) { + Ok(0u64) + } else { + if f14(f15(v0.clone(), { + let a62 = v1; + let a63 = 1u64; + nat_sub(a62, a63) + })?) { + Ok(1u64) + } else { + let a64 = 2u64; + let a65 = v1; + if if nat_le(a64, a65) { + let a68 = f13(v0.clone(), { + let a66 = v1; + let a67 = 2u64; + nat_sub(a66, a67) + })?; + let a69 = 2u64; + nat_eq(a68, a69) + } else { + false + } { + Ok(2u64) + } else { + let a70 = 3u64; + let a71 = v1; + if if nat_le(a70, a71) { + let a74 = f13(v0, { + let a72 = v1; + let a73 = 3u64; + nat_sub(a72, a73) + })?; + let a75 = 3u64; + nat_eq(a74, a75) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f13(v0: Bytes, v1: u64) -> R { + let v2: u64 = f15(v0.clone(), v1)?; + let v3: u64 = f15(v0.clone(), { + let a76 = v1; + let a77 = 1u64; + nat_add(a76, a77)? + })?; + let v4: u64 = f15(v0, { + let a78 = v1; + let a79 = 2u64; + nat_add(a78, a79)? + })?; + if f14(v2) { + Ok(1u64) + } else { + let a80 = v2; + let a81 = 194u64; + if nat_eq(a80, a81) { + let a82 = v3; + let a83 = 133u64; + if if nat_eq(a82, a83) { + true + } else { + let a84 = v3; + let a85 = 160u64; + nat_eq(a84, a85) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a86 = v2; + let a87 = 225u64; + if nat_eq(a86, a87) { + let a88 = v3; + let a89 = 154u64; + if if nat_eq(a88, a89) { + let a90 = v4; + let a91 = 128u64; + nat_eq(a90, a91) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a92 = v2; + let a93 = 226u64; + if nat_eq(a92, a93) { + let a94 = v3; + let a95 = 128u64; + if nat_eq(a94, a95) { + let a96 = 128u64; + let a97 = v4; + if if if nat_le(a96, a97) { + let a98 = v4; + let a99 = 138u64; + nat_le(a98, a99) + } else { + false + } { + true + } else { + let a100 = v4; + let a101 = 168u64; + if nat_eq(a100, a101) { + true + } else { + let a102 = v4; + let a103 = 169u64; + if nat_eq(a102, a103) { + true + } else { + let a104 = v4; + let a105 = 175u64; + nat_eq(a104, a105) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a106 = v3; + let a107 = 129u64; + if if nat_eq(a106, a107) { + let a108 = v4; + let a109 = 159u64; + nat_eq(a108, a109) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a110 = v2; + let a111 = 227u64; + if if nat_eq(a110, a111) { + let a112 = v3; + let a113 = 128u64; + if nat_eq(a112, a113) { + let a114 = v4; + let a115 = 128u64; + nat_eq(a114, a115) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f14(v0: u64) -> bool { + let a116 = v0; + let a117 = 32u64; + if nat_eq(a116, a117) { + true + } else { + let a118 = 9u64; + let a119 = v0; + if nat_le(a118, a119) { + let a120 = v0; + let a121 = 13u64; + nat_le(a120, a121) + } else { + false + } + } +} + +pub fn f15(v0: Bytes, v1: u64) -> R { + let m124 = { + let a122 = v0; + let a123 = v1; + index_bytes(a122, a123) + }; + match m124 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a169 = { + let a145 = { + let a133 = { + let a127 = { + let a125 = v3; + let a126 = 128u8; + fixed_u8::bit_and(a125, a126) + }; + let a128 = 128u8; + if equal(a127, a128) { + 128u64 + } else { + 0u64 + } + }; + let a134 = { + let a131 = { + let a129 = v3; + let a130 = 64u8; + fixed_u8::bit_and(a129, a130) + }; + let a132 = 64u8; + if equal(a131, a132) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a133, a134)? + }; + let a146 = { + let a143 = { + let a137 = { + let a135 = v3; + let a136 = 32u8; + fixed_u8::bit_and(a135, a136) + }; + let a138 = 32u8; + if equal(a137, a138) { + 32u64 + } else { + 0u64 + } + }; + let a144 = { + let a141 = { + let a139 = v3; + let a140 = 16u8; + fixed_u8::bit_and(a139, a140) + }; + let a142 = 16u8; + if equal(a141, a142) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a143, a144)? + }; + nat_add(a145, a146)? + }; + let a170 = { + let a167 = { + let a155 = { + let a149 = { + let a147 = v3; + let a148 = 8u8; + fixed_u8::bit_and(a147, a148) + }; + let a150 = 8u8; + if equal(a149, a150) { + 8u64 + } else { + 0u64 + } + }; + let a156 = { + let a153 = { + let a151 = v3; + let a152 = 4u8; + fixed_u8::bit_and(a151, a152) + }; + let a154 = 4u8; + if equal(a153, a154) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a155, a156)? + }; + let a168 = { + let a165 = { + let a159 = { + let a157 = v3; + let a158 = 2u8; + fixed_u8::bit_and(a157, a158) + }; + let a160 = 2u8; + if equal(a159, a160) { + 2u64 + } else { + 0u64 + } + }; + let a166 = { + let a163 = { + let a161 = v3; + let a162 = 1u8; + fixed_u8::bit_and(a161, a162) + }; + let a164 = 1u8; + if equal(a163, a164) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a165, a166)? + }; + nat_add(a167, a168)? + }; + nat_add(a169, a170) + } + } +} + +pub fn run(p0: Str) -> R { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_is_needs_address.rs b/crates/certified/roots/uorust_certified_is_needs_address.rs index 3e2a8558..618dedcb 100644 --- a/crates/certified/roots/uorust_certified_is_needs_address.rs +++ b/crates/certified/roots/uorust_certified_is_needs_address.rs @@ -927,13 +927,17 @@ pub fn f0(v0: Adt0) -> bool { false } Adt0::C9(v10) => { - let a4 = v10; - let a5 = { - let a2 = List::cons(f1(), List::cons(Str::lit(": "), List::cons(f2(), List::::nil()))); - let a3 = Str::lit(""); - join(a2, a3) + let a6 = v10; + let a7 = { + let a4 = { + let a2 = List::cons(f1(), List::::nil()); + let a3 = List::cons(Str::lit(": "), List::cons(f2(), List::::nil())); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + join(a4, a5) }; - equal(a4, a5) + equal(a6, a7) } Adt0::C10(_) => { false diff --git a/crates/certified/roots/uorust_certified_is_needs_memory.rs b/crates/certified/roots/uorust_certified_is_needs_memory.rs index 14fa8a42..3c379fd1 100644 --- a/crates/certified/roots/uorust_certified_is_needs_memory.rs +++ b/crates/certified/roots/uorust_certified_is_needs_memory.rs @@ -927,13 +927,17 @@ pub fn f0(v0: Adt0) -> bool { false } Adt0::C9(v10) => { - let a4 = v10; - let a5 = { - let a2 = List::cons(f1(), List::cons(Str::lit(": "), List::cons(f2(), List::::nil()))); - let a3 = Str::lit(""); - join(a2, a3) + let a6 = v10; + let a7 = { + let a4 = { + let a2 = List::cons(f1(), List::::nil()); + let a3 = List::cons(Str::lit(": "), List::cons(f2(), List::::nil())); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + join(a4, a5) }; - equal(a4, a5) + equal(a6, a7) } Adt0::C10(_) => { false diff --git a/crates/certified/roots/uorust_certified_is_pointer.rs b/crates/certified/roots/uorust_certified_is_pointer.rs index 3321b781..985d2de3 100644 --- a/crates/certified/roots/uorust_certified_is_pointer.rs +++ b/crates/certified/roots/uorust_certified_is_pointer.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -905,7 +906,7 @@ pub fn f0(v0: Adt0) -> bool { Adt0::C5(_) => { false } - Adt0::C6 => { + Adt0::C6(_) => { false } Adt0::C7 => { @@ -920,18 +921,18 @@ pub fn f0(v0: Adt0) -> bool { Adt0::C10 => { false } - Adt0::C11(v5) => { - let a2 = v5; + Adt0::C11 => { + false + } + Adt0::C12(v6) => { + let a2 = v6; let a3 = f1(); equal(a2, a3) } - Adt0::C12(_) => { - false - } - Adt0::C13(_, _) => { + Adt0::C13(_) => { false } - Adt0::C14(_) => { + Adt0::C14(_, _) => { false } Adt0::C15(_) => { @@ -940,15 +941,18 @@ pub fn f0(v0: Adt0) -> bool { Adt0::C16(_) => { false } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { false } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { false } Adt0::C19(_, _) => { false } + Adt0::C20(_, _) => { + false + } } } diff --git a/crates/certified/roots/uorust_certified_kind.rs b/crates/certified/roots/uorust_certified_kind.rs index 42d834cb..9bdb800a 100644 --- a/crates/certified/roots/uorust_certified_kind.rs +++ b/crates/certified/roots/uorust_certified_kind.rs @@ -903,9 +903,13 @@ pub fn f0(v0: Str, v1: Str) -> Adt0 { Adt0::C9(v0) } else { Adt0::C9({ - let a3 = List::cons(v0, List::cons(Str::lit(": "), List::cons(v1, List::::nil()))); - let a4 = Str::lit(""); - join(a3, a4) + let a5 = { + let a3 = List::cons(v0, List::::nil()); + let a4 = List::cons(Str::lit(": "), List::cons(v1, List::::nil())); + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) }) } } diff --git a/crates/certified/roots/uorust_certified_lambda_wrap.rs b/crates/certified/roots/uorust_certified_lambda_wrap.rs index 10ad5120..6aa8417e 100644 --- a/crates/certified/roots/uorust_certified_lambda_wrap.rs +++ b/crates/certified/roots/uorust_certified_lambda_wrap.rs @@ -873,20 +873,21 @@ pub enum Adt2 { C3(u64), C4(Adt3), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_lambda_wrap_expr.rs b/crates/certified/roots/uorust_certified_lambda_wrap_expr.rs index 15db149c..08199d9b 100644 --- a/crates/certified/roots/uorust_certified_lambda_wrap_expr.rs +++ b/crates/certified/roots/uorust_certified_lambda_wrap_expr.rs @@ -873,20 +873,21 @@ pub enum Adt2 { C3(u64), C4(Adt3), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_leaving_value.rs b/crates/certified/roots/uorust_certified_leaving_value.rs index ef3f6cde..b70ca7e9 100644 --- a/crates/certified/roots/uorust_certified_leaving_value.rs +++ b/crates/certified/roots/uorust_certified_leaving_value.rs @@ -1199,20 +1199,21 @@ pub enum Adt49 { C3(u64), C4(Adt50), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_local_name.rs b/crates/certified/roots/uorust_certified_local_name.rs new file mode 100644 index 00000000..97ce9e73 --- /dev/null +++ b/crates/certified/roots/uorust_certified_local_name.rs @@ -0,0 +1,1692 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, bool, bool), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str, bool), +} + +pub fn f0(v0: Str) -> R { + let v1: Str = f1(List::cons(f2(v0, Str::lit("r#"))?, List::::nil()))?; + let a1 = v1.clone(); + let a2 = Str::lit(""); + if if equal(a1, a2) { + true + } else { + f3(f4(), v1.clone()) + } { + let a3 = List::cons(v1, List::cons(Str::lit("Value"), List::::nil())); + let a4 = Str::lit(""); + Ok(join(a3, a4)) + } else { + Ok(v1) + } +} + +pub fn f1(v0: List) -> R { + let a5 = f5(f6(f7(f8(v0)?)?, 0u64)?)?; + let a6 = Str::lit(""); + Ok(join(a5, a6)) +} + +pub fn f2(v0: Str, v1: Str) -> R { + let v2: Bytes = { + let a7 = v0.clone(); + utf8_encode(a7) + }; + let v3: Bytes = { + let a8 = v1; + utf8_encode(a8) + }; + let a10 = { + let a9 = v3.clone(); + length_bytes(a9) + }; + let a11 = 0u64; + if nat_eq(a10, a11) { + Ok(v0) + } else { + Ok(f9(v2.clone(), f10({ + let a12 = v2.clone(); + length_bytes(a12) + }, v2.clone(), v3, 0u64)?, { + let a13 = v2; + length_bytes(a13) + })) + } +} + +pub fn f3(p18: List, v1: Str) -> bool { + let m17 = p18; + { + let mut m17 = m17; + loop { + let step = { + let v0 = m17; + let m14 = v0; + match m14.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a15 = v2; + let a16 = v1.clone(); + if equal(a15, a16) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m17 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f4() -> List { + let a47 = { + let a31 = { + let a23 = { + let a19 = List::cons(Str::lit("at"), List::cons(Str::lit("by"), List::cons(Str::lit("calc"), List::cons(Str::lit("def"), List::cons(Str::lit("do"), List::cons(Str::lit("else"), List::::nil())))))); + let a20 = List::cons(Str::lit("end"), List::cons(Str::lit("example"), List::cons(Str::lit("fun"), List::cons(Str::lit("have"), List::cons(Str::lit("if"), List::cons(Str::lit("in"), List::::nil())))))); + append_list(a19, a20) + }; + let a24 = { + let a21 = List::cons(Str::lit("instance"), List::cons(Str::lit("let"), List::cons(Str::lit("match"), List::cons(Str::lit("mut"), List::cons(Str::lit("nomatch"), List::cons(Str::lit("open"), List::::nil())))))); + let a22 = List::cons(Str::lit("prop"), List::cons(Str::lit("return"), List::cons(Str::lit("show"), List::cons(Str::lit("then"), List::cons(Str::lit("theorem"), List::cons(Str::lit("type"), List::cons(Str::lit("where"), List::::nil()))))))); + append_list(a21, a22) + }; + append_list(a23, a24) + }; + let a32 = { + let a29 = { + let a25 = List::cons(Str::lit("with"), List::cons(Str::lit("from"), List::cons(Str::lit("for"), List::cons(Str::lit("try"), List::cons(Str::lit("catch"), List::cons(Str::lit("break"), List::::nil())))))); + let a26 = List::cons(Str::lit("continue"), List::cons(Str::lit("unless"), List::cons(Str::lit("structure"), List::cons(Str::lit("inductive"), List::cons(Str::lit("class"), List::cons(Str::lit("namespace"), List::cons(Str::lit("section"), List::::nil()))))))); + append_list(a25, a26) + }; + let a30 = { + let a27 = List::cons(Str::lit("local"), List::cons(Str::lit("private"), List::cons(Str::lit("protected"), List::cons(Str::lit("partial"), List::cons(Str::lit("unsafe"), List::cons(Str::lit("macro"), List::::nil())))))); + let a28 = List::cons(Str::lit("syntax"), List::cons(Str::lit("import"), List::cons(Str::lit("export"), List::cons(Str::lit("axiom"), List::cons(Str::lit("abbrev"), List::cons(Str::lit("opaque"), List::cons(Str::lit("mutual"), List::::nil()))))))); + append_list(a27, a28) + }; + append_list(a29, a30) + }; + append_list(a31, a32) + }; + let a48 = { + let a45 = { + let a37 = { + let a33 = List::cons(Str::lit("variable"), List::cons(Str::lit("universe"), List::cons(Str::lit("deriving"), List::cons(Str::lit("extends"), List::cons(Str::lit("suffices"), List::cons(Str::lit("obtain"), List::::nil())))))); + let a34 = List::cons(Str::lit("record"), List::cons(Str::lit("ctor"), List::cons(Str::lit("prim"), List::cons(Str::lit("project"), List::cons(Str::lit("cons"), List::cons(Str::lit("nil"), List::::nil())))))); + append_list(a33, a34) + }; + let a38 = { + let a35 = List::cons(Str::lit("not"), List::cons(Str::lit("true"), List::cons(Str::lit("false"), List::cons(Str::lit("forall"), List::cons(Str::lit("first"), List::cons(Str::lit("second"), List::::nil())))))); + let a36 = List::cons(Str::lit("apply"), List::cons(Str::lit("ref"), List::cons(Str::lit("checked"), List::cons(Str::lit("self"), List::cons(Str::lit("noncomputable"), List::cons(Str::lit("termination_by"), List::cons(Str::lit("and_congr"), List::::nil()))))))); + append_list(a35, a36) + }; + append_list(a37, a38) + }; + let a46 = { + let a43 = { + let a39 = List::cons(Str::lit("and_true"), List::cons(Str::lit("beq_iff_eq"), List::cons(Str::lit("congr"), List::cons(Str::lit("decide"), List::cons(Str::lit("decide_eq_false_iff_not"), List::cons(Str::lit("decide_eq_true_eq"), List::::nil())))))); + let a40 = List::cons(Str::lit("id"), List::cons(Str::lit("reduceIte"), List::cons(Str::lit("rfl"), List::cons(Str::lit("true_and"), List::cons(Str::lit("isFalse"), List::cons(Str::lit("isTrue"), List::cons(Str::lit("none"), List::::nil()))))))); + append_list(a39, a40) + }; + let a44 = { + let a41 = List::cons(Str::lit("some"), List::cons(Str::lit("below"), List::cons(Str::lit("brecOn"), List::cons(Str::lit("casesOn"), List::cons(Str::lit("ctorElim"), List::cons(Str::lit("ctorElimType"), List::::nil())))))); + let a42 = List::cons(Str::lit("ctorIdx"), List::cons(Str::lit("mk"), List::cons(Str::lit("noConfusion"), List::cons(Str::lit("noConfusionType"), List::cons(Str::lit("rec"), List::cons(Str::lit("recOn"), List::cons(Str::lit("toCtorIdx"), List::::nil()))))))); + append_list(a41, a42) + }; + append_list(a43, a44) + }; + append_list(a45, a46) + }; + append_list(a47, a48) +} + +pub fn f5(v0: List) -> R> { + let m49 = v0; + match m49.uncons() { + None => { + Ok(List::::nil()) + } + Some((v1, v2)) => { + let v3: u64 = match v1.clone() { + Adt0::C0(h50, _) => { + h50 + } + }; + let v4: Str = match v1 { + Adt0::C0(_, h51) => { + h51 + } + }; + Ok(List::cons({ + let a52 = v3; + let a53 = 0u64; + if nat_eq(a52, a53) { + f11(v4)? + } else { + v4 + } + }, f5(v2)?)) + } + } +} + +pub fn f6(v0: List, v1: u64) -> R> { + let m54 = v0; + match m54.uncons() { + None => { + Ok(List::::nil()) + } + Some((v2, v3)) => { + Ok(List::cons(Adt0::C0(v1, v2), f6(v3, { + let a55 = v1; + let a56 = 1u64; + nat_add(a55, a56)? + })?)) + } + } +} + +pub fn f7(v0: Str) -> R> { + let v1: Bytes = { + let a57 = v0; + utf8_encode(a57) + }; + f12({ + let a58 = v1.clone(); + length_bytes(a58) + }, v1, 0u64) +} + +pub fn f8(v0: List) -> R { + let v1: Str = Str::lit(""); + let v2: Str = f13(v0, v1)?; + if f14(v2.clone())? { + let a59 = List::cons(Str::lit("N"), List::cons(v2, List::::nil())); + let a60 = Str::lit(""); + Ok(join(a59, a60)) + } else { + Ok(v2) + } +} + +pub fn f9(v0: Bytes, v1: u64, v2: u64) -> Str { + let m66 = { + let a63 = v0; + let a64 = v1; + let a65 = { + let a61 = v2; + let a62 = v1; + nat_sub(a61, a62) + }; + slice_bytes(a63, a64, a65) + }; + match m66 { + None => { + Str::lit("") + } + Some(v3) => { + let m68 = { + let a67 = v3; + utf8_decode(a67) + }; + match m68 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f10(p74: u64, v1: Bytes, v2: Bytes, p75: u64) -> R { + let m73 = (p74, p75); + { + let mut m73 = m73; + loop { + let step = { + let (v0, v3) = m73; + let m69 = v0; + if m69 == 0 { + Err::<(u64, u64), R>(Ok(v3)) + } else { + let v4 = m69 - 1; + if f15(v1.clone(), v3, v2.clone()) { + Ok::<(u64, u64), R>((v4, { + let a71 = v3; + let a72 = { + let a70 = v2.clone(); + length_bytes(a70) + }; + nat_add(a71, a72)? + })) + } else { + Err::<(u64, u64), R>(Ok(v3)) + } + } + }; + match step { + Ok(next) => { m73 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f11(v0: Str) -> R { + f16(v0, 65u64, Bytes::lit(&[0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a])) +} + +pub fn f12(v0: u64, v1: Bytes, v2: u64) -> R> { + let m76 = v0; + if m76 == 0 { + Ok(List::::nil()) + } else { + let v3 = m76 - 1; + let a78 = { + let a77 = v1.clone(); + length_bytes(a77) + }; + let a79 = v2; + if nat_le(a78, a79) { + Ok(List::::nil()) + } else { + let v4: u64 = f17(f18(v1.clone(), v2)?); + Ok(List::cons(f9(v1.clone(), v2, { + let a80 = v2; + let a81 = v4; + nat_add(a80, a81)? + }), f12(v3, v1, { + let a82 = v2; + let a83 = v4; + nat_add(a82, a83)? + })?)) + } + } +} + +pub fn f13(p89: List, p90: Str) -> R { + let m88 = (p89, p90); + { + let mut m88 = m88; + loop { + let step = { + let (v0, v1) = m88; + let m84 = v0; + match m84.uncons() { + None => { + Err::<(List, Str), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: bool = true; + let v5: bool = false; + let v6: Adt1 = f19(f7(v2)?, Adt1::C0(v1, v5, v4))?; + let v7: Str = match v6.clone() { + Adt1::C0(h85, _, _) => { + h85 + } + }; + let _: bool = match v6.clone() { + Adt1::C0(_, h86, _) => { + h86 + } + }; + let _: bool = match v6 { + Adt1::C0(_, _, h87) => { + h87 + } + }; + Ok::<(List, Str), R>((v3, v7)) + } + } + }; + match step { + Ok(next) => { m88 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f14(v0: Str) -> R { + let m93 = { + let a91 = f7(v0)?; + let a92 = 0u64; + index_list(a91, a92) + }; + match m93 { + None => { + Ok(false) + } + Some(v1) => { + f20(v1) + } + } +} + +pub fn f15(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m98 = { + let a95 = v0; + let a96 = v1; + let a97 = { + let a94 = v2.clone(); + length_bytes(a94) + }; + slice_bytes(a95, a96, a97) + }; + match m98 { + None => { + false + } + Some(v3) => { + let a99 = v3; + let a100 = v2; + equal(a99, a100) + } + } +} + +pub fn f16(v0: Str, v1: u64, v2: Bytes) -> R { + let v3: Bytes = { + let a101 = v0.clone(); + utf8_encode(a101) + }; + let m105 = { + let a104 = f21({ + let a102 = v3.clone(); + length_bytes(a102) + }, v3, 0u64, v1, v2, { + let a103 = Str::lit(""); + utf8_encode(a103) + })?; + utf8_decode(a104) + }; + match m105 { + None => { + Ok(v0) + } + Some(v4) => { + Ok(v4) + } + } +} + +pub fn f17(v0: u64) -> u64 { + let a106 = v0; + let a107 = 128u64; + if nat_lt(a106, a107) { + 1u64 + } else { + let a108 = v0; + let a109 = 224u64; + if nat_lt(a108, a109) { + 2u64 + } else { + let a110 = v0; + let a111 = 240u64; + if nat_lt(a110, a111) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f18(v0: Bytes, v1: u64) -> R { + let m114 = { + let a112 = v0; + let a113 = v1; + index_bytes(a112, a113) + }; + match m114 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a159 = { + let a135 = { + let a123 = { + let a117 = { + let a115 = v3; + let a116 = 128u8; + fixed_u8::bit_and(a115, a116) + }; + let a118 = 128u8; + if equal(a117, a118) { + 128u64 + } else { + 0u64 + } + }; + let a124 = { + let a121 = { + let a119 = v3; + let a120 = 64u8; + fixed_u8::bit_and(a119, a120) + }; + let a122 = 64u8; + if equal(a121, a122) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a123, a124)? + }; + let a136 = { + let a133 = { + let a127 = { + let a125 = v3; + let a126 = 32u8; + fixed_u8::bit_and(a125, a126) + }; + let a128 = 32u8; + if equal(a127, a128) { + 32u64 + } else { + 0u64 + } + }; + let a134 = { + let a131 = { + let a129 = v3; + let a130 = 16u8; + fixed_u8::bit_and(a129, a130) + }; + let a132 = 16u8; + if equal(a131, a132) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a133, a134)? + }; + nat_add(a135, a136)? + }; + let a160 = { + let a157 = { + let a145 = { + let a139 = { + let a137 = v3; + let a138 = 8u8; + fixed_u8::bit_and(a137, a138) + }; + let a140 = 8u8; + if equal(a139, a140) { + 8u64 + } else { + 0u64 + } + }; + let a146 = { + let a143 = { + let a141 = v3; + let a142 = 4u8; + fixed_u8::bit_and(a141, a142) + }; + let a144 = 4u8; + if equal(a143, a144) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a145, a146)? + }; + let a158 = { + let a155 = { + let a149 = { + let a147 = v3; + let a148 = 2u8; + fixed_u8::bit_and(a147, a148) + }; + let a150 = 2u8; + if equal(a149, a150) { + 2u64 + } else { + 0u64 + } + }; + let a156 = { + let a153 = { + let a151 = v3; + let a152 = 1u8; + fixed_u8::bit_and(a151, a152) + }; + let a154 = 1u8; + if equal(a153, a154) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a155, a156)? + }; + nat_add(a157, a158)? + }; + nat_add(a159, a160) + } + } +} + +pub fn f19(p176: List, p177: Adt1) -> R { + let m175 = (p176, p177); + { + let mut m175 = m175; + loop { + let step = { + let (v0, v1) = m175; + let m161 = v0; + match m161.uncons() { + None => { + Err::<(List, Adt1), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: Str = match v1.clone() { + Adt1::C0(h162, _, _) => { + h162 + } + }; + let v5: bool = match v1.clone() { + Adt1::C0(_, h163, _) => { + h163 + } + }; + let v6: bool = match v1 { + Adt1::C0(_, _, h164) => { + h164 + } + }; + let a165 = f22(v2.clone())?; + if bool_not(a165) { + let v7: bool = true; + let v8: bool = false; + Ok::<(List, Adt1), R>((v3, Adt1::C0(v4, v8, v7))) + } else { + let v14: Adt2 = if v6 { + let v9: Str = { + let a166 = List::cons(v4, List::cons(f23(v2.clone())?, List::::nil())); + let a167 = Str::lit(""); + join(a166, a167) + }; + let v10: bool = false; + Adt2::C0(v9, v10) + } else { + let v13: Str = if if f24(v2.clone())? { + let a168 = v5; + bool_not(a168) + } else { + false + } { + let v11: Str = { + let a169 = List::cons(v4, List::cons(f11(v2.clone())?, List::::nil())); + let a170 = Str::lit(""); + join(a169, a170) + }; + v11 + } else { + let v12: Str = { + let a171 = List::cons(v4, List::cons(v2.clone(), List::::nil())); + let a172 = Str::lit(""); + join(a171, a172) + }; + v12 + }; + Adt2::C0(v13, v6) + }; + let v15: Str = match v14.clone() { + Adt2::C0(h173, _) => { + h173 + } + }; + let v16: bool = match v14 { + Adt2::C0(_, h174) => { + h174 + } + }; + let v17: bool = if f25(v2.clone())? { + true + } else { + f20(v2)? + }; + Ok::<(List, Adt1), R>((v3, Adt1::C0(v15, v17, v16))) + } + } + } + }; + match step { + Ok(next) => { m175 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f20(v0: Str) -> R { + let v1: u64 = f26(v0)?; + let a178 = 48u64; + let a179 = v1; + if nat_le(a178, a179) { + let a180 = v1; + let a181 = 57u64; + Ok(nat_le(a180, a181)) + } else { + Ok(false) + } +} + +pub fn f21(p204: u64, v1: Bytes, p205: u64, v3: u64, v4: Bytes, p206: Bytes) -> R { + let m203 = (p204, (p205, p206)); + { + let mut m203 = m203; + loop { + let step = { + let (v0, (v2, v5)) = m203; + let m182 = v0; + if m182 == 0 { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } else { + let v6 = m182 - 1; + let m186 = { + let a183 = v1.clone(); + let a184 = v2; + let a185 = 1u64; + slice_bytes(a183, a184, a185) + }; + match m186 { + None => { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } + Some(v7) => { + let v8: u64 = f18(v1.clone(), v2)?; + let v10: Bytes = { + let a187 = v3; + let a188 = v8; + if if nat_le(a187, a188) { + let a191 = v8; + let a192 = { + let a189 = v3; + let a190 = 26u64; + nat_add(a189, a190)? + }; + nat_lt(a191, a192) + } else { + false + } { + let m198 = { + let a195 = v4.clone(); + let a196 = { + let a193 = v8; + let a194 = v3; + nat_sub(a193, a194) + }; + let a197 = 1u64; + slice_bytes(a195, a196, a197) + }; + match m198 { + None => { + v7 + } + Some(v9) => { + v9 + } + } + } else { + v7 + } + }; + Ok::<(u64, (u64, Bytes)), R>((v6, ({ + let a199 = v2; + let a200 = 1u64; + nat_add(a199, a200)? + }, { + let a201 = v5; + let a202 = v10; + append_bytes(a201, a202) + }))) + } + } + } + }; + match step { + Ok(next) => { m203 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f22(v0: Str) -> R { + if f27(v0.clone())? { + Ok(true) + } else { + f20(v0) + } +} + +pub fn f23(v0: Str) -> R { + f16(v0, 97u64, Bytes::lit(&[0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a])) +} + +pub fn f24(v0: Str) -> R { + let v1: u64 = f26(v0)?; + let a207 = 65u64; + let a208 = v1; + if nat_le(a207, a208) { + let a209 = v1; + let a210 = 90u64; + Ok(nat_le(a209, a210)) + } else { + Ok(false) + } +} + +pub fn f25(v0: Str) -> R { + let v1: u64 = f26(v0)?; + let a211 = 97u64; + let a212 = v1; + if nat_le(a211, a212) { + let a213 = v1; + let a214 = 122u64; + Ok(nat_le(a213, a214)) + } else { + Ok(false) + } +} + +pub fn f26(v0: Str) -> R { + f18({ + let a215 = v0; + utf8_encode(a215) + }, 0u64) +} + +pub fn f27(v0: Str) -> R { + if f24(v0.clone())? { + Ok(true) + } else { + f25(v0) + } +} + +pub fn run(p0: Str) -> R { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_members.rs b/crates/certified/roots/uorust_certified_members.rs index df0eb125..4d84dc97 100644 --- a/crates/certified/roots/uorust_certified_members.rs +++ b/crates/certified/roots/uorust_certified_members.rs @@ -857,39 +857,47 @@ pub fn format_int(p0: i64) -> Str { pub fn f0(v0: Str, v1: List, v2: List, v3: bool) -> Str { let v4: Str = { - let a3 = List::cons(v0.clone(), List::cons(Str::lit("{"), List::cons({ - let a1 = v1; - let a2 = Str::lit(", "); - join(a1, a2) - }, List::cons(Str::lit("}"), List::::nil())))); - let a4 = Str::lit(""); - join(a3, a4) + let a5 = { + let a3 = List::cons(v0.clone(), List::cons(Str::lit("{"), List::::nil())); + let a4 = List::cons({ + let a1 = v1; + let a2 = Str::lit(", "); + join(a1, a2) + }, List::cons(Str::lit("}"), List::::nil())); + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) }; if if v3 { - let a5 = f1(v4.clone()); - let a6 = f2(); - nat_le(a5, a6) + let a7 = f1(v4.clone()); + let a8 = f2(); + nat_le(a7, a8) } else { false } { v4 } else { - let a9 = List::cons(v0, List::cons(Str::lit("{\u{a}"), List::cons({ - let a7 = v2; - let a8 = Str::lit(",\u{a}"); - join(a7, a8) - }, List::cons(Str::lit("\u{a}}"), List::::nil())))); - let a10 = Str::lit(""); - join(a9, a10) + let a13 = { + let a11 = List::cons(v0, List::cons(Str::lit("{\u{a}"), List::::nil())); + let a12 = List::cons({ + let a9 = v2; + let a10 = Str::lit(",\u{a}"); + join(a9, a10) + }, List::cons(Str::lit("\u{a}}"), List::::nil())); + append_list(a11, a12) + }; + let a14 = Str::lit(""); + join(a13, a14) } } pub fn f1(v0: Str) -> u64 { - let a12 = { - let a11 = v0; - utf8_encode(a11) + let a16 = { + let a15 = v0; + utf8_encode(a15) }; - length_bytes(a12) + length_bytes(a16) } pub fn f2() -> u64 { diff --git a/crates/certified/roots/uorust_certified_memory_fields.rs b/crates/certified/roots/uorust_certified_memory_fields.rs index 68f3eaca..1b279332 100644 --- a/crates/certified/roots/uorust_certified_memory_fields.rs +++ b/crates/certified/roots/uorust_certified_memory_fields.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -885,37 +886,39 @@ pub enum Adt1 { } pub fn f0() -> List<(Str, Adt0)> { - List::cons((Str::lit("count"), Adt0::C2(None::)), List::cons((Str::lit("top"), Adt0::C2(None::)), List::cons((Str::lit("base"), f1()), List::cons((Str::lit("length"), f2()), List::cons((Str::lit("stride"), f3()), List::cons((Str::lit("live"), f4()), List::cons((Str::lit("cells"), f5()), List::cons((Str::lit("defined"), f6()), List::<(Str, Adt0)>::nil())))))))) + let a1 = List::cons((Str::lit("count"), Adt0::C2(None::)), List::cons((Str::lit("top"), Adt0::C2(None::)), List::cons((Str::lit("base"), f1()), List::cons((Str::lit("length"), f2()), List::<(Str, Adt0)>::nil())))); + let a2 = List::cons((Str::lit("stride"), f3()), List::cons((Str::lit("live"), f4()), List::cons((Str::lit("cells"), f5()), List::cons((Str::lit("defined"), f6()), List::<(Str, Adt0)>::nil())))); + append_list(a1, a2) } pub fn f1() -> Adt0 { let v0: Adt0 = Adt0::C2(None::); - Adt0::C19(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) + Adt0::C20(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) } pub fn f2() -> Adt0 { let v0: Adt0 = Adt0::C2(None::); - Adt0::C19(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) + Adt0::C20(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) } pub fn f3() -> Adt0 { let v0: Adt0 = Adt0::C2(None::); - Adt0::C19(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) + Adt0::C20(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) } pub fn f4() -> Adt0 { let v0: Adt0 = Adt0::C2(None::); - Adt0::C19(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) + Adt0::C20(List::cons(Adt0::C2(None::), List::::nil()), std::rc::Rc::new(v0)) } pub fn f5() -> Adt0 { let v0: Adt0 = Adt0::C2(None::); - Adt0::C19(List::cons(Adt0::C2(None::), List::cons(Adt0::C2(None::), List::::nil())), std::rc::Rc::new(v0)) + Adt0::C20(List::cons(Adt0::C2(None::), List::cons(Adt0::C2(None::), List::::nil())), std::rc::Rc::new(v0)) } pub fn f6() -> Adt0 { let v0: Adt0 = Adt0::C2(None::); - Adt0::C19(List::cons(Adt0::C2(None::), List::cons(Adt0::C2(None::), List::::nil())), std::rc::Rc::new(v0)) + Adt0::C20(List::cons(Adt0::C2(None::), List::cons(Adt0::C2(None::), List::::nil())), std::rc::Rc::new(v0)) } pub fn run() -> List<(Str, Adt0)> { diff --git a/crates/certified/roots/uorust_certified_memory_ty.rs b/crates/certified/roots/uorust_certified_memory_ty.rs index 20266814..9b301061 100644 --- a/crates/certified/roots/uorust_certified_memory_ty.rs +++ b/crates/certified/roots/uorust_certified_memory_ty.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -885,7 +886,7 @@ pub enum Adt1 { } pub fn f0() -> Adt0 { - Adt0::C11(f1()) + Adt0::C12(f1()) } pub fn f1() -> Str { diff --git a/crates/certified/roots/uorust_certified_method_char_any.rs b/crates/certified/roots/uorust_certified_method_char_any.rs index af1f50e0..693fdd67 100644 --- a/crates/certified/roots/uorust_certified_method_char_any.rs +++ b/crates/certified/roots/uorust_certified_method_char_any.rs @@ -876,20 +876,21 @@ pub enum Adt2 { C3(u64), C4(Adt3), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -989,49 +990,69 @@ pub fn f2(v0: Str) -> Option { if equal(a2, a3) { let v1: Str = Str::lit("Alphabetic"); Some({ - let a4 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v1, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a5 = Str::lit(""); - join(a4, a5) + let a6 = { + let a4 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a5 = List::cons(Str::lit(" tests the Unicode "), List::cons(v1, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a4, a5) + }; + let a7 = Str::lit(""); + join(a6, a7) }) } else { - let a6 = v0.clone(); - let a7 = Str::lit("is_alphanumeric"); - if equal(a6, a7) { + let a8 = v0.clone(); + let a9 = Str::lit("is_alphanumeric"); + if equal(a8, a9) { let v2: Str = Str::lit("Alphabetic or Numeric"); Some({ - let a8 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v2, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a9 = Str::lit(""); - join(a8, a9) + let a12 = { + let a10 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a11 = List::cons(Str::lit(" tests the Unicode "), List::cons(v2, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a10, a11) + }; + let a13 = Str::lit(""); + join(a12, a13) }) } else { - let a10 = v0.clone(); - let a11 = Str::lit("is_numeric"); - if equal(a10, a11) { + let a14 = v0.clone(); + let a15 = Str::lit("is_numeric"); + if equal(a14, a15) { let v3: Str = Str::lit("Numeric"); Some({ - let a12 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v3, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a13 = Str::lit(""); - join(a12, a13) + let a18 = { + let a16 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a17 = List::cons(Str::lit(" tests the Unicode "), List::cons(v3, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a16, a17) + }; + let a19 = Str::lit(""); + join(a18, a19) }) } else { - let a14 = v0.clone(); - let a15 = Str::lit("is_uppercase"); - if equal(a14, a15) { + let a20 = v0.clone(); + let a21 = Str::lit("is_uppercase"); + if equal(a20, a21) { let v4: Str = Str::lit("Uppercase"); Some({ - let a16 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v4, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a17 = Str::lit(""); - join(a16, a17) + let a24 = { + let a22 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a23 = List::cons(Str::lit(" tests the Unicode "), List::cons(v4, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a22, a23) + }; + let a25 = Str::lit(""); + join(a24, a25) }) } else { - let a18 = v0.clone(); - let a19 = Str::lit("is_lowercase"); - if equal(a18, a19) { + let a26 = v0.clone(); + let a27 = Str::lit("is_lowercase"); + if equal(a26, a27) { let v5: Str = Str::lit("Lowercase"); Some({ - let a20 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v5, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a21 = Str::lit(""); - join(a20, a21) + let a30 = { + let a28 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a29 = List::cons(Str::lit(" tests the Unicode "), List::cons(v5, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a28, a29) + }; + let a31 = Str::lit(""); + join(a30, a31) }) } else { None:: diff --git a/crates/certified/roots/uorust_certified_method_int_checked_neg.rs b/crates/certified/roots/uorust_certified_method_int_checked_neg.rs index 00a10dbb..4be1e050 100644 --- a/crates/certified/roots/uorust_certified_method_int_checked_neg.rs +++ b/crates/certified/roots/uorust_certified_method_int_checked_neg.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -975,24 +976,32 @@ pub fn f0(v0: u64, v1: Str, v2: Str, v3: Adt0, v4: Adt2) -> R(Adt9::C5({ - let a4 = List::cons(Str::lit("."), List::cons(v1, List::cons(Str::lit(" on i"), List::cons(f1(v0)?, List::::nil())))); - let a5 = Str::lit(""); - join(a4, a5) + let a6 = { + let a4 = List::cons(Str::lit("."), List::cons(v1, List::::nil())); + let a5 = List::cons(Str::lit(" on i"), List::cons(f1(v0)?, List::::nil())); + append_list(a4, a5) + }; + let a7 = Str::lit(""); + join(a6, a7) }))) } else { Ok(f2({ - let a6 = List::cons(Str::lit("(prim checked_negate "), List::cons(v2, List::cons(Str::lit(" : (Option Int64))"), List::::nil()))); - let a7 = Str::lit(""); - join(a6, a7) + let a10 = { + let a8 = List::cons(Str::lit("(prim checked_negate "), List::::nil()); + let a9 = List::cons(v2, List::cons(Str::lit(" : (Option Int64))"), List::::nil())); + append_list(a8, a9) + }; + let a11 = Str::lit(""); + join(a10, a11) }, f3(v3), v4)) } } pub fn f1(v0: u64) -> R { Ok(f4({ - let a8 = v0; - let a9 = 1u64; - nat_add(a8, a9)? + let a12 = v0; + let a13 = 1u64; + nat_add(a12, a13)? }, v0)) } @@ -1001,81 +1010,81 @@ pub fn f2(v0: Str, v1: Adt0, v2: Adt2) -> Result<((Adt5, Adt0), Adt2), Adt9> { } pub fn f3(v0: Adt0) -> Adt0 { - Adt0::C12(std::rc::Rc::new(v0)) + Adt0::C13(std::rc::Rc::new(v0)) } pub fn f4(v0: u64, v1: u64) -> Str { - let m10 = v0; - if m10 == 0 { + let m14 = v0; + if m14 == 0 { Str::lit("") } else { - let v2 = m10 - 1; - let a11 = v1; - let a12 = 10u64; - if nat_lt(a11, a12) { + let v2 = m14 - 1; + let a15 = v1; + let a16 = 10u64; + if nat_lt(a15, a16) { f5(v1) } else { - let a19 = List::cons(f4(v2, { - let a13 = v1; - let a14 = 10u64; - let a15 = 0u64; - nat_quot(a13, a14, a15) + let a23 = List::cons(f4(v2, { + let a17 = v1; + let a18 = 10u64; + let a19 = 0u64; + nat_quot(a17, a18, a19) }), List::cons(f5({ - let a16 = v1; - let a17 = 10u64; - let a18 = 0u64; - nat_rem(a16, a17, a18) + let a20 = v1; + let a21 = 10u64; + let a22 = 0u64; + nat_rem(a20, a21, a22) }), List::::nil())); - let a20 = Str::lit(""); - join(a19, a20) + let a24 = Str::lit(""); + join(a23, a24) } } } pub fn f5(v0: u64) -> Str { - let a21 = v0; - let a22 = 0u64; - if nat_eq(a21, a22) { + let a25 = v0; + let a26 = 0u64; + if nat_eq(a25, a26) { Str::lit("0") } else { - let a23 = v0; - let a24 = 1u64; - if nat_eq(a23, a24) { + let a27 = v0; + let a28 = 1u64; + if nat_eq(a27, a28) { Str::lit("1") } else { - let a25 = v0; - let a26 = 2u64; - if nat_eq(a25, a26) { + let a29 = v0; + let a30 = 2u64; + if nat_eq(a29, a30) { Str::lit("2") } else { - let a27 = v0; - let a28 = 3u64; - if nat_eq(a27, a28) { + let a31 = v0; + let a32 = 3u64; + if nat_eq(a31, a32) { Str::lit("3") } else { - let a29 = v0; - let a30 = 4u64; - if nat_eq(a29, a30) { + let a33 = v0; + let a34 = 4u64; + if nat_eq(a33, a34) { Str::lit("4") } else { - let a31 = v0; - let a32 = 5u64; - if nat_eq(a31, a32) { + let a35 = v0; + let a36 = 5u64; + if nat_eq(a35, a36) { Str::lit("5") } else { - let a33 = v0; - let a34 = 6u64; - if nat_eq(a33, a34) { + let a37 = v0; + let a38 = 6u64; + if nat_eq(a37, a38) { Str::lit("6") } else { - let a35 = v0; - let a36 = 7u64; - if nat_eq(a35, a36) { + let a39 = v0; + let a40 = 7u64; + if nat_eq(a39, a40) { Str::lit("7") } else { - let a37 = v0; - let a38 = 8u64; - if nat_eq(a37, a38) { + let a41 = v0; + let a42 = 8u64; + if nat_eq(a41, a42) { Str::lit("8") } else { Str::lit("9") diff --git a/crates/certified/roots/uorust_certified_method_list_is_empty.rs b/crates/certified/roots/uorust_certified_method_list_is_empty.rs index 0f68e638..7bb4e6c5 100644 --- a/crates/certified/roots/uorust_certified_method_list_is_empty.rs +++ b/crates/certified/roots/uorust_certified_method_list_is_empty.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -969,9 +970,13 @@ pub enum Adt13 { pub fn f0(v0: Str, v1: Adt0) -> Result<((Adt5, Adt1), Adt0), Adt9> { f1({ - let a1 = List::cons(Str::lit("((prim length "), List::cons(v0, List::cons(Str::lit(" : Nat) =? 0)"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("((prim length "), List::::nil()); + let a2 = List::cons(v0, List::cons(Str::lit(" : Nat) =? 0)"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) }, Adt1::C1, v1) } diff --git a/crates/certified/roots/uorust_certified_method_list_len.rs b/crates/certified/roots/uorust_certified_method_list_len.rs index f38fbfdd..1a1e31c2 100644 --- a/crates/certified/roots/uorust_certified_method_list_len.rs +++ b/crates/certified/roots/uorust_certified_method_list_len.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -969,9 +970,13 @@ pub enum Adt13 { pub fn f0(v0: Str, v1: Adt0) -> Result<((Adt5, Adt1), Adt0), Adt9> { f1({ - let a1 = List::cons(Str::lit("(prim length "), List::cons(v0, List::cons(Str::lit(" : Nat)"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("(prim length "), List::::nil()); + let a2 = List::cons(v0, List::cons(Str::lit(" : Nat)"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) }, Adt1::C2(None::), v1) } diff --git a/crates/certified/roots/uorust_certified_method_option_is_some.rs b/crates/certified/roots/uorust_certified_method_option_is_some.rs index c27da6da..b79f4705 100644 --- a/crates/certified/roots/uorust_certified_method_option_is_some.rs +++ b/crates/certified/roots/uorust_certified_method_option_is_some.rs @@ -862,7 +862,7 @@ pub enum Adt0 { #[derive(Clone)] pub enum Adt1 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -883,20 +883,21 @@ pub enum Adt4 { C3(u64), C4(Adt5), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_method_outcome_is_ok.rs b/crates/certified/roots/uorust_certified_method_outcome_is_ok.rs index ab02297d..c3865322 100644 --- a/crates/certified/roots/uorust_certified_method_outcome_is_ok.rs +++ b/crates/certified/roots/uorust_certified_method_outcome_is_ok.rs @@ -862,7 +862,7 @@ pub enum Adt0 { #[derive(Clone)] pub enum Adt1 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -883,20 +883,21 @@ pub enum Adt4 { C3(u64), C4(Adt5), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_method_outcome_ok.rs b/crates/certified/roots/uorust_certified_method_outcome_ok.rs index 47d1a4d2..08477244 100644 --- a/crates/certified/roots/uorust_certified_method_outcome_ok.rs +++ b/crates/certified/roots/uorust_certified_method_outcome_ok.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -891,7 +892,7 @@ pub enum Adt2 { #[derive(Clone)] pub enum Adt3 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -1465,55 +1466,63 @@ pub fn f1(v0: Adt16, v1: Adt2, v2: Adt69, v3: Str) -> R { } pub fn f2(v0: Adt0, v1: Str) -> Str { - let a18 = List::cons(Str::lit("(ctor Option.some ["), List::cons(f7(v0), List::cons(Str::lit("] "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))))); - let a19 = Str::lit(""); - join(a18, a19) + let a20 = { + let a18 = List::cons(Str::lit("(ctor Option.some ["), List::cons(f7(v0), List::::nil())); + let a19 = List::cons(Str::lit("] "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))); + append_list(a18, a19) + }; + let a21 = Str::lit(""); + join(a20, a21) } pub fn f3(v0: Adt0) -> Str { - let a20 = List::cons(Str::lit("(ctor Option.none ["), List::cons(f7(v0), List::cons(Str::lit("])"), List::::nil()))); - let a21 = Str::lit(""); - join(a20, a21) + let a24 = { + let a22 = List::cons(Str::lit("(ctor Option.none ["), List::::nil()); + let a23 = List::cons(f7(v0), List::cons(Str::lit("])"), List::::nil())); + append_list(a22, a23) + }; + let a25 = Str::lit(""); + join(a24, a25) } pub fn f4(v0: Adt0) -> Adt0 { - Adt0::C12(std::rc::Rc::new(v0)) + Adt0::C13(std::rc::Rc::new(v0)) } pub fn f5(v0: Str, v1: List) -> R { let v2: u64 = f8(f9(f10(v1.clone(), v0.clone()))?, 0u64); - let m28 = { - let a24 = { - let a22 = v2; - let a23 = 1u64; - nat_add(a22, a23)? + let m32 = { + let a28 = { + let a26 = v2; + let a27 = 1u64; + nat_add(a26, a27)? }; - let a25 = 4294967296u64; - if nat_lt(a24, a25) { + let a29 = 4294967296u64; + if nat_lt(a28, a29) { Some({ - let a26 = v2; - let a27 = 1u64; - nat_add(a26, a27)? + let a30 = v2; + let a31 = 1u64; + nat_add(a30, a31)? }) } else { None:: } }; - match m28 { + match m32 { None => { - let m34 = f11(f12(f13(1u64, { - let a32 = { - let a30 = { - let a29 = v1.clone(); - length_list(a29) + let m38 = f11(f12(f13(1u64, { + let a36 = { + let a34 = { + let a33 = v1.clone(); + length_list(a33) }; - let a31 = 2u64; - nat_add(a30, a31)? + let a35 = 2u64; + nat_add(a34, a35)? }; - let a33 = 1u64; - nat_sub(a32, a33) + let a37 = 1u64; + nat_sub(a36, a37) })?, v0)?, v1); - match m34 { + match m38 { None => { Ok(Str::lit("")) } @@ -1523,60 +1532,60 @@ pub fn f5(v0: Str, v1: List) -> R { } } Some(v4) => { - let a35 = List::cons(v0, List::cons(f14(v4)?, List::::nil())); - let a36 = Str::lit(""); - Ok(join(a35, a36)) + let a39 = List::cons(v0, List::cons(f14(v4)?, List::::nil())); + let a40 = Str::lit(""); + Ok(join(a39, a40)) } } } pub fn f6(v0: Adt16, v1: Adt2, v2: Adt69, v3: Str, v4: List) -> List { f15({ - let a50 = { - let a48 = { - let a45 = { - let a42 = { - let a39 = f16(f17(match v0.clone() { - Adt16::C0(_, _, _, _, h37, _, _, _, _, _, _, _, _, _, _, _, _) => { - h37 + let a54 = { + let a52 = { + let a49 = { + let a46 = { + let a43 = f16(f17(match v0.clone() { + Adt16::C0(_, _, _, _, h41, _, _, _, _, _, _, _, _, _, _, _, _) => { + h41 } })); - let a40 = match v0 { - Adt16::C0(_, _, _, _, _, _, _, _, h38, _, _, _, _, _, _, _, _) => { - h38 + let a44 = match v0 { + Adt16::C0(_, _, _, _, _, _, _, _, h42, _, _, _, _, _, _, _, _) => { + h42 } }; - append_list(a39, a40) + append_list(a43, a44) }; - let a43 = f18(f19(match v1.clone() { - Adt2::C0(_, h41, _, _) => { - h41 + let a47 = f18(f19(match v1.clone() { + Adt2::C0(_, h45, _, _) => { + h45 } })); - append_list(a42, a43) + append_list(a46, a47) }; - let a46 = match v1 { - Adt2::C0(_, _, _, h44) => { - h44 + let a50 = match v1 { + Adt2::C0(_, _, _, h48) => { + h48 } }; - append_list(a45, a46) + append_list(a49, a50) }; - let a49 = match v2 { - Adt69::C0(_, _, h47, _, _, _, _) => { - h47 + let a53 = match v2 { + Adt69::C0(_, _, h51, _, _, _, _) => { + h51 } }; - append_list(a48, a49) + append_list(a52, a53) }; - let a51 = v4; - append_list(a50, a51) + let a55 = v4; + append_list(a54, a55) }, v3) } pub fn f7(v0: Adt0) -> Str { - let m52 = v0; - match m52 { + let m56 = v0; + match m56 { Adt0::C0 => { Str::lit("Unit") } @@ -1593,110 +1602,141 @@ pub fn f7(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + Str::lit("Int") } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - let a53 = List::cons(f20(), List::cons(Str::lit("::ParseIntError"), List::::nil())); - let a54 = Str::lit(""); - join(a53, a54) + Str::lit("Nat") } Adt0::C10 => { - let a55 = List::cons(f20(), List::cons(Str::lit("::FilePath"), List::::nil())); - let a56 = Str::lit(""); - join(a55, a56) - } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r79) => { - let v6 = (*r79).clone(); - let a57 = List::cons(Str::lit("(Option "), List::cons(f7(v6), List::cons(Str::lit(")"), List::::nil()))); + let a57 = List::cons(f20(), List::cons(Str::lit("::ParseIntError"), List::::nil())); let a58 = Str::lit(""); join(a57, a58) } - Adt0::C13(r80, r81) => { - let v7 = (*r80).clone(); - let v8 = (*r81).clone(); - let a59 = List::cons(Str::lit("(Result "), List::cons(f7(v7), List::cons(Str::lit(" "), List::cons(f7(v8), List::cons(Str::lit(")"), List::::nil()))))); + Adt0::C11 => { + let a59 = List::cons(f20(), List::cons(Str::lit("::FilePath"), List::::nil())); let a60 = Str::lit(""); join(a59, a60) } - Adt0::C14(r82) => { - let v9 = (*r82).clone(); - let a61 = List::cons(Str::lit("(List "), List::cons(f7(v9), List::cons(Str::lit(")"), List::::nil()))); - let a62 = Str::lit(""); - join(a61, a62) - } - Adt0::C15(v10) => { - let a65 = List::cons(Str::lit("Tuple"), List::cons({ - let a63 = f21(v10); - let a64 = Str::lit(""); - join(a63, a64) - }, List::::nil())); - let a66 = Str::lit(""); - join(a65, a66) + Adt0::C12(v6) => { + v6 } - Adt0::C16(v11) => { - let a69 = List::cons(Str::lit("("), List::cons({ - let a67 = f22(v11); - let a68 = Str::lit(" * "); - join(a67, a68) - }, List::cons(Str::lit(")"), List::::nil()))); - let a70 = Str::lit(""); - join(a69, a70) - } - Adt0::C17(r83, r84, _) => { - let v12 = (*r83).clone(); - let v13 = (*r84).clone(); - let a71 = List::cons(Str::lit("(List Tuple"), List::cons(f23(v12), List::cons(f23(v13), List::cons(Str::lit(")"), List::::nil())))); + Adt0::C13(r97) => { + let v7 = (*r97).clone(); + let a63 = { + let a61 = List::cons(Str::lit("(Option "), List::::nil()); + let a62 = List::cons(f7(v7), List::cons(Str::lit(")"), List::::nil())); + append_list(a61, a62) + }; + let a64 = Str::lit(""); + join(a63, a64) + } + Adt0::C14(r98, r99) => { + let v8 = (*r98).clone(); + let v9 = (*r99).clone(); + let a67 = { + let a65 = List::cons(Str::lit("(Result "), List::cons(f7(v8), List::::nil())); + let a66 = List::cons(Str::lit(" "), List::cons(f7(v9), List::cons(Str::lit(")"), List::::nil()))); + append_list(a65, a66) + }; + let a68 = Str::lit(""); + join(a67, a68) + } + Adt0::C15(r100) => { + let v10 = (*r100).clone(); + let a71 = { + let a69 = List::cons(Str::lit("(List "), List::::nil()); + let a70 = List::cons(f7(v10), List::cons(Str::lit(")"), List::::nil())); + append_list(a69, a70) + }; let a72 = Str::lit(""); join(a71, a72) } - Adt0::C18(r85, _) => { - let v15 = (*r85).clone(); - let a73 = List::cons(Str::lit("(List "), List::cons(f7(v15), List::cons(Str::lit(")"), List::::nil()))); - let a74 = Str::lit(""); - join(a73, a74) - } - Adt0::C19(v17, r86) => { - let v18 = (*r86).clone(); - let a77 = List::cons(Str::lit("(Fn ("), List::cons({ - let a75 = f24(v17); - let a76 = Str::lit(" "); - join(a75, a76) - }, List::cons(Str::lit(") "), List::cons(f7(v18), List::cons(Str::lit(")"), List::::nil()))))); - let a78 = Str::lit(""); - join(a77, a78) + Adt0::C16(v11) => { + let a75 = List::cons(Str::lit("Tuple"), List::cons({ + let a73 = f21(v11); + let a74 = Str::lit(""); + join(a73, a74) + }, List::::nil())); + let a76 = Str::lit(""); + join(a75, a76) + } + Adt0::C17(v12) => { + let a81 = { + let a79 = List::cons(Str::lit("("), List::::nil()); + let a80 = List::cons({ + let a77 = f22(v12); + let a78 = Str::lit(" * "); + join(a77, a78) + }, List::cons(Str::lit(")"), List::::nil())); + append_list(a79, a80) + }; + let a82 = Str::lit(""); + join(a81, a82) + } + Adt0::C18(r101, r102, _) => { + let v13 = (*r101).clone(); + let v14 = (*r102).clone(); + let a85 = { + let a83 = List::cons(Str::lit("(List Tuple"), List::cons(f23(v13), List::::nil())); + let a84 = List::cons(f23(v14), List::cons(Str::lit(")"), List::::nil())); + append_list(a83, a84) + }; + let a86 = Str::lit(""); + join(a85, a86) + } + Adt0::C19(r103, _) => { + let v16 = (*r103).clone(); + let a89 = { + let a87 = List::cons(Str::lit("(List "), List::::nil()); + let a88 = List::cons(f7(v16), List::cons(Str::lit(")"), List::::nil())); + append_list(a87, a88) + }; + let a90 = Str::lit(""); + join(a89, a90) + } + Adt0::C20(v18, r104) => { + let v19 = (*r104).clone(); + let a95 = { + let a93 = List::cons(Str::lit("(Fn ("), List::cons({ + let a91 = f24(v18); + let a92 = Str::lit(" "); + join(a91, a92) + }, List::::nil())); + let a94 = List::cons(Str::lit(") "), List::cons(f7(v19), List::cons(Str::lit(")"), List::::nil()))); + append_list(a93, a94) + }; + let a96 = Str::lit(""); + join(a95, a96) } } } -pub fn f8(p91: List, p92: u64) -> u64 { - let m90 = (p91, p92); +pub fn f8(p109: List, p110: u64) -> u64 { + let m108 = (p109, p110); { - let mut m90 = m90; + let mut m108 = m108; loop { let step = { - let (v0, v1) = m90; - let m87 = v0; - match m87.uncons() { + let (v0, v1) = m108; + let m105 = v0; + match m105.uncons() { None => { Err::<(List, u64), u64>(v1) } Some((v2, v3)) => { Ok::<(List, u64), u64>((v3, { - let a88 = v1; - let a89 = v2; - if nat_le(a88, a89) { + let a106 = v1; + let a107 = v2; + if nat_le(a106, a107) { v2 } else { v1 @@ -1706,7 +1746,7 @@ pub fn f8(p91: List, p92: u64) -> u64 { } }; match step { - Ok(next) => { m90 = next; } + Ok(next) => { m108 = next; } Err(done) => break done, } } @@ -1714,14 +1754,14 @@ pub fn f8(p91: List, p92: u64) -> u64 { } pub fn f9(v0: List) -> R> { - let m93 = v0; - match m93.uncons() { + let m111 = v0; + match m111.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { - let m94 = f25(v1)?; - match m94 { + let m112 = f25(v1)?; + match m112 { None => { f9(v2) } @@ -1734,14 +1774,14 @@ pub fn f9(v0: List) -> R> { } pub fn f10(v0: List, v1: Str) -> List { - let m95 = v0; - match m95.uncons() { + let m113 = v0; + match m113.uncons() { None => { List::::nil() } Some((v2, v3)) => { - let m96 = f26(v2, v1.clone()); - match m96 { + let m114 = f26(v2, v1.clone()); + match m114 { None => { f10(v3, v1) } @@ -1753,21 +1793,21 @@ pub fn f10(v0: List, v1: Str) -> List { } } -pub fn f11(p100: List, v1: List) -> Option { - let m99 = p100; +pub fn f11(p118: List, v1: List) -> Option { + let m117 = p118; { - let mut m99 = m99; + let mut m117 = m117; loop { let step = { - let v0 = m99; - let m97 = v0; - match m97.uncons() { + let v0 = m117; + let m115 = v0; + match m115.uncons() { None => { Err::, Option>(None::) } Some((v2, v3)) => { - let a98 = f27(v1.clone(), v2.clone()); - if bool_not(a98) { + let a116 = f27(v1.clone(), v2.clone()); + if bool_not(a116) { Err::, Option>(Some(v2)) } else { Ok::, Option>(v3) @@ -1776,7 +1816,7 @@ pub fn f11(p100: List, v1: List) -> Option { } }; match step { - Ok(next) => { m99 = next; } + Ok(next) => { m117 = next; } Err(done) => break done, } } @@ -1784,46 +1824,46 @@ pub fn f11(p100: List, v1: List) -> Option { } pub fn f12(v0: List, v1: Str) -> R> { - let m101 = v0; - match m101.uncons() { + let m119 = v0; + match m119.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons({ - let a102 = List::cons(v1.clone(), List::cons(f14(v2)?, List::::nil())); - let a103 = Str::lit(""); - join(a102, a103) + let a120 = List::cons(v1.clone(), List::cons(f14(v2)?, List::::nil())); + let a121 = Str::lit(""); + join(a120, a121) }, f12(v3, v1)?)) } } } pub fn f13(v0: u64, v1: u64) -> R> { - let m104 = v1; - if m104 == 0 { + let m122 = v1; + if m122 == 0 { Ok(List::::nil()) } else { - let v2 = m104 - 1; + let v2 = m122 - 1; Ok(List::cons(v0, f13({ - let a105 = v0; - let a106 = 1u64; - nat_add(a105, a106)? + let a123 = v0; + let a124 = 1u64; + nat_add(a123, a124)? }, v2)?)) } } pub fn f14(v0: u64) -> R { Ok(f28({ - let a107 = v0; - let a108 = 1u64; - nat_add(a107, a108)? + let a125 = v0; + let a126 = 1u64; + nat_add(a125, a126)? }, v0)) } pub fn f15(v0: List, v1: Str) -> List { - let m109 = v0; - match m109.uncons() { + let m127 = v0; + match m127.uncons() { None => { List::::nil() } @@ -1838,19 +1878,19 @@ pub fn f15(v0: List, v1: Str) -> List { } pub fn f16(v0: List<(Str, Adt0)>) -> List { - let m110 = v0; - match m110.uncons() { + let m128 = v0; + match m128.uncons() { None => { List::::nil() } Some((v1, v2)) => { let v3: Str = { - let (h111, _) = v1; - h111 + let (h129, _) = v1; + h129 }; let _: Adt0 = { - let (_, h112) = v1; - h112 + let (_, h130) = v1; + h130 }; List::cons(v3, f16(v2)) } @@ -1858,15 +1898,15 @@ pub fn f16(v0: List<(Str, Adt0)>) -> List { } pub fn f17(v0: List) -> List<(Str, Adt0)> { - let m113 = v0; - match m113.uncons() { + let m131 = v0; + match m131.uncons() { None => { List::<(Str, Adt0)>::nil() } Some((v1, v2)) => { List::cons(match v1 { - Adt17::C0(_, h114) => { - h114 + Adt17::C0(_, h132) => { + h132 } }, f17(v2)) } @@ -1874,15 +1914,15 @@ pub fn f17(v0: List) -> List<(Str, Adt0)> { } pub fn f18(v0: List) -> List { - let m115 = v0; - match m115.uncons() { + let m133 = v0; + match m133.uncons() { None => { List::::nil() } Some((v1, v2)) => { List::cons(match v1 { - Adt14::C0(h116, _, _) => { - h116 + Adt14::C0(h134, _, _) => { + h134 } }, f18(v2)) } @@ -1890,15 +1930,15 @@ pub fn f18(v0: List) -> List { } pub fn f19(v0: List) -> List { - let m117 = v0; - match m117.uncons() { + let m135 = v0; + match m135.uncons() { None => { List::::nil() } Some((v1, v2)) => { List::cons(match v1 { - Adt13::C0(_, h118) => { - h118 + Adt13::C0(_, h136) => { + h136 } }, f19(v2)) } @@ -1910,8 +1950,8 @@ pub fn f20() -> Str { } pub fn f21(v0: List) -> List { - let m119 = v0; - match m119.uncons() { + let m137 = v0; + match m137.uncons() { None => { List::::nil() } @@ -1922,8 +1962,8 @@ pub fn f21(v0: List) -> List { } pub fn f22(v0: List) -> List { - let m120 = v0; - match m120.uncons() { + let m138 = v0; + match m138.uncons() { None => { List::::nil() } @@ -1934,8 +1974,8 @@ pub fn f22(v0: List) -> List { } pub fn f23(v0: Adt0) -> Str { - let m121 = v0; - match m121 { + let m139 = v0; + match m139 { Adt0::C0 => { Str::lit("Unit") } @@ -1952,92 +1992,107 @@ pub fn f23(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f30() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { + Str::lit("ParseIntError") + } + Adt0::C11 => { Str::lit("FilePath") } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r144) => { - let v6 = (*r144).clone(); - let a122 = List::cons(Str::lit("Option"), List::cons(f23(v6), List::::nil())); - let a123 = Str::lit(""); - join(a122, a123) - } - Adt0::C13(r145, r146) => { - let v7 = (*r145).clone(); - let v8 = (*r146).clone(); - let a124 = List::cons(Str::lit("Result"), List::cons(f23(v7), List::cons(f23(v8), List::::nil()))); - let a125 = Str::lit(""); - join(a124, a125) - } - Adt0::C14(r147) => { - let v9 = (*r147).clone(); - let a126 = List::cons(Str::lit("List"), List::cons(f23(v9), List::::nil())); - let a127 = Str::lit(""); - join(a126, a127) - } - Adt0::C15(v10) => { - let a130 = List::cons(Str::lit("Tuple"), List::cons({ - let a128 = f30(v10); - let a129 = Str::lit(""); - join(a128, a129) - }, List::::nil())); - let a131 = Str::lit(""); - join(a130, a131) + Adt0::C12(v6) => { + v6 + } + Adt0::C13(r168) => { + let v7 = (*r168).clone(); + let a140 = List::cons(Str::lit("Option"), List::cons(f23(v7), List::::nil())); + let a141 = Str::lit(""); + join(a140, a141) + } + Adt0::C14(r169, r170) => { + let v8 = (*r169).clone(); + let v9 = (*r170).clone(); + let a144 = { + let a142 = List::cons(Str::lit("Result"), List::::nil()); + let a143 = List::cons(f23(v8), List::cons(f23(v9), List::::nil())); + append_list(a142, a143) + }; + let a145 = Str::lit(""); + join(a144, a145) + } + Adt0::C15(r171) => { + let v10 = (*r171).clone(); + let a146 = List::cons(Str::lit("List"), List::cons(f23(v10), List::::nil())); + let a147 = Str::lit(""); + join(a146, a147) } Adt0::C16(v11) => { - let a134 = List::cons(Str::lit("Pair"), List::cons({ - let a132 = f31(v11); - let a133 = Str::lit(""); - join(a132, a133) + let a150 = List::cons(Str::lit("Tuple"), List::cons({ + let a148 = f31(v11); + let a149 = Str::lit(""); + join(a148, a149) }, List::::nil())); - let a135 = Str::lit(""); - join(a134, a135) - } - Adt0::C17(r148, r149, _) => { - let v12 = (*r148).clone(); - let v13 = (*r149).clone(); - let a136 = List::cons(Str::lit("ListTuple"), List::cons(f23(v12), List::cons(f23(v13), List::::nil()))); - let a137 = Str::lit(""); - join(a136, a137) - } - Adt0::C18(r150, _) => { - let v15 = (*r150).clone(); - let a138 = List::cons(Str::lit("List"), List::cons(f23(v15), List::::nil())); - let a139 = Str::lit(""); - join(a138, a139) - } - Adt0::C19(v17, r151) => { - let v18 = (*r151).clone(); - let a142 = List::cons(Str::lit("Fn"), List::cons({ - let a140 = f32(v17); - let a141 = Str::lit(""); - join(a140, a141) - }, List::cons(Str::lit("To"), List::cons(f23(v18), List::::nil())))); - let a143 = Str::lit(""); - join(a142, a143) + let a151 = Str::lit(""); + join(a150, a151) + } + Adt0::C17(v12) => { + let a154 = List::cons(Str::lit("Pair"), List::cons({ + let a152 = f32(v12); + let a153 = Str::lit(""); + join(a152, a153) + }, List::::nil())); + let a155 = Str::lit(""); + join(a154, a155) + } + Adt0::C18(r172, r173, _) => { + let v13 = (*r172).clone(); + let v14 = (*r173).clone(); + let a158 = { + let a156 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a157 = List::cons(f23(v13), List::cons(f23(v14), List::::nil())); + append_list(a156, a157) + }; + let a159 = Str::lit(""); + join(a158, a159) + } + Adt0::C19(r174, _) => { + let v16 = (*r174).clone(); + let a160 = List::cons(Str::lit("List"), List::cons(f23(v16), List::::nil())); + let a161 = Str::lit(""); + join(a160, a161) + } + Adt0::C20(v18, r175) => { + let v19 = (*r175).clone(); + let a166 = { + let a164 = List::cons(Str::lit("Fn"), List::cons({ + let a162 = f33(v18); + let a163 = Str::lit(""); + join(a162, a163) + }, List::::nil())); + let a165 = List::cons(Str::lit("To"), List::cons(f23(v19), List::::nil())); + append_list(a164, a165) + }; + let a167 = Str::lit(""); + join(a166, a167) } } } pub fn f24(v0: List) -> List { - let m152 = v0; - match m152.uncons() { + let m176 = v0; + match m176.uncons() { None => { List::::nil() } @@ -2048,8 +2103,8 @@ pub fn f24(v0: List) -> List { } pub fn f25(v0: Str) -> R> { - let m153 = f33(v0, 4294967295u64)?; - match m153 { + let m177 = f34(v0, 4294967295u64)?; + match m177 { Ok(v1) => { Ok(Some(v1)) } @@ -2061,42 +2116,42 @@ pub fn f25(v0: Str) -> R> { pub fn f26(v0: Str, v1: Str) -> Option { let v2: Bytes = { - let a154 = v0; - utf8_encode(a154) + let a178 = v0; + utf8_encode(a178) }; let v3: Bytes = { - let a155 = v1; - utf8_encode(a155) + let a179 = v1; + utf8_encode(a179) }; - if f34(v2.clone(), 0u64, v3.clone()) { - Some(f35(v2.clone(), { - let a156 = v3; - length_bytes(a156) + if f35(v2.clone(), 0u64, v3.clone()) { + Some(f36(v2.clone(), { + let a180 = v3; + length_bytes(a180) }, { - let a157 = v2; - length_bytes(a157) + let a181 = v2; + length_bytes(a181) })) } else { None:: } } -pub fn f27(p162: List, v1: Str) -> bool { - let m161 = p162; +pub fn f27(p186: List, v1: Str) -> bool { + let m185 = p186; { - let mut m161 = m161; + let mut m185 = m185; loop { let step = { - let v0 = m161; - let m158 = v0; - match m158.uncons() { + let v0 = m185; + let m182 = v0; + match m182.uncons() { None => { Err::, bool>(false) } Some((v2, v3)) => { - let a159 = v2; - let a160 = v1.clone(); - if equal(a159, a160) { + let a183 = v2; + let a184 = v1.clone(); + if equal(a183, a184) { Err::, bool>(true) } else { Ok::, bool>(v3) @@ -2105,7 +2160,7 @@ pub fn f27(p162: List, v1: Str) -> bool { } }; match step { - Ok(next) => { m161 = next; } + Ok(next) => { m185 = next; } Err(done) => break done, } } @@ -2113,152 +2168,156 @@ pub fn f27(p162: List, v1: Str) -> bool { } pub fn f28(v0: u64, v1: u64) -> Str { - let m163 = v0; - if m163 == 0 { + let m187 = v0; + if m187 == 0 { Str::lit("") } else { - let v2 = m163 - 1; - let a164 = v1; - let a165 = 10u64; - if nat_lt(a164, a165) { - f36(v1) + let v2 = m187 - 1; + let a188 = v1; + let a189 = 10u64; + if nat_lt(a188, a189) { + f37(v1) } else { - let a172 = List::cons(f28(v2, { - let a166 = v1; - let a167 = 10u64; - let a168 = 0u64; - nat_quot(a166, a167, a168) - }), List::cons(f36({ - let a169 = v1; - let a170 = 10u64; - let a171 = 0u64; - nat_rem(a169, a170, a171) + let a196 = List::cons(f28(v2, { + let a190 = v1; + let a191 = 10u64; + let a192 = 0u64; + nat_quot(a190, a191, a192) + }), List::cons(f37({ + let a193 = v1; + let a194 = 10u64; + let a195 = 0u64; + nat_rem(a193, a194, a195) }), List::::nil())); - let a173 = Str::lit(""); - join(a172, a173) + let a197 = Str::lit(""); + join(a196, a197) } } } pub fn f29(v0: Str, v1: Str) -> bool { - f34({ - let a174 = v0; - utf8_encode(a174) + f35({ + let a198 = v0; + utf8_encode(a198) }, 0u64, { - let a175 = v1; - utf8_encode(a175) + let a199 = v1; + utf8_encode(a199) }) } -pub fn f30(v0: List) -> List { - let m176 = v0; - match m176.uncons() { +pub fn f30() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f31(v0: List) -> List { + let m200 = v0; + match m200.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f23(v1), f30(v2)) + List::cons(f23(v1), f31(v2)) } } } -pub fn f31(v0: List) -> List { - let m177 = v0; - match m177.uncons() { +pub fn f32(v0: List) -> List { + let m201 = v0; + match m201.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f23(v1), f31(v2)) + List::cons(f23(v1), f32(v2)) } } } -pub fn f32(v0: List) -> List { - let m178 = v0; - match m178.uncons() { +pub fn f33(v0: List) -> List { + let m202 = v0; + match m202.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f23(v1), f32(v2)) + List::cons(f23(v1), f33(v2)) } } } -pub fn f33(v0: Str, v1: u64) -> R> { +pub fn f34(v0: Str, v1: u64) -> R> { let v2: Bytes = { - let a179 = v0; - utf8_encode(a179) + let a203 = v0; + utf8_encode(a203) }; let v3: u64 = { - let a180 = v2.clone(); - length_bytes(a180) + let a204 = v2.clone(); + length_bytes(a204) }; - let a181 = v3; - let a182 = 0u64; - if nat_eq(a181, a182) { + let a205 = v3; + let a206 = 0u64; + if nat_eq(a205, a206) { Ok(Err::(Adt79::C0)) } else { - let a183 = f37(v2.clone(), 0u64)?; - let a184 = 43u64; - if nat_eq(a183, a184) { - let a185 = v3; - let a186 = 1u64; - if nat_eq(a185, a186) { + let a207 = f38(v2.clone(), 0u64)?; + let a208 = 43u64; + if nat_eq(a207, a208) { + let a209 = v3; + let a210 = 1u64; + if nat_eq(a209, a210) { Ok(Err::(Adt79::C1)) } else { - f38(v3, v2, 1u64, 0u64, v1) + f39(v3, v2, 1u64, 0u64, v1) } } else { - f38(v3, v2, 0u64, 0u64, v1) + f39(v3, v2, 0u64, 0u64, v1) } } } -pub fn f34(v0: Bytes, v1: u64, v2: Bytes) -> bool { - let m191 = { - let a188 = v0; - let a189 = v1; - let a190 = { - let a187 = v2.clone(); - length_bytes(a187) +pub fn f35(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m215 = { + let a212 = v0; + let a213 = v1; + let a214 = { + let a211 = v2.clone(); + length_bytes(a211) }; - slice_bytes(a188, a189, a190) + slice_bytes(a212, a213, a214) }; - match m191 { + match m215 { None => { false } Some(v3) => { - let a192 = v3; - let a193 = v2; - equal(a192, a193) + let a216 = v3; + let a217 = v2; + equal(a216, a217) } } } -pub fn f35(v0: Bytes, v1: u64, v2: u64) -> Str { - let m199 = { - let a196 = v0; - let a197 = v1; - let a198 = { - let a194 = v2; - let a195 = v1; - nat_sub(a194, a195) +pub fn f36(v0: Bytes, v1: u64, v2: u64) -> Str { + let m223 = { + let a220 = v0; + let a221 = v1; + let a222 = { + let a218 = v2; + let a219 = v1; + nat_sub(a218, a219) }; - slice_bytes(a196, a197, a198) + slice_bytes(a220, a221, a222) }; - match m199 { + match m223 { None => { Str::lit("") } Some(v3) => { - let m201 = { - let a200 = v3; - utf8_decode(a200) + let m225 = { + let a224 = v3; + utf8_decode(a224) }; - match m201 { + match m225 { None => { Str::lit("") } @@ -2270,50 +2329,50 @@ pub fn f35(v0: Bytes, v1: u64, v2: u64) -> Str { } } -pub fn f36(v0: u64) -> Str { - let a202 = v0; - let a203 = 0u64; - if nat_eq(a202, a203) { +pub fn f37(v0: u64) -> Str { + let a226 = v0; + let a227 = 0u64; + if nat_eq(a226, a227) { Str::lit("0") } else { - let a204 = v0; - let a205 = 1u64; - if nat_eq(a204, a205) { + let a228 = v0; + let a229 = 1u64; + if nat_eq(a228, a229) { Str::lit("1") } else { - let a206 = v0; - let a207 = 2u64; - if nat_eq(a206, a207) { + let a230 = v0; + let a231 = 2u64; + if nat_eq(a230, a231) { Str::lit("2") } else { - let a208 = v0; - let a209 = 3u64; - if nat_eq(a208, a209) { + let a232 = v0; + let a233 = 3u64; + if nat_eq(a232, a233) { Str::lit("3") } else { - let a210 = v0; - let a211 = 4u64; - if nat_eq(a210, a211) { + let a234 = v0; + let a235 = 4u64; + if nat_eq(a234, a235) { Str::lit("4") } else { - let a212 = v0; - let a213 = 5u64; - if nat_eq(a212, a213) { + let a236 = v0; + let a237 = 5u64; + if nat_eq(a236, a237) { Str::lit("5") } else { - let a214 = v0; - let a215 = 6u64; - if nat_eq(a214, a215) { + let a238 = v0; + let a239 = 6u64; + if nat_eq(a238, a239) { Str::lit("6") } else { - let a216 = v0; - let a217 = 7u64; - if nat_eq(a216, a217) { + let a240 = v0; + let a241 = 7u64; + if nat_eq(a240, a241) { Str::lit("7") } else { - let a218 = v0; - let a219 = 8u64; - if nat_eq(a218, a219) { + let a242 = v0; + let a243 = 8u64; + if nat_eq(a242, a243) { Str::lit("8") } else { Str::lit("9") @@ -2328,197 +2387,197 @@ pub fn f36(v0: u64) -> Str { } } -pub fn f37(v0: Bytes, v1: u64) -> R { - let m222 = { - let a220 = v0; - let a221 = v1; - index_bytes(a220, a221) +pub fn f38(v0: Bytes, v1: u64) -> R { + let m246 = { + let a244 = v0; + let a245 = v1; + index_bytes(a244, a245) }; - match m222 { + match m246 { None => { Ok(256u64) } Some(v2) => { let v3: u8 = v2; - let a267 = { - let a243 = { - let a231 = { - let a225 = { - let a223 = v3; - let a224 = 128u8; - fixed_u8::bit_and(a223, a224) + let a291 = { + let a267 = { + let a255 = { + let a249 = { + let a247 = v3; + let a248 = 128u8; + fixed_u8::bit_and(a247, a248) }; - let a226 = 128u8; - if equal(a225, a226) { + let a250 = 128u8; + if equal(a249, a250) { 128u64 } else { 0u64 } }; - let a232 = { - let a229 = { - let a227 = v3; - let a228 = 64u8; - fixed_u8::bit_and(a227, a228) + let a256 = { + let a253 = { + let a251 = v3; + let a252 = 64u8; + fixed_u8::bit_and(a251, a252) }; - let a230 = 64u8; - if equal(a229, a230) { + let a254 = 64u8; + if equal(a253, a254) { 64u64 } else { 0u64 } }; - nat_add(a231, a232)? + nat_add(a255, a256)? }; - let a244 = { - let a241 = { - let a235 = { - let a233 = v3; - let a234 = 32u8; - fixed_u8::bit_and(a233, a234) + let a268 = { + let a265 = { + let a259 = { + let a257 = v3; + let a258 = 32u8; + fixed_u8::bit_and(a257, a258) }; - let a236 = 32u8; - if equal(a235, a236) { + let a260 = 32u8; + if equal(a259, a260) { 32u64 } else { 0u64 } }; - let a242 = { - let a239 = { - let a237 = v3; - let a238 = 16u8; - fixed_u8::bit_and(a237, a238) + let a266 = { + let a263 = { + let a261 = v3; + let a262 = 16u8; + fixed_u8::bit_and(a261, a262) }; - let a240 = 16u8; - if equal(a239, a240) { + let a264 = 16u8; + if equal(a263, a264) { 16u64 } else { 0u64 } }; - nat_add(a241, a242)? + nat_add(a265, a266)? }; - nat_add(a243, a244)? + nat_add(a267, a268)? }; - let a268 = { - let a265 = { - let a253 = { - let a247 = { - let a245 = v3; - let a246 = 8u8; - fixed_u8::bit_and(a245, a246) + let a292 = { + let a289 = { + let a277 = { + let a271 = { + let a269 = v3; + let a270 = 8u8; + fixed_u8::bit_and(a269, a270) }; - let a248 = 8u8; - if equal(a247, a248) { + let a272 = 8u8; + if equal(a271, a272) { 8u64 } else { 0u64 } }; - let a254 = { - let a251 = { - let a249 = v3; - let a250 = 4u8; - fixed_u8::bit_and(a249, a250) + let a278 = { + let a275 = { + let a273 = v3; + let a274 = 4u8; + fixed_u8::bit_and(a273, a274) }; - let a252 = 4u8; - if equal(a251, a252) { + let a276 = 4u8; + if equal(a275, a276) { 4u64 } else { 0u64 } }; - nat_add(a253, a254)? + nat_add(a277, a278)? }; - let a266 = { - let a263 = { - let a257 = { - let a255 = v3; - let a256 = 2u8; - fixed_u8::bit_and(a255, a256) + let a290 = { + let a287 = { + let a281 = { + let a279 = v3; + let a280 = 2u8; + fixed_u8::bit_and(a279, a280) }; - let a258 = 2u8; - if equal(a257, a258) { + let a282 = 2u8; + if equal(a281, a282) { 2u64 } else { 0u64 } }; - let a264 = { - let a261 = { - let a259 = v3; - let a260 = 1u8; - fixed_u8::bit_and(a259, a260) + let a288 = { + let a285 = { + let a283 = v3; + let a284 = 1u8; + fixed_u8::bit_and(a283, a284) }; - let a262 = 1u8; - if equal(a261, a262) { + let a286 = 1u8; + if equal(a285, a286) { 1u64 } else { 0u64 } }; - nat_add(a263, a264)? + nat_add(a287, a288)? }; - nat_add(a265, a266)? + nat_add(a289, a290)? }; - nat_add(a267, a268) + nat_add(a291, a292) } } } -pub fn f38(p288: u64, v1: Bytes, p289: u64, p290: u64, v4: u64) -> R> { - let m287 = (p288, (p289, p290)); +pub fn f39(p312: u64, v1: Bytes, p313: u64, p314: u64, v4: u64) -> R> { + let m311 = (p312, (p313, p314)); { - let mut m287 = m287; + let mut m311 = m311; loop { let step = { - let (v0, (v2, v3)) = m287; - let m269 = v0; - if m269 == 0 { + let (v0, (v2, v3)) = m311; + let m293 = v0; + if m293 == 0 { Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) } else { - let v5 = m269 - 1; - let a271 = { - let a270 = v1.clone(); - length_bytes(a270) + let v5 = m293 - 1; + let a295 = { + let a294 = v1.clone(); + length_bytes(a294) }; - let a272 = v2; - if nat_le(a271, a272) { + let a296 = v2; + if nat_le(a295, a296) { Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) } else { - let v6: u64 = f37(v1.clone(), v2)?; - let a273 = 48u64; - let a274 = v6; - if if nat_le(a273, a274) { - let a275 = v6; - let a276 = 57u64; - nat_le(a275, a276) + let v6: u64 = f38(v1.clone(), v2)?; + let a297 = 48u64; + let a298 = v6; + if if nat_le(a297, a298) { + let a299 = v6; + let a300 = 57u64; + nat_le(a299, a300) } else { false } { let v7: u64 = { - let a281 = { - let a277 = v3; - let a278 = 10u64; - nat_mul(a277, a278)? + let a305 = { + let a301 = v3; + let a302 = 10u64; + nat_mul(a301, a302)? }; - let a282 = { - let a279 = v6; - let a280 = 48u64; - nat_sub(a279, a280) + let a306 = { + let a303 = v6; + let a304 = 48u64; + nat_sub(a303, a304) }; - nat_add(a281, a282)? + nat_add(a305, a306)? }; - let a283 = v4; - let a284 = v7; - if nat_lt(a283, a284) { + let a307 = v4; + let a308 = v7; + if nat_lt(a307, a308) { Err::<(u64, (u64, u64)), R>>(Ok(Err::(Adt79::C2))) } else { Ok::<(u64, (u64, u64)), R>>((v5, ({ - let a285 = v2; - let a286 = 1u64; - nat_add(a285, a286)? + let a309 = v2; + let a310 = 1u64; + nat_add(a309, a310)? }, v7))) } } else { @@ -2528,7 +2587,7 @@ pub fn f38(p288: u64, v1: Bytes, p289: u64, p290: u64, v4: u64) -> R { m287 = next; } + Ok(next) => { m311 = next; } Err(done) => break done, } } diff --git a/crates/certified/roots/uorust_certified_method_str_is_empty.rs b/crates/certified/roots/uorust_certified_method_str_is_empty.rs index 53cc0de2..f3ceb3b9 100644 --- a/crates/certified/roots/uorust_certified_method_str_is_empty.rs +++ b/crates/certified/roots/uorust_certified_method_str_is_empty.rs @@ -868,20 +868,21 @@ pub enum Adt1 { C3(u64), C4(Adt2), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -969,9 +970,13 @@ pub enum Adt13 { pub fn f0(v0: Str, v1: Adt0) -> Result<((Adt5, Adt1), Adt0), Adt9> { f1({ - let a1 = List::cons(Str::lit("(prim equal "), List::cons(v0, List::cons(Str::lit(" \"\" : Bool)"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("(prim equal "), List::::nil()); + let a2 = List::cons(v0, List::cons(Str::lit(" \"\" : Bool)"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) }, Adt1::C1, v1) } diff --git a/crates/certified/roots/uorust_certified_method_str_to_string.rs b/crates/certified/roots/uorust_certified_method_str_to_string.rs index 87c3566d..41884b1f 100644 --- a/crates/certified/roots/uorust_certified_method_str_to_string.rs +++ b/crates/certified/roots/uorust_certified_method_str_to_string.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] diff --git a/crates/certified/roots/uorust_certified_module_path.rs b/crates/certified/roots/uorust_certified_module_path.rs index db938831..113b2225 100644 --- a/crates/certified/roots/uorust_certified_module_path.rs +++ b/crates/certified/roots/uorust_certified_module_path.rs @@ -893,112 +893,116 @@ pub enum Adt5 { } pub fn f0(v0: Adt0) -> R { - let a2 = List::cons(Str::lit("src/"), List::cons(f1(match v0 { - Adt0::C0(h1, _, _, _, _) => { - h1 - } - }, Str::lit("."), Str::lit("/"))?, List::cons(Str::lit(".lex.tex"), List::::nil()))); - let a3 = Str::lit(""); - Ok(join(a2, a3)) + let a4 = { + let a2 = List::cons(Str::lit("src/"), List::::nil()); + let a3 = List::cons(f1(match v0 { + Adt0::C0(h1, _, _, _, _) => { + h1 + } + }, Str::lit("."), Str::lit("/"))?, List::cons(Str::lit(".lex.tex"), List::::nil())); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + Ok(join(a4, a5)) } pub fn f1(v0: Str, v1: Str, v2: Str) -> R { - let a4 = f2(v0, v1)?; - let a5 = v2; - Ok(join(a4, a5)) + let a6 = f2(v0, v1)?; + let a7 = v2; + Ok(join(a6, a7)) } pub fn f2(v0: Str, v1: Str) -> R> { let v2: Bytes = { - let a6 = v0.clone(); - utf8_encode(a6) + let a8 = v0.clone(); + utf8_encode(a8) }; let v3: Bytes = { - let a7 = v1; - utf8_encode(a7) + let a9 = v1; + utf8_encode(a9) }; - let a9 = { - let a8 = v3.clone(); - length_bytes(a8) + let a11 = { + let a10 = v3.clone(); + length_bytes(a10) }; - let a10 = 0u64; - if nat_eq(a9, a10) { + let a12 = 0u64; + if nat_eq(a11, a12) { Ok(List::cons(Str::lit(""), { - let a11 = f3(v0)?; - let a12 = List::cons(Str::lit(""), List::::nil()); - append_list(a11, a12) + let a13 = f3(v0)?; + let a14 = List::cons(Str::lit(""), List::::nil()); + append_list(a13, a14) })) } else { f4({ - let a14 = { - let a13 = v2.clone(); - length_bytes(a13) + let a16 = { + let a15 = v2.clone(); + length_bytes(a15) }; - let a15 = 1u64; - nat_add(a14, a15)? + let a17 = 1u64; + nat_add(a16, a17)? }, v2, v3, 0u64, 0u64) } } pub fn f3(v0: Str) -> R> { let v1: Bytes = { - let a16 = v0; - utf8_encode(a16) + let a18 = v0; + utf8_encode(a18) }; f5({ - let a17 = v1.clone(); - length_bytes(a17) + let a19 = v1.clone(); + length_bytes(a19) }, v1, 0u64) } pub fn f4(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { - let m18 = v0; - if m18 == 0 { + let m20 = v0; + if m20 == 0 { Ok(List::cons(f6(v1.clone(), v3, { - let a19 = v1; - length_bytes(a19) + let a21 = v1; + length_bytes(a21) }), List::::nil())) } else { - let v5 = m18 - 1; - let a24 = { - let a20 = v1.clone(); - length_bytes(a20) + let v5 = m20 - 1; + let a26 = { + let a22 = v1.clone(); + length_bytes(a22) }; - let a25 = { - let a22 = v4; - let a23 = { - let a21 = v2.clone(); - length_bytes(a21) + let a27 = { + let a24 = v4; + let a25 = { + let a23 = v2.clone(); + length_bytes(a23) }; - nat_add(a22, a23)? + nat_add(a24, a25)? }; - if nat_lt(a24, a25) { + if nat_lt(a26, a27) { Ok(List::cons(f6(v1.clone(), v3, { - let a26 = v1; - length_bytes(a26) + let a28 = v1; + length_bytes(a28) }), List::::nil())) } else { if f7(v1.clone(), v4, v2.clone()) { Ok(List::cons(f6(v1.clone(), v3, v4), f4(v5, v1, v2.clone(), { - let a28 = v4; - let a29 = { - let a27 = v2.clone(); - length_bytes(a27) + let a30 = v4; + let a31 = { + let a29 = v2.clone(); + length_bytes(a29) }; - nat_add(a28, a29)? + nat_add(a30, a31)? }, { - let a31 = v4; - let a32 = { - let a30 = v2; - length_bytes(a30) + let a33 = v4; + let a34 = { + let a32 = v2; + length_bytes(a32) }; - nat_add(a31, a32)? + nat_add(a33, a34)? })?)) } else { f4(v5, v1, v2, v3, { - let a33 = v4; - let a34 = 1u64; - nat_add(a33, a34)? + let a35 = v4; + let a36 = 1u64; + nat_add(a35, a36)? }) } } @@ -1006,54 +1010,54 @@ pub fn f4(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { } pub fn f5(v0: u64, v1: Bytes, v2: u64) -> R> { - let m35 = v0; - if m35 == 0 { + let m37 = v0; + if m37 == 0 { Ok(List::::nil()) } else { - let v3 = m35 - 1; - let a37 = { - let a36 = v1.clone(); - length_bytes(a36) + let v3 = m37 - 1; + let a39 = { + let a38 = v1.clone(); + length_bytes(a38) }; - let a38 = v2; - if nat_le(a37, a38) { + let a40 = v2; + if nat_le(a39, a40) { Ok(List::::nil()) } else { let v4: u64 = f8(f9(v1.clone(), v2)?); Ok(List::cons(f6(v1.clone(), v2, { - let a39 = v2; - let a40 = v4; - nat_add(a39, a40)? - }), f5(v3, v1, { let a41 = v2; let a42 = v4; nat_add(a41, a42)? + }), f5(v3, v1, { + let a43 = v2; + let a44 = v4; + nat_add(a43, a44)? })?)) } } } pub fn f6(v0: Bytes, v1: u64, v2: u64) -> Str { - let m48 = { - let a45 = v0; - let a46 = v1; - let a47 = { - let a43 = v2; - let a44 = v1; - nat_sub(a43, a44) + let m50 = { + let a47 = v0; + let a48 = v1; + let a49 = { + let a45 = v2; + let a46 = v1; + nat_sub(a45, a46) }; - slice_bytes(a45, a46, a47) + slice_bytes(a47, a48, a49) }; - match m48 { + match m50 { None => { Str::lit("") } Some(v3) => { - let m50 = { - let a49 = v3; - utf8_decode(a49) + let m52 = { + let a51 = v3; + utf8_decode(a51) }; - match m50 { + match m52 { None => { Str::lit("") } @@ -1066,41 +1070,41 @@ pub fn f6(v0: Bytes, v1: u64, v2: u64) -> Str { } pub fn f7(v0: Bytes, v1: u64, v2: Bytes) -> bool { - let m55 = { - let a52 = v0; - let a53 = v1; - let a54 = { - let a51 = v2.clone(); - length_bytes(a51) + let m57 = { + let a54 = v0; + let a55 = v1; + let a56 = { + let a53 = v2.clone(); + length_bytes(a53) }; - slice_bytes(a52, a53, a54) + slice_bytes(a54, a55, a56) }; - match m55 { + match m57 { None => { false } Some(v3) => { - let a56 = v3; - let a57 = v2; - equal(a56, a57) + let a58 = v3; + let a59 = v2; + equal(a58, a59) } } } pub fn f8(v0: u64) -> u64 { - let a58 = v0; - let a59 = 128u64; - if nat_lt(a58, a59) { + let a60 = v0; + let a61 = 128u64; + if nat_lt(a60, a61) { 1u64 } else { - let a60 = v0; - let a61 = 224u64; - if nat_lt(a60, a61) { + let a62 = v0; + let a63 = 224u64; + if nat_lt(a62, a63) { 2u64 } else { - let a62 = v0; - let a63 = 240u64; - if nat_lt(a62, a63) { + let a64 = v0; + let a65 = 240u64; + if nat_lt(a64, a65) { 3u64 } else { 4u64 @@ -1110,140 +1114,140 @@ pub fn f8(v0: u64) -> u64 { } pub fn f9(v0: Bytes, v1: u64) -> R { - let m66 = { - let a64 = v0; - let a65 = v1; - index_bytes(a64, a65) + let m68 = { + let a66 = v0; + let a67 = v1; + index_bytes(a66, a67) }; - match m66 { + match m68 { None => { Ok(256u64) } Some(v2) => { let v3: u8 = v2; - let a111 = { - let a87 = { - let a75 = { - let a69 = { - let a67 = v3; - let a68 = 128u8; - fixed_u8::bit_and(a67, a68) + let a113 = { + let a89 = { + let a77 = { + let a71 = { + let a69 = v3; + let a70 = 128u8; + fixed_u8::bit_and(a69, a70) }; - let a70 = 128u8; - if equal(a69, a70) { + let a72 = 128u8; + if equal(a71, a72) { 128u64 } else { 0u64 } }; - let a76 = { - let a73 = { - let a71 = v3; - let a72 = 64u8; - fixed_u8::bit_and(a71, a72) + let a78 = { + let a75 = { + let a73 = v3; + let a74 = 64u8; + fixed_u8::bit_and(a73, a74) }; - let a74 = 64u8; - if equal(a73, a74) { + let a76 = 64u8; + if equal(a75, a76) { 64u64 } else { 0u64 } }; - nat_add(a75, a76)? + nat_add(a77, a78)? }; - let a88 = { - let a85 = { - let a79 = { - let a77 = v3; - let a78 = 32u8; - fixed_u8::bit_and(a77, a78) + let a90 = { + let a87 = { + let a81 = { + let a79 = v3; + let a80 = 32u8; + fixed_u8::bit_and(a79, a80) }; - let a80 = 32u8; - if equal(a79, a80) { + let a82 = 32u8; + if equal(a81, a82) { 32u64 } else { 0u64 } }; - let a86 = { - let a83 = { - let a81 = v3; - let a82 = 16u8; - fixed_u8::bit_and(a81, a82) + let a88 = { + let a85 = { + let a83 = v3; + let a84 = 16u8; + fixed_u8::bit_and(a83, a84) }; - let a84 = 16u8; - if equal(a83, a84) { + let a86 = 16u8; + if equal(a85, a86) { 16u64 } else { 0u64 } }; - nat_add(a85, a86)? + nat_add(a87, a88)? }; - nat_add(a87, a88)? + nat_add(a89, a90)? }; - let a112 = { - let a109 = { - let a97 = { - let a91 = { - let a89 = v3; - let a90 = 8u8; - fixed_u8::bit_and(a89, a90) + let a114 = { + let a111 = { + let a99 = { + let a93 = { + let a91 = v3; + let a92 = 8u8; + fixed_u8::bit_and(a91, a92) }; - let a92 = 8u8; - if equal(a91, a92) { + let a94 = 8u8; + if equal(a93, a94) { 8u64 } else { 0u64 } }; - let a98 = { - let a95 = { - let a93 = v3; - let a94 = 4u8; - fixed_u8::bit_and(a93, a94) + let a100 = { + let a97 = { + let a95 = v3; + let a96 = 4u8; + fixed_u8::bit_and(a95, a96) }; - let a96 = 4u8; - if equal(a95, a96) { + let a98 = 4u8; + if equal(a97, a98) { 4u64 } else { 0u64 } }; - nat_add(a97, a98)? + nat_add(a99, a100)? }; - let a110 = { - let a107 = { - let a101 = { - let a99 = v3; - let a100 = 2u8; - fixed_u8::bit_and(a99, a100) + let a112 = { + let a109 = { + let a103 = { + let a101 = v3; + let a102 = 2u8; + fixed_u8::bit_and(a101, a102) }; - let a102 = 2u8; - if equal(a101, a102) { + let a104 = 2u8; + if equal(a103, a104) { 2u64 } else { 0u64 } }; - let a108 = { - let a105 = { - let a103 = v3; - let a104 = 1u8; - fixed_u8::bit_and(a103, a104) + let a110 = { + let a107 = { + let a105 = v3; + let a106 = 1u8; + fixed_u8::bit_and(a105, a106) }; - let a106 = 1u8; - if equal(a105, a106) { + let a108 = 1u8; + if equal(a107, a108) { 1u64 } else { 0u64 } }; - nat_add(a107, a108)? + nat_add(a109, a110)? }; - nat_add(a109, a110)? + nat_add(a111, a112)? }; - nat_add(a111, a112) + nat_add(a113, a114) } } } diff --git a/crates/certified/roots/uorust_certified_name_taken.rs b/crates/certified/roots/uorust_certified_name_taken.rs new file mode 100644 index 00000000..85ab6f97 --- /dev/null +++ b/crates/certified/roots/uorust_certified_name_taken.rs @@ -0,0 +1,970 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn f0(v0: Str, v1: bool) -> bool { + let v2: bool = if v1 { + f1(v0.clone(), Str::lit("Tuple")) + } else { + false + }; + if if f2(f3(), v0.clone()) { + true + } else { + f1(v0, Str::lit("LexLean")) + } { + true + } else { + v2 + } +} + +pub fn f1(v0: Str, v1: Str) -> bool { + f4({ + let a1 = v0; + utf8_encode(a1) + }, 0u64, { + let a2 = v1; + utf8_encode(a2) + }) +} + +pub fn f2(p7: List, v1: Str) -> bool { + let m6 = p7; + { + let mut m6 = m6; + loop { + let step = { + let v0 = m6; + let m3 = v0; + match m3.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a4 = v2; + let a5 = v1.clone(); + if equal(a4, a5) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m6 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f3() -> List { + let a20 = { + let a12 = { + let a8 = List::cons(Str::lit("And"), List::cons(Str::lit("BitVec"), List::cons(Str::lit("Bool"), List::::nil()))); + let a9 = List::cons(Str::lit("ByteArray"), List::cons(Str::lit("ContractViolation"), List::cons(Str::lit("Except"), List::::nil()))); + append_list(a8, a9) + }; + let a13 = { + let a10 = List::cons(Str::lit("Iff"), List::cons(Str::lit("Int"), List::cons(Str::lit("Int16"), List::::nil()))); + let a11 = List::cons(Str::lit("Int32"), List::cons(Str::lit("Int64"), List::cons(Str::lit("Int8"), List::cons(Str::lit("List"), List::::nil())))); + append_list(a10, a11) + }; + append_list(a12, a13) + }; + let a21 = { + let a18 = { + let a14 = List::cons(Str::lit("Nat"), List::cons(Str::lit("Option"), List::cons(Str::lit("Ordering"), List::::nil()))); + let a15 = List::cons(Str::lit("Prod"), List::cons(Str::lit("Prop"), List::cons(Str::lit("ReasoningFailure"), List::cons(Str::lit("Result"), List::::nil())))); + append_list(a14, a15) + }; + let a19 = { + let a16 = List::cons(Str::lit("String"), List::cons(Str::lit("Type"), List::cons(Str::lit("UInt16"), List::::nil()))); + let a17 = List::cons(Str::lit("UInt32"), List::cons(Str::lit("UInt64"), List::cons(Str::lit("UInt8"), List::cons(Str::lit("Unit"), List::::nil())))); + append_list(a16, a17) + }; + append_list(a18, a19) + }; + append_list(a20, a21) +} + +pub fn f4(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m26 = { + let a23 = v0; + let a24 = v1; + let a25 = { + let a22 = v2.clone(); + length_bytes(a22) + }; + slice_bytes(a23, a24, a25) + }; + match m26 { + None => { + false + } + Some(v3) => { + let a27 = v3; + let a28 = v2; + equal(a27, a28) + } + } +} + +pub fn run(p0: Str, p1: bool) -> bool { + f0(p0, p1) +} diff --git a/crates/certified/roots/uorust_certified_named_in.rs b/crates/certified/roots/uorust_certified_named_in.rs index 38dfc514..84bc42da 100644 --- a/crates/certified/roots/uorust_certified_named_in.rs +++ b/crates/certified/roots/uorust_certified_named_in.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -929,7 +930,7 @@ pub fn f2(v0: Adt0) -> Option { Adt0::C5(_) => { None:: } - Adt0::C6 => { + Adt0::C6(_) => { None:: } Adt0::C7 => { @@ -944,16 +945,16 @@ pub fn f2(v0: Adt0) -> Option { Adt0::C10 => { None:: } - Adt0::C11(v5) => { - Some(v5) - } - Adt0::C12(_) => { + Adt0::C11 => { None:: } - Adt0::C13(_, _) => { + Adt0::C12(v6) => { + Some(v6) + } + Adt0::C13(_) => { None:: } - Adt0::C14(_) => { + Adt0::C14(_, _) => { None:: } Adt0::C15(_) => { @@ -962,15 +963,18 @@ pub fn f2(v0: Adt0) -> Option { Adt0::C16(_) => { None:: } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { None:: } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { None:: } Adt0::C19(_, _) => { None:: } + Adt0::C20(_, _) => { + None:: + } } } diff --git a/crates/certified/roots/uorust_certified_needs_address.rs b/crates/certified/roots/uorust_certified_needs_address.rs index e8e34401..e5ed117f 100644 --- a/crates/certified/roots/uorust_certified_needs_address.rs +++ b/crates/certified/roots/uorust_certified_needs_address.rs @@ -907,9 +907,13 @@ pub fn f1(v0: Str, v1: Str) -> Adt0 { Adt0::C9(v0) } else { Adt0::C9({ - let a3 = List::cons(v0, List::cons(Str::lit(": "), List::cons(v1, List::::nil()))); - let a4 = Str::lit(""); - join(a3, a4) + let a5 = { + let a3 = List::cons(v0, List::::nil()); + let a4 = List::cons(Str::lit(": "), List::cons(v1, List::::nil())); + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) }) } } diff --git a/crates/certified/roots/uorust_certified_needs_memory.rs b/crates/certified/roots/uorust_certified_needs_memory.rs index 8383b42f..b5ccec1d 100644 --- a/crates/certified/roots/uorust_certified_needs_memory.rs +++ b/crates/certified/roots/uorust_certified_needs_memory.rs @@ -907,9 +907,13 @@ pub fn f1(v0: Str, v1: Str) -> Adt0 { Adt0::C9(v0) } else { Adt0::C9({ - let a3 = List::cons(v0, List::cons(Str::lit(": "), List::cons(v1, List::::nil()))); - let a4 = Str::lit(""); - join(a3, a4) + let a5 = { + let a3 = List::cons(v0, List::::nil()); + let a4 = List::cons(Str::lit(": "), List::cons(v1, List::::nil())); + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) }) } } diff --git a/crates/certified/roots/uorust_certified_none_of.rs b/crates/certified/roots/uorust_certified_none_of.rs index c026e0c1..37e4b104 100644 --- a/crates/certified/roots/uorust_certified_none_of.rs +++ b/crates/certified/roots/uorust_certified_none_of.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -885,14 +886,18 @@ pub enum Adt1 { } pub fn f0(v0: Adt0) -> Str { - let a1 = List::cons(Str::lit("(ctor Option.none ["), List::cons(f1(v0), List::cons(Str::lit("])"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("(ctor Option.none ["), List::::nil()); + let a2 = List::cons(f1(v0), List::cons(Str::lit("])"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) } pub fn f1(v0: Adt0) -> Str { - let m3 = v0; - match m3 { + let m5 = v0; + match m5 { Adt0::C0 => { Str::lit("Unit") } @@ -909,89 +914,120 @@ pub fn f1(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + Str::lit("Int") } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - let a4 = List::cons(f2(), List::cons(Str::lit("::ParseIntError"), List::::nil())); - let a5 = Str::lit(""); - join(a4, a5) + Str::lit("Nat") } Adt0::C10 => { - let a6 = List::cons(f2(), List::cons(Str::lit("::FilePath"), List::::nil())); + let a6 = List::cons(f2(), List::cons(Str::lit("::ParseIntError"), List::::nil())); let a7 = Str::lit(""); join(a6, a7) } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r30) => { - let v6 = (*r30).clone(); - let a8 = List::cons(Str::lit("(Option "), List::cons(f1(v6), List::cons(Str::lit(")"), List::::nil()))); + Adt0::C11 => { + let a8 = List::cons(f2(), List::cons(Str::lit("::FilePath"), List::::nil())); let a9 = Str::lit(""); join(a8, a9) } - Adt0::C13(r31, r32) => { - let v7 = (*r31).clone(); - let v8 = (*r32).clone(); - let a10 = List::cons(Str::lit("(Result "), List::cons(f1(v7), List::cons(Str::lit(" "), List::cons(f1(v8), List::cons(Str::lit(")"), List::::nil()))))); - let a11 = Str::lit(""); - join(a10, a11) + Adt0::C12(v6) => { + v6 } - Adt0::C14(r33) => { - let v9 = (*r33).clone(); - let a12 = List::cons(Str::lit("(List "), List::cons(f1(v9), List::cons(Str::lit(")"), List::::nil()))); + Adt0::C13(r46) => { + let v7 = (*r46).clone(); + let a12 = { + let a10 = List::cons(Str::lit("(Option "), List::::nil()); + let a11 = List::cons(f1(v7), List::cons(Str::lit(")"), List::::nil())); + append_list(a10, a11) + }; let a13 = Str::lit(""); join(a12, a13) } - Adt0::C15(v10) => { - let a16 = List::cons(Str::lit("Tuple"), List::cons({ - let a14 = f3(v10); - let a15 = Str::lit(""); - join(a14, a15) - }, List::::nil())); + Adt0::C14(r47, r48) => { + let v8 = (*r47).clone(); + let v9 = (*r48).clone(); + let a16 = { + let a14 = List::cons(Str::lit("(Result "), List::cons(f1(v8), List::::nil())); + let a15 = List::cons(Str::lit(" "), List::cons(f1(v9), List::cons(Str::lit(")"), List::::nil()))); + append_list(a14, a15) + }; let a17 = Str::lit(""); join(a16, a17) } - Adt0::C16(v11) => { - let a20 = List::cons(Str::lit("("), List::cons({ - let a18 = f4(v11); - let a19 = Str::lit(" * "); - join(a18, a19) - }, List::cons(Str::lit(")"), List::::nil()))); + Adt0::C15(r49) => { + let v10 = (*r49).clone(); + let a20 = { + let a18 = List::cons(Str::lit("(List "), List::::nil()); + let a19 = List::cons(f1(v10), List::cons(Str::lit(")"), List::::nil())); + append_list(a18, a19) + }; let a21 = Str::lit(""); join(a20, a21) } - Adt0::C17(r34, r35, _) => { - let v12 = (*r34).clone(); - let v13 = (*r35).clone(); - let a22 = List::cons(Str::lit("(List Tuple"), List::cons(f5(v12), List::cons(f5(v13), List::cons(Str::lit(")"), List::::nil())))); - let a23 = Str::lit(""); - join(a22, a23) - } - Adt0::C18(r36, _) => { - let v15 = (*r36).clone(); - let a24 = List::cons(Str::lit("(List "), List::cons(f1(v15), List::cons(Str::lit(")"), List::::nil()))); + Adt0::C16(v11) => { + let a24 = List::cons(Str::lit("Tuple"), List::cons({ + let a22 = f3(v11); + let a23 = Str::lit(""); + join(a22, a23) + }, List::::nil())); let a25 = Str::lit(""); join(a24, a25) } - Adt0::C19(v17, r37) => { - let v18 = (*r37).clone(); - let a28 = List::cons(Str::lit("(Fn ("), List::cons({ - let a26 = f6(v17); - let a27 = Str::lit(" "); - join(a26, a27) - }, List::cons(Str::lit(") "), List::cons(f1(v18), List::cons(Str::lit(")"), List::::nil()))))); - let a29 = Str::lit(""); - join(a28, a29) + Adt0::C17(v12) => { + let a30 = { + let a28 = List::cons(Str::lit("("), List::::nil()); + let a29 = List::cons({ + let a26 = f4(v12); + let a27 = Str::lit(" * "); + join(a26, a27) + }, List::cons(Str::lit(")"), List::::nil())); + append_list(a28, a29) + }; + let a31 = Str::lit(""); + join(a30, a31) + } + Adt0::C18(r50, r51, _) => { + let v13 = (*r50).clone(); + let v14 = (*r51).clone(); + let a34 = { + let a32 = List::cons(Str::lit("(List Tuple"), List::cons(f5(v13), List::::nil())); + let a33 = List::cons(f5(v14), List::cons(Str::lit(")"), List::::nil())); + append_list(a32, a33) + }; + let a35 = Str::lit(""); + join(a34, a35) + } + Adt0::C19(r52, _) => { + let v16 = (*r52).clone(); + let a38 = { + let a36 = List::cons(Str::lit("(List "), List::::nil()); + let a37 = List::cons(f1(v16), List::cons(Str::lit(")"), List::::nil())); + append_list(a36, a37) + }; + let a39 = Str::lit(""); + join(a38, a39) + } + Adt0::C20(v18, r53) => { + let v19 = (*r53).clone(); + let a44 = { + let a42 = List::cons(Str::lit("(Fn ("), List::cons({ + let a40 = f6(v18); + let a41 = Str::lit(" "); + join(a40, a41) + }, List::::nil())); + let a43 = List::cons(Str::lit(") "), List::cons(f1(v19), List::cons(Str::lit(")"), List::::nil()))); + append_list(a42, a43) + }; + let a45 = Str::lit(""); + join(a44, a45) } } } @@ -1001,8 +1037,8 @@ pub fn f2() -> Str { } pub fn f3(v0: List) -> List { - let m38 = v0; - match m38.uncons() { + let m54 = v0; + match m54.uncons() { None => { List::::nil() } @@ -1013,8 +1049,8 @@ pub fn f3(v0: List) -> List { } pub fn f4(v0: List) -> List { - let m39 = v0; - match m39.uncons() { + let m55 = v0; + match m55.uncons() { None => { List::::nil() } @@ -1025,8 +1061,8 @@ pub fn f4(v0: List) -> List { } pub fn f5(v0: Adt0) -> Str { - let m40 = v0; - match m40 { + let m56 = v0; + match m56 { Adt0::C0 => { Str::lit("Unit") } @@ -1043,92 +1079,107 @@ pub fn f5(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f7() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { + Str::lit("ParseIntError") + } + Adt0::C11 => { Str::lit("FilePath") } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r63) => { - let v6 = (*r63).clone(); - let a41 = List::cons(Str::lit("Option"), List::cons(f5(v6), List::::nil())); - let a42 = Str::lit(""); - join(a41, a42) - } - Adt0::C13(r64, r65) => { - let v7 = (*r64).clone(); - let v8 = (*r65).clone(); - let a43 = List::cons(Str::lit("Result"), List::cons(f5(v7), List::cons(f5(v8), List::::nil()))); - let a44 = Str::lit(""); - join(a43, a44) - } - Adt0::C14(r66) => { - let v9 = (*r66).clone(); - let a45 = List::cons(Str::lit("List"), List::cons(f5(v9), List::::nil())); - let a46 = Str::lit(""); - join(a45, a46) - } - Adt0::C15(v10) => { - let a49 = List::cons(Str::lit("Tuple"), List::cons({ - let a47 = f7(v10); - let a48 = Str::lit(""); - join(a47, a48) - }, List::::nil())); - let a50 = Str::lit(""); - join(a49, a50) + Adt0::C12(v6) => { + v6 } - Adt0::C16(v11) => { - let a53 = List::cons(Str::lit("Pair"), List::cons({ - let a51 = f8(v11); - let a52 = Str::lit(""); - join(a51, a52) - }, List::::nil())); - let a54 = Str::lit(""); - join(a53, a54) - } - Adt0::C17(r67, r68, _) => { - let v12 = (*r67).clone(); - let v13 = (*r68).clone(); - let a55 = List::cons(Str::lit("ListTuple"), List::cons(f5(v12), List::cons(f5(v13), List::::nil()))); - let a56 = Str::lit(""); - join(a55, a56) - } - Adt0::C18(r69, _) => { - let v15 = (*r69).clone(); - let a57 = List::cons(Str::lit("List"), List::cons(f5(v15), List::::nil())); + Adt0::C13(r85) => { + let v7 = (*r85).clone(); + let a57 = List::cons(Str::lit("Option"), List::cons(f5(v7), List::::nil())); let a58 = Str::lit(""); join(a57, a58) } - Adt0::C19(v17, r70) => { - let v18 = (*r70).clone(); - let a61 = List::cons(Str::lit("Fn"), List::cons({ - let a59 = f9(v17); - let a60 = Str::lit(""); - join(a59, a60) - }, List::cons(Str::lit("To"), List::cons(f5(v18), List::::nil())))); + Adt0::C14(r86, r87) => { + let v8 = (*r86).clone(); + let v9 = (*r87).clone(); + let a61 = { + let a59 = List::cons(Str::lit("Result"), List::::nil()); + let a60 = List::cons(f5(v8), List::cons(f5(v9), List::::nil())); + append_list(a59, a60) + }; let a62 = Str::lit(""); join(a61, a62) } + Adt0::C15(r88) => { + let v10 = (*r88).clone(); + let a63 = List::cons(Str::lit("List"), List::cons(f5(v10), List::::nil())); + let a64 = Str::lit(""); + join(a63, a64) + } + Adt0::C16(v11) => { + let a67 = List::cons(Str::lit("Tuple"), List::cons({ + let a65 = f8(v11); + let a66 = Str::lit(""); + join(a65, a66) + }, List::::nil())); + let a68 = Str::lit(""); + join(a67, a68) + } + Adt0::C17(v12) => { + let a71 = List::cons(Str::lit("Pair"), List::cons({ + let a69 = f9(v12); + let a70 = Str::lit(""); + join(a69, a70) + }, List::::nil())); + let a72 = Str::lit(""); + join(a71, a72) + } + Adt0::C18(r89, r90, _) => { + let v13 = (*r89).clone(); + let v14 = (*r90).clone(); + let a75 = { + let a73 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a74 = List::cons(f5(v13), List::cons(f5(v14), List::::nil())); + append_list(a73, a74) + }; + let a76 = Str::lit(""); + join(a75, a76) + } + Adt0::C19(r91, _) => { + let v16 = (*r91).clone(); + let a77 = List::cons(Str::lit("List"), List::cons(f5(v16), List::::nil())); + let a78 = Str::lit(""); + join(a77, a78) + } + Adt0::C20(v18, r92) => { + let v19 = (*r92).clone(); + let a83 = { + let a81 = List::cons(Str::lit("Fn"), List::cons({ + let a79 = f10(v18); + let a80 = Str::lit(""); + join(a79, a80) + }, List::::nil())); + let a82 = List::cons(Str::lit("To"), List::cons(f5(v19), List::::nil())); + append_list(a81, a82) + }; + let a84 = Str::lit(""); + join(a83, a84) + } } } pub fn f6(v0: List) -> List { - let m71 = v0; - match m71.uncons() { + let m93 = v0; + match m93.uncons() { None => { List::::nil() } @@ -1138,38 +1189,42 @@ pub fn f6(v0: List) -> List { } } -pub fn f7(v0: List) -> List { - let m72 = v0; - match m72.uncons() { +pub fn f7() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f8(v0: List) -> List { + let m94 = v0; + match m94.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f7(v2)) + List::cons(f5(v1), f8(v2)) } } } -pub fn f8(v0: List) -> List { - let m73 = v0; - match m73.uncons() { +pub fn f9(v0: List) -> List { + let m95 = v0; + match m95.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f8(v2)) + List::cons(f5(v1), f9(v2)) } } } -pub fn f9(v0: List) -> List { - let m74 = v0; - match m74.uncons() { +pub fn f10(v0: List) -> List { + let m96 = v0; + match m96.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f9(v2)) + List::cons(f5(v1), f10(v2)) } } } diff --git a/crates/certified/roots/uorust_certified_of.rs b/crates/certified/roots/uorust_certified_of.rs index 65780085..1988ce86 100644 --- a/crates/certified/roots/uorust_certified_of.rs +++ b/crates/certified/roots/uorust_certified_of.rs @@ -856,9 +856,13 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: Str) -> Str { - let a1 = List::cons(Str::lit("(apply (project memory "), List::cons(v0, List::cons(Str::lit(") (project pointer allocation))"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("(apply (project memory "), List::::nil()); + let a2 = List::cons(v0, List::cons(Str::lit(") (project pointer allocation))"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) } pub fn run(p0: Str) -> Str { diff --git a/crates/certified/roots/uorust_certified_opt_of.rs b/crates/certified/roots/uorust_certified_opt_of.rs index 3f9c9e18..647bafb9 100644 --- a/crates/certified/roots/uorust_certified_opt_of.rs +++ b/crates/certified/roots/uorust_certified_opt_of.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -885,7 +886,7 @@ pub enum Adt1 { } pub fn f0(v0: Adt0) -> Adt0 { - Adt0::C12(std::rc::Rc::new(v0)) + Adt0::C13(std::rc::Rc::new(v0)) } pub fn run(p0: Adt0) -> Adt0 { diff --git a/crates/certified/roots/uorust_certified_params.rs b/crates/certified/roots/uorust_certified_params.rs index edd9de1a..ad4eadf4 100644 --- a/crates/certified/roots/uorust_certified_params.rs +++ b/crates/certified/roots/uorust_certified_params.rs @@ -882,9 +882,13 @@ pub fn f1(v0: List) -> List { } }; List::cons({ - let a4 = List::cons(v3, List::cons(Str::lit(" : "), List::cons(v4, List::::nil()))); - let a5 = Str::lit(""); - join(a4, a5) + let a6 = { + let a4 = List::cons(v3, List::::nil()); + let a5 = List::cons(Str::lit(" : "), List::cons(v4, List::::nil())); + append_list(a4, a5) + }; + let a7 = Str::lit(""); + join(a6, a7) }, f1(v2)) } } diff --git a/crates/certified/roots/uorust_certified_pascal.rs b/crates/certified/roots/uorust_certified_pascal.rs new file mode 100644 index 00000000..6aaf1100 --- /dev/null +++ b/crates/certified/roots/uorust_certified_pascal.rs @@ -0,0 +1,1442 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(Str, bool, bool), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, bool), +} + +pub fn f0(v0: List) -> R { + let v1: Str = Str::lit(""); + let v2: Str = f1(v0, v1)?; + if f2(v2.clone())? { + let a1 = List::cons(Str::lit("N"), List::cons(v2, List::::nil())); + let a2 = Str::lit(""); + Ok(join(a1, a2)) + } else { + Ok(v2) + } +} + +pub fn f1(p8: List, p9: Str) -> R { + let m7 = (p8, p9); + { + let mut m7 = m7; + loop { + let step = { + let (v0, v1) = m7; + let m3 = v0; + match m3.uncons() { + None => { + Err::<(List, Str), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: bool = true; + let v5: bool = false; + let v6: Adt0 = f3(f4(v2)?, Adt0::C0(v1, v5, v4))?; + let v7: Str = match v6.clone() { + Adt0::C0(h4, _, _) => { + h4 + } + }; + let _: bool = match v6.clone() { + Adt0::C0(_, h5, _) => { + h5 + } + }; + let _: bool = match v6 { + Adt0::C0(_, _, h6) => { + h6 + } + }; + Ok::<(List, Str), R>((v3, v7)) + } + } + }; + match step { + Ok(next) => { m7 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f2(v0: Str) -> R { + let m12 = { + let a10 = f4(v0)?; + let a11 = 0u64; + index_list(a10, a11) + }; + match m12 { + None => { + Ok(false) + } + Some(v1) => { + f5(v1) + } + } +} + +pub fn f3(p28: List, p29: Adt0) -> R { + let m27 = (p28, p29); + { + let mut m27 = m27; + loop { + let step = { + let (v0, v1) = m27; + let m13 = v0; + match m13.uncons() { + None => { + Err::<(List, Adt0), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: Str = match v1.clone() { + Adt0::C0(h14, _, _) => { + h14 + } + }; + let v5: bool = match v1.clone() { + Adt0::C0(_, h15, _) => { + h15 + } + }; + let v6: bool = match v1 { + Adt0::C0(_, _, h16) => { + h16 + } + }; + let a17 = f6(v2.clone())?; + if bool_not(a17) { + let v7: bool = true; + let v8: bool = false; + Ok::<(List, Adt0), R>((v3, Adt0::C0(v4, v8, v7))) + } else { + let v14: Adt1 = if v6 { + let v9: Str = { + let a18 = List::cons(v4, List::cons(f7(v2.clone())?, List::::nil())); + let a19 = Str::lit(""); + join(a18, a19) + }; + let v10: bool = false; + Adt1::C0(v9, v10) + } else { + let v13: Str = if if f8(v2.clone())? { + let a20 = v5; + bool_not(a20) + } else { + false + } { + let v11: Str = { + let a21 = List::cons(v4, List::cons(f9(v2.clone())?, List::::nil())); + let a22 = Str::lit(""); + join(a21, a22) + }; + v11 + } else { + let v12: Str = { + let a23 = List::cons(v4, List::cons(v2.clone(), List::::nil())); + let a24 = Str::lit(""); + join(a23, a24) + }; + v12 + }; + Adt1::C0(v13, v6) + }; + let v15: Str = match v14.clone() { + Adt1::C0(h25, _) => { + h25 + } + }; + let v16: bool = match v14 { + Adt1::C0(_, h26) => { + h26 + } + }; + let v17: bool = if f10(v2.clone())? { + true + } else { + f5(v2)? + }; + Ok::<(List, Adt0), R>((v3, Adt0::C0(v15, v17, v16))) + } + } + } + }; + match step { + Ok(next) => { m27 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f4(v0: Str) -> R> { + let v1: Bytes = { + let a30 = v0; + utf8_encode(a30) + }; + f11({ + let a31 = v1.clone(); + length_bytes(a31) + }, v1, 0u64) +} + +pub fn f5(v0: Str) -> R { + let v1: u64 = f12(v0)?; + let a32 = 48u64; + let a33 = v1; + if nat_le(a32, a33) { + let a34 = v1; + let a35 = 57u64; + Ok(nat_le(a34, a35)) + } else { + Ok(false) + } +} + +pub fn f6(v0: Str) -> R { + if f13(v0.clone())? { + Ok(true) + } else { + f5(v0) + } +} + +pub fn f7(v0: Str) -> R { + f14(v0, 97u64, Bytes::lit(&[0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a])) +} + +pub fn f8(v0: Str) -> R { + let v1: u64 = f12(v0)?; + let a36 = 65u64; + let a37 = v1; + if nat_le(a36, a37) { + let a38 = v1; + let a39 = 90u64; + Ok(nat_le(a38, a39)) + } else { + Ok(false) + } +} + +pub fn f9(v0: Str) -> R { + f14(v0, 65u64, Bytes::lit(&[0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a])) +} + +pub fn f10(v0: Str) -> R { + let v1: u64 = f12(v0)?; + let a40 = 97u64; + let a41 = v1; + if nat_le(a40, a41) { + let a42 = v1; + let a43 = 122u64; + Ok(nat_le(a42, a43)) + } else { + Ok(false) + } +} + +pub fn f11(v0: u64, v1: Bytes, v2: u64) -> R> { + let m44 = v0; + if m44 == 0 { + Ok(List::::nil()) + } else { + let v3 = m44 - 1; + let a46 = { + let a45 = v1.clone(); + length_bytes(a45) + }; + let a47 = v2; + if nat_le(a46, a47) { + Ok(List::::nil()) + } else { + let v4: u64 = f15(f16(v1.clone(), v2)?); + Ok(List::cons(f17(v1.clone(), v2, { + let a48 = v2; + let a49 = v4; + nat_add(a48, a49)? + }), f11(v3, v1, { + let a50 = v2; + let a51 = v4; + nat_add(a50, a51)? + })?)) + } + } +} + +pub fn f12(v0: Str) -> R { + f16({ + let a52 = v0; + utf8_encode(a52) + }, 0u64) +} + +pub fn f13(v0: Str) -> R { + if f8(v0.clone())? { + Ok(true) + } else { + f10(v0) + } +} + +pub fn f14(v0: Str, v1: u64, v2: Bytes) -> R { + let v3: Bytes = { + let a53 = v0.clone(); + utf8_encode(a53) + }; + let m57 = { + let a56 = f18({ + let a54 = v3.clone(); + length_bytes(a54) + }, v3, 0u64, v1, v2, { + let a55 = Str::lit(""); + utf8_encode(a55) + })?; + utf8_decode(a56) + }; + match m57 { + None => { + Ok(v0) + } + Some(v4) => { + Ok(v4) + } + } +} + +pub fn f15(v0: u64) -> u64 { + let a58 = v0; + let a59 = 128u64; + if nat_lt(a58, a59) { + 1u64 + } else { + let a60 = v0; + let a61 = 224u64; + if nat_lt(a60, a61) { + 2u64 + } else { + let a62 = v0; + let a63 = 240u64; + if nat_lt(a62, a63) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f16(v0: Bytes, v1: u64) -> R { + let m66 = { + let a64 = v0; + let a65 = v1; + index_bytes(a64, a65) + }; + match m66 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a111 = { + let a87 = { + let a75 = { + let a69 = { + let a67 = v3; + let a68 = 128u8; + fixed_u8::bit_and(a67, a68) + }; + let a70 = 128u8; + if equal(a69, a70) { + 128u64 + } else { + 0u64 + } + }; + let a76 = { + let a73 = { + let a71 = v3; + let a72 = 64u8; + fixed_u8::bit_and(a71, a72) + }; + let a74 = 64u8; + if equal(a73, a74) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a75, a76)? + }; + let a88 = { + let a85 = { + let a79 = { + let a77 = v3; + let a78 = 32u8; + fixed_u8::bit_and(a77, a78) + }; + let a80 = 32u8; + if equal(a79, a80) { + 32u64 + } else { + 0u64 + } + }; + let a86 = { + let a83 = { + let a81 = v3; + let a82 = 16u8; + fixed_u8::bit_and(a81, a82) + }; + let a84 = 16u8; + if equal(a83, a84) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a85, a86)? + }; + nat_add(a87, a88)? + }; + let a112 = { + let a109 = { + let a97 = { + let a91 = { + let a89 = v3; + let a90 = 8u8; + fixed_u8::bit_and(a89, a90) + }; + let a92 = 8u8; + if equal(a91, a92) { + 8u64 + } else { + 0u64 + } + }; + let a98 = { + let a95 = { + let a93 = v3; + let a94 = 4u8; + fixed_u8::bit_and(a93, a94) + }; + let a96 = 4u8; + if equal(a95, a96) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a97, a98)? + }; + let a110 = { + let a107 = { + let a101 = { + let a99 = v3; + let a100 = 2u8; + fixed_u8::bit_and(a99, a100) + }; + let a102 = 2u8; + if equal(a101, a102) { + 2u64 + } else { + 0u64 + } + }; + let a108 = { + let a105 = { + let a103 = v3; + let a104 = 1u8; + fixed_u8::bit_and(a103, a104) + }; + let a106 = 1u8; + if equal(a105, a106) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a107, a108)? + }; + nat_add(a109, a110)? + }; + nat_add(a111, a112) + } + } +} + +pub fn f17(v0: Bytes, v1: u64, v2: u64) -> Str { + let m118 = { + let a115 = v0; + let a116 = v1; + let a117 = { + let a113 = v2; + let a114 = v1; + nat_sub(a113, a114) + }; + slice_bytes(a115, a116, a117) + }; + match m118 { + None => { + Str::lit("") + } + Some(v3) => { + let m120 = { + let a119 = v3; + utf8_decode(a119) + }; + match m120 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f18(p143: u64, v1: Bytes, p144: u64, v3: u64, v4: Bytes, p145: Bytes) -> R { + let m142 = (p143, (p144, p145)); + { + let mut m142 = m142; + loop { + let step = { + let (v0, (v2, v5)) = m142; + let m121 = v0; + if m121 == 0 { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } else { + let v6 = m121 - 1; + let m125 = { + let a122 = v1.clone(); + let a123 = v2; + let a124 = 1u64; + slice_bytes(a122, a123, a124) + }; + match m125 { + None => { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } + Some(v7) => { + let v8: u64 = f16(v1.clone(), v2)?; + let v10: Bytes = { + let a126 = v3; + let a127 = v8; + if if nat_le(a126, a127) { + let a130 = v8; + let a131 = { + let a128 = v3; + let a129 = 26u64; + nat_add(a128, a129)? + }; + nat_lt(a130, a131) + } else { + false + } { + let m137 = { + let a134 = v4.clone(); + let a135 = { + let a132 = v8; + let a133 = v3; + nat_sub(a132, a133) + }; + let a136 = 1u64; + slice_bytes(a134, a135, a136) + }; + match m137 { + None => { + v7 + } + Some(v9) => { + v9 + } + } + } else { + v7 + } + }; + Ok::<(u64, (u64, Bytes)), R>((v6, ({ + let a138 = v2; + let a139 = 1u64; + nat_add(a138, a139)? + }, { + let a140 = v5; + let a141 = v10; + append_bytes(a140, a141) + }))) + } + } + } + }; + match step { + Ok(next) => { m142 = next; } + Err(done) => break done, + } + } + } +} + +pub fn run(p0: List) -> R { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_plain_cell.rs b/crates/certified/roots/uorust_certified_plain_cell.rs index 4c144e3e..39a74bae 100644 --- a/crates/certified/roots/uorust_certified_plain_cell.rs +++ b/crates/certified/roots/uorust_certified_plain_cell.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -903,11 +904,11 @@ pub fn f0(v0: Adt0) -> bool { true } Adt0::C5(_) => { - true - } - Adt0::C6 => { false } + Adt0::C6(_) => { + true + } Adt0::C7 => { false } @@ -920,16 +921,16 @@ pub fn f0(v0: Adt0) -> bool { Adt0::C10 => { false } - Adt0::C11(_) => { + Adt0::C11 => { false } Adt0::C12(_) => { false } - Adt0::C13(_, _) => { + Adt0::C13(_) => { false } - Adt0::C14(_) => { + Adt0::C14(_, _) => { false } Adt0::C15(_) => { @@ -938,15 +939,18 @@ pub fn f0(v0: Adt0) -> bool { Adt0::C16(_) => { false } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { false } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { false } Adt0::C19(_, _) => { false } + Adt0::C20(_, _) => { + false + } } } diff --git a/crates/certified/roots/uorust_certified_pointer_fields.rs b/crates/certified/roots/uorust_certified_pointer_fields.rs index 6d931955..92c165d3 100644 --- a/crates/certified/roots/uorust_certified_pointer_fields.rs +++ b/crates/certified/roots/uorust_certified_pointer_fields.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -885,7 +886,9 @@ pub enum Adt1 { } pub fn f0() -> List<(Str, Adt0)> { - List::cons((Str::lit("allocation"), Adt0::C2(None::)), List::cons((Str::lit("address"), Adt0::C2(None::)), List::cons((Str::lit("metadata"), Adt0::C2(None::)), List::<(Str, Adt0)>::nil()))) + let a1 = List::cons((Str::lit("allocation"), Adt0::C2(None::)), List::<(Str, Adt0)>::nil()); + let a2 = List::cons((Str::lit("address"), Adt0::C2(None::)), List::cons((Str::lit("metadata"), Adt0::C2(None::)), List::<(Str, Adt0)>::nil())); + append_list(a1, a2) } pub fn run() -> List<(Str, Adt0)> { diff --git a/crates/certified/roots/uorust_certified_pointer_value.rs b/crates/certified/roots/uorust_certified_pointer_value.rs index 37a6b5ee..7a79d2dd 100644 --- a/crates/certified/roots/uorust_certified_pointer_value.rs +++ b/crates/certified/roots/uorust_certified_pointer_value.rs @@ -856,9 +856,17 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: Str, v1: Str, v2: Str) -> Str { - let a1 = List::cons(Str::lit("(record RawPointer {allocation := "), List::cons(v0, List::cons(Str::lit(", address := "), List::cons(v1, List::cons(Str::lit(", metadata := "), List::cons(v2, List::cons(Str::lit("})"), List::::nil()))))))); - let a2 = Str::lit(""); - join(a1, a2) + let a5 = { + let a3 = List::cons(Str::lit("(record RawPointer {allocation := "), List::cons(v0, List::cons(Str::lit(", address := "), List::::nil()))); + let a4 = { + let a1 = List::cons(v1, List::cons(Str::lit(", metadata := "), List::::nil())); + let a2 = List::cons(v2, List::cons(Str::lit("})"), List::::nil())); + append_list(a1, a2) + }; + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) } pub fn run(p0: Str, p1: Str, p2: Str) -> Str { diff --git a/crates/certified/roots/uorust_certified_pointer_width.rs b/crates/certified/roots/uorust_certified_pointer_width.rs index 05e7869b..cd75fa2b 100644 --- a/crates/certified/roots/uorust_certified_pointer_width.rs +++ b/crates/certified/roots/uorust_certified_pointer_width.rs @@ -866,8 +866,48 @@ pub fn f0(v0: Str) -> R> { Ok(None::) } Some(v1) => { - let v2: List = List::cons(Str::lit("x86_64"), List::cons(Str::lit("aarch64"), List::cons(Str::lit("arm64"), List::cons(Str::lit("riscv64"), List::cons(Str::lit("powerpc64"), List::cons(Str::lit("powerpc64le"), List::cons(Str::lit("s390x"), List::cons(Str::lit("sparc64"), List::cons(Str::lit("mips64"), List::cons(Str::lit("mips64el"), List::cons(Str::lit("loongarch64"), List::cons(Str::lit("wasm64"), List::cons(Str::lit("bpfel"), List::cons(Str::lit("bpfeb"), List::::nil())))))))))))))); - let v3: List = List::cons(Str::lit("i386"), List::cons(Str::lit("i586"), List::cons(Str::lit("i686"), List::cons(Str::lit("x86"), List::cons(Str::lit("arm"), List::cons(Str::lit("armv7"), List::cons(Str::lit("armv7a"), List::cons(Str::lit("armv7r"), List::cons(Str::lit("armebv7r"), List::cons(Str::lit("armv5te"), List::cons(Str::lit("armv4t"), List::cons(Str::lit("armv6"), List::cons(Str::lit("thumbv6m"), List::cons(Str::lit("thumbv7m"), List::cons(Str::lit("thumbv7em"), List::cons(Str::lit("thumbv7neon"), List::cons(Str::lit("thumbv8m.base"), List::cons(Str::lit("thumbv8m.main"), List::cons(Str::lit("riscv32i"), List::cons(Str::lit("riscv32im"), List::cons(Str::lit("riscv32imc"), List::cons(Str::lit("riscv32imac"), List::cons(Str::lit("riscv32imafc"), List::cons(Str::lit("powerpc"), List::cons(Str::lit("mips"), List::cons(Str::lit("mipsel"), List::cons(Str::lit("sparc"), List::cons(Str::lit("wasm32"), List::cons(Str::lit("hexagon"), List::cons(Str::lit("csky"), List::cons(Str::lit("xtensa"), List::cons(Str::lit("m68k"), List::::nil())))))))))))))))))))))))))))))))); + let v2: List = { + let a8 = { + let a4 = List::cons(Str::lit("x86_64"), List::cons(Str::lit("aarch64"), List::cons(Str::lit("arm64"), List::::nil()))); + let a5 = List::cons(Str::lit("riscv64"), List::cons(Str::lit("powerpc64"), List::cons(Str::lit("powerpc64le"), List::cons(Str::lit("s390x"), List::::nil())))); + append_list(a4, a5) + }; + let a9 = { + let a6 = List::cons(Str::lit("sparc64"), List::cons(Str::lit("mips64"), List::cons(Str::lit("mips64el"), List::::nil()))); + let a7 = List::cons(Str::lit("loongarch64"), List::cons(Str::lit("wasm64"), List::cons(Str::lit("bpfel"), List::cons(Str::lit("bpfeb"), List::::nil())))); + append_list(a6, a7) + }; + append_list(a8, a9) + }; + let v3: List = { + let a22 = { + let a14 = { + let a10 = List::cons(Str::lit("i386"), List::cons(Str::lit("i586"), List::cons(Str::lit("i686"), List::cons(Str::lit("x86"), List::::nil())))); + let a11 = List::cons(Str::lit("arm"), List::cons(Str::lit("armv7"), List::cons(Str::lit("armv7a"), List::cons(Str::lit("armv7r"), List::::nil())))); + append_list(a10, a11) + }; + let a15 = { + let a12 = List::cons(Str::lit("armebv7r"), List::cons(Str::lit("armv5te"), List::cons(Str::lit("armv4t"), List::cons(Str::lit("armv6"), List::::nil())))); + let a13 = List::cons(Str::lit("thumbv6m"), List::cons(Str::lit("thumbv7m"), List::cons(Str::lit("thumbv7em"), List::cons(Str::lit("thumbv7neon"), List::::nil())))); + append_list(a12, a13) + }; + append_list(a14, a15) + }; + let a23 = { + let a20 = { + let a16 = List::cons(Str::lit("thumbv8m.base"), List::cons(Str::lit("thumbv8m.main"), List::cons(Str::lit("riscv32i"), List::cons(Str::lit("riscv32im"), List::::nil())))); + let a17 = List::cons(Str::lit("riscv32imc"), List::cons(Str::lit("riscv32imac"), List::cons(Str::lit("riscv32imafc"), List::cons(Str::lit("powerpc"), List::::nil())))); + append_list(a16, a17) + }; + let a21 = { + let a18 = List::cons(Str::lit("mips"), List::cons(Str::lit("mipsel"), List::cons(Str::lit("sparc"), List::cons(Str::lit("wasm32"), List::::nil())))); + let a19 = List::cons(Str::lit("hexagon"), List::cons(Str::lit("csky"), List::cons(Str::lit("xtensa"), List::cons(Str::lit("m68k"), List::::nil())))); + append_list(a18, a19) + }; + append_list(a20, a21) + }; + append_list(a22, a23) + }; if f2(v2, v1.clone()) { Ok(Some(64u64)) } else { @@ -882,14 +922,14 @@ pub fn f0(v0: Str) -> R> { } { Ok(Some(32u64)) } else { - let a4 = v1.clone(); - let a5 = Str::lit("avr"); - if if equal(a4, a5) { + let a24 = v1.clone(); + let a25 = Str::lit("avr"); + if if equal(a24, a25) { true } else { - let a6 = v1; - let a7 = Str::lit("msp430"); - equal(a6, a7) + let a26 = v1; + let a27 = Str::lit("msp430"); + equal(a26, a27) } { Ok(Some(16u64)) } else { @@ -903,52 +943,52 @@ pub fn f0(v0: Str) -> R> { pub fn f1(v0: Str, v1: Str) -> R> { let v2: Bytes = { - let a8 = v0.clone(); - utf8_encode(a8) + let a28 = v0.clone(); + utf8_encode(a28) }; let v3: Bytes = { - let a9 = v1; - utf8_encode(a9) + let a29 = v1; + utf8_encode(a29) }; - let a11 = { - let a10 = v3.clone(); - length_bytes(a10) + let a31 = { + let a30 = v3.clone(); + length_bytes(a30) }; - let a12 = 0u64; - if nat_eq(a11, a12) { + let a32 = 0u64; + if nat_eq(a31, a32) { Ok(List::cons(Str::lit(""), { - let a13 = f5(v0)?; - let a14 = List::cons(Str::lit(""), List::::nil()); - append_list(a13, a14) + let a33 = f5(v0)?; + let a34 = List::cons(Str::lit(""), List::::nil()); + append_list(a33, a34) })) } else { f6({ - let a16 = { - let a15 = v2.clone(); - length_bytes(a15) + let a36 = { + let a35 = v2.clone(); + length_bytes(a35) }; - let a17 = 1u64; - nat_add(a16, a17)? + let a37 = 1u64; + nat_add(a36, a37)? }, v2, v3, 0u64, 0u64) } } -pub fn f2(p22: List, v1: Str) -> bool { - let m21 = p22; +pub fn f2(p42: List, v1: Str) -> bool { + let m41 = p42; { - let mut m21 = m21; + let mut m41 = m41; loop { let step = { - let v0 = m21; - let m18 = v0; - match m18.uncons() { + let v0 = m41; + let m38 = v0; + match m38.uncons() { None => { Err::, bool>(false) } Some((v2, v3)) => { - let a19 = v2; - let a20 = v1.clone(); - if equal(a19, a20) { + let a39 = v2; + let a40 = v1.clone(); + if equal(a39, a40) { Err::, bool>(true) } else { Ok::, bool>(v3) @@ -957,29 +997,29 @@ pub fn f2(p22: List, v1: Str) -> bool { } }; match step { - Ok(next) => { m21 = next; } + Ok(next) => { m41 = next; } Err(done) => break done, } } } } -pub fn f3(p27: List, v1: Str) -> bool { - let m26 = p27; +pub fn f3(p47: List, v1: Str) -> bool { + let m46 = p47; { - let mut m26 = m26; + let mut m46 = m46; loop { let step = { - let v0 = m26; - let m23 = v0; - match m23.uncons() { + let v0 = m46; + let m43 = v0; + match m43.uncons() { None => { Err::, bool>(false) } Some((v2, v3)) => { - let a24 = v2; - let a25 = v1.clone(); - if equal(a24, a25) { + let a44 = v2; + let a45 = v1.clone(); + if equal(a44, a45) { Err::, bool>(true) } else { Ok::, bool>(v3) @@ -988,7 +1028,7 @@ pub fn f3(p27: List, v1: Str) -> bool { } }; match step { - Ok(next) => { m26 = next; } + Ok(next) => { m46 = next; } Err(done) => break done, } } @@ -997,73 +1037,73 @@ pub fn f3(p27: List, v1: Str) -> bool { pub fn f4(v0: Str, v1: Str) -> bool { f7({ - let a28 = v0; - utf8_encode(a28) + let a48 = v0; + utf8_encode(a48) }, 0u64, { - let a29 = v1; - utf8_encode(a29) + let a49 = v1; + utf8_encode(a49) }) } pub fn f5(v0: Str) -> R> { let v1: Bytes = { - let a30 = v0; - utf8_encode(a30) + let a50 = v0; + utf8_encode(a50) }; f8({ - let a31 = v1.clone(); - length_bytes(a31) + let a51 = v1.clone(); + length_bytes(a51) }, v1, 0u64) } pub fn f6(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { - let m32 = v0; - if m32 == 0 { + let m52 = v0; + if m52 == 0 { Ok(List::cons(f9(v1.clone(), v3, { - let a33 = v1; - length_bytes(a33) + let a53 = v1; + length_bytes(a53) }), List::::nil())) } else { - let v5 = m32 - 1; - let a38 = { - let a34 = v1.clone(); - length_bytes(a34) + let v5 = m52 - 1; + let a58 = { + let a54 = v1.clone(); + length_bytes(a54) }; - let a39 = { - let a36 = v4; - let a37 = { - let a35 = v2.clone(); - length_bytes(a35) + let a59 = { + let a56 = v4; + let a57 = { + let a55 = v2.clone(); + length_bytes(a55) }; - nat_add(a36, a37)? + nat_add(a56, a57)? }; - if nat_lt(a38, a39) { + if nat_lt(a58, a59) { Ok(List::cons(f9(v1.clone(), v3, { - let a40 = v1; - length_bytes(a40) + let a60 = v1; + length_bytes(a60) }), List::::nil())) } else { if f7(v1.clone(), v4, v2.clone()) { Ok(List::cons(f9(v1.clone(), v3, v4), f6(v5, v1, v2.clone(), { - let a42 = v4; - let a43 = { - let a41 = v2.clone(); - length_bytes(a41) + let a62 = v4; + let a63 = { + let a61 = v2.clone(); + length_bytes(a61) }; - nat_add(a42, a43)? + nat_add(a62, a63)? }, { - let a45 = v4; - let a46 = { - let a44 = v2; - length_bytes(a44) + let a65 = v4; + let a66 = { + let a64 = v2; + length_bytes(a64) }; - nat_add(a45, a46)? + nat_add(a65, a66)? })?)) } else { f6(v5, v1, v2, v3, { - let a47 = v4; - let a48 = 1u64; - nat_add(a47, a48)? + let a67 = v4; + let a68 = 1u64; + nat_add(a67, a68)? }) } } @@ -1071,76 +1111,76 @@ pub fn f6(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { } pub fn f7(v0: Bytes, v1: u64, v2: Bytes) -> bool { - let m53 = { - let a50 = v0; - let a51 = v1; - let a52 = { - let a49 = v2.clone(); - length_bytes(a49) + let m73 = { + let a70 = v0; + let a71 = v1; + let a72 = { + let a69 = v2.clone(); + length_bytes(a69) }; - slice_bytes(a50, a51, a52) + slice_bytes(a70, a71, a72) }; - match m53 { + match m73 { None => { false } Some(v3) => { - let a54 = v3; - let a55 = v2; - equal(a54, a55) + let a74 = v3; + let a75 = v2; + equal(a74, a75) } } } pub fn f8(v0: u64, v1: Bytes, v2: u64) -> R> { - let m56 = v0; - if m56 == 0 { + let m76 = v0; + if m76 == 0 { Ok(List::::nil()) } else { - let v3 = m56 - 1; - let a58 = { - let a57 = v1.clone(); - length_bytes(a57) + let v3 = m76 - 1; + let a78 = { + let a77 = v1.clone(); + length_bytes(a77) }; - let a59 = v2; - if nat_le(a58, a59) { + let a79 = v2; + if nat_le(a78, a79) { Ok(List::::nil()) } else { let v4: u64 = f10(f11(v1.clone(), v2)?); Ok(List::cons(f9(v1.clone(), v2, { - let a60 = v2; - let a61 = v4; - nat_add(a60, a61)? + let a80 = v2; + let a81 = v4; + nat_add(a80, a81)? }), f8(v3, v1, { - let a62 = v2; - let a63 = v4; - nat_add(a62, a63)? + let a82 = v2; + let a83 = v4; + nat_add(a82, a83)? })?)) } } } pub fn f9(v0: Bytes, v1: u64, v2: u64) -> Str { - let m69 = { - let a66 = v0; - let a67 = v1; - let a68 = { - let a64 = v2; - let a65 = v1; - nat_sub(a64, a65) + let m89 = { + let a86 = v0; + let a87 = v1; + let a88 = { + let a84 = v2; + let a85 = v1; + nat_sub(a84, a85) }; - slice_bytes(a66, a67, a68) + slice_bytes(a86, a87, a88) }; - match m69 { + match m89 { None => { Str::lit("") } Some(v3) => { - let m71 = { - let a70 = v3; - utf8_decode(a70) + let m91 = { + let a90 = v3; + utf8_decode(a90) }; - match m71 { + match m91 { None => { Str::lit("") } @@ -1153,19 +1193,19 @@ pub fn f9(v0: Bytes, v1: u64, v2: u64) -> Str { } pub fn f10(v0: u64) -> u64 { - let a72 = v0; - let a73 = 128u64; - if nat_lt(a72, a73) { + let a92 = v0; + let a93 = 128u64; + if nat_lt(a92, a93) { 1u64 } else { - let a74 = v0; - let a75 = 224u64; - if nat_lt(a74, a75) { + let a94 = v0; + let a95 = 224u64; + if nat_lt(a94, a95) { 2u64 } else { - let a76 = v0; - let a77 = 240u64; - if nat_lt(a76, a77) { + let a96 = v0; + let a97 = 240u64; + if nat_lt(a96, a97) { 3u64 } else { 4u64 @@ -1175,140 +1215,140 @@ pub fn f10(v0: u64) -> u64 { } pub fn f11(v0: Bytes, v1: u64) -> R { - let m80 = { - let a78 = v0; - let a79 = v1; - index_bytes(a78, a79) + let m100 = { + let a98 = v0; + let a99 = v1; + index_bytes(a98, a99) }; - match m80 { + match m100 { None => { Ok(256u64) } Some(v2) => { let v3: u8 = v2; - let a125 = { - let a101 = { - let a89 = { - let a83 = { - let a81 = v3; - let a82 = 128u8; - fixed_u8::bit_and(a81, a82) + let a145 = { + let a121 = { + let a109 = { + let a103 = { + let a101 = v3; + let a102 = 128u8; + fixed_u8::bit_and(a101, a102) }; - let a84 = 128u8; - if equal(a83, a84) { + let a104 = 128u8; + if equal(a103, a104) { 128u64 } else { 0u64 } }; - let a90 = { - let a87 = { - let a85 = v3; - let a86 = 64u8; - fixed_u8::bit_and(a85, a86) + let a110 = { + let a107 = { + let a105 = v3; + let a106 = 64u8; + fixed_u8::bit_and(a105, a106) }; - let a88 = 64u8; - if equal(a87, a88) { + let a108 = 64u8; + if equal(a107, a108) { 64u64 } else { 0u64 } }; - nat_add(a89, a90)? + nat_add(a109, a110)? }; - let a102 = { - let a99 = { - let a93 = { - let a91 = v3; - let a92 = 32u8; - fixed_u8::bit_and(a91, a92) + let a122 = { + let a119 = { + let a113 = { + let a111 = v3; + let a112 = 32u8; + fixed_u8::bit_and(a111, a112) }; - let a94 = 32u8; - if equal(a93, a94) { + let a114 = 32u8; + if equal(a113, a114) { 32u64 } else { 0u64 } }; - let a100 = { - let a97 = { - let a95 = v3; - let a96 = 16u8; - fixed_u8::bit_and(a95, a96) + let a120 = { + let a117 = { + let a115 = v3; + let a116 = 16u8; + fixed_u8::bit_and(a115, a116) }; - let a98 = 16u8; - if equal(a97, a98) { + let a118 = 16u8; + if equal(a117, a118) { 16u64 } else { 0u64 } }; - nat_add(a99, a100)? + nat_add(a119, a120)? }; - nat_add(a101, a102)? + nat_add(a121, a122)? }; - let a126 = { - let a123 = { - let a111 = { - let a105 = { - let a103 = v3; - let a104 = 8u8; - fixed_u8::bit_and(a103, a104) + let a146 = { + let a143 = { + let a131 = { + let a125 = { + let a123 = v3; + let a124 = 8u8; + fixed_u8::bit_and(a123, a124) }; - let a106 = 8u8; - if equal(a105, a106) { + let a126 = 8u8; + if equal(a125, a126) { 8u64 } else { 0u64 } }; - let a112 = { - let a109 = { - let a107 = v3; - let a108 = 4u8; - fixed_u8::bit_and(a107, a108) + let a132 = { + let a129 = { + let a127 = v3; + let a128 = 4u8; + fixed_u8::bit_and(a127, a128) }; - let a110 = 4u8; - if equal(a109, a110) { + let a130 = 4u8; + if equal(a129, a130) { 4u64 } else { 0u64 } }; - nat_add(a111, a112)? + nat_add(a131, a132)? }; - let a124 = { - let a121 = { - let a115 = { - let a113 = v3; - let a114 = 2u8; - fixed_u8::bit_and(a113, a114) + let a144 = { + let a141 = { + let a135 = { + let a133 = v3; + let a134 = 2u8; + fixed_u8::bit_and(a133, a134) }; - let a116 = 2u8; - if equal(a115, a116) { + let a136 = 2u8; + if equal(a135, a136) { 2u64 } else { 0u64 } }; - let a122 = { - let a119 = { - let a117 = v3; - let a118 = 1u8; - fixed_u8::bit_and(a117, a118) + let a142 = { + let a139 = { + let a137 = v3; + let a138 = 1u8; + fixed_u8::bit_and(a137, a138) }; - let a120 = 1u8; - if equal(a119, a120) { + let a140 = 1u8; + if equal(a139, a140) { 1u64 } else { 0u64 } }; - nat_add(a121, a122)? + nat_add(a141, a142)? }; - nat_add(a123, a124)? + nat_add(a143, a144)? }; - nat_add(a125, a126) + nat_add(a145, a146) } } } diff --git a/crates/certified/roots/uorust_certified_pointer_widths.rs b/crates/certified/roots/uorust_certified_pointer_widths.rs index 022fa94e..f5471107 100644 --- a/crates/certified/roots/uorust_certified_pointer_widths.rs +++ b/crates/certified/roots/uorust_certified_pointer_widths.rs @@ -887,7 +887,11 @@ pub fn f0(v0: List) -> R> { } }; let v7: List = if v5 { - let v6: List = f2(List::cons(16u64, List::cons(32u64, List::cons(64u64, List::::nil()))), v4)?; + let v6: List = f2({ + let a6 = List::cons(16u64, List::::nil()); + let a7 = List::cons(32u64, List::cons(64u64, List::::nil())); + append_list(a6, a7) + }, v4)?; v6 } else { v4 @@ -895,31 +899,31 @@ pub fn f0(v0: List) -> R> { Ok(v7) } -pub fn f1(p13: List, p14: Adt1) -> R { - let m12 = (p13, p14); +pub fn f1(p15: List, p16: Adt1) -> R { + let m14 = (p15, p16); { - let mut m12 = m12; + let mut m14 = m14; loop { let step = { - let (v0, v1) = m12; - let m6 = v0; - match m6.uncons() { + let (v0, v1) = m14; + let m8 = v0; + match m8.uncons() { None => { Err::<(List, Adt1), R>(Ok(v1)) } Some((v2, v3)) => { let v4: List = match v1.clone() { - Adt1::C0(h7, _) => { - h7 + Adt1::C0(h9, _) => { + h9 } }; let v5: bool = match v1 { - Adt1::C0(_, h8) => { - h8 + Adt1::C0(_, h10) => { + h10 } }; - let m9 = f3(v2.clone())?; - match m9 { + let m11 = f3(v2.clone())?; + match m11 { None => { let v6: bool = true; Ok::<(List, Adt1), R>((v3, Adt1::C0(v4, v6))) @@ -927,9 +931,9 @@ pub fn f1(p13: List, p14: Adt1) -> R { Some(v7) => { let v8: List = f4(v4.clone(), v7); let v9: List = { - let a10 = v8; - let a11 = List::cons(v2, List::::nil()); - append_list(a10, a11) + let a12 = v8; + let a13 = List::cons(v2, List::::nil()); + append_list(a12, a13) }; let v10: List = f5(v4, Adt0::C0(v7, v9)); Ok::<(List, Adt1), R>((v3, Adt1::C0(v10, v5))) @@ -939,35 +943,39 @@ pub fn f1(p13: List, p14: Adt1) -> R { } }; match step { - Ok(next) => { m12 = next; } + Ok(next) => { m14 = next; } Err(done) => break done, } } } } -pub fn f2(p21: List, p22: List) -> R> { - let m20 = (p21, p22); +pub fn f2(p25: List, p26: List) -> R> { + let m24 = (p25, p26); { - let mut m20 = m20; + let mut m24 = m24; loop { let step = { - let (v0, v1) = m20; - let m15 = v0; - match m15.uncons() { + let (v0, v1) = m24; + let m17 = v0; + match m17.uncons() { None => { Err::<(List, List), R>>(Ok(v1)) } Some((v2, v3)) => { let v4: List = f6(v1.clone(), v2); let v5: List = { - let a18 = v4; - let a19 = List::cons({ - let a16 = List::cons(Str::lit("any "), List::cons(f7(v2)?, List::cons(Str::lit("-bit target"), List::::nil()))); - let a17 = Str::lit(""); - join(a16, a17) + let a22 = v4; + let a23 = List::cons({ + let a20 = { + let a18 = List::cons(Str::lit("any "), List::::nil()); + let a19 = List::cons(f7(v2)?, List::cons(Str::lit("-bit target"), List::::nil())); + append_list(a18, a19) + }; + let a21 = Str::lit(""); + join(a20, a21) }, List::::nil()); - append_list(a18, a19) + append_list(a22, a23) }; let v6: List = f8(v1, Adt0::C0(v2, v5)); Ok::<(List, List), R>>((v3, v6)) @@ -975,7 +983,7 @@ pub fn f2(p21: List, p22: List) -> R> { } }; match step { - Ok(next) => { m20 = next; } + Ok(next) => { m24 = next; } Err(done) => break done, } } @@ -983,18 +991,58 @@ pub fn f2(p21: List, p22: List) -> R> { } pub fn f3(v0: Str) -> R> { - let m25 = { - let a23 = f9(v0, Str::lit("-"))?; - let a24 = 0u64; - index_list(a23, a24) + let m29 = { + let a27 = f9(v0, Str::lit("-"))?; + let a28 = 0u64; + index_list(a27, a28) }; - match m25 { + match m29 { None => { Ok(None::) } Some(v1) => { - let v2: List = List::cons(Str::lit("x86_64"), List::cons(Str::lit("aarch64"), List::cons(Str::lit("arm64"), List::cons(Str::lit("riscv64"), List::cons(Str::lit("powerpc64"), List::cons(Str::lit("powerpc64le"), List::cons(Str::lit("s390x"), List::cons(Str::lit("sparc64"), List::cons(Str::lit("mips64"), List::cons(Str::lit("mips64el"), List::cons(Str::lit("loongarch64"), List::cons(Str::lit("wasm64"), List::cons(Str::lit("bpfel"), List::cons(Str::lit("bpfeb"), List::::nil())))))))))))))); - let v3: List = List::cons(Str::lit("i386"), List::cons(Str::lit("i586"), List::cons(Str::lit("i686"), List::cons(Str::lit("x86"), List::cons(Str::lit("arm"), List::cons(Str::lit("armv7"), List::cons(Str::lit("armv7a"), List::cons(Str::lit("armv7r"), List::cons(Str::lit("armebv7r"), List::cons(Str::lit("armv5te"), List::cons(Str::lit("armv4t"), List::cons(Str::lit("armv6"), List::cons(Str::lit("thumbv6m"), List::cons(Str::lit("thumbv7m"), List::cons(Str::lit("thumbv7em"), List::cons(Str::lit("thumbv7neon"), List::cons(Str::lit("thumbv8m.base"), List::cons(Str::lit("thumbv8m.main"), List::cons(Str::lit("riscv32i"), List::cons(Str::lit("riscv32im"), List::cons(Str::lit("riscv32imc"), List::cons(Str::lit("riscv32imac"), List::cons(Str::lit("riscv32imafc"), List::cons(Str::lit("powerpc"), List::cons(Str::lit("mips"), List::cons(Str::lit("mipsel"), List::cons(Str::lit("sparc"), List::cons(Str::lit("wasm32"), List::cons(Str::lit("hexagon"), List::cons(Str::lit("csky"), List::cons(Str::lit("xtensa"), List::cons(Str::lit("m68k"), List::::nil())))))))))))))))))))))))))))))))); + let v2: List = { + let a34 = { + let a30 = List::cons(Str::lit("x86_64"), List::cons(Str::lit("aarch64"), List::cons(Str::lit("arm64"), List::::nil()))); + let a31 = List::cons(Str::lit("riscv64"), List::cons(Str::lit("powerpc64"), List::cons(Str::lit("powerpc64le"), List::cons(Str::lit("s390x"), List::::nil())))); + append_list(a30, a31) + }; + let a35 = { + let a32 = List::cons(Str::lit("sparc64"), List::cons(Str::lit("mips64"), List::cons(Str::lit("mips64el"), List::::nil()))); + let a33 = List::cons(Str::lit("loongarch64"), List::cons(Str::lit("wasm64"), List::cons(Str::lit("bpfel"), List::cons(Str::lit("bpfeb"), List::::nil())))); + append_list(a32, a33) + }; + append_list(a34, a35) + }; + let v3: List = { + let a48 = { + let a40 = { + let a36 = List::cons(Str::lit("i386"), List::cons(Str::lit("i586"), List::cons(Str::lit("i686"), List::cons(Str::lit("x86"), List::::nil())))); + let a37 = List::cons(Str::lit("arm"), List::cons(Str::lit("armv7"), List::cons(Str::lit("armv7a"), List::cons(Str::lit("armv7r"), List::::nil())))); + append_list(a36, a37) + }; + let a41 = { + let a38 = List::cons(Str::lit("armebv7r"), List::cons(Str::lit("armv5te"), List::cons(Str::lit("armv4t"), List::cons(Str::lit("armv6"), List::::nil())))); + let a39 = List::cons(Str::lit("thumbv6m"), List::cons(Str::lit("thumbv7m"), List::cons(Str::lit("thumbv7em"), List::cons(Str::lit("thumbv7neon"), List::::nil())))); + append_list(a38, a39) + }; + append_list(a40, a41) + }; + let a49 = { + let a46 = { + let a42 = List::cons(Str::lit("thumbv8m.base"), List::cons(Str::lit("thumbv8m.main"), List::cons(Str::lit("riscv32i"), List::cons(Str::lit("riscv32im"), List::::nil())))); + let a43 = List::cons(Str::lit("riscv32imc"), List::cons(Str::lit("riscv32imac"), List::cons(Str::lit("riscv32imafc"), List::cons(Str::lit("powerpc"), List::::nil())))); + append_list(a42, a43) + }; + let a47 = { + let a44 = List::cons(Str::lit("mips"), List::cons(Str::lit("mipsel"), List::cons(Str::lit("sparc"), List::cons(Str::lit("wasm32"), List::::nil())))); + let a45 = List::cons(Str::lit("hexagon"), List::cons(Str::lit("csky"), List::cons(Str::lit("xtensa"), List::cons(Str::lit("m68k"), List::::nil())))); + append_list(a44, a45) + }; + append_list(a46, a47) + }; + append_list(a48, a49) + }; if f10(v2, v1.clone()) { Ok(Some(64u64)) } else { @@ -1009,14 +1057,14 @@ pub fn f3(v0: Str) -> R> { } { Ok(Some(32u64)) } else { - let a26 = v1.clone(); - let a27 = Str::lit("avr"); - if if equal(a26, a27) { + let a50 = v1.clone(); + let a51 = Str::lit("avr"); + if if equal(a50, a51) { true } else { - let a28 = v1; - let a29 = Str::lit("msp430"); - equal(a28, a29) + let a52 = v1; + let a53 = Str::lit("msp430"); + equal(a52, a53) } { Ok(Some(16u64)) } else { @@ -1029,8 +1077,8 @@ pub fn f3(v0: Str) -> R> { } pub fn f4(v0: List, v1: u64) -> List { - let m30 = f13(v0, v1); - match m30 { + let m54 = f13(v0, v1); + match m54 { None => { List::::nil() } @@ -1041,36 +1089,36 @@ pub fn f4(v0: List, v1: u64) -> List { } pub fn f5(v0: List, v1: Adt0) -> List { - let m31 = v0; - match m31.uncons() { + let m55 = v0; + match m55.uncons() { None => { List::cons(v1, List::::nil()) } Some((v2, v3)) => { - let a34 = match v1.clone() { - Adt0::C0(h32, _) => { - h32 + let a58 = match v1.clone() { + Adt0::C0(h56, _) => { + h56 } }; - let a35 = match v2.clone() { - Adt0::C0(h33, _) => { - h33 + let a59 = match v2.clone() { + Adt0::C0(h57, _) => { + h57 } }; - if nat_eq(a34, a35) { + if nat_eq(a58, a59) { List::cons(v1, v3) } else { - let a38 = match v1.clone() { - Adt0::C0(h36, _) => { - h36 + let a62 = match v1.clone() { + Adt0::C0(h60, _) => { + h60 } }; - let a39 = match v2.clone() { - Adt0::C0(h37, _) => { - h37 + let a63 = match v2.clone() { + Adt0::C0(h61, _) => { + h61 } }; - if nat_lt(a38, a39) { + if nat_lt(a62, a63) { List::cons(v1, List::cons(v2, v3)) } else { List::cons(v2, f5(v3, v1)) @@ -1081,8 +1129,8 @@ pub fn f5(v0: List, v1: Adt0) -> List { } pub fn f6(v0: List, v1: u64) -> List { - let m40 = f14(v0, v1); - match m40 { + let m64 = f14(v0, v1); + match m64 { None => { List::::nil() } @@ -1094,43 +1142,43 @@ pub fn f6(v0: List, v1: u64) -> List { pub fn f7(v0: u64) -> R { Ok(f15({ - let a41 = v0; - let a42 = 1u64; - nat_add(a41, a42)? + let a65 = v0; + let a66 = 1u64; + nat_add(a65, a66)? }, v0)) } pub fn f8(v0: List, v1: Adt0) -> List { - let m43 = v0; - match m43.uncons() { + let m67 = v0; + match m67.uncons() { None => { List::cons(v1, List::::nil()) } Some((v2, v3)) => { - let a46 = match v1.clone() { - Adt0::C0(h44, _) => { - h44 + let a70 = match v1.clone() { + Adt0::C0(h68, _) => { + h68 } }; - let a47 = match v2.clone() { - Adt0::C0(h45, _) => { - h45 + let a71 = match v2.clone() { + Adt0::C0(h69, _) => { + h69 } }; - if nat_eq(a46, a47) { + if nat_eq(a70, a71) { List::cons(v1, v3) } else { - let a50 = match v1.clone() { - Adt0::C0(h48, _) => { - h48 + let a74 = match v1.clone() { + Adt0::C0(h72, _) => { + h72 } }; - let a51 = match v2.clone() { - Adt0::C0(h49, _) => { - h49 + let a75 = match v2.clone() { + Adt0::C0(h73, _) => { + h73 } }; - if nat_lt(a50, a51) { + if nat_lt(a74, a75) { List::cons(v1, List::cons(v2, v3)) } else { List::cons(v2, f8(v3, v1)) @@ -1142,52 +1190,52 @@ pub fn f8(v0: List, v1: Adt0) -> List { pub fn f9(v0: Str, v1: Str) -> R> { let v2: Bytes = { - let a52 = v0.clone(); - utf8_encode(a52) + let a76 = v0.clone(); + utf8_encode(a76) }; let v3: Bytes = { - let a53 = v1; - utf8_encode(a53) + let a77 = v1; + utf8_encode(a77) }; - let a55 = { - let a54 = v3.clone(); - length_bytes(a54) + let a79 = { + let a78 = v3.clone(); + length_bytes(a78) }; - let a56 = 0u64; - if nat_eq(a55, a56) { + let a80 = 0u64; + if nat_eq(a79, a80) { Ok(List::cons(Str::lit(""), { - let a57 = f16(v0)?; - let a58 = List::cons(Str::lit(""), List::::nil()); - append_list(a57, a58) + let a81 = f16(v0)?; + let a82 = List::cons(Str::lit(""), List::::nil()); + append_list(a81, a82) })) } else { f17({ - let a60 = { - let a59 = v2.clone(); - length_bytes(a59) + let a84 = { + let a83 = v2.clone(); + length_bytes(a83) }; - let a61 = 1u64; - nat_add(a60, a61)? + let a85 = 1u64; + nat_add(a84, a85)? }, v2, v3, 0u64, 0u64) } } -pub fn f10(p66: List, v1: Str) -> bool { - let m65 = p66; +pub fn f10(p90: List, v1: Str) -> bool { + let m89 = p90; { - let mut m65 = m65; + let mut m89 = m89; loop { let step = { - let v0 = m65; - let m62 = v0; - match m62.uncons() { + let v0 = m89; + let m86 = v0; + match m86.uncons() { None => { Err::, bool>(false) } Some((v2, v3)) => { - let a63 = v2; - let a64 = v1.clone(); - if equal(a63, a64) { + let a87 = v2; + let a88 = v1.clone(); + if equal(a87, a88) { Err::, bool>(true) } else { Ok::, bool>(v3) @@ -1196,29 +1244,29 @@ pub fn f10(p66: List, v1: Str) -> bool { } }; match step { - Ok(next) => { m65 = next; } + Ok(next) => { m89 = next; } Err(done) => break done, } } } } -pub fn f11(p71: List, v1: Str) -> bool { - let m70 = p71; +pub fn f11(p95: List, v1: Str) -> bool { + let m94 = p95; { - let mut m70 = m70; + let mut m94 = m94; loop { let step = { - let v0 = m70; - let m67 = v0; - match m67.uncons() { + let v0 = m94; + let m91 = v0; + match m91.uncons() { None => { Err::, bool>(false) } Some((v2, v3)) => { - let a68 = v2; - let a69 = v1.clone(); - if equal(a68, a69) { + let a92 = v2; + let a93 = v1.clone(); + if equal(a92, a93) { Err::, bool>(true) } else { Ok::, bool>(v3) @@ -1227,7 +1275,7 @@ pub fn f11(p71: List, v1: Str) -> bool { } }; match step { - Ok(next) => { m70 = next; } + Ok(next) => { m94 = next; } Err(done) => break done, } } @@ -1236,37 +1284,37 @@ pub fn f11(p71: List, v1: Str) -> bool { pub fn f12(v0: Str, v1: Str) -> bool { f18({ - let a72 = v0; - utf8_encode(a72) + let a96 = v0; + utf8_encode(a96) }, 0u64, { - let a73 = v1; - utf8_encode(a73) + let a97 = v1; + utf8_encode(a97) }) } -pub fn f13(p80: List, v1: u64) -> Option> { - let m79 = p80; +pub fn f13(p104: List, v1: u64) -> Option> { + let m103 = p104; { - let mut m79 = m79; + let mut m103 = m103; loop { let step = { - let v0 = m79; - let m74 = v0; - match m74.uncons() { + let v0 = m103; + let m98 = v0; + match m98.uncons() { None => { Err::, Option>>(None::>) } Some((v2, v3)) => { - let a76 = match v2.clone() { - Adt0::C0(h75, _) => { - h75 + let a100 = match v2.clone() { + Adt0::C0(h99, _) => { + h99 } }; - let a77 = v1; - if nat_eq(a76, a77) { + let a101 = v1; + if nat_eq(a100, a101) { Err::, Option>>(Some(match v2 { - Adt0::C0(_, h78) => { - h78 + Adt0::C0(_, h102) => { + h102 } })) } else { @@ -1276,36 +1324,36 @@ pub fn f13(p80: List, v1: u64) -> Option> { } }; match step { - Ok(next) => { m79 = next; } + Ok(next) => { m103 = next; } Err(done) => break done, } } } } -pub fn f14(p87: List, v1: u64) -> Option> { - let m86 = p87; +pub fn f14(p111: List, v1: u64) -> Option> { + let m110 = p111; { - let mut m86 = m86; + let mut m110 = m110; loop { let step = { - let v0 = m86; - let m81 = v0; - match m81.uncons() { + let v0 = m110; + let m105 = v0; + match m105.uncons() { None => { Err::, Option>>(None::>) } Some((v2, v3)) => { - let a83 = match v2.clone() { - Adt0::C0(h82, _) => { - h82 + let a107 = match v2.clone() { + Adt0::C0(h106, _) => { + h106 } }; - let a84 = v1; - if nat_eq(a83, a84) { + let a108 = v1; + if nat_eq(a107, a108) { Err::, Option>>(Some(match v2 { - Adt0::C0(_, h85) => { - h85 + Adt0::C0(_, h109) => { + h109 } })) } else { @@ -1315,7 +1363,7 @@ pub fn f14(p87: List, v1: u64) -> Option> { } }; match step { - Ok(next) => { m86 = next; } + Ok(next) => { m110 = next; } Err(done) => break done, } } @@ -1323,92 +1371,92 @@ pub fn f14(p87: List, v1: u64) -> Option> { } pub fn f15(v0: u64, v1: u64) -> Str { - let m88 = v0; - if m88 == 0 { + let m112 = v0; + if m112 == 0 { Str::lit("") } else { - let v2 = m88 - 1; - let a89 = v1; - let a90 = 10u64; - if nat_lt(a89, a90) { + let v2 = m112 - 1; + let a113 = v1; + let a114 = 10u64; + if nat_lt(a113, a114) { f19(v1) } else { - let a97 = List::cons(f15(v2, { - let a91 = v1; - let a92 = 10u64; - let a93 = 0u64; - nat_quot(a91, a92, a93) + let a121 = List::cons(f15(v2, { + let a115 = v1; + let a116 = 10u64; + let a117 = 0u64; + nat_quot(a115, a116, a117) }), List::cons(f19({ - let a94 = v1; - let a95 = 10u64; - let a96 = 0u64; - nat_rem(a94, a95, a96) + let a118 = v1; + let a119 = 10u64; + let a120 = 0u64; + nat_rem(a118, a119, a120) }), List::::nil())); - let a98 = Str::lit(""); - join(a97, a98) + let a122 = Str::lit(""); + join(a121, a122) } } } pub fn f16(v0: Str) -> R> { let v1: Bytes = { - let a99 = v0; - utf8_encode(a99) + let a123 = v0; + utf8_encode(a123) }; f20({ - let a100 = v1.clone(); - length_bytes(a100) + let a124 = v1.clone(); + length_bytes(a124) }, v1, 0u64) } pub fn f17(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { - let m101 = v0; - if m101 == 0 { + let m125 = v0; + if m125 == 0 { Ok(List::cons(f21(v1.clone(), v3, { - let a102 = v1; - length_bytes(a102) + let a126 = v1; + length_bytes(a126) }), List::::nil())) } else { - let v5 = m101 - 1; - let a107 = { - let a103 = v1.clone(); - length_bytes(a103) + let v5 = m125 - 1; + let a131 = { + let a127 = v1.clone(); + length_bytes(a127) }; - let a108 = { - let a105 = v4; - let a106 = { - let a104 = v2.clone(); - length_bytes(a104) + let a132 = { + let a129 = v4; + let a130 = { + let a128 = v2.clone(); + length_bytes(a128) }; - nat_add(a105, a106)? + nat_add(a129, a130)? }; - if nat_lt(a107, a108) { + if nat_lt(a131, a132) { Ok(List::cons(f21(v1.clone(), v3, { - let a109 = v1; - length_bytes(a109) + let a133 = v1; + length_bytes(a133) }), List::::nil())) } else { if f18(v1.clone(), v4, v2.clone()) { Ok(List::cons(f21(v1.clone(), v3, v4), f17(v5, v1, v2.clone(), { - let a111 = v4; - let a112 = { - let a110 = v2.clone(); - length_bytes(a110) + let a135 = v4; + let a136 = { + let a134 = v2.clone(); + length_bytes(a134) }; - nat_add(a111, a112)? + nat_add(a135, a136)? }, { - let a114 = v4; - let a115 = { - let a113 = v2; - length_bytes(a113) + let a138 = v4; + let a139 = { + let a137 = v2; + length_bytes(a137) }; - nat_add(a114, a115)? + nat_add(a138, a139)? })?)) } else { f17(v5, v1, v2, v3, { - let a116 = v4; - let a117 = 1u64; - nat_add(a116, a117)? + let a140 = v4; + let a141 = 1u64; + nat_add(a140, a141)? }) } } @@ -1416,71 +1464,71 @@ pub fn f17(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { } pub fn f18(v0: Bytes, v1: u64, v2: Bytes) -> bool { - let m122 = { - let a119 = v0; - let a120 = v1; - let a121 = { - let a118 = v2.clone(); - length_bytes(a118) + let m146 = { + let a143 = v0; + let a144 = v1; + let a145 = { + let a142 = v2.clone(); + length_bytes(a142) }; - slice_bytes(a119, a120, a121) + slice_bytes(a143, a144, a145) }; - match m122 { + match m146 { None => { false } Some(v3) => { - let a123 = v3; - let a124 = v2; - equal(a123, a124) + let a147 = v3; + let a148 = v2; + equal(a147, a148) } } } pub fn f19(v0: u64) -> Str { - let a125 = v0; - let a126 = 0u64; - if nat_eq(a125, a126) { + let a149 = v0; + let a150 = 0u64; + if nat_eq(a149, a150) { Str::lit("0") } else { - let a127 = v0; - let a128 = 1u64; - if nat_eq(a127, a128) { + let a151 = v0; + let a152 = 1u64; + if nat_eq(a151, a152) { Str::lit("1") } else { - let a129 = v0; - let a130 = 2u64; - if nat_eq(a129, a130) { + let a153 = v0; + let a154 = 2u64; + if nat_eq(a153, a154) { Str::lit("2") } else { - let a131 = v0; - let a132 = 3u64; - if nat_eq(a131, a132) { + let a155 = v0; + let a156 = 3u64; + if nat_eq(a155, a156) { Str::lit("3") } else { - let a133 = v0; - let a134 = 4u64; - if nat_eq(a133, a134) { + let a157 = v0; + let a158 = 4u64; + if nat_eq(a157, a158) { Str::lit("4") } else { - let a135 = v0; - let a136 = 5u64; - if nat_eq(a135, a136) { + let a159 = v0; + let a160 = 5u64; + if nat_eq(a159, a160) { Str::lit("5") } else { - let a137 = v0; - let a138 = 6u64; - if nat_eq(a137, a138) { + let a161 = v0; + let a162 = 6u64; + if nat_eq(a161, a162) { Str::lit("6") } else { - let a139 = v0; - let a140 = 7u64; - if nat_eq(a139, a140) { + let a163 = v0; + let a164 = 7u64; + if nat_eq(a163, a164) { Str::lit("7") } else { - let a141 = v0; - let a142 = 8u64; - if nat_eq(a141, a142) { + let a165 = v0; + let a166 = 8u64; + if nat_eq(a165, a166) { Str::lit("8") } else { Str::lit("9") @@ -1496,54 +1544,54 @@ pub fn f19(v0: u64) -> Str { } pub fn f20(v0: u64, v1: Bytes, v2: u64) -> R> { - let m143 = v0; - if m143 == 0 { + let m167 = v0; + if m167 == 0 { Ok(List::::nil()) } else { - let v3 = m143 - 1; - let a145 = { - let a144 = v1.clone(); - length_bytes(a144) + let v3 = m167 - 1; + let a169 = { + let a168 = v1.clone(); + length_bytes(a168) }; - let a146 = v2; - if nat_le(a145, a146) { + let a170 = v2; + if nat_le(a169, a170) { Ok(List::::nil()) } else { let v4: u64 = f22(f23(v1.clone(), v2)?); Ok(List::cons(f21(v1.clone(), v2, { - let a147 = v2; - let a148 = v4; - nat_add(a147, a148)? + let a171 = v2; + let a172 = v4; + nat_add(a171, a172)? }), f20(v3, v1, { - let a149 = v2; - let a150 = v4; - nat_add(a149, a150)? + let a173 = v2; + let a174 = v4; + nat_add(a173, a174)? })?)) } } } pub fn f21(v0: Bytes, v1: u64, v2: u64) -> Str { - let m156 = { - let a153 = v0; - let a154 = v1; - let a155 = { - let a151 = v2; - let a152 = v1; - nat_sub(a151, a152) + let m180 = { + let a177 = v0; + let a178 = v1; + let a179 = { + let a175 = v2; + let a176 = v1; + nat_sub(a175, a176) }; - slice_bytes(a153, a154, a155) + slice_bytes(a177, a178, a179) }; - match m156 { + match m180 { None => { Str::lit("") } Some(v3) => { - let m158 = { - let a157 = v3; - utf8_decode(a157) + let m182 = { + let a181 = v3; + utf8_decode(a181) }; - match m158 { + match m182 { None => { Str::lit("") } @@ -1556,19 +1604,19 @@ pub fn f21(v0: Bytes, v1: u64, v2: u64) -> Str { } pub fn f22(v0: u64) -> u64 { - let a159 = v0; - let a160 = 128u64; - if nat_lt(a159, a160) { + let a183 = v0; + let a184 = 128u64; + if nat_lt(a183, a184) { 1u64 } else { - let a161 = v0; - let a162 = 224u64; - if nat_lt(a161, a162) { + let a185 = v0; + let a186 = 224u64; + if nat_lt(a185, a186) { 2u64 } else { - let a163 = v0; - let a164 = 240u64; - if nat_lt(a163, a164) { + let a187 = v0; + let a188 = 240u64; + if nat_lt(a187, a188) { 3u64 } else { 4u64 @@ -1578,140 +1626,140 @@ pub fn f22(v0: u64) -> u64 { } pub fn f23(v0: Bytes, v1: u64) -> R { - let m167 = { - let a165 = v0; - let a166 = v1; - index_bytes(a165, a166) + let m191 = { + let a189 = v0; + let a190 = v1; + index_bytes(a189, a190) }; - match m167 { + match m191 { None => { Ok(256u64) } Some(v2) => { let v3: u8 = v2; - let a212 = { - let a188 = { - let a176 = { - let a170 = { - let a168 = v3; - let a169 = 128u8; - fixed_u8::bit_and(a168, a169) + let a236 = { + let a212 = { + let a200 = { + let a194 = { + let a192 = v3; + let a193 = 128u8; + fixed_u8::bit_and(a192, a193) }; - let a171 = 128u8; - if equal(a170, a171) { + let a195 = 128u8; + if equal(a194, a195) { 128u64 } else { 0u64 } }; - let a177 = { - let a174 = { - let a172 = v3; - let a173 = 64u8; - fixed_u8::bit_and(a172, a173) + let a201 = { + let a198 = { + let a196 = v3; + let a197 = 64u8; + fixed_u8::bit_and(a196, a197) }; - let a175 = 64u8; - if equal(a174, a175) { + let a199 = 64u8; + if equal(a198, a199) { 64u64 } else { 0u64 } }; - nat_add(a176, a177)? + nat_add(a200, a201)? }; - let a189 = { - let a186 = { - let a180 = { - let a178 = v3; - let a179 = 32u8; - fixed_u8::bit_and(a178, a179) + let a213 = { + let a210 = { + let a204 = { + let a202 = v3; + let a203 = 32u8; + fixed_u8::bit_and(a202, a203) }; - let a181 = 32u8; - if equal(a180, a181) { + let a205 = 32u8; + if equal(a204, a205) { 32u64 } else { 0u64 } }; - let a187 = { - let a184 = { - let a182 = v3; - let a183 = 16u8; - fixed_u8::bit_and(a182, a183) + let a211 = { + let a208 = { + let a206 = v3; + let a207 = 16u8; + fixed_u8::bit_and(a206, a207) }; - let a185 = 16u8; - if equal(a184, a185) { + let a209 = 16u8; + if equal(a208, a209) { 16u64 } else { 0u64 } }; - nat_add(a186, a187)? + nat_add(a210, a211)? }; - nat_add(a188, a189)? + nat_add(a212, a213)? }; - let a213 = { - let a210 = { - let a198 = { - let a192 = { - let a190 = v3; - let a191 = 8u8; - fixed_u8::bit_and(a190, a191) + let a237 = { + let a234 = { + let a222 = { + let a216 = { + let a214 = v3; + let a215 = 8u8; + fixed_u8::bit_and(a214, a215) }; - let a193 = 8u8; - if equal(a192, a193) { + let a217 = 8u8; + if equal(a216, a217) { 8u64 } else { 0u64 } }; - let a199 = { - let a196 = { - let a194 = v3; - let a195 = 4u8; - fixed_u8::bit_and(a194, a195) + let a223 = { + let a220 = { + let a218 = v3; + let a219 = 4u8; + fixed_u8::bit_and(a218, a219) }; - let a197 = 4u8; - if equal(a196, a197) { + let a221 = 4u8; + if equal(a220, a221) { 4u64 } else { 0u64 } }; - nat_add(a198, a199)? + nat_add(a222, a223)? }; - let a211 = { - let a208 = { - let a202 = { - let a200 = v3; - let a201 = 2u8; - fixed_u8::bit_and(a200, a201) + let a235 = { + let a232 = { + let a226 = { + let a224 = v3; + let a225 = 2u8; + fixed_u8::bit_and(a224, a225) }; - let a203 = 2u8; - if equal(a202, a203) { + let a227 = 2u8; + if equal(a226, a227) { 2u64 } else { 0u64 } }; - let a209 = { - let a206 = { - let a204 = v3; - let a205 = 1u8; - fixed_u8::bit_and(a204, a205) + let a233 = { + let a230 = { + let a228 = v3; + let a229 = 1u8; + fixed_u8::bit_and(a228, a229) }; - let a207 = 1u8; - if equal(a206, a207) { + let a231 = 1u8; + if equal(a230, a231) { 1u64 } else { 0u64 } }; - nat_add(a208, a209)? + nat_add(a232, a233)? }; - nat_add(a210, a211)? + nat_add(a234, a235)? }; - nat_add(a212, a213) + nat_add(a236, a237) } } } diff --git a/crates/certified/roots/uorust_certified_reason.rs b/crates/certified/roots/uorust_certified_reason.rs index bd79b095..d45e9ee7 100644 --- a/crates/certified/roots/uorust_certified_reason.rs +++ b/crates/certified/roots/uorust_certified_reason.rs @@ -962,155 +962,199 @@ pub fn f1(v0: Adt0) -> R { Ok(Str::lit("the body has statements other than let")) } Adt0::C3(v3) => { - let a7 = List::cons(Str::lit("integer operator "), List::cons(v3, List::cons(Str::lit(" wraps or panics depending on the build profile"), List::::nil()))); - let a8 = Str::lit(""); - Ok(join(a7, a8)) + let a9 = { + let a7 = List::cons(Str::lit("integer operator "), List::::nil()); + let a8 = List::cons(v3, List::cons(Str::lit(" wraps or panics depending on the build profile"), List::::nil())); + append_list(a7, a8) + }; + let a10 = Str::lit(""); + Ok(join(a9, a10)) } Adt0::C4(v4, v5) => { let v6: List = f3(v5)?; - let a11 = List::cons(Str::lit("usize "), List::cons(v4, List::cons(Str::lit(" wraps or panics where its value leaves the pointer width: "), List::cons({ - let a9 = v6; - let a10 = Str::lit(", "); - join(a9, a10) - }, List::::nil())))); - let a12 = Str::lit(""); - Ok(join(a11, a12)) - } - Adt0::C5(v7) => { - let a13 = List::cons(v7, List::cons(Str::lit(" depends on an integer width LexLean does not fix"), List::::nil())); - let a14 = Str::lit(""); - Ok(join(a13, a14)) - } - Adt0::C6(v8) => { - let a15 = List::cons(Str::lit("expression form outside the lift: "), List::cons(v8, List::::nil())); + let a15 = { + let a13 = List::cons(Str::lit("usize "), List::cons(v4, List::::nil())); + let a14 = List::cons(Str::lit(" wraps or panics where its value leaves the pointer width: "), List::cons({ + let a11 = v6; + let a12 = Str::lit(", "); + join(a11, a12) + }, List::::nil())); + append_list(a13, a14) + }; let a16 = Str::lit(""); Ok(join(a15, a16)) } - Adt0::C7(v9) => { - let a17 = List::cons(Str::lit("calls "), List::cons(v9, List::cons(Str::lit(", which is not lifted"), List::::nil()))); + Adt0::C5(v7) => { + let a17 = List::cons(v7, List::cons(Str::lit(" depends on an integer width LexLean does not fix"), List::::nil())); let a18 = Str::lit(""); Ok(join(a17, a18)) } - Adt0::C8(v10) => { - let a19 = List::cons(Str::lit("another function of the crate is also named "), List::cons(v10, List::::nil())); + Adt0::C6(v8) => { + let a19 = List::cons(Str::lit("expression form outside the lift: "), List::cons(v8, List::::nil())); let a20 = Str::lit(""); Ok(join(a19, a20)) } + Adt0::C7(v9) => { + let a23 = { + let a21 = List::cons(Str::lit("calls "), List::::nil()); + let a22 = List::cons(v9, List::cons(Str::lit(", which is not lifted"), List::::nil())); + append_list(a21, a22) + }; + let a24 = Str::lit(""); + Ok(join(a23, a24)) + } + Adt0::C8(v10) => { + let a25 = List::cons(Str::lit("another function of the crate is also named "), List::cons(v10, List::::nil())); + let a26 = Str::lit(""); + Ok(join(a25, a26)) + } Adt0::C9(v11) => { - let a21 = List::cons(Str::lit("mir::"), List::cons(v11, List::::nil())); - let a22 = Str::lit(""); - Ok(join(a21, a22)) + let a27 = List::cons(Str::lit("mir::"), List::cons(v11, List::::nil())); + let a28 = Str::lit(""); + Ok(join(a27, a28)) } Adt0::C10(v12) => { - let a23 = List::cons(Str::lit("mir::Memory: "), List::cons(f2(v12)?, List::::nil())); - let a24 = Str::lit(""); - Ok(join(a23, a24)) + let a29 = List::cons(Str::lit("mir::Memory: "), List::cons(f2(v12)?, List::::nil())); + let a30 = Str::lit(""); + Ok(join(a29, a30)) } } } pub fn f2(v0: Adt2) -> R { - let m25 = v0; - match m25 { + let m31 = v0; + match m31 { Adt2::C0(v1, v2) => { - let a26 = List::cons(Str::lit("`"), List::cons(v1, List::cons(Str::lit("` is not a number of bits in `"), List::cons(v2, List::cons(Str::lit("`"), List::::nil()))))); - let a27 = Str::lit(""); - Ok(join(a26, a27)) + let a34 = { + let a32 = List::cons(Str::lit("`"), List::cons(v1, List::::nil())); + let a33 = List::cons(Str::lit("` is not a number of bits in `"), List::cons(v2, List::cons(Str::lit("`"), List::::nil()))); + append_list(a32, a33) + }; + let a35 = Str::lit(""); + Ok(join(a34, a35)) } Adt2::C1(v3) => { - let a28 = List::cons(Str::lit("a pointer without a size in `"), List::cons(v3, List::cons(Str::lit("`"), List::::nil()))); - let a29 = Str::lit(""); - Ok(join(a28, a29)) + let a38 = { + let a36 = List::cons(Str::lit("a pointer without a size in `"), List::::nil()); + let a37 = List::cons(v3, List::cons(Str::lit("`"), List::::nil())); + append_list(a36, a37) + }; + let a39 = Str::lit(""); + Ok(join(a38, a39)) } Adt2::C2(v4) => { - let a30 = List::cons(Str::lit("a width without an alignment in `"), List::cons(v4, List::cons(Str::lit("`"), List::::nil()))); - let a31 = Str::lit(""); - Ok(join(a30, a31)) + let a42 = { + let a40 = List::cons(Str::lit("a width without an alignment in `"), List::::nil()); + let a41 = List::cons(v4, List::cons(Str::lit("`"), List::::nil())); + append_list(a40, a41) + }; + let a43 = Str::lit(""); + Ok(join(a42, a43)) } Adt2::C3 => { Ok(Str::lit("a data layout without its triple")) } Adt2::C4(v5) => { - let a32 = List::cons(Str::lit("the layout of "), List::cons(v5, List::cons(Str::lit(", with no data layout recorded for the target"), List::::nil()))); - let a33 = Str::lit(""); - Ok(join(a32, a33)) + let a46 = { + let a44 = List::cons(Str::lit("the layout of "), List::::nil()); + let a45 = List::cons(v5, List::cons(Str::lit(", with no data layout recorded for the target"), List::::nil())); + append_list(a44, a45) + }; + let a47 = Str::lit(""); + Ok(join(a46, a47)) } Adt2::C5(v6, v7) => { - let a34 = List::cons(Str::lit("the layout of "), List::cons(v6, List::cons(Str::lit(", which the data layout of "), List::cons(v7, List::cons(Str::lit(" does not state"), List::::nil()))))); - let a35 = Str::lit(""); - Ok(join(a34, a35)) + let a50 = { + let a48 = List::cons(Str::lit("the layout of "), List::cons(v6, List::::nil())); + let a49 = List::cons(Str::lit(", which the data layout of "), List::cons(v7, List::cons(Str::lit(" does not state"), List::::nil()))); + append_list(a48, a49) + }; + let a51 = Str::lit(""); + Ok(join(a50, a51)) } Adt2::C6(v8, v9) => { - let a38 = List::cons(Str::lit("the layout of "), List::cons(v8, List::cons(Str::lit(", which differs by target: "), List::cons({ - let a36 = f4(v9)?; - let a37 = Str::lit(", "); - join(a36, a37) - }, List::::nil())))); - let a39 = Str::lit(""); - Ok(join(a38, a39)) + let a56 = { + let a54 = List::cons(Str::lit("the layout of "), List::cons(v8, List::::nil())); + let a55 = List::cons(Str::lit(", which differs by target: "), List::cons({ + let a52 = f4(v9)?; + let a53 = Str::lit(", "); + join(a52, a53) + }, List::::nil())); + append_list(a54, a55) + }; + let a57 = Str::lit(""); + Ok(join(a56, a57)) } } } pub fn f3(v0: List) -> R> { - let m40 = v0; - match m40.uncons() { + let m58 = v0; + match m58.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt1::C0(h41, _) => { - h41 + Adt1::C0(h59, _) => { + h59 } }; let v4: List = match v1 { - Adt1::C0(_, h42) => { - h42 + Adt1::C0(_, h60) => { + h60 } }; Ok(List::cons({ - let a45 = List::cons(Str::lit("past 2^"), List::cons(f5(v3)?, List::cons(Str::lit(" on "), List::cons({ - let a43 = v4; - let a44 = Str::lit(" and "); - join(a43, a44) - }, List::::nil())))); - let a46 = Str::lit(""); - join(a45, a46) + let a65 = { + let a63 = List::cons(Str::lit("past 2^"), List::cons(f5(v3)?, List::::nil())); + let a64 = List::cons(Str::lit(" on "), List::cons({ + let a61 = v4; + let a62 = Str::lit(" and "); + join(a61, a62) + }, List::::nil())); + append_list(a63, a64) + }; + let a66 = Str::lit(""); + join(a65, a66) }, f3(v2)?)) } } } pub fn f4(v0: List) -> R> { - let m47 = v0; - match m47.uncons() { + let m67 = v0; + match m67.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: Str = match v1.clone() { - Adt3::C0(h48, _) => { - h48 + Adt3::C0(h68, _) => { + h68 } }; let v4: Adt4 = match v1 { - Adt3::C0(_, h49) => { - h49 + Adt3::C0(_, h69) => { + h69 } }; Ok(List::cons({ - let a52 = List::cons(Str::lit("size "), List::cons(f5(match v4.clone() { - Adt4::C0(h50, _) => { - h50 - } - })?, List::cons(Str::lit(" align "), List::cons(f5(match v4 { - Adt4::C0(_, h51) => { - h51 - } - })?, List::cons(Str::lit(" on "), List::cons(v3, List::::nil())))))); - let a53 = Str::lit(""); - join(a52, a53) + let a74 = { + let a72 = List::cons(Str::lit("size "), List::cons(f5(match v4.clone() { + Adt4::C0(h70, _) => { + h70 + } + })?, List::cons(Str::lit(" align "), List::::nil()))); + let a73 = List::cons(f5(match v4 { + Adt4::C0(_, h71) => { + h71 + } + })?, List::cons(Str::lit(" on "), List::cons(v3, List::::nil()))); + append_list(a72, a73) + }; + let a75 = Str::lit(""); + join(a74, a75) }, f4(v2)?)) } } @@ -1118,84 +1162,84 @@ pub fn f4(v0: List) -> R> { pub fn f5(v0: u64) -> R { Ok(f6({ - let a54 = v0; - let a55 = 1u64; - nat_add(a54, a55)? + let a76 = v0; + let a77 = 1u64; + nat_add(a76, a77)? }, v0)) } pub fn f6(v0: u64, v1: u64) -> Str { - let m56 = v0; - if m56 == 0 { + let m78 = v0; + if m78 == 0 { Str::lit("") } else { - let v2 = m56 - 1; - let a57 = v1; - let a58 = 10u64; - if nat_lt(a57, a58) { + let v2 = m78 - 1; + let a79 = v1; + let a80 = 10u64; + if nat_lt(a79, a80) { f7(v1) } else { - let a65 = List::cons(f6(v2, { - let a59 = v1; - let a60 = 10u64; - let a61 = 0u64; - nat_quot(a59, a60, a61) + let a87 = List::cons(f6(v2, { + let a81 = v1; + let a82 = 10u64; + let a83 = 0u64; + nat_quot(a81, a82, a83) }), List::cons(f7({ - let a62 = v1; - let a63 = 10u64; - let a64 = 0u64; - nat_rem(a62, a63, a64) + let a84 = v1; + let a85 = 10u64; + let a86 = 0u64; + nat_rem(a84, a85, a86) }), List::::nil())); - let a66 = Str::lit(""); - join(a65, a66) + let a88 = Str::lit(""); + join(a87, a88) } } } pub fn f7(v0: u64) -> Str { - let a67 = v0; - let a68 = 0u64; - if nat_eq(a67, a68) { + let a89 = v0; + let a90 = 0u64; + if nat_eq(a89, a90) { Str::lit("0") } else { - let a69 = v0; - let a70 = 1u64; - if nat_eq(a69, a70) { + let a91 = v0; + let a92 = 1u64; + if nat_eq(a91, a92) { Str::lit("1") } else { - let a71 = v0; - let a72 = 2u64; - if nat_eq(a71, a72) { + let a93 = v0; + let a94 = 2u64; + if nat_eq(a93, a94) { Str::lit("2") } else { - let a73 = v0; - let a74 = 3u64; - if nat_eq(a73, a74) { + let a95 = v0; + let a96 = 3u64; + if nat_eq(a95, a96) { Str::lit("3") } else { - let a75 = v0; - let a76 = 4u64; - if nat_eq(a75, a76) { + let a97 = v0; + let a98 = 4u64; + if nat_eq(a97, a98) { Str::lit("4") } else { - let a77 = v0; - let a78 = 5u64; - if nat_eq(a77, a78) { + let a99 = v0; + let a100 = 5u64; + if nat_eq(a99, a100) { Str::lit("5") } else { - let a79 = v0; - let a80 = 6u64; - if nat_eq(a79, a80) { + let a101 = v0; + let a102 = 6u64; + if nat_eq(a101, a102) { Str::lit("6") } else { - let a81 = v0; - let a82 = 7u64; - if nat_eq(a81, a82) { + let a103 = v0; + let a104 = 7u64; + if nat_eq(a103, a104) { Str::lit("7") } else { - let a83 = v0; - let a84 = 8u64; - if nat_eq(a83, a84) { + let a105 = v0; + let a106 = 8u64; + if nat_eq(a105, a106) { Str::lit("8") } else { Str::lit("9") diff --git a/crates/certified/roots/uorust_certified_refused.rs b/crates/certified/roots/uorust_certified_refused.rs new file mode 100644 index 00000000..74f72631 --- /dev/null +++ b/crates/certified/roots/uorust_certified_refused.rs @@ -0,0 +1,923 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(Adt1), + C1(Str), + C2(Str, List), + C3(Str, List), + C4(Str, std::rc::Rc, std::rc::Rc), + C5(std::rc::Rc), + C6(std::rc::Rc, std::rc::Rc, std::rc::Rc), + C7(Str, std::rc::Rc, std::rc::Rc), + C8(std::rc::Rc, std::rc::Rc, Str, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(List), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str), + C1(Str), + C2, + C3(Str), + C4(Str, List), + C5(Str), + C6(Str), + C7(Str), + C8(Str), + C9(Str), + C10(Adt4), +} + +#[derive(Clone)] +pub enum Adt3 { + C0(u64, List), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(Str, Str), + C1(Str), + C2(Str), + C3, + C4(Str), + C5(Str, Str), + C6(Str, List), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(Str, Adt6), +} + +#[derive(Clone)] +pub enum Adt6 { + C0(u64, u64), +} + +pub fn f0() -> Result { + Err::(Adt2::C6(Str::lit("match pattern"))) +} + +pub fn run() -> Result { + f0() +} diff --git a/crates/certified/roots/uorust_certified_residue_detail.rs b/crates/certified/roots/uorust_certified_residue_detail.rs index a90528a9..8b7aee40 100644 --- a/crates/certified/roots/uorust_certified_residue_detail.rs +++ b/crates/certified/roots/uorust_certified_residue_detail.rs @@ -913,240 +913,284 @@ pub fn f0(v0: Adt0) -> R { Ok(Str::lit("the body has statements other than let")) } Adt0::C3(v3) => { - let a6 = List::cons(Str::lit("integer operator "), List::cons(v3, List::cons(Str::lit(" wraps or panics depending on the build profile"), List::::nil()))); - let a7 = Str::lit(""); - Ok(join(a6, a7)) + let a8 = { + let a6 = List::cons(Str::lit("integer operator "), List::::nil()); + let a7 = List::cons(v3, List::cons(Str::lit(" wraps or panics depending on the build profile"), List::::nil())); + append_list(a6, a7) + }; + let a9 = Str::lit(""); + Ok(join(a8, a9)) } Adt0::C4(v4, v5) => { let v6: List = f1(v5)?; - let a10 = List::cons(Str::lit("usize "), List::cons(v4, List::cons(Str::lit(" wraps or panics where its value leaves the pointer width: "), List::cons({ - let a8 = v6; - let a9 = Str::lit(", "); - join(a8, a9) - }, List::::nil())))); - let a11 = Str::lit(""); - Ok(join(a10, a11)) - } - Adt0::C5(v7) => { - let a12 = List::cons(v7, List::cons(Str::lit(" depends on an integer width LexLean does not fix"), List::::nil())); - let a13 = Str::lit(""); - Ok(join(a12, a13)) - } - Adt0::C6(v8) => { - let a14 = List::cons(Str::lit("expression form outside the lift: "), List::cons(v8, List::::nil())); + let a14 = { + let a12 = List::cons(Str::lit("usize "), List::cons(v4, List::::nil())); + let a13 = List::cons(Str::lit(" wraps or panics where its value leaves the pointer width: "), List::cons({ + let a10 = v6; + let a11 = Str::lit(", "); + join(a10, a11) + }, List::::nil())); + append_list(a12, a13) + }; let a15 = Str::lit(""); Ok(join(a14, a15)) } - Adt0::C7(v9) => { - let a16 = List::cons(Str::lit("calls "), List::cons(v9, List::cons(Str::lit(", which is not lifted"), List::::nil()))); + Adt0::C5(v7) => { + let a16 = List::cons(v7, List::cons(Str::lit(" depends on an integer width LexLean does not fix"), List::::nil())); let a17 = Str::lit(""); Ok(join(a16, a17)) } - Adt0::C8(v10) => { - let a18 = List::cons(Str::lit("another function of the crate is also named "), List::cons(v10, List::::nil())); + Adt0::C6(v8) => { + let a18 = List::cons(Str::lit("expression form outside the lift: "), List::cons(v8, List::::nil())); let a19 = Str::lit(""); Ok(join(a18, a19)) } + Adt0::C7(v9) => { + let a22 = { + let a20 = List::cons(Str::lit("calls "), List::::nil()); + let a21 = List::cons(v9, List::cons(Str::lit(", which is not lifted"), List::::nil())); + append_list(a20, a21) + }; + let a23 = Str::lit(""); + Ok(join(a22, a23)) + } + Adt0::C8(v10) => { + let a24 = List::cons(Str::lit("another function of the crate is also named "), List::cons(v10, List::::nil())); + let a25 = Str::lit(""); + Ok(join(a24, a25)) + } Adt0::C9(v11) => { - let a20 = List::cons(Str::lit("mir::"), List::cons(v11, List::::nil())); - let a21 = Str::lit(""); - Ok(join(a20, a21)) + let a26 = List::cons(Str::lit("mir::"), List::cons(v11, List::::nil())); + let a27 = Str::lit(""); + Ok(join(a26, a27)) } Adt0::C10(v12) => { - let a22 = List::cons(Str::lit("mir::Memory: "), List::cons(f2(v12)?, List::::nil())); - let a23 = Str::lit(""); - Ok(join(a22, a23)) + let a28 = List::cons(Str::lit("mir::Memory: "), List::cons(f2(v12)?, List::::nil())); + let a29 = Str::lit(""); + Ok(join(a28, a29)) } } } pub fn f1(v0: List) -> R> { - let m24 = v0; - match m24.uncons() { + let m30 = v0; + match m30.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt1::C0(h25, _) => { - h25 + Adt1::C0(h31, _) => { + h31 } }; let v4: List = match v1 { - Adt1::C0(_, h26) => { - h26 + Adt1::C0(_, h32) => { + h32 } }; Ok(List::cons({ - let a29 = List::cons(Str::lit("past 2^"), List::cons(f3(v3)?, List::cons(Str::lit(" on "), List::cons({ - let a27 = v4; - let a28 = Str::lit(" and "); - join(a27, a28) - }, List::::nil())))); - let a30 = Str::lit(""); - join(a29, a30) + let a37 = { + let a35 = List::cons(Str::lit("past 2^"), List::cons(f3(v3)?, List::::nil())); + let a36 = List::cons(Str::lit(" on "), List::cons({ + let a33 = v4; + let a34 = Str::lit(" and "); + join(a33, a34) + }, List::::nil())); + append_list(a35, a36) + }; + let a38 = Str::lit(""); + join(a37, a38) }, f1(v2)?)) } } } pub fn f2(v0: Adt2) -> R { - let m31 = v0; - match m31 { + let m39 = v0; + match m39 { Adt2::C0(v1, v2) => { - let a32 = List::cons(Str::lit("`"), List::cons(v1, List::cons(Str::lit("` is not a number of bits in `"), List::cons(v2, List::cons(Str::lit("`"), List::::nil()))))); - let a33 = Str::lit(""); - Ok(join(a32, a33)) + let a42 = { + let a40 = List::cons(Str::lit("`"), List::cons(v1, List::::nil())); + let a41 = List::cons(Str::lit("` is not a number of bits in `"), List::cons(v2, List::cons(Str::lit("`"), List::::nil()))); + append_list(a40, a41) + }; + let a43 = Str::lit(""); + Ok(join(a42, a43)) } Adt2::C1(v3) => { - let a34 = List::cons(Str::lit("a pointer without a size in `"), List::cons(v3, List::cons(Str::lit("`"), List::::nil()))); - let a35 = Str::lit(""); - Ok(join(a34, a35)) + let a46 = { + let a44 = List::cons(Str::lit("a pointer without a size in `"), List::::nil()); + let a45 = List::cons(v3, List::cons(Str::lit("`"), List::::nil())); + append_list(a44, a45) + }; + let a47 = Str::lit(""); + Ok(join(a46, a47)) } Adt2::C2(v4) => { - let a36 = List::cons(Str::lit("a width without an alignment in `"), List::cons(v4, List::cons(Str::lit("`"), List::::nil()))); - let a37 = Str::lit(""); - Ok(join(a36, a37)) + let a50 = { + let a48 = List::cons(Str::lit("a width without an alignment in `"), List::::nil()); + let a49 = List::cons(v4, List::cons(Str::lit("`"), List::::nil())); + append_list(a48, a49) + }; + let a51 = Str::lit(""); + Ok(join(a50, a51)) } Adt2::C3 => { Ok(Str::lit("a data layout without its triple")) } Adt2::C4(v5) => { - let a38 = List::cons(Str::lit("the layout of "), List::cons(v5, List::cons(Str::lit(", with no data layout recorded for the target"), List::::nil()))); - let a39 = Str::lit(""); - Ok(join(a38, a39)) + let a54 = { + let a52 = List::cons(Str::lit("the layout of "), List::::nil()); + let a53 = List::cons(v5, List::cons(Str::lit(", with no data layout recorded for the target"), List::::nil())); + append_list(a52, a53) + }; + let a55 = Str::lit(""); + Ok(join(a54, a55)) } Adt2::C5(v6, v7) => { - let a40 = List::cons(Str::lit("the layout of "), List::cons(v6, List::cons(Str::lit(", which the data layout of "), List::cons(v7, List::cons(Str::lit(" does not state"), List::::nil()))))); - let a41 = Str::lit(""); - Ok(join(a40, a41)) + let a58 = { + let a56 = List::cons(Str::lit("the layout of "), List::cons(v6, List::::nil())); + let a57 = List::cons(Str::lit(", which the data layout of "), List::cons(v7, List::cons(Str::lit(" does not state"), List::::nil()))); + append_list(a56, a57) + }; + let a59 = Str::lit(""); + Ok(join(a58, a59)) } Adt2::C6(v8, v9) => { - let a44 = List::cons(Str::lit("the layout of "), List::cons(v8, List::cons(Str::lit(", which differs by target: "), List::cons({ - let a42 = f4(v9)?; - let a43 = Str::lit(", "); - join(a42, a43) - }, List::::nil())))); - let a45 = Str::lit(""); - Ok(join(a44, a45)) + let a64 = { + let a62 = List::cons(Str::lit("the layout of "), List::cons(v8, List::::nil())); + let a63 = List::cons(Str::lit(", which differs by target: "), List::cons({ + let a60 = f4(v9)?; + let a61 = Str::lit(", "); + join(a60, a61) + }, List::::nil())); + append_list(a62, a63) + }; + let a65 = Str::lit(""); + Ok(join(a64, a65)) } } } pub fn f3(v0: u64) -> R { Ok(f5({ - let a46 = v0; - let a47 = 1u64; - nat_add(a46, a47)? + let a66 = v0; + let a67 = 1u64; + nat_add(a66, a67)? }, v0)) } pub fn f4(v0: List) -> R> { - let m48 = v0; - match m48.uncons() { + let m68 = v0; + match m68.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: Str = match v1.clone() { - Adt3::C0(h49, _) => { - h49 + Adt3::C0(h69, _) => { + h69 } }; let v4: Adt4 = match v1 { - Adt3::C0(_, h50) => { - h50 + Adt3::C0(_, h70) => { + h70 } }; Ok(List::cons({ - let a53 = List::cons(Str::lit("size "), List::cons(f3(match v4.clone() { - Adt4::C0(h51, _) => { - h51 - } - })?, List::cons(Str::lit(" align "), List::cons(f3(match v4 { - Adt4::C0(_, h52) => { - h52 - } - })?, List::cons(Str::lit(" on "), List::cons(v3, List::::nil())))))); - let a54 = Str::lit(""); - join(a53, a54) + let a75 = { + let a73 = List::cons(Str::lit("size "), List::cons(f3(match v4.clone() { + Adt4::C0(h71, _) => { + h71 + } + })?, List::cons(Str::lit(" align "), List::::nil()))); + let a74 = List::cons(f3(match v4 { + Adt4::C0(_, h72) => { + h72 + } + })?, List::cons(Str::lit(" on "), List::cons(v3, List::::nil()))); + append_list(a73, a74) + }; + let a76 = Str::lit(""); + join(a75, a76) }, f4(v2)?)) } } } pub fn f5(v0: u64, v1: u64) -> Str { - let m55 = v0; - if m55 == 0 { + let m77 = v0; + if m77 == 0 { Str::lit("") } else { - let v2 = m55 - 1; - let a56 = v1; - let a57 = 10u64; - if nat_lt(a56, a57) { + let v2 = m77 - 1; + let a78 = v1; + let a79 = 10u64; + if nat_lt(a78, a79) { f6(v1) } else { - let a64 = List::cons(f5(v2, { - let a58 = v1; - let a59 = 10u64; - let a60 = 0u64; - nat_quot(a58, a59, a60) + let a86 = List::cons(f5(v2, { + let a80 = v1; + let a81 = 10u64; + let a82 = 0u64; + nat_quot(a80, a81, a82) }), List::cons(f6({ - let a61 = v1; - let a62 = 10u64; - let a63 = 0u64; - nat_rem(a61, a62, a63) + let a83 = v1; + let a84 = 10u64; + let a85 = 0u64; + nat_rem(a83, a84, a85) }), List::::nil())); - let a65 = Str::lit(""); - join(a64, a65) + let a87 = Str::lit(""); + join(a86, a87) } } } pub fn f6(v0: u64) -> Str { - let a66 = v0; - let a67 = 0u64; - if nat_eq(a66, a67) { + let a88 = v0; + let a89 = 0u64; + if nat_eq(a88, a89) { Str::lit("0") } else { - let a68 = v0; - let a69 = 1u64; - if nat_eq(a68, a69) { + let a90 = v0; + let a91 = 1u64; + if nat_eq(a90, a91) { Str::lit("1") } else { - let a70 = v0; - let a71 = 2u64; - if nat_eq(a70, a71) { + let a92 = v0; + let a93 = 2u64; + if nat_eq(a92, a93) { Str::lit("2") } else { - let a72 = v0; - let a73 = 3u64; - if nat_eq(a72, a73) { + let a94 = v0; + let a95 = 3u64; + if nat_eq(a94, a95) { Str::lit("3") } else { - let a74 = v0; - let a75 = 4u64; - if nat_eq(a74, a75) { + let a96 = v0; + let a97 = 4u64; + if nat_eq(a96, a97) { Str::lit("4") } else { - let a76 = v0; - let a77 = 5u64; - if nat_eq(a76, a77) { + let a98 = v0; + let a99 = 5u64; + if nat_eq(a98, a99) { Str::lit("5") } else { - let a78 = v0; - let a79 = 6u64; - if nat_eq(a78, a79) { + let a100 = v0; + let a101 = 6u64; + if nat_eq(a100, a101) { Str::lit("6") } else { - let a80 = v0; - let a81 = 7u64; - if nat_eq(a80, a81) { + let a102 = v0; + let a103 = 7u64; + if nat_eq(a102, a103) { Str::lit("7") } else { - let a82 = v0; - let a83 = 8u64; - if nat_eq(a82, a83) { + let a104 = v0; + let a105 = 8u64; + if nat_eq(a104, a105) { Str::lit("8") } else { Str::lit("9") diff --git a/crates/certified/roots/uorust_certified_same_constructor.rs b/crates/certified/roots/uorust_certified_same_constructor.rs index 813409a8..187944e4 100644 --- a/crates/certified/roots/uorust_certified_same_constructor.rs +++ b/crates/certified/roots/uorust_certified_same_constructor.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -888,112 +889,285 @@ pub fn f0(v0: Adt0, v1: Str, v2: Str) -> Str { let m1 = v0; match m1 { Adt0::C0 => { - let a2 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a3 = Str::lit(""); - join(a2, a3) + let a6 = { + let a4 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a5 = { + let a2 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a3 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a2, a3) + }; + append_list(a4, a5) + }; + let a7 = Str::lit(""); + join(a6, a7) } Adt0::C1 => { - let a4 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a5 = Str::lit(""); - join(a4, a5) + let a12 = { + let a10 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a11 = { + let a8 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a9 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a8, a9) + }; + append_list(a10, a11) + }; + let a13 = Str::lit(""); + join(a12, a13) } Adt0::C2(_) => { - let a6 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a7 = Str::lit(""); - join(a6, a7) + let a18 = { + let a16 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a17 = { + let a14 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a15 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a14, a15) + }; + append_list(a16, a17) + }; + let a19 = Str::lit(""); + join(a18, a19) } Adt0::C3(_) => { - let a8 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a9 = Str::lit(""); - join(a8, a9) + let a24 = { + let a22 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a23 = { + let a20 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a21 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a20, a21) + }; + append_list(a22, a23) + }; + let a25 = Str::lit(""); + join(a24, a25) } Adt0::C4(_) => { - let a10 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a11 = Str::lit(""); - join(a10, a11) + let a30 = { + let a28 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a29 = { + let a26 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a27 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a26, a27) + }; + append_list(a28, a29) + }; + let a31 = Str::lit(""); + join(a30, a31) } Adt0::C5(_) => { - let a12 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a13 = Str::lit(""); - join(a12, a13) + let a36 = { + let a34 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a35 = { + let a32 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a33 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a32, a33) + }; + append_list(a34, a35) + }; + let a37 = Str::lit(""); + join(a36, a37) } - Adt0::C6 => { - let a14 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a15 = Str::lit(""); - join(a14, a15) + Adt0::C6(_) => { + let a42 = { + let a40 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a41 = { + let a38 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a39 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a38, a39) + }; + append_list(a40, a41) + }; + let a43 = Str::lit(""); + join(a42, a43) } Adt0::C7 => { - let a16 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a17 = Str::lit(""); - join(a16, a17) + let a48 = { + let a46 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a47 = { + let a44 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a45 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a44, a45) + }; + append_list(a46, a47) + }; + let a49 = Str::lit(""); + join(a48, a49) } Adt0::C8 => { - let a18 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a19 = Str::lit(""); - join(a18, a19) + let a54 = { + let a52 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a53 = { + let a50 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a51 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a50, a51) + }; + append_list(a52, a53) + }; + let a55 = Str::lit(""); + join(a54, a55) } Adt0::C9 => { - let a20 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a21 = Str::lit(""); - join(a20, a21) + let a60 = { + let a58 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a59 = { + let a56 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a57 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a56, a57) + }; + append_list(a58, a59) + }; + let a61 = Str::lit(""); + join(a60, a61) } Adt0::C10 => { - let a22 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a23 = Str::lit(""); - join(a22, a23) + let a66 = { + let a64 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a65 = { + let a62 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a63 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a62, a63) + }; + append_list(a64, a65) + }; + let a67 = Str::lit(""); + join(a66, a67) } - Adt0::C11(v7) => { - let a24 = List::cons(Str::lit("("), List::cons(f1(v7), List::cons(Str::lit(" "), List::cons(v1, List::cons(Str::lit(" "), List::cons(v2, List::cons(Str::lit(")"), List::::nil()))))))); - let a25 = Str::lit(""); - join(a24, a25) + Adt0::C11 => { + let a72 = { + let a70 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a71 = { + let a68 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a69 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a68, a69) + }; + append_list(a70, a71) + }; + let a73 = Str::lit(""); + join(a72, a73) } - Adt0::C12(_) => { - let a26 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a27 = Str::lit(""); - join(a26, a27) + Adt0::C12(v8) => { + let a78 = { + let a76 = List::cons(Str::lit("("), List::cons(f1(v8), List::cons(Str::lit(" "), List::::nil()))); + let a77 = { + let a74 = List::cons(v1, List::cons(Str::lit(" "), List::::nil())); + let a75 = List::cons(v2, List::cons(Str::lit(")"), List::::nil())); + append_list(a74, a75) + }; + append_list(a76, a77) + }; + let a79 = Str::lit(""); + join(a78, a79) } - Adt0::C13(_, _) => { - let a28 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a29 = Str::lit(""); - join(a28, a29) + Adt0::C13(_) => { + let a84 = { + let a82 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a83 = { + let a80 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a81 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a80, a81) + }; + append_list(a82, a83) + }; + let a85 = Str::lit(""); + join(a84, a85) } - Adt0::C14(_) => { - let a30 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a31 = Str::lit(""); - join(a30, a31) + Adt0::C14(_, _) => { + let a90 = { + let a88 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a89 = { + let a86 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a87 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a86, a87) + }; + append_list(a88, a89) + }; + let a91 = Str::lit(""); + join(a90, a91) } Adt0::C15(_) => { - let a32 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a33 = Str::lit(""); - join(a32, a33) + let a96 = { + let a94 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a95 = { + let a92 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a93 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a92, a93) + }; + append_list(a94, a95) + }; + let a97 = Str::lit(""); + join(a96, a97) } Adt0::C16(_) => { - let a34 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a35 = Str::lit(""); - join(a34, a35) + let a102 = { + let a100 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a101 = { + let a98 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a99 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a98, a99) + }; + append_list(a100, a101) + }; + let a103 = Str::lit(""); + join(a102, a103) } - Adt0::C17(_, _, _) => { - let a36 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a37 = Str::lit(""); - join(a36, a37) + Adt0::C17(_) => { + let a108 = { + let a106 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a107 = { + let a104 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a105 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a104, a105) + }; + append_list(a106, a107) + }; + let a109 = Str::lit(""); + join(a108, a109) } - Adt0::C18(_, _) => { - let a38 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a39 = Str::lit(""); - join(a38, a39) + Adt0::C18(_, _, _) => { + let a114 = { + let a112 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a113 = { + let a110 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a111 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a110, a111) + }; + append_list(a112, a113) + }; + let a115 = Str::lit(""); + join(a114, a115) } Adt0::C19(_, _) => { - let a40 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::cons(v2, List::cons(Str::lit("))"), List::::nil()))))))); - let a41 = Str::lit(""); - join(a40, a41) + let a120 = { + let a118 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a119 = { + let a116 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a117 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a116, a117) + }; + append_list(a118, a119) + }; + let a121 = Str::lit(""); + join(a120, a121) + } + Adt0::C20(_, _) => { + let a126 = { + let a124 = List::cons(Str::lit("(if "), List::cons(v1, List::cons(Str::lit(" then "), List::::nil()))); + let a125 = { + let a122 = List::cons(v2.clone(), List::cons(Str::lit(" else (not "), List::::nil())); + let a123 = List::cons(v2, List::cons(Str::lit("))"), List::::nil())); + append_list(a122, a123) + }; + append_list(a124, a125) + }; + let a127 = Str::lit(""); + join(a126, a127) } } } pub fn f1(v0: Str) -> Str { - let a42 = List::cons(Str::lit("equal"), List::cons(v0, List::::nil())); - let a43 = Str::lit(""); - join(a42, a43) + let a128 = List::cons(Str::lit("equal"), List::cons(v0, List::::nil())); + let a129 = Str::lit(""); + join(a128, a129) } pub fn run(p0: Adt0, p1: Str, p2: Str) -> Str { diff --git a/crates/certified/roots/uorust_certified_scalar_value.rs b/crates/certified/roots/uorust_certified_scalar_value.rs index b3ae8d3b..2cbc963c 100644 --- a/crates/certified/roots/uorust_certified_scalar_value.rs +++ b/crates/certified/roots/uorust_certified_scalar_value.rs @@ -856,9 +856,17 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: Str) -> Str { - let a1 = List::cons(Str::lit("((("), List::cons(v0.clone(), List::cons(Str::lit(" ::nil()))))))); - let a2 = Str::lit(""); - join(a1, a2) + let a5 = { + let a3 = List::cons(Str::lit("((("), List::cons(v0.clone(), List::cons(Str::lit(" ::nil()))); + let a4 = { + let a1 = List::cons(v0.clone(), List::cons(Str::lit(")) && ("), List::::nil())); + let a2 = List::cons(v0, List::cons(Str::lit(" ::nil())); + append_list(a1, a2) + }; + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) } pub fn run(p0: Str) -> Str { diff --git a/crates/certified/roots/uorust_certified_single_field.rs b/crates/certified/roots/uorust_certified_single_field.rs index cdb53cfa..04eaefe8 100644 --- a/crates/certified/roots/uorust_certified_single_field.rs +++ b/crates/certified/roots/uorust_certified_single_field.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -886,7 +887,7 @@ pub enum Adt1 { #[derive(Clone)] pub enum Adt2 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -955,7 +956,7 @@ pub fn f0(v0: Adt0, v1: Adt2) -> Option<(Str, Adt0)> { Adt0::C5(_) => { None::<(Str, Adt0)> } - Adt0::C6 => { + Adt0::C6(_) => { None::<(Str, Adt0)> } Adt0::C7 => { @@ -970,31 +971,34 @@ pub fn f0(v0: Adt0, v1: Adt2) -> Option<(Str, Adt0)> { Adt0::C10 => { None::<(Str, Adt0)> } - Adt0::C11(v6) => { - let m2 = f1(v6, v1); + Adt0::C11 => { + None::<(Str, Adt0)> + } + Adt0::C12(v7) => { + let m2 = f1(v7, v1); match m2 { None => { None::<(Str, Adt0)> } - Some(v7) => { - let m3 = v7; + Some(v8) => { + let m3 = v8; match m3.uncons() { None => { None::<(Str, Adt0)> } - Some((v8, v9)) => { - let m4 = v9; + Some((v9, v10)) => { + let m4 = v10; match m4.uncons() { None => { - let v10: Str = { - let (h5, _) = v8; + let v11: Str = { + let (h5, _) = v9; h5 }; - let v11: Adt0 = { - let (_, h6) = v8; + let v12: Adt0 = { + let (_, h6) = v9; h6 }; - Some((v10, v11)) + Some((v11, v12)) } Some((_, _)) => { None::<(Str, Adt0)> @@ -1005,13 +1009,10 @@ pub fn f0(v0: Adt0, v1: Adt2) -> Option<(Str, Adt0)> { } } } - Adt0::C12(_) => { - None::<(Str, Adt0)> - } - Adt0::C13(_, _) => { + Adt0::C13(_) => { None::<(Str, Adt0)> } - Adt0::C14(_) => { + Adt0::C14(_, _) => { None::<(Str, Adt0)> } Adt0::C15(_) => { @@ -1020,21 +1021,24 @@ pub fn f0(v0: Adt0, v1: Adt2) -> Option<(Str, Adt0)> { Adt0::C16(_) => { None::<(Str, Adt0)> } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { None::<(Str, Adt0)> } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { None::<(Str, Adt0)> } Adt0::C19(_, _) => { None::<(Str, Adt0)> } + Adt0::C20(_, _) => { + None::<(Str, Adt0)> + } } } pub fn f1(v0: Str, v1: Adt2) -> Option> { let m8 = f2(match v1 { - Adt2::C0(_, h7, _, _, _, _, _, _, _, _, _, _) => { + Adt2::C0(_, h7, _, _, _, _, _, _, _, _, _, _, _) => { h7 } }, v0); diff --git a/crates/certified/roots/uorust_certified_size_suffix.rs b/crates/certified/roots/uorust_certified_size_suffix.rs index a50e7f2f..537558c5 100644 --- a/crates/certified/roots/uorust_certified_size_suffix.rs +++ b/crates/certified/roots/uorust_certified_size_suffix.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -905,7 +906,7 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C5(_) => { None:: } - Adt0::C6 => { + Adt0::C6(_) => { None:: } Adt0::C7 => { @@ -920,16 +921,19 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C10 => { None:: } - Adt0::C11(v6) => { - if f1(v1, v6.clone()) { - Some(v6) + Adt0::C11 => { + None:: + } + Adt0::C12(v7) => { + if f1(v1, v7.clone()) { + Some(v7) } else { None:: } } - Adt0::C12(r8) => { - let v7 = (*r8).clone(); - let m2 = v7; + Adt0::C13(r8) => { + let v8 = (*r8).clone(); + let m2 = v8; match m2 { Adt0::C0 => { None:: @@ -949,7 +953,7 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C5(_) => { None:: } - Adt0::C6 => { + Adt0::C6(_) => { None:: } Adt0::C7 => { @@ -964,10 +968,13 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C10 => { None:: } - Adt0::C11(v12) => { - if f2(v1, v12.clone()) { + Adt0::C11 => { + None:: + } + Adt0::C12(v14) => { + if f2(v1, v14.clone()) { Some({ - let a3 = List::cons(Str::lit("option_"), List::cons(v12, List::::nil())); + let a3 = List::cons(Str::lit("option_"), List::cons(v14, List::::nil())); let a4 = Str::lit(""); join(a3, a4) }) @@ -975,13 +982,10 @@ pub fn f0(v0: Adt0, v1: List) -> Option { None:: } } - Adt0::C12(_) => { + Adt0::C13(_) => { None:: } - Adt0::C13(_, _) => { - None:: - } - Adt0::C14(_) => { + Adt0::C14(_, _) => { None:: } Adt0::C15(_) => { @@ -990,23 +994,26 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C16(_) => { None:: } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { None:: } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { None:: } Adt0::C19(_, _) => { None:: } + Adt0::C20(_, _) => { + None:: + } } } - Adt0::C13(_, _) => { + Adt0::C14(_, _) => { None:: } - Adt0::C14(r9) => { - let v28 = (*r9).clone(); - let m5 = v28; + Adt0::C15(r9) => { + let v30 = (*r9).clone(); + let m5 = v30; match m5 { Adt0::C0 => { None:: @@ -1026,7 +1033,7 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C5(_) => { None:: } - Adt0::C6 => { + Adt0::C6(_) => { None:: } Adt0::C7 => { @@ -1041,10 +1048,13 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C10 => { None:: } - Adt0::C11(v33) => { - if f3(v1, v33.clone()) { + Adt0::C11 => { + None:: + } + Adt0::C12(v36) => { + if f3(v1, v36.clone()) { Some({ - let a6 = List::cons(Str::lit("list_"), List::cons(v33, List::::nil())); + let a6 = List::cons(Str::lit("list_"), List::cons(v36, List::::nil())); let a7 = Str::lit(""); join(a6, a7) }) @@ -1052,13 +1062,10 @@ pub fn f0(v0: Adt0, v1: List) -> Option { None:: } } - Adt0::C12(_) => { - None:: - } - Adt0::C13(_, _) => { + Adt0::C13(_) => { None:: } - Adt0::C14(_) => { + Adt0::C14(_, _) => { None:: } Adt0::C15(_) => { @@ -1067,32 +1074,35 @@ pub fn f0(v0: Adt0, v1: List) -> Option { Adt0::C16(_) => { None:: } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { None:: } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { None:: } Adt0::C19(_, _) => { None:: } + Adt0::C20(_, _) => { + None:: + } } } - Adt0::C15(_) => { - None:: - } Adt0::C16(_) => { None:: } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { None:: } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { None:: } Adt0::C19(_, _) => { None:: } + Adt0::C20(_, _) => { + None:: + } } } diff --git a/crates/certified/roots/uorust_certified_some_of.rs b/crates/certified/roots/uorust_certified_some_of.rs index 18438e94..82891e3b 100644 --- a/crates/certified/roots/uorust_certified_some_of.rs +++ b/crates/certified/roots/uorust_certified_some_of.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -885,14 +886,18 @@ pub enum Adt1 { } pub fn f0(v0: Adt0, v1: Str) -> Str { - let a1 = List::cons(Str::lit("(ctor Option.some ["), List::cons(f1(v0), List::cons(Str::lit("] "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("(ctor Option.some ["), List::cons(f1(v0), List::::nil())); + let a2 = List::cons(Str::lit("] "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) } pub fn f1(v0: Adt0) -> Str { - let m3 = v0; - match m3 { + let m5 = v0; + match m5 { Adt0::C0 => { Str::lit("Unit") } @@ -909,89 +914,120 @@ pub fn f1(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + Str::lit("Int") } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - let a4 = List::cons(f2(), List::cons(Str::lit("::ParseIntError"), List::::nil())); - let a5 = Str::lit(""); - join(a4, a5) + Str::lit("Nat") } Adt0::C10 => { - let a6 = List::cons(f2(), List::cons(Str::lit("::FilePath"), List::::nil())); + let a6 = List::cons(f2(), List::cons(Str::lit("::ParseIntError"), List::::nil())); let a7 = Str::lit(""); join(a6, a7) } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r30) => { - let v6 = (*r30).clone(); - let a8 = List::cons(Str::lit("(Option "), List::cons(f1(v6), List::cons(Str::lit(")"), List::::nil()))); + Adt0::C11 => { + let a8 = List::cons(f2(), List::cons(Str::lit("::FilePath"), List::::nil())); let a9 = Str::lit(""); join(a8, a9) } - Adt0::C13(r31, r32) => { - let v7 = (*r31).clone(); - let v8 = (*r32).clone(); - let a10 = List::cons(Str::lit("(Result "), List::cons(f1(v7), List::cons(Str::lit(" "), List::cons(f1(v8), List::cons(Str::lit(")"), List::::nil()))))); - let a11 = Str::lit(""); - join(a10, a11) + Adt0::C12(v6) => { + v6 } - Adt0::C14(r33) => { - let v9 = (*r33).clone(); - let a12 = List::cons(Str::lit("(List "), List::cons(f1(v9), List::cons(Str::lit(")"), List::::nil()))); + Adt0::C13(r46) => { + let v7 = (*r46).clone(); + let a12 = { + let a10 = List::cons(Str::lit("(Option "), List::::nil()); + let a11 = List::cons(f1(v7), List::cons(Str::lit(")"), List::::nil())); + append_list(a10, a11) + }; let a13 = Str::lit(""); join(a12, a13) } - Adt0::C15(v10) => { - let a16 = List::cons(Str::lit("Tuple"), List::cons({ - let a14 = f3(v10); - let a15 = Str::lit(""); - join(a14, a15) - }, List::::nil())); + Adt0::C14(r47, r48) => { + let v8 = (*r47).clone(); + let v9 = (*r48).clone(); + let a16 = { + let a14 = List::cons(Str::lit("(Result "), List::cons(f1(v8), List::::nil())); + let a15 = List::cons(Str::lit(" "), List::cons(f1(v9), List::cons(Str::lit(")"), List::::nil()))); + append_list(a14, a15) + }; let a17 = Str::lit(""); join(a16, a17) } - Adt0::C16(v11) => { - let a20 = List::cons(Str::lit("("), List::cons({ - let a18 = f4(v11); - let a19 = Str::lit(" * "); - join(a18, a19) - }, List::cons(Str::lit(")"), List::::nil()))); + Adt0::C15(r49) => { + let v10 = (*r49).clone(); + let a20 = { + let a18 = List::cons(Str::lit("(List "), List::::nil()); + let a19 = List::cons(f1(v10), List::cons(Str::lit(")"), List::::nil())); + append_list(a18, a19) + }; let a21 = Str::lit(""); join(a20, a21) } - Adt0::C17(r34, r35, _) => { - let v12 = (*r34).clone(); - let v13 = (*r35).clone(); - let a22 = List::cons(Str::lit("(List Tuple"), List::cons(f5(v12), List::cons(f5(v13), List::cons(Str::lit(")"), List::::nil())))); - let a23 = Str::lit(""); - join(a22, a23) - } - Adt0::C18(r36, _) => { - let v15 = (*r36).clone(); - let a24 = List::cons(Str::lit("(List "), List::cons(f1(v15), List::cons(Str::lit(")"), List::::nil()))); + Adt0::C16(v11) => { + let a24 = List::cons(Str::lit("Tuple"), List::cons({ + let a22 = f3(v11); + let a23 = Str::lit(""); + join(a22, a23) + }, List::::nil())); let a25 = Str::lit(""); join(a24, a25) } - Adt0::C19(v17, r37) => { - let v18 = (*r37).clone(); - let a28 = List::cons(Str::lit("(Fn ("), List::cons({ - let a26 = f6(v17); - let a27 = Str::lit(" "); - join(a26, a27) - }, List::cons(Str::lit(") "), List::cons(f1(v18), List::cons(Str::lit(")"), List::::nil()))))); - let a29 = Str::lit(""); - join(a28, a29) + Adt0::C17(v12) => { + let a30 = { + let a28 = List::cons(Str::lit("("), List::::nil()); + let a29 = List::cons({ + let a26 = f4(v12); + let a27 = Str::lit(" * "); + join(a26, a27) + }, List::cons(Str::lit(")"), List::::nil())); + append_list(a28, a29) + }; + let a31 = Str::lit(""); + join(a30, a31) + } + Adt0::C18(r50, r51, _) => { + let v13 = (*r50).clone(); + let v14 = (*r51).clone(); + let a34 = { + let a32 = List::cons(Str::lit("(List Tuple"), List::cons(f5(v13), List::::nil())); + let a33 = List::cons(f5(v14), List::cons(Str::lit(")"), List::::nil())); + append_list(a32, a33) + }; + let a35 = Str::lit(""); + join(a34, a35) + } + Adt0::C19(r52, _) => { + let v16 = (*r52).clone(); + let a38 = { + let a36 = List::cons(Str::lit("(List "), List::::nil()); + let a37 = List::cons(f1(v16), List::cons(Str::lit(")"), List::::nil())); + append_list(a36, a37) + }; + let a39 = Str::lit(""); + join(a38, a39) + } + Adt0::C20(v18, r53) => { + let v19 = (*r53).clone(); + let a44 = { + let a42 = List::cons(Str::lit("(Fn ("), List::cons({ + let a40 = f6(v18); + let a41 = Str::lit(" "); + join(a40, a41) + }, List::::nil())); + let a43 = List::cons(Str::lit(") "), List::cons(f1(v19), List::cons(Str::lit(")"), List::::nil()))); + append_list(a42, a43) + }; + let a45 = Str::lit(""); + join(a44, a45) } } } @@ -1001,8 +1037,8 @@ pub fn f2() -> Str { } pub fn f3(v0: List) -> List { - let m38 = v0; - match m38.uncons() { + let m54 = v0; + match m54.uncons() { None => { List::::nil() } @@ -1013,8 +1049,8 @@ pub fn f3(v0: List) -> List { } pub fn f4(v0: List) -> List { - let m39 = v0; - match m39.uncons() { + let m55 = v0; + match m55.uncons() { None => { List::::nil() } @@ -1025,8 +1061,8 @@ pub fn f4(v0: List) -> List { } pub fn f5(v0: Adt0) -> Str { - let m40 = v0; - match m40 { + let m56 = v0; + match m56 { Adt0::C0 => { Str::lit("Unit") } @@ -1043,92 +1079,107 @@ pub fn f5(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f7() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { + Str::lit("ParseIntError") + } + Adt0::C11 => { Str::lit("FilePath") } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r63) => { - let v6 = (*r63).clone(); - let a41 = List::cons(Str::lit("Option"), List::cons(f5(v6), List::::nil())); - let a42 = Str::lit(""); - join(a41, a42) - } - Adt0::C13(r64, r65) => { - let v7 = (*r64).clone(); - let v8 = (*r65).clone(); - let a43 = List::cons(Str::lit("Result"), List::cons(f5(v7), List::cons(f5(v8), List::::nil()))); - let a44 = Str::lit(""); - join(a43, a44) - } - Adt0::C14(r66) => { - let v9 = (*r66).clone(); - let a45 = List::cons(Str::lit("List"), List::cons(f5(v9), List::::nil())); - let a46 = Str::lit(""); - join(a45, a46) - } - Adt0::C15(v10) => { - let a49 = List::cons(Str::lit("Tuple"), List::cons({ - let a47 = f7(v10); - let a48 = Str::lit(""); - join(a47, a48) - }, List::::nil())); - let a50 = Str::lit(""); - join(a49, a50) + Adt0::C12(v6) => { + v6 } - Adt0::C16(v11) => { - let a53 = List::cons(Str::lit("Pair"), List::cons({ - let a51 = f8(v11); - let a52 = Str::lit(""); - join(a51, a52) - }, List::::nil())); - let a54 = Str::lit(""); - join(a53, a54) - } - Adt0::C17(r67, r68, _) => { - let v12 = (*r67).clone(); - let v13 = (*r68).clone(); - let a55 = List::cons(Str::lit("ListTuple"), List::cons(f5(v12), List::cons(f5(v13), List::::nil()))); - let a56 = Str::lit(""); - join(a55, a56) - } - Adt0::C18(r69, _) => { - let v15 = (*r69).clone(); - let a57 = List::cons(Str::lit("List"), List::cons(f5(v15), List::::nil())); + Adt0::C13(r85) => { + let v7 = (*r85).clone(); + let a57 = List::cons(Str::lit("Option"), List::cons(f5(v7), List::::nil())); let a58 = Str::lit(""); join(a57, a58) } - Adt0::C19(v17, r70) => { - let v18 = (*r70).clone(); - let a61 = List::cons(Str::lit("Fn"), List::cons({ - let a59 = f9(v17); - let a60 = Str::lit(""); - join(a59, a60) - }, List::cons(Str::lit("To"), List::cons(f5(v18), List::::nil())))); + Adt0::C14(r86, r87) => { + let v8 = (*r86).clone(); + let v9 = (*r87).clone(); + let a61 = { + let a59 = List::cons(Str::lit("Result"), List::::nil()); + let a60 = List::cons(f5(v8), List::cons(f5(v9), List::::nil())); + append_list(a59, a60) + }; let a62 = Str::lit(""); join(a61, a62) } + Adt0::C15(r88) => { + let v10 = (*r88).clone(); + let a63 = List::cons(Str::lit("List"), List::cons(f5(v10), List::::nil())); + let a64 = Str::lit(""); + join(a63, a64) + } + Adt0::C16(v11) => { + let a67 = List::cons(Str::lit("Tuple"), List::cons({ + let a65 = f8(v11); + let a66 = Str::lit(""); + join(a65, a66) + }, List::::nil())); + let a68 = Str::lit(""); + join(a67, a68) + } + Adt0::C17(v12) => { + let a71 = List::cons(Str::lit("Pair"), List::cons({ + let a69 = f9(v12); + let a70 = Str::lit(""); + join(a69, a70) + }, List::::nil())); + let a72 = Str::lit(""); + join(a71, a72) + } + Adt0::C18(r89, r90, _) => { + let v13 = (*r89).clone(); + let v14 = (*r90).clone(); + let a75 = { + let a73 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a74 = List::cons(f5(v13), List::cons(f5(v14), List::::nil())); + append_list(a73, a74) + }; + let a76 = Str::lit(""); + join(a75, a76) + } + Adt0::C19(r91, _) => { + let v16 = (*r91).clone(); + let a77 = List::cons(Str::lit("List"), List::cons(f5(v16), List::::nil())); + let a78 = Str::lit(""); + join(a77, a78) + } + Adt0::C20(v18, r92) => { + let v19 = (*r92).clone(); + let a83 = { + let a81 = List::cons(Str::lit("Fn"), List::cons({ + let a79 = f10(v18); + let a80 = Str::lit(""); + join(a79, a80) + }, List::::nil())); + let a82 = List::cons(Str::lit("To"), List::cons(f5(v19), List::::nil())); + append_list(a81, a82) + }; + let a84 = Str::lit(""); + join(a83, a84) + } } } pub fn f6(v0: List) -> List { - let m71 = v0; - match m71.uncons() { + let m93 = v0; + match m93.uncons() { None => { List::::nil() } @@ -1138,38 +1189,42 @@ pub fn f6(v0: List) -> List { } } -pub fn f7(v0: List) -> List { - let m72 = v0; - match m72.uncons() { +pub fn f7() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f8(v0: List) -> List { + let m94 = v0; + match m94.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f7(v2)) + List::cons(f5(v1), f8(v2)) } } } -pub fn f8(v0: List) -> List { - let m73 = v0; - match m73.uncons() { +pub fn f9(v0: List) -> List { + let m95 = v0; + match m95.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f8(v2)) + List::cons(f5(v1), f9(v2)) } } } -pub fn f9(v0: List) -> List { - let m74 = v0; - match m74.uncons() { +pub fn f10(v0: List) -> List { + let m96 = v0; + match m96.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f9(v2)) + List::cons(f5(v1), f10(v2)) } } } diff --git a/crates/certified/roots/uorust_certified_some_value.rs b/crates/certified/roots/uorust_certified_some_value.rs new file mode 100644 index 00000000..63c5c4f7 --- /dev/null +++ b/crates/certified/roots/uorust_certified_some_value.rs @@ -0,0 +1,960 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(Adt1), + C1(Str), + C2(Str, List), + C3(Str, List), + C4(Str, std::rc::Rc, std::rc::Rc), + C5(std::rc::Rc), + C6(std::rc::Rc, std::rc::Rc, std::rc::Rc), + C7(Str, std::rc::Rc, std::rc::Rc), + C8(std::rc::Rc, std::rc::Rc, Str, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(List), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(List, List, List, List, List, List, List), +} + +#[derive(Clone)] +pub enum Adt3 { + C0, + C1, + C2(Option), + C3(u64), + C4(Adt4), + C5(Option), + C6(Option), + C7, + C8, + C9, + C10, + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), + C16(List), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(u64, u64), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(Str, List, Str, Adt7, List, List, bool, bool, Option<(Str, List)>), +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Str, Str), +} + +#[derive(Clone)] +pub enum Adt7 { + C0(Str), + C1(Str, List), + C2(std::rc::Rc, std::rc::Rc, std::rc::Rc), + C3(Str, Str, std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt8 { + C0(Str, Adt7), +} + +#[derive(Clone)] +pub enum Adt9 { + C0(Str, List), + C1(Str, List), + C2(Str, List, Option), + C3(Str, List, Str, Adt7, List, Option, Option, Option), + C4(Str, List, Str, Str, List), +} + +#[derive(Clone)] +pub enum Adt10 { + C0(Str, List), +} + +pub fn f0(v0: (Adt0, Adt2)) -> (Option, Adt2) { + (Some({ + let (h1, _) = v0; + h1 + }), { + let (_, h2) = v0; + h2 + }) +} + +pub fn run(p0: (Adt0, Adt2)) -> (Option, Adt2) { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_std_path.rs b/crates/certified/roots/uorust_certified_std_path.rs new file mode 100644 index 00000000..9455c44d --- /dev/null +++ b/crates/certified/roots/uorust_certified_std_path.rs @@ -0,0 +1,1120 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(List, Str), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, Adt2), +} + +#[derive(Clone)] +pub enum Adt2 { + C0, + C1(List), + C2, +} + +#[derive(Clone)] +pub enum Adt3 { + C0(Adt4), + C1(Str), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(Str, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(bool, std::rc::Rc), + C1(std::rc::Rc), + C2(std::rc::Rc, Str), + C3(List, std::rc::Rc), + C4(std::rc::Rc), + C5(List), + C6(bool, Adt0), + C7, +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Str, List), +} + +pub fn f0(v0: Adt0) -> bool { + let m1 = f1(v0); + match m1.uncons() { + None => { + false + } + Some((v1, v2)) => { + let m2 = v2; + match m2.uncons() { + None => { + false + } + Some((v3, v4)) => { + let m3 = v4; + match m3.uncons() { + None => { + false + } + Some((v5, v6)) => { + let m4 = v6; + match m4.uncons() { + None => { + let a5 = f2(v1.clone()); + let a6 = Str::lit("std"); + if if if if if equal(a5, a6) { + true + } else { + let a7 = f2(v1.clone()); + let a8 = Str::lit("core"); + equal(a7, a8) + } { + true + } else { + let a9 = f2(v1.clone()); + let a10 = Str::lit("alloc"); + equal(a9, a10) + } { + f3(v1) + } else { + false + } { + f4(v3.clone()) + } else { + false + } { + f5(f6(), v5, v3) + } else { + false + } + } + Some((_, _)) => { + false + } + } + } + } + } + } + } + } +} + +pub fn f1(v0: Adt0) -> List { + let m11 = v0; + match m11 { + Adt0::C0(v1, _) => { + v1 + } + } +} + +pub fn f2(v0: Adt1) -> Str { + let m12 = v0; + match m12 { + Adt1::C0(v1, _) => { + v1 + } + } +} + +pub fn f3(v0: Adt1) -> bool { + let v1: Adt1 = v0; + let m13 = f7(v1); + match m13 { + Adt2::C0 => { + true + } + Adt2::C1(_) => { + false + } + Adt2::C2 => { + false + } + } +} + +pub fn f4(v0: Adt1) -> bool { + let v1: Adt1 = v0; + let m14 = f7(v1); + match m14 { + Adt2::C0 => { + true + } + Adt2::C1(_) => { + false + } + Adt2::C2 => { + false + } + } +} + +pub fn f5(p21: List, v1: Adt1, v2: Adt1) -> bool { + let m20 = p21; + { + let mut m20 = m20; + loop { + let step = { + let v0 = m20; + let m15 = v0; + match m15.uncons() { + None => { + Err::, bool>(false) + } + Some((v3, v4)) => { + let v5: Str = match v3.clone() { + Adt6::C0(h16, _) => { + h16 + } + }; + let v6: List = match v3 { + Adt6::C0(_, h17) => { + h17 + } + }; + let a18 = v5; + let a19 = f2(v2.clone()); + if if equal(a18, a19) { + f8(v6, f2(v1.clone())) + } else { + false + } { + Err::, bool>(true) + } else { + Ok::, bool>(v4) + } + } + } + }; + match step { + Ok(next) => { m20 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f6() -> List { + let a28 = { + let a24 = List::cons(Adt6::C0(Str::lit("boxed"), List::cons(Str::lit("Box"), List::::nil())), List::cons(Adt6::C0(Str::lit("collections"), { + let a22 = List::cons(Str::lit("BTreeMap"), List::cons(Str::lit("BTreeSet"), List::::nil())); + let a23 = List::cons(Str::lit("HashMap"), List::cons(Str::lit("HashSet"), List::cons(Str::lit("VecDeque"), List::::nil()))); + append_list(a22, a23) + }), List::::nil())); + let a25 = List::cons(Adt6::C0(Str::lit("ops"), List::cons(Str::lit("Range"), List::::nil())), List::cons(Adt6::C0(Str::lit("option"), List::cons(Str::lit("Option"), List::::nil())), List::cons(Adt6::C0(Str::lit("path"), List::cons(Str::lit("Path"), List::cons(Str::lit("PathBuf"), List::::nil()))), List::::nil()))); + append_list(a24, a25) + }; + let a29 = { + let a26 = List::cons(Adt6::C0(Str::lit("rc"), List::cons(Str::lit("Rc"), List::::nil())), List::cons(Adt6::C0(Str::lit("result"), List::cons(Str::lit("Result"), List::::nil())), List::::nil())); + let a27 = List::cons(Adt6::C0(Str::lit("string"), List::cons(Str::lit("String"), List::::nil())), List::cons(Adt6::C0(Str::lit("sync"), List::cons(Str::lit("Arc"), List::::nil())), List::cons(Adt6::C0(Str::lit("vec"), List::cons(Str::lit("Vec"), List::::nil())), List::::nil()))); + append_list(a26, a27) + }; + append_list(a28, a29) +} + +pub fn f7(v0: Adt1) -> Adt2 { + let m30 = v0; + match m30 { + Adt1::C0(_, v2) => { + v2 + } + } +} + +pub fn f8(p35: List, v1: Str) -> bool { + let m34 = p35; + { + let mut m34 = m34; + loop { + let step = { + let v0 = m34; + let m31 = v0; + match m31.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a32 = v2; + let a33 = v1.clone(); + if equal(a32, a33) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m34 = next; } + Err(done) => break done, + } + } + } +} + +pub fn run(p0: Adt0) -> bool { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_struct_cells.rs b/crates/certified/roots/uorust_certified_struct_cells.rs new file mode 100644 index 00000000..c01952e9 --- /dev/null +++ b/crates/certified/roots/uorust_certified_struct_cells.rs @@ -0,0 +1,2214 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(Adt1, List, bool), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(List, Str), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str, Adt3), +} + +#[derive(Clone)] +pub enum Adt3 { + C0, + C1(List), + C2, +} + +#[derive(Clone)] +pub enum Adt4 { + C0(Adt5), + C1(Str), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(Str, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt6 { + C0(bool, std::rc::Rc), + C1(std::rc::Rc), + C2(std::rc::Rc, Str), + C3(List, std::rc::Rc), + C4(std::rc::Rc), + C5(List), + C6(bool, Adt1), + C7, +} + +#[derive(Clone)] +pub enum Adt7 { + C0(Adt8, Adt9), +} + +#[derive(Clone)] +pub enum Adt8 { + C0(Str), + C1(u64), +} + +#[derive(Clone)] +pub enum Adt9 { + C0(std::rc::Rc), + C1, + C2(std::rc::Rc), + C3(std::rc::Rc), + C4(List), + C5(Adt12), + C6(Adt0), + C7(List), + C8, + C9(Adt13), + C10(std::rc::Rc), + C11(Adt1), + C12(List), + C13(std::rc::Rc), + C14, +} + +#[derive(Clone)] +pub enum Adt10 { + C0(Str, bool, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt11 { + C0(std::rc::Rc, Adt5), +} + +#[derive(Clone)] +pub enum Adt12 { + C0(Adt1, List), +} + +#[derive(Clone)] +pub enum Adt13 { + C0(bool), + C1(Option, Str), + C2(Str), + C3(Str), + C4(u64), + C5(List), + C6, +} + +#[derive(Clone)] +pub enum Adt14 { + C0(std::rc::Rc>, std::rc::Rc>, bool), +} + +#[derive(Clone)] +pub enum Adt15 { + C0(List), + C1(std::rc::Rc), + C2(std::rc::Rc), + C3(Adt19), + C4(std::rc::Rc), + C5(std::rc::Rc), + C6(std::rc::Rc), + C7(std::rc::Rc), + C8(bool), + C9(std::rc::Rc), + C10(std::rc::Rc), + C11(std::rc::Rc), + C12(std::rc::Rc), + C13(std::rc::Rc), + C14(Adt13), + C15(Adt36), + C16(std::rc::Rc), + C17(std::rc::Rc), + C18(std::rc::Rc), + C19(std::rc::Rc), + C20(Adt1), + C21(std::rc::Rc), + C22(std::rc::Rc>), + C23(std::rc::Rc), + C24(std::rc::Rc), + C25(List), + C26(std::rc::Rc), + C27(std::rc::Rc), + C28(Adt46), +} + +#[derive(Clone)] +pub enum Adt16 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt17 { + C0(std::rc::Rc, Adt18, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt18 { + C0, + C1, + C2, + C3, + C4, + C5, + C6, + C7, + C8, + C9, + C10, + C11, + C12, + C13, + C14, + C15, + C16, + C17, + C18, + C19, + C20, + C21, + C22, + C23, + C24, + C25, + C26, + C27, +} + +#[derive(Clone)] +pub enum Adt19 { + C0(bool, Adt20), +} + +#[derive(Clone)] +pub enum Adt20 { + C0(List), +} + +#[derive(Clone)] +pub enum Adt21 { + C0(Adt22), + C1(Adt15, bool), + C2(Adt24), + C3, +} + +#[derive(Clone)] +pub enum Adt22 { + C0(Adt9, Option), +} + +#[derive(Clone)] +pub enum Adt23 { + C0(Adt15, Option), +} + +#[derive(Clone)] +pub enum Adt24 { + C0(Adt1, Option, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt25 { + C0(List), +} + +#[derive(Clone)] +pub enum Adt26 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt27 { + C0(bool, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt28 { + C0(std::rc::Rc, List), +} + +#[derive(Clone)] +pub enum Adt29 { + C0(std::rc::Rc, Adt5), +} + +#[derive(Clone)] +pub enum Adt30 { + C0(List, std::rc::Rc, bool), +} + +#[derive(Clone)] +pub enum Adt31 { + C0(std::rc::Rc, Adt8), +} + +#[derive(Clone)] +pub enum Adt32 { + C0(bool, std::rc::Rc, std::rc::Rc, Adt20), +} + +#[derive(Clone)] +pub enum Adt33 { + C0(std::rc::Rc, Adt20, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt34 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt35 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt36 { + C0(bool, Adt20), +} + +#[derive(Clone)] +pub enum Adt37 { + C0(std::rc::Rc, List), +} + +#[derive(Clone)] +pub enum Adt38 { + C0(Adt9, Adt15), +} + +#[derive(Clone)] +pub enum Adt39 { + C0(std::rc::Rc, Str, Option>, List), +} + +#[derive(Clone)] +pub enum Adt40 { + C0(bool, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt41 { + C0(bool, Adt1, List, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt42 { + C0(Adt8, Adt15), +} + +#[derive(Clone)] +pub enum Adt43 { + C0(Adt44, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt44 { + C0, + C1, + C2, +} + +#[derive(Clone)] +pub enum Adt45 { + C0(bool, std::rc::Rc, Adt20), +} + +#[derive(Clone)] +pub enum Adt46 { + C0(Str, List, List), +} + +#[derive(Clone)] +pub enum Adt47 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt48 { + C0(Adt9), + C1, + C2(List), +} + +#[derive(Clone)] +pub enum Adt49 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt50 { + C0(Str, bool, bool), +} + +#[derive(Clone)] +pub enum Adt51 { + C0(Str, bool), +} + +pub fn f0(v0: Adt0, v1: List) -> R>> { + let v2: List = List::::nil(); + let m1 = f1(v1, v2, v0.clone())?; + match m1 { + Ok(v3) => { + let v4: u64 = { + let a2 = f2(v3.clone()); + length_list(a2) + }; + let a4 = v4; + let a5 = { + let a3 = f3(v0); + length_list(a3) + }; + if nat_eq(a4, a5) { + Ok(Some(v3)) + } else { + Ok(None::>) + } + } + Err(v5) => { + Ok(v5) + } + } +} + +pub fn f1(p13: List, p14: List, v2: Adt0) -> R, Option>>> { + let m12 = (p13, p14); + { + let mut m12 = m12; + loop { + let step = { + let (v0, v1) = m12; + let m6 = v0; + match m6.uncons() { + None => { + Err::<(List, List), R, Option>>>>(Ok(Ok::, Option>>(v1))) + } + Some((v3, v4)) => { + let v5: Option = f4(f3(v2.clone()), v3)?; + let m7 = v5; + match m7 { + None => { + if f5(v2.clone()) { + let v6: List = { + let a8 = v1; + let a9 = List::cons(Adt48::C1, List::::nil()); + append_list(a8, a9) + }; + Ok::<(List, List), R, Option>>>>((v4, v6)) + } else { + Err::<(List, List), R, Option>>>>(Ok(Err::, Option>>(None::>))) + } + } + Some(v7) => { + let v8: List = { + let a10 = v1; + let a11 = List::cons(Adt48::C0(f6(v7)), List::::nil()); + append_list(a10, a11) + }; + Ok::<(List, List), R, Option>>>>((v4, v8)) + } + } + } + } + }; + match step { + Ok(next) => { m12 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f2(v0: List) -> List { + let m15 = v0; + match m15.uncons() { + None => { + List::::nil() + } + Some((v1, v2)) => { + if f7(v1.clone()) { + List::cons(v1, f2(v2)) + } else { + f2(v2) + } + } + } +} + +pub fn f3(v0: Adt0) -> List { + let m16 = v0; + match m16 { + Adt0::C0(_, v2, _) => { + v2 + } + } +} + +pub fn f4(p19: List, v1: Str) -> R> { + let m18 = p19; + { + let mut m18 = m18; + loop { + let step = { + let v0 = m18; + let m17 = v0; + match m17.uncons() { + None => { + Err::, R>>(Ok(None::)) + } + Some((v2, v3)) => { + if f8(v2.clone(), v1.clone())? { + Err::, R>>(Ok(Some(v2))) + } else { + Ok::, R>>(v3) + } + } + } + }; + match step { + Ok(next) => { m18 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f5(v0: Adt0) -> bool { + let m20 = v0; + match m20 { + Adt0::C0(_, _, v3) => { + v3 + } + } +} + +pub fn f6(v0: Adt7) -> Adt9 { + let m21 = v0; + match m21 { + Adt7::C0(_, v2) => { + v2 + } + } +} + +pub fn f7(v0: Adt48) -> bool { + let m22 = v0; + match m22 { + Adt48::C0(_) => { + true + } + Adt48::C1 => { + false + } + Adt48::C2(_) => { + false + } + } +} + +pub fn f8(v0: Adt7, v1: Str) -> R { + let m23 = f9(v0); + match m23 { + Adt8::C0(v2) => { + let a24 = f10(v2)?; + let a25 = v1; + Ok(equal(a24, a25)) + } + Adt8::C1(_) => { + Ok(false) + } + } +} + +pub fn f9(v0: Adt7) -> Adt8 { + let m26 = v0; + match m26 { + Adt7::C0(v1, _) => { + v1 + } + } +} + +pub fn f10(v0: Str) -> R { + let v1: Str = f11(List::cons(f12(v0, Str::lit("r#"))?, List::::nil()))?; + let a27 = v1.clone(); + let a28 = Str::lit(""); + if if equal(a27, a28) { + true + } else { + f13(f14(), v1.clone()) + } { + let a29 = List::cons(v1, List::cons(Str::lit("Value"), List::::nil())); + let a30 = Str::lit(""); + Ok(join(a29, a30)) + } else { + Ok(v1) + } +} + +pub fn f11(v0: List) -> R { + let a31 = f15(f16(f17(f18(v0)?)?, 0u64)?)?; + let a32 = Str::lit(""); + Ok(join(a31, a32)) +} + +pub fn f12(v0: Str, v1: Str) -> R { + let v2: Bytes = { + let a33 = v0.clone(); + utf8_encode(a33) + }; + let v3: Bytes = { + let a34 = v1; + utf8_encode(a34) + }; + let a36 = { + let a35 = v3.clone(); + length_bytes(a35) + }; + let a37 = 0u64; + if nat_eq(a36, a37) { + Ok(v0) + } else { + Ok(f19(v2.clone(), f20({ + let a38 = v2.clone(); + length_bytes(a38) + }, v2.clone(), v3, 0u64)?, { + let a39 = v2; + length_bytes(a39) + })) + } +} + +pub fn f13(p44: List, v1: Str) -> bool { + let m43 = p44; + { + let mut m43 = m43; + loop { + let step = { + let v0 = m43; + let m40 = v0; + match m40.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a41 = v2; + let a42 = v1.clone(); + if equal(a41, a42) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m43 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f14() -> List { + let a73 = { + let a57 = { + let a49 = { + let a45 = List::cons(Str::lit("at"), List::cons(Str::lit("by"), List::cons(Str::lit("calc"), List::cons(Str::lit("def"), List::cons(Str::lit("do"), List::cons(Str::lit("else"), List::::nil())))))); + let a46 = List::cons(Str::lit("end"), List::cons(Str::lit("example"), List::cons(Str::lit("fun"), List::cons(Str::lit("have"), List::cons(Str::lit("if"), List::cons(Str::lit("in"), List::::nil())))))); + append_list(a45, a46) + }; + let a50 = { + let a47 = List::cons(Str::lit("instance"), List::cons(Str::lit("let"), List::cons(Str::lit("match"), List::cons(Str::lit("mut"), List::cons(Str::lit("nomatch"), List::cons(Str::lit("open"), List::::nil())))))); + let a48 = List::cons(Str::lit("prop"), List::cons(Str::lit("return"), List::cons(Str::lit("show"), List::cons(Str::lit("then"), List::cons(Str::lit("theorem"), List::cons(Str::lit("type"), List::cons(Str::lit("where"), List::::nil()))))))); + append_list(a47, a48) + }; + append_list(a49, a50) + }; + let a58 = { + let a55 = { + let a51 = List::cons(Str::lit("with"), List::cons(Str::lit("from"), List::cons(Str::lit("for"), List::cons(Str::lit("try"), List::cons(Str::lit("catch"), List::cons(Str::lit("break"), List::::nil())))))); + let a52 = List::cons(Str::lit("continue"), List::cons(Str::lit("unless"), List::cons(Str::lit("structure"), List::cons(Str::lit("inductive"), List::cons(Str::lit("class"), List::cons(Str::lit("namespace"), List::cons(Str::lit("section"), List::::nil()))))))); + append_list(a51, a52) + }; + let a56 = { + let a53 = List::cons(Str::lit("local"), List::cons(Str::lit("private"), List::cons(Str::lit("protected"), List::cons(Str::lit("partial"), List::cons(Str::lit("unsafe"), List::cons(Str::lit("macro"), List::::nil())))))); + let a54 = List::cons(Str::lit("syntax"), List::cons(Str::lit("import"), List::cons(Str::lit("export"), List::cons(Str::lit("axiom"), List::cons(Str::lit("abbrev"), List::cons(Str::lit("opaque"), List::cons(Str::lit("mutual"), List::::nil()))))))); + append_list(a53, a54) + }; + append_list(a55, a56) + }; + append_list(a57, a58) + }; + let a74 = { + let a71 = { + let a63 = { + let a59 = List::cons(Str::lit("variable"), List::cons(Str::lit("universe"), List::cons(Str::lit("deriving"), List::cons(Str::lit("extends"), List::cons(Str::lit("suffices"), List::cons(Str::lit("obtain"), List::::nil())))))); + let a60 = List::cons(Str::lit("record"), List::cons(Str::lit("ctor"), List::cons(Str::lit("prim"), List::cons(Str::lit("project"), List::cons(Str::lit("cons"), List::cons(Str::lit("nil"), List::::nil())))))); + append_list(a59, a60) + }; + let a64 = { + let a61 = List::cons(Str::lit("not"), List::cons(Str::lit("true"), List::cons(Str::lit("false"), List::cons(Str::lit("forall"), List::cons(Str::lit("first"), List::cons(Str::lit("second"), List::::nil())))))); + let a62 = List::cons(Str::lit("apply"), List::cons(Str::lit("ref"), List::cons(Str::lit("checked"), List::cons(Str::lit("self"), List::cons(Str::lit("noncomputable"), List::cons(Str::lit("termination_by"), List::cons(Str::lit("and_congr"), List::::nil()))))))); + append_list(a61, a62) + }; + append_list(a63, a64) + }; + let a72 = { + let a69 = { + let a65 = List::cons(Str::lit("and_true"), List::cons(Str::lit("beq_iff_eq"), List::cons(Str::lit("congr"), List::cons(Str::lit("decide"), List::cons(Str::lit("decide_eq_false_iff_not"), List::cons(Str::lit("decide_eq_true_eq"), List::::nil())))))); + let a66 = List::cons(Str::lit("id"), List::cons(Str::lit("reduceIte"), List::cons(Str::lit("rfl"), List::cons(Str::lit("true_and"), List::cons(Str::lit("isFalse"), List::cons(Str::lit("isTrue"), List::cons(Str::lit("none"), List::::nil()))))))); + append_list(a65, a66) + }; + let a70 = { + let a67 = List::cons(Str::lit("some"), List::cons(Str::lit("below"), List::cons(Str::lit("brecOn"), List::cons(Str::lit("casesOn"), List::cons(Str::lit("ctorElim"), List::cons(Str::lit("ctorElimType"), List::::nil())))))); + let a68 = List::cons(Str::lit("ctorIdx"), List::cons(Str::lit("mk"), List::cons(Str::lit("noConfusion"), List::cons(Str::lit("noConfusionType"), List::cons(Str::lit("rec"), List::cons(Str::lit("recOn"), List::cons(Str::lit("toCtorIdx"), List::::nil()))))))); + append_list(a67, a68) + }; + append_list(a69, a70) + }; + append_list(a71, a72) + }; + append_list(a73, a74) +} + +pub fn f15(v0: List) -> R> { + let m75 = v0; + match m75.uncons() { + None => { + Ok(List::::nil()) + } + Some((v1, v2)) => { + let v3: u64 = match v1.clone() { + Adt49::C0(h76, _) => { + h76 + } + }; + let v4: Str = match v1 { + Adt49::C0(_, h77) => { + h77 + } + }; + Ok(List::cons({ + let a78 = v3; + let a79 = 0u64; + if nat_eq(a78, a79) { + f21(v4)? + } else { + v4 + } + }, f15(v2)?)) + } + } +} + +pub fn f16(v0: List, v1: u64) -> R> { + let m80 = v0; + match m80.uncons() { + None => { + Ok(List::::nil()) + } + Some((v2, v3)) => { + Ok(List::cons(Adt49::C0(v1, v2), f16(v3, { + let a81 = v1; + let a82 = 1u64; + nat_add(a81, a82)? + })?)) + } + } +} + +pub fn f17(v0: Str) -> R> { + let v1: Bytes = { + let a83 = v0; + utf8_encode(a83) + }; + f22({ + let a84 = v1.clone(); + length_bytes(a84) + }, v1, 0u64) +} + +pub fn f18(v0: List) -> R { + let v1: Str = Str::lit(""); + let v2: Str = f23(v0, v1)?; + if f24(v2.clone())? { + let a85 = List::cons(Str::lit("N"), List::cons(v2, List::::nil())); + let a86 = Str::lit(""); + Ok(join(a85, a86)) + } else { + Ok(v2) + } +} + +pub fn f19(v0: Bytes, v1: u64, v2: u64) -> Str { + let m92 = { + let a89 = v0; + let a90 = v1; + let a91 = { + let a87 = v2; + let a88 = v1; + nat_sub(a87, a88) + }; + slice_bytes(a89, a90, a91) + }; + match m92 { + None => { + Str::lit("") + } + Some(v3) => { + let m94 = { + let a93 = v3; + utf8_decode(a93) + }; + match m94 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f20(p100: u64, v1: Bytes, v2: Bytes, p101: u64) -> R { + let m99 = (p100, p101); + { + let mut m99 = m99; + loop { + let step = { + let (v0, v3) = m99; + let m95 = v0; + if m95 == 0 { + Err::<(u64, u64), R>(Ok(v3)) + } else { + let v4 = m95 - 1; + if f25(v1.clone(), v3, v2.clone()) { + Ok::<(u64, u64), R>((v4, { + let a97 = v3; + let a98 = { + let a96 = v2.clone(); + length_bytes(a96) + }; + nat_add(a97, a98)? + })) + } else { + Err::<(u64, u64), R>(Ok(v3)) + } + } + }; + match step { + Ok(next) => { m99 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f21(v0: Str) -> R { + f26(v0, 65u64, Bytes::lit(&[0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a])) +} + +pub fn f22(v0: u64, v1: Bytes, v2: u64) -> R> { + let m102 = v0; + if m102 == 0 { + Ok(List::::nil()) + } else { + let v3 = m102 - 1; + let a104 = { + let a103 = v1.clone(); + length_bytes(a103) + }; + let a105 = v2; + if nat_le(a104, a105) { + Ok(List::::nil()) + } else { + let v4: u64 = f27(f28(v1.clone(), v2)?); + Ok(List::cons(f19(v1.clone(), v2, { + let a106 = v2; + let a107 = v4; + nat_add(a106, a107)? + }), f22(v3, v1, { + let a108 = v2; + let a109 = v4; + nat_add(a108, a109)? + })?)) + } + } +} + +pub fn f23(p115: List, p116: Str) -> R { + let m114 = (p115, p116); + { + let mut m114 = m114; + loop { + let step = { + let (v0, v1) = m114; + let m110 = v0; + match m110.uncons() { + None => { + Err::<(List, Str), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: bool = true; + let v5: bool = false; + let v6: Adt50 = f29(f17(v2)?, Adt50::C0(v1, v5, v4))?; + let v7: Str = match v6.clone() { + Adt50::C0(h111, _, _) => { + h111 + } + }; + let _: bool = match v6.clone() { + Adt50::C0(_, h112, _) => { + h112 + } + }; + let _: bool = match v6 { + Adt50::C0(_, _, h113) => { + h113 + } + }; + Ok::<(List, Str), R>((v3, v7)) + } + } + }; + match step { + Ok(next) => { m114 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f24(v0: Str) -> R { + let m119 = { + let a117 = f17(v0)?; + let a118 = 0u64; + index_list(a117, a118) + }; + match m119 { + None => { + Ok(false) + } + Some(v1) => { + f30(v1) + } + } +} + +pub fn f25(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m124 = { + let a121 = v0; + let a122 = v1; + let a123 = { + let a120 = v2.clone(); + length_bytes(a120) + }; + slice_bytes(a121, a122, a123) + }; + match m124 { + None => { + false + } + Some(v3) => { + let a125 = v3; + let a126 = v2; + equal(a125, a126) + } + } +} + +pub fn f26(v0: Str, v1: u64, v2: Bytes) -> R { + let v3: Bytes = { + let a127 = v0.clone(); + utf8_encode(a127) + }; + let m131 = { + let a130 = f31({ + let a128 = v3.clone(); + length_bytes(a128) + }, v3, 0u64, v1, v2, { + let a129 = Str::lit(""); + utf8_encode(a129) + })?; + utf8_decode(a130) + }; + match m131 { + None => { + Ok(v0) + } + Some(v4) => { + Ok(v4) + } + } +} + +pub fn f27(v0: u64) -> u64 { + let a132 = v0; + let a133 = 128u64; + if nat_lt(a132, a133) { + 1u64 + } else { + let a134 = v0; + let a135 = 224u64; + if nat_lt(a134, a135) { + 2u64 + } else { + let a136 = v0; + let a137 = 240u64; + if nat_lt(a136, a137) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f28(v0: Bytes, v1: u64) -> R { + let m140 = { + let a138 = v0; + let a139 = v1; + index_bytes(a138, a139) + }; + match m140 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a185 = { + let a161 = { + let a149 = { + let a143 = { + let a141 = v3; + let a142 = 128u8; + fixed_u8::bit_and(a141, a142) + }; + let a144 = 128u8; + if equal(a143, a144) { + 128u64 + } else { + 0u64 + } + }; + let a150 = { + let a147 = { + let a145 = v3; + let a146 = 64u8; + fixed_u8::bit_and(a145, a146) + }; + let a148 = 64u8; + if equal(a147, a148) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a149, a150)? + }; + let a162 = { + let a159 = { + let a153 = { + let a151 = v3; + let a152 = 32u8; + fixed_u8::bit_and(a151, a152) + }; + let a154 = 32u8; + if equal(a153, a154) { + 32u64 + } else { + 0u64 + } + }; + let a160 = { + let a157 = { + let a155 = v3; + let a156 = 16u8; + fixed_u8::bit_and(a155, a156) + }; + let a158 = 16u8; + if equal(a157, a158) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a159, a160)? + }; + nat_add(a161, a162)? + }; + let a186 = { + let a183 = { + let a171 = { + let a165 = { + let a163 = v3; + let a164 = 8u8; + fixed_u8::bit_and(a163, a164) + }; + let a166 = 8u8; + if equal(a165, a166) { + 8u64 + } else { + 0u64 + } + }; + let a172 = { + let a169 = { + let a167 = v3; + let a168 = 4u8; + fixed_u8::bit_and(a167, a168) + }; + let a170 = 4u8; + if equal(a169, a170) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a171, a172)? + }; + let a184 = { + let a181 = { + let a175 = { + let a173 = v3; + let a174 = 2u8; + fixed_u8::bit_and(a173, a174) + }; + let a176 = 2u8; + if equal(a175, a176) { + 2u64 + } else { + 0u64 + } + }; + let a182 = { + let a179 = { + let a177 = v3; + let a178 = 1u8; + fixed_u8::bit_and(a177, a178) + }; + let a180 = 1u8; + if equal(a179, a180) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a181, a182)? + }; + nat_add(a183, a184)? + }; + nat_add(a185, a186) + } + } +} + +pub fn f29(p202: List, p203: Adt50) -> R { + let m201 = (p202, p203); + { + let mut m201 = m201; + loop { + let step = { + let (v0, v1) = m201; + let m187 = v0; + match m187.uncons() { + None => { + Err::<(List, Adt50), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: Str = match v1.clone() { + Adt50::C0(h188, _, _) => { + h188 + } + }; + let v5: bool = match v1.clone() { + Adt50::C0(_, h189, _) => { + h189 + } + }; + let v6: bool = match v1 { + Adt50::C0(_, _, h190) => { + h190 + } + }; + let a191 = f32(v2.clone())?; + if bool_not(a191) { + let v7: bool = true; + let v8: bool = false; + Ok::<(List, Adt50), R>((v3, Adt50::C0(v4, v8, v7))) + } else { + let v14: Adt51 = if v6 { + let v9: Str = { + let a192 = List::cons(v4, List::cons(f33(v2.clone())?, List::::nil())); + let a193 = Str::lit(""); + join(a192, a193) + }; + let v10: bool = false; + Adt51::C0(v9, v10) + } else { + let v13: Str = if if f34(v2.clone())? { + let a194 = v5; + bool_not(a194) + } else { + false + } { + let v11: Str = { + let a195 = List::cons(v4, List::cons(f21(v2.clone())?, List::::nil())); + let a196 = Str::lit(""); + join(a195, a196) + }; + v11 + } else { + let v12: Str = { + let a197 = List::cons(v4, List::cons(v2.clone(), List::::nil())); + let a198 = Str::lit(""); + join(a197, a198) + }; + v12 + }; + Adt51::C0(v13, v6) + }; + let v15: Str = match v14.clone() { + Adt51::C0(h199, _) => { + h199 + } + }; + let v16: bool = match v14 { + Adt51::C0(_, h200) => { + h200 + } + }; + let v17: bool = if f35(v2.clone())? { + true + } else { + f30(v2)? + }; + Ok::<(List, Adt50), R>((v3, Adt50::C0(v15, v17, v16))) + } + } + } + }; + match step { + Ok(next) => { m201 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f30(v0: Str) -> R { + let v1: u64 = f36(v0)?; + let a204 = 48u64; + let a205 = v1; + if nat_le(a204, a205) { + let a206 = v1; + let a207 = 57u64; + Ok(nat_le(a206, a207)) + } else { + Ok(false) + } +} + +pub fn f31(p230: u64, v1: Bytes, p231: u64, v3: u64, v4: Bytes, p232: Bytes) -> R { + let m229 = (p230, (p231, p232)); + { + let mut m229 = m229; + loop { + let step = { + let (v0, (v2, v5)) = m229; + let m208 = v0; + if m208 == 0 { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } else { + let v6 = m208 - 1; + let m212 = { + let a209 = v1.clone(); + let a210 = v2; + let a211 = 1u64; + slice_bytes(a209, a210, a211) + }; + match m212 { + None => { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } + Some(v7) => { + let v8: u64 = f28(v1.clone(), v2)?; + let v10: Bytes = { + let a213 = v3; + let a214 = v8; + if if nat_le(a213, a214) { + let a217 = v8; + let a218 = { + let a215 = v3; + let a216 = 26u64; + nat_add(a215, a216)? + }; + nat_lt(a217, a218) + } else { + false + } { + let m224 = { + let a221 = v4.clone(); + let a222 = { + let a219 = v8; + let a220 = v3; + nat_sub(a219, a220) + }; + let a223 = 1u64; + slice_bytes(a221, a222, a223) + }; + match m224 { + None => { + v7 + } + Some(v9) => { + v9 + } + } + } else { + v7 + } + }; + Ok::<(u64, (u64, Bytes)), R>((v6, ({ + let a225 = v2; + let a226 = 1u64; + nat_add(a225, a226)? + }, { + let a227 = v5; + let a228 = v10; + append_bytes(a227, a228) + }))) + } + } + } + }; + match step { + Ok(next) => { m229 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f32(v0: Str) -> R { + if f37(v0.clone())? { + Ok(true) + } else { + f30(v0) + } +} + +pub fn f33(v0: Str) -> R { + f26(v0, 97u64, Bytes::lit(&[0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a])) +} + +pub fn f34(v0: Str) -> R { + let v1: u64 = f36(v0)?; + let a233 = 65u64; + let a234 = v1; + if nat_le(a233, a234) { + let a235 = v1; + let a236 = 90u64; + Ok(nat_le(a235, a236)) + } else { + Ok(false) + } +} + +pub fn f35(v0: Str) -> R { + let v1: u64 = f36(v0)?; + let a237 = 97u64; + let a238 = v1; + if nat_le(a237, a238) { + let a239 = v1; + let a240 = 122u64; + Ok(nat_le(a239, a240)) + } else { + Ok(false) + } +} + +pub fn f36(v0: Str) -> R { + f28({ + let a241 = v0; + utf8_encode(a241) + }, 0u64) +} + +pub fn f37(v0: Str) -> R { + if f34(v0.clone())? { + Ok(true) + } else { + f35(v0) + } +} + +pub fn run(p0: Adt0, p1: List) -> R>> { + f0(p0, p1) +} diff --git a/crates/certified/roots/uorust_certified_struct_value.rs b/crates/certified/roots/uorust_certified_struct_value.rs new file mode 100644 index 00000000..f5ff7149 --- /dev/null +++ b/crates/certified/roots/uorust_certified_struct_value.rs @@ -0,0 +1,1153 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(Str, Str), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt3 { + C0(Str, List<(Str, Adt4)>), +} + +#[derive(Clone)] +pub enum Adt4 { + C0, + C1, + C2(Option), + C3(u64), + C4(Adt5), + C5(Option), + C6(Option), + C7, + C8, + C9, + C10, + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), + C16(List), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(u64, u64), +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Str, List<(Str, List<(Option, Adt4)>)>), +} + +#[derive(Clone)] +pub enum Adt7 { + C0(Str, Adt5), +} + +#[derive(Clone)] +pub enum Adt8 { + C0(Str, Adt0), +} + +#[derive(Clone)] +pub enum Adt9 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt10 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt11 { + C0(Str, List), +} + +pub fn f0(v0: Str, v1: List, v2: Adt1) -> Str { + if f1(v2, v0.clone()) { + let v3: Str = { + let a1 = f2(v1); + let a2 = Str::lit(""); + join(a1, a2) + }; + let a5 = { + let a3 = List::cons(Str::lit("(ctor "), List::cons(v0, List::::nil())); + let a4 = List::cons(Str::lit(".mk"), List::cons(v3, List::cons(Str::lit(")"), List::::nil()))); + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) + } else { + let v4: List = f3(v1); + let a11 = { + let a9 = List::cons(Str::lit("(record "), List::cons(v0, List::::nil())); + let a10 = List::cons(Str::lit(" {"), List::cons({ + let a7 = v4; + let a8 = Str::lit(", "); + join(a7, a8) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a9, a10) + }; + let a12 = Str::lit(""); + join(a11, a12) + } +} + +pub fn f1(v0: Adt1, v1: Str) -> bool { + if f4(match v0.clone() { + Adt1::C0(_, h13, _, _, _, _, _, _, _, _, _, _, _) => { + h13 + } + }, v1.clone()) { + f5(v1, v0) + } else { + false + } +} + +pub fn f2(v0: List) -> List { + let m14 = v0; + match m14.uncons() { + None => { + List::::nil() + } + Some((v1, v2)) => { + let _: Str = match v1.clone() { + Adt0::C0(h15, _) => { + h15 + } + }; + let v4: Str = match v1 { + Adt0::C0(_, h16) => { + h16 + } + }; + List::cons({ + let a17 = List::cons(Str::lit(" "), List::cons(v4, List::::nil())); + let a18 = Str::lit(""); + join(a17, a18) + }, f2(v2)) + } + } +} + +pub fn f3(v0: List) -> List { + let m19 = v0; + match m19.uncons() { + None => { + List::::nil() + } + Some((v1, v2)) => { + let v3: Str = match v1.clone() { + Adt0::C0(h20, _) => { + h20 + } + }; + let v4: Str = match v1 { + Adt0::C0(_, h21) => { + h21 + } + }; + List::cons({ + let a24 = { + let a22 = List::cons(v3, List::::nil()); + let a23 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a22, a23) + }; + let a25 = Str::lit(""); + join(a24, a25) + }, f3(v2)) + } + } +} + +pub fn f4(p31: List, v1: Str) -> bool { + let m30 = p31; + { + let mut m30 = m30; + loop { + let step = { + let v0 = m30; + let m26 = v0; + match m26.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a28 = match v2 { + Adt3::C0(h27, _) => { + h27 + } + }; + let a29 = v1.clone(); + if equal(a28, a29) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m30 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f5(v0: Str, v1: Adt1) -> bool { + let m32 = f6(v1, v0); + match m32 { + None => { + false + } + Some(_) => { + true + } + } +} + +pub fn f6(v0: Adt1, v1: Str) -> Option> { + f7(match v0 { + Adt1::C0(_, _, _, _, h33, _, _, _, _, _, _, _, _) => { + h33 + } + }, v1) +} + +pub fn f7(p36: List>, v1: Str) -> Option> { + let m35 = p36; + { + let mut m35 = m35; + loop { + let step = { + let v0 = m35; + let m34 = v0; + match m34.uncons() { + None => { + Err::>, Option>>(None::>) + } + Some((v2, v3)) => { + if f8(v2.clone(), v1.clone()) { + Err::>, Option>>(Some(v2)) + } else { + Ok::>, Option>>(v3) + } + } + } + }; + match step { + Ok(next) => { m35 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f8(p41: List, v1: Str) -> bool { + let m40 = p41; + { + let mut m40 = m40; + loop { + let step = { + let v0 = m40; + let m37 = v0; + match m37.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a38 = v2; + let a39 = v1.clone(); + if equal(a38, a39) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m40 = next; } + Err(done) => break done, + } + } + } +} + +pub fn run(p0: Str, p1: List, p2: Adt1) -> Str { + f0(p0, p1, p2) +} diff --git a/crates/certified/roots/uorust_certified_through_pointer.rs b/crates/certified/roots/uorust_certified_through_pointer.rs index fd21e4a2..f875f006 100644 --- a/crates/certified/roots/uorust_certified_through_pointer.rs +++ b/crates/certified/roots/uorust_certified_through_pointer.rs @@ -910,29 +910,37 @@ pub enum Adt5 { pub fn f0(v0: Str) -> Adt0 { f1(f2(Adt5::C0), { - let a1 = List::cons(Str::lit("a "), List::cons(v0, List::cons(Str::lit(" through a raw pointer, into memory the value model does not hold"), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("a "), List::::nil()); + let a2 = List::cons(v0, List::cons(Str::lit(" through a raw pointer, into memory the value model does not hold"), List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) }) } pub fn f1(v0: Str, v1: Str) -> Adt0 { - let a3 = v1.clone(); - let a4 = Str::lit(""); - if equal(a3, a4) { + let a5 = v1.clone(); + let a6 = Str::lit(""); + if equal(a5, a6) { Adt0::C9(v0) } else { Adt0::C9({ - let a5 = List::cons(v0, List::cons(Str::lit(": "), List::cons(v1, List::::nil()))); - let a6 = Str::lit(""); - join(a5, a6) + let a9 = { + let a7 = List::cons(v0, List::::nil()); + let a8 = List::cons(Str::lit(": "), List::cons(v1, List::::nil())); + append_list(a7, a8) + }; + let a10 = Str::lit(""); + join(a9, a10) }) } } pub fn f2(v0: Adt5) -> Str { - let m7 = v0; - match m7 { + let m11 = v0; + match m11 { Adt5::C0 => { Str::lit("ProjectionElem::Deref") } diff --git a/crates/certified/roots/uorust_certified_tuple_item.rs b/crates/certified/roots/uorust_certified_tuple_item.rs index 48a5a525..bb6bd749 100644 --- a/crates/certified/roots/uorust_certified_tuple_item.rs +++ b/crates/certified/roots/uorust_certified_tuple_item.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -888,196 +889,289 @@ pub fn f0(v0: Adt0, v1: Str, v2: u64) -> R { let m1 = v0; match m1 { Adt0::C0 => { - let a2 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a3 = Str::lit(""); - Ok(join(a2, a3)) - } - Adt0::C1 => { - let a4 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); + let a4 = { + let a2 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a3 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a2, a3) + }; let a5 = Str::lit(""); Ok(join(a4, a5)) } + Adt0::C1 => { + let a8 = { + let a6 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a7 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a6, a7) + }; + let a9 = Str::lit(""); + Ok(join(a8, a9)) + } Adt0::C2(_) => { - let a6 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a7 = Str::lit(""); - Ok(join(a6, a7)) + let a12 = { + let a10 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a11 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a10, a11) + }; + let a13 = Str::lit(""); + Ok(join(a12, a13)) } Adt0::C3(_) => { - let a8 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a9 = Str::lit(""); - Ok(join(a8, a9)) + let a16 = { + let a14 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a15 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a14, a15) + }; + let a17 = Str::lit(""); + Ok(join(a16, a17)) } Adt0::C4(_) => { - let a10 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a11 = Str::lit(""); - Ok(join(a10, a11)) + let a20 = { + let a18 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a19 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a18, a19) + }; + let a21 = Str::lit(""); + Ok(join(a20, a21)) } Adt0::C5(_) => { - let a12 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a13 = Str::lit(""); - Ok(join(a12, a13)) + let a24 = { + let a22 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a23 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a22, a23) + }; + let a25 = Str::lit(""); + Ok(join(a24, a25)) } - Adt0::C6 => { - let a14 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a15 = Str::lit(""); - Ok(join(a14, a15)) + Adt0::C6(_) => { + let a28 = { + let a26 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a27 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a26, a27) + }; + let a29 = Str::lit(""); + Ok(join(a28, a29)) } Adt0::C7 => { - let a16 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a17 = Str::lit(""); - Ok(join(a16, a17)) + let a32 = { + let a30 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a31 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a30, a31) + }; + let a33 = Str::lit(""); + Ok(join(a32, a33)) } Adt0::C8 => { - let a18 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a19 = Str::lit(""); - Ok(join(a18, a19)) + let a36 = { + let a34 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a35 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a34, a35) + }; + let a37 = Str::lit(""); + Ok(join(a36, a37)) } Adt0::C9 => { - let a20 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a21 = Str::lit(""); - Ok(join(a20, a21)) + let a40 = { + let a38 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a39 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a38, a39) + }; + let a41 = Str::lit(""); + Ok(join(a40, a41)) } Adt0::C10 => { - let a22 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a23 = Str::lit(""); - Ok(join(a22, a23)) + let a44 = { + let a42 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a43 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a42, a43) + }; + let a45 = Str::lit(""); + Ok(join(a44, a45)) } - Adt0::C11(_) => { - let a24 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a25 = Str::lit(""); - Ok(join(a24, a25)) + Adt0::C11 => { + let a48 = { + let a46 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a47 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a46, a47) + }; + let a49 = Str::lit(""); + Ok(join(a48, a49)) } Adt0::C12(_) => { - let a26 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a27 = Str::lit(""); - Ok(join(a26, a27)) + let a52 = { + let a50 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a51 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a50, a51) + }; + let a53 = Str::lit(""); + Ok(join(a52, a53)) } - Adt0::C13(_, _) => { - let a28 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a29 = Str::lit(""); - Ok(join(a28, a29)) + Adt0::C13(_) => { + let a56 = { + let a54 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a55 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a54, a55) + }; + let a57 = Str::lit(""); + Ok(join(a56, a57)) } - Adt0::C14(_) => { - let a30 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a31 = Str::lit(""); - Ok(join(a30, a31)) + Adt0::C14(_, _) => { + let a60 = { + let a58 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a59 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a58, a59) + }; + let a61 = Str::lit(""); + Ok(join(a60, a61)) } Adt0::C15(_) => { - let a32 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a33 = Str::lit(""); - Ok(join(a32, a33)) + let a64 = { + let a62 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a63 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a62, a63) + }; + let a65 = Str::lit(""); + Ok(join(a64, a65)) } Adt0::C16(_) => { - let a34 = v2; - let a35 = 0u64; - if nat_eq(a34, a35) { - let a36 = List::cons(Str::lit("(first "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))); - let a37 = Str::lit(""); - Ok(join(a36, a37)) + let a68 = { + let a66 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a67 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a66, a67) + }; + let a69 = Str::lit(""); + Ok(join(a68, a69)) + } + Adt0::C17(_) => { + let a70 = v2; + let a71 = 0u64; + if nat_eq(a70, a71) { + let a74 = { + let a72 = List::cons(Str::lit("(first "), List::::nil()); + let a73 = List::cons(v1, List::cons(Str::lit(")"), List::::nil())); + append_list(a72, a73) + }; + let a75 = Str::lit(""); + Ok(join(a74, a75)) } else { - let a38 = List::cons(Str::lit("(second "), List::cons(v1, List::cons(Str::lit(")"), List::::nil()))); - let a39 = Str::lit(""); - Ok(join(a38, a39)) + let a78 = { + let a76 = List::cons(Str::lit("(second "), List::::nil()); + let a77 = List::cons(v1, List::cons(Str::lit(")"), List::::nil())); + append_list(a76, a77) + }; + let a79 = Str::lit(""); + Ok(join(a78, a79)) } } - Adt0::C17(_, _, _) => { - let a40 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a41 = Str::lit(""); - Ok(join(a40, a41)) - } - Adt0::C18(_, _) => { - let a42 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a43 = Str::lit(""); - Ok(join(a42, a43)) + Adt0::C18(_, _, _) => { + let a82 = { + let a80 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a81 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a80, a81) + }; + let a83 = Str::lit(""); + Ok(join(a82, a83)) } Adt0::C19(_, _) => { - let a44 = List::cons(Str::lit("(project "), List::cons(v1, List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))))); - let a45 = Str::lit(""); - Ok(join(a44, a45)) + let a86 = { + let a84 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a85 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a84, a85) + }; + let a87 = Str::lit(""); + Ok(join(a86, a87)) + } + Adt0::C20(_, _) => { + let a90 = { + let a88 = List::cons(Str::lit("(project "), List::cons(v1, List::::nil())); + let a89 = List::cons(Str::lit(" item"), List::cons(f1(v2)?, List::cons(Str::lit(")"), List::::nil()))); + append_list(a88, a89) + }; + let a91 = Str::lit(""); + Ok(join(a90, a91)) } } } pub fn f1(v0: u64) -> R { Ok(f2({ - let a46 = v0; - let a47 = 1u64; - nat_add(a46, a47)? + let a92 = v0; + let a93 = 1u64; + nat_add(a92, a93)? }, v0)) } pub fn f2(v0: u64, v1: u64) -> Str { - let m48 = v0; - if m48 == 0 { + let m94 = v0; + if m94 == 0 { Str::lit("") } else { - let v2 = m48 - 1; - let a49 = v1; - let a50 = 10u64; - if nat_lt(a49, a50) { + let v2 = m94 - 1; + let a95 = v1; + let a96 = 10u64; + if nat_lt(a95, a96) { f3(v1) } else { - let a57 = List::cons(f2(v2, { - let a51 = v1; - let a52 = 10u64; - let a53 = 0u64; - nat_quot(a51, a52, a53) + let a103 = List::cons(f2(v2, { + let a97 = v1; + let a98 = 10u64; + let a99 = 0u64; + nat_quot(a97, a98, a99) }), List::cons(f3({ - let a54 = v1; - let a55 = 10u64; - let a56 = 0u64; - nat_rem(a54, a55, a56) + let a100 = v1; + let a101 = 10u64; + let a102 = 0u64; + nat_rem(a100, a101, a102) }), List::::nil())); - let a58 = Str::lit(""); - join(a57, a58) + let a104 = Str::lit(""); + join(a103, a104) } } } pub fn f3(v0: u64) -> Str { - let a59 = v0; - let a60 = 0u64; - if nat_eq(a59, a60) { + let a105 = v0; + let a106 = 0u64; + if nat_eq(a105, a106) { Str::lit("0") } else { - let a61 = v0; - let a62 = 1u64; - if nat_eq(a61, a62) { + let a107 = v0; + let a108 = 1u64; + if nat_eq(a107, a108) { Str::lit("1") } else { - let a63 = v0; - let a64 = 2u64; - if nat_eq(a63, a64) { + let a109 = v0; + let a110 = 2u64; + if nat_eq(a109, a110) { Str::lit("2") } else { - let a65 = v0; - let a66 = 3u64; - if nat_eq(a65, a66) { + let a111 = v0; + let a112 = 3u64; + if nat_eq(a111, a112) { Str::lit("3") } else { - let a67 = v0; - let a68 = 4u64; - if nat_eq(a67, a68) { + let a113 = v0; + let a114 = 4u64; + if nat_eq(a113, a114) { Str::lit("4") } else { - let a69 = v0; - let a70 = 5u64; - if nat_eq(a69, a70) { + let a115 = v0; + let a116 = 5u64; + if nat_eq(a115, a116) { Str::lit("5") } else { - let a71 = v0; - let a72 = 6u64; - if nat_eq(a71, a72) { + let a117 = v0; + let a118 = 6u64; + if nat_eq(a117, a118) { Str::lit("6") } else { - let a73 = v0; - let a74 = 7u64; - if nat_eq(a73, a74) { + let a119 = v0; + let a120 = 7u64; + if nat_eq(a119, a120) { Str::lit("7") } else { - let a75 = v0; - let a76 = 8u64; - if nat_eq(a75, a76) { + let a121 = v0; + let a122 = 8u64; + if nat_eq(a121, a122) { Str::lit("8") } else { Str::lit("9") diff --git a/crates/certified/roots/uorust_certified_tuple_struct.rs b/crates/certified/roots/uorust_certified_tuple_struct.rs new file mode 100644 index 00000000..d38a8635 --- /dev/null +++ b/crates/certified/roots/uorust_certified_tuple_struct.rs @@ -0,0 +1,3358 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(List, Str), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, Adt2), +} + +#[derive(Clone)] +pub enum Adt2 { + C0, + C1(List), + C2, +} + +#[derive(Clone)] +pub enum Adt3 { + C0(Adt4), + C1(Str), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(Str, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(bool, std::rc::Rc), + C1(std::rc::Rc), + C2(std::rc::Rc, Str), + C3(List, std::rc::Rc), + C4(std::rc::Rc), + C5(List), + C6(bool, Adt0), + C7, +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Adt7, List, List, List), +} + +#[derive(Clone)] +pub enum Adt7 { + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), +} + +#[derive(Clone)] +pub enum Adt8 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt9 { + C0(Str, List<(Str, Adt10)>), +} + +#[derive(Clone)] +pub enum Adt10 { + C0, + C1, + C2(Option), + C3(u64), + C4(Adt11), + C5(Option), + C6(Option), + C7, + C8, + C9, + C10, + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), + C16(List), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt11 { + C0(u64, u64), +} + +#[derive(Clone)] +pub enum Adt12 { + C0(Str, Str), +} + +#[derive(Clone)] +pub enum Adt13 { + C0(Str, List<(Str, List<(Option, Adt10)>)>), +} + +#[derive(Clone)] +pub enum Adt14 { + C0(Str, Adt11), +} + +#[derive(Clone)] +pub enum Adt15 { + C0(Str, Adt12), +} + +#[derive(Clone)] +pub enum Adt16 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt17 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt18 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt19 { + C0(Str, Adt20), +} + +#[derive(Clone)] +pub enum Adt20 { + C0(Str, List, Adt10), +} + +#[derive(Clone)] +pub enum Adt21 { + C0(u64, List), +} + +#[derive(Clone)] +pub enum Adt22 { + C0(Str, List, Adt10, Str, List, List, bool, Option>, List, List, List, Option, List, List, List, Option, Option), +} + +#[derive(Clone)] +pub enum Adt23 { + C0(Str, (Str, Adt10)), +} + +#[derive(Clone)] +pub enum Adt24 { + C0(Str, Adt25), +} + +#[derive(Clone)] +pub enum Adt25 { + C0(List, Adt35, List), +} + +#[derive(Clone)] +pub enum Adt26 { + C0(std::rc::Rc), + C1, + C2(std::rc::Rc), + C3(std::rc::Rc), + C4(List), + C5(Adt29), + C6(Adt30), + C7(List), + C8, + C9(Adt33), + C10(std::rc::Rc), + C11(Adt0), + C12(List), + C13(std::rc::Rc), + C14, +} + +#[derive(Clone)] +pub enum Adt27 { + C0(Str, bool, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt28 { + C0(std::rc::Rc, Adt4), +} + +#[derive(Clone)] +pub enum Adt29 { + C0(Adt0, List), +} + +#[derive(Clone)] +pub enum Adt30 { + C0(Adt0, List, bool), +} + +#[derive(Clone)] +pub enum Adt31 { + C0(Adt32, Adt26), +} + +#[derive(Clone)] +pub enum Adt32 { + C0(Str), + C1(u64), +} + +#[derive(Clone)] +pub enum Adt33 { + C0(bool), + C1(Option, Str), + C2(Str), + C3(Str), + C4(u64), + C5(List), + C6, +} + +#[derive(Clone)] +pub enum Adt34 { + C0(std::rc::Rc>, std::rc::Rc>, bool), +} + +#[derive(Clone)] +pub enum Adt35 { + C0(List), + C1(std::rc::Rc), + C2(std::rc::Rc), + C3(Adt39), + C4(std::rc::Rc), + C5(std::rc::Rc), + C6(std::rc::Rc), + C7(std::rc::Rc), + C8(bool), + C9(std::rc::Rc), + C10(std::rc::Rc), + C11(std::rc::Rc), + C12(std::rc::Rc), + C13(std::rc::Rc), + C14(Adt33), + C15(Adt56), + C16(std::rc::Rc), + C17(std::rc::Rc), + C18(std::rc::Rc), + C19(std::rc::Rc), + C20(Adt0), + C21(std::rc::Rc), + C22(std::rc::Rc>), + C23(std::rc::Rc), + C24(std::rc::Rc), + C25(List), + C26(std::rc::Rc), + C27(std::rc::Rc), + C28(Adt66), +} + +#[derive(Clone)] +pub enum Adt36 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt37 { + C0(std::rc::Rc, Adt38, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt38 { + C0, + C1, + C2, + C3, + C4, + C5, + C6, + C7, + C8, + C9, + C10, + C11, + C12, + C13, + C14, + C15, + C16, + C17, + C18, + C19, + C20, + C21, + C22, + C23, + C24, + C25, + C26, + C27, +} + +#[derive(Clone)] +pub enum Adt39 { + C0(bool, Adt40), +} + +#[derive(Clone)] +pub enum Adt40 { + C0(List), +} + +#[derive(Clone)] +pub enum Adt41 { + C0(Adt42), + C1(Adt35, bool), + C2(Adt44), + C3, +} + +#[derive(Clone)] +pub enum Adt42 { + C0(Adt26, Option), +} + +#[derive(Clone)] +pub enum Adt43 { + C0(Adt35, Option), +} + +#[derive(Clone)] +pub enum Adt44 { + C0(Adt0, Option, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt45 { + C0(List), +} + +#[derive(Clone)] +pub enum Adt46 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt47 { + C0(bool, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt48 { + C0(std::rc::Rc, List), +} + +#[derive(Clone)] +pub enum Adt49 { + C0(std::rc::Rc, Adt4), +} + +#[derive(Clone)] +pub enum Adt50 { + C0(List, std::rc::Rc, bool), +} + +#[derive(Clone)] +pub enum Adt51 { + C0(std::rc::Rc, Adt32), +} + +#[derive(Clone)] +pub enum Adt52 { + C0(bool, std::rc::Rc, std::rc::Rc, Adt40), +} + +#[derive(Clone)] +pub enum Adt53 { + C0(std::rc::Rc, Adt40, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt54 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt55 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt56 { + C0(bool, Adt40), +} + +#[derive(Clone)] +pub enum Adt57 { + C0(std::rc::Rc, List), +} + +#[derive(Clone)] +pub enum Adt58 { + C0(Adt26, Adt35), +} + +#[derive(Clone)] +pub enum Adt59 { + C0(std::rc::Rc, Str, Option>, List), +} + +#[derive(Clone)] +pub enum Adt60 { + C0(bool, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt61 { + C0(bool, Adt0, List, std::rc::Rc>), +} + +#[derive(Clone)] +pub enum Adt62 { + C0(Adt32, Adt35), +} + +#[derive(Clone)] +pub enum Adt63 { + C0(Adt64, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt64 { + C0, + C1, + C2, +} + +#[derive(Clone)] +pub enum Adt65 { + C0(bool, std::rc::Rc, Adt40), +} + +#[derive(Clone)] +pub enum Adt66 { + C0(Str, List, List), +} + +#[derive(Clone)] +pub enum Adt67 { + C0(std::rc::Rc, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt68 { + C0(Str, u64), +} + +#[derive(Clone)] +pub enum Adt69 { + C0, + C1, + C2, + C3, +} + +#[derive(Clone)] +pub enum Adt70 { + C0(Str, bool, bool), +} + +#[derive(Clone)] +pub enum Adt71 { + C0(Str, bool), +} + +pub fn f0(v0: Adt0, v1: u64, v2: Adt6, v3: Adt22) -> R)>> { + let m1 = f1(v0); + match m1 { + None => { + Ok(None::<(Str, List<(Str, Adt10)>)>) + } + Some(v4) => { + let v5: Option = f2(v3)?; + let v6: Str = f3(v2.clone(), v5, v4)?; + let m5 = f4({ + let m4 = match v2 { + Adt6::C0(h3, _, _, _) => { + h3 + } + }; + match m4 { + Adt7::C0(_, h2, _, _, _, _, _, _, _, _, _, _, _) => { + h2 + } + } + }, v6.clone()); + match m5 { + None => { + Ok(None::<(Str, List<(Str, Adt10)>)>) + } + Some(v7) => { + let v8: bool = f5(f6(v7.clone(), 0u64)?)?; + if if v8 { + let a7 = { + let a6 = v7.clone(); + length_list(a6) + }; + let a8 = v1; + nat_eq(a7, a8) + } else { + false + } { + Ok(Some((v6, v7))) + } else { + Ok(None::<(Str, List<(Str, Adt10)>)>) + } + } + } + } + } +} + +pub fn f1(v0: Adt0) -> Option { + let a12 = { + let a10 = { + let a9 = f7(v0.clone()); + length_list(a9) + }; + let a11 = 1u64; + nat_eq(a10, a11) + }; + if bool_not(a12) { + None:: + } else { + let m15 = { + let a13 = f7(v0); + let a14 = 0u64; + index_list(a13, a14) + }; + match m15 { + None => { + None:: + } + Some(v1) => { + if f8(v1.clone()) { + Some(f9(v1)) + } else { + None:: + } + } + } + } +} + +pub fn f2(v0: Adt22) -> R> { + let m16 = f10(v0)?; + match m16 { + None => { + Ok(None::) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt12::C0(h17, _) => { + h17 + } + }; + let _: Str = match v1 { + Adt12::C0(_, h18) => { + h18 + } + }; + Ok(Some(v2)) + } + } +} + +pub fn f3(v0: Adt6, v1: Option, v2: Str) -> R { + let a19 = v2.clone(); + let a20 = Str::lit("Self"); + if equal(a19, a20) { + let m21 = v1; + match m21 { + None => { + f11(match v0 { + Adt6::C0(h22, _, _, _) => { + h22 + } + }, v2) + } + Some(v3) => { + f11(match v0 { + Adt6::C0(h23, _, _, _) => { + h23 + } + }, v3) + } + } + } else { + f11(match v0 { + Adt6::C0(h24, _, _, _) => { + h24 + } + }, v2) + } +} + +pub fn f4(p31: List, v1: Str) -> Option> { + let m30 = p31; + { + let mut m30 = m30; + loop { + let step = { + let v0 = m30; + let m25 = v0; + match m25.uncons() { + None => { + Err::, Option>>(None::>) + } + Some((v2, v3)) => { + let a27 = match v2.clone() { + Adt9::C0(h26, _) => { + h26 + } + }; + let a28 = v1.clone(); + if equal(a27, a28) { + Err::, Option>>(Some(match v2 { + Adt9::C0(_, h29) => { + h29 + } + })) + } else { + Ok::, Option>>(v3) + } + } + } + }; + match step { + Ok(next) => { m30 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f5(p42: List<(u64, (Str, Adt10))>) -> R { + let m41 = p42; + { + let mut m41 = m41; + loop { + let step = { + let v0 = m41; + let m32 = v0; + match m32.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + let v3: u64 = { + let (h33, _) = v1; + h33 + }; + let v4: (Str, Adt10) = { + let (_, h34) = v1; + h34 + }; + let v5: Str = { + let (h35, _) = v4; + h35 + }; + let _: Adt10 = { + let (_, h36) = v4; + h36 + }; + let a39 = v5; + let a40 = f12({ + let a37 = List::cons(f13(v3)?, List::::nil()); + let a38 = Str::lit(""); + join(a37, a38) + })?; + if equal(a39, a40) { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m41 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f6(v0: List<(Str, Adt10)>, v1: u64) -> R> { + let m43 = v0; + match m43.uncons() { + None => { + Ok(List::<(u64, (Str, Adt10))>::nil()) + } + Some((v2, v3)) => { + Ok(List::cons((v1, v2), f6(v3, { + let a44 = v1; + let a45 = 1u64; + nat_add(a44, a45)? + })?)) + } + } +} + +pub fn f7(v0: Adt0) -> List { + let m46 = v0; + match m46 { + Adt0::C0(v1, _) => { + v1 + } + } +} + +pub fn f8(v0: Adt1) -> bool { + let m47 = f14(v0); + match m47 { + Adt2::C0 => { + true + } + Adt2::C1(_) => { + false + } + Adt2::C2 => { + false + } + } +} + +pub fn f9(v0: Adt1) -> Str { + let m48 = v0; + match m48 { + Adt1::C0(v1, _) => { + v1 + } + } +} + +pub fn f10(v0: Adt22) -> R> { + let m50 = f15(match v0.clone() { + Adt22::C0(h49, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => { + h49 + } + }, Str::lit("::"))?; + match m50 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt12::C0(f16(match v0.clone() { + Adt22::C0(h51, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => { + h51 + } + }, 0u64, v1), f16(match v0.clone() { + Adt22::C0(h52, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => { + h52 + } + }, { + let a53 = v1; + let a54 = f17(Str::lit("::")); + nat_add(a53, a54)? + }, f17(match v0 { + Adt22::C0(h55, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => { + h55 + } + }))))) + } + } +} + +pub fn f11(v0: Adt7, v1: Str) -> R { + let v2: Str = f18(v1)?; + let m57 = f19(match v0 { + Adt7::C0(_, _, h56, _, _, _, _, _, _, _, _, _, _) => { + h56 + } + }, v2.clone()); + match m57 { + None => { + Ok(v2) + } + Some(v3) => { + Ok(v3) + } + } +} + +pub fn f12(v0: Str) -> R { + let m58 = f20(v0.clone(), 4294967295u64)?; + match m58 { + Ok(v1) => { + let a59 = List::cons(Str::lit("item"), List::cons(f13(v1)?, List::::nil())); + let a60 = Str::lit(""); + Ok(join(a59, a60)) + } + Err(_) => { + f21(v0) + } + } +} + +pub fn f13(v0: u64) -> R { + Ok(f22({ + let a61 = v0; + let a62 = 1u64; + nat_add(a61, a62)? + }, v0)) +} + +pub fn f14(v0: Adt1) -> Adt2 { + let m63 = v0; + match m63 { + Adt1::C0(_, v2) => { + v2 + } + } +} + +pub fn f15(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a64 = v0; + utf8_encode(a64) + }; + f23({ + let a66 = { + let a65 = v2.clone(); + length_bytes(a65) + }; + let a67 = 1u64; + nat_add(a66, a67)? + }, v2, { + let a68 = v1; + utf8_encode(a68) + }, 0u64) +} + +pub fn f16(v0: Str, v1: u64, v2: u64) -> Str { + f24({ + let a69 = v0; + utf8_encode(a69) + }, v1, v2) +} + +pub fn f17(v0: Str) -> u64 { + let a71 = { + let a70 = v0; + utf8_encode(a70) + }; + length_bytes(a71) +} + +pub fn f18(v0: Str) -> R { + let m72 = f25(v0.clone())?; + match m72 { + None => { + Ok(v0) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt12::C0(h73, _) => { + h73 + } + }; + let v3: Str = match v1 { + Adt12::C0(_, h74) => { + h74 + } + }; + let m75 = f26(v3, Str::lit(">")); + match m75 { + None => { + Ok(v0) + } + Some(v4) => { + if f27(f28(v4, Str::lit(","))?)? { + f29(v2) + } else { + Ok(v0) + } + } + } + } + } +} + +pub fn f19(p82: List, v1: Str) -> Option { + let m81 = p82; + { + let mut m81 = m81; + loop { + let step = { + let v0 = m81; + let m76 = v0; + match m76.uncons() { + None => { + Err::, Option>(None::) + } + Some((v2, v3)) => { + let a78 = match v2.clone() { + Adt12::C0(h77, _) => { + h77 + } + }; + let a79 = v1.clone(); + if equal(a78, a79) { + Err::, Option>(Some(match v2 { + Adt12::C0(_, h80) => { + h80 + } + })) + } else { + Ok::, Option>(v3) + } + } + } + }; + match step { + Ok(next) => { m81 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f20(v0: Str, v1: u64) -> R> { + let v2: Bytes = { + let a83 = v0; + utf8_encode(a83) + }; + let v3: u64 = { + let a84 = v2.clone(); + length_bytes(a84) + }; + let a85 = v3; + let a86 = 0u64; + if nat_eq(a85, a86) { + Ok(Err::(Adt69::C0)) + } else { + let a87 = f30(v2.clone(), 0u64)?; + let a88 = 43u64; + if nat_eq(a87, a88) { + let a89 = v3; + let a90 = 1u64; + if nat_eq(a89, a90) { + Ok(Err::(Adt69::C1)) + } else { + f31(v3, v2, 1u64, 0u64, v1) + } + } else { + f31(v3, v2, 0u64, 0u64, v1) + } + } +} + +pub fn f21(v0: Str) -> R { + let v1: Str = f32(List::cons(f33(v0, Str::lit("r#"))?, List::::nil()))?; + let a91 = v1.clone(); + let a92 = Str::lit(""); + if if equal(a91, a92) { + true + } else { + f34(f35(), v1.clone()) + } { + let a93 = List::cons(v1, List::cons(Str::lit("Value"), List::::nil())); + let a94 = Str::lit(""); + Ok(join(a93, a94)) + } else { + Ok(v1) + } +} + +pub fn f22(v0: u64, v1: u64) -> Str { + let m95 = v0; + if m95 == 0 { + Str::lit("") + } else { + let v2 = m95 - 1; + let a96 = v1; + let a97 = 10u64; + if nat_lt(a96, a97) { + f36(v1) + } else { + let a104 = List::cons(f22(v2, { + let a98 = v1; + let a99 = 10u64; + let a100 = 0u64; + nat_quot(a98, a99, a100) + }), List::cons(f36({ + let a101 = v1; + let a102 = 10u64; + let a103 = 0u64; + nat_rem(a101, a102, a103) + }), List::::nil())); + let a105 = Str::lit(""); + join(a104, a105) + } + } +} + +pub fn f23(p116: u64, v1: Bytes, v2: Bytes, p117: u64) -> R> { + let m115 = (p116, p117); + { + let mut m115 = m115; + loop { + let step = { + let (v0, v3) = m115; + let m106 = v0; + if m106 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m106 - 1; + let a111 = { + let a107 = v1.clone(); + length_bytes(a107) + }; + let a112 = { + let a109 = v3; + let a110 = { + let a108 = v2.clone(); + length_bytes(a108) + }; + nat_add(a109, a110)? + }; + if nat_lt(a111, a112) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f37(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a113 = v3; + let a114 = 1u64; + nat_add(a113, a114)? + })) + } + } + } + }; + match step { + Ok(next) => { m115 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f24(v0: Bytes, v1: u64, v2: u64) -> Str { + let m123 = { + let a120 = v0; + let a121 = v1; + let a122 = { + let a118 = v2; + let a119 = v1; + nat_sub(a118, a119) + }; + slice_bytes(a120, a121, a122) + }; + match m123 { + None => { + Str::lit("") + } + Some(v3) => { + let m125 = { + let a124 = v3; + utf8_decode(a124) + }; + match m125 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f25(v0: Str) -> R> { + let m126 = f15(v0.clone(), Str::lit("<"))?; + match m126 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt12::C0(f16(v0.clone(), 0u64, v1), f16(v0.clone(), { + let a127 = v1; + let a128 = f17(Str::lit("<")); + nat_add(a127, a128)? + }, f17(v0))))) + } + } +} + +pub fn f26(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a129 = v0.clone(); + utf8_encode(a129) + }; + let v3: u64 = { + let a130 = v2.clone(); + length_bytes(a130) + }; + let v4: u64 = f17(v1.clone()); + if f38(v0, v1) { + Some(f24(v2, 0u64, { + let a131 = v3; + let a132 = v4; + nat_sub(a131, a132) + })) + } else { + None:: + } +} + +pub fn f27(p135: List) -> R { + let m134 = p135; + { + let mut m134 = m134; + loop { + let step = { + let v0 = m134; + let m133 = v0; + match m133.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + if f39(v1)? { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m134 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f28(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a136 = v0.clone(); + utf8_encode(a136) + }; + let v3: Bytes = { + let a137 = v1; + utf8_encode(a137) + }; + let a139 = { + let a138 = v3.clone(); + length_bytes(a138) + }; + let a140 = 0u64; + if nat_eq(a139, a140) { + Ok(List::cons(Str::lit(""), { + let a141 = f40(v0)?; + let a142 = List::cons(Str::lit(""), List::::nil()); + append_list(a141, a142) + })) + } else { + f41({ + let a144 = { + let a143 = v2.clone(); + length_bytes(a143) + }; + let a145 = 1u64; + nat_add(a144, a145)? + }, v2, v3, 0u64, 0u64) + } +} + +pub fn f29(v0: Str) -> R { + let v1: Bytes = { + let a146 = v0; + utf8_encode(a146) + }; + let v2: u64 = { + let a147 = v1.clone(); + length_bytes(a147) + }; + Ok(f24(v1.clone(), 0u64, f42(v2, v1, v2)?)) +} + +pub fn f30(v0: Bytes, v1: u64) -> R { + let m150 = { + let a148 = v0; + let a149 = v1; + index_bytes(a148, a149) + }; + match m150 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a195 = { + let a171 = { + let a159 = { + let a153 = { + let a151 = v3; + let a152 = 128u8; + fixed_u8::bit_and(a151, a152) + }; + let a154 = 128u8; + if equal(a153, a154) { + 128u64 + } else { + 0u64 + } + }; + let a160 = { + let a157 = { + let a155 = v3; + let a156 = 64u8; + fixed_u8::bit_and(a155, a156) + }; + let a158 = 64u8; + if equal(a157, a158) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a159, a160)? + }; + let a172 = { + let a169 = { + let a163 = { + let a161 = v3; + let a162 = 32u8; + fixed_u8::bit_and(a161, a162) + }; + let a164 = 32u8; + if equal(a163, a164) { + 32u64 + } else { + 0u64 + } + }; + let a170 = { + let a167 = { + let a165 = v3; + let a166 = 16u8; + fixed_u8::bit_and(a165, a166) + }; + let a168 = 16u8; + if equal(a167, a168) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a169, a170)? + }; + nat_add(a171, a172)? + }; + let a196 = { + let a193 = { + let a181 = { + let a175 = { + let a173 = v3; + let a174 = 8u8; + fixed_u8::bit_and(a173, a174) + }; + let a176 = 8u8; + if equal(a175, a176) { + 8u64 + } else { + 0u64 + } + }; + let a182 = { + let a179 = { + let a177 = v3; + let a178 = 4u8; + fixed_u8::bit_and(a177, a178) + }; + let a180 = 4u8; + if equal(a179, a180) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a181, a182)? + }; + let a194 = { + let a191 = { + let a185 = { + let a183 = v3; + let a184 = 2u8; + fixed_u8::bit_and(a183, a184) + }; + let a186 = 2u8; + if equal(a185, a186) { + 2u64 + } else { + 0u64 + } + }; + let a192 = { + let a189 = { + let a187 = v3; + let a188 = 1u8; + fixed_u8::bit_and(a187, a188) + }; + let a190 = 1u8; + if equal(a189, a190) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a191, a192)? + }; + nat_add(a193, a194)? + }; + nat_add(a195, a196) + } + } +} + +pub fn f31(p216: u64, v1: Bytes, p217: u64, p218: u64, v4: u64) -> R> { + let m215 = (p216, (p217, p218)); + { + let mut m215 = m215; + loop { + let step = { + let (v0, (v2, v3)) = m215; + let m197 = v0; + if m197 == 0 { + Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) + } else { + let v5 = m197 - 1; + let a199 = { + let a198 = v1.clone(); + length_bytes(a198) + }; + let a200 = v2; + if nat_le(a199, a200) { + Err::<(u64, (u64, u64)), R>>(Ok(Ok::(v3))) + } else { + let v6: u64 = f30(v1.clone(), v2)?; + let a201 = 48u64; + let a202 = v6; + if if nat_le(a201, a202) { + let a203 = v6; + let a204 = 57u64; + nat_le(a203, a204) + } else { + false + } { + let v7: u64 = { + let a209 = { + let a205 = v3; + let a206 = 10u64; + nat_mul(a205, a206)? + }; + let a210 = { + let a207 = v6; + let a208 = 48u64; + nat_sub(a207, a208) + }; + nat_add(a209, a210)? + }; + let a211 = v4; + let a212 = v7; + if nat_lt(a211, a212) { + Err::<(u64, (u64, u64)), R>>(Ok(Err::(Adt69::C2))) + } else { + Ok::<(u64, (u64, u64)), R>>((v5, ({ + let a213 = v2; + let a214 = 1u64; + nat_add(a213, a214)? + }, v7))) + } + } else { + Err::<(u64, (u64, u64)), R>>(Ok(Err::(Adt69::C1))) + } + } + } + }; + match step { + Ok(next) => { m215 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f32(v0: List) -> R { + let a219 = f43(f44(f40(f45(v0)?)?, 0u64)?)?; + let a220 = Str::lit(""); + Ok(join(a219, a220)) +} + +pub fn f33(v0: Str, v1: Str) -> R { + let v2: Bytes = { + let a221 = v0.clone(); + utf8_encode(a221) + }; + let v3: Bytes = { + let a222 = v1; + utf8_encode(a222) + }; + let a224 = { + let a223 = v3.clone(); + length_bytes(a223) + }; + let a225 = 0u64; + if nat_eq(a224, a225) { + Ok(v0) + } else { + Ok(f24(v2.clone(), f46({ + let a226 = v2.clone(); + length_bytes(a226) + }, v2.clone(), v3, 0u64)?, { + let a227 = v2; + length_bytes(a227) + })) + } +} + +pub fn f34(p232: List, v1: Str) -> bool { + let m231 = p232; + { + let mut m231 = m231; + loop { + let step = { + let v0 = m231; + let m228 = v0; + match m228.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a229 = v2; + let a230 = v1.clone(); + if equal(a229, a230) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m231 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f35() -> List { + let a261 = { + let a245 = { + let a237 = { + let a233 = List::cons(Str::lit("at"), List::cons(Str::lit("by"), List::cons(Str::lit("calc"), List::cons(Str::lit("def"), List::cons(Str::lit("do"), List::cons(Str::lit("else"), List::::nil())))))); + let a234 = List::cons(Str::lit("end"), List::cons(Str::lit("example"), List::cons(Str::lit("fun"), List::cons(Str::lit("have"), List::cons(Str::lit("if"), List::cons(Str::lit("in"), List::::nil())))))); + append_list(a233, a234) + }; + let a238 = { + let a235 = List::cons(Str::lit("instance"), List::cons(Str::lit("let"), List::cons(Str::lit("match"), List::cons(Str::lit("mut"), List::cons(Str::lit("nomatch"), List::cons(Str::lit("open"), List::::nil())))))); + let a236 = List::cons(Str::lit("prop"), List::cons(Str::lit("return"), List::cons(Str::lit("show"), List::cons(Str::lit("then"), List::cons(Str::lit("theorem"), List::cons(Str::lit("type"), List::cons(Str::lit("where"), List::::nil()))))))); + append_list(a235, a236) + }; + append_list(a237, a238) + }; + let a246 = { + let a243 = { + let a239 = List::cons(Str::lit("with"), List::cons(Str::lit("from"), List::cons(Str::lit("for"), List::cons(Str::lit("try"), List::cons(Str::lit("catch"), List::cons(Str::lit("break"), List::::nil())))))); + let a240 = List::cons(Str::lit("continue"), List::cons(Str::lit("unless"), List::cons(Str::lit("structure"), List::cons(Str::lit("inductive"), List::cons(Str::lit("class"), List::cons(Str::lit("namespace"), List::cons(Str::lit("section"), List::::nil()))))))); + append_list(a239, a240) + }; + let a244 = { + let a241 = List::cons(Str::lit("local"), List::cons(Str::lit("private"), List::cons(Str::lit("protected"), List::cons(Str::lit("partial"), List::cons(Str::lit("unsafe"), List::cons(Str::lit("macro"), List::::nil())))))); + let a242 = List::cons(Str::lit("syntax"), List::cons(Str::lit("import"), List::cons(Str::lit("export"), List::cons(Str::lit("axiom"), List::cons(Str::lit("abbrev"), List::cons(Str::lit("opaque"), List::cons(Str::lit("mutual"), List::::nil()))))))); + append_list(a241, a242) + }; + append_list(a243, a244) + }; + append_list(a245, a246) + }; + let a262 = { + let a259 = { + let a251 = { + let a247 = List::cons(Str::lit("variable"), List::cons(Str::lit("universe"), List::cons(Str::lit("deriving"), List::cons(Str::lit("extends"), List::cons(Str::lit("suffices"), List::cons(Str::lit("obtain"), List::::nil())))))); + let a248 = List::cons(Str::lit("record"), List::cons(Str::lit("ctor"), List::cons(Str::lit("prim"), List::cons(Str::lit("project"), List::cons(Str::lit("cons"), List::cons(Str::lit("nil"), List::::nil())))))); + append_list(a247, a248) + }; + let a252 = { + let a249 = List::cons(Str::lit("not"), List::cons(Str::lit("true"), List::cons(Str::lit("false"), List::cons(Str::lit("forall"), List::cons(Str::lit("first"), List::cons(Str::lit("second"), List::::nil())))))); + let a250 = List::cons(Str::lit("apply"), List::cons(Str::lit("ref"), List::cons(Str::lit("checked"), List::cons(Str::lit("self"), List::cons(Str::lit("noncomputable"), List::cons(Str::lit("termination_by"), List::cons(Str::lit("and_congr"), List::::nil()))))))); + append_list(a249, a250) + }; + append_list(a251, a252) + }; + let a260 = { + let a257 = { + let a253 = List::cons(Str::lit("and_true"), List::cons(Str::lit("beq_iff_eq"), List::cons(Str::lit("congr"), List::cons(Str::lit("decide"), List::cons(Str::lit("decide_eq_false_iff_not"), List::cons(Str::lit("decide_eq_true_eq"), List::::nil())))))); + let a254 = List::cons(Str::lit("id"), List::cons(Str::lit("reduceIte"), List::cons(Str::lit("rfl"), List::cons(Str::lit("true_and"), List::cons(Str::lit("isFalse"), List::cons(Str::lit("isTrue"), List::cons(Str::lit("none"), List::::nil()))))))); + append_list(a253, a254) + }; + let a258 = { + let a255 = List::cons(Str::lit("some"), List::cons(Str::lit("below"), List::cons(Str::lit("brecOn"), List::cons(Str::lit("casesOn"), List::cons(Str::lit("ctorElim"), List::cons(Str::lit("ctorElimType"), List::::nil())))))); + let a256 = List::cons(Str::lit("ctorIdx"), List::cons(Str::lit("mk"), List::cons(Str::lit("noConfusion"), List::cons(Str::lit("noConfusionType"), List::cons(Str::lit("rec"), List::cons(Str::lit("recOn"), List::cons(Str::lit("toCtorIdx"), List::::nil()))))))); + append_list(a255, a256) + }; + append_list(a257, a258) + }; + append_list(a259, a260) + }; + append_list(a261, a262) +} + +pub fn f36(v0: u64) -> Str { + let a263 = v0; + let a264 = 0u64; + if nat_eq(a263, a264) { + Str::lit("0") + } else { + let a265 = v0; + let a266 = 1u64; + if nat_eq(a265, a266) { + Str::lit("1") + } else { + let a267 = v0; + let a268 = 2u64; + if nat_eq(a267, a268) { + Str::lit("2") + } else { + let a269 = v0; + let a270 = 3u64; + if nat_eq(a269, a270) { + Str::lit("3") + } else { + let a271 = v0; + let a272 = 4u64; + if nat_eq(a271, a272) { + Str::lit("4") + } else { + let a273 = v0; + let a274 = 5u64; + if nat_eq(a273, a274) { + Str::lit("5") + } else { + let a275 = v0; + let a276 = 6u64; + if nat_eq(a275, a276) { + Str::lit("6") + } else { + let a277 = v0; + let a278 = 7u64; + if nat_eq(a277, a278) { + Str::lit("7") + } else { + let a279 = v0; + let a280 = 8u64; + if nat_eq(a279, a280) { + Str::lit("8") + } else { + Str::lit("9") + } + } + } + } + } + } + } + } + } +} + +pub fn f37(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m285 = { + let a282 = v0; + let a283 = v1; + let a284 = { + let a281 = v2.clone(); + length_bytes(a281) + }; + slice_bytes(a282, a283, a284) + }; + match m285 { + None => { + false + } + Some(v3) => { + let a286 = v3; + let a287 = v2; + equal(a286, a287) + } + } +} + +pub fn f38(v0: Str, v1: Str) -> bool { + let v2: Bytes = { + let a288 = v0; + utf8_encode(a288) + }; + let v3: Bytes = { + let a289 = v1; + utf8_encode(a289) + }; + let v4: u64 = { + let a290 = v2.clone(); + length_bytes(a290) + }; + let v5: u64 = { + let a291 = v3.clone(); + length_bytes(a291) + }; + let a292 = v5; + let a293 = v4; + if nat_le(a292, a293) { + f37(v2, { + let a294 = v4; + let a295 = v5; + nat_sub(a294, a295) + }, v3) + } else { + false + } +} + +pub fn f39(v0: Str) -> R { + let m296 = f47(f48(v0)?, Str::lit("'")); + match m296 { + None => { + Ok(false) + } + Some(v1) => { + let a297 = f49(v1, Str::lit("'"))?; + Ok(bool_not(a297)) + } + } +} + +pub fn f40(v0: Str) -> R> { + let v1: Bytes = { + let a298 = v0; + utf8_encode(a298) + }; + f50({ + let a299 = v1.clone(); + length_bytes(a299) + }, v1, 0u64) +} + +pub fn f41(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { + let m300 = v0; + if m300 == 0 { + Ok(List::cons(f24(v1.clone(), v3, { + let a301 = v1; + length_bytes(a301) + }), List::::nil())) + } else { + let v5 = m300 - 1; + let a306 = { + let a302 = v1.clone(); + length_bytes(a302) + }; + let a307 = { + let a304 = v4; + let a305 = { + let a303 = v2.clone(); + length_bytes(a303) + }; + nat_add(a304, a305)? + }; + if nat_lt(a306, a307) { + Ok(List::cons(f24(v1.clone(), v3, { + let a308 = v1; + length_bytes(a308) + }), List::::nil())) + } else { + if f37(v1.clone(), v4, v2.clone()) { + Ok(List::cons(f24(v1.clone(), v3, v4), f41(v5, v1, v2.clone(), { + let a310 = v4; + let a311 = { + let a309 = v2.clone(); + length_bytes(a309) + }; + nat_add(a310, a311)? + }, { + let a313 = v4; + let a314 = { + let a312 = v2; + length_bytes(a312) + }; + nat_add(a313, a314)? + })?)) + } else { + f41(v5, v1, v2, v3, { + let a315 = v4; + let a316 = 1u64; + nat_add(a315, a316)? + }) + } + } + } +} + +pub fn f42(p323: u64, v1: Bytes, p324: u64) -> R { + let m322 = (p323, p324); + { + let mut m322 = m322; + loop { + let step = { + let (v0, v2) = m322; + let m317 = v0; + if m317 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m317 - 1; + let v4: u64 = f51(v1.clone(), v2)?; + let a318 = v4; + let a319 = 0u64; + if nat_eq(a318, a319) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a320 = v2; + let a321 = v4; + nat_sub(a320, a321) + })) + } + } + }; + match step { + Ok(next) => { m322 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f43(v0: List) -> R> { + let m325 = v0; + match m325.uncons() { + None => { + Ok(List::::nil()) + } + Some((v1, v2)) => { + let v3: u64 = match v1.clone() { + Adt17::C0(h326, _) => { + h326 + } + }; + let v4: Str = match v1 { + Adt17::C0(_, h327) => { + h327 + } + }; + Ok(List::cons({ + let a328 = v3; + let a329 = 0u64; + if nat_eq(a328, a329) { + f52(v4)? + } else { + v4 + } + }, f43(v2)?)) + } + } +} + +pub fn f44(v0: List, v1: u64) -> R> { + let m330 = v0; + match m330.uncons() { + None => { + Ok(List::::nil()) + } + Some((v2, v3)) => { + Ok(List::cons(Adt17::C0(v1, v2), f44(v3, { + let a331 = v1; + let a332 = 1u64; + nat_add(a331, a332)? + })?)) + } + } +} + +pub fn f45(v0: List) -> R { + let v1: Str = Str::lit(""); + let v2: Str = f53(v0, v1)?; + if f54(v2.clone())? { + let a333 = List::cons(Str::lit("N"), List::cons(v2, List::::nil())); + let a334 = Str::lit(""); + Ok(join(a333, a334)) + } else { + Ok(v2) + } +} + +pub fn f46(p340: u64, v1: Bytes, v2: Bytes, p341: u64) -> R { + let m339 = (p340, p341); + { + let mut m339 = m339; + loop { + let step = { + let (v0, v3) = m339; + let m335 = v0; + if m335 == 0 { + Err::<(u64, u64), R>(Ok(v3)) + } else { + let v4 = m335 - 1; + if f37(v1.clone(), v3, v2.clone()) { + Ok::<(u64, u64), R>((v4, { + let a337 = v3; + let a338 = { + let a336 = v2.clone(); + length_bytes(a336) + }; + nat_add(a337, a338)? + })) + } else { + Err::<(u64, u64), R>(Ok(v3)) + } + } + }; + match step { + Ok(next) => { m339 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f47(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a342 = v0; + utf8_encode(a342) + }; + let v3: Bytes = { + let a343 = v1; + utf8_encode(a343) + }; + if f37(v2.clone(), 0u64, v3.clone()) { + Some(f24(v2.clone(), { + let a344 = v3; + length_bytes(a344) + }, { + let a345 = v2; + length_bytes(a345) + })) + } else { + None:: + } +} + +pub fn f48(v0: Str) -> R { + f29(f55(v0)?) +} + +pub fn f49(v0: Str, v1: Str) -> R { + let m346 = f15(v0, v1)?; + match m346 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f50(v0: u64, v1: Bytes, v2: u64) -> R> { + let m347 = v0; + if m347 == 0 { + Ok(List::::nil()) + } else { + let v3 = m347 - 1; + let a349 = { + let a348 = v1.clone(); + length_bytes(a348) + }; + let a350 = v2; + if nat_le(a349, a350) { + Ok(List::::nil()) + } else { + let v4: u64 = f56(f30(v1.clone(), v2)?); + Ok(List::cons(f24(v1.clone(), v2, { + let a351 = v2; + let a352 = v4; + nat_add(a351, a352)? + }), f50(v3, v1, { + let a353 = v2; + let a354 = v4; + nat_add(a353, a354)? + })?)) + } + } +} + +pub fn f51(v0: Bytes, v1: u64) -> R { + let a355 = v1; + let a356 = 0u64; + if nat_eq(a355, a356) { + Ok(0u64) + } else { + if f57(f30(v0.clone(), { + let a357 = v1; + let a358 = 1u64; + nat_sub(a357, a358) + })?) { + Ok(1u64) + } else { + let a359 = 2u64; + let a360 = v1; + if if nat_le(a359, a360) { + let a363 = f58(v0.clone(), { + let a361 = v1; + let a362 = 2u64; + nat_sub(a361, a362) + })?; + let a364 = 2u64; + nat_eq(a363, a364) + } else { + false + } { + Ok(2u64) + } else { + let a365 = 3u64; + let a366 = v1; + if if nat_le(a365, a366) { + let a369 = f58(v0, { + let a367 = v1; + let a368 = 3u64; + nat_sub(a367, a368) + })?; + let a370 = 3u64; + nat_eq(a369, a370) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f52(v0: Str) -> R { + f59(v0, 65u64, Bytes::lit(&[0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a])) +} + +pub fn f53(p376: List, p377: Str) -> R { + let m375 = (p376, p377); + { + let mut m375 = m375; + loop { + let step = { + let (v0, v1) = m375; + let m371 = v0; + match m371.uncons() { + None => { + Err::<(List, Str), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: bool = true; + let v5: bool = false; + let v6: Adt70 = f60(f40(v2)?, Adt70::C0(v1, v5, v4))?; + let v7: Str = match v6.clone() { + Adt70::C0(h372, _, _) => { + h372 + } + }; + let _: bool = match v6.clone() { + Adt70::C0(_, h373, _) => { + h373 + } + }; + let _: bool = match v6 { + Adt70::C0(_, _, h374) => { + h374 + } + }; + Ok::<(List, Str), R>((v3, v7)) + } + } + }; + match step { + Ok(next) => { m375 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f54(v0: Str) -> R { + let m380 = { + let a378 = f40(v0)?; + let a379 = 0u64; + index_list(a378, a379) + }; + match m380 { + None => { + Ok(false) + } + Some(v1) => { + f61(v1) + } + } +} + +pub fn f55(v0: Str) -> R { + let v1: Bytes = { + let a381 = v0; + utf8_encode(a381) + }; + let v2: u64 = { + let a382 = v1.clone(); + length_bytes(a382) + }; + Ok(f24(v1.clone(), f62(v2, v1, 0u64)?, v2)) +} + +pub fn f56(v0: u64) -> u64 { + let a383 = v0; + let a384 = 128u64; + if nat_lt(a383, a384) { + 1u64 + } else { + let a385 = v0; + let a386 = 224u64; + if nat_lt(a385, a386) { + 2u64 + } else { + let a387 = v0; + let a388 = 240u64; + if nat_lt(a387, a388) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f57(v0: u64) -> bool { + let a389 = v0; + let a390 = 32u64; + if nat_eq(a389, a390) { + true + } else { + let a391 = 9u64; + let a392 = v0; + if nat_le(a391, a392) { + let a393 = v0; + let a394 = 13u64; + nat_le(a393, a394) + } else { + false + } + } +} + +pub fn f58(v0: Bytes, v1: u64) -> R { + let v2: u64 = f30(v0.clone(), v1)?; + let v3: u64 = f30(v0.clone(), { + let a395 = v1; + let a396 = 1u64; + nat_add(a395, a396)? + })?; + let v4: u64 = f30(v0, { + let a397 = v1; + let a398 = 2u64; + nat_add(a397, a398)? + })?; + if f57(v2) { + Ok(1u64) + } else { + let a399 = v2; + let a400 = 194u64; + if nat_eq(a399, a400) { + let a401 = v3; + let a402 = 133u64; + if if nat_eq(a401, a402) { + true + } else { + let a403 = v3; + let a404 = 160u64; + nat_eq(a403, a404) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a405 = v2; + let a406 = 225u64; + if nat_eq(a405, a406) { + let a407 = v3; + let a408 = 154u64; + if if nat_eq(a407, a408) { + let a409 = v4; + let a410 = 128u64; + nat_eq(a409, a410) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a411 = v2; + let a412 = 226u64; + if nat_eq(a411, a412) { + let a413 = v3; + let a414 = 128u64; + if nat_eq(a413, a414) { + let a415 = 128u64; + let a416 = v4; + if if if nat_le(a415, a416) { + let a417 = v4; + let a418 = 138u64; + nat_le(a417, a418) + } else { + false + } { + true + } else { + let a419 = v4; + let a420 = 168u64; + if nat_eq(a419, a420) { + true + } else { + let a421 = v4; + let a422 = 169u64; + if nat_eq(a421, a422) { + true + } else { + let a423 = v4; + let a424 = 175u64; + nat_eq(a423, a424) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a425 = v3; + let a426 = 129u64; + if if nat_eq(a425, a426) { + let a427 = v4; + let a428 = 159u64; + nat_eq(a427, a428) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a429 = v2; + let a430 = 227u64; + if if nat_eq(a429, a430) { + let a431 = v3; + let a432 = 128u64; + if nat_eq(a431, a432) { + let a433 = v4; + let a434 = 128u64; + nat_eq(a433, a434) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f59(v0: Str, v1: u64, v2: Bytes) -> R { + let v3: Bytes = { + let a435 = v0.clone(); + utf8_encode(a435) + }; + let m439 = { + let a438 = f63({ + let a436 = v3.clone(); + length_bytes(a436) + }, v3, 0u64, v1, v2, { + let a437 = Str::lit(""); + utf8_encode(a437) + })?; + utf8_decode(a438) + }; + match m439 { + None => { + Ok(v0) + } + Some(v4) => { + Ok(v4) + } + } +} + +pub fn f60(p455: List, p456: Adt70) -> R { + let m454 = (p455, p456); + { + let mut m454 = m454; + loop { + let step = { + let (v0, v1) = m454; + let m440 = v0; + match m440.uncons() { + None => { + Err::<(List, Adt70), R>(Ok(v1)) + } + Some((v2, v3)) => { + let v4: Str = match v1.clone() { + Adt70::C0(h441, _, _) => { + h441 + } + }; + let v5: bool = match v1.clone() { + Adt70::C0(_, h442, _) => { + h442 + } + }; + let v6: bool = match v1 { + Adt70::C0(_, _, h443) => { + h443 + } + }; + let a444 = f64(v2.clone())?; + if bool_not(a444) { + let v7: bool = true; + let v8: bool = false; + Ok::<(List, Adt70), R>((v3, Adt70::C0(v4, v8, v7))) + } else { + let v14: Adt71 = if v6 { + let v9: Str = { + let a445 = List::cons(v4, List::cons(f65(v2.clone())?, List::::nil())); + let a446 = Str::lit(""); + join(a445, a446) + }; + let v10: bool = false; + Adt71::C0(v9, v10) + } else { + let v13: Str = if if f66(v2.clone())? { + let a447 = v5; + bool_not(a447) + } else { + false + } { + let v11: Str = { + let a448 = List::cons(v4, List::cons(f52(v2.clone())?, List::::nil())); + let a449 = Str::lit(""); + join(a448, a449) + }; + v11 + } else { + let v12: Str = { + let a450 = List::cons(v4, List::cons(v2.clone(), List::::nil())); + let a451 = Str::lit(""); + join(a450, a451) + }; + v12 + }; + Adt71::C0(v13, v6) + }; + let v15: Str = match v14.clone() { + Adt71::C0(h452, _) => { + h452 + } + }; + let v16: bool = match v14 { + Adt71::C0(_, h453) => { + h453 + } + }; + let v17: bool = if f67(v2.clone())? { + true + } else { + f61(v2)? + }; + Ok::<(List, Adt70), R>((v3, Adt70::C0(v15, v17, v16))) + } + } + } + }; + match step { + Ok(next) => { m454 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f61(v0: Str) -> R { + let v1: u64 = f68(v0)?; + let a457 = 48u64; + let a458 = v1; + if nat_le(a457, a458) { + let a459 = v1; + let a460 = 57u64; + Ok(nat_le(a459, a460)) + } else { + Ok(false) + } +} + +pub fn f62(p467: u64, v1: Bytes, p468: u64) -> R { + let m466 = (p467, p468); + { + let mut m466 = m466; + loop { + let step = { + let (v0, v2) = m466; + let m461 = v0; + if m461 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m461 - 1; + let v4: u64 = f58(v1.clone(), v2)?; + let a462 = v4; + let a463 = 0u64; + if nat_eq(a462, a463) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a464 = v2; + let a465 = v4; + nat_add(a464, a465)? + })) + } + } + }; + match step { + Ok(next) => { m466 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f63(p491: u64, v1: Bytes, p492: u64, v3: u64, v4: Bytes, p493: Bytes) -> R { + let m490 = (p491, (p492, p493)); + { + let mut m490 = m490; + loop { + let step = { + let (v0, (v2, v5)) = m490; + let m469 = v0; + if m469 == 0 { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } else { + let v6 = m469 - 1; + let m473 = { + let a470 = v1.clone(); + let a471 = v2; + let a472 = 1u64; + slice_bytes(a470, a471, a472) + }; + match m473 { + None => { + Err::<(u64, (u64, Bytes)), R>(Ok(v5)) + } + Some(v7) => { + let v8: u64 = f30(v1.clone(), v2)?; + let v10: Bytes = { + let a474 = v3; + let a475 = v8; + if if nat_le(a474, a475) { + let a478 = v8; + let a479 = { + let a476 = v3; + let a477 = 26u64; + nat_add(a476, a477)? + }; + nat_lt(a478, a479) + } else { + false + } { + let m485 = { + let a482 = v4.clone(); + let a483 = { + let a480 = v8; + let a481 = v3; + nat_sub(a480, a481) + }; + let a484 = 1u64; + slice_bytes(a482, a483, a484) + }; + match m485 { + None => { + v7 + } + Some(v9) => { + v9 + } + } + } else { + v7 + } + }; + Ok::<(u64, (u64, Bytes)), R>((v6, ({ + let a486 = v2; + let a487 = 1u64; + nat_add(a486, a487)? + }, { + let a488 = v5; + let a489 = v10; + append_bytes(a488, a489) + }))) + } + } + } + }; + match step { + Ok(next) => { m490 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f64(v0: Str) -> R { + if f69(v0.clone())? { + Ok(true) + } else { + f61(v0) + } +} + +pub fn f65(v0: Str) -> R { + f59(v0, 97u64, Bytes::lit(&[0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a])) +} + +pub fn f66(v0: Str) -> R { + let v1: u64 = f68(v0)?; + let a494 = 65u64; + let a495 = v1; + if nat_le(a494, a495) { + let a496 = v1; + let a497 = 90u64; + Ok(nat_le(a496, a497)) + } else { + Ok(false) + } +} + +pub fn f67(v0: Str) -> R { + let v1: u64 = f68(v0)?; + let a498 = 97u64; + let a499 = v1; + if nat_le(a498, a499) { + let a500 = v1; + let a501 = 122u64; + Ok(nat_le(a500, a501)) + } else { + Ok(false) + } +} + +pub fn f68(v0: Str) -> R { + f30({ + let a502 = v0; + utf8_encode(a502) + }, 0u64) +} + +pub fn f69(v0: Str) -> R { + if f66(v0.clone())? { + Ok(true) + } else { + f67(v0) + } +} + +pub fn run(p0: Adt0, p1: u64, p2: Adt6, p3: Adt22) -> R)>> { + f0(p0, p1, p2, p3) +} diff --git a/crates/certified/roots/uorust_certified_tuple_value.rs b/crates/certified/roots/uorust_certified_tuple_value.rs index 0cd1b856..da089259 100644 --- a/crates/certified/roots/uorust_certified_tuple_value.rs +++ b/crates/certified/roots/uorust_certified_tuple_value.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -894,255 +895,353 @@ pub fn f0(v0: Adt0, v1: List) -> R { match m1 { Adt0::C0 => { let v2: List = f1(f2(v1, 0u64)?)?; - let a4 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C0), List::cons(Str::lit(" {"), List::cons({ - let a2 = v2; - let a3 = Str::lit(", "); - join(a2, a3) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a5 = Str::lit(""); - Ok(join(a4, a5)) + let a6 = { + let a4 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C0), List::::nil())); + let a5 = List::cons(Str::lit(" {"), List::cons({ + let a2 = v2; + let a3 = Str::lit(", "); + join(a2, a3) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a4, a5) + }; + let a7 = Str::lit(""); + Ok(join(a6, a7)) } Adt0::C1 => { let v3: List = f4(f5(v1, 0u64)?)?; - let a8 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C1), List::cons(Str::lit(" {"), List::cons({ - let a6 = v3; - let a7 = Str::lit(", "); - join(a6, a7) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a9 = Str::lit(""); - Ok(join(a8, a9)) + let a12 = { + let a10 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C1), List::::nil())); + let a11 = List::cons(Str::lit(" {"), List::cons({ + let a8 = v3; + let a9 = Str::lit(", "); + join(a8, a9) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a10, a11) + }; + let a13 = Str::lit(""); + Ok(join(a12, a13)) } Adt0::C2(v4) => { let v5: List = f6(f7(v1, 0u64)?)?; - let a12 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C2(v4)), List::cons(Str::lit(" {"), List::cons({ - let a10 = v5; - let a11 = Str::lit(", "); - join(a10, a11) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a13 = Str::lit(""); - Ok(join(a12, a13)) + let a18 = { + let a16 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C2(v4)), List::::nil())); + let a17 = List::cons(Str::lit(" {"), List::cons({ + let a14 = v5; + let a15 = Str::lit(", "); + join(a14, a15) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a16, a17) + }; + let a19 = Str::lit(""); + Ok(join(a18, a19)) } Adt0::C3(v6) => { let v7: List = f8(f9(v1, 0u64)?)?; - let a16 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C3(v6)), List::cons(Str::lit(" {"), List::cons({ - let a14 = v7; - let a15 = Str::lit(", "); - join(a14, a15) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a17 = Str::lit(""); - Ok(join(a16, a17)) + let a24 = { + let a22 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C3(v6)), List::::nil())); + let a23 = List::cons(Str::lit(" {"), List::cons({ + let a20 = v7; + let a21 = Str::lit(", "); + join(a20, a21) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a22, a23) + }; + let a25 = Str::lit(""); + Ok(join(a24, a25)) } Adt0::C4(v8) => { let v9: List = f10(f11(v1, 0u64)?)?; - let a20 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C4(v8)), List::cons(Str::lit(" {"), List::cons({ - let a18 = v9; - let a19 = Str::lit(", "); - join(a18, a19) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a21 = Str::lit(""); - Ok(join(a20, a21)) + let a30 = { + let a28 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C4(v8)), List::::nil())); + let a29 = List::cons(Str::lit(" {"), List::cons({ + let a26 = v9; + let a27 = Str::lit(", "); + join(a26, a27) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a28, a29) + }; + let a31 = Str::lit(""); + Ok(join(a30, a31)) } Adt0::C5(v10) => { let v11: List = f12(f13(v1, 0u64)?)?; - let a24 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C5(v10)), List::cons(Str::lit(" {"), List::cons({ - let a22 = v11; - let a23 = Str::lit(", "); - join(a22, a23) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a25 = Str::lit(""); - Ok(join(a24, a25)) - } - Adt0::C6 => { - let v12: List = f14(f15(v1, 0u64)?)?; - let a28 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C6), List::cons(Str::lit(" {"), List::cons({ - let a26 = v12; - let a27 = Str::lit(", "); - join(a26, a27) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a29 = Str::lit(""); - Ok(join(a28, a29)) - } - Adt0::C7 => { - let v13: List = f16(f17(v1, 0u64)?)?; - let a32 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C7), List::cons(Str::lit(" {"), List::cons({ - let a30 = v13; - let a31 = Str::lit(", "); - join(a30, a31) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a33 = Str::lit(""); - Ok(join(a32, a33)) - } - Adt0::C8 => { - let v14: List = f18(f19(v1, 0u64)?)?; - let a36 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C8), List::cons(Str::lit(" {"), List::cons({ - let a34 = v14; - let a35 = Str::lit(", "); - join(a34, a35) - }, List::cons(Str::lit("})"), List::::nil()))))); + let a36 = { + let a34 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C5(v10)), List::::nil())); + let a35 = List::cons(Str::lit(" {"), List::cons({ + let a32 = v11; + let a33 = Str::lit(", "); + join(a32, a33) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a34, a35) + }; let a37 = Str::lit(""); Ok(join(a36, a37)) } - Adt0::C9 => { - let v15: List = f20(f21(v1, 0u64)?)?; - let a40 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C9), List::cons(Str::lit(" {"), List::cons({ - let a38 = v15; - let a39 = Str::lit(", "); - join(a38, a39) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a41 = Str::lit(""); - Ok(join(a40, a41)) + Adt0::C6(v12) => { + let v13: List = f14(f15(v1, 0u64)?)?; + let a42 = { + let a40 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C6(v12)), List::::nil())); + let a41 = List::cons(Str::lit(" {"), List::cons({ + let a38 = v13; + let a39 = Str::lit(", "); + join(a38, a39) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a40, a41) + }; + let a43 = Str::lit(""); + Ok(join(a42, a43)) } - Adt0::C10 => { - let v16: List = f22(f23(v1, 0u64)?)?; - let a44 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C10), List::cons(Str::lit(" {"), List::cons({ - let a42 = v16; - let a43 = Str::lit(", "); - join(a42, a43) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a45 = Str::lit(""); - Ok(join(a44, a45)) - } - Adt0::C11(v17) => { - let v18: List = f24(f25(v1, 0u64)?)?; - let a48 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C11(v17)), List::cons(Str::lit(" {"), List::cons({ - let a46 = v18; - let a47 = Str::lit(", "); - join(a46, a47) - }, List::cons(Str::lit("})"), List::::nil()))))); + Adt0::C7 => { + let v14: List = f16(f17(v1, 0u64)?)?; + let a48 = { + let a46 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C7), List::::nil())); + let a47 = List::cons(Str::lit(" {"), List::cons({ + let a44 = v14; + let a45 = Str::lit(", "); + join(a44, a45) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a46, a47) + }; let a49 = Str::lit(""); Ok(join(a48, a49)) } - Adt0::C12(r80) => { - let v19 = (*r80).clone(); - let v20: List = f26(f27(v1, 0u64)?)?; - let a52 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C12(std::rc::Rc::new(v19))), List::cons(Str::lit(" {"), List::cons({ - let a50 = v20; - let a51 = Str::lit(", "); - join(a50, a51) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a53 = Str::lit(""); - Ok(join(a52, a53)) - } - Adt0::C13(r81, r82) => { - let v21 = (*r81).clone(); - let v22 = (*r82).clone(); - let v23: List = f28(f29(v1, 0u64)?)?; - let a56 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C13(std::rc::Rc::new(v21), std::rc::Rc::new(v22))), List::cons(Str::lit(" {"), List::cons({ - let a54 = v23; - let a55 = Str::lit(", "); - join(a54, a55) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a57 = Str::lit(""); - Ok(join(a56, a57)) - } - Adt0::C14(r83) => { - let v24 = (*r83).clone(); - let v25: List = f30(f31(v1, 0u64)?)?; - let a60 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C14(std::rc::Rc::new(v24))), List::cons(Str::lit(" {"), List::cons({ - let a58 = v25; - let a59 = Str::lit(", "); - join(a58, a59) - }, List::cons(Str::lit("})"), List::::nil()))))); + Adt0::C8 => { + let v15: List = f18(f19(v1, 0u64)?)?; + let a54 = { + let a52 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C8), List::::nil())); + let a53 = List::cons(Str::lit(" {"), List::cons({ + let a50 = v15; + let a51 = Str::lit(", "); + join(a50, a51) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a52, a53) + }; + let a55 = Str::lit(""); + Ok(join(a54, a55)) + } + Adt0::C9 => { + let v16: List = f20(f21(v1, 0u64)?)?; + let a60 = { + let a58 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C9), List::::nil())); + let a59 = List::cons(Str::lit(" {"), List::cons({ + let a56 = v16; + let a57 = Str::lit(", "); + join(a56, a57) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a58, a59) + }; let a61 = Str::lit(""); Ok(join(a60, a61)) } - Adt0::C15(v26) => { - let v27: List = f32(f33(v1, 0u64)?)?; - let a64 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C15(v26)), List::cons(Str::lit(" {"), List::cons({ - let a62 = v27; - let a63 = Str::lit(", "); - join(a62, a63) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a65 = Str::lit(""); - Ok(join(a64, a65)) - } - Adt0::C16(_) => { - let a66 = List::cons(Str::lit("("), List::cons(f34(v1.clone()), List::cons(Str::lit(", "), List::cons(f35(v1), List::cons(Str::lit(")"), List::::nil()))))); + Adt0::C10 => { + let v17: List = f22(f23(v1, 0u64)?)?; + let a66 = { + let a64 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C10), List::::nil())); + let a65 = List::cons(Str::lit(" {"), List::cons({ + let a62 = v17; + let a63 = Str::lit(", "); + join(a62, a63) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a64, a65) + }; let a67 = Str::lit(""); Ok(join(a66, a67)) } - Adt0::C17(r84, r85, v31) => { - let v29 = (*r84).clone(); - let v30 = (*r85).clone(); - let v32: List = f36(f37(v1, 0u64)?)?; - let a70 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C17(std::rc::Rc::new(v29), std::rc::Rc::new(v30), v31)), List::cons(Str::lit(" {"), List::cons({ - let a68 = v32; - let a69 = Str::lit(", "); - join(a68, a69) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a71 = Str::lit(""); - Ok(join(a70, a71)) - } - Adt0::C18(r86, v34) => { - let v33 = (*r86).clone(); - let v35: List = f38(f39(v1, 0u64)?)?; - let a74 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C18(std::rc::Rc::new(v33), v34)), List::cons(Str::lit(" {"), List::cons({ - let a72 = v35; - let a73 = Str::lit(", "); - join(a72, a73) - }, List::cons(Str::lit("})"), List::::nil()))))); - let a75 = Str::lit(""); - Ok(join(a74, a75)) - } - Adt0::C19(v36, r87) => { - let v37 = (*r87).clone(); - let v38: List = f40(f41(v1, 0u64)?)?; - let a78 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C19(v36, std::rc::Rc::new(v37))), List::cons(Str::lit(" {"), List::cons({ - let a76 = v38; - let a77 = Str::lit(", "); - join(a76, a77) - }, List::cons(Str::lit("})"), List::::nil()))))); + Adt0::C11 => { + let v18: List = f24(f25(v1, 0u64)?)?; + let a72 = { + let a70 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C11), List::::nil())); + let a71 = List::cons(Str::lit(" {"), List::cons({ + let a68 = v18; + let a69 = Str::lit(", "); + join(a68, a69) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a70, a71) + }; + let a73 = Str::lit(""); + Ok(join(a72, a73)) + } + Adt0::C12(v19) => { + let v20: List = f26(f27(v1, 0u64)?)?; + let a78 = { + let a76 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C12(v19)), List::::nil())); + let a77 = List::cons(Str::lit(" {"), List::cons({ + let a74 = v20; + let a75 = Str::lit(", "); + join(a74, a75) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a76, a77) + }; let a79 = Str::lit(""); Ok(join(a78, a79)) } + Adt0::C13(r126) => { + let v21 = (*r126).clone(); + let v22: List = f28(f29(v1, 0u64)?)?; + let a84 = { + let a82 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C13(std::rc::Rc::new(v21))), List::::nil())); + let a83 = List::cons(Str::lit(" {"), List::cons({ + let a80 = v22; + let a81 = Str::lit(", "); + join(a80, a81) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a82, a83) + }; + let a85 = Str::lit(""); + Ok(join(a84, a85)) + } + Adt0::C14(r127, r128) => { + let v23 = (*r127).clone(); + let v24 = (*r128).clone(); + let v25: List = f30(f31(v1, 0u64)?)?; + let a90 = { + let a88 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C14(std::rc::Rc::new(v23), std::rc::Rc::new(v24))), List::::nil())); + let a89 = List::cons(Str::lit(" {"), List::cons({ + let a86 = v25; + let a87 = Str::lit(", "); + join(a86, a87) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a88, a89) + }; + let a91 = Str::lit(""); + Ok(join(a90, a91)) + } + Adt0::C15(r129) => { + let v26 = (*r129).clone(); + let v27: List = f32(f33(v1, 0u64)?)?; + let a96 = { + let a94 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C15(std::rc::Rc::new(v26))), List::::nil())); + let a95 = List::cons(Str::lit(" {"), List::cons({ + let a92 = v27; + let a93 = Str::lit(", "); + join(a92, a93) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a94, a95) + }; + let a97 = Str::lit(""); + Ok(join(a96, a97)) + } + Adt0::C16(v28) => { + let v29: List = f34(f35(v1, 0u64)?)?; + let a102 = { + let a100 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C16(v28)), List::::nil())); + let a101 = List::cons(Str::lit(" {"), List::cons({ + let a98 = v29; + let a99 = Str::lit(", "); + join(a98, a99) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a100, a101) + }; + let a103 = Str::lit(""); + Ok(join(a102, a103)) + } + Adt0::C17(_) => { + let a106 = { + let a104 = List::cons(Str::lit("("), List::cons(f36(v1.clone()), List::::nil())); + let a105 = List::cons(Str::lit(", "), List::cons(f37(v1), List::cons(Str::lit(")"), List::::nil()))); + append_list(a104, a105) + }; + let a107 = Str::lit(""); + Ok(join(a106, a107)) + } + Adt0::C18(r130, r131, v33) => { + let v31 = (*r130).clone(); + let v32 = (*r131).clone(); + let v34: List = f38(f39(v1, 0u64)?)?; + let a112 = { + let a110 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C18(std::rc::Rc::new(v31), std::rc::Rc::new(v32), v33)), List::::nil())); + let a111 = List::cons(Str::lit(" {"), List::cons({ + let a108 = v34; + let a109 = Str::lit(", "); + join(a108, a109) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a110, a111) + }; + let a113 = Str::lit(""); + Ok(join(a112, a113)) + } + Adt0::C19(r132, v36) => { + let v35 = (*r132).clone(); + let v37: List = f40(f41(v1, 0u64)?)?; + let a118 = { + let a116 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C19(std::rc::Rc::new(v35), v36)), List::::nil())); + let a117 = List::cons(Str::lit(" {"), List::cons({ + let a114 = v37; + let a115 = Str::lit(", "); + join(a114, a115) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a116, a117) + }; + let a119 = Str::lit(""); + Ok(join(a118, a119)) + } + Adt0::C20(v38, r133) => { + let v39 = (*r133).clone(); + let v40: List = f42(f43(v1, 0u64)?)?; + let a124 = { + let a122 = List::cons(Str::lit("(record "), List::cons(f3(Adt0::C20(v38, std::rc::Rc::new(v39))), List::::nil())); + let a123 = List::cons(Str::lit(" {"), List::cons({ + let a120 = v40; + let a121 = Str::lit(", "); + join(a120, a121) + }, List::cons(Str::lit("})"), List::::nil()))); + append_list(a122, a123) + }; + let a125 = Str::lit(""); + Ok(join(a124, a125)) + } } } pub fn f1(v0: List) -> R> { - let m88 = v0; - match m88.uncons() { + let m134 = v0; + match m134.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h89, _) => { - h89 + Adt2::C0(h135, _) => { + h135 } }; let v4: Str = match v1 { - Adt2::C0(_, h90) => { - h90 + Adt2::C0(_, h136) => { + h136 } }; Ok(List::cons({ - let a91 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a92 = Str::lit(""); - join(a91, a92) + let a139 = { + let a137 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a138 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a137, a138) + }; + let a140 = Str::lit(""); + join(a139, a140) }, f1(v2)?)) } } } pub fn f2(v0: List, v1: u64) -> R> { - let m93 = v0; - match m93.uncons() { + let m141 = v0; + match m141.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f2(v3, { - let a94 = v1; - let a95 = 1u64; - nat_add(a94, a95)? + let a142 = v1; + let a143 = 1u64; + nat_add(a142, a143)? })?)) } } } pub fn f3(v0: Adt0) -> Str { - let m96 = v0; - match m96 { + let m144 = v0; + match m144 { Adt0::C0 => { Str::lit("Unit") } @@ -1159,730 +1258,867 @@ pub fn f3(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + Str::lit("Int") } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - let a97 = List::cons(f43(), List::cons(Str::lit("::ParseIntError"), List::::nil())); - let a98 = Str::lit(""); - join(a97, a98) + Str::lit("Nat") } Adt0::C10 => { - let a99 = List::cons(f43(), List::cons(Str::lit("::FilePath"), List::::nil())); - let a100 = Str::lit(""); - join(a99, a100) - } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r123) => { - let v6 = (*r123).clone(); - let a101 = List::cons(Str::lit("(Option "), List::cons(f3(v6), List::cons(Str::lit(")"), List::::nil()))); - let a102 = Str::lit(""); - join(a101, a102) - } - Adt0::C13(r124, r125) => { - let v7 = (*r124).clone(); - let v8 = (*r125).clone(); - let a103 = List::cons(Str::lit("(Result "), List::cons(f3(v7), List::cons(Str::lit(" "), List::cons(f3(v8), List::cons(Str::lit(")"), List::::nil()))))); - let a104 = Str::lit(""); - join(a103, a104) - } - Adt0::C14(r126) => { - let v9 = (*r126).clone(); - let a105 = List::cons(Str::lit("(List "), List::cons(f3(v9), List::cons(Str::lit(")"), List::::nil()))); - let a106 = Str::lit(""); - join(a105, a106) - } - Adt0::C15(v10) => { - let a109 = List::cons(Str::lit("Tuple"), List::cons({ - let a107 = f44(v10); - let a108 = Str::lit(""); - join(a107, a108) - }, List::::nil())); - let a110 = Str::lit(""); - join(a109, a110) + let a145 = List::cons(f45(), List::cons(Str::lit("::ParseIntError"), List::::nil())); + let a146 = Str::lit(""); + join(a145, a146) + } + Adt0::C11 => { + let a147 = List::cons(f45(), List::cons(Str::lit("::FilePath"), List::::nil())); + let a148 = Str::lit(""); + join(a147, a148) + } + Adt0::C12(v6) => { + v6 + } + Adt0::C13(r185) => { + let v7 = (*r185).clone(); + let a151 = { + let a149 = List::cons(Str::lit("(Option "), List::::nil()); + let a150 = List::cons(f3(v7), List::cons(Str::lit(")"), List::::nil())); + append_list(a149, a150) + }; + let a152 = Str::lit(""); + join(a151, a152) + } + Adt0::C14(r186, r187) => { + let v8 = (*r186).clone(); + let v9 = (*r187).clone(); + let a155 = { + let a153 = List::cons(Str::lit("(Result "), List::cons(f3(v8), List::::nil())); + let a154 = List::cons(Str::lit(" "), List::cons(f3(v9), List::cons(Str::lit(")"), List::::nil()))); + append_list(a153, a154) + }; + let a156 = Str::lit(""); + join(a155, a156) + } + Adt0::C15(r188) => { + let v10 = (*r188).clone(); + let a159 = { + let a157 = List::cons(Str::lit("(List "), List::::nil()); + let a158 = List::cons(f3(v10), List::cons(Str::lit(")"), List::::nil())); + append_list(a157, a158) + }; + let a160 = Str::lit(""); + join(a159, a160) } Adt0::C16(v11) => { - let a113 = List::cons(Str::lit("("), List::cons({ - let a111 = f45(v11); - let a112 = Str::lit(" * "); - join(a111, a112) - }, List::cons(Str::lit(")"), List::::nil()))); - let a114 = Str::lit(""); - join(a113, a114) - } - Adt0::C17(r127, r128, _) => { - let v12 = (*r127).clone(); - let v13 = (*r128).clone(); - let a115 = List::cons(Str::lit("(List Tuple"), List::cons(f46(v12), List::cons(f46(v13), List::cons(Str::lit(")"), List::::nil())))); - let a116 = Str::lit(""); - join(a115, a116) - } - Adt0::C18(r129, _) => { - let v15 = (*r129).clone(); - let a117 = List::cons(Str::lit("(List "), List::cons(f3(v15), List::cons(Str::lit(")"), List::::nil()))); - let a118 = Str::lit(""); - join(a117, a118) - } - Adt0::C19(v17, r130) => { - let v18 = (*r130).clone(); - let a121 = List::cons(Str::lit("(Fn ("), List::cons({ - let a119 = f47(v17); - let a120 = Str::lit(" "); - join(a119, a120) - }, List::cons(Str::lit(") "), List::cons(f3(v18), List::cons(Str::lit(")"), List::::nil()))))); - let a122 = Str::lit(""); - join(a121, a122) + let a163 = List::cons(Str::lit("Tuple"), List::cons({ + let a161 = f46(v11); + let a162 = Str::lit(""); + join(a161, a162) + }, List::::nil())); + let a164 = Str::lit(""); + join(a163, a164) + } + Adt0::C17(v12) => { + let a169 = { + let a167 = List::cons(Str::lit("("), List::::nil()); + let a168 = List::cons({ + let a165 = f47(v12); + let a166 = Str::lit(" * "); + join(a165, a166) + }, List::cons(Str::lit(")"), List::::nil())); + append_list(a167, a168) + }; + let a170 = Str::lit(""); + join(a169, a170) + } + Adt0::C18(r189, r190, _) => { + let v13 = (*r189).clone(); + let v14 = (*r190).clone(); + let a173 = { + let a171 = List::cons(Str::lit("(List Tuple"), List::cons(f48(v13), List::::nil())); + let a172 = List::cons(f48(v14), List::cons(Str::lit(")"), List::::nil())); + append_list(a171, a172) + }; + let a174 = Str::lit(""); + join(a173, a174) + } + Adt0::C19(r191, _) => { + let v16 = (*r191).clone(); + let a177 = { + let a175 = List::cons(Str::lit("(List "), List::::nil()); + let a176 = List::cons(f3(v16), List::cons(Str::lit(")"), List::::nil())); + append_list(a175, a176) + }; + let a178 = Str::lit(""); + join(a177, a178) + } + Adt0::C20(v18, r192) => { + let v19 = (*r192).clone(); + let a183 = { + let a181 = List::cons(Str::lit("(Fn ("), List::cons({ + let a179 = f49(v18); + let a180 = Str::lit(" "); + join(a179, a180) + }, List::::nil())); + let a182 = List::cons(Str::lit(") "), List::cons(f3(v19), List::cons(Str::lit(")"), List::::nil()))); + append_list(a181, a182) + }; + let a184 = Str::lit(""); + join(a183, a184) } } } pub fn f4(v0: List) -> R> { - let m131 = v0; - match m131.uncons() { + let m193 = v0; + match m193.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h132, _) => { - h132 + Adt2::C0(h194, _) => { + h194 } }; let v4: Str = match v1 { - Adt2::C0(_, h133) => { - h133 + Adt2::C0(_, h195) => { + h195 } }; Ok(List::cons({ - let a134 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a135 = Str::lit(""); - join(a134, a135) + let a198 = { + let a196 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a197 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a196, a197) + }; + let a199 = Str::lit(""); + join(a198, a199) }, f4(v2)?)) } } } pub fn f5(v0: List, v1: u64) -> R> { - let m136 = v0; - match m136.uncons() { + let m200 = v0; + match m200.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f5(v3, { - let a137 = v1; - let a138 = 1u64; - nat_add(a137, a138)? + let a201 = v1; + let a202 = 1u64; + nat_add(a201, a202)? })?)) } } } pub fn f6(v0: List) -> R> { - let m139 = v0; - match m139.uncons() { + let m203 = v0; + match m203.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h140, _) => { - h140 + Adt2::C0(h204, _) => { + h204 } }; let v4: Str = match v1 { - Adt2::C0(_, h141) => { - h141 + Adt2::C0(_, h205) => { + h205 } }; Ok(List::cons({ - let a142 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a143 = Str::lit(""); - join(a142, a143) + let a208 = { + let a206 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a207 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a206, a207) + }; + let a209 = Str::lit(""); + join(a208, a209) }, f6(v2)?)) } } } pub fn f7(v0: List, v1: u64) -> R> { - let m144 = v0; - match m144.uncons() { + let m210 = v0; + match m210.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f7(v3, { - let a145 = v1; - let a146 = 1u64; - nat_add(a145, a146)? + let a211 = v1; + let a212 = 1u64; + nat_add(a211, a212)? })?)) } } } pub fn f8(v0: List) -> R> { - let m147 = v0; - match m147.uncons() { + let m213 = v0; + match m213.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h148, _) => { - h148 + Adt2::C0(h214, _) => { + h214 } }; let v4: Str = match v1 { - Adt2::C0(_, h149) => { - h149 + Adt2::C0(_, h215) => { + h215 } }; Ok(List::cons({ - let a150 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a151 = Str::lit(""); - join(a150, a151) + let a218 = { + let a216 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a217 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a216, a217) + }; + let a219 = Str::lit(""); + join(a218, a219) }, f8(v2)?)) } } } pub fn f9(v0: List, v1: u64) -> R> { - let m152 = v0; - match m152.uncons() { + let m220 = v0; + match m220.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f9(v3, { - let a153 = v1; - let a154 = 1u64; - nat_add(a153, a154)? + let a221 = v1; + let a222 = 1u64; + nat_add(a221, a222)? })?)) } } } pub fn f10(v0: List) -> R> { - let m155 = v0; - match m155.uncons() { + let m223 = v0; + match m223.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h156, _) => { - h156 + Adt2::C0(h224, _) => { + h224 } }; let v4: Str = match v1 { - Adt2::C0(_, h157) => { - h157 + Adt2::C0(_, h225) => { + h225 } }; Ok(List::cons({ - let a158 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a159 = Str::lit(""); - join(a158, a159) + let a228 = { + let a226 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a227 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a226, a227) + }; + let a229 = Str::lit(""); + join(a228, a229) }, f10(v2)?)) } } } pub fn f11(v0: List, v1: u64) -> R> { - let m160 = v0; - match m160.uncons() { + let m230 = v0; + match m230.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f11(v3, { - let a161 = v1; - let a162 = 1u64; - nat_add(a161, a162)? + let a231 = v1; + let a232 = 1u64; + nat_add(a231, a232)? })?)) } } } pub fn f12(v0: List) -> R> { - let m163 = v0; - match m163.uncons() { + let m233 = v0; + match m233.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h164, _) => { - h164 + Adt2::C0(h234, _) => { + h234 } }; let v4: Str = match v1 { - Adt2::C0(_, h165) => { - h165 + Adt2::C0(_, h235) => { + h235 } }; Ok(List::cons({ - let a166 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a167 = Str::lit(""); - join(a166, a167) + let a238 = { + let a236 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a237 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a236, a237) + }; + let a239 = Str::lit(""); + join(a238, a239) }, f12(v2)?)) } } } pub fn f13(v0: List, v1: u64) -> R> { - let m168 = v0; - match m168.uncons() { + let m240 = v0; + match m240.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f13(v3, { - let a169 = v1; - let a170 = 1u64; - nat_add(a169, a170)? + let a241 = v1; + let a242 = 1u64; + nat_add(a241, a242)? })?)) } } } pub fn f14(v0: List) -> R> { - let m171 = v0; - match m171.uncons() { + let m243 = v0; + match m243.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h172, _) => { - h172 + Adt2::C0(h244, _) => { + h244 } }; let v4: Str = match v1 { - Adt2::C0(_, h173) => { - h173 + Adt2::C0(_, h245) => { + h245 } }; Ok(List::cons({ - let a174 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a175 = Str::lit(""); - join(a174, a175) + let a248 = { + let a246 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a247 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a246, a247) + }; + let a249 = Str::lit(""); + join(a248, a249) }, f14(v2)?)) } } } pub fn f15(v0: List, v1: u64) -> R> { - let m176 = v0; - match m176.uncons() { + let m250 = v0; + match m250.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f15(v3, { - let a177 = v1; - let a178 = 1u64; - nat_add(a177, a178)? + let a251 = v1; + let a252 = 1u64; + nat_add(a251, a252)? })?)) } } } pub fn f16(v0: List) -> R> { - let m179 = v0; - match m179.uncons() { + let m253 = v0; + match m253.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h180, _) => { - h180 + Adt2::C0(h254, _) => { + h254 } }; let v4: Str = match v1 { - Adt2::C0(_, h181) => { - h181 + Adt2::C0(_, h255) => { + h255 } }; Ok(List::cons({ - let a182 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a183 = Str::lit(""); - join(a182, a183) + let a258 = { + let a256 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a257 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a256, a257) + }; + let a259 = Str::lit(""); + join(a258, a259) }, f16(v2)?)) } } } pub fn f17(v0: List, v1: u64) -> R> { - let m184 = v0; - match m184.uncons() { + let m260 = v0; + match m260.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f17(v3, { - let a185 = v1; - let a186 = 1u64; - nat_add(a185, a186)? + let a261 = v1; + let a262 = 1u64; + nat_add(a261, a262)? })?)) } } } pub fn f18(v0: List) -> R> { - let m187 = v0; - match m187.uncons() { + let m263 = v0; + match m263.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h188, _) => { - h188 + Adt2::C0(h264, _) => { + h264 } }; let v4: Str = match v1 { - Adt2::C0(_, h189) => { - h189 + Adt2::C0(_, h265) => { + h265 } }; Ok(List::cons({ - let a190 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a191 = Str::lit(""); - join(a190, a191) + let a268 = { + let a266 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a267 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a266, a267) + }; + let a269 = Str::lit(""); + join(a268, a269) }, f18(v2)?)) } } } pub fn f19(v0: List, v1: u64) -> R> { - let m192 = v0; - match m192.uncons() { + let m270 = v0; + match m270.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f19(v3, { - let a193 = v1; - let a194 = 1u64; - nat_add(a193, a194)? + let a271 = v1; + let a272 = 1u64; + nat_add(a271, a272)? })?)) } } } pub fn f20(v0: List) -> R> { - let m195 = v0; - match m195.uncons() { + let m273 = v0; + match m273.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h196, _) => { - h196 + Adt2::C0(h274, _) => { + h274 } }; let v4: Str = match v1 { - Adt2::C0(_, h197) => { - h197 + Adt2::C0(_, h275) => { + h275 } }; Ok(List::cons({ - let a198 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a199 = Str::lit(""); - join(a198, a199) + let a278 = { + let a276 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a277 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a276, a277) + }; + let a279 = Str::lit(""); + join(a278, a279) }, f20(v2)?)) } } } pub fn f21(v0: List, v1: u64) -> R> { - let m200 = v0; - match m200.uncons() { + let m280 = v0; + match m280.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f21(v3, { - let a201 = v1; - let a202 = 1u64; - nat_add(a201, a202)? + let a281 = v1; + let a282 = 1u64; + nat_add(a281, a282)? })?)) } } } pub fn f22(v0: List) -> R> { - let m203 = v0; - match m203.uncons() { + let m283 = v0; + match m283.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h204, _) => { - h204 + Adt2::C0(h284, _) => { + h284 } }; let v4: Str = match v1 { - Adt2::C0(_, h205) => { - h205 + Adt2::C0(_, h285) => { + h285 } }; Ok(List::cons({ - let a206 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a207 = Str::lit(""); - join(a206, a207) + let a288 = { + let a286 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a287 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a286, a287) + }; + let a289 = Str::lit(""); + join(a288, a289) }, f22(v2)?)) } } } pub fn f23(v0: List, v1: u64) -> R> { - let m208 = v0; - match m208.uncons() { + let m290 = v0; + match m290.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f23(v3, { - let a209 = v1; - let a210 = 1u64; - nat_add(a209, a210)? + let a291 = v1; + let a292 = 1u64; + nat_add(a291, a292)? })?)) } } } pub fn f24(v0: List) -> R> { - let m211 = v0; - match m211.uncons() { + let m293 = v0; + match m293.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h212, _) => { - h212 + Adt2::C0(h294, _) => { + h294 } }; let v4: Str = match v1 { - Adt2::C0(_, h213) => { - h213 + Adt2::C0(_, h295) => { + h295 } }; Ok(List::cons({ - let a214 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a215 = Str::lit(""); - join(a214, a215) + let a298 = { + let a296 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a297 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a296, a297) + }; + let a299 = Str::lit(""); + join(a298, a299) }, f24(v2)?)) } } } pub fn f25(v0: List, v1: u64) -> R> { - let m216 = v0; - match m216.uncons() { + let m300 = v0; + match m300.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f25(v3, { - let a217 = v1; - let a218 = 1u64; - nat_add(a217, a218)? + let a301 = v1; + let a302 = 1u64; + nat_add(a301, a302)? })?)) } } } pub fn f26(v0: List) -> R> { - let m219 = v0; - match m219.uncons() { + let m303 = v0; + match m303.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h220, _) => { - h220 + Adt2::C0(h304, _) => { + h304 } }; let v4: Str = match v1 { - Adt2::C0(_, h221) => { - h221 + Adt2::C0(_, h305) => { + h305 } }; Ok(List::cons({ - let a222 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a223 = Str::lit(""); - join(a222, a223) + let a308 = { + let a306 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a307 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a306, a307) + }; + let a309 = Str::lit(""); + join(a308, a309) }, f26(v2)?)) } } } pub fn f27(v0: List, v1: u64) -> R> { - let m224 = v0; - match m224.uncons() { + let m310 = v0; + match m310.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f27(v3, { - let a225 = v1; - let a226 = 1u64; - nat_add(a225, a226)? + let a311 = v1; + let a312 = 1u64; + nat_add(a311, a312)? })?)) } } } pub fn f28(v0: List) -> R> { - let m227 = v0; - match m227.uncons() { + let m313 = v0; + match m313.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h228, _) => { - h228 + Adt2::C0(h314, _) => { + h314 } }; let v4: Str = match v1 { - Adt2::C0(_, h229) => { - h229 + Adt2::C0(_, h315) => { + h315 } }; Ok(List::cons({ - let a230 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a231 = Str::lit(""); - join(a230, a231) + let a318 = { + let a316 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a317 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a316, a317) + }; + let a319 = Str::lit(""); + join(a318, a319) }, f28(v2)?)) } } } pub fn f29(v0: List, v1: u64) -> R> { - let m232 = v0; - match m232.uncons() { + let m320 = v0; + match m320.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f29(v3, { - let a233 = v1; - let a234 = 1u64; - nat_add(a233, a234)? + let a321 = v1; + let a322 = 1u64; + nat_add(a321, a322)? })?)) } } } pub fn f30(v0: List) -> R> { - let m235 = v0; - match m235.uncons() { + let m323 = v0; + match m323.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h236, _) => { - h236 + Adt2::C0(h324, _) => { + h324 } }; let v4: Str = match v1 { - Adt2::C0(_, h237) => { - h237 + Adt2::C0(_, h325) => { + h325 } }; Ok(List::cons({ - let a238 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a239 = Str::lit(""); - join(a238, a239) + let a328 = { + let a326 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a327 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a326, a327) + }; + let a329 = Str::lit(""); + join(a328, a329) }, f30(v2)?)) } } } pub fn f31(v0: List, v1: u64) -> R> { - let m240 = v0; - match m240.uncons() { + let m330 = v0; + match m330.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f31(v3, { - let a241 = v1; - let a242 = 1u64; - nat_add(a241, a242)? + let a331 = v1; + let a332 = 1u64; + nat_add(a331, a332)? })?)) } } } pub fn f32(v0: List) -> R> { - let m243 = v0; - match m243.uncons() { + let m333 = v0; + match m333.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h244, _) => { - h244 + Adt2::C0(h334, _) => { + h334 } }; let v4: Str = match v1 { - Adt2::C0(_, h245) => { - h245 + Adt2::C0(_, h335) => { + h335 } }; Ok(List::cons({ - let a246 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a247 = Str::lit(""); - join(a246, a247) + let a338 = { + let a336 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a337 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a336, a337) + }; + let a339 = Str::lit(""); + join(a338, a339) }, f32(v2)?)) } } } pub fn f33(v0: List, v1: u64) -> R> { - let m248 = v0; - match m248.uncons() { + let m340 = v0; + match m340.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { Ok(List::cons(Adt2::C0(v1, v2), f33(v3, { - let a249 = v1; - let a250 = 1u64; - nat_add(a249, a250)? + let a341 = v1; + let a342 = 1u64; + nat_add(a341, a342)? })?)) } } } -pub fn f34(v0: List) -> Str { - let m253 = { - let a251 = v0; - let a252 = 0u64; - index_list(a251, a252) +pub fn f34(v0: List) -> R> { + let m343 = v0; + match m343.uncons() { + None => { + Ok(List::::nil()) + } + Some((v1, v2)) => { + let v3: u64 = match v1.clone() { + Adt2::C0(h344, _) => { + h344 + } + }; + let v4: Str = match v1 { + Adt2::C0(_, h345) => { + h345 + } + }; + Ok(List::cons({ + let a348 = { + let a346 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a347 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a346, a347) + }; + let a349 = Str::lit(""); + join(a348, a349) + }, f34(v2)?)) + } + } +} + +pub fn f35(v0: List, v1: u64) -> R> { + let m350 = v0; + match m350.uncons() { + None => { + Ok(List::::nil()) + } + Some((v2, v3)) => { + Ok(List::cons(Adt2::C0(v1, v2), f35(v3, { + let a351 = v1; + let a352 = 1u64; + nat_add(a351, a352)? + })?)) + } + } +} + +pub fn f36(v0: List) -> Str { + let m355 = { + let a353 = v0; + let a354 = 0u64; + index_list(a353, a354) }; - match m253 { + match m355 { None => { Str::lit("") } @@ -1892,13 +2128,13 @@ pub fn f34(v0: List) -> Str { } } -pub fn f35(v0: List) -> Str { - let m256 = { - let a254 = v0; - let a255 = 1u64; - index_list(a254, a255) +pub fn f37(v0: List) -> Str { + let m358 = { + let a356 = v0; + let a357 = 1u64; + index_list(a356, a357) }; - match m256 { + match m358 { None => { Str::lit("") } @@ -1908,171 +2144,183 @@ pub fn f35(v0: List) -> Str { } } -pub fn f36(v0: List) -> R> { - let m257 = v0; - match m257.uncons() { +pub fn f38(v0: List) -> R> { + let m359 = v0; + match m359.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h258, _) => { - h258 + Adt2::C0(h360, _) => { + h360 } }; let v4: Str = match v1 { - Adt2::C0(_, h259) => { - h259 + Adt2::C0(_, h361) => { + h361 } }; Ok(List::cons({ - let a260 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a261 = Str::lit(""); - join(a260, a261) - }, f36(v2)?)) + let a364 = { + let a362 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a363 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a362, a363) + }; + let a365 = Str::lit(""); + join(a364, a365) + }, f38(v2)?)) } } } -pub fn f37(v0: List, v1: u64) -> R> { - let m262 = v0; - match m262.uncons() { +pub fn f39(v0: List, v1: u64) -> R> { + let m366 = v0; + match m366.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { - Ok(List::cons(Adt2::C0(v1, v2), f37(v3, { - let a263 = v1; - let a264 = 1u64; - nat_add(a263, a264)? + Ok(List::cons(Adt2::C0(v1, v2), f39(v3, { + let a367 = v1; + let a368 = 1u64; + nat_add(a367, a368)? })?)) } } } -pub fn f38(v0: List) -> R> { - let m265 = v0; - match m265.uncons() { +pub fn f40(v0: List) -> R> { + let m369 = v0; + match m369.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h266, _) => { - h266 + Adt2::C0(h370, _) => { + h370 } }; let v4: Str = match v1 { - Adt2::C0(_, h267) => { - h267 + Adt2::C0(_, h371) => { + h371 } }; Ok(List::cons({ - let a268 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a269 = Str::lit(""); - join(a268, a269) - }, f38(v2)?)) + let a374 = { + let a372 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a373 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a372, a373) + }; + let a375 = Str::lit(""); + join(a374, a375) + }, f40(v2)?)) } } } -pub fn f39(v0: List, v1: u64) -> R> { - let m270 = v0; - match m270.uncons() { +pub fn f41(v0: List, v1: u64) -> R> { + let m376 = v0; + match m376.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { - Ok(List::cons(Adt2::C0(v1, v2), f39(v3, { - let a271 = v1; - let a272 = 1u64; - nat_add(a271, a272)? + Ok(List::cons(Adt2::C0(v1, v2), f41(v3, { + let a377 = v1; + let a378 = 1u64; + nat_add(a377, a378)? })?)) } } } -pub fn f40(v0: List) -> R> { - let m273 = v0; - match m273.uncons() { +pub fn f42(v0: List) -> R> { + let m379 = v0; + match m379.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: u64 = match v1.clone() { - Adt2::C0(h274, _) => { - h274 + Adt2::C0(h380, _) => { + h380 } }; let v4: Str = match v1 { - Adt2::C0(_, h275) => { - h275 + Adt2::C0(_, h381) => { + h381 } }; Ok(List::cons({ - let a276 = List::cons(Str::lit("item"), List::cons(f42(v3)?, List::cons(Str::lit(" := "), List::cons(v4, List::::nil())))); - let a277 = Str::lit(""); - join(a276, a277) - }, f40(v2)?)) + let a384 = { + let a382 = List::cons(Str::lit("item"), List::cons(f44(v3)?, List::::nil())); + let a383 = List::cons(Str::lit(" := "), List::cons(v4, List::::nil())); + append_list(a382, a383) + }; + let a385 = Str::lit(""); + join(a384, a385) + }, f42(v2)?)) } } } -pub fn f41(v0: List, v1: u64) -> R> { - let m278 = v0; - match m278.uncons() { +pub fn f43(v0: List, v1: u64) -> R> { + let m386 = v0; + match m386.uncons() { None => { Ok(List::::nil()) } Some((v2, v3)) => { - Ok(List::cons(Adt2::C0(v1, v2), f41(v3, { - let a279 = v1; - let a280 = 1u64; - nat_add(a279, a280)? + Ok(List::cons(Adt2::C0(v1, v2), f43(v3, { + let a387 = v1; + let a388 = 1u64; + nat_add(a387, a388)? })?)) } } } -pub fn f42(v0: u64) -> R { - Ok(f48({ - let a281 = v0; - let a282 = 1u64; - nat_add(a281, a282)? +pub fn f44(v0: u64) -> R { + Ok(f50({ + let a389 = v0; + let a390 = 1u64; + nat_add(a389, a390)? }, v0)) } -pub fn f43() -> Str { +pub fn f45() -> Str { Str::lit("Prelude") } -pub fn f44(v0: List) -> List { - let m283 = v0; - match m283.uncons() { +pub fn f46(v0: List) -> List { + let m391 = v0; + match m391.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f46(v1), f44(v2)) + List::cons(f48(v1), f46(v2)) } } } -pub fn f45(v0: List) -> List { - let m284 = v0; - match m284.uncons() { +pub fn f47(v0: List) -> List { + let m392 = v0; + match m392.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f3(v1), f45(v2)) + List::cons(f3(v1), f47(v2)) } } } -pub fn f46(v0: Adt0) -> Str { - let m285 = v0; - match m285 { +pub fn f48(v0: Adt0) -> Str { + let m393 = v0; + match m393 { Adt0::C0 => { Str::lit("Unit") } @@ -2089,209 +2337,228 @@ pub fn f46(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f51() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { + Str::lit("ParseIntError") + } + Adt0::C11 => { Str::lit("FilePath") } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r308) => { - let v6 = (*r308).clone(); - let a286 = List::cons(Str::lit("Option"), List::cons(f46(v6), List::::nil())); - let a287 = Str::lit(""); - join(a286, a287) - } - Adt0::C13(r309, r310) => { - let v7 = (*r309).clone(); - let v8 = (*r310).clone(); - let a288 = List::cons(Str::lit("Result"), List::cons(f46(v7), List::cons(f46(v8), List::::nil()))); - let a289 = Str::lit(""); - join(a288, a289) - } - Adt0::C14(r311) => { - let v9 = (*r311).clone(); - let a290 = List::cons(Str::lit("List"), List::cons(f46(v9), List::::nil())); - let a291 = Str::lit(""); - join(a290, a291) - } - Adt0::C15(v10) => { - let a294 = List::cons(Str::lit("Tuple"), List::cons({ - let a292 = f49(v10); - let a293 = Str::lit(""); - join(a292, a293) - }, List::::nil())); - let a295 = Str::lit(""); - join(a294, a295) + Adt0::C12(v6) => { + v6 + } + Adt0::C13(r422) => { + let v7 = (*r422).clone(); + let a394 = List::cons(Str::lit("Option"), List::cons(f48(v7), List::::nil())); + let a395 = Str::lit(""); + join(a394, a395) + } + Adt0::C14(r423, r424) => { + let v8 = (*r423).clone(); + let v9 = (*r424).clone(); + let a398 = { + let a396 = List::cons(Str::lit("Result"), List::::nil()); + let a397 = List::cons(f48(v8), List::cons(f48(v9), List::::nil())); + append_list(a396, a397) + }; + let a399 = Str::lit(""); + join(a398, a399) + } + Adt0::C15(r425) => { + let v10 = (*r425).clone(); + let a400 = List::cons(Str::lit("List"), List::cons(f48(v10), List::::nil())); + let a401 = Str::lit(""); + join(a400, a401) } Adt0::C16(v11) => { - let a298 = List::cons(Str::lit("Pair"), List::cons({ - let a296 = f50(v11); - let a297 = Str::lit(""); - join(a296, a297) + let a404 = List::cons(Str::lit("Tuple"), List::cons({ + let a402 = f52(v11); + let a403 = Str::lit(""); + join(a402, a403) }, List::::nil())); - let a299 = Str::lit(""); - join(a298, a299) - } - Adt0::C17(r312, r313, _) => { - let v12 = (*r312).clone(); - let v13 = (*r313).clone(); - let a300 = List::cons(Str::lit("ListTuple"), List::cons(f46(v12), List::cons(f46(v13), List::::nil()))); - let a301 = Str::lit(""); - join(a300, a301) - } - Adt0::C18(r314, _) => { - let v15 = (*r314).clone(); - let a302 = List::cons(Str::lit("List"), List::cons(f46(v15), List::::nil())); - let a303 = Str::lit(""); - join(a302, a303) - } - Adt0::C19(v17, r315) => { - let v18 = (*r315).clone(); - let a306 = List::cons(Str::lit("Fn"), List::cons({ - let a304 = f51(v17); - let a305 = Str::lit(""); - join(a304, a305) - }, List::cons(Str::lit("To"), List::cons(f46(v18), List::::nil())))); - let a307 = Str::lit(""); - join(a306, a307) + let a405 = Str::lit(""); + join(a404, a405) + } + Adt0::C17(v12) => { + let a408 = List::cons(Str::lit("Pair"), List::cons({ + let a406 = f53(v12); + let a407 = Str::lit(""); + join(a406, a407) + }, List::::nil())); + let a409 = Str::lit(""); + join(a408, a409) + } + Adt0::C18(r426, r427, _) => { + let v13 = (*r426).clone(); + let v14 = (*r427).clone(); + let a412 = { + let a410 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a411 = List::cons(f48(v13), List::cons(f48(v14), List::::nil())); + append_list(a410, a411) + }; + let a413 = Str::lit(""); + join(a412, a413) + } + Adt0::C19(r428, _) => { + let v16 = (*r428).clone(); + let a414 = List::cons(Str::lit("List"), List::cons(f48(v16), List::::nil())); + let a415 = Str::lit(""); + join(a414, a415) + } + Adt0::C20(v18, r429) => { + let v19 = (*r429).clone(); + let a420 = { + let a418 = List::cons(Str::lit("Fn"), List::cons({ + let a416 = f54(v18); + let a417 = Str::lit(""); + join(a416, a417) + }, List::::nil())); + let a419 = List::cons(Str::lit("To"), List::cons(f48(v19), List::::nil())); + append_list(a418, a419) + }; + let a421 = Str::lit(""); + join(a420, a421) } } } -pub fn f47(v0: List) -> List { - let m316 = v0; - match m316.uncons() { +pub fn f49(v0: List) -> List { + let m430 = v0; + match m430.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f3(v1), f47(v2)) + List::cons(f3(v1), f49(v2)) } } } -pub fn f48(v0: u64, v1: u64) -> Str { - let m317 = v0; - if m317 == 0 { +pub fn f50(v0: u64, v1: u64) -> Str { + let m431 = v0; + if m431 == 0 { Str::lit("") } else { - let v2 = m317 - 1; - let a318 = v1; - let a319 = 10u64; - if nat_lt(a318, a319) { - f52(v1) + let v2 = m431 - 1; + let a432 = v1; + let a433 = 10u64; + if nat_lt(a432, a433) { + f55(v1) } else { - let a326 = List::cons(f48(v2, { - let a320 = v1; - let a321 = 10u64; - let a322 = 0u64; - nat_quot(a320, a321, a322) - }), List::cons(f52({ - let a323 = v1; - let a324 = 10u64; - let a325 = 0u64; - nat_rem(a323, a324, a325) + let a440 = List::cons(f50(v2, { + let a434 = v1; + let a435 = 10u64; + let a436 = 0u64; + nat_quot(a434, a435, a436) + }), List::cons(f55({ + let a437 = v1; + let a438 = 10u64; + let a439 = 0u64; + nat_rem(a437, a438, a439) }), List::::nil())); - let a327 = Str::lit(""); - join(a326, a327) + let a441 = Str::lit(""); + join(a440, a441) } } } -pub fn f49(v0: List) -> List { - let m328 = v0; - match m328.uncons() { +pub fn f51() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f52(v0: List) -> List { + let m442 = v0; + match m442.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f46(v1), f49(v2)) + List::cons(f48(v1), f52(v2)) } } } -pub fn f50(v0: List) -> List { - let m329 = v0; - match m329.uncons() { +pub fn f53(v0: List) -> List { + let m443 = v0; + match m443.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f46(v1), f50(v2)) + List::cons(f48(v1), f53(v2)) } } } -pub fn f51(v0: List) -> List { - let m330 = v0; - match m330.uncons() { +pub fn f54(v0: List) -> List { + let m444 = v0; + match m444.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f46(v1), f51(v2)) + List::cons(f48(v1), f54(v2)) } } } -pub fn f52(v0: u64) -> Str { - let a331 = v0; - let a332 = 0u64; - if nat_eq(a331, a332) { +pub fn f55(v0: u64) -> Str { + let a445 = v0; + let a446 = 0u64; + if nat_eq(a445, a446) { Str::lit("0") } else { - let a333 = v0; - let a334 = 1u64; - if nat_eq(a333, a334) { + let a447 = v0; + let a448 = 1u64; + if nat_eq(a447, a448) { Str::lit("1") } else { - let a335 = v0; - let a336 = 2u64; - if nat_eq(a335, a336) { + let a449 = v0; + let a450 = 2u64; + if nat_eq(a449, a450) { Str::lit("2") } else { - let a337 = v0; - let a338 = 3u64; - if nat_eq(a337, a338) { + let a451 = v0; + let a452 = 3u64; + if nat_eq(a451, a452) { Str::lit("3") } else { - let a339 = v0; - let a340 = 4u64; - if nat_eq(a339, a340) { + let a453 = v0; + let a454 = 4u64; + if nat_eq(a453, a454) { Str::lit("4") } else { - let a341 = v0; - let a342 = 5u64; - if nat_eq(a341, a342) { + let a455 = v0; + let a456 = 5u64; + if nat_eq(a455, a456) { Str::lit("5") } else { - let a343 = v0; - let a344 = 6u64; - if nat_eq(a343, a344) { + let a457 = v0; + let a458 = 6u64; + if nat_eq(a457, a458) { Str::lit("6") } else { - let a345 = v0; - let a346 = 7u64; - if nat_eq(a345, a346) { + let a459 = v0; + let a460 = 7u64; + if nat_eq(a459, a460) { Str::lit("7") } else { - let a347 = v0; - let a348 = 8u64; - if nat_eq(a347, a348) { + let a461 = v0; + let a462 = 8u64; + if nat_eq(a461, a462) { Str::lit("8") } else { Str::lit("9") diff --git a/crates/certified/roots/uorust_certified_types_accessor.rs b/crates/certified/roots/uorust_certified_types_accessor.rs index e492d9d9..d978d8d1 100644 --- a/crates/certified/roots/uorust_certified_types_accessor.rs +++ b/crates/certified/roots/uorust_certified_types_accessor.rs @@ -856,9 +856,13 @@ pub fn format_int(p0: i64) -> Str { } pub fn f0(v0: Str, v1: Str) -> Str { - let a1 = List::cons(Str::lit("field_"), List::cons(v0, List::cons(Str::lit("_"), List::cons(v1, List::::nil())))); - let a2 = Str::lit(""); - join(a1, a2) + let a3 = { + let a1 = List::cons(Str::lit("field_"), List::cons(v0, List::::nil())); + let a2 = List::cons(Str::lit("_"), List::cons(v1, List::::nil())); + append_list(a1, a2) + }; + let a4 = Str::lit(""); + join(a3, a4) } pub fn run(p0: Str, p1: Str) -> Str { diff --git a/crates/certified/roots/uorust_certified_types_boxed.rs b/crates/certified/roots/uorust_certified_types_boxed.rs index 89c8b61b..45c23dbb 100644 --- a/crates/certified/roots/uorust_certified_types_boxed.rs +++ b/crates/certified/roots/uorust_certified_types_boxed.rs @@ -857,7 +857,7 @@ pub fn format_int(p0: i64) -> Str { #[derive(Clone)] pub enum Adt0 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -878,20 +878,21 @@ pub enum Adt3 { C3(u64), C4(Adt4), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -936,7 +937,7 @@ pub enum Adt11 { pub fn f0(v0: Adt0, v1: Str) -> bool { if f1(match v0.clone() { - Adt0::C0(_, h1, _, _, _, _, _, _, _, _, _, _) => { + Adt0::C0(_, h1, _, _, _, _, _, _, _, _, _, _, _) => { h1 } }, v1.clone()) { @@ -995,7 +996,7 @@ pub fn f2(v0: Str, v1: Adt0) -> bool { pub fn f3(v0: Adt0, v1: Str) -> Option> { f4(match v0 { - Adt0::C0(_, _, _, _, h9, _, _, _, _, _, _, _) => { + Adt0::C0(_, _, _, _, h9, _, _, _, _, _, _, _, _) => { h9 } }, v1) diff --git a/crates/certified/roots/uorust_certified_types_declares.rs b/crates/certified/roots/uorust_certified_types_declares.rs new file mode 100644 index 00000000..4fcfd113 --- /dev/null +++ b/crates/certified/roots/uorust_certified_types_declares.rs @@ -0,0 +1,2057 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str, List<(Str, Adt3)>), +} + +#[derive(Clone)] +pub enum Adt3 { + C0, + C1, + C2(Option), + C3(u64), + C4(Adt4), + C5(Option), + C6(Option), + C7, + C8, + C9, + C10, + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), + C16(List), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(u64, u64), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(Str, Str), +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Str, List<(Str, List<(Option, Adt3)>)>), +} + +#[derive(Clone)] +pub enum Adt7 { + C0(Str, Adt4), +} + +#[derive(Clone)] +pub enum Adt8 { + C0(Str, Adt5), +} + +#[derive(Clone)] +pub enum Adt9 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt10 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt11 { + C0(Str, List), +} + +pub fn f0(v0: Adt0, v1: Str) -> R { + let v2: Str = f1(v0.clone(), v1)?; + if if if f2(match v0.clone() { + Adt0::C0(h1, _, _, _, _, _, _, _, _, _, _, _, _) => { + h1 + } + }, v2.clone()) { + true + } else { + f3(match v0.clone() { + Adt0::C0(_, h2, _, _, _, _, _, _, _, _, _, _, _) => { + h2 + } + }, v2.clone()) + } { + true + } else { + f4(match v0.clone() { + Adt0::C0(_, _, _, h3, _, _, _, _, _, _, _, _, _) => { + h3 + } + }, v2.clone()) + } { + Ok(true) + } else { + Ok(f5(match v0 { + Adt0::C0(_, _, _, _, _, _, _, _, _, _, _, _, h4) => { + h4 + } + }, v2)) + } +} + +pub fn f1(v0: Adt0, v1: Str) -> R { + let v2: Str = f6(v1)?; + let m6 = f7(match v0 { + Adt0::C0(_, _, h5, _, _, _, _, _, _, _, _, _, _) => { + h5 + } + }, v2.clone()); + match m6 { + None => { + Ok(v2) + } + Some(v3) => { + Ok(v3) + } + } +} + +pub fn f2(p12: List, v1: Str) -> bool { + let m11 = p12; + { + let mut m11 = m11; + loop { + let step = { + let v0 = m11; + let m7 = v0; + match m7.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a9 = match v2 { + Adt1::C0(h8, _) => { + h8 + } + }; + let a10 = v1.clone(); + if equal(a9, a10) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m11 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f3(p18: List, v1: Str) -> bool { + let m17 = p18; + { + let mut m17 = m17; + loop { + let step = { + let v0 = m17; + let m13 = v0; + match m13.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a15 = match v2 { + Adt2::C0(h14, _) => { + h14 + } + }; + let a16 = v1.clone(); + if equal(a15, a16) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m17 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f4(p24: List, v1: Str) -> bool { + let m23 = p24; + { + let mut m23 = m23; + loop { + let step = { + let v0 = m23; + let m19 = v0; + match m19.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a21 = match v2 { + Adt6::C0(h20, _) => { + h20 + } + }; + let a22 = v1.clone(); + if equal(a21, a22) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m23 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f5(p30: List, v1: Str) -> bool { + let m29 = p30; + { + let mut m29 = m29; + loop { + let step = { + let v0 = m29; + let m25 = v0; + match m25.uncons() { + None => { + Err::, bool>(false) + } + Some((v2, v3)) => { + let a27 = match v2 { + Adt5::C0(h26, _) => { + h26 + } + }; + let a28 = v1.clone(); + if equal(a27, a28) { + Err::, bool>(true) + } else { + Ok::, bool>(v3) + } + } + } + }; + match step { + Ok(next) => { m29 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f6(v0: Str) -> R { + let m31 = f8(v0.clone())?; + match m31 { + None => { + Ok(v0) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt5::C0(h32, _) => { + h32 + } + }; + let v3: Str = match v1 { + Adt5::C0(_, h33) => { + h33 + } + }; + let m34 = f9(v3, Str::lit(">")); + match m34 { + None => { + Ok(v0) + } + Some(v4) => { + if f10(f11(v4, Str::lit(","))?)? { + f12(v2) + } else { + Ok(v0) + } + } + } + } + } +} + +pub fn f7(p41: List, v1: Str) -> Option { + let m40 = p41; + { + let mut m40 = m40; + loop { + let step = { + let v0 = m40; + let m35 = v0; + match m35.uncons() { + None => { + Err::, Option>(None::) + } + Some((v2, v3)) => { + let a37 = match v2.clone() { + Adt5::C0(h36, _) => { + h36 + } + }; + let a38 = v1.clone(); + if equal(a37, a38) { + Err::, Option>(Some(match v2 { + Adt5::C0(_, h39) => { + h39 + } + })) + } else { + Ok::, Option>(v3) + } + } + } + }; + match step { + Ok(next) => { m40 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f8(v0: Str) -> R> { + let m42 = f13(v0.clone(), Str::lit("<"))?; + match m42 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt5::C0(f14(v0.clone(), 0u64, v1), f14(v0.clone(), { + let a43 = v1; + let a44 = f15(Str::lit("<")); + nat_add(a43, a44)? + }, f15(v0))))) + } + } +} + +pub fn f9(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a45 = v0.clone(); + utf8_encode(a45) + }; + let v3: u64 = { + let a46 = v2.clone(); + length_bytes(a46) + }; + let v4: u64 = f15(v1.clone()); + if f16(v0, v1) { + Some(f17(v2, 0u64, { + let a47 = v3; + let a48 = v4; + nat_sub(a47, a48) + })) + } else { + None:: + } +} + +pub fn f10(p51: List) -> R { + let m50 = p51; + { + let mut m50 = m50; + loop { + let step = { + let v0 = m50; + let m49 = v0; + match m49.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + if f18(v1)? { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m50 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f11(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a52 = v0.clone(); + utf8_encode(a52) + }; + let v3: Bytes = { + let a53 = v1; + utf8_encode(a53) + }; + let a55 = { + let a54 = v3.clone(); + length_bytes(a54) + }; + let a56 = 0u64; + if nat_eq(a55, a56) { + Ok(List::cons(Str::lit(""), { + let a57 = f19(v0)?; + let a58 = List::cons(Str::lit(""), List::::nil()); + append_list(a57, a58) + })) + } else { + f20({ + let a60 = { + let a59 = v2.clone(); + length_bytes(a59) + }; + let a61 = 1u64; + nat_add(a60, a61)? + }, v2, v3, 0u64, 0u64) + } +} + +pub fn f12(v0: Str) -> R { + let v1: Bytes = { + let a62 = v0; + utf8_encode(a62) + }; + let v2: u64 = { + let a63 = v1.clone(); + length_bytes(a63) + }; + Ok(f17(v1.clone(), 0u64, f21(v2, v1, v2)?)) +} + +pub fn f13(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a64 = v0; + utf8_encode(a64) + }; + f22({ + let a66 = { + let a65 = v2.clone(); + length_bytes(a65) + }; + let a67 = 1u64; + nat_add(a66, a67)? + }, v2, { + let a68 = v1; + utf8_encode(a68) + }, 0u64) +} + +pub fn f14(v0: Str, v1: u64, v2: u64) -> Str { + f17({ + let a69 = v0; + utf8_encode(a69) + }, v1, v2) +} + +pub fn f15(v0: Str) -> u64 { + let a71 = { + let a70 = v0; + utf8_encode(a70) + }; + length_bytes(a71) +} + +pub fn f16(v0: Str, v1: Str) -> bool { + let v2: Bytes = { + let a72 = v0; + utf8_encode(a72) + }; + let v3: Bytes = { + let a73 = v1; + utf8_encode(a73) + }; + let v4: u64 = { + let a74 = v2.clone(); + length_bytes(a74) + }; + let v5: u64 = { + let a75 = v3.clone(); + length_bytes(a75) + }; + let a76 = v5; + let a77 = v4; + if nat_le(a76, a77) { + f23(v2, { + let a78 = v4; + let a79 = v5; + nat_sub(a78, a79) + }, v3) + } else { + false + } +} + +pub fn f17(v0: Bytes, v1: u64, v2: u64) -> Str { + let m85 = { + let a82 = v0; + let a83 = v1; + let a84 = { + let a80 = v2; + let a81 = v1; + nat_sub(a80, a81) + }; + slice_bytes(a82, a83, a84) + }; + match m85 { + None => { + Str::lit("") + } + Some(v3) => { + let m87 = { + let a86 = v3; + utf8_decode(a86) + }; + match m87 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f18(v0: Str) -> R { + let m88 = f24(f25(v0)?, Str::lit("'")); + match m88 { + None => { + Ok(false) + } + Some(v1) => { + let a89 = f26(v1, Str::lit("'"))?; + Ok(bool_not(a89)) + } + } +} + +pub fn f19(v0: Str) -> R> { + let v1: Bytes = { + let a90 = v0; + utf8_encode(a90) + }; + f27({ + let a91 = v1.clone(); + length_bytes(a91) + }, v1, 0u64) +} + +pub fn f20(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { + let m92 = v0; + if m92 == 0 { + Ok(List::cons(f17(v1.clone(), v3, { + let a93 = v1; + length_bytes(a93) + }), List::::nil())) + } else { + let v5 = m92 - 1; + let a98 = { + let a94 = v1.clone(); + length_bytes(a94) + }; + let a99 = { + let a96 = v4; + let a97 = { + let a95 = v2.clone(); + length_bytes(a95) + }; + nat_add(a96, a97)? + }; + if nat_lt(a98, a99) { + Ok(List::cons(f17(v1.clone(), v3, { + let a100 = v1; + length_bytes(a100) + }), List::::nil())) + } else { + if f23(v1.clone(), v4, v2.clone()) { + Ok(List::cons(f17(v1.clone(), v3, v4), f20(v5, v1, v2.clone(), { + let a102 = v4; + let a103 = { + let a101 = v2.clone(); + length_bytes(a101) + }; + nat_add(a102, a103)? + }, { + let a105 = v4; + let a106 = { + let a104 = v2; + length_bytes(a104) + }; + nat_add(a105, a106)? + })?)) + } else { + f20(v5, v1, v2, v3, { + let a107 = v4; + let a108 = 1u64; + nat_add(a107, a108)? + }) + } + } + } +} + +pub fn f21(p115: u64, v1: Bytes, p116: u64) -> R { + let m114 = (p115, p116); + { + let mut m114 = m114; + loop { + let step = { + let (v0, v2) = m114; + let m109 = v0; + if m109 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m109 - 1; + let v4: u64 = f28(v1.clone(), v2)?; + let a110 = v4; + let a111 = 0u64; + if nat_eq(a110, a111) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a112 = v2; + let a113 = v4; + nat_sub(a112, a113) + })) + } + } + }; + match step { + Ok(next) => { m114 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f22(p127: u64, v1: Bytes, v2: Bytes, p128: u64) -> R> { + let m126 = (p127, p128); + { + let mut m126 = m126; + loop { + let step = { + let (v0, v3) = m126; + let m117 = v0; + if m117 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m117 - 1; + let a122 = { + let a118 = v1.clone(); + length_bytes(a118) + }; + let a123 = { + let a120 = v3; + let a121 = { + let a119 = v2.clone(); + length_bytes(a119) + }; + nat_add(a120, a121)? + }; + if nat_lt(a122, a123) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f23(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a124 = v3; + let a125 = 1u64; + nat_add(a124, a125)? + })) + } + } + } + }; + match step { + Ok(next) => { m126 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f23(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m133 = { + let a130 = v0; + let a131 = v1; + let a132 = { + let a129 = v2.clone(); + length_bytes(a129) + }; + slice_bytes(a130, a131, a132) + }; + match m133 { + None => { + false + } + Some(v3) => { + let a134 = v3; + let a135 = v2; + equal(a134, a135) + } + } +} + +pub fn f24(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a136 = v0; + utf8_encode(a136) + }; + let v3: Bytes = { + let a137 = v1; + utf8_encode(a137) + }; + if f23(v2.clone(), 0u64, v3.clone()) { + Some(f17(v2.clone(), { + let a138 = v3; + length_bytes(a138) + }, { + let a139 = v2; + length_bytes(a139) + })) + } else { + None:: + } +} + +pub fn f25(v0: Str) -> R { + f12(f29(v0)?) +} + +pub fn f26(v0: Str, v1: Str) -> R { + let m140 = f13(v0, v1)?; + match m140 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f27(v0: u64, v1: Bytes, v2: u64) -> R> { + let m141 = v0; + if m141 == 0 { + Ok(List::::nil()) + } else { + let v3 = m141 - 1; + let a143 = { + let a142 = v1.clone(); + length_bytes(a142) + }; + let a144 = v2; + if nat_le(a143, a144) { + Ok(List::::nil()) + } else { + let v4: u64 = f30(f31(v1.clone(), v2)?); + Ok(List::cons(f17(v1.clone(), v2, { + let a145 = v2; + let a146 = v4; + nat_add(a145, a146)? + }), f27(v3, v1, { + let a147 = v2; + let a148 = v4; + nat_add(a147, a148)? + })?)) + } + } +} + +pub fn f28(v0: Bytes, v1: u64) -> R { + let a149 = v1; + let a150 = 0u64; + if nat_eq(a149, a150) { + Ok(0u64) + } else { + if f32(f31(v0.clone(), { + let a151 = v1; + let a152 = 1u64; + nat_sub(a151, a152) + })?) { + Ok(1u64) + } else { + let a153 = 2u64; + let a154 = v1; + if if nat_le(a153, a154) { + let a157 = f33(v0.clone(), { + let a155 = v1; + let a156 = 2u64; + nat_sub(a155, a156) + })?; + let a158 = 2u64; + nat_eq(a157, a158) + } else { + false + } { + Ok(2u64) + } else { + let a159 = 3u64; + let a160 = v1; + if if nat_le(a159, a160) { + let a163 = f33(v0, { + let a161 = v1; + let a162 = 3u64; + nat_sub(a161, a162) + })?; + let a164 = 3u64; + nat_eq(a163, a164) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f29(v0: Str) -> R { + let v1: Bytes = { + let a165 = v0; + utf8_encode(a165) + }; + let v2: u64 = { + let a166 = v1.clone(); + length_bytes(a166) + }; + Ok(f17(v1.clone(), f34(v2, v1, 0u64)?, v2)) +} + +pub fn f30(v0: u64) -> u64 { + let a167 = v0; + let a168 = 128u64; + if nat_lt(a167, a168) { + 1u64 + } else { + let a169 = v0; + let a170 = 224u64; + if nat_lt(a169, a170) { + 2u64 + } else { + let a171 = v0; + let a172 = 240u64; + if nat_lt(a171, a172) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f31(v0: Bytes, v1: u64) -> R { + let m175 = { + let a173 = v0; + let a174 = v1; + index_bytes(a173, a174) + }; + match m175 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a220 = { + let a196 = { + let a184 = { + let a178 = { + let a176 = v3; + let a177 = 128u8; + fixed_u8::bit_and(a176, a177) + }; + let a179 = 128u8; + if equal(a178, a179) { + 128u64 + } else { + 0u64 + } + }; + let a185 = { + let a182 = { + let a180 = v3; + let a181 = 64u8; + fixed_u8::bit_and(a180, a181) + }; + let a183 = 64u8; + if equal(a182, a183) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a184, a185)? + }; + let a197 = { + let a194 = { + let a188 = { + let a186 = v3; + let a187 = 32u8; + fixed_u8::bit_and(a186, a187) + }; + let a189 = 32u8; + if equal(a188, a189) { + 32u64 + } else { + 0u64 + } + }; + let a195 = { + let a192 = { + let a190 = v3; + let a191 = 16u8; + fixed_u8::bit_and(a190, a191) + }; + let a193 = 16u8; + if equal(a192, a193) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a194, a195)? + }; + nat_add(a196, a197)? + }; + let a221 = { + let a218 = { + let a206 = { + let a200 = { + let a198 = v3; + let a199 = 8u8; + fixed_u8::bit_and(a198, a199) + }; + let a201 = 8u8; + if equal(a200, a201) { + 8u64 + } else { + 0u64 + } + }; + let a207 = { + let a204 = { + let a202 = v3; + let a203 = 4u8; + fixed_u8::bit_and(a202, a203) + }; + let a205 = 4u8; + if equal(a204, a205) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a206, a207)? + }; + let a219 = { + let a216 = { + let a210 = { + let a208 = v3; + let a209 = 2u8; + fixed_u8::bit_and(a208, a209) + }; + let a211 = 2u8; + if equal(a210, a211) { + 2u64 + } else { + 0u64 + } + }; + let a217 = { + let a214 = { + let a212 = v3; + let a213 = 1u8; + fixed_u8::bit_and(a212, a213) + }; + let a215 = 1u8; + if equal(a214, a215) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a216, a217)? + }; + nat_add(a218, a219)? + }; + nat_add(a220, a221) + } + } +} + +pub fn f32(v0: u64) -> bool { + let a222 = v0; + let a223 = 32u64; + if nat_eq(a222, a223) { + true + } else { + let a224 = 9u64; + let a225 = v0; + if nat_le(a224, a225) { + let a226 = v0; + let a227 = 13u64; + nat_le(a226, a227) + } else { + false + } + } +} + +pub fn f33(v0: Bytes, v1: u64) -> R { + let v2: u64 = f31(v0.clone(), v1)?; + let v3: u64 = f31(v0.clone(), { + let a228 = v1; + let a229 = 1u64; + nat_add(a228, a229)? + })?; + let v4: u64 = f31(v0, { + let a230 = v1; + let a231 = 2u64; + nat_add(a230, a231)? + })?; + if f32(v2) { + Ok(1u64) + } else { + let a232 = v2; + let a233 = 194u64; + if nat_eq(a232, a233) { + let a234 = v3; + let a235 = 133u64; + if if nat_eq(a234, a235) { + true + } else { + let a236 = v3; + let a237 = 160u64; + nat_eq(a236, a237) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a238 = v2; + let a239 = 225u64; + if nat_eq(a238, a239) { + let a240 = v3; + let a241 = 154u64; + if if nat_eq(a240, a241) { + let a242 = v4; + let a243 = 128u64; + nat_eq(a242, a243) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a244 = v2; + let a245 = 226u64; + if nat_eq(a244, a245) { + let a246 = v3; + let a247 = 128u64; + if nat_eq(a246, a247) { + let a248 = 128u64; + let a249 = v4; + if if if nat_le(a248, a249) { + let a250 = v4; + let a251 = 138u64; + nat_le(a250, a251) + } else { + false + } { + true + } else { + let a252 = v4; + let a253 = 168u64; + if nat_eq(a252, a253) { + true + } else { + let a254 = v4; + let a255 = 169u64; + if nat_eq(a254, a255) { + true + } else { + let a256 = v4; + let a257 = 175u64; + nat_eq(a256, a257) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a258 = v3; + let a259 = 129u64; + if if nat_eq(a258, a259) { + let a260 = v4; + let a261 = 159u64; + nat_eq(a260, a261) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a262 = v2; + let a263 = 227u64; + if if nat_eq(a262, a263) { + let a264 = v3; + let a265 = 128u64; + if nat_eq(a264, a265) { + let a266 = v4; + let a267 = 128u64; + nat_eq(a266, a267) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f34(p274: u64, v1: Bytes, p275: u64) -> R { + let m273 = (p274, p275); + { + let mut m273 = m273; + loop { + let step = { + let (v0, v2) = m273; + let m268 = v0; + if m268 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m268 - 1; + let v4: u64 = f33(v1.clone(), v2)?; + let a269 = v4; + let a270 = 0u64; + if nat_eq(a269, a270) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a271 = v2; + let a272 = v4; + nat_add(a271, a272)? + })) + } + } + }; + match step { + Ok(next) => { m273 = next; } + Err(done) => break done, + } + } + } +} + +pub fn run(p0: Adt0, p1: Str) -> R { + f0(p0, p1) +} diff --git a/crates/certified/roots/uorust_certified_types_family_of.rs b/crates/certified/roots/uorust_certified_types_family_of.rs index 0d389d39..51918989 100644 --- a/crates/certified/roots/uorust_certified_types_family_of.rs +++ b/crates/certified/roots/uorust_certified_types_family_of.rs @@ -857,7 +857,7 @@ pub fn format_int(p0: i64) -> Str { #[derive(Clone)] pub enum Adt0 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -878,20 +878,21 @@ pub enum Adt3 { C3(u64), C4(Adt4), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -936,7 +937,7 @@ pub enum Adt11 { pub fn f0(v0: Adt0, v1: Str) -> Option> { f1(match v0 { - Adt0::C0(_, _, _, _, h1, _, _, _, _, _, _, _) => { + Adt0::C0(_, _, _, _, h1, _, _, _, _, _, _, _, _) => { h1 } }, v1) diff --git a/crates/certified/roots/uorust_certified_types_has_data.rs b/crates/certified/roots/uorust_certified_types_has_data.rs index 2c07679c..a3604960 100644 --- a/crates/certified/roots/uorust_certified_types_has_data.rs +++ b/crates/certified/roots/uorust_certified_types_has_data.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -886,7 +887,7 @@ pub enum Adt1 { #[derive(Clone)] pub enum Adt2 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -955,7 +956,7 @@ pub fn f0(v0: Adt0, v1: Adt2) -> bool { Adt0::C5(_) => { false } - Adt0::C6 => { + Adt0::C6(_) => { false } Adt0::C7 => { @@ -970,20 +971,20 @@ pub fn f0(v0: Adt0, v1: Adt2) -> bool { Adt0::C10 => { false } - Adt0::C11(v6) => { + Adt0::C11 => { + false + } + Adt0::C12(v7) => { f1(match v1 { - Adt2::C0(_, _, _, h2, _, _, _, _, _, _, _, _) => { + Adt2::C0(_, _, _, h2, _, _, _, _, _, _, _, _, _) => { h2 } - }, v6) - } - Adt0::C12(_) => { - false + }, v7) } - Adt0::C13(_, _) => { + Adt0::C13(_) => { false } - Adt0::C14(_) => { + Adt0::C14(_, _) => { false } Adt0::C15(_) => { @@ -992,15 +993,18 @@ pub fn f0(v0: Adt0, v1: Adt2) -> bool { Adt0::C16(_) => { false } - Adt0::C17(_, _, _) => { + Adt0::C17(_) => { false } - Adt0::C18(_, _) => { + Adt0::C18(_, _, _) => { false } Adt0::C19(_, _) => { false } + Adt0::C20(_, _) => { + false + } } } diff --git a/crates/certified/roots/uorust_certified_types_resolve.rs b/crates/certified/roots/uorust_certified_types_resolve.rs index d36d7ee9..6f424923 100644 --- a/crates/certified/roots/uorust_certified_types_resolve.rs +++ b/crates/certified/roots/uorust_certified_types_resolve.rs @@ -857,7 +857,7 @@ pub fn format_int(p0: i64) -> Str { #[derive(Clone)] pub enum Adt0 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -878,20 +878,21 @@ pub enum Adt3 { C3(u64), C4(Adt4), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -934,45 +935,80 @@ pub enum Adt11 { C0(Str, List), } -pub fn f0(v0: Adt0, v1: Str) -> Str { - let m2 = f1(match v0 { - Adt0::C0(_, _, h1, _, _, _, _, _, _, _, _, _) => { +pub fn f0(v0: Adt0, v1: Str) -> R { + let v2: Str = f1(v1)?; + let m2 = f2(match v0 { + Adt0::C0(_, _, h1, _, _, _, _, _, _, _, _, _, _) => { h1 } - }, v1.clone()); + }, v2.clone()); match m2 { None => { - v1 + Ok(v2) } - Some(v2) => { - v2 + Some(v3) => { + Ok(v3) + } + } +} + +pub fn f1(v0: Str) -> R { + let m3 = f3(v0.clone())?; + match m3 { + None => { + Ok(v0) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt5::C0(h4, _) => { + h4 + } + }; + let v3: Str = match v1 { + Adt5::C0(_, h5) => { + h5 + } + }; + let m6 = f4(v3, Str::lit(">")); + match m6 { + None => { + Ok(v0) + } + Some(v4) => { + if f5(f6(v4, Str::lit(","))?)? { + f7(v2) + } else { + Ok(v0) + } + } + } } } } -pub fn f1(p9: List, v1: Str) -> Option { - let m8 = p9; +pub fn f2(p13: List, v1: Str) -> Option { + let m12 = p13; { - let mut m8 = m8; + let mut m12 = m12; loop { let step = { - let v0 = m8; - let m3 = v0; - match m3.uncons() { + let v0 = m12; + let m7 = v0; + match m7.uncons() { None => { Err::, Option>(None::) } Some((v2, v3)) => { - let a5 = match v2.clone() { - Adt5::C0(h4, _) => { - h4 + let a9 = match v2.clone() { + Adt5::C0(h8, _) => { + h8 } }; - let a6 = v1.clone(); - if equal(a5, a6) { + let a10 = v1.clone(); + if equal(a9, a10) { Err::, Option>(Some(match v2 { - Adt5::C0(_, h7) => { - h7 + Adt5::C0(_, h11) => { + h11 } })) } else { @@ -982,13 +1018,867 @@ pub fn f1(p9: List, v1: Str) -> Option { } }; match step { - Ok(next) => { m8 = next; } + Ok(next) => { m12 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f3(v0: Str) -> R> { + let m14 = f8(v0.clone(), Str::lit("<"))?; + match m14 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt5::C0(f9(v0.clone(), 0u64, v1), f9(v0.clone(), { + let a15 = v1; + let a16 = f10(Str::lit("<")); + nat_add(a15, a16)? + }, f10(v0))))) + } + } +} + +pub fn f4(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a17 = v0.clone(); + utf8_encode(a17) + }; + let v3: u64 = { + let a18 = v2.clone(); + length_bytes(a18) + }; + let v4: u64 = f10(v1.clone()); + if f11(v0, v1) { + Some(f12(v2, 0u64, { + let a19 = v3; + let a20 = v4; + nat_sub(a19, a20) + })) + } else { + None:: + } +} + +pub fn f5(p23: List) -> R { + let m22 = p23; + { + let mut m22 = m22; + loop { + let step = { + let v0 = m22; + let m21 = v0; + match m21.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + if f13(v1)? { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m22 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f6(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a24 = v0.clone(); + utf8_encode(a24) + }; + let v3: Bytes = { + let a25 = v1; + utf8_encode(a25) + }; + let a27 = { + let a26 = v3.clone(); + length_bytes(a26) + }; + let a28 = 0u64; + if nat_eq(a27, a28) { + Ok(List::cons(Str::lit(""), { + let a29 = f14(v0)?; + let a30 = List::cons(Str::lit(""), List::::nil()); + append_list(a29, a30) + })) + } else { + f15({ + let a32 = { + let a31 = v2.clone(); + length_bytes(a31) + }; + let a33 = 1u64; + nat_add(a32, a33)? + }, v2, v3, 0u64, 0u64) + } +} + +pub fn f7(v0: Str) -> R { + let v1: Bytes = { + let a34 = v0; + utf8_encode(a34) + }; + let v2: u64 = { + let a35 = v1.clone(); + length_bytes(a35) + }; + Ok(f12(v1.clone(), 0u64, f16(v2, v1, v2)?)) +} + +pub fn f8(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a36 = v0; + utf8_encode(a36) + }; + f17({ + let a38 = { + let a37 = v2.clone(); + length_bytes(a37) + }; + let a39 = 1u64; + nat_add(a38, a39)? + }, v2, { + let a40 = v1; + utf8_encode(a40) + }, 0u64) +} + +pub fn f9(v0: Str, v1: u64, v2: u64) -> Str { + f12({ + let a41 = v0; + utf8_encode(a41) + }, v1, v2) +} + +pub fn f10(v0: Str) -> u64 { + let a43 = { + let a42 = v0; + utf8_encode(a42) + }; + length_bytes(a43) +} + +pub fn f11(v0: Str, v1: Str) -> bool { + let v2: Bytes = { + let a44 = v0; + utf8_encode(a44) + }; + let v3: Bytes = { + let a45 = v1; + utf8_encode(a45) + }; + let v4: u64 = { + let a46 = v2.clone(); + length_bytes(a46) + }; + let v5: u64 = { + let a47 = v3.clone(); + length_bytes(a47) + }; + let a48 = v5; + let a49 = v4; + if nat_le(a48, a49) { + f18(v2, { + let a50 = v4; + let a51 = v5; + nat_sub(a50, a51) + }, v3) + } else { + false + } +} + +pub fn f12(v0: Bytes, v1: u64, v2: u64) -> Str { + let m57 = { + let a54 = v0; + let a55 = v1; + let a56 = { + let a52 = v2; + let a53 = v1; + nat_sub(a52, a53) + }; + slice_bytes(a54, a55, a56) + }; + match m57 { + None => { + Str::lit("") + } + Some(v3) => { + let m59 = { + let a58 = v3; + utf8_decode(a58) + }; + match m59 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f13(v0: Str) -> R { + let m60 = f19(f20(v0)?, Str::lit("'")); + match m60 { + None => { + Ok(false) + } + Some(v1) => { + let a61 = f21(v1, Str::lit("'"))?; + Ok(bool_not(a61)) + } + } +} + +pub fn f14(v0: Str) -> R> { + let v1: Bytes = { + let a62 = v0; + utf8_encode(a62) + }; + f22({ + let a63 = v1.clone(); + length_bytes(a63) + }, v1, 0u64) +} + +pub fn f15(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { + let m64 = v0; + if m64 == 0 { + Ok(List::cons(f12(v1.clone(), v3, { + let a65 = v1; + length_bytes(a65) + }), List::::nil())) + } else { + let v5 = m64 - 1; + let a70 = { + let a66 = v1.clone(); + length_bytes(a66) + }; + let a71 = { + let a68 = v4; + let a69 = { + let a67 = v2.clone(); + length_bytes(a67) + }; + nat_add(a68, a69)? + }; + if nat_lt(a70, a71) { + Ok(List::cons(f12(v1.clone(), v3, { + let a72 = v1; + length_bytes(a72) + }), List::::nil())) + } else { + if f18(v1.clone(), v4, v2.clone()) { + Ok(List::cons(f12(v1.clone(), v3, v4), f15(v5, v1, v2.clone(), { + let a74 = v4; + let a75 = { + let a73 = v2.clone(); + length_bytes(a73) + }; + nat_add(a74, a75)? + }, { + let a77 = v4; + let a78 = { + let a76 = v2; + length_bytes(a76) + }; + nat_add(a77, a78)? + })?)) + } else { + f15(v5, v1, v2, v3, { + let a79 = v4; + let a80 = 1u64; + nat_add(a79, a80)? + }) + } + } + } +} + +pub fn f16(p87: u64, v1: Bytes, p88: u64) -> R { + let m86 = (p87, p88); + { + let mut m86 = m86; + loop { + let step = { + let (v0, v2) = m86; + let m81 = v0; + if m81 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m81 - 1; + let v4: u64 = f23(v1.clone(), v2)?; + let a82 = v4; + let a83 = 0u64; + if nat_eq(a82, a83) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a84 = v2; + let a85 = v4; + nat_sub(a84, a85) + })) + } + } + }; + match step { + Ok(next) => { m86 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f17(p99: u64, v1: Bytes, v2: Bytes, p100: u64) -> R> { + let m98 = (p99, p100); + { + let mut m98 = m98; + loop { + let step = { + let (v0, v3) = m98; + let m89 = v0; + if m89 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m89 - 1; + let a94 = { + let a90 = v1.clone(); + length_bytes(a90) + }; + let a95 = { + let a92 = v3; + let a93 = { + let a91 = v2.clone(); + length_bytes(a91) + }; + nat_add(a92, a93)? + }; + if nat_lt(a94, a95) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f18(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a96 = v3; + let a97 = 1u64; + nat_add(a96, a97)? + })) + } + } + } + }; + match step { + Ok(next) => { m98 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f18(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m105 = { + let a102 = v0; + let a103 = v1; + let a104 = { + let a101 = v2.clone(); + length_bytes(a101) + }; + slice_bytes(a102, a103, a104) + }; + match m105 { + None => { + false + } + Some(v3) => { + let a106 = v3; + let a107 = v2; + equal(a106, a107) + } + } +} + +pub fn f19(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a108 = v0; + utf8_encode(a108) + }; + let v3: Bytes = { + let a109 = v1; + utf8_encode(a109) + }; + if f18(v2.clone(), 0u64, v3.clone()) { + Some(f12(v2.clone(), { + let a110 = v3; + length_bytes(a110) + }, { + let a111 = v2; + length_bytes(a111) + })) + } else { + None:: + } +} + +pub fn f20(v0: Str) -> R { + f7(f24(v0)?) +} + +pub fn f21(v0: Str, v1: Str) -> R { + let m112 = f8(v0, v1)?; + match m112 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f22(v0: u64, v1: Bytes, v2: u64) -> R> { + let m113 = v0; + if m113 == 0 { + Ok(List::::nil()) + } else { + let v3 = m113 - 1; + let a115 = { + let a114 = v1.clone(); + length_bytes(a114) + }; + let a116 = v2; + if nat_le(a115, a116) { + Ok(List::::nil()) + } else { + let v4: u64 = f25(f26(v1.clone(), v2)?); + Ok(List::cons(f12(v1.clone(), v2, { + let a117 = v2; + let a118 = v4; + nat_add(a117, a118)? + }), f22(v3, v1, { + let a119 = v2; + let a120 = v4; + nat_add(a119, a120)? + })?)) + } + } +} + +pub fn f23(v0: Bytes, v1: u64) -> R { + let a121 = v1; + let a122 = 0u64; + if nat_eq(a121, a122) { + Ok(0u64) + } else { + if f27(f26(v0.clone(), { + let a123 = v1; + let a124 = 1u64; + nat_sub(a123, a124) + })?) { + Ok(1u64) + } else { + let a125 = 2u64; + let a126 = v1; + if if nat_le(a125, a126) { + let a129 = f28(v0.clone(), { + let a127 = v1; + let a128 = 2u64; + nat_sub(a127, a128) + })?; + let a130 = 2u64; + nat_eq(a129, a130) + } else { + false + } { + Ok(2u64) + } else { + let a131 = 3u64; + let a132 = v1; + if if nat_le(a131, a132) { + let a135 = f28(v0, { + let a133 = v1; + let a134 = 3u64; + nat_sub(a133, a134) + })?; + let a136 = 3u64; + nat_eq(a135, a136) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f24(v0: Str) -> R { + let v1: Bytes = { + let a137 = v0; + utf8_encode(a137) + }; + let v2: u64 = { + let a138 = v1.clone(); + length_bytes(a138) + }; + Ok(f12(v1.clone(), f29(v2, v1, 0u64)?, v2)) +} + +pub fn f25(v0: u64) -> u64 { + let a139 = v0; + let a140 = 128u64; + if nat_lt(a139, a140) { + 1u64 + } else { + let a141 = v0; + let a142 = 224u64; + if nat_lt(a141, a142) { + 2u64 + } else { + let a143 = v0; + let a144 = 240u64; + if nat_lt(a143, a144) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f26(v0: Bytes, v1: u64) -> R { + let m147 = { + let a145 = v0; + let a146 = v1; + index_bytes(a145, a146) + }; + match m147 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a192 = { + let a168 = { + let a156 = { + let a150 = { + let a148 = v3; + let a149 = 128u8; + fixed_u8::bit_and(a148, a149) + }; + let a151 = 128u8; + if equal(a150, a151) { + 128u64 + } else { + 0u64 + } + }; + let a157 = { + let a154 = { + let a152 = v3; + let a153 = 64u8; + fixed_u8::bit_and(a152, a153) + }; + let a155 = 64u8; + if equal(a154, a155) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a156, a157)? + }; + let a169 = { + let a166 = { + let a160 = { + let a158 = v3; + let a159 = 32u8; + fixed_u8::bit_and(a158, a159) + }; + let a161 = 32u8; + if equal(a160, a161) { + 32u64 + } else { + 0u64 + } + }; + let a167 = { + let a164 = { + let a162 = v3; + let a163 = 16u8; + fixed_u8::bit_and(a162, a163) + }; + let a165 = 16u8; + if equal(a164, a165) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a166, a167)? + }; + nat_add(a168, a169)? + }; + let a193 = { + let a190 = { + let a178 = { + let a172 = { + let a170 = v3; + let a171 = 8u8; + fixed_u8::bit_and(a170, a171) + }; + let a173 = 8u8; + if equal(a172, a173) { + 8u64 + } else { + 0u64 + } + }; + let a179 = { + let a176 = { + let a174 = v3; + let a175 = 4u8; + fixed_u8::bit_and(a174, a175) + }; + let a177 = 4u8; + if equal(a176, a177) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a178, a179)? + }; + let a191 = { + let a188 = { + let a182 = { + let a180 = v3; + let a181 = 2u8; + fixed_u8::bit_and(a180, a181) + }; + let a183 = 2u8; + if equal(a182, a183) { + 2u64 + } else { + 0u64 + } + }; + let a189 = { + let a186 = { + let a184 = v3; + let a185 = 1u8; + fixed_u8::bit_and(a184, a185) + }; + let a187 = 1u8; + if equal(a186, a187) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a188, a189)? + }; + nat_add(a190, a191)? + }; + nat_add(a192, a193) + } + } +} + +pub fn f27(v0: u64) -> bool { + let a194 = v0; + let a195 = 32u64; + if nat_eq(a194, a195) { + true + } else { + let a196 = 9u64; + let a197 = v0; + if nat_le(a196, a197) { + let a198 = v0; + let a199 = 13u64; + nat_le(a198, a199) + } else { + false + } + } +} + +pub fn f28(v0: Bytes, v1: u64) -> R { + let v2: u64 = f26(v0.clone(), v1)?; + let v3: u64 = f26(v0.clone(), { + let a200 = v1; + let a201 = 1u64; + nat_add(a200, a201)? + })?; + let v4: u64 = f26(v0, { + let a202 = v1; + let a203 = 2u64; + nat_add(a202, a203)? + })?; + if f27(v2) { + Ok(1u64) + } else { + let a204 = v2; + let a205 = 194u64; + if nat_eq(a204, a205) { + let a206 = v3; + let a207 = 133u64; + if if nat_eq(a206, a207) { + true + } else { + let a208 = v3; + let a209 = 160u64; + nat_eq(a208, a209) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a210 = v2; + let a211 = 225u64; + if nat_eq(a210, a211) { + let a212 = v3; + let a213 = 154u64; + if if nat_eq(a212, a213) { + let a214 = v4; + let a215 = 128u64; + nat_eq(a214, a215) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a216 = v2; + let a217 = 226u64; + if nat_eq(a216, a217) { + let a218 = v3; + let a219 = 128u64; + if nat_eq(a218, a219) { + let a220 = 128u64; + let a221 = v4; + if if if nat_le(a220, a221) { + let a222 = v4; + let a223 = 138u64; + nat_le(a222, a223) + } else { + false + } { + true + } else { + let a224 = v4; + let a225 = 168u64; + if nat_eq(a224, a225) { + true + } else { + let a226 = v4; + let a227 = 169u64; + if nat_eq(a226, a227) { + true + } else { + let a228 = v4; + let a229 = 175u64; + nat_eq(a228, a229) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a230 = v3; + let a231 = 129u64; + if if nat_eq(a230, a231) { + let a232 = v4; + let a233 = 159u64; + nat_eq(a232, a233) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a234 = v2; + let a235 = 227u64; + if if nat_eq(a234, a235) { + let a236 = v3; + let a237 = 128u64; + if nat_eq(a236, a237) { + let a238 = v4; + let a239 = 128u64; + nat_eq(a238, a239) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f29(p246: u64, v1: Bytes, p247: u64) -> R { + let m245 = (p246, p247); + { + let mut m245 = m245; + loop { + let step = { + let (v0, v2) = m245; + let m240 = v0; + if m240 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m240 - 1; + let v4: u64 = f28(v1.clone(), v2)?; + let a241 = v4; + let a242 = 0u64; + if nat_eq(a241, a242) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a243 = v2; + let a244 = v4; + nat_add(a243, a244)? + })) + } + } + }; + match step { + Ok(next) => { m245 = next; } Err(done) => break done, } } } } -pub fn run(p0: Adt0, p1: Str) -> Str { +pub fn run(p0: Adt0, p1: Str) -> R { f0(p0, p1) } diff --git a/crates/certified/roots/uorust_certified_types_size_name.rs b/crates/certified/roots/uorust_certified_types_size_name.rs index df254cc7..6c19c617 100644 --- a/crates/certified/roots/uorust_certified_types_size_name.rs +++ b/crates/certified/roots/uorust_certified_types_size_name.rs @@ -857,7 +857,7 @@ pub fn format_int(p0: i64) -> Str { #[derive(Clone)] pub enum Adt0 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -878,20 +878,21 @@ pub enum Adt3 { C3(u64), C4(Adt4), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -971,7 +972,7 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C5(_) => { None:: } - Adt3::C6 => { + Adt3::C6(_) => { None:: } Adt3::C7 => { @@ -986,16 +987,19 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C10 => { None:: } - Adt3::C11(v6) => { - if f2(v1, v6.clone()) { - Some(v6) + Adt3::C11 => { + None:: + } + Adt3::C12(v7) => { + if f2(v1, v7.clone()) { + Some(v7) } else { None:: } } - Adt3::C12(r11) => { - let v7 = (*r11).clone(); - let m5 = v7; + Adt3::C13(r11) => { + let v8 = (*r11).clone(); + let m5 = v8; match m5 { Adt3::C0 => { None:: @@ -1015,7 +1019,7 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C5(_) => { None:: } - Adt3::C6 => { + Adt3::C6(_) => { None:: } Adt3::C7 => { @@ -1030,10 +1034,13 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C10 => { None:: } - Adt3::C11(v12) => { - if f3(v1, v12.clone()) { + Adt3::C11 => { + None:: + } + Adt3::C12(v14) => { + if f3(v1, v14.clone()) { Some({ - let a6 = List::cons(Str::lit("option_"), List::cons(v12, List::::nil())); + let a6 = List::cons(Str::lit("option_"), List::cons(v14, List::::nil())); let a7 = Str::lit(""); join(a6, a7) }) @@ -1041,13 +1048,10 @@ pub fn f1(v0: Adt3, v1: List) -> Option { None:: } } - Adt3::C12(_) => { + Adt3::C13(_) => { None:: } - Adt3::C13(_, _) => { - None:: - } - Adt3::C14(_) => { + Adt3::C14(_, _) => { None:: } Adt3::C15(_) => { @@ -1056,23 +1060,26 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C16(_) => { None:: } - Adt3::C17(_, _, _) => { + Adt3::C17(_) => { None:: } - Adt3::C18(_, _) => { + Adt3::C18(_, _, _) => { None:: } Adt3::C19(_, _) => { None:: } + Adt3::C20(_, _) => { + None:: + } } } - Adt3::C13(_, _) => { + Adt3::C14(_, _) => { None:: } - Adt3::C14(r12) => { - let v28 = (*r12).clone(); - let m8 = v28; + Adt3::C15(r12) => { + let v30 = (*r12).clone(); + let m8 = v30; match m8 { Adt3::C0 => { None:: @@ -1092,7 +1099,7 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C5(_) => { None:: } - Adt3::C6 => { + Adt3::C6(_) => { None:: } Adt3::C7 => { @@ -1107,10 +1114,13 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C10 => { None:: } - Adt3::C11(v33) => { - if f4(v1, v33.clone()) { + Adt3::C11 => { + None:: + } + Adt3::C12(v36) => { + if f4(v1, v36.clone()) { Some({ - let a9 = List::cons(Str::lit("list_"), List::cons(v33, List::::nil())); + let a9 = List::cons(Str::lit("list_"), List::cons(v36, List::::nil())); let a10 = Str::lit(""); join(a9, a10) }) @@ -1118,13 +1128,10 @@ pub fn f1(v0: Adt3, v1: List) -> Option { None:: } } - Adt3::C12(_) => { - None:: - } - Adt3::C13(_, _) => { + Adt3::C13(_) => { None:: } - Adt3::C14(_) => { + Adt3::C14(_, _) => { None:: } Adt3::C15(_) => { @@ -1133,32 +1140,35 @@ pub fn f1(v0: Adt3, v1: List) -> Option { Adt3::C16(_) => { None:: } - Adt3::C17(_, _, _) => { + Adt3::C17(_) => { None:: } - Adt3::C18(_, _) => { + Adt3::C18(_, _, _) => { None:: } Adt3::C19(_, _) => { None:: } + Adt3::C20(_, _) => { + None:: + } } } - Adt3::C15(_) => { - None:: - } Adt3::C16(_) => { None:: } - Adt3::C17(_, _, _) => { + Adt3::C17(_) => { None:: } - Adt3::C18(_, _) => { + Adt3::C18(_, _, _) => { None:: } Adt3::C19(_, _) => { None:: } + Adt3::C20(_, _) => { + None:: + } } } diff --git a/crates/certified/roots/uorust_certified_types_unnamed.rs b/crates/certified/roots/uorust_certified_types_unnamed.rs new file mode 100644 index 00000000..005eefd2 --- /dev/null +++ b/crates/certified/roots/uorust_certified_types_unnamed.rs @@ -0,0 +1,1985 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(Str, List<(Str, Adt3)>), +} + +#[derive(Clone)] +pub enum Adt3 { + C0, + C1, + C2(Option), + C3(u64), + C4(Adt4), + C5(Option), + C6(Option), + C7, + C8, + C9, + C10, + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), + C16(List), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(u64, u64), +} + +#[derive(Clone)] +pub enum Adt5 { + C0(Str, Str), +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Str, List<(Str, List<(Option, Adt3)>)>), +} + +#[derive(Clone)] +pub enum Adt7 { + C0(Str, Adt4), +} + +#[derive(Clone)] +pub enum Adt8 { + C0(Str, Adt5), +} + +#[derive(Clone)] +pub enum Adt9 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt10 { + C0(u64, Str), +} + +#[derive(Clone)] +pub enum Adt11 { + C0(Str, List), +} + +#[derive(Clone)] +pub enum Adt12 { + C0(Str), + C1(Str), + C2, + C3(Str), + C4(Str, List), + C5(Str), + C6(Str), + C7(Str), + C8(Str), + C9(Str), + C10(Adt14), +} + +#[derive(Clone)] +pub enum Adt13 { + C0(u64, List), +} + +#[derive(Clone)] +pub enum Adt14 { + C0(Str, Str), + C1(Str), + C2(Str), + C3, + C4(Str), + C5(Str, Str), + C6(Str, List), +} + +#[derive(Clone)] +pub enum Adt15 { + C0(Str, Adt16), +} + +#[derive(Clone)] +pub enum Adt16 { + C0(u64, u64), +} + +pub fn f0(v0: Adt0, v1: Str) -> R { + let v2: Option = f1(match v0.clone() { + Adt0::C0(_, _, _, _, _, _, _, _, _, _, _, _, h1) => { + h1 + } + }, f2(v0, v1.clone())?); + Ok(Adt12::C1(f3(v2, v1))) +} + +pub fn f1(p8: List, v1: Str) -> Option { + let m7 = p8; + { + let mut m7 = m7; + loop { + let step = { + let v0 = m7; + let m2 = v0; + match m2.uncons() { + None => { + Err::, Option>(None::) + } + Some((v2, v3)) => { + let a4 = match v2.clone() { + Adt5::C0(h3, _) => { + h3 + } + }; + let a5 = v1.clone(); + if equal(a4, a5) { + Err::, Option>(Some(match v2 { + Adt5::C0(_, h6) => { + h6 + } + })) + } else { + Ok::, Option>(v3) + } + } + } + }; + match step { + Ok(next) => { m7 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f2(v0: Adt0, v1: Str) -> R { + let v2: Str = f4(v1)?; + let m10 = f5(match v0 { + Adt0::C0(_, _, h9, _, _, _, _, _, _, _, _, _, _) => { + h9 + } + }, v2.clone()); + match m10 { + None => { + Ok(v2) + } + Some(v3) => { + Ok(v3) + } + } +} + +pub fn f3(v0: Option, v1: Str) -> Str { + let m11 = v0; + match m11 { + None => { + v1 + } + Some(v2) => { + v2 + } + } +} + +pub fn f4(v0: Str) -> R { + let m12 = f6(v0.clone())?; + match m12 { + None => { + Ok(v0) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt5::C0(h13, _) => { + h13 + } + }; + let v3: Str = match v1 { + Adt5::C0(_, h14) => { + h14 + } + }; + let m15 = f7(v3, Str::lit(">")); + match m15 { + None => { + Ok(v0) + } + Some(v4) => { + if f8(f9(v4, Str::lit(","))?)? { + f10(v2) + } else { + Ok(v0) + } + } + } + } + } +} + +pub fn f5(p22: List, v1: Str) -> Option { + let m21 = p22; + { + let mut m21 = m21; + loop { + let step = { + let v0 = m21; + let m16 = v0; + match m16.uncons() { + None => { + Err::, Option>(None::) + } + Some((v2, v3)) => { + let a18 = match v2.clone() { + Adt5::C0(h17, _) => { + h17 + } + }; + let a19 = v1.clone(); + if equal(a18, a19) { + Err::, Option>(Some(match v2 { + Adt5::C0(_, h20) => { + h20 + } + })) + } else { + Ok::, Option>(v3) + } + } + } + }; + match step { + Ok(next) => { m21 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f6(v0: Str) -> R> { + let m23 = f11(v0.clone(), Str::lit("<"))?; + match m23 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt5::C0(f12(v0.clone(), 0u64, v1), f12(v0.clone(), { + let a24 = v1; + let a25 = f13(Str::lit("<")); + nat_add(a24, a25)? + }, f13(v0))))) + } + } +} + +pub fn f7(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a26 = v0.clone(); + utf8_encode(a26) + }; + let v3: u64 = { + let a27 = v2.clone(); + length_bytes(a27) + }; + let v4: u64 = f13(v1.clone()); + if f14(v0, v1) { + Some(f15(v2, 0u64, { + let a28 = v3; + let a29 = v4; + nat_sub(a28, a29) + })) + } else { + None:: + } +} + +pub fn f8(p32: List) -> R { + let m31 = p32; + { + let mut m31 = m31; + loop { + let step = { + let v0 = m31; + let m30 = v0; + match m30.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + if f16(v1)? { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m31 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f9(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a33 = v0.clone(); + utf8_encode(a33) + }; + let v3: Bytes = { + let a34 = v1; + utf8_encode(a34) + }; + let a36 = { + let a35 = v3.clone(); + length_bytes(a35) + }; + let a37 = 0u64; + if nat_eq(a36, a37) { + Ok(List::cons(Str::lit(""), { + let a38 = f17(v0)?; + let a39 = List::cons(Str::lit(""), List::::nil()); + append_list(a38, a39) + })) + } else { + f18({ + let a41 = { + let a40 = v2.clone(); + length_bytes(a40) + }; + let a42 = 1u64; + nat_add(a41, a42)? + }, v2, v3, 0u64, 0u64) + } +} + +pub fn f10(v0: Str) -> R { + let v1: Bytes = { + let a43 = v0; + utf8_encode(a43) + }; + let v2: u64 = { + let a44 = v1.clone(); + length_bytes(a44) + }; + Ok(f15(v1.clone(), 0u64, f19(v2, v1, v2)?)) +} + +pub fn f11(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a45 = v0; + utf8_encode(a45) + }; + f20({ + let a47 = { + let a46 = v2.clone(); + length_bytes(a46) + }; + let a48 = 1u64; + nat_add(a47, a48)? + }, v2, { + let a49 = v1; + utf8_encode(a49) + }, 0u64) +} + +pub fn f12(v0: Str, v1: u64, v2: u64) -> Str { + f15({ + let a50 = v0; + utf8_encode(a50) + }, v1, v2) +} + +pub fn f13(v0: Str) -> u64 { + let a52 = { + let a51 = v0; + utf8_encode(a51) + }; + length_bytes(a52) +} + +pub fn f14(v0: Str, v1: Str) -> bool { + let v2: Bytes = { + let a53 = v0; + utf8_encode(a53) + }; + let v3: Bytes = { + let a54 = v1; + utf8_encode(a54) + }; + let v4: u64 = { + let a55 = v2.clone(); + length_bytes(a55) + }; + let v5: u64 = { + let a56 = v3.clone(); + length_bytes(a56) + }; + let a57 = v5; + let a58 = v4; + if nat_le(a57, a58) { + f21(v2, { + let a59 = v4; + let a60 = v5; + nat_sub(a59, a60) + }, v3) + } else { + false + } +} + +pub fn f15(v0: Bytes, v1: u64, v2: u64) -> Str { + let m66 = { + let a63 = v0; + let a64 = v1; + let a65 = { + let a61 = v2; + let a62 = v1; + nat_sub(a61, a62) + }; + slice_bytes(a63, a64, a65) + }; + match m66 { + None => { + Str::lit("") + } + Some(v3) => { + let m68 = { + let a67 = v3; + utf8_decode(a67) + }; + match m68 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f16(v0: Str) -> R { + let m69 = f22(f23(v0)?, Str::lit("'")); + match m69 { + None => { + Ok(false) + } + Some(v1) => { + let a70 = f24(v1, Str::lit("'"))?; + Ok(bool_not(a70)) + } + } +} + +pub fn f17(v0: Str) -> R> { + let v1: Bytes = { + let a71 = v0; + utf8_encode(a71) + }; + f25({ + let a72 = v1.clone(); + length_bytes(a72) + }, v1, 0u64) +} + +pub fn f18(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { + let m73 = v0; + if m73 == 0 { + Ok(List::cons(f15(v1.clone(), v3, { + let a74 = v1; + length_bytes(a74) + }), List::::nil())) + } else { + let v5 = m73 - 1; + let a79 = { + let a75 = v1.clone(); + length_bytes(a75) + }; + let a80 = { + let a77 = v4; + let a78 = { + let a76 = v2.clone(); + length_bytes(a76) + }; + nat_add(a77, a78)? + }; + if nat_lt(a79, a80) { + Ok(List::cons(f15(v1.clone(), v3, { + let a81 = v1; + length_bytes(a81) + }), List::::nil())) + } else { + if f21(v1.clone(), v4, v2.clone()) { + Ok(List::cons(f15(v1.clone(), v3, v4), f18(v5, v1, v2.clone(), { + let a83 = v4; + let a84 = { + let a82 = v2.clone(); + length_bytes(a82) + }; + nat_add(a83, a84)? + }, { + let a86 = v4; + let a87 = { + let a85 = v2; + length_bytes(a85) + }; + nat_add(a86, a87)? + })?)) + } else { + f18(v5, v1, v2, v3, { + let a88 = v4; + let a89 = 1u64; + nat_add(a88, a89)? + }) + } + } + } +} + +pub fn f19(p96: u64, v1: Bytes, p97: u64) -> R { + let m95 = (p96, p97); + { + let mut m95 = m95; + loop { + let step = { + let (v0, v2) = m95; + let m90 = v0; + if m90 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m90 - 1; + let v4: u64 = f26(v1.clone(), v2)?; + let a91 = v4; + let a92 = 0u64; + if nat_eq(a91, a92) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a93 = v2; + let a94 = v4; + nat_sub(a93, a94) + })) + } + } + }; + match step { + Ok(next) => { m95 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f20(p108: u64, v1: Bytes, v2: Bytes, p109: u64) -> R> { + let m107 = (p108, p109); + { + let mut m107 = m107; + loop { + let step = { + let (v0, v3) = m107; + let m98 = v0; + if m98 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m98 - 1; + let a103 = { + let a99 = v1.clone(); + length_bytes(a99) + }; + let a104 = { + let a101 = v3; + let a102 = { + let a100 = v2.clone(); + length_bytes(a100) + }; + nat_add(a101, a102)? + }; + if nat_lt(a103, a104) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f21(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a105 = v3; + let a106 = 1u64; + nat_add(a105, a106)? + })) + } + } + } + }; + match step { + Ok(next) => { m107 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f21(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m114 = { + let a111 = v0; + let a112 = v1; + let a113 = { + let a110 = v2.clone(); + length_bytes(a110) + }; + slice_bytes(a111, a112, a113) + }; + match m114 { + None => { + false + } + Some(v3) => { + let a115 = v3; + let a116 = v2; + equal(a115, a116) + } + } +} + +pub fn f22(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a117 = v0; + utf8_encode(a117) + }; + let v3: Bytes = { + let a118 = v1; + utf8_encode(a118) + }; + if f21(v2.clone(), 0u64, v3.clone()) { + Some(f15(v2.clone(), { + let a119 = v3; + length_bytes(a119) + }, { + let a120 = v2; + length_bytes(a120) + })) + } else { + None:: + } +} + +pub fn f23(v0: Str) -> R { + f10(f27(v0)?) +} + +pub fn f24(v0: Str, v1: Str) -> R { + let m121 = f11(v0, v1)?; + match m121 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f25(v0: u64, v1: Bytes, v2: u64) -> R> { + let m122 = v0; + if m122 == 0 { + Ok(List::::nil()) + } else { + let v3 = m122 - 1; + let a124 = { + let a123 = v1.clone(); + length_bytes(a123) + }; + let a125 = v2; + if nat_le(a124, a125) { + Ok(List::::nil()) + } else { + let v4: u64 = f28(f29(v1.clone(), v2)?); + Ok(List::cons(f15(v1.clone(), v2, { + let a126 = v2; + let a127 = v4; + nat_add(a126, a127)? + }), f25(v3, v1, { + let a128 = v2; + let a129 = v4; + nat_add(a128, a129)? + })?)) + } + } +} + +pub fn f26(v0: Bytes, v1: u64) -> R { + let a130 = v1; + let a131 = 0u64; + if nat_eq(a130, a131) { + Ok(0u64) + } else { + if f30(f29(v0.clone(), { + let a132 = v1; + let a133 = 1u64; + nat_sub(a132, a133) + })?) { + Ok(1u64) + } else { + let a134 = 2u64; + let a135 = v1; + if if nat_le(a134, a135) { + let a138 = f31(v0.clone(), { + let a136 = v1; + let a137 = 2u64; + nat_sub(a136, a137) + })?; + let a139 = 2u64; + nat_eq(a138, a139) + } else { + false + } { + Ok(2u64) + } else { + let a140 = 3u64; + let a141 = v1; + if if nat_le(a140, a141) { + let a144 = f31(v0, { + let a142 = v1; + let a143 = 3u64; + nat_sub(a142, a143) + })?; + let a145 = 3u64; + nat_eq(a144, a145) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f27(v0: Str) -> R { + let v1: Bytes = { + let a146 = v0; + utf8_encode(a146) + }; + let v2: u64 = { + let a147 = v1.clone(); + length_bytes(a147) + }; + Ok(f15(v1.clone(), f32(v2, v1, 0u64)?, v2)) +} + +pub fn f28(v0: u64) -> u64 { + let a148 = v0; + let a149 = 128u64; + if nat_lt(a148, a149) { + 1u64 + } else { + let a150 = v0; + let a151 = 224u64; + if nat_lt(a150, a151) { + 2u64 + } else { + let a152 = v0; + let a153 = 240u64; + if nat_lt(a152, a153) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f29(v0: Bytes, v1: u64) -> R { + let m156 = { + let a154 = v0; + let a155 = v1; + index_bytes(a154, a155) + }; + match m156 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a201 = { + let a177 = { + let a165 = { + let a159 = { + let a157 = v3; + let a158 = 128u8; + fixed_u8::bit_and(a157, a158) + }; + let a160 = 128u8; + if equal(a159, a160) { + 128u64 + } else { + 0u64 + } + }; + let a166 = { + let a163 = { + let a161 = v3; + let a162 = 64u8; + fixed_u8::bit_and(a161, a162) + }; + let a164 = 64u8; + if equal(a163, a164) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a165, a166)? + }; + let a178 = { + let a175 = { + let a169 = { + let a167 = v3; + let a168 = 32u8; + fixed_u8::bit_and(a167, a168) + }; + let a170 = 32u8; + if equal(a169, a170) { + 32u64 + } else { + 0u64 + } + }; + let a176 = { + let a173 = { + let a171 = v3; + let a172 = 16u8; + fixed_u8::bit_and(a171, a172) + }; + let a174 = 16u8; + if equal(a173, a174) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a175, a176)? + }; + nat_add(a177, a178)? + }; + let a202 = { + let a199 = { + let a187 = { + let a181 = { + let a179 = v3; + let a180 = 8u8; + fixed_u8::bit_and(a179, a180) + }; + let a182 = 8u8; + if equal(a181, a182) { + 8u64 + } else { + 0u64 + } + }; + let a188 = { + let a185 = { + let a183 = v3; + let a184 = 4u8; + fixed_u8::bit_and(a183, a184) + }; + let a186 = 4u8; + if equal(a185, a186) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a187, a188)? + }; + let a200 = { + let a197 = { + let a191 = { + let a189 = v3; + let a190 = 2u8; + fixed_u8::bit_and(a189, a190) + }; + let a192 = 2u8; + if equal(a191, a192) { + 2u64 + } else { + 0u64 + } + }; + let a198 = { + let a195 = { + let a193 = v3; + let a194 = 1u8; + fixed_u8::bit_and(a193, a194) + }; + let a196 = 1u8; + if equal(a195, a196) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a197, a198)? + }; + nat_add(a199, a200)? + }; + nat_add(a201, a202) + } + } +} + +pub fn f30(v0: u64) -> bool { + let a203 = v0; + let a204 = 32u64; + if nat_eq(a203, a204) { + true + } else { + let a205 = 9u64; + let a206 = v0; + if nat_le(a205, a206) { + let a207 = v0; + let a208 = 13u64; + nat_le(a207, a208) + } else { + false + } + } +} + +pub fn f31(v0: Bytes, v1: u64) -> R { + let v2: u64 = f29(v0.clone(), v1)?; + let v3: u64 = f29(v0.clone(), { + let a209 = v1; + let a210 = 1u64; + nat_add(a209, a210)? + })?; + let v4: u64 = f29(v0, { + let a211 = v1; + let a212 = 2u64; + nat_add(a211, a212)? + })?; + if f30(v2) { + Ok(1u64) + } else { + let a213 = v2; + let a214 = 194u64; + if nat_eq(a213, a214) { + let a215 = v3; + let a216 = 133u64; + if if nat_eq(a215, a216) { + true + } else { + let a217 = v3; + let a218 = 160u64; + nat_eq(a217, a218) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a219 = v2; + let a220 = 225u64; + if nat_eq(a219, a220) { + let a221 = v3; + let a222 = 154u64; + if if nat_eq(a221, a222) { + let a223 = v4; + let a224 = 128u64; + nat_eq(a223, a224) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a225 = v2; + let a226 = 226u64; + if nat_eq(a225, a226) { + let a227 = v3; + let a228 = 128u64; + if nat_eq(a227, a228) { + let a229 = 128u64; + let a230 = v4; + if if if nat_le(a229, a230) { + let a231 = v4; + let a232 = 138u64; + nat_le(a231, a232) + } else { + false + } { + true + } else { + let a233 = v4; + let a234 = 168u64; + if nat_eq(a233, a234) { + true + } else { + let a235 = v4; + let a236 = 169u64; + if nat_eq(a235, a236) { + true + } else { + let a237 = v4; + let a238 = 175u64; + nat_eq(a237, a238) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a239 = v3; + let a240 = 129u64; + if if nat_eq(a239, a240) { + let a241 = v4; + let a242 = 159u64; + nat_eq(a241, a242) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a243 = v2; + let a244 = 227u64; + if if nat_eq(a243, a244) { + let a245 = v3; + let a246 = 128u64; + if nat_eq(a245, a246) { + let a247 = v4; + let a248 = 128u64; + nat_eq(a247, a248) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f32(p255: u64, v1: Bytes, p256: u64) -> R { + let m254 = (p255, p256); + { + let mut m254 = m254; + loop { + let step = { + let (v0, v2) = m254; + let m249 = v0; + if m249 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m249 - 1; + let v4: u64 = f31(v1.clone(), v2)?; + let a250 = v4; + let a251 = 0u64; + if nat_eq(a250, a251) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a252 = v2; + let a253 = v4; + nat_add(a252, a253)? + })) + } + } + }; + match step { + Ok(next) => { m254 = next; } + Err(done) => break done, + } + } + } +} + +pub fn run(p0: Adt0, p1: Str) -> R { + f0(p0, p1) +} diff --git a/crates/certified/roots/uorust_certified_unicode_property.rs b/crates/certified/roots/uorust_certified_unicode_property.rs index aaa8a080..9aeb719b 100644 --- a/crates/certified/roots/uorust_certified_unicode_property.rs +++ b/crates/certified/roots/uorust_certified_unicode_property.rs @@ -861,49 +861,69 @@ pub fn f0(v0: Str) -> Option { if equal(a1, a2) { let v1: Str = Str::lit("Alphabetic"); Some({ - let a3 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v1, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a4 = Str::lit(""); - join(a3, a4) + let a5 = { + let a3 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a4 = List::cons(Str::lit(" tests the Unicode "), List::cons(v1, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a3, a4) + }; + let a6 = Str::lit(""); + join(a5, a6) }) } else { - let a5 = v0.clone(); - let a6 = Str::lit("is_alphanumeric"); - if equal(a5, a6) { + let a7 = v0.clone(); + let a8 = Str::lit("is_alphanumeric"); + if equal(a7, a8) { let v2: Str = Str::lit("Alphabetic or Numeric"); Some({ - let a7 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v2, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a8 = Str::lit(""); - join(a7, a8) + let a11 = { + let a9 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a10 = List::cons(Str::lit(" tests the Unicode "), List::cons(v2, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a9, a10) + }; + let a12 = Str::lit(""); + join(a11, a12) }) } else { - let a9 = v0.clone(); - let a10 = Str::lit("is_numeric"); - if equal(a9, a10) { + let a13 = v0.clone(); + let a14 = Str::lit("is_numeric"); + if equal(a13, a14) { let v3: Str = Str::lit("Numeric"); Some({ - let a11 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v3, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a12 = Str::lit(""); - join(a11, a12) + let a17 = { + let a15 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a16 = List::cons(Str::lit(" tests the Unicode "), List::cons(v3, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a15, a16) + }; + let a18 = Str::lit(""); + join(a17, a18) }) } else { - let a13 = v0.clone(); - let a14 = Str::lit("is_uppercase"); - if equal(a13, a14) { + let a19 = v0.clone(); + let a20 = Str::lit("is_uppercase"); + if equal(a19, a20) { let v4: Str = Str::lit("Uppercase"); Some({ - let a15 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v4, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a16 = Str::lit(""); - join(a15, a16) + let a23 = { + let a21 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a22 = List::cons(Str::lit(" tests the Unicode "), List::cons(v4, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a21, a22) + }; + let a24 = Str::lit(""); + join(a23, a24) }) } else { - let a17 = v0.clone(); - let a18 = Str::lit("is_lowercase"); - if equal(a17, a18) { + let a25 = v0.clone(); + let a26 = Str::lit("is_lowercase"); + if equal(a25, a26) { let v5: Str = Str::lit("Lowercase"); Some({ - let a19 = List::cons(Str::lit("char::"), List::cons(v0, List::cons(Str::lit(" tests the Unicode "), List::cons(v5, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))))); - let a20 = Str::lit(""); - join(a19, a20) + let a29 = { + let a27 = List::cons(Str::lit("char::"), List::cons(v0, List::::nil())); + let a28 = List::cons(Str::lit(" tests the Unicode "), List::cons(v5, List::cons(Str::lit(" property, and no Unicode table is bound in LexLean or the SDK"), List::::nil()))); + append_list(a27, a28) + }; + let a30 = Str::lit(""); + join(a29, a30) }) } else { None:: diff --git a/crates/certified/roots/uorust_certified_unread_shape.rs b/crates/certified/roots/uorust_certified_unread_shape.rs new file mode 100644 index 00000000..1a8f8d4a --- /dev/null +++ b/crates/certified/roots/uorust_certified_unread_shape.rs @@ -0,0 +1,910 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +#[derive(Clone)] +pub enum Adt0 { + C0(Str, Adt1), +} + +#[derive(Clone)] +pub enum Adt1 { + C0(Str, std::rc::Rc), +} + +#[derive(Clone)] +pub enum Adt2 { + C0(bool, std::rc::Rc), + C1(std::rc::Rc), + C2(std::rc::Rc, Str), + C3(List, std::rc::Rc), + C4(std::rc::Rc), + C5(List), + C6(bool, Adt3), + C7, +} + +#[derive(Clone)] +pub enum Adt3 { + C0(List, Str), +} + +#[derive(Clone)] +pub enum Adt4 { + C0(Str, Adt5), +} + +#[derive(Clone)] +pub enum Adt5 { + C0, + C1(List), + C2, +} + +#[derive(Clone)] +pub enum Adt6 { + C0(Adt1), + C1(Str), +} + +pub fn f0(v0: Str) -> Adt0 { + let v1: Adt1 = Adt1::C0(v0, std::rc::Rc::new(Adt2::C7)); + Adt0::C0(Str::lit(""), v1) +} + +pub fn run(p0: Str) -> Adt0 { + f0(p0) +} diff --git a/crates/certified/roots/uorust_certified_ty_entry.rs b/crates/certified/roots/uorust_certified_uorust_lift_ty_entry.rs similarity index 94% rename from crates/certified/roots/uorust_certified_ty_entry.rs rename to crates/certified/roots/uorust_certified_uorust_lift_ty_entry.rs index 8528b5c2..f015076e 100644 --- a/crates/certified/roots/uorust_certified_ty_entry.rs +++ b/crates/certified/roots/uorust_certified_uorust_lift_ty_entry.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -911,68 +912,72 @@ pub fn f0(v0: Adt0) -> Adt0 { let v10: Adt0 = Adt0::C5(v9); v10 } - Adt0::C6 => { - let v11: Adt0 = Adt0::C6; - v11 + Adt0::C6(v11) => { + let v12: Adt0 = Adt0::C6(v11); + v12 } Adt0::C7 => { - let v12: Adt0 = Adt0::C7; - v12 + let v13: Adt0 = Adt0::C7; + v13 } Adt0::C8 => { - let v13: Adt0 = Adt0::C8; - v13 + let v14: Adt0 = Adt0::C8; + v14 } Adt0::C9 => { - let v14: Adt0 = Adt0::C9; - v14 + let v15: Adt0 = Adt0::C9; + v15 } Adt0::C10 => { - let v15: Adt0 = Adt0::C10; - v15 + let v16: Adt0 = Adt0::C10; + v16 } - Adt0::C11(v16) => { - let v17: Adt0 = Adt0::C11(v16); + Adt0::C11 => { + let v17: Adt0 = Adt0::C11; v17 } - Adt0::C12(r2) => { - let v18 = (*r2).clone(); - let v19: Adt0 = Adt0::C12(std::rc::Rc::new(v18)); + Adt0::C12(v18) => { + let v19: Adt0 = Adt0::C12(v18); v19 } - Adt0::C13(r3, r4) => { - let v20 = (*r3).clone(); - let v21 = (*r4).clone(); - let v22: Adt0 = Adt0::C13(std::rc::Rc::new(v20), std::rc::Rc::new(v21)); - v22 + Adt0::C13(r2) => { + let v20 = (*r2).clone(); + let v21: Adt0 = Adt0::C13(std::rc::Rc::new(v20)); + v21 } - Adt0::C14(r5) => { - let v23 = (*r5).clone(); - let v24: Adt0 = Adt0::C14(std::rc::Rc::new(v23)); + Adt0::C14(r3, r4) => { + let v22 = (*r3).clone(); + let v23 = (*r4).clone(); + let v24: Adt0 = Adt0::C14(std::rc::Rc::new(v22), std::rc::Rc::new(v23)); v24 } - Adt0::C15(v25) => { - let v26: Adt0 = Adt0::C15(v25); + Adt0::C15(r5) => { + let v25 = (*r5).clone(); + let v26: Adt0 = Adt0::C15(std::rc::Rc::new(v25)); v26 } Adt0::C16(v27) => { let v28: Adt0 = Adt0::C16(v27); v28 } - Adt0::C17(r6, r7, _) => { - let v29 = (*r6).clone(); - let v30 = (*r7).clone(); - Adt0::C15(List::cons(v29, List::cons(v30, List::::nil()))) + Adt0::C17(v29) => { + let v30: Adt0 = Adt0::C17(v29); + v30 + } + Adt0::C18(r6, r7, _) => { + let v31 = (*r6).clone(); + let v32 = (*r7).clone(); + Adt0::C16(List::cons(v31, List::cons(v32, List::::nil()))) } - Adt0::C18(r8, v33) => { - let v32 = (*r8).clone(); - let v34: Adt0 = Adt0::C18(std::rc::Rc::new(v32), v33); - v34 + Adt0::C19(r8, v35) => { + let v34 = (*r8).clone(); + let v36: Adt0 = Adt0::C19(std::rc::Rc::new(v34), v35); + v36 } - Adt0::C19(v35, r9) => { - let v36 = (*r9).clone(); - let v37: Adt0 = Adt0::C19(v35, std::rc::Rc::new(v36)); - v37 + Adt0::C20(v37, r9) => { + let v38 = (*r9).clone(); + let v39: Adt0 = Adt0::C20(v37, std::rc::Rc::new(v38)); + v39 } } } diff --git a/crates/certified/roots/uorust_certified_ty_render.rs b/crates/certified/roots/uorust_certified_uorust_lift_ty_render.rs similarity index 82% rename from crates/certified/roots/uorust_certified_ty_render.rs rename to crates/certified/roots/uorust_certified_uorust_lift_ty_render.rs index 148a89c0..03acd103 100644 --- a/crates/certified/roots/uorust_certified_ty_render.rs +++ b/crates/certified/roots/uorust_certified_uorust_lift_ty_render.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -903,90 +904,121 @@ pub fn f0(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + Str::lit("Int") } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { + Str::lit("Nat") + } + Adt0::C10 => { let a2 = List::cons(f1(), List::cons(Str::lit("::ParseIntError"), List::::nil())); let a3 = Str::lit(""); join(a2, a3) } - Adt0::C10 => { + Adt0::C11 => { let a4 = List::cons(f1(), List::cons(Str::lit("::FilePath"), List::::nil())); let a5 = Str::lit(""); join(a4, a5) } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r28) => { - let v6 = (*r28).clone(); - let a6 = List::cons(Str::lit("(Option "), List::cons(f0(v6), List::cons(Str::lit(")"), List::::nil()))); - let a7 = Str::lit(""); - join(a6, a7) + Adt0::C12(v6) => { + v6 } - Adt0::C13(r29, r30) => { - let v7 = (*r29).clone(); - let v8 = (*r30).clone(); - let a8 = List::cons(Str::lit("(Result "), List::cons(f0(v7), List::cons(Str::lit(" "), List::cons(f0(v8), List::cons(Str::lit(")"), List::::nil()))))); + Adt0::C13(r42) => { + let v7 = (*r42).clone(); + let a8 = { + let a6 = List::cons(Str::lit("(Option "), List::::nil()); + let a7 = List::cons(f0(v7), List::cons(Str::lit(")"), List::::nil())); + append_list(a6, a7) + }; let a9 = Str::lit(""); join(a8, a9) } - Adt0::C14(r31) => { - let v9 = (*r31).clone(); - let a10 = List::cons(Str::lit("(List "), List::cons(f0(v9), List::cons(Str::lit(")"), List::::nil()))); - let a11 = Str::lit(""); - join(a10, a11) - } - Adt0::C15(v10) => { - let a14 = List::cons(Str::lit("Tuple"), List::cons({ - let a12 = f2(v10); - let a13 = Str::lit(""); - join(a12, a13) - }, List::::nil())); - let a15 = Str::lit(""); - join(a14, a15) + Adt0::C14(r43, r44) => { + let v8 = (*r43).clone(); + let v9 = (*r44).clone(); + let a12 = { + let a10 = List::cons(Str::lit("(Result "), List::cons(f0(v8), List::::nil())); + let a11 = List::cons(Str::lit(" "), List::cons(f0(v9), List::cons(Str::lit(")"), List::::nil()))); + append_list(a10, a11) + }; + let a13 = Str::lit(""); + join(a12, a13) + } + Adt0::C15(r45) => { + let v10 = (*r45).clone(); + let a16 = { + let a14 = List::cons(Str::lit("(List "), List::::nil()); + let a15 = List::cons(f0(v10), List::cons(Str::lit(")"), List::::nil())); + append_list(a14, a15) + }; + let a17 = Str::lit(""); + join(a16, a17) } Adt0::C16(v11) => { - let a18 = List::cons(Str::lit("("), List::cons({ - let a16 = f3(v11); - let a17 = Str::lit(" * "); - join(a16, a17) - }, List::cons(Str::lit(")"), List::::nil()))); - let a19 = Str::lit(""); - join(a18, a19) - } - Adt0::C17(r32, r33, _) => { - let v12 = (*r32).clone(); - let v13 = (*r33).clone(); - let a20 = List::cons(Str::lit("(List Tuple"), List::cons(f4(v12), List::cons(f4(v13), List::cons(Str::lit(")"), List::::nil())))); + let a20 = List::cons(Str::lit("Tuple"), List::cons({ + let a18 = f2(v11); + let a19 = Str::lit(""); + join(a18, a19) + }, List::::nil())); let a21 = Str::lit(""); join(a20, a21) } - Adt0::C18(r34, _) => { - let v15 = (*r34).clone(); - let a22 = List::cons(Str::lit("(List "), List::cons(f0(v15), List::cons(Str::lit(")"), List::::nil()))); - let a23 = Str::lit(""); - join(a22, a23) - } - Adt0::C19(v17, r35) => { - let v18 = (*r35).clone(); - let a26 = List::cons(Str::lit("(Fn ("), List::cons({ - let a24 = f5(v17); - let a25 = Str::lit(" "); - join(a24, a25) - }, List::cons(Str::lit(") "), List::cons(f0(v18), List::cons(Str::lit(")"), List::::nil()))))); + Adt0::C17(v12) => { + let a26 = { + let a24 = List::cons(Str::lit("("), List::::nil()); + let a25 = List::cons({ + let a22 = f3(v12); + let a23 = Str::lit(" * "); + join(a22, a23) + }, List::cons(Str::lit(")"), List::::nil())); + append_list(a24, a25) + }; let a27 = Str::lit(""); join(a26, a27) } + Adt0::C18(r46, r47, _) => { + let v13 = (*r46).clone(); + let v14 = (*r47).clone(); + let a30 = { + let a28 = List::cons(Str::lit("(List Tuple"), List::cons(f4(v13), List::::nil())); + let a29 = List::cons(f4(v14), List::cons(Str::lit(")"), List::::nil())); + append_list(a28, a29) + }; + let a31 = Str::lit(""); + join(a30, a31) + } + Adt0::C19(r48, _) => { + let v16 = (*r48).clone(); + let a34 = { + let a32 = List::cons(Str::lit("(List "), List::::nil()); + let a33 = List::cons(f0(v16), List::cons(Str::lit(")"), List::::nil())); + append_list(a32, a33) + }; + let a35 = Str::lit(""); + join(a34, a35) + } + Adt0::C20(v18, r49) => { + let v19 = (*r49).clone(); + let a40 = { + let a38 = List::cons(Str::lit("(Fn ("), List::cons({ + let a36 = f5(v18); + let a37 = Str::lit(" "); + join(a36, a37) + }, List::::nil())); + let a39 = List::cons(Str::lit(") "), List::cons(f0(v19), List::cons(Str::lit(")"), List::::nil()))); + append_list(a38, a39) + }; + let a41 = Str::lit(""); + join(a40, a41) + } } } @@ -995,8 +1027,8 @@ pub fn f1() -> Str { } pub fn f2(v0: List) -> List { - let m36 = v0; - match m36.uncons() { + let m50 = v0; + match m50.uncons() { None => { List::::nil() } @@ -1007,8 +1039,8 @@ pub fn f2(v0: List) -> List { } pub fn f3(v0: List) -> List { - let m37 = v0; - match m37.uncons() { + let m51 = v0; + match m51.uncons() { None => { List::::nil() } @@ -1019,8 +1051,8 @@ pub fn f3(v0: List) -> List { } pub fn f4(v0: Adt0) -> Str { - let m38 = v0; - match m38 { + let m52 = v0; + match m52 { Adt0::C0 => { Str::lit("Unit") } @@ -1037,92 +1069,107 @@ pub fn f4(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f6() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { - Str::lit("FilePath") + Str::lit("ParseIntError") } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r61) => { - let v6 = (*r61).clone(); - let a39 = List::cons(Str::lit("Option"), List::cons(f4(v6), List::::nil())); - let a40 = Str::lit(""); - join(a39, a40) - } - Adt0::C13(r62, r63) => { - let v7 = (*r62).clone(); - let v8 = (*r63).clone(); - let a41 = List::cons(Str::lit("Result"), List::cons(f4(v7), List::cons(f4(v8), List::::nil()))); - let a42 = Str::lit(""); - join(a41, a42) - } - Adt0::C14(r64) => { - let v9 = (*r64).clone(); - let a43 = List::cons(Str::lit("List"), List::cons(f4(v9), List::::nil())); - let a44 = Str::lit(""); - join(a43, a44) - } - Adt0::C15(v10) => { - let a47 = List::cons(Str::lit("Tuple"), List::cons({ - let a45 = f6(v10); - let a46 = Str::lit(""); - join(a45, a46) - }, List::::nil())); - let a48 = Str::lit(""); - join(a47, a48) + Adt0::C11 => { + Str::lit("FilePath") } - Adt0::C16(v11) => { - let a51 = List::cons(Str::lit("Pair"), List::cons({ - let a49 = f7(v11); - let a50 = Str::lit(""); - join(a49, a50) - }, List::::nil())); - let a52 = Str::lit(""); - join(a51, a52) + Adt0::C12(v6) => { + v6 } - Adt0::C17(r65, r66, _) => { - let v12 = (*r65).clone(); - let v13 = (*r66).clone(); - let a53 = List::cons(Str::lit("ListTuple"), List::cons(f4(v12), List::cons(f4(v13), List::::nil()))); + Adt0::C13(r81) => { + let v7 = (*r81).clone(); + let a53 = List::cons(Str::lit("Option"), List::cons(f4(v7), List::::nil())); let a54 = Str::lit(""); join(a53, a54) } - Adt0::C18(r67, _) => { - let v15 = (*r67).clone(); - let a55 = List::cons(Str::lit("List"), List::cons(f4(v15), List::::nil())); - let a56 = Str::lit(""); - join(a55, a56) - } - Adt0::C19(v17, r68) => { - let v18 = (*r68).clone(); - let a59 = List::cons(Str::lit("Fn"), List::cons({ - let a57 = f8(v17); - let a58 = Str::lit(""); - join(a57, a58) - }, List::cons(Str::lit("To"), List::cons(f4(v18), List::::nil())))); + Adt0::C14(r82, r83) => { + let v8 = (*r82).clone(); + let v9 = (*r83).clone(); + let a57 = { + let a55 = List::cons(Str::lit("Result"), List::::nil()); + let a56 = List::cons(f4(v8), List::cons(f4(v9), List::::nil())); + append_list(a55, a56) + }; + let a58 = Str::lit(""); + join(a57, a58) + } + Adt0::C15(r84) => { + let v10 = (*r84).clone(); + let a59 = List::cons(Str::lit("List"), List::cons(f4(v10), List::::nil())); let a60 = Str::lit(""); join(a59, a60) } + Adt0::C16(v11) => { + let a63 = List::cons(Str::lit("Tuple"), List::cons({ + let a61 = f7(v11); + let a62 = Str::lit(""); + join(a61, a62) + }, List::::nil())); + let a64 = Str::lit(""); + join(a63, a64) + } + Adt0::C17(v12) => { + let a67 = List::cons(Str::lit("Pair"), List::cons({ + let a65 = f8(v12); + let a66 = Str::lit(""); + join(a65, a66) + }, List::::nil())); + let a68 = Str::lit(""); + join(a67, a68) + } + Adt0::C18(r85, r86, _) => { + let v13 = (*r85).clone(); + let v14 = (*r86).clone(); + let a71 = { + let a69 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a70 = List::cons(f4(v13), List::cons(f4(v14), List::::nil())); + append_list(a69, a70) + }; + let a72 = Str::lit(""); + join(a71, a72) + } + Adt0::C19(r87, _) => { + let v16 = (*r87).clone(); + let a73 = List::cons(Str::lit("List"), List::cons(f4(v16), List::::nil())); + let a74 = Str::lit(""); + join(a73, a74) + } + Adt0::C20(v18, r88) => { + let v19 = (*r88).clone(); + let a79 = { + let a77 = List::cons(Str::lit("Fn"), List::cons({ + let a75 = f9(v18); + let a76 = Str::lit(""); + join(a75, a76) + }, List::::nil())); + let a78 = List::cons(Str::lit("To"), List::cons(f4(v19), List::::nil())); + append_list(a77, a78) + }; + let a80 = Str::lit(""); + join(a79, a80) + } } } pub fn f5(v0: List) -> List { - let m69 = v0; - match m69.uncons() { + let m89 = v0; + match m89.uncons() { None => { List::::nil() } @@ -1132,38 +1179,42 @@ pub fn f5(v0: List) -> List { } } -pub fn f6(v0: List) -> List { - let m70 = v0; - match m70.uncons() { +pub fn f6() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f7(v0: List) -> List { + let m90 = v0; + match m90.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f4(v1), f6(v2)) + List::cons(f4(v1), f7(v2)) } } } -pub fn f7(v0: List) -> List { - let m71 = v0; - match m71.uncons() { +pub fn f8(v0: List) -> List { + let m91 = v0; + match m91.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f4(v1), f7(v2)) + List::cons(f4(v1), f8(v2)) } } } -pub fn f8(v0: List) -> List { - let m72 = v0; - match m72.uncons() { +pub fn f9(v0: List) -> List { + let m92 = v0; + match m92.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f4(v1), f8(v2)) + List::cons(f4(v1), f9(v2)) } } } diff --git a/crates/certified/roots/uorust_certified_ty_same.rs b/crates/certified/roots/uorust_certified_uorust_lift_ty_same.rs similarity index 82% rename from crates/certified/roots/uorust_certified_ty_same.rs rename to crates/certified/roots/uorust_certified_uorust_lift_ty_same.rs index a7d04e00..ff7b0d7d 100644 --- a/crates/certified/roots/uorust_certified_ty_same.rs +++ b/crates/certified/roots/uorust_certified_uorust_lift_ty_same.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -909,90 +910,121 @@ pub fn f1(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + Str::lit("Int") } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { + Str::lit("Nat") + } + Adt0::C10 => { let a4 = List::cons(f2(), List::cons(Str::lit("::ParseIntError"), List::::nil())); let a5 = Str::lit(""); join(a4, a5) } - Adt0::C10 => { + Adt0::C11 => { let a6 = List::cons(f2(), List::cons(Str::lit("::FilePath"), List::::nil())); let a7 = Str::lit(""); join(a6, a7) } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r30) => { - let v6 = (*r30).clone(); - let a8 = List::cons(Str::lit("(Option "), List::cons(f1(v6), List::cons(Str::lit(")"), List::::nil()))); - let a9 = Str::lit(""); - join(a8, a9) + Adt0::C12(v6) => { + v6 } - Adt0::C13(r31, r32) => { - let v7 = (*r31).clone(); - let v8 = (*r32).clone(); - let a10 = List::cons(Str::lit("(Result "), List::cons(f1(v7), List::cons(Str::lit(" "), List::cons(f1(v8), List::cons(Str::lit(")"), List::::nil()))))); + Adt0::C13(r44) => { + let v7 = (*r44).clone(); + let a10 = { + let a8 = List::cons(Str::lit("(Option "), List::::nil()); + let a9 = List::cons(f1(v7), List::cons(Str::lit(")"), List::::nil())); + append_list(a8, a9) + }; let a11 = Str::lit(""); join(a10, a11) } - Adt0::C14(r33) => { - let v9 = (*r33).clone(); - let a12 = List::cons(Str::lit("(List "), List::cons(f1(v9), List::cons(Str::lit(")"), List::::nil()))); - let a13 = Str::lit(""); - join(a12, a13) - } - Adt0::C15(v10) => { - let a16 = List::cons(Str::lit("Tuple"), List::cons({ - let a14 = f3(v10); - let a15 = Str::lit(""); - join(a14, a15) - }, List::::nil())); - let a17 = Str::lit(""); - join(a16, a17) + Adt0::C14(r45, r46) => { + let v8 = (*r45).clone(); + let v9 = (*r46).clone(); + let a14 = { + let a12 = List::cons(Str::lit("(Result "), List::cons(f1(v8), List::::nil())); + let a13 = List::cons(Str::lit(" "), List::cons(f1(v9), List::cons(Str::lit(")"), List::::nil()))); + append_list(a12, a13) + }; + let a15 = Str::lit(""); + join(a14, a15) + } + Adt0::C15(r47) => { + let v10 = (*r47).clone(); + let a18 = { + let a16 = List::cons(Str::lit("(List "), List::::nil()); + let a17 = List::cons(f1(v10), List::cons(Str::lit(")"), List::::nil())); + append_list(a16, a17) + }; + let a19 = Str::lit(""); + join(a18, a19) } Adt0::C16(v11) => { - let a20 = List::cons(Str::lit("("), List::cons({ - let a18 = f4(v11); - let a19 = Str::lit(" * "); - join(a18, a19) - }, List::cons(Str::lit(")"), List::::nil()))); - let a21 = Str::lit(""); - join(a20, a21) - } - Adt0::C17(r34, r35, _) => { - let v12 = (*r34).clone(); - let v13 = (*r35).clone(); - let a22 = List::cons(Str::lit("(List Tuple"), List::cons(f5(v12), List::cons(f5(v13), List::cons(Str::lit(")"), List::::nil())))); + let a22 = List::cons(Str::lit("Tuple"), List::cons({ + let a20 = f3(v11); + let a21 = Str::lit(""); + join(a20, a21) + }, List::::nil())); let a23 = Str::lit(""); join(a22, a23) } - Adt0::C18(r36, _) => { - let v15 = (*r36).clone(); - let a24 = List::cons(Str::lit("(List "), List::cons(f1(v15), List::cons(Str::lit(")"), List::::nil()))); - let a25 = Str::lit(""); - join(a24, a25) - } - Adt0::C19(v17, r37) => { - let v18 = (*r37).clone(); - let a28 = List::cons(Str::lit("(Fn ("), List::cons({ - let a26 = f6(v17); - let a27 = Str::lit(" "); - join(a26, a27) - }, List::cons(Str::lit(") "), List::cons(f1(v18), List::cons(Str::lit(")"), List::::nil()))))); + Adt0::C17(v12) => { + let a28 = { + let a26 = List::cons(Str::lit("("), List::::nil()); + let a27 = List::cons({ + let a24 = f4(v12); + let a25 = Str::lit(" * "); + join(a24, a25) + }, List::cons(Str::lit(")"), List::::nil())); + append_list(a26, a27) + }; let a29 = Str::lit(""); join(a28, a29) } + Adt0::C18(r48, r49, _) => { + let v13 = (*r48).clone(); + let v14 = (*r49).clone(); + let a32 = { + let a30 = List::cons(Str::lit("(List Tuple"), List::cons(f5(v13), List::::nil())); + let a31 = List::cons(f5(v14), List::cons(Str::lit(")"), List::::nil())); + append_list(a30, a31) + }; + let a33 = Str::lit(""); + join(a32, a33) + } + Adt0::C19(r50, _) => { + let v16 = (*r50).clone(); + let a36 = { + let a34 = List::cons(Str::lit("(List "), List::::nil()); + let a35 = List::cons(f1(v16), List::cons(Str::lit(")"), List::::nil())); + append_list(a34, a35) + }; + let a37 = Str::lit(""); + join(a36, a37) + } + Adt0::C20(v18, r51) => { + let v19 = (*r51).clone(); + let a42 = { + let a40 = List::cons(Str::lit("(Fn ("), List::cons({ + let a38 = f6(v18); + let a39 = Str::lit(" "); + join(a38, a39) + }, List::::nil())); + let a41 = List::cons(Str::lit(") "), List::cons(f1(v19), List::cons(Str::lit(")"), List::::nil()))); + append_list(a40, a41) + }; + let a43 = Str::lit(""); + join(a42, a43) + } } } @@ -1001,8 +1033,8 @@ pub fn f2() -> Str { } pub fn f3(v0: List) -> List { - let m38 = v0; - match m38.uncons() { + let m52 = v0; + match m52.uncons() { None => { List::::nil() } @@ -1013,8 +1045,8 @@ pub fn f3(v0: List) -> List { } pub fn f4(v0: List) -> List { - let m39 = v0; - match m39.uncons() { + let m53 = v0; + match m53.uncons() { None => { List::::nil() } @@ -1025,8 +1057,8 @@ pub fn f4(v0: List) -> List { } pub fn f5(v0: Adt0) -> Str { - let m40 = v0; - match m40 { + let m54 = v0; + match m54 { Adt0::C0 => { Str::lit("Unit") } @@ -1043,92 +1075,107 @@ pub fn f5(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f7() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { - Str::lit("FilePath") + Str::lit("ParseIntError") } - Adt0::C11(v5) => { - v5 - } - Adt0::C12(r63) => { - let v6 = (*r63).clone(); - let a41 = List::cons(Str::lit("Option"), List::cons(f5(v6), List::::nil())); - let a42 = Str::lit(""); - join(a41, a42) - } - Adt0::C13(r64, r65) => { - let v7 = (*r64).clone(); - let v8 = (*r65).clone(); - let a43 = List::cons(Str::lit("Result"), List::cons(f5(v7), List::cons(f5(v8), List::::nil()))); - let a44 = Str::lit(""); - join(a43, a44) - } - Adt0::C14(r66) => { - let v9 = (*r66).clone(); - let a45 = List::cons(Str::lit("List"), List::cons(f5(v9), List::::nil())); - let a46 = Str::lit(""); - join(a45, a46) - } - Adt0::C15(v10) => { - let a49 = List::cons(Str::lit("Tuple"), List::cons({ - let a47 = f7(v10); - let a48 = Str::lit(""); - join(a47, a48) - }, List::::nil())); - let a50 = Str::lit(""); - join(a49, a50) + Adt0::C11 => { + Str::lit("FilePath") } - Adt0::C16(v11) => { - let a53 = List::cons(Str::lit("Pair"), List::cons({ - let a51 = f8(v11); - let a52 = Str::lit(""); - join(a51, a52) - }, List::::nil())); - let a54 = Str::lit(""); - join(a53, a54) + Adt0::C12(v6) => { + v6 } - Adt0::C17(r67, r68, _) => { - let v12 = (*r67).clone(); - let v13 = (*r68).clone(); - let a55 = List::cons(Str::lit("ListTuple"), List::cons(f5(v12), List::cons(f5(v13), List::::nil()))); + Adt0::C13(r83) => { + let v7 = (*r83).clone(); + let a55 = List::cons(Str::lit("Option"), List::cons(f5(v7), List::::nil())); let a56 = Str::lit(""); join(a55, a56) } - Adt0::C18(r69, _) => { - let v15 = (*r69).clone(); - let a57 = List::cons(Str::lit("List"), List::cons(f5(v15), List::::nil())); - let a58 = Str::lit(""); - join(a57, a58) - } - Adt0::C19(v17, r70) => { - let v18 = (*r70).clone(); - let a61 = List::cons(Str::lit("Fn"), List::cons({ - let a59 = f9(v17); - let a60 = Str::lit(""); - join(a59, a60) - }, List::cons(Str::lit("To"), List::cons(f5(v18), List::::nil())))); + Adt0::C14(r84, r85) => { + let v8 = (*r84).clone(); + let v9 = (*r85).clone(); + let a59 = { + let a57 = List::cons(Str::lit("Result"), List::::nil()); + let a58 = List::cons(f5(v8), List::cons(f5(v9), List::::nil())); + append_list(a57, a58) + }; + let a60 = Str::lit(""); + join(a59, a60) + } + Adt0::C15(r86) => { + let v10 = (*r86).clone(); + let a61 = List::cons(Str::lit("List"), List::cons(f5(v10), List::::nil())); let a62 = Str::lit(""); join(a61, a62) } + Adt0::C16(v11) => { + let a65 = List::cons(Str::lit("Tuple"), List::cons({ + let a63 = f8(v11); + let a64 = Str::lit(""); + join(a63, a64) + }, List::::nil())); + let a66 = Str::lit(""); + join(a65, a66) + } + Adt0::C17(v12) => { + let a69 = List::cons(Str::lit("Pair"), List::cons({ + let a67 = f9(v12); + let a68 = Str::lit(""); + join(a67, a68) + }, List::::nil())); + let a70 = Str::lit(""); + join(a69, a70) + } + Adt0::C18(r87, r88, _) => { + let v13 = (*r87).clone(); + let v14 = (*r88).clone(); + let a73 = { + let a71 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a72 = List::cons(f5(v13), List::cons(f5(v14), List::::nil())); + append_list(a71, a72) + }; + let a74 = Str::lit(""); + join(a73, a74) + } + Adt0::C19(r89, _) => { + let v16 = (*r89).clone(); + let a75 = List::cons(Str::lit("List"), List::cons(f5(v16), List::::nil())); + let a76 = Str::lit(""); + join(a75, a76) + } + Adt0::C20(v18, r90) => { + let v19 = (*r90).clone(); + let a81 = { + let a79 = List::cons(Str::lit("Fn"), List::cons({ + let a77 = f10(v18); + let a78 = Str::lit(""); + join(a77, a78) + }, List::::nil())); + let a80 = List::cons(Str::lit("To"), List::cons(f5(v19), List::::nil())); + append_list(a79, a80) + }; + let a82 = Str::lit(""); + join(a81, a82) + } } } pub fn f6(v0: List) -> List { - let m71 = v0; - match m71.uncons() { + let m91 = v0; + match m91.uncons() { None => { List::::nil() } @@ -1138,38 +1185,42 @@ pub fn f6(v0: List) -> List { } } -pub fn f7(v0: List) -> List { - let m72 = v0; - match m72.uncons() { +pub fn f7() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f8(v0: List) -> List { + let m92 = v0; + match m92.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f7(v2)) + List::cons(f5(v1), f8(v2)) } } } -pub fn f8(v0: List) -> List { - let m73 = v0; - match m73.uncons() { +pub fn f9(v0: List) -> List { + let m93 = v0; + match m93.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f8(v2)) + List::cons(f5(v1), f9(v2)) } } } -pub fn f9(v0: List) -> List { - let m74 = v0; - match m74.uncons() { +pub fn f10(v0: List) -> List { + let m94 = v0; + match m94.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f5(v1), f9(v2)) + List::cons(f5(v1), f10(v2)) } } } diff --git a/crates/certified/roots/uorust_certified_ty_tag.rs b/crates/certified/roots/uorust_certified_uorust_lift_ty_tag.rs similarity index 90% rename from crates/certified/roots/uorust_certified_ty_tag.rs rename to crates/certified/roots/uorust_certified_uorust_lift_ty_tag.rs index 1ea8f8ad..61162aee 100644 --- a/crates/certified/roots/uorust_certified_ty_tag.rs +++ b/crates/certified/roots/uorust_certified_uorust_lift_ty_tag.rs @@ -863,20 +863,21 @@ pub enum Adt0 { C3(u64), C4(Adt1), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -903,121 +904,140 @@ pub fn f0(v0: Adt0) -> Str { Str::lit("Nat") } Adt0::C5(_) => { - Str::lit("Nat") + f1() } - Adt0::C6 => { - Str::lit("String") + Adt0::C6(_) => { + Str::lit("Nat") } Adt0::C7 => { Str::lit("String") } Adt0::C8 => { - Str::lit("Nat") + Str::lit("String") } Adt0::C9 => { - Str::lit("ParseIntError") + Str::lit("Nat") } Adt0::C10 => { + Str::lit("ParseIntError") + } + Adt0::C11 => { Str::lit("FilePath") } - Adt0::C11(v5) => { - v5 + Adt0::C12(v6) => { + v6 } - Adt0::C12(r24) => { - let v6 = (*r24).clone(); - let a2 = List::cons(Str::lit("Option"), List::cons(f0(v6), List::::nil())); + Adt0::C13(r30) => { + let v7 = (*r30).clone(); + let a2 = List::cons(Str::lit("Option"), List::cons(f0(v7), List::::nil())); let a3 = Str::lit(""); join(a2, a3) } - Adt0::C13(r25, r26) => { - let v7 = (*r25).clone(); - let v8 = (*r26).clone(); - let a4 = List::cons(Str::lit("Result"), List::cons(f0(v7), List::cons(f0(v8), List::::nil()))); - let a5 = Str::lit(""); - join(a4, a5) - } - Adt0::C14(r27) => { - let v9 = (*r27).clone(); - let a6 = List::cons(Str::lit("List"), List::cons(f0(v9), List::::nil())); + Adt0::C14(r31, r32) => { + let v8 = (*r31).clone(); + let v9 = (*r32).clone(); + let a6 = { + let a4 = List::cons(Str::lit("Result"), List::::nil()); + let a5 = List::cons(f0(v8), List::cons(f0(v9), List::::nil())); + append_list(a4, a5) + }; let a7 = Str::lit(""); join(a6, a7) } - Adt0::C15(v10) => { - let a10 = List::cons(Str::lit("Tuple"), List::cons({ - let a8 = f1(v10); - let a9 = Str::lit(""); - join(a8, a9) - }, List::::nil())); - let a11 = Str::lit(""); - join(a10, a11) + Adt0::C15(r33) => { + let v10 = (*r33).clone(); + let a8 = List::cons(Str::lit("List"), List::cons(f0(v10), List::::nil())); + let a9 = Str::lit(""); + join(a8, a9) } Adt0::C16(v11) => { - let a14 = List::cons(Str::lit("Pair"), List::cons({ - let a12 = f2(v11); - let a13 = Str::lit(""); - join(a12, a13) + let a12 = List::cons(Str::lit("Tuple"), List::cons({ + let a10 = f2(v11); + let a11 = Str::lit(""); + join(a10, a11) }, List::::nil())); - let a15 = Str::lit(""); - join(a14, a15) + let a13 = Str::lit(""); + join(a12, a13) } - Adt0::C17(r28, r29, _) => { - let v12 = (*r28).clone(); - let v13 = (*r29).clone(); - let a16 = List::cons(Str::lit("ListTuple"), List::cons(f0(v12), List::cons(f0(v13), List::::nil()))); + Adt0::C17(v12) => { + let a16 = List::cons(Str::lit("Pair"), List::cons({ + let a14 = f3(v12); + let a15 = Str::lit(""); + join(a14, a15) + }, List::::nil())); let a17 = Str::lit(""); join(a16, a17) } - Adt0::C18(r30, _) => { - let v15 = (*r30).clone(); - let a18 = List::cons(Str::lit("List"), List::cons(f0(v15), List::::nil())); - let a19 = Str::lit(""); - join(a18, a19) + Adt0::C18(r34, r35, _) => { + let v13 = (*r34).clone(); + let v14 = (*r35).clone(); + let a20 = { + let a18 = List::cons(Str::lit("ListTuple"), List::::nil()); + let a19 = List::cons(f0(v13), List::cons(f0(v14), List::::nil())); + append_list(a18, a19) + }; + let a21 = Str::lit(""); + join(a20, a21) } - Adt0::C19(v17, r31) => { - let v18 = (*r31).clone(); - let a22 = List::cons(Str::lit("Fn"), List::cons({ - let a20 = f3(v17); - let a21 = Str::lit(""); - join(a20, a21) - }, List::cons(Str::lit("To"), List::cons(f0(v18), List::::nil())))); + Adt0::C19(r36, _) => { + let v16 = (*r36).clone(); + let a22 = List::cons(Str::lit("List"), List::cons(f0(v16), List::::nil())); let a23 = Str::lit(""); join(a22, a23) } + Adt0::C20(v18, r37) => { + let v19 = (*r37).clone(); + let a28 = { + let a26 = List::cons(Str::lit("Fn"), List::cons({ + let a24 = f4(v18); + let a25 = Str::lit(""); + join(a24, a25) + }, List::::nil())); + let a27 = List::cons(Str::lit("To"), List::cons(f0(v19), List::::nil())); + append_list(a26, a27) + }; + let a29 = Str::lit(""); + join(a28, a29) + } } } -pub fn f1(v0: List) -> List { - let m32 = v0; - match m32.uncons() { +pub fn f1() -> Str { + Str::lit("LexLeanInt") +} + +pub fn f2(v0: List) -> List { + let m38 = v0; + match m38.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f0(v1), f1(v2)) + List::cons(f0(v1), f2(v2)) } } } -pub fn f2(v0: List) -> List { - let m33 = v0; - match m33.uncons() { +pub fn f3(v0: List) -> List { + let m39 = v0; + match m39.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f0(v1), f2(v2)) + List::cons(f0(v1), f3(v2)) } } } -pub fn f3(v0: List) -> List { - let m34 = v0; - match m34.uncons() { +pub fn f4(v0: List) -> List { + let m40 = v0; + match m40.uncons() { None => { List::::nil() } Some((v1, v2)) => { - List::cons(f0(v1), f3(v2)) + List::cons(f0(v1), f4(v2)) } } } diff --git a/crates/certified/roots/uorust_certified_uorust_mir_core_scope_registry.rs b/crates/certified/roots/uorust_certified_uorust_mir_core_scope_registry.rs index bd861f0a..2fc21ab0 100644 --- a/crates/certified/roots/uorust_certified_uorust_mir_core_scope_registry.rs +++ b/crates/certified/roots/uorust_certified_uorust_mir_core_scope_registry.rs @@ -862,13 +862,21 @@ pub enum Adt0 { pub fn f0(v0: Str, v1: Str) -> Adt0 { Adt0::C0(v0.clone(), false, { - let a1 = List::cons(v0.clone(), List::cons(Str::lit(" "), List::cons(v1.clone(), List::::nil()))); - let a2 = Str::lit(""); - join(a1, a2) - }, { - let a3 = List::cons(Str::lit("uorust crate "), List::cons(v0, List::cons(Str::lit("@"), List::cons(v1, List::::nil())))); + let a3 = { + let a1 = List::cons(v0.clone(), List::::nil()); + let a2 = List::cons(Str::lit(" "), List::cons(v1.clone(), List::::nil())); + append_list(a1, a2) + }; let a4 = Str::lit(""); join(a3, a4) + }, { + let a7 = { + let a5 = List::cons(Str::lit("uorust crate "), List::cons(v0, List::::nil())); + let a6 = List::cons(Str::lit("@"), List::cons(v1, List::::nil())); + append_list(a5, a6) + }; + let a8 = Str::lit(""); + join(a7, a8) }) } diff --git a/crates/certified/roots/uorust_certified_uorust_mir_layout_refusal_text.rs b/crates/certified/roots/uorust_certified_uorust_mir_layout_refusal_text.rs index 8c7ced67..c0dd5127 100644 --- a/crates/certified/roots/uorust_certified_uorust_mir_layout_refusal_text.rs +++ b/crates/certified/roots/uorust_certified_uorust_mir_layout_refusal_text.rs @@ -880,74 +880,102 @@ pub fn f0(v0: Adt0) -> R { let m1 = v0; match m1 { Adt0::C0(v1, v2) => { - let a2 = List::cons(Str::lit("`"), List::cons(v1, List::cons(Str::lit("` is not a number of bits in `"), List::cons(v2, List::cons(Str::lit("`"), List::::nil()))))); - let a3 = Str::lit(""); - Ok(join(a2, a3)) - } - Adt0::C1(v3) => { - let a4 = List::cons(Str::lit("a pointer without a size in `"), List::cons(v3, List::cons(Str::lit("`"), List::::nil()))); + let a4 = { + let a2 = List::cons(Str::lit("`"), List::cons(v1, List::::nil())); + let a3 = List::cons(Str::lit("` is not a number of bits in `"), List::cons(v2, List::cons(Str::lit("`"), List::::nil()))); + append_list(a2, a3) + }; let a5 = Str::lit(""); Ok(join(a4, a5)) } + Adt0::C1(v3) => { + let a8 = { + let a6 = List::cons(Str::lit("a pointer without a size in `"), List::::nil()); + let a7 = List::cons(v3, List::cons(Str::lit("`"), List::::nil())); + append_list(a6, a7) + }; + let a9 = Str::lit(""); + Ok(join(a8, a9)) + } Adt0::C2(v4) => { - let a6 = List::cons(Str::lit("a width without an alignment in `"), List::cons(v4, List::cons(Str::lit("`"), List::::nil()))); - let a7 = Str::lit(""); - Ok(join(a6, a7)) + let a12 = { + let a10 = List::cons(Str::lit("a width without an alignment in `"), List::::nil()); + let a11 = List::cons(v4, List::cons(Str::lit("`"), List::::nil())); + append_list(a10, a11) + }; + let a13 = Str::lit(""); + Ok(join(a12, a13)) } Adt0::C3 => { Ok(Str::lit("a data layout without its triple")) } Adt0::C4(v5) => { - let a8 = List::cons(Str::lit("the layout of "), List::cons(v5, List::cons(Str::lit(", with no data layout recorded for the target"), List::::nil()))); - let a9 = Str::lit(""); - Ok(join(a8, a9)) + let a16 = { + let a14 = List::cons(Str::lit("the layout of "), List::::nil()); + let a15 = List::cons(v5, List::cons(Str::lit(", with no data layout recorded for the target"), List::::nil())); + append_list(a14, a15) + }; + let a17 = Str::lit(""); + Ok(join(a16, a17)) } Adt0::C5(v6, v7) => { - let a10 = List::cons(Str::lit("the layout of "), List::cons(v6, List::cons(Str::lit(", which the data layout of "), List::cons(v7, List::cons(Str::lit(" does not state"), List::::nil()))))); - let a11 = Str::lit(""); - Ok(join(a10, a11)) + let a20 = { + let a18 = List::cons(Str::lit("the layout of "), List::cons(v6, List::::nil())); + let a19 = List::cons(Str::lit(", which the data layout of "), List::cons(v7, List::cons(Str::lit(" does not state"), List::::nil()))); + append_list(a18, a19) + }; + let a21 = Str::lit(""); + Ok(join(a20, a21)) } Adt0::C6(v8, v9) => { - let a14 = List::cons(Str::lit("the layout of "), List::cons(v8, List::cons(Str::lit(", which differs by target: "), List::cons({ - let a12 = f1(v9)?; - let a13 = Str::lit(", "); - join(a12, a13) - }, List::::nil())))); - let a15 = Str::lit(""); - Ok(join(a14, a15)) + let a26 = { + let a24 = List::cons(Str::lit("the layout of "), List::cons(v8, List::::nil())); + let a25 = List::cons(Str::lit(", which differs by target: "), List::cons({ + let a22 = f1(v9)?; + let a23 = Str::lit(", "); + join(a22, a23) + }, List::::nil())); + append_list(a24, a25) + }; + let a27 = Str::lit(""); + Ok(join(a26, a27)) } } } pub fn f1(v0: List) -> R> { - let m16 = v0; - match m16.uncons() { + let m28 = v0; + match m28.uncons() { None => { Ok(List::::nil()) } Some((v1, v2)) => { let v3: Str = match v1.clone() { - Adt1::C0(h17, _) => { - h17 + Adt1::C0(h29, _) => { + h29 } }; let v4: Adt2 = match v1 { - Adt1::C0(_, h18) => { - h18 + Adt1::C0(_, h30) => { + h30 } }; Ok(List::cons({ - let a21 = List::cons(Str::lit("size "), List::cons(f2(match v4.clone() { - Adt2::C0(h19, _) => { - h19 - } - })?, List::cons(Str::lit(" align "), List::cons(f2(match v4 { - Adt2::C0(_, h20) => { - h20 - } - })?, List::cons(Str::lit(" on "), List::cons(v3, List::::nil())))))); - let a22 = Str::lit(""); - join(a21, a22) + let a35 = { + let a33 = List::cons(Str::lit("size "), List::cons(f2(match v4.clone() { + Adt2::C0(h31, _) => { + h31 + } + })?, List::cons(Str::lit(" align "), List::::nil()))); + let a34 = List::cons(f2(match v4 { + Adt2::C0(_, h32) => { + h32 + } + })?, List::cons(Str::lit(" on "), List::cons(v3, List::::nil()))); + append_list(a33, a34) + }; + let a36 = Str::lit(""); + join(a35, a36) }, f1(v2)?)) } } @@ -955,84 +983,84 @@ pub fn f1(v0: List) -> R> { pub fn f2(v0: u64) -> R { Ok(f3({ - let a23 = v0; - let a24 = 1u64; - nat_add(a23, a24)? + let a37 = v0; + let a38 = 1u64; + nat_add(a37, a38)? }, v0)) } pub fn f3(v0: u64, v1: u64) -> Str { - let m25 = v0; - if m25 == 0 { + let m39 = v0; + if m39 == 0 { Str::lit("") } else { - let v2 = m25 - 1; - let a26 = v1; - let a27 = 10u64; - if nat_lt(a26, a27) { + let v2 = m39 - 1; + let a40 = v1; + let a41 = 10u64; + if nat_lt(a40, a41) { f4(v1) } else { - let a34 = List::cons(f3(v2, { - let a28 = v1; - let a29 = 10u64; - let a30 = 0u64; - nat_quot(a28, a29, a30) + let a48 = List::cons(f3(v2, { + let a42 = v1; + let a43 = 10u64; + let a44 = 0u64; + nat_quot(a42, a43, a44) }), List::cons(f4({ - let a31 = v1; - let a32 = 10u64; - let a33 = 0u64; - nat_rem(a31, a32, a33) + let a45 = v1; + let a46 = 10u64; + let a47 = 0u64; + nat_rem(a45, a46, a47) }), List::::nil())); - let a35 = Str::lit(""); - join(a34, a35) + let a49 = Str::lit(""); + join(a48, a49) } } } pub fn f4(v0: u64) -> Str { - let a36 = v0; - let a37 = 0u64; - if nat_eq(a36, a37) { + let a50 = v0; + let a51 = 0u64; + if nat_eq(a50, a51) { Str::lit("0") } else { - let a38 = v0; - let a39 = 1u64; - if nat_eq(a38, a39) { + let a52 = v0; + let a53 = 1u64; + if nat_eq(a52, a53) { Str::lit("1") } else { - let a40 = v0; - let a41 = 2u64; - if nat_eq(a40, a41) { + let a54 = v0; + let a55 = 2u64; + if nat_eq(a54, a55) { Str::lit("2") } else { - let a42 = v0; - let a43 = 3u64; - if nat_eq(a42, a43) { + let a56 = v0; + let a57 = 3u64; + if nat_eq(a56, a57) { Str::lit("3") } else { - let a44 = v0; - let a45 = 4u64; - if nat_eq(a44, a45) { + let a58 = v0; + let a59 = 4u64; + if nat_eq(a58, a59) { Str::lit("4") } else { - let a46 = v0; - let a47 = 5u64; - if nat_eq(a46, a47) { + let a60 = v0; + let a61 = 5u64; + if nat_eq(a60, a61) { Str::lit("5") } else { - let a48 = v0; - let a49 = 6u64; - if nat_eq(a48, a49) { + let a62 = v0; + let a63 = 6u64; + if nat_eq(a62, a63) { Str::lit("6") } else { - let a50 = v0; - let a51 = 7u64; - if nat_eq(a50, a51) { + let a64 = v0; + let a65 = 7u64; + if nat_eq(a64, a65) { Str::lit("7") } else { - let a52 = v0; - let a53 = 8u64; - if nat_eq(a52, a53) { + let a66 = v0; + let a67 = 8u64; + if nat_eq(a66, a67) { Str::lit("8") } else { Str::lit("9") diff --git a/crates/certified/roots/uorust_certified_uorust_sha256.rs b/crates/certified/roots/uorust_certified_uorust_sha256.rs deleted file mode 100644 index 6b8fc5aa..00000000 --- a/crates/certified/roots/uorust_certified_uorust_sha256.rs +++ /dev/null @@ -1,6458 +0,0 @@ -#![forbid(unsafe_code)] -use core::cmp::Ordering; - -use core::sync::atomic::{AtomicU64, Ordering as Memory}; - -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct Overflow; - -pub type R = Result; - -static WORK: AtomicU64 = AtomicU64::new(0); - -pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } - -pub fn work() -> u64 { WORK.load(Memory::Relaxed) } - -pub trait Same { - fn same(&self, other: &Self) -> bool; -} - -pub trait Key { - fn key(&self, other: &Self) -> Ordering; -} - -impl Same for bool { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for bool { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for u8 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for u8 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for u16 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for u16 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for u32 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for u32 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for u64 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for u64 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for i8 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for i8 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for i16 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for i16 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for i32 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for i32 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for i64 { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for i64 { - fn key(&self, other: &Self) -> Ordering { self.cmp(other) } -} - -impl Same for Ordering { - fn same(&self, other: &Self) -> bool { self == other } -} - -impl Key for (A, B) { - fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } -} - -pub fn equal(a: T, b: T) -> bool { a.same(&b) } - -pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } - -pub fn nat_add(p0: u64, p1: u64) -> R { - match u64::checked_add(p0, p1) { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } -} - -pub fn nat_sub(p0: u64, p1: u64) -> u64 { - u64::saturating_sub(p0, p1) -} - -pub fn nat_mul(p0: u64, p1: u64) -> R { - match u64::checked_mul(p0, p1) { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } -} - -pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { - u64::checked_div(p0, p1).unwrap_or(p2) -} - -pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { - u64::checked_rem(p0, p1).unwrap_or(p2) -} - -pub fn nat_eq(p0: u64, p1: u64) -> bool { - core::cmp::PartialEq::eq(&p0, &p1) -} - -pub fn nat_le(p0: u64, p1: u64) -> bool { - core::cmp::PartialOrd::le(&p0, &p1) -} - -pub fn nat_lt(p0: u64, p1: u64) -> bool { - core::cmp::PartialOrd::lt(&p0, &p1) -} - -pub fn nat_succ(p0: u64) -> R { - match u64::checked_add(p0, 1u64) { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } -} - -pub fn int_add(p0: i64, p1: i64) -> R { - match i64::checked_add(p0, p1) { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } -} - -pub fn int_sub(p0: i64, p1: i64) -> R { - match i64::checked_sub(p0, p1) { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } -} - -pub fn int_mul(p0: i64, p1: i64) -> R { - match i64::checked_mul(p0, p1) { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } -} - -pub fn int_neg(p0: i64) -> R { - match i64::checked_neg(p0) { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } -} - -pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { - { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { - Some(v0) => { - Ok(v0) - } - None => { - Err::(Overflow) - } - } } -} - -pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { - { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } -} - -pub fn bool_not(p0: bool) -> bool { - !p0 -} - -pub fn bool_and(p0: bool, p1: bool) -> bool { - if p0 { - p1 - } else { - false - } -} - -pub fn bool_or(p0: bool, p1: bool) -> bool { - if p0 { - true - } else { - p1 - } -} - -pub mod fixed_u8 { - pub fn checked_add(p0: u8, p1: u8) -> Option { - u8::checked_add(p0, p1) - } - - pub fn checked_sub(p0: u8, p1: u8) -> Option { - u8::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: u8, p1: u8) -> Option { - u8::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: u8, p1: u8) -> Option { - u8::checked_div(p0, p1) - } - - pub fn bit_and(p0: u8, p1: u8) -> u8 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: u8, p1: u8) -> u8 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: u8, p1: u8) -> u8 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: u8) -> u8 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: u8, p1: u32) -> Option { - u8::checked_shl(p0, p1) - } - - pub fn shift_right(p0: u8, p1: u32) -> Option { - u8::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - u8::try_from(p0).ok() - } -} - -pub mod fixed_u16 { - pub fn checked_add(p0: u16, p1: u16) -> Option { - u16::checked_add(p0, p1) - } - - pub fn checked_sub(p0: u16, p1: u16) -> Option { - u16::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: u16, p1: u16) -> Option { - u16::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: u16, p1: u16) -> Option { - u16::checked_div(p0, p1) - } - - pub fn bit_and(p0: u16, p1: u16) -> u16 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: u16, p1: u16) -> u16 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: u16, p1: u16) -> u16 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: u16) -> u16 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: u16, p1: u32) -> Option { - u16::checked_shl(p0, p1) - } - - pub fn shift_right(p0: u16, p1: u32) -> Option { - u16::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - u16::try_from(p0).ok() - } -} - -pub mod fixed_u32 { - pub fn checked_add(p0: u32, p1: u32) -> Option { - u32::checked_add(p0, p1) - } - - pub fn checked_sub(p0: u32, p1: u32) -> Option { - u32::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: u32, p1: u32) -> Option { - u32::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: u32, p1: u32) -> Option { - u32::checked_div(p0, p1) - } - - pub fn bit_and(p0: u32, p1: u32) -> u32 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: u32, p1: u32) -> u32 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: u32, p1: u32) -> u32 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: u32) -> u32 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: u32, p1: u32) -> Option { - u32::checked_shl(p0, p1) - } - - pub fn shift_right(p0: u32, p1: u32) -> Option { - u32::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - u32::try_from(p0).ok() - } -} - -pub mod fixed_u64 { - pub fn checked_add(p0: u64, p1: u64) -> Option { - u64::checked_add(p0, p1) - } - - pub fn checked_sub(p0: u64, p1: u64) -> Option { - u64::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: u64, p1: u64) -> Option { - u64::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: u64, p1: u64) -> Option { - u64::checked_div(p0, p1) - } - - pub fn bit_and(p0: u64, p1: u64) -> u64 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: u64, p1: u64) -> u64 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: u64, p1: u64) -> u64 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: u64) -> u64 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: u64, p1: u32) -> Option { - u64::checked_shl(p0, p1) - } - - pub fn shift_right(p0: u64, p1: u32) -> Option { - u64::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - u64::try_from(p0).ok() - } -} - -pub mod fixed_i8 { - pub fn checked_add(p0: i8, p1: i8) -> Option { - i8::checked_add(p0, p1) - } - - pub fn checked_sub(p0: i8, p1: i8) -> Option { - i8::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: i8, p1: i8) -> Option { - i8::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: i8, p1: i8) -> Option { - i8::checked_div(p0, p1) - } - - pub fn bit_and(p0: i8, p1: i8) -> i8 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: i8, p1: i8) -> i8 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: i8, p1: i8) -> i8 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: i8) -> i8 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: i8, p1: u32) -> Option { - i8::checked_shl(p0, p1) - } - - pub fn shift_right(p0: i8, p1: u32) -> Option { - i8::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - i8::try_from(p0).ok() - } -} - -pub fn checked_neg_i8(p0: i8) -> Option { - i8::checked_neg(p0) -} - -pub mod fixed_i16 { - pub fn checked_add(p0: i16, p1: i16) -> Option { - i16::checked_add(p0, p1) - } - - pub fn checked_sub(p0: i16, p1: i16) -> Option { - i16::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: i16, p1: i16) -> Option { - i16::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: i16, p1: i16) -> Option { - i16::checked_div(p0, p1) - } - - pub fn bit_and(p0: i16, p1: i16) -> i16 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: i16, p1: i16) -> i16 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: i16, p1: i16) -> i16 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: i16) -> i16 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: i16, p1: u32) -> Option { - i16::checked_shl(p0, p1) - } - - pub fn shift_right(p0: i16, p1: u32) -> Option { - i16::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - i16::try_from(p0).ok() - } -} - -pub fn checked_neg_i16(p0: i16) -> Option { - i16::checked_neg(p0) -} - -pub mod fixed_i32 { - pub fn checked_add(p0: i32, p1: i32) -> Option { - i32::checked_add(p0, p1) - } - - pub fn checked_sub(p0: i32, p1: i32) -> Option { - i32::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: i32, p1: i32) -> Option { - i32::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: i32, p1: i32) -> Option { - i32::checked_div(p0, p1) - } - - pub fn bit_and(p0: i32, p1: i32) -> i32 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: i32, p1: i32) -> i32 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: i32, p1: i32) -> i32 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: i32) -> i32 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: i32, p1: u32) -> Option { - i32::checked_shl(p0, p1) - } - - pub fn shift_right(p0: i32, p1: u32) -> Option { - i32::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - i32::try_from(p0).ok() - } -} - -pub fn checked_neg_i32(p0: i32) -> Option { - i32::checked_neg(p0) -} - -pub mod fixed_i64 { - pub fn checked_add(p0: i64, p1: i64) -> Option { - i64::checked_add(p0, p1) - } - - pub fn checked_sub(p0: i64, p1: i64) -> Option { - i64::checked_sub(p0, p1) - } - - pub fn checked_mul(p0: i64, p1: i64) -> Option { - i64::checked_mul(p0, p1) - } - - pub fn checked_quot(p0: i64, p1: i64) -> Option { - i64::checked_div(p0, p1) - } - - pub fn bit_and(p0: i64, p1: i64) -> i64 { - core::ops::BitAnd::bitand(p0, p1) - } - - pub fn bit_or(p0: i64, p1: i64) -> i64 { - core::ops::BitOr::bitor(p0, p1) - } - - pub fn bit_xor(p0: i64, p1: i64) -> i64 { - core::ops::BitXor::bitxor(p0, p1) - } - - pub fn bit_not(p0: i64) -> i64 { - core::ops::Not::not(p0) - } - - pub fn shift_left(p0: i64, p1: u32) -> Option { - i64::checked_shl(p0, p1) - } - - pub fn shift_right(p0: i64, p1: u32) -> Option { - i64::checked_shr(p0, p1) - } - - pub fn convert(p0: i128) -> Option { - i64::try_from(p0).ok() - } -} - -pub fn checked_neg_i64(p0: i64) -> Option { - i64::checked_neg(p0) -} -use core::str; - -use std::mem; - -use std::rc::Rc; - -#[derive(Clone)] -pub struct Str(Rc); - -impl Str { - pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } - pub fn text(&self) -> &str { &self.0 } - pub fn length(&self) -> u64 { chars(&self.0) } - pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } - pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } - pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } - pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } - pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } - pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } - pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } - pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } - pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } - pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } - pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } - pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } - pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } -} - -#[derive(Clone)] -pub struct Bytes(Rc<[u8]>); - -impl Bytes { - pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } - pub fn octets(&self) -> &[u8] { &self.0 } - pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } - pub fn length(&self) -> u64 { self.0.len() as u64 } - pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } - pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } - pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } - pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } -} - -pub struct Node { head: T, tail: List } - -pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } - -pub struct List(Repr); - -impl Clone for List { - fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } -} - -impl List { - fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } -} - -impl Drop for Node { - fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } -} - -impl List { - pub fn nil() -> Self { List(Repr::Nil) } - pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } - pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } - pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } - pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } - pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } - pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } - fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } - fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } -} - -pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } - -impl Same for Str { - fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } -} - -impl Same for Bytes { - fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } -} - -impl Key for Str { - fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } -} - -pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } - -pub fn append_list(p0: List, p1: List) -> List { - List::append(p0, p1) -} - -pub fn length_list(p0: List) -> u64 { - List::length(&p0) -} - -pub fn index_list(p0: List, p1: u64) -> Option { - List::index(&p0, p1) -} - -pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { - List::slice(&p0, p1, p2) -} - -pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { - Bytes::append(p0, p1) -} - -pub fn length_bytes(p0: Bytes) -> u64 { - Bytes::length(&p0) -} - -pub fn length_string(p0: Str) -> u64 { - Str::length(&p0) -} - -pub fn index_bytes(p0: Bytes, p1: u64) -> Option { - Bytes::index(&p0, p1) -} - -pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { - Bytes::slice(&p0, p1, p2) -} - -pub fn utf8_encode(p0: Str) -> Bytes { - Str::utf8_encode(&p0) -} - -pub fn utf8_decode(p0: Bytes) -> Option { - Bytes::utf8_decode(&p0) -} - -pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { - Bytes::compare(&p0, &p1) -} - -pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { - Str::split_exact(&p0, &p1, p2) -} - -pub fn join(p0: List, p1: Str) -> Str { - Str::join(p0, &p1) -} - -pub fn format_u8(p0: u8) -> Str { - Str::format_u8(p0) -} - -pub fn parse_u8(p0: Str) -> Option { - Str::parse_u8(&p0) -} - -pub fn format_u16(p0: u16) -> Str { - Str::format_u16(p0) -} - -pub fn parse_u16(p0: Str) -> Option { - Str::parse_u16(&p0) -} - -pub fn format_u32(p0: u32) -> Str { - Str::format_u32(p0) -} - -pub fn parse_u32(p0: Str) -> Option { - Str::parse_u32(&p0) -} - -pub fn format_u64(p0: u64) -> Str { - Str::format_u64(p0) -} - -pub fn parse_u64(p0: Str) -> Option { - Str::parse_u64(&p0) -} - -pub fn format_i8(p0: i8) -> Str { - Str::format_i8(p0) -} - -pub fn parse_i8(p0: Str) -> Option { - Str::parse_i8(&p0) -} - -pub fn format_i16(p0: i16) -> Str { - Str::format_i16(p0) -} - -pub fn parse_i16(p0: Str) -> Option { - Str::parse_i16(&p0) -} - -pub fn format_i32(p0: i32) -> Str { - Str::format_i32(p0) -} - -pub fn parse_i32(p0: Str) -> Option { - Str::parse_i32(&p0) -} - -pub fn format_i64(p0: i64) -> Str { - Str::format_i64(p0) -} - -pub fn parse_i64(p0: Str) -> Option { - Str::parse_i64(&p0) -} - -pub fn parse_int(p0: Str) -> R> { - match Str::parse_int(&p0) { - Some(v0) => { - Ok(v0) - } - None => { - Err::, Overflow>(Overflow) - } - } -} - -pub fn format_int(p0: i64) -> Str { - Str::format_i64(p0) -} - -#[derive(Clone)] -pub enum Adt0 { - C0(u32, u32, u32, u32, u32, u32, u32, u32), -} - -#[derive(Clone)] -pub enum Adt1 { - C0(Adt0, List, u64), -} - -pub fn f0(v0: List) -> R { - Ok(f1(f2(v0)?)) -} - -pub fn f1(v0: List) -> Str { - let m2 = { - let a1 = f3(v0); - utf8_decode(a1) - }; - match m2 { - None => { - Str::lit("") - } - Some(v1) => { - v1 - } - } -} - -pub fn f2(v0: List) -> R> { - let v1: Bytes = f4(f5(v0))?; - let v2: Bytes = f6(f7({ - let a4 = { - let a3 = v1.clone(); - length_bytes(a3) - }; - let a5 = f8(); - let a6 = 0u64; - nat_quot(a4, a5, a6) - }, f9(), v1, 0u64)?)?; - f10({ - let a7 = v2.clone(); - length_bytes(a7) - }, v2, 0u64) -} - -pub fn f3(v0: List) -> Bytes { - let m8 = v0; - match m8.uncons() { - None => { - Bytes::lit(&[]) - } - Some((v1, v2)) => { - let a17 = { - let a15 = f11({ - let a9 = v1; - let a10 = 16u64; - let a11 = 0u64; - nat_quot(a9, a10, a11) - }); - let a16 = f11({ - let a12 = v1; - let a13 = 16u64; - let a14 = 0u64; - nat_rem(a12, a13, a14) - }); - append_bytes(a15, a16) - }; - let a18 = f3(v2); - append_bytes(a17, a18) - } - } -} - -pub fn f4(v0: Bytes) -> R { - let v1: u64 = { - let a19 = v0.clone(); - length_bytes(a19) - }; - let v2: u64 = { - let a20 = f8(); - let a21 = f12(); - nat_sub(a20, a21) - }; - let v3: u64 = { - let a24 = { - let a22 = v1; - let a23 = 1u64; - nat_add(a22, a23)? - }; - let a25 = f8(); - let a26 = 0u64; - nat_rem(a24, a25, a26) - }; - let a41 = { - let a37 = { - let a27 = v0; - let a28 = Bytes::lit(&[0x80]); - append_bytes(a27, a28) - }; - let a38 = f13({ - let a29 = v3; - let a30 = v2; - if nat_le(a29, a30) { - let a31 = v2; - let a32 = v3; - nat_sub(a31, a32) - } else { - let a35 = { - let a33 = f8(); - let a34 = v2; - nat_add(a33, a34)? - }; - let a36 = v3; - nat_sub(a35, a36) - } - }); - append_bytes(a37, a38) - }; - let a42 = f14(f12(), { - let a39 = v1; - let a40 = 8u64; - nat_mul(a39, a40)? - }); - Ok(append_bytes(a41, a42)) -} - -pub fn f5(v0: List) -> Bytes { - let m43 = v0; - match m43.uncons() { - None => { - Bytes::lit(&[]) - } - Some((v1, v2)) => { - let a44 = f15(v1); - let a45 = f5(v2); - append_bytes(a44, a45) - } - } -} - -pub fn f6(v0: Adt0) -> R { - let a1588 = { - let a1395 = { - let a1202 = { - let a1009 = { - let a816 = { - let a623 = { - let a430 = { - let a237 = Bytes::lit(&[]); - let a238 = f14(4u64, { - let v1: u32 = match v0.clone() { - Adt0::C0(h46, _, _, _, _, _, _, _) => { - h46 - } - }; - let a235 = { - let a139 = { - let a91 = { - let a67 = { - let a55 = { - let a49 = { - let a47 = v1; - let a48 = 2147483648u32; - fixed_u32::bit_and(a47, a48) - }; - let a50 = 2147483648u32; - if equal(a49, a50) { - 2147483648u64 - } else { - 0u64 - } - }; - let a56 = { - let a53 = { - let a51 = v1; - let a52 = 1073741824u32; - fixed_u32::bit_and(a51, a52) - }; - let a54 = 1073741824u32; - if equal(a53, a54) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a55, a56)? - }; - let a68 = { - let a65 = { - let a59 = { - let a57 = v1; - let a58 = 536870912u32; - fixed_u32::bit_and(a57, a58) - }; - let a60 = 536870912u32; - if equal(a59, a60) { - 536870912u64 - } else { - 0u64 - } - }; - let a66 = { - let a63 = { - let a61 = v1; - let a62 = 268435456u32; - fixed_u32::bit_and(a61, a62) - }; - let a64 = 268435456u32; - if equal(a63, a64) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a65, a66)? - }; - nat_add(a67, a68)? - }; - let a92 = { - let a89 = { - let a77 = { - let a71 = { - let a69 = v1; - let a70 = 134217728u32; - fixed_u32::bit_and(a69, a70) - }; - let a72 = 134217728u32; - if equal(a71, a72) { - 134217728u64 - } else { - 0u64 - } - }; - let a78 = { - let a75 = { - let a73 = v1; - let a74 = 67108864u32; - fixed_u32::bit_and(a73, a74) - }; - let a76 = 67108864u32; - if equal(a75, a76) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a77, a78)? - }; - let a90 = { - let a87 = { - let a81 = { - let a79 = v1; - let a80 = 33554432u32; - fixed_u32::bit_and(a79, a80) - }; - let a82 = 33554432u32; - if equal(a81, a82) { - 33554432u64 - } else { - 0u64 - } - }; - let a88 = { - let a85 = { - let a83 = v1; - let a84 = 16777216u32; - fixed_u32::bit_and(a83, a84) - }; - let a86 = 16777216u32; - if equal(a85, a86) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a87, a88)? - }; - nat_add(a89, a90)? - }; - nat_add(a91, a92)? - }; - let a140 = { - let a137 = { - let a113 = { - let a101 = { - let a95 = { - let a93 = v1; - let a94 = 8388608u32; - fixed_u32::bit_and(a93, a94) - }; - let a96 = 8388608u32; - if equal(a95, a96) { - 8388608u64 - } else { - 0u64 - } - }; - let a102 = { - let a99 = { - let a97 = v1; - let a98 = 4194304u32; - fixed_u32::bit_and(a97, a98) - }; - let a100 = 4194304u32; - if equal(a99, a100) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a101, a102)? - }; - let a114 = { - let a111 = { - let a105 = { - let a103 = v1; - let a104 = 2097152u32; - fixed_u32::bit_and(a103, a104) - }; - let a106 = 2097152u32; - if equal(a105, a106) { - 2097152u64 - } else { - 0u64 - } - }; - let a112 = { - let a109 = { - let a107 = v1; - let a108 = 1048576u32; - fixed_u32::bit_and(a107, a108) - }; - let a110 = 1048576u32; - if equal(a109, a110) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a111, a112)? - }; - nat_add(a113, a114)? - }; - let a138 = { - let a135 = { - let a123 = { - let a117 = { - let a115 = v1; - let a116 = 524288u32; - fixed_u32::bit_and(a115, a116) - }; - let a118 = 524288u32; - if equal(a117, a118) { - 524288u64 - } else { - 0u64 - } - }; - let a124 = { - let a121 = { - let a119 = v1; - let a120 = 262144u32; - fixed_u32::bit_and(a119, a120) - }; - let a122 = 262144u32; - if equal(a121, a122) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a123, a124)? - }; - let a136 = { - let a133 = { - let a127 = { - let a125 = v1; - let a126 = 131072u32; - fixed_u32::bit_and(a125, a126) - }; - let a128 = 131072u32; - if equal(a127, a128) { - 131072u64 - } else { - 0u64 - } - }; - let a134 = { - let a131 = { - let a129 = v1; - let a130 = 65536u32; - fixed_u32::bit_and(a129, a130) - }; - let a132 = 65536u32; - if equal(a131, a132) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a133, a134)? - }; - nat_add(a135, a136)? - }; - nat_add(a137, a138)? - }; - nat_add(a139, a140)? - }; - let a236 = { - let a233 = { - let a185 = { - let a161 = { - let a149 = { - let a143 = { - let a141 = v1; - let a142 = 32768u32; - fixed_u32::bit_and(a141, a142) - }; - let a144 = 32768u32; - if equal(a143, a144) { - 32768u64 - } else { - 0u64 - } - }; - let a150 = { - let a147 = { - let a145 = v1; - let a146 = 16384u32; - fixed_u32::bit_and(a145, a146) - }; - let a148 = 16384u32; - if equal(a147, a148) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a149, a150)? - }; - let a162 = { - let a159 = { - let a153 = { - let a151 = v1; - let a152 = 8192u32; - fixed_u32::bit_and(a151, a152) - }; - let a154 = 8192u32; - if equal(a153, a154) { - 8192u64 - } else { - 0u64 - } - }; - let a160 = { - let a157 = { - let a155 = v1; - let a156 = 4096u32; - fixed_u32::bit_and(a155, a156) - }; - let a158 = 4096u32; - if equal(a157, a158) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a159, a160)? - }; - nat_add(a161, a162)? - }; - let a186 = { - let a183 = { - let a171 = { - let a165 = { - let a163 = v1; - let a164 = 2048u32; - fixed_u32::bit_and(a163, a164) - }; - let a166 = 2048u32; - if equal(a165, a166) { - 2048u64 - } else { - 0u64 - } - }; - let a172 = { - let a169 = { - let a167 = v1; - let a168 = 1024u32; - fixed_u32::bit_and(a167, a168) - }; - let a170 = 1024u32; - if equal(a169, a170) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a171, a172)? - }; - let a184 = { - let a181 = { - let a175 = { - let a173 = v1; - let a174 = 512u32; - fixed_u32::bit_and(a173, a174) - }; - let a176 = 512u32; - if equal(a175, a176) { - 512u64 - } else { - 0u64 - } - }; - let a182 = { - let a179 = { - let a177 = v1; - let a178 = 256u32; - fixed_u32::bit_and(a177, a178) - }; - let a180 = 256u32; - if equal(a179, a180) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a181, a182)? - }; - nat_add(a183, a184)? - }; - nat_add(a185, a186)? - }; - let a234 = { - let a231 = { - let a207 = { - let a195 = { - let a189 = { - let a187 = v1; - let a188 = 128u32; - fixed_u32::bit_and(a187, a188) - }; - let a190 = 128u32; - if equal(a189, a190) { - 128u64 - } else { - 0u64 - } - }; - let a196 = { - let a193 = { - let a191 = v1; - let a192 = 64u32; - fixed_u32::bit_and(a191, a192) - }; - let a194 = 64u32; - if equal(a193, a194) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a195, a196)? - }; - let a208 = { - let a205 = { - let a199 = { - let a197 = v1; - let a198 = 32u32; - fixed_u32::bit_and(a197, a198) - }; - let a200 = 32u32; - if equal(a199, a200) { - 32u64 - } else { - 0u64 - } - }; - let a206 = { - let a203 = { - let a201 = v1; - let a202 = 16u32; - fixed_u32::bit_and(a201, a202) - }; - let a204 = 16u32; - if equal(a203, a204) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a205, a206)? - }; - nat_add(a207, a208)? - }; - let a232 = { - let a229 = { - let a217 = { - let a211 = { - let a209 = v1; - let a210 = 8u32; - fixed_u32::bit_and(a209, a210) - }; - let a212 = 8u32; - if equal(a211, a212) { - 8u64 - } else { - 0u64 - } - }; - let a218 = { - let a215 = { - let a213 = v1; - let a214 = 4u32; - fixed_u32::bit_and(a213, a214) - }; - let a216 = 4u32; - if equal(a215, a216) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a217, a218)? - }; - let a230 = { - let a227 = { - let a221 = { - let a219 = v1; - let a220 = 2u32; - fixed_u32::bit_and(a219, a220) - }; - let a222 = 2u32; - if equal(a221, a222) { - 2u64 - } else { - 0u64 - } - }; - let a228 = { - let a225 = { - let a223 = v1; - let a224 = 1u32; - fixed_u32::bit_and(a223, a224) - }; - let a226 = 1u32; - if equal(a225, a226) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a227, a228)? - }; - nat_add(a229, a230)? - }; - nat_add(a231, a232)? - }; - nat_add(a233, a234)? - }; - nat_add(a235, a236)? - }); - append_bytes(a237, a238) - }; - let a431 = f14(4u64, { - let v2: u32 = match v0.clone() { - Adt0::C0(_, h239, _, _, _, _, _, _) => { - h239 - } - }; - let a428 = { - let a332 = { - let a284 = { - let a260 = { - let a248 = { - let a242 = { - let a240 = v2; - let a241 = 2147483648u32; - fixed_u32::bit_and(a240, a241) - }; - let a243 = 2147483648u32; - if equal(a242, a243) { - 2147483648u64 - } else { - 0u64 - } - }; - let a249 = { - let a246 = { - let a244 = v2; - let a245 = 1073741824u32; - fixed_u32::bit_and(a244, a245) - }; - let a247 = 1073741824u32; - if equal(a246, a247) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a248, a249)? - }; - let a261 = { - let a258 = { - let a252 = { - let a250 = v2; - let a251 = 536870912u32; - fixed_u32::bit_and(a250, a251) - }; - let a253 = 536870912u32; - if equal(a252, a253) { - 536870912u64 - } else { - 0u64 - } - }; - let a259 = { - let a256 = { - let a254 = v2; - let a255 = 268435456u32; - fixed_u32::bit_and(a254, a255) - }; - let a257 = 268435456u32; - if equal(a256, a257) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a258, a259)? - }; - nat_add(a260, a261)? - }; - let a285 = { - let a282 = { - let a270 = { - let a264 = { - let a262 = v2; - let a263 = 134217728u32; - fixed_u32::bit_and(a262, a263) - }; - let a265 = 134217728u32; - if equal(a264, a265) { - 134217728u64 - } else { - 0u64 - } - }; - let a271 = { - let a268 = { - let a266 = v2; - let a267 = 67108864u32; - fixed_u32::bit_and(a266, a267) - }; - let a269 = 67108864u32; - if equal(a268, a269) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a270, a271)? - }; - let a283 = { - let a280 = { - let a274 = { - let a272 = v2; - let a273 = 33554432u32; - fixed_u32::bit_and(a272, a273) - }; - let a275 = 33554432u32; - if equal(a274, a275) { - 33554432u64 - } else { - 0u64 - } - }; - let a281 = { - let a278 = { - let a276 = v2; - let a277 = 16777216u32; - fixed_u32::bit_and(a276, a277) - }; - let a279 = 16777216u32; - if equal(a278, a279) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a280, a281)? - }; - nat_add(a282, a283)? - }; - nat_add(a284, a285)? - }; - let a333 = { - let a330 = { - let a306 = { - let a294 = { - let a288 = { - let a286 = v2; - let a287 = 8388608u32; - fixed_u32::bit_and(a286, a287) - }; - let a289 = 8388608u32; - if equal(a288, a289) { - 8388608u64 - } else { - 0u64 - } - }; - let a295 = { - let a292 = { - let a290 = v2; - let a291 = 4194304u32; - fixed_u32::bit_and(a290, a291) - }; - let a293 = 4194304u32; - if equal(a292, a293) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a294, a295)? - }; - let a307 = { - let a304 = { - let a298 = { - let a296 = v2; - let a297 = 2097152u32; - fixed_u32::bit_and(a296, a297) - }; - let a299 = 2097152u32; - if equal(a298, a299) { - 2097152u64 - } else { - 0u64 - } - }; - let a305 = { - let a302 = { - let a300 = v2; - let a301 = 1048576u32; - fixed_u32::bit_and(a300, a301) - }; - let a303 = 1048576u32; - if equal(a302, a303) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a304, a305)? - }; - nat_add(a306, a307)? - }; - let a331 = { - let a328 = { - let a316 = { - let a310 = { - let a308 = v2; - let a309 = 524288u32; - fixed_u32::bit_and(a308, a309) - }; - let a311 = 524288u32; - if equal(a310, a311) { - 524288u64 - } else { - 0u64 - } - }; - let a317 = { - let a314 = { - let a312 = v2; - let a313 = 262144u32; - fixed_u32::bit_and(a312, a313) - }; - let a315 = 262144u32; - if equal(a314, a315) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a316, a317)? - }; - let a329 = { - let a326 = { - let a320 = { - let a318 = v2; - let a319 = 131072u32; - fixed_u32::bit_and(a318, a319) - }; - let a321 = 131072u32; - if equal(a320, a321) { - 131072u64 - } else { - 0u64 - } - }; - let a327 = { - let a324 = { - let a322 = v2; - let a323 = 65536u32; - fixed_u32::bit_and(a322, a323) - }; - let a325 = 65536u32; - if equal(a324, a325) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a326, a327)? - }; - nat_add(a328, a329)? - }; - nat_add(a330, a331)? - }; - nat_add(a332, a333)? - }; - let a429 = { - let a426 = { - let a378 = { - let a354 = { - let a342 = { - let a336 = { - let a334 = v2; - let a335 = 32768u32; - fixed_u32::bit_and(a334, a335) - }; - let a337 = 32768u32; - if equal(a336, a337) { - 32768u64 - } else { - 0u64 - } - }; - let a343 = { - let a340 = { - let a338 = v2; - let a339 = 16384u32; - fixed_u32::bit_and(a338, a339) - }; - let a341 = 16384u32; - if equal(a340, a341) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a342, a343)? - }; - let a355 = { - let a352 = { - let a346 = { - let a344 = v2; - let a345 = 8192u32; - fixed_u32::bit_and(a344, a345) - }; - let a347 = 8192u32; - if equal(a346, a347) { - 8192u64 - } else { - 0u64 - } - }; - let a353 = { - let a350 = { - let a348 = v2; - let a349 = 4096u32; - fixed_u32::bit_and(a348, a349) - }; - let a351 = 4096u32; - if equal(a350, a351) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a352, a353)? - }; - nat_add(a354, a355)? - }; - let a379 = { - let a376 = { - let a364 = { - let a358 = { - let a356 = v2; - let a357 = 2048u32; - fixed_u32::bit_and(a356, a357) - }; - let a359 = 2048u32; - if equal(a358, a359) { - 2048u64 - } else { - 0u64 - } - }; - let a365 = { - let a362 = { - let a360 = v2; - let a361 = 1024u32; - fixed_u32::bit_and(a360, a361) - }; - let a363 = 1024u32; - if equal(a362, a363) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a364, a365)? - }; - let a377 = { - let a374 = { - let a368 = { - let a366 = v2; - let a367 = 512u32; - fixed_u32::bit_and(a366, a367) - }; - let a369 = 512u32; - if equal(a368, a369) { - 512u64 - } else { - 0u64 - } - }; - let a375 = { - let a372 = { - let a370 = v2; - let a371 = 256u32; - fixed_u32::bit_and(a370, a371) - }; - let a373 = 256u32; - if equal(a372, a373) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a374, a375)? - }; - nat_add(a376, a377)? - }; - nat_add(a378, a379)? - }; - let a427 = { - let a424 = { - let a400 = { - let a388 = { - let a382 = { - let a380 = v2; - let a381 = 128u32; - fixed_u32::bit_and(a380, a381) - }; - let a383 = 128u32; - if equal(a382, a383) { - 128u64 - } else { - 0u64 - } - }; - let a389 = { - let a386 = { - let a384 = v2; - let a385 = 64u32; - fixed_u32::bit_and(a384, a385) - }; - let a387 = 64u32; - if equal(a386, a387) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a388, a389)? - }; - let a401 = { - let a398 = { - let a392 = { - let a390 = v2; - let a391 = 32u32; - fixed_u32::bit_and(a390, a391) - }; - let a393 = 32u32; - if equal(a392, a393) { - 32u64 - } else { - 0u64 - } - }; - let a399 = { - let a396 = { - let a394 = v2; - let a395 = 16u32; - fixed_u32::bit_and(a394, a395) - }; - let a397 = 16u32; - if equal(a396, a397) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a398, a399)? - }; - nat_add(a400, a401)? - }; - let a425 = { - let a422 = { - let a410 = { - let a404 = { - let a402 = v2; - let a403 = 8u32; - fixed_u32::bit_and(a402, a403) - }; - let a405 = 8u32; - if equal(a404, a405) { - 8u64 - } else { - 0u64 - } - }; - let a411 = { - let a408 = { - let a406 = v2; - let a407 = 4u32; - fixed_u32::bit_and(a406, a407) - }; - let a409 = 4u32; - if equal(a408, a409) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a410, a411)? - }; - let a423 = { - let a420 = { - let a414 = { - let a412 = v2; - let a413 = 2u32; - fixed_u32::bit_and(a412, a413) - }; - let a415 = 2u32; - if equal(a414, a415) { - 2u64 - } else { - 0u64 - } - }; - let a421 = { - let a418 = { - let a416 = v2; - let a417 = 1u32; - fixed_u32::bit_and(a416, a417) - }; - let a419 = 1u32; - if equal(a418, a419) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a420, a421)? - }; - nat_add(a422, a423)? - }; - nat_add(a424, a425)? - }; - nat_add(a426, a427)? - }; - nat_add(a428, a429)? - }); - append_bytes(a430, a431) - }; - let a624 = f14(4u64, { - let v3: u32 = match v0.clone() { - Adt0::C0(_, _, h432, _, _, _, _, _) => { - h432 - } - }; - let a621 = { - let a525 = { - let a477 = { - let a453 = { - let a441 = { - let a435 = { - let a433 = v3; - let a434 = 2147483648u32; - fixed_u32::bit_and(a433, a434) - }; - let a436 = 2147483648u32; - if equal(a435, a436) { - 2147483648u64 - } else { - 0u64 - } - }; - let a442 = { - let a439 = { - let a437 = v3; - let a438 = 1073741824u32; - fixed_u32::bit_and(a437, a438) - }; - let a440 = 1073741824u32; - if equal(a439, a440) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a441, a442)? - }; - let a454 = { - let a451 = { - let a445 = { - let a443 = v3; - let a444 = 536870912u32; - fixed_u32::bit_and(a443, a444) - }; - let a446 = 536870912u32; - if equal(a445, a446) { - 536870912u64 - } else { - 0u64 - } - }; - let a452 = { - let a449 = { - let a447 = v3; - let a448 = 268435456u32; - fixed_u32::bit_and(a447, a448) - }; - let a450 = 268435456u32; - if equal(a449, a450) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a451, a452)? - }; - nat_add(a453, a454)? - }; - let a478 = { - let a475 = { - let a463 = { - let a457 = { - let a455 = v3; - let a456 = 134217728u32; - fixed_u32::bit_and(a455, a456) - }; - let a458 = 134217728u32; - if equal(a457, a458) { - 134217728u64 - } else { - 0u64 - } - }; - let a464 = { - let a461 = { - let a459 = v3; - let a460 = 67108864u32; - fixed_u32::bit_and(a459, a460) - }; - let a462 = 67108864u32; - if equal(a461, a462) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a463, a464)? - }; - let a476 = { - let a473 = { - let a467 = { - let a465 = v3; - let a466 = 33554432u32; - fixed_u32::bit_and(a465, a466) - }; - let a468 = 33554432u32; - if equal(a467, a468) { - 33554432u64 - } else { - 0u64 - } - }; - let a474 = { - let a471 = { - let a469 = v3; - let a470 = 16777216u32; - fixed_u32::bit_and(a469, a470) - }; - let a472 = 16777216u32; - if equal(a471, a472) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a473, a474)? - }; - nat_add(a475, a476)? - }; - nat_add(a477, a478)? - }; - let a526 = { - let a523 = { - let a499 = { - let a487 = { - let a481 = { - let a479 = v3; - let a480 = 8388608u32; - fixed_u32::bit_and(a479, a480) - }; - let a482 = 8388608u32; - if equal(a481, a482) { - 8388608u64 - } else { - 0u64 - } - }; - let a488 = { - let a485 = { - let a483 = v3; - let a484 = 4194304u32; - fixed_u32::bit_and(a483, a484) - }; - let a486 = 4194304u32; - if equal(a485, a486) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a487, a488)? - }; - let a500 = { - let a497 = { - let a491 = { - let a489 = v3; - let a490 = 2097152u32; - fixed_u32::bit_and(a489, a490) - }; - let a492 = 2097152u32; - if equal(a491, a492) { - 2097152u64 - } else { - 0u64 - } - }; - let a498 = { - let a495 = { - let a493 = v3; - let a494 = 1048576u32; - fixed_u32::bit_and(a493, a494) - }; - let a496 = 1048576u32; - if equal(a495, a496) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a497, a498)? - }; - nat_add(a499, a500)? - }; - let a524 = { - let a521 = { - let a509 = { - let a503 = { - let a501 = v3; - let a502 = 524288u32; - fixed_u32::bit_and(a501, a502) - }; - let a504 = 524288u32; - if equal(a503, a504) { - 524288u64 - } else { - 0u64 - } - }; - let a510 = { - let a507 = { - let a505 = v3; - let a506 = 262144u32; - fixed_u32::bit_and(a505, a506) - }; - let a508 = 262144u32; - if equal(a507, a508) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a509, a510)? - }; - let a522 = { - let a519 = { - let a513 = { - let a511 = v3; - let a512 = 131072u32; - fixed_u32::bit_and(a511, a512) - }; - let a514 = 131072u32; - if equal(a513, a514) { - 131072u64 - } else { - 0u64 - } - }; - let a520 = { - let a517 = { - let a515 = v3; - let a516 = 65536u32; - fixed_u32::bit_and(a515, a516) - }; - let a518 = 65536u32; - if equal(a517, a518) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a519, a520)? - }; - nat_add(a521, a522)? - }; - nat_add(a523, a524)? - }; - nat_add(a525, a526)? - }; - let a622 = { - let a619 = { - let a571 = { - let a547 = { - let a535 = { - let a529 = { - let a527 = v3; - let a528 = 32768u32; - fixed_u32::bit_and(a527, a528) - }; - let a530 = 32768u32; - if equal(a529, a530) { - 32768u64 - } else { - 0u64 - } - }; - let a536 = { - let a533 = { - let a531 = v3; - let a532 = 16384u32; - fixed_u32::bit_and(a531, a532) - }; - let a534 = 16384u32; - if equal(a533, a534) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a535, a536)? - }; - let a548 = { - let a545 = { - let a539 = { - let a537 = v3; - let a538 = 8192u32; - fixed_u32::bit_and(a537, a538) - }; - let a540 = 8192u32; - if equal(a539, a540) { - 8192u64 - } else { - 0u64 - } - }; - let a546 = { - let a543 = { - let a541 = v3; - let a542 = 4096u32; - fixed_u32::bit_and(a541, a542) - }; - let a544 = 4096u32; - if equal(a543, a544) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a545, a546)? - }; - nat_add(a547, a548)? - }; - let a572 = { - let a569 = { - let a557 = { - let a551 = { - let a549 = v3; - let a550 = 2048u32; - fixed_u32::bit_and(a549, a550) - }; - let a552 = 2048u32; - if equal(a551, a552) { - 2048u64 - } else { - 0u64 - } - }; - let a558 = { - let a555 = { - let a553 = v3; - let a554 = 1024u32; - fixed_u32::bit_and(a553, a554) - }; - let a556 = 1024u32; - if equal(a555, a556) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a557, a558)? - }; - let a570 = { - let a567 = { - let a561 = { - let a559 = v3; - let a560 = 512u32; - fixed_u32::bit_and(a559, a560) - }; - let a562 = 512u32; - if equal(a561, a562) { - 512u64 - } else { - 0u64 - } - }; - let a568 = { - let a565 = { - let a563 = v3; - let a564 = 256u32; - fixed_u32::bit_and(a563, a564) - }; - let a566 = 256u32; - if equal(a565, a566) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a567, a568)? - }; - nat_add(a569, a570)? - }; - nat_add(a571, a572)? - }; - let a620 = { - let a617 = { - let a593 = { - let a581 = { - let a575 = { - let a573 = v3; - let a574 = 128u32; - fixed_u32::bit_and(a573, a574) - }; - let a576 = 128u32; - if equal(a575, a576) { - 128u64 - } else { - 0u64 - } - }; - let a582 = { - let a579 = { - let a577 = v3; - let a578 = 64u32; - fixed_u32::bit_and(a577, a578) - }; - let a580 = 64u32; - if equal(a579, a580) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a581, a582)? - }; - let a594 = { - let a591 = { - let a585 = { - let a583 = v3; - let a584 = 32u32; - fixed_u32::bit_and(a583, a584) - }; - let a586 = 32u32; - if equal(a585, a586) { - 32u64 - } else { - 0u64 - } - }; - let a592 = { - let a589 = { - let a587 = v3; - let a588 = 16u32; - fixed_u32::bit_and(a587, a588) - }; - let a590 = 16u32; - if equal(a589, a590) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a591, a592)? - }; - nat_add(a593, a594)? - }; - let a618 = { - let a615 = { - let a603 = { - let a597 = { - let a595 = v3; - let a596 = 8u32; - fixed_u32::bit_and(a595, a596) - }; - let a598 = 8u32; - if equal(a597, a598) { - 8u64 - } else { - 0u64 - } - }; - let a604 = { - let a601 = { - let a599 = v3; - let a600 = 4u32; - fixed_u32::bit_and(a599, a600) - }; - let a602 = 4u32; - if equal(a601, a602) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a603, a604)? - }; - let a616 = { - let a613 = { - let a607 = { - let a605 = v3; - let a606 = 2u32; - fixed_u32::bit_and(a605, a606) - }; - let a608 = 2u32; - if equal(a607, a608) { - 2u64 - } else { - 0u64 - } - }; - let a614 = { - let a611 = { - let a609 = v3; - let a610 = 1u32; - fixed_u32::bit_and(a609, a610) - }; - let a612 = 1u32; - if equal(a611, a612) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a613, a614)? - }; - nat_add(a615, a616)? - }; - nat_add(a617, a618)? - }; - nat_add(a619, a620)? - }; - nat_add(a621, a622)? - }); - append_bytes(a623, a624) - }; - let a817 = f14(4u64, { - let v4: u32 = match v0.clone() { - Adt0::C0(_, _, _, h625, _, _, _, _) => { - h625 - } - }; - let a814 = { - let a718 = { - let a670 = { - let a646 = { - let a634 = { - let a628 = { - let a626 = v4; - let a627 = 2147483648u32; - fixed_u32::bit_and(a626, a627) - }; - let a629 = 2147483648u32; - if equal(a628, a629) { - 2147483648u64 - } else { - 0u64 - } - }; - let a635 = { - let a632 = { - let a630 = v4; - let a631 = 1073741824u32; - fixed_u32::bit_and(a630, a631) - }; - let a633 = 1073741824u32; - if equal(a632, a633) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a634, a635)? - }; - let a647 = { - let a644 = { - let a638 = { - let a636 = v4; - let a637 = 536870912u32; - fixed_u32::bit_and(a636, a637) - }; - let a639 = 536870912u32; - if equal(a638, a639) { - 536870912u64 - } else { - 0u64 - } - }; - let a645 = { - let a642 = { - let a640 = v4; - let a641 = 268435456u32; - fixed_u32::bit_and(a640, a641) - }; - let a643 = 268435456u32; - if equal(a642, a643) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a644, a645)? - }; - nat_add(a646, a647)? - }; - let a671 = { - let a668 = { - let a656 = { - let a650 = { - let a648 = v4; - let a649 = 134217728u32; - fixed_u32::bit_and(a648, a649) - }; - let a651 = 134217728u32; - if equal(a650, a651) { - 134217728u64 - } else { - 0u64 - } - }; - let a657 = { - let a654 = { - let a652 = v4; - let a653 = 67108864u32; - fixed_u32::bit_and(a652, a653) - }; - let a655 = 67108864u32; - if equal(a654, a655) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a656, a657)? - }; - let a669 = { - let a666 = { - let a660 = { - let a658 = v4; - let a659 = 33554432u32; - fixed_u32::bit_and(a658, a659) - }; - let a661 = 33554432u32; - if equal(a660, a661) { - 33554432u64 - } else { - 0u64 - } - }; - let a667 = { - let a664 = { - let a662 = v4; - let a663 = 16777216u32; - fixed_u32::bit_and(a662, a663) - }; - let a665 = 16777216u32; - if equal(a664, a665) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a666, a667)? - }; - nat_add(a668, a669)? - }; - nat_add(a670, a671)? - }; - let a719 = { - let a716 = { - let a692 = { - let a680 = { - let a674 = { - let a672 = v4; - let a673 = 8388608u32; - fixed_u32::bit_and(a672, a673) - }; - let a675 = 8388608u32; - if equal(a674, a675) { - 8388608u64 - } else { - 0u64 - } - }; - let a681 = { - let a678 = { - let a676 = v4; - let a677 = 4194304u32; - fixed_u32::bit_and(a676, a677) - }; - let a679 = 4194304u32; - if equal(a678, a679) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a680, a681)? - }; - let a693 = { - let a690 = { - let a684 = { - let a682 = v4; - let a683 = 2097152u32; - fixed_u32::bit_and(a682, a683) - }; - let a685 = 2097152u32; - if equal(a684, a685) { - 2097152u64 - } else { - 0u64 - } - }; - let a691 = { - let a688 = { - let a686 = v4; - let a687 = 1048576u32; - fixed_u32::bit_and(a686, a687) - }; - let a689 = 1048576u32; - if equal(a688, a689) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a690, a691)? - }; - nat_add(a692, a693)? - }; - let a717 = { - let a714 = { - let a702 = { - let a696 = { - let a694 = v4; - let a695 = 524288u32; - fixed_u32::bit_and(a694, a695) - }; - let a697 = 524288u32; - if equal(a696, a697) { - 524288u64 - } else { - 0u64 - } - }; - let a703 = { - let a700 = { - let a698 = v4; - let a699 = 262144u32; - fixed_u32::bit_and(a698, a699) - }; - let a701 = 262144u32; - if equal(a700, a701) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a702, a703)? - }; - let a715 = { - let a712 = { - let a706 = { - let a704 = v4; - let a705 = 131072u32; - fixed_u32::bit_and(a704, a705) - }; - let a707 = 131072u32; - if equal(a706, a707) { - 131072u64 - } else { - 0u64 - } - }; - let a713 = { - let a710 = { - let a708 = v4; - let a709 = 65536u32; - fixed_u32::bit_and(a708, a709) - }; - let a711 = 65536u32; - if equal(a710, a711) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a712, a713)? - }; - nat_add(a714, a715)? - }; - nat_add(a716, a717)? - }; - nat_add(a718, a719)? - }; - let a815 = { - let a812 = { - let a764 = { - let a740 = { - let a728 = { - let a722 = { - let a720 = v4; - let a721 = 32768u32; - fixed_u32::bit_and(a720, a721) - }; - let a723 = 32768u32; - if equal(a722, a723) { - 32768u64 - } else { - 0u64 - } - }; - let a729 = { - let a726 = { - let a724 = v4; - let a725 = 16384u32; - fixed_u32::bit_and(a724, a725) - }; - let a727 = 16384u32; - if equal(a726, a727) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a728, a729)? - }; - let a741 = { - let a738 = { - let a732 = { - let a730 = v4; - let a731 = 8192u32; - fixed_u32::bit_and(a730, a731) - }; - let a733 = 8192u32; - if equal(a732, a733) { - 8192u64 - } else { - 0u64 - } - }; - let a739 = { - let a736 = { - let a734 = v4; - let a735 = 4096u32; - fixed_u32::bit_and(a734, a735) - }; - let a737 = 4096u32; - if equal(a736, a737) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a738, a739)? - }; - nat_add(a740, a741)? - }; - let a765 = { - let a762 = { - let a750 = { - let a744 = { - let a742 = v4; - let a743 = 2048u32; - fixed_u32::bit_and(a742, a743) - }; - let a745 = 2048u32; - if equal(a744, a745) { - 2048u64 - } else { - 0u64 - } - }; - let a751 = { - let a748 = { - let a746 = v4; - let a747 = 1024u32; - fixed_u32::bit_and(a746, a747) - }; - let a749 = 1024u32; - if equal(a748, a749) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a750, a751)? - }; - let a763 = { - let a760 = { - let a754 = { - let a752 = v4; - let a753 = 512u32; - fixed_u32::bit_and(a752, a753) - }; - let a755 = 512u32; - if equal(a754, a755) { - 512u64 - } else { - 0u64 - } - }; - let a761 = { - let a758 = { - let a756 = v4; - let a757 = 256u32; - fixed_u32::bit_and(a756, a757) - }; - let a759 = 256u32; - if equal(a758, a759) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a760, a761)? - }; - nat_add(a762, a763)? - }; - nat_add(a764, a765)? - }; - let a813 = { - let a810 = { - let a786 = { - let a774 = { - let a768 = { - let a766 = v4; - let a767 = 128u32; - fixed_u32::bit_and(a766, a767) - }; - let a769 = 128u32; - if equal(a768, a769) { - 128u64 - } else { - 0u64 - } - }; - let a775 = { - let a772 = { - let a770 = v4; - let a771 = 64u32; - fixed_u32::bit_and(a770, a771) - }; - let a773 = 64u32; - if equal(a772, a773) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a774, a775)? - }; - let a787 = { - let a784 = { - let a778 = { - let a776 = v4; - let a777 = 32u32; - fixed_u32::bit_and(a776, a777) - }; - let a779 = 32u32; - if equal(a778, a779) { - 32u64 - } else { - 0u64 - } - }; - let a785 = { - let a782 = { - let a780 = v4; - let a781 = 16u32; - fixed_u32::bit_and(a780, a781) - }; - let a783 = 16u32; - if equal(a782, a783) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a784, a785)? - }; - nat_add(a786, a787)? - }; - let a811 = { - let a808 = { - let a796 = { - let a790 = { - let a788 = v4; - let a789 = 8u32; - fixed_u32::bit_and(a788, a789) - }; - let a791 = 8u32; - if equal(a790, a791) { - 8u64 - } else { - 0u64 - } - }; - let a797 = { - let a794 = { - let a792 = v4; - let a793 = 4u32; - fixed_u32::bit_and(a792, a793) - }; - let a795 = 4u32; - if equal(a794, a795) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a796, a797)? - }; - let a809 = { - let a806 = { - let a800 = { - let a798 = v4; - let a799 = 2u32; - fixed_u32::bit_and(a798, a799) - }; - let a801 = 2u32; - if equal(a800, a801) { - 2u64 - } else { - 0u64 - } - }; - let a807 = { - let a804 = { - let a802 = v4; - let a803 = 1u32; - fixed_u32::bit_and(a802, a803) - }; - let a805 = 1u32; - if equal(a804, a805) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a806, a807)? - }; - nat_add(a808, a809)? - }; - nat_add(a810, a811)? - }; - nat_add(a812, a813)? - }; - nat_add(a814, a815)? - }); - append_bytes(a816, a817) - }; - let a1010 = f14(4u64, { - let v5: u32 = match v0.clone() { - Adt0::C0(_, _, _, _, h818, _, _, _) => { - h818 - } - }; - let a1007 = { - let a911 = { - let a863 = { - let a839 = { - let a827 = { - let a821 = { - let a819 = v5; - let a820 = 2147483648u32; - fixed_u32::bit_and(a819, a820) - }; - let a822 = 2147483648u32; - if equal(a821, a822) { - 2147483648u64 - } else { - 0u64 - } - }; - let a828 = { - let a825 = { - let a823 = v5; - let a824 = 1073741824u32; - fixed_u32::bit_and(a823, a824) - }; - let a826 = 1073741824u32; - if equal(a825, a826) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a827, a828)? - }; - let a840 = { - let a837 = { - let a831 = { - let a829 = v5; - let a830 = 536870912u32; - fixed_u32::bit_and(a829, a830) - }; - let a832 = 536870912u32; - if equal(a831, a832) { - 536870912u64 - } else { - 0u64 - } - }; - let a838 = { - let a835 = { - let a833 = v5; - let a834 = 268435456u32; - fixed_u32::bit_and(a833, a834) - }; - let a836 = 268435456u32; - if equal(a835, a836) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a837, a838)? - }; - nat_add(a839, a840)? - }; - let a864 = { - let a861 = { - let a849 = { - let a843 = { - let a841 = v5; - let a842 = 134217728u32; - fixed_u32::bit_and(a841, a842) - }; - let a844 = 134217728u32; - if equal(a843, a844) { - 134217728u64 - } else { - 0u64 - } - }; - let a850 = { - let a847 = { - let a845 = v5; - let a846 = 67108864u32; - fixed_u32::bit_and(a845, a846) - }; - let a848 = 67108864u32; - if equal(a847, a848) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a849, a850)? - }; - let a862 = { - let a859 = { - let a853 = { - let a851 = v5; - let a852 = 33554432u32; - fixed_u32::bit_and(a851, a852) - }; - let a854 = 33554432u32; - if equal(a853, a854) { - 33554432u64 - } else { - 0u64 - } - }; - let a860 = { - let a857 = { - let a855 = v5; - let a856 = 16777216u32; - fixed_u32::bit_and(a855, a856) - }; - let a858 = 16777216u32; - if equal(a857, a858) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a859, a860)? - }; - nat_add(a861, a862)? - }; - nat_add(a863, a864)? - }; - let a912 = { - let a909 = { - let a885 = { - let a873 = { - let a867 = { - let a865 = v5; - let a866 = 8388608u32; - fixed_u32::bit_and(a865, a866) - }; - let a868 = 8388608u32; - if equal(a867, a868) { - 8388608u64 - } else { - 0u64 - } - }; - let a874 = { - let a871 = { - let a869 = v5; - let a870 = 4194304u32; - fixed_u32::bit_and(a869, a870) - }; - let a872 = 4194304u32; - if equal(a871, a872) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a873, a874)? - }; - let a886 = { - let a883 = { - let a877 = { - let a875 = v5; - let a876 = 2097152u32; - fixed_u32::bit_and(a875, a876) - }; - let a878 = 2097152u32; - if equal(a877, a878) { - 2097152u64 - } else { - 0u64 - } - }; - let a884 = { - let a881 = { - let a879 = v5; - let a880 = 1048576u32; - fixed_u32::bit_and(a879, a880) - }; - let a882 = 1048576u32; - if equal(a881, a882) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a883, a884)? - }; - nat_add(a885, a886)? - }; - let a910 = { - let a907 = { - let a895 = { - let a889 = { - let a887 = v5; - let a888 = 524288u32; - fixed_u32::bit_and(a887, a888) - }; - let a890 = 524288u32; - if equal(a889, a890) { - 524288u64 - } else { - 0u64 - } - }; - let a896 = { - let a893 = { - let a891 = v5; - let a892 = 262144u32; - fixed_u32::bit_and(a891, a892) - }; - let a894 = 262144u32; - if equal(a893, a894) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a895, a896)? - }; - let a908 = { - let a905 = { - let a899 = { - let a897 = v5; - let a898 = 131072u32; - fixed_u32::bit_and(a897, a898) - }; - let a900 = 131072u32; - if equal(a899, a900) { - 131072u64 - } else { - 0u64 - } - }; - let a906 = { - let a903 = { - let a901 = v5; - let a902 = 65536u32; - fixed_u32::bit_and(a901, a902) - }; - let a904 = 65536u32; - if equal(a903, a904) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a905, a906)? - }; - nat_add(a907, a908)? - }; - nat_add(a909, a910)? - }; - nat_add(a911, a912)? - }; - let a1008 = { - let a1005 = { - let a957 = { - let a933 = { - let a921 = { - let a915 = { - let a913 = v5; - let a914 = 32768u32; - fixed_u32::bit_and(a913, a914) - }; - let a916 = 32768u32; - if equal(a915, a916) { - 32768u64 - } else { - 0u64 - } - }; - let a922 = { - let a919 = { - let a917 = v5; - let a918 = 16384u32; - fixed_u32::bit_and(a917, a918) - }; - let a920 = 16384u32; - if equal(a919, a920) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a921, a922)? - }; - let a934 = { - let a931 = { - let a925 = { - let a923 = v5; - let a924 = 8192u32; - fixed_u32::bit_and(a923, a924) - }; - let a926 = 8192u32; - if equal(a925, a926) { - 8192u64 - } else { - 0u64 - } - }; - let a932 = { - let a929 = { - let a927 = v5; - let a928 = 4096u32; - fixed_u32::bit_and(a927, a928) - }; - let a930 = 4096u32; - if equal(a929, a930) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a931, a932)? - }; - nat_add(a933, a934)? - }; - let a958 = { - let a955 = { - let a943 = { - let a937 = { - let a935 = v5; - let a936 = 2048u32; - fixed_u32::bit_and(a935, a936) - }; - let a938 = 2048u32; - if equal(a937, a938) { - 2048u64 - } else { - 0u64 - } - }; - let a944 = { - let a941 = { - let a939 = v5; - let a940 = 1024u32; - fixed_u32::bit_and(a939, a940) - }; - let a942 = 1024u32; - if equal(a941, a942) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a943, a944)? - }; - let a956 = { - let a953 = { - let a947 = { - let a945 = v5; - let a946 = 512u32; - fixed_u32::bit_and(a945, a946) - }; - let a948 = 512u32; - if equal(a947, a948) { - 512u64 - } else { - 0u64 - } - }; - let a954 = { - let a951 = { - let a949 = v5; - let a950 = 256u32; - fixed_u32::bit_and(a949, a950) - }; - let a952 = 256u32; - if equal(a951, a952) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a953, a954)? - }; - nat_add(a955, a956)? - }; - nat_add(a957, a958)? - }; - let a1006 = { - let a1003 = { - let a979 = { - let a967 = { - let a961 = { - let a959 = v5; - let a960 = 128u32; - fixed_u32::bit_and(a959, a960) - }; - let a962 = 128u32; - if equal(a961, a962) { - 128u64 - } else { - 0u64 - } - }; - let a968 = { - let a965 = { - let a963 = v5; - let a964 = 64u32; - fixed_u32::bit_and(a963, a964) - }; - let a966 = 64u32; - if equal(a965, a966) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a967, a968)? - }; - let a980 = { - let a977 = { - let a971 = { - let a969 = v5; - let a970 = 32u32; - fixed_u32::bit_and(a969, a970) - }; - let a972 = 32u32; - if equal(a971, a972) { - 32u64 - } else { - 0u64 - } - }; - let a978 = { - let a975 = { - let a973 = v5; - let a974 = 16u32; - fixed_u32::bit_and(a973, a974) - }; - let a976 = 16u32; - if equal(a975, a976) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a977, a978)? - }; - nat_add(a979, a980)? - }; - let a1004 = { - let a1001 = { - let a989 = { - let a983 = { - let a981 = v5; - let a982 = 8u32; - fixed_u32::bit_and(a981, a982) - }; - let a984 = 8u32; - if equal(a983, a984) { - 8u64 - } else { - 0u64 - } - }; - let a990 = { - let a987 = { - let a985 = v5; - let a986 = 4u32; - fixed_u32::bit_and(a985, a986) - }; - let a988 = 4u32; - if equal(a987, a988) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a989, a990)? - }; - let a1002 = { - let a999 = { - let a993 = { - let a991 = v5; - let a992 = 2u32; - fixed_u32::bit_and(a991, a992) - }; - let a994 = 2u32; - if equal(a993, a994) { - 2u64 - } else { - 0u64 - } - }; - let a1000 = { - let a997 = { - let a995 = v5; - let a996 = 1u32; - fixed_u32::bit_and(a995, a996) - }; - let a998 = 1u32; - if equal(a997, a998) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a999, a1000)? - }; - nat_add(a1001, a1002)? - }; - nat_add(a1003, a1004)? - }; - nat_add(a1005, a1006)? - }; - nat_add(a1007, a1008)? - }); - append_bytes(a1009, a1010) - }; - let a1203 = f14(4u64, { - let v6: u32 = match v0.clone() { - Adt0::C0(_, _, _, _, _, h1011, _, _) => { - h1011 - } - }; - let a1200 = { - let a1104 = { - let a1056 = { - let a1032 = { - let a1020 = { - let a1014 = { - let a1012 = v6; - let a1013 = 2147483648u32; - fixed_u32::bit_and(a1012, a1013) - }; - let a1015 = 2147483648u32; - if equal(a1014, a1015) { - 2147483648u64 - } else { - 0u64 - } - }; - let a1021 = { - let a1018 = { - let a1016 = v6; - let a1017 = 1073741824u32; - fixed_u32::bit_and(a1016, a1017) - }; - let a1019 = 1073741824u32; - if equal(a1018, a1019) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a1020, a1021)? - }; - let a1033 = { - let a1030 = { - let a1024 = { - let a1022 = v6; - let a1023 = 536870912u32; - fixed_u32::bit_and(a1022, a1023) - }; - let a1025 = 536870912u32; - if equal(a1024, a1025) { - 536870912u64 - } else { - 0u64 - } - }; - let a1031 = { - let a1028 = { - let a1026 = v6; - let a1027 = 268435456u32; - fixed_u32::bit_and(a1026, a1027) - }; - let a1029 = 268435456u32; - if equal(a1028, a1029) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a1030, a1031)? - }; - nat_add(a1032, a1033)? - }; - let a1057 = { - let a1054 = { - let a1042 = { - let a1036 = { - let a1034 = v6; - let a1035 = 134217728u32; - fixed_u32::bit_and(a1034, a1035) - }; - let a1037 = 134217728u32; - if equal(a1036, a1037) { - 134217728u64 - } else { - 0u64 - } - }; - let a1043 = { - let a1040 = { - let a1038 = v6; - let a1039 = 67108864u32; - fixed_u32::bit_and(a1038, a1039) - }; - let a1041 = 67108864u32; - if equal(a1040, a1041) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a1042, a1043)? - }; - let a1055 = { - let a1052 = { - let a1046 = { - let a1044 = v6; - let a1045 = 33554432u32; - fixed_u32::bit_and(a1044, a1045) - }; - let a1047 = 33554432u32; - if equal(a1046, a1047) { - 33554432u64 - } else { - 0u64 - } - }; - let a1053 = { - let a1050 = { - let a1048 = v6; - let a1049 = 16777216u32; - fixed_u32::bit_and(a1048, a1049) - }; - let a1051 = 16777216u32; - if equal(a1050, a1051) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a1052, a1053)? - }; - nat_add(a1054, a1055)? - }; - nat_add(a1056, a1057)? - }; - let a1105 = { - let a1102 = { - let a1078 = { - let a1066 = { - let a1060 = { - let a1058 = v6; - let a1059 = 8388608u32; - fixed_u32::bit_and(a1058, a1059) - }; - let a1061 = 8388608u32; - if equal(a1060, a1061) { - 8388608u64 - } else { - 0u64 - } - }; - let a1067 = { - let a1064 = { - let a1062 = v6; - let a1063 = 4194304u32; - fixed_u32::bit_and(a1062, a1063) - }; - let a1065 = 4194304u32; - if equal(a1064, a1065) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a1066, a1067)? - }; - let a1079 = { - let a1076 = { - let a1070 = { - let a1068 = v6; - let a1069 = 2097152u32; - fixed_u32::bit_and(a1068, a1069) - }; - let a1071 = 2097152u32; - if equal(a1070, a1071) { - 2097152u64 - } else { - 0u64 - } - }; - let a1077 = { - let a1074 = { - let a1072 = v6; - let a1073 = 1048576u32; - fixed_u32::bit_and(a1072, a1073) - }; - let a1075 = 1048576u32; - if equal(a1074, a1075) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a1076, a1077)? - }; - nat_add(a1078, a1079)? - }; - let a1103 = { - let a1100 = { - let a1088 = { - let a1082 = { - let a1080 = v6; - let a1081 = 524288u32; - fixed_u32::bit_and(a1080, a1081) - }; - let a1083 = 524288u32; - if equal(a1082, a1083) { - 524288u64 - } else { - 0u64 - } - }; - let a1089 = { - let a1086 = { - let a1084 = v6; - let a1085 = 262144u32; - fixed_u32::bit_and(a1084, a1085) - }; - let a1087 = 262144u32; - if equal(a1086, a1087) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a1088, a1089)? - }; - let a1101 = { - let a1098 = { - let a1092 = { - let a1090 = v6; - let a1091 = 131072u32; - fixed_u32::bit_and(a1090, a1091) - }; - let a1093 = 131072u32; - if equal(a1092, a1093) { - 131072u64 - } else { - 0u64 - } - }; - let a1099 = { - let a1096 = { - let a1094 = v6; - let a1095 = 65536u32; - fixed_u32::bit_and(a1094, a1095) - }; - let a1097 = 65536u32; - if equal(a1096, a1097) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a1098, a1099)? - }; - nat_add(a1100, a1101)? - }; - nat_add(a1102, a1103)? - }; - nat_add(a1104, a1105)? - }; - let a1201 = { - let a1198 = { - let a1150 = { - let a1126 = { - let a1114 = { - let a1108 = { - let a1106 = v6; - let a1107 = 32768u32; - fixed_u32::bit_and(a1106, a1107) - }; - let a1109 = 32768u32; - if equal(a1108, a1109) { - 32768u64 - } else { - 0u64 - } - }; - let a1115 = { - let a1112 = { - let a1110 = v6; - let a1111 = 16384u32; - fixed_u32::bit_and(a1110, a1111) - }; - let a1113 = 16384u32; - if equal(a1112, a1113) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a1114, a1115)? - }; - let a1127 = { - let a1124 = { - let a1118 = { - let a1116 = v6; - let a1117 = 8192u32; - fixed_u32::bit_and(a1116, a1117) - }; - let a1119 = 8192u32; - if equal(a1118, a1119) { - 8192u64 - } else { - 0u64 - } - }; - let a1125 = { - let a1122 = { - let a1120 = v6; - let a1121 = 4096u32; - fixed_u32::bit_and(a1120, a1121) - }; - let a1123 = 4096u32; - if equal(a1122, a1123) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a1124, a1125)? - }; - nat_add(a1126, a1127)? - }; - let a1151 = { - let a1148 = { - let a1136 = { - let a1130 = { - let a1128 = v6; - let a1129 = 2048u32; - fixed_u32::bit_and(a1128, a1129) - }; - let a1131 = 2048u32; - if equal(a1130, a1131) { - 2048u64 - } else { - 0u64 - } - }; - let a1137 = { - let a1134 = { - let a1132 = v6; - let a1133 = 1024u32; - fixed_u32::bit_and(a1132, a1133) - }; - let a1135 = 1024u32; - if equal(a1134, a1135) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a1136, a1137)? - }; - let a1149 = { - let a1146 = { - let a1140 = { - let a1138 = v6; - let a1139 = 512u32; - fixed_u32::bit_and(a1138, a1139) - }; - let a1141 = 512u32; - if equal(a1140, a1141) { - 512u64 - } else { - 0u64 - } - }; - let a1147 = { - let a1144 = { - let a1142 = v6; - let a1143 = 256u32; - fixed_u32::bit_and(a1142, a1143) - }; - let a1145 = 256u32; - if equal(a1144, a1145) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a1146, a1147)? - }; - nat_add(a1148, a1149)? - }; - nat_add(a1150, a1151)? - }; - let a1199 = { - let a1196 = { - let a1172 = { - let a1160 = { - let a1154 = { - let a1152 = v6; - let a1153 = 128u32; - fixed_u32::bit_and(a1152, a1153) - }; - let a1155 = 128u32; - if equal(a1154, a1155) { - 128u64 - } else { - 0u64 - } - }; - let a1161 = { - let a1158 = { - let a1156 = v6; - let a1157 = 64u32; - fixed_u32::bit_and(a1156, a1157) - }; - let a1159 = 64u32; - if equal(a1158, a1159) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a1160, a1161)? - }; - let a1173 = { - let a1170 = { - let a1164 = { - let a1162 = v6; - let a1163 = 32u32; - fixed_u32::bit_and(a1162, a1163) - }; - let a1165 = 32u32; - if equal(a1164, a1165) { - 32u64 - } else { - 0u64 - } - }; - let a1171 = { - let a1168 = { - let a1166 = v6; - let a1167 = 16u32; - fixed_u32::bit_and(a1166, a1167) - }; - let a1169 = 16u32; - if equal(a1168, a1169) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a1170, a1171)? - }; - nat_add(a1172, a1173)? - }; - let a1197 = { - let a1194 = { - let a1182 = { - let a1176 = { - let a1174 = v6; - let a1175 = 8u32; - fixed_u32::bit_and(a1174, a1175) - }; - let a1177 = 8u32; - if equal(a1176, a1177) { - 8u64 - } else { - 0u64 - } - }; - let a1183 = { - let a1180 = { - let a1178 = v6; - let a1179 = 4u32; - fixed_u32::bit_and(a1178, a1179) - }; - let a1181 = 4u32; - if equal(a1180, a1181) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a1182, a1183)? - }; - let a1195 = { - let a1192 = { - let a1186 = { - let a1184 = v6; - let a1185 = 2u32; - fixed_u32::bit_and(a1184, a1185) - }; - let a1187 = 2u32; - if equal(a1186, a1187) { - 2u64 - } else { - 0u64 - } - }; - let a1193 = { - let a1190 = { - let a1188 = v6; - let a1189 = 1u32; - fixed_u32::bit_and(a1188, a1189) - }; - let a1191 = 1u32; - if equal(a1190, a1191) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a1192, a1193)? - }; - nat_add(a1194, a1195)? - }; - nat_add(a1196, a1197)? - }; - nat_add(a1198, a1199)? - }; - nat_add(a1200, a1201)? - }); - append_bytes(a1202, a1203) - }; - let a1396 = f14(4u64, { - let v7: u32 = match v0.clone() { - Adt0::C0(_, _, _, _, _, _, h1204, _) => { - h1204 - } - }; - let a1393 = { - let a1297 = { - let a1249 = { - let a1225 = { - let a1213 = { - let a1207 = { - let a1205 = v7; - let a1206 = 2147483648u32; - fixed_u32::bit_and(a1205, a1206) - }; - let a1208 = 2147483648u32; - if equal(a1207, a1208) { - 2147483648u64 - } else { - 0u64 - } - }; - let a1214 = { - let a1211 = { - let a1209 = v7; - let a1210 = 1073741824u32; - fixed_u32::bit_and(a1209, a1210) - }; - let a1212 = 1073741824u32; - if equal(a1211, a1212) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a1213, a1214)? - }; - let a1226 = { - let a1223 = { - let a1217 = { - let a1215 = v7; - let a1216 = 536870912u32; - fixed_u32::bit_and(a1215, a1216) - }; - let a1218 = 536870912u32; - if equal(a1217, a1218) { - 536870912u64 - } else { - 0u64 - } - }; - let a1224 = { - let a1221 = { - let a1219 = v7; - let a1220 = 268435456u32; - fixed_u32::bit_and(a1219, a1220) - }; - let a1222 = 268435456u32; - if equal(a1221, a1222) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a1223, a1224)? - }; - nat_add(a1225, a1226)? - }; - let a1250 = { - let a1247 = { - let a1235 = { - let a1229 = { - let a1227 = v7; - let a1228 = 134217728u32; - fixed_u32::bit_and(a1227, a1228) - }; - let a1230 = 134217728u32; - if equal(a1229, a1230) { - 134217728u64 - } else { - 0u64 - } - }; - let a1236 = { - let a1233 = { - let a1231 = v7; - let a1232 = 67108864u32; - fixed_u32::bit_and(a1231, a1232) - }; - let a1234 = 67108864u32; - if equal(a1233, a1234) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a1235, a1236)? - }; - let a1248 = { - let a1245 = { - let a1239 = { - let a1237 = v7; - let a1238 = 33554432u32; - fixed_u32::bit_and(a1237, a1238) - }; - let a1240 = 33554432u32; - if equal(a1239, a1240) { - 33554432u64 - } else { - 0u64 - } - }; - let a1246 = { - let a1243 = { - let a1241 = v7; - let a1242 = 16777216u32; - fixed_u32::bit_and(a1241, a1242) - }; - let a1244 = 16777216u32; - if equal(a1243, a1244) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a1245, a1246)? - }; - nat_add(a1247, a1248)? - }; - nat_add(a1249, a1250)? - }; - let a1298 = { - let a1295 = { - let a1271 = { - let a1259 = { - let a1253 = { - let a1251 = v7; - let a1252 = 8388608u32; - fixed_u32::bit_and(a1251, a1252) - }; - let a1254 = 8388608u32; - if equal(a1253, a1254) { - 8388608u64 - } else { - 0u64 - } - }; - let a1260 = { - let a1257 = { - let a1255 = v7; - let a1256 = 4194304u32; - fixed_u32::bit_and(a1255, a1256) - }; - let a1258 = 4194304u32; - if equal(a1257, a1258) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a1259, a1260)? - }; - let a1272 = { - let a1269 = { - let a1263 = { - let a1261 = v7; - let a1262 = 2097152u32; - fixed_u32::bit_and(a1261, a1262) - }; - let a1264 = 2097152u32; - if equal(a1263, a1264) { - 2097152u64 - } else { - 0u64 - } - }; - let a1270 = { - let a1267 = { - let a1265 = v7; - let a1266 = 1048576u32; - fixed_u32::bit_and(a1265, a1266) - }; - let a1268 = 1048576u32; - if equal(a1267, a1268) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a1269, a1270)? - }; - nat_add(a1271, a1272)? - }; - let a1296 = { - let a1293 = { - let a1281 = { - let a1275 = { - let a1273 = v7; - let a1274 = 524288u32; - fixed_u32::bit_and(a1273, a1274) - }; - let a1276 = 524288u32; - if equal(a1275, a1276) { - 524288u64 - } else { - 0u64 - } - }; - let a1282 = { - let a1279 = { - let a1277 = v7; - let a1278 = 262144u32; - fixed_u32::bit_and(a1277, a1278) - }; - let a1280 = 262144u32; - if equal(a1279, a1280) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a1281, a1282)? - }; - let a1294 = { - let a1291 = { - let a1285 = { - let a1283 = v7; - let a1284 = 131072u32; - fixed_u32::bit_and(a1283, a1284) - }; - let a1286 = 131072u32; - if equal(a1285, a1286) { - 131072u64 - } else { - 0u64 - } - }; - let a1292 = { - let a1289 = { - let a1287 = v7; - let a1288 = 65536u32; - fixed_u32::bit_and(a1287, a1288) - }; - let a1290 = 65536u32; - if equal(a1289, a1290) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a1291, a1292)? - }; - nat_add(a1293, a1294)? - }; - nat_add(a1295, a1296)? - }; - nat_add(a1297, a1298)? - }; - let a1394 = { - let a1391 = { - let a1343 = { - let a1319 = { - let a1307 = { - let a1301 = { - let a1299 = v7; - let a1300 = 32768u32; - fixed_u32::bit_and(a1299, a1300) - }; - let a1302 = 32768u32; - if equal(a1301, a1302) { - 32768u64 - } else { - 0u64 - } - }; - let a1308 = { - let a1305 = { - let a1303 = v7; - let a1304 = 16384u32; - fixed_u32::bit_and(a1303, a1304) - }; - let a1306 = 16384u32; - if equal(a1305, a1306) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a1307, a1308)? - }; - let a1320 = { - let a1317 = { - let a1311 = { - let a1309 = v7; - let a1310 = 8192u32; - fixed_u32::bit_and(a1309, a1310) - }; - let a1312 = 8192u32; - if equal(a1311, a1312) { - 8192u64 - } else { - 0u64 - } - }; - let a1318 = { - let a1315 = { - let a1313 = v7; - let a1314 = 4096u32; - fixed_u32::bit_and(a1313, a1314) - }; - let a1316 = 4096u32; - if equal(a1315, a1316) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a1317, a1318)? - }; - nat_add(a1319, a1320)? - }; - let a1344 = { - let a1341 = { - let a1329 = { - let a1323 = { - let a1321 = v7; - let a1322 = 2048u32; - fixed_u32::bit_and(a1321, a1322) - }; - let a1324 = 2048u32; - if equal(a1323, a1324) { - 2048u64 - } else { - 0u64 - } - }; - let a1330 = { - let a1327 = { - let a1325 = v7; - let a1326 = 1024u32; - fixed_u32::bit_and(a1325, a1326) - }; - let a1328 = 1024u32; - if equal(a1327, a1328) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a1329, a1330)? - }; - let a1342 = { - let a1339 = { - let a1333 = { - let a1331 = v7; - let a1332 = 512u32; - fixed_u32::bit_and(a1331, a1332) - }; - let a1334 = 512u32; - if equal(a1333, a1334) { - 512u64 - } else { - 0u64 - } - }; - let a1340 = { - let a1337 = { - let a1335 = v7; - let a1336 = 256u32; - fixed_u32::bit_and(a1335, a1336) - }; - let a1338 = 256u32; - if equal(a1337, a1338) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a1339, a1340)? - }; - nat_add(a1341, a1342)? - }; - nat_add(a1343, a1344)? - }; - let a1392 = { - let a1389 = { - let a1365 = { - let a1353 = { - let a1347 = { - let a1345 = v7; - let a1346 = 128u32; - fixed_u32::bit_and(a1345, a1346) - }; - let a1348 = 128u32; - if equal(a1347, a1348) { - 128u64 - } else { - 0u64 - } - }; - let a1354 = { - let a1351 = { - let a1349 = v7; - let a1350 = 64u32; - fixed_u32::bit_and(a1349, a1350) - }; - let a1352 = 64u32; - if equal(a1351, a1352) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a1353, a1354)? - }; - let a1366 = { - let a1363 = { - let a1357 = { - let a1355 = v7; - let a1356 = 32u32; - fixed_u32::bit_and(a1355, a1356) - }; - let a1358 = 32u32; - if equal(a1357, a1358) { - 32u64 - } else { - 0u64 - } - }; - let a1364 = { - let a1361 = { - let a1359 = v7; - let a1360 = 16u32; - fixed_u32::bit_and(a1359, a1360) - }; - let a1362 = 16u32; - if equal(a1361, a1362) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a1363, a1364)? - }; - nat_add(a1365, a1366)? - }; - let a1390 = { - let a1387 = { - let a1375 = { - let a1369 = { - let a1367 = v7; - let a1368 = 8u32; - fixed_u32::bit_and(a1367, a1368) - }; - let a1370 = 8u32; - if equal(a1369, a1370) { - 8u64 - } else { - 0u64 - } - }; - let a1376 = { - let a1373 = { - let a1371 = v7; - let a1372 = 4u32; - fixed_u32::bit_and(a1371, a1372) - }; - let a1374 = 4u32; - if equal(a1373, a1374) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a1375, a1376)? - }; - let a1388 = { - let a1385 = { - let a1379 = { - let a1377 = v7; - let a1378 = 2u32; - fixed_u32::bit_and(a1377, a1378) - }; - let a1380 = 2u32; - if equal(a1379, a1380) { - 2u64 - } else { - 0u64 - } - }; - let a1386 = { - let a1383 = { - let a1381 = v7; - let a1382 = 1u32; - fixed_u32::bit_and(a1381, a1382) - }; - let a1384 = 1u32; - if equal(a1383, a1384) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a1385, a1386)? - }; - nat_add(a1387, a1388)? - }; - nat_add(a1389, a1390)? - }; - nat_add(a1391, a1392)? - }; - nat_add(a1393, a1394)? - }); - append_bytes(a1395, a1396) - }; - let a1589 = f14(4u64, { - let v8: u32 = match v0 { - Adt0::C0(_, _, _, _, _, _, _, h1397) => { - h1397 - } - }; - let a1586 = { - let a1490 = { - let a1442 = { - let a1418 = { - let a1406 = { - let a1400 = { - let a1398 = v8; - let a1399 = 2147483648u32; - fixed_u32::bit_and(a1398, a1399) - }; - let a1401 = 2147483648u32; - if equal(a1400, a1401) { - 2147483648u64 - } else { - 0u64 - } - }; - let a1407 = { - let a1404 = { - let a1402 = v8; - let a1403 = 1073741824u32; - fixed_u32::bit_and(a1402, a1403) - }; - let a1405 = 1073741824u32; - if equal(a1404, a1405) { - 1073741824u64 - } else { - 0u64 - } - }; - nat_add(a1406, a1407)? - }; - let a1419 = { - let a1416 = { - let a1410 = { - let a1408 = v8; - let a1409 = 536870912u32; - fixed_u32::bit_and(a1408, a1409) - }; - let a1411 = 536870912u32; - if equal(a1410, a1411) { - 536870912u64 - } else { - 0u64 - } - }; - let a1417 = { - let a1414 = { - let a1412 = v8; - let a1413 = 268435456u32; - fixed_u32::bit_and(a1412, a1413) - }; - let a1415 = 268435456u32; - if equal(a1414, a1415) { - 268435456u64 - } else { - 0u64 - } - }; - nat_add(a1416, a1417)? - }; - nat_add(a1418, a1419)? - }; - let a1443 = { - let a1440 = { - let a1428 = { - let a1422 = { - let a1420 = v8; - let a1421 = 134217728u32; - fixed_u32::bit_and(a1420, a1421) - }; - let a1423 = 134217728u32; - if equal(a1422, a1423) { - 134217728u64 - } else { - 0u64 - } - }; - let a1429 = { - let a1426 = { - let a1424 = v8; - let a1425 = 67108864u32; - fixed_u32::bit_and(a1424, a1425) - }; - let a1427 = 67108864u32; - if equal(a1426, a1427) { - 67108864u64 - } else { - 0u64 - } - }; - nat_add(a1428, a1429)? - }; - let a1441 = { - let a1438 = { - let a1432 = { - let a1430 = v8; - let a1431 = 33554432u32; - fixed_u32::bit_and(a1430, a1431) - }; - let a1433 = 33554432u32; - if equal(a1432, a1433) { - 33554432u64 - } else { - 0u64 - } - }; - let a1439 = { - let a1436 = { - let a1434 = v8; - let a1435 = 16777216u32; - fixed_u32::bit_and(a1434, a1435) - }; - let a1437 = 16777216u32; - if equal(a1436, a1437) { - 16777216u64 - } else { - 0u64 - } - }; - nat_add(a1438, a1439)? - }; - nat_add(a1440, a1441)? - }; - nat_add(a1442, a1443)? - }; - let a1491 = { - let a1488 = { - let a1464 = { - let a1452 = { - let a1446 = { - let a1444 = v8; - let a1445 = 8388608u32; - fixed_u32::bit_and(a1444, a1445) - }; - let a1447 = 8388608u32; - if equal(a1446, a1447) { - 8388608u64 - } else { - 0u64 - } - }; - let a1453 = { - let a1450 = { - let a1448 = v8; - let a1449 = 4194304u32; - fixed_u32::bit_and(a1448, a1449) - }; - let a1451 = 4194304u32; - if equal(a1450, a1451) { - 4194304u64 - } else { - 0u64 - } - }; - nat_add(a1452, a1453)? - }; - let a1465 = { - let a1462 = { - let a1456 = { - let a1454 = v8; - let a1455 = 2097152u32; - fixed_u32::bit_and(a1454, a1455) - }; - let a1457 = 2097152u32; - if equal(a1456, a1457) { - 2097152u64 - } else { - 0u64 - } - }; - let a1463 = { - let a1460 = { - let a1458 = v8; - let a1459 = 1048576u32; - fixed_u32::bit_and(a1458, a1459) - }; - let a1461 = 1048576u32; - if equal(a1460, a1461) { - 1048576u64 - } else { - 0u64 - } - }; - nat_add(a1462, a1463)? - }; - nat_add(a1464, a1465)? - }; - let a1489 = { - let a1486 = { - let a1474 = { - let a1468 = { - let a1466 = v8; - let a1467 = 524288u32; - fixed_u32::bit_and(a1466, a1467) - }; - let a1469 = 524288u32; - if equal(a1468, a1469) { - 524288u64 - } else { - 0u64 - } - }; - let a1475 = { - let a1472 = { - let a1470 = v8; - let a1471 = 262144u32; - fixed_u32::bit_and(a1470, a1471) - }; - let a1473 = 262144u32; - if equal(a1472, a1473) { - 262144u64 - } else { - 0u64 - } - }; - nat_add(a1474, a1475)? - }; - let a1487 = { - let a1484 = { - let a1478 = { - let a1476 = v8; - let a1477 = 131072u32; - fixed_u32::bit_and(a1476, a1477) - }; - let a1479 = 131072u32; - if equal(a1478, a1479) { - 131072u64 - } else { - 0u64 - } - }; - let a1485 = { - let a1482 = { - let a1480 = v8; - let a1481 = 65536u32; - fixed_u32::bit_and(a1480, a1481) - }; - let a1483 = 65536u32; - if equal(a1482, a1483) { - 65536u64 - } else { - 0u64 - } - }; - nat_add(a1484, a1485)? - }; - nat_add(a1486, a1487)? - }; - nat_add(a1488, a1489)? - }; - nat_add(a1490, a1491)? - }; - let a1587 = { - let a1584 = { - let a1536 = { - let a1512 = { - let a1500 = { - let a1494 = { - let a1492 = v8; - let a1493 = 32768u32; - fixed_u32::bit_and(a1492, a1493) - }; - let a1495 = 32768u32; - if equal(a1494, a1495) { - 32768u64 - } else { - 0u64 - } - }; - let a1501 = { - let a1498 = { - let a1496 = v8; - let a1497 = 16384u32; - fixed_u32::bit_and(a1496, a1497) - }; - let a1499 = 16384u32; - if equal(a1498, a1499) { - 16384u64 - } else { - 0u64 - } - }; - nat_add(a1500, a1501)? - }; - let a1513 = { - let a1510 = { - let a1504 = { - let a1502 = v8; - let a1503 = 8192u32; - fixed_u32::bit_and(a1502, a1503) - }; - let a1505 = 8192u32; - if equal(a1504, a1505) { - 8192u64 - } else { - 0u64 - } - }; - let a1511 = { - let a1508 = { - let a1506 = v8; - let a1507 = 4096u32; - fixed_u32::bit_and(a1506, a1507) - }; - let a1509 = 4096u32; - if equal(a1508, a1509) { - 4096u64 - } else { - 0u64 - } - }; - nat_add(a1510, a1511)? - }; - nat_add(a1512, a1513)? - }; - let a1537 = { - let a1534 = { - let a1522 = { - let a1516 = { - let a1514 = v8; - let a1515 = 2048u32; - fixed_u32::bit_and(a1514, a1515) - }; - let a1517 = 2048u32; - if equal(a1516, a1517) { - 2048u64 - } else { - 0u64 - } - }; - let a1523 = { - let a1520 = { - let a1518 = v8; - let a1519 = 1024u32; - fixed_u32::bit_and(a1518, a1519) - }; - let a1521 = 1024u32; - if equal(a1520, a1521) { - 1024u64 - } else { - 0u64 - } - }; - nat_add(a1522, a1523)? - }; - let a1535 = { - let a1532 = { - let a1526 = { - let a1524 = v8; - let a1525 = 512u32; - fixed_u32::bit_and(a1524, a1525) - }; - let a1527 = 512u32; - if equal(a1526, a1527) { - 512u64 - } else { - 0u64 - } - }; - let a1533 = { - let a1530 = { - let a1528 = v8; - let a1529 = 256u32; - fixed_u32::bit_and(a1528, a1529) - }; - let a1531 = 256u32; - if equal(a1530, a1531) { - 256u64 - } else { - 0u64 - } - }; - nat_add(a1532, a1533)? - }; - nat_add(a1534, a1535)? - }; - nat_add(a1536, a1537)? - }; - let a1585 = { - let a1582 = { - let a1558 = { - let a1546 = { - let a1540 = { - let a1538 = v8; - let a1539 = 128u32; - fixed_u32::bit_and(a1538, a1539) - }; - let a1541 = 128u32; - if equal(a1540, a1541) { - 128u64 - } else { - 0u64 - } - }; - let a1547 = { - let a1544 = { - let a1542 = v8; - let a1543 = 64u32; - fixed_u32::bit_and(a1542, a1543) - }; - let a1545 = 64u32; - if equal(a1544, a1545) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a1546, a1547)? - }; - let a1559 = { - let a1556 = { - let a1550 = { - let a1548 = v8; - let a1549 = 32u32; - fixed_u32::bit_and(a1548, a1549) - }; - let a1551 = 32u32; - if equal(a1550, a1551) { - 32u64 - } else { - 0u64 - } - }; - let a1557 = { - let a1554 = { - let a1552 = v8; - let a1553 = 16u32; - fixed_u32::bit_and(a1552, a1553) - }; - let a1555 = 16u32; - if equal(a1554, a1555) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a1556, a1557)? - }; - nat_add(a1558, a1559)? - }; - let a1583 = { - let a1580 = { - let a1568 = { - let a1562 = { - let a1560 = v8; - let a1561 = 8u32; - fixed_u32::bit_and(a1560, a1561) - }; - let a1563 = 8u32; - if equal(a1562, a1563) { - 8u64 - } else { - 0u64 - } - }; - let a1569 = { - let a1566 = { - let a1564 = v8; - let a1565 = 4u32; - fixed_u32::bit_and(a1564, a1565) - }; - let a1567 = 4u32; - if equal(a1566, a1567) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a1568, a1569)? - }; - let a1581 = { - let a1578 = { - let a1572 = { - let a1570 = v8; - let a1571 = 2u32; - fixed_u32::bit_and(a1570, a1571) - }; - let a1573 = 2u32; - if equal(a1572, a1573) { - 2u64 - } else { - 0u64 - } - }; - let a1579 = { - let a1576 = { - let a1574 = v8; - let a1575 = 1u32; - fixed_u32::bit_and(a1574, a1575) - }; - let a1577 = 1u32; - if equal(a1576, a1577) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a1578, a1579)? - }; - nat_add(a1580, a1581)? - }; - nat_add(a1582, a1583)? - }; - nat_add(a1584, a1585)? - }; - nat_add(a1586, a1587)? - }); - Ok(append_bytes(a1588, a1589)) -} - -pub fn f7(p1594: u64, p1595: Adt0, v2: Bytes, p1596: u64) -> R { - let m1593 = (p1594, (p1595, p1596)); - { - let mut m1593 = m1593; - loop { - let step = { - let (v0, (v1, v3)) = m1593; - let m1590 = v0; - if m1590 == 0 { - Err::<(u64, (Adt0, u64)), R>(Ok(v1)) - } else { - let v4 = m1590 - 1; - Ok::<(u64, (Adt0, u64)), R>((v4, (f16(v1, v2.clone(), v3)?, { - let a1591 = v3; - let a1592 = f8(); - nat_add(a1591, a1592)? - }))) - } - }; - match step { - Ok(next) => { m1593 = next; } - Err(done) => break done, - } - } - } -} - -pub fn f8() -> u64 { - 64u64 -} - -pub fn f9() -> Adt0 { - Adt0::C0(1779033703u32, 3144134277u32, 1013904242u32, 2773480762u32, 1359893119u32, 2600822924u32, 528734635u32, 1541459225u32) -} - -pub fn f10(v0: u64, v1: Bytes, v2: u64) -> R> { - let m1597 = v0; - if m1597 == 0 { - Ok(List::::nil()) - } else { - let v3 = m1597 - 1; - let m1600 = { - let a1598 = v1.clone(); - let a1599 = v2; - index_bytes(a1598, a1599) - }; - match m1600 { - None => { - Ok(List::::nil()) - } - Some(v4) => { - Ok(List::cons({ - let v5: u8 = v4; - let a1645 = { - let a1621 = { - let a1609 = { - let a1603 = { - let a1601 = v5; - let a1602 = 128u8; - fixed_u8::bit_and(a1601, a1602) - }; - let a1604 = 128u8; - if equal(a1603, a1604) { - 128u64 - } else { - 0u64 - } - }; - let a1610 = { - let a1607 = { - let a1605 = v5; - let a1606 = 64u8; - fixed_u8::bit_and(a1605, a1606) - }; - let a1608 = 64u8; - if equal(a1607, a1608) { - 64u64 - } else { - 0u64 - } - }; - nat_add(a1609, a1610)? - }; - let a1622 = { - let a1619 = { - let a1613 = { - let a1611 = v5; - let a1612 = 32u8; - fixed_u8::bit_and(a1611, a1612) - }; - let a1614 = 32u8; - if equal(a1613, a1614) { - 32u64 - } else { - 0u64 - } - }; - let a1620 = { - let a1617 = { - let a1615 = v5; - let a1616 = 16u8; - fixed_u8::bit_and(a1615, a1616) - }; - let a1618 = 16u8; - if equal(a1617, a1618) { - 16u64 - } else { - 0u64 - } - }; - nat_add(a1619, a1620)? - }; - nat_add(a1621, a1622)? - }; - let a1646 = { - let a1643 = { - let a1631 = { - let a1625 = { - let a1623 = v5; - let a1624 = 8u8; - fixed_u8::bit_and(a1623, a1624) - }; - let a1626 = 8u8; - if equal(a1625, a1626) { - 8u64 - } else { - 0u64 - } - }; - let a1632 = { - let a1629 = { - let a1627 = v5; - let a1628 = 4u8; - fixed_u8::bit_and(a1627, a1628) - }; - let a1630 = 4u8; - if equal(a1629, a1630) { - 4u64 - } else { - 0u64 - } - }; - nat_add(a1631, a1632)? - }; - let a1644 = { - let a1641 = { - let a1635 = { - let a1633 = v5; - let a1634 = 2u8; - fixed_u8::bit_and(a1633, a1634) - }; - let a1636 = 2u8; - if equal(a1635, a1636) { - 2u64 - } else { - 0u64 - } - }; - let a1642 = { - let a1639 = { - let a1637 = v5; - let a1638 = 1u8; - fixed_u8::bit_and(a1637, a1638) - }; - let a1640 = 1u8; - if equal(a1639, a1640) { - 1u64 - } else { - 0u64 - } - }; - nat_add(a1641, a1642)? - }; - nat_add(a1643, a1644)? - }; - nat_add(a1645, a1646)? - }, f10(v3, v1, { - let a1647 = v2; - let a1648 = 1u64; - nat_add(a1647, a1648)? - })?)) - } - } - } -} - -pub fn f11(v0: u64) -> Bytes { - let m1652 = { - let a1649 = Bytes::lit(&[0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66]); - let a1650 = v0; - let a1651 = 1u64; - slice_bytes(a1649, a1650, a1651) - }; - match m1652 { - None => { - Bytes::lit(&[]) - } - Some(v1) => { - v1 - } - } -} - -pub fn f12() -> u64 { - 8u64 -} - -pub fn f13(v0: u64) -> Bytes { - let m1653 = v0; - if m1653 == 0 { - Bytes::lit(&[]) - } else { - let v1 = m1653 - 1; - let a1654 = Bytes::lit(&[0x00]); - let a1655 = f13(v1); - append_bytes(a1654, a1655) - } -} - -pub fn f14(v0: u64, v1: u64) -> Bytes { - let m1656 = v0; - if m1656 == 0 { - Bytes::lit(&[]) - } else { - let v2 = m1656 - 1; - let a1663 = f14(v2, { - let a1657 = v1; - let a1658 = 256u64; - let a1659 = 0u64; - nat_quot(a1657, a1658, a1659) - }); - let a1664 = f15({ - let a1660 = v1; - let a1661 = 256u64; - let a1662 = 0u64; - nat_rem(a1660, a1661, a1662) - }); - append_bytes(a1663, a1664) - } -} - -pub fn f15(v0: u64) -> Bytes { - let m1668 = { - let a1665 = Bytes::lit(&[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff]); - let a1666 = v0; - let a1667 = 1u64; - slice_bytes(a1665, a1666, a1667) - }; - match m1668 { - None => { - Bytes::lit(&[]) - } - Some(v1) => { - v1 - } - } -} - -pub fn f16(v0: Adt0, v1: Bytes, v2: u64) -> R { - let v3: Adt0 = { - let m1702 = f17(f18(), Adt1::C0(v0.clone(), List::cons(f19(v1.clone(), { - let a1670 = v2; - let a1671 = 0u64; - nat_add(a1670, a1671)? - })?, List::cons(f19(v1.clone(), { - let a1672 = v2; - let a1673 = 4u64; - nat_add(a1672, a1673)? - })?, List::cons(f19(v1.clone(), { - let a1674 = v2; - let a1675 = 8u64; - nat_add(a1674, a1675)? - })?, List::cons(f19(v1.clone(), { - let a1676 = v2; - let a1677 = 12u64; - nat_add(a1676, a1677)? - })?, List::cons(f19(v1.clone(), { - let a1678 = v2; - let a1679 = 16u64; - nat_add(a1678, a1679)? - })?, List::cons(f19(v1.clone(), { - let a1680 = v2; - let a1681 = 20u64; - nat_add(a1680, a1681)? - })?, List::cons(f19(v1.clone(), { - let a1682 = v2; - let a1683 = 24u64; - nat_add(a1682, a1683)? - })?, List::cons(f19(v1.clone(), { - let a1684 = v2; - let a1685 = 28u64; - nat_add(a1684, a1685)? - })?, List::cons(f19(v1.clone(), { - let a1686 = v2; - let a1687 = 32u64; - nat_add(a1686, a1687)? - })?, List::cons(f19(v1.clone(), { - let a1688 = v2; - let a1689 = 36u64; - nat_add(a1688, a1689)? - })?, List::cons(f19(v1.clone(), { - let a1690 = v2; - let a1691 = 40u64; - nat_add(a1690, a1691)? - })?, List::cons(f19(v1.clone(), { - let a1692 = v2; - let a1693 = 44u64; - nat_add(a1692, a1693)? - })?, List::cons(f19(v1.clone(), { - let a1694 = v2; - let a1695 = 48u64; - nat_add(a1694, a1695)? - })?, List::cons(f19(v1.clone(), { - let a1696 = v2; - let a1697 = 52u64; - nat_add(a1696, a1697)? - })?, List::cons(f19(v1.clone(), { - let a1698 = v2; - let a1699 = 56u64; - nat_add(a1698, a1699)? - })?, List::cons(f19(v1, { - let a1700 = v2; - let a1701 = 60u64; - nat_add(a1700, a1701)? - })?, List::::nil())))))))))))))))), 0u64))?; - match m1702 { - Adt1::C0(h1669, _, _) => { - h1669 - } - } - }; - Ok(Adt0::C0(f20(match v0.clone() { - Adt0::C0(h1703, _, _, _, _, _, _, _) => { - h1703 - } - }, match v3.clone() { - Adt0::C0(h1704, _, _, _, _, _, _, _) => { - h1704 - } - }), f20(match v0.clone() { - Adt0::C0(_, h1705, _, _, _, _, _, _) => { - h1705 - } - }, match v3.clone() { - Adt0::C0(_, h1706, _, _, _, _, _, _) => { - h1706 - } - }), f20(match v0.clone() { - Adt0::C0(_, _, h1707, _, _, _, _, _) => { - h1707 - } - }, match v3.clone() { - Adt0::C0(_, _, h1708, _, _, _, _, _) => { - h1708 - } - }), f20(match v0.clone() { - Adt0::C0(_, _, _, h1709, _, _, _, _) => { - h1709 - } - }, match v3.clone() { - Adt0::C0(_, _, _, h1710, _, _, _, _) => { - h1710 - } - }), f20(match v0.clone() { - Adt0::C0(_, _, _, _, h1711, _, _, _) => { - h1711 - } - }, match v3.clone() { - Adt0::C0(_, _, _, _, h1712, _, _, _) => { - h1712 - } - }), f20(match v0.clone() { - Adt0::C0(_, _, _, _, _, h1713, _, _) => { - h1713 - } - }, match v3.clone() { - Adt0::C0(_, _, _, _, _, h1714, _, _) => { - h1714 - } - }), f20(match v0.clone() { - Adt0::C0(_, _, _, _, _, _, h1715, _) => { - h1715 - } - }, match v3.clone() { - Adt0::C0(_, _, _, _, _, _, h1716, _) => { - h1716 - } - }), f20(match v0 { - Adt0::C0(_, _, _, _, _, _, _, h1717) => { - h1717 - } - }, match v3 { - Adt0::C0(_, _, _, _, _, _, _, h1718) => { - h1718 - } - }))) -} - -pub fn f17(p1721: List, p1722: Adt1) -> R { - let m1720 = (p1721, p1722); - { - let mut m1720 = m1720; - loop { - let step = { - let (v0, v1) = m1720; - let m1719 = v0; - match m1719.uncons() { - None => { - Err::<(List, Adt1), R>(Ok(v1)) - } - Some((v2, v3)) => { - Ok::<(List, Adt1), R>((v3, f21(v1, v2)?)) - } - } - }; - match step { - Ok(next) => { m1720 = next; } - Err(done) => break done, - } - } - } -} - -pub fn f18() -> List { - List::cons(1116352408u32, List::cons(1899447441u32, List::cons(3049323471u32, List::cons(3921009573u32, List::cons(961987163u32, List::cons(1508970993u32, List::cons(2453635748u32, List::cons(2870763221u32, List::cons(3624381080u32, List::cons(310598401u32, List::cons(607225278u32, List::cons(1426881987u32, List::cons(1925078388u32, List::cons(2162078206u32, List::cons(2614888103u32, List::cons(3248222580u32, List::cons(3835390401u32, List::cons(4022224774u32, List::cons(264347078u32, List::cons(604807628u32, List::cons(770255983u32, List::cons(1249150122u32, List::cons(1555081692u32, List::cons(1996064986u32, List::cons(2554220882u32, List::cons(2821834349u32, List::cons(2952996808u32, List::cons(3210313671u32, List::cons(3336571891u32, List::cons(3584528711u32, List::cons(113926993u32, List::cons(338241895u32, List::cons(666307205u32, List::cons(773529912u32, List::cons(1294757372u32, List::cons(1396182291u32, List::cons(1695183700u32, List::cons(1986661051u32, List::cons(2177026350u32, List::cons(2456956037u32, List::cons(2730485921u32, List::cons(2820302411u32, List::cons(3259730800u32, List::cons(3345764771u32, List::cons(3516065817u32, List::cons(3600352804u32, List::cons(4094571909u32, List::cons(275423344u32, List::cons(430227734u32, List::cons(506948616u32, List::cons(659060556u32, List::cons(883997877u32, List::cons(958139571u32, List::cons(1322822218u32, List::cons(1537002063u32, List::cons(1747873779u32, List::cons(1955562222u32, List::cons(2024104815u32, List::cons(2227730452u32, List::cons(2361852424u32, List::cons(2428436474u32, List::cons(2756734187u32, List::cons(3204031479u32, List::cons(3329325298u32, List::::nil())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) -} - -pub fn f19(v0: Bytes, v1: u64) -> R { - let a1754 = { - let a1737 = { - let m1728 = { - let a1726 = f22({ - let m1725 = { - let a1723 = v0.clone(); - let a1724 = v1; - index_bytes(a1723, a1724) - }; - match m1725 { - None => { - 0u8 - } - Some(v2) => { - v2 - } - } - }); - let a1727 = 24u32; - fixed_u32::shift_left(a1726, a1727) - }; - match m1728 { - None => { - 0u32 - } - Some(v3) => { - v3 - } - } - }; - let a1738 = { - let m1736 = { - let a1734 = f22({ - let m1733 = { - let a1731 = v0.clone(); - let a1732 = { - let a1729 = v1; - let a1730 = 1u64; - nat_add(a1729, a1730)? - }; - index_bytes(a1731, a1732) - }; - match m1733 { - None => { - 0u8 - } - Some(v4) => { - v4 - } - } - }); - let a1735 = 16u32; - fixed_u32::shift_left(a1734, a1735) - }; - match m1736 { - None => { - 0u32 - } - Some(v5) => { - v5 - } - } - }; - fixed_u32::bit_or(a1737, a1738) - }; - let a1755 = { - let a1752 = { - let m1746 = { - let a1744 = f22({ - let m1743 = { - let a1741 = v0.clone(); - let a1742 = { - let a1739 = v1; - let a1740 = 2u64; - nat_add(a1739, a1740)? - }; - index_bytes(a1741, a1742) - }; - match m1743 { - None => { - 0u8 - } - Some(v6) => { - v6 - } - } - }); - let a1745 = 8u32; - fixed_u32::shift_left(a1744, a1745) - }; - match m1746 { - None => { - 0u32 - } - Some(v7) => { - v7 - } - } - }; - let a1753 = f22({ - let m1751 = { - let a1749 = v0; - let a1750 = { - let a1747 = v1; - let a1748 = 3u64; - nat_add(a1747, a1748)? - }; - index_bytes(a1749, a1750) - }; - match m1751 { - None => { - 0u8 - } - Some(v8) => { - v8 - } - } - }); - fixed_u32::bit_or(a1752, a1753) - }; - Ok(fixed_u32::bit_or(a1754, a1755)) -} - -pub fn f20(v0: u32, v1: u32) -> u32 { - let m1758 = { - let a1756 = v0; - let a1757 = v1; - fixed_u32::checked_add(a1756, a1757) - }; - match m1758 { - None => { - f23(f23(v0, { - let a1759 = v1; - fixed_u32::bit_not(a1759) - }), 1u32) - } - Some(v2) => { - v2 - } - } -} - -pub fn f21(v0: Adt1, v1: u32) -> R { - Ok(Adt1::C0(f24(match v0.clone() { - Adt1::C0(h1760, _, _) => { - h1760 - } - }, f25(v0.clone())?, v1), f26(match v0.clone() { - Adt1::C0(_, h1761, _) => { - h1761 - } - }, { - let a1763 = match v0.clone() { - Adt1::C0(_, _, h1762) => { - h1762 - } - }; - let a1764 = 16u64; - let a1765 = 0u64; - nat_rem(a1763, a1764, a1765) - }, f25(v0.clone())?), { - let a1767 = match v0 { - Adt1::C0(_, _, h1766) => { - h1766 - } - }; - let a1768 = 1u64; - nat_add(a1767, a1768)? - })) -} - -pub fn f22(v0: u8) -> u32 { - let m1770 = { - let a1769 = v0; - fixed_u32::convert(i128::from(a1769)) - }; - match m1770 { - None => { - 0u32 - } - Some(v1) => { - v1 - } - } -} - -pub fn f23(v0: u32, v1: u32) -> u32 { - let m1773 = { - let a1771 = v0; - let a1772 = v1; - fixed_u32::checked_sub(a1771, a1772) - }; - match m1773 { - None => { - 0u32 - } - Some(v2) => { - v2 - } - } -} - -pub fn f24(v0: Adt0, v1: u32, v2: u32) -> Adt0 { - Adt0::C0(f20(f27(v0.clone(), v1, v2), f28(v0.clone())), match v0.clone() { - Adt0::C0(h1774, _, _, _, _, _, _, _) => { - h1774 - } - }, match v0.clone() { - Adt0::C0(_, h1775, _, _, _, _, _, _) => { - h1775 - } - }, match v0.clone() { - Adt0::C0(_, _, h1776, _, _, _, _, _) => { - h1776 - } - }, f20(match v0.clone() { - Adt0::C0(_, _, _, h1777, _, _, _, _) => { - h1777 - } - }, f27(v0.clone(), v1, v2)), match v0.clone() { - Adt0::C0(_, _, _, _, h1778, _, _, _) => { - h1778 - } - }, match v0.clone() { - Adt0::C0(_, _, _, _, _, h1779, _, _) => { - h1779 - } - }, match v0 { - Adt0::C0(_, _, _, _, _, _, h1780, _) => { - h1780 - } - }) -} - -pub fn f25(v0: Adt1) -> R { - let a1782 = match v0.clone() { - Adt1::C0(_, _, h1781) => { - h1781 - } - }; - let a1783 = 16u64; - if nat_lt(a1782, a1783) { - let m1788 = { - let a1786 = match v0.clone() { - Adt1::C0(_, h1784, _) => { - h1784 - } - }; - let a1787 = match v0 { - Adt1::C0(_, _, h1785) => { - h1785 - } - }; - index_list(a1786, a1787) - }; - match m1788 { - None => { - Ok(0u32) - } - Some(v1) => { - Ok(v1) - } - } - } else { - Ok(f20(f20(f20({ - let m1796 = { - let a1794 = match v0.clone() { - Adt1::C0(_, h1789, _) => { - h1789 - } - }; - let a1795 = { - let a1791 = match v0.clone() { - Adt1::C0(_, _, h1790) => { - h1790 - } - }; - let a1792 = 16u64; - let a1793 = 0u64; - nat_rem(a1791, a1792, a1793) - }; - index_list(a1794, a1795) - }; - match m1796 { - None => { - 0u32 - } - Some(v2) => { - v2 - } - } - }, f29({ - let m1806 = { - let a1804 = match v0.clone() { - Adt1::C0(_, h1797, _) => { - h1797 - } - }; - let a1805 = { - let a1801 = { - let a1799 = match v0.clone() { - Adt1::C0(_, _, h1798) => { - h1798 - } - }; - let a1800 = 1u64; - nat_add(a1799, a1800)? - }; - let a1802 = 16u64; - let a1803 = 0u64; - nat_rem(a1801, a1802, a1803) - }; - index_list(a1804, a1805) - }; - match m1806 { - None => { - 0u32 - } - Some(v3) => { - v3 - } - } - })), { - let m1816 = { - let a1814 = match v0.clone() { - Adt1::C0(_, h1807, _) => { - h1807 - } - }; - let a1815 = { - let a1811 = { - let a1809 = match v0.clone() { - Adt1::C0(_, _, h1808) => { - h1808 - } - }; - let a1810 = 9u64; - nat_add(a1809, a1810)? - }; - let a1812 = 16u64; - let a1813 = 0u64; - nat_rem(a1811, a1812, a1813) - }; - index_list(a1814, a1815) - }; - match m1816 { - None => { - 0u32 - } - Some(v4) => { - v4 - } - } - }), f30({ - let m1826 = { - let a1824 = match v0.clone() { - Adt1::C0(_, h1817, _) => { - h1817 - } - }; - let a1825 = { - let a1821 = { - let a1819 = match v0 { - Adt1::C0(_, _, h1818) => { - h1818 - } - }; - let a1820 = 14u64; - nat_add(a1819, a1820)? - }; - let a1822 = 16u64; - let a1823 = 0u64; - nat_rem(a1821, a1822, a1823) - }; - index_list(a1824, a1825) - }; - match m1826 { - None => { - 0u32 - } - Some(v5) => { - v5 - } - } - }))) - } -} - -pub fn f26(v0: List, v1: u64, v2: u32) -> List { - let m1827 = v0; - match m1827.uncons() { - None => { - List::::nil() - } - Some((v3, v4)) => { - List::cons({ - let a1828 = v1; - let a1829 = 0u64; - if nat_eq(a1828, a1829) { - v2 - } else { - v3 - } - }, { - let a1830 = v1; - let a1831 = 0u64; - if nat_eq(a1830, a1831) { - v4 - } else { - f26(v4, { - let a1832 = v1; - let a1833 = 1u64; - nat_sub(a1832, a1833) - }, v2) - } - }) - } - } -} - -pub fn f27(v0: Adt0, v1: u32, v2: u32) -> u32 { - f20(f20(f20(f20(match v0.clone() { - Adt0::C0(_, _, _, _, _, _, _, h1834) => { - h1834 - } - }, f31(match v0.clone() { - Adt0::C0(_, _, _, _, h1835, _, _, _) => { - h1835 - } - })), f32(match v0.clone() { - Adt0::C0(_, _, _, _, h1836, _, _, _) => { - h1836 - } - }, match v0.clone() { - Adt0::C0(_, _, _, _, _, h1837, _, _) => { - h1837 - } - }, match v0 { - Adt0::C0(_, _, _, _, _, _, h1838, _) => { - h1838 - } - })), v2), v1) -} - -pub fn f28(v0: Adt0) -> u32 { - f20(f33(match v0.clone() { - Adt0::C0(h1839, _, _, _, _, _, _, _) => { - h1839 - } - }), f34(match v0.clone() { - Adt0::C0(h1840, _, _, _, _, _, _, _) => { - h1840 - } - }, match v0.clone() { - Adt0::C0(_, h1841, _, _, _, _, _, _) => { - h1841 - } - }, match v0 { - Adt0::C0(_, _, h1842, _, _, _, _, _) => { - h1842 - } - })) -} - -pub fn f29(v0: u32) -> u32 { - let a1864 = { - let a1859 = { - let a1849 = { - let m1845 = { - let a1843 = v0; - let a1844 = 7u32; - fixed_u32::shift_right(a1843, a1844) - }; - match m1845 { - None => { - 0u32 - } - Some(v1) => { - v1 - } - } - }; - let a1850 = { - let m1848 = { - let a1846 = v0; - let a1847 = 25u32; - fixed_u32::shift_left(a1846, a1847) - }; - match m1848 { - None => { - 0u32 - } - Some(v2) => { - v2 - } - } - }; - fixed_u32::bit_or(a1849, a1850) - }; - let a1860 = { - let a1857 = { - let m1853 = { - let a1851 = v0; - let a1852 = 18u32; - fixed_u32::shift_right(a1851, a1852) - }; - match m1853 { - None => { - 0u32 - } - Some(v3) => { - v3 - } - } - }; - let a1858 = { - let m1856 = { - let a1854 = v0; - let a1855 = 14u32; - fixed_u32::shift_left(a1854, a1855) - }; - match m1856 { - None => { - 0u32 - } - Some(v4) => { - v4 - } - } - }; - fixed_u32::bit_or(a1857, a1858) - }; - fixed_u32::bit_xor(a1859, a1860) - }; - let a1865 = { - let m1863 = { - let a1861 = v0; - let a1862 = 3u32; - fixed_u32::shift_right(a1861, a1862) - }; - match m1863 { - None => { - 0u32 - } - Some(v5) => { - v5 - } - } - }; - fixed_u32::bit_xor(a1864, a1865) -} - -pub fn f30(v0: u32) -> u32 { - let a1887 = { - let a1882 = { - let a1872 = { - let m1868 = { - let a1866 = v0; - let a1867 = 17u32; - fixed_u32::shift_right(a1866, a1867) - }; - match m1868 { - None => { - 0u32 - } - Some(v1) => { - v1 - } - } - }; - let a1873 = { - let m1871 = { - let a1869 = v0; - let a1870 = 15u32; - fixed_u32::shift_left(a1869, a1870) - }; - match m1871 { - None => { - 0u32 - } - Some(v2) => { - v2 - } - } - }; - fixed_u32::bit_or(a1872, a1873) - }; - let a1883 = { - let a1880 = { - let m1876 = { - let a1874 = v0; - let a1875 = 19u32; - fixed_u32::shift_right(a1874, a1875) - }; - match m1876 { - None => { - 0u32 - } - Some(v3) => { - v3 - } - } - }; - let a1881 = { - let m1879 = { - let a1877 = v0; - let a1878 = 13u32; - fixed_u32::shift_left(a1877, a1878) - }; - match m1879 { - None => { - 0u32 - } - Some(v4) => { - v4 - } - } - }; - fixed_u32::bit_or(a1880, a1881) - }; - fixed_u32::bit_xor(a1882, a1883) - }; - let a1888 = { - let m1886 = { - let a1884 = v0; - let a1885 = 10u32; - fixed_u32::shift_right(a1884, a1885) - }; - match m1886 { - None => { - 0u32 - } - Some(v5) => { - v5 - } - } - }; - fixed_u32::bit_xor(a1887, a1888) -} - -pub fn f31(v0: u32) -> u32 { - let a1915 = { - let a1905 = { - let a1895 = { - let m1891 = { - let a1889 = v0; - let a1890 = 6u32; - fixed_u32::shift_right(a1889, a1890) - }; - match m1891 { - None => { - 0u32 - } - Some(v1) => { - v1 - } - } - }; - let a1896 = { - let m1894 = { - let a1892 = v0; - let a1893 = 26u32; - fixed_u32::shift_left(a1892, a1893) - }; - match m1894 { - None => { - 0u32 - } - Some(v2) => { - v2 - } - } - }; - fixed_u32::bit_or(a1895, a1896) - }; - let a1906 = { - let a1903 = { - let m1899 = { - let a1897 = v0; - let a1898 = 11u32; - fixed_u32::shift_right(a1897, a1898) - }; - match m1899 { - None => { - 0u32 - } - Some(v3) => { - v3 - } - } - }; - let a1904 = { - let m1902 = { - let a1900 = v0; - let a1901 = 21u32; - fixed_u32::shift_left(a1900, a1901) - }; - match m1902 { - None => { - 0u32 - } - Some(v4) => { - v4 - } - } - }; - fixed_u32::bit_or(a1903, a1904) - }; - fixed_u32::bit_xor(a1905, a1906) - }; - let a1916 = { - let a1913 = { - let m1909 = { - let a1907 = v0; - let a1908 = 25u32; - fixed_u32::shift_right(a1907, a1908) - }; - match m1909 { - None => { - 0u32 - } - Some(v5) => { - v5 - } - } - }; - let a1914 = { - let m1912 = { - let a1910 = v0; - let a1911 = 7u32; - fixed_u32::shift_left(a1910, a1911) - }; - match m1912 { - None => { - 0u32 - } - Some(v6) => { - v6 - } - } - }; - fixed_u32::bit_or(a1913, a1914) - }; - fixed_u32::bit_xor(a1915, a1916) -} - -pub fn f32(v0: u32, v1: u32, v2: u32) -> u32 { - let a1922 = { - let a1917 = v0; - let a1918 = v1; - fixed_u32::bit_and(a1917, a1918) - }; - let a1923 = { - let a1920 = { - let a1919 = v0; - fixed_u32::bit_not(a1919) - }; - let a1921 = v2; - fixed_u32::bit_and(a1920, a1921) - }; - fixed_u32::bit_xor(a1922, a1923) -} - -pub fn f33(v0: u32) -> u32 { - let a1950 = { - let a1940 = { - let a1930 = { - let m1926 = { - let a1924 = v0; - let a1925 = 2u32; - fixed_u32::shift_right(a1924, a1925) - }; - match m1926 { - None => { - 0u32 - } - Some(v1) => { - v1 - } - } - }; - let a1931 = { - let m1929 = { - let a1927 = v0; - let a1928 = 30u32; - fixed_u32::shift_left(a1927, a1928) - }; - match m1929 { - None => { - 0u32 - } - Some(v2) => { - v2 - } - } - }; - fixed_u32::bit_or(a1930, a1931) - }; - let a1941 = { - let a1938 = { - let m1934 = { - let a1932 = v0; - let a1933 = 13u32; - fixed_u32::shift_right(a1932, a1933) - }; - match m1934 { - None => { - 0u32 - } - Some(v3) => { - v3 - } - } - }; - let a1939 = { - let m1937 = { - let a1935 = v0; - let a1936 = 19u32; - fixed_u32::shift_left(a1935, a1936) - }; - match m1937 { - None => { - 0u32 - } - Some(v4) => { - v4 - } - } - }; - fixed_u32::bit_or(a1938, a1939) - }; - fixed_u32::bit_xor(a1940, a1941) - }; - let a1951 = { - let a1948 = { - let m1944 = { - let a1942 = v0; - let a1943 = 22u32; - fixed_u32::shift_right(a1942, a1943) - }; - match m1944 { - None => { - 0u32 - } - Some(v5) => { - v5 - } - } - }; - let a1949 = { - let m1947 = { - let a1945 = v0; - let a1946 = 10u32; - fixed_u32::shift_left(a1945, a1946) - }; - match m1947 { - None => { - 0u32 - } - Some(v6) => { - v6 - } - } - }; - fixed_u32::bit_or(a1948, a1949) - }; - fixed_u32::bit_xor(a1950, a1951) -} - -pub fn f34(v0: u32, v1: u32, v2: u32) -> u32 { - let a1960 = { - let a1956 = { - let a1952 = v0; - let a1953 = v1; - fixed_u32::bit_and(a1952, a1953) - }; - let a1957 = { - let a1954 = v0; - let a1955 = v2; - fixed_u32::bit_and(a1954, a1955) - }; - fixed_u32::bit_xor(a1956, a1957) - }; - let a1961 = { - let a1958 = v1; - let a1959 = v2; - fixed_u32::bit_and(a1958, a1959) - }; - fixed_u32::bit_xor(a1960, a1961) -} - -pub fn run(p0: List) -> R { - f0(p0) -} diff --git a/crates/certified/roots/uorust_certified_variant_field.rs b/crates/certified/roots/uorust_certified_variant_field.rs new file mode 100644 index 00000000..d6dc25df --- /dev/null +++ b/crates/certified/roots/uorust_certified_variant_field.rs @@ -0,0 +1,978 @@ +#![forbid(unsafe_code)] +use core::cmp::Ordering; + +use core::sync::atomic::{AtomicU64, Ordering as Memory}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Overflow; + +pub type R = Result; + +static WORK: AtomicU64 = AtomicU64::new(0); + +pub fn tick(units: u64) { WORK.fetch_add(units, Memory::Relaxed); } + +pub fn work() -> u64 { WORK.load(Memory::Relaxed) } + +pub trait Same { + fn same(&self, other: &Self) -> bool; +} + +pub trait Key { + fn key(&self, other: &Self) -> Ordering; +} + +impl Same for bool { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for bool { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for u64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for u64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i8 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i8 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i16 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i16 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i32 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i32 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for i64 { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for i64 { + fn key(&self, other: &Self) -> Ordering { self.cmp(other) } +} + +impl Same for Ordering { + fn same(&self, other: &Self) -> bool { self == other } +} + +impl Key for (A, B) { + fn key(&self, other: &Self) -> Ordering { match self.0.key(&other.0) { Ordering::Equal => self.1.key(&other.1), decided => decided, } } +} + +pub fn equal(a: T, b: T) -> bool { a.same(&b) } + +pub fn compare(a: T, b: T) -> Ordering { a.key(&b) } + +pub fn nat_add(p0: u64, p1: u64) -> R { + match u64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_sub(p0: u64, p1: u64) -> u64 { + u64::saturating_sub(p0, p1) +} + +pub fn nat_mul(p0: u64, p1: u64) -> R { + match u64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn nat_quot(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_div(p0, p1).unwrap_or(p2) +} + +pub fn nat_rem(p0: u64, p1: u64, p2: u64) -> u64 { + u64::checked_rem(p0, p1).unwrap_or(p2) +} + +pub fn nat_eq(p0: u64, p1: u64) -> bool { + core::cmp::PartialEq::eq(&p0, &p1) +} + +pub fn nat_le(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::le(&p0, &p1) +} + +pub fn nat_lt(p0: u64, p1: u64) -> bool { + core::cmp::PartialOrd::lt(&p0, &p1) +} + +pub fn nat_succ(p0: u64) -> R { + match u64::checked_add(p0, 1u64) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_add(p0: i64, p1: i64) -> R { + match i64::checked_add(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_sub(p0: i64, p1: i64) -> R { + match i64::checked_sub(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_mul(p0: i64, p1: i64) -> R { + match i64::checked_mul(p0, p1) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_neg(p0: i64) -> R { + match i64::checked_neg(p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } +} + +pub fn int_quot(p0: i64, p1: i64, p2: i64) -> R { + { let value = { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { Some(z) } else { a.checked_div(b) } }; match value { + Some(v0) => { + Ok(v0) + } + None => { + Err::(Overflow) + } + } } +} + +pub fn int_rem(p0: i64, p1: i64, p2: i64) -> i64 { + { let (a, b, z): (i64, i64, i64) = (p0, p1, p2); if b == 0 { z } else { a.wrapping_rem(b) } } +} + +pub fn bool_not(p0: bool) -> bool { + !p0 +} + +pub fn bool_and(p0: bool, p1: bool) -> bool { + if p0 { + p1 + } else { + false + } +} + +pub fn bool_or(p0: bool, p1: bool) -> bool { + if p0 { + true + } else { + p1 + } +} + +pub mod fixed_u8 { + pub fn checked_add(p0: u8, p1: u8) -> Option { + u8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u8, p1: u8) -> Option { + u8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u8, p1: u8) -> Option { + u8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u8, p1: u8) -> Option { + u8::checked_div(p0, p1) + } + + pub fn bit_and(p0: u8, p1: u8) -> u8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u8, p1: u8) -> u8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u8, p1: u8) -> u8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u8) -> u8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u8, p1: u32) -> Option { + u8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u8, p1: u32) -> Option { + u8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u8::try_from(p0).ok() + } +} + +pub mod fixed_u16 { + pub fn checked_add(p0: u16, p1: u16) -> Option { + u16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u16, p1: u16) -> Option { + u16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u16, p1: u16) -> Option { + u16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u16, p1: u16) -> Option { + u16::checked_div(p0, p1) + } + + pub fn bit_and(p0: u16, p1: u16) -> u16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u16, p1: u16) -> u16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u16, p1: u16) -> u16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u16) -> u16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u16, p1: u32) -> Option { + u16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u16, p1: u32) -> Option { + u16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u16::try_from(p0).ok() + } +} + +pub mod fixed_u32 { + pub fn checked_add(p0: u32, p1: u32) -> Option { + u32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u32, p1: u32) -> Option { + u32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u32, p1: u32) -> Option { + u32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u32, p1: u32) -> Option { + u32::checked_div(p0, p1) + } + + pub fn bit_and(p0: u32, p1: u32) -> u32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u32, p1: u32) -> u32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u32, p1: u32) -> u32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u32) -> u32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u32, p1: u32) -> Option { + u32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u32, p1: u32) -> Option { + u32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u32::try_from(p0).ok() + } +} + +pub mod fixed_u64 { + pub fn checked_add(p0: u64, p1: u64) -> Option { + u64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: u64, p1: u64) -> Option { + u64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: u64, p1: u64) -> Option { + u64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: u64, p1: u64) -> Option { + u64::checked_div(p0, p1) + } + + pub fn bit_and(p0: u64, p1: u64) -> u64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: u64, p1: u64) -> u64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: u64, p1: u64) -> u64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: u64) -> u64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: u64, p1: u32) -> Option { + u64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: u64, p1: u32) -> Option { + u64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + u64::try_from(p0).ok() + } +} + +pub mod fixed_i8 { + pub fn checked_add(p0: i8, p1: i8) -> Option { + i8::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i8, p1: i8) -> Option { + i8::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i8, p1: i8) -> Option { + i8::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i8, p1: i8) -> Option { + i8::checked_div(p0, p1) + } + + pub fn bit_and(p0: i8, p1: i8) -> i8 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i8, p1: i8) -> i8 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i8, p1: i8) -> i8 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i8) -> i8 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i8, p1: u32) -> Option { + i8::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i8, p1: u32) -> Option { + i8::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i8::try_from(p0).ok() + } +} + +pub fn checked_neg_i8(p0: i8) -> Option { + i8::checked_neg(p0) +} + +pub mod fixed_i16 { + pub fn checked_add(p0: i16, p1: i16) -> Option { + i16::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i16, p1: i16) -> Option { + i16::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i16, p1: i16) -> Option { + i16::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i16, p1: i16) -> Option { + i16::checked_div(p0, p1) + } + + pub fn bit_and(p0: i16, p1: i16) -> i16 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i16, p1: i16) -> i16 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i16, p1: i16) -> i16 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i16) -> i16 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i16, p1: u32) -> Option { + i16::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i16, p1: u32) -> Option { + i16::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i16::try_from(p0).ok() + } +} + +pub fn checked_neg_i16(p0: i16) -> Option { + i16::checked_neg(p0) +} + +pub mod fixed_i32 { + pub fn checked_add(p0: i32, p1: i32) -> Option { + i32::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i32, p1: i32) -> Option { + i32::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i32, p1: i32) -> Option { + i32::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i32, p1: i32) -> Option { + i32::checked_div(p0, p1) + } + + pub fn bit_and(p0: i32, p1: i32) -> i32 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i32, p1: i32) -> i32 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i32, p1: i32) -> i32 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i32) -> i32 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i32, p1: u32) -> Option { + i32::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i32, p1: u32) -> Option { + i32::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i32::try_from(p0).ok() + } +} + +pub fn checked_neg_i32(p0: i32) -> Option { + i32::checked_neg(p0) +} + +pub mod fixed_i64 { + pub fn checked_add(p0: i64, p1: i64) -> Option { + i64::checked_add(p0, p1) + } + + pub fn checked_sub(p0: i64, p1: i64) -> Option { + i64::checked_sub(p0, p1) + } + + pub fn checked_mul(p0: i64, p1: i64) -> Option { + i64::checked_mul(p0, p1) + } + + pub fn checked_quot(p0: i64, p1: i64) -> Option { + i64::checked_div(p0, p1) + } + + pub fn bit_and(p0: i64, p1: i64) -> i64 { + core::ops::BitAnd::bitand(p0, p1) + } + + pub fn bit_or(p0: i64, p1: i64) -> i64 { + core::ops::BitOr::bitor(p0, p1) + } + + pub fn bit_xor(p0: i64, p1: i64) -> i64 { + core::ops::BitXor::bitxor(p0, p1) + } + + pub fn bit_not(p0: i64) -> i64 { + core::ops::Not::not(p0) + } + + pub fn shift_left(p0: i64, p1: u32) -> Option { + i64::checked_shl(p0, p1) + } + + pub fn shift_right(p0: i64, p1: u32) -> Option { + i64::checked_shr(p0, p1) + } + + pub fn convert(p0: i128) -> Option { + i64::try_from(p0).ok() + } +} + +pub fn checked_neg_i64(p0: i64) -> Option { + i64::checked_neg(p0) +} +use core::str; + +use std::mem; + +use std::rc::Rc; + +#[derive(Clone)] +pub struct Str(Rc); + +impl Str { + pub fn lit(text: &str) -> Str { Str(Rc::from(text)) } + pub fn text(&self) -> &str { &self.0 } + pub fn length(&self) -> u64 { chars(&self.0) } + pub fn utf8_encode(&self) -> Bytes { tick(self.0.len() as u64); Bytes::lit(self.0.as_bytes()) } + pub fn split_exact(&self, delimiter: &Str, maximum: u32) -> Option> { if delimiter.0.is_empty() { return None; }; chars(&self.0); let mut fields: Vec = Vec::new(); for piece in self.0.split(&*delimiter.0) { fields.push(Str::lit(piece)); }; if fields.len() as u128 > u128::from(maximum) { return None; }; Some(List::onto(fields, List::nil())) } + pub fn join(texts: List, delimiter: &Str) -> Str { let mut out = String::new(); let mut first = true; let mut cursor = &texts; while let Repr::Cell(cell) = &cursor.0 { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&cell.head.0); out.push_str(&cell.head.0); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for text in buffer[..*len].iter().rev() { tick(1); if !first { chars(&delimiter.0); out.push_str(&delimiter.0); }; first = false; chars(&text.0); out.push_str(&text.0); } }, _ => { }, }; Str::lit(&out) } + pub fn parse_int(text: &Str) -> Option> { match canonical_decimal(&text.0) { None => Some(None), Some(Some(n)) => match i64::try_from(n) { Ok(value) => Some(Some(value)), Err(_) => None, }, Some(None) => None, } } + pub fn format_u8(a: u8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u8::try_from(n).ok(), _ => None, } } + pub fn format_u16(a: u16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u16::try_from(n).ok(), _ => None, } } + pub fn format_u32(a: u32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u32::try_from(n).ok(), _ => None, } } + pub fn format_u64(a: u64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_u64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => u64::try_from(n).ok(), _ => None, } } + pub fn format_i8(a: i8) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i8(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i8::try_from(n).ok(), _ => None, } } + pub fn format_i16(a: i16) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i16(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i16::try_from(n).ok(), _ => None, } } + pub fn format_i32(a: i32) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i32(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i32::try_from(n).ok(), _ => None, } } + pub fn format_i64(a: i64) -> Str { let text = a.to_string(); tick(text.len() as u64); Str::lit(&text) } + pub fn parse_i64(text: &Str) -> Option { match canonical_decimal(&text.0) { Some(Some(n)) => i64::try_from(n).ok(), _ => None, } } +} + +#[derive(Clone)] +pub struct Bytes(Rc<[u8]>); + +impl Bytes { + pub fn lit(octets: &[u8]) -> Bytes { Bytes(Rc::from(octets)) } + pub fn octets(&self) -> &[u8] { &self.0 } + pub fn append(a: Bytes, b: Bytes) -> Bytes { tick((a.0.len() + b.0.len()) as u64); let mut out = Vec::with_capacity(a.0.len() + b.0.len()); out.extend_from_slice(&a.0); out.extend_from_slice(&b.0); Bytes(Rc::from(out)) } + pub fn length(&self) -> u64 { self.0.len() as u64 } + pub fn index(&self, i: u64) -> Option { match usize::try_from(i) { Ok(at) => self.0.get(at).copied(), Err(_) => None, } } + pub fn slice(&self, start: u64, count: u64) -> Option { let end = u128::from(start) + u128::from(count); if end > self.0.len() as u128 { return None; }; tick(count); Some(Bytes::lit(&self.0[start as usize..end as usize])) } + pub fn utf8_decode(&self) -> Option { tick(self.0.len() as u64); match str::from_utf8(&self.0) { Ok(text) => Some(Str::lit(text)), Err(_) => None, } } + pub fn compare(&self, other: &Bytes) -> Ordering { tick(1 + self.0.len().min(other.0.len()) as u64); self.0.cmp(&other.0) } +} + +pub struct Node { head: T, tail: List } + +pub enum Repr { Nil, Run { buffer: Rc>, len: usize }, Cell(Rc>) } + +pub struct List(Repr); + +impl Clone for List { + fn clone(&self) -> Self { List(match &self.0 { Repr::Nil => Repr::Nil, Repr::Run { buffer, len } => Repr::Run { buffer: buffer.clone(), len: *len }, Repr::Cell(cell) => Repr::Cell(cell.clone()), }) } +} + +impl List { + fn take(&mut self) -> Repr { mem::replace(&mut self.0, Repr::Nil) } +} + +impl Drop for Node { + fn drop(&mut self) { let mut next = match self.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }; while let Some(cell) = next { match Rc::try_unwrap(cell) { Ok(mut node) => next = match node.tail.take() { Repr::Cell(cell) => Some(cell), _ => None, }, Err(_) => break, } } } +} + +impl List { + pub fn nil() -> Self { List(Repr::Nil) } + pub fn cons(head: T, mut tail: List) -> Self { List(match tail.take() { Repr::Nil => { let mut buffer = Vec::with_capacity(16); buffer.push(head); Repr::Run { buffer: Rc::new(buffer), len: 1 } }, Repr::Run { mut buffer, len } => { match Rc::get_mut(&mut buffer) { Some(cells) => { cells.truncate(len); cells.push(head); Repr::Run { buffer, len: len + 1 } }, None => Repr::Cell(Rc::new(Node { head, tail: List(Repr::Run { buffer, len }) })), } }, rest => Repr::Cell(Rc::new(Node { head, tail: List(rest) })), }) } + pub fn uncons(&self) -> Option<(T, List)> { match &self.0 { Repr::Nil => None, Repr::Run { buffer, len } => { let head = buffer[len - 1].clone(); Some((head, List(if *len == 1 { Repr::Nil } else { Repr::Run { buffer: buffer.clone(), len: len - 1 } }))) }, Repr::Cell(cell) => Some((cell.head.clone(), cell.tail.clone())), } } + pub fn length(&self) -> u64 { let mut count = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); count += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for _ in buffer[..*len].iter().rev() { tick(1); count += 1; } }, _ => { }, }; count } + pub fn append(a: List, b: List) -> List { List::onto(a.items(), b) } + pub fn index(&self, i: u64) -> Option { let mut position = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position == i { return Some(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position == i { return Some(item.clone()); }; position += 1; } }, _ => { }, }; None } + pub fn slice(&self, start: u64, count: u64) -> Option> { let end = u128::from(start) + u128::from(count); let mut part = Vec::new(); let mut position: u128 = 0; let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(cell.head.clone()); }; position += 1; cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); if position >= end { return Some(List::onto(part, List::nil())); }; if position >= u128::from(start) { part.push(item.clone()); }; position += 1; } }, _ => { }, }; if position < end { None } else { Some(List::onto(part, List::nil())) } } + fn items(&self) -> Vec { let mut out = Vec::new(); let mut cursor = self; while let Repr::Cell(cell) = &cursor.0 { tick(1); out.push(cell.head.clone()); cursor = &cell.tail; }; match &cursor.0 { Repr::Run { buffer, len } => { for item in buffer[..*len].iter().rev() { tick(1); out.push(item.clone()); } }, _ => { }, }; out } + fn onto(mut items: Vec, tail: List) -> List { let mut out = tail; while let Some(item) = items.pop() { tick(1); out = List::cons(item, out); }; out } +} + +pub fn chars(text: &str) -> u64 { let mut count = 0; for _ in text.chars() { tick(1); count += 1; }; count } + +impl Same for Str { + fn same(&self, other: &Self) -> bool { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return true, (a, b) if a != b => return false, _ => { }, } } } +} + +impl Same for Bytes { + fn same(&self, other: &Self) -> bool { tick(1 + self.0.len().min(other.0.len()) as u64); self.0 == other.0 } +} + +impl Key for Str { + fn key(&self, other: &Self) -> Ordering { let mut left = self.0.chars(); let mut right = other.0.chars(); loop { tick(1); match (left.next(), right.next()) { (None, None) => return Ordering::Equal, (None, Some(_)) => return Ordering::Less, (Some(_), None) => return Ordering::Greater, (Some(a), Some(b)) => match a.cmp(&b) { Ordering::Equal => { }, decided => return decided, }, } } } +} + +pub fn canonical_decimal(text: &str) -> Option> { let digits = match text.strip_prefix('-') { Some(rest) => rest, None => text, }; let mut canonical = !digits.is_empty() && (digits == "0" || !digits.starts_with('0')) && text != "-0"; for c in digits.chars() { tick(1); canonical = canonical && c.is_ascii_digit(); }; if !canonical { return None; }; Some(text.parse::().ok()) } + +pub fn append_list(p0: List, p1: List) -> List { + List::append(p0, p1) +} + +pub fn length_list(p0: List) -> u64 { + List::length(&p0) +} + +pub fn index_list(p0: List, p1: u64) -> Option { + List::index(&p0, p1) +} + +pub fn slice_list(p0: List, p1: u64, p2: u64) -> Option> { + List::slice(&p0, p1, p2) +} + +pub fn append_bytes(p0: Bytes, p1: Bytes) -> Bytes { + Bytes::append(p0, p1) +} + +pub fn length_bytes(p0: Bytes) -> u64 { + Bytes::length(&p0) +} + +pub fn length_string(p0: Str) -> u64 { + Str::length(&p0) +} + +pub fn index_bytes(p0: Bytes, p1: u64) -> Option { + Bytes::index(&p0, p1) +} + +pub fn slice_bytes(p0: Bytes, p1: u64, p2: u64) -> Option { + Bytes::slice(&p0, p1, p2) +} + +pub fn utf8_encode(p0: Str) -> Bytes { + Str::utf8_encode(&p0) +} + +pub fn utf8_decode(p0: Bytes) -> Option { + Bytes::utf8_decode(&p0) +} + +pub fn compare_bytes(p0: Bytes, p1: Bytes) -> Ordering { + Bytes::compare(&p0, &p1) +} + +pub fn split_exact(p0: Str, p1: Str, p2: u32) -> Option> { + Str::split_exact(&p0, &p1, p2) +} + +pub fn join(p0: List, p1: Str) -> Str { + Str::join(p0, &p1) +} + +pub fn format_u8(p0: u8) -> Str { + Str::format_u8(p0) +} + +pub fn parse_u8(p0: Str) -> Option { + Str::parse_u8(&p0) +} + +pub fn format_u16(p0: u16) -> Str { + Str::format_u16(p0) +} + +pub fn parse_u16(p0: Str) -> Option { + Str::parse_u16(&p0) +} + +pub fn format_u32(p0: u32) -> Str { + Str::format_u32(p0) +} + +pub fn parse_u32(p0: Str) -> Option { + Str::parse_u32(&p0) +} + +pub fn format_u64(p0: u64) -> Str { + Str::format_u64(p0) +} + +pub fn parse_u64(p0: Str) -> Option { + Str::parse_u64(&p0) +} + +pub fn format_i8(p0: i8) -> Str { + Str::format_i8(p0) +} + +pub fn parse_i8(p0: Str) -> Option { + Str::parse_i8(&p0) +} + +pub fn format_i16(p0: i16) -> Str { + Str::format_i16(p0) +} + +pub fn parse_i16(p0: Str) -> Option { + Str::parse_i16(&p0) +} + +pub fn format_i32(p0: i32) -> Str { + Str::format_i32(p0) +} + +pub fn parse_i32(p0: Str) -> Option { + Str::parse_i32(&p0) +} + +pub fn format_i64(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn parse_i64(p0: Str) -> Option { + Str::parse_i64(&p0) +} + +pub fn parse_int(p0: Str) -> R> { + match Str::parse_int(&p0) { + Some(v0) => { + Ok(v0) + } + None => { + Err::, Overflow>(Overflow) + } + } +} + +pub fn format_int(p0: i64) -> Str { + Str::format_i64(p0) +} + +pub fn f0(v0: Str, v1: Str, v2: Option, v3: u64) -> R { + let m1 = v2; + match m1 { + None => { + let a4 = { + let a2 = List::cons(v0, List::cons(Str::lit("::"), List::::nil())); + let a3 = List::cons(v1, List::cons(Str::lit("."), List::cons(f1(v3)?, List::::nil()))); + append_list(a2, a3) + }; + let a5 = Str::lit(""); + Ok(join(a4, a5)) + } + Some(v4) => { + let a8 = { + let a6 = List::cons(v0, List::cons(Str::lit("::"), List::::nil())); + let a7 = List::cons(v1, List::cons(Str::lit("."), List::cons(v4, List::::nil()))); + append_list(a6, a7) + }; + let a9 = Str::lit(""); + Ok(join(a8, a9)) + } + } +} + +pub fn f1(v0: u64) -> R { + Ok(f2({ + let a10 = v0; + let a11 = 1u64; + nat_add(a10, a11)? + }, v0)) +} + +pub fn f2(v0: u64, v1: u64) -> Str { + let m12 = v0; + if m12 == 0 { + Str::lit("") + } else { + let v2 = m12 - 1; + let a13 = v1; + let a14 = 10u64; + if nat_lt(a13, a14) { + f3(v1) + } else { + let a21 = List::cons(f2(v2, { + let a15 = v1; + let a16 = 10u64; + let a17 = 0u64; + nat_quot(a15, a16, a17) + }), List::cons(f3({ + let a18 = v1; + let a19 = 10u64; + let a20 = 0u64; + nat_rem(a18, a19, a20) + }), List::::nil())); + let a22 = Str::lit(""); + join(a21, a22) + } + } +} + +pub fn f3(v0: u64) -> Str { + let a23 = v0; + let a24 = 0u64; + if nat_eq(a23, a24) { + Str::lit("0") + } else { + let a25 = v0; + let a26 = 1u64; + if nat_eq(a25, a26) { + Str::lit("1") + } else { + let a27 = v0; + let a28 = 2u64; + if nat_eq(a27, a28) { + Str::lit("2") + } else { + let a29 = v0; + let a30 = 3u64; + if nat_eq(a29, a30) { + Str::lit("3") + } else { + let a31 = v0; + let a32 = 4u64; + if nat_eq(a31, a32) { + Str::lit("4") + } else { + let a33 = v0; + let a34 = 5u64; + if nat_eq(a33, a34) { + Str::lit("5") + } else { + let a35 = v0; + let a36 = 6u64; + if nat_eq(a35, a36) { + Str::lit("6") + } else { + let a37 = v0; + let a38 = 7u64; + if nat_eq(a37, a38) { + Str::lit("7") + } else { + let a39 = v0; + let a40 = 8u64; + if nat_eq(a39, a40) { + Str::lit("8") + } else { + Str::lit("9") + } + } + } + } + } + } + } + } + } +} + +pub fn run(p0: Str, p1: Str, p2: Option, p3: u64) -> R { + f0(p0, p1, p2, p3) +} diff --git a/crates/certified/roots/uorust_certified_variant_owner.rs b/crates/certified/roots/uorust_certified_variant_owner.rs index c7464a52..9e5002df 100644 --- a/crates/certified/roots/uorust_certified_variant_owner.rs +++ b/crates/certified/roots/uorust_certified_variant_owner.rs @@ -902,7 +902,7 @@ pub enum Adt6 { #[derive(Clone)] pub enum Adt7 { - C0(List, List, List, List, List>, List, List, bool, List, List, List, List), + C0(List, List, List, List, List>, List, List, bool, List, List, List, List, List), } #[derive(Clone)] @@ -923,20 +923,21 @@ pub enum Adt10 { C3(u64), C4(Adt11), C5(Option), - C6, + C6(Option), C7, C8, C9, C10, - C11(Str), - C12(std::rc::Rc), - C13(std::rc::Rc, std::rc::Rc), - C14(std::rc::Rc), - C15(List), + C11, + C12(Str), + C13(std::rc::Rc), + C14(std::rc::Rc, std::rc::Rc), + C15(std::rc::Rc), C16(List), - C17(std::rc::Rc, std::rc::Rc, bool), - C18(std::rc::Rc, bool), - C19(List, std::rc::Rc), + C17(List), + C18(std::rc::Rc, std::rc::Rc, bool), + C19(std::rc::Rc, bool), + C20(List, std::rc::Rc), } #[derive(Clone)] @@ -994,7 +995,7 @@ pub enum Adt21 { C0(u64, List), } -pub fn f0(v0: Adt0, v1: Adt6) -> Option { +pub fn f0(v0: Adt0, v1: Adt6) -> R> { let m3 = { let a1 = f1(f2(v0)); let a2 = 1u64; @@ -1002,14 +1003,14 @@ pub fn f0(v0: Adt0, v1: Adt6) -> Option { }; match m3 { None => { - None:: + Ok(None::) } Some(v2) => { let v3: Str = f3(match v1.clone() { Adt6::C0(h4, _, _, _) => { h4 } - }, f4(v2)); + }, f4(v2))?; if if f5({ let m7 = match v1.clone() { Adt6::C0(h6, _, _, _) => { @@ -1017,7 +1018,7 @@ pub fn f0(v0: Adt0, v1: Adt6) -> Option { } }; match m7 { - Adt7::C0(_, _, _, h5, _, _, _, _, _, _, _, _) => { + Adt7::C0(_, _, _, h5, _, _, _, _, _, _, _, _, _) => { h5 } } @@ -1031,15 +1032,15 @@ pub fn f0(v0: Adt0, v1: Adt6) -> Option { } }; match m10 { - Adt7::C0(h8, _, _, _, _, _, _, _, _, _, _, _) => { + Adt7::C0(h8, _, _, _, _, _, _, _, _, _, _, _, _) => { h8 } } }, v3.clone()) } { - Some(Adt10::C11(v3)) + Ok(Some(Adt10::C12(v3))) } else { - None:: + Ok(None::) } } } @@ -1068,18 +1069,19 @@ pub fn f2(v0: Adt0) -> List { } } -pub fn f3(v0: Adt7, v1: Str) -> Str { - let m16 = f7(match v0 { - Adt7::C0(_, _, h15, _, _, _, _, _, _, _, _, _) => { +pub fn f3(v0: Adt7, v1: Str) -> R { + let v2: Str = f7(v1)?; + let m16 = f8(match v0 { + Adt7::C0(_, _, h15, _, _, _, _, _, _, _, _, _, _) => { h15 } - }, v1.clone()); + }, v2.clone()); match m16 { None => { - v1 + Ok(v2) } - Some(v2) => { - v2 + Some(v3) => { + Ok(v3) } } } @@ -1163,29 +1165,63 @@ pub fn f6(p29: List, v1: Str) -> bool { } } -pub fn f7(p36: List, v1: Str) -> Option { - let m35 = p36; +pub fn f7(v0: Str) -> R { + let m30 = f9(v0.clone())?; + match m30 { + None => { + Ok(v0) + } + Some(v1) => { + let v2: Str = match v1.clone() { + Adt12::C0(h31, _) => { + h31 + } + }; + let v3: Str = match v1 { + Adt12::C0(_, h32) => { + h32 + } + }; + let m33 = f10(v3, Str::lit(">")); + match m33 { + None => { + Ok(v0) + } + Some(v4) => { + if f11(f12(v4, Str::lit(","))?)? { + f13(v2) + } else { + Ok(v0) + } + } + } + } + } +} + +pub fn f8(p40: List, v1: Str) -> Option { + let m39 = p40; { - let mut m35 = m35; + let mut m39 = m39; loop { let step = { - let v0 = m35; - let m30 = v0; - match m30.uncons() { + let v0 = m39; + let m34 = v0; + match m34.uncons() { None => { Err::, Option>(None::) } Some((v2, v3)) => { - let a32 = match v2.clone() { - Adt12::C0(h31, _) => { - h31 + let a36 = match v2.clone() { + Adt12::C0(h35, _) => { + h35 } }; - let a33 = v1.clone(); - if equal(a32, a33) { + let a37 = v1.clone(); + if equal(a36, a37) { Err::, Option>(Some(match v2 { - Adt12::C0(_, h34) => { - h34 + Adt12::C0(_, h38) => { + h38 } })) } else { @@ -1195,13 +1231,867 @@ pub fn f7(p36: List, v1: Str) -> Option { } }; match step { - Ok(next) => { m35 = next; } + Ok(next) => { m39 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f9(v0: Str) -> R> { + let m41 = f14(v0.clone(), Str::lit("<"))?; + match m41 { + None => { + Ok(None::) + } + Some(v1) => { + Ok(Some(Adt12::C0(f15(v0.clone(), 0u64, v1), f15(v0.clone(), { + let a42 = v1; + let a43 = f16(Str::lit("<")); + nat_add(a42, a43)? + }, f16(v0))))) + } + } +} + +pub fn f10(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a44 = v0.clone(); + utf8_encode(a44) + }; + let v3: u64 = { + let a45 = v2.clone(); + length_bytes(a45) + }; + let v4: u64 = f16(v1.clone()); + if f17(v0, v1) { + Some(f18(v2, 0u64, { + let a46 = v3; + let a47 = v4; + nat_sub(a46, a47) + })) + } else { + None:: + } +} + +pub fn f11(p50: List) -> R { + let m49 = p50; + { + let mut m49 = m49; + loop { + let step = { + let v0 = m49; + let m48 = v0; + match m48.uncons() { + None => { + Err::, R>(Ok(true)) + } + Some((v1, v2)) => { + if f19(v1)? { + Ok::, R>(v2) + } else { + Err::, R>(Ok(false)) + } + } + } + }; + match step { + Ok(next) => { m49 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f12(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a51 = v0.clone(); + utf8_encode(a51) + }; + let v3: Bytes = { + let a52 = v1; + utf8_encode(a52) + }; + let a54 = { + let a53 = v3.clone(); + length_bytes(a53) + }; + let a55 = 0u64; + if nat_eq(a54, a55) { + Ok(List::cons(Str::lit(""), { + let a56 = f20(v0)?; + let a57 = List::cons(Str::lit(""), List::::nil()); + append_list(a56, a57) + })) + } else { + f21({ + let a59 = { + let a58 = v2.clone(); + length_bytes(a58) + }; + let a60 = 1u64; + nat_add(a59, a60)? + }, v2, v3, 0u64, 0u64) + } +} + +pub fn f13(v0: Str) -> R { + let v1: Bytes = { + let a61 = v0; + utf8_encode(a61) + }; + let v2: u64 = { + let a62 = v1.clone(); + length_bytes(a62) + }; + Ok(f18(v1.clone(), 0u64, f22(v2, v1, v2)?)) +} + +pub fn f14(v0: Str, v1: Str) -> R> { + let v2: Bytes = { + let a63 = v0; + utf8_encode(a63) + }; + f23({ + let a65 = { + let a64 = v2.clone(); + length_bytes(a64) + }; + let a66 = 1u64; + nat_add(a65, a66)? + }, v2, { + let a67 = v1; + utf8_encode(a67) + }, 0u64) +} + +pub fn f15(v0: Str, v1: u64, v2: u64) -> Str { + f18({ + let a68 = v0; + utf8_encode(a68) + }, v1, v2) +} + +pub fn f16(v0: Str) -> u64 { + let a70 = { + let a69 = v0; + utf8_encode(a69) + }; + length_bytes(a70) +} + +pub fn f17(v0: Str, v1: Str) -> bool { + let v2: Bytes = { + let a71 = v0; + utf8_encode(a71) + }; + let v3: Bytes = { + let a72 = v1; + utf8_encode(a72) + }; + let v4: u64 = { + let a73 = v2.clone(); + length_bytes(a73) + }; + let v5: u64 = { + let a74 = v3.clone(); + length_bytes(a74) + }; + let a75 = v5; + let a76 = v4; + if nat_le(a75, a76) { + f24(v2, { + let a77 = v4; + let a78 = v5; + nat_sub(a77, a78) + }, v3) + } else { + false + } +} + +pub fn f18(v0: Bytes, v1: u64, v2: u64) -> Str { + let m84 = { + let a81 = v0; + let a82 = v1; + let a83 = { + let a79 = v2; + let a80 = v1; + nat_sub(a79, a80) + }; + slice_bytes(a81, a82, a83) + }; + match m84 { + None => { + Str::lit("") + } + Some(v3) => { + let m86 = { + let a85 = v3; + utf8_decode(a85) + }; + match m86 { + None => { + Str::lit("") + } + Some(v4) => { + v4 + } + } + } + } +} + +pub fn f19(v0: Str) -> R { + let m87 = f25(f26(v0)?, Str::lit("'")); + match m87 { + None => { + Ok(false) + } + Some(v1) => { + let a88 = f27(v1, Str::lit("'"))?; + Ok(bool_not(a88)) + } + } +} + +pub fn f20(v0: Str) -> R> { + let v1: Bytes = { + let a89 = v0; + utf8_encode(a89) + }; + f28({ + let a90 = v1.clone(); + length_bytes(a90) + }, v1, 0u64) +} + +pub fn f21(v0: u64, v1: Bytes, v2: Bytes, v3: u64, v4: u64) -> R> { + let m91 = v0; + if m91 == 0 { + Ok(List::cons(f18(v1.clone(), v3, { + let a92 = v1; + length_bytes(a92) + }), List::::nil())) + } else { + let v5 = m91 - 1; + let a97 = { + let a93 = v1.clone(); + length_bytes(a93) + }; + let a98 = { + let a95 = v4; + let a96 = { + let a94 = v2.clone(); + length_bytes(a94) + }; + nat_add(a95, a96)? + }; + if nat_lt(a97, a98) { + Ok(List::cons(f18(v1.clone(), v3, { + let a99 = v1; + length_bytes(a99) + }), List::::nil())) + } else { + if f24(v1.clone(), v4, v2.clone()) { + Ok(List::cons(f18(v1.clone(), v3, v4), f21(v5, v1, v2.clone(), { + let a101 = v4; + let a102 = { + let a100 = v2.clone(); + length_bytes(a100) + }; + nat_add(a101, a102)? + }, { + let a104 = v4; + let a105 = { + let a103 = v2; + length_bytes(a103) + }; + nat_add(a104, a105)? + })?)) + } else { + f21(v5, v1, v2, v3, { + let a106 = v4; + let a107 = 1u64; + nat_add(a106, a107)? + }) + } + } + } +} + +pub fn f22(p114: u64, v1: Bytes, p115: u64) -> R { + let m113 = (p114, p115); + { + let mut m113 = m113; + loop { + let step = { + let (v0, v2) = m113; + let m108 = v0; + if m108 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m108 - 1; + let v4: u64 = f29(v1.clone(), v2)?; + let a109 = v4; + let a110 = 0u64; + if nat_eq(a109, a110) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a111 = v2; + let a112 = v4; + nat_sub(a111, a112) + })) + } + } + }; + match step { + Ok(next) => { m113 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f23(p126: u64, v1: Bytes, v2: Bytes, p127: u64) -> R> { + let m125 = (p126, p127); + { + let mut m125 = m125; + loop { + let step = { + let (v0, v3) = m125; + let m116 = v0; + if m116 == 0 { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + let v4 = m116 - 1; + let a121 = { + let a117 = v1.clone(); + length_bytes(a117) + }; + let a122 = { + let a119 = v3; + let a120 = { + let a118 = v2.clone(); + length_bytes(a118) + }; + nat_add(a119, a120)? + }; + if nat_lt(a121, a122) { + Err::<(u64, u64), R>>(Ok(None::)) + } else { + if f24(v1.clone(), v3, v2.clone()) { + Err::<(u64, u64), R>>(Ok(Some(v3))) + } else { + Ok::<(u64, u64), R>>((v4, { + let a123 = v3; + let a124 = 1u64; + nat_add(a123, a124)? + })) + } + } + } + }; + match step { + Ok(next) => { m125 = next; } + Err(done) => break done, + } + } + } +} + +pub fn f24(v0: Bytes, v1: u64, v2: Bytes) -> bool { + let m132 = { + let a129 = v0; + let a130 = v1; + let a131 = { + let a128 = v2.clone(); + length_bytes(a128) + }; + slice_bytes(a129, a130, a131) + }; + match m132 { + None => { + false + } + Some(v3) => { + let a133 = v3; + let a134 = v2; + equal(a133, a134) + } + } +} + +pub fn f25(v0: Str, v1: Str) -> Option { + let v2: Bytes = { + let a135 = v0; + utf8_encode(a135) + }; + let v3: Bytes = { + let a136 = v1; + utf8_encode(a136) + }; + if f24(v2.clone(), 0u64, v3.clone()) { + Some(f18(v2.clone(), { + let a137 = v3; + length_bytes(a137) + }, { + let a138 = v2; + length_bytes(a138) + })) + } else { + None:: + } +} + +pub fn f26(v0: Str) -> R { + f13(f30(v0)?) +} + +pub fn f27(v0: Str, v1: Str) -> R { + let m139 = f14(v0, v1)?; + match m139 { + None => { + Ok(false) + } + Some(_) => { + Ok(true) + } + } +} + +pub fn f28(v0: u64, v1: Bytes, v2: u64) -> R> { + let m140 = v0; + if m140 == 0 { + Ok(List::::nil()) + } else { + let v3 = m140 - 1; + let a142 = { + let a141 = v1.clone(); + length_bytes(a141) + }; + let a143 = v2; + if nat_le(a142, a143) { + Ok(List::::nil()) + } else { + let v4: u64 = f31(f32(v1.clone(), v2)?); + Ok(List::cons(f18(v1.clone(), v2, { + let a144 = v2; + let a145 = v4; + nat_add(a144, a145)? + }), f28(v3, v1, { + let a146 = v2; + let a147 = v4; + nat_add(a146, a147)? + })?)) + } + } +} + +pub fn f29(v0: Bytes, v1: u64) -> R { + let a148 = v1; + let a149 = 0u64; + if nat_eq(a148, a149) { + Ok(0u64) + } else { + if f33(f32(v0.clone(), { + let a150 = v1; + let a151 = 1u64; + nat_sub(a150, a151) + })?) { + Ok(1u64) + } else { + let a152 = 2u64; + let a153 = v1; + if if nat_le(a152, a153) { + let a156 = f34(v0.clone(), { + let a154 = v1; + let a155 = 2u64; + nat_sub(a154, a155) + })?; + let a157 = 2u64; + nat_eq(a156, a157) + } else { + false + } { + Ok(2u64) + } else { + let a158 = 3u64; + let a159 = v1; + if if nat_le(a158, a159) { + let a162 = f34(v0, { + let a160 = v1; + let a161 = 3u64; + nat_sub(a160, a161) + })?; + let a163 = 3u64; + nat_eq(a162, a163) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } +} + +pub fn f30(v0: Str) -> R { + let v1: Bytes = { + let a164 = v0; + utf8_encode(a164) + }; + let v2: u64 = { + let a165 = v1.clone(); + length_bytes(a165) + }; + Ok(f18(v1.clone(), f35(v2, v1, 0u64)?, v2)) +} + +pub fn f31(v0: u64) -> u64 { + let a166 = v0; + let a167 = 128u64; + if nat_lt(a166, a167) { + 1u64 + } else { + let a168 = v0; + let a169 = 224u64; + if nat_lt(a168, a169) { + 2u64 + } else { + let a170 = v0; + let a171 = 240u64; + if nat_lt(a170, a171) { + 3u64 + } else { + 4u64 + } + } + } +} + +pub fn f32(v0: Bytes, v1: u64) -> R { + let m174 = { + let a172 = v0; + let a173 = v1; + index_bytes(a172, a173) + }; + match m174 { + None => { + Ok(256u64) + } + Some(v2) => { + let v3: u8 = v2; + let a219 = { + let a195 = { + let a183 = { + let a177 = { + let a175 = v3; + let a176 = 128u8; + fixed_u8::bit_and(a175, a176) + }; + let a178 = 128u8; + if equal(a177, a178) { + 128u64 + } else { + 0u64 + } + }; + let a184 = { + let a181 = { + let a179 = v3; + let a180 = 64u8; + fixed_u8::bit_and(a179, a180) + }; + let a182 = 64u8; + if equal(a181, a182) { + 64u64 + } else { + 0u64 + } + }; + nat_add(a183, a184)? + }; + let a196 = { + let a193 = { + let a187 = { + let a185 = v3; + let a186 = 32u8; + fixed_u8::bit_and(a185, a186) + }; + let a188 = 32u8; + if equal(a187, a188) { + 32u64 + } else { + 0u64 + } + }; + let a194 = { + let a191 = { + let a189 = v3; + let a190 = 16u8; + fixed_u8::bit_and(a189, a190) + }; + let a192 = 16u8; + if equal(a191, a192) { + 16u64 + } else { + 0u64 + } + }; + nat_add(a193, a194)? + }; + nat_add(a195, a196)? + }; + let a220 = { + let a217 = { + let a205 = { + let a199 = { + let a197 = v3; + let a198 = 8u8; + fixed_u8::bit_and(a197, a198) + }; + let a200 = 8u8; + if equal(a199, a200) { + 8u64 + } else { + 0u64 + } + }; + let a206 = { + let a203 = { + let a201 = v3; + let a202 = 4u8; + fixed_u8::bit_and(a201, a202) + }; + let a204 = 4u8; + if equal(a203, a204) { + 4u64 + } else { + 0u64 + } + }; + nat_add(a205, a206)? + }; + let a218 = { + let a215 = { + let a209 = { + let a207 = v3; + let a208 = 2u8; + fixed_u8::bit_and(a207, a208) + }; + let a210 = 2u8; + if equal(a209, a210) { + 2u64 + } else { + 0u64 + } + }; + let a216 = { + let a213 = { + let a211 = v3; + let a212 = 1u8; + fixed_u8::bit_and(a211, a212) + }; + let a214 = 1u8; + if equal(a213, a214) { + 1u64 + } else { + 0u64 + } + }; + nat_add(a215, a216)? + }; + nat_add(a217, a218)? + }; + nat_add(a219, a220) + } + } +} + +pub fn f33(v0: u64) -> bool { + let a221 = v0; + let a222 = 32u64; + if nat_eq(a221, a222) { + true + } else { + let a223 = 9u64; + let a224 = v0; + if nat_le(a223, a224) { + let a225 = v0; + let a226 = 13u64; + nat_le(a225, a226) + } else { + false + } + } +} + +pub fn f34(v0: Bytes, v1: u64) -> R { + let v2: u64 = f32(v0.clone(), v1)?; + let v3: u64 = f32(v0.clone(), { + let a227 = v1; + let a228 = 1u64; + nat_add(a227, a228)? + })?; + let v4: u64 = f32(v0, { + let a229 = v1; + let a230 = 2u64; + nat_add(a229, a230)? + })?; + if f33(v2) { + Ok(1u64) + } else { + let a231 = v2; + let a232 = 194u64; + if nat_eq(a231, a232) { + let a233 = v3; + let a234 = 133u64; + if if nat_eq(a233, a234) { + true + } else { + let a235 = v3; + let a236 = 160u64; + nat_eq(a235, a236) + } { + Ok(2u64) + } else { + Ok(0u64) + } + } else { + let a237 = v2; + let a238 = 225u64; + if nat_eq(a237, a238) { + let a239 = v3; + let a240 = 154u64; + if if nat_eq(a239, a240) { + let a241 = v4; + let a242 = 128u64; + nat_eq(a241, a242) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a243 = v2; + let a244 = 226u64; + if nat_eq(a243, a244) { + let a245 = v3; + let a246 = 128u64; + if nat_eq(a245, a246) { + let a247 = 128u64; + let a248 = v4; + if if if nat_le(a247, a248) { + let a249 = v4; + let a250 = 138u64; + nat_le(a249, a250) + } else { + false + } { + true + } else { + let a251 = v4; + let a252 = 168u64; + if nat_eq(a251, a252) { + true + } else { + let a253 = v4; + let a254 = 169u64; + if nat_eq(a253, a254) { + true + } else { + let a255 = v4; + let a256 = 175u64; + nat_eq(a255, a256) + } + } + } { + Ok(3u64) + } else { + Ok(0u64) + } + } else { + let a257 = v3; + let a258 = 129u64; + if if nat_eq(a257, a258) { + let a259 = v4; + let a260 = 159u64; + nat_eq(a259, a260) + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } else { + let a261 = v2; + let a262 = 227u64; + if if nat_eq(a261, a262) { + let a263 = v3; + let a264 = 128u64; + if nat_eq(a263, a264) { + let a265 = v4; + let a266 = 128u64; + nat_eq(a265, a266) + } else { + false + } + } else { + false + } { + Ok(3u64) + } else { + Ok(0u64) + } + } + } + } + } +} + +pub fn f35(p273: u64, v1: Bytes, p274: u64) -> R { + let m272 = (p273, p274); + { + let mut m272 = m272; + loop { + let step = { + let (v0, v2) = m272; + let m267 = v0; + if m267 == 0 { + Err::<(u64, u64), R>(Ok(v2)) + } else { + let v3 = m267 - 1; + let v4: u64 = f34(v1.clone(), v2)?; + let a268 = v4; + let a269 = 0u64; + if nat_eq(a268, a269) { + Err::<(u64, u64), R>(Ok(v2)) + } else { + Ok::<(u64, u64), R>((v3, { + let a270 = v2; + let a271 = v4; + nat_add(a270, a271)? + })) + } + } + }; + match step { + Ok(next) => { m272 = next; } Err(done) => break done, } } } } -pub fn run(p0: Adt0, p1: Adt6) -> Option { +pub fn run(p0: Adt0, p1: Adt6) -> R> { f0(p0, p1) } diff --git a/crates/certified/src/lib.rs b/crates/certified/src/lib.rs index 16208924..8de507fd 100644 --- a/crates/certified/src/lib.rs +++ b/crates/certified/src/lib.rs @@ -90,6 +90,12 @@ pub mod assert; #[path = "../roots/uorust_certified_assert_kind.rs"] pub mod assert_kind; +/// `uorust::lift::barred`, certified as `Behavior::barred`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_barred.rs"] +pub mod barred; + /// `uorust::mir::coverage::binop`, certified as `Behavior::binop`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -108,6 +114,12 @@ pub mod borrow; #[path = "../roots/uorust_certified_called_value.rs"] pub mod called_value; +/// `uorust::lex::camel`, certified as `Behavior::camel`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_camel.rs"] +pub mod camel; + /// `uorust::lift::captures`, certified as `Behavior::captures`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -240,6 +252,12 @@ pub mod expr_is_flat; #[path = "../roots/uorust_certified_expr_pieces.rs"] pub mod expr_pieces; +/// `uorust::lift::field_name`, certified as `Behavior::fieldName`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_field_name.rs"] +pub mod field_name; + /// `uorust::lift::first_free`, certified as `Behavior::firstFree`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -306,6 +324,12 @@ pub mod is_const_argument; #[path = "../roots/uorust_certified_is_enum_or_bool.rs"] pub mod is_enum_or_bool; +/// `uorust::lift::is_lifetime`, certified as `Behavior::isLifetime`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_is_lifetime.rs"] +pub mod is_lifetime; + /// `uorust::mir::lower::is_needs_address`, certified as `Behavior::isNeedsAddress`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -372,6 +396,12 @@ pub mod lift_max_of; #[path = "../roots/uorust_certified_lift_pow2.rs"] pub mod lift_pow2; +/// `uorust::lift::local_name`, certified as `Behavior::localName`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_local_name.rs"] +pub mod local_name; + /// `uorust::lex::members`, certified as `Behavior::members`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -582,6 +612,12 @@ pub mod module_path; #[path = "../roots/uorust_certified_mut_target.rs"] pub mod mut_target; +/// `uorust::lift::name_taken`, certified as `Behavior::nameTaken`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_name_taken.rs"] +pub mod name_taken; + /// `uorust::lift::named_field`, certified as `Behavior::namedField`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -630,6 +666,12 @@ pub mod opt_of; #[path = "../roots/uorust_certified_params.rs"] pub mod params; +/// `uorust::lex::pascal`, certified as `Behavior::pascal`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_pascal.rs"] +pub mod pascal; + /// `uorust::mir::lower::plain_cell`, certified as `Behavior::plainCell`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -678,6 +720,12 @@ pub mod reason; #[path = "../roots/uorust_certified_referent.rs"] pub mod referent; +/// `uorust::lift::refused`, certified as `Behavior::refused`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_refused.rs"] +pub mod refused; + /// `uorust::lift::Residue::code`, certified as `Behavior::residueCode`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -738,12 +786,36 @@ pub mod size_suffix; #[path = "../roots/uorust_certified_some_of.rs"] pub mod some_of; +/// `uorust::lift::some`, certified as `Behavior::someValue`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_some_value.rs"] +pub mod some_value; + /// `uorust::lift::state_expr`, certified as `Behavior::stateExpr`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] #[path = "../roots/uorust_certified_state_expr.rs"] pub mod state_expr; +/// `uorust::lift::std_path`, certified as `Behavior::stdPath`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_std_path.rs"] +pub mod std_path; + +/// `uorust::lift::struct_cells`, certified as `Behavior::structCells`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_struct_cells.rs"] +pub mod struct_cells; + +/// `uorust::lift::struct_value`, certified as `Behavior::structValue`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_struct_value.rs"] +pub mod struct_value; + /// `uorust::lift::then_rest`, certified as `Behavior::thenRest`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -768,35 +840,17 @@ pub mod trial_admits; #[path = "../roots/uorust_certified_tuple_item.rs"] pub mod tuple_item; -/// `uorust::lift::tuple_value`, certified as `Behavior::tupleValue`. -#[rustfmt::skip] -#[allow(missing_docs, dead_code, clippy::all)] -#[path = "../roots/uorust_certified_tuple_value.rs"] -pub mod tuple_value; - -/// `uorust::lift::Ty::entry`, certified as `Behavior::tyEntry`. -#[rustfmt::skip] -#[allow(missing_docs, dead_code, clippy::all)] -#[path = "../roots/uorust_certified_ty_entry.rs"] -pub mod ty_entry; - -/// `uorust::lift::Ty::render`, certified as `Behavior::tyRender`. +/// `uorust::lift::tuple_struct`, certified as `Behavior::tupleStruct`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] -#[path = "../roots/uorust_certified_ty_render.rs"] -pub mod ty_render; +#[path = "../roots/uorust_certified_tuple_struct.rs"] +pub mod tuple_struct; -/// `uorust::lift::Ty::same`, certified as `Behavior::tySame`. -#[rustfmt::skip] -#[allow(missing_docs, dead_code, clippy::all)] -#[path = "../roots/uorust_certified_ty_same.rs"] -pub mod ty_same; - -/// `uorust::lift::Ty::tag`, certified as `Behavior::tyTag`. +/// `uorust::lift::tuple_value`, certified as `Behavior::tupleValue`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] -#[path = "../roots/uorust_certified_ty_tag.rs"] -pub mod ty_tag; +#[path = "../roots/uorust_certified_tuple_value.rs"] +pub mod tuple_value; /// `uorust::lift::Types::accessor`, certified as `Behavior::typesAccessor`. #[rustfmt::skip] @@ -810,6 +864,12 @@ pub mod types_accessor; #[path = "../roots/uorust_certified_types_boxed.rs"] pub mod types_boxed; +/// `uorust::lift::Types::declares`, certified as `Behavior::typesDeclares`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_types_declares.rs"] +pub mod types_declares; + /// `uorust::lift::Types::family_of`, certified as `Behavior::typesFamilyOf`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -834,6 +894,12 @@ pub mod types_resolve; #[path = "../roots/uorust_certified_types_size_name.rs"] pub mod types_size_name; +/// `uorust::lift::Types::unnamed`, certified as `Behavior::typesUnnamed`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_types_unnamed.rs"] +pub mod types_unnamed; + /// `uorust::lift::unicode_property`, certified as `Behavior::unicodeProperty`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -852,6 +918,12 @@ pub mod uninhabited; #[path = "../roots/uorust_certified_unop.rs"] pub mod unop; +/// `uorust::lift::unread_shape`, certified as `Behavior::unreadShape`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_unread_shape.rs"] +pub mod unread_shape; + /// `uorust::lift::untyped`, certified as `Behavior::untyped`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -864,6 +936,30 @@ pub mod untyped; #[path = "../roots/uorust_certified_uorust_helper.rs"] pub mod uorust_helper; +/// `uorust::lift::Ty::entry`, certified as `Behavior::uorustLiftTyEntry`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_uorust_lift_ty_entry.rs"] +pub mod uorust_lift_ty_entry; + +/// `uorust::lift::Ty::render`, certified as `Behavior::uorustLiftTyRender`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_uorust_lift_ty_render.rs"] +pub mod uorust_lift_ty_render; + +/// `uorust::lift::Ty::same`, certified as `Behavior::uorustLiftTySame`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_uorust_lift_ty_same.rs"] +pub mod uorust_lift_ty_same; + +/// `uorust::lift::Ty::tag`, certified as `Behavior::uorustLiftTyTag`. +#[rustfmt::skip] +#[allow(missing_docs, dead_code, clippy::all)] +#[path = "../roots/uorust_certified_uorust_lift_ty_tag.rs"] +pub mod uorust_lift_ty_tag; + /// `uorust::mir::core::Scope::core`, certified as `Behavior::uorustMirCoreScopeCore`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] @@ -888,11 +984,11 @@ pub mod uorust_mir_core_scope_registry; #[path = "../roots/uorust_certified_uorust_mir_layout_refusal_text.rs"] pub mod uorust_mir_layout_refusal_text; -/// `uorust::mir::generate::sha256`, certified as `Behavior::uorustSha256`. +/// `uorust::lift::variant_field`, certified as `Behavior::variantField`. #[rustfmt::skip] #[allow(missing_docs, dead_code, clippy::all)] -#[path = "../roots/uorust_certified_uorust_sha256.rs"] -pub mod uorust_sha256; +#[path = "../roots/uorust_certified_variant_field.rs"] +pub mod variant_field; /// `uorust::lift::variant_owner`, certified as `Behavior::variantOwner`. #[rustfmt::skip] diff --git a/crates/certified/targets.json b/crates/certified/targets.json index 2e7ee1bf..65849e36 100644 --- a/crates/certified/targets.json +++ b/crates/certified/targets.json @@ -1 +1 @@ -{"spec":"lexlean/target-descriptors/1","targets":[{"allocation":false,"digest":"62c2e726c8ecf9006db5cbb3f0b3eda35053adccf2c61dd259048077681c2779","id":"rust-core","integer_bits":64,"natural_bits":64,"renderer":"9485cdbc755f0333d26820d82630b6c77c89aa77861bf1d39f8de3fee687e850","runtime":"f3c11eef9db0785d5d20c987c971a7b4fc5f6d187f60082f8982d3d33dd76408","spec":"lexlean/target-descriptor/1","statement":"Safe Rust using only the core library: no heap allocation, 64-bit natural and integer representations."},{"allocation":true,"digest":"957f6e9a7a87b504094f9c5d0ed9305aad7cbee156bba670acc8bda99db5224c","id":"rust-std","integer_bits":64,"natural_bits":64,"renderer":"9485cdbc755f0333d26820d82630b6c77c89aa77861bf1d39f8de3fee687e850","runtime":"4bb6ab6dc7e2fc1a587876290fac070f499170ff7609aee0fd924aa8fd7bcab7","spec":"lexlean/target-descriptor/1","statement":"Safe Rust with the standard library: heap allocation, 64-bit natural and integer representations."}]} +{"spec":"lexlean/target-descriptors/1","targets":[{"allocation":false,"digest":"8b3e80b4c157feb88808a57a2f91c28fcb8bee10ed2b7288d784342f291b34a4","id":"rust-core","integer_bits":64,"natural_bits":64,"renderer":"c23c935fae8719dcd578e0fd1e6fb7ade20a2cc72b58e51600af1d7e96e4cffd","runtime":"f3c11eef9db0785d5d20c987c971a7b4fc5f6d187f60082f8982d3d33dd76408","spec":"lexlean/target-descriptor/1","statement":"Safe Rust using only the core library: no heap allocation, 64-bit natural and integer representations."},{"allocation":true,"digest":"d664a7da9c2a8d81a49a5418c842ab5a99550375cd506b5c46c5e4fcc35d1371","id":"rust-std","integer_bits":64,"natural_bits":64,"renderer":"c23c935fae8719dcd578e0fd1e6fb7ade20a2cc72b58e51600af1d7e96e4cffd","runtime":"72477f9e44fe54531b9c68f2b547db7300563373df9d8d29fa5632b8a9d7c14c","spec":"lexlean/target-descriptor/1","statement":"Safe Rust with the standard library: heap allocation, 64-bit natural and integer representations."}]} diff --git a/crates/conformance/tests/factory.rs b/crates/conformance/tests/factory.rs new file mode 100644 index 00000000..6740e03f --- /dev/null +++ b/crates/conformance/tests/factory.rs @@ -0,0 +1,230 @@ +//! The `factory` suite: one test per scenario in `features/suites/factory.feature`. +//! +//! The routing, the identity and the graph's theorems are the certified core's +//! and the Lean kernel's (`prism-factory/check.sh`, the `factory-model` +//! obligation, and the host's own tests against Python's `hashlib`). What this +//! test holds fixed is the claim around them: the component is upstream's at +//! the recorded revision, the model text is the one graph's, and the graph +//! declares what it reads. Each part is shown to refuse its planted defect. + +use std::path::{Path, PathBuf}; +use std::process::Command; + +fn root() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .ancestors() + .nth(2) + .expect("crates/conformance is two below the root") + .to_path_buf() +} + +/// `graph.py check` run on the component at `root`: its exit and its words. +fn factory_check(root: &Path) -> (bool, String) { + let out = Command::new("python3") + .args(["-I", "prism-factory/graph.py", "check"]) + .current_dir(root) + .output() + .expect("python3 runs"); + let words = format!( + "{}{}", + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + (out.status.success(), words) +} + +/// A copy of the component and the Justfile its graph reads, in a fresh +/// directory of its own. +fn factory_copy(label: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("uorust-ue20-{label}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).expect("scratch"); + let status = Command::new("cp") + .args(["-r", "prism-factory", "Justfile"]) + .arg(&dir) + .current_dir(root()) + .status() + .expect("cp runs"); + assert!(status.success()); + dir +} + +fn factory_edit(path: &Path, from: &str, to: &str) { + let text = std::fs::read_to_string(path).expect("readable"); + assert!(text.contains(from), "{} lacks {from:?}", path.display()); + std::fs::write(path, text.replacen(from, to, 1)).expect("writable"); +} + +/// `UE-20`: The gate, the writers and the certified export are obligations of the upstream Prism factory installed under prism-factory/: its engine, standard library and identity protocol are upstream's at the revision prism-factory/upstream.toml names and an installed file that differs from what that record states is refused, the graph's one source is prism-factory/graph.toml with the Justfile's recipe bodies and a model text or table that differs from what graph.py writes from them is refused, no obligation reads the whole tree, one run in the SDK declares the lock that pins the image and the launcher, the certified plan routes each obligation proved, observe, refuted or blocked from receipts of its identity, a test target that names or a compiled source that embeds a tracked file its obligation does not declare is refused before the plan, each obligation runs in a closure that is its own repository whose parent holds exactly the base entries it declares, under a work directory no cargo or rustup configuration sits above, a command stopped by a signal leaves no receipt, and one run at a time holds the receipt store +#[test] +fn factory_ue_20() { + let (passed, words) = factory_check(&root()); + assert!( + passed, + "the committed component fails its own check:\n{words}" + ); + let record = + std::fs::read_to_string(root().join("prism-factory/upstream.toml")).expect("upstream.toml"); + assert!(record.contains("path = \"model/src/Factory/Engine.lex.tex\"\nhow = \"identical\"")); + assert!(record.contains("path = \"std/src/Sha256.lex.tex\"\nhow = \"identical\"")); + let model = + std::fs::read_to_string(root().join("prism-factory/model/src/Factory/UORust.lex.tex")) + .expect("model"); + for theorem in [ + "no_obligation_reads_the_whole_tree", + "every_obligation_in_the_sdk_declares_its_image_and_its_launcher", + "every_need_is_declared_before_it_is_needed", + ] { + assert!( + model.contains(&format!(" name: {theorem},\n")), + "{theorem}" + ); + } + let root_module = + std::fs::read_to_string(root().join("prism-factory/model/src/Factory.lex.tex")) + .expect("root"); + assert!( + root_module.contains("(Factory.Engine::planAll (Factory.UORust::graph)"), + "the plan root plans this graph" + ); + + // An installed upstream file drifts: refused, naming the file. + let drifted = factory_copy("drift"); + factory_edit( + &drifted.join("prism-factory/model/src/Factory/Engine.lex.tex"), + "\"hermetic\"", + "\"sealed\"", + ); + let (passed, words) = factory_check(&drifted); + assert!( + !passed && words.contains("model/src/Factory/Engine.lex.tex: differs"), + "{words}" + ); + + // A recipe the graph runs changes, the model text does not: refused. + let stale = factory_copy("stale"); + factory_edit( + &stale.join("Justfile"), + "cargo deny --all-features check", + "cargo deny check", + ); + let (passed, words) = factory_check(&stale); + assert!( + !passed && words.contains("UORust.lex.tex is not what graph.py writes"), + "{words}" + ); + + // An obligation that reads the whole tree: refused before anything is written. + let whole = factory_copy("whole"); + factory_edit( + &whole.join("prism-factory/graph.toml"), + "inputs = [\"deny.toml\"]", + "inputs = [\"deny.toml\", \"\"]", + ); + let (passed, words) = factory_check(&whole); + assert!( + !passed && words.contains("deny reads the whole tree"), + "{words}" + ); + + // An SDK obligation without the lock that pins the image: refused. + let unpinned = factory_copy("unpinned"); + factory_edit( + &unpinned.join("prism-factory/graph.toml"), + "sdk = [\"prismpm.lock\", \"prism-factory/sdk.sh\"]", + "sdk = [\"prism-factory/sdk.sh\"]", + ); + let (passed, words) = factory_check(&unpinned); + assert!( + !passed && words.contains("without declaring prismpm.lock"), + "{words}" + ); + + for dir in [drifted, stale, whole, unpinned] { + let _ = std::fs::remove_dir_all(dir); + } +} + +// Class: the factory's closure (refute-factory-6: `test` read prism-factory/ +// and the brand's stylesheet without declaring them). `graph.py reads`, run +// by the entry on a checkout before it plans, refuses an obligation whose test +// target names, or whose compiled source embeds, a tracked file the +// obligation does not declare; declaring it lifts the refusal. + +/// `graph.py reads` on the component at `root`: its exit and its words. +fn closure_reads(root: &Path) -> (bool, String) { + let out = Command::new("python3") + .args(["-I", "prism-factory/graph.py", "reads"]) + .current_dir(root) + .output() + .expect("python3 runs"); + let words = format!( + "{}{}", + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + (out.status.success(), words) +} + +/// A checkout of the component with one workspace member whose test reads +/// `brand/planted.css` and whose library embeds `site/planted.txt`. +fn closure_checkout(label: &str) -> PathBuf { + let dir = factory_copy(label); + let files = [ + ("Cargo.toml", "[workspace]\nmembers = [\"crates/*\"]\n"), + ( + "crates/probe/Cargo.toml", + "[package]\nname = \"probe\"\nversion = \"0.0.0\"\n", + ), + ( + "crates/probe/src/lib.rs", + "pub const PLANTED: &str = include_str!(\"../../../site/planted.txt\");\n", + ), + ( + "crates/probe/tests/probe.rs", + "#[test]\nfn reads() {\n let root = std::path::Path::new(env!(\"CARGO_MANIFEST_DIR\")).join(\"../..\");\n std::fs::read_to_string(root.join(\"brand/planted.css\")).unwrap();\n}\n", + ), + ("brand/planted.css", ":root {}\n"), + ("site/planted.txt", "planted\n"), + ]; + for (path, text) in files { + let target = dir.join(path); + std::fs::create_dir_all(target.parent().expect("a parent")).expect("scratch"); + std::fs::write(target, text).expect("writable"); + } + for args in [vec!["init", "--quiet"], vec!["add", "--all"]] { + let status = Command::new("git") + .args(&args) + .current_dir(&dir) + .status() + .expect("git runs"); + assert!(status.success(), "git {args:?}"); + } + dir +} + +#[test] +fn an_undeclared_read_of_a_test_or_an_embedded_file_is_refused_ue_20() { + let planted = closure_checkout("reads"); + let (passed, words) = closure_reads(&planted); + assert!(!passed, "{words}"); + assert!( + words.contains("test reads brand/planted.css (crates/probe/tests/probe.rs:4)"), + "{words}" + ); + assert!( + words.contains("lint embeds site/planted.txt (crates/probe/src/lib.rs:1)"), + "{words}" + ); + // Declared where it is read, nothing is refused. + let graph = planted.join("prism-factory/graph.toml"); + factory_edit( + &graph, + " \"brand/foundation/src/index.css\",\n", + " \"brand/foundation/src/index.css\",\n \"brand/planted.css\",\n \"site/planted.txt\",\n", + ); + factory_edit(&graph, "rust = [\n", "rust = [\n \"site/planted.txt\",\n"); + let (passed, words) = closure_reads(&planted); + assert!(passed, "{words}"); + let _ = std::fs::remove_dir_all(planted); +} diff --git a/crates/conformance/tests/ratchet.rs b/crates/conformance/tests/ratchet.rs index 4a6f42e7..d7e85af0 100644 --- a/crates/conformance/tests/ratchet.rs +++ b/crates/conformance/tests/ratchet.rs @@ -57,28 +57,54 @@ fn manifest_at(root: &Path, text: Option) -> Manifest { } } -#[test] -fn the_hand_written_translator_only_shrinks_ue_18() { - let root = root(); +/// Whether the base must be there. CI checks out the whole history +/// (fetch-depth: 0). The Prism factory runs this suite in a closure that is its +/// own repository, whose parent commit holds the base entries `test` declares +/// (`@base:frontier.toml`, `@base:crates/certified/manifest.toml`), and its +/// host names the obligation (`FACTORY_KAPPA`). In either place, a missing base +/// means the comparison cannot be made, so UE-18 fails instead of passing +/// undecided. +fn base_required() -> bool { + std::env::var_os("CI").is_some() || std::env::var_os("FACTORY_KAPPA").is_some() +} + +/// UE-18 at `root`: refused when more translator functions are uncertified +/// than under the base. Without a base it passes only where none is +/// `required` (a checkout without history, outside CI and the factory). +fn ue_18(root: &Path, required: bool) -> Result<(), String> { let head_text = std::fs::read_to_string(root.join(REGISTER)).expect("frontier.toml"); let head = Register::parse(&root.join(REGISTER), &head_text).expect("the register parses"); - let head_manifest = manifest_at(&root, std::fs::read_to_string(root.join(MANIFEST)).ok()); - let Some(rev) = base(&root) else { - // A checkout without the parent cannot be compared; CI checks out - // the whole history (fetch-depth: 0), so this never decides there. - assert!( - std::env::var_os("CI").is_none(), - "CI must check out the parent commit to decide the ratchet" - ); - return; + let head_manifest = manifest_at(root, std::fs::read_to_string(root.join(MANIFEST)).ok()); + let Some(rev) = base(root) else { + if required { + return Err( + "UE-18 has no base to compare: CI must check out the parent commit, \ + and a factory closure must declare @base:frontier.toml and \ + @base:crates/certified/manifest.toml" + .into(), + ); + } + return Ok(()); }; - let Some(base_text) = git(&root, &["show", &format!("{rev}:{REGISTER}")]) else { - return; + let Some(base_text) = git(root, &["show", &format!("{rev}:{REGISTER}")]) else { + if required { + return Err(format!( + "UE-18: the base {rev} holds no {REGISTER} to compare" + )); + } + return Ok(()); }; let base = Register::parse(Path::new(REGISTER), &base_text).expect("the base register parses"); - let base_manifest = manifest_at(&root, git(&root, &["show", &format!("{rev}:{MANIFEST}")])); - if let Err(refusal) = ratchet(&head, &head_manifest, &base, &base_manifest) { - panic!("UE-18 against {rev}: {refusal}"); + let base_manifest = manifest_at(root, git(root, &["show", &format!("{rev}:{MANIFEST}")])); + ratchet(&head, &head_manifest, &base, &base_manifest) + .map(|_| ()) + .map_err(|refusal| format!("UE-18 against {rev}: {refusal}")) +} + +#[test] +fn the_hand_written_translator_only_shrinks_ue_18() { + if let Err(refusal) = ue_18(&root(), base_required()) { + panic!("{refusal}"); } } @@ -106,3 +132,72 @@ fn a_grown_translator_is_refused_ue_18() { "{message}" ); } + +// Class: the factory's closure (refute-factory-6, UE-18 read the parent from +// history the identity did not cover). In a closure the base is a declared +// input; a closure without it fails UE-18 instead of skipping it, and a closure +// whose parent commit holds the base decides against it. + +/// A fresh directory holding the head's register and manifest; with `parent`, +/// a repository of two commits whose first holds `parent` as the register. +fn closure_ue_18(label: &str, parent: Option<&str>, head: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("uorust-ue18-{label}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(dir.join("crates/certified")).expect("scratch"); + let manifest = std::fs::read_to_string(root().join(MANIFEST)).unwrap_or_default(); + std::fs::write(dir.join(MANIFEST), &manifest).expect("manifest"); + let commit = |message: &str| { + for args in [ + vec!["add", "--all"], + vec![ + "-c", + "user.name=t", + "-c", + "user.email=t@t", + "-c", + "commit.gpgsign=false", + "commit", + "--quiet", + "--allow-empty", + "-m", + message, + ], + ] { + assert!(git(&dir, &args).is_some(), "git {args:?}"); + } + }; + if let Some(parent) = parent { + assert!(git(&dir, &["init", "--quiet"]).is_some()); + std::fs::write(dir.join(REGISTER), parent).expect("base register"); + commit("base"); + std::fs::write(dir.join(REGISTER), head).expect("register"); + commit("closure"); + } else { + std::fs::write(dir.join(REGISTER), head).expect("register"); + } + dir +} + +#[test] +fn a_closure_without_its_base_fails_ue_18_and_one_with_it_decides() { + let text = std::fs::read_to_string(root().join(REGISTER)).expect("frontier.toml"); + let grown = format!( + "{text}\n[[residue]]\nkappa = \"{}\"\nfunction = \"uorust::mir::lower::planted\"\nreason = \"mir\"\ndetail = \"mir::Rvalue::Use\"\n", + "0".repeat(64) + ); + // No history: undecided, so it fails where a base is required and passes elsewhere. + let bare = closure_ue_18("bare", None, &grown); + let refusal = ue_18(&bare, true).expect_err("a required base that is absent fails"); + assert!(refusal.contains("@base:frontier.toml"), "{refusal}"); + assert!(ue_18(&bare, false).is_ok()); + // The parent holds the base: the same grown head is refused against it, + // and an unchanged head passes. + let grew = closure_ue_18("grew", Some(&text), &grown); + let refusal = ue_18(&grew, true).expect_err("a grown translator is refused against the base"); + assert!(refusal.contains("uorust::mir::lower::planted"), "{refusal}"); + let same = closure_ue_18("same", Some(&text), &text); + assert!(ue_18(&same, true).is_ok()); + for dir in [bare, grew, same] { + let _ = std::fs::remove_dir_all(dir); + } +} diff --git a/crates/uorust/src/admit.rs b/crates/uorust/src/admit.rs index ae356bf6..377ca281 100644 --- a/crates/uorust/src/admit.rs +++ b/crates/uorust/src/admit.rs @@ -20,6 +20,13 @@ pub(crate) enum Refusal { Unaccepted { span: Span, feature: String }, /// Two facts project to the same LexLean name. Collision { span: Span, name: String }, + /// An item stands under a `cfg` predicate the projected configuration + /// compiles out, beside the variant of it the projection states. + CfgVariant { + span: Span, + name: String, + predicate: String, + }, /// A state machine has no `#[default]` variant and no unique source state. NoInitialState { span: Span, machine: String }, /// A fact carries two tags the router routes differently. @@ -56,6 +63,7 @@ impl Refusal { Self::ExternalPath { .. } => "external-path-dependency", Self::Unaccepted { .. } => "feature-without-acceptance", Self::Collision { .. } => "name-collision", + Self::CfgVariant { .. } => "cfg-variant", Self::NoInitialState { .. } => "no-initial-state", Self::NoMsrv { .. } => "no-msrv", Self::AmbiguousFact { .. } => "ambiguous-fact", @@ -71,7 +79,7 @@ impl Refusal { Self::AmbiguousCall { .. } => "UR-R27", Self::ExternalPath { .. } => "UR-R05", Self::Unaccepted { .. } => "UR-R10", - Self::Collision { .. } => "UR-R13", + Self::Collision { .. } | Self::CfgVariant { .. } => "UR-R13", Self::NoInitialState { .. } | Self::AmbiguousFact { .. } => "UR-R26", Self::NoMsrv { .. } => "UR-R24", Self::AdvisoriesUnconsulted | Self::UnansweredAdvisory { .. } => "UR-R21", @@ -85,6 +93,7 @@ impl Refusal { | Self::AmbiguousCall { span, .. } | Self::Unaccepted { span, .. } | Self::Collision { span, .. } + | Self::CfgVariant { span, .. } | Self::NoInitialState { span, .. } | Self::AmbiguousFact { span, .. } => span.render(), Self::ExternalPath { package, .. } @@ -118,6 +127,12 @@ impl Refusal { Self::Collision { name, .. } => { format!("{name} is the projection of more than one fact") } + Self::CfgVariant { + name, predicate, .. + } => format!( + "{name} has a variant under cfg({predicate}), which the projected \ + configuration compiles out; the projection states the variant it compiles" + ), Self::NoInitialState { machine, .. } => format!( "{machine} has no #[default] variant and no unique state that no transition \ enters" diff --git a/crates/uorust/src/certified.rs b/crates/uorust/src/certified.rs index 8fe2a5b1..0dc4df38 100644 --- a/crates/uorust/src/certified.rs +++ b/crates/uorust/src/certified.rs @@ -138,6 +138,19 @@ pub(crate) fn lift_evidence_proof(p0: &&[std::string::String]) -> Option Option { + Some( + match uorust_certified::field_name::run(uorust_certified::field_name::Str::lit((*p0))) { + Ok(v) => v, + Err(_) => panic!("uorust::lift::field_name: the certified root overflowed"), + } + .text() + .to_string(), + ) +} + /// `uorust::lift::first_free`, certified as `Behavior::firstFree`. #[allow(clippy::all, non_snake_case, unused_parens)] pub(crate) fn lift_first_free( @@ -163,6 +176,30 @@ pub(crate) fn lift_first_free( ) } +/// `uorust::lift::is_lifetime`, certified as `Behavior::isLifetime`. +#[allow(clippy::all, non_snake_case, unused_parens)] +pub(crate) fn lift_is_lifetime(p0: &&str) -> Option { + Some( + match uorust_certified::is_lifetime::run(uorust_certified::is_lifetime::Str::lit((*p0))) { + Ok(v) => v, + Err(_) => panic!("uorust::lift::is_lifetime: the certified root overflowed"), + }, + ) +} + +/// `uorust::lift::local_name`, certified as `Behavior::localName`. +#[allow(clippy::all, non_snake_case, unused_parens)] +pub(crate) fn lift_local_name(p0: &&str) -> Option { + Some( + match uorust_certified::local_name::run(uorust_certified::local_name::Str::lit((*p0))) { + Ok(v) => v, + Err(_) => panic!("uorust::lift::local_name: the certified root overflowed"), + } + .text() + .to_string(), + ) +} + /// `uorust::lift::mentions_word`, certified as `Behavior::mentionsWord`. #[allow(clippy::all, non_snake_case, unused_parens)] pub(crate) fn lift_mentions_word(p0: &&str, p1: &&str) -> Option { @@ -177,6 +214,15 @@ pub(crate) fn lift_mentions_word(p0: &&str, p1: &&str) -> Option { ) } +/// `uorust::lift::name_taken`, certified as `Behavior::nameTaken`. +#[allow(clippy::all, non_snake_case, unused_parens)] +pub(crate) fn lift_name_taken(p0: &&str, p1: &bool) -> Option { + Some(uorust_certified::name_taken::run( + uorust_certified::name_taken::Str::lit((*p0)), + *p1, + )) +} + /// `uorust::lift::pointer_width`, certified as `Behavior::pointerWidth`. #[allow(clippy::all, non_snake_case, unused_parens)] pub(crate) fn lift_pointer_width(p0: &&str) -> Option> { diff --git a/crates/uorust/src/certify.rs b/crates/uorust/src/certify.rs index bfc7cf00..897eafbe 100644 --- a/crates/uorust/src/certify.rs +++ b/crates/uorust/src/certify.rs @@ -19,6 +19,16 @@ //! from the projection that lifts it. [`ratchet`] refuses a register and a //! manifest under which more translator functions are uncertified than under //! the parent's, naming each new one with its cause. +//! +//! None of it is the translator's alone. A [`Profile`] says what an export +//! is of: the scope, the entry, the package prefix, the effects and the +//! target. The constants below are the translator's own profile, the default +//! of every step, so its gate reads as before; any other workspace states +//! its own (`--workspace`, the table of its Cargo manifest, the command's +//! options) and has every lifted function in its scope exported, taken into +//! a directory it names and held by the same ratchet. Its agreement is +//! [`cases`]: the closed assertions of its own tests, each a production +//! root of its own. use std::collections::{BTreeMap, BTreeSet}; use std::path::{Path, PathBuf}; @@ -29,6 +39,11 @@ use crate::mir::{Dumps, IrBody}; use crate::register::{Register, Status}; use crate::UorustError; +pub mod cases; +mod profile; + +pub use profile::{Kind, Options, Profile, PROFILE}; + /// The modules of the translator, by their crate paths. pub const SCOPE: &[&str] = &["uorust::mir::", "uorust::lift::", "uorust::lex::"]; @@ -42,6 +57,10 @@ pub const SCHEMA: &str = "uorust/certified/1"; /// The prefix of every certified package's name. pub const PACKAGE: &str = "uorust_certified_"; +/// The version every certified package is requested at, and the crate that +/// holds them is written at. +const PACKAGE_VERSION: &str = "0.1.0"; + /// The effects every root admits: the whole closed registry of SPEC §17.13. /// The translator builds strings and lists (allocation), computes on /// naturals of unbounded width (overflow, an explicit failure at the @@ -67,13 +86,28 @@ pub struct Root { pub kappa: String, /// The definition in the projection's `Behavior` module, unqualified. pub definition: String, + /// The prefix of its package's name, the profile's. + pub prefix: String, } +/// The most characters a crate's name has, as the compiler states the rule +/// (`LLC0201`: a crate name is `[a-z][a-z0-9_]{0,63}`). +const CRATE_NAME: usize = 64; + +/// The hexadecimal digits of the SHA-256 of a longer name that end its +/// shortened form: a quarter of the digest, 64 bits, which no two roots of a +/// workspace share by chance; two that did would be refused by name +/// ([`Profile::export_roots`]). +const NAME_DIGEST: usize = CRATE_NAME / 4; + impl Root { - /// The certified package's name: [`PACKAGE`] and the definition in - /// snake case. + /// The certified package's name: the profile's prefix ([`PACKAGE`], for + /// the translator) and the definition in snake case. A name longer than + /// a crate's may be ([`CRATE_NAME`]) keeps its start and ends with the + /// first [`NAME_DIGEST`] digits of its own SHA-256, so it is still the + /// root's alone and the same at every export. pub fn package(&self) -> String { - let mut out = PACKAGE.to_string(); + let mut out = self.prefix.clone(); for c in self.definition.chars() { if c.is_ascii_uppercase() { out.push('_'); @@ -82,32 +116,88 @@ impl Root { out.push(c); } } - out + if out.chars().count() <= CRATE_NAME { + return out; + } + let digest = crate::project::sha(out.as_bytes()); + let kept: String = out.chars().take(CRATE_NAME - NAME_DIGEST - 1).collect(); + format!("{kept}_{}", &digest[..NAME_DIGEST]) } } /// The production roots of a register: every lifted translator function, by /// definition. pub fn roots(register: &Register) -> Vec { - let mut out: Vec = register - .rows - .iter() - .filter(|(_, row)| in_scope(&row.function)) - .filter_map(|(kappa, row)| match &row.status { - Status::Lifted(definition) => Some(Root { - function: row.function.clone(), - kappa: kappa.clone(), - definition: definition - .rsplit("::") - .next() - .unwrap_or(definition) - .to_string(), - }), - _ => None, - }) - .collect(); - out.sort_by(|a, b| a.definition.cmp(&b.definition)); - out + Profile::default().roots(register) +} + +impl Profile { + /// The function roots of a register under this profile: every lifted + /// function in its scope, by definition. + pub fn roots(&self, register: &Register) -> Vec { + let mut out: Vec = register + .rows + .iter() + .filter(|(_, row)| self.in_scope(&row.function)) + .filter_map(|(kappa, row)| match &row.status { + Status::Lifted(definition) => Some(Root { + function: row.function.clone(), + kappa: kappa.clone(), + definition: definition + .rsplit("::") + .next() + .unwrap_or(definition) + .to_string(), + prefix: self.package.clone(), + }), + _ => None, + }) + .collect(); + out.sort_by(|a, b| a.definition.cmp(&b.definition)); + out + } + + /// The roots of an export under this profile: its functions, or, of a + /// cases export, the closed assertions the projection at `projection` + /// states over them. + pub fn export_roots( + &self, + projection: &Path, + register: &Register, + ) -> Result, UorustError> { + let roots: Vec = match self.kind { + Kind::Functions => self.roots(register), + Kind::Cases => cases::cases(self, &modules(projection)?, register) + .into_iter() + .map(|c| c.root) + .collect(), + }; + // A package is one root's: two definitions that come to one name + // would have one certify the other's function. + let mut packages: BTreeMap = BTreeMap::new(); + for root in &roots { + if let Some(other) = packages.insert(root.package(), &root.definition) { + return Err(UorustError::Tool(format!( + "the definitions {other} and {} come to one package name, {}", + root.definition, + root.package() + ))); + } + } + Ok(roots) + } +} + +/// The modules of a projection a root's closure lies in, by name, with +/// their texts: `Behavior`, and the `Prelude` it imports. +pub(crate) fn modules(projection: &Path) -> Result, UorustError> { + let mut modules = BTreeMap::new(); + for module in [BEHAVIOR, "Prelude"] { + let path = projection.join("src").join(format!("{module}.lex.tex")); + let text = std::fs::read_to_string(&path).map_err(|e| io(&path, e))?; + modules.insert(module.to_string(), text); + } + Ok(modules) } /// Write the production project: the projection at `projection` with every @@ -117,6 +207,7 @@ pub fn roots(register: &Register) -> Vec { /// targets`), restricted to the definitions of `batch` when it is given. /// Returns the roots the request names, by definition. pub fn production( + profile: &Profile, projection: &Path, out: &Path, register: &Register, @@ -128,23 +219,18 @@ pub fn production( path: path.to_path_buf(), reason, }; - let digest = descriptor(targets)?; + let digest = profile.descriptor(targets)?; let prefix = module_prefix(projection)?; copy_tree(projection, out)?; - let roots = roots(register); + let roots = profile.export_roots(projection, register)?; let names: BTreeSet<&str> = roots.iter().map(|r| r.definition.as_str()).collect(); - let mut modules = BTreeMap::new(); - for module in [BEHAVIOR, "Prelude"] { - let path = out.join("src").join(format!("{module}.lex.tex")); - let text = std::fs::read_to_string(&path).map_err(|e| io(&path, e))?; - modules.insert(module.to_string(), text); - } + let modules = modules(out)?; let exported: BTreeSet<&str> = names .iter() .copied() .filter(|n| !compiler.contains_key(*n)) .collect(); - let (mut marked, found, mut refused) = mark(&modules, &exported); + let (mut marked, found, mut refused) = profile.mark(&modules, &exported); // The compiler generates a package for every root the source marks, so // a batch marks only its own roots, and their closures executable. if let Some(batch) = batch { @@ -153,7 +239,7 @@ pub fn production( .copied() .filter(|n| batch.contains(*n)) .collect(); - marked = mark(&modules, &own).0; + marked = profile.mark(&modules, &own).0; } refused.extend(compiler.iter().map(|(k, v)| (k.clone(), v.clone()))); if let Some(missing) = names @@ -194,9 +280,9 @@ pub fn production( .map(|r| { let root = format!("{prefix}.Behavior.{}", r.definition); let entry = serde_json::json!({ - "package": {"name": r.package(), "version": "0.1.0"}, + "package": {"name": r.package(), "version": PACKAGE_VERSION}, "root": root, - "targets": [{"digest": digest, "id": TARGET}], + "targets": [{"digest": digest, "id": profile.target}], }); (root, entry) }) @@ -240,48 +326,32 @@ const MAX_SHARDS: usize = 64; /// whose refusal is the compiler's own (`LLB6005`, or `LLV7015` built alone), whose full /// diagnostics the diagnose job keeps. pub fn plan(register: &Register, prior: &Manifest, budget: u64) -> (usize, Vec) { - let all = roots(register); - let refused = |r: &&Root| { - prior.refused.contains_key(&r.kappa) && !prior.refused[&r.kappa].starts_with(UNBUILT) - }; - let to_build = all.iter().filter(|r| !refused(r)).count(); - let per_root = prior - .seconds_per_root - .unwrap_or(MEASURED_SECONDS_PER_ROOT) - .max(1); - let per_shard = usize::try_from(budget / (per_root * BUILDS_PER_SHARD)) - .unwrap_or(usize::MAX) - .clamp(1, MAX_ROOTS_PER_SHARD); - let shards = to_build.div_ceil(per_shard).clamp(1, MAX_SHARDS); - let diagnose = all - .iter() - .filter(|r| { - prior - .refused - .get(&r.kappa) - .is_some_and(|c| c.starts_with(ALONE) || c.starts_with("LLB6005")) - }) - .map(|r| r.definition.clone()) - .collect(); - (shards, diagnose) + plan_of(&roots(register), prior, budget) +} + +/// [`plan`] over the roots of any export. +pub fn plan_of(all: &[Root], prior: &Manifest, budget: u64) -> (usize, Vec) { + let plan = plan_keyed(all, None, prior, budget); + (plan.shards, plan.diagnose) } /// Build `root` alone in a production project at `out` and keep, in /// `out/build.log`, everything `lexlean production build` prints in human /// form: a refusal's whole diagnostic, which the JSON form cuts short. -pub fn diagnose( - projection: &Path, - out: &Path, - register: &Register, - targets: &str, - root: &str, -) -> Result<(), UorustError> { - descriptor(targets)?; +pub fn diagnose(input: &Input<'_>, out: &Path, root: &str) -> Result<(), UorustError> { + let Input { + profile, + projection, + register, + targets, + } = *input; + profile.descriptor(targets)?; if out.exists() { std::fs::remove_dir_all(out).map_err(|e| io(out, e))?; } let only: BTreeSet = [root.to_string()].into_iter().collect(); let named = production( + profile, projection, out, register, @@ -313,25 +383,191 @@ pub fn diagnose( std::fs::write(&log, text).map_err(|e| io(&log, e)) } -/// The digest of the [`TARGET`] descriptor in `targets` (the output of -/// `lexlean production targets`). -fn descriptor(targets: &str) -> Result { - let bad = |reason: String| UorustError::Malformed { - path: PathBuf::from("targets.json"), - reason, +/// What an export reads: its profile, the projection, the projection's +/// register, and the target descriptors (the output of `lexlean production +/// targets`). +#[derive(Clone, Copy, Debug)] +pub struct Input<'a> { + /// What the export is of. + pub profile: &'a Profile, + /// The projection (`uorust project --out ...`). + pub projection: &'a Path, + /// Its lift register. + pub register: &'a Register, + /// The target descriptors. + pub targets: &'a str, +} + +/// What a check of an export's roots decided, without a build. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Admission { + /// The roots of the export. + pub roots: usize, + /// Those the compiler admits, by definition. + pub admitted: Vec, + /// Those refused, by κ, with their causes. + pub refused: BTreeMap, + /// The module prefix of the projection, which starts every name of its + /// own a diagnostic quotes. + pub prefix: String, +} + +impl Admission { + /// The causes of the refusals, each as its class ([`class`]), with the + /// roots it refuses: the most first. + pub fn causes(&self) -> Vec<(String, usize)> { + let mut counts: BTreeMap = BTreeMap::new(); + for cause in self.refused.values() { + *counts.entry(class(cause, &self.prefix)).or_default() += 1; + } + let mut out: Vec<(String, usize)> = counts.into_iter().collect(); + out.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0))); + out + } +} + +/// The class of a refusal's cause: its first line in the compiler's own +/// terms, without what is the project's. Each quoted name of the project +/// (`..`) and each definition named by its module +/// (`Module::name`) is `_`, and the closing parenthesis that locates the +/// violation in the project is left out. +pub(crate) fn class(cause: &str, prefix: &str) -> String { + let line = cause.lines().next().unwrap_or_default(); + let line = match line.rfind(" (") { + Some(at) if line.ends_with(')') => &line[..at], + _ => line, + }; + let own = format!("{prefix}."); + let mut out = String::new(); + for (i, part) in line.split('`').enumerate() { + if i % 2 == 1 { + let name = if part.starts_with(&own) { "_" } else { part }; + out.push_str(&format!("`{name}`")); + continue; + } + let words: Vec<&str> = part + .split(' ') + .map(|w| if w.contains("::") { "_" } else { w }) + .collect(); + out.push_str(&words.join(" ")); + } + out +} + +/// Decide which roots of an export the compiler admits, without a build: +/// the production project at `out` with every root marked is checked by +/// `lexlean check`, which types the project and decides each root's +/// eligibility (SPEC §17.13) and runs no Lean; each root a diagnostic names +/// is refused with it and the rest are checked again, until the check +/// passes. What is left are the roots a build is asked for: the kernel's +/// own refusals are a build's to find. +pub fn admit_roots(input: &Input<'_>, out: &Path) -> Result { + let Input { + profile, + projection, + register, + targets, + } = *input; + let all = profile.export_roots(projection, register)?; + let prefix = format!("{}.{BEHAVIOR}.", module_prefix(projection)?); + let mut compiler: BTreeMap = BTreeMap::new(); + let admitted = loop { + if out.exists() { + std::fs::remove_dir_all(out).map_err(|e| io(out, e))?; + } + let named = production(profile, projection, out, register, targets, &compiler, None)?; + if named.is_empty() { + break named; + } + lexlean(out, &["lock"])?; + let result = lexlean(out, &["check"])?; + if result.get("success").and_then(serde_json::Value::as_bool) == Some(true) { + break named; + } + let messages = diagnostics(&result); + let refused: BTreeMap = messages + .iter() + .filter_map(|m| first_root(m, &prefix).map(|r| (r, m.clone()))) + .filter(|(r, _)| named.contains(r)) + .collect(); + if refused.is_empty() { + return Err(UorustError::Tool(format!( + "lexlean check: {}", + messages + .first() + .map_or("refused without a diagnostic", String::as_str) + ))); + } + compiler.extend(refused); }; - let descriptors: serde_json::Value = - serde_json::from_str(targets).map_err(|e| bad(e.to_string()))?; - descriptors - .get("targets") - .and_then(|t| t.as_array()) + let path = out.join(REFUSALS); + let text = std::fs::read_to_string(&path).map_err(|e| io(&path, e))?; + let doc: toml::Value = text.parse().map_err(|e| UorustError::Malformed { + path: path.clone(), + reason: format!("{e}"), + })?; + let refused = doc + .get("refused") + .and_then(toml::Value::as_array) .into_iter() .flatten() - .find(|t| t.get("id").and_then(|i| i.as_str()) == Some(TARGET)) - .and_then(|t| t.get("digest")) - .and_then(|d| d.as_str()) - .map(str::to_string) - .ok_or_else(|| bad(format!("no {TARGET} descriptor"))) + .filter_map(|r| { + Some(( + r.get("kappa")?.as_str()?.to_string(), + r.get("cause")?.as_str()?.to_string(), + )) + }) + .collect(); + Ok(Admission { + roots: all.len(), + admitted, + refused, + prefix: module_prefix(projection)?, + }) +} + +impl Profile { + /// The digest of the descriptor of the profile's target ([`TARGET`], for + /// the translator) in `targets` (the output of `lexlean production + /// targets`). + fn descriptor(&self, targets: &str) -> Result { + let bad = |reason: String| UorustError::Malformed { + path: PathBuf::from("targets.json"), + reason, + }; + let descriptors: serde_json::Value = + serde_json::from_str(targets).map_err(|e| bad(e.to_string()))?; + descriptors + .get("targets") + .and_then(|t| t.as_array()) + .into_iter() + .flatten() + .find(|t| t.get("id").and_then(|i| i.as_str()) == Some(self.target.as_str())) + .and_then(|t| t.get("digest")) + .and_then(|d| d.as_str()) + .map(str::to_string) + .ok_or_else(|| bad(format!("no {} descriptor", self.target))) + } + + /// The whole descriptor of the profile's target in `targets`, as JSON + /// text: its renderer and runtime digests with the rest, all of which a + /// root's identity binds. + fn descriptor_text(&self, targets: &str) -> Result { + let bad = |reason: String| UorustError::Malformed { + path: PathBuf::from("targets.json"), + reason, + }; + let descriptors: serde_json::Value = + serde_json::from_str(targets).map_err(|e| bad(e.to_string()))?; + descriptors + .get("targets") + .and_then(|t| t.as_array()) + .into_iter() + .flatten() + .find(|t| t.get("id").and_then(|i| i.as_str()) == Some(self.target.as_str())) + .map(serde_json::Value::to_string) + .ok_or_else(|| bad(format!("no {} descriptor", self.target))) + } } /// The file of `kept` that records the build seconds of every pass and the @@ -363,27 +599,13 @@ fn kept_roots(kept: &Path) -> Result, UorustError> { /// at, by package. pub const KAPPAS: &str = "kappas.toml"; -/// The file of `kept` that records each root's closure κ -/// ([`closure_kappas`]), by package. -pub const CLOSURES: &str = "closures.toml"; - -/// The manifest of `kept` that lists the roots carried from the last export -/// (their closure κ unchanged), whose sources lie in `kept/carried`. -pub const CARRIED: &str = "carried"; - -/// The domain tag of a root's closure κ. -pub const CLOSURE: &str = "uorust/certified-closure/1"; - /// What part of the export one run builds, and for how long. #[derive(Clone, Copy, Debug, Default)] -pub struct Scope<'a> { +pub struct Scope { /// The time it may build for; the roots unbuilt then are refused. pub within: Option, /// Shard I of N: every Nth eligible root, from the Ith. pub shard: Option<(usize, usize)>, - /// The certified crate whose roots are carried when unchanged - /// ([`carry_roots`]); none carries nothing. - pub carry: Option<&'a Path>, } /// The code of the kernel's rejection of a certificate B. Run 43700278692's @@ -415,6 +637,7 @@ struct Export { late: bool, seconds: u64, published: usize, + builds: usize, } /// What one build of a batch asks of the export next. @@ -447,22 +670,41 @@ enum Outcome { /// once. Each pass is printed to stderr. When `within` passes, the builds /// still running are stopped and the roots not yet built are refused as /// [`UNBUILT`], so the export ends with what it published. The project and -/// the build may live on a scratch volume. The roots `scope.carry` -/// certifies unchanged are carried ([`carry_roots`]), not built. +/// the build may live on a scratch volume. +/// +/// A root whose closure κ ([`closure_kappas`], under `compiler`) the prior +/// manifest holds as certified ([`carry`]) is carried: its package source is +/// taken from `prior`'s source directories byte for byte, checked against +/// the SHA-256 the manifest records, and kept under [`CARRIED_DIR`] for +/// `sync`; it is not built, so an export whose roots are all unchanged runs +/// no build. It is carried only into a project that verifies: the prior +/// export verified the same [`project_identity`], or a build of this export +/// published (every build verifies the whole selection first, SPEC §24.7), +/// or, when none did, one verification of the production project with a +/// single carried root marked passes (`prior.verify`; its cost does not grow +/// with the roots, as a verification with every root marked does until it +/// passes the compiler's total budget). When that verification refuses, the +/// carried roots are built as a fresh export builds them. An export that +/// stops (an error, the deadline) before its project is verified publishes +/// no carried root. A shard carries every Nth carried root from the Ith, as +/// it builds every Nth of the rest. pub fn production_build( - projection: &Path, + input: &Input<'_>, out: &Path, - register: &Register, - targets: &str, kept: &Path, - prior: &Manifest, - scope: Scope<'_>, -) -> Result<(), UorustError> { - let Scope { - within, - shard, - carry, - } = scope; + prior: &Prior<'_>, + compiler: &Compiler, + scope: Scope, +) -> Result { + let carry = prior; + let prior = prior.manifest; + let Input { + profile, + projection, + register, + targets, + } = *input; + let Scope { within, shard } = scope; if let Some((k, n)) = shard.filter(|(k, n)| k >= n) { return Err(UorustError::Tool(format!( "shard {k} of {n}: a shard is below the count" @@ -470,32 +712,26 @@ pub fn production_build( } let deadline = within.map(|w| std::time::Instant::now() + w); let prefix = format!("{}.{BEHAVIOR}.", module_prefix(projection)?); - let all = roots(register); + let all = profile.export_roots(projection, register)?; // Refused before anything is written: no descriptor to export to. - descriptor(targets)?; - let mut compiler: BTreeMap = BTreeMap::new(); - let version = compiler_version()?; - if !prior.compiler.is_empty() && prior.compiler == version { - let by_kappa: BTreeMap<&str, &str> = all - .iter() - .map(|r| (r.kappa.as_str(), r.definition.as_str())) - .collect(); - compiler.extend(prior.refused.iter().filter_map(|(kappa, cause)| { - by_kappa - .get(kappa.as_str()) - .filter(|_| cause.contains(&format!("`{prefix}"))) - // A kernel rejection is carried only when the root was built - // alone: in a batch it can be the batch's, not the root's. - .filter(|_| !cause.starts_with(KERNEL)) - .map(|d| ((*d).to_string(), cause.clone())) - })); - } + profile.descriptor(targets)?; for dir in [out, kept] { if dir.exists() { std::fs::remove_dir_all(dir).map_err(|e| io(dir, e))?; } std::fs::create_dir_all(dir).map_err(|e| io(dir, e))?; } + let program = compiler.program.clone(); + let decided = self::carry(input, &all, compiler, carry)?; + let Carry { + ids, + project, + verified, + carried, + refused: compiler, + marked, + } = decided; + let carried_names: BTreeSet<&str> = carried.iter().map(|c| c.definition.as_str()).collect(); // The κ each package is exported at, so that a sync on a newer commit // takes a package only while its function is the one exported. let measured: String = all @@ -504,13 +740,41 @@ pub fn production_build( .collect(); let path = kept.join(KAPPAS); std::fs::write(&path, measured).map_err(|e| io(&path, e))?; - let skip = carry_roots(projection, targets, &all, carry, kept, &version)?; + // The identity each package is exported at, which the manifest keeps so + // that the next export carries the package while it is unchanged. + let identified: String = all + .iter() + .filter_map(|r| { + Some(format!( + "{} = \"{}\"\n", + r.package(), + ids.get(&r.definition)? + )) + }) + .collect(); + let path = kept.join(CLOSURES); + std::fs::write(&path, identified).map_err(|e| io(&path, e))?; + let own_carried: Vec<&Carried> = carried + .iter() + .enumerate() + .filter(|(i, _)| shard.is_none_or(|(k, n)| i % n == k)) + .map(|(_, c)| c) + .collect(); + // What the export is of, for the steps that take it in. The + // translator's own is every step's default and is not restated. + if *profile != Profile::default() { + let path = kept.join(PROFILE); + std::fs::write(&path, profile.rows()).map_err(|e| io(&path, e))?; + } // Every root the request may name: the higher-order ones are refused by // `production` itself. let probe = out.join("probe"); - let eligible: Vec = production(projection, &probe, register, targets, &compiler, None)? + let admitted = production( + profile, projection, &probe, register, targets, &compiler, None, + )?; + let eligible: Vec = admitted .into_iter() - .filter(|r| !skip.contains(r)) + .filter(|r| !carried_names.contains(r.as_str())) .enumerate() .filter(|(i, _)| shard.is_none_or(|(k, n)| i % n == k)) .map(|(_, r)| r) @@ -523,29 +787,180 @@ pub fn production_build( for (i, root) in eligible.into_iter().enumerate() { batches[i % count].push(root); } + batches.retain(|b| !b.is_empty()); batches.reverse(); eprintln!( - "certify production: {} batches on {workers} workers, {} roots refused before any build, {} carried", + "certify production: {} roots carried from the prior export, {} to build in {} batches on {workers} workers, {} roots refused before any build", + own_carried.len(), + batches.iter().map(Vec::len).sum::(), batches.len(), - compiler.len(), - skip.len() + compiler.len() + marked.len() ); let state = std::sync::Mutex::new(Export { batches, compiler, ..Export::default() }); - let wake = std::sync::Condvar::new(); let source = Source { + profile, projection, register, targets, prefix: &prefix, deadline, + program: &program, + }; + build_all(&source, out, kept, workers, &state); + // A carried root is published only into a project a build or a + // verification of this export verified (SPEC §24.7: every build verifies + // the whole entrypoint selection before it renders a package). A build + // that published has; when none did, one verification with the fewest + // roots marked (one carried root) does, so that what it costs does not + // grow with the roots. When it refuses, the carried roots are built as a + // fresh export builds them, and each is refused as such a build refuses. + let mut own_carried = own_carried; + let mut verified = verified; + let (unverified, stopped) = { + let s = state + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner); + (s.published == 0 && !verified, s.error.is_some() || s.late) + }; + if unverified && stopped { + // No build passed and none may run: the carried roots are left + // unbuilt, never published unverified. + let roots: Vec = own_carried.iter().map(|c| c.definition.clone()).collect(); + own_carried.clear(); + state + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .batches + .push(roots); + } else if unverified { + // The verification runs where the first worker builds, so a project + // that links packages finds its workspace as a build does. + if let Some(first) = own_carried.first() { + let only: BTreeSet = std::iter::once(first.definition.clone()).collect(); + let scratch = out.join("0"); + if scratch.exists() { + std::fs::remove_dir_all(&scratch).map_err(|e| io(&scratch, e))?; + } + let refusals = state + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .compiler + .clone(); + production( + profile, + projection, + &scratch, + register, + targets, + &refusals, + Some(&only), + )?; + let verdict = (carry.verify)(&scratch)?; + std::fs::remove_dir_all(&scratch).map_err(|e| io(&scratch, e))?; + match verdict { + None => verified = true, + Some(refusal) => { + eprintln!( + "certify production: the project does not verify, so nothing is carried and the {} carried roots are built: {}", + own_carried.len(), + refusal.lines().next().unwrap_or_default() + ); + let roots: Vec = + own_carried.iter().map(|c| c.definition.clone()).collect(); + own_carried.clear(); + let count = workers.min(roots.len()).max(1); + let mut batches: Vec> = vec![Vec::new(); count]; + for (i, root) in roots.into_iter().enumerate() { + batches[i % count].push(root); + } + state + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .batches + .extend(batches.into_iter().rev()); + build_all(&source, out, kept, workers, &state); + } + } + } + } + keep_carried(kept, &own_carried, &prior.result)?; + let mut s = state + .into_inner() + .unwrap_or_else(std::sync::PoisonError::into_inner); + if let Some(e) = s.error { + return Err(e); + } + // The roots no build reached by the deadline: uncertified at this + // export, and built again by the next, since no compiler refused them. + let unbuilt: Vec = s.batches.drain(..).flatten().collect(); + for root in unbuilt { + s.compiler + .entry(root) + .or_insert_with(|| UNBUILT.to_string()); + } + // The refusals of every root refused by the end. + let last = out.join("refusals"); + production( + profile, + projection, + &last, + register, + targets, + &s.compiler, + None, + )?; + let refusals = last.join(REFUSALS); + std::fs::copy(&refusals, kept.join(REFUSALS)).map_err(|e| io(&refusals, e))?; + let timing = kept.join(TIMING); + // An export that built nothing measured nothing: it keeps the prior + // export's figure, which the next export sizes its shards by. + let (seconds, roots) = match (s.published, prior.seconds_per_root) { + (0, Some(per_root)) => (per_root, 1), + _ => (s.seconds, u64::try_from(s.published).unwrap_or(u64::MAX)), }; + let text = format!("seconds = {seconds}\nroots = {roots}\n"); + std::fs::write(&timing, text).map_err(|e| io(&timing, e))?; + // A build that published verified the whole project it was built in. + if verified || s.published > 0 { + let path = kept.join(PROJECT); + std::fs::write(&path, format!("identity = \"{project}\"\n")).map_err(|e| io(&path, e))?; + } + // Builds are the passes that reached `lexlean production build`: a + // batch every root of which was refused before is no build. + eprintln!( + "certify production: {} roots carried, {} bundles in {} passes, {} roots refused by the compiler, {} by the marking", + own_carried.len(), + s.bundles, + s.passes, + s.compiler.len(), + marked.len() + ); + Ok(Exported { + carried: own_carried.len(), + built: s.published, + builds: s.builds, + refused: s.compiler.len() + marked.len(), + }) +} + +/// Run the batches of `state` to the end on `workers` parallel workers, +/// each in its own directory under `out`, keeping each published bundle +/// under `kept` ([`production_build`]). +fn build_all( + source: &Source<'_>, + out: &Path, + kept: &Path, + workers: usize, + state: &std::sync::Mutex, +) { + let wake = std::sync::Condvar::new(); std::thread::scope(|scope| { for worker in 0..workers { - let (state, wake, source) = (&state, &wake, &source); + let wake = &wake; let dir = out.join(worker.to_string()); scope.spawn(move || loop { let (batch, compiler, pass) = { @@ -569,6 +984,9 @@ pub fn production_build( s.busy -= 1; let seconds = started.elapsed().as_secs(); s.seconds += seconds; + if matches!(outcome, Ok((_, Some(_)))) { + s.builds += 1; + } match outcome { Ok((_, None)) => {} Ok((named, Some(Outcome::Bundle(bundle)))) => { @@ -640,119 +1058,19 @@ pub fn production_build( }); } }); - let mut s = state - .into_inner() - .unwrap_or_else(std::sync::PoisonError::into_inner); - if let Some(e) = s.error { - return Err(e); - } - // The roots no build reached by the deadline: uncertified at this - // export, and built again by the next, since no compiler refused them. - let unbuilt: Vec = s.batches.drain(..).flatten().collect(); - for root in unbuilt { - s.compiler - .entry(root) - .or_insert_with(|| UNBUILT.to_string()); - } - // The refusals of every root refused by the end. - let last = out.join("refusals"); - production(projection, &last, register, targets, &s.compiler, None)?; - let refusals = last.join(REFUSALS); - std::fs::copy(&refusals, kept.join(REFUSALS)).map_err(|e| io(&refusals, e))?; - let timing = kept.join(TIMING); - let text = format!("seconds = {}\nroots = {}\n", s.seconds, s.published); - std::fs::write(&timing, text).map_err(|e| io(&timing, e))?; - eprintln!( - "certify production: {} bundles in {} passes, {} roots refused by the compiler", - s.bundles, - s.passes, - s.compiler.len() - ); - Ok(()) -} - -/// Write each root's closure κ ([`closure_kappas`]) to `kept`, and carry -/// into `kept/carried` every root the certified crate at `carry` (its -/// manifest and `roots/`) certifies by the same compiler, at the same κ and -/// closure κ, with its source as the manifest records it: the package such a -/// root would build to is the one already held. Returns the carried roots' -/// definitions, which the export does not build. -fn carry_roots( - projection: &Path, - targets: &str, - all: &[Root], - carry: Option<&Path>, - kept: &Path, - version: &str, -) -> Result, UorustError> { - let mut modules = BTreeMap::new(); - for module in [BEHAVIOR, "Prelude"] { - let path = projection.join("src").join(format!("{module}.lex.tex")); - let text = std::fs::read_to_string(&path).map_err(|e| io(&path, e))?; - modules.insert(module.to_string(), text); - } - let stamp = format!("{version}\n{}", descriptor(targets)?); - let definitions: Vec<&str> = all.iter().map(|r| r.definition.as_str()).collect(); - let keys = closure_kappas(&modules, &definitions, &stamp); - let by_package: BTreeMap = all - .iter() - .filter_map(|r| keys.get(&r.definition).map(|k| (r.package(), (r, k)))) - .collect(); - let text: String = by_package - .iter() - .map(|(package, (_, key))| format!("{package} = \"{key}\"\n")) - .collect(); - let path = kept.join(CLOSURES); - std::fs::write(&path, text).map_err(|e| io(&path, e))?; - let held = match carry { - Some(dir) => Manifest::read(&dir.join("manifest.toml"))?, - None => Manifest::default(), - }; - let to = kept.join(CARRIED); - std::fs::create_dir_all(&to).map_err(|e| io(&to, e))?; - let mut carried = Vec::new(); - if held.compiler == version { - for row in held.roots { - let Some((root, key)) = by_package.get(&row.package) else { - continue; - }; - if row.closure.is_empty() || row.closure != **key || row.kappa != root.kappa { - continue; - } - let Some(dir) = carry else { - continue; - }; - let from = dir.join("roots").join(format!("{}.rs", row.package)); - let Ok(bytes) = std::fs::read(&from) else { - continue; - }; - if crate::project::sha(&bytes) != row.source { - continue; - } - let target = to.join(format!("{}.rs", row.package)); - std::fs::write(&target, &bytes).map_err(|e| io(&target, e))?; - carried.push(row); - } - } - let skip = carried.iter().map(|r| r.definition.clone()).collect(); - let manifest = Manifest { - compiler: version.to_string(), - roots: carried, - ..Manifest::default() - }; - let path = to.join("manifest.toml"); - std::fs::write(&path, manifest.to_text()).map_err(|e| io(&path, e))?; - Ok(skip) } /// What every build of an export reads: the projection, the register, the /// target descriptors, the roots' qualified prefix and the deadline. struct Source<'a> { + profile: &'a Profile, projection: &'a Path, register: &'a Register, targets: &'a str, prefix: &'a str, deadline: Option, + /// The compiler's program ([`Compiler::program`]). + program: &'a Path, } /// Build one batch in the production project at `dir`: the roots the request @@ -769,6 +1087,7 @@ fn build_batch( } let only: BTreeSet = batch.iter().cloned().collect(); let named = production( + source.profile, source.projection, dir, source.register, @@ -779,8 +1098,10 @@ fn build_batch( if named.is_empty() { return Ok((named, None)); } - lexlean(dir, &["lock"])?; + let program = source.program; + run_lexlean(program, dir, &["lock"])?; let Some(result) = lexlean_until( + program, dir, &["production", "build", "--request", "request.json"], source.deadline, @@ -798,7 +1119,7 @@ fn build_batch( .and_then(|a| a.as_str()) .ok_or_else(|| UorustError::Tool("lexlean production build: no bundle".into()))?; let bundle = dir.join(artifact); - let replay = lexlean(dir, &["production", "verify-artifact", artifact])?; + let replay = run_lexlean(program, dir, &["production", "verify-artifact", artifact])?; if replay.get("success").and_then(serde_json::Value::as_bool) != Some(true) { return Err(UorustError::Tool(format!( "lexlean production verify-artifact: {}", @@ -835,20 +1156,899 @@ fn build_batch( /// The LexLean compiler's version, as `lexlean --version` states it. fn compiler_version() -> Result { - let run = std::process::Command::new("lexlean") - .arg("--version") - .output() - .map_err(|e| UorustError::Tool(format!("lexlean --version: {e}")))?; - Ok(String::from_utf8_lossy(&run.stdout) - .lines() - .next() - .and_then(|l| l.split_whitespace().nth(1)) - .unwrap_or_default() - .to_string()) + Ok(Compiler::installed()?.version()) +} + +/// The compiler an export builds with: every line `lexlean --version` +/// prints. Its version alone is not the compiler: two builds of one version +/// can differ in their compiler semantics (the digest `lexlean --version` +/// states on its own line, which the lock and the result bind, SPEC §21.2, +/// §24.7) or in the Lean toolchain, and either changes what a build emits. +/// +/// The program a build runs is part of the compiler too, so that what an +/// export states it builds with is what it runs: a build never falls back +/// to whichever `lexlean` the path holds. The program is no input of an +/// identity: where a compiler is installed does not change what it emits, +/// and what it states of itself does. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Compiler { + /// Every line ` --version` prints. + pub stated: String, + /// The program every build of the export runs. + pub program: PathBuf, +} + +/// The compiler's program on the path. +pub const LEXLEAN: &str = "lexlean"; + +impl Compiler { + /// The compiler on the path. + pub fn installed() -> Result { + let run = std::process::Command::new(LEXLEAN) + .arg("--version") + .output() + .map_err(|e| UorustError::Tool(format!("lexlean --version: {e}")))?; + Ok(Compiler { + stated: String::from_utf8_lossy(&run.stdout).into_owned(), + program: PathBuf::from(LEXLEAN), + }) + } + + /// The version the manifest records: the second word of the first line. + pub fn version(&self) -> String { + self.stated + .lines() + .next() + .and_then(|l| l.split_whitespace().nth(1)) + .unwrap_or_default() + .to_string() + } +} + +/// The domain tag of a root's closure κ ([`closure_kappas`]): the identity +/// of everything its exported package is a function of. Its text is the one +/// the first keyed export recorded, so the roots a manifest holds at it are +/// still carried; a manifest's closure κ of another tag (an export's before +/// the project, the linked packages and the order of declarations were in +/// it) never equals one of this tag, and its roots are built once again. +pub const CLOSURE: &str = "uorust/certified-root/1"; + +/// The file of `kept` that records the closure κ each root's package was +/// exported at, by package, so that the manifest keeps it for the next export. +pub const CLOSURES: &str = "closures.toml"; + +/// The file of `kept` that lists the packages an export carried from the +/// prior one; their sources are kept beside it under [`CARRIED_DIR`]. +pub const CARRIED: &str = "carried.toml"; + +/// The directory of `kept` that holds each carried package's `src/lib.rs`, +/// as `.rs`. +pub const CARRIED_DIR: &str = "carried"; + +/// The file of `kept` that records the project identity ([`project_identity`]) +/// the export verified, by a build that published or by the verification +/// before a carry, so that the manifest keeps it for the next export. +pub const PROJECT: &str = "project.toml"; + +/// A module's text read for an identity: its frame (every non-blank line +/// outside a top-level declaration, in order), each top-level declaration (a +/// definition, structure, inductive, theorem, any `kind{..}` block) by name +/// with its text, and the names in the order the module declares them. +/// Blank lines are left out. The order is kept apart from the texts because +/// it is an input only relative to the declarations a root reaches: the +/// language links a module's declarations in order and refuses a forward +/// reference (SPEC §17.11, `LLT4001`), so two closures of equal texts in +/// another relative order are another program, while a declaration +/// inserted elsewhere moves the others without changing that order. +fn declarations(source: &str) -> (Vec, BTreeMap, Vec) { + let mut frame = Vec::new(); + let mut decls: BTreeMap = BTreeMap::new(); + let mut order: Vec = Vec::new(); + let mut open: Option<(Option, String)> = None; + let starts = |line: &str| { + line.split_once('{').is_some_and(|(kind, _)| { + !kind.is_empty() && kind.chars().all(|c| c.is_ascii_lowercase() || c == '_') + }) + }; + let mut close = |name: Option, text: String, frame: &mut Vec| match name { + Some(name) => { + if !order.contains(&name) { + order.push(name.clone()); + } + decls.entry(name).or_default().push_str(&text); + } + None => frame.extend(text.lines().map(str::to_string)), + }; + for line in source.lines() { + if let Some((name, text)) = open.as_mut() { + if name.is_none() { + *name = line + .strip_prefix(" name: ") + .and_then(|n| n.strip_suffix(',')) + .map(str::to_string); + } + text.push_str(line); + text.push('\n'); + if line == "}" { + let (name, text) = open.take().unwrap_or_default(); + close(name, text, &mut frame); + } + continue; + } + if !starts(line) { + if !line.trim().is_empty() { + frame.push(line.to_string()); + } + continue; + } + let one_line = line.ends_with('}'); + let name = line + .split_once("{name: ") + .and_then(|(_, rest)| rest.split([',', '}']).next()) + .map(str::to_string); + if one_line { + close(name, format!("{line}\n"), &mut frame); + } else { + open = Some((name, format!("{line}\n"))); + } + } + if let Some((name, text)) = open { + close(name, text, &mut frame); + } + (frame, decls, order) +} + +/// The files of a projection outside its modules that a build reads, by +/// project-relative path, with their SHA-256: `lexlean.toml`; the workspace +/// files its lock binds (`[[workspace_file]]` of the lock it names, the Lake +/// files and the Lean toolchain); and every file of each lexicon source it +/// reads from a path. The builtin lexicons are the compiler's own and are +/// bound by its semantics ([`Compiler`]). A listed file that is absent is +/// stated absent, so that its appearing changes the identity too. +fn project_files(projection: &Path) -> Result, UorustError> { + let config_path = projection.join("lexlean.toml"); + let config_text = std::fs::read_to_string(&config_path).map_err(|e| io(&config_path, e))?; + let config: toml::Value = config_text.parse().map_err(|e| UorustError::Malformed { + path: config_path.clone(), + reason: format!("{e}"), + })?; + let mut files: BTreeSet = ["lexlean.toml".to_string()].into_iter().collect(); + let lock = config + .get("lockfile") + .and_then(toml::Value::as_str) + .unwrap_or("lexlean.lock"); + if let Ok(text) = std::fs::read_to_string(projection.join(lock)) { + if let Ok(doc) = text.parse::() { + files.extend( + doc.get("workspace_file") + .and_then(toml::Value::as_array) + .into_iter() + .flatten() + .filter_map(|f| f.get("path")?.as_str().map(str::to_string)), + ); + } + } + for source in config + .get("lexicon_source") + .and_then(toml::Value::as_array) + .into_iter() + .flatten() + .filter(|s| s.get("kind").and_then(toml::Value::as_str) == Some("path")) + { + let Some(dir) = source.get("path").and_then(toml::Value::as_str) else { + continue; + }; + let root = projection.join(dir); + if root.is_dir() { + let mut found = Vec::new(); + tree_files(projection, &root, &mut found)?; + files.extend(found.into_iter().map(|(rel, _)| rel)); + } else { + files.insert(dir.to_string()); + } + } + files + .into_iter() + .map(|rel| { + let path = projection.join(&rel); + let digest = match std::fs::read(&path) { + Ok(bytes) => crate::project::sha(&bytes), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => "absent".to_string(), + Err(e) => return Err(io(&path, e)), + }; + Ok((rel, digest)) + }) + .collect() +} + +/// The `[[source_package]]` rows of a project's (or a package's) +/// `lexlean.toml`, each its id, version and workspace-relative path. +fn package_rows(config: &Path) -> Result, UorustError> { + let text = match std::fs::read_to_string(config) { + Ok(text) => text, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()), + Err(e) => return Err(io(config, e)), + }; + let doc: toml::Value = text.parse().map_err(|e| UorustError::Malformed { + path: config.to_path_buf(), + reason: format!("{e}"), + })?; + let field = |row: &toml::Value, key: &str| { + row.get(key) + .and_then(toml::Value::as_str) + .unwrap_or_default() + .to_string() + }; + Ok(doc + .get("source_package") + .and_then(toml::Value::as_array) + .into_iter() + .flatten() + .map(|row| { + ( + field(row, "package"), + field(row, "version"), + field(row, "path"), + ) + }) + .collect()) +} + +/// The source roots a project's (or a package's) `lexlean.toml` declares; +/// `src` when it declares none. +fn source_roots(config: &Path) -> Vec { + let roots: Vec = std::fs::read_to_string(config) + .ok() + .and_then(|t| t.parse::().ok()) + .and_then(|doc| { + Some( + doc.get("source_roots")? + .as_array()? + .iter() + .filter_map(|r| r.as_str().map(str::to_string)) + .collect(), + ) + }) + .unwrap_or_default(); + if roots.is_empty() { + vec!["src".to_string()] + } else { + roots + } +} + +/// The SHA-256 over `dir`'s `lexlean.toml` and every file beneath its +/// source roots, each by its path relative to `dir`, in bytewise path +/// order: the files of a package the language reads (SPEC §10.5); a +/// directory that is absent is `absent`. +fn package_tree(dir: &Path) -> Result { + if !dir.is_dir() { + return Ok("absent".to_string()); + } + let config = dir.join("lexlean.toml"); + let mut files: Vec<(String, PathBuf)> = vec![("lexlean.toml".to_string(), config.clone())]; + for root in source_roots(&config) { + let at = dir.join(&root); + if at.is_dir() { + tree_files(dir, &at, &mut files)?; + } + } + files.sort(); + let mut text = String::new(); + for (rel, path) in files { + let digest = match std::fs::read(&path) { + Ok(bytes) => crate::project::sha(&bytes), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => "absent".to_string(), + Err(e) => return Err(io(&path, e)), + }; + text.push_str(&format!("{digest} {rel}\n")); + } + Ok(crate::project::sha(text.as_bytes())) +} + +/// The packages a projection links, as identity lines: `workspace +/// `, the workspace file that grants them (SPEC §10.5: the nearest +/// proper ancestor of the project that holds `lexlean-workspace.toml`), and +/// one `source-package ` per package of the +/// transitive closure of the project's `[[source_package]]` rows, each +/// path resolved from the workspace root and hashed by [`package_tree`]. +/// A package module is linked into a root's package like a module of the +/// project, but it lies outside the project's source roots, so without +/// these lines a changed package body would leave every identity as it was. +/// A project that declares no package reads nothing outside its root and +/// has no lines here. +fn source_packages(projection: &Path) -> Result, UorustError> { + let declared = package_rows(&projection.join("lexlean.toml"))?; + if declared.is_empty() { + return Ok(Vec::new()); + } + let canonical = projection.canonicalize().map_err(|e| io(projection, e))?; + let workspace = canonical + .ancestors() + .skip(1) + .find(|a| a.join("lexlean-workspace.toml").is_file()); + let mut lines = vec![match workspace { + Some(root) => { + let path = root.join("lexlean-workspace.toml"); + let bytes = std::fs::read(&path).map_err(|e| io(&path, e))?; + format!("workspace {}", crate::project::sha(&bytes)) + } + None => "workspace absent".to_string(), + }]; + let mut seen: BTreeSet<(String, String, String)> = BTreeSet::new(); + let mut work = declared; + while let Some(row) = work.pop() { + if !seen.insert(row.clone()) { + continue; + } + let (id, version, path) = &row; + let digest = match workspace { + Some(root) => { + let dir = root.join(path); + work.extend(package_rows(&dir.join("lexlean.toml"))?); + package_tree(&dir)? + } + None => "absent".to_string(), + }; + lines.push(format!("source-package {id} {version} {path} {digest}")); + } + lines.sort(); + Ok(lines) +} + +/// The domain tag of a projection's identity ([`project_identity`]). +pub const PROJECT_IDENTITY: &str = "uorust/certified-project/1"; + +/// The identity of what every build of an export verifies besides a root's +/// closure: the SHA-256 of the text below. +/// +/// ```text +/// uorust/certified-project/1 +/// compiler one per line of `lexlean --version` +/// target the profile's target descriptor, as JSON +/// effects .. the effects every root admits +/// roots .. the roots the production project marks +/// file one per file of [`project_files`], the +/// lock, and every file beneath the +/// project's source roots +/// one per line of [`source_packages`] +/// ``` +/// +/// A build verifies the whole entrypoint selection (SPEC §24.7), so a root +/// whose closure is unchanged is still refused by a fresh build when any +/// other declaration of the project, in any module, no longer verifies (a +/// false theorem, a forward reference). A root's identity ([`closure_kappas`]) +/// therefore says what its package is, and this identity says whether the +/// project it would be built in is the one an earlier export verified: +/// a root is carried only under both ([`carry`]). +pub fn project_identity(input: &Input<'_>, compiler: &Compiler) -> Result { + let Input { + profile, + projection, + register, + targets, + } = *input; + let mut text = format!("{PROJECT_IDENTITY}\n"); + for line in compiler.stated.lines() { + text.push_str(&format!("compiler {line}\n")); + } + let descriptor = profile.descriptor_text(targets)?; + text.push_str(&format!( + "target {} {}\n", + profile.target, + crate::project::sha(descriptor.as_bytes()) + )); + text.push_str(&format!("effects {}\n", profile.effects.join(" "))); + let mut roots: Vec = profile + .export_roots(projection, register)? + .into_iter() + .map(|r| r.definition) + .collect(); + roots.sort(); + text.push_str(&format!("roots {}\n", roots.join(" "))); + let config = projection.join("lexlean.toml"); + let mut files: BTreeMap = project_files(projection)?.into_iter().collect(); + let lock = std::fs::read_to_string(&config) + .ok() + .and_then(|t| t.parse::().ok()) + .and_then(|d| d.get("lockfile")?.as_str().map(str::to_string)) + .unwrap_or_else(|| "lexlean.lock".to_string()); + let lock_path = projection.join(&lock); + let mut read = vec![(lock, lock_path)]; + for root in source_roots(&config) { + let at = projection.join(&root); + if at.is_dir() { + tree_files(projection, &at, &mut read)?; + } + } + for (rel, path) in read { + let digest = match std::fs::read(&path) { + Ok(bytes) => crate::project::sha(&bytes), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => "absent".to_string(), + Err(e) => return Err(io(&path, e)), + }; + files.insert(rel, digest); + } + for (rel, digest) in files { + text.push_str(&format!("file {digest} {rel}\n")); + } + for line in source_packages(projection)? { + text.push_str(&format!("{line}\n")); + } + Ok(crate::project::sha(text.as_bytes())) +} + +/// The identity of each root's export, by definition: the SHA-256 of the +/// text below, which states once everything the root's package source is a +/// function of. +/// +/// ```text +/// uorust/certified-root/1 +/// compiler one per line of `lexlean --version` +/// target the profile's target descriptor, as JSON +/// effects .. the effects every root admits +/// file one per file of [`project_files`] +/// one per line of [`source_packages`] +/// frame Behavior's and Prelude's lines outside declarations +/// module any other module of the project their imports reach, whole +/// package the package the request names +/// root .Behavior. the production root +/// declaration one per declaration of the closure +/// order .. the closure's declarations of each module, in its order +/// ``` +/// +/// The closure is the root's declaration and every declaration of Behavior +/// and Prelude its text reaches, definitions and the types they name alike, +/// by the same reading of names as [`Definitions::closure`]: a callee is in +/// it, so a change in a callee changes the identity although the root's own +/// κ (its Rust function's) does not change. A module of a linked package +/// (`Prefix.Module::name`) is not read through the closure: every package +/// the project links is bound whole, by its tree, so a changed package body +/// changes every root's identity. What the closure leaves out does not +/// reach the package: the compiler renders a root's package from its +/// verified lowered program alone (SPEC §24.7, "the renderer of §17.16 over +/// the verified lowered program"), and `sync` takes only its `src/lib.rs`, +/// not the manifests that bind the whole project's semantic identity. The +/// batch a root is built in is no input either: a request names roots, and +/// each package is rendered for its own root. Whether the rest of the +/// project still verifies, which decides whether a build publishes the +/// package at all, is the project's identity's ([`project_identity`]). +pub fn closure_kappas( + input: &Input<'_>, + roots: &[Root], + compiler: &Compiler, +) -> Result, UorustError> { + let Input { + profile, + projection, + targets, + .. + } = *input; + let prefix = module_prefix(projection)?; + let modules = modules(projection)?; + let mut shared = format!("{CLOSURE}\n"); + for line in compiler.stated.lines() { + shared.push_str(&format!("compiler {line}\n")); + } + let descriptor = profile.descriptor_text(targets)?; + shared.push_str(&format!( + "target {} {}\n", + profile.target, + crate::project::sha(descriptor.as_bytes()) + )); + shared.push_str(&format!("effects {}\n", profile.effects.join(" "))); + for (path, digest) in project_files(projection)? { + shared.push_str(&format!("file {digest} {path}\n")); + } + for line in source_packages(projection)? { + shared.push_str(&format!("{line}\n")); + } + let mut all: BTreeMap = BTreeMap::new(); + let mut orders: BTreeMap> = BTreeMap::new(); + let mut imported: BTreeSet = BTreeSet::new(); + for (module, text) in &modules { + let (frame, decls, order) = declarations(text); + orders.insert(module.clone(), order); + let frame = frame.join("\n"); + shared.push_str(&format!( + "frame {module} {}\n", + crate::project::sha(frame.as_bytes()) + )); + imported.extend( + frame + .lines() + .filter_map(|l| l.strip_prefix("\\importmodule{")?.strip_suffix('}')) + .filter(|m| !modules.contains_key(*m)) + .map(str::to_string), + ); + all.extend( + decls + .into_iter() + .map(|(n, t)| (format!("{module}::{n}"), t)), + ); + } + // A module is bound whole with every module its own imports reach: the + // compiler renders a root through each of them, so one read only at the + // first step would leave a body two imports away in no identity. + let mut reached: BTreeMap = BTreeMap::new(); + let mut pending: Vec = imported.into_iter().collect(); + while let Some(module) = pending.pop() { + if reached.contains_key(&module) { + continue; + } + let path = projection + .join("src") + .join(format!("{}.lex.tex", module.replace('.', "/"))); + let digest = match std::fs::read(&path) { + Ok(bytes) => { + pending.extend( + String::from_utf8_lossy(&bytes) + .lines() + .filter_map(|l| l.trim().strip_prefix("\\importmodule{")?.strip_suffix('}')) + .filter(|m| !modules.contains_key(*m)) + .map(str::to_string), + ); + crate::project::sha(&bytes) + } + Err(e) if e.kind() == std::io::ErrorKind::NotFound => "absent".to_string(), + Err(e) => return Err(io(&path, e)), + }; + reached.insert(module, digest); + } + for (module, digest) in &reached { + shared.push_str(&format!("module {module} {digest}\n")); + } + let declarations = Definitions(all); + let mut out = BTreeMap::new(); + for root in roots { + let mut text = shared.clone(); + text.push_str(&format!("package {} {PACKAGE_VERSION}\n", root.package())); + text.push_str(&format!("root {prefix}.{BEHAVIOR}.{}\n", root.definition)); + let closure = declarations.closure(&format!("{BEHAVIOR}::{}", root.definition)); + for d in &closure { + let body = declarations.text(d).unwrap_or_default(); + text.push_str(&format!( + "declaration {d} {}\n", + crate::project::sha(body.as_bytes()) + )); + } + for (module, order) in &orders { + let reached: Vec<&str> = order + .iter() + .filter(|n| closure.contains(&format!("{module}::{n}"))) + .map(String::as_str) + .collect(); + if !reached.is_empty() { + text.push_str(&format!("order {module} {}\n", reached.join(" "))); + } + } + out.insert( + root.definition.clone(), + crate::project::sha(text.as_bytes()), + ); + } + Ok(out) +} + +/// What an export takes from the one before it: its manifest, and the +/// directories that hold its packages' sources in a certified crate's layout +/// (`/roots/.rs`), searched in order. +#[derive(Clone, Copy, Debug)] +pub struct Prior<'a> { + /// The manifest of the last export. + pub manifest: &'a Manifest, + /// Where its package sources are. + pub sources: &'a [PathBuf], + /// How a project the prior export did not verify is verified before + /// anything is carried into it: [`verify_project`]. + pub verify: Verifier, +} + +/// A check of the production project in a directory: `None` when it +/// verifies, else the refusal. +pub type Verifier = fn(&Path) -> Result, UorustError>; + +/// The verification every build of an export runs before it renders a +/// package, run once on the production project in `dir` with no package +/// requested: `lexlean lock`, then `lexlean verify`. `None` when it +/// verifies, else its diagnostics. +pub fn verify_project(dir: &Path) -> Result, UorustError> { + lexlean(dir, &["lock"])?; + let result = lexlean(dir, &["verify"])?; + if result.get("success").and_then(serde_json::Value::as_bool) == Some(true) { + return Ok(None); + } + let found = diagnostics(&result); + Ok(Some(if found.is_empty() { + "lexlean verify: refused without a diagnostic".to_string() + } else { + found.join("; ") + })) +} + +/// A root an export takes from the prior export without a build. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Carried { + /// The definition. + pub definition: String, + /// Its package. + pub package: String, + /// The identity it was exported at, which is this export's too. + pub closure: String, + /// The SHA-256 of the package's `src/lib.rs`, as the prior manifest + /// records it. + pub source: String, + /// The kernel's status of its certificates, as the prior manifest + /// records it. + pub certification: String, + /// The Rust edition its package's Cargo manifest declared, as the prior + /// manifest records it: the sources are written for it, and a crate + /// that compiles them under another does not compile (an all-carried + /// sync has no bundle to read it from). + pub edition: String, + /// The package's `src/lib.rs`. + pub bytes: Vec, +} + +/// The roots of `roots` the prior export certified at the identity `ids` +/// states for them, with their package sources: a root is carried only when +/// the prior manifest has a root of the same package at that identity and a +/// source directory holds a file whose SHA-256 is the one the manifest +/// records, so what is carried is byte for byte what the prior build +/// published, and the manifest records the package's edition. Any other +/// root is built. Whether the project still verifies is [`carry`]'s. +pub fn carried( + roots: &[Root], + ids: &BTreeMap, + prior: &Prior<'_>, +) -> Result, UorustError> { + let mut out = Vec::new(); + for root in roots { + let Some(id) = ids.get(&root.definition) else { + continue; + }; + let package = root.package(); + let Some(was) = prior + .manifest + .roots + .iter() + .find(|c| c.package == package && c.closure.as_deref() == Some(id.as_str())) + else { + continue; + }; + let Some(edition) = was.edition.clone() else { + continue; + }; + for dir in prior.sources { + let path = dir.join("roots").join(format!("{package}.rs")); + let bytes = match std::fs::read(&path) { + Ok(bytes) => bytes, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => continue, + Err(e) => return Err(io(&path, e)), + }; + if crate::project::sha(&bytes) != was.source { + continue; + } + out.push(Carried { + definition: root.definition.clone(), + package: package.clone(), + closure: id.clone(), + source: was.source.clone(), + certification: was.certification.clone(), + edition: edition.clone(), + bytes, + }); + break; + } + } + Ok(out) +} + +/// What an export takes from the prior one and what it refuses before any +/// build, decided once for the plan and the export alike. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Carry { + /// Every root's identity, by definition. + pub ids: BTreeMap, + /// The projection's identity ([`project_identity`]). + pub project: String, + /// Whether this export's project is known to verify without a build or + /// a verification: the prior export verified a project of the same + /// identity. + pub verified: bool, + /// The roots carried when the project verifies (candidates, until the + /// export has verified it). + pub carried: Vec, + /// The roots the prior export's compiler refused, refused again before + /// any build (by definition, with the cause). + pub refused: BTreeMap, + /// The roots the production project's marking refuses (a definition + /// with a function parameter in the closure), by definition. + pub marked: BTreeMap, +} + +/// The refusals of the prior export an export repeats before any build: a +/// root at the κ the prior refused under the same compiler version, whose +/// cause names a production root, and not a kernel rejection in a batch. +fn prior_refusals( + roots: &[Root], + prior: &Manifest, + version: &str, + prefix: &str, +) -> BTreeMap { + if prior.compiler.is_empty() || prior.compiler != version { + return BTreeMap::new(); + } + let by_kappa: BTreeMap<&str, &str> = roots + .iter() + .map(|r| (r.kappa.as_str(), r.definition.as_str())) + .collect(); + prior + .refused + .iter() + .filter_map(|(kappa, cause)| { + by_kappa + .get(kappa.as_str()) + .filter(|_| cause.contains(&format!("`{prefix}"))) + // A kernel rejection is carried only when the root was built + // alone: in a batch it can be the batch's, not the root's. + .filter(|_| !cause.starts_with(KERNEL)) + .map(|d| ((*d).to_string(), cause.clone())) + }) + .collect() +} + +/// Decide what an export of `roots` carries from `prior` and refuses before +/// any build. A root is a carried candidate when the prior manifest +/// certified it at its closure κ ([`carried`]): its package is then the one +/// a build would render. Whether the project it is carried into verifies is +/// decided by the export, never here and never by a verification that grows +/// with the number of roots ([`production_build`]): `verified` says only +/// whether the prior export verified a project of the same +/// [`project_identity`]. The marking's own refusals are counted here too, so +/// that a plan and its export state the same counts. +pub fn carry( + input: &Input<'_>, + roots: &[Root], + compiler: &Compiler, + prior: &Prior<'_>, +) -> Result { + let Input { + profile, + projection, + .. + } = *input; + let ids = closure_kappas(input, roots, compiler)?; + let project = project_identity(input, compiler)?; + let prefix = format!("{}.{BEHAVIOR}.", module_prefix(projection)?); + let before = prior_refusals(roots, prior.manifest, &compiler.version(), &prefix); + let carried = carried(roots, &ids, prior)?; + let verified = prior.manifest.project.as_deref() == Some(project.as_str()); + let names: BTreeSet<&str> = carried.iter().map(|c| c.definition.as_str()).collect(); + let refused: BTreeMap = before + .into_iter() + .filter(|(d, _)| !names.contains(d.as_str())) + .collect(); + let exported: BTreeSet<&str> = roots + .iter() + .map(|r| r.definition.as_str()) + .filter(|d| !refused.contains_key(*d) && !names.contains(d)) + .collect(); + let marked = profile.mark(&modules(projection)?, &exported).2; + Ok(Carry { + ids, + project, + verified, + carried, + refused, + marked, + }) +} + +/// What an export is left to do: the shards that build it within a budget, +/// the roots to diagnose, and the counts of roots carried from the prior +/// export (`None` when no identity was computed, so nothing could be +/// carried), left to build, and refused before any build. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Plan { + /// Shards. + pub shards: usize, + /// Roots whose compiler refusal is kept in full. + pub diagnose: Vec, + /// Roots carried, when identities were computed. + pub carried: Option, + /// Roots left to build. + pub build: usize, + /// Roots the prior export refused. + pub refused: usize, +} + +/// [`plan_of`] that leaves out what `carry` decided (the roots carried and +/// those refused before any build, by the prior compiler or by the +/// marking, exactly as the export decides them): only what is left to +/// build is sharded. Without it, the prior manifest's refusals by κ are +/// the only ones known. +pub fn plan_keyed(all: &[Root], carry: Option<&Carry>, prior: &Manifest, budget: u64) -> Plan { + let refused = |r: &Root| match carry { + Some(c) => c.refused.contains_key(&r.definition) || c.marked.contains_key(&r.definition), + None => { + prior.refused.contains_key(&r.kappa) && !prior.refused[&r.kappa].starts_with(UNBUILT) + } + }; + let is_carried = + |r: &Root| carry.is_some_and(|c| c.carried.iter().any(|k| k.definition == r.definition)); + let left: Vec<&Root> = all + .iter() + .filter(|r| !is_carried(r) && !refused(r)) + .collect(); + let per_root = prior + .seconds_per_root + .unwrap_or(MEASURED_SECONDS_PER_ROOT) + .max(1); + let per_shard = usize::try_from(budget / (per_root * BUILDS_PER_SHARD)) + .unwrap_or(usize::MAX) + .clamp(1, MAX_ROOTS_PER_SHARD); + let shards = left.len().div_ceil(per_shard).clamp(1, MAX_SHARDS); + let diagnose = all + .iter() + .filter(|r| !is_carried(r)) + .filter(|r| { + prior + .refused + .get(&r.kappa) + .is_some_and(|c| c.starts_with(ALONE) || c.starts_with("LLB6005")) + }) + .map(|r| r.definition.clone()) + .collect(); + Plan { + shards, + diagnose, + carried: carry.map(|_| all.iter().filter(|r| is_carried(r)).count()), + build: left.len(), + refused: all.iter().filter(|r| !is_carried(r) && refused(r)).count(), + } +} + +/// What one export did: the roots it carried, the roots it published by a +/// build, the builds it ran, and the roots refused by the end. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct Exported { + /// Roots carried from the prior export. + pub carried: usize, + /// Roots published by this export's builds. + pub built: usize, + /// Builds run (`lexlean production build` invocations). + pub builds: usize, + /// Roots refused. + pub refused: usize, +} + +/// Write what an export carried under `kept`: [`CARRIED`] with one row per +/// package and the prior export's result ids, and each package's source +/// under [`CARRIED_DIR`]. +fn keep_carried(kept: &Path, carried: &[&Carried], results: &str) -> Result<(), UorustError> { + let dir = kept.join(CARRIED_DIR); + std::fs::create_dir_all(&dir).map_err(|e| io(&dir, e))?; + let mut text = format!("results = {}\n", toml_quoted(results)); + for c in carried { + let path = dir.join(format!("{}.rs", c.package)); + std::fs::write(&path, &c.bytes).map_err(|e| io(&path, e))?; + text.push_str(&format!( + "\n[[carried]]\npackage = \"{}\"\nclosure = \"{}\"\nsource = \"{}\"\ncertification = {}\nedition = {}\n", + c.package, + c.closure, + c.source, + toml_quoted(&c.certification), + toml_quoted(&c.edition) + )); + } + let path = kept.join(CARRIED); + std::fs::write(&path, text).map_err(|e| io(&path, e)) } /// Keep what [`sync`] reads of a bundle under `to`: its `result.json` and -/// every package's `src/lib.rs`, at their paths in the bundle. +/// every package's `src/lib.rs` and Cargo manifest, at their paths in the +/// bundle. fn keep(bundle: &Path, to: &Path) -> Result { if to.exists() { std::fs::remove_dir_all(to).map_err(|e| io(to, e))?; @@ -866,6 +2066,13 @@ fn keep(bundle: &Path, to: &Path) -> Result { std::fs::create_dir_all(&dest).map_err(|e| io(&dest, e))?; let lib = package.join("src").join("lib.rs"); std::fs::copy(&lib, dest.join("lib.rs")).map_err(|e| io(&lib, e))?; + // The package's own manifest, whose edition a crate written + // for the packages takes. + let cargo = package.join("Cargo.toml"); + if cargo.is_file() { + let to = to.join(rel).join("Cargo.toml"); + std::fs::copy(&cargo, to).map_err(|e| io(&cargo, e))?; + } } } Ok(to.to_path_buf()) @@ -902,7 +2109,16 @@ pub(crate) fn first_root(message: &str, prefix: &str) -> Option { /// Run `lexlean --diagnostic-format json` in `dir`: its command /// result, whatever its exit. fn lexlean(dir: &Path, args: &[&str]) -> Result { - lexlean_until(dir, args, None)? + run_lexlean(Path::new(LEXLEAN), dir, args) +} + +/// [`lexlean`], with the compiler's `program`. +fn run_lexlean( + program: &Path, + dir: &Path, + args: &[&str], +) -> Result { + lexlean_until(program, dir, args, None)? .ok_or_else(|| UorustError::Tool(format!("lexlean {}: no result", args.join(" ")))) } @@ -912,11 +2128,13 @@ fn lexlean(dir: &Path, args: &[&str]) -> Result /// `lean` lexlean runs among it, at the first whole second past `deadline`; /// the `lake` and `lean` that left the group are killed by their build root. fn lexlean_until( + program: &Path, dir: &Path, args: &[&str], deadline: Option, ) -> Result, UorustError> { - let tool = |e: String| UorustError::Tool(format!("lexlean {}: {e}", args.join(" "))); + let tool = + |e: String| UorustError::Tool(format!("{} {}: {e}", program.display(), args.join(" "))); let mut command = match deadline { Some(d) => { let left = d.saturating_duration_since(std::time::Instant::now()); @@ -924,14 +2142,11 @@ fn lexlean_until( return Ok(None); } let mut c = std::process::Command::new("timeout"); - c.args([ - "--signal=KILL", - &format!("{}s", left.as_secs() + 1), - "lexlean", - ]); + c.args(["--signal=KILL", &format!("{}s", left.as_secs() + 1)]) + .arg(program); c } - None => std::process::Command::new("lexlean"), + None => std::process::Command::new(program), }; let run = command .args(args) @@ -1020,74 +2235,62 @@ fn chunks(source: &str) -> Vec { out } -/// Every definition of `defs` (by `Module::name`, with its text) that -/// `start` reaches by name, `start` among them. -fn reach(defs: &BTreeMap, start: &str) -> BTreeSet { - let mut reached: BTreeSet = BTreeSet::new(); - let mut work = vec![start.to_string()]; - while let Some(def) = work.pop() { - let Some(text) = defs.get(&def) else { - continue; - }; - if !reached.insert(def.clone()) { - continue; - } - let module = def.split("::").next().unwrap_or_default(); - for token in text.split(|c: char| !(c.is_ascii_alphanumeric() || c == '_' || c == ':')) { - let key = if token.contains("::") { - token.to_string() - } else { - format!("{module}::{token}") - }; - if defs.contains_key(&key) && !reached.contains(&key) { - work.push(key); +/// The definitions of a projection's modules, by qualified name +/// (`Module::name`), with their texts. +pub(crate) struct Definitions(BTreeMap); + +impl Definitions { + /// The definitions of `modules`, by module name with their texts. + pub(crate) fn of(modules: &BTreeMap) -> Definitions { + let mut defs = BTreeMap::new(); + for (module, text) in modules { + for c in chunks(text) { + if let Some(name) = c.name { + defs.insert(format!("{module}::{name}"), c.text); + } } } + Definitions(defs) } - reached -} -/// The κ of what each root's package is compiled from, by definition: SHA-256 -/// over `stamp` (the compiler and the target descriptors), every declaration -/// of `modules` that is no definition (the header, the types, the theorems), -/// and each definition the root reaches, by name. A root whose κ the last -/// export certified compiles to the same package, so it is carried, not -/// built again. -pub(crate) fn closure_kappas( - modules: &BTreeMap, - roots: &[&str], - stamp: &str, -) -> BTreeMap { - let cut: BTreeMap<&String, Vec> = - modules.iter().map(|(m, text)| (m, chunks(text))).collect(); - let mut shared = format!("{CLOSURE}\n{stamp}\n"); - let mut defs: BTreeMap = BTreeMap::new(); - for (module, chunks) in &cut { - shared.push_str(&format!("module {module}\n")); - for c in chunks { - match &c.name { - Some(name) => { - defs.insert(format!("{module}::{name}"), &c.text); + /// A definition's text. + pub(crate) fn text(&self, def: &str) -> Option<&str> { + self.0.get(def).map(String::as_str) + } + + /// A definition's closure: itself and every definition its body + /// reaches. + pub(crate) fn closure(&self, start: &str) -> BTreeSet { + let mut reached: BTreeSet = BTreeSet::new(); + let mut work = vec![start.to_string()]; + while let Some(def) = work.pop() { + let Some(text) = self.0.get(&def) else { + continue; + }; + if !reached.insert(def.clone()) { + continue; + } + let module = def.split("::").next().unwrap_or_default(); + for token in text.split(|c: char| !(c.is_ascii_alphanumeric() || c == '_' || c == ':')) + { + let key = if token.contains("::") { + token.to_string() + } else { + format!("{module}::{token}") + }; + if self.0.contains_key(&key) && !reached.contains(&key) { + work.push(key); } - None => shared.push_str(&c.text), } } + reached } - roots - .iter() - .map(|root| { - let mut text = shared.clone(); - for def in reach(&defs, &format!("{BEHAVIOR}::{root}")) { - text.push_str(&format!("def {def}\n{}", defs[&def])); - } - ((*root).to_string(), crate::project::sha(text.as_bytes())) - }) - .collect() } /// The modules' texts, by module name, with every root (a definition of /// `Behavior`) a production root and every definition a root reaches /// executable, the roots found, and the roots refused with their causes. +#[cfg(test)] pub(crate) fn mark( modules: &BTreeMap, roots: &BTreeSet<&str>, @@ -1096,75 +2299,88 @@ pub(crate) fn mark( BTreeSet, BTreeMap, ) { - let cut: BTreeMap<&String, Vec> = - modules.iter().map(|(m, text)| (m, chunks(text))).collect(); - // Every definition by its qualified name, `Module::name`, with its text. - let mut defs: BTreeMap = BTreeMap::new(); - for (module, chunks) in &cut { - for c in chunks { - if let Some(name) = &c.name { - defs.insert(format!("{module}::{name}"), &c.text); - } - } - } - let mut reached: BTreeSet = BTreeSet::new(); - let mut refused: BTreeMap = BTreeMap::new(); - for root in roots { - let own = reach(&defs, &format!("{BEHAVIOR}::{root}")); - // SPEC §17.13: an executable definition takes no function. - if let Some(hof) = own - .iter() - .find(|d| defs.get(*d).is_some_and(|t| higher_order(t))) - { - refused.insert( + Profile::default().mark(modules, roots) +} + +impl Profile { + /// The modules' texts, by module name, with every root (a definition + /// of `Behavior`) a production root with this profile's effects and + /// target, and every definition a root reaches executable; the roots + /// found; and the roots refused with their causes. + pub(crate) fn mark( + &self, + modules: &BTreeMap, + roots: &BTreeSet<&str>, + ) -> ( + BTreeMap, + BTreeSet, + BTreeMap, + ) { + let cut: BTreeMap<&String, Vec> = + modules.iter().map(|(m, text)| (m, chunks(text))).collect(); + let definitions = Definitions::of(modules); + let defs = &definitions.0; + let closure = |start: &str| definitions.closure(start); + let mut reached: BTreeSet = BTreeSet::new(); + let mut refused: BTreeMap = BTreeMap::new(); + for root in roots { + let own = closure(&format!("{BEHAVIOR}::{root}")); + // SPEC §17.13: an executable definition takes no function. + if let Some(hof) = own + .iter() + .find(|d| defs.get(*d).is_some_and(|t| higher_order(t))) + { + refused.insert( (*root).to_string(), format!("reaches {hof}, a definition with a function parameter, which no production root may"), ); - continue; - } - reached.extend(own); - } - let mut found = BTreeSet::new(); - let mut out = BTreeMap::new(); - for (module, chunks) in cut { - let mut text = String::new(); - for c in chunks { - let key = c.name.as_ref().map(|n| format!("{module}::{n}")); - let Some(key) = key.filter(|k| reached.contains(k)) else { - text.push_str(&c.text); continue; - }; - let root = module == BEHAVIOR - && c.name - .as_deref() - .is_some_and(|n| roots.contains(n) && !refused.contains_key(n)); - let mut fields = Vec::new(); - if !c.text.contains("executable: true") { - fields.push("executable: true".to_string()); - } - if root { - fields.push(format!( - "production: {{effects: [{}], targets: [{TARGET}]}}", - EFFECTS.join(", ") - )); - found.insert(key.trim_start_matches(&format!("{BEHAVIOR}::")).to_string()); } - let body = c - .text - .trim_end_matches('\n') - .trim_end_matches('}') - .trim_end(); - if fields.is_empty() { - text.push_str(&c.text); - } else if c.text.lines().count() == 1 { - text.push_str(&format!("{body}, {}}}\n", fields.join(", "))); - } else { - text.push_str(&format!("{body},\n {}\n}}\n", fields.join(",\n "))); + reached.extend(own); + } + let mut found = BTreeSet::new(); + let mut out = BTreeMap::new(); + for (module, chunks) in cut { + let mut text = String::new(); + for c in chunks { + let key = c.name.as_ref().map(|n| format!("{module}::{n}")); + let Some(key) = key.filter(|k| reached.contains(k)) else { + text.push_str(&c.text); + continue; + }; + let root = module == BEHAVIOR + && c.name + .as_deref() + .is_some_and(|n| roots.contains(n) && !refused.contains_key(n)); + let mut fields = Vec::new(); + if !c.text.contains("executable: true") { + fields.push("executable: true".to_string()); + } + if root { + fields.push(format!( + "production: {{effects: [{}], targets: [{}]}}", + self.effects.join(", "), + self.target + )); + found.insert(key.trim_start_matches(&format!("{BEHAVIOR}::")).to_string()); + } + let body = c + .text + .trim_end_matches('\n') + .trim_end_matches('}') + .trim_end(); + if fields.is_empty() { + text.push_str(&c.text); + } else if c.text.lines().count() == 1 { + text.push_str(&format!("{body}, {}}}\n", fields.join(", "))); + } else { + text.push_str(&format!("{body},\n {}\n}}\n", fields.join(",\n "))); + } } + out.insert(module.clone(), text); } - out.insert(module.clone(), text); + (out, found, refused) } - (out, found, refused) } /// Whether a definition's text takes a function: a parameter of a `Fn` type. @@ -1227,9 +2443,13 @@ pub struct Certified { pub source: String, /// The kernel's status of its certificates. pub certification: String, - /// The κ of what its package was compiled from ([`closure_kappas`]); - /// empty when the export did not record it, and then it is never carried. - pub closure: String, + /// The closure κ its package was exported at ([`closure_kappas`]); a + /// manifest written before closure κs has none, and its roots are built + /// again by the next export. + pub closure: Option, + /// The Rust edition its package's Cargo manifest declares; a root + /// without one is built again rather than carried. + pub edition: Option, } /// The certified translator: the bundle it came from, its roots, and the @@ -1240,6 +2460,9 @@ pub struct Manifest { pub result: String, /// The LexLean compiler's version. pub compiler: String, + /// The project identity ([`project_identity`]) the export verified, + /// when it verified one. + pub project: Option, /// The certified roots, by package. pub roots: Vec, /// The figures, as [`Share`] computes them. @@ -1318,7 +2541,16 @@ impl Manifest { package: text_of(row, "package")?, source: text_of(row, "source")?, certification: text_of(row, "certification")?, - closure: text_of(row, "closure").unwrap_or_default(), + // An export that kept the key under its first name, + // `identity`, is read as it wrote it. + closure: ["closure", "identity"] + .iter() + .find_map(|k| row.get(*k).and_then(toml::Value::as_str)) + .map(str::to_string), + edition: row + .get("edition") + .and_then(toml::Value::as_str) + .map(str::to_string), }); } let mut refused = BTreeMap::new(); @@ -1339,6 +2571,10 @@ impl Manifest { refused, result: text_of(&doc, "result")?, compiler: text_of(&doc, "compiler")?, + project: doc + .get("project") + .and_then(toml::Value::as_str) + .map(str::to_string), roots, share: Share { translator: count("translator")?, @@ -1349,20 +2585,53 @@ impl Manifest { }) } - /// The manifest's text. + /// The manifest's text, of the translator's own export. pub fn to_text(&self) -> String { + self.text(&Profile::default()) + } + + /// The manifest's text, of an export under `profile`: the translator's + /// own states no profile, any other states its own in `[profile]`. + pub fn text(&self, profile: &Profile) -> String { let s = &self.share; + let own = *profile == Profile::default(); let mut out = String::new(); - out.push_str( - "# The certified translator, written by `uorust certify sync` (just certified):\n\ - # every lifted translator function exported by `lexlean production` and\n\ - # kernel-checked, keyed by the κ of the Rust function it certifies.\n", - ); + out.push_str(match (own, profile.kind) { + (true, _) => { + "# The certified translator, written by `uorust certify sync` (just certified):\n\ + # every lifted translator function exported by `lexlean production` and\n\ + # kernel-checked, keyed by the κ of the Rust function it certifies.\n" + } + (false, Kind::Functions) => { + "# The certified implementation, written by `uorust certify sync`: every\n\ + # lifted function in scope exported by `lexlean production` and\n\ + # kernel-checked, keyed by the κ of the Rust function it certifies.\n" + } + (false, Kind::Cases) => { + "# The certified cases, written by `uorust certify sync`: every closed\n\ + # assertion of the workspace's tests over a lifted function in scope,\n\ + # exported by `lexlean production` and kernel-checked, keyed by the κ of\n\ + # the definitions it runs.\n" + } + }); out.push_str(&format!("schema = \"{SCHEMA}\"\n")); out.push_str(&format!("result = \"{}\"\n", self.result)); out.push_str(&format!("compiler = \"{}\"\n", self.compiler)); - out.push_str(&format!("entry = \"{ENTRY}\"\n\n")); - out.push_str("# The bootstrap: the share of the translator that runs certified.\n"); + if let Some(project) = &self.project { + out.push_str(&format!("project = \"{project}\"\n")); + } + if let Some(entry) = &profile.entry { + out.push_str(&format!("entry = \"{entry}\"\n")); + } + if !own { + out.push_str("\n# What the export is of.\n[profile]\n"); + out.push_str(&profile.rows()); + } + out.push_str(if own { + "\n# The bootstrap: the share of the translator that runs certified.\n" + } else { + "\n# The share that is certified: `translator` counts what is in scope.\n" + }); out.push_str("[share]\n"); out.push_str(&format!("translator = {}\n", s.translator)); out.push_str(&format!("certified = {}\n", s.certified)); @@ -1385,8 +2654,11 @@ impl Manifest { out.push_str(&format!("package = \"{}\"\n", r.package)); out.push_str(&format!("source = \"{}\"\n", r.source)); out.push_str(&format!("certification = \"{}\"\n", r.certification)); - if !r.closure.is_empty() { - out.push_str(&format!("closure = \"{}\"\n", r.closure)); + if let Some(closure) = &r.closure { + out.push_str(&format!("closure = \"{closure}\"\n")); + } + if let Some(edition) = &r.edition { + out.push_str(&format!("edition = \"{edition}\"\n")); } } for (kappa, cause) in &self.refused { @@ -1414,25 +2686,56 @@ fn bundles(kept: &Path) -> Result, UorustError> { Ok(out.into_iter().map(|(_, p)| p).collect()) } +/// What a sync takes in and where: the kept bundles, the directory of the +/// certified crate, the register its roots are current under, and what only +/// some exports have. +#[derive(Clone, Copy, Debug)] +pub struct Sync<'a> { + /// What `certify production` kept, whole or by shard. + pub kept: &'a Path, + /// The certified crate's directory, which the caller names. + pub dir: &'a Path, + /// The register the roots are current under. + pub register: &'a Register, + /// The projection of that register: a cases export's roots are read + /// from it. + pub projection: Option<&'a Path>, + /// The adapters' module that is written, when the workspace runs its + /// certified packages in place of its functions. + pub adapters: Option<&'a Path>, + /// The workspace and its MIR dumps, for the adapters' types and for the + /// share reachable from the profile's entry. + pub mir: Option<(&'a Path, &'a Path)>, +} + /// Take the bundles kept under `kept` into `dir`: each certified root's /// `src/lib.rs` as `dir/roots/.rs` (checked against the SHA-256 its -/// bundle's result records), the crate that compiles them, and the manifest, -/// with the share over `register` and the call graph of `dumps`. +/// bundle's result records), the crate that compiles them (with its Cargo +/// manifest, when the directory has none), and the manifest, with the share +/// over `register` and the call graph of `dumps`. A package is taken only +/// while its root's κ is the one it was exported at, so a function changed +/// since the export is uncertified until its package is rebuilt. pub(crate) fn sync( - kept: &Path, - production: &Path, - dir: &Path, - adapters: &Path, - register: &Register, - dumps: &Dumps, + profile: &Profile, + sync: &Sync<'_>, + roots: &[Root], + dumps: Option<&Dumps>, + compiler: &str, ) -> Result { + let Sync { + kept, + dir, + register, + adapters, + .. + } = *sync; let bad = |path: &Path, reason: String| UorustError::Malformed { path: path.to_path_buf(), reason, }; // Refused before anything is written: not what `certify production` // keeps, which always holds the refusals and each bundle's result.json. - let outputs = kept_roots(production)?; + let outputs = kept_roots(kept)?; if !outputs.iter().any(|k| k.join(REFUSALS).is_file()) { return Err(bad( kept, @@ -1440,6 +2743,7 @@ pub(crate) fn sync( )); } let mut measured: Option = None; + let mut identified = toml::Table::new(); let mut all = Vec::new(); for k in &outputs { let kappas = k.join(KAPPAS); @@ -1447,6 +2751,11 @@ pub(crate) fn sync( let table: toml::Table = text.parse().map_err(|e| bad(&kappas, format!("{e}")))?; measured.get_or_insert_with(toml::Table::new).extend(table); } + let ids = k.join(CLOSURES); + if let Ok(text) = std::fs::read_to_string(&ids) { + let table: toml::Table = text.parse().map_err(|e| bad(&ids, format!("{e}")))?; + identified.extend(table); + } all.extend(bundles(k)?); } let mut results = Vec::new(); @@ -1464,10 +2773,7 @@ pub(crate) fn sync( } at.as_str().unwrap_or_default().to_string() }; - let by_package: BTreeMap = roots(register) - .into_iter() - .map(|r| (r.package(), r)) - .collect(); + let by_package: BTreeMap = roots.iter().map(|r| (r.package(), r)).collect(); let roots_dir = dir.join("roots"); if roots_dir.is_dir() { std::fs::remove_dir_all(&roots_dir).map_err(|e| io(&roots_dir, e))?; @@ -1527,91 +2833,134 @@ pub(crate) fn sync( function: own.function.clone(), kappa: own.kappa.clone(), definition: own.definition.clone(), + closure: identified + .get(&name) + .and_then(toml::Value::as_str) + .map(str::to_string), + edition: package_edition(&bundle.join(&directory)), package: name, source: digest, certification: field(output, &["certification", "status"]), - closure: String::new(), }); } } } - // The roots the export carried, each source as the certified crate held - // it, while its function's κ is still the one it was carried at; and - // every root's closure κ, which the next export carries it by. - let mut closures: BTreeMap = BTreeMap::new(); + let mut carried_results: Vec = Vec::new(); for k in &outputs { - let path = k.join(CLOSURES); - if let Ok(text) = std::fs::read_to_string(&path) { - let table: toml::Table = text.parse().map_err(|e| bad(&path, format!("{e}")))?; - closures.extend( - table - .into_iter() - .filter_map(|(p, v)| Some((p, v.as_str()?.to_string()))), - ); - } - let held = k.join(CARRIED); - let path = held.join("manifest.toml"); - if !path.is_file() { + let list = k.join(CARRIED); + let Ok(text) = std::fs::read_to_string(&list) else { continue; + }; + let doc: toml::Value = text.parse().map_err(|e| bad(&list, format!("{e}")))?; + let rows = doc.get("carried").and_then(toml::Value::as_array); + if rows.is_some_and(|r| !r.is_empty()) { + carried_results.extend( + doc.get("results") + .and_then(toml::Value::as_str) + .unwrap_or_default() + .split_whitespace() + .map(str::to_string), + ); } - for row in Manifest::read(&path)?.roots { - if certified.iter().any(|c| c.package == row.package) { - continue; - } - let Some(own) = by_package.get(&row.package) else { + for row in rows.into_iter().flatten() { + let text_of = |key: &str| { + row.get(key) + .and_then(toml::Value::as_str) + .map(str::to_string) + .ok_or_else(|| bad(&list, format!("a carried package without {key}"))) + }; + let name = text_of("package")?; + let Some(own) = by_package.get(&name) else { continue; }; - if own.kappa != row.kappa { + // As a built package: taken only while its function is the one + // exported, and once. + if measured.as_ref().is_some_and(|m| { + m.get(&name).and_then(toml::Value::as_str) != Some(own.kappa.as_str()) + }) || certified.iter().any(|c| c.package == name) + { continue; } - let source = held.join(format!("{}.rs", row.package)); - let bytes = std::fs::read(&source).map_err(|e| io(&source, e))?; + let recorded = text_of("source")?; + let source_path = k.join(CARRIED_DIR).join(format!("{name}.rs")); + let bytes = std::fs::read(&source_path).map_err(|e| io(&source_path, e))?; let digest = crate::project::sha(&bytes); - if digest != row.source { + if digest != recorded { return Err(bad( - &source, - format!( - "SHA-256 {digest}, the carried manifest records {}", - row.source - ), + &source_path, + format!("SHA-256 {digest}, the prior manifest records {recorded}"), )); } - let target = roots_dir.join(format!("{}.rs", row.package)); + let target = roots_dir.join(format!("{name}.rs")); std::fs::write(&target, &bytes).map_err(|e| io(&target, e))?; certified.push(Certified { function: own.function.clone(), + kappa: own.kappa.clone(), definition: own.definition.clone(), - ..row + package: name, + source: digest, + certification: text_of("certification")?, + closure: Some(text_of("closure")?), + edition: Some(text_of("edition")?), }); } } - for c in &mut certified { - if let Some(k) = closures.get(&c.package) { - c.closure.clone_from(k); - } - } certified.sort_by(|a, b| a.package.cmp(&b.package)); - let lib = crate_source(&certified); + // The edition the packages are written for, built or carried alike. + let edition = certified.iter().find_map(|c| c.edition.clone()); + // The project every shard verified, when they state one and agree. + let mut verified: BTreeSet = BTreeSet::new(); + for k in &outputs { + let path = k.join(PROJECT); + let Ok(text) = std::fs::read_to_string(&path) else { + continue; + }; + let table: toml::Table = text.parse().map_err(|e| bad(&path, format!("{e}")))?; + verified.extend( + table + .get("identity") + .and_then(toml::Value::as_str) + .map(str::to_string), + ); + } + let project = match verified.len() { + 1 => verified.pop_first(), + _ => None, + }; + let lib = profile.crate_source(&certified); let lib_path = dir.join("src").join("lib.rs"); std::fs::create_dir_all(dir.join("src")).map_err(|e| io(dir, e))?; std::fs::write(&lib_path, lib).map_err(|e| io(&lib_path, e))?; - let empty = BTreeMap::new(); - let bodies = dumps.crates.get("uorust").unwrap_or(&empty); - let mut wired = BTreeMap::new(); - for c in &certified { - let source = std::fs::read_to_string(roots_dir.join(format!("{}.rs", c.package))) - .map_err(|e| io(&roots_dir, e))?; - let path = c.function.strip_prefix("uorust::").unwrap_or(&c.function); - if let Some((name, code)) = bodies.get(path).and_then(|b| adapter(c, b, &source)) { - wired.insert(name, code); - } - } - let mut sites = BTreeMap::new(); - if let Some(src) = adapters.parent() { - call_sites(src, adapters, &mut sites)?; - } - let text = adapters_source(&wired, &sites); - std::fs::write(adapters, text).map_err(|e| io(adapters, e))?; + // The crate's Cargo manifest is the caller's when the directory has + // one (the translator's inherits its workspace's); else it is written, + // a package of its own that any directory builds. + let cargo = dir.join("Cargo.toml"); + if !cargo.exists() { + let text = profile.cargo_manifest(edition.as_deref()); + std::fs::write(&cargo, text).map_err(|e| io(&cargo, e))?; + } + if let (Some(adapters), Some(dumps)) = (adapters, dumps) { + let empty = BTreeMap::new(); + let mut wired = BTreeMap::new(); + for c in &certified { + let source = std::fs::read_to_string(roots_dir.join(format!("{}.rs", c.package))) + .map_err(|e| io(&roots_dir, e))?; + let (krate, path) = c.function.split_once("::").unwrap_or(("", &c.function)); + let bodies = dumps.crates.get(krate).unwrap_or(&empty); + let adapted = bodies + .get(path) + .and_then(|b| profile.adapter(c, b, &source)); + if let Some((name, code)) = adapted { + wired.insert(name, code); + } + } + let mut sites = BTreeMap::new(); + if let Some(src) = adapters.parent() { + call_sites(src, adapters, &mut sites)?; + } + let text = adapters_source(&wired, &sites); + std::fs::write(adapters, text).map_err(|e| io(adapters, e))?; + } let kappas: BTreeSet = certified.iter().map(|c| c.kappa.clone()).collect(); let mut refused: BTreeMap = BTreeMap::new(); let (mut seconds, mut built) = (0u64, 0u64); @@ -1651,35 +3000,89 @@ pub(crate) fn sync( refused.retain(|kappa, _| !kappas.contains(kappa)); let manifest = Manifest { refused, - result: results - .iter() - .map(|(_, _, r)| field(r, &["result_id"])) - .collect::>() - .join(" "), + // The bundles this export published, then those the carried + // packages were published in. + result: { + let mut ids: Vec = results + .iter() + .map(|(_, _, r)| field(r, &["result_id"])) + .collect(); + for id in carried_results { + if !ids.contains(&id) { + ids.push(id); + } + } + ids.join(" ") + }, // As `lexlean --version` states it, which the next export compares // its own against: a manifest of no bundle has it too. - compiler: compiler_version()?, + compiler: compiler.to_string(), + project, seconds_per_root: seconds.checked_div(built), roots: certified, - share: share(register, &kappas, dumps), + share: match profile.kind { + Kind::Functions => profile.share(register, &kappas, dumps), + // Of a cases export, the cases the projection states and those + // whose package is current. + Kind::Cases => Share { + translator: roots.len(), + certified: roots.iter().filter(|r| kappas.contains(&r.kappa)).count(), + ..Share::default() + }, + }, }; let manifest_path = dir.join("manifest.toml"); - std::fs::write(&manifest_path, manifest.to_text()).map_err(|e| io(&manifest_path, e))?; + std::fs::write(&manifest_path, manifest.text(profile)).map_err(|e| io(&manifest_path, e))?; Ok(manifest) } -/// [`sync`] of the bundles [`production_build`] kept at `kept`, with the dumps read from -/// `mir` of the workspace at `workspace`. -pub fn sync_paths( - kept: &Path, - dir: &Path, - adapters: &Path, - register: &Register, - workspace: &Path, - mir: &Path, -) -> Result { - let dumps = crate::mir::load(workspace, mir)?; - sync(kept, kept, dir, adapters, register, &dumps) +/// The edition a bundle's package declares in its Cargo manifest. +fn package_edition(package: &Path) -> Option { + let text = std::fs::read_to_string(package.join("Cargo.toml")).ok()?; + let doc: toml::Value = text.parse().ok()?; + doc.get("package")? + .get("edition")? + .as_str() + .map(str::to_string) +} + +/// The profile every kept output under `kept` recorded: one export has one. +pub fn kept_profile(kept: &Path) -> Result { + let mut found: Option = None; + for k in kept_roots(kept)? { + let profile = Profile::kept(&k)?; + if found.as_ref().is_some_and(|f| *f != profile) { + return Err(UorustError::Malformed { + path: k.join(PROFILE), + reason: "the shards were exported under different profiles".to_string(), + }); + } + found = Some(profile); + } + Ok(found.unwrap_or_default()) +} + +/// [`sync`] of the bundles [`production_build`] kept, under the profile the +/// export recorded there, with the dumps read when the sync names them. +/// Returns the profile and the manifest. +pub fn sync_paths(s: &Sync<'_>) -> Result<(Profile, Manifest), UorustError> { + let profile = kept_profile(s.kept)?; + let roots = match (profile.kind, s.projection) { + (Kind::Functions, _) => profile.roots(s.register), + (Kind::Cases, Some(projection)) => profile.export_roots(projection, s.register)?, + (Kind::Cases, None) => { + return Err(UorustError::Tool( + "a cases export is taken in against the projection its cases are read from: pass --projection" + .to_string(), + )) + } + }; + let dumps = match s.mir { + Some((workspace, mir)) => Some(crate::mir::load(workspace, mir)?), + None => None, + }; + let manifest = sync(&profile, s, &roots, dumps.as_ref(), &compiler_version()?)?; + Ok((profile, manifest)) } /// The adapters' module, `crates/uorust/src/certified.rs`: the switch @@ -1824,52 +3227,65 @@ mod tests { /// The adapter of a certified root over its hand-written function's body: /// none when a parameter or the result has no conversion. +#[cfg(test)] pub(crate) fn adapter(root: &Certified, body: &IrBody, source: &str) -> Option<(String, String)> { - let (params, result) = run_signature(source)?; - if params.len() != body.arity { - return None; - } - let m = format!( - "uorust_certified::{}", - root.package.strip_prefix(PACKAGE).unwrap_or(&root.package) - ); - let mut args = Vec::new(); - let mut converted = Vec::new(); - for (i, cert) in params.iter().enumerate() { - let rust = unlifetimed(body.locals.get(i + 1)?); - // Each argument comes by reference, so the hand-written body still - // owns it when the root is not certified. - args.push(format!("p{i}: &{rust}")); - converted.push(if rust.starts_with('&') { - to_cert(&format!("(*p{i})"), &rust, cert, &m)? - } else { - to_cert(&format!("p{i}"), &format!("&{rust}"), cert, &m)? - }); - } - let rust_result = unlifetimed(body.locals.first()?); - let call = format!("{m}::run({})", converted.join(", ")); - let value = match result.strip_prefix("R<").and_then(|r| r.strip_suffix('>')) { - Some(inner) => { - let overflow = format!( + Profile::default().adapter(root, body, source) +} + +impl Profile { + /// The adapter of a root certified under this profile over its function's + /// body, calling its module of the profile's certified crate and named by + /// the function's path in its own crate: none when a parameter or the + /// result has no conversion. + pub(crate) fn adapter( + &self, + root: &Certified, + body: &IrBody, + source: &str, + ) -> Option<(String, String)> { + let (params, result) = run_signature(source)?; + if params.len() != body.arity { + return None; + } + let m = format!("{}::{}", self.crate_name(), self.module(&root.package)); + let mut args = Vec::new(); + let mut converted = Vec::new(); + for (i, cert) in params.iter().enumerate() { + let rust = unlifetimed(body.locals.get(i + 1)?); + // Each argument comes by reference, so the hand-written body still + // owns it when the root is not certified. + args.push(format!("p{i}: &{rust}")); + converted.push(if rust.starts_with('&') { + to_cert(&format!("(*p{i})"), &rust, cert, &m)? + } else { + to_cert(&format!("p{i}"), &format!("&{rust}"), cert, &m)? + }); + } + let rust_result = unlifetimed(body.locals.first()?); + let call = format!("{m}::run({})", converted.join(", ")); + let value = match result.strip_prefix("R<").and_then(|r| r.strip_suffix('>')) { + Some(inner) => { + let overflow = format!( "match {call} {{ Ok(v) => v, Err(_) => panic!(\"{}: the certified root overflowed\") }}", root.function ); - from_cert(&overflow, inner, &rust_result)? - } - None => from_cert(&call, &result, &rust_result)?, - }; - let name = root - .function - .strip_prefix("uorust::") - .unwrap_or(&root.function) - .replace("::", "_"); - let code = format!( + from_cert(&overflow, inner, &rust_result)? + } + None => from_cert(&call, &result, &rust_result)?, + }; + let name = root + .function + .split_once("::") + .map_or(root.function.as_str(), |(_, path)| path) + .replace("::", "_"); + let code = format!( "/// `{}`, certified as `Behavior::{}`.\n#[allow(clippy::all, non_snake_case, unused_parens)]\npub(crate) fn {name}({}) -> Option<{rust_result}> {{\n Some({value})\n}}\n", root.function, root.definition, args.join(", ") ); - Some((name, code)) + Some((name, code)) + } } /// A type as MIR prints it, without its lifetimes. @@ -2022,58 +3438,118 @@ fn from_cert(e: &str, cert: &str, rust: &str) -> Option { } } -/// The certified crate's `lib.rs`: one module per root, its file the -/// package source byte for byte. -pub(crate) fn crate_source(roots: &[Certified]) -> String { - let mut out = String::from( - "//! The certified translator: the Rust `lexlean production` exported from the\n\ - //! lifted translator's definitions, one module per production root, each file\n\ - //! the certified package's `src/lib.rs` byte for byte. Written by `uorust\n\ - //! certify sync`; `crates/certified/manifest.toml` keys each by the κ of the\n\ - //! Rust function it certifies.\n\n\ - #![forbid(unsafe_code)]\n", - ); - for r in roots { - out.push_str(&format!( - "\n/// `{}`, certified as `Behavior::{}`.\n#[rustfmt::skip]\n#[allow(missing_docs, dead_code, clippy::all)]\n#[path = \"../roots/{}.rs\"]\npub mod {};\n", - r.function, - r.definition, - r.package, - r.package.strip_prefix(PACKAGE).unwrap_or(&r.package) - )); +impl Profile { + /// The certified crate's `lib.rs`: one module per root, its file the + /// package source byte for byte. + pub(crate) fn crate_source(&self, roots: &[Certified]) -> String { + let mut out = String::from(match (*self == Profile::default(), self.kind) { + (true, _) => { + "//! The certified translator: the Rust `lexlean production` exported from the\n\ + //! lifted translator's definitions, one module per production root, each file\n\ + //! the certified package's `src/lib.rs` byte for byte. Written by `uorust\n\ + //! certify sync`; `crates/certified/manifest.toml` keys each by the κ of the\n\ + //! Rust function it certifies.\n\n\ + #![forbid(unsafe_code)]\n" + } + (false, Kind::Functions) => { + "//! The certified implementation: the Rust `lexlean production` exported from\n\ + //! the lifted definitions of the functions in scope, one module per\n\ + //! production root, each file the certified package's `src/lib.rs` byte for\n\ + //! byte. Written by `uorust certify sync`; `manifest.toml` keys each by the κ\n\ + //! of the Rust function it certifies.\n\n\ + #![forbid(unsafe_code)]\n" + } + (false, Kind::Cases) => { + "//! The certified cases: the Rust `lexlean production` exported from the\n\ + //! closed assertions of the workspace's tests, one module per production\n\ + //! root, each file the certified package's `src/lib.rs` byte for byte.\n\ + //! Written by `uorust certify sync`; `manifest.toml` keys each by the κ of\n\ + //! the definitions it runs.\n\n\ + #![forbid(unsafe_code)]\n" + } + }); + for r in roots { + let named = match self.kind { + Kind::Functions => format!("`{}`, certified as", r.function), + Kind::Cases => format!("A case of `{}`:", r.function), + }; + out.push_str(&format!( + "\n/// {named} `Behavior::{}`.\n#[rustfmt::skip]\n#[allow(missing_docs, dead_code, clippy::all)]\n#[path = \"../roots/{}.rs\"]\npub mod {};\n", + r.definition, + r.package, + self.module(&r.package) + )); + } + out } - out -} -/// The figures of the bootstrap over `register`, a function being certified -/// when its κ is in `certified`. -pub(crate) fn share(register: &Register, certified: &BTreeSet, dumps: &Dumps) -> Share { - let reach = reachable(dumps); - // (reachable, certified) of each translator function; a root certifies - // its κ only while the register lifts it. - let rows: Vec<(bool, bool)> = register - .rows - .iter() - .filter(|(_, r)| in_scope(&r.function)) - .map(|(k, r)| { - ( - reach.contains(&r.function), - certified.contains(k) && matches!(r.status, Status::Lifted(_)), - ) - }) - .collect(); - Share { - translator: rows.len(), - certified: rows.iter().filter(|(_, c)| *c).count(), - reachable: rows.iter().filter(|(r, _)| *r).count(), - reachable_certified: rows.iter().filter(|(r, c)| *r && *c).count(), + /// The module of the certified crate a package is, by its name: the + /// name without the profile's prefix. + pub(crate) fn module<'a>(&self, package: &'a str) -> &'a str { + package + .strip_prefix(self.package.as_str()) + .unwrap_or(package) + } + + /// The certified crate's name: the package prefix without the + /// separator it ends with. + pub(crate) fn crate_name(&self) -> String { + self.package.trim_end_matches('_').to_string() + } + + /// The Cargo manifest of a certified crate whose directory has none: a + /// package and a workspace of its own, at the edition the bundle's + /// packages declare, which builds wherever the directory is. + pub(crate) fn cargo_manifest(&self, edition: Option<&str>) -> String { + let edition = edition.map_or_else(String::new, |e| format!("edition = \"{e}\"\n")); + format!( + "# Written by `uorust certify sync` into a directory that had no Cargo\n\ + # manifest: the crate of the certified packages `manifest.toml` lists.\n\ + [package]\nname = \"{}\"\nversion = \"{PACKAGE_VERSION}\"\n{edition}publish = false\n\n\ + [lib]\npath = \"src/lib.rs\"\n\n[workspace]\n", + self.crate_name() + ) + } + + /// The figures of the bootstrap over `register`, a function being + /// certified when its κ is in `certified`; the reachable ones are + /// counted when the profile names an entry and the dumps are given. + pub(crate) fn share( + &self, + register: &Register, + certified: &BTreeSet, + dumps: Option<&Dumps>, + ) -> Share { + let reach = match (&self.entry, dumps) { + (Some(entry), Some(dumps)) => reachable_from(entry, dumps), + _ => BTreeSet::new(), + }; + // (reachable, certified) of each function in scope; a root + // certifies its κ only while the register lifts it. + let rows: Vec<(bool, bool)> = register + .rows + .iter() + .filter(|(_, r)| self.in_scope(&r.function)) + .map(|(k, r)| { + ( + reach.contains(&r.function), + certified.contains(k) && matches!(r.status, Status::Lifted(_)), + ) + }) + .collect(); + Share { + translator: rows.len(), + certified: rows.iter().filter(|(_, c)| *c).count(), + reachable: rows.iter().filter(|(r, _)| *r).count(), + reachable_certified: rows.iter().filter(|(r, c)| *r && *c).count(), + } } } -/// The functions of the `uorust` crate the translate entry reaches, by crate -/// path, over the calls, the closures and the function items of their MIR. -pub(crate) fn reachable(dumps: &Dumps) -> BTreeSet { - let krate = ENTRY.split("::").next().unwrap_or_default(); +/// The functions of its crate an entry reaches, by crate path, over the +/// calls, the closures and the function items of their MIR. +pub(crate) fn reachable_from(entry: &str, dumps: &Dumps) -> BTreeSet { + let krate = entry.split("::").next().unwrap_or_default(); let empty = BTreeMap::new(); let bodies = dumps.crates.get(krate).unwrap_or(&empty); let closures = dumps.closures.get(krate).unwrap_or(&empty); @@ -2081,9 +3557,9 @@ pub(crate) fn reachable(dumps: &Dumps) -> BTreeSet { let mut seen: BTreeSet = BTreeSet::new(); let mut work: Vec<&IrBody> = Vec::new(); let mut closures_seen: BTreeSet<&str> = BTreeSet::new(); - if let Some(entry) = bodies.get(ENTRY.strip_prefix(&prefix).unwrap_or(ENTRY)) { - seen.insert(ENTRY.to_string()); - work.push(entry); + if let Some(body) = bodies.get(entry.strip_prefix(&prefix).unwrap_or(entry)) { + seen.insert(entry.to_string()); + work.push(body); } while let Some(body) = work.pop() { let (calls, made) = body_mentions(body); @@ -2250,26 +3726,7 @@ pub fn agree(dir: &Path) -> Result, UorustError> { /// The translator functions of `register` the manifest does not certify, /// by function, each with its cause. pub fn uncertified(register: &Register, manifest: &Manifest) -> BTreeMap { - let certified = manifest.kappas(); - register - .rows - .iter() - // A root certifies its κ only while the register lifts it. - .filter(|(k, r)| { - in_scope(&r.function) - && !(certified.contains(*k) && matches!(r.status, Status::Lifted(_))) - }) - .map(|(k, r)| { - let cause = match (&r.status, manifest.refused.get(k)) { - (Status::Lifted(d), Some(why)) => format!("lifted as {d}, not exported: {why}"), - (Status::Lifted(d), None) => format!("lifted as {d}, not yet certified"), - (Status::Residue(reason, detail), _) => format!("residue ({reason}): {detail}"), - (Status::Foreign(detail), _) => format!("foreign: {detail}"), - (Status::Effect(effect), _) => format!("effect: {effect}"), - }; - (r.function.clone(), cause) - }) - .collect() + Profile::default().uncertified(register, manifest) } /// The ratchet: the hand-written translator may only shrink. Refused when @@ -2282,22 +3739,116 @@ pub fn ratchet( base: &Register, base_manifest: &Manifest, ) -> Result { - let now = uncertified(head, head_manifest); - let before = uncertified(base, base_manifest); - if now.len() <= before.len() { - return Ok(now.len()); - } - let mut rows = vec![format!( - "{} uncertified translator functions, {} in the parent", - now.len(), - before.len() - )]; - rows.extend( - now.iter() - .filter(|(f, _)| !before.contains_key(*f)) - .map(|(f, cause)| format!("{f}: {cause}")), - ); - Err(UorustError::Grown(rows)) + Profile::default().ratchet(head, head_manifest, base, base_manifest) +} + +impl Profile { + /// The functions of `register` in this profile's scope the manifest + /// does not certify, by function, each with its cause. + pub fn uncertified( + &self, + register: &Register, + manifest: &Manifest, + ) -> BTreeMap { + let certified = manifest.kappas(); + register + .rows + .iter() + // A root certifies its κ only while the register lifts it. + .filter(|(k, r)| { + self.in_scope(&r.function) + && !(certified.contains(*k) && matches!(r.status, Status::Lifted(_))) + }) + .map(|(k, r)| { + let cause = match (&r.status, manifest.refused.get(k)) { + (Status::Lifted(d), Some(why)) => { + format!("lifted as {d}, not exported: {why}") + } + (Status::Lifted(d), None) => format!("lifted as {d}, not yet certified"), + (Status::Residue(reason, detail), _) => { + format!("residue ({reason}): {detail}") + } + (Status::Foreign(detail), _) => format!("foreign: {detail}"), + (Status::Effect(effect), _) => format!("effect: {effect}"), + }; + (r.function.clone(), cause) + }) + .collect() + } + + /// The ratchet over this profile's scope: what is not certified may + /// only shrink. Refused when more functions in scope are uncertified + /// under the head than under the base, naming each that is uncertified + /// under the head and not under the base, with its cause. Returns the + /// head's count. + pub fn ratchet( + &self, + head: &Register, + head_manifest: &Manifest, + base: &Register, + base_manifest: &Manifest, + ) -> Result { + let now = self.uncertified(head, head_manifest); + let before = self.uncertified(base, base_manifest); + if now.len() <= before.len() { + return Ok(now.len()); + } + let mut rows = vec![format!( + "{} uncertified {}, {} in the parent", + now.len(), + self.measured(), + before.len() + )]; + rows.extend( + now.iter() + .filter(|(f, _)| !before.contains_key(*f)) + .map(|(f, cause)| format!("{f}: {cause}")), + ); + Err(UorustError::Grown(rows)) + } + + /// What the ratchet counts, in words: the translator's functions, or + /// the functions in another workspace's scope. + pub fn measured(&self) -> &'static str { + if *self == Profile::default() { + "translator functions" + } else { + "functions in scope" + } + } + + /// [`Profile::ratchet`] of a head measured under this profile against a + /// base that was measured under `base_profile`, when its manifest + /// states one: refused, before any count, when this scope leaves out a + /// prefix the base measured, since a function taken out of the scope is + /// hand-written and no longer counted. + pub fn ratchet_from( + &self, + base_profile: Option<&Profile>, + head: &Register, + head_manifest: &Manifest, + base: &Register, + base_manifest: &Manifest, + ) -> Result { + if self.kind != Kind::Functions { + return Err(UorustError::Tool( + "the ratchet measures functions: the manifest is of a cases export".to_string(), + )); + } + let dropped = base_profile.map(|b| b.dropped_by(self)).unwrap_or_default(); + if !dropped.is_empty() { + let mut rows = vec![format!( + "the scope measures less than the base's: {} of its prefixes are left out", + dropped.len() + )]; + rows.extend(dropped.into_iter().map(|p| { + let prefix = if p.is_empty() { "every function" } else { &p }; + format!("{prefix}: no longer in scope") + })); + return Err(UorustError::Grown(rows)); + } + self.ratchet(head, head_manifest, base, base_manifest) + } } #[cfg(test)] @@ -2352,36 +3903,57 @@ mod tests { ); } + // Main's test of the closure κ (6d6b4e6), on the merged key: a root's + // closure κ changes exactly with what its root reaches, and with the + // compiler and the descriptors. A type no root reaches changes no root's + // closure κ here (its package cannot differ, SPEC §24.7); it changes the + // project's identity, without which no root is carried unverified. #[test] fn a_closure_kappa_changes_exactly_with_what_its_root_reaches() { - let modules = |c_body: &str, type_body: &str| -> BTreeMap { - [ - ( - BEHAVIOR.to_string(), - format!( - "inductive{{\n name: T,\n constructors: [{type_body}]\n}}\n\ndefinition{{\n name: a,\n body: (b 1)\n}}\n\ndefinition{{\n name: b,\n body: (Prelude::p 1)\n}}\n\ndefinition{{name: c, parameters: [], body: {c_body}}}\n" - ), - ), - ( - "Prelude".to_string(), - "definition{\n name: p,\n body: 1\n}\n".to_string(), - ), - ] - .into_iter() - .collect() + let tmp = scratch("closure-kappa"); + let behavior = |c_body: &str, type_body: &str| { + format!( + "\\begin{{lexlean}}{{Behavior}}\n\\begin{{semanticmodule}}\ninductive{{\n name: T,\n constructors: [{type_body}]\n}}\n\ndefinition{{\n name: a,\n body: (b 1)\n}}\n\ndefinition{{\n name: b,\n body: (Prelude::p 1)\n}}\n\ndefinition{{name: c, parameters: [], body: {c_body}}}\n\\end{{semanticmodule}}\n\\end{{lexlean}}\n" + ) }; - let roots = ["a", "b", "c"]; - let base = closure_kappas(&modules("1", "x"), &roots, "lexlean 1"); - let c_changed = closure_kappas(&modules("2", "x"), &roots, "lexlean 1"); + let prelude = "\\begin{lexlean}{Prelude}\n\\begin{semanticmodule}\ndefinition{\n name: p,\n body: 1\n}\n\\end{semanticmodule}\n\\end{lexlean}\n"; + let register = register(&[ + ("k1", "meter::a", Status::Lifted("Behavior::a".into())), + ("k2", "meter::b", Status::Lifted("Behavior::b".into())), + ("k3", "meter::c", Status::Lifted("Behavior::c".into())), + ]); + let profile = keyed_profile(); + let keys = |name: &str, c_body: &str, type_body: &str, compiler: &str, runtime: &str| { + let dir = tmp.join(name); + keyed_projection(&dir, &behavior(c_body, type_body), prelude); + let targets = keyed_targets(runtime); + let input = Input { + profile: &profile, + projection: &dir, + register: ®ister, + targets: &targets, + }; + let compiler = keyed_compiler(compiler); + ( + closure_kappas(&input, &profile.roots(®ister), &compiler).expect("closure κs"), + project_identity(&input, &compiler).expect("a project identity"), + ) + }; + let (base, project) = keys("base", "1", "x", "lexlean 1", "r1"); + let (c_changed, _) = keys("c", "2", "x", "lexlean 1", "r1"); + assert_eq!(base.len(), 3); assert_eq!(base["a"], c_changed["a"]); assert_eq!(base["b"], c_changed["b"]); assert_ne!(base["c"], c_changed["c"]); - // A type, the compiler or the descriptors change every package. - let typed = closure_kappas(&modules("1", "y"), &roots, "lexlean 1"); - let compiled = closure_kappas(&modules("1", "x"), &roots, "lexlean 2"); - for r in roots { - assert_ne!(base[r], typed[r]); + let (typed, typed_project) = keys("typed", "1", "y", "lexlean 1", "r1"); + assert_eq!(base, typed); + assert_ne!(project, typed_project); + // The compiler or the descriptors change every package. + let (compiled, _) = keys("compiled", "1", "x", "lexlean 2", "r1"); + let (described, _) = keys("described", "1", "x", "lexlean 1", "r2"); + for r in ["a", "b", "c"] { assert_ne!(base[r], compiled[r]); + assert_ne!(base[r], described[r]); } } @@ -2420,7 +3992,8 @@ mod tests { package: "uorust_certified_implication".into(), source: "s".into(), certification: "kernel-checked".into(), - closure: String::new(), + closure: None, + edition: None, }; let body = IrBody { arity: 2, @@ -2532,7 +4105,8 @@ mod tests { package: "uorust_certified_a".into(), source: "s".into(), certification: "kernel-checked".into(), - closure: String::new(), + closure: None, + edition: None, }], ..Manifest::default() }; @@ -2603,6 +4177,7 @@ mod tests { let m = Manifest { result: "r".into(), compiler: "0.4.0".into(), + project: Some("p".into()), roots: vec![Certified { function: "uorust::mir::coverage::binop".into(), kappa: "k".into(), @@ -2610,7 +4185,8 @@ mod tests { package: "uorust_certified_binop".into(), source: "s".into(), certification: "kernel-checked".into(), - closure: "c1".into(), + closure: Some("c1".into()), + edition: Some("2021".into()), }], share: Share { translator: 3, @@ -2676,4 +4252,1606 @@ mod tests { .collect(); assert_eq!(names, ["1", "2", "10"]); } + + // Class: the implementation produced from the model, for any workspace. + + /// A workspace that is not the translator's: a meter with two crates. + fn meter() -> Profile { + Profile { + scope: vec!["meter::".to_string()], + entry: None, + package: "meter_certified_".to_string(), + effects: vec!["overflow".to_string()], + target: "rust-core".to_string(), + kind: Kind::Functions, + } + } + + fn scratch(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("uorust-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).expect("a scratch directory"); + dir + } + + // The default of every step is the translator's own export, so its gate + // reads as before: the constants, the committed manifest byte for byte, + // and the committed crate of its roots byte for byte. + #[test] + fn the_default_profile_is_the_translators_own() { + let own = Profile::default(); + assert_eq!(own.scope, SCOPE); + assert_eq!(own.entry.as_deref(), Some(ENTRY)); + assert_eq!(own.package, PACKAGE); + assert_eq!(own.effects, EFFECTS); + assert_eq!(own.target, TARGET); + assert_eq!(own.kind, Kind::Functions); + assert_eq!(Profile::resolve(&Options::default()), Ok(own.clone())); + assert!(SCOPE.iter().all(|s| in_scope(&format!("{s}f")))); + let certified = Path::new(env!("CARGO_MANIFEST_DIR")).join("../certified"); + let path = certified.join("manifest.toml"); + let text = std::fs::read_to_string(&path).expect("the committed manifest"); + let manifest = Manifest::parse(&path, &text).expect("it parses"); + assert_eq!(manifest.to_text(), text); + assert_eq!(manifest.text(&own), text); + assert_eq!(Profile::recorded(&path, &text), Ok(own.clone())); + let lib = std::fs::read_to_string(certified.join("src/lib.rs")).expect("its crate"); + assert_eq!(own.crate_source(&manifest.roots), lib); + } + + // Step 1, the export. The planted defect: roots read through the + // translator's constants give this workspace none. + #[test] + fn another_workspace_has_its_own_roots_packages_effects_and_target() { + let r = register(&[ + ("a", "meter::read", Status::Lifted("Behavior::read".into())), + ( + "b", + "gauge::show", + Status::Lifted("Behavior::showAll".into()), + ), + ( + "c", + "meter::write", + Status::Residue("form".into(), "d".into()), + ), + ]); + assert!(roots(&r).is_empty()); + let meter = meter(); + let found = meter.roots(&r); + assert_eq!(found.len(), 1); + assert_eq!(found[0].function, "meter::read"); + assert_eq!(found[0].package(), "meter_certified_read"); + // Every function of the register, under the empty prefix. + let every = Profile { + scope: vec![String::new()], + ..meter.clone() + }; + let packages: Vec = every.roots(&r).iter().map(Root::package).collect(); + assert_eq!( + packages, + ["meter_certified_read", "meter_certified_show_all"] + ); + let modules: BTreeMap = [ + ( + "Behavior".to_string(), + "definition{\n name: read,\n body: 1\n}\n".to_string(), + ), + ("Prelude".to_string(), String::new()), + ] + .into_iter() + .collect(); + let names: BTreeSet<&str> = ["read"].into_iter().collect(); + let (out, found, refused) = meter.mark(&modules, &names); + assert!(refused.is_empty() && found.contains("read")); + assert!(out["Behavior"].contains( + " executable: true,\n production: {effects: [overflow], targets: [rust-core]}\n}\n" + )); + // An adapter calls the workspace's own certified crate and is named + // by the function's path in its own crate. + let certified = Certified { + function: "meter::dial::read".into(), + kappa: "a".into(), + definition: "read".into(), + package: "meter_certified_read".into(), + source: "s".into(), + certification: "kernel-checked".into(), + closure: None, + edition: None, + }; + let body = IrBody { + arity: 2, + locals: vec!["u32".into(), "&[u32]".into(), "u32".into()], + ..IrBody::default() + }; + let source = "pub fn run(p0: List, p1: u64) -> R {\n}\n"; + let (name, code) = meter + .adapter(&certified, &body, source) + .expect("an adapter"); + assert_eq!(name, "dial_read"); + assert!(code.contains("pub(crate) fn dial_read(p0: &&[u32], p1: &u32) -> Option")); + assert!(code.contains("meter_certified::read::run("), "{code}"); + // The request's descriptor is the profile's target's. + let targets = + r#"{"targets":[{"id":"rust-core","digest":"c0"},{"id":"rust-std","digest":"5d"}]}"#; + assert_eq!(meter.descriptor(targets), Ok("c0".to_string())); + assert_eq!(Profile::default().descriptor(targets), Ok("5d".to_string())); + let none = Profile { + target: "rust-wasm".to_string(), + ..meter + }; + assert!(matches!( + none.descriptor(targets), + Err(UorustError::Malformed { .. }) + )); + } + + #[test] + fn a_workspace_declares_its_profile_in_its_cargo_manifest() { + let dir = scratch("profile").join("meter-ws"); + std::fs::create_dir_all(&dir).expect("the workspace"); + let cargo = dir.join("Cargo.toml"); + std::fs::write(&cargo, "[workspace]\nmembers = [\"meter\"]\n").expect("write"); + // What the workspace gives without a table: everything in scope, + // packages named after its directory, every effect, the std target. + let derived = Profile::of_workspace(&dir).expect("a profile"); + assert_eq!(derived.scope, [""]); + assert!(derived.in_scope("meter::read") && derived.in_scope("gauge::show")); + assert_eq!(derived.entry, None); + assert_eq!(derived.package, "meter_ws_certified_"); + assert_eq!(derived.effects, EFFECTS); + assert_eq!(derived.target, TARGET); + std::fs::write( + &cargo, + "[workspace]\nmembers = [\"meter\"]\n\n[workspace.metadata.uorust.certify]\nscope = [\"meter::\"]\nentry = \"meter::run\"\neffects = [\"overflow\"]\ntarget = \"rust-core\"\n", + ) + .expect("write"); + let declared = Profile::of_workspace(&dir).expect("a profile"); + assert_eq!(declared.scope, ["meter::"]); + assert_eq!(declared.entry.as_deref(), Some("meter::run")); + assert_eq!(declared.package, "meter_ws_certified_"); + assert_eq!(declared.effects, ["overflow"]); + assert_eq!(declared.target, "rust-core"); + // An option replaces what the workspace declares. + let options = Options { + workspace: Some(dir.clone()), + package: Some("m_".to_string()), + cases: true, + ..Options::default() + }; + let resolved = Profile::resolve(&options).expect("a profile"); + assert_eq!( + (resolved.package.as_str(), resolved.kind), + ("m_", Kind::Cases) + ); + assert_eq!(resolved.scope, ["meter::"]); + // What an export records is read back whole, whatever the base. + let table: toml::Value = resolved.rows().parse().expect("rows"); + assert_eq!( + Profile::parse(&cargo, &table, Profile::default()), + Ok(resolved) + ); + for bad in [ + "effects = [\"io\"]\n", + "roots = \"tests\"\n", + "scopes = []\n", + "package = \"Meter-\"\n", + "package = \"9meter_\"\n", + "scope = []\n", + ] { + std::fs::write(&cargo, format!("[package.metadata.uorust.certify]\n{bad}")) + .expect("write"); + assert!( + matches!( + Profile::of_workspace(&dir), + Err(UorustError::Malformed { .. }) + ), + "{bad}" + ); + } + let _ = std::fs::remove_dir_all(dir.parent().expect("the scratch")); + } + + /// What `certify production` keeps of one bundle of one package, under + /// `kept`: the result, the package's source and Cargo manifest, the κ it + /// was exported at, the refusals, the timing and the profile. + fn kept_bundle(kept: &Path, profile: &Profile, root: &Root, source: &str) { + let package = root.package(); + let directory = format!("packages/{}/{package}", profile.target); + let bundle = kept.join("1"); + std::fs::create_dir_all(bundle.join(&directory).join("src")).expect("the package"); + std::fs::write(bundle.join(&directory).join("src/lib.rs"), source).expect("write"); + std::fs::write( + bundle.join(&directory).join("Cargo.toml"), + format!("[package]\nname = \"{package}\"\nversion = \"0.1.0\"\nedition = \"2021\"\n"), + ) + .expect("write"); + let result = serde_json::json!({ + "result_id": "r1", + "roots": [{"outputs": [{ + "certification": {"status": "kernel-checked"}, + "package": { + "directory": directory, + "files": [{ + "path": format!("{directory}/src/lib.rs"), + "sha256": crate::project::sha(source.as_bytes()), + }], + }, + }]}], + }); + std::fs::write(bundle.join("result.json"), result.to_string()).expect("write"); + std::fs::write( + kept.join(KAPPAS), + format!("{package} = \"{}\"\n", root.kappa), + ) + .expect("write"); + std::fs::write( + kept.join(REFUSALS), + "[[refused]]\nkappa = \"k2\"\ncause = \"LLT4005 not eligible\"\n", + ) + .expect("write"); + std::fs::write(kept.join(TIMING), "seconds = 12\nroots = 1\n").expect("write"); + std::fs::write(kept.join(PROFILE), profile.rows()).expect("write"); + } + + // Step 2, taking the bundle in. The planted defects: a package taken + // whatever its function's κ, and a source that is not the one the + // bundle's result records. + #[test] + fn a_sync_takes_the_packages_into_the_named_directory_keyed_by_kappa() { + let tmp = scratch("sync"); + let (kept, dir) = (tmp.join("kept"), tmp.join("meter-certified")); + let profile = Profile { + target: TARGET.to_string(), + ..meter() + }; + let rows = |kappa: &'static str| { + register(&[ + ( + kappa, + "meter::read", + Status::Lifted("Behavior::read".into()), + ), + ( + "k2", + "meter::scale", + Status::Lifted("Behavior::scale".into()), + ), + ("k3", "gauge::show", Status::Lifted("Behavior::show".into())), + ]) + }; + let exported = rows("k1"); + let source = "pub fn run(p0: u64) -> u64 {\n p0\n}\n"; + kept_bundle(&kept, &profile, &profile.roots(&exported)[0], source); + assert_eq!(kept_profile(&kept), Ok(profile.clone())); + let take = |register: &Register| { + let s = Sync { + kept: &kept, + dir: &dir, + register, + projection: None, + adapters: None, + mir: None, + }; + sync(&profile, &s, &profile.roots(register), None, "0.4.0") + }; + let manifest = take(&exported).expect("a sync"); + assert_eq!(manifest.kappas(), ["k1".to_string()].into_iter().collect()); + assert_eq!(manifest.roots[0].function, "meter::read"); + assert_eq!(manifest.roots[0].package, "meter_certified_read"); + assert_eq!(manifest.refused["k2"], "LLT4005 not eligible"); + assert_eq!(manifest.seconds_per_root, Some(12)); + // Two functions in scope, one certified; the gauge is not measured. + assert_eq!( + (manifest.share.translator, manifest.share.certified), + (2, 1) + ); + let read = |rel: &str| std::fs::read_to_string(dir.join(rel)).expect(rel); + assert_eq!(read("roots/meter_certified_read.rs"), source); + assert!(read("src/lib.rs") + .contains("#[path = \"../roots/meter_certified_read.rs\"]\npub mod read;\n")); + let cargo = read("Cargo.toml"); + assert!(cargo.contains("name = \"meter_certified\"\n"), "{cargo}"); + assert!(cargo.contains("edition = \"2021\"\n") && cargo.contains("[workspace]\n")); + // The manifest states the profile it was taken in under. + let text = read("manifest.toml"); + let path = dir.join("manifest.toml"); + assert_eq!(Profile::recorded(&path, &text), Ok(profile.clone())); + assert_eq!(Manifest::parse(&path, &text), Ok(manifest.clone())); + assert!(!text.contains("entry = \"uorust")); + // A caller's own Cargo manifest is kept. + std::fs::write(dir.join("Cargo.toml"), "# the caller's\n").expect("write"); + // The function changed since the export: a new question, whose + // package is not taken, so it is uncertified until rebuilt. + let changed = rows("k9"); + let later = take(&changed).expect("a sync"); + assert!(later.roots.is_empty()); + assert!(!dir.join("roots/meter_certified_read.rs").exists()); + assert_eq!(read("Cargo.toml"), "# the caller's\n"); + assert_eq!( + profile.uncertified(&changed, &later)["meter::read"], + "lifted as Behavior::read, not yet certified" + ); + assert_eq!( + profile + .uncertified(&exported, &manifest) + .keys() + .collect::>(), + ["meter::scale"] + ); + // A source that is not the one the result records is refused. + std::fs::write( + kept.join("1/packages/rust-std/meter_certified_read/src/lib.rs"), + "pub fn run(p0: u64) -> u64 {\n 0\n}\n", + ) + .expect("plant"); + match take(&exported) { + Err(UorustError::Malformed { reason, .. }) => { + assert!(reason.contains("the result records"), "{reason}"); + } + other => panic!("not refused: {other:?}"), + } + let _ = std::fs::remove_dir_all(tmp); + } + + // Step 3, the ratchet. The planted defect: a head measured through the + // translator's scope sees none of this workspace's functions and passes. + #[test] + fn the_ratchet_holds_any_scope_and_a_scope_only_widens() { + let meter = meter(); + let base = register(&[ + ("k1", "meter::read", Status::Lifted("Behavior::read".into())), + ( + "k2", + "meter::scale", + Status::Residue("form".into(), "x".into()), + ), + ]); + let certified = Manifest { + roots: vec![Certified { + function: "meter::read".into(), + kappa: "k1".into(), + definition: "read".into(), + package: "meter_certified_read".into(), + source: "s".into(), + certification: "kernel-checked".into(), + closure: None, + edition: None, + }], + ..Manifest::default() + }; + assert_eq!(meter.ratchet(&base, &certified, &base, &certified), Ok(1)); + let grown = register(&[ + ("k9", "meter::read", Status::Lifted("Behavior::read".into())), + ( + "k2", + "meter::scale", + Status::Residue("form".into(), "x".into()), + ), + ( + "k3", + "meter::sum", + Status::Effect("Fs effect: fs::read".into()), + ), + ( + "k4", + "gauge::show", + Status::Residue("form".into(), "y".into()), + ), + ]); + // The translator's scope measures nothing here. + assert_eq!(ratchet(&grown, &certified, &base, &certified), Ok(0)); + match meter.ratchet(&grown, &certified, &base, &certified) { + Err(UorustError::Grown(rows)) => assert_eq!( + rows, + [ + "3 uncertified functions in scope, 1 in the parent", + "meter::read: lifted as Behavior::read, not yet certified", + "meter::sum: effect: Fs effect: fs::read" + ] + ), + other => panic!("not refused: {other:?}"), + } + // A head that measures less than its base is refused before any + // count; one that measures more is counted under its own scope. + let wide = Profile { + scope: vec![String::new()], + ..meter.clone() + }; + match meter.ratchet_from(Some(&wide), &base, &certified, &base, &certified) { + Err(UorustError::Grown(rows)) => { + assert_eq!(rows[1], "every function: no longer in scope"); + } + other => panic!("not refused: {other:?}"), + } + assert_eq!( + wide.ratchet_from(Some(&meter), &base, &certified, &base, &certified), + Ok(1) + ); + assert_eq!( + meter.ratchet_from(None, &base, &certified, &base, &certified), + Ok(1) + ); + let cases = Profile { + kind: Kind::Cases, + ..meter + }; + assert!(matches!( + cases.ratchet_from(None, &base, &certified, &base, &certified), + Err(UorustError::Tool(_)) + )); + } + + // Step 4, the agreement's export: the roots of a cases export are the + // cases the projection states, read from its modules. + #[test] + fn the_roots_of_a_cases_export_are_the_projections_cases() { + let tmp = scratch("cases"); + std::fs::create_dir_all(tmp.join("src")).expect("the sources"); + std::fs::write( + tmp.join("src/Behavior.lex.tex"), + "definition{\n name: read,\n parameters: [n : Nat],\n result: Nat,\n body: n\n}\n\ndefinition{\n name: acceptMeterReads0Root,\n parameters: [],\n result: Bool,\n body: ((read 2) =? 2)\n}\n\ntheorem{\n name: acceptMeterReads0RootHolds,\n parameters: [],\n statement: ((acceptMeterReads0Root) = true),\n proof: decide{}\n}\n", + ) + .expect("write"); + std::fs::write(tmp.join("src/Prelude.lex.tex"), "").expect("write"); + let r = register(&[("k1", "meter::read", Status::Lifted("Behavior::read".into()))]); + let functions = meter(); + let cases = Profile { + kind: Kind::Cases, + ..functions.clone() + }; + let of = |p: &Profile| -> Vec { + let roots = p.export_roots(&tmp, &r).expect("the roots"); + roots.iter().map(Root::package).collect() + }; + assert_eq!(of(&functions), ["meter_certified_read"]); + // A name longer than a crate's may be is shortened to the bound, + // the same at every export and each root's alone. + let long = |end: &str| Root { + definition: format!( + "acceptMeterReadsEveryRoomOfTheRosterInItsOwnOrderAndKeepsThem{end}" + ), + ..functions.roots(&r)[0].clone() + }; + let (first, second) = (long("0Root").package(), long("1Root").package()); + assert_eq!((first.len(), second.len()), (CRATE_NAME, CRATE_NAME)); + assert!( + first.starts_with("meter_certified_accept_meter_reads_every_room_") && first != second + ); + assert_eq!(first, long("0Root").package()); + assert_eq!(of(&cases), ["meter_certified_accept_meter_reads0_root"]); + let found = cases.export_roots(&tmp, &r).expect("the roots"); + assert_eq!(found[0].function, "meter::read"); + let _ = std::fs::remove_dir_all(tmp); + } + + #[test] + fn a_refusals_class_is_its_cause_without_the_projects_names() { + let admission = Admission { + roots: 4, + admitted: vec!["a".into()], + refused: [ + ("k1", "LLT4005 phase production: production root `Meter.Behavior.read` is not eligible for target `rust-std`: effect mismatch: construct `prim append` realizes effect `allocation`, which the root does not admit (in `Meter.Behavior.read`, reached by Meter.Behavior.read; 1 violation(s) in total)"), + ("k2", "LLT4005 phase production: production root `Meter.Behavior.scale` is not eligible for target `rust-std`: effect mismatch: construct `prim append` realizes effect `allocation`, which the root does not admit (in `Meter.Behavior.scaleLoop1`, reached by Meter.Behavior.scale -> Meter.Behavior.scaleLoop1; 2 violation(s) in total)"), + ("k3", "reaches Behavior::walk, a definition with a function parameter, which no production root may"), + ] + .into_iter() + .map(|(k, c)| (k.to_string(), c.to_string())) + .collect(), + prefix: "Meter".to_string(), + }; + assert_eq!( + admission.causes(), + [ + ("LLT4005 phase production: production root `_` is not eligible for target `rust-std`: effect mismatch: construct `prim append` realizes effect `allocation`, which the root does not admit".to_string(), 2), + ("reaches _ a definition with a function parameter, which no production root may".to_string(), 1), + ] + ); + } + + // Class: keyed. A certified root is never built twice: its export's + // identity states everything its package is a function of, and an export + // carries every root the prior manifest certified at its identity. + + const KEYED_BEHAVIOR: &str = "\\begin{lexlean}{Behavior}\n\\importmodule{Prelude}\n\\begin{semanticmodule}\nstructure{\n name: Reading,\n type_parameters: [],\n parameters: [],\n fields: [{name: value, type: Nat}]\n}\n\ndefinition{\n name: helper,\n parameters: [x : Nat],\n result: Nat,\n body: x\n}\n\ndefinition{\n name: read,\n parameters: [r : Reading],\n result: Nat,\n body: helper (Prelude::unit r.value)\n}\n\ndefinition{name: scale, parameters: [x : Nat], result: Nat, body: x}\n\ndefinition{name: spare, parameters: [x : Nat], result: Nat, body: x}\n\\end{semanticmodule}\n\\end{lexlean}\n"; + + const KEYED_PRELUDE: &str = "\\begin{lexlean}{Prelude}\n\\begin{semanticmodule}\ndefinition{name: unit, parameters: [x : Nat], result: Nat, body: x}\n\\end{semanticmodule}\n\\end{lexlean}\n"; + + const KEYED_COMPILER: &str = "lexlean 0.4.0\nlanguage 1.0\ncompiler-semantics aaaa\nlean-toolchain leanprover/lean4:v4.32.1\n"; + + fn keyed_targets(runtime: &str) -> String { + format!( + "{{\"targets\":[{{\"id\":\"rust-std\",\"digest\":\"d1\",\"runtime\":\"{runtime}\"}},{{\"id\":\"rust-core\",\"digest\":\"d2\",\"runtime\":\"r2\"}}]}}" + ) + } + + /// A projection of two roots, `read` (which reaches `helper`, the + /// structure `Reading` and Prelude's `unit`) and `scale` (which reaches + /// nothing), with the configuration files a build reads. + fn keyed_projection(dir: &Path, behavior: &str, prelude: &str) { + let write = |rel: &str, text: &str| { + let path = dir.join(rel); + std::fs::create_dir_all(path.parent().expect("a parent")).expect("a directory"); + std::fs::write(path, text).expect("a file"); + }; + write( + "lexlean.toml", + "spec = \"lexlean/project/1\"\nname = \"meter\"\nmodule_prefix = \"Meter\"\nlockfile = \"lexlean.lock\"\n\n[[lexicon_source]]\npackage = \"meter.words\"\nkind = \"path\"\npath = \"language/meter.words\"\n", + ); + write( + "lexlean.lock", + "spec = \"lexlean/lock/2\"\n\n[[workspace_file]]\npath = \"lakefile.toml\"\nsha256 = \"x\"\n", + ); + write("lakefile.toml", "name = \"Meter\"\n"); + write("language/meter.words/glossary.toml", "words = 1\n"); + write("frontier.toml", "# the register, which no build reads\n"); + write("src/Behavior.lex.tex", behavior); + write("src/Prelude.lex.tex", prelude); + } + + fn keyed_register() -> Register { + register(&[ + ("k1", "meter::read", Status::Lifted("Behavior::read".into())), + ( + "k2", + "meter::scale", + Status::Lifted("Behavior::scale".into()), + ), + ]) + } + + fn keyed_profile() -> Profile { + Profile { + target: TARGET.to_string(), + ..meter() + } + } + + /// The identities of the two roots of a projection written with these + /// texts, under this compiler and these descriptors. + fn keyed_ids( + tmp: &Path, + name: &str, + behavior: &str, + prelude: &str, + compiler: &str, + targets: &str, + ) -> BTreeMap { + let dir = tmp.join(name); + keyed_projection(&dir, behavior, prelude); + let (profile, register) = (keyed_profile(), keyed_register()); + let input = Input { + profile: &profile, + projection: &dir, + register: ®ister, + targets, + }; + closure_kappas(&input, &profile.roots(®ister), &keyed_compiler(compiler)) + .expect("identities") + } + + /// A prior manifest that certifies each root at its identity, and the + /// source directory that holds each package as a certified crate does. + fn keyed_prior(sources: &Path, ids: &BTreeMap) -> Manifest { + let profile = keyed_profile(); + let mut roots = Vec::new(); + for root in profile.roots(&keyed_register()) { + let bytes = format!("pub fn run() -> u64 {{ {} }}\n", root.definition.len()); + let path = sources.join("roots").join(format!("{}.rs", root.package())); + std::fs::create_dir_all(path.parent().expect("a parent")).expect("roots"); + std::fs::write(&path, &bytes).expect("a source"); + roots.push(Certified { + function: root.function.clone(), + kappa: root.kappa.clone(), + definition: root.definition.clone(), + package: root.package(), + source: crate::project::sha(bytes.as_bytes()), + certification: "kernel-checked".into(), + closure: ids.get(&root.definition).cloned(), + edition: Some("2021".into()), + }); + } + Manifest { + result: "r-prior".into(), + compiler: "0.4.0".into(), + roots, + seconds_per_root: Some(7), + ..Manifest::default() + } + } + + // The planted defects: an export that builds the roots it carries runs + // `lexlean` (absent here) and fails; a sync that drops the carried + // packages certifies nothing; a manifest that loses the identity carries + // nothing the next time. + #[test] + fn keyed_an_unchanged_root_is_carried_byte_for_byte_and_never_built() { + let tmp = scratch("keyed-carry"); + let targets = keyed_targets("r1"); + let ids = keyed_ids( + &tmp, + "p", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ); + let sources = tmp.join("prior"); + let manifest = keyed_prior(&sources, &ids); + let (profile, register) = (keyed_profile(), keyed_register()); + let projection = tmp.join("p"); + let input = Input { + profile: &profile, + projection: &projection, + register: ®ister, + targets: &targets, + }; + let export = |manifest: &Manifest, sources: &[PathBuf], kept: &Path, verify: Verifier| { + production_build( + &input, + &tmp.join("out"), + kept, + &Prior { + manifest, + sources, + verify, + }, + &keyed_compiler(KEYED_COMPILER), + Scope::default(), + ) + }; + let kept = tmp.join("kept"); + // The prior export verified no project: the project is verified + // once, before anything is carried. + let done = export( + &manifest, + std::slice::from_ref(&sources), + &kept, + keyed_verifies, + ) + .expect("an export"); + assert_eq!( + done, + Exported { + carried: 2, + built: 0, + builds: 0, + refused: 0 + } + ); + let dir = tmp.join("certified"); + let synced = sync( + &profile, + &Sync { + kept: &kept, + dir: &dir, + register: ®ister, + projection: None, + adapters: None, + mir: None, + }, + &profile.roots(®ister), + None, + "0.4.0", + ) + .expect("a sync"); + assert_eq!( + synced.kappas(), + ["k1", "k2"].map(String::from).into_iter().collect() + ); + for root in &synced.roots { + let prior = std::fs::read(sources.join("roots").join(format!("{}.rs", root.package))); + let now = std::fs::read(dir.join("roots").join(format!("{}.rs", root.package))); + assert_eq!( + prior.expect("the prior source"), + now.expect("the carried source") + ); + assert_eq!(root.closure, ids.get(&root.definition).cloned()); + } + assert_eq!(synced.result, "r-prior"); + // The figure the shards are sized by survives an export that built + // nothing. + assert_eq!(synced.seconds_per_root, Some(7)); + let text = std::fs::read_to_string(dir.join("manifest.toml")).expect("the manifest"); + assert_eq!( + Manifest::parse(&dir.join("manifest.toml"), &text).as_ref(), + Ok(&synced) + ); + // A steady export: the synced manifest is the next prior, its crate + // the next source, and again nothing is built. + // It verifies nothing again: the manifest holds the project. + assert!(synced.project.is_some()); + let again = export( + &synced, + std::slice::from_ref(&dir), + &tmp.join("kept2"), + keyed_never_verified, + ) + .expect("a steady export"); + assert_eq!((again.carried, again.builds), (2, 0)); + // A source that is not the one the manifest records is not carried: + // the export then builds it, and finds no compiler here. + std::fs::write( + sources.join("roots").join("meter_certified_scale.rs"), + "pub fn run() -> u64 { 0 }\n", + ) + .expect("plant"); + let found = carried( + &profile.roots(®ister), + &ids, + &Prior { + manifest: &manifest, + sources: std::slice::from_ref(&sources), + verify: keyed_verifies, + }, + ) + .expect("carried"); + assert_eq!( + found + .iter() + .map(|c| c.definition.as_str()) + .collect::>(), + ["read"] + ); + assert!(export( + &manifest, + std::slice::from_ref(&sources), + &tmp.join("kept3"), + keyed_verifies + ) + .is_err()); + // A carried source changed after the export is refused by the sync. + std::fs::write(kept.join(CARRIED_DIR).join("meter_certified_read.rs"), "x").expect("plant"); + let refused = sync( + &profile, + &Sync { + kept: &kept, + dir: &dir, + register: ®ister, + projection: None, + adapters: None, + mir: None, + }, + &profile.roots(®ister), + None, + "0.4.0", + ); + match refused { + Err(UorustError::Malformed { reason, .. }) => { + assert!(reason.contains("the prior manifest records"), "{reason}"); + } + other => panic!("not refused: {other:?}"), + } + let _ = std::fs::remove_dir_all(tmp); + } + + // The planted defects: an identity of the root's own declaration alone, + // or a carry keyed by κ, carries `read` after its callee changed. + #[test] + fn keyed_a_change_in_a_roots_closure_builds_it_again_though_its_kappa_is_unchanged() { + let tmp = scratch("keyed-closure"); + let targets = keyed_targets("r1"); + let at = |name: &str, behavior: &str, prelude: &str| { + keyed_ids(&tmp, name, behavior, prelude, KEYED_COMPILER, &targets) + }; + let base = at("base", KEYED_BEHAVIOR, KEYED_PRELUDE); + let same = |ids: &BTreeMap, def: &str| ids[def] == base[def]; + // The callee changes; the register (every κ) does not. + let callee = at( + "callee", + &KEYED_BEHAVIOR.replace( + " body: x\n}\n\ndefinition{\n name: read", + " body: 0\n}\n\ndefinition{\n name: read", + ), + KEYED_PRELUDE, + ); + assert!(!same(&callee, "read") && same(&callee, "scale")); + // A type the root names, and a definition of another module it calls. + let ty = at( + "type", + &KEYED_BEHAVIOR.replace("{name: value, type: Nat}", "{name: value, type: Int}"), + KEYED_PRELUDE, + ); + assert!(!same(&ty, "read") && same(&ty, "scale")); + let prelude = at( + "prelude", + KEYED_BEHAVIOR, + &KEYED_PRELUDE.replace("body: x}", "body: 1}"), + ); + assert!(!same(&prelude, "read") && same(&prelude, "scale")); + // What no root reaches, the order of declarations, blank lines and + // the files no build reads change nothing. + let spare = at( + "spare", + &KEYED_BEHAVIOR.replace( + "name: spare, parameters: [x : Nat], result: Nat, body: x", + "name: spare, parameters: [x : Nat], result: Nat, body: 2", + ), + KEYED_PRELUDE, + ); + assert_eq!(spare, base); + let moved = at( + "moved", + &KEYED_BEHAVIOR.replace( + "\\begin{semanticmodule}\n", + "\\begin{semanticmodule}\nstructure{\n name: Other,\n type_parameters: [],\n parameters: [],\n fields: []\n}\n\n\n", + ), + KEYED_PRELUDE, + ); + assert_eq!(moved, base); + std::fs::write(tmp.join("base").join("frontier.toml"), "# moved\n").expect("write"); + assert_eq!(at("base", KEYED_BEHAVIOR, KEYED_PRELUDE), base); + // The plan counts what is left: the prior certified both at the base. + let sources = tmp.join("prior"); + let manifest = keyed_prior(&sources, &base); + let roots = keyed_profile().roots(&keyed_register()); + let prior = Prior { + manifest: &manifest, + sources: std::slice::from_ref(&sources), + verify: keyed_verifies, + }; + let (profile, register) = (keyed_profile(), keyed_register()); + let projection = tmp.join("callee"); + let input = Input { + profile: &profile, + projection: &projection, + register: ®ister, + targets: &targets, + }; + let decided = + carry(&input, &roots, &keyed_compiler(KEYED_COMPILER), &prior).expect("carry"); + assert_eq!(decided.ids, callee); + let carried_now: BTreeSet = decided + .carried + .iter() + .map(|c| c.definition.clone()) + .collect(); + assert_eq!(carried_now, ["scale".to_string()].into_iter().collect()); + let plan = plan_keyed(&roots, Some(&decided), &manifest, u64::MAX / 2); + assert_eq!( + (plan.carried, plan.build, plan.refused, plan.shards), + (Some(1), 1, 0, 1) + ); + // Without identities nothing is known to be carried. + let blind = plan_keyed(&roots, None, &manifest, u64::MAX / 2); + assert_eq!((blind.carried, blind.build), (None, 2)); + // A manifest written before identities carries nothing. + let mut old = manifest.clone(); + for r in &mut old.roots { + r.closure = None; + } + let none = carried( + &roots, + &base, + &Prior { + manifest: &old, + sources: &[sources], + verify: keyed_verifies, + }, + ); + assert_eq!(none.map(|c| c.len()), Ok(0)); + let _ = std::fs::remove_dir_all(tmp); + } + + // The planted defect: an identity without the compiler's lines, the + // descriptor or the project's files keeps every root carried. + #[test] + fn keyed_a_compiler_descriptor_or_configuration_change_builds_every_root_again() { + let tmp = scratch("keyed-toolchain"); + let targets = keyed_targets("r1"); + let base = keyed_ids( + &tmp, + "base", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ); + let all_differ = |ids: &BTreeMap| { + assert_eq!(ids.len(), base.len()); + for (def, id) in ids { + assert_ne!(&base[def], id, "{def} keeps its identity"); + } + }; + // One version, another compiler semantics. + let semantics = KEYED_COMPILER.replace("aaaa", "bbbb"); + assert_eq!( + keyed_compiler(&semantics).version(), + keyed_compiler(KEYED_COMPILER).version() + ); + all_differ(&keyed_ids( + &tmp, + "c", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + &semantics, + &targets, + )); + let toolchain = KEYED_COMPILER.replace("v4.32.1", "v4.33.0"); + all_differ(&keyed_ids( + &tmp, + "l", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + &toolchain, + &targets, + )); + // The target's runtime, under one descriptor id. + all_differ(&keyed_ids( + &tmp, + "t", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + KEYED_COMPILER, + &keyed_targets("r9"), + )); + // Another target's descriptor is no input. + let other = targets.replace("\"r2\"", "\"r8\""); + assert_eq!( + keyed_ids( + &tmp, + "o", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + KEYED_COMPILER, + &other + ), + base + ); + // The project's configuration, a lexicon it reads, a workspace file + // its lock binds. + for (rel, text) in [ + ("lexlean.toml", None), + ("language/meter.words/glossary.toml", Some("words = 2\n")), + ("lakefile.toml", Some("name = \"Meter2\"\n")), + ] { + let name = format!("f-{}", rel.replace('/', "-")); + let dir = tmp.join(&name); + keyed_projection(&dir, KEYED_BEHAVIOR, KEYED_PRELUDE); + let path = dir.join(rel); + let changed = match text { + Some(t) => t.to_string(), + None => { + std::fs::read_to_string(&path).expect("read") + "\n[limits]\nmax_ir_nodes = 1\n" + } + }; + std::fs::write(&path, changed).expect("write"); + let (profile, register) = (keyed_profile(), keyed_register()); + let input = Input { + profile: &profile, + projection: &dir, + register: ®ister, + targets: &targets, + }; + all_differ( + &closure_kappas( + &input, + &profile.roots(®ister), + &keyed_compiler(KEYED_COMPILER), + ) + .expect("identities"), + ); + } + // The effects the roots admit. + let dir = tmp.join("base"); + let profile = Profile { + effects: vec!["allocation".into()], + ..keyed_profile() + }; + let register = keyed_register(); + let input = Input { + profile: &profile, + projection: &dir, + register: ®ister, + targets: &targets, + }; + all_differ( + &closure_kappas( + &input, + &profile.roots(®ister), + &keyed_compiler(KEYED_COMPILER), + ) + .expect("identities"), + ); + let _ = std::fs::remove_dir_all(tmp); + } + + #[test] + fn keyed_a_modules_declarations_are_read_by_name_whatever_their_kind_and_place() { + let (frame, decls, order) = declarations(KEYED_BEHAVIOR); + assert_eq!(order, ["Reading", "helper", "read", "scale", "spare"]); + assert_eq!( + decls.keys().map(String::as_str).collect::>(), + ["Reading", "helper", "read", "scale", "spare"] + ); + assert_eq!( + frame, + [ + "\\begin{lexlean}{Behavior}", + "\\importmodule{Prelude}", + "\\begin{semanticmodule}", + "\\end{semanticmodule}", + "\\end{lexlean}" + ] + ); + assert!(decls["Reading"].starts_with("structure{\n") && decls["Reading"].ends_with("}\n")); + assert_eq!( + decls["scale"], + "definition{name: scale, parameters: [x : Nat], result: Nat, body: x}\n" + ); + } + + // keyed: the counterexamples of refute-keyed-6. Each identity input a + // refuter found missing is in the identity now, with its test: a linked + // package, the closure's relative order, the project a build verifies, + // a carried package's edition, and the marking's refusals in the plan. + + fn keyed_verifies(dir: &Path) -> Result, UorustError> { + assert!(dir.join("request.json").is_file(), "no production project"); + Ok(None) + } + + // keyed2: the verification of a project nothing was built in marks one + // root, so that its cost does not grow with the roots. + fn keyed_verifies_one(dir: &Path) -> Result, UorustError> { + let request = std::fs::read_to_string(dir.join("request.json")).expect("a request"); + let request: serde_json::Value = serde_json::from_str(&request).expect("json"); + assert_eq!(request["roots"].as_array().map(Vec::len), Some(1)); + Ok(None) + } + + fn keyed_refuses(dir: &Path) -> Result, UorustError> { + assert!(dir.join("request.json").is_file(), "no production project"); + Ok(Some( + "LLV7002 Lean rejected `Meter.Behavior`: Tactic rfl failed".to_string(), + )) + } + + fn keyed_never_verified(dir: &Path) -> Result, UorustError> { + panic!("verified {} again", dir.display()) + } + + /// The input of the base projection under `dir`, read with the + /// compiler and descriptors of the other keyed tests. + fn keyed_decide(dir: &Path, register: &Register, prior: &Prior<'_>) -> Carry { + let profile = keyed_profile(); + let targets = keyed_targets("r1"); + let input = Input { + profile: &profile, + projection: dir, + register, + targets: &targets, + }; + carry( + &input, + &profile.roots(register), + &keyed_compiler(KEYED_COMPILER), + prior, + ) + .expect("carry") + } + + fn keyed_project(dir: &Path) -> String { + let (profile, register) = (keyed_profile(), keyed_register()); + let targets = keyed_targets("r1"); + let input = Input { + profile: &profile, + projection: dir, + register: ®ister, + targets: &targets, + }; + project_identity(&input, &keyed_compiler(KEYED_COMPILER)).expect("a project identity") + } + + // The planted defect: an identity without the linked packages' trees + // carries a root whose package body changed. + #[test] + fn keyed_a_linked_packages_body_is_in_every_roots_identity() { + let tmp = scratch("keyed-package"); + let targets = keyed_targets("r1"); + let ws = tmp.join("ws"); + let app = ws.join("app"); + let write = |path: &Path, text: &str| { + std::fs::create_dir_all(path.parent().expect("a parent")).expect("a directory"); + std::fs::write(path, text).expect("a file"); + }; + let behavior = KEYED_BEHAVIOR.replace( + " body: helper (Prelude::unit r.value)\n", + " body: helper (PkgLib.Util::combine r.value)\n", + ); + keyed_projection(&app, &behavior, KEYED_PRELUDE); + let config = app.join("lexlean.toml"); + let text = std::fs::read_to_string(&config).expect("read"); + write( + &config, + &format!("{text}\n[[source_package]]\npackage = \"pkglib\"\nversion = \"1.0.0\"\nkind = \"path\"\npath = \"lib\"\n"), + ); + write( + &ws.join("lexlean-workspace.toml"), + "spec = \"lexlean/workspace/1\"\nmembers = [\"app\", \"lib\", \"out/0\"]\n", + ); + write( + &ws.join("lib/lexlean.toml"), + "spec = \"lexlean/project/1\"\nname = \"pkglib\"\nmodule_prefix = \"PkgLib\"\nsource_roots = [\"src\"]\n", + ); + let util = ws.join("lib/src/Util.lex.tex"); + write( + &util, + "\\begin{lexlean}{Util}\n\\begin{semanticmodule}\ndefinition{name: combine, parameters: [x : Nat], result: Nat, body: x}\n\\end{semanticmodule}\n\\end{lexlean}\n", + ); + let (profile, register) = (keyed_profile(), keyed_register()); + let ids = || { + let input = Input { + profile: &profile, + projection: &app, + register: ®ister, + targets: &targets, + }; + closure_kappas( + &input, + &profile.roots(®ister), + &keyed_compiler(KEYED_COMPILER), + ) + .expect("identities") + }; + let base = ids(); + let project = keyed_project(&app); + let all_differ = |now: &BTreeMap| { + for (def, id) in now { + assert_ne!(&base[def], id, "{def} keeps its identity"); + } + }; + // The package's body changes: every root, and the project. + std::fs::write( + &util, + std::fs::read_to_string(&util) + .expect("read") + .replace("body: x}", "body: 0}"), + ) + .expect("plant"); + all_differ(&ids()); + assert_ne!(keyed_project(&app), project); + // A file the language does not read of the package changes nothing. + let restore = std::fs::read_to_string(&util) + .expect("read") + .replace("body: 0}", "body: x}"); + std::fs::write(&util, restore).expect("restore"); + assert_eq!(ids(), base); + write(&ws.join("lib/notes.txt"), "not a source\n"); + assert_eq!(ids(), base); + // The package's manifest and the workspace that grants it do. + write( + &ws.join("lib/lexlean.toml"), + "spec = \"lexlean/project/1\"\nname = \"pkglib\"\nmodule_prefix = \"PkgLib\"\nsource_roots = [\"src\"]\n\n[limits]\nmax_ir_nodes = 1\n", + ); + all_differ(&ids()); + let _ = std::fs::remove_dir_all(tmp); + } + + // The planted defect: an identity without the closure's order carries a + // root whose callee now follows it, which the language refuses. + #[test] + fn keyed_the_relative_order_of_a_roots_closure_is_in_its_identity() { + let tmp = scratch("keyed-order"); + let targets = keyed_targets("r1"); + let at = |name: &str, behavior: &str| { + keyed_ids( + &tmp, + name, + behavior, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ) + }; + let base = at("base", KEYED_BEHAVIOR); + let helper = "definition{\n name: helper,\n parameters: [x : Nat],\n result: Nat,\n body: x\n}\n\n"; + assert!(KEYED_BEHAVIOR.contains(helper)); + // `helper` moved below `read`, which calls it: the same texts. + let moved = KEYED_BEHAVIOR.replace(helper, "").replace( + "definition{name: scale,", + &format!("{helper}definition{{name: scale,"), + ); + let (_, before, _) = declarations(KEYED_BEHAVIOR); + let (_, after, order) = declarations(&moved); + assert_eq!(before, after); + assert_eq!(order, ["Reading", "read", "helper", "scale", "spare"]); + let now = at("moved", &moved); + assert_ne!(now["read"], base["read"]); + assert_eq!(now["scale"], base["scale"]); + // A declaration the closure does not hold moving changes nothing. + let spare = "definition{name: spare, parameters: [x : Nat], result: Nat, body: x}\n\n"; + let first = KEYED_BEHAVIOR.replace(spare, "").replace( + "\\begin{semanticmodule}\n", + &format!("\\begin{{semanticmodule}}\n{spare}"), + ); + assert_eq!(at("spare", &first), base); + let _ = std::fs::remove_dir_all(tmp); + } + + // The planted defect: a carry that does not verify the project carries + // both roots into a project whose theorem is false. + #[test] + fn keyed_a_root_is_carried_only_into_a_project_that_verifies() { + let tmp = scratch("keyed-project"); + let targets = keyed_targets("r1"); + let base = keyed_ids( + &tmp, + "base", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ); + let sources = tmp.join("prior"); + let mut manifest = keyed_prior(&sources, &base); + // A false theorem no root reaches: no root's identity moves, the + // project's does. + let theorem = KEYED_BEHAVIOR.replace( + "\\end{semanticmodule}", + "theorem{name: scaleIsZero, statement: ((scale 1) = 0), proof: reflexivity{}}\n\\end{semanticmodule}", + ); + let ids = keyed_ids( + &tmp, + "false", + &theorem, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ); + assert_eq!(ids, base); + let (dir, register) = (tmp.join("false"), keyed_register()); + let project = keyed_project(&dir); + assert_ne!(project, keyed_project(&tmp.join("base"))); + let decide = |manifest: &Manifest| { + keyed_decide( + &dir, + ®ister, + &Prior { + manifest, + sources: std::slice::from_ref(&sources), + verify: keyed_never_verified, + }, + ) + }; + // The decision verifies nothing: both roots are candidates, and the + // plan counts them carried, as an export that verifies carries them. + let candidates = decide(&manifest); + assert_eq!((candidates.carried.len(), candidates.verified), (2, false)); + let plan = plan_keyed( + &keyed_profile().roots(®ister), + Some(&candidates), + &manifest, + u64::MAX / 2, + ); + assert_eq!((plan.carried, plan.build), (Some(2), 0)); + // The project the prior export verified is known to verify. + manifest.project = Some(project.clone()); + let known = decide(&manifest); + assert_eq!((known.carried.len(), known.verified), (2, true)); + assert_eq!(known.project, project); + // A module no root imports, and the project's lock, are verified + // by a build: either moves the project; the register does not. + let other = dir.join("src").join("Quality.lex.tex"); + std::fs::write(&other, "\\begin{lexlean}{Quality}\n\\end{lexlean}\n").expect("write"); + assert_ne!(keyed_project(&dir), project); + std::fs::remove_file(&other).expect("remove"); + assert_eq!(keyed_project(&dir), project); + let lock = dir.join("lexlean.lock"); + let locked = std::fs::read_to_string(&lock).expect("the lock"); + std::fs::write(&lock, format!("{locked}\n# relocked\n")).expect("write"); + assert_ne!(keyed_project(&dir), project); + std::fs::write(&lock, locked).expect("restore"); + std::fs::write(dir.join("frontier.toml"), "# moved\n").expect("write"); + // The export, of a project no export verified. + manifest.project = None; + let profile = keyed_profile(); + let input = Input { + profile: &profile, + projection: &dir, + register: ®ister, + targets: &targets, + }; + let export = |manifest: &Manifest, verify: Verifier| { + production_build( + &input, + &tmp.join("out"), + &tmp.join("kept"), + &Prior { + manifest, + sources: std::slice::from_ref(&sources), + verify, + }, + &keyed_compiler(KEYED_COMPILER), + Scope::default(), + ) + }; + // An export that builds nothing verifies the project once, with one + // root marked; when it refuses, the carried roots are built (and no + // compiler is found here), so nothing is published unverified. + assert!(export(&manifest, keyed_refuses).is_err()); + let done = export(&manifest, keyed_verifies_one).expect("an export"); + assert_eq!((done.carried, done.builds), (2, 0)); + let kept = std::fs::read_to_string(tmp.join("kept").join(PROJECT)).expect("the project"); + assert_eq!(kept, format!("identity = \"{}\"\n", keyed_project(&dir))); + // Verified by the prior export, it is not verified again. + let mut verified = manifest.clone(); + verified.project = Some(keyed_project(&dir)); + let steady = export(&verified, keyed_never_verified).expect("a steady export"); + assert_eq!((steady.carried, steady.builds), (2, 0)); + let _ = std::fs::remove_dir_all(tmp); + } + + // The planted defect: a sync that takes the edition from built bundles + // only writes a crate of no edition (Rust 2015) for carried packages. + #[test] + fn keyed_an_all_carried_sync_writes_the_edition_its_packages_were_built_for() { + let tmp = scratch("keyed-edition"); + let targets = keyed_targets("r1"); + let ids = keyed_ids( + &tmp, + "p", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ); + let sources = tmp.join("prior"); + let mut manifest = keyed_prior(&sources, &ids); + let (profile, register) = (keyed_profile(), keyed_register()); + let projection = tmp.join("p"); + let input = Input { + profile: &profile, + projection: &projection, + register: ®ister, + targets: &targets, + }; + let kept = tmp.join("kept"); + let done = production_build( + &input, + &tmp.join("out"), + &kept, + &Prior { + manifest: &manifest, + sources: std::slice::from_ref(&sources), + verify: keyed_verifies, + }, + &keyed_compiler(KEYED_COMPILER), + Scope::default(), + ) + .expect("an export"); + assert_eq!((done.carried, done.builds), (2, 0)); + let dir = tmp.join("crate"); + let synced = sync( + &profile, + &Sync { + kept: &kept, + dir: &dir, + register: ®ister, + projection: None, + adapters: None, + mir: None, + }, + &profile.roots(®ister), + None, + "0.4.0", + ) + .expect("a sync"); + let cargo = std::fs::read_to_string(dir.join("Cargo.toml")).expect("a Cargo manifest"); + assert!(cargo.contains("edition = \"2021\""), "{cargo}"); + assert!(synced + .roots + .iter() + .all(|r| r.edition.as_deref() == Some("2021"))); + // A prior that does not record the edition carries nothing. + for r in &mut manifest.roots { + r.edition = None; + } + let none = carried( + &profile.roots(®ister), + &ids, + &Prior { + manifest: &manifest, + sources: std::slice::from_ref(&sources), + verify: keyed_verifies, + }, + ); + assert_eq!(none.map(|c| c.len()), Ok(0)); + let _ = std::fs::remove_dir_all(tmp); + } + + // The planted defect: a plan or an export that counts only the prior + // compiler's refusals misses the marking's. + #[test] + fn keyed_the_plan_counts_the_markings_refusals_as_the_export_does() { + let tmp = scratch("keyed-marked"); + let targets = keyed_targets("r1"); + let behavior = KEYED_BEHAVIOR.replace( + "\\end{semanticmodule}", + "definition{name: applyBoth, parameters: [f : (Fn Nat Nat), x : Nat], result: Nat, body: f x}\n\\end{semanticmodule}", + ); + let ids = keyed_ids( + &tmp, + "p", + &behavior, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ); + let sources = tmp.join("prior"); + let manifest = keyed_prior(&sources, &ids); + let mut register = keyed_register(); + register.rows.insert( + "k3".to_string(), + crate::register::Row { + function: "meter::apply_both".to_string(), + status: Status::Lifted("Behavior::applyBoth".into()), + divergence: None, + }, + ); + let profile = keyed_profile(); + let roots = profile.roots(®ister); + assert_eq!(roots.len(), 3); + let projection = tmp.join("p"); + let prior = Prior { + manifest: &manifest, + sources: std::slice::from_ref(&sources), + verify: keyed_verifies, + }; + let decided = keyed_decide(&projection, ®ister, &prior); + assert_eq!( + decided + .marked + .keys() + .map(String::as_str) + .collect::>(), + ["applyBoth"] + ); + let plan = plan_keyed(&roots, Some(&decided), &manifest, u64::MAX / 2); + assert_eq!((plan.carried, plan.build, plan.refused), (Some(2), 0, 1)); + let input = Input { + profile: &profile, + projection: &projection, + register: ®ister, + targets: &targets, + }; + let done = production_build( + &input, + &tmp.join("out"), + &tmp.join("kept"), + &prior, + &keyed_compiler(KEYED_COMPILER), + Scope::default(), + ) + .expect("an export"); + assert_eq!( + done, + Exported { + carried: 2, + built: 0, + builds: 0, + refused: 1 + } + ); + let _ = std::fs::remove_dir_all(tmp); + } + + // keyed2: one key after the merge of main's closure κ. A manifest of + // either past shape is read: the first keyed export's (`identity` rows) + // is carried, since its key is this one under its first name; main's + // (`closure` rows of its own tag and text) never equals this key, so + // its roots are built once. + #[test] + fn keyed2_a_manifest_of_either_past_shape_is_read_and_only_this_key_carries() { + let tmp = scratch("keyed2-shapes"); + let targets = keyed_targets("r1"); + let ids = keyed_ids( + &tmp, + "p", + KEYED_BEHAVIOR, + KEYED_PRELUDE, + KEYED_COMPILER, + &targets, + ); + let sources = tmp.join("prior"); + let written = keyed_prior(&sources, &ids).to_text(); + assert_eq!(written.matches("\nclosure = ").count(), 2); + let path = tmp.join("manifest.toml"); + let carry = |text: &str| { + let manifest = Manifest::parse(&path, text).expect("a manifest of a past shape"); + carried( + &keyed_profile().roots(&keyed_register()), + &ids, + &Prior { + manifest: &manifest, + sources: std::slice::from_ref(&sources), + verify: keyed_verifies, + }, + ) + .expect("carried") + .len() + }; + assert_eq!(carry(&written), 2); + let first = written.replace("\nclosure = ", "\nidentity = "); + assert_eq!(carry(&first), 2); + // Main's shape: each root's closure κ of main's own text. + let mut main = written.clone(); + for id in ids.values() { + let theirs = + crate::project::sha(format!("uorust/certified-closure/1\n{id}").as_bytes()); + main = main.replace(id.as_str(), &theirs); + } + assert_eq!(carry(&main), 0); + // Rewritten, a manifest keeps the key under this name only. + let read = Manifest::parse(&path, &first).expect("a manifest"); + assert_eq!(read.to_text(), written); + let _ = std::fs::remove_dir_all(tmp); + } + + // Class keyed, the refuter's transitive case: a module that only another + // module's import reaches. + #[test] + fn keyed_a_module_reached_through_another_modules_import_is_in_every_roots_identity() { + let tmp = scratch("keyed-transitive"); + let targets = keyed_targets("r1"); + let behavior = KEYED_BEHAVIOR.replace( + "\\importmodule{Prelude}\n", + "\\importmodule{Prelude}\n\\importmodule{Helpers}\n", + ); + assert_ne!(behavior, KEYED_BEHAVIOR); + let ids = |name: &str, deep: &str, apart: &str| { + let dir = tmp.join(name); + keyed_projection(&dir, &behavior, KEYED_PRELUDE); + let write = |module: &str, text: &str| { + std::fs::write(dir.join("src").join(format!("{module}.lex.tex")), text) + .expect("a module"); + }; + write( + "Helpers", + "\\begin{lexlean}{Helpers}\n\\importmodule{Deep}\n\\end{lexlean}\n", + ); + write("Deep", deep); + write("Apart", apart); + let (profile, register) = (keyed_profile(), keyed_register()); + let input = Input { + profile: &profile, + projection: &dir, + register: ®ister, + targets: &targets, + }; + closure_kappas( + &input, + &profile.roots(®ister), + &keyed_compiler(KEYED_COMPILER), + ) + .expect("identities") + }; + // Deep imports Helpers back, so the walk must end on a cycle. + let and = "\\begin{lexlean}{Deep}\n\\importmodule{Helpers}\ncore a b = (a && b)\n\\end{lexlean}\n"; + let base = ids("base", and, "one\n"); + assert!(!base.is_empty()); + assert_eq!(ids("again", and, "one\n"), base); + // Helpers alone imports Deep: its body is in every root's identity. + let or = and.replace("&&", "||"); + for (def, id) in &ids("or", &or, "one\n") { + assert_ne!( + &base[def], id, + "{def} keeps its identity though Deep changed" + ); + } + // A module no import reaches is the project's identity's, not a root's. + assert_eq!(ids("apart", and, "two\n"), base); + let _ = std::fs::remove_dir_all(tmp); + } + + // keyed2 (item 0): a test states its compiler. The stand-in is a + // program that exists nowhere, so a build the test does not expect fails + // to start wherever the suite runs, whether or not a real `lexlean` is + // on the path; what the compiler states of itself is the test's own. + fn keyed_compiler(stated: &str) -> Compiler { + Compiler { + stated: stated.to_string(), + program: PathBuf::from("/nonexistent/uorust-test-stand-in/lexlean"), + } + } } diff --git a/crates/uorust/src/certify/cases.rs b/crates/uorust/src/certify/cases.rs new file mode 100644 index 00000000..1176b1ad --- /dev/null +++ b/crates/uorust/src/certify/cases.rs @@ -0,0 +1,612 @@ +//! Agreement for any workspace: the certified package and the function it +//! certifies, on the cases the workspace's own tests state. +//! +//! The translator's differential ([`super::agree`]) compares whole outputs +//! of one program run twice, once through its certified packages and once +//! through its hand-written functions. It relies on what only the +//! translator has: a `certified!` call site written as the first statement +//! of each hand-written function, an adapter per root that converts the +//! function's own types to the package's (generated from the crate's MIR +//! dumps, into a module of the crate itself), the certified crate as a +//! dependency of the crate it certifies, a `--translator` switch in the +//! binary, a build flag that hides the call site from the lift, and a corpus +//! the binary translates (core, and itself). A workspace that is only +//! projected has none of these. +//! +//! What every projected workspace does have is its tests. The projection +//! states each closed assertion of a test over a lifted function as a closed +//! Boolean definition and proves it true ([`cases`]). Each is a production +//! root with no parameter: `lexlean production` certifies the Rust of the +//! whole assertion, the function's definition in its closure, and rustc runs +//! it ([`answers`]). The same assertion over the Rust function is the test +//! itself, which cargo runs ([`tests`]). A case agrees when the certified +//! package answers true and its test passes ([`verdicts`]); the cases are +//! the tests' own, none is invented, and a function no test asserts on has +//! none. + +use std::collections::{BTreeMap, BTreeSet}; +use std::path::Path; + +use super::{Definitions, Kind, Manifest, Profile, Root, BEHAVIOR}; +use crate::error::io; +use crate::register::{Register, Status}; +use crate::UorustError; + +/// The domain tag of a case's κ. +pub const DOMAIN: &str = "uorust/certified-case/1"; + +/// What the projection ends the name of a case's definition with, and what +/// it adds for the theorem that the case holds. +const ROOT: &str = "Root"; +const HOLDS: &str = "Holds"; + +/// What the projection starts the name of a case's definition with, before +/// the test's package and name in Pascal case. +const ACCEPT: &str = "accept"; + +/// The example of the certified crate that runs every case. +pub const HARNESS: &str = "cases"; + +/// A case: a closed assertion of a test, as a production root. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Case { + /// Its root: the definition, the κ of the definitions it runs, and the + /// functions in scope it asserts on, by crate path. + pub root: Root, + /// Those functions. + pub functions: Vec, +} + +/// The cases of a projection under `profile`: every definition of +/// `Behavior` the projection proves true as a closed Boolean (`Holds` +/// states `(() = true)`) whose closure reaches the definition of a +/// lifted function in scope, by definition. A case's κ is the SHA-256 of +/// [`DOMAIN`] and every definition of its closure, by name with its text, so +/// it is a new question when the assertion or anything it runs changes. +pub fn cases( + profile: &Profile, + modules: &BTreeMap, + register: &Register, +) -> Vec { + let definitions = Definitions::of(modules); + let behavior = modules.get(BEHAVIOR).map_or("", String::as_str); + // The lifted functions in scope, by their definitions. + let lifted: BTreeMap = register + .rows + .values() + .filter(|row| profile.in_scope(&row.function)) + .filter_map(|row| match &row.status { + Status::Lifted(definition) => Some(( + format!( + "{BEHAVIOR}::{}", + definition.rsplit("::").next().unwrap_or(definition) + ), + row.function.as_str(), + )), + _ => None, + }) + .collect(); + let mut out = Vec::new(); + for chunk in super::chunks(behavior) { + let Some(name) = chunk.name else { continue }; + if !name.ends_with(ROOT) + || !behavior.contains(&format!("name: {name}{HOLDS},")) + || !behavior.contains(&format!("statement: (({name}) = true)")) + { + continue; + } + let closure = definitions.closure(&format!("{BEHAVIOR}::{name}")); + let functions: BTreeSet<&str> = closure + .iter() + .filter_map(|d| lifted.get(d).copied()) + .collect(); + if functions.is_empty() { + continue; + } + let mut text = Vec::from(DOMAIN.as_bytes()); + for def in &closure { + let body = definitions.text(def).unwrap_or_default(); + text.extend_from_slice(format!("\n{def}\n{}\n", body.len()).as_bytes()); + text.extend_from_slice(body.as_bytes()); + } + let functions: Vec = functions.into_iter().map(str::to_string).collect(); + out.push(Case { + root: Root { + function: functions.join(", "), + kappa: crate::project::sha(&text), + definition: name, + prefix: profile.package.clone(), + }, + functions, + }); + } + out.sort_by(|a, b| a.root.definition.cmp(&b.root.definition)); + out +} + +/// The source of the example that runs every case of a manifest and prints +/// ` ` for each, as Rust prints the +/// value: a Boolean, or one in the package's own bounded result. +pub fn harness(profile: &Profile, manifest: &Manifest) -> String { + let krate = profile.crate_name(); + let mut out = String::from( + "//! Written by `uorust certify agree`: runs every certified case of\n\ + //! `manifest.toml` and prints what each returns.\n\n\ + fn main() {\n", + ); + for root in &manifest.roots { + out.push_str(&format!( + " println!(\"{} {{:?}}\", {krate}::{}::run());\n", + root.definition, + profile.module(&root.package) + )); + } + out.push_str("}\n"); + out +} + +/// What a case answers, from what its run printed: `true` or `false`, bare +/// or as the `Ok` of a package whose naturals are the target's width, and +/// `overflow` for that package's failure. +fn answer(printed: &str) -> String { + match printed + .strip_prefix("Ok(") + .and_then(|p| p.strip_suffix(')')) + { + Some(held) => held.to_string(), + None if printed.starts_with("Err(") => "overflow".to_string(), + None => printed.to_string(), + } +} + +/// What each case of the certified crate at `dir` answers, by definition: +/// every package source checked against the SHA-256 the manifest records +/// and the crate's `lib.rs` against the manifest's own, then the harness +/// written and run by cargo. +pub fn answers( + dir: &Path, + profile: &Profile, + manifest: &Manifest, +) -> Result, UorustError> { + let bad = |path: &Path, reason: String| UorustError::Malformed { + path: path.to_path_buf(), + reason, + }; + for root in &manifest.roots { + let path = dir.join("roots").join(format!("{}.rs", root.package)); + let bytes = std::fs::read(&path).map_err(|e| io(&path, e))?; + let digest = crate::project::sha(&bytes); + if digest != root.source { + return Err(bad( + &path, + format!("SHA-256 {digest}, the manifest records {}", root.source), + )); + } + } + let lib = dir.join("src").join("lib.rs"); + let found = std::fs::read_to_string(&lib).map_err(|e| io(&lib, e))?; + if found != profile.crate_source(&manifest.roots) { + return Err(bad(&lib, "not the crate of the manifest's roots".into())); + } + let examples = dir.join("examples"); + std::fs::create_dir_all(&examples).map_err(|e| io(&examples, e))?; + let path = examples.join(format!("{HARNESS}.rs")); + std::fs::write(&path, harness(profile, manifest)).map_err(|e| io(&path, e))?; + let run = std::process::Command::new("cargo") + .args(["run", "--quiet", "--offline", "--example", HARNESS]) + .current_dir(dir) + .output() + .map_err(|e| UorustError::Tool(format!("cargo run --example {HARNESS}: {e}")))?; + if !run.status.success() { + return Err(UorustError::Tool(format!( + "cargo run --example {HARNESS} in {}: {}", + dir.display(), + String::from_utf8_lossy(&run.stderr) + ))); + } + Ok(String::from_utf8_lossy(&run.stdout) + .lines() + .filter_map(|l| l.split_once(' ')) + .map(|(d, a)| (d.to_string(), answer(a))) + .collect()) +} + +/// One test function's run, over every test of its name in its package. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Ran { + /// The tests libtest reported `ok`. + pub passed: Vec, + /// Those it reported otherwise, with what it reported. + pub other: Vec, +} + +/// The test functions libtest reports in `output`, the standard output of +/// `cargo test` of `package`, by the prefix of the cases the projection +/// states of each: `accept` and the package and the function's name in +/// Pascal case. +pub fn ran(package: &str, output: &str, into: &mut BTreeMap) { + for line in output.lines() { + let Some((path, verdict)) = line + .strip_prefix("test ") + .and_then(|l| l.rsplit_once(" ... ")) + else { + continue; + }; + // A doc test's path names a file and a line, never a function. + if path.contains(' ') { + continue; + } + let name = path.rsplit("::").next().unwrap_or(path); + let key = format!("{ACCEPT}{}", crate::lex::pascal(&[package, name])); + let entry = into.entry(key).or_default(); + if verdict == "ok" { + entry.passed.push(path.to_string()); + } else { + entry.other.push(format!("{path} {verdict}")); + } + } +} + +/// The packages whose tests may state a case: each whose name in Pascal +/// case the case's definition has after `accept`. One package's name can +/// start another's, so every one that fits is run, and the test function's +/// own key decides ([`test_of`]). +fn packages_of<'a>(definition: &str, packages: &'a [String]) -> Vec<&'a str> { + packages + .iter() + .filter(|p| definition.starts_with(&format!("{ACCEPT}{}", crate::lex::pascal(&[p])))) + .map(String::as_str) + .collect() +} + +/// The tests of the workspace at `workspace` that state the manifest's +/// cases, run by cargo: every test of each package a case names, by +/// [`ran`]'s keys. +pub fn tests(workspace: &Path, manifest: &Manifest) -> Result, UorustError> { + let tool = |what: &str, reason: String| UorustError::Tool(format!("{what}: {reason}")); + let listed = std::process::Command::new("cargo") + .args(["metadata", "--no-deps", "--format-version", "1"]) + .current_dir(workspace) + .output() + .map_err(|e| tool("cargo metadata", e.to_string()))?; + if !listed.status.success() { + return Err(UorustError::CargoMetadata( + String::from_utf8_lossy(&listed.stderr).into_owned(), + )); + } + let metadata: serde_json::Value = serde_json::from_slice(&listed.stdout) + .map_err(|e| UorustError::CargoMetadata(e.to_string()))?; + let packages: Vec = metadata + .get("packages") + .and_then(|p| p.as_array()) + .into_iter() + .flatten() + .filter_map(|p| p.get("name")?.as_str().map(str::to_string)) + .collect(); + let named: BTreeSet<&str> = manifest + .roots + .iter() + .flat_map(|r| packages_of(&r.definition, &packages)) + .collect(); + let mut out = BTreeMap::new(); + for package in named { + // The verdict is each test's own line, never cargo's exit: a + // failing test is a disagreement of its cases, named below. + let run = std::process::Command::new("cargo") + .args(["test", "--no-fail-fast", "--package", package]) + .current_dir(workspace) + .output() + .map_err(|e| tool("cargo test", e.to_string()))?; + let text = String::from_utf8_lossy(&run.stdout); + if !text.lines().any(|l| l.starts_with("test result: ")) { + return Err(tool( + &format!("cargo test --package {package}"), + String::from_utf8_lossy(&run.stderr).into_owned(), + )); + } + ran(package, &text, &mut out); + } + Ok(out) +} + +/// The test function's key a case's definition is stated under: the key +/// the definition has before the assertion's index and `Root`, the longest +/// when several fit. +fn test_of<'a>(definition: &str, tests: &'a BTreeMap) -> Option<&'a Ran> { + tests + .iter() + .filter(|(key, _)| { + definition + .strip_prefix(key.as_str()) + .and_then(|rest| rest.strip_suffix(ROOT)) + .is_some_and(|index| !index.is_empty() && index.chars().all(|c| c.is_ascii_digit())) + }) + .max_by_key(|(key, _)| key.len()) + .map(|(_, ran)| ran) +} + +/// The verdict of every case of a manifest: one line per case that agrees, +/// ` `. Refused, naming each case with what parted, +/// when a certified package does not answer true, when the test that states +/// a case did not pass or did not run, and when there is no case at all, so +/// that an agreement is never an empty one. +pub fn verdicts( + manifest: &Manifest, + answers: &BTreeMap, + tests: &BTreeMap, +) -> Result, UorustError> { + let mut lines = Vec::new(); + let mut disagree = Vec::new(); + for root in &manifest.roots { + let case = format!("{} ({})", root.definition, root.function); + let mut parted = Vec::new(); + match answers.get(&root.definition).map(String::as_str) { + Some("true") => {} + Some(other) => parted.push(format!("the certified package answers {other}")), + None => parted.push("the certified package gave no answer".to_string()), + } + match test_of(&root.definition, tests) { + Some(ran) if ran.other.is_empty() && !ran.passed.is_empty() => {} + Some(ran) => parted.push(format!("its test did not pass: {}", ran.other.join(", "))), + None => parted.push("no test of the workspace that states it ran".to_string()), + } + if parted.is_empty() { + lines.push(format!("{} {}", root.definition, root.function)); + } else { + disagree.push(format!("{case}: {}", parted.join("; "))); + } + } + if manifest.roots.is_empty() { + disagree.push("the manifest certifies no case".to_string()); + } + if disagree.is_empty() { + Ok(lines) + } else { + Err(UorustError::Disagree(disagree)) + } +} + +/// The agreement of the certified cases taken into `dir` with the tests of +/// the workspace at `workspace`: [`verdicts`] over what the packages answer +/// ([`answers`]) and what the tests did ([`tests`]). +pub fn agree(dir: &Path, workspace: &Path) -> Result, UorustError> { + let path = dir.join("manifest.toml"); + let text = std::fs::read_to_string(&path).map_err(|e| io(&path, e))?; + let profile = Profile::recorded(&path, &text)?; + if profile.kind != Kind::Cases { + return Err(UorustError::Malformed { + path, + reason: "not the manifest of a cases export (certify production --cases)".to_string(), + }); + } + let manifest = Manifest::parse(&path, &text)?; + let answered = answers(dir, &profile, &manifest)?; + let tested = tests(workspace, &manifest)?; + verdicts(&manifest, &answered, &tested) +} + +/// The functions the cases of a manifest assert on, by crate path. +pub fn covered(manifest: &Manifest) -> BTreeSet { + manifest + .roots + .iter() + .flat_map(|r| r.function.split(", ")) + .map(str::to_string) + .collect() +} + +#[cfg(test)] +mod tests { + use super::super::Certified; + use super::*; + use crate::register::Row; + + fn register(rows: &[(&str, &str, &str)]) -> Register { + let mut r = Register::default(); + for (kappa, function, definition) in rows { + r.rows.insert( + (*kappa).to_string(), + Row { + function: (*function).to_string(), + status: Status::Lifted(format!("Behavior::{definition}")), + divergence: None, + }, + ); + } + r + } + + fn profile() -> Profile { + Profile { + scope: vec!["meter::".to_string()], + entry: None, + package: "meter_certified_".to_string(), + kind: Kind::Cases, + ..Profile::default() + } + } + + fn behavior(above: &str) -> BTreeMap { + let text = format!( + "definition{{\n name: above,\n parameters: [n : Nat],\n result: Nat,\n body: {above}\n}}\n\n\ + definition{{\n name: other,\n parameters: [n : Nat],\n result: Nat,\n body: n\n}}\n\n\ + definition{{\n name: acceptMeterCountsAbove0Root,\n parameters: [],\n result: Bool,\n body: ((above 2) =? 3)\n}}\n\n\ + theorem{{\n name: acceptMeterCountsAbove0RootHolds,\n parameters: [],\n statement: ((acceptMeterCountsAbove0Root) = true),\n proof: decide{{}}\n}}\n\n\ + definition{{\n name: acceptGaugeReads0Root,\n parameters: [],\n result: Bool,\n body: ((other 2) =? 2)\n}}\n\n\ + theorem{{\n name: acceptGaugeReads0RootHolds,\n parameters: [],\n statement: ((acceptGaugeReads0Root) = true),\n proof: decide{{}}\n}}\n\n\ + definition{{\n name: plainRoot,\n parameters: [],\n result: Bool,\n body: ((above 1) =? 2)\n}}\n" + ); + [ + ("Behavior".to_string(), text), + ("Prelude".to_string(), String::new()), + ] + .into_iter() + .collect() + } + + // A case is a closed assertion the projection proves, over a lifted + // function in scope; its κ is the question of everything it runs. + #[test] + fn a_case_is_a_proved_closed_assertion_over_a_function_in_scope() { + let reg = register(&[ + ("k1", "meter::above", "above"), + ("k2", "gauge::other", "other"), + ]); + let found = cases(&profile(), &behavior("(n + 1)"), ®); + // `acceptGaugeReads0Root` asserts on a function outside the scope, + // and `plainRoot` has no theorem that it holds. + assert_eq!(found.len(), 1); + let case = &found[0]; + assert_eq!(case.root.definition, "acceptMeterCountsAbove0Root"); + assert_eq!(case.functions, ["meter::above"]); + assert_eq!( + case.root.package(), + "meter_certified_accept_meter_counts_above0_root" + ); + // The function's definition changed: the case is a new question. + let changed = cases(&profile(), &behavior("(n + 2)"), ®); + assert_ne!(changed[0].root.kappa, case.root.kappa); + // An unrelated definition changed: the same question. + let mut elsewhere = behavior("(n + 1)"); + let text = elsewhere["Behavior"].replace(" body: n\n", " body: (n + 0)\n"); + elsewhere.insert("Behavior".to_string(), text); + assert_eq!( + cases(&profile(), &elsewhere, ®)[0].root.kappa, + case.root.kappa + ); + } + + fn manifest(definitions: &[&str]) -> Manifest { + Manifest { + roots: definitions + .iter() + .map(|d| Certified { + function: "meter::above".into(), + kappa: format!("k-{d}"), + definition: (*d).to_string(), + package: format!("meter_certified_{}", d.to_lowercase()), + source: "s".into(), + certification: "kernel-checked".into(), + closure: None, + edition: None, + }) + .collect(), + ..Manifest::default() + } + } + + #[test] + fn libtest_lines_are_read_by_the_cases_they_state() { + let mut out = BTreeMap::new(); + ran( + "meter", + "running 3 tests\ntest tests::counts_above ... ok\ntest tests::reads_low ... FAILED\ntest src/lib.rs - above (line 3) ... ok\n\ntest result: FAILED. 1 passed; 1 failed\n", + &mut out, + ); + assert_eq!( + out["acceptMeterCountsAbove"].passed, + ["tests::counts_above"] + ); + assert_eq!( + out["acceptMeterReadsLow"].other, + ["tests::reads_low FAILED"] + ); + assert_eq!(out.len(), 2); + } + + // The planted defects of the agreement: a certified package that answers + // false, a test that failed, a case no test ran and a manifest of no + // case are each refused, naming the case and what parted. + #[test] + fn a_case_agrees_only_when_the_package_answers_true_and_its_test_passes() { + let m = manifest(&[ + "acceptMeterCountsAbove0Root", + "acceptMeterCountsAbove12Root", + ]); + let mut tests = BTreeMap::new(); + ran("meter", "test tests::counts_above ... ok\n", &mut tests); + let both: BTreeMap = m + .roots + .iter() + .map(|r| (r.definition.clone(), "true".to_string())) + .collect(); + assert_eq!( + verdicts(&m, &both, &tests), + Ok(vec![ + "acceptMeterCountsAbove0Root meter::above".to_string(), + "acceptMeterCountsAbove12Root meter::above".to_string() + ]) + ); + let mut planted = both.clone(); + planted.insert("acceptMeterCountsAbove12Root".into(), "false".into()); + match verdicts(&m, &planted, &tests) { + Err(UorustError::Disagree(rows)) => assert_eq!( + rows, + ["acceptMeterCountsAbove12Root (meter::above): the certified package answers false"] + ), + other => panic!("not refused: {other:?}"), + } + let mut failed = BTreeMap::new(); + ran( + "meter", + "test tests::counts_above ... FAILED\n", + &mut failed, + ); + match verdicts(&m, &both, &failed) { + Err(UorustError::Disagree(rows)) => { + assert_eq!(rows.len(), 2); + assert!(rows[0].ends_with("its test did not pass: tests::counts_above FAILED")); + } + other => panic!("not refused: {other:?}"), + } + match verdicts(&m, &both, &BTreeMap::new()) { + Err(UorustError::Disagree(rows)) => { + assert!(rows[0].ends_with("no test of the workspace that states it ran")); + } + other => panic!("not refused: {other:?}"), + } + assert!(matches!( + verdicts(&manifest(&[]), &BTreeMap::new(), &tests), + Err(UorustError::Disagree(_)) + )); + } + + #[test] + fn every_package_whose_name_fits_a_case_is_run() { + let packages = [ + "meter".to_string(), + "meter-core".to_string(), + "gauge".to_string(), + ]; + assert_eq!( + packages_of("acceptMeterCoreReads0Root", &packages), + ["meter", "meter-core"] + ); + // The test function's own key decides: the longest that fits. + let mut tests = BTreeMap::new(); + ran("meter", "test core_reads ... FAILED\n", &mut tests); + ran( + "meter-core", + "test reads ... ok\ntest reads_low ... ok\n", + &mut tests, + ); + assert_eq!(tests.len(), 2); + let found = test_of("acceptMeterCoreReads0Root", &tests).expect("a test"); + assert_eq!(found.passed, ["reads"]); + assert_eq!(found.other, ["core_reads FAILED"]); + assert!(test_of("acceptMeterCoreReadsLow0Root", &tests).is_some()); + assert!(test_of("acceptMeterCoreReadsHigh0Root", &tests).is_none()); + } + + #[test] + fn the_harness_runs_every_case_of_the_manifest() { + let text = harness(&profile(), &manifest(&["acceptMeterCountsAbove0Root"])); + assert!(text.contains( + "println!(\"acceptMeterCountsAbove0Root {:?}\", meter_certified::acceptmetercountsabove0root::run());" + )); + assert_eq!(answer("true"), "true"); + assert_eq!(answer("Ok(true)"), "true"); + assert_eq!(answer("Ok(false)"), "false"); + assert_eq!(answer("Err(Overflow)"), "overflow"); + } +} diff --git a/crates/uorust/src/certify/profile.rs b/crates/uorust/src/certify/profile.rs new file mode 100644 index 00000000..785a19ae --- /dev/null +++ b/crates/uorust/src/certify/profile.rs @@ -0,0 +1,322 @@ +//! What an export is of: the functions it certifies, where it starts, how +//! its packages are named, and what `lexlean production` is asked for. +//! +//! The translator's own export is the default ([`Profile::default`]): the +//! scope, the entry, the package prefix, the effects and the target the +//! module's constants name. Any other workspace has its own, from three +//! places, each over the one before: what its Cargo manifest and its +//! directory give ([`Profile::of_workspace`]), the table it declares in that +//! manifest (`[workspace.metadata.uorust.certify]`, or `[package.metadata..]` +//! of a manifest without a workspace), and the command's options +//! ([`Options`]). An export records its profile beside what it keeps, and a +//! manifest states the profile it was taken in under, so the steps after the +//! export never ask again. + +use std::path::Path; + +use super::{EFFECTS, ENTRY, PACKAGE, SCOPE, TARGET}; +use crate::error::io; +use crate::UorustError; + +/// The file of an export's kept output that records its profile. +pub const PROFILE: &str = "profile.toml"; + +/// The table of a workspace's Cargo manifest that declares its profile. +pub const TABLE: &str = "metadata.uorust.certify"; + +/// What every package prefix a workspace does not declare ends with. +const SUFFIX: &str = "_certified_"; + +/// What an export's roots are. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub enum Kind { + /// The lifted functions in scope, each by its definition. + #[default] + Functions, + /// The closed assertions of the workspace's own tests over them, each + /// the Boolean definition the projection states it as. + Cases, +} + +impl Kind { + /// The word a table states it by. + pub fn word(self) -> &'static str { + match self { + Kind::Functions => "functions", + Kind::Cases => "cases", + } + } +} + +/// The profile of an export. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Profile { + /// The crate-path prefixes of the functions measured; the empty prefix + /// is every function of the register. + pub scope: Vec, + /// The function the share's reachability starts at, when one is named. + pub entry: Option, + /// The prefix of every certified package's name. + pub package: String, + /// The effects every root admits. + pub effects: Vec, + /// The target every root is exported to. + pub target: String, + /// What the roots are. + pub kind: Kind, +} + +impl Default for Profile { + /// The translator's own: the module's constants. + fn default() -> Self { + Profile { + scope: SCOPE.iter().map(|s| (*s).to_string()).collect(), + entry: Some(ENTRY.to_string()), + package: PACKAGE.to_string(), + effects: EFFECTS.iter().map(|s| (*s).to_string()).collect(), + target: TARGET.to_string(), + kind: Kind::Functions, + } + } +} + +/// What a command's options say of the profile; each one given replaces +/// what the workspace says. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Options { + /// The workspace whose manifest is read. + pub workspace: Option, + /// The scope's prefixes. + pub scope: Vec, + /// The entry. + pub entry: Option, + /// The package prefix. + pub package: Option, + /// The effects. + pub effects: Vec, + /// The target. + pub target: Option, + /// The roots are the cases. + pub cases: bool, +} + +impl Profile { + /// Whether a function is measured. + pub fn in_scope(&self, function: &str) -> bool { + self.scope.iter().any(|s| function.starts_with(s.as_str())) + } + + /// The profile a command runs under: the translator's own, or the + /// workspace's when one is named, then every option given. + pub fn resolve(options: &Options) -> Result { + let mut profile = match &options.workspace { + Some(workspace) => Profile::of_workspace(workspace)?, + None => Profile::default(), + }; + if !options.scope.is_empty() { + profile.scope.clone_from(&options.scope); + } + if let Some(entry) = &options.entry { + profile.entry = Some(entry.clone()).filter(|e| !e.is_empty()); + } + if let Some(package) = &options.package { + profile.package.clone_from(package); + } + if !options.effects.is_empty() { + profile.effects.clone_from(&options.effects); + } + if let Some(target) = &options.target { + profile.target.clone_from(target); + } + if options.cases { + profile.kind = Kind::Cases; + } + profile.checked(Path::new("the command's options")) + } + + /// The profile of the workspace at `workspace`: every function of its + /// register in scope, no entry, packages named after its directory, every + /// effect of the closed registry and the `std` target; then what the + /// table of its Cargo manifest declares. + pub fn of_workspace(workspace: &Path) -> Result { + let manifest = workspace.join("Cargo.toml"); + let text = std::fs::read_to_string(&manifest).map_err(|e| io(&manifest, e))?; + let doc: toml::Value = text.parse().map_err(|e| UorustError::Malformed { + path: manifest.clone(), + reason: format!("{e}"), + })?; + let derived = Profile { + scope: vec![String::new()], + entry: None, + package: crate_name(&crate::default_name(workspace)?) + SUFFIX, + ..Profile::default() + }; + let declared = ["workspace", "package"].into_iter().find_map(|owner| { + TABLE + .split('.') + .try_fold(doc.get(owner)?, |at, key| at.get(key)) + }); + match declared { + Some(table) => Profile::parse(&manifest, table, derived), + None => Ok(derived), + } + } + + /// The profile a table states over `base`: each key it holds replaces + /// the base's. A key of another type, an effect outside the closed + /// registry, a package prefix that is no crate name, a key the profile + /// does not have: [`UorustError::Malformed`] at `path`. + pub fn parse(path: &Path, table: &toml::Value, base: Profile) -> Result { + let bad = |reason: String| UorustError::Malformed { + path: path.to_path_buf(), + reason, + }; + let rows = table + .as_table() + .ok_or_else(|| bad(format!("{TABLE} is not a table")))?; + let text = |key: &str, v: &toml::Value| { + v.as_str() + .map(str::to_string) + .ok_or_else(|| bad(format!("{key} is not a string"))) + }; + let list = |key: &str, v: &toml::Value| { + v.as_array() + .ok_or_else(|| bad(format!("{key} is not a list")))? + .iter() + .map(|item| text(key, item)) + .collect::, UorustError>>() + }; + let mut profile = base; + for (key, value) in rows { + match key.as_str() { + "scope" => profile.scope = list(key, value)?, + "entry" => profile.entry = Some(text(key, value)?).filter(|e| !e.is_empty()), + "package" => profile.package = text(key, value)?, + "effects" => profile.effects = list(key, value)?, + "target" => profile.target = text(key, value)?, + "roots" => { + let word = text(key, value)?; + profile.kind = [Kind::Functions, Kind::Cases] + .into_iter() + .find(|k| k.word() == word) + .ok_or_else(|| bad(format!("roots = {word:?}: functions or cases")))?; + } + other => return Err(bad(format!("{TABLE} has no key {other}"))), + } + } + profile.checked(path) + } + + /// The profile, when it is one an export can run under. + fn checked(self, path: &Path) -> Result { + let bad = |reason: String| UorustError::Malformed { + path: path.to_path_buf(), + reason, + }; + if self.scope.is_empty() { + return Err(bad("the scope names no prefix".to_string())); + } + if let Some(effect) = self.effects.iter().find(|e| !EFFECTS.contains(&e.as_str())) { + return Err(bad(format!( + "{effect} is no effect of the closed registry ({})", + EFFECTS.join(", ") + ))); + } + let named = self.package.starts_with(|c: char| c.is_ascii_lowercase()); + if !named || crate_name(&self.package) != self.package { + return Err(bad(format!( + "the package prefix {:?} is not a crate name's", + self.package + ))); + } + if self.target.is_empty() { + return Err(bad("no target".to_string())); + } + Ok(self) + } + + /// The profile as a table's rows, every key stated: what [`Profile::parse`] + /// reads back whatever its base. + pub fn rows(&self) -> String { + let list = |items: &[String]| { + let quoted: Vec = items.iter().map(|i| quoted(i)).collect(); + format!("[{}]", quoted.join(", ")) + }; + format!( + "scope = {}\nentry = {}\npackage = {}\neffects = {}\ntarget = {}\nroots = {}\n", + list(&self.scope), + quoted(self.entry.as_deref().unwrap_or_default()), + quoted(&self.package), + list(&self.effects), + quoted(&self.target), + quoted(self.kind.word()) + ) + } + + /// The profile an export recorded in its kept output at `kept`; the + /// translator's own when it recorded none. + pub fn kept(kept: &Path) -> Result { + let path = kept.join(PROFILE); + let text = match std::fs::read_to_string(&path) { + Ok(text) => text, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Profile::default()), + Err(e) => return Err(io(&path, e)), + }; + let doc: toml::Value = text.parse().map_err(|e| UorustError::Malformed { + path: path.clone(), + reason: format!("{e}"), + })?; + Profile::parse(&path, &doc, Profile::default()) + } + + /// The profile a manifest's text states it was taken in under: its + /// `[profile]` table, or the translator's own when it has none. + pub fn recorded(path: &Path, text: &str) -> Result { + let doc: toml::Value = text.parse().map_err(|e| UorustError::Malformed { + path: path.to_path_buf(), + reason: format!("{e}"), + })?; + match doc.get("profile") { + Some(table) => Profile::parse(path, table, Profile::default()), + None => Ok(Profile::default()), + } + } + + /// [`Profile::recorded`] of the manifest file at `path`; an absent file + /// states none. + pub fn recorded_at(path: &Path) -> Result, UorustError> { + match std::fs::read_to_string(path) { + Ok(text) => Profile::recorded(path, &text).map(Some), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None), + Err(e) => Err(io(path, e)), + } + } + + /// The prefixes of `self`'s scope that `head`'s scope does not cover: a + /// scope a head measures under may only widen. + pub fn dropped_by(&self, head: &Profile) -> Vec { + self.scope + .iter() + .filter(|prefix| !head.scope.iter().any(|h| prefix.starts_with(h.as_str()))) + .cloned() + .collect() + } +} + +fn quoted(text: &str) -> String { + toml::Value::String(text.to_string()).to_string() +} + +/// A name as a crate's: lower case, every character outside a crate name's +/// an underscore. +pub(crate) fn crate_name(name: &str) -> String { + name.chars() + .map(|c| { + if c.is_ascii_alphanumeric() { + c.to_ascii_lowercase() + } else { + '_' + } + }) + .collect() +} diff --git a/crates/uorust/src/error.rs b/crates/uorust/src/error.rs index e7784b8a..c14798da 100644 --- a/crates/uorust/src/error.rs +++ b/crates/uorust/src/error.rs @@ -38,6 +38,17 @@ pub enum UorustError { /// A function the incumbent lift register records as lifted (a proved /// claim, by κ) is decided unlifted by this projection. Regressed(Vec), + /// A module of the projection is larger than the `max_file_bytes` the + /// projection's own `lexlean.toml` states, so LexLean would refuse the + /// project it is part of. + ModuleTooLarge { + /// The module's path in the projection. + module: String, + /// Its size in bytes. + bytes: usize, + /// The limit the projection states. + limit: usize, + }, /// A tool the engine runs could not be run or failed: `cargo rustc` /// dumping MIR, or `lexlean verify` deciding the MIR path's theorems. Tool(String), @@ -84,6 +95,15 @@ impl fmt::Display for UorustError { "a lifted function is no longer lifted, and a lifted κ is never re-decided: {}", rows.join("; ") ), + Self::ModuleTooLarge { + module, + bytes, + limit, + } => write!( + f, + "the module {module} is {bytes} bytes, beyond the max_file_bytes of {limit} the \ + projection states in lexlean.toml" + ), Self::Tool(reason) => write!(f, "{reason}"), Self::Disagree(rows) => write!( f, diff --git a/crates/uorust/src/facts.rs b/crates/uorust/src/facts.rs index aa573c73..02ec86b6 100644 --- a/crates/uorust/src/facts.rs +++ b/crates/uorust/src/facts.rs @@ -124,6 +124,15 @@ pub(crate) struct SourceFile { pub(crate) enums: Vec, pub(crate) structs: Vec, pub(crate) error_impls: Vec, + /// The types the file declares in a shape the lift does not read, each + /// with that shape (`a tuple struct`). + pub(crate) unread: Vec<(String, &'static str)>, + /// The file's module scopes: its own first, then each inline module's + /// in source order. + pub(crate) scopes: Vec, + /// Whether the file, or a module it declares, is marked + /// `no_implicit_prelude`. + pub(crate) no_prelude: bool, pub(crate) capabilities: Vec<(Capability, Span, String)>, /// `use` imports: the imported name -> the path it names. pub(crate) imports: BTreeMap, @@ -157,6 +166,41 @@ pub(crate) struct FnFact { pub(crate) in_trait: bool, /// For a method of `impl Trait for Type`: the trait's last segment. pub(crate) implements: Option, + /// For a method of `impl Trait for Type`: the trait as the impl names + /// it, its last segment with its arguments (`From`). + pub(crate) trait_ref: Option, + /// Whether the method's type has another method of its name in the same + /// build: an inherent one beside a trait's, two traits', or one generic + /// trait's at two argument lists. Rust then names a trait's method + /// `::name`, and `Type::name` otherwise. + pub(crate) apart: bool, + /// The receiver as the method writes it (`&mut self`), where it takes + /// one. + pub(crate) receiver: Option, + /// For a method of `impl Trait for Type`: the trait's path as the impl + /// writes it, without its arguments (`fmt::Display`). + pub(crate) trait_path: Option, + /// The type and const parameters of the method's impl block: a method + /// of `impl Trait for T` is one function per type. + pub(crate) impl_params: Vec, + /// Which of its file's module scopes (`SourceFile::scopes`) declares + /// the function. + pub(crate) scope: usize, +} + +/// One module scope of a file: the file's own items, or an inline module's. +/// A trait's methods are callable where the trait is in scope, and a scope +/// inherits no name from the module around it. +#[derive(Clone, Debug, Default)] +pub(crate) struct ScopeFact { + /// Each name a `use` of the scope binds, with the path it names. + pub(crate) uses: Vec<(String, String)>, + /// Whether a `use` of the scope ends in `*`: it may bind any name. + pub(crate) glob: bool, + /// The traits the scope declares. + pub(crate) traits: Vec, + /// The modules the scope declares out of line, each a file of its own. + pub(crate) mods: Vec, } #[derive(Clone, Debug)] @@ -171,7 +215,7 @@ pub(crate) struct EnumFact { pub(crate) variants: Vec, } -/// A struct with named fields and no generic parameters. +/// A struct, whatever its shape: its syntax says which fields it has. #[derive(Clone, Debug)] pub(crate) struct StructFact { pub(crate) name: String, @@ -185,6 +229,9 @@ pub(crate) struct StructFact { #[derive(Clone, Debug, Default)] pub(crate) struct Syntax { pub(crate) files: BTreeMap, + /// What name resolution reads of the workspace: each module's bindings + /// and each body's calls. + pub(crate) names: crate::names::Names, } impl Syntax { diff --git a/crates/uorust/src/ingest.rs b/crates/uorust/src/ingest.rs index f61721f9..8bf804b9 100644 --- a/crates/uorust/src/ingest.rs +++ b/crates/uorust/src/ingest.rs @@ -1,19 +1,21 @@ //! Ingest: `cargo metadata`, the manifests, `Cargo.lock` and every source file, //! parsed with `syn`, into [`facts`](crate::facts) with spans. -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::path::{Path, PathBuf}; use std::process::Command; use quote::ToTokens; use serde_json::Value; +use syn::ext::IdentExt; use syn::punctuated::Punctuated; use syn::visit::Visit; use crate::error::{io, UorustError}; use crate::facts::{ Advisories, Advisory, Capability, Dep, EnumFact, FileSyntax, FnFact, FnSyntax, LockedPackage, - Package, SourceFile, Span, StructFact, Syntax, Target, TargetKind, Variant, Workspace, + Package, ScopeFact, SourceFile, Span, StructFact, Syntax, Target, TargetKind, Variant, + Workspace, }; /// Read a workspace from its root directory: its facts, and the syntax the @@ -424,12 +426,35 @@ fn package( collect_rs(&dir_abs.join(sub), &mut paths)?; } paths.sort(); + // Each file is read and parsed once, and the files that are test code + // as a whole are found across them before any file's facts are read. + let mut read = Vec::new(); for path in paths { let rel_path = rel(&root_text, &path_text(&path)); let Some((target, module)) = assign(&rel_path, &dir, &targets) else { continue; }; - let (file, file_syntax) = source(&path, rel_path, target, module, &targets[target].kind)?; + let text = std::fs::read_to_string(&path).map_err(|e| io(&path, e))?; + read.push((path, rel_path, target, module, syn::parse_file(&text))); + } + let roots: Vec = targets.iter().map(|t| root.join(&t.src)).collect(); + let trees: BTreeMap<&Path, &syn::File> = read + .iter() + .filter_map(|(path, _, _, _, parsed)| Some((path.as_path(), parsed.as_ref().ok()?))) + .collect(); + let tests = test_files(&roots, &trees); + for (path, rel_path, target, module, parsed) in &read { + let (file, file_syntax) = match parsed { + Ok(tree) => source( + tree, + rel_path.clone(), + *target, + module.clone(), + &targets[*target].kind, + tests.contains(path), + ), + Err(error) => unparsed(rel_path.clone(), *target, module.clone(), error), + }; syntax.insert(file.rel.clone(), file_syntax); files.push(file); } @@ -562,14 +587,231 @@ fn lock(path: &Path) -> Result, UorustError> { Ok(out) } +/// A file a `mod` declaration names, as the walk over a package's module +/// tree meets it. +struct ModFile { + file: PathBuf, + /// The directory its own out-of-line modules are found from. + dir: PathBuf, + /// The directory under `dir` that holds them where the file is neither + /// a `mod.rs` nor named by a `#[path]`: its own name. + own: Option, + /// Whether the declaration that names it stands in test code. + test: bool, +} + +/// The files of a package that are test code as a whole: each file an +/// out-of-line `mod name;` names under a test cfg, in a test module or in a +/// test file, unless another declaration names it outside all three, since +/// a build without tests then holds it too. Read from the target roots down, +/// as Rust reads the module tree. +fn test_files(roots: &[PathBuf], trees: &BTreeMap<&Path, &syn::File>) -> BTreeSet { + // Per named file: whether a declaration outside test code names it. + let mut named: BTreeMap = BTreeMap::new(); + let mut seen: BTreeSet<(PathBuf, bool)> = BTreeSet::new(); + let mut todo: Vec = roots + .iter() + .map(|root| ModFile { + file: root.clone(), + dir: parent(root), + own: None, + test: false, + }) + .collect(); + while let Some(at) = todo.pop() { + if !seen.insert((at.file.clone(), at.test)) { + continue; + } + let Some(tree) = trees.get(at.file.as_path()) else { + continue; + }; + let mut found = Vec::new(); + declared_files(&tree.items, &at.dir, at.own.as_deref(), at.test, &mut found); + for next in found { + if trees.contains_key(next.file.as_path()) { + *named.entry(next.file.clone()).or_insert(false) |= !next.test; + todo.push(next); + } + } + } + named + .into_iter() + .filter(|(_, product)| !product) + .map(|(file, _)| file) + .collect() +} + +/// The files the out-of-line modules among `items` name, by Rust's own +/// rule: `name.rs` or `name/mod.rs` in the directory of a target root, a +/// `mod.rs` or a `#[path]` file, and under the declaring file's own name +/// otherwise; the inline modules around a declaration are directories on +/// the way; and a `#[path]` names the file itself, or an inline module's +/// directory. Both files a plain declaration could mean are given: the one +/// that exists is the module. +fn declared_files( + items: &[syn::Item], + dir: &Path, + own: Option<&str>, + test: bool, + out: &mut Vec, +) { + for item in items { + let syn::Item::Mod(m) = item else { + continue; + }; + let test = test || is_cfg_test(&attrs(&m.attrs)); + let name = m.ident.unraw().to_string(); + let under = match own { + Some(own) => dir.join(own), + None => dir.to_path_buf(), + }; + match (&m.content, path_attr(&m.attrs)) { + (Some((_, inner)), Some(given)) => { + declared_files(inner, &normal(&dir.join(given)), None, test, out); + } + (Some((_, inner)), None) => { + declared_files(inner, &under.join(&name), None, test, out); + } + (None, Some(given)) => { + let file = normal(&dir.join(given)); + out.push(ModFile { + dir: parent(&file), + file, + own: None, + test, + }); + } + (None, None) => { + out.push(ModFile { + file: under.join(format!("{name}.rs")), + dir: under.clone(), + own: Some(name.clone()), + test, + }); + out.push(ModFile { + file: under.join(&name).join("mod.rs"), + dir: under.join(&name), + own: None, + test, + }); + } + } + } +} + +/// The file or directory a `#[path = "..."]` attribute gives. +fn path_attr(list: &[syn::Attribute]) -> Option { + list.iter().find_map(|a| match &a.meta { + syn::Meta::NameValue(nv) if a.path().is_ident("path") => match &nv.value { + syn::Expr::Lit(syn::ExprLit { + lit: syn::Lit::Str(s), + .. + }) => Some(s.value()), + _ => None, + }, + _ => None, + }) +} + +/// The directory of a file. +fn parent(file: &Path) -> PathBuf { + file.parent().map(Path::to_path_buf).unwrap_or_default() +} + +/// A path without its `.` and `..` components, each `..` taking the +/// component before it: the path a `#[path]` that climbs out of its +/// directory names. +fn normal(path: &Path) -> PathBuf { + let mut out = PathBuf::new(); + for part in path.components() { + match part { + std::path::Component::CurDir => {} + std::path::Component::ParentDir => { + out.pop(); + } + other => out.push(other), + } + } + out +} + +/// Rust names a method `Type::name` while its type has one method of that +/// name, and `::name` once it has several: an inherent one +/// beside a trait's, two traits', or one generic trait's at two argument +/// lists. Each method of a trait implementation that shares its type and +/// name with another method of the file, in the same build (with tests or +/// without), is marked as named apart. +fn name_apart(fns: &mut [FnFact]) { + let mut sharing: BTreeMap<(String, String, bool), usize> = BTreeMap::new(); + for f in fns.iter().filter(|f| !f.in_trait) { + if let Some(owner) = &f.owner { + *sharing + .entry((owner.clone(), f.name.clone(), f.in_test_module)) + .or_default() += 1; + } + } + for f in fns.iter_mut().filter(|f| f.trait_ref.is_some()) { + if let Some(owner) = &f.owner { + let key = (owner.clone(), f.name.clone(), f.in_test_module); + f.apart = sharing.get(&key).is_some_and(|n| *n > 1); + } + } +} + +/// The types among `items` that are declared in a shape the lift does not +/// read, each with that shape, so that a refusal over one can say why. +fn unread_types(items: &[syn::Item], out: &mut Vec<(String, &'static str)>) { + for item in items { + match item { + syn::Item::Struct(st) => { + // A struct's fields are read whatever its form, named or + // by position; only its own parameters leave it unread. + if !only_lifetimes(&st.generics) { + out.push((st.ident.to_string(), crate::lift::PARAMETRIC_STRUCT)); + } + } + syn::Item::Enum(e) if !only_lifetimes(&e.generics) => { + out.push((e.ident.to_string(), "an enum with type parameters")); + } + syn::Item::Union(u) => out.push((u.ident.to_string(), "a union")), + syn::Item::Mod(m) => { + if let Some((_, inner)) = &m.content { + unread_types(inner, out); + } + } + _ => {} + } + } +} + +/// The facts of a file `syn` does not parse: where it stands and why it is +/// not read, with no item of it. The projection records the reason and the +/// names resolved through the file stay open. +fn unparsed( + rel: String, + target: usize, + module: String, + error: &syn::Error, +) -> (SourceFile, FileSyntax) { + let at = error.span().start(); + let file = SourceFile { + parse_error: Some(format!("{}:{}: {error}", rel, at.line)), + rel, + target, + module, + ..SourceFile::default() + }; + (file, FileSyntax::default()) +} + fn source( - path: &Path, + parsed: &syn::File, rel: String, target: usize, module: String, kind: &TargetKind, -) -> Result<(SourceFile, FileSyntax), UorustError> { - let text = std::fs::read_to_string(path).map_err(|e| io(path, e))?; + test_file: bool, +) -> (SourceFile, FileSyntax) { let mut file = SourceFile { rel: rel.clone(), target, @@ -577,16 +819,9 @@ fn source( ..SourceFile::default() }; let mut syntax = FileSyntax::default(); - let parsed = match syn::parse_file(&text) { - Ok(parsed) => parsed, - Err(error) => { - let at = error.span().start(); - file.parse_error = Some(format!("{}:{}: {error}", rel, at.line)); - return Ok((file, syntax)); - } - }; let file_attrs = attrs(&parsed.attrs); file.doc = doc_of(&file_attrs); + file.no_prelude = file_attrs.iter().any(|a| named(a, "no_implicit_prelude")); file.forbids_unsafe = file_attrs .iter() .any(|a| named(a, "forbid") && a.tokens.contains("unsafe_code")); @@ -597,15 +832,17 @@ fn source( &parsed.items, &rel, None, - test_target, + test_target || test_file, product, lib, &mut file, &mut syntax, ); + name_apart(&mut file.fns); + unread_types(&parsed.items, &mut file.unread); file.capabilities.sort(); file.capabilities.dedup(); - Ok((file, syntax)) + (file, syntax) } /// An attribute, as the facts read it. @@ -621,6 +858,33 @@ struct Attr { doc: Option, /// The type names a `#[derive(...)]` lists. derives: Vec, + /// For a `#[cfg(..)]`: whether its predicate holds in a test build + /// alone. + test_only: bool, +} + +/// Whether a `cfg` predicate holds in a test build alone: `test` itself, an +/// `all(..)` one of whose members does, or an `any(..)` whose every member +/// does. A `not(..)`, a feature or a target holds in some build without +/// tests, where what stands under it is product code. +fn only_in_tests(predicate: &syn::Meta) -> bool { + match predicate { + syn::Meta::Path(p) => p.is_ident("test"), + syn::Meta::List(list) => { + let members: Vec = list + .parse_args_with(Punctuated::::parse_terminated) + .map(|members| members.into_iter().collect()) + .unwrap_or_default(); + if list.path.is_ident("all") { + members.iter().any(only_in_tests) + } else { + list.path.is_ident("any") + && !members.is_empty() + && members.iter().all(only_in_tests) + } + } + syn::Meta::NameValue(_) => false, + } } /// The attributes of an item, converted once from `syn`. @@ -650,6 +914,9 @@ fn attrs(list: &[syn::Attribute]) -> Vec { } else { Vec::new() }; + let test_only = ident.as_deref() == Some("cfg") + && a.parse_args::() + .is_ok_and(|predicate| only_in_tests(&predicate)); Attr { last: a .path() @@ -661,6 +928,7 @@ fn attrs(list: &[syn::Attribute]) -> Vec { tokens: a.to_token_stream().to_string(), doc, derives, + test_only, } }) .collect() @@ -674,10 +942,10 @@ fn named(attr: &Attr, name: &str) -> bool { } } +/// Whether an item stands under a cfg that holds in a test build alone: +/// several `#[cfg]` attributes hold together, so one such is enough. fn is_cfg_test(attrs: &[Attr]) -> bool { - attrs - .iter() - .any(|a| named(a, "cfg") && a.tokens.contains("test")) + attrs.iter().any(|a| a.test_only) } fn doc_of(attrs: &[Attr]) -> String { @@ -803,6 +1071,14 @@ fn function( effect: block.and_then(effect_of), in_trait: false, implements: None, + trait_ref: None, + apart: false, + receiver: sig + .receiver() + .map(|r| tidy(&r.to_token_stream().to_string())), + trait_path: None, + impl_params: Vec::new(), + scope: 0, }; let syntax = FnSyntax { signature: crate::convert::signature(sig), @@ -812,6 +1088,62 @@ fn function( (fact, syntax) } +/// The names one module scope binds for its trait methods: what its `use` +/// items name, whether one of them is a glob, and the traits it declares. +fn scope_fact(list: &[syn::Item]) -> ScopeFact { + let mut fact = ScopeFact::default(); + for item in list { + match item { + syn::Item::Use(u) => scope_uses(&u.tree, &[], u.leading_colon.is_some(), &mut fact), + syn::Item::Trait(t) => fact.traits.push(t.ident.unraw().to_string()), + syn::Item::Mod(m) if m.content.is_none() => { + fact.mods.push(m.ident.unraw().to_string()); + } + _ => {} + } + } + fact +} + +/// The bindings of one `use` tree, each with the path it names; a path +/// written from the crate graph's root (`::name`) keeps its two colons. +fn scope_uses(tree: &syn::UseTree, prefix: &[String], rooted: bool, out: &mut ScopeFact) { + let with = |ident: &syn::Ident| { + let mut path = prefix.to_vec(); + path.push(ident.to_string()); + path + }; + let printed = |path: Vec| match rooted { + true => format!("::{}", path.join("::")), + false => path.join("::"), + }; + match tree { + syn::UseTree::Path(p) => scope_uses(&p.tree, &with(&p.ident), rooted, out), + syn::UseTree::Name(n) if n.ident == "self" => { + if let Some(last) = prefix.last() { + out.uses.push((last.clone(), printed(prefix.to_vec()))); + } + } + syn::UseTree::Name(n) => out + .uses + .push((n.ident.to_string(), printed(with(&n.ident)))), + syn::UseTree::Rename(r) if r.ident == "self" => { + out.uses + .push((r.rename.to_string(), printed(prefix.to_vec()))); + } + syn::UseTree::Rename(r) => { + out.uses + .push((r.rename.to_string(), printed(with(&r.ident)))); + } + syn::UseTree::Glob(_) => out.glob = true, + syn::UseTree::Group(g) => { + for item in &g.items { + scope_uses(item, prefix, rooted, out); + } + } + } +} + #[allow(clippy::too_many_arguments)] fn items( list: &[syn::Item], @@ -823,11 +1155,13 @@ fn items( file: &mut SourceFile, syntax: &mut FileSyntax, ) { + let scope = file.scopes.len(); + file.scopes.push(scope_fact(list)); for item in list { match item { syn::Item::Fn(f) => { let public = matches!(f.vis, syn::Visibility::Public(_)); - let (fact, fn_syntax) = function( + let (mut fact, fn_syntax) = function( &f.sig, Some(&f.block), &attrs(&f.attrs), @@ -837,6 +1171,7 @@ fn items( in_test, lib, ); + fact.scope = scope; file.fns.push(fact); syntax.fns.push(fn_syntax); } @@ -847,11 +1182,30 @@ fn items( file.error_impls.push(self_ty.clone()); } } - let implements = imp + let named_trait = imp .trait_ .as_ref() - .and_then(|(path, _)| path.segments.last()) - .map(|s| s.ident.to_string()); + .and_then(|(path, _)| path.segments.last()); + let implements = named_trait.map(|s| s.ident.to_string()); + let trait_ref = named_trait.map(|s| tidy(&s.to_token_stream().to_string())); + let trait_path = imp.trait_.as_ref().map(|(path, _)| { + let written: Vec = + path.segments.iter().map(|s| s.ident.to_string()).collect(); + match path.leading_colon { + Some(_) => format!("::{}", written.join("::")), + None => written.join("::"), + } + }); + let impl_params: Vec = imp + .generics + .params + .iter() + .filter_map(|p| match p { + syn::GenericParam::Type(t) => Some(t.ident.to_string()), + syn::GenericParam::Const(c) => Some(c.ident.to_string()), + syn::GenericParam::Lifetime(_) => None, + }) + .collect(); for member in &imp.items { if let syn::ImplItem::Fn(f) = member { let public = matches!(f.vis, syn::Visibility::Public(_)); @@ -866,6 +1220,10 @@ fn items( lib, ); fact.implements.clone_from(&implements); + fact.trait_ref.clone_from(&trait_ref); + fact.trait_path.clone_from(&trait_path); + fact.impl_params.clone_from(&impl_params); + fact.scope = scope; file.fns.push(fact); syntax.fns.push(fn_syntax); } @@ -886,6 +1244,7 @@ fn items( lib, ); fact.in_trait = true; + fact.scope = scope; file.fns.push(fact); syntax.fns.push(fn_syntax); } @@ -932,26 +1291,39 @@ fn items( .collect(), }); } - syn::Item::Struct(st) if only_lifetimes(&st.generics) => { - if let syn::Fields::Named(named) = &st.fields { - file.structs.push(StructFact { - name: st.ident.to_string(), - span: Span { - file: rel.to_string(), - line: st.ident.span().start().line, - }, - derives: derives(&attrs(&st.attrs)), - }); - syntax.structs.push( - named - .named - .iter() - .filter_map(|f| { - Some((f.ident.as_ref()?.to_string(), crate::convert::ty(&f.ty))) - }) - .collect(), - ); - } + // Every struct is registered, so that a type the lift does not + // read is named with its shape and not as an unknown name. A + // unit struct is a struct of no fields. + syn::Item::Struct(st) => { + file.structs.push(StructFact { + name: st.ident.to_string(), + span: Span { + file: rel.to_string(), + line: st.ident.span().start().line, + }, + derives: derives(&attrs(&st.attrs)), + }); + syntax.structs.push(match &st.fields { + _ if !only_lifetimes(&st.generics) => { + vec![crate::lift::unread_shape(crate::lift::PARAMETRIC_STRUCT)] + } + syn::Fields::Named(named) => named + .named + .iter() + .filter_map(|f| { + Some((f.ident.as_ref()?.to_string(), crate::convert::ty(&f.ty))) + }) + .collect(), + // A tuple struct's field is named by its position, as + // Rust reads it (`value.0`). + syn::Fields::Unnamed(unnamed) => unnamed + .unnamed + .iter() + .enumerate() + .map(|(i, f)| (i.to_string(), crate::convert::ty(&f.ty))) + .collect(), + syn::Fields::Unit => Vec::new(), + }); } syn::Item::Type(t) if !in_test @@ -982,8 +1354,12 @@ fn items( } } syn::Item::Mod(m) => { + let marks = attrs(&m.attrs); + if marks.iter().any(|a| named(a, "no_implicit_prelude")) { + file.no_prelude = true; + } if let Some((_, inner)) = &m.content { - let test = in_test || is_cfg_test(&attrs(&m.attrs)); + let test = in_test || is_cfg_test(&marks); items(inner, rel, None, test, product, lib, file, syntax); } } @@ -1208,3 +1584,272 @@ fn effect_of(block: &syn::Block) -> Option<(Capability, String)> { scan.visit_block(block); scan.0 } + +/// The facts and the syntax of one library source text, as [`source`] +/// reads a file. +#[cfg(test)] +pub(crate) fn read_text(text: &str) -> (SourceFile, FileSyntax) { + let parsed = syn::parse_file(text).expect("the source parses"); + let mut file = SourceFile::default(); + let mut syntax = FileSyntax::default(); + items( + &parsed.items, + "lib.rs", + None, + false, + true, + true, + &mut file, + &mut syntax, + ); + (file, syntax) +} + +#[cfg(test)] +mod tests { + use super::*; + + // Types outside the lift. + + #[test] + fn every_struct_is_registered_with_the_fields_its_shape_has() { + let (file, syntax) = read_text( + "struct Named { a: u8 } struct Meters(u32, bool); struct Marker; \ + struct Wrapper { value: T } struct Reader<'a> { text: &'a str }", + ); + let names: Vec<&str> = file.structs.iter().map(|s| s.name.as_str()).collect(); + assert_eq!(names, ["Named", "Meters", "Marker", "Wrapper", "Reader"]); + let fields = |i: usize| -> Vec<(&str, &str)> { + syntax.structs[i] + .iter() + .map(|(n, t)| (n.as_str(), t.text.as_str())) + .collect() + }; + assert_eq!(fields(0), [("a", "u8")]); + // A tuple struct's fields are named by position. + assert_eq!(fields(1), [("0", "u32"), ("1", "bool")]); + // A unit struct has none. + assert!(fields(2).is_empty()); + // A struct with a type parameter is no one type: it is registered + // under no field name, with its shape. + assert_eq!(fields(3), [("", crate::lift::PARAMETRIC_STRUCT)]); + // A lifetime is no such parameter. + assert_eq!(fields(4), [("text", "&'a str")]); + } + + // Functions refused by their signature or misread by where they stand: + // which files and modules are test code, the names each module scope + // binds, and the facts a trait implementation's method carries. + + fn facts(src: &str, test_file: bool) -> SourceFile { + let parsed = syn::parse_file(src).unwrap_or_else(|e| panic!("parses: {e}")); + let rel = "src/lib.rs".to_string(); + source(&parsed, rel, 0, String::new(), &TargetKind::Lib, test_file).0 + } + + fn method<'a>(file: &'a SourceFile, owner: &str, of: Option<&str>, name: &str) -> &'a FnFact { + file.fns + .iter() + .find(|f| { + f.owner.as_deref() == Some(owner) + && f.trait_ref.as_deref() == of + && f.name == name + && !f.in_trait + }) + .unwrap_or_else(|| panic!("{owner} has {name} of {of:?}")) + } + + #[test] + fn a_cfg_marks_test_code_where_it_holds_in_a_test_build_alone() { + let marked = |cfg: &str| -> bool { + let item: syn::ItemMod = + syn::parse_str(&format!("#[cfg({cfg})] mod m;")).expect("parses"); + is_cfg_test(&attrs(&item.attrs)) + }; + for cfg in [ + "test", + "all(test, feature = \"x\")", + "all(unix, any(test))", + "any(test)", + "any(test, all(test, unix))", + ] { + assert!(marked(cfg), "{cfg} holds in a test build alone"); + } + for cfg in [ + "not(test)", + "any(test, feature = \"x\")", + "all(unix, not(test))", + "feature = \"test\"", + "target_os = \"test\"", + "any()", + "all()", + ] { + assert!(!marked(cfg), "{cfg} holds outside a test build too"); + } + // Several attributes hold together: one that is a test build's is + // enough. + let both: syn::ItemMod = + syn::parse_str("#[cfg(unix)] #[cfg(test)] mod m;").expect("parses"); + assert!(is_cfg_test(&attrs(&both.attrs))); + } + + #[test] + fn a_module_declared_out_of_line_under_a_test_cfg_marks_its_files() { + let sources = [ + ( + "src/lib.rs", + "#[cfg(test)] mod tests; mod a; mod plain; #[cfg(test)] mod deep; \ + #[cfg(test)] #[path = \"elsewhere/odd.rs\"] mod odd; \ + #[cfg(test)] pub mod both; #[cfg(not(test))] mod both; \ + #[cfg(any(test, feature = \"x\"))] mod shared; \ + mod inline { #[cfg(test)] mod under; mod over; }", + ), + ("src/tests.rs", "mod helpers;"), + ("src/tests/helpers.rs", ""), + ("src/a.rs", "#[cfg(test)] mod t; mod u;"), + ("src/a/t.rs", ""), + ("src/a/u.rs", ""), + ("src/plain.rs", ""), + ("src/deep/mod.rs", "mod inner;"), + ("src/deep/inner.rs", ""), + ("src/elsewhere/odd.rs", "mod beside;"), + ("src/elsewhere/beside.rs", ""), + ("src/both.rs", "mod part;"), + ("src/both/part.rs", ""), + ("src/shared.rs", ""), + ("src/inline/under.rs", ""), + ("src/inline/over.rs", ""), + // A file no declaration names is no module at all. + ("src/stray.rs", ""), + ]; + let parsed: Vec<(PathBuf, syn::File)> = sources + .iter() + .map(|(path, src)| (PathBuf::from(path), syn::parse_file(src).expect("parses"))) + .collect(); + let trees: BTreeMap<&Path, &syn::File> = + parsed.iter().map(|(p, f)| (p.as_path(), f)).collect(); + let found = test_files(&[PathBuf::from("src/lib.rs")], &trees); + let expected: BTreeSet = [ + "src/a/t.rs", + "src/deep/inner.rs", + "src/deep/mod.rs", + "src/elsewhere/beside.rs", + "src/elsewhere/odd.rs", + "src/inline/under.rs", + "src/tests.rs", + "src/tests/helpers.rs", + ] + .iter() + .map(PathBuf::from) + .collect(); + assert_eq!(found, expected); + } + + #[test] + fn a_function_of_a_test_file_is_test_code() { + let src = "pub fn helper() -> u32 { 1 } pub struct S; impl S { fn m(&self) {} }"; + assert!(facts(src, true).fns.iter().all(|f| f.in_test_module)); + assert!(facts(src, false).fns.iter().all(|f| !f.in_test_module)); + } + + #[test] + fn a_trait_method_stands_apart_where_its_type_has_another_of_its_name() { + let file = facts( + "struct S; struct T; \ + trait A { fn m(&self) -> u32; fn n(&self) -> u32; } \ + trait B { fn m(&self) -> u32; } \ + impl S { fn n(&self) -> u32 { 0 } } \ + impl A for S { fn m(&self) -> u32 { 1 } fn n(&self) -> u32 { 2 } } \ + impl B for S { fn m(&self) -> u32 { 3 } } \ + impl A for T { fn m(&self) -> u32 { 4 } fn n(&self) -> u32 { 5 } } \ + impl From for T { fn from(_n: u8) -> T { T } } \ + impl From for T { fn from(_n: u16) -> T { T } } \ + impl From for S { fn from(_n: u8) -> S { S } }", + false, + ); + // Two traits give `S` an `m`, and an inherent `n` stands beside a + // trait's; one generic trait gives `T` a `from` twice. + assert!(method(&file, "S", Some("A"), "m").apart); + assert!(method(&file, "S", Some("B"), "m").apart); + assert!(method(&file, "S", Some("A"), "n").apart); + assert!(method(&file, "T", Some("From"), "from").apart); + assert!(method(&file, "T", Some("From"), "from").apart); + // One trait for two types, and a type's only method of a name. + assert!(!method(&file, "T", Some("A"), "m").apart); + assert!(!method(&file, "T", Some("A"), "n").apart); + assert!(!method(&file, "S", Some("From"), "from").apart); + // An inherent method is `Type::name` whatever stands beside it. + assert!(!method(&file, "S", None, "n").apart); + } + + #[test] + fn each_module_scope_keeps_the_names_it_binds() { + let file = facts( + "#![no_implicit_prelude] \ + use std::fmt; use crate::shapes::{self, Shape, Named as _}; use ::serde::Serialize; \ + mod child; \ + trait Local { fn m(&mut self); } \ + struct S; \ + impl Local for S { fn m(&mut self) {} } \ + pub mod inner { \ + use super::*; \ + pub struct T; \ + impl crate::shapes::Shape for T { fn area(&self) -> u32 { 0 } } \ + impl From<[X; N]> for T { fn from(_x: [X; N]) -> T { T } } \ + }", + false, + ); + assert!(file.no_prelude); + assert_eq!(file.scopes.len(), 2); + let uses: Vec<(&str, &str)> = file.scopes[0] + .uses + .iter() + .map(|(n, p)| (n.as_str(), p.as_str())) + .collect(); + assert_eq!( + uses, + [ + ("fmt", "std::fmt"), + ("shapes", "crate::shapes"), + ("Shape", "crate::shapes::Shape"), + ("_", "crate::shapes::Named"), + ("Serialize", "::serde::Serialize"), + ] + ); + assert!(!file.scopes[0].glob); + assert_eq!(file.scopes[0].traits, ["Local"]); + assert_eq!(file.scopes[0].mods, ["child"]); + // The inline module binds nothing by name, and its glob may bind + // anything. + assert!(file.scopes[1].glob && file.scopes[1].uses.is_empty()); + let m = method(&file, "S", Some("Local"), "m"); + assert_eq!((m.scope, m.trait_path.as_deref()), (0, Some("Local"))); + assert_eq!(m.receiver.as_deref(), Some("&mut self")); + assert!(m.impl_params.is_empty()); + let area = method(&file, "T", Some("Shape"), "area"); + assert_eq!( + (area.scope, area.trait_path.as_deref()), + (1, Some("crate::shapes::Shape")) + ); + let from = file.fns.iter().find(|f| f.name == "from").expect("from"); + assert_eq!(from.impl_params, ["X", "N"]); + assert_eq!(from.receiver, None); + } + + #[test] + fn a_type_the_lift_does_not_read_says_its_shape() { + let file = facts( + "struct A(u32); struct B; struct C { t: T } enum D { X(T) } \ + union E { a: u32 } struct F { a: u32 } enum G { X } struct H<'a> { a: &'a str }", + false, + ); + assert_eq!( + file.unread, + [ + ("C".to_string(), crate::lift::PARAMETRIC_STRUCT), + ("D".to_string(), "an enum with type parameters"), + ("E".to_string(), "a union"), + ] + ); + } +} diff --git a/crates/uorust/src/lex.rs b/crates/uorust/src/lex.rs index 62ed2cb2..a0ffe898 100644 --- a/crates/uorust/src/lex.rs +++ b/crates/uorust/src/lex.rs @@ -565,24 +565,23 @@ pub(crate) fn escape(text: &str) -> String { out } -/// `(cons "a" (cons "b" (nil String)))`. +/// The list of the strings `items`: `(cons "a" (cons "b" (nil String)))`, +/// and a long one as balanced halves ([`crate::embed::term_list`]), since a +/// feature lists every call and acceptance row of its module and the linker +/// reads a term to a bounded depth. pub(crate) fn string_list(items: &[String]) -> String { - let mut out = "(nil String)".to_string(); - for item in items.iter().rev() { - out = format!("(cons {} {out})", string(item)); - } - out + let quoted: Vec = items.iter().map(|item| string(item)).collect(); + crate::embed::term_list("ed, "String") } /// `lowerCamel` from any Rust or Cargo name: `thermo-core::should_heat` -> /// `thermoCoreShouldHeat`. pub(crate) fn camel(parts: &[&str]) -> String { - let pascal = pascal(parts); - let mut chars = pascal.chars(); - match chars.next() { - Some(first) => first.to_ascii_lowercase().to_string() + chars.as_str(), - None => String::new(), - } + pascal(parts) + .chars() + .enumerate() + .map(|(i, c)| if i == 0 { c.to_ascii_lowercase() } else { c }) + .collect::() } /// `PascalCase` from any Rust or Cargo name. @@ -609,9 +608,10 @@ pub(crate) fn pascal(parts: &[&str]) -> String { } } if out.starts_with(|c: char| c.is_ascii_digit()) { - out.insert(0, 'N'); + format!("N{out}") + } else { + out } - out } #[cfg(test)] @@ -659,4 +659,26 @@ mod tests { let long = Decl::value("callA", "String", string(&"x".repeat(80))); assert!(render_decl(&long).starts_with("definition{\n name: callA,\n")); } + + // residue: `camel` and `pascal` rewritten inside the fragment the tool + // lifts from itself; this pins what the old bodies did. + + #[test] + fn residue_names_keep_their_case_rules_at_the_edges() { + assert_eq!(camel(&[]), ""); + assert_eq!(camel(&["--", "_"]), ""); + assert_eq!(pascal(&[]), ""); + assert_eq!(pascal(&["--"]), ""); + // The first character only is lowered, after the digit's prefix. + assert_eq!(camel(&["2d"]), "n2d"); + assert_eq!(camel(&["x"]), "x"); + assert_eq!(camel(&["Ab", "Cd"]), "abCd"); + assert_eq!(camel(&["r#type"]), "rType"); + // A digit after the first part is no prefix. + assert_eq!(pascal(&["a", "2"]), "A2"); + assert_eq!(pascal(&["9", "a"]), "N9A"); + assert_eq!(camel(&["9", "a"]), "n9A"); + // Non-ASCII characters are separators. + assert_eq!(pascal(&["é9"]), "N9"); + } } diff --git a/crates/uorust/src/lib.rs b/crates/uorust/src/lib.rs index 717aa27f..e3e511b8 100644 --- a/crates/uorust/src/lib.rs +++ b/crates/uorust/src/lib.rs @@ -27,6 +27,7 @@ pub mod layouts; mod lex; mod lift; pub mod mir; +mod names; mod order; mod project; pub mod queue; @@ -77,11 +78,12 @@ fn project_workspace_here( return Err(UorustError::BadTimestamp(options.last_modified.clone())); } let (workspace, syntax) = ingest::workspace(root, options.advisories.as_deref())?; + let syntax = names::read(root, &workspace, syntax)?; let dumps = match &options.mir { Some(m) => Some(mir::load(root, &m.dumps)?), None => None, }; - let mut files = project::project(&workspace, &syntax, options, dumps.as_ref()); + let mut files = project::project(&workspace, &syntax, options, dumps.as_ref())?; let manifest: String = files .iter() .map(|(path, bytes)| format!("{} {path}\n", project::sha(bytes))) @@ -166,7 +168,7 @@ pub fn admit(path: &Path, files: &BTreeMap>) -> Result<(), Uorus return Ok(()); } let text = std::fs::read_to_string(path).map_err(|e| error::io(path, e))?; - let incumbent = register::Register::parse(path, &text)?; + let incumbent = register::Register::read(path, &text)?; let regressed = register::admit(&incumbent, &lift_register(files)?); if regressed.is_empty() { Ok(()) diff --git a/crates/uorust/src/lift.rs b/crates/uorust/src/lift.rs index b757a0d5..22f03548 100644 --- a/crates/uorust/src/lift.rs +++ b/crates/uorust/src/lift.rs @@ -115,6 +115,12 @@ pub(crate) enum Ty { /// (a `Nat`): the format's exponent and fraction widths, as core's own /// constants give them (see `mir::float`). Float(crate::mir::float::Format), + /// A signed integer the 64-bit family does not hold: `i128`, of 128 + /// bits, or `isize` (`None`), as wide as the target's pointer. Held as + /// LexLean's mathematical `Int`, as `u128` and `usize` are held as + /// `Nat`: the width says what an operation may return, and is no part + /// of how a value is held. + Integer(Option), /// The MIR path's signed integer of this many bits (`None` for /// `isize`), held as its two's-complement bit pattern in `Nat`: LexLean /// converts no `Nat` to a signed family, so a cast between the two @@ -161,6 +167,7 @@ impl Ty { Self::Bool => "Bool".into(), Self::Nat(_) | Self::Float(_) | Self::Signed(_) | Self::Scalar => "Nat".into(), Self::Int(_) => "Int64".into(), + Self::Integer(_) => "Int".into(), Self::Str | Self::Char => "String".into(), Self::ParseError => format!("{PRELUDE}::ParseIntError"), Self::Path => format!("{PRELUDE}::FilePath"), @@ -203,6 +210,9 @@ impl Ty { Self::Bool => "Bool".into(), Self::Nat(_) | Self::Float(_) | Self::Signed(_) | Self::Scalar => "Nat".into(), Self::Int(_) => "Int".into(), + // `Int` is the tag of `Int64`; a name of the prefix no + // workspace type lifts under tells the two apart. + Self::Integer(_) => INTEGER_TAG.into(), Self::Str | Self::Char => "String".into(), Self::ParseError => "ParseIntError".into(), Self::Path => "FilePath".into(), @@ -284,7 +294,10 @@ fn named_in(types: &BTreeSet) -> BTreeSet { /// constructor `mk` of a struct of a recursive family. pub(crate) fn struct_value(name: &str, fields: &[(&String, String)], types: &Types) -> String { if types.boxed(name) { - let args: String = fields.iter().map(|(_, v)| format!(" {v}")).collect(); + let args = fields + .iter() + .map(|(_, v)| format!(" {v}")) + .collect::(); format!("(ctor {name}.mk{args})") } else { let parts: Vec = fields.iter().map(|(f, v)| format!("{f} := {v}")).collect(); @@ -354,8 +367,133 @@ pub(crate) struct Types { /// by LexLean name, where they are not the variants' indices alone. /// Held as `i64`, the width the lift lifts, and widened where read. pub(crate) discriminants: BTreeMap>, + /// The workspace's structs and enums outside the lift, by LexLean name: + /// the chain from each down to the leaf that keeps it out + /// (`Mid.leaf: Leaf.x: f64`), so that a residue row states its cause + /// and not only the nearest type the cause is inside. + pub(crate) outside: BTreeMap, +} + +/// The tag of the mathematical `Int` in a generated name. +const INTEGER_TAG: &str = "LexLeanInt"; + +/// The one constructor of a struct that declares no field (`struct S;`): +/// LexLean's structure holds at least one field, so such a struct is the +/// inductive of one constructor, named as Lean names a structure's own. +const SOLE: &str = "mk"; + +/// The LexLean name of a struct's field: a tuple struct's, which Rust +/// names by position, as a generated tuple's item is named. A position is +/// read as a `u32`, a width fixed on every target: rustc numbers a +/// struct's fields by `FieldIdx`, a 32-bit index, so every position Rust +/// can write fits it, and the reading holds whatever `usize` is. +fn field_name(rust: &str) -> String { + match rust.parse::() { + Ok(position) => format!("item{position}"), + Err(_) => local_name(rust), + } +} + +/// A type whose name LexLean or the projection writes for a type of its own. +const TAKEN_NAME: &str = "a type named as LexLean or the projection names one of its own"; + +/// A variant whose name is a word LexLean or Lean reserves. +const TAKEN_VARIANT: &str = "a variant named as a word LexLean reserves"; + +/// A recursive occurrence Lean does not nest an inductive under. +const NOT_NESTED: &str = + "a recursion through a tuple, a map or a set, where Lean nests no inductive"; + +/// A struct with a type or const parameter: one declaration, a type per +/// instance. +pub(crate) const PARAMETRIC_STRUCT: &str = "a struct with type or const parameters"; + +/// A name two declarations of one module share: one type per build +/// configuration, or an item of an inline module read at its file's. +pub(crate) const DECLARED_TWICE: &str = "a type declared twice in one module"; + +/// A name several types of a crate share, where the file that writes it +/// neither declares nor imports one of them. +pub(crate) const SHARED_NAME: &str = + "one of several types of this name in its crate, which the file does not tell apart"; + +/// A struct the reader of structs does not read as fields, or a name that +/// reads as no one type, registered so that the type side names it: under +/// no field name, with its shape where a field's type stands. A shape is +/// no type, so the name stays outside the lift and is itself the leaf of +/// every chain through it. +pub(crate) fn unread_shape(shape: &str) -> (String, rs::RustType) { + let shape = rs::RustType { + text: shape.to_string(), + kind: rs::TypeKind::Other, + }; + (String::new(), shape) +} + +/// Where the standard library declares each type the lift reads that a +/// source may name by its full path: the module, under `std` (or `core` +/// or `alloc`, which `std` re-exports them from), and the names. +const LIBRARY: [(&str, &[&str]); 10] = [ + ("boxed", &["Box"]), + ( + "collections", + &["BTreeMap", "BTreeSet", "HashMap", "HashSet", "VecDeque"], + ), + ("ops", &["Range"]), + ("option", &["Option"]), + ("path", &["Path", "PathBuf"]), + ("rc", &["Rc"]), + ("result", &["Result"]), + ("string", &["String"]), + ("sync", &["Arc"]), + ("vec", &["Vec"]), +]; + +/// Whether a path is the standard library's own full path of a type the +/// lift reads: `std::collections::BTreeMap`, `std::rc::Rc`. +fn std_path(path: &rs::Path) -> bool { + let [root, module, last] = path.segments.as_slice() else { + return false; + }; + let plain = |s: &rs::PathSegment| matches!(s.arguments, rs::PathArguments::None); + matches!(root.ident.as_str(), "std" | "core" | "alloc") + && plain(root) + && plain(module) + && LIBRARY + .iter() + .any(|(m, names)| *m == module.ident && names.contains(&last.ident.as_str())) } +/// Whether a generic argument, as written, is a lifetime (`'a`, `'_`): a +/// character literal, a const argument, closes its quote. +fn is_lifetime(argument: &str) -> bool { + match argument.trim().strip_prefix('\'') { + Some(name) => !name.contains('\''), + None => false, + } +} + +/// A field of a variant as Rust writes its place: `Enum::Variant.name`, or +/// `Enum::Variant.0` by position. +fn variant_field(owner: &str, variant: &str, field: Option<&str>, at: usize) -> String { + match field { + Some(f) => format!("{owner}::{variant}.{f}"), + None => format!("{owner}::{variant}.{at}"), + } +} + +/// What keeps a field of a type of the workspace outside the lift. +enum Stop { + /// A leaf, by its text: a type no part of the workspace's types. + Leaf(String), + /// Another type of the workspace that is itself outside, by name. + Type(String), +} + +/// Marks, in the text of a type residue, a type of the workspace whose +/// chain is still to be built: a character no type's text holds. +const PENDING: char = '\u{1}'; + /// The strongly connected components of a graph, each one set. fn strong_components(graph: &BTreeMap>) -> Vec> { let reach = |start: &String| { @@ -405,8 +543,11 @@ fn positive(ty: &Ty, family: &BTreeSet) -> bool { /// A field of a data-carrying variant: its Rust name, if any, and its type. pub(crate) type DataField = (Option, Ty); +/// A variant of a data-carrying enum and its fields, as Rust writes them. +type RawVariant = (String, Vec<(Option, rs::RustType)>); + /// The fields of each variant of a data-carrying enum, as Rust writes them. -pub(crate) type RawVariants = Vec<(String, Vec<(Option, rs::RustType)>)>; +pub(crate) type RawVariants = Vec; /// Whether `ty` names `me` only where Lean accepts a nested occurrence: /// directly, or inside `Option`, `List` or `Result`. @@ -457,10 +598,46 @@ fn with_domains(ty: &Ty, family: &BTreeSet, domains: Vec) -> Vec domains } +/// Whether LexLean or the projection writes this name for a type of its +/// own, so that no type of the workspace lifts under it. `declared` is a +/// struct or a data-carrying enum, whose declaration may not be named as +/// the tuple structures the projection generates are. The projection lifts +/// such a type under its crate's name and its own. +pub(crate) fn name_taken(name: &str, declared: bool) -> bool { + let generated = declared && name.starts_with("Tuple"); + BARE_TYPES.contains(&name) || name.starts_with("LexLean") || generated +} + +/// Why a type is outside the lift whatever it holds, known before any type +/// is read: the chain that names it, where one does. Its own name, or a +/// variant's, is one LexLean writes; or the reader of structs did not read +/// it as fields (see [`unread_shape`]), and the struct is the leaf. +fn barred( + name: &str, + declared: bool, + variants: &[&str], + fields: &[(String, rs::RustType)], +) -> Option { + if let [(unnamed, shape)] = fields { + if unnamed.is_empty() { + return Some(format!("{name}: {}", shape.text)); + } + } + if name_taken(name, declared) { + return Some(format!("{name}: {TAKEN_NAME}")); + } + variants + .iter() + .find(|v| RESERVED.contains(v)) + .map(|v| format!("{name}::{v}: {TAKEN_VARIANT}")) +} + impl Types { /// The lifted types with data-carrying enums among them: every type to /// the fixpoint where each names only types that lift, and no two name - /// each other (a data enum may name itself). + /// each other (a data enum may name itself). A type the fixpoint drops + /// is recorded in `outside` with the chain down to its leaf (see + /// [`Types::chains`]). pub(crate) fn with_data( enums: BTreeMap>, datas: &BTreeMap, @@ -468,18 +645,35 @@ impl Types { aliases: BTreeMap, ) -> Self { let base = Self::new(enums, structs, aliases); + // What a name or a variant alone keeps out, whatever the type + // holds. The structs' chains of `new` are not taken: it read them + // without the data-carrying enums. + let mut outside: BTreeMap = base + .outside + .iter() + .filter(|(n, _)| !structs.contains_key(*n)) + .map(|(n, chain)| (n.clone(), chain.clone())) + .collect(); + for (n, variants) in datas { + let known = base.enums.contains_key(n) || base.structs.contains_key(n); + let named: Vec<&str> = variants.iter().map(|(v, _)| v.as_str()).collect(); + if let (false, Some(why)) = (known, barred(n, true, &named, &[])) { + outside.insert(n.clone(), why); + } + } + for (n, fields) in structs { + let barred = barred(n, true, &[], fields); + if let (false, Some(why)) = (base.enums.contains_key(n), barred) { + outside.insert(n.clone(), why); + } + } let mut names: BTreeSet = datas .keys() .filter(|n| { !base.enums.contains_key(*n) && !base.structs.contains_key(*n) - && !BARE_TYPES.contains(&n.as_str()) - && !n.starts_with("LexLean") - && !n.starts_with("Tuple") + && !outside.contains_key(*n) && !datas[*n].is_empty() - && datas[*n] - .iter() - .all(|(v, _)| !RESERVED.contains(&v.as_str())) }) .cloned() .collect(); @@ -487,14 +681,10 @@ impl Types { // Lean writes bare or that the projection generates. let mut struct_names: BTreeSet = structs .keys() - .filter(|n| { - !base.enums.contains_key(*n) - && !BARE_TYPES.contains(&n.as_str()) - && !n.starts_with("LexLean") - && !n.starts_with("Tuple") - }) + .filter(|n| !base.enums.contains_key(*n) && !outside.contains_key(*n)) .cloned() .collect(); + let candidates: BTreeSet = names.union(&struct_names).cloned().collect(); loop { let probe = Self { datas: names.iter().map(|n| (n.clone(), Vec::new())).collect(), @@ -503,40 +693,20 @@ impl Types { .filter(|n| !base.enums.contains_key(*n)) .map(|n| (n.clone(), Vec::new())) .collect(), + outside: outside.clone(), ..base.clone() }; + // The families this round refuses, each member with its chain. + let mut refused: BTreeMap = BTreeMap::new(); let mut lifted = BTreeMap::new(); for name in &names { - let mut variants = Vec::new(); - let mut ok = true; - for (variant, fields) in &datas[name] { - let mut tys = Vec::new(); - for (field, t) in fields { - match probe.ty(t) { - Ok(ty) if nested_ok(&ty, name) => tys.push((field.clone(), ty)), - _ => ok = false, - } - } - variants.push((variant.clone(), tys)); - } - if ok { + if let Some(variants) = probe.variants_read(name, &datas[name]) { lifted.insert(name.clone(), variants); } } let mut fields_of = BTreeMap::new(); for name in &struct_names { - let Some(raw) = structs.get(name) else { - continue; - }; - let mut fields = Vec::new(); - let mut ok = !raw.is_empty(); - for (field, t) in raw { - match probe.ty(t) { - Ok(ty) => fields.push((local_name(field), ty)), - Err(_) => ok = false, - } - } - if ok { + if let Some(fields) = structs.get(name).and_then(|raw| probe.fields_read(raw)) { fields_of.insert(name.clone(), fields); } } @@ -570,43 +740,222 @@ impl Types { if !recursive { continue; } - let fields = family.iter().flat_map(|n| { - lifted + // Each member's fields: where Rust writes it, as written + // and as read, in declaration order. + let places = |n: &String| { + let of_variants = lifted .get(n) .into_iter() .flatten() - .flat_map(|(_, fs)| fs.iter().map(|(_, t)| t.clone())) - .chain( - fields_of - .get(n) - .into_iter() - .flatten() - .map(|(_, t)| t.clone()), - ) - .collect::>() - }); - let positive = fields.clone().all(|t| positive(&t, &family)); - if positive { - families.push(family); - } else { - cyclic.extend(family); + .zip(datas.get(n).into_iter().flatten()) + .flat_map(|((v, tys), (_, raws))| { + tys.iter() + .zip(raws) + .enumerate() + .map(|(i, ((_, ty), (f, raw)))| { + (variant_field(n, v, f.as_deref(), i), raw, ty.clone()) + }) + }); + let of_fields = fields_of + .get(n) + .into_iter() + .flatten() + .zip(structs.get(n).into_iter().flatten()) + .map(|((_, ty), (f, raw))| (format!("{n}.{f}"), raw, ty.clone())); + of_variants.chain(of_fields).collect::>() + }; + let held = family + .iter() + .flat_map(places) + .find(|(_, _, ty)| !positive(ty, &family)); + match held { + None => families.push(family), + Some((at, raw, _)) => { + let chain = format!("{at}: {}: {NOT_NESTED}", raw.text); + for member in &family { + // The member that holds the occurrence states + // it; the others are in its family. + let own = at.starts_with(&format!("{member}.")) + || at.starts_with(&format!("{member}::")); + let why = if own { + chain.clone() + } else { + format!("{member}: in one recursive family with {chain}") + }; + refused.insert(member.clone(), why); + } + cyclic.extend(family); + } } } lifted.retain(|n, _| !cyclic.contains(n)); fields_of.retain(|n, _| !cyclic.contains(n)); if lifted.len() == names.len() && fields_of.len() == struct_names.len() { + // This round's probe names exactly the types that lift. + let pending = candidates + .iter() + .filter(|n| !probe.datas.contains_key(*n) && !probe.structs.contains_key(*n)) + .filter(|n| !outside.contains_key(*n)) + .cloned() + .collect(); + outside.extend(probe.chains(&pending, datas, structs)); return Self { datas: lifted, structs: fields_of, families, + outside, ..base }; } + outside.extend(refused); names = lifted.into_keys().collect(); struct_names = fields_of.into_keys().collect(); } } + /// The chain of each type the fixpoint dropped, down to its leaf. From + /// the type, the first field in declaration order that is outside the + /// lift and under which a leaf lies without passing through a type + /// already on the chain; then the same from the type that field names, + /// to the leaf. A chain so never leads back into a type it explains: + /// of two types each outside through the other, each names what keeps + /// it out on its own account. `self` names the types that lift, and + /// holds in `outside` the chains already known; `pending` are the + /// dropped types. + fn chains( + &self, + pending: &BTreeSet, + datas: &BTreeMap, + structs: &BTreeMap>, + ) -> BTreeMap { + let mut probe = self.clone(); + for n in pending { + probe.outside.insert(n.clone(), format!("{PENDING}{n}")); + } + let stop = |at: String, read: Lift, written: &rs::RustType, owner: &str| { + let stop = match read { + Ok(ty) if nested_ok(&ty, owner) => return None, + Ok(_) => Stop::Leaf(format!("{}: {NOT_NESTED}", written.text)), + Err(Residue::Type(text)) => match text.strip_prefix(PENDING) { + Some(name) => Stop::Type(name.to_string()), + None => Stop::Leaf(text), + }, + Err(other) => Stop::Leaf(other.detail()), + }; + Some((at, stop)) + }; + // Each dropped type's fields that are outside, in declaration + // order: where Rust writes the field, and what stops it. The type + // itself is read as known there: a field that holds it is outside + // on the type's own account only where Lean nests no inductive. + let stops: BTreeMap<&String, Vec<(String, Stop)>> = pending + .iter() + .map(|n| { + let mut own = probe.clone(); + own.outside.remove(n); + if datas.contains_key(n) { + own.datas.insert(n.clone(), Vec::new()); + } else { + own.structs.insert(n.clone(), Vec::new()); + } + let of_variants = datas.get(n).into_iter().flatten().flat_map(|(v, fields)| { + let own = &own; + fields.iter().enumerate().filter_map(move |(i, (f, t))| { + stop(variant_field(n, v, f.as_deref(), i), own.ty(t), t, n) + }) + }); + let of_fields = structs + .get(n) + .into_iter() + .flatten() + .filter_map(|(f, t)| stop(format!("{n}.{f}"), own.ty(t), t, "")); + (n, of_variants.chain(of_fields).collect()) + }) + .collect(); + // Whether a leaf lies under `from` without passing through `on`. + let grounded = |from: &String, on: &BTreeSet<&String>| { + let mut seen: BTreeSet<&String> = on.clone(); + let mut next = vec![from]; + while let Some(n) = next.pop() { + if !seen.insert(n) { + continue; + } + for (_, stop) in stops.get(n).into_iter().flatten() { + match stop { + Stop::Leaf(_) => return true, + Stop::Type(inner) => next.push(inner), + } + } + } + false + }; + let mut chains = BTreeMap::new(); + for start in pending { + let mut on: BTreeSet<&String> = BTreeSet::from([start]); + let mut at = start; + let mut chain = String::new(); + loop { + let held = stops.get(at).into_iter().flatten().find(|(_, s)| match s { + Stop::Leaf(_) => true, + Stop::Type(inner) => !on.contains(inner) && grounded(inner, &on), + }); + match held { + Some((place, Stop::Leaf(leaf))) => { + chain.push_str(&format!("{place}: {leaf}")); + break; + } + Some((place, Stop::Type(inner))) => { + chain.push_str(&format!("{place}: ")); + on.insert(inner); + at = inner; + } + // Every dropped type has a leaf under it: the round + // that dropped it read one, or a type dropped before. + None => { + chain.push_str(at); + break; + } + } + } + chains.insert(start.clone(), chain); + } + chains + } + + /// A struct's fields as the lift names them, where every one lifts. A + /// tuple struct's field is named by its position. + fn fields_read(&self, raw: &[(String, rs::RustType)]) -> Option> { + let read: Vec<(String, Ty)> = raw + .iter() + .filter_map(|(field, t)| self.ty(t).ok().map(|ty| (field_name(field), ty))) + .collect(); + (read.len() == raw.len()).then_some(read) + } + + /// A data-carrying enum's variants as the lift names them, where every + /// field lifts and holds the enum itself only where Lean nests an + /// inductive. + fn variants_read( + &self, + name: &str, + raw: &[RawVariant], + ) -> Option)>> { + let read = raw + .iter() + .filter_map(|(variant, fields)| { + let tys: Vec<(Option, Ty)> = fields + .iter() + .filter_map(|(field, t)| { + let ty = self.ty(t).ok().filter(|ty| nested_ok(ty, name)); + ty.map(|ty| (field.clone(), ty)) + }) + .collect(); + (tys.len() == fields.len()).then_some((variant.clone(), tys)) + }) + .collect::>(); + (read.len() == raw.len()).then_some(read) + } + /// The structs whose every field lifts, to the fixpoint where a struct /// only names enums and structs that lift. /// Rust type names `aliases` maps to the LexLean names the maps are @@ -616,67 +965,60 @@ impl Types { structs: &BTreeMap>, aliases: BTreeMap, ) -> Self { - let enums: BTreeMap> = enums - .into_iter() - .filter(|(n, vs)| { - !BARE_TYPES.contains(&n.as_str()) - && !n.starts_with("LexLean") - && vs.iter().all(|v| !RESERVED.contains(&v.as_str())) + let mut outside: BTreeMap = enums + .iter() + .filter_map(|(n, vs)| { + let named: Vec<&str> = vs.iter().map(String::as_str).collect(); + Some((n.clone(), barred(n, false, &named, &[])?)) }) .collect(); - let mut names: BTreeSet = structs - .keys() - .filter(|n| { - !enums.contains_key(*n) - && !BARE_TYPES.contains(&n.as_str()) - && !n.starts_with("LexLean") - && !n.starts_with("Tuple") - }) - .cloned() + let mut enums: BTreeMap> = enums + .into_iter() + .filter(|(n, _)| !outside.contains_key(n)) .collect(); + let mut names = BTreeSet::new(); + for (n, fields) in structs { + if enums.contains_key(n) { + continue; + } + match barred(n, true, &[], fields) { + Some(why) => { + outside.insert(n.clone(), why); + } + // A struct of no fields has one value: the inductive of + // one constructor. + None if fields.is_empty() => { + enums.insert(n.clone(), vec![SOLE.to_string()]); + } + None => { + names.insert(n.clone()); + } + } + } + let candidates = names.clone(); loop { let probe = Self { enums: enums.clone(), structs: names.iter().map(|n| (n.clone(), Vec::new())).collect(), aliases: aliases.clone(), - datas: BTreeMap::new(), - families: Vec::new(), - derives: BTreeMap::new(), - closures: BTreeMap::new(), - core: false, - floats: BTreeMap::new(), - valid: BTreeMap::new(), - borrowing: BTreeMap::new(), - discriminants: BTreeMap::new(), + outside: outside.clone(), + ..Self::default() }; let mut lifted = BTreeMap::new(); for name in &names { - let mut fields = Vec::new(); - let mut ok = !structs[name].is_empty(); - for (field, t) in &structs[name] { - match probe.ty(t) { - Ok(ty) => fields.push((local_name(field), ty)), - Err(_) => ok = false, - } - } - if ok { + if let Some(fields) = probe.fields_read(&structs[name]) { lifted.insert(name.clone(), fields); } } if lifted.len() == names.len() { + let pending = candidates.difference(&names).cloned().collect(); + outside.extend(probe.chains(&pending, &BTreeMap::new(), structs)); return Self { enums, structs: lifted, aliases, - datas: BTreeMap::new(), - families: Vec::new(), - derives: BTreeMap::new(), - closures: BTreeMap::new(), - core: false, - floats: BTreeMap::new(), - valid: BTreeMap::new(), - borrowing: BTreeMap::new(), - discriminants: BTreeMap::new(), + outside, + ..Self::default() }; } names = lifted.into_keys().collect(); @@ -777,12 +1119,40 @@ impl Types { format!("field_{name}_{field}") } - /// The LexLean name of a Rust type name. + /// The LexLean name of a Rust type name. A lifetime argument is erased, + /// as where a type is read: the owner `Reader<'a>` of a method names + /// the struct `Reader`. pub(crate) fn resolve(&self, rust: &str) -> String { + let bare = match rust.split_once('<') { + Some((head, arguments)) => match arguments.strip_suffix('>') { + Some(list) if list.split(',').all(is_lifetime) => head.trim_end(), + _ => rust, + }, + None => rust, + }; self.aliases - .get(rust) + .get(bare) .cloned() - .unwrap_or_else(|| rust.to_string()) + .unwrap_or_else(|| bare.to_string()) + } + + /// Whether the workspace declares a type of this Rust name, inside the + /// lift or outside it: a name of the standard library that is not in + /// the prelude (`Rc`, `Range`) is the library's only where it does not. + fn declares(&self, rust: &str) -> bool { + let lex = self.resolve(rust); + self.enums.contains_key(&lex) + || self.structs.contains_key(&lex) + || self.datas.contains_key(&lex) + || self.outside.contains_key(&lex) + } + + /// The residue of a type the lift does not name, by its Rust name: the + /// chain down to its leaf where the workspace declares it, the name as + /// written otherwise. + pub(crate) fn unnamed(&self, rust: &str) -> Residue { + let chain = self.outside.get(&self.resolve(rust)); + Residue::Type(chain.cloned().unwrap_or_else(|| rust.to_string())) } pub(crate) fn ty(&self, t: &rs::RustType) -> Lift { @@ -815,78 +1185,125 @@ impl Types { } Ok(self.tuple(ts)) } - // `std::path::PathBuf`, written out. - rs::TypeKind::Path { qself: false, path } - if path.segments.len() == 3 - && path.segments[0].ident == "std" - && path.segments[1].ident == "path" - && matches!(path.segments[2].ident.as_str(), "Path" | "PathBuf") => - { - Ok(Ty::Path) + // A type of the standard library written by its full path + // (`std::collections::BTreeMap`): the library's, whatever + // the workspace declares under the name. + rs::TypeKind::Path { qself: false, path } if std_path(path) => { + match path.segments.last() { + Some(last) => self.named(t, last, true), + None => bad(), + } } rs::TypeKind::Path { qself: false, path } if path.segments.len() == 1 => { - let seg = &path.segments[0]; - let name = seg.ident.clone(); - let mut args = Vec::new(); - match &seg.arguments { - rs::PathArguments::None => {} - rs::PathArguments::AngleBracketed(a) => { - for arg in a { - match arg { - rs::GenericArgument::Type(t) => args.push(self.ty(t)?), - // A lifetime is erased. - rs::GenericArgument::Other(l) if l.starts_with('\'') => {} - rs::GenericArgument::Other(_) => return bad(), - } - } - } - rs::PathArguments::Parenthesized => return bad(), - } - let ty = match (name.as_str(), args.as_slice()) { - ("bool", []) => Ty::Bool, - ("u8", []) => Ty::Nat(Some(8)), - ("u16", []) => Ty::Nat(Some(16)), - ("u32", []) => Ty::Nat(Some(32)), - ("u64", []) => Ty::Nat(Some(64)), - ("u128", []) => Ty::Nat(Some(128)), - ("usize", []) => Ty::Nat(None), - ("i8", []) => Ty::Int(8), - ("i16", []) => Ty::Int(16), - ("i32", []) => Ty::Int(32), - ("i64", []) => Ty::Int(64), - ("String", []) => Ty::Str, - ("char", []) => Ty::Char, - ("Option", [t]) => Ty::Option(Box::new(t.clone())), - ("Result", [t, e]) => Ty::Outcome(Box::new(t.clone()), Box::new(e.clone())), - ("Vec", [t]) => Ty::List(Box::new(t.clone())), - ("Box", [t]) => t.clone(), - ("BTreeMap", [k, v]) => Ty::Map(Box::new(k.clone()), Box::new(v.clone()), true), - ("HashMap", [k, v]) => Ty::Map(Box::new(k.clone()), Box::new(v.clone()), false), - ("BTreeSet", [t]) => Ty::Set(Box::new(t.clone()), true), - ("HashSet", [t]) => Ty::Set(Box::new(t.clone()), false), - (n, []) - if self.enums.contains_key(&self.resolve(n)) - || self.structs.contains_key(&self.resolve(n)) - || self.datas.contains_key(&self.resolve(n)) => - { - Ty::Named(self.resolve(n)) - } - // The standard path, where the crate declares no type - // of the name. - ("Path" | "PathBuf", []) => Ty::Path, - _ => return bad(), - }; - Ok(ty) + self.named(t, &path.segments[0], false) } _ => bad(), } } - /// The LexLean signature of a candidate, or why it is not one. + /// The type one path segment names, with its arguments: a type of the + /// standard library the lift reads, or one of the workspace. `library` + /// is a segment reached by the library's own full path. + fn named(&self, t: &rs::RustType, seg: &rs::PathSegment, library: bool) -> Lift { + let bad = || Err(Residue::Type(t.text.clone())); + let name = seg.ident.clone(); + // The type arguments as written, a lifetime erased. + let mut written = Vec::new(); + match &seg.arguments { + rs::PathArguments::None => {} + rs::PathArguments::AngleBracketed(a) => { + for arg in a { + match arg { + rs::GenericArgument::Type(t) => written.push(t), + rs::GenericArgument::Other(l) if is_lifetime(l) => {} + rs::GenericArgument::Other(_) => return bad(), + } + } + } + rs::PathArguments::Parenthesized => return bad(), + } + // A name of the library outside the prelude (`Rc`, `Range`) is the + // library's where its full path says so, or where the workspace + // declares no type of the name. + let imported = library || !self.declares(&name); + // The head is read before its arguments: a head the lift does not + // read is the leaf whatever it holds (`RefCell` is outside for + // every `T`), and only a head it reads passes the question on to + // what it holds. + let arg = |i: usize| self.ty(written[i]).map(Box::new); + let ty = match (name.as_str(), written.len()) { + ("bool", 0) => Ty::Bool, + ("u8", 0) => Ty::Nat(Some(8)), + ("u16", 0) => Ty::Nat(Some(16)), + ("u32", 0) => Ty::Nat(Some(32)), + ("u64", 0) => Ty::Nat(Some(64)), + ("u128", 0) => Ty::Nat(Some(128)), + ("usize", 0) => Ty::Nat(None), + ("i8", 0) => Ty::Int(8), + ("i16", 0) => Ty::Int(16), + ("i32", 0) => Ty::Int(32), + ("i64", 0) => Ty::Int(64), + ("i128", 0) => Ty::Integer(Some(128)), + ("isize", 0) => Ty::Integer(None), + ("String", 0) => Ty::Str, + ("char", 0) => Ty::Char, + ("Option", 1) => Ty::Option(arg(0)?), + ("Result", 2) => Ty::Outcome(arg(0)?, arg(1)?), + ("Vec", 1) => Ty::List(arg(0)?), + // An owning pointer reads as what it owns. `Rc` and `Arc` + // share that ownership, and through either a function reaches + // only `&T`: what it reads is the content, the same from every + // owner for as long as any holds it, so a pure function of the + // pointer is a function of the content. What tells two owners + // of equal content apart (`ptr_eq`, the counts, `Weak`) is no + // operation the lift reads. A cell that changes behind a + // shared borrow (`RefCell`, `Cell`, `Mutex`, `RwLock`, an + // atomic) is not read: it stays outside, the leaf of every + // chain through it. + ("Box", 1) => *arg(0)?, + ("Rc" | "Arc", 1) if imported => *arg(0)?, + ("BTreeMap", 2) => Ty::Map(arg(0)?, arg(1)?, true), + ("HashMap", 2) => Ty::Map(arg(0)?, arg(1)?, false), + ("BTreeSet", 1) => Ty::Set(arg(0)?, true), + ("HashSet", 1) => Ty::Set(arg(0)?, false), + // A double-ended queue is the sequence of its items, front to + // back, as a vector is. + ("VecDeque", 1) if imported => Ty::List(arg(0)?), + // `a..b` as a value: the struct of its two bounds, which the + // language declares with both public. + ("Range", 1) if imported => { + let bound = *arg(0)?; + self.tuple(vec![bound.clone(), bound]) + } + (n, 0) + if !library + && (self.enums.contains_key(&self.resolve(n)) + || self.structs.contains_key(&self.resolve(n)) + || self.datas.contains_key(&self.resolve(n))) => + { + Ty::Named(self.resolve(n)) + } + // The standard path, where the crate declares no type of the + // name. + ("Path" | "PathBuf", 0) => Ty::Path, + // A type of the workspace outside the lift: the chain down to + // its leaf. Any other name is itself the leaf. + (n, _) => { + return match self.outside.get(&self.resolve(n)).filter(|_| !library) { + Some(chain) => Err(Residue::Type(chain.clone())), + None => bad(), + } + } + }; + Ok(ty) + } + + /// The LexLean signature of a candidate, or why it is not one. `owner` + /// says what its `self` and `Self` name, where it is a method. pub(crate) fn signature( &self, sig: &rs::Signature, - owner: Option<&str>, + owner: Option<&Owner<'_>>, ) -> Lift<(Vec, Ty)> { // A lifetime parameter says how long a borrow lives, which a value // of LexLean does not have: it is erased. A type or const parameter @@ -900,36 +1317,59 @@ impl Types { "generic, async, unsafe or variadic".to_string(), )); } + // The type `Self` names: none in a default method, where it is each + // implementing type. + let named = match owner { + Some(Owner::Type { name, .. }) => Some(*name), + Some(Owner::Implementor) | None => None, + }; let mut params = Vec::new(); for input in &sig.inputs { match input { rs::FnArg::Receiver { plain } => match owner { - Some(o) - if *plain - && (self.enums.contains_key(o) - || self.structs.contains_key(o) - || self.datas.contains_key(o)) => + // A default method that lifts reads nothing of `self`, + // which is each implementing type's value: the + // definition does not take it. + Some(Owner::Implementor) => {} + Some(Owner::Type { name, receiver }) + if self.enums.contains_key(*name) + || self.structs.contains_key(*name) + || self.datas.contains_key(*name) => { + if !*plain { + return Err(Residue::Signature(format!( + "takes {} of {name}: the lift reads self and &self as the \ + value, and threads no other receiver", + receiver.unwrap_or("self") + ))); + } params.push(( "self".to_string(), local_name("self"), - Ty::Named(o.to_string()), + Ty::Named((*name).to_string()), )); } - _ => return Err(Residue::Signature("takes self".to_string())), + Some(Owner::Type { name, .. }) => { + return Err(Residue::Signature(format!( + "takes self of {name}, a type outside the lift" + ))); + } + None => { + return Err(Residue::Signature("takes self outside a type".to_string())); + } }, rs::FnArg::Typed(pat) => { let rs::Pat::Ident(name) = &*pat.pat else { return Err(Residue::Signature("pattern parameter".to_string())); }; let rust = name.ident.clone(); - params.push((rust.clone(), local_name(&rust), self.ty_in(&pat.ty, owner)?)); + params.push((rust.clone(), local_name(&rust), self.ty_in(&pat.ty, named)?)); } } } let result = match &sig.output { None => Ty::Unit, - Some(t) => self.ty_in(t, owner)?, + Some(t) => self.ty_in(t, named)?, }; Ok((params, result)) } @@ -1106,6 +1546,20 @@ pub(crate) fn local_name(ident: &str) -> String { /// A parameter: its Rust name, its LexLean name and its type. pub(crate) type Param = (String, String, Ty); +/// What `self` and `Self` name in a method's signature. +#[derive(Clone, Copy, Debug)] +pub(crate) enum Owner<'a> { + /// The type the method is of, by its LexLean name, and the receiver as + /// the method writes it (`&mut self`), where it takes one. + Type { + name: &'a str, + receiver: Option<&'a str>, + }, + /// Each type that implements the trait: a default method the trait + /// declares. + Implementor, +} + /// A lifted function's signature. #[derive(Clone, Debug)] pub(crate) struct Sig { @@ -1750,8 +2204,10 @@ fn literal_of(lit: &rs::Lit, want: Option<&Ty>, negative: bool) -> Lift<(Expr, T "i16" => Ty::Int(16), "i32" => Ty::Int(32), "i64" => Ty::Int(64), + "i128" => Ty::Integer(Some(128)), + "isize" => Ty::Integer(None), "" => match want { - Some(t @ (Ty::Nat(_) | Ty::Int(_))) => t.clone(), + Some(t @ (Ty::Nat(_) | Ty::Int(_) | Ty::Integer(_))) => t.clone(), _ if negative => Ty::Int(32), _ => Ty::Nat(Some(32)), }, @@ -1762,6 +2218,12 @@ fn literal_of(lit: &rs::Lit, want: Option<&Ty>, negative: bool) -> Lift<(Expr, T let sign = if negative { "-" } else { "" }; flat(format!("({sign}{v} : Int64)"), ty) } + // The widest signed type bounds the literal Rust accepts; + // the mathematical `Int` holds every one of them. + Ty::Integer(_) if v <= i128::MAX as u128 + u128::from(negative) => { + let sign = if negative { "-" } else { "" }; + flat(format!("({sign}{v} : Int)"), ty) + } Ty::Nat(_) if !negative => flat(v.to_string(), ty), _ => Err(Residue::Form("integer literal".to_string())), } @@ -1776,11 +2238,11 @@ fn literal_of(lit: &rs::Lit, want: Option<&Ty>, negative: bool) -> Lift<(Expr, T }, rs::Lit::Byte(b) if !negative => flat(b.to_string(), Ty::Nat(Some(8))), rs::Lit::ByteStr(b) if !negative => { - let mut list = "(nil Nat)".to_string(); - for byte in b.iter().rev() { - list = format!("(cons {byte} {list})"); - } - flat(list, Ty::List(Box::new(Ty::Nat(Some(8))))) + let bytes: Vec = b.iter().map(u8::to_string).collect(); + flat( + crate::embed::term_list(&bytes, "Nat"), + Ty::List(Box::new(Ty::Nat(Some(8)))), + ) } _ => Err(Residue::Form("literal".to_string())), } @@ -1788,6 +2250,16 @@ fn literal_of(lit: &rs::Lit, want: Option<&Ty>, negative: bool) -> Lift<(Expr, T fn ctor(path: &rs::Path, types: &Types) -> Option<(String, String)> { let n = path.segments.len(); + // `S` of `struct S;`: the one value of its type. No variant of an + // enum lifts under the constructor's name, so the name alone tells. + if n == 1 { + let owner = types.resolve(&path.segments[0].ident); + let sole = types + .enums + .get(&owner) + .is_some_and(|vs| vs.len() == 1 && vs.iter().all(|v| v == SOLE)); + return sole.then(|| (owner, SOLE.to_string())); + } if n < 2 { return None; } @@ -2158,8 +2630,12 @@ fn match_value( fn field_value(f: &rs::ExprField, env: &Env, ctx: &Ctx, acc: Acc) -> Lift<((Expr, Ty), Acc)> { let ((base, bt), acc) = flat_of(&f.base, env, ctx, acc, None)?; match (&f.member, &bt) { - (rs::Member::Named(field), Ty::Named(s)) => { - let name = local_name(field); + (member, Ty::Named(s)) => { + // A tuple struct's field is named by its position. + let name = match member { + rs::Member::Named(field) => local_name(field), + rs::Member::Unnamed(position) => field_name(&position.to_string()), + }; let Some((_, ty)) = env .types .structs @@ -2348,6 +2824,8 @@ fn cast_value(c: &rs::ExprCast, env: &Env, ctx: &Ctx, acc: Acc) -> Lift<((Expr, }; // `usize` is as wide as the narrowest declared target's pointer. let narrowest = env.widths.first().map(|(w, _)| *w); + // `isize` is at most as wide as the widest one's. + let widest = env.widths.last().map(|(w, _)| *w); match (&vt, &target) { (Ty::Nat(Some(a)), Ty::Nat(Some(b))) if a <= b => flat_lift(v, target, acc), (Ty::Nat(Some(a)), Ty::Nat(None)) if narrowest.is_some_and(|w| *a <= w) => { @@ -2361,6 +2839,21 @@ fn cast_value(c: &rs::ExprCast, env: &Env, ctx: &Ctx, acc: Acc) -> Lift<((Expr, acc, ), (Ty::Int(a), Ty::Int(b)) if a <= b => flat_lift(v, target, acc), + // A signed value widens to `i128` as itself; to `isize` where the + // narrowest declared pointer holds its type, as `usize` does. + (Ty::Int(a), Ty::Integer(wide)) + if wide.map_or(narrowest, Some).is_some_and(|w| *a <= w) => + { + // The conversion of a fixed width to `Int` elaborates through + // these two. + let acc = acc.axiom("Quot.sound").axiom("propext"); + flat_lift(format!("(prim to_int {v} : Int)"), target, acc) + } + (Ty::Integer(a), Ty::Integer(b)) + if a == b || matches!((a.map_or(widest, Some), b), (Some(w), Some(b)) if w <= *b) => + { + flat_lift(v, target, acc) + } (Ty::Nat(_), Ty::Int(_)) => Err(Residue::Form( "a cast from an unsigned to a signed integer, where LexLean binds no \ conversion from Nat to Int64" @@ -2458,10 +2951,9 @@ fn list_of( "an empty list of an unknown type".to_string(), )); }; - let mut list = format!("(nil {})", elem.render()); - for part in parts.iter().rev() { - list = format!("(cons {part} {list})"); - } + // A literal can be as long as its author likes, and the linker reads a + // term to a bounded depth: the list is written as balanced halves. + let list = crate::embed::term_list(&parts, &elem.render()); Ok(((Expr::Flat(list), Ty::List(Box::new(elem))), acc)) } @@ -2616,10 +3108,7 @@ fn format_macro(mac: &rs::ExprMacro, env: &Env, ctx: &Ctx, acc: Acc) -> Lift<((E } // Joining strings elaborates through propositional extensionality. let acc = acc.axiom("propext"); - let mut list = "(nil String)".to_string(); - for piece in pieces.iter().rev() { - list = format!("(cons {piece} {list})"); - } + let list = crate::embed::term_list(&pieces, "String"); Ok(( ( Expr::Flat(format!("(prim join {list} \"\" : String)")), @@ -2662,6 +3151,21 @@ fn comparison(b: &rs::ExprBinary, env: &Env, ctx: &Ctx, acc: Acc) -> Lift<((Expr (Ty::Int(_) | Ty::Str | Ty::Char, B::Ne) => { (format!("(not (prim equal {l} {r} : Bool))"), acc) } + // The mathematical `Int` has an order and no `equal`: two values + // are the same where neither is below the other. + (Ty::Integer(_), _) => { + let acc = acc.axiom("propext"); + let below = |x: &str, y: &str| format!("(prim less_than {x} {y} : Bool)"); + let text = match b.op { + B::Lt => below(&l, &r), + B::Gt => below(&r, &l), + B::Le => format!("(not {})", below(&r, &l)), + B::Ge => format!("(not {})", below(&l, &r)), + B::Eq => format!("(not ({} || {}))", below(&l, &r), below(&r, &l)), + _ => format!("({} || {})", below(&l, &r), below(&r, &l)), + }; + (text, acc) + } // Strings order by their scalar values, as Rust's `str` and // `char` do. (Ty::Int(_) | Ty::Str | Ty::Char, B::Lt | B::Gt | B::Le | B::Ge) => { @@ -2980,9 +3484,63 @@ fn call( if let Some((owner, variant, fields)) = data_variant(p, &env.types) { return variant_call(c, owner, &variant, fields, env, ctx, acc); } + if let Some((name, fields)) = tuple_struct(p, c.args.len(), env, ctx) { + return tuple_struct_value(c, &name, fields, env, ctx, acc); + } path_call(c, p, env, ctx, acc, want) } +/// The tuple struct a call's path names, `S(a, b)` or `Self(a, b)`, with +/// its fields: a struct of as many fields as the call has arguments, each +/// named by its position. Rust reads the name as the struct's constructor +/// before any function, since both live in the one value namespace. +fn tuple_struct<'e>( + p: &rs::Path, + arity: usize, + env: &'e Env, + ctx: &Ctx, +) -> Option<(String, &'e [(String, Ty)])> { + let written = p.get_ident()?; + let owner = ctx.current.split_once("::").map(|(o, _)| o); + let name = match (written.as_str(), owner) { + ("Self", Some(o)) => env.types.resolve(o), + _ => env.types.resolve(written), + }; + let fields = env.types.structs.get(&name)?; + let positional = fields + .iter() + .enumerate() + .all(|(i, (f, _))| *f == field_name(&format!("{i}"))); + (positional && fields.len() == arity).then_some((name, fields.as_slice())) +} + +/// `S(a, b)`: a value of a tuple struct, its fields in order. +fn tuple_struct_value( + c: &rs::ExprCall, + name: &str, + fields: &[(String, Ty)], + env: &Env, + ctx: &Ctx, + acc: Acc, +) -> Lift<((Expr, Ty), Acc)> { + let mut acc = acc; + let mut values = Vec::new(); + for (arg, (_, ty)) in c.args.iter().zip(fields) { + let ((v, vt), next) = flat_of(arg, env, ctx, acc, Some(ty))?; + if !vt.same(ty) { + return Err(Residue::Form(format!("{name} of another type"))); + } + acc = next; + values.push(v); + } + let parts: Vec<(&String, String)> = fields.iter().map(|(f, _)| f).zip(values).collect(); + flat_lift( + struct_value(name, &parts, &env.types), + Ty::Named(name.to_string()), + acc, + ) +} + /// `f(x)` of a function parameter `f`: its application. fn applied_param( c: &rs::ExprCall, @@ -3187,10 +3745,20 @@ fn std_call( let (path, acc) = acc.prelude("pathOf", &[&v]); flat_some(path, Ty::Path, acc) } - ([s, n], [a], _) if s == "Box" && n == "new" => { + // An owning pointer is what it owns (see `Types::ty`): building one + // is its content, and so is another owner of the same content. + ([s, n], [a], _) + if matches!(s.as_str(), "Box" | "Rc" | "Arc") && matches!(n.as_str(), "new") => + { let ((v, vt), acc) = flat_of(a, env, ctx, acc, want)?; flat_some(v, vt, acc) } + ([s, n], [rs::RustExpr::Reference(a)], _) + if matches!(s.as_str(), "Rc" | "Arc") && n == "clone" && !a.mutable => + { + let ((v, vt), acc) = flat_of(&a.expr, env, ctx, acc, want)?; + flat_some(v, vt, acc) + } ([s, n], [a], _) if s == "String" && n == "from" => { let ((v, vt), acc) = flat_of(a, env, ctx, acc, Some(&Ty::Str))?; if vt == Ty::Str { @@ -4000,6 +4568,10 @@ fn method_typed( (Ty::Int(_), "min" | "max") => { method_int_min(name, r, rt, args, env, ctx, acc) } + ( + Ty::Integer(bits), + "checked_add" | "checked_sub" | "checked_mul" | "checked_div" | "checked_neg", + ) => method_integer_checked(bits, name, r, rt, args, env, ctx, acc), (Ty::List(_), "len") if args.is_empty() => { method_list_len(r, acc) } @@ -4349,6 +4921,72 @@ fn method_int_checked_neg( ) } +/// A checked operation on a receiver of type `Integer`: the mathematical +/// result where the type's width holds it. `i128` holds `-2^127` to +/// `2^127 - 1`; what `isize` holds is its target's, so the operation is +/// residue there, as it is on `usize`. +#[allow(clippy::too_many_arguments)] +fn method_integer_checked( + bits: &Option, + name: &str, + r: &str, + rt: &Ty, + args: &[&rs::RustExpr], + env: &Env, + ctx: &Ctx, + acc: Acc, +) -> Lift<((Expr, Ty), Acc)> { + let Some(bits) = bits else { + return Err(Residue::Width(format!(".{name} on isize"))); + }; + let half = 1u128 << (bits - 1); + let lowest = format!("(-{half} : Int)"); + let highest = format!("({} : Int)", half - 1); + let below = |x: &str, y: &str| format!("(prim less_than {x} {y} : Bool)"); + let none = "(ctor Option.none [Int])"; + let acc = acc.axiom("propext"); + let (value, zero, acc) = if name == "checked_neg" { + if !args.is_empty() { + return Err(Residue::Form(format!("method call .{name}"))); + } + (format!("(prim negate {r} : Int)"), None, acc) + } else { + let (a, acc) = one_arg(args, name, env, ctx, rt, acc)?; + match name { + // LexLean adds no two of `Int`: a sum is the difference from + // the negation. + "checked_add" => ( + format!("(prim subtract {r} (prim negate {a} : Int) : Int)"), + None, + acc, + ), + "checked_sub" => (format!("(prim subtract {r} {a} : Int)"), None, acc), + "checked_mul" => (format!("(prim multiply {r} {a} : Int)"), None, acc), + // `Int`'s quotient truncates toward zero, as Rust's does; a + // zero divisor has no quotient. + _ => { + let zero = "(0 : Int)"; + let is_zero = format!("(not ({} || {}))", below(&a, zero), below(zero, &a)); + ( + format!("(prim quotient {r} {a} {zero} : Int)"), + Some(is_zero), + acc, + ) + } + } + }; + let (held, acc) = ctx.fresh(env, acc, "wide"); + let out_of_range = format!("({} || {})", below(&held, &lowest), below(&highest, &held)); + let checked = format!( + "(let {held} : Int := {value}; (if {out_of_range} then {none} else (ctor Option.some [Int] {held})))" + ); + let text = match zero { + Some(is_zero) => format!("(if {is_zero} then {none} else {checked})"), + None => checked, + }; + flat_lift(text, opt_of(rt), acc) +} + /// `.min` on a receiver of type `Int`. fn method_int_min( name: &str, @@ -4688,6 +5326,7 @@ fn default_in(ty: &Ty, types: &Types, depth: usize) -> Option { Ty::Bool => "false".into(), Ty::Nat(_) | Ty::Float(_) | Ty::Signed(_) | Ty::Scalar => "0".into(), Ty::Int(_) => "(0 : Int64)".into(), + Ty::Integer(_) => "(0 : Int)".into(), Ty::Str | Ty::Char => "\"\"".into(), Ty::ParseError => format!("(ctor {PRELUDE}::ParseIntError.InvalidDigit)"), Ty::Option(t) => format!("(ctor Option.none [{}])", t.render()), @@ -6952,7 +7591,13 @@ fn matched_row( return Err(Residue::Form("non-boolean guard".to_string())); } let ((then, tt), acc) = expr(e, env, &scope, acc, want)?; - let ((other, ot), acc) = compile(m.cols, m.rest, env, ctx, acc, Some(want.unwrap_or(&tt)))?; + // The rows after it are written inside this row's binders, which wrap + // the whole conditional: none of them may name one of these again. + let mut after = ctx.clone(); + after + .hidden + .extend(lets.iter().map(|(name, _, _)| name.clone())); + let ((other, ot), acc) = compile(m.cols, m.rest, env, &after, acc, Some(want.unwrap_or(&tt)))?; if !tt.same(&ot) { return Err(Residue::Form("arms of different types".to_string())); } @@ -11190,11 +11835,85 @@ mod tests { ) .expect("lifts"); assert!( - out.contains("(prim join (cons m (cons \"::\" (cons n (nil String)))) \"\" : String)"), + out.contains("(prim join (prim append (cons m (nil String)) (cons \"::\" (cons n (nil String))) : (List String)) \"\" : String)"), "{out}" ); } + #[test] + fn a_long_literal_is_balanced_halves() { + // The linker reads a term to a bounded depth, and a literal is as + // long as its author likes: no list nests one cell per element. + let items: Vec = (0..300).map(|i| (i % 250).to_string()).collect(); + let array = lift( + &format!("fn table() -> [u8; 300] {{ [{}] }}", items.join(", ")), + &plain(), + ) + .expect("lifts"); + let bytes = lift( + &format!("fn text() -> &'static [u8] {{ b\"{}\" }}", "ab".repeat(150)), + &plain(), + ) + .expect("lifts"); + let pieces = lift( + &format!( + "fn row(m: &str) -> String {{ format!(\"{}\") }}", + "{m}, ".repeat(150) + ), + &plain(), + ) + .expect("lifts"); + for out in [array, bytes, pieces] { + assert!(out.contains("(prim append "), "{out}"); + let mut depth = 0usize; + let mut deepest = 0usize; + for c in out.chars() { + match c { + '(' => { + depth += 1; + deepest = deepest.max(depth); + } + ')' => depth -= 1, + _ => {} + } + } + assert!(deepest < 40, "nests {deepest} deep"); + } + } + + #[test] + fn a_guarded_row_and_the_rows_after_it_bind_distinct_names() { + // The guarded row's binders wrap the whole conditional, so the row + // after it, which binds the same Rust name to another part, is + // written inside them: a binder there of the same name shadows. + let out = lift( + "fn k(p: (u8, u8)) -> u8 { match p { (0, d) | (d, 0) if d > 5 => d, (1, d) if d > 7 => d, _ => 2 } }", + &plain(), + ) + .expect("lifts"); + let lets: Vec = out.match_indices("(let ").map(|(at, _)| at).collect(); + assert!(lets.len() >= 2, "{out}"); + for at in lets { + let name = out[at + 5..].split_whitespace().next().expect("a binder"); + let mut depth = 0usize; + let end = out[at..] + .char_indices() + .find_map(|(i, c)| { + match c { + '(' => depth += 1, + ')' => depth -= 1, + _ => {} + } + (depth == 0).then_some(at + i) + }) + .expect("a closed binder"); + assert!( + !out[at + 5..end].contains(&format!("(let {name} ")), + "{name} is bound again inside its own scope: {out}" + ); + } + } + #[test] fn a_match_on_a_state_enum_lifts_exhaustively() { let mut types = plain(); @@ -11374,4 +12093,596 @@ mod tests { assert!(out.contains("(prim index xs 2 : (Option Nat))"), "{out}"); assert!(out.contains("Option.none => 0"), "{out}"); } + + // Types outside the lift. + + /// The types of one library source, registered as the projection + /// registers them: every enum and struct of the file, by its own name. + fn types_of(src: &str) -> Types { + let (file, syntax) = crate::ingest::read_text(src); + let mut enums = BTreeMap::new(); + let mut datas = BTreeMap::new(); + for (e, payload) in file.enums.iter().zip(&syntax.enums) { + if e.variants.iter().all(|v| v.unit) { + let variants = e.variants.iter().map(|v| v.name.clone()).collect(); + enums.insert(e.name.clone(), variants); + } else { + datas.insert(e.name.clone(), payload.clone()); + } + } + let structs = file + .structs + .iter() + .map(|s| s.name.clone()) + .zip(syntax.structs.iter().cloned()) + .collect(); + Types::with_data(enums, &datas, &structs, BTreeMap::new()) + } + + /// A struct's fields, as the lift names and reads them. + fn fields(types: &Types, name: &str) -> Vec<(String, Ty)> { + types.structs.get(name).cloned().unwrap_or_default() + } + + fn field(name: &str, ty: Ty) -> (String, Ty) { + (name.to_string(), ty) + } + + #[test] + fn a_type_outside_the_lift_names_the_chain_to_its_leaf() { + let types = types_of( + "struct Leaf { x: f64 } struct Mid { n: u32, leaf: Leaf, other: f32 } \ + struct Top { mids: Vec> }", + ); + // Through the containers the lift reads, down to the first field + // in declaration order that is outside. + assert_eq!( + lift("fn through(t: &Top) -> bool { true }", &types), + Err(Residue::Type("Top.mids: Mid.leaf: Leaf.x: f64".to_string())) + ); + // The owner of a method is named the same way; a name the + // workspace does not declare is its own leaf. + assert_eq!( + types.unnamed("Mid"), + Residue::Type("Mid.leaf: Leaf.x: f64".to_string()) + ); + assert_eq!( + types.unnamed("Elsewhere"), + Residue::Type("Elsewhere".to_string()) + ); + assert_eq!( + types.unnamed("Mid").detail(), + "type outside the lift: Mid.leaf: Leaf.x: f64" + ); + } + + #[test] + fn a_chain_never_leads_back_into_the_type_it_explains() { + // `A` holds `B` first, and `B` is outside only because it holds + // `A`: the chain of `A` names what kept `A` out on its own. + let types = types_of("struct A { b: Vec, x: f64 } struct B { a: Option }"); + assert_eq!(types.outside["A"], "A.x: f64"); + assert_eq!(types.outside["B"], "B.a: A.x: f64"); + // Each of two types outside on its own account names the other + // first, as declared, and then what keeps that one out. + let types = types_of("struct T { u: Vec, x: f64 } struct U { t: Box, y: f32 }"); + assert_eq!(types.outside["T"], "T.u: U.y: f32"); + assert_eq!(types.outside["U"], "U.t: T.x: f64"); + } + + #[test] + fn an_enum_names_the_variant_and_the_field_of_its_leaf() { + let types = types_of( + "enum Reading { Count(u32), Pair(u8, f64), Level { level: f64 } } \ + enum Tree { Leaf, Node(BTreeMap) } \ + struct Parent { kids: BTreeSet } struct Child { parent: Vec }", + ); + assert_eq!(types.outside["Reading"], "Reading::Pair.1: f64"); + assert_eq!( + types.outside["Tree"], + format!("Tree::Node.0: BTreeMap: {NOT_NESTED}") + ); + // A family that names itself where Lean nests no inductive: the + // member that holds the occurrence states it, the other names it. + let held = format!("Parent.kids: BTreeSet: {NOT_NESTED}"); + assert_eq!(types.outside["Parent"], held); + assert_eq!( + types.outside["Child"], + format!("Child: in one recursive family with {held}") + ); + } + + // Functions refused by their signature: what `self` and `Self` name in + // a method's signature, by the type that owns the method. + + fn method_signature( + src: &str, + owner: Option<&Owner<'_>>, + types: &Types, + ) -> Lift<(Vec, Ty)> { + let f: syn::ImplItemFn = syn::parse_str(src).expect("parses"); + types.signature(&crate::convert::signature(&f.sig), owner) + } + + fn with_square() -> Types { + let mut types = Types::default(); + types.structs.insert("Square".to_string(), Vec::new()); + types + } + + #[test] + fn a_method_takes_the_value_of_its_type_first() { + let types = with_square(); + for (src, receiver) in [ + ("fn area(&self, by: bool) -> bool { by }", "&self"), + ("fn area(self, by: bool) -> bool { by }", "self"), + ] { + let owner = Owner::Type { + name: "Square", + receiver: Some(receiver), + }; + let (params, result) = method_signature(src, Some(&owner), &types).expect("lifts"); + assert_eq!(params.len(), 2, "{src}"); + assert_eq!( + params[0], + ( + "self".to_string(), + local_name("self"), + Ty::Named("Square".to_string()) + ) + ); + assert_eq!(result, Ty::Bool); + } + // `Self` is the type the method is of. + let owner = Owner::Type { + name: "Square", + receiver: None, + }; + let (params, result) = method_signature( + "fn same(other: Self) -> Self { other }", + Some(&owner), + &types, + ) + .expect("lifts"); + assert_eq!(params[0].2, Ty::Named("Square".to_string())); + assert_eq!(result, Ty::Named("Square".to_string())); + } + + #[test] + fn a_receiver_the_lift_does_not_thread_is_named_with_its_type() { + let types = with_square(); + for receiver in ["&mut self", "mut self"] { + let owner = Owner::Type { + name: "Square", + receiver: Some(receiver), + }; + let src = format!("fn grow({receiver}, by: bool) {{}}"); + assert_eq!( + method_signature(&src, Some(&owner), &types).err(), + Some(Residue::Signature(format!( + "takes {receiver} of Square: the lift reads self and &self as the value, \ + and threads no other receiver" + ))) + ); + } + // A type the scope does not name, and a receiver outside any type. + let owner = Owner::Type { + name: "Circle", + receiver: Some("&self"), + }; + assert_eq!( + method_signature("fn area(&self) -> bool { true }", Some(&owner), &types).err(), + Some(Residue::Signature( + "takes self of Circle, a type outside the lift".to_string() + )) + ); + assert_eq!( + method_signature("fn area(&self) -> bool { true }", None, &types).err(), + Some(Residue::Signature("takes self outside a type".to_string())) + ); + } + + #[test] + fn shared_ownership_reads_as_its_content() { + let types = types_of( + "struct Shared { inner: Arc, name: Rc, deep: Arc>> } \ + struct Cellular { inner: Rc> } struct Counted { hits: Cell } \ + struct Locked { state: Arc>> }", + ); + assert_eq!( + fields(&types, "Shared"), + [ + field("inner", Ty::Nat(Some(32))), + field("name", Ty::Str), + field("deep", Ty::List(Box::new(Ty::Nat(Some(8))))), + ] + ); + // A cell that changes behind a shared borrow is the leaf, whatever + // shares it and whatever it holds. + assert_eq!(types.outside["Cellular"], "Cellular.inner: RefCell"); + assert_eq!(types.outside["Counted"], "Counted.hits: Cell"); + assert_eq!(types.outside["Locked"], "Locked.state: Mutex>"); + // Another owner, and a new one, are the content. + let out = lift( + "fn again(s: &Shared) -> Arc { Arc::clone(&s.inner) }", + &types, + ) + .expect("lifts"); + assert!(out.contains("body: (project s inner)"), "{out}"); + let out = lift("fn build(n: u32) -> Rc { Rc::new(n) }", &types).expect("lifts"); + assert!(out.contains("result: Nat, body: n"), "{out}"); + // A type the workspace declares under the name is not the + // library's pointer. + let own = types_of("struct Rc { value: T } struct Holder { inner: Rc }"); + assert_eq!( + own.outside["Holder"], + format!("Holder.inner: Rc: {PARAMETRIC_STRUCT}") + ); + } + + #[test] + fn the_wide_signed_integers_lift_as_the_mathematical_int() { + let types = types_of("struct Wide { n: i128, offset: isize }"); + assert_eq!( + fields(&types, "Wide"), + [ + field("n", Ty::Integer(Some(128))), + field("offset", Ty::Integer(None)), + ] + ); + let out = lift( + "fn below(a: i128, b: isize) -> bool { a < 0 || b >= 1 }", + &types, + ) + .expect("lifts"); + assert!(out.contains("parameters: [a : Int, b : Int]"), "{out}"); + assert!(out.contains("(prim less_than a (0 : Int) : Bool)"), "{out}"); + assert!( + out.contains("(not (prim less_than b (1 : Int) : Bool))"), + "{out}" + ); + // `Int` has no `equal`: neither value is below the other. + let out = lift("fn same(a: i128) -> bool { a == -1 }", &types).expect("lifts"); + assert!( + out.contains("(not ((prim less_than a (-1 : Int) : Bool) || (prim less_than (-1 : Int) a : Bool)))"), + "{out}" + ); + // A checked operation is the mathematical one where 128 bits hold + // its result. + let out = lift( + "fn sum(a: i128, b: i128) -> Option { a.checked_add(b) }", + &types, + ) + .expect("lifts"); + assert!( + out.contains("(prim subtract a (prim negate b : Int) : Int)"), + "{out}" + ); + assert!(out.contains(&format!("(-{} : Int)", 1u128 << 127)), "{out}"); + assert!(out.contains(&format!("({} : Int)", i128::MAX)), "{out}"); + let out = lift( + "fn quotient(a: i128, b: i128) -> Option { a.checked_div(b) }", + &types, + ) + .expect("lifts"); + assert!(out.contains("(prim quotient a b (0 : Int) : Int)"), "{out}"); + // The width of `isize` is the target's, as `usize`'s is. + assert_eq!( + lift( + "fn sum(a: isize, b: isize) -> Option { a.checked_add(b) }", + &types + ), + Err(Residue::Width(".checked_add on isize".to_string())) + ); + // A signed value widens as itself: to `i128` always, to `isize` + // where the narrowest declared pointer holds it. + let out = lift("fn widen(a: i64) -> i128 { a as i128 }", &types).expect("lifts"); + assert!(out.contains("(prim to_int a : Int)"), "{out}"); + let out = lift("fn widen(a: i8) -> isize { a as isize }", &types).expect("lifts"); + assert!(out.contains("(prim to_int a : Int)"), "{out}"); + let narrowing = Err(Residue::Form("narrowing or sign-changing cast".to_string())); + assert_eq!( + lift("fn widen(a: i32) -> isize { a as isize }", &types), + narrowing + ); + assert_eq!( + lift("fn narrow(a: i128) -> i64 { a as i64 }", &types), + narrowing + ); + assert_eq!( + default_of(&Ty::Integer(None), &types), + Some("(0 : Int)".to_string()) + ); + } + + #[test] + fn every_struct_shape_is_a_type_or_names_its_leaf() { + let types = types_of( + "struct Marker; struct Empty {} struct Meters(u32); struct Pair(u32, f64); \ + struct Wrapper { value: T } struct Holder { m: Marker, w: Wrapper }", + ); + // A struct of no fields has one value: one constructor. + assert_eq!(types.enums["Marker"], [SOLE]); + assert_eq!(types.enums["Empty"], [SOLE]); + let out = lift("fn make() -> Marker { Marker }", &types).expect("lifts"); + assert!(out.contains("body: (ctor Marker.mk)"), "{out}"); + // A tuple struct's fields are named by position. + assert_eq!( + fields(&types, "Meters"), + [field("item0", Ty::Nat(Some(32)))] + ); + let out = lift("fn first(m: &Meters) -> u32 { m.0 }", &types).expect("lifts"); + assert!(out.contains("body: (project m item0)"), "{out}"); + let out = lift("fn make(n: u32) -> Meters { Meters(n) }", &types).expect("lifts"); + assert!(out.contains("body: (record Meters {item0 := n})"), "{out}"); + assert_eq!(types.outside["Pair"], "Pair.1: f64"); + // A struct with a type parameter is the leaf. + assert_eq!( + types.outside["Wrapper"], + format!("Wrapper: {PARAMETRIC_STRUCT}") + ); + assert_eq!( + types.outside["Holder"], + format!("Holder.w: Wrapper: {PARAMETRIC_STRUCT}") + ); + } + + #[test] + fn a_lifetime_is_erased_and_a_taken_name_is_named() { + let types = types_of("struct Reader<'a> { text: &'a str } struct Prop { weight: u8 }"); + // The owner of `impl<'a> Reader<'a>` is the struct. + assert!(types.structs.contains_key("Reader")); + assert_eq!(types.resolve("Reader<'a>"), "Reader"); + assert_eq!(types.resolve("Reader<'_, 'b>"), "Reader"); + // A type or const argument is not erased. + assert_eq!(types.resolve("Wrapper"), "Wrapper"); + assert_eq!(types.resolve("Letter<'a'>"), "Letter<'a'>"); + // A name LexLean writes for a type of its own does not lift as + // itself; the projection lifts it under its crate's name. + assert_eq!(types.outside["Prop"], format!("Prop: {TAKEN_NAME}")); + assert!(name_taken("Prop", true)); + assert!(name_taken("TupleNat", true)); + assert!(!name_taken("TupleNat", false)); + assert!(!name_taken("Reader", true)); + let (file, syntax) = crate::ingest::read_text("struct Prop { weight: u8 }"); + let structs = BTreeMap::from([("StageProp".to_string(), syntax.structs[0].clone())]); + let aliases = BTreeMap::from([(file.structs[0].name.clone(), "StageProp".to_string())]); + let named = Types::with_data(BTreeMap::new(), &BTreeMap::new(), &structs, aliases); + let out = lift("fn weight(p: &Prop) -> u8 { p.weight }", &named).expect("lifts"); + assert!(out.contains("parameters: [p : StageProp]"), "{out}"); + } + + #[test] + fn library_types_read_by_name_or_by_their_full_path() { + let types = types_of( + "struct Window { bounds: Range, queue: VecDeque, \ + index: std::collections::BTreeMap, text: std::string::String, \ + shared: alloc::sync::Arc>, at: std::path::PathBuf } \ + struct Borrowed { cell: std::cell::RefCell } struct Misplaced { rc: std::fmt::Rc }", + ); + let nat = |bits: u32| Box::new(Ty::Nat(Some(bits))); + assert_eq!( + fields(&types, "Window"), + [ + field("bounds", Ty::Tuple(vec![*nat(32), *nat(32)])), + field("queue", Ty::List(nat(8))), + field("index", Ty::Map(Box::new(Ty::Str), nat(32), true)), + field("text", Ty::Str), + field("shared", Ty::Option(nat(8))), + field("atValue", Ty::Path), + ] + ); + // A full path the lift does not read is the leaf, as written. + assert_eq!( + types.outside["Borrowed"], + "Borrowed.cell: std::cell::RefCell" + ); + assert_eq!(types.outside["Misplaced"], "Misplaced.rc: std::fmt::Rc"); + } + + #[test] + fn a_default_method_takes_no_value_of_an_implementing_type() { + let types = with_square(); + let (params, result) = method_signature( + "fn corners(&self, sharp: bool) -> bool { sharp }", + Some(&Owner::Implementor), + &types, + ) + .expect("lifts"); + assert_eq!( + params, + [("sharp".to_string(), local_name("sharp"), Ty::Bool)] + ); + assert_eq!(result, Ty::Bool); + // `Self` there is each implementing type: no one type. + assert!(method_signature( + "fn same(&self) -> Self { loop {} }", + Some(&Owner::Implementor), + &types + ) + .is_err()); + // And a method is generic as a function is. + assert_eq!( + method_signature( + "fn map(&self, t: T) -> T { t }", + Some(&Owner::Implementor), + &types + ) + .err(), + Some(Residue::Signature( + "generic, async, unsafe or variadic".to_string() + )) + ); + } + + // residue: the translator's own functions, rewritten inside the fragment + // the tool lifts from itself; each test pins what the old body did. + + fn residue_path(src: &str) -> rs::Path { + crate::convert::path(&syn::parse_str::(src).expect("parses")) + } + + fn residue_ty(src: &str) -> rs::RustType { + crate::convert::ty(&syn::parse_str::(src).expect("parses")) + } + + #[test] + fn residue_a_unit_value_is_named_by_its_type_or_its_variant() { + let types = types_of( + "struct Mark; enum Two { A, B } enum Only { One } \ + enum Mixed { Bare, Held(u8) } enum Never {}", + ); + let ctor_of = |src: &str| ctor(&residue_path(src), &types); + let named = |o: &str, v: &str| Some((o.to_string(), v.to_string())); + // A struct of no fields: its one value, under the name alone. + assert_eq!(ctor_of("Mark"), named("Mark", SOLE)); + // An enum's name alone is no value, whatever its variants. + assert_eq!(ctor_of("Two"), None); + assert_eq!(ctor_of("Only"), None); + assert_eq!(ctor_of("Mixed"), None); + // An enum of no variants has no value to name. + assert_eq!(ctor_of("Never"), None); + // A unit variant, by the last two segments. + assert_eq!(ctor_of("Two::A"), named("Two", "A")); + assert_eq!(ctor_of("crate::Two::B"), named("Two", "B")); + assert_eq!(ctor_of("Only::One"), named("Only", "One")); + assert_eq!(ctor_of("Mixed::Bare"), named("Mixed", "Bare")); + // A variant that carries data, or none of the enum's, is no unit. + assert_eq!(ctor_of("Mixed::Held"), None); + assert_eq!(ctor_of("Two::C"), None); + assert_eq!(ctor_of("Missing::A"), None); + assert_eq!(ctor_of("Missing"), None); + } + + #[test] + fn residue_a_library_path_is_plain_full_and_of_a_type_the_lift_reads() { + for full in [ + "std::collections::BTreeMap", + "core::option::Option", + "alloc::sync::Arc", + "std::vec::Vec", + "std::path::PathBuf", + // The last segment's arguments are the type's own. + "std::collections::HashMap", + ] { + assert!(std_path(&residue_path(full)), "{full}"); + } + for other in [ + "std::fmt::Rc", + "std::collections::Rc", + "mine::collections::BTreeMap", + "collections::BTreeMap", + "std::collections::btree_map::BTreeMap", + "BTreeMap", + ] { + assert!(!std_path(&residue_path(other)), "{other}"); + } + // Arguments on the root or the module make it no library path. + for at in [0, 1] { + let mut path = residue_path("std::collections::BTreeMap"); + path.segments[at].arguments = rs::PathArguments::Parenthesized; + assert!(!std_path(&path), "arguments at {at}"); + } + } + + #[test] + fn residue_a_field_named_by_position_is_an_item() { + assert_eq!(field_name("0"), "item0"); + assert_eq!(field_name("12"), "item12"); + // What `str::parse` accepts as a number reads as one. + assert_eq!(field_name("+3"), "item3"); + assert_eq!(field_name("007"), "item7"); + assert_eq!(field_name("4294967295"), "item4294967295"); + // A name is the local name of its identifier. + assert_eq!(field_name("name"), local_name("name")); + assert_eq!(field_name("r#type"), local_name("r#type")); + assert_eq!(field_name("-1"), local_name("-1")); + assert_eq!(field_name(""), local_name("")); + } + + #[test] + fn residue_fields_and_variants_read_only_where_every_one_lifts() { + let types = types_of("struct Leaf { n: u8 }"); + let raw = |fields: &[(&str, &str)]| -> Vec<(String, rs::RustType)> { + fields + .iter() + .map(|(f, t)| (f.to_string(), residue_ty(t))) + .collect() + }; + assert_eq!( + types.fields_read(&raw(&[("0", "u8"), ("1", "String")])), + Some(vec![ + field("item0", Ty::Nat(Some(8))), + field("item1", Ty::Str) + ]) + ); + assert_eq!( + types.fields_read(&raw(&[("leaf", "Leaf"), ("flag", "bool")])), + Some(vec![ + field(&local_name("leaf"), Ty::Named("Leaf".to_string())), + field(&local_name("flag"), Ty::Bool) + ]) + ); + assert_eq!(types.fields_read(&[]), Some(Vec::new())); + // One field outside, first or last, keeps the whole out. + assert_eq!( + types.fields_read(&raw(&[("a", "std::cell::RefCell"), ("b", "u8")])), + None + ); + assert_eq!( + types.fields_read(&raw(&[("a", "u8"), ("b", "std::cell::RefCell")])), + None + ); + let variant = |v: &str, fields: &[(Option<&str>, &str)]| -> RawVariant { + let fields = fields + .iter() + .map(|(f, t)| (f.map(str::to_string), residue_ty(t))) + .collect(); + (v.to_string(), fields) + }; + let mut own = types.clone(); + own.datas.insert("Tree".to_string(), Vec::new()); + let read = own.variants_read( + "Tree", + &[ + variant("Leaf", &[]), + variant("Node", &[(None, "Vec"), (Some("tag"), "u8")]), + ], + ); + assert_eq!( + read, + Some(vec![ + ("Leaf".to_string(), Vec::new()), + ( + "Node".to_string(), + vec![ + (None, Ty::List(Box::new(Ty::Named("Tree".to_string())))), + (Some("tag".to_string()), Ty::Nat(Some(8))) + ] + ) + ]) + ); + assert_eq!(own.variants_read("Tree", &[]), Some(Vec::new())); + // A field outside the lift, or the enum inside a map where Lean + // nests no inductive, keeps the whole out. + for bad in ["std::cell::RefCell", "BTreeMap"] { + let raw = [variant("Leaf", &[]), variant("Node", &[(None, bad)])]; + assert_eq!(own.variants_read("Tree", &raw), None, "{bad}"); + } + } + + #[test] + fn residue_a_struct_value_is_a_record_or_its_family_constructor() { + let types = types_of("struct P { a: u8, b: u8 }"); + let (a, b) = ("a".to_string(), "b".to_string()); + let parts = [(&a, "1".to_string()), (&b, "2".to_string())]; + assert_eq!( + struct_value("P", &parts, &types), + "(record P {a := 1, b := 2})" + ); + let mut family = types.clone(); + family.families.push(BTreeSet::from(["P".to_string()])); + assert_eq!(struct_value("P", &parts, &family), "(ctor P.mk 1 2)"); + assert_eq!(struct_value("P", &[], &family), "(ctor P.mk)"); + } } diff --git a/crates/uorust/src/main.rs b/crates/uorust/src/main.rs index 2488af51..411e84b0 100644 --- a/crates/uorust/src/main.rs +++ b/crates/uorust/src/main.rs @@ -104,14 +104,16 @@ enum Certify { #[arg(long)] kept: PathBuf, /// The manifest of the last export: the roots it refused at an - /// unchanged κ and compiler are refused again without a build. + /// unchanged κ and compiler are refused again without a build, and + /// the roots it certified at an unchanged identity are carried. #[arg(long)] prior: PathBuf, - /// The certified crate (its manifest and `roots/`): each root it - /// certifies at an unchanged κ, closure κ and compiler is carried, - /// not built again. Without it every root is built. + /// A directory holding the prior export's package sources as a + /// certified crate does (`roots/.rs`), searched in order + /// (repeatable); the prior manifest's own directory when none is + /// given. #[arg(long)] - carry: Option, + carry: Vec, /// Seconds the export may build for: the builds still running then /// are stopped, and the roots not built are refused for this export. #[arg(long)] @@ -123,6 +125,8 @@ enum Certify { /// The shards of a sharded export. #[arg(long, requires = "shard")] shards: Option, + #[command(flatten)] + profile: ProfileArgs, }, /// Plan a sharded export: print, as JSON, the shards that build the /// roots the prior manifest did not refuse within `budget` seconds, and @@ -137,6 +141,20 @@ enum Certify { /// The seconds each shard may build for. #[arg(long)] budget: u64, + /// The projection, which the roots of a cases export are read from, + /// and with `--targets` the roots' identities, so that the plan + /// leaves out the roots the prior export carries. + #[arg(long)] + projection: Option, + /// The output of `lexlean production targets`. + #[arg(long, requires = "projection")] + targets: Option, + /// Where the prior export's package sources are (as `certify + /// production --carry`). + #[arg(long)] + carry: Vec, + #[command(flatten)] + profile: ProfileArgs, }, /// Build one root alone and keep everything lexlean prints of it. Diagnose { @@ -155,37 +173,79 @@ enum Certify { /// The production project, with `build.log`. #[arg(long)] out: PathBuf, + #[command(flatten)] + profile: ProfileArgs, + }, + /// Decide, without a build, which roots of an export the compiler + /// admits: the production project with every root marked is checked + /// (`lexlean check`, which runs no Lean), each root it finds ineligible + /// is refused with its diagnostic and the rest checked again. Prints the + /// counts and each refusal, and writes `refusals.toml` in `out`. + Roots { + /// The projection (`uorust project --out ...`). + #[arg(long)] + projection: PathBuf, + /// The lift register of that projection. + #[arg(long)] + register: PathBuf, + /// The output of `lexlean production targets`. + #[arg(long)] + targets: PathBuf, + /// The directory the production project is written to. + #[arg(long)] + out: PathBuf, + #[command(flatten)] + profile: ProfileArgs, }, /// Take a published bundle into the certified crate and write its - /// manifest with the bootstrap's share. + /// manifest with the bootstrap's share, under the profile the export + /// recorded in what it kept. Sync { /// What `certify production` kept of the bundle. #[arg(long)] kept: PathBuf, - /// The self register, `frontier.toml`. + /// The register, `frontier.toml`. #[arg(long)] register: PathBuf, - /// The workspace's MIR dumps (`uorust mir`). - #[arg(long)] - mir: PathBuf, - /// The workspace root. - #[arg(long)] - workspace: PathBuf, + /// The workspace's MIR dumps (`uorust mir`): the adapters' types, + /// and the share reachable from the profile's entry. + #[arg(long, requires = "workspace")] + mir: Option, + /// The workspace root the dumps are of. + #[arg(long, requires = "mir")] + workspace: Option, /// The certified crate's directory. #[arg(long)] dir: PathBuf, - /// The adapters' module of uorust that is written. + /// The adapters' module that is written, of a workspace that runs + /// its certified packages in place of its functions. + #[arg(long, requires = "mir")] + adapters: Option, + /// The projection of the register, which the roots of a cases + /// export are read from. #[arg(long)] - adapters: PathBuf, + projection: Option, }, /// The differential and the fixpoint: every output directory under `dir` /// written by the certified translator (`-certified`) has the κ of /// the one the hand-written translator wrote (`-hand`); prints each /// output's κ, and is refused on any disagreement. + /// + /// With `--cases`, the agreement of any workspace: every certified case + /// taken into that directory (`certify production --cases`, `certify + /// sync`) answers true when rustc runs it, and the test of the workspace + /// that states it passes; prints each case with the functions it asserts + /// on, and is refused on any case that parts. Agree { /// The directory of the outputs. - #[arg(long)] - dir: PathBuf, + #[arg(long, required_unless_present = "cases")] + dir: Option, + /// The certified crate of a cases export. + #[arg(long, conflicts_with = "dir", requires = "workspace")] + cases: Option, + /// The workspace whose tests state the cases. + #[arg(long, requires = "cases")] + workspace: Option, }, /// Refuse a head under which more translator functions are uncertified /// than under the base. @@ -202,9 +262,62 @@ enum Certify { /// The base's manifest. #[arg(long)] base_manifest: PathBuf, + #[command(flatten)] + profile: ProfileArgs, }, } +/// What an export is of, when it is not the translator's own: each option +/// given replaces what the workspace declares, and with none of them the +/// export is the translator's (uorust::mir, lift and lex, from the translate +/// entry, as `uorust_certified_` packages). +#[derive(clap::Args, Default)] +struct ProfileArgs { + /// The workspace the export is of: every function of its register is in + /// scope and its packages are named after its directory, unless the + /// `[workspace.metadata.uorust.certify]` table of its Cargo manifest + /// (`scope`, `entry`, `package`, `effects`, `target`) says otherwise. + #[arg(long)] + workspace: Option, + /// A crate-path prefix of the functions in scope (repeatable). + #[arg(long)] + scope: Vec, + /// The function the share's reachability starts at. + #[arg(long)] + entry: Option, + /// The prefix of every certified package's name. + #[arg(long)] + package: Option, + /// An effect every root admits (repeatable). + #[arg(long)] + effect: Vec, + /// The target every root is exported to. + #[arg(long)] + target: Option, + /// Export the cases: the closed assertions of the workspace's tests + /// over the functions in scope, each a root with no parameter. + #[arg(long)] + cases: bool, +} + +impl ProfileArgs { + fn options(&self) -> uorust::certify::Options { + uorust::certify::Options { + workspace: self.workspace.clone(), + scope: self.scope.clone(), + entry: self.entry.clone(), + package: self.package.clone(), + effects: self.effect.clone(), + target: self.target.clone(), + cases: self.cases, + } + } + + fn profile(&self) -> Result { + uorust::certify::Profile::resolve(&self.options()) + } +} + #[derive(clap::Args)] struct MirArgs { /// The workspace root, the directory with the top `Cargo.toml`. @@ -665,11 +778,30 @@ fn read_register(path: &std::path::Path) -> Result) -> Vec { + if !given.is_empty() { + return given; + } + prior + .parent() + .map(std::path::Path::to_path_buf) + .into_iter() + .collect() } fn certify(step: Certify) -> Result<(), UorustError> { use uorust::certify; + let read = |path: &PathBuf| { + std::fs::read_to_string(path).map_err(|e| UorustError::Io { + path: path.clone(), + reason: e.to_string(), + }) + }; match step { Certify::Production { projection, @@ -682,25 +814,38 @@ fn certify(step: Certify) -> Result<(), UorustError> { within, shard, shards, + profile, } => { - let targets = std::fs::read_to_string(&targets).map_err(|e| UorustError::Io { - path: targets.clone(), - reason: e.to_string(), - })?; - certify::production_build( - &projection, + let manifest = certify::Manifest::read(&prior)?; + let sources = carried_from(&prior, carry); + let done = certify::production_build( + &certify::Input { + profile: &profile.profile()?, + projection: &projection, + register: &read_register(®ister)?, + targets: &read(&targets)?, + }, &out, - &read_register(®ister)?, - &targets, &kept, - &certify::Manifest::read(&prior)?, + &certify::Prior { + manifest: &manifest, + sources: &sources, + verify: certify::verify_project, + }, + &certify::Compiler::installed()?, certify::Scope { - carry: carry.as_deref(), within: within.map(std::time::Duration::from_secs), shard: shard.zip(shards), }, )?; - println!("certified bundle kept in {}", kept.display()); + println!( + "carried {}, built {} in {} builds, refused {}; certified bundle kept in {}", + done.carried, + done.built, + done.builds, + done.refused, + kept.display() + ); } Certify::Sync { kept, @@ -709,40 +854,97 @@ fn certify(step: Certify) -> Result<(), UorustError> { workspace, dir, adapters, + projection, } => { - let m = certify::sync_paths( - &kept, - &dir, - &adapters, - &read_register(®ister)?, - &workspace, - &mir, - )?; + let (profile, m) = certify::sync_paths(&certify::Sync { + kept: &kept, + dir: &dir, + register: &read_register(®ister)?, + projection: projection.as_deref(), + adapters: adapters.as_deref(), + mir: workspace.as_deref().zip(mir.as_deref()), + })?; let s = &m.share; - println!( - "{} certified roots; {} of {} translator functions certified, {} of {} reachable from {}", - m.roots.len(), - s.certified, - s.translator, - s.reachable_certified, - s.reachable, - certify::ENTRY - ); + match (profile.kind, &profile.entry) { + (certify::Kind::Cases, _) => println!( + "{} certified roots; {} of {} cases certified, over {} functions", + m.roots.len(), + s.certified, + s.translator, + certify::cases::covered(&m).len() + ), + (certify::Kind::Functions, Some(entry)) => println!( + "{} certified roots; {} of {} translator functions certified, {} of {} reachable from {entry}", + m.roots.len(), + s.certified, + s.translator, + s.reachable_certified, + s.reachable + ), + (certify::Kind::Functions, None) => println!( + "{} certified roots; {} of {} functions in scope certified", + m.roots.len(), + s.certified, + s.translator + ), + } } Certify::Plan { register, prior, budget, + projection, + targets, + carry, + profile, } => { - let (shards, diagnose) = certify::plan( - &read_register(®ister)?, - &certify::Manifest::read(&prior)?, - budget, - ); - let shards: Vec = (0..shards).map(|i| format!("{i}-{shards}")).collect(); + let profile = profile.profile()?; + let register = read_register(®ister)?; + let roots = match (profile.kind, &projection) { + (certify::Kind::Cases, None) => { + return Err(UorustError::Tool( + "the cases are read from the projection: pass --projection".to_string(), + )) + } + (certify::Kind::Cases, Some(projection)) => { + profile.export_roots(projection, ®ister)? + } + (certify::Kind::Functions, _) => profile.roots(®ister), + }; + let manifest = certify::Manifest::read(&prior)?; + let carried = match (&projection, &targets) { + (Some(projection), Some(targets)) => { + let input = certify::Input { + profile: &profile, + projection, + register: ®ister, + targets: &read(targets)?, + }; + let sources = carried_from(&prior, carry); + let prior = certify::Prior { + manifest: &manifest, + sources: &sources, + verify: certify::verify_project, + }; + let decided = + certify::carry(&input, &roots, &certify::Compiler::installed()?, &prior); + Some(decided?) + } + _ => None, + }; + let plan = certify::plan_keyed(&roots, carried.as_ref(), &manifest, budget); + let shards: Vec = (0..plan.shards) + .map(|i| format!("{i}-{}", plan.shards)) + .collect(); println!( "{}", - serde_json::json!({"shards": shards, "diagnose": diagnose}) + serde_json::json!({ + "shards": shards, + "diagnose": plan.diagnose, + "carried": plan.carried, + "build": plan.build, + "refused": plan.refused, + }) ); } Certify::Diagnose { @@ -751,38 +953,94 @@ fn certify(step: Certify) -> Result<(), UorustError> { targets, root, out, + profile, } => { - let targets = std::fs::read_to_string(&targets).map_err(|e| UorustError::Io { - path: targets.clone(), - reason: e.to_string(), - })?; certify::diagnose( - &projection, + &certify::Input { + profile: &profile.profile()?, + projection: &projection, + register: &read_register(®ister)?, + targets: &read(&targets)?, + }, &out, - &read_register(®ister)?, - &targets, &root, )?; println!("{}", out.join("build.log").display()); } - Certify::Agree { dir } => { - for line in certify::agree(&dir)? { - println!("{line}"); + Certify::Roots { + projection, + register, + targets, + out, + profile, + } => { + let admission = certify::admit_roots( + &certify::Input { + profile: &profile.profile()?, + projection: &projection, + register: &read_register(®ister)?, + targets: &read(&targets)?, + }, + &out, + )?; + println!( + "{} roots: {} admitted, {} refused", + admission.roots, + admission.admitted.len(), + admission.refused.len() + ); + for (cause, count) in admission.causes() { + println!("{count}\t{cause}"); } } + Certify::Agree { + dir, + cases, + workspace, + } => match (dir, cases, workspace) { + (_, Some(cases), Some(workspace)) => { + let lines = certify::cases::agree(&cases, &workspace)?; + for line in &lines { + println!("{line}"); + } + println!("{} cases agree", lines.len()); + } + (Some(dir), ..) => { + for line in certify::agree(&dir)? { + println!("{line}"); + } + } + _ => { + return Err(UorustError::Tool( + "agree needs --dir, or --cases and --workspace".to_string(), + )) + } + }, Certify::Ratchet { register, manifest, base_register, base_manifest, + profile, } => { - let n = certify::ratchet( + // The scope the head is measured under: the options', else the + // one its manifest states, else the translator's own. + let stated = profile.options() != certify::Options::default(); + let head_profile = match certify::Profile::recorded_at(&manifest)? { + Some(recorded) if !stated => recorded, + _ => profile.profile()?, + }; + let n = head_profile.ratchet_from( + certify::Profile::recorded_at(&base_manifest)?.as_ref(), &read_register(®ister)?, &certify::Manifest::read(&manifest)?, &read_register(&base_register)?, &certify::Manifest::read(&base_manifest)?, )?; - println!("{n} translator functions uncertified, none more than in the base"); + println!( + "{n} {} uncertified, none more than in the base", + head_profile.measured() + ); } } Ok(()) diff --git a/crates/uorust/src/names.rs b/crates/uorust/src/names.rs new file mode 100644 index 00000000..dcbecf5c --- /dev/null +++ b/crates/uorust/src/names.rs @@ -0,0 +1,2959 @@ +//! Names: Rust's name resolution over a workspace, as far as the written +//! code decides it. +//! +//! Admission may call a call ambiguous only after it is resolved the way the +//! language resolves it: a path through the `use` bindings, the globs and +//! the modules of the module it stands in, `Self` and `self` to the type of +//! the `impl` around it, a method by the type its receiver is written with, +//! and one of several functions of a name by the `cfg` predicates they stand +//! under and by the types of the arguments. What the written code does not +//! decide stays open, and nothing here guesses: a rule either names the one +//! function the language would, says the call leaves the workspace, or +//! leaves the call to admission. +//! +//! The facts are read from the source once more, beside ingest's: each +//! module's bindings (an inline `mod` is a module of its own) and each +//! function body's calls with what the code writes of their arguments' types. + +use std::collections::{BTreeMap, BTreeSet}; +use std::path::Path; + +use quote::ToTokens; +use syn::punctuated::Punctuated; +use syn::visit::Visit; + +use crate::admit::Refusal; +use crate::ast::{FnArg, GenericArgument, PathArguments, RustType, TypeKind}; +use crate::error::{io, UorustError}; +use crate::facts::{FnFact, SourceFile, Syntax, TargetKind, Workspace}; + +/// A `cfg` predicate, as its attribute writes it. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub(crate) enum Cfg { + /// One option: `test`, or `feature = "x"` with its value. + Option(String, Option), + Not(Box), + All(Vec), + Any(Vec), +} + +/// One `cfg` option: its name and, for `name = "value"`, its value. +type CfgOption = (String, Option); + +/// What a build decides of `cfg` options. +#[derive(Clone, Debug, Default)] +pub(crate) struct Config { + /// The options it decides, each with whether it holds. + decided: BTreeMap, + /// The features it enables, when it says which: every other is off. + features: Option>, +} + +/// rustc's codegen switches that are `cfg` options too, each with the option +/// it sets (the rustc book, "Codegen options"). +const CODEGEN_OPTIONS: [(&str, &str); 2] = [ + ("-Cdebug-assertions=", "debug_assertions"), + ("-Coverflow-checks=", "overflow_checks"), +]; + +impl Config { + /// The configuration the lift's MIR dump compiles, which a projection + /// states: the package's default features, no `test`, and what + /// [`crate::mir::FLAGS`] pass to rustc. The target is the host's, which + /// no file of the workspace declares: no `target_*` option is decided. + fn dump(features: BTreeSet) -> Config { + let mut decided = BTreeMap::new(); + decided.insert(("test".to_string(), None), false); + for flag in crate::mir::FLAGS { + if let Some(option) = flag.strip_prefix("--cfg=") { + let (name, value) = match option.split_once('=') { + Some((n, v)) => (n, Some(v.trim_matches('"').to_string())), + None => (option, None), + }; + decided.insert((name.to_string(), value), true); + } + for (switch, option) in CODEGEN_OPTIONS { + let state = match flag.strip_prefix(switch) { + Some("y" | "yes" | "on" | "true") => true, + Some("n" | "no" | "off" | "false") => false, + _ => continue, + }; + decided.insert((option.to_string(), None), state); + } + } + Config { + decided, + features: Some(features), + } + } + + fn says(&self, name: &str, value: Option<&str>) -> Option { + let key = (name.to_string(), value.map(str::to_string)); + if let Some(held) = self.decided.get(&key) { + return Some(*held); + } + match (name, value, &self.features) { + ("feature", Some(v), Some(on)) => Some(on.contains(v)), + _ => None, + } + } +} + +impl Cfg { + /// The predicates of the `#[cfg(..)]` attributes among `attrs`. + fn of(attrs: &[syn::Attribute]) -> Vec { + attrs + .iter() + .filter(|a| a.path().is_ident("cfg")) + .map(|a| match a.parse_args::() { + Ok(meta) => Cfg::read(&meta), + // A predicate this reader does not parse is an option of its + // own, which no configuration decides. + Err(_) => Cfg::Option(written(a), None), + }) + .collect() + } + + fn read(meta: &syn::Meta) -> Cfg { + match meta { + syn::Meta::Path(p) => Cfg::Option(written(p), None), + syn::Meta::NameValue(nv) => { + let value = match &nv.value { + syn::Expr::Lit(syn::ExprLit { + lit: syn::Lit::Str(s), + .. + }) => s.value(), + other => written(other), + }; + Cfg::Option(written(&nv.path), Some(value)) + } + syn::Meta::List(l) => { + let inner = l + .parse_args_with(Punctuated::::parse_terminated) + .map(|list| list.iter().map(Cfg::read).collect::>()); + match (written(&l.path).as_str(), inner) { + ("not", Ok(inner)) if inner.len() == 1 => Cfg::Not(Box::new(inner[0].clone())), + ("all", Ok(inner)) => Cfg::All(inner), + ("any", Ok(inner)) => Cfg::Any(inner), + _ => Cfg::Option(written(meta), None), + } + } + } + } + + /// The predicate as Rust writes it inside `cfg( )`. + pub(crate) fn text(&self) -> String { + let list = |cs: &[Cfg]| cs.iter().map(Cfg::text).collect::>().join(", "); + match self { + Cfg::Option(name, None) => name.clone(), + Cfg::Option(name, Some(value)) => format!("{name} = \"{value}\""), + Cfg::Not(c) => format!("not({})", c.text()), + Cfg::All(cs) => format!("all({})", list(cs)), + Cfg::Any(cs) => format!("any({})", list(cs)), + } + } + + /// Whether the predicate holds under `config`: `None` where the + /// configuration does not decide it. + fn holds(&self, config: &Config) -> Option { + match self { + Cfg::Option(name, value) => config.says(name, value.as_deref()), + Cfg::Not(c) => c.holds(config).map(|held| !held), + Cfg::All(cs) => { + let each: Vec> = cs.iter().map(|c| c.holds(config)).collect(); + if each.contains(&Some(false)) { + Some(false) + } else if each.iter().all(|held| *held == Some(true)) { + Some(true) + } else { + None + } + } + Cfg::Any(cs) => { + let each: Vec> = cs.iter().map(|c| c.holds(config)).collect(); + if each.contains(&Some(true)) { + Some(true) + } else if each.iter().all(|held| *held == Some(false)) { + Some(false) + } else { + None + } + } + } + } + + fn options(&self, out: &mut BTreeSet) { + match self { + Cfg::Option(name, value) => { + out.insert((name.clone(), value.clone())); + } + Cfg::Not(c) => c.options(out), + Cfg::All(cs) | Cfg::Any(cs) => cs.iter().for_each(|c| c.options(out)), + } + } +} + +/// Whether every predicate of `all` holds under `config`. +fn hold(all: &[Cfg], config: &Config) -> Option { + Cfg::All(all.to_vec()).holds(config) +} + +/// Whether some build holds every predicate of `all`: some assignment of +/// their options makes each true. Options are taken as independent, so two +/// values of one single-valued option (`target_os`) count as a build; the +/// answer errs towards "some build does". +fn satisfiable(all: &[Cfg]) -> bool { + fn search(all: &[Cfg], options: &[CfgOption], config: &mut Config) -> bool { + match hold(all, config) { + Some(decided) => decided, + None => { + let Some((first, rest)) = options.split_first() else { + return false; + }; + for held in [true, false] { + config.decided.insert(first.clone(), held); + if search(all, rest, config) { + config.decided.remove(first); + return true; + } + } + config.decided.remove(first); + false + } + } + } + let mut options = BTreeSet::new(); + all.iter().for_each(|c| c.options(&mut options)); + let options: Vec = options.into_iter().collect(); + search(all, &options, &mut Config::default()) +} + +/// Whether no build holds both `a` and `b`: two items under them never +/// stand in one crate together. +fn exclusive(a: &[Cfg], b: &[Cfg]) -> bool { + let both: Vec = a.iter().chain(b).cloned().collect(); + !satisfiable(&both) +} + +/// The tokens as Rust writes them. +fn written(tokens: &dyn ToTokens) -> String { + crate::ingest::tidy(&tokens.to_token_stream().to_string()) +} + +/// Who may name an item, as its declaration writes it. +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) enum Vis { + Public, + /// `pub(crate)`. + Crate, + /// `pub(super)`. + Super, + /// No `pub`, or `pub(self)`. + Private, + /// `pub(in path)`, the path as written. + In(Vec), +} + +impl Vis { + fn read(vis: &syn::Visibility) -> Vis { + match vis { + syn::Visibility::Public(_) => Vis::Public, + syn::Visibility::Inherited => Vis::Private, + syn::Visibility::Restricted(r) => { + let path: Vec = r + .path + .segments + .iter() + .map(|s| s.ident.to_string()) + .collect(); + match path.as_slice() { + [one] if one == "crate" => Vis::Crate, + [one] if one == "self" => Vis::Private, + [one] if one == "super" => Vis::Super, + _ => Vis::In(path), + } + } + } + } +} + +/// One name a `use` binds: the name, and the path it names as written. A +/// path with a leading `::` starts with an empty segment. +#[derive(Clone, Debug)] +pub(crate) struct UseName { + name: String, + path: Vec, + vis: Vis, + cfg: Vec, +} + +/// A glob import, `a::b` of `use a::b::*`. +#[derive(Clone, Debug)] +pub(crate) struct Glob { + path: Vec, + vis: Vis, +} + +/// What kind of type a declaration declares. +#[derive(Clone, Debug)] +pub(crate) enum Kind { + Struct, + /// An enum, with its variants. + Enum(Vec), + Union, + Trait, + /// `type Name = To;`. + Alias(Vec, RustType), +} + +/// A type, trait or alias a module declares. +#[derive(Clone, Debug)] +pub(crate) struct TypeDecl { + kind: Kind, + /// How many type parameters it takes. + generics: usize, + vis: Vis, +} + +/// An `impl` block: its self type, the trait it implements by its last +/// segment, and its type parameters. +#[derive(Clone, Debug)] +pub(crate) struct ImplDecl { + self_ty: RustType, + trait_name: Option, + generics: Vec, +} + +/// What one module binds: the file's own module, or an inline `mod`. +#[derive(Clone, Debug, Default)] +pub(crate) struct Scope { + uses: Vec, + globs: Vec, + types: BTreeMap>, + /// The free functions it declares, each with who may name it. + values: BTreeMap>, + /// The modules it declares, inline or in a file of their own. + mods: BTreeSet, + impls: Vec, +} + +/// What a function is a method of. +#[derive(Clone, Debug)] +pub(crate) enum Owner { + /// A free function. + None, + /// A method of an `impl` block with this self type. + Impl(RustType), + /// A method a trait declares. + Trait(String), +} + +/// What the written code says of an expression's type, before any name in +/// it is resolved. +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) enum Hint { + /// Nothing written decides it. + Open, + /// A type as written: a parameter's, a typed `let`'s, a cast's. + Written(RustType), + /// A primitive type a literal has by the language: `str`, `bool`, or a + /// suffix's. + Prim(String), + /// An integer literal without a suffix. + Integer, + /// A float literal without a suffix. + Float, + /// `&e` or `&mut e`. + Ref(bool, Box), + /// `*e`. + Deref(Box), + /// `Self`, the type of the `impl` around the function. + This, + /// The value of the function's call of this index. + Result(usize), + /// `e?`. + Try(Box), + /// A struct literal, or a path that is a value: a unit struct or a + /// variant. + Ctor(Vec), + Tuple(Vec), +} + +/// What a call calls. +#[derive(Clone, Debug)] +pub(crate) enum Callee { + /// `a::b::f(..)`: the path's segments with any `use` of the body + /// written out, its text so, and its text as ingest records it. + Path { + segments: Vec, + text: String, + recorded: String, + /// `::f`: the type, and the trait's last segment. + qself: Option<(RustType, Option)>, + /// A glob import of an enclosing block may bind the path's head. + opaque: bool, + }, + /// `receiver.name(..)`. + Method { name: String, receiver: Hint }, + /// A call of a name the body binds: a closure or a function a variable + /// holds, or a function the body declares, which no fact holds. + Local(String), +} + +/// One call of a body, with what the code writes of its arguments. +#[derive(Clone, Debug)] +pub(crate) struct Call { + callee: Callee, + args: Vec, +} + +impl Call { + /// The call as ingest records it: a path, or `.name` for a method. + fn recorded(&self) -> String { + match &self.callee { + Callee::Path { recorded, .. } => recorded.clone(), + Callee::Method { name, .. } => format!(".{name}"), + Callee::Local(name) => name.clone(), + } + } + + /// The call with any `use` of the body written out. + fn text(&self) -> String { + match &self.callee { + Callee::Path { text, .. } => text.clone(), + _ => self.recorded(), + } + } +} + +/// What name resolution reads of one function. +#[derive(Clone, Debug)] +pub(crate) struct FnNames { + /// The inline module it stands in, `""` for the file's own. + module: String, + /// The `cfg` predicates it stands under: its own, and those of the + /// `impl` and the inline modules around it. + cfg: Vec, + owner: Owner, + /// The type parameters in scope: its own and its `impl`'s or trait's. + generics: Vec, + /// The names its body binds anew: by a `use` or a type it declares. + rebound: BTreeSet, + calls: Vec, +} + +/// Where a type stands, and under which `cfg` predicates. +#[derive(Clone, Debug)] +pub(crate) struct Site { + module: String, + cfg: Vec, +} + +/// What name resolution reads of one source file. +#[derive(Clone, Debug, Default)] +pub(crate) struct FileNames { + /// The file's own module (`""`) and each inline module in it, by its + /// path inside the file (`a::b`). + modules: BTreeMap, + /// Each function, by the line and the name of its fact. + fns: BTreeMap<(usize, String), FnNames>, + /// Each enum and struct, by the line and the name of its fact. + types: BTreeMap<(usize, String), Site>, +} + +/// What name resolution reads of a workspace. +#[derive(Clone, Debug, Default)] +pub(crate) struct Names { + /// Per source file, by its path relative to the workspace root. + files: BTreeMap, + /// Per package, by its directory: the features its default set enables. + features: BTreeMap>, +} + +/// `syntax` with the names of the workspace at `root` read into it. +pub(crate) fn read(root: &Path, ws: &Workspace, mut syntax: Syntax) -> Result { + let mut names = Names::default(); + for package in &ws.packages { + let manifest = root.join(&package.dir).join("Cargo.toml"); + names + .features + .insert(package.dir.clone(), default_features(&manifest)?); + for file in &package.files { + if file.parse_error.is_some() { + continue; + } + let path = root.join(&file.rel); + let text = std::fs::read_to_string(&path).map_err(|e| io(&path, e))?; + // Ingest parsed the same text: a file that does not parse is + // already an `unparsable-source` refusal. + let Ok(parsed) = syn::parse_file(&text) else { + continue; + }; + names.files.insert(file.rel.clone(), FileNames::of(&parsed)); + } + } + syntax.names = names; + Ok(syntax) +} + +/// The features a package's `default` feature enables, by Cargo's rules +/// (the Cargo book, "Features"): a feature enables the features it lists; an +/// optional dependency is a feature of its own name unless some feature +/// names it `dep:name`; `dep/feature` enables the dependency and `dep?/feature` +/// does not. +fn default_features(manifest: &Path) -> Result, UorustError> { + let text = std::fs::read_to_string(manifest).map_err(|e| io(manifest, e))?; + let value: toml::Value = text + .parse() + .map_err(|e: toml::de::Error| UorustError::Malformed { + path: manifest.to_path_buf(), + reason: e.to_string(), + })?; + Ok(enabled_by_default(&value)) +} + +fn enabled_by_default(manifest: &toml::Value) -> BTreeSet { + let table: BTreeMap> = manifest + .get("features") + .and_then(toml::Value::as_table) + .map(|features| { + features + .iter() + .map(|(name, enables)| { + let enables = enables + .as_array() + .into_iter() + .flatten() + .filter_map(toml::Value::as_str) + .map(str::to_string) + .collect(); + (name.clone(), enables) + }) + .collect() + }) + .unwrap_or_default(); + let explicit: BTreeSet<&str> = table + .values() + .flatten() + .filter_map(|entry| entry.strip_prefix("dep:")) + .collect(); + let mut on = BTreeSet::new(); + let mut todo: Vec = table.get("default").cloned().unwrap_or_default(); + if table.contains_key("default") { + on.insert("default".to_string()); + } + while let Some(entry) = todo.pop() { + if entry.starts_with("dep:") { + continue; + } + let name = match entry.split_once('/') { + Some((dep, _)) if dep.ends_with('?') || explicit.contains(dep) => continue, + Some((dep, _)) => dep.to_string(), + None => entry, + }; + if on.insert(name.clone()) { + todo.extend(table.get(&name).cloned().unwrap_or_default()); + } + } + on +} + +/// The type parameters `generics` declares. +fn type_params(generics: &syn::Generics) -> Vec { + generics + .params + .iter() + .filter_map(|p| match p { + syn::GenericParam::Type(t) => Some(t.ident.to_string()), + _ => None, + }) + .collect() +} + +fn idents(path: &syn::Path) -> Vec { + let mut out: Vec = path.segments.iter().map(|s| s.ident.to_string()).collect(); + if path.leading_colon.is_some() { + out.insert(0, String::new()); + } + out +} + +fn join(module: &str, name: &str) -> String { + match (module.is_empty(), name.is_empty()) { + (true, _) => name.to_string(), + (_, true) => module.to_string(), + _ => format!("{module}::{name}"), + } +} + +/// The names a `use` tree binds and the globs it imports, into `scope`. +fn use_tree( + tree: &syn::UseTree, + prefix: &mut Vec, + vis: &Vis, + cfg: &[Cfg], + scope: &mut Scope, +) { + let mut bind = |name: String, path: Vec| { + if name != "_" { + scope.uses.push(UseName { + name, + path, + vis: vis.clone(), + cfg: cfg.to_vec(), + }); + } + }; + match tree { + syn::UseTree::Path(p) => { + prefix.push(p.ident.to_string()); + use_tree(&p.tree, prefix, vis, cfg, scope); + prefix.pop(); + } + // `use a::{self}` binds `a`. + syn::UseTree::Name(n) if n.ident == "self" => { + if let Some(last) = prefix.last() { + bind(last.clone(), prefix.clone()); + } + } + syn::UseTree::Name(n) => { + let mut path = prefix.clone(); + path.push(n.ident.to_string()); + bind(n.ident.to_string(), path); + } + syn::UseTree::Rename(r) => { + let mut path = prefix.clone(); + if r.ident != "self" { + path.push(r.ident.to_string()); + } + bind(r.rename.to_string(), path); + } + syn::UseTree::Glob(_) => scope.globs.push(Glob { + path: prefix.clone(), + vis: vis.clone(), + }), + syn::UseTree::Group(g) => { + for item in &g.items { + use_tree(item, prefix, vis, cfg, scope); + } + } + } +} + +fn use_item(u: &syn::ItemUse, cfg: &[Cfg], scope: &mut Scope) { + let mut prefix = Vec::new(); + if u.leading_colon.is_some() { + prefix.push(String::new()); + } + use_tree(&u.tree, &mut prefix, &Vis::read(&u.vis), cfg, scope); +} + +impl FileNames { + fn of(file: &syn::File) -> FileNames { + let mut out = FileNames::default(); + out.items(&file.items, "", &[]); + out + } + + fn items(&mut self, list: &[syn::Item], module: &str, cfg: &[Cfg]) { + let under = |attrs: &[syn::Attribute]| -> Vec { + cfg.iter().cloned().chain(Cfg::of(attrs)).collect() + }; + let mut scope = Scope::default(); + let declare = |scope: &mut Scope, + name: &syn::Ident, + kind: Kind, + generics: usize, + vis: &syn::Visibility| { + scope + .types + .entry(name.to_string()) + .or_default() + .push(TypeDecl { + kind, + generics, + vis: Vis::read(vis), + }); + }; + for item in list { + match item { + syn::Item::Fn(f) => { + scope + .values + .entry(f.sig.ident.to_string()) + .or_default() + .push(Vis::read(&f.vis)); + self.function( + &f.sig, + Some(&f.block), + module, + under(&f.attrs), + Owner::None, + &[], + ); + } + syn::Item::Impl(imp) => { + let generics = type_params(&imp.generics); + let self_ty = crate::convert::ty(&imp.self_ty); + scope.impls.push(ImplDecl { + self_ty: self_ty.clone(), + trait_name: imp + .trait_ + .as_ref() + .and_then(|(path, _)| path.segments.last()) + .map(|s| s.ident.to_string()), + generics: generics.clone(), + }); + let outer = under(&imp.attrs); + for member in &imp.items { + if let syn::ImplItem::Fn(f) = member { + let cfg = outer.iter().cloned().chain(Cfg::of(&f.attrs)).collect(); + self.function( + &f.sig, + Some(&f.block), + module, + cfg, + Owner::Impl(self_ty.clone()), + &generics, + ); + } + } + } + syn::Item::Trait(t) => { + let generics = type_params(&t.generics); + declare(&mut scope, &t.ident, Kind::Trait, generics.len(), &t.vis); + let outer = under(&t.attrs); + for member in &t.items { + if let syn::TraitItem::Fn(f) = member { + let cfg = outer.iter().cloned().chain(Cfg::of(&f.attrs)).collect(); + self.function( + &f.sig, + f.default.as_ref(), + module, + cfg, + Owner::Trait(t.ident.to_string()), + &generics, + ); + } + } + } + syn::Item::Enum(e) => { + let variants = e.variants.iter().map(|v| v.ident.to_string()).collect(); + let generics = type_params(&e.generics).len(); + declare(&mut scope, &e.ident, Kind::Enum(variants), generics, &e.vis); + self.site(&e.ident, module, under(&e.attrs)); + } + syn::Item::Struct(s) => { + let generics = type_params(&s.generics).len(); + declare(&mut scope, &s.ident, Kind::Struct, generics, &s.vis); + self.site(&s.ident, module, under(&s.attrs)); + } + syn::Item::Union(u) => { + let generics = type_params(&u.generics).len(); + declare(&mut scope, &u.ident, Kind::Union, generics, &u.vis); + } + syn::Item::Type(t) => { + let params = type_params(&t.generics); + let kind = Kind::Alias(params.clone(), crate::convert::ty(&t.ty)); + declare(&mut scope, &t.ident, kind, params.len(), &t.vis); + } + syn::Item::Use(u) => use_item(u, &under(&u.attrs), &mut scope), + syn::Item::ExternCrate(e) => { + let name = match &e.rename { + Some((_, rename)) => rename.to_string(), + None => e.ident.to_string(), + }; + scope.uses.push(UseName { + name, + path: vec![String::new(), e.ident.to_string()], + vis: Vis::read(&e.vis), + cfg: under(&e.attrs), + }); + } + syn::Item::Mod(m) => { + scope.mods.insert(m.ident.to_string()); + if let Some((_, inner)) = &m.content { + self.items(inner, &join(module, &m.ident.to_string()), &under(&m.attrs)); + } + } + _ => {} + } + } + // An inline module written twice (once per configuration) is one + // module with the bindings of both. + let merged = self.modules.entry(module.to_string()).or_default(); + merged.uses.extend(scope.uses); + merged.globs.extend(scope.globs); + for (name, decls) in scope.types { + merged.types.entry(name).or_default().extend(decls); + } + for (name, vis) in scope.values { + merged.values.entry(name).or_default().extend(vis); + } + merged.mods.extend(scope.mods); + merged.impls.extend(scope.impls); + } + + fn site(&mut self, ident: &syn::Ident, module: &str, cfg: Vec) { + self.types.insert( + (ident.span().start().line, ident.to_string()), + Site { + module: module.to_string(), + cfg, + }, + ); + } + + fn function( + &mut self, + sig: &syn::Signature, + block: Option<&syn::Block>, + module: &str, + cfg: Vec, + owner: Owner, + outer: &[String], + ) { + let mut generics = outer.to_vec(); + generics.extend(type_params(&sig.generics)); + let (calls, rebound) = match block { + Some(block) => Walker::calls(sig, block), + None => (Vec::new(), BTreeSet::new()), + }; + self.fns.insert( + (sig.ident.span().start().line, sig.ident.to_string()), + FnNames { + module: module.to_string(), + cfg, + owner, + generics, + rebound, + calls, + }, + ); + } +} + +/// A name a body binds. +#[derive(Clone, Debug)] +enum BodyName { + /// A variable, with what the code writes of its type. + Value(Hint), + /// A function declared inside the body, which no fact holds. + Item, + /// A name a `use` inside the body binds, with the path it names. + Use(Vec), +} + +/// The names one block of a body binds. +#[derive(Default)] +struct Bindings { + names: BTreeMap, + /// The block has a glob import, whose names the block does not say. + glob: bool, +} + +/// Reads a body's calls in the scopes of its blocks. +struct Walker { + scopes: Vec, + calls: Vec, + /// The names a `use` or a type declaration of the body binds. + rebound: BTreeSet, +} + +/// The identifiers a pattern binds. +struct Bound(Vec); + +impl<'ast> Visit<'ast> for Bound { + fn visit_pat_ident(&mut self, node: &'ast syn::PatIdent) { + self.0.push(node.ident.to_string()); + syn::visit::visit_pat_ident(self, node); + } + + fn visit_expr(&mut self, _: &'ast syn::Expr) {} +} + +impl<'ast> Visit<'ast> for Walker { + fn visit_expr(&mut self, node: &'ast syn::Expr) { + self.expr(node); + } + + fn visit_block(&mut self, node: &'ast syn::Block) { + self.block(node); + } + + fn visit_macro(&mut self, node: &'ast syn::Macro) { + self.mac(node); + } + + // An item inside a body is not part of the body's own calls. + fn visit_item(&mut self, _: &'ast syn::Item) {} +} + +impl Walker { + fn calls(sig: &syn::Signature, block: &syn::Block) -> (Vec, BTreeSet) { + let mut walker = Walker { + scopes: vec![Bindings::default()], + calls: Vec::new(), + rebound: BTreeSet::new(), + }; + for input in &sig.inputs { + match input { + syn::FnArg::Receiver(r) => { + let hint = match &r.kind { + syn::ReceiverKind::Value => Hint::This, + syn::ReceiverKind::Reference(_, _, mutable) => { + Hint::Ref(mutable.is_some(), Box::new(Hint::This)) + } + syn::ReceiverKind::Typed(_, ty) => Hint::Written(crate::convert::ty(ty)), + _ => Hint::Open, + }; + walker.bind("self".to_string(), BodyName::Value(hint)); + } + syn::FnArg::Typed(t) => walker.typed(&t.pat, &t.ty), + } + } + walker.block(block); + (walker.calls, walker.rebound) + } + + fn bind(&mut self, name: String, local: BodyName) { + if let Some(scope) = self.scopes.last_mut() { + scope.names.insert(name, local); + } + } + + /// `pat: ty`: a plain name has the written type; any other pattern + /// binds names whose types the code does not write. + fn typed(&mut self, pat: &syn::Pat, ty: &syn::Type) { + match pat { + syn::Pat::Ident(i) if i.subpat.is_none() && i.by_ref.is_none() => { + let hint = Hint::Written(crate::convert::ty(ty)); + self.bind(i.ident.to_string(), BodyName::Value(hint)); + } + other => self.pattern(other), + } + } + + /// A pattern without a written type: each name it binds is open, and + /// its guard is read. + fn pattern(&mut self, pat: &syn::Pat) { + match pat { + syn::Pat::Guard(g) => { + self.pattern(&g.pat); + self.expr(&g.guard); + } + syn::Pat::Type(t) => self.typed(&t.pat, &t.ty), + other => { + let mut bound = Bound(Vec::new()); + bound.visit_pat(other); + for name in bound.0 { + self.bind(name, BodyName::Value(Hint::Open)); + } + } + } + } + + /// What the innermost scope that binds `name` binds it to, and whether + /// a block with a glob import lies between. + fn local(&self, name: &str) -> (Option<&BodyName>, bool) { + let mut glob = false; + for scope in self.scopes.iter().rev() { + if let Some(local) = scope.names.get(name) { + return (Some(local), glob); + } + glob |= scope.glob; + } + (None, glob) + } + + /// A path with the `use` of the body that binds its head written out, + /// and whether a glob import of the body may bind the head instead. + fn written_out(&self, segments: Vec) -> (Vec, bool) { + let Some(head) = segments.first() else { + return (segments, false); + }; + match self.local(head) { + (Some(BodyName::Use(path)), glob) => { + let mut out = path.clone(); + out.extend(segments.into_iter().skip(1)); + (out, glob) + } + (_, glob) => (segments, glob), + } + } + + fn push(&mut self, call: Call) -> Hint { + self.calls.push(call); + Hint::Result(self.calls.len() - 1) + } + + fn block(&mut self, block: &syn::Block) -> Hint { + self.scopes.push(Bindings::default()); + // The items of a block are in scope throughout it. + for stmt in &block.stmts { + match stmt { + syn::Stmt::Item(syn::Item::Fn(f)) => { + self.bind(f.sig.ident.to_string(), BodyName::Item); + } + syn::Stmt::Item(syn::Item::Use(u)) => { + let mut scope = Scope::default(); + use_item(u, &[], &mut scope); + for bound in scope.uses { + self.rebound.insert(bound.name.clone()); + self.bind(bound.name, BodyName::Use(bound.path)); + } + if let (false, Some(bindings)) = + (scope.globs.is_empty(), self.scopes.last_mut()) + { + bindings.glob = true; + } + } + syn::Stmt::Item(syn::Item::Const(c)) => { + let hint = Hint::Written(crate::convert::ty(&c.ty)); + self.bind(c.ident.to_string(), BodyName::Value(hint)); + } + syn::Stmt::Item(syn::Item::Static(s)) => { + let hint = Hint::Written(crate::convert::ty(&s.ty)); + self.bind(s.ident.to_string(), BodyName::Value(hint)); + } + syn::Stmt::Item(syn::Item::Struct(syn::ItemStruct { ident, .. })) + | syn::Stmt::Item(syn::Item::Enum(syn::ItemEnum { ident, .. })) + | syn::Stmt::Item(syn::Item::Union(syn::ItemUnion { ident, .. })) + | syn::Stmt::Item(syn::Item::Type(syn::ItemType { ident, .. })) + | syn::Stmt::Item(syn::Item::Trait(syn::ItemTrait { ident, .. })) => { + self.rebound.insert(ident.to_string()); + } + _ => {} + } + } + let mut last = Hint::Open; + for stmt in &block.stmts { + last = Hint::Open; + match stmt { + syn::Stmt::Local(l) => { + let hint = match &l.init { + Some(init) => { + let hint = self.expr(&init.expr); + if let Some((_, diverge)) = &init.diverge { + self.expr(diverge); + } + hint + } + None => Hint::Open, + }; + match &l.pat { + syn::Pat::Ident(i) if i.subpat.is_none() && i.by_ref.is_none() => { + self.bind(i.ident.to_string(), BodyName::Value(hint)); + } + other => self.pattern(other), + } + } + syn::Stmt::Expr(e, semi) => { + let hint = self.expr(e); + if semi.is_none() { + last = hint; + } + } + syn::Stmt::Macro(m) => { + self.mac(&m.mac); + } + syn::Stmt::Item(_) => {} + } + } + self.scopes.pop(); + last + } + + /// A macro's arguments, where they read as expressions separated by + /// commas: what ingest reads of a macro too. + fn mac(&mut self, m: &syn::Macro) -> Hint { + let args = m.parse_body_with(Punctuated::::parse_terminated); + if let Ok(args) = args { + for arg in &args { + self.expr(arg); + } + } + Hint::Open + } + + /// Reads an expression's calls and returns what the code writes of its + /// type. + #[allow(clippy::too_many_lines)] + fn expr(&mut self, e: &syn::Expr) -> Hint { + match e { + syn::Expr::Call(c) => { + let args: Vec = c.args.iter().map(|a| self.expr(a)).collect(); + let syn::Expr::Path(p) = &*c.func else { + self.expr(&c.func); + return Hint::Open; + }; + let segments = idents(&p.path); + // A closure or a function a variable holds, or a function + // the body declares, is no path to a function fact. + if let ([one], None) = (segments.as_slice(), &p.qself) { + if matches!(self.local(one).0, Some(BodyName::Value(_) | BodyName::Item)) { + return self.push(Call { + callee: Callee::Local(one.clone()), + args, + }); + } + } + let recorded = crate::convert::path(&p.path).text; + let (written, opaque) = self.written_out(segments.clone()); + let text = if written == segments { + recorded.clone() + } else { + written.join("::") + }; + let qself = p.qself.as_ref().map(|q| { + let of = q + .position + .checked_sub(1) + .and_then(|last| p.path.segments.iter().nth(last)) + .map(|s| s.ident.to_string()); + (crate::convert::ty(&q.ty), of) + }); + self.push(Call { + callee: Callee::Path { + segments: written, + text, + recorded, + qself, + opaque, + }, + args, + }) + } + syn::Expr::MethodCall(m) => { + let receiver = self.expr(&m.receiver); + let args = m.args.iter().map(|a| self.expr(a)).collect(); + self.push(Call { + callee: Callee::Method { + name: m.method.to_string(), + receiver, + }, + args, + }) + } + syn::Expr::Path(p) => { + if p.qself.is_some() { + return Hint::Open; + } + let segments = idents(&p.path); + if let [one] = segments.as_slice() { + match self.local(one).0 { + Some(BodyName::Value(hint)) => return hint.clone(), + Some(BodyName::Item) => return Hint::Open, + Some(BodyName::Use(_)) | None => {} + } + } + match self.written_out(segments) { + (written, false) => Hint::Ctor(written), + (_, true) => Hint::Open, + } + } + syn::Expr::Lit(l) => match &l.lit { + syn::Lit::Str(_) => Hint::Ref(false, Box::new(Hint::Prim("str".to_string()))), + syn::Lit::Bool(_) => Hint::Prim("bool".to_string()), + syn::Lit::Char(_) => Hint::Prim("char".to_string()), + syn::Lit::Byte(_) => Hint::Prim("u8".to_string()), + syn::Lit::Int(i) if i.suffix().is_empty() => Hint::Integer, + syn::Lit::Int(i) => Hint::Prim(i.suffix().to_string()), + syn::Lit::Float(f) if f.suffix().is_empty() => Hint::Float, + syn::Lit::Float(f) => Hint::Prim(f.suffix().to_string()), + _ => Hint::Open, + }, + syn::Expr::Reference(r) => { + Hint::Ref(r.mutability.is_some(), Box::new(self.expr(&r.expr))) + } + syn::Expr::Paren(p) => self.expr(&p.expr), + syn::Expr::Group(g) => self.expr(&g.expr), + syn::Expr::Unary(u) => { + let hint = self.expr(&u.expr); + match u.op { + syn::UnOp::Deref(_) => Hint::Deref(Box::new(hint)), + // The negation of a literal is a literal of its type. + syn::UnOp::Neg(_) => match hint { + Hint::Integer | Hint::Float | Hint::Prim(_) => hint, + _ => Hint::Open, + }, + _ => Hint::Open, + } + } + syn::Expr::Cast(c) => { + self.expr(&c.expr); + Hint::Written(crate::convert::ty(&c.ty)) + } + syn::Expr::Struct(s) => { + for field in &s.fields { + self.expr(&field.expr); + } + if let Some(rest) = &s.rest { + self.expr(rest); + } + match (&s.qself, self.written_out(idents(&s.path))) { + (None, (written, false)) => Hint::Ctor(written), + _ => Hint::Open, + } + } + syn::Expr::Try(t) => Hint::Try(Box::new(self.expr(&t.expr))), + syn::Expr::Tuple(t) => Hint::Tuple(t.elems.iter().map(|x| self.expr(x)).collect()), + syn::Expr::Block(b) => self.block(&b.block), + syn::Expr::Unsafe(u) => self.block(&u.block), + syn::Expr::If(i) => { + // A `let` of the condition binds its names in the branch. + self.scopes.push(Bindings::default()); + self.expr(&i.cond); + self.block(&i.then_branch); + self.scopes.pop(); + if let Some((_, otherwise)) = &i.else_branch { + self.expr(otherwise); + } + Hint::Open + } + syn::Expr::While(w) => { + self.scopes.push(Bindings::default()); + self.expr(&w.cond); + self.block(&w.body); + self.scopes.pop(); + Hint::Open + } + syn::Expr::Let(l) => { + self.expr(&l.expr); + self.pattern(&l.pat); + Hint::Open + } + syn::Expr::Match(m) => { + self.expr(&m.expr); + for arm in &m.arms { + self.scopes.push(Bindings::default()); + self.pattern(&arm.pat); + self.expr(&arm.body); + self.scopes.pop(); + } + Hint::Open + } + syn::Expr::ForLoop(f) => { + self.expr(&f.expr); + self.scopes.push(Bindings::default()); + self.pattern(&f.pat); + self.block(&f.body); + self.scopes.pop(); + Hint::Open + } + syn::Expr::Closure(c) => { + self.scopes.push(Bindings::default()); + for input in &c.inputs { + self.pattern(input); + } + self.expr(&c.body); + self.scopes.pop(); + Hint::Open + } + syn::Expr::Macro(m) => self.mac(&m.mac), + other => { + syn::visit::visit_expr(self, other); + Hint::Open + } + } + } +} + +/// A function of the workspace: package, file and position in the file. +pub(crate) type FnId = (usize, usize, usize); + +/// A module of the workspace: package, target and path inside the target. +type ModKey = (usize, usize, String); + +/// What the language's rules say a call calls. +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) enum Outcome { + /// These functions of the workspace: one, or the variants of one under + /// `cfg` predicates no build holds together. + Resolved(Vec), + /// Nothing the workspace declares as a function: the standard library, + /// a registry crate, a constructor, a closure. + Outside, + /// One of these, and the written code does not decide which. + Open(Vec), + /// The rules could not follow the call: admission reads it by name. + Unknown, +} + +/// What a type is named by, once its path is resolved. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +enum TypeId { + /// A type a module of the workspace declares. + Local(ModKey, String), + /// A path through a crate outside the workspace. + Extern(Vec), + /// A name no module binds: a primitive type or one of the standard + /// prelude. + Prelude(String), + /// A type parameter. + Param(String), +} + +/// A type as far as the written code decides it. +#[derive(Clone, Debug, PartialEq, Eq)] +enum Ty { + Named(TypeId, Vec), + Ref(bool, Box), + Tuple(Vec), + Slice(Box), + Array(Box, String), + /// An integer literal's: some integer type. + Integer, + /// A float literal's: some float type. + Float, + Open, +} + +/// Whether two types are one type. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Match { + Same, + Different, + /// The written code does not decide it. + Unknown, + /// A literal against a type its kind of literal can have. + Literal, +} + +/// The primitive integer types (the Rust reference, "Numeric types"). +const INTEGERS: [&str; 12] = [ + "i8", "i16", "i32", "i64", "i128", "isize", "u8", "u16", "u32", "u64", "u128", "usize", +]; + +/// The primitive float types. +const FLOATS: [&str; 2] = ["f32", "f64"]; + +/// The types an unsuffixed literal falls back to when nothing else decides +/// it (the Rust reference, "Literal expressions"). +const INTEGER_FALLBACK: &str = "i32"; +const FLOAT_FALLBACK: &str = "f64"; + +/// The crates every build has without a manifest naming them. +const SYSROOT: [&str; 5] = ["std", "core", "alloc", "proc_macro", "test"]; + +/// What a path names. +#[derive(Clone, Debug, PartialEq, Eq)] +enum Found { + Module(ModKey), + /// A type a module declares. + Type(ModKey, String), + /// A free function a module declares. + Fn(ModKey, String), + /// An item of a type: `Type::item`. + Assoc(Box, Vec), + /// A path through a crate outside the workspace. + Extern(Vec), + /// A name no module binds, in a module without a glob of an outside + /// crate: a primitive or a name of the standard prelude. + Prelude(String), + /// Something outside the workspace that a glob of an outside crate may + /// bind: no module of the workspace declares it. + Outside, + /// A module of the workspace that binds nothing of the name. + Absent, + /// The path cannot be followed. + Unknown, +} + +/// Where a type is read: the module, the type parameters in scope and +/// what `Self` is. +struct Reading<'a> { + module: ModKey, + generics: &'a [String], + this: Option, +} + +/// Rust's name resolution over a workspace's facts. +pub(crate) struct Resolver<'a> { + ws: &'a Workspace, + syntax: &'a Syntax, + /// Each module: the file that holds it and its path inside the file. + modules: BTreeMap, + /// The free functions by module and name. + free: BTreeMap<(ModKey, String), Vec>, + /// The methods by name. + methods: BTreeMap>, + /// The type each method is a method of. + owners: BTreeMap, + /// Each trait a type implements: the type, and the trait's name. + implemented: BTreeSet<(TypeId, String)>, + /// The workspace's libraries by crate name: package and target. + libs: BTreeMap, + /// The crates outside the workspace a path can start with. + outside: BTreeSet, + /// The registry crates among them. + registry: BTreeSet, + /// Each package's projected configuration. + configs: Vec, + /// How many aliases the workspace declares: no chain of aliases that + /// does not repeat one is longer. + aliases: usize, +} + +fn parent(module: &str) -> Option { + if module.is_empty() { + return None; + } + Some(match module.rsplit_once("::") { + Some((up, _)) => up.to_string(), + None => String::new(), + }) +} + +/// Whether `module` is `ancestor` or lies inside it. +fn within(module: &str, ancestor: &str) -> bool { + ancestor.is_empty() || module == ancestor || module.starts_with(&format!("{ancestor}::")) +} + +/// The type with each parameter of `params` replaced by its argument. +fn substituted(ty: &Ty, params: &[String], args: &[Ty]) -> Ty { + let inner = |t: &Ty| Box::new(substituted(t, params, args)); + match ty { + Ty::Named(TypeId::Param(p), own) if own.is_empty() => { + match params.iter().position(|q| q == p) { + Some(i) => args.get(i).cloned().unwrap_or(Ty::Open), + None => ty.clone(), + } + } + Ty::Named(id, own) => Ty::Named( + id.clone(), + own.iter().map(|t| substituted(t, params, args)).collect(), + ), + Ty::Ref(mutable, t) => Ty::Ref(*mutable, inner(t)), + Ty::Tuple(ts) => Ty::Tuple(ts.iter().map(|t| substituted(t, params, args)).collect()), + Ty::Slice(t) => Ty::Slice(inner(t)), + Ty::Array(t, n) => Ty::Array(inner(t), n.clone()), + Ty::Integer | Ty::Float | Ty::Open => ty.clone(), + } +} + +/// Whether each pair is one type: the same when all are, different when +/// one is. +fn all_same(pairs: impl Iterator) -> Match { + let mut out = Match::Same; + for one in pairs { + match one { + Match::Different => return Match::Different, + Match::Same => {} + Match::Unknown | Match::Literal => out = Match::Unknown, + } + } + out +} + +/// Whether an argument of type `arg` is a parameter of type `param`. +fn compare(arg: &Ty, param: &Ty) -> Match { + // A nominal type of the workspace, a primitive or a prelude type is + // not a reference, a tuple, a slice or an array; a type of an outside + // crate may be an alias of one. + let nominal = |id: &TypeId| matches!(id, TypeId::Local(..) | TypeId::Prelude(_)); + match (arg, param) { + (Ty::Open, _) | (_, Ty::Open) => Match::Unknown, + (Ty::Named(TypeId::Param(_), _), _) | (_, Ty::Named(TypeId::Param(_), _)) => Match::Unknown, + (Ty::Integer, Ty::Named(TypeId::Prelude(p), _)) if INTEGERS.contains(&p.as_str()) => { + Match::Literal + } + (Ty::Float, Ty::Named(TypeId::Prelude(p), _)) if FLOATS.contains(&p.as_str()) => { + Match::Literal + } + (Ty::Integer | Ty::Float, Ty::Named(id, _)) if !nominal(id) => Match::Unknown, + (Ty::Integer | Ty::Float, _) => Match::Different, + (_, Ty::Integer | Ty::Float) => Match::Unknown, + (Ty::Named(a, xs), Ty::Named(b, ys)) => { + let args = || { + if xs.len() == ys.len() { + all_same(xs.iter().zip(ys).map(|(x, y)| compare(x, y))) + } else { + Match::Unknown + } + }; + match (a, b) { + _ if a == b => args(), + (TypeId::Local(..), _) | (_, TypeId::Local(..)) => Match::Different, + (TypeId::Prelude(_), TypeId::Prelude(_)) => Match::Different, + // One type of an outside crate can have two paths. + _ => Match::Unknown, + } + } + (Ty::Ref(m, x), Ty::Ref(n, y)) => { + if m == n { + compare(x, y) + } else { + Match::Different + } + } + (Ty::Tuple(xs), Ty::Tuple(ys)) => { + if xs.len() == ys.len() { + all_same(xs.iter().zip(ys).map(|(x, y)| compare(x, y))) + } else { + Match::Different + } + } + (Ty::Slice(x), Ty::Slice(y)) => compare(x, y), + (Ty::Array(x, m), Ty::Array(y, n)) => { + if m == n { + compare(x, y) + } else { + Match::Unknown + } + } + (Ty::Named(id, _), _) | (_, Ty::Named(id, _)) => { + if nominal(id) { + Match::Different + } else { + Match::Unknown + } + } + _ => Match::Different, + } +} + +impl<'a> Resolver<'a> { + pub(crate) fn new(ws: &'a Workspace, syntax: &'a Syntax) -> Resolver<'a> { + let mut resolver = Resolver { + ws, + syntax, + modules: BTreeMap::new(), + free: BTreeMap::new(), + methods: BTreeMap::new(), + owners: BTreeMap::new(), + implemented: BTreeSet::new(), + libs: BTreeMap::new(), + outside: SYSROOT.iter().map(|s| (*s).to_string()).collect(), + registry: BTreeSet::new(), + configs: Vec::new(), + aliases: 0, + }; + let names = &syntax.names; + for (pkg, package) in ws.packages.iter().enumerate() { + let features = names + .features + .get(&package.dir) + .cloned() + .unwrap_or_default(); + resolver.configs.push(Config::dump(features)); + for (t, target) in package.targets.iter().enumerate() { + if target.kind == TargetKind::Lib { + resolver + .libs + .insert(target.name.replace('-', "_"), (pkg, t)); + } + } + for dep in package.deps.iter().filter(|d| d.path.is_none()) { + resolver.registry.insert(dep.name.replace('-', "_")); + } + for (fi, file) in package.files.iter().enumerate() { + let Some(read) = names.files.get(&file.rel) else { + continue; + }; + for (inline, scope) in &read.modules { + let key = (pkg, file.target, join(&file.module, inline)); + resolver.modules.entry(key).or_insert((fi, inline.clone())); + resolver.aliases += scope + .types + .values() + .flatten() + .filter(|d| matches!(d.kind, Kind::Alias(..))) + .count(); + } + } + } + // A registry crate named like a library of the workspace is the + // workspace's: a path dependency, not a registry one. + let libs: Vec = resolver.libs.keys().cloned().collect(); + for lib in libs { + resolver.registry.remove(&lib); + } + resolver.outside.extend(resolver.registry.iter().cloned()); + for (pkg, package) in ws.packages.iter().enumerate() { + for (fi, file) in package.files.iter().enumerate() { + for (idx, fact) in file.fns.iter().enumerate() { + let f = (pkg, fi, idx); + if fact.owner.is_some() { + resolver + .methods + .entry(fact.name.clone()) + .or_default() + .push(f); + } else { + let key = (resolver.module(f), fact.name.clone()); + resolver.free.entry(key).or_default().push(f); + } + } + } + } + let methods: Vec = resolver.methods.values().flatten().copied().collect(); + for f in methods { + if let Some(owner) = resolver.owner(f) { + resolver.owners.insert(f, owner); + } + } + let modules: Vec = resolver.modules.keys().cloned().collect(); + for module in modules { + let Some(scope) = resolver.scope(&module) else { + continue; + }; + for imp in &scope.impls { + let Some(of) = &imp.trait_name else { + continue; + }; + let reading = Reading { + module: module.clone(), + generics: &imp.generics, + this: None, + }; + if let Some(id) = head(&resolver.ty(&reading, &imp.self_ty, resolver.aliases)) { + resolver.implemented.insert((id, of.clone())); + } + } + } + resolver + } + + fn file(&self, f: FnId) -> &'a SourceFile { + &self.ws.packages[f.0].files[f.1] + } + + fn fact(&self, f: FnId) -> &'a FnFact { + &self.file(f).fns[f.2] + } + + fn names(&self, f: FnId) -> Option<&'a FnNames> { + let file = self.file(f); + let fact = &file.fns[f.2]; + let read = self.syntax.names.files.get(&file.rel)?; + read.fns.get(&(fact.span.line, fact.name.clone())) + } + + /// The module a function stands in. + fn module(&self, f: FnId) -> ModKey { + let file = self.file(f); + let inline = self.names(f).map(|n| n.module.as_str()).unwrap_or(""); + (f.0, file.target, join(&file.module, inline)) + } + + fn scope(&self, module: &ModKey) -> Option<&'a Scope> { + let (fi, inline) = self.modules.get(module)?; + let file = &self.ws.packages[module.0].files[*fi]; + self.syntax.names.files.get(&file.rel)?.modules.get(inline) + } + + fn signature(&self, f: FnId) -> &'a crate::ast::Signature { + &self.syntax.function(&self.file(f).rel, f.2).signature + } + + fn cfg(&self, f: FnId) -> &'a [Cfg] { + self.names(f).map(|n| n.cfg.as_slice()).unwrap_or(&[]) + } + + /// The type a method is a method of: the `impl`'s self type without + /// its references, or the trait that declares it. + fn owner(&self, f: FnId) -> Option { + let names = self.names(f)?; + let module = self.module(f); + match &names.owner { + Owner::None => None, + Owner::Trait(name) => Some(TypeId::Local(module, name.clone())), + Owner::Impl(self_ty) => { + let reading = Reading { + module, + generics: &names.generics, + this: None, + }; + head(&self.ty(&reading, self_ty, self.aliases)) + } + } + } + + /// Where a function's types are read. + fn reading(&self, f: FnId) -> Reading<'a> { + let module = self.module(f); + let Some(names) = self.names(f) else { + return Reading { + module, + generics: &[], + this: None, + }; + }; + let this = match &names.owner { + Owner::Impl(self_ty) => { + let outer = Reading { + module: module.clone(), + generics: &names.generics, + this: None, + }; + Some(self.ty(&outer, self_ty, self.aliases)) + } + // In a trait's own methods `Self` is read as the trait: what + // it declares is what `Self` has. + Owner::Trait(name) => Some(Ty::Named( + TypeId::Local(module.clone(), name.clone()), + Vec::new(), + )), + Owner::None => None, + }; + Reading { + module, + generics: &names.generics, + this, + } + } + + /// Whether an item declared in `declared` with `vis` can be named + /// from `from`. + fn visible(vis: &Vis, declared: &ModKey, from: &ModKey) -> bool { + if *vis == Vis::Public { + return true; + } + if (declared.0, declared.1) != (from.0, from.1) { + return false; + } + match vis { + Vis::Public | Vis::Crate => true, + Vis::Private => within(&from.2, &declared.2), + Vis::Super => within(&from.2, &parent(&declared.2).unwrap_or_default()), + Vis::In(path) => { + let mut at = declared.2.clone(); + let mut rest = path.as_slice(); + match rest.first().map(String::as_str) { + Some("crate") => { + at = String::new(); + rest = &rest[1..]; + } + Some("self") => rest = &rest[1..], + _ => {} + } + while rest.first().is_some_and(|s| s == "super") { + at = parent(&at).unwrap_or_default(); + rest = &rest[1..]; + } + within(&from.2, &join(&at, &rest.join("::"))) + } + } + } + + /// A crate a path names by its first segment. + fn krate(&self, name: &str) -> Found { + if let Some(&(pkg, target)) = self.libs.get(name) { + return Found::Module((pkg, target, String::new())); + } + if self.outside.contains(name) { + return Found::Extern(vec![name.to_string()]); + } + Found::Unknown + } + + /// What `name` names in the scope of module `x`, read from `from`: + /// what `x` declares, then what its `use` binds, then what its globs + /// import. `None` when the module binds nothing of the name. + fn named( + &self, + x: &ModKey, + from: &ModKey, + name: &str, + value: bool, + seen: &mut Vec<(ModKey, String, bool)>, + ) -> Option { + let key = (x.clone(), name.to_string(), value); + // An import that leads back to itself names nothing. + if seen.contains(&key) { + return None; + } + seen.push(key); + let found = self.named_in(x, from, name, value, seen); + seen.pop(); + found + } + + fn named_in( + &self, + x: &ModKey, + from: &ModKey, + name: &str, + value: bool, + seen: &mut Vec<(ModKey, String, bool)>, + ) -> Option { + let Some(scope) = self.scope(x) else { + return Some(Found::Unknown); + }; + let types = scope.types.get(name).map(Vec::as_slice).unwrap_or(&[]); + if value { + let fns = scope.values.get(name).map(Vec::as_slice).unwrap_or(&[]); + if fns.iter().any(|vis| Self::visible(vis, x, from)) { + return Some(Found::Fn(x.clone(), name.to_string())); + } + // A struct's name is a value too: its constructor. + let ctor = + |d: &TypeDecl| matches!(d.kind, Kind::Struct) && Self::visible(&d.vis, x, from); + if types.iter().any(ctor) { + return Some(Found::Type(x.clone(), name.to_string())); + } + } else { + if scope.mods.contains(name) { + let child = (x.0, x.1, join(&x.2, name)); + return Some(if self.modules.contains_key(&child) { + Found::Module(child) + } else { + Found::Unknown + }); + } + if types.iter().any(|d| Self::visible(&d.vis, x, from)) { + return Some(Found::Type(x.clone(), name.to_string())); + } + } + let config = &self.configs[x.0]; + let mut found: Vec = Vec::new(); + let mut add = |one: Found| { + if !found.contains(&one) { + found.push(one); + } + }; + // A binding the projected configuration compiles out is read only + // when every binding of the name is. + let bound: Vec<&UseName> = scope + .uses + .iter() + .filter(|u| u.name == name && Self::visible(&u.vis, x, from)) + .collect(); + let live: Vec<&UseName> = bound + .iter() + .copied() + .filter(|u| hold(&u.cfg, config) != Some(false)) + .collect(); + for binding in if live.is_empty() { &bound } else { &live } { + match self.path(x, &binding.path, value, seen) { + // The binding names nothing in this namespace. + Found::Absent => {} + one => add(one), + } + } + match found.len() { + 0 => {} + 1 => return found.pop(), + _ => return Some(Found::Unknown), + } + let mut outside = false; + let mut unknown = false; + for glob in scope + .globs + .iter() + .filter(|g| Self::visible(&g.vis, x, from)) + { + match self.path(x, &glob.path, false, seen) { + Found::Module(y) => match self.named(&y, x, name, value, seen) { + None | Some(Found::Absent) => {} + Some(Found::Outside) => outside = true, + Some(one) => { + if !found.contains(&one) { + found.push(one); + } + } + }, + // An enum's variants, or an item's: no module, no function. + Found::Type(..) | Found::Assoc(..) => {} + Found::Extern(_) | Found::Outside => outside = true, + _ => unknown = true, + } + } + match found.len() { + 0 if unknown => Some(Found::Unknown), + 0 if outside => Some(Found::Outside), + 0 => None, + 1 => found.pop(), + _ => Some(Found::Unknown), + } + } + + /// What a path names, read in module `m`: the last segment as a value + /// (a function) when `value`, every other as a module or a type. + fn path( + &self, + m: &ModKey, + segments: &[String], + value: bool, + seen: &mut Vec<(ModKey, String, bool)>, + ) -> Found { + let Some((first, mut rest)) = segments.split_first() else { + return Found::Unknown; + }; + let mut at = match first.as_str() { + // `::krate::..`. + "" => { + let Some((krate, tail)) = rest.split_first() else { + return Found::Unknown; + }; + rest = tail; + self.krate(krate) + } + "crate" => Found::Module((m.0, m.1, String::new())), + "self" => Found::Module(m.clone()), + "super" => { + let Some(mut module) = parent(&m.2) else { + return Found::Unknown; + }; + while let Some((next, tail)) = rest.split_first() { + if next != "super" { + break; + } + let Some(up) = parent(&module) else { + return Found::Unknown; + }; + module = up; + rest = tail; + } + Found::Module((m.0, m.1, module)) + } + "Self" => return Found::Unknown, + name => match self.named(m, m, name, value && rest.is_empty(), seen) { + Some(found) => found, + // Nothing the module binds: a crate, or a name of the + // prelude. + None => match self.krate(name) { + Found::Unknown => Found::Prelude(name.to_string()), + krate => krate, + }, + }, + }; + while let Some((next, tail)) = rest.split_first() { + at = match at { + Found::Module(x) => match self.named(&x, m, next, value && tail.is_empty(), seen) { + Some(found) => found, + None => Found::Absent, + }, + Found::Type(..) | Found::Prelude(_) => { + return Found::Assoc(Box::new(at), rest.to_vec()); + } + Found::Extern(mut path) => { + path.push(next.clone()); + Found::Extern(path) + } + Found::Outside => Found::Outside, + Found::Absent => return Found::Absent, + Found::Fn(..) | Found::Assoc(..) | Found::Unknown => return Found::Unknown, + }; + rest = tail; + } + at + } + + /// The type a declaration of the workspace declares: itself, or what + /// it stands for when it is an alias. + fn declared(&self, module: ModKey, name: String, args: Vec, depth: usize) -> Ty { + let decls = self + .scope(&module) + .and_then(|s| s.types.get(&name)) + .map(Vec::as_slice) + .unwrap_or(&[]); + match decls { + [TypeDecl { + kind: Kind::Alias(params, to), + .. + }] => { + if depth == 0 || params.len() != args.len() { + return Ty::Open; + } + let reading = Reading { + module, + generics: params, + this: None, + }; + substituted(&self.ty(&reading, to, depth - 1), params, &args) + } + // An alias under one configuration and something else under + // another is not read. + many if many.iter().any(|d| matches!(d.kind, Kind::Alias(..))) => Ty::Open, + _ => Ty::Named(TypeId::Local(module, name), args), + } + } + + /// A written type, with each name resolved where it is read. + fn ty(&self, reading: &Reading<'_>, written: &RustType, depth: usize) -> Ty { + let inner = |t: &RustType| Box::new(self.ty(reading, t, depth)); + match &written.kind { + TypeKind::Reference { mutable, elem } => Ty::Ref(*mutable, inner(elem)), + TypeKind::Slice(t) => Ty::Slice(inner(t)), + TypeKind::Array(t, n) => Ty::Array(inner(t), n.clone()), + TypeKind::Paren(t) => self.ty(reading, t, depth), + TypeKind::Tuple(ts) => { + Ty::Tuple(ts.iter().map(|t| self.ty(reading, t, depth)).collect()) + } + TypeKind::Path { qself: false, path } => { + let Some((last, before)) = path.segments.split_last() else { + return Ty::Open; + }; + if before.iter().any(|s| s.arguments != PathArguments::None) { + return Ty::Open; + } + let mut args = Vec::new(); + match &last.arguments { + PathArguments::None => {} + PathArguments::AngleBracketed(list) => { + for arg in list { + match arg { + GenericArgument::Type(t) => args.push(self.ty(reading, t, depth)), + // A lifetime says how long a borrow lives, + // not which type it is. + GenericArgument::Other(text) if text.starts_with('\'') => {} + GenericArgument::Other(_) => args.push(Ty::Open), + } + } + } + PathArguments::Parenthesized => return Ty::Open, + } + let segments: Vec = path.segments.iter().map(|s| s.ident.clone()).collect(); + if let [one] = segments.as_slice() { + if one == "Self" { + return reading.this.clone().unwrap_or(Ty::Open); + } + if reading.generics.contains(one) { + return Ty::Named(TypeId::Param(one.clone()), args); + } + } + match self.path(&reading.module, &segments, false, &mut Vec::new()) { + Found::Type(module, name) => self.declared(module, name, args, depth), + Found::Prelude(name) => Ty::Named(TypeId::Prelude(name), args), + Found::Extern(path) => Ty::Named(TypeId::Extern(path), args), + _ => Ty::Open, + } + } + _ => Ty::Open, + } + } + + /// The type a constructor path constructs: a struct without type + /// parameters, or a variant of an enum without them. + fn constructed(&self, reading: &Reading<'_>, segments: &[String]) -> Ty { + let plain = |module: &ModKey, name: &str, variant: Option<&String>| -> bool { + let decls = self + .scope(module) + .and_then(|s| s.types.get(name)) + .map(Vec::as_slice) + .unwrap_or(&[]); + match (decls, variant) { + ([one], None) => one.generics == 0 && matches!(one.kind, Kind::Struct), + ([one], Some(v)) => { + one.generics == 0 && matches!(&one.kind, Kind::Enum(vs) if vs.contains(v)) + } + _ => false, + } + }; + if let Some((first, rest)) = segments.split_first() { + if first == "Self" { + let Some(Ty::Named(TypeId::Local(module, name), args)) = &reading.this else { + return Ty::Open; + }; + let known = match rest { + [] => args.is_empty(), + [variant] => plain(module, name, Some(variant)), + _ => false, + }; + return if known { + Ty::Named(TypeId::Local(module.clone(), name.clone()), Vec::new()) + } else { + Ty::Open + }; + } + } + match self.path(&reading.module, segments, false, &mut Vec::new()) { + Found::Type(module, name) if plain(&module, &name, None) => { + Ty::Named(TypeId::Local(module, name), Vec::new()) + } + Found::Assoc(of, rest) => match (*of, rest.as_slice()) { + (Found::Type(module, name), [variant]) if plain(&module, &name, Some(variant)) => { + Ty::Named(TypeId::Local(module, name), Vec::new()) + } + _ => Ty::Open, + }, + _ => Ty::Open, + } + } + + /// The type a function's result has, read where it is declared. + fn returns(&self, f: FnId) -> Ty { + let signature = self.signature(f); + if signature.asyncness { + return Ty::Open; + } + match &signature.output { + None => Ty::Tuple(Vec::new()), + Some(out) => self.ty(&self.reading(f), out, self.aliases), + } + } + + /// The types of a function's parameters after its receiver. + fn params(&self, f: FnId) -> Vec { + let reading = self.reading(f); + self.signature(f) + .inputs + .iter() + .filter_map(|input| match input { + FnArg::Typed(p) => Some(self.ty(&reading, &p.ty, self.aliases)), + FnArg::Receiver { .. } => None, + }) + .collect() + } + + fn takes_self(&self, f: FnId) -> bool { + matches!( + self.signature(f).inputs.first(), + Some(FnArg::Receiver { .. }) + ) + } + + /// The functions of `candidates` when they are one function: a single + /// one, or the variants of one under `cfg` predicates no build holds + /// together. Of variants, those the projected configuration compiles + /// out are left out when it compiles another in. + fn one(&self, candidates: &[FnId]) -> Option> { + match candidates { + [] => None, + [only] => Some(vec![*only]), + many => { + let apart = many.iter().enumerate().all(|(i, a)| { + many[i + 1..] + .iter() + .all(|b| exclusive(self.cfg(*a), self.cfg(*b))) + }); + if !apart { + return None; + } + let live: Vec = many + .iter() + .copied() + .filter(|c| hold(self.cfg(*c), &self.configs[c.0]) != Some(false)) + .collect(); + Some(if live.is_empty() { many.to_vec() } else { live }) + } + } + } + + /// Which of several functions of one name on one type a call calls. + /// An inherent function comes before a trait's; implementations of one + /// trait at different arguments are told apart by the types of the + /// call's arguments, of which at most one can be the same by the + /// trait's coherence. + fn select( + &self, + caller: FnId, + mut candidates: Vec, + args: &[Ty], + path_call: bool, + local: bool, + ) -> Outcome { + // A function no build holds together with the caller is not called. + let own = self.cfg(caller); + candidates.retain(|c| !exclusive(own, self.cfg(*c))); + if candidates.is_empty() { + return Outcome::Outside; + } + let inherent: Vec = candidates + .iter() + .copied() + .filter(|c| self.fact(*c).implements.is_none() && !self.fact(*c).in_trait) + .collect(); + if !inherent.is_empty() { + if let Some(one) = self.one(&inherent) { + return Outcome::Resolved(one); + } + candidates = inherent; + } + // How each candidate's parameters take the arguments. + let fit = |c: FnId| -> Match { + let params = self.params(c); + // `Type::method(receiver, ..)` passes the receiver first. + let skip = usize::from(path_call && self.takes_self(c)); + if args.len() != params.len() + skip { + return Match::Different; + } + let pairs: Vec = args[skip..] + .iter() + .zip(¶ms) + .map(|(arg, param)| compare(arg, param)) + .collect(); + if pairs.contains(&Match::Different) { + Match::Different + } else if pairs.contains(&Match::Unknown) { + Match::Unknown + } else if pairs.contains(&Match::Literal) { + Match::Literal + } else { + Match::Same + } + }; + let fits: Vec<(FnId, Match)> = candidates.iter().map(|c| (*c, fit(*c))).collect(); + let of = |m: Match| -> Vec { + fits.iter() + .filter(|(_, x)| *x == m) + .map(|(c, _)| *c) + .collect() + }; + if let Some(one) = self.one(&candidates) { + // The only function of the name the workspace gives the type. + // A trait's implementation whose parameters cannot take the + // arguments is not the one called: the trait has another + // implementation outside the workspace. For a type of the + // workspace every other implementation is the standard + // library's blanket one; for a type outside it the call is + // this one only when the arguments' types say so. + let fitting = |m: Match| one.iter().all(|c| of(m).contains(c)); + let traits = one.iter().all(|c| self.fact(*c).implements.is_some()); + return if traits && fitting(Match::Different) { + Outcome::Outside + } else if local || !traits || fitting(Match::Same) { + Outcome::Resolved(one) + } else { + Outcome::Open(one) + }; + } + let same = of(Match::Same); + if let Some(one) = self.one(&same) { + return Outcome::Resolved(one); + } + let open: Vec = fits + .iter() + .filter(|(_, m)| *m != Match::Different) + .map(|(c, _)| *c) + .collect(); + if open.is_empty() { + return Outcome::Outside; + } + // An unsuffixed literal is of the one implementation whose + // parameter its kind of literal can be, and of the fallback type's + // when several can. Only a type of the workspace has all of its + // implementations in the workspace. + let literal = of(Match::Literal); + if local && same.is_empty() && literal.len() == open.len() { + if let Some(one) = self.one(&literal) { + return Outcome::Resolved(one); + } + let fallback: Vec = literal + .iter() + .copied() + .filter(|c| { + let skip = usize::from(path_call && self.takes_self(*c)); + args[skip..] + .iter() + .zip(self.params(*c)) + .all(|(arg, param)| { + let want = match arg { + Ty::Integer => INTEGER_FALLBACK, + Ty::Float => FLOAT_FALLBACK, + _ => return true, + }; + matches!(param, Ty::Named(TypeId::Prelude(p), _) if p == want) + }) + }) + .collect(); + if let Some(one) = self.one(&fallback) { + return Outcome::Resolved(one); + } + } + Outcome::Open(open) + } + + /// A function `name` of the type `id`: its own, or the one a trait it + /// implements declares with a body. + fn assoc( + &self, + caller: FnId, + id: &TypeId, + name: &str, + args: &[Ty], + path_call: bool, + ) -> Outcome { + let named = self.methods.get(name).map(Vec::as_slice).unwrap_or(&[]); + let own: Vec = named + .iter() + .copied() + .filter(|c| self.owners.get(c) == Some(id)) + .collect(); + if !own.is_empty() { + let local = matches!(id, TypeId::Local(..)); + return self.select(caller, own, args, path_call, local); + } + let declared: Vec = named + .iter() + .copied() + .filter(|c| self.fact(*c).in_trait) + .filter(|c| match (self.owners.get(c), &self.fact(*c).owner) { + (Some(_), Some(of)) => self.implemented.contains(&(id.clone(), of.clone())), + _ => false, + }) + .collect(); + match self.one(&declared) { + Some(one) => Outcome::Resolved(one), + None if declared.is_empty() => Outcome::Outside, + None => Outcome::Open(declared), + } + } + + /// What a path call calls, and the type it constructs when the path is + /// a constructor. + fn path_call( + &self, + caller: FnId, + reading: &Reading<'_>, + segments: &[String], + qself: &Option<(RustType, Option)>, + args: &[Ty], + ) -> (Outcome, Ty) { + let plain = |outcome: Outcome| (outcome, Ty::Open); + let Some((name, before)) = segments.split_last() else { + return plain(Outcome::Unknown); + }; + if let Some((of, as_trait)) = qself { + let Some(id) = head(&self.ty(reading, of, self.aliases)) else { + return plain(Outcome::Unknown); + }; + let named = self.methods.get(name).map(Vec::as_slice).unwrap_or(&[]); + let own: Vec = named + .iter() + .copied() + .filter(|c| self.owners.get(c) == Some(&id)) + .filter(|c| as_trait.is_none() || self.fact(*c).implements == *as_trait) + .collect(); + if own.is_empty() { + return plain(Outcome::Outside); + } + let local = matches!(id, TypeId::Local(..)); + return plain(self.select(caller, own, args, true, local)); + } + match before { + [one] if one == "Self" => { + return plain(match reading.this.as_ref().and_then(head) { + Some(id) => self.assoc(caller, &id, name, args, true), + None => Outcome::Unknown, + }); + } + // A type parameter's function is the one its bounds give. + [first, ..] if reading.generics.contains(first) || first == "Self" => { + return plain(Outcome::Unknown); + } + _ => {} + } + match self.path(&reading.module, segments, true, &mut Vec::new()) { + Found::Fn(module, name) => { + let declared = self + .free + .get(&(module, name)) + .map(Vec::as_slice) + .unwrap_or(&[]); + let own = self.cfg(caller); + let callable: Vec = declared + .iter() + .copied() + .filter(|c| !exclusive(own, self.cfg(*c))) + .collect(); + plain(match self.one(&callable) { + Some(one) => Outcome::Resolved(one), + None if callable.is_empty() => Outcome::Unknown, + None => Outcome::Open(callable), + }) + } + Found::Type(..) => (Outcome::Outside, self.constructed(reading, segments)), + Found::Assoc(of, rest) => { + let [name] = rest.as_slice() else { + return plain(Outcome::Unknown); + }; + let id = match *of { + Found::Type(module, of) => { + match head(&self.declared(module, of, Vec::new(), self.aliases)) { + Some(id) => id, + None => return plain(Outcome::Unknown), + } + } + Found::Prelude(of) => TypeId::Prelude(of), + _ => return plain(Outcome::Unknown), + }; + match self.assoc(caller, &id, name, args, true) { + // No function of the name: a variant's constructor. + Outcome::Outside => (Outcome::Outside, self.constructed(reading, segments)), + outcome => plain(outcome), + } + } + // A function of a type of an outside crate is the workspace's + // when the workspace implements a trait for that type. + Found::Extern(path) => match path.split_last() { + Some((name, of)) if !of.is_empty() => { + plain(self.assoc(caller, &TypeId::Extern(of.to_vec()), name, args, true)) + } + _ => plain(Outcome::Outside), + }, + Found::Prelude(_) | Found::Outside => plain(Outcome::Outside), + Found::Module(_) | Found::Absent | Found::Unknown => plain(Outcome::Unknown), + } + } + + /// What a method call calls, by the type its receiver is written with. + fn method_call(&self, caller: FnId, name: &str, receiver: &Ty, args: &[Ty]) -> Outcome { + let mut of = receiver; + while let Ty::Ref(_, inner) = of { + of = inner; + } + match of { + Ty::Named(id @ TypeId::Local(..), _) => self.assoc(caller, id, name, args, false), + // A type of an outside crate with arguments can hand the call + // on to one of them (`Box`, `Rc`), and a type parameter + // to its bounds: the code does not say here. + Ty::Named(TypeId::Prelude(_) | TypeId::Extern(_), type_args) + if type_args.is_empty() => + { + Outcome::Outside + } + Ty::Tuple(_) | Ty::Slice(_) | Ty::Array(..) | Ty::Integer | Ty::Float => { + Outcome::Outside + } + Ty::Named(..) | Ty::Ref(..) | Ty::Open => Outcome::Unknown, + } + } + + /// The type a hint stands for. + fn hint(&self, caller: FnId, reading: &Reading<'_>, hint: &Hint, done: &[(Outcome, Ty)]) -> Ty { + let of = |h: &Hint| self.hint(caller, reading, h, done); + match hint { + Hint::Open => Ty::Open, + // A type the body itself declares or imports is not the + // module's: what it names stays open. + Hint::Written(written) + if self.names(caller).is_some_and(|n| { + written + .text + .split(|c: char| !(c.is_ascii_alphanumeric() || c == '_')) + .any(|w| n.rebound.contains(w)) + }) => + { + Ty::Open + } + Hint::Written(written) => self.ty(reading, written, self.aliases), + Hint::Prim(name) => Ty::Named(TypeId::Prelude(name.clone()), Vec::new()), + Hint::Integer => Ty::Integer, + Hint::Float => Ty::Float, + Hint::Ref(mutable, inner) => Ty::Ref(*mutable, Box::new(of(inner))), + Hint::Deref(inner) => match of(inner) { + Ty::Ref(_, to) => *to, + _ => Ty::Open, + }, + Hint::This => reading.this.clone().unwrap_or(Ty::Open), + Hint::Result(i) => done.get(*i).map(|(_, ty)| ty.clone()).unwrap_or(Ty::Open), + // `?` on a `Result` or an `Option` is a `T`. + Hint::Try(inner) => match of(inner) { + Ty::Named(id, args) if unwraps(&id) => args.first().cloned().unwrap_or(Ty::Open), + _ => Ty::Open, + }, + Hint::Ctor(segments) => self.constructed(reading, segments), + Hint::Tuple(items) => Ty::Tuple(items.iter().map(of).collect()), + } + } + + /// What each call of a function calls, with the call as ingest records + /// it. `None` when the function's names were not read. + pub(crate) fn calls(&self, f: FnId) -> Option> { + let names = self.names(f)?; + let reading = self.reading(f); + // A hint names only calls before its own: arguments and receivers + // are read before the call they belong to. + let mut done: Vec<(Outcome, Ty)> = Vec::new(); + for call in &names.calls { + let args: Vec = call + .args + .iter() + .map(|h| self.hint(f, &reading, h, &done)) + .collect(); + let (outcome, constructed) = match &call.callee { + Callee::Path { opaque: true, .. } => (Outcome::Unknown, Ty::Open), + Callee::Path { + segments, qself, .. + } => self.path_call(f, &reading, segments, qself, &args), + Callee::Method { name, receiver } => { + let receiver = self.hint(f, &reading, receiver, &done); + (self.method_call(f, name, &receiver, &args), Ty::Open) + } + // A closure or a body-local function: no fact of the + // workspace, and nothing admission resolves by name. + Callee::Local(_) => (Outcome::Outside, Ty::Open), + }; + let ty = match &outcome { + // The result's type, where every variant declares the same. + Outcome::Resolved(fns) => { + let mut types = fns.iter().map(|g| self.returns(*g)); + match types.next() { + Some(first) if types.all(|t| t == first) => first, + _ => Ty::Open, + } + } + Outcome::Outside => constructed, + Outcome::Open(_) | Outcome::Unknown => Ty::Open, + }; + done.push((outcome, ty)); + } + Some( + names + .calls + .iter() + .zip(done) + .map(|(call, (outcome, _))| (call.text(), outcome)) + .collect(), + ) + } + + /// The bare type names a function's module binds to a type of a + /// registry crate, each with the crate: `Value` of `use serde_json::Value`. + pub(crate) fn registry_types(&self, f: FnId) -> BTreeMap { + let module = self.module(f); + let Some(scope) = self.scope(&module) else { + return BTreeMap::new(); + }; + // The names the module's own `use` binds, and those of the modules + // of the workspace it imports whole. + let mut names: BTreeSet<&str> = scope.uses.iter().map(|u| u.name.as_str()).collect(); + for glob in &scope.globs { + if let Found::Module(y) = self.path(&module, &glob.path, false, &mut Vec::new()) { + if let Some(imported) = self.scope(&y) { + names.extend(imported.uses.iter().map(|u| u.name.as_str())); + } + } + } + let mut out = BTreeMap::new(); + for name in names { + let path = [name.to_string()]; + if let Found::Extern(to) = self.path(&module, &path, false, &mut Vec::new()) { + if let Some(krate) = to.first().filter(|k| self.registry.contains(*k)) { + out.insert(name.to_string(), krate.clone()); + } + } + } + out + } +} + +/// What a type is named by, without its references. +fn head(ty: &Ty) -> Option { + match ty { + Ty::Ref(_, inner) => head(inner), + Ty::Named(id, _) if !matches!(id, TypeId::Param(_)) => Some(id.clone()), + _ => None, + } +} + +/// Whether `?` on the type yields its first argument: the standard +/// library's `Result` and `Option`, by the prelude's name or by path. +fn unwraps(id: &TypeId) -> bool { + match id { + TypeId::Prelude(name) => name == "Result" || name == "Option", + TypeId::Extern(path) => match path.as_slice() { + [krate, module, name] => { + (krate == "std" || krate == "core") + && ((module == "result" && name == "Result") + || (module == "option" && name == "Option")) + } + _ => false, + }, + _ => false, + } +} + +/// The workspace as its projected configuration compiles it. Two items of +/// one path under `cfg` predicates no build holds together are one fact +/// with two variants, not two facts: where the configuration compiles one +/// in and every other out, the projection states that one, and each other +/// is an open claim. Where the configuration does not decide (a predicate +/// on the target), both stay, and admission refuses the name they share. +pub(crate) fn stated(ws: &Workspace, syntax: &Syntax) -> (Workspace, Syntax, Vec) { + let mut ws = ws.clone(); + let mut syntax = syntax.clone(); + let mut refusals = Vec::new(); + for package in &mut ws.packages { + let features = syntax + .names + .features + .get(&package.dir) + .cloned() + .unwrap_or_default(); + let config = Config::dump(features); + // The items of one path: where each stands, and under what. + type Variant = (usize, usize, Vec); + // A function's path: target, module, owner, trait, whether a + // trait declares it, and its name. + type FnPath = (usize, String, Option, Option, bool, String); + let mut fns: BTreeMap> = BTreeMap::new(); + let mut enums: BTreeMap<(usize, String, String), Vec> = BTreeMap::new(); + let mut structs: BTreeMap<(usize, String, String), Vec> = BTreeMap::new(); + for (fi, file) in package.files.iter().enumerate() { + let Some(read) = syntax.names.files.get(&file.rel) else { + continue; + }; + for (idx, fact) in file.fns.iter().enumerate() { + let Some(names) = read.fns.get(&(fact.span.line, fact.name.clone())) else { + continue; + }; + let key = ( + file.target, + join(&file.module, &names.module), + fact.owner.clone(), + fact.implements.clone(), + fact.in_trait, + fact.name.clone(), + ); + fns.entry(key) + .or_default() + .push((fi, idx, names.cfg.clone())); + } + for (idx, fact) in file.enums.iter().enumerate() { + if let Some(site) = read.types.get(&(fact.span.line, fact.name.clone())) { + let key = ( + file.target, + join(&file.module, &site.module), + fact.name.clone(), + ); + enums + .entry(key) + .or_default() + .push((fi, idx, site.cfg.clone())); + } + } + for (idx, fact) in file.structs.iter().enumerate() { + if let Some(site) = read.types.get(&(fact.span.line, fact.name.clone())) { + let key = ( + file.target, + join(&file.module, &site.module), + fact.name.clone(), + ); + structs + .entry(key) + .or_default() + .push((fi, idx, site.cfg.clone())); + } + } + } + // Of each path's variants, those the configuration compiles out. + let unstated = |variants: &[Variant]| -> Vec { + let apart = variants + .iter() + .enumerate() + .all(|(i, a)| variants[i + 1..].iter().all(|b| exclusive(&a.2, &b.2))); + let held: Vec> = variants.iter().map(|v| hold(&v.2, &config)).collect(); + let one = held.iter().filter(|h| **h == Some(true)).count() == 1 + && held.iter().all(Option::is_some); + if variants.len() < 2 || !apart || !one { + return Vec::new(); + } + variants + .iter() + .zip(held) + .filter(|(_, h)| *h == Some(false)) + .map(|(v, _)| v.clone()) + .collect() + }; + let predicate = |cfg: &[Cfg]| match cfg { + [one] => one.text(), + many => Cfg::All(many.to_vec()).text(), + }; + let krate = |file: &SourceFile| package.targets[file.target].name.replace('-', "_"); + let mut drop_fns: BTreeSet<(usize, usize)> = BTreeSet::new(); + let mut drop_enums: BTreeSet<(usize, usize)> = BTreeSet::new(); + let mut drop_structs: BTreeSet<(usize, usize)> = BTreeSet::new(); + for ((_, module, owner, _, _, name), variants) in &fns { + for (fi, idx, cfg) in unstated(variants) { + let file = &package.files[fi]; + let mut parts = vec![krate(file)]; + parts.extend( + module + .split("::") + .filter(|s| !s.is_empty()) + .map(str::to_string), + ); + parts.extend(owner.clone()); + parts.push(name.clone()); + refusals.push(Refusal::CfgVariant { + span: file.fns[idx].span.clone(), + name: parts.join("::"), + predicate: predicate(&cfg), + }); + drop_fns.insert((fi, idx)); + } + } + for (types, dropped, enumeration) in [ + (&enums, &mut drop_enums, true), + (&structs, &mut drop_structs, false), + ] { + for ((_, module, name), variants) in types { + for (fi, idx, cfg) in unstated(variants) { + let file = &package.files[fi]; + let mut parts = vec![krate(file)]; + parts.extend( + module + .split("::") + .filter(|s| !s.is_empty()) + .map(str::to_string), + ); + parts.push(name.clone()); + let span = if enumeration { + file.enums[idx].span.clone() + } else { + file.structs[idx].span.clone() + }; + refusals.push(Refusal::CfgVariant { + span, + name: parts.join("::"), + predicate: predicate(&cfg), + }); + dropped.insert((fi, idx)); + } + } + } + // A fact and its syntax leave together: the two lists stay in step. + fn keep(list: &mut Vec, file: usize, dropped: &BTreeSet<(usize, usize)>) { + let mut idx = 0; + list.retain(|_| { + idx += 1; + !dropped.contains(&(file, idx - 1)) + }); + } + for (fi, file) in package.files.iter_mut().enumerate() { + let Some(file_syntax) = syntax.files.get_mut(&file.rel) else { + continue; + }; + keep(&mut file.fns, fi, &drop_fns); + keep(&mut file_syntax.fns, fi, &drop_fns); + keep(&mut file.enums, fi, &drop_enums); + keep(&mut file_syntax.enums, fi, &drop_enums); + keep(&mut file.structs, fi, &drop_structs); + keep(&mut file_syntax.structs, fi, &drop_structs); + } + } + (ws, syntax, refusals) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn cfg(text: &str) -> Vec { + let item: syn::ItemFn = + syn::parse_str(&format!("#[cfg({text})] fn f() {{}}")).expect("an item"); + Cfg::of(&item.attrs) + } + + #[test] + fn a_predicate_and_its_negation_hold_in_no_build_together() { + assert!(exclusive( + &cfg("feature = \"a\""), + &cfg("not(feature = \"a\")") + )); + assert!(exclusive( + &cfg("all(feature = \"a\", target_arch = \"wasm32\")"), + &cfg("any(not(feature = \"a\"), not(target_arch = \"wasm32\"))") + )); + // Two features can be on together, and an item without a predicate + // stands in every build. + assert!(!exclusive(&cfg("feature = \"a\""), &cfg("feature = \"b\""))); + assert!(!exclusive(&cfg("feature = \"a\""), &[])); + assert!(!exclusive( + &cfg("any(feature = \"a\", test)"), + &cfg("not(feature = \"a\")") + )); + } + + #[test] + fn the_projected_configuration_is_the_dumps() { + let config = Config::dump(["x".to_string()].into_iter().collect()); + let holds = |text: &str| hold(&cfg(text), &config); + assert_eq!(holds("feature = \"x\""), Some(true)); + assert_eq!(holds("feature = \"y\""), Some(false)); + assert_eq!(holds("test"), Some(false)); + assert_eq!(holds("not(uorust_lift)"), Some(false)); + assert_eq!(holds("debug_assertions"), Some(false)); + // The target is the host's, which the workspace does not declare. + assert_eq!(holds("target_arch = \"wasm32\""), None); + assert_eq!(holds("all(feature = \"x\", target_os = \"linux\")"), None); + assert_eq!( + holds("all(feature = \"y\", target_os = \"linux\")"), + Some(false) + ); + } + + #[test] + fn default_features_follow_cargos_rules() { + let manifest: toml::Value = "[features]\ndefault = [\"a\", \"opt/x\", \"weak?/y\"]\n\ + a = [\"b\", \"dep:hidden\"]\nb = []\nc = []\n" + .parse() + .expect("a manifest"); + let on: Vec = enabled_by_default(&manifest).into_iter().collect(); + assert_eq!(on, ["a", "b", "default", "opt"]); + let none: toml::Value = "[features]\nc = []\n".parse().expect("a manifest"); + assert!(enabled_by_default(&none).is_empty()); + } + + fn body_calls(source: &str) -> Vec { + let file: syn::File = syn::parse_str(source).expect("a file"); + let names = FileNames::of(&file); + names.fns.into_values().next().expect("a function").calls + } + + #[test] + fn a_body_is_read_with_what_it_writes_of_types() { + let calls = body_calls( + "fn f(a: u8, b: &str) { let c: Foo = make(); let d = 1.5; let (e, _) = pair(); \ + g(a, b, c, d, e, \"s\", -2, &a, x as i64); let a = other(); h(a); }", + ); + let texts: Vec = calls.iter().map(Call::text).collect(); + assert_eq!(texts, ["make", "pair", "g", "other", "h"]); + let written = |h: &Hint| match h { + Hint::Written(t) => t.text.clone(), + other => format!("{other:?}"), + }; + let args: Vec = calls[2].args.iter().map(written).collect(); + assert_eq!( + args, + [ + "u8", + "&str", + "Foo", + "Float", + "Open", + "Ref(false, Prim(\"str\"))", + "Integer", + "Ref(false, Written(RustType { text: \"u8\", kind: Path { qself: false, path: Path { segments: [PathSegment { ident: \"u8\", arguments: None }], text: \"u8\" } } }))", + "i64" + ] + ); + // A `let` without a written type has its value's: here a call's. + assert_eq!(calls[4].args, [Hint::Result(3)]); + } + + #[test] + fn a_name_the_body_binds_is_not_a_path_to_a_function() { + let calls = body_calls( + "fn f() { let run = |x: u8| x; run(1); fn inner() {} inner(); \ + { use a::b::go; go(); } go(); }", + ); + let texts: Vec = calls + .iter() + .filter(|c| !matches!(c.callee, Callee::Local(_))) + .map(Call::text) + .collect(); + assert_eq!(texts, ["a::b::go", "go"]); + let local: Vec = calls + .iter() + .filter(|c| matches!(c.callee, Callee::Local(_))) + .map(Call::text) + .collect(); + assert_eq!(local, ["run", "inner"]); + } + + // Name resolution: a call resolved as the language resolves it. + + /// What each call of each function of `source` (a library `lib.rs`) + /// resolves to, as `caller: call -> outcome`, with a function written + /// `Owner::name@line`. + fn resolutions(tag: &str, manifest_extra: &str, source: &str) -> Vec { + let dir = std::env::temp_dir().join(format!("uorust-names-{tag}-{}", std::process::id())); + std::fs::create_dir_all(dir.join("src")).unwrap(); + std::fs::write( + dir.join("Cargo.toml"), + format!("[package]\nname = \"w\"\nversion = \"0.1.0\"\nedition = \"2021\"\n{manifest_extra}"), + ) + .unwrap(); + std::fs::write(dir.join("src/lib.rs"), source).unwrap(); + let (ws, syntax) = crate::ingest::workspace(&dir, None).expect("a workspace"); + let syntax = read(&dir, &ws, syntax).expect("its names"); + let _ = std::fs::remove_dir_all(&dir); + let resolver = Resolver::new(&ws, &syntax); + let named = |g: &FnId| { + let f = &ws.packages[g.0].files[g.1].fns[g.2]; + match &f.owner { + Some(o) => format!("{o}::{}@{}", f.name, f.span.line), + None => format!("{}@{}", f.name, f.span.line), + } + }; + let mut out = Vec::new(); + for (pkg, package) in ws.packages.iter().enumerate() { + for (file, source) in package.files.iter().enumerate() { + for (idx, fact) in source.fns.iter().enumerate() { + for (call, outcome) in resolver.calls((pkg, file, idx)).unwrap_or_default() { + let to = match &outcome { + Outcome::Resolved(fns) => { + fns.iter().map(named).collect::>().join(" ") + } + Outcome::Open(fns) => format!( + "open {}", + fns.iter().map(named).collect::>().join(" ") + ), + Outcome::Outside => "outside".to_string(), + Outcome::Unknown => "unknown".to_string(), + }; + out.push(format!("{}: {call} -> {to}", fact.name)); + } + } + } + } + out + } + + #[test] + fn self_and_a_written_receiver_resolve_to_their_types_method() { + let got = resolutions( + "recv", + "", + "pub struct A;\npub struct B;\n\ + impl A {\n pub fn m(&self) -> u8 { 1 }\n pub fn f() -> u8 { 1 }\n \ + pub fn g() -> u8 { Self::f() }\n pub fn h(&self) -> u8 { self.m() }\n}\n\ + impl B {\n pub fn m(&self) -> u8 { 2 }\n pub fn f() -> u8 { 2 }\n}\n\ + pub fn by_param(x: &A) -> u8 { x.m() }\n\ + pub fn by_let() -> u8 { let x: B = B; x.m() }\n", + ); + for want in [ + "g: Self::f -> A::f@5", + "h: .m -> A::m@4", + "by_param: .m -> A::m@4", + "by_let: .m -> B::m@10", + ] { + assert!(got.iter().any(|g| g == want), "{want} not in {got:#?}"); + } + } + + #[test] + fn a_path_resolves_through_use_and_the_nearest_module() { + let got = resolutions( + "path", + "", + "use crate::left::pick;\n\ + pub mod left {\n pub fn pick() -> u8 { 1 }\n pub fn near() -> u8 { 3 }\n \ + pub fn here() -> u8 { near() }\n}\n\ + pub mod right {\n pub fn pick() -> u8 { 2 }\n pub fn near() -> u8 { 4 }\n \ + pub fn there() -> u8 { super::left::near() + pick() }\n}\n\ + pub fn through_use() -> u8 { pick() }\n", + ); + for want in [ + "here: near -> near@4", + "through_use: pick -> pick@3", + "there: super::left::near -> near@4", + // `pick` in `right` is its own, not the crate root's import. + "there: pick -> pick@8", + ] { + assert!(got.iter().any(|g| g == want), "{want} not in {got:#?}"); + } + } + + #[test] + fn a_call_the_written_code_leaves_open_stays_open() { + let got = resolutions( + "open", + "", + "pub struct A(u8);\npub struct B;\n\ + impl From for A { fn from(x: u8) -> A { A(x) } }\n\ + impl From for A { fn from(x: u16) -> A { A(x as u8) } }\n\ + pub fn unknown() -> A { A::from(Default::default()) }\n", + ); + assert!( + got.iter() + .any(|g| g.starts_with("unknown: A::from -> open ")), + "{got:#?}" + ); + } +} diff --git a/crates/uorust/src/order.rs b/crates/uorust/src/order.rs index 6edcb362..abdafefe 100644 --- a/crates/uorust/src/order.rs +++ b/crates/uorust/src/order.rs @@ -81,7 +81,13 @@ fn derived_in(ty: &Ty, types: &Types, assumed: &BTreeSet) -> bool { Ty::Unit | Ty::Bool | Ty::Nat(_) | Ty::Str | Ty::Char | Ty::Scalar => true, // A float's order is partial, and a signed bit pattern orders as // its value, not as the natural: no derived total order holds. - Ty::Int(_) | Ty::Float(_) | Ty::Signed(_) | Ty::ParseError | Ty::Path | Ty::Fn(..) => false, + Ty::Int(_) + | Ty::Integer(_) + | Ty::Float(_) + | Ty::Signed(_) + | Ty::ParseError + | Ty::Path + | Ty::Fn(..) => false, Ty::Option(t) | Ty::List(t) | Ty::Set(t, true) => derived_in(t, types, assumed), Ty::Set(_, false) | Ty::Map(_, _, false) => false, Ty::Map(k, v, true) | Ty::Outcome(k, v) => { @@ -415,6 +421,7 @@ fn body(ty: &Ty, types: &Types) -> Expr { (None, None, None) => Expr::Flat(ordering_value("Equal")), }, Ty::Int(_) + | Ty::Integer(_) | Ty::Float(_) | Ty::Signed(_) | Ty::ParseError diff --git a/crates/uorust/src/project.rs b/crates/uorust/src/project.rs index 70dbddab..f6293b99 100644 --- a/crates/uorust/src/project.rs +++ b/crates/uorust/src/project.rs @@ -10,6 +10,8 @@ use crate::facts::{Capability, FnFact, Package, SourceFile, Span, Syntax, Target use crate::ingest::summary; use crate::lex::{pascal, string, string_list, Arm, Decl, Expr, Module}; use crate::lift::{self, Candidate, Residue, Ty, Types}; +use crate::register::{queue_row, ranked, Register}; +use crate::UorustError; /// What a projection is parameterised by beyond the workspace. #[derive(Clone, Debug)] @@ -28,6 +30,12 @@ pub struct Options { /// The largest source file the projection's LexLean project admits. pub(crate) const MAX_FILE_BYTES: usize = 4_194_304; +/// The projection's own register of what it did not admit or lift. +const FRONTIER: &str = "frontier.toml"; + +/// The projection's LexLean project file, which states its limits. +const LEXLEAN: &str = "lexlean.toml"; + const ARCH: &str = "Architecture"; const IFACE: &str = "Interface"; const DESIGN: &str = "Design"; @@ -73,8 +81,16 @@ struct Model { edges: BTreeMap, /// Resolved calls: caller -> callees. calls: BTreeMap>, + /// Each call a function writes, as written, -> the one function of + /// product code the language's name resolution names at every place it + /// is written, or none where the places differ or the call is not one + /// function. Admission's reading, which the lift reads calls by too. + named: BTreeMap>>, /// The route the router admitted for each enum: `(package, file, enum)`. enum_routes: BTreeMap<(usize, usize, usize), &'static str>, + /// The bare names a function's module binds by a `use` to a type of a + /// registry crate, each with the crate. + registry: BTreeMap>, } /// What the frontier records, as the facets find it. @@ -120,7 +136,9 @@ impl Model { self.package(r).targets[file.target].name.replace('-', "_") } - /// `crate::module::Type::name`. + /// `crate::module::Type::name`; and `crate::module::::name` for a trait implementation's method whose type has + /// another method of its name, which is how Rust names the two apart. fn path(&self, r: FnRef) -> String { let file = self.file(r); let f = self.func(r); @@ -129,12 +147,24 @@ impl Model { parts.push(file.module.clone()); } if let Some(owner) = &f.owner { - parts.push(owner.clone()); + match &f.trait_ref { + Some(named) if f.apart => parts.push(format!("<{owner} as {named}>")), + _ => parts.push(owner.clone()), + } } parts.push(f.name.clone()); parts.join("::") } + /// The registry crate a type names through a `use` of the function's + /// module: `Value` where `use serde_json::Value;` binds it. + fn bound_crate(&self, r: FnRef, ty: &str) -> Option { + let bound = self.registry.get(&r)?; + ty.split(|c: char| !(c.is_ascii_alphanumeric() || c == '_' || c == ':')) + .filter_map(|word| word.split("::").next()) + .find_map(|head| bound.get(head).cloned()) + } + fn component_of(&self, r: FnRef) -> Option<&String> { self.targets.get(&(r.pkg, self.file(r).target)) } @@ -144,14 +174,19 @@ impl Model { fn record_residue(&self, notes: &mut Notes, r: FnRef, span: Span, reason: Residue) { let package = &self.ws.packages[r.pkg]; if let Residue::Type(ty) = &reason { - if let Some(dep) = foreign_crate(package, ty) { + if let Some(dep) = foreign_crate(package, ty).or_else(|| self.bound_crate(r, ty)) { let detail = format!( "takes or returns {ty}, a type of the {dep} crate with no LexLean model" ); - notes.foreign.insert(self.path(r), (span, detail)); + // A path two functions project to (a name collision) keeps + // one row: residue, wherever one of them is residue. + if !notes.residue.contains_key(&self.path(r)) { + notes.foreign.insert(self.path(r), (span, detail)); + } return; } } + notes.foreign.remove(&self.path(r)); notes.residue.insert(self.path(r), (span, reason)); } @@ -228,14 +263,22 @@ fn kebab(name: &str) -> String { out } -/// The whole projection: path -> bytes. +/// The whole projection: path -> bytes. There is none where the function +/// rows it would write are not a lift register, or where a module it would +/// write is larger than the limit its own `lexlean.toml` states. pub(crate) fn project( ws: &Workspace, syntax: &Syntax, options: &Options, dumps: Option<&crate::mir::Dumps>, -) -> BTreeMap> { +) -> Result>, UorustError> { let mut notes = Notes::default(); + // Items under `cfg` predicates no build holds together are one fact: + // the projection states the variant its configuration compiles. + let (ws, syntax, variants) = crate::names::stated(ws, syntax); + let (ws, syntax) = (&ws, &syntax); + notes.refusals.extend(variants); + let resolver = crate::names::Resolver::new(ws, syntax); for package in &ws.packages { for file in &package.files { if let Some(reason) = &file.parse_error { @@ -263,11 +306,20 @@ pub(crate) fn project( index, edges: BTreeMap::new(), calls: BTreeMap::new(), + named: BTreeMap::new(), enum_routes: BTreeMap::new(), + registry: BTreeMap::new(), }; + ctx.registry = ctx + .all_fns() + .into_iter() + .map(|r| (r, resolver.registry_types((r.pkg, r.file, r.idx)))) + .filter(|(_, bound)| !bound.is_empty()) + .collect(); ctx.edges = edges(&ctx); - let (calls, refused) = resolve(&ctx); + let (calls, named, refused) = resolve(&ctx, &resolver); ctx.calls = calls; + ctx.named = named; notes.refusals.extend(refused); let (enum_routes, refused) = route_enums(&ctx); ctx.enum_routes = enum_routes; @@ -298,12 +350,30 @@ pub(crate) fn project( } } let security = security(&ctx, options); - let (quality, refused) = quality(&ctx, iface.feature_count); - notes.refusals.extend(refused); let mir = dumps.zip(options.mir.as_ref()); let (behavior, candidates) = behavior(&ctx, syntax, &mut notes, mir); let supply = supply(&ctx); let library = library(ws, &prefix, &behavior, &mut notes); + // The κ of every function of product code: the question its row answers. + let kappas: BTreeMap = ctx + .all_fns() + .into_iter() + .filter(|&r| ctx.product(r)) + .map(|r| { + let path = ctx.path(r); + let kappa = crate::register::kappa(&path, &ctx.func(r).tokens); + (path, kappa) + }) + .collect(); + // The lift register of this run, read from the function rows the + // frontier is about to carry: what the queue ranks and the Quality facet + // measures is what a reader of the frontier finds. + let rows = function_rows(¬es, &kappas); + let lift = Register::parse(std::path::Path::new(FRONTIER), &rows)?; + // Quality is written last of the facets: it measures what the others + // admitted, refused and lifted. + let (quality, refused) = quality(&ctx, iface.feature_count, &lift, ¬es.refusals); + notes.refusals.extend(refused); modules.push(arch); modules.push(iface.module); modules.push(design); @@ -322,12 +392,31 @@ pub(crate) fn project( } let mut entrypoints: Vec = files .keys() - .filter(|p| p.ends_with(".lex.tex")) + .filter(|p| p.ends_with(MODULE_SUFFIX)) .cloned() .collect(); - for module in &modules { - entrypoints.push(module.path()); - files.insert(module.path(), module.render().into_bytes()); + // Every file that is no generated module comes first: beside the modules + // themselves, these are what can cite a record of one by its ID. + for (path, bytes) in register(&iface.register) { + files.insert(path, bytes); + } + files.insert("supply/spdx.json".into(), spdx(ws, options).into_bytes()); + // The prover's trial run lists the translations it admitted on trial. + if let Some(listing) = candidates { + files.insert(crate::mir::CANDIDATES.into(), listing.into_bytes()); + } + files.insert(FRONTIER.into(), frontier(¬es, &lift, &rows).into_bytes()); + let cited = |id: &str| { + files + .values() + .any(|bytes| String::from_utf8_lossy(bytes).contains(id)) + }; + // Each module within the limit the project file below states, in parts + // where it is beyond it and its declarations can be written apart. + let written = sized(&modules, MAX_FILE_BYTES, &cited); + for (path, text) in written { + entrypoints.push(path.clone()); + files.insert(path, text.into_bytes()); } entrypoints.sort(); let toml_name: String = options @@ -387,7 +476,7 @@ pub(crate) fn project( build_root = \".prism\"\n\n[limits]\nmax_holo_bytes = 16777216\nmax_entities = 100000\n\ max_diagnostics = 256\n" ); - files.insert("lexlean.toml".into(), lexlean.into_bytes()); + files.insert(LEXLEAN.into(), lexlean.into_bytes()); files.insert("lexlean.lock".into(), lock.into_bytes()); files.insert("lakefile.toml".into(), lakefile.into_bytes()); files.insert("lake-manifest.json".into(), manifest.into_bytes()); @@ -397,30 +486,8 @@ pub(crate) fn project( ".gitignore".into(), b"/.lexlean/\n/.prism/\n/.lake/\n".to_vec(), ); - for (path, bytes) in register(&iface.register) { - files.insert(path, bytes); - } - files.insert("supply/spdx.json".into(), spdx(ws, options).into_bytes()); - // The prover's trial run lists the translations it admitted on trial. - if let Some(listing) = candidates { - files.insert(crate::mir::CANDIDATES.into(), listing.into_bytes()); - } - // The κ of every function of product code: the question its row answers. - let kappas: BTreeMap = ctx - .all_fns() - .into_iter() - .filter(|&r| ctx.product(r)) - .map(|r| { - let path = ctx.path(r); - let kappa = crate::register::kappa(&path, &ctx.func(r).tokens); - (path, kappa) - }) - .collect(); - files.insert( - "frontier.toml".into(), - frontier(¬es, &kappas).into_bytes(), - ); - files + within_limit(&files)?; + Ok(files) } /// The LexLean compiler semantics a projection locks to: the one UORust's own @@ -755,10 +822,21 @@ fn edges(ctx: &Model) -> BTreeMap { edges } -/// Resolve every path call and unique method call to workspace functions. +/// Resolve every call to workspace functions: by the language's own name +/// resolution where the written code decides it ([`crate::names`]), and by +/// name where those rules could not follow the call. #[allow(clippy::type_complexity)] -fn resolve(ctx: &Model) -> (BTreeMap>, Vec) { +fn resolve( + ctx: &Model, + resolver: &crate::names::Resolver<'_>, +) -> ( + BTreeMap>, + BTreeMap>>, + Vec, +) { + use crate::names::Outcome; let mut calls = BTreeMap::new(); + let mut named: BTreeMap>> = BTreeMap::new(); let mut refusals = Vec::new(); let all = ctx.all_fns(); let mut by_name: BTreeMap<&str, Vec> = BTreeMap::new(); @@ -782,10 +860,70 @@ fn resolve(ctx: &Model) -> (BTreeMap>, Vec) { .map(move |t| (t.name.replace('-', "_"), pkg)) }) .collect(); + let fn_ref = |(pkg, file, idx): crate::names::FnId| FnRef { pkg, file, idx }; for &caller in &all { let f = ctx.func(caller); let mut out = BTreeSet::new(); - for call in &f.calls { + let ruled: Vec<(String, Option)> = + match resolver.calls((caller.pkg, caller.file, caller.idx)) { + Some(list) => list.into_iter().map(|(c, o)| (c, Some(o))).collect(), + None => f.calls.iter().map(|c| (c.clone(), None)).collect(), + }; + for (call, outcome) in &ruled { + // Product code's functions only, as by name below. + let product = |fns: &[crate::names::FnId]| -> Vec { + let mut v: Vec = fns.iter().map(|g| fn_ref(*g)).collect(); + v.retain(|r| ctx.product(*r)); + v + }; + if outcome.is_some() { + let one = match outcome { + Some(Outcome::Resolved(fns)) => match product(fns).as_slice() { + [only] => Some(*only), + _ => None, + }, + _ => None, + }; + let reading = named.entry(caller).or_default(); + let agreed = reading + .get(call) + .map_or(one, |seen| one.filter(|_| *seen == one)); + reading.insert(call.clone(), agreed); + } + match outcome { + // One function, or the variants of one no build holds + // together: the call reaches each. + Some(Outcome::Resolved(fns)) => { + out.extend(product(fns)); + continue; + } + Some(Outcome::Outside) => continue, + // The written code leaves it open between these. + Some(Outcome::Open(fns)) => { + match product(fns).as_slice() { + [] => {} + [only] => { + out.insert(*only); + } + many => { + let mut names: Vec = many + .iter() + .map(|r| { + format!("{} ({})", ctx.path(*r), ctx.func(*r).span.render()) + }) + .collect(); + names.sort(); + refusals.push(Refusal::AmbiguousCall { + span: f.span.clone(), + callee: call.clone(), + candidates: names, + }); + } + } + continue; + } + Some(Outcome::Unknown) | None => {} + } if let Some(method) = call.strip_prefix('.') { let candidates: Vec = by_name .get(method) @@ -925,7 +1063,7 @@ fn resolve(ctx: &Model) -> (BTreeMap>, Vec) { calls.insert(caller, out); } } - (calls, refusals) + (calls, named, refusals) } fn record(ty: &str, fields: &[(&str, String)]) -> String { @@ -2868,7 +3006,18 @@ fn truncate(text: &str, limit: usize) -> String { } } -fn quality(ctx: &Model, features: usize) -> (Module, Vec) { +/// The Quality facet. Beside what it counts in the workspace, it states the +/// lift and the admission as measures of the model: the functions of product +/// code and those of them that lifted, from `lift` (the register this run +/// writes), and the open refusals, `admitted`'s and its own. Each is a +/// measured count under its own requirement, as every other measure here is; +/// none is a threshold the tool chose. +fn quality( + ctx: &Model, + features: usize, + lift: &Register, + admitted: &BTreeSet, +) -> (Module, Vec) { let mut refusals = Vec::new(); let ws = &ctx.ws; let q = "Foundation.Qual::"; @@ -2938,6 +3087,14 @@ fn quality(ctx: &Model, features: usize) -> (Module, Vec) { } } let crates = ws.packages.len(); + // The refusals the frontier will count: the other facets' and the ones + // found above, each once. + let open_refusals = admitted + .iter() + .chain(&refusals) + .collect::>() + .len(); + let lift = lift.totals(); // (characteristic, subcharacteristic, measure, threshold) let mut measures: Vec<(&str, &str, &str, usize)> = vec![ ( @@ -2946,6 +3103,24 @@ fn quality(ctx: &Model, features: usize) -> (Module, Vec) { "AdmittedFeatures", features, ), + ( + "FunctionalSuitability", + "FunctionalCompleteness", + "OpenRefusals", + open_refusals, + ), + ( + "FunctionalSuitability", + "FunctionalCompleteness", + "ProductFunctions", + lift.functions, + ), + ( + "FunctionalSuitability", + "FunctionalCompleteness", + "LiftedFunctions", + lift.lifted, + ), ( "Maintainability", "Analysability", @@ -3161,6 +3336,8 @@ fn behavior( structs: BTreeMap)>, datas: BTreeMap, spans: BTreeMap, + /// The names of the keys declared twice, which name no one type. + twice: BTreeSet, } let mut declared: Vec = Vec::new(); for (pkg, package) in ws.packages.iter().enumerate() { @@ -3237,6 +3414,7 @@ fn behavior( d.enums.remove(key); d.structs.remove(key); d.datas.remove(key); + d.twice.insert(key.2.clone()); } declared.push(d); } @@ -3272,7 +3450,10 @@ fn behavior( .iter() .map(|key| { let (target, module, name) = key; - let lex = if everywhere[name] == 1 { + // A name LexLean writes for a type of its own (`Prop`) is + // shared with it as with another crate's type. + let taken = lift::name_taken(name, !d.enums.contains_key(key)); + let lex = if everywhere[name] == 1 && !taken { name.clone() } else if in_crate[name.as_str()] == 1 { format!("{}{name}", pascal(&[&package.name])) @@ -3402,7 +3583,7 @@ fn behavior( aliases.insert(rust.to_string(), crate::order::ORDERING.to_string()); } // A field's type is read in the file that declares it. - let structs: Fields = d + let mut structs: Fields = d .structs .into_iter() .map(|(key, (fi, fs))| { @@ -3445,6 +3626,21 @@ fn behavior( .collect::>() }) .collect(); + // A name of the crate that reads as no one type is registered + // with the reason, so that a row it stops states it: a key + // declared twice, and a name several of the crate's types + // share where a file does not say which it means. + let unread = d + .twice + .iter() + .map(|n| (n, lift::DECLARED_TWICE)) + .chain(ambiguous[pkg].iter().map(|n| (n, lift::SHARED_NAME))); + for (name, why) in unread { + let free = !enums.contains_key(name) && !datas.contains_key(name); + if free && !structs.contains_key(name) { + structs.insert(name.clone(), vec![lift::unread_shape(why)]); + } + } Types { derives, ..Types::with_data(enums, &datas, &structs, aliases) @@ -3563,20 +3759,47 @@ fn behavior( .iter() .map(|_| (Vec::new(), BTreeMap::new())) .collect(); + // How many functions of product code each path names, and how many + // methods each type has of each name over its crate. Rust reads + // `Type::name` and `value.name()` as the type's one method of that name, + // an inherent one before a trait's. + let mut pathed: BTreeMap = BTreeMap::new(); + let mut methods: BTreeMap<(usize, String, String), usize> = BTreeMap::new(); + for &r in all.iter().filter(|&&r| ctx.product(r)) { + *pathed.entry(ctx.path(r)).or_default() += 1; + let f = ctx.func(r); + if let (Some(o), false) = (&f.owner, f.in_trait) { + let owner = file_scopes[&(r.pkg, r.file)].resolve(o); + *methods.entry((r.pkg, owner, f.name.clone())).or_default() += 1; + } + } + // The trait methods a call can mean, each with its crate, the key such a + // call reads and its own key; and the candidates that give way. + let mut reach: Vec<(usize, String, String, FnRef)> = Vec::new(); + let mut yielding: BTreeMap<(usize, String), u8> = BTreeMap::new(); for &r in &all { let f = ctx.func(r); let types = &file_scopes[&(r.pkg, r.file)]; if !ctx.product(r) { continue; } - // Inherent methods of a type the lift names lift with `self` as their - // first parameter; trait methods and methods of other types stop, each - // with a row of its own. + // Methods of a type the lift names lift with `self` as their first + // parameter, inherent ones and a trait implementation's alike; + // methods of other types stop, each with a row of its own that says + // why its type is outside the lift. let known = |o: &String| { types.enums.contains_key(&types.resolve(o)) || types.structs.contains_key(&types.resolve(o)) || types.datas.contains_key(&types.resolve(o)) }; + // A path Rust's own naming leaves to two trait methods (an impl or + // a trait declared once per configuration) is one row, and names + // neither of them. + if (f.implements.is_some() || f.in_trait) && pathed[&ctx.path(r)] > 1 { + ctx.stopped(notes, &effectful, r, Residue::Collision(ctx.path(r))); + continue; + } + let fn_syntax = syntax.function(&ctx.file(r).rel, r.idx); // `Display::fmt` lifts as the function from the value to the text // it writes: `write!` into its formatter is that `format!`. let display = matches!( @@ -3585,45 +3808,76 @@ fn behavior( ); let method = match (&f.owner, &f.implements) { (None, _) => None, - (Some(o), Some(_)) if display => Some(types.resolve(o)), - (Some(_), _) if f.in_trait => { - let reason = Residue::Signature("a method a trait declares".to_string()); - ctx.stopped(notes, &effectful, r, reason); - continue; - } - // A trait method over a registry crate's types, such as a `syn` - // visitor, is the converter shell's: a foreign row. - (Some(_), Some(t)) => { - let sig = &syntax.function(&ctx.file(r).rel, r.idx).signature; - let foreign = sig - .inputs - .iter() - .filter_map(|i| match i { - crate::ast::FnArg::Typed(p) => Some(p.ty.text.clone()), - crate::ast::FnArg::Receiver { .. } => None, - }) - .chain(sig.output.iter().map(|o| o.text.clone())) - .find(|ty| foreign_crate(&ctx.ws.packages[r.pkg], ty).is_some()); - let reason = match foreign { - Some(ty) => Residue::Type(ty), - None => Residue::Signature(format!("implements the trait {t}")), + // A method a trait declares: its default body, where it is one + // function for every implementing type. + (Some(declarer), _) if f.in_trait => { + let refusal = match &fn_syntax.block { + None => Some(Residue::Signature(format!( + "a method {declarer} declares without a body, which each implementing \ + type gives" + ))), + Some(block) => default_refusal(ctx.file(r), f, declarer, block), }; - ctx.stopped(notes, &effectful, r, reason); - continue; - } - (Some(o), None) - if types.enums.contains_key(&types.resolve(o)) - || types.structs.contains_key(&types.resolve(o)) - || types.datas.contains_key(&types.resolve(o)) => - { - Some(types.resolve(o)) + if let Some(reason) = refusal { + ctx.stopped(notes, &effectful, r, reason); + continue; + } + None } - (Some(o), None) => { - ctx.stopped(notes, &effectful, r, Residue::Type(o.clone())); - continue; + (Some(o), Some(_)) if display => Some(types.resolve(o)), + (Some(o), implements) => { + // A trait method over a registry crate's types, such as a + // `syn` visitor, is the converter shell's: a foreign row. + let foreign = implements.as_ref().and_then(|_| { + let sig = &fn_syntax.signature; + sig.inputs + .iter() + .filter_map(|i| match i { + crate::ast::FnArg::Typed(p) => Some(p.ty.text.clone()), + crate::ast::FnArg::Receiver { .. } => None, + }) + .chain(sig.output.iter().map(|o| o.text.clone())) + .find(|ty| foreign_crate(&ctx.ws.packages[r.pkg], ty).is_some()) + }); + if let Some(ty) = foreign { + ctx.stopped(notes, &effectful, r, Residue::Type(ty)); + continue; + } + // An impl with parameters of its own is one impl for each + // type or constant that takes their place, and its methods + // are generic as a function with parameters is. + if implements.is_some() && !f.impl_params.is_empty() { + let reason = Residue::Signature(format!( + "a method of an impl generic in {}: one function for each type or \ + constant that takes its place", + f.impl_params.join(", ") + )); + ctx.stopped(notes, &effectful, r, reason); + continue; + } + if known(o) { + Some(types.resolve(o)) + } else if foreign_crate(&ctx.ws.packages[r.pkg], o).is_some() { + ctx.stopped(notes, &effectful, r, Residue::Type(o.clone())); + continue; + } else { + // The type and why the lift does not name it: a type + // the workspace registers by the chain down to its + // leaf, as a parameter of the type is, and any other by + // what the crate's source shows. The leaf decides the + // row: a registry crate's type there makes it foreign. + let reason = if types.outside.contains_key(&types.resolve(o)) { + types.unnamed(o) + } else { + let why = + unlifted_type(ctx, syntax, &file_scopes, &expanded, r.pkg, r.file, o); + Residue::Type(format!("{o}, {why}")) + }; + ctx.stopped(notes, &effectful, r, reason); + continue; + } } }; - let fn_syntax = syntax.function(&ctx.file(r).rel, r.idx); let mut sig = fn_syntax.signature.clone(); for input in &mut sig.inputs { if let crate::ast::FnArg::Typed(t) = input { @@ -3654,17 +3908,81 @@ fn behavior( ctx.file(r).module.clone(), f.name.clone(), ); - let (rust, name) = match (&method, homonyms.get(&site)) { - (Some(o), _) => ( - format!("{o}::{}", f.name), - lift::local_name(&format!("{o}_{}", f.name)), + // The key a call written `Type::name` or `value.name()` reads, where + // this is a trait's method such a call can mean. + let mut reached = None; + let (rust, name) = match (&method, &f.owner, homonyms.get(&site)) { + (Some(o), _, _) => { + let plain = ( + format!("{o}::{}", f.name), + lift::local_name(&format!("{o}_{}", f.name)), + ); + let sole = methods[&(r.pkg, o.clone(), f.name.clone())] == 1; + match &f.trait_ref { + None => plain, + // The text a value displays as keeps the key and the + // name it had: no call reads it, `write!` and `format!` + // do. + Some(_) if display && sole => plain, + // A trait's method lifts under a key no call writes, + // and each scope that sees the trait reads the call's + // key as it (`trait_in_scope`). Where its type has + // another method of the name, Rust names this one by + // its trait and no call is read as it. Nor where the + // trait is generic: it is implemented once per argument + // list (`From` beside `From` and core's own + // `From for T`), and Rust picks among them by the + // types at the call. Its definition is named by its + // type and its trait whatever else its type has, so the + // name is one for each trait of a type and each type of + // a trait, and a method the type gains later leaves it. + Some(t) => { + if sole && !t.contains('<') { + reached = Some(plain.0); + } + ( + format!("{o}::<{t}>::{}", f.name), + lift::local_name(&format!("{o}_{t}_{}", f.name)), + ) + } + } + } + // A default method lifts under its trait's name, and under a + // key no call writes: a call means an implementing type's. + (None, Some(declarer), _) => ( + format!("<{declarer}>::{}", f.name), + lift::local_name(&format!("{declarer}_{}", f.name)), ), - (None, Some((rust, lex))) => (rust.clone(), lex.clone()), - (None, None) => (f.name.clone(), lift::local_name(&f.name)), + (None, None, Some((rust, lex))) => (rust.clone(), lex.clone()), + (None, None, None) => (f.name.clone(), lift::local_name(&f.name)), + }; + // What a call of the function by itself is written as: a free + // function's name, a method's key, and a trait's method as its own + // scope reads it. + let called = match (&method, &f.owner, &reached) { + (None, None, _) => f.name.clone(), + (_, _, Some(plain)) if trait_in_scope(ctx, r, r) => plain.clone(), + _ => rust.clone(), }; - let called = match &method { - Some(_) => rust.clone(), - None => f.name.clone(), + if let Some(plain) = reached { + reach.push((r.pkg, plain, rust.clone(), r)); + } + // Who keeps a name two functions lift to, whichever the projection + // reaches first: a free function before a type's own method + // (`sample_cases` beside `Sample::cases`), and that before a + // trait's method. + let yields: u8 = if f.in_trait || (f.implements.is_some() && !display) { + 2 + } else { + u8::from(method.is_some()) + }; + let owner = match (&method, &f.owner) { + (Some(o), _) => Some(lift::Owner::Type { + name: o, + receiver: f.receiver.as_deref(), + }), + (None, Some(_)) => Some(lift::Owner::Implementor), + (None, None) => None, }; let (candidates, names) = &mut scoped[r.pkg]; let signature = match (&formatter, &method) { @@ -3679,11 +3997,28 @@ fn behavior( (None, _) if display => Err(Residue::Signature( "a Display impl whose formatter is not a plain parameter".to_string(), )), - _ => types.signature(sig, method.as_deref()), + _ => types.signature(sig, owner.as_ref()), }; match signature { Ok((params, result)) => { - if names.contains_key(&rust) + let holder = candidates + .iter() + .position(|c: &Candidate<'_>| c.name == name) + .filter(|&i| { + !names.contains_key(&rust) + && yielding + .get(&(r.pkg, candidates[i].rust.clone())) + .is_some_and(|held| yields < *held) + }); + if let Some(held) = holder.and_then(|i| names.remove(&candidates[i].rust)) { + // The name's holder gives way, and keeps its row. + candidates.retain(|c| c.name != name); + notes.refusals.insert(Refusal::Collision { + span: ctx.func(held).span.clone(), + name: qualified(BEHAVIOR, &name), + }); + ctx.stopped(notes, &effectful, held, Residue::Collision(name.clone())); + } else if names.contains_key(&rust) || candidates.iter().any(|c: &Candidate<'_>| c.name == name) { notes.refusals.insert(Refusal::Collision { @@ -3694,6 +4029,7 @@ fn behavior( ctx.stopped(notes, &effectful, r, Residue::Collision(name)); continue; } + yielding.insert((r.pkg, rust.clone()), yields); names.insert(rust.clone(), r); candidates.push(Candidate { rust, @@ -3703,7 +4039,7 @@ fn behavior( block, imports: ctx.file(r).imports.clone(), aliases: overlays[&(r.pkg, r.file)].clone(), - homonyms: homonym_reading(ctx, &homonyms, r.pkg, r.file), + homonyms: call_reading(ctx, &homonyms, r), called, formatter, }); @@ -3756,6 +4092,18 @@ fn behavior( } } } + // Each candidate reads a call's key as the trait's method where its + // scope sees the trait, and as no function where it does not. A + // constant's value calls no trait's method. + for (pkg, (candidates, names)) in scoped.iter_mut().enumerate() { + for c in candidates.iter_mut() { + let caller = names.get(&c.rust).copied(); + for (_, plain, key, imp) in reach.iter().filter(|(p, ..)| *p == pkg) { + let seen = caller.is_some_and(|caller| trait_in_scope(ctx, caller, *imp)); + c.homonyms.insert(plain.clone(), seen.then(|| key.clone())); + } + } + } let mut shared: BTreeMap = BTreeMap::new(); for (candidates, _) in &scoped { for c in candidates { @@ -3824,8 +4172,21 @@ fn behavior( out.decls.iter().any(|d| d.name() == c.name), names.get(&c.rust), ) { + // A path has one row and one κ. Two functions share a path + // where two traits give one type a method of one name (the + // `fmt` of `Display` and of `Debug`): where the other did + // not lift, the path's row stays the one that says so, + // since the κ the register holds for the path may be + // either function's. + let path = ctx.path(r); + if notes.residue.contains_key(&path) + || notes.foreign.contains_key(&path) + || notes.effects.contains_key(&path) + { + continue; + } notes.lifted.insert( - ctx.path(r), + path, ( ctx.func(r).span.clone(), qualified(BEHAVIOR, &c.name), @@ -4900,6 +5261,322 @@ fn toml_string(text: &str) -> String { /// target, module and name. type FnSite = (usize, usize, String, String); +/// Whether the trait a method implements is in scope where `caller` stands: +/// Rust reads `Type::name` and `value.name()` as a trait's method there +/// alone. Three rules of the language decide it, and whatever they leave +/// open counts as out of scope, so a call is refused before it is misread: +/// the scope that names a trait by one segment has it in scope (it declares +/// the trait, imports it, or takes it from the prelude); a name the impl's +/// scope neither declares nor imports, with no glob that could bind it, is +/// the standard prelude's, in scope everywhere in a crate that keeps its +/// prelude; and a file's own scope has a trait it declares or imports by a +/// path that leads to the trait's declaration (`declared_trait`). +fn trait_in_scope(ctx: &Model, caller: FnRef, imp: FnRef) -> bool { + let method = ctx.func(imp); + let Some(path) = &method.trait_path else { + return false; + }; + let single = !path.contains("::"); + let from = ctx.func(caller); + if single && caller.pkg == imp.pkg && caller.file == imp.file && from.scope == method.scope { + return true; + } + let package = &ctx.ws.packages[imp.pkg]; + let home = &ctx.file(imp).scopes[method.scope]; + let bound = home.traits.contains(path) || home.uses.iter().any(|(n, _)| n == path); + if single && !bound && !home.glob { + return caller.pkg == imp.pkg && !package.files.iter().any(|f| f.no_prelude); + } + if caller.pkg != imp.pkg || from.scope != 0 || method.scope != 0 { + return false; + } + let Some(named) = declared_trait(ctx, imp.pkg, imp.file, path) else { + return false; + }; + let here = ctx.file(caller); + let (file, name) = &named; + (*file == caller.file && here.scopes[0].traits.contains(name)) + || here.scopes[0].uses.iter().any(|(_, used)| { + declared_trait(ctx, caller.pkg, caller.file, used).as_ref() == Some(&named) + }) +} + +/// The trait a path names from a file's own scope: the file of the crate +/// that declares it, and its name there. The path is read as Rust reads it, +/// through the scope's own `use` bindings, from a module the scope declares +/// and from `crate`, `self` and `super`, and through each module that only +/// re-exports the name. A path +/// into another crate, and one Rust would read from a name this does not +/// see, names no trait here. +fn declared_trait(ctx: &Model, pkg: usize, fi: usize, path: &str) -> Option<(usize, String)> { + let files = &ctx.ws.packages[pkg].files; + let mut at = fi; + let mut path = path.to_string(); + let mut seen: BTreeSet<(usize, String)> = BTreeSet::new(); + // Each step moves to another module's file or reads another binding, and + // no step is taken twice. + while seen.insert((at, path.clone())) { + let file = &files[at]; + let scope = file.scopes.first()?; + let mut segs: Vec<&str> = path.split("::").collect(); + let first = *segs.first()?; + if first.is_empty() { + return None; + } + if segs.len() == 1 && scope.traits.iter().any(|t| t == first) { + return Some((at, first.to_string())); + } + let own = scope.mods.iter().any(|m| m == first); + if !own && !matches!(first, "crate" | "self" | "super") { + // The scope's own binding of the first name, read in its place. + let (_, bound) = scope + .uses + .iter() + .find(|(n, used)| n == first && *used != path)?; + let rest = segs[1..].join("::"); + path = match rest.is_empty() { + true => bound.clone(), + false => format!("{bound}::{rest}"), + }; + continue; + } + let mut module: Vec<&str> = file.module.split("::").filter(|s| !s.is_empty()).collect(); + match first { + "crate" => { + module.clear(); + segs.remove(0); + } + "self" => { + segs.remove(0); + } + _ => {} + } + while segs.first() == Some(&"super") { + module.pop()?; + segs.remove(0); + } + let name = segs.pop()?; + module.extend(segs); + let module = module.join("::"); + at = files + .iter() + .position(|f| f.target == file.target && f.module == module)?; + path = name.to_string(); + } + None +} + +/// Why a default method a trait declares is not one function for every +/// implementing type, if it is not: it calls a method through `self` or +/// `Self`, which is each implementing type's (the trait's own body of it is +/// one an implementation may replace), or reads `self` or names `Self` +/// otherwise. `None` for a body that does neither: it means the same for +/// every implementing type, and lifts as written. +fn default_refusal( + file: &SourceFile, + f: &FnFact, + declarer: &str, + block: &crate::ast::Block, +) -> Option { + let mut called = Vec::new(); + calls_through_self(block, &mut called); + if let Some(method) = called.first() { + let declared = file + .fns + .iter() + .find(|g| g.in_trait && g.owner.as_deref() == Some(declarer) && &g.name == method); + let whose = match declared { + Some(g) if g.tokens.ends_with('}') => format!( + "{declarer}::{method}, whose body in the trait an implementing type may replace" + ), + Some(_) => format!("{declarer}::{method}, which the trait declares without a body"), + None => format!("{method}, which {declarer} does not declare"), + }; + return Some(Residue::Signature(format!( + "a default method of {declarer} that calls {whose}: it means each implementing \ + type's" + ))); + } + let words = |word: &str| { + f.tokens + .split(|c: char| !(c.is_alphanumeric() || c == '_')) + .filter(|w| *w == word) + .count() + }; + if words("Self") > 0 { + return Some(Residue::Signature(format!( + "a default method of {declarer} that names Self, each implementing type" + ))); + } + // The receiver is the one `self` a signature writes. + if words("self") > usize::from(f.receiver.is_some()) { + return Some(Residue::Signature(format!( + "a default method of {declarer} that reads self, each implementing type's value" + ))); + } + None +} + +/// The methods a body calls on `self` and the functions it calls as +/// `Self::name`, in source order. +fn calls_through_self(block: &crate::ast::Block, out: &mut Vec) { + use crate::ast::{RustExpr, Stmt, UnOp}; + fn is_self(e: &RustExpr) -> bool { + match e { + RustExpr::Path(p) => p.is_ident("self"), + RustExpr::Paren(inner) => is_self(inner), + RustExpr::Reference(r) => is_self(&r.expr), + RustExpr::Unary(u) => matches!(u.op, UnOp::Deref) && is_self(&u.expr), + _ => false, + } + } + fn expr(e: &RustExpr, out: &mut Vec) { + match e { + RustExpr::MethodCall(m) if is_self(&m.receiver) => out.push(m.method.clone()), + RustExpr::Call(c) => { + if let RustExpr::Path(p) = &*c.func { + if let [owner, name] = p.segments.as_slice() { + if owner.ident == "Self" { + out.push(name.ident.clone()); + } + } + } + } + RustExpr::Macro(m) => { + for arg in m.args.iter().flat_map(|a| &a.items) { + expr(arg, out); + } + } + _ => {} + } + let (exprs, blocks) = e.parts(); + for inner in exprs { + expr(inner, out); + } + for inner in blocks { + calls_through_self(inner, out); + } + } + for stmt in &block.stmts { + match stmt { + Stmt::Local(l) => { + if let Some(init) = &l.init { + expr(&init.expr, out); + if let Some(diverge) = &init.diverge { + expr(diverge, out); + } + } + } + Stmt::Expr(e, _) => expr(e, out), + Stmt::Macro(m) => { + for arg in m.args.iter().flat_map(|a| &a.items) { + expr(arg, out); + } + } + Stmt::Other => {} + } + } +} + +/// Why the lift does not name the type a method is of, as the file `fi` of +/// package `pkg` writes it: the shape it is declared in, or the first of +/// its fields whose type is outside the lift and, where that is another +/// type of the crate, why that one is, down to a type the crate does not +/// declare. Each type is explained once, so a family of types that hold +/// each other ends. +fn unlifted_type( + ctx: &Model, + syntax: &Syntax, + scopes: &BTreeMap<(usize, usize), Types>, + expanded: &dyn Fn(usize, &crate::ast::RustType) -> crate::ast::RustType, + pkg: usize, + fi: usize, + written: &str, +) -> String { + let package = &ctx.ws.packages[pkg]; + let mut seen: BTreeSet = BTreeSet::new(); + let mut out: Vec = Vec::new(); + let mut next = Some((fi, written.to_string())); + while let Some((from, ty)) = next.take() { + // The name a declaration would carry: the path's last segment, + // without its arguments. + let head = ty.split('<').next().unwrap_or(&ty); + let name = head.rsplit("::").next().unwrap_or(head).trim().to_string(); + let plain = name.chars().all(|c| c.is_alphanumeric() || c == '_') && !name.is_empty(); + if !plain || !seen.insert(name.clone()) { + out.push(if plain { + "which holds itself where no inductive type can".to_string() + } else { + "which is not a struct or an enum by name".to_string() + }); + break; + } + if ty.contains('<') && out.is_empty() { + out.push( + "written with arguments, where a method's type is read by its name alone" + .to_string(), + ); + break; + } + // Its declaration: the writing file's own, else the crate's first. + let order = std::iter::once(from).chain((0..package.files.len()).filter(|i| *i != from)); + let mut found = None; + for at in order { + let file = &package.files[at]; + let read = &syntax.files[&file.rel]; + if let Some(shape) = file.unread.iter().find(|(n, _)| *n == name) { + found = Some(Err(shape.1.to_string())); + } else if let Some(i) = file.structs.iter().position(|st| st.name == name) { + let fields = read.structs[i] + .iter() + .map(|(field, t)| (format!("field {field}"), t.clone())) + .collect::>(); + found = Some(Ok((at, fields))); + } else if let Some(i) = file.enums.iter().position(|e| e.name == name) { + let fields = read.enums[i] + .iter() + .flat_map(|(variant, fields)| { + fields + .iter() + .map(move |(_, t)| (format!("variant {variant}"), t.clone())) + }) + .collect::>(); + found = Some(Ok((at, fields))); + } + if found.is_some() { + break; + } + } + match found { + None => out.push("which this crate does not declare".to_string()), + Some(Err(shape)) => out.push(format!("{shape}, which the lift does not read")), + Some(Ok((at, fields))) => { + let scope = &scopes[&(pkg, at)]; + let imports = &package.files[at].imports; + let outside = fields.iter().find_map(|(part, t)| { + match scope.ty(&expanded(pkg, &t.localized(imports))) { + Err(Residue::Type(inner)) => Some((part, inner)), + _ => None, + } + }); + match outside { + Some((part, inner)) => { + out.push(format!("whose {part} holds {inner}")); + next = Some((at, inner)); + } + None => out.push( + "which the lift leaves out though each of its parts lifts: it has no \ + part, it is declared twice, its name is one the projection keeps, or \ + it holds itself where no inductive type can" + .to_string(), + ), + } + } + } + } + out.join(", ") +} + /// The free functions of product code whose name two modules (or two /// targets) of one crate share, `toml_string` in `project` and in /// `certify`, each -> its `rust` key and the LexLean name it lifts under: @@ -4920,47 +5597,104 @@ fn homonym_fns(ctx: &Model) -> BTreeMap { .or_default() .insert(site); } + // A site's key and name by its target and module. + let qualified = |site: &FnSite| { + let package = &ctx.ws.packages[site.0]; + let target = &package.targets[site.1]; + let mut parts: Vec = Vec::new(); + if !matches!(target.kind, TargetKind::Lib) { + parts.push(target.name.replace('-', "_")); + } + parts.extend( + site.2 + .split("::") + .filter(|m| !m.is_empty()) + .map(str::to_string), + ); + if parts.is_empty() { + parts.push(package.name.replace('-', "_")); + } + parts.push(site.3.clone()); + let rust = format!("{}#{}", site.1, parts.join("::")); + (rust, lift::local_name(&parts.join("_"))) + }; let mut out = BTreeMap::new(); - for ((pkg, name), at) in sites { + let mut single: Vec = Vec::new(); + for at in sites.into_values() { if at.len() < 2 { + single.extend(at); continue; } - let package = &ctx.ws.packages[pkg]; for site in at { - let target = &package.targets[site.1]; - let mut parts: Vec = Vec::new(); - if !matches!(target.kind, TargetKind::Lib) { - parts.push(target.name.replace('-', "_")); - } - parts.extend( - site.2 - .split("::") - .filter(|m| !m.is_empty()) - .map(str::to_string), - ); - if parts.is_empty() { - parts.push(package.name.replace('-', "_")); - } - parts.push(name.clone()); - let rust = format!("{}#{}", site.1, parts.join("::")); - let lex = lift::local_name(&parts.join("_")); - out.insert(site, (rust, lex)); + let names = qualified(&site); + out.insert(site, names); + } + } + // A function alone of its name, whose name reads as one a module gave + // (`mir_memory_axioms` beside `axioms` of `mir::memory`), takes its + // module's too: the names stay one per function whichever of the two + // lifts, and whichever the projection reaches first. + loop { + let given: BTreeSet<(usize, String)> = out + .iter() + .map(|(site, (_, lex)): (&FnSite, &(String, String))| (site.0, lex.clone())) + .collect(); + let (clashing, rest): (Vec, Vec) = single + .into_iter() + .partition(|site| given.contains(&(site.0, lift::local_name(&site.3)))); + single = rest; + if clashing.is_empty() { + break; + } + for site in clashing { + let names = qualified(&site); + out.insert(site, names); } } out } -/// How a file reads each name its crate's free functions share: the -/// function its module declares, else the one its `use` names, else none. -fn homonym_reading( +/// How a function reads each name its crate's free functions share: as the +/// one function admission's name resolution names for the call (a glob +/// import's, say), and where it names none, as its file does. +fn call_reading( ctx: &Model, homonyms: &BTreeMap, - pkg: usize, - fi: usize, + r: FnRef, ) -> BTreeMap> { - let file = &ctx.ws.packages[pkg].files[fi]; - let mut out = BTreeMap::new(); - for ((p, target, module, name), (rust, _)) in homonyms { + let mut out = homonym_reading(ctx, homonyms, r.pkg, r.file); + for (call, callee) in ctx.named.get(&r).into_iter().flatten() { + let (Some(meant), Some(callee)) = (out.get_mut(call), callee) else { + continue; + }; + if ctx.func(*callee).owner.is_some() { + continue; + } + let file = ctx.file(*callee); + let site = ( + callee.pkg, + file.target, + file.module.clone(), + ctx.func(*callee).name.clone(), + ); + if let Some((rust, _)) = homonyms.get(&site) { + *meant = Some(rust.clone()); + } + } + out +} + +/// How a file reads each name its crate's free functions share: the +/// function its module declares, else the one its `use` names, else none. +fn homonym_reading( + ctx: &Model, + homonyms: &BTreeMap, + pkg: usize, + fi: usize, +) -> BTreeMap> { + let file = &ctx.ws.packages[pkg].files[fi]; + let mut out = BTreeMap::new(); + for ((p, target, module, name), (rust, _)) in homonyms { if *p != pkg { continue; } @@ -5025,13 +5759,17 @@ fn effect_phrase(effect: &str) -> String { } } -fn frontier(notes: &Notes, kappas: &BTreeMap) -> String { - let kappa = |path: &str| { - kappas - .get(path) - .map(|k| format!("kappa = \"{k}\"\n")) - .unwrap_or_default() - }; +/// The table the frontier's count of refusals is written under: the stage +/// that refused them. +const ADMISSION: &str = "admission"; + +/// The unit the frontier's refusal queue counts in. +const REFUSALS: &str = "refusals"; + +/// The projection's `frontier.toml`: the counts and the ranked queues, then +/// every refusal and every function row. `lift` is the register of `rows`, +/// the function rows ([`function_rows`]). +fn frontier(notes: &Notes, lift: &Register, rows: &str) -> String { let mut out = String::from( "# frontier.toml: what uorust did not admit or lift, each with a typed reason.\n\ # A refusal is an open claim: the router proposed it and admission would\n\ @@ -5045,9 +5783,15 @@ fn frontier(notes: &Notes, kappas: &BTreeMap) -> String { # definition parts from the Rust function, its divergence. Every function of\n\ # product code has exactly one residue, foreign, effect or lifted row, keyed\n\ # by the κ of its question (crate path and tokens): a lifted κ never turns\n\ - # unlifted in a later projection.\n\n\ + # unlifted in a later projection.\n\ + # The work queue comes first: [admission] counts the refusals and each\n\ + # [[reason]] row the refusals of one reason; [lift] counts the functions by\n\ + # table and each [[construct]] row the functions one cause and detail stops.\n\ + # Both queues are ranked, what stops the most first.\n\n\ spec = \"uorust/frontier/1\"\n", ); + out.push_str(&refusal_queue(¬es.refusals)); + out.push_str(&lift.queue_text()); for r in ¬es.refusals { out.push_str(&format!( "\n[[refusal]]\nstatus = \"open\"\nreason = \"{}\"\nroute = \"{}\"\nspan = {}\ndetail = {}\n", @@ -5057,6 +5801,42 @@ fn frontier(notes: &Notes, kappas: &BTreeMap) -> String { toml_string(&r.detail()) )); } + out.push_str(rows); + out +} + +/// The refusals as the frontier counts and ranks them: the `[admission]` +/// table, then one `[[reason]]` row per reason a refusal carries, with the +/// route that refused it and the refusals of that reason, in the order and +/// the row shape of the lift's queue ([`ranked`], [`queue_row`]). +fn refusal_queue(refusals: &BTreeSet) -> String { + let mut reasons: BTreeMap<(&str, &str), usize> = BTreeMap::new(); + for r in refusals { + *reasons.entry((r.code(), r.route())).or_default() += 1; + } + let mut out = format!("\n[{ADMISSION}]\n{REFUSALS} = {}\n", refusals.len()); + for ((reason, route), count) in ranked(reasons) { + out.push('\n'); + out.push_str(&queue_row( + "reason", + &[("reason", reason), ("route", route)], + REFUSALS, + count, + )); + } + out +} + +/// The frontier's function rows: every function of product code under the +/// table of what the lift decided for it, keyed by its κ. +fn function_rows(notes: &Notes, kappas: &BTreeMap) -> String { + let kappa = |path: &str| { + kappas + .get(path) + .map(|k| format!("kappa = \"{k}\"\n")) + .unwrap_or_default() + }; + let mut out = String::new(); for (path, (span, reason)) in ¬es.residue { out.push_str(&format!( "\n[[residue]]\nstatus = \"open\"\n{}function = {}\nspan = {}\nreason = \"{}\"\ndetail = {}\n", @@ -5103,6 +5883,219 @@ fn frontier(notes: &Notes, kappas: &BTreeMap) -> String { out } +/// Every module of the projection within the `max_file_bytes` its own +/// `lexlean.toml` states, which LexLean refuses a source file beyond +/// (LLS8002): the limit is read back from the project file the same run +/// writes, so the check and the stated limit cannot part. A module beyond it +/// is [`UorustError::ModuleTooLarge`], naming the first such module. +fn within_limit(files: &BTreeMap>) -> Result<(), UorustError> { + let at = std::path::Path::new(LEXLEAN); + let bad = |reason: String| UorustError::Malformed { + path: at.to_path_buf(), + reason, + }; + let text = String::from_utf8_lossy(files.get(LEXLEAN).map_or(&[][..], Vec::as_slice)); + let config: toml::Value = text.parse().map_err(|e| bad(format!("{e}")))?; + let limit = config + .get("limits") + .and_then(|limits| limits.get("max_file_bytes")) + .and_then(toml::Value::as_integer) + .and_then(|n| usize::try_from(n).ok()) + .ok_or_else(|| bad("it states no [limits] max_file_bytes".to_string()))?; + match files + .iter() + .find(|(path, bytes)| path.ends_with(MODULE_SUFFIX) && bytes.len() > limit) + { + Some((path, bytes)) => Err(UorustError::ModuleTooLarge { + module: path.clone(), + bytes: bytes.len(), + limit, + }), + None => Ok(()), + } +} + +/// What the path of a LexLean module's source ends with. +const MODULE_SUFFIX: &str = ".lex.tex"; + +/// The modules as they are written, each `(path, text)`: a module within +/// `limit` bytes whole, and a module beyond it as its [`parts`] where its +/// records can be written apart and nothing but the module itself cites one +/// (no other module, and no other file, which `cited` answers for the text +/// `Module::`). A module beyond the limit that cannot be parted is written +/// whole, and [`within_limit`] refuses the projection by its name and size. +fn sized(modules: &[Module], limit: usize, cited: &dyn Fn(&str) -> bool) -> Vec<(String, String)> { + let texts: Vec = modules.iter().map(Module::render).collect(); + let taken: BTreeSet<&str> = modules.iter().map(|m| m.name.as_str()).collect(); + let mut out = Vec::new(); + for (i, (module, text)) in modules.iter().zip(&texts).enumerate() { + if text.len() > limit { + let id = format!("{}::", module.name); + let elsewhere = cited(&id) + || texts + .iter() + .enumerate() + .any(|(j, other)| j != i && other.contains(&id)); + let parted = (!elsewhere).then(|| parts(module, limit, &taken)).flatten(); + if let Some(parted) = parted { + out.extend(parted.iter().map(|part| (part.path(), part.render()))); + continue; + } + } + out.push((module.path(), text.clone())); + } + out +} + +/// The parts a module is written as when it is beyond `limit` bytes: its +/// declarations in their order, each part the longest run of them that +/// stays within the limit. The first part keeps the module's name and the +/// `n`th is named `{Module}{n}`, so a record's ID (`Module::name`, which +/// PrismPM reads from the module that declares it) names its part, and every +/// reference to a record of the module is rewritten to the part it is in. +/// +/// Only a module of separate records is parted: every declaration a closed +/// value in which no word outside a string is another declaration's name +/// (the term is not read further, so a field or a constructor spelled like +/// one counts as naming it), and none carrying a canonical `index`, which +/// PrismPM derives from the order of the IDs a parting changes. `None` where +/// the module is not one, where one record alone is beyond the limit, or +/// where a part's name is `taken`. +fn parts(module: &Module, limit: usize, taken: &BTreeSet<&str>) -> Option> { + let names: BTreeSet<&str> = module.decls.iter().map(Decl::name).collect(); + let mut records = Vec::new(); + for decl in &module.decls { + let Decl::Definition { + name, + parameters, + result, + body: Expr::Flat(body), + axioms, + recursive: None, + termination: None, + mutual: None, + } = decl + else { + return None; + }; + let indexed = body.contains("{index := ") || body.contains(", index := "); + if !parameters.is_empty() + || !axioms.is_empty() + || indexed + || words(body).any(|word| names.contains(word)) + { + return None; + } + records.push((name, result, body)); + } + let part = |decls: Vec, name: String| Module { + name, + glossaries: module.glossaries.clone(), + imports: module.imports.clone(), + title: module.title, + decls, + }; + // The size of each record under the longest name a part can have: there + // are no more parts than records, so no part's number is wider than + // their count. A shorter name never prints a record larger, since a + // line that fits stays flat. + let widest = format!("{}{}", module.name, module.decls.len()); + let room = limit.checked_sub(part(Vec::new(), widest.clone()).render().len() + "\n".len())?; + let between = "\n\n".len(); + let mut groups: Vec> = Vec::new(); + let mut used = 0; + for (i, (name, result, body)) in records.iter().enumerate() { + let widened = renamed(body, &module.name, &|n| { + names.contains(n).then_some(widest.as_str()) + }); + let size = crate::lex::render_decl(&Decl::value(*name, *result, widened)).len(); + match groups.last_mut() { + Some(group) if used + between + size <= room => { + group.push(i); + used += between + size; + } + _ if size <= room => { + groups.push(vec![i]); + used = size; + } + _ => return None, + } + } + let part_names: Vec = (0..groups.len()) + .map(|k| match k { + 0 => module.name.clone(), + _ => format!("{}{}", module.name, k + 1), + }) + .collect(); + if part_names[1..].iter().any(|n| taken.contains(n.as_str())) { + return None; + } + let part_of: BTreeMap<&str, &str> = groups + .iter() + .zip(&part_names) + .flat_map(|(group, part)| { + group + .iter() + .map(|&i| (records[i].0.as_str(), part.as_str())) + }) + .collect(); + Some( + groups + .iter() + .zip(&part_names) + .map(|(group, name)| { + let decls = group + .iter() + .map(|&i| { + let (record, result, body) = records[i]; + let body = renamed(body, &module.name, &|n| part_of.get(n).copied()); + Decl::value(record, result, body) + }) + .collect(); + part(decls, name.clone()) + }) + .collect(), + ) +} + +/// `text` with every string that is an ID of `module` (`"Module::name"`) +/// naming the module `part_of` gives for its `name`; an ID it gives none for +/// stays as it is. +fn renamed<'a>(text: &str, module: &str, part_of: &dyn Fn(&str) -> Option<&'a str>) -> String { + let opening = format!("\"{module}::"); + let mut out = String::with_capacity(text.len()); + let mut rest = text; + while let Some(at) = rest.find(&opening) { + let after = &rest[at + opening.len()..]; + let name = &after[..after.find('"').unwrap_or(after.len())]; + out.push_str(&rest[..at]); + match part_of(name) { + Some(part) => out.push_str(&format!("\"{part}::")), + None => out.push_str(&opening), + } + rest = after; + } + out.push_str(rest); + out +} + +/// The words of a term outside its string literals: each run of letters, +/// digits and underscores, the shape of a declaration's name. +fn words(text: &str) -> impl Iterator { + let (mut quoted, mut escaped) = (false, false); + text.split(move |c: char| { + let inside = quoted; + match c { + _ if escaped => escaped = false, + '\\' if quoted => escaped = true, + '"' => quoted = !quoted, + _ => {} + } + inside || !(c.is_alphanumeric() || c == '_') + }) + .filter(|word| !word.is_empty()) +} + fn spdx(ws: &Workspace, options: &Options) -> String { let id = |name: &str, version: &str| { let raw = format!("SPDXRef-Package-{name}-{version}"); @@ -5266,4 +6259,1293 @@ mod tests { } } } + + // Types outside the lift. + + /// The frontier of a one-crate workspace of these files, written under + /// the system's temporary directory and projected. + fn frontier_of(name: &str, files: &[(&str, &str)]) -> String { + let dir = std::env::temp_dir().join(format!("uorust-lib-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + let manifest = + format!("[package]\nname = \"{name}\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[workspace]\n"); + for (path, body) in [("Cargo.toml", manifest.as_str())].iter().chain(files) { + let path = dir.join(path); + std::fs::create_dir_all(path.parent().expect("a parent")).expect("a directory"); + std::fs::write(path, body).expect("a file"); + } + let options = super::Options { + name: name.to_string(), + last_modified: "2026-11-11T00:00:00Z".to_string(), + advisories: None, + mir: None, + }; + let projected = crate::project_workspace(&dir, &options).expect("a projection"); + let _ = std::fs::remove_dir_all(&dir); + String::from_utf8(projected["frontier.toml"].clone()).expect("text") + } + + /// The rows of a frontier that are of this function: each one's table + /// and the line of it that starts with this key. + fn rows_of(frontier: &str, function: &str, key: &str) -> Vec<(String, String)> { + frontier + .split("\n[[") + .filter(|row| row.contains(&format!("\nfunction = \"{function}\"\n"))) + .map(|row| { + let table = row.split("]]").next().unwrap_or_default().to_string(); + let line = row + .lines() + .find_map(|l| l.strip_prefix(&format!("{key} = "))) + .unwrap_or_default() + .trim_matches('"') + .to_string(); + (table, line) + }) + .collect() + } + + const NAMES: &[(&str, &str)] = &[ + ( + "src/lib.rs", + "//! Names that read as one type, as none, or as a leaf.\n\ + pub mod first;\npub mod reader;\npub mod second;\npub mod teller;\n\n\ + /// One type for each build configuration.\n#[cfg(unix)]\n\ + pub struct Handle {\n /// A descriptor.\n pub fd: u32,\n}\n\n\ + /// One type for each build configuration.\n#[cfg(not(unix))]\n\ + pub struct Handle {\n /// A raw handle.\n pub raw: u64,\n}\n\n\ + /// Stopped by a name two declarations share.\n\ + pub fn opened(h: &Handle) -> bool {\n let _ = h;\n true\n}\n\n\ + /// A float.\npub struct Leaf {\n /// The float.\n pub x: f64,\n}\n\n\ + /// Holds the leaf.\npub struct Mid {\n /// A count.\n pub n: u32,\n \ + /// The leaf.\n pub leaf: Leaf,\n}\n\n\ + impl Mid {\n /// Stopped by the type it is a method of.\n \ + pub fn count(&self) -> u32 {\n self.n\n }\n}\n\n\ + /// A type named as LexLean names one of its own.\n\ + pub struct Prop {\n /// A power.\n pub power: u8,\n}\n\n\ + /// Reads it.\npub fn power(p: &Prop) -> u8 {\n p.power\n}\n\n\ + /// Two traits give one type a method of one name.\n\ + pub struct Label {\n /// The text.\n pub text: String,\n}\n\n\ + impl std::fmt::Display for Label {\n \ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n \ + write!(f, \"{}\", self.text)\n }\n}\n\n\ + impl std::fmt::Debug for Label {\n \ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n \ + f.write_str(\"label\")\n }\n}\n\n\ + /// One function for each build configuration.\n#[cfg(unix)]\n\ + pub fn width() -> u32 {\n 1\n}\n\n\ + /// One function for each build configuration.\n#[cfg(not(unix))]\n\ + pub fn width(scale: f64) -> u32 {\n let _ = scale;\n 2\n}\n", + ), + ( + "src/first.rs", + "//! The first of two modules that declare a type of one name.\n\n\ + /// A shape with sides.\npub struct Shape {\n /// The sides.\n pub sides: u32,\n}\n\n\ + /// Reads the shape its own module declares.\n\ + pub fn sides(s: &Shape) -> u32 {\n s.sides\n}\n", + ), + ( + "src/second.rs", + "//! The second of two modules that declare a type of one name.\n\n\ + /// A shape with a radius.\npub struct Shape {\n /// The radius.\n pub radius: u32,\n}\n\n\ + /// Reads the shape its own module declares.\n\ + pub fn radius(s: &Shape) -> u32 {\n s.radius\n}\n", + ), + ( + "src/teller.rs", + "//! A file that says which of the two shapes it means.\n\n\ + use crate::second::Shape;\n\n\ + /// Reads the shape its import names.\n\ + pub fn round(s: &Shape) -> u32 {\n s.radius\n}\n", + ), + ( + "src/reader.rs", + "//! A file that does not say which of the two shapes it means.\n\n\ + use crate::first::*;\n\n\ + /// Stopped by a name the file does not tell apart.\n\ + pub fn corners(s: &Shape) -> u32 {\n s.sides\n}\n", + ), + ]; + + #[test] + fn a_name_that_reads_as_no_one_type_states_why() { + let frontier = frontier_of("names", NAMES); + let detail = |function: &str| rows_of(&frontier, function, "detail"); + let residue = |why: String| vec![("residue".to_string(), why)]; + // One name, two declarations in one module: neither is the type. + assert_eq!( + detail("names::opened"), + residue(format!( + "type outside the lift: Handle: {}", + crate::lift::DECLARED_TWICE + )) + ); + // One name, two modules: the module that declares one and the file + // that imports one read it, and a file that does neither reads none. + assert_eq!( + detail("names::reader::corners"), + residue(format!( + "type outside the lift: Shape: {}", + crate::lift::SHARED_NAME + )) + ); + for told in [ + "names::first::sides", + "names::second::radius", + "names::teller::round", + ] { + let rows = rows_of(&frontier, told, "definition"); + assert_eq!(rows.len(), 1, "{told}: {rows:?}"); + assert_eq!(rows[0].0, "lifted", "{told}"); + } + } + + #[test] + fn a_method_of_a_type_outside_the_lift_names_the_leaf() { + let frontier = frontier_of("owners", NAMES); + assert_eq!( + rows_of(&frontier, "owners::Mid::count", "detail"), + vec![( + "residue".to_string(), + "type outside the lift: Mid.leaf: Leaf.x: f64".to_string() + )] + ); + } + + #[test] + fn a_type_named_as_lexlean_names_its_own_lifts_under_its_crate() { + let frontier = frontier_of("taken", NAMES); + let rows = rows_of(&frontier, "taken::power", "definition"); + assert_eq!(rows.len(), 1, "{rows:?}"); + assert_eq!(rows[0].0, "lifted"); + } + + #[test] + fn two_functions_of_one_path_share_one_row() { + let frontier = frontier_of("paths", NAMES); + let rows = rows_of(&frontier, "paths::width", "detail"); + assert_eq!(rows.len(), 1, "{rows:?}"); + // The row is the one that claims least: the function not lifted. + assert_eq!(rows[0].0, "residue"); + // Two traits' methods of one name on one type are two paths, each + // with its own row. + for path in [ + "paths::