Datasets:
AI4M
/

text
stringlengths
0
3.34M
using PolyChaos mutable struct PolynomialChaosSurrogate{X,Y,L,U,C,O,N} <: AbstractSurrogate x::X y::Y lb::L ub::U coeff::C ortopolys::O num_of_multi_indexes::N end function _calculatepce_coeff(x,y,num_of_multi_indexes,op::AbstractCanonicalOrthoPoly) n = length(x) A = zeros(eltype(x),n,num_of_multi_indexes) for i = 1:n A[i,:] = PolyChaos.evaluate(x[i],op) end return (A'*A)\(A'*y) end function PolynomialChaosSurrogate(x,y,lb::Number,ub::Number; op::AbstractCanonicalOrthoPoly = GaussOrthoPoly(2)) n = length(x) poly_degree = op.deg num_of_multi_indexes = 1+poly_degree if n < 2+3*num_of_multi_indexes throw("To avoid numerical problems, it's strongly suggested to have at least $(2+3*num_of_multi_indexes) samples") end coeff = _calculatepce_coeff(x,y,num_of_multi_indexes,op) return PolynomialChaosSurrogate(x,y,lb,ub,coeff,op,num_of_multi_indexes) end function (pc::PolynomialChaosSurrogate)(val::Number) return sum([pc.coeff[i]*PolyChaos.evaluate(val,pc.ortopolys)[i] for i = 1:pc.num_of_multi_indexes]) end function _calculatepce_coeff(x,y,num_of_multi_indexes,op::MultiOrthoPoly) n = length(x) d = length(x[1]) A = zeros(eltype(x[1]),n,num_of_multi_indexes) for i = 1:n xi = zeros(eltype(x[1]),d) for j = 1:d xi[j] = x[i][j] end A[i,:] = PolyChaos.evaluate(xi,op) end return (A'*A)\(A'*y) end function PolynomialChaosSurrogate(x,y,lb,ub; op::MultiOrthoPoly = MultiOrthoPoly([GaussOrthoPoly(2) for j = 1:length(lb)],2)) n = length(x) d = length(lb) poly_degree = op.deg num_of_multi_indexes = binomial(d+poly_degree,poly_degree) if n < 2+3*num_of_multi_indexes throw("To avoid numerical problems, it's strongly suggested to have at least $(2+3*num_of_multi_indexes) samples") end coeff = _calculatepce_coeff(x,y,num_of_multi_indexes,op) return PolynomialChaosSurrogate(x,y,lb,ub,coeff,op,num_of_multi_indexes) end function (pcND::PolynomialChaosSurrogate)(val) sum = zero(eltype(val[1])) for i = 1:pcND.num_of_multi_indexes sum = sum + pcND.coeff[i]*first(PolyChaos.evaluate(pcND.ortopolys.ind[i,:],collect(val),pcND.ortopolys)) end return sum end function add_point!(polych::PolynomialChaosSurrogate,x_new,y_new) if length(polych.lb) == 1 #1D polych.x = vcat(polych.x,x_new) polych.y = vcat(polych.y,y_new) polych.coeff = _calculatepce_coeff(polych.x,polych.y,polych.num_of_multi_indexes,polych.ortopolys) else polych.x = vcat(polych.x,x_new) polych.y = vcat(polych.y,y_new) polych.coeff = _calculatepce_coeff(polych.x,polych.y,polych.num_of_multi_indexes,polych.ortopolys) end nothing end
library("tximeta") colfile="~\\data\\coldata.txt" coldata <- read.csv(colfile, stringsAsFactors=FALSE) indexdir="~\\data\\genome\\Homo_sapiens.GRCh38_index\\" fastadir="~\\data\\genome\\Homo_sapiens.GRCh38.cdna.all.fa" gtfPath="ftp://ftp.ensembl.org/pub/release-100/gtf/homo_sapiens/Homo_sapiens.GRCh38.100.gtf.gz" makeLinkedTxome(indexDir=indexdir, source="Ensembl", organism="Homo sapiens", release="100", genome="GRCh38", fasta=fastadir, gtf=gtfPath, write=FALSE) se <- tximeta(coldata) gse <- summarizeToGene(se) library("DESeq2") dds <- DESeqDataSet(gse, design = ~ diagnosis) dds <- DESeq(dds) res <- results(dds) resOrdered <- res[order(res$padj),] write.csv(as.data.frame(resOrdered), file="~\\data\\DE_AD_all.csv")
import KnetLayers: IndexedDict @testset "data" begin data = "this is an example data with example words" vocab = IndexedDict{String}() append!(vocab,split(data)) vocab["example"] vocab[4] vocab[[1,2,3,4]] vocab[["example","this"]] push!(vocab,"a-new-word") vocab["a-new-word"] length(vocab) @test true #https://github.com/denizyuret/Knet.jl/pull/374 #x = arrtype(rand(10)) #indices = rand([0,1],10) #l2 = BCELoss() #l2(x,indices) #@test true #x = arrtype(randn(10)) #indices = rand([-1,1],10) #l3 = LogisticLoss() #l3(x,indices) #@test true end
Formal statement is: lemma uniformly_continuous_on_minus[continuous_intros]: fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" shows "uniformly_continuous_on s f \<Longrightarrow> uniformly_continuous_on s (\<lambda>x. - f x)" Informal statement is: If $f$ is uniformly continuous on $s$, then so is $-f$.
[STATEMENT] lemma agreement: "(t \<lhd> r = t \<lhd> s) \<longleftrightarrow> (\<forall>v \<in> vars_of t. Var v \<lhd> r = Var v \<lhd> s)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (t \<lhd> r = t \<lhd> s) = (\<forall>v\<in>vars_of t. Var v \<lhd> r = Var v \<lhd> s) [PROOF STEP] by (induct t) auto
Formal statement is: lemma closed_span [iff]: "closed (span s)" for s :: "'a::euclidean_space set" Informal statement is: The span of a set is closed.
Formal statement is: lemma minus: "f \<in> R \<Longrightarrow> (\<lambda>x. - f x) \<in> R" Informal statement is: If $f$ is a real-valued function, then $-f$ is also a real-valued function.
/- Copyright (c) 2018 Guy Leroy. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sangwoo Jo (aka Jason), Guy Leroy, Johannes Hölzl, Mario Carneiro ! This file was ported from Lean 3 source module data.int.gcd ! leanprover-community/mathlib commit d4f69d96f3532729da8ebb763f4bc26fcf640f06 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Data.Nat.GCD.Basic import Mathlib.Algebra.Ring.Regular import Mathlib.Data.Int.Dvd.Basic import Mathlib.Order.Bounds.Basic import Mathlib.Tactic.NormNum /-! # Extended GCD and divisibility over ℤ ## Main definitions * Given `x y : ℕ`, `xgcd x y` computes the pair of integers `(a, b)` such that `gcd x y = x * a + y * b`. `gcd_a x y` and `gcd_b x y` are defined to be `a` and `b`, respectively. ## Main statements * `gcd_eq_gcd_ab`: Bézout's lemma, given `x y : ℕ`, `gcd x y = x * gcd_a x y + y * gcd_b x y`. ## Tags Bézout's lemma, Bezout's lemma -/ /-! ### Extended Euclidean algorithm -/ namespace Nat /-- Helper function for the extended GCD algorithm (`Nat.xgcd`). -/ def xgcdAux : ℕ → ℤ → ℤ → ℕ → ℤ → ℤ → ℕ × ℤ × ℤ | 0, _, _, r', s', t' => (r', s', t') | succ k, s, t, r', s', t' => have : r' % succ k < succ k := mod_lt _ <| (succ_pos _).gt let q := r' / succ k xgcdAux (r' % succ k) (s' - q * s) (t' - q * t) (succ k) s t #align nat.xgcd_aux Nat.xgcdAux -- porting note: these are not in mathlib3; these equation lemmas are to fix -- complaints by the Lean 4 `unusedHavesSuffices` linter obtained when `simp [xgcdAux]` is used. theorem xgcdAux_zero : xgcdAux 0 s t r' s' t' = (r', s', t') := rfl theorem xgcdAux_succ : xgcdAux (succ k) s t r' s' t' = xgcdAux (r' % succ k) (s' - (r' / succ k) * s) (t' - (r' / succ k) * t) (succ k) s t := rfl @[simp] theorem xgcd_zero_left {s t r' s' t'} : xgcdAux 0 s t r' s' t' = (r', s', t') := by simp [xgcdAux] #align nat.xgcd_zero_left Nat.xgcd_zero_left theorem xgcd_aux_rec {r s t r' s' t'} (h : 0 < r) : xgcdAux r s t r' s' t' = xgcdAux (r' % r) (s' - r' / r * s) (t' - r' / r * t) r s t := by obtain ⟨r, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h.ne' rfl #align nat.xgcd_aux_rec Nat.xgcd_aux_rec /-- Use the extended GCD algorithm to generate the `a` and `b` values satisfying `gcd x y = x * a + y * b`. -/ def xgcd (x y : ℕ) : ℤ × ℤ := (xgcdAux x 1 0 y 0 1).2 #align nat.xgcd Nat.xgcd /-- The extended GCD `a` value in the equation `gcd x y = x * a + y * b`. -/ def gcdA (x y : ℕ) : ℤ := (xgcd x y).1 #align nat.gcd_a Nat.gcdA /-- The extended GCD `b` value in the equation `gcd x y = x * a + y * b`. -/ def gcdB (x y : ℕ) : ℤ := (xgcd x y).2 #align nat.gcd_b Nat.gcdB @[simp] theorem gcdA_zero_left {s : ℕ} : gcdA 0 s = 0 := by unfold gcdA rw [xgcd, xgcd_zero_left] #align nat.gcd_a_zero_left Nat.gcdA_zero_left @[simp] theorem gcdB_zero_left {s : ℕ} : gcdB 0 s = 1 := by unfold gcdB rw [xgcd, xgcd_zero_left] #align nat.gcd_b_zero_left Nat.gcdB_zero_left @[simp] theorem gcdA_zero_right {s : ℕ} (h : s ≠ 0) : gcdA s 0 = 1 := by unfold gcdA xgcd obtain ⟨s, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h -- Porting note: `simp [xgcdAux_succ]` crashes Lean here rw [xgcdAux_succ] rfl #align nat.gcd_a_zero_right Nat.gcdA_zero_right @[simp] theorem gcdB_zero_right {s : ℕ} (h : s ≠ 0) : gcdB s 0 = 0 := by unfold gcdB xgcd obtain ⟨s, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h -- Porting note: `simp [xgcdAux_succ]` crashes Lean here rw [xgcdAux_succ] rfl #align nat.gcd_b_zero_right Nat.gcdB_zero_right @[simp] theorem xgcd_aux_fst (x y) : ∀ s t s' t', (xgcdAux x s t y s' t').1 = gcd x y := gcd.induction x y (by simp) fun x y h IH s t s' t' => by simp [xgcd_aux_rec, h, IH] rw [← gcd_rec] #align nat.xgcd_aux_fst Nat.xgcd_aux_fst theorem xgcd_val (x y) : xgcd x y = (gcdA x y, gcdB x y) := by unfold gcdA gcdB; cases xgcd x y; rfl #align nat.xgcd_val Nat.xgcd_val section variable (x y : ℕ) private def P : ℕ × ℤ × ℤ → Prop | (r, s, t) => (r : ℤ) = x * s + y * t theorem xgcd_aux_P {r r'} : ∀ {s t s' t'}, P x y (r, s, t) → P x y (r', s', t') → P x y (xgcdAux r s t r' s' t') := by induction r, r' using gcd.induction with | H0 => simp | H1 a b h IH => intro s t s' t' p p' rw [xgcd_aux_rec h]; refine' IH _ p; dsimp [P] at * rw [Int.emod_def]; generalize (b / a : ℤ) = k rw [p, p', mul_sub, sub_add_eq_add_sub, mul_sub, add_mul, mul_comm k t, mul_comm k s, ← mul_assoc, ← mul_assoc, add_comm (x * s * k), ← add_sub_assoc, sub_sub] set_option linter.uppercaseLean3 false in #align nat.xgcd_aux_P Nat.xgcd_aux_P /-- **Bézout's lemma**: given `x y : ℕ`, `gcd x y = x * a + y * b`, where `a = gcd_a x y` and `b = gcd_b x y` are computed by the extended Euclidean algorithm. -/ theorem gcd_eq_gcd_ab : (gcd x y : ℤ) = x * gcdA x y + y * gcdB x y := by have := @xgcd_aux_P x y x y 1 0 0 1 (by simp [P]) (by simp [P]) rwa [xgcd_aux_val, xgcd_val] at this #align nat.gcd_eq_gcd_ab Nat.gcd_eq_gcd_ab end theorem exists_mul_emod_eq_gcd {k n : ℕ} (hk : gcd n k < k) : ∃ m, n * m % k = gcd n k := by have hk' := Int.ofNat_ne_zero.2 (ne_of_gt (lt_of_le_of_lt (zero_le (gcd n k)) hk)) have key := congr_arg (fun (m : ℤ) => (m % k).toNat) (gcd_eq_gcd_ab n k) simp only at key rw [Int.add_mul_emod_self_left, ← Int.coe_nat_mod, Int.toNat_coe_nat, mod_eq_of_lt hk] at key refine' ⟨(n.gcdA k % k).toNat, Eq.trans (Int.ofNat.inj _) key.symm⟩ rw [Int.ofNat_eq_coe, Int.coe_nat_mod, Int.ofNat_mul, Int.toNat_of_nonneg (Int.emod_nonneg _ hk'), Int.ofNat_eq_coe, Int.toNat_of_nonneg (Int.emod_nonneg _ hk'), Int.mul_emod, Int.emod_emod, ← Int.mul_emod] #align nat.exists_mul_mod_eq_gcd Nat.exists_mul_emod_eq_gcd theorem exists_mul_emod_eq_one_of_coprime {k n : ℕ} (hkn : coprime n k) (hk : 1 < k) : ∃ m, n * m % k = 1 := Exists.recOn (exists_mul_emod_eq_gcd (lt_of_le_of_lt (le_of_eq hkn) hk)) fun m hm ↦ ⟨m, hm.trans hkn⟩ #align nat.exists_mul_mod_eq_one_of_coprime Nat.exists_mul_emod_eq_one_of_coprime end Nat /-! ### Divisibility over ℤ -/ namespace Int protected theorem coe_nat_gcd (m n : ℕ) : Int.gcd ↑m ↑n = Nat.gcd m n := rfl #align int.coe_nat_gcd Int.coe_nat_gcd /-- The extended GCD `a` value in the equation `gcd x y = x * a + y * b`. -/ def gcdA : ℤ → ℤ → ℤ | ofNat m, n => m.gcdA n.natAbs | -[m+1], n => -m.succ.gcdA n.natAbs #align int.gcd_a Int.gcdA /-- The extended GCD `b` value in the equation `gcd x y = x * a + y * b`. -/ def gcdB : ℤ → ℤ → ℤ | m, ofNat n => m.natAbs.gcdB n | m, -[n+1] => -m.natAbs.gcdB n.succ #align int.gcd_b Int.gcdB /-- **Bézout's lemma** -/ theorem gcd_eq_gcd_ab : ∀ x y : ℤ, (gcd x y : ℤ) = x * gcdA x y + y * gcdB x y | (m : ℕ), (n : ℕ) => Nat.gcd_eq_gcd_ab _ _ | (m : ℕ), -[n+1] => show (_ : ℤ) = _ + -(n + 1) * -_ by rw [neg_mul_neg]; apply Nat.gcd_eq_gcd_ab | -[m+1], (n : ℕ) => show (_ : ℤ) = -(m + 1) * -_ + _ by rw [neg_mul_neg]; apply Nat.gcd_eq_gcd_ab | -[m+1], -[n+1] => show (_ : ℤ) = -(m + 1) * -_ + -(n + 1) * -_ by rw [neg_mul_neg, neg_mul_neg] apply Nat.gcd_eq_gcd_ab #align int.gcd_eq_gcd_ab Int.gcd_eq_gcd_ab theorem natAbs_ediv (a b : ℤ) (H : b ∣ a) : natAbs (a / b) = natAbs a / natAbs b := by rcases Nat.eq_zero_or_pos (natAbs b) with (h | h) rw [natAbs_eq_zero.1 h] simp [Int.ediv_zero] calc natAbs (a / b) = natAbs (a / b) * 1 := by rw [mul_one] _ = natAbs (a / b) * (natAbs b / natAbs b) := by rw [Nat.div_self h] _ = natAbs (a / b) * natAbs b / natAbs b := by rw [Nat.mul_div_assoc _ dvd_rfl] _ = natAbs (a / b * b) / natAbs b := by rw [natAbs_mul (a / b) b] _ = natAbs a / natAbs b := by rw [Int.ediv_mul_cancel H] #align int.nat_abs_div Int.natAbs_ediv theorem dvd_of_mul_dvd_mul_left {i j k : ℤ} (k_non_zero : k ≠ 0) (H : k * i ∣ k * j) : i ∣ j := Dvd.elim H fun l H1 => by rw [mul_assoc] at H1; exact ⟨_, mul_left_cancel₀ k_non_zero H1⟩ #align int.dvd_of_mul_dvd_mul_left Int.dvd_of_mul_dvd_mul_left theorem dvd_of_mul_dvd_mul_right {i j k : ℤ} (k_non_zero : k ≠ 0) (H : i * k ∣ j * k) : i ∣ j := by rw [mul_comm i k, mul_comm j k] at H; exact dvd_of_mul_dvd_mul_left k_non_zero H #align int.dvd_of_mul_dvd_mul_right Int.dvd_of_mul_dvd_mul_right /-- ℤ specific version of least common multiple. -/ def lcm (i j : ℤ) : ℕ := Nat.lcm (natAbs i) (natAbs j) #align int.lcm Int.lcm theorem lcm_def (i j : ℤ) : lcm i j = Nat.lcm (natAbs i) (natAbs j) := rfl #align int.lcm_def Int.lcm_def protected theorem coe_nat_lcm (m n : ℕ) : Int.lcm ↑m ↑n = Nat.lcm m n := rfl #align int.coe_nat_lcm Int.coe_nat_lcm theorem gcd_dvd_left (i j : ℤ) : (gcd i j : ℤ) ∣ i := dvd_natAbs.mp <| coe_nat_dvd.mpr <| Nat.gcd_dvd_left _ _ #align int.gcd_dvd_left Int.gcd_dvd_left theorem gcd_dvd_right (i j : ℤ) : (gcd i j : ℤ) ∣ j := dvd_natAbs.mp <| coe_nat_dvd.mpr <| Nat.gcd_dvd_right _ _ #align int.gcd_dvd_right Int.gcd_dvd_right theorem dvd_gcd {i j k : ℤ} (h1 : k ∣ i) (h2 : k ∣ j) : k ∣ gcd i j := natAbs_dvd.1 <| coe_nat_dvd.2 <| Nat.dvd_gcd (natAbs_dvd_natAbs.2 h1) (natAbs_dvd_natAbs.2 h2) #align int.dvd_gcd Int.dvd_gcd theorem gcd_mul_lcm (i j : ℤ) : gcd i j * lcm i j = natAbs (i * j) := by rw [Int.gcd, Int.lcm, Nat.gcd_mul_lcm, natAbs_mul] #align int.gcd_mul_lcm Int.gcd_mul_lcm theorem gcd_comm (i j : ℤ) : gcd i j = gcd j i := Nat.gcd_comm _ _ #align int.gcd_comm Int.gcd_comm theorem gcd_assoc (i j k : ℤ) : gcd (gcd i j) k = gcd i (gcd j k) := Nat.gcd_assoc _ _ _ #align int.gcd_assoc Int.gcd_assoc @[simp] theorem gcd_self (i : ℤ) : gcd i i = natAbs i := by simp [gcd] #align int.gcd_self Int.gcd_self @[simp] theorem gcd_zero_left (i : ℤ) : gcd 0 i = natAbs i := by simp [gcd] #align int.gcd_zero_left Int.gcd_zero_left @[simp] theorem gcd_zero_right (i : ℤ) : gcd i 0 = natAbs i := by simp [gcd] #align int.gcd_zero_right Int.gcd_zero_right @[simp] theorem gcd_one_left (i : ℤ) : gcd 1 i = 1 := Nat.gcd_one_left _ #align int.gcd_one_left Int.gcd_one_left @[simp] theorem gcd_one_right (i : ℤ) : gcd i 1 = 1 := Nat.gcd_one_right _ #align int.gcd_one_right Int.gcd_one_right @[simp] theorem gcd_neg_right {x y : ℤ} : gcd x (-y) = gcd x y := by rw [Int.gcd, Int.gcd, natAbs_neg] #align int.gcd_neg_right Int.gcd_neg_right @[simp] theorem gcd_neg_left {x y : ℤ} : gcd (-x) y = gcd x y := by rw [Int.gcd, Int.gcd, natAbs_neg] #align int.gcd_neg_left Int.gcd_neg_left theorem gcd_mul_left (i j k : ℤ) : gcd (i * j) (i * k) = natAbs i * gcd j k := by rw [Int.gcd, Int.gcd, natAbs_mul, natAbs_mul] apply Nat.gcd_mul_left #align int.gcd_mul_left Int.gcd_mul_left theorem gcd_mul_right (i j k : ℤ) : gcd (i * j) (k * j) = gcd i k * natAbs j := by rw [Int.gcd, Int.gcd, natAbs_mul, natAbs_mul] apply Nat.gcd_mul_right #align int.gcd_mul_right Int.gcd_mul_right theorem gcd_pos_of_non_zero_left {i : ℤ} (j : ℤ) (i_non_zero : i ≠ 0) : 0 < gcd i j := Nat.gcd_pos_of_pos_left (natAbs j) (natAbs_pos.2 i_non_zero) #align int.gcd_pos_of_non_zero_left Int.gcd_pos_of_non_zero_left theorem gcd_pos_of_non_zero_right (i : ℤ) {j : ℤ} (j_non_zero : j ≠ 0) : 0 < gcd i j := Nat.gcd_pos_of_pos_right (natAbs i) (natAbs_pos.2 j_non_zero) #align int.gcd_pos_of_non_zero_right Int.gcd_pos_of_non_zero_right theorem gcd_eq_zero_iff {i j : ℤ} : gcd i j = 0 ↔ i = 0 ∧ j = 0 := by rw [gcd, Nat.gcd_eq_zero_iff, natAbs_eq_zero, natAbs_eq_zero] #align int.gcd_eq_zero_iff Int.gcd_eq_zero_iff theorem gcd_pos_iff {i j : ℤ} : 0 < gcd i j ↔ i ≠ 0 ∨ j ≠ 0 := pos_iff_ne_zero.trans <| gcd_eq_zero_iff.not.trans not_and_or #align int.gcd_pos_iff Int.gcd_pos_iff theorem gcd_div {i j k : ℤ} (H1 : k ∣ i) (H2 : k ∣ j) : gcd (i / k) (j / k) = gcd i j / natAbs k := by rw [gcd, natAbs_ediv i k H1, natAbs_ediv j k H2] exact Nat.gcd_div (natAbs_dvd_natAbs.mpr H1) (natAbs_dvd_natAbs.mpr H2) #align int.gcd_div Int.gcd_div theorem gcd_div_gcd_div_gcd {i j : ℤ} (H : 0 < gcd i j) : gcd (i / gcd i j) (j / gcd i j) = 1 := by rw [gcd_div (gcd_dvd_left i j) (gcd_dvd_right i j), natAbs_ofNat, Nat.div_self H] #align int.gcd_div_gcd_div_gcd Int.gcd_div_gcd_div_gcd theorem gcd_dvd_gcd_of_dvd_left {i k : ℤ} (j : ℤ) (H : i ∣ k) : gcd i j ∣ gcd k j := Int.coe_nat_dvd.1 <| dvd_gcd ((gcd_dvd_left i j).trans H) (gcd_dvd_right i j) #align int.gcd_dvd_gcd_of_dvd_left Int.gcd_dvd_gcd_of_dvd_left theorem gcd_dvd_gcd_of_dvd_right {i k : ℤ} (j : ℤ) (H : i ∣ k) : gcd j i ∣ gcd j k := Int.coe_nat_dvd.1 <| dvd_gcd (gcd_dvd_left j i) ((gcd_dvd_right j i).trans H) #align int.gcd_dvd_gcd_of_dvd_right Int.gcd_dvd_gcd_of_dvd_right theorem gcd_dvd_gcd_mul_left (i j k : ℤ) : gcd i j ∣ gcd (k * i) j := gcd_dvd_gcd_of_dvd_left _ (dvd_mul_left _ _) #align int.gcd_dvd_gcd_mul_left Int.gcd_dvd_gcd_mul_left theorem gcd_dvd_gcd_mul_right (i j k : ℤ) : gcd i j ∣ gcd (i * k) j := gcd_dvd_gcd_of_dvd_left _ (dvd_mul_right _ _) #align int.gcd_dvd_gcd_mul_right Int.gcd_dvd_gcd_mul_right theorem gcd_dvd_gcd_mul_left_right (i j k : ℤ) : gcd i j ∣ gcd i (k * j) := gcd_dvd_gcd_of_dvd_right _ (dvd_mul_left _ _) #align int.gcd_dvd_gcd_mul_left_right Int.gcd_dvd_gcd_mul_left_right theorem gcd_dvd_gcd_mul_right_right (i j k : ℤ) : gcd i j ∣ gcd i (j * k) := gcd_dvd_gcd_of_dvd_right _ (dvd_mul_right _ _) #align int.gcd_dvd_gcd_mul_right_right Int.gcd_dvd_gcd_mul_right_right theorem gcd_eq_left {i j : ℤ} (H : i ∣ j) : gcd i j = natAbs i := Nat.dvd_antisymm (Nat.gcd_dvd_left _ _) (Nat.dvd_gcd dvd_rfl (natAbs_dvd_natAbs.mpr H)) #align int.gcd_eq_left Int.gcd_eq_left theorem gcd_eq_right {i j : ℤ} (H : j ∣ i) : gcd i j = natAbs j := by rw [gcd_comm, gcd_eq_left H] #align int.gcd_eq_right Int.gcd_eq_right theorem ne_zero_of_gcd {x y : ℤ} (hc : gcd x y ≠ 0) : x ≠ 0 ∨ y ≠ 0 := by contrapose! hc rw [hc.left, hc.right, gcd_zero_right, natAbs_zero] #align int.ne_zero_of_gcd Int.ne_zero_of_gcd theorem exists_gcd_one {m n : ℤ} (H : 0 < gcd m n) : ∃ m' n' : ℤ, gcd m' n' = 1 ∧ m = m' * gcd m n ∧ n = n' * gcd m n := ⟨_, _, gcd_div_gcd_div_gcd H, (Int.ediv_mul_cancel (gcd_dvd_left m n)).symm, (Int.ediv_mul_cancel (gcd_dvd_right m n)).symm⟩ #align int.exists_gcd_one Int.exists_gcd_one theorem exists_gcd_one' {m n : ℤ} (H : 0 < gcd m n) : ∃ (g : ℕ)(m' n' : ℤ), 0 < g ∧ gcd m' n' = 1 ∧ m = m' * g ∧ n = n' * g := let ⟨m', n', h⟩ := exists_gcd_one H ⟨_, m', n', H, h⟩ #align int.exists_gcd_one' Int.exists_gcd_one' theorem pow_dvd_pow_iff {m n : ℤ} {k : ℕ} (k0 : 0 < k) : m ^ k ∣ n ^ k ↔ m ∣ n := by refine' ⟨fun h => _, fun h => pow_dvd_pow_of_dvd h _⟩ rwa [← natAbs_dvd_natAbs, ← Nat.pow_dvd_pow_iff k0, ← Int.natAbs_pow, ← Int.natAbs_pow, natAbs_dvd_natAbs] #align int.pow_dvd_pow_iff Int.pow_dvd_pow_iff theorem gcd_dvd_iff {a b : ℤ} {n : ℕ} : gcd a b ∣ n ↔ ∃ x y : ℤ, ↑n = a * x + b * y := by constructor · intro h rw [← Nat.mul_div_cancel' h, Int.ofNat_mul, gcd_eq_gcd_ab, add_mul, mul_assoc, mul_assoc] exact ⟨_, _, rfl⟩ · rintro ⟨x, y, h⟩ rw [← Int.coe_nat_dvd, h] exact dvd_add (dvd_mul_of_dvd_left (gcd_dvd_left a b) _) (dvd_mul_of_dvd_left (gcd_dvd_right a b) y) #align int.gcd_dvd_iff Int.gcd_dvd_iff theorem gcd_greatest {a b d : ℤ} (hd_pos : 0 ≤ d) (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : ℤ, e ∣ a → e ∣ b → e ∣ d) : d = gcd a b := dvd_antisymm hd_pos (ofNat_zero_le (gcd a b)) (dvd_gcd hda hdb) (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) #align int.gcd_greatest Int.gcd_greatest /-- Euclid's lemma: if `a ∣ b * c` and `gcd a c = 1` then `a ∣ b`. Compare with `IsCoprime.dvd_of_dvd_mul_left` and `UniqueFactorizationMonoid.dvd_of_dvd_mul_left_of_no_prime_factors` -/ theorem dvd_of_dvd_mul_left_of_gcd_one {a b c : ℤ} (habc : a ∣ b * c) (hab : gcd a c = 1) : a ∣ b := by have := gcd_eq_gcd_ab a c simp only [hab, Int.ofNat_zero, Int.ofNat_succ, zero_add] at this have : b * a * gcdA a c + b * c * gcdB a c = b := by simp [mul_assoc, ← mul_add, ← this] rw [← this] exact dvd_add (dvd_mul_of_dvd_left (dvd_mul_left a b) _) (dvd_mul_of_dvd_left habc _) #align int.dvd_of_dvd_mul_left_of_gcd_one Int.dvd_of_dvd_mul_left_of_gcd_one /-- Euclid's lemma: if `a ∣ b * c` and `gcd a b = 1` then `a ∣ c`. Compare with `IsCoprime.dvd_of_dvd_mul_right` and `UniqueFactorizationMonoid.dvd_of_dvd_mul_right_of_no_prime_factors` -/ theorem dvd_of_dvd_mul_right_of_gcd_one {a b c : ℤ} (habc : a ∣ b * c) (hab : gcd a b = 1) : a ∣ c := by rw [mul_comm] at habc exact dvd_of_dvd_mul_left_of_gcd_one habc hab #align int.dvd_of_dvd_mul_right_of_gcd_one Int.dvd_of_dvd_mul_right_of_gcd_one /-- For nonzero integers `a` and `b`, `gcd a b` is the smallest positive natural number that can be written in the form `a * x + b * y` for some pair of integers `x` and `y` -/ theorem gcd_least_linear {a b : ℤ} (ha : a ≠ 0) : IsLeast { n : ℕ | 0 < n ∧ ∃ x y : ℤ, ↑n = a * x + b * y } (a.gcd b) := by simp_rw [← gcd_dvd_iff] constructor · simpa [and_true_iff, dvd_refl, Set.mem_setOf_eq] using gcd_pos_of_non_zero_left b ha · simp only [lowerBounds, and_imp, Set.mem_setOf_eq] exact fun n hn_pos hn => Nat.le_of_dvd hn_pos hn #align int.gcd_least_linear Int.gcd_least_linear /-! ### lcm -/ theorem lcm_comm (i j : ℤ) : lcm i j = lcm j i := by rw [Int.lcm, Int.lcm] exact Nat.lcm_comm _ _ #align int.lcm_comm Int.lcm_comm theorem lcm_assoc (i j k : ℤ) : lcm (lcm i j) k = lcm i (lcm j k) := by rw [Int.lcm, Int.lcm, Int.lcm, Int.lcm, natAbs_ofNat, natAbs_ofNat] apply Nat.lcm_assoc #align int.lcm_assoc Int.lcm_assoc @[simp] theorem lcm_zero_left (i : ℤ) : lcm 0 i = 0 := by rw [Int.lcm] apply Nat.lcm_zero_left #align int.lcm_zero_left Int.lcm_zero_left @[simp] theorem lcm_zero_right (i : ℤ) : lcm i 0 = 0 := by rw [Int.lcm] apply Nat.lcm_zero_right #align int.lcm_zero_right Int.lcm_zero_right @[simp] theorem lcm_one_left (i : ℤ) : lcm 1 i = natAbs i := by rw [Int.lcm] apply Nat.lcm_one_left #align int.lcm_one_left Int.lcm_one_left @[simp] theorem lcm_one_right (i : ℤ) : lcm i 1 = natAbs i := by rw [Int.lcm] apply Nat.lcm_one_right #align int.lcm_one_right Int.lcm_one_right @[simp] theorem lcm_self (i : ℤ) : lcm i i = natAbs i := by rw [Int.lcm] apply Nat.lcm_self #align int.lcm_self Int.lcm_self theorem dvd_lcm_left (i j : ℤ) : i ∣ lcm i j := by rw [Int.lcm] apply coe_nat_dvd_right.mpr apply Nat.dvd_lcm_left #align int.dvd_lcm_left Int.dvd_lcm_left theorem dvd_lcm_right (i j : ℤ) : j ∣ lcm i j := by rw [Int.lcm] apply coe_nat_dvd_right.mpr apply Nat.dvd_lcm_right #align int.dvd_lcm_right Int.dvd_lcm_right theorem lcm_dvd {i j k : ℤ} : i ∣ k → j ∣ k → (lcm i j : ℤ) ∣ k := by rw [Int.lcm] intro hi hj exact coe_nat_dvd_left.mpr (Nat.lcm_dvd (natAbs_dvd_natAbs.mpr hi) (natAbs_dvd_natAbs.mpr hj)) #align int.lcm_dvd Int.lcm_dvd end Int @[to_additive gcd_nsmul_eq_zero] theorem pow_gcd_eq_one {M : Type _} [Monoid M] (x : M) {m n : ℕ} (hm : x ^ m = 1) (hn : x ^ n = 1) : x ^ m.gcd n = 1 := by rcases m with (rfl | m); · simp [hn] obtain ⟨y, rfl⟩ := isUnit_ofPowEqOne hm m.succ_ne_zero simp only [← Units.val_pow_eq_pow_val] at * rw [← Units.val_one, ← zpow_coe_nat, ← Units.ext_iff] at * simp only [Nat.gcd_eq_gcd_ab, zpow_add, zpow_mul, hm, hn, one_zpow, one_mul] #align pow_gcd_eq_one pow_gcd_eq_one #align gcd_nsmul_eq_zero gcd_nsmul_eq_zero /-! ### GCD prover -/ -- open NormNum -- namespace Tactic -- namespace NormNum -- theorem int_gcd_helper' {d : ℕ} {x y a b : ℤ} (h₁ : (d : ℤ) ∣ x) (h₂ : (d : ℤ) ∣ y) -- (h₃ : x * a + y * b = d) : Int.gcd x y = d := by -- refine' Nat.dvd_antisymm _ (Int.coe_nat_dvd.1 (Int.dvd_gcd h₁ h₂)) -- rw [← Int.coe_nat_dvd, ← h₃] -- apply dvd_add -- · exact (Int.gcd_dvd_left _ _).mul_right _ -- · exact (Int.gcd_dvd_right _ _).mul_right _ -- #align tactic.norm_num.int_gcd_helper' Tactic.NormNum.int_gcd_helper' -- theorem nat_gcd_helper_dvd_left (x y a : ℕ) (h : x * a = y) : Nat.gcd x y = x := -- Nat.gcd_eq_left ⟨a, h.symm⟩ -- #align tactic.norm_num.nat_gcd_helper_dvd_left Tactic.NormNum.nat_gcd_helper_dvd_left -- theorem nat_gcd_helper_dvd_right (x y a : ℕ) (h : y * a = x) : Nat.gcd x y = y := -- Nat.gcd_eq_right ⟨a, h.symm⟩ -- #align tactic.norm_num.nat_gcd_helper_dvd_right Tactic.NormNum.nat_gcd_helper_dvd_right -- theorem nat_gcd_helper_2 (d x y a b u v tx ty : ℕ) (hu : d * u = x) (hv : d * v = y) -- (hx : x * a = tx) (hy : y * b = ty) (h : ty + d = tx) : Nat.gcd x y = d := by -- rw [← Int.coe_nat_gcd]; -- apply -- @int_gcd_helper' _ _ _ a (-b) (Int.coe_nat_dvd.2 ⟨_, hu.symm⟩) (Int.coe_nat_dvd.2 -- ⟨_, hv.symm⟩) -- rw [mul_neg, ← sub_eq_add_neg, sub_eq_iff_eq_add'] -- norm_cast; rw [hx, hy, h] -- #align tactic.norm_num.nat_gcd_helper_2 Tactic.NormNum.nat_gcd_helper_2 -- theorem nat_gcd_helper_1 (d x y a b u v tx ty : ℕ) (hu : d * u = x) (hv : d * v = y) -- (hx : x * a = tx) (hy : y * b = ty) (h : tx + d = ty) : Nat.gcd x y = d := -- (Nat.gcd_comm _ _).trans <| nat_gcd_helper_2 _ _ _ _ _ _ _ _ _ hv hu hy hx h -- #align tactic.norm_num.nat_gcd_helper_1 Tactic.NormNum.nat_gcd_helper_1 -- --Porting note: the `simp only` was not necessary in Lean3. -- theorem nat_lcm_helper (x y d m n : ℕ) (hd : Nat.gcd x y = d) (d0 : 0 < d) (xy : x * y = n) -- (dm : d * m = n) : Nat.lcm x y = m := -- mul_right_injective₀ d0.ne' <| by simp only; rw [dm, ← xy, ← hd, Nat.gcd_mul_lcm] -- #align tactic.norm_num.nat_lcm_helper Tactic.NormNum.nat_lcm_helper -- theorem nat_coprime_helper_zero_left (x : ℕ) (h : 1 < x) : ¬Nat.coprime 0 x := -- mt (Nat.coprime_zero_left _).1 <| ne_of_gt h -- #align tactic.norm_num.nat_coprime_helper_zero_left Tactic.NormNum.nat_coprime_helper_zero_left -- theorem nat_coprime_helper_zero_right (x : ℕ) (h : 1 < x) : ¬Nat.coprime x 0 := -- mt (Nat.coprime_zero_right _).1 <| ne_of_gt h -- #align tactic.norm_num.nat_coprime_helper_zero_right Tactic.NormNum.nat_coprime_helper_zero_right -- theorem nat_coprime_helper_1 (x y a b tx ty : ℕ) (hx : x * a = tx) (hy : y * b = ty) -- (h : tx + 1 = ty) : Nat.coprime x y := -- nat_gcd_helper_1 _ _ _ _ _ _ _ _ _ (one_mul _) (one_mul _) hx hy h -- #align tactic.norm_num.nat_coprime_helper_1 Tactic.NormNum.nat_coprime_helper_1 -- theorem nat_coprime_helper_2 (x y a b tx ty : ℕ) (hx : x * a = tx) (hy : y * b = ty) -- (h : ty + 1 = tx) : Nat.coprime x y := -- nat_gcd_helper_2 _ _ _ _ _ _ _ _ _ (one_mul _) (one_mul _) hx hy h -- #align tactic.norm_num.nat_coprime_helper_2 Tactic.NormNum.nat_coprime_helper_2 -- theorem nat_not_coprime_helper (d x y u v : ℕ) (hu : d * u = x) (hv : d * v = y) (h : 1 < d) : -- ¬Nat.coprime x y := -- Nat.not_coprime_of_dvd_of_dvd h ⟨_, hu.symm⟩ ⟨_, hv.symm⟩ -- #align tactic.norm_num.nat_not_coprime_helper Tactic.NormNum.nat_not_coprime_helper -- theorem int_gcd_helper (x y : ℤ) (nx ny d : ℕ) (hx : (nx : ℤ) = x) (hy : (ny : ℤ) = y) -- (h : Nat.gcd nx ny = d) : Int.gcd x y = d := by rwa [← hx, ← hy, Int.coe_nat_gcd] -- #align tactic.norm_num.int_gcd_helper Tactic.NormNum.int_gcd_helper -- theorem int_gcd_helper_neg_left (x y : ℤ) (d : ℕ) (h : Int.gcd x y = d) : Int.gcd (-x) y = d := -- by rw [Int.gcd] at h⊢; rwa [Int.natAbs_neg] -- #align tactic.norm_num.int_gcd_helper_neg_left Tactic.NormNum.int_gcd_helper_neg_left -- theorem int_gcd_helper_neg_right (x y : ℤ) (d : ℕ) (h : Int.gcd x y = d) : Int.gcd x (-y) = d := -- by rw [Int.gcd] at h⊢; rwa [Int.natAbs_neg] -- #align tactic.norm_num.int_gcd_helper_neg_right Tactic.NormNum.int_gcd_helper_neg_right -- theorem int_lcm_helper (x y : ℤ) (nx ny d : ℕ) (hx : (nx : ℤ) = x) (hy : (ny : ℤ) = y) -- (h : Nat.lcm nx ny = d) : Int.lcm x y = d := by rwa [← hx, ← hy, Int.coe_nat_lcm] -- #align tactic.norm_num.int_lcm_helper Tactic.NormNum.int_lcm_helper -- theorem int_lcm_helper_neg_left (x y : ℤ) (d : ℕ) (h : Int.lcm x y = d) : Int.lcm (-x) y = d := -- by rw [Int.lcm] at h⊢; rwa [Int.natAbs_neg] -- #align tactic.norm_num.int_lcm_helper_neg_left Tactic.NormNum.int_lcm_helper_neg_left -- theorem int_lcm_helper_neg_right (x y : ℤ) (d : ℕ) (h : Int.lcm x y = d) : Int.lcm x (-y) = d := -- by rw [Int.lcm] at h⊢; rwa [Int.natAbs_neg] -- #align tactic.norm_num.int_lcm_helper_neg_right Tactic.NormNum.int_lcm_helper_neg_right -- /-- Evaluates the `nat.gcd` function. -/ -- unsafe def prove_gcd_nat (c : instance_cache) (ex ey : expr) : -- tactic (instance_cache × expr × expr) := do -- let x ← ex.toNat -- let y ← ey.toNat -- match x, y with -- | 0, _ => pure (c, ey, q(Nat.gcd_zero_left).mk_app [ey]) -- | _, 0 => pure (c, ex, q(Nat.gcd_zero_right).mk_app [ex]) -- | 1, _ => pure (c, q((1 : ℕ)), q(Nat.gcd_one_left).mk_app [ey]) -- | _, 1 => pure (c, q((1 : ℕ)), q(Nat.gcd_one_right).mk_app [ex]) -- | _, _ => do -- let (d, a, b) := Nat.xgcdAux x 1 0 y 0 1 -- if d = x then do -- let (c, ea) ← c (y / x) -- let (c, _, p) ← prove_mul_nat c ex ea -- pure (c, ex, q(nat_gcd_helper_dvd_left).mk_app [ex, ey, ea, p]) -- else -- if d = y then do -- let (c, ea) ← c (x / y) -- let (c, _, p) ← prove_mul_nat c ey ea -- pure (c, ey, q(nat_gcd_helper_dvd_right).mk_app [ex, ey, ea, p]) -- else do -- let (c, ed) ← c d -- let (c, ea) ← c a -- let (c, eb) ← c b -- let (c, eu) ← c (x / d) -- let (c, ev) ← c (y / d) -- let (c, _, pu) ← prove_mul_nat c ed eu -- let (c, _, pv) ← prove_mul_nat c ed ev -- let (c, etx, px) ← prove_mul_nat c ex ea -- let (c, ety, py) ← prove_mul_nat c ey eb -- let (c, p) ← if a ≥ 0 then prove_add_nat c ety ed etx else prove_add_nat c etx ed ety -- let pf : expr := if a ≥ 0 then q(nat_gcd_helper_2) else q(nat_gcd_helper_1) -- pure (c, ed, pf [ed, ex, ey, ea, eb, eu, ev, etx, ety, pu, pv, px, py, p]) -- #align tactic.norm_num.prove_gcd_nat tactic.norm_num.prove_gcd_nat -- /-- Evaluates the `nat.lcm` function. -/ -- unsafe def prove_lcm_nat (c : instance_cache) (ex ey : expr) : -- tactic (instance_cache × expr × expr) := do -- let x ← ex.toNat -- let y ← ey.toNat -- match x, y with -- | 0, _ => pure (c, q((0 : ℕ)), q(Nat.lcm_zero_left).mk_app [ey]) -- | _, 0 => pure (c, q((0 : ℕ)), q(Nat.lcm_zero_right).mk_app [ex]) -- | 1, _ => pure (c, ey, q(Nat.lcm_one_left).mk_app [ey]) -- | _, 1 => pure (c, ex, q(Nat.lcm_one_right).mk_app [ex]) -- | _, _ => do -- let (c, ed, pd) ← prove_gcd_nat c ex ey -- let (c, p0) ← prove_pos c ed -- let (c, en, xy) ← prove_mul_nat c ex ey -- let d ← ed -- let (c, em) ← c (x * y / d) -- let (c, _, dm) ← prove_mul_nat c ed em -- pure (c, em, q(nat_lcm_helper).mk_app [ex, ey, ed, em, en, pd, p0, xy, dm]) -- #align tactic.norm_num.prove_lcm_nat tactic.norm_num.prove_lcm_nat -- /-- Evaluates the `int.gcd` function. -/ -- unsafe def prove_gcd_int (zc nc : instance_cache) : -- expr → expr → tactic (instance_cache × instance_cache × expr × expr) -- | x, y => -- match match_neg x with -- | some x => do -- let (zc, nc, d, p) ← prove_gcd_int x y -- pure (zc, nc, d, q(int_gcd_helper_neg_left).mk_app [x, y, d, p]) -- | none => -- match match_neg y with -- | some y => do -- let (zc, nc, d, p) ← prove_gcd_int x y -- pure (zc, nc, d, q(int_gcd_helper_neg_right).mk_app [x, y, d, p]) -- | none => do -- let (zc, nc, nx, px) ← prove_nat_uncast zc nc x -- let (zc, nc, ny, py) ← prove_nat_uncast zc nc y -- let (nc, d, p) ← prove_gcd_nat nc nx ny -- pure (zc, nc, d, q(int_gcd_helper).mk_app [x, y, nx, ny, d, px, py, p]) -- #align tactic.norm_num.prove_gcd_int tactic.norm_num.prove_gcd_int -- /-- Evaluates the `int.lcm` function. -/ -- unsafe def prove_lcm_int (zc nc : instance_cache) : -- expr → expr → tactic (instance_cache × instance_cache × expr × expr) -- | x, y => -- match match_neg x with -- | some x => do -- let (zc, nc, d, p) ← prove_lcm_int x y -- pure (zc, nc, d, q(int_lcm_helper_neg_left).mk_app [x, y, d, p]) -- | none => -- match match_neg y with -- | some y => do -- let (zc, nc, d, p) ← prove_lcm_int x y -- pure (zc, nc, d, q(int_lcm_helper_neg_right).mk_app [x, y, d, p]) -- | none => do -- let (zc, nc, nx, px) ← prove_nat_uncast zc nc x -- let (zc, nc, ny, py) ← prove_nat_uncast zc nc y -- let (nc, d, p) ← prove_lcm_nat nc nx ny -- pure (zc, nc, d, q(int_lcm_helper).mk_app [x, y, nx, ny, d, px, py, p]) -- #align tactic.norm_num.prove_lcm_int tactic.norm_num.prove_lcm_int -- /-- Evaluates the `nat.coprime` function. -/ -- unsafe def prove_coprime_nat (c : instance_cache) (ex ey : expr) : -- tactic (instance_cache × Sum expr expr) := do -- let x ← ex.toNat -- let y ← ey.toNat -- match x, y with -- | 1, _ => pure (c, Sum.inl <| q(Nat.coprime_one_left).mk_app [ey]) -- | _, 1 => pure (c, Sum.inl <| q(Nat.coprime_one_right).mk_app [ex]) -- | 0, 0 => pure (c, Sum.inr q(Nat.not_coprime_zero_zero)) -- | 0, _ => do -- let c ← mk_instance_cache q(ℕ) -- let (c, p) ← prove_lt_nat c q(1) ey -- pure (c, Sum.inr <| q(nat_coprime_helper_zero_left).mk_app [ey, p]) -- | _, 0 => do -- let c ← mk_instance_cache q(ℕ) -- let (c, p) ← prove_lt_nat c q(1) ex -- pure (c, Sum.inr <| q(nat_coprime_helper_zero_right).mk_app [ex, p]) -- | _, _ => do -- let c ← mk_instance_cache q(ℕ) -- let (d, a, b) := Nat.xgcdAux x 1 0 y 0 1 -- if d = 1 then do -- let (c, ea) ← c a -- let (c, eb) ← c b -- let (c, etx, px) ← prove_mul_nat c ex ea -- let (c, ety, py) ← prove_mul_nat c ey eb -- let (c, p) ← if a ≥ 0 then -- prove_add_nat c ety q(1) etx else prove_add_nat c etx q(1) ety -- let pf : expr := if a ≥ 0 then q(nat_coprime_helper_2) else q(nat_coprime_helper_1) -- pure (c, Sum.inl <| pf [ex, ey, ea, eb, etx, ety, px, py, p]) -- else do -- let (c, ed) ← c d -- let (c, eu) ← c (x / d) -- let (c, ev) ← c (y / d) -- let (c, _, pu) ← prove_mul_nat c ed eu -- let (c, _, pv) ← prove_mul_nat c ed ev -- let (c, p) ← prove_lt_nat c q(1) ed -- pure (c, Sum.inr <| q(nat_not_coprime_helper).mk_app [ed, ex, ey, eu, ev, pu, pv, p]) -- #align tactic.norm_num.prove_coprime_nat tactic.norm_num.prove_coprime_nat -- /-- Evaluates the `gcd`, `lcm`, and `coprime` functions. -/ -- @[norm_num] -- unsafe def eval_gcd : expr → tactic (expr × expr) -- | q(Nat.gcd $(ex) $(ey)) => do -- let c ← mk_instance_cache q(ℕ) -- Prod.snd <$> prove_gcd_nat c ex ey -- | q(Nat.lcm $(ex) $(ey)) => do -- let c ← mk_instance_cache q(ℕ) -- Prod.snd <$> prove_lcm_nat c ex ey -- | q(Nat.Coprime $(ex) $(ey)) => do -- let c ← mk_instance_cache q(ℕ) -- prove_coprime_nat c ex ey >>= Sum.elim true_intro false_intro ∘ Prod.snd -- | q(Int.gcd $(ex) $(ey)) => do -- let zc ← mk_instance_cache q(ℤ) -- let nc ← mk_instance_cache q(ℕ) -- (Prod.snd ∘ Prod.snd) <$> prove_gcd_int zc nc ex ey -- | q(Int.lcm $(ex) $(ey)) => do -- let zc ← mk_instance_cache q(ℤ) -- let nc ← mk_instance_cache q(ℕ) -- (Prod.snd ∘ Prod.snd) <$> prove_lcm_int zc nc ex ey -- | _ => failed -- #align tactic.norm_num.eval_gcd tactic.norm_num.eval_gcd -- end NormNum -- end Tactic
(* Clean-slate look at subtyping relation based on *) (* singleton types (single env) *) (* TODO: + get rid of all admits + Rewriting semantics + Soundness proof Type checker / examples ------ + expansion other than 0 - multiple members - intersection types - app var / proper TAll comparison - remove unnecessary size variables - stp_selx rule? - closedness question: expansion cannot use id beyond self *) Require Export SfLib. Require Export Arith.EqNat. Require Export Arith.Lt. Module STLC. Definition id := nat. Inductive ty : Type := | TBot : ty | TTop : ty | TBool : ty | TFun : ty -> ty -> ty | TMem : ty -> ty -> ty (* intro *) | TVar : bool -> id -> ty | TVarB : id -> ty | TSel : ty -> ty (* elim *) | TBind : ty -> ty . Inductive tm : Type := | tvar : bool -> id -> tm | tbool : bool -> tm | tmem : ty -> tm | tapp : tm -> tm -> tm | tabs : ty -> ty -> tm -> tm . Inductive vl : Type := | vbool : bool -> vl | vabs : ty -> ty -> tm -> vl | vty : ty -> vl . Definition venv := list vl. Definition tenv := list ty. Hint Unfold venv. Hint Unfold tenv. Fixpoint index {X : Type} (n : id) (l : list X) : option X := match l with | [] => None | a :: l' => if beq_nat n (length l') then Some a else index n l' end. (* closed i j k means normal variables < i and < j, bound variables < k *) Inductive closed: nat -> nat -> nat -> ty -> Prop := | cl_bot: forall i j k, closed i j k TBot | cl_top: forall i j k, closed i j k TTop | cl_bool: forall i j k, closed i j k TBool | cl_fun: forall i j k T1 T2, closed i j k T1 -> closed i j k T2 -> closed i j k (TFun T1 T2) | cl_mem: forall i j k T1 T2, closed i j k T1 -> closed i j k T2 -> closed i j k (TMem T1 T2) | cl_var0: forall i j k x, i > x -> closed i j k (TVar false x) | cl_var1: forall i j k x, j > x -> closed i j k (TVar true x) | cl_varB: forall i j k x, k > x -> closed i j k (TVarB x) | cl_sel: forall i j k T1, closed i j k T1 -> closed i j k (TSel T1) | cl_bind: forall i j k T1, closed i j (S k) T1 -> closed i j k (TBind T1) . Fixpoint open (k: nat) (u: ty) (T: ty) { struct T }: ty := match T with | TVar b x => TVar b x (* free var remains free. functional, so we can't check for conflict *) | TVarB x => if beq_nat k x then u else TVarB x | TTop => TTop | TBot => TBot | TBool => TBool | TSel T1 => TSel (open k u T1) | TFun T1 T2 => TFun (open k u T1) (open k u T2) | TMem T1 T2 => TMem (open k u T1) (open k u T2) | TBind T1 => TBind (open (S k) u T1) end. Fixpoint subst (U : ty) (T : ty) {struct T} : ty := match T with | TTop => TTop | TBot => TBot | TBool => TBool | TMem T1 T2 => TMem (subst U T1) (subst U T2) | TSel T1 => TSel (subst U T1) | TVarB i => TVarB i | TVar true i => TVar true i | TVar false i => if beq_nat i 0 then U else TVar false (i-1) | TFun T1 T2 => TFun (subst U T1) (subst U T2) | TBind T2 => TBind (subst U T2) end. Inductive has_type : tenv -> venv -> tm -> ty -> nat -> Prop := | T_Varx : forall GH G1 x n1, x < length G1 -> has_type GH G1 (tvar true x) (TVar true x) (S n1) | T_Vary : forall G1 GH x n1, x < length GH -> has_type GH G1 (tvar false x) (TVar false x) (S n1) | T_Mem : forall GH G1 T11 n1, closed (length GH) (length G1) 0 T11 -> has_type GH G1 (tmem T11) (TMem T11 T11) (S n1) | T_Abs : forall GH G1 T11 T12 t12 n1, has_type (T11::GH) G1 t12 T12 n1 -> closed (length GH) (length G1) 0 T11 -> closed (length GH) (length G1) 0 T12 -> has_type GH G1 (tabs T11 T12 t12) (TFun T11 T12) (S n1) | T_App : forall T1 T2 GH G1 t1 t2 n1 n2, has_type GH G1 t1 (TFun T1 T2) n1 -> has_type GH G1 t2 T1 n2 -> has_type GH G1 (tapp t1 t2) T2 (S (n1+n2)) | T_Sub : forall m GH G1 t T1 T2 n1 n2, has_type GH G1 t T1 n1 -> stp2 m false GH G1 T1 T2 n2 -> has_type GH G1 t T2 (S (n1 + n2)) with stp2: nat -> bool -> tenv -> venv -> ty -> ty -> nat -> Prop := | stp2_bot: forall m GH G1 T n1, closed (length GH) (length G1) 0 T -> stp2 m true GH G1 TBot T (S n1) | stp2_top: forall m GH G1 T n1, closed (length GH) (length G1) 0 T -> stp2 m true GH G1 T TTop (S n1) | stp2_bool: forall m GH G1 n1, stp2 m true GH G1 TBool TBool (S n1) | stp2_fun: forall m GH G1 T1 T2 T3 T4 n1 n2, stp2 m false GH G1 T3 T1 n1 -> stp2 m false GH G1 T2 T4 n2 -> stp2 m true GH G1 (TFun T1 T2) (TFun T3 T4) (S (n1+n2)) | stp2_mem: forall m GH G1 T1 T2 T3 T4 n1 n2, stp2 m false GH G1 T3 T1 n2 -> stp2 m false GH G1 T2 T4 n1 -> stp2 m true GH G1 (TMem T1 T2) (TMem T3 T4) (S (n1+n2)) | stp2_varx: forall m GH G1 x n1, x < length G1 -> stp2 m true GH G1 (TVar true x) (TVar true x) (S n1) | stp2_var1: forall m GH G1 x T2 n1, vtp2 G1 x T2 n1 -> (* slack for: val_type G2 v T2 *) stp2 m true GH G1 (TVar true x) T2 (S n1) (* not sure if we should have these 2 or not ... ? *) (* | stp2_varb1: forall m GH G1 T2 x n1, stp2 m true GH G1 (TVar true x) (TBind T2) n1 -> stp2 m true GH G1 (TVar true x) (open 0 (TVar false x) T2) (S n1) | stp2_varb2: forall m GH G1 T2 x n1, stp2 m true GH G1 (TVar true x) (open 0 (TVar false x) T2) n1 -> stp2 m true GH G1 (TVar true x) (TBind T2) (S n1) *) | stp2_varax: forall m GH G1 x n1, x < length GH -> stp2 m true GH G1 (TVar false x) (TVar false x) (S n1) (* | stp2_varay: forall m GH G1 TX x1 x2 n1, index x1 GH = Some TX -> stp2 m false GH G1 TX (TVar false x2) n1 -> stp2 m true GH G1 (TVar false x2) (TVar false x1) (S n1) | stp2_vary: forall m GH G1 x1 x2 n1, index x1 GH = Some (TVar true x2) -> x2 < length G1 -> stp2 m true GH G1 (TVar true x2) (TVar false x1) (S n1) *) | stp2_vara1: forall m GH G1 T2 x n1, htp m false GH G1 x T2 n1 -> (* TEMP -- SHOULD ALLOW UP TO x *) stp2 m true GH G1 (TVar false x) T2 (S n1) (* | stp2_varab1: forall m GH G1 T2 x n1, stp2 m true GH G1 (TVar false x) (TBind T2) n1 -> stp2 m true GH G1 (TVar false x) (open 0 (TVar false x) T2) (S n1) | stp2_varab2: forall m GH G1 T2 x n1, stp2 m true GH G1 (TVar false x) (open 0 (TVar false x) T2) n1 -> stp2 (S m) true GH G1 (TVar false x) (TBind T2) (S n1) *) (* NOTE: Currently we require *all* store references (TVar true x) to expand (strong_sel), even in nested contexts (GH <> nil). This is directly related to the htp GL restriction: when substituting, we must derive the precise expansion, and cannot tolerate potentially unsafe bindings in GH. Is this an issue? If yes, we can keep sel1/sel2 and htp for store references, and only invert once we know GH=[]. We need to be careful, though: it is not clear that we can use stp2_trans on the embedded vtp. We may need to specially mark self variables (again), since they are the only ones that occur recursively. *) | stp2_strong_sel1: forall m GH G1 T2 TX x n1, index x G1 = Some (vty TX) -> stp2 m false [] G1 TX T2 n1 -> stp2 m true GH G1 (TSel (TVar true x)) T2 (S n1) | stp2_strong_sel2: forall m GH G1 T1 TX x n1, index x G1 = Some (vty TX) -> stp2 m false [] G1 T1 TX n1 -> stp2 m true GH G1 T1 (TSel (TVar true x)) (S n1) (* | stp2_xsel1: forall m GH G1 T2 TX x n1, index x G1 = Some (vty TX) -> stp2 m false [] G1 TX T2 n1 -> stp2 m true GH G1 (TSel (TVar true x)) T2 (S n1) | stp2_xsel2: forall m GH G1 T1 TX x n1, index x G1 = Some (vty TX) -> stp2 m false [] G1 T1 TX n1 -> stp2 m true GH G1 T1 (TSel (TVar true x)) (S n1) *) | stp2_sel1: forall m GH G1 T2 x n1, htp m false GH G1 x (TMem TBot T2) n1 -> stp2 m true GH G1 (TSel (TVar false x)) T2 (S n1) | stp2_sel2: forall m GH G1 T1 x n1, htp m false GH G1 x (TMem T1 TTop) n1 -> stp2 m true GH G1 T1 (TSel (TVar false x)) (S n1) | stp2_bind1: forall m GH G1 T1 T1' T2 n1, htp m false (T1'::GH) G1 (length GH) T2 n1 -> T1' = (open 0 (TVar false (length GH)) T1) -> closed (length GH) (length G1) 1 T1 -> closed (length GH) (length G1) 0 T2 -> stp2 m true GH G1 (TBind T1) T2 (S n1) | stp2_bindx: forall m GH G1 T1 T1' T2 T2' n1, htp m false (T1'::GH) G1 (length GH) T2' n1 -> T1' = (open 0 (TVar false (length GH)) T1) -> T2' = (open 0 (TVar false (length GH)) T2) -> closed (length GH) (length G1) 1 T1 -> closed (length GH) (length G1) 1 T2 -> stp2 m true GH G1 (TBind T1) (TBind T2) (S n1) | stp2_wrapf: forall m GH G1 T1 T2 n1, stp2 m true GH G1 T1 T2 n1 -> stp2 m false GH G1 T1 T2 (S n1) | stp2_transf: forall m GH G1 T1 T2 T3 n1 n2 m2 m3, stp2 m false GH G1 T1 T2 n1 -> stp2 m2 false GH G1 T2 T3 n2 -> stp2 m3 false GH G1 T1 T3 (S (n1+n2)) with htp: nat -> bool -> tenv -> venv -> nat -> ty -> nat -> Prop := | htp_var: forall m b GH G1 x TX n1, (* can we assign (TVar false x) ? probably not ... *) index x GH = Some TX -> closed (length GH) (length G1) 0 TX -> htp m b GH G1 x TX (S n1) | htp_bind: forall m b GH G1 x TX n1, (* is it needed given stp2_bind1? for the moment, yes ...*) htp m b GH G1 x (TBind TX) n1 -> closed x (length G1) 1 TX -> htp m b GH G1 x (open 0 (TVar false x) TX) (S n1) | htp_sub: forall m b GH GU GL G1 x T1 T2 n1 n2, htp m b GH G1 x T1 n1 -> stp2 m b GL G1 T1 T2 n2 -> length GL = S x -> GH = GU ++ GL -> (* NOTE: restriction to GL means we need trans in sel rules *) htp m b GH G1 x T2 (S (n1+n2)) with vtp : nat -> venv -> nat -> ty -> nat -> Prop := | vtp_top: forall m G1 x n1, x < length G1 -> vtp m G1 x TTop (S n1) | vtp_bool: forall m G1 x b n1, index x G1 = Some (vbool b) -> vtp m G1 x (TBool) (S (n1)) | vtp_mem: forall m G1 x TX T1 T2 ms n1 n2, index x G1 = Some (vty TX) -> stp2 ms false [] G1 T1 TX n1 -> stp2 ms false [] G1 TX T2 n2 -> vtp m G1 x (TMem T1 T2) (S (n1+n2)) | vtp_fun: forall m G1 x T1 T2 T3 T4 t ms n1 n2 n3, index x G1 = Some (vabs T1 T2 t) -> has_type [T1] G1 t T2 n3 -> stp2 ms false [] G1 T3 T1 n1 -> stp2 ms false [] G1 T2 T4 n2 -> vtp m G1 x (TFun T3 T4) (S (n1+n2+n3)) | vtp_bind: forall m G1 x T2 n1, vtp m G1 x (open 0 (TVar true x) T2) n1 -> closed 0 (length G1) 1 T2 -> vtp (S m) G1 x (TBind T2) (S (n1)) | vtp_sel: forall m G1 x y TX n1, index y G1 = Some (vty TX) -> vtp m G1 x TX n1 -> vtp m G1 x (TSel (TVar true y)) (S (n1)) with vtp2 : venv -> nat -> ty -> nat -> Prop := | vtp2_refl: forall G1 x n1, x < length G1 -> vtp2 G1 x (TVar true x) (S n1) | vtp2_down: forall m G1 x T n1, vtp m G1 x T n1 -> vtp2 G1 x T (S n1) | vtp2_sel: forall G1 x y TX n1, index y G1 = Some (vty TX) -> vtp2 G1 x TX n1 -> vtp2 G1 x (TSel (TVar true y)) (S (n1)). Definition has_typed GH G1 x T1 := exists n, has_type GH G1 x T1 n. Definition stpd2 m b GH G1 T1 T2 := exists n, stp2 m b GH G1 T1 T2 n. Definition htpd m b GH G1 x T1 := exists n, htp m b GH G1 x T1 n. Definition vtpd m G1 x T1 := exists n, vtp m G1 x T1 n. Definition vtpd2 G1 x T1 := exists n, vtp2 G1 x T1 n. Definition vtpdd m G1 x T1 := exists m1 n, vtp m1 G1 x T1 n /\ m1 <= m. Hint Constructors stp2. Hint Constructors vtp. Ltac ep := match goal with | [ |- stp2 ?M ?B ?GH ?G1 ?T1 ?T2 ?N ] => assert (exists (n:nat), stp2 M B GH G1 T1 T2 n) as EEX end. Ltac eu := match goal with | H: has_typed _ _ _ _ |- _ => destruct H as [? H] | H: stpd2 _ _ _ _ _ _ |- _ => destruct H as [? H] | H: htpd _ _ _ _ _ _ |- _ => destruct H as [? H] | H: vtpd _ _ _ _ |- _ => destruct H as [? H] | H: vtpd2 _ _ _ |- _ => destruct H as [? H] | H: vtpdd _ _ _ _ |- _ => destruct H as [? [? [H ?]]] end. Lemma stpd2_bot: forall m GH G1 T, closed (length GH) (length G1) 0 T -> stpd2 m true GH G1 TBot T. Proof. intros. exists 1. eauto. Qed. Lemma stpd2_top: forall m GH G1 T, closed (length GH) (length G1) 0 T -> stpd2 m true GH G1 T TTop. Proof. intros. exists 1. eauto. Qed. Lemma stpd2_bool: forall m GH G1, stpd2 m true GH G1 TBool TBool. Proof. intros. exists 1. eauto. Qed. Lemma stpd2_fun: forall m GH G1 T1 T2 T3 T4, stpd2 m false GH G1 T3 T1 -> stpd2 m false GH G1 T2 T4 -> stpd2 m true GH G1 (TFun T1 T2) (TFun T3 T4). Proof. intros. repeat eu. eexists. eauto. Qed. Lemma stpd2_mem: forall m GH G1 T1 T2 T3 T4, stpd2 m false GH G1 T3 T1 -> stpd2 m false GH G1 T2 T4 -> stpd2 m true GH G1 (TMem T1 T2) (TMem T3 T4). Proof. intros. repeat eu. eexists. eauto. Qed. (* Lemma stpd2_varx: forall m GH G1 x, x < length G1 -> stpd2 m true GH G1 (TVar true x) (TVar true x). Proof. intros. repeat eu. exists 1. eauto. Qed. Lemma stpd2_var1: forall m GH G1 TX x T2 v, index x G1 = Some v -> val_type0 G1 v TX -> (* slack for: val_type G2 v T2 *) stpd2 m true GH G1 TX T2 -> stpd2 m true GH G1 (TVar true x) T2. Proof. intros. repeat eu. eexists. eauto. Qed. (*Lemma stpd2_var1b: forall m GH G1 GX TX G2 x x2 T2 v, index x G1 = Some v -> index x2 G2 = Some v -> val_type0 GX v TX -> (* slack for: val_type G2 v T2 *) stpd2 m true GH GX TX G2 (open 0 (TVar true x2) T2) -> stpd2 m true GH G1 (TVar true x) G2 (TBind T2). Proof. intros. repeat eu. eexists. eauto. Qed.*) Lemma stpd2_sel: forall m GH G1 T1 T2, stpd2 m false GH G1 T2 T1 -> stpd2 m true GH G1 T1 T2 -> stpd2 m true GH G1 (TSel T1) (TSel T2). Proof. intros. repeat eu. eexists. eauto. Qed. Lemma stpd2_red: forall m GH G1 T1 T2, stpd2 m true GH G1 T1 (TMem TBot T2) -> stpd2 m true GH G1 (TSel T1) T2. Proof. intros. repeat eu. eexists. eauto. Qed. Lemma stpd2_red2: forall m GH G1 TX T1 T2 T0, real T0 -> stpd2 m true GH G1 T0 T2 -> stpd2 m false GH G1 T2 (TMem TX TTop) -> stpd2 m true GH G1 T0 (TMem TX TTop) -> stpd2 m false GH G1 T1 TX -> stpd2 m true GH G1 T1 (TSel T2). Proof. intros. repeat eu. eexists. eauto. Qed. (* Lemma stpd2_bindI: forall G1 G2 T2 x, stpd2 true G1 (TVar x) G2 (open 0 (TVar x) T2) -> stpd2 true G1 (TVar x) G2 (TBind T2). Proof. intros. repeat eu. eexists. eauto. Qed. * Lemma stpd2_bindE: forall G1 G2 T2 x, stpd2 true G1 (TVar x) G2 (TBind T2) -> stpd2 true G1 (TVar x) G2 (open 0 (TVar x) T2). Proof. intros. repeat eu. eexists. eauto. Qed. *) (*Lemma stpd2_bind1: forall m GH G1 T1 T2, closed (length GH) (length G2) 0 T2 -> stpd2 m true ((G1,(open 0 (TVar false (length GH)) T1))::GH) G1 (TVar false (length GH)) G2 T2 -> stpd2 m true GH G1 (TBind T1) G2 T2. Proof. intros. repeat eu. eexists. eauto. Qed. *) *) Lemma stpd2_wrapf: forall m GH G1 T1 T2, stpd2 m true GH G1 T1 T2 -> stpd2 m false GH G1 T1 T2. Proof. intros. repeat eu. eexists. eauto. Qed. Lemma stpd2_transf: forall m GH G1 T1 T2 T3, stpd2 m false GH G1 T1 T2 -> stpd2 m true GH G1 T2 T3 -> stpd2 m false GH G1 T1 T3. Proof. intros. repeat eu. eexists. eauto. Qed. Hint Constructors ty. Hint Constructors vl. Hint Constructors stp2. Hint Constructors vtp. Hint Constructors htp. Hint Constructors has_type. Hint Unfold has_typed. Hint Unfold stpd2. Hint Unfold vtpd. Hint Unfold vtpdd. Hint Constructors option. Hint Constructors list. Hint Unfold index. Hint Unfold length. Hint Resolve ex_intro. Ltac ev := repeat match goal with | H: exists _, _ |- _ => destruct H | H: _ /\ _ |- _ => destruct H end. Lemma index_max : forall X vs n (T: X), index n vs = Some T -> n < length vs. Proof. intros X vs. induction vs. Case "nil". intros. inversion H. Case "cons". intros. inversion H. case_eq (beq_nat n (length vs)); intros E. SCase "hit". rewrite E in H1. inversion H1. subst. eapply beq_nat_true in E. unfold length. unfold length in E. rewrite E. eauto. SCase "miss". rewrite E in H1. assert (n < length vs). eapply IHvs. apply H1. compute. eauto. Qed. Lemma index_exists : forall X vs n, n < length vs -> exists (T:X), index n vs = Some T. Proof. intros X vs. induction vs. Case "nil". intros. inversion H. Case "cons". intros. inversion H. SCase "hit". assert (beq_nat n (length vs) = true) as E. eapply beq_nat_true_iff. eauto. simpl. subst n. rewrite E. eauto. SCase "miss". assert (beq_nat n (length vs) = false) as E. eapply beq_nat_false_iff. omega. simpl. rewrite E. eapply IHvs. eauto. Qed. Lemma index_extend : forall X vs n a (T: X), index n vs = Some T -> index n (a::vs) = Some T. Proof. intros. assert (n < length vs). eapply index_max. eauto. assert (n <> length vs). omega. assert (beq_nat n (length vs) = false) as E. eapply beq_nat_false_iff; eauto. unfold index. unfold index in H. rewrite H. rewrite E. reflexivity. Qed. Lemma closed_extend : forall T X (a:X) i k G, closed i (length G) k T -> closed i (length (a::G)) k T. Proof. intros T. induction T; intros; inversion H; econstructor; eauto. simpl. omega. Qed. Lemma all_extend: forall ni, (forall m b GH v1 G1 T1 T2 n, stp2 m b GH G1 T1 T2 n -> n < ni -> stp2 m b GH (v1::G1) T1 T2 n) /\ (forall m v1 x G1 T2 n, vtp m G1 x T2 n -> n < ni -> vtp m (v1::G1) x T2 n) /\ (forall m b v1 x GH G1 T2 n, htp m b GH G1 x T2 n -> n < ni -> htp m b GH (v1::G1) x T2 n) /\ (forall GH G1 t T v n, has_type GH G1 t T n -> n < ni -> has_type GH (v::G1) t T n). Proof. intros n. induction n. repeat split; intros; omega. repeat split; intros; inversion H. (* stp *) - econstructor. eapply closed_extend. eauto. - econstructor. eapply closed_extend. eauto. - econstructor. - econstructor. eapply IHn. eauto. omega. eapply IHn. eauto. omega. - econstructor. eapply IHn. eauto. omega. eapply IHn. eauto. omega. - econstructor. simpl. eauto. - econstructor. admit. (* eapply IHn. eauto. omega. *) - econstructor. eauto. - econstructor. eapply IHn. eauto. omega. - econstructor. eapply index_extend. eauto. eapply IHn. eauto. omega. - econstructor. eapply index_extend. eauto. eapply IHn. eauto. omega. - econstructor. eapply IHn. eauto. omega. - econstructor. eapply IHn. eauto. omega. - econstructor. eapply IHn. eauto. omega. eauto. eapply closed_extend. eauto. eapply closed_extend. eauto. - eapply stp2_bindx. eapply IHn. eauto. omega. eauto. eauto. eapply closed_extend. eauto. eapply closed_extend. eauto. - econstructor. eapply IHn. eauto. omega. - eapply stp2_transf. eapply IHn. eauto. omega. eapply IHn. eauto. omega. (* vtp *) - econstructor. simpl. eauto. - econstructor. eapply index_extend. eauto. - econstructor. eapply index_extend. eauto. eapply IHn. eauto. omega. eapply IHn. eauto. omega. - econstructor. eapply index_extend. eauto. eapply IHn. eauto. omega. eapply IHn. eauto. omega. eapply IHn. eauto. omega. - econstructor. eapply IHn. eauto. omega. eapply closed_extend. eauto. - econstructor. eapply index_extend. eauto. eapply IHn. eauto. omega. (* htp *) - econstructor. eauto. eapply closed_extend. eauto. - eapply htp_bind. eapply IHn. eauto. omega. eapply closed_extend. eauto. - eapply htp_sub. eapply IHn. eauto. omega. eapply IHn. eauto. omega. eauto. eauto. (* has_type *) - admit. (* econstructor. eapply IHn. eauto. omega. *) - econstructor. eauto. - econstructor. eapply closed_extend. eauto. - econstructor. eapply IHn. eauto. omega. eapply closed_extend. eauto. eapply closed_extend. eauto. - econstructor. eapply IHn. eauto. omega. eapply IHn. eauto. omega. - econstructor. eapply IHn. eauto. omega. eapply IHn. eauto. omega. Qed. Lemma closed_upgrade_gh: forall i i1 j k T1, closed i j k T1 -> i <= i1 -> closed i1 j k T1. Proof. intros. generalize dependent i1. induction H; intros; econstructor; eauto. omega. Qed. Lemma closed_upgrade: forall i j k k1 T1, closed i j k T1 -> k <= k1 -> closed i j k1 T1. Proof. intros. generalize dependent k1. induction H; intros; econstructor; eauto. omega. eapply IHclosed. omega. Qed. Lemma closed_open: forall j k n b V T, closed k n (j+1) T -> closed k n j (TVar b V) -> closed k n j (open j (TVar b V) T). Proof. intros. generalize dependent j. induction T; intros; inversion H; try econstructor; try eapply IHT1; eauto; try eapply IHT2; eauto; try eapply IHT; eauto. - Case "TVarB". simpl. case_eq (beq_nat j i); intros E. eauto. econstructor. eapply beq_nat_false_iff in E. omega. - eapply closed_upgrade; eauto. Qed. Lemma all_closed: forall ni, (forall m b GH G1 T1 T2 n, stp2 m b GH G1 T1 T2 n -> n < ni -> closed (length GH) (length G1) 0 T1) /\ (forall m b GH G1 T1 T2 n, stp2 m b GH G1 T1 T2 n -> n < ni -> closed (length GH) (length G1) 0 T2) /\ (forall m x G1 T2 n, vtp m G1 x T2 n -> n < ni -> x < length G1) /\ (forall m x G1 T2 n, vtp m G1 x T2 n -> n < ni -> closed 0 (length G1) 0 T2) /\ (forall m b x GH G1 T2 n, htp m b GH G1 x T2 n -> n < ni -> x < length GH) /\ (forall m b x GH G1 T2 n, htp m b GH G1 x T2 n -> n < ni -> closed (length GH) (length G1) 0 T2) /\ (forall GH G1 t T n, has_type GH G1 t T n -> n < ni -> closed (length GH) (length G1) 0 T). Proof. intros n. induction n. repeat split; intros; omega. repeat split; intros; inversion H; destruct IHn as [IHS1 [IHS2 [IHV1 [IHV2 [IHH1 [IHH2 IHT]]]]]]. (* stp left *) - econstructor. - eauto. - econstructor. - econstructor. eapply IHS2. eauto. omega. eapply IHS1. eauto. omega. - econstructor. eapply IHS2. eauto. omega. eapply IHS1. eauto. omega. - econstructor. simpl. eauto. - econstructor. admit. (* eauto. eapply IHV1. eauto. omega. *) - econstructor. eauto. - econstructor. eapply IHH1. eauto. omega. - econstructor. econstructor. eapply index_max. eauto. - eapply closed_upgrade_gh. eapply IHS1. eapply H2. omega. simpl. omega. - econstructor. econstructor. eapply IHH1. eauto. omega. - eapply closed_upgrade_gh. eapply IHH2 in H1. inversion H1. eauto. omega. simpl. omega. - econstructor. eauto. - econstructor. eauto. - eapply IHS1. eauto. omega. - eapply IHS1. eauto. omega. (* stp right *) - eauto. - econstructor. - econstructor. - econstructor. eapply IHS1. eauto. omega. eapply IHS2. eauto. omega. - econstructor. eapply IHS1. eauto. omega. eapply IHS2. eauto. omega. - econstructor. simpl. eauto. - admit. (* eapply closed_upgrade_gh. eapply IHV2. eauto. omega. omega. *) - econstructor. eauto. - eapply IHH2. eauto. omega. - eapply closed_upgrade_gh. eapply IHS2. eapply H2. omega. simpl. omega. - econstructor. econstructor. eapply index_max. eauto. - eapply closed_upgrade_gh. eapply IHH2 in H1. inversion H1. eauto. omega. simpl. omega. - econstructor. econstructor. eapply IHH1. eauto. omega. - eauto. - econstructor. eauto. - eapply IHS2. eauto. omega. - eapply IHS2. eauto. omega. (* vtp left *) - eauto. - eapply index_max. eauto. - eapply index_max. eauto. - eapply index_max. eauto. - eapply IHV1. eauto. omega. - eapply IHV1. eauto. omega. (* vtp right *) - econstructor. - econstructor. - change 0 with (length ([]:tenv)) at 1. econstructor. eapply IHS1. eauto. omega. eapply IHS2. eauto. omega. - change 0 with (length ([]:tenv)) at 1. econstructor. eapply IHS1. eauto. omega. eapply IHS2. eauto. omega. - econstructor. eauto. (* eapply IHV2 in H1. eauto. omega. *) - econstructor. econstructor. eapply index_max. eauto. (* htp left *) - eapply index_max. eauto. - eapply IHH1. eauto. omega. - eapply IHH1. eauto. omega. (* htp right *) - eauto. - eapply IHH1 in H1. eapply closed_open. simpl. eapply closed_upgrade_gh. eauto. omega. econstructor. eauto. omega. - eapply closed_upgrade_gh. eapply IHS2. eauto. omega. rewrite H4. rewrite app_length. omega. (* has_type *) - econstructor. eauto. - econstructor. eauto. - econstructor. eauto. eauto. - econstructor. eauto. eauto. - eapply IHT in H1. inversion H1. eauto. omega. - eapply IHS2. eauto. omega. Qed. Lemma vtp_extend : forall m v1 x G1 T2 n, vtp m G1 x T2 n -> vtp m (v1::G1) x T2 n. Proof. intros. eapply all_extend. eauto. eauto. Qed. Lemma htp_extend : forall m b v1 x GH G1 T2 n, htp m b GH G1 x T2 n -> htp m b GH (v1::G1) x T2 n. Proof. intros. eapply all_extend. eauto. eauto. Qed. Lemma stp2_extend : forall m b GH v1 G1 T1 T2 n, stp2 m b GH G1 T1 T2 n -> stp2 m b GH (v1::G1) T1 T2 n. Proof. intros. eapply all_extend. eauto. eauto. Qed. Lemma stp2_extend_mult : forall m b GH G1 G' T1 T2 n, stp2 m b GH G1 T1 T2 n -> stp2 m b GH (G'++G1) T1 T2 n. Proof. intros. induction G'. simpl. eauto. simpl. eapply stp2_extend. eauto. Qed. Lemma has_type_extend: forall GH G1 t T v n1, has_type GH G1 t T n1 -> has_type GH (v::G1) t T n1. Proof. intros. eapply all_extend. eauto. eauto. Qed. Lemma has_type_extend_mult: forall GH G1 t T G' n1, has_type GH G1 t T n1 -> has_type GH (G'++G1) t T n1. Proof. intros. induction G'. simpl. eauto. simpl. eapply has_type_extend. eauto. Qed. Lemma vtp_closed: forall m G1 x T2 n1, vtp m G1 x T2 n1 -> closed 0 (length G1) 0 T2. Proof. intros. eapply all_closed. eauto. eauto. Qed. Lemma vtp2_closed: forall G1 x T2 n1, vtp2 G1 x T2 n1 -> closed 0 (length G1) 0 T2. Proof. admit. (* intros. eapply all_closed. eauto. eauto. *) Qed. Lemma vtp_closed1: forall m G1 x T2 n1, vtp m G1 x T2 n1 -> x < length G1. Proof. intros. eapply all_closed. eauto. eauto. Qed. Lemma vtp2_closed1: forall G1 x T2 n1, vtp2 G1 x T2 n1 -> x < length G1. Proof. intros. induction H; eauto. eapply vtp_closed1. eauto. Qed. Lemma has_type_closed: forall GH G1 t T n1, has_type GH G1 t T n1 -> closed (length GH) (length G1) 0 T. Proof. intros. eapply all_closed. eauto. eauto. Qed. Lemma stp2_closed1 : forall m b GH G1 T1 T2 n1, stp2 m b GH G1 T1 T2 n1 -> closed (length GH) (length G1) 0 T1. Proof. intros. edestruct all_closed. eapply H0. eauto. eauto. Qed. Lemma stp2_closed2 : forall m b GH G1 T1 T2 n1, stp2 m b GH G1 T1 T2 n1 -> closed (length GH) (length G1) 0 T2. Proof. intros. edestruct all_closed. destruct H1. eapply H1. eauto. eauto. Qed. Lemma stpd2_closed1 : forall m b GH G1 T1 T2, stpd2 m b GH G1 T1 T2 -> closed (length GH) (length G1) 0 T1. Proof. intros. eu. eapply stp2_closed1. eauto. Qed. Lemma stpd2_closed2 : forall m b GH G1 T1 T2, stpd2 m b GH G1 T1 T2 -> closed (length GH) (length G1) 0 T2. Proof. intros. eu. eapply stp2_closed2. eauto. Qed. Lemma beq_nat_true_eq: forall A, beq_nat A A = true. Proof. intros. eapply beq_nat_true_iff. eauto. Qed. Lemma stpd2_refl: forall m GH G1 T1, closed (length GH) (length G1) 0 T1 -> stpd2 m true GH G1 T1 T1. Proof. intros. induction T1; inversion H. - Case "bot". exists 1. eauto. - Case "top". exists 1. eauto. - Case "bool". eapply stpd2_bool; eauto. - Case "fun". eapply stpd2_fun; try eapply stpd2_wrapf; eauto. - Case "mem". eapply stpd2_mem; try eapply stpd2_wrapf; eauto. - Case "var0". exists 1. eauto. - Case "var1". assert (exists v, index i G1 = Some v) as E. eapply index_exists; eauto. destruct E. eexists. eapply stp2_varx; eauto. - Case "varb". inversion H4. - Case "sel". admit. (* sel-sel ? *) - Case "bind". eexists. eapply stp2_bindx. eapply htp_var. simpl. rewrite beq_nat_true_eq. eauto. instantiate (1:=open 0 (TVar false (length GH)) T1). eapply closed_open. simpl. eapply closed_upgrade_gh. eauto. omega. econstructor. simpl. omega. eauto. eauto. eauto. eauto. Grab Existential Variables. apply 0. apply 0. Qed. Lemma stpd2_reg1 : forall m b GH G1 T1 T2, stpd2 m b GH G1 T1 T2 -> stpd2 m true GH G1 T1 T1. Proof. intros. eapply stpd2_refl. eapply stpd2_closed1. eauto. Qed. Lemma stpd2_reg2 : forall m b GH G1 T1 T2, stpd2 m b GH G1 T1 T2 -> stpd2 m true GH G1 T2 T2. Proof. intros. eapply stpd2_refl. eapply stpd2_closed2. eauto. Qed. Ltac index_subst := match goal with | H1: index ?x ?G = ?V1 , H2: index ?x ?G = ?V2 |- _ => rewrite H1 in H2; inversion H2; subst | _ => idtac end. Ltac invty := match goal with | H1: TBot = _ |- _ => inversion H1 | H1: TBool = _ |- _ => inversion H1 | H1: TSel _ = _ |- _ => inversion H1 | H1: TMem _ _ = _ |- _ => inversion H1 | H1: TVar _ _ = _ |- _ => inversion H1 | H1: TFun _ _ = _ |- _ => inversion H1 | H1: TBind _ = _ |- _ => inversion H1 | _ => idtac end. Ltac invstp_var := match goal with | H1: stp2 _ true _ _ TBot (TVar _ _) _ |- _ => inversion H1 | H1: stp2 _ true _ _ TTop (TVar _ _) _ |- _ => inversion H1 | H1: stp2 _ true _ _ TBool (TVar _ _) _ |- _ => inversion H1 | H1: stp2 _ true _ _ (TFun _ _) (TVar _ _) _ |- _ => inversion H1 | H1: stp2 _ true _ _ (TMem _ _) (TVar _ _) _ |- _ => inversion H1 | _ => idtac end. Definition substt x T := (subst (TVar true x) T). Hint Immediate substt. Lemma closed_no_open: forall T x k l j, closed l k j T -> T = open j (TVar false x) T. Proof. intros. induction H; intros; eauto; try solve [compute; compute in IHclosed; rewrite <-IHclosed; auto]; try solve [compute; compute in IHclosed1; compute in IHclosed2; rewrite <-IHclosed1; rewrite <-IHclosed2; auto]. Case "TSelB". simpl. assert (k <> x0). omega. apply beq_nat_false_iff in H0. rewrite H0. auto. Qed. Lemma closed_no_subst: forall T j k TX, closed 0 j k T -> subst TX T = T. Proof. intros T. induction T; intros; inversion H; simpl; eauto; try rewrite (IHT j (S k) TX); eauto; (* try rewrite (IHT2 (S j) TX); eauto; *) try rewrite (IHT j k TX); eauto; try rewrite (IHT1 j k TX); eauto; try rewrite (IHT2 j k TX); eauto. subst. inversion H4. eapply closed_upgrade. eauto. eauto. Qed. Lemma closed_subst: forall j n k V T, closed (n+1) k j T -> closed n k 0 V -> closed n k j (subst V T). Proof. intros. generalize dependent j. induction T; intros; inversion H; try econstructor; try eapply IHT1; eauto; try eapply IHT2; eauto; try eapply IHT; eauto. - Case "TSelH". simpl. case_eq (beq_nat i 0); intros E. eapply closed_upgrade. eapply closed_upgrade_gh. eauto. eauto. omega. econstructor. subst. assert (i > 0). eapply beq_nat_false_iff in E. omega. omega. Qed. (* not used? *) Lemma subst_open_commute_m: forall j k n m V T2, closed (n+1) k (j+1) T2 -> closed m k 0 V -> subst V (open j (TVar false (n+1)) T2) = open j (TVar false n) (subst V T2). Proof. intros. generalize dependent j. generalize dependent n. induction T2; intros; inversion H; simpl; eauto; try rewrite IHT2_1; try rewrite IHT2_2; try rewrite IHT2; eauto. simpl. case_eq (beq_nat i 0); intros E. eapply closed_no_open. eapply closed_upgrade. eauto. omega. simpl. eauto. simpl. case_eq (beq_nat j i); intros E. simpl. case_eq (beq_nat (n+1) 0); intros E2. eapply beq_nat_true_iff in E2. omega. assert (n+1-1 = n) as A. omega. rewrite A. eauto. eauto. Qed. (* not used? *) Lemma subst_open_commute: forall j k n V T2, closed (n+1) k (j+1) T2 -> closed 0 k 0 V -> subst V (open j (TVar false (n+1)) T2) = open j (TVar false n) (subst V T2). Proof. intros. eapply subst_open_commute_m; eauto. Qed. Lemma subst_open_commute0: forall T0 n j TX, closed 0 n (j+1) T0 -> (subst TX (open j (TVar false 0) T0)) = open j TX T0. Proof. intros T0 n. induction T0; intros. eauto. eauto. eauto. simpl. inversion H. rewrite IHT0_1. rewrite IHT0_2. eauto. eauto. eauto. simpl. inversion H. rewrite IHT0_1. rewrite IHT0_2. eauto. eauto. eauto. simpl. inversion H. omega. eauto. simpl. inversion H. subst. destruct i. case_eq (beq_nat j 0); intros E; simpl; eauto. case_eq (beq_nat j (S i)); intros E; simpl; eauto. simpl. inversion H. rewrite IHT0. eauto. eauto. simpl. inversion H. rewrite IHT0. eauto. subst. eauto. Qed. Lemma subst_open_commute1: forall T0 x x0 j, (open j (TVar true x0) (subst (TVar true x) T0)) = (subst (TVar true x) (open j (TVar true x0) T0)). Proof. induction T0; intros. eauto. eauto. eauto. simpl. rewrite IHT0_1. rewrite IHT0_2. eauto. eauto. eauto. simpl. rewrite IHT0_1. rewrite IHT0_2. eauto. eauto. eauto. simpl. destruct b. simpl. eauto. case_eq (beq_nat i 0); intros E. simpl. eauto. simpl. eauto. simpl. case_eq (beq_nat j i); intros E. simpl. eauto. simpl. eauto. simpl. rewrite IHT0. eauto. simpl. rewrite IHT0. eauto. Qed. Lemma subst_closed_id: forall x j k T2, closed 0 j k T2 -> substt x T2 = T2. Proof. intros. eapply closed_no_subst. eauto. Qed. Lemma closed_subst0: forall i j k x T2, closed (i + 1) j k T2 -> x < j -> closed i j k (substt x T2). Proof. intros. eapply closed_subst. eauto. econstructor. eauto. Qed. Lemma closed_subst1: forall i j k x T2, closed i j k T2 -> x < j -> i <> 0 -> closed (i-1) j k (substt x T2). Proof. intros. eapply closed_subst. assert ((i - 1 + 1) = i) as R. omega. rewrite R. eauto. econstructor. eauto. Qed. Lemma index_subst: forall GH TX T0 T3 x, index (length (GH ++ [TX])) (T0 :: GH ++ [TX]) = Some T3 -> index (length GH) (map (substt x) (T0 :: GH)) = Some (substt x T3). Proof. intros GH. induction GH; intros; inversion H. - eauto. - rewrite beq_nat_true_eq in H1. inversion H1. subst. simpl. rewrite map_length. rewrite beq_nat_true_eq. eauto. Qed. Lemma index_subst1: forall GH TX T3 x x0, index x0 (GH ++ [TX]) = Some T3 -> x0 <> 0 -> index (x0-1) (map (substt x) GH) = Some (substt x T3). Proof. intros GH. induction GH; intros; inversion H. - eapply beq_nat_false_iff in H0. rewrite H0 in H2. inversion H2. - simpl. assert (beq_nat (x0 - 1) (length (map (substt x) GH)) = beq_nat x0 (length (GH ++ [TX]))). { case_eq (beq_nat x0 (length (GH ++ [TX]))); intros E. eapply beq_nat_true_iff. rewrite map_length. eapply beq_nat_true_iff in E. subst x0. rewrite app_length. simpl. omega. eapply beq_nat_false_iff. eapply beq_nat_false_iff in E. rewrite app_length in E. simpl in E. rewrite map_length. destruct x0. destruct H0. reflexivity. omega. } rewrite H1. case_eq (beq_nat x0 (length (GH ++ [TX]))); intros E; rewrite E in H2. inversion H2. subst. eauto. eauto. Qed. Lemma index_hit0: forall (GH:tenv) TX T2, index 0 (GH ++ [TX]) = Some T2 -> T2 = TX. Proof. intros GH. induction GH; intros; inversion H. - eauto. - rewrite app_length in H1. simpl in H1. remember (length GH + 1) as L. destruct L. omega. eauto. Qed. Lemma subst_open: forall TX n x j, (substt x (open j (TVar false (n+1)) TX)) = (open j (TVar false n) (substt x TX)). Proof. intros TX. induction TX; intros; eauto. - unfold substt. simpl. unfold substt in IHTX1. unfold substt in IHTX2. erewrite <-IHTX1. erewrite <-IHTX2. eauto. - unfold substt. simpl. unfold substt in IHTX1. unfold substt in IHTX2. erewrite <-IHTX1. erewrite <-IHTX2. eauto. - unfold substt. simpl. destruct b. eauto. case_eq (beq_nat i 0); intros E. eauto. eauto. - unfold substt. simpl. case_eq (beq_nat j i); intros E. simpl. assert (beq_nat (n + 1) 0 = false). eapply beq_nat_false_iff. omega. assert ((n + 1 - 1 = n)). omega. rewrite H. rewrite H0. eauto. eauto. - unfold substt. simpl. unfold substt in IHTX. erewrite <-IHTX. eauto. - unfold substt. simpl. unfold substt in IHTX. erewrite <-IHTX. eauto. Qed. Lemma subst_open3: forall TX0 (GH:tenv) TX x, (substt x (open 0 (TVar false (length (GH ++ [TX]))) TX0)) = (open 0 (TVar false (length GH)) (substt x TX0)). Proof. intros. rewrite app_length. simpl. eapply subst_open. Qed. Lemma subst_open4: forall T0 (GH:tenv) TX x, substt x (open 0 (TVar false (length (GH ++ [TX]))) T0) = open 0 (TVar false (length (map (substt x) GH))) (substt x T0). Proof. intros. rewrite map_length. eapply subst_open3. Qed. Lemma subst_open5: forall (GH:tenv) T0 x xi, xi <> 0 -> substt x (open 0 (TVar false xi) T0) = open 0 (TVar false (xi-1)) (substt x T0). Proof. intros. remember (xi-1) as n. assert (xi=n+1) as R. omega. rewrite R. eapply subst_open. Qed. Lemma gh_match1: forall (GU:tenv) GH GL TX, GH ++ [TX] = GU ++ GL -> length GL > 0 -> exists GL1, GL = GL1 ++ [TX] /\ GH = GU ++ GL1. Proof. intros GU. induction GU; intros. - eexists. simpl in H. eauto. - destruct GH. simpl in H. assert (length [TX] = 1). eauto. rewrite H in H1. simpl in H1. rewrite app_length in H1. omega. destruct (IHGU GH GL TX). simpl in H. inversion H. eauto. eauto. eexists. split. eapply H1. simpl. destruct H1. simpl in H. inversion H. subst. eauto. Qed. Lemma gh_match: forall (GH:tenv) GU GL TX T0, T0 :: GH ++ [TX] = GU ++ GL -> length GL = S (length (GH ++ [TX])) -> GU = [] /\ GL = T0 :: GH ++ [TX]. Proof. intros. edestruct gh_match1. rewrite app_comm_cons in H. eapply H. omega. assert (length (T0 :: GH ++ [TX]) = length (GU ++ GL)). rewrite H. eauto. assert (GU = []). destruct GU. eauto. simpl in H. simpl in H2. rewrite app_length in H2. simpl in H2. rewrite app_length in H2. simpl in H2. rewrite H0 in H2. rewrite app_length in H2. simpl in H2. omega. split. eauto. rewrite H3 in H1. simpl in H1. subst. simpl in H1. eauto. Qed. Lemma sub_env1: forall (GL:tenv) GU GH TX, GH ++ [TX] = GU ++ GL -> length GL = 1 -> GL = [TX]. Proof. intros. destruct GL. inversion H0. destruct GL. eapply app_inj_tail in H. destruct H. subst. eauto. inversion H0. Qed. Lemma app_cons1: forall (G1:venv) v, v::G1 = [v]++G1. Proof. intros. simpl. eauto. Qed. (* NOT SO EASY ... *) (* It seems like we'd need to have z:z.type, which is problematic Lemma htp_bind_admissible: forall m GH G1 x TX n1, (* is it needed given stp2_bind1? *) htp m true GH G1 x (TBind TX) n1 -> htpd m true GH G1 x (open 0 (TVar false x) TX). Proof. intros. assert (closed x (length G1) 1 TX). admit. assert (GL: tenv). admit. assert (length GL = S x). admit. eexists. eapply htp_sub. eapply H. eapply stp2_bind1. eapply htp_sub. eapply htp_var. simpl. rewrite beq_nat_true_eq. eauto. Qed. *) Lemma stp2_subst_narrow0: forall n, forall m2 b GH G1 T1 T2 TX x n2, stp2 m2 b (GH++[TX]) G1 T1 T2 n2 -> x < length G1 -> n2 < n -> (forall (m1 : nat) GH (T3 : ty) (n1 : nat), htp m1 false (GH++[TX]) G1 0 T3 n1 -> n1 < n -> vtpd2 G1 x (substt x T3)) -> stpd2 m2 b (map (substt x) GH) G1 (substt x T1) (substt x T2). Proof. intros n. induction n. intros. omega. intros ? ? ? ? ? ? ? ? ? ? ? ? narrowX. (* helper lemma for htp *) assert (forall ni n2, forall m GH T2 xi, htp m false (GH ++ [TX]) G1 xi T2 n2 -> xi <> 0 -> n2 < ni -> ni < S n -> htpd m false (map (substt x) GH) G1 (xi-1) (substt x T2)) as htp_subst_narrow02. { induction ni. intros. omega. intros. inversion H2. + (* var *) subst. repeat eexists. eapply htp_var. eapply index_subst1. eauto. eauto. rewrite map_length. eauto. eapply closed_subst0. rewrite app_length in H7. eapply H7. eauto. + (* bind *) subst. assert (htpd m false (map (substt x) (GH0)) G1 (xi-1) (substt x (TBind TX0))) as BB. eapply IHni. eapply H6. eauto. omega. omega. rewrite subst_open5. eu. repeat eexists. eapply htp_bind. eauto. eapply closed_subst1. eauto. eauto. eauto. apply []. eauto. + (* sub *) subst. assert (exists GL0, GL = GL0 ++ [TX] /\ GH0 = GU ++ GL0) as A. eapply gh_match1. eauto. omega. destruct A as [GL0 [? ?]]. subst GL. assert (htpd m false (map (substt x) GH0) G1 (xi-1) (substt x T3)) as AA. eapply IHni. eauto. eauto. omega. omega. assert (stpd2 m false (map (substt x) GL0) G1 (substt x T3) (substt x T0)) as BB. eapply IHn. eauto. eauto. omega. { intros. eapply narrowX. eauto. eauto. } eu. eu. repeat eexists. eapply htp_sub. eauto. eauto. (* - *) rewrite map_length. rewrite app_length in H8. simpl in H8. omega. subst GH0. rewrite map_app. eauto. } (* special case *) assert (forall ni n2, forall m T0 T2, htp m false (T0 :: GH ++ [TX]) G1 (length (GH ++ [TX])) T2 n2 -> n2 < ni -> ni < S n -> htpd m false (map (substt x) (T0::GH)) G1 (length GH) (substt x T2)) as htp_subst_narrow0. { intros. rewrite app_comm_cons in H2. remember (T0::GH) as GH1. remember (length (GH ++ [TX])) as xi. rewrite app_length in Heqxi. simpl in Heqxi. assert (length GH = xi-1) as R. omega. rewrite R. eapply htp_subst_narrow02. eauto. omega. eauto. eauto. } (* main logic *) inversion H. - Case "bot". subst. eapply stpd2_bot; eauto. rewrite map_length. simpl. eapply closed_subst0. rewrite app_length in H2. simpl in H2. eapply H2. eauto. - Case "top". subst. eapply stpd2_top; eauto. rewrite map_length. simpl. eapply closed_subst0. rewrite app_length in H2. simpl in H2. eapply H2. eauto. - Case "bool". subst. eapply stpd2_bool; eauto. - Case "fun". subst. eapply stpd2_fun. eapply IHn; eauto. omega. eapply IHn; eauto. omega. - Case "mem". subst. eapply stpd2_mem. eapply IHn; eauto. omega. eapply IHn; eauto. omega. - Case "varx". subst. eexists. eapply stp2_varx. eauto. - Case "var1". subst. assert (substt x T2 = T2) as R. eapply subst_closed_id. eapply vtp2_closed. eauto. eexists. eapply stp2_var1. rewrite R. eauto. - Case "varax". subst. case_eq (beq_nat x0 0); intros E. + (* hit *) assert (x0 = 0). eapply beq_nat_true_iff. eauto. repeat eexists. unfold substt. subst x0. simpl. eapply stp2_varx. eauto. + (* miss *) assert (x0 <> 0). eapply beq_nat_false_iff. eauto. repeat eexists. unfold substt. simpl. rewrite E. eapply stp2_varax. rewrite map_length. rewrite app_length in H2. simpl in H2. omega. - Case "vara1". case_eq (beq_nat x0 0); intros E. + (* hit *) assert (x0 = 0). eapply beq_nat_true_iff. eauto. subst x0. assert (vtpd2 G1 x (substt x T2)). subst. eapply narrowX; eauto. omega. ev. eu. subst. repeat eexists. simpl. eapply stp2_var1. eauto. + (* miss *) assert (x0 <> 0). eapply beq_nat_false_iff. eauto. subst. assert (htpd m2 false (map (substt x) GH) G1 (x0-1) (substt x T2)). eapply htp_subst_narrow02. eauto. eauto. eauto. eauto. eu. repeat eexists. unfold substt at 2. simpl. rewrite E. eapply stp2_vara1. eauto. (* - Case "varab1". case_eq (beq_nat x0 0); intros E. + (* hit *) assert (x0 = 0). eapply beq_nat_true_iff; eauto. assert (exists m0, vtpd m0 G1 x (substt x (TBind T0))). subst. eapply H1; eauto. omega. assert ((subst 0 (TVar true x) T0) = T0) as R. admit. (* closed! *) ev. eu. inversion H11. rewrite R in H16. clear R. subst. repeat eexists. eapply stp2_var1. unfold substt. rewrite subst_open_commute. eauto. + (* miss *) assert (stpd2 m2 true (map (substt x) GH) G1 (substt x (TVar false x0)) (substt x (TBind T0))). eapply IHn; eauto. omega. assert (substt x (TBind T0) = TBind (substt x T0)) as R1. admit. assert (substt x (open 0 (TVar false x0) T0) = open 0 (TVar false x0) (substt x T0)) as R2. admit. assert (substt x (TVar false x0) = (TVar false x0)) as R3. admit. rewrite R2. rewrite R3. eu. repeat eexists. eapply stp2_varab1. rewrite <-R3. rewrite <-R1. eauto. - Case "varab2". case_eq (beq_nat x0 0); intros E. + (* hit *) assert (x0 = 0). eapply beq_nat_true_iff; eauto. subst x0. assert (exists m0, vtpd m0 G1 x (substt x (open 0 (TVar false 0) T0))). subst. eapply H1; eauto. omega. assert ((subst 0 (TVar true x) T0) = T0) as R. admit. (* closed! *) ev. eu. unfold substt in H10. rewrite subst_open_commute in H10. repeat eexists. unfold substt. simpl. eapply stp2_var1. eapply vtp_bind. eauto. rewrite R. eauto. + (* miss *) assert (stpd2 m true (map (substt x) GH) G1 (substt x (TVar false x0)) (substt x (open 0 (TVar false x0) T0))). eapply IHn; eauto. omega. assert (substt x (TBind T0) = TBind (substt x T0)) as R1. admit. assert (substt x (open 0 (TVar false x0) T0) = open 0 (TVar false x0) (substt x T0)) as R2. admit. assert (substt x (TVar false x0) = (TVar false x0)) as R3. admit. rewrite R3. rewrite R1. eu. repeat eexists. eapply stp2_varab2. rewrite R3 in H10. rewrite R2 in H10. eauto. *) - Case "ssel1". subst. assert (substt x T2 = T2) as R. eapply subst_closed_id. eapply stpd2_closed2 with (GH:=[]). eauto. eexists. eapply stp2_strong_sel1. eauto. rewrite R. eauto. - Case "ssel2". subst. assert (substt x T1 = T1) as R. eapply subst_closed_id. eapply stpd2_closed1 with (GH:=[]). eauto. eexists. eapply stp2_strong_sel2. eauto. rewrite R. eauto. - Case "sel1". subst. (* invert htp to vtp and create strong_sel node *) case_eq (beq_nat x0 0); intros E. + assert (x0 = 0). eapply beq_nat_true_iff. eauto. subst x0. assert (vtpd2 G1 x (substt x (TMem TBot T2))) as A. eapply narrowX. eauto. omega. eu. inversion A. inversion H3. repeat eexists. eapply stp2_strong_sel1. eauto. unfold substt. assert (m2=ms) as R. admit. rewrite R. eauto. + assert (x0 <> 0). eapply beq_nat_false_iff. eauto. eapply htp_subst_narrow02 in H2. eu. repeat eexists. unfold substt. simpl. rewrite E. eapply stp2_sel1. eapply H2. eauto. eauto. eauto. - Case "sel2". subst. (* invert htp to vtp and create strong_sel node *) case_eq (beq_nat x0 0); intros E. + assert (x0 = 0). eapply beq_nat_true_iff. eauto. subst x0. assert (vtpd2 G1 x (substt x (TMem T1 TTop))) as A. eapply narrowX. eauto. omega. eu. inversion A. inversion H3. repeat eexists. eapply stp2_strong_sel2. eauto. unfold substt. assert (m2=ms) as R. admit. rewrite R. eauto. + assert (x0 <> 0). eapply beq_nat_false_iff. eauto. eapply htp_subst_narrow02 in H2. eu. repeat eexists. unfold substt. simpl. rewrite E. eapply stp2_sel2. eapply H2. eauto. eauto. eauto. - Case "bind1". assert (htpd m2 false (map (substt x) (T1'::GH)) G1 (length GH) (substt x T2)). eapply htp_subst_narrow0. eauto. eauto. omega. eu. repeat eexists. eapply stp2_bind1. rewrite map_length. eapply H13. simpl. subst T1'. fold subst. eapply subst_open4. fold subst. eapply closed_subst0. rewrite app_length in H4. simpl in H4. rewrite map_length. eauto. eauto. eapply closed_subst0. rewrite map_length. rewrite app_length in H5. simpl in H5. eauto. eauto. - Case "bindx". assert (htpd m2 false (map (substt x) (T1'::GH)) G1 (length GH) (substt x T2')). eapply htp_subst_narrow0. eauto. eauto. omega. eu. repeat eexists. eapply stp2_bindx. rewrite map_length. eapply H14. subst T1'. fold subst. eapply subst_open4. subst T2'. fold subst. eapply subst_open4. rewrite app_length in H5. simpl in H5. eauto. eapply closed_subst0. rewrite map_length. eauto. eauto. rewrite app_length in H6. simpl in H6. eauto. eapply closed_subst0. rewrite map_length. eauto. eauto. - Case "wrapf". assert (stpd2 m2 true (map (substt x) GH) G1 (substt x T1) (substt x T2)). eapply IHn; eauto. omega. eu. repeat eexists. eapply stp2_wrapf. eauto. - Case "transf". assert (stpd2 m false (map (substt x) GH) G1 (substt x T1) (substt x T3)). eapply IHn; eauto. omega. assert (stpd2 m0 false (map (substt x) GH) G1 (substt x T3) (substt x T2)). eapply IHn; eauto. omega. eu. eu. repeat eexists. eapply stp2_transf. eauto. eauto. Grab Existential Variables. apply 0. apply 0. apply 0. apply 0. Qed. Lemma stp2_subst_narrowX: forall ml, forall nl, forall m b m2 GH G1 T2 TX x n1 n2, vtp m G1 x (substt x TX) n1 -> htp m2 b (GH++[TX]) G1 0 T2 n2 -> x < length G1 -> m < ml -> n2 < nl -> (forall (m0 m1 : nat) (b : bool) (G1 : venv) x (T2 T3 : ty) (n1 n2 : nat), vtp m0 G1 x T2 n1 -> stp2 m1 b [] G1 T2 T3 n2 -> m0 <= m -> vtpdd m0 G1 x T3) -> vtpdd m G1 x (substt x T2). (* decrease b/c transitivity *) Proof. intros ml. (* induction ml. intros. omega. *) intros nl. induction nl. intros. omega. intros. inversion H0. - Case "var". subst. assert (T2 = TX). eapply index_hit0. eauto. subst T2. repeat eexists. eauto. eauto. - Case "bind". subst. assert (vtpdd m G1 x (substt x (TBind TX0))) as A. eapply IHnl. eauto. eauto. eauto. eauto. omega. eauto. destruct A as [? [? [A ?]]]. inversion A. subst. repeat eexists. unfold substt. erewrite subst_open_commute0. assert (closed 0 (length G1) 0 (TBind (substt x TX0))). eapply vtp_closed. unfold substt in A. simpl in A. eapply A. assert ((substt x (TX0)) = TX0) as R. eapply subst_closed_id. eauto. unfold substt in R. rewrite R in H9. eapply H9. simpl. eauto. omega. - Case "sub". subst. assert (GL = [TX]). eapply sub_env1; eauto. subst GL. assert (vtpdd m G1 x (substt x T1)) as A. eapply IHnl. eauto. eauto. eauto. eauto. omega. eauto. eu. assert (stpd2 m2 b (map (substt x) []) G1 (substt x T1) (substt x T2)) as B. eapply stp2_subst_narrow0. eauto. eauto. eauto. { intros. eapply IHnl in H. eu. repeat eexists. eapply vtp2_down. eauto. eauto. eauto. eauto. omega. eauto. } simpl in B. eu. assert (vtpdd x0 G1 x (substt x T2)). eapply H4. eauto. eauto. eauto. eu. repeat eexists. eauto. omega. Qed. Lemma stp2_trans: forall l, forall n, forall k, forall m1 m2 b G1 x T2 T3 n1 n2, vtp m1 G1 x T2 n1 -> stp2 m2 b [] G1 T2 T3 n2 -> m1 < l -> n2 < n -> n1 < k -> vtpdd m1 G1 x T3. Proof. intros l. induction l. intros. solve by inversion. intros n. induction n. intros. solve by inversion. intros k. induction k; intros. solve by inversion. destruct b. (* b = true *) { inversion H. - Case "top". inversion H0; subst; invty. + SCase "top". repeat eexists; eauto. + SCase "ssel2". assert (vtpdd m1 G1 x TX). eapply IHn; eauto. omega. eu. repeat eexists. eapply vtp_sel. eauto. eauto. eauto. + SCase "sel2". eapply stp2_closed2 in H0. simpl in H0. inversion H0. inversion H9. omega. - Case "bool". inversion H0; subst; invty. + SCase "top". repeat eexists. eapply vtp_top. eapply index_max. eauto. eauto. + SCase "bool". repeat eexists; eauto. + SCase "ssel2". assert (vtpdd m1 G1 x TX). eapply IHn; eauto. omega. eu. repeat eexists. eapply vtp_sel. eauto. eauto. eauto. + SCase "sel2". eapply stp2_closed2 in H0. simpl in H0. inversion H0. inversion H9. omega. - Case "mem". inversion H0; subst; invty. + SCase "top". repeat eexists. eapply vtp_top. eapply index_max. eauto. eauto. + SCase "mem". invty. subst. repeat eexists. eapply vtp_mem. eauto. eapply stp2_transf. eauto. eapply H5. eapply stp2_transf. eauto. eapply H13. eauto. + SCase "sel2". assert (vtpdd m1 G1 x TX0). eapply IHn; eauto. omega. eu. repeat eexists. eapply vtp_sel. eauto. eauto. eauto. + SCase "sel2". eapply stp2_closed2 in H0. simpl in H0. inversion H0. inversion H11. omega. - Case "fun". inversion H0; subst; invty. + SCase "top". repeat eexists. eapply vtp_top. eapply index_max. eauto. eauto. + SCase "fun". invty. subst. repeat eexists. eapply vtp_fun. eauto. eauto. eapply stp2_transf. eauto. eapply H6. eapply stp2_transf. eauto. eapply H14. eauto. + SCase "sel2". assert (vtpdd m1 G1 x TX). eapply IHn; eauto. omega. eu. repeat eexists. eapply vtp_sel. eauto. eauto. eauto. + SCase "sel2". eapply stp2_closed2 in H0. simpl in H0. inversion H0. inversion H12. omega. - Case "bind". inversion H0; subst; invty. + SCase "top". repeat eexists. eapply vtp_top. eapply vtp_closed1. eauto. eauto. + SCase "sel2". assert (vtpdd (S m) G1 x TX). eapply IHn; eauto. omega. eu. repeat eexists. eapply vtp_sel. eauto. eauto. eauto. + SCase "sel2". eapply stp2_closed2 in H0. simpl in H0. inversion H0. inversion H10. omega. + SCase "bind1". invty. subst. remember (TVar false (length [])) as VZ. remember (TVar true x) as VX. (* left *) assert (vtpd m G1 x (open 0 VX T0)) as LHS. eexists. eassumption. eu. (* right *) assert (substt x (open 0 VZ T0) = (open 0 VX T0)) as R. unfold substt. subst. eapply subst_open_commute0. eauto. assert (substt x T3 = T3) as R1. eapply subst_closed_id. eauto. assert (vtpdd m G1 x (substt x T3)) as BB. { eapply stp2_subst_narrowX. rewrite <-R in LHS. eapply LHS. instantiate (2:=nil). simpl. eapply H11. eapply vtp_closed1. eauto. eauto. eauto. { intros. eapply IHl. eauto. eauto. omega. eauto. eauto. } } rewrite R1 in BB. eu. repeat eexists. eauto. omega. + SCase "bindx". invty. subst. remember (TVar false (length [])) as VZ. remember (TVar true x) as VX. (* left *) assert (vtpd m G1 x (open 0 VX T0)) as LHS. eexists. eassumption. eu. (* right *) assert (substt x (open 0 VZ T0) = (open 0 VX T0)) as R. unfold substt. subst. eapply subst_open_commute0. eauto. assert (vtpdd m G1 x (substt x (open 0 VZ T4))) as BB. { eapply stp2_subst_narrowX. rewrite <-R in LHS. eapply LHS. instantiate (2:=nil). simpl. eapply H11. eapply vtp_closed1. eauto. eauto. eauto. { intros. eapply IHl. eauto. eauto. omega. eauto. eauto. } } unfold substt in BB. subst. erewrite subst_open_commute0 in BB. clear R. eu. repeat eexists. eapply vtp_bind. eauto. eauto. omega. eauto. (* enough slack to add bind back *) - Case "ssel2". subst. inversion H0; subst; invty. + SCase "top". repeat eexists. eapply vtp_top. eapply vtp_closed1. eauto. eauto. + SCase "ssel1". index_subst. eapply IHn. eauto. eauto. eauto. omega. eauto. + SCase "ssel2". assert (vtpdd m1 G1 x TX0). eapply IHn; eauto. omega. eu. repeat eexists. eapply vtp_sel. eauto. eauto. eauto. + SCase "sel1". assert (closed (length ([]:tenv)) (length G1) 0 (TSel (TVar false x0))). eapply stpd2_closed2. eauto. simpl in H7. inversion H7. inversion H12. omega. } (* b = false *) { inversion H0. - Case "wrapf". eapply IHn. eapply H. eauto. eauto. omega. eauto. - Case "transf". subst. assert (vtpdd m1 G1 x T0) as LHS. eapply IHn. eauto. eauto. eauto. omega. eauto. eu. assert (vtpdd x0 G1 x T3) as BB. eapply IHn. eapply LHS. eauto. omega. omega. eauto. eu. repeat eexists. eauto. omega. } Grab Existential Variables. apply 0. apply 0. apply 0. apply 0. apply 0. apply 0. apply 0. Qed. Lemma stp2_trans2: forall n, forall m b G1 T2 T3 x n1 n2, vtp2 G1 x T2 n1 -> stp2 m b [] G1 T2 T3 n2 -> n2 < n -> vtpd2 G1 x T3. Proof. intros n. induction n. intros. omega. intros. inversion H. - Case "self". subst. inversion H0. + SCase "top". subst. eexists. eapply vtp2_down. eapply vtp_top. eauto. + SCase "varx". subst. eexists. eapply vtp2_refl. eauto. + SCase "var1". subst. eexists. eauto. + SCase "ssel2". subst. assert (vtpd2 G1 x TX). eapply IHn; eauto. omega. eu. eexists. eapply vtp2_sel. eauto. eauto. + SCase "sel2". subst. assert (closed (length ([]:tenv)) (length G1) 0 (TVar false x0)) as CL. eapply stpd2_closed1. eauto. simpl in CL. inversion CL. omega. + SCase "wrapf". subst. clear H0. eapply IHn; eauto. omega. + SCase "transf". subst. assert (vtpd2 G1 x T2). eapply IHn; eauto. omega. eu. eapply IHn; eauto. omega. - Case "down". subst. assert (vtpdd m0 G1 x T3). eapply stp2_trans; eauto. eu. eexists. eapply vtp2_down. eauto. - Case "sel". subst. inversion H0. + SCase "top". subst. eexists. eapply vtp2_down. eapply vtp_top. eapply vtp2_closed1. eauto. + SCase "varx". subst. index_subst. eapply IHn. eauto. eauto. omega. + SCase "ssel1". subst. assert (vtpd2 G1 x TX0). eapply IHn. eapply H. eauto. omega. eu. eexists. eapply vtp2_sel. eauto. eauto. + SCase "sel1". subst. assert (closed (length ([]:tenv)) (length G1) 0 (TVar false x0)) as CL. eapply stpd2_closed1. eauto. simpl in CL. inversion CL. omega. + SCase "wrapf". subst. clear H0. eapply IHn; eauto. omega. + SCase "transf". subst. assert (vtpd2 G1 x T2). eapply IHn; eauto. omega. eu. eapply IHn; eauto. omega. Grab Existential Variables. apply 0. apply 0. apply 0. apply 0. apply 0. Qed. Lemma stp2_subst_narrowX2: forall nl, forall b m2 GH G1 T2 TX x n1 n2, vtp2 G1 x (substt x TX) n1 -> htp m2 b (GH++[TX]) G1 0 T2 n2 -> x < length G1 -> n2 < nl -> vtpd2 G1 x (substt x T2). Proof. intros nl. induction nl. intros. omega. intros. inversion H0. - Case "var". subst. assert (T2 = TX). eapply index_hit0. eauto. subst T2. repeat eexists. eauto. - Case "bind". subst. assert (vtpd2 G1 x (substt x (TBind TX0))) as A. eapply IHnl. eauto. eauto. eauto. eauto. omega. eauto. destruct A as [? A]. inversion A. inversion H5. subst. repeat eexists. unfold substt. erewrite subst_open_commute0. assert (closed 0 (length G1) 0 (TBind (substt x TX0))). eapply vtp2_closed. unfold substt in A. simpl in A. eapply A. assert ((substt x (TX0)) = TX0) as R. eapply subst_closed_id. eauto. unfold substt in R. rewrite R in H11. eapply vtp2_down. eapply H11. simpl. eauto. - Case "sub". subst. assert (GL = [TX]). eapply sub_env1; eauto. subst GL. assert (vtpd2 G1 x (substt x T1)) as A. eapply IHnl. eauto. eauto. eauto. eauto. omega. eauto. eu. assert (stpd2 m2 b (map (substt x) []) G1 (substt x T1) (substt x T2)) as B. eapply stp2_subst_narrow0. eauto. eauto. eauto. { intros. eapply IHnl in H. eu. repeat eexists. eauto. eauto. eauto. eauto. omega. } simpl in B. eu. eapply stp2_trans2. eauto. eauto. eauto. Qed. (* TODO: stp_to_stp2 *) (* TODO: specific inversion lemmas *) (* TODO: evaluation semantics / soundness *) (* Reduction semantics *) Fixpoint subst_tm (u:nat) (T : tm) {struct T} : tm := match T with | tvar true i => tvar true i | tvar false i => if beq_nat i 0 then (tvar true u) else tvar false (i-1) | tbool b => tbool b | tmem T => tmem (subst (TVar true u) T) | tabs T1 T2 t => tabs (subst (TVar true u) T1) (subst (TVar true u) T2) (subst_tm u t) (* | TVarB i => TVarB i *) | tapp t1 t2 => tapp (subst_tm u t1) (subst_tm u t2) end. Inductive step : venv -> tm -> venv -> tm -> Prop := | ST_Mem : forall G1 T1, step G1 (tmem T1) (vty T1::G1) (tvar true (length G1)) | ST_Abs : forall G1 T1 T2 t, step G1 (tabs T1 T2 t) (vabs T1 T2 t::G1) (tvar true (length G1)) | ST_AppAbs : forall G1 f x T1 T2 t12, index f G1 = Some (vabs T1 T2 t12) -> step G1 (tapp (tvar true f) (tvar true x)) G1 (subst_tm x t12) | ST_App1 : forall G1 G1' t1 t1' t2, step G1 t1 G1' t1' -> step G1 (tapp t1 t2) G1' (tapp t1' t2) | ST_App2 : forall G1 G1' f t2 t2', step G1 t2 G1' t2' -> step G1 (tapp (tvar true f) t2) G1' (tapp (tvar true f) t2') . Lemma hastp_inv: forall G1 x T n1, has_type [] G1 (tvar true x) T n1 -> vtpd2 G1 x T. Proof. intros. remember [] as GH. remember (tvar true x) as t. induction H; subst; try inversion Heqt. - Case "varx". subst. exists 1. eapply vtp2_refl. eauto. - Case "sub". destruct IHhas_type. eauto. eauto. ev. eapply stp2_trans2; eauto. Qed. Lemma hastp_subst: forall G1 GH TX T x t n1 n2, has_type (GH++[TX]) G1 t T n2 -> vtp2 G1 x TX n1 -> exists n3, has_type (map (substt x) GH) G1 (subst_tm x t) (substt x T) n3. Proof. intros. remember (GH++[TX]) as GH0. revert GH HeqGH0. induction H; intros. - Case "varx". simpl. eexists. eapply T_Varx. eauto. - Case "vary". subst. simpl. case_eq (beq_nat x0 0); intros E. + assert (x0 = 0). eapply beq_nat_true_iff; eauto. subst x0. exists 1. eapply T_Varx. eapply vtp2_closed1. eauto. + assert (x0 <> 0). eapply beq_nat_false_iff; eauto. exists 1. unfold substt. simpl. rewrite E. eapply T_Vary. rewrite map_length. rewrite app_length in H. simpl in H. omega. - Case "mem". subst. simpl. eexists. eapply T_Mem. eapply closed_subst0. rewrite app_length in H. rewrite map_length. eauto. eapply vtp2_closed1. eauto. - Case "abs". subst. simpl. assert (has_typed (map (substt x) (T11::GH0)) G1 (subst_tm x t12) (substt x T12)) as HI. eapply IHhas_type. eauto. eauto. eu. simpl in HI. eexists. eapply T_Abs. eapply HI. eapply closed_subst0. rewrite map_length. rewrite app_length in H1. simpl in H1. eauto. eauto. eapply vtp2_closed1. eauto. eapply closed_subst0. rewrite map_length. rewrite app_length in H2. simpl in H2. eauto. eapply vtp2_closed1. eauto. - Case "app". edestruct IHhas_type1. eauto. eauto. edestruct IHhas_type2. eauto. eauto. eexists. eapply T_App. eapply H2. eapply H3. - Case "sub". subst. edestruct stp2_subst_narrow0. eapply H1. eapply vtp2_closed1. eauto. eauto. { intros. edestruct stp2_subst_narrowX2. erewrite subst_closed_id. eapply H0. eapply vtp2_closed. eauto. eauto. eapply vtp2_closed1. eauto. eauto. eexists. eauto. } edestruct IHhas_type. eauto. eauto. eexists. eapply T_Sub. eauto. eauto. Grab Existential Variables. apply 0. apply 0. Qed. Theorem type_safety : forall G t T n1, has_type [] G t T n1 -> (exists x, t = tvar true x) \/ (exists G' t' n2, step G t (G'++G) t' /\ has_type [] (G'++G) t' T n2). Proof. intros. assert (closed (length ([]:tenv)) (length G) 0 T) as CL. eapply has_type_closed. eauto. remember [] as GH. remember t as tt. remember T as TT. revert T t HeqTT HeqGH Heqtt CL. induction H; intros. - Case "varx". eauto. - Case "vary". subst GH. inversion H. - Case "mem". right. assert (stpd2 0 true [] (vty T11::G1) T11 T11). eapply stpd2_refl. subst. eapply closed_extend. eauto. eu. repeat eexists. rewrite <-app_cons1. eapply ST_Mem. eapply T_Sub. eapply T_Varx. eauto. eapply stp2_wrapf. eapply stp2_var1. eapply vtp2_down. eapply vtp_mem. simpl. rewrite beq_nat_true_eq. eauto. eauto. eauto. - Case "abs". right. inversion CL. assert (stpd2 0 true [] (vabs T11 T12 t12::G1) T11 T11). eapply stpd2_refl. subst. eapply closed_extend. eauto. assert (stpd2 0 true [] (vabs T11 T12 t12::G1) T12 T12). eapply stpd2_refl. subst. eapply closed_extend. eauto. eu. eu. repeat eexists. rewrite <-app_cons1. eapply ST_Abs. eapply T_Sub. eapply T_Varx. eauto. eapply stp2_wrapf. eapply stp2_var1. eapply vtp2_down. eapply vtp_fun. simpl. rewrite beq_nat_true_eq. eauto. subst. eapply has_type_extend. eauto. eauto. eauto. - Case "app". subst. assert (closed (length ([]:tenv)) (length G1) 0 (TFun T1 T)) as TF. eapply has_type_closed. eauto. assert ((exists x : id, t2 = tvar true x) \/ (exists (G' : venv) (t' : tm) n2, step G1 t2 (G'++G1) t' /\ has_type [] (G'++G1) t' T1 n2)) as HX. eapply IHhas_type2. eauto. eauto. eauto. inversion TF. eauto. assert ((exists x : id, t1 = tvar true x) \/ (exists (G' : venv) (t' : tm) n2, step G1 t1 (G'++G1) t' /\ has_type [] (G'++G1) t' (TFun T1 T) n2)) as HF. eapply IHhas_type1. eauto. eauto. eauto. eauto. destruct HF. + SCase "fun-val". destruct HX. * SSCase "arg-val". ev. ev. subst. assert (vtpd2 G1 x (TFun T1 T)). eapply hastp_inv. eauto. assert (vtpd2 G1 x0 T1). eapply hastp_inv. eauto. eu. eu. inversion H1. inversion H3. subst. assert (vtpd2 G1 x0 T2). eapply stp2_trans2. eauto. eauto. eauto. eauto. eauto. eu. assert (has_typed (map (substt x0) []) G1 (subst_tm x0 t) (substt x0 T3)) as HI. eapply hastp_subst; eauto. eu. simpl in HI. erewrite subst_closed_id in HI. right. repeat eexists. rewrite app_nil_l. eapply ST_AppAbs. eauto. eapply T_Sub. eauto. eauto. change 0 with (length ([]:tenv)). eapply stpd2_closed1. eauto. * SSCase "arg_step". ev. subst. right. repeat eexists. eapply ST_App2. eauto. eapply T_App. eapply has_type_extend_mult. eauto. eauto. + SCase "fun_step". ev. subst. right. repeat eexists. eapply ST_App1. eauto. eapply T_App. eauto. eapply has_type_extend_mult. eauto. - Case "sub". subst. assert ((exists x : id, t0 = tvar true x) \/ (exists (G' : venv) (t' : tm) n2, step G1 t0 (G'++G1) t' /\ has_type [] (G'++G1) t' T1 n2)) as HH. eapply IHhas_type; eauto. change 0 with (length ([]:tenv)) at 1. eapply stpd2_closed1; eauto. destruct HH. + SCase "val". ev. subst. left. eexists. eauto. + SCase "step". ev. subst. right. repeat eexists. eauto. eapply T_Sub. eauto. eapply stp2_extend_mult. eauto. Grab Existential Variables. apply 0. apply 0. apply 0. apply 0. apply 0. apply 0. Qed. End STLC.
module Calibration using Distributions function monteCarlo(paramSpace;samples=100000) params = Dict{Symbol,Array}() keyList = collect(keys(paramSpace)) for k in keyList p = paramSpace[k] minV = p[:lower] maxV = p[:upper] params[k] = collect(rand(Uniform(minV,maxV), samples)) end return params end function latinHypercube(func,forcing,obs,param_bounds;samples=10000) end # end module end
USE VHCALL_FORTRAN INTEGER(8) :: HANDLE INTEGER(8) :: SYM INTEGER(8) :: CA INTEGER(8) :: RETVAL INTEGER :: IR REAL :: VAL(5) = (/ 1.0,2.0,3.0,4.0,5.0 /) HANDLE = FVHCALL_INSTALL('./libvhcall.so') ! Case of subroutine SYM = FVHCALL_FIND(HANDLE,'VH_SBR') CA = FVHCALL_ARGS_ALLOC() IR = FVHCALL_ARGS_SET(CA, FVHCALL_INTENT_INOUT, 1, VAL) IR = FVHCALL_ARGS_SET(CA, FVHCALL_INTENT_IN, 2, SIZE(VAL)) WRITE(*,*)"VH subroutine INPUT > ",VAL IR = FVHCALL_INVOKE_WITH_ARGS(SYM, CA) IF (IR==1) THEN WRITE(*,*)"Fail to invoke subroutine" STOP(1) ENDIF WRITE(*,*)"VH subroutine OUTPUT> ",VAL ! Case of function SYM = FVHCALL_FIND(HANDLE,'VH_MOD::VH_FUNC') CALL FVHCALL_ARGS_CLEAR(CA) IR = FVHCALL_INVOKE_WITH_ARGS(SYM, CA, RETVAL) IF (IR==1) THEN WRITE(*,*)"Fail to invoke function" STOP(1) ENDIF WRITE(*,*)"VH function return ",RETVAL CALL FVHCALL_ARGS_FREE(CA) IR = FVHCALL_UNINSTALL(HANDLE) STOP END
lemma space_Sup_eq_UN: "space (Sup M) = (\<Union>x\<in>M. space x)"
Formal statement is: lemma sets_eq_bot: "sets M = {{}} \<longleftrightarrow> M = bot" Informal statement is: The sets of a measure space $M$ are empty if and only if $M$ is the trivial measure space.
-- Monotonía de la multiplicación por no negativo -- ============================================== -- Demostrar que si a, b y c son números reales tales que -- 0 ≤ c y a ≤ b, entonces a*c ≤ b*c. import data.real.basic variables {a b c : ℝ} -- 1ª demostración example (hc : 0 ≤ c) (hab : a ≤ b) : a * c ≤ b * c := begin rw ← sub_nonneg, have h : b * c - a * c = (b - a) * c, { ring, }, { rw h, apply mul_nonneg, { rw sub_nonneg, exact hab, }, { exact hc, }}, end -- 2ª demostración example (hc : 0 ≤ c) (hab : a ≤ b) : a * c ≤ b * c := begin have hab' : 0 ≤ b - a, { rw ← sub_nonneg at hab, exact hab, }, have h1 : 0 ≤ (b - a) * c, { exact mul_nonneg hab' hc, }, have h2 : (b - a) * c = b * c - a * c, { ring, }, have h3 : 0 ≤ b * c - a * c, { rw h2 at h1, exact h1, }, rw sub_nonneg at h3, exact h3, end -- 3ª demostración example (hc : 0 ≤ c) (hab : a ≤ b) : a * c ≤ b * c := begin have hab' : 0 ≤ b - a, { rwa ← sub_nonneg at hab, }, have h1 : 0 ≤ (b - a) * c, { exact mul_nonneg hab' hc, }, have h2 : (b - a) * c = b * c - a * c, { ring, }, have h3 : 0 ≤ b * c - a * c, { rwa h2 at h1, }, rwa sub_nonneg at h3, end -- 4ª demostración example (hc : 0 ≤ c) (hab : a ≤ b) : a * c ≤ b * c := begin rw ← sub_nonneg, calc 0 ≤ (b - a)*c : mul_nonneg (by rwa sub_nonneg) hc ... = b*c - a*c : by ring, end -- 5ª demostración example (hc : 0 ≤ c) (hab : a ≤ b) : a * c ≤ b * c := mul_mono_nonneg hc hab -- 6ª demostración example (hc : 0 ≤ c) (hab : a ≤ b) : a * c ≤ b * c := by nlinarith
using ConvOptDL using Test using StatsBase @testset "data_loader.jl" begin dloader = FewShotDataLoader("./test_data.jls") meta_sample = sample(dloader, 2) @test size(meta_sample) == 2 end
module Minecraft.Base.PreClassic.GrassBlock.Export import public Minecraft.Base.PreClassic.GrassBlock.Block.Export import public Minecraft.Base.PreClassic.GrassBlock.Item.Export import public Minecraft.Base.PreClassic.GrassBlock.ItemEntity.Export %default total
\section{Peripherals} In this section are detailed informations about all peripherals. All MARK-II peripherals are memory mapped. Some peripherals can not be configured (such as PLL) and they are not listed here.
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. * Author(s): Vincent Rouvreau * * Copyright (C) 2020 Inria * * Modification(s): * - YYYY/MM Author: Description of the modification */ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE "zero_weighted_alpha_complex" #include <boost/test/unit_test.hpp> #include <boost/mpl/list.hpp> #include <CGAL/Epeck_d.h> #include <vector> #include <random> #include <cmath> // for std::fabs #include <gudhi/Alpha_complex.h> #include <gudhi/Simplex_tree.h> #include <gudhi/Unitary_tests_utils.h> using list_of_exact_kernel_variants = boost::mpl::list<CGAL::Epeck_d< CGAL::Dynamic_dimension_tag >, CGAL::Epeck_d< CGAL::Dimension_tag<4> > > ; BOOST_AUTO_TEST_CASE_TEMPLATE(Zero_weighted_alpha_complex, Kernel, list_of_exact_kernel_variants) { // Check that in exact mode for static dimension 4 the code for dD unweighted and for dD weighted with all weights // 0 give exactly the same simplex tree (simplices and filtration values). // Random points construction using Point_d = typename Kernel::Point_d; std::vector<Point_d> points; std::uniform_real_distribution<double> rd_pts(-10., 10.); std::random_device rand_dev; std::mt19937 rand_engine(rand_dev()); for (int idx = 0; idx < 20; idx++) { std::vector<double> point {rd_pts(rand_engine), rd_pts(rand_engine), rd_pts(rand_engine), rd_pts(rand_engine)}; points.emplace_back(point.begin(), point.end()); } // Alpha complex from points Gudhi::alpha_complex::Alpha_complex<Kernel, false> alpha_complex_from_points(points); Gudhi::Simplex_tree<> simplex; Gudhi::Simplex_tree<>::Filtration_value infty = std::numeric_limits<Gudhi::Simplex_tree<>::Filtration_value>::infinity(); BOOST_CHECK(alpha_complex_from_points.create_complex(simplex, infty, true)); std::clog << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl; for (auto f_simplex : simplex.filtration_simplex_range()) { std::clog << " ( "; for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { std::clog << vertex << " "; } std::clog << ") -> " << "[" << simplex.filtration(f_simplex) << "] " << std::endl; } // Alpha complex from zero weighted points std::vector<typename Kernel::FT> weights(20, 0.); Gudhi::alpha_complex::Alpha_complex<Kernel, true> alpha_complex_from_zero_weighted_points(points, weights); Gudhi::Simplex_tree<> zw_simplex; BOOST_CHECK(alpha_complex_from_zero_weighted_points.create_complex(zw_simplex, infty, true)); std::clog << "Iterator on zero weighted alpha complex simplices in the filtration order, with [filtration value]:" << std::endl; for (auto f_simplex : zw_simplex.filtration_simplex_range()) { std::clog << " ( "; for (auto vertex : zw_simplex.simplex_vertex_range(f_simplex)) { std::clog << vertex << " "; } std::clog << ") -> " << "[" << zw_simplex.filtration(f_simplex) << "] " << std::endl; } BOOST_CHECK(zw_simplex == simplex); }
The Catechism states : " Human life is sacred because from its beginning it involves the creative action of God and it remains forever in a special relationship with the Creator , who is its sole end . ... no one can under any circumstance claim for himself the right directly to destroy an innocent human being . " Direct and intentional killing of an innocent human is considered a mortal sin . Considered by the Church to be of an even greater gravity is the murder of family members , including " infanticide , fratricide , parricide , the murder of a spouse and procured abortion . "
{-# LANGUAGE TemplateHaskell #-} module NewTTRS.Law where import Control.Lens import Data.Array.Unboxed import Data.List import Data.Monoid import Statistics.Distribution (complCumulative, cumulative) import Statistics.Distribution.Normal (normalDistr) import NewTTRS.Outcome data Law = Law { lawRaw :: !(UArray Int Double) , lawMean, lawStddev :: !Double } data LawUpdate = LawUpdate { playerLaw , opponentLaw :: Law , updateOutcome :: Outcome } -- | Law assigned to unrated players defaultLaw :: Law defaultLaw = normalLaw 1800 450 -- | The list of discrete scores characterized by a law omega :: [Int] omega = [0,10..3600] -- | The parameter used to characterize upset probability. alpha :: Double alpha = 0.0148540595817432 -- | Generate a normalized law from a list of probabilities -- which correspond to the elements of 'omega'. lawFromList :: [Double] -> Law lawFromList xs = Law (listArray (0,360) normalized) mean (sqrt variance) where normalized = fmap (/ sum xs) xs mean = sum [ fromIntegral p * x | (p,x) <- zip omega normalized ] variance = sum [ fromIntegral (p * p) * x | (p,x) <- zip omega normalized ] - mean * mean -- | Find the probability that the score is in the range of -- [i-5,i+5] given a law. lawAt :: Law -> Int -> Double lawAt law i = lawRaw law ! (i `div` 10) {-# INLINE lawAt #-} -- | Probability of an upset given the difference in two ratings. upsetProbability :: Int -> Double upsetProbability d = recip (1 + exp (alpha * fromIntegral d)) -- | Perform a bayesian inference given a player's law, the opponent's law -- and the outcome of the matches between the two. lawUpdate :: Law {- ^ Player's law to be updated -} -> Law {- ^ Opponent's law -} -> Outcome {- ^ Player's outcome against opponent -} -> Law lawUpdate lp lq outcome = lawFromList [ sum [ upsetProbability (q - p) ^ w * upsetProbability (p - q) ^ l * lawAt lq q | q <- omega ] * lawAt lp p | p <- omega ] where w = view outcomeWins outcome l = view outcomeLosses outcome -- | Perform the inverse computation of 'lawUpdate' lawUnupdate :: Law {- ^ Player's law to be updated -} -> Law {- ^ Opponent's law -} -> Outcome {- ^ Player's outcome against opponent -} -> Law lawUnupdate lp lq outcome = lawFromList [ lawAt lp p / sum [ upsetProbability (q - p) ^ w * upsetProbability (p - q) ^ l * lawAt lq q | q <- omega ] | p <- omega ] where w = view outcomeWins outcome l = view outcomeLosses outcome -- | Chance that a player with the first law will defeat a player with the second law chanceToWin :: Law -> Law -> Double chanceToWin lp lq = sum [ upsetProbability (q - p) * lawAt lp p * lawAt lq q | q <- omega , p <- omega ] -- | Generate a discretized normal law given a mean and standard deviation. normalLaw :: Double {- ^ mean -} -> Double {- ^ standard deviation -} -> Law normalLaw mean stddev = lawFromList $ mkNormal 0 3600 mean stddev -- | Generate a discrete approximation of a normal distribution. mkNormal :: Int {- ^ lower bound -} -> Int {- ^ upper bound -} -> Double {- ^ mean -} -> Double {- ^ standard deviation -} -> [Double] mkNormal lo hi mean stddev = [ c (lo + 5) ] ++ [ c (p+10) - c p | p <- [lo+5, lo+15 .. hi - 15]] ++ [ c' (hi - 5) ] where distr = normalDistr mean stddev c = cumulative distr . fromIntegral c' = complCumulative distr . fromIntegral -- | Degrade a law given a certain number of days. When days is -- less than 1, no degrading is done. timeEffect :: Int -> Law -> Law timeEffect days law | days <= 0 = law | otherwise = lawFromList $ sum [ lawAt law x * timeAt y | x <- omega, y <- [-3600,-3590.. -x]] : [ sum [ lawAt law x * timeAt (r - x) | x <- omega ] | r <- omega \\ [0,3600] ] ++ [ sum [lawAt law x * timeAt y | x <- omega, y <- [3600-x,3610-x..3600]] ] where timeArray :: UArray Int Double timeArray = listArray (-360,360) $ mkNormal (-3600) 3600 0 (70 * sqrt (fromIntegral days / 365)) timeAt y = timeArray ! (y `div` 10) -- | Compute a metric of the law used to order players lawScore :: Law -> Double lawScore law = lawMean law - 2 * lawStddev law -- | Return the raw law discrete approximations lawElems :: Law -> [Double] lawElems = elems . lawRaw
{-# OPTIONS --show-implicit #-} module _ where postulate R : Set module ModuleB where module NotRecordB (r : R) where postulate notfieldB : Set open module NotRecBI {{r : R}} = NotRecordB r public record RecordB : Set₁ where field fieldB : Set open module RecBI {{r : RecordB}} = RecordB r public open module ModBA = ModuleB postulate myRecB : RecordB myR : R test₀ : fieldB {{myRecB}} test₀ = {!!} test₁ : ModuleB.RecordB.fieldB myRecB test₁ = {!!} test₂ : notfieldB {{myR}} test₂ = {!!} test₃ : ModuleB.NotRecordB.notfieldB myR test₃ = {!!}
lemma closed_span [iff]: "closed (span s)" for s :: "'a::euclidean_space set"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % a0poster Portrait Poster % LaTeX Template % Version 1.0 (22/06/13) % % The a0poster class was created by: % Gerlinde Kettl and Matthias Weiser ([email protected]) % % This template has been downloaded from: % http://www.LaTeXTemplates.com % % License: % CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %---------------------------------------------------------------------------------------- % PACKAGES AND OTHER DOCUMENT CONFIGURATIONS %---------------------------------------------------------------------------------------- \documentclass[a0,portrait]{a0poster} \usepackage{multicol} % This is so we can have multiple columns of text side-by-side \columnsep=100pt % This is the amount of white space between the columns in the poster \columnseprule=3pt % This is the thickness of the black line between the columns in the poster \usepackage[svgnames]{xcolor} % Specify colors by their 'svgnames', for a full list of all colors available see here: http://www.latextemplates.com/svgnames-colors \usepackage{times} % Use the times font %\usepackage{palatino} % Uncomment to use the Palatino font \usepackage{graphicx} % Required for including images \graphicspath{{figures/}} % Location of the graphics files \usepackage{booktabs} % Top and bottom rules for table \usepackage[font=small,labelfont=bf]{caption} % Required for specifying captions to tables and figures \usepackage{amsfonts, amsmath, amsthm, amssymb} % For math fonts, symbols and environments \usepackage{wrapfig} % Allows wrapping text around tables and figures \usepackage[utf8]{inputenc} \begin{document} %---------------------------------------------------------------------------------------- % POSTER HEADER %---------------------------------------------------------------------------------------- % The header is divided into two boxes: % The first is 75% wide and houses the title, subtitle, names, university/organization and contact information % The second is 25% wide and houses a logo for your university/organization or a photo of you % The widths of these boxes can be easily edited to accommodate your content as you see fit \begin{minipage}[b]{0.723\linewidth} \veryHuge \color{NavyBlue} \textbf{Estimating pooled within-time series variograms with spatially shifted temporal points} \color{Black}\\[2cm]% Title %\Huge\textit{An Exploration of Complexity}\\[2cm] % Subtitle \huge \textbf{Avit Kumar Bhowmik\textsuperscript{1} and Pedro Cabral\textsuperscript{2}}\\[0.5cm] % Author(s) \LARGE \textsuperscript{1}Institute for Environmental Sciences, University of Koblenz-Landau, Germany\\ \LARGE \textsuperscript{2}NOVA Information Management School, Universidade Nova de Lisboa, Portugal\\[0.4cm] % University/organization \Large \texttt{[email protected], https://github.com/AvitBhowmik/SSTP}\\ \end{minipage} % \begin{minipage}[b]{0.277\linewidth} \includegraphics[width=20cm]{logo.png}\\ \end{minipage} \vspace{1cm} % A bit of extra whitespace between the header and poster content %---------------------------------------------------------------------------------------- \begin{multicols}{2} % This is how many columns your poster will be broken into, a portrait poster is generally split into 2 columns %---------------------------------------------------------------------------------------- % ABSTRACT %---------------------------------------------------------------------------------------- %\color{Navy} % Navy color for the abstract %\begin{abstract} %We developed an alternative method, i.e. spatially shifting temporal points (SSTP), for pooled within-time series (PTS) variogram estimation using R open-source software environment. The method spatializes temporal data points by shifting them to arbitrary coordinate clusters, and a PTS variogram is estimated by controlling lower and upper boundaries of spatial-lags. We applied SSTP for PTS variogram estimation of a precipitation index in a data-scarce region. SSTP exhibited higher precision than the available method of averaging semivariances over spatial-lags. %\end{abstract} %---------------------------------------------------------------------------------------- % INTRODUCTION %---------------------------------------------------------------------------------------- \color{SaddleBrown} % SaddleBrown color for the introduction \section*{Introduction} Estimation of pooled within-time series (PTS) variograms is frequently done for geostatistical interpolation in spatially data-scarce regions \cite{wagner_comparison_2012}. The only available averaging empirical variograms (AEV) method averages semivariances that are computed for individual time steps over each spatial-lag within a pooled time series \cite{graler_spatio-temporal_2011}. However, semivariances computed by a few paired comparisons in individual time steps are erratic and hence hamper precision of PTS variogram estimation. Here, we outline an alternative method, i.e. ``spatially shifting temporal points (SSTP)'', for PTS variogram estimation that was developed using R open source software environment. %---------------------------------------------------------------------------------------- % OBJECTIVES %---------------------------------------------------------------------------------------- \color{DarkSlateGray} % DarkSlateGray color for the rest of the content %\section*{Main Objectives} %\begin{enumerate} %\item Lorem ipsum dolor sit amet, consectetur. %\item Nullam at mi nisl. Vestibulum est purus, ultricies cursus volutpat sit amet, vestibulum eu. %\item Praesent tortor libero, vulputate quis elementum a, iaculis. %\item Phasellus a quam mauris, non varius mauris. Fusce tristique, enim tempor varius porta, elit purus commodo velit, pretium mattis ligula nisl nec ante. %\item Ut adipiscing accumsan sapien, sit amet pretium. %\item Estibulum est purus, ultricies cursus volutpat %\item Nullam at mi nisl. Vestibulum est purus, ultricies cursus volutpat sit amet, vestibulum eu. %\item Praesent tortor libero, vulputate quis elementum a, iaculis. %\end{enumerate} %---------------------------------------------------------------------------------------- % MATERIALS AND METHODS %---------------------------------------------------------------------------------------- \section*{Methods} \subsection*{Spatially shifting temporal points} The temporal data point sets were spatialized, i.e. assigned to different coordinate clusters on the same space (Figure 1 and 2). $s$ is a data point location vector with coordinate touples $(x,y)$, $t$ is a time vector, $Z(s,t)$ is the vector for a random process in data point $s$ and year $t$, $||s_{i,t}-s_{j,t}||$ is the spatial-lag for the point pair $s_i$ and $s_j$ in year $t$; $i,j \in 1..n$. We first assigned the points from $t_1$ to its original coordinates $x_{t_1},y_{t_1}$. The coordinates for the the latter years were calculated according to Eq. (1), when $(t_1+1)+4n \leq t<(t_1+1)+4(n+1)$; $n \in N$. \begin{equation} \begin{split} s_{(t_1+1)+4n} = x_{(t_1+1)+4n}+(n+1)d, y_{(t_1+1)+4n} \\ s_{(t_1+1)+4n+1} = x_{(t_1+1)+4n+1}-(n+1)d, y_{(t_1+1)+4n+1} \\ s_{(t_1+1)+4n+2} = x_{(t_1+1)+4n+2}, y_{(t_1+1)+4n+2}+(n+1)d \\ s_{(t_1+1)+4n+3} = x_{(t_1+1)+4n+3}, y_{(t_1+1)+4n+3}-(n+1)d \\ \\ where, d>2(max||s_{i,t}-s_{j,t}||) \end{split} \end{equation} \begin{center} \includegraphics[width=1\linewidth]{Fig_1} \captionof{figure}{\color{Green} Work-flows of spatially shifting temporal points (SSTP), averaging empirical variograms (AEV) and weighted AEV methods.} \end{center} \subsection*{Estimation of pooled within-time series variograms} The empirical variograms were computed by simulatenous comparison of spatially shifted points using the commonly applied Methods of Moments (MoM) \cite{webster_geostatistics_2007}. For the point pair $s_i$ and $s_j$, the pooled semivariance $\gamma ||s_i-s_j||$ was computed by Eq. (2). \begin{equation} \begin{split} \gamma ||s_i-s_j||=\frac{1}{2M||s_i-s_j||}\sum_{i,j}(Z(s_i)-Z(s_j))^2 \\ \\ where, ||s_1-s_2||=min||s_{i,t}-s_{j,t}||; ||s_{n-1}-s_n||=max||s_{i,t}-s{j,t}|| \end{split} \end{equation} We checked for anisotropy and computed the ratio between the major and minor axes ($A:B$) of the anisotropy ellipse and the anisotropy angle ($\phi$). The available variogram models were fitted to the computed semivariances by a weighted least square approach providing $\frac{M||s_i-s_j||}{(s_i-s_j)^2}$ as weights. The nugget, partial sill, and range ($a$) parameters were extracted. Precision of the PTS variogram estimation was evaluated by (i) variogram model-fit (weighted mean of squared error (MSE)) and (ii) cross-validation of a universal kriging (UK) interpolation (root means squared error (RMSE) and Nash-Sutcliffe efficiency (NSE)) using the best-fit models. %\subsection*{Pooling time series} \subsection*{Study area and data} SSTP was applied to the PTS variogram estimation for ``annual total precipitation in hydrological wet days (PRCPTOT)'' in Bangladesh (Figure 2). Currently, 32 rain-gauges report daily precipitation in Bangladesh, classifying the country as data scarce. Moreover, the numbers of data points exhibit an increasing coverage from 8 in 1948 to 32 in 2007, indicating variable lengths of the time-series. PTS variograms were also estimated using the available AEV and weighted AEV (WAEV) (see Figure 1 for details) and the precision statistics were compared with the SSTP estimated variograms. \begin{center} \includegraphics[width=1\linewidth]{Fig_2} \captionof{figure}{\color{Green} PRCPTOT points \& distribution in four representative years (left) and SSTP for 1948-1975 series (right).} \end{center} %We first quantified spatial structure in the data by computing its spatial correlation coefficients along the longitudinal and latitudinal gradients and then applied the Pettitt–Mann–Whitney test to the correlation coefficients to identify changes within a time series. The (sub)time series between the change points were extracted as time series with consistent spatial structure. Next, we checked for the stationarity within the extracted time series by applying the Augmented Dickey-Fuller test. Finally, the time series with consistent spatial structure and stationarity were checked to ensure that the numbers of pooled data points meet the threshold for reliable variogram estimation. %------------------------------------------------ %\subsection*{Mathematical Section} %Nulla vel nisl sed mauris auctor mollis non sed. %\begin{equation} %E = mc^{2} %\label{eqn:Einstein} %\end{equation} %Curabitur mi sem, pulvinar quis aliquam rutrum. (1) edf (2) %, $\Omega=[-1,1]^3$, maecenas leo est, ornare at. $z=-1$ edf $z=1$ sed interdum felis dapibus sem. $x$ set $y$ ytruem. %Turpis $j$ amet accumsan enim $y$-lacina; %ref $k$-viverra nec porttitor $x$-lacina. %Vestibulum ac diam a odio tempus congue. Vivamus id enim nisi: %\begin{eqnarray} %\cos\bar{\phi}_k Q_{j,k+1,t} + Q_{j,k+1,x}+\frac{\sin^2\bar{\phi}_k}{T\cos\bar{\phi}_k} Q_{j,k+1} &=&\nonumber\\ %-\cos\phi_k Q_{j,k,t} + Q_{j,k,x}-\frac{\sin^2\phi_k}{T\cos\phi_k} Q_{j,k}\label{edgek} %\end{eqnarray} %and %\begin{eqnarray} %\cos\bar{\phi}_j Q_{j+1,k,t} + Q_{j+1,k,y}+\frac{\sin^2\bar{\phi}_j}{T\cos\bar{\phi}_j} Q_{j+1,k}&=&\nonumber \\ %-\cos\phi_j Q_{j,k,t} + Q_{j,k,y}-\frac{\sin^2\phi_j}{T\cos\phi_j} Q_{j,k}.\label{edgej} %\end{eqnarray} %Nulla sed arcu arcu. Duis et ante gravida orci venenatis tincidunt. Fusce vitae lacinia metus. Pellentesque habitant morbi. $\mathbf{A}\underline{\xi}=\underline{\beta}$ Vim $\underline{\xi}$ enum nidi $3(P+2)^{2}$ lacina. Id feugain $\mathbf{A}$ nun quis; magno. %---------------------------------------------------------------------------------------- % RESULTS %---------------------------------------------------------------------------------------- \color{SaddleBrown} % SaddleBrown color for the conclusions to make them stand out \section*{Results and Conclusion} ``Power model'' showed the best-fit for all methods and pooled series except for SSTP in 1948-2007. SSTP computed semivariances exhibited much less noise than the AEV and WAEV, and consequently PTS variograms estimated by SSTP showed lower MSE and RMSE, and higher NSE indicating higher precision than AEV and WAEV (Figure 3). SSTP reduces uncertainty for variogram modelling while preserving spatiotemporal properties. It can be improved by including temporal autocorrelation, external variables and expert elicitation. % %\begin{wraptable}{l}{12cm} % Left or right alignment is specified in the first bracket, the width of the table is in the second %\begin{tabular}{l l l} %\toprule %\textbf{Treatments} & \textbf{Response 1} & \textbf{Response 2}\\ %\midrule %Treatment 1 & 0.0003262 & 0.562 \\ %Treatment 2 & 0.0015681 & 0.910 \\ %Treatment 3 & 0.0009271 & 0.296 \\ %\bottomrule %\end{tabular} %\captionof{table}{\color{Green} Table caption} %\end{wraptable} % %Phasellus imperdiet, tortor vitae congue bibendum, felis enim sagittis lorem, et volutpat ante orci sagittis mi. Morbi rutrum laoreet semper. Morbi accumsan enim nec tortor consectetur non commodo nisi sollicitudin. Proin sollicitudin. Pellentesque eget orci eros. Fusce ultricies, tellus et pellentesque fringilla, ante massa luctus libero, quis tristique purus urna nec nibh. %Nulla ut porttitor enim. Suspendisse venenatis dui eget eros gravida tempor. Mauris feugiat elit et augue placerat ultrices. Morbi accumsan enim nec tortor consectetur non commodo. Pellentesque condimentum dui. Etiam sagittis purus non tellus tempor volutpat. Donec et dui non massa tristique adipiscing. Quisque vestibulum eros eu. Phasellus imperdiet, tortor vitae congue bibendum, felis enim sagittis lorem, et volutpat ante orci sagittis mi. Morbi rutrum laoreet semper. Morbi accumsan enim nec tortor consectetur non commodo nisi sollicitudin. \begin{center} \includegraphics[width=1\linewidth]{Fig_3} \captionof{figure}{\color{Green} Estimated PTS variograms by SSTP, AEV and WAEV methods with model parameters and precision statistics.} \end{center} %\begin{center}\vspace{1cm} %\begin{tabular}{l l l l} %\toprule %\textbf{Treatments} & \textbf{Response 1} & \textbf{Response 2} \\ %\midrule %Treatment 1 & 0.0003262 & 0.562 \\ %Treatment 2 & 0.0015681 & 0.910 \\ %Treatment 3 & 0.0009271 & 0.296 \\ %\bottomrule %\end{tabular} %\captionof{table}{\color{Green} Table caption} %\end{center}\vspace{1cm} %Vivamus sed nibh ac metus tristique tristique a vitae ante. Sed lobortis mi ut arcu fringilla et adipiscing ligula rutrum. Aenean turpis velit, placerat eget tincidunt nec, ornare in nisl. In placerat. %---------------------------------------------------------------------------------------- % CONCLUSIONS %---------------------------------------------------------------------------------------- %\color{SaddleBrown} % SaddleBrown color for the conclusions to make them stand out %\section*{Conclusions} %\begin{itemize} %\item Pellentesque eget orci eros. Fusce ultricies, tellus et pellentesque fringilla, ante massa luctus libero, quis tristique purus urna nec nibh. Phasellus fermentum rutrum elementum. Nam quis justo lectus. %\item Vestibulum sem ante, hendrerit a gravida ac, blandit quis magna. %\item Donec sem metus, facilisis at condimentum eget, vehicula ut massa. Morbi consequat, diam sed convallis tincidunt, arcu nunc. %\item Nunc at convallis urna. isus ante. Pellentesque condimentum dui. Etiam sagittis purus non tellus tempor volutpat. Donec et dui non massa tristique adipiscing. %\end{itemize} \color{DarkSlateGray} % Set the color back to DarkSlateGray for the rest of the content %---------------------------------------------------------------------------------------- % FORTHCOMING RESEARCH %---------------------------------------------------------------------------------------- %\section*{Forthcoming Research} %Vivamus molestie, risus tempor vehicula mattis, libero arcu volutpat purus, sed blandit sem nibh eget turpis. Maecenas rutrum dui blandit lorem vulputate gravida. Praesent venenatis mi vel lorem tempor at varius diam sagittis. Nam eu leo id turpis interdum luctus a sed augue. Nam tellus. %---------------------------------------------------------------------------------------- % REFERENCES %---------------------------------------------------------------------------------------- %\nocite{*} % Print all references regardless of whether they were cited in the poster or not \bibliographystyle{unsrt} % Plain referencing style \bibliography{SPAT_Bhowmik} % Use the example bibliography file sample.bib %---------------------------------------------------------------------------------------- % ACKNOWLEDGEMENTS %---------------------------------------------------------------------------------------- %\section*{Acknowledgements} %Etiam fermentum, arcu ut gravida fringilla, dolor arcu laoreet justo, ut imperdiet urna arcu a arcu. Donec nec ante a dui tempus consectetur. Cras nisi turpis, dapibus sit amet mattis sed, laoreet. %---------------------------------------------------------------------------------------- \end{multicols} \end{document}
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Instance.Simplex where open import Level open import Data.Product open import Data.Fin open import Data.Nat using (ℕ) open import Function renaming (id to idF; _∘_ to _∙_) open import Relation.Binary open import Relation.Binary.PropositionalEquality Δ : Category 0ℓ 0ℓ 0ℓ Δ = record { Obj = ℕ ; _⇒_ = λ m n → Σ (Fin m → Fin n) (λ f → _≤_ =[ f ]⇒ _≤_) ; _≈_ = λ { (f , mf) (g , mg) → ∀ x → f x ≡ g x } ; id = idF , idF ; _∘_ = λ { (f , mf) (g , mg) → f ∙ g , mf ∙ mg } ; assoc = λ _ → refl ; sym-assoc = λ _ → refl ; identityˡ = λ _ → refl ; identityʳ = λ _ → refl ; identity² = λ _ → refl ; equiv = record { refl = λ _ → refl ; sym = λ eq x → sym (eq x) ; trans = λ eq₁ eq₂ x → trans (eq₁ x) (eq₂ x) } ; ∘-resp-≈ = λ {_ _ _ f g h i} eq₁ eq₂ x → trans (cong (λ t → proj₁ f t) (eq₂ x)) (eq₁ (proj₁ i x)) }
[STATEMENT] lemma fixes ps:: partstate and s::state assumes "vars a \<subseteq> dom ps" "ps \<preceq> part s" shows emb_update: "emb [x \<mapsto> paval a ps] s = (emb ps s) (x := aval a (emb ps s))" [PROOF STATE] proof (prove) goal (1 subgoal): 1. emb [x \<mapsto> paval a ps] s = (emb ps s)(x := aval a (emb ps s)) [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: vars a \<subseteq> dom ps ps \<preceq> part s goal (1 subgoal): 1. emb [x \<mapsto> paval a ps] s = (emb ps s)(x := aval a (emb ps s)) [PROOF STEP] unfolding emb_def [PROOF STATE] proof (prove) using this: vars a \<subseteq> dom ps ps \<preceq> part s goal (1 subgoal): 1. (\<lambda>v. case [x \<mapsto> paval a ps] v of None \<Rightarrow> s v | Some r \<Rightarrow> r) = (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)(x := aval a (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)) [PROOF STEP] apply auto [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> part s\<rbrakk> \<Longrightarrow> (\<lambda>v. case if v = x then Some (paval a ps) else None of None \<Rightarrow> s v | Some r \<Rightarrow> r) = (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)(x := aval a (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)) [PROOF STEP] apply (rule ext) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> part s\<rbrakk> \<Longrightarrow> (case if v = x then Some (paval a ps) else None of None \<Rightarrow> s v | Some r \<Rightarrow> r) = ((\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)(x := aval a (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r))) v [PROOF STEP] apply(case_tac "v=x") [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> part s; v = x\<rbrakk> \<Longrightarrow> (case if v = x then Some (paval a ps) else None of None \<Rightarrow> s v | Some r \<Rightarrow> r) = ((\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)(x := aval a (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r))) v 2. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> part s; v \<noteq> x\<rbrakk> \<Longrightarrow> (case if v = x then Some (paval a ps) else None of None \<Rightarrow> s v | Some r \<Rightarrow> r) = ((\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)(x := aval a (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r))) v [PROOF STEP] apply(simp add: paval_aval) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> part s; v \<noteq> x\<rbrakk> \<Longrightarrow> (case if v = x then Some (paval a ps) else None of None \<Rightarrow> s v | Some r \<Rightarrow> r) = ((\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r)(x := aval a (\<lambda>v. case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r))) v [PROOF STEP] apply(simp) [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> part s; v \<noteq> x\<rbrakk> \<Longrightarrow> s v = (case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r) [PROOF STEP] unfolding part_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> (\<lambda>v. Some (s v)); v \<noteq> x\<rbrakk> \<Longrightarrow> s v = (case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r) [PROOF STEP] apply(case_tac "v \<in> dom ps") [PROOF STATE] proof (prove) goal (2 subgoals): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> (\<lambda>v. Some (s v)); v \<noteq> x; v \<in> dom ps\<rbrakk> \<Longrightarrow> s v = (case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r) 2. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> (\<lambda>v. Some (s v)); v \<noteq> x; v \<notin> dom ps\<rbrakk> \<Longrightarrow> s v = (case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r) [PROOF STEP] using subState [PROOF STATE] proof (prove) using this: \<lbrakk>?x \<preceq> ?y; ?v \<in> dom ?x\<rbrakk> \<Longrightarrow> ?x ?v = ?y ?v goal (2 subgoals): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> (\<lambda>v. Some (s v)); v \<noteq> x; v \<in> dom ps\<rbrakk> \<Longrightarrow> s v = (case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r) 2. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> (\<lambda>v. Some (s v)); v \<noteq> x; v \<notin> dom ps\<rbrakk> \<Longrightarrow> s v = (case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r) [PROOF STEP] apply fastforce [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>v. \<lbrakk>vars a \<subseteq> dom ps; ps \<preceq> (\<lambda>v. Some (s v)); v \<noteq> x; v \<notin> dom ps\<rbrakk> \<Longrightarrow> s v = (case ps v of None \<Rightarrow> s v | Some r \<Rightarrow> r) [PROOF STEP] by (simp add: domIff)
#%% import os import json import numpy as np from common import Action, Direction from sklearn.utils import shuffle import pickle as pkl data_level2dir = {"easy": 'data_easy', "medium": 'data_medium', "hard": 'data'} def parse_dataset(levels=["easy"], mode="train", sort_by_hardness=False, compact=True): size_mode = 'compact' if compact else 'verbose' pickled_path = f'datasets/preprocessed_{mode}_{"_".join(levels)}_{size_mode}.pkl' if os.path.isfile(pickled_path): all_tasks, all_seqs = pkl.load(open(pickled_path, 'rb')) return all_tasks, all_seqs all_tasks, all_seqs = [], [] for level in levels: data_dir = f"datasets/{data_level2dir[level]}" tasks_dir = f"{data_dir}/{mode}/task" seqs_dir = f"{data_dir}/{mode}/seq" task_fnames = sorted(os.listdir(tasks_dir), key=lambda s: int(s.split("_")[0])) seq_fnames = sorted(os.listdir(seqs_dir), key=lambda s: int(s.split("_")[0])) tasks = [json.load(open(f"{tasks_dir}/{fname}")) for fname in task_fnames] seqs = [json.load(open(f"{seqs_dir}/{fname}")) for fname in seq_fnames] all_tasks.extend(tasks) all_seqs.extend(seqs) if sort_by_hardness: all_tasks, all_seqs = ( list(t) for t in zip(*sorted(zip(all_tasks, all_seqs), key=compute_hardness)) ) else: all_tasks, all_seqs = shuffle(all_tasks, all_seqs, random_state=73) if pickled_path: pkl.dump((all_tasks, all_seqs), open(pickled_path, 'wb')) return all_tasks, all_seqs def parse_dataset_by_dir(tasks_dir): all_tasks = [] task_fnames = sorted(os.listdir(tasks_dir), key=lambda s: int(s.split("_")[0])) task_ids = list(map(lambda s: s.split("_")[0], task_fnames)) tasks = [json.load(open(f"{tasks_dir}/{fname}")) for fname in task_fnames] all_tasks.extend(tasks) return all_tasks, task_ids def parse_test_dataset(levels=["hard"], compact=True): size_mode = 'compact' if compact else 'verbose' mode = 'test_without_seq' pickled_path = f'datasets/preprocessed_{mode}_{"_".join(levels)}_{size_mode}.pkl' if os.path.isfile(pickled_path): all_tasks = pkl.load(open(pickled_path, 'rb')) return all_tasks all_tasks = [] for level in levels: data_dir = f"datasets/{data_level2dir[level]}" tasks_dir = f"{data_dir}/{mode}/task" task_fnames = sorted(os.listdir(tasks_dir), key=lambda s: int(s.split("_")[0])) tasks = [json.load(open(f"{tasks_dir}/{fname}")) for fname in task_fnames] all_tasks.extend(tasks) if pickled_path: pkl.dump(all_tasks, open(pickled_path, 'wb')) return all_tasks def compute_hardness(task_seq): seq = task_seq[1]["sequence"] task_len = len(seq) pickMarkers = seq.count("pickMarker") putMarkers = seq.count("putMarker") return task_len + 1.5 * putMarkers + 2.0 * pickMarkers def vectorize_obs(task, is_compact=True): n, m = task["gridsz_num_rows"], task["gridsz_num_cols"] ar1 = task["pregrid_agent_row"] ac1 = task["pregrid_agent_col"] ad1 = Direction.from_str[task["pregrid_agent_dir"]] ar2 = task["postgrid_agent_row"] ac2 = task["postgrid_agent_col"] ad2 = Direction.from_str[task["postgrid_agent_dir"]] if is_compact: feat_v = np.zeros((n, m, 1 + 2 * 2)) feat_rot = np.zeros((8)) feat_v[ar1, ac1, 2] = 1 feat_v[ar2, ac2, 4] = 1 # Represent walls for w_pos in task["walls"]: feat_v[w_pos[0], w_pos[1], 0] = 1 # Represent markers for m_pos in task["pregrid_markers"]: feat_v[m_pos[0], m_pos[1], 1] = 1 for m_pos in task["postgrid_markers"]: feat_v[m_pos[0], m_pos[1], 3] = 1 rot_bits = np.zeros((8)) rot_bits[ad1] = 1 rot_bits[ad2 + 4] = 1 feat_v = feat_v.flatten() feat_v = np.concatenate((feat_v, rot_bits)) else: feat_v = np.zeros((n, m, 1 + 2 * 5)) feat_v[ar1, ac1, ad1 + 2] = 1 feat_v[ar2, ac2, ad2 + 7] = 1 # Represent walls for w_pos in task["walls"]: feat_v[w_pos[0], w_pos[1], 0] = 1 # Represent markers for m_pos in task["pregrid_markers"]: feat_v[m_pos[0], m_pos[1], 1] = 1 for m_pos in task["postgrid_markers"]: feat_v[m_pos[0], m_pos[1], 6] = 1 return feat_v def vectorize_seq(seq): feat_v = [Action.from_str[cmd] for cmd in seq["sequence"]] return feat_v
module Idris.Pretty.Render import Core.Context import Core.Core import Idris.REPL.Opts import Libraries.Control.ANSI.SGR import Libraries.Text.PrettyPrint.Prettyprinter import public Libraries.Text.PrettyPrint.Prettyprinter.Render.Terminal import Libraries.Utils.Term import System %default total getPageWidth : {auto o : Ref ROpts REPLOpts} -> Core PageWidth getPageWidth = do consoleWidth <- getConsoleWidth case consoleWidth of Nothing => do cols <- coreLift getTermCols pure $ if cols == 0 then Unbounded else AvailablePerLine cols 1 Just 0 => pure $ Unbounded Just cw => pure $ AvailablePerLine (cast cw) 1 export render : {auto o : Ref ROpts REPLOpts} -> (ann -> AnsiStyle) -> Doc ann -> Core String render stylerAnn doc = do color <- getColor isDumb <- (Just "dumb" ==) <$> coreLift (getEnv "TERM") -- ^-- emacs sets the TERM variable to `dumb` and expects the compiler -- to not emit any ANSI escape codes pageWidth <- getPageWidth let opts = MkLayoutOptions pageWidth let layout = layoutPretty opts doc pure $ renderString $ if color && not isDumb then reAnnotateS stylerAnn layout else unAnnotateS layout export renderWithoutColor : {auto o : Ref ROpts REPLOpts} -> Doc ann -> Core String renderWithoutColor doc = do pageWidth <- getPageWidth let opts = MkLayoutOptions pageWidth let layout = layoutPretty opts doc pure $ renderString $ unAnnotateS layout export renderWithSpans : {auto o : Ref ROpts REPLOpts} -> Doc ann -> Core (String, List (Span ann)) renderWithSpans doc = do pageWidth <- getPageWidth let opts = MkLayoutOptions pageWidth let layout = layoutPretty opts doc pure $ displaySpans layout
# Solución de ecuaciones <p><code>Python en Jupyter Notebook</code></p> <p>Creado por <code>Giancarlo Ortiz</code> para el curso de <code>Métodos Numéricos</code></p> <style type="text/css"> .border { display: inline-block; border: solid 1px rgba(204, 204, 204, 0.4); border-bottom-color: rgba(187, 187, 187, 0.4); border-radius: 3px; box-shadow: inset 0 -1px 0 rgba(187, 187, 187, 0.4); background-color: inherit !important; vertical-align: middle; color: inherit !important; font-size: 11px; padding: 3px 5px; margin: 0 2px; } </style> ## Búsqueda de raíces por métodos abiertos Los métodos abiertos, a diferencia de los métodos cerrados, calculan en cada iteración una aproximación a la raíz partiendo de un valor inicial y una función auxiliar, sin necesidad de verificar lo que sucede dentro de un intervalo. ## Agenda 1. Generalidades 1. Método de punto fijo 1. Método de Newton-Raphson 1. Método de la secante ```python # Importar módulos al cuaderno de jupyter import math as m import numpy as np import pylab as plt # Definir e incluir nuevas funciones al cuaderno def _buscar_intervalos(fun, ini, fin): """ Método para buscar intervalos en los que ocurra cambio de signo. ## Parámetros: fun (function) : función para analizar. ini (int) : inicio del análisis. fin (int) : limite final del análisis. ## Devoluciones: I (list) : Lista de tuplas con los intervalos donde hay un cero. """ i = ini - 1 # Variable para contar iteraciones I = [] # Variable para almacenar los intervalos while i < fin: i += 1 if fun(i) == 0: I.append((i, i)) elif fun(i) * fun(i+1) < 0: I.append((i, i+1)) else: pass return I def _imprimir_paso(paso): Iteraciones = len(paso[0]) Tb = f"| I # | {'Xi':>8} | {'Error Abs':>9} | {'F(Xi)':>9} |\n" Tb += "------------------------------------------\n" for i in range(Iteraciones): xi = paso[0][i] eai = paso[1][i] yi = paso[2][i] Tb += f"| {i+1:3} | {xi:8.5f} | {eai:9.5f} | {yi:9.5f} |\n" return print(Tb) ``` ## 1. Métodos Abiertos --- Los métodos abiertos calculan en cada iteración una aproximación a la raíz partiendo de un valor inicial y una función auxiliar, pero no se ocupan de verificar si esta aproximación genera o no un intervalo que contenga una raíz; como consecuencia de ello en estos métodos no hay garantía de la convergencia. La función auxiliar usada para predecir la raíz es una fórmula puede desarrollarse como la sustitución de un punto fijo en cada iteración y el valor inicial que se sustituye en la función auxiliar se conoce como semilla. > **NOTA:** Nótese que para estos métodos no es necesario tener un intervalo, solo es necesaria la semilla, el máximo de iteraciones y la tolerancia aceptada. ## 2. Método de punto fijo --- Es el primero y más sencillo de los métodos abiertos y se basa en la definición de un punto fijo de forma que para buscar la raíz de una ecuación $\color{#a78a4d}{f(x)=0}$, se genera una función auxiliar de punto fijo $\color{#a78a4d}{x=g(x)}$ y se calcula sucesivamente el valor $\color{#a78a4d}{x}$ de la función partiendo de la semilla $\color{#a78a4d}{x_o}$ introducida al inicio, buscando que en cada iteración el valor de $\color{#a78a4d}{x}$ se acerque al valor de la raíz; continuando hasta que se reduzca el nivel de error a un nivel aceptable, según la tolerancia; o hasta que se supere el número máximo de iteraciones. > **PUNTO FIJO:** un punto fijo de una función $f(x)$ es un número real p tal que $p = f(p)$ <p align="center"> </p> <div align="center"><b>Figura 1.</b> Explicación gráfica punto fijo</div> ### Formulación: * Se desplaza la función $f(x)$ de forma que la raíz coincida con un un punto fijo de la función desplazada, $g(x)$. Para encontrar el punto fijo (raíz) se evalúa la semilla inicial $x_o$ en $g(x)$, si el valor no es aceptable se toma el resultado como un nuevo $x_o$ y se generaliza para una solución que repita el proceso: \begin{align} \tag{1} f(x) &=0 \\ \tag{2} f(x) + x &=x \\ \tag{3} g(x) &=x \\ \tag{4} x_1 &= g(x_0) \\ \text{Generalizando (3):$\qquad\qquad$} \\ \tag{5} x_n &= g(x_{n-1}) \end{align} ### Ventajas: * En algunos casos puede converger más rápidamente que los métodos cerrados. * Útil para entender el funcionamiento de los métodos abiertos. ### Desventajas: * El método no siempre converge. ```python # Defino el método del punto fijo def _fijo(Func, SemX, Imax, Tmax): """ Método de la Bisección para encontrar raíces en un intervalo. ## Parámetros: Func (function) : función que depende de una variable. SemX (int) : semilla de la solución. Imax (int) : número máximo de iteraciones. Tmax (int) : exponente de tolerancia máxima, T = 1e^Tmax. ## Devoluciones: Km (float) : valor de x encontrado. No (int) : iteraciones. ea (float) : error absoluto final Li (list) : lista de las soluciones, los errores absolutos y la tabla con la evolución de iteraciones. """ def g(x): y = Func(x[0]) + x[0] return [y,] xo = [SemX,] x = [] ea = [] y = [] for i in range(Imax): xi = g(xo) eai = abs((xi[0] - g(xi)[0])/xi[0]) x.append(xi[0]) ea.append(eai) y.append(Func(xi[0])) if eai < (10**Tmax): break xo = xi # Salida del método Xm, No, ea, [S, E, Tb] return i, xi, eai, [x, ea, y] ``` ## 3. Método de Newton-Raphson --- En matemáticas, el método de Newton-Raphson es una variante del método del punto fijo, en este caso la función auxiliar se define de tal forma que sea una aproximación lineal en las cercanías del valor semilla $\color{#a78a4d}{x_o}$ de la función original, y sucesivamente calcular el corte dicha recta como un nuevo valor de $\color{#a78a4d}{x}$. <p align="center"> </p> <div align="center"><b>Figura 2.</b> Explicación gráfica Newton-Raphson</div> ### Formulación: * Se construye una recta tangente que pase la semilla inicial $x_o$, se encuentra la raíz de la recta tangente, si el valor no es aceptable se toma el resultado como una nueva semilla y se generaliza para una solución que repita el proceso y se generaliza con una solución que repita el proceso: \begin{align} \tag{6} y - y_o &= m (x - x_o) \\ \tag{7} f(x) - f(x_o) &= f^{\prime}(x_o)(x - x_o) \\ \tag{8} f(x) &= f^{\prime}(x_o)(x - x_o) + f(x_o) = 0 \\ \tag{9} x &= x_o - \frac{f(x_o)}{f^{\prime}(x_o)} \\ \tag{10} x_n &= x_{n-1} - \frac{f(x_{n-1})}{f^{\prime}(x_{n-1})} \\ \end{align} ### Ventajas: * Método muy eficiente en la mayoría de los casos. * Se puede evitar alguna de sus desventajas definiendo un valor cercano de la raíz. ### Desventajas: * El método no siempre converge. * para evitar puntos críticos en la cercanía de la solución. * Raíces múltiples * Múltiples puntos de inflexión * Pendientes prolongadas alrededor de la raíz. ```python # Defino el método Newton-Raphson def _newton(Func, DevX, SemX, Imax, Tmax): """ Método de la Bisección para encontrar raíces en un intervalo. ## Parámetros: Func (function) : función que depende de una variable. DevX (function) : derivada de la función. SemX (int) : semilla de la solución. Imax (int) : número máximo de iteraciones. Tmax (int) : exponente de tolerancia máxima, T = 1e^Tmax. ## Devoluciones: Km (float) : valor de x encontrado. No (int) : iteraciones. ea (float) : error absoluto final Li (list) : lista de las soluciones, los errores absolutos y la tabla con la evolución de iteraciones. """ def g(x): y = x[0] - Func(x[0])/DevX(x[0]) return [y,] xo = [SemX,] x = [] ea = [] y = [] for i in range(Imax): xi = g(xo) eai = abs((xi[0] - g(xi)[0])/xi[0]) x.append(xi[0]) ea.append(eai) y.append(Func(xi[0])) if eai < (10**Tmax): break xo = xi # Salida del método Xm, No, ea, [S, E, Tb] return i, xi, eai, [x, ea, y] ``` ## 4. Método de la secante --- Un La recta secante es una recta que corta a una circunferencia en dos puntos. Conforme estos puntos de corte se acercan, dicha recta se aproxima a un punto y, cuando solo existe un punto que toca la circunferencia, se le llama tangente. caso particular de las ecuaciones algebraicas sucede cuando solo los dos primeros coeficientes son distintos de cero y la solución para x es única y trivial. <p align="center"> </p> <div align="center"><b>Figura 3.</b> Explicación gráfica secante</div> ### Formulación: * Se construye una recta secante que pase por las semillas iniciales $x_o$, $x_1$, se encuentra la raíz de la recta secante, si el valor no es aceptable se toma el resultado como una nueva semilla y se generaliza para una solución que repita el proceso y se generaliza con una solución que repita el proceso: \begin{align} \tag{11} y - y_o &= m (x - x_o) \\ \tag{12} f(x) - f(x_o) &= f^{\prime}(x_o)(x - x_o) \\ \tag{13} f(x) - f(x_o) &= \frac{f(x_o)-f(x_1)}{x_o-x_1} (x - x_o) \\ \tag{14} f(x) &= \frac{f(x_o)-f(x_1)}{x_o-x_1} (x - x_o) + f(x_o) = 0 \\ \tag{15} x &= x_o - f(x_o) \frac{ x_o-x_1 }{ f(x_o)-f(x_1) }\\ \tag{16} x_n &= x_{n-1} - f(x_{n-1}) \frac{ x_{n-1}-x_{n-2} }{ f(x_{n-1})-f(x_{n-2}) }\\ \end{align} ### Ventajas: * Muy eficiente cuando la ecuación no posee múltiples puntos de inflexión o pendientes prolongadas alrededor de la raíz. * Útil como aproximación inicial de otros métodos. ### Desventajas: * El método no siempre converge. * Es útil definir un valor cercano de la raíz, para evitar puntos críticos en la cercania de la solución. ```python # Defino el método iterativo de la Secante def _secante(Func, Sem1, Sem2, Imax, Tmax): """ Método de la Bisección para encontrar raíces en un intervalo. ## Parámetros: Func (function) : función que depende de una variable. Sem1 (int) : semilla uno de la solución. Sem2 (int) : semilla dos de la solución. Imax (int) : número máximo de iteraciones. Tmax (int) : exponente de tolerancia máxima, T = 1e^Tmax. ## Devoluciones: Km (float) : valor de x encontrado. No (int) : iteraciones. ea (float) : error absoluto final Li (list) : lista de las soluciones, los errores absolutos y la tabla con la evolución de iteraciones. """ def g(xo): y1 = xo[0] - Func(xo[0])*(xo[0] - xo[1])/(Func(xo[0])-Func(xo[1])) y = [y1, xo[1]] return y xo = [Sem1, Sem2] x = [] ea = [] y = [] for i in range(Imax): xi = g(xo) eai = abs((xi[0] - g(xi)[0])/xi[0]) x.append(xi[0]) ea.append(eai) y.append(Func(xi[0])) if eai < (10**Tmax): break xo = xi # Salida del método Xm, No, ea, [S, E, Tb] return i, xi, eai, [x, ea, y] ``` ```python # Ecuación de la altura para el movimiento parabólico def altura(θ, Vo, ho, t): g = 9.8179 Voy = Vo * np.sin(θ*np.pi/180) y = -(1/2) * g * t**2 + Voy * t + ho return y # Funciónes de prueba F1 = lambda t: altura(45, 12, 3, t) F2 = lambda x: np.e**(-x) - x F3 = lambda x: np.cos(x) - x # Derivadas de las funciónes de prueba D1 = lambda t: -9.8179 * t + 12 * np.sin(45*np.pi/180) D2 = lambda x: -np.e**(-x) - 1 D3 = lambda x: -np.sin(x) - 1 # Vectores de prueba t = np.linspace(-1, 3, 256, endpoint=True) x = np.linspace(-1, 3, 256, endpoint=True) # Gráficas #------------------- fig, ax = plt.subplots(1, 3) fig.set_size_inches(16, 4) fig.suptitle('Funciones de Prueba'.upper(), fontsize=14, fontweight="bold") # Gráficas 1 ax[0].axhline(y = 0, linewidth=1.0, color="#ccc") ax[0].plot(t, F1(t), label="$F_1(x)$") ax[0].plot(t, D1(t), label="$F_1^{\prime}(x)$") ax[0].set_xlim([-1, 3]) ax[0].set_title("Función cuadrática", fontsize=8) ax[0].set_xlabel("Variable independiente") ax[0].set_ylabel("variable dependiente") ax[0].legend() # Gráficas 2 ax[1].axhline(y = 0, linewidth=1, color="#ccc") ax[1].plot(x, F2(x), label="$F_2(x)$") ax[1].plot(x, D2(x), label="$F_2^{\prime}(x)$") ax[1].set_xlim([-1, 3]) ax[1].set_title("Función exponencial", fontsize=8) ax[1].set_xlabel("Variable independiente") ax[1].legend() # Gráficas 3 ax[2].axhline(y = 0, linewidth=1, color="#ccc") ax[2].plot(x, F3(x), label="$F_3(x)$") ax[2].plot(x, D3(x), label="$F_3^{\prime}(x)$") ax[2].set_xlim([-1, 3]) ax[2].set_title("Función sinusoide", fontsize=8) ax[2].set_xlabel("Variable independiente") ax[2].legend() plt.show() ``` ```python # Métodos abiertos n1, x1, ea1, paso1 = _fijo(F2, 0.7, 20, -4) n2, x2, ea2, paso2 = _newton(F2, D3, 0.7, 20, -4) n3, x3, ea3, paso3 = _secante(F2, 0, 1, 20, -4) ``` ```python _imprimir_paso(paso1) ``` | I # | Xi | Error Abs | F(Xi) | ------------------------------------------ | 1 | 0.49659 | 0.22558 | 0.11202 | | 2 | 0.60861 | 0.10597 | -0.06450 | | 3 | 0.54411 | 0.06662 | 0.03625 | | 4 | 0.58036 | 0.03560 | -0.02066 | | 5 | 0.55970 | 0.02088 | 0.01168 | | 6 | 0.57138 | 0.01162 | -0.00664 | | 7 | 0.56474 | 0.00666 | 0.00376 | | 8 | 0.56851 | 0.00375 | -0.00213 | | 9 | 0.56637 | 0.00214 | 0.00121 | | 10 | 0.56758 | 0.00121 | -0.00069 | | 11 | 0.56689 | 0.00069 | 0.00039 | | 12 | 0.56728 | 0.00039 | -0.00022 | | 13 | 0.56706 | 0.00022 | 0.00013 | | 14 | 0.56719 | 0.00013 | -0.00007 | | 15 | 0.56712 | 0.00007 | 0.00004 | ```python _imprimir_paso(paso2) ``` | I # | Xi | Error Abs | F(Xi) | ------------------------------------------ | 1 | 0.57628 | 0.01606 | -0.01430 | | 2 | 0.56703 | 0.00021 | 0.00018 | | 3 | 0.56715 | 0.00000 | -0.00000 | ```python _imprimir_paso(paso3) ``` | I # | Xi | Error Abs | F(Xi) | ------------------------------------------ | 1 | 0.61270 | 0.07975 | -0.07081 | | 2 | 0.56384 | 0.00629 | 0.00518 | | 3 | 0.56739 | 0.00046 | -0.00038 | | 4 | 0.56713 | 0.00003 | 0.00003 | --- ## Mas Recursos - [Búsqueda de raíces](https://es.wikipedia.org/wiki/Resoluci%C3%B3n_num%C3%A9rica_de_ecuaciones_no_lineales) (Wikipedia) - [Método del punto fijo](https://es.wikipedia.org/wiki/M%C3%A9todo_del_punto_fijo) (Wikipedia) - [Método de Newton](https://es.wikipedia.org/wiki/M%C3%A9todo_de_Newton) (Wikipedia) - [Método de la secante](https://es.wikipedia.org/wiki/M%C3%A9todo_de_la_secante) (Wikipedia)
/* Copyright (C) 2018 Quaternion Risk Management Ltd All rights reserved. This file is part of ORE, a free-software/open-source library for transparent pricing and risk analysis - http://opensourcerisk.org ORE is free software: you can redistribute it and/or modify it under the terms of the Modified BSD License. You should have received a copy of the license along with this program. The license is also available online at <http://opensourcerisk.org> This program is distributed on the basis that it will form a useful contribution to risk analytics and model standardisation, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ #include <boost/make_shared.hpp> #include <ql/math/solvers1d/brent.hpp> #include <ql/termstructures/yieldtermstructure.hpp> #include <qle/instruments/impliedbondspread.hpp> using namespace QuantLib; namespace QuantExt { namespace { class PriceError { public: PriceError(const Bond& engine, SimpleQuote& spread, Real targetValue, bool isCleanPrice); Real operator()(Real spread) const; private: const Bond& bond_; SimpleQuote& spread_; Real targetValue_; bool isCleanPrice_; }; PriceError::PriceError(const Bond& bond, SimpleQuote& spread, Real targetValue, bool isCleanPrice) : bond_(bond), spread_(spread), targetValue_(targetValue), isCleanPrice_(isCleanPrice) {} Real PriceError::operator()(Real spread) const { spread_.setValue(spread); Real guessValue = isCleanPrice_ ? bond_.cleanPrice() : bond_.dirtyPrice(); return guessValue - targetValue_; } } // namespace namespace detail { Real ImpliedBondSpreadHelper::calculate(const boost::shared_ptr<Bond>& bond, const boost::shared_ptr<PricingEngine>& engine, const boost::shared_ptr<SimpleQuote>& spreadQuote, Real targetValue, bool isCleanPrice, Real accuracy, Natural maxEvaluations, Real minSpread, Real maxSpread) { Bond clonedBond = *bond; clonedBond.setPricingEngine(engine); clonedBond.recalculate(); spreadQuote->setValue(0.005); PriceError f(clonedBond, *spreadQuote, targetValue, isCleanPrice); Brent solver; solver.setMaxEvaluations(maxEvaluations); Real guess = (minSpread + maxSpread) / 2.0; Real result = solver.solve(f, accuracy, guess, minSpread, maxSpread); return result; } } // namespace detail } // namespace QuantExt
function tests = test_ft_specest_hilbert % MEM 1gb % WALLTIME 00:10:00 % DEPENDENCY ft_specest_hilbert if nargout % assume that this is called by RUNTESTS tests = functiontests(localfunctions); else % assume that this is called from the command line fn = localfunctions; for i=1:numel(fn) feval(fn{i}); end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function testOptions(testCase) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fsample = 1000; nchan = 8; nsample = 1000; dat = randn(nchan, nsample) + 1 + linspace(0,1,nsample); time = (0:(nsample-1))/fsample; verbose = false; freqoi = (10:10:100)'; width = 5; result = {}; % first explore the different filter types and orders result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 2, 'bpfiltdir', 'twopass', 'timeoi', time); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 2, 'bpfiltdir', 'twopass', 'timeoi', time(1:2:end)); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 3, 'bpfiltdir', 'twopass', 'timeoi', time(1:2:end)); % bpfiltdir=twopass is the default, use a different filter order for the following ones result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 1, 'bpfiltdir', 'onepass'); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 1, 'bpfiltdir', 'onepass-reverse'); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 1, 'bpfiltdir', 'twopass'); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 1, 'bpfiltdir', 'twopass-reverse'); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 1, 'bpfiltdir', 'twopass-average'); % padtype=zero is the default, use a different filter order for the following ones result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 2, 'bpfiltdir', 'twopass', 'pad', 2, 'padtype', 'zero' ); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 2, 'bpfiltdir', 'twopass', 'pad', 2, 'padtype', 'mean' ); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 2, 'bpfiltdir', 'twopass', 'pad', 2, 'padtype', 'localmean' ); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 2, 'bpfiltdir', 'twopass', 'pad', 2, 'padtype', 'edge' ); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 2, 'bpfiltdir', 'twopass', 'pad', 2, 'padtype', 'mirror' ); % polyorder=0 is the default, use a different filter order for the following ones result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 3, 'bpfiltdir', 'twopass', 'polyorder', 0); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 3, 'bpfiltdir', 'twopass', 'polyorder', 1); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 3, 'bpfiltdir', 'twopass', 'polyorder', 2); result{end+1} = ft_specest_hilbert(dat, time, 'verbose', verbose, 'freqoi', freqoi, 'width', width, 'bpfilttype', 'but', 'bpfiltord', 3, 'bpfiltdir', 'twopass', 'polyorder', 3); % all iterations were done with (slightly) different options, hence the results should not be equal for i=1:numel(result) for j=(i+1):numel(result) assert(~isequal(result{i}, result{j}), 'the results %d and %d should not be equal', i, j); end end
# Data Visualization for Exploration This notebook details data visualization for exploring a dataset. The goal is to understand more about the data as a human, not to make beautiful graphs, communicate, or feature engineering input into models. ```python import pandas as pd import numpy as np import scipy.stats as st #ggplot equivalent: plotnine from plotnine import * #scales package equivalent: mizani from mizani.breaks import * from mizani.formatters import * #widgets from ipywidgets import interact, interactive, fixed, interact_manual import ipywidgets as widgets #utility import utils def clean_comma(x): return float(str(x).replace(',','')) ``` ```python ''' Snippet for plotnine with thai font by @korakot https://gist.github.com/korakot/01d181229b21411b0a20784e0ca20d3d ''' import matplotlib # !wget https://github.com/Phonbopit/sarabun-webfont/raw/master/fonts/thsarabunnew-webfont.ttf -q # !cp thsarabunnew-webfont.ttf /usr/share/fonts/truetype/ matplotlib.font_manager._rebuild() matplotlib.rc('font', family='TH Sarabun New') theme_set(theme_minimal(11, 'TH Sarabun New')); ``` ```python df = pd.read_csv('data/taladrod.csv') df['sales_price'] = df.sales_price.map(clean_comma) df['market_price'] = df.market_price.map(clean_comma) df.head() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>id</th> <th>brand</th> <th>series</th> <th>model</th> <th>gen</th> <th>year</th> <th>color</th> <th>gear</th> <th>gas</th> <th>sales_price</th> <th>original_price</th> <th>market_price</th> <th>description</th> <th>contact_location</th> <th>subscribers</th> <th>scraped_date</th> <th>removed_date</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>2210000</td> <td>HONDA</td> <td>JAZZ</td> <td>1.5 i-VTEC SV (AS)</td> <td>ปี08-13</td> <td>2014.0</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>NaN</td> <td>488000.0</td> <td>NaN</td> <td>NaN</td> <td>เครดิตดีออกรถ10,000จบครับ\nรับประกันเครื่องเกี...</td> <td>กรุงเทพฯ</td> <td>1047.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>1</th> <td>2210001</td> <td>TOYOTA</td> <td>ESTIMA</td> <td>2.4 G HYBRID</td> <td>ปี10-ปัจจุบัน</td> <td>2013.0</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>NaN</td> <td>1677000.0</td> <td>NaN</td> <td>3050000.0</td> <td>TOPสุด Estima Aeras Hybrid รถเข้าเซอร์วิส TOYO...</td> <td>กรุงเทพฯ</td> <td>182.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>2</th> <td>2210009</td> <td>HONDA</td> <td>JAZZ</td> <td>1.5 i-VTEC V (AS)</td> <td>ปี08-13</td> <td>2008.0</td> <td>สีน้ำเงิน</td> <td>เกียร์ออโต้</td> <td>NaN</td> <td>338000.0</td> <td>NaN</td> <td>NaN</td> <td>เครดิดีออกรถ10,000จบครับ\nรับประกันเครื่องเกีย...</td> <td>กรุงเทพฯ</td> <td>1047.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>3</th> <td>2210012</td> <td>FORD</td> <td>RANGER</td> <td>2.2 WILDTRAK DBL CAB HI-RIDER</td> <td>DOUBLECAB</td> <td>2016.0</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>NaN</td> <td>689000.0</td> <td>NaN</td> <td>849000.0</td> <td>รับรองสภาพ ไม่มีชน มือเดียว พาช่างมาตรวจสภาพรถ...</td> <td>กรุงเทพฯ</td> <td>760.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>4</th> <td>2210016</td> <td>TOYOTA</td> <td>SOLUNA</td> <td>VIOS 1.5 E (ABS+AB)</td> <td>VIOS ปี13-ปัจจุบัน</td> <td>2015.0</td> <td>สีบรอนซ์เงิน</td> <td>เกียร์ออโต้</td> <td>NaN</td> <td>359000.0</td> <td>NaN</td> <td>649000.0</td> <td>ไมล์แท้ 99,xxx TOYOTA SOLUNA VIOS 1.5E\nTOYOTA...</td> <td>กรุงเทพฯ</td> <td>699.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> </tbody> </table> </div> ## Warming Up: Missing Values We use grammar of graphics implementation `ggplot` (ported to Python as `plotnine`) to explore the `taladrod` dataset. Grammar of graphics is an especially useful tool since we do not know exactly what kind of plots we want to see and want to be able to add them up as we go. Source: [A Comprehensive Guide to the Grammar of Graphics for Effective Visualization of Multi-dimensional Data](https://towardsdatascience.com/a-comprehensive-guide-to-the-grammar-of-graphics-for-effective-visualization-of-multi-dimensional-1f92b4ed4149) ```python missing = utils.check_missing(df) missing['over90'] = missing.per_missing.map(lambda x: True if x>0.9 else False) missing.head() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>col_name</th> <th>per_missing</th> <th>rnk</th> <th>over90</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>original_price</td> <td>0.991380</td> <td>00_original_price</td> <td>True</td> </tr> <tr> <th>1</th> <td>gas</td> <td>0.936525</td> <td>01_gas</td> <td>True</td> </tr> <tr> <th>2</th> <td>removed_date</td> <td>0.886728</td> <td>02_removed_date</td> <td>False</td> </tr> <tr> <th>3</th> <td>market_price</td> <td>0.561658</td> <td>03_market_price</td> <td>False</td> </tr> <tr> <th>4</th> <td>subscribers</td> <td>0.000641</td> <td>04_subscribers</td> <td>False</td> </tr> </tbody> </table> </div> ```python g = (ggplot(missing,aes(x='rnk',y='per_missing',fill='over90')) + #base plot geom_col() + #type of plot geom_text(aes(x='rnk',y='per_missing+0.1',label='round(100*per_missing,2)')) +#annotate scale_y_continuous(labels=percent_format()) + #y-axis tick theme_minimal() + coord_flip()#theme and flipping plot ) g ``` ```python #drop columns with too many missing values df.drop(missing[missing.over90==True].col_name,1,inplace=True) df.head() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>id</th> <th>brand</th> <th>series</th> <th>model</th> <th>gen</th> <th>year</th> <th>color</th> <th>gear</th> <th>sales_price</th> <th>market_price</th> <th>description</th> <th>contact_location</th> <th>subscribers</th> <th>scraped_date</th> <th>removed_date</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>2210000</td> <td>HONDA</td> <td>JAZZ</td> <td>1.5 i-VTEC SV (AS)</td> <td>ปี08-13</td> <td>2014.0</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>488000.0</td> <td>NaN</td> <td>เครดิตดีออกรถ10,000จบครับ\nรับประกันเครื่องเกี...</td> <td>กรุงเทพฯ</td> <td>1047.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>1</th> <td>2210001</td> <td>TOYOTA</td> <td>ESTIMA</td> <td>2.4 G HYBRID</td> <td>ปี10-ปัจจุบัน</td> <td>2013.0</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>1677000.0</td> <td>3050000.0</td> <td>TOPสุด Estima Aeras Hybrid รถเข้าเซอร์วิส TOYO...</td> <td>กรุงเทพฯ</td> <td>182.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>2</th> <td>2210009</td> <td>HONDA</td> <td>JAZZ</td> <td>1.5 i-VTEC V (AS)</td> <td>ปี08-13</td> <td>2008.0</td> <td>สีน้ำเงิน</td> <td>เกียร์ออโต้</td> <td>338000.0</td> <td>NaN</td> <td>เครดิดีออกรถ10,000จบครับ\nรับประกันเครื่องเกีย...</td> <td>กรุงเทพฯ</td> <td>1047.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>3</th> <td>2210012</td> <td>FORD</td> <td>RANGER</td> <td>2.2 WILDTRAK DBL CAB HI-RIDER</td> <td>DOUBLECAB</td> <td>2016.0</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>689000.0</td> <td>849000.0</td> <td>รับรองสภาพ ไม่มีชน มือเดียว พาช่างมาตรวจสภาพรถ...</td> <td>กรุงเทพฯ</td> <td>760.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> <tr> <th>4</th> <td>2210016</td> <td>TOYOTA</td> <td>SOLUNA</td> <td>VIOS 1.5 E (ABS+AB)</td> <td>VIOS ปี13-ปัจจุบัน</td> <td>2015.0</td> <td>สีบรอนซ์เงิน</td> <td>เกียร์ออโต้</td> <td>359000.0</td> <td>649000.0</td> <td>ไมล์แท้ 99,xxx TOYOTA SOLUNA VIOS 1.5E\nTOYOTA...</td> <td>กรุงเทพฯ</td> <td>699.0</td> <td>2019-05-22</td> <td>NaN</td> </tr> </tbody> </table> </div> ## Categorical Variables We want to know primarily two things about our categorical variables: 1. How each variable is distributed 2. How each variable relate to the dependent variable * 2.1 when dependent variable is numerical * 2.2 when dependent variable is categorical ```python cat_vars = ['brand','series','gen','color','gear','contact_location'] cat_df = df[cat_vars].copy() cat_df.head() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>brand</th> <th>series</th> <th>gen</th> <th>color</th> <th>gear</th> <th>contact_location</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>HONDA</td> <td>JAZZ</td> <td>ปี08-13</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> </tr> <tr> <th>1</th> <td>TOYOTA</td> <td>ESTIMA</td> <td>ปี10-ปัจจุบัน</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> </tr> <tr> <th>2</th> <td>HONDA</td> <td>JAZZ</td> <td>ปี08-13</td> <td>สีน้ำเงิน</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> </tr> <tr> <th>3</th> <td>FORD</td> <td>RANGER</td> <td>DOUBLECAB</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> </tr> <tr> <th>4</th> <td>TOYOTA</td> <td>SOLUNA</td> <td>VIOS ปี13-ปัจจุบัน</td> <td>สีบรอนซ์เงิน</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> </tr> </tbody> </table> </div> To simplify the data cleaning step, we "otherify" values that appear less than 3% of the time in all categorical columns. ```python #otherify popular values; you can (should?) also have a mapping dict for col in cat_vars: cat_df = utils.otherify(cat_df,col,th=0.03) ``` ### Value Distribution Even without plotting them out, we can see the value distribution in each variable using `ipywidgets`. ```python interact(utils.value_dist, df =fixed(cat_df), col = widgets.Dropdown(options=list(cat_df.columns),value='brand')) ``` interactive(children=(Dropdown(description='col', options=('brand', 'series', 'gen', 'color', 'gear', 'contact… <function utils.value_dist(df, col)> **Exercise** Implement `cat_plot` function that plots value distribution for each categorical variable. ```python def cat_plot(df,col): return utils.cat_plot(df,col) #input dataframe and column #output histogram plot of value distribution interact(cat_plot, df=fixed(cat_df), col = widgets.Dropdown(options=list(cat_df.columns),value='brand')) ``` interactive(children=(Dropdown(description='col', options=('brand', 'series', 'gen', 'color', 'gear', 'contact… <function __main__.cat_plot(df, col)> ```python #excluding others def cat_plot_noothers(df,col): x = df.copy() x = x[x[col]!='others'] return utils.cat_plot(x,col) + utils.thai_text(8) interact(cat_plot_noothers, df=fixed(cat_df), col = widgets.Dropdown(options=list(cat_df.columns),value='gen')) ``` interactive(children=(Dropdown(description='col', index=2, options=('brand', 'series', 'gen', 'color', 'gear',… <function __main__.cat_plot_noothers(df, col)> ### Numerical and Categorical Variables ```python #relationship between dependent variable and categorical variable cat_df['sales_price'] = utils.boxcox(df['sales_price']) cat_df.head() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>brand</th> <th>series</th> <th>gen</th> <th>color</th> <th>gear</th> <th>contact_location</th> <th>sales_price</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>HONDA</td> <td>others</td> <td>ปี08-13</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> <td>13.056226</td> </tr> <tr> <th>1</th> <td>TOYOTA</td> <td>others</td> <td>others</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> <td>14.320520</td> </tr> <tr> <th>2</th> <td>HONDA</td> <td>others</td> <td>ปี08-13</td> <td>others</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> <td>12.669810</td> </tr> <tr> <th>3</th> <td>FORD</td> <td>others</td> <td>others</td> <td>สีขาว</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> <td>13.413541</td> </tr> <tr> <th>4</th> <td>TOYOTA</td> <td>SOLUNA</td> <td>others</td> <td>สีบรอนซ์เงิน</td> <td>เกียร์ออโต้</td> <td>กรุงเทพฯ</td> <td>12.733758</td> </tr> </tbody> </table> </div> ```python #relationship between sales price and color cat_df.groupby('color').sales_price.describe() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>count</th> <th>mean</th> <th>std</th> <th>min</th> <th>25%</th> <th>50%</th> <th>75%</th> <th>max</th> </tr> <tr> <th>color</th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <th>others</th> <td>1756.0</td> <td>12.568359</td> <td>1.019319</td> <td>0.000000</td> <td>12.072547</td> <td>12.542548</td> <td>13.028055</td> <td>16.905644</td> </tr> <tr> <th>สีขาว</th> <td>4207.0</td> <td>13.085453</td> <td>0.940839</td> <td>0.000000</td> <td>12.672950</td> <td>13.005832</td> <td>13.498058</td> <td>16.438729</td> </tr> <tr> <th>สีดำ</th> <td>2848.0</td> <td>13.071142</td> <td>0.913027</td> <td>0.000000</td> <td>12.594734</td> <td>13.014780</td> <td>13.535466</td> <td>16.111071</td> </tr> <tr> <th>สีน้ำตาล</th> <td>607.0</td> <td>12.660002</td> <td>0.814474</td> <td>8.853808</td> <td>12.144203</td> <td>12.782689</td> <td>13.140205</td> <td>15.635210</td> </tr> <tr> <th>สีบรอนซ์เงิน</th> <td>1879.0</td> <td>12.760100</td> <td>0.923268</td> <td>0.000000</td> <td>12.421188</td> <td>12.779876</td> <td>13.151924</td> <td>15.854130</td> </tr> <tr> <th>สีเทา</th> <td>2740.0</td> <td>12.786451</td> <td>0.957211</td> <td>0.000000</td> <td>12.421188</td> <td>12.818555</td> <td>13.188621</td> <td>17.822480</td> </tr> </tbody> </table> </div> **Exercise** Implement `numcat_plot` function that plots the relationship between a dependent numerical variable and an independent categorical as displayed above. Useful geoms are `geom_boxplot`, `geom_violin` and `geom_jitter`. Optionally remove outliers before plotting. ```python def numcat_plot(df,num,cat, no_outliers=True, geom=geom_boxplot()): return utils.numcat_plot(df,num,cat, no_outliers, geom) #plot the summary above ``` ```python interact(numcat_plot, df=fixed(cat_df), num=fixed('sales_price'), no_outliers = widgets.Checkbox(value=True), geom=fixed(geom_boxplot()), #geom_violin, geom_jitter cat= widgets.Dropdown(options=list(cat_df.columns)[:-1],value='gen')) ``` interactive(children=(Dropdown(description='cat', index=2, options=('brand', 'series', 'gen', 'color', 'gear',… <function __main__.numcat_plot(df, num, cat, no_outliers=True, geom=<plotnine.geoms.geom_boxplot.geom_boxplot object at 0x7fa9a455f358>)> ```python interact(numcat_plot, df=fixed(cat_df), num=fixed('sales_price'), no_outliers = widgets.Checkbox(value=True), geom=fixed(geom_violin()), #geom_violin, geom_jitter cat= widgets.Dropdown(options=list(cat_df.columns)[:-1],value='series')) ``` interactive(children=(Dropdown(description='cat', index=1, options=('brand', 'series', 'gen', 'color', 'gear',… <function __main__.numcat_plot(df, num, cat, no_outliers=True, geom=<plotnine.geoms.geom_boxplot.geom_boxplot object at 0x7fa9a455f358>)> Sometimes we want to see the numerical distribution filled with categories. This is especially useful plotting the results of a binary classification. ```python def numdist_plot(df, num,cat, geom=geom_density(alpha=0.5), no_outliers=True): return utils.numdist_plot(df, num, cat, geom, no_outliers) #either #density: geom_density(alpha=0.5) #histogram: geom_histogram(binwidth=0.5, position='identity',alpha=0.5) #position: identity or dodge numdist_plot(cat_df,'sales_price','gear') ``` ```python numdist_plot(cat_df,'sales_price','gear', geom=geom_histogram(binwidth=0.5, position='dodge',alpha=0.5)) ``` ### Categorical and Categorical Variables **Exercise** We can cross-tabulate categorical variables to see their relationship by using `facet_wrap`; for instance, if our dependent variable is `gear` and indpendent variable of interest is `color`. ```python def catcat_plot(df, cat_dep, cat_ind): return utils.catcat_plot(df,cat_dep,cat_ind) ``` ```python interact(catcat_plot, df=fixed(cat_df), cat_dep=widgets.Dropdown(options=list(cat_df.columns)[:-1],value='gear'), cat_ind= widgets.Dropdown(options=list(cat_df.columns)[:-1],value='color')) ``` interactive(children=(Dropdown(description='cat_dep', index=4, options=('brand', 'series', 'gen', 'color', 'ge… <function __main__.catcat_plot(df, cat_dep, cat_ind)> ### Multiple Ways of Relationships You can use `facet_grid` to display multiple ways of relationships; but keep in mind that this is probably what your model is doing anyways so it might not be most human-readable plot to explore. ```python #getting fancy; not necessarily the best idea new_df = utils.remove_outliers(cat_df,'sales_price') g = (ggplot(new_df, aes(x='gen',y='sales_price')) + geom_boxplot() + theme_minimal() + facet_grid('contact_location~color') + theme(axis_text_x = element_text(angle = 90, hjust = 1)) ) + utils.thai_text(8) g ``` ## Numerical Variables We want to know two things about numerical variables: 1. Their distributions 2. Their relationships with one another; possibly this involves transforming variables to make them less skewed aka more difficult to see variations ```python import datetime now = datetime.datetime.now() df['nb_year'] = now.year - df['year'] num_vars = ['nb_year','sales_price','market_price','subscribers'] num_df = df[num_vars].dropna() #this is why you need to deal with missing values BEFORE exploration num_df.describe() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>nb_year</th> <th>sales_price</th> <th>market_price</th> <th>subscribers</th> </tr> </thead> <tbody> <tr> <th>count</th> <td>6150.000000</td> <td>6.150000e+03</td> <td>6.150000e+03</td> <td>6150.000000</td> </tr> <tr> <th>mean</th> <td>4.512195</td> <td>7.120724e+05</td> <td>1.333557e+06</td> <td>525.634959</td> </tr> <tr> <th>std</th> <td>2.026358</td> <td>7.745356e+05</td> <td>1.288468e+06</td> <td>386.841217</td> </tr> <tr> <th>min</th> <td>0.000000</td> <td>1.000000e+00</td> <td>3.690000e+05</td> <td>1.000000</td> </tr> <tr> <th>25%</th> <td>3.000000</td> <td>3.390010e+05</td> <td>6.490000e+05</td> <td>191.250000</td> </tr> <tr> <th>50%</th> <td>5.000000</td> <td>4.790010e+05</td> <td>8.770000e+05</td> <td>423.000000</td> </tr> <tr> <th>75%</th> <td>6.000000</td> <td>7.590010e+05</td> <td>1.445000e+06</td> <td>772.000000</td> </tr> <tr> <th>max</th> <td>8.000000</td> <td>1.297000e+07</td> <td>1.645000e+07</td> <td>1469.000000</td> </tr> </tbody> </table> </div> `seaborn` has an excellent `pairplot` implementation which not only shows the distribution of values but also their relathionships. It seems like we can get what we want easily; however, as we can see `sales_price` and `market_price` are a little skewed, making it more difficult to see their relationships with other more spread out variables. ```python import seaborn as sns sns.pairplot(num_df) #non-normal data is a problem! ``` In a lot of cases, a variable with normally distributed values have more variations and easier for us to see their relationships with other variables. We will try to transform our skewed variables to more "normal" ones to see if that helps. **Q-Q plot** compares two probability distributions by plotting their quantiles against each other. We can use this to determine the normality of a variable by plotting the sample quantiles (from the data we have) against its theoretical quantiles (where the quantiles would be if the variable is normally distributed). ```python interact(utils.qq_plot, df=fixed(num_df), col=widgets.Dropdown(options=list(num_df.columns))) ``` interactive(children=(Dropdown(description='col', options=('nb_year', 'sales_price', 'market_price', 'subscrib… <function utils.qq_plot(df, col)> **Box-Cox transformation** is a statistical technique used to make data look like more normally distributed. \begin{align} g_\lambda(y) = \left\{ \begin{array}{lr}\displaystyle\frac{y^\lambda - 1}{\lambda} & \lambda \neq 0\\ & \\ \log(y) & \lambda = 0 \end{array} \right. \end{align} **Exercise** Implement `boxcox` transformation according to the equation above. ```python def boxcox(ser,lamb=0): pass #input a column from pandas dataframe #output transformed column ``` One way of choosing the hyperparameter $\lambda$ is to look at the Q-Q plot and choose transformation which makes the slope closest to 1. ```python #see transformation results def what_lamb(df,col,lamb): sample_df = df.copy() former_g = utils.qq_plot(sample_df,col) sample_df[col] = utils.boxcox(sample_df[col],lamb) print(utils.qq_plot(sample_df,col),former_g) interact(what_lamb, df=fixed(num_df), col=widgets.Dropdown(options=list(num_df.columns),value='sales_price'), lamb=widgets.FloatSlider(min=-3,max=3,step=0.5,value=0) ) ``` interactive(children=(Dropdown(description='col', index=1, options=('nb_year', 'sales_price', 'market_price', … <function __main__.what_lamb(df, col, lamb)> This can also be automated by plotting a slope for each arbitary $\lambda$; for instance from -3 to 3. ```python lamb_df = utils.boxcox_lamb_df(num_df.subscribers) interact(utils.boxcox_plot, df=fixed(num_df), col=widgets.Dropdown(options=list(num_df.columns),value='sales_price'), ls=fixed([i/10 for i in range(-30,31,5)]) ) ``` interactive(children=(Dropdown(description='col', index=1, options=('nb_year', 'sales_price', 'market_price', … <function utils.boxcox_plot(df, col, ls=[-3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0])> ```python #transform sales and market prices for col in ['sales_price','market_price']: num_df['new_'+col] = utils.boxcox(num_df[col], utils.boxcox_lamb(num_df[col])) ``` You can see that post transformation, we can see the (lack of) relationships between variables clearer. ```python sns.pairplot(num_df[['nb_year','new_sales_price','new_market_price','subscribers']]) #a little better! ``` For our example, we have only four numerical variables; but imagine when you have ten or more. You may want to plot their distributions separately from relationships. ```python num_m = num_df.melt() num_m.head() ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>variable</th> <th>value</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>nb_year</td> <td>6.0</td> </tr> <tr> <th>1</th> <td>nb_year</td> <td>3.0</td> </tr> <tr> <th>2</th> <td>nb_year</td> <td>4.0</td> </tr> <tr> <th>3</th> <td>nb_year</td> <td>4.0</td> </tr> <tr> <th>4</th> <td>nb_year</td> <td>7.0</td> </tr> </tbody> </table> </div> **Exercise** Implement `value_dist_plot` to plot value distribution of all variables. ```python def value_dist_plot(df,bins=30): return utils.value_dist_plot(df,bins) #input dataframe with only numerical variables #output distribution plot for each variable value_dist_plot(num_df) ``` Likewise in case there are too many pairs of relationships, you might plot the relationships pair-by-pair with `ipywidget` and `seaborn`'s `jointplot` function. ```python interact(utils.jointplot, df=fixed(num_df), col_x= widgets.Dropdown(options=list(num_df.columns),value='sales_price'), col_y=widgets.Dropdown(options=list(num_df.columns),value='market_price'), kind=widgets.Dropdown(options=['scatter','resid','reg','hex','kde','point'],value='scatter')) ``` interactive(children=(Dropdown(description='col_x', index=1, options=('nb_year', 'sales_price', 'market_price'… <function utils.jointplot(df, col_x, col_y, no_outliers=True, kind='reg')> As you might have noticed, we have not used any statistical concept to describe the relationship, and that is by design. We can also see correlation table with a simple `pandas` function: ```python #correlation plot if you must; but it's just ONE number for the relationship num_df.corr(method='pearson').style.background_gradient(cmap='coolwarm') ``` <style type="text/css" > #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col0 { background-color: #b40426; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col1 { background-color: #3b4cc0; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col2 { background-color: #4a63d3; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col3 { background-color: #84a7fc; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col4 { background-color: #3b4cc0; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col5 { background-color: #3b4cc0; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col0 { background-color: #465ecf; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col1 { background-color: #b40426; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col2 { background-color: #df634e; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col3 { background-color: #3b4cc0; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col4 { background-color: #c0282f; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col5 { background-color: #e97a5f; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col0 { background-color: #7ea1fa; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col1 { background-color: #d95847; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col2 { background-color: #b40426; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col3 { background-color: #3e51c5; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col4 { background-color: #d95847; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col5 { background-color: #c73635; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col0 { background-color: #aec9fc; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col1 { background-color: #5e7de7; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col2 { background-color: #3b4cc0; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col3 { background-color: #b40426; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col4 { background-color: #7b9ff9; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col5 { background-color: #4a63d3; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col0 { background-color: #3b4cc0; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col1 { background-color: #c12b30; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col2 { background-color: #df634e; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col3 { background-color: #4b64d5; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col4 { background-color: #b40426; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col5 { background-color: #da5a49; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col0 { background-color: #7da0f9; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col1 { background-color: #e36b54; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col2 { background-color: #c53334; color: #f1f1f1; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col3 { background-color: #5b7ae5; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col4 { background-color: #d44e41; color: #000000; } #T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col5 { background-color: #b40426; color: #f1f1f1; }</style><table id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0b" ><thead> <tr> <th class="blank level0" ></th> <th class="col_heading level0 col0" >nb_year</th> <th class="col_heading level0 col1" >sales_price</th> <th class="col_heading level0 col2" >market_price</th> <th class="col_heading level0 col3" >subscribers</th> <th class="col_heading level0 col4" >new_sales_price</th> <th class="col_heading level0 col5" >new_market_price</th> </tr></thead><tbody> <tr> <th id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0blevel0_row0" class="row_heading level0 row0" >nb_year</th> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col0" class="data row0 col0" >1</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col1" class="data row0 col1" >-0.220633</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col2" class="data row0 col2" >-0.00786656</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col3" class="data row0 col3" >0.163404</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col4" class="data row0 col4" >-0.275434</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow0_col5" class="data row0 col5" >-0.0152819</td> </tr> <tr> <th id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0blevel0_row1" class="row_heading level0 row1" >sales_price</th> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col0" class="data row1 col0" >-0.220633</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col1" class="data row1 col1" >1</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col2" class="data row1 col2" >0.862739</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col3" class="data row1 col3" >-0.07795</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col4" class="data row1 col4" >0.955499</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow1_col5" class="data row1 col5" >0.819534</td> </tr> <tr> <th id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0blevel0_row2" class="row_heading level0 row2" >market_price</th> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col0" class="data row2 col0" >-0.00786656</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col1" class="data row2 col1" >0.862739</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col2" class="data row2 col2" >1</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col3" class="data row2 col3" >-0.063786</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col4" class="data row2 col4" >0.858924</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow2_col5" class="data row2 col5" >0.948289</td> </tr> <tr> <th id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0blevel0_row3" class="row_heading level0 row3" >subscribers</th> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col0" class="data row3 col0" >0.163404</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col1" class="data row3 col1" >-0.07795</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col2" class="data row3 col2" >-0.063786</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col3" class="data row3 col3" >1</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col4" class="data row3 col4" >-0.0165204</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow3_col5" class="data row3 col5" >0.039791</td> </tr> <tr> <th id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0blevel0_row4" class="row_heading level0 row4" >new_sales_price</th> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col0" class="data row4 col0" >-0.275434</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col1" class="data row4 col1" >0.955499</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col2" class="data row4 col2" >0.858924</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col3" class="data row4 col3" >-0.0165204</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col4" class="data row4 col4" >1</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow4_col5" class="data row4 col5" >0.882803</td> </tr> <tr> <th id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0blevel0_row5" class="row_heading level0 row5" >new_market_price</th> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col0" class="data row5 col0" >-0.0152819</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col1" class="data row5 col1" >0.819534</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col2" class="data row5 col2" >0.948289</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col3" class="data row5 col3" >0.039791</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col4" class="data row5 col4" >0.882803</td> <td id="T_1d00e18a_85e2_11e9_b01d_1d76819b2e0brow5_col5" class="data row5 col5" >1</td> </tr> </tbody></table> ```python def pearson_corr(x,y): sub_x = x - x.mean() sub_y = y - y.mean() return (sub_x * sub_y).sum() / np.sqrt((sub_x**2).sum() * (sub_y**2).sum()) #spearman and kendall: pearson with rank variables pearson_corr(df.nb_year,df.sales_price) ``` -0.23316757399518453 However, the famous Anscombe plots show us that it is always better to look at distribution rather than a summary number. Source: [A Comprehensive Guide to the Grammar of Graphics for Effective Visualization of Multi-dimensional Data](https://towardsdatascience.com/a-comprehensive-guide-to-the-grammar-of-graphics-for-effective-visualization-of-multi-dimensional-1f92b4ed4149) ```python ```
\documentclass{\TEX/ug/ug} \usepackage{float} \usepackage{color, colortbl} \usepackage[section]{placeins} \usepackage{mathtools} \usepackage{amsthm} %\usepackage[T1]{helvet} \usepackage[OT1]{fontenc} \usepackage{array} \usepackage[binary-units=true]{siunitx} \usepackage{subcaption} \usepackage{caption,tabularx,booktabs} \usepackage{longtable} \usepackage[all]{nowidow} \widowpenalty10000 \clubpenalty10000 \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} \graphicspath{ {./figures/} } \input{../title} \category{User Guide, \input{version.tex}, Build \input{shortHash.tex}} %\confidential{} \input{\TEX/color} \begin{document} \maketitle \cleardoublepage \tableofcontents \listoftables \listoffigures \cleardoublepage \section{Introduction} \label{sec:intro} \input{../intro} \section{Symbol} \label{sec:symb} \input{\TEX/ug/symb} \section{Features} \label{sec:feat} \input{../features} \section{Benefits} \label{sec:benef} \input{../benefits} \section{Deliverables} \label{sec:deliv} \input{../deliverables} \section{Block Diagram and Description} \label{sec:bdd} \input{\TEX/ug/bdd} \section{Interface Signals} \label{sec:ifsig} \input{./if} %timing diagrams \ifdefined\TD \section{Timing Diagrams} \label{sec:td} \input{./td} \fi %software components \ifdefined\SW \section{Software Driver} \label{sec:sw} \input{\TEX/ug/sw} \fi \section{Instantiation and External Circuitry} \label{sec:inst} \input{\TEX/ug/inst} \section{Simulation} \label{sec:tbbd} \input{\TEX/ug/sim} \section{Synthesis} \label{sec:synth} \input{\TEX/ug/synth} \section{Implementation Results} \label{sec:results} \input{\TEX/results} \ifdefined\CUSTOM \input{custom} \fi \end{document}
Jill, Kaia and I have been planning to get away to the coast for weeks, with our busy lives it took us a bit longer than we had hoped but it was so worth it! We hit the road at 3pm on Friday and headed to Coolum Seaside Resort to check out our 2 bedroom apartment we had booked for the night, right in the middle of town. Sandie, the lovely host, welcomed us and we found our spacious apartment tucked away in lush gardens. We quickly checked out the beach right at the end of the road ready for the morning. Kaia was quick to pop open a bottle of sparkling rose on the balcony and we sat down to enjoy the sunset and catch up. Once the sun was set we were up and off to Canteen, a buzzing bar just a block and a half away for cocktails! Canteen has a funky area out the front where you can lounge on cushions watching the world go by as you sip on your bevvies. We had booked Harvest for dinner, only a 5-minute walk down the road. Everything is close by in Coolum, with bars, restaurants and shopping along the central strip, right across from the beach. Harvest had been recommended by a few friends and while it wasn’t what we had expected when we arrived, the wine list and entrees surely made up for it. You can read about that here. After dinner (and dessert) we strolled to The Coolum Hotel. Hot tip: do NOT wear thongs (jandals / flip flops) if you want to get in. With that option out of the way and the knowledge we had another bottle of champagne chilling in the fridge, it was an easy decision to chill out back at the apartment. A few glasses of bubbles later and some green tea, (could have cooked a feast in the massive kitchen!) it was bed time. We woke up fresh and hungry, devoured breakfast at My Place, with a view of the beach and great food. Hitting the pool (one of the three), spa and tennis court were next on the agenda for the getaway. We jumped in the first pool, had a spa and tried out the outdoor shower where a little lizard friend wanted to get in on the action. The next pool and spa were my favourite, right next to the tennis courts so you can watch the game while you soak in the spa and then cool off in the pool. There was a great BBQ area there too, if I was staying another night I would have bought in some food to enjoy poolside with a nice, ice cold beer. I learnt very quickly that I’m terrible at tennis. Hilariously, I managed to hit three out of our four balls into the pool in about 20 minutes. Amused, I sat the last one out so the girls could have a proper hit without my …. lack of coordination. There’s a gym and a business centre at the hotel too but they didn’t fit in with our champagne and spa schedule this time. Although I did have good intentions and had packed my runners. Will have to be on my next visit, as I am definitely going back! Strawberry and Nutella calzone – tick, tick tick! After a lovely, leisurely day hitting the beach and checking out the shops at Shoppingworld, my girlfriends and I headed to Groove Train Kawana Waters for a bite to eat and a wind down wine. We had been really impressed with the variety of shops at Kawana Shoppingworld, with some of our favourite stores for fashion and beauty buys and we needed a debrief. We chose a table outside the restaurant, perfect for people watching and with a beautiful, cool breeze. As a regular holiday maker to the Sunshine Coast, I’m always looking for great places to kick back and enjoy some beverages and great food with friends. A large menu is always important for me as everyone has different tastes and food requirements or allergies. As luck would have it, their menu had something for everyone. We all explored the menu, tossing in ideas of sharing plates so we could taste everything as it all sounded so good. I ended up picking an old time favourite of mine, the pumpkin and spinach risotto. Boy, did it not disappoint! Lightly creamy and full of flavour. Obviously, I paired it with a glass of red, a lovely cab sav that was recommended by our waitress. I noticed a large range of beers there too, will have to bring the boys next time! The girls went on the fresh side (something about this warmer weather) and chose a seared beef salad and a Thai calamari salad to share. The salads which, of course I tried, were refreshing and light. I think I favoured the calamari best. For dessert I can never go past the chocolatey calzone… it’s full of Nutella and strawberries. Delightfully warm, melted Nutella and strawberries in a beautiful, crisp calzone with ice cream on the side – cue drooling! A bunch of big ticks for me! We will definitely be back soon. Yup, you read that right, Mudjimba. It’s on the Sunny Coast about 15 mins past Mooloolaba. After some unexpected circumstances saw us lose our preplanned weekend accomodation at the last minute, we were all so devastated at the thought of not going away we had to find something else. Mudjimba it was! We rented a three bedroom apartment at Santorini Twin Waters for two nights. The apartment was huge with a beautiful deck looking out to the ocean. The first night Ka Lei, Kieran and I ate pasta and drank champagne. We bought champagne for about ten people and found a pet snail in our mint while preparing dinner. I walked along the beach in the morning and Nikki, Lisa and Scott joined us for the second night. We had dinner across the road from our hotel that night and while the food wasn’t amazing, the company was great. Sunday we tried a place for brunch that had us wait far too long (read super hanrgy), followed by more beach time, another lunch at the Spit and some light shopping. Oh and gelato! Can’t forget the delicious choc and raspberry dairy free gelato!
module Numeral.Ordinal where import Lvl open import Numeral.Natural open import Syntax.Function open import Type private variable ℓ : Lvl.Level private variable T : Type{ℓ} -- Ordinal numbers up to a certain level as a type. -- 𝟎 is the zero ordinal, the smallest ordinal number. -- 𝐒 is the successor ordinal function, the smallest ordinal greater than the given argument. -- lim is the limit ordinal function, the "limit" of the given sequence. The smallest ordinal greater than all values of the given sequence. Note that this is not the usual definition of a "limit ordinal" because `lim` allows arbitrary sequences, specifically those with a maximum, resulting in an equivalent to the successor ordinal `𝐒` (TODO: If this is the case, then 𝐒 is actually unnecessary? Just define it by (lim ∘ const)? -- Note: Usually the indexing in a limit ordinal should be the class of ordinals before it, so this definition is probably unable to express all ordinals. data Ordinal(T : Type{ℓ}) : Type{ℓ} where 𝟎 : Ordinal(T) 𝐒 : Ordinal(T) → Ordinal(T) lim : (T → Ordinal(T)) → Ordinal(T) {- data Ordinal' : (ℓ : Lvl.Level) → Typeω where 𝟎 : Ordinal'(ℓ) 𝐒 : Ordinal'(ℓ) → Ordinal'(ℓ) lim : (Ordinal'(ℓ) → Ordinal'(Lvl.𝐒(ℓ))) → Ordinal'(Lvl.𝐒(ℓ)) -- When the next ordinal have the current ordinal as its index data Ordinal(T : Type{ℓ}) : Type{ℓ} where 𝟎 : Ordinal(T) lim : (T → Ordinal(T)) → Ordinal(T) -- 𝐒 is expressable through lim data Ordinal(T : Type{ℓ}) : Type{ℓ} where 𝟎 : Ordinal(T) 𝐒 : Ordinal(T) → Ordinal(T) lim : (f : T → Ordinal(T)) → ∃(IncreasingSubsequence(_<_)(f)) → Ordinal(T) -- This excludes the cases where f have a maximum, resulting in no intersection between 𝐒 and lim -} _+_ : Ordinal(T) → Ordinal(T) → Ordinal(T) x + 𝟎 = x x + 𝐒(y) = 𝐒(x + y) x + lim f = lim(y ↦ (x + f(y))) _⋅_ : Ordinal(T) → Ordinal(T) → Ordinal(T) x ⋅ 𝟎 = 𝟎 x ⋅ 𝐒(y) = (x ⋅ y) + x x ⋅ lim f = lim(y ↦ (x ⋅ f(y))) _^_ : Ordinal(T) → Ordinal(T) → Ordinal(T) x ^ 𝟎 = x x ^ 𝐒(y) = (x ^ y) ⋅ x x ^ lim f = lim(y ↦ (x ^ f(y))) open import Logic.Propositional private variable x y z x₁ x₂ y₁ y₂ z₁ z₂ : Ordinal(T) module _ {T : Type{ℓ}} where open import Functional open import Logic.Propositional -- TODO: Not sure if this is correct data _<_ : Ordinal(T) → Ordinal(T) → Type{ℓ} where minimal : ∀{x} → (𝟎 < 𝐒(x)) step : ∀{x y} → (x < y) → (𝐒(x) < 𝐒(y)) limitₗ : ∀{f}{x} → (∀{i} → (f(i) < x)) → (lim f < 𝐒(x)) limitᵣ : ∀{i}{f}{x} → (x < 𝐒(f(i))) → (x < lim f) _>_ = swap(_<_) _≤_ : Ordinal(T) → Ordinal(T) → Type x ≤ y = x < 𝐒(y) _≥_ = swap(_≤_) _≡_ : Ordinal(T) → Ordinal(T) → Type x ≡ y = (y ≤ x) ∧ (x ≤ y) open import Numeral.Natural.Induction from-ℕ : ℕ → Ordinal(T) from-ℕ = ℕ-elim 𝟎 (const 𝐒) _+ₙ_ : Ordinal(T) → ℕ → Ordinal(T) _+ₙ_ x = ℕ-elim x (const 𝐒) private variable f g : T → Ordinal(T) private variable n : T [<]-limitₗ-inv : (lim f < 𝐒(x)) → (∀{n} → (f(n) < x)) [<]-limitₗ-inv (limitₗ p) = p open import Logic.Predicate open import Type.Properties.Inhabited [<]-limitᵣ-inv : (x < lim f) → ∃(n ↦ (x < 𝐒(f(n)))) [<]-limitᵣ-inv (limitᵣ{n} p) = [∃]-intro n ⦃ p ⦄ [<]-lim-minimal : ⦃ ◊ T ⦄ → (𝟎 < lim f) [<]-lim-minimal = limitᵣ{i = [◊]-existence} minimal [<]-lim-maximum : (f(n) < lim f) [<]-of-step : (x < 𝐒(x)) [<]-lim-maximum{f}{n} = limitᵣ{n} [<]-of-step [<]-without-step : (𝐒(x) < 𝐒(y)) → (x < y) [<]-without-step (step p) = p [<]-of-step {𝟎} = minimal [<]-of-step {𝐒(x)} = step [<]-of-step [<]-of-step {lim f} = limitₗ [<]-lim-maximum [<]-transitivity : (x < y) → (y < z) → (x < z) [<]-transitivity minimal (step yz) = minimal [<]-transitivity minimal (limitᵣ {n}{f} yz) = limitᵣ {n}{f} minimal [<]-transitivity (step xy) (step yz) = step ([<]-transitivity xy yz) [<]-transitivity (step xy) (limitᵣ yz) = limitᵣ ([<]-transitivity (step xy) yz) [<]-transitivity (limitₗ xy) (step yz) = limitₗ ([<]-transitivity xy yz) [<]-transitivity (limitₗ xy) (limitᵣ yz) = limitᵣ (limitₗ ([<]-without-step([<]-transitivity (step xy) yz))) [<]-transitivity (limitᵣ xy) (limitₗ yz) = [<]-transitivity xy (step yz) [<]-transitivity (limitᵣ xy) (limitᵣ yz) = limitᵣ ([<]-transitivity (limitᵣ xy) yz) [<]-stepᵣ : (x < y) → (x < 𝐒(y)) [<]-stepᵣ minimal = minimal [<]-stepᵣ (step p) = step ([<]-stepᵣ p) [<]-stepᵣ (limitₗ p) = limitₗ ([<]-stepᵣ p) [<]-stepᵣ (limitᵣ p) = [<]-transitivity p (step [<]-lim-maximum) [<]-to-[≤] : (x < y) → (x ≤ y) [<]-to-[≤] = [<]-stepᵣ [<]-irreflexivity : ¬(x < x) [<]-irreflexivity (step p) = [<]-irreflexivity p [<]-irreflexivity (limitᵣ (limitₗ x)) = [<]-irreflexivity x [<]-asymmetry : (x < y) → (y < x) → ⊥ [<]-asymmetry xy yx = [<]-irreflexivity([<]-transitivity xy yx) [<]-without-stepₗ : (𝐒(x) < y) → (x < y) [<]-without-stepₗ (step p) = [<]-stepᵣ p [<]-without-stepₗ (limitᵣ p) = limitᵣ ([<]-without-stepₗ p) [<]-no-less-than-minimum : ¬(x < 𝟎) [<]-no-less-than-minimum () [≤]-minimal : (𝟎 ≤ x) [≤]-minimal = minimal [≤]-step : (x ≤ y) → (𝐒(x) ≤ 𝐒(y)) [≤]-step = step [≤]-reflexivity : (x ≤ x) [≤]-reflexivity = [<]-of-step [≡]-reflexivity : (x ≡ x) [≡]-reflexivity = [∧]-intro [≤]-reflexivity [≤]-reflexivity open import Logic.Propositional.Theorems [≡]-symmetry : (x ≡ y) → (y ≡ x) [≡]-symmetry = [∧]-symmetry [≡]-step : (x ≡ y) → (𝐒(x) ≡ 𝐒(y)) [≡]-step = [∧]-map step step open import Relator.Equals renaming (_≡_ to _≡ₑ_) [<]-less-than-one : ⦃ ◊ T ⦄ → (x < 𝐒(𝟎)) → (x ≡ₑ 𝟎) [<]-less-than-one minimal = [≡]-intro [<]-less-than-one (limitₗ p) with () ← p{[◊]-existence} [<][≤]-semitransitivityₗ : ⦃ ◊ T ⦄ → (x ≤ y) → (y < z) → (x < z) [<][≤]-semitransitivityₗ {_} {y} {.(lim _)} xy (limitᵣ yz) = limitᵣ ([<][≤]-semitransitivityₗ xy yz) [<][≤]-semitransitivityₗ {.𝟎} {.𝟎} {.(𝐒 _)} minimal minimal = minimal [<][≤]-semitransitivityₗ {.𝟎} {.(𝐒 _)} {.(𝐒 _)} minimal (step yz) = minimal [<][≤]-semitransitivityₗ {.𝟎} {.(lim _)} {.(𝐒 _)} minimal (limitₗ x) = minimal [<][≤]-semitransitivityₗ {.(𝐒 _)} {.(𝐒 _)} {.(𝐒 _)} (step xy) (step yz) = step ([<][≤]-semitransitivityₗ xy yz) [<][≤]-semitransitivityₗ {.(𝐒 _)} {.(lim _)} {.(𝐒 _)} (step (limitᵣ xy)) (limitₗ yz) = step ([<][≤]-semitransitivityₗ xy yz) [<][≤]-semitransitivityₗ {.(lim _)} {.𝟎} {.(𝐒 _)} (limitₗ xy) minimal with () ← xy{[◊]-existence} [<][≤]-semitransitivityₗ {.(lim _)} {.(𝐒 _)} {.(𝐒 _)} (limitₗ xy) (step yz) = limitₗ ([<][≤]-semitransitivityₗ xy yz) [<][≤]-semitransitivityₗ {.(lim _)} {.(lim _)} {.(𝐒 _)} (limitₗ xy) (limitₗ yz) = limitₗ ([<][≤]-semitransitivityₗ ([∃]-proof([<]-limitᵣ-inv xy)) yz) [≤]-transitivity : ⦃ ◊ T ⦄ → (x ≤ y) → (y ≤ z) → (x ≤ z) [≤]-transitivity = [<][≤]-semitransitivityₗ [≡]-transitivity : ⦃ ◊ T ⦄ → (x ≡ y) → (y ≡ z) → (x ≡ z) [≡]-transitivity ([∧]-intro yx xy) ([∧]-intro zy yz) = [∧]-intro ([≤]-transitivity zy yx) ([≤]-transitivity xy yz) [<][≤]-semitransitivityᵣ : ⦃ ◊ T ⦄ → (x < y) → (y ≤ z) → (x < z) [<][≤]-semitransitivityᵣ {.𝟎} {.(𝐒 𝟎)} {.(𝐒 _)} minimal (step minimal) = minimal [<][≤]-semitransitivityᵣ {.𝟎} {.(𝐒 (𝐒 _))} {.(𝐒 _)} minimal (step (step yz)) = minimal [<][≤]-semitransitivityᵣ {.𝟎} {.(𝐒 (lim _))} {.(𝐒 _)} minimal (step (limitₗ yz)) = minimal [<][≤]-semitransitivityᵣ {.𝟎} {.(𝐒 _)} {.(lim _)} minimal (step (limitᵣ yz)) = limitᵣ{[◊]-existence} minimal [<][≤]-semitransitivityᵣ {.(𝐒 _)} {.(𝐒 _)} {𝐒 z} (step xy) (step yz) = step ([<][≤]-semitransitivityᵣ xy yz) [<][≤]-semitransitivityᵣ {.(𝐒 _)} {.(𝐒 _)} {lim z} (step xy) (step (limitᵣ yz)) = limitᵣ (step ([<][≤]-semitransitivityᵣ xy yz)) [<][≤]-semitransitivityᵣ {.(lim _)} {.(𝐒 _)} {𝐒 z} (limitₗ xy) (step yz) = limitₗ ([<][≤]-semitransitivityᵣ xy yz) [<][≤]-semitransitivityᵣ {.(lim _)} {.(𝐒 _)} {lim z} (limitₗ xy) (step (limitᵣ yz)) = limitᵣ ([<][≤]-semitransitivityᵣ (limitₗ xy) (step yz)) [<][≤]-semitransitivityᵣ {x} {.(lim _)} {z} (limitᵣ xy) (limitₗ yz) = [<][≤]-semitransitivityᵣ xy (step yz) {- StrictlyIncreasingSubsequenceExistence : ∀{ℓ}{I : Type{ℓ}} → (I → Ordinal(T)) → Type StrictlyIncreasingSubsequenceExistence{I = I} (f) = ∃{Obj = ℕ → I}(g ↦ ∀{n} → (f(g(n)) < f(g(𝐒(n))))) -- TODO: Requires some kind of search for T StrictlyIncreasingSubsequenceExistence-to-no-maximum : StrictlyIncreasingSubsequenceExistence(f) → ¬ ∃(max ↦ ∀{x} → (f(x) < f(max))) StrictlyIncreasingSubsequenceExistence-to-no-maximum ([∃]-intro witness) ([∃]-intro witness₁) = [<]-asymmetry {!!} {!!} -} {- TODO: Maybe unprovable constructively [<]-classical : (x < y) ∨ ¬(x < y) [<]-classical {𝟎} {𝟎} = [∨]-introᵣ \() [<]-classical {𝟎} {𝐒 y} = [∨]-introₗ minimal [<]-classical {𝟎} {lim y} = [∨]-introₗ (limitᵣ{𝟎} minimal) [<]-classical {𝐒 x} {𝟎} = [∨]-introᵣ \() [<]-classical {𝐒 x} {𝐒 y} = [∨]-elim2 step (_∘ [<]-without-step) ([<]-classical {x} {y}) [<]-classical {𝐒 x} {lim y} with [<]-classical {x} {lim y} ... | [∨]-introₗ p = {!!} ... | [∨]-introᵣ p = {!!} [<]-classical {lim x} {𝟎} = [∨]-introᵣ \() [<]-classical {lim x} {𝐒 y} with [<]-classical {lim x} {y} ... | [∨]-introₗ (limitₗ p) = [∨]-introₗ (limitₗ ([<]-stepᵣ p)) ... | [∨]-introₗ (limitᵣ (limitₗ p)) = [∨]-introₗ (limitₗ (limitᵣ ([<]-stepᵣ p))) ... | [∨]-introᵣ p = [∨]-introᵣ (p ∘ (q ↦ {![<]-limitₗ-inv q!})) [<]-classical {lim x} {lim y} = {!!} -} {- TODO: This is true when there is no maximum for f ∀{x} → ∃(y ↦ (x < y) ∧ (f(x) < f(y))) test : (x < lim f) → (𝐒(x) < lim f) test {𝟎} (limitᵣ minimal) = limitᵣ (step {!!}) test {𝐒 x} (limitᵣ (step p)) = limitᵣ (step {!!}) test {lim x} (limitᵣ (limitₗ x₁)) = {!!} -} {- TODO: Also unprovable constructively? f either have a maximum value or is unbounded (so, this would require some kind of search?) [<]-sequence-limit : ∀{n} → (f(n) < lim g) → ((∀{n} → (f(n) < lim g)) ∨ (f(n) ≡ x)) [≤]-total : ⦃ ◊ T ⦄ → ((x ≤ y) ∨ (y ≤ x)) [≤]-total {𝟎} {_} = [∨]-introₗ minimal [≤]-total {_} {𝟎} = [∨]-introᵣ minimal [≤]-total {𝐒 x} {𝐒 y} = [∨]-elim2 step step ([≤]-total {x} {y}) [≤]-total {𝐒 x} {lim y} with [≤]-total {x} {lim y} ... | [∨]-introₗ minimal = [∨]-introₗ (step [<]-lim-minimal) ... | [∨]-introₗ (step (limitᵣ p)) = [∨]-introₗ (step (limitᵣ (step {!!}))) ... | [∨]-introₗ (limitₗ p) = [∨]-introₗ (step (limitᵣ (limitₗ (\{n} → {![<]-limitᵣ-inv (p{n})!})))) ... | [∨]-introᵣ p = [∨]-introᵣ ([<]-stepᵣ p) [≤]-total {lim x} {𝐒 y} = {!!} -- [∨]-symmetry ([≤]-total {𝐒 y} {lim x}) [≤]-total {lim x} {lim y} = {!!} -} {- [≤]-to-[<][≡] : ⦃ ◊ T ⦄ → (x ≤ y) → ((x < y) ∨ (x ≡ y)) [≤]-to-[<][≡] {𝟎} {𝟎} minimal = [∨]-introᵣ ([∧]-intro minimal minimal) [≤]-to-[<][≡] {𝟎} {𝐒 y} minimal = [∨]-introₗ minimal [≤]-to-[<][≡] {𝟎} {lim y} minimal = [∨]-introₗ [<]-lim-minimal [≤]-to-[<][≡] {𝐒 x} {𝐒 y} (step p) = [∨]-elim2 step [≡]-step ([≤]-to-[<][≡] {x}{y} p) [≤]-to-[<][≡] {𝐒 x} {lim y} (step (limitᵣ p)) with [≤]-to-[<][≡] p ... | [∨]-introₗ pp = [∨]-introₗ (limitᵣ (step pp)) ... | [∨]-introᵣ ([∧]-intro l r) = {!!} -- [∨]-introᵣ ([∧]-intro (limitₗ (\{n} → {!!})) (step (limitᵣ r))) -- [∨]-elim2 (limitᵣ ∘ step) (\([∧]-intro l r) → [∧]-intro (limitₗ {![<]-stepᵣ l!}) (step (limitᵣ r))) ([≤]-to-[<][≡] p) [≤]-to-[<][≡] {lim x} {𝟎} (limitₗ p) = [∨]-introᵣ ([∧]-intro minimal (limitₗ p)) [≤]-to-[<][≡] {lim x} {𝐒 y} (limitₗ p) = {!!} [≤]-to-[<][≡] {lim x} {lim y} (limitₗ p) = {!!} [<]-trichotomy : ⦃ ◊ T ⦄ → ((x < y) ∨ (x ≡ y) ∨ (x > y)) [<]-trichotomy {𝟎} {𝟎} = [∨]-introₗ ([∨]-introᵣ [≡]-reflexivity) [<]-trichotomy {𝟎} {𝐒 y} = [∨]-introₗ ([∨]-introₗ minimal) [<]-trichotomy {𝟎} {lim y} = [∨]-introₗ ([∨]-introₗ [<]-lim-minimal) [<]-trichotomy {𝐒 x} {𝟎} = [∨]-introᵣ minimal [<]-trichotomy {lim x} {𝟎} = [∨]-introᵣ [<]-lim-minimal [<]-trichotomy {𝐒 x} {𝐒 y} = [∨]-elim2 ([∨]-elim2 step [≡]-step) step ([<]-trichotomy {x}{y}) [<]-trichotomy {𝐒 x} {lim y} with [<]-trichotomy {x} {lim y} ... | [∨]-introₗ ([∨]-introᵣ ([∧]-intro p _)) = [∨]-introᵣ p ... | [∨]-introᵣ p = [∨]-introᵣ ([<]-stepᵣ p) ... | [∨]-introₗ ([∨]-introₗ (limitᵣ{n} p)) = {!!} [<]-trichotomy {lim x} {𝐒 y} = {!!} [<]-trichotomy {lim x} {lim y} = {!!} -} lim-of-constant : ⦃ ◊ T ⦄ → (lim(const x) ≡ 𝐒(x)) lim-of-constant = [∧]-intro (step (limitᵣ{[◊]-existence} [<]-of-step)) (limitₗ [<]-of-step) lim-of-sequence-with-maximum : ∀{max} → (∀{n} → (f(n) ≤ f(max))) → (lim f ≡ 𝐒(f(max))) lim-of-sequence-with-maximum{max = max} p = [∧]-intro (step (limitᵣ{max} [<]-of-step)) (limitₗ p) -- ∃(max ↦ (∀{n} → (f(n) ≤ f(max))) ∧ (lim f ≡ 𝐒(f(max)))) ∨ (∀{x} → (𝐒(f(x)) < lim f)) -- or maybe (∀{x y} → (f(x) + f(y) < lim f)) lim-[≤]-function : (∀{x} → (f(x) ≤ g(x))) → (lim f ≤ lim g) lim-[≤]-function p = limitₗ(limitᵣ p) lim-function : (∀{x} → (f(x) ≡ g(x))) → (lim f ≡ lim g) lim-function p = [∧]-intro (lim-[≤]-function([∧]-elimₗ p)) (lim-[≤]-function([∧]-elimᵣ p)) [+]-identityᵣ : ((x + 𝟎) ≡ x) [+]-identityᵣ = [≡]-reflexivity [+]-identityₗ : ((𝟎 + x) ≡ x) [+]-identityₗ {𝟎} = [+]-identityᵣ [+]-identityₗ {𝐒 x} = [≡]-step ([+]-identityₗ {x}) [+]-identityₗ {lim x} = lim-function [+]-identityₗ [+]-associativity : (((x + y) + z) ≡ (x + (y + z))) [+]-associativity {x}{y}{𝟎} = [≡]-reflexivity [+]-associativity {x}{y}{𝐒 z} = [≡]-step ([+]-associativity {x}{y}{z}) [+]-associativity {x}{y}{lim z} = lim-function ([+]-associativity {x}{y}{_}) [+]ₗ-[<][≤]-semifunction : (x < y) → ((x + z) ≤ (y + z)) [+]ₗ-[<][≤]-semifunction {z = 𝟎} p = [<]-to-[≤] p [+]ₗ-[<][≤]-semifunction {z = 𝐒 z} p = [≤]-step([+]ₗ-[<][≤]-semifunction {z = z} p) [+]ₗ-[<][≤]-semifunction {z = lim x} p = limitₗ (limitᵣ ([+]ₗ-[<][≤]-semifunction p)) [+]ᵣ-[<]-function : ⦃ ◊ T ⦄ → (y < z) → ((x + y) < (x + z)) [+]ᵣ-[<]-function (minimal {𝟎}) = [<]-of-step [+]ᵣ-[<]-function (minimal {𝐒 x}) = [<]-stepᵣ ([+]ᵣ-[<]-function minimal) [+]ᵣ-[<]-function (minimal {lim x}) = [<]-stepᵣ (limitᵣ{[◊]-existence} ([+]ᵣ-[<]-function minimal)) [+]ᵣ-[<]-function (step p) = step ([+]ᵣ-[<]-function p) [+]ᵣ-[<]-function (limitₗ p) = limitₗ ([+]ᵣ-[<]-function p) [+]ᵣ-[<]-function (limitᵣ p) = limitᵣ ([+]ᵣ-[<]-function p) {- [+]-operator : ⦃ ◊ T ⦄ → (x₁ ≡ x₂) → (y₁ ≡ y₂) → ((x₁ + y₁) ≡ (x₂ + y₂)) [+]-operator ([∧]-intro pxl pxr) ([∧]-intro pyl pyr) = [∧]-intro {!!} {!!} where l : (x₁ ≡ x₂) → ((x₁ + y) ≡ (x₂ + y)) l {𝟎} {x₂} ([∧]-intro pl pr) = [∧]-intro {!!} {!!} l {𝐒 x₁} {x₂} ([∧]-intro pl pr) = [∧]-intro {!!} {!!} l {lim x₁} {x₂} ([∧]-intro pl pr) = [∧]-intro {!!} {!!} r : (y₁ ≡ y₂) → ((x + y₁) ≡ (x + y₂)) r ([∧]-intro pl pr) = [∧]-intro ([+]ᵣ-[<]-function pl) ([+]ᵣ-[<]-function pr) -} open import Structure.Relator.Ordering open Structure.Relator.Ordering.Strict.Properties using (intro) Ordinal-accessibleₗ : ⦃ ◊ T ⦄ → Strict.Properties.Accessibleₗ(_<_)(x) Ordinal-accessibleₗ {n} = intro ⦃ proof{n} ⦄ where proof : ∀{y x} → ⦃ _ : (x < y) ⦄ → Strict.Properties.Accessibleₗ(_<_)(x) proof {_} {𝟎} = intro ⦃ \ ⦃ ⦄ ⦄ proof {𝐒 𝟎} {lim y} ⦃ limitₗ p ⦄ with () ← p{[◊]-existence} proof {𝐒 x} {𝐒 y} ⦃ step p ⦄ = intro ⦃ \{z} ⦃ pz ⦄ → Strict.Properties.Accessibleₗ.proof (Ordinal-accessibleₗ {x}) ⦃ [<][≤]-semitransitivityₗ pz p ⦄ ⦄ proof {𝐒(𝐒 x)} {lim y} ⦃ limitₗ p ⦄ = intro ⦃ \{z} ⦃ pz ⦄ → Strict.Properties.Accessibleₗ.proof (Ordinal-accessibleₗ {𝐒 x}) ⦃ [<][≤]-semitransitivityₗ ([∃]-proof([<]-limitᵣ-inv pz)) p ⦄ ⦄ proof {𝐒(lim x)} {lim y} ⦃ limitₗ p ⦄ = intro ⦃ \{z} ⦃ pz ⦄ → Strict.Properties.Accessibleₗ.proof (Ordinal-accessibleₗ {lim x}) ⦃ [<][≤]-semitransitivityₗ ([∃]-proof([<]-limitᵣ-inv pz)) p ⦄ ⦄ proof {lim x} {𝐒 y} ⦃ limitᵣ(step p) ⦄ = intro ⦃ \{z} ⦃ pz ⦄ → Strict.Properties.Accessibleₗ.proof Ordinal-accessibleₗ ⦃ [<][≤]-semitransitivityₗ pz p ⦄ ⦄ proof {lim x} {lim y} ⦃ limitᵣ(limitₗ p) ⦄ = intro ⦃ \{z} ⦃ pz ⦄ → Strict.Properties.Accessibleₗ.proof Ordinal-accessibleₗ ⦃ [<][≤]-semitransitivityₗ ([∃]-proof([<]-limitᵣ-inv pz)) p ⦄ ⦄ module _ where open import Functional open import Function.Iteration open import Numeral.Natural.Induction private variable n : ℕ _⋅ₙ_ : Ordinal(ℕ) → ℕ → Ordinal(ℕ) _⋅ₙ_ x = ℕ-elim 𝟎 (const(lim ∘ (_+ₙ_))) ω : Ordinal(ℕ) ω = lim from-ℕ ω² : Ordinal(ℕ) ω² = lim(ω ⋅ₙ_) ω-[<]-correctness : from-ℕ(n) < ω ω-[<]-correctness {𝟎} = limitᵣ{i = 𝟎} minimal ω-[<]-correctness {𝐒(n)} = limitᵣ{i = 𝐒(n)} (step [<]-of-step) open import Relator.Equals renaming (_≡_ to _≡ₑ_) open import Relator.Equals.Proofs open import Type.Properties.Inhabited open import Structure.Relator private variable f : ℕ → Ordinal(ℕ) instance ℕ-inhabited : ◊ ℕ ℕ-inhabited = intro ⦃ 𝟎 ⦄ strictly-increasing-sequence-when-zero : (∀{n} → (f(n) < f(𝐒(n)))) → (f(n) ≡ₑ 𝟎) → (n ≡ₑ 𝟎) strictly-increasing-sequence-when-zero {f = f}{n = 𝟎} ord p = [≡]-intro strictly-increasing-sequence-when-zero {f = f}{n = 𝐒 n} ord p with f(n) | ord{n} ... | 𝟎 | ord' with () ← [<]-irreflexivity (substitute₂ᵣ(_<_) p ord') ... | 𝐒 fn | ord' with () ← [<]-asymmetry minimal (substitute₂ᵣ(_<_) p ord') ... | lim x | ord' with () ← [<]-asymmetry [<]-lim-minimal (substitute₂ᵣ(_<_) p ord')
module Groups using GroupsCore using ThreadsX import KnuthBendix import KnuthBendix: AbstractWord, Alphabet, Word import KnuthBendix: alphabet import Random import OrderedCollections: OrderedSet export Alphabet, AutomorphismGroup, FreeGroup, FreeGroup, FPGroup, FPGroupElement, SpecialAutomorphismGroup export alphabet, evaluate, word, gens include("types.jl") include("hashing.jl") include("normalform.jl") include("autgroups.jl") include("groups/sautFn.jl") include("groups/mcg.jl") include("wl_ball.jl") end # of module Groups
------------------------------------------------------------------------ -- The Agda standard library -- -- Some properties imply others ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.Consequences where open import Relation.Binary.Core open import Relation.Nullary using (yes; no) open import Relation.Unary using (∁) open import Function using (_∘_; flip) open import Data.Maybe.Base using (just; nothing) open import Data.Sum using (inj₁; inj₂) open import Data.Product using (_,_) open import Data.Empty using (⊥-elim) ------------------------------------------------------------------------ -- Substitutive properties module _ {a ℓ p} {A : Set a} {_∼_ : Rel A ℓ} (P : Rel A p) where subst⟶respˡ : Substitutive _∼_ p → P Respectsˡ _∼_ subst⟶respˡ subst {y} x'∼x Px'y = subst (flip P y) x'∼x Px'y subst⟶respʳ : Substitutive _∼_ p → P Respectsʳ _∼_ subst⟶respʳ subst {x} y'∼y Pxy' = subst (P x) y'∼y Pxy' subst⟶resp₂ : Substitutive _∼_ p → P Respects₂ _∼_ subst⟶resp₂ subst = subst⟶respʳ subst , subst⟶respˡ subst module _ {a ℓ p} {A : Set a} {∼ : Rel A ℓ} {P : A → Set p} where P-resp⟶¬P-resp : Symmetric ∼ → P Respects ∼ → (∁ P) Respects ∼ P-resp⟶¬P-resp sym resp x∼y ¬Px Py = ¬Px (resp (sym x∼y) Py) ------------------------------------------------------------------------ -- Proofs for non-strict orders module _ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_≤_ : Rel A ℓ₂} where total⟶refl : _≤_ Respects₂ _≈_ → Symmetric _≈_ → Total _≤_ → _≈_ ⇒ _≤_ total⟶refl (respʳ , respˡ) sym total {x} {y} x≈y with total x y ... | inj₁ x∼y = x∼y ... | inj₂ y∼x = respʳ x≈y (respˡ (sym x≈y) y∼x) total+dec⟶dec : _≈_ ⇒ _≤_ → Antisymmetric _≈_ _≤_ → Total _≤_ → Decidable _≈_ → Decidable _≤_ total+dec⟶dec refl antisym total _≟_ x y with total x y ... | inj₁ x≤y = yes x≤y ... | inj₂ y≤x with x ≟ y ... | yes x≈y = yes (refl x≈y) ... | no x≉y = no (λ x≤y → x≉y (antisym x≤y y≤x)) ------------------------------------------------------------------------ -- Proofs for strict orders module _ {a ℓ₁ ℓ₂} {A : Set a} {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} where trans∧irr⟶asym : Reflexive _≈_ → Transitive _<_ → Irreflexive _≈_ _<_ → Asymmetric _<_ trans∧irr⟶asym refl trans irrefl x<y y<x = irrefl refl (trans x<y y<x) irr∧antisym⟶asym : Irreflexive _≈_ _<_ → Antisymmetric _≈_ _<_ → Asymmetric _<_ irr∧antisym⟶asym irrefl antisym x<y y<x = irrefl (antisym x<y y<x) x<y asym⟶antisym : Asymmetric _<_ → Antisymmetric _≈_ _<_ asym⟶antisym asym x<y y<x = ⊥-elim (asym x<y y<x) asym⟶irr : _<_ Respects₂ _≈_ → Symmetric _≈_ → Asymmetric _<_ → Irreflexive _≈_ _<_ asym⟶irr (respʳ , respˡ) sym asym {x} {y} x≈y x<y = asym x<y (respʳ (sym x≈y) (respˡ x≈y x<y)) tri⟶asym : Trichotomous _≈_ _<_ → Asymmetric _<_ tri⟶asym tri {x} {y} x<y x>y with tri x y ... | tri< _ _ x≯y = x≯y x>y ... | tri≈ _ _ x≯y = x≯y x>y ... | tri> x≮y _ _ = x≮y x<y tri⟶irr : Trichotomous _≈_ _<_ → Irreflexive _≈_ _<_ tri⟶irr compare {x} {y} x≈y x<y with compare x y ... | tri< _ x≉y y≮x = x≉y x≈y ... | tri> x≮y x≉y y<x = x≉y x≈y ... | tri≈ x≮y _ y≮x = x≮y x<y tri⟶dec≈ : Trichotomous _≈_ _<_ → Decidable _≈_ tri⟶dec≈ compare x y with compare x y ... | tri< _ x≉y _ = no x≉y ... | tri≈ _ x≈y _ = yes x≈y ... | tri> _ x≉y _ = no x≉y tri⟶dec< : Trichotomous _≈_ _<_ → Decidable _<_ tri⟶dec< compare x y with compare x y ... | tri< x<y _ _ = yes x<y ... | tri≈ x≮y _ _ = no x≮y ... | tri> x≮y _ _ = no x≮y trans∧tri⟶respʳ≈ : Symmetric _≈_ → Transitive _≈_ → Transitive _<_ → Trichotomous _≈_ _<_ → _<_ Respectsʳ _≈_ trans∧tri⟶respʳ≈ sym ≈-tr <-tr tri {x} {y} {z} y≈z x<y with tri x z ... | tri< x<z _ _ = x<z ... | tri≈ _ x≈z _ = ⊥-elim (tri⟶irr tri (≈-tr x≈z (sym y≈z)) x<y) ... | tri> _ _ z<x = ⊥-elim (tri⟶irr tri (sym y≈z) (<-tr z<x x<y)) trans∧tri⟶respˡ≈ : Transitive _≈_ → Transitive _<_ → Trichotomous _≈_ _<_ → _<_ Respectsˡ _≈_ trans∧tri⟶respˡ≈ ≈-tr <-tr tri {z} {_} {y} x≈y x<z with tri y z ... | tri< y<z _ _ = y<z ... | tri≈ _ y≈z _ = ⊥-elim (tri⟶irr tri (≈-tr x≈y y≈z) x<z) ... | tri> _ _ z<y = ⊥-elim (tri⟶irr tri x≈y (<-tr x<z z<y)) trans∧tri⟶resp≈ : Symmetric _≈_ → Transitive _≈_ → Transitive _<_ → Trichotomous _≈_ _<_ → _<_ Respects₂ _≈_ trans∧tri⟶resp≈ sym ≈-tr <-tr tri = trans∧tri⟶respʳ≈ sym ≈-tr <-tr tri , trans∧tri⟶respˡ≈ ≈-tr <-tr tri ------------------------------------------------------------------------ -- Without Loss of Generality module _ {a r q} {A : Set a} {_R_ : Rel A r} {Q : Rel A q} where wlog : Total _R_ → Symmetric Q → (∀ a b → a R b → Q a b) → ∀ a b → Q a b wlog r-total q-sym prf a b with r-total a b ... | inj₁ aRb = prf a b aRb ... | inj₂ bRa = q-sym (prf b a bRa) ------------------------------------------------------------------------ -- Other proofs module _ {a b p} {A : Set a} {B : Set b} {P : REL A B p} where dec⟶weaklyDec : Decidable P → WeaklyDecidable P dec⟶weaklyDec dec x y with dec x y ... | yes p = just p ... | no _ = nothing module _ {a b p q} {A : Set a} {B : Set b } {P : REL A B p} {Q : REL A B q} where map-NonEmpty : P ⇒ Q → NonEmpty P → NonEmpty Q map-NonEmpty f x = nonEmpty (f (NonEmpty.proof x))
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Neutral {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Properties.Symmetry import Definition.LogicalRelation.Weakening as W open import Tools.Product import Tools.PropositionalEquality as PE import Data.Fin as Fin import Data.Nat as Nat -- Neutral reflexive types are reducible. neu : ∀ {l Γ A r ll} (neA : Neutral A) → Γ ⊢ A ^ [ r , ι ll ] → Γ ⊢ A ~ A ∷ Univ r ll ^ [ ! , next ll ] → Γ ⊩⟨ l ⟩ A ^ [ r , ι ll ] neu neA A A~A = ne′ _ (idRed:*: A) neA A~A -- Helper function for reducible neutral equality of a specific type of derivation. neuEq′ : ∀ {l Γ A B r ll} ([A] : Γ ⊩⟨ l ⟩ne A ^[ r , ll ]) (neA : Neutral A) (neB : Neutral B) → Γ ⊢ A ^ [ r , ι ll ] → Γ ⊢ B ^ [ r , ι ll ] → Γ ⊢ A ~ B ∷ Univ r ll ^ [ ! , next ll ] → Γ ⊩⟨ l ⟩ A ≡ B ^ [ r , ι ll ] / ne-intr [A] neuEq′ (noemb (ne K [[ ⊢A , ⊢B , D ]] neK K≡K)) neA neB A B A~B = let A≡K = whnfRed* D (ne neA) in ne₌ _ (idRed:*: B) neB (PE.subst (λ x → _ ⊢ x ~ _ ∷ _ ^ _) A≡K A~B) neuEq′ {ι ¹} (emb emb< X) = neuEq′ X neuEq′ {∞} (emb ∞< X) = neuEq′ X -- Neutrally equal types are of reducible equality. neuEq : ∀ {l Γ A B r ll} ([A] : Γ ⊩⟨ l ⟩ A ^ [ r , ι ll ]) (neA : Neutral A) (neB : Neutral B) → Γ ⊢ A ^ [ r , ι ll ] → Γ ⊢ B ^ [ r , ι ll ] → Γ ⊢ A ~ B ∷ Univ r ll ^ [ ! , next ll ] → Γ ⊩⟨ l ⟩ A ≡ B ^ [ r , ι ll ] / [A] neuEq [A] neA neB A B A~B = irrelevanceEq (ne-intr (ne-elim neA [A])) [A] (neuEq′ (ne-elim neA [A]) neA neB A B A~B) mutual neuTerm⁰ : ∀ {Γ A r n} ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ r) (neN : Neutral n) → Γ ⊢ n ∷ A ^ r → Γ ⊢ n ~ n ∷ A ^ r → Γ ⊩⟨ ι ⁰ ⟩ n ∷ A ^ r / [A] neuTerm⁰ (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN n n~n = let A≡ℕ = subset* D n~n′ = ~-conv n~n A≡ℕ n≡n = ~-to-≅ₜ n~n′ in ℕₜ _ (idRedTerm:*: (conv n A≡ℕ)) n≡n (ne (neNfₜ neN (conv n A≡ℕ) n~n′)) neuTerm⁰ {r = [ ! , ll ]} (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) neN n n~n = let A≡K = subset* D in neₜ _ (idRedTerm:*: (conv n A≡K)) (neNfₜ neN (conv n A≡K) (~-conv n~n A≡K)) neuTerm⁰ {r = [ ! , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in Πₜ _ (idRedTerm:*: (conv n A≡ΠFG)) (ne neN) (~-to-≅ₜ (~-conv n~n A≡ΠFG)) (λ {ρ} [ρ] ⊢Δ [a] [b] [a≡b] → let A≡ΠFG = subset* (red D) ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) G[a]≡G[b] = escapeEq ([G] [ρ] ⊢Δ [b]) (symEq ([G] [ρ] ⊢Δ [a]) ([G] [ρ] ⊢Δ [b]) (G-ext [ρ] ⊢Δ [a] [b] [a≡b])) a = escapeTerm ([F] [ρ] ⊢Δ) [a] b = escapeTerm ([F] [ρ] ⊢Δ) [b] a≡b = escapeTermEq ([F] [ρ] ⊢Δ) [a≡b] ρn = conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG neN∘a = ∘ₙ (wkNeutral ρ neN) neN∘b = ∘ₙ (wkNeutral ρ neN) in neuEqTerm⁰ ([G] [ρ] ⊢Δ [a]) neN∘a neN∘b (ρn ∘ⱼ a) (conv (ρn ∘ⱼ b) (≅-eq G[a]≡G[b])) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡b)) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) in neuTerm⁰ ([G] [ρ] ⊢Δ [a]) (∘ₙ (wkNeutral ρ neN)) (conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡a)) neuTerm⁰ (Emptyᵣ [[ ⊢A , ⊢B , D ]]) neN n n~n = let A≡ℕ = subset* D in Emptyₜ (ne (conv n A≡ℕ)) neuTerm⁰ {r = [ % , ll ]} (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) neN n n~n = let A≡K = subset* D in neₜ n neuTerm⁰ {r = [ % , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in conv n A≡ΠFG neuTerm⁰ {r = [ % , ll ]} (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in conv n A≡ΠFG neuEqTerm⁰ : ∀ {Γ A n n′ r} ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ r) (neN : Neutral n) (neN′ : Neutral n′) → Γ ⊢ n ∷ A ^ r → Γ ⊢ n′ ∷ A ^ r → Γ ⊢ n ~ n′ ∷ A ^ r → Γ ⊩⟨ ι ⁰ ⟩ n ≡ n′ ∷ A ^ r / [A] neuEqTerm⁰ (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN neN′ n n′ n~n′ = let A≡ℕ = subset* D n~n′₁ = ~-conv n~n′ A≡ℕ n≡n′ = ~-to-≅ₜ n~n′₁ in ℕₜ₌ _ _ (idRedTerm:*: (conv n A≡ℕ)) (idRedTerm:*: (conv n′ A≡ℕ)) n≡n′ (ne (neNfₜ₌ neN neN′ n~n′₁)) neuEqTerm⁰ (Emptyᵣ [[ ⊢A , ⊢B , D ]]) neN neN′ n n′ n~n′ = let A≡Empty = subset* D in Emptyₜ₌ (ne (conv n A≡Empty) (conv n′ A≡Empty)) neuEqTerm⁰ {r = [ ! , ll ]} (ne (ne K [[ ⊢A , ⊢B , D ]] neK K≡K)) neN neN′ n n′ n~n′ = let A≡K = subset* D in neₜ₌ _ _ (idRedTerm:*: (conv n A≡K)) (idRedTerm:*: (conv n′ A≡K)) (neNfₜ₌ neN neN′ (~-conv n~n′ A≡K)) neuEqTerm⁰ {r = [ % , ll ]} (ne (ne K [[ ⊢A , ⊢B , D ]] neK K≡K)) neN neN′ n n′ n~n′ = let A≡K = subset* D in neₜ₌ n n′ neuEqTerm⁰ {r = [ ! , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let [ΠFG] = Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext A≡ΠFG = subset* D n~n′₁ = ~-conv n~n′ A≡ΠFG n≡n′ = ~-to-≅ₜ n~n′₁ n~n = ~-trans n~n′ (~-sym n~n′) n′~n′ = ~-trans (~-sym n~n′) n~n′ in Πₜ₌ _ _ (idRedTerm:*: (conv n A≡ΠFG)) (idRedTerm:*: (conv n′ A≡ΠFG)) (ne neN) (ne neN′) n≡n′ (neuTerm⁰ [ΠFG] neN n n~n) (neuTerm⁰ [ΠFG] neN′ n′ n′~n′) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ A≡ΠFG ρn = wkTerm [ρ] ⊢Δ n ρn′ = wkTerm [ρ] ⊢Δ n′ a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) neN∙a = ∘ₙ (wkNeutral ρ neN) neN′∙a′ = ∘ₙ (wkNeutral ρ neN′) in neuEqTerm⁰ ([G] [ρ] ⊢Δ [a]) neN∙a neN′∙a′ (conv ρn ρA≡ρΠFG ∘ⱼ a) (conv ρn′ ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ n~n′₁) a≡a)) neuEqTerm⁰ {r = [ % , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let A≡ΠFG = subset* D in conv n A≡ΠFG , conv n′ A≡ΠFG neuEqTerm⁰ {r = [ % , ll ]} (∃ᵣ′ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let A≡ΠFG = subset* D in conv n A≡ΠFG , conv n′ A≡ΠFG mutual -- Neutral reflexive terms are reducible. neuTerm : ∀ {l Γ A r n} ([A] : Γ ⊩⟨ l ⟩ A ^ r) (neN : Neutral n) → Γ ⊢ n ∷ A ^ r → Γ ⊢ n ~ n ∷ A ^ r → Γ ⊩⟨ l ⟩ n ∷ A ^ r / [A] neuTerm {ι ¹} (Uᵣ′ A .(next ⁰) r ⁰ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN n n~n = let n' = (conv n (subset* D)) n~n' = ~-conv n~n (subset* D) [n] = neu {l = ι ¹} neN (univ n') n~n' in Uₜ _ (idRedTerm:*: n') (ne neN) (~-to-≅ₜ n~n') (λ {ρ} [ρ] ⊢Δ → let n'ρ = wkTerm [ρ] ⊢Δ n' n~n'ρ = ~-wk [ρ] ⊢Δ n~n' [nρ] = neu (wkNeutral ρ neN) (univ n'ρ) n~n'ρ in [nρ]) neuTerm {∞} (Uᵣ′ A .(next ¹) r ¹ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN n n~n = let n' = (conv n (subset* D)) n~n' = ~-conv n~n (subset* D) [n] = neu {l = ∞} neN (univ n') n~n' in Uₜ _ (idRedTerm:*: n') (ne neN) (~-to-≅ₜ n~n') (λ {ρ} [ρ] ⊢Δ → let n'ρ = wkTerm [ρ] ⊢Δ n' n~n'ρ = ~-wk [ρ] ⊢Δ n~n' [nρ] = neu (wkNeutral ρ neN) (univ n'ρ) n~n'ρ in [nρ]) neuTerm (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN n n~n = let A≡ℕ = subset* D n~n′ = ~-conv n~n A≡ℕ n≡n = ~-to-≅ₜ n~n′ in ℕₜ _ (idRedTerm:*: (conv n A≡ℕ)) n≡n (ne (neNfₜ neN (conv n A≡ℕ) n~n′)) neuTerm {r = [ ! , ll ]} (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) neN n n~n = let A≡K = subset* D in neₜ _ (idRedTerm:*: (conv n A≡K)) (neNfₜ neN (conv n A≡K) (~-conv n~n A≡K)) neuTerm {r = [ ! , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in Πₜ _ (idRedTerm:*: (conv n A≡ΠFG)) (ne neN) (~-to-≅ₜ (~-conv n~n A≡ΠFG)) (λ {ρ} [ρ] ⊢Δ [a] [b] [a≡b] → let A≡ΠFG = subset* (red D) ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) G[a]≡G[b] = escapeEq ([G] [ρ] ⊢Δ [b]) (symEq ([G] [ρ] ⊢Δ [a]) ([G] [ρ] ⊢Δ [b]) (G-ext [ρ] ⊢Δ [a] [b] [a≡b])) a = escapeTerm ([F] [ρ] ⊢Δ) [a] b = escapeTerm ([F] [ρ] ⊢Δ) [b] a≡b = escapeTermEq ([F] [ρ] ⊢Δ) [a≡b] ρn = conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG neN∘a = ∘ₙ (wkNeutral ρ neN) neN∘b = ∘ₙ (wkNeutral ρ neN) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∘a neN∘b (ρn ∘ⱼ a) (conv (ρn ∘ⱼ b) (≅-eq G[a]≡G[b])) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡b)) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) in neuTerm ([G] [ρ] ⊢Δ [a]) (∘ₙ (wkNeutral ρ neN)) (conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡a)) neuTerm (Emptyᵣ [[ ⊢A , ⊢B , D ]]) neN n n~n = let A≡ℕ = subset* D in Emptyₜ (ne (conv n A≡ℕ)) neuTerm {r = [ % , ll ]} (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) neN n n~n = let A≡K = subset* D in neₜ n neuTerm {r = [ % , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in conv n A≡ΠFG neuTerm {r = [ % , ll ]} (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in conv n A≡ΠFG neuTerm {ι ¹} (emb l< X) neN n = neuTerm X neN n neuTerm {∞} (emb l< X) neN n = neuTerm X neN n -- Neutrally equal terms are of reducible equality. neuEqTerm : ∀ {l Γ A n n′ r} ([A] : Γ ⊩⟨ l ⟩ A ^ r) (neN : Neutral n) (neN′ : Neutral n′) → Γ ⊢ n ∷ A ^ r → Γ ⊢ n′ ∷ A ^ r → Γ ⊢ n ~ n′ ∷ A ^ r → Γ ⊩⟨ l ⟩ n ≡ n′ ∷ A ^ r / [A] neuEqTerm {ι ¹} (Uᵣ′ A _ r ⁰ l< PE.refl D) neN neN′ n n′ n~n' = let n~n = ~-trans n~n' (~-sym n~n') n'~n' = ~-trans (~-sym n~n') n~n' [[n]] = neuTerm (Uᵣ (Uᵣ r ⁰ l< PE.refl D)) neN n n~n [[n']] = neuTerm (Uᵣ (Uᵣ r ⁰ l< PE.refl D)) neN′ n′ n'~n' n' = conv n (subset* (red D)) n′' = conv n′ (subset* (red D)) n~n'U = ~-conv n~n' (subset* (red D)) [n] = neu {l = ι ¹} neN (univ n') (~-conv n~n (subset* (red D))) [n′] = neu {l = ι ¹} neN′ (univ n′') (~-conv n'~n' (subset* (red D))) in Uₜ₌ [[n]] [[n']] (~-to-≅ₜ n~n'U) (λ [ρ] ⊢Δ → W.wkEq [ρ] ⊢Δ [n] ((neuEq [n] neN neN′ (univ n') (univ n′') n~n'U))) neuEqTerm {∞} (Uᵣ′ A _ r ¹ l< PE.refl D) neN neN′ n n′ n~n' = let n~n = ~-trans n~n' (~-sym n~n') n'~n' = ~-trans (~-sym n~n') n~n' [[n]] = neuTerm (Uᵣ (Uᵣ r ¹ l< PE.refl D)) neN n n~n [[n']] = neuTerm (Uᵣ (Uᵣ r ¹ l< PE.refl D)) neN′ n′ n'~n' n' = conv n (subset* (red D)) n′' = conv n′ (subset* (red D)) n~n'U = ~-conv n~n' (subset* (red D)) [n] = neu {l = ∞} neN (univ n') (~-conv n~n (subset* (red D))) [n′] = neu {l = ∞} neN′ (univ n′') (~-conv n'~n' (subset* (red D))) in Uₜ₌ [[n]] [[n']] (~-to-≅ₜ n~n'U) (λ [ρ] ⊢Δ → W.wkEq [ρ] ⊢Δ [n] ((neuEq [n] neN neN′ (univ n') (univ n′') n~n'U))) neuEqTerm (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN neN′ n n′ n~n′ = let A≡ℕ = subset* D n~n′₁ = ~-conv n~n′ A≡ℕ n≡n′ = ~-to-≅ₜ n~n′₁ in ℕₜ₌ _ _ (idRedTerm:*: (conv n A≡ℕ)) (idRedTerm:*: (conv n′ A≡ℕ)) n≡n′ (ne (neNfₜ₌ neN neN′ n~n′₁)) neuEqTerm (Emptyᵣ [[ ⊢A , ⊢B , D ]]) neN neN′ n n′ n~n′ = let A≡Empty = subset* D in Emptyₜ₌ (ne (conv n A≡Empty) (conv n′ A≡Empty)) neuEqTerm {r = [ ! , ll ]} (ne (ne K [[ ⊢A , ⊢B , D ]] neK K≡K)) neN neN′ n n′ n~n′ = let A≡K = subset* D in neₜ₌ _ _ (idRedTerm:*: (conv n A≡K)) (idRedTerm:*: (conv n′ A≡K)) (neNfₜ₌ neN neN′ (~-conv n~n′ A≡K)) neuEqTerm {r = [ % , ll ]} (ne (ne K [[ ⊢A , ⊢B , D ]] neK K≡K)) neN neN′ n n′ n~n′ = let A≡K = subset* D in neₜ₌ n n′ neuEqTerm {r = [ ! , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let [ΠFG] = Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext A≡ΠFG = subset* D n~n′₁ = ~-conv n~n′ A≡ΠFG n≡n′ = ~-to-≅ₜ n~n′₁ n~n = ~-trans n~n′ (~-sym n~n′) n′~n′ = ~-trans (~-sym n~n′) n~n′ in Πₜ₌ _ _ (idRedTerm:*: (conv n A≡ΠFG)) (idRedTerm:*: (conv n′ A≡ΠFG)) (ne neN) (ne neN′) n≡n′ (neuTerm [ΠFG] neN n n~n) (neuTerm [ΠFG] neN′ n′ n′~n′) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ A≡ΠFG ρn = wkTerm [ρ] ⊢Δ n ρn′ = wkTerm [ρ] ⊢Δ n′ a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) neN∙a = ∘ₙ (wkNeutral ρ neN) neN′∙a′ = ∘ₙ (wkNeutral ρ neN′) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∙a neN′∙a′ (conv ρn ρA≡ρΠFG ∘ⱼ a) (conv ρn′ ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ n~n′₁) a≡a)) neuEqTerm {r = [ % , ll ]} (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let A≡ΠFG = subset* D in conv n A≡ΠFG , conv n′ A≡ΠFG neuEqTerm {r = [ % , ll ]} (∃ᵣ′ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let A≡ΠFG = subset* D in conv n A≡ΠFG , conv n′ A≡ΠFG neuEqTerm {ι ¹} (emb l< X) neN n neN′ n:≡:n′ = neuEqTerm X neN n neN′ n:≡:n′ neuEqTerm {∞} (emb l< X) neN n neN′ n:≡:n′ = neuEqTerm X neN n neN′ n:≡:n′ -- Neutral reflexive types are reducible. neu:⇒*: : ∀ {l Γ A K r ll} (neK : Neutral K) → Γ ⊢ A :⇒*: K ^ [ r , ι ll ] → Γ ⊢ K ~ K ∷ Univ r ll ^ [ ! , next ll ] → Γ ⊩⟨ l ⟩ A ^ [ r , ι ll ] neu:⇒*: neK D K~K = ne′ _ D neK K~K -- Helper function for reducible neutral equality of a specific type of derivation. neuEq:⇒*:′ : ∀ {l Γ A B K L r ll} ([A] : Γ ⊩⟨ l ⟩ne A ^[ r , ll ]) (neK : Neutral K) (neL : Neutral L) → Γ ⊢ A :⇒*: K ^ [ r , ι ll ] → Γ ⊢ B :⇒*: L ^ [ r , ι ll ] → Γ ⊢ K ~ L ∷ Univ r ll ^ [ ! , next ll ] → Γ ⊩⟨ l ⟩ A ≡ B ^ [ r , ι ll ] / ne-intr [A] neuEq:⇒*:′ (noemb (ne A' [[ ⊢A , ⊢B , D ]] neA A≡A)) neK neL [[ ⊢A' , ⊢K , D' ]] [B] A~B = let A≡K = whrDet* (D , ne neA) (D' , ne neK) -- (ne neA) in ne₌ _ [B] neL (PE.subst (λ x → _ ⊢ x ~ _ ∷ _ ^ _) (PE.sym A≡K) A~B) neuEq:⇒*:′ {ι ¹} (emb emb< X) = neuEq:⇒*:′ X neuEq:⇒*:′ {∞} (emb ∞< X) = neuEq:⇒*:′ X -- Neutrally equal types are of reducible equality. neuEq:⇒*: : ∀ {l Γ A B K L r ll} ([A] : Γ ⊩⟨ l ⟩ A ^ [ r , ι ll ]) (neK : Neutral K) (neL : Neutral L) → Γ ⊢ A :⇒*: K ^ [ r , ι ll ] → Γ ⊢ B :⇒*: L ^ [ r , ι ll ] → Γ ⊢ K ~ L ∷ Univ r ll ^ [ ! , next ll ] → Γ ⊩⟨ l ⟩ A ≡ B ^ [ r , ι ll ] / [A] neuEq:⇒*: [A] neK neL [[ ⊢A , ⊢K , D ]] B A~B = let ne-intrA = ne-elim′ D neK [A] PE.refl in irrelevanceEq (ne-intr ne-intrA) [A] (neuEq:⇒*:′ ne-intrA neK neL [[ ⊢A , ⊢K , D ]] B A~B) app:⇒*: : ∀ {Γ a t u A B rA lA lB l} (⊢a : Γ ⊢ a ∷ A ^ [ rA , ι lA ]) (D : Γ ⊢ t :⇒*: u ∷ (Π A ^ rA ° lA ▹ B ° lB ° l) ^ ι l) → Γ ⊢ t ∘ a ^ l :⇒*: u ∘ a ^ l ∷ B [ a ] ^ ι lB app:⇒*: ⊢a [[ ⊢t , ⊢u , D ]] = [[ ⊢t ∘ⱼ ⊢a , ⊢u ∘ⱼ ⊢a , appRed* ⊢a D ]] mutual neuTerm:⇒*:⁰ : ∀ {Γ A ll t n} ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ ! , ll ]) (neN : Neutral n) → Γ ⊢ t :⇒*: n ∷ A ^ ll → Γ ⊢ n ~ n ∷ A ^ [ ! , ll ] → Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ ! , ll ] / [A] neuTerm:⇒*:⁰ (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN [[ ⊢t , n , D' ]] n~n = let A≡ℕ = subset* D n~n′ = ~-conv n~n A≡ℕ n≡n = ~-to-≅ₜ n~n′ in ℕₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ℕ) n≡n (ne (neNfₜ neN (conv n A≡ℕ) n~n′)) neuTerm:⇒*:⁰ (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) neN [[ ⊢t , n , D' ]] n~n = let A≡K = subset* D in neₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡K) (neNfₜ neN (conv n A≡K) (~-conv n~n A≡K)) neuTerm:⇒*:⁰ (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN [[ ⊢t , n , D' ]] n~n = let A≡ΠFG = subset* (red D) in Πₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ΠFG) (ne neN) (~-to-≅ₜ (~-conv n~n A≡ΠFG)) (λ {ρ} [ρ] ⊢Δ [a] [b] [a≡b] → let A≡ΠFG = subset* (red D) ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) G[a]≡G[b] = escapeEq ([G] [ρ] ⊢Δ [b]) (symEq ([G] [ρ] ⊢Δ [a]) ([G] [ρ] ⊢Δ [b]) (G-ext [ρ] ⊢Δ [a] [b] [a≡b])) a = escapeTerm ([F] [ρ] ⊢Δ) [a] b = escapeTerm ([F] [ρ] ⊢Δ) [b] a≡b = escapeTermEq ([F] [ρ] ⊢Δ) [a≡b] ρn = conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG neN∘a = ∘ₙ (wkNeutral ρ neN) neN∘b = ∘ₙ (wkNeutral ρ neN) in neuEqTerm⁰ ([G] [ρ] ⊢Δ [a]) neN∘a neN∘b (ρn ∘ⱼ a) (conv (ρn ∘ⱼ b) (≅-eq G[a]≡G[b])) ((~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡b))) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) in neuTerm ([G] [ρ] ⊢Δ [a]) (∘ₙ (wkNeutral ρ neN)) (conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡a)) neuEqTerm:⇒*:⁰ : ∀ {Γ A n n′ t u ll} ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ ! , ll ]) (neN : Neutral n) (neN′ : Neutral n′) → Γ ⊢ t :⇒*: n ∷ A ^ ll → Γ ⊢ u :⇒*: n′ ∷ A ^ ll → Γ ⊢ n ~ n′ ∷ A ^ [ ! , ll ] → Γ ⊩⟨ ι ⁰ ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] neuEqTerm:⇒*:⁰ (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n′ = let A≡ℕ = subset* D n~n′₁ = ~-conv n~n′ A≡ℕ n≡n′ = ~-to-≅ₜ n~n′₁ in ℕₜ₌ _ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ℕ) (conv:⇒*: [[ ⊢u , n′ , D′ ]] A≡ℕ) n≡n′ (ne (neNfₜ₌ neN neN′ n~n′₁)) neuEqTerm:⇒*:⁰ (ne (ne K [[ ⊢A , ⊢B , D ]] neK K≡K)) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n′ = let A≡K = subset* D in neₜ₌ _ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡K) (conv:⇒*: [[ ⊢u , n′ , D′ ]] A≡K) (neNfₜ₌ neN neN′ (~-conv n~n′ A≡K)) neuEqTerm:⇒*:⁰ (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n′ = let [ΠFG] = Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext A≡ΠFG = subset* D n~n′₁ = ~-conv n~n′ A≡ΠFG n≡n′ = ~-to-≅ₜ n~n′₁ n~n = ~-trans n~n′ (~-sym n~n′) n′~n′ = ~-trans (~-sym n~n′) n~n′ in Πₜ₌ _ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ΠFG) (conv:⇒*: [[ ⊢u , n′ , D′ ]] A≡ΠFG) (ne neN) (ne neN′) n≡n′ (neuTerm:⇒*:⁰ [ΠFG] neN [[ ⊢t , n , D' ]] n~n) (neuTerm:⇒*:⁰ [ΠFG] neN′ [[ ⊢u , n′ , D′ ]] n′~n′) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ A≡ΠFG ρn = wkTerm [ρ] ⊢Δ n ρn′ = wkTerm [ρ] ⊢Δ n′ a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) neN∙a = ∘ₙ (wkNeutral ρ neN) neN′∙a′ = ∘ₙ (wkNeutral ρ neN′) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∙a neN′∙a′ (conv ρn ρA≡ρΠFG ∘ⱼ a) (conv ρn′ ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ n~n′₁) a≡a) ) mutual -- Neutral reflexive terms are reducible. neuTerm:⇒*: : ∀ {l Γ A ll t n} ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) (neN : Neutral n) → Γ ⊢ t :⇒*: n ∷ A ^ ll → Γ ⊢ n ~ n ∷ A ^ [ ! , ll ] → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ll ] / [A] neuTerm:⇒*: {ι ¹} (Uᵣ′ A .(next ⁰) r ⁰ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN [[ ⊢t , n , D' ]] n~n = let D'' = conv:⇒*: [[ ⊢t , n , D' ]] (subset* D) n~n' = ~-conv n~n (subset* D) in Uₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] (subset* D)) (ne neN) (~-to-≅ₜ n~n') (λ {ρ} [ρ] ⊢Δ → let ρD' = wkRed:*:Term [ρ] ⊢Δ D'' n~n'ρ = ~-wk [ρ] ⊢Δ n~n' in neu:⇒*: (wkNeutral ρ neN) (univ:⇒*: ρD') n~n'ρ) neuTerm:⇒*: {∞} (Uᵣ′ A .(next ¹) r ¹ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN [[ ⊢t , n , D' ]] n~n = let D'' = conv:⇒*: [[ ⊢t , n , D' ]] (subset* D) n~n' = ~-conv n~n (subset* D) in Uₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] (subset* D)) (ne neN) (~-to-≅ₜ n~n') (λ {ρ} [ρ] ⊢Δ → let ρD' = wkRed:*:Term [ρ] ⊢Δ D'' n~n'ρ = ~-wk [ρ] ⊢Δ n~n' in neu:⇒*: (wkNeutral ρ neN) (univ:⇒*: ρD') n~n'ρ) neuTerm:⇒*: (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN [[ ⊢t , n , D' ]] n~n = let A≡ℕ = subset* D n~n′ = ~-conv n~n A≡ℕ n≡n = ~-to-≅ₜ n~n′ in ℕₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ℕ) n≡n (ne (neNfₜ neN (conv n A≡ℕ) n~n′)) neuTerm:⇒*: (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) neN [[ ⊢t , n , D' ]] n~n = let A≡K = subset* D in neₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡K) (neNfₜ neN (conv n A≡K) (~-conv n~n A≡K)) neuTerm:⇒*: (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN [[ ⊢t , n , D' ]] n~n = let A≡ΠFG = subset* (red D) in Πₜ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ΠFG) (ne neN) (~-to-≅ₜ (~-conv n~n A≡ΠFG)) (λ {ρ} [ρ] ⊢Δ [a] [b] [a≡b] → let A≡ΠFG = subset* (red D) ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) G[a]≡G[b] = escapeEq ([G] [ρ] ⊢Δ [b]) (symEq ([G] [ρ] ⊢Δ [a]) ([G] [ρ] ⊢Δ [b]) (G-ext [ρ] ⊢Δ [a] [b] [a≡b])) a = escapeTerm ([F] [ρ] ⊢Δ) [a] b = escapeTerm ([F] [ρ] ⊢Δ) [b] a≡b = escapeTermEq ([F] [ρ] ⊢Δ) [a≡b] ρn = conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG neN∘a = ∘ₙ (wkNeutral ρ neN) neN∘b = ∘ₙ (wkNeutral ρ neN) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∘a neN∘b (ρn ∘ⱼ a) (conv (ρn ∘ⱼ b) (≅-eq G[a]≡G[b])) ((~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡b))) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) in neuTerm ([G] [ρ] ⊢Δ [a]) (∘ₙ (wkNeutral ρ neN)) (conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡a)) neuTerm:⇒*: {ι ¹} (emb l< X) neN n n:≡:n′ = neuTerm:⇒*: X neN n n:≡:n′ neuTerm:⇒*: {∞} (emb l< X) neN n n:≡:n′ = neuTerm:⇒*: X neN n n:≡:n′ -- Neutrally equal terms are of reducible equality. neuEqTerm:⇒*: : ∀ {l Γ A t u n n′ ll} ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) (neN : Neutral n) (neN′ : Neutral n′) → Γ ⊢ t :⇒*: n ∷ A ^ ll → Γ ⊢ u :⇒*: n′ ∷ A ^ ll → Γ ⊢ n ~ n′ ∷ A ^ [ ! , ll ] → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] neuEqTerm:⇒*: {ι ¹} (Uᵣ′ A _ r ⁰ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n' = let n~n = ~-trans n~n' (~-sym n~n') n'~n' = ~-trans (~-sym n~n') n~n' n~n'U = ~-conv n~n' (subset* D) n~nU = ~-conv n~n (subset* D) [t] = neuTerm:⇒*: (Uᵣ′ A _ r ⁰ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN [[ ⊢t , n , D' ]] n~n Uₜ _ _ _ _ [Δt] = [t] D'' = conv:⇒*: [[ ⊢t , n , D' ]] (subset* D) D′' = conv:⇒*: [[ ⊢u , n′ , D′ ]] (subset* D) in Uₜ₌ [t] (neuTerm:⇒*: (Uᵣ′ A _ r ⁰ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN′ [[ ⊢u , n′ , D′ ]] n'~n') (~-to-≅ₜ n~n'U) λ {ρ} [ρ] ⊢Δ → let ρD' = wkRed:*:Term [ρ] ⊢Δ D'' ρD′ = wkRed:*:Term [ρ] ⊢Δ D′' n~nUρ = ~-wk [ρ] ⊢Δ n~nU n~n'Uρ = ~-wk [ρ] ⊢Δ n~n'U in neuEq:⇒*: {l = ι ¹} (neu:⇒*: (wkNeutral ρ neN) (univ:⇒*: ρD') n~nUρ) (wkNeutral ρ neN) (wkNeutral ρ neN′) (univ:⇒*: ρD') (univ:⇒*: ρD′) n~n'Uρ neuEqTerm:⇒*: {∞} (Uᵣ′ A _ r ¹ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n' = let n~n = ~-trans n~n' (~-sym n~n') n'~n' = ~-trans (~-sym n~n') n~n' n~n'U = ~-conv n~n' (subset* D) n~nU = ~-conv n~n (subset* D) [t] = neuTerm:⇒*: (Uᵣ′ A _ r ¹ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN [[ ⊢t , n , D' ]] n~n Uₜ _ _ _ _ [Δt] = [t] D'' = conv:⇒*: [[ ⊢t , n , D' ]] (subset* D) D′' = conv:⇒*: [[ ⊢u , n′ , D′ ]] (subset* D) in Uₜ₌ [t] (neuTerm:⇒*: (Uᵣ′ A _ r ¹ l< PE.refl [[ ⊢A , ⊢U , D ]]) neN′ [[ ⊢u , n′ , D′ ]] n'~n') (~-to-≅ₜ n~n'U) λ {ρ} [ρ] ⊢Δ → let ρD' = wkRed:*:Term [ρ] ⊢Δ D'' ρD′ = wkRed:*:Term [ρ] ⊢Δ D′' n~nUρ = ~-wk [ρ] ⊢Δ n~nU n~n'Uρ = ~-wk [ρ] ⊢Δ n~n'U in neuEq:⇒*: {l = ∞} (neu:⇒*: (wkNeutral ρ neN) (univ:⇒*: ρD') n~nUρ) (wkNeutral ρ neN) (wkNeutral ρ neN′) (univ:⇒*: ρD') (univ:⇒*: ρD′) n~n'Uρ neuEqTerm:⇒*: (ℕᵣ [[ ⊢A , ⊢B , D ]]) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n′ = let A≡ℕ = subset* D n~n′₁ = ~-conv n~n′ A≡ℕ n≡n′ = ~-to-≅ₜ n~n′₁ in ℕₜ₌ _ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ℕ) (conv:⇒*: [[ ⊢u , n′ , D′ ]] A≡ℕ) n≡n′ (ne (neNfₜ₌ neN neN′ n~n′₁)) neuEqTerm:⇒*: (ne (ne K [[ ⊢A , ⊢B , D ]] neK K≡K)) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n′ = let A≡K = subset* D in neₜ₌ _ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡K) (conv:⇒*: [[ ⊢u , n′ , D′ ]] A≡K) (neNfₜ₌ neN neN′ (~-conv n~n′ A≡K)) neuEqTerm:⇒*: (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ [[ ⊢t , n , D' ]] [[ ⊢u , n′ , D′ ]] n~n′ = let [ΠFG] = Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext A≡ΠFG = subset* D n~n′₁ = ~-conv n~n′ A≡ΠFG n≡n′ = ~-to-≅ₜ n~n′₁ n~n = ~-trans n~n′ (~-sym n~n′) n′~n′ = ~-trans (~-sym n~n′) n~n′ in Πₜ₌ _ _ (conv:⇒*: [[ ⊢t , n , D' ]] A≡ΠFG) (conv:⇒*: [[ ⊢u , n′ , D′ ]] A≡ΠFG) (ne neN) (ne neN′) n≡n′ (neuTerm:⇒*: [ΠFG] neN [[ ⊢t , n , D' ]] n~n) (neuTerm:⇒*: [ΠFG] neN′ [[ ⊢u , n′ , D′ ]] n′~n′) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ A≡ΠFG ρn = wkTerm [ρ] ⊢Δ n ρn′ = wkTerm [ρ] ⊢Δ n′ a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) neN∙a = ∘ₙ (wkNeutral ρ neN) neN′∙a′ = ∘ₙ (wkNeutral ρ neN′) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∙a neN′∙a′ (conv ρn ρA≡ρΠFG ∘ⱼ a) (conv ρn′ ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ n~n′₁) a≡a) ) neuEqTerm:⇒*: {ι ¹} (emb l< X) neN n neN′ n:≡:n′ = neuEqTerm:⇒*: X neN n neN′ n:≡:n′ neuEqTerm:⇒*: {∞} (emb l< X) neN n neN′ n:≡:n′ = neuEqTerm:⇒*: X neN n neN′ n:≡:n′
State Before: α : Type u_1 β : Type ?u.112926 inst✝² : Preorder α inst✝¹ : Preorder β inst✝ : LocallyFiniteOrder α a b : α ⊢ Ico (↑toDual a) (↑toDual b) = map (Equiv.toEmbedding toDual) (Ioc b a) State After: α : Type u_1 β : Type ?u.112926 inst✝² : Preorder α inst✝¹ : Preorder β inst✝ : LocallyFiniteOrder α a b : α ⊢ Ico (↑toDual a) (↑toDual b) = Ioc b a Tactic: refine' Eq.trans _ map_refl.symm State Before: α : Type u_1 β : Type ?u.112926 inst✝² : Preorder α inst✝¹ : Preorder β inst✝ : LocallyFiniteOrder α a b : α ⊢ Ico (↑toDual a) (↑toDual b) = Ioc b a State After: case a α : Type u_1 β : Type ?u.112926 inst✝² : Preorder α inst✝¹ : Preorder β inst✝ : LocallyFiniteOrder α a b : α c : (fun x => αᵒᵈ) a ⊢ c ∈ Ico (↑toDual a) (↑toDual b) ↔ c ∈ Ioc b a Tactic: ext c State Before: case a α : Type u_1 β : Type ?u.112926 inst✝² : Preorder α inst✝¹ : Preorder β inst✝ : LocallyFiniteOrder α a b : α c : (fun x => αᵒᵈ) a ⊢ c ∈ Ico (↑toDual a) (↑toDual b) ↔ c ∈ Ioc b a State After: case a α : Type u_1 β : Type ?u.112926 inst✝² : Preorder α inst✝¹ : Preorder β inst✝ : LocallyFiniteOrder α a b : α c : (fun x => αᵒᵈ) a ⊢ ↑toDual a ≤ c ∧ c < ↑toDual b ↔ b < c ∧ c ≤ a Tactic: rw [mem_Ico, mem_Ioc (α := α)] State Before: case a α : Type u_1 β : Type ?u.112926 inst✝² : Preorder α inst✝¹ : Preorder β inst✝ : LocallyFiniteOrder α a b : α c : (fun x => αᵒᵈ) a ⊢ ↑toDual a ≤ c ∧ c < ↑toDual b ↔ b < c ∧ c ≤ a State After: no goals Tactic: exact and_comm
{-# OPTIONS --safe #-} module Cubical.Categories.Morphism where open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Categories.Category private variable ℓ ℓ' : Level -- C needs to be explicit for these definitions as Agda can't infer it module _ (C : Category ℓ ℓ') where open Category C private variable x y z w : ob isMonic : Hom[ x , y ] → Type (ℓ-max ℓ ℓ') isMonic {x} {y} f = ∀ {z} {a a' : Hom[ z , x ]} → f ∘ a ≡ f ∘ a' → a ≡ a' isEpic : (Hom[ x , y ]) → Type (ℓ-max ℓ ℓ') isEpic {x} {y} g = ∀ {z} {b b' : Hom[ y , z ]} → b ∘ g ≡ b' ∘ g → b ≡ b' -- A morphism is split monic if it has a *retraction* isSplitMon : (Hom[ x , y ]) → Type ℓ' isSplitMon {x} {y} f = ∃[ r ∈ Hom[ y , x ] ] r ∘ f ≡ id -- A morphism is split epic if it has a *section* isSplitEpi : (Hom[ x , y ]) → Type ℓ' isSplitEpi {x} {y} g = ∃[ s ∈ Hom[ y , x ] ] g ∘ s ≡ id record areInv (f : Hom[ x , y ]) (g : Hom[ y , x ]) : Type ℓ' where field sec : g ⋆ f ≡ id ret : f ⋆ g ≡ id record isIso (f : Hom[ x , y ]) : Type ℓ' where field inv : Hom[ y , x ] sec : inv ⋆ f ≡ id ret : f ⋆ inv ≡ id -- C can be implicit here module _ {C : Category ℓ ℓ'} where open Category C private variable x y z w : ob open areInv symAreInv : {f : Hom[ x , y ]} {g : Hom[ y , x ]} → areInv C f g → areInv C g f sec (symAreInv x) = ret x ret (symAreInv x) = sec x -- equational reasoning with inverses invMoveR : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]} {h : Hom[ z , x ]} {k : Hom[ z , y ]} → areInv C f g → h ⋆ f ≡ k → h ≡ k ⋆ g invMoveR {f = f} {g} {h} {k} ai p = h ≡⟨ sym (⋆IdR _) ⟩ (h ⋆ id) ≡⟨ cong (h ⋆_) (sym (ai .ret)) ⟩ (h ⋆ (f ⋆ g)) ≡⟨ sym (⋆Assoc _ _ _) ⟩ ((h ⋆ f) ⋆ g) ≡⟨ cong (_⋆ g) p ⟩ k ⋆ g ∎ invMoveL : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]} {h : Hom[ y , z ]} {k : Hom[ x , z ]} → areInv C f g → f ⋆ h ≡ k → h ≡ g ⋆ k invMoveL {f = f} {g} {h} {k} ai p = h ≡⟨ sym (⋆IdL _) ⟩ id ⋆ h ≡⟨ cong (_⋆ h) (sym (ai .sec)) ⟩ (g ⋆ f) ⋆ h ≡⟨ ⋆Assoc _ _ _ ⟩ g ⋆ (f ⋆ h) ≡⟨ cong (g ⋆_) p ⟩ (g ⋆ k) ∎ open isIso isIso→areInv : ∀ {f : Hom[ x , y ]} → (isI : isIso C f) → areInv C f (isI .inv) sec (isIso→areInv isI) = sec isI ret (isIso→areInv isI) = ret isI open CatIso -- isIso agrees with CatIso isIso→CatIso : ∀ {f : C [ x , y ]} → isIso C f → CatIso C x y mor (isIso→CatIso {f = f} x) = f inv (isIso→CatIso x) = inv x sec (isIso→CatIso x) = sec x ret (isIso→CatIso x) = ret x CatIso→isIso : (cIso : CatIso C x y) → isIso C (cIso .mor) inv (CatIso→isIso f) = inv f sec (CatIso→isIso f) = sec f ret (CatIso→isIso f) = ret f CatIso→areInv : (cIso : CatIso C x y) → areInv C (cIso .mor) (cIso .inv) CatIso→areInv cIso = isIso→areInv (CatIso→isIso cIso) -- reverse of an iso is also an iso symCatIso : ∀ {x y} → CatIso C x y → CatIso C y x symCatIso (catiso mor inv sec ret) = catiso inv mor ret sec
If two functions are equal in a neighborhood of a point, then they have the same pole at that point.
library(npowerPrioR) scenario <- 4 source(paste("data_Bernoulli_scenario_", scenario, ".r", sep = "")) library(rstan) rstan_options(auto_write = TRUE) options(mc.cores = 4) #### Sampling from the "prior" prior <- stan_model("stan/simple_Bernoulli_prior.stan") bb.data <- list( N0 = N_0, y0 = y_0, c = cc, d = dd, a_0 = NA ) ##################### epsilon <- 0.05 J <- 20 maxA <- 1 adaptive.time <- system.time( adaptive.ca0.estimates <- build_grid(compiled.model.prior = prior, eps = epsilon, M = maxA, J = J, v1 = 10, v2 = 10, stan.list = bb.data, pars = "theta") ) warnings() write.csv(adaptive.ca0.estimates$result, file = paste("../../data/constant_data/Bernoulli_logCA0_scenario_", scenario, "_J=", J, ".csv", sep = ""), row.names = FALSE) summaries.adaptive <- adaptive.ca0.estimates$summaries for (j in 1:length(summaries.adaptive)){ summaries.adaptive[[j]] <- data.frame(summaries.adaptive[[j]], a_0 = adaptive.ca0.estimates$result$a0[j]) } summaries.adaptive.dt <- do.call(rbind, summaries.adaptive) write.csv(summaries.adaptive.dt, file = paste("../../data/sensitivity_data/priorSensitivity_simpleBernoulli_adaptive_scenario_", scenario, "_J=", J, ".csv", sep = ""))
/- Copyright (c) 2018 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Reid Barton, Bhavik Mehta ! This file was ported from Lean 3 source module category_theory.limits.constructions.over.connected ! leanprover-community/mathlib commit 10bf4f825ad729c5653adc039dafa3622e7f93c9 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathbin.CategoryTheory.Limits.Creates import Mathbin.CategoryTheory.Over import Mathbin.CategoryTheory.IsConnected /-! # Connected limits in the over category > THIS FILE IS SYNCHRONIZED WITH MATHLIB4. > Any changes to this file require a corresponding PR to mathlib4. Shows that the forgetful functor `over B ⥤ C` creates connected limits, in particular `over B` has any connected limit which `C` has. -/ universe v u -- morphism levels before object levels. See note [category_theory universes]. noncomputable section open CategoryTheory CategoryTheory.Limits variable {J : Type v} [SmallCategory J] variable {C : Type u} [Category.{v} C] variable {X : C} namespace CategoryTheory.Over namespace CreatesConnected /- warning: category_theory.over.creates_connected.nat_trans_in_over -> CategoryTheory.Over.CreatesConnected.natTransInOver is a dubious translation: lean 3 declaration is forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] {B : C} (F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B)), Quiver.Hom.{succ u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2))) (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B)) (CategoryTheory.Functor.obj.{u1, u1, u2, max u1 u2} C _inst_2 (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.const.{u1, u1, u1, u2} J _inst_1 C _inst_2) B) but is expected to have type forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] {B : C} (F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B)), Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2))) (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B)) (Prefunctor.obj.{succ u1, succ u1, u2, max u1 u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_2)) (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, max u1 u2} C _inst_2 (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.const.{u1, u1, u1, u2} J _inst_1 C _inst_2)) B) Case conversion may be inaccurate. Consider using '#align category_theory.over.creates_connected.nat_trans_in_over CategoryTheory.Over.CreatesConnected.natTransInOverₓ'. -/ /-- (Impl) Given a diagram in the over category, produce a natural transformation from the diagram legs to the specific object. -/ def natTransInOver {B : C} (F : J ⥤ Over B) : F ⋙ forget B ⟶ (CategoryTheory.Functor.const J).obj B where app j := (F.obj j).Hom #align category_theory.over.creates_connected.nat_trans_in_over CategoryTheory.Over.CreatesConnected.natTransInOver attribute [local tidy] tactic.case_bash #print CategoryTheory.Over.CreatesConnected.raiseCone /- /-- (Impl) Given a cone in the base category, raise it to a cone in the over category. Note this is where the connected assumption is used. -/ @[simps] def raiseCone [IsConnected J] {B : C} {F : J ⥤ Over B} (c : Cone (F ⋙ forget B)) : Cone F where pt := Over.mk (c.π.app (Classical.arbitrary J) ≫ (F.obj (Classical.arbitrary J)).Hom) π := { app := fun j => Over.homMk (c.π.app j) (nat_trans_from_is_connected (c.π ≫ natTransInOver F) j _) } #align category_theory.over.creates_connected.raise_cone CategoryTheory.Over.CreatesConnected.raiseCone -/ /- warning: category_theory.over.creates_connected.raised_cone_lowers_to_original -> CategoryTheory.Over.CreatesConnected.raised_cone_lowers_to_original is a dubious translation: lean 3 declaration is forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.IsConnected.{u1, u1} J _inst_1] {B : C} {F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B)} (c : CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))), (CategoryTheory.Limits.IsLimit.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B)) c) -> (Eq.{max (succ u2) (succ u1)} (CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} C _inst_2 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) C _inst_2 (CategoryTheory.Functor.id.{u1, u2} C _inst_2) (CategoryTheory.Functor.fromPUnit.{u1, u2} C _inst_2 B)) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))) (CategoryTheory.Functor.mapCone.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} C _inst_2 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) C _inst_2 (CategoryTheory.Functor.id.{u1, u2} C _inst_2) (CategoryTheory.Functor.fromPUnit.{u1, u2} C _inst_2 B)) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B) (CategoryTheory.Over.CreatesConnected.raiseCone.{u1, u2} J _inst_1 C _inst_2 _inst_3 B F c)) c) but is expected to have type forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.IsConnected.{u1, u1} J _inst_1] {B : C} {F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B)} (c : CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))), Eq.{max (succ u2) (succ u1)} (CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))) (CategoryTheory.Functor.mapCone.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B) F (CategoryTheory.Over.CreatesConnected.raiseCone.{u1, u2} J _inst_1 C _inst_2 _inst_3 B F c)) c Case conversion may be inaccurate. Consider using '#align category_theory.over.creates_connected.raised_cone_lowers_to_original CategoryTheory.Over.CreatesConnected.raised_cone_lowers_to_originalₓ'. -/ theorem raised_cone_lowers_to_original [IsConnected J] {B : C} {F : J ⥤ Over B} (c : Cone (F ⋙ forget B)) (t : IsLimit c) : (forget B).mapCone (raiseCone c) = c := by tidy #align category_theory.over.creates_connected.raised_cone_lowers_to_original CategoryTheory.Over.CreatesConnected.raised_cone_lowers_to_original #print CategoryTheory.Over.CreatesConnected.raisedConeIsLimit /- /-- (Impl) Show that the raised cone is a limit. -/ def raisedConeIsLimit [IsConnected J] {B : C} {F : J ⥤ Over B} {c : Cone (F ⋙ forget B)} (t : IsLimit c) : IsLimit (raiseCone c) where lift s := Over.homMk (t.lift ((forget B).mapCone s)) (by dsimp simp) uniq s m K := by ext1 apply t.hom_ext intro j simp [← K j] #align category_theory.over.creates_connected.raised_cone_is_limit CategoryTheory.Over.CreatesConnected.raisedConeIsLimit -/ end CreatesConnected #print CategoryTheory.Over.forgetCreatesConnectedLimits /- /-- The forgetful functor from the over category creates any connected limit. -/ instance forgetCreatesConnectedLimits [IsConnected J] {B : C} : CreatesLimitsOfShape J (forget B) where CreatesLimit K := createsLimitOfReflectsIso fun c t => { liftedCone := CreatesConnected.raiseCone c validLift := eqToIso (CreatesConnected.raised_cone_lowers_to_original c t) makesLimit := CreatesConnected.raisedConeIsLimit t } #align category_theory.over.forget_creates_connected_limits CategoryTheory.Over.forgetCreatesConnectedLimits -/ #print CategoryTheory.Over.has_connected_limits /- /-- The over category has any connected limit which the original category has. -/ instance has_connected_limits {B : C} [IsConnected J] [HasLimitsOfShape J C] : HasLimitsOfShape J (Over B) where HasLimit F := hasLimit_of_created F (forget B) #align category_theory.over.has_connected_limits CategoryTheory.Over.has_connected_limits -/ end CategoryTheory.Over
\chapter{Evaluation}\label{chap:evaluation} Evaluating the \bslongs{} derived from \dbased{} clustering and classification accuracy of \krap{} is key to gauging the effectiveness of these two techniques. For the \dbased{} clustering method, we focused on cluster purity and clustering coverage. For \krap{}, we investigate precision and recall and use an indicator that balances both of them called the \fmeasure{}. \input{chapters/evaluation/purity} \input{chapters/evaluation/metrics}
The function $f$ tends to infinity if and only if the function $1/f$ tends to zero from the right.
# GEOL351 Lab 9 # Multiple Climate Equilibria: Icehouse vs Hothouse ## Student Name : [WRITE YOUR NAME HERE] In this lab, you will explore, tweak and tinker with the zero-dimensional climate model seen in class. This model, and much of the following lab, is strongly inspired by Ray Pierrehumbert's excellent book, [Principles of Planetary Climate](http://www.cambridge.org/raypierre). We will be working in the iPython / Jupyter notebook system. We like these because they are a form of literate programming in which we can mix textbook instruction and explanations with code that can also be run and edited. You will be asked to run some cells, tweak parameters and write down results. **Please save the resulting notebook once you are done; this is what you will be handing out**. Think you can't code? Be reassured, we will guide you by the hand. The beauty of iPython notebooks is that they integrate the code very naturally in a scholarly document, and the most you will have to do is sliughtly edit the code and watch how this affects the results. This should allow you to focus on the dynamics, not so much the informatics. Let's start with a little preliminary learning. ## Part 0: iPython notebooks ### Python Haven't you always wanted to code? Thanks to [Python](https://www.python.org/), anyone with a modicum of common sense and a keyboard can do so. Python is a high-level language whose syntax makes it very difficult to be a bad programmer. For a few of the many reasons why you should pick up Python before your education is over, read [this](http://www.nature.com/news/programming-pick-up-python-1.16833?WT.ec_id=NATURE-20150206). ### Markdown You can document your iPython notebooks by making some cells into [Markdown Website](http://daringfireball.net/projects/markdown/) cells. Markdown is a way of formatting text that is supposed to be almost as readable un-rendered as when it is tidied up. If you look at the **Markdown** cells as source code (by double-clicking on them) you will see how the raw text looks. If you can deal with the unwieldy and ugly Microsoft Word, you can certainly handle Markdown. You will be expected to turn in your lab for grading as a notebook, so you should write all your notes, observations, and concluions in the notebook. ### Maths In a browser, you can render beautiful equations using a javascript tool called [Mathjax Website](http://docs.mathjax.org) which is build into the iPython notebooks. It is based on a [LaTeX](https://www.latex-project.org/) engine, You can build in symbols to your text such as $\pi$ and $\epsilon$ if you use the \$ signs to indicate where your equations begin and end, and you know enough $\LaTeX$ [try it here !](http://www.codecogs.com/latex/eqneditor.php) to get by. Equations in 'display' mode are written like this (again look at the source for this cell to see what is used) \\[ e^{i\pi} + 1 = 0 \\] or even like this \begin{equation} %% \nabla^4 \psi = \frac{\partial T}{\partial x} %% \end{equation} Go back to the rendered form of the cell by 'running' it. ## A zero-dimensional climate model The dynamics are governed by conservation of energy, which takes the form of an ordinary linear equation: $ C_s \frac{d T_e}{dt} = \left(1 -\alpha(T_e) \right) \frac{S_{\circ}}{4} - \sigma {T_e}^4 \equiv G(T_e)$ [Eq (1)] with $T_e$ the *emission temperature* and the albedo $\alpha$ is a nonlinear function of climate state (indexed by $T_e$, which is therefore the *state variable* for the system). $\alpha$ is given by : $\alpha(T) = \begin{cases} \alpha_i & \text{for } T \leq T_i \\ \alpha_0 + (\alpha_i- \alpha_0) \frac{(T-T_0)^2}{(T_i-T_0)^2} & \text{for } T_i < T < T_0 \\ \alpha_0 & \text{for } T \geq T_0 \\ \end{cases} $ [Eq (2)] By definition, the emission of radiation to outer space takes place at some height $z_rad$ above the ground, corresponding to a pressure $p_\text{rad}$. The greenhouse effect can be understood as a tendency to raise the emission level, hence lower $p_\text{rad}$. Choosing $p_\text{rad} = 670 mb$ yields a climate not to dissimilar to our current one. ** Question 1: ** Is the planet's emission of electromagnetic radiation in the longwave or shortwave domain? What does this depend on? ** Answer 1 ** : PLEASE WRITE YOUR ANSWER HERE The other relation we need is the relationship between the surface temperature $T_s$ and $T_e$: $T_s = T_e \left(\frac{p_s}{p_\text{rad}} \right)^{\kappa}$ where $\kappa = 2/7$ If we assume that $p_s$ and $p_\text{rad}$ are both constant, working with $T_e$ is equivalent to working with $T_s$, which we shall do from now on. Now, in order to get going, we need to set up a few preliminaries. First, let's import other bits and pieces of Python code to save us some time. ```python %matplotlib inline # ensures that graphics display in the notebook import matplotlib import numpy as np import matplotlib.pyplot as plt import sys sys.path.append("./CoursewareModules") from ClimateUtilities import * # import Ray Pierrehumbert's climate utilities import phys import seaborn as sns ``` ## Outgoing Long-wave radiation Let us define a function that will compute outgoing longwave emission from the planet for a given emission temperature $T$ (dropping the subscript for convenience). ```python def OLR(T,param=None): pRad = param return phys.sigma * (T**4.)*(pRad/1000.)**(4.*2./7.) ``` The radiating pressure pRad, in mb, is passed as the optional second parameter. It can be used to pass parameters of other OLR expressions, e.g. CO2 concentrations. Let's see how this depends on T. ## Incoming solar radiation Similarly, let's define a function for the albedo, $\alpha(T)$. ```python def albedo(T): if T < T1: return alpha_ice elif (T >= T1)&(T<=T2): r = (T-T2)**2/(T2-T1)**2 return alpha_0 + (alpha_ice - alpha_0)*r else: return alpha_0 ``` Notice how the function uses "global" arguments alpha_ice, alpha_ice, T1, T2. We need to define those for the function to work. Let's do this, along with defining pRad. ```python L = 1.*1370. alpha_ice = .6 alpha_0 = .2 T1 = 260. # in Kelvins T2 = 290. # in Kelvins pRad = 1000. # in mb ``` The next cell generates lists of values for OLR, the next flux, and the incoming radiation given a range of temperature values from 200 to 340 K. ```python Tlist = [200.+ 2.*i for i in range(70)] SabsList = [] OLRlist = [] NetFluxlist = [] Glist = [] aList = [] for T in Tlist: aList.append(albedo(T)) # albedo function SabsList.append((L/4.)*(1.-albedo(T))) # incident solar values OLRlist.append(OLR(T,pRad)) # outgoing longwave emissions NetFluxlist.append((L/4.)*(1.-albedo(T)) - OLR(T,pRad)) # net flux Glist.append(4.*OLR(T,pRad)/(1.-albedo(T))) # balance function ``` Time to plot a few things! First, the albedo: ```python c1 = Curve() c1.addCurve(Tlist) c1.addCurve(aList,'Albedo','Alb') c1.Xlabel = 'Temperature (K)' c1.Ylabel = 'Alpha' c1.PlotTitle = 'Planetary Albedo' w1 = plot(c1) plt.ylim((0, 0.8)) ``` ## Energy Balance Next, let's look at energy balance. What's coming in, what's going out? ```python c1 = Curve() c1.addCurve(Tlist) c1.addCurve(SabsList,'Sabs','Absorbed Solar') c1.addCurve(OLRlist,'OLR','Outgoing Longwave') c1.Xlabel = 'Temperature (K)' c1.Ylabel = 'Flux ($W/m^2$)' c1.PlotTitle = 'Energy Balance Diagram' w1 = plot(c1) ``` Another way to look at this is to graph the difference between these curves (which we called $G(T)$ above) ```python c2 = Curve() c2.addCurve(Tlist) c2.addCurve(NetFluxlist,'Net','Net Flux') c2.addCurve([0. for i in range(len(Glist))],'Zero','Equilibrium') c2.Xlabel = 'Temperature (K)' c2.Ylabel = 'Net Flux ($W/m^2$)' c2.PlotTitle = 'Stability diagram' w2 = plot(c2) ``` ### Question 2: Solving graphically, **for which values of the solar luminosity L do we get 1, 2 or 3 equilibria?** ### Answer 2: Write your answer here What you just did, informally, is to draw a **bifurcation diagram** for the system. Now we can be a lot smarter about this, and instead of typing like monkeys hoping to recreate Shakespeare (or Pierrehumbert as the case may be), we can try to solve for $G(T) = 0$. ### Question 3: **Setting $G(T) = 0$, derive an analytical expression for $L_{eq}$, the value of $L$ for which incoming solar radiation balances exactly outgoing longwave radiation. ** ### Answer 3: Write your answer here ## Solar Bifurcation Next we plot this value as a function of $T$. However, let's introduce a little twist: $T$ of course, is a consequence of the value of L and pRad, not a cause of it. So we should switch the X and Y axes so that we get $T = f(L)$, not $ L = f(T)$. ```python c3 = Curve() c3.addCurve(Tlist) c3.addCurve(Glist,'G','Balance Function') c3.addCurve([L for i in range(len(Glist))],'S','Incident Solar') c3.switchXY = True #Switches axis so it looks like a hysteresis plot c3.PlotTitle = 'Bifurcation diagram, pRad = %f mb'%pRad c3.Xlabel = 'Surface Temperature (K)' c3.Ylabel = 'Solar Constant ($W/m^2$)' w3 = plot(c3) ``` Once again, wherever this balance function (blue curve) inersects the incident solar radiation (dashed green curve), we get one or more equilibrium temperature(s). From this it is easy to find the values of the solar constant for which we can have 1, 2 or 3 equilibria. Note that some of the branches in this diagram are unstable. For instance, as you vary L from 1370 up to 3000, say, at some point you will leave the lower branch and land abruptly and without warning, on the upper branch. This is one reason why bifurcations are relevant to climate risk assessment. ### Question 4 The current greenhouse effect yields a radiative pressure pRad in the neighborhood of 670mb. Repeat the calculations above for this value of $p_{Rad}$, (it will be cleaner if you copy and paste the relevant cells below). ** For which value of L, approximately, would we enter a stable snowball state? ** (to answer this, redraw the bifurcation diagram above with $p_{Rad}=670$mb. For $L = 1370 W.m^{-2}$ you should find 3 possible states. Assume that you are on the upper, toasty branch. For which value of $L$ would you fall onto the lower, icy branch?) ```python # perform your new calculations here ``` ### Answer 4 write your answer here Finally, we could ask what kind of climate would be obtained by varying the atmosphere's opacity to outgoing longwave radiation (i.e. its concentration of greenhouse gases). We seek a stability diagram similar to the one above, but cast in terms of radiative pressure $p_{rad}$ instead of $L$. ### Question 5 ** What is the effect of lowering $p_{rad}$ on the surface temperature $T_s$? ** You may answer using purely mathematical, physical, or heuristic arguments (one way to do this is to vary $p_{rad}$ and see how it affects the OLR). ### Answer 5 write your answer here ## Greenhouse Bifurcation To draw the bifurcation diagram in terms of $p_{rad}$ we need a bit more machinery. Let's define a function that solves for radiative pressure given the solar flux and the temperature. (if you really want to know, it uses Newton-Raphson's method, but you needn't worry about that) ```python def radPress(flux,T): def g(p,const): return OLR(const.T,p) - const.flux root = newtSolve(g) const= Dummy() const.T = T const.flux = flux root.setParams(const) return root(500.) L = 1370. TList = [220.+i for i in range(131)] gList = [radPress((1.-albedo(T))*L/4.,T) for T in TList] cG = Curve() cG.addCurve(gList,'pRad') cG.addCurve(TList,'T') #Just for variety, here I've shown that instead of # switching axes, you can just put the data into # the Curve in a different order cG.PlotTitle = 'Bifurcation diagram, L = %f W/m**2'%L cG.Ylabel = 'Surface Temperature (K)' cG.Xlabel = 'Radiating pressure (mb)' cG.reverseX = True #Reverse pressure axis so warmer is to the right plot(cG) ``` ### Question 6 ### Assume the current climate state is pRad = 670 mb. Where on the diagram do you think we are? (upper or lower branch?). The solar luminosity L was about 7% lower during the Neoproterozoic. ** Would this have been enough to trigger a glaciation? If not, what value of L would have? ** ### Answer 6 ###
[STATEMENT] lemma polyfun_single: assumes "i\<in>N" shows "polyfun N (\<lambda>x. x i)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. polyfun N (\<lambda>x. x i) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. polyfun N (\<lambda>x. x i) [PROOF STEP] have "\<forall>f. insertion f (monom (Poly_Mapping.single i 1) 1) = f i" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>f. insertion f (monom (Poly_Mapping.single i 1) (1::'b)) = f i [PROOF STEP] using insertion_single [PROOF STATE] proof (prove) using this: insertion ?f (monom (Poly_Mapping.single ?v ?n) ?a) = ?a * ?f ?v ^ ?n goal (1 subgoal): 1. \<forall>f. insertion f (monom (Poly_Mapping.single i 1) (1::'b)) = f i [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<forall>f. insertion f (monom (Poly_Mapping.single i 1) (1::?'b1)) = f i goal (1 subgoal): 1. polyfun N (\<lambda>x. x i) [PROOF STEP] then [PROOF STATE] proof (chain) picking this: \<forall>f. insertion f (monom (Poly_Mapping.single i 1) (1::?'b1)) = f i [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: \<forall>f. insertion f (monom (Poly_Mapping.single i 1) (1::?'b1)) = f i goal (1 subgoal): 1. polyfun N (\<lambda>x. x i) [PROOF STEP] unfolding polyfun_def [PROOF STATE] proof (prove) using this: \<forall>f. insertion f (monom (Poly_Mapping.single i 1) (1::?'b1)) = f i goal (1 subgoal): 1. \<exists>p. vars p \<subseteq> N \<and> (\<forall>x. insertion x p = x i) [PROOF STEP] using vars_monom_single[of i 1 1] One_nat_def assms singletonD subset_eq [PROOF STATE] proof (prove) using this: \<forall>f. insertion f (monom (Poly_Mapping.single i 1) (1::?'b1)) = f i vars (monom (Poly_Mapping.single i 1) (1::?'b1)) \<subseteq> {i} 1 = Suc 0 i \<in> N ?b \<in> {?a} \<Longrightarrow> ?b = ?a (?A \<subseteq> ?B) = (\<forall>x\<in>?A. x \<in> ?B) goal (1 subgoal): 1. \<exists>p. vars p \<subseteq> N \<and> (\<forall>x. insertion x p = x i) [PROOF STEP] by blast [PROOF STATE] proof (state) this: polyfun N (\<lambda>x. x i) goal: No subgoals! [PROOF STEP] qed
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro ! This file was ported from Lean 3 source module data.finset.lattice ! leanprover-community/mathlib commit 1c857a1f6798cb054be942199463c2cf904cb937 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Data.Finset.Fold import Mathlib.Data.Finset.Option import Mathlib.Data.Finset.Prod import Mathlib.Data.Multiset.Lattice import Mathlib.Order.CompleteLattice /-! # Lattice operations on finsets -/ variable {α β γ ι : Type _} namespace Finset open Multiset OrderDual /-! ### sup -/ section Sup -- TODO: define with just `[Bot α]` where some lemmas hold without requiring `[OrderBot α]` variable [SemilatticeSup α] [OrderBot α] /-- Supremum of a finite set: `sup {a, b, c} f = f a ⊔ f b ⊔ f c` -/ def sup (s : Finset β) (f : β → α) : α := s.fold (· ⊔ ·) ⊥ f #align finset.sup Finset.sup variable {s s₁ s₂ : Finset β} {f g : β → α} {a : α} theorem sup_def : s.sup f = (s.1.map f).sup := rfl #align finset.sup_def Finset.sup_def @[simp] theorem sup_empty : (∅ : Finset β).sup f = ⊥ := fold_empty #align finset.sup_empty Finset.sup_empty @[simp] theorem sup_cons {b : β} (h : b ∉ s) : (cons b s h).sup f = f b ⊔ s.sup f := fold_cons h #align finset.sup_cons Finset.sup_cons @[simp] theorem sup_insert [DecidableEq β] {b : β} : (insert b s : Finset β).sup f = f b ⊔ s.sup f := fold_insert_idem #align finset.sup_insert Finset.sup_insert theorem sup_image [DecidableEq β] (s : Finset γ) (f : γ → β) (g : β → α) : (s.image f).sup g = s.sup (g ∘ f) := fold_image_idem #align finset.sup_image Finset.sup_image @[simp] theorem sup_map (s : Finset γ) (f : γ ↪ β) (g : β → α) : (s.map f).sup g = s.sup (g ∘ f) := fold_map #align finset.sup_map Finset.sup_map @[simp] theorem sup_singleton {b : β} : ({b} : Finset β).sup f = f b := Multiset.sup_singleton #align finset.sup_singleton Finset.sup_singleton theorem sup_union [DecidableEq β] : (s₁ ∪ s₂).sup f = s₁.sup f ⊔ s₂.sup f := Finset.induction_on s₁ (by rw [empty_union, sup_empty, bot_sup_eq]) (fun a s _ ih => by rw [insert_union, sup_insert, sup_insert, ih, sup_assoc]) #align finset.sup_union Finset.sup_union theorem sup_sup : s.sup (f ⊔ g) = s.sup f ⊔ s.sup g := by refine' Finset.cons_induction_on s _ fun b t _ h => _ · rw [sup_empty, sup_empty, sup_empty, bot_sup_eq] · rw [sup_cons, sup_cons, sup_cons, h] exact sup_sup_sup_comm _ _ _ _ #align finset.sup_sup Finset.sup_sup theorem sup_congr {f g : β → α} (hs : s₁ = s₂) (hfg : ∀ a ∈ s₂, f a = g a) : s₁.sup f = s₂.sup g := by subst hs exact Finset.fold_congr hfg #align finset.sup_congr Finset.sup_congr @[simp] protected theorem sup_le_iff {a : α} : s.sup f ≤ a ↔ ∀ b ∈ s, f b ≤ a := by apply Iff.trans Multiset.sup_le simp only [Multiset.mem_map, and_imp, exists_imp] exact ⟨fun k b hb => k _ _ hb rfl, fun k a' b hb h => h ▸ k _ hb⟩ #align finset.sup_le_iff Finset.sup_le_iff alias Finset.sup_le_iff ↔ _ sup_le #align finset.sup_le Finset.sup_le -- Porting note: removed `attribute [protected] sup_le` theorem sup_const_le : (s.sup fun _ => a) ≤ a := Finset.sup_le fun _ _ => le_rfl #align finset.sup_const_le Finset.sup_const_le theorem le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f := Finset.sup_le_iff.1 le_rfl _ hb #align finset.le_sup Finset.le_sup @[simp] theorem sup_bunionᵢ [DecidableEq β] (s : Finset γ) (t : γ → Finset β) : (s.bunionᵢ t).sup f = s.sup fun x => (t x).sup f := eq_of_forall_ge_iff fun c => by simp [@forall_swap _ β] #align finset.sup_bUnion Finset.sup_bunionᵢ theorem sup_const {s : Finset β} (h : s.Nonempty) (c : α) : (s.sup fun _ => c) = c := eq_of_forall_ge_iff (fun _ => Finset.sup_le_iff.trans h.forall_const) #align finset.sup_const Finset.sup_const @[simp] theorem sup_bot (s : Finset β) : (s.sup fun _ => ⊥) = (⊥ : α) := by obtain rfl | hs := s.eq_empty_or_nonempty · exact sup_empty · exact sup_const hs _ #align finset.sup_bot Finset.sup_bot theorem sup_ite (p : β → Prop) [DecidablePred p] : (s.sup fun i => ite (p i) (f i) (g i)) = (s.filter p).sup f ⊔ (s.filter fun i => ¬p i).sup g := fold_ite _ #align finset.sup_ite Finset.sup_ite theorem sup_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ≤ g b) : s.sup f ≤ s.sup g := Finset.sup_le fun b hb => le_trans (h b hb) (le_sup hb) #align finset.sup_mono_fun Finset.sup_mono_fun theorem sup_mono (h : s₁ ⊆ s₂) : s₁.sup f ≤ s₂.sup f := Finset.sup_le (fun _ hb => le_sup (h hb)) #align finset.sup_mono Finset.sup_mono protected theorem sup_comm (s : Finset β) (t : Finset γ) (f : β → γ → α) : (s.sup fun b => t.sup (f b)) = t.sup fun c => s.sup fun b => f b c := by refine' eq_of_forall_ge_iff fun a => _ simp_rw [Finset.sup_le_iff] exact ⟨fun h c hc b hb => h b hb c hc, fun h b hb c hc => h c hc b hb⟩ #align finset.sup_comm Finset.sup_comm @[simp, nolint simpNF] -- Porting note: linter claims that LHS does not simplify theorem sup_attach (s : Finset β) (f : β → α) : (s.attach.sup fun x => f x) = s.sup f := (s.attach.sup_map (Function.Embedding.subtype _) f).symm.trans <| congr_arg _ attach_map_val #align finset.sup_attach Finset.sup_attach /-- See also `Finset.product_bunionᵢ`. -/ theorem sup_product_left (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ᶠ t).sup f = s.sup fun i => t.sup fun i' => f ⟨i, i'⟩ := by simp only [le_antisymm_iff, Finset.sup_le_iff, mem_product, and_imp, Prod.forall] -- Porting note: was one expression. refine ⟨fun b c hb hc => ?_, fun b hb c hc => ?_⟩ · refine (le_sup hb).trans' ?_ exact @le_sup _ _ _ _ _ (fun c => f (b, c)) c hc · exact le_sup <| mem_product.2 ⟨hb, hc⟩ #align finset.sup_product_left Finset.sup_product_left theorem sup_product_right (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ᶠ t).sup f = t.sup fun i' => s.sup fun i => f ⟨i, i'⟩ := by rw [sup_product_left, Finset.sup_comm] #align finset.sup_product_right Finset.sup_product_right @[simp] theorem sup_erase_bot [DecidableEq α] (s : Finset α) : (s.erase ⊥).sup id = s.sup id := by refine' (sup_mono (s.erase_subset _)).antisymm (Finset.sup_le_iff.2 fun a ha => _) obtain rfl | ha' := eq_or_ne a ⊥ · exact bot_le · exact le_sup (mem_erase.2 ⟨ha', ha⟩) #align finset.sup_erase_bot Finset.sup_erase_bot theorem sup_sdiff_right {α β : Type _} [GeneralizedBooleanAlgebra α] (s : Finset β) (f : β → α) (a : α) : (s.sup fun b => f b \ a) = s.sup f \ a := by refine' Finset.cons_induction_on s _ fun b t _ h => _ · rw [sup_empty, sup_empty, bot_sdiff] · rw [sup_cons, sup_cons, h, sup_sdiff] #align finset.sup_sdiff_right Finset.sup_sdiff_right theorem comp_sup_eq_sup_comp [SemilatticeSup γ] [OrderBot γ] {s : Finset β} {f : β → α} (g : α → γ) (g_sup : ∀ x y, g (x ⊔ y) = g x ⊔ g y) (bot : g ⊥ = ⊥) : g (s.sup f) = s.sup (g ∘ f) := Finset.cons_induction_on s bot fun c t hc ih => by rw [sup_cons, sup_cons, g_sup, ih, Function.comp_apply] #align finset.comp_sup_eq_sup_comp Finset.comp_sup_eq_sup_comp /-- Computing `sup` in a subtype (closed under `sup`) is the same as computing it in `α`. -/ theorem sup_coe {P : α → Prop} {Pbot : P ⊥} {Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)} (t : Finset β) (f : β → { x : α // P x }) : (@sup { x // P x } _ (Subtype.semilatticeSup Psup) (Subtype.orderBot Pbot) t f : α) = t.sup fun x => ↑(f x) := by letI := Subtype.semilatticeSup Psup letI := Subtype.orderBot Pbot apply comp_sup_eq_sup_comp Subtype.val <;> intros <;> rfl #align finset.sup_coe Finset.sup_coe @[simp] theorem sup_toFinset {α β} [DecidableEq β] (s : Finset α) (f : α → Multiset β) : (s.sup f).toFinset = s.sup fun x => (f x).toFinset := comp_sup_eq_sup_comp Multiset.toFinset toFinset_union rfl #align finset.sup_to_finset Finset.sup_toFinset theorem _root_.List.foldr_sup_eq_sup_toFinset [DecidableEq α] (l : List α) : l.foldr (· ⊔ ·) ⊥ = l.toFinset.sup id := by rw [← coe_fold_r, ← Multiset.fold_dedup_idem, sup_def, ← List.toFinset_coe, toFinset_val, Multiset.map_id] rfl #align list.foldr_sup_eq_sup_to_finset List.foldr_sup_eq_sup_toFinset theorem subset_range_sup_succ (s : Finset ℕ) : s ⊆ range (s.sup id).succ := fun _ hn => mem_range.2 <| Nat.lt_succ_of_le <| @le_sup _ _ _ _ _ id _ hn #align finset.subset_range_sup_succ Finset.subset_range_sup_succ theorem exists_nat_subset_range (s : Finset ℕ) : ∃ n : ℕ, s ⊆ range n := ⟨_, s.subset_range_sup_succ⟩ #align finset.exists_nat_subset_range Finset.exists_nat_subset_range theorem sup_induction {p : α → Prop} (hb : p ⊥) (hp : ∀ a₁, p a₁ → ∀ a₂, p a₂ → p (a₁ ⊔ a₂)) (hs : ∀ b ∈ s, p (f b)) : p (s.sup f) := by induction' s using Finset.cons_induction with c s hc ih · exact hb · rw [sup_cons] apply hp · exact hs c (mem_cons.2 (Or.inl rfl)) · exact ih fun b h => hs b (mem_cons.2 (Or.inr h)) #align finset.sup_induction Finset.sup_induction theorem sup_le_of_le_directed {α : Type _} [SemilatticeSup α] [OrderBot α] (s : Set α) (hs : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s) (t : Finset α) : (∀ x ∈ t, ∃ y ∈ s, x ≤ y) → ∃ x, x ∈ s ∧ t.sup id ≤ x := by classical induction' t using Finset.induction_on with a r _ ih h · simpa only [forall_prop_of_true, and_true_iff, forall_prop_of_false, bot_le, not_false_iff, sup_empty, forall_true_iff, not_mem_empty] · intro h have incs : (r : Set α) ⊆ ↑(insert a r) := by rw [Finset.coe_subset] apply Finset.subset_insert -- x ∈ s is above the sup of r obtain ⟨x, ⟨hxs, hsx_sup⟩⟩ := ih fun x hx => h x <| incs hx -- y ∈ s is above a obtain ⟨y, hys, hay⟩ := h a (Finset.mem_insert_self a r) -- z ∈ s is above x and y obtain ⟨z, hzs, ⟨hxz, hyz⟩⟩ := hdir x hxs y hys use z, hzs rw [sup_insert, id.def, sup_le_iff] exact ⟨le_trans hay hyz, le_trans hsx_sup hxz⟩ #align finset.sup_le_of_le_directed Finset.sup_le_of_le_directed -- If we acquire sublattices -- the hypotheses should be reformulated as `s : SubsemilatticeSupBot` theorem sup_mem (s : Set α) (w₁ : ⊥ ∈ s) (w₂ : ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), x ⊔ y ∈ s) {ι : Type _} (t : Finset ι) (p : ι → α) (h : ∀ i ∈ t, p i ∈ s) : t.sup p ∈ s := @sup_induction _ _ _ _ _ _ (· ∈ s) w₁ w₂ h #align finset.sup_mem Finset.sup_mem @[simp] theorem sup_eq_bot_iff (f : β → α) (S : Finset β) : S.sup f = ⊥ ↔ ∀ s ∈ S, f s = ⊥ := by classical induction' S using Finset.induction with a S _ hi <;> simp [*] #align finset.sup_eq_bot_iff Finset.sup_eq_bot_iff end Sup theorem sup_eq_supᵢ [CompleteLattice β] (s : Finset α) (f : α → β) : s.sup f = ⨆ a ∈ s, f a := le_antisymm (Finset.sup_le (fun a ha => le_supᵢ_of_le a <| le_supᵢ (fun _ => f a) ha)) (supᵢ_le fun _ => supᵢ_le fun ha => le_sup ha) #align finset.sup_eq_supr Finset.sup_eq_supᵢ theorem sup_id_eq_supₛ [CompleteLattice α] (s : Finset α) : s.sup id = supₛ s := by simp [supₛ_eq_supᵢ, sup_eq_supᵢ] #align finset.sup_id_eq_Sup Finset.sup_id_eq_supₛ theorem sup_id_set_eq_unionₛ (s : Finset (Set α)) : s.sup id = ⋃₀ ↑s := sup_id_eq_supₛ _ #align finset.sup_id_set_eq_sUnion Finset.sup_id_set_eq_unionₛ @[simp] theorem sup_set_eq_bunionᵢ (s : Finset α) (f : α → Set β) : s.sup f = ⋃ x ∈ s, f x := sup_eq_supᵢ _ _ #align finset.sup_set_eq_bUnion Finset.sup_set_eq_bunionᵢ theorem sup_eq_supₛ_image [CompleteLattice β] (s : Finset α) (f : α → β) : s.sup f = supₛ (f '' s) := by classical rw [← Finset.coe_image, ← sup_id_eq_supₛ, sup_image, Function.comp.left_id] #align finset.sup_eq_Sup_image Finset.sup_eq_supₛ_image /-! ### inf -/ section Inf -- TODO: define with just `[Top α]` where some lemmas hold without requiring `[OrderTop α]` variable [SemilatticeInf α] [OrderTop α] /-- Infimum of a finite set: `inf {a, b, c} f = f a ⊓ f b ⊓ f c` -/ def inf (s : Finset β) (f : β → α) : α := s.fold (· ⊓ ·) ⊤ f #align finset.inf Finset.inf variable {s s₁ s₂ : Finset β} {f g : β → α} {a : α} theorem inf_def : s.inf f = (s.1.map f).inf := rfl #align finset.inf_def Finset.inf_def @[simp] theorem inf_empty : (∅ : Finset β).inf f = ⊤ := fold_empty #align finset.inf_empty Finset.inf_empty @[simp] theorem inf_cons {b : β} (h : b ∉ s) : (cons b s h).inf f = f b ⊓ s.inf f := @sup_cons αᵒᵈ _ _ _ _ _ _ h #align finset.inf_cons Finset.inf_cons @[simp] theorem inf_insert [DecidableEq β] {b : β} : (insert b s : Finset β).inf f = f b ⊓ s.inf f := fold_insert_idem #align finset.inf_insert Finset.inf_insert theorem inf_image [DecidableEq β] (s : Finset γ) (f : γ → β) (g : β → α) : (s.image f).inf g = s.inf (g ∘ f) := fold_image_idem #align finset.inf_image Finset.inf_image @[simp] theorem inf_map (s : Finset γ) (f : γ ↪ β) (g : β → α) : (s.map f).inf g = s.inf (g ∘ f) := fold_map #align finset.inf_map Finset.inf_map @[simp] theorem inf_singleton {b : β} : ({b} : Finset β).inf f = f b := Multiset.inf_singleton #align finset.inf_singleton Finset.inf_singleton theorem inf_union [DecidableEq β] : (s₁ ∪ s₂).inf f = s₁.inf f ⊓ s₂.inf f := @sup_union αᵒᵈ _ _ _ _ _ _ _ #align finset.inf_union Finset.inf_union theorem inf_inf : s.inf (f ⊓ g) = s.inf f ⊓ s.inf g := @sup_sup αᵒᵈ _ _ _ _ _ _ #align finset.inf_inf Finset.inf_inf theorem inf_congr {f g : β → α} (hs : s₁ = s₂) (hfg : ∀ a ∈ s₂, f a = g a) : s₁.inf f = s₂.inf g := by subst hs exact Finset.fold_congr hfg #align finset.inf_congr Finset.inf_congr @[simp] theorem inf_bunionᵢ [DecidableEq β] (s : Finset γ) (t : γ → Finset β) : (s.bunionᵢ t).inf f = s.inf fun x => (t x).inf f := @sup_bunionᵢ αᵒᵈ _ _ _ _ _ _ _ _ #align finset.inf_bUnion Finset.inf_bunionᵢ theorem inf_const {s : Finset β} (h : s.Nonempty) (c : α) : (s.inf fun _ => c) = c := @sup_const αᵒᵈ _ _ _ _ h _ #align finset.inf_const Finset.inf_const @[simp] theorem inf_top (s : Finset β) : (s.inf fun _ => ⊤) = (⊤ : α) := @sup_bot αᵒᵈ _ _ _ _ #align finset.inf_top Finset.inf_top protected theorem le_inf_iff {a : α} : a ≤ s.inf f ↔ ∀ b ∈ s, a ≤ f b := @Finset.sup_le_iff αᵒᵈ _ _ _ _ _ _ #align finset.le_inf_iff Finset.le_inf_iff alias Finset.le_inf_iff ↔ _ le_inf #align finset.le_inf Finset.le_inf -- Porting note: removed attribute [protected] le_inf theorem le_inf_const_le : a ≤ s.inf fun _ => a := Finset.le_inf fun _ _ => le_rfl #align finset.le_inf_const_le Finset.le_inf_const_le theorem inf_le {b : β} (hb : b ∈ s) : s.inf f ≤ f b := Finset.le_inf_iff.1 le_rfl _ hb #align finset.inf_le Finset.inf_le theorem inf_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ≤ g b) : s.inf f ≤ s.inf g := Finset.le_inf fun b hb => le_trans (inf_le hb) (h b hb) #align finset.inf_mono_fun Finset.inf_mono_fun theorem inf_mono (h : s₁ ⊆ s₂) : s₂.inf f ≤ s₁.inf f := Finset.le_inf (fun _ hb => inf_le (h hb)) #align finset.inf_mono Finset.inf_mono theorem inf_attach (s : Finset β) (f : β → α) : (s.attach.inf fun x => f x) = s.inf f := @sup_attach αᵒᵈ _ _ _ _ _ #align finset.inf_attach Finset.inf_attach protected theorem inf_comm (s : Finset β) (t : Finset γ) (f : β → γ → α) : (s.inf fun b => t.inf (f b)) = t.inf fun c => s.inf fun b => f b c := @Finset.sup_comm αᵒᵈ _ _ _ _ _ _ _ #align finset.inf_comm Finset.inf_comm theorem inf_product_left (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ᶠ t).inf f = s.inf fun i => t.inf fun i' => f ⟨i, i'⟩ := @sup_product_left αᵒᵈ _ _ _ _ _ _ _ #align finset.inf_product_left Finset.inf_product_left theorem inf_product_right (s : Finset β) (t : Finset γ) (f : β × γ → α) : (s ×ᶠ t).inf f = t.inf fun i' => s.inf fun i => f ⟨i, i'⟩ := @sup_product_right αᵒᵈ _ _ _ _ _ _ _ #align finset.inf_product_right Finset.inf_product_right @[simp] theorem inf_erase_top [DecidableEq α] (s : Finset α) : (s.erase ⊤).inf id = s.inf id := @sup_erase_bot αᵒᵈ _ _ _ _ #align finset.inf_erase_top Finset.inf_erase_top theorem sup_sdiff_left {α β : Type _} [BooleanAlgebra α] (s : Finset β) (f : β → α) (a : α) : (s.sup fun b => a \ f b) = a \ s.inf f := by refine' Finset.cons_induction_on s _ fun b t _ h => _ · rw [sup_empty, inf_empty, sdiff_top] · rw [sup_cons, inf_cons, h, sdiff_inf] #align finset.sup_sdiff_left Finset.sup_sdiff_left theorem inf_sdiff_left {α β : Type _} [BooleanAlgebra α] {s : Finset β} (hs : s.Nonempty) (f : β → α) (a : α) : (s.inf fun b => a \ f b) = a \ s.sup f := by induction' hs using Finset.Nonempty.cons_induction with b b t _ _ h · rw [sup_singleton, inf_singleton] · rw [sup_cons, inf_cons, h, sdiff_sup] #align finset.inf_sdiff_left Finset.inf_sdiff_left theorem inf_sdiff_right {α β : Type _} [BooleanAlgebra α] {s : Finset β} (hs : s.Nonempty) (f : β → α) (a : α) : (s.inf fun b => f b \ a) = s.inf f \ a := by induction' hs using Finset.Nonempty.cons_induction with b b t _ _ h · rw [inf_singleton, inf_singleton] · rw [inf_cons, inf_cons, h, inf_sdiff] #align finset.inf_sdiff_right Finset.inf_sdiff_right theorem comp_inf_eq_inf_comp [SemilatticeInf γ] [OrderTop γ] {s : Finset β} {f : β → α} (g : α → γ) (g_inf : ∀ x y, g (x ⊓ y) = g x ⊓ g y) (top : g ⊤ = ⊤) : g (s.inf f) = s.inf (g ∘ f) := @comp_sup_eq_sup_comp αᵒᵈ _ γᵒᵈ _ _ _ _ _ _ _ g_inf top #align finset.comp_inf_eq_inf_comp Finset.comp_inf_eq_inf_comp /-- Computing `inf` in a subtype (closed under `inf`) is the same as computing it in `α`. -/ theorem inf_coe {P : α → Prop} {Ptop : P ⊤} {Pinf : ∀ ⦃x y⦄, P x → P y → P (x ⊓ y)} (t : Finset β) (f : β → { x : α // P x }) : (@inf { x // P x } _ (Subtype.semilatticeInf Pinf) (Subtype.orderTop Ptop) t f : α) = t.inf fun x => ↑(f x) := @sup_coe αᵒᵈ _ _ _ _ Ptop Pinf t f #align finset.inf_coe Finset.inf_coe theorem _root_.List.foldr_inf_eq_inf_toFinset [DecidableEq α] (l : List α) : l.foldr (· ⊓ ·) ⊤ = l.toFinset.inf id := by rw [← coe_fold_r, ← Multiset.fold_dedup_idem, inf_def, ← List.toFinset_coe, toFinset_val, Multiset.map_id] rfl #align list.foldr_inf_eq_inf_to_finset List.foldr_inf_eq_inf_toFinset theorem inf_induction {p : α → Prop} (ht : p ⊤) (hp : ∀ a₁, p a₁ → ∀ a₂, p a₂ → p (a₁ ⊓ a₂)) (hs : ∀ b ∈ s, p (f b)) : p (s.inf f) := @sup_induction αᵒᵈ _ _ _ _ _ _ ht hp hs #align finset.inf_induction Finset.inf_induction theorem inf_mem (s : Set α) (w₁ : ⊤ ∈ s) (w₂ : ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), x ⊓ y ∈ s) {ι : Type _} (t : Finset ι) (p : ι → α) (h : ∀ i ∈ t, p i ∈ s) : t.inf p ∈ s := @inf_induction _ _ _ _ _ _ (· ∈ s) w₁ w₂ h #align finset.inf_mem Finset.inf_mem @[simp] theorem inf_eq_top_iff (f : β → α) (S : Finset β) : S.inf f = ⊤ ↔ ∀ s ∈ S, f s = ⊤ := @Finset.sup_eq_bot_iff αᵒᵈ _ _ _ _ _ #align finset.inf_eq_top_iff Finset.inf_eq_top_iff end Inf @[simp] theorem toDual_sup [SemilatticeSup α] [OrderBot α] (s : Finset β) (f : β → α) : toDual (s.sup f) = s.inf (toDual ∘ f) := rfl #align finset.to_dual_sup Finset.toDual_sup @[simp] theorem toDual_inf [SemilatticeInf α] [OrderTop α] (s : Finset β) (f : β → α) : toDual (s.inf f) = s.sup (toDual ∘ f) := rfl #align finset.to_dual_inf Finset.toDual_inf @[simp] theorem ofDual_sup [SemilatticeInf α] [OrderTop α] (s : Finset β) (f : β → αᵒᵈ) : ofDual (s.sup f) = s.inf (ofDual ∘ f) := rfl #align finset.of_dual_sup Finset.ofDual_sup @[simp] theorem ofDual_inf [SemilatticeSup α] [OrderBot α] (s : Finset β) (f : β → αᵒᵈ) : ofDual (s.inf f) = s.sup (ofDual ∘ f) := rfl #align finset.of_dual_inf Finset.ofDual_inf section DistribLattice variable [DistribLattice α] section OrderBot variable [OrderBot α] {s : Finset β} {f : β → α} {a : α} theorem sup_inf_distrib_left (s : Finset ι) (f : ι → α) (a : α) : a ⊓ s.sup f = s.sup fun i => a ⊓ f i := by induction' s using Finset.cons_induction with i s hi h · simp_rw [Finset.sup_empty, inf_bot_eq] · rw [sup_cons, sup_cons, inf_sup_left, h] #align finset.sup_inf_distrib_left Finset.sup_inf_distrib_left theorem sup_inf_distrib_right (s : Finset ι) (f : ι → α) (a : α) : s.sup f ⊓ a = s.sup fun i => f i ⊓ a := by rw [_root_.inf_comm, s.sup_inf_distrib_left] simp_rw [_root_.inf_comm] #align finset.sup_inf_distrib_right Finset.sup_inf_distrib_right protected theorem disjoint_sup_right : Disjoint a (s.sup f) ↔ ∀ i ∈ s, Disjoint a (f i) := by simp only [disjoint_iff, sup_inf_distrib_left, sup_eq_bot_iff] #align finset.disjoint_sup_right Finset.disjoint_sup_right protected theorem disjoint_sup_left : Disjoint (s.sup f) a ↔ ∀ i ∈ s, Disjoint (f i) a := by simp only [disjoint_iff, sup_inf_distrib_right, sup_eq_bot_iff] #align finset.disjoint_sup_left Finset.disjoint_sup_left end OrderBot section OrderTop variable [OrderTop α] theorem inf_sup_distrib_left (s : Finset ι) (f : ι → α) (a : α) : a ⊔ s.inf f = s.inf fun i => a ⊔ f i := @sup_inf_distrib_left αᵒᵈ _ _ _ _ _ _ #align finset.inf_sup_distrib_left Finset.inf_sup_distrib_left theorem inf_sup_distrib_right (s : Finset ι) (f : ι → α) (a : α) : s.inf f ⊔ a = s.inf fun i => f i ⊔ a := @sup_inf_distrib_right αᵒᵈ _ _ _ _ _ _ #align finset.inf_sup_distrib_right Finset.inf_sup_distrib_right end OrderTop end DistribLattice section LinearOrder variable [LinearOrder α] section OrderBot variable [OrderBot α] {s : Finset ι} {f : ι → α} {a : α} theorem comp_sup_eq_sup_comp_of_is_total [SemilatticeSup β] [OrderBot β] (g : α → β) (mono_g : Monotone g) (bot : g ⊥ = ⊥) : g (s.sup f) = s.sup (g ∘ f) := comp_sup_eq_sup_comp g mono_g.map_sup bot #align finset.comp_sup_eq_sup_comp_of_is_total Finset.comp_sup_eq_sup_comp_of_is_total @[simp] protected theorem le_sup_iff (ha : ⊥ < a) : a ≤ s.sup f ↔ ∃ b ∈ s, a ≤ f b := by apply Iff.intro · induction s using cons_induction with | empty => exact (absurd · (not_le_of_lt ha)) | @cons c t hc ih => rw [sup_cons, le_sup_iff] exact fun | Or.inl h => ⟨c, mem_cons.2 (Or.inl rfl), h⟩ | Or.inr h => let ⟨b, hb, hle⟩ := ih h; ⟨b, mem_cons.2 (Or.inr hb), hle⟩ · exact fun ⟨b, hb, hle⟩ => le_trans hle (le_sup hb) #align finset.le_sup_iff Finset.le_sup_iff @[simp] protected theorem lt_sup_iff : a < s.sup f ↔ ∃ b ∈ s, a < f b := by apply Iff.intro · induction s using cons_induction with | empty => exact (absurd · not_lt_bot) | @cons c t hc ih => rw [sup_cons, lt_sup_iff] exact fun | Or.inl h => ⟨c, mem_cons.2 (Or.inl rfl), h⟩ | Or.inr h => let ⟨b, hb, hlt⟩ := ih h; ⟨b, mem_cons.2 (Or.inr hb), hlt⟩ · exact fun ⟨b, hb, hlt⟩ => lt_of_lt_of_le hlt (le_sup hb) #align finset.lt_sup_iff Finset.lt_sup_iff @[simp] protected theorem sup_lt_iff (ha : ⊥ < a) : s.sup f < a ↔ ∀ b ∈ s, f b < a := ⟨fun hs b hb => lt_of_le_of_lt (le_sup hb) hs, Finset.cons_induction_on s (fun _ => ha) fun c t hc => by simpa only [sup_cons, sup_lt_iff, mem_cons, forall_eq_or_imp] using And.imp_right⟩ #align finset.sup_lt_iff Finset.sup_lt_iff end OrderBot section OrderTop variable [OrderTop α] {s : Finset ι} {f : ι → α} {a : α} theorem comp_inf_eq_inf_comp_of_is_total [SemilatticeInf β] [OrderTop β] (g : α → β) (mono_g : Monotone g) (top : g ⊤ = ⊤) : g (s.inf f) = s.inf (g ∘ f) := comp_inf_eq_inf_comp g mono_g.map_inf top #align finset.comp_inf_eq_inf_comp_of_is_total Finset.comp_inf_eq_inf_comp_of_is_total @[simp] protected theorem inf_le_iff (ha : a < ⊤) : s.inf f ≤ a ↔ ∃ b ∈ s, f b ≤ a := @Finset.le_sup_iff αᵒᵈ _ _ _ _ _ _ ha #align finset.inf_le_iff Finset.inf_le_iff @[simp] protected theorem inf_lt_iff : s.inf f < a ↔ ∃ b ∈ s, f b < a := @Finset.lt_sup_iff αᵒᵈ _ _ _ _ _ _ #align finset.inf_lt_iff Finset.inf_lt_iff @[simp] protected theorem lt_inf_iff (ha : a < ⊤) : a < s.inf f ↔ ∀ b ∈ s, a < f b := @Finset.sup_lt_iff αᵒᵈ _ _ _ _ _ _ ha #align finset.lt_inf_iff Finset.lt_inf_iff end OrderTop end LinearOrder theorem inf_eq_infᵢ [CompleteLattice β] (s : Finset α) (f : α → β) : s.inf f = ⨅ a ∈ s, f a := @sup_eq_supᵢ _ βᵒᵈ _ _ _ #align finset.inf_eq_infi Finset.inf_eq_infᵢ theorem inf_id_eq_infₛ [CompleteLattice α] (s : Finset α) : s.inf id = infₛ s := @sup_id_eq_supₛ αᵒᵈ _ _ #align finset.inf_id_eq_Inf Finset.inf_id_eq_infₛ theorem inf_id_set_eq_interₛ (s : Finset (Set α)) : s.inf id = ⋂₀ ↑s := inf_id_eq_infₛ _ #align finset.inf_id_set_eq_sInter Finset.inf_id_set_eq_interₛ @[simp] theorem inf_set_eq_interᵢ (s : Finset α) (f : α → Set β) : s.inf f = ⋂ x ∈ s, f x := inf_eq_infᵢ _ _ #align finset.inf_set_eq_bInter Finset.inf_set_eq_interᵢ theorem inf_eq_infₛ_image [CompleteLattice β] (s : Finset α) (f : α → β) : s.inf f = infₛ (f '' s) := @sup_eq_supₛ_image _ βᵒᵈ _ _ _ #align finset.inf_eq_Inf_image Finset.inf_eq_infₛ_image section Sup' variable [SemilatticeSup α] theorem sup_of_mem {s : Finset β} (f : β → α) {b : β} (h : b ∈ s) : ∃ a : α, s.sup ((↑) ∘ f : β → WithBot α) = ↑a := Exists.imp (fun _ => And.left) (@le_sup (WithBot α) _ _ _ _ _ _ h (f b) rfl) #align finset.sup_of_mem Finset.sup_of_mem /-- Given nonempty finset `s` then `s.sup' H f` is the supremum of its image under `f` in (possibly unbounded) join-semilattice `α`, where `H` is a proof of nonemptiness. If `α` has a bottom element you may instead use `Finset.sup` which does not require `s` nonempty. -/ def sup' (s : Finset β) (H : s.Nonempty) (f : β → α) : α := WithBot.unbot (s.sup ((↑) ∘ f)) (by simpa using H) #align finset.sup' Finset.sup' variable {s : Finset β} (H : s.Nonempty) (f : β → α) @[simp] theorem coe_sup' : ((s.sup' H f : α) : WithBot α) = s.sup ((↑) ∘ f) := by rw [sup', WithBot.coe_unbot] #align finset.coe_sup' Finset.coe_sup' @[simp] theorem sup'_cons {b : β} {hb : b ∉ s} {h : (cons b s hb).Nonempty} : (cons b s hb).sup' h f = f b ⊔ s.sup' H f := by rw [← WithBot.coe_eq_coe] simp [WithBot.coe_sup] #align finset.sup'_cons Finset.sup'_cons @[simp] theorem sup'_insert [DecidableEq β] {b : β} {h : (insert b s).Nonempty} : (insert b s).sup' h f = f b ⊔ s.sup' H f := by rw [← WithBot.coe_eq_coe] simp [WithBot.coe_sup] #align finset.sup'_insert Finset.sup'_insert @[simp] theorem sup'_singleton {b : β} {h : ({b} : Finset β).Nonempty} : ({b} : Finset β).sup' h f = f b := rfl #align finset.sup'_singleton Finset.sup'_singleton theorem sup'_le {a : α} (hs : ∀ b ∈ s, f b ≤ a) : s.sup' H f ≤ a := by rw [← WithBot.coe_le_coe, coe_sup'] exact Finset.sup_le fun b h => WithBot.coe_le_coe.2 <| hs b h #align finset.sup'_le Finset.sup'_le theorem le_sup' {b : β} (h : b ∈ s) : f b ≤ s.sup' ⟨b, h⟩ f := by rw [← WithBot.coe_le_coe, coe_sup'] exact le_sup (f := fun c => WithBot.some (f c)) h #align finset.le_sup' Finset.le_sup' @[simp] theorem sup'_const (a : α) : s.sup' H (fun _ => a) = a := by apply le_antisymm · apply sup'_le intros exact le_rfl · apply le_sup' (fun _ => a) H.choose_spec #align finset.sup'_const Finset.sup'_const @[simp] theorem sup'_le_iff {a : α} : s.sup' H f ≤ a ↔ ∀ b ∈ s, f b ≤ a := Iff.intro (fun h _ hb => le_trans (le_sup' f hb) h) (sup'_le H f) #align finset.sup'_le_iff Finset.sup'_le_iff theorem sup'_bunionᵢ [DecidableEq β] {s : Finset γ} (Hs : s.Nonempty) {t : γ → Finset β} (Ht : ∀ b, (t b).Nonempty) : (s.bunionᵢ t).sup' (Hs.bunionᵢ fun b _ => Ht b) f = s.sup' Hs (fun b => (t b).sup' (Ht b) f) := eq_of_forall_ge_iff fun c => by simp [@forall_swap _ β] #align finset.sup'_bUnion Finset.sup'_bunionᵢ theorem comp_sup'_eq_sup'_comp [SemilatticeSup γ] {s : Finset β} (H : s.Nonempty) {f : β → α} (g : α → γ) (g_sup : ∀ x y, g (x ⊔ y) = g x ⊔ g y) : g (s.sup' H f) = s.sup' H (g ∘ f) := by rw [← WithBot.coe_eq_coe, coe_sup'] let g' := WithBot.map g show g' ↑(s.sup' H f) = s.sup fun a => g' ↑(f a) rw [coe_sup'] refine' comp_sup_eq_sup_comp g' _ rfl intro f₁ f₂ cases f₁ using WithBot.recBotCoe with | bot => rw [bot_sup_eq] exact bot_sup_eq.symm | coe f₁ => cases f₂ using WithBot.recBotCoe with | bot => rfl | coe f₂ => exact congr_arg _ (g_sup f₁ f₂) #align finset.comp_sup'_eq_sup'_comp Finset.comp_sup'_eq_sup'_comp theorem sup'_induction {p : α → Prop} (hp : ∀ a₁, p a₁ → ∀ a₂, p a₂ → p (a₁ ⊔ a₂)) (hs : ∀ b ∈ s, p (f b)) : p (s.sup' H f) := by show @WithBot.recBotCoe α (fun _ => Prop) True p ↑(s.sup' H f) rw [coe_sup'] refine' sup_induction trivial _ hs rintro (_ | a₁) h₁ a₂ h₂ · rw [WithBot.none_eq_bot, bot_sup_eq] exact h₂ · cases a₂ using WithBot.recBotCoe with | bot => exact h₁ | coe a₂ => exact hp a₁ h₁ a₂ h₂ #align finset.sup'_induction Finset.sup'_induction theorem sup'_mem (s : Set α) (w : ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), x ⊔ y ∈ s) {ι : Type _} (t : Finset ι) (H : t.Nonempty) (p : ι → α) (h : ∀ i ∈ t, p i ∈ s) : t.sup' H p ∈ s := sup'_induction H p w h #align finset.sup'_mem Finset.sup'_mem @[congr] theorem sup'_congr {t : Finset β} {f g : β → α} (h₁ : s = t) (h₂ : ∀ x ∈ s, f x = g x) : s.sup' H f = t.sup' (h₁ ▸ H) g := by subst s refine' eq_of_forall_ge_iff fun c => _ simp (config := { contextual := true }) only [sup'_le_iff, h₂] #align finset.sup'_congr Finset.sup'_congr @[simp] theorem sup'_map {s : Finset γ} {f : γ ↪ β} (g : β → α) (hs : (s.map f).Nonempty) (hs' : s.Nonempty := Finset.map_nonempty.mp hs) : (s.map f).sup' hs g = s.sup' hs' (g ∘ f) := by rw [← WithBot.coe_eq_coe, coe_sup', sup_map, coe_sup'] rfl #align finset.sup'_map Finset.sup'_map end Sup' section Inf' variable [SemilatticeInf α] theorem inf_of_mem {s : Finset β} (f : β → α) {b : β} (h : b ∈ s) : ∃ a : α, s.inf ((↑) ∘ f : β → WithTop α) = ↑a := @sup_of_mem αᵒᵈ _ _ _ f _ h #align finset.inf_of_mem Finset.inf_of_mem /-- Given nonempty finset `s` then `s.inf' H f` is the infimum of its image under `f` in (possibly unbounded) meet-semilattice `α`, where `H` is a proof of nonemptiness. If `α` has a top element you may instead use `Finset.inf` which does not require `s` nonempty. -/ def inf' (s : Finset β) (H : s.Nonempty) (f : β → α) : α := WithTop.untop (s.inf ((↑) ∘ f)) (by simpa using H) #align finset.inf' Finset.inf' variable {s : Finset β} (H : s.Nonempty) (f : β → α) @[simp] theorem coe_inf' : ((s.inf' H f : α) : WithTop α) = s.inf ((↑) ∘ f) := @coe_sup' αᵒᵈ _ _ _ H f #align finset.coe_inf' Finset.coe_inf' @[simp] theorem inf'_cons {b : β} {hb : b ∉ s} {h : (cons b s hb).Nonempty} : (cons b s hb).inf' h f = f b ⊓ s.inf' H f := @sup'_cons αᵒᵈ _ _ _ H f _ _ h #align finset.inf'_cons Finset.inf'_cons @[simp] theorem inf'_insert [DecidableEq β] {b : β} {h : (insert b s).Nonempty} : (insert b s).inf' h f = f b ⊓ s.inf' H f := @sup'_insert αᵒᵈ _ _ _ H f _ _ h #align finset.inf'_insert Finset.inf'_insert @[simp] theorem inf'_singleton {b : β} {h : ({b} : Finset β).Nonempty} : ({b} : Finset β).inf' h f = f b := rfl #align finset.inf'_singleton Finset.inf'_singleton theorem le_inf' {a : α} (hs : ∀ b ∈ s, a ≤ f b) : a ≤ s.inf' H f := sup'_le (α := αᵒᵈ) H f hs #align finset.le_inf' Finset.le_inf' theorem inf'_le {b : β} (h : b ∈ s) : s.inf' ⟨b, h⟩ f ≤ f b := le_sup' (α := αᵒᵈ) f h #align finset.inf'_le Finset.inf'_le @[simp] theorem inf'_const (a : α) : (s.inf' H fun _ => a) = a := sup'_const (α := αᵒᵈ) H a #align finset.inf'_const Finset.inf'_const @[simp] theorem le_inf'_iff {a : α} : a ≤ s.inf' H f ↔ ∀ b ∈ s, a ≤ f b := sup'_le_iff (α := αᵒᵈ) H f #align finset.le_inf'_iff Finset.le_inf'_iff theorem inf'_bunionᵢ [DecidableEq β] {s : Finset γ} (Hs : s.Nonempty) {t : γ → Finset β} (Ht : ∀ b, (t b).Nonempty) : (s.bunionᵢ t).inf' (Hs.bunionᵢ fun b _ => Ht b) f = s.inf' Hs (fun b => (t b).inf' (Ht b) f) := sup'_bunionᵢ (α := αᵒᵈ) _ Hs Ht #align finset.inf'_bUnion Finset.inf'_bunionᵢ theorem comp_inf'_eq_inf'_comp [SemilatticeInf γ] {s : Finset β} (H : s.Nonempty) {f : β → α} (g : α → γ) (g_inf : ∀ x y, g (x ⊓ y) = g x ⊓ g y) : g (s.inf' H f) = s.inf' H (g ∘ f) := comp_sup'_eq_sup'_comp (α := αᵒᵈ) (γ := γᵒᵈ) H g g_inf #align finset.comp_inf'_eq_inf'_comp Finset.comp_inf'_eq_inf'_comp theorem inf'_induction {p : α → Prop} (hp : ∀ a₁, p a₁ → ∀ a₂, p a₂ → p (a₁ ⊓ a₂)) (hs : ∀ b ∈ s, p (f b)) : p (s.inf' H f) := sup'_induction (α := αᵒᵈ) H f hp hs #align finset.inf'_induction Finset.inf'_induction theorem inf'_mem (s : Set α) (w : ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), x ⊓ y ∈ s) {ι : Type _} (t : Finset ι) (H : t.Nonempty) (p : ι → α) (h : ∀ i ∈ t, p i ∈ s) : t.inf' H p ∈ s := inf'_induction H p w h #align finset.inf'_mem Finset.inf'_mem @[congr] theorem inf'_congr {t : Finset β} {f g : β → α} (h₁ : s = t) (h₂ : ∀ x ∈ s, f x = g x) : s.inf' H f = t.inf' (h₁ ▸ H) g := sup'_congr (α := αᵒᵈ) H h₁ h₂ #align finset.inf'_congr Finset.inf'_congr @[simp] theorem inf'_map {s : Finset γ} {f : γ ↪ β} (g : β → α) (hs : (s.map f).Nonempty) (hs' : s.Nonempty := Finset.map_nonempty.mp hs) : (s.map f).inf' hs g = s.inf' hs' (g ∘ f) := sup'_map (α := αᵒᵈ) _ hs hs' #align finset.inf'_map Finset.inf'_map end Inf' section Sup variable [SemilatticeSup α] [OrderBot α] theorem sup'_eq_sup {s : Finset β} (H : s.Nonempty) (f : β → α) : s.sup' H f = s.sup f := le_antisymm (sup'_le H f fun _ => le_sup) (Finset.sup_le fun _ => le_sup' f) #align finset.sup'_eq_sup Finset.sup'_eq_sup theorem sup_closed_of_sup_closed {s : Set α} (t : Finset α) (htne : t.Nonempty) (h_subset : ↑t ⊆ s) (h : ∀ (a) (_ : a ∈ s) (b) (_ : b ∈ s), a ⊔ b ∈ s) : t.sup id ∈ s := sup'_eq_sup htne id ▸ sup'_induction _ _ h h_subset #align finset.sup_closed_of_sup_closed Finset.sup_closed_of_sup_closed theorem coe_sup_of_nonempty {s : Finset β} (h : s.Nonempty) (f : β → α) : (↑(s.sup f) : WithBot α) = s.sup ((↑) ∘ f) := by simp only [← sup'_eq_sup h, coe_sup' h] #align finset.coe_sup_of_nonempty Finset.coe_sup_of_nonempty end Sup section Inf variable [SemilatticeInf α] [OrderTop α] theorem inf'_eq_inf {s : Finset β} (H : s.Nonempty) (f : β → α) : s.inf' H f = s.inf f := sup'_eq_sup (α := αᵒᵈ) H f #align finset.inf'_eq_inf Finset.inf'_eq_inf theorem inf_closed_of_inf_closed {s : Set α} (t : Finset α) (htne : t.Nonempty) (h_subset : ↑t ⊆ s) (h : ∀ (a) (_ : a ∈ s) (b) (_ : b ∈ s), a ⊓ b ∈ s) : t.inf id ∈ s := sup_closed_of_sup_closed (α := αᵒᵈ) t htne h_subset h #align finset.inf_closed_of_inf_closed Finset.inf_closed_of_inf_closed theorem coe_inf_of_nonempty {s : Finset β} (h : s.Nonempty) (f : β → α) : (↑(s.inf f) : WithTop α) = s.inf ((↑) ∘ f) := coe_sup_of_nonempty (α := αᵒᵈ) h f #align finset.coe_inf_of_nonempty Finset.coe_inf_of_nonempty end Inf @[simp] protected theorem sup_apply {C : β → Type _} [∀ b : β, SemilatticeSup (C b)] [∀ b : β, OrderBot (C b)] (s : Finset α) (f : α → ∀ b : β, C b) (b : β) : s.sup f b = s.sup fun a => f a b := comp_sup_eq_sup_comp (fun x : ∀ b : β, C b => x b) (fun _ _ => rfl) rfl #align finset.sup_apply Finset.sup_apply @[simp] protected theorem inf_apply {C : β → Type _} [∀ b : β, SemilatticeInf (C b)] [∀ b : β, OrderTop (C b)] (s : Finset α) (f : α → ∀ b : β, C b) (b : β) : s.inf f b = s.inf fun a => f a b := Finset.sup_apply (C := fun b => (C b)ᵒᵈ) s f b #align finset.inf_apply Finset.inf_apply @[simp] protected theorem sup'_apply {C : β → Type _} [∀ b : β, SemilatticeSup (C b)] {s : Finset α} (H : s.Nonempty) (f : α → ∀ b : β, C b) (b : β) : s.sup' H f b = s.sup' H fun a => f a b := comp_sup'_eq_sup'_comp H (fun x : ∀ b : β, C b => x b) fun _ _ => rfl #align finset.sup'_apply Finset.sup'_apply @[simp] protected theorem inf'_apply {C : β → Type _} [∀ b : β, SemilatticeInf (C b)] {s : Finset α} (H : s.Nonempty) (f : α → ∀ b : β, C b) (b : β) : s.inf' H f b = s.inf' H fun a => f a b := Finset.sup'_apply (C := fun b => (C b)ᵒᵈ) H f b #align finset.inf'_apply Finset.inf'_apply @[simp] theorem toDual_sup' [SemilatticeSup α] {s : Finset ι} (hs : s.Nonempty) (f : ι → α) : toDual (s.sup' hs f) = s.inf' hs (toDual ∘ f) := rfl #align finset.to_dual_sup' Finset.toDual_sup' @[simp] theorem toDual_inf' [SemilatticeInf α] {s : Finset ι} (hs : s.Nonempty) (f : ι → α) : toDual (s.inf' hs f) = s.sup' hs (toDual ∘ f) := rfl #align finset.to_dual_inf' Finset.toDual_inf' @[simp] theorem ofDual_sup' [SemilatticeInf α] {s : Finset ι} (hs : s.Nonempty) (f : ι → αᵒᵈ) : ofDual (s.sup' hs f) = s.inf' hs (ofDual ∘ f) := rfl #align finset.of_dual_sup' Finset.ofDual_sup' @[simp] theorem ofDual_inf' [SemilatticeSup α] {s : Finset ι} (hs : s.Nonempty) (f : ι → αᵒᵈ) : ofDual (s.inf' hs f) = s.sup' hs (ofDual ∘ f) := rfl #align finset.of_dual_inf' Finset.ofDual_inf' section LinearOrder variable [LinearOrder α] {s : Finset ι} (H : s.Nonempty) {f : ι → α} {a : α} @[simp] theorem le_sup'_iff : a ≤ s.sup' H f ↔ ∃ b ∈ s, a ≤ f b := by rw [← WithBot.coe_le_coe, coe_sup', Finset.le_sup_iff (WithBot.bot_lt_coe a)] exact exists_congr (fun _ => and_congr_right' WithBot.coe_le_coe) #align finset.le_sup'_iff Finset.le_sup'_iff @[simp] theorem lt_sup'_iff : a < s.sup' H f ↔ ∃ b ∈ s, a < f b := by rw [← WithBot.coe_lt_coe, coe_sup', Finset.lt_sup_iff] exact exists_congr (fun _ => and_congr_right' WithBot.coe_lt_coe) #align finset.lt_sup'_iff Finset.lt_sup'_iff @[simp] theorem sup'_lt_iff : s.sup' H f < a ↔ ∀ i ∈ s, f i < a := by rw [← WithBot.coe_lt_coe, coe_sup', Finset.sup_lt_iff (WithBot.bot_lt_coe a)] exact ball_congr (fun _ _ => WithBot.coe_lt_coe) #align finset.sup'_lt_iff Finset.sup'_lt_iff @[simp] theorem inf'_le_iff : s.inf' H f ≤ a ↔ ∃ i ∈ s, f i ≤ a := le_sup'_iff (α := αᵒᵈ) H #align finset.inf'_le_iff Finset.inf'_le_iff @[simp] theorem inf'_lt_iff : s.inf' H f < a ↔ ∃ i ∈ s, f i < a := lt_sup'_iff (α := αᵒᵈ) H #align finset.inf'_lt_iff Finset.inf'_lt_iff @[simp] theorem lt_inf'_iff : a < s.inf' H f ↔ ∀ i ∈ s, a < f i := sup'_lt_iff (α := αᵒᵈ) H #align finset.lt_inf'_iff Finset.lt_inf'_iff theorem exists_mem_eq_sup' (f : ι → α) : ∃ i, i ∈ s ∧ s.sup' H f = f i := by refine' H.cons_induction (fun c => _) fun c s hc hs ih => _ · exact ⟨c, mem_singleton_self c, rfl⟩ · rcases ih with ⟨b, hb, h'⟩ rw [sup'_cons hs, h'] cases le_total (f b) (f c) with | inl h => exact ⟨c, mem_cons.2 (Or.inl rfl), sup_eq_left.2 h⟩ | inr h => exact ⟨b, mem_cons.2 (Or.inr hb), sup_eq_right.2 h⟩ #align finset.exists_mem_eq_sup' Finset.exists_mem_eq_sup' theorem exists_mem_eq_inf' (f : ι → α) : ∃ i, i ∈ s ∧ s.inf' H f = f i := exists_mem_eq_sup' (α := αᵒᵈ) H f #align finset.exists_mem_eq_inf' Finset.exists_mem_eq_inf' theorem exists_mem_eq_sup [OrderBot α] (s : Finset ι) (h : s.Nonempty) (f : ι → α) : ∃ i, i ∈ s ∧ s.sup f = f i := sup'_eq_sup h f ▸ exists_mem_eq_sup' h f #align finset.exists_mem_eq_sup Finset.exists_mem_eq_sup theorem exists_mem_eq_inf [OrderTop α] (s : Finset ι) (h : s.Nonempty) (f : ι → α) : ∃ i, i ∈ s ∧ s.inf f = f i := exists_mem_eq_sup (α := αᵒᵈ) s h f #align finset.exists_mem_eq_inf Finset.exists_mem_eq_inf end LinearOrder /-! ### max and min of finite sets -/ section MaxMin variable [LinearOrder α] /-- Let `s` be a finset in a linear order. Then `s.max` is the maximum of `s` if `s` is not empty, and `⊥` otherwise. It belongs to `WithBot α`. If you want to get an element of `α`, see `s.max'`. -/ protected def max (s : Finset α) : WithBot α := sup s (↑) #align finset.max Finset.max theorem max_eq_sup_coe {s : Finset α} : s.max = s.sup (↑) := rfl #align finset.max_eq_sup_coe Finset.max_eq_sup_coe theorem max_eq_sup_withBot (s : Finset α) : s.max = sup s (↑) := rfl #align finset.max_eq_sup_with_bot Finset.max_eq_sup_withBot @[simp] theorem max_empty : (∅ : Finset α).max = ⊥ := rfl #align finset.max_empty Finset.max_empty @[simp] theorem max_insert {a : α} {s : Finset α} : (insert a s).max = max ↑a s.max := fold_insert_idem #align finset.max_insert Finset.max_insert @[simp] theorem max_singleton {a : α} : Finset.max {a} = (a : WithBot α) := by rw [← insert_emptyc_eq] exact max_insert #align finset.max_singleton Finset.max_singleton theorem max_of_mem {s : Finset α} {a : α} (h : a ∈ s) : ∃ b : α, s.max = b := by obtain ⟨b, h, _⟩ := le_sup (α := WithBot α) h _ rfl exact ⟨b, h⟩ #align finset.max_of_mem Finset.max_of_mem theorem max_eq_bot {s : Finset α} : s.max = ⊥ ↔ s = ∅ := ⟨fun h ↦ s.eq_empty_or_nonempty.elim id fun H ↦ by obtain ⟨a, ha⟩ := max_of_nonempty H rw [h] at ha; cases ha; done, -- Porting note: error without `done` fun h ↦ h.symm ▸ max_empty⟩ #align finset.max_eq_bot Finset.max_eq_bot theorem mem_of_max {s : Finset α} : ∀ {a : α}, s.max = a → a ∈ s := by induction' s using Finset.induction_on with b s _ ih · intro _ H; cases H · intro a h by_cases p : b = a · induction p exact mem_insert_self b s · cases' max_choice (↑b) s.max with q q <;> rw [max_insert, q] at h · cases h cases p rfl · exact mem_insert_of_mem (ih h) #align finset.mem_of_max Finset.mem_of_max theorem le_max {a : α} {s : Finset α} (as : a ∈ s) : ↑a ≤ s.max := le_sup as #align finset.le_max Finset.le_max theorem not_mem_of_max_lt_coe {a : α} {s : Finset α} (h : s.max < a) : a ∉ s := mt le_max h.not_le #align finset.not_mem_of_max_lt_coe Finset.not_mem_of_max_lt_coe theorem le_max_of_eq {s : Finset α} {a b : α} (h₁ : a ∈ s) (h₂ : s.max = b) : a ≤ b := WithBot.coe_le_coe.mp <| (le_max h₁).trans h₂.le #align finset.le_max_of_eq Finset.le_max_of_eq theorem not_mem_of_max_lt {s : Finset α} {a b : α} (h₁ : b < a) (h₂ : s.max = ↑b) : a ∉ s := Finset.not_mem_of_max_lt_coe <| h₂.trans_lt <| WithBot.coe_lt_coe.mpr h₁ #align finset.not_mem_of_max_lt Finset.not_mem_of_max_lt theorem max_mono {s t : Finset α} (st : s ⊆ t) : s.max ≤ t.max := sup_mono st #align finset.max_mono Finset.max_mono protected theorem max_le {M : WithBot α} {s : Finset α} (st : ∀ a ∈ s, (a : WithBot α) ≤ M) : s.max ≤ M := Finset.sup_le st #align finset.max_le Finset.max_le /-- Let `s` be a finset in a linear order. Then `s.min` is the minimum of `s` if `s` is not empty, and `⊤` otherwise. It belongs to `WithTop α`. If you want to get an element of `α`, see `s.min'`. -/ protected def min (s : Finset α) : WithTop α := inf s (↑) #align finset.min Finset.min theorem min_eq_inf_withTop (s : Finset α) : s.min = inf s (↑) := rfl #align finset.min_eq_inf_with_top Finset.min_eq_inf_withTop @[simp] theorem min_empty : (∅ : Finset α).min = ⊤ := rfl #align finset.min_empty Finset.min_empty @[simp] theorem min_insert {a : α} {s : Finset α} : (insert a s).min = min (↑a) s.min := fold_insert_idem #align finset.min_insert Finset.min_insert @[simp] theorem min_singleton {a : α} : Finset.min {a} = (a : WithTop α) := by rw [← insert_emptyc_eq] exact min_insert #align finset.min_singleton Finset.min_singleton theorem min_of_mem {s : Finset α} {a : α} (h : a ∈ s) : ∃ b : α, s.min = b := by obtain ⟨b, h, _⟩ := inf_le (α := WithTop α) h _ rfl exact ⟨b, h⟩ #align finset.min_of_mem Finset.min_of_mem theorem min_of_nonempty {s : Finset α} (h : s.Nonempty) : ∃ a : α, s.min = a := let ⟨_, h⟩ := h min_of_mem h #align finset.min_of_nonempty Finset.min_of_nonempty theorem min_eq_top {s : Finset α} : s.min = ⊤ ↔ s = ∅ := ⟨fun h => s.eq_empty_or_nonempty.elim id fun H => by let ⟨a, ha⟩ := min_of_nonempty H rw [h] at ha; cases ha; done, -- Porting note: error without `done` fun h => h.symm ▸ min_empty⟩ #align finset.min_eq_top Finset.min_eq_top theorem mem_of_min {s : Finset α} : ∀ {a : α}, s.min = a → a ∈ s := @mem_of_max αᵒᵈ _ s #align finset.mem_of_min Finset.mem_of_min theorem min_le {a : α} {s : Finset α} (as : a ∈ s) : s.min ≤ a := inf_le as #align finset.min_le Finset.min_le theorem not_mem_of_coe_lt_min {a : α} {s : Finset α} (h : ↑a < s.min) : a ∉ s := mt min_le h.not_le #align finset.not_mem_of_coe_lt_min Finset.not_mem_of_coe_lt_min theorem min_le_of_eq {s : Finset α} {a b : α} (h₁ : b ∈ s) (h₂ : s.min = a) : a ≤ b := WithTop.coe_le_coe.mp <| h₂.ge.trans (min_le h₁) #align finset.min_le_of_eq Finset.min_le_of_eq theorem not_mem_of_lt_min {s : Finset α} {a b : α} (h₁ : a < b) (h₂ : s.min = ↑b) : a ∉ s := Finset.not_mem_of_coe_lt_min <| (WithTop.coe_lt_coe.mpr h₁).trans_eq h₂.symm #align finset.not_mem_of_lt_min Finset.not_mem_of_lt_min theorem min_mono {s t : Finset α} (st : s ⊆ t) : t.min ≤ s.min := inf_mono st #align finset.min_mono Finset.min_mono protected theorem le_min {m : WithTop α} {s : Finset α} (st : ∀ a : α, a ∈ s → m ≤ a) : m ≤ s.min := Finset.le_inf st #align finset.le_min Finset.le_min /-- Given a nonempty finset `s` in a linear order `α`, then `s.min' h` is its minimum, as an element of `α`, where `h` is a proof of nonemptiness. Without this assumption, use instead `s.min`, taking values in `WithTop α`. -/ def min' (s : Finset α) (H : s.Nonempty) : α := inf' s H id #align finset.min' Finset.min' /-- Given a nonempty finset `s` in a linear order `α`, then `s.max' h` is its maximum, as an element of `α`, where `h` is a proof of nonemptiness. Without this assumption, use instead `s.max`, taking values in `WithBot α`. -/ def max' (s : Finset α) (H : s.Nonempty) : α := sup' s H id #align finset.max' Finset.max' variable (s : Finset α) (H : s.Nonempty) {x : α} theorem min'_mem : s.min' H ∈ s := mem_of_min <| by simp only [Finset.min, min', id_eq, coe_inf']; rfl #align finset.min'_mem Finset.min'_mem theorem min'_le (x) (H2 : x ∈ s) : s.min' ⟨x, H2⟩ ≤ x := min_le_of_eq H2 (WithTop.coe_untop _ _).symm #align finset.min'_le Finset.min'_le theorem le_min' (x) (H2 : ∀ y ∈ s, x ≤ y) : x ≤ s.min' H := H2 _ <| min'_mem _ _ #align finset.le_min' Finset.le_min' theorem isLeast_min' : IsLeast (↑s) (s.min' H) := ⟨min'_mem _ _, min'_le _⟩ #align finset.is_least_min' Finset.isLeast_min' @[simp] theorem le_min'_iff {x} : x ≤ s.min' H ↔ ∀ y ∈ s, x ≤ y := le_isGLB_iff (isLeast_min' s H).isGLB #align finset.le_min'_iff Finset.le_min'_iff /-- `{a}.min' _` is `a`. -/ @[simp] theorem min'_singleton (a : α) : ({a} : Finset α).min' (singleton_nonempty _) = a := by simp [min'] #align finset.min'_singleton Finset.min'_singleton theorem max'_mem : s.max' H ∈ s := mem_of_max <| by simp only [max', Finset.max, id_eq, coe_sup']; rfl #align finset.max'_mem Finset.max'_mem theorem le_max' (x) (H2 : x ∈ s) : x ≤ s.max' ⟨x, H2⟩ := le_max_of_eq H2 (WithBot.coe_unbot _ _).symm #align finset.le_max' Finset.le_max' theorem max'_le (x) (H2 : ∀ y ∈ s, y ≤ x) : s.max' H ≤ x := H2 _ <| max'_mem _ _ #align finset.max'_le Finset.max'_le theorem isGreatest_max' : IsGreatest (↑s) (s.max' H) := ⟨max'_mem _ _, le_max' _⟩ #align finset.is_greatest_max' Finset.isGreatest_max' @[simp] theorem max'_le_iff {x} : s.max' H ≤ x ↔ ∀ y ∈ s, y ≤ x := isLUB_le_iff (isGreatest_max' s H).isLUB #align finset.max'_le_iff Finset.max'_le_iff @[simp] theorem max'_lt_iff {x} : s.max' H < x ↔ ∀ y ∈ s, y < x := ⟨fun Hlt y hy => (s.le_max' y hy).trans_lt Hlt, fun H => H _ <| s.max'_mem _⟩ #align finset.max'_lt_iff Finset.max'_lt_iff @[simp] theorem lt_min'_iff : x < s.min' H ↔ ∀ y ∈ s, x < y := @max'_lt_iff αᵒᵈ _ _ H _ #align finset.lt_min'_iff Finset.lt_min'_iff theorem max'_eq_sup' : s.max' H = s.sup' H id := eq_of_forall_ge_iff fun _ => (max'_le_iff _ _).trans (sup'_le_iff _ _).symm #align finset.max'_eq_sup' Finset.max'_eq_sup' theorem min'_eq_inf' : s.min' H = s.inf' H id := @max'_eq_sup' αᵒᵈ _ s H #align finset.min'_eq_inf' Finset.min'_eq_inf' /-- `{a}.max' _` is `a`. -/ @[simp] theorem max'_singleton (a : α) : ({a} : Finset α).max' (singleton_nonempty _) = a := by simp [max'] #align finset.max'_singleton Finset.max'_singleton theorem min'_lt_max' {i j} (H1 : i ∈ s) (H2 : j ∈ s) (H3 : i ≠ j) : s.min' ⟨i, H1⟩ < s.max' ⟨i, H1⟩ := isGLB_lt_isLUB_of_ne (s.isLeast_min' _).isGLB (s.isGreatest_max' _).isLUB H1 H2 H3 #align finset.min'_lt_max' Finset.min'_lt_max' /-- If there's more than 1 element, the min' is less than the max'. An alternate version of `min'_lt_max'` which is sometimes more convenient. -/ theorem min'_lt_max'_of_card (h₂ : 1 < card s) : s.min' (Finset.card_pos.mp <| lt_trans zero_lt_one h₂) < s.max' (Finset.card_pos.mp <| lt_trans zero_lt_one h₂) := by rcases one_lt_card.1 h₂ with ⟨a, ha, b, hb, hab⟩ exact s.min'_lt_max' ha hb hab #align finset.min'_lt_max'_of_card Finset.min'_lt_max'_of_card theorem map_ofDual_min (s : Finset αᵒᵈ) : s.min.map ofDual = (s.image ofDual).max := by rw [max_eq_sup_withBot, sup_image] exact congr_fun Option.map_id _ #align finset.map_of_dual_min Finset.map_ofDual_min theorem map_ofDual_max (s : Finset αᵒᵈ) : s.max.map ofDual = (s.image ofDual).min := by rw [min_eq_inf_withTop, inf_image] exact congr_fun Option.map_id _ #align finset.map_of_dual_max Finset.map_ofDual_max theorem map_toDual_min (s : Finset α) : s.min.map toDual = (s.image toDual).max := by rw [max_eq_sup_withBot, sup_image] exact congr_fun Option.map_id _ #align finset.map_to_dual_min Finset.map_toDual_min theorem map_toDual_max (s : Finset α) : s.max.map toDual = (s.image toDual).min := by rw [min_eq_inf_withTop, inf_image] exact congr_fun Option.map_id _ #align finset.map_to_dual_max Finset.map_toDual_max -- Porting note: new proofs without `convert` for the next four theorems. theorem ofDual_min' {s : Finset αᵒᵈ} (hs : s.Nonempty) : ofDual (min' s hs) = max' (s.image ofDual) (hs.image _) := by rw [← WithBot.coe_eq_coe] simp only [min'_eq_inf', id_eq, ofDual_inf', Function.comp_apply, coe_sup', max'_eq_sup', sup_image] rfl #align finset.of_dual_min' Finset.ofDual_min' theorem ofDual_max' {s : Finset αᵒᵈ} (hs : s.Nonempty) : ofDual (max' s hs) = min' (s.image ofDual) (hs.image _) := by rw [← WithTop.coe_eq_coe] simp only [max'_eq_sup', id_eq, ofDual_sup', Function.comp_apply, coe_inf', min'_eq_inf', inf_image] rfl #align finset.of_dual_max' Finset.ofDual_max' theorem toDual_min' {s : Finset α} (hs : s.Nonempty) : toDual (min' s hs) = max' (s.image toDual) (hs.image _) := by rw [← WithBot.coe_eq_coe] simp only [min'_eq_inf', id_eq, toDual_inf', Function.comp_apply, coe_sup', max'_eq_sup', sup_image] rfl #align finset.to_dual_min' Finset.toDual_min' theorem toDual_max' {s : Finset α} (hs : s.Nonempty) : toDual (max' s hs) = min' (s.image toDual) (hs.image _) := by rw [← WithTop.coe_eq_coe] simp only [max'_eq_sup', id_eq, toDual_sup', Function.comp_apply, coe_inf', min'_eq_inf', inf_image] rfl #align finset.to_dual_max' Finset.toDual_max' theorem max'_subset {s t : Finset α} (H : s.Nonempty) (hst : s ⊆ t) : s.max' H ≤ t.max' (H.mono hst) := le_max' _ _ (hst (s.max'_mem H)) #align finset.max'_subset Finset.max'_subset theorem min'_subset {s t : Finset α} (H : s.Nonempty) (hst : s ⊆ t) : t.min' (H.mono hst) ≤ s.min' H := min'_le _ _ (hst (s.min'_mem H)) #align finset.min'_subset Finset.min'_subset theorem max'_insert (a : α) (s : Finset α) (H : s.Nonempty) : (insert a s).max' (s.insert_nonempty a) = max (s.max' H) a := (isGreatest_max' _ _).unique <| by rw [coe_insert, max_comm] exact (isGreatest_max' _ _).insert _ #align finset.max'_insert Finset.max'_insert theorem min'_insert (a : α) (s : Finset α) (H : s.Nonempty) : (insert a s).min' (s.insert_nonempty a) = min (s.min' H) a := (isLeast_min' _ _).unique <| by rw [coe_insert, min_comm] exact (isLeast_min' _ _).insert _ #align finset.min'_insert Finset.min'_insert theorem lt_max'_of_mem_erase_max' [DecidableEq α] {a : α} (ha : a ∈ s.erase (s.max' H)) : a < s.max' H := lt_of_le_of_ne (le_max' _ _ (mem_of_mem_erase ha)) <| ne_of_mem_of_not_mem ha <| not_mem_erase _ _ #align finset.lt_max'_of_mem_erase_max' Finset.lt_max'_of_mem_erase_max' theorem min'_lt_of_mem_erase_min' [DecidableEq α] {a : α} (ha : a ∈ s.erase (s.min' H)) : s.min' H < a := @lt_max'_of_mem_erase_max' αᵒᵈ _ s H _ a ha #align finset.min'_lt_of_mem_erase_min' Finset.min'_lt_of_mem_erase_min' @[simp] theorem max'_image [LinearOrder β] {f : α → β} (hf : Monotone f) (s : Finset α) (h : (s.image f).Nonempty) : (s.image f).max' h = f (s.max' ((Nonempty.image_iff f).mp h)) := by refine' le_antisymm (max'_le _ _ _ fun y hy => _) (le_max' _ _ (mem_image.mpr ⟨_, max'_mem _ _, rfl⟩)) obtain ⟨x, hx, rfl⟩ := mem_image.mp hy exact hf (le_max' _ _ hx) #align finset.max'_image Finset.max'_image @[simp] theorem min'_image [LinearOrder β] {f : α → β} (hf : Monotone f) (s : Finset α) (h : (s.image f).Nonempty) : (s.image f).min' h = f (s.min' ((Nonempty.image_iff f).mp h)) := by refine' le_antisymm (min'_le _ _ (mem_image.mpr ⟨_, min'_mem _ _, rfl⟩)) (le_min' _ _ _ fun y hy => _) obtain ⟨x, hx, rfl⟩ := mem_image.mp hy exact hf (min'_le _ _ hx) #align finset.min'_image Finset.min'_image theorem coe_max' {s : Finset α} (hs : s.Nonempty) : ↑(s.max' hs) = s.max := coe_sup' hs id #align finset.coe_max' Finset.coe_max' theorem coe_min' {s : Finset α} (hs : s.Nonempty) : ↑(s.min' hs) = s.min := coe_inf' hs id #align finset.coe_min' Finset.coe_min' theorem max_mem_image_coe {s : Finset α} (hs : s.Nonempty) : s.max ∈ (s.image (↑) : Finset (WithBot α)) := mem_image.2 ⟨max' s hs, max'_mem _ _, coe_max' hs⟩ #align finset.max_mem_image_coe Finset.max_mem_image_coe theorem min_mem_image_coe {s : Finset α} (hs : s.Nonempty) : s.min ∈ (s.image (↑) : Finset (WithTop α)) := mem_image.2 ⟨min' s hs, min'_mem _ _, coe_min' hs⟩ #align finset.min_mem_image_coe Finset.min_mem_image_coe theorem max_mem_insert_bot_image_coe (s : Finset α) : s.max ∈ (insert ⊥ (s.image (↑)) : Finset (WithBot α)) := mem_insert.2 <| s.eq_empty_or_nonempty.imp max_eq_bot.2 max_mem_image_coe #align finset.max_mem_insert_bot_image_coe Finset.max_mem_insert_bot_image_coe theorem min_mem_insert_top_image_coe (s : Finset α) : s.min ∈ (insert ⊤ (s.image (↑)) : Finset (WithTop α)) := mem_insert.2 <| s.eq_empty_or_nonempty.imp min_eq_top.2 min_mem_image_coe #align finset.min_mem_insert_top_image_coe Finset.min_mem_insert_top_image_coe theorem max'_erase_ne_self {s : Finset α} (s0 : (s.erase x).Nonempty) : (s.erase x).max' s0 ≠ x := ne_of_mem_erase (max'_mem _ s0) #align finset.max'_erase_ne_self Finset.max'_erase_ne_self theorem min'_erase_ne_self {s : Finset α} (s0 : (s.erase x).Nonempty) : (s.erase x).min' s0 ≠ x := ne_of_mem_erase (min'_mem _ s0) #align finset.min'_erase_ne_self Finset.min'_erase_ne_self theorem max_erase_ne_self {s : Finset α} : (s.erase x).max ≠ x := by by_cases s0 : (s.erase x).Nonempty · refine' ne_of_eq_of_ne (coe_max' s0).symm _ exact WithBot.coe_eq_coe.not.mpr (max'_erase_ne_self _) · rw [not_nonempty_iff_eq_empty.mp s0, max_empty] exact WithBot.bot_ne_coe #align finset.max_erase_ne_self Finset.max_erase_ne_self theorem min_erase_ne_self {s : Finset α} : (s.erase x).min ≠ x := by -- Porting note: old proof `convert @max_erase_ne_self αᵒᵈ _ _ _` convert @max_erase_ne_self αᵒᵈ _ (toDual x) (s.map toDual.toEmbedding) using 1 apply congr_arg -- porting note: forces unfolding to see `Finset.min` is `Finset.max` congr! · ext; simp only [mem_map_equiv]; exact Iff.rfl #align finset.min_erase_ne_self Finset.min_erase_ne_self theorem exists_next_right {x : α} {s : Finset α} (h : ∃ y ∈ s, x < y) : ∃ y ∈ s, x < y ∧ ∀ z ∈ s, x < z → y ≤ z := have Hne : (s.filter ((· < ·) x)).Nonempty := h.imp fun y hy => mem_filter.2 (by simpa) have aux := (mem_filter.1 (min'_mem _ Hne)) ⟨min' _ Hne, aux.1, by simp, fun z hzs hz => min'_le _ _ <| mem_filter.2 ⟨hzs, by simpa⟩⟩ #align finset.exists_next_right Finset.exists_next_right theorem exists_next_left {x : α} {s : Finset α} (h : ∃ y ∈ s, y < x) : ∃ y ∈ s, y < x ∧ ∀ z ∈ s, z < x → z ≤ y := @exists_next_right αᵒᵈ _ x s h #align finset.exists_next_left Finset.exists_next_left /-- If finsets `s` and `t` are interleaved, then `Finset.card s ≤ Finset.card t + 1`. -/ theorem card_le_of_interleaved {s t : Finset α} (h : ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), x < y → (∀ z ∈ s, z ∉ Set.Ioo x y) → ∃ z ∈ t, x < z ∧ z < y) : s.card ≤ t.card + 1 := by replace h : ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), x < y → ∃ z ∈ t, x < z ∧ z < y · intro x hx y hy hxy rcases exists_next_right ⟨y, hy, hxy⟩ with ⟨a, has, hxa, ha⟩ rcases h x hx a has hxa fun z hzs hz => hz.2.not_le <| ha _ hzs hz.1 with ⟨b, hbt, hxb, hba⟩ exact ⟨b, hbt, hxb, hba.trans_le <| ha _ hy hxy⟩ set f : α → WithTop α := fun x => (t.filter fun y => x < y).min have f_mono : StrictMonoOn f s := by intro x hx y hy hxy rcases h x hx y hy hxy with ⟨a, hat, hxa, hay⟩ calc f x ≤ a := min_le (mem_filter.2 ⟨hat, by simpa⟩) _ < f y := (Finset.lt_inf_iff <| WithTop.coe_lt_top a).2 fun b hb => WithTop.coe_lt_coe.2 <| hay.trans (by simpa using (mem_filter.1 hb).2) calc s.card = (s.image f).card := (card_image_of_injOn f_mono.injOn).symm _ ≤ (insert ⊤ (t.image (↑)) : Finset (WithTop α)).card := card_mono <| image_subset_iff.2 fun x _ => insert_subset_insert _ (image_subset_image <| filter_subset _ _) (min_mem_insert_top_image_coe _) _ ≤ t.card + 1 := (card_insert_le _ _).trans (add_le_add_right card_image_le _) #align finset.card_le_of_interleaved Finset.card_le_of_interleaved /-- If finsets `s` and `t` are interleaved, then `Finset.card s ≤ Finset.card (t \ s) + 1`. -/ theorem card_le_diff_of_interleaved {s t : Finset α} (h : ∀ (x) (_ : x ∈ s) (y) (_ : y ∈ s), x < y → (∀ z ∈ s, z ∉ Set.Ioo x y) → ∃ z ∈ t, x < z ∧ z < y) : s.card ≤ (t \ s).card + 1 := card_le_of_interleaved fun x hx y hy hxy hs => let ⟨z, hzt, hxz, hzy⟩ := h x hx y hy hxy hs ⟨z, mem_sdiff.2 ⟨hzt, fun hzs => hs z hzs ⟨hxz, hzy⟩⟩, hxz, hzy⟩ #align finset.card_le_diff_of_interleaved Finset.card_le_diff_of_interleaved /-- Induction principle for `Finset`s in a linearly ordered type: a predicate is true on all `s : Finset α` provided that: * it is true on the empty `Finset`, * for every `s : Finset α` and an element `a` strictly greater than all elements of `s`, `p s` implies `p (insert a s)`. -/ @[elab_as_elim] theorem induction_on_max [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h0 : p ∅) (step : ∀ a s, (∀ x ∈ s, x < a) → p s → p (insert a s)) : p s := by induction' s using Finset.strongInductionOn with s ihs rcases s.eq_empty_or_nonempty with (rfl | hne) · exact h0 · have H : s.max' hne ∈ s := max'_mem s hne rw [← insert_erase H] exact step _ _ (fun x => s.lt_max'_of_mem_erase_max' hne) (ihs _ <| erase_ssubset H) #align finset.induction_on_max Finset.induction_on_max /-- Induction principle for `Finset`s in a linearly ordered type: a predicate is true on all `s : Finset α` provided that: * it is true on the empty `Finset`, * for every `s : Finset α` and an element `a` strictly less than all elements of `s`, `p s` implies `p (insert a s)`. -/ @[elab_as_elim] theorem induction_on_min [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h0 : p ∅) (step : ∀ a s, (∀ x ∈ s, a < x) → p s → p (insert a s)) : p s := @induction_on_max αᵒᵈ _ _ _ s h0 step #align finset.induction_on_min Finset.induction_on_min end MaxMin section MaxMinInductionValue variable [LinearOrder α] [LinearOrder β] /-- Induction principle for `Finset`s in any type from which a given function `f` maps to a linearly ordered type : a predicate is true on all `s : Finset α` provided that: * it is true on the empty `Finset`, * for every `s : Finset α` and an element `a` such that for elements of `s` denoted by `x` we have `f x ≤ f a`, `p s` implies `p (insert a s)`. -/ @[elab_as_elim] theorem induction_on_max_value [DecidableEq ι] (f : ι → α) {p : Finset ι → Prop} (s : Finset ι) (h0 : p ∅) (step : ∀ a s, a ∉ s → (∀ x ∈ s, f x ≤ f a) → p s → p (insert a s)) : p s := by induction' s using Finset.strongInductionOn with s ihs rcases(s.image f).eq_empty_or_nonempty with (hne | hne) · simp only [image_eq_empty] at hne simp only [hne, h0] · have H : (s.image f).max' hne ∈ s.image f := max'_mem (s.image f) hne simp only [mem_image, exists_prop] at H rcases H with ⟨a, has, hfa⟩ rw [← insert_erase has] refine' step _ _ (not_mem_erase a s) (fun x hx => _) (ihs _ <| erase_ssubset has) rw [hfa] exact le_max' _ _ (mem_image_of_mem _ <| mem_of_mem_erase hx) #align finset.induction_on_max_value Finset.induction_on_max_value /-- Induction principle for `Finset`s in any type from which a given function `f` maps to a linearly ordered type : a predicate is true on all `s : Finset α` provided that: * it is true on the empty `Finset`, * for every `s : Finset α` and an element `a` such that for elements of `s` denoted by `x` we have `f a ≤ f x`, `p s` implies `p (insert a s)`. -/ @[elab_as_elim] theorem induction_on_min_value [DecidableEq ι] (f : ι → α) {p : Finset ι → Prop} (s : Finset ι) (h0 : p ∅) (step : ∀ a s, a ∉ s → (∀ x ∈ s, f a ≤ f x) → p s → p (insert a s)) : p s := @induction_on_max_value αᵒᵈ ι _ _ _ _ s h0 step #align finset.induction_on_min_value Finset.induction_on_min_value end MaxMinInductionValue section ExistsMaxMin variable [LinearOrder α] theorem exists_max_image (s : Finset β) (f : β → α) (h : s.Nonempty) : ∃ x ∈ s, ∀ x' ∈ s, f x' ≤ f x := by cases' max_of_nonempty (h.image f) with y hy rcases mem_image.mp (mem_of_max hy) with ⟨x, hx, rfl⟩ exact ⟨x, hx, fun x' hx' => le_max_of_eq (mem_image_of_mem f hx') hy⟩ #align finset.exists_max_image Finset.exists_max_image theorem exists_min_image (s : Finset β) (f : β → α) (h : s.Nonempty) : ∃ x ∈ s, ∀ x' ∈ s, f x ≤ f x' := @exists_max_image αᵒᵈ β _ s f h #align finset.exists_min_image Finset.exists_min_image end ExistsMaxMin -- TODO names theorem is_glb_iff_is_least [LinearOrder α] (i : α) (s : Finset α) (hs : s.Nonempty) : IsGLB (s : Set α) i ↔ IsLeast (↑s) i := by refine' ⟨fun his => _, IsLeast.isGLB⟩ suffices i = min' s hs by rw [this] exact isLeast_min' s hs rw [IsGLB, IsGreatest, mem_lowerBounds, mem_upperBounds] at his exact le_antisymm (his.1 (Finset.min' s hs) (Finset.min'_mem s hs)) (his.2 _ (Finset.min'_le s)) #align finset.is_glb_iff_is_least Finset.is_glb_iff_is_least theorem is_lub_iff_is_greatest [LinearOrder α] (i : α) (s : Finset α) (hs : s.Nonempty) : IsLUB (s : Set α) i ↔ IsGreatest (↑s) i := @is_glb_iff_is_least αᵒᵈ _ i s hs #align finset.is_lub_iff_is_greatest Finset.is_lub_iff_is_greatest theorem is_glb_mem [LinearOrder α] {i : α} (s : Finset α) (his : IsGLB (s : Set α) i) (hs : s.Nonempty) : i ∈ s := by rw [← mem_coe] exact ((is_glb_iff_is_least i s hs).mp his).1 #align finset.is_glb_mem Finset.is_glb_mem theorem is_lub_mem [LinearOrder α] {i : α} (s : Finset α) (his : IsLUB (s : Set α) i) (hs : s.Nonempty) : i ∈ s := @is_glb_mem αᵒᵈ _ i s his hs #align finset.is_lub_mem Finset.is_lub_mem end Finset namespace Multiset theorem map_finset_sup [DecidableEq α] [DecidableEq β] (s : Finset γ) (f : γ → Multiset β) (g : β → α) (hg : Function.Injective g) : map g (s.sup f) = s.sup (map g ∘ f) := Finset.comp_sup_eq_sup_comp _ (fun _ _ => map_union hg) (map_zero _) #align multiset.map_finset_sup Multiset.map_finset_sup theorem count_finset_sup [DecidableEq β] (s : Finset α) (f : α → Multiset β) (b : β) : count b (s.sup f) = s.sup fun a => count b (f a) := by letI := Classical.decEq α refine' s.induction _ _ · exact count_zero _ · intro i s _ ih rw [Finset.sup_insert, sup_eq_union, count_union, Finset.sup_insert, ih] rfl #align multiset.count_finset_sup Multiset.count_finset_sup theorem mem_sup {α β} [DecidableEq β] {s : Finset α} {f : α → Multiset β} {x : β} : x ∈ s.sup f ↔ ∃ v ∈ s, x ∈ f v := by classical induction' s using Finset.induction_on with a s has hxs · simp · rw [Finset.sup_insert, Multiset.sup_eq_union, Multiset.mem_union] constructor · intro hxi cases' hxi with hf hf · refine' ⟨a, _, hf⟩ simp only [true_or_iff, eq_self_iff_true, Finset.mem_insert] · rcases hxs.mp hf with ⟨v, hv, hfv⟩ refine' ⟨v, _, hfv⟩ simp only [hv, or_true_iff, Finset.mem_insert] · rintro ⟨v, hv, hfv⟩ rw [Finset.mem_insert] at hv rcases hv with (rfl | hv) · exact Or.inl hfv · refine' Or.inr (hxs.mpr ⟨v, hv, hfv⟩) #align multiset.mem_sup Multiset.mem_sup end Multiset namespace Finset theorem mem_sup {α β} [DecidableEq β] {s : Finset α} {f : α → Finset β} {x : β} : x ∈ s.sup f ↔ ∃ v ∈ s, x ∈ f v := by change _ ↔ ∃ v ∈ s, x ∈ (f v).val rw [← Multiset.mem_sup, ← Multiset.mem_toFinset, sup_toFinset] simp_rw [val_toFinset] #align finset.mem_sup Finset.mem_sup theorem sup_eq_bunionᵢ {α β} [DecidableEq β] (s : Finset α) (t : α → Finset β) : s.sup t = s.bunionᵢ t := by ext rw [mem_sup, mem_bunionᵢ] #align finset.sup_eq_bUnion Finset.sup_eq_bunionᵢ @[simp] theorem sup_singleton'' [DecidableEq α] (s : Finset β) (f : β → α) : (s.sup fun b => {f b}) = s.image f := by ext a rw [mem_sup, mem_image] simp only [mem_singleton, eq_comm] #align finset.sup_singleton'' Finset.sup_singleton'' @[simp] theorem sup_singleton' [DecidableEq α] (s : Finset α) : s.sup singleton = s := (s.sup_singleton'' _).trans image_id #align finset.sup_singleton' Finset.sup_singleton' end Finset section Lattice variable {ι' : Sort _} [CompleteLattice α] /-- Supremum of `s i`, `i : ι`, is equal to the supremum over `t : Finset ι` of suprema `⨆ i ∈ t, s i`. This version assumes `ι` is a `Type _`. See `supᵢ_eq_supᵢ_finset'` for a version that works for `ι : Sort*`. -/ theorem supᵢ_eq_supᵢ_finset (s : ι → α) : (⨆ i, s i) = ⨆ t : Finset ι, ⨆ i ∈ t, s i := by classical refine le_antisymm ?_ ?_ exact supᵢ_le fun b => le_supᵢ_of_le {b} <| le_supᵢ_of_le b <| le_supᵢ_of_le (by simp) <| le_rfl exact supᵢ_le fun t => supᵢ_le fun b => supᵢ_le fun _ => le_supᵢ _ _ #align supr_eq_supr_finset supᵢ_eq_supᵢ_finset /-- Supremum of `s i`, `i : ι`, is equal to the supremum over `t : Finset ι` of suprema `⨆ i ∈ t, s i`. This version works for `ι : Sort*`. See `supᵢ_eq_supᵢ_finset` for a version that assumes `ι : Type _` but has no `plift`s. -/ theorem supᵢ_eq_supᵢ_finset' (s : ι' → α) : (⨆ i, s i) = ⨆ t : Finset (PLift ι'), ⨆ i ∈ t, s (PLift.down i) := by rw [← supᵢ_eq_supᵢ_finset, ← Equiv.plift.surjective.supᵢ_comp]; rfl #align supr_eq_supr_finset' supᵢ_eq_supᵢ_finset' /-- Infimum of `s i`, `i : ι`, is equal to the infimum over `t : Finset ι` of infima `⨅ i ∈ t, s i`. This version assumes `ι` is a `Type _`. See `infᵢ_eq_infᵢ_finset'` for a version that works for `ι : Sort*`. -/ theorem infᵢ_eq_infᵢ_finset (s : ι → α) : (⨅ i, s i) = ⨅ (t : Finset ι) (i ∈ t), s i := @supᵢ_eq_supᵢ_finset αᵒᵈ _ _ _ #align infi_eq_infi_finset infᵢ_eq_infᵢ_finset /-- Infimum of `s i`, `i : ι`, is equal to the infimum over `t : Finset ι` of infima `⨅ i ∈ t, s i`. This version works for `ι : Sort*`. See `infᵢ_eq_infᵢ_finset` for a version that assumes `ι : Type _` but has no `plift`s. -/ theorem infᵢ_eq_infᵢ_finset' (s : ι' → α) : (⨅ i, s i) = ⨅ t : Finset (PLift ι'), ⨅ i ∈ t, s (PLift.down i) := @supᵢ_eq_supᵢ_finset' αᵒᵈ _ _ _ #align infi_eq_infi_finset' infᵢ_eq_infᵢ_finset' end Lattice namespace Set variable {ι' : Sort _} /-- Union of an indexed family of sets `s : ι → Set α` is equal to the union of the unions of finite subfamilies. This version assumes `ι : Type _`. See also `unionᵢ_eq_unionᵢ_finset'` for a version that works for `ι : Sort*`. -/ theorem unionᵢ_eq_unionᵢ_finset (s : ι → Set α) : (⋃ i, s i) = ⋃ t : Finset ι, ⋃ i ∈ t, s i := supᵢ_eq_supᵢ_finset s #align set.Union_eq_Union_finset Set.unionᵢ_eq_unionᵢ_finset /-- Union of an indexed family of sets `s : ι → Set α` is equal to the union of the unions of finite subfamilies. This version works for `ι : Sort*`. See also `unionᵢ_eq_unionᵢ_finset` for a version that assumes `ι : Type _` but avoids `plift`s in the right hand side. -/ theorem unionᵢ_eq_unionᵢ_finset' (s : ι' → Set α) : (⋃ i, s i) = ⋃ t : Finset (PLift ι'), ⋃ i ∈ t, s (PLift.down i) := supᵢ_eq_supᵢ_finset' s #align set.Union_eq_Union_finset' Set.unionᵢ_eq_unionᵢ_finset' /-- Intersection of an indexed family of sets `s : ι → Set α` is equal to the intersection of the intersections of finite subfamilies. This version assumes `ι : Type _`. See also `interᵢ_eq_interᵢ_finset'` for a version that works for `ι : Sort*`. -/ theorem interᵢ_eq_interᵢ_finset (s : ι → Set α) : (⋂ i, s i) = ⋂ t : Finset ι, ⋂ i ∈ t, s i := infᵢ_eq_infᵢ_finset s #align set.Inter_eq_Inter_finset Set.interᵢ_eq_interᵢ_finset /-- Intersection of an indexed family of sets `s : ι → Set α` is equal to the intersection of the intersections of finite subfamilies. This version works for `ι : Sort*`. See also `interᵢ_eq_interᵢ_finset` for a version that assumes `ι : Type _` but avoids `plift`s in the right hand side. -/ theorem interᵢ_eq_interᵢ_finset' (s : ι' → Set α) : (⋂ i, s i) = ⋂ t : Finset (PLift ι'), ⋂ i ∈ t, s (PLift.down i) := infᵢ_eq_infᵢ_finset' s #align set.Inter_eq_Inter_finset' Set.interᵢ_eq_interᵢ_finset' end Set namespace Finset /-! ### Interaction with ordered algebra structures -/ theorem sup_mul_le_mul_sup_of_nonneg [LinearOrderedSemiring α] [OrderBot α] {a b : ι → α} (s : Finset ι) (ha : ∀ i ∈ s, 0 ≤ a i) (hb : ∀ i ∈ s, 0 ≤ b i) : s.sup (a * b) ≤ s.sup a * s.sup b := Finset.sup_le fun _i hi => mul_le_mul (le_sup hi) (le_sup hi) (hb _ hi) ((ha _ hi).trans <| le_sup hi) #align finset.sup_mul_le_mul_sup_of_nonneg Finset.sup_mul_le_mul_sup_of_nonneg theorem mul_inf_le_inf_mul_of_nonneg [LinearOrderedSemiring α] [OrderTop α] {a b : ι → α} (s : Finset ι) (ha : ∀ i ∈ s, 0 ≤ a i) (hb : ∀ i ∈ s, 0 ≤ b i) : s.inf a * s.inf b ≤ s.inf (a * b) := Finset.le_inf fun i hi => mul_le_mul (inf_le hi) (inf_le hi) (Finset.le_inf hb) (ha i hi) #align finset.mul_inf_le_inf_mul_of_nonneg Finset.mul_inf_le_inf_mul_of_nonneg theorem sup'_mul_le_mul_sup'_of_nonneg [LinearOrderedSemiring α] {a b : ι → α} (s : Finset ι) (H : s.Nonempty) (ha : ∀ i ∈ s, 0 ≤ a i) (hb : ∀ i ∈ s, 0 ≤ b i) : s.sup' H (a * b) ≤ s.sup' H a * s.sup' H b := (sup'_le _ _) fun _i hi => mul_le_mul (le_sup' _ hi) (le_sup' _ hi) (hb _ hi) ((ha _ hi).trans <| le_sup' _ hi) #align finset.sup'_mul_le_mul_sup'_of_nonneg Finset.sup'_mul_le_mul_sup'_of_nonneg theorem inf'_mul_le_mul_inf'_of_nonneg [LinearOrderedSemiring α] {a b : ι → α} (s : Finset ι) (H : s.Nonempty) (ha : ∀ i ∈ s, 0 ≤ a i) (hb : ∀ i ∈ s, 0 ≤ b i) : s.inf' H a * s.inf' H b ≤ s.inf' H (a * b) := (le_inf' _ _) fun _i hi => mul_le_mul (inf'_le _ hi) (inf'_le _ hi) (le_inf' _ _ hb) (ha _ hi) #align finset.inf'_mul_le_mul_inf'_of_nonneg Finset.inf'_mul_le_mul_inf'_of_nonneg open Function /-! ### Interaction with big lattice/set operations -/ section Lattice theorem supᵢ_coe [SupSet β] (f : α → β) (s : Finset α) : (⨆ x ∈ (↑s : Set α), f x) = ⨆ x ∈ s, f x := rfl #align finset.supr_coe Finset.supᵢ_coe theorem infᵢ_coe [InfSet β] (f : α → β) (s : Finset α) : (⨅ x ∈ (↑s : Set α), f x) = ⨅ x ∈ s, f x := rfl #align finset.infi_coe Finset.infᵢ_coe variable [CompleteLattice β] theorem supᵢ_singleton (a : α) (s : α → β) : (⨆ x ∈ ({a} : Finset α), s x) = s a := by simp #align finset.supr_singleton Finset.supᵢ_singleton theorem infᵢ_singleton (a : α) (s : α → β) : (⨅ x ∈ ({a} : Finset α), s x) = s a := by simp #align finset.infi_singleton Finset.infᵢ_singleton theorem supᵢ_option_toFinset (o : Option α) (f : α → β) : (⨆ x ∈ o.toFinset, f x) = ⨆ x ∈ o, f x := by simp #align finset.supr_option_to_finset Finset.supᵢ_option_toFinset theorem infᵢ_option_toFinset (o : Option α) (f : α → β) : (⨅ x ∈ o.toFinset, f x) = ⨅ x ∈ o, f x := @supᵢ_option_toFinset _ βᵒᵈ _ _ _ #align finset.infi_option_to_finset Finset.infᵢ_option_toFinset variable [DecidableEq α] theorem supᵢ_union {f : α → β} {s t : Finset α} : (⨆ x ∈ s ∪ t, f x) = (⨆ x ∈ s, f x) ⊔ ⨆ x ∈ t, f x := by simp [supᵢ_or, supᵢ_sup_eq] #align finset.supr_union Finset.supᵢ_union theorem infᵢ_union {f : α → β} {s t : Finset α} : (⨅ x ∈ s ∪ t, f x) = (⨅ x ∈ s, f x) ⊓ ⨅ x ∈ t, f x := @supᵢ_union α βᵒᵈ _ _ _ _ _ #align finset.infi_union Finset.infᵢ_union theorem supᵢ_insert (a : α) (s : Finset α) (t : α → β) : (⨆ x ∈ insert a s, t x) = t a ⊔ ⨆ x ∈ s, t x := by rw [insert_eq] simp only [supᵢ_union, Finset.supᵢ_singleton] #align finset.supr_insert Finset.supᵢ_insert theorem infᵢ_insert (a : α) (s : Finset α) (t : α → β) : (⨅ x ∈ insert a s, t x) = t a ⊓ ⨅ x ∈ s, t x := @supᵢ_insert α βᵒᵈ _ _ _ _ _ #align finset.infi_insert Finset.infᵢ_insert theorem supᵢ_finset_image {f : γ → α} {g : α → β} {s : Finset γ} : (⨆ x ∈ s.image f, g x) = ⨆ y ∈ s, g (f y) := by rw [← supᵢ_coe, coe_image, supᵢ_image, supᵢ_coe] #align finset.supr_finset_image Finset.supᵢ_finset_image theorem sup_finset_image {β γ : Type _} [SemilatticeSup β] [OrderBot β] (f : γ → α) (g : α → β) (s : Finset γ) : (s.image f).sup g = s.sup (g ∘ f) := by classical induction' s using Finset.induction_on with a s' _ ih <;> simp [*] #align finset.sup_finset_image Finset.sup_finset_image theorem infᵢ_finset_image {f : γ → α} {g : α → β} {s : Finset γ} : (⨅ x ∈ s.image f, g x) = ⨅ y ∈ s, g (f y) := by rw [← infᵢ_coe, coe_image, infᵢ_image, infᵢ_coe] #align finset.infi_finset_image Finset.infᵢ_finset_image theorem supᵢ_insert_update {x : α} {t : Finset α} (f : α → β) {s : β} (hx : x ∉ t) : (⨆ i ∈ insert x t, Function.update f x s i) = s ⊔ ⨆ i ∈ t, f i := by simp only [Finset.supᵢ_insert, update_same] rcongr (i hi); apply update_noteq; rintro rfl; exact hx hi #align finset.supr_insert_update Finset.supᵢ_insert_update theorem infᵢ_insert_update {x : α} {t : Finset α} (f : α → β) {s : β} (hx : x ∉ t) : (⨅ i ∈ insert x t, update f x s i) = s ⊓ ⨅ i ∈ t, f i := @supᵢ_insert_update α βᵒᵈ _ _ _ _ f _ hx #align finset.infi_insert_update Finset.infᵢ_insert_update theorem supᵢ_bunionᵢ (s : Finset γ) (t : γ → Finset α) (f : α → β) : (⨆ y ∈ s.bunionᵢ t, f y) = ⨆ (x ∈ s) (y ∈ t x), f y := by simp [@supᵢ_comm _ α, supᵢ_and] #align finset.supr_bUnion Finset.supᵢ_bunionᵢ theorem infᵢ_bunionᵢ (s : Finset γ) (t : γ → Finset α) (f : α → β) : (⨅ y ∈ s.bunionᵢ t, f y) = ⨅ (x ∈ s) (y ∈ t x), f y := @supᵢ_bunionᵢ _ βᵒᵈ _ _ _ _ _ _ #align finset.infi_bUnion Finset.infᵢ_bunionᵢ end Lattice theorem set_bunionᵢ_coe (s : Finset α) (t : α → Set β) : (⋃ x ∈ (↑s : Set α), t x) = ⋃ x ∈ s, t x := rfl #align finset.set_bUnion_coe Finset.set_bunionᵢ_coe theorem set_binterᵢ_coe (s : Finset α) (t : α → Set β) : (⋂ x ∈ (↑s : Set α), t x) = ⋂ x ∈ s, t x := rfl #align finset.set_bInter_coe Finset.set_binterᵢ_coe theorem set_bunionᵢ_singleton (a : α) (s : α → Set β) : (⋃ x ∈ ({a} : Finset α), s x) = s a := supᵢ_singleton a s #align finset.set_bUnion_singleton Finset.set_bunionᵢ_singleton theorem set_binterᵢ_singleton (a : α) (s : α → Set β) : (⋂ x ∈ ({a} : Finset α), s x) = s a := infᵢ_singleton a s #align finset.set_bInter_singleton Finset.set_binterᵢ_singleton @[simp] theorem set_bunionᵢ_preimage_singleton (f : α → β) (s : Finset β) : (⋃ y ∈ s, f ⁻¹' {y}) = f ⁻¹' s := Set.bunionᵢ_preimage_singleton f s #align finset.set_bUnion_preimage_singleton Finset.set_bunionᵢ_preimage_singleton theorem set_bunionᵢ_option_toFinset (o : Option α) (f : α → Set β) : (⋃ x ∈ o.toFinset, f x) = ⋃ x ∈ o, f x := supᵢ_option_toFinset o f #align finset.set_bUnion_option_to_finset Finset.set_bunionᵢ_option_toFinset theorem set_binterᵢ_option_toFinset (o : Option α) (f : α → Set β) : (⋂ x ∈ o.toFinset, f x) = ⋂ x ∈ o, f x := infᵢ_option_toFinset o f #align finset.set_bInter_option_to_finset Finset.set_binterᵢ_option_toFinset theorem subset_set_bunionᵢ_of_mem {s : Finset α} {f : α → Set β} {x : α} (h : x ∈ s) : f x ⊆ ⋃ y ∈ s, f y := show f x ≤ ⨆ y ∈ s, f y from le_supᵢ_of_le x <| by simp only [h, supᵢ_pos, le_refl] #align finset.subset_set_bUnion_of_mem Finset.subset_set_bunionᵢ_of_mem variable [DecidableEq α] theorem set_bunionᵢ_union (s t : Finset α) (u : α → Set β) : (⋃ x ∈ s ∪ t, u x) = (⋃ x ∈ s, u x) ∪ ⋃ x ∈ t, u x := supᵢ_union #align finset.set_bUnion_union Finset.set_bunionᵢ_union theorem set_binterᵢ_inter (s t : Finset α) (u : α → Set β) : (⋂ x ∈ s ∪ t, u x) = (⋂ x ∈ s, u x) ∩ ⋂ x ∈ t, u x := infᵢ_union #align finset.set_bInter_inter Finset.set_binterᵢ_inter theorem set_bunionᵢ_insert (a : α) (s : Finset α) (t : α → Set β) : (⋃ x ∈ insert a s, t x) = t a ∪ ⋃ x ∈ s, t x := supᵢ_insert a s t #align finset.set_bUnion_insert Finset.set_bunionᵢ_insert theorem set_binterᵢ_insert (a : α) (s : Finset α) (t : α → Set β) : (⋂ x ∈ insert a s, t x) = t a ∩ ⋂ x ∈ s, t x := infᵢ_insert a s t #align finset.set_bInter_insert Finset.set_binterᵢ_insert theorem set_bunionᵢ_finset_image {f : γ → α} {g : α → Set β} {s : Finset γ} : (⋃ x ∈ s.image f, g x) = ⋃ y ∈ s, g (f y) := supᵢ_finset_image #align finset.set_bUnion_finset_image Finset.set_bunionᵢ_finset_image theorem set_binterᵢ_finset_image {f : γ → α} {g : α → Set β} {s : Finset γ} : (⋂ x ∈ s.image f, g x) = ⋂ y ∈ s, g (f y) := infᵢ_finset_image #align finset.set_bInter_finset_image Finset.set_binterᵢ_finset_image theorem set_bunionᵢ_insert_update {x : α} {t : Finset α} (f : α → Set β) {s : Set β} (hx : x ∉ t) : (⋃ i ∈ insert x t, @update _ _ _ f x s i) = s ∪ ⋃ i ∈ t, f i := supᵢ_insert_update f hx #align finset.set_bUnion_insert_update Finset.set_bunionᵢ_insert_update theorem set_binterᵢ_insert_update {x : α} {t : Finset α} (f : α → Set β) {s : Set β} (hx : x ∉ t) : (⋂ i ∈ insert x t, @update _ _ _ f x s i) = s ∩ ⋂ i ∈ t, f i := infᵢ_insert_update f hx #align finset.set_bInter_insert_update Finset.set_binterᵢ_insert_update theorem set_bunionᵢ_bunionᵢ (s : Finset γ) (t : γ → Finset α) (f : α → Set β) : (⋃ y ∈ s.bunionᵢ t, f y) = ⋃ (x ∈ s) (y ∈ t x), f y := supᵢ_bunionᵢ s t f #align finset.set_bUnion_bUnion Finset.set_bunionᵢ_bunionᵢ theorem set_binterᵢ_bunionᵢ (s : Finset γ) (t : γ → Finset α) (f : α → Set β) : (⋂ y ∈ s.bunionᵢ t, f y) = ⋂ (x ∈ s) (y ∈ t x), f y := infᵢ_bunionᵢ s t f #align finset.set_bInter_bUnion Finset.set_binterᵢ_bunionᵢ end Finset
lemma real_affinity_le: "0 < m \<Longrightarrow> m * x + c \<le> y \<longleftrightarrow> x \<le> inverse m * y + - (c / m)" for m :: "'a::linordered_field"
If $b < a$, then the contour integral of $f$ along the part of the circle of radius $r$ centered at $c$ from $a$ to $b$ is equal to the negative of the contour integral of $f$ along the part of the circle of radius $r$ centered at $c$ from $b$ to $a$.
(* Title: HOL/Auth/n_germanSymIndex_lemma_inv__26_on_rules.thy Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences *) header{*The n_germanSymIndex Protocol Case Study*} theory n_germanSymIndex_lemma_inv__26_on_rules imports n_germanSymIndex_lemma_on_inv__26 begin section{*All lemmas on causal relation between inv__26*} lemma lemma_inv__26_on_rules: assumes b1: "r \<in> rules N" and b2: "(\<exists> p__Inv0 p__Inv2. p__Inv0\<le>N\<and>p__Inv2\<le>N\<and>p__Inv0~=p__Inv2\<and>f=inv__26 p__Inv0 p__Inv2)" shows "invHoldForRule s f r (invariants N)" proof - have c1: "(\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d)\<or> (\<exists> i. i\<le>N\<and>r=n_SendReqS i)\<or> (\<exists> i. i\<le>N\<and>r=n_SendReqE__part__0 i)\<or> (\<exists> i. i\<le>N\<and>r=n_SendReqE__part__1 i)\<or> (\<exists> i. i\<le>N\<and>r=n_RecvReqS N i)\<or> (\<exists> i. i\<le>N\<and>r=n_RecvReqE N i)\<or> (\<exists> i. i\<le>N\<and>r=n_SendInv__part__0 i)\<or> (\<exists> i. i\<le>N\<and>r=n_SendInv__part__1 i)\<or> (\<exists> i. i\<le>N\<and>r=n_SendInvAck i)\<or> (\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)\<or> (\<exists> i. i\<le>N\<and>r=n_SendGntS i)\<or> (\<exists> i. i\<le>N\<and>r=n_SendGntE N i)\<or> (\<exists> i. i\<le>N\<and>r=n_RecvGntS i)\<or> (\<exists> i. i\<le>N\<and>r=n_RecvGntE i)" apply (cut_tac b1, auto) done moreover { assume d1: "(\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_StoreVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendReqS i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendReqSVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendReqE__part__0 i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendReqE__part__0Vsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendReqE__part__1 i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendReqE__part__1Vsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvReqS N i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_RecvReqSVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvReqE N i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_RecvReqEVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__0 i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendInv__part__0Vsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__1 i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendInv__part__1Vsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendInvAckVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_RecvInvAckVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendGntS i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendGntSVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_SendGntEVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_RecvGntSVsinv__26) done } moreover { assume d1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)" have "invHoldForRule s f r (invariants N)" apply (cut_tac b2 d1, metis n_RecvGntEVsinv__26) done } ultimately show "invHoldForRule s f r (invariants N)" by satx qed end
module mmhelloworld.idrisjvmautoffisample.importer.JvmImporter import IdrisJvm.IO import IdrisJvm.JvmImport import Java.Lang import Java.Util %access public export %language TypeProviders objectMapperClass : String objectMapperClass = "com/fasterxml/jackson/databind/ObjectMapper" jsonNodeClass : String jsonNodeClass = "com/fasterxml/jackson/databind/JsonNode" javaimport "mvn -f ../pom.xml exec:java@jvm-import-idris -Dexec.arguments=" [ (objectMapperClass, ["<init>", "readTree"]), (jsonNodeClass, ["at", "asDouble"]), (integerClass, ["parseInt"]) ]
[GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t ⊢ IsPreconnected s [PROOFSTEP] rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] have xs : x ∈ s := by rcases H y ys with ⟨t, ts, xt, -, -⟩ exact ts xt [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v ⊢ x ∈ s [PROOFSTEP] rcases H y ys with ⟨t, ts, xt, -, -⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v t : Set α ts : t ⊆ s xt : x ∈ t ⊢ x ∈ s [PROOFSTEP] exact ts xt [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] cases hs xs [GOAL] case intro.intro.intro.intro.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s h✝ : x ∈ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) case intro.intro.intro.intro.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s h✝ : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] case inl xu => rcases H y ys with ⟨t, ts, xt, yt, ht⟩ have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩ exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xu : x ∈ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] case inl xu => rcases H y ys with ⟨t, ts, xt, yt, ht⟩ have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩ exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xu : x ∈ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases H y ys with ⟨t, ts, xt, yt, ht⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xu : x ∈ u t : Set α ts : t ⊆ s xt : x ∈ t yt : y ∈ t ht : IsPreconnected t ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xu : x ∈ u t : Set α ts : t ⊆ s xt : x ∈ t yt : y ∈ t ht : IsPreconnected t this : Set.Nonempty (t ∩ (u ∩ v)) ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩ [GOAL] case intro.intro.intro.intro.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s h✝ : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] case inr xv => rcases H z zs with ⟨t, ts, xt, zt, ht⟩ have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩ exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xv : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] case inr xv => rcases H z zs with ⟨t, ts, xt, zt, ht⟩ have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩ exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xv : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases H z zs with ⟨t, ts, xt, zt, ht⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xv : x ∈ v t : Set α ts : t ⊆ s xt : x ∈ t zt : z ∈ t ht : IsPreconnected t ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xv : x ∈ v t : Set α ts : t ⊆ s xt : x ∈ t zt : z ∈ t ht : IsPreconnected t ⊢ s ⊆ v ∪ u [PROOFSTEP] rwa [union_comm] [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α x : α H : ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v z : α zs : z ∈ s zu : z ∈ u y : α ys : y ∈ s yv : y ∈ v xs : x ∈ s xv : x ∈ v t : Set α ts : t ⊆ s xt : x ∈ t zt : z ∈ t ht : IsPreconnected t this : Set.Nonempty (t ∩ (v ∩ u)) ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α H : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t ⊢ IsPreconnected s [PROOFSTEP] rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩) [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α H : ∀ (x : α), x ∈ ∅ → ∀ (y : α), y ∈ ∅ → ∃ t, t ⊆ ∅ ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t ⊢ IsPreconnected ∅ case inr.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α H : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t x : α hx : x ∈ s ⊢ IsPreconnected s [PROOFSTEP] exacts [isPreconnected_empty, isPreconnected_of_forall x fun y => H x hx y] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α c : Set (Set α) H1 : ∀ (s : Set α), s ∈ c → x ∈ s H2 : ∀ (s : Set α), s ∈ c → IsPreconnected s ⊢ IsPreconnected (⋃₀ c) [PROOFSTEP] apply isPreconnected_of_forall x [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α c : Set (Set α) H1 : ∀ (s : Set α), s ∈ c → x ∈ s H2 : ∀ (s : Set α), s ∈ c → IsPreconnected s ⊢ ∀ (y : α), y ∈ ⋃₀ c → ∃ t, t ⊆ ⋃₀ c ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t [PROOFSTEP] rintro y ⟨s, sc, ys⟩ [GOAL] case intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v : Set α x : α c : Set (Set α) H1 : ∀ (s : Set α), s ∈ c → x ∈ s H2 : ∀ (s : Set α), s ∈ c → IsPreconnected s y : α s : Set α sc : s ∈ c ys : y ∈ s ⊢ ∃ t, t ⊆ ⋃₀ c ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t [PROOFSTEP] exact ⟨s, subset_sUnion_of_mem sc, H1 s sc, ys, H2 s sc⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α x : α s t : Set α H1 : x ∈ s H2 : x ∈ t H3 : IsPreconnected s H4 : IsPreconnected t ⊢ ∀ (s_1 : Set α), s_1 ∈ {s, t} → x ∈ s_1 [PROOFSTEP] rintro r (rfl | rfl | h) [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t✝ u v : Set α x : α t : Set α H2 : x ∈ t H4 : IsPreconnected t r : Set α H1 : x ∈ r H3 : IsPreconnected r ⊢ x ∈ r [PROOFSTEP] assumption [GOAL] case inr.refl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α x : α s t : Set α H1 : x ∈ s H2 : x ∈ t H3 : IsPreconnected s H4 : IsPreconnected t ⊢ x ∈ t [PROOFSTEP] assumption [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α x : α s t : Set α H1 : x ∈ s H2 : x ∈ t H3 : IsPreconnected s H4 : IsPreconnected t ⊢ ∀ (s_1 : Set α), s_1 ∈ {s, t} → IsPreconnected s_1 [PROOFSTEP] rintro r (rfl | rfl | h) [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t✝ u v : Set α x : α t : Set α H2 : x ∈ t H4 : IsPreconnected t r : Set α H1 : x ∈ r H3 : IsPreconnected r ⊢ IsPreconnected r [PROOFSTEP] assumption [GOAL] case inr.refl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α x : α s t : Set α H1 : x ∈ s H2 : x ∈ t H3 : IsPreconnected s H4 : IsPreconnected t ⊢ IsPreconnected t [PROOFSTEP] assumption [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s t : Set α H : Set.Nonempty (s ∩ t) hs : IsPreconnected s ht : IsPreconnected t ⊢ IsPreconnected (s ∪ t) [PROOFSTEP] rcases H with ⟨x, hxs, hxt⟩ [GOAL] case intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s t : Set α hs : IsPreconnected s ht : IsPreconnected t x : α hxs : x ∈ s hxt : x ∈ t ⊢ IsPreconnected (s ∪ t) [PROOFSTEP] exact hs.union x hxs hxt ht [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s t : Set α H : Set.Nonempty (s ∩ t) Hs : IsConnected s Ht : IsConnected t ⊢ IsConnected (s ∪ t) [PROOFSTEP] rcases H with ⟨x, hx⟩ [GOAL] case intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s t : Set α Hs : IsConnected s Ht : IsConnected t x : α hx : x ∈ s ∩ t ⊢ IsConnected (s ∪ t) [PROOFSTEP] refine' ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, _⟩ [GOAL] case intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s t : Set α Hs : IsConnected s Ht : IsConnected t x : α hx : x ∈ s ∩ t ⊢ IsPreconnected (s ∪ t) [PROOFSTEP] exact Hs.isPreconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx) Ht.isPreconnected [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α S : Set (Set α) K : DirectedOn (fun x x_1 => x ⊆ x_1) S H : ∀ (s : Set α), s ∈ S → IsPreconnected s ⊢ IsPreconnected (⋃₀ S) [PROOFSTEP] rintro u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ : Set α S : Set (Set α) K : DirectedOn (fun x x_1 => x ⊆ x_1) S H : ∀ (s : Set α), s ∈ S → IsPreconnected s u v : Set α hu : IsOpen u hv : IsOpen v Huv : ⋃₀ S ⊆ u ∪ v a : α hau : a ∈ u s : Set α hsS : s ∈ S has : a ∈ s b : α hbv : b ∈ v t : Set α htS : t ∈ S hbt : b ∈ t ⊢ Set.Nonempty (⋃₀ S ∩ (u ∩ v)) [PROOFSTEP] obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ : Set α S : Set (Set α) K : DirectedOn (fun x x_1 => x ⊆ x_1) S H : ∀ (s : Set α), s ∈ S → IsPreconnected s u v : Set α hu : IsOpen u hv : IsOpen v Huv : ⋃₀ S ⊆ u ∪ v a : α hau : a ∈ u s : Set α hsS : s ∈ S has : a ∈ s b : α hbv : b ∈ v t : Set α htS : t ∈ S hbt : b ∈ t r : Set α hrS : r ∈ S hsr : s ⊆ r htr : t ⊆ r ⊢ Set.Nonempty (⋃₀ S ∩ (u ∩ v)) [PROOFSTEP] have Hnuv : (r ∩ (u ∩ v)).Nonempty := H _ hrS u v hu hv ((subset_sUnion_of_mem hrS).trans Huv) ⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ : Set α S : Set (Set α) K : DirectedOn (fun x x_1 => x ⊆ x_1) S H : ∀ (s : Set α), s ∈ S → IsPreconnected s u v : Set α hu : IsOpen u hv : IsOpen v Huv : ⋃₀ S ⊆ u ∪ v a : α hau : a ∈ u s : Set α hsS : s ∈ S has : a ∈ s b : α hbv : b ∈ v t : Set α htS : t ∈ S hbt : b ∈ t r : Set α hrS : r ∈ S hsr : s ⊆ r htr : t ⊆ r Hnuv : Set.Nonempty (r ∩ (u ∩ v)) ⊢ Set.Nonempty (⋃₀ S ∩ (u ∩ v)) [PROOFSTEP] have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) := inter_subset_inter_left _ (subset_sUnion_of_mem hrS) [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ : Set α S : Set (Set α) K : DirectedOn (fun x x_1 => x ⊆ x_1) S H : ∀ (s : Set α), s ∈ S → IsPreconnected s u v : Set α hu : IsOpen u hv : IsOpen v Huv : ⋃₀ S ⊆ u ∪ v a : α hau : a ∈ u s : Set α hsS : s ∈ S has : a ∈ s b : α hbv : b ∈ v t : Set α htS : t ∈ S hbt : b ∈ t r : Set α hrS : r ∈ S hsr : s ⊆ r htr : t ⊆ r Hnuv : Set.Nonempty (r ∩ (u ∩ v)) Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) ⊢ Set.Nonempty (⋃₀ S ∩ (u ∩ v)) [PROOFSTEP] exact Hnuv.mono Kruv [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j ⊢ IsPreconnected (⋃ (n : ι) (_ : n ∈ t), s n) [PROOFSTEP] let R := fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t ⊢ IsPreconnected (⋃ (n : ι) (_ : n ∈ t), s n) [PROOFSTEP] have P : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ j ∈ p, s j) := fun i hi j hj h => by induction h case refl => refine ⟨{ i }, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ rw [biUnion_singleton] exact H i hi case tail j k _ hjk ih => obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ rw [biUnion_insert] refine (H k hj).union' (hjk.1.mono ?_) hp rw [inter_comm] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j : ι hj : j ∈ t h : ReflTransGen R i j ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] induction h [GOAL] case refl α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j : ι hj : i ∈ t ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ i ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) case tail α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j b✝ c✝ : ι a✝¹ : ReflTransGen R i b✝ a✝ : R b✝ c✝ a_ih✝ : b✝ ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ b✝ ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : c✝ ∈ t ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ c✝ ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] case refl => refine ⟨{ i }, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ rw [biUnion_singleton] exact H i hi [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j : ι hj : i ∈ t ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ i ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] case refl => refine ⟨{ i }, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ rw [biUnion_singleton] exact H i hi [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j : ι hj : i ∈ t ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ i ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] refine ⟨{ i }, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j : ι hj : i ∈ t ⊢ IsPreconnected (⋃ (j : ι) (_ : j ∈ {i}), s j) [PROOFSTEP] rw [biUnion_singleton] [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j : ι hj : i ∈ t ⊢ IsPreconnected (s i) [PROOFSTEP] exact H i hi [GOAL] case tail α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j b✝ c✝ : ι a✝¹ : ReflTransGen R i b✝ a✝ : R b✝ c✝ a_ih✝ : b✝ ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ b✝ ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : c✝ ∈ t ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ c✝ ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] case tail j k _ hjk ih => obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ rw [biUnion_insert] refine (H k hj).union' (hjk.1.mono ?_) hp rw [inter_comm] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j✝ j k : ι a✝ : ReflTransGen R i j hjk : R j k ih : j ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : k ∈ t ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ k ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] case tail j k _ hjk ih => obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ rw [biUnion_insert] refine (H k hj).union' (hjk.1.mono ?_) hp rw [inter_comm] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j✝ j k : ι a✝ : ReflTransGen R i j hjk : R j k ih : j ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : k ∈ t ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ k ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j✝ j k : ι a✝ : ReflTransGen R i j hjk : R j k ih : j ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : k ∈ t p : Set ι hpt : p ⊆ t hip : i ∈ p hjp : j ∈ p hp : IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ ∃ p, p ⊆ t ∧ i ∈ p ∧ k ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) [PROOFSTEP] refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j✝ j k : ι a✝ : ReflTransGen R i j hjk : R j k ih : j ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : k ∈ t p : Set ι hpt : p ⊆ t hip : i ∈ p hjp : j ∈ p hp : IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ IsPreconnected (⋃ (j : ι) (_ : j ∈ insert k p), s j) [PROOFSTEP] rw [biUnion_insert] [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j✝ j k : ι a✝ : ReflTransGen R i j hjk : R j k ih : j ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : k ∈ t p : Set ι hpt : p ⊆ t hip : i ∈ p hjp : j ∈ p hp : IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ IsPreconnected (s k ∪ ⋃ (x : ι) (_ : x ∈ p), s x) [PROOFSTEP] refine (H k hj).union' (hjk.1.mono ?_) hp [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j✝ j k : ι a✝ : ReflTransGen R i j hjk : R j k ih : j ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : k ∈ t p : Set ι hpt : p ⊆ t hip : i ∈ p hjp : j ∈ p hp : IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ s j ∩ s k ⊆ s k ∩ ⋃ (x : ι) (_ : x ∈ p), s x [PROOFSTEP] rw [inter_comm] [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t i : ι hi : i ∈ t j✝ j k : ι a✝ : ReflTransGen R i j hjk : R j k ih : j ∈ t → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) hj : k ∈ t p : Set ι hpt : p ⊆ t hip : i ∈ p hjp : j ∈ p hp : IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ s k ∩ s j ⊆ s k ∩ ⋃ (x : ι) (_ : x ∈ p), s x [PROOFSTEP] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t P : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ IsPreconnected (⋃ (n : ι) (_ : n ∈ t), s n) [PROOFSTEP] refine' isPreconnected_of_forall_pair _ [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t P : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ ∀ (x : α), x ∈ ⋃ (n : ι) (_ : n ∈ t), s n → ∀ (y : α), y ∈ ⋃ (n : ι) (_ : n ∈ t), s n → ∃ t_1, t_1 ⊆ ⋃ (n : ι) (_ : n ∈ t), s n ∧ x ∈ t_1 ∧ y ∈ t_1 ∧ IsPreconnected t_1 [PROOFSTEP] intro x hx y hy [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t P : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) x : α hx : x ∈ ⋃ (n : ι) (_ : n ∈ t), s n y : α hy : y ∈ ⋃ (n : ι) (_ : n ∈ t), s n ⊢ ∃ t_1, t_1 ⊆ ⋃ (n : ι) (_ : n ∈ t), s n ∧ x ∈ t_1 ∧ y ∈ t_1 ∧ IsPreconnected t_1 [PROOFSTEP] obtain ⟨i : ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_iUnion₂.1 hx [GOAL] case intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t P : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) x : α hx : x ∈ ⋃ (n : ι) (_ : n ∈ t), s n y : α hy : y ∈ ⋃ (n : ι) (_ : n ∈ t), s n i : ι hi : i ∈ t hxi : x ∈ s i ⊢ ∃ t_1, t_1 ⊆ ⋃ (n : ι) (_ : n ∈ t), s n ∧ x ∈ t_1 ∧ y ∈ t_1 ∧ IsPreconnected t_1 [PROOFSTEP] obtain ⟨j : ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_iUnion₂.1 hy [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t P : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) x : α hx : x ∈ ⋃ (n : ι) (_ : n ∈ t), s n y : α hy : y ∈ ⋃ (n : ι) (_ : n ∈ t), s n i : ι hi : i ∈ t hxi : x ∈ s i j : ι hj : j ∈ t hyj : y ∈ s j ⊢ ∃ t_1, t_1 ⊆ ⋃ (n : ι) (_ : n ∈ t), s n ∧ x ∈ t_1 ∧ y ∈ t_1 ∧ IsPreconnected t_1 [PROOFSTEP] obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj) [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v : Set α ι : Type u_3 t : Set ι s : ι → Set α H : ∀ (i : ι), i ∈ t → IsPreconnected (s i) K : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j R : ι → ι → Prop := fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t P : ∀ (i : ι), i ∈ t → ∀ (j : ι), j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) x : α hx : x ∈ ⋃ (n : ι) (_ : n ∈ t), s n y : α hy : y ∈ ⋃ (n : ι) (_ : n ∈ t), s n i : ι hi : i ∈ t hxi : x ∈ s i j : ι hj : j ∈ t hyj : y ∈ s j p : Set ι hpt : p ⊆ t hip : i ∈ p hjp : j ∈ p hp : IsPreconnected (⋃ (j : ι) (_ : j ∈ p), s j) ⊢ ∃ t_1, t_1 ⊆ ⋃ (n : ι) (_ : n ∈ t), s n ∧ x ∈ t_1 ∧ y ∈ t_1 ∧ IsPreconnected t_1 [PROOFSTEP] exact ⟨⋃ j ∈ p, s j, biUnion_subset_biUnion_left hpt, mem_biUnion hip hxi, mem_biUnion hjp hyj, hp⟩ [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t u v : Set α ι : Type u_3 s : ι → Set α H : ∀ (i : ι), IsPreconnected (s i) K : ∀ (i j : ι), ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j)) i j ⊢ IsPreconnected (⋃ (n : ι), s n) [PROOFSTEP] rw [← biUnion_univ] [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t u v : Set α ι : Type u_3 s : ι → Set α H : ∀ (i : ι), IsPreconnected (s i) K : ∀ (i j : ι), ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j)) i j ⊢ IsPreconnected (⋃ (x : ι) (_ : x ∈ univ), s x) [PROOFSTEP] exact IsPreconnected.biUnion_of_reflTransGen (fun i _ => H i) fun i _ j _ => by simpa [mem_univ] using K i j [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s✝ t u v : Set α ι : Type u_3 s : ι → Set α H : ∀ (i : ι), IsPreconnected (s i) K : ∀ (i j : ι), ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j)) i j i : ι x✝¹ : i ∈ univ j : ι x✝ : j ∈ univ ⊢ ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ univ) i j [PROOFSTEP] simpa [mem_univ] using K i j [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α H : ∀ (n : β), IsPreconnected (s n) K : ∀ (n : β), Set.Nonempty (s n ∩ s (succ n)) i✝ j i : β x✝ : i ∈ Ico j i✝ ⊢ Set.Nonempty (s (succ i) ∩ s i) [PROOFSTEP] rw [inter_comm] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α H : ∀ (n : β), IsPreconnected (s n) K : ∀ (n : β), Set.Nonempty (s n ∩ s (succ n)) i✝ j i : β x✝ : i ∈ Ico j i✝ ⊢ Set.Nonempty (s i ∩ s (succ i)) [PROOFSTEP] exact K i [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝⁴ : TopologicalSpace α s✝ t u v : Set α inst✝³ : LinearOrder β inst✝² : SuccOrder β inst✝¹ : IsSuccArchimedean β inst✝ : Nonempty β s : β → Set α H : ∀ (n : β), IsConnected (s n) K : ∀ (n : β), Set.Nonempty (s n ∩ s (succ n)) i✝ j i : β x✝ : i ∈ Ico j i✝ ⊢ Set.Nonempty (s (succ i) ∩ s i) [PROOFSTEP] rw [inter_comm] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝⁴ : TopologicalSpace α s✝ t u v : Set α inst✝³ : LinearOrder β inst✝² : SuccOrder β inst✝¹ : IsSuccArchimedean β inst✝ : Nonempty β s : β → Set α H : ∀ (n : β), IsConnected (s n) K : ∀ (n : β), Set.Nonempty (s n ∩ s (succ n)) i✝ j i : β x✝ : i ∈ Ico j i✝ ⊢ Set.Nonempty (s i ∩ s (succ i)) [PROOFSTEP] exact K i [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t✝ u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α t : Set β ht : OrdConnected t H : ∀ (n : β), n ∈ t → IsPreconnected (s n) K : ∀ (n : β), n ∈ t → succ n ∈ t → Set.Nonempty (s n ∩ s (succ n)) ⊢ IsPreconnected (⋃ (n : β) (_ : n ∈ t), s n) [PROOFSTEP] have h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t := fun hi hj hk => ht.out hi hj (Ico_subset_Icc_self hk) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t✝ u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α t : Set β ht : OrdConnected t H : ∀ (n : β), n ∈ t → IsPreconnected (s n) K : ∀ (n : β), n ∈ t → succ n ∈ t → Set.Nonempty (s n ∩ s (succ n)) h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t ⊢ IsPreconnected (⋃ (n : β) (_ : n ∈ t), s n) [PROOFSTEP] have h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t := fun hi hj hk => ht.out hi hj ⟨hk.1.trans <| le_succ _, succ_le_of_lt hk.2⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t✝ u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α t : Set β ht : OrdConnected t H : ∀ (n : β), n ∈ t → IsPreconnected (s n) K : ∀ (n : β), n ∈ t → succ n ∈ t → Set.Nonempty (s n ∩ s (succ n)) h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t ⊢ IsPreconnected (⋃ (n : β) (_ : n ∈ t), s n) [PROOFSTEP] have h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → (s k ∩ s (succ k)).Nonempty := fun hi hj hk => K _ (h1 hi hj hk) (h2 hi hj hk) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t✝ u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α t : Set β ht : OrdConnected t H : ∀ (n : β), n ∈ t → IsPreconnected (s n) K : ∀ (n : β), n ∈ t → succ n ∈ t → Set.Nonempty (s n ∩ s (succ n)) h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → Set.Nonempty (s k ∩ s (succ k)) ⊢ IsPreconnected (⋃ (n : β) (_ : n ∈ t), s n) [PROOFSTEP] refine' IsPreconnected.biUnion_of_reflTransGen H fun i hi j hj => _ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t✝ u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α t : Set β ht : OrdConnected t H : ∀ (n : β), n ∈ t → IsPreconnected (s n) K : ∀ (n : β), n ∈ t → succ n ∈ t → Set.Nonempty (s n ∩ s (succ n)) h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → Set.Nonempty (s k ∩ s (succ k)) i : β hi : i ∈ t j : β hj : j ∈ t ⊢ ReflTransGen (fun i j => Set.Nonempty (s i ∩ s j) ∧ i ∈ t) i j [PROOFSTEP] exact reflTransGen_of_succ _ (fun k hk => ⟨h3 hi hj hk, h1 hi hj hk⟩) fun k hk => ⟨by rw [inter_comm]; exact h3 hj hi hk, h2 hj hi hk⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t✝ u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α t : Set β ht : OrdConnected t H : ∀ (n : β), n ∈ t → IsPreconnected (s n) K : ∀ (n : β), n ∈ t → succ n ∈ t → Set.Nonempty (s n ∩ s (succ n)) h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → Set.Nonempty (s k ∩ s (succ k)) i : β hi : i ∈ t j : β hj : j ∈ t k : β hk : k ∈ Ico j i ⊢ Set.Nonempty (s (succ k) ∩ s k) [PROOFSTEP] rw [inter_comm] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t✝ u v : Set α inst✝² : LinearOrder β inst✝¹ : SuccOrder β inst✝ : IsSuccArchimedean β s : β → Set α t : Set β ht : OrdConnected t H : ∀ (n : β), n ∈ t → IsPreconnected (s n) K : ∀ (n : β), n ∈ t → succ n ∈ t → Set.Nonempty (s n ∩ s (succ n)) h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → Set.Nonempty (s k ∩ s (succ k)) i : β hi : i ∈ t j : β hj : j ∈ t k : β hk : k ∈ Ico j i ⊢ Set.Nonempty (s k ∩ s (succ k)) [PROOFSTEP] exact h3 hj hi hk [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s ⊢ IsPreconnected (f '' s) [PROOFSTEP] rintro u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v huv : f '' s ⊆ u ∪ v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v ⊢ Set.Nonempty (f '' s ∩ (u ∩ v)) [PROOFSTEP] rcases continuousOn_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v huv : f '' s ⊆ u ∪ v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s ⊢ Set.Nonempty (f '' s ∩ (u ∩ v)) [PROOFSTEP] rcases continuousOn_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩ -- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'` [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v huv : f '' s ⊆ u ∪ v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s ⊢ Set.Nonempty (f '' s ∩ (u ∩ v)) [PROOFSTEP] replace huv : s ⊆ u' ∪ v' [GOAL] case huv α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v huv : f '' s ⊆ u ∪ v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s ⊢ s ⊆ u' ∪ v' [PROOFSTEP] rw [image_subset_iff, preimage_union] at huv [GOAL] case huv α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v huv : s ⊆ f ⁻¹' u ∪ f ⁻¹' v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s ⊢ s ⊆ u' ∪ v' [PROOFSTEP] replace huv := subset_inter huv Subset.rfl [GOAL] case huv α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ (f ⁻¹' u ∪ f ⁻¹' v) ∩ s ⊢ s ⊆ u' ∪ v' [PROOFSTEP] rw [inter_distrib_right, u'_eq, v'_eq, ← inter_distrib_right] at huv [GOAL] case huv α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ (u' ∪ v') ∩ s ⊢ s ⊆ u' ∪ v' [PROOFSTEP] exact (subset_inter_iff.1 huv).1 -- Now `s ⊆ u' ∪ v'`, so we can apply `‹IsPreconnected s›` [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' ⊢ Set.Nonempty (f '' s ∩ (u ∩ v)) [PROOFSTEP] obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).Nonempty := by refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ <;> rw [inter_comm] exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' ⊢ Set.Nonempty (s ∩ (u' ∩ v')) [PROOFSTEP] refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' ⊢ x ∈ s ∩ u' [PROOFSTEP] rw [inter_comm] [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' ⊢ y ∈ s ∩ v' [PROOFSTEP] rw [inter_comm] [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' ⊢ x ∈ u' ∩ s case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' ⊢ y ∈ v' ∩ s [PROOFSTEP] exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩] [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' z : α hz : z ∈ s ∩ (u' ∩ v') ⊢ Set.Nonempty (f '' s ∩ (u ∩ v)) [PROOFSTEP] rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc, inter_comm s, inter_comm s, ← u'_eq, ← v'_eq] at hz [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α H : IsPreconnected s f : α → β hf : ContinuousOn f s u v : Set β hu : IsOpen u hv : IsOpen v x : α xs : x ∈ s xu : f x ∈ u y : α ys : y ∈ s yv : f y ∈ v u' : Set α hu' : IsOpen u' u'_eq : f ⁻¹' u ∩ s = u' ∩ s v' : Set α hv' : IsOpen v' v'_eq : f ⁻¹' v ∩ s = v' ∩ s huv : s ⊆ u' ∪ v' z : α hz : z ∈ f ⁻¹' u ∩ s ∩ (f ⁻¹' v ∩ s) ⊢ Set.Nonempty (f '' s ∩ (u ∩ v)) [PROOFSTEP] exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α ⊢ IsPreconnected s → ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) [PROOFSTEP] rintro h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α h : IsPreconnected s t t' : Set α ht : IsClosed t ht' : IsClosed t' htt' : s ⊆ t ∪ t' x : α xs : x ∈ s xt : x ∈ t y : α ys : y ∈ s yt' : y ∈ t' ⊢ Set.Nonempty (s ∩ (t ∩ t')) [PROOFSTEP] rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α h : IsPreconnected s t t' : Set α ht : IsClosed t ht' : IsClosed t' htt' : s ⊆ t ∪ t' x : α xs : x ∈ s xt : x ∈ t y : α ys : y ∈ s yt' : y ∈ t' ⊢ ¬s ⊆ tᶜ ∪ t'ᶜ [PROOFSTEP] intro h' [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α h : IsPreconnected s t t' : Set α ht : IsClosed t ht' : IsClosed t' htt' : s ⊆ t ∪ t' x : α xs : x ∈ s xt : x ∈ t y : α ys : y ∈ s yt' : y ∈ t' h' : s ⊆ tᶜ ∪ t'ᶜ ⊢ False [PROOFSTEP] have xt' : x ∉ t' := (h' xs).resolve_left (absurd xt) [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α h : IsPreconnected s t t' : Set α ht : IsClosed t ht' : IsClosed t' htt' : s ⊆ t ∪ t' x : α xs : x ∈ s xt : x ∈ t y : α ys : y ∈ s yt' : y ∈ t' h' : s ⊆ tᶜ ∪ t'ᶜ xt' : ¬x ∈ t' ⊢ False [PROOFSTEP] have yt : y ∉ t := (h' ys).resolve_right (absurd yt') [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α h : IsPreconnected s t t' : Set α ht : IsClosed t ht' : IsClosed t' htt' : s ⊆ t ∪ t' x : α xs : x ∈ s xt : x ∈ t y : α ys : y ∈ s yt' : y ∈ t' h' : s ⊆ tᶜ ∪ t'ᶜ xt' : ¬x ∈ t' yt : ¬y ∈ t ⊢ False [PROOFSTEP] have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α h : IsPreconnected s t t' : Set α ht : IsClosed t ht' : IsClosed t' htt' : s ⊆ t ∪ t' x : α xs : x ∈ s xt : x ∈ t y : α ys : y ∈ s yt' : y ∈ t' h' : s ⊆ tᶜ ∪ t'ᶜ xt' : ¬x ∈ t' yt : ¬y ∈ t this : Set.Nonempty (s ∩ (tᶜ ∩ t'ᶜ)) ⊢ False [PROOFSTEP] rw [← compl_union] at this [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α h : IsPreconnected s t t' : Set α ht : IsClosed t ht' : IsClosed t' htt' : s ⊆ t ∪ t' x : α xs : x ∈ s xt : x ∈ t y : α ys : y ∈ s yt' : y ∈ t' h' : s ⊆ tᶜ ∪ t'ᶜ xt' : ¬x ∈ t' yt : ¬y ∈ t this : Set.Nonempty (s ∩ (t ∪ t')ᶜ) ⊢ False [PROOFSTEP] exact this.ne_empty htt'.disjoint_compl_right.inter_eq [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α ⊢ (∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t'))) → IsPreconnected s [PROOFSTEP] rintro h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsOpen u hv : IsOpen v huv : s ⊆ u ∪ v x : α xs : x ∈ s xu : x ∈ u y : α ys : y ∈ s yv : y ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsOpen u hv : IsOpen v huv : s ⊆ u ∪ v x : α xs : x ∈ s xu : x ∈ u y : α ys : y ∈ s yv : y ∈ v ⊢ ¬s ⊆ uᶜ ∪ vᶜ [PROOFSTEP] intro h' [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsOpen u hv : IsOpen v huv : s ⊆ u ∪ v x : α xs : x ∈ s xu : x ∈ u y : α ys : y ∈ s yv : y ∈ v h' : s ⊆ uᶜ ∪ vᶜ ⊢ False [PROOFSTEP] have xv : x ∉ v := (h' xs).elim (absurd xu) id [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsOpen u hv : IsOpen v huv : s ⊆ u ∪ v x : α xs : x ∈ s xu : x ∈ u y : α ys : y ∈ s yv : y ∈ v h' : s ⊆ uᶜ ∪ vᶜ xv : ¬x ∈ v ⊢ False [PROOFSTEP] have yu : y ∉ u := (h' ys).elim id (absurd yv) [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsOpen u hv : IsOpen v huv : s ⊆ u ∪ v x : α xs : x ∈ s xu : x ∈ u y : α ys : y ∈ s yv : y ∈ v h' : s ⊆ uᶜ ∪ vᶜ xv : ¬x ∈ v yu : ¬y ∈ u ⊢ False [PROOFSTEP] have := h _ _ hu.isClosed_compl hv.isClosed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsOpen u hv : IsOpen v huv : s ⊆ u ∪ v x : α xs : x ∈ s xu : x ∈ u y : α ys : y ∈ s yv : y ∈ v h' : s ⊆ uᶜ ∪ vᶜ xv : ¬x ∈ v yu : ¬y ∈ u this : Set.Nonempty (s ∩ (uᶜ ∩ vᶜ)) ⊢ False [PROOFSTEP] rw [← compl_union] at this [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsOpen u hv : IsOpen v huv : s ⊆ u ∪ v x : α xs : x ∈ s xu : x ∈ u y : α ys : y ∈ s yv : y ∈ v h' : s ⊆ uᶜ ∪ vᶜ xv : ¬x ∈ v yu : ¬y ∈ u this : Set.Nonempty (s ∩ (u ∪ v)ᶜ) ⊢ False [PROOFSTEP] exact this.ne_empty huv.disjoint_compl_right.inter_eq [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f ⊢ IsPreconnected (f '' s) ↔ IsPreconnected s [PROOFSTEP] refine' ⟨fun h => _, fun h => h.image _ hf.continuous.continuousOn⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f h : IsPreconnected (f '' s) ⊢ IsPreconnected s [PROOFSTEP] rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f h : IsPreconnected (f '' s) u v : Set α hu' : IsOpen u hv' : IsOpen v huv : s ⊆ u ∪ v x : α hxs : x ∈ s hxu : x ∈ u y : α hys : y ∈ s hyv : y ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases hf.isOpen_iff.1 hu' with ⟨u, hu, rfl⟩ [GOAL] case intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f h : IsPreconnected (f '' s) v : Set α hv' : IsOpen v x : α hxs : x ∈ s y : α hys : y ∈ s hyv : y ∈ v u : Set β hu : IsOpen u hu' : IsOpen (f ⁻¹' u) huv : s ⊆ f ⁻¹' u ∪ v hxu : x ∈ f ⁻¹' u ⊢ Set.Nonempty (s ∩ (f ⁻¹' u ∩ v)) [PROOFSTEP] rcases hf.isOpen_iff.1 hv' with ⟨v, hv, rfl⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f h : IsPreconnected (f '' s) x : α hxs : x ∈ s y : α hys : y ∈ s u : Set β hu : IsOpen u hu' : IsOpen (f ⁻¹' u) hxu : x ∈ f ⁻¹' u v : Set β hv : IsOpen v hv' : IsOpen (f ⁻¹' v) hyv : y ∈ f ⁻¹' v huv : s ⊆ f ⁻¹' u ∪ f ⁻¹' v ⊢ Set.Nonempty (s ∩ (f ⁻¹' u ∩ f ⁻¹' v)) [PROOFSTEP] replace huv : f '' s ⊆ u ∪ v [GOAL] case huv α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f h : IsPreconnected (f '' s) x : α hxs : x ∈ s y : α hys : y ∈ s u : Set β hu : IsOpen u hu' : IsOpen (f ⁻¹' u) hxu : x ∈ f ⁻¹' u v : Set β hv : IsOpen v hv' : IsOpen (f ⁻¹' v) hyv : y ∈ f ⁻¹' v huv : s ⊆ f ⁻¹' u ∪ f ⁻¹' v ⊢ f '' s ⊆ u ∪ v [PROOFSTEP] rwa [image_subset_iff] [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f h : IsPreconnected (f '' s) x : α hxs : x ∈ s y : α hys : y ∈ s u : Set β hu : IsOpen u hu' : IsOpen (f ⁻¹' u) hxu : x ∈ f ⁻¹' u v : Set β hv : IsOpen v hv' : IsOpen (f ⁻¹' v) hyv : y ∈ f ⁻¹' v huv : f '' s ⊆ u ∪ v ⊢ Set.Nonempty (s ∩ (f ⁻¹' u ∩ f ⁻¹' v)) [PROOFSTEP] rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩ with ⟨_, ⟨z, hzs, rfl⟩, hzuv⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set α f : α → β hf : Inducing f h : IsPreconnected (f '' s) x : α hxs : x ∈ s y : α hys : y ∈ s u : Set β hu : IsOpen u hu' : IsOpen (f ⁻¹' u) hxu : x ∈ f ⁻¹' u v : Set β hv : IsOpen v hv' : IsOpen (f ⁻¹' v) hyv : y ∈ f ⁻¹' v huv : f '' s ⊆ u ∪ v z : α hzs : z ∈ s hzuv : f z ∈ u ∩ v ⊢ Set.Nonempty (s ∩ (f ⁻¹' u ∩ f ⁻¹' v)) [PROOFSTEP] exact ⟨z, hzs, hzuv⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsOpenMap f hsf : s ⊆ range f u v : Set α hu : IsOpen u hv : IsOpen v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) ⊢ Set.Nonempty (f ⁻¹' s ∩ (u ∩ v)) [PROOFSTEP] replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsOpenMap f u v : Set α hu : IsOpen u hv : IsOpen v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (f ⁻¹' s ∩ (u ∩ v)) [PROOFSTEP] obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsOpenMap f u v : Set α hu : IsOpen u hv : IsOpen v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (s ∩ (f '' u ∩ f '' v)) [PROOFSTEP] refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsOpenMap f u v : Set α hu : IsOpen u hv : IsOpen v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ s ⊆ f '' u ∪ f '' v [PROOFSTEP] simpa only [hsf, image_union] using image_subset f hsuv [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsOpenMap f u v : Set α hu : IsOpen u hv : IsOpen v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (s ∩ f '' u) [PROOFSTEP] simpa only [image_preimage_inter] using hsu.image f [GOAL] case refine_3 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsOpenMap f u v : Set α hu : IsOpen u hv : IsOpen v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (s ∩ f '' v) [PROOFSTEP] simpa only [image_preimage_inter] using hsv.image f [GOAL] case intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsOpenMap f u v : Set α hu : IsOpen u hv : IsOpen v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s a : α hau : a ∈ u has : f a ∈ s hav : f a ∈ f '' v ⊢ Set.Nonempty (f ⁻¹' s ∩ (u ∩ v)) [PROOFSTEP] exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsClosedMap f hsf : s ⊆ range f u v : Set α hu : IsClosed u hv : IsClosed v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) ⊢ Set.Nonempty (f ⁻¹' s ∩ (u ∩ v)) [PROOFSTEP] replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsClosedMap f u v : Set α hu : IsClosed u hv : IsClosed v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (f ⁻¹' s ∩ (u ∩ v)) [PROOFSTEP] obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsClosedMap f u v : Set α hu : IsClosed u hv : IsClosed v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (s ∩ (f '' u ∩ f '' v)) [PROOFSTEP] refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsClosedMap f u v : Set α hu : IsClosed u hv : IsClosed v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ s ⊆ f '' u ∪ f '' v [PROOFSTEP] simpa only [hsf, image_union] using image_subset f hsuv [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsClosedMap f u v : Set α hu : IsClosed u hv : IsClosed v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (s ∩ f '' u) [PROOFSTEP] simpa only [image_preimage_inter] using hsu.image f [GOAL] case refine_3 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsClosedMap f u v : Set α hu : IsClosed u hv : IsClosed v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s ⊢ Set.Nonempty (s ∩ f '' v) [PROOFSTEP] simpa only [image_preimage_inter] using hsv.image f [GOAL] case intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : TopologicalSpace β s : Set β hs : IsPreconnected s f : α → β hinj : Injective f hf : IsClosedMap f u v : Set α hu : IsClosed u hv : IsClosed v hsuv : f ⁻¹' s ⊆ u ∪ v hsu : Set.Nonempty (f ⁻¹' s ∩ u) hsv : Set.Nonempty (f ⁻¹' s ∩ v) hsf : f '' (f ⁻¹' s) = s a : α hau : a ∈ u has : f a ∈ s hav : f a ∈ f '' v ⊢ Set.Nonempty (f ⁻¹' s ∩ (u ∩ v)) [PROOFSTEP] exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hs : IsPreconnected s ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] specialize hs u v hu hv hsuv [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hs : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hs : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) hsu : s ∩ u = ∅ ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv) [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hs : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) hsu : Set.Nonempty (s ∩ u) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] replace hs := mt (hs hsu) [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hs : ¬Set.Nonempty (s ∩ (u ∩ v)) → ¬Set.Nonempty (s ∩ v) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] simp_rw [Set.not_nonempty_iff_eq_empty, ← Set.disjoint_iff_inter_eq_empty, disjoint_iff_inter_eq_empty.1 huv] at hs [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hs : Disjoint s ∅ → Disjoint s v ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] exact Or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hs : IsPreconnected s ⊢ Disjoint s v [PROOFSTEP] by_contra hsv [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hs : IsPreconnected s hsv : ¬Disjoint s v ⊢ False [PROOFSTEP] rw [not_disjoint_iff_nonempty_inter] at hsv [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hs : IsPreconnected s hsv : Set.Nonempty (s ∩ v) ⊢ False [PROOFSTEP] obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv [GOAL] case intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hu : IsOpen u hv : IsOpen v huv : Disjoint u v hsuv : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hs : IsPreconnected s hsv : Set.Nonempty (s ∩ v) x : α left✝ : x ∈ s hx : x ∈ u ∩ v ⊢ False [PROOFSTEP] exact Set.disjoint_iff.1 huv hx [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s t : Set α hs : IsPreconnected s ht : IsClopen t hne : Set.Nonempty (s ∩ t) ⊢ s ⊆ t ∪ tᶜ [PROOFSTEP] simp [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u ⊢ s ⊆ u [PROOFSTEP] have A : s ⊆ u ∪ (closure u)ᶜ := by intro x hx by_cases xu : x ∈ u · exact Or.inl xu · right intro h'x exact xu (h (mem_inter h'x hx)) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u ⊢ s ⊆ u ∪ (closure u)ᶜ [PROOFSTEP] intro x hx [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u x : α hx : x ∈ s ⊢ x ∈ u ∪ (closure u)ᶜ [PROOFSTEP] by_cases xu : x ∈ u [GOAL] case pos α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u x : α hx : x ∈ s xu : x ∈ u ⊢ x ∈ u ∪ (closure u)ᶜ [PROOFSTEP] exact Or.inl xu [GOAL] case neg α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u x : α hx : x ∈ s xu : ¬x ∈ u ⊢ x ∈ u ∪ (closure u)ᶜ [PROOFSTEP] right [GOAL] case neg.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u x : α hx : x ∈ s xu : ¬x ∈ u ⊢ x ∈ (closure u)ᶜ [PROOFSTEP] intro h'x [GOAL] case neg.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u x : α hx : x ∈ s xu : ¬x ∈ u h'x : x ∈ closure u ⊢ False [PROOFSTEP] exact xu (h (mem_inter h'x hx)) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u A : s ⊆ u ∪ (closure u)ᶜ ⊢ s ⊆ u [PROOFSTEP] apply hs.subset_left_of_subset_union hu isClosed_closure.isOpen_compl _ A h'u [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α hs : IsPreconnected s hu : IsOpen u h'u : Set.Nonempty (s ∩ u) h : closure u ∩ s ⊆ u A : s ⊆ u ∪ (closure u)ᶜ ⊢ Disjoint u (closure u)ᶜ [PROOFSTEP] exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : TopologicalSpace β s : Set α t : Set β hs : IsPreconnected s ht : IsPreconnected t ⊢ IsPreconnected (s ×ˢ t) [PROOFSTEP] apply isPreconnected_of_forall_pair [GOAL] case H α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : TopologicalSpace β s : Set α t : Set β hs : IsPreconnected s ht : IsPreconnected t ⊢ ∀ (x : α × β), x ∈ s ×ˢ t → ∀ (y : α × β), y ∈ s ×ˢ t → ∃ t_1, t_1 ⊆ s ×ˢ t ∧ x ∈ t_1 ∧ y ∈ t_1 ∧ IsPreconnected t_1 [PROOFSTEP] rintro ⟨a₁, b₁⟩ ⟨ha₁, hb₁⟩ ⟨a₂, b₂⟩ ⟨ha₂, hb₂⟩ [GOAL] case H.mk.intro.mk.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : TopologicalSpace β s : Set α t : Set β hs : IsPreconnected s ht : IsPreconnected t a₁ : α b₁ : β ha₁ : (a₁, b₁).fst ∈ s hb₁ : (a₁, b₁).snd ∈ t a₂ : α b₂ : β ha₂ : (a₂, b₂).fst ∈ s hb₂ : (a₂, b₂).snd ∈ t ⊢ ∃ t_1, t_1 ⊆ s ×ˢ t ∧ (a₁, b₁) ∈ t_1 ∧ (a₂, b₂) ∈ t_1 ∧ IsPreconnected t_1 [PROOFSTEP] refine' ⟨Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s, _, .inl ⟨b₁, hb₁, rfl⟩, .inr ⟨a₂, ha₂, rfl⟩, _⟩ [GOAL] case H.mk.intro.mk.intro.refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : TopologicalSpace β s : Set α t : Set β hs : IsPreconnected s ht : IsPreconnected t a₁ : α b₁ : β ha₁ : (a₁, b₁).fst ∈ s hb₁ : (a₁, b₁).snd ∈ t a₂ : α b₂ : β ha₂ : (a₂, b₂).fst ∈ s hb₂ : (a₂, b₂).snd ∈ t ⊢ Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s ⊆ s ×ˢ t [PROOFSTEP] rintro _ (⟨y, hy, rfl⟩ | ⟨x, hx, rfl⟩) [GOAL] case H.mk.intro.mk.intro.refine'_1.inl.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : TopologicalSpace β s : Set α t : Set β hs : IsPreconnected s ht : IsPreconnected t a₁ : α b₁ : β ha₁ : (a₁, b₁).fst ∈ s hb₁ : (a₁, b₁).snd ∈ t a₂ : α b₂ : β ha₂ : (a₂, b₂).fst ∈ s hb₂ : (a₂, b₂).snd ∈ t y : β hy : y ∈ t ⊢ (a₁, y) ∈ s ×ˢ t case H.mk.intro.mk.intro.refine'_1.inr.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : TopologicalSpace β s : Set α t : Set β hs : IsPreconnected s ht : IsPreconnected t a₁ : α b₁ : β ha₁ : (a₁, b₁).fst ∈ s hb₁ : (a₁, b₁).snd ∈ t a₂ : α b₂ : β ha₂ : (a₂, b₂).fst ∈ s hb₂ : (a₂, b₂).snd ∈ t x : α hx : x ∈ s ⊢ flip Prod.mk b₂ x ∈ s ×ˢ t [PROOFSTEP] exacts [⟨ha₁, hy⟩, ⟨hx, hb₂⟩] [GOAL] case H.mk.intro.mk.intro.refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : TopologicalSpace β s : Set α t : Set β hs : IsPreconnected s ht : IsPreconnected t a₁ : α b₁ : β ha₁ : (a₁, b₁).fst ∈ s hb₁ : (a₁, b₁).snd ∈ t a₂ : α b₂ : β ha₂ : (a₂, b₂).fst ∈ s hb₂ : (a₂, b₂).snd ∈ t ⊢ IsPreconnected (Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s) [PROOFSTEP] exact (ht.image _ (Continuous.Prod.mk _).continuousOn).union (a₁, b₂) ⟨b₂, hb₂, rfl⟩ ⟨a₁, ha₁, rfl⟩ (hs.image _ (continuous_id.prod_mk continuous_const).continuousOn) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) ⊢ IsPreconnected (pi univ s) [PROOFSTEP] rintro u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩ [GOAL] case intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I : Finset ι hI : Finset.piecewise I f g ∈ u ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] induction' I using Finset.induction_on with i I _ ihI [GOAL] case intro.intro.intro.intro.intro.empty α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I : Finset ι hI✝ : Finset.piecewise I f g ∈ u hI : Finset.piecewise ∅ f g ∈ u ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] refine' ⟨g, hgs, ⟨_, hgv⟩⟩ [GOAL] case intro.intro.intro.intro.intro.empty α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I : Finset ι hI✝ : Finset.piecewise I f g ∈ u hI : Finset.piecewise ∅ f g ∈ u ⊢ g ∈ u [PROOFSTEP] simpa using hI [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : Finset.piecewise (insert i I) f g ∈ u ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] rw [Finset.piecewise_insert] at hI [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] have := I.piecewise_mem_set_pi hfs hgs [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] refine' (hsuv this).elim ihI fun h => _ [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] set S := update (I.piecewise f g) i '' s i [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] have hsub : S ⊆ pi univ s := by refine' image_subset_iff.2 fun z hz => _ rwa [update_preimage_univ_pi] exact fun j _ => this j trivial [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i ⊢ S ⊆ pi univ s [PROOFSTEP] refine' image_subset_iff.2 fun z hz => _ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i z : π i hz : z ∈ s i ⊢ z ∈ update (Finset.piecewise I f g) i ⁻¹' pi univ s [PROOFSTEP] rwa [update_preimage_univ_pi] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i z : π i hz : z ∈ s i ⊢ ∀ (j : ι), j ≠ i → Finset.piecewise I f g j ∈ s j [PROOFSTEP] exact fun j _ => this j trivial [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i hsub : S ⊆ pi univ s ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] have hconn : IsPreconnected S := (hs i).image _ (continuous_const.update i continuous_id).continuousOn [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i hsub : S ⊆ pi univ s hconn : IsPreconnected S ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] have hSu : (S ∩ u).Nonempty := ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩ [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i hsub : S ⊆ pi univ s hconn : IsPreconnected S hSu : Set.Nonempty (S ∩ u) ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] have hSv : (S ∩ v).Nonempty := ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩ [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i hsub : S ⊆ pi univ s hconn : IsPreconnected S hSu : Set.Nonempty (S ∩ u) hSv : Set.Nonempty (S ∩ v) ⊢ Set.Nonempty (pi univ s ∩ (u ∩ v)) [PROOFSTEP] refine' (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono _ [GOAL] case intro.intro.intro.intro.intro.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u✝ v✝ : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hs : ∀ (i : ι), IsPreconnected (s i) u v : Set ((i : ι) → π i) uo : IsOpen u vo : IsOpen v hsuv : pi univ s ⊆ u ∪ v f : (i : ι) → π i hfs : f ∈ pi univ s hfu : f ∈ u g : (i : ι) → π i hgs : g ∈ pi univ s hgv : g ∈ v I✝ : Finset ι hI✝ : Finset.piecewise I✝ f g ∈ u i : ι I : Finset ι a✝ : ¬i ∈ I ihI : Finset.piecewise I f g ∈ u → Set.Nonempty (pi univ s ∩ (u ∩ v)) hI : update (Finset.piecewise I f g) i (f i) ∈ u this : Finset.piecewise I f g ∈ pi univ s h : Finset.piecewise I f g ∈ v S : Set ((a : ι) → π a) := update (Finset.piecewise I f g) i '' s i hsub : S ⊆ pi univ s hconn : IsPreconnected S hSu : Set.Nonempty (S ∩ u) hSv : Set.Nonempty (S ∩ v) ⊢ S ∩ (u ∩ v) ⊆ pi univ s ∩ (u ∩ v) [PROOFSTEP] exact inter_subset_inter_left _ hsub [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) ⊢ IsConnected (pi univ s) ↔ ∀ (i : ι), IsConnected (s i) [PROOFSTEP] simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) ⊢ Set.Nonempty (pi univ s) → (IsPreconnected (pi univ s) ↔ ∀ (x : ι), IsPreconnected (s x)) [PROOFSTEP] refine' fun hne => ⟨fun hc i => _, isPreconnected_univ_pi⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hne : Set.Nonempty (pi univ s) hc : IsPreconnected (pi univ s) i : ι ⊢ IsPreconnected (s i) [PROOFSTEP] rw [← eval_image_univ_pi hne] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : (i : ι) → Set (π i) hne : Set.Nonempty (pi univ s) hc : IsPreconnected (pi univ s) i : ι ⊢ IsPreconnected ((fun f => f i) '' pi univ s) [PROOFSTEP] exact hc.image _ (continuous_apply _).continuousOn [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) ⊢ IsConnected s ↔ ∃ i t, IsConnected t ∧ s = mk i '' t [PROOFSTEP] refine' ⟨fun hs => _, _⟩ [GOAL] case refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) hs : IsConnected s ⊢ ∃ i t, IsConnected t ∧ s = mk i '' t [PROOFSTEP] obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty [GOAL] case refine'_1.intro.mk α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) hs : IsConnected s i : ι x : π i hx : { fst := i, snd := x } ∈ s ⊢ ∃ i t, IsConnected t ∧ s = mk i '' t [PROOFSTEP] have : s ⊆ range (Sigma.mk i) := hs.isPreconnected.subset_clopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩ [GOAL] case refine'_1.intro.mk α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) hs : IsConnected s i : ι x : π i hx : { fst := i, snd := x } ∈ s this : s ⊆ range (mk i) ⊢ ∃ i t, IsConnected t ∧ s = mk i '' t [PROOFSTEP] exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_openMap sigma_mk_injective isOpenMap_sigmaMk this, (Set.image_preimage_eq_of_subset this).symm⟩ [GOAL] case refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) ⊢ (∃ i t, IsConnected t ∧ s = mk i '' t) → IsConnected s [PROOFSTEP] rintro ⟨i, t, ht, rfl⟩ [GOAL] case refine'_2.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : (i : ι) → TopologicalSpace (π i) i : ι t : Set (π i) ht : IsConnected t ⊢ IsConnected (mk i '' t) [PROOFSTEP] exact ht.image _ continuous_sigmaMk.continuousOn [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α hι : Nonempty ι inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) ⊢ IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = mk i '' t [PROOFSTEP] refine' ⟨fun hs => _, _⟩ [GOAL] case refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α hι : Nonempty ι inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) hs : IsPreconnected s ⊢ ∃ i t, IsPreconnected t ∧ s = mk i '' t [PROOFSTEP] obtain rfl | h := s.eq_empty_or_nonempty [GOAL] case refine'_1.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α hι : Nonempty ι inst✝ : (i : ι) → TopologicalSpace (π i) hs : IsPreconnected ∅ ⊢ ∃ i t, IsPreconnected t ∧ ∅ = mk i '' t [PROOFSTEP] exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩ [GOAL] case refine'_1.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α hι : Nonempty ι inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) hs : IsPreconnected s h : Set.Nonempty s ⊢ ∃ i t, IsPreconnected t ∧ s = mk i '' t [PROOFSTEP] obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ [GOAL] case refine'_1.inr.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α hι : Nonempty ι inst✝ : (i : ι) → TopologicalSpace (π i) a : ι t : Set (π a) ht : IsConnected t hs : IsPreconnected (mk a '' t) h : Set.Nonempty (mk a '' t) ⊢ ∃ i t_1, IsPreconnected t_1 ∧ mk a '' t = mk i '' t_1 [PROOFSTEP] refine' ⟨a, t, ht.isPreconnected, rfl⟩ [GOAL] case refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α hι : Nonempty ι inst✝ : (i : ι) → TopologicalSpace (π i) s : Set ((i : ι) × π i) ⊢ (∃ i t, IsPreconnected t ∧ s = mk i '' t) → IsPreconnected s [PROOFSTEP] rintro ⟨a, t, ht, rfl⟩ [GOAL] case refine'_2.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α hι : Nonempty ι inst✝ : (i : ι) → TopologicalSpace (π i) a : ι t : Set (π a) ht : IsPreconnected t ⊢ IsPreconnected (mk a '' t) [PROOFSTEP] exact ht.image _ continuous_sigmaMk.continuousOn [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) ⊢ IsConnected s ↔ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t [PROOFSTEP] refine' ⟨fun hs => _, _⟩ [GOAL] case refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s ⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t [PROOFSTEP] obtain ⟨x | x, hx⟩ := hs.nonempty [GOAL] case refine'_1.intro.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : α hx : inl x ∈ s ⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t [PROOFSTEP] have h : s ⊆ range Sum.inl := hs.isPreconnected.subset_clopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩ [GOAL] case refine'_1.intro.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : α hx : inl x ∈ s h : s ⊆ range inl ⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t [PROOFSTEP] refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩ [GOAL] case refine'_1.intro.inl.refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : α hx : inl x ∈ s h : s ⊆ range inl ⊢ IsConnected (inl ⁻¹' s) [PROOFSTEP] exact hs.preimage_of_openMap Sum.inl_injective isOpenMap_inl h [GOAL] case refine'_1.intro.inl.refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : α hx : inl x ∈ s h : s ⊆ range inl ⊢ s = inl '' (inl ⁻¹' s) [PROOFSTEP] exact (image_preimage_eq_of_subset h).symm [GOAL] case refine'_1.intro.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : β hx : inr x ∈ s ⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t [PROOFSTEP] have h : s ⊆ range Sum.inr := hs.isPreconnected.subset_clopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩ [GOAL] case refine'_1.intro.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : β hx : inr x ∈ s h : s ⊆ range inr ⊢ (∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t [PROOFSTEP] refine' Or.inr ⟨Sum.inr ⁻¹' s, _, _⟩ [GOAL] case refine'_1.intro.inr.refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : β hx : inr x ∈ s h : s ⊆ range inr ⊢ IsConnected (inr ⁻¹' s) [PROOFSTEP] exact hs.preimage_of_openMap Sum.inr_injective isOpenMap_inr h [GOAL] case refine'_1.intro.inr.refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsConnected s x : β hx : inr x ∈ s h : s ⊆ range inr ⊢ s = inr '' (inr ⁻¹' s) [PROOFSTEP] exact (image_preimage_eq_of_subset h).symm [GOAL] case refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) ⊢ ((∃ t, IsConnected t ∧ s = inl '' t) ∨ ∃ t, IsConnected t ∧ s = inr '' t) → IsConnected s [PROOFSTEP] rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) [GOAL] case refine'_2.inl.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β t : Set α ht : IsConnected t ⊢ IsConnected (inl '' t) [PROOFSTEP] exact ht.image _ continuous_inl.continuousOn [GOAL] case refine'_2.inr.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β t : Set β ht : IsConnected t ⊢ IsConnected (inr '' t) [PROOFSTEP] exact ht.image _ continuous_inr.continuousOn [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) ⊢ IsPreconnected s ↔ (∃ t, IsPreconnected t ∧ s = inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = inr '' t [PROOFSTEP] refine' ⟨fun hs => _, _⟩ [GOAL] case refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsPreconnected s ⊢ (∃ t, IsPreconnected t ∧ s = inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = inr '' t [PROOFSTEP] obtain rfl | h := s.eq_empty_or_nonempty [GOAL] case refine'_1.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : TopologicalSpace β hs : IsPreconnected ∅ ⊢ (∃ t, IsPreconnected t ∧ ∅ = inl '' t) ∨ ∃ t, IsPreconnected t ∧ ∅ = inr '' t [PROOFSTEP] exact Or.inl ⟨∅, isPreconnected_empty, (Set.image_empty _).symm⟩ [GOAL] case refine'_1.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) hs : IsPreconnected s h : Set.Nonempty s ⊢ (∃ t, IsPreconnected t ∧ s = inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = inr '' t [PROOFSTEP] obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isConnected_iff.1 ⟨h, hs⟩ [GOAL] case refine'_1.inr.inl.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β t : Set α ht : IsConnected t hs : IsPreconnected (inl '' t) h : Set.Nonempty (inl '' t) ⊢ (∃ t_1, IsPreconnected t_1 ∧ inl '' t = inl '' t_1) ∨ ∃ t_1, IsPreconnected t_1 ∧ inl '' t = inr '' t_1 [PROOFSTEP] exact Or.inl ⟨t, ht.isPreconnected, rfl⟩ [GOAL] case refine'_1.inr.inr.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β t : Set β ht : IsConnected t hs : IsPreconnected (inr '' t) h : Set.Nonempty (inr '' t) ⊢ (∃ t_1, IsPreconnected t_1 ∧ inr '' t = inl '' t_1) ∨ ∃ t_1, IsPreconnected t_1 ∧ inr '' t = inr '' t_1 [PROOFSTEP] exact Or.inr ⟨t, ht.isPreconnected, rfl⟩ [GOAL] case refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : TopologicalSpace β s : Set (α ⊕ β) ⊢ ((∃ t, IsPreconnected t ∧ s = inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = inr '' t) → IsPreconnected s [PROOFSTEP] rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) [GOAL] case refine'_2.inl.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β t : Set α ht : IsPreconnected t ⊢ IsPreconnected (inl '' t) [PROOFSTEP] exact ht.image _ continuous_inl.continuousOn [GOAL] case refine'_2.inr.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β t : Set β ht : IsPreconnected t ⊢ IsPreconnected (inr '' t) [PROOFSTEP] exact ht.image _ continuous_inr.continuousOn [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hx : x ∈ F ⊢ x ∈ connectedComponentIn F x [PROOFSTEP] simp [connectedComponentIn_eq_image hx, mem_connectedComponent, hx] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α ⊢ Set.Nonempty (connectedComponentIn F x) ↔ x ∈ F [PROOFSTEP] rw [connectedComponentIn] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α ⊢ Set.Nonempty (if h : x ∈ F then Subtype.val '' connectedComponent { val := x, property := h } else ∅) ↔ x ∈ F [PROOFSTEP] split_ifs [GOAL] case pos α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α h✝ : x ∈ F ⊢ Set.Nonempty (Subtype.val '' connectedComponent { val := x, property := h✝ }) ↔ x ∈ F [PROOFSTEP] simp [connectedComponent_nonempty, *] [GOAL] case neg α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α h✝ : ¬x ∈ F ⊢ Set.Nonempty ∅ ↔ x ∈ F [PROOFSTEP] simp [connectedComponent_nonempty, *] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v F : Set α x : α ⊢ connectedComponentIn F x ⊆ F [PROOFSTEP] rw [connectedComponentIn] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v F : Set α x : α ⊢ (if h : x ∈ F then Subtype.val '' connectedComponent { val := x, property := h } else ∅) ⊆ F [PROOFSTEP] split_ifs [GOAL] case pos α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v F : Set α x : α h✝ : x ∈ F ⊢ Subtype.val '' connectedComponent { val := x, property := h✝ } ⊆ F [PROOFSTEP] simp [GOAL] case neg α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v F : Set α x : α h✝ : ¬x ∈ F ⊢ ∅ ⊆ F [PROOFSTEP] simp [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α ⊢ IsPreconnected (connectedComponentIn F x) [PROOFSTEP] rw [connectedComponentIn] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α ⊢ IsPreconnected (if h : x ∈ F then Subtype.val '' connectedComponent { val := x, property := h } else ∅) [PROOFSTEP] split_ifs [GOAL] case pos α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α h✝ : x ∈ F ⊢ IsPreconnected (Subtype.val '' connectedComponent { val := x, property := h✝ }) [PROOFSTEP] exact inducing_subtype_val.isPreconnected_image.mpr isPreconnected_connectedComponent [GOAL] case neg α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α h✝ : ¬x ∈ F ⊢ IsPreconnected ∅ [PROOFSTEP] exact isPreconnected_empty [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α ⊢ IsConnected (connectedComponentIn F x) ↔ x ∈ F [PROOFSTEP] simp_rw [← connectedComponentIn_nonempty_iff, IsConnected, isPreconnected_connectedComponentIn, and_true_iff] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F ⊢ s ⊆ connectedComponentIn F x [PROOFSTEP] have : IsPreconnected (((↑) : F → α) ⁻¹' s) := by refine' inducing_subtype_val.isPreconnected_image.mp _ rwa [Subtype.image_preimage_coe, inter_eq_left_iff_subset.mpr hsF] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F ⊢ IsPreconnected (Subtype.val ⁻¹' s) [PROOFSTEP] refine' inducing_subtype_val.isPreconnected_image.mp _ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F ⊢ IsPreconnected (Subtype.val '' (Subtype.val ⁻¹' s)) [PROOFSTEP] rwa [Subtype.image_preimage_coe, inter_eq_left_iff_subset.mpr hsF] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F this : IsPreconnected (Subtype.val ⁻¹' s) ⊢ s ⊆ connectedComponentIn F x [PROOFSTEP] have h2xs : (⟨x, hsF hxs⟩ : F) ∈ (↑) ⁻¹' s := by rw [mem_preimage] exact hxs [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F this : IsPreconnected (Subtype.val ⁻¹' s) ⊢ { val := x, property := (_ : x ∈ F) } ∈ Subtype.val ⁻¹' s [PROOFSTEP] rw [mem_preimage] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F this : IsPreconnected (Subtype.val ⁻¹' s) ⊢ ↑{ val := x, property := (_ : x ∈ F) } ∈ s [PROOFSTEP] exact hxs [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F this : IsPreconnected (Subtype.val ⁻¹' s) h2xs : { val := x, property := (_ : x ∈ F) } ∈ Subtype.val ⁻¹' s ⊢ s ⊆ connectedComponentIn F x [PROOFSTEP] have := this.subset_connectedComponent h2xs [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F this✝ : IsPreconnected (Subtype.val ⁻¹' s) h2xs : { val := x, property := (_ : x ∈ F) } ∈ Subtype.val ⁻¹' s this : Subtype.val ⁻¹' s ⊆ connectedComponent { val := x, property := (_ : x ∈ F) } ⊢ s ⊆ connectedComponentIn F x [PROOFSTEP] rw [connectedComponentIn_eq_image (hsF hxs)] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F this✝ : IsPreconnected (Subtype.val ⁻¹' s) h2xs : { val := x, property := (_ : x ∈ F) } ∈ Subtype.val ⁻¹' s this : Subtype.val ⁻¹' s ⊆ connectedComponent { val := x, property := (_ : x ∈ F) } ⊢ s ⊆ Subtype.val '' connectedComponent { val := x, property := (_ : x ∈ F) } [PROOFSTEP] refine' Subset.trans _ (image_subset _ this) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hs : IsPreconnected s hxs : x ∈ s hsF : s ⊆ F this✝ : IsPreconnected (Subtype.val ⁻¹' s) h2xs : { val := x, property := (_ : x ∈ F) } ∈ Subtype.val ⁻¹' s this : Subtype.val ⁻¹' s ⊆ connectedComponent { val := x, property := (_ : x ∈ F) } ⊢ s ⊆ Subtype.val '' (Subtype.val ⁻¹' s) [PROOFSTEP] rw [Subtype.image_preimage_coe, inter_eq_left_iff_subset.mpr hsF] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x y : α F : Set α h : y ∈ connectedComponentIn F x ⊢ connectedComponentIn F x = connectedComponentIn F y [PROOFSTEP] have hx : x ∈ F := connectedComponentIn_nonempty_iff.mp ⟨y, h⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x y : α F : Set α h : y ∈ connectedComponentIn F x hx : x ∈ F ⊢ connectedComponentIn F x = connectedComponentIn F y [PROOFSTEP] simp_rw [connectedComponentIn_eq_image hx] at h ⊢ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x y : α F : Set α hx : x ∈ F h : y ∈ Subtype.val '' connectedComponent { val := x, property := hx } ⊢ Subtype.val '' connectedComponent { val := x, property := hx } = connectedComponentIn F y [PROOFSTEP] obtain ⟨⟨y, hy⟩, h2y, rfl⟩ := h [GOAL] case intro.mk.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F : Set α hx : x ∈ F y : α hy : y ∈ F h2y : { val := y, property := hy } ∈ connectedComponent { val := x, property := hx } ⊢ Subtype.val '' connectedComponent { val := x, property := hx } = connectedComponentIn F ↑{ val := y, property := hy } [PROOFSTEP] simp_rw [connectedComponentIn_eq_image hy, connectedComponent_eq h2y] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F G : Set α h : F ⊆ G ⊢ connectedComponentIn F x ⊆ connectedComponentIn G x [PROOFSTEP] by_cases hx : x ∈ F [GOAL] case pos α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F G : Set α h : F ⊆ G hx : x ∈ F ⊢ connectedComponentIn F x ⊆ connectedComponentIn G x [PROOFSTEP] rw [connectedComponentIn_eq_image hx, connectedComponentIn_eq_image (h hx), ← show ((↑) : G → α) ∘ inclusion h = (↑) from rfl, image_comp] [GOAL] case pos α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F G : Set α h : F ⊆ G hx : x ∈ F ⊢ Subtype.val '' (inclusion h '' connectedComponent { val := x, property := hx }) ⊆ Subtype.val '' connectedComponent { val := x, property := (_ : x ∈ G) } [PROOFSTEP] exact image_subset _ ((continuous_inclusion h).image_connectedComponent_subset ⟨x, hx⟩) [GOAL] case neg α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F G : Set α h : F ⊆ G hx : ¬x ∈ F ⊢ connectedComponentIn F x ⊆ connectedComponentIn G x [PROOFSTEP] rw [connectedComponentIn_eq_empty hx] [GOAL] case neg α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α F G : Set α h : F ⊆ G hx : ¬x ∈ F ⊢ ∅ ⊆ connectedComponentIn G x [PROOFSTEP] exact Set.empty_subset _ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : TopologicalSpace β f : α → β hf : Surjective f hf' : Continuous f ⊢ ConnectedSpace β [PROOFSTEP] rw [connectedSpace_iff_univ, ← hf.range_eq] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : TopologicalSpace β f : α → β hf : Surjective f hf' : Continuous f ⊢ IsConnected (range f) [PROOFSTEP] exact isConnected_range hf' [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ ConnectedSpace α ↔ ∃ x, connectedComponent x = univ [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ ConnectedSpace α → ∃ x, connectedComponent x = univ [PROOFSTEP] rintro ⟨⟨x⟩⟩ [GOAL] case mp.mk.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α toPreconnectedSpace✝ : PreconnectedSpace α x : α ⊢ ∃ x, connectedComponent x = univ [PROOFSTEP] exact ⟨x, eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)⟩ [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∃ x, connectedComponent x = univ) → ConnectedSpace α [PROOFSTEP] rintro ⟨x, h⟩ [GOAL] case mpr.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α h : connectedComponent x = univ ⊢ ConnectedSpace α [PROOFSTEP] haveI : PreconnectedSpace α := ⟨by rw [← h]; exact isPreconnected_connectedComponent⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α h : connectedComponent x = univ ⊢ IsPreconnected univ [PROOFSTEP] rw [← h] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α h : connectedComponent x = univ ⊢ IsPreconnected (connectedComponent x) [PROOFSTEP] exact isPreconnected_connectedComponent [GOAL] case mpr.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α h : connectedComponent x = univ this : PreconnectedSpace α ⊢ ConnectedSpace α [PROOFSTEP] exact ⟨⟨x⟩⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ PreconnectedSpace α ↔ ∀ (x : α), connectedComponent x = univ [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ PreconnectedSpace α → ∀ (x : α), connectedComponent x = univ [PROOFSTEP] intro h x [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : PreconnectedSpace α x : α ⊢ connectedComponent x = univ [PROOFSTEP] exact eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x) [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α), connectedComponent x = univ) → PreconnectedSpace α [PROOFSTEP] intro h [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), connectedComponent x = univ ⊢ PreconnectedSpace α [PROOFSTEP] cases' isEmpty_or_nonempty α with hα hα [GOAL] case mpr.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), connectedComponent x = univ hα : IsEmpty α ⊢ PreconnectedSpace α [PROOFSTEP] exact ⟨by rw [univ_eq_empty_iff.mpr hα]; exact isPreconnected_empty⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), connectedComponent x = univ hα : IsEmpty α ⊢ IsPreconnected univ [PROOFSTEP] rw [univ_eq_empty_iff.mpr hα] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), connectedComponent x = univ hα : IsEmpty α ⊢ IsPreconnected ∅ [PROOFSTEP] exact isPreconnected_empty [GOAL] case mpr.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), connectedComponent x = univ hα : Nonempty α ⊢ PreconnectedSpace α [PROOFSTEP] exact ⟨by rw [← h (Classical.choice hα)]; exact isPreconnected_connectedComponent⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), connectedComponent x = univ hα : Nonempty α ⊢ IsPreconnected univ [PROOFSTEP] rw [← h (Classical.choice hα)] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), connectedComponent x = univ hα : Nonempty α ⊢ IsPreconnected (connectedComponent (Classical.choice hα)) [PROOFSTEP] exact isPreconnected_connectedComponent [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s t u v : Set α inst✝² : TopologicalSpace β inst✝¹ : PreconnectedSpace α inst✝ : PreconnectedSpace β ⊢ IsPreconnected univ [PROOFSTEP] rw [← univ_prod_univ] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s t u v : Set α inst✝² : TopologicalSpace β inst✝¹ : PreconnectedSpace α inst✝ : PreconnectedSpace β ⊢ IsPreconnected (univ ×ˢ univ) [PROOFSTEP] exact isPreconnected_univ.prod isPreconnected_univ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : (i : ι) → TopologicalSpace (π i) inst✝ : ∀ (i : ι), PreconnectedSpace (π i) ⊢ IsPreconnected univ [PROOFSTEP] rw [← pi_univ univ] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : (i : ι) → TopologicalSpace (π i) inst✝ : ∀ (i : ι), PreconnectedSpace (π i) ⊢ IsPreconnected (pi univ fun i => univ) [PROOFSTEP] exact isPreconnected_univ_pi fun i => isPreconnected_univ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : (i : ι) → TopologicalSpace (π i) f : α → (i : ι) × π i hf : Continuous f ⊢ ∃ i g, Continuous g ∧ f = Sigma.mk i ∘ g [PROOFSTEP] obtain ⟨i, hi⟩ : ∃ i, range f ⊆ range (.mk i) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : (i : ι) → TopologicalSpace (π i) f : α → (i : ι) × π i hf : Continuous f ⊢ ∃ i, range f ⊆ range (Sigma.mk i) [PROOFSTEP] rcases Sigma.isConnected_iff.1 (isConnected_range hf) with ⟨i, s, -, hs⟩ [GOAL] case intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : (i : ι) → TopologicalSpace (π i) f : α → (i : ι) × π i hf : Continuous f i : ι s : Set (π i) hs : range f = Sigma.mk i '' s ⊢ ∃ i, range f ⊆ range (Sigma.mk i) [PROOFSTEP] exact ⟨i, hs.trans_subset (image_subset_range _ _)⟩ [GOAL] case intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : (i : ι) → TopologicalSpace (π i) f : α → (i : ι) × π i hf : Continuous f i : ι hi : range f ⊆ range (Sigma.mk i) ⊢ ∃ i g, Continuous g ∧ f = Sigma.mk i ∘ g [PROOFSTEP] rcases range_subset_range_iff_exists_comp.1 hi with ⟨g, rfl⟩ [GOAL] case intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : (i : ι) → TopologicalSpace (π i) i : ι g : α → π i hf : Continuous (Sigma.mk i ∘ g) hi : range (Sigma.mk i ∘ g) ⊆ range (Sigma.mk i) ⊢ ∃ i_1 g_1, Continuous g_1 ∧ Sigma.mk i ∘ g = Sigma.mk i_1 ∘ g_1 [PROOFSTEP] refine ⟨i, g, ?_, rfl⟩ [GOAL] case intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : ConnectedSpace α inst✝ : (i : ι) → TopologicalSpace (π i) i : ι g : α → π i hf : Continuous (Sigma.mk i ∘ g) hi : range (Sigma.mk i ∘ g) ⊆ range (Sigma.mk i) ⊢ Continuous g [PROOFSTEP] rwa [← embedding_sigmaMk.continuous_iff] at hf [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t✝ u v : Set α inst✝ : PreconnectedSpace α s t : Set α ⊢ IsOpen s → IsOpen t → s ∪ t = univ → Set.Nonempty s → Set.Nonempty t → Set.Nonempty (s ∩ t) [PROOFSTEP] simpa only [univ_inter, univ_subset_iff] using @PreconnectedSpace.isPreconnected_univ α _ _ s t [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : Set α hs : IsClopen s h : ¬(s = ∅ ∨ s = univ) h2 : sᶜ = ∅ ⊢ s = univ [PROOFSTEP] rw [← compl_compl s, h2, compl_empty] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : Set α ⊢ s = ∅ ∨ s = univ → IsClopen s [PROOFSTEP] rintro (rfl | rfl) <;> [exact isClopen_empty; exact isClopen_univ] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : Set α ⊢ s = ∅ ∨ s = univ → IsClopen s [PROOFSTEP] rintro (rfl | rfl) [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : PreconnectedSpace α ⊢ IsClopen ∅ [PROOFSTEP] exact isClopen_empty [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : PreconnectedSpace α ⊢ IsClopen univ [PROOFSTEP] exact isClopen_univ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) ⊢ Subsingleton ι [PROOFSTEP] replace h_nonempty : ∀ i, s i ≠ ∅ := by intro i; rw [← nonempty_iff_ne_empty]; exact h_nonempty i [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) ⊢ ∀ (i : ι), s i ≠ ∅ [PROOFSTEP] intro i [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) i : ι ⊢ s i ≠ ∅ [PROOFSTEP] rw [← nonempty_iff_ne_empty] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) i : ι ⊢ Set.Nonempty (s i) [PROOFSTEP] exact h_nonempty i [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ ⊢ Subsingleton ι [PROOFSTEP] rw [← not_nontrivial_iff_subsingleton] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ ⊢ ¬Nontrivial ι [PROOFSTEP] by_contra contra [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ contra : Nontrivial ι ⊢ False [PROOFSTEP] obtain ⟨i, j, h_ne⟩ := contra [GOAL] case mk.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ i j : ι h_ne : i ≠ j ⊢ False [PROOFSTEP] replace h_ne : s i ∩ s j = ∅ := by simpa only [← bot_eq_empty, eq_bot_iff, ← inf_eq_inter, ← disjoint_iff_inf_le] using h_disj h_ne [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ i j : ι h_ne : i ≠ j ⊢ s i ∩ s j = ∅ [PROOFSTEP] simpa only [← bot_eq_empty, eq_bot_iff, ← inf_eq_inter, ← disjoint_iff_inf_le] using h_disj h_ne [GOAL] case mk.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ i j : ι h_ne : s i ∩ s j = ∅ ⊢ False [PROOFSTEP] cases' isClopen_iff.mp (h_clopen i) with hi hi [GOAL] case mk.intro.intro.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ i j : ι h_ne : s i ∩ s j = ∅ hi : s i = ∅ ⊢ False [PROOFSTEP] exact h_nonempty i hi [GOAL] case mk.intro.intro.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ i j : ι h_ne : s i ∩ s j = ∅ hi : s i = univ ⊢ False [PROOFSTEP] rw [hi, univ_inter] at h_ne [GOAL] case mk.intro.intro.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_disj : Pairwise (Disjoint on s) h_clopen : ∀ (i : ι), IsClopen (s i) h_nonempty : ∀ (i : ι), s i ≠ ∅ i j : ι h_ne : s j = ∅ hi : s i = univ ⊢ False [PROOFSTEP] exact h_nonempty j h_ne [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_open : ∀ (i : ι), IsOpen (s i) h_Union : ⋃ (i : ι), s i = univ ⊢ Subsingleton ι [PROOFSTEP] refine' subsingleton_of_disjoint_isClopen h_nonempty h_disj (fun i ↦ ⟨h_open i, _⟩) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_open : ∀ (i : ι), IsOpen (s i) h_Union : ⋃ (i : ι), s i = univ i : ι ⊢ IsClosed (s i) [PROOFSTEP] rw [← isOpen_compl_iff, compl_eq_univ_diff, ← h_Union, iUnion_diff] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_open : ∀ (i : ι), IsOpen (s i) h_Union : ⋃ (i : ι), s i = univ i : ι ⊢ IsOpen (⋃ (i_1 : ι), s i_1 \ s i) [PROOFSTEP] refine' isOpen_iUnion (fun j ↦ _) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_open : ∀ (i : ι), IsOpen (s i) h_Union : ⋃ (i : ι), s i = univ i j : ι ⊢ IsOpen (s j \ s i) [PROOFSTEP] rcases eq_or_ne i j with rfl | h_ne [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_open : ∀ (i : ι), IsOpen (s i) h_Union : ⋃ (i : ι), s i = univ i : ι ⊢ IsOpen (s i \ s i) [PROOFSTEP] simp [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) h_open : ∀ (i : ι), IsOpen (s i) h_Union : ⋃ (i : ι), s i = univ i j : ι h_ne : i ≠ j ⊢ IsOpen (s j \ s i) [PROOFSTEP] simpa only [(h_disj h_ne.symm).sdiff_eq_left] using h_open j [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) inst✝ : Finite ι h_closed : ∀ (i : ι), IsClosed (s i) h_Union : ⋃ (i : ι), s i = univ ⊢ Subsingleton ι [PROOFSTEP] refine' subsingleton_of_disjoint_isClopen h_nonempty h_disj (fun i ↦ ⟨_, h_closed i⟩) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) inst✝ : Finite ι h_closed : ∀ (i : ι), IsClosed (s i) h_Union : ⋃ (i : ι), s i = univ i : ι ⊢ IsOpen (s i) [PROOFSTEP] rw [← isClosed_compl_iff, compl_eq_univ_diff, ← h_Union, iUnion_diff] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) inst✝ : Finite ι h_closed : ∀ (i : ι), IsClosed (s i) h_Union : ⋃ (i : ι), s i = univ i : ι ⊢ IsClosed (⋃ (i_1 : ι), s i_1 \ s i) [PROOFSTEP] refine' isClosed_iUnion (fun j ↦ _) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) inst✝ : Finite ι h_closed : ∀ (i : ι), IsClosed (s i) h_Union : ⋃ (i : ι), s i = univ i j : ι ⊢ IsClosed (s j \ s i) [PROOFSTEP] rcases eq_or_ne i j with rfl | h_ne [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) inst✝ : Finite ι h_closed : ∀ (i : ι), IsClosed (s i) h_Union : ⋃ (i : ι), s i = univ i : ι ⊢ IsClosed (s i \ s i) [PROOFSTEP] simp [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : PreconnectedSpace α s : ι → Set α h_nonempty : ∀ (i : ι), Set.Nonempty (s i) h_disj : Pairwise (Disjoint on s) inst✝ : Finite ι h_closed : ∀ (i : ι), IsClosed (s i) h_Union : ⋃ (i : ι), s i = univ i j : ι h_ne : i ≠ j ⊢ IsClosed (s j \ s i) [PROOFSTEP] simpa only [(h_disj h_ne.symm).sdiff_eq_left] using h_closed j [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : PreconnectedSpace α s : Set α ⊢ Set.Nonempty (frontier s) ↔ Set.Nonempty s ∧ s ≠ univ [PROOFSTEP] simp only [nonempty_iff_ne_empty, Ne.def, frontier_eq_empty_iff, not_or] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α h : IsPreconnected s ⊢ IsPreconnected univ [PROOFSTEP] rwa [← inducing_subtype_val.isPreconnected_image, image_univ, Subtype.range_val] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α h : PreconnectedSpace ↑s ⊢ IsPreconnected s [PROOFSTEP] simpa using isPreconnected_univ.image ((↑) : s → α) continuous_subtype_val.continuousOn [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α ⊢ P x y [PROOFSTEP] let u := {z | P x z} [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} ⊢ P x y [PROOFSTEP] have A : IsOpen u := by apply isOpen_iff_mem_nhds.2 (fun z hz ↦ ?_) filter_upwards [h z] with t ht exact h' hz ht.1 [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} ⊢ IsOpen u [PROOFSTEP] apply isOpen_iff_mem_nhds.2 (fun z hz ↦ ?_) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} z : α hz : z ∈ u ⊢ u ∈ 𝓝 z [PROOFSTEP] filter_upwards [h z] with t ht [GOAL] case h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} z : α hz : z ∈ u t : α ht : P z t ∧ P t z ⊢ P x t [PROOFSTEP] exact h' hz ht.1 [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u ⊢ P x y [PROOFSTEP] have B : IsClosed u := by apply isClosed_iff_nhds.2 (fun z hz ↦ ?_) rcases hz _ (h z) with ⟨t, ht, h't⟩ exact h' h't ht.2 [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u ⊢ IsClosed u [PROOFSTEP] apply isClosed_iff_nhds.2 (fun z hz ↦ ?_) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u z : α hz : ∀ (U : Set α), U ∈ 𝓝 z → Set.Nonempty (U ∩ u) ⊢ z ∈ u [PROOFSTEP] rcases hz _ (h z) with ⟨t, ht, h't⟩ [GOAL] case intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u z : α hz : ∀ (U : Set α), U ∈ 𝓝 z → Set.Nonempty (U ∩ u) t : α ht : t ∈ {x | (fun y => P z y ∧ P y z) x} h't : t ∈ u ⊢ z ∈ u [PROOFSTEP] exact h' h't ht.2 [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u B : IsClosed u ⊢ P x y [PROOFSTEP] have C : u.Nonempty := ⟨x, (mem_of_mem_nhds (h x)).1⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u B : IsClosed u C : Set.Nonempty u ⊢ P x y [PROOFSTEP] have D : u = Set.univ := IsClopen.eq_univ ⟨A, B⟩ C [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u B : IsClosed u C : Set.Nonempty u D : u = univ ⊢ P x y [PROOFSTEP] show y ∈ u [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u✝ v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y ∧ P y x h' : Transitive P x y : α u : Set α := {z | P x z} A : IsOpen u B : IsClosed u C : Set.Nonempty u D : u = univ ⊢ y ∈ u [PROOFSTEP] simp [D] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y h' : Transitive P h'' : Symmetric P x y : α ⊢ P x y [PROOFSTEP] refine PreconnectedSpace.induction₂' P (fun z ↦ ?_) h' x y [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y h' : Transitive P h'' : Symmetric P x y z : α ⊢ ∀ᶠ (y : α) in 𝓝 z, P z y ∧ P y z [PROOFSTEP] filter_upwards [h z] with a ha [GOAL] case h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : PreconnectedSpace α P : α → α → Prop h : ∀ (x : α), ∀ᶠ (y : α) in 𝓝 x, P x y h' : Transitive P h'' : Symmetric P x y z a : α ha : P z a ⊢ P z a ∧ P a z [PROOFSTEP] refine ⟨ha, h'' ha⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x y : α hx : x ∈ s hy : y ∈ s ⊢ P x y [PROOFSTEP] let Q : s → s → Prop := fun a b ↦ P a b [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x y : α hx : x ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b ⊢ P x y [PROOFSTEP] show Q ⟨x, hx⟩ ⟨y, hy⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x y : α hx : x ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b ⊢ Q { val := x, property := hx } { val := y, property := hy } [PROOFSTEP] have : PreconnectedSpace s := Subtype.preconnectedSpace hs [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x y : α hx : x ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b this : PreconnectedSpace ↑s ⊢ Q { val := x, property := hx } { val := y, property := hy } [PROOFSTEP] apply PreconnectedSpace.induction₂' [GOAL] case h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x y : α hx : x ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b this : PreconnectedSpace ↑s ⊢ ∀ (x : { x // x ∈ s }), ∀ᶠ (y : { x // x ∈ s }) in 𝓝 x, Q x y ∧ Q y x [PROOFSTEP] rintro ⟨x, hx⟩ [GOAL] case h.mk α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x✝ y : α hx✝ : x✝ ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b this : PreconnectedSpace ↑s x : α hx : x ∈ s ⊢ ∀ᶠ (y : { x // x ∈ s }) in 𝓝 { val := x, property := hx }, Q { val := x, property := hx } y ∧ Q y { val := x, property := hx } [PROOFSTEP] have Z := h x hx [GOAL] case h.mk α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x✝ y : α hx✝ : x✝ ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b this : PreconnectedSpace ↑s x : α hx : x ∈ s Z : ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x ⊢ ∀ᶠ (y : { x // x ∈ s }) in 𝓝 { val := x, property := hx }, Q { val := x, property := hx } y ∧ Q y { val := x, property := hx } [PROOFSTEP] rwa [nhdsWithin_eq_map_subtype_coe] at Z [GOAL] case h' α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x y : α hx : x ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b this : PreconnectedSpace ↑s ⊢ Transitive Q [PROOFSTEP] rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩ hab hbc [GOAL] case h'.mk.mk.mk α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y ∧ P y x h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z x y : α hx : x ∈ s hy : y ∈ s Q : ↑s → ↑s → Prop := fun a b => P ↑a ↑b this : PreconnectedSpace ↑s a : α ha : a ∈ s b : α hb : b ∈ s c : α hc : c ∈ s hab : Q { val := a, property := ha } { val := b, property := hb } hbc : Q { val := b, property := hb } { val := c, property := hc } ⊢ Q { val := a, property := ha } { val := c, property := hc } [PROOFSTEP] exact h' a b c ha hb hc hab hbc [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z h'' : ∀ (x y : α), x ∈ s → y ∈ s → P x y → P y x x y : α hx : x ∈ s hy : y ∈ s ⊢ P x y [PROOFSTEP] apply hs.induction₂' P (fun z hz ↦ ?_) h' hx hy [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z h'' : ∀ (x y : α), x ∈ s → y ∈ s → P x y → P y x x y : α hx : x ∈ s hy : y ∈ s z : α hz : z ∈ s ⊢ ∀ᶠ (y : α) in 𝓝[s] z, P z y ∧ P y z [PROOFSTEP] filter_upwards [h z hz, self_mem_nhdsWithin] with a ha h'a [GOAL] case h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsPreconnected s P : α → α → Prop h : ∀ (x : α), x ∈ s → ∀ᶠ (y : α) in 𝓝[s] x, P x y h' : ∀ (x y z : α), x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z h'' : ∀ (x y : α), x ∈ s → y ∈ s → P x y → P y x x y : α hx : x ∈ s hy : y ∈ s z : α hz : z ∈ s a : α ha : P z a h'a : a ∈ s ⊢ P z a ∧ P a z [PROOFSTEP] exact ⟨ha, h'' z a hz h'a ha⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α ⊢ IsPreconnected s ↔ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α ⊢ IsPreconnected s → ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v [PROOFSTEP] intro h [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α ⊢ (∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v) → IsPreconnected s [PROOFSTEP] intro h [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α h : IsPreconnected s ⊢ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v [PROOFSTEP] intro u v hu hv hs huv [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : IsPreconnected s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] specialize h u v hu hv hs [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] contrapose! huv [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) huv : ¬s ⊆ u ∧ ¬s ⊆ v ⊢ s ∩ (u ∩ v) ≠ ∅ [PROOFSTEP] rw [← nonempty_iff_ne_empty] [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) huv : ¬s ⊆ u ∧ ¬s ⊆ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] simp [not_subset] at huv [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) huv : (∃ a, a ∈ s ∧ ¬a ∈ u) ∧ ∃ a, a ∈ s ∧ ¬a ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩ [GOAL] case mp.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) x : α hxs : x ∈ s hxu : ¬x ∈ u y : α hys : y ∈ s hyv : ¬y ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu [GOAL] case mp.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) x : α hxs : x ∈ s hxu : ¬x ∈ u y : α hys : y ∈ s hyv : ¬y ∈ v hxv : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv [GOAL] case mp.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) x : α hxs : x ∈ s hxu : ¬x ∈ u y : α hys : y ∈ s hyv : ¬y ∈ v hxv : x ∈ v hyu : y ∈ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v ⊢ IsPreconnected s [PROOFSTEP] intro u v hu hv hs hsu hsv [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rw [nonempty_iff_ne_empty] [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) ⊢ s ∩ (u ∩ v) ≠ ∅ [PROOFSTEP] intro H [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : s ∩ (u ∩ v) = ∅ ⊢ False [PROOFSTEP] specialize h u v hu hv hs H [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : s ∩ (u ∩ v) = ∅ h : s ⊆ u ∨ s ⊆ v ⊢ False [PROOFSTEP] contrapose H [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) h : s ⊆ u ∨ s ⊆ v H : ¬False ⊢ ¬s ∩ (u ∩ v) = ∅ [PROOFSTEP] apply Nonempty.ne_empty [GOAL] case mpr.a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) h : s ⊆ u ∨ s ⊆ v H : ¬False ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] cases' h with h h [GOAL] case mpr.a.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : ¬False h : s ⊆ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases hsv with ⟨x, hxs, hxv⟩ [GOAL] case mpr.a.inl.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) H : ¬False h : s ⊆ u x : α hxs : x ∈ s hxv : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ [GOAL] case mpr.a.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : ¬False h : s ⊆ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases hsu with ⟨x, hxs, hxu⟩ [GOAL] case mpr.a.inr.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsv : Set.Nonempty (s ∩ v) H : ¬False h : s ⊆ v x : α hxs : x ∈ s hxu : x ∈ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α ⊢ IsConnected s ↔ ∀ (U : Finset (Set α)), (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u [PROOFSTEP] rw [IsConnected, isPreconnected_iff_subset_of_disjoint] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α ⊢ (Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v) ↔ ∀ (U : Finset (Set α)), (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u [PROOFSTEP] refine ⟨fun ⟨hne, h⟩ U hU hUo hsU => ?_, fun h => ⟨?_, fun u v hu hv hs hsuv => ?_⟩⟩ [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v U : Finset (Set α) hU : ∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v hUo : ∀ (u : Set α), u ∈ U → IsOpen u hsU : s ⊆ ⋃₀ ↑U hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v ⊢ ∃ u, u ∈ U ∧ s ⊆ u [PROOFSTEP] induction U using Finset.induction_on [GOAL] case refine_1.empty α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hU : ∀ (u v : Set α), u ∈ ∅ → v ∈ ∅ → Set.Nonempty (s ∩ (u ∩ v)) → u = v hUo : ∀ (u : Set α), u ∈ ∅ → IsOpen u hsU : s ⊆ ⋃₀ ↑∅ ⊢ ∃ u, u ∈ ∅ ∧ s ⊆ u case refine_1.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝¹ t u v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v a✝² : Set α s✝ : Finset (Set α) a✝¹ : ¬a✝² ∈ s✝ a✝ : (∀ (u v : Set α), u ∈ s✝ → v ∈ s✝ → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ s✝ → IsOpen u) → s ⊆ ⋃₀ ↑s✝ → ∃ u, u ∈ s✝ ∧ s ⊆ u hU : ∀ (u v : Set α), u ∈ insert a✝² s✝ → v ∈ insert a✝² s✝ → Set.Nonempty (s ∩ (u ∩ v)) → u = v hUo : ∀ (u : Set α), u ∈ insert a✝² s✝ → IsOpen u hsU : s ⊆ ⋃₀ ↑(insert a✝² s✝) ⊢ ∃ u, u ∈ insert a✝² s✝ ∧ s ⊆ u [PROOFSTEP] case empty => exact absurd (by simpa using hsU) hne.not_subset_empty [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hU : ∀ (u v : Set α), u ∈ ∅ → v ∈ ∅ → Set.Nonempty (s ∩ (u ∩ v)) → u = v hUo : ∀ (u : Set α), u ∈ ∅ → IsOpen u hsU : s ⊆ ⋃₀ ↑∅ ⊢ ∃ u, u ∈ ∅ ∧ s ⊆ u [PROOFSTEP] case empty => exact absurd (by simpa using hsU) hne.not_subset_empty [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hU : ∀ (u v : Set α), u ∈ ∅ → v ∈ ∅ → Set.Nonempty (s ∩ (u ∩ v)) → u = v hUo : ∀ (u : Set α), u ∈ ∅ → IsOpen u hsU : s ⊆ ⋃₀ ↑∅ ⊢ ∃ u, u ∈ ∅ ∧ s ⊆ u [PROOFSTEP] exact absurd (by simpa using hsU) hne.not_subset_empty [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hU : ∀ (u v : Set α), u ∈ ∅ → v ∈ ∅ → Set.Nonempty (s ∩ (u ∩ v)) → u = v hUo : ∀ (u : Set α), u ∈ ∅ → IsOpen u hsU : s ⊆ ⋃₀ ↑∅ ⊢ s ⊆ ∅ [PROOFSTEP] simpa using hsU [GOAL] case refine_1.insert α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝¹ t u v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v a✝² : Set α s✝ : Finset (Set α) a✝¹ : ¬a✝² ∈ s✝ a✝ : (∀ (u v : Set α), u ∈ s✝ → v ∈ s✝ → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ s✝ → IsOpen u) → s ⊆ ⋃₀ ↑s✝ → ∃ u, u ∈ s✝ ∧ s ⊆ u hU : ∀ (u v : Set α), u ∈ insert a✝² s✝ → v ∈ insert a✝² s✝ → Set.Nonempty (s ∩ (u ∩ v)) → u = v hUo : ∀ (u : Set α), u ∈ insert a✝² s✝ → IsOpen u hsU : s ⊆ ⋃₀ ↑(insert a✝² s✝) ⊢ ∃ u, u ∈ insert a✝² s✝ ∧ s ⊆ u [PROOFSTEP] case insert u U uU IH => simp only [← ball_cond_comm, Finset.forall_mem_insert, Finset.exists_mem_insert, Finset.coe_insert, sUnion_insert, implies_true, true_and] at * refine (h _ hUo.1 (⋃₀ ↑U) (isOpen_sUnion hUo.2) hsU ?_).imp_right ?_ · refine subset_empty_iff.1 fun x ⟨hxs, hxu, v, hvU, hxv⟩ => ?_ exact ne_of_mem_of_not_mem hvU uU (hU.1 v hvU ⟨x, hxs, hxu, hxv⟩).symm · exact IH (fun u hu => (hU.2 u hu).2) hUo.2 [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u : Set α U : Finset (Set α) uU : ¬u ∈ U IH : (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u hU : ∀ (u_1 v : Set α), u_1 ∈ insert u U → v ∈ insert u U → Set.Nonempty (s ∩ (u_1 ∩ v)) → u_1 = v hUo : ∀ (u_1 : Set α), u_1 ∈ insert u U → IsOpen u_1 hsU : s ⊆ ⋃₀ ↑(insert u U) ⊢ ∃ u_1, u_1 ∈ insert u U ∧ s ⊆ u_1 [PROOFSTEP] case insert u U uU IH => simp only [← ball_cond_comm, Finset.forall_mem_insert, Finset.exists_mem_insert, Finset.coe_insert, sUnion_insert, implies_true, true_and] at * refine (h _ hUo.1 (⋃₀ ↑U) (isOpen_sUnion hUo.2) hsU ?_).imp_right ?_ · refine subset_empty_iff.1 fun x ⟨hxs, hxu, v, hvU, hxv⟩ => ?_ exact ne_of_mem_of_not_mem hvU uU (hU.1 v hvU ⟨x, hxs, hxu, hxv⟩).symm · exact IH (fun u hu => (hU.2 u hu).2) hUo.2 [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v s : Set α x✝ : Set.Nonempty s ∧ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v hne : Set.Nonempty s h : ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u : Set α U : Finset (Set α) uU : ¬u ∈ U IH : (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u hU : ∀ (u_1 v : Set α), u_1 ∈ insert u U → v ∈ insert u U → Set.Nonempty (s ∩ (u_1 ∩ v)) → u_1 = v hUo : ∀ (u_1 : Set α), u_1 ∈ insert u U → IsOpen u_1 hsU : s ⊆ ⋃₀ ↑(insert u U) ⊢ ∃ u_1, u_1 ∈ insert u U ∧ s ⊆ u_1 [PROOFSTEP] simp only [← ball_cond_comm, Finset.forall_mem_insert, Finset.exists_mem_insert, Finset.coe_insert, sUnion_insert, implies_true, true_and] at * [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v s : Set α hne : Set.Nonempty s u : Set α U : Finset (Set α) uU : ¬u ∈ U x✝ : Set.Nonempty s ∧ ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b h : ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b IH : (∀ (a : Set α), a ∈ U → ∀ (b : Set α), b ∈ U → Set.Nonempty (s ∩ (a ∩ b)) → a = b) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u hU : (∀ (x : Set α), x ∈ U → Set.Nonempty (s ∩ (u ∩ x)) → u = x) ∧ ∀ (x : Set α), x ∈ U → (Set.Nonempty (s ∩ (x ∩ u)) → x = u) ∧ ∀ (x_1 : Set α), x_1 ∈ U → Set.Nonempty (s ∩ (x ∩ x_1)) → x = x_1 hUo : IsOpen u ∧ ∀ (x : Set α), x ∈ U → IsOpen x hsU : s ⊆ u ∪ ⋃₀ ↑U ⊢ s ⊆ u ∨ ∃ x, x ∈ U ∧ s ⊆ x [PROOFSTEP] refine (h _ hUo.1 (⋃₀ ↑U) (isOpen_sUnion hUo.2) hsU ?_).imp_right ?_ [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v s : Set α hne : Set.Nonempty s u : Set α U : Finset (Set α) uU : ¬u ∈ U x✝ : Set.Nonempty s ∧ ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b h : ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b IH : (∀ (a : Set α), a ∈ U → ∀ (b : Set α), b ∈ U → Set.Nonempty (s ∩ (a ∩ b)) → a = b) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u hU : (∀ (x : Set α), x ∈ U → Set.Nonempty (s ∩ (u ∩ x)) → u = x) ∧ ∀ (x : Set α), x ∈ U → (Set.Nonempty (s ∩ (x ∩ u)) → x = u) ∧ ∀ (x_1 : Set α), x_1 ∈ U → Set.Nonempty (s ∩ (x ∩ x_1)) → x = x_1 hUo : IsOpen u ∧ ∀ (x : Set α), x ∈ U → IsOpen x hsU : s ⊆ u ∪ ⋃₀ ↑U ⊢ s ∩ (u ∩ ⋃₀ ↑U) = ∅ [PROOFSTEP] refine subset_empty_iff.1 fun x ⟨hxs, hxu, v, hvU, hxv⟩ => ?_ [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hne : Set.Nonempty s u : Set α U : Finset (Set α) uU : ¬u ∈ U x✝¹ : Set.Nonempty s ∧ ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b h : ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b IH : (∀ (a : Set α), a ∈ U → ∀ (b : Set α), b ∈ U → Set.Nonempty (s ∩ (a ∩ b)) → a = b) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u hU : (∀ (x : Set α), x ∈ U → Set.Nonempty (s ∩ (u ∩ x)) → u = x) ∧ ∀ (x : Set α), x ∈ U → (Set.Nonempty (s ∩ (x ∩ u)) → x = u) ∧ ∀ (x_1 : Set α), x_1 ∈ U → Set.Nonempty (s ∩ (x ∩ x_1)) → x = x_1 hUo : IsOpen u ∧ ∀ (x : Set α), x ∈ U → IsOpen x hsU : s ⊆ u ∪ ⋃₀ ↑U x : α x✝ : x ∈ s ∩ (u ∩ ⋃₀ ↑U) hxs : x ∈ s hxu : x ∈ u v : Set α hvU : v ∈ ↑U hxv : x ∈ v ⊢ x ∈ ∅ [PROOFSTEP] exact ne_of_mem_of_not_mem hvU uU (hU.1 v hvU ⟨x, hxs, hxu, hxv⟩).symm [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v s : Set α hne : Set.Nonempty s u : Set α U : Finset (Set α) uU : ¬u ∈ U x✝ : Set.Nonempty s ∧ ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b h : ∀ (a : Set α), IsOpen a → ∀ (b : Set α), IsOpen b → s ⊆ a ∪ b → s ∩ (a ∩ b) = ∅ → s ⊆ a ∨ s ⊆ b IH : (∀ (a : Set α), a ∈ U → ∀ (b : Set α), b ∈ U → Set.Nonempty (s ∩ (a ∩ b)) → a = b) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u hU : (∀ (x : Set α), x ∈ U → Set.Nonempty (s ∩ (u ∩ x)) → u = x) ∧ ∀ (x : Set α), x ∈ U → (Set.Nonempty (s ∩ (x ∩ u)) → x = u) ∧ ∀ (x_1 : Set α), x_1 ∈ U → Set.Nonempty (s ∩ (x ∩ x_1)) → x = x_1 hUo : IsOpen u ∧ ∀ (x : Set α), x ∈ U → IsOpen x hsU : s ⊆ u ∪ ⋃₀ ↑U ⊢ s ⊆ ⋃₀ ↑U → ∃ x, x ∈ U ∧ s ⊆ x [PROOFSTEP] exact IH (fun u hu => (hU.2 u hu).2) hUo.2 [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α h : ∀ (U : Finset (Set α)), (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u ⊢ Set.Nonempty s [PROOFSTEP] simpa [subset_empty_iff, nonempty_iff_ne_empty] using h ∅ [GOAL] case refine_3 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (U : Finset (Set α)), (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsuv : s ∩ (u ∩ v) = ∅ ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] rw [← not_nonempty_iff_eq_empty] at hsuv [GOAL] case refine_3 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (U : Finset (Set α)), (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsuv : ¬Set.Nonempty (s ∩ (u ∩ v)) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] have := hsuv [GOAL] case refine_3 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (U : Finset (Set α)), (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsuv this : ¬Set.Nonempty (s ∩ (u ∩ v)) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] rw [inter_comm u] at this [GOAL] case refine_3 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α h : ∀ (U : Finset (Set α)), (∀ (u v : Set α), u ∈ U → v ∈ U → Set.Nonempty (s ∩ (u ∩ v)) → u = v) → (∀ (u : Set α), u ∈ U → IsOpen u) → s ⊆ ⋃₀ ↑U → ∃ u, u ∈ U ∧ s ⊆ u u v : Set α hu : IsOpen u hv : IsOpen v hs : s ⊆ u ∪ v hsuv : ¬Set.Nonempty (s ∩ (u ∩ v)) this : ¬Set.Nonempty (s ∩ (v ∩ u)) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] simpa [*, or_imp, forall_and] using h { u, v } [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ IsPreconnected s ↔ ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ IsPreconnected s → ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v [PROOFSTEP] intro h [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v) → IsPreconnected s [PROOFSTEP] intro h [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : IsPreconnected s ⊢ ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v [PROOFSTEP] intro u v hu hv hs huv [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ : Set α h : IsPreconnected s u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] rw [isPreconnected_closed_iff] at h [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ : Set α h : ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] specialize h u v hu hv hs [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] contrapose! huv [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) huv : ¬s ⊆ u ∧ ¬s ⊆ v ⊢ s ∩ (u ∩ v) ≠ ∅ [PROOFSTEP] rw [← nonempty_iff_ne_empty] [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) huv : ¬s ⊆ u ∧ ¬s ⊆ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] simp [not_subset] at huv [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) huv : (∃ a, a ∈ s ∧ ¬a ∈ u) ∧ ∃ a, a ∈ s ∧ ¬a ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩ [GOAL] case mp.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) x : α hxs : x ∈ s hxu : ¬x ∈ u y : α hys : y ∈ s hyv : ¬y ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu [GOAL] case mp.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) x : α hxs : x ∈ s hxu : ¬x ∈ u y : α hys : y ∈ s hyv : ¬y ∈ v hxv : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv [GOAL] case mp.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v h : Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) x : α hxs : x ∈ s hxu : ¬x ∈ u y : α hys : y ∈ s hyv : ¬y ∈ v hxv : x ∈ v hyu : y ∈ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v ⊢ IsPreconnected s [PROOFSTEP] rw [isPreconnected_closed_iff] [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v ⊢ ∀ (t t' : Set α), IsClosed t → IsClosed t' → s ⊆ t ∪ t' → Set.Nonempty (s ∩ t) → Set.Nonempty (s ∩ t') → Set.Nonempty (s ∩ (t ∩ t')) [PROOFSTEP] intro u v hu hv hs hsu hsv [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ : Set α h : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rw [nonempty_iff_ne_empty] [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ : Set α h : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) ⊢ s ∩ (u ∩ v) ≠ ∅ [PROOFSTEP] intro H [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ : Set α h : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : s ∩ (u ∩ v) = ∅ ⊢ False [PROOFSTEP] specialize h u v hu hv hs H [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : s ∩ (u ∩ v) = ∅ h : s ⊆ u ∨ s ⊆ v ⊢ False [PROOFSTEP] contrapose H [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) h : s ⊆ u ∨ s ⊆ v H : ¬False ⊢ ¬s ∩ (u ∩ v) = ∅ [PROOFSTEP] apply Nonempty.ne_empty [GOAL] case mpr.a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) h : s ⊆ u ∨ s ⊆ v H : ¬False ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] cases' h with h h [GOAL] case mpr.a.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : ¬False h : s ⊆ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases hsv with ⟨x, hxs, hxv⟩ [GOAL] case mpr.a.inl.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) H : ¬False h : s ⊆ u x : α hxs : x ∈ s hxv : x ∈ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ [GOAL] case mpr.a.inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsu : Set.Nonempty (s ∩ u) hsv : Set.Nonempty (s ∩ v) H : ¬False h : s ⊆ v ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] rcases hsu with ⟨x, hxs, hxu⟩ [GOAL] case mpr.a.inr.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u✝ v✝ u v : Set α hu : IsClosed u hv : IsClosed v hs : s ⊆ u ∪ v hsv : Set.Nonempty (s ∩ v) H : ¬False h : s ⊆ v x : α hxs : x ∈ s hxu : x ∈ u ⊢ Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsClosed s ⊢ IsPreconnected s ↔ ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v [PROOFSTEP] refine isPreconnected_iff_subset_of_disjoint_closed.trans ⟨?_, ?_⟩ [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsClosed s ⊢ (∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v) → ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v [PROOFSTEP] intro H u v hu hv hss huv [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : IsClosed s ⊢ (∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v) → ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v [PROOFSTEP] intro H u v hu hv hss huv [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : Disjoint u v ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] apply H u v hu hv hss [GOAL] case refine_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : Disjoint u v ⊢ s ∩ (u ∩ v) = ∅ [PROOFSTEP] rw [huv.inter_eq, inter_empty] [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] have H1 := H (u ∩ s) (v ∩ s) [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ H1 : IsClosed (u ∩ s) → IsClosed (v ∩ s) → s ⊆ u ∩ s ∪ v ∩ s → Disjoint (u ∩ s) (v ∩ s) → s ⊆ u ∩ s ∨ s ⊆ v ∩ s ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] rw [subset_inter_iff, subset_inter_iff] at H1 [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ H1 : IsClosed (u ∩ s) → IsClosed (v ∩ s) → s ⊆ u ∩ s ∪ v ∩ s → Disjoint (u ∩ s) (v ∩ s) → s ⊆ u ∧ s ⊆ s ∨ s ⊆ v ∧ s ⊆ s ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] simp only [Subset.refl, and_true] at H1 [GOAL] case refine_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ H1 : IsClosed (u ∩ s) → IsClosed (v ∩ s) → s ⊆ u ∩ s ∪ v ∩ s → Disjoint (u ∩ s) (v ∩ s) → s ⊆ u ∨ s ⊆ v ⊢ s ⊆ u ∨ s ⊆ v [PROOFSTEP] apply H1 (hu.inter hs) (hv.inter hs) [GOAL] case refine_2.a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ H1 : IsClosed (u ∩ s) → IsClosed (v ∩ s) → s ⊆ u ∩ s ∪ v ∩ s → Disjoint (u ∩ s) (v ∩ s) → s ⊆ u ∨ s ⊆ v ⊢ s ⊆ u ∩ s ∪ v ∩ s [PROOFSTEP] rw [← inter_distrib_right] [GOAL] case refine_2.a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ H1 : IsClosed (u ∩ s) → IsClosed (v ∩ s) → s ⊆ u ∩ s ∪ v ∩ s → Disjoint (u ∩ s) (v ∩ s) → s ⊆ u ∨ s ⊆ v ⊢ s ⊆ (u ∪ v) ∩ s [PROOFSTEP] exact subset_inter hss Subset.rfl [GOAL] case refine_2.a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : IsClosed s H : ∀ (u v : Set α), IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v u v : Set α hu : IsClosed u hv : IsClosed v hss : s ⊆ u ∪ v huv : s ∩ (u ∩ v) = ∅ H1 : IsClosed (u ∩ s) → IsClosed (v ∩ s) → s ⊆ u ∩ s ∪ v ∩ s → Disjoint (u ∩ s) (v ∩ s) → s ⊆ u ∨ s ⊆ v ⊢ Disjoint (u ∩ s) (v ∩ s) [PROOFSTEP] rwa [disjoint_iff_inter_eq_empty, ← inter_inter_distrib_right, inter_comm] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β ⊢ IsConnected (f ⁻¹' connectedComponent t) [PROOFSTEP] have hf : Surjective f := Surjective.of_comp fun t : β => (connected_fibers t).1 [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f ⊢ IsConnected (f ⁻¹' connectedComponent t) [PROOFSTEP] refine ⟨Nonempty.preimage connectedComponent_nonempty hf, ?_⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f ⊢ IsPreconnected (f ⁻¹' connectedComponent t) [PROOFSTEP] have hT : IsClosed (f ⁻¹' connectedComponent t) := (hcl (connectedComponent t)).1 isClosed_connectedComponent [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) ⊢ IsPreconnected (f ⁻¹' connectedComponent t) [PROOFSTEP] rw [isPreconnected_iff_subset_of_fully_disjoint_closed hT] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u v : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) ⊢ ∀ (u v : Set α), IsClosed u → IsClosed v → f ⁻¹' connectedComponent t ⊆ u ∪ v → Disjoint u v → f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] intro u v hu hv huv uv_disj [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] let T₁ := {t' ∈ connectedComponent t | f ⁻¹' { t' } ⊆ u} [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] let T₂ := {t' ∈ connectedComponent t | f ⁻¹' { t' } ⊆ v} [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] have fiber_decomp : ∀ t' ∈ connectedComponent t, f ⁻¹' { t' } ⊆ u ∨ f ⁻¹' { t' } ⊆ v := by intro t' ht' apply isPreconnected_iff_subset_of_disjoint_closed.1 (connected_fibers t').2 u v hu hv · exact Subset.trans (preimage_mono (singleton_subset_iff.2 ht')) huv rw [uv_disj.inter_eq, inter_empty] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} ⊢ ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v [PROOFSTEP] intro t' ht' [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} t' : β ht' : t' ∈ connectedComponent t ⊢ f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v [PROOFSTEP] apply isPreconnected_iff_subset_of_disjoint_closed.1 (connected_fibers t').2 u v hu hv [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} t' : β ht' : t' ∈ connectedComponent t ⊢ f ⁻¹' {t'} ⊆ u ∪ v [PROOFSTEP] exact Subset.trans (preimage_mono (singleton_subset_iff.2 ht')) huv [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} t' : β ht' : t' ∈ connectedComponent t ⊢ f ⁻¹' {t'} ∩ (u ∩ v) = ∅ [PROOFSTEP] rw [uv_disj.inter_eq, inter_empty] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] have T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u := by apply eq_of_subset_of_subset · rw [← biUnion_preimage_singleton] refine' iUnion₂_subset fun t' ht' => subset_inter _ ht'.2 rw [hf.preimage_subset_preimage_iff, singleton_subset_iff] exact ht'.1 rintro a ⟨hat, hau⟩ constructor · exact mem_preimage.1 hat refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_right fun h => ?_ exact uv_disj.subset_compl_right hau (h rfl) -- This proof is exactly the same as the above (modulo some symmetry) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v ⊢ f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u [PROOFSTEP] apply eq_of_subset_of_subset [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v ⊢ f ⁻¹' T₁ ⊆ f ⁻¹' connectedComponent t ∩ u [PROOFSTEP] rw [← biUnion_preimage_singleton] [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v ⊢ ⋃ (y : β) (_ : y ∈ T₁), f ⁻¹' {y} ⊆ f ⁻¹' connectedComponent t ∩ u [PROOFSTEP] refine' iUnion₂_subset fun t' ht' => subset_inter _ ht'.2 [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v t' : β ht' : t' ∈ T₁ ⊢ f ⁻¹' {t'} ⊆ f ⁻¹' connectedComponent t [PROOFSTEP] rw [hf.preimage_subset_preimage_iff, singleton_subset_iff] [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v t' : β ht' : t' ∈ T₁ ⊢ t' ∈ connectedComponent t [PROOFSTEP] exact ht'.1 [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v ⊢ f ⁻¹' connectedComponent t ∩ u ⊆ f ⁻¹' T₁ [PROOFSTEP] rintro a ⟨hat, hau⟩ [GOAL] case a.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v a : α hat : a ∈ f ⁻¹' connectedComponent t hau : a ∈ u ⊢ a ∈ f ⁻¹' T₁ [PROOFSTEP] constructor [GOAL] case a.intro.left α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v a : α hat : a ∈ f ⁻¹' connectedComponent t hau : a ∈ u ⊢ f a ∈ connectedComponent t [PROOFSTEP] exact mem_preimage.1 hat [GOAL] case a.intro.right α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v a : α hat : a ∈ f ⁻¹' connectedComponent t hau : a ∈ u ⊢ f ⁻¹' {f a} ⊆ u [PROOFSTEP] refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_right fun h => ?_ [GOAL] case a.intro.right α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v a : α hat : a ∈ f ⁻¹' connectedComponent t hau : a ∈ u h : f ⁻¹' {f a} ⊆ v ⊢ False [PROOFSTEP] exact uv_disj.subset_compl_right hau (h rfl) -- This proof is exactly the same as the above (modulo some symmetry) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] have T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v := by apply eq_of_subset_of_subset · rw [← biUnion_preimage_singleton] refine' iUnion₂_subset fun t' ht' => subset_inter _ ht'.2 rw [hf.preimage_subset_preimage_iff, singleton_subset_iff] exact ht'.1 rintro a ⟨hat, hav⟩ constructor · exact mem_preimage.1 hat · refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_left fun h => ?_ exact uv_disj.subset_compl_left hav (h rfl) -- Now we show T₁, T₂ are closed, cover connectedComponent t and are disjoint. [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u ⊢ f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v [PROOFSTEP] apply eq_of_subset_of_subset [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u ⊢ f ⁻¹' T₂ ⊆ f ⁻¹' connectedComponent t ∩ v [PROOFSTEP] rw [← biUnion_preimage_singleton] [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u ⊢ ⋃ (y : β) (_ : y ∈ T₂), f ⁻¹' {y} ⊆ f ⁻¹' connectedComponent t ∩ v [PROOFSTEP] refine' iUnion₂_subset fun t' ht' => subset_inter _ ht'.2 [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u t' : β ht' : t' ∈ T₂ ⊢ f ⁻¹' {t'} ⊆ f ⁻¹' connectedComponent t [PROOFSTEP] rw [hf.preimage_subset_preimage_iff, singleton_subset_iff] [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u t' : β ht' : t' ∈ T₂ ⊢ t' ∈ connectedComponent t [PROOFSTEP] exact ht'.1 [GOAL] case a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u ⊢ f ⁻¹' connectedComponent t ∩ v ⊆ f ⁻¹' T₂ [PROOFSTEP] rintro a ⟨hat, hav⟩ [GOAL] case a.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u a : α hat : a ∈ f ⁻¹' connectedComponent t hav : a ∈ v ⊢ a ∈ f ⁻¹' T₂ [PROOFSTEP] constructor [GOAL] case a.intro.left α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u a : α hat : a ∈ f ⁻¹' connectedComponent t hav : a ∈ v ⊢ f a ∈ connectedComponent t [PROOFSTEP] exact mem_preimage.1 hat [GOAL] case a.intro.right α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u a : α hat : a ∈ f ⁻¹' connectedComponent t hav : a ∈ v ⊢ f ⁻¹' {f a} ⊆ v [PROOFSTEP] refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_left fun h => ?_ [GOAL] case a.intro.right α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u a : α hat : a ∈ f ⁻¹' connectedComponent t hav : a ∈ v h : f ⁻¹' {f a} ⊆ u ⊢ False [PROOFSTEP] exact uv_disj.subset_compl_left hav (h rfl) -- Now we show T₁, T₂ are closed, cover connectedComponent t and are disjoint. [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] have hT₁ : IsClosed T₁ := (hcl T₁).2 (T₁_u.symm ▸ IsClosed.inter hT hu) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] have hT₂ : IsClosed T₂ := (hcl T₂).2 (T₂_v.symm ▸ IsClosed.inter hT hv) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] have T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ := fun t' ht' => by rw [mem_union t' T₁ T₂] cases' fiber_decomp t' ht' with htu htv · left exact ⟨ht', htu⟩ right exact ⟨ht', htv⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ t' : β ht' : t' ∈ connectedComponent t ⊢ t' ∈ T₁ ∪ T₂ [PROOFSTEP] rw [mem_union t' T₁ T₂] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ t' : β ht' : t' ∈ connectedComponent t ⊢ t' ∈ T₁ ∨ t' ∈ T₂ [PROOFSTEP] cases' fiber_decomp t' ht' with htu htv [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ t' : β ht' : t' ∈ connectedComponent t htu : f ⁻¹' {t'} ⊆ u ⊢ t' ∈ T₁ ∨ t' ∈ T₂ [PROOFSTEP] left [GOAL] case inl.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ t' : β ht' : t' ∈ connectedComponent t htu : f ⁻¹' {t'} ⊆ u ⊢ t' ∈ T₁ [PROOFSTEP] exact ⟨ht', htu⟩ [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ t' : β ht' : t' ∈ connectedComponent t htv : f ⁻¹' {t'} ⊆ v ⊢ t' ∈ T₁ ∨ t' ∈ T₂ [PROOFSTEP] right [GOAL] case inr.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ t' : β ht' : t' ∈ connectedComponent t htv : f ⁻¹' {t'} ⊆ v ⊢ t' ∈ T₂ [PROOFSTEP] exact ⟨ht', htv⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] have T_disjoint : Disjoint T₁ T₂ := by refine' Disjoint.of_preimage hf _ rw [T₁_u, T₂_v, disjoint_iff_inter_eq_empty, ← inter_inter_distrib_left, uv_disj.inter_eq, inter_empty] -- Now we do cases on whether (connectedComponent t) is a subset of T₁ or T₂ to show -- that the preimage is a subset of u or v. [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ ⊢ Disjoint T₁ T₂ [PROOFSTEP] refine' Disjoint.of_preimage hf _ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ ⊢ Disjoint (f ⁻¹' T₁) (f ⁻¹' T₂) [PROOFSTEP] rw [T₁_u, T₂_v, disjoint_iff_inter_eq_empty, ← inter_inter_distrib_left, uv_disj.inter_eq, inter_empty] -- Now we do cases on whether (connectedComponent t) is a subset of T₁ or T₂ to show -- that the preimage is a subset of u or v. [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] cases' (isPreconnected_iff_subset_of_fully_disjoint_closed isClosed_connectedComponent).1 isPreconnected_connectedComponent T₁ T₂ hT₁ hT₂ T_decomp T_disjoint with h h [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₁ ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] left [GOAL] case inl.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₁ ⊢ f ⁻¹' connectedComponent t ⊆ u [PROOFSTEP] rw [Subset.antisymm_iff] at T₁_u [GOAL] case inl.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ ⊆ f ⁻¹' connectedComponent t ∩ u ∧ f ⁻¹' connectedComponent t ∩ u ⊆ f ⁻¹' T₁ T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₁ ⊢ f ⁻¹' connectedComponent t ⊆ u [PROOFSTEP] suffices f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₁ from (this.trans T₁_u.1).trans (inter_subset_right _ _) [GOAL] case inl.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ ⊆ f ⁻¹' connectedComponent t ∩ u ∧ f ⁻¹' connectedComponent t ∩ u ⊆ f ⁻¹' T₁ T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₁ ⊢ f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₁ [PROOFSTEP] exact preimage_mono h [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₂ ⊢ f ⁻¹' connectedComponent t ⊆ u ∨ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] right [GOAL] case inr.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₂ ⊢ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] rw [Subset.antisymm_iff] at T₂_v [GOAL] case inr.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ ⊆ f ⁻¹' connectedComponent t ∩ v ∧ f ⁻¹' connectedComponent t ∩ v ⊆ f ⁻¹' T₂ hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₂ ⊢ f ⁻¹' connectedComponent t ⊆ v [PROOFSTEP] suffices f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₂ from (this.trans T₂_v.1).trans (inter_subset_right _ _) [GOAL] case inr.h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t✝ u✝ v✝ : Set α inst✝ : TopologicalSpace β f : α → β connected_fibers : ∀ (t : β), IsConnected (f ⁻¹' {t}) hcl : ∀ (T : Set β), IsClosed T ↔ IsClosed (f ⁻¹' T) t : β hf : Surjective f hT : IsClosed (f ⁻¹' connectedComponent t) u v : Set α hu : IsClosed u hv : IsClosed v huv : f ⁻¹' connectedComponent t ⊆ u ∪ v uv_disj : Disjoint u v T₁ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ u} T₂ : Set β := {t' | t' ∈ connectedComponent t ∧ f ⁻¹' {t'} ⊆ v} fiber_decomp : ∀ (t' : β), t' ∈ connectedComponent t → f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u T₂_v : f ⁻¹' T₂ ⊆ f ⁻¹' connectedComponent t ∩ v ∧ f ⁻¹' connectedComponent t ∩ v ⊆ f ⁻¹' T₂ hT₁ : IsClosed T₁ hT₂ : IsClosed T₂ T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ T_disjoint : Disjoint T₁ T₂ h : connectedComponent t ⊆ T₂ ⊢ f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₂ [PROOFSTEP] exact preimage_mono h [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : TopologicalSpace β f : α → β hf : QuotientMap f h_fibers : ∀ (y : β), IsConnected (f ⁻¹' {y}) a : α ⊢ f '' connectedComponent a = connectedComponent (f a) [PROOFSTEP] rw [← hf.preimage_connectedComponent h_fibers, image_preimage_eq _ hf.surjective] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ LocallyConnectedSpace α ↔ ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V [PROOFSTEP] simp_rw [locallyConnectedSpace_iff_open_connected_basis] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α), Filter.HasBasis (𝓝 x) (fun s => IsOpen s ∧ x ∈ s ∧ IsConnected s) id) ↔ ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V [PROOFSTEP] refine forall_congr' fun _ => ?_ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x✝ : α ⊢ Filter.HasBasis (𝓝 x✝) (fun s => IsOpen s ∧ x✝ ∈ s ∧ IsConnected s) id ↔ ∀ (U : Set α), U ∈ 𝓝 x✝ → ∃ V, V ⊆ U ∧ IsOpen V ∧ x✝ ∈ V ∧ IsConnected V [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x✝ : α ⊢ Filter.HasBasis (𝓝 x✝) (fun s => IsOpen s ∧ x✝ ∈ s ∧ IsConnected s) id → ∀ (U : Set α), U ∈ 𝓝 x✝ → ∃ V, V ⊆ U ∧ IsOpen V ∧ x✝ ∈ V ∧ IsConnected V [PROOFSTEP] intro h U hU [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x✝ : α h : Filter.HasBasis (𝓝 x✝) (fun s => IsOpen s ∧ x✝ ∈ s ∧ IsConnected s) id U : Set α hU : U ∈ 𝓝 x✝ ⊢ ∃ V, V ⊆ U ∧ IsOpen V ∧ x✝ ∈ V ∧ IsConnected V [PROOFSTEP] rcases h.mem_iff.mp hU with ⟨V, hV, hVU⟩ [GOAL] case mp.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x✝ : α h : Filter.HasBasis (𝓝 x✝) (fun s => IsOpen s ∧ x✝ ∈ s ∧ IsConnected s) id U : Set α hU : U ∈ 𝓝 x✝ V : Set α hV : IsOpen V ∧ x✝ ∈ V ∧ IsConnected V hVU : id V ⊆ U ⊢ ∃ V, V ⊆ U ∧ IsOpen V ∧ x✝ ∈ V ∧ IsConnected V [PROOFSTEP] exact ⟨V, hVU, hV⟩ [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x✝ : α ⊢ (∀ (U : Set α), U ∈ 𝓝 x✝ → ∃ V, V ⊆ U ∧ IsOpen V ∧ x✝ ∈ V ∧ IsConnected V) → Filter.HasBasis (𝓝 x✝) (fun s => IsOpen s ∧ x✝ ∈ s ∧ IsConnected s) id [PROOFSTEP] exact fun h => ⟨fun U => ⟨fun hU => let ⟨V, hVU, hV⟩ := h U hU ⟨V, hV, hVU⟩, fun ⟨V, ⟨hV, hxV, _⟩, hVU⟩ => mem_nhds_iff.mpr ⟨V, hVU, hV, hxV⟩⟩⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α F : Set α x : α h : F ∈ 𝓝 x ⊢ connectedComponentIn F x ∈ 𝓝 x [PROOFSTEP] rw [(LocallyConnectedSpace.open_connected_basis x).mem_iff] at h [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α F : Set α x : α h : ∃ i, (IsOpen i ∧ x ∈ i ∧ IsConnected i) ∧ id i ⊆ F ⊢ connectedComponentIn F x ∈ 𝓝 x [PROOFSTEP] rcases h with ⟨s, ⟨h1s, hxs, h2s⟩, hsF⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s✝ t u v : Set α inst✝ : LocallyConnectedSpace α F : Set α x : α s : Set α hsF : id s ⊆ F h1s : IsOpen s hxs : x ∈ s h2s : IsConnected s ⊢ connectedComponentIn F x ∈ 𝓝 x [PROOFSTEP] exact mem_nhds_iff.mpr ⟨s, h2s.isPreconnected.subset_connectedComponentIn hxs hsF, h1s, hxs⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α F : Set α x : α hF : IsOpen F ⊢ IsOpen (connectedComponentIn F x) [PROOFSTEP] rw [isOpen_iff_mem_nhds] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α F : Set α x : α hF : IsOpen F ⊢ ∀ (a : α), a ∈ connectedComponentIn F x → connectedComponentIn F x ∈ 𝓝 a [PROOFSTEP] intro y hy [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α F : Set α x : α hF : IsOpen F y : α hy : y ∈ connectedComponentIn F x ⊢ connectedComponentIn F x ∈ 𝓝 y [PROOFSTEP] rw [connectedComponentIn_eq hy] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α F : Set α x : α hF : IsOpen F y : α hy : y ∈ connectedComponentIn F x ⊢ connectedComponentIn F y ∈ 𝓝 y [PROOFSTEP] exact connectedComponentIn_mem_nhds (hF.mem_nhds <| connectedComponentIn_subset F x hy) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α x : α ⊢ IsOpen (connectedComponent x) [PROOFSTEP] rw [← connectedComponentIn_univ] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α inst✝ : LocallyConnectedSpace α x : α ⊢ IsOpen (connectedComponentIn univ x) [PROOFSTEP] exact isOpen_univ.connectedComponentIn [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ LocallyConnectedSpace α ↔ ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ LocallyConnectedSpace α → ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) [PROOFSTEP] intro h [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : LocallyConnectedSpace α ⊢ ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) [PROOFSTEP] exact fun F hF x _ => hF.connectedComponentIn [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x)) → LocallyConnectedSpace α [PROOFSTEP] intro h [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) ⊢ LocallyConnectedSpace α [PROOFSTEP] rw [locallyConnectedSpace_iff_open_connected_subsets] [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) ⊢ ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V [PROOFSTEP] refine' fun x U hU => ⟨connectedComponentIn (interior U) x, (connectedComponentIn_subset _ _).trans interior_subset, h _ isOpen_interior x _, mem_connectedComponentIn _, isConnected_connectedComponentIn_iff.mpr _⟩ [GOAL] case mpr.refine'_1 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) x : α U : Set α hU : U ∈ 𝓝 x ⊢ x ∈ interior U [PROOFSTEP] exact mem_interior_iff_mem_nhds.mpr hU [GOAL] case mpr.refine'_2 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) x : α U : Set α hU : U ∈ 𝓝 x ⊢ x ∈ interior U [PROOFSTEP] exact mem_interior_iff_mem_nhds.mpr hU [GOAL] case mpr.refine'_3 α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) x : α U : Set α hU : U ∈ 𝓝 x ⊢ x ∈ interior U [PROOFSTEP] exact mem_interior_iff_mem_nhds.mpr hU [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ LocallyConnectedSpace α ↔ ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ LocallyConnectedSpace α → ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U [PROOFSTEP] rw [locallyConnectedSpace_iff_open_connected_subsets] [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V) → ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U [PROOFSTEP] intro h x U hxU [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V x : α U : Set α hxU : U ∈ 𝓝 x ⊢ ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U [PROOFSTEP] rcases h x U hxU with ⟨V, hVU, hV₁, hxV, hV₂⟩ [GOAL] case mp.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V x : α U : Set α hxU : U ∈ 𝓝 x V : Set α hVU : V ⊆ U hV₁ : IsOpen V hxV : x ∈ V hV₂ : IsConnected V ⊢ ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U [PROOFSTEP] exact ⟨V, hV₁.mem_nhds hxV, hV₂.isPreconnected, hVU⟩ [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U) → LocallyConnectedSpace α [PROOFSTEP] rw [locallyConnectedSpace_iff_connectedComponentIn_open] [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U) → ∀ (F : Set α), IsOpen F → ∀ (x : α), x ∈ F → IsOpen (connectedComponentIn F x) [PROOFSTEP] refine' fun h U hU x _ => isOpen_iff_mem_nhds.mpr fun y hy => _ [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U U : Set α hU : IsOpen U x : α x✝ : x ∈ U y : α hy : y ∈ connectedComponentIn U x ⊢ connectedComponentIn U x ∈ 𝓝 y [PROOFSTEP] rw [connectedComponentIn_eq hy] [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U U : Set α hU : IsOpen U x : α x✝ : x ∈ U y : α hy : y ∈ connectedComponentIn U x ⊢ connectedComponentIn U y ∈ 𝓝 y [PROOFSTEP] rcases h y U (hU.mem_nhds <| (connectedComponentIn_subset _ _) hy) with ⟨V, hVy, hV, hVU⟩ [GOAL] case mpr.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U U : Set α hU : IsOpen U x : α x✝ : x ∈ U y : α hy : y ∈ connectedComponentIn U x V : Set α hVy : V ∈ 𝓝 y hV : IsPreconnected V hVU : V ⊆ U ⊢ connectedComponentIn U y ∈ 𝓝 y [PROOFSTEP] exact Filter.mem_of_superset hVy (hV.subset_connectedComponentIn (mem_of_mem_nhds hVy) hVU) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ LocallyConnectedSpace α ↔ ∀ (x : α), Filter.HasBasis (𝓝 x) (fun s => s ∈ 𝓝 x ∧ IsPreconnected s) id [PROOFSTEP] rw [locallyConnectedSpace_iff_connected_subsets] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α) (U : Set α), U ∈ 𝓝 x → ∃ V, V ∈ 𝓝 x ∧ IsPreconnected V ∧ V ⊆ U) ↔ ∀ (x : α), Filter.HasBasis (𝓝 x) (fun s => s ∈ 𝓝 x ∧ IsPreconnected s) id [PROOFSTEP] exact forall_congr' <| fun x => Filter.hasBasis_self.symm [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ι : Type u_3 b : α → ι → Set α p : α → ι → Prop hbasis : ∀ (x : α), Filter.HasBasis (𝓝 x) (p x) (b x) hconnected : ∀ (x : α) (i : ι), p x i → IsPreconnected (b x i) ⊢ LocallyConnectedSpace α [PROOFSTEP] rw [locallyConnectedSpace_iff_connected_basis] [GOAL] α : Type u β : Type v ι✝ : Type u_1 π : ι✝ → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ι : Type u_3 b : α → ι → Set α p : α → ι → Prop hbasis : ∀ (x : α), Filter.HasBasis (𝓝 x) (p x) (b x) hconnected : ∀ (x : α) (i : ι), p x i → IsPreconnected (b x i) ⊢ ∀ (x : α), Filter.HasBasis (𝓝 x) (fun s => s ∈ 𝓝 x ∧ IsPreconnected s) id [PROOFSTEP] exact fun x => (hbasis x).to_hasBasis (fun i hi => ⟨b x i, ⟨(hbasis x).mem_of_mem hi, hconnected x i hi⟩, subset_rfl⟩) fun s hs => ⟨(hbasis x).index s hs.1, ⟨(hbasis x).property_index hs.1, (hbasis x).set_index_subset hs.1⟩⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s t u v : Set α inst✝² : TopologicalSpace β inst✝¹ : TotallyDisconnectedSpace α inst✝ : TotallyDisconnectedSpace β ⊢ TotallyDisconnectedSpace (α ⊕ β) [PROOFSTEP] refine' ⟨fun s _ hs => _⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s✝ t u v : Set α inst✝² : TopologicalSpace β inst✝¹ : TotallyDisconnectedSpace α inst✝ : TotallyDisconnectedSpace β s : Set (α ⊕ β) x✝ : s ⊆ univ hs : IsPreconnected s ⊢ Set.Subsingleton s [PROOFSTEP] obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isPreconnected_iff.1 hs [GOAL] case inl.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s t✝ u v : Set α inst✝² : TopologicalSpace β inst✝¹ : TotallyDisconnectedSpace α inst✝ : TotallyDisconnectedSpace β t : Set α ht : IsPreconnected t x✝ : Sum.inl '' t ⊆ univ hs : IsPreconnected (Sum.inl '' t) ⊢ Set.Subsingleton (Sum.inl '' t) [PROOFSTEP] exact ht.subsingleton.image _ [GOAL] case inr.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝³ : TopologicalSpace α s t✝ u v : Set α inst✝² : TopologicalSpace β inst✝¹ : TotallyDisconnectedSpace α inst✝ : TotallyDisconnectedSpace β t : Set β ht : IsPreconnected t x✝ : Sum.inr '' t ⊆ univ hs : IsPreconnected (Sum.inr '' t) ⊢ Set.Subsingleton (Sum.inr '' t) [PROOFSTEP] exact ht.subsingleton.image _ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : (i : ι) → TopologicalSpace (π i) inst✝ : ∀ (i : ι), TotallyDisconnectedSpace (π i) ⊢ TotallyDisconnectedSpace ((i : ι) × π i) [PROOFSTEP] refine' ⟨fun s _ hs => _⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : (i : ι) → TopologicalSpace (π i) inst✝ : ∀ (i : ι), TotallyDisconnectedSpace (π i) s : Set ((i : ι) × π i) x✝ : s ⊆ univ hs : IsPreconnected s ⊢ Set.Subsingleton s [PROOFSTEP] obtain rfl | h := s.eq_empty_or_nonempty [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : (i : ι) → TopologicalSpace (π i) inst✝ : ∀ (i : ι), TotallyDisconnectedSpace (π i) x✝ : ∅ ⊆ univ hs : IsPreconnected ∅ ⊢ Set.Subsingleton ∅ [PROOFSTEP] exact subsingleton_empty [GOAL] case inr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s✝ t u v : Set α inst✝¹ : (i : ι) → TopologicalSpace (π i) inst✝ : ∀ (i : ι), TotallyDisconnectedSpace (π i) s : Set ((i : ι) × π i) x✝ : s ⊆ univ hs : IsPreconnected s h : Set.Nonempty s ⊢ Set.Subsingleton s [PROOFSTEP] obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ [GOAL] case inr.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t✝ u v : Set α inst✝¹ : (i : ι) → TopologicalSpace (π i) inst✝ : ∀ (i : ι), TotallyDisconnectedSpace (π i) a : ι t : Set (π a) ht : IsConnected t x✝ : Sigma.mk a '' t ⊆ univ hs : IsPreconnected (Sigma.mk a '' t) h : Set.Nonempty (Sigma.mk a '' t) ⊢ Set.Subsingleton (Sigma.mk a '' t) [PROOFSTEP] exact ht.isPreconnected.subsingleton.image _ -- porting note: reformulated using `Pairwise` [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U ⊢ IsTotallyDisconnected univ [PROOFSTEP] rintro S - hS [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U S : Set X hS : IsPreconnected S ⊢ Set.Subsingleton S [PROOFSTEP] unfold Set.Subsingleton [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U S : Set X hS : IsPreconnected S ⊢ ∀ ⦃x : X⦄, x ∈ S → ∀ ⦃y : X⦄, y ∈ S → x = y [PROOFSTEP] by_contra' h_contra [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U S : Set X hS : IsPreconnected S h_contra : Exists fun ⦃x⦄ => x ∈ S ∧ Exists fun ⦃y⦄ => y ∈ S ∧ x ≠ y ⊢ False [PROOFSTEP] rcases h_contra with ⟨x, hx, y, hy, hxy⟩ [GOAL] case intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U S : Set X hS : IsPreconnected S x : X hx : x ∈ S y : X hy : y ∈ S hxy : x ≠ y ⊢ False [PROOFSTEP] obtain ⟨U, h_clopen, hxU, hyU⟩ := hX hxy [GOAL] case intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U S : Set X hS : IsPreconnected S x : X hx : x ∈ S y : X hy : y ∈ S hxy : x ≠ y U : Set X h_clopen : IsClopen U hxU : x ∈ U hyU : ¬y ∈ U ⊢ False [PROOFSTEP] specialize hS U Uᶜ h_clopen.1 h_clopen.compl.1 (fun a _ => em (a ∈ U)) ⟨x, hx, hxU⟩ ⟨y, hy, hyU⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U S : Set X x : X hx : x ∈ S y : X hy : y ∈ S hxy : x ≠ y U : Set X h_clopen : IsClopen U hxU : x ∈ U hyU : ¬y ∈ U hS : Set.Nonempty (S ∩ (U ∩ Uᶜ)) ⊢ False [PROOFSTEP] rw [inter_compl_self, Set.inter_empty] at hS [GOAL] case intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α s t u v : Set α X : Type u_3 inst✝ : TopologicalSpace X hX : Pairwise fun x y => ∃ U, IsClopen U ∧ x ∈ U ∧ ¬y ∈ U S : Set X x : X hx : x ∈ S y : X hy : y ∈ S hxy : x ≠ y U : Set X h_clopen : IsClopen U hxU : x ∈ U hyU : ¬y ∈ U hS : Set.Nonempty ∅ ⊢ False [PROOFSTEP] exact Set.not_nonempty_empty hS [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ TotallyDisconnectedSpace α ↔ ∀ (x : α), Set.Subsingleton (connectedComponent x) [PROOFSTEP] constructor [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ TotallyDisconnectedSpace α → ∀ (x : α), Set.Subsingleton (connectedComponent x) [PROOFSTEP] intro h x [GOAL] case mp α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : TotallyDisconnectedSpace α x : α ⊢ Set.Subsingleton (connectedComponent x) [PROOFSTEP] apply h.1 [GOAL] case mp.a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : TotallyDisconnectedSpace α x : α ⊢ connectedComponent x ⊆ univ [PROOFSTEP] exact subset_univ _ [GOAL] case mp.a α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : TotallyDisconnectedSpace α x : α ⊢ IsPreconnected (connectedComponent x) [PROOFSTEP] exact isPreconnected_connectedComponent [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α), Set.Subsingleton (connectedComponent x)) → TotallyDisconnectedSpace α [PROOFSTEP] intro h [GOAL] case mpr α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), Set.Subsingleton (connectedComponent x) ⊢ TotallyDisconnectedSpace α [PROOFSTEP] constructor [GOAL] case mpr.isTotallyDisconnected_univ α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), Set.Subsingleton (connectedComponent x) ⊢ IsTotallyDisconnected univ [PROOFSTEP] intro s s_sub hs [GOAL] case mpr.isTotallyDisconnected_univ α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v : Set α h : ∀ (x : α), Set.Subsingleton (connectedComponent x) s : Set α s_sub : s ⊆ univ hs : IsPreconnected s ⊢ Set.Subsingleton s [PROOFSTEP] rcases eq_empty_or_nonempty s with (rfl | ⟨x, x_in⟩) [GOAL] case mpr.isTotallyDisconnected_univ.inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α h : ∀ (x : α), Set.Subsingleton (connectedComponent x) s_sub : ∅ ⊆ univ hs : IsPreconnected ∅ ⊢ Set.Subsingleton ∅ [PROOFSTEP] exact subsingleton_empty [GOAL] case mpr.isTotallyDisconnected_univ.inr.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v : Set α h : ∀ (x : α), Set.Subsingleton (connectedComponent x) s : Set α s_sub : s ⊆ univ hs : IsPreconnected s x : α x_in : x ∈ s ⊢ Set.Subsingleton s [PROOFSTEP] exact (h x).anti (hs.subset_connectedComponent x_in) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ TotallyDisconnectedSpace α ↔ ∀ (x : α), connectedComponent x = {x} [PROOFSTEP] rw [totallyDisconnectedSpace_iff_connectedComponent_subsingleton] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α ⊢ (∀ (x : α), Set.Subsingleton (connectedComponent x)) ↔ ∀ (x : α), connectedComponent x = {x} [PROOFSTEP] refine forall_congr' fun x => ?_ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α ⊢ Set.Subsingleton (connectedComponent x) ↔ connectedComponent x = {x} [PROOFSTEP] rw [subsingleton_iff_singleton] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s t u v : Set α x : α ⊢ x ∈ connectedComponent x [PROOFSTEP] exact mem_connectedComponent [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α H : IsTotallySeparated s ⊢ IsTotallyDisconnected s [PROOFSTEP] intro t hts ht x x_in y y_in [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α H : IsTotallySeparated s t : Set α hts : t ⊆ s ht : IsPreconnected t x : α x_in : x ∈ t y : α y_in : y ∈ t ⊢ x = y [PROOFSTEP] by_contra h [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u v s : Set α H : IsTotallySeparated s t : Set α hts : t ⊆ s ht : IsPreconnected t x : α x_in : x ∈ t y : α y_in : y ∈ t h : ¬x = y ⊢ False [PROOFSTEP] obtain ⟨u : Set α, v : Set α, hu : IsOpen u, hv : IsOpen v, hxu : x ∈ u, hyv : y ∈ v, hs : s ⊆ u ∪ v, huv⟩ := H x (hts x_in) y (hts y_in) h [GOAL] case intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α H : IsTotallySeparated s t : Set α hts : t ⊆ s ht : IsPreconnected t x : α x_in : x ∈ t y : α y_in : y ∈ t h : ¬x = y u v : Set α hu : IsOpen u hv : IsOpen v hxu : x ∈ u hyv : y ∈ v hs : s ⊆ u ∪ v huv : Disjoint u v ⊢ False [PROOFSTEP] refine' (ht _ _ hu hv (hts.trans hs) ⟨x, x_in, hxu⟩ ⟨y, y_in, hyv⟩).ne_empty _ [GOAL] case intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t✝ u✝ v✝ s : Set α H : IsTotallySeparated s t : Set α hts : t ⊆ s ht : IsPreconnected t x : α x_in : x ∈ t y : α y_in : y ∈ t h : ¬x = y u v : Set α hu : IsOpen u hv : IsOpen v hxu : x ∈ u hyv : y ∈ v hs : s ⊆ u ∪ v huv : Disjoint u v ⊢ t ∩ (u ∩ v) = ∅ [PROOFSTEP] rw [huv.inter_eq, inter_empty] [GOAL] α✝ : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α✝ s t u v : Set α✝ α : Type u_3 inst✝¹ : TopologicalSpace α inst✝ : TotallySeparatedSpace α x y : α hxy : x ≠ y ⊢ ∃ U, IsClopen U ∧ x ∈ U ∧ y ∈ Uᶜ [PROOFSTEP] obtain ⟨U, V, hU, hV, Ux, Vy, f, disj⟩ := TotallySeparatedSpace.isTotallySeparated_univ x (Set.mem_univ x) y (Set.mem_univ y) hxy [GOAL] case intro.intro.intro.intro.intro.intro.intro α✝ : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α✝ s t u v : Set α✝ α : Type u_3 inst✝¹ : TopologicalSpace α inst✝ : TotallySeparatedSpace α x y : α hxy : x ≠ y U V : Set α hU : IsOpen U hV : IsOpen V Ux : x ∈ U Vy : y ∈ V f : univ ⊆ U ∪ V disj : Disjoint U V ⊢ ∃ U, IsClopen U ∧ x ∈ U ∧ y ∈ Uᶜ [PROOFSTEP] have clopen_U := isClopen_inter_of_disjoint_cover_clopen isClopen_univ f hU hV disj [GOAL] case intro.intro.intro.intro.intro.intro.intro α✝ : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α✝ s t u v : Set α✝ α : Type u_3 inst✝¹ : TopologicalSpace α inst✝ : TotallySeparatedSpace α x y : α hxy : x ≠ y U V : Set α hU : IsOpen U hV : IsOpen V Ux : x ∈ U Vy : y ∈ V f : univ ⊆ U ∪ V disj : Disjoint U V clopen_U : IsClopen (univ ∩ U) ⊢ ∃ U, IsClopen U ∧ x ∈ U ∧ y ∈ Uᶜ [PROOFSTEP] rw [univ_inter _] at clopen_U [GOAL] case intro.intro.intro.intro.intro.intro.intro α✝ : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α✝ s t u v : Set α✝ α : Type u_3 inst✝¹ : TopologicalSpace α inst✝ : TotallySeparatedSpace α x y : α hxy : x ≠ y U V : Set α hU : IsOpen U hV : IsOpen V Ux : x ∈ U Vy : y ∈ V f : univ ⊆ U ∪ V disj : Disjoint U V clopen_U : IsClopen U ⊢ ∃ U, IsClopen U ∧ x ∈ U ∧ y ∈ Uᶜ [PROOFSTEP] rw [← Set.subset_compl_iff_disjoint_right, subset_compl_comm] at disj [GOAL] case intro.intro.intro.intro.intro.intro.intro α✝ : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α✝ s t u v : Set α✝ α : Type u_3 inst✝¹ : TopologicalSpace α inst✝ : TotallySeparatedSpace α x y : α hxy : x ≠ y U V : Set α hU : IsOpen U hV : IsOpen V Ux : x ∈ U Vy : y ∈ V f : univ ⊆ U ∪ V disj : V ⊆ Uᶜ clopen_U : IsClopen U ⊢ ∃ U, IsClopen U ∧ x ∈ U ∧ y ∈ Uᶜ [PROOFSTEP] exact ⟨U, clopen_U, Ux, disj Vy⟩ [GOAL] α✝ : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝¹ : TopologicalSpace α✝ s t u v : Set α✝ α : Type u_3 inst✝ : TopologicalSpace α x : α ⊢ connectedComponent x = connectedComponent x [PROOFSTEP] trivial [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β h : Continuous f ⊢ ∀ (a b : α), Setoid.r a b → f a = f b [PROOFSTEP] convert h.image_eq_of_connectedComponent_eq [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β x : α ⊢ ConnectedComponents.mk ⁻¹' {ConnectedComponents.mk x} = connectedComponent x [PROOFSTEP] ext y [GOAL] case h α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β x y : α ⊢ y ∈ ConnectedComponents.mk ⁻¹' {ConnectedComponents.mk x} ↔ y ∈ connectedComponent x [PROOFSTEP] rw [mem_preimage, mem_singleton_iff, ConnectedComponents.coe_eq_coe'] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β U : Set α ⊢ ConnectedComponents.mk ⁻¹' (ConnectedComponents.mk '' U) = ⋃ (x : α) (_ : x ∈ U), connectedComponent x [PROOFSTEP] simp only [connectedComponents_preimage_singleton, preimage_iUnion₂, image_eq_iUnion] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β ⊢ TotallyDisconnectedSpace (ConnectedComponents α) [PROOFSTEP] rw [totallyDisconnectedSpace_iff_connectedComponent_singleton] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β ⊢ ∀ (x : ConnectedComponents α), connectedComponent x = {x} [PROOFSTEP] refine' ConnectedComponents.surjective_coe.forall.2 fun x => _ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β x : α ⊢ connectedComponent (mk x) = {mk x} [PROOFSTEP] rw [← ConnectedComponents.quotientMap_coe.image_connectedComponent, ← connectedComponents_preimage_singleton, image_preimage_eq _ ConnectedComponents.surjective_coe] [GOAL] case h_fibers α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β x : α ⊢ ∀ (y : ConnectedComponents α), IsConnected (mk ⁻¹' {y}) [PROOFSTEP] refine' ConnectedComponents.surjective_coe.forall.2 fun y => _ [GOAL] case h_fibers α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β x y : α ⊢ IsConnected (mk ⁻¹' {mk y}) [PROOFSTEP] rw [connectedComponents_preimage_singleton] [GOAL] case h_fibers α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β inst✝ : TotallyDisconnectedSpace β f : α → β x y : α ⊢ IsConnected (connectedComponent y) [PROOFSTEP] exact isConnected_connectedComponent [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y ⊢ IsPreconnected s [PROOFSTEP] unfold IsPreconnected [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y ⊢ ∀ (u v : Set α), IsOpen u → IsOpen v → s ⊆ u ∪ v → Set.Nonempty (s ∩ u) → Set.Nonempty (s ∩ v) → Set.Nonempty (s ∩ (u ∩ v)) [PROOFSTEP] by_contra' [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u v s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y this : ∃ u v, IsOpen u ∧ IsOpen v ∧ s ⊆ u ∪ v ∧ Set.Nonempty (s ∩ u) ∧ Set.Nonempty (s ∩ v) ∧ ¬Set.Nonempty (s ∩ (u ∩ v)) ⊢ False [PROOFSTEP] rcases this with ⟨u, v, u_op, v_op, hsuv, ⟨x, x_in_s, x_in_u⟩, ⟨y, y_in_s, y_in_v⟩, H⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : ¬Set.Nonempty (s ∩ (u ∩ v)) y : α y_in_s : y ∈ s y_in_v : y ∈ v ⊢ False [PROOFSTEP] rw [not_nonempty_iff_eq_empty] at H [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : s ∩ (u ∩ v) = ∅ y : α y_in_s : y ∈ s y_in_v : y ∈ v ⊢ False [PROOFSTEP] have hy : y ∉ u := fun y_in_u => eq_empty_iff_forall_not_mem.mp H y ⟨y_in_s, ⟨y_in_u, y_in_v⟩⟩ [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : s ∩ (u ∩ v) = ∅ y : α y_in_s : y ∈ s y_in_v : y ∈ v hy : ¬y ∈ u ⊢ False [PROOFSTEP] have : ContinuousOn u.boolIndicator s := by apply (continuousOn_boolIndicator_iff_clopen _ _).mpr ⟨_, _⟩ · exact u_op.preimage continuous_subtype_val · rw [preimage_subtype_coe_eq_compl hsuv H] exact (v_op.preimage continuous_subtype_val).isClosed_compl [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : s ∩ (u ∩ v) = ∅ y : α y_in_s : y ∈ s y_in_v : y ∈ v hy : ¬y ∈ u ⊢ ContinuousOn (boolIndicator u) s [PROOFSTEP] apply (continuousOn_boolIndicator_iff_clopen _ _).mpr ⟨_, _⟩ [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : s ∩ (u ∩ v) = ∅ y : α y_in_s : y ∈ s y_in_v : y ∈ v hy : ¬y ∈ u ⊢ IsOpen (Subtype.val ⁻¹' u) [PROOFSTEP] exact u_op.preimage continuous_subtype_val [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : s ∩ (u ∩ v) = ∅ y : α y_in_s : y ∈ s y_in_v : y ∈ v hy : ¬y ∈ u ⊢ IsClosed (Subtype.val ⁻¹' u) [PROOFSTEP] rw [preimage_subtype_coe_eq_compl hsuv H] [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : s ∩ (u ∩ v) = ∅ y : α y_in_s : y ∈ s y_in_v : y ∈ v hy : ¬y ∈ u ⊢ IsClosed (Subtype.val ⁻¹' v)ᶜ [PROOFSTEP] exact (v_op.preimage continuous_subtype_val).isClosed_compl [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝ : TopologicalSpace α s✝ t u✝ v✝ s : Set α hs : ∀ (f : α → Bool), ContinuousOn f s → ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y u v : Set α u_op : IsOpen u v_op : IsOpen v hsuv : s ⊆ u ∪ v x : α x_in_s : x ∈ s x_in_u : x ∈ u H : s ∩ (u ∩ v) = ∅ y : α y_in_s : y ∈ s y_in_v : y ∈ v hy : ¬y ∈ u this : ContinuousOn (boolIndicator u) s ⊢ False [PROOFSTEP] simpa [(u.mem_iff_boolIndicator _).mp x_in_u, (u.not_mem_iff_boolIndicator _).mp hy] using hs _ this x x_in_s y y_in_s [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β S : Set α hS : IsPreconnected S T : Set β inst✝ : DiscreteTopology ↑T f : α → β hc : ContinuousOn f S hTm : MapsTo f S T x y : α hx : x ∈ S hy : y ∈ S ⊢ f x = f y [PROOFSTEP] let F : S → T := hTm.restrict f S T [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β S : Set α hS : IsPreconnected S T : Set β inst✝ : DiscreteTopology ↑T f : α → β hc : ContinuousOn f S hTm : MapsTo f S T x y : α hx : x ∈ S hy : y ∈ S F : ↑S → ↑T := MapsTo.restrict f S T hTm ⊢ f x = f y [PROOFSTEP] suffices F ⟨x, hx⟩ = F ⟨y, hy⟩ by rwa [← Subtype.coe_inj] at this [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β S : Set α hS : IsPreconnected S T : Set β inst✝ : DiscreteTopology ↑T f : α → β hc : ContinuousOn f S hTm : MapsTo f S T x y : α hx : x ∈ S hy : y ∈ S F : ↑S → ↑T := MapsTo.restrict f S T hTm this : F { val := x, property := hx } = F { val := y, property := hy } ⊢ f x = f y [PROOFSTEP] rwa [← Subtype.coe_inj] at this [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β S : Set α hS : IsPreconnected S T : Set β inst✝ : DiscreteTopology ↑T f : α → β hc : ContinuousOn f S hTm : MapsTo f S T x y : α hx : x ∈ S hy : y ∈ S F : ↑S → ↑T := MapsTo.restrict f S T hTm ⊢ F { val := x, property := hx } = F { val := y, property := hy } [PROOFSTEP] exact (isPreconnected_iff_preconnectedSpace.mp hS).constant (hc.restrict_mapsTo _) [GOAL] α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β S : Set α hS : IsPreconnected S T : Set β inst✝ : DiscreteTopology ↑T f : α → β hc : ContinuousOn f S hTm : MapsTo f S T hne : Set.Nonempty T ⊢ ∃ y, y ∈ T ∧ EqOn f (const α y) S [PROOFSTEP] rcases S.eq_empty_or_nonempty with (rfl | ⟨x, hx⟩) [GOAL] case inl α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β T : Set β inst✝ : DiscreteTopology ↑T f : α → β hne : Set.Nonempty T hS : IsPreconnected ∅ hc : ContinuousOn f ∅ hTm : MapsTo f ∅ T ⊢ ∃ y, y ∈ T ∧ EqOn f (const α y) ∅ [PROOFSTEP] exact hne.imp fun _ hy => ⟨hy, eqOn_empty _ _⟩ [GOAL] case inr.intro α : Type u β : Type v ι : Type u_1 π : ι → Type u_2 inst✝² : TopologicalSpace α s t u v : Set α inst✝¹ : TopologicalSpace β S : Set α hS : IsPreconnected S T : Set β inst✝ : DiscreteTopology ↑T f : α → β hc : ContinuousOn f S hTm : MapsTo f S T hne : Set.Nonempty T x : α hx : x ∈ S ⊢ ∃ y, y ∈ T ∧ EqOn f (const α y) S [PROOFSTEP] exact ⟨f x, hTm hx, fun x' hx' => hS.constant_of_mapsTo hc hTm hx' hx⟩
module GameServer.Protocol.Mock import Data.Buffer import Data.List import Network.Socket import Network.Socket.Data import Network.Socket.Raw import System import GameServer.Protocol.Options import GameServer.Protocol.Messages import GameServer.Protocol.Binary %cg chez libidris_net.so handleClient : Socket -> SocketAddress -> (len_buf : BufPtr) -> IO () handleClient socket addr len_buf = do putStrLn $ "waiting for input" Right res <- recvBuf socket len_buf 8 -- receive 8 bytes representing length of message | Left err => do putStrLn ("failed to read length of message " ++ show err) ; close socket if res < 0 then do putStrLn ("error reading message length: " ++ show res) ; close socket else do len <- read64be len_buf data_buf <- sock_alloc (cast len) Right res <- recvBuf socket data_buf (fromInteger len) | Left err => do putStrLn ("failed to read message of len " ++ show len ++ ": " ++ show err) ; sock_free data_buf ; close socket if res < 0 then do putStrLn ("failed to read message " ++ show res) ; sock_free data_buf ; close socket else do Right msg <- decodeMessage data_buf len | Left err => do putStrLn ("failed to decode message " ++ show err) ; sock_free data_buf print msg sock_free data_buf handleClient socket addr len_buf serve : Socket -> IO (Either String ()) serve sock = do Right (s, addr) <- accept sock | Left err => pure (Left $ "Failed to accept on socket with error: " ++ show err) pid <- fork $ do len_buf <- sock_alloc 8 handleClient s addr len_buf serve sock export server : Int -> String -> IO (Either String ()) server port host = do Right sock <- socket AF_INET Stream 0 | Left fail => pure (Left $ "Failed to open socket: " ++ show fail) res <- bind sock (Just (Hostname host)) port if res /= 0 then pure (Left $ "Failed to bind socket with error: " ++ show res) else do res <- listen sock if res /= 0 then pure (Left $ "Failed to listen on socket with error: " ++ show res) else serve sock export mock : Options -> IO (Either String ()) mock (MkOptions port host MockMode) = server port host mock _ = pure $ Left "invalid mode for mock server"
#single tissue top #gtex v8 args<-as.numeric(commandArgs(TRUE)) folder='top' #set up sub jobs run_id<-1 run_list<-list() for (i in c(22)){ #tissues for (j in 1:40){ #subjobs per tissue run_list[[run_id]]<-c(i,j) run_id=run_id+1 } } run_i<-run_list[[args[1]]] print(run_i) #tissue tissue_list<-dir('/data/c***/z***/data/gtex/exp/v8/weighted/') tissue<-tissue_list[run_i[1]] #mkdir com<-paste0('mkdir /data/c***/z***/projects/gtex/weights/',folder,'/ ; mkdir /data/c***/z***/projects/gtex/weights/',folder,'/',tissue) system(command = com, wait = T) #get gene list exp_list<-sub('....$','',dir(paste0('/data/c***/z***/data/gtex/exp/v8/weighted/',tissue))) geno_list<-sub('....$','',dir('/data/c***/z***/data/gtex/geno/v8/gene/dosage_1m/')) gene_list<-intersect(exp_list,geno_list) #start and end id i_start=(run_i[2]-1)*500+1 i_end=run_i[2]*500 if (i_end>length(gene_list)){ i_end=length(gene_list) } #--------------------------- output<-as.data.frame(matrix(data=NA,nrow = 0,ncol=8)) if (i_start<length(gene_list)){ for (i in i_start:i_end){ print(i) #input geno and snp info geno<-readRDS(paste0('/data/c***/z***/data/gtex/geno/v8/gene/dosage_1m/',gene_list[i],'.rds')) geno[,1]<-paste0('GTEX.',geno[,1]) snp_info<-readRDS(paste0('/data/c***/z***/data/gtex/geno/v8/gene/info_1m/',gene_list[i],'.rds')) #input expression levels exp<-readRDS(paste0('/data/c***/z***/data/gtex/exp/v8/weighted/',tissue,'/',gene_list[i],'.rds')) exp<-exp[exp$tissue==tissue,] #only keeps expression in target tissue #merge d<-merge(exp,geno,by='sampleid') #find the top find_top_p<-c() find_top_beta<-c() find_top_r<-c() for (j in 1:(ncol(d)-4)){ ans<-summary(lm(d$exp~d[,j+4])) find_top_beta[j]<-ans$coefficients['d[, j + 4]','Estimate'] find_top_p[j]<-ans$coefficients['d[, j + 4]','Pr(>|t|)'] find_top_r[j]<-abs(cor(d$exp,d[,j+4])) } top<-which.min(find_top_p) rsid<-colnames(d)[top+4] snp_info<-snp_info[snp_info$rsid==rsid,] snp_info$weight<-find_top_beta[top] snp_info$gene<-gene_list[i] snp_info$r2<-find_top_r[top]^2 snp_info$p<-find_top_p[top] snp_info$lambda=0 snp_info<-snp_info[,c(6,1,2,3,4,5,7,8,9)] snp_info<-snp_info[snp_info$weight!=0,] output<-snp_info #writeRDS if (nrow(output)>0 & find_top_p[top]<0.05 & find_top_r[top]>0.1){ out_path<-paste0('/data/c***/z***/projects/gtex/weights/',folder,'/',tissue,'/',gene_list[i],'.rds') saveRDS(output,file=out_path) } } }else{ print('out of range') }
\name{ComplexHeatmap-package} \docType{package} \alias{ComplexHeatmap-package} \title{ Make complex heatmaps } \description{ Make complex heatmaps } \details{ This package aims to provide a simple and flexible way to arrange multiple heatmaps as well as flexible annotation graphics. The package is implemented in an object-oriented way. The heatmap lists are abstracted into several classes. \itemize{ \item \code{\link{Heatmap-class}}: a single heatmap containing heatmap body, row/column names, titles, dendrograms and annotations. \item \code{\link{HeatmapList-class}}: a list of heatmaps and annotations. \item \code{\link{HeatmapAnnotation-class}}: a list of row/column annotations. } There are also several internal classes: \itemize{ \item \code{\link{SingleAnnotation-class}}: a single row annotation or column annotation. \item \code{\link{ColorMapping-class}}: mapping from values to colors. \item \code{\link{AnnotationFunction-class}}: construct an annotation function which allows subsetting. } Following two high-level functions take use of functionality of complex heatmaps: \itemize{ \item \code{\link{oncoPrint}}: oncoPrint plot which visualize genomic alterations in a set of genes. \item \code{\link{densityHeatmap}}: use heatmaps to visualize density distributions. } The complete reference of ComplexHeatmap package is available at \url{http://jokergoo.github.io/ComplexHeatmap-reference/book.} } \examples{ # There is no example NULL }
#' Write msf api objects to disk #' #' @param j a list representing a json object #' @param datadir base directory to write files into #' @export write_msf <- function(j, datadir = ".") { path <- file.path(datadir, attr(j, "local_path")) # create directory if it doesn't exist if (!dir.exists(dirname(path))) { dir.create(dirname(path), recursive = TRUE) } jsonlite::write_json(j, path) path } #' Read msf api objects from disk #' #' @param path filepath where data is located #' @export read_msf <- function(path) { j <- jsonlite::read_json(path, simplifyVector = TRUE, simplifyDataFrame = FALSE, simplifyMatrix = FALSE) obj <- new_api(j, path) attr(obj, "local_path") <- path obj }
In 1966 , Reines took most of his neutrino research team with him when he left for the new University of California , Irvine ( UCI ) , becoming its first dean of physical sciences . At UCI , Reines extended the research interests of some of his graduate students into the development of medical radiation detectors , such as for measuring total radiation delivered to the whole human body in radiation therapy .
module Module import Monoid import Group import Ring import Group_property import NatUtils --(modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> -- ((*) : ring -> ring -> ring) -> (IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) --This just the data required for a module, the set modu and a ring. So, this big chunk of code will appear everywhere |||Type of operation between a ring and a moduule that distributes over addition of the ring total dotDistributesOverRing : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> Type dotDistributesOverRing modu ring (+) (++) (*) prfRing (.) = (r : ring) -> (s : ring) -> (m : modu) -> ((r ++ s) . m = (r . m) + (s . m)) |||Type of operation between a ring and a moduuule that distributes over addition of the Module total dotDistributesOverModule : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> Type dotDistributesOverModule modu ring (+) (++) (*) prfRing (.) = (m : modu) -> (n : modu) -> (r : ring) -> (r . (m + n) = (r . m) + (r . n)) |||Type of operation that respects ring multiplication total dotRespectsRingMult : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> Type dotRespectsRingMult modu ring (+) (++) (*) prfRing (.) = (r : ring) -> (s : ring) -> (m : modu) -> ((r*s) . m = r . (s . m)) |||Type of operation that maps 1.m to m. total dotRespectsIdentity : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> Type dotRespectsIdentity modu ring (+) (++) (*) prfRing (.) = (m : modu) -> (e . m = m) where e = fst (snd (fst (snd prfRing))) |||The type of a Module. As the operations on the set modu determines it's abelianess property, we should only include the operation on the set modu and the operation between the set modu and the ring total IsleftModule : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> Type IsleftModule modu ring (+) (++) (*) prfRing (.) = ((IsAbelianGrp modu (+)) , (dotRespectsIdentity modu ring (+) (++) (*) prfRing (.) , (dotDistributesOverRing modu ring (+) (++) (*) prfRing (.) , ( dotDistributesOverModule modu ring (+) (++) (*) prfRing (.) , dotRespectsRingMult modu ring (+) (++) (*) prfRing (.))))) --Below are a bunch of auxiliary functions to get recover dot distributing over blah from the envelope Type IsleftModule |||Gives the Abelian Group property of a module total AbelianAddition : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (IsleftModule modu ring (+) (++) (*) prfRing (.)) -> (IsAbelianGrp modu (+)) AbelianAddition modu ring (+) (++) (*) prfRing (.) prfLeftModule = fst (prfLeftModule) |||Gives the Zero of the Module total ZeroOfModule : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (IsleftModule modu ring (+) (++) (*) prfRing (.)) -> (e : modu ** ((a : modu) -> (a + e = a , e + a = a))) ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule = fst (snd (fst (fst (prfLeftModule)))) |||Gives the dot distributes over Ring addition property of the module total dotOverRingAdd : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (IsleftModule modu ring (+) (++) (*) prfRing (.)) -> dotDistributesOverRing modu ring (+) (++) (*) prfRing (.) dotOverRingAdd modu ring (+) (++) (*) prfRing (.) prfLeftModule = fst (snd (snd (prfLeftModule))) |||Gives the dot distributes over module addition property of the module total dotOverModuleAdd : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (IsleftModule modu ring (+) (++) (*) prfRing (.)) -> dotDistributesOverModule modu ring (+) (++) (*) prfRing (.) dotOverModuleAdd modu ring (+) (++) (*) prfRing (.) prfLeftModule = fst (snd (snd (snd (prfLeftModule)))) |||Gives the dot Associates with ring multiplication property of the module total dotAssociatesRingMult : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (IsleftModule modu ring (+) (++) (*) prfRing (.)) -> dotRespectsRingMult modu ring (+) (++) (*) prfRing (.) dotAssociatesRingMult modu ring (+) (++) (*) prfRing (.) prfLeftModule = snd (snd (snd (snd (prfLeftModule)))) |||Gives the dot Associates with ring multiplication property of the module total dotRingIdentity : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (IsleftModule modu ring (+) (++) (*) prfRing (.)) -> dotRespectsIdentity modu ring (+) (++) (*) prfRing (.) dotRingIdentity modu ring (+) (++) (*) prfRing (.) prfLeftModule = fst (snd (prfLeftModule)) |||Proof that r*0 = 0 for all r in the underlying ring total RingMultZeroEqualsZero : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (prfLeftModule : IsleftModule modu ring (+) (++) (*) prfRing (.)) -> ((r : ring) -> (r . (fst (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule)) = (fst (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule)))) RingMultZeroEqualsZero modu ring (+) (++) (*) prfRing (.) prfLeftModule = k where e : modu e = fst (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule) u : ring -> modu -> modu u r m = r . m f : (r : ring) -> (r . (e + e) = (r . e) + (r . e)) f r = (dotOverModuleAdd modu ring (+) (++) (*) prfRing (.) prfLeftModule e e r) g : (r : ring) -> (r . (e + e) = r . e) g r = (cong (fst ((snd (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule)) e))) h : (r : ring) -> (r . e = (r . e) + (r . e)) h r = (trans (sym (g r)) (f r)) i : (r : ring) -> ((r . e) + e = (r . e)) i r = (fst ((snd (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule)) (r . e))) j : (r : ring) -> ((r . e) + e = (r . e) + (r . e)) j r = (trans (i r) (h r)) k : (r : ring) -> ((r . e) = e) k r = (sym (Group_property_4 modu (+) (fst (fst prfLeftModule)) (r . e) e (r . e) (j r))) |||Proof that 0*m = 0 for m in the module total ZeroMultModuleEqualsZero : (modu : Type) -> (ring : Type) -> ((+) : modu -> modu -> modu) -> ((++) : ring -> ring -> ring) -> ((*) : ring -> ring -> ring) -> (prfRing : IsRing_with_identity ring (++) (*)) -> ((.) : ring -> modu -> modu) -> (prfLeftModule : IsleftModule modu ring (+) (++) (*) prfRing (.)) -> ((m : modu) -> ((fst (fst (snd (fst (fst prfRing))))) . m = fst (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule))) ZeroMultModuleEqualsZero modu ring (+) (++) (*) prfRing (.) prfLeftModule = k where e : modu e = fst (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule) z : ring z = fst (fst (snd (fst (fst prfRing)))) u : modu -> ring -> modu u m r = r . m f : (m : modu) -> ((z ++ z) . m = (z . m) + (z . m)) f m = (dotOverRingAdd modu ring (+) (++) (*) prfRing (.) prfLeftModule z z m) g : (m : modu) -> ((z ++ z) . m = z . m) g m = (functionExtendsEquality2 ring modu (u m) (z ++ z) z (fst (snd (fst (snd (fst (fst prfRing)))) z))) h : (m : modu) -> (z . m = (z . m) + (z . m)) h m = (trans (sym (g m)) (f m)) i : (m : modu) -> ((z . m) + e = (z . m)) i m = (fst ((snd (ZeroOfModule modu ring (+) (++) (*) prfRing (.) prfLeftModule)) (z . m))) j : (m : modu) -> ((z . m) + e = (z . m) + (z . m)) j m = (trans (i m) (h m)) k : (m : modu) -> ((z . m) = e) k m = (sym (Group_property_4 modu (+) (fst (fst prfLeftModule)) (z . m) e (z . m) (j m)))
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Ring where open import Cubical.Algebra.Ring.Base public open import Cubical.Algebra.Ring.Properties public open import Cubical.Algebra.Ring.Ideal public open import Cubical.Algebra.Ring.Kernel public
Formal statement is: lemma fact_cancel: fixes c :: "'a::real_field" shows "of_nat (Suc n) * c / (fact (Suc n)) = c / (fact n)" Informal statement is: For any real number $c$ and any natural number $n$, we have $\frac{(n+1)c}{(n+1)!} = \frac{c}{n!}$.
make_GL3_2 := proc() global GL3_2; local G,L,E,f,n,i,j,k,g,h; G := table(): L := [[]]: for i from 1 to 9 do L := [seq(seq([op(u),j],j=0..1),u in L)]; od: # Strange order ensures that 1 comes first, followed by other # upper unitriangular matrices. f := (u) -> Matrix([[u[7],u[5],u[6]], [u[1],u[8],u[4]], [u[3],u[2],u[9]]]); L := select(u -> mods(Determinant(f(u)),2) <> 0,L); n := nops(L); E := map(f,L); G["elements"] := E; G["index"] := table(): for i from 1 to n do G["index"][convert(E[i],listlist)] := i; od: G["id"] := IdentityMatrix(3); G["o"] := (u,v) -> map(mods,u . v,2); G["inv"] := (u) -> map(mods,1 / u,2); G["o_table"] := table(); G["inv_table"] := table(); for i from 1 to n do g := G["elements"][i]; G["inv_table"][i] := G["index"][convert(G["inv"](g),listlist)]; for j from 1 to n do h := G["elements"][j]; G["o_table"][i,j] := G["index"][convert(G["o"](g,h),listlist)]; od: od: G["ee"] := convert(IdentityMatrix(n),listlist); G["ring_id"] := G["ee"][1]; G["antipode"] := proc(u) local n,M,w,i,j; n := 168; M := eval(GL3_2["inv_table"]); w := [seq(u[M[i]],i=1..n)]; return w; end: G["convolve"] := proc(u,v) local n,J,M,w,i,j,ii; n := 168; J := eval(GL3_2["inv_table"]); M := eval(GL3_2["o_table"]); w := [0$n]; for i from 1 to n do if u[i] <> 0 then ii := J[i]; w := w +~ [seq(u[i] * v[M[ii,j]],j=1..n)]; fi; od; return w; end: G["borel_elements"] := [seq(seq(seq(Matrix([[1,i,j],[0,1,k],[0,0,1]]),i=0..1),j=0..1),k=0..1)]: G["borel_indices"] := map(b -> G["index"][convert(b,listlist)],G["borel_elements"]); G["borel_sum"] := [0$168]: for i in G["borel_indices"] do G["borel_sum"] := G["borel_sum"] +~ G["ee"][i]: od: G["coxeter_elements"] := map(permutation_matrix,combinat[permute](3)): G["coxeter_indices"] := map(w -> G["index"][convert(w,listlist)],G["coxeter_elements"]): G["signed_coxeter_sum"] := [0$168]: for i in G["coxeter_indices"] do G["signed_coxeter_sum"] := G["signed_coxeter_sum"] +~ Determinant(E[i]) *~ G["ee"][i]: od: G["steinberg_idempotent"] := G["convolve"](G["signed_coxeter_sum"], G["borel_sum"]) / 21; GL3_2 := eval(G); return(eval(G)); end:
[GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α y x d : α h : x ≠ y ⊢ nextOr (y :: xs) x d = nextOr xs x d [PROOFSTEP] cases' xs with z zs [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α y x d : α h : x ≠ y ⊢ nextOr [y] x d = nextOr [] x d [PROOFSTEP] rfl [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α y x d : α h : x ≠ y z : α zs : List α ⊢ nextOr (y :: z :: zs) x d = nextOr (z :: zs) x d [PROOFSTEP] exact if_neg h [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem : x ∈ xs x_ne : x ≠ getLast xs (_ : xs ≠ []) ⊢ nextOr xs x d = nextOr xs x d' [PROOFSTEP] induction' xs with y ys IH [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) x_mem : x ∈ [] x_ne : x ≠ getLast [] (_ : [] ≠ []) ⊢ nextOr [] x d = nextOr [] x d' [PROOFSTEP] cases x_mem [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y : α ys : List α IH : ∀ (x_mem : x ∈ ys), x ≠ getLast ys (_ : ys ≠ []) → nextOr ys x d = nextOr ys x d' x_mem : x ∈ y :: ys x_ne : x ≠ getLast (y :: ys) (_ : y :: ys ≠ []) ⊢ nextOr (y :: ys) x d = nextOr (y :: ys) x d' [PROOFSTEP] cases' ys with z zs [GOAL] case cons.nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y : α IH : ∀ (x_mem : x ∈ []), x ≠ getLast [] (_ : [] ≠ []) → nextOr [] x d = nextOr [] x d' x_mem : x ∈ [y] x_ne : x ≠ getLast [y] (_ : [y] ≠ []) ⊢ nextOr [y] x d = nextOr [y] x d' [PROOFSTEP] simp at x_mem x_ne [GOAL] case cons.nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y : α IH : ∀ (x_mem : x ∈ []), x ≠ getLast [] (_ : [] ≠ []) → nextOr [] x d = nextOr [] x d' x_ne : ¬x = y x_mem : x = y ⊢ nextOr [y] x d = nextOr [y] x d' [PROOFSTEP] contradiction [GOAL] case cons.cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y z : α zs : List α IH : ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d' x_mem : x ∈ y :: z :: zs x_ne : x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ []) ⊢ nextOr (y :: z :: zs) x d = nextOr (y :: z :: zs) x d' [PROOFSTEP] by_cases h : x = y [GOAL] case pos α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y z : α zs : List α IH : ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d' x_mem : x ∈ y :: z :: zs x_ne : x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ []) h : x = y ⊢ nextOr (y :: z :: zs) x d = nextOr (y :: z :: zs) x d' [PROOFSTEP] rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons] [GOAL] case neg α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y z : α zs : List α IH : ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d' x_mem : x ∈ y :: z :: zs x_ne : x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ []) h : ¬x = y ⊢ nextOr (y :: z :: zs) x d = nextOr (y :: z :: zs) x d' [PROOFSTEP] rw [nextOr, nextOr, IH] [GOAL] case neg.x_mem α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y z : α zs : List α IH : ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d' x_mem : x ∈ y :: z :: zs x_ne : x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ []) h : ¬x = y ⊢ x ∈ z :: zs [PROOFSTEP] simpa [h] using x_mem [GOAL] case neg.x_ne α : Type u_1 inst✝ : DecidableEq α xs : List α x d d' : α x_mem✝ : x ∈ xs x_ne✝ : x ≠ getLast xs (_ : xs ≠ []) y z : α zs : List α IH : ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d' x_mem : x ∈ y :: z :: zs x_ne : x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ []) h : ¬x = y ⊢ x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) [PROOFSTEP] simpa using x_ne [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h : nextOr xs x d ≠ d ⊢ x ∈ xs [PROOFSTEP] induction' xs with y ys IH [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : nextOr xs x d ≠ d h : nextOr [] x d ≠ d ⊢ x ∈ [] [PROOFSTEP] simp at h [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : nextOr xs x d ≠ d y : α ys : List α IH : nextOr ys x d ≠ d → x ∈ ys h : nextOr (y :: ys) x d ≠ d ⊢ x ∈ y :: ys [PROOFSTEP] cases' ys with z zs [GOAL] case cons.nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : nextOr xs x d ≠ d y : α IH : nextOr [] x d ≠ d → x ∈ [] h : nextOr [y] x d ≠ d ⊢ x ∈ [y] [PROOFSTEP] simp at h [GOAL] case cons.cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : nextOr xs x d ≠ d y z : α zs : List α IH : nextOr (z :: zs) x d ≠ d → x ∈ z :: zs h : nextOr (y :: z :: zs) x d ≠ d ⊢ x ∈ y :: z :: zs [PROOFSTEP] by_cases hx : x = y [GOAL] case pos α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : nextOr xs x d ≠ d y z : α zs : List α IH : nextOr (z :: zs) x d ≠ d → x ∈ z :: zs h : nextOr (y :: z :: zs) x d ≠ d hx : x = y ⊢ x ∈ y :: z :: zs [PROOFSTEP] simp [hx] [GOAL] case neg α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : nextOr xs x d ≠ d y z : α zs : List α IH : nextOr (z :: zs) x d ≠ d → x ∈ z :: zs h : nextOr (y :: z :: zs) x d ≠ d hx : ¬x = y ⊢ x ∈ y :: z :: zs [PROOFSTEP] rw [nextOr_cons_of_ne _ _ _ _ hx] at h [GOAL] case neg α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : nextOr xs x d ≠ d y z : α zs : List α IH : nextOr (z :: zs) x d ≠ d → x ∈ z :: zs h : nextOr (z :: zs) x d ≠ d hx : ¬x = y ⊢ x ∈ y :: z :: zs [PROOFSTEP] simpa [hx] using IH h [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h : ¬x ∈ xs ⊢ nextOr (xs ++ [x]) x d = d [PROOFSTEP] induction' xs with z zs IH [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : ¬x ∈ xs h : ¬x ∈ [] ⊢ nextOr ([] ++ [x]) x d = d [PROOFSTEP] simp [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : ¬x ∈ xs z : α zs : List α IH : ¬x ∈ zs → nextOr (zs ++ [x]) x d = d h : ¬x ∈ z :: zs ⊢ nextOr (z :: zs ++ [x]) x d = d [PROOFSTEP] obtain ⟨hz, hzs⟩ := not_or.mp (mt mem_cons.2 h) [GOAL] case cons.intro α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α h✝ : ¬x ∈ xs z : α zs : List α IH : ¬x ∈ zs → nextOr (zs ++ [x]) x d = d h : ¬x ∈ z :: zs hz : ¬x = z hzs : ¬x ∈ zs ⊢ nextOr (z :: zs ++ [x]) x d = d [PROOFSTEP] rw [cons_append, nextOr_cons_of_ne _ _ _ _ hz, IH hzs] [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α hd : d ∈ xs ⊢ nextOr xs x d ∈ xs [PROOFSTEP] revert hd [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α ⊢ d ∈ xs → nextOr xs x d ∈ xs [PROOFSTEP] suffices ∀ (xs' : List α) (_ : ∀ x ∈ xs, x ∈ xs') (_ : d ∈ xs'), nextOr xs x d ∈ xs' by exact this xs fun _ => id [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α this : ∀ (xs' : List α), (∀ (x : α), x ∈ xs → x ∈ xs') → d ∈ xs' → nextOr xs x d ∈ xs' ⊢ d ∈ xs → nextOr xs x d ∈ xs [PROOFSTEP] exact this xs fun _ => id [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α ⊢ ∀ (xs' : List α), (∀ (x : α), x ∈ xs → x ∈ xs') → d ∈ xs' → nextOr xs x d ∈ xs' [PROOFSTEP] intro xs' hxs' hd [GOAL] α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs' : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' ⊢ nextOr xs x d ∈ xs' [PROOFSTEP] induction' xs with y ys ih [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs'✝ : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' hxs' : ∀ (x : α), x ∈ [] → x ∈ xs' ⊢ nextOr [] x d ∈ xs' [PROOFSTEP] exact hd [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs'✝ : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' y : α ys : List α ih : (∀ (x : α), x ∈ ys → x ∈ xs') → nextOr ys x d ∈ xs' hxs' : ∀ (x : α), x ∈ y :: ys → x ∈ xs' ⊢ nextOr (y :: ys) x d ∈ xs' [PROOFSTEP] cases' ys with z zs [GOAL] case cons.nil α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs'✝ : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' y : α ih : (∀ (x : α), x ∈ [] → x ∈ xs') → nextOr [] x d ∈ xs' hxs' : ∀ (x : α), x ∈ [y] → x ∈ xs' ⊢ nextOr [y] x d ∈ xs' [PROOFSTEP] exact hd [GOAL] case cons.cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs'✝ : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' y z : α zs : List α ih : (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs' hxs' : ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs' ⊢ nextOr (y :: z :: zs) x d ∈ xs' [PROOFSTEP] rw [nextOr] [GOAL] case cons.cons α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs'✝ : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' y z : α zs : List α ih : (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs' hxs' : ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs' ⊢ (if x = y then z else nextOr (z :: zs) x d) ∈ xs' [PROOFSTEP] split_ifs with h [GOAL] case pos α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs'✝ : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' y z : α zs : List α ih : (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs' hxs' : ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs' h : x = y ⊢ z ∈ xs' [PROOFSTEP] exact hxs' _ (mem_cons_of_mem _ (mem_cons_self _ _)) [GOAL] case neg α : Type u_1 inst✝ : DecidableEq α xs : List α x d : α xs' : List α hxs'✝ : ∀ (x : α), x ∈ xs → x ∈ xs' hd : d ∈ xs' y z : α zs : List α ih : (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs' hxs' : ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs' h : ¬x = y ⊢ nextOr (z :: zs) x d ∈ xs' [PROOFSTEP] exact ih fun _ h => hxs' _ (mem_cons_of_mem _ h) [GOAL] α : Type u_1 inst✝ : DecidableEq α x✝ : α h : x✝ ∈ [] ⊢ α [PROOFSTEP] simp at h [GOAL] α : Type u_1 inst✝ : DecidableEq α y z : α xs : List α x : α h : x ∈ y :: z :: xs hx : ¬x = y ⊢ x ∈ z :: xs [PROOFSTEP] simpa [hx] using h [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y z : α h : x ∈ y :: z :: l hx : x = y ⊢ next (y :: z :: l) x h = z [PROOFSTEP] rw [next, nextOr, if_pos hx] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x ≠ getLast (y :: l) (_ : y :: l ≠ []) ⊢ x ∈ l [PROOFSTEP] simpa [hy] using h [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x ≠ getLast (y :: l) (_ : y :: l ≠ []) ⊢ next (y :: l) x h = next l x (_ : x ∈ l) [PROOFSTEP] rw [next, next, nextOr_cons_of_ne _ _ _ _ hy, nextOr_eq_nextOr_of_mem_of_ne] [GOAL] case x_mem α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x ≠ getLast (y :: l) (_ : y :: l ≠ []) ⊢ x ∈ l [PROOFSTEP] rwa [getLast_cons] at hx [GOAL] case x_mem α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x ≠ getLast (y :: l) (_ : y :: l ≠ []) ⊢ l ≠ [] [PROOFSTEP] exact ne_nil_of_mem (by assumption) [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x ≠ getLast (y :: l) (_ : y :: l ≠ []) ⊢ ?m.65756 ∈ l [PROOFSTEP] assumption [GOAL] case x_ne α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x ≠ getLast (y :: l) (_ : y :: l ≠ []) ⊢ x ≠ getLast l (_ : l ≠ []) [PROOFSTEP] rwa [getLast_cons] at hx [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y : α hy : x ≠ y hx : ¬x ∈ l h : optParam (x ∈ y :: l ++ [x]) (_ : x ∈ y :: l ++ [x]) ⊢ next (y :: l ++ [x]) x h = y [PROOFSTEP] rw [next, nextOr_concat] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y : α hy : x ≠ y hx : ¬x ∈ l h : optParam (x ∈ y :: l ++ [x]) (_ : x ∈ y :: l ++ [x]) ⊢ get (y :: l ++ [x]) { val := 0, isLt := (_ : 0 < length (y :: l ++ [x])) } = y [PROOFSTEP] rfl [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α x y : α hy : x ≠ y hx : ¬x ∈ l h : optParam (x ∈ y :: l ++ [x]) (_ : x ∈ y :: l ++ [x]) ⊢ ¬x ∈ y :: l [PROOFSTEP] simp [hy, hx] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x = getLast (y :: l) (_ : y :: l ≠ []) hl : Nodup l ⊢ next (y :: l) x h = y [PROOFSTEP] rw [next, get, ← dropLast_append_getLast (cons_ne_nil y l), hx, nextOr_concat] [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α x : α h✝ : x ∈ l y : α h : x ∈ y :: l hy : x ≠ y hx : x = getLast (y :: l) (_ : y :: l ≠ []) hl : Nodup l ⊢ ¬getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) [PROOFSTEP] subst hx [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y ⊢ ¬getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) [PROOFSTEP] intro H [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) ⊢ False [PROOFSTEP] obtain ⟨⟨_ | k, hk⟩, hk'⟩ := get_of_mem H [GOAL] case h.intro.mk.zero α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) hk : Nat.zero < length (dropLast (y :: l)) hk' : get (dropLast (y :: l)) { val := Nat.zero, isLt := hk } = getLast (y :: l) (_ : y :: l ≠ []) ⊢ False [PROOFSTEP] rw [← Option.some_inj] at hk' [GOAL] case h.intro.mk.zero α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) hk : Nat.zero < length (dropLast (y :: l)) hk' : some (get (dropLast (y :: l)) { val := Nat.zero, isLt := hk }) = some (getLast (y :: l) (_ : y :: l ≠ [])) ⊢ False [PROOFSTEP] rw [← get?_eq_get, dropLast_eq_take, get?_take, get?_zero, head?_cons, Option.some_inj] at hk' [GOAL] case h.intro.mk.zero α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) hk : Nat.zero < length (dropLast (y :: l)) hk' : y = getLast (y :: l) (_ : y :: l ≠ []) ⊢ False case h.intro.mk.zero α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) hk : Nat.zero < length (dropLast (y :: l)) hk' : get? (take (Nat.pred (length (y :: l))) (y :: l)) Nat.zero = some (getLast (y :: l) (_ : y :: l ≠ [])) ⊢ Nat.zero < Nat.pred (length (y :: l)) [PROOFSTEP] exact hy (Eq.symm hk') [GOAL] case h.intro.mk.zero α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) hk : Nat.zero < length (dropLast (y :: l)) hk' : get? (take (Nat.pred (length (y :: l))) (y :: l)) Nat.zero = some (getLast (y :: l) (_ : y :: l ≠ [])) ⊢ Nat.zero < Nat.pred (length (y :: l)) [PROOFSTEP] rw [Nat.zero_eq, length_cons, Nat.pred_succ] [GOAL] case h.intro.mk.zero α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) hk : Nat.zero < length (dropLast (y :: l)) hk' : get? (take (Nat.pred (length (y :: l))) (y :: l)) Nat.zero = some (getLast (y :: l) (_ : y :: l ≠ [])) ⊢ 0 < length l [PROOFSTEP] exact length_pos_of_mem (by assumption) [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) hk : Nat.zero < length (dropLast (y :: l)) hk' : get? (take (Nat.pred (length (y :: l))) (y :: l)) Nat.zero = some (getLast (y :: l) (_ : y :: l ≠ [])) ⊢ ?m.71859 ∈ l [PROOFSTEP] assumption [GOAL] case h.intro.mk.succ α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) k : ℕ hk : Nat.succ k < length (dropLast (y :: l)) hk' : get (dropLast (y :: l)) { val := Nat.succ k, isLt := hk } = getLast (y :: l) (_ : y :: l ≠ []) ⊢ False [PROOFSTEP] suffices k.succ = l.length by simp [this] at hk [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) k : ℕ hk : Nat.succ k < length (dropLast (y :: l)) hk' : get (dropLast (y :: l)) { val := Nat.succ k, isLt := hk } = getLast (y :: l) (_ : y :: l ≠ []) this : Nat.succ k = length l ⊢ False [PROOFSTEP] simp [this] at hk [GOAL] case h.intro.mk.succ α : Type u_1 inst✝ : DecidableEq α l : List α y : α hl : Nodup l h✝ : getLast (y :: l) (_ : y :: l ≠ []) ∈ l h : getLast (y :: l) (_ : y :: l ≠ []) ∈ y :: l hy : getLast (y :: l) (_ : y :: l ≠ []) ≠ y H : getLast (y :: l) (_ : y :: l ≠ []) ∈ dropLast (y :: l) k : ℕ hk : Nat.succ k < length (dropLast (y :: l)) hk' : get (dropLast (y :: l)) { val := Nat.succ k, isLt := hk } = getLast (y :: l) (_ : y :: l ≠ []) ⊢ Nat.succ k = length l [PROOFSTEP] cases' l with hd tl [GOAL] case h.intro.mk.succ.nil α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hl : Nodup [] h✝ : getLast [y] (_ : [y] ≠ []) ∈ [] h : getLast [y] (_ : [y] ≠ []) ∈ [y] hy : getLast [y] (_ : [y] ≠ []) ≠ y H : getLast [y] (_ : [y] ≠ []) ∈ dropLast [y] hk : Nat.succ k < length (dropLast [y]) hk' : get (dropLast [y]) { val := Nat.succ k, isLt := hk } = getLast [y] (_ : [y] ≠ []) ⊢ Nat.succ k = length [] [PROOFSTEP] simp at hk [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Nodup (hd :: tl) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get (dropLast (y :: hd :: tl)) { val := Nat.succ k, isLt := hk } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ Nat.succ k = length (hd :: tl) [PROOFSTEP] rw [nodup_iff_injective_get] at hl [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get (dropLast (y :: hd :: tl)) { val := Nat.succ k, isLt := hk } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ Nat.succ k = length (hd :: tl) [PROOFSTEP] rw [length, Nat.succ_inj'] [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get (dropLast (y :: hd :: tl)) { val := Nat.succ k, isLt := hk } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ k = length tl [PROOFSTEP] refine' Fin.veq_of_eq (@hl ⟨k, Nat.lt_of_succ_lt <| by simpa using hk⟩ ⟨tl.length, by simp⟩ _) [GOAL] α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get (dropLast (y :: hd :: tl)) { val := Nat.succ k, isLt := hk } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ Nat.succ k < length (hd :: tl) [PROOFSTEP] simpa using hk [GOAL] α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get (dropLast (y :: hd :: tl)) { val := Nat.succ k, isLt := hk } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ length tl < length (hd :: tl) [PROOFSTEP] simp [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get (dropLast (y :: hd :: tl)) { val := Nat.succ k, isLt := hk } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ get (hd :: tl) { val := k, isLt := (_ : k < length (hd :: tl)) } = get (hd :: tl) { val := length tl, isLt := (_ : length tl < Nat.succ (length tl)) } [PROOFSTEP] rw [← Option.some_inj] at hk' [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : some (get (dropLast (y :: hd :: tl)) { val := Nat.succ k, isLt := hk }) = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) ⊢ get (hd :: tl) { val := k, isLt := (_ : k < length (hd :: tl)) } = get (hd :: tl) { val := length tl, isLt := (_ : length tl < Nat.succ (length tl)) } [PROOFSTEP] rw [← get?_eq_get, dropLast_eq_take, get?_take, get?, get?_eq_get, Option.some_inj] at hk' [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk'✝ : get? (hd :: tl) k = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) hk' : get (hd :: tl) { val := k, isLt := ?h.intro.mk.succ.cons } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ get (hd :: tl) { val := k, isLt := (_ : k < length (hd :: tl)) } = get (hd :: tl) { val := length tl, isLt := (_ : length tl < Nat.succ (length tl)) } case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get? (hd :: tl) k = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) ⊢ k < length (hd :: tl) case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get? (hd :: tl) k = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) ⊢ k < length (hd :: tl) case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get? (take (Nat.pred (length (y :: hd :: tl))) (y :: hd :: tl)) (Nat.succ k) = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) ⊢ Nat.succ k < Nat.pred (length (y :: hd :: tl)) [PROOFSTEP] rw [hk'] [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk'✝ : get? (hd :: tl) k = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) hk' : get (hd :: tl) { val := k, isLt := (_ : k < length (hd :: tl)) } = getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ⊢ getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) = get (hd :: tl) { val := length tl, isLt := (_ : length tl < Nat.succ (length tl)) } case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get? (take (Nat.pred (length (y :: hd :: tl))) (y :: hd :: tl)) (Nat.succ k) = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) ⊢ Nat.succ k < Nat.pred (length (y :: hd :: tl)) [PROOFSTEP] simp [getLast_eq_get] [GOAL] case h.intro.mk.succ.cons α : Type u_1 inst✝ : DecidableEq α y : α k : ℕ hd : α tl : List α hl : Function.Injective (get (hd :: tl)) h✝ : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ hd :: tl h : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ y :: hd :: tl hy : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ≠ y H : getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ []) ∈ dropLast (y :: hd :: tl) hk : Nat.succ k < length (dropLast (y :: hd :: tl)) hk' : get? (take (Nat.pred (length (y :: hd :: tl))) (y :: hd :: tl)) (Nat.succ k) = some (getLast (y :: hd :: tl) (_ : y :: hd :: tl ≠ [])) ⊢ Nat.succ k < Nat.pred (length (y :: hd :: tl)) [PROOFSTEP] simpa using hk [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y : α hxy : x ∈ y :: l hx : x = y ⊢ prev (y :: l) x hxy = getLast (y :: l) (_ : y :: l ≠ []) [PROOFSTEP] cases l [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α x y : α hx : x = y hxy : x ∈ [y] ⊢ prev [y] x hxy = getLast [y] (_ : [y] ≠ []) [PROOFSTEP] simp [prev, hx] [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α x y : α hx : x = y head✝ : α tail✝ : List α hxy : x ∈ y :: head✝ :: tail✝ ⊢ prev (y :: head✝ :: tail✝) x hxy = getLast (y :: head✝ :: tail✝) (_ : y :: head✝ :: tail✝ ≠ []) [PROOFSTEP] simp [prev, hx] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y z : α h : x ∈ y :: z :: l hx : x = y ⊢ prev (y :: z :: l) x h = getLast (z :: l) (_ : z :: l ≠ []) [PROOFSTEP] rw [prev, dif_pos hx] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y z : α h : x ∈ y :: z :: l hy : x ≠ y hz : x = z ⊢ prev (y :: z :: l) x h = y [PROOFSTEP] cases l [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α x y z : α hy : x ≠ y hz : x = z h : x ∈ [y, z] ⊢ prev [y, z] x h = y [PROOFSTEP] simp [prev, hy, hz] [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α x y z : α hy : x ≠ y hz : x = z head✝ : α tail✝ : List α h : x ∈ y :: z :: head✝ :: tail✝ ⊢ prev (y :: z :: head✝ :: tail✝) x h = y [PROOFSTEP] rw [prev, dif_neg hy, if_pos hz] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y z : α h : x ∈ y :: z :: l hy : x ≠ y hz : x ≠ z ⊢ x ∈ z :: l [PROOFSTEP] simpa [hy] using h [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x y z : α h : x ∈ y :: z :: l hy : x ≠ y hz : x ≠ z ⊢ prev (y :: z :: l) x h = prev (z :: l) x (_ : x ∈ z :: l) [PROOFSTEP] cases l [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α x y z : α hy : x ≠ y hz : x ≠ z h : x ∈ [y, z] ⊢ prev [y, z] x h = prev [z] x (_ : x ∈ [z]) [PROOFSTEP] simp [hy, hz] at h [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α x y z : α hy : x ≠ y hz : x ≠ z head✝ : α tail✝ : List α h : x ∈ y :: z :: head✝ :: tail✝ ⊢ prev (y :: z :: head✝ :: tail✝) x h = prev (z :: head✝ :: tail✝) x (_ : x ∈ z :: head✝ :: tail✝) [PROOFSTEP] rw [prev, dif_neg hy, if_neg hz] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : x ∈ l ⊢ prev l x h ∈ l [PROOFSTEP] cases' l with hd tl [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α x : α h : x ∈ [] ⊢ prev [] x h ∈ [] [PROOFSTEP] simp at h [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α x hd : α tl : List α h : x ∈ hd :: tl ⊢ prev (hd :: tl) x h ∈ hd :: tl [PROOFSTEP] induction' tl with hd' tl hl generalizing hd [GOAL] case cons.nil α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl : List α h✝ : x ∈ hd✝ :: tl hd : α h : x ∈ [hd] ⊢ prev [hd] x h ∈ [hd] [PROOFSTEP] simp [GOAL] case cons.cons α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl✝ : List α h✝ : x ∈ hd✝ :: tl✝ hd' : α tl : List α hl : ∀ (hd : α) (h : x ∈ hd :: tl), prev (hd :: tl) x h ∈ hd :: tl hd : α h : x ∈ hd :: hd' :: tl ⊢ prev (hd :: hd' :: tl) x h ∈ hd :: hd' :: tl [PROOFSTEP] by_cases hx : x = hd [GOAL] case pos α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl✝ : List α h✝ : x ∈ hd✝ :: tl✝ hd' : α tl : List α hl : ∀ (hd : α) (h : x ∈ hd :: tl), prev (hd :: tl) x h ∈ hd :: tl hd : α h : x ∈ hd :: hd' :: tl hx : x = hd ⊢ prev (hd :: hd' :: tl) x h ∈ hd :: hd' :: tl [PROOFSTEP] simp only [hx, prev_cons_cons_eq] [GOAL] case pos α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl✝ : List α h✝ : x ∈ hd✝ :: tl✝ hd' : α tl : List α hl : ∀ (hd : α) (h : x ∈ hd :: tl), prev (hd :: tl) x h ∈ hd :: tl hd : α h : x ∈ hd :: hd' :: tl hx : x = hd ⊢ getLast (hd' :: tl) (_ : hd' :: tl ≠ []) ∈ hd :: hd' :: tl [PROOFSTEP] exact mem_cons_of_mem _ (getLast_mem _) [GOAL] case neg α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl✝ : List α h✝ : x ∈ hd✝ :: tl✝ hd' : α tl : List α hl : ∀ (hd : α) (h : x ∈ hd :: tl), prev (hd :: tl) x h ∈ hd :: tl hd : α h : x ∈ hd :: hd' :: tl hx : ¬x = hd ⊢ prev (hd :: hd' :: tl) x h ∈ hd :: hd' :: tl [PROOFSTEP] rw [prev, dif_neg hx] [GOAL] case neg α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl✝ : List α h✝ : x ∈ hd✝ :: tl✝ hd' : α tl : List α hl : ∀ (hd : α) (h : x ∈ hd :: tl), prev (hd :: tl) x h ∈ hd :: tl hd : α h : x ∈ hd :: hd' :: tl hx : ¬x = hd ⊢ (if x = hd' then hd else prev (hd' :: tl) x (_ : x ∈ hd' :: tl)) ∈ hd :: hd' :: tl [PROOFSTEP] split_ifs with hm [GOAL] case pos α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl✝ : List α h✝ : x ∈ hd✝ :: tl✝ hd' : α tl : List α hl : ∀ (hd : α) (h : x ∈ hd :: tl), prev (hd :: tl) x h ∈ hd :: tl hd : α h : x ∈ hd :: hd' :: tl hx : ¬x = hd hm : x = hd' ⊢ hd ∈ hd :: hd' :: tl [PROOFSTEP] exact mem_cons_self _ _ [GOAL] case neg α : Type u_1 inst✝ : DecidableEq α x hd✝ : α tl✝ : List α h✝ : x ∈ hd✝ :: tl✝ hd' : α tl : List α hl : ∀ (hd : α) (h : x ∈ hd :: tl), prev (hd :: tl) x h ∈ hd :: tl hd : α h : x ∈ hd :: hd' :: tl hx : ¬x = hd hm : ¬x = hd' ⊢ prev (hd' :: tl) x (_ : x ∈ hd' :: tl) ∈ hd :: hd' :: tl [PROOFSTEP] exact mem_cons_of_mem _ (hl _ _) [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α x✝ : Nodup [] i : Fin (length []) ⊢ next [] (get [] i) (_ : get [] { val := ↑i, isLt := (_ : ↑i < length []) } ∈ []) = get [] { val := (↑i + 1) % length [], isLt := (_ : (↑i + 1) % length [] < length []) } [PROOFSTEP] simpa using i.2 [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x head✝ : α x✝¹ : Nodup [head✝] x✝ : Fin (length [head✝]) ⊢ next [head✝] (get [head✝] x✝) (_ : get [head✝] { val := ↑x✝, isLt := (_ : ↑x✝ < length [head✝]) } ∈ [head✝]) = get [head✝] { val := (↑x✝ + 1) % length [head✝], isLt := (_ : (↑x✝ + 1) % length [head✝] < length [head✝]) } [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α _h : Nodup (x :: y :: l) h0 : 0 < length (x :: y :: l) ⊢ next (x :: y :: l) (get (x :: y :: l) { val := 0, isLt := h0 }) (_ : get (x :: y :: l) { val := ↑{ val := 0, isLt := h0 }, isLt := (_ : ↑{ val := 0, isLt := h0 } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := 0, isLt := h0 } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := 0, isLt := h0 } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] have h₁ : get (x :: y :: l) { val := 0, isLt := h0 } = x := by simp [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α _h : Nodup (x :: y :: l) h0 : 0 < length (x :: y :: l) ⊢ get (x :: y :: l) { val := 0, isLt := h0 } = x [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α _h : Nodup (x :: y :: l) h0 : 0 < length (x :: y :: l) h₁ : get (x :: y :: l) { val := 0, isLt := h0 } = x ⊢ next (x :: y :: l) (get (x :: y :: l) { val := 0, isLt := h0 }) (_ : get (x :: y :: l) { val := ↑{ val := 0, isLt := h0 }, isLt := (_ : ↑{ val := 0, isLt := h0 } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := 0, isLt := h0 } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := 0, isLt := h0 } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] rw [next_cons_cons_eq' _ _ _ _ _ h₁] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α _h : Nodup (x :: y :: l) h0 : 0 < length (x :: y :: l) h₁ : get (x :: y :: l) { val := 0, isLt := h0 } = x ⊢ y = get (x :: y :: l) { val := (↑{ val := 0, isLt := h0 } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := 0, isLt := h0 } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) ⊢ next (x :: y :: l) (get (x :: y :: l) { val := i + 1, isLt := hi }) (_ : get (x :: y :: l) { val := ↑{ val := i + 1, isLt := hi }, isLt := (_ : ↑{ val := i + 1, isLt := hi } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] have hx' : (x :: y :: l).get ⟨i + 1, hi⟩ ≠ x := by intro H suffices (i + 1 : ℕ) = 0 by simpa rw [nodup_iff_injective_get] at hn refine' Fin.veq_of_eq (@hn ⟨i + 1, hi⟩ ⟨0, by simp⟩ _) simpa using H [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x [PROOFSTEP] intro H [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) H : get (x :: y :: l) { val := i + 1, isLt := hi } = x ⊢ False [PROOFSTEP] suffices (i + 1 : ℕ) = 0 by simpa [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) H : get (x :: y :: l) { val := i + 1, isLt := hi } = x this : i + 1 = 0 ⊢ False [PROOFSTEP] simpa [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) H : get (x :: y :: l) { val := i + 1, isLt := hi } = x ⊢ i + 1 = 0 [PROOFSTEP] rw [nodup_iff_injective_get] at hn [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Function.Injective (get (x :: y :: l)) i : ℕ hi : i + 1 < length (x :: y :: l) H : get (x :: y :: l) { val := i + 1, isLt := hi } = x ⊢ i + 1 = 0 [PROOFSTEP] refine' Fin.veq_of_eq (@hn ⟨i + 1, hi⟩ ⟨0, by simp⟩ _) [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Function.Injective (get (x :: y :: l)) i : ℕ hi : i + 1 < length (x :: y :: l) H : get (x :: y :: l) { val := i + 1, isLt := hi } = x ⊢ 0 < length (x :: y :: l) [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Function.Injective (get (x :: y :: l)) i : ℕ hi : i + 1 < length (x :: y :: l) H : get (x :: y :: l) { val := i + 1, isLt := hi } = x ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } = get (x :: y :: l) { val := 0, isLt := (_ : 0 < Nat.succ (length l + 1)) } [PROOFSTEP] simpa using H [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x ⊢ next (x :: y :: l) (get (x :: y :: l) { val := i + 1, isLt := hi }) (_ : get (x :: y :: l) { val := ↑{ val := i + 1, isLt := hi }, isLt := (_ : ↑{ val := i + 1, isLt := hi } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] have hi' : i ≤ l.length := Nat.le_of_lt_succ (Nat.succ_lt_succ_iff.1 hi) [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi' : i ≤ length l ⊢ next (x :: y :: l) (get (x :: y :: l) { val := i + 1, isLt := hi }) (_ : get (x :: y :: l) { val := ↑{ val := i + 1, isLt := hi }, isLt := (_ : ↑{ val := i + 1, isLt := hi } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] rcases hi'.eq_or_lt with (hi' | hi') [GOAL] case inl α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i = length l ⊢ next (x :: y :: l) (get (x :: y :: l) { val := i + 1, isLt := hi }) (_ : get (x :: y :: l) { val := ↑{ val := i + 1, isLt := hi }, isLt := (_ : ↑{ val := i + 1, isLt := hi } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] subst hi' [GOAL] case inl α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) hi : length l + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x hi' : length l ≤ length l ⊢ next (x :: y :: l) (get (x :: y :: l) { val := length l + 1, isLt := hi }) (_ : get (x :: y :: l) { val := ↑{ val := length l + 1, isLt := hi }, isLt := (_ : ↑{ val := length l + 1, isLt := hi } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := length l + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := length l + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] rw [next_getLast_cons] [GOAL] case inl α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) hi : length l + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x hi' : length l ≤ length l ⊢ x = get (x :: y :: l) { val := (↑{ val := length l + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := length l + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] simp [hi', get] [GOAL] case inl.h α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) hi : length l + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x hi' : length l ≤ length l ⊢ get (x :: y :: l) { val := length l + 1, isLt := hi } ∈ y :: l [PROOFSTEP] rw [get_cons_succ] [GOAL] case inl.h α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) hi : length l + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x hi' : length l ≤ length l ⊢ get (y :: l) { val := length l, isLt := (_ : length l < length (y :: l)) } ∈ y :: l [PROOFSTEP] exact get_mem _ _ _ [GOAL] case inl.hy α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) hi : length l + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x hi' : length l ≤ length l ⊢ get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x [PROOFSTEP] exact hx' [GOAL] case inl.hx α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) hi : length l + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x hi' : length l ≤ length l ⊢ get (x :: y :: l) { val := length l + 1, isLt := hi } = getLast (x :: y :: l) (_ : x :: y :: l ≠ []) [PROOFSTEP] simp [getLast_eq_get] [GOAL] case inl.hl α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) hi : length l + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := length l + 1, isLt := hi } ≠ x hi' : length l ≤ length l ⊢ Nodup (y :: l) [PROOFSTEP] exact hn.of_cons [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ next (x :: y :: l) (get (x :: y :: l) { val := i + 1, isLt := hi }) (_ : get (x :: y :: l) { val := ↑{ val := i + 1, isLt := hi }, isLt := (_ : ↑{ val := i + 1, isLt := hi } < length (x :: y :: l)) } ∈ x :: y :: l) = get (x :: y :: l) { val := (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } [PROOFSTEP] rw [next_ne_head_ne_getLast _ _ _ _ _ hx'] [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ next (y :: l) (get (x :: y :: l) { val := i + 1, isLt := hi }) (_ : get (x :: y :: l) { val := i + 1, isLt := hi } ∈ y :: l) = get (x :: y :: l) { val := (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ getLast (x :: y :: l) (_ : x :: y :: l ≠ []) α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ∈ y :: l [PROOFSTEP] simp only [get_cons_succ] [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ next (y :: l) (get (y :: l) { val := i, isLt := (_ : i < length (y :: l)) }) (_ : get (y :: l) { val := i, isLt := (_ : i < length (y :: l)) } ∈ y :: l) = get (x :: y :: l) { val := (i + 1 + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ getLast (x :: y :: l) (_ : x :: y :: l ≠ []) α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ∈ y :: l [PROOFSTEP] rw [next_get (y :: l), ← get_cons_succ (a := x)] [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := (↑{ val := i, isLt := (_ : i < length (y :: l)) } + 1) % length (y :: l) + 1, isLt := ?m.114701 } = get (x :: y :: l) { val := (i + 1 + 1) % length (x :: y :: l), isLt := (_ : (↑{ val := i + 1, isLt := hi } + 1) % length (x :: y :: l) < length (x :: y :: l)) } α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ (↑{ val := i, isLt := (_ : i < length (y :: l)) } + 1) % length (y :: l) + 1 < length (x :: y :: l) case inr._h α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ Nodup (y :: l) case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ getLast (x :: y :: l) (_ : x :: y :: l ≠ []) α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ∈ y :: l [PROOFSTEP] congr [GOAL] case inr.e_a.e_val α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ (↑{ val := i, isLt := (_ : i < length (y :: l)) } + 1) % length (y :: l) + 1 = (i + 1 + 1) % length (x :: y :: l) α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ (↑{ val := i, isLt := (_ : i < length (y :: l)) } + 1) % length (y :: l) + 1 < length (x :: y :: l) case inr._h α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ Nodup (y :: l) case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ getLast (x :: y :: l) (_ : x :: y :: l ≠ []) α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ∈ y :: l [PROOFSTEP] dsimp [GOAL] case inr.e_a.e_val α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ (i + 1) % Nat.succ (length l) + 1 = (i + 1 + 1) % Nat.succ (Nat.succ (length l)) α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ (↑{ val := i, isLt := (_ : i < length (y :: l)) } + 1) % length (y :: l) + 1 < length (x :: y :: l) case inr._h α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ Nodup (y :: l) case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ getLast (x :: y :: l) (_ : x :: y :: l ≠ []) α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ∈ y :: l [PROOFSTEP] rw [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 (Nat.succ_lt_succ_iff.2 hi'))] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ (↑{ val := i, isLt := (_ : i < length (y :: l)) } + 1) % length (y :: l) + 1 < length (x :: y :: l) [PROOFSTEP] simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi'] [GOAL] case inr._h α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ Nodup (y :: l) [PROOFSTEP] exact hn.of_cons [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ getLast (x :: y :: l) (_ : x :: y :: l ≠ []) [PROOFSTEP] rw [getLast_eq_get] [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ≠ get (x :: y :: l) { val := length (x :: y :: l) - 1, isLt := (_ : length (x :: y :: l) - 1 < length (x :: y :: l)) } [PROOFSTEP] intro h [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l h : get (x :: y :: l) { val := i + 1, isLt := hi } = get (x :: y :: l) { val := length (x :: y :: l) - 1, isLt := (_ : length (x :: y :: l) - 1 < length (x :: y :: l)) } ⊢ False [PROOFSTEP] have := nodup_iff_injective_get.1 hn h [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l h : get (x :: y :: l) { val := i + 1, isLt := hi } = get (x :: y :: l) { val := length (x :: y :: l) - 1, isLt := (_ : length (x :: y :: l) - 1 < length (x :: y :: l)) } this : { val := i + 1, isLt := hi } = { val := length (x :: y :: l) - 1, isLt := (_ : length (x :: y :: l) - 1 < length (x :: y :: l)) } ⊢ False [PROOFSTEP] simp at this [GOAL] case inr α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l h : get (x :: y :: l) { val := i + 1, isLt := hi } = get (x :: y :: l) { val := length (x :: y :: l) - 1, isLt := (_ : length (x :: y :: l) - 1 < length (x :: y :: l)) } this : i = length l ⊢ False [PROOFSTEP] simp [this] at hi' [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (x :: y :: l) { val := i + 1, isLt := hi } ∈ y :: l [PROOFSTEP] rw [get_cons_succ] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ x y : α l : List α hn : Nodup (x :: y :: l) i : ℕ hi : i + 1 < length (x :: y :: l) hx' : get (x :: y :: l) { val := i + 1, isLt := hi } ≠ x hi'✝ : i ≤ length l hi' : i < length l ⊢ get (y :: l) { val := i, isLt := (_ : i < length (y :: l)) } ∈ y :: l [PROOFSTEP] exact get_mem _ _ _ [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l n : ℕ hn : n < length l ⊢ prev l (nthLe l n hn) (_ : nthLe l n hn ∈ l) = nthLe l ((n + (length l - 1)) % length l) (_ : (n + (length l - 1)) % length l < length l) [PROOFSTEP] cases' l with x l [GOAL] case nil α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ h : Nodup [] hn : n < length [] ⊢ prev [] (nthLe [] n hn) (_ : nthLe [] n hn ∈ []) = nthLe [] ((n + (length [] - 1)) % length []) (_ : (n + (length [] - 1)) % length [] < length []) [PROOFSTEP] simp at hn [GOAL] case cons α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α n : ℕ x : α l : List α h : Nodup (x :: l) hn : n < length (x :: l) ⊢ prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) [PROOFSTEP] induction' l with y l hl generalizing n x [GOAL] case cons.nil α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝¹ : α n✝ : ℕ x✝ : α l : List α h✝ : Nodup (x✝ :: l) hn✝ : n✝ < length (x✝ :: l) n : ℕ x : α h : Nodup [x] hn : n < length [x] ⊢ prev [x] (nthLe [x] n hn) (_ : nthLe [x] n hn ∈ [x]) = nthLe [x] ((n + (length [x] - 1)) % length [x]) (_ : (n + (length [x] - 1)) % length [x] < length [x]) [PROOFSTEP] simp [GOAL] case cons.cons α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) n : ℕ x : α h : Nodup (x :: y :: l) hn : n < length (x :: y :: l) ⊢ prev (x :: y :: l) (nthLe (x :: y :: l) n hn) (_ : nthLe (x :: y :: l) n hn ∈ x :: y :: l) = nthLe (x :: y :: l) ((n + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (n + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) [PROOFSTEP] rcases n with (_ | _ | n) [GOAL] case cons.cons.zero α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) hn : Nat.zero < length (x :: y :: l) ⊢ prev (x :: y :: l) (nthLe (x :: y :: l) Nat.zero hn) (_ : nthLe (x :: y :: l) Nat.zero hn ∈ x :: y :: l) = nthLe (x :: y :: l) ((Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) [PROOFSTEP] simp [Nat.add_succ_sub_one, add_zero, List.prev_cons_cons_eq, Nat.zero_eq, List.length, List.nthLe, Nat.succ_add_sub_one, zero_add, getLast_eq_get, Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)] [GOAL] case cons.cons.succ.zero α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) hn : Nat.succ Nat.zero < length (x :: y :: l) ⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ Nat.zero) hn) (_ : nthLe (x :: y :: l) (Nat.succ Nat.zero) hn ∈ x :: y :: l) = nthLe (x :: y :: l) ((Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) [PROOFSTEP] simp only [mem_cons, nodup_cons] at h [GOAL] case cons.cons.succ.zero α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α hn : Nat.succ Nat.zero < length (x :: y :: l) h : ¬(x = y ∨ x ∈ l) ∧ ¬y ∈ l ∧ Nodup l ⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ Nat.zero) hn) (_ : nthLe (x :: y :: l) (Nat.succ Nat.zero) hn ∈ x :: y :: l) = nthLe (x :: y :: l) ((Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) [PROOFSTEP] push_neg at h [GOAL] case cons.cons.succ.zero α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α hn : Nat.succ Nat.zero < length (x :: y :: l) h : (x ≠ y ∧ ¬x ∈ l) ∧ ¬y ∈ l ∧ Nodup l ⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ Nat.zero) hn) (_ : nthLe (x :: y :: l) (Nat.succ Nat.zero) hn ∈ x :: y :: l) = nthLe (x :: y :: l) ((Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) [PROOFSTEP] simp only [List.prev_cons_cons_of_ne _ _ _ _ h.left.left.symm, Nat.zero_eq, List.length, List.nthLe, add_comm, eq_self_iff_true, Nat.succ_add_sub_one, Nat.mod_self, zero_add, List.get] [GOAL] case cons.cons.succ.succ α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) ⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn) (_ : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ∈ x :: y :: l) = nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) [PROOFSTEP] rw [prev_ne_cons_cons] [GOAL] case cons.cons.succ.succ α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) ⊢ prev (y :: l) (nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn) (_ : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ∈ y :: l) = nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) [PROOFSTEP] convert hl n.succ y h.of_cons (Nat.le_of_succ_le_succ hn) using 1 [GOAL] case h.e'_3 α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) ⊢ nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) = nthLe (y :: l) ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l)) (_ : (Nat.succ n + (length (y :: l) - 1)) % length (y :: l) < length (y :: l)) [PROOFSTEP] have : ∀ k hk, (y :: l).nthLe k hk = (x :: y :: l).nthLe (k + 1) (Nat.succ_lt_succ hk) := by intros simp [List.nthLe] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) ⊢ ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) [PROOFSTEP] intros [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) k✝ : ℕ hk✝ : k✝ < length (y :: l) ⊢ nthLe (y :: l) k✝ hk✝ = nthLe (x :: y :: l) (k✝ + 1) (_ : Nat.succ k✝ < Nat.succ (length (y :: l))) [PROOFSTEP] simp [List.nthLe] [GOAL] case h.e'_3 α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) ⊢ nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) = nthLe (y :: l) ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l)) (_ : (Nat.succ n + (length (y :: l) - 1)) % length (y :: l) < length (y :: l)) [PROOFSTEP] rw [this] [GOAL] case h.e'_3 α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) ⊢ nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l)) (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) = nthLe (x :: y :: l) ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l) + 1) (_ : Nat.succ ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l)) < Nat.succ (length (y :: l))) [PROOFSTEP] congr [GOAL] case h.e'_3.e_n α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) ⊢ (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) = (Nat.succ n + (length (y :: l) - 1)) % length (y :: l) + 1 [PROOFSTEP] simp only [Nat.add_succ_sub_one, add_zero, length] [GOAL] case h.e'_3.e_n α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) ⊢ (Nat.succ (Nat.succ n) + (length l + 1)) % (length l + 1 + 1) = (Nat.succ n + length l) % (length l + 1) + 1 [PROOFSTEP] simp only [length, Nat.succ_lt_succ_iff] at hn [GOAL] case h.e'_3.e_n α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) hn : n < length l ⊢ (Nat.succ (Nat.succ n) + (length l + 1)) % (length l + 1 + 1) = (Nat.succ n + length l) % (length l + 1) + 1 [PROOFSTEP] set k := l.length [GOAL] case h.e'_3.e_n α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) k : ℕ := length l hn : n < k ⊢ (Nat.succ (Nat.succ n) + (k + 1)) % (k + 1 + 1) = (Nat.succ n + k) % (k + 1) + 1 [PROOFSTEP] rw [Nat.succ_add, ← Nat.add_succ, Nat.add_mod_right, Nat.succ_add, ← Nat.add_succ _ k, Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt] [GOAL] case h.e'_3.e_n α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) k : ℕ := length l hn : n < k ⊢ n < Nat.succ k [PROOFSTEP] exact Nat.lt_succ_of_lt hn [GOAL] case h.e'_3.e_n α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ this : ∀ (k : ℕ) (hk : k < length (y :: l)), nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l))) k : ℕ := length l hn : n < k ⊢ n + 1 < Nat.succ (k + 1) [PROOFSTEP] exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn) [GOAL] case cons.cons.succ.succ.hy α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) ⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ≠ x [PROOFSTEP] intro H [GOAL] case cons.cons.succ.succ.hy α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x ⊢ False [PROOFSTEP] suffices n.succ.succ = 0 by simpa [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x this : Nat.succ (Nat.succ n) = 0 ⊢ False [PROOFSTEP] simpa [GOAL] case cons.cons.succ.succ.hy α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x ⊢ Nat.succ (Nat.succ n) = 0 [PROOFSTEP] rw [nodup_iff_nthLe_inj] at h [GOAL] case cons.cons.succ.succ.hy α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)), nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x ⊢ Nat.succ (Nat.succ n) = 0 [PROOFSTEP] refine' h _ _ hn Nat.succ_pos' _ [GOAL] case cons.cons.succ.succ.hy α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)), nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x ⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = nthLe (x :: y :: l) 0 (_ : 0 < Nat.succ (length (y :: l))) [PROOFSTEP] simpa using H [GOAL] case cons.cons.succ.succ.hz α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) ⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ≠ y [PROOFSTEP] intro H [GOAL] case cons.cons.succ.succ.hz α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y ⊢ False [PROOFSTEP] suffices n.succ.succ = 1 by simpa [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y this : Nat.succ (Nat.succ n) = 1 ⊢ False [PROOFSTEP] simpa [GOAL] case cons.cons.succ.succ.hz α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : Nodup (x :: y :: l) n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y ⊢ Nat.succ (Nat.succ n) = 1 [PROOFSTEP] rw [nodup_iff_nthLe_inj] at h [GOAL] case cons.cons.succ.succ.hz α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)), nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y ⊢ Nat.succ (Nat.succ n) = 1 [PROOFSTEP] refine' h _ _ hn (Nat.succ_lt_succ Nat.succ_pos') _ [GOAL] case cons.cons.succ.succ.hz α : Type u_1 inst✝ : DecidableEq α l✝¹ : List α x✝¹ : α n✝ : ℕ x✝ : α l✝ : List α h✝ : Nodup (x✝ :: l✝) hn✝ : n✝ < length (x✝ :: l✝) y : α l : List α hl : ∀ (n : ℕ) (x : α), Nodup (x :: l) → ∀ (hn : n < length (x :: l)), prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) = nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l)) (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l)) x : α h : ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)), nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j n : ℕ hn : Nat.succ (Nat.succ n) < length (x :: y :: l) H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y ⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = nthLe (x :: y :: l) 1 (_ : Nat.succ 0 < Nat.succ (length (y :: l))) [PROOFSTEP] simpa using H [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l ⊢ pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l) = rotate l 1 [PROOFSTEP] apply List.ext_nthLe [GOAL] case hl α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l ⊢ length (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) = length (rotate l 1) [PROOFSTEP] simp [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l ⊢ ∀ (n : ℕ) (h₁ : n < length (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l))) (h₂ : n < length (rotate l 1)), nthLe (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) n h₁ = nthLe (rotate l 1) n h₂ [PROOFSTEP] intros [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l n✝ : ℕ h₁✝ : n✝ < length (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) h₂✝ : n✝ < length (rotate l 1) ⊢ nthLe (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) n✝ h₁✝ = nthLe (rotate l 1) n✝ h₂✝ [PROOFSTEP] rw [nthLe_pmap, nthLe_rotate, next_nthLe _ h] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l ⊢ pmap (prev l) l (_ : ∀ (x : α), x ∈ l → x ∈ l) = rotate l (length l - 1) [PROOFSTEP] apply List.ext_nthLe [GOAL] case hl α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l ⊢ length (pmap (prev l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) = length (rotate l (length l - 1)) [PROOFSTEP] simp [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l ⊢ ∀ (n : ℕ) (h₁ : n < length (pmap (prev l) l (_ : ∀ (x : α), x ∈ l → x ∈ l))) (h₂ : n < length (rotate l (length l - 1))), nthLe (pmap (prev l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) n h₁ = nthLe (rotate l (length l - 1)) n h₂ [PROOFSTEP] intro n hn hn' [GOAL] case h α : Type u_1 inst✝ : DecidableEq α l : List α x : α h : Nodup l n : ℕ hn : n < length (pmap (prev l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) hn' : n < length (rotate l (length l - 1)) ⊢ nthLe (pmap (prev l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) n hn = nthLe (rotate l (length l - 1)) n hn' [PROOFSTEP] rw [nthLe_rotate, nthLe_pmap, prev_nthLe _ h] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l : List α h : Nodup l x : α hx : x ∈ l ⊢ prev l (next l x hx) (_ : next l x hx ∈ l) = x [PROOFSTEP] obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l n : ℕ hn : n < length l hx : nthLe l n hn ∈ l ⊢ prev l (next l (nthLe l n hn) hx) (_ : next l (nthLe l n hn) hx ∈ l) = nthLe l n hn [PROOFSTEP] simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod] [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l n : ℕ hn : n < length l hx : nthLe l n hn ∈ l ⊢ nthLe l ((n + 1 + (length l - 1)) % length l) (_ : (n + 1 + (length l - 1)) % length l < length l) = nthLe l n hn [PROOFSTEP] cases' l with hd tl [GOAL] case intro.intro.nil α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ h : Nodup [] hn : n < length [] hx : nthLe [] n hn ∈ [] ⊢ nthLe [] ((n + 1 + (length [] - 1)) % length []) (_ : (n + 1 + (length [] - 1)) % length [] < length []) = nthLe [] n hn [PROOFSTEP] simp at hx [GOAL] case intro.intro.cons α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn : n < length (hd :: tl) hx : nthLe (hd :: tl) n hn ∈ hd :: tl ⊢ nthLe (hd :: tl) ((n + 1 + (length (hd :: tl) - 1)) % length (hd :: tl)) (_ : (n + 1 + (length (hd :: tl) - 1)) % length (hd :: tl) < length (hd :: tl)) = nthLe (hd :: tl) n hn [PROOFSTEP] have : (n + 1 + length tl) % (length tl + 1) = n := by rw [length_cons] at hn rw [add_assoc, add_comm 1, Nat.add_mod_right, Nat.mod_eq_of_lt hn] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn : n < length (hd :: tl) hx : nthLe (hd :: tl) n hn ∈ hd :: tl ⊢ (n + 1 + length tl) % (length tl + 1) = n [PROOFSTEP] rw [length_cons] at hn [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn✝ : n < length (hd :: tl) hn : n < Nat.succ (length tl) hx : nthLe (hd :: tl) n hn✝ ∈ hd :: tl ⊢ (n + 1 + length tl) % (length tl + 1) = n [PROOFSTEP] rw [add_assoc, add_comm 1, Nat.add_mod_right, Nat.mod_eq_of_lt hn] [GOAL] case intro.intro.cons α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn : n < length (hd :: tl) hx : nthLe (hd :: tl) n hn ∈ hd :: tl this : (n + 1 + length tl) % (length tl + 1) = n ⊢ nthLe (hd :: tl) ((n + 1 + (length (hd :: tl) - 1)) % length (hd :: tl)) (_ : (n + 1 + (length (hd :: tl) - 1)) % length (hd :: tl) < length (hd :: tl)) = nthLe (hd :: tl) n hn [PROOFSTEP] simp only [length_cons, Nat.succ_sub_succ_eq_sub, tsub_zero, Nat.succ_eq_add_one, this] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l : List α h : Nodup l x : α hx : x ∈ l ⊢ next l (prev l x hx) (_ : prev l x hx ∈ l) = x [PROOFSTEP] obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l n : ℕ hn : n < length l hx : nthLe l n hn ∈ l ⊢ next l (prev l (nthLe l n hn) hx) (_ : prev l (nthLe l n hn) hx ∈ l) = nthLe l n hn [PROOFSTEP] simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod] [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l n : ℕ hn : n < length l hx : nthLe l n hn ∈ l ⊢ nthLe l ((n + (length l - 1) + 1) % length l) (_ : (n + (length l - 1) + 1) % length l < length l) = nthLe l n hn [PROOFSTEP] cases' l with hd tl [GOAL] case intro.intro.nil α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ h : Nodup [] hn : n < length [] hx : nthLe [] n hn ∈ [] ⊢ nthLe [] ((n + (length [] - 1) + 1) % length []) (_ : (n + (length [] - 1) + 1) % length [] < length []) = nthLe [] n hn [PROOFSTEP] simp at hx [GOAL] case intro.intro.cons α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn : n < length (hd :: tl) hx : nthLe (hd :: tl) n hn ∈ hd :: tl ⊢ nthLe (hd :: tl) ((n + (length (hd :: tl) - 1) + 1) % length (hd :: tl)) (_ : (n + (length (hd :: tl) - 1) + 1) % length (hd :: tl) < length (hd :: tl)) = nthLe (hd :: tl) n hn [PROOFSTEP] have : (n + length tl + 1) % (length tl + 1) = n := by rw [length_cons] at hn rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn] [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn : n < length (hd :: tl) hx : nthLe (hd :: tl) n hn ∈ hd :: tl ⊢ (n + length tl + 1) % (length tl + 1) = n [PROOFSTEP] rw [length_cons] at hn [GOAL] α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn✝ : n < length (hd :: tl) hn : n < Nat.succ (length tl) hx : nthLe (hd :: tl) n hn✝ ∈ hd :: tl ⊢ (n + length tl + 1) % (length tl + 1) = n [PROOFSTEP] rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn] [GOAL] case intro.intro.cons α : Type u_1 inst✝ : DecidableEq α l : List α x : α n : ℕ hd : α tl : List α h : Nodup (hd :: tl) hn : n < length (hd :: tl) hx : nthLe (hd :: tl) n hn ∈ hd :: tl this : (n + length tl + 1) % (length tl + 1) = n ⊢ nthLe (hd :: tl) ((n + (length (hd :: tl) - 1) + 1) % length (hd :: tl)) (_ : (n + (length (hd :: tl) - 1) + 1) % length (hd :: tl) < length (hd :: tl)) = nthLe (hd :: tl) n hn [PROOFSTEP] simp [this] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l : List α h : Nodup l x : α hx : x ∈ l ⊢ prev (reverse l) x (_ : x ∈ reverse l) = next l x hx [PROOFSTEP] obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l ⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) = next l (nthLe l k hk) hx [PROOFSTEP] have lpos : 0 < l.length := k.zero_le.trans_lt hk [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l ⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) = next l (nthLe l k hk) hx [PROOFSTEP] have key : l.length - 1 - k < l.length := (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos') [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) = next l (nthLe l k hk) hx [PROOFSTEP] rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ k < length (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) [PROOFSTEP] simpa using hk [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) = nthLe (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l)) k (_ : k < length (pmap (next l) l (_ : ∀ (x : α), x ∈ l → x ∈ l))) [PROOFSTEP] simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ length l ≤ length (reverse l) [PROOFSTEP] simp [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ prev (reverse l) (nthLe (reverse l) (length l - 1 - k) (_ : length l - 1 - k < length (reverse l))) (_ : nthLe (reverse l) (length l - 1 - k) (_ : length l - 1 - k < length (reverse l)) ∈ reverse l) = nthLe (rotate l 1) k (_ : k < length (rotate l 1)) [PROOFSTEP] rw [← nthLe_pmap l.reverse.prev fun _ h => h] [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ nthLe (pmap (prev (reverse l)) (reverse l) (_ : ∀ (x : α), x ∈ reverse l → x ∈ reverse l)) (length l - 1 - k) ?intro.intro = nthLe (rotate l 1) k (_ : k < length (rotate l 1)) [PROOFSTEP] simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse, length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'), tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)] [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ nthLe (reverse (rotate l (Nat.succ 0))) (length l - 1 - k) (_ : length l - 1 - k < length (reverse (rotate l (Nat.succ 0)))) = nthLe (rotate l 1) k (_ : k < length (rotate l 1)) [PROOFSTEP] rw [← nthLe_reverse] [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ nthLe (reverse (reverse (rotate l (Nat.succ 0)))) (length (reverse (rotate l (Nat.succ 0))) - 1 - (length l - 1 - k)) ?intro.intro.h1 = nthLe (rotate l 1) k (_ : k < length (rotate l 1)) [PROOFSTEP] simp [tsub_tsub_cancel_of_le (Nat.le_pred_of_lt hk)] [GOAL] case intro.intro.h1 α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ length (reverse (rotate l (Nat.succ 0))) - 1 - (length l - 1 - k) < length (reverse (reverse (rotate l (Nat.succ 0)))) [PROOFSTEP] simpa using (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos') [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α h : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l lpos : 0 < length l key : length l - 1 - k < length l ⊢ length l - 1 - k < length (pmap (prev (reverse l)) (reverse l) (_ : ∀ (x : α), x ∈ reverse l → x ∈ reverse l)) [PROOFSTEP] simpa [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l : List α h : Nodup l x : α hx : x ∈ l ⊢ next (reverse l) x (_ : x ∈ reverse l) = prev l x hx [PROOFSTEP] convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm [GOAL] case h.e'_3.h.e'_3 α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l : List α h : Nodup l x : α hx : x ∈ l ⊢ l = reverse (reverse l) [PROOFSTEP] exact (reverse_reverse l).symm [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l l' : List α h : l ~r l' hn : Nodup l x : α hx : x ∈ l ⊢ next l x hx = next l' x (_ : x ∈ l') [PROOFSTEP] obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx [GOAL] case intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l l' : List α h : l ~r l' hn : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l ⊢ next l (nthLe l k hk) hx = next l' (nthLe l k hk) (_ : nthLe l k hk ∈ l') [PROOFSTEP] obtain ⟨n, rfl⟩ := id h [GOAL] case intro.intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α hn : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l n : ℕ h : l ~r rotate l n ⊢ next l (nthLe l k hk) hx = next (rotate l n) (nthLe l k hk) (_ : nthLe l k hk ∈ rotate l n) [PROOFSTEP] rw [next_nthLe _ hn] [GOAL] case intro.intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α hn : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l n : ℕ h : l ~r rotate l n ⊢ nthLe l ((k + 1) % length l) (_ : (k + 1) % length l < length l) = next (rotate l n) (nthLe l k hk) (_ : nthLe l k hk ∈ rotate l n) [PROOFSTEP] simp_rw [← nthLe_rotate' _ n k] [GOAL] case intro.intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α hn : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l n : ℕ h : l ~r rotate l n ⊢ nthLe l ((k + 1) % length l) (_ : (k + 1) % length l < length l) = next (rotate l n) (nthLe (rotate l n) ((length l - n % length l + k) % length l) (_ : (length l - n % length l + k) % length l < length (rotate l n))) (_ : nthLe (rotate l n) ((length l - n % length l + k) % length l) (_ : (length l - n % length l + k) % length l < length (rotate l n)) ∈ rotate l n) [PROOFSTEP] rw [next_nthLe _ (h.nodup_iff.mp hn), ← nthLe_rotate' _ n] [GOAL] case intro.intro.intro α : Type u_1 inst✝ : DecidableEq α l✝ : List α x : α l : List α hn : Nodup l k : ℕ hk : k < length l hx : nthLe l k hk ∈ l n : ℕ h : l ~r rotate l n ⊢ nthLe (rotate l n) ((length l - n % length l + (k + 1) % length l) % length l) (_ : (length l - n % length l + (k + 1) % length l) % length l < length (rotate l n)) = nthLe (rotate l n) (((length l - n % length l + k) % length l + 1) % length (rotate l n)) (_ : ((length l - n % length l + k) % length l + 1) % length (rotate l n) < length (rotate l n)) [PROOFSTEP] simp [add_assoc] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l l' : List α h : l ~r l' hn : Nodup l x : α hx : x ∈ l ⊢ prev l x hx = prev l' x (_ : x ∈ l') [PROOFSTEP] rw [← next_reverse_eq_prev _ hn, ← next_reverse_eq_prev _ (h.nodup_iff.mp hn)] [GOAL] α : Type u_1 inst✝ : DecidableEq α l✝ : List α x✝ : α l l' : List α h : l ~r l' hn : Nodup l x : α hx : x ∈ l ⊢ next (reverse l) x (_ : x ∈ reverse l) = next (reverse l') x (_ : x ∈ reverse l') [PROOFSTEP] exact isRotated_next_eq h.reverse (nodup_reverse.mpr hn) _ [GOAL] α : Type u_1 l : List α a : α ⊢ rotate (a :: l) 1 = l ++ [a] [PROOFSTEP] rw [rotate_cons_succ, rotate_zero] [GOAL] α : Type u_1 C : Cycle α → Prop s : Cycle α H0 : C nil HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l) l : List α ⊢ C (Quotient.mk'' l) [PROOFSTEP] refine List.recOn l ?_ ?_ [GOAL] case refine_1 α : Type u_1 C : Cycle α → Prop s : Cycle α H0 : C nil HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l) l : List α ⊢ C (Quotient.mk'' []) [PROOFSTEP] simp [GOAL] case refine_2 α : Type u_1 C : Cycle α → Prop s : Cycle α H0 : C nil HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l) l : List α ⊢ ∀ (head : α) (tail : List α), C (Quotient.mk'' tail) → C (Quotient.mk'' (head :: tail)) [PROOFSTEP] simp [GOAL] case refine_1 α : Type u_1 C : Cycle α → Prop s : Cycle α H0 : C nil HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l) l : List α ⊢ C nil case refine_2 α : Type u_1 C : Cycle α → Prop s : Cycle α H0 : C nil HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l) l : List α ⊢ ∀ (head : α) (tail : List α), C ↑tail → C ↑(head :: tail) [PROOFSTEP] assumption' [GOAL] α : Type u_1 s : Cycle α x✝ : List α ⊢ reverse (reverse (Quot.mk Setoid.r x✝)) = Quot.mk Setoid.r x✝ [PROOFSTEP] simp [GOAL] α : Type u_1 s : Cycle α ⊢ Subsingleton (reverse s) ↔ Subsingleton s [PROOFSTEP] simp [length_subsingleton_iff] [GOAL] α : Type u_1 s : Cycle α h : Subsingleton s ⊢ ∀ ⦃x : α⦄, x ∈ s → ∀ ⦃y : α⦄, y ∈ s → x = y [PROOFSTEP] induction' s using Quot.inductionOn with l [GOAL] case h α : Type u_1 s : Cycle α h✝ : Subsingleton s l : List α h : Subsingleton (Quot.mk Setoid.r l) ⊢ ∀ ⦃x : α⦄, x ∈ Quot.mk Setoid.r l → ∀ ⦃y : α⦄, y ∈ Quot.mk Setoid.r l → x = y [PROOFSTEP] simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, Nat.lt_add_one_iff, length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h [GOAL] case h α : Type u_1 s : Cycle α h✝ : Subsingleton s l : List α h : l = [] ∨ ∃ a, l = [a] ⊢ ∀ ⦃x : α⦄, x ∈ Quot.mk Setoid.r l → ∀ ⦃y : α⦄, y ∈ Quot.mk Setoid.r l → x = y [PROOFSTEP] rcases h with (rfl | ⟨z, rfl⟩) [GOAL] case h.inl α : Type u_1 s : Cycle α h : Subsingleton s ⊢ ∀ ⦃x : α⦄, x ∈ Quot.mk Setoid.r [] → ∀ ⦃y : α⦄, y ∈ Quot.mk Setoid.r [] → x = y [PROOFSTEP] simp [GOAL] case h.inr.intro α : Type u_1 s : Cycle α h : Subsingleton s z : α ⊢ ∀ ⦃x : α⦄, x ∈ Quot.mk Setoid.r [z] → ∀ ⦃y : α⦄, y ∈ Quot.mk Setoid.r [z] → x = y [PROOFSTEP] simp [GOAL] α : Type u_1 l : List α hl : Nodup l ⊢ Nontrivial ↑l ↔ 2 ≤ List.length l [PROOFSTEP] rw [Nontrivial] [GOAL] α : Type u_1 l : List α hl : Nodup l ⊢ (∃ x y _h, x ∈ ↑l ∧ y ∈ ↑l) ↔ 2 ≤ List.length l [PROOFSTEP] rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩) [GOAL] case nil α : Type u_1 hl : Nodup [] ⊢ (∃ x y _h, x ∈ ↑[] ∧ y ∈ ↑[]) ↔ 2 ≤ List.length [] [PROOFSTEP] simp [GOAL] case cons.nil α : Type u_1 hd : α hl : Nodup [hd] ⊢ (∃ x y _h, x ∈ ↑[hd] ∧ y ∈ ↑[hd]) ↔ 2 ≤ List.length [hd] [PROOFSTEP] simp [GOAL] case cons.cons α : Type u_1 hd hd' : α tl : List α hl : Nodup (hd :: hd' :: tl) ⊢ (∃ x y _h, x ∈ ↑(hd :: hd' :: tl) ∧ y ∈ ↑(hd :: hd' :: tl)) ↔ 2 ≤ List.length (hd :: hd' :: tl) [PROOFSTEP] simp only [mem_cons, exists_prop, mem_coe_iff, List.length, Ne.def, Nat.succ_le_succ_iff, zero_le, iff_true_iff] [GOAL] case cons.cons α : Type u_1 hd hd' : α tl : List α hl : Nodup (hd :: hd' :: tl) ⊢ ∃ x y, ¬x = y ∧ (x = hd ∨ x = hd' ∨ x ∈ tl) ∧ (y = hd ∨ y = hd' ∨ y ∈ tl) [PROOFSTEP] refine' ⟨hd, hd', _, by simp⟩ [GOAL] α : Type u_1 hd hd' : α tl : List α hl : Nodup (hd :: hd' :: tl) ⊢ (hd = hd ∨ hd = hd' ∨ hd ∈ tl) ∧ (hd' = hd ∨ hd' = hd' ∨ hd' ∈ tl) [PROOFSTEP] simp [GOAL] case cons.cons α : Type u_1 hd hd' : α tl : List α hl : Nodup (hd :: hd' :: tl) ⊢ ¬hd = hd' [PROOFSTEP] simp only [not_or, mem_cons, nodup_cons] at hl [GOAL] case cons.cons α : Type u_1 hd hd' : α tl : List α hl : (¬hd = hd' ∧ ¬hd ∈ tl) ∧ ¬hd' ∈ tl ∧ Nodup tl ⊢ ¬hd = hd' [PROOFSTEP] exact hl.left.left [GOAL] α : Type u_1 s : Cycle α ⊢ Nontrivial (reverse s) ↔ Nontrivial s [PROOFSTEP] simp [Nontrivial] [GOAL] α : Type u_1 s : Cycle α h : Nontrivial s ⊢ 2 ≤ length s [PROOFSTEP] obtain ⟨x, y, hxy, hx, hy⟩ := h [GOAL] case intro.intro.intro.intro α : Type u_1 s : Cycle α x y : α hxy : x ≠ y hx : x ∈ s hy : y ∈ s ⊢ 2 ≤ length s [PROOFSTEP] induction' s using Quot.inductionOn with l [GOAL] case intro.intro.intro.intro.h α : Type u_1 s : Cycle α x y : α hxy : x ≠ y hx✝ : x ∈ s hy✝ : y ∈ s l : List α hx : x ∈ Quot.mk Setoid.r l hy : y ∈ Quot.mk Setoid.r l ⊢ 2 ≤ length (Quot.mk Setoid.r l) [PROOFSTEP] rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩) [GOAL] case intro.intro.intro.intro.h.nil α : Type u_1 s : Cycle α x y : α hxy : x ≠ y hx✝ : x ∈ s hy✝ : y ∈ s hx : x ∈ Quot.mk Setoid.r [] hy : y ∈ Quot.mk Setoid.r [] ⊢ 2 ≤ length (Quot.mk Setoid.r []) [PROOFSTEP] simp at hx [GOAL] case intro.intro.intro.intro.h.cons.nil α : Type u_1 s : Cycle α x y : α hxy : x ≠ y hx✝ : x ∈ s hy✝ : y ∈ s hd : α hx : x ∈ Quot.mk Setoid.r [hd] hy : y ∈ Quot.mk Setoid.r [hd] ⊢ 2 ≤ length (Quot.mk Setoid.r [hd]) [PROOFSTEP] simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy [GOAL] case intro.intro.intro.intro.h.cons.nil α : Type u_1 s : Cycle α x y : α hxy : x ≠ y hx✝ : x ∈ s hy✝ : y ∈ s hd : α hx : x = hd hy : y = hd ⊢ 2 ≤ length (Quot.mk Setoid.r [hd]) [PROOFSTEP] simp [hx, hy] at hxy [GOAL] case intro.intro.intro.intro.h.cons.cons α : Type u_1 s : Cycle α x y : α hxy : x ≠ y hx✝ : x ∈ s hy✝ : y ∈ s hd hd' : α tl : List α hx : x ∈ Quot.mk Setoid.r (hd :: hd' :: tl) hy : y ∈ Quot.mk Setoid.r (hd :: hd' :: tl) ⊢ 2 ≤ length (Quot.mk Setoid.r (hd :: hd' :: tl)) [PROOFSTEP] simp [Nat.succ_le_succ_iff] [GOAL] α : Type u_1 s : Cycle α h : Subsingleton s ⊢ Nodup s [PROOFSTEP] induction' s using Quot.inductionOn with l [GOAL] case h α : Type u_1 s : Cycle α h✝ : Subsingleton s l : List α h : Subsingleton (Quot.mk Setoid.r l) ⊢ Nodup (Quot.mk Setoid.r l) [PROOFSTEP] cases' l with hd tl [GOAL] case h.nil α : Type u_1 s : Cycle α h✝ : Subsingleton s h : Subsingleton (Quot.mk Setoid.r []) ⊢ Nodup (Quot.mk Setoid.r []) [PROOFSTEP] simp [GOAL] case h.cons α : Type u_1 s : Cycle α h✝ : Subsingleton s hd : α tl : List α h : Subsingleton (Quot.mk Setoid.r (hd :: tl)) ⊢ Nodup (Quot.mk Setoid.r (hd :: tl)) [PROOFSTEP] have : tl = [] := by simpa [Subsingleton, length_eq_zero, Nat.succ_le_succ_iff] using h [GOAL] α : Type u_1 s : Cycle α h✝ : Subsingleton s hd : α tl : List α h : Subsingleton (Quot.mk Setoid.r (hd :: tl)) ⊢ tl = [] [PROOFSTEP] simpa [Subsingleton, length_eq_zero, Nat.succ_le_succ_iff] using h [GOAL] case h.cons α : Type u_1 s : Cycle α h✝ : Subsingleton s hd : α tl : List α h : Subsingleton (Quot.mk Setoid.r (hd :: tl)) this : tl = [] ⊢ Nodup (Quot.mk Setoid.r (hd :: tl)) [PROOFSTEP] simp [this] [GOAL] α : Type u_1 s : Cycle α h : Nodup s ⊢ Nontrivial s ↔ ¬Subsingleton s [PROOFSTEP] rw [length_subsingleton_iff] [GOAL] α : Type u_1 s : Cycle α h : Nodup s ⊢ Nontrivial s ↔ ¬length s ≤ 1 [PROOFSTEP] induction s using Quotient.inductionOn' [GOAL] case h α : Type u_1 a✝ : List α h : Nodup (Quotient.mk'' a✝) ⊢ Nontrivial (Quotient.mk'' a✝) ↔ ¬length (Quotient.mk'' a✝) ≤ 1 [PROOFSTEP] simp only [mk''_eq_coe, nodup_coe_iff] at h [GOAL] case h α : Type u_1 a✝ : List α h : List.Nodup a✝ ⊢ Nontrivial (Quotient.mk'' a✝) ↔ ¬length (Quotient.mk'' a✝) ≤ 1 [PROOFSTEP] simp [h, Nat.succ_le_iff] [GOAL] α : Type u_1 s : Cycle α ⊢ ∀ (a : List α), ↑Multiset.card (toMultiset (Quotient.mk'' a)) = length (Quotient.mk'' a) [PROOFSTEP] simp [GOAL] α : Type u_1 s : Cycle α ⊢ ∀ (a : List α), toMultiset (Quotient.mk'' a) = 0 ↔ Quotient.mk'' a = nil [PROOFSTEP] simp [GOAL] α : Type u_1 β : Type u_2 f : α → β s : Cycle α ⊢ ∀ (a : List α), map f (Quotient.mk'' a) = nil ↔ Quotient.mk'' a = nil [PROOFSTEP] simp [GOAL] α : Type u_1 β : Type u_2 f : α → β b : β s : Cycle α ⊢ ∀ (a : List α), b ∈ map f (Quotient.mk'' a) ↔ ∃ a_1, a_1 ∈ Quotient.mk'' a ∧ f a_1 = b [PROOFSTEP] simp [GOAL] α : Type u_1 s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ ⊢ (fun l => ↑(cyclicPermutations l)) l₁ = (fun l => ↑(cyclicPermutations l)) l₂ [PROOFSTEP] simpa using h.cyclicPermutations.perm [GOAL] α : Type u_1 s : Cycle α l✝ l : List α ⊢ l✝ ∈ lists (Quotient.mk'' l) ↔ ↑l✝ = Quotient.mk'' l [PROOFSTEP] rw [lists, Quotient.liftOn'_mk''] [GOAL] α : Type u_1 s : Cycle α l✝ l : List α ⊢ l✝ ∈ ↑(cyclicPermutations l) ↔ ↑l✝ = Quotient.mk'' l [PROOFSTEP] simp [GOAL] α : Type u_1 ⊢ lists nil = ↑[[]] [PROOFSTEP] rw [nil, lists_coe, cyclicPermutations_nil] [GOAL] α : Type u_1 inst✝ : DecidableEq α ⊢ ¬Nontrivial ↑[] [PROOFSTEP] simp [Nontrivial] [GOAL] α : Type u_1 inst✝ : DecidableEq α x : α ⊢ ¬Nontrivial ↑[x] [PROOFSTEP] simp [Nontrivial] [GOAL] α : Type u_1 inst✝ : DecidableEq α x y : α l : List α h : x = y ⊢ Nontrivial ↑(x :: y :: l) ↔ Nontrivial ↑(x :: l) [PROOFSTEP] simp [h, Nontrivial] [GOAL] α : Type u_1 inst✝ : DecidableEq α x y : α l : List α h : ¬x = y ⊢ x ∈ ↑(x :: y :: l) [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝ : DecidableEq α x y : α l : List α h : ¬x = y ⊢ y ∈ ↑(x :: y :: l) [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α l : { l // List.Nodup l } ⊢ Nodup ↑↑l [PROOFSTEP] simpa using l.prop [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α x✝ : { s // Nodup s } s : Cycle α hs : Nodup s ⊢ ∃ a, (fun l => { val := ↑↑l, property := (_ : Nodup ↑↑l) }) a = { val := s, property := hs } [PROOFSTEP] induction' s using Quotient.inductionOn' with s hs [GOAL] case h α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α x✝ : { s // Nodup s } s✝ : Cycle α hs✝ : Nodup s✝ s : List α hs : Nodup (Quotient.mk'' s) ⊢ ∃ a, (fun l => { val := ↑↑l, property := (_ : Nodup ↑↑l) }) a = { val := Quotient.mk'' s, property := hs } [PROOFSTEP] exact ⟨⟨s, hs⟩, by simp⟩ [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α x✝ : { s // Nodup s } s✝ : Cycle α hs✝ : Nodup s✝ s : List α hs : Nodup (Quotient.mk'' s) ⊢ (fun l => { val := ↑↑l, property := (_ : Nodup ↑↑l) }) { val := s, property := hs } = { val := Quotient.mk'' s, property := hs } [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝¹ : DecidableEq α inst✝ : Fintype α ⊢ ∀ (x : Cycle α), x ∈ Finset.filter Nontrivial (Finset.map (Function.Embedding.subtype fun s => Nodup s) Finset.univ) ↔ Nodup x ∧ Nontrivial x [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α ⊢ ∀ (a : List α), toFinset (Quotient.mk'' a) = ∅ ↔ Quotient.mk'' a = nil [PROOFSTEP] simp [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : HEq x y ⊢ x ∈ Quot.mk Setoid.r l₁ ↔ y ∈ Quot.mk Setoid.r l₂ [PROOFSTEP] rw [eq_of_heq hxy] [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : HEq x y ⊢ y ∈ Quot.mk Setoid.r l₁ ↔ y ∈ Quot.mk Setoid.r l₂ [PROOFSTEP] simpa [eq_of_heq hxy] using h.mem_iff [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : HEq x y hm : x ∈ Quot.mk Setoid.r l₁ hm' : y ∈ Quot.mk Setoid.r l₂ he' : HEq hm hm' ⊢ (fun l _hn x hx => List.next l x hx) l₁ h₁ x hm = (fun l _hn x hx => List.next l x hx) l₂ h₂ y hm' [PROOFSTEP] rw [heq_iff_eq] at hxy [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : x = y hm : x ∈ Quot.mk Setoid.r l₁ hm' : y ∈ Quot.mk Setoid.r l₂ he' : HEq hm hm' ⊢ (fun l _hn x hx => List.next l x hx) l₁ h₁ x hm = (fun l _hn x hx => List.next l x hx) l₂ h₂ y hm' [PROOFSTEP] subst x [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ y : α hm' : y ∈ Quot.mk Setoid.r l₂ hm : y ∈ Quot.mk Setoid.r l₁ he' : HEq hm hm' ⊢ (fun l _hn x hx => List.next l x hx) l₁ h₁ y hm = (fun l _hn x hx => List.next l x hx) l₂ h₂ y hm' [PROOFSTEP] simpa using isRotated_next_eq h h₁ _ [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : HEq x y ⊢ x ∈ Quot.mk Setoid.r l₁ ↔ y ∈ Quot.mk Setoid.r l₂ [PROOFSTEP] rw [eq_of_heq hxy] [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : HEq x y ⊢ y ∈ Quot.mk Setoid.r l₁ ↔ y ∈ Quot.mk Setoid.r l₂ [PROOFSTEP] simpa [eq_of_heq hxy] using h.mem_iff [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : HEq x y hm : x ∈ Quot.mk Setoid.r l₁ hm' : y ∈ Quot.mk Setoid.r l₂ he' : HEq hm hm' ⊢ (fun l _hn x hx => List.prev l x hx) l₁ h₁ x hm = (fun l _hn x hx => List.prev l x hx) l₂ h₂ y hm' [PROOFSTEP] rw [heq_iff_eq] at hxy [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ x y : α hxy : x = y hm : x ∈ Quot.mk Setoid.r l₁ hm' : y ∈ Quot.mk Setoid.r l₂ he' : HEq hm hm' ⊢ (fun l _hn x hx => List.prev l x hx) l₁ h₁ x hm = (fun l _hn x hx => List.prev l x hx) l₂ h₂ y hm' [PROOFSTEP] subst x [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α l₁ l₂ : List α h : Setoid.r l₁ l₂ h₁ : Nodup (Quot.mk Setoid.r l₁) h₂ : Nodup (Quot.mk Setoid.r l₂) _he : HEq h₁ h₂ y : α hm' : y ∈ Quot.mk Setoid.r l₂ hm : y ∈ Quot.mk Setoid.r l₁ he' : HEq hm hm' ⊢ (fun l _hn x hx => List.prev l x hx) l₁ h₁ y hm = (fun l _hn x hx => List.prev l x hx) l₂ h₂ y hm' [PROOFSTEP] simpa using isRotated_prev_eq h h₁ _ [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α hs : Nodup s x : α hx : x ∈ s ⊢ next (reverse s) (_ : Nodup (reverse s)) x (_ : x ∈ reverse s) = prev s hs x hx [PROOFSTEP] simp [← prev_reverse_eq_next] [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α hs : Nodup (reverse s) x : α hx : x ∈ reverse s ⊢ next (reverse s) hs x hx = prev s (_ : Nodup s) x (_ : x ∈ s) [PROOFSTEP] simp [← prev_reverse_eq_next] [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α hs : Nodup s x : α hx : x ∈ s ⊢ next s hs x hx ∈ s [PROOFSTEP] induction s using Quot.inductionOn [GOAL] case h α : Type u_1 inst✝ : DecidableEq α x : α a✝ : List α hs : Nodup (Quot.mk Setoid.r a✝) hx : x ∈ Quot.mk Setoid.r a✝ ⊢ next (Quot.mk Setoid.r a✝) hs x hx ∈ Quot.mk Setoid.r a✝ [PROOFSTEP] apply next_mem [GOAL] case h.h α : Type u_1 inst✝ : DecidableEq α x : α a✝ : List α hs : Nodup (Quot.mk Setoid.r a✝) hx : x ∈ Quot.mk Setoid.r a✝ ⊢ x ∈ a✝ [PROOFSTEP] assumption [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α hs : Nodup s x : α hx : x ∈ s ⊢ prev s hs x hx ∈ s [PROOFSTEP] rw [← next_reverse_eq_prev, ← mem_reverse_iff] [GOAL] α : Type u_1 inst✝ : DecidableEq α s : Cycle α hs : Nodup s x : α hx : x ∈ s ⊢ next (reverse s) (_ : Nodup (reverse s)) x (_ : x ∈ reverse s) ∈ reverse s [PROOFSTEP] apply next_mem [GOAL] α : Type u_1 r : α → α → Prop c : Cycle α a b : List α hab : Setoid.r a b ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) a ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) b [PROOFSTEP] cases' a with a l [GOAL] case nil α : Type u_1 r : α → α → Prop c : Cycle α b : List α hab : Setoid.r [] b ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) [] ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) b [PROOFSTEP] cases' b with b m [GOAL] case cons α : Type u_1 r : α → α → Prop c : Cycle α b : List α a : α l : List α hab : Setoid.r (a :: l) b ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) (a :: l) ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) b [PROOFSTEP] cases' b with b m [GOAL] case nil.nil α : Type u_1 r : α → α → Prop c : Cycle α hab : Setoid.r [] [] ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) [] ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) [] [PROOFSTEP] rfl [GOAL] case nil.cons α : Type u_1 r : α → α → Prop c : Cycle α b : α m : List α hab : Setoid.r [] (b :: m) ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) [] ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) (b :: m) [PROOFSTEP] have := isRotated_nil_iff'.1 hab [GOAL] case nil.cons α : Type u_1 r : α → α → Prop c : Cycle α b : α m : List α hab : Setoid.r [] (b :: m) this : [] = b :: m ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) [] ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) (b :: m) [PROOFSTEP] contradiction [GOAL] case cons.nil α : Type u_1 r : α → α → Prop c : Cycle α a : α l : List α hab : Setoid.r (a :: l) [] ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) (a :: l) ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) [] [PROOFSTEP] have := isRotated_nil_iff.1 hab [GOAL] case cons.nil α : Type u_1 r : α → α → Prop c : Cycle α a : α l : List α hab : Setoid.r (a :: l) [] this : a :: l = [] ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) (a :: l) ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) [] [PROOFSTEP] contradiction [GOAL] case cons.cons α : Type u_1 r : α → α → Prop c : Cycle α a : α l : List α b : α m : List α hab : Setoid.r (a :: l) (b :: m) ⊢ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) (a :: l) ↔ (fun l => match l with | [] => True | a :: m => List.Chain r a (m ++ [a])) (b :: m) [PROOFSTEP] dsimp only [GOAL] case cons.cons α : Type u_1 r : α → α → Prop c : Cycle α a : α l : List α b : α m : List α hab : Setoid.r (a :: l) (b :: m) ⊢ List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] cases' hab with n hn [GOAL] case cons.cons.intro α : Type u_1 r : α → α → Prop c : Cycle α a : α l : List α b : α m : List α n : ℕ hn : rotate (a :: l) n = b :: m ⊢ List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] induction' n with d hd generalizing a b l m [GOAL] case cons.cons.intro.zero α : Type u_1 r : α → α → Prop c : Cycle α a✝ : α l✝ : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l✝) n = b✝ :: m✝ a : α l : List α b : α m : List α hn : rotate (a :: l) Nat.zero = b :: m ⊢ List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] simp only [Nat.zero_eq, rotate_zero, cons.injEq] at hn [GOAL] case cons.cons.intro.zero α : Type u_1 r : α → α → Prop c : Cycle α a✝ : α l✝ : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l✝) n = b✝ :: m✝ a : α l : List α b : α m : List α hn : a = b ∧ l = m ⊢ List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] rw [hn.1, hn.2] [GOAL] case cons.cons.intro.succ α : Type u_1 r : α → α → Prop c : Cycle α a✝ : α l✝ : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l✝) n = b✝ :: m✝ d : ℕ hd : ∀ (a : α) (l : List α) (b : α) (m : List α), rotate (a :: l) d = b :: m → (List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b])) a : α l : List α b : α m : List α hn : rotate (a :: l) (Nat.succ d) = b :: m ⊢ List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] cases' l with c s [GOAL] case cons.cons.intro.succ.nil α : Type u_1 r : α → α → Prop c : Cycle α a✝ : α l : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l) n = b✝ :: m✝ d : ℕ hd : ∀ (a : α) (l : List α) (b : α) (m : List α), rotate (a :: l) d = b :: m → (List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b])) a b : α m : List α hn : rotate [a] (Nat.succ d) = b :: m ⊢ List.Chain r a ([] ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] simp only [rotate_cons_succ, nil_append, rotate_singleton, cons.injEq] at hn [GOAL] case cons.cons.intro.succ.nil α : Type u_1 r : α → α → Prop c : Cycle α a✝ : α l : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l) n = b✝ :: m✝ d : ℕ hd : ∀ (a : α) (l : List α) (b : α) (m : List α), rotate (a :: l) d = b :: m → (List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b])) a b : α m : List α hn : a = b ∧ [] = m ⊢ List.Chain r a ([] ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] rw [hn.1, hn.2] [GOAL] case cons.cons.intro.succ.cons α : Type u_1 r : α → α → Prop c✝ : Cycle α a✝ : α l : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l) n = b✝ :: m✝ d : ℕ hd : ∀ (a : α) (l : List α) (b : α) (m : List α), rotate (a :: l) d = b :: m → (List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b])) a b : α m : List α c : α s : List α hn : rotate (a :: c :: s) (Nat.succ d) = b :: m ⊢ List.Chain r a (c :: s ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] rw [Nat.succ_eq_one_add, ← rotate_rotate, rotate_cons_succ, rotate_zero, cons_append] at hn [GOAL] case cons.cons.intro.succ.cons α : Type u_1 r : α → α → Prop c✝ : Cycle α a✝ : α l : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l) n = b✝ :: m✝ d : ℕ hd : ∀ (a : α) (l : List α) (b : α) (m : List α), rotate (a :: l) d = b :: m → (List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b])) a b : α m : List α c : α s : List α hn : rotate (c :: (s ++ [a])) d = b :: m ⊢ List.Chain r a (c :: s ++ [a]) ↔ List.Chain r b (m ++ [b]) [PROOFSTEP] rw [← hd c _ _ _ hn] [GOAL] case cons.cons.intro.succ.cons α : Type u_1 r : α → α → Prop c✝ : Cycle α a✝ : α l : List α b✝ : α m✝ : List α n : ℕ hn✝ : rotate (a✝ :: l) n = b✝ :: m✝ d : ℕ hd : ∀ (a : α) (l : List α) (b : α) (m : List α), rotate (a :: l) d = b :: m → (List.Chain r a (l ++ [a]) ↔ List.Chain r b (m ++ [b])) a b : α m : List α c : α s : List α hn : rotate (c :: (s ++ [a])) d = b :: m ⊢ List.Chain r a (c :: s ++ [a]) ↔ List.Chain r c (s ++ [a] ++ [c]) [PROOFSTEP] simp [and_comm] [GOAL] α : Type u_1 r : α → α → Prop ⊢ Chain r Cycle.nil [PROOFSTEP] trivial [GOAL] α : Type u_1 r : α → α → Prop a : α ⊢ Chain r ↑[a] ↔ r a a [PROOFSTEP] rw [chain_coe_cons, nil_append, List.chain_singleton] [GOAL] α : Type u_1 r : α → α → Prop l : List α ⊢ ∀ (l : List α) (a : α), (∀ (hl : l ≠ []), Chain r ↑l ↔ List.Chain r (getLast l hl) l) → ∀ (hl : l ++ [a] ≠ []), Chain r ↑(l ++ [a]) ↔ List.Chain r (getLast (l ++ [a]) hl) (l ++ [a]) [PROOFSTEP] intro m a _H _ [GOAL] α : Type u_1 r : α → α → Prop l m : List α a : α _H : ∀ (hl : m ≠ []), Chain r ↑m ↔ List.Chain r (getLast m hl) m hl✝ : m ++ [a] ≠ [] ⊢ Chain r ↑(m ++ [a]) ↔ List.Chain r (getLast (m ++ [a]) hl✝) (m ++ [a]) [PROOFSTEP] rw [← coe_cons_eq_coe_append, chain_coe_cons, getLast_append_singleton] [GOAL] α : Type u_1 β : Type u_2 r : α → α → Prop f : β → α s : Cycle β l : List β ⊢ Chain r (map f (Quotient.mk'' l)) ↔ Chain (fun a b => r (f a) (f b)) (Quotient.mk'' l) [PROOFSTEP] cases' l with a l [GOAL] case nil α : Type u_1 β : Type u_2 r : α → α → Prop f : β → α s : Cycle β ⊢ Chain r (map f (Quotient.mk'' [])) ↔ Chain (fun a b => r (f a) (f b)) (Quotient.mk'' []) case cons α : Type u_1 β : Type u_2 r : α → α → Prop f : β → α s : Cycle β a : β l : List β ⊢ Chain r (map f (Quotient.mk'' (a :: l))) ↔ Chain (fun a b => r (f a) (f b)) (Quotient.mk'' (a :: l)) [PROOFSTEP] rfl [GOAL] case cons α : Type u_1 β : Type u_2 r : α → α → Prop f : β → α s : Cycle β a : β l : List β ⊢ Chain r (map f (Quotient.mk'' (a :: l))) ↔ Chain (fun a b => r (f a) (f b)) (Quotient.mk'' (a :: l)) [PROOFSTEP] dsimp only [Chain, ← mk''_eq_coe, Quotient.liftOn'_mk'', Cycle.map, Quotient.map', Quot.map, Quotient.mk'', Quotient.liftOn', Quotient.liftOn, Quot.liftOn_mk, List.map] [GOAL] case cons α : Type u_1 β : Type u_2 r : α → α → Prop f : β → α s : Cycle β a : β l : List β ⊢ List.Chain r (f a) (List.map f l ++ [f a]) ↔ List.Chain (fun a b => r (f a) (f b)) a (l ++ [a]) [PROOFSTEP] rw [← concat_eq_append, ← List.map_concat, List.chain_map f] [GOAL] case cons α : Type u_1 β : Type u_2 r : α → α → Prop f : β → α s : Cycle β a : β l : List β ⊢ List.Chain (fun a b => r (f a) (f b)) a (concat l a) ↔ List.Chain (fun a b => r (f a) (f b)) a (l ++ [a]) [PROOFSTEP] simp [GOAL] α : Type u_1 r : ℕ → ℕ → Prop n : ℕ ⊢ Chain r ↑(range (Nat.succ n)) ↔ r n 0 ∧ ∀ (m : ℕ), m < n → r m (Nat.succ m) [PROOFSTEP] rw [range_succ, ← coe_cons_eq_coe_append, chain_coe_cons, ← range_succ, chain_range_succ] [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α r₁ r₂ : α → α → Prop H : ∀ (a b : α), r₁ a b → r₂ a b p : Chain r₁ s ⊢ Chain r₂ s [PROOFSTEP] induction s using Cycle.induction_on [GOAL] case H0 α : Type u_1 r : α → α → Prop s : Cycle α r₁ r₂ : α → α → Prop H : ∀ (a b : α), r₁ a b → r₂ a b p : Chain r₁ Cycle.nil ⊢ Chain r₂ Cycle.nil [PROOFSTEP] triv [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α r₁ r₂ : α → α → Prop H : ∀ (a b : α), r₁ a b → r₂ a b a✝¹ : α l✝ : List α a✝ : Chain r₁ ↑l✝ → Chain r₂ ↑l✝ p : Chain r₁ ↑(a✝¹ :: l✝) ⊢ Chain r₂ ↑(a✝¹ :: l✝) [PROOFSTEP] rw [chain_coe_cons] at p ⊢ [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α r₁ r₂ : α → α → Prop H : ∀ (a b : α), r₁ a b → r₂ a b a✝¹ : α l✝ : List α a✝ : Chain r₁ ↑l✝ → Chain r₂ ↑l✝ p : List.Chain r₁ a✝¹ (l✝ ++ [a✝¹]) ⊢ List.Chain r₂ a✝¹ (l✝ ++ [a✝¹]) [PROOFSTEP] exact p.imp H [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α ⊢ (∀ (a : α), a ∈ s → ∀ (b : α), b ∈ s → r a b) → Chain r s [PROOFSTEP] induction' s using Cycle.induction_on with a l _ [GOAL] case H0 α : Type u_1 r : α → α → Prop s : Cycle α ⊢ (∀ (a : α), a ∈ nil → ∀ (b : α), b ∈ nil → r a b) → Chain r nil case HI α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l ⊢ (∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b) → Chain r ↑(a :: l) [PROOFSTEP] exact fun _ => Cycle.Chain.nil r [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l ⊢ (∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b) → Chain r ↑(a :: l) [PROOFSTEP] intro hs [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b ⊢ Chain r ↑(a :: l) [PROOFSTEP] have Ha : a ∈ (a :: l : Cycle α) := by simp [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b ⊢ a ∈ ↑(a :: l) [PROOFSTEP] simp [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) ⊢ Chain r ↑(a :: l) [PROOFSTEP] have Hl : ∀ {b} (_hb : b ∈ l), b ∈ (a :: l : Cycle α) := @fun b hb => by simp [hb] [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) b : α hb : b ∈ l ⊢ b ∈ ↑(a :: l) [PROOFSTEP] simp [hb] [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) ⊢ Chain r ↑(a :: l) [PROOFSTEP] rw [Cycle.chain_coe_cons] [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) ⊢ List.Chain r a (l ++ [a]) [PROOFSTEP] apply Pairwise.chain [GOAL] case HI.p α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) ⊢ List.Pairwise r (a :: (l ++ [a])) [PROOFSTEP] rw [pairwise_cons] [GOAL] case HI.p α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) ⊢ (∀ (a' : α), a' ∈ l ++ [a] → r a a') ∧ List.Pairwise r (l ++ [a]) [PROOFSTEP] refine' ⟨fun b hb => _, pairwise_append.2 ⟨pairwise_of_forall_mem_list fun b hb c hc => hs b (Hl hb) c (Hl hc), pairwise_singleton r a, fun b hb c hc => _⟩⟩ [GOAL] case HI.p.refine'_1 α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b ∈ l ++ [a] ⊢ r a b [PROOFSTEP] rw [mem_append] at hb [GOAL] case HI.p.refine'_1 α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b ∈ l ∨ b ∈ [a] ⊢ r a b [PROOFSTEP] cases' hb with hb hb [GOAL] case HI.p.refine'_1.inl α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b ∈ l ⊢ r a b [PROOFSTEP] exact hs a Ha b (Hl hb) [GOAL] case HI.p.refine'_1.inr α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b ∈ [a] ⊢ r a b [PROOFSTEP] rw [mem_singleton] at hb [GOAL] case HI.p.refine'_1.inr α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b = a ⊢ r a b [PROOFSTEP] rw [hb] [GOAL] case HI.p.refine'_1.inr α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b = a ⊢ r a a [PROOFSTEP] exact hs a Ha a Ha [GOAL] case HI.p.refine'_2 α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b ∈ l c : α hc : c ∈ [a] ⊢ r b c [PROOFSTEP] rw [mem_singleton] at hc [GOAL] case HI.p.refine'_2 α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b ∈ l c : α hc : c = a ⊢ r b c [PROOFSTEP] rw [hc] [GOAL] case HI.p.refine'_2 α : Type u_1 r : α → α → Prop s : Cycle α a : α l : List α a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b Ha : a ∈ ↑(a :: l) Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l) b : α hb : b ∈ l c : α hc : c = a ⊢ r b a [PROOFSTEP] exact hs b (Hl hb) a Ha [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r ⊢ Chain r s → ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ s → r a b [PROOFSTEP] induction' s using Cycle.induction_on with a l _ [GOAL] case H0 α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r ⊢ Chain r nil → ∀ (a : α), a ∈ nil → ∀ (b : α), b ∈ nil → r a b [PROOFSTEP] exact fun _ b hb => (not_mem_nil _ hb).elim [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r a : α l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b ⊢ Chain r ↑(a :: l) → ∀ (a_2 : α), a_2 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_2 b [PROOFSTEP] intro hs b hb c hc [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r a : α l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b hs : Chain r ↑(a :: l) b : α hb : b ∈ ↑(a :: l) c : α hc : c ∈ ↑(a :: l) ⊢ r b c [PROOFSTEP] rw [Cycle.chain_coe_cons, List.chain_iff_pairwise] at hs [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r a : α l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b hs : List.Pairwise r (a :: (l ++ [a])) b : α hb : b ∈ ↑(a :: l) c : α hc : c ∈ ↑(a :: l) ⊢ r b c [PROOFSTEP] simp only [pairwise_append, pairwise_cons, mem_append, mem_singleton, List.not_mem_nil, IsEmpty.forall_iff, imp_true_iff, Pairwise.nil, forall_eq, true_and_iff] at hs [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r a : α l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b b : α hb : b ∈ ↑(a :: l) c : α hc : c ∈ ↑(a :: l) hs : (∀ (a' : α), a' ∈ l ∨ a' = a → r a a') ∧ List.Pairwise r l ∧ ∀ (a_1 : α), a_1 ∈ l → r a_1 a ⊢ r b c [PROOFSTEP] simp only [mem_coe_iff, mem_cons] at hb hc [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r a : α l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b b c : α hs : (∀ (a' : α), a' ∈ l ∨ a' = a → r a a') ∧ List.Pairwise r l ∧ ∀ (a_1 : α), a_1 ∈ l → r a_1 a hb : b = a ∨ b ∈ l hc : c = a ∨ c ∈ l ⊢ r b c [PROOFSTEP] rcases hb with (rfl | hb) [GOAL] case HI.inl α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b b c : α hs : (∀ (a' : α), a' ∈ l ∨ a' = b → r b a') ∧ List.Pairwise r l ∧ ∀ (a : α), a ∈ l → r a b hc : c = b ∨ c ∈ l ⊢ r b c [PROOFSTEP] rcases hc with (rfl | hc) [GOAL] case HI.inr α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r a : α l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b b c : α hs : (∀ (a' : α), a' ∈ l ∨ a' = a → r a a') ∧ List.Pairwise r l ∧ ∀ (a_1 : α), a_1 ∈ l → r a_1 a hc : c = a ∨ c ∈ l hb : b ∈ l ⊢ r b c [PROOFSTEP] rcases hc with (rfl | hc) [GOAL] case HI.inl.inl α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b c : α hs : (∀ (a' : α), a' ∈ l ∨ a' = c → r c a') ∧ List.Pairwise r l ∧ ∀ (a : α), a ∈ l → r a c ⊢ r c c [PROOFSTEP] exact hs.1 c (Or.inr rfl) [GOAL] case HI.inl.inr α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b b c : α hs : (∀ (a' : α), a' ∈ l ∨ a' = b → r b a') ∧ List.Pairwise r l ∧ ∀ (a : α), a ∈ l → r a b hc : c ∈ l ⊢ r b c [PROOFSTEP] exact hs.1 c (Or.inl hc) [GOAL] case HI.inr.inl α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b b c : α hb : b ∈ l hs : (∀ (a' : α), a' ∈ l ∨ a' = c → r c a') ∧ List.Pairwise r l ∧ ∀ (a : α), a ∈ l → r a c ⊢ r b c [PROOFSTEP] exact hs.2.2 b hb [GOAL] case HI.inr.inr α : Type u_1 r : α → α → Prop s : Cycle α inst✝ : IsTrans α r a : α l : List α a✝ : Chain r ↑l → ∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b b c : α hs : (∀ (a' : α), a' ∈ l ∨ a' = a → r a a') ∧ List.Pairwise r l ∧ ∀ (a_1 : α), a_1 ∈ l → r a_1 a hb : b ∈ l hc : c ∈ l ⊢ r b c [PROOFSTEP] exact _root_.trans (hs.2.2 b hb) (hs.1 c (Or.inl hc)) [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α inst✝¹ : IsTrans α r inst✝ : IsIrrefl α r h : Chain r s ⊢ s = Cycle.nil [PROOFSTEP] induction' s using Cycle.induction_on with a l _ h [GOAL] case H0 α : Type u_1 r : α → α → Prop s : Cycle α inst✝¹ : IsTrans α r inst✝ : IsIrrefl α r h✝ : Chain r s h : Chain r Cycle.nil ⊢ Cycle.nil = Cycle.nil [PROOFSTEP] rfl [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α inst✝¹ : IsTrans α r inst✝ : IsIrrefl α r h✝ : Chain r s a : α l : List α a✝ : Chain r ↑l → ↑l = Cycle.nil h : Chain r ↑(a :: l) ⊢ ↑(a :: l) = Cycle.nil [PROOFSTEP] have ha := mem_cons_self a l [GOAL] case HI α : Type u_1 r : α → α → Prop s : Cycle α inst✝¹ : IsTrans α r inst✝ : IsIrrefl α r h✝ : Chain r s a : α l : List α a✝ : Chain r ↑l → ↑l = Cycle.nil h : Chain r ↑(a :: l) ha : a ∈ a :: l ⊢ ↑(a :: l) = Cycle.nil [PROOFSTEP] exact (irrefl_of r a <| chain_iff_pairwise.1 h a ha a ha).elim [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α inst✝¹ : IsTrans α r inst✝ : IsAntisymm α r hs : Chain r s a b : α ha : a ∈ s hb : b ∈ s ⊢ a = b [PROOFSTEP] rw [chain_iff_pairwise] at hs [GOAL] α : Type u_1 r : α → α → Prop s : Cycle α inst✝¹ : IsTrans α r inst✝ : IsAntisymm α r hs : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ s → r a b a b : α ha : a ∈ s hb : b ∈ s ⊢ a = b [PROOFSTEP] exact antisymm (hs a ha b hb) (hs b hb a ha)
[GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y z : E hz : z ∈ segment 𝕜 x y hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q ⊢ ¬Disjoint (segment 𝕜 u v) (↑(convexHull 𝕜) {p, q, z}) [PROOFSTEP] rw [not_disjoint_iff] [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y z : E hz : z ∈ segment 𝕜 x y hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q ⊢ ∃ x, x ∈ segment 𝕜 u v ∧ x ∈ ↑(convexHull 𝕜) {p, q, z} [PROOFSTEP] obtain ⟨az, bz, haz, hbz, habz, rfl⟩ := hz [GOAL] case intro.intro.intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u v ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] obtain rfl | haz' := haz.eq_or_lt [GOAL] case intro.intro.intro.intro.intro.inl 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q bz : 𝕜 hbz : 0 ≤ bz haz : 0 ≤ 0 habz : 0 + bz = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u v ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, 0 • x + bz • y} [PROOFSTEP] rw [zero_add] at habz [GOAL] case intro.intro.intro.intro.intro.inl 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q bz : 𝕜 hbz : 0 ≤ bz haz : 0 ≤ 0 habz : bz = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u v ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, 0 • x + bz • y} [PROOFSTEP] rw [zero_smul, zero_add, habz, one_smul] [GOAL] case intro.intro.intro.intro.intro.inl 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q bz : 𝕜 hbz : 0 ≤ bz haz : 0 ≤ 0 habz : bz = 1 ⊢ ∃ x, x ∈ segment 𝕜 u v ∧ x ∈ ↑(convexHull 𝕜) {p, q, y} [PROOFSTEP] refine' ⟨v, by apply right_mem_segment, segment_subset_convexHull _ _ hv⟩ [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q bz : 𝕜 hbz : 0 ≤ bz haz : 0 ≤ 0 habz : bz = 1 ⊢ v ∈ segment 𝕜 u v [PROOFSTEP] apply right_mem_segment [GOAL] case intro.intro.intro.intro.intro.inl.refine'_1 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q bz : 𝕜 hbz : 0 ≤ bz haz : 0 ≤ 0 habz : bz = 1 ⊢ y ∈ {p, q, y} [PROOFSTEP] simp [GOAL] case intro.intro.intro.intro.intro.inl.refine'_2 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q bz : 𝕜 hbz : 0 ≤ bz haz : 0 ≤ 0 habz : bz = 1 ⊢ q ∈ {p, q, y} [PROOFSTEP] simp [GOAL] case intro.intro.intro.intro.intro.inr 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u v x y : E hu : u ∈ segment 𝕜 x p hv : v ∈ segment 𝕜 y q az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u v ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] obtain ⟨av, bv, hav, hbv, habv, rfl⟩ := hv [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u x y : E hu : u ∈ segment 𝕜 x p az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u (av • y + bv • q) ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] obtain rfl | hav' := hav.eq_or_lt [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inl 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u x y : E hu : u ∈ segment 𝕜 x p az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az bv : 𝕜 hbv : 0 ≤ bv hav : 0 ≤ 0 habv : 0 + bv = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u (0 • y + bv • q) ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] rw [zero_add] at habv [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inl 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u x y : E hu : u ∈ segment 𝕜 x p az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az bv : 𝕜 hbv : 0 ≤ bv hav : 0 ≤ 0 habv : bv = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u (0 • y + bv • q) ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] rw [zero_smul, zero_add, habv, one_smul] [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inl 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u x y : E hu : u ∈ segment 𝕜 x p az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az bv : 𝕜 hbv : 0 ≤ bv hav : 0 ≤ 0 habv : bv = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u q ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] exact ⟨q, right_mem_segment _ _ _, subset_convexHull _ _ <| by simp⟩ [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u x y : E hu : u ∈ segment 𝕜 x p az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az bv : 𝕜 hbv : 0 ≤ bv hav : 0 ≤ 0 habv : bv = 1 ⊢ q ∈ {p, q, az • x + bz • y} [PROOFSTEP] simp [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q u x y : E hu : u ∈ segment 𝕜 x p az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av ⊢ ∃ x_1, x_1 ∈ segment 𝕜 u (av • y + bv • q) ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] obtain ⟨au, bu, hau, hbu, habu, rfl⟩ := hu [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 ⊢ ∃ x_1, x_1 ∈ segment 𝕜 (au • x + bu • p) (av • y + bv • q) ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] have hab : 0 < az * av + bz * au := add_pos_of_pos_of_nonneg (mul_pos haz' hav') (mul_nonneg hbz hau) [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au ⊢ ∃ x_1, x_1 ∈ segment 𝕜 (au • x + bu • p) (av • y + bv • q) ∧ x_1 ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] refine' ⟨(az * av / (az * av + bz * au)) • (au • x + bu • p) + (bz * au / (az * av + bz * au)) • (av • y + bv • q), ⟨_, _, _, _, _, rfl⟩, _⟩ [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_1 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au ⊢ 0 ≤ az * av / (az * av + bz * au) [PROOFSTEP] exact div_nonneg (mul_nonneg haz hav) hab.le [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_2 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au ⊢ 0 ≤ bz * au / (az * av + bz * au) [PROOFSTEP] exact div_nonneg (mul_nonneg hbz hau) hab.le [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_3 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au ⊢ az * av / (az * av + bz * au) + bz * au / (az * av + bz * au) = 1 [PROOFSTEP] rw [← add_div, div_self hab.ne'] [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au ⊢ (az * av / (az * av + bz * au)) • (au • x + bu • p) + (bz * au / (az * av + bz * au)) • (av • y + bv • q) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] rw [smul_add, smul_add, add_add_add_comm, add_comm, ← mul_smul, ← mul_smul] [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] classical let w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] let z : Fin 3 → E := ![p, q, az • x + bz • y] have hw₀ : ∀ i, 0 ≤ w i := by rintro i fin_cases i · exact mul_nonneg (mul_nonneg haz hav) hbu · exact mul_nonneg (mul_nonneg hbz hau) hbv · exact mul_nonneg hau hav have hw : ∑ i, w i = az * av + bz * au := by trans az * av * bu + (bz * au * bv + au * av) · simp [Fin.sum_univ_succ, Fin.sum_univ_zero] rw [← one_mul (au * av), ← habz, add_mul, ← add_assoc, add_add_add_comm, mul_assoc, ← mul_add, mul_assoc, ← mul_add, mul_comm av, ← add_mul, ← mul_add, add_comm bu, add_comm bv, habu, habv, one_mul, mul_one] have hz : ∀ i, z i ∈ ({p, q, az • x + bz • y} : Set E) := fun i => by fin_cases i <;> simp convert Finset.centerMass_mem_convexHull (Finset.univ : Finset (Fin 3)) (fun i _ => hw₀ i) (by rwa [hw]) fun i _ => hz i rw [Finset.centerMass] simp_rw [div_eq_inv_mul, hw, mul_assoc, mul_smul (az * av + bz * au)⁻¹, ← smul_add, add_assoc, ← mul_assoc] congr 3 rw [← mul_smul, ← mul_rotate, mul_right_comm, mul_smul, ← mul_smul _ av, mul_rotate, mul_smul _ bz, ← smul_add] simp only [smul_add, List.foldr, Matrix.cons_val_succ', Fin.mk_one, Matrix.cons_val_one, Matrix.head_cons, add_zero] [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] let w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] let z : Fin 3 → E := ![p, q, az • x + bz • y] [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] have hw₀ : ∀ i, 0 ≤ w i := by rintro i fin_cases i · exact mul_nonneg (mul_nonneg haz hav) hbu · exact mul_nonneg (mul_nonneg hbz hau) hbv · exact mul_nonneg hau hav [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] ⊢ ∀ (i : Fin 3), 0 ≤ w i [PROOFSTEP] rintro i [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] i : Fin 3 ⊢ 0 ≤ w i [PROOFSTEP] fin_cases i [GOAL] case head 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] ⊢ 0 ≤ w { val := 0, isLt := (_ : 0 < 3) } [PROOFSTEP] exact mul_nonneg (mul_nonneg haz hav) hbu [GOAL] case tail.head 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] ⊢ 0 ≤ w { val := 1, isLt := (_ : (fun a => a < 3) 1) } [PROOFSTEP] exact mul_nonneg (mul_nonneg hbz hau) hbv [GOAL] case tail.tail.head 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] ⊢ 0 ≤ w { val := 2, isLt := (_ : (fun a => (fun a => a < 3) a) 2) } [PROOFSTEP] exact mul_nonneg hau hav [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] have hw : ∑ i, w i = az * av + bz * au := by trans az * av * bu + (bz * au * bv + au * av) · simp [Fin.sum_univ_succ, Fin.sum_univ_zero] rw [← one_mul (au * av), ← habz, add_mul, ← add_assoc, add_add_add_comm, mul_assoc, ← mul_add, mul_assoc, ← mul_add, mul_comm av, ← add_mul, ← mul_add, add_comm bu, add_comm bv, habu, habv, one_mul, mul_one] [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i ⊢ ∑ i : Fin 3, w i = az * av + bz * au [PROOFSTEP] trans az * av * bu + (bz * au * bv + au * av) [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i ⊢ ∑ i : Fin 3, w i = az * av * bu + (bz * au * bv + au * av) [PROOFSTEP] simp [Fin.sum_univ_succ, Fin.sum_univ_zero] [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i ⊢ az * av * bu + (bz * au * bv + au * av) = az * av + bz * au [PROOFSTEP] rw [← one_mul (au * av), ← habz, add_mul, ← add_assoc, add_add_add_comm, mul_assoc, ← mul_add, mul_assoc, ← mul_add, mul_comm av, ← add_mul, ← mul_add, add_comm bu, add_comm bv, habu, habv, one_mul, mul_one] [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] have hz : ∀ i, z i ∈ ({p, q, az • x + bz • y} : Set E) := fun i => by fin_cases i <;> simp [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au i : Fin 3 ⊢ z i ∈ {p, q, az • x + bz • y} [PROOFSTEP] fin_cases i [GOAL] case head 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au ⊢ z { val := 0, isLt := (_ : 0 < 3) } ∈ {p, q, az • x + bz • y} [PROOFSTEP] simp [GOAL] case tail.head 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au ⊢ z { val := 1, isLt := (_ : (fun a => a < 3) 1) } ∈ {p, q, az • x + bz • y} [PROOFSTEP] simp [GOAL] case tail.tail.head 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au ⊢ z { val := 2, isLt := (_ : (fun a => (fun a => a < 3) a) 2) } ∈ {p, q, az • x + bz • y} [PROOFSTEP] simp [GOAL] case intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.inr.intro.intro.intro.intro.intro.refine'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au hz : ∀ (i : Fin 3), z i ∈ {p, q, az • x + bz • y} ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) ∈ ↑(convexHull 𝕜) {p, q, az • x + bz • y} [PROOFSTEP] convert Finset.centerMass_mem_convexHull (Finset.univ : Finset (Fin 3)) (fun i _ => hw₀ i) (by rwa [hw]) fun i _ => hz i [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au hz : ∀ (i : Fin 3), z i ∈ {p, q, az • x + bz • y} ⊢ 0 < ∑ i : Fin 3, w i [PROOFSTEP] rwa [hw] [GOAL] case h.e'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au hz : ∀ (i : Fin 3), z i ∈ {p, q, az • x + bz • y} ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) = Finset.centerMass Finset.univ (fun i => w i) fun i => z i [PROOFSTEP] rw [Finset.centerMass] [GOAL] case h.e'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au hz : ∀ (i : Fin 3), z i ∈ {p, q, az • x + bz • y} ⊢ (az * av / (az * av + bz * au) * bu) • p + (bz * au / (az * av + bz * au) * bv) • q + ((az * av / (az * av + bz * au)) • au • x + (bz * au / (az * av + bz * au)) • av • y) = (∑ i : Fin 3, w i)⁻¹ • ∑ i : Fin 3, w i • z i [PROOFSTEP] simp_rw [div_eq_inv_mul, hw, mul_assoc, mul_smul (az * av + bz * au)⁻¹, ← smul_add, add_assoc, ← mul_assoc] [GOAL] case h.e'_4 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au hz : ∀ (i : Fin 3), z i ∈ {p, q, az • x + bz • y} ⊢ (az * av + bz * au)⁻¹ • ((az * av * bu) • p + ((bz * au * bv) • q + ((az * av) • au • x + (bz * au) • av • y))) = (az * av + bz * au)⁻¹ • ∑ x_1 : Fin 3, Matrix.vecCons (az * av * bu) ![bz * au * bv, au * av] x_1 • Matrix.vecCons p ![q, az • x + bz • y] x_1 [PROOFSTEP] congr 3 [GOAL] case h.e'_4.e_a.e_a.e_a 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au hz : ∀ (i : Fin 3), z i ∈ {p, q, az • x + bz • y} ⊢ (az * av) • au • x + (bz * au) • av • y = List.foldr (fun x x_1 => x + x_1) 0 (List.map (fun x_1 => Matrix.vecCons (az * av * bu) ![bz * au * bv, au * av] x_1 • Matrix.vecCons p ![q, az • x + bz • y] x_1) (List.pmap Fin.mk [2] (_ : ∀ (x : ℕ), x ∈ [2] → (fun a => a < 3) x))) [PROOFSTEP] rw [← mul_smul, ← mul_rotate, mul_right_comm, mul_smul, ← mul_smul _ av, mul_rotate, mul_smul _ bz, ← smul_add] [GOAL] case h.e'_4.e_a.e_a.e_a 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E p q x y : E az bz : 𝕜 haz : 0 ≤ az hbz : 0 ≤ bz habz : az + bz = 1 haz' : 0 < az av bv : 𝕜 hav : 0 ≤ av hbv : 0 ≤ bv habv : av + bv = 1 hav' : 0 < av au bu : 𝕜 hau : 0 ≤ au hbu : 0 ≤ bu habu : au + bu = 1 hab : 0 < az * av + bz * au w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] z : Fin 3 → E := ![p, q, az • x + bz • y] hw₀ : ∀ (i : Fin 3), 0 ≤ w i hw : ∑ i : Fin 3, w i = az * av + bz * au hz : ∀ (i : Fin 3), z i ∈ {p, q, az • x + bz • y} ⊢ (au * av) • (az • x + bz • y) = List.foldr (fun x x_1 => x + x_1) 0 (List.map (fun x_1 => Matrix.vecCons (az * av * bu) ![bz * au * bv, au * av] x_1 • Matrix.vecCons p ![q, az • x + bz • y] x_1) (List.pmap Fin.mk [2] (_ : ∀ (x : ℕ), x ∈ [2] → (fun a => a < 3) x))) [PROOFSTEP] simp only [smul_add, List.foldr, Matrix.cons_val_succ', Fin.mk_one, Matrix.cons_val_one, Matrix.head_cons, add_zero] [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t ⊢ ∃ C, Convex 𝕜 C ∧ Convex 𝕜 Cᶜ ∧ s ⊆ C ∧ t ⊆ Cᶜ [PROOFSTEP] let S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} [GOAL] 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} ⊢ ∃ C, Convex 𝕜 C ∧ Convex 𝕜 Cᶜ ∧ s ⊆ C ∧ t ⊆ Cᶜ [PROOFSTEP] obtain ⟨C, hC, hsC, hCmax⟩ := zorn_subset_nonempty S (fun c hcS hc ⟨_, _⟩ => ⟨⋃₀ c, ⟨hc.directedOn.convex_sUnion fun s hs => (hcS hs).1, disjoint_sUnion_left.2 fun c hc => (hcS hc).2⟩, fun s => subset_sUnion_of_mem⟩) s ⟨hs, hst⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C ⊢ ∃ C, Convex 𝕜 C ∧ Convex 𝕜 Cᶜ ∧ s ⊆ C ∧ t ⊆ Cᶜ [PROOFSTEP] refine' ⟨C, hC.1, convex_iff_segment_subset.2 fun x hx y hy z hz hzC => _, hsC, hC.2.subset_compl_left⟩ [GOAL] case intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C ⊢ False [PROOFSTEP] suffices h : ∀ c ∈ Cᶜ, ∃ a ∈ C, (segment 𝕜 c a ∩ t).Nonempty [GOAL] case intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C h : ∀ (c : E), c ∈ Cᶜ → ∃ a, a ∈ C ∧ Set.Nonempty (segment 𝕜 c a ∩ t) ⊢ False [PROOFSTEP] obtain ⟨p, hp, u, hu, hut⟩ := h x hx [GOAL] case intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C h : ∀ (c : E), c ∈ Cᶜ → ∃ a, a ∈ C ∧ Set.Nonempty (segment 𝕜 c a ∩ t) p : E hp : p ∈ C u : E hu : u ∈ segment 𝕜 x p hut : u ∈ t ⊢ False [PROOFSTEP] obtain ⟨q, hq, v, hv, hvt⟩ := h y hy [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C h : ∀ (c : E), c ∈ Cᶜ → ∃ a, a ∈ C ∧ Set.Nonempty (segment 𝕜 c a ∩ t) p : E hp : p ∈ C u : E hu : u ∈ segment 𝕜 x p hut : u ∈ t q : E hq : q ∈ C v : E hv : v ∈ segment 𝕜 y q hvt : v ∈ t ⊢ False [PROOFSTEP] refine' not_disjoint_segment_convexHull_triple hz hu hv (hC.2.symm.mono (ht.segment_subset hut hvt) <| convexHull_min _ hC.1) [GOAL] case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C h : ∀ (c : E), c ∈ Cᶜ → ∃ a, a ∈ C ∧ Set.Nonempty (segment 𝕜 c a ∩ t) p : E hp : p ∈ C u : E hu : u ∈ segment 𝕜 x p hut : u ∈ t q : E hq : q ∈ C v : E hv : v ∈ segment 𝕜 y q hvt : v ∈ t ⊢ {p, q, z} ⊆ C [PROOFSTEP] simpa [insert_subset_iff, hp, hq, singleton_subset_iff.2 hzC] [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C ⊢ ∀ (c : E), c ∈ Cᶜ → ∃ a, a ∈ C ∧ Set.Nonempty (segment 𝕜 c a ∩ t) [PROOFSTEP] rintro c hc [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C c : E hc : c ∈ Cᶜ ⊢ ∃ a, a ∈ C ∧ Set.Nonempty (segment 𝕜 c a ∩ t) [PROOFSTEP] by_contra' h [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C c : E hc : c ∈ Cᶜ h : ∀ (a : E), a ∈ C → ¬Set.Nonempty (segment 𝕜 c a ∩ t) ⊢ False [PROOFSTEP] suffices h : Disjoint (convexHull 𝕜 (insert c C)) t [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C c : E hc : c ∈ Cᶜ h✝ : ∀ (a : E), a ∈ C → ¬Set.Nonempty (segment 𝕜 c a ∩ t) h : Disjoint (↑(convexHull 𝕜) (insert c C)) t ⊢ False [PROOFSTEP] rw [← hCmax _ ⟨convex_convexHull _ _, h⟩ ((subset_insert _ _).trans <| subset_convexHull _ _)] at hc [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C c : E hc : c ∈ (↑(convexHull 𝕜) (insert c C))ᶜ h✝ : ∀ (a : E), a ∈ C → ¬Set.Nonempty (segment 𝕜 c a ∩ t) h : Disjoint (↑(convexHull 𝕜) (insert c C)) t ⊢ False [PROOFSTEP] exact hc (subset_convexHull _ _ <| mem_insert _ _) [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C c : E hc : c ∈ Cᶜ h : ∀ (a : E), a ∈ C → ¬Set.Nonempty (segment 𝕜 c a ∩ t) ⊢ Disjoint (↑(convexHull 𝕜) (insert c C)) t [PROOFSTEP] rw [convexHull_insert ⟨z, hzC⟩, convexJoin_singleton_left] [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C c : E hc : c ∈ Cᶜ h : ∀ (a : E), a ∈ C → ¬Set.Nonempty (segment 𝕜 c a ∩ t) ⊢ Disjoint (⋃ (y : E) (_ : y ∈ ↑(convexHull 𝕜) C), segment 𝕜 c y) t [PROOFSTEP] refine' disjoint_iUnion₂_left.2 fun a ha => disjoint_iff_inf_le.mpr fun b hb => h a _ ⟨b, hb⟩ [GOAL] case h 𝕜 : Type u_1 E : Type u_2 ι : Type u_3 inst✝² : LinearOrderedField 𝕜 inst✝¹ : AddCommGroup E inst✝ : Module 𝕜 E s t : Set E hs : Convex 𝕜 s ht : Convex 𝕜 t hst : Disjoint s t S : Set (Set E) := {C | Convex 𝕜 C ∧ Disjoint C t} C : Set E hC : C ∈ S hsC : s ⊆ C hCmax : ∀ (a : Set E), a ∈ S → C ⊆ a → a = C x : E hx : x ∈ Cᶜ y : E hy : y ∈ Cᶜ z : E hz : z ∈ segment 𝕜 x y hzC : z ∈ C c : E hc : c ∈ Cᶜ h : ∀ (a : E), a ∈ C → ¬Set.Nonempty (segment 𝕜 c a ∩ t) a : E ha : a ∈ ↑(convexHull 𝕜) C b : E hb : b ∈ segment 𝕜 c a ⊓ t ⊢ a ∈ C [PROOFSTEP] rwa [← hC.1.convexHull_eq]
[STATEMENT] lemma roofed_greater: "\<And>B. S \<subseteq> roofed_gen G B S" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>B. S \<subseteq> roofed_gen G B S [PROOF STEP] by(auto simp add: roofed_def)
(**************************************************************) (* Copyright Dominique Larchey-Wendling [*] *) (* *) (* [*] Affiliation LORIA -- CNRS *) (**************************************************************) (* This file is distributed under the terms of the *) (* CeCILL v2 FREE SOFTWARE LICENSE AGREEMENT *) (**************************************************************) Require Import List Arith Bool Lia Eqdep_dec. From Undecidability.Shared.Libs.DLW.Utils Require Import utils_tac utils_list utils_nat finite. From Undecidability.Shared.Libs.DLW.Vec Require Import pos vec. From Undecidability.FOL.TRAKHTENBROT Require Import notations utils fol_ops fo_sig fo_terms fo_logic fo_sat. Import fol_notations. Set Implicit Arguments. (* * Uniformize the arity of relations *) Local Notation ø := vec_nil. Section vec_fill_tail. Variable (X : Type) (n : nat) (k : nat) (v : vec X k) (e : X). Definition vec_fill_tail : vec X n. Proof using v e. apply vec_set_pos; intros p. destruct (le_lt_dec k (pos2nat p)) as [ | H ]. + exact e. + exact (vec_pos v (nat2pos H)). Defined. Fact vec_fill_tail_lt p (Hp : pos2nat p < k) : vec_pos vec_fill_tail p = vec_pos v (nat2pos Hp). Proof. unfold vec_fill_tail; rew vec. destruct (le_lt_dec k (pos2nat p)). + exfalso; lia. + do 2 f_equal; apply lt_pirr. Qed. Fact vec_fill_tail_ge p : k <= pos2nat p -> vec_pos vec_fill_tail p = e. Proof. intros H; unfold vec_fill_tail; rew vec. destruct (le_lt_dec k (pos2nat p)); auto; exfalso; lia. Qed. End vec_fill_tail. Opaque vec_fill_tail. Fact vec_map_fill_tail X Y (f : X -> Y) n k v e : vec_map f (@vec_fill_tail X n k v e) = vec_fill_tail n (vec_map f v) (f e). Proof. apply vec_pos_ext; intros p; rew vec. destruct (le_lt_dec k (pos2nat p)) as [ | Hp ]. + do 2 (rewrite vec_fill_tail_ge; auto). + do 2 rewrite vec_fill_tail_lt with (Hp := Hp); rew vec. Qed. Section vec_first_half. Variable (X : Type) (n : nat) (k : nat) (Hk : k <= n). Definition vec_first_half (v : vec X n) : vec X k. Proof using Hk. apply vec_set_pos; intros p. refine (vec_pos v (@nat2pos _ (pos2nat p) _)). apply Nat.lt_le_trans with (2 := Hk), pos2nat_prop. Defined. Fact vec_first_half_fill_tail v e : vec_first_half (vec_fill_tail _ v e) = v. Proof. apply vec_pos_ext; intros p. unfold vec_first_half; rew vec. match goal with | |- vec_pos _ ?p = _ => assert (H : pos2nat p < k) end. { rewrite pos2nat_nat2pos; apply pos2nat_prop. } rewrite vec_fill_tail_lt with (Hp := H). revert H. rewrite pos2nat_nat2pos. intros; f_equal; apply nat2pos_pos2nat. Qed. End vec_first_half. Section Sig_uniformize_rels. Variable (Σ : fo_signature) (n : nat) (Hn : forall r, ar_rels Σ r <= n). Definition Σunif : fo_signature. Proof using Σ n. exists (syms Σ) (rels Σ). + exact (ar_syms Σ). + exact (fun _ => n). Defined. Notation Σ' := Σunif. Fixpoint fol_uniformize (A : fol_form Σ) : fol_form Σ' := match A with | ⊥ => ⊥ | @fol_atom _ r v => @fol_atom Σ' r (vec_fill_tail _ v (£0)) | fol_bin c A B => fol_bin c (fol_uniformize A) (fol_uniformize B) | fol_quant q A => fol_quant q (fol_uniformize A) end. Variable (X : Type) (e : X). Section soundness. Variables (M : fo_model Σ X). Local Definition fom_uniformize : fo_model Σ' X. Proof using M Hn. split. + intros s; apply (fom_syms M s). + intros r v; exact (fom_rels M r (vec_first_half (Hn r) v)). Defined. Notation M' := fom_uniformize. Theorem fol_uniformize_sound A φ : fol_sem M φ A <-> fol_sem M' φ (fol_uniformize A). Proof. revert φ; induction A as [ | r v | A HA B HB | q A HA ]; simpl; try tauto; intros phi. + apply fol_equiv_ext; f_equal. rewrite vec_map_fill_tail, vec_first_half_fill_tail; auto. + apply fol_bin_sem_ext; auto. + apply fol_quant_sem_ext; auto. Qed. End soundness. Variable (lr : list (rels Σ)). Section completeness. Variable (M' : fo_model Σ' X). Local Definition fom_specialize : fo_model Σ X. Proof using M' e. split. + intros s; apply (fom_syms M' s). + intros r v; exact (fom_rels M' r (vec_fill_tail n v e)). Defined. Notation M := fom_specialize. Section uniform_after. Variable (r : rels Σ). Let k := ar_rels _ r. Let w1 : vec (fol_term Σ') _ := vec_fill_tail n (vec_set_pos (fun p : pos k => £(2+pos2nat p))) (£ 1). Let w2 : vec (fol_term Σ') _ := vec_fill_tail n (vec_set_pos (fun p : pos k => £(2+pos2nat p))) (£ 0). Local Definition fol_uniform_after : fol_form Σ' := fol_mquant fol_fa k (∀∀ @fol_atom Σ' r w1 ↔ @fol_atom Σ' r w2). Local Fact fol_uniform_after_spec φ : fol_sem M' φ fol_uniform_after <-> forall v e1 e2, fom_rels M' r (@vec_fill_tail _ n k v e1) <-> fom_rels M' r (vec_fill_tail n v e2). Proof. unfold fol_uniform_after. rewrite fol_sem_mforall. apply forall_equiv; intros v. rewrite fol_sem_quant_fix. apply forall_equiv; intros e1. rewrite fol_sem_quant_fix. apply forall_equiv; intros e2. apply fol_equiv_sem_ext. + apply fol_equiv_ext; f_equal. unfold w1; rewrite vec_map_fill_tail; simpl; f_equal. apply vec_pos_ext; intros p; rew vec; simpl. rewrite env_vlift_fix0; auto. + apply fol_equiv_ext; f_equal. unfold w2; rewrite vec_map_fill_tail; simpl; f_equal. apply vec_pos_ext; intros p; rew vec; simpl. rewrite env_vlift_fix0; auto. Qed. End uniform_after. Local Definition fol_all_uniform_after : fol_form Σ' := fol_lconj (map fol_uniform_after lr). Let uniform := forall r, In r lr -> forall (v : vec _ (ar_rels _ r)) e1 e2, fom_rels M' r (vec_fill_tail n v e1) <-> fom_rels M' r (vec_fill_tail n v e2). Local Fact fol_all_uniform_after_spec φ : fol_sem M' φ fol_all_uniform_after <-> uniform. Proof. unfold fol_all_uniform_after. rewrite fol_sem_lconj; unfold uniform. split. + intros H r Hr. apply (fol_uniform_after_spec _ φ), H, in_map_iff. exists r; auto. + intros H f; rewrite in_map_iff. intros (r & <- & Hr); apply fol_uniform_after_spec, H; auto. Qed. Hypothesis Hlr : uniform. Theorem fol_uniformize_complete A φ : incl (fol_rels A) lr -> fol_sem M φ A <-> fol_sem M' φ (fol_uniformize A). Proof using Hlr. revert φ; induction A as [ | r v | b A HA B HB | q A HA ]; simpl; try tauto; intros phi Hr. + rewrite vec_map_fill_tail; rew fot. apply Hlr, Hr; simpl; auto. + apply fol_bin_sem_ext; auto. * apply HA; intros ? ?; apply Hr, in_app_iff; auto. * apply HB; intros ? ?; apply Hr, in_app_iff; auto. + apply fol_quant_sem_ext; auto. Qed. End completeness. Variable (A : fol_form Σ) (HA : incl (fol_rels A) lr). Definition Σuniformize := fol_all_uniform_after ⟑ fol_uniformize A. Theorem Σuniformize_sound : fo_form_fin_dec_SAT_in A X -> fo_form_fin_dec_SAT_in Σuniformize X. Proof using Hn. intros (M & H1 & H2 & phi & H). exists (fom_uniformize M), H1. exists. { intros ? ?; apply H2. } exists phi; split. + apply fol_all_uniform_after_spec. intros r _ v e1 e2; simpl. do 2 rewrite vec_first_half_fill_tail; tauto. + revert H; apply fol_uniformize_sound. Qed. Theorem Σuniformize_complete : fo_form_fin_dec_SAT_in Σuniformize X -> fo_form_fin_dec_SAT_in A X. Proof using e HA. intros (M' & H1 & H2 & phi & H3 & H4). rewrite fol_all_uniform_after_spec in H3. exists (fom_specialize M'), H1. exists. { intros ? ?; apply H2. } exists phi. revert H4. apply fol_uniformize_complete; auto. Qed. End Sig_uniformize_rels.
Yardley London Yardley London Morning Dew, Charming Princess Pack of 2 Deodorants Yardley London Deodorants For Women, A light scent with citrus top notes, combined with a heart of fresh, spring flowers. Starts an aromatic journey into the heart of gentle rosebuds and jasmine petals that caress your skin. Amber and sandalwood make their appearance in the base notes which anchor the floating rose down to your skin. Product #: Regular price: Rs.398INR340(Sale ends 01 January ) Available from: DeoBazaar.com Condition: New In stock! Order now!
If $S$ is a sequentially compact set and $f$ is a sequence of elements of $S$, then there exists a subsequence $f_{r(n)}$ of $f$ that converges to an element $l \in S$.
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Bool where open import Cubical.Data.Bool.Base public open import Cubical.Data.Bool.Properties public
#include <boost/mpl/aux_/erase_impl.hpp>
#ifndef MATMUL_CMAT_MUL_H #define MATMUL_CMAT_MUL_H #include <cblas.h> #include <pthread.h> #include "cmatrix.h" #define _AVX512 //#define _AVX2 //#define _NEON #if defined(_NEON) #include "arm_neon.h" #elif defined(_AVX512) || defined(_AVX2) #include <immintrin.h> #endif #define BLOCKSIZE 1 #define UNROLL 4 typedef enum { Naive, Blas, Order, Simd, OpenCv, Threads, OpenMp, Unroll, Block, // UnrollMp, } kMatMulMode; CMatrix *MatMul(ReadOnlyMat mat1, ReadOnlyMat mat2, kMatMulMode mode, int times); CMatrix *MatMulO3(ReadOnlyMat mat1, ReadOnlyMat mat2); void MatMulChangeOrd(ReadOnlyMat mat1, ReadOnlyMat mat2, int times); CMatrix *MatMulBlas(ReadOnlyMat mat1, ReadOnlyMat mat2); //CMatrix *MatMulStrassen(ReadOnlyMat mat1, ReadOnlyMat mat2, int edge); CMatrix *MatMulCV(ReadOnlyMat mat1, ReadOnlyMat mat2); CMatrix *MatMulMP(ReadOnlyMat mat1, ReadOnlyMat mat2); CMatrix *MatMulSimd(ReadOnlyMat mat1, ReadOnlyMat mat2); CMatrix *MatMulUnroll(ReadOnlyMat mat1, ReadOnlyMat mat2); CMatrix *MatMulBlock(ReadOnlyMat mat1, ReadOnlyMat mat2); CMatrix *MatMulThreads(ReadOnlyMat mat1, ReadOnlyMat mat2); //CMatrix *MatMulUnrollMp(ReadOnlyMat mat1, ReadOnlyMat mat2); #endif //MATMUL_CMAT_MUL_H
State Before: 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) ⊢ ContDiffOn 𝕜 n f s State After: 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s ⊢ ContDiffWithinAt 𝕜 n f s x Tactic: intro x xs State Before: 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s ⊢ ContDiffWithinAt 𝕜 n f s x State After: case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s u : Set E u_open : IsOpen u xu : x ∈ u hu : ContDiffOn 𝕜 n f (s ∩ u) ⊢ ContDiffWithinAt 𝕜 n f s x Tactic: rcases h x xs with ⟨u, u_open, xu, hu⟩ State Before: case intro.intro.intro 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s u : Set E u_open : IsOpen u xu : x ∈ u hu : ContDiffOn 𝕜 n f (s ∩ u) ⊢ ContDiffWithinAt 𝕜 n f s x State After: 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s u : Set E u_open : IsOpen u xu : x ∈ u hu : ContDiffOn 𝕜 n f (s ∩ u) ⊢ u ∈ 𝓝 x Tactic: apply (contDiffWithinAt_inter _).1 (hu x ⟨xs, xu⟩) State Before: 𝕜 : Type u inst✝⁸ : NontriviallyNormedField 𝕜 E : Type uE inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type uF inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type uG inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G X : Type uX inst✝¹ : NormedAddCommGroup X inst✝ : NormedSpace 𝕜 X s s₁ t u✝ : Set E f f₁ : E → F g : F → G x✝ x₀ : E c : F m n : ℕ∞ p : E → FormalMultilinearSeries 𝕜 E F h : ∀ (x : E), x ∈ s → ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u) x : E xs : x ∈ s u : Set E u_open : IsOpen u xu : x ∈ u hu : ContDiffOn 𝕜 n f (s ∩ u) ⊢ u ∈ 𝓝 x State After: no goals Tactic: exact IsOpen.mem_nhds u_open xu
module Two where open import Relation.Binary.PropositionalEquality open ≡-Reasoning import Data.Nat as ℕ import Data.Nat.Properties as ℕₚ open ℕ using (ℕ; zero; suc; _+_) -- Our language consists of constants and addition data Expr : Set where const : ℕ → Expr plus : Expr → Expr → Expr -- Straightforward semantics eval-expr : Expr → ℕ eval-expr (const n) = n eval-expr (plus e1 e2) = eval-expr e1 + eval-expr e2 -- Tail recursive semantics eval-expr-tail' : Expr → ℕ → ℕ eval-expr-tail' (const n) acc = n + acc eval-expr-tail' (plus e1 e2) acc = eval-expr-tail' e2 (eval-expr-tail' e1 acc) eval-expr-tail : Expr → ℕ eval-expr-tail e = eval-expr-tail' e 0 -- -- Task: prove that eval-expr-tail is equivalent to eval-expr. -- -- The tail recursive evaluation does not depend on its accumulator eval-expr-tail-correct-lemma : ∀ e acc → eval-expr-tail' e acc ≡ eval-expr-tail' e 0 + acc eval-expr-tail-correct-lemma e acc = ? -- The tail recursive evaluation agrees with the straightforward evaluation eval-expr-tail-correct : ∀ e → eval-expr-tail e ≡ eval-expr e eval-expr-tail-correct e = ?
Require Import Crypto.Language.PreExtra. Require Import Rewriter.Language.Language. Require Import Crypto.Language.IdentifierParameters. Require Import Rewriter.Language.IdentifiersBasicGenerate. Require Import Rewriter.Util.plugins.RewriterBuild. Module Compilers. Import IdentifiersBasicLibrary.Compilers.Basic. Import IdentifiersBasicGenerate.Compilers.Basic. Local Unset Decidable Equality Schemes. Local Unset Boolean Equality Schemes. Rewriter Emit Inductives From Scraped {| ScrapedData.base_type_list_named := base_type_list_named ; ScrapedData.all_ident_named_interped := all_ident_named_interped |} As base ident raw_ident pattern_ident. Definition package : GoalType.package_with_args scraped_data var_like_idents base ident. Proof. Tactic.make_package. Defined. Global Strategy -1000 [base_interp ident_interp]. End Compilers.
18 @-@ year @-@ old Rebbie 's announcement that she wanted to marry her childhood love , Nathaniel Brown , in May 1968 created a division in the Jackson family . Jackson expressed her feelings for the man and proclaimed that she wanted to move with him to Kentucky . Katherine encouraged her daughter to proceed with the union ; she felt that being a wife and mother were important roles for all of her daughters to play . Joseph , however , was against the marriage ; he wanted Rebbie to follow in the footsteps of her brothers ( The Jackson 5 ) and become a singer . Her father felt that married life would stop her from becoming a success in the entertainment business . Though Rebbie had taken clarinet , piano and dance lessons in her childhood , she had no interest in a music career . This was despite the fact that according to brother Jermaine she had won several singing contests , duetting with brother Jackie . The teenager thought a happy home was more comforting and secure than the instability of show business . She also wanted to leave her family 's drama @-@ filled home on Jackson Street as well as get away from her controlling father . Arguments ensued for several weeks before her father relented and allowed Rebbie to wed Brown . Having the last word on the matter , Joseph refused to walk his daughter down the aisle .
Formal statement is: lemma algebra_single_set: "X \<subseteq> S \<Longrightarrow> algebra S { {}, X, S - X, S }" Informal statement is: If $X$ is a subset of $S$, then the algebra generated by $X$ is the set of all subsets of $S$.
If $x$ is an algebraic integer, then $\overline{x}$ is an algebraic integer.
If $x$ is an algebraic integer, then $\overline{x}$ is an algebraic integer.
(* Author: Tobias Nipkow *) section \<open>Tree Rotations\<close> theory Tree_Rotations imports "HOL-Library.Tree" begin text \<open>How to transform a tree into a list and into any other tree (with the same @{const inorder}) by rotations.\<close> fun is_list :: "'a tree \<Rightarrow> bool" where "is_list (Node l _ r) = (l = Leaf \<and> is_list r)" | "is_list Leaf = True" text \<open>Termination proof via measure function. NB @{term "size t - rlen t"} works for the actual rotation equation but not for the second equation.\<close> fun rlen :: "'a tree \<Rightarrow> nat" where "rlen Leaf = 0" | "rlen (Node l x r) = rlen r + 1" lemma rlen_le_size: "rlen t \<le> size t" by(induction t) auto subsection \<open>Without positions\<close> function (sequential) list_of :: "'a tree \<Rightarrow> 'a tree" where "list_of (Node (Node A a B) b C) = list_of (Node A a (Node B b C))" | "list_of (Node Leaf a A) = Node Leaf a (list_of A)" | "list_of Leaf = Leaf" by pat_completeness auto termination proof let ?R = "measure(\<lambda>t. 2*size t - rlen t)" show "wf ?R" by (auto simp add: mlex_prod_def) fix A a B b C show "(Node A a (Node B b C), Node (Node A a B) b C) \<in> ?R" using rlen_le_size[of C] by(simp) fix a A show "(A, Node Leaf a A) \<in> ?R" using rlen_le_size[of A] by(simp) qed lemma is_list_rot: "is_list(list_of t)" by (induction t rule: list_of.induct) auto lemma inorder_rot: "inorder(list_of t) = inorder t" by (induction t rule: list_of.induct) auto subsection \<open>With positions\<close> datatype dir = L | R type_synonym "pos" = "dir list" function (sequential) rotR_poss :: "'a tree \<Rightarrow> pos list" where "rotR_poss (Node (Node A a B) b C) = [] # rotR_poss (Node A a (Node B b C))" | "rotR_poss (Node Leaf a A) = map (Cons R) (rotR_poss A)" | "rotR_poss Leaf = []" by pat_completeness auto termination proof let ?R = "measure(\<lambda>t. 2*size t - rlen t)" show "wf ?R" by (auto simp add: mlex_prod_def) fix A a B b C show "(Node A a (Node B b C), Node (Node A a B) b C) \<in> ?R" using rlen_le_size[of C] by(simp) fix a A show "(A, Node Leaf a A) \<in> ?R" using rlen_le_size[of A] by(simp) qed fun rotR :: "'a tree \<Rightarrow> 'a tree" where "rotR (Node (Node A a B) b C) = Node A a (Node B b C)" fun rotL :: "'a tree \<Rightarrow> 'a tree" where "rotL (Node A a (Node B b C)) = Node (Node A a B) b C" fun apply_at :: "('a tree \<Rightarrow> 'a tree) \<Rightarrow> pos \<Rightarrow> 'a tree \<Rightarrow> 'a tree" where "apply_at f [] t = f t" | "apply_at f (L # ds) (Node l a r) = Node (apply_at f ds l) a r" | "apply_at f (R # ds) (Node l a r) = Node l a (apply_at f ds r)" fun apply_ats :: "('a tree \<Rightarrow> 'a tree) \<Rightarrow> pos list \<Rightarrow> 'a tree \<Rightarrow> 'a tree" where "apply_ats _ [] t = t" | "apply_ats f (p#ps) t = apply_ats f ps (apply_at f p t)" lemma apply_ats_append: "apply_ats f (ps\<^sub>1 @ ps\<^sub>2) t = apply_ats f ps\<^sub>2 (apply_ats f ps\<^sub>1 t)" by (induction ps\<^sub>1 arbitrary: t) auto abbreviation "rotRs \<equiv> apply_ats rotR" abbreviation "rotLs \<equiv> apply_ats rotL" lemma apply_ats_map_R: "apply_ats f (map ((#) R) ps) \<langle>l, a, r\<rangle> = Node l a (apply_ats f ps r)" by(induction ps arbitrary: r) auto lemma inorder_rotRs_poss: "inorder (rotRs (rotR_poss t) t) = inorder t" apply(induction t rule: rotR_poss.induct) apply(auto simp: apply_ats_map_R) done lemma is_list_rotRs: "is_list (rotRs (rotR_poss t) t)" apply(induction t rule: rotR_poss.induct) apply(auto simp: apply_ats_map_R) done lemma "is_list (rotRs ps t) \<longrightarrow> length ps \<le> length(rotR_poss t)" quickcheck[expect=counterexample] oops lemma length_rotRs_poss: "length (rotR_poss t) = size t - rlen t" proof(induction t rule: rotR_poss.induct) case (1 A a B b C) then show ?case using rlen_le_size[of C] by simp qed auto lemma is_list_inorder_same: "is_list t1 \<Longrightarrow> is_list t2 \<Longrightarrow> inorder t1 = inorder t2 \<Longrightarrow> t1 = t2" proof(induction t1 arbitrary: t2) case Leaf then show ?case by simp next case Node then show ?case by (cases t2) simp_all qed lemma rot_id: "rotLs (rev (rotR_poss t)) (rotRs (rotR_poss t) t) = t" apply(induction t rule: rotR_poss.induct) apply(auto simp: apply_ats_map_R rev_map apply_ats_append) done corollary tree_to_tree_rotations: assumes "inorder t1 = inorder t2" shows "rotLs (rev (rotR_poss t2)) (rotRs (rotR_poss t1) t1) = t2" proof - have "rotRs (rotR_poss t1) t1 = rotRs (rotR_poss t2) t2" (is "?L = ?R") by (simp add: assms inorder_rotRs_poss is_list_inorder_same is_list_rotRs) hence "rotLs (rev (rotR_poss t2)) ?L = rotLs (rev (rotR_poss t2)) ?R" by simp also have "\<dots> = t2" by(rule rot_id) finally show ?thesis . qed lemma size_rlen_better_ub: "size t - rlen t \<le> size t - 1" by (cases t) auto end
module Text.Markup.Edda.LaTeX import public Text.Markup.Edda.Model import public Text.Markup.Edda.Walk import public Text.Markup.Edda.Query import public Text.Markup.Edda.Writer.LaTeX
#== import modules here ==# using PyCall bse = pyimport("basis_set_exchange") using HDF5 #== initialization ==# upper_to_lower = Dict( "A" => "a", "B" => "b", "C" => "c", "D" => "d", "E" => "e", "F" => "f", "G" => "g", "H" => "h", "I" => "i", "J" => "j", "K" => "k", "L" => "l", "M" => "m", "N" => "n", "O" => "o", "P" => "p", "Q" => "q", "R" => "r", "S" => "s", "T" => "t", "U" => "u", "V" => "v", "W" => "w", "X" => "x", "Y" => "y", "Z" => "z" ) #==============================# #== get atom/basis set pairs ==# #==============================# basis_list = Vector{String}([]) status_bsed = h5open("../records/bsed.h5","r") do bsed #== loop over atoms ==# for symbol in names(bsed) #== loop over basis sets in atom ==# for basis in names(bsed["$symbol"]) #== add basis set to pair list if unique ==# if !in(basis, basis_list) push!(basis_list, basis) end end end end for basis in basis_list bs_psi4 = bse.get_basis(basis,fmt="psi4", header=false) bs_psi4 = replace(bs_psi4, "D+" => "E+") bs_psi4 = replace(bs_psi4, "D-" => "E-") bs_name = basis bs_name = replace(bs_name, "*" => "s") bs_name = replace(bs_name, "+" => "p") bs_name = replace(bs_name, "(" => "_") bs_name = replace(bs_name, ")" => "_") bs_name = replace(bs_name, "," => "_") for letter in upper_to_lower bs_name = replace(bs_name, letter[1] => letter[2]) end println(bs_name) bs_file = open("$bs_name.gbs", "w") do file write(file, bs_psi4) end end
// Copyright (C) 2008-2018 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 (see accompanying // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html // Test constructor cannot use `.precondition(...)`. #include <boost/contract/constructor.hpp> #include <boost/contract/check.hpp> struct a { a() { boost::contract::check c = boost::contract::constructor(this) .precondition([] {}) // Error (must use constructor_precondition). ; } }; int main() { a aa; return 0; }
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************) (** * An light axiomatization of integers (used in MSetAVL). *) (** We define a signature for an integer datatype based on [Z]. The goal is to allow a switch after extraction to ocaml's [big_int] or even [int] when finiteness isn't a problem (typically : when mesuring the height of an AVL tree). *) Require Import BinInt. Delimit Scope Int_scope with I. Local Open Scope Int_scope. (** * A specification of integers *) Module Type Int. Parameter t : Set. Bind Scope Int_scope with t. Parameter i2z : t -> Z. Parameter _0 : t. Parameter _1 : t. Parameter _2 : t. Parameter _3 : t. Parameter add : t -> t -> t. Parameter opp : t -> t. Parameter sub : t -> t -> t. Parameter mul : t -> t -> t. Parameter max : t -> t -> t. Notation "0" := _0 : Int_scope. Notation "1" := _1 : Int_scope. Notation "2" := _2 : Int_scope. Notation "3" := _3 : Int_scope. Infix "+" := add : Int_scope. Infix "-" := sub : Int_scope. Infix "*" := mul : Int_scope. Notation "- x" := (opp x) : Int_scope. (** For logical relations, we can rely on their counterparts in Z, since they don't appear after extraction. Moreover, using tactics like omega is easier this way. *) Notation "x == y" := (i2z x = i2z y) (at level 70, y at next level, no associativity) : Int_scope. Notation "x <= y" := (i2z x <= i2z y)%Z : Int_scope. Notation "x < y" := (i2z x < i2z y)%Z : Int_scope. Notation "x >= y" := (i2z x >= i2z y)%Z : Int_scope. Notation "x > y" := (i2z x > i2z y)%Z : Int_scope. Notation "x <= y <= z" := (x <= y /\ y <= z) : Int_scope. Notation "x <= y < z" := (x <= y /\ y < z) : Int_scope. Notation "x < y < z" := (x < y /\ y < z) : Int_scope. Notation "x < y <= z" := (x < y /\ y <= z) : Int_scope. (** Informative comparisons. *) Axiom eqb : t -> t -> bool. Axiom ltb : t -> t -> bool. Axiom leb : t -> t -> bool. Infix "=?" := eqb. Infix "<?" := ltb. Infix "<=?" := leb. (** For compatibility, some decidability fonctions (informative). *) Axiom gt_le_dec : forall x y : t, {x > y} + {x <= y}. Axiom ge_lt_dec : forall x y : t, {x >= y} + {x < y}. Axiom eq_dec : forall x y : t, { x == y } + {~ x==y }. (** Specifications *) (** First, we ask [i2z] to be injective. Said otherwise, our ad-hoc equality [==] and the generic [=] are in fact equivalent. We define [==] nonetheless since the translation to [Z] for using automatic tactic is easier. *) Axiom i2z_eq : forall n p : t, n == p -> n = p. (** Then, we express the specifications of the above parameters using their Z counterparts. *) Axiom i2z_0 : i2z _0 = 0%Z. Axiom i2z_1 : i2z _1 = 1%Z. Axiom i2z_2 : i2z _2 = 2%Z. Axiom i2z_3 : i2z _3 = 3%Z. Axiom i2z_add : forall n p, i2z (n + p) = (i2z n + i2z p)%Z. Axiom i2z_opp : forall n, i2z (-n) = (-i2z n)%Z. Axiom i2z_sub : forall n p, i2z (n - p) = (i2z n - i2z p)%Z. Axiom i2z_mul : forall n p, i2z (n * p) = (i2z n * i2z p)%Z. Axiom i2z_max : forall n p, i2z (max n p) = Z.max (i2z n) (i2z p). Axiom i2z_eqb : forall n p, eqb n p = Z.eqb (i2z n) (i2z p). Axiom i2z_ltb : forall n p, ltb n p = Z.ltb (i2z n) (i2z p). Axiom i2z_leb : forall n p, leb n p = Z.leb (i2z n) (i2z p). End Int. (** * Facts and tactics using [Int] *) Module MoreInt (Import I:Int). Local Notation int := I.t. Lemma eqb_eq n p : (n =? p) = true <-> n == p. Proof. now rewrite i2z_eqb, Z.eqb_eq. Qed. Lemma eqb_neq n p : (n =? p) = false <-> ~(n == p). Proof. rewrite <- eqb_eq. destruct (n =? p); intuition. Qed. Lemma ltb_lt n p : (n <? p) = true <-> n < p. Proof. now rewrite i2z_ltb, Z.ltb_lt. Qed. Lemma ltb_nlt n p : (n <? p) = false <-> ~(n < p). Proof. rewrite <- ltb_lt. destruct (n <? p); intuition. Qed. Lemma leb_le n p : (n <=? p) = true <-> n <= p. Proof. now rewrite i2z_leb, Z.leb_le. Qed. Lemma leb_nle n p : (n <=? p) = false <-> ~(n <= p). Proof. rewrite <- leb_le. destruct (n <=? p); intuition. Qed. (** A magic (but costly) tactic that goes from [int] back to the [Z] friendly world ... *) Hint Rewrite -> i2z_0 i2z_1 i2z_2 i2z_3 i2z_add i2z_opp i2z_sub i2z_mul i2z_max i2z_eqb i2z_ltb i2z_leb : i2z. Ltac i2z := match goal with | H : ?a = ?b |- _ => generalize (f_equal i2z H); try autorewrite with i2z; clear H; intro H; i2z | |- ?a = ?b => apply (i2z_eq a b); try autorewrite with i2z; i2z | H : _ |- _ => progress autorewrite with i2z in H; i2z | _ => try autorewrite with i2z end. (** A reflexive version of the [i2z] tactic *) (** this [i2z_refl] is actually weaker than [i2z]. For instance, if a [i2z] is buried deep inside a subterm, [i2z_refl] may miss it. See also the limitation about [Set] or [Type] part below. Anyhow, [i2z_refl] is enough for applying [romega]. *) Ltac i2z_gen := match goal with | |- ?a = ?b => apply (i2z_eq a b); i2z_gen | H : ?a = ?b |- _ => generalize (f_equal i2z H); clear H; i2z_gen | H : eq (A:=Z) ?a ?b |- _ => revert H; i2z_gen | H : Z.lt ?a ?b |- _ => revert H; i2z_gen | H : Z.le ?a ?b |- _ => revert H; i2z_gen | H : Z.gt ?a ?b |- _ => revert H; i2z_gen | H : Z.ge ?a ?b |- _ => revert H; i2z_gen | H : _ -> ?X |- _ => (* A [Set] or [Type] part cannot be dealt with easily using the [ExprP] datatype. So we forget it, leaving a goal that can be weaker than the original. *) match type of X with | Type => clear H; i2z_gen | Prop => revert H; i2z_gen end | H : _ <-> _ |- _ => revert H; i2z_gen | H : _ /\ _ |- _ => revert H; i2z_gen | H : _ \/ _ |- _ => revert H; i2z_gen | H : ~ _ |- _ => revert H; i2z_gen | _ => idtac end. Inductive ExprI : Set := | EI0 : ExprI | EI1 : ExprI | EI2 : ExprI | EI3 : ExprI | EIadd : ExprI -> ExprI -> ExprI | EIopp : ExprI -> ExprI | EIsub : ExprI -> ExprI -> ExprI | EImul : ExprI -> ExprI -> ExprI | EImax : ExprI -> ExprI -> ExprI | EIraw : int -> ExprI. Inductive ExprZ : Set := | EZadd : ExprZ -> ExprZ -> ExprZ | EZopp : ExprZ -> ExprZ | EZsub : ExprZ -> ExprZ -> ExprZ | EZmul : ExprZ -> ExprZ -> ExprZ | EZmax : ExprZ -> ExprZ -> ExprZ | EZofI : ExprI -> ExprZ | EZraw : Z -> ExprZ. Inductive ExprP : Type := | EPeq : ExprZ -> ExprZ -> ExprP | EPlt : ExprZ -> ExprZ -> ExprP | EPle : ExprZ -> ExprZ -> ExprP | EPgt : ExprZ -> ExprZ -> ExprP | EPge : ExprZ -> ExprZ -> ExprP | EPimpl : ExprP -> ExprP -> ExprP | EPequiv : ExprP -> ExprP -> ExprP | EPand : ExprP -> ExprP -> ExprP | EPor : ExprP -> ExprP -> ExprP | EPneg : ExprP -> ExprP | EPraw : Prop -> ExprP. (** [int] to [ExprI] *) Ltac i2ei trm := match constr:(trm) with | 0 => constr:(EI0) | 1 => constr:(EI1) | 2 => constr:(EI2) | 3 => constr:(EI3) | ?x + ?y => let ex := i2ei x with ey := i2ei y in constr:(EIadd ex ey) | ?x - ?y => let ex := i2ei x with ey := i2ei y in constr:(EIsub ex ey) | ?x * ?y => let ex := i2ei x with ey := i2ei y in constr:(EImul ex ey) | max ?x ?y => let ex := i2ei x with ey := i2ei y in constr:(EImax ex ey) | - ?x => let ex := i2ei x in constr:(EIopp ex) | ?x => constr:(EIraw x) end (** [Z] to [ExprZ] *) with z2ez trm := match constr:(trm) with | (?x + ?y)%Z => let ex := z2ez x with ey := z2ez y in constr:(EZadd ex ey) | (?x - ?y)%Z => let ex := z2ez x with ey := z2ez y in constr:(EZsub ex ey) | (?x * ?y)%Z => let ex := z2ez x with ey := z2ez y in constr:(EZmul ex ey) | (Z.max ?x ?y) => let ex := z2ez x with ey := z2ez y in constr:(EZmax ex ey) | (- ?x)%Z => let ex := z2ez x in constr:(EZopp ex) | i2z ?x => let ex := i2ei x in constr:(EZofI ex) | ?x => constr:(EZraw x) end. (** [Prop] to [ExprP] *) Ltac p2ep trm := match constr:(trm) with | (?x <-> ?y) => let ex := p2ep x with ey := p2ep y in constr:(EPequiv ex ey) | (?x -> ?y) => let ex := p2ep x with ey := p2ep y in constr:(EPimpl ex ey) | (?x /\ ?y) => let ex := p2ep x with ey := p2ep y in constr:(EPand ex ey) | (?x \/ ?y) => let ex := p2ep x with ey := p2ep y in constr:(EPor ex ey) | (~ ?x) => let ex := p2ep x in constr:(EPneg ex) | (eq (A:=Z) ?x ?y) => let ex := z2ez x with ey := z2ez y in constr:(EPeq ex ey) | (?x < ?y)%Z => let ex := z2ez x with ey := z2ez y in constr:(EPlt ex ey) | (?x <= ?y)%Z => let ex := z2ez x with ey := z2ez y in constr:(EPle ex ey) | (?x > ?y)%Z => let ex := z2ez x with ey := z2ez y in constr:(EPgt ex ey) | (?x >= ?y)%Z => let ex := z2ez x with ey := z2ez y in constr:(EPge ex ey) | ?x => constr:(EPraw x) end. (** [ExprI] to [int] *) Fixpoint ei2i (e:ExprI) : int := match e with | EI0 => 0 | EI1 => 1 | EI2 => 2 | EI3 => 3 | EIadd e1 e2 => (ei2i e1)+(ei2i e2) | EIsub e1 e2 => (ei2i e1)-(ei2i e2) | EImul e1 e2 => (ei2i e1)*(ei2i e2) | EImax e1 e2 => max (ei2i e1) (ei2i e2) | EIopp e => -(ei2i e) | EIraw i => i end. (** [ExprZ] to [Z] *) Fixpoint ez2z (e:ExprZ) : Z := match e with | EZadd e1 e2 => ((ez2z e1)+(ez2z e2))%Z | EZsub e1 e2 => ((ez2z e1)-(ez2z e2))%Z | EZmul e1 e2 => ((ez2z e1)*(ez2z e2))%Z | EZmax e1 e2 => Z.max (ez2z e1) (ez2z e2) | EZopp e => (-(ez2z e))%Z | EZofI e => i2z (ei2i e) | EZraw z => z end. (** [ExprP] to [Prop] *) Fixpoint ep2p (e:ExprP) : Prop := match e with | EPeq e1 e2 => (ez2z e1) = (ez2z e2) | EPlt e1 e2 => ((ez2z e1)<(ez2z e2))%Z | EPle e1 e2 => ((ez2z e1)<=(ez2z e2))%Z | EPgt e1 e2 => ((ez2z e1)>(ez2z e2))%Z | EPge e1 e2 => ((ez2z e1)>=(ez2z e2))%Z | EPimpl e1 e2 => (ep2p e1) -> (ep2p e2) | EPequiv e1 e2 => (ep2p e1) <-> (ep2p e2) | EPand e1 e2 => (ep2p e1) /\ (ep2p e2) | EPor e1 e2 => (ep2p e1) \/ (ep2p e2) | EPneg e => ~ (ep2p e) | EPraw p => p end. (** [ExprI] (supposed under a [i2z]) to a simplified [ExprZ] *) Fixpoint norm_ei (e:ExprI) : ExprZ := match e with | EI0 => EZraw (0%Z) | EI1 => EZraw (1%Z) | EI2 => EZraw (2%Z) | EI3 => EZraw (3%Z) | EIadd e1 e2 => EZadd (norm_ei e1) (norm_ei e2) | EIsub e1 e2 => EZsub (norm_ei e1) (norm_ei e2) | EImul e1 e2 => EZmul (norm_ei e1) (norm_ei e2) | EImax e1 e2 => EZmax (norm_ei e1) (norm_ei e2) | EIopp e => EZopp (norm_ei e) | EIraw i => EZofI (EIraw i) end. (** [ExprZ] to a simplified [ExprZ] *) Fixpoint norm_ez (e:ExprZ) : ExprZ := match e with | EZadd e1 e2 => EZadd (norm_ez e1) (norm_ez e2) | EZsub e1 e2 => EZsub (norm_ez e1) (norm_ez e2) | EZmul e1 e2 => EZmul (norm_ez e1) (norm_ez e2) | EZmax e1 e2 => EZmax (norm_ez e1) (norm_ez e2) | EZopp e => EZopp (norm_ez e) | EZofI e => norm_ei e | EZraw z => EZraw z end. (** [ExprP] to a simplified [ExprP] *) Fixpoint norm_ep (e:ExprP) : ExprP := match e with | EPeq e1 e2 => EPeq (norm_ez e1) (norm_ez e2) | EPlt e1 e2 => EPlt (norm_ez e1) (norm_ez e2) | EPle e1 e2 => EPle (norm_ez e1) (norm_ez e2) | EPgt e1 e2 => EPgt (norm_ez e1) (norm_ez e2) | EPge e1 e2 => EPge (norm_ez e1) (norm_ez e2) | EPimpl e1 e2 => EPimpl (norm_ep e1) (norm_ep e2) | EPequiv e1 e2 => EPequiv (norm_ep e1) (norm_ep e2) | EPand e1 e2 => EPand (norm_ep e1) (norm_ep e2) | EPor e1 e2 => EPor (norm_ep e1) (norm_ep e2) | EPneg e => EPneg (norm_ep e) | EPraw p => EPraw p end. Lemma norm_ei_correct (e:ExprI) : ez2z (norm_ei e) = i2z (ei2i e). Proof. induction e; simpl; i2z; auto; try congruence. Qed. Lemma norm_ez_correct (e:ExprZ) : ez2z (norm_ez e) = ez2z e. Proof. induction e; simpl; i2z; auto; try congruence; apply norm_ei_correct. Qed. Lemma norm_ep_correct (e:ExprP) : ep2p (norm_ep e) <-> ep2p e. Proof. induction e; simpl; rewrite ?norm_ez_correct; intuition. Qed. Lemma norm_ep_correct2 (e:ExprP) : ep2p (norm_ep e) -> ep2p e. Proof. intros; destruct (norm_ep_correct e); auto. Qed. Ltac i2z_refl := i2z_gen; match goal with |- ?t => let e := p2ep t in change (ep2p e); apply norm_ep_correct2; simpl end. (* i2z_refl can be replaced below by (simpl in *; i2z). The reflexive version improves compilation of AVL files by about 15% *) End MoreInt. (** * An implementation of [Int] *) (** It's always nice to know that our [Int] interface is realizable :-) *) Module Z_as_Int <: Int. Local Open Scope Z_scope. Definition t := Z. Definition _0 := 0. Definition _1 := 1. Definition _2 := 2. Definition _3 := 3. Definition add := Z.add. Definition opp := Z.opp. Definition sub := Z.sub. Definition mul := Z.mul. Definition max := Z.max. Definition eqb := Z.eqb. Definition ltb := Z.ltb. Definition leb := Z.leb. Definition eq_dec := Z.eq_dec. Definition gt_le_dec i j : {i > j} + { i <= j }. Proof. generalize (Z.ltb_spec j i). destruct (j <? i); [left|right]; inversion H; trivial. now apply Z.lt_gt. Defined. Definition ge_lt_dec i j : {i >= j} + { i < j }. Proof. generalize (Z.ltb_spec i j). destruct (i <? j); [right|left]; inversion H; trivial. now apply Z.le_ge. Defined. Definition i2z : t -> Z := fun n => n. Lemma i2z_eq n p : i2z n = i2z p -> n = p. Proof. trivial. Qed. Lemma i2z_0 : i2z _0 = 0. Proof. reflexivity. Qed. Lemma i2z_1 : i2z _1 = 1. Proof. reflexivity. Qed. Lemma i2z_2 : i2z _2 = 2. Proof. reflexivity. Qed. Lemma i2z_3 : i2z _3 = 3. Proof. reflexivity. Qed. Lemma i2z_add n p : i2z (n + p) = i2z n + i2z p. Proof. reflexivity. Qed. Lemma i2z_opp n : i2z (- n) = - i2z n. Proof. reflexivity. Qed. Lemma i2z_sub n p : i2z (n - p) = i2z n - i2z p. Proof. reflexivity. Qed. Lemma i2z_mul n p : i2z (n * p) = i2z n * i2z p. Proof. reflexivity. Qed. Lemma i2z_max n p : i2z (max n p) = Z.max (i2z n) (i2z p). Proof. reflexivity. Qed. Lemma i2z_eqb n p : eqb n p = Z.eqb (i2z n) (i2z p). Proof. reflexivity. Qed. Lemma i2z_leb n p : leb n p = Z.leb (i2z n) (i2z p). Proof. reflexivity. Qed. Lemma i2z_ltb n p : ltb n p = Z.ltb (i2z n) (i2z p). Proof. reflexivity. Qed. (** Compatibility notations for Coq v8.4 *) Notation plus := add (only parsing). Notation minus := sub (only parsing). Notation mult := mul (only parsing). End Z_as_Int.
function gf=gfobs_L1L2(obsr,obsb,lam) pi=sdobs(obsr,obsb,1)*lam(1); pj=sdobs(obsr,obsb,2)*lam(2); if pi==0||pj==0 gf=0; else gf=pi-pj; end return
[GOAL] C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C W : (Cover J X)ᵒᵖ ⊢ (diagram J P X ⋙ F).obj W ≅ (diagram J (P ⋙ F) X).obj W [PROOFSTEP] refine' _ ≪≫ HasLimit.isoOfNatIso (W.unop.multicospanComp _ _).symm [GOAL] C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C W : (Cover J X)ᵒᵖ ⊢ (diagram J P X ⋙ F).obj W ≅ limit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F) [PROOFSTEP] refine' (isLimitOfPreserves F (limit.isLimit _)).conePointUniqueUpToIso (limit.isLimit _) [GOAL] C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C ⊢ ∀ {X_1 Y : (Cover J X)ᵒᵖ} (f : X_1 ⟶ Y), (diagram J P X ⋙ F).map f ≫ ((fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm) Y).hom = ((fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm) X_1).hom ≫ (diagram J (P ⋙ F) X).map f [PROOFSTEP] intro A B f [GOAL] C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C A B : (Cover J X)ᵒᵖ f : A ⟶ B ⊢ (diagram J P X ⋙ F).map f ≫ ((fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm) B).hom = ((fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm) A).hom ≫ (diagram J (P ⋙ F) X).map f [PROOFSTEP] apply Multiequalizer.hom_ext [GOAL] case h C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C A B : (Cover J X)ᵒᵖ f : A ⟶ B ⊢ ∀ (a : (Cover.index B.unop (P ⋙ F)).L), ((diagram J P X ⋙ F).map f ≫ ((fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm) B).hom) ≫ Multiequalizer.ι (Cover.index B.unop (P ⋙ F)) a = (((fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm) A).hom ≫ (diagram J (P ⋙ F) X).map f) ≫ Multiequalizer.ι (Cover.index B.unop (P ⋙ F)) a [PROOFSTEP] dsimp [GOAL] case h C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C A B : (Cover J X)ᵒᵖ f : A ⟶ B ⊢ ∀ (a : (Cover.index B.unop (P ⋙ F)).L), (F.map (Multiequalizer.lift (Cover.index B.unop P) (multiequalizer (Cover.index A.unop P)) (fun I => Multiequalizer.ι (Cover.index A.unop P) (Cover.Arrow.map I f.unop)) (_ : ∀ (I : (Cover.index B.unop P).R), Multiequalizer.ι (Cover.index A.unop P) (MulticospanIndex.fstTo (Cover.index A.unop P) (Cover.Relation.map I f.unop)) ≫ MulticospanIndex.fst (Cover.index A.unop P) (Cover.Relation.map I f.unop) = Multiequalizer.ι (Cover.index A.unop P) (MulticospanIndex.sndTo (Cover.index A.unop P) (Cover.Relation.map I f.unop)) ≫ MulticospanIndex.snd (Cover.index A.unop P) (Cover.Relation.map I f.unop))) ≫ (IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index B.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index B.unop P) ⋙ F))).hom ≫ (HasLimit.isoOfNatIso (Cover.multicospanComp F P B.unop).symm).hom) ≫ Multiequalizer.ι (Cover.index B.unop (P ⋙ F)) a = (((IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index A.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index A.unop P) ⋙ F))).hom ≫ (HasLimit.isoOfNatIso (Cover.multicospanComp F P A.unop).symm).hom) ≫ Multiequalizer.lift (Cover.index B.unop (P ⋙ F)) (multiequalizer (Cover.index A.unop (P ⋙ F))) (fun I => Multiequalizer.ι (Cover.index A.unop (P ⋙ F)) (Cover.Arrow.map I f.unop)) (_ : ∀ (I : (Cover.index B.unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index A.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index A.unop (P ⋙ F)) (Cover.Relation.map I f.unop)) ≫ MulticospanIndex.fst (Cover.index A.unop (P ⋙ F)) (Cover.Relation.map I f.unop) = Multiequalizer.ι (Cover.index A.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index A.unop (P ⋙ F)) (Cover.Relation.map I f.unop)) ≫ MulticospanIndex.snd (Cover.index A.unop (P ⋙ F)) (Cover.Relation.map I f.unop))) ≫ Multiequalizer.ι (Cover.index B.unop (P ⋙ F)) a [PROOFSTEP] simp only [Functor.mapCone_π_app, Multiequalizer.multifork_π_app_left, Iso.symm_hom, Multiequalizer.lift_ι, eqToHom_refl, Category.comp_id, limit.conePointUniqueUpToIso_hom_comp, GrothendieckTopology.Cover.multicospanComp_hom_inv_left, HasLimit.isoOfNatIso_hom_π, Category.assoc] [GOAL] case h C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C A B : (Cover J X)ᵒᵖ f : A ⟶ B ⊢ ∀ (a : (Cover.index B.unop (P ⋙ F)).L), F.map (Multiequalizer.lift (Cover.index B.unop P) (multiequalizer (Cover.index A.unop P)) (fun I => Multiequalizer.ι (Cover.index A.unop P) (Cover.Arrow.map I f.unop)) (_ : ∀ (I : (Cover.index B.unop P).R), Multiequalizer.ι (Cover.index A.unop P) (MulticospanIndex.fstTo (Cover.index A.unop P) (Cover.Relation.map I f.unop)) ≫ MulticospanIndex.fst (Cover.index A.unop P) (Cover.Relation.map I f.unop) = Multiequalizer.ι (Cover.index A.unop P) (MulticospanIndex.sndTo (Cover.index A.unop P) (Cover.Relation.map I f.unop)) ≫ MulticospanIndex.snd (Cover.index A.unop P) (Cover.Relation.map I f.unop))) ≫ F.map (Multiequalizer.ι (Cover.index B.unop P) a) = F.map (Multiequalizer.ι (Cover.index A.unop P) (Cover.Arrow.map a f.unop)) [PROOFSTEP] simp only [← F.map_comp, limit.lift_π, Multifork.ofι_π_app, implies_true] [GOAL] C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C W : (Cover J X)ᵒᵖ i : Cover.Arrow W.unop ⊢ NatTrans.app (diagramCompIso J F P X).hom W ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i = F.map (Multiequalizer.ι (Cover.index W.unop P) i) [PROOFSTEP] delta diagramCompIso [GOAL] C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C W : (Cover J X)ᵒᵖ i : Cover.Arrow W.unop ⊢ NatTrans.app (NatIso.ofComponents fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm).hom W ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i = F.map (Multiequalizer.ι (Cover.index W.unop P) i) [PROOFSTEP] dsimp [GOAL] C : Type u inst✝⁵ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁴ : Category.{max v u, w₁} D E : Type w₂ inst✝³ : Category.{max v u, w₂} E F : D ⥤ E inst✝² : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝¹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D X : C W : (Cover J X)ᵒᵖ i : Cover.Arrow W.unop ⊢ ((IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F))).hom ≫ (HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm).hom) ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i = F.map (Multiequalizer.ι (Cover.index W.unop P) i) [PROOFSTEP] simp [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X : Cᵒᵖ ⊢ (plusObj J P ⋙ F).obj X ≅ (plusObj J (P ⋙ F)).obj X [PROOFSTEP] refine' _ ≪≫ HasColimit.isoOfNatIso (J.diagramCompIso F P X.unop) [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X : Cᵒᵖ ⊢ (plusObj J P ⋙ F).obj X ≅ colimit (diagram J P X.unop ⋙ F) [PROOFSTEP] refine' (isColimitOfPreserves F (colimit.isColimit (J.diagram P (unop X)))).coconePointUniqueUpToIso (colimit.isColimit _) [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F ⊢ ∀ {X Y : Cᵒᵖ} (f : X ⟶ Y), (plusObj J P ⋙ F).map f ≫ ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) Y).hom = ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) X).hom ≫ (plusObj J (P ⋙ F)).map f [PROOFSTEP] intro X Y f [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y ⊢ (plusObj J P ⋙ F).map f ≫ ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) Y).hom = ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) X).hom ≫ (plusObj J (P ⋙ F)).map f [PROOFSTEP] apply (isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).hom_ext [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y ⊢ ∀ (j : (Cover J X.unop)ᵒᵖ), NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι j ≫ (plusObj J P ⋙ F).map f ≫ ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) Y).hom = NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι j ≫ ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) X).hom ≫ (plusObj J (P ⋙ F)).map f [PROOFSTEP] intro W [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι W ≫ (plusObj J P ⋙ F).map f ≫ ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) Y).hom = NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι W ≫ ((fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)) X).hom ≫ (plusObj J (P ⋙ F)).map f [PROOFSTEP] dsimp [plusObj, plusMap] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramPullback J P f.unop) ≫ colimit.pre (diagram J P Y.unop) (pullback J f.unop).op) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom = F.map (colimit.ι (diagram J P X.unop) W) ≫ ((IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F))).hom ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom) ≫ colimMap (diagramPullback J (P ⋙ F) f.unop) ≫ colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] simp only [Functor.map_comp, Category.assoc] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramPullback J P f.unop)) ≫ F.map (colimit.pre (diagram J P Y.unop) (pullback J f.unop).op) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom = F.map (colimit.ι (diagram J P X.unop) W) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F))).hom ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom ≫ colimMap (diagramPullback J (P ⋙ F) f.unop) ≫ colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] slice_rhs 1 2 => erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).fac] [GOAL] case a.a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F))).hom case a.a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | colimMap (diagramPullback J (P ⋙ F) f.unop) case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).fac] [GOAL] case a.a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F))).hom case a.a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | colimMap (diagramPullback J (P ⋙ F) f.unop) case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).fac] [GOAL] case a.a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F))).hom case a.a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | colimMap (diagramPullback J (P ⋙ F) f.unop) case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).fac] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramPullback J P f.unop)) ≫ F.map (colimit.pre (diagram J P Y.unop) (pullback J f.unop).op) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom = ((NatTrans.app (colimit.cocone (diagram J P X.unop ⋙ F)).ι W ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom) ≫ colimMap (diagramPullback J (P ⋙ F) f.unop)) ≫ colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] slice_lhs 1 3 => simp only [← F.map_comp] dsimp [colimMap, IsColimit.map, colimit.pre] simp only [colimit.ι_desc_assoc, colimit.ι_desc] dsimp [Cocones.precompose] simp only [Category.assoc, colimit.ι_desc] dsimp [Cocone.whisker] rw [F.map_comp] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramPullback J P f.unop)) ≫ F.map (colimit.pre (diagram J P Y.unop) (pullback J f.unop).op) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] simp only [← F.map_comp] dsimp [colimMap, IsColimit.map, colimit.pre] simp only [colimit.ι_desc_assoc, colimit.ι_desc] dsimp [Cocones.precompose] simp only [Category.assoc, colimit.ι_desc] dsimp [Cocone.whisker] rw [F.map_comp] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramPullback J P f.unop)) ≫ F.map (colimit.pre (diagram J P Y.unop) (pullback J f.unop).op) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] simp only [← F.map_comp] dsimp [colimMap, IsColimit.map, colimit.pre] simp only [colimit.ι_desc_assoc, colimit.ι_desc] dsimp [Cocones.precompose] simp only [Category.assoc, colimit.ι_desc] dsimp [Cocone.whisker] rw [F.map_comp] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramPullback J P f.unop)) ≫ F.map (colimit.pre (diagram J P Y.unop) (pullback J f.unop).op) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] simp only [← F.map_comp] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W ≫ colimMap (diagramPullback J P f.unop) ≫ colimit.pre (diagram J P Y.unop) (pullback J f.unop).op) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] dsimp [colimMap, IsColimit.map, colimit.pre] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P X.unop) W ≫ colimit.desc (diagram J P X.unop) ((Cocones.precompose (diagramPullback J P f.unop)).obj (colimit.cocone ((pullback J f.unop).op ⋙ diagram J P Y.unop))) ≫ colimit.desc ((pullback J f.unop).op ⋙ diagram J P Y.unop) (Cocone.whisker (pullback J f.unop).op (colimit.cocone (diagram J P Y.unop)))) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] simp only [colimit.ι_desc_assoc, colimit.ι_desc] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (NatTrans.app ((Cocones.precompose (diagramPullback J P f.unop)).obj (colimit.cocone ((pullback J f.unop).op ⋙ diagram J P Y.unop))).ι W ≫ colimit.desc ((pullback J f.unop).op ⋙ diagram J P Y.unop) (Cocone.whisker (pullback J f.unop).op (colimit.cocone (diagram J P Y.unop)))) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] dsimp [Cocones.precompose] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map ((Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I)) ≫ colimit.ι ((pullback J f.unop).op ⋙ diagram J P Y.unop) W) ≫ colimit.desc ((pullback J f.unop).op ⋙ diagram J P Y.unop) (Cocone.whisker (pullback J f.unop).op (colimit.cocone (diagram J P Y.unop)))) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] simp only [Category.assoc, colimit.ι_desc] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I)) ≫ NatTrans.app (Cocone.whisker (pullback J f.unop).op (colimit.cocone (diagram J P Y.unop))).ι W) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] dsimp [Cocone.whisker] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I)) ≫ colimit.ι (diagram J P Y.unop) (op (Cover.pullback W.unop f.unop))) case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom [PROOFSTEP] rw [F.map_comp] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ ((F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ F.map (colimit.ι (diagram J P Y.unop) (op (Cover.pullback W.unop f.unop)))) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom) ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom = ((NatTrans.app (colimit.cocone (diagram J P X.unop ⋙ F)).ι W ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom) ≫ colimMap (diagramPullback J (P ⋙ F) f.unop)) ≫ colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] simp only [Category.assoc] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ F.map (colimit.ι (diagram J P Y.unop) (op (Cover.pullback W.unop f.unop))) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom = NatTrans.app (colimit.cocone (diagram J P X.unop ⋙ F)).ι W ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom ≫ colimMap (diagramPullback J (P ⋙ F) f.unop) ≫ colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] slice_lhs 2 3 => erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P Y.unop))).fac] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P Y.unop) (op (Cover.pullback W.unop f.unop))) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) [PROOFSTEP] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P Y.unop))).fac] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P Y.unop) (op (Cover.pullback W.unop f.unop))) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) [PROOFSTEP] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P Y.unop))).fac] [GOAL] case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (colimit.ι (diagram J P Y.unop) (op (Cover.pullback W.unop f.unop))) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P Y.unop))) (colimit.isColimit (diagram J P Y.unop ⋙ F))).hom case a.a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom case a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ | F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) [PROOFSTEP] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P Y.unop))).fac] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (colimit.cocone (diagram J P Y.unop ⋙ F)).ι (op (Cover.pullback W.unop f.unop)) ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom = NatTrans.app (colimit.cocone (diagram J P X.unop ⋙ F)).ι W ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom ≫ colimMap (diagramPullback J (P ⋙ F) f.unop) ≫ colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] dsimp [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ colimit.ι (diagram J P Y.unop ⋙ F) (op (Cover.pullback W.unop f.unop)) ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P Y.unop)).hom = colimit.ι (diagram J P X.unop ⋙ F) W ≫ (HasColimit.isoOfNatIso (diagramCompIso J F P X.unop)).hom ≫ colimMap (diagramPullback J (P ⋙ F) f.unop) ≫ colimit.pre (diagram J (P ⋙ F) Y.unop) (pullback J f.unop).op [PROOFSTEP] simp only [HasColimit.isoOfNatIso_ι_hom_assoc, GrothendieckTopology.diagramPullback_app, colimit.ι_pre, HasColimit.isoOfNatIso_ι_hom, ι_colimMap_assoc] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (diagramCompIso J F P Y.unop).hom (op (Cover.pullback W.unop f.unop)) ≫ colimit.ι (diagram J (P ⋙ F) Y.unop) (op (Cover.pullback W.unop f.unop)) = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)) ((diagram J (P ⋙ F) X.unop).obj W) (fun I => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ colimit.ι (diagram J (P ⋙ F) Y.unop) ((pullback J f.unop).op.obj W) [PROOFSTEP] simp only [← Category.assoc] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ (F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (diagramCompIso J F P Y.unop).hom (op (Cover.pullback W.unop f.unop))) ≫ colimit.ι (diagram J (P ⋙ F) Y.unop) (op (Cover.pullback W.unop f.unop)) = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)) ((diagram J (P ⋙ F) X.unop).obj W) (fun I => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I))) ≫ colimit.ι (diagram J (P ⋙ F) Y.unop) ((pullback J f.unop).op.obj W) [PROOFSTEP] dsimp [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ (F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (diagramCompIso J F P Y.unop).hom (op (Cover.pullback W.unop f.unop))) ≫ colimit.ι (diagram J (P ⋙ F) Y.unop) (op (Cover.pullback W.unop f.unop)) = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun I => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I))) ≫ colimit.ι (diagram J (P ⋙ F) Y.unop) (op (Cover.pullback W.unop f.unop)) [PROOFSTEP] congr 1 [GOAL] case e_a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (diagramCompIso J F P Y.unop).hom (op (Cover.pullback W.unop f.unop)) = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun I => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) [PROOFSTEP] ext [GOAL] case e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ a✝ : (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)).L ⊢ (F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (diagramCompIso J F P Y.unop).hom (op (Cover.pullback W.unop f.unop))) ≫ Multiequalizer.ι (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) a✝ = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun I => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I))) ≫ Multiequalizer.ι (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) a✝ [PROOFSTEP] dsimp [GOAL] case e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ a✝ : (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)).L ⊢ (F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (diagramCompIso J F P Y.unop).hom (op (Cover.pullback W.unop f.unop))) ≫ Multiequalizer.ι (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) a✝ = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun I => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I))) ≫ Multiequalizer.ι (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) a✝ [PROOFSTEP] simp only [Category.assoc] [GOAL] case e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X Y : Cᵒᵖ f : X ⟶ Y W : (Cover J X.unop)ᵒᵖ a✝ : (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)).L ⊢ F.map (Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) P) (multiequalizer (Cover.index W.unop P)) (fun I => Multiequalizer.ι (Cover.index W.unop P) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop P).R), Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.fstTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop P) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop P) (MulticospanIndex.sndTo (Cover.index W.unop P) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop P) (Cover.Relation.base I))) ≫ NatTrans.app (diagramCompIso J F P Y.unop).hom (op (Cover.pullback W.unop f.unop)) ≫ Multiequalizer.ι (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) a✝ = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun I => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (Cover.Arrow.base I)) (_ : ∀ (I : (Cover.index ((pullback J f.unop).op.obj W).unop (P ⋙ F)).R), Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I) = Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ F)) (Cover.Relation.base I)) ≫ Multiequalizer.ι (Cover.index (Cover.pullback W.unop f.unop) (P ⋙ F)) a✝ [PROOFSTEP] erw [Multiequalizer.lift_ι, diagramCompIso_hom_ι, diagramCompIso_hom_ι, ← F.map_comp, Multiequalizer.lift_ι] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ NatTrans.app (plusCompIso J F P).hom X = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ colimit.ι (diagram J (P ⋙ F) X.unop) W [PROOFSTEP] delta diagramCompIso plusCompIso [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ NatTrans.app (NatIso.ofComponents fun X => IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F)) ≪≫ HasColimit.isoOfNatIso (NatIso.ofComponents fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm)).hom X = NatTrans.app (NatIso.ofComponents fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm).hom W ≫ colimit.ι (diagram J (P ⋙ F) X.unop) W [PROOFSTEP] simp only [IsColimit.descCoconeMorphism_Hom, IsColimit.uniqueUpToIso_hom, Cocones.forget_map, Iso.trans_hom, NatIso.ofComponents_hom_app, Functor.mapIso_hom, ← Category.assoc] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ (F.map (colimit.ι (diagram J P X.unop) W) ≫ (IsColimit.coconePointUniqueUpToIso (isColimitOfPreserves F (colimit.isColimit (diagram J P X.unop))) (colimit.isColimit (diagram J P X.unop ⋙ F))).hom) ≫ (HasColimit.isoOfNatIso (NatIso.ofComponents fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm)).hom = ((IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F))).hom ≫ (HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm).hom) ≫ colimit.ι (diagram J (P ⋙ F) X.unop) W [PROOFSTEP] erw [(isColimitOfPreserves F (colimit.isColimit (J.diagram P (unop X)))).fac] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ NatTrans.app (colimit.cocone (diagram J P X.unop ⋙ F)).ι W ≫ (HasColimit.isoOfNatIso (NatIso.ofComponents fun W => IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F)) ≪≫ HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm)).hom = ((IsLimit.conePointUniqueUpToIso (isLimitOfPreserves F (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P)))) (limit.isLimit (MulticospanIndex.multicospan (Cover.index W.unop P) ⋙ F))).hom ≫ (HasLimit.isoOfNatIso (Cover.multicospanComp F P W.unop).symm).hom) ≫ colimit.ι (diagram J (P ⋙ F) X.unop) W [PROOFSTEP] simp only [Category.assoc, HasLimit.isoOfNatIso_hom_π, Iso.symm_hom, Cover.multicospanComp_hom_inv_left, eqToHom_refl, Category.comp_id, limit.conePointUniqueUpToIso_hom_comp, Functor.mapCone_π_app, Multiequalizer.multifork_π_app_left, Multiequalizer.lift_ι, Functor.map_comp, eq_self_iff_true, Category.assoc, Iso.trans_hom, Iso.cancel_iso_hom_left, NatIso.ofComponents_hom_app, colimit.cocone_ι, Category.assoc, HasColimit.isoOfNatIso_ι_hom] [GOAL] C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G ⊢ whiskerLeft (plusObj J P) η ≫ (plusCompIso J G P).hom = (plusCompIso J F P).hom ≫ plusMap J (whiskerLeft P η) [PROOFSTEP] ext X [GOAL] case w.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ ⊢ NatTrans.app (whiskerLeft (plusObj J P) η ≫ (plusCompIso J G P).hom) X = NatTrans.app ((plusCompIso J F P).hom ≫ plusMap J (whiskerLeft P η)) X [PROOFSTEP] apply (isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).hom_ext [GOAL] case w.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ ⊢ ∀ (j : (Cover J X.unop)ᵒᵖ), NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι j ≫ NatTrans.app (whiskerLeft (plusObj J P) η ≫ (plusCompIso J G P).hom) X = NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι j ≫ NatTrans.app ((plusCompIso J F P).hom ≫ plusMap J (whiskerLeft P η)) X [PROOFSTEP] intro W [GOAL] case w.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι W ≫ NatTrans.app (whiskerLeft (plusObj J P) η ≫ (plusCompIso J G P).hom) X = NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι W ≫ NatTrans.app ((plusCompIso J F P).hom ≫ plusMap J (whiskerLeft P η)) X [PROOFSTEP] dsimp [plusObj, plusMap] [GOAL] case w.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ NatTrans.app η (colimit (diagram J P X.unop)) ≫ NatTrans.app (plusCompIso J G P).hom X = F.map (colimit.ι (diagram J P X.unop) W) ≫ NatTrans.app (plusCompIso J F P).hom X ≫ colimMap (diagramNatTrans J (whiskerLeft P η) X.unop) [PROOFSTEP] simp only [ι_plusCompIso_hom, ι_colimMap, whiskerLeft_app, ι_plusCompIso_hom_assoc, NatTrans.naturality_assoc, GrothendieckTopology.diagramNatTrans_app] [GOAL] case w.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ NatTrans.app η (multiequalizer (Cover.index W.unop P)) ≫ NatTrans.app (diagramCompIso J G P X.unop).hom W ≫ colimit.ι (diagram J (P ⋙ G) X.unop) W = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (P ⋙ G)) ((diagram J (P ⋙ F) X.unop).obj W) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (_ : ∀ (b : (Cover.index W.unop (P ⋙ G)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ G)) b = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ G)) b) ≫ colimit.ι (diagram J (P ⋙ G) X.unop) W [PROOFSTEP] simp only [← Category.assoc] [GOAL] case w.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ (NatTrans.app η (multiequalizer (Cover.index W.unop P)) ≫ NatTrans.app (diagramCompIso J G P X.unop).hom W) ≫ colimit.ι (diagram J (P ⋙ G) X.unop) W = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (P ⋙ G)) ((diagram J (P ⋙ F) X.unop).obj W) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (_ : ∀ (b : (Cover.index W.unop (P ⋙ G)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ G)) b = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ G)) b)) ≫ colimit.ι (diagram J (P ⋙ G) X.unop) W [PROOFSTEP] congr 1 -- porting note: this used to work with `ext` -- See https://github.com/leanprover-community/mathlib4/issues/5229 [GOAL] case w.h.e_a C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ NatTrans.app η (multiequalizer (Cover.index W.unop P)) ≫ NatTrans.app (diagramCompIso J G P X.unop).hom W = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (P ⋙ G)) ((diagram J (P ⋙ F) X.unop).obj W) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (_ : ∀ (b : (Cover.index W.unop (P ⋙ G)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ G)) b = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ G)) b) [PROOFSTEP] apply Multiequalizer.hom_ext [GOAL] case w.h.e_a.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ ∀ (a : (Cover.index W.unop (P ⋙ G)).L), (NatTrans.app η (multiequalizer (Cover.index W.unop P)) ≫ NatTrans.app (diagramCompIso J G P X.unop).hom W) ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ G)) a = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (P ⋙ G)) ((diagram J (P ⋙ F) X.unop).obj W) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (_ : ∀ (b : (Cover.index W.unop (P ⋙ G)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ G)) b = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ G)) b)) ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ G)) a [PROOFSTEP] intro a [GOAL] case w.h.e_a.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ a : (Cover.index W.unop (P ⋙ G)).L ⊢ (NatTrans.app η (multiequalizer (Cover.index W.unop P)) ≫ NatTrans.app (diagramCompIso J G P X.unop).hom W) ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ G)) a = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (P ⋙ G)) ((diagram J (P ⋙ F) X.unop).obj W) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (_ : ∀ (b : (Cover.index W.unop (P ⋙ G)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ G)) b = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ G)) b) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ G)) b)) ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ G)) a [PROOFSTEP] dsimp [GOAL] case w.h.e_a.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ a : (Cover.index W.unop (P ⋙ G)).L ⊢ (NatTrans.app η (multiequalizer (Cover.index W.unop P)) ≫ NatTrans.app (diagramCompIso J G P X.unop).hom W) ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ G)) a = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (P ⋙ G)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app η (P.obj (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (P ⋙ G)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerLeft P η) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (P ⋙ G)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (P ⋙ G)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerLeft P η) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (P ⋙ G)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (P ⋙ G)) i)) ≫ Multiequalizer.ι (Cover.index W.unop (P ⋙ G)) a [PROOFSTEP] simp -- Porting note: in mathlib3 `simp` managed to apply this. [GOAL] case w.h.e_a.h C : Type u inst✝¹² : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝¹¹ : Category.{max v u, w₁} D E : Type w₂ inst✝¹⁰ : Category.{max v u, w₂} E F✝ : D ⥤ E inst✝⁹ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁸ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝⁷ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F✝ P✝ : Cᵒᵖ ⥤ D inst✝⁶ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝⁵ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝⁴ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F✝ F G : D ⥤ E η : F ⟶ G P : Cᵒᵖ ⥤ D inst✝³ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F inst✝² : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F inst✝¹ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ G inst✝ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) G X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ a : (Cover.index W.unop (P ⋙ G)).L ⊢ NatTrans.app η (multiequalizer (Cover.index W.unop P)) ≫ G.map (Multiequalizer.ι (Cover.index W.unop P) a) = F.map (Multiequalizer.ι (Cover.index W.unop P) a) ≫ NatTrans.app η (P.obj (op a.Y)) [PROOFSTEP] erw [η.naturality] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q ⊢ whiskerRight (plusMap J η) F ≫ (plusCompIso J F Q).hom = (plusCompIso J F P).hom ≫ plusMap J (whiskerRight η F) [PROOFSTEP] ext X [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ ⊢ NatTrans.app (whiskerRight (plusMap J η) F ≫ (plusCompIso J F Q).hom) X = NatTrans.app ((plusCompIso J F P).hom ≫ plusMap J (whiskerRight η F)) X [PROOFSTEP] apply (isColimitOfPreserves F (colimit.isColimit (J.diagram P X.unop))).hom_ext [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ ⊢ ∀ (j : (Cover J X.unop)ᵒᵖ), NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι j ≫ NatTrans.app (whiskerRight (plusMap J η) F ≫ (plusCompIso J F Q).hom) X = NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι j ≫ NatTrans.app ((plusCompIso J F P).hom ≫ plusMap J (whiskerRight η F)) X [PROOFSTEP] intro W [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι W ≫ NatTrans.app (whiskerRight (plusMap J η) F ≫ (plusCompIso J F Q).hom) X = NatTrans.app (F.mapCocone (colimit.cocone (diagram J P X.unop))).ι W ≫ NatTrans.app ((plusCompIso J F P).hom ≫ plusMap J (whiskerRight η F)) X [PROOFSTEP] dsimp [plusObj, plusMap] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramNatTrans J η X.unop)) ≫ NatTrans.app (plusCompIso J F Q).hom X = F.map (colimit.ι (diagram J P X.unop) W) ≫ NatTrans.app (plusCompIso J F P).hom X ≫ colimMap (diagramNatTrans J (whiskerRight η F) X.unop) [PROOFSTEP] simp only [ι_colimMap, whiskerRight_app, ι_plusCompIso_hom_assoc, GrothendieckTopology.diagramNatTrans_app] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W) ≫ F.map (colimMap (diagramNatTrans J η X.unop)) ≫ NatTrans.app (plusCompIso J F Q).hom X = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) ((diagram J (P ⋙ F) X.unop).obj W) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (b : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) b) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) b = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) b) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) b) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W [PROOFSTEP] simp only [← Category.assoc, ← F.map_comp] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W ≫ colimMap (diagramNatTrans J η X.unop)) ≫ NatTrans.app (plusCompIso J F Q).hom X = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) ((diagram J (P ⋙ F) X.unop).obj W) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (b : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) b) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) b = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) b) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) b)) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W [PROOFSTEP] dsimp [colimMap, IsColimit.map] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (colimit.ι (diagram J P X.unop) W ≫ colimit.desc (diagram J P X.unop) ((Cocones.precompose (diagramNatTrans J η X.unop)).obj (colimit.cocone (diagram J Q X.unop)))) ≫ NatTrans.app (plusCompIso J F Q).hom X = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i)) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W [PROOFSTEP] simp only [colimit.ι_desc] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (NatTrans.app ((Cocones.precompose (diagramNatTrans J η X.unop)).obj (colimit.cocone (diagram J Q X.unop))).ι W) ≫ NatTrans.app (plusCompIso J F Q).hom X = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i)) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W [PROOFSTEP] dsimp [Cocones.precompose] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i) ≫ colimit.ι (diagram J Q X.unop) W) ≫ NatTrans.app (plusCompIso J F Q).hom X = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i)) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W [PROOFSTEP] simp only [Functor.map_comp, Category.assoc, ι_plusCompIso_hom] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i)) ≫ NatTrans.app (diagramCompIso J F Q X.unop).hom W ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W [PROOFSTEP] simp only [← Category.assoc] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ (F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i)) ≫ NatTrans.app (diagramCompIso J F Q X.unop).hom W) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i)) ≫ colimit.ι (diagram J (Q ⋙ F) X.unop) W [PROOFSTEP] congr 1 -- porting note: this used to work with `ext` -- See https://github.com/leanprover-community/mathlib4/issues/5229 [GOAL] case w.h.e_a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i)) ≫ NatTrans.app (diagramCompIso J F Q X.unop).hom W = NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i) [PROOFSTEP] apply Multiequalizer.hom_ext [GOAL] case w.h.e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ ⊢ ∀ (a : (Cover.index W.unop (Q ⋙ F)).L), (F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i)) ≫ NatTrans.app (diagramCompIso J F Q X.unop).hom W) ≫ Multiequalizer.ι (Cover.index W.unop (Q ⋙ F)) a = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i)) ≫ Multiequalizer.ι (Cover.index W.unop (Q ⋙ F)) a [PROOFSTEP] intro a [GOAL] case w.h.e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ a : (Cover.index W.unop (Q ⋙ F)).L ⊢ (F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i)) ≫ NatTrans.app (diagramCompIso J F Q X.unop).hom W) ≫ Multiequalizer.ι (Cover.index W.unop (Q ⋙ F)) a = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i)) ≫ Multiequalizer.ι (Cover.index W.unop (Q ⋙ F)) a [PROOFSTEP] dsimp [GOAL] case w.h.e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ a : (Cover.index W.unop (Q ⋙ F)).L ⊢ (F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i)) ≫ NatTrans.app (diagramCompIso J F Q X.unop).hom W) ≫ Multiequalizer.ι (Cover.index W.unop (Q ⋙ F)) a = (NatTrans.app (diagramCompIso J F P X.unop).hom W ≫ Multiequalizer.lift (Cover.index W.unop (Q ⋙ F)) (multiequalizer (Cover.index W.unop (P ⋙ F))) (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ F.map (NatTrans.app η (op i.Y))) (_ : ∀ (i : (Cover.index W.unop (Q ⋙ F)).R), (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.fst (Cover.index W.unop (Q ⋙ F)) i = (fun i => Multiequalizer.ι (Cover.index W.unop (P ⋙ F)) i ≫ NatTrans.app (whiskerRight η F) (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop (Q ⋙ F)) i) ≫ MulticospanIndex.snd (Cover.index W.unop (Q ⋙ F)) i)) ≫ Multiequalizer.ι (Cover.index W.unop (Q ⋙ F)) a [PROOFSTEP] simp only [diagramCompIso_hom_ι_assoc, Multiequalizer.lift_ι, diagramCompIso_hom_ι, Category.assoc] [GOAL] case w.h.e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P✝ : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F P Q : Cᵒᵖ ⥤ D η : P ⟶ Q X : Cᵒᵖ W : (Cover J X.unop)ᵒᵖ a : (Cover.index W.unop (Q ⋙ F)).L ⊢ F.map (Multiequalizer.lift (Cover.index W.unop Q) (multiequalizer (Cover.index W.unop P)) (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (_ : ∀ (i : (Cover.index W.unop Q).R), (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.fstTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.fst (Cover.index W.unop Q) i = (fun i => Multiequalizer.ι (Cover.index W.unop P) i ≫ NatTrans.app η (op i.Y)) (MulticospanIndex.sndTo (Cover.index W.unop Q) i) ≫ MulticospanIndex.snd (Cover.index W.unop Q) i)) ≫ F.map (Multiequalizer.ι (Cover.index W.unop Q) a) = F.map (Multiequalizer.ι (Cover.index W.unop P) a) ≫ F.map (NatTrans.app η (op a.Y)) [PROOFSTEP] simp only [← F.map_comp, Multiequalizer.lift_ι] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F ⊢ whiskerRight (toPlus J P) F ≫ (plusCompIso J F P).hom = toPlus J (P ⋙ F) [PROOFSTEP] ext [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ NatTrans.app (whiskerRight (toPlus J P) F ≫ (plusCompIso J F P).hom) x✝ = NatTrans.app (toPlus J (P ⋙ F)) x✝ [PROOFSTEP] dsimp [toPlus] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ F.map (Cover.toMultiequalizer ⊤ P ≫ colimit.ι (diagram J P x✝.unop) (op ⊤)) ≫ NatTrans.app (plusCompIso J F P).hom x✝ = Cover.toMultiequalizer ⊤ (P ⋙ F) ≫ colimit.ι (diagram J (P ⋙ F) x✝.unop) (op ⊤) [PROOFSTEP] simp only [ι_plusCompIso_hom, Functor.map_comp, Category.assoc] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ F.map (Cover.toMultiequalizer ⊤ P) ≫ NatTrans.app (diagramCompIso J F P x✝.unop).hom (op ⊤) ≫ colimit.ι (diagram J (P ⋙ F) x✝.unop) (op ⊤) = Cover.toMultiequalizer ⊤ (P ⋙ F) ≫ colimit.ι (diagram J (P ⋙ F) x✝.unop) (op ⊤) [PROOFSTEP] simp only [← Category.assoc] [GOAL] case w.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ (F.map (Cover.toMultiequalizer ⊤ P) ≫ NatTrans.app (diagramCompIso J F P x✝.unop).hom (op ⊤)) ≫ colimit.ι (diagram J (P ⋙ F) x✝.unop) (op ⊤) = Cover.toMultiequalizer ⊤ (P ⋙ F) ≫ colimit.ι (diagram J (P ⋙ F) x✝.unop) (op ⊤) [PROOFSTEP] congr 1 -- porting note: this used to work with `ext` -- See https://github.com/leanprover-community/mathlib4/issues/5229 [GOAL] case w.h.e_a C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ F.map (Cover.toMultiequalizer ⊤ P) ≫ NatTrans.app (diagramCompIso J F P x✝.unop).hom (op ⊤) = Cover.toMultiequalizer ⊤ (P ⋙ F) [PROOFSTEP] apply Multiequalizer.hom_ext [GOAL] case w.h.e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ ∀ (a : (Cover.index (op ⊤).unop (P ⋙ F)).L), (F.map (Cover.toMultiequalizer ⊤ P) ≫ NatTrans.app (diagramCompIso J F P x✝.unop).hom (op ⊤)) ≫ Multiequalizer.ι (Cover.index (op ⊤).unop (P ⋙ F)) a = Cover.toMultiequalizer ⊤ (P ⋙ F) ≫ Multiequalizer.ι (Cover.index (op ⊤).unop (P ⋙ F)) a [PROOFSTEP] delta Cover.toMultiequalizer [GOAL] case w.h.e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ ∀ (a : (Cover.index (op ⊤).unop (P ⋙ F)).L), (F.map (Multiequalizer.lift (Cover.index ⊤ P) (P.obj (op x✝.unop)) (fun I => P.map I.f.op) (_ : ∀ (I : (Cover.index ⊤ P).R), (fun I => P.map I.f.op) (MulticospanIndex.fstTo (Cover.index ⊤ P) I) ≫ MulticospanIndex.fst (Cover.index ⊤ P) I = (fun I => P.map I.f.op) (MulticospanIndex.sndTo (Cover.index ⊤ P) I) ≫ MulticospanIndex.snd (Cover.index ⊤ P) I)) ≫ NatTrans.app (diagramCompIso J F P x✝.unop).hom (op ⊤)) ≫ Multiequalizer.ι (Cover.index (op ⊤).unop (P ⋙ F)) a = Multiequalizer.lift (Cover.index ⊤ (P ⋙ F)) ((P ⋙ F).obj (op x✝.unop)) (fun I => (P ⋙ F).map I.f.op) (_ : ∀ (I : (Cover.index ⊤ (P ⋙ F)).R), (fun I => (P ⋙ F).map I.f.op) (MulticospanIndex.fstTo (Cover.index ⊤ (P ⋙ F)) I) ≫ MulticospanIndex.fst (Cover.index ⊤ (P ⋙ F)) I = (fun I => (P ⋙ F).map I.f.op) (MulticospanIndex.sndTo (Cover.index ⊤ (P ⋙ F)) I) ≫ MulticospanIndex.snd (Cover.index ⊤ (P ⋙ F)) I) ≫ Multiequalizer.ι (Cover.index (op ⊤).unop (P ⋙ F)) a [PROOFSTEP] simp only [diagramCompIso_hom_ι, Category.assoc, ← F.map_comp] [GOAL] case w.h.e_a.h C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F x✝ : Cᵒᵖ ⊢ ∀ (a : (Cover.index (op ⊤).unop (P ⋙ F)).L), F.map (Multiequalizer.lift (Cover.index ⊤ P) (P.obj (op x✝.unop)) (fun I => P.map I.f.op) (_ : ∀ (I : (Cover.index ⊤ P).R), (fun I => P.map I.f.op) (MulticospanIndex.fstTo (Cover.index ⊤ P) I) ≫ MulticospanIndex.fst (Cover.index ⊤ P) I = (fun I => P.map I.f.op) (MulticospanIndex.sndTo (Cover.index ⊤ P) I) ≫ MulticospanIndex.snd (Cover.index ⊤ P) I) ≫ Multiequalizer.ι (Cover.index (op ⊤).unop P) a) = Multiequalizer.lift (Cover.index ⊤ (P ⋙ F)) ((P ⋙ F).obj (op x✝.unop)) (fun I => (P ⋙ F).map I.f.op) (_ : ∀ (I : (Cover.index ⊤ (P ⋙ F)).R), (fun I => (P ⋙ F).map I.f.op) (MulticospanIndex.fstTo (Cover.index ⊤ (P ⋙ F)) I) ≫ MulticospanIndex.fst (Cover.index ⊤ (P ⋙ F)) I = (fun I => (P ⋙ F).map I.f.op) (MulticospanIndex.sndTo (Cover.index ⊤ (P ⋙ F)) I) ≫ MulticospanIndex.snd (Cover.index ⊤ (P ⋙ F)) I) ≫ Multiequalizer.ι (Cover.index (op ⊤).unop (P ⋙ F)) a [PROOFSTEP] simp only [unop_op, limit.lift_π, Multifork.ofι_π_app, Functor.comp_obj, Functor.comp_map, implies_true] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F ⊢ toPlus J (P ⋙ F) ≫ (plusCompIso J F P).inv = whiskerRight (toPlus J P) F [PROOFSTEP] simp [Iso.comp_inv_eq] [GOAL] C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F hP : Presheaf.IsSheaf J (plusObj J P ⋙ F) ⊢ (plusCompIso J F P).inv = plusLift J (whiskerRight (toPlus J P) F) hP [PROOFSTEP] apply J.plusLift_unique [GOAL] case hγ C : Type u inst✝⁸ : Category.{v, u} C J : GrothendieckTopology C D : Type w₁ inst✝⁷ : Category.{max v u, w₁} D E : Type w₂ inst✝⁶ : Category.{max v u, w₂} E F : D ⥤ E inst✝⁵ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D inst✝⁴ : ∀ (α β : Type (max v u)) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E inst✝³ : (X : C) → (W : Cover J X) → (P : Cᵒᵖ ⥤ D) → PreservesLimit (MulticospanIndex.multicospan (Cover.index W P)) F P : Cᵒᵖ ⥤ D inst✝² : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ D inst✝¹ : ∀ (X : C), HasColimitsOfShape (Cover J X)ᵒᵖ E inst✝ : (X : C) → PreservesColimitsOfShape (Cover J X)ᵒᵖ F hP : Presheaf.IsSheaf J (plusObj J P ⋙ F) ⊢ toPlus J (P ⋙ F) ≫ (plusCompIso J F P).inv = whiskerRight (toPlus J P) F [PROOFSTEP] simp [Iso.comp_inv_eq]
# Lecture 13 ## Standard Normal, Normal normalizing constant ## Proof of the Universality of $Unif(0,1)$ Let $F$ be a _continuous_, _strictly increasing_ CDF. Then \begin{align} &X = F^{-1}(U) \sim F & &\text{if } U \sim Unif(0,1) & &\text{(1)}\\ \\ &F(X) \sim Unif(0,1) & &\text{if } X \sim F & &\text{(2)} \end{align} $F$ is just a function, and hence we can treat it like an operator. Also, like $X$, $F(X)$ is just another r.v. ### Interpreting the Universality of $Unif(0,1)$ _How to interpret this universality?_ \begin{align} &F(x) = P(X \le x) & &\text{does not imply that } \\ \\ \require{cancel} &\bcancel{F(X) = P(X \le X) = 1} \\ \\ \\ &F(x) = 1 - e^{-x} & &\text{where } x \gt 0 \\ &F(X) = 1 - e^{-X} \end{align} _First_ evaluate $F$ at $x$, and _then_ replace $x$ for $X$. ### Simulating random variable draws using the universality of $Unif(0,1)$ These 2 approaches to universality of the Uniform are quite useful, like when you want to simulate draws from another r.v. Let $F(x) = 1 - e^{-x}$, where $x \gt 0$. This is the exponential random distribution $Expo(1)$. Say we have $U \sim Unif(0,1)$. _How can we leverage universality of $Unif(0,1)$ to simulate $X \sim F$?_ \begin{align} u &= 1 - e^{-x} & &\text{first we obtain }F^{-1}(x) \\ e^{-x} &= 1 - u \\ -x &= ln(1 - u) \\ x &= - ln(1-u) \\ \\ \Rightarrow F^{-1}(u) &= -ln(1-u) \\ \Rightarrow F^{-1}(U) &= -ln(1-U) \sim F & &\text{by universality} \end{align} And so we could simulate 10 i.i.d. draws from $F(x) = 1 - e^{-x}$ by calculating $-ln(1-U)$ 10 times. ### Symmetry of $Unif(0,1)$ Note that \begin{align} 1 - U \sim Unif(0,1) & &\text{symmetry of Uniform} \\ \\ a + b U & &\text{linear transformations are also } Unif \end{align} Non-linear transformations will, in general, __not__ be $Unif$. ---- ## Independence of Random Variables ### General case Say we have r.v. $X_1, X_2, \dots , X_n$. > __Definition__ $X_1, X_2, \dots , X_n$ are independent if, for all $x_1, x_2, \dots, x_n$ > > \\begin{align} > P(X_1 \le x_1, X_2 \le x_2, \dots , X_n \le x_n) &= P(X_1 \le x_1) P(X_2 \le x_2) \cdots P(X_n \le x_n) > \\end{align} Note that in this general case, $P(X_1 \le x_1, X_2 \le x_2, \dots , X_n \le x_n)$ is called the __joint CDF__. ### Discrete case > __Definition__ Discrete r.v. $X_1, X_2, \dots , X_n$ are independent if, for all $x_1, x_2, \dots, x_n$ > > \\begin{align} > P(X_1 = x_1, X_2 = x_2, \dots , X_n = x_n) &= P(X_1 = x_1) P(X_2 = x_2) \cdots P(X_n = x_n) > \\end{align} In the discrete case, $P(X_1 = x_1, X_2 = x_2, \dots , X_n = x_n)$ is called the __joint PMF__. ### Interpretation Simply put, in both the general and discrete cases, knowing any subset of the r.v. gives us __no__ information about the rest. This is _stronger_ than pair-wise independence. #### Ex. A penny-matching game Consider a penny-matching game where 2 players flip a penny. If the faces showing match (HH or TT), then one of the players wins; else the other player wins. Let \begin{align} X_1, X_2 &\sim \mathbb{Bern}\left(\frac{1}{2}\right) ~~ \text{, i.i.d} \\ \\ X_3 &= \begin{cases} 1 & \quad \text{if } X_1 = X_2 \\ 0 & \quad \text{otherwise}\\ \end{cases} \end{align} $X_1, X_2, X_3$ are _pair-wise independent_, but not independent. - Knowing $X_1, X_2$ gives us complete knowledge of $X_3$. - However, just knowing $X_1$ tells us nothing about $X_2$, nor can it say anything about $X_3$. ____ ## Normal Distribution (Gaussian) ### Description The most important distribution in all statistics, mostly due to the Central Limit Theorem. The Central Limit Theorem is surprising; if you sum up a large number of i.i.d. random variables will always look like a bell-shaped curve. This is irrespective of continuous or discrete; beautiful or ugly. ```python import matplotlib import numpy as np import matplotlib.pyplot as plt %matplotlib inline plt.xkcd() x = np.linspace(-5, 5, 500) y = np.e ** ((-x**2)/2) _, ax = plt.subplots() ax.plot(x, y) ax.grid(True, which='both') ax.axhline(y=0, color='k') ax.axvline(x=0, color='k') plt.show() ``` ### Notation $X \sim \mathcal{N}(\mu, Var)$ ### Parameters - $\mu$ mean - $Var$ variance ### Probability density function For the Standard Normal $\mathcal{N}(0,1)$ \begin{align} f(z) &= c e^{-\frac{z^{2}}{2}} \end{align} where $c$ is the normalizing constant that will let $f(x)$ integrate to 1. _But what is $c$?_ If we can figure out what the integral of the PDF is, then the _inverse_ of that will be the constant $c$ that ensures $f(z) = c e^{-\frac{z^{2}}{2}} = 1$. Consider the indefinite integral of the PDF of $\mathcal{N}$. \begin{align} \int_{-\infty}^{\infty} e^{-\frac{z^2}{2}} ~~ dz \end{align} There is a theorem that states that this integral, as an indefinite integral, cannot be solved in closed form. But this can be solved... First, we start by _multiplying the integral by itself_... \begin{align} \int_{-\infty}^{\infty} e^{-\frac{z^2}{2}} ~~ dz \int_{-\infty}^{\infty} e^{-\frac{z^2}{2}} ~~ dz &= \int_{-\infty}^{\infty} e^{-\frac{x^2}{2}} ~~ dx \int_{-\infty}^{\infty} e^{-\frac{y^2}{2}} ~~ dy \\ &= \iint_{-\infty}^{\infty} e^{-\frac{(x+y)^2}{2}} ~~ dxdy \\ &= \int_{0}^{2\pi} \int_{0}^{\infty} e^{-\frac{r^2}{2}}~ \underbrace{r}_{\text{jacobian}} ~ drd\theta & \quad \text{switch to polar} \\ &= \int_{0}^{2\pi} \left( \int_{0}^{\infty} e^{-u} du \right) ~ d\theta & \quad \text{let } u = \frac{r^2}{2} \text{ , } du = r \\ &= \int_{0}^{2\pi} \left( -e^{-\infty} + e^{-0} \right) ~ d\theta \\ &= \int_{0}^{2\pi} 1 ~ d\theta \\ &= 2 \pi - 0 \\ &= 2\pi \\ \\ \int_{-\infty}^{\infty} e^{-\frac{z^2}{2}} ~~ dz &= \sqrt{2\pi} \\ \\ \therefore c &= \boxed{\frac{1}{\sqrt{2\pi}} } \end{align} ### Expected value For the standard normal distribution, $\mathbb{E}(Z) = 0$. Let's prove that... \begin{align} \mathbb{E}(Z) &= \int_{-\infty}^{\infty} z ~ \frac{e^{-\frac{z^2}{2}}}{\sqrt{2\pi}} ~ dz \\ &= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} z ~ e^{-\frac{z^2}{2}} ~ dz \\ &= \frac{1}{\sqrt{2\pi}} (0) & \quad \text{since this is an odd function} \\ &= 0 & \quad \blacksquare \end{align} ```python x = np.linspace(-5, 5, 500) y = x * (np.e ** ((-x**2)/2)) _, ax = plt.subplots() ax.plot(x, y, color='black') ax.fill_between(x, y, where=y >= 0, facecolor='blue', interpolate=True) ax.fill_between(x, y, where=y < 0, facecolor='red', interpolate=True) ax.axhline(y=0, color='black') ax.axvline(x=0, color='black') plt.title("$g(x)$ is an odd function") plt.show() ``` Recall that if $g(x)$ is an _odd function_, then $g(x) + g(-x) = 0$. Integrating an odd function $g(x)$ from $-a$ to $a$ is 0, since the portion _above the x-axis_ cancels out the portion _below the x-axis_. ### Variance For the standard normal distribution, $\mathbb{Var}(Z) = 1$. Let's prove this as well... \begin{align} \mathbb{Var}(Z) &= \mathbb{E}Z^2 - \mathbb{E}(Z)^2 \\ &= \int_{-\infty}^{\infty} z^2 ~ \frac{e^{-\frac{z^2}{2}}}{\sqrt{2\pi}} ~ dz - (0)^2 & \quad \text{by LOTUS; and by calculations above} \\= &= 2 \int_{0}^{\infty} z^2 ~ \frac{e^{-\frac{z^2}{2}}}{\sqrt{2\pi}} ~ dz & \quad \text{this is an even function} \\ &= \frac{2}{\sqrt{2\pi}} \int_{0}^{\infty} z^2 ~ e^{-\frac{z^2}{2}} ~ dz & \quad \text{set us up for integration by parts} \\ &= \frac{2}{\sqrt{2\pi}} \int_{0}^{\infty} z ~ z ~ e^{-\frac{z^2}{2}} ~ dz \\ &= \frac{2}{\sqrt{2\pi}} \int_{0}^{\infty} u ~ du ~ dv & \quad \text{let } u = z \text{, } \quad dv = z ~ e^{-\frac{z^2}{2}} \\ & & \quad du = dz \text{, } \quad v = -e^{-\frac{z^2}{2}} \\ &= \frac{2}{\sqrt{2\pi}} \left( \left.(uv)\right\vert_{0}^{\infty} - \int_{0}^{\infty} v du \right) \\ &= \frac{2}{\sqrt{2\pi}} \left( 0 + \int_{0}^{\infty} e^{-\frac{z^2}{2}} ~ dz \right) \\ &= \frac{2}{\sqrt{2\pi}} \left( \frac{\sqrt{2\pi}}{2} \right) & \quad \text{from calculation of normalization constant }c \\ &= 1 & \quad \blacksquare \end{align} ```python x = np.linspace(-5, 5, 500) y = (x**2) * (np.e ** ((-x**2)/2)) _, ax = plt.subplots() ax.plot(x, y, color='black') ax.fill_between(x, y, where=y >= 0, facecolor='blue', interpolate=True) ax.axhline(y=0, color='black') ax.axvline(x=0, color='black') plt.title("$g(x)$ is an even function") plt.show() ``` ## Standard Normal Distribution This standard normal distribution $\mathcal{N}(0,1)$ is so important that it has its own name and notation. $\mathcal{Z} \sim \mathcal{N}(0,1)$, where mean $\mu = 0$ and variance $\sigma^2 = 1$ ### Notation The standard normal distribution's CDF is notated by $\mathbb{\Phi}(Z)$. ### Cumulative distribution function The cumulative distribution function of $\Phi(Z)$ is \begin{align} \mathbb{\Phi}(Z) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{z} e^{-\frac{t^2}{2}} ~~ dt \end{align} ### Property of $\Phi(-Z)$ \begin{align} \mathbb{\Phi}(-Z) = 1 - \mathbb{\Phi}(Z) \end{align} ----
Formal statement is: proposition component_diff_connected: fixes S :: "'a::metric_space set" assumes "connected S" "connected U" "S \<subseteq> U" and C: "C \<in> components (U - S)" shows "connected(U - C)" Informal statement is: If $S$ and $U$ are connected sets with $S \subseteq U$, and $C$ is a component of $U - S$, then $U - C$ is connected.
data Vect : Nat -> Type -> Type where Nil : Vect Z a (::) : (x : a) -> (xs : Vect k a) -> Vect (S k) a %name Vect xs, ys, zs data EqNat : (num1 : Nat) -> (num2 : Nat) -> Type where Same : (num : Nat) -> EqNat num num sameS : (eq : EqNat j k) -> EqNat (S j) (S k) sameS (Same j) = Same (S j) checkEqNat : (num1 : Nat) -> (num2 : Nat) -> Maybe (num1 = num2) checkEqNat Z Z = Just Refl checkEqNat Z (S k) = Nothing checkEqNat (S k) Z = Nothing checkEqNat (S j) (S k) = do eq <- checkEqNat j k pure (cong eq) exactLength : (len : Nat) -> (input : Vect m a) -> Maybe (Vect len a) exactLength {m} len input = case checkEqNat m len of Nothing => Nothing Just Refl => Just input same_cons : (xs : List a) -> (ys : List a) -> (xs = ys) -> (x :: xs = x :: ys) same_cons xs xs Refl = Refl same_lists : {xs : List a} -> {ys : List a} -> (x = y) -> (xs = ys) -> x :: xs = y :: ys same_lists Refl Refl = Refl data ThreeEq : (a : ty) -> (b : ty) -> (c : ty) -> Type where Same3 : (a : ty) -> ThreeEq a a a allSameS : ThreeEq x y z -> ThreeEq (S x) (S y) (S z) allSameS (Same3 j) = Same3 (S j) exactLength' : (len : Nat) -> (input : Vect m a) -> Maybe (Vect len a) exactLength' {m} len input = case decEq len m of (Yes Refl) => Just input (No contra) => Nothing head_unequal : DecEq a => (xs : Vect n a) -> (ys : Vect n a) -> (contra : (x = y) -> Void) -> ((x :: xs) = (y :: ys)) -> Void head_unequal xs xs contra Refl = contra Refl tail_unequal : DecEq a => (xs : Vect n a) -> (ys : Vect n a) -> (contra : (xs = ys) -> Void) -> ((x :: xs) = (y :: ys)) -> Void tail_unequal xs xs contra Refl = contra Refl DecEq a => DecEq (Vect n a) where decEq [] [] = Yes Refl decEq (x :: xs) (y :: ys) = case decEq x y of (No contra) => No (head_unequal xs ys contra) (Yes Refl) => case decEq xs ys of (No contra) => No (tail_unequal xs ys contra) (Yes Refl) => Yes Refl
#' Get laddersplit count report from FPC #' #' Downloads the daily ladder split report for mainstem Columbia and Snake River dams. #' @param sdate Start date for ladder counts #' @param edate End date for ladder counts #' @param rpt Report to download, either `"salmon"` (anadromous salmonids) or `"lamprey"` (all other species) #' @importFrom dplyr filter #' @return #' @export #' #' @examples #' \dontrun{ #' get_laddersplit(sdate="1-1-2019", edate="12-31-2019", rpt="salmon") #' } # fpc_laddersplit <- function(sdate, edate, rpt=c("salmon", "lamprey")){ rpt <- match.arg(rpt) url <- "https://www.fpc.org/adults/R_adultcoequeries_laddersplitreport_results_get" # Suppress date parsing warning. Report comes with blank and total rows with NA dates suppressWarnings(readr::read_csv(glue::glue("{url}{rpt}.php?sdate={sdate}&edate={edate}"), col_types=readr::cols(CountDate=readr::col_date(format="%m/%d/%Y")))) %>% dplyr::filter(!is.na(CountDate)) }
Require Import Arith. Require Import Iterates F_alpha E0. Require Import ArithRing Lia Max. Import Exp2. Require Import Compat815. Open Scope nat_scope. Lemma LF3 : dominates_from 2 (F_ 3) (fun n => iterate exp2 n n). Proof. generalize (LF3_2); intros H n Hn; eapply Nat.le_lt_trans. - apply iterate_le_n_Sn; intro x; generalize (exp2_gt_id x); lia. - now apply H. Qed. (** * Proof that F_alpha (S n) > exp2 (F_ alpha n) for alpha >= 3 and n >= 2 (by induction over alpha) *) Section S1. Let P alpha := forall n, 2 <= n -> exp2 (F_ alpha n) <= F_ alpha (S n). Remark F_3_eqn : forall n, F_ 3 n = iterate (F_ 2) (S n) n. Proof. intro n; ochange (E0fin 3) (E0succ (E0fin 2)); now rewrite F_succ_eqn. Qed. (** ** Base case *) Lemma P_3 : P 3. Proof. intros n H; rewrite (F_3_eqn (S n)); rewrite iterate_S_eqn. rewrite F_3_eqn. transitivity (exp2 (iterate (F_ 2) (S n) (S n))). - apply PeanoNat.Nat.lt_le_incl; apply exp2_mono. apply iterate_mono; auto. + apply F_alpha_mono. + intro n0; apply (F_alpha_gt (E0fin 2) n0). - specialize (LF2_0 (iterate (F_ 2) (S n) (S n))); intro H0. remember (iterate (F_ 2) (S n) (S n)) as N. transitivity ((fun i : nat => (exp2 i * i)%nat) N). + assert (0 < N). { rewrite HeqN; cbn; apply F_alpha_positive. } rewrite PeanoNat.Nat.mul_comm. (** deprecated, not replaced yet *) destruct (Compat815.mult_O_le (exp2 N) N). auto. * lia. * apply H2. + apply PeanoNat.Nat.lt_le_incl, LF2. Qed. (** Successor case *) Section Successor. Variable alpha: E0. Hypothesis H_alpha : P alpha. Remark R1: forall n, 2 <= n -> forall p, n < p -> exp2 (F_ alpha n) <= F_ alpha p. Proof. induction 2. - apply H_alpha; auto. - transitivity (F_ alpha m);auto. + apply mono_weak. * apply F_alpha_mono. * auto with arith. Qed. Section S2. Variable n : nat. Hypothesis Hn : 2 <= n. Remark R3 : F_ (E0succ alpha) (S n)= F_ alpha (iterate (F_ alpha) (S n) (S n)). Proof. rewrite F_succ_eqn; now rewrite iterate_S_eqn. Qed. Remark R3' : F_ (E0succ alpha) n = iterate (F_ alpha) (S n) n. Proof. now rewrite F_succ_eqn. Qed. Remark R4 : F_ (E0succ alpha) n < iterate (F_ alpha) (S n) (S n). Proof. rewrite F_succ_eqn; apply iterate_mono; auto with arith. - apply F_alpha_mono. - intro; apply F_alpha_gt. Qed. Lemma L2 : exp2 (F_ (E0succ alpha) n) <= (F_ (E0succ alpha) (S n)). Proof. assert (H: 2 <= (F_ (E0succ alpha) n)). { apply Nat.le_lt_trans with n. - lia. - apply F_alpha_gt. } assert (H0: F_ (E0succ alpha) n < iterate (F_ alpha) (S n) (S n)). { rewrite F_succ_eqn; apply iterate_mono; auto. - apply F_alpha_mono. - intro; apply F_alpha_gt. } generalize(R1 (F_ (E0succ alpha) n) H (iterate (F_ alpha) (S n) (S n)) H0); intro H1; rewrite <- R3 in H1. transitivity ( exp2 (F_ alpha (F_ (E0succ alpha) n))); [| auto]. - apply PeanoNat.Nat.lt_le_incl; apply exp2_mono. apply F_alpha_gt. Qed. End S2. Lemma L3 : P (E0succ alpha). Proof. unfold P; intros; now apply L2. Qed. End Successor. (** ** Limit case *) Section Limit. Variable lambda : E0. Hypothesis Hlambda : E0limit lambda. Hypothesis IHlambda : forall alpha, E0fin 3 o<= alpha -> alpha o< lambda -> P alpha. Remark R5: forall beta, 3 o<= beta -> beta o< lambda -> forall n, 2 <= n -> forall p, n < p -> exp2 (F_ beta n) <= F_ beta p. Proof. induction 4. - apply IHlambda; auto. - transitivity (F_ beta m);auto. + apply mono_weak. * apply F_alpha_mono. * auto with arith. Qed. Section S3. Variable n: nat. Hypothesis Hn : 2 <= n. (* TODO: simplify this proof ! *) Lemma L04 : forall beta:T1, T1limit beta -> forall n, leq lt (\F (S n)) (Canon.canon beta (S n)). Proof. destruct beta. - discriminate. - cbn. destruct beta1. + discriminate. + destruct beta2. * destruct n0. -- cbn. destruct beta1_1; cbn. ++ destruct n1. ** reflexivity. ** intros; apply lt_incl_le. apply head_lt; auto with T1. ++ destruct (pred beta1_2). ** intros; apply lt_incl_le; apply head_lt; auto with T1. ** intros; apply lt_incl_le; apply head_lt. { destruct n1;cbn. destruct beta1_2; cbn. - destruct beta1_1_1; cbn. + destruct n0; cbn; auto with T1. + destruct (pred beta1_1_2); cbn; auto with T1. - destruct n0; cbn; auto with T1. - destruct beta1_2; auto with T1. + destruct beta1_1_1. * destruct n0; cbn; auto with T1. * destruct (pred beta1_1_2); cbn; auto with T1. } -- intros;apply lt_incl_le. destruct (pred (cons beta1_1 n1 beta1_2)). ++ apply head_lt; auto with T1. ++ apply head_lt; auto with T1. * intros; apply lt_incl_le. destruct n0. -- apply head_lt; auto with T1. -- apply head_lt; auto with T1. Qed. Lemma L04' : forall beta, E0limit beta -> forall n, (S n) o<= (Canon.Canon beta (S n)). Proof. destruct beta; unfold E0limit. cbn; intros; rewrite Le_iff; split. - apply (@E0.cnf_ok (E0finS n0)). - cbn; split. + apply L04; auto. + cbn; apply Canon.nf_canon; auto. Qed. Lemma L4 : exp2 (F_ lambda n) <= F_ lambda (S n). Proof. repeat rewrite (F_lim_eqn lambda); auto. transitivity (exp2 (F_ (Canon.Canon lambda (S n)) n)). - apply PeanoNat.Nat.lt_le_incl; apply exp2_mono. apply F_mono_l_0 with 0. + apply Paths.Canon_mono1; auto. + apply Paths.Cor12_E0 with (i := 0); auto. * apply Paths.Canon_mono1; auto. * destruct n. -- lia. -- apply (@Paths.KS_thm_2_4_E0 _ Hlambda n0 (S n0)). auto with arith. + auto with arith. - apply R5; auto. + generalize (L04' lambda Hlambda); intro H; specialize (H n). eapply E0.Le_trans with (S n). * rewrite Le_iff. split. -- now compute. -- split. ++ cbn; destruct (Compat815.le_lt_or_eq _ _ Hn). ** apply lt_incl_le; now apply finite_lt. ** subst n; apply Comparable.le_refl. ++ cbn; apply nf_FS. * assumption. + apply Canon.Canon_lt. apply Limit_not_Zero; auto. Qed. End S3. End Limit. Lemma L alpha : 3 o<= alpha -> P alpha. Proof. pattern alpha; eapply well_founded_induction with E0lt. - apply E0lt_wf. - clear alpha; intro alpha. intros IHalpha Halpha. destruct (Zero_Limit_Succ_dec alpha) as [[H1 | H1] | H1]. + subst; rewrite Le_iff in Halpha. decompose [and] Halpha. cbn in Halpha. destruct Halpha as [H1 [H2 H3]]. rewrite le_lt_eq in H2; destruct H2; try discriminate. + red; intros; eapply L4; auto. + destruct H1; subst alpha. assert (H: 3 o<= x \/ x = E0fin 2). { destruct (le_lt_eq_dec Halpha). - left; destruct (E0_Lt_Succ_inv e). + apply Lt_Le_incl; auto. + subst; apply Le_refl. - right; revert e; ochange (E0fin 3) (E0succ 2). intro; symmetry ; now apply Succ_inj. } destruct H. * apply L3; apply IHalpha; auto. -- apply Lt_Succ; auto. * subst x; ochange (E0succ 2) (E0fin 3); apply P_3. Qed. End S1. Theorem F_alpha_Sn alpha : 3 o<= alpha -> forall n, 2 <= n -> exp2 (F_ alpha n) <= F_ alpha (S n). Proof. apply L. Qed. (** What happens if alpha is less than 3, or n less than 2 ? *) Goal F_ 2 3 = 63. ochange (E0fin 2) (E0succ (E0fin 1)). rewrite F_succ_eqn. cbn. repeat rewrite LF1. reflexivity. Qed. Goal F_ 2 2 = 23. ochange (E0fin 2) (E0succ (E0fin 1)). rewrite F_succ_eqn. cbn. repeat rewrite LF1. reflexivity. Qed. Goal F_ 3 1 = 2047. ochange (E0fin 3) (E0succ (E0succ (E0fin 1))). repeat rewrite F_succ_eqn. cbn. repeat rewrite F_succ_eqn. cbn. repeat rewrite LF1. rewrite iterate_S_eqn. cbn. repeat rewrite LF1. compute. reflexivity. Qed.
Elfland is a neat little EGA platform game, seemingly inspired by games like Captain Comic and Commander Keen; it looks and plays sort of like an early Apogee game. You choose your character (either boy Elfie or girl Elfita) and the gameplay involves jumping around levels and trying to figure out where to go next. It's cute and enjoyable, as long as you turn the extremely annoying PC speaker sound effects off. (On the main menu.) Don't be fooled by the cuteness though, this game can be old-school difficult. Elfland. Added to website: 2018-02-17. All copyrights, trademarks, etc, are property of their respective holders.
The limit of a function $f$ plus a constant $c$ is the constant $c$ plus the limit of $f$.
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Object.IndexedProduct {o ℓ e} (C : Category o ℓ e) where -- An indexed product is similar to a limit, but the diagram is from a Set -- (irrelevant Setoid here) rather than a category, so there are no subobjects -- involved. open Category C open Equiv open import Level open import Relation.Binary as Bi using () open import Categories.Support.Equivalence import Categories.Object.Indexed as IObj import Categories.Morphism.Indexed as IArrow -- Borrowed from Dan Doel's definition of products record IndexedProduct {c q} (B : Setoid c q) (As : IObj.Dust C B) : Set (o ⊔ ℓ ⊔ e ⊔ c ⊔ q) where module B = Setoid B open B using (_≈_) open Heterogeneous C open IObj C B open IArrow C B Cone : Obj → _ Cone apex = apex ⇒∗ As cone-setoid : Obj → Setoid _ _ cone-setoid apex = fan-setoid apex As _≜_ : ∀ {apex} → Bi.Rel (Cone apex) _ _≜_ {apex} = Setoid._≈_ (cone-setoid apex) field ∏ : Obj π : Cone ∏ -- convenience! π[_] : (x : B.Carrier) → (∏ ⇒ (As ! x)) π[_] x = π ‼ x -- ↑ XXX for some reason it won't parse as π[ x ] .π-cong : ∀ {x y} → x ≈ y → (π[ x ] ∼ π[ y ]) π-cong x≈y = cong₁ π x≈y π▹_ : ∀ {X} (f : X ⇒ ∏) → Cone X π▹_ f = _▹_ {Zs = As} π f field uncurry : ∀ {V} → Cone V → V ⇒ ∏ -- XXX fs should be implicit but call sites can't infer it -- because of eta-driven irrelevant-field dropping .commute∗ : ∀ {V} (fs : Cone V) → (π▹ uncurry fs) ≜ fs .universal : ∀ {V} (fs : Cone V) {i : V ⇒ ∏} → (∀ {x} → π[ x ] ∘ i ≡ fs ‼ x) → uncurry fs ≡ i -- convenience? .commute : ∀ {V} (fs : Cone V) {x} → (π[ x ] ∘ uncurry fs) ≡ fs ‼ x commute fs {x} = ∼⇒≡ (commute∗ fs B.refl) .universal∗ : ∀ {V} (fs : Cone V) {i : V ⇒ ∏} → ((π▹ i) ≜ fs) → uncurry fs ≡ i universal∗ fs pf = universal fs (∼⇒≡ (pf B.refl)) .g-η : ∀ {C} {f : C ⇒ ∏} → (uncurry (π▹ f) ≡ f) g-η {f = f} = universal (π▹ f) Equiv.refl .η : uncurry π ≡ Category.id C η = universal π identityʳ .uncurry-cong : ∀ {V} {fs gs : Cone V} → (∀ {x} → fs ‼ x ≡ gs ‼ x) → uncurry fs ≡ uncurry gs uncurry-cong {fs = fs} {gs} eq = universal fs (Equiv.trans (commute gs) (Equiv.sym eq)) .uncurry-cong∗ : ∀ {V} {fs gs : Cone V} → fs ≜ gs → uncurry fs ≡ uncurry gs uncurry-cong∗ {V} {fs} {gs} eq = universal∗ fs (≜-trans {π▹ uncurry gs} {gs} {fs} (commute∗ gs) (≜-sym {fs} {gs} eq)) where open Setoid (cone-setoid V) using () renaming (trans to ≜-trans; sym to ≜-sym) .uncurry∘ : ∀ {V W} (fs : Cone V) {q : W ⇒ V} → (uncurry fs) ∘ q ≡ uncurry (_▹_ {Zs = As} fs q) uncurry∘ fs {q} = Equiv.sym (universal (_▹_ {Zs = As} fs q) (Equiv.trans (Equiv.sym assoc) (∘-resp-≡ˡ (commute fs)))) {- open import Categories.Morphisms Commutative : ∀ {A B} → (p₁ : Product A B) (p₂ : Product B A) → _≅_ C (Product.A×B p₁) (Product.A×B p₂) Commutative p₁ p₂ = record { f = ⟨ π₂ , π₁ ⟩′ ; g = ⟨ π′₂ , π′₁ ⟩ ; iso = record { isoˡ = isoˡ ; isoʳ = isoʳ } } where module p₁ = Product p₁ module p₂ = Product p₂ open Product p₁ open Product p₂ renaming (A×B to B×A; π₁ to π′₁; π₂ to π′₂; ⟨_,_⟩ to ⟨_,_⟩′) idˡ : A×B ⇒ A×B idˡ = ⟨ π′₂ , π′₁ ⟩ ∘ ⟨ π₂ , π₁ ⟩′ idʳ : B×A ⇒ B×A idʳ = ⟨ π₂ , π₁ ⟩′ ∘ ⟨ π′₂ , π′₁ ⟩ .idˡ-commutes₁ : π₁ ∘ idˡ ≡ π₁ idˡ-commutes₁ = begin π₁ ∘ idˡ ↑⟨ assoc ⟩ (π₁ ∘ ⟨ π′₂ , π′₁ ⟩) ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ ∘-resp-≡ˡ p₁.commute₁ ⟩ π′₂ ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ p₂.commute₂ ⟩ π₁ ∎ where open HomReasoning .idˡ-commutes₂ : π₂ ∘ idˡ ≡ π₂ idˡ-commutes₂ = begin π₂ ∘ idˡ ↑⟨ assoc ⟩ (π₂ ∘ ⟨ π′₂ , π′₁ ⟩) ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ ∘-resp-≡ˡ p₁.commute₂ ⟩ π′₁ ∘ ⟨ π₂ , π₁ ⟩′ ↓⟨ p₂.commute₁ ⟩ π₂ ∎ where open HomReasoning .isoˡ : idˡ ≡ id isoˡ = begin idˡ ↑⟨ p₁.universal idˡ-commutes₁ idˡ-commutes₂ ⟩ ⟨ π₁ , π₂ ⟩ ↓⟨ p₁.η ⟩ id ∎ where open HomReasoning .idʳ-commutes₁ : π′₁ ∘ idʳ ≡ π′₁ idʳ-commutes₁ = begin π′₁ ∘ idʳ ↑⟨ assoc ⟩ (π′₁ ∘ ⟨ π₂ , π₁ ⟩′) ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ ∘-resp-≡ˡ p₂.commute₁ ⟩ π₂ ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ p₁.commute₂ ⟩ π′₁ ∎ where open HomReasoning .idʳ-commutes₂ : π′₂ ∘ idʳ ≡ π′₂ idʳ-commutes₂ = begin π′₂ ∘ idʳ ↑⟨ assoc ⟩ (π′₂ ∘ ⟨ π₂ , π₁ ⟩′) ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ ∘-resp-≡ˡ p₂.commute₂ ⟩ π₁ ∘ ⟨ π′₂ , π′₁ ⟩ ↓⟨ p₁.commute₁ ⟩ π′₂ ∎ where open HomReasoning .isoʳ : idʳ ≡ id isoʳ = begin idʳ ↑⟨ p₂.universal idʳ-commutes₁ idʳ-commutes₂ ⟩ ⟨ π′₁ , π′₂ ⟩′ ↓⟨ p₂.η ⟩ id ∎ where open HomReasoning Associative : ∀ {X Y Z} (p₁ : Product X Y) (p₂ : Product Y Z) (p₃ : Product X (Product.A×B p₂)) (p₄ : Product (Product.A×B p₁) Z) → _≅_ C (Product.A×B p₃) (Product.A×B p₄) Associative p₁ p₂ p₃ p₄ = record { f = f ; g = g ; iso = record { isoˡ = isoˡ ; isoʳ = isoʳ } } where module p₁ = Product p₁ module p₂ = Product p₂ module p₃ = Product p₃ module p₄ = Product p₄ open Product p₁ hiding (π₁; π₂) renaming (⟨_,_⟩ to ⟨_,_⟩p₁) open Product p₂ hiding (π₁; π₂) renaming (A×B to B×C; ⟨_,_⟩ to ⟨_,_⟩p₂) open Product p₃ renaming (A×B to A×[B×C]) open Product p₄ renaming (A×B to [A×B]×C; π₁ to π′₁; π₂ to π′₂; ⟨_,_⟩ to ⟨_,_⟩′) f : A×[B×C] ⇒ [A×B]×C f = ⟨ ⟨ π₁ , p₂.π₁ ∘ π₂ ⟩p₁ , p₂.π₂ ∘ π₂ ⟩′ g : [A×B]×C ⇒ A×[B×C] g = ⟨ p₁.π₁ ∘ π′₁ , ⟨ p₁.π₂ ∘ π′₁ , π′₂ ⟩p₂ ⟩ idˡ : A×[B×C] ⇒ A×[B×C] idˡ = g ∘ f idʳ : [A×B]×C ⇒ [A×B]×C idʳ = f ∘ g .cmˡ₁ : π₁ ∘ idˡ ≡ π₁ cmˡ₁ = begin π₁ ∘ idˡ ↑⟨ assoc ⟩ (π₁ ∘ g) ∘ f ↓⟨ ∘-resp-≡ˡ p₃.commute₁ ⟩ (p₁.π₁ ∘ π′₁) ∘ f ↓⟨ assoc ⟩ p₁.π₁ ∘ (π′₁ ∘ f) ↓⟨ ∘-resp-≡ʳ p₄.commute₁ ⟩ p₁.π₁ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ↓⟨ p₁.commute₁ ⟩ p₃.π₁ ∎ where open HomReasoning .cmˡ₂₁ : p₂.π₁ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ≡ p₂.π₁ ∘ p₃.π₂ cmˡ₂₁ = begin p₂.π₁ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ↑⟨ assoc ⟩ (p₂.π₁ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂) ∘ f ↓⟨ ∘-resp-≡ˡ p₂.commute₁ ⟩ (p₁.π₂ ∘ p₄.π₁) ∘ f ↓⟨ assoc ⟩ p₁.π₂ ∘ (p₄.π₁ ∘ f) ↓⟨ ∘-resp-≡ʳ p₄.commute₁ ⟩ p₁.π₂ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ↓⟨ p₁.commute₂ ⟩ p₂.π₁ ∘ p₃.π₂ ∎ where open HomReasoning .cmˡ₂₂ : p₂.π₂ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ≡ p₂.π₂ ∘ p₃.π₂ cmˡ₂₂ = begin p₂.π₂ ∘ (⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f) ↑⟨ assoc ⟩ (p₂.π₂ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂) ∘ f ↓⟨ ∘-resp-≡ˡ p₂.commute₂ ⟩ p₄.π₂ ∘ f ↓⟨ p₄.commute₂ ⟩ p₂.π₂ ∘ p₃.π₂ ∎ where open HomReasoning .cmˡ₂ : π₂ ∘ idˡ ≡ π₂ cmˡ₂ = begin π₂ ∘ idˡ ↑⟨ assoc ⟩ (π₂ ∘ g) ∘ f ↓⟨ ∘-resp-≡ˡ p₃.commute₂ ⟩ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ∘ f ↑⟨ p₂.universal cmˡ₂₁ cmˡ₂₂ ⟩ ⟨ p₂.π₁ ∘ p₃.π₂ , p₂.π₂ ∘ p₃.π₂ ⟩p₂ ↓⟨ p₂.g-η ⟩ p₃.π₂ ∎ where open HomReasoning .isoˡ : idˡ ≡ id isoˡ = begin idˡ ↑⟨ p₃.universal cmˡ₁ cmˡ₂ ⟩ ⟨ π₁ , π₂ ⟩ ↓⟨ p₃.η ⟩ id ∎ where open HomReasoning .cmʳ₁₁ : p₁.π₁ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ≡ p₁.π₁ ∘ p₄.π₁ cmʳ₁₁ = begin p₁.π₁ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ↑⟨ assoc ⟩ (p₁.π₁ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁) ∘ g ↓⟨ ∘-resp-≡ˡ p₁.commute₁ ⟩ p₃.π₁ ∘ g ↓⟨ p₃.commute₁ ⟩ p₁.π₁ ∘ p₄.π₁ ∎ where open HomReasoning .cmʳ₁₂ : p₁.π₂ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ≡ p₁.π₂ ∘ p₄.π₁ cmʳ₁₂ = begin p₁.π₂ ∘ (⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g) ↑⟨ assoc ⟩ (p₁.π₂ ∘ ⟨ p₃.π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁) ∘ g ↓⟨ ∘-resp-≡ˡ p₁.commute₂ ⟩ (p₂.π₁ ∘ p₃.π₂) ∘ g ↓⟨ assoc ⟩ p₂.π₁ ∘ (p₃.π₂ ∘ g) ↓⟨ ∘-resp-≡ʳ p₃.commute₂ ⟩ p₂.π₁ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ↓⟨ p₂.commute₁ ⟩ p₁.π₂ ∘ p₄.π₁ ∎ where open HomReasoning .cmʳ₁ : π′₁ ∘ idʳ ≡ π′₁ cmʳ₁ = begin π′₁ ∘ idʳ ↑⟨ assoc ⟩ (π′₁ ∘ f) ∘ g ↓⟨ ∘-resp-≡ˡ p₄.commute₁ ⟩ ⟨ π₁ , p₂.π₁ ∘ p₃.π₂ ⟩p₁ ∘ g ↑⟨ p₁.universal cmʳ₁₁ cmʳ₁₂ ⟩ ⟨ p₁.π₁ ∘ p₄.π₁ , p₁.π₂ ∘ p₄.π₁ ⟩p₁ ↓⟨ p₁.g-η ⟩ π′₁ ∎ where open HomReasoning .cmʳ₂ : π′₂ ∘ idʳ ≡ π′₂ cmʳ₂ = begin π′₂ ∘ idʳ ↑⟨ assoc ⟩ (π′₂ ∘ f) ∘ g ↓⟨ ∘-resp-≡ˡ p₄.commute₂ ⟩ (p₂.π₂ ∘ p₃.π₂) ∘ g ↓⟨ assoc ⟩ p₂.π₂ ∘ (p₃.π₂ ∘ g) ↓⟨ ∘-resp-≡ʳ p₃.commute₂ ⟩ p₂.π₂ ∘ ⟨ p₁.π₂ ∘ p₄.π₁ , p₄.π₂ ⟩p₂ ↓⟨ p₂.commute₂ ⟩ p₄.π₂ ∎ where open HomReasoning .isoʳ : idʳ ≡ id isoʳ = begin idʳ ↑⟨ p₄.universal cmʳ₁ cmʳ₂ ⟩ ⟨ π′₁ , π′₂ ⟩′ ↓⟨ p₄.η ⟩ id ∎ where open HomReasoning -}
module Graphics.Cairo.Effect import Data.Vect import Effects import Graphics.SDL2.Effect as SDL import Graphics.Color import Graphics.Shape import Graphics.Cairo.Cairo as C %access public export %default total data CairoCtx = MkCairoCtx (Int, Int) SDLRenderer SDLTexture Surface DrawingCtx data OpenPathCtx = MkOpenPath CairoCtx drawingCtx : CairoCtx -> DrawingCtx drawingCtx (MkCairoCtx _ _ _ _ ctx) = ctx windowSize : CairoCtx -> (Int, Int) windowSize (MkCairoCtx s _ _ _ ctx) = s -- Effect resultValue inputResource outputResource data Cairo : Effect where ||| creates the window + renderer. the effect has no result value, consumes no resource and ||| the output resource will have type SDLRenderer GetCanvas : SDLCtx -> sig Cairo () () CairoCtx CloseCanvas : sig Cairo () CairoCtx () OpenPath : sig Cairo () CairoCtx OpenPathCtx AddPath : sig Cairo () OpenPathCtx OpenPathCtx ClosePath : sig Cairo () OpenPathCtx CairoCtx Center : sig Cairo () CairoCtx CairoCtx WithCairo : (DrawingCtx -> IO a) -> sig Cairo a CairoCtx CairoCtx implementation Handler Cairo IO where handle () (GetCanvas (win, renderer)) k = do (width, height) <- getWindowSize win texture <- sdlCreateTexture renderer SDL_PIXELFORMAT_ARGB8888 SDL_TEXTUREACCESS_STREAMING width height tex <- lockTexture texture srf <- C.createSurfaceForData tex width height ctx <- C.createContext srf k () (MkCairoCtx (width, height) renderer texture srf ctx) handle (MkCairoCtx _ renderer texture srf ctx) CloseCanvas k = do C.flushSurface srf C.destroyContext ctx C.destroySurface srf unlockTexture texture renderCopyFull renderer texture k () () handle s (WithCairo f) k = do res <- f (drawingCtx s) k res s handle s Center k = do let (w,h) = windowSize s translate (drawingCtx s) (cast w / 2) (cast h / 2) k () s handle s OpenPath k = k () (MkOpenPath s) handle s AddPath k = k () s handle (MkOpenPath cairoCtx) ClosePath k = k () cairoCtx CAIRO : Type -> EFFECT CAIRO res = MkEff res Cairo CAIRO_OFF : EFFECT CAIRO_OFF = CAIRO () CAIRO_ON : EFFECT CAIRO_ON = CAIRO CairoCtx -- ------------------------------------------------------------------------ -- API -- ------------------------------------------------------------------------ getCanvas : SDLCtx -> { [CAIRO_OFF] ==> [CAIRO_ON] } Eff () getCanvas sdlCtx = call $ GetCanvas sdlCtx closeCanvas : { [CAIRO_ON] ==> [CAIRO_OFF] } Eff () closeCanvas = call $ CloseCanvas -- Drawing Context setSourceRGBA : Color -> { [CAIRO_ON] } Eff () setSourceRGBA color = let (r, g, b, a) = colorToDoubles color in call $ WithCairo (\ctx => C.setSourceRGBA ctx r g b a) setLineWidth : Double -> { [CAIRO_ON] } Eff () setLineWidth width = call $ WithCairo (\ctx => C.setLineWidth ctx width) stroke : { [CAIRO_ON] } Eff () stroke = call $ WithCairo (\ctx => C.stroke ctx) fill : { [CAIRO_ON] } Eff () fill = call $ WithCairo (\ctx => C.fill ctx) -- Shapes line : (Double, Double) -> (Double, Double) -> { [CAIRO_ON] } Eff () line from to = call $ WithCairo (\ctx => do C.moveTo ctx from C.lineTo ctx to C.stroke ctx) polygon : Path (S (S k)) -> { [CAIRO_ON] } Eff () polygon p = call $ WithCairo (\ctx => do C.newPath ctx C.draw ctx (toPoints p)) triangle : (Double, Double) -> (Double, Double) -> (Double, Double) -> { [CAIRO_ON] } Eff () triangle a b c = polygon $ (Line a b) `Append` c -- transformations center : { [CAIRO_ON] } Eff () center = call Center rotate : (angle: Double) -> { [CAIRO_ON] } Eff () rotate angle = call $ WithCairo (\ctx => C.rotate ctx angle)
= = = Appearance and voice = = =
Formal statement is: lemma pseudo_mod: fixes f g :: "'a::{comm_ring_1,semiring_1_no_zero_divisors} poly" defines "r \<equiv> pseudo_mod f g" assumes g: "g \<noteq> 0" shows "\<exists>a q. a \<noteq> 0 \<and> smult a f = g * q + r" "r = 0 \<or> degree r < degree g" Informal statement is: If $g$ is a nonzero polynomial, then there exist a nonzero constant $a$ and a polynomial $q$ such that $a f = g q + r$, where $r$ is the pseudo remainder of $f$ and $g$. Moreover, $r$ is either zero or has degree less than the degree of $g$.
(* original Author: Martin Desharnais updated to version 2016 by Michaël Noël Divo *) (*<*) theory Untyped_Lambda_Calculus imports Nameless_Representation_Of_Terms begin (*>*) section {* Untyped Lambda-Calculus *} text {* \label{sec:untyped-lambda-calculus} *} text {* The untyped lambda calculus is the first core calculus we formalize. It imports the theory on the nameless representation of terms (Section~\ref{sec:nameless-rep-of-terms}), which formalizes the representation used for the syntax of the language. We complete the definitions, by providing the semantics, and we prove the determinacy of evaluation, the relation between values and normal form, the uniqueness of normal form and the potentially non-terminating nature of evaluation. *} subsection {* Definitions *} text {* In the pure $\lambda$-calculus, only function abstractions are considered values: *} inductive is_value_UL :: "ulterm \<Rightarrow> bool" where "is_value_UL (ULAbs t)" text {* Variables are not part of this definition because they are a way to refer to a specific $\lambda$-abstraction. Since abstractions are themselves values, we do not need to consider their bound variables. The only ones we could consider as values are the free variables, i.e. variables referring to non-existing $\lambda$-abstractions. In the following examples, every occurrence of @{term w} is free: \begin{displaymath} w \qquad (\lambda x. \ x) \ w \qquad (\lambda x. \lambda y. \lambda z. \ w \ x \ y \ z) \end{displaymath} There is no consensus on how the semantics should handle such situations. By excluding them from the set of values, the semantics described in the book defines that such terms are meaningless. This decision is consistent with many programming languages where the use of an undefined identifier leads to an error, either at compile-time or at run-time. The single-step evaluation relation is defined, in the book, with the following inference rules where $[x \mapsto s] \ t$ is the replacement of variable $x$ by $s$ in $t$: \setcounter{equation}{0} \begin{gather} \inferrule {t_1 \implies t_1'}{t_1 \ t_2 \implies t_1' \ t_2} \\[0.8em] \inferrule {t_2 \implies t_2'}{v_1 \ t_2 \implies v_1 \ t_2'} \\[0.8em] \inferrule {}{(\lambda x. \ t_{12}) \ v_2 \implies [x \mapsto v_2] \ t_{12}} \end{gather} The first rule states that the left side of an application must be reduced first, the second rule states that the right side of an application must be reduced second and the third rule states that an application consists of replacing both the $\lambda$-abstraction and the argument by the $\lambda$-abstraction's body where the substitution has been performed. We translate these rules with the following inductive definition: *} inductive eval1_UL :: "ulterm \<Rightarrow> ulterm \<Rightarrow> bool" where eval1_ULApp1: "eval1_UL t1 t1' \<Longrightarrow> eval1_UL (ULApp t1 t2) (ULApp t1' t2)" | eval1_ULApp2: "is_value_UL v1 \<Longrightarrow> eval1_UL t2 t2' \<Longrightarrow> eval1_UL (ULApp v1 t2) (ULApp v1 t2')" | eval1_ULApp_ULAbs: "is_value_UL v2 \<Longrightarrow> eval1_UL (ULApp (ULAbs t12) v2) (shift_UL (-1) 0 (subst_UL 0 (shift_UL 1 0 v2) t12))" text {* Apart from the explicit assumption on the nature of @{term v1}, the only difference is the substitution in the third rule. This is the reason that motivated us to formalize the nameless representation of terms in the first place. The book uses a high level definition of substitution where name clashes are not considered. We replace this higher level operation by our concrete substitution operation on de Bruijn indices. We begin by shifting up by on the concrete argument because, conceptually, it \emph{enters} the function abstraction. We then perform the proper substitution of the function's variable, i.e. of index zero. Finally, we shift down every variable of the resulting body to account for the removed $\lambda$-abstraction. The multi-step evaluation relation and the normal form definitions follow the usual pattern: *} inductive eval_UL :: "ulterm \<Rightarrow> ulterm \<Rightarrow> bool" where eval_UL_base: "eval_UL t t" | eval_UL_step: "eval1_UL t t' \<Longrightarrow> eval_UL t' t'' \<Longrightarrow> eval_UL t t''" definition is_normal_form_UL :: "ulterm \<Rightarrow> bool" where "is_normal_form_UL t \<longleftrightarrow> (\<forall>t'. \<not> eval1_UL t t')" subsection {* Theorems *} text {* In the book, this chapter consists mainly of the presentation of the $\lambda$-calculus, of which we gave a short introduction in the background section (Section~\ref{sec:background-lambda-calculus}), and does not contains meaningful theorems. Nevertheless, we revisit the properties introduced with the arithmetic expressions language (Section~\ref{sec:untyped-arith-expr}) and either prove that they are still theorems or disprove them. *} (* Theorem 3.5.4 for Untyped Lambda Calculus *) text {* The determinacy of the single-step evaluation still holds: *} theorem eval1_UL_determinacy: "eval1_UL t t' \<Longrightarrow> eval1_UL t t'' \<Longrightarrow> t' = t''" proof (induction t t' arbitrary: t'' rule: eval1_UL.induct) case (eval1_ULApp1 t1 t1' t2) from eval1_ULApp1.hyps eval1_ULApp1.prems show ?case by (auto elim: eval1_UL.cases is_value_UL.cases intro: eval1_ULApp1.IH) next case (eval1_ULApp2 t1 t2 t2') from eval1_ULApp2.hyps eval1_ULApp2.prems show ?case by (auto elim: eval1_UL.cases is_value_UL.cases intro: eval1_ULApp2.IH) next case (eval1_ULApp_ULAbs v2 t12) thus ?case by (auto elim: eval1_UL.cases simp: is_value_UL.simps) qed (* Definition 3.5.6 for Untyped Lambda Calculus *) text {* Every value is in normal form: *} (* Theorem 3.5.7 for Untyped Lambda Calculus *) theorem value_imp_normal_form: "is_value_UL t \<Longrightarrow> is_normal_form_UL t" by (auto elim: is_value_UL.cases eval1_UL.cases simp: is_normal_form_UL_def) (* Theorem 3.5.8 does not hold for Untyped Lambda calculus *) text {* Meanwhile, the converse of the preceding theorem is not true since variables are in normal form but are not values: *} theorem normal_form_does_not_imp_value: "\<exists>t. is_normal_form_UL t \<and> \<not> is_value_UL t" (is "\<exists>t. ?P t") proof have a: "\<And>n. is_normal_form_UL (ULVar n)" by (auto simp: is_normal_form_UL_def elim: eval1_UL.cases) have b: "\<And>n. \<not> is_value_UL (ULVar n)" by (auto simp: is_normal_form_UL_def elim: is_value_UL.cases) from a b show "\<And>n. ?P (ULVar n)" by simp qed (* Corollary 3.5.11 for Untyped Lambda Calculus *) text {* The uniqueness of normal form still holds: *} corollary uniqueness_of_normal_form: "eval_UL t u \<Longrightarrow> eval_UL t u' \<Longrightarrow> is_normal_form_UL u \<Longrightarrow> is_normal_form_UL u' \<Longrightarrow> u = u'" by (induction t u rule: eval_UL.induct) (metis eval_UL.cases is_normal_form_UL_def eval1_UL_determinacy)+ (* Theorem 3.5.12 does not hold for Untyped Lambda calculus *) text {* This time, the evaluation relation could be non-terminating. A typical example of term whose evaluation does not terminate is the self-application combinator ($\omega \: \equiv \: \lambda x. \ x \ x$) applied to itself, resulting in a term called $\Omega$: *} (*<*) lemma eval1_UL_ULVarD: "eval1_UL (ULVar x) t \<Longrightarrow> P" by (induction "ULVar x" t rule: eval1_UL.induct) lemma eval1_UL_ULAbsD: "eval1_UL (ULAbs x) t \<Longrightarrow> P" by (induction "ULAbs x" t rule: eval1_UL.induct) (*>*) definition \<omega> :: ulterm where "\<omega> \<equiv> ULAbs (ULApp (ULVar 0) (ULVar 0))" definition \<Omega> :: ulterm where "\<Omega> \<equiv> ULApp \<omega> \<omega>" text {* A single step of evaluation will result in the same term: *} lemma eval1_UL_\<Omega>: "eval1_UL \<Omega> t \<Longrightarrow> \<Omega> = t" by (induction \<Omega> t rule: eval1_UL.induct) (auto elim: eval1_UL_ULAbsD simp: \<omega>_def \<Omega>_def) text {* Since the single-step evaluation is equivalent to the identity, the multi-step evaluation relation will loop infinitely (e.g. $\Omega \to \Omega \to \dots$): *} lemma eval_UL_\<Omega>: "eval_UL \<Omega> t \<Longrightarrow> \<Omega> = t" by (induction \<Omega> t rule: eval_UL.induct) (blast dest: eval1_UL_\<Omega>)+ lemma "eval_UL \<Omega> \<Omega>" by (rule eval_UL.intros) text {* Based on this simple example, we can show that there exists some terms which cannot be reduce to a normal form: *} theorem eval_does_not_always_terminate: "\<exists>t. \<forall>t'. eval_UL t t' \<longrightarrow> \<not> is_normal_form_UL t'" (is "\<exists>t. \<forall>t'. ?P t t'") proof show "\<forall>t'. ?P \<Omega> t'" by (auto dest!: eval_UL_\<Omega>) (auto intro: eval1_UL.intros is_value_UL.intros simp: \<omega>_def \<Omega>_def is_normal_form_UL_def) qed (*<*) end (*>*)
function test_bug731 % MEM 2gb % WALLTIME 00:10:00 % DEPENDENCY % this function checks problems encountered with the neuromag digital trigger reading cfg.dataset = dccnpath('/home/common/matlab/fieldtrip/data/test/bug731/test_bug731.fif'); event = ft_read_event(cfg.dataset); % issue confirmed -> updated bug but will wait for Alex' input before proceeding
(* Copyright (C) 2017 M.A.L. Marques This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. *) (* type: mgga_exc *) $define xc_dimensions_2d js17_lambda := 0.74: js17_beta := 30.0: (* Notes: rho -> 2 rho_sigma, from the spin sum rule tsu2d_unif_sigma/n_sigma^2 = 4 Pi, tau is missing 1/2 in paper *) (* Eq. (18) *) js17_ff := s -> (1 + 90*(2*js17_lambda - 1)^2*s^2 + js17_beta*(2*js17_lambda - 1)^4*s^4)^(1/15): (* Eq. (23) *) js17_R := (s, t) -> 1 + 128/21*(2*js17_lambda - 1)^2*s^2 + (3*(js17_lambda^2 - js17_lambda + 1/2)*(t - 4*Pi) - t)/(4*Pi): js17_f := (x, u, t) -> 1/js17_ff(X2S_2D*x) + 2/5 * js17_R(X2S_2D*x, t)/js17_ff(X2S_2D*x)^3: f := (rs, z, xt, xs0, xs1, u0, u1, t0, t1) -> mgga_exchange(js17_f, rs, z, xs0, xs1, u0, u1, t0, t1):
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc cc cc cc mnperc : percur test program cc cc cc cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc real x(27),y(27),w(27),t(37),c(37),wrk(1400),sp(27) integer iwrk(37) real al,fp,s integer i,ier,iopt,is,j,k,l,lwrk,l1,l2,m,m1,n,nest,nk1 c the data absciss values data x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8),x(9),x(10),x(11), * x(12),x(13),x(14),x(15),x(16),x(17),x(18),x(19),x(20),x(21), * x(22),x(23),x(24),x(25),x(26)/0.0,3.922,7.843,11.765,15.686, * 19.608,23.509,27.451,31.373,35.294,39.216,43.137,47.059,50.980, * 54.902,58.824,62.745,66.667,70.588,74.510,78.431,82.353,86.275, * 90.196,94.118,98.039/ c the data ordinate values data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11), * y(12),y(13),y(14),y(15),y(16),y(17),y(18),y(19),y(20),y(21), * y(22),y(23),y(24),y(25),y(26)/10.099,14.835,21.453,25.022,22.427, * 22.315,22.070,19.673,16.754,13.983,11.973,12.286,16.129,21.560, * 28.041,39.205,59.489,72.559,75.960,79.137,75.925,68.809,55.758, * 39.915,22.006,12.076/ c m denotes the number of data points m = 27 c the period of the spline is determined by x(m) x(m) = 100. y(m) = y(1) c we set up the weights of the data points m1 = m-1 do 10 i=1,m1 w(i) = 1.0 10 continue c we set up the dimension information. nest = 37 lwrk = 1400 c loop for the different spline degrees. do 400 k=3,5,2 c loop for the different spline approximations of degree k do 300 is=1,7 go to (110,120,130,140,150,160,170),is c we start computing the least-squares constant (large value for s). 110 iopt = 0 s = 65000. go to 200 c iopt=1 from the second call on 120 iopt = 1 s = 500. go to 200 c a smaller value for s to get a closer approximation 130 s = 5. go to 200 c a larger value for s to get a smoother approximation 140 s = 20. go to 200 c if a satisfactory fit is obtained we can calculate a spline of equal c quality of fit ( same value for s ) but possibly with fewer knots by c specifying iopt=0 150 s = 20. iopt = 0 go to 200 c we calculate an interpolating periodic spline. 160 s = 0. go to 200 c finally, we also calculate a least-squares periodic spline function c with specified knots. 170 iopt = -1 n = 11+2*k j = k+2 do 180 l=1,9 al = l*10 t(j) = al j = j+1 180 continue c determine the periodic spline approximation 200 call percur(iopt,m,x,y,w,k,s,nest,n,t,c,fp,wrk,lwrk, * iwrk,ier) c printing of the results. if(iopt.ge.0) go to 210 write(6,910) k go to 220 210 write(6,915) k write(6,920) s 220 write(6,925) fp,ier write(6,930) n write(6,935) write(6,940) (t(i),i=1,n) nk1 = n-k-1 write(6,945) write(6,950) (c(i),i=1,nk1) write(6,955) c evaluation of the spline approximation call splev(t,n,c,k,x,sp,m,ier) do 230 i=1,9 l1 = (i-1)*3+1 l2 = l1+2 write(6,960) (x(l),y(l),sp(l),l=l1,l2) 230 continue 300 continue 400 continue stop 910 format(41h0least-squares periodic spline of degree ,i1) 915 format(37h0smoothing periodic spline of degree ,i1) 920 format(20h smoothing factor s=,f7.0) 925 format(1x,23hsum squared residuals =,e15.6,5x,11herror flag=,i2) 930 format(1x,24htotal number of knots n=,i3) 935 format(1x,22hposition of the knots ) 940 format(5x,8f8.3) 945 format(23h0b-spline coefficients ) 950 format(5x,8f8.4) 955 format(1h0,3(3x,2hxi,6x,2hyi,4x,5hs(xi),3x)) 960 format(1h ,3(f7.3,1x,f7.3,1x,f7.3,2x)) end
Formal statement is: lemma multiplicity_eq_int: fixes x y :: int assumes "x > 0" "y > 0" "\<And>p. prime p \<Longrightarrow> multiplicity p x = multiplicity p y" shows "x = y" Informal statement is: If two positive integers have the same prime factorization, then they are equal.