{-

This is a HoTT-UF core library based on cubical type theory, where the
cubical machinery is hidden, using the HoTT Book terminology and
notation.

The point is that function extensionality, propositional truncation
and univalence compute (an example is given below).

For the moment, this requires the development version of Agda.

-}

{-# OPTIONS --exact-split --safe #-}

module Cubical.Experiments.HoTT-UF where

open import Cubical.Core.Primitives hiding ( _≡_ )

open import Cubical.Data.Equality public
     using ( _≡_            -- The identity type.
           ; refl           -- Unfortunately, pattern matching on refl is not available.
           ; J              -- Until it is, you have to use the induction principle J.

           ; transport      -- As in the HoTT Book.
           ; ap
           ; _∙_

           ; step-≡         -- Standard equational reasoning.
           ; _∎

           ; funExt         -- Function extensionality
                            -- (can also be derived from univalence).

           ; Σ              -- Sum type. Needed to define contractible types, equivalences
           ; _,_            -- and univalence.
           ; pr₁            -- The eta rule is available.
           ; pr₂

           ; isProp         -- The usual notions of proposition, contractible type, set.
           ; isContr

           ; isEquiv        -- A map with contractible fibers
                            -- (Voevodsky's version of the notion).
           ; _≃_            -- The type of equivalences between two given types.
           ; univalence
           ; ua             -- A formulation of univalence.

           ; ∥_∥₁            -- Propositional truncation.
           ; ∣_∣₁            -- Map into the propositional truncation.
           ; squash₁         -- A truncated type is a proposition.
           ; ∥∥-rec          -- Non-dependent elimination.
           ; ∥∥-elim         -- Dependent elimination.
           )
           renaming (sym to _⁻¹)

{-

Here is an illustration of how function extensionality computes.

-}

private

  data  : Type₀ where
   zero : 
   succ :   

  f g :   

  f n = n

  g zero = zero
  g (succ n) = succ (g n)

  h : (n : )  f n  g n
  h zero = refl
  h (succ n) = ap succ (h n)

  p : f  g
  p = funExt h

  five : 
  five = succ (succ (succ (succ (succ zero))))

  a : Σ   n  f n  five)
  a = five , refl

  b : Σ   n  g n  five)
  b = transport  -  Σ   n  - n  five)) p a

  c : pr₁ b  five
  c = refl

{-

If we had funExt as a postulate, then the definition of c would not
type check. Moreover, the term pr₁ b would not evaluate to five, as it
does with the cubical type theory implementation of funext.

TODO. A similar computational example with univalence.

-}