Constructing a path with constraints in an isSet type

主宰稳场 提交于 2019-12-02 03:53:48

Ideally you'd just be able to write

rightEndpointsButConstraintsDon'tHold j = fillSquare _ _ _ _ i j

but the paths there are not uniquely determined "in the middle" so unification won't solve them.

Luckily there's another cheap way to find them out, let me first fix some definitions:

open import Cubical.Core.Everything
open import Cubical.Foundations.Everything

data FreeMonoid (A : Set) : Set where
  [_]    : A → FreeMonoid A
  ε      : FreeMonoid A
  _*_    : FreeMonoid A → FreeMonoid A → FreeMonoid A
  e^l : ∀ m → ε * m ≡ m

data List (A : Set) : Set where

variable
  A : Set

fromList : List A → FreeMonoid A
toList : FreeMonoid A → List A

fillSquare : isSet' (FreeMonoid A)

from-to : ∀ (m : FreeMonoid A) → fromList (toList m) ≡ m
from-to (e^l m i) j = ?

Our current goal is supposed to answer what happens when we reduce \ i j -> from-to (el^ m i) j, luckily we can rephrase that expression in a way where inference will do what we want.

We ask for the type of cong from-to (e^l m):

PathP (λ i₁ → fromList (toList (e^l m i₁)) ≡ e^l m i₁)
(from-to (ε * m)) (from-to m)

Now we can match it with the type of fillSquare and solve our goal:

from-to (e^l m i) j 
  = fillSquare (from-to (ε * m)) (from-to m) 
               (λ i → fromList (toList (e^l m i))) (e^l m)
               i j

There's still a catch, the recursive call to from-to (ε * m) will not be seen as terminating, but if you expand that using the clauses of from-to for ε and _*_ it should work out.

Btw, the order of the paths in isSet' and Square differ which made this extra confusing, I think I'll open an issue about it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!