Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vale/styles/config/ignore/names.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
Bhavik
Blott
Bruijn
Carneiro
Collatz
Himmel's
Hoare
Lua
Madelaine
Markus
Mathlib
Mehta
Merkin
Moura
Peano
Rish
Selsam
Simons
Streicher
Expand All @@ -20,3 +26,4 @@ Nawrocki's
Rustan
Leino
Leino's
Vaishnav's
10 changes: 10 additions & 0 deletions .vale/styles/config/ignore/terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ letterlike
linearization
linearize
linearizing
logics
lookup
lookups
lossy
macro_rules
matcher
matchers
Expand All @@ -117,10 +119,12 @@ monad's
monoid
monomorphic
monomorphism
morphism
multipattern
multipatterns
multiset
multisets
mvcgen
namespace
namespace's
namespaces
Expand All @@ -139,12 +143,16 @@ polymorphic
polymorphically
ponens
popcount
postcondition
postconditions
postfix
poststate
predicative
predicativity
prepending
preprocesses
propositionally
prestate
quasiquotation
quasiquotations
quasiquote
Expand Down Expand Up @@ -207,6 +215,8 @@ uninstantiated
unparenthesized
uploader
upvote
VC
VCs
walkthrough
workspace's
zulip
3 changes: 3 additions & 0 deletions Manual.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Manual.ErrorExplanations
import Manual.Tactics
import Manual.Simp
import Manual.Grind
import Manual.VCGen
import Manual.BasicTypes
import Manual.BasicProps
import Manual.NotationsMacros
Expand Down Expand Up @@ -99,6 +100,8 @@ Thus, this reference manual does not draw a barrier between the two aspects, but

{include 0 Manual.Grind}

{include 0 Manual.VCGen}

{include 0 Manual.BasicProps}

{include 0 Manual.BasicTypes}
Expand Down
2 changes: 1 addition & 1 deletion Manual/BasicTypes/BitVec.lean
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ The resulting proofs rely only on the axiom {name}`Lean.ofReduceBool`; the exter

:::example "Popcount"

```imports
```imports -show
import Std.Tactic.BVDecide
```

Expand Down
5 changes: 2 additions & 3 deletions Manual/BasicTypes/Maps.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Author: David Thrane Christiansen
import VersoManual

import Manual.Meta
import Manual.Meta.ImportsBlock

import Manual.BasicTypes.Maps.TreeSet
import Manual.BasicTypes.Maps.TreeMap
Expand Down Expand Up @@ -177,7 +176,7 @@ A nested inductive type that occurs inside a map or set should be defined in thr

:::example "Nested Inductive Types with `Std.HashMap`"

```imports
```imports -show
import Std
```

Expand Down Expand Up @@ -310,7 +309,7 @@ These operations avoid creating a second reference to the value during modificat

:::example "Modifying Values in Maps"

```imports
```imports -show
import Std
```

Expand Down
4 changes: 2 additions & 2 deletions Manual/BasicTypes/Option.lean
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The {lean}`Option` API makes frequent use of this perspective.

:::example "Options as Nullability"

```imports
```imports -show
import Std
```

Expand Down Expand Up @@ -68,7 +68,7 @@ In many programming languages, it is important to remember to check for the null
When using {name}`Option`, the type system requires these checks in the right places: {lean}`Option α` and {lean}`α` are not the same type, and converting from one to the other requires handling the case of {lean (type := "Option α")}`none`.
This can be done via helpers such as {name}`Option.getD`, or with pattern matching.

```imports
```imports -show
import Std
```

Expand Down
2 changes: 1 addition & 1 deletion Manual/Classes/DerivingHandlers.lean
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Lean includes deriving handlers for the following classes:
::::keepEnv
:::example "Deriving Handlers"

```imports
```imports -show
import Lean.Elab
```

Expand Down
4 changes: 2 additions & 2 deletions Manual/Grind/Linarith.lean
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ It can be disabled using the option `grind -linarith`.


:::example "Goals Decided by `linarith`" (open := true)
```imports
```imports -show
import Std
```
```lean -show
Expand Down Expand Up @@ -75,7 +75,7 @@ example {a b c d e : α} :
:::

