The nth Number Satisfying a Predicate #
This file defines a function for "what is the nth number that satisfies a given predicate p",
and provides lemmas that deal with this function and its connection to Nat.count.
Main definitions #
Nat.nth p n: Then-th naturalk(zero-indexed) such thatp k. If there is no such natural (that is,pis true for at mostnnaturals), thenNat.nth p n = 0.
Main results #
Nat.nth_eq_orderEmbOfFin: For a finitely-often truep, gives the cardinality of the set of numbers satisfyingpabove particular values ofnth pNat.gc_count_nth: Establishes a Galois connection betweenNat.nth pandNat.count p.Nat.nth_eq_orderIsoOfNat: For an infinitely-often true predicate,nthagrees with the order-isomorphism of the subtype to the natural numbers.
There has been some discussion on the subject of whether both of nth and
Nat.Subtype.orderIsoOfNat should exist. See discussion
here.
Future work should address how lemmas that use these should be written.
Find the n-th natural number satisfying p (indexed from 0, so nth p 0 is the first
natural number satisfying p), or 0 if there is no such number. See also
Subtype.orderIsoOfNat for the order isomorphism with ℕ when p is infinitely often true.
Equations
Instances For
When s is an infinite set, nth agrees with Nat.Subtype.orderIsoOfNat.
When s is an infinite set, nth agrees with Nat.Subtype.orderIsoOfNat.
Lemmas that work for finite and infinite sets #
If a predicate p : ℕ → Prop is true for infinitely many numbers, then Nat.count p and
Nat.nth p form a Galois insertion.
Equations
- Nat.giCountNth hp = GaloisInsertion.monotoneIntro ⋯ ⋯ ⋯ ⋯