l3lab/ntp-mathlib huggingface dataset:
/-- A fiber bundle trivialization can be pulled back to a trivialization on the pullback bundle. -/
noncomputable def Trivialization.pullback (e : Trivialization F (π F E)) (f : K) :
    Trivialization F (π F ((f : B' → B) *ᵖ E)) where
  toFun z := (z.proj, (e (Pullback.lift f z)).2)
  invFun y := @TotalSpace.mk _ F (f *ᵖ E) y.1 (e.symm (f y.1) y.2)
  source := Pullback.lift f ⁻¹' e.source
  baseSet := f ⁻¹' e.baseSet
  target := (f ⁻¹' e.baseSet) ×ˢ univ
  map_source' x h := by
    simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj] at h
    simp_rw [prod_mk_mem_set_prod_eq, mem_univ, and_true_iff, mem_preimage, h]
  map_target' y h := by
    rw [mem_prod, mem_preimage] at h
    simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj, h.1]
  left_inv' x h := by
    simp_rw [mem_preimage, e.mem_source, Pullback.lift_proj] at h
    simp_rw [Pullback.lift, e.symm_apply_apply_mk h]
  right_inv' x h := by
    simp_rw [mem_prod, mem_preimage, mem_univ, and_true_iff] at h
    simp_rw [Pullback.lift_mk, e.apply_mk_symm h]
  open_source := by
    simp_rw [e.source_eq, ← preimage_comp]
    exact e.open_baseSet.preimage ((map_continuous f).comp <| Pullback.continuous_proj F E f)
  open_target := ((map_continuous f).isOpen_preimage _ e.open_baseSet).prod isOpen_univ
  open_baseSet := (map_continuous f).isOpen_preimage _ e.open_baseSet
  continuousOn_toFun :=
    (Pullback.continuous_proj F E f).continuousOn.prod
      (continuous_snd.comp_continuousOn <|
        e.continuousOn.comp (Pullback.continuous_lift F E f).continuousOn Subset.rfl)
  continuousOn_invFun := by
    dsimp only
    simp_rw [(inducing_pullbackTotalSpaceEmbedding F E f).continuousOn_iff, Function.comp,
      pullbackTotalSpaceEmbedding]
    refine'
      continuousOn_fst.prod
        (e.continuousOn_symm.comp ((map_continuous f).prod_map continuous_id).continuousOn
          Subset.rfl)
  source_eq := by
    dsimp only
    

Proof state:
B : Type u
F : Type v
E : B → Type w₁
B' : Type w₂
f✝ : B' → B
inst✝⁵ : TopologicalSpace B'
inst✝⁴ : TopologicalSpace (TotalSpace F E)
inst✝³ : TopologicalSpace F
inst✝² : TopologicalSpace B
inst✝¹ : (_b : B) → Zero (E _b)
K : Type U
inst✝ : ContinuousMapClass K B' B
e : Trivialization F TotalSpace.proj
f : K
⊢ Pullback.lift ⇑f ⁻¹' e.source = TotalSpace.proj ⁻¹' (⇑f ⁻¹' e.baseSet)

Next tactic:
rw [e.source_eq]
/-- A fiber bundle trivialization can be pulled back to a trivialization on the pullback bundle. -/
noncomputable def Trivialization.pullback (e : Trivialization F (π F E)) (f : K) :
    Trivialization F (π F ((f : B' → B) *ᵖ E)) where
  toFun z := (z.proj, (e (Pullback.lift f z)).2)
  invFun y := @TotalSpace.mk _ F (f *ᵖ E) y.1 (e.symm (f y.1) y.2)
  source := Pullback.lift f ⁻¹' e.source
  baseSet := f ⁻¹' e.baseSet
  target := (f ⁻¹' e.baseSet) ×ˢ univ
  map_source' x h := by
    simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj] at h
    simp_rw [prod_mk_mem_set_prod_eq, mem_univ, and_true_iff, mem_preimage, h]
  map_target' y h := by
    rw [mem_prod, mem_preimage] at h
    simp_rw [e.source_eq, mem_preimage, Pullback.lift_proj, h.1]
  left_inv' x h := by
    simp_rw [mem_preimage, e.mem_source, Pullback.lift_proj] at h
    simp_rw [Pullback.lift, e.symm_apply_apply_mk h]
  right_inv' x h := by
    simp_rw [mem_prod, mem_preimage, mem_univ, and_true_iff] at h
    simp_rw [Pullback.lift_mk, e.apply_mk_symm h]
  open_source := by
    simp_rw [e.source_eq, ← preimage_comp]
    exact e.open_baseSet.preimage ((map_continuous f).comp <| Pullback.continuous_proj F E f)
  open_target := ((map_continuous f).isOpen_preimage _ e.open_baseSet).prod isOpen_univ
  open_baseSet := (map_continuous f).isOpen_preimage _ e.open_baseSet
  continuousOn_toFun :=
    (Pullback.continuous_proj F E f).continuousOn.prod
      (continuous_snd.comp_continuousOn <|
        e.continuousOn.comp (Pullback.continuous_lift F E f).continuousOn Subset.rfl)
  continuousOn_invFun := by
    dsimp only
    simp_rw [(inducing_pullbackTotalSpaceEmbedding F E f).continuousOn_iff, Function.comp,
      pullbackTotalSpaceEmbedding]
    refine'
      continuousOn_fst.prod
        (e.continuousOn_symm.comp ((map_continuous f).prod_map continuous_id).continuousOn
          Subset.rfl)
  source_eq := by
    dsimp only
    rw [e.source_eq]
    

Proof state:
B : Type u
F : Type v
E : B → Type w₁
B' : Type w₂
f✝ : B' → B
inst✝⁵ : TopologicalSpace B'
inst✝⁴ : TopologicalSpace (TotalSpace F E)
inst✝³ : TopologicalSpace F
inst✝² : TopologicalSpace B
inst✝¹ : (_b : B) → Zero (E _b)
K : Type U
inst✝ : ContinuousMapClass K B' B
e : Trivialization F TotalSpace.proj
f : K
⊢ Pullback.lift ⇑f ⁻¹' (TotalSpace.proj ⁻¹' e.baseSet) = TotalSpace.proj ⁻¹' (⇑f ⁻¹' e.baseSet)

Next tactic:
rfl
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    

Proof state:
α : Type u_1
I B X : Set α
M : IndepMatroid α
⊢ ∃ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) B

Next tactic:
obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    

Proof state:
case intro.intro.intro.intro
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B : Set α
hB₁ : ∀ ⦃b : Set α⦄, b ∈ {Y | M.Indep Y ∧ ∅ ⊆ Y ∧ Y ⊆ M.E} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB : M.Indep B
⊢ ∃ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) B

Next tactic:
exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    

Proof state:
α : Type u_1
I B X : Set α
M : IndepMatroid α
⊢ ExchangeProperty fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}

Next tactic:
rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    

Proof state:
case intro.intro
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
⊢ ∃ b ∈ B' \ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) (insert b (B \ {e}))

Next tactic:
have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    

Proof state:
case hnotmax
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
⊢ B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
case intro.intro
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
hnotmax : B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
⊢ ∃ b ∈ B' \ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) (insert b (B \ {e}))

Next tactic:
{ simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { 

Proof state:
case hnotmax
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
⊢ B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}

Next tactic:
simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      

Proof state:
case hnotmax
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
⊢ M.Indep (B \ {e}) → ∃ x, M.Indep x ∧ B ⊆ insert e x ∧ ¬B \ {e} = x

Next tactic:
exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by 

Proof state:
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
x✝ : M.Indep (B \ {e})
⊢ ¬B \ {e} = B

Next tactic:
simpa using he.1
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }

    

Proof state:
case intro.intro
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
hnotmax : B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
⊢ ∃ b ∈ B' \ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) (insert b (B \ {e}))

Next tactic:
obtain ⟨f,hf,hfB⟩ := M.indep_aug (M.indep_subset hB (diff_subset B {e})) hnotmax ⟨hB',hB'max⟩
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }

    obtain ⟨f,hf,hfB⟩ := M.indep_aug (M.indep_subset hB (diff_subset B {e})) hnotmax ⟨hB',hB'max⟩
    

