refactor(library/data/fin): simplify 'fin' module using new inversion tactic
This commit is contained in:
parent
ad0dfb4c64
commit
011e955fed
1 changed files with 6 additions and 20 deletions
|
@ -8,32 +8,18 @@ fs : Π {n}, fin n → fin (succ n)
|
||||||
namespace fin
|
namespace fin
|
||||||
|
|
||||||
definition z_cases_on (C : fin zero → Type) (p : fin zero) : C p :=
|
definition z_cases_on (C : fin zero → Type) (p : fin zero) : C p :=
|
||||||
have aux : Π (C : Type) (n : nat) (p : fin n), n = zero → C, from
|
by cases p
|
||||||
λ C n p, fin.rec_on p
|
|
||||||
(λ n h, nat.no_confusion h)
|
|
||||||
(λ n f ih h, nat.no_confusion h),
|
|
||||||
aux (C p) zero p rfl
|
|
||||||
|
|
||||||
definition nz_cases_on {C : Π n, fin (succ n) → Type}
|
definition nz_cases_on {C : Π n, fin (succ n) → Type}
|
||||||
(H₁ : Π n, C n (fz n))
|
(H₁ : Π n, C n (fz n))
|
||||||
(H₂ : Π n (f : fin n), C n (fs f))
|
(H₂ : Π n (f : fin n), C n (fs f))
|
||||||
{n : nat}
|
{n : nat}
|
||||||
(f : fin (succ n)) : C n f :=
|
(f : fin (succ n)) : C n f :=
|
||||||
have aux : Π (n₁ : nat) (f₁ : fin n₁) (heq₁ : n₁ = succ n) (f : fin (succ n)) (heq₂ : f₁ == f), C n f, from
|
begin
|
||||||
λ n₁ f₁, fin.rec_on f₁
|
cases f with (n', n', f'),
|
||||||
(λ (n₁ : nat) (heq₁ : succ n₁ = succ n),
|
apply (H₁ n'),
|
||||||
have heq₁' : n₁ = n, from nat.no_confusion heq₁ (λ e, e),
|
apply (H₂ n' f')
|
||||||
eq.rec_on heq₁' (λ (f : fin (succ n₁)) (heq₂ : fz n₁ == f),
|
end
|
||||||
have heq₂' : fz n₁ = f, from heq.to_eq heq₂,
|
|
||||||
have Cfz : C n₁ (fz n₁), from H₁ n₁,
|
|
||||||
eq.rec_on heq₂' Cfz))
|
|
||||||
(λ (n₁ : nat) (f₁ : fin n₁) (ih : _) (heq₁ : succ n₁ = succ n),
|
|
||||||
have heq₁' : n₁ = n, from nat.no_confusion heq₁ (λ e, e),
|
|
||||||
eq.rec_on heq₁' (λ (f : fin (succ n₁)) (heq₂ : @fs n₁ f₁ == f),
|
|
||||||
have heq₂' : @fs n₁ f₁ = f, from heq.to_eq heq₂,
|
|
||||||
have Cfs : C n₁ (@fs n₁ f₁), from H₂ n₁ f₁,
|
|
||||||
eq.rec_on heq₂' Cfs)),
|
|
||||||
aux (succ n) f rfl f !heq.refl
|
|
||||||
|
|
||||||
definition to_nat {n : nat} (f : fin n) : nat :=
|
definition to_nat {n : nat} (f : fin n) : nat :=
|
||||||
fin.rec_on f
|
fin.rec_on f
|
||||||
|
|
Loading…
Reference in a new issue