Sample programs
The examples below use compiler/run.ps1 from the repository root. The script builds the compiler if needed. You can also build the compiler first and run wec.exe directly with the same arguments.
The song as a program
Run main.world alongside the lyrics:
.\compiler\run.ps1 run main.world
The live verdict is true. The listener leaves during the chorus. Their return happens only in a rehearsal. Run with --detailed-full to see it.
What the narrator can prove is that they’re trapped in love. They still can’t prove they’re loved.
Theorem examples
Use check for the theorems. Use run to also test the final claim against the sample data.
| Program | What to look for |
|---|---|
| Cogito | some owner where thinks(owner, t) proves a thought has a thinker without naming one. A separate concrete fact identifies i as a thinker. |
| Connected components | Two vertices are connected if each reaches the other. The theorems establish reflexivity on vertices, symmetry, and transitivity. Try removing the return edge edge(c, a): the general proofs still check, but the concrete claim no longer holds. |
| Election fairness | Does a majority rule treat voters and candidates equally? For all eight ways three voters can vote for Ada or Ben, voter_anonymity checks that reordering the ballots preserves the winner, and candidate_neutrality checks that swapping the candidates' names swaps the winner. |
.\compiler\run.ps1 check examples/election.world
.\compiler\run.ps1 run --trace examples/components.world
.\compiler\run.ps1 run examples/cogito.world
A lamp and a listener
sample.world asks whether a gift reaches its listener. Compare the same program under two observations:
.\compiler\run.ps1 run --detailed-full --input you.presence=present sample.world
.\compiler\run.ps1 run --detailed-full --input you.presence=gone sample.world
Look for light_sent in the events. It appears in both rehearsals, which assume the listener is present. In the live run with gone, can(send_light(i, you)) skips the gift and the program still succeeds.
A budget with a spending limit
budget.world starts with a balance of 100. Try the two prices in Getting started, then run with --no-prompt and no price. Without a price the program can't prove price > 0, so it skips the purchase.