command ::= ... |declModifiers
`declModifiers` is the collection of modifiers on a declaration: * a doc comment `/-- ... -/` * a list of attributes `@[attr1, attr2]` * a visibility specifier, `private` or `protected` * `noncomputable` * `unsafe` * `partial` or `nonrec` All modifiers are optional, and have to come in the listed order. `nestedDeclModifiers` is the same as `declModifiers`, but attributes are printed on the same line as the declaration. It is used for declarations nested inside other syntax, such as inductive constructors, structure projections, and `let rec` / `where` definitions.
inductive
In Lean, every concrete type other than the universes and every type constructor other than dependent arrows is an instance of a general family of type constructions known as inductive types. It is remarkable that it is possible to construct a substantial edifice of mathematics based on nothing more than the type universes, dependent arrow types, and inductive types; everything else follows from those. Intuitively, an inductive type is built up from a specified list of constructors. For example, `List Ξ±` is the list of elements of type `Ξ±`, and is defined as follows: ``` inductive List (Ξ± : Type u) where | nil | cons (head : Ξ±) (tail : List Ξ±) ``` A list of elements of type `Ξ±` is either the empty list, `nil`, or an element `head : Ξ±` followed by a list `tail : List Ξ±`. See [Inductive types](https://lean-lang.org/theorem_proving_in_lean4/inductive_types.html) for more information.
declId
`declId` matches `foo` or `foo.{u,v}`: an identifier possibly followed by a list of universe names
optDeclSig where (|
`optDeclSig` matches the signature of a declaration with optional type: a list of binders and then possibly `: type`
declModifiers ident
`declModifiers` is the collection of modifiers on a declaration: * a doc comment `/-- ... -/` * a list of attributes `@[attr1, attr2]` * a visibility specifier, `private` or `protected` * `noncomputable` * `unsafe` * `partial` or `nonrec` All modifiers are optional, and have to come in the listed order. `nestedDeclModifiers` is the same as `declModifiers`, but attributes are printed on the same line as the declaration. It is used for declarations nested inside other syntax, such as inductive constructors, structure projections, and `let rec` / `where` definitions.
optDeclSig)* (deriving ident,*)?
`optDeclSig` matches the signature of a declaration with optional type: a list of binders and then possibly `: type`
Declares a new inductive type.
The meaning of the declModifiers
is as described in the section on declaration modifiers.