I'm trying to write the following function:
justEq : ∀ {A} -> (x y : A) -> (just x ≡ just y) -> (x ≡ y)
justEq x y pf = {!!}
I don't know how to write this. To me, it is intuitive to the point of being axiomatic, but the compiler doesn't accept refl as a proof of it.
I'm routinely having to prove these sorts of things, for example, showing that if two non-empty lists are equal, then their heads are equal.
What is the general approach to this? Is this related to Conor McBride's "green-goo" of having functions in the return of Constructors?
The basis of the solution is to pattern match on
pf
beingrefl
together with using a dotted pattern fory
being equal tox
(because of the type ofrefl
!).At this point, the type of the hole on the right-hand side has been unified to
(x ≡ x)
because of they = .x
equality from the pattern match, meaning you can userefl
as a well-typed value, giving