Proof state:
case intro.intro.intro.intro
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
hnotmax : B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
f : α
hf : f ∈ B' \ (B \ {e})
hfB : M.Indep (insert f (B \ {e}))
⊢ ∃ b ∈ B' \ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) (insert b (B \ {e}))

Next tactic:
simp only [mem_diff, mem_singleton_iff, not_and, not_not] at hf
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }

    obtain ⟨f,hf,hfB⟩ := M.indep_aug (M.indep_subset hB (diff_subset B {e})) hnotmax ⟨hB',hB'max⟩
    simp only [mem_diff, mem_singleton_iff, not_and, not_not] at hf

    

Proof state:
case intro.intro.intro.intro
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
hnotmax : B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
f : α
hfB : M.Indep (insert f (B \ {e}))
hf : f ∈ B' ∧ (f ∈ B → f = e)
⊢ ∃ b ∈ B' \ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) (insert b (B \ {e}))

Next tactic:
have hfB' : f ∉ B := by (intro hfB; obtain rfl := hf.2 hfB; exact he.2 hf.1)
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }

    obtain ⟨f,hf,hfB⟩ := M.indep_aug (M.indep_subset hB (diff_subset B {e})) hnotmax ⟨hB',hB'max⟩
    simp only [mem_diff, mem_singleton_iff, not_and, not_not] at hf

    have hfB' : f ∉ B := by (

