l3lab/ntp-mathlib huggingface dataset:
/-- An independence predicate on `Finset α` that obeys the finite matroid axioms determines a
  finitary matroid on `α`. -/
protected def ofFinset [DecidableEq α] (E : Set α) (Indep : Finset α → Prop)
    (indep_empty : Indep ∅)
    (indep_subset : ∀ ⦃I J⦄, Indep J → I ⊆ J → Indep I)
    (indep_aug : ∀ ⦃I J⦄, Indep I → Indep J → I.card < J.card → ∃ e ∈ J, e ∉ I ∧ Indep (insert e I))
    (subset_ground : ∀ ⦃I⦄, Indep I → (I : Set α) ⊆ E) : IndepMatroid α :=
  IndepMatroid.ofFinitary
    (E := E)
    (Indep := (fun I ↦ (∀ (J : Finset α), (J : Set α) ⊆ I → Indep J)))
    (indep_empty := by simpa [subset_empty_iff])
    (indep_subset := ( fun I J hJ hIJ K hKI ↦ hJ _ (hKI.trans hIJ) ))
    (indep_aug := by
      intro I J hI hIfin hJ hJfin hIJ
      rw [ncard_eq_toFinset_card _ hIfin, ncard_eq_toFinset_card _ hJfin] at hIJ
      have aug := indep_aug (hI _ (by simp [Subset.rfl])) (hJ _ (by simp [Subset.rfl])) hIJ
      simp only [Finite.mem_toFinset] at aug
      obtain ⟨e, heJ, heI, hi⟩ := aug
      exact ⟨e, heJ, heI, fun K hK ↦ indep_subset hi <| Finset.coe_subset.1 (by simpa)⟩ )
    (indep_compact := fun I h J hJ ↦ h _ hJ J.finite_toSet _ Subset.rfl )
    (subset_ground := fun I hI x hxI ↦ by simpa using subset_ground <| hI {x} (by 

Proof state:
α : Type u_1
I✝ B X : Set α
inst✝ : DecidableEq α
E : Set α
Indep : Finset α → Prop
indep_empty : Indep ∅
indep_subset : ∀ ⦃I J : Finset α⦄, Indep J → I ⊆ J → Indep I
indep_aug : ∀ ⦃I J : Finset α⦄, Indep I → Indep J → Finset.card I < Finset.card J → ∃ e ∈ J, e ∉ I ∧ Indep (insert e I)
subset_ground : ∀ ⦃I : Finset α⦄, Indep I → ↑I ⊆ E
I : Set α
hI : (fun I => ∀ (J : Finset α), ↑J ⊆ I → Indep J) I
x : α
hxI : x ∈ I
⊢ ↑{x} ⊆ I

Next tactic:
simpa
@[simp] theorem ofFinset_indep [DecidableEq α] (E : Set α) Indep indep_empty indep_subset indep_aug
    subset_ground {I : Finset α} : (IndepMatroid.ofFinset
      E Indep indep_empty indep_subset indep_aug subset_ground).Indep I ↔ Indep I := by
  

Proof state:
α : Type u_1
I✝ B X : Set α
inst✝ : DecidableEq α
E : Set α
Indep : Finset α → Prop
indep_empty : Indep ∅
indep_subset : ∀ ⦃I J : Finset α⦄, Indep J → I ⊆ J → Indep I
indep_aug : ∀ ⦃I J : Finset α⦄, Indep I → Indep J → Finset.card I < Finset.card J → ∃ e ∈ J, e ∉ I ∧ Indep (insert e I)
subset_ground : ∀ ⦃I : Finset α⦄, Indep I → ↑I ⊆ E
I : Finset α
⊢ (IndepMatroid.ofFinset E Indep indep_empty indep_subset indep_aug subset_ground).Indep ↑I ↔ Indep I

Next tactic:
simp only [IndepMatroid.ofFinset, ofFinitary_indep, Finset.coe_subset]
@[simp] theorem ofFinset_indep [DecidableEq α] (E : Set α) Indep indep_empty indep_subset indep_aug
    subset_ground {I : Finset α} : (IndepMatroid.ofFinset
      E Indep indep_empty indep_subset indep_aug subset_ground).Indep I ↔ Indep I := by
  simp only [IndepMatroid.ofFinset, ofFinitary_indep, Finset.coe_subset]
  

Proof state:
α : Type u_1
I✝ B X : Set α
inst✝ : DecidableEq α
E : Set α
Indep : Finset α → Prop
indep_empty : Indep ∅
indep_subset : ∀ ⦃I J : Finset α⦄, Indep J → I ⊆ J → Indep I
indep_aug : ∀ ⦃I J : Finset α⦄, Indep I → Indep J → Finset.card I < Finset.card J → ∃ e ∈ J, e ∉ I ∧ Indep (insert e I)
subset_ground : ∀ ⦃I : Finset α⦄, Indep I → ↑I ⊆ E
I : Finset α
⊢ (∀ J ⊆ I, Indep J) ↔ Indep I

Next tactic:
exact ⟨fun h ↦ h _ Subset.rfl, fun h J hJI ↦ indep_subset h hJI⟩
/-- This can't be `@[simp]`, because it would cause the more useful
  `Matroid.ofIndepFinset_apply` not to be in simp normal form. -/
theorem ofFinset_indep' [DecidableEq α] (E : Set α) Indep indep_empty indep_subset indep_aug
    subset_ground {I : Set α} : (IndepMatroid.ofFinset
      E Indep indep_empty indep_subset indep_aug subset_ground).Indep I ↔
        ∀ (J : Finset α), (J : Set α) ⊆ I → Indep J := by
  

Proof state:
α : Type u_1
I✝ B X : Set α
inst✝ : DecidableEq α
E : Set α
Indep : Finset α → Prop
indep_empty : Indep ∅
indep_subset : ∀ ⦃I J : Finset α⦄, Indep J → I ⊆ J → Indep I
indep_aug : ∀ ⦃I J : Finset α⦄, Indep I → Indep J → Finset.card I < Finset.card J → ∃ e ∈ J, e ∉ I ∧ Indep (insert e I)
subset_ground : ∀ ⦃I : Finset α⦄, Indep I → ↑I ⊆ E
I : Set α
⊢ (IndepMatroid.ofFinset E Indep indep_empty indep_subset indep_aug subset_ground).Indep I ↔
    ∀ (J : Finset α), ↑J ⊆ I → Indep J

Next tactic:
simp only [IndepMatroid.ofFinset, ofFinitary_indep]
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    

Proof state:
α : Type u_1
I B X E : Set α
Indep : Set α → Prop
hM : ∃ M, E = M.E ∧ ∀ (I : Set α), M.Indep I ↔ Indep I
⊢ ∃ M, E = M.E ∧ M.Indep = Indep

Next tactic:
obtain ⟨M, rfl, h⟩ := hM
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; 

Proof state:
case intro.intro
α : Type u_1
I B X : Set α
Indep : Set α → Prop
M : Matroid α
h : ∀ (I : Set α), M.Indep I ↔ Indep I
⊢ ∃ M_1, M.E = M_1.E ∧ M_1.Indep = Indep

Next tactic:
refine ⟨_, rfl, funext (by simp [h])⟩
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by 

Proof state:
α : Type u_1
I B X : Set α
Indep : Set α → Prop
M : Matroid α
h : ∀ (I : Set α), M.Indep I ↔ Indep I
⊢ ∀ (x : Set α), M.Indep x = Indep x

Next tactic:
simp [h]
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by 

Proof state:
α : Type u_1
I B X E : Set α
Indep : Set α → Prop
hM : ∃ M, E = M.E ∧ ∀ (I : Set α), M.Indep I ↔ Indep I
hex : ∃ M, E = M.E ∧ M.Indep = Indep
⊢ Indep ∅

Next tactic:
obtain ⟨M, -, rfl⟩ := hex
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; 

Proof state:
case intro.intro
α : Type u_1
I B X E : Set α
M : Matroid α
hM : ∃ M_1, E = M_1.E ∧ ∀ (I : Set α), M_1.Indep I ↔ M.Indep I
⊢ M.Indep ∅

Next tactic:
exact M.empty_indep
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by 

Proof state:
α : Type u_1
I B X E : Set α
Indep : Set α → Prop
hM : ∃ M, E = M.E ∧ ∀ (I : Set α), M.Indep I ↔ Indep I
hex : ∃ M, E = M.E ∧ M.Indep = Indep
⊢ ∀ ⦃I J : Set α⦄, Indep J → I ⊆ J → Indep I

Next tactic:
obtain ⟨M, -, rfl⟩ := hex
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by obtain ⟨M, -, rfl⟩ := hex; 

Proof state:
case intro.intro
α : Type u_1
I B X E : Set α
M : Matroid α
hM : ∃ M_1, E = M_1.E ∧ ∀ (I : Set α), M_1.Indep I ↔ M.Indep I
⊢ ∀ ⦃I J : Set α⦄, M.Indep J → I ⊆ J → M.Indep I

Next tactic:
exact fun I J hJ hIJ ↦ hJ.subset hIJ
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by obtain ⟨M, -, rfl⟩ := hex; exact fun I J hJ hIJ ↦ hJ.subset hIJ)
  (indep_aug := by 

Proof state:
α : Type u_1
I B X E : Set α
Indep : Set α → Prop
hM : ∃ M, E = M.E ∧ ∀ (I : Set α), M.Indep I ↔ Indep I
hex : ∃ M, E = M.E ∧ M.Indep = Indep
⊢ ∀ ⦃I B : Set α⦄,
    Indep I →
      I ∉ maximals (fun x x_1 => x ⊆ x_1) {I | Indep I} →
        B ∈ maximals (fun x x_1 => x ⊆ x_1) {I | Indep I} → ∃ x ∈ B \ I, Indep (insert x I)

Next tactic:
obtain ⟨M, -, rfl⟩ := hex
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by obtain ⟨M, -, rfl⟩ := hex; exact fun I J hJ hIJ ↦ hJ.subset hIJ)
  (indep_aug := by obtain ⟨M, -, rfl⟩ := hex; 

Proof state:
case intro.intro
α : Type u_1
I B X E : Set α
M : Matroid α
hM : ∃ M_1, E = M_1.E ∧ ∀ (I : Set α), M_1.Indep I ↔ M.Indep I
⊢ ∀ ⦃I B : Set α⦄,
    M.Indep I →
      I ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I} →
        B ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I} → ∃ x ∈ B \ I, M.Indep (insert x I)

Next tactic:
exact Indep.exists_insert_of_not_mem_maximals M
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by obtain ⟨M, -, rfl⟩ := hex; exact fun I J hJ hIJ ↦ hJ.subset hIJ)
  (indep_aug := by obtain ⟨M, -, rfl⟩ := hex; exact Indep.exists_insert_of_not_mem_maximals M)
  (indep_maximal := by 

Proof state:
α : Type u_1
I B X E : Set α
Indep : Set α → Prop
hM : ∃ M, E = M.E ∧ ∀ (I : Set α), M.Indep I ↔ Indep I
hex : ∃ M, E = M.E ∧ M.Indep = Indep
⊢ ∀ X ⊆ E, ExistsMaximalSubsetProperty Indep X

Next tactic:
obtain ⟨M, rfl, rfl⟩ := hex
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by obtain ⟨M, -, rfl⟩ := hex; exact fun I J hJ hIJ ↦ hJ.subset hIJ)
  (indep_aug := by obtain ⟨M, -, rfl⟩ := hex; exact Indep.exists_insert_of_not_mem_maximals M)
  (indep_maximal := by obtain ⟨M, rfl, rfl⟩ := hex; 

Proof state:
case intro.intro
α : Type u_1
I B X : Set α
M : Matroid α
hM : ∃ M_1, M.E = M_1.E ∧ ∀ (I : Set α), M_1.Indep I ↔ M.Indep I
⊢ ∀ X ⊆ M.E, ExistsMaximalSubsetProperty M.Indep X

Next tactic:
exact M.existsMaximalSubsetProperty_indep
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by obtain ⟨M, -, rfl⟩ := hex; exact fun I J hJ hIJ ↦ hJ.subset hIJ)
  (indep_aug := by obtain ⟨M, -, rfl⟩ := hex; exact Indep.exists_insert_of_not_mem_maximals M)
  (indep_maximal := by obtain ⟨M, rfl, rfl⟩ := hex; exact M.existsMaximalSubsetProperty_indep)
  (subset_ground := by 

Proof state:
α : Type u_1
I B X E : Set α
Indep : Set α → Prop
hM : ∃ M, E = M.E ∧ ∀ (I : Set α), M.Indep I ↔ Indep I
hex : ∃ M, E = M.E ∧ M.Indep = Indep
⊢ ∀ (I : Set α), Indep I → I ⊆ E

Next tactic:
obtain ⟨M, rfl, rfl⟩ := hex
/-- Construct an `IndepMatroid` from an independence predicate that agrees with that of some
  matroid `M`. Computable even when `M` is not known constructively. -/
@[simps E] protected def ofExistsMatroid (E : Set α) (Indep : Set α → Prop)
    (hM : ∃ (M : Matroid α), E = M.E ∧ ∀ I, M.Indep I ↔ Indep I) : IndepMatroid α :=
  have hex : ∃ (M : Matroid α), E = M.E ∧ M.Indep = Indep := by
    obtain ⟨M, rfl, h⟩ := hM; refine ⟨_, rfl, funext (by simp [h])⟩
  IndepMatroid.mk (E := E) (Indep := Indep)
  (indep_empty := by obtain ⟨M, -, rfl⟩ := hex; exact M.empty_indep)
  (indep_subset := by obtain ⟨M, -, rfl⟩ := hex; exact fun I J hJ hIJ ↦ hJ.subset hIJ)
  (indep_aug := by obtain ⟨M, -, rfl⟩ := hex; exact Indep.exists_insert_of_not_mem_maximals M)
  (indep_maximal := by obtain ⟨M, rfl, rfl⟩ := hex; exact M.existsMaximalSubsetProperty_indep)
  (subset_ground := by obtain ⟨M, rfl, rfl⟩ := hex; 

Proof state:
case intro.intro
α : Type u_1
I B X : Set α
M : Matroid α
hM : ∃ M_1, M.E = M_1.E ∧ ∀ (I : Set α), M_1.Indep I ↔ M.Indep I
⊢ ∀ (I : Set α), M.Indep I → I ⊆ M.E

Next tactic:
exact fun I ↦ Indep.subset_ground
/-- A collection of bases with the exchange property and at least one finite member is a matroid -/
@[simps E] protected def ofExistsFiniteBase (E : Set α) (Base : Set α → Prop)
    (exists_finite_base : ∃ B, Base B ∧ B.Finite) (base_exchange : ExchangeProperty Base)
    (subset_ground : ∀ B, Base B → B ⊆ E) : Matroid α where
  E := E
  Base := Base
  exists_base := by
    

Proof state:
α : Type u_1
I B X E : Set α
Base : Set α → Prop
exists_finite_base : ∃ B, Base B ∧ Set.Finite B
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
⊢ ∃ B, Base B

Next tactic:
obtain ⟨B,h⟩ := exists_finite_base
/-- A collection of bases with the exchange property and at least one finite member is a matroid -/
@[simps E] protected def ofExistsFiniteBase (E : Set α) (Base : Set α → Prop)
    (exists_finite_base : ∃ B, Base B ∧ B.Finite) (base_exchange : ExchangeProperty Base)
    (subset_ground : ∀ B, Base B → B ⊆ E) : Matroid α where
  E := E
  Base := Base
  exists_base := by
    obtain ⟨B,h⟩ := exists_finite_base; 

Proof state:
case intro
α : Type u_1
I B✝ X E : Set α
Base : Set α → Prop
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
B : Set α
h : Base B ∧ Set.Finite B
⊢ ∃ B, Base B

Next tactic:
exact ⟨B, h.1⟩
/-- A collection of bases with the exchange property and at least one finite member is a matroid -/
@[simps E] protected def ofExistsFiniteBase (E : Set α) (Base : Set α → Prop)
    (exists_finite_base : ∃ B, Base B ∧ B.Finite) (base_exchange : ExchangeProperty Base)
    (subset_ground : ∀ B, Base B → B ⊆ E) : Matroid α where
  E := E
  Base := Base
  exists_base := by
    obtain ⟨B,h⟩ := exists_finite_base; exact ⟨B, h.1⟩
  base_exchange := base_exchange
  maximality := by
    

Proof state:
α : Type u_1
I B X E : Set α
Base : Set α → Prop
exists_finite_base : ∃ B, Base B ∧ Set.Finite B
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
⊢ ∀ X ⊆ E, ExistsMaximalSubsetProperty (fun x => ∃ B, Base B ∧ x ⊆ B) X

Next tactic:
obtain ⟨B, hB, hfin⟩ := exists_finite_base
/-- A collection of bases with the exchange property and at least one finite member is a matroid -/
@[simps E] protected def ofExistsFiniteBase (E : Set α) (Base : Set α → Prop)
    (exists_finite_base : ∃ B, Base B ∧ B.Finite) (base_exchange : ExchangeProperty Base)
    (subset_ground : ∀ B, Base B → B ⊆ E) : Matroid α where
  E := E
  Base := Base
  exists_base := by
    obtain ⟨B,h⟩ := exists_finite_base; exact ⟨B, h.1⟩
  base_exchange := base_exchange
  maximality := by
    obtain ⟨B, hB, hfin⟩ := exists_finite_base
    

Proof state:
case intro.intro
α : Type u_1
I B✝ X E : Set α
Base : Set α → Prop
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
B : Set α
hB : Base B
hfin : Set.Finite B
⊢ ∀ X ⊆ E, ExistsMaximalSubsetProperty (fun x => ∃ B, Base B ∧ x ⊆ B) X

Next tactic:
refine' fun X _ ↦ Matroid.existsMaximalSubsetProperty_of_bdd
      ⟨B.ncard, fun Y ⟨B', hB', hYB'⟩ ↦ _⟩ X
/-- A collection of bases with the exchange property and at least one finite member is a matroid -/
@[simps E] protected def ofExistsFiniteBase (E : Set α) (Base : Set α → Prop)
    (exists_finite_base : ∃ B, Base B ∧ B.Finite) (base_exchange : ExchangeProperty Base)
    (subset_ground : ∀ B, Base B → B ⊆ E) : Matroid α where
  E := E
  Base := Base
  exists_base := by
    obtain ⟨B,h⟩ := exists_finite_base; exact ⟨B, h.1⟩
  base_exchange := base_exchange
  maximality := by
    obtain ⟨B, hB, hfin⟩ := exists_finite_base
    refine' fun X _ ↦ Matroid.existsMaximalSubsetProperty_of_bdd
      ⟨B.ncard, fun Y ⟨B', hB', hYB'⟩ ↦ _⟩ X
    

Proof state:
case intro.intro
α : Type u_1
I B✝ X✝ E : Set α
Base : Set α → Prop
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
B : Set α
hB : Base B
hfin : Set.Finite B
X : Set α
x✝¹ : X ⊆ E
Y : Set α
x✝ : ∃ B, Base B ∧ Y ⊆ B
B' : Set α
hB' : Base B'
hYB' : Y ⊆ B'
⊢ encard Y ≤ ↑(ncard B)

Next tactic:
rw [hfin.cast_ncard_eq, base_exchange.encard_base_eq hB hB']
/-- A collection of bases with the exchange property and at least one finite member is a matroid -/
@[simps E] protected def ofExistsFiniteBase (E : Set α) (Base : Set α → Prop)
    (exists_finite_base : ∃ B, Base B ∧ B.Finite) (base_exchange : ExchangeProperty Base)
    (subset_ground : ∀ B, Base B → B ⊆ E) : Matroid α where
  E := E
  Base := Base
  exists_base := by
    obtain ⟨B,h⟩ := exists_finite_base; exact ⟨B, h.1⟩
  base_exchange := base_exchange
  maximality := by
    obtain ⟨B, hB, hfin⟩ := exists_finite_base
    refine' fun X _ ↦ Matroid.existsMaximalSubsetProperty_of_bdd
      ⟨B.ncard, fun Y ⟨B', hB', hYB'⟩ ↦ _⟩ X
    rw [hfin.cast_ncard_eq, base_exchange.encard_base_eq hB hB']
    

Proof state:
case intro.intro
α : Type u_1
I B✝ X✝ E : Set α
Base : Set α → Prop
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
B : Set α
hB : Base B
hfin : Set.Finite B
X : Set α
x✝¹ : X ⊆ E
Y : Set α
x✝ : ∃ B, Base B ∧ Y ⊆ B
B' : Set α
hB' : Base B'
hYB' : Y ⊆ B'
⊢ encard Y ≤ encard B'

Next tactic:
exact encard_mono hYB'
instance ofExistsFiniteBase_finiteRk (E : Set α) Base exists_finite_base
    base_exchange subset_ground : FiniteRk (Matroid.ofExistsFiniteBase
      E Base exists_finite_base base_exchange subset_ground) := by
  

Proof state:
α : Type u_1
I B X E : Set α
Base : Set α → Prop
exists_finite_base : ∃ B, Base B ∧ Set.Finite B
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
⊢ FiniteRk (Matroid.ofExistsFiniteBase E Base exists_finite_base base_exchange subset_ground)

Next tactic:
obtain ⟨B, hB, hfin⟩ := exists_finite_base
instance ofExistsFiniteBase_finiteRk (E : Set α) Base exists_finite_base
    base_exchange subset_ground : FiniteRk (Matroid.ofExistsFiniteBase
      E Base exists_finite_base base_exchange subset_ground) := by
  obtain ⟨B, hB, hfin⟩ := exists_finite_base
  

Proof state:
case intro.intro
α : Type u_1
I B✝ X E : Set α
Base : Set α → Prop
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
B : Set α
hB : Base B
hfin : Set.Finite B
⊢ FiniteRk (Matroid.ofExistsFiniteBase E Base (_ : ∃ B, Base B ∧ Set.Finite B) base_exchange subset_ground)

Next tactic:
exact Matroid.Base.finiteRk_of_finite (by simpa) hfin
instance ofExistsFiniteBase_finiteRk (E : Set α) Base exists_finite_base
    base_exchange subset_ground : FiniteRk (Matroid.ofExistsFiniteBase
      E Base exists_finite_base base_exchange subset_ground) := by
  obtain ⟨B, hB, hfin⟩ := exists_finite_base
  exact Matroid.Base.finiteRk_of_finite (by 

Proof state:
α : Type u_1
I B✝ X E : Set α
Base : Set α → Prop
base_exchange : ExchangeProperty Base
subset_ground : ∀ (B : Set α), Base B → B ⊆ E
B : Set α
hB : Base B
hfin : Set.Finite B
⊢ (Matroid.ofExistsFiniteBase E Base (_ : ∃ B, Base B ∧ Set.Finite B) base_exchange subset_ground).Base B

Next tactic:
simpa
instance AddCommMonoid.ofSubmonoidOnSemiring [Semiring R] [SetLike σ R] [AddSubmonoidClass σ R]
    (A : ι → σ) : ∀ i, AddCommMonoid (A i) := fun i => by 

Proof state:
ι : Type u_1
σ : Type u_2
S : Type u_3
R : Type u_4
inst✝² : Semiring R
inst✝¹ : SetLike σ R
inst✝ : AddSubmonoidClass σ R
A : ι → σ
i : ι
⊢ AddCommMonoid ↥(A i)

Next tactic:
infer_instance
instance AddCommGroup.ofSubgroupOnRing [Ring R] [SetLike σ R] [AddSubgroupClass σ R] (A : ι → σ) :
    ∀ i, AddCommGroup (A i) := fun i => by 

Proof state:
ι : Type u_1
σ : Type u_2
S : Type u_3
R : Type u_4
inst✝² : Ring R
inst✝¹ : SetLike σ R
inst✝ : AddSubgroupClass σ R
A : ι → σ
i : ι
⊢ AddCommGroup ↥(A i)

Next tactic:
infer_instance
theorem SetLike.algebraMap_mem_graded [Zero ι] [CommSemiring S] [Semiring R] [Algebra S R]
    (A : ι → Submodule S R) [SetLike.GradedOne A] (s : S) : algebraMap S R s ∈ A 0 := by
  

Proof state:
ι : Type u_1
σ : Type u_2
S : Type u_3
R : Type u_4
inst✝⁴ : Zero ι
inst✝³ : CommSemiring S
inst✝² : Semiring R
inst✝¹ : Algebra S R
A : ι → Submodule S R
inst✝ : GradedOne A
s : S
⊢ (algebraMap S R) s ∈ A 0

Next tactic:
rw [Algebra.algebraMap_eq_smul_one]
theorem SetLike.algebraMap_mem_graded [Zero ι] [CommSemiring S] [Semiring R] [Algebra S R]
    (A : ι → Submodule S R) [SetLike.GradedOne A] (s : S) : algebraMap S R s ∈ A 0 := by
  rw [Algebra.algebraMap_eq_smul_one]
  

Proof state:
ι : Type u_1
σ : Type u_2
S : Type u_3
R : Type u_4
inst✝⁴ : Zero ι
inst✝³ : CommSemiring S
inst✝² : Semiring R
inst✝¹ : Algebra S R
A : ι → Submodule S R
inst✝ : GradedOne A
s : S
⊢ s • 1 ∈ A 0

Next tactic:
exact (A 0).smul_mem s <| SetLike.one_mem_graded _