1
- <div class =" alert alert-info " >
2
- <p >
3
- We are currently updating the Lean community website to describe working with Lean 4,
4
- but most of the information you will find here today still describes Lean 3.
5
- </p >
6
- <p >
7
- Pull requests updating this page for Lean 4 are very welcome.
8
- There is a link at the bottom of this page.
9
- </p >
10
- <p >
11
- Please visit <a href =" https://leanprover.zulipchat.com " >the leanprover zulip</a >
12
- and ask for whatever help you need during this transitional period!
13
- </p >
14
- <p >
15
- The website for Lean 3 has been <a href =" https://leanprover-community.github.io/lean3/ " >archived</a >.
16
- If you need to link to Lean 3 specific resources please link there.
17
- </p >
18
- </div >
19
-
20
1
# Documentation style
21
2
22
3
All pull requests must meet the following documentation standards. See
23
- [ the ` doc-gen ` repo] ( https://github.com/leanprover-community /doc-gen ) for information about the
24
- [ automatically generated doc pages] ( https://leanprover-community.github.io/mathlib_docs / ) .
4
+ [ the ` doc-gen ` repo] ( https://github.com/leanprover/doc-gen4 ) for information about the
5
+ [ automatically generated doc pages] ( https://leanprover-community.github.io/mathlib4_docs / ) .
25
6
26
7
You can preview the markdown processing of a GitHub page or pull request
27
8
using the [ Lean doc preview page] ( https://observablehq.com/@bryangingechen/github-lean-doc-preview ) .
@@ -52,7 +33,7 @@ The other sections, with second level headers are (in this order):
52
33
* * Tags* (a list of keywords that could be useful when doing text search in mathlib to find where
53
34
something is covered)
54
35
55
- References should refer to bibtex entries in [ the mathlib citations file] ( https://github.com/leanprover-community/mathlib /blob/master/docs/references.bib ) .
36
+ References should refer to bibtex entries in [ the mathlib citations file] ( https://github.com/leanprover-community/mathlib4 /blob/master/docs/references.bib ) .
56
37
See the [ Citing other works] ( #citing-other-works ) section below.
57
38
58
39
The following code block is an example of a file header.
@@ -62,39 +43,36 @@ The following code block is an example of a file header.
62
43
Copyright (c) 2018 Robert Y. Lewis. All rights reserved.
63
44
Released under Apache 2.0 license as described in the file LICENSE.
64
45
Authors: Robert Y. Lewis
46
+
47
+ ! This file was ported from Lean 3 source module number_theory.padics.padic_norm
48
+ ! leanprover-community/mathlib commit 92ca63f0fb391a9ca5f22d2409a6080e786d99f7
49
+ ! Please do not edit these lines, except to modify the commit id
50
+ ! if you have ported upstream changes.
65
51
-/
66
- import data.rat
67
- import algebra.gcd_domain
68
- import algebra.field_power
69
- import ring_theory.multiplicity
70
- import tactic.ring
71
- import data.real.cau_seq
72
- import tactic.norm_cast
52
+ import Mathlib.Algebra.Order.Field.Power
53
+ import Mathlib.NumberTheory.Padics.PadicVal
73
54
74
55
/-!
75
56
# p-adic norm
76
57
77
- This file defines the p -adic valuation and the p-adic norm on ℚ .
58
+ This file defines the `p` -adic norm on `ℚ` .
78
59
79
- The p -adic valuation on ℚ is the difference of the multiplicities of `p` in the numerator and
60
+ The `p` -adic valuation on `ℚ` is the difference of the multiplicities of `p` in the numerator and
80
61
denominator of `q`. This function obeys the standard properties of a valuation, with the appropriate
81
- assumptions on p .
62
+ assumptions on `p` .
82
63
83
- The valuation induces a norm on ℚ . This norm is a nonarchimedean absolute value.
64
+ The valuation induces a norm on `ℚ` . This norm is a nonarchimedean absolute value.
84
65
It takes values in {0} ∪ {1/p^k | k ∈ ℤ}.
85
66
86
- ## Notations
87
-
88
- This file uses the local notation `/.` for `rat.mk`.
89
-
90
67
## Implementation notes
91
68
92
69
Much, but not all, of this file assumes that `p` is prime. This assumption is inferred automatically
93
- by taking (prime p) as a type class argument.
70
+ by taking `[Fact p.Prime]` as a type class argument.
94
71
95
72
## References
96
73
97
74
* [F. Q. Gouvêa, *p-adic numbers*][gouvea1997]
75
+ * [R. Y. Lewis, *A formal proof of Hensel's lemma over the p-adic integers*][lewis2019]
98
76
* <https://en.wikipedia.org/wiki/P-adic_number>
99
77
100
78
## Tags
@@ -118,61 +96,49 @@ Doc strings should convey the mathematical meaning of the definition. They are a
118
96
slightly about the actual implementation. The following is a doc string example:
119
97
120
98
``` lean
121
- /--
122
- If `q ≠ 0`, the p-adic norm of a rational `q` is `p ^ (-(padic_val_rat p q))`.
123
- If `q = 0`, the p-adic norm of `q` is 0.
124
- -/
125
- def padic_norm (p : ℕ) (q : ℚ) : ℚ :=
126
- if q = 0 then 0 else (p : ℚ) ^ (-(padic_val_rat p q))
99
+ /-- If `q ≠ 0`, the `p`-adic norm of a rational `q` is `p ^ (-padicValRat p q)`.
100
+ If `q = 0`, the `p`-adic norm of `q` is `0`. -/
101
+ def padicNorm (p : ℕ) (q : ℚ) : ℚ :=
102
+ if q = 0 then 0 else (p : ℚ) ^ (-padicValRat p q)
127
103
```
128
104
129
105
An example that is slightly lying but still describes the mathematical content would be:
130
106
131
107
``` lean
132
- /--
133
- For `p ≠ 1`, the p-adic valuation of an integer `z ≠ 0` is the largest natural number `n` such that
134
- `p^n` divides `z`.
135
- `padic_val_rat` defines the valuation of a rational `q` to be the valuation of `q.num` minus the
136
- valuation of `q.denom`.
137
- If `q = 0` or `p = 1`, then `padic_val_rat p q` defaults to 0.
138
- -/
139
- def padic_val_rat (p : ℕ) (q : ℚ) : ℤ :=
140
- if h : q ≠ 0 ∧ p ≠ 1
141
- then (multiplicity (p : ℤ) q.num).get
142
- (multiplicity.finite_int_iff.2 ⟨h.2, rat.num_ne_zero_of_ne_zero h.1⟩) -
143
- (multiplicity (p : ℤ) q.denom).get
144
- (multiplicity.finite_int_iff.2 ⟨h.2, by exact_mod_cast rat.denom_ne_zero _⟩)
145
- else 0
108
+ /-- `padicValRat` defines the valuation of a rational `q` to be the valuation of `q.num` minus the
109
+ valuation of `q.den`. If `q = 0` or `p = 1`, then `padicValRat p q` defaults to `0`. -/
110
+ def padicValRat (p : ℕ) (q : ℚ) : ℤ :=
111
+ padicValInt p q.num - padicValNat p q.den
146
112
```
147
113
148
- The ` doc_blame ` linter lists all definitions that do not have doc strings. The ` doc_blame_thm `
114
+ The ` docBlame ` linter lists all definitions that do not have doc strings. The ` docBlameThm `
149
115
linter will lists theorems and lemmas that do not have doc strings.
150
116
151
- To run only the ` doc_blame ` linter, add the following to the end of your lean file:
117
+ To run only the ` docBlame ` linter, add the following to the end of your lean file:
152
118
```
153
- #lint only doc_blame
119
+ #lint only docBlame
154
120
```
155
- To run only the ` doc_blame ` and ` doc_blame_thm ` linters, add the following to the end of your lean
121
+ To run only the ` docBlame ` and ` docBlameThm ` linters, add the following to the end of your lean
156
122
file:
157
123
```
158
- #lint only doc_blame doc_blame_thm
124
+ #lint only docBlame docBlameThm
159
125
```
160
- To run the all default linters, including ` doc_blame ` , add the following to the end of your lean
126
+ To run the all default linters, including ` docBlame ` , add the following to the end of your lean
161
127
file:
162
128
```
163
129
#lint
164
130
```
165
- To run the all default linters, including ` doc_blame ` and run ` doc_blame_thm ` , add the following to
131
+ To run the all default linters, including ` docBlame ` and run ` docBlameThm ` , add the following to
166
132
the end of your lean file:
167
133
```
168
- #lint doc_blame_thm
134
+ #lint docBlameThm
169
135
```
170
136
171
137
## LaTeX and Markdown
172
138
173
139
We generally put references to Lean declarations or variables in between backticks. Writing
174
140
the fully-qualified name (e.g. ` finset.card_pos ` instead of just ` card_pos ` ) will turn the name
175
- into a link on our [ online docs] ( https://leanprover-community.github.io/mathlib_docs / ) .
141
+ into a link on our [ online docs] ( https://leanprover-community.github.io/mathlib4_docs / ) .
176
142
177
143
Raw URLs should be enclosed in angle brackets ` <...> ` to ensure that they will be clickable online.
178
144
(Some URLs, especially those with parentheses or other special symbols,
@@ -192,50 +158,6 @@ to preview the final result. See also the math.stackexchange
192
158
[ MathJax tutorial] ( https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference ) .
193
159
194
160
195
- ## Tactic doc entries
196
-
197
- Interactive tactics, user commands, hole commands and user attributes should have doc strings
198
- explaining how they can be used. The ` add_tactic_doc ` command should be invoked afterwards to add a
199
- doc entry to the appropriate page in the online docs.
200
-
201
- Example:
202
- ``` lean
203
- /--
204
- describe what the command does here
205
- -/
206
- add_tactic_doc
207
- { name := "display name of the tactic",
208
- category := cat,
209
- decl_names := [`dcl_1, `dcl_2],
210
- tags := ["tag_1", "tag_2"]
211
- }
212
- ```
213
-
214
- The argument to ` add_tactic_doc ` is a structure of type ` tactic_doc_entry ` .
215
- * ` name ` refers to the display name of the tactic; it is used as the header of the doc entry.
216
- * ` cat ` refers to the category of doc entry.
217
- Options: ` doc_category.tactic ` , ` doc_category.cmd ` , ` doc_category.hole_cmd ` , ` doc_category.attr `
218
- * ` decl_names ` is a list of the declarations associated with this doc. For instance,
219
- the entry for ` linarith ` would set `` decl_names := [`tactic.interactive.linarith] `` .
220
- Some entries may cover multiple declarations.
221
- It is only necessary to list the interactive versions of tactics.
222
- * ` tags ` is an optional list of strings used to categorize entries.
223
- * The doc string is the body of the entry. It can be formatted with markdown.
224
- What you are reading now is taken from the description of ` add_tactic_doc ` .
225
-
226
- If only one related declaration is listed in ` decl_names ` and if this
227
- invocation of ` add_tactic_doc ` does not have a doc string, the doc string of
228
- that declaration will become the body of the tactic doc entry. If there are
229
- multiple declarations, you can select the one to be used by passing a name to
230
- the ` inherit_description_from ` field.
231
-
232
- If you prefer a tactic to have a doc string that is different then the doc entry, then between
233
- the ` /-- ` ` -/ ` markers, write the desired doc string first, then ` --- ` surrounded by new lines,
234
- and then the doc entry.
235
-
236
- Note that providing a badly formed ` tactic_doc_entry ` to the command can result in strange error
237
- messages.
238
-
239
161
## Sectioning comments
240
162
241
163
It is common to structure a file in sections, where each section contains related declarations.
@@ -253,39 +175,34 @@ Third-level headers `###` should be used for titles inside sectioning comments.
253
175
If the comment is more than one line long, the delimiters ` /-! ` and ` -/ ` should appear on their own
254
176
lines.
255
177
256
- See [ meta/expr .lean] ( https://github.com/leanprover-community/mathlib /blob/master/src/meta/expr .lean ) for an example in practice.
178
+ See [ Lean/Expr/Basic .lean] ( https://github.com/leanprover-community/mathlib4 /blob/master/Mathlib/Lean/Expr/Basic .lean ) for an example in practice.
257
179
258
180
``` lean
259
- namespace binder_info
181
+ namespace BinderInfo
260
182
261
- /-!
262
- ### Declarations about `binder_info`
183
+ /-! ### Declarations about `BinderInfo` -/
263
184
264
- This section develops an extended API for the type `binder_info`.
265
- -/
266
-
267
- instance : inhabited binder_info := ⟨ binder_info.default ⟩
185
+ /-- The brackets corresponding to a given `BinderInfo`. -/
186
+ def brackets : BinderInfo → String × String
187
+ | BinderInfo.implicit => ("{", "}")
188
+ | BinderInfo.strictImplicit => ("{{", "}}")
189
+ | BinderInfo.instImplicit => ("[", "]")
190
+ | _ => ("(", ")")
268
191
269
- /-- The brackets corresponding to a given binder_info. -/
270
- def brackets : binder_info → string × string
271
- | binder_info.implicit := ("{", "}")
272
- | binder_info.strict_implicit := ("{{", "}}")
273
- | binder_info.inst_implicit := ("[", "]")
274
- | _ := ("(", ")")
192
+ end BinderInfo
275
193
276
- end binder_info
277
-
278
- namespace name
194
+ namespace Name
279
195
280
196
/-! ### Declarations about `name` -/
281
197
282
- /-- Find the largest prefix `n` of a `name ` such that `f n ≠ none`, then replace this prefix
198
+ /-- Find the largest prefix `n` of a `Name ` such that `f n != none`, then replace this prefix
283
199
with the value of `f n`. -/
284
- def map_prefix (f : name → option name) : name → name
285
- | anonymous := anonymous
286
- | (mk_string s n') := (f (mk_string s n')).get_or_else (mk_string s $ map_prefix n')
287
- | (mk_numeral d n') := (f (mk_numeral d n')).get_or_else (mk_numeral d $ map_prefix n')
288
-
200
+ def mapPrefix (f : Name → Option Name) (n : Name) : Name := Id.run do
201
+ if let some n' := f n then return n'
202
+ match n with
203
+ | anonymous => anonymous
204
+ | str n' s => mkStr (mapPrefix f n') s
205
+ | num n' i => mkNum (mapPrefix f n') i
289
206
```
290
207
291
208
## Theories documentation
@@ -316,10 +233,10 @@ The proof can be found in [Boole1854].
316
233
317
234
In the online docs, this will become something like:
318
235
319
- > The proof can be found in [[ Boo54]] ( https://leanprover-community.github.io/mathlib_docs /references.html )
236
+ > The proof can be found in [[ Boo54]] ( https://leanprover-community.github.io/mathlib4_docs /references.html )
320
237
321
238
(The key will change into an [ ` alpha ` style label] ( https://www.bibtex.com/s/bibliography-style-base-alpha/ )
322
- and become a link to the [ References page] ( https://leanprover-community.github.io/mathlib_docs /references.html )
239
+ and become a link to the [ References page] ( https://leanprover-community.github.io/mathlib4_docs /references.html )
323
240
of the docs.)
324
241
325
242
Alternatively, you can use custom text for the citation by putting text in square brackets
@@ -329,7 +246,7 @@ ahead of the citation key:
329
246
See [Grundlagen der Geometrie][hilbert1999] for an alternative axiomatization.
330
247
```
331
248
332
- > See [ Grundlagen der Geometrie] ( https://leanprover-community.github.io/mathlib_docs /references.html ) for an alternative axiomatization.
249
+ > See [ Grundlagen der Geometrie] ( https://leanprover-community.github.io/mathlib4_docs /references.html ) for an alternative axiomatization.
333
250
334
251
Note that you currently cannot use the closing square bracket ` ] ` symbol in the link text.
335
252
So the following will not result in a working link:
@@ -344,6 +261,6 @@ We follow [Euclid's *Elements* [Prop. 1]][heath1956a].
344
261
345
262
The following files are maintained as examples of good documentation style:
346
263
347
- * [ data/padics/padic_norm ] ( https://github.com/leanprover-community/mathlib /blob/master/src/number_theory/padics/padic_norm .lean )
348
- * [ topology/basic ] ( https://github.com/leanprover-community/mathlib /blob/master/src/topology/basic .lean )
349
- * [ analysis/calculus/cont_diff ] ( https://github.com/leanprover-community/mathlib /blob/master/src/analysis/calculus/cont_diff .lean )
264
+ * [ Mathlib.NumberTheory.Padics.PadicNorm ] ( https://github.com/leanprover-community/mathlib4 /blob/master/Mathlib/NumberTheory/Padics/PadicNorm .lean )
265
+ * [ Mathlib.Topology.Basic ] ( https://github.com/leanprover-community/mathlib4 /blob/master/Mathlib/Topology/Basic .lean )
266
+ * [ Analysis.Calculus.ContDiff ] ( https://github.com/leanprover-community/mathlib4 /blob/master/Mathlib/Analysis/Calculus/ContDiff .lean )
0 commit comments