Library HoTT_Tests.Truncations.Core
Tests for strip_truncations
Goal ∀ (A B C : Type) (P : A → Type),
IsHProp B → merely A → hexists P → hor A B → Tr (-1) C → Tr (-1) (A × sig P × (A + B) × C).
Proof.
intros A B C P HB a p ab c.
strip_truncations.
(* All four truncated hypotheses keep their names and have been replaced by their underlying types. *)
match type of a with A ⇒ idtac end.
match type of p with sig P ⇒ idtac end.
match type of ab with (A + B)%type ⇒ idtac end.
match type of c with C ⇒ idtac end.
(* The other hypotheses are untouched. *)
match type of HB with IsHProp B ⇒ idtac end.
exact (tr (a, p, ab, c)).
Defined.
IsHProp B → merely A → hexists P → hor A B → Tr (-1) C → Tr (-1) (A × sig P × (A + B) × C).
Proof.
intros A B C P HB a p ab c.
strip_truncations.
(* All four truncated hypotheses keep their names and have been replaced by their underlying types. *)
match type of a with A ⇒ idtac end.
match type of p with sig P ⇒ idtac end.
match type of ab with (A + B)%type ⇒ idtac end.
match type of c with C ⇒ idtac end.
(* The other hypotheses are untouched. *)
match type of HB with IsHProp B ⇒ idtac end.
exact (tr (a, p, ab, c)).
Defined.
A truncated hypothesis on which the goal depends is stripped using dependent elimination.
Goal ∀ (A : Type) (P : merely A → Type), (∀ x, IsHProp (P x))
→ (∀ a, P (tr a)) → ∀ x, P x.
Proof.
intros A P ? f x.
strip_truncations.
exact (f x).
Defined.
→ (∀ a, P (tr a)) → ∀ x, P x.
Proof.
intros A P ? f x.
strip_truncations.
exact (f x).
Defined.
Truncations behind local definitions are stripped too.
Section Local.
Context (A : Type).
Let mA := merely A.
Goal mA → merely A.
Proof.
intro a.
strip_truncations.
exact (tr a).
Defined.
End Local.
Context (A : Type).
Let mA := merely A.
Goal mA → merely A.
Proof.
intro a.
strip_truncations.
exact (tr a).
Defined.
End Local.
Let-bound hypotheses are not stripped.
Goal ∀ (A : Type), A → merely A.
Proof.
intros A a.
pose (b := tr a : merely A).
Fail strip_truncations.
Abort.
Proof.
intros A a.
pose (b := tr a : merely A).
Fail strip_truncations.
Abort.
Nothing is stripped if the goal is not appropriately truncated.
Goal ∀ (A : Type), merely A → Tr 0 A.
Proof.
intros A a.
Fail strip_truncations.
Abort.
Goal ∀ (A : Type), merely A → A.
Proof.
intros A a.
Fail strip_truncations.
Abort.
Proof.
intros A a.
Fail strip_truncations.
Abort.
Goal ∀ (A : Type), merely A → A.
Proof.
intros A a.
Fail strip_truncations.
Abort.
A truncation of a higher level than the goal is not stripped, but the others are.