{-# OPTIONS --without-K #-}


-- Agda-hott library.
-- Author: Mario Román

-- Truncation.  Propositional truncation of types. It works as an
-- adjoint, this is shared code with the Agda-mltt library.

open import Base
open import Equality
open import logic.Propositions

module logic.Truncation where

  private
    -- Higher inductive type, defined with equalities between any two
    -- members.
    data !∥_∥ {} (A : Type ) : Type  where
      !∣_∣ : A  !∥ A 

  ∥_∥ : ∀{} (A : Type )  Type 
   A  = !∥ A 

  ∣_∣ : ∀{} {X : Type }  X   X 
   x  = !∣ x 

  -- Any two elements of the truncated type are equal
  postulate trunc : ∀{} {A : Type }  isProp  A 

  -- Recursion principle
  trunc-rec : ∀{ℓᵢ ℓⱼ} {A : Type ℓᵢ} {P : Type ℓⱼ}  isProp P  (A  P)   A   P
  trunc-rec _ f !∣ x  = f x