feat(library/data/prod): define swap

This commit is contained in:
Leonardo de Moura 2015-04-01 17:30:37 -07:00
parent 7b64a47221
commit 3951b50282

View file

@ -27,4 +27,15 @@ namespace prod
(assume H, H ▸ and.intro rfl rfl)
(assume H, and.elim H (assume H₄ H₅, equal H₄ H₅)),
decidable_of_decidable_of_iff _ (iff.symm H₃)
definition swap {A : Type} : A × A → A × A
| (a, b) := (b, a)
theorem swap_swap {A : Type} : ∀ p : A × A, swap (swap p) = p
| (a, b) := rfl
theorem eq_of_swap_eq {A : Type} : ∀ p₁ p₂ : A × A, swap p₁ = swap p₂ → p₁ = p₂ :=
take p₁ p₂, assume seqs,
assert h₁ : swap (swap p₁) = swap (swap p₂), from congr_arg swap seqs,
by rewrite *swap_swap at h₁; exact h₁
end prod