Zulip Chat Archive
Stream: Is there code for X?
Topic: Finite types
Ben (Feb 25 2022 at 11:36):
How do finite types work in lean 3? #check (100: fin 8) is being passed as valid which is unexpected?
Mario Carneiro (Feb 25 2022 at 11:37):
fin 8 is the set of natural numbers less than 8, but 100 doesn't mean what you think there
Mario Carneiro (Feb 25 2022 at 11:37):
it actually means 100 % 8 = 4
Mario Carneiro (Feb 25 2022 at 11:38):
this is because numeral desugaring is defined generically for anything with a 0,1,+, and fin n (for n>0) has these operations defined via modulo arithmetic
Mario Carneiro (Feb 25 2022 at 11:40):
If you want the natural number 100, you should write #check (⟨100, _⟩ : fin 8) where the _ is a proof obligation of 100 < 8 that of course you can't fill
Ben (Feb 25 2022 at 11:48):
Interesting, I did not know it did that to the number in that way. That makes sense now :thumbs_up:
Last updated: May 02 2025 at 03:31 UTC