Timings for Powers.v
From HoTT Require Import Basics Types TruncType.
 
From HoTT Require Import Universes.Smallness.
 
From HoTT Require Import Spaces.Card Spaces.Nat.Core.
 
(** * Definition of Power types *)
(* The definition is only used in Hartogs.v to allow defining a coercion, and one place below.  Everywhere else we prefer to write out the definition for clarity. *)
 
Definition power_type (A : Type) : Type
  := A -> HProp.
 
Lemma Injection_power {PR : PropResizing} X
  : IsHSet X -> Injection X (X -> HProp).
 
  set (f (x : X) := fun y => Build_HProp (smalltype (x = y))).
 
Definition power_iterated X n := nat_iter n power_type X.
 
Definition power_iterated_shift X n
  : power_iterated (X -> HProp) n = (power_iterated X n -> HProp)
  := (nat_iter_succ_r _ _ _)^.
 
Instance hset_power {UA : Univalence} (X : HSet)
  : IsHSet (X -> HProp).
 
  destruct (equiv_path_arrow p q) as [f [g Hfg Hgf _]].
 
  rewrite <- (Hfg H), <- (Hfg H').
 
Instance hset_power_iterated {UA : Univalence} (X : HSet) n
  : IsHSet (power_iterated X n).
 
  napply (nat_iter_invariant n power_type (fun A => IsHSet A)).
 
Lemma Injection_power_iterated {UA : Univalence} {PR : PropResizing} (X : HSet) n
  : Injection X (power_iterated X n).
 
 eapply Injection_trans; try exact IHn.
 
Lemma infinite_inject X Y
  : infinite X -> Injection X Y -> infinite Y.
 
Lemma infinite_power_iterated {UA : Univalence} {PR : PropResizing} (X : HSet) n
  : infinite X -> infinite (power_iterated X n).
 
 eapply infinite_inject; try apply H.
 
 apply Injection_power_iterated.