Natural numbers with infinity #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
The natural numbers and an extra top
element ⊤
. This implementation uses part ℕ
as an
implementation. Use ℕ∞
instead unless you care about computability.
Main definitions #
The following instances are defined:
ordered_add_comm_monoid part_enat
canonically_ordered_add_monoid part_enat
complete_linear_order part_enat
There is no additive analogue of monoid_with_zero
; if there were then part_enat
could
be an add_monoid_with_top
.
-
to_with_top
: the map frompart_enat
toℕ∞
, with theorems that it plays well with+
and≤
. -
with_top_add_equiv : part_enat ≃+ ℕ∞
-
with_top_order_iso : part_enat ≃o ℕ∞
Implementation details #
part_enat
is defined to be part ℕ
.
+
and ≤
are defined on part_enat
, but there is an issue with *
because it's not
clear what 0 * ⊤
should be. mul
is hence left undefined. Similarly ⊤ - ⊤
is ambiguous
so there is no -
defined on part_enat
.
Before the open_locale classical
line, various proofs are made with decidability assumptions.
This can cause issues -- see for example the non-simp lemma to_with_top_zero
proved by rfl
,
followed by @[simp] lemma to_with_top_zero'
whose proof uses convert
.
Tags #
part_enat, ℕ∞
Type of natural numbers with infinity (⊤
)
Instances for part_enat
- part_enat.has_zero
- part_enat.inhabited
- part_enat.has_one
- part_enat.has_add
- part_enat.add_comm_monoid
- part_enat.add_comm_monoid_with_one
- part_enat.part.dom.can_lift
- part_enat.has_le
- part_enat.has_top
- part_enat.has_bot
- part_enat.has_sup
- part_enat.partial_order
- part_enat.semilattice_sup
- part_enat.order_bot
- part_enat.order_top
- part_enat.has_le.le.is_total
- part_enat.linear_order
- part_enat.bounded_order
- part_enat.lattice
- part_enat.ordered_add_comm_monoid
- part_enat.canonically_ordered_add_monoid
- part_enat.well_founded_lt
- part_enat.has_lt.lt.is_well_order
- part_enat.has_well_founded
- part_enat.linear_ordered_add_comm_monoid_with_top
- part_enat.complete_linear_order
The computable embedding ℕ → part_enat
.
This coincides with the coercion coe : ℕ → part_enat
, see part_enat.some_eq_coe
.
However, coe
is noncomputable so some
is preferable when computability is a concern.
Equations
Equations
Equations
- part_enat.inhabited = {default := 0}
Equations
- part_enat.has_one = {one := part_enat.some 1}
Equations
Equations
- part_enat.add_comm_monoid = {add := has_add.add part_enat.has_add, add_assoc := part_enat.add_comm_monoid._proof_1, zero := 0, zero_add := part_enat.add_comm_monoid._proof_2, add_zero := part_enat.add_comm_monoid._proof_3, nsmul := add_monoid.nsmul._default 0 has_add.add part_enat.add_comm_monoid._proof_4 part_enat.add_comm_monoid._proof_5, nsmul_zero' := part_enat.add_comm_monoid._proof_6, nsmul_succ' := part_enat.add_comm_monoid._proof_7, add_comm := part_enat.add_comm_monoid._proof_8}
Equations
- part_enat.add_comm_monoid_with_one = {nat_cast := part_enat.some, add := add_comm_monoid.add part_enat.add_comm_monoid, add_assoc := _, zero := add_comm_monoid.zero part_enat.add_comm_monoid, zero_add := _, add_zero := _, nsmul := add_comm_monoid.nsmul part_enat.add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, one := 1, nat_cast_zero := part_enat.add_comm_monoid_with_one._proof_1, nat_cast_succ := part_enat.add_comm_monoid_with_one._proof_2, add_comm := _}
Equations
- part_enat.has_bot = {bot := 0}
Equations
- x.decidable_le y = dite x.dom (λ (hx : x.dom), decidable_of_decidable_of_iff (show decidable (∀ (hy : y.dom), x.get hx ≤ y.get hy), from forall_prop_decidable (λ (hy : y.dom), x.get hx ≤ y.get hy)) _) (λ (hx : ¬x.dom), dite y.dom (λ (hy : y.dom), decidable.is_false _) (λ (hy : ¬y.dom), decidable.is_true _))
The coercion ℕ → part_enat
preserves 0
and addition.
Equations
- part_enat.coe_hom = {to_fun := coe coe_to_lift, map_zero' := part_enat.coe_hom._proof_1, map_add' := part_enat.coe_hom._proof_2}
Equations
- part_enat.partial_order = {le := has_le.le part_enat.has_le, lt := preorder.lt._default has_le.le, le_refl := part_enat.partial_order._proof_1, le_trans := part_enat.partial_order._proof_2, lt_iff_le_not_le := part_enat.partial_order._proof_3, le_antisymm := part_enat.partial_order._proof_4}
Equations
- part_enat.semilattice_sup = {sup := has_sup.sup part_enat.has_sup, le := partial_order.le part_enat.partial_order, lt := partial_order.lt part_enat.partial_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := part_enat.semilattice_sup._proof_1, le_sup_right := part_enat.semilattice_sup._proof_2, sup_le := part_enat.semilattice_sup._proof_3}
Equations
- part_enat.linear_order = {le := partial_order.le part_enat.partial_order, lt := partial_order.lt part_enat.partial_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := part_enat.linear_order._proof_1, decidable_le := classical.dec_rel has_le.le, decidable_eq := decidable_eq_of_decidable_le (classical.dec_rel has_le.le), decidable_lt := decidable_lt_of_decidable_le (classical.dec_rel has_le.le), max := has_sup.sup part_enat.has_sup, max_def := part_enat.linear_order._proof_2, min := min_default (λ (a b : part_enat), classical.dec_rel has_le.le a b), min_def := part_enat.linear_order._proof_3}
Equations
- part_enat.bounded_order = {top := order_top.top part_enat.order_top, le_top := _, bot := order_bot.bot part_enat.order_bot, bot_le := _}
Equations
- part_enat.lattice = {sup := semilattice_sup.sup part_enat.semilattice_sup, le := semilattice_sup.le part_enat.semilattice_sup, lt := semilattice_sup.lt part_enat.semilattice_sup, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := linear_order.min part_enat.linear_order, inf_le_left := _, inf_le_right := _, le_inf := part_enat.lattice._proof_1}
Equations
- part_enat.ordered_add_comm_monoid = {add := add_comm_monoid.add part_enat.add_comm_monoid, add_assoc := _, zero := add_comm_monoid.zero part_enat.add_comm_monoid, zero_add := _, add_zero := _, nsmul := add_comm_monoid.nsmul part_enat.add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, le := linear_order.le part_enat.linear_order, lt := linear_order.lt part_enat.linear_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := part_enat.ordered_add_comm_monoid._proof_1}
Equations
- part_enat.canonically_ordered_add_monoid = {add := ordered_add_comm_monoid.add part_enat.ordered_add_comm_monoid, add_assoc := _, zero := ordered_add_comm_monoid.zero part_enat.ordered_add_comm_monoid, zero_add := _, add_zero := _, nsmul := ordered_add_comm_monoid.nsmul part_enat.ordered_add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, le := semilattice_sup.le part_enat.semilattice_sup, lt := semilattice_sup.lt part_enat.semilattice_sup, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := _, bot := order_bot.bot part_enat.order_bot, bot_le := _, exists_add_of_le := part_enat.canonically_ordered_add_monoid._proof_1, le_self_add := part_enat.canonically_ordered_add_monoid._proof_2}
Computably converts an part_enat
to a ℕ∞
.
Equations
equiv
between part_enat
and ℕ∞
(for the order isomorphism see
with_top_order_iso
).
Equations
- part_enat.with_top_equiv = {to_fun := λ (x : part_enat), x.to_with_top, inv_fun := λ (x : ℕ∞), part_enat.with_top_equiv._match_1 x, left_inv := part_enat.with_top_equiv._proof_1, right_inv := part_enat.with_top_equiv._proof_2}
- part_enat.with_top_equiv._match_1 (option.some n) = ↑n
- part_enat.with_top_equiv._match_1 option.none = ⊤
to_with_top
induces an order isomorphism between part_enat
and ℕ∞
.
Equations
- part_enat.with_top_order_iso = {to_equiv := {to_fun := part_enat.with_top_equiv.to_fun, inv_fun := part_enat.with_top_equiv.inv_fun, left_inv := _, right_inv := _}, map_rel_iff' := part_enat.with_top_order_iso._proof_1}
to_with_top
induces an additive monoid isomorphism between part_enat
and ℕ∞
.
Equations
- part_enat.with_top_add_equiv = {to_fun := part_enat.with_top_equiv.to_fun, inv_fun := part_enat.with_top_equiv.inv_fun, left_inv := _, right_inv := _, map_add' := part_enat.with_top_add_equiv._proof_1}
Equations
Equations
- part_enat.linear_ordered_add_comm_monoid_with_top = {le := linear_order.le part_enat.linear_order, lt := linear_order.lt part_enat.linear_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := linear_order.decidable_le part_enat.linear_order, decidable_eq := linear_order.decidable_eq part_enat.linear_order, decidable_lt := linear_order.decidable_lt part_enat.linear_order, max := linear_order.max part_enat.linear_order, max_def := _, min := linear_order.min part_enat.linear_order, min_def := _, add := ordered_add_comm_monoid.add part_enat.ordered_add_comm_monoid, add_assoc := _, zero := ordered_add_comm_monoid.zero part_enat.ordered_add_comm_monoid, zero_add := _, add_zero := _, nsmul := ordered_add_comm_monoid.nsmul part_enat.ordered_add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, add_le_add_left := _, top := order_top.top part_enat.order_top, le_top := _, top_add' := part_enat.top_add}
Equations
- part_enat.complete_linear_order = {sup := has_sup.sup part_enat.has_sup, le := has_le.le part_enat.has_le, lt := has_lt.lt (preorder.to_has_lt part_enat), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := has_inf.inf (semilattice_inf.to_has_inf part_enat), inf_le_left := _, inf_le_right := _, le_inf := _, Sup := complete_lattice.Sup part_enat.with_top_order_iso.symm.to_galois_insertion.lift_complete_lattice, le_Sup := part_enat.complete_linear_order._proof_1, Sup_le := part_enat.complete_linear_order._proof_2, Inf := complete_lattice.Inf part_enat.with_top_order_iso.symm.to_galois_insertion.lift_complete_lattice, Inf_le := part_enat.complete_linear_order._proof_3, le_Inf := part_enat.complete_linear_order._proof_4, top := ⊤, bot := ⊥, le_top := part_enat.complete_linear_order._proof_5, bot_le := part_enat.complete_linear_order._proof_6, le_total := _, decidable_le := linear_order.decidable_le part_enat.linear_order, decidable_eq := linear_order.decidable_eq part_enat.linear_order, decidable_lt := linear_order.decidable_lt part_enat.linear_order, max_def := _, min_def := _}