I was surprised to discover that the proof of Isomorphism.≲-antisym can be simplified.
Here is the original proof:
|
```agda |
|
≲-antisym : ∀ {A B : Set} |
|
→ (A≲B : A ≲ B) |
|
→ (B≲A : B ≲ A) |
|
→ (to A≲B ≡ from B≲A) |
|
→ (from A≲B ≡ to B≲A) |
|
------------------- |
|
→ A ≃ B |
|
≲-antisym A≲B B≲A to≡from from≡to = |
|
record |
|
{ to = to A≲B |
|
; from = from A≲B |
|
; from∘to = from∘to A≲B |
|
; to∘from = λ{y → |
|
begin |
|
to A≲B (from A≲B y) |
|
≡⟨ cong (to A≲B) (cong-app from≡to y) ⟩ |
|
to A≲B (to B≲A y) |
|
≡⟨ cong-app to≡from (to B≲A y) ⟩ |
|
from B≲A (to B≲A y) |
|
≡⟨ from∘to B≲A y ⟩ |
|
y |
|
∎} |
|
} |
|
``` |
Interestingly, one can pattern match against the arguments to≡from and from≡to resulting in this shorter proof:
≲-antisym A≲B B≲A to≡from@refl from≡to@refl =
record
{ to = to A≲B
; from = from A≲B
; from∘to = from∘to A≲B
; to∘from = from∘to B≲A
}
Matching against refl works only because records are subject to eta-expansion.
What is the argument for having the longer proof in the text?
I was surprised to discover that the proof of Isomorphism.≲-antisym can be simplified.
Here is the original proof:
plfa.github.io/src/plfa/part1/Isomorphism.lagda.md
Lines 397 to 421 in 8e5406e
Interestingly, one can pattern match against the arguments
to≡fromandfrom≡toresulting in this shorter proof:Matching against
reflworks only because records are subject to eta-expansion.What is the argument for having the longer proof in the text?