l3lab/ntp-mathlib huggingface dataset:
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  

Proof state:
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
⊢ ∃ y, (πs C o) y = f

Next tactic:
have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  

Proof state:
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
⊢ ∃ y, (πs C o) y = f

Next tactic:
refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · 

Proof state:
case refine_1
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
⊢ (π C fun x => ord I x < o) ⊆ C0 C ho ∪ π (C1 C ho) fun x => ord I x < o

Next tactic:
rintro _ ⟨y, hyC, rfl⟩
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    

Proof state:
case refine_1.intro.intro
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
y : I → Bool
hyC : y ∈ C
⊢ Proj (fun x => ord I x < o) y ∈ C0 C ho ∪ π (C1 C ho) fun x => ord I x < o

Next tactic:
simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    

Proof state:
case refine_1.intro.intro
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
y : I → Bool
hyC : y ∈ C
⊢ Proj (fun x => ord I x < o) y ∈ C0 C ho ∨ Proj (fun x => ord I x < o) y ∈ π (C1 C ho) fun x => ord I x < o

Next tactic:
rw [← union_C0C1_eq C ho] at hyC
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    

Proof state:
case refine_1.intro.intro
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
y : I → Bool
hyC : y ∈ C0 C ho ∪ C1 C ho
⊢ Proj (fun x => ord I x < o) y ∈ C0 C ho ∨ Proj (fun x => ord I x < o) y ∈ π (C1 C ho) fun x => ord I x < o

Next tactic:
refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    

Proof state:
case refine_1.intro.intro
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
y : I → Bool
hyC✝ : y ∈ C0 C ho ∪ C1 C ho
hyC : y ∈ C0 C ho
⊢ Proj (fun x => ord I x < o) y ∈ C0 C ho

Next tactic:
rwa [C0_projOrd C hsC ho hyC]
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · 

Proof state:
case refine_2
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
⊢ ∀ (x : I → Bool) (hx : x ∈ C0 C ho ∩ π (C1 C ho) fun x => ord I x < o),
    (LocallyConstant.comap C₀C f) { val := x, property := (_ : x ∈ C0 C ho) } =
      (LocallyConstant.comap C₁C f) { val := x, property := (_ : x ∈ π (C1 C ho) fun x => ord I x < o) }

Next tactic:
intro x hx
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · intro x hx
    

Proof state:
case refine_2
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
x : I → Bool
hx : x ∈ C0 C ho ∩ π (C1 C ho) fun x => ord I x < o
⊢ (LocallyConstant.comap C₀C f) { val := x, property := (_ : x ∈ C0 C ho) } =
    (LocallyConstant.comap C₁C f) { val := x, property := (_ : x ∈ π (C1 C ho) fun x => ord I x < o) }

Next tactic:
simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · intro x hx
    simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm
  · 

Proof state:
case refine_3
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
⊢ (πs C o)
      (LocallyConstant.piecewise'
        (_ : ∀ ⦃a : I → Bool⦄, (a ∈ π C fun x => ord I x < o) → a ∈ C0 C ho ∪ π (C1 C ho) fun x => ord I x < o)
        (_ : IsClosed (C0 C ho)) (_ : IsClosed (π (C1 C ho) fun x => ord I x < o)) (LocallyConstant.comap C₀C f)
        (LocallyConstant.comap C₁C f)
        (_ :
          ∀ (x : I → Bool) (hx : x ∈ C0 C ho ∩ π (C1 C ho) fun x => ord I x < o),
            (LocallyConstant.comap C₀C f) { val := x, property := (_ : x ∈ C0 C ho) } =
              (LocallyConstant.comap C₁C f) { val := x, property := (_ : x ∈ π (C1 C ho) fun x => ord I x < o) })) =
    f

Next tactic:
ext ⟨x, hx⟩
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · intro x hx
    simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm
  · ext ⟨x, hx⟩
    

Proof state:
case refine_3.h.mk
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
x : I → Bool
hx : x ∈ C
⊢ ((πs C o)
        (LocallyConstant.piecewise'
          (_ : ∀ ⦃a : I → Bool⦄, (a ∈ π C fun x => ord I x < o) → a ∈ C0 C ho ∪ π (C1 C ho) fun x => ord I x < o)
          (_ : IsClosed (C0 C ho)) (_ : IsClosed (π (C1 C ho) fun x => ord I x < o)) (LocallyConstant.comap C₀C f)
          (LocallyConstant.comap C₁C f)
          (_ :
            ∀ (x : I → Bool) (hx : x ∈ C0 C ho ∩ π (C1 C ho) fun x => ord I x < o),
              (LocallyConstant.comap C₀C f) { val := x, property := (_ : x ∈ C0 C ho) } =
                (LocallyConstant.comap C₁C f) { val := x, property := (_ : x ∈ π (C1 C ho) fun x => ord I x < o) })))
      { val := x, property := hx } =
    f { val := x, property := hx }

