module Data.Irr where

Strict propositional truncations🔗

As with how the propositional truncation freely generates a proposition from a type, we can define a strict truncation modality which freely generates a definitionally irrelevant type from a type.

This is a secondary notion in our type theory, since this type former does not have a well-behaved elimination principle. However, its presence in the theory allows defining record types with finer control over definitional equality, which can be a notable optimisation; and the resulting types are essentially well-behaved as long as we only wrap decidable propositions.

The construction proceeds in two stages: first, we define Irrˢ, living in SProp, generated by This type is then wrapped in the record Irr to bring it back to the correct universe of fibrant types.

data Irrˢ {} (A : Type ) : SProp  where
  forgetˢ : A  Irrˢ A

record Irr {} (A : Type ) : Type  where
  constructor liftˢ
  field lowerˢ : Irrˢ A

As promised, Irr is definitionally irrelevant, as can be demonstrated by checking that the reflexive path connects the a priori distinct variables and

instance
  H-Level-Irr :  {n}  H-Level (Irr A) (suc n)
  H-Level-Irr {n} = prop-instance λ x y  refl

Recovering decidable propositions🔗

As mentioned above, Irr does not have a well-behaved elimination principle. However, since is a strict proposition, we can show that implies

Irr→not-not :  {} {A : Type }  Irr A  ¬ ¬ A
Irr→not-not {A = A} (liftˢ ) f = liftˢ (go  f) where
  go : Irrˢ A  (A  )  ⊥ˢ
  go (forgetˢ a) ¬a = ¬a a .⊥.lowerˢ

Therefore, if the type being truncated is decidable, we can recover a legitimate given only knowledge of using the result above to refute the no case.

recover :  {} {A : Type }  d : Dec A   Irr A  A
recover  yes x  _   = x
recover  no ¬x  ¬¬x = absurd (Irr→not-not ¬¬x ¬x)