Why is pattern matching sometimes "essential" in Agda?
I'm taking this out of Programming Language Foundations in Agda.
When not pattern matching, Agda gives doesn't allow refl
in the hole:
η-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w
η-× x = ?
And it reports this goal and assumptions:
Goal: ⟨ proj₁ x , proj₂ x ⟩ ≡ x
————————————————————————————————————————————————————————————
x : A × B
But Agda can figure out what is going on if I tell it to case split (ctrl-c ctrl-c x Ret)
η-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w
η-× ⟨ x , x₁ ⟩ = ?
Goal: ⟨ x , x₁ ⟩ ≡ ⟨ x , x₁ ⟩
Then Agda lets me fill in the hole with refl
.
What's going on? How does doing the pattern match give Agda more information?
The PLFA text says:
The pattern matching on the left-hand side is essential, since replacing
w
by⟨ x , y ⟩
allows both sides of the propositional equality to simplify to the same term.
but that doesn't say why the pattern match helps the simplification, or when we can expect to see this effect.