If n > 0, then natural number literals can be used for Fin n:
example : Fin 5 := 3
example : Fin 20 := 19
When the literal is greater than or equal to n, the remainder when dividing by n is used:
2#eval (5 : Fin 3)
[0, 1, 2, 0, 1, 2, 0]#eval ([0, 1, 2, 3, 4, 5, 6] : List (Fin 3))
If Lean can't synthesize an instance of NeZero n, then there is no OfNat (Fin n) instance:
example : Fin 0 := failed to synthesize
OfNat (Fin 0) 0
numerals are polymorphic in Lean, but the numeral `0` cannot be used in a context where the expected type is
Fin 0
due to the absence of the instance above
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.0
failed to synthesize
OfNat (Fin 0) 0
numerals are polymorphic in Lean, but the numeral `0` cannot be used in a context where the expected type is
Fin 0
due to the absence of the instance above
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
example (k : Nat) : Fin k := failed to synthesize
OfNat (Fin k) 0
numerals are polymorphic in Lean, but the numeral `0` cannot be used in a context where the expected type is
Fin k
due to the absence of the instance above
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.0
failed to synthesize
OfNat (Fin k) 0
numerals are polymorphic in Lean, but the numeral `0` cannot be used in a context where the expected type is
Fin k
due to the absence of the instance above
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.