Skip to content

Commit

Permalink
feat: Add instance of Infinite String (#1973)
Browse files Browse the repository at this point in the history
This proves that the `String` type is infinite.
  • Loading branch information
loewenheim committed Mar 29, 2023
1 parent 26daa9a commit ba7950c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Mathlib/Data/Fintype/Card.lean
Expand Up @@ -42,7 +42,7 @@ See `Infinite.of_injective` and `Infinite.of_surjective`.
## Instances
We provide `Infinite` instances for
* specific types: `ℕ`, `ℤ`
* specific types: `ℕ`, `ℤ`, `String`
* type constructors: `Multiset α`, `List α`
-/
Expand Down Expand Up @@ -1039,6 +1039,12 @@ instance [Nonempty α] : Infinite (Multiset α) :=
instance [Nonempty α] : Infinite (List α) :=
Infinite.of_surjective ((↑) : List α → Multiset α) (surjective_quot_mk _)

instance String.infinite : Infinite String :=
Infinite.of_injective (String.mk) <| by
intro _ _ h
cases h with
| refl => rfl

instance Infinite.set [Infinite α] : Infinite (Set α) :=
Infinite.of_injective singleton Set.singleton_injective
#align infinite.set Infinite.set
Expand Down

0 comments on commit ba7950c

Please sign in to comment.