Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. lemma eq_of_kth_eq [deceqA : decidable_eq A]
  2. : ∀ {l1 l2 : list A} (Pleq : length l1 = length l2),
  3. (∀ (k : nat) (Plt1 : k < length l1) (Plt2 : k < length l2), kth k l1 Plt1 = kth k l2 Plt2) → l1 = l2
  4. | [] [] h₁ h₂ := rfl
  5. | (a₁::l₁) [] h₁ h₂ := by contradiction
  6. | [] (a₂::l₂) h₁ h₂ := by contradiction
  7. | (a₁::l₁) (a₂::l₂) h₁ h₂ :=
  8. have ih₁ : length l₁ = length l₂, by injection h₁; eassumption,
  9. have ih₂ : ∀ (k : nat) (plt₁ : k < length l₁) (plt₂ : k < length l₂), kth k l₁ plt₁ = kth k l₂ plt₂,
  10. begin
  11. intro k plt₁ plt₂,
  12. have splt₁ : succ k < length l₁ + 1, from succ_le_succ plt₁,
  13. have splt₂ : succ k < length l₂ + 1, from succ_le_succ plt₂,
  14. have keq : kth (succ k) (a₁::l₁) splt₁ = kth (succ k) (a₂::l₂) splt₂, from h₂ (succ k) splt₁ splt₂,
  15. rewrite *kth_succ_of_cons at keq,
  16. exact keq
  17. end,
  18. assert ih : l₁ = l₂, from eq_of_kth_eq ih₁ ih₂,
  19. assert k₁ : a₁ = a₂,
  20. begin
  21. have lt₁ : 0 < length (a₁::l₁), from !zero_lt_succ,
  22. have lt₂ : 0 < length (a₂::l₂), from !zero_lt_succ,
  23. have e₁ : kth 0 (a₁::l₁) lt₁ = kth 0 (a₂::l₂) lt₂, from h₂ 0 lt₁ lt₂,
  24. rewrite *kth_zero_of_cons at e₁,
  25. assumption
  26. end,
  27. by subst l₁; subst a₁
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement