Lema Lema

The Lema programming language

Agents do the heavy lifting

Once humans have written the high level contracts, laws and interfaces, the intention is that agents write the implementations and optionally proofs. Humans usually don’t need to read these implementations or proofs, which are currently written in Lean. Agents are experts at writing Lean and, in fact thrive on the mathematically structured Lean language.

For example, an agent implements a sorting function and proves it obeys the ‘sorting laws’, then Lema checks correctness of the proof with the Lean proof checker.

A sort + its preservation proofLean excerpt
def sort (xs : List Nat) : List Nat :=
  sortBy (fun a b => decide (a ≤ b)) xs

theorem sort_preserves (xs : List Nat) :
    (sort xs).Perm xs :=
  sortBy_perm (fun a b => decide (a ≤ b)) xs
  1. Agent submits
  2. Lean checks
  3. Store accepts

Lema setup prompt

Install Lema 0.3.2 and run its HTTPS echo starter on my machine. Comment on your experience as you go.

Use only public instructions and downloads from https://www.lema-lang.org/docs/tutorials/get-started/ and its linked setup/requirements pages. Do not assume access to the Lema source repository or ask me to install Rust.

## Check this machine

- Inspect the operating system, architecture, existing Lema installations and PATH. Use the published qualified Apple Silicon macOS or Linux x86_64 requirements. On another host, report the limitation before installing anything.
- Preserve existing projects, runtime configuration and unrelated services. Create the echo project in a new directory; if that name exists, choose a separate directory rather than overwrite it.
- Install or reuse the documented OpenSSL and TLS 1.3 curl tools. On Linux, bubblewrap must come from the OS package manager at /usr/bin/bwrap. Do not weaken ownership, sandbox or quarantine checks.

## Install and set up Lema

Use one public method. If Homebrew is already the preferred package manager, use:
brew tap lorenalabs/lema https://brew.lema-lang.org/homebrew-lema.git
if brew help trust >/dev/null 2>&1; then
  brew trust --formula lorenalabs/lema/lema
fi
brew install lorenalabs/lema/lema

Otherwise download and run the public installer:
curl --proto '=https' --tlsv1.2 -fsSLo install-lema.sh https://www.lema-lang.org/install.sh
sh install-lema.sh

Follow its printed PATH instruction. Keep lema and lema-vm-runner paired. Run lema --version, lema build-info --check-worker, then lema setup. Report the installed version and location, selected runtime configuration, worker check and library-pack result. Continue only when setup exits successfully and prints setup complete. Report a failed download or runtime check; do not silently use --no-pack to get past it.

## Run and test HTTPS

Run lema new echo in the chosen parent directory, enter the new echo project, then run lema run echo. Wait for the serving line, which follows the worker's bind, and copy the exact curl command Lema prints. On macOS this may use an absolute Homebrew curl path. Send the request twice and confirm both return POST /hello, request headers and hi.

The request uses --noproxy '*', HTTP/1.1 and TLS 1.3, with -k only for the local self-signed development certificate. Do not write TCP, TLS or HTTP framing code yourself. If the port is occupied, report it and choose a free development port with lema dev-cert echo --port PORT; do not kill an unrelated process.

## Exercise the edit loop and hand over

Stop the app with Ctrl-C. Change the successful branch of respond in Handler.lean to return Hello from Lema followed by a newline, as shown in the tutorial. Run lema add Handler.lean, then lema test Handler.report with the tutorial's explicit --expect oracle including that newline. Restart lema run echo, wait for serving, and repeat the printed request to confirm the changed response.

Leave the app running when successful. Give me its URL, project path and stop instructions, and explain that Ctrl-C stops the app while lema stop manages the background codebase server. Summarize installed tools, versions, locations, PATH changes and any remaining blockers. Distinguish what Lean checked from what these requests and the handler test exercised. Explain the explicit app/server restart needed after an update.