[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"qDlKw2dMpF":3},"# Programming Languages lab in Lean\n\nThis laboratory is an introduction to functional programming and theorem proving with Lean 4. \n\nNo previous experience with functional programming or formal proofs is required.\n\n## Getting started\n\nThe simplest way to use Lean is [Lean 4 Web](https://live.lean-lang.org/):\n\n1. Open Lean 4 Web in your browser.\n2. Open the `.lean` file provided for the laboratory, or copy its contents into\n   the editor.\n3. Wait a few seconds while Lean starts and checks the file.\n\n## Working on an exercise\n\nExercises contain the placeholder `sorry`, for example:\n\n```lean\nexample (b : Bool) : b && true = b := by\n  sorry\n```\n\nReplace `sorry` with your code:\n\n```lean\nexample (b : Bool) : b && true = b := by\n  cases b with\n  | false => rfl\n  | true  => rfl\n```\n\nLean checks your code continuously:\n\n- Place the cursor inside a proof to see the current goal and hypotheses in the **Infoview**.\n- A red underline indicates an error. Hover over it and read the complete error message.\n- A warning about `sorry` means that the exercise is not finished, although Lean temporarily accepts the file.\n\nWork on one exercise at a time. Do not change names or types unless the exercise explicitly asks you to do so.\n\n## Useful commands\n\n```lean\n#check Bool             -- Ask Lean for the type of an expression.\n#eval true && false     -- Evaluate an expression.\n#print name             -- Print the definition of a name.\n```\n\nSome proof commands used in the first laboratories are:\n- `rfl`: prove an equality by computation and reflexivity;\n- `intro h`: introduce an assumption or a universally quantified value;\n- `cases b`: consider all possible forms of `b`;\n- `simp`: simplify the goal using known rules;\n- `exact h`: finish the goal using `h`.\n\nYou are not expected to memorize every command. Try small examples and use the\nInfoview to observe how each command changes the goal.\n\n## Saving your work\n\nSave your work frequently. If you use Lean 4 Web, copy or download your code before closing the page.\n\nIf you need help, show the instructor or teaching assistant the code you are working on, your current attempt, and Lean's complete error message.\n\n## References\n\n- [Lean Game Server](https://adam.math.hhu.de/)\n- [Interactive Theorem Proving course](https://github.com/RobertoZunino/ITPCourse/tree/main)\n- [Lean 4 documentation](https://lean-lang.org/learn/)\n- [Theorem Proving in Lean 4](https://lean-lang.org/theorem_proving_in_lean4/)\n",1791742497588]