mathlib3 documentation

data.nat.upto

nat.upto #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

nat.upto p, with p a predicate on , is a subtype of elements n : ℕ such that no value (strictly) below n satisfies p.

This type has the property that > is well-founded when ∃ i, p i, which allows us to implement searches on , starting at 0 and with an unknown upper-bound.

It is similar to the well founded relation constructed to define nat.find with the difference that, in nat.upto p, p does not need to be decidable. In fact, nat.find could be slightly altered to factor decidability out of its well founded relation and would then fulfill the same purpose as this file.

@[reducible]
def nat.upto (p : Prop) :

The subtype of natural numbers i which have the property that no j less than i satisfies p. This is an initial segment of the natural numbers, up to and including the first value satisfying p.

We will be particularly interested in the case where there exists a value satisfying p, because in this case the > relation is well-founded.

Equations
@[protected]
def nat.upto.gt (p : Prop) (x y : nat.upto p) :
Prop

Lift the "greater than" relation on natural numbers to nat.upto.

Equations
@[protected, instance]
def nat.upto.has_lt {p : Prop} :
Equations
@[protected]
theorem nat.upto.wf {p : Prop} :

The "greater than" relation on upto p is well founded if (and only if) there exists a value satisfying p.

def nat.upto.zero {p : Prop} :

Zero is always a member of nat.upto p because it has no predecessors.

Equations
def nat.upto.succ {p : Prop} (x : nat.upto p) (h : ¬p x.val) :

The successor of n is in nat.upto p provided that n doesn't satisfy p.

Equations