Arend icon indicating copy to clipboard operation
Arend copied to clipboard

Is that a problem of variable inference?

Open ice1000 opened this issue 4 years ago • 5 comments

I have a proof that type-checks:

\import Arith.Int
\import Function
\import Homotopy.Sphere.Circle
\import Paths

\func transport-ap-assoc {A :\Type} (cover : A -> \Type)
                         {a a' : A} (p : a = a')
  : transport cover p = transport id (pmap cover p) \elim p
  | idp => idp

\func transport-code-loop : transport code (path loop) = isuc =>
  transport code (path loop)                    ==< transport-ap-assoc code (path loop) >==
  transport id (pmap code (path loop))          ==< pmap (transport id) lemma >==
  transport id (path (\lam i => code (loop i))) `qed
  \where {
    \func lemma : pmap code (path loop) = path (\lam i => code (loop i)) => idp
  }

I'm using a lemma whose type is whatever but the body is idp, which means its lhs and rhs are convertible. However, when I inline lemma, say, replace it with idp directly, Arend gives me type error.

Why should this happen?

The does-not-work code:

\func transport-code-loop : transport code (path loop) = isuc =>
  transport code (path loop)                    ==< transport-ap-assoc code (path loop) >==
  transport id (pmap code (path loop))          ==< pmap (transport id) lemma >==
  transport id (path (\lam i => code (loop i))) `qed

The error message:

[ERROR] bug.ard:13:53: Type mismatch
  Expected type: transport id (pmap code (path loop)) = ?a'
    Actual type: transport id ?a = transport id ?a'

ice1000 avatar Jul 14 '20 15:07 ice1000

I guess it tries to unify the two sides without trying to compute one of them.

ice1000 avatar Jul 14 '20 15:07 ice1000

Can't you just write

\func transport-code-loop : transport code (path loop) = isuc => transport-ap-assoc code (path loop)

?

valis avatar Jul 14 '20 16:07 valis

That's not related to this inference problem. The proof can be simplified, and I'm aware of that

ice1000 avatar Jul 14 '20 20:07 ice1000

Even \func transport-code-loop : transport code (path loop) = isuc => idp works.

valis avatar Jul 14 '20 21:07 valis

Anyway, the problem is pmap (transport id) idp. Arguments for pmap cannot be inferred from idp (since they are not specified there, but they are specified in lemma so it works with it) and they cannot be inferred from the expected type because one of them evaluates to isuc and it doesn't match the expression from the type of pmap (which is transport id ... ?a).

valis avatar Jul 14 '20 21:07 valis