refactor(library/data/list/perm): prove auxiliary theorems using 'match-with'
This commit is contained in:
parent
56d20852aa
commit
afc75f141c
1 changed files with 26 additions and 29 deletions
|
@ -263,13 +263,15 @@ private theorem discr {P : Prop} {a b : A} {l₁ l₂ l₃ : list A} :
|
||||||
a::l₁ = l₂++(b::l₃) →
|
a::l₁ = l₂++(b::l₃) →
|
||||||
(l₂ = [] → a = b → l₁ = l₃ → P) →
|
(l₂ = [] → a = b → l₁ = l₃ → P) →
|
||||||
(∀ t, l₂ = a::t → l₁ = t++(b::l₃) → P) → P :=
|
(∀ t, l₂ = a::t → l₁ = t++(b::l₃) → P) → P :=
|
||||||
list.cases_on l₂
|
match l₂ with
|
||||||
(λ e h₁ h₂, begin rewrite append_nil_left at e, exact (list.no_confusion e (λ e₁ e₂, h₁ rfl e₁ e₂)) end)
|
| [] := λ e h₁ h₂, list.no_confusion e (λ e₁ e₂, h₁ rfl e₁ e₂)
|
||||||
(λ h t e h₁ h₂, begin
|
| h::t := λ e h₁ h₂,
|
||||||
rewrite append_cons at e, apply (list.no_confusion e), intros [e₁, e₂],
|
begin
|
||||||
|
apply (list.no_confusion e), intros [e₁, e₂],
|
||||||
rewrite e₁ at h₂,
|
rewrite e₁ at h₂,
|
||||||
exact (h₂ t rfl e₂)
|
exact (h₂ t rfl e₂)
|
||||||
end)
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Auxiliary theorem for performing cases-analysis on l₂.
|
-- Auxiliary theorem for performing cases-analysis on l₂.
|
||||||
-- We use it to prove perm_inv_core.
|
-- We use it to prove perm_inv_core.
|
||||||
|
@ -278,30 +280,25 @@ private theorem discr₂ {P : Prop} {a b c : A} {l₁ l₂ l₃ : list A} :
|
||||||
(l₂ = [] → l₃ = b::l₁ → a = c → P) →
|
(l₂ = [] → l₃ = b::l₁ → a = c → P) →
|
||||||
(l₂ = [a] → b = c → l₁ = l₃ → P) →
|
(l₂ = [a] → b = c → l₁ = l₃ → P) →
|
||||||
(∀ t, l₂ = a::b::t → l₁ = t++(c::l₃) → P) → P :=
|
(∀ t, l₂ = a::b::t → l₁ = t++(c::l₃) → P) → P :=
|
||||||
list.cases_on l₂
|
match l₂ with
|
||||||
(λ e H₁ H₂ H₃,
|
| [] := λ e H₁ H₂ H₃,
|
||||||
begin
|
list.no_confusion e (λ a_eq_c b_l₁_eq_l₃, H₁ rfl (eq.symm b_l₁_eq_l₃) a_eq_c)
|
||||||
apply (list.no_confusion e), intros [a_eq_c, b_l₁_eq_l₃],
|
| [h₁] := λ e H₁ H₂ H₃,
|
||||||
exact (H₁ rfl (eq.symm b_l₁_eq_l₃) a_eq_c)
|
begin
|
||||||
end)
|
rewrite [append_cons at e, append_nil_left at e],
|
||||||
(λ h₁ t₁,
|
apply (list.no_confusion e), intros [a_eq_h₁, rest],
|
||||||
list.cases_on t₁
|
apply (list.no_confusion rest), intros [b_eq_c, l₁_eq_l₃],
|
||||||
(λ e H₁ H₂ H₃,
|
rewrite [a_eq_h₁ at H₂, b_eq_c at H₂, l₁_eq_l₃ at H₂],
|
||||||
begin
|
exact (H₂ rfl rfl rfl)
|
||||||
rewrite [append_cons at e, append_nil_left at e],
|
end
|
||||||
apply (list.no_confusion e), intros [a_eq_h₁, rest],
|
| h₁::h₂::t₂ := λ e H₁ H₂ H₃,
|
||||||
apply (list.no_confusion rest), intros [b_eq_c, l₁_eq_l₃],
|
begin
|
||||||
rewrite [a_eq_h₁ at H₂, b_eq_c at H₂, l₁_eq_l₃ at H₂],
|
apply (list.no_confusion e), intros [a_eq_h₁, rest],
|
||||||
exact (H₂ rfl rfl rfl)
|
apply (list.no_confusion rest), intros [b_eq_h₂, l₁_eq],
|
||||||
end)
|
rewrite [a_eq_h₁ at H₃, b_eq_h₂ at H₃],
|
||||||
(λ h₂ t₂ e H₁ H₂ H₃,
|
exact (H₃ t₂ rfl l₁_eq)
|
||||||
begin
|
end
|
||||||
rewrite [*append_cons at e],
|
end
|
||||||
apply (list.no_confusion e), intros [a_eq_h₁, rest],
|
|
||||||
apply (list.no_confusion rest), intros [b_eq_h₂, l₁_eq],
|
|
||||||
rewrite [a_eq_h₁ at H₃, b_eq_h₂ at H₃],
|
|
||||||
exact (H₃ t₂ rfl l₁_eq)
|
|
||||||
end))
|
|
||||||
|
|
||||||
/- permutation inversion -/
|
/- permutation inversion -/
|
||||||
theorem perm_inv_core {l₁ l₂ : list A} (p' : l₁ ~ l₂) : ∀ {a s₁ s₂}, l₁≈a|s₁ → l₂≈a|s₂ → s₁ ~ s₂ :=
|
theorem perm_inv_core {l₁ l₂ : list A} (p' : l₁ ~ l₂) : ∀ {a s₁ s₂}, l₁≈a|s₁ → l₂≈a|s₂ → s₁ ~ s₂ :=
|
||||||
|
|
Loading…
Reference in a new issue