Proof state:
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
hnotmax : B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
f : α
hfB : M.Indep (insert f (B \ {e}))
hf : f ∈ B' ∧ (f ∈ B → f = e)
⊢ f ∉ B

Next tactic:
intro hfB
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }

    obtain ⟨f,hf,hfB⟩ := M.indep_aug (M.indep_subset hB (diff_subset B {e})) hnotmax ⟨hB',hB'max⟩
    simp only [mem_diff, mem_singleton_iff, not_and, not_not] at hf

    have hfB' : f ∉ B := by (intro hfB; 

Proof state:
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
hnotmax : B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
f : α
hfB✝ : M.Indep (insert f (B \ {e}))
hf : f ∈ B' ∧ (f ∈ B → f = e)
hfB : f ∈ B
⊢ False

Next tactic:
obtain rfl := hf.2 hfB
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }

    obtain ⟨f,hf,hfB⟩ := M.indep_aug (M.indep_subset hB (diff_subset B {e})) hnotmax ⟨hB',hB'max⟩
    simp only [mem_diff, mem_singleton_iff, not_and, not_not] at hf

    have hfB' : f ∉ B := by (intro hfB; obtain rfl := hf.2 hfB; 

Proof state:
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
f : α
hfB✝ : f ∈ B
he : f ∈ B \ B'
hnotmax : B \ {f} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
hfB : M.Indep (insert f (B \ {f}))
hf : f ∈ B' ∧ (f ∈ B → f = f)
⊢ False

Next tactic:
exact he.2 hf.1
/-- An `M : IndepMatroid α` gives a `Matroid α` whose bases are the maximal `M`-independent sets. -/
@[simps] protected def matroid (M : IndepMatroid α) : Matroid α where
  E := M.E
  Base := (· ∈ maximals (· ⊆ ·) {I | M.Indep I})
  exists_base := by
    obtain ⟨B, ⟨hB,-,-⟩, hB₁⟩ :=
      M.indep_maximal M.E rfl.subset ∅ M.indep_empty (empty_subset _)
    exact ⟨B, ⟨hB, fun B' hB' h' ↦ hB₁ ⟨hB', empty_subset _,M.subset_ground B' hB'⟩ h'⟩⟩
  base_exchange := by
    rintro B B' ⟨hB, hBmax⟩ ⟨hB',hB'max⟩ e he
    have hnotmax : B \ {e} ∉ maximals (· ⊆ ·) {I | M.Indep I}
    { simp only [mem_maximals_setOf_iff, diff_singleton_subset_iff, not_and, not_forall,
        exists_prop, exists_and_left]
      exact fun _ ↦ ⟨B, hB, subset_insert _ _, by simpa using he.1⟩ }

    obtain ⟨f,hf,hfB⟩ := M.indep_aug (M.indep_subset hB (diff_subset B {e})) hnotmax ⟨hB',hB'max⟩
    simp only [mem_diff, mem_singleton_iff, not_and, not_not] at hf

    have hfB' : f ∉ B := by (intro hfB; obtain rfl := hf.2 hfB; exact he.2 hf.1)

    

Proof state:
case intro.intro.intro.intro
α : Type u_1
I B✝ X : Set α
M : IndepMatroid α
B B' : Set α
hB : B ∈ {I | M.Indep I}
hBmax : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B b → (fun x x_1 => x ⊆ x_1) b B
hB' : B' ∈ {I | M.Indep I}
hB'max : ∀ ⦃b : Set α⦄, b ∈ {I | M.Indep I} → (fun x x_1 => x ⊆ x_1) B' b → (fun x x_1 => x ⊆ x_1) b B'
e : α
he : e ∈ B \ B'
hnotmax : B \ {e} ∉ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}
f : α
hfB : M.Indep (insert f (B \ {e}))
hf : f ∈ B' ∧ (f ∈ B → f = e)
hfB' : f ∉ B
⊢ ∃ b ∈ B' \ B, (fun x => x ∈ maximals (fun x x_1 => x ⊆ x_1) {I | M.Indep I}) (insert b (B \ {e}))

Next tactic:
refine' ⟨f, ⟨hf.1, hfB'⟩, by_contra (fun hnot ↦ _)⟩