TheHoTTGame/1FundamentalGroup/Quest0Part2.md
2021-09-15 19:15:12 +01:00

4.6 KiB

refl ≡ loop is empty - Defining flipPath via Univalence

In this part, we will define the path flipPath : Bool ≡ Bool. Recall the picture of doubleCover. (Insert gif.)

This means we need flipPath to correspond to the unique non-identity permutation of Bool that flips true and false.

We proceed in steps :

  1. Define the function Flip : Bool → Bool.
  2. Promote this to an isomorphism flipIso : Bool ≅ Bool.
  3. The intuition is that the univalence axiom asserts that paths in the space of spaces correspond to homotopy-equivalences of spaces. As a corollary, we can make paths in Type from isomorphisms of types. We use this to turn flipIso into a path flipPath : Bool ≡ Bool.

The function

  • In 1FundamentalGroup/Quest0.agda, navigate to :

    Flip : Bool  Bool
    Flip x = {!!}
    
  • Write x inside the hole, and do C-c C-c with your cursor still inside. The c stands for cases. You should now see :

    Flip : Bool  Bool
    Flip false = {!!}
    Flip true = {!!} 
    

    What this is saying is that the space Bool is made of two points false, true and nothing else, so to map out of it, it suffices to give something to map false and true to respectively.

  • Since we want Flip to flip true and false, fill the first hole with true and the second with false.

  • To check things have worked, try C-c C-d. (d stands for deduce.) Then agda will ask you to input an expression. Enter Flip. In the *Agda Information* window, you should see

    Bool  Bool  
    

    This means agda recognises Flip as a well-formulated term and is a point in the space of maps from Bool to Bool.

  • We can also ask agda to compute outputs of Flip. Try C-c C-n. (n stands for normalise.) agda should again be asking for an expression. Enter Flip true. In the *Agda Information* window, you should see false, as desired.

The isomorphism

  • Navigate to

    flipIso : Bool  Bool
    flipIso = {!!} 
    
  • Write iso in the hole and refine with C-c C-r. You should now see

    flipIso : Bool  Bool
    flipIso = iso {!!} {!!} {!!} {!!}  
    
  • Check that what agda is expecting in the first two holes are functions Bool → Bool. These are our maps back and forth which will constitute the isomorphism so write Flip and Flip in the first two holes.

  • Check the goal of the next two holes. They should be

    section Flip Flip 
    

    and

    retract Flip Flip 
    

    This means we need to prove Flip is a right inverse and a left inverse of Flip.

  • Write the following so that your code looks like

    flipIso : Bool  Bool 
    flipIso = iso Flip Flip s r where
    
      s : section Flip Flip
      s b = {!!}
    
      r : retract Flip Flip
      r b = {!!} 
    

    The where allows you to make definitions local to the current definition, in the sense that you will not be able to access s and r outside this proof. Note that what follows where must be indented.

  • Check the goal of the hole s b = {!!}. In the *Agda Information* window, you should see

    Goal: Flip (Flip b)  b
    —————————————————————————————————
    b : Bool 
    

    Try to prove this.

    Hint

    You need to do cases on what b can be. Then for the case of true and false, try C-c C-r to see if agda can help.

  • Do the same for r b = {!!}.

  • Use C-c C-d to check that agda is okay with flipIso.

The path

  • Navigate to

    flipPath : Bool  Bool
    flipPath = {!!} 
    
  • In the hole, write in isoToPath and refine with C-c C-r. You should now have

    flipPath : Bool  Bool
    flipPath = isoToPath {!!} 
    

    If you check the new hole, you should see that agda is expecting an isomorphism Bool ≅ Bool.

    isoToPath is the function from the cubical library that converts isomorphisms between spaces into paths between the corresponding points in the space of spaces Type.

  • Fill in the hole with flipIso and use C-c C-d to check agda is happy with flipPath.

  • Try C-c C-n with transport flipPath false. You should get true in the *Agda Information* window.

    What transport did is it took the path flipPath in the space of spaces Type and followed the point false as Bool is transformed along flipPath. The end result is of course true, since flipPath is the path obtained from flip!