The class GetElem coll idx elem valid implements the xs[i] notation.
Given xs[i] with xs : coll and i : idx, Lean looks for an instance of
GetElem coll idx elem valid and uses this to infer the type of return
value elem and side conditions valid required to ensure xs[i] yields
a valid value of type elem.
For example, the instance for arrays looks like
GetElem (Array α) Nat α (fun xs i => i < xs.size).
The proof side-condition valid xs i is automatically dispatched by the
get_elem_tactic tactic, which can be extended by adding more clauses to
get_elem_tactic_trivial.
- getElem : (xs : coll) → (i : idx) → valid xs i → elemThe syntax arr[i]gets thei'th element of the collectionarr. If there are proof side conditions to the application, they will be automatically inferred by theget_elem_tactictactic.The actual behavior of this class is type-dependent, but here are some important implementations: - arr[i] : αwhere- arr : Array αand- i : Nator- i : USize: does array indexing with no bounds check and a proof side goal- i < arr.size.
- l[i] : αwhere- l : List αand- i : Nat: index into a list, with proof side goal- i < l.length.
- stx[i] : Syntaxwhere- stx : Syntaxand- i : Nat: get a syntax argument, no side goal (returns- .missingout of range)
 There are other variations on this syntax: 
Instances
The syntax arr[i] gets the i'th element of the collection arr. If there
are proof side conditions to the application, they will be automatically
inferred by the get_elem_tactic tactic.
The actual behavior of this class is type-dependent, but here are some important implementations:
- arr[i] : αwhere- arr : Array αand- i : Nator- i : USize: does array indexing with no bounds check and a proof side goal- i < arr.size.
- l[i] : αwhere- l : List αand- i : Nat: index into a list, with proof side goal- i < l.length.
- stx[i] : Syntaxwhere- stx : Syntaxand- i : Nat: get a syntax argument, no side goal (returns- .missingout of range)
There are other variations on this syntax:
- arr[i]!is syntax for- getElem! arr iwhich should panic and return- default : αif the index is not valid.
- arr[i]?is syntax for- getElem?which should return- noneif the index is not valid.
- arr[i]'his syntax for- getElem arr i hwith- han explicit proof the index is valid.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The syntax arr[i] gets the i'th element of the collection arr. If there
are proof side conditions to the application, they will be automatically
inferred by the get_elem_tactic tactic.
The actual behavior of this class is type-dependent, but here are some important implementations:
- arr[i] : αwhere- arr : Array αand- i : Nator- i : USize: does array indexing with no bounds check and a proof side goal- i < arr.size.
- l[i] : αwhere- l : List αand- i : Nat: index into a list, with proof side goal- i < l.length.
- stx[i] : Syntaxwhere- stx : Syntaxand- i : Nat: get a syntax argument, no side goal (returns- .missingout of range)
There are other variations on this syntax:
- arr[i]!is syntax for- getElem! arr iwhich should panic and return- default : αif the index is not valid.
- arr[i]?is syntax for- getElem?which should return- noneif the index is not valid.
- arr[i]'his syntax for- getElem arr i hwith- han explicit proof the index is valid.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The syntax arr[i]? gets the i'th element of the collection arr or
returns none if i is out of bounds.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The syntax arr[i]! gets the i'th element of the collection arr and
panics i is out of bounds.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- One or more equations did not get rendered due to their size.