Next tactic:
rw [← union_C0C1_eq C ho] at hx
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · intro x hx
    simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm
  · ext ⟨x, hx⟩
    rw [← union_C0C1_eq C ho] at hx
    

Proof state:
case refine_3.h.mk
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
x : I → Bool
hx✝ : x ∈ C
hx : x ∈ C0 C ho ∪ C1 C ho
⊢ ((πs C o)
        (LocallyConstant.piecewise'
          (_ : ∀ ⦃a : I → Bool⦄, (a ∈ π C fun x => ord I x < o) → a ∈ C0 C ho ∪ π (C1 C ho) fun x => ord I x < o)
          (_ : IsClosed (C0 C ho)) (_ : IsClosed (π (C1 C ho) fun x => ord I x < o)) (LocallyConstant.comap C₀C f)
          (LocallyConstant.comap C₁C f)
          (_ :
            ∀ (x : I → Bool) (hx : x ∈ C0 C ho ∩ π (C1 C ho) fun x => ord I x < o),
              (LocallyConstant.comap C₀C f) { val := x, property := (_ : x ∈ C0 C ho) } =
                (LocallyConstant.comap C₁C f) { val := x, property := (_ : x ∈ π (C1 C ho) fun x => ord I x < o) })))
      { val := x, property := hx✝ } =
    f { val := x, property := hx✝ }

Next tactic:
cases' hx with hx₀ hx₁
open Classical in
theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) :
    ∃ y, πs C o y = f := by
  dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf
  simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap,
    continuous_CC'₀, continuous_CC'₁] at hf
  let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩
  have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _
  let C₁C : π (C1 C ho) (ord I · < o) → C :=
    fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩
  have h₁ : Continuous C₁C := Continuous.subtype_mk
    ((continuous_swapTrue o).comp continuous_subtype_val) _
  refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho)
      (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap C₀C) (f.comap C₁C) ?_, ?_⟩
  · rintro _ ⟨y, hyC, rfl⟩
    simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true]
    rw [← union_C0C1_eq C ho] at hyC
    refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩)
    rwa [C0_projOrd C hsC ho hyC]
  · intro x hx
    simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm
  · ext ⟨x, hx⟩
    rw [← union_C0C1_eq C ho] at hx
    cases' hx with hx₀ hx₁
    · 

Proof state:
case refine_3.h.mk.inl
I : Type u
inst✝² : Inhabited I
inst✝¹ : LinearOrder I
inst✝ : IsWellOrder I fun x x_1 => x < x_1
C : Set (I → Bool)
o : Ordinal.{u}
hC : IsClosed C
hsC : contained C (Order.succ o)
ho : o < Ordinal.type fun x x_1 => x < x_1
f : LocallyConstant ↑C ℤ
hf : ⇑f ∘ CC'₁ C hsC ho = ⇑f ∘ CC'₀ C ho
C₀C : ↑(C0 C ho) → ↑C := fun x => { val := ↑x, property := (_ : ↑x ∈ C) }
h₀ : Continuous C₀C
C₁C : ↑(π (C1 C ho) fun x => ord I x < o) → ↑C := fun x => { val := SwapTrue o ↑x, property := (_ : SwapTrue o ↑x ∈ C) }
h₁ : Continuous C₁C
x : I → Bool
hx : x ∈ C
hx₀ : x ∈ C0 C ho
⊢ ((πs C o)
        (LocallyConstant.piecewise'
          (_ : ∀ ⦃a : I → Bool⦄, (a ∈ π C fun x => ord I x < o) → a ∈ C0 C ho ∪ π (C1 C ho) fun x => ord I x < o)
          (_ : IsClosed (C0 C ho)) (_ : IsClosed (π (C1 C ho) fun x => ord I x < o)) (LocallyConstant.comap C₀C f)
          (LocallyConstant.comap C₁C f)
          (_ :
            ∀ (x : I → Bool) (hx : x ∈ C0 C ho ∩ π (C1 C ho) fun x => ord I x < o),
              (LocallyConstant.comap C₀C f) { val := x, property := (_ : x ∈ C0 C ho) } =
                (LocallyConstant.comap C₁C f) { val := x, property := (_ : x ∈ π (C1 C ho) fun x => ord I x < o) })))
      { val := x, property := hx } =
    f { val := x, property := hx }

Next tactic:
have hx₀' : ProjRestrict C (ord I · < o) ⟨x, hx⟩ = x