[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"pnGnd78lPt":3},"# lean-cloud\n\n[![CI](https://github.com/palladin/lean-cloud/actions/workflows/ci.yml/badge.svg)](https://github.com/palladin/lean-cloud/actions/workflows/ci.yml)\n[![Lean 4](https://img.shields.io/badge/Lean-%E2%89%A5%204.35.0-blue)](https://leanprover.github.io/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green)](LICENSE)\n\nParallel and distributed programming for Lean using composable monadic programs.\n\nWrite workflows with `cloud { ... }`, run independent computations with\n`Cloud.parallel`, and combine their results using ordinary Lean code. Parallel\nbranches can use variables from their surrounding scope. The same workflow runs\non local workers or in the cloud.\n\nFor example, count error lines across log files in shared blob storage:\n\n```lean\nimport LeanCloud\n\nopen LeanCloud\n\ndef summarizeLogs (files : Array String) : Cloud IO BlobRef := cloud {\n  let counts ← Cloud.parallel (files.map fun name =>\n    Cloud.exec fun env => do\n      let text ← env.blobs.readTextByName name\n      return ((text.splitOn \"\\n\").filter (·.startsWith \"ERROR\")).length)\n\n  let total := counts.foldl (· + ·) 0\n  Cloud.exec fun env => env.blobs.putText s!\"files={files.size}, errors={total}\\n\"\n}\n```\n\nEach branch reads one file and counts its errors. The workflow combines the\ncounts and saves a report. Its type, `Cloud IO BlobRef`, tells us that the result\nis a reference to that report in blob storage.\n\n## Cloud console\n\nConnect the console to a deployed scheduler to run programs and follow their\nprogress. `watch` shows the branch tree, executing code, and worker resource use.\nLocal Docker, Azure, and AWS use the same console commands.\n\n```text\ncloud> connect mathlib-demo http://127.0.0.1:8081 --token-file .mathlib-deployment/client.token\ncloud> programs\ncloud> run lean-build --input Applications/LeanBuild/mathlib.json --id mathlib\ncloud> watch mathlib\n```\n\nBuilding Mathlib on four AWS workers:\n\n![Cloud console showing Mathlib build progress, workflow code, and four workers' CPU, memory, and IO](docs/images/mathlib-watch.png)\n\nFollow the [AWS Mathlib walkthrough](Applications/LeanBuild/MathlibAWS.md) to\nset this up, or see the [console guide](LeanCloud/Console.md) for all commands.\n\n## Applications\n\n- [LeanBuild](Applications/LeanBuild/README.md): build Lean projects from GitHub\n  across workers, using Lake's local parallelism.\n- [Cube-and-conquer SAT](Applications/CubeAndConquer/README.md): split a CNF\n  problem, solve it in parallel, and check the resulting models or proofs.\n- [Wiki](Applications/Wiki/README.md): count words and search Wikipedia dumps\n  using composable cloud reducers.\n\n## Get started\n\n- [Run locally with Docker](deploy/README.md#local-docker)\n- [Deploy and run the example on Azure](deploy/Azure.md)\n- [Deploy and run the example on AWS](deploy/AWS.md)\n- [Run your first log-processing workflow](deploy/README.md#run-the-log-processing-example)\n\n## How it works\n\n- [Proofs](LeanCloud/Proofs/README.md): for pure cloud programs, sequential,\n  parallel and crash-restarting replay return the same result as direct execution.\n- [Worker recovery](LeanCloud/ReplayRecovery.md) and\n  [scheduler simulation](LeanCloud/Simulation.md).\n- [Deployment model](LeanCloud/Deployment.md): durability, scaling and credentials.\n- [Tests](LeanCloudTests/README.md): run `lake build` for the library and proofs,\n  then `lake test`.\n\n## Repository layout\n\n| Directory | Contents |\n| --- | --- |\n| `LeanCloud/` | The `Cloud` monad, interpreters, scheduler model and proofs |\n| `LeanCloudCli/` | The `lean_cloud` console |\n| `runtime/` | Deployed scheduler and worker processes: HTTP mailboxes, SQLite, S3/Azure blob storage, and the demo registry that ships as `cloud-app` |\n| `reducers/` | [Cloud reducers](reducers/README.md) for tree-shaped aggregation |\n| `Applications/` | [Example applications](Applications/README.md) |\n| `deploy/` | [Deployment helpers](deploy/README.md) for Docker, Kubernetes, Azure and AWS |\n",1795286031697]