feat(library/data/fintype): add decidable_exists_finite
This commit is contained in:
parent
6bb6644c25
commit
d455bb4c5b
1 changed files with 15 additions and 1 deletions
|
@ -117,7 +117,7 @@ theorem ex_of_check_pred_eq_ff {p : A → Prop} [h : decidable_pred p] : ∀ {l
|
||||||
(λ npa : ¬ p a, exists.intro a npa)
|
(λ npa : ¬ p a, exists.intro a npa)
|
||||||
end check_pred
|
end check_pred
|
||||||
|
|
||||||
definition decidable_finite_pred [instance] {A : Type} {p : A → Prop} [h₁ : fintype A] [h₂ : decidable_pred p]
|
definition decidable_forall_finite [instance] {A : Type} {p : A → Prop} [h₁ : fintype A] [h₂ : decidable_pred p]
|
||||||
: decidable (∀ x : A, p x) :=
|
: decidable (∀ x : A, p x) :=
|
||||||
match h₁ with
|
match h₁ with
|
||||||
| fintype.mk e u c :=
|
| fintype.mk e u c :=
|
||||||
|
@ -130,6 +130,20 @@ match h₁ with
|
||||||
end rfl
|
end rfl
|
||||||
end
|
end
|
||||||
|
|
||||||
|
definition decidable_exists_finite [instance] {A : Type} {p : A → Prop} [h₁ : fintype A] [h₂ : decidable_pred p]
|
||||||
|
: decidable (∃ x : A, p x) :=
|
||||||
|
match h₁ with
|
||||||
|
| fintype.mk e u c :=
|
||||||
|
match check_pred (λ a, ¬ p a) e with
|
||||||
|
| tt := λ h : check_pred (λ a, ¬ p a) e = tt, inr (λ ex : (∃ x, p x),
|
||||||
|
obtain x px, from ex,
|
||||||
|
absurd px (all_of_check_pred_eq_tt h (c x)))
|
||||||
|
| ff := λ h : check_pred (λ a, ¬ p a) e = ff, inl (
|
||||||
|
assert aux₁ : ∃ x, ¬¬p x, from ex_of_check_pred_eq_ff h,
|
||||||
|
obtain x nnpx, from aux₁, exists.intro x (not_not_elim nnpx))
|
||||||
|
end rfl
|
||||||
|
end
|
||||||
|
|
||||||
open list.as_type
|
open list.as_type
|
||||||
-- Auxiliary function for returning a list with all elements of the type: (list.as_type l)
|
-- Auxiliary function for returning a list with all elements of the type: (list.as_type l)
|
||||||
-- Remark ⟪s⟫ is notation for (list.as_type l)
|
-- Remark ⟪s⟫ is notation for (list.as_type l)
|
||||||
|
|
Loading…
Reference in a new issue