Built with Alectryon, running Coq+SerAPI v8.19.0+0.19.3. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑Ctrl+↓ to navigate, Ctrl+🖱️ to focus. On Mac, use ⌘ instead of Ctrl.
(** * Bounded Search *)(** The main result of this file is [minimal_n], which say that if [P : nat -> Type] is a family such that each [P n] is decidable and [{n & P n}] is merely inhabited, then [{n & P n}] is inhabited. Since [P n] is decidable, it is sufficient to prove [{n & merely (P n)}], and to do this, we prove the stronger claim that there is a *minimal* [n] satisfying [merely (P n)]. This stronger claim is a proposition, which is what makes the argument work. Along the way, we also prove that [{ l : nat & (l <= n) * P l }] is decidable for each [n]. *)
[Loading ML file number_string_notation_plugin.cmxs (using legacy method) ... done]
Require Import Types.Sigma Types.Prod.Require Import Truncations.Core.Require Import Spaces.Nat.Core.Sectionbounded_search.Context (P : nat -> Type) (P_dec : foralln, Decidable (P n)).(** We open [type_scope] again after [nat_scope] in order to use the product type notation. *)LocalOpen Scope nat_scope.LocalOpen Scope type_scope.Local Definitionminimal (n : nat) : Type := forallm : nat, P m -> n <= m.(** If we assume [Funext], then [minimal n] is a proposition. But to avoid needing [Funext], we propositionally truncate it. *)Local Definitionmin_n_Type : Type := { n : nat & merely (P n) * merely (minimal n) }.
P: nat -> Type P_dec: foralln : nat, Decidable (P n) P_inhab: hexists P
{n : nat & P n}
P: nat -> Type P_dec: foralln : nat, Decidable (P n) P_inhab: hexists P
{n : nat & P n}
P: nat -> Type P_dec: foralln : nat, Decidable (P n) P_inhab: hexists P n: nat p: merely (P n)
{n : nat & P n}
exact (n; fst merely_inhabited_iff_inhabited_stable p).Defined.(** As a consequence of [bounded_search] we deduce that bounded existence is decidable. See also [decidable_exists_bounded_nat] in Spaces/Lists/Theory.v for a similar result with different dependencies. *)
P: nat -> Type P_dec: foralln : nat, Decidable (P n) n: nat s: smaller n
Decidable {l : nat & (l <= n) * P l}
P: nat -> Type P_dec: foralln : nat, Decidable (P n) n: nat no_l: foralll : nat, l <= n -> ~ P l
Decidable {l : nat & (l <= n) * P l}
P: nat -> Type P_dec: foralln : nat, Decidable (P n) n: nat s: smaller n
Decidable {l : nat & (l <= n) * P l}
P: nat -> Type P_dec: foralln : nat, Decidable (P n) n, l: nat Pl: P l min: minimal l l_leq_n: l <= n
Decidable {l : nat & (l <= n) * P l}
exact (inl (l; (l_leq_n, Pl))).
P: nat -> Type P_dec: foralln : nat, Decidable (P n) n: nat no_l: foralll : nat, l <= n -> ~ P l
Decidable {l : nat & (l <= n) * P l}
P: nat -> Type P_dec: foralln : nat, Decidable (P n) n: nat no_l: foralll : nat, l <= n -> ~ P l
~ {l : nat & (l <= n) * P l}
P: nat -> Type P_dec: foralln : nat, Decidable (P n) n: nat no_l: foralll : nat, l <= n -> ~ P l l: nat l_leq_n: l <= n Pl: P l
Empty
exact (no_l l l_leq_n Pl).Defined.Endbounded_search.Sectionbounded_search_alt_type.Context (X : Type)
(e : nat <~> X)
(P : X -> Type)
(P_dec : forallx, Decidable (P x))
(P_inhab : hexists P).(** Bounded search works for types equivalent to the naturals even without full univalence. *)
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P
{x : X & P x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P
{x : X & P x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P P':= funn : nat => P (e n): nat -> Type
{x : X & P x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n)
{x : X & P x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n)
hexists P'
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P'_inhab: hexists P'
{x : X & P x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n)
hexists P'
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P_inhab: {x : _ & P x}
hexists P'
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P_inhab: {x : _ & P x}
{x : _ & P' x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P_inhab: {x : _ & P x} x: X p: P x
{x : _ & P' x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P_inhab: {x : _ & P x} x: X p: P x
P' (e^-1 x)
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P_inhab: {x : _ & P x} x: X p: P x
P (e (e^-1 x))
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P_inhab: {x : _ & P x} x: X p: P x
P x
exact p.
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P'_inhab: hexists P'
{x : X & P x}
X: Type e: nat <~> X P: X -> Type P_dec: forallx : X, Decidable (P x) P_inhab: hexists P P':= funn : nat => P (e n): nat -> Type P'_dec:= funn : nat => P_dec (e n) : Decidable (P' n): foralln : nat, Decidable (P' n) P'_inhab: hexists P' n: nat p': P' n