@@ -259,6 +259,44 @@ check le_of_mul_le_mul_left
259
259
check le_of_mul_le_mul_right
260
260
```
261
261
262
+ ## Naming of structural lemmas ##
263
+
264
+ We are trying to standardize certain naming patterns for structural lemmas.
265
+ At present these are not uniform across mathlib.
266
+
267
+ ### Extensionality ###
268
+
269
+ A lemma of the form ` (∀ x, f x = g x) → f = g ` should be named ` .ext ` ,
270
+ and labelled with the ` @[ext] ` attribute.
271
+ Often this type of lemma can be generated automatically by putting the
272
+ ` @[ext] ` attribute on a structure.
273
+ (However an automatically generated lemma will always be written in terms
274
+ of the structure projections, and often there is a better statement,
275
+ e.g. using coercions, that should be written by hand then marked with ` @[ext] ` .)
276
+
277
+
278
+ A lemma of the form ` f = g ↔ ∀ x, f x = g x ` should be named ` .ext_iff ` .
279
+
280
+ ### Injectivity ###
281
+
282
+ Injectivity lemmas should usually be written as bidirectional implications,
283
+ e.g. as ` f x = f y ↔ x = y ` . Such lemmas should be named ` f_inj `
284
+ (although if they are in an appropriate namespace ` .inj ` is good too).
285
+ Bidirectional injectivity lemmas are often good candidates for ` @[simp] ` .
286
+ There are still many unidirectional implications named ` inj ` in mathlib,
287
+ and it is reasonable to update and replace these as you come across them.
288
+
289
+ Note however that constructors for inductive types have
290
+ automatically generated unidirectional implications, named ` .inj ` ,
291
+ and there is no intention to change this.
292
+ When such an automatically generated lemma already exists,
293
+ and a bidirectional lemma is needed, it may be named ` .inj_iff ` .
294
+
295
+ Injectivity lemmas written in terms of an ` injective f ` conclusion
296
+ should instead use the full word ` injective ` , typically as ` f_injective ` .
297
+ The form ` injective_f ` still appears often in mathlib.
298
+
299
+
262
300
------
263
301
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
264
302
Released under Apache 2.0 license as described in the file LICENSE.
0 commit comments