:::example "Commutative Ring Goals Decided by `linarith`" (open := true)
```imports
```imports -show
import Std
```
```lean -show
Expand Down
2 changes: 1 addition & 1 deletion Manual/Interaction.lean
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Lists all axioms that the constant transitively relies on. See {ref "print-axiom
:::

:::example "Printing Axioms"
```imports
```imports -show
import Std.Tactic.BVDecide
```

Expand Down
2 changes: 1 addition & 1 deletion Manual/Interaction/FormatRepr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The most important {name Std.Format}`Format` operations are:
::::

:::example "Widths and Newlines"
```imports
```imports -show
import Std
```
```lean
Expand Down
2 changes: 1 addition & 1 deletion Manual/Language/InductiveTypes/Structures.lean
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Its constructor is named {name}`Palindrome.ofString`, rather than `Palindrome.mk
:::

::: example "Modifiers on structure constructor"
```imports
```imports -show
import Std
```
The structure {lean}`NatStringBimap` maintains a finite bijection between natural numbers and strings.
Expand Down
2 changes: 2 additions & 0 deletions Manual/Meta.lean
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import Manual.Meta.Syntax
import Manual.Meta.Tactics
import Manual.Meta.SpliceContents
import Manual.Meta.Markdown
import Manual.Meta.Imports
import Manual.Meta.Namespace


open Verso ArgParse Doc Elab Genre.Manual Html Code Highlighted.WebAssets
Expand Down
2 changes: 1 addition & 1 deletion Manual/Meta/Example.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Author: David Thrane Christiansen

import VersoManual
import Manual.Meta.Figure
import Manual.Meta.Imports
import Manual.Meta.LzCompress
import Manual.Meta.ImportsBlock
import Lean.Elab.InfoTree.Types

open Verso Doc Elab
Expand Down
38 changes: 38 additions & 0 deletions Manual/Meta/Imports.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/-
Copyright (c) 2025 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/

import VersoManual
import Lean.Elab.InfoTree.Types
import SubVerso.Highlighting.Code

open scoped Lean.Doc.Syntax

open Verso Doc Elab
open Lean Elab
open Verso.Genre.Manual InlineLean Scopes
open Verso.SyntaxUtils
open SubVerso.Highlighting
open ArgParse

namespace Manual

structure ImportsParams where
«show» : Bool := true

instance : FromArgs ImportsParams m where
fromArgs := ImportsParams.mk <$> .flag `show true (some "Whether to show the import header")

@[code_block]
def imports : CodeBlockExpanderOf ImportsParams
| { «show» } , str => do
let altStr ← parserInputString str
let p := Parser.whitespace >> Parser.Module.header.fn
let headerStx ← p.parseString altStr
let hl ← highlight headerStx #[] {}
if «show» then
``(Block.other (Block.lean $(quote hl) {}) #[Block.code $(quote str.getString)])
else
``(Block.empty)
21 changes: 0 additions & 21 deletions Manual/Meta/ImportsBlock.lean

This file was deleted.

31 changes: 31 additions & 0 deletions Manual/Meta/Namespace.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/-
Copyright (c) 2025 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/

import VersoManual
import Lean.Elab.InfoTree.Types
import SubVerso.Highlighting.Code

open scoped Lean.Doc.Syntax

open Verso Doc Elab
open Lean Elab
open Verso.Genre.Manual InlineLean Scopes
open Verso.SyntaxUtils
open SubVerso.Highlighting

@[role]
def «namespace» : RoleExpanderOf Unit
| (), #[arg] => do
let `(inline|code($s)) := arg
| throwErrorAt arg "Expected code"
-- TODO validate that namespace exists? Or is that too strict?
-- TODO namespace domain for documentation
``(Inline.code $(quote s.getString))
| _, more =>
if h : more.size > 0 then
throwErrorAt more[0] "Expected code literal with the namespace"
else
throwError "Expected code literal with the namespace"
6 changes: 6 additions & 0 deletions Manual/Monads/Syntax.lean
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ In addition to convenient support for sequential computations with data dependen
These effects are implemented via transformations of the entire {keywordOf Lean.Parser.Term.do}`do` block in a manner akin to {tech}[monad transformers], rather than via a local desugaring.

## Early Return
%%%
tag := "early-return"
%%%

Early return terminates a computation immediately with a given value.
The value is returned from the closest containing {keywordOf Lean.Parser.Term.do}`do` block; however, this may not be the closest `do` keyword.
Expand All @@ -452,6 +455,9 @@ Internally, the {keywordOf Lean.Parser.Term.do}`do` elaborator performs a transl
On its own, {keywordOf Lean.Parser.Term.doReturn}`return` is short for {keywordOf Lean.Parser.Term.doReturn}`return`​` `​{lean}`()`.

## Local Mutable State
%%%
tag := "let-mut"
%%%

Local mutable state is mutable state that cannot escape the {keywordOf Lean.Parser.Term.do}`do` block in which it is defined.
The {keywordOf Lean.Parser.Term.doLet}`let mut` binder introduces a locally-mutable binding.
Expand Down
4 changes: 2 additions & 2 deletions Manual/NotationsMacros.lean
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ The optional suffix `?` in syntax and splices correspond with each other.

::::keepEnv
:::example "Suffixed Splices"
```imports
```imports -show
import Lean.Elab
```
```lean -show
Expand Down Expand Up @@ -697,7 +697,7 @@ macro_rules

::::keepEnv
:::example "Optional Splices"
```imports
```imports -show
import Lean.Elab
```
The following syntax declaration optionally matches a term between two tokens.
Expand Down
6 changes: 3 additions & 3 deletions Manual/NotationsMacros/Elab.lean
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ A command elaborator has type {name}`CommandElab`, which is an abbreviation for
Command elaborators may be implicitly defined using {keywordOf Lean.Parser.Command.elab_rules}`elab_rules`, or explicitly by defining a function and applying the {attr}`command_elab` attribute.

:::example "Querying the Environment"
```imports
```imports -show
import Lean.Elab
```
```lean -show
Expand Down Expand Up @@ -143,7 +143,7 @@ The optional {lean}`Expr` parameter is the type expected for the term being elab
Like command elaborators, term elaborators may be implicitly defined using {keywordOf Lean.Parser.Command.elab_rules}`elab_rules`, or explicitly by defining a function and applying the {attr}`term_elab` attribute.

:::example "Avoiding a Type"
```imports
```imports -show
import Lean.Elab
```
```lean -show
Expand Down Expand Up @@ -205,7 +205,7 @@ Got unwanted type String
:::

:::example "Using Any Local Variable"
```imports
```imports -show
import Lean.Elab
```
```lean -show
Expand Down
Loading