text
stringlengths 0
3.34M
|
---|
theory prop_07
imports Main
"$HIPSTER_HOME/IsaHipster"
begin
datatype Nat = Z | S "Nat"
fun plus :: "Nat => Nat => Nat" where
"plus (Z) y = y"
| "plus (S z) y = S (plus z y)"
fun minus :: "Nat => Nat => Nat" where
"minus (Z) y = Z"
| "minus (S z) (Z) = S z"
| "minus (S z) (S x2) = minus z x2"
(*hipster plus minus *)
(*hipster minus*)
lemma lemma_a [thy_expl]: "minus x2 x2 = Z"
by (hipster_induct_schemes minus.simps)
lemma lemma_aa [thy_expl]: "minus x3 Z = x3"
by (hipster_induct_schemes minus.simps)
lemma lemma_ab [thy_expl]: "minus x2 (S x2) = Z"
by (hipster_induct_schemes)
lemma lemma_ac [thy_expl]: "minus (S x2) x2 = S Z"
by (hipster_induct_schemes)
lemma lemma_ad [thy_expl]: "minus (minus x3 y3) (minus y3 x3) = minus x3 y3"
by (hipster_induct_schemes minus.simps)
lemma lemma_ae [thy_expl]: "minus (minus x3 y3) (S Z) = minus x3 (S y3)"
by (hipster_induct_schemes minus.simps)
lemma lemma_af [thy_expl]: "minus (minus x4 y4) x4 = Z"
by (hipster_induct_schemes minus.simps)
theorem x0 :
"(minus (plus n m) n) = m"
by (tactic \<open>Subgoal.FOCUS_PARAMS (K (Tactic_Data.hard_tac @{context})) @{context} 1\<close>)
end
|
[STATEMENT]
lemma Exists_foldr_Disj:
"Exists x (foldr Disj xs b) \<triangleq> foldr Disj (map (exists x) xs) (exists x b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Exists x (foldr Disj xs b) \<triangleq> foldr Disj (map (exists x) xs) (exists x b)
[PROOF STEP]
by (auto simp: equiv_def) |
theory bla
imports Main
begin
definition bla :: "char \<Rightarrow> bool" where
"bla val = (nat_of_char val \<le> 90)"
declare bla_def [simp]
lemma "\<exists>x::char . bla x = True"
proof -
{
assume "\<not>(\<exists>x . bla x = True)"
hence "\<forall>x . bla x \<noteq> True" by simp
hence "bla CHR ''A'' \<noteq> True" by (rule allE)
hence "False " by simp
}
thus ?thesis by auto
qed
lemma "\<exists>x::char . bla x "
proof -
have "bla CHR ''Z''" by simp
thus "\<exists>x. bla x " by (rule exI)
qed |
Formal statement is: lemma bounded_bilinear_mult: "bounded_bilinear ((*) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a::real_normed_algebra)" Informal statement is: The multiplication operation is bounded bilinear. |
[STATEMENT]
lemma sup_left_top [simp]:
"top \<squnion> x = top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. top \<squnion> x = top
[PROOF STEP]
using sup_right_top sup.commute
[PROOF STATE]
proof (prove)
using this:
?x \<squnion> top = top
?a \<squnion> ?b = ?b \<squnion> ?a
goal (1 subgoal):
1. top \<squnion> x = top
[PROOF STEP]
by fastforce |
The first quarter after Saprang was appointed Chairman , AoT profits plunged 90 % compared to the previous year , despite higher traffic volumes and increased passenger service charters and airline fees . Operating expenses surged 137 % , contributing to the AoT 's worst quarterly earnings report since it was listed on the Stock Exchange of Thailand .
|
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ ∀ (n : ℕ),
(∀ (m : ℕ), m < n → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts) →
∃ conts, continuantsAux (of v) n = Pair.map Rat.cast conts
[PROOFSTEP]
clear n
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
⊢ ∀ (n : ℕ),
(∀ (m : ℕ), m < n → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts) →
∃ conts, continuantsAux (of v) n = Pair.map Rat.cast conts
[PROOFSTEP]
let g := of v
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
⊢ ∀ (n : ℕ),
(∀ (m : ℕ), m < n → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts) →
∃ conts, continuantsAux (of v) n = Pair.map Rat.cast conts
[PROOFSTEP]
intro n IH
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < n → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ ∃ conts, continuantsAux (of v) n = Pair.map Rat.cast conts
[PROOFSTEP]
rcases n with
(_ | _ | n)
-- n = 0
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ ∃ conts, continuantsAux (of v) Nat.zero = Pair.map Rat.cast conts
[PROOFSTEP]
suffices ∃ gp : Pair ℚ, Pair.mk (1 : K) 0 = gp.map (↑) by simpa [continuantsAux]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
this : ∃ gp, { a := 1, b := 0 } = Pair.map Rat.cast gp
⊢ ∃ conts, continuantsAux (of v) Nat.zero = Pair.map Rat.cast conts
[PROOFSTEP]
simpa [continuantsAux]
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ ∃ gp, { a := 1, b := 0 } = Pair.map Rat.cast gp
[PROOFSTEP]
use Pair.mk 1 0
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ { a := 1, b := 0 } = Pair.map Rat.cast { a := 1, b := 0 }
[PROOFSTEP]
simp
-- n = 1
[GOAL]
case succ.zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.succ Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ ∃ conts, continuantsAux (of v) (Nat.succ Nat.zero) = Pair.map Rat.cast conts
[PROOFSTEP]
suffices ∃ conts : Pair ℚ, Pair.mk g.h 1 = conts.map (↑) by simpa [continuantsAux]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.succ Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
this : ∃ conts, { a := g.h, b := 1 } = Pair.map Rat.cast conts
⊢ ∃ conts, continuantsAux (of v) (Nat.succ Nat.zero) = Pair.map Rat.cast conts
[PROOFSTEP]
simpa [continuantsAux]
[GOAL]
case succ.zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.succ Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ ∃ conts, { a := g.h, b := 1 } = Pair.map Rat.cast conts
[PROOFSTEP]
use Pair.mk ⌊v⌋ 1
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
IH : ∀ (m : ℕ), m < Nat.succ Nat.zero → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ { a := g.h, b := 1 } = Pair.map Rat.cast { a := ↑⌊v⌋, b := 1 }
[PROOFSTEP]
simp
-- 2 ≤ n
[GOAL]
case succ.succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
⊢ ∃ conts, continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast conts
[PROOFSTEP]
cases' IH (n + 1) <| lt_add_one (n + 1) with pred_conts pred_conts_eq
[GOAL]
case succ.succ.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
⊢ ∃ conts, continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast conts
[PROOFSTEP]
cases' s_ppred_nth_eq : g.s.get? n with gp_n
[GOAL]
case succ.succ.intro.none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
s_ppred_nth_eq : Stream'.Seq.get? g.s n = none
⊢ ∃ conts, continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast conts
[PROOFSTEP]
use pred_conts
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
s_ppred_nth_eq : Stream'.Seq.get? g.s n = none
⊢ continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast pred_conts
[PROOFSTEP]
have : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) :=
continuantsAux_stable_of_terminated (n + 1).le_succ s_ppred_nth_eq
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
s_ppred_nth_eq : Stream'.Seq.get? g.s n = none
this : continuantsAux g (n + 2) = continuantsAux g (n + 1)
⊢ continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast pred_conts
[PROOFSTEP]
simp only [this, pred_conts_eq]
-- option.some
[GOAL]
case succ.succ.intro.some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
⊢ ∃ conts, continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast conts
[PROOFSTEP]
cases' IH n <| lt_of_le_of_lt n.le_succ <| lt_add_one <| n + 1 with ppred_conts ppred_conts_eq
[GOAL]
case succ.succ.intro.some.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
ppred_conts : Pair ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast ppred_conts
⊢ ∃ conts, continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast conts
[PROOFSTEP]
obtain ⟨a_eq_one, z, b_eq_z⟩ : gp_n.a = 1 ∧ ∃ z : ℤ, gp_n.b = (z : K)
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
ppred_conts : Pair ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast ppred_conts
⊢ gp_n.a = 1 ∧ ∃ z, gp_n.b = ↑z
case succ.succ.intro.some.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
ppred_conts : Pair ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast ppred_conts
a_eq_one : gp_n.a = 1
z : ℤ
b_eq_z : gp_n.b = ↑z
⊢ ∃ conts, continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast conts
[PROOFSTEP]
exact of_part_num_eq_one_and_exists_int_part_denom_eq s_ppred_nth_eq
[GOAL]
case succ.succ.intro.some.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
ppred_conts : Pair ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast ppred_conts
a_eq_one : gp_n.a = 1
z : ℤ
b_eq_z : gp_n.b = ↑z
⊢ ∃ conts, continuantsAux (of v) (Nat.succ (Nat.succ n)) = Pair.map Rat.cast conts
[PROOFSTEP]
simp only [a_eq_one, b_eq_z, continuantsAux_recurrence s_ppred_nth_eq ppred_conts_eq pred_conts_eq]
[GOAL]
case succ.succ.intro.some.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
ppred_conts : Pair ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast ppred_conts
a_eq_one : gp_n.a = 1
z : ℤ
b_eq_z : gp_n.b = ↑z
⊢ ∃ conts,
{ a := ↑z * (Pair.map Rat.cast pred_conts).a + 1 * (Pair.map Rat.cast ppred_conts).a,
b := ↑z * (Pair.map Rat.cast pred_conts).b + 1 * (Pair.map Rat.cast ppred_conts).b } =
Pair.map Rat.cast conts
[PROOFSTEP]
use nextContinuants 1 (z : ℚ) ppred_conts pred_conts
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
ppred_conts : Pair ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast ppred_conts
a_eq_one : gp_n.a = 1
z : ℤ
b_eq_z : gp_n.b = ↑z
⊢ { a := ↑z * (Pair.map Rat.cast pred_conts).a + 1 * (Pair.map Rat.cast ppred_conts).a,
b := ↑z * (Pair.map Rat.cast pred_conts).b + 1 * (Pair.map Rat.cast ppred_conts).b } =
Pair.map Rat.cast (nextContinuants 1 (↑z) ppred_conts pred_conts)
[PROOFSTEP]
cases ppred_conts
[GOAL]
case h.mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
pred_conts : Pair ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast pred_conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
a_eq_one : gp_n.a = 1
z : ℤ
b_eq_z : gp_n.b = ↑z
a✝ b✝ : ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast { a := a✝, b := b✝ }
⊢ { a := ↑z * (Pair.map Rat.cast pred_conts).a + 1 * (Pair.map Rat.cast { a := a✝, b := b✝ }).a,
b := ↑z * (Pair.map Rat.cast pred_conts).b + 1 * (Pair.map Rat.cast { a := a✝, b := b✝ }).b } =
Pair.map Rat.cast (nextContinuants 1 ↑z { a := a✝, b := b✝ } pred_conts)
[PROOFSTEP]
cases pred_conts
[GOAL]
case h.mk.mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
g : GeneralizedContinuedFraction K := of v
n : ℕ
IH : ∀ (m : ℕ), m < Nat.succ (Nat.succ n) → ∃ conts, continuantsAux (of v) m = Pair.map Rat.cast conts
gp_n : Pair K
s_ppred_nth_eq : Stream'.Seq.get? g.s n = some gp_n
a_eq_one : gp_n.a = 1
z : ℤ
b_eq_z : gp_n.b = ↑z
a✝¹ b✝¹ : ℚ
ppred_conts_eq : continuantsAux (of v) n = Pair.map Rat.cast { a := a✝¹, b := b✝¹ }
a✝ b✝ : ℚ
pred_conts_eq : continuantsAux (of v) (n + 1) = Pair.map Rat.cast { a := a✝, b := b✝ }
⊢ { a := ↑z * (Pair.map Rat.cast { a := a✝, b := b✝ }).a + 1 * (Pair.map Rat.cast { a := a✝¹, b := b✝¹ }).a,
b := ↑z * (Pair.map Rat.cast { a := a✝, b := b✝ }).b + 1 * (Pair.map Rat.cast { a := a✝¹, b := b✝¹ }).b } =
Pair.map Rat.cast (nextContinuants 1 ↑z { a := a✝¹, b := b✝¹ } { a := a✝, b := b✝ })
[PROOFSTEP]
simp [nextContinuants, nextNumerator, nextDenominator]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ ∃ conts, continuants (of v) n = Pair.map Rat.cast conts
[PROOFSTEP]
rw [nth_cont_eq_succ_nth_cont_aux]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ ∃ conts, continuantsAux (of v) (n + 1) = Pair.map Rat.cast conts
[PROOFSTEP]
exact exists_gcf_pair_rat_eq_of_nth_conts_aux v <| n + 1
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ ∃ q, numerators (of v) n = ↑q
[PROOFSTEP]
rcases exists_gcf_pair_rat_eq_nth_conts v n with ⟨⟨a, _⟩, nth_cont_eq⟩
[GOAL]
case intro.mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a b✝ : ℚ
nth_cont_eq : continuants (of v) n = Pair.map Rat.cast { a := a, b := b✝ }
⊢ ∃ q, numerators (of v) n = ↑q
[PROOFSTEP]
use a
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a b✝ : ℚ
nth_cont_eq : continuants (of v) n = Pair.map Rat.cast { a := a, b := b✝ }
⊢ numerators (of v) n = ↑a
[PROOFSTEP]
simp [num_eq_conts_a, nth_cont_eq]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ ∃ q, denominators (of v) n = ↑q
[PROOFSTEP]
rcases exists_gcf_pair_rat_eq_nth_conts v n with ⟨⟨_, b⟩, nth_cont_eq⟩
[GOAL]
case intro.mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a✝ b : ℚ
nth_cont_eq : continuants (of v) n = Pair.map Rat.cast { a := a✝, b := b }
⊢ ∃ q, denominators (of v) n = ↑q
[PROOFSTEP]
use b
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a✝ b : ℚ
nth_cont_eq : continuants (of v) n = Pair.map Rat.cast { a := a✝, b := b }
⊢ denominators (of v) n = ↑b
[PROOFSTEP]
simp [denom_eq_conts_b, nth_cont_eq]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ ∃ q, convergents (of v) n = ↑q
[PROOFSTEP]
rcases exists_rat_eq_nth_numerator v n with ⟨Aₙ, nth_num_eq⟩
[GOAL]
case intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
Aₙ : ℚ
nth_num_eq : numerators (of v) n = ↑Aₙ
⊢ ∃ q, convergents (of v) n = ↑q
[PROOFSTEP]
rcases exists_rat_eq_nth_denominator v n with ⟨Bₙ, nth_denom_eq⟩
[GOAL]
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
Aₙ : ℚ
nth_num_eq : numerators (of v) n = ↑Aₙ
Bₙ : ℚ
nth_denom_eq : denominators (of v) n = ↑Bₙ
⊢ ∃ q, convergents (of v) n = ↑q
[PROOFSTEP]
use Aₙ / Bₙ
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
Aₙ : ℚ
nth_num_eq : numerators (of v) n = ↑Aₙ
Bₙ : ℚ
nth_denom_eq : denominators (of v) n = ↑Bₙ
⊢ convergents (of v) n = ↑(Aₙ / Bₙ)
[PROOFSTEP]
simp [nth_num_eq, nth_denom_eq, convergent_eq_num_div_denom]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
terminates : Terminates (of v)
⊢ ∃ q, v = ↑q
[PROOFSTEP]
obtain ⟨n, v_eq_conv⟩ : ∃ n, v = (of v).convergents n
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
terminates : Terminates (of v)
⊢ ∃ n, v = convergents (of v) n
case intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
terminates : Terminates (of v)
n : ℕ
v_eq_conv : v = convergents (of v) n
⊢ ∃ q, v = ↑q
[PROOFSTEP]
exact of_correctness_of_terminates terminates
[GOAL]
case intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
terminates : Terminates (of v)
n : ℕ
v_eq_conv : v = convergents (of v) n
⊢ ∃ q, v = ↑q
[PROOFSTEP]
obtain ⟨q, conv_eq_q⟩ : ∃ q : ℚ, (of v).convergents n = (↑q : K)
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
terminates : Terminates (of v)
n : ℕ
v_eq_conv : v = convergents (of v) n
⊢ ∃ q, convergents (of v) n = ↑q
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
terminates : Terminates (of v)
n : ℕ
v_eq_conv : v = convergents (of v) n
q : ℚ
conv_eq_q : convergents (of v) n = ↑q
⊢ ∃ q, v = ↑q
[PROOFSTEP]
exact exists_rat_eq_nth_convergent v n
[GOAL]
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
terminates : Terminates (of v)
n : ℕ
v_eq_conv : v = convergents (of v) n
q : ℚ
conv_eq_q : convergents (of v) n = ↑q
⊢ ∃ q, v = ↑q
[PROOFSTEP]
have : v = (↑q : K) := Eq.trans v_eq_conv conv_eq_q
[GOAL]
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
terminates : Terminates (of v)
n : ℕ
v_eq_conv : v = convergents (of v) n
q : ℚ
conv_eq_q : convergents (of v) n = ↑q
this : v = ↑q
⊢ ∃ q, v = ↑q
[PROOFSTEP]
use q, this
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ mapFr Rat.cast (IntFractPair.of q) = IntFractPair.of v
[PROOFSTEP]
simp [IntFractPair.of, v_eq_q]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream v n
[PROOFSTEP]
induction' n with n IH
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q Nat.zero) = IntFractPair.stream v Nat.zero
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream v n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
case zero =>
-- Porting note: was
-- simp [IntFractPair.stream, coe_of_rat_eq v_eq_q]simp only [IntFractPair.stream, Option.map_some',
coe_of_rat_eq v_eq_q]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q Nat.zero) = IntFractPair.stream v Nat.zero
[PROOFSTEP]
case zero =>
-- Porting note: was
-- simp [IntFractPair.stream, coe_of_rat_eq v_eq_q]simp only [IntFractPair.stream, Option.map_some',
coe_of_rat_eq v_eq_q]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q Nat.zero) = IntFractPair.stream v Nat.zero
[PROOFSTEP]
simp only [IntFractPair.stream, Option.map_some', coe_of_rat_eq v_eq_q]
[GOAL]
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream v n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
case succ =>
rw [v_eq_q] at IH
cases' stream_q_nth_eq : IntFractPair.stream q n with ifp_n
case none => simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq]
case some =>
cases' ifp_n with b fr
cases' Decidable.em (fr = 0) with fr_zero fr_ne_zero
· simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_zero]
· replace IH : some (IntFractPair.mk b (fr : K)) = IntFractPair.stream (↑q) n; · rwa [stream_q_nth_eq] at IH
have : (fr : K)⁻¹ = ((fr⁻¹ : ℚ) : K) := by norm_cast
have coe_of_fr := coe_of_rat_eq this
simpa [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_ne_zero]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream v n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
case succ =>
rw [v_eq_q] at IH
cases' stream_q_nth_eq : IntFractPair.stream q n with ifp_n
case none => simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq]
case some =>
cases' ifp_n with b fr
cases' Decidable.em (fr = 0) with fr_zero fr_ne_zero
· simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_zero]
· replace IH : some (IntFractPair.mk b (fr : K)) = IntFractPair.stream (↑q) n; · rwa [stream_q_nth_eq] at IH
have : (fr : K)⁻¹ = ((fr⁻¹ : ℚ) : K) := by norm_cast
have coe_of_fr := coe_of_rat_eq this
simpa [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_ne_zero]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream v n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
rw [v_eq_q] at IH
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
cases' stream_q_nth_eq : IntFractPair.stream q n with ifp_n
[GOAL]
case none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
stream_q_nth_eq : IntFractPair.stream q n = none
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
ifp_n : IntFractPair ℚ
stream_q_nth_eq : IntFractPair.stream q n = some ifp_n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
case none => simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
stream_q_nth_eq : IntFractPair.stream q n = none
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
case none => simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
stream_q_nth_eq : IntFractPair.stream q n = none
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq]
[GOAL]
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
ifp_n : IntFractPair ℚ
stream_q_nth_eq : IntFractPair.stream q n = some ifp_n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
case some =>
cases' ifp_n with b fr
cases' Decidable.em (fr = 0) with fr_zero fr_ne_zero
· simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_zero]
· replace IH : some (IntFractPair.mk b (fr : K)) = IntFractPair.stream (↑q) n; · rwa [stream_q_nth_eq] at IH
have : (fr : K)⁻¹ = ((fr⁻¹ : ℚ) : K) := by norm_cast
have coe_of_fr := coe_of_rat_eq this
simpa [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_ne_zero]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
ifp_n : IntFractPair ℚ
stream_q_nth_eq : IntFractPair.stream q n = some ifp_n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
case some =>
cases' ifp_n with b fr
cases' Decidable.em (fr = 0) with fr_zero fr_ne_zero
· simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_zero]
· replace IH : some (IntFractPair.mk b (fr : K)) = IntFractPair.stream (↑q) n; · rwa [stream_q_nth_eq] at IH
have : (fr : K)⁻¹ = ((fr⁻¹ : ℚ) : K) := by norm_cast
have coe_of_fr := coe_of_rat_eq this
simpa [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_ne_zero]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
ifp_n : IntFractPair ℚ
stream_q_nth_eq : IntFractPair.stream q n = some ifp_n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
cases' ifp_n with b fr
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
cases' Decidable.em (fr = 0) with fr_zero fr_ne_zero
[GOAL]
case mk.inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
fr_zero : fr = 0
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
simp [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_zero]
[GOAL]
case mk.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
fr_ne_zero : ¬fr = 0
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
replace IH : some (IntFractPair.mk b (fr : K)) = IntFractPair.stream (↑q) n
[GOAL]
case IH
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
IH : Option.map (mapFr Rat.cast) (IntFractPair.stream q n) = IntFractPair.stream (↑q) n
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
fr_ne_zero : ¬fr = 0
⊢ some { b := b, fr := ↑fr } = IntFractPair.stream (↑q) n
[PROOFSTEP]
rwa [stream_q_nth_eq] at IH
[GOAL]
case mk.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
fr_ne_zero : ¬fr = 0
IH : some { b := b, fr := ↑fr } = IntFractPair.stream (↑q) n
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
have : (fr : K)⁻¹ = ((fr⁻¹ : ℚ) : K) := by norm_cast
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
fr_ne_zero : ¬fr = 0
IH : some { b := b, fr := ↑fr } = IntFractPair.stream (↑q) n
⊢ (↑fr)⁻¹ = ↑fr⁻¹
[PROOFSTEP]
norm_cast
[GOAL]
case mk.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
fr_ne_zero : ¬fr = 0
IH : some { b := b, fr := ↑fr } = IntFractPair.stream (↑q) n
this : (↑fr)⁻¹ = ↑fr⁻¹
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
have coe_of_fr := coe_of_rat_eq this
[GOAL]
case mk.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
b : ℤ
fr : ℚ
stream_q_nth_eq : IntFractPair.stream q n = some { b := b, fr := fr }
fr_ne_zero : ¬fr = 0
IH : some { b := b, fr := ↑fr } = IntFractPair.stream (↑q) n
this : (↑fr)⁻¹ = ↑fr⁻¹
coe_of_fr : mapFr Rat.cast (IntFractPair.of fr⁻¹) = IntFractPair.of (↑fr)⁻¹
⊢ Option.map (mapFr Rat.cast) (IntFractPair.stream q (Nat.succ n)) = IntFractPair.stream v (Nat.succ n)
[PROOFSTEP]
simpa [IntFractPair.stream, IH.symm, v_eq_q, stream_q_nth_eq, fr_ne_zero]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Stream'.map (Option.map (mapFr Rat.cast)) (IntFractPair.stream q) = IntFractPair.stream v
[PROOFSTEP]
funext n
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
⊢ Stream'.map (Option.map (mapFr Rat.cast)) (IntFractPair.stream q) n = IntFractPair.stream v n
[PROOFSTEP]
exact IntFractPair.coe_stream_nth_rat_eq v_eq_q n
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ ↑(of q).h = (of v).h
[PROOFSTEP]
unfold of IntFractPair.seq1
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ ↑(match
(IntFractPair.of q,
Stream'.Seq.tail
{ val := IntFractPair.stream q, property := (_ : Stream'.IsSeq (IntFractPair.stream q)) }) with
| (h, s) => { h := ↑h.b, s := Stream'.Seq.map (fun p => { a := 1, b := ↑p.b }) s }).h =
(match
(IntFractPair.of v,
Stream'.Seq.tail
{ val := IntFractPair.stream v, property := (_ : Stream'.IsSeq (IntFractPair.stream v)) }) with
| (h, s) => { h := ↑h.b, s := Stream'.Seq.map (fun p => { a := 1, b := ↑p.b }) s }).h
[PROOFSTEP]
rw [← IntFractPair.coe_of_rat_eq v_eq_q]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ ↑(match
(IntFractPair.of q,
Stream'.Seq.tail
{ val := IntFractPair.stream q, property := (_ : Stream'.IsSeq (IntFractPair.stream q)) }) with
| (h, s) => { h := ↑h.b, s := Stream'.Seq.map (fun p => { a := 1, b := ↑p.b }) s }).h =
(match
(IntFractPair.mapFr Rat.cast (IntFractPair.of q),
Stream'.Seq.tail
{ val := IntFractPair.stream v, property := (_ : Stream'.IsSeq (IntFractPair.stream v)) }) with
| (h, s) => { h := ↑h.b, s := Stream'.Seq.map (fun p => { a := 1, b := ↑p.b }) s }).h
[PROOFSTEP]
simp
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (Pair.map Rat.cast) (Stream'.Seq.get? (of q).s n) = Stream'.Seq.get? (of v).s n
[PROOFSTEP]
simp only [of, IntFractPair.seq1, Stream'.Seq.map_get?, Stream'.Seq.get?_tail]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (Pair.map Rat.cast)
(Option.map (fun p => { a := 1, b := ↑p.b })
(Stream'.Seq.get? { val := IntFractPair.stream q, property := (_ : Stream'.IsSeq (IntFractPair.stream q)) }
(n + 1))) =
Option.map (fun p => { a := 1, b := ↑p.b })
(Stream'.Seq.get? { val := IntFractPair.stream v, property := (_ : Stream'.IsSeq (IntFractPair.stream v)) }
(n + 1))
[PROOFSTEP]
simp only [Stream'.Seq.get?]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (Pair.map Rat.cast) (Option.map (fun p => { a := 1, b := ↑p.b }) (IntFractPair.stream q (n + 1))) =
Option.map (fun p => { a := 1, b := ↑p.b }) (IntFractPair.stream v (n + 1))
[PROOFSTEP]
rw [← IntFractPair.coe_stream'_rat_eq v_eq_q]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Option.map (Pair.map Rat.cast) (Option.map (fun p => { a := 1, b := ↑p.b }) (IntFractPair.stream q (n + 1))) =
Option.map (fun p => { a := 1, b := ↑p.b })
(Stream'.map (Option.map (IntFractPair.mapFr Rat.cast)) (IntFractPair.stream q) (n + 1))
[PROOFSTEP]
rcases succ_nth_stream_eq : IntFractPair.stream q (n + 1) with (_ | ⟨_, _⟩)
[GOAL]
case none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
succ_nth_stream_eq : IntFractPair.stream q (n + 1) = none
⊢ Option.map (Pair.map Rat.cast) (Option.map (fun p => { a := 1, b := ↑p.b }) none) =
Option.map (fun p => { a := 1, b := ↑p.b })
(Stream'.map (Option.map (IntFractPair.mapFr Rat.cast)) (IntFractPair.stream q) (n + 1))
[PROOFSTEP]
simp [Stream'.map, Stream'.nth, succ_nth_stream_eq]
[GOAL]
case some.mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
b✝ : ℤ
fr✝ : ℚ
succ_nth_stream_eq : IntFractPair.stream q (n + 1) = some { b := b✝, fr := fr✝ }
⊢ Option.map (Pair.map Rat.cast) (Option.map (fun p => { a := 1, b := ↑p.b }) (some { b := b✝, fr := fr✝ })) =
Option.map (fun p => { a := 1, b := ↑p.b })
(Stream'.map (Option.map (IntFractPair.mapFr Rat.cast)) (IntFractPair.stream q) (n + 1))
[PROOFSTEP]
simp [Stream'.map, Stream'.nth, succ_nth_stream_eq]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ Stream'.Seq.map (Pair.map Rat.cast) (of q).s = (of v).s
[PROOFSTEP]
ext n
[GOAL]
case h.a
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
a✝ : Pair K
⊢ a✝ ∈ Stream'.Seq.get? (Stream'.Seq.map (Pair.map Rat.cast) (of q).s) n ↔ a✝ ∈ Stream'.Seq.get? (of v).s n
[PROOFSTEP]
rw [← coe_of_s_get?_rat_eq v_eq_q]
[GOAL]
case h.a
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n✝ n : ℕ
a✝ : Pair K
⊢ a✝ ∈ Stream'.Seq.get? (Stream'.Seq.map (Pair.map Rat.cast) (of q).s) n ↔
a✝ ∈ Option.map (Pair.map Rat.cast) (Stream'.Seq.get? (of q).s n)
[PROOFSTEP]
rfl
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
⊢ { h := ↑(of q).h, s := Stream'.Seq.map (Pair.map Rat.cast) (of q).s } = of v
[PROOFSTEP]
cases' gcf_v_eq : of v with h s
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : K
s : Stream'.Seq (Pair K)
gcf_v_eq : of v = { h := h, s := s }
⊢ { h := ↑(of q).h, s := Stream'.Seq.map (Pair.map Rat.cast) (of q).s } = { h := h, s := s }
[PROOFSTEP]
subst v
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
h : K
s : Stream'.Seq (Pair K)
gcf_v_eq : of ↑q = { h := h, s := s }
⊢ { h := ↑(of q).h, s := Stream'.Seq.map (Pair.map Rat.cast) (of q).s } = { h := h, s := s }
[PROOFSTEP]
obtain rfl : ↑⌊(q : K)⌋ = h := by injection gcf_v_eq
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
h : K
s : Stream'.Seq (Pair K)
gcf_v_eq : of ↑q = { h := h, s := s }
⊢ ↑⌊↑q⌋ = h
[PROOFSTEP]
injection gcf_v_eq
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
s : Stream'.Seq (Pair K)
gcf_v_eq : of ↑q = { h := ↑⌊↑q⌋, s := s }
⊢ { h := ↑(of q).h, s := Stream'.Seq.map (Pair.map Rat.cast) (of q).s } = { h := ↑⌊↑q⌋, s := s }
[PROOFSTEP]
simp only [gcf_v_eq, Int.cast_inj, Rat.floor_cast, of_h_eq_floor, eq_self_iff_true, Rat.cast_coe_int, and_self,
coe_of_h_rat_eq rfl, coe_of_s_rat_eq rfl]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
⊢ Terminates (of v) ↔ Terminates (of q)
[PROOFSTEP]
constructor
[GOAL]
case mp
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
⊢ Terminates (of v) → Terminates (of q)
[PROOFSTEP]
intro h
[GOAL]
case mpr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
⊢ Terminates (of q) → Terminates (of v)
[PROOFSTEP]
intro h
[GOAL]
case mp
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
h : Terminates (of v)
⊢ Terminates (of q)
[PROOFSTEP]
cases' h with n h
[GOAL]
case mpr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
h : Terminates (of q)
⊢ Terminates (of v)
[PROOFSTEP]
cases' h with n h
[GOAL]
case mp.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Stream'.Seq.TerminatedAt (of v).s n
⊢ Terminates (of q)
[PROOFSTEP]
use n
[GOAL]
case mpr.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Stream'.Seq.TerminatedAt (of q).s n
⊢ Terminates (of v)
[PROOFSTEP]
use n
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Stream'.Seq.TerminatedAt (of v).s n
⊢ Stream'.Seq.TerminatedAt (of q).s n
[PROOFSTEP]
simp only [Stream'.Seq.TerminatedAt, (coe_of_s_get?_rat_eq v_eq_q n).symm] at h ⊢
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Stream'.Seq.TerminatedAt (of q).s n
⊢ Stream'.Seq.TerminatedAt (of v).s n
[PROOFSTEP]
simp only [Stream'.Seq.TerminatedAt, (coe_of_s_get?_rat_eq v_eq_q n).symm] at h ⊢
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Option.map (Pair.map Rat.cast) (Stream'.Seq.get? (of q).s n) = none
⊢ Stream'.Seq.get? (of q).s n = none
[PROOFSTEP]
cases h' : (of q).s.get? n
[GOAL]
case h
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Stream'.Seq.get? (of q).s n = none
⊢ Option.map (Pair.map Rat.cast) (Stream'.Seq.get? (of q).s n) = none
[PROOFSTEP]
cases h' : (of q).s.get? n
[GOAL]
case h.none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Option.map (Pair.map Rat.cast) (Stream'.Seq.get? (of q).s n) = none
h' : Stream'.Seq.get? (of q).s n = none
⊢ none = none
[PROOFSTEP]
simp only [h'] at h
[GOAL]
case h.some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Option.map (Pair.map Rat.cast) (Stream'.Seq.get? (of q).s n) = none
val✝ : Pair ℚ
h' : Stream'.Seq.get? (of q).s n = some val✝
⊢ some val✝ = none
[PROOFSTEP]
simp only [h'] at h
[GOAL]
case h.none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h h' : Stream'.Seq.get? (of q).s n = none
⊢ Option.map (Pair.map Rat.cast) none = none
[PROOFSTEP]
simp only [h'] at h
[GOAL]
case h.some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h : Stream'.Seq.get? (of q).s n = none
val✝ : Pair ℚ
h' : Stream'.Seq.get? (of q).s n = some val✝
⊢ Option.map (Pair.map Rat.cast) (some val✝) = none
[PROOFSTEP]
simp only [h'] at h
[GOAL]
case h.none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h' : Stream'.Seq.get? (of q).s n = none
h : Option.map (Pair.map Rat.cast) none = none
⊢ none = none
[PROOFSTEP]
trivial
[GOAL]
case h.some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
val✝ : Pair ℚ
h' : Stream'.Seq.get? (of q).s n = some val✝
h : Option.map (Pair.map Rat.cast) (some val✝) = none
⊢ some val✝ = none
[PROOFSTEP]
trivial
[GOAL]
case h.none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
q✝ : ℚ
v_eq_q✝ : v✝ = ↑q✝
n✝ : ℕ
v : K
q : ℚ
v_eq_q : v = ↑q
n : ℕ
h' : Stream'.Seq.get? (of q).s n = none
h : True
⊢ Option.map (Pair.map Rat.cast) none = none
[PROOFSTEP]
trivial
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
⊢ ifp_succ_n.fr.num < ifp_n.fr.num
[PROOFSTEP]
obtain ⟨ifp_n', stream_nth_eq', ifp_n_fract_ne_zero, IntFractPair.of_eq_ifp_succ_n⟩ :
∃ ifp_n', IntFractPair.stream q n = some ifp_n' ∧ ifp_n'.fr ≠ 0 ∧ IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
⊢ ∃ ifp_n', IntFractPair.stream q n = some ifp_n' ∧ ifp_n'.fr ≠ 0 ∧ IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n
case intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
ifp_n' : IntFractPair ℚ
stream_nth_eq' : IntFractPair.stream q n = some ifp_n'
ifp_n_fract_ne_zero : ifp_n'.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n
⊢ ifp_succ_n.fr.num < ifp_n.fr.num
[PROOFSTEP]
exact succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq
[GOAL]
case intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
ifp_n' : IntFractPair ℚ
stream_nth_eq' : IntFractPair.stream q n = some ifp_n'
ifp_n_fract_ne_zero : ifp_n'.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n
⊢ ifp_succ_n.fr.num < ifp_n.fr.num
[PROOFSTEP]
have : ifp_n = ifp_n' := by injection Eq.trans stream_nth_eq.symm stream_nth_eq'
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
ifp_n' : IntFractPair ℚ
stream_nth_eq' : IntFractPair.stream q n = some ifp_n'
ifp_n_fract_ne_zero : ifp_n'.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n
⊢ ifp_n = ifp_n'
[PROOFSTEP]
injection Eq.trans stream_nth_eq.symm stream_nth_eq'
[GOAL]
case intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
ifp_n' : IntFractPair ℚ
stream_nth_eq' : IntFractPair.stream q n = some ifp_n'
ifp_n_fract_ne_zero : ifp_n'.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n
this : ifp_n = ifp_n'
⊢ ifp_succ_n.fr.num < ifp_n.fr.num
[PROOFSTEP]
cases this
[GOAL]
case intro.intro.intro.refl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
stream_nth_eq' : IntFractPair.stream q n = some ifp_n
ifp_n_fract_ne_zero : ifp_n.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
⊢ ifp_succ_n.fr.num < ifp_n.fr.num
[PROOFSTEP]
rw [← IntFractPair.of_eq_ifp_succ_n]
[GOAL]
case intro.intro.intro.refl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
stream_nth_eq' : IntFractPair.stream q n = some ifp_n
ifp_n_fract_ne_zero : ifp_n.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
⊢ (IntFractPair.of ifp_n.fr⁻¹).fr.num < ifp_n.fr.num
[PROOFSTEP]
cases' nth_stream_fr_nonneg_lt_one stream_nth_eq with zero_le_ifp_n_fract ifp_n_fract_lt_one
[GOAL]
case intro.intro.intro.refl.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
stream_nth_eq' : IntFractPair.stream q n = some ifp_n
ifp_n_fract_ne_zero : ifp_n.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
zero_le_ifp_n_fract : 0 ≤ ifp_n.fr
ifp_n_fract_lt_one : ifp_n.fr < 1
⊢ (IntFractPair.of ifp_n.fr⁻¹).fr.num < ifp_n.fr.num
[PROOFSTEP]
have : 0 < ifp_n.fr := lt_of_le_of_ne zero_le_ifp_n_fract <| ifp_n_fract_ne_zero.symm
[GOAL]
case intro.intro.intro.refl.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_n ifp_succ_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n
stream_nth_eq' : IntFractPair.stream q n = some ifp_n
ifp_n_fract_ne_zero : ifp_n.fr ≠ 0
IntFractPair.of_eq_ifp_succ_n : IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
zero_le_ifp_n_fract : 0 ≤ ifp_n.fr
ifp_n_fract_lt_one : ifp_n.fr < 1
this : 0 < ifp_n.fr
⊢ (IntFractPair.of ifp_n.fr⁻¹).fr.num < ifp_n.fr.num
[PROOFSTEP]
exact of_inv_fr_num_lt_num_of_pos this
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
⊢ ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
[PROOFSTEP]
induction' n with n IH
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
⊢ ∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q Nat.zero = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑Nat.zero
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
⊢ ∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q (Nat.succ n) = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑(Nat.succ n)
[PROOFSTEP]
case zero =>
intro ifp_zero stream_zero_eq
have : IntFractPair.of q = ifp_zero := by injection stream_zero_eq
simp [le_refl, this.symm]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
⊢ ∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q Nat.zero = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑Nat.zero
[PROOFSTEP]
case zero =>
intro ifp_zero stream_zero_eq
have : IntFractPair.of q = ifp_zero := by injection stream_zero_eq
simp [le_refl, this.symm]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
⊢ ∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q Nat.zero = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑Nat.zero
[PROOFSTEP]
intro ifp_zero stream_zero_eq
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_zero : IntFractPair ℚ
stream_zero_eq : IntFractPair.stream q Nat.zero = some ifp_zero
⊢ ifp_zero.fr.num ≤ (IntFractPair.of q).fr.num - ↑Nat.zero
[PROOFSTEP]
have : IntFractPair.of q = ifp_zero := by injection stream_zero_eq
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_zero : IntFractPair ℚ
stream_zero_eq : IntFractPair.stream q Nat.zero = some ifp_zero
⊢ IntFractPair.of q = ifp_zero
[PROOFSTEP]
injection stream_zero_eq
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n : ℕ
ifp_zero : IntFractPair ℚ
stream_zero_eq : IntFractPair.stream q Nat.zero = some ifp_zero
this : IntFractPair.of q = ifp_zero
⊢ ifp_zero.fr.num ≤ (IntFractPair.of q).fr.num - ↑Nat.zero
[PROOFSTEP]
simp [le_refl, this.symm]
[GOAL]
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
⊢ ∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q (Nat.succ n) = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑(Nat.succ n)
[PROOFSTEP]
case succ =>
intro ifp_succ_n stream_succ_nth_eq
suffices ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - n
by
rw [Int.ofNat_succ, sub_add_eq_sub_sub]
solve_by_elim [le_sub_right_of_add_le]
rcases succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq with ⟨ifp_n, stream_nth_eq, -⟩
have : ifp_succ_n.fr.num < ifp_n.fr.num := stream_succ_nth_fr_num_lt_nth_fr_num_rat stream_nth_eq stream_succ_nth_eq
have : ifp_succ_n.fr.num + 1 ≤ ifp_n.fr.num := Int.add_one_le_of_lt this
exact le_trans this (IH stream_nth_eq)
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
⊢ ∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q (Nat.succ n) = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑(Nat.succ n)
[PROOFSTEP]
case succ =>
intro ifp_succ_n stream_succ_nth_eq
suffices ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - n
by
rw [Int.ofNat_succ, sub_add_eq_sub_sub]
solve_by_elim [le_sub_right_of_add_le]
rcases succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq with ⟨ifp_n, stream_nth_eq, -⟩
have : ifp_succ_n.fr.num < ifp_n.fr.num := stream_succ_nth_fr_num_lt_nth_fr_num_rat stream_nth_eq stream_succ_nth_eq
have : ifp_succ_n.fr.num + 1 ≤ ifp_n.fr.num := Int.add_one_le_of_lt this
exact le_trans this (IH stream_nth_eq)
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
⊢ ∀ {ifp_n : IntFractPair ℚ},
IntFractPair.stream q (Nat.succ n) = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑(Nat.succ n)
[PROOFSTEP]
intro ifp_succ_n stream_succ_nth_eq
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
ifp_succ_n : IntFractPair ℚ
stream_succ_nth_eq : IntFractPair.stream q (Nat.succ n) = some ifp_succ_n
⊢ ifp_succ_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑(Nat.succ n)
[PROOFSTEP]
suffices ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - n
by
rw [Int.ofNat_succ, sub_add_eq_sub_sub]
solve_by_elim [le_sub_right_of_add_le]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
ifp_succ_n : IntFractPair ℚ
stream_succ_nth_eq : IntFractPair.stream q (Nat.succ n) = some ifp_succ_n
this : ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - ↑n
⊢ ifp_succ_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑(Nat.succ n)
[PROOFSTEP]
rw [Int.ofNat_succ, sub_add_eq_sub_sub]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
ifp_succ_n : IntFractPair ℚ
stream_succ_nth_eq : IntFractPair.stream q (Nat.succ n) = some ifp_succ_n
this : ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - ↑n
⊢ ifp_succ_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n - 1
[PROOFSTEP]
solve_by_elim [le_sub_right_of_add_le]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
ifp_succ_n : IntFractPair ℚ
stream_succ_nth_eq : IntFractPair.stream q (Nat.succ n) = some ifp_succ_n
⊢ ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - ↑n
[PROOFSTEP]
rcases succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq with ⟨ifp_n, stream_nth_eq, -⟩
[GOAL]
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
ifp_succ_n : IntFractPair ℚ
stream_succ_nth_eq : IntFractPair.stream q (Nat.succ n) = some ifp_succ_n
ifp_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
⊢ ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - ↑n
[PROOFSTEP]
have : ifp_succ_n.fr.num < ifp_n.fr.num := stream_succ_nth_fr_num_lt_nth_fr_num_rat stream_nth_eq stream_succ_nth_eq
[GOAL]
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
ifp_succ_n : IntFractPair ℚ
stream_succ_nth_eq : IntFractPair.stream q (Nat.succ n) = some ifp_succ_n
ifp_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
this : ifp_succ_n.fr.num < ifp_n.fr.num
⊢ ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - ↑n
[PROOFSTEP]
have : ifp_succ_n.fr.num + 1 ≤ ifp_n.fr.num := Int.add_one_le_of_lt this
[GOAL]
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q : ℚ
n✝ n : ℕ
IH : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - ↑n
ifp_succ_n : IntFractPair ℚ
stream_succ_nth_eq : IntFractPair.stream q (Nat.succ n) = some ifp_succ_n
ifp_n : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp_n
this✝ : ifp_succ_n.fr.num < ifp_n.fr.num
this : ifp_succ_n.fr.num + 1 ≤ ifp_n.fr.num
⊢ ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - ↑n
[PROOFSTEP]
exact le_trans this (IH stream_nth_eq)
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n : ℕ
q : ℚ
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
let fract_q_num := (Int.fract q).num
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
let n := fract_q_num.natAbs + 1
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
cases' stream_nth_eq : IntFractPair.stream q n with ifp
[GOAL]
case none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
stream_nth_eq : IntFractPair.stream q n = none
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
use n, stream_nth_eq
[GOAL]
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
ifp : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
have ifp_fr_num_le_q_fr_num_sub_n : ifp.fr.num ≤ fract_q_num - n := stream_nth_fr_num_le_fr_num_sub_n_rat stream_nth_eq
[GOAL]
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
ifp : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp
ifp_fr_num_le_q_fr_num_sub_n : ifp.fr.num ≤ fract_q_num - ↑n
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
have : fract_q_num - n = -1 :=
by
have : 0 ≤ fract_q_num :=
Rat.num_nonneg_iff_zero_le.mpr
(Int.fract_nonneg q)
-- Porting note: was
-- simp [Int.natAbs_of_nonneg this, sub_add_eq_sub_sub_swap, sub_right_comm]
simp only [Nat.cast_add, Int.natAbs_of_nonneg this, Nat.cast_one, sub_add_eq_sub_sub_swap, sub_right_comm, sub_self,
zero_sub]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
ifp : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp
ifp_fr_num_le_q_fr_num_sub_n : ifp.fr.num ≤ fract_q_num - ↑n
⊢ fract_q_num - ↑n = -1
[PROOFSTEP]
have : 0 ≤ fract_q_num :=
Rat.num_nonneg_iff_zero_le.mpr
(Int.fract_nonneg q)
-- Porting note: was
-- simp [Int.natAbs_of_nonneg this, sub_add_eq_sub_sub_swap, sub_right_comm]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
ifp : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp
ifp_fr_num_le_q_fr_num_sub_n : ifp.fr.num ≤ fract_q_num - ↑n
this : 0 ≤ fract_q_num
⊢ fract_q_num - ↑n = -1
[PROOFSTEP]
simp only [Nat.cast_add, Int.natAbs_of_nonneg this, Nat.cast_one, sub_add_eq_sub_sub_swap, sub_right_comm, sub_self,
zero_sub]
[GOAL]
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
ifp : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp
ifp_fr_num_le_q_fr_num_sub_n : ifp.fr.num ≤ fract_q_num - ↑n
this : fract_q_num - ↑n = -1
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
have : 0 ≤ ifp.fr := (nth_stream_fr_nonneg_lt_one stream_nth_eq).left
[GOAL]
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
ifp : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp
ifp_fr_num_le_q_fr_num_sub_n : ifp.fr.num ≤ fract_q_num - ↑n
this✝ : fract_q_num - ↑n = -1
this : 0 ≤ ifp.fr
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
have : 0 ≤ ifp.fr.num := Rat.num_nonneg_iff_zero_le.mpr this
[GOAL]
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
q✝ : ℚ
n✝ : ℕ
q : ℚ
fract_q_num : ℤ := (Int.fract q).num
n : ℕ := Int.natAbs fract_q_num + 1
ifp : IntFractPair ℚ
stream_nth_eq : IntFractPair.stream q n = some ifp
ifp_fr_num_le_q_fr_num_sub_n : ifp.fr.num ≤ fract_q_num - ↑n
this✝¹ : fract_q_num - ↑n = -1
this✝ : 0 ≤ ifp.fr
this : 0 ≤ ifp.fr.num
⊢ ∃ n, IntFractPair.stream q n = none
[PROOFSTEP]
linarith
|
[GOAL]
x : ℚ
⊢ 0 ≤ x ↔ x ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
[PROOFSTEP]
refine'
⟨fun hx => _, fun hx =>
AddSubmonoid.closure_induction hx (by rintro - ⟨s, rfl⟩; exact mul_self_nonneg s) le_rfl fun _ _ => add_nonneg⟩
/- If `x = p / q`, then, since `0 ≤ x`, we have `p q : ℕ`, and `p / q` is the sum of `p * q`
copies of `(1 / q) ^ 2`, and so `x` lies in the `AddSubmonoid` generated by square elements.
Note: it's possible to rephrase this argument as `x = (p * q) • (1 / q) ^ 2`, but this would
be somewhat challenging without increasing import requirements. -/
-- Porting note: rewrote proof to avoid removed constructor rat.mk_pnat
[GOAL]
x : ℚ
hx : x ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
⊢ ∀ (x : ℚ), (x ∈ Set.range fun s => star s * s) → 0 ≤ x
[PROOFSTEP]
rintro - ⟨s, rfl⟩
[GOAL]
case intro
x : ℚ
hx : x ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
s : ℚ
⊢ 0 ≤ (fun s => star s * s) s
[PROOFSTEP]
exact mul_self_nonneg s
[GOAL]
x : ℚ
hx : 0 ≤ x
⊢ x ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
[PROOFSTEP]
suffices (Finset.range (x.num.natAbs * x.den)).sum (Function.const ℕ ((1 : ℚ) / x.den * ((1 : ℚ) / x.den))) = x by
exact this ▸ sum_mem fun n _ => AddSubmonoid.subset_closure ⟨_, rfl⟩
[GOAL]
x : ℚ
hx : 0 ≤ x
this : Finset.sum (Finset.range (Int.natAbs x.num * x.den)) (Function.const ℕ (1 / ↑x.den * (1 / ↑x.den))) = x
⊢ x ∈ AddSubmonoid.closure (Set.range fun s => star s * s)
[PROOFSTEP]
exact this ▸ sum_mem fun n _ => AddSubmonoid.subset_closure ⟨_, rfl⟩
[GOAL]
x : ℚ
hx : 0 ≤ x
⊢ Finset.sum (Finset.range (Int.natAbs x.num * x.den)) (Function.const ℕ (1 / ↑x.den * (1 / ↑x.den))) = x
[PROOFSTEP]
simp only [Function.const_apply, Finset.sum_const, Finset.card_range, nsmul_eq_mul]
[GOAL]
x : ℚ
hx : 0 ≤ x
⊢ ↑(Int.natAbs x.num * x.den) * (1 / ↑x.den * (1 / ↑x.den)) = x
[PROOFSTEP]
rw [← Int.cast_ofNat, Int.ofNat_mul, Int.coe_natAbs, abs_of_nonneg (num_nonneg_iff_zero_le.mpr hx), Int.cast_mul,
Int.cast_ofNat]
[GOAL]
x : ℚ
hx : 0 ≤ x
⊢ ↑x.num * ↑x.den * (1 / ↑x.den * (1 / ↑x.den)) = x
[PROOFSTEP]
rw [← mul_assoc, mul_assoc (x.num : ℚ), mul_one_div_cancel (Nat.cast_ne_zero.mpr x.pos.ne'), mul_one, mul_one_div,
Rat.num_div_den]
|
---
author: Nathan Carter ([email protected])
---
This answer assumes you have imported SymPy as follows.
```python
from sympy import * # load all math functions
init_printing( use_latex='mathjax' ) # use pretty math output
```
In SymPy, we tend to work with formulas (that is, mathematical expressions)
rather than functions (like $f(x)$). So if we wish to compute the
derivative of $f(x)=10x^2-16x+1$, we will focus on just the $10x^2-16x+1$ portion.
```python
var( 'x' )
formula = 10*x**2 - 16*x + 1
formula
```
$\displaystyle 10 x^{2} - 16 x + 1$
We can compute its derivative by using the `diff` function.
```python
diff( formula )
```
$\displaystyle 20 x - 16$
If it had been a multi-variable function, we would need to specify the
variable with respect to which we wanted to compute a derivative.
```python
var( 'y' ) # introduce a new variable
formula2 = x**2 - y**2 # consider the formula x^2 + y^2
diff( formula2, y ) # differentiate with respect to y
```
$\displaystyle - 2 y$
We can compute second or third derivatives by repeating the variable
with respect to which we're differentiating. To do partial derivatives,
use multiple variables.
```python
diff( formula, x, x ) # second derivative with respect to x
```
$\displaystyle 20$
```python
diff( formula2, x, y ) # mixed partial derivative
```
$\displaystyle 0$
|
/-
Copyright (c) 2015 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis
Ported by: Joël Riou
! This file was ported from Lean 3 source module algebra.group_power.ring
! leanprover-community/mathlib commit fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Algebra.GroupPower.Basic
import Mathlib.Algebra.GroupWithZero.Commute
import Mathlib.Algebra.Hom.Ring
import Mathlib.Algebra.Ring.Commute
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.Ring.Divisibility
import Mathlib.Data.Nat.Order.Basic
/-!
# Power operations on monoids with zero, semirings, and rings
This file provides additional lemmas about the natural power operator on rings and semirings.
Further lemmas about ordered semirings and rings can be found in `Algebra.GroupPower.Lemmas`.
-/
variable {R S M : Type _}
section MonoidWithZero
variable [MonoidWithZero M]
theorem zero_pow : ∀ {n : ℕ}, 0 < n → (0 : M) ^ n = 0
| n + 1, _ => by rw [pow_succ, zero_mul]
#align zero_pow zero_pow
@[simp]
theorem zero_pow' : ∀ n : ℕ, n ≠ 0 → (0 : M) ^ n = 0
| 0, h => absurd rfl h
| k + 1, _ => by
rw [pow_succ]
exact zero_mul _
#align zero_pow' zero_pow'
theorem zero_pow_eq (n : ℕ) : (0 : M) ^ n = if n = 0 then 1 else 0 := by
split_ifs with h
· rw [h, pow_zero]
· rw [zero_pow (Nat.pos_of_ne_zero h)]
#align zero_pow_eq zero_pow_eq
theorem pow_eq_zero_of_le {x : M} {n m : ℕ} (hn : n ≤ m) (hx : x ^ n = 0) : x ^ m = 0 := by
rw [← tsub_add_cancel_of_le hn, pow_add, hx, mul_zero]
#align pow_eq_zero_of_le pow_eq_zero_of_le
theorem pow_eq_zero [NoZeroDivisors M] {x : M} {n : ℕ} (H : x ^ n = 0) : x = 0 := by
induction' n with n ih
· rw [pow_zero] at H
rw [← mul_one x, H, mul_zero]
· rw [pow_succ] at H
exact Or.casesOn (mul_eq_zero.1 H) id ih
#align pow_eq_zero pow_eq_zero
@[simp]
theorem pow_eq_zero_iff [NoZeroDivisors M] {a : M} {n : ℕ} (hn : 0 < n) : a ^ n = 0 ↔ a = 0 := by
refine' ⟨pow_eq_zero, _⟩
rintro rfl
exact zero_pow hn
#align pow_eq_zero_iff pow_eq_zero_iff
theorem pow_eq_zero_iff' [NoZeroDivisors M] [Nontrivial M] {a : M} {n : ℕ} :
a ^ n = 0 ↔ a = 0 ∧ n ≠ 0 := by cases (zero_le n).eq_or_gt <;> simp [*, ne_of_gt]
#align pow_eq_zero_iff' pow_eq_zero_iff'
theorem pow_ne_zero_iff [NoZeroDivisors M] {a : M} {n : ℕ} (hn : 0 < n) : a ^ n ≠ 0 ↔ a ≠ 0 :=
(pow_eq_zero_iff hn).not
#align pow_ne_zero_iff pow_ne_zero_iff
theorem ne_zero_pow {a : M} {n : ℕ} (hn : n ≠ 0) : a ^ n ≠ 0 → a ≠ 0 := by
contrapose!
rintro rfl
exact zero_pow' n hn
#align ne_zero_pow ne_zero_pow
@[field_simps]
theorem pow_ne_zero [NoZeroDivisors M] {a : M} (n : ℕ) (h : a ≠ 0) : a ^ n ≠ 0 :=
mt pow_eq_zero h
#align pow_ne_zero pow_ne_zero
instance NeZero.pow [NoZeroDivisors M] {x : M} [NeZero x] {n : ℕ} : NeZero (x ^ n) :=
⟨pow_ne_zero n NeZero.out⟩
#align ne_zero.pow NeZero.pow
theorem sq_eq_zero_iff [NoZeroDivisors M] {a : M} : a ^ 2 = 0 ↔ a = 0 :=
pow_eq_zero_iff two_pos
#align sq_eq_zero_iff sq_eq_zero_iff
@[simp]
theorem zero_pow_eq_zero [Nontrivial M] {n : ℕ} : (0 : M) ^ n = 0 ↔ 0 < n := by
constructor <;> intro h
· rw [pos_iff_ne_zero]
rintro rfl
simp at h
· exact zero_pow' n h.ne.symm
#align zero_pow_eq_zero zero_pow_eq_zero
theorem Ring.inverse_pow (r : M) : ∀ n : ℕ, Ring.inverse r ^ n = Ring.inverse (r ^ n)
| 0 => by rw [pow_zero, pow_zero, Ring.inverse_one]
| n + 1 => by
rw [pow_succ, pow_succ', Ring.mul_inverse_rev' ((Commute.refl r).pow_left n),
Ring.inverse_pow r n]
#align ring.inverse_pow Ring.inverse_pow
end MonoidWithZero
section CommMonoidWithZero
variable [CommMonoidWithZero M] {n : ℕ} (hn : 0 < n)
/-- We define `x ↦ x^n` (for positive `n : ℕ`) as a `MonoidWithZeroHom` -/
def powMonoidWithZeroHom : M →*₀ M :=
{ powMonoidHom n with map_zero' := zero_pow hn }
#align pow_monoid_with_zero_hom powMonoidWithZeroHom
@[simp]
theorem coe_powMonoidWithZeroHom : (powMonoidWithZeroHom hn : M → M) = fun x ↦ (x^n : M) := rfl
#align coe_pow_monoid_with_zero_hom coe_powMonoidWithZeroHom
@[simp]
theorem powMonoidWithZeroHom_apply (a : M) : powMonoidWithZeroHom hn a = a ^ n :=
rfl
#align pow_monoid_with_zero_hom_apply powMonoidWithZeroHom_apply
end CommMonoidWithZero
theorem pow_dvd_pow_iff [CancelCommMonoidWithZero R] {x : R} {n m : ℕ} (h0 : x ≠ 0)
(h1 : ¬IsUnit x) : x ^ n ∣ x ^ m ↔ n ≤ m := by
constructor
· intro h
rw [← not_lt]
intro hmn
apply h1
have : x ^ m * x ∣ x ^ m * 1 := by
rw [← pow_succ', mul_one]
exact (pow_dvd_pow _ (Nat.succ_le_of_lt hmn)).trans h
rwa [mul_dvd_mul_iff_left, ← isUnit_iff_dvd_one] at this
apply pow_ne_zero m h0
· apply pow_dvd_pow
#align pow_dvd_pow_iff pow_dvd_pow_iff
section Semiring
variable [Semiring R] [Semiring S]
protected theorem RingHom.map_pow (f : R →+* S) (a) : ∀ n : ℕ, f (a ^ n) = f a ^ n :=
map_pow f a
#align ring_hom.map_pow RingHom.map_pow
theorem min_pow_dvd_add {n m : ℕ} {a b c : R} (ha : c ^ n ∣ a) (hb : c ^ m ∣ b) :
c ^ min n m ∣ a + b := by
replace ha := (pow_dvd_pow c (min_le_left n m)).trans ha
replace hb := (pow_dvd_pow c (min_le_right n m)).trans hb
exact dvd_add ha hb
#align min_pow_dvd_add min_pow_dvd_add
end Semiring
section CommSemiring
variable [CommSemiring R]
theorem add_sq (a b : R) : (a + b) ^ 2 = a ^ 2 + 2 * a * b + b ^ 2 := by
simp only [sq, add_mul_self_eq]
#align add_sq add_sq
theorem add_sq' (a b : R) : (a + b) ^ 2 = a ^ 2 + b ^ 2 + 2 * a * b := by
rw [add_sq, add_assoc, add_comm _ (b ^ 2), add_assoc]
#align add_sq' add_sq'
alias add_sq ← add_pow_two
#align add_pow_two add_pow_two
end CommSemiring
section HasDistribNeg
variable [Monoid R] [HasDistribNeg R]
variable (R)
theorem neg_one_pow_eq_or : ∀ n : ℕ, (-1 : R) ^ n = 1 ∨ (-1 : R) ^ n = -1
| 0 => Or.inl (pow_zero _)
| n + 1 => (neg_one_pow_eq_or n).symm.imp
(fun h ↦ by rw [pow_succ, h, neg_one_mul, neg_neg])
(fun h ↦ by rw [pow_succ, h, mul_one])
#align neg_one_pow_eq_or neg_one_pow_eq_or
variable {R}
theorem neg_pow (a : R) (n : ℕ) : (-a) ^ n = (-1) ^ n * a ^ n :=
neg_one_mul a ▸ (Commute.neg_one_left a).mul_pow n
#align neg_pow neg_pow
section
set_option linter.deprecated false
@[simp]
theorem neg_pow_bit0 (a : R) (n : ℕ) : (-a) ^ bit0 n = a ^ bit0 n := by
rw [pow_bit0', neg_mul_neg, pow_bit0']
#align neg_pow_bit0 neg_pow_bit0
@[simp]
theorem neg_pow_bit1 (a : R) (n : ℕ) : (-a) ^ bit1 n = -a ^ bit1 n := by
simp only [bit1, pow_succ, neg_pow_bit0, neg_mul_eq_neg_mul]
#align neg_pow_bit1 neg_pow_bit1
end
@[simp]
theorem neg_sq (a : R) : (-a) ^ 2 = a ^ 2 := by simp [sq]
#align neg_sq neg_sq
-- Porting note: removed the simp attribute to please the simpNF linter
theorem neg_one_sq : (-1 : R) ^ 2 = 1 := by simp [neg_sq, one_pow]
#align neg_one_sq neg_one_sq
alias neg_sq ← neg_pow_two
#align neg_pow_two neg_pow_two
alias neg_one_sq ← neg_one_pow_two
#align neg_one_pow_two neg_one_pow_two
end HasDistribNeg
section Ring
variable [Ring R] {a b : R}
protected theorem Commute.sq_sub_sq (h : Commute a b) : a ^ 2 - b ^ 2 = (a + b) * (a - b) := by
rw [sq, sq, h.mul_self_sub_mul_self_eq]
#align commute.sq_sub_sq Commute.sq_sub_sq
@[simp]
theorem neg_one_pow_mul_eq_zero_iff {n : ℕ} {r : R} : (-1) ^ n * r = 0 ↔ r = 0 := by
rcases neg_one_pow_eq_or R n with h | h <;> simp [h]
#align neg_one_pow_mul_eq_zero_iff neg_one_pow_mul_eq_zero_iff
@[simp]
theorem mul_neg_one_pow_eq_zero_iff {n : ℕ} {r : R} : r * (-1) ^ n = 0 ↔ r = 0 := by
rcases neg_one_pow_eq_or R n with h | h <;> simp [h]
#align mul_neg_one_pow_eq_zero_iff mul_neg_one_pow_eq_zero_iff
variable [NoZeroDivisors R]
protected theorem Commute.sq_eq_sq_iff_eq_or_eq_neg (h : Commute a b) :
a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b := by
rw [← sub_eq_zero, h.sq_sub_sq, mul_eq_zero, add_eq_zero_iff_eq_neg, sub_eq_zero, or_comm]
#align commute.sq_eq_sq_iff_eq_or_eq_neg Commute.sq_eq_sq_iff_eq_or_eq_neg
@[simp]
theorem sq_eq_one_iff : a ^ 2 = 1 ↔ a = 1 ∨ a = -1 := by
rw [← (Commute.one_right a).sq_eq_sq_iff_eq_or_eq_neg, one_pow]
#align sq_eq_one_iff sq_eq_one_iff
theorem sq_ne_one_iff : a ^ 2 ≠ 1 ↔ a ≠ 1 ∧ a ≠ -1 :=
sq_eq_one_iff.not.trans not_or
#align sq_ne_one_iff sq_ne_one_iff
end Ring
section CommRing
variable [CommRing R]
theorem sq_sub_sq (a b : R) : a ^ 2 - b ^ 2 = (a + b) * (a - b) :=
(Commute.all a b).sq_sub_sq
#align sq_sub_sq sq_sub_sq
alias sq_sub_sq ← pow_two_sub_pow_two
#align pow_two_sub_pow_two pow_two_sub_pow_two
theorem sub_sq (a b : R) : (a - b) ^ 2 = a ^ 2 - 2 * a * b + b ^ 2 := by
rw [sub_eq_add_neg, add_sq, neg_sq, mul_neg, ← sub_eq_add_neg]
#align sub_sq sub_sq
alias sub_sq ← sub_pow_two
#align sub_pow_two sub_pow_two
theorem sub_sq' (a b : R) : (a - b) ^ 2 = a ^ 2 + b ^ 2 - 2 * a * b := by
rw [sub_eq_add_neg, add_sq', neg_sq, mul_neg, ← sub_eq_add_neg]
#align sub_sq' sub_sq'
variable [NoZeroDivisors R] {a b : R}
theorem sq_eq_sq_iff_eq_or_eq_neg : a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b :=
(Commute.all a b).sq_eq_sq_iff_eq_or_eq_neg
#align sq_eq_sq_iff_eq_or_eq_neg sq_eq_sq_iff_eq_or_eq_neg
theorem eq_or_eq_neg_of_sq_eq_sq (a b : R) : a ^ 2 = b ^ 2 → a = b ∨ a = -b :=
sq_eq_sq_iff_eq_or_eq_neg.1
#align eq_or_eq_neg_of_sq_eq_sq eq_or_eq_neg_of_sq_eq_sq
-- Copies of the above CommRing lemmas for `Units R`.
namespace Units
protected theorem sq_eq_sq_iff_eq_or_eq_neg {a b : Rˣ} : a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b := by
simp_rw [ext_iff, val_pow_eq_pow_val, sq_eq_sq_iff_eq_or_eq_neg, Units.val_neg]
#align units.sq_eq_sq_iff_eq_or_eq_neg Units.sq_eq_sq_iff_eq_or_eq_neg
protected theorem eq_or_eq_neg_of_sq_eq_sq (a b : Rˣ) (h : a ^ 2 = b ^ 2) : a = b ∨ a = -b :=
Units.sq_eq_sq_iff_eq_or_eq_neg.1 h
#align units.eq_or_eq_neg_of_sq_eq_sq Units.eq_or_eq_neg_of_sq_eq_sq
end Units
end CommRing
|
lemma primitive_part_fract_0 [simp]: "primitive_part_fract 0 = 0" |
{-# OPTIONS --without-K --exact-split --safe #-}
module 06-universes where
import 05-identity-types
open 05-identity-types public
--------------------------------------------------------------------------------
-- Section 6.3 Observational equality on the natural numbers
-- Definition 6.3.1
Eq-ℕ : ℕ → ℕ → UU lzero
Eq-ℕ zero-ℕ zero-ℕ = 𝟙
Eq-ℕ zero-ℕ (succ-ℕ n) = 𝟘
Eq-ℕ (succ-ℕ m) zero-ℕ = 𝟘
Eq-ℕ (succ-ℕ m) (succ-ℕ n) = Eq-ℕ m n
-- Lemma 6.3.2
refl-Eq-ℕ : (n : ℕ) → Eq-ℕ n n
refl-Eq-ℕ zero-ℕ = star
refl-Eq-ℕ (succ-ℕ n) = refl-Eq-ℕ n
-- Proposition 6.3.3
Eq-ℕ-eq : {x y : ℕ} → Id x y → Eq-ℕ x y
Eq-ℕ-eq {x} {.x} refl = refl-Eq-ℕ x
eq-Eq-ℕ : (x y : ℕ) → Eq-ℕ x y → Id x y
eq-Eq-ℕ zero-ℕ zero-ℕ e = refl
eq-Eq-ℕ (succ-ℕ x) (succ-ℕ y) e = ap succ-ℕ (eq-Eq-ℕ x y e)
--------------------------------------------------------------------------------
-- Section 6.4 Peano's seventh and eighth axioms
-- Theorem 6.4.1
is-injective-succ-ℕ : (x y : ℕ) → Id (succ-ℕ x) (succ-ℕ y) → Id x y
is-injective-succ-ℕ x y e = eq-Eq-ℕ x y (Eq-ℕ-eq e)
Peano-7 :
(x y : ℕ) →
((Id x y) → (Id (succ-ℕ x) (succ-ℕ y))) ×
((Id (succ-ℕ x) (succ-ℕ y)) → (Id x y))
Peano-7 x y = pair (ap succ-ℕ) (is-injective-succ-ℕ x y)
-- Theorem 6.4.2
Peano-8 :
(x : ℕ) → ¬ (Id zero-ℕ (succ-ℕ x))
Peano-8 x p = Eq-ℕ-eq p
--------------------------------------------------------------------------------
-- Exercises
-- Exercise 6.1
-- Exercise 6.1 (a)
is-injective-add-ℕ :
(k m n : ℕ) → Id (add-ℕ m k) (add-ℕ n k) → Id m n
is-injective-add-ℕ zero-ℕ m n = id
is-injective-add-ℕ (succ-ℕ k) m n p =
is-injective-add-ℕ k m n (is-injective-succ-ℕ (add-ℕ m k) (add-ℕ n k) p)
-- Exercise 6.1 (b)
is-injective-mul-ℕ :
(k m n : ℕ) → Id (mul-ℕ m (succ-ℕ k)) (mul-ℕ n (succ-ℕ k)) → Id m n
is-injective-mul-ℕ k zero-ℕ zero-ℕ p = refl
is-injective-mul-ℕ k (succ-ℕ m) (succ-ℕ n) p =
ap succ-ℕ
( is-injective-mul-ℕ k m n
( is-injective-add-ℕ
( succ-ℕ k)
( mul-ℕ m (succ-ℕ k))
( mul-ℕ n (succ-ℕ k))
( ( inv (left-successor-law-mul-ℕ m (succ-ℕ k))) ∙
( ( p) ∙
( left-successor-law-mul-ℕ n (succ-ℕ k))))))
-- Exercise 6.1 (c)
neq-add-ℕ :
(m n : ℕ) → ¬ (Id m (add-ℕ m (succ-ℕ n)))
neq-add-ℕ (succ-ℕ m) n p =
neq-add-ℕ m n
( ( is-injective-succ-ℕ m (add-ℕ (succ-ℕ m) n) p) ∙
( left-successor-law-add-ℕ m n))
-- Exercise 6.1 (d)
neq-mul-ℕ :
(m n : ℕ) → ¬ (Id (succ-ℕ m) (mul-ℕ (succ-ℕ m) (succ-ℕ (succ-ℕ n))))
neq-mul-ℕ m n p =
neq-add-ℕ
( succ-ℕ m)
( add-ℕ (mul-ℕ m (succ-ℕ n)) n)
( ( p) ∙
( ( right-successor-law-mul-ℕ (succ-ℕ m) (succ-ℕ n)) ∙
( ap (add-ℕ (succ-ℕ m)) (left-successor-law-mul-ℕ m (succ-ℕ n)))))
-- Exercise 6.2
-- Exercise 6.2 (a)
Eq-𝟚 : bool → bool → UU lzero
Eq-𝟚 true true = unit
Eq-𝟚 true false = empty
Eq-𝟚 false true = empty
Eq-𝟚 false false = unit
-- Exercise 6.2 (b)
reflexive-Eq-𝟚 : (x : bool) → Eq-𝟚 x x
reflexive-Eq-𝟚 true = star
reflexive-Eq-𝟚 false = star
Eq-eq-𝟚 :
{x y : bool} → Id x y → Eq-𝟚 x y
Eq-eq-𝟚 {x = x} refl = reflexive-Eq-𝟚 x
eq-Eq-𝟚 :
{x y : bool} → Eq-𝟚 x y → Id x y
eq-Eq-𝟚 {true} {true} star = refl
eq-Eq-𝟚 {false} {false} star = refl
-- Exercise 6.2 (c)
neq-neg-𝟚 : (b : bool) → ¬ (Id b (neg-𝟚 b))
neq-neg-𝟚 true = Eq-eq-𝟚
neq-neg-𝟚 false = Eq-eq-𝟚
neq-false-true-𝟚 :
¬ (Id false true)
neq-false-true-𝟚 = Eq-eq-𝟚
-- Exercise 6.3
-- Exercise 6.3 (a)
leq-ℕ : ℕ → ℕ → UU lzero
leq-ℕ zero-ℕ m = unit
leq-ℕ (succ-ℕ n) zero-ℕ = empty
leq-ℕ (succ-ℕ n) (succ-ℕ m) = leq-ℕ n m
_≤_ = leq-ℕ
-- Some trivialities that will be useful later
leq-zero-ℕ :
(n : ℕ) → leq-ℕ zero-ℕ n
leq-zero-ℕ n = star
eq-leq-zero-ℕ :
(x : ℕ) → leq-ℕ x zero-ℕ → Id zero-ℕ x
eq-leq-zero-ℕ zero-ℕ star = refl
succ-leq-ℕ : (n : ℕ) → leq-ℕ n (succ-ℕ n)
succ-leq-ℕ zero-ℕ = star
succ-leq-ℕ (succ-ℕ n) = succ-leq-ℕ n
concatenate-eq-leq-eq-ℕ :
{x1 x2 x3 x4 : ℕ} → Id x1 x2 → leq-ℕ x2 x3 → Id x3 x4 → leq-ℕ x1 x4
concatenate-eq-leq-eq-ℕ refl H refl = H
concatenate-leq-eq-ℕ :
(m : ℕ) {n n' : ℕ} → leq-ℕ m n → Id n n' → leq-ℕ m n'
concatenate-leq-eq-ℕ m H refl = H
concatenate-eq-leq-ℕ :
{m m' : ℕ} (n : ℕ) → Id m' m → leq-ℕ m n → leq-ℕ m' n
concatenate-eq-leq-ℕ n refl H = H
-- Exercise 6.3 (b)
reflexive-leq-ℕ : (n : ℕ) → leq-ℕ n n
reflexive-leq-ℕ zero-ℕ = star
reflexive-leq-ℕ (succ-ℕ n) = reflexive-leq-ℕ n
leq-eq-ℕ : (m n : ℕ) → Id m n → leq-ℕ m n
leq-eq-ℕ m .m refl = reflexive-leq-ℕ m
transitive-leq-ℕ :
(n m l : ℕ) → (n ≤ m) → (m ≤ l) → (n ≤ l)
transitive-leq-ℕ zero-ℕ m l p q = star
transitive-leq-ℕ (succ-ℕ n) (succ-ℕ m) (succ-ℕ l) p q =
transitive-leq-ℕ n m l p q
preserves-leq-succ-ℕ :
(m n : ℕ) → leq-ℕ m n → leq-ℕ m (succ-ℕ n)
preserves-leq-succ-ℕ m n p = transitive-leq-ℕ m n (succ-ℕ n) p (succ-leq-ℕ n)
anti-symmetric-leq-ℕ : (m n : ℕ) → leq-ℕ m n → leq-ℕ n m → Id m n
anti-symmetric-leq-ℕ zero-ℕ zero-ℕ p q = refl
anti-symmetric-leq-ℕ (succ-ℕ m) (succ-ℕ n) p q =
ap succ-ℕ (anti-symmetric-leq-ℕ m n p q)
-- Exercise 6.3 (c)
decide-leq-ℕ :
(m n : ℕ) → coprod (leq-ℕ m n) (leq-ℕ n m)
decide-leq-ℕ zero-ℕ zero-ℕ = inl star
decide-leq-ℕ zero-ℕ (succ-ℕ n) = inl star
decide-leq-ℕ (succ-ℕ m) zero-ℕ = inr star
decide-leq-ℕ (succ-ℕ m) (succ-ℕ n) = decide-leq-ℕ m n
-- Exercise 6.3 (d)
preserves-order-add-ℕ :
(k m n : ℕ) → leq-ℕ m n → leq-ℕ (add-ℕ m k) (add-ℕ n k)
preserves-order-add-ℕ zero-ℕ m n = id
preserves-order-add-ℕ (succ-ℕ k) m n = preserves-order-add-ℕ k m n
reflects-order-add-ℕ :
(k m n : ℕ) → leq-ℕ (add-ℕ m k) (add-ℕ n k) → leq-ℕ m n
reflects-order-add-ℕ zero-ℕ m n = id
reflects-order-add-ℕ (succ-ℕ k) m n = reflects-order-add-ℕ k m n
-- Exercise 6.3 (e)
preserves-order-mul-ℕ :
(k m n : ℕ) → leq-ℕ m n → leq-ℕ (mul-ℕ m k) (mul-ℕ n k)
preserves-order-mul-ℕ k zero-ℕ n p = star
preserves-order-mul-ℕ k (succ-ℕ m) (succ-ℕ n) p =
preserves-order-add-ℕ k
( mul-ℕ m k)
( mul-ℕ n k)
( preserves-order-mul-ℕ k m n p)
reflects-order-mul-ℕ :
(k m n : ℕ) → leq-ℕ (mul-ℕ m (succ-ℕ k)) (mul-ℕ n (succ-ℕ k)) → leq-ℕ m n
reflects-order-mul-ℕ k zero-ℕ n p = star
reflects-order-mul-ℕ k (succ-ℕ m) (succ-ℕ n) p =
reflects-order-mul-ℕ k m n
( reflects-order-add-ℕ
( succ-ℕ k)
( mul-ℕ m (succ-ℕ k))
( mul-ℕ n (succ-ℕ k))
( p))
-- Exercise 6.3 (f)
leq-min-ℕ :
(k m n : ℕ) → leq-ℕ k m → leq-ℕ k n → leq-ℕ k (min-ℕ m n)
leq-min-ℕ zero-ℕ zero-ℕ zero-ℕ H K = star
leq-min-ℕ zero-ℕ zero-ℕ (succ-ℕ n) H K = star
leq-min-ℕ zero-ℕ (succ-ℕ m) zero-ℕ H K = star
leq-min-ℕ zero-ℕ (succ-ℕ m) (succ-ℕ n) H K = star
leq-min-ℕ (succ-ℕ k) (succ-ℕ m) (succ-ℕ n) H K = leq-min-ℕ k m n H K
leq-left-leq-min-ℕ :
(k m n : ℕ) → leq-ℕ k (min-ℕ m n) → leq-ℕ k m
leq-left-leq-min-ℕ zero-ℕ zero-ℕ zero-ℕ H = star
leq-left-leq-min-ℕ zero-ℕ zero-ℕ (succ-ℕ n) H = star
leq-left-leq-min-ℕ zero-ℕ (succ-ℕ m) zero-ℕ H = star
leq-left-leq-min-ℕ zero-ℕ (succ-ℕ m) (succ-ℕ n) H = star
leq-left-leq-min-ℕ (succ-ℕ k) (succ-ℕ m) (succ-ℕ n) H =
leq-left-leq-min-ℕ k m n H
leq-right-leq-min-ℕ :
(k m n : ℕ) → leq-ℕ k (min-ℕ m n) → leq-ℕ k n
leq-right-leq-min-ℕ zero-ℕ zero-ℕ zero-ℕ H = star
leq-right-leq-min-ℕ zero-ℕ zero-ℕ (succ-ℕ n) H = star
leq-right-leq-min-ℕ zero-ℕ (succ-ℕ m) zero-ℕ H = star
leq-right-leq-min-ℕ zero-ℕ (succ-ℕ m) (succ-ℕ n) H = star
leq-right-leq-min-ℕ (succ-ℕ k) (succ-ℕ m) (succ-ℕ n) H =
leq-right-leq-min-ℕ k m n H
leq-max-ℕ :
(k m n : ℕ) → leq-ℕ m k → leq-ℕ n k → leq-ℕ (max-ℕ m n) k
leq-max-ℕ zero-ℕ zero-ℕ zero-ℕ H K = star
leq-max-ℕ (succ-ℕ k) zero-ℕ zero-ℕ H K = star
leq-max-ℕ (succ-ℕ k) zero-ℕ (succ-ℕ n) H K = K
leq-max-ℕ (succ-ℕ k) (succ-ℕ m) zero-ℕ H K = H
leq-max-ℕ (succ-ℕ k) (succ-ℕ m) (succ-ℕ n) H K = leq-max-ℕ k m n H K
leq-left-leq-max-ℕ :
(k m n : ℕ) → leq-ℕ (max-ℕ m n) k → leq-ℕ m k
leq-left-leq-max-ℕ k zero-ℕ zero-ℕ H = star
leq-left-leq-max-ℕ k zero-ℕ (succ-ℕ n) H = star
leq-left-leq-max-ℕ k (succ-ℕ m) zero-ℕ H = H
leq-left-leq-max-ℕ (succ-ℕ k) (succ-ℕ m) (succ-ℕ n) H =
leq-left-leq-max-ℕ k m n H
leq-right-leq-max-ℕ :
(k m n : ℕ) → leq-ℕ (max-ℕ m n) k → leq-ℕ n k
leq-right-leq-max-ℕ k zero-ℕ zero-ℕ H = star
leq-right-leq-max-ℕ k zero-ℕ (succ-ℕ n) H = H
leq-right-leq-max-ℕ k (succ-ℕ m) zero-ℕ H = star
leq-right-leq-max-ℕ (succ-ℕ k) (succ-ℕ m) (succ-ℕ n) H =
leq-right-leq-max-ℕ k m n H
-- Exercise 6.4
-- Exercise 6.4 (a)
-- We define a distance function on ℕ --
dist-ℕ : ℕ → ℕ → ℕ
dist-ℕ zero-ℕ n = n
dist-ℕ (succ-ℕ m) zero-ℕ = succ-ℕ m
dist-ℕ (succ-ℕ m) (succ-ℕ n) = dist-ℕ m n
dist-ℕ' : ℕ → ℕ → ℕ
dist-ℕ' m n = dist-ℕ n m
ap-dist-ℕ :
{m n m' n' : ℕ} → Id m m' → Id n n' → Id (dist-ℕ m n) (dist-ℕ m' n')
ap-dist-ℕ refl refl = refl
{- We show that two natural numbers are equal if and only if their distance is
zero. -}
eq-dist-ℕ :
(m n : ℕ) → Id zero-ℕ (dist-ℕ m n) → Id m n
eq-dist-ℕ zero-ℕ zero-ℕ p = refl
eq-dist-ℕ (succ-ℕ m) (succ-ℕ n) p = ap succ-ℕ (eq-dist-ℕ m n p)
dist-eq-ℕ' :
(n : ℕ) → Id zero-ℕ (dist-ℕ n n)
dist-eq-ℕ' zero-ℕ = refl
dist-eq-ℕ' (succ-ℕ n) = dist-eq-ℕ' n
dist-eq-ℕ :
(m n : ℕ) → Id m n → Id zero-ℕ (dist-ℕ m n)
dist-eq-ℕ m .m refl = dist-eq-ℕ' m
-- The distance function is symmetric --
symmetric-dist-ℕ :
(m n : ℕ) → Id (dist-ℕ m n) (dist-ℕ n m)
symmetric-dist-ℕ zero-ℕ zero-ℕ = refl
symmetric-dist-ℕ zero-ℕ (succ-ℕ n) = refl
symmetric-dist-ℕ (succ-ℕ m) zero-ℕ = refl
symmetric-dist-ℕ (succ-ℕ m) (succ-ℕ n) = symmetric-dist-ℕ m n
-- We compute the distance from zero --
left-zero-law-dist-ℕ :
(n : ℕ) → Id (dist-ℕ zero-ℕ n) n
left-zero-law-dist-ℕ zero-ℕ = refl
left-zero-law-dist-ℕ (succ-ℕ n) = refl
right-zero-law-dist-ℕ :
(n : ℕ) → Id (dist-ℕ n zero-ℕ) n
right-zero-law-dist-ℕ zero-ℕ = refl
right-zero-law-dist-ℕ (succ-ℕ n) = refl
-- We prove the triangle inequality --
ap-add-ℕ :
{m n m' n' : ℕ} → Id m m' → Id n n' → Id (add-ℕ m n) (add-ℕ m' n')
ap-add-ℕ refl refl = refl
triangle-inequality-dist-ℕ :
(m n k : ℕ) → leq-ℕ (dist-ℕ m n) (add-ℕ (dist-ℕ m k) (dist-ℕ k n))
triangle-inequality-dist-ℕ zero-ℕ zero-ℕ zero-ℕ = star
triangle-inequality-dist-ℕ zero-ℕ zero-ℕ (succ-ℕ k) = star
triangle-inequality-dist-ℕ zero-ℕ (succ-ℕ n) zero-ℕ =
tr ( leq-ℕ (succ-ℕ n))
( inv (left-unit-law-add-ℕ (succ-ℕ n)))
( reflexive-leq-ℕ (succ-ℕ n))
triangle-inequality-dist-ℕ zero-ℕ (succ-ℕ n) (succ-ℕ k) =
concatenate-eq-leq-eq-ℕ
( inv (ap succ-ℕ (left-zero-law-dist-ℕ n)))
( triangle-inequality-dist-ℕ zero-ℕ n k)
( ( ap (succ-ℕ ∘ (add-ℕ' (dist-ℕ k n))) (left-zero-law-dist-ℕ k)) ∙
( inv (left-successor-law-add-ℕ k (dist-ℕ k n))))
triangle-inequality-dist-ℕ (succ-ℕ m) zero-ℕ zero-ℕ = reflexive-leq-ℕ (succ-ℕ m)
triangle-inequality-dist-ℕ (succ-ℕ m) zero-ℕ (succ-ℕ k) =
concatenate-eq-leq-eq-ℕ
( inv (ap succ-ℕ (right-zero-law-dist-ℕ m)))
( triangle-inequality-dist-ℕ m zero-ℕ k)
( ap (succ-ℕ ∘ (add-ℕ (dist-ℕ m k))) (right-zero-law-dist-ℕ k))
triangle-inequality-dist-ℕ (succ-ℕ m) (succ-ℕ n) zero-ℕ =
concatenate-leq-eq-ℕ
( dist-ℕ m n)
( transitive-leq-ℕ
( dist-ℕ m n)
( succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)))
( succ-ℕ (succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))))
( transitive-leq-ℕ
( dist-ℕ m n)
( add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))
( succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)))
( triangle-inequality-dist-ℕ m n zero-ℕ)
( succ-leq-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))))
( succ-leq-ℕ (succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)))))
( ( ap (succ-ℕ ∘ succ-ℕ)
( ap-add-ℕ (right-zero-law-dist-ℕ m) (left-zero-law-dist-ℕ n))) ∙
( inv (left-successor-law-add-ℕ m (succ-ℕ n))))
triangle-inequality-dist-ℕ (succ-ℕ m) (succ-ℕ n) (succ-ℕ k) =
triangle-inequality-dist-ℕ m n k
-- We show that dist-ℕ x y is a solution to a simple equation.
leq-dist-ℕ :
(x y : ℕ) → leq-ℕ x y → Id (add-ℕ x (dist-ℕ x y)) y
leq-dist-ℕ zero-ℕ zero-ℕ H = refl
leq-dist-ℕ zero-ℕ (succ-ℕ y) star = left-unit-law-add-ℕ (succ-ℕ y)
leq-dist-ℕ (succ-ℕ x) (succ-ℕ y) H =
( left-successor-law-add-ℕ x (dist-ℕ x y)) ∙
( ap succ-ℕ (leq-dist-ℕ x y H))
rewrite-left-add-dist-ℕ :
(x y z : ℕ) → Id (add-ℕ x y) z → Id x (dist-ℕ y z)
rewrite-left-add-dist-ℕ zero-ℕ zero-ℕ .zero-ℕ refl = refl
rewrite-left-add-dist-ℕ zero-ℕ (succ-ℕ y) .(succ-ℕ (add-ℕ zero-ℕ y)) refl =
( dist-eq-ℕ' y) ∙
( inv (ap (dist-ℕ (succ-ℕ y)) (left-unit-law-add-ℕ (succ-ℕ y))))
rewrite-left-add-dist-ℕ (succ-ℕ x) zero-ℕ .(succ-ℕ x) refl = refl
rewrite-left-add-dist-ℕ
(succ-ℕ x) (succ-ℕ y) .(succ-ℕ (add-ℕ (succ-ℕ x) y)) refl =
rewrite-left-add-dist-ℕ (succ-ℕ x) y (add-ℕ (succ-ℕ x) y) refl
rewrite-left-dist-add-ℕ :
(x y z : ℕ) → leq-ℕ y z → Id x (dist-ℕ y z) → Id (add-ℕ x y) z
rewrite-left-dist-add-ℕ .(dist-ℕ y z) y z H refl =
( commutative-add-ℕ (dist-ℕ y z) y) ∙
( leq-dist-ℕ y z H)
rewrite-right-add-dist-ℕ :
(x y z : ℕ) → Id (add-ℕ x y) z → Id y (dist-ℕ x z)
rewrite-right-add-dist-ℕ x y z p =
rewrite-left-add-dist-ℕ y x z (commutative-add-ℕ y x ∙ p)
rewrite-right-dist-add-ℕ :
(x y z : ℕ) → leq-ℕ x z → Id y (dist-ℕ x z) → Id (add-ℕ x y) z
rewrite-right-dist-add-ℕ x .(dist-ℕ x z) z H refl =
leq-dist-ℕ x z H
-- We show that dist-ℕ is translation invariant
translation-invariant-dist-ℕ :
(k m n : ℕ) → Id (dist-ℕ (add-ℕ k m) (add-ℕ k n)) (dist-ℕ m n)
translation-invariant-dist-ℕ zero-ℕ m n =
ap-dist-ℕ (left-unit-law-add-ℕ m) (left-unit-law-add-ℕ n)
translation-invariant-dist-ℕ (succ-ℕ k) m n =
( ap-dist-ℕ (left-successor-law-add-ℕ k m) (left-successor-law-add-ℕ k n)) ∙
( translation-invariant-dist-ℕ k m n)
-- We show that dist-ℕ is linear with respect to scalar multiplication
linear-dist-ℕ :
(m n k : ℕ) → Id (dist-ℕ (mul-ℕ k m) (mul-ℕ k n)) (mul-ℕ k (dist-ℕ m n))
linear-dist-ℕ zero-ℕ zero-ℕ zero-ℕ = refl
linear-dist-ℕ zero-ℕ zero-ℕ (succ-ℕ k) = linear-dist-ℕ zero-ℕ zero-ℕ k
linear-dist-ℕ zero-ℕ (succ-ℕ n) zero-ℕ = refl
linear-dist-ℕ zero-ℕ (succ-ℕ n) (succ-ℕ k) =
ap (dist-ℕ' (mul-ℕ (succ-ℕ k) (succ-ℕ n))) (right-zero-law-mul-ℕ (succ-ℕ k))
linear-dist-ℕ (succ-ℕ m) zero-ℕ zero-ℕ = refl
linear-dist-ℕ (succ-ℕ m) zero-ℕ (succ-ℕ k) =
ap (dist-ℕ (mul-ℕ (succ-ℕ k) (succ-ℕ m))) (right-zero-law-mul-ℕ (succ-ℕ k))
linear-dist-ℕ (succ-ℕ m) (succ-ℕ n) zero-ℕ = refl
linear-dist-ℕ (succ-ℕ m) (succ-ℕ n) (succ-ℕ k) =
( ap-dist-ℕ
( right-successor-law-mul-ℕ (succ-ℕ k) m)
( right-successor-law-mul-ℕ (succ-ℕ k) n)) ∙
( ( translation-invariant-dist-ℕ
( succ-ℕ k)
( mul-ℕ (succ-ℕ k) m)
( mul-ℕ (succ-ℕ k) n)) ∙
( linear-dist-ℕ m n (succ-ℕ k)))
-- Exercise 6.6
{- In this exercise we were asked to define the relations ≤ and < on the
integers. As a criterion of correctness, we were then also asked to show
that the type of all integers l satisfying k ≤ l satisfy the induction
principle of the natural numbers. -}
diff-ℤ : ℤ → ℤ → ℤ
diff-ℤ k l = add-ℤ (neg-ℤ k) l
is-non-negative-ℤ : ℤ → UU lzero
is-non-negative-ℤ (inl x) = empty
is-non-negative-ℤ (inr k) = unit
leq-ℤ : ℤ → ℤ → UU lzero
leq-ℤ k l = is-non-negative-ℤ (diff-ℤ k l)
reflexive-leq-ℤ : (k : ℤ) → leq-ℤ k k
reflexive-leq-ℤ k =
tr is-non-negative-ℤ (inv (left-inverse-law-add-ℤ k)) star
is-non-negative-succ-ℤ :
(k : ℤ) → is-non-negative-ℤ k → is-non-negative-ℤ (succ-ℤ k)
is-non-negative-succ-ℤ (inr (inl star)) p = star
is-non-negative-succ-ℤ (inr (inr x)) p = star
is-non-negative-add-ℤ :
(k l : ℤ) →
is-non-negative-ℤ k → is-non-negative-ℤ l → is-non-negative-ℤ (add-ℤ k l)
is-non-negative-add-ℤ (inr (inl star)) (inr (inl star)) p q = star
is-non-negative-add-ℤ (inr (inl star)) (inr (inr n)) p q = star
is-non-negative-add-ℤ (inr (inr zero-ℕ)) (inr (inl star)) p q = star
is-non-negative-add-ℤ (inr (inr (succ-ℕ n))) (inr (inl star)) star star =
is-non-negative-succ-ℤ
( add-ℤ (inr (inr n)) (inr (inl star)))
( is-non-negative-add-ℤ (inr (inr n)) (inr (inl star)) star star)
is-non-negative-add-ℤ (inr (inr zero-ℕ)) (inr (inr m)) star star = star
is-non-negative-add-ℤ (inr (inr (succ-ℕ n))) (inr (inr m)) star star =
is-non-negative-succ-ℤ
( add-ℤ (inr (inr n)) (inr (inr m)))
( is-non-negative-add-ℤ (inr (inr n)) (inr (inr m)) star star)
triangle-diff-ℤ :
(k l m : ℤ) → Id (add-ℤ (diff-ℤ k l) (diff-ℤ l m)) (diff-ℤ k m)
triangle-diff-ℤ k l m =
( associative-add-ℤ (neg-ℤ k) l (diff-ℤ l m)) ∙
( ap
( add-ℤ (neg-ℤ k))
( ( inv (associative-add-ℤ l (neg-ℤ l) m)) ∙
( ( ap (λ x → add-ℤ x m) (right-inverse-law-add-ℤ l)) ∙
( left-unit-law-add-ℤ m))))
transitive-leq-ℤ : (k l m : ℤ) → leq-ℤ k l → leq-ℤ l m → leq-ℤ k m
transitive-leq-ℤ k l m p q =
tr is-non-negative-ℤ
( triangle-diff-ℤ k l m)
( is-non-negative-add-ℤ
( add-ℤ (neg-ℤ k) l)
( add-ℤ (neg-ℤ l) m)
( p)
( q))
succ-leq-ℤ : (k : ℤ) → leq-ℤ k (succ-ℤ k)
succ-leq-ℤ k =
tr is-non-negative-ℤ
( inv
( ( right-successor-law-add-ℤ (neg-ℤ k) k) ∙
( ap succ-ℤ (left-inverse-law-add-ℤ k))))
( star)
leq-ℤ-succ-leq-ℤ : (k l : ℤ) → leq-ℤ k l → leq-ℤ k (succ-ℤ l)
leq-ℤ-succ-leq-ℤ k l p = transitive-leq-ℤ k l (succ-ℤ l) p (succ-leq-ℤ l)
is-positive-ℤ : ℤ → UU lzero
is-positive-ℤ k = is-non-negative-ℤ (pred-ℤ k)
le-ℤ : ℤ → ℤ → UU lzero
le-ℤ (inl zero-ℕ) (inl x) = empty
le-ℤ (inl zero-ℕ) (inr y) = unit
le-ℤ (inl (succ-ℕ x)) (inl zero-ℕ) = unit
le-ℤ (inl (succ-ℕ x)) (inl (succ-ℕ y)) = le-ℤ (inl x) (inl y)
le-ℤ (inl (succ-ℕ x)) (inr y) = unit
le-ℤ (inr x) (inl y) = empty
le-ℤ (inr (inl star)) (inr (inl star)) = empty
le-ℤ (inr (inl star)) (inr (inr x)) = unit
le-ℤ (inr (inr x)) (inr (inl star)) = empty
le-ℤ (inr (inr zero-ℕ)) (inr (inr zero-ℕ)) = empty
le-ℤ (inr (inr zero-ℕ)) (inr (inr (succ-ℕ y))) = unit
le-ℤ (inr (inr (succ-ℕ x))) (inr (inr zero-ℕ)) = empty
le-ℤ (inr (inr (succ-ℕ x))) (inr (inr (succ-ℕ y))) =
le-ℤ (inr (inr x)) (inr (inr y))
-- Extra material
-- We show that ℕ is an ordered semi-ring
left-law-leq-add-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (add-ℕ m k) (add-ℕ n k)
left-law-leq-add-ℕ zero-ℕ m n = id
left-law-leq-add-ℕ (succ-ℕ k) m n H = left-law-leq-add-ℕ k m n H
right-law-leq-add-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (add-ℕ k m) (add-ℕ k n)
right-law-leq-add-ℕ k m n H =
concatenate-eq-leq-eq-ℕ
( commutative-add-ℕ k m)
( left-law-leq-add-ℕ k m n H)
( commutative-add-ℕ n k)
preserves-leq-add-ℕ :
{m m' n n' : ℕ} → leq-ℕ m m' → leq-ℕ n n' → leq-ℕ (add-ℕ m n) (add-ℕ m' n')
preserves-leq-add-ℕ {m} {m'} {n} {n'} H K =
transitive-leq-ℕ
( add-ℕ m n)
( add-ℕ m' n)
( add-ℕ m' n')
( left-law-leq-add-ℕ n m m' H)
( right-law-leq-add-ℕ m' n n' K)
{-
right-law-leq-mul-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (mul-ℕ k m) (mul-ℕ k n)
right-law-leq-mul-ℕ zero-ℕ m n H = star
right-law-leq-mul-ℕ (succ-ℕ k) m n H = {!!}
-}
{-
preserves-leq-add-ℕ
{ m = mul-ℕ k m}
{ m' = mul-ℕ k n}
( right-law-leq-mul-ℕ k m n H) H
left-law-leq-mul-ℕ : (k m n : ℕ) → leq-ℕ m n → leq-ℕ (mul-ℕ m k) (mul-ℕ n k)
left-law-leq-mul-ℕ k m n H =
concatenate-eq-leq-eq-ℕ
( commutative-mul-ℕ k m)
( commutative-mul-ℕ k n)
( right-law-leq-mul-ℕ k m n H)
-}
-- We show that ℤ is an ordered ring
{-
leq-add-ℤ : (m k l : ℤ) → leq-ℤ k l → leq-ℤ (add-ℤ m k) (add-ℤ m l)
leq-add-ℤ (inl zero-ℕ) k l H = {!!}
leq-add-ℤ (inl (succ-ℕ x)) k l H = {!!}
leq-add-ℤ (inr m) k l H = {!!}
-}
-- Section 5.5 Identity systems
succ-fam-Eq-ℕ :
{i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i) →
(m n : ℕ) → Eq-ℕ m n → UU i
succ-fam-Eq-ℕ R m n e = R (succ-ℕ m) (succ-ℕ n) e
succ-refl-fam-Eq-ℕ :
{i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i)
(ρ : (n : ℕ) → R n n (refl-Eq-ℕ n)) →
(n : ℕ) → (succ-fam-Eq-ℕ R n n (refl-Eq-ℕ n))
succ-refl-fam-Eq-ℕ R ρ n = ρ (succ-ℕ n)
path-ind-Eq-ℕ :
{i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i)
( ρ : (n : ℕ) → R n n (refl-Eq-ℕ n)) →
( m n : ℕ) (e : Eq-ℕ m n) → R m n e
path-ind-Eq-ℕ R ρ zero-ℕ zero-ℕ star = ρ zero-ℕ
path-ind-Eq-ℕ R ρ zero-ℕ (succ-ℕ n) ()
path-ind-Eq-ℕ R ρ (succ-ℕ m) zero-ℕ ()
path-ind-Eq-ℕ R ρ (succ-ℕ m) (succ-ℕ n) e =
path-ind-Eq-ℕ
( λ m n e → R (succ-ℕ m) (succ-ℕ n) e)
( λ n → ρ (succ-ℕ n)) m n e
comp-path-ind-Eq-ℕ :
{i : Level} (R : (m n : ℕ) → Eq-ℕ m n → UU i)
( ρ : (n : ℕ) → R n n (refl-Eq-ℕ n)) →
( n : ℕ) → Id (path-ind-Eq-ℕ R ρ n n (refl-Eq-ℕ n)) (ρ n)
comp-path-ind-Eq-ℕ R ρ zero-ℕ = refl
comp-path-ind-Eq-ℕ R ρ (succ-ℕ n) =
comp-path-ind-Eq-ℕ
( λ m n e → R (succ-ℕ m) (succ-ℕ n) e)
( λ n → ρ (succ-ℕ n)) n
{-
-- Graphs
Gph : (i : Level) → UU (lsuc i)
Gph i = Σ (UU i) (λ X → (X → X → (UU i)))
-- Reflexive graphs
rGph : (i : Level) → UU (lsuc i)
rGph i = Σ (UU i) (λ X → Σ (X → X → (UU i)) (λ R → (x : X) → R x x))
-}
-- Exercise 3.7
{- With the construction of the divisibility relation we open the door to basic
number theory. -}
divides : (d n : ℕ) → UU lzero
divides d n = Σ ℕ (λ m → Eq-ℕ (mul-ℕ d m) n)
-- We prove some lemmas about inequalities --
leq-add-ℕ :
(m n : ℕ) → leq-ℕ m (add-ℕ m n)
leq-add-ℕ m zero-ℕ = reflexive-leq-ℕ m
leq-add-ℕ m (succ-ℕ n) =
transitive-leq-ℕ m (add-ℕ m n) (succ-ℕ (add-ℕ m n))
( leq-add-ℕ m n)
( succ-leq-ℕ (add-ℕ m n))
leq-add-ℕ' :
(m n : ℕ) → leq-ℕ m (add-ℕ n m)
leq-add-ℕ' m n =
concatenate-leq-eq-ℕ m (leq-add-ℕ m n) (commutative-add-ℕ m n)
leq-leq-add-ℕ :
(m n x : ℕ) → leq-ℕ (add-ℕ m x) (add-ℕ n x) → leq-ℕ m n
leq-leq-add-ℕ m n zero-ℕ H = H
leq-leq-add-ℕ m n (succ-ℕ x) H = leq-leq-add-ℕ m n x H
leq-leq-add-ℕ' :
(m n x : ℕ) → leq-ℕ (add-ℕ x m) (add-ℕ x n) → leq-ℕ m n
leq-leq-add-ℕ' m n x H =
leq-leq-add-ℕ m n x
( concatenate-eq-leq-eq-ℕ
( commutative-add-ℕ m x)
( H)
( commutative-add-ℕ x n))
leq-leq-mul-ℕ :
(m n x : ℕ) → leq-ℕ (mul-ℕ (succ-ℕ x) m) (mul-ℕ (succ-ℕ x) n) → leq-ℕ m n
leq-leq-mul-ℕ zero-ℕ zero-ℕ x H = star
leq-leq-mul-ℕ zero-ℕ (succ-ℕ n) x H = star
leq-leq-mul-ℕ (succ-ℕ m) zero-ℕ x H =
ex-falso
( concatenate-leq-eq-ℕ
( mul-ℕ (succ-ℕ x) (succ-ℕ m))
( H)
( right-zero-law-mul-ℕ (succ-ℕ x)))
leq-leq-mul-ℕ (succ-ℕ m) (succ-ℕ n) x H =
leq-leq-mul-ℕ m n x
( leq-leq-add-ℕ' (mul-ℕ (succ-ℕ x) m) (mul-ℕ (succ-ℕ x) n) (succ-ℕ x)
( concatenate-eq-leq-eq-ℕ
( inv (right-successor-law-mul-ℕ (succ-ℕ x) m))
( H)
( right-successor-law-mul-ℕ (succ-ℕ x) n)))
leq-leq-mul-ℕ' :
(m n x : ℕ) → leq-ℕ (mul-ℕ m (succ-ℕ x)) (mul-ℕ n (succ-ℕ x)) → leq-ℕ m n
leq-leq-mul-ℕ' m n x H =
leq-leq-mul-ℕ m n x
( concatenate-eq-leq-eq-ℕ
( commutative-mul-ℕ (succ-ℕ x) m)
( H)
( commutative-mul-ℕ n (succ-ℕ x)))
{-
succ-relation-ℕ :
{i : Level} (R : ℕ → ℕ → UU i) → ℕ → ℕ → UU i
succ-relation-ℕ R m n = R (succ-ℕ m) (succ-ℕ n)
succ-reflexivity-ℕ :
{i : Level} (R : ℕ → ℕ → UU i) (ρ : (n : ℕ) → R n n) →
(n : ℕ) → succ-relation-ℕ R n n
succ-reflexivity-ℕ R ρ n = ρ (succ-ℕ n)
{- In the book we suggest that first the order of the variables should be
swapped, in order to make the inductive hypothesis stronger. Agda's pattern
matching mechanism allows us to bypass this step and give a more direct
construction. -}
least-reflexive-Eq-ℕ :
{i : Level} (R : ℕ → ℕ → UU i) (ρ : (n : ℕ) → R n n) →
(m n : ℕ) → Eq-ℕ m n → R m n
least-reflexive-Eq-ℕ R ρ zero-ℕ zero-ℕ star = ρ zero-ℕ
least-reflexive-Eq-ℕ R ρ zero-ℕ (succ-ℕ n) ()
least-reflexive-Eq-ℕ R ρ (succ-ℕ m) zero-ℕ ()
least-reflexive-Eq-ℕ R ρ (succ-ℕ m) (succ-ℕ n) e =
least-reflexive-Eq-ℕ (succ-relation-ℕ R) (succ-reflexivity-ℕ R ρ) m n e
-}
-- The definition of <
le-ℕ : ℕ → ℕ → UU lzero
le-ℕ m zero-ℕ = empty
le-ℕ zero-ℕ (succ-ℕ m) = unit
le-ℕ (succ-ℕ n) (succ-ℕ m) = le-ℕ n m
_<_ = le-ℕ
anti-reflexive-le-ℕ : (n : ℕ) → ¬ (n < n)
anti-reflexive-le-ℕ zero-ℕ = ind-empty
anti-reflexive-le-ℕ (succ-ℕ n) = anti-reflexive-le-ℕ n
transitive-le-ℕ : (n m l : ℕ) → (le-ℕ n m) → (le-ℕ m l) → (le-ℕ n l)
transitive-le-ℕ zero-ℕ (succ-ℕ m) (succ-ℕ l) p q = star
transitive-le-ℕ (succ-ℕ n) (succ-ℕ m) (succ-ℕ l) p q =
transitive-le-ℕ n m l p q
succ-le-ℕ : (n : ℕ) → le-ℕ n (succ-ℕ n)
succ-le-ℕ zero-ℕ = star
succ-le-ℕ (succ-ℕ n) = succ-le-ℕ n
anti-symmetric-le-ℕ : (m n : ℕ) → le-ℕ m n → le-ℕ n m → Id m n
anti-symmetric-le-ℕ (succ-ℕ m) (succ-ℕ n) p q =
ap succ-ℕ (anti-symmetric-le-ℕ m n p q)
{-
--------------------------------------------------------------------------------
data Fin-Tree : UU lzero where
constr : (n : ℕ) → (Fin n → Fin-Tree) → Fin-Tree
root-Fin-Tree : Fin-Tree
root-Fin-Tree = constr zero-ℕ ex-falso
succ-Fin-Tree : Fin-Tree → Fin-Tree
succ-Fin-Tree t = constr one-ℕ (λ i → t)
map-assoc-coprod :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3} →
coprod (coprod A B) C → coprod A (coprod B C)
map-assoc-coprod (inl (inl x)) = inl x
map-assoc-coprod (inl (inr x)) = inr (inl x)
map-assoc-coprod (inr x) = inr (inr x)
map-coprod-Fin :
(m n : ℕ) → Fin (add-ℕ m n) → coprod (Fin m) (Fin n)
map-coprod-Fin m zero-ℕ = inl
map-coprod-Fin m (succ-ℕ n) =
map-assoc-coprod ∘ (functor-coprod (map-coprod-Fin m n) (id {A = unit}))
add-Fin-Tree : Fin-Tree → Fin-Tree → Fin-Tree
add-Fin-Tree (constr n x) (constr m y) =
constr (add-ℕ n m) ((ind-coprod (λ i → Fin-Tree) x y) ∘ (map-coprod-Fin n m))
--------------------------------------------------------------------------------
data labeled-Bin-Tree {l1 : Level} (A : UU l1) : UU l1 where
leaf : A → labeled-Bin-Tree A
constr : (bool → labeled-Bin-Tree A) → labeled-Bin-Tree A
mul-leaves-labeled-Bin-Tree :
{l1 : Level} {A : UU l1} (μ : A → (A → A)) →
labeled-Bin-Tree A → A
mul-leaves-labeled-Bin-Tree μ (leaf x) = x
mul-leaves-labeled-Bin-Tree μ (constr f) =
μ ( mul-leaves-labeled-Bin-Tree μ (f false))
( mul-leaves-labeled-Bin-Tree μ (f true))
pick-list : {l1 : Level} {A : UU l1} → ℕ → list A → coprod A unit
pick-list zero-ℕ nil = inr star
pick-list zero-ℕ (cons a x) = inl a
pick-list (succ-ℕ n) nil = inr star
pick-list (succ-ℕ n) (cons a x) = pick-list n x
-}
|
module Square where
import Genetics
import qualified Neural
import Utilities
import qualified Numeric.LinearAlgebra
( cmap )
import Numeric.LinearAlgebra
( (<>)
, (><)
)
import System.Random
newtype Phenotype = Network Double
trainingSet :: TrainingSet
trainingSet = [ ((1><3)[1, 1, 1], (6><1)[1, 1, 1, 0, 1, 1])
, ((1><3)[0, 0, 1], (6><1)[0, 0, 0, 0, 0, 1])
, ((1><3)[0, 1, 0], (6><1)[0, 0, 0, 1, 0, 0])
, ((1><3)[0, 1, 1], (6><1)[0, 0, 1, 0, 0, 1])
, ((1><3)[1, 0, 0], (6><1)[0, 1, 0, 0, 0, 0])
]
randompopulation :: IO [Genotype]
randompopulation = do
g <- getStdGen
return $ map Neural.flatten $ take 10 $ randomNetworks g [3, 6]
morphogenesis :: Genotype -> Phenotype
morphogenesis g = Neural.fromList [3, 6]
fit :: Genotype -> Double
fit = (fitness trainingSet) . morphogenesis
-- Iterates fitness and selection on a population, where the
-- selection function uses randomness.
iterations :: RandomGen g => g -> Population -> [Population]
iterations g population =
map fst $ iterate (mySelection fit) (population, g)
maximums :: [Population] -> [Double]
maximums populations = map maximum $ (map.map) fit $ populations
-- example to see how well we are doing
example :: IO [Double]
example = do
g <- newStdGen
population <- randompopulation
return $ maximums (iterations g population)
fitness :: Neural.TrainingSet -> Neural.Network -> Double
fitness training network =
let xs = map fst training
ys = concat (map (Neural.toList . Neural.flatten . snd) training)
actual = concat (map (Neural.toList . Neural.flatten . (Neural.forward network)) xs)
differences = zipWith (-) ys actual
in (-1) * sqrt (sum (map (^2) differences))
|
[STATEMENT]
theorem CYK_eq2 :
assumes A: "i + j \<le> length w"
and B: "1 < j"
shows "CYK G w i j = {X | X A B k. (X, Branch A B) \<in> set G \<and> A \<in> CYK G w i k \<and> B \<in> CYK G w (i + k) (j - k) \<and> 1 \<le> k \<and> k < j}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. CYK G w i j = {uu_. \<exists>X A B k. uu_ = X \<and> (X, Branch A B) \<in> set G \<and> A \<in> CYK G w i k \<and> B \<in> CYK G w (i + k) (j - k) \<and> 1 \<le> k \<and> k < j}
[PROOF STEP]
proof(rule set_eqI, rule iffI, simp_all add: CYK_def)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<And>x. subword w i j \<in> Lang G x \<Longrightarrow> \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
2. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
fix X
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. \<And>x. subword w i j \<in> Lang G x \<Longrightarrow> \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
2. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
assume a: "subword w i j \<in> Lang G X"
[PROOF STATE]
proof (state)
this:
subword w i j \<in> Lang G X
goal (2 subgoals):
1. \<And>x. subword w i j \<in> Lang G x \<Longrightarrow> \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
2. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
show "\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
have b: "1 < length(subword w i j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. 1 < length (subword w i j)
[PROOF STEP]
by(subst subword_length, rule A, rule B)
[PROOF STATE]
proof (state)
this:
1 < length (subword w i j)
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
note Lang_eq2[THEN iffD1, OF conjI, OF a b]
[PROOF STATE]
proof (state)
this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>l r. subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B)
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>l r. subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B)
[PROOF STEP]
obtain A B l r where c: "(X, Branch A B) \<in> set G \<and> subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B"
[PROOF STATE]
proof (prove)
using this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>l r. subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B)
goal (1 subgoal):
1. (\<And>A B l r. (X, Branch A B) \<in> set G \<and> subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(X, Branch A B) \<in> set G \<and> subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
note Lang_no_Nil[OF c[THEN conjunct2, THEN conjunct2, THEN conjunct1]]
[PROOF STATE]
proof (state)
this:
l \<noteq> []
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
hence d: "0 < length l"
[PROOF STATE]
proof (prove)
using this:
l \<noteq> []
goal (1 subgoal):
1. 0 < length l
[PROOF STEP]
by(case_tac l, simp_all)
[PROOF STATE]
proof (state)
this:
0 < length l
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
note Lang_no_Nil[OF c[THEN conjunct2, THEN conjunct2, THEN conjunct2]]
[PROOF STATE]
proof (state)
this:
r \<noteq> []
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
hence e: "0 < length r"
[PROOF STATE]
proof (prove)
using this:
r \<noteq> []
goal (1 subgoal):
1. 0 < length r
[PROOF STEP]
by(case_tac r, simp_all)
[PROOF STATE]
proof (state)
this:
0 < length r
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
note subword_split2[OF c[THEN conjunct2, THEN conjunct1], OF A, OF d, OF e]
[PROOF STATE]
proof (state)
this:
l = subword w i (length l) \<and> r = subword w (i + length l) (j - length l)
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
with c
[PROOF STATE]
proof (chain)
picking this:
(X, Branch A B) \<in> set G \<and> subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B
l = subword w i (length l) \<and> r = subword w (i + length l) (j - length l)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(X, Branch A B) \<in> set G \<and> subword w i j = l \<cdot> r \<and> l \<in> Lang G A \<and> r \<in> Lang G B
l = subword w i (length l) \<and> r = subword w (i + length l) (j - length l)
goal (1 subgoal):
1. \<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
proof(rule_tac x=A in exI, rule_tac x=B in exI, simp,
rule_tac x="length l" in exI, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<lbrakk>subword w (i + length l) (j - length l) \<in> Lang G B; (X, Branch A B) \<in> set G \<and> subword w i j = l \<cdot> subword w (i + length l) (j - length l) \<and> l \<in> Lang G A; l = subword w i (length l) \<and> r = subword w (i + length l) (j - length l)\<rbrakk> \<Longrightarrow> Suc 0 \<le> length l \<and> length l < j
[PROOF STEP]
show "Suc 0 \<le> length l \<and> length l < j" (is "?A \<and> ?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. Suc 0 \<le> length l \<and> length l < j
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. Suc 0 \<le> length l
2. length l < j
[PROOF STEP]
from d
[PROOF STATE]
proof (chain)
picking this:
0 < length l
[PROOF STEP]
show "?A"
[PROOF STATE]
proof (prove)
using this:
0 < length l
goal (1 subgoal):
1. Suc 0 \<le> length l
[PROOF STEP]
by(case_tac l, simp_all)
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> length l
goal (1 subgoal):
1. length l < j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. length l < j
[PROOF STEP]
note arg_cong[where f=length, OF c[THEN conjunct2, THEN conjunct1], THEN sym]
[PROOF STATE]
proof (state)
this:
length (l \<cdot> r) = length (subword w i j)
goal (1 subgoal):
1. length l < j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
length (l \<cdot> r) = length (subword w i j)
goal (1 subgoal):
1. length l < j
[PROOF STEP]
have "length(subword w i j) = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. length (subword w i j) = j
[PROOF STEP]
by(rule subword_length, rule A)
[PROOF STATE]
proof (state)
this:
length (subword w i j) = j
goal (1 subgoal):
1. length l < j
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
length (l \<cdot> r) = j
[PROOF STEP]
have "length l + length r = j"
[PROOF STATE]
proof (prove)
using this:
length (l \<cdot> r) = j
goal (1 subgoal):
1. length l + length r = j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length l + length r = j
goal (1 subgoal):
1. length l < j
[PROOF STEP]
with e
[PROOF STATE]
proof (chain)
picking this:
0 < length r
length l + length r = j
[PROOF STEP]
show ?B
[PROOF STATE]
proof (prove)
using this:
0 < length r
length l + length r = j
goal (1 subgoal):
1. length l < j
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
length l < j
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> length l \<and> length l < j
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
goal (1 subgoal):
1. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
fix X
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
assume "\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)"
[PROOF STATE]
proof (state)
this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
goal (1 subgoal):
1. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
[PROOF STEP]
obtain A B k where a: "(X, Branch A B) \<in> set G \<and> subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j"
[PROOF STATE]
proof (prove)
using this:
\<exists>A B. (X, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j)
goal (1 subgoal):
1. (\<And>A B k. (X, Branch A B) \<in> set G \<and> subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(X, Branch A B) \<in> set G \<and> subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j
goal (1 subgoal):
1. \<And>x. \<exists>A B. (x, Branch A B) \<in> set G \<and> (\<exists>k. subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j) \<Longrightarrow> subword w i j \<in> Lang G x
[PROOF STEP]
show "subword w i j \<in> Lang G X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. subword w i j \<in> Lang G X
[PROOF STEP]
proof(rule Lang_eq2[THEN iffD2, THEN conjunct1], rule_tac x=A in exI, rule_tac x=B in exI, simp add: a,
rule_tac x="subword w i k" in exI, rule_tac x="subword w (i + k) (j - k)" in exI, simp add: a,
rule subword_split, rule A)
[PROOF STATE]
proof (state)
goal (2 subgoals):
1. 0 < k
2. k < j
[PROOF STEP]
from a
[PROOF STATE]
proof (chain)
picking this:
(X, Branch A B) \<in> set G \<and> subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j
[PROOF STEP]
show "0 < k"
[PROOF STATE]
proof (prove)
using this:
(X, Branch A B) \<in> set G \<and> subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j
goal (1 subgoal):
1. 0 < k
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
0 < k
goal (1 subgoal):
1. k < j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. k < j
[PROOF STEP]
from a
[PROOF STATE]
proof (chain)
picking this:
(X, Branch A B) \<in> set G \<and> subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j
[PROOF STEP]
show "k < j"
[PROOF STATE]
proof (prove)
using this:
(X, Branch A B) \<in> set G \<and> subword w i k \<in> Lang G A \<and> subword w (i + k) (j - k) \<in> Lang G B \<and> Suc 0 \<le> k \<and> k < j
goal (1 subgoal):
1. k < j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k < j
goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
subword w i j \<in> Lang G X
goal:
No subgoals!
[PROOF STEP]
qed |
%default total
data F : Type where
MkFix : ((0 g : Type -> Type) -> g === Not -> g F) -> F
yesF : Not F -> F
yesF nf = MkFix (\ g, Refl => nf)
notF : Not F
notF (MkFix f) =
let g = f Not Refl in
g (yesF g)
argh : Void
argh = notF (yesF notF)
|
# This file was generated, do not modify it. # hide
DecisionTreeClassifier = @load DecisionTreeClassifier pkg=DecisionTree
tree_model = DecisionTreeClassifier() |
module BitInformation
export shave, set_one, groom, halfshave,
shave!, set_one!, groom!, halfshave!, round!
export bittranspose, bitbacktranspose,
xor_delta, unxor_delta, xor_delta!, unxor_delta!,
signed_exponent
export bitinformation, mutual_information, redundancy, bitpattern_entropy,
bitcount, bitcount_entropy, bitpaircount, bit_condprobability,
bit_condentropy
import StatsBase.entropy
include("which_uint.jl")
include("bitstring.jl")
include("bittranspose.jl")
include("round_nearest.jl")
include("shave_set_groom.jl")
include("xor_delta.jl")
include("signed_exponent.jl")
include("bit_information.jl")
include("mutual_information.jl")
include("bitpattern_entropy.jl")
include("binomial.jl")
end
|
Require Import Coq.Logic.ChoiceFacts.
Require Import Notation.
Require Import GeneralTactics.
Require Import Truncations.
Require Import Axioms.Classical.
Require Import Axioms.Extensionality.
(* "If `x: A` implies there exists some `B x`, then there exists
some function `Π x: A, B x`". *)
Axiom choice : Π (A: Type) (B: A -> Type),
(Π x, ‖B x‖) -> ‖Π x, B x‖.
(* Truncation commutes across Π-abstractions *)
Corollary trunc_comm_forall : Π (A: Type) (B: A -> Type),
(Π x, ‖B x‖) = ‖Π x, B x‖.
Proof using.
intros *.
extensionality; split.
- apply choice.
- intros H *.
now uninhabit H.
Qed.
(* Reduction rule on choice (trivialized by proof irrelevance) *)
Lemma choice_red : forall (A: Type) (B: A -> Type) (b: Π a, B a),
choice _ _ (λ x, |b x|) = |λ x, b x|.
Proof using.
intros *.
apply proof_irrelevance.
Qed.
Lemma nondep_choice : forall A B,
(A -> ‖B‖) -> ‖A -> B‖.
Proof using.
intros * f.
now apply choice.
Qed.
Corollary trunc_comm_arrow : forall A B,
(A -> ‖B‖) = ‖A -> B‖.
Proof using.
intros.
apply trunc_comm_forall.
Qed.
Theorem trunc_distr_arrow : forall A B,
(‖A‖ -> ‖B‖) = ‖A -> B‖ .
Proof using.
intros *.
extensionality; split.
- intros f.
apply choice.
intro a.
applyc f.
exists a.
- intros [f] [a].
exists (f a).
Qed.
Lemma fun_choice : forall A B (R: A -> B -> Prop),
(forall a, exists b, R a b) ->
exists f: A -> B, forall a, R a (f a).
Proof using.
intros * Rltotal.
transform Rltotal (Π x, ‖{y | R x y}‖) by
(intros; now rewrite trunc_sig_eq_exists).
apply choice in Rltotal.
uninhabit Rltotal.
define exists.
- intro a.
specialize (Rltotal a).
now destruct Rltotal.
- intros *.
simpl.
now destruct (Rltotal a).
Qed.
Corollary dependent_choice : forall (A: Type) (B: A -> Type) (R: forall a, B a -> Prop),
(forall a, exists b, R a b) ->
exists f: (forall a, B a),
forall a, R a (f a).
Proof using.
apply non_dep_dep_functional_choice.
exact fun_choice.
Qed.
(* Functional choice does not require an axiom when the proof of left-totalness
is transparent/constructive *)
Definition fun_choice_constructive : forall A B (R: A -> B -> Prop),
(forall a, Σ b, R a b) ->
Σ f: A -> B, forall a, R a (f a).
Proof using.
intros * Rltotal.
exists (λ a, projT1 (Rltotal a)).
intro a.
now destruct (Rltotal a).
Defined.
Lemma rel_choice : forall A B (R: A -> B -> Prop),
(forall x, exists y, R x y) ->
exists R': A -> B -> Prop,
subrelation R' R /\
forall x, exists! y, R' x y.
Proof using.
intros * Rltotal.
transform Rltotal (Π x, ‖{y | R x y}‖) by
(intros; now rewrite trunc_sig_eq_exists).
apply choice in Rltotal.
uninhabit Rltotal.
define exists.
- intro a.
specialize (Rltotal a).
destruct exists Rltotal b.
exact (λ x, b = x).
- simpl.
split.
+ unfold subrelation.
intros * ?.
destruct (Rltotal x).
now subst.
+ intros *.
follows destruct (Rltotal x).
Qed.
Theorem exists_universal_decision_procedure :
‖Π P, {P} + {~P}‖.
Proof using.
apply choice.
intro P.
destruct classic P as H.
- exists (left H).
- exists (right H).
Qed.
(* Warning: this is known to conflict with impredicative set. *)
Theorem double_neg_classic_set :
(* ((Π P, {P} + {~P}) -> False) -> False. *)
notT (notT (Π P, {P} + {~P})).
Proof using.
rewrite <- truncated_eq_double_neg.
exact exists_universal_decision_procedure.
Qed.
Require Import Coq.Relations.Relation_Definitions.
Require Import Coq.Classes.RelationClasses.
Require Import Coq.Sets.Ensembles.
Definition antisymmetric {A} (R: relation A) :=
forall x y, R x y -> R y x -> x = y.
Definition strongly_connected {A} (R: relation A) :=
forall x y, R x y \/ R y x.
Definition total_order {A} (R: relation A) :=
Reflexive R /\
Transitive R /\
antisymmetric R /\
strongly_connected R.
Definition well_order {A} (R: relation A) :=
total_order R /\
forall subset: Ensemble A,
Inhabited A subset ->
exists least, forall x, In A subset x -> R least x.
(* Theorem ex_well_ordering : forall A,
exists R: relation A, well_order R.
Proof using. *)
|
[STATEMENT]
lemma prime_nth_prime [intro]: "prime (nth_prime n)"
and card_less_nth_prime [simp]: "card {q. prime q \<and> q < nth_prime n} = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. prime (nth_prime n) &&& card {q. prime q \<and> q < nth_prime n} = n
[PROOF STEP]
using theI'[OF nth_prime_exists1[of n]]
[PROOF STATE]
proof (prove)
using this:
prime (THE x. prime x \<and> card {q. prime q \<and> q < x} = n) \<and> card {q. prime q \<and> q < (THE x. prime x \<and> card {q. prime q \<and> q < x} = n)} = n
goal (1 subgoal):
1. prime (nth_prime n) &&& card {q. prime q \<and> q < nth_prime n} = n
[PROOF STEP]
by (simp_all add: nth_prime_def) |
State Before: m : Type u_1 → Type u_2
α β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
f : α → β
x : m α
⊢ f <$> x = do
let a ← x
pure (f a) State After: no goals Tactic: rw [← bind_pure_comp] |
/-
Copyright (c) 2021 OpenAI. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f
-/
import minif2f_import
open_locale big_operators
open_locale real
open_locale nat
open_locale topological_space
theorem amc12a_2019_p21
(z : ℂ)
(h₀ : z = (1 + complex.I) / real.sqrt 2) :
(∑ k in finset.range 13 \ finset.range 1, (z^(k^2))) * (∑ k in finset.range 13 \ finset.range 1, (1 / z^(k^2))) = 36 :=
begin
sorry
end
theorem amc12a_2015_p10
(x y : ℤ)
(h₀ : 0 < y)
(h₁ : y < x)
(h₂ : x + y + (x * y) = 80) :
x = 26 :=
begin
sorry
end
theorem amc12a_2008_p8
(x y : ℝ)
(h₀ : 0 < x ∧ 0 < y)
(h₁ : y^3 = 1)
(h₂ : 6 * x^2 = 2 * (6 * y^2)) :
x^3 = 2 * real.sqrt 2 :=
begin
sorry
end
theorem mathd_algebra_182
(y : ℂ) :
7 * (3 * y + 2) = 21 * y + 14 :=
begin
ring_nf,
end
theorem aime_1984_p5
(a b : ℝ)
(h₀ : real.log a / real.log 8 + real.log (b^2) / real.log 4 = 5)
(h₁ : real.log b / real.log 8 + real.log (a^2) / real.log 4 = 7) :
a * b = 512 :=
begin
sorry
end
theorem mathd_numbertheory_780
(m x : ℕ)
(h₀ : 10 ≤ m)
(h₁ : m ≤ 99)
(h₂ : (6 * x) % m = 1)
(h₃ : (x - 6^2) % m = 0) :
m = 43 :=
begin
sorry
end
theorem mathd_algebra_116
(k x: ℝ)
(h₀ : x = (13 - real.sqrt 131) / 4)
(h₁ : 2 * x^2 - 13 * x + k = 0) :
k = 19/4 :=
begin
rw h₀ at h₁,
rw eq_comm.mp (add_eq_zero_iff_neg_eq.mp h₁),
norm_num,
rw pow_two,
rw mul_sub,
rw [sub_mul, sub_mul],
rw real.mul_self_sqrt _,
ring,
linarith,
end
theorem mathd_numbertheory_13
(u v : ℕ+)
(h₀ : 14 * ↑u % 100 = 46)
(h₁ : 14 * ↑v % 100 = 46)
(h₂ : u < 50)
(h₃ : v < 100)
(h₄ : 50 < v) :
((u + v):ℕ) / 2 = 64 :=
begin
sorry
end
theorem mathd_numbertheory_169 :
nat.gcd (nat.factorial 20) 200000 = 40000 :=
begin
sorry
end
theorem amc12a_2009_p9
(a b c : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f (x + 3) = 3 * x^2 + 7 * x + 4)
(h₁ : ∀ x, f x = a * x^2 + b * x + c) :
a + b + c = 2 :=
begin
sorry
end
theorem amc12a_2019_p9
(a : ℕ+ → ℚ)
(h₀ : a 1 = 1)
(h₁ : a 2 = 3 / 7)
(h₂ : ∀ n, a (n + 2) = (a n * a (n + 1)) / (2 * a n - a (n + 1))) :
↑(a 2019).denom + (a 2019).num = 8078 :=
begin
sorry
end
theorem mathd_algebra_13
(a b :ℝ)
(h₀ : ∀ x, (x - 3 ≠ 0 ∧ x - 5 ≠ 0) → 4 * x / (x^2 - 8 * x + 15) = a / (x - 3) + b / (x - 5)) :
a = -6 ∧ b = 10 :=
begin
sorry
end
theorem induction_sum2kp1npqsqm1
(n : ℕ) :
↑∑ k in (finset.range n), 2 * k + 3 = ↑(n + 1)^2 - (1:ℤ) :=
begin
sorry
end
theorem aime_1991_p6
(r : ℝ)
(h₀ : ∑ k in finset.range 92 \ finset.range 19, (int.floor (r + k / 100)) = 546) :
int.floor (100 * r) = 743 :=
begin
sorry
end
theorem mathd_numbertheory_149 :
∑ k in (finset.filter (λ x, x % 8 = 5 ∧ x % 6 = 3) (finset.range 50)), k = 66 :=
begin
sorry
end
theorem imo_1984_p2
(a b : ℕ)
(h₀ : 0 < a ∧ 0 < b)
(h₁ : ¬ 7 ∣ a)
(h₂ : ¬ 7 ∣ b)
(h₃ : ¬ 7 ∣ (a + b))
(h₄ : (7^7) ∣ ((a + b)^7 - a^7 - b^7)) :
19 ≤ a + b :=
begin
sorry
end
theorem amc12a_2008_p4 :
∏ k in finset.range 502 \ finset.range 1, ((4:ℝ) * k + 4) / (4 * k) = 502 :=
begin
sorry
end
theorem imo_2006_p6
(a b c : ℝ) :
(a * b * (a^2 - b^2)) + (b * c * (b^2 - c^2)) + (c * a * (c^2 - a^2)) ≤ (9 * real.sqrt 2) / 32 * (a^2 + b^2 + c^2)^2 :=
begin
sorry
end
theorem mathd_algebra_462 :
(1 / 2 + 1 / 3) * (1 / 2 - 1 / 3) = 5 / 36 :=
begin
norm_num,
end
theorem imo_1964_p1_2
(n : ℕ) :
¬ 7 ∣ (2^n + 1) :=
begin
sorry
end
theorem mathd_numbertheory_221
(h₀ : fintype {x : ℕ | 0 < x ∧ x < 1000 ∧ x.divisors.card = 3}) :
finset.card {x : ℕ | 0 < x ∧ x < 1000 ∧ finset.card (nat.divisors x) = 3}.to_finset = 11 :=
begin
sorry
end
theorem mathd_numbertheory_64 :
is_least { x : ℕ | 30 * x ≡ 42 [MOD 47] } 39 :=
begin
fsplit,
norm_num,
dec_trivial!,
rintro ⟨n, hn⟩,
simp,
dec_trivial,
intros h,
norm_num,
contrapose! h,
dec_trivial!,
end
theorem imo_1987_p4
(f : ℕ → ℕ) :
∃ n, f (f n) ≠ n + 1987 :=
begin
sorry
end
theorem mathd_numbertheory_33
(n : ℕ)
(h₀ : n < 398)
(h₁ : (n * 7) % 398 = 1) :
n = 57 :=
begin
sorry
end
theorem amc12_2001_p9
(f : ℝ → ℝ)
(h₀ : ∀ x > 0, ∀ y > 0, f (x * y) = f x / y)
(h₁ : f 500 = 3) : f 600 = 5 / 2 :=
begin
-- specialize h₀ 500 _ (6/5) _,
-- rw h₁ at h₀,
-- calc f 600 = f (500 * (6/5)) : by {congr, norm_num,}
-- ... = 3 / (6 / 5) : by { exact h₀,}
-- ... = 5 / 2 : by {norm_num,},
-- linarith,
-- linarith,
sorry
end
theorem imo_1965_p1
(x : ℝ)
(h₀ : 0 ≤ x)
(h₁ : x ≤ 2 * π)
(h₂ : 2 * real.cos x ≤ abs (real.sqrt (1 + real.sin (2 * x)) - real.sqrt (1 - real.sin (2 * x))))
(h₃ : abs (real.sqrt (1 + real.sin (2 * x)) - real.sqrt (1 - real.sin (2 * x))) ≤ real.sqrt 2) :
π / 4 ≤ x ∧ x ≤ 7 * π / 4 :=
begin
sorry
end
theorem mathd_numbertheory_48
(b : ℕ)
(h₀ : 0 < b)
(h₁ : 3 * b^2 + 2 * b + 1 = 57) :
b = 4 :=
begin
nlinarith,
end
theorem numbertheory_sqmod4in01d
(a : ℤ) :
(a^2 % 4) = 0 ∨ (a^2 % 4) = 1 :=
begin
sorry
end
theorem mathd_numbertheory_466 :
(∑ k in (finset.range 11), k) % 9 = 1 :=
begin
sorry
end
theorem mathd_algebra_48
(q e : ℂ)
(h₀ : q = 9 - 4 * complex.I)
(h₁ : e = -3 - 4 * complex.I) : q - e = 12 :=
begin
rw [h₀, h₁],
ring,
end
theorem amc12_2000_p15
(f : ℂ → ℂ)
(h₀ : ∀ x, f (x / 3) = x^2 + x + 1)
(h₁ : fintype (f ⁻¹' {7})) :
∑ y in (f⁻¹' {7}).to_finset, y / 3 = - 1 / 9 :=
begin
sorry
end
theorem mathd_numbertheory_132 :
2004 % 12 = 0 :=
begin
norm_num,
end
theorem amc12a_2009_p5
(x : ℝ)
(h₀ : x^3 - (x + 1) * (x - 1) * x = 5) :
x^3 = 125 :=
begin
sorry
end
theorem mathd_numbertheory_188 :
nat.gcd 180 168 = 12 :=
begin
norm_num,
end
theorem mathd_algebra_224
(h₀ : fintype { n : ℕ | real.sqrt n < 7 / 2 ∧ 2 < real.sqrt n}) :
finset.card { n : ℕ | real.sqrt n < 7 / 2 ∧ 2 < real.sqrt n}.to_finset = 8 :=
begin
sorry
end
theorem induction_divisibility_3divnto3m2n
(n : ℕ) :
3 ∣ n^3 + 2 * n :=
begin
sorry
end
theorem induction_sum_1oktkp1
(n : ℕ) :
∑ k in (finset.range n), (1:ℝ) / ((k + 1) * (k + 2)) = n / (n + 1) :=
begin
sorry
end
theorem mathd_numbertheory_32
(h₀ : fintype { n : ℕ | n ∣ 36}) :
∑ k in { n : ℕ | n ∣ 36}.to_finset, k = 91 :=
begin
sorry
end
theorem mathd_algebra_422
(x : ℝ)
(σ : equiv ℝ ℝ)
(h₀ : ∀ x, σ.1 x = 5 * x - 12)
(h₁ : σ.1 (x + 1) = σ.2 x) :
x = 47 / 24 :=
begin
field_simp [h₀, mul_add, add_mul, sub_add_cancel, mul_assoc, add_comm],
have := congr_arg σ.to_fun h₁,
rw h₀ at this,
rw h₀ at this,
symmetry,
norm_num at this,
linarith,
end
theorem amc12b_2002_p11
(a b : ℕ)
(h₀ : nat.prime a)
(h₁ : nat.prime b)
(h₂ : nat.prime (a + b))
(h₃ : nat.prime (a - b)) :
nat.prime (a + b + (a - b + (a + b))) :=
begin
sorry
end
theorem mathd_algebra_73
(p q r x : ℂ)
(h₀ : (x - p) * (x - q) = (r - p) * (r - q))
(h₁ : x ≠ r) :
x = p + q - r :=
begin
sorry
end
theorem mathd_numbertheory_109
(v : ℕ → ℕ)
(h₀ : ∀ n, v n = 2 * n - 1) :
(∑ k in (finset.erase (finset.range 101) 0), v k) % 7 = 4 :=
begin
norm_num,
simp [h₀],
rw finset.sum_erase,
swap,
{ simp, },
norm_num [finset.sum_range_succ, h₀],
end
theorem algebra_xmysqpymzsqpzmxsqeqxyz_xpypzp6dvdx3y3z3
(x y z : ℤ)
(h₀ : (x - y)^2 + (y - z)^2 + (z - x)^2 = x * y * z) :
(x + y + z + 6) ∣ (x^3 + y^3 + z^3) :=
begin
sorry
end
theorem imo_1962_p4
(x : ℝ)
(h₀ : (real.cos x)^2 + (real.cos (2 * x))^2 + (real.cos (3 * x))^2 = 1) :
(∃ m : ℤ, x = π / 2 + m * π) ∨ (∃ m : ℤ, x = π / 4 + m * π / 2) ∨ (∃ m : ℤ, x = π / 6 + m * π / 3) :=
begin
sorry
end
theorem mathd_numbertheory_236 :
(1999^2000) % 5 = 1 :=
begin
sorry
end
theorem mathd_numbertheory_24 :
(∑ k in (finset.erase (finset.range 10) 0), 11^k) % 100 = 59 :=
begin
norm_num,
rw finset.sum_eq_multiset_sum,
norm_num,
end
theorem algebra_amgm_prod1toneq1_sum1tongeqn
(a : ℕ → nnreal)
(n : ℕ)
(h₀ : finset.prod (finset.range(n)) a = 1) :
finset.sum (finset.range(n)) a ≥ n :=
begin
sorry
end
theorem mathd_algebra_101
(x : ℝ)
(h₀ : x^2 - 5 * x - 4 ≤ 10) :
x ≥ -2 ∧ x ≤ 7 :=
begin
split; nlinarith,
end
theorem mathd_numbertheory_257
(x : ℕ)
(h₀ : 1 ≤ x ∧ x ≤ 100)
(h₁ : 77∣(∑ k in (finset.range 101), k - x)) :
x = 45 :=
begin
sorry
end
theorem amc12_2000_p5
(x p : ℝ)
(h₀ : x < 2)
(h₁ : abs (x - 2) = p) :
x - p = 2 - 2 * p :=
begin
suffices : abs (x - 2) = -(x - 2),
{
rw h₁ at this,
linarith,
},
apply abs_of_neg,
linarith,
end
theorem mathd_algebra_547
(x y : ℝ)
(h₀ : x = 5)
(h₁ : y = 2) :
real.sqrt (x^3 - 2^y) = 11 :=
begin
sorry
end
theorem mathd_numbertheory_200 :
139 % 11 = 7 :=
begin
norm_num,
end
theorem mathd_algebra_510
(x y : ℝ)
(h₀ : x + y = 13)
(h₁ : x * y = 24) :
real.sqrt (x^2 + y^2) = 11 :=
begin
sorry
end
theorem mathd_algebra_140
(a b c : ℝ)
(h₀ : 0 < a ∧ 0 < b ∧ 0 < c)
(h₁ : ∀ x, 24 * x^2 - 19 * x - 35 = (((a * x) - 5) * ((2 * (b * x)) + c))) :
a * b - 3 * c = -9 :=
begin
have h₂ := h₁ 0,
have h₂ := h₁ 1,
have h₃ := h₁ (-1),
linarith,
end
theorem mathd_algebra_455
(x : ℝ)
(h₀ : 2 * (2 * (2 * (2 * x))) = 48) :
x = 3 :=
begin
linarith,
end
theorem mathd_numbertheory_45 :
(nat.gcd 6432 132) + 11 = 23 :=
begin
simp only [nat.gcd_comm],
norm_num,
end
theorem aime_1994_p4
(n : ℕ)
(h₀ : 0 < n)
(h₀ : ∑ k in finset.range (n + 1) \ finset.range 1, int.floor (real.log k / real.log 2) = 1994) :
n = 312 :=
begin
sorry
end
theorem mathd_numbertheory_739 :
(nat.factorial 9) % 10 = 0 :=
begin
norm_num,
end
theorem mathd_algebra_245
(x : ℝ)
(h₀ : x ≠ 0) :
(4 / x)⁻¹ * ((3 * x^3) / x)^2 * ((1 / (2 * x))⁻¹)^3 = 18 * x^8 :=
begin
field_simp [(show x ≠ 0, by simpa using h₀), mul_comm x]; ring,
end
theorem algebra_apb4leq8ta4pb4
(a b : ℝ)
(h₀ : 0 < a ∧ 0 < b) :
(a + b)^4 ≤ 8 * (a^4 + b^4) :=
begin
sorry
end
theorem mathd_algebra_28
(c : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = 2 * x^2 + 5 * x + c)
(h₁ : ∃ x, f x ≤ 0) :
c ≤ 25/8 :=
begin
sorry
end
theorem mathd_numbertheory_543 :
(∑ k in (nat.divisors (30^4)), 1) - 2 = 123 :=
begin
sorry
end
theorem mathd_algebra_480
(f : ℝ → ℝ)
(h₀ : ∀ x < 0, f x = -(x^2) - 1)
(h₁ : ∀ x, 0 ≤ x ∧ x < 4 → f x = 2)
(h₂ : ∀ x ≥ 4, f x = real.sqrt x) :
f π = 2 :=
begin
sorry
end
theorem mathd_algebra_69
(r s : ℕ+)
(h₀ : ↑r * ↑s = (450:ℤ))
(h₁ : (↑r + 5) * (↑s - 3) = (450:ℤ)) :
r = 25 :=
begin
sorry
end
theorem mathd_algebra_433
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = 3 * real.sqrt (2 * x - 7) - 8) :
f 8 = 1 :=
begin
sorry
end
theorem mathd_algebra_126
(x y : ℝ)
(h₀ : 2 * 3 = x - 9)
(h₁ : 2 * (-5) = y + 1) :
x = 15 ∧ y = -11 :=
begin
split; linarith,
end
theorem aimeII_2020_p6
(t : ℕ+ → ℚ)
(h₀ : t 1 = 20)
(h₁ : t 2 = 21)
(h₂ : ∀ n ≥ 3, t n = (5 * t (n - 1) + 1) / (25 * t (n - 2))) :
↑(t 2020).denom + (t 2020).num = 626 :=
begin
sorry
end
theorem amc12a_2008_p2
(x : ℝ)
(h₀ : x * (1 / 2 + 2 / 3) = 1) :
x = 6 / 7 :=
begin
linarith,
end
theorem mathd_algebra_35
(p q : ℝ → ℝ)
(h₀ : ∀ x, p x = 2 - x^2)
(h₁ : ∀ x≠0, q x = 6 / x) :
p (q 2) = -7 :=
begin
rw [h₀, h₁],
ring,
linarith,
end
theorem algebra_amgm_faxinrrp2msqrt2geq2mxm1div2x :
∀ x > 0, 2 - real.sqrt 2 ≥ 2 - x - 1 / (2 * x) :=
begin
intros x h,
suffices : real.sqrt 2 ≤ x + 1 / (2 * x), linarith,
have h₀ := (nnreal.geom_mean_le_arith_mean2_weighted (1/2) (1/2) (real.to_nnreal x) (real.to_nnreal (1/(2 * x)))) _,
norm_num at h₀,
rw [← nnreal.mul_rpow, ← real.to_nnreal_mul] at h₀,
have h₁ : x * (1 / (2 * x)) = 1 / 2, {
rw [mul_div_comm, one_mul, div_eq_div_iff],
ring,
apply ne_of_gt,
repeat {linarith,},
},
rw h₁ at h₀,
have h₂ : real.to_nnreal (1/2)^((1:ℝ)/2) = real.to_nnreal ((1/2)^((1:ℝ)/2)), {
refine nnreal.coe_eq.mp _,
rw [real.coe_to_nnreal, nnreal.coe_rpow, real.coe_to_nnreal],
linarith,
apply le_of_lt,
exact real.rpow_pos_of_pos (by norm_num) _,
},
rw [h₂, ←nnreal.coe_le_coe, real.coe_to_nnreal, nnreal.coe_add, nnreal.coe_mul, nnreal.coe_mul, real.coe_to_nnreal, real.coe_to_nnreal] at h₀,
have h₃ : 2 * ((1 / 2)^((1:ℝ) / 2)) ≤ 2 * (↑((1:nnreal) / 2) * x + ↑((1:nnreal) / 2) * (1 / (2 * x))), {
refine (mul_le_mul_left _).mpr _,
linarith,
exact h₀,
},
have h₄ : 2 * ((1 / 2)^((1:ℝ) / 2)) = real.sqrt 2, {
rw [eq_comm, real.sqrt_eq_iff_mul_self_eq],
calc (2:ℝ) * (1 / (2:ℝ))^(1 / (2:ℝ)) * ((2:ℝ) * (1 / (2:ℝ))^(1 / (2:ℝ))) = (2:ℝ) * (2:ℝ) * ((1 / (2:ℝ))^(1 / (2:ℝ)) * (1 / (2:ℝ))^(1 / (2:ℝ))) : by {ring,}
... = (2:ℝ) * (2:ℝ) * (1 / (2:ℝ))^((1 / (2:ℝ)) + (1 / (2:ℝ))) : by {rw real.rpow_add, linarith,}
... = (2:ℝ) * (2:ℝ) * (1 / (2:ℝ))^(1:ℝ) : by {congr', apply add_halves,}
... = (2:ℝ) * (2:ℝ) * (1 / (2:ℝ)) : by {simp,}
... = (2:ℝ) : by {norm_num,},
linarith,
apply le_of_lt,
norm_num,
exact real.rpow_pos_of_pos (by norm_num) _,
},
have h₅ : 2 * (↑((1:nnreal) / 2) * x + ↑((1:nnreal) / 2) * (1 / (2 * x))) = x + 1 / (2 * x), {
rw [mul_add, ← mul_assoc, ← mul_assoc, nnreal.coe_div, nnreal.coe_one],
have h₆ : ↑(2:nnreal) = (2:ℝ), exact rfl,
rw h₆,
ring,
},
rwa [←h₄, ←h₅],
apply div_nonneg_iff.mpr,
left,
split,
repeat {linarith,},
apply le_of_lt,
exact real.rpow_pos_of_pos (by norm_num) _,
apply nnreal.add_halves,
end
theorem mathd_numbertheory_335
(n : ℕ)
(h₀ : n % 7 = 5) :
(5 * n) % 7 = 4 :=
begin
sorry
end
theorem mathd_numbertheory_35
(h₀ : fintype { n : ℕ | n ∣ (nat.sqrt 196)}) :
∑ k in { n : ℕ | n ∣ (nat.sqrt 196)}.to_finset, k = 24 :=
begin
sorry
end
theorem amc12a_2021_p7
(x : ℝ)
(y : ℝ) :
1 ≤ ((x * y) - 1)^2 + (x + y)^2 :=
begin
ring_nf,
nlinarith,
end
theorem mathd_algebra_327
(a : ℝ)
(h₀ : 1 / 5 * abs (9 + 2 * a) < 1) :
-7 < a ∧ a < -2 :=
begin
have h₁ := (mul_lt_mul_left (show 0 < (5:ℝ), by linarith)).mpr h₀,
have h₂ : abs (9 + 2 * a) < 5, linarith,
have h₃ := abs_lt.mp h₂,
cases h₃ with h₃ h₄,
split; nlinarith,
end
theorem aime_1984_p15
(x y z w : ℝ)
(h₀ : (x^2 / (2^2 - 1)) + (y^2 / (2^2 - 3^2)) + (z^2 / (2^2 - 5^2)) + (w^2 / (2^2 - 7^2)) = 1)
(h₁ : (x^2 / (4^2 - 1)) + (y^2 / (4^2 - 3^2)) + (z^2 / (4^2 - 5^2)) + (w^2 / (4^2 - 7^2)) = 1)
(h₂ : (x^2 / (6^2 - 1)) + (y^2 / (6^2 - 3^2)) + (z^2 / (6^2 - 5^2)) + (w^2 / (6^2 - 7^2)) = 1)
(h₃ : (x^2 / (8^2 - 1)) + (y^2 / (8^2 - 3^2)) + (z^2 / (8^2 - 5^2)) + (w^2 / (8^2 - 7^2)) = 1) :
x^2 + y^2 + z^2 + w^2 = 36 :=
begin
revert x y z w h₀ h₁ h₂ h₃,
ring_nf,
intros x y z w h,
intros h,
intros; linarith,
end
theorem algebra_amgm_sqrtxymulxmyeqxpy_xpygeq4
(x y : ℝ)
(h₀ : 0 < x ∧ 0 < y)
(h₁ : y ≤ x)
(h₂ : real.sqrt (x * y) * (x - y) = (x + y)) :
x + y ≥ 4 :=
begin
sorry
end
theorem amc12a_2002_p21
(u : ℕ → ℕ)
(h₀ : u 0 = 4)
(h₁ : u 1 = 7)
(h₂ : ∀ n ≥ 2, u (n + 2) = (u n + u (n + 1)) % 10) :
∀ n, ∑ k in finset.range(n), u k > 10000 → 1999 ≤ n :=
begin
sorry
end
theorem mathd_algebra_192
(q e d : ℂ)
(h₀ : q = 11 - (5 * complex.I))
(h₁ : e = 11 + (5 * complex.I))
(h₂ : d = 2 * complex.I) :
q * e * d = 292 * complex.I :=
begin
rw [h₀, h₁, h₂],
ring_nf,
rw [pow_two, complex.I_mul_I],
ring,
end
theorem amc12b_2002_p6
(a b : ℝ)
(h₀ : a ≠ 0 ∧ b ≠ 0)
(h₁ : ∀ x, x^2 + a * x + b = (x - a) * (x - b)) :
a = 1 ∧ b = -2 :=
begin
have h₂ := h₁ a,
have h₃ := h₁ b,
have h₄ := h₁ 0,
simp at *,
have h₅ : b * (1 - a) = 0, linarith,
simp at h₅,
cases h₅ with h₅ h₆,
exfalso,
exact absurd h₅ h₀.2,
have h₆ : a = 1, linarith,
split,
exact h₆,
rw h₆ at h₂,
linarith,
end
theorem mathd_numbertheory_102 :
(2^8) % 5 = 1 :=
begin
norm_num,
end
theorem amc12a_2010_p22
(x : ℝ) :
49 ≤ ∑ k in finset.range 120 \ finset.range 1, abs (↑k * x - 1) :=
begin
sorry
end
theorem mathd_numbertheory_81 :
71 % 3 = 2 :=
begin
norm_num,
end
theorem mathd_numbertheory_155 :
finset.card (finset.filter (λ x, x % 19 = 7) (finset.range 1000 \ finset.range 100)) = 52 :=
begin
sorry
end
theorem imo_1978_p5
(n : ℕ)
(p : ℕ+ → ℕ+)
(f : ℕ → ℕ+)
(h₀ : function.injective p)
(h₁ : ∀ n : ℕ+, f n = p n)
(h₁ : 0 < n) :
(∑ k in finset.range (n + 1) \ finset.range 1, (1:ℝ) / k) ≤ ∑ k in finset.range (n + 1) \ finset.range 1, (f k) / k^2 :=
begin
sorry
end
theorem amc12a_2017_p7
(f : ℕ → ℝ)
(h₀ : f 1 = 2)
(h₁ : ∀ n, 1 < n ∧ even n → f n = f (n - 1) + 1)
(h₂ : ∀ n, 1 < n ∧ odd n → f n = f (n - 2) + 2) :
f 2017 = 2018 :=
begin
sorry
end
theorem mathd_numbertheory_42
(u v : ℕ+)
(h₀ : 27 * ↑u % 40 = 17)
(h₁ : 27 * ↑v % 40 = 17)
(h₂ : u < 40)
(h₃ : v < 80)
(h₄ : 40 < v) :
(u + v) = 62 :=
begin
sorry
end
theorem mathd_algebra_110
(q e : ℂ)
(h₀ : q = 2 - 2 * complex.I)
(h₁ : e = 5 + 5 * complex.I) :
q * e = 20 :=
begin
rw [h₀, h₁],
ring_nf,
rw [pow_two, complex.I_mul_I],
ring,
end
theorem amc12b_2021_p21
(h₀ : fintype {x : ℝ | 0 < x ∧ x^((2:ℝ)^real.sqrt 2) = (real.sqrt 2)^((2:ℝ)^x)}) :
↑2 ≤ ∑ k in {x : ℝ | 0 < x ∧ x^((2:ℝ)^real.sqrt 2) = (real.sqrt 2)^((2:ℝ)^x)}.to_finset, k ∧ ∑ k in {x : ℝ | 0 < x ∧ x^((2:ℝ)^real.sqrt 2) = (real.sqrt 2)^((2:ℝ)^x)}.to_finset, k < 6 :=
begin
sorry
end
theorem mathd_algebra_405
(x : ℕ)
(h₀ : 0 < x)
(h₁ : x^2 + 4 * x + 4 < 20) :
x = 1 ∨ x = 2 :=
begin
sorry
end
theorem numbertheory_sumkmulnckeqnmul2pownm1
(n : ℕ)
(h₀ : 0 < n) :
∑ k in finset.range (n + 1) \ finset.range 1, (k * nat.choose n k) = n * 2^(n - 1) :=
begin
sorry
end
theorem mathd_algebra_393
(σ : equiv ℝ ℝ)
(h₀ : ∀ x, σ.1 x = 4 * x^3 + 1) :
σ.2 33 = 2 :=
begin
sorry
end
theorem amc12b_2004_p3
(x y : ℕ)
(h₀ : 2^x * 3^y = 1296) :
x + y = 8 :=
begin
sorry
end
theorem mathd_numbertheory_303
(h₀ : fintype {n : ℕ | 2 ≤ n ∧ 171 ≡ 80 [MOD n] ∧ 468 ≡ 13 [MOD n]}) :
∑ k in {n : ℕ | 2 ≤ n ∧ 171 ≡ 80 [MOD n] ∧ 468 ≡ 13 [MOD n]}.to_finset, k = 111 :=
begin
sorry
end
theorem mathd_algebra_151 :
int.ceil (real.sqrt 27) - int.floor (real.sqrt 26) = 1 :=
begin
sorry
end
theorem amc12a_2011_p18
(x y : ℝ)
(h₀ : abs (x + y) + abs (x - y) = 2) :
x^2 - 6 * x + y^2 ≤ 9 :=
begin
sorry
end
theorem mathd_algebra_15
(s : ℕ+ → ℕ+ → ℕ+)
(h₀ : ∀ a b, s a b = a^(b:ℕ) + b^(a:ℕ)) :
s 2 6 = 100 :=
begin
rw h₀,
refl,
end
theorem mathd_numbertheory_211 :
finset.card (finset.filter (λ n, 6 ∣ (4 * ↑n - (2:ℤ))) (finset.range 60)) = 20 :=
begin
-- apply le_antisymm,
-- -- haveI := classical.prop_decidable,
-- swap,
-- dec_trivial!,
-- apply le_trans,
-- swap,
-- apply nat.le_of_dvd,
-- { norm_num, },
-- -- haveI := classical.dec,
-- simp,
sorry
end
theorem mathd_numbertheory_640 :
(91145 + 91146 + 91147 + 91148) % 4 = 2 :=
begin
norm_num,
end
theorem amc12b_2003_p6
(a r : ℝ)
(u : ℕ → ℝ)
(h₀ : ∀ k, u k = a * r^k)
(h₁ : u 1 = 2)
(h₂ : u 3 = 6) :
u 0 = 2 / real.sqrt 3 ∨ u 0 = - (2 / real.sqrt 3) :=
begin
sorry
end
theorem algebra_2rootsintpoly_am10tap11eqasqpam110
(a : ℂ) :
(a - 10) * (a + 11) = a^2 + a - 110 :=
begin
ring,
end
theorem aime_1991_p1
(x y : ℕ)
(h₀ : 0 < x ∧ 0 < y)
(h₁ : x * y + (x + y) = 71)
(h₂ : x^2 * y + x * y^2 = 880) :
x^2 + y^2 = 146 :=
begin
sorry
end
theorem mathd_algebra_43
(a b : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = a * x + b)
(h₁ : f 7 = 4)
(h₂ : f 6 = 3) :
f 3 = 0 :=
begin
rw h₀ at *,
linarith,
end
theorem imo_1988_p6
(a b : ℕ)
(h₀ : 0 < a ∧ 0 < b)
(h₁ : (a * b + 1) ∣ (a^2 + b^2)) :
∃ x : ℕ, (x^2:ℝ) = (a^2 + b^2) / (a*b + 1) :=
begin
sorry
end
theorem aime_1996_p5
(a b c r s t : ℝ)
(f g : ℝ → ℝ)
(h₀ : ∀ x, f x = x^3 + 3 * x^2 + 4 * x - 11)
(h₁ : ∀ x, g x = x^3 + r * x^2 + s * x + t)
(h₂ : f a = 0)
(h₃ : f b = 0)
(h₄ : f c = 0)
(h₅ : g (a + b) = 0)
(h₆ : g (b + c) = 0)
(h₇ : g (c + a) = 0) :
t = 23 :=
begin
sorry
end
theorem mathd_algebra_55
(q p : ℝ)
(h₀ : q = 2 - 4 + 6 - 8 + 10 - 12 + 14)
(h₁ : p = 3 - 6 + 9 - 12 + 15 - 18 + 21) :
q / p = 2 / 3 :=
begin
rw [h₀, h₁],
ring,
end
theorem algebra_sqineq_2at2pclta2c2p41pc
(a c : ℝ) :
2 * a * (2 + c) ≤ a^2 + c^2 + 4 * (1 + c) :=
begin
suffices : 0 ≤ (c - a)^2 + 2^2 + 2 * 2 * (c - a), nlinarith,
suffices : 0 ≤ (c - a + 2)^2, nlinarith,
exact pow_two_nonneg (c - a + 2),
end
theorem mathd_numbertheory_43
(n : ℕ+)
(h₀ : 15^(n:ℕ) ∣ nat.factorial 942)
(h₁ : ∀ m, 15^(m:ℕ) ∣ nat.factorial 942 → m ≤ n) :
n = 233 :=
begin
sorry
end
theorem mathd_algebra_214
(a : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = a * (x - 2)^2 + 3)
(h₁ : f 4 = 4) :
f 6 = 7 :=
begin
revert h₁,
simp [h₀],
intro,
nlinarith,
end
theorem mathd_algebra_96
(x y z a : ℝ)
(h₀ : 0 < x ∧ 0 < y ∧ 0 < z ∧ 0 < a)
(h₁ : real.log x - real.log y = a)
(h₂ : real.log y - real.log z = 15)
(h₃ : real.log z - real.log x = -7) :
a = -8 :=
begin
nlinarith [h₁, h₂, h₃],
end
theorem amc12_2001_p2
(a b n : ℕ)
(h₀ : 1 ≤ a ∧ a ≤ 9)
(h₁ : 0 ≤ b ∧ b ≤ 9)
(h₂ : n = 10 * a + b)
(h₃ : n = a * b + a + b) :
b = 9 :=
begin
rw h₂ at h₃,
simp at h₃,
have h₄ : 10 * a = (b + 1) * a, linarith,
simp at h₄,
cases h₄ with h₅ h₆,
linarith,
exfalso,
simp [*, le_refl] at *,
end
theorem mathd_algebra_185
(s: finset ℤ)
(f : ℤ → ℤ)
(h₀ : ∀ x, f x = abs (x + 4))
(h₁ : ∀ x, x ∈ s ↔ f x < 9) :
s.card = 17 :=
begin
sorry
end
theorem algebra_binomnegdiscrineq_10alt28asqp1
(a : ℝ) :
10 * a ≤ 28 * a^2 + 1 :=
begin
sorry
end
theorem mathd_numbertheory_284
(a b : ℕ)
(h₀ : 1 ≤ a ∧ a ≤ 9 ∧ b ≤ 9)
(h₁ : 10 * a + b = 2 * (a + b)) :
10 * a + b = 18 :=
begin
sorry
end
theorem amc12a_2009_p2 :
1 + (1 / (1 + (1 / (1 + 1)))) = (5:ℝ) / 3 :=
begin
norm_num,
end
theorem mathd_numbertheory_709
(n : ℕ+)
(h₀ : finset.card (nat.divisors (2*n)) = 28)
(h₁ : finset.card (nat.divisors (3*n)) = 30) :
finset.card (nat.divisors (6*n)) = 35 :=
begin
sorry
end
theorem amc12a_2013_p8
(x y : ℝ)
(h₀ : x ≠ 0)
(h₁ : y ≠ 0)
(h₂ : x ≠ y)
(h₃ : x + 2 / x = y + 2 / y) :
x * y = 2 :=
begin
sorry
end
theorem mathd_numbertheory_461
(n : ℕ)
(h₀ : n = finset.card (finset.filter (λ x, gcd x 8 = 1) (finset.range 8 \ finset.range 1))) :
(3^n) % 8 = 1 :=
begin
sorry
end
theorem mathd_algebra_59
(b : ℝ)
(h₀ : (4:ℝ)^b + 2^3 = 12) :
b = 1 :=
begin
have h₁ : (4:ℝ)^b = 4, linarith,
by_contradiction h,
clear h₀,
change b ≠ 1 at h,
by_cases b₀ : b < 1,
have key₁ : (4:ℝ)^b < (4:ℝ)^(1:ℝ), {
apply real.rpow_lt_rpow_of_exponent_lt _ _,
linarith,
exact b₀,
},
simp at key₁,
have key₂ : (4:ℝ)^b ≠ (4:ℝ), {
exact ne_of_lt key₁,
},
exact h (false.rec (b = 1) (key₂ h₁)),
have key₃ : 1 < b, {
refine h.symm.le_iff_lt.mp _,
exact not_lt.mp b₀,
},
have key₄ : (4:ℝ)^(1:ℝ) < (4:ℝ)^b, {
apply real.rpow_lt_rpow_of_exponent_lt _ _,
linarith,
exact key₃,
},
simp at key₄,
have key₂ : (4:ℝ)^b ≠ (4:ℝ), {
rw ne_comm,
exact ne_of_lt key₄,
},
exact h (false.rec (b = 1) (key₂ h₁)),
end
theorem mathd_algebra_234
(d : ℝ)
(h₀ : 27 / 125 * d = 9 / 25) :
3 / 5 * d^3 = 25 / 9 :=
begin
field_simp,
rw [mul_right_comm, pow_succ, mul_comm],
{ nlinarith },
end
theorem imo_1973_p3
(a b : ℝ)
(h₀ : ∃ x, x^4 + a * x^3 + b * x^2 + a * x + 1 = 0) :
4 / 5 ≤ a^2 + b^2 :=
begin
sorry
end
theorem amc12b_2020_p5
(a b : ℕ+)
(h₀ : (5:ℝ) / 8 * b - 2 / 3 * a = 7)
(h₁ : ↑b - (5:ℝ) / 8 * b - (a - 2 / 3 * a) = 7) :
a = 42 :=
begin
sorry
end
theorem numbertheory_sqmod3in01d
(a : ℤ) :
(a^2) % 3 = 0 ∨ (a^2) % 3 = 1 :=
begin
sorry
end
theorem mathd_algebra_131
(a b : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = 2 * x^2 - 7 * x + 2)
(h₁ : f a = 0)
(h₂ : f b = 0)
(h₃ : a ≠ b) :
1 / (a - 1) + 1 / (b - 1) = -1 :=
begin
sorry
end
theorem amc12b_2003_p17
(x y : ℝ)
(h₀ : 0 < x ∧ 0 < y)
(h₁ : real.log (x * y^3) = 1)
(h₂ : real.log (x^2 * y) = 1) :
real.log (x * y) = 3 / 5 :=
begin
sorry
end
theorem mathd_algebra_536 :
↑3! * ((2:ℝ)^3 + real.sqrt 9) / 2 = (33:ℝ) :=
begin
sorry
end
theorem mathd_algebra_22 :
real.log (5^4) / real.log (5^2)= 2 :=
begin
sorry
end
theorem numbertheory_xsqpysqintdenomeq
(x y : ℚ)
(h₀ : (x^2 + y^2).denom = 1) :
x.denom = y.denom :=
begin
sorry
end
theorem aimeI_2001_p3
(x : ℕ+ → ℤ)
(h₀ : x 1 = 211)
(h₂ : x 2 = 375)
(h₃ : x 3 = 420)
(h₄ : x 4 = 523)
(h₆ : ∀ n ≥ 5, x n = x (n - 1) - x (n - 2) + x (n - 3) - x (n - 4)) :
x 531 + x 753 + x 975 = 898 :=
begin
sorry
end
theorem mathd_numbertheory_22
(b : ℕ)
(h₀ : b < 10)
(h₁ : nat.sqrt (10 * b + 6) * nat.sqrt (10 * b + 6) = 10 * b + 6) :
b = 3 ∨ b = 1 :=
begin
sorry
end
theorem aime_1987_p8
(n : ℕ)
(h₀ : 0 < n)
(h₁ : ∃! k, (8:ℝ) / 15 < n / (n + k) ∧ (n:ℝ) / (n + k) < 7 / 13) :
n ≤ 112 :=
begin
sorry
end
theorem mathd_numbertheory_136
(n : ℕ)
(h₀ : 123 * n + 17 = 39500) : n = 321 :=
begin
linarith,
end
theorem amc12_2000_p11
(a b : ℝ)
(h₀ : a ≠ 0 ∧ b ≠ 0)
(h₁ : a * b = a - b) :
a / b + b / a - a * b = 2 :=
begin
field_simp [h₀.1, h₀.2],
simp only [h₁, mul_comm, mul_sub],
ring,
end
theorem amc12b_2003_p9
(a b : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = a * x + b)
(h₁ : f 6 - f 2 = 12) :
f 12 - f 2 = 30 :=
begin
revert h₁,
simp only [h₀],
intro,
linarith,
end
theorem algebra_2complexrootspoly_xsqp49eqxp7itxpn7i
(x : ℂ) :
x^2 + 49 = (x + (7 * complex.I)) * (x + (-7 * complex.I)) :=
begin
ring_nf,
ring_nf,
rw [pow_two, pow_two, complex.I_mul_I],
ring,
end
theorem mathd_numbertheory_198 :
(5^2005) % 100 = 25 :=
begin
sorry
end
theorem mathd_algebra_149
(f : ℝ → ℝ)
(h₀ : ∀ x < -5, f x = x^2 + 5)
(h₁ : ∀ x ≥ -5, f x = 3 * x -8)
(h₂ : fintype (f⁻¹' {10})) :
∑ k in (f⁻¹' {10}).to_finset, k = 6 :=
begin
sorry
end
theorem mathd_algebra_132
(x : ℝ)
(f g : ℝ → ℝ)
(h₀ : ∀ x, f x = x + 2)
(h₁ : ∀ x, g x = x^2)
(h₂ : f (g x) = g (f x)) :
x = - 1/2 :=
begin
norm_num,
simp [*, -one_div] at *,
field_simp [h₁],
linarith,
end
theorem mathd_numbertheory_37 :
(nat.lcm 9999 100001) = 90900909 :=
begin
let e : empty → fin 1 → ℕ := λ _, 1,
have : fintype.card (fin 1) = 1 := fintype.card_fin 1,
unfold nat.lcm,
have : fintype.card (fin 1) = 1 := fintype.card_fin 1,
simp only [eq_comm] at this,
rw this,
simp [bit1],
norm_num,
end
theorem aime_1983_p9
(x : ℝ)
(h₀ : 0 < x ∧ x < real.pi) :
12 ≤ ((9 * (x^2 * (real.sin x)^2)) + 4) / (x * real.sin x) :=
begin
let y := x * real.sin x,
rw ← mul_pow,
change 12 ≤ (9 * y^2 + 4) / y,
refine (le_div_iff _).mpr _,
apply mul_pos h₀.1,
apply real.sin_pos_of_pos_of_lt_pi h₀.1 h₀.2,
suffices : 0 ≤ (3 * y - 2)^2, nlinarith,
exact pow_two_nonneg (3 * y - 2),
end
theorem mathd_algebra_37
(x y : ℝ)
(h₀ : x + y = 7)
(h₁ : 3 * x + y = 45) :
x^2 - y^2 = 217 :=
begin
nlinarith,
end
theorem mathd_numbertheory_458
(n : ℕ)
(h₀ : n % 8 = 7) :
n % 4 = 3 :=
begin
sorry
end
theorem amc12a_2008_p15
(k : ℕ)
(h₀ : k = 2008^2 + 2^2008) :
(k^2 + 2^k) % 10 = 6 :=
begin
sorry
end
theorem mathd_numbertheory_301
(j : ℕ+) :
(3 * (7 * ↑j + 3)) % 7 = 2 :=
begin
calc 3 * (7 * ↑j + 3) % 7 = (3 * 3 + (3 * ↑j) * 7) % 7 : by {ring_nf}
... = (3 * 3) % 7 : by {apply nat.add_mul_mod_self_right}
... = 2 : by {norm_num},
end
theorem amc12a_2009_p15
(n : ℕ)
(h₀ : 0 < n)
(h₁ : ∑ k in finset.erase (finset.range (n + 1)) 0, (↑k * (complex.I^k)) = 48 + 49 * complex.I) :
n = 97 :=
begin
sorry
end
theorem algebra_sqineq_36azm9asqle36zsq
(z a : ℝ) :
36 * (a * z) - 9 * a^2 ≤ 36 * z^2 :=
begin
suffices : 4 * (a * z) - a^2 ≤ 4 * z^2, nlinarith,
suffices : 0 ≤ (a - 2 * z)^2, nlinarith,
exact pow_two_nonneg (a - 2 * z),
end
theorem amc12a_2013_p7
(s : ℕ → ℝ)
(h₀: ∀ n, s (n + 2) = s (n + 1) + s n)
(h₁ : s 9 = 110)
(h₂ : s 7 = 42) :
s 4 = 10 :=
begin
sorry
end
theorem mathd_algebra_104
(x : ℝ)
(h₀ : 125 / 8 = x / 12) :
x = 375 / 2 :=
begin
linarith,
end
theorem mathd_numbertheory_252 :
(nat.factorial 7) % 23 = 3 :=
begin
sorry
end
theorem amc12a_2020_p22
(h₀ : fintype {n : ℕ | 5∣n ∧ nat.lcm (nat.factorial 5) n = 5 * nat.gcd (nat.factorial 10) n}) :
finset.card {n : ℕ | 5∣n ∧ nat.lcm (nat.factorial 5) n = 5 * nat.gcd (nat.factorial 10) n}.to_finset = 1 :=
begin
sorry
end
theorem mathd_algebra_493
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = x^2 - 4 * real.sqrt x + 1) :
f (f 4) = 70 :=
begin
sorry
end
theorem numbertheory_nckeqnm1ckpnm1ckm1
(n k : ℕ)
(h₀ : 0 < n ∧ 0 < k)
(h₁ : k ≤ n) :
nat.choose n k = nat.choose (n - 1) k + nat.choose (n - 1) (k - 1) :=
begin
sorry
end
theorem algebra_3rootspoly_amdtamctambeqnasqmbpctapcbtdpasqmbpctapcbta
(b c d a : ℂ) :
(a-d) * (a-c) * (a-b) = -(((a^2 - (b+c) * a) + c * b) * d) + (a^2 - (b+c) * a + c * b) * a :=
begin
ring,
end
theorem mathd_numbertheory_403 :
∑ k in (nat.proper_divisors 198), k = 270 :=
begin
sorry
end
theorem mathd_algebra_190 :
((3:ℝ) / 8 + 7 / 8) / (4 / 5) = 25 / 16 :=
begin
norm_num,
end
theorem mathd_numbertheory_269 :
(2005^2 + 2005^0 + 2005^0 + 2005^5) % 100 = 52 :=
begin
sorry
end
theorem aime_1990_p2 :
(52 + 6 * real.sqrt 43)^((3:ℝ) / 2) - (52 - 6 * real.sqrt 43)^((3:ℝ) / 2) = 828 :=
begin
sorry
end
theorem mathd_numbertheory_101 :
(17 * 18) % 4 = 2 :=
begin
norm_num,
end
theorem algebra_sqineq_4bap1lt4bsqpap1sq
(a b : ℝ) :
4 * b * (a + 1) ≤ 4 * b^2 + (a + 1)^2 :=
begin
suffices : 0 ≤ (2 * b - (a + 1))^2, nlinarith,
exact pow_two_nonneg (2 * b - (a + 1)),
end
theorem mathd_numbertheory_156
(n : ℕ+) :
nat.gcd (n + 7) (2 * n + 1) ≤ 13 :=
begin
sorry
end
theorem mathd_algebra_451
(σ : equiv ℝ ℝ)
(h₀ : σ.2 (-15) = 0)
(h₁ : σ.2 0 = 3)
(h₂ : σ.2 3 = 9)
(h₃ : σ.2 9 = 20) :
σ.1 (σ.1 9) = 0 :=
begin
sorry
end
theorem mathd_algebra_144
(a b c d : ℕ+)
(h₀ : (c:ℤ) - (b:ℤ) = (d:ℤ))
(h₁ : (b:ℤ) - (a:ℤ) = (d:ℤ))
(h₂ : a + b + c = 60)
(h₃ : a + b > c) :
d < 10 :=
begin
sorry
end
theorem mathd_algebra_282
(f : ℝ → ℝ)
(h₀ : ∀ x, (¬ irrational x) → f x = abs (int.floor x))
(h₁ : ∀ x, (irrational x) → f x = (int.ceil x)^2) :
f (8^(1/3)) + f (-real.pi) + f (real.sqrt 50) + f (9/2) = 79 :=
begin
sorry
end
theorem mathd_algebra_410
(x y : ℝ)
(h₀ : y = x^2 - 6 * x + 13) :
4 ≤ y :=
begin
sorry
end
theorem mathd_numbertheory_232
(x y z : zmod 31)
(h₀ : x = 3⁻¹)
(h₁ : y = 5⁻¹)
(h₂ : z = (x + y)⁻¹) :
z = 29 :=
begin
sorry
end
theorem mathd_algebra_77
(a b : ℝ)
(f : ℝ → ℝ)
(h₀ : a ≠ 0 ∧ b ≠ 0)
(h₁ : ∀ x, f x = x^2 + a * x + b)
(h₂ : f a = 0)
(h₃ : f b = 0) :
a = 1 ∧ b = -2 :=
begin
sorry
end
theorem imo_1974_p5
(a b c d s : ℝ)
(h₀ : s = a / (a + b + d) + b / (a + b + c) + c / (b + c + d) + d / (a + c + d)) :
1 < s ∧ s < 2 :=
begin
sorry
end
theorem aime_1988_p3
(x : ℝ)
(h₀ : 0 < x)
(h₁ : real.log (real.log x / real.log 8) / real.log 2 = real.log (real.log x / real.log 2) / real.log 8) :
(real.log x / real.log 2)^2 = 27 :=
begin
sorry
end
theorem mathd_numbertheory_530
(n k : ℕ+)
(h₀ : ↑n / ↑k < (6:ℝ))
(h₁ : (5:ℝ) < ↑n / ↑k) :
22 ≤ (nat.lcm n k) / (nat.gcd n k) :=
begin
sorry
end
theorem mathd_algebra_109
(a b : ℝ)
(h₀ : 3 * a + 2 * b = 12)
(h₁ : a = 4) :
b = 0 :=
begin
linarith,
end
theorem imo_1967_p3
(k m n : ℕ)
(c : ℕ → ℕ)
(h₀ : 0 < k ∧ 0 < m ∧ 0 < n)
(h₁ : ∀ s, c s = s * (s + 1))
(h₂ : nat.prime (k + m + 1))
(h₃ : n + 1 < k + m + 1) :
(∏ i in finset.range (n + 1) \ finset.range 1, c i) ∣ (∏ i in finset.range (n + 1) \ finset.range 1, (c (m + i) - c k)) :=
begin
sorry
end
theorem mathd_algebra_11
(a b : ℝ)
(h₀ : a ≠ b)
(h₁ : a ≠ 2*b)
(h₂ : (4 * a + 3 * b) / (a - 2 * b) = 5) :
(a + 11 * b) / (a - b) = 2 :=
begin
rw eq_comm,
refine (eq_div_iff _).mpr _,
exact sub_ne_zero_of_ne h₀,
rw eq_comm at h₂,
suffices : a = 13 * b, linarith,
have key : 5 * (a - 2 * b) = (4 * a + 3 * b), rwa (eq_div_iff (sub_ne_zero_of_ne h₁)).mp,
linarith,
end
theorem amc12a_2003_p1
(u v : ℕ → ℕ)
(h₀ : ∀ n, u n = 2 * n + 2)
(h₁ : ∀ n, v n = 2 * n + 1) :
(∑ k in finset.range(2003), u k) - (∑ k in finset.range(2003), v k) = 2003 :=
begin
sorry
end
theorem numbertheory_aneqprodakp4_anmsqrtanp1eq2
(a : ℕ → ℝ)
(h₀ : a 0 = 1)
(h₁ : ∀ n, a (n + 1) = (∏ k in finset.range (n + 1), (a k)) + 4) :
∀ n ≥ 1, a n - real.sqrt (a (n + 1)) = 2 :=
begin
sorry
end
theorem algebra_2rootspoly_apatapbeq2asqp2ab
(a b : ℂ) :
(a + a) * (a + b) = 2 * a^2 + 2 * (a * b) :=
begin
ring,
end
theorem induction_sum_odd
(n : ℕ) :
∑ k in (finset.range n), 2 * k + 1 = n^2 :=
begin
sorry
end
theorem mathd_algebra_568
(a : ℝ) :
(a - 1) * (a + 1) * (a + 2) - (a - 2) * (a + 1) = a^3 + a^2 :=
begin
linarith,
end
theorem mathd_algebra_616
(f g : ℝ → ℝ)
(h₀ : ∀ x, f x = x^3 + 2 * x + 1)
(h₁ : ∀ x, g x = x - 1) :
f (g 1) = 1 :=
begin
sorry
end
theorem mathd_numbertheory_690 :
is_least {a : ℕ+ | a ≡ 2 [MOD 3] ∧ a ≡ 4 [MOD 5] ∧ a ≡ 6 [MOD 7] ∧ a ≡ 8 [MOD 9]} 314 :=
begin
sorry
end
theorem amc12a_2016_p2
(x : ℝ)
(h₀ : (10:ℝ)^x * 100^(2 * x) = 1000^5) :
x = 3 :=
begin
sorry
end
theorem mathd_numbertheory_405
(a b c : ℕ)
(t : ℕ → ℕ)
(h₀ : t 0 = 0)
(h₁ : t 1 = 1)
(h₂ : ∀ n > 1, t n = t (n - 2) + t (n - 1))
(h₃ : a ≡ 5 [MOD 16])
(h₄ : b ≡ 10 [MOD 16])
(h₅ : c ≡ 15 [MOD 16]) :
(t a + t b + t c) % 7 = 5 :=
begin
sorry
end
theorem mathd_numbertheory_110
(a b : ℕ)
(h₀ : 0 < a ∧ 0 < b ∧ b ≤ a)
(h₁ : (a + b) % 10 = 2)
(h₂ : (2 * a + b) % 10 = 1) :
(a - b) % 10 = 6 :=
begin
sorry
end
theorem amc12a_2003_p25
(a b : ℝ)
(f : ℝ → ℝ)
(h₀ : 0 < b)
(h₁ : ∀ x, f x = real.sqrt (a * x^2 + b * x))
(h₂ : {x | 0 ≤ f x} = f '' {x | 0 ≤ f x}) :
a = 0 ∨ a = -4 :=
begin
sorry
end
theorem amc12a_2010_p10
(p q : ℝ)
(a : ℕ → ℝ)
(h₀ : ∀ n, a (n + 2) - a (n + 1) = a (n + 1) - a n)
(h₁ : a 1 = p)
(h₂ : a 2 = 9)
(h₃ : a 3 = 3 * p - q)
(h₄ : a 4 = 3 * p + q) :
a 2010 = 8041 :=
begin
sorry
end
theorem mathd_algebra_509 :
real.sqrt ((5 / real.sqrt 80 + real.sqrt 845 / 9 + real.sqrt 45) / real.sqrt 5) = 13 / 6 :=
begin
sorry
end
theorem mathd_algebra_159
(b : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = 3 * x^4 - 7 * x^3 + 2 * x^2 - b * x + 1)
(h₁ : f 1 = 1) :
b = -2 :=
begin
rw h₀ at h₁,
linarith,
end
theorem aime_1997_p12
(x : ℝ)
(h₀ : x = (∑ n in finset.range 45 \ finset.range 1, real.cos (n * π / 180)) / (∑ n in finset.range 45 \ finset.range 1, real.sin (n * π / 180))) :
int.floor (100 * x) = 241 :=
begin
sorry
end
theorem aimeI_2000_p7
(x y z : ℝ)
(m : ℚ)
(h₀ : 0 < x ∧ 0 < y ∧ 0 < z)
(h₁ : x * y * z = 1)
(h₂ : x + 1 / z = 5)
(h₃ : y + 1 / x = 29)
(h₄ : z + 1 / y = m)
(h₅ : 0 < m) :
↑m.denom + m.num = 5 :=
begin
sorry
end
theorem aime_1988_p4
(n : ℕ)
(a : ℕ → ℝ)
(h₀ : ∀ n, abs (a n) < 1)
(h₁ : ∑ k in finset.range n, (abs (a k)) = 19 + abs (∑ k in finset.range n, a k)) :
20 ≤ n :=
begin
sorry
end
theorem induction_divisibility_9div10tonm1
(n : ℕ+) :
9 ∣(10^(n:ℕ) - 1) :=
begin
sorry
end
theorem mathd_numbertheory_126
(x a : ℕ+)
(h₀ : nat.gcd a 40 = x + 3)
(h₁ : nat.lcm a 40 = x * (x + 3))
(h₂ : ∀ b : ℕ+, nat.gcd b 40 = x + 3 ∧ nat.lcm b 40 = x * (x + 3) → a ≤ b) :
a = 8 :=
begin
sorry
end
theorem mathd_algebra_323
(σ : equiv ℝ ℝ)
(h : ∀ x, σ.1 x = x^3 - 8) :
σ.2 (σ.1 (σ.2 19)) = 3 :=
begin
revert h,
simp,
intro h,
apply σ.injective,
simp [h, σ.apply_symm_apply],
norm_num,
end
theorem mathd_algebra_421
(a b c d : ℝ)
(h₀ : b = a^2 + 4 * a + 6)
(h₁ : b = 1 / 2 * a^2 + a + 6)
(h₂ : d = c^2 + 4 * c + 6)
(h₃ : d = 1 / 2 * c^2 + c + 6)
(h₄ : a ≤ c) :
c - a = 6 :=
begin
sorry
end
theorem imo_1987_p6
(p : ℕ)
(f : ℕ → ℕ)
(h₀ : ∀ x, f x = x^2 + x + p)
(h₀ : ∀ k : ℕ, k ≤ nat.floor (real.sqrt (p / 3)) → nat.prime (f k)) :
∀ i ≤ p - 2, nat.prime (f i) :=
begin
sorry
end
theorem amc12a_2009_p25
(a : ℕ+ → ℝ)
(h₀ : a 1 = 1)
(h₁ : a 2 = 1 / real.sqrt 3)
(h₂ : ∀ n, a (n + 2) = (a n + a (n + 1)) / (1 - a n * a (n + 1))) :
abs (a 2009) = 0 :=
begin
sorry
end
theorem imo_1961_p1
(x y z a b : ℝ)
(h₀ : 0 < x ∧ 0 < y ∧ 0 < z)
(h₁ : x ≠ y)
(h₂ : y ≠ z)
(h₃ : z ≠ x)
(h₄ : x + y + z = a)
(h₅ : x^2 + y^2 + z^2 = b^2)
(h₆ : x * y = z^2) :
0 < a ∧ b^2 < a^2 ∧ a^2 < 3 * b^2 :=
begin
sorry
end
theorem mathd_algebra_31
(x : nnreal)
(u : ℕ → nnreal)
(h₀ : ∀ n, u (n + 1) = nnreal.sqrt (x + u n))
(h₁ : filter.tendsto u filter.at_top (𝓝 9)) :
9 = nnreal.sqrt (x + 9) :=
begin
sorry
end
theorem algebra_manipexpr_apbeq2cceqiacpbceqm2
(a b c : ℂ)
(h₀ : a + b = 2 * c)
(h₁ : c = complex.I) :
a * c + b * c = -2 :=
begin
rw [← add_mul, h₀, h₁, mul_assoc, complex.I_mul_I],
ring,
end
theorem mathd_numbertheory_370
(n : ℕ)
(h₀ : n % 7 = 3) :
(2 * n + 1) % 7 = 0 :=
begin
sorry
end
theorem mathd_algebra_437
(x y : ℝ)
(n : ℤ)
(h₀ : x^3 = -45)
(h₁ : y^3 = -101)
(h₂ : x < n)
(h₃ : ↑n < y) :
n = -4 :=
begin
sorry
end
theorem imo_1966_p5
(x a : ℕ → ℝ)
(h₀ : a 1 ≠ a 2)
(h₁ : a 1 ≠ a 3)
(h₂ : a 1 ≠ a 4)
(h₃ : a 2 ≠ a 3)
(h₄ : a 2 ≠ a 4)
(h₅ : a 3 ≠ a 4)
(h₆ : abs (a 1 - a 2) * x 2 + abs (a 1 - a 3) * x 3 + abs (a 1 - a 4) * x 4 = 1)
(h₇ : abs (a 2 - a 1) * x 1 + abs (a 2 - a 3) * x 3 + abs (a 2 - a 4) * x 4 = 1)
(h₈ : abs (a 3 - a 1) * x 1 + abs (a 3 - a 2) * x 2 + abs (a 3 - a 4) * x 4 = 1)
(h₉ : abs (a 4 - a 1) * x 1 + abs (a 4 - a 2) * x 2 + abs (a 4 - a 3) * x 3 = 1) :
x 2 = 0 ∧ x 3 = 0 ∧ x 1 = 1 / abs (a 1 - a 4) ∧ x 4 = 1 / abs (a 1 - a 4) :=
begin
sorry
end
theorem mathd_algebra_89
(b : ℝ)
(h₀ : b ≠ 0) :
(7 * b^3)^2 * (4 * b^2)^(-(3:ℤ)) = 49 / 64 :=
begin
ring_nf,
field_simp,
norm_cast,
refine (div_eq_iff _).mpr _,
{ norm_num,
assumption },
ring,
end
theorem imo_1966_p4
(n : ℕ)
(x : ℝ)
(h₀ : ∀ k : ℕ+, ∀ m : ℤ, x ≠ m * π / (2^(k:ℕ)))
(h₁ : 0 < n) :
∑ k in finset.range (n + 1) \ finset.range 1, (1 / real.sin ((2^k) * x)) = 1 / real.tan x - 1 / real.tan ((2^n) * x) :=
begin
sorry
end
theorem mathd_algebra_67
(f g : ℝ → ℝ)
(h₀ : ∀ x, f x = 5 * x + 3)
(h₁ : ∀ x, g x = x^2 - 2) :
g (f (-1)) = 2 :=
begin
rw [h₀, h₁],
ring,
end
theorem mathd_numbertheory_326
(n : ℕ)
(h₀ : (↑n - 1) * ↑n * (↑n + 1) = (720:ℤ)) :
(n + 1) = 10 :=
begin
sorry
end
theorem induction_divisibility_3div2tooddnp1
(n : ℕ) :
3 ∣ (2^(2 * n + 1) + 1) :=
begin
sorry
end
theorem mathd_algebra_123
(a b : ℕ+)
(h₀ : a + b = 20)
(h₁ : a = 3 * b) :
a - b = 10 :=
begin
rw h₁ at h₀,
rw h₁,
have h₂ : 3 * (b:ℕ) + (b:ℕ) = (20:ℕ), {
exact subtype.mk.inj h₀,
},
have h₃ : (b:ℕ) = 5, linarith,
have h₄ : b = 5, {
exact pnat.eq h₃,
},
rw h₄,
calc (3:ℕ+) * 5 - 5 = 15 - 5 : by {congr,}
... = 10 : by {exact rfl},
end
theorem algebra_2varlineareq_xpeeq7_2xpeeq3_eeq11_xeqn4
(x e : ℂ)
(h₀ : x + e = 7)
(h₁ : 2 * x + e = 3) :
e = 11 ∧ x = -4 :=
begin
sorry
end
theorem imo_1993_p5 :
∃ f : ℕ+ → ℕ+, (∀ a b, (a < b) ↔ f a < f b) ∧ f 1 = 2 ∧ ∀ n, f (f n) = f n + n :=
begin
sorry
end
theorem numbertheory_prmdvsneqnsqmodpeq0
(n : ℤ)
(p : ℕ)
(h₀ : nat.prime p) :
↑p ∣ n ↔ (n^2) % p = 0 :=
begin
simp [nat.dvd_prime_pow (show nat.prime p, from h₀), pow_succ],
simp only [int.coe_nat_dvd_right, int.coe_nat_dvd_left, int.nat_abs_mul],
rw nat.prime.dvd_mul,
{ tauto },
assumption,
end
theorem imo_1964_p1_1
(n : ℕ)
(h₀ : 7 ∣ (2^n - 1)) :
3 ∣ n :=
begin
sorry
end
theorem imo_1990_p3
(n : ℕ)
(h₀ : 2 ≤ n)
(h₁ : n^2 ∣ 2^n + 1) :
n = 3 :=
begin
sorry
end
theorem induction_ineq_nsqlefactn
(n : ℕ)
(h₀ : 4 ≤ n) :
n^2 ≤ n! :=
begin
simp only [sq],
casesI n with n,
exact dec_trivial,
simp,
apply nat.succ_le_of_lt,
apply nat.lt_factorial_self,
exact nat.succ_le_succ_iff.mp h₀,
end
theorem mathd_numbertheory_30 :
(33818^2 + 33819^2 + 33820^2 + 33821^2 + 33822^2) % 17 = 0 :=
begin
norm_num,
end
theorem mathd_algebra_267
(x : ℝ)
(h₀ : x ≠ 1)
(h₁ : x ≠ -2)
(h₂ : (x + 1) / (x - 1) = (x - 2) / (x + 2)) :
x = 0 :=
begin
revert x h₀ h₁ h₂,
norm_num,
intros a ha,
intros ha,
intro h,
rw ← sub_eq_zero at *,
simp,
field_simp at *,
linarith,
end
theorem mathd_numbertheory_961 :
2003 % 11 = 1 :=
begin
norm_num,
end
theorem induction_seq_mul2pnp1
(n : ℕ)
(u : ℕ → ℕ)
(h₀ : u 0 = 0)
(h₁ : ∀ n, u (n + 1) = 2 * u n + (n + 1)) :
u n = 2^(n + 1) - (n + 2) :=
begin
sorry
end
theorem amc12a_2002_p12
(f : ℝ → ℝ)
(k : ℝ)
(h₀ : ∀ x, f x = x^2 - 63 * x + k)
(h₁ : set.subset (f ⁻¹' {0}) { x : ℝ | ∃ n : ℕ, ↑n = x ∧ nat.prime n}) :
k = 122 :=
begin
sorry
end
theorem algebra_manipexpr_2erprsqpesqeqnrpnesq
(e r : ℂ) :
2 * (e * r) + (e^2 + r^2) = (-r + (-e))^2 :=
begin
ring,
end
theorem mathd_algebra_119
(d e : ℝ)
(h₀ : 2 * d = 17 * e - 8)
(h₁ : 2 * e = d - 9) :
e = 2 :=
begin
linarith,
end
theorem amc12a_2020_p13
(a b c : ℕ)
(n : nnreal)
(h₀ : n ≠ 1)
(h₁ : 1 < a ∧ 1 < b ∧ 1 < c)
(h₂ : (n * ((n * (n^(1 / c)))^(1 / b)))^(1 / a) = (n^25)^(1 / 36)) :
b = 3 :=
begin
sorry
end
theorem imo_1977_p5
(a b q r : ℕ)
(h₀ : r < a + b)
(h₁ : a^2 + b^2 = (a + b) * q + r)
(h₂ : q^2 + r = 1977) :
(abs ((a:ℤ) - 22) = 15 ∧ abs ((b:ℤ) - 22) = 28) ∨ (abs ((a:ℤ) - 22) = 28 ∧ abs ((b:ℤ) - 22) = 15) :=
begin
sorry
end
theorem numbertheory_2dvd4expn
(n : ℕ)
(h₀ : n ≠ 0) :
2 ∣ 4^n :=
begin
revert n h₀,
rintros ⟨k, rfl⟩,
{ norm_num },
apply dvd_pow,
norm_num,
end
theorem amc12a_2010_p11
(x b : ℝ)
(h₀ : 0 < b)
(h₁ : (7:ℝ)^(x + 7) = 8^x)
(h₂ : x = real.log (7^7) / real.log b) :
b = 8 / 7 :=
begin
sorry
end
theorem amc12a_2003_p24
(a b : ℝ)
(h₀ : b ≤ a)
(h₁ : 1 < b) :
real.log (a / b) / real.log a + real.log (b / a) / real.log b ≤ 0 :=
begin
sorry
end
theorem amc12a_2002_p1
(f : ℂ → ℂ)
(h₀ : ∀ x, f x = (2 * x + 3) * (x - 4) + (2 * x + 3) * (x - 6))
(h₁ : fintype (f ⁻¹' {0})) :
∑ y in (f⁻¹' {0}).to_finset, y = 7 / 2 :=
begin
sorry
end
theorem mathd_algebra_206
(a b : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f x = x^2 + a * x + b)
(h₁ : 2 * a ≠ b)
(h₂ : f (2 * a) = 0)
(h₃ : f b = 0) :
a + b = -1 :=
begin
sorry
end
theorem mathd_numbertheory_92
(n : ℕ)
(h₀ : (5 * n) % 17 = 8) :
n % 17 = 5 :=
begin
sorry
end
theorem mathd_algebra_482
(m n : ℕ)
(k : ℝ)
(f : ℝ → ℝ)
(h₀ : nat.prime m)
(h₁ : nat.prime n)
(h₂ : ∀ x, f x = x^2 - 12 * x + k)
(h₃ : f m = 0)
(h₄ : f n = 0)
(h₅ : m ≠ n) :
k = 35 :=
begin
sorry
end
theorem amc12b_2002_p3
(n : ℕ)
(h₀ : 0 < n)
-- note: we use this over (n^2 - 3 * n + 2) because nat subtraction truncates the latter at 1 and 2
(h₁ : nat.prime (n^2 + 2 - 3 * n)) :
n = 3 :=
begin
sorry
end
theorem mathd_numbertheory_668
(l r : zmod 7)
(h₀ : l = (2 + 3)⁻¹)
(h₁ : r = 2⁻¹ + 3⁻¹) :
l - r = 1 :=
begin
sorry
end
theorem mathd_algebra_251
(x : ℝ)
(h₀ : x ≠ 0)
(h₁ : 3 + 1 / x = 7 / x) :
x = 2 :=
begin
field_simp [h₀] at h₁,
linarith,
end
theorem mathd_numbertheory_84 :
int.floor ((9:ℝ) / 160 * 100) = 5 :=
begin
rw int.floor_eq_iff,
split,
all_goals { norm_num },
end
theorem mathd_numbertheory_412
(x y : ℕ)
(h₀ : x % 19 = 4)
(h₁ : y % 19 = 7) :
((x + 1)^2 * (y + 5)^3) % 19 = 13 :=
begin
sorry
end
theorem mathd_algebra_181
(n : ℝ)
(h₀ : n ≠ 3)
(h₁ : (n + 5) / (n - 3) = 2) : n = 11 :=
begin
rw div_eq_iff at h₁,
linarith,
exact sub_ne_zero.mpr h₀,
end
theorem amc12a_2016_p3
(f : ℝ → ℝ → ℝ)
(h₀ : ∀ x, ∀ y ≠ 0, f x y = x - y * int.floor (x / y)) :
f (3 / 8) (-(2 / 5)) = -(1 / 40) :=
begin
sorry
end
theorem mathd_algebra_247
(t s : ℝ)
(n : ℤ)
(h₀ : t = 2 * s - s^2)
(h₁ : s = n^2 - 2^n + 1)
(n = 3) :
t = 0 :=
begin
sorry
end
theorem algebra_sqineq_2unitcircatblt1
(a b : ℝ)
(h₀ : a^2 + b^2 = 2) :
a * b ≤ 1 :=
begin
have hu := sq_nonneg a,
have hv := sq_nonneg b,
have H₁ := add_nonneg hu hv,
have H₂ : 0 ≤ (a - b) ^ 2 := by nlinarith,
nlinarith,
end
theorem mathd_numbertheory_629 :
is_least {t : ℕ+ | (nat.lcm 12 t)^3 = (12 * t)^2} 18 :=
begin
sorry
end
theorem amc12a_2017_p2
(x y : ℝ)
(h₀ : x ≠ 0)
(h₁ : y ≠ 0)
(h₂ : x + y = 4 * (x * y)) :
1 / x + 1 / y = 4 :=
begin
sorry
end
theorem algebra_amgm_sumasqdivbsqgeqsumbdiva
(a b c : ℝ)
(h₀ : 0 < a ∧ 0 < b ∧ 0 < c) :
a^2 / b^2 + b^2 / c^2 + c^2 / a^2 ≥ b / a + c / b + a / c :=
begin
sorry
end
theorem mathd_numbertheory_202 :
(19^19 + 99^99) % 10 = 8 :=
begin
sorry
end
theorem imo_1979_p1
(p q : ℕ)
(h₀ : 0 < q)
(h₁ : ∑ k in finset.range 1320 \ finset.range 1, ((-1)^(k + 1) * ((1:ℝ) / k)) = p / q) :
1979 ∣ p :=
begin
sorry
end
theorem mathd_algebra_51
(a b : ℝ)
(h₀ : 0 < a ∧ 0 < b)
(h₁ : a + b = 35)
(h₂ : a = (2/5) * b) :
b - a = 15 :=
begin
linarith,
end
theorem mathd_algebra_10 :
abs ((120:ℝ) / 100 * 30 - 130 / 100 * 20) = 10 :=
begin
norm_num,
end
|
Foil plaid lycra and spandex shortall with metallic slinky insets. Attached metallic elastic belt with O-ring. Headband included. Great hip hop or jazz dance costume. Made in the USA. |
module UniDB.Morph.Sim where
open import UniDB.Spec
open import UniDB.Subst.Core
open import UniDB.Morph.Depth
import Level
open import Relation.Binary.PropositionalEquality
--------------------------------------------------------------------------------
record Sim (T : STX) (γ₁ γ₂ : Dom) : Set where
constructor sim
field
lk-sim : (i : Ix γ₁) → T γ₂
open Sim public
module _ {T : STX} where
instance
iLkSim : {{vrT : Vr T}} → Lk T (Sim T)
lk {{iLkSim}} = lk-sim
iWkSim : {{wkT : Wk T}} → {γ₁ : Dom} → Wk (Sim T γ₁)
wk₁ {{iWkSim}} (sim f) = sim (wk₁ ∘ f)
wk {{iWkSim}} δ (sim f) = sim (wk δ ∘ f)
wk-zero {{iWkSim {{wkT}}}} (sim f) = cong sim (ext (wk-zero {T} ∘ f))
where postulate ext : Extensionality Level.zero Level.zero
wk-suc {{iWkSim}} δ (sim f) = cong sim (ext (wk-suc {T} δ ∘ f))
where postulate ext : Extensionality Level.zero Level.zero
iSnocSim : Snoc T (Sim T)
snoc {{iSnocSim}} (sim f) t = sim λ
{ zero → t
; (suc i) → f i
}
iUpSim : {{vrT : Vr T}} {{wkT : Wk T}} → Up (Sim T)
_↑₁ {{iUpSim}} ξ = snoc {T} {Sim T} (wk₁ ξ) (vr {T} zero)
_↑_ {{iUpSim}} ξ 0 = ξ
_↑_ {{iUpSim}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁
↑-zero {{iUpSim}} ξ = refl
↑-suc {{iUpSim}} ξ δ⁺ = refl
iIdmSim : {{vrT : Vr T}} → Idm (Sim T)
idm {{iIdmSim}} γ = sim (vr {T})
iWkmSim : {{vrT : Vr T}} → Wkm (Sim T)
wkm {{iWkmSim}} δ = sim (vr {T} ∘ wk δ)
iBetaSim : {{vrT : Vr T}} → Beta T (Sim T)
beta {{iBetaSim}} t = snoc {T} {Sim T} (idm {Sim T} _) t
iCompSim : {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} → Comp (Sim T)
lk-sim (_⊙_ {{iCompSim}} ξ ζ) i =
ap {T} {T} {Sim T} ζ (lk {T} {Sim T} ξ i)
iLkUpSim : {{vrT : Vr T}} {{wkT : Wk T}} → LkUp T (Sim T)
lk-↑₁-zero {{iLkUpSim}} ξ = refl
lk-↑₁-suc {{iLkUpSim}} ξ zero = refl
lk-↑₁-suc {{iLkUpSim}} ξ (suc i) = refl
iLkWkmSim : {{vrT : Vr T}} → LkWkm T (Sim T)
lk-wkm {{iLkWkmSim}} δ i = refl
iLkIdmSim : {{vrT : Vr T}} → LkIdm T (Sim T)
lk-idm {{iLkIdmSim}} i = refl
iLkCompSim : {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} → LkCompAp T (Sim T)
lk-⊙-ap {{iLkCompSim}} ξ₁ ξ₂ i = refl
--------------------------------------------------------------------------------
module SimIxInstances (T : STX) where
instance
iLkSimIx : {{vrT : Vr T}} → Lk T (Sim Ix)
lk {{iLkSimIx}} ξ i = vr {T} (lk {Ix} {Sim Ix} ξ i)
iLkUpSimIx : {{vrT : Vr T}} {{wkT : Wk T}}
{{wkVrT : WkVr T}} → LkUp T (Sim Ix)
lk-↑₁-zero {{iLkUpSimIx}} ξ = refl
lk-↑₁-suc {{iLkUpSimIx}} ξ i = sym (wk₁-vr {T} (lk {Ix} {Sim Ix} ξ i))
iLkWkmSimIx : {{vrT : Vr T}} → LkWkm T (Sim Ix)
lk-wkm {{iLkWkmSimIx}} δ i = refl
iLkIdmSimIx : {{vrT : Vr T}} → LkIdm T (Sim Ix)
lk-idm {{iLkIdmSimIx}} i = refl
iLkCompSimIx : {{vrT : Vr T}} {{apTT : Ap T T}}
{{apVrT : ApVr T}} → LkCompAp T (Sim Ix)
lk-⊙-ap {{iLkCompSimIx}} ξ₁ ξ₂ i =
sym (ap-vr {T} {Sim Ix} ξ₂ (lk {Ix} {Sim Ix} ξ₁ i))
--------------------------------------------------------------------------------
|
(* Title: ZF/AC/AC18_AC19.thy
Author: Krzysztof Grabczewski
The proof of AC1 ==> AC18 ==> AC19 ==> AC1
*)
theory AC18_AC19
imports AC_Equiv
begin
definition
uu :: "i => i" where
"uu(a) == {c \<union> {0}. c \<in> a}"
(* ********************************************************************** *)
(* AC1 ==> AC18 *)
(* ********************************************************************** *)
lemma PROD_subsets:
"[| f \<in> (\<Prod>b \<in> {P(a). a \<in> A}. b); \<forall>a \<in> A. P(a)<=Q(a) |]
==> (\<lambda>a \<in> A. f`P(a)) \<in> (\<Prod>a \<in> A. Q(a))"
by (rule lam_type, drule apply_type, auto)
lemma lemma_AC18:
"[| \<forall>A. 0 \<notin> A \<longrightarrow> (\<exists>f. f \<in> (\<Prod>X \<in> A. X)); A \<noteq> 0 |]
==> (\<Inter>a \<in> A. \<Union>b \<in> B(a). X(a, b)) \<subseteq>
(\<Union>f \<in> \<Prod>a \<in> A. B(a). \<Inter>a \<in> A. X(a, f`a))"
apply (rule subsetI)
apply (erule_tac x = "{{b \<in> B (a) . x \<in> X (a,b) }. a \<in> A}" in allE)
apply (erule impE, fast)
apply (erule exE)
apply (rule UN_I)
apply (fast elim!: PROD_subsets)
apply (simp, fast elim!: not_emptyE dest: apply_type [OF _ RepFunI])
done
lemma AC1_AC18: "AC1 ==> PROP AC18"
apply (unfold AC1_def)
apply (rule AC18.intro)
apply (fast elim!: lemma_AC18 apply_type intro!: equalityI INT_I UN_I)
done
(* ********************************************************************** *)
(* AC18 ==> AC19 *)
(* ********************************************************************** *)
theorem (in AC18) AC19
apply (unfold AC19_def)
apply (intro allI impI)
apply (rule AC18 [of _ "%x. x", THEN mp], blast)
done
(* ********************************************************************** *)
(* AC19 ==> AC1 *)
(* ********************************************************************** *)
lemma RepRep_conj:
"[| A \<noteq> 0; 0 \<notin> A |] ==> {uu(a). a \<in> A} \<noteq> 0 & 0 \<notin> {uu(a). a \<in> A}"
apply (unfold uu_def, auto)
apply (blast dest!: sym [THEN RepFun_eq_0_iff [THEN iffD1]])
done
lemma lemma1_1: "[|c \<in> a; x = c \<union> {0}; x \<notin> a |] ==> x - {0} \<in> a"
apply clarify
apply (rule subst_elem, assumption)
apply (fast elim: notE subst_elem)
done
lemma lemma1_2:
"[| f`(uu(a)) \<notin> a; f \<in> (\<Prod>B \<in> {uu(a). a \<in> A}. B); a \<in> A |]
==> f`(uu(a))-{0} \<in> a"
apply (unfold uu_def, fast elim!: lemma1_1 dest!: apply_type)
done
lemma lemma1: "\<exists>f. f \<in> (\<Prod>B \<in> {uu(a). a \<in> A}. B) ==> \<exists>f. f \<in> (\<Prod>B \<in> A. B)"
apply (erule exE)
apply (rule_tac x = "\<lambda>a\<in>A. if (f` (uu(a)) \<in> a, f` (uu(a)), f` (uu(a))-{0})"
in exI)
apply (rule lam_type)
apply (simp add: lemma1_2)
done
lemma lemma2_1: "a\<noteq>0 ==> 0 \<in> (\<Union>b \<in> uu(a). b)"
by (unfold uu_def, auto)
lemma lemma2: "[| A\<noteq>0; 0\<notin>A |] ==> (\<Inter>x \<in> {uu(a). a \<in> A}. \<Union>b \<in> x. b) \<noteq> 0"
apply (erule not_emptyE)
apply (rule_tac a = 0 in not_emptyI)
apply (fast intro!: lemma2_1)
done
lemma AC19_AC1: "AC19 ==> AC1"
apply (unfold AC19_def AC1_def, clarify)
apply (case_tac "A=0", force)
apply (erule_tac x = "{uu (a) . a \<in> A}" in allE)
apply (erule impE)
apply (erule RepRep_conj, assumption)
apply (rule lemma1)
apply (drule lemma2, assumption, auto)
done
end
|
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\hypersetup{colorlinks}
\usepackage{iftex}
\title{The iftex package}
\author{The \LaTeX\ Project Team\thanks{%
\url{https://github.com/latex3/iftex}}}
\date{\csname [email protected]\endcsname}
\newcommand\cs[1]{{\ttfamily\textbackslash #1}}
\renewcommand*\descriptionlabel[1]{\makebox[\dimexpr\textwidth][l]{%
\normalfont\bfseries #1}}
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
This original \textsf{iftex} was written as part of the \textsf{bidi}
collection (by the Persian TeX Group / Vafa Khalighi)
and provided checks for whether a document was being
processed with PDF\TeX, or Xe\TeX, or Lua\TeX. This version recodes
the package and incorporates similar tests from the \textsf{ifetex}
package by Martin Scharrer, the \textsf{ifxetex} package by Will
Robertson, the \textsf{ifluatex} and \textsf{ifvtex}
packages from Heiko Oberdiek and parts of \textsf{ifptex} by Takayuki
Yato.
For each \TeX\ variant engine supported two commands are provided:
\begin{itemize}
\item
a conditional, \verb|\iffootex| that is true if the \textsf(footex)
engine (or a compatible extension) is being used.
For compatibility with earlier packages which did not all use the same
naming convention all these conditionals are provided in two forms, a
lowercase name \verb|\iffootex| and a mixed case name \verb|\iffooTeX|.
\item a command \verb|RequireFooTeX| which checks that \textsf{footex}
is being used, and stops the run with an error message if a
different engine is detected.
\end{itemize}
\section{Loading the package}
The package can be loaded in the usual way in both Plain \TeX\ and \LaTeX.
\subsection{Loading the package in plain \TeX}
\begin{verbatim}
\input iftex.sty
\end{verbatim}
\subsection{Loading the package in \LaTeX}
\begin{verbatim}
\usepackage{iftex}
\end{verbatim}
\subsection{Loading the package in ini\TeX}
The package assumes no existing macros and may be loaded
during format setup in a format without the plain \TeX\ or \LaTeX\
format being loaded. From an initial ini\TeX\ setup the package may
be loaded as for plain \TeX.
\section{Engine test conditionals}
All the conditionals defined here are used in the same way:
\begin{verbatim}
\ifluatex
luatex specific code
\else
code for other engines
\fi
\end{verbatim}
\begin{description}
\item[\cs{ifetex}, \cs{ifeTeX}]
True if an e\TeX\ enabled format is in use. (This is necessarily true
in all \LaTeX\ variants.)
\item[\cs{ifpdftex}, \cs{ifPDFTeX}]
True if PDF\TeX\ is in use (whether writing PDF or DVI), so this is
true for documents processed with both the \textsf{latex} and
\textsf{pdflatex} commands.
\item[\cs{ifxetex}, \cs{ifXeTeX}]
True if Xe\TeX\ is in use.
\item[\cs{ifluatex}, \cs{ifLuaTeX}]
True if Lua\TeX\ and extensions such as LuaHB\TeX\ are in use.
\item[\cs{ifluahbtex}, \cs{ifLuaHBTeX}]
True if the \textsf{luaharftex} Lua module is available.
This will be true in \textsf{luahbtex} and may be true in
\textsf{luatex} if a binary Lua \textsf{luaharftex} module has been
compiled and is available in Lua's search path.
\item[\cs{ifptex}, \cs{ifpTeX}]
True if any of the p\TeX\ variants are in use.
\item[\cs{ifuptex}, \cs{ifupTeX}]
True if any of the up\TeX\ variants are in use. (\verb|\ifetex| could
be used in addition to distinguish \textsf{uptex} and \textsf{euptex}.)
\item[\cs{ifptexng}, \cs{ifpTeXng}]
True if p\TeX-ng (Asiatic p\TeX) is in use.
\item[\cs{ifvtex}, \cs{ifVTeX}]
True if V\TeX\ is in use.
\item[\cs{ifalephtex}, \cs{ifAlephTeX}]
True if Aleph is in use. (The \textsf{aleph}-based \LaTeX\ command is
\textsf{lamed}.)
\item[\cs{iftutex}, \cs{ifTUTeX}]
This is not strictly an engine variant, but it is true if
\verb|\Umathchardef| is available, which essentially means that it is
true for Lua\TeX\ and Xe\TeX, allowing constructs such as
\begin{verbatim}
\iftutex
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\usepackage{unicode-math}
\setmathfont{Stix Two Math}
\else
\usepackage{newtxtext,newtxmath}
\fi
\end{verbatim}
\item[\cs{iftexpadtex}, \cs{ifTexpadTeX}]
True if Texpad\TeX\ is in use. Please note that Texpad\TeX\ can run in two
modes, one which uses Unicode and native fonts internally (similar to
Xe\TeX\ and Lua\TeX), and one which uses 8-bit codepages internally (similar to
PDF\TeX). This can be determined using \cs{iftutex}.
\item[\cs{ifhint}, \cs{ifHINT}]
True if Hi\TeX\ (HINT output format) is in use.
\end{description}
\section{Requiring specific engines}
For each supported engine, the package provides a command
\verb|\Require...| which checks that the document is being processed
with a suitable engine, and stops with an error message if not.
\begin{description}
\item[\cs{RequireeTeX}]
\item[\cs{RequirePDFTeX}]
\item[\cs{RequireXeTeX}]
\item[\cs{RequireLuaTeX}]
\item[\cs{RequireLuaHBTeX}]
\item[\cs{RequirepTeX}]
\item[\cs{RequireupTeX}]
\item[\cs{RequirepTeXng}]
\item[\cs{RequireVTeX}]
\item[\cs{RequireAlephTeX}]
\item[\cs{RequireTUTeX}]
\item[\cs{RequireTexpadTeX}]
\item[\cs{RequireHINT}]
\end{description}
\section{Output mode conditional}
This package also provides an \verb|\ifpdf| conditional that is true
if the format is set up to output in PDF mode rather than DVI. This is
equivalent to the test in the existing \textsf{ifpdf} package.
Unlike the engine tests above this is defined as if by \verb|\newif|
with user-documented commands \verb|\pdftrue| and \verb|\pdffalse| that can
change the boolean value. These would be needed to reset the boolean
if the output mode is reset (for example by setting
\verb|\pdfoutput=0| in PDF\LaTeX).
Unlike the original \textsf{ifpdf} package, the version here also
detects PDF output mode if running in V\TeX.
\section{Additional packages}
This extended \textsf{iftex} is designed to replace the original
\textsf{iftex} and also the packages
\textsf{ifetex},
\textsf{ifluatex},
\textsf{ifvtex},
\textsf{ifxetex},
\textsf{ifpdf}.
This collection includes small packages with these names that include
the main \textsf{iftex} package, and in some cases define additional
commands for increased compatibility. These packages should mean that
authors do not need to change existing documents, although it is
recommended that new documents use the \textsf{iftex} package
directly.
Note that while this package provides basic support for detecting
p\TeX\ (Japanese \TeX) variants and is broadly compatible with the
\textsf{ifptex} package, the \textsf{ifptex} package has many more detailed
tests for p\TeX\ variants and this package does \emph{not} replace the
\textsf{ifptex} (or \textsf{ifxptex}) packages, which are maintained
by their original authors and recommended for Japanese documents that
need fine control over the Japanese \TeX\ system in use.
\section{Compatibility with \textsf{scrbase}}
The \textsf{scrbase} package (which is automatically included in the
popular \textsf{KOMA-Script} classes) by default defines
\verb|\ifpdftex| and \verb|\ifVTeX| with a different syntax. If you
use the \textsf{scrbase} option \verb|internalonly| then
\textsf{scrbase} will not define these and the definitions as
described here will take effect. This is recommended and will not
affect any \textsf{scrbase} package code as internally
\textsf{scrbase} uses private versions of those commands prefixed with
\verb|\scr@|. However this package detects if the \textsf{scrbase}
definitions are in effect and if so does not redefine them, for
compatibility with existing documents. The \textsf{iftex} versions
will still be available under the names \verb|\ifPDFTeX| and
\verb|\ifvtex|.
\end{document}
|
! { dg-do run }
! PR 20361 : We didn't check if a large equivalence actually fit on
! the stack, and therefore segfaulted at execution time
subroutine test
integer i(1000000), j
equivalence (i(50), j)
j = 1
if (i(50) /= j) STOP 1
end subroutine test
call test
end
|
Formal statement is: lemma cball_scale: assumes "a \<noteq> 0" shows "(\<lambda>x. a *\<^sub>R x) ` cball c r = cball (a *\<^sub>R c :: 'a :: real_normed_vector) (\<bar>a\<bar> * r)" Informal statement is: If $a \neq 0$, then the image of the closed ball of radius $r$ centered at $c$ under the map $x \mapsto a \cdot x$ is the closed ball of radius $\lvert a \rvert \cdot r$ centered at $a \cdot c$. |
(** * Logic: Logic in Coq *)
Require Export MoreCoq.
(** Coq's built-in logic is very small: the only primitives are
[Inductive] definitions, universal quantification ([forall]), and
implication ([->]), while all the other familiar logical
connectives -- conjunction, disjunction, negation, existential
quantification, even equality -- can be encoded using just these.
This chapter explains the encodings and shows how the tactics
we've seen can be used to carry out standard forms of logical
reasoning involving these connectives.
*)
(* ########################################################### *)
(** * Propositions *)
(** In previous chapters, we have seen many examples of factual
claims (_propositions_) and ways of presenting evidence of their
truth (_proofs_). In particular, we have worked extensively with
_equality propositions_ of the form [e1 = e2], with
implications ([P -> Q]), and with quantified propositions
([forall x, P]).
*)
(** In Coq, the type of things that can (potentially)
be proven is [Prop]. *)
(** Here is an example of a provable proposition: *)
Check (3 = 3).
(* ===> Prop *)
(** Here is an example of an unprovable proposition: *)
Check (forall (n:nat), n = 2).
(* ===> Prop *)
(** Recall that [Check] asks Coq to tell us the type of the indicated
expression. *)
(* ########################################################### *)
(** * Proofs and Evidence *)
(** In Coq, propositions have the same status as other types, such as
[nat]. Just as the natural numbers [0], [1], [2], etc. inhabit
the type [nat], a Coq proposition [P] is inhabited by its
_proofs_. We will refer to such inhabitants as _proof term_ or
_proof object_ or _evidence_ for the truth of [P].
In Coq, when we state and then prove a lemma such as:
Lemma silly : 0 * 3 = 0.
Proof. reflexivity. Qed.
the tactics we use within the [Proof]...[Qed] keywords tell Coq
how to construct a proof term that inhabits the proposition. In
this case, the proposition [0 * 3 = 0] is justified by a
combination of the _definition_ of [mult], which says that [0 * 3]
_simplifies_ to just [0], and the _reflexive_ principle of
equality, which says that [0 = 0].
*)
(** *** *)
Lemma silly : 0 * 3 = 0.
Proof. reflexivity. Qed.
(** We can see which proof term Coq constructs for a given Lemma by
using the [Print] directive: *)
Print silly.
(* ===> silly = eq_refl : 0 * 3 = 0 *)
(** Here, the [eq_refl] proof term witnesses the equality. (More on
equality later!)*)
(** ** Implications _are_ functions *)
(** Just as we can implement natural number multiplication as a
function:
[
mult : nat -> nat -> nat
]
The _proof term_ for an implication [P -> Q] is a _function_ that
takes evidence for [P] as input and produces evidence for [Q] as its
output.
*)
Lemma silly_implication : (1 + 1) = 2 -> 0 * 3 = 0.
Proof. intros H. reflexivity. Qed.
(** We can see that the proof term for the above lemma is indeed a
function: *)
Print silly_implication.
(* ===> silly_implication = fun _ : 1 + 1 = 2 => eq_refl
: 1 + 1 = 2 -> 0 * 3 = 0 *)
(** ** Defining propositions *)
(** Just as we can create user-defined inductive types (like the
lists, binary representations of natural numbers, etc., that we
seen before), we can also create _user-defined_ propositions.
Question: How do you define the meaning of a proposition?
*)
(** *** *)
(** The meaning of a proposition is given by _rules_ and _definitions_
that say how to construct _evidence_ for the truth of the
proposition from other evidence.
- Typically, rules are defined _inductively_, just like any other
datatype.
- Sometimes a proposition is declared to be true without
substantiating evidence. Such propositions are called _axioms_.
In this, and subsequence chapters, we'll see more about how these
proof terms work in more detail.
*)
(* ########################################################### *)
(** * Conjunction (Logical "and") *)
(** The logical conjunction of propositions [P] and [Q] can be
represented using an [Inductive] definition with one
constructor. *)
Inductive and (P Q : Prop) : Prop :=
conj : P -> Q -> (and P Q).
(** The intuition behind this definition is simple: to
construct evidence for [and P Q], we must provide evidence
for [P] and evidence for [Q]. More precisely:
- [conj p q] can be taken as evidence for [and P Q] if [p]
is evidence for [P] and [q] is evidence for [Q]; and
- this is the _only_ way to give evidence for [and P Q] --
that is, if someone gives us evidence for [and P Q], we
know it must have the form [conj p q], where [p] is
evidence for [P] and [q] is evidence for [Q].
Since we'll be using conjunction a lot, let's introduce a more
familiar-looking infix notation for it. *)
Notation "P /\ Q" := (and P Q) : type_scope.
(** (The [type_scope] annotation tells Coq that this notation
will be appearing in propositions, not values.) *)
(** Consider the "type" of the constructor [conj]: *)
Check conj.
(* ===> forall P Q : Prop, P -> Q -> P /\ Q *)
(** Notice that it takes 4 inputs -- namely the propositions [P]
and [Q] and evidence for [P] and [Q] -- and returns as output the
evidence of [P /\ Q]. *)
(** ** "Introducing" conjunctions *)
(** Besides the elegance of building everything up from a tiny
foundation, what's nice about defining conjunction this way is
that we can prove statements involving conjunction using the
tactics that we already know. For example, if the goal statement
is a conjuction, we can prove it by applying the single
constructor [conj], which (as can be seen from the type of [conj])
solves the current goal and leaves the two parts of the
conjunction as subgoals to be proved separately. *)
Theorem and_example :
(0 = 0) /\ (4 = mult 2 2).
Proof.
apply conj.
Case "left". reflexivity.
Case "right". reflexivity. Qed.
(** Just for convenience, we can use the tactic [split] as a shorthand for
[apply conj]. *)
Theorem and_example' :
(0 = 0) /\ (4 = mult 2 2).
Proof.
split.
Case "left". reflexivity.
Case "right". reflexivity. Qed.
(** ** "Eliminating" conjunctions *)
(** Conversely, the [destruct] tactic can be used to take a
conjunction hypothesis in the context, calculate what evidence
must have been used to build it, and add variables representing
this evidence to the proof context. *)
Theorem proj1 : forall P Q : Prop,
P /\ Q -> P.
Proof.
intros P Q H.
destruct H as [HP HQ].
apply HP. Qed.
(** **** Exercise: 1 star, optional (proj2) *)
Theorem proj2 : forall P Q : Prop,
P /\ Q -> Q.
Proof.
intros P Q H.
destruct H as [π1 π2].
apply π2.
Qed.
(** [] *)
Theorem and_commut : forall P Q : Prop,
P /\ Q -> Q /\ P.
Proof.
(* WORKED IN CLASS *)
intros P Q H.
destruct H as [HP HQ].
split.
Case "left". apply HQ.
Case "right". apply HP. Qed.
(** **** Exercise: 2 stars (and_assoc) *)
(** In the following proof, notice how the _nested pattern_ in the
[destruct] breaks the hypothesis [H : P /\ (Q /\ R)] down into
[HP: P], [HQ : Q], and [HR : R]. Finish the proof from there: *)
Theorem and_assoc : forall P Q R : Prop,
P /\ (Q /\ R) -> (P /\ Q) /\ R.
Proof.
intros P Q R H.
destruct H as [HP [HQ HR]].
split.
split.
apply HP.
apply HQ.
apply HR.
Qed.
(** [] *)
(* ###################################################### *)
(** * Iff *)
(** The handy "if and only if" connective is just the conjunction of
two implications. *)
Definition iff (P Q : Prop) := (P -> Q) /\ (Q -> P).
Notation "P <-> Q" := (iff P Q)
(at level 95, no associativity)
: type_scope.
Theorem iff_implies : forall P Q : Prop,
(P <-> Q) -> P -> Q.
Proof.
intros P Q H.
destruct H as [HAB HBA]. apply HAB. Qed.
Theorem iff_sym : forall P Q : Prop,
(P <-> Q) -> (Q <-> P).
Proof.
(* WORKED IN CLASS *)
intros P Q H.
destruct H as [HAB HBA].
split.
Case "->". apply HBA.
Case "<-". apply HAB. Qed.
(** **** Exercise: 1 star, optional (iff_properties) *)
(** Using the above proof that [<->] is symmetric ([iff_sym]) as
a guide, prove that it is also reflexive and transitive. *)
Theorem iff_refl : forall P : Prop,
P <-> P.
Proof.
intro p.
split.
apply self_implication.
apply self_implication.
Qed.
Theorem iff_trans : forall P Q R : Prop,
(P <-> Q) -> (Q <-> R) -> (P <-> R).
Proof.
intros P Q R bi1 bi2.
inversion bi1 as [PQ QP].
inversion bi2 as [QR RQ].
split.
intro HP. apply PQ in HP. apply QR in HP. apply HP.
intro HR. apply RQ in HR. apply QP in HR. apply HR.
Qed.
(** Hint: If you have an iff hypothesis in the context, you can use
[inversion] to break it into two separate implications. (Think
about why this works.) *)
(** [] *)
(** Some of Coq's tactics treat [iff] statements specially, thus
avoiding the need for some low-level manipulation when reasoning
with them. In particular, [rewrite] can be used with [iff]
statements, not just equalities. *)
(* ############################################################ *)
(** * Disjunction (Logical "or") *)
(** ** Implementing disjunction *)
(** Disjunction ("logical or") can also be defined as an
inductive proposition. *)
Inductive or (P Q : Prop) : Prop :=
| or_introl : P -> or P Q
| or_intror : Q -> or P Q.
Notation "P \/ Q" := (or P Q) : type_scope.
(** Consider the "type" of the constructor [or_introl]: *)
Check or_introl.
(* ===> forall P Q : Prop, P -> P \/ Q *)
(** It takes 3 inputs, namely the propositions [P], [Q] and
evidence of [P], and returns, as output, the evidence of [P \/ Q].
Next, look at the type of [or_intror]: *)
Check or_intror.
(* ===> forall P Q : Prop, Q -> P \/ Q *)
(** It is like [or_introl] but it requires evidence of [Q]
instead of evidence of [P]. *)
(** Intuitively, there are two ways of giving evidence for [P \/ Q]:
- give evidence for [P] (and say that it is [P] you are giving
evidence for -- this is the function of the [or_introl]
constructor), or
- give evidence for [Q], tagged with the [or_intror]
constructor. *)
(** *** *)
(** Since [P \/ Q] has two constructors, doing [destruct] on a
hypothesis of type [P \/ Q] yields two subgoals. *)
Theorem or_commut : forall P Q : Prop,
P \/ Q -> Q \/ P.
Proof.
intros P Q H.
destruct H as [HP | HQ].
Case "left". apply or_intror. apply HP.
Case "right". apply or_introl. apply HQ. Qed.
(** From here on, we'll use the shorthand tactics [left] and [right]
in place of [apply or_introl] and [apply or_intror]. *)
Theorem or_commut' : forall P Q : Prop,
P \/ Q -> Q \/ P.
Proof.
intros P Q H.
destruct H as [HP | HQ].
Case "left". right. apply HP.
Case "right". left. apply HQ. Qed.
Theorem or_distributes_over_and_1 : forall P Q R : Prop,
P \/ (Q /\ R) -> (P \/ Q) /\ (P \/ R).
Proof.
intros P Q R. intros H. destruct H as [HP | [HQ HR]].
Case "left". split.
SCase "left". left. apply HP.
SCase "right". left. apply HP.
Case "right". split.
SCase "left". right. apply HQ.
SCase "right". right. apply HR. Qed.
(** **** Exercise: 2 stars (or_distributes_over_and_2) *)
Theorem or_distributes_over_and_2 : forall P Q R : Prop,
(P \/ Q) /\ (P \/ R) -> P \/ (Q /\ R).
Proof.
intros P Q R H. destruct H as [[HP0 | HQ] [HP1 | HR]].
left. apply HP0.
left. apply HP0.
left. apply HP1.
right. split. apply HQ. apply HR.
Qed.
(** [] *)
(** **** Exercise: 1 star, optional (or_distributes_over_and) *)
Theorem or_distributes_over_and : forall P Q R : Prop,
P \/ (Q /\ R) <-> (P \/ Q) /\ (P \/ R).
Proof.
intros.
split.
apply or_distributes_over_and_1.
apply or_distributes_over_and_2.
Qed.
(** [] *)
(* ################################################### *)
(** ** Relating [/\] and [\/] with [andb] and [orb] *)
(** We've already seen several places where analogous structures
can be found in Coq's computational ([Type]) and logical ([Prop])
worlds. Here is one more: the boolean operators [andb] and [orb]
are clearly analogs of the logical connectives [/\] and [\/].
This analogy can be made more precise by the following theorems,
which show how to translate knowledge about [andb] and [orb]'s
behaviors on certain inputs into propositional facts about those
inputs. *)
Theorem andb_prop : forall b c,
andb b c = true -> b = true /\ c = true.
Proof.
(* WORKED IN CLASS *)
intros b c H.
destruct b.
Case "b = true". destruct c.
SCase "c = true". apply conj. reflexivity. reflexivity.
SCase "c = false". inversion H.
Case "b = false". inversion H. Qed.
Theorem andb_true_intro : forall b c,
b = true /\ c = true -> andb b c = true.
Proof.
(* WORKED IN CLASS *)
intros b c H.
destruct H.
rewrite H. rewrite H0. reflexivity. Qed.
(** **** Exercise: 2 stars, optional (andb_false) *)
Theorem andb_false : forall b c,
andb b c = false -> b = false \/ c = false.
Proof.
intros b c H.
destruct b,c.
inversion H.
right. reflexivity.
left. reflexivity.
left. reflexivity.
Qed.
(** **** Exercise: 2 stars, optional (orb_false) *)
Theorem orb_prop : forall b c,
orb b c = true -> b = true \/ c = true.
Proof.
intros b c H.
destruct b, c.
left. reflexivity.
left. reflexivity.
right. reflexivity.
inversion H.
Qed.
(** **** Exercise: 2 stars, optional (orb_false_elim) *)
Theorem orb_false_elim : forall b c,
orb b c = false -> b = false /\ c = false.
Proof.
intros b c H.
split.
destruct b. inversion H.
reflexivity.
destruct c. destruct b. inversion H.
inversion H.
reflexivity.
Qed.
(** [] *)
(* ################################################### *)
(** * Falsehood *)
(** Logical falsehood can be represented in Coq as an inductively
defined proposition with no constructors. *)
Inductive False : Prop := .
(** Intuition: [False] is a proposition for which there is no way
to give evidence. *)
(** Since [False] has no constructors, inverting an assumption
of type [False] always yields zero subgoals, allowing us to
immediately prove any goal. *)
Theorem False_implies_nonsense :
False -> 2 + 2 = 5.
Proof.
intros contra.
inversion contra. Qed.
(** How does this work? The [inversion] tactic breaks [contra] into
each of its possible cases, and yields a subgoal for each case.
As [contra] is evidence for [False], it has _no_ possible cases,
hence, there are no possible subgoals and the proof is done. *)
(** *** *)
(** Conversely, the only way to prove [False] is if there is already
something nonsensical or contradictory in the context: *)
Theorem nonsense_implies_False :
2 + 2 = 5 -> False.
Proof.
intros contra.
inversion contra. Qed.
(** Actually, since the proof of [False_implies_nonsense]
doesn't actually have anything to do with the specific nonsensical
thing being proved; it can easily be generalized to work for an
arbitrary [P]: *)
Theorem ex_falso_quodlibet : forall (P:Prop),
False -> P.
Proof.
(* WORKED IN CLASS *)
intros P contra.
inversion contra. Qed.
(** The Latin _ex falso quodlibet_ means, literally, "from
falsehood follows whatever you please." This theorem is also
known as the _principle of explosion_. *)
(* #################################################### *)
(** ** Truth *)
(** Since we have defined falsehood in Coq, one might wonder whether
it is possible to define truth in the same way. We can. *)
(** **** Exercise: 2 stars, advanced (True) *)
(** Define [True] as another inductively defined proposition. (The
intution is that [True] should be a proposition for which it is
trivial to give evidence.) *)
Inductive True : Prop :=
Truth : True.
(** [] *)
(** However, unlike [False], which we'll use extensively, [True] is
used fairly rarely. By itself, it is trivial (and therefore
uninteresting) to prove as a goal, and it carries no useful
information as a hypothesis. But it can be useful when defining
complex [Prop]s using conditionals, or as a parameter to
higher-order [Prop]s. *)
(* #################################################### *)
(** * Negation *)
(** The logical complement of a proposition [P] is written [not
P] or, for shorthand, [~P]: *)
Definition not (P:Prop) := P -> False.
(** The intuition is that, if [P] is not true, then anything at
all (even [False]) follows from assuming [P]. *)
Notation "~ x" := (not x) : type_scope.
Check not.
(* ===> Prop -> Prop *)
(** It takes a little practice to get used to working with
negation in Coq. Even though you can see perfectly well why
something is true, it can be a little hard at first to get things
into the right configuration so that Coq can see it! Here are
proofs of a few familiar facts about negation to get you warmed
up. *)
Theorem not_False :
~ False.
Proof.
unfold not. intros H. inversion H. Qed.
(** *** *)
Theorem contradiction_implies_anything : forall P Q : Prop,
(P /\ ~P) -> Q.
Proof.
(* WORKED IN CLASS *)
intros P Q H. destruct H as [HP HNA]. unfold not in HNA.
apply HNA in HP. inversion HP. Qed.
Theorem double_neg : forall P : Prop,
P -> ~~P.
Proof.
(* WORKED IN CLASS *)
intros P H. unfold not. intros G. apply G. apply H. Qed.
(** **** Exercise: 2 stars, advanced (double_neg_inf) *)
(** Write an informal proof of [double_neg]:
_Theorem_: [P] implies [~~P], for any proposition [P].
By definition of P this is the same thing as proving
P -> ( P -> False) -> False
By introducting P and applying it in P -> False, we have the hypothesis False from which we can prove anything.
*)
(** **** Exercise: 2 stars (contrapositive) *)
Theorem contrapositive : forall P Q : Prop,
(P -> Q) -> (~Q -> ~P).
Proof.
unfold not. intros.
apply H in H1. apply H0 in H1. inversion H1.
Qed.
(** [] *)
(** **** Exercise: 1 star (not_both_true_and_false) *)
Theorem not_both_true_and_false : forall P : Prop,
~ (P /\ ~P).
Proof.
unfold not.
intros.
apply contradiction_implies_anything with (Q := False) in H.
apply H.
Qed.
(** [] *)
(** **** Exercise: 1 star, advanced (informal_not_PNP) *)
(** Write an informal proof (in English) of the proposition [forall P
: Prop, ~(P /\ ~P)]. *)
(**
We can unfold the proposition into (P /\ ~P) -> False
from the Hypthesis we can conclude False by contradiction_implies_anything.
*)
(** *** Constructive logic *)
(** Note that some theorems that are true in classical logic are _not_
provable in Coq's (constructive) logic. E.g., let's look at how
this proof gets stuck... *)
Theorem classic_double_neg : forall P : Prop,
~~P -> P.
Proof.
(* WORKED IN CLASS *)
intros P H. unfold not in H.
(* But now what? There is no way to "invent" evidence for [~P]
from evidence for [P]. *)
Abort.
(** **** Exercise: 5 stars, advanced, optional (classical_axioms) *)
(** For those who like a challenge, here is an exercise
taken from the Coq'Art book (p. 123). The following five
statements are often considered as characterizations of
classical logic (as opposed to constructive logic, which is
what is "built in" to Coq). We can't prove them in Coq, but
we can consistently add any one of them as an unproven axiom
if we wish to work in classical logic. Prove that these five
propositions are equivalent. *)
Definition peirce := forall P Q: Prop,
((P->Q)->P)->P.
Definition classic := forall P:Prop,
~~P -> P.
Definition excluded_middle := forall P:Prop,
P \/ ~P.
Definition de_morgan_not_and_not := forall P Q:Prop,
~(~P /\ ~Q) -> P\/Q.
Definition implies_to_or := forall P Q:Prop,
(P->Q) -> (~P\/Q).
Theorem excluded_middle_classic: excluded_middle <-> classic.
Proof.
unfold classic.
unfold excluded_middle.
split.
intros.
destruct H with (P := P) as [PT | PF]. apply PT.
apply H0 in PF. inversion PF.
unfold not. intros. apply H. intros. apply H0. left. intros. apply H. intros. apply H0. right. apply H1.
Qed.
Theorem peirce_excluded_middle : peirce <-> excluded_middle.
unfold peirce.
unfold excluded_middle.
split.
intros. apply H with (Q := False). intros. right. unfold not. intros. apply H0. left. apply H1.
intros EXC P. destruct EXC with (P := P) as [PT | PF]. intros. apply PT.
intros. apply H. intros. apply PF in H0. inversion H0.
Qed.
Theorem classic_de_morgan : classic <-> de_morgan_not_and_not.
Proof.
unfold classic.
unfold de_morgan_not_and_not.
split.
unfold not. intros CLS P.
intros Q DMG. apply CLS. intros PDQ. destruct DMG. split.
intro H. apply PDQ. left. apply H.
intro H. apply PDQ. right. apply H.
unfold not. intros DMG P NNP. destruct DMG with (P := P) (Q := P). intros H. destruct H as [H _]. apply NNP. apply H. apply H. apply H.
Qed.
Theorem excluded_middle_implies_to_or : excluded_middle <-> implies_to_or.
Proof.
unfold excluded_middle.
unfold implies_to_or.
unfold not.
split.
intros EXC P Q PQ. destruct EXC with (P := P) as [PT | PF].
right. apply PQ. apply PT.
left. apply PF.
intros IMP P. apply or_commut. apply IMP. intro H. apply H.
Qed.
(** [] *)
(** **** Exercise: 3 stars (excluded_middle_irrefutable) *)
(** This theorem implies that it is always safe to add a decidability
axiom (i.e. an instance of excluded middle) for any _particular_ Prop [P].
Why? Because we cannot prove the negation of such an axiom; if we could,
we would have both [~ (P \/ ~P)] and [~ ~ (P \/ ~P)], a contradiction. *)
Theorem excluded_middle_irrefutable: forall (P:Prop), ~ ~ (P \/ ~ P).
Proof.
unfold not.
intros P H.
apply H.
right.
intro HP.
apply H.
left.
apply HP.
Qed.
(* ########################################################## *)
(** ** Inequality *)
(** Saying [x <> y] is just the same as saying [~(x = y)]. *)
Notation "x <> y" := (~ (x = y)) : type_scope.
(** Since inequality involves a negation, it again requires
a little practice to be able to work with it fluently. Here
is one very useful trick. If you are trying to prove a goal
that is nonsensical (e.g., the goal state is [false = true]),
apply the lemma [ex_falso_quodlibet] to change the goal to
[False]. This makes it easier to use assumptions of the form
[~P] that are available in the context -- in particular,
assumptions of the form [x<>y]. *)
Theorem not_false_then_true : forall b : bool,
b <> false -> b = true.
Proof.
intros b H. destruct b.
Case "b = true". reflexivity.
Case "b = false".
unfold not in H.
apply ex_falso_quodlibet.
apply H. reflexivity. Qed.
(** *** *)
(** *** *)
(** *** *)
(** *** *)
(** *** *)
(** **** Exercise: 2 stars (false_beq_nat) *)
Theorem false_beq_nat : forall n m : nat,
n <> m ->
beq_nat n m = false.
Proof.
intros n m Hnm.
destruct (beq_nat n m) eqn:eq.
unfold not in Hnm.
apply ex_falso_quodlibet.
apply Hnm.
apply beq_nat_true in eq.
apply eq.
reflexivity.
Qed.
(** [] *)
(** **** Exercise: 2 stars, optional (beq_nat_false) *)
Theorem beq_nat_false : forall n m,
beq_nat n m = false -> n <> m.
Proof.
unfold not.
intros n m H0.
destruct (beq_nat n m) eqn:eq.
inversion H0.
intro H1. rewrite H1 in eq. rewrite <- beq_nat_refl in eq. inversion eq.
Qed.
(** [] *)
(** $Date: 2014-12-31 11:17:56 -0500 (Wed, 31 Dec 2014) $ *)
|
[GOAL]
X Y : WalkingParallelPair
f : WalkingParallelPairHom X Y
⊢ comp f (id Y) = f
[PROOFSTEP]
cases f
[GOAL]
case left
⊢ comp left (id one) = left
[PROOFSTEP]
rfl
[GOAL]
case right
⊢ comp right (id one) = right
[PROOFSTEP]
rfl
[GOAL]
case id
X : WalkingParallelPair
⊢ comp (id X) (id X) = id X
[PROOFSTEP]
rfl
[GOAL]
X Y Z W : WalkingParallelPair
f : WalkingParallelPairHom X Y
g : WalkingParallelPairHom Y Z
h : WalkingParallelPairHom Z W
⊢ comp (comp f g) h = comp f (comp g h)
[PROOFSTEP]
cases f
[GOAL]
case left
Z W : WalkingParallelPair
h : WalkingParallelPairHom Z W
g : WalkingParallelPairHom one Z
⊢ comp (comp left g) h = comp left (comp g h)
[PROOFSTEP]
cases g
[GOAL]
case right
Z W : WalkingParallelPair
h : WalkingParallelPairHom Z W
g : WalkingParallelPairHom one Z
⊢ comp (comp right g) h = comp right (comp g h)
[PROOFSTEP]
cases g
[GOAL]
case id
X Z W : WalkingParallelPair
h : WalkingParallelPairHom Z W
g : WalkingParallelPairHom X Z
⊢ comp (comp (id X) g) h = comp (id X) (comp g h)
[PROOFSTEP]
cases g
[GOAL]
case left.id
W : WalkingParallelPair
h : WalkingParallelPairHom one W
⊢ comp (comp left (id one)) h = comp left (comp (id one) h)
[PROOFSTEP]
cases h
[GOAL]
case right.id
W : WalkingParallelPair
h : WalkingParallelPairHom one W
⊢ comp (comp right (id one)) h = comp right (comp (id one) h)
[PROOFSTEP]
cases h
[GOAL]
case id.left
W : WalkingParallelPair
h : WalkingParallelPairHom one W
⊢ comp (comp (id zero) left) h = comp (id zero) (comp left h)
[PROOFSTEP]
cases h
[GOAL]
case id.right
W : WalkingParallelPair
h : WalkingParallelPairHom one W
⊢ comp (comp (id zero) right) h = comp (id zero) (comp right h)
[PROOFSTEP]
cases h
[GOAL]
case id.id
X W : WalkingParallelPair
h : WalkingParallelPairHom X W
⊢ comp (comp (id X) (id X)) h = comp (id X) (comp (id X) h)
[PROOFSTEP]
cases h
[GOAL]
case left.id.id
⊢ comp (comp left (id one)) (id one) = comp left (comp (id one) (id one))
[PROOFSTEP]
rfl
[GOAL]
case right.id.id
⊢ comp (comp right (id one)) (id one) = comp right (comp (id one) (id one))
[PROOFSTEP]
rfl
[GOAL]
case id.left.id
⊢ comp (comp (id zero) left) (id one) = comp (id zero) (comp left (id one))
[PROOFSTEP]
rfl
[GOAL]
case id.right.id
⊢ comp (comp (id zero) right) (id one) = comp (id zero) (comp right (id one))
[PROOFSTEP]
rfl
[GOAL]
case id.id.left
⊢ comp (comp (id zero) (id zero)) left = comp (id zero) (comp (id zero) left)
[PROOFSTEP]
rfl
[GOAL]
case id.id.right
⊢ comp (comp (id zero) (id zero)) right = comp (id zero) (comp (id zero) right)
[PROOFSTEP]
rfl
[GOAL]
case id.id.id
X : WalkingParallelPair
⊢ comp (comp (id X) (id X)) (id X) = comp (id X) (comp (id X) (id X))
[PROOFSTEP]
rfl
[GOAL]
X : WalkingParallelPair
⊢ sizeOf (𝟙 X) = 1 + sizeOf X
[PROOFSTEP]
cases X
[GOAL]
case zero
⊢ sizeOf (𝟙 zero) = 1 + sizeOf zero
[PROOFSTEP]
rfl
[GOAL]
case one
⊢ sizeOf (𝟙 one) = 1 + sizeOf one
[PROOFSTEP]
rfl
[GOAL]
x : WalkingParallelPair
⊢ WalkingParallelPair
[PROOFSTEP]
cases x
[GOAL]
case zero
⊢ WalkingParallelPair
case one ⊢ WalkingParallelPair
[PROOFSTEP]
exacts [one, zero]
[GOAL]
X✝ Y✝ : WalkingParallelPair
f : X✝ ⟶ Y✝
⊢ (fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X✝ ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y✝
[PROOFSTEP]
cases f
[GOAL]
case left
⊢ (fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
one
[PROOFSTEP]
apply Quiver.Hom.op
[GOAL]
case right
⊢ (fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
one
[PROOFSTEP]
apply Quiver.Hom.op
[GOAL]
case id
X✝ : WalkingParallelPair
⊢ (fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X✝ ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X✝
[PROOFSTEP]
apply Quiver.Hom.op
[GOAL]
case left.f
⊢ WalkingParallelPair.casesOn (motive := fun t => one = t → WalkingParallelPair) one (fun h => (_ : zero = one) ▸ one)
(fun h => (_ : one = one) ▸ zero) (_ : one = one) ⟶
WalkingParallelPair.casesOn (motive := fun t => zero = t → WalkingParallelPair) zero
(fun h => (_ : zero = zero) ▸ one) (fun h => (_ : one = zero) ▸ zero) (_ : zero = zero)
case right.f
⊢ WalkingParallelPair.casesOn (motive := fun t => one = t → WalkingParallelPair) one (fun h => (_ : zero = one) ▸ one)
(fun h => (_ : one = one) ▸ zero) (_ : one = one) ⟶
WalkingParallelPair.casesOn (motive := fun t => zero = t → WalkingParallelPair) zero
(fun h => (_ : zero = zero) ▸ one) (fun h => (_ : one = zero) ▸ zero) (_ : zero = zero)
case id.f
X✝ : WalkingParallelPair
⊢ WalkingParallelPair.casesOn (motive := fun t => X✝ = t → WalkingParallelPair) X✝ (fun h => (_ : zero = X✝) ▸ one)
(fun h => (_ : one = X✝) ▸ zero) (_ : X✝ = X✝) ⟶
WalkingParallelPair.casesOn (motive := fun t => X✝ = t → WalkingParallelPair) X✝ (fun h => (_ : zero = X✝) ▸ one)
(fun h => (_ : one = X✝) ▸ zero) (_ : X✝ = X✝)
[PROOFSTEP]
exacts [left, right, WalkingParallelPairHom.id _]
[GOAL]
⊢ ∀ {X Y Z : WalkingParallelPair} (f : X ⟶ Y) (g : Y ⟶ Z),
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(f ≫ g) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
f ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
g
[PROOFSTEP]
rintro _ _ _ (_ | _ | _) g
[GOAL]
case left
Z✝ : WalkingParallelPair
g : one ⟶ Z✝
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(left ≫ g) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
left ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
g
[PROOFSTEP]
cases g
[GOAL]
case right
Z✝ : WalkingParallelPair
g : one ⟶ Z✝
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(right ≫ g) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
right ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
g
[PROOFSTEP]
cases g
[GOAL]
case id
X✝ Z✝ : WalkingParallelPair
g : X✝ ⟶ Z✝
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id X✝ ≫ g) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id X✝) ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
g
[PROOFSTEP]
cases g
[GOAL]
case left.id
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(left ≫ WalkingParallelPairHom.id one) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
left ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id one)
[PROOFSTEP]
rfl
[GOAL]
case right.id
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(right ≫ WalkingParallelPairHom.id one) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
right ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id one)
[PROOFSTEP]
rfl
[GOAL]
case id.left
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id zero ≫ left) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id zero) ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
left
[PROOFSTEP]
rfl
[GOAL]
case id.right
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id zero ≫ right) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id zero) ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
right
[PROOFSTEP]
rfl
[GOAL]
case id.id
X✝ : WalkingParallelPair
⊢ {
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id X✝ ≫ WalkingParallelPairHom.id X✝) =
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id X✝) ≫
{
obj := fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)),
map := fun {X Y} f =>
WalkingParallelPairHom.casesOn (motive := fun a a_1 t =>
X = a →
Y = a_1 →
HEq f t →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
f
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f left →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : left = f) ▸ left.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun h =>
Eq.ndrec (motive := fun {X} =>
(f : X ⟶ Y) →
Y = one →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
Eq.ndrec (motive := fun {Y} =>
(f : zero ⟶ Y) →
HEq f right →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
zero ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h => (_ : right = f) ▸ right.op) (_ : one = Y) f)
(_ : zero = X) f)
(fun X_1 h =>
Eq.ndrec (motive := fun X_2 =>
Y = X_2 →
HEq f (WalkingParallelPairHom.id X_2) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun h =>
Eq.ndrec (motive := fun {Y} =>
(f : X ⟶ Y) →
HEq f (WalkingParallelPairHom.id X) →
((fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
X ⟶
(fun x =>
op
(WalkingParallelPair.casesOn (motive := fun t => x = t → WalkingParallelPair) x
(fun h => (_ : zero = x) ▸ one) (fun h => (_ : one = x) ▸ zero) (_ : x = x)))
Y))
(fun f h =>
(_ : WalkingParallelPairHom.id X = f) ▸
(WalkingParallelPairHom.id
(WalkingParallelPair.casesOn (motive := fun t => X = t → WalkingParallelPair) X
(fun h => (_ : zero = X) ▸ one) (fun h => (_ : one = X) ▸ zero) (_ : X = X))).op)
(_ : X = Y) f)
h)
(_ : X = X) (_ : Y = Y) (_ : HEq f f) }.map
(WalkingParallelPairHom.id X✝)
[PROOFSTEP]
rfl
[GOAL]
j : WalkingParallelPair
⊢ (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j
[PROOFSTEP]
cases j
[GOAL]
case zero
⊢ (𝟭 WalkingParallelPair).obj zero = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj zero
[PROOFSTEP]
rfl
[GOAL]
case one
⊢ (𝟭 WalkingParallelPair).obj one = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj one
[PROOFSTEP]
rfl
[GOAL]
⊢ ∀ {X Y : WalkingParallelPair} (f : X ⟶ Y),
(𝟭 WalkingParallelPair).map f ≫
((fun j =>
eqToIso
(_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
Y).hom =
((fun j =>
eqToIso
(_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
X).hom ≫
(walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).map f
[PROOFSTEP]
rintro _ _ (_ | _ | _)
[GOAL]
case left
⊢ (𝟭 WalkingParallelPair).map left ≫
((fun j =>
eqToIso (_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
one).hom =
((fun j =>
eqToIso (_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
zero).hom ≫
(walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).map left
[PROOFSTEP]
simp
[GOAL]
case right
⊢ (𝟭 WalkingParallelPair).map right ≫
((fun j =>
eqToIso (_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
one).hom =
((fun j =>
eqToIso (_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
zero).hom ≫
(walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).map right
[PROOFSTEP]
simp
[GOAL]
case id
X✝ : WalkingParallelPair
⊢ (𝟭 WalkingParallelPair).map (WalkingParallelPairHom.id X✝) ≫
((fun j =>
eqToIso (_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
X✝).hom =
((fun j =>
eqToIso (_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j))
X✝).hom ≫
(walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
simp
[GOAL]
j : WalkingParallelPairᵒᵖ
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j
[PROOFSTEP]
induction' j with X
[GOAL]
case h
X : WalkingParallelPair
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj (op X) = (𝟭 WalkingParallelPairᵒᵖ).obj (op X)
[PROOFSTEP]
cases X
[GOAL]
case h.zero
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj (op zero) = (𝟭 WalkingParallelPairᵒᵖ).obj (op zero)
[PROOFSTEP]
rfl
[GOAL]
case h.one
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj (op one) = (𝟭 WalkingParallelPairᵒᵖ).obj (op one)
[PROOFSTEP]
rfl
[GOAL]
i j : WalkingParallelPairᵒᵖ
f : i ⟶ j
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map f ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
j).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
i).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map f
[PROOFSTEP]
induction' i with i
[GOAL]
case h
i✝ j : WalkingParallelPairᵒᵖ
f✝ : i✝ ⟶ j
i : WalkingParallelPair
f : op i ⟶ j
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map f ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
j).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op i)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map f
[PROOFSTEP]
induction' j with j
[GOAL]
case h.h
i✝ j✝ : WalkingParallelPairᵒᵖ
f✝² : i✝ ⟶ j✝
i : WalkingParallelPair
f✝¹ : op i ⟶ j✝
j : WalkingParallelPair
f✝ : i✝ ⟶ op j
f : op i ⟶ op j
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map f ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op j)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op i)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map f
[PROOFSTEP]
let g := f.unop
[GOAL]
case h.h
i✝ j✝ : WalkingParallelPairᵒᵖ
f✝² : i✝ ⟶ j✝
i : WalkingParallelPair
f✝¹ : op i ⟶ j✝
j : WalkingParallelPair
f✝ : i✝ ⟶ op j
f : op i ⟶ op j
g : (op j).unop ⟶ (op i).unop := f.unop
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map f ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op j)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op i)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map f
[PROOFSTEP]
have : f = g.op := rfl
[GOAL]
case h.h
i✝ j✝ : WalkingParallelPairᵒᵖ
f✝² : i✝ ⟶ j✝
i : WalkingParallelPair
f✝¹ : op i ⟶ j✝
j : WalkingParallelPair
f✝ : i✝ ⟶ op j
f : op i ⟶ op j
g : (op j).unop ⟶ (op i).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map f ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op j)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op i)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map f
[PROOFSTEP]
rw [this]
[GOAL]
case h.h
i✝ j✝ : WalkingParallelPairᵒᵖ
f✝² : i✝ ⟶ j✝
i : WalkingParallelPair
f✝¹ : op i ⟶ j✝
j : WalkingParallelPair
f✝ : i✝ ⟶ op j
f : op i ⟶ op j
g : (op j).unop ⟶ (op i).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map g.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op j)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op i)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map g.op
[PROOFSTEP]
cases i
[GOAL]
case h.h.zero
i j✝ : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j✝
j : WalkingParallelPair
f✝¹ : i ⟶ op j
f✝ : op zero ⟶ j✝
f : op zero ⟶ op j
g : (op j).unop ⟶ (op zero).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map g.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op j)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map g.op
[PROOFSTEP]
cases j
[GOAL]
case h.h.one
i j✝ : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j✝
j : WalkingParallelPair
f✝¹ : i ⟶ op j
f✝ : op one ⟶ j✝
f : op one ⟶ op j
g : (op j).unop ⟶ (op one).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map g.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op j)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map g.op
[PROOFSTEP]
cases j
[GOAL]
case h.h.zero.zero
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op zero ⟶ j
f✝ : i ⟶ op zero
f : op zero ⟶ op zero
g : (op zero).unop ⟶ (op zero).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map g.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map g.op
[PROOFSTEP]
cases g
[GOAL]
case h.h.zero.one
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op zero ⟶ j
f✝ : i ⟶ op one
f : op zero ⟶ op one
g : (op one).unop ⟶ (op zero).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map g.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map g.op
[PROOFSTEP]
cases g
[GOAL]
case h.h.one.zero
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op one ⟶ j
f✝ : i ⟶ op zero
f : op one ⟶ op zero
g : (op zero).unop ⟶ (op one).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map g.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map g.op
[PROOFSTEP]
cases g
[GOAL]
case h.h.one.one
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op one ⟶ j
f✝ : i ⟶ op one
f : op one ⟶ op one
g : (op one).unop ⟶ (op one).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map g.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map g.op
[PROOFSTEP]
cases g
[GOAL]
case h.h.zero.zero.id
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op zero ⟶ j
f✝ : i ⟶ op zero
f : op zero ⟶ op zero
g : (op zero).unop ⟶ (op zero).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map (WalkingParallelPairHom.id (op zero).unop).op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map (WalkingParallelPairHom.id (op zero).unop).op
[PROOFSTEP]
rfl
[GOAL]
case h.h.one.zero.left
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op one ⟶ j
f✝ : i ⟶ op zero
f : op one ⟶ op zero
g : (op zero).unop ⟶ (op one).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map left.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map left.op
[PROOFSTEP]
rfl
[GOAL]
case h.h.one.zero.right
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op one ⟶ j
f✝ : i ⟶ op zero
f : op one ⟶ op zero
g : (op zero).unop ⟶ (op one).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map right.op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op zero)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map right.op
[PROOFSTEP]
rfl
[GOAL]
case h.h.one.one.id
i j : WalkingParallelPairᵒᵖ
f✝² : i ⟶ j
f✝¹ : op one ⟶ j
f✝ : i ⟶ op one
f : op one ⟶ op one
g : (op one).unop ⟶ (op one).unop := f.unop
this : f = g.op
⊢ (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).map (WalkingParallelPairHom.id (op one).unop).op ≫
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom =
((fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j))
(op one)).hom ≫
(𝟭 WalkingParallelPairᵒᵖ).map (WalkingParallelPairHom.id (op one).unop).op
[PROOFSTEP]
rfl
[GOAL]
j : WalkingParallelPair
⊢ walkingParallelPairOp.map
(NatTrans.app
(NatIso.ofComponents fun j =>
eqToIso
(_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j)).hom
j) ≫
NatTrans.app
(NatIso.ofComponents fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j)).hom
(walkingParallelPairOp.obj j) =
𝟙 (walkingParallelPairOp.obj j)
[PROOFSTEP]
cases j
[GOAL]
case zero
⊢ walkingParallelPairOp.map
(NatTrans.app
(NatIso.ofComponents fun j =>
eqToIso
(_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j)).hom
zero) ≫
NatTrans.app
(NatIso.ofComponents fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j)).hom
(walkingParallelPairOp.obj zero) =
𝟙 (walkingParallelPairOp.obj zero)
[PROOFSTEP]
rfl
[GOAL]
case one
⊢ walkingParallelPairOp.map
(NatTrans.app
(NatIso.ofComponents fun j =>
eqToIso
(_ : (𝟭 WalkingParallelPair).obj j = (walkingParallelPairOp ⋙ walkingParallelPairOp.leftOp).obj j)).hom
one) ≫
NatTrans.app
(NatIso.ofComponents fun j =>
eqToIso
(_ : (walkingParallelPairOp.leftOp ⋙ walkingParallelPairOp).obj j = (𝟭 WalkingParallelPairᵒᵖ).obj j)).hom
(walkingParallelPairOp.obj one) =
𝟙 (walkingParallelPairOp.obj one)
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ ∀ {X_1 Y_1 Z : WalkingParallelPair} (f_1 : X_1 ⟶ Y_1) (g_1 : Y_1 ⟶ Z),
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_2 Y_2} h =>
match X_2, Y_2, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(f_1 ≫ g_1) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_2 Y_2} h =>
match X_2, Y_2, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
f_1 ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_2 Y_2} h =>
match X_2, Y_2, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
g_1
[PROOFSTEP]
rintro _ _ _ ⟨⟩ g
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g✝ : X ⟶ Y
Z✝ : WalkingParallelPair
g : one ⟶ Z✝
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
(left ≫ g) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
left ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
g
[PROOFSTEP]
cases g
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g✝ : X ⟶ Y
Z✝ : WalkingParallelPair
g : one ⟶ Z✝
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
(right ≫ g) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
right ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
g
[PROOFSTEP]
cases g
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g✝ : X ⟶ Y
X✝ Z✝ : WalkingParallelPair
g : X✝ ⟶ Z✝
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
(WalkingParallelPairHom.id X✝ ≫ g) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
(WalkingParallelPairHom.id X✝) ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g✝ }.map
g
[PROOFSTEP]
cases g
[GOAL]
case left.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(left ≫ WalkingParallelPairHom.id one) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
left ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id one)
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case left.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(left ≫ WalkingParallelPairHom.id one) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
left ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id one)
[PROOFSTEP]
dsimp
[GOAL]
case left.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ (match zero, one, left ≫ 𝟙 one with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
(match x with
| zero => X
| one => Y)
| .(zero), .(one), left => f
| .(zero), .(one), right => g) =
f ≫ 𝟙 Y
[PROOFSTEP]
simp
[GOAL]
case right.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(right ≫ WalkingParallelPairHom.id one) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
right ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id one)
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case right.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(right ≫ WalkingParallelPairHom.id one) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
right ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id one)
[PROOFSTEP]
dsimp
[GOAL]
case right.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ (match zero, one, right ≫ 𝟙 one with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
(match x with
| zero => X
| one => Y)
| .(zero), .(one), left => f
| .(zero), .(one), right => g) =
g ≫ 𝟙 Y
[PROOFSTEP]
simp
[GOAL]
case id.left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero ≫ left) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero) ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
left
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case id.left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero ≫ left) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero) ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
left
[PROOFSTEP]
dsimp
[GOAL]
case id.left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ (match zero, one, 𝟙 zero ≫ left with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
(match x with
| zero => X
| one => Y)
| .(zero), .(one), left => f
| .(zero), .(one), right => g) =
𝟙 X ≫ f
[PROOFSTEP]
simp
[GOAL]
case id.right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero ≫ right) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero) ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
right
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case id.right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero ≫ right) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id zero) ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
right
[PROOFSTEP]
dsimp
[GOAL]
case id.right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ (match zero, one, 𝟙 zero ≫ right with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
(match x with
| zero => X
| one => Y)
| .(zero), .(one), left => f
| .(zero), .(one), right => g) =
𝟙 X ≫ g
[PROOFSTEP]
simp
[GOAL]
case id.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
X✝ : WalkingParallelPair
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id X✝ ≫ WalkingParallelPairHom.id X✝) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id X✝) ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id X✝)
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case id.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
X✝ : WalkingParallelPair
⊢ {
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id X✝ ≫ WalkingParallelPairHom.id X✝) =
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id X✝) ≫
{
obj := fun x =>
match x with
| zero => X
| one => Y,
map := fun {X_1 Y_1} h =>
match X_1, Y_1, h with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
((fun x =>
match x with
| zero => X
| one => Y)
x)
| .(zero), .(one), left => f
| .(zero), .(one), right => g }.map
(WalkingParallelPairHom.id X✝)
[PROOFSTEP]
dsimp
[GOAL]
case id.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
X✝ : WalkingParallelPair
⊢ (match X✝, X✝, 𝟙 X✝ ≫ 𝟙 X✝ with
| x, .(x), WalkingParallelPairHom.id .(x) =>
𝟙
(match x with
| zero => X
| one => Y)
| .(zero), .(one), left => f
| .(zero), .(one), right => g) =
𝟙
(match X✝ with
| zero => X
| one => Y) ≫
𝟙
(match X✝ with
| zero => X
| one => Y)
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
j : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).obj j = F.obj j
[PROOFSTEP]
cases j
[GOAL]
case zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
⊢ (parallelPair (F.map left) (F.map right)).obj zero = F.obj zero
[PROOFSTEP]
rfl
[GOAL]
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
⊢ (parallelPair (F.map left) (F.map right)).obj one = F.obj one
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
j : WalkingParallelPair
⊢ F.obj j = (parallelPair (F.map left) (F.map right)).obj j
[PROOFSTEP]
cases j
[GOAL]
case zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
⊢ F.obj zero = (parallelPair (F.map left) (F.map right)).obj zero
[PROOFSTEP]
rfl
[GOAL]
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
⊢ F.obj one = (parallelPair (F.map left) (F.map right)).obj one
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
⊢ ∀ {X Y : WalkingParallelPair} (f : X ⟶ Y),
F.map f ≫ ((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) Y).hom =
((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) X).hom ≫
(parallelPair (F.map left) (F.map right)).map f
[PROOFSTEP]
rintro _ _ (_ | _ | _)
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
⊢ F.map left ≫ ((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) one).hom =
((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) zero).hom ≫
(parallelPair (F.map left) (F.map right)).map left
[PROOFSTEP]
simp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
⊢ F.map right ≫ ((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) one).hom =
((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) zero).hom ≫
(parallelPair (F.map left) (F.map right)).map right
[PROOFSTEP]
simp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F : WalkingParallelPair ⥤ C
X✝ : WalkingParallelPair
⊢ F.map (WalkingParallelPairHom.id X✝) ≫
((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) X✝).hom =
((fun j => eqToIso (_ : F.obj j = (parallelPair (F.map left) (F.map right)).obj j)) X✝).hom ≫
(parallelPair (F.map left) (F.map right)).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
⊢ ∀ ⦃X_1 Y_1 : WalkingParallelPair⦄ (f_1 : X_1 ⟶ Y_1),
(parallelPair f g).map f_1 ≫
(fun j =>
match j with
| zero => p
| one => q)
Y_1 =
(fun j =>
match j with
| zero => p
| one => q)
X_1 ≫
(parallelPair f' g').map f_1
[PROOFSTEP]
rintro _ _ ⟨⟩
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
⊢ (parallelPair f g).map left ≫
(fun j =>
match j with
| zero => p
| one => q)
one =
(fun j =>
match j with
| zero => p
| one => q)
zero ≫
(parallelPair f' g').map left
[PROOFSTEP]
{dsimp; simp [wf, wg]
}
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
⊢ (parallelPair f g).map left ≫
(fun j =>
match j with
| zero => p
| one => q)
one =
(fun j =>
match j with
| zero => p
| one => q)
zero ≫
(parallelPair f' g').map left
[PROOFSTEP]
dsimp
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
⊢ f ≫ q = p ≫ f'
[PROOFSTEP]
simp [wf, wg]
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
⊢ (parallelPair f g).map right ≫
(fun j =>
match j with
| zero => p
| one => q)
one =
(fun j =>
match j with
| zero => p
| one => q)
zero ≫
(parallelPair f' g').map right
[PROOFSTEP]
{dsimp; simp [wf, wg]
}
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
⊢ (parallelPair f g).map right ≫
(fun j =>
match j with
| zero => p
| one => q)
one =
(fun j =>
match j with
| zero => p
| one => q)
zero ≫
(parallelPair f' g').map right
[PROOFSTEP]
dsimp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
⊢ g ≫ q = p ≫ g'
[PROOFSTEP]
simp [wf, wg]
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
X✝ : WalkingParallelPair
⊢ (parallelPair f g).map (WalkingParallelPairHom.id X✝) ≫
(fun j =>
match j with
| zero => p
| one => q)
X✝ =
(fun j =>
match j with
| zero => p
| one => q)
X✝ ≫
(parallelPair f' g').map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
{dsimp; simp [wf, wg]
}
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
X✝ : WalkingParallelPair
⊢ (parallelPair f g).map (WalkingParallelPairHom.id X✝) ≫
(fun j =>
match j with
| zero => p
| one => q)
X✝ =
(fun j =>
match j with
| zero => p
| one => q)
X✝ ≫
(parallelPair f' g').map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
dsimp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y X' Y' : C
f g : X ⟶ Y
f' g' : X' ⟶ Y'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
X✝ : WalkingParallelPair
⊢ ((parallelPair f g).map (𝟙 X✝) ≫
match X✝ with
| zero => p
| one => q) =
(match X✝ with
| zero => p
| one => q) ≫
(parallelPair f' g').map (𝟙 X✝)
[PROOFSTEP]
simp [wf, wg]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F G : WalkingParallelPair ⥤ C
zero : F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
one : F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
left :
F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.left
right :
F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.right
⊢ (X : WalkingParallelPair) → F.obj X ≅ G.obj X
[PROOFSTEP]
rintro ⟨j⟩
[GOAL]
case zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F G : WalkingParallelPair ⥤ C
zero : F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
one : F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
left :
F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.left
right :
F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.right
⊢ F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F G : WalkingParallelPair ⥤ C
zero : F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
one : F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
left :
F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.left
right :
F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.right
⊢ F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
[PROOFSTEP]
exacts [zero, one]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F G : WalkingParallelPair ⥤ C
zero : F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
one : F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
left :
F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.left
right :
F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.right
⊢ ∀ {X Y : WalkingParallelPair} (f : X ⟶ Y),
F.map f ≫ (WalkingParallelPair.casesOn Y zero one).hom = (WalkingParallelPair.casesOn X zero one).hom ≫ G.map f
[PROOFSTEP]
rintro _ _ ⟨_⟩
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F G : WalkingParallelPair ⥤ C
zero : F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
one : F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
left :
F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.left
right :
F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.right
⊢ F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫
(WalkingParallelPair.casesOn CategoryTheory.Limits.WalkingParallelPair.one zero one).hom =
(WalkingParallelPair.casesOn CategoryTheory.Limits.WalkingParallelPair.zero zero one).hom ≫
G.map CategoryTheory.Limits.WalkingParallelPairHom.left
[PROOFSTEP]
simp [left, right]
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F G : WalkingParallelPair ⥤ C
zero : F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
one : F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
left :
F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.left
right :
F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.right
⊢ F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫
(WalkingParallelPair.casesOn CategoryTheory.Limits.WalkingParallelPair.one zero one).hom =
(WalkingParallelPair.casesOn CategoryTheory.Limits.WalkingParallelPair.zero zero one).hom ≫
G.map CategoryTheory.Limits.WalkingParallelPairHom.right
[PROOFSTEP]
simp [left, right]
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
F G : WalkingParallelPair ⥤ C
zero : F.obj CategoryTheory.Limits.WalkingParallelPair.zero ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.zero
one : F.obj CategoryTheory.Limits.WalkingParallelPair.one ≅ G.obj CategoryTheory.Limits.WalkingParallelPair.one
left :
F.map CategoryTheory.Limits.WalkingParallelPairHom.left ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.left
right :
F.map CategoryTheory.Limits.WalkingParallelPairHom.right ≫ one.hom =
zero.hom ≫ G.map CategoryTheory.Limits.WalkingParallelPairHom.right
X✝ : WalkingParallelPair
⊢ F.map (WalkingParallelPairHom.id X✝) ≫ (WalkingParallelPair.casesOn X✝ zero one).hom =
(WalkingParallelPair.casesOn X✝ zero one).hom ≫ G.map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
simp [left, right]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g f' g' : X ⟶ Y
hf : f = f'
hg : g = g'
⊢ (parallelPair f g).map left ≫ (Iso.refl ((parallelPair f g).obj one)).hom =
(Iso.refl ((parallelPair f g).obj zero)).hom ≫ (parallelPair f' g').map left
[PROOFSTEP]
simp [hf]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g f' g' : X ⟶ Y
hf : f = f'
hg : g = g'
⊢ (parallelPair f g).map right ≫ (Iso.refl ((parallelPair f g).obj one)).hom =
(Iso.refl ((parallelPair f g).obj zero)).hom ≫ (parallelPair f' g').map right
[PROOFSTEP]
simp [hg]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Fork f g
⊢ NatTrans.app s.π one = ι s ≫ f
[PROOFSTEP]
rw [← s.app_zero_eq_ι, ← s.w left, parallelPair_map_left]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Fork f g
⊢ NatTrans.app s.π one = ι s ≫ g
[PROOFSTEP]
rw [← s.app_zero_eq_ι, ← s.w right, parallelPair_map_right]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Cofork f g
⊢ NatTrans.app s.ι zero = f ≫ π s
[PROOFSTEP]
rw [← s.app_one_eq_π, ← s.w left, parallelPair_map_left]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Cofork f g
⊢ NatTrans.app s.ι zero = g ≫ π s
[PROOFSTEP]
rw [← s.app_one_eq_π, ← s.w right, parallelPair_map_right]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f g : X✝ ⟶ Y
P : C
ι : P ⟶ X✝
w : ι ≫ f = ι ≫ g
X : WalkingParallelPair
⊢ ((Functor.const WalkingParallelPair).obj P).obj X ⟶ (parallelPair f g).obj X
[PROOFSTEP]
cases X
[GOAL]
case zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ((Functor.const WalkingParallelPair).obj P).obj zero ⟶ (parallelPair f g).obj zero
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ((Functor.const WalkingParallelPair).obj P).obj one ⟶ (parallelPair f g).obj one
[PROOFSTEP]
exact ι
[GOAL]
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ((Functor.const WalkingParallelPair).obj P).obj one ⟶ (parallelPair f g).obj one
[PROOFSTEP]
exact ι ≫ f
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
P : C
ι : P ⟶ X✝
w : ι ≫ f✝ = ι ≫ g
X Y : WalkingParallelPair
f : X ⟶ Y
⊢ ((Functor.const WalkingParallelPair).obj P).map f ≫
(fun X =>
WalkingParallelPair.casesOn (motive := fun t =>
X = t → (((Functor.const WalkingParallelPair).obj P).obj X ⟶ (parallelPair f✝ g).obj X)) X
(fun h => (_ : zero = X) ▸ ι) (fun h => (_ : one = X) ▸ ι ≫ f✝) (_ : X = X))
Y =
(fun X =>
WalkingParallelPair.casesOn (motive := fun t =>
X = t → (((Functor.const WalkingParallelPair).obj P).obj X ⟶ (parallelPair f✝ g).obj X)) X
(fun h => (_ : zero = X) ▸ ι) (fun h => (_ : one = X) ▸ ι ≫ f✝) (_ : X = X))
X ≫
(parallelPair f✝ g).map f
[PROOFSTEP]
cases X
[GOAL]
case zero
C : Type u
inst✝ : Category.{v, u} C
X Y✝ : C
f✝ g : X ⟶ Y✝
P : C
ι : P ⟶ X
w : ι ≫ f✝ = ι ≫ g
Y : WalkingParallelPair
f : zero ⟶ Y
⊢ ((Functor.const WalkingParallelPair).obj P).map f ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
Y =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
zero ≫
(parallelPair f✝ g).map f
[PROOFSTEP]
cases Y
[GOAL]
case one
C : Type u
inst✝ : Category.{v, u} C
X Y✝ : C
f✝ g : X ⟶ Y✝
P : C
ι : P ⟶ X
w : ι ≫ f✝ = ι ≫ g
Y : WalkingParallelPair
f : one ⟶ Y
⊢ ((Functor.const WalkingParallelPair).obj P).map f ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
Y =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
one ≫
(parallelPair f✝ g).map f
[PROOFSTEP]
cases Y
[GOAL]
case zero.zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f✝ = ι ≫ g
f : zero ⟶ zero
⊢ ((Functor.const WalkingParallelPair).obj P).map f ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
zero =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
zero ≫
(parallelPair f✝ g).map f
[PROOFSTEP]
cases f
[GOAL]
case zero.one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f✝ = ι ≫ g
f : zero ⟶ one
⊢ ((Functor.const WalkingParallelPair).obj P).map f ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
one =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
zero ≫
(parallelPair f✝ g).map f
[PROOFSTEP]
cases f
[GOAL]
case one.zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f✝ = ι ≫ g
f : one ⟶ zero
⊢ ((Functor.const WalkingParallelPair).obj P).map f ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
zero =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
one ≫
(parallelPair f✝ g).map f
[PROOFSTEP]
cases f
[GOAL]
case one.one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f✝ = ι ≫ g
f : one ⟶ one
⊢ ((Functor.const WalkingParallelPair).obj P).map f ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
one =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f✝ g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f✝) (_ : X_1 = X_1))
one ≫
(parallelPair f✝ g).map f
[PROOFSTEP]
cases f
[GOAL]
case zero.zero.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ((Functor.const WalkingParallelPair).obj P).map (WalkingParallelPairHom.id zero) ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
zero =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
zero ≫
(parallelPair f g).map (WalkingParallelPairHom.id zero)
[PROOFSTEP]
dsimp
[GOAL]
case zero.one.left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ((Functor.const WalkingParallelPair).obj P).map left ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
one =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
zero ≫
(parallelPair f g).map left
[PROOFSTEP]
dsimp
[GOAL]
case zero.one.right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ((Functor.const WalkingParallelPair).obj P).map right ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
one =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
zero ≫
(parallelPair f g).map right
[PROOFSTEP]
dsimp
[GOAL]
case one.one.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ((Functor.const WalkingParallelPair).obj P).map (WalkingParallelPairHom.id one) ≫
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
one =
(fun X_1 =>
WalkingParallelPair.casesOn (motive := fun t =>
X_1 = t → (((Functor.const WalkingParallelPair).obj P).obj X_1 ⟶ (parallelPair f g).obj X_1)) X_1
(fun h => (_ : zero = X_1) ▸ ι) (fun h => (_ : one = X_1) ▸ ι ≫ f) (_ : X_1 = X_1))
one ≫
(parallelPair f g).map (WalkingParallelPairHom.id one)
[PROOFSTEP]
dsimp
[GOAL]
case zero.zero.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ 𝟙 P ≫ ι = ι ≫ (parallelPair f g).map (𝟙 zero)
[PROOFSTEP]
simp
[GOAL]
case zero.one.left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ 𝟙 P ≫ ι ≫ f = ι ≫ f
[PROOFSTEP]
simp
[GOAL]
case zero.one.right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ 𝟙 P ≫ ι ≫ f = ι ≫ g
[PROOFSTEP]
simp
[GOAL]
case one.one.id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ 𝟙 P ≫ ι ≫ f = (ι ≫ f) ≫ (parallelPair f g).map (𝟙 one)
[PROOFSTEP]
simp
[GOAL]
case zero.one.right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
ι : P ⟶ X
w : ι ≫ f = ι ≫ g
⊢ ι ≫ f = ι ≫ g
[PROOFSTEP]
assumption
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
P : C
π : Y ⟶ P
w : f✝ ≫ π = g ≫ π
i j : WalkingParallelPair
f : i ⟶ j
⊢ (parallelPair f✝ g).map f ≫ (fun X_1 => WalkingParallelPair.casesOn X_1 (f✝ ≫ π) π) j =
(fun X_1 => WalkingParallelPair.casesOn X_1 (f✝ ≫ π) π) i ≫ ((Functor.const WalkingParallelPair).obj P).map f
[PROOFSTEP]
cases f
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
π : Y ⟶ P
w : f ≫ π = g ≫ π
⊢ (parallelPair f g).map left ≫ (fun X_1 => WalkingParallelPair.casesOn X_1 (f ≫ π) π) one =
(fun X_1 => WalkingParallelPair.casesOn X_1 (f ≫ π) π) zero ≫ ((Functor.const WalkingParallelPair).obj P).map left
[PROOFSTEP]
dsimp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
π : Y ⟶ P
w : f ≫ π = g ≫ π
⊢ (parallelPair f g).map right ≫ (fun X_1 => WalkingParallelPair.casesOn X_1 (f ≫ π) π) one =
(fun X_1 => WalkingParallelPair.casesOn X_1 (f ≫ π) π) zero ≫ ((Functor.const WalkingParallelPair).obj P).map right
[PROOFSTEP]
dsimp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
π : Y ⟶ P
w : f ≫ π = g ≫ π
i : WalkingParallelPair
⊢ (parallelPair f g).map (WalkingParallelPairHom.id i) ≫ (fun X_1 => WalkingParallelPair.casesOn X_1 (f ≫ π) π) i =
(fun X_1 => WalkingParallelPair.casesOn X_1 (f ≫ π) π) i ≫
((Functor.const WalkingParallelPair).obj P).map (WalkingParallelPairHom.id i)
[PROOFSTEP]
dsimp
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
π : Y ⟶ P
w : f ≫ π = g ≫ π
⊢ f ≫ π = (f ≫ π) ≫ 𝟙 P
[PROOFSTEP]
simp [w]
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
π : Y ⟶ P
w : f ≫ π = g ≫ π
⊢ g ≫ π = (f ≫ π) ≫ 𝟙 P
[PROOFSTEP]
simp [w]
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
P : C
π : Y ⟶ P
w : f ≫ π = g ≫ π
i : WalkingParallelPair
⊢ (parallelPair f g).map (𝟙 i) ≫ WalkingParallelPair.rec (f ≫ π) π i = WalkingParallelPair.rec (f ≫ π) π i ≫ 𝟙 P
[PROOFSTEP]
simp [w]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Fork f g
⊢ ι t ≫ f = ι t ≫ g
[PROOFSTEP]
rw [← t.app_one_eq_ι_comp_left, ← t.app_one_eq_ι_comp_right]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Cofork f g
⊢ f ≫ π t = g ≫ π t
[PROOFSTEP]
rw [← t.app_zero_eq_comp_π_left, ← t.app_zero_eq_comp_π_right]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Fork f g
W : C
k l : W ⟶ s.pt
h : k ≫ ι s = l ≫ ι s
⊢ k ≫ NatTrans.app s.π one = l ≫ NatTrans.app s.π one
[PROOFSTEP]
have : k ≫ ι s ≫ f = l ≫ ι s ≫ f := by simp only [← Category.assoc]; exact congrArg (· ≫ f) h
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Fork f g
W : C
k l : W ⟶ s.pt
h : k ≫ ι s = l ≫ ι s
⊢ k ≫ ι s ≫ f = l ≫ ι s ≫ f
[PROOFSTEP]
simp only [← Category.assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Fork f g
W : C
k l : W ⟶ s.pt
h : k ≫ ι s = l ≫ ι s
⊢ (k ≫ ι s) ≫ f = (l ≫ ι s) ≫ f
[PROOFSTEP]
exact congrArg (· ≫ f) h
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Fork f g
W : C
k l : W ⟶ s.pt
h : k ≫ ι s = l ≫ ι s
this : k ≫ ι s ≫ f = l ≫ ι s ≫ f
⊢ k ≫ NatTrans.app s.π one = l ≫ NatTrans.app s.π one
[PROOFSTEP]
rw [s.app_one_eq_ι_comp_left, this]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Cofork f g
W : C
k l : s.pt ⟶ W
h : π s ≫ k = π s ≫ l
⊢ NatTrans.app s.ι zero ≫ k = NatTrans.app s.ι zero ≫ l
[PROOFSTEP]
simp only [s.app_zero_eq_comp_π_left, Category.assoc, h]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Fork f g
hs : IsLimit s
W : C
k : W ⟶ X
h : k ≫ f = k ≫ g
⊢ lift hs k h ≫ ι s = k
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s : Cofork f g
hs : IsColimit s
W : C
k : Y ⟶ W
h : f ≫ k = g ≫ k
⊢ π s ≫ desc hs k h = k
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Fork f g
lift : (s : Fork f g) → s.pt ⟶ t.pt
fac : ∀ (s : Fork f g), lift s ≫ ι t = ι s
uniq : ∀ (s : Fork f g) (m : s.pt ⟶ t.pt), m ≫ ι t = ι s → m = lift s
s : Cone (parallelPair f g)
j : WalkingParallelPair
⊢ lift s ≫ NatTrans.app t.π one = NatTrans.app s.π one
[PROOFSTEP]
erw [← s.w left, ← t.w left, ← Category.assoc, fac]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Fork f g
lift : (s : Fork f g) → s.pt ⟶ t.pt
fac : ∀ (s : Fork f g), lift s ≫ ι t = ι s
uniq : ∀ (s : Fork f g) (m : s.pt ⟶ t.pt), m ≫ ι t = ι s → m = lift s
s : Cone (parallelPair f g)
j : WalkingParallelPair
⊢ ι s ≫ (parallelPair f g).map left = NatTrans.app s.π zero ≫ (parallelPair f g).map left
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Fork f g
lift : (s : Fork f g) → s.pt ⟶ t.pt
fac : ∀ (s : Fork f g), lift s ≫ ι t = ι s
uniq : ∀ (s : Fork f g) (m : s.pt ⟶ t.pt), m ≫ ι t = ι s → m = lift s
s : Cone (parallelPair f g)
m : s.pt ⟶ t.pt
j : ∀ (j : WalkingParallelPair), m ≫ NatTrans.app t.π j = NatTrans.app s.π j
⊢ m = lift s
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Cofork f g
desc : (s : Cofork f g) → t.pt ⟶ s.pt
fac : ∀ (s : Cofork f g), π t ≫ desc s = π s
uniq : ∀ (s : Cofork f g) (m : t.pt ⟶ s.pt), π t ≫ m = π s → m = desc s
s : Cocone (parallelPair f g)
j : WalkingParallelPair
⊢ NatTrans.app t.ι zero ≫ desc s = NatTrans.app s.ι zero
[PROOFSTEP]
erw [← s.w left, ← t.w left, Category.assoc, fac]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Cofork f g
desc : (s : Cofork f g) → t.pt ⟶ s.pt
fac : ∀ (s : Cofork f g), π t ≫ desc s = π s
uniq : ∀ (s : Cofork f g) (m : t.pt ⟶ s.pt), π t ≫ m = π s → m = desc s
s : Cocone (parallelPair f g)
j : WalkingParallelPair
⊢ (parallelPair f g).map left ≫ π s = (parallelPair f g).map left ≫ NatTrans.app s.ι one
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Cofork f g
desc : (s : Cofork f g) → t.pt ⟶ s.pt
fac : ∀ (s : Cofork f g), π t ≫ desc s = π s
uniq : ∀ (s : Cofork f g) (m : t.pt ⟶ s.pt), π t ≫ m = π s → m = desc s
⊢ ∀ (s : Cocone (parallelPair f g)) (m : t.pt ⟶ s.pt),
(∀ (j : WalkingParallelPair), NatTrans.app t.ι j ≫ m = NatTrans.app s.ι j) → m = desc s
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Fork f g
hs : ∀ (s : Fork f g), ∃! l, l ≫ ι t = ι s
⊢ IsLimit t
[PROOFSTEP]
choose d hd hd' using hs
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Fork f g
d : (s : Fork f g) → s.pt ⟶ t.pt
hd : ∀ (s : Fork f g), (fun l => l ≫ ι t = ι s) (d s)
hd' : ∀ (s : Fork f g) (y : s.pt ⟶ t.pt), (fun l => l ≫ ι t = ι s) y → y = d s
⊢ IsLimit t
[PROOFSTEP]
exact Fork.IsLimit.mk _ d hd fun s m hm => hd' _ _ hm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Cofork f g
hs : ∀ (s : Cofork f g), ∃! d, π t ≫ d = π s
⊢ IsColimit t
[PROOFSTEP]
choose d hd hd' using hs
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
t : Cofork f g
d : (s : Cofork f g) → t.pt ⟶ s.pt
hd : ∀ (s : Cofork f g), (fun d => π t ≫ d = π s) (d s)
hd' : ∀ (s : Cofork f g) (y : t.pt ⟶ s.pt), (fun d => π t ≫ d = π s) y → y = d s
⊢ IsColimit t
[PROOFSTEP]
exact Cofork.IsColimit.mk _ d hd fun s m hm => hd' _ _ hm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y✝ : C
f✝ g✝ : X✝ ⟶ Y✝
X Y : C
f g : X ⟶ Y
t : Fork f g
ht : IsLimit t
Z : C
k : Z ⟶ t.pt
⊢ (k ≫ ι t) ≫ f = (k ≫ ι t) ≫ g
[PROOFSTEP]
simp only [Category.assoc, t.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y✝ : C
f✝ g✝ : X✝ ⟶ Y✝
X Y : C
f g : X ⟶ Y
t : Cofork f g
ht : IsColimit t
Z : C
k : t.pt ⟶ Z
⊢ f ≫ π t ≫ k = g ≫ π t ≫ k
[PROOFSTEP]
simp only [← Category.assoc, t.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f g : X✝ ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
X : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).obj X = F.obj X
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
⊢ ∀ ⦃X Y : WalkingParallelPair⦄ (f : X ⟶ Y),
((Functor.const WalkingParallelPair).obj t.pt).map f ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) Y =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) X ≫
F.map f
[PROOFSTEP]
rintro _ _ (_ | _ | _)
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map left ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) zero ≫
F.map left
[PROOFSTEP]
{dsimp; simp [t.condition]
}
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map left ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) zero ≫
F.map left
[PROOFSTEP]
dsimp
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
⊢ 𝟙 t.pt ≫ NatTrans.app t.π one ≫ 𝟙 (F.obj one) = (Fork.ι t ≫ 𝟙 (F.obj zero)) ≫ F.map left
[PROOFSTEP]
simp [t.condition]
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map right ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) zero ≫
F.map right
[PROOFSTEP]
{dsimp; simp [t.condition]
}
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map right ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) zero ≫
F.map right
[PROOFSTEP]
dsimp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
⊢ 𝟙 t.pt ≫ NatTrans.app t.π one ≫ 𝟙 (F.obj one) = (Fork.ι t ≫ 𝟙 (F.obj zero)) ≫ F.map right
[PROOFSTEP]
simp [t.condition]
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
X✝ : WalkingParallelPair
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝) ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) X✝ =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) X✝ ≫
F.map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
{dsimp; simp [t.condition]
}
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
X✝ : WalkingParallelPair
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝) ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) X✝ =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X)) X✝ ≫
F.map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
dsimp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
X✝ : WalkingParallelPair
⊢ 𝟙 t.pt ≫ NatTrans.app t.π X✝ ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X✝ = F.obj X✝) =
(NatTrans.app t.π X✝ ≫ eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X✝ = F.obj X✝)) ≫ F.map (𝟙 X✝)
[PROOFSTEP]
simp [t.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f g : X✝ ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
X : WalkingParallelPair
⊢ F.obj X = (parallelPair (F.map left) (F.map right)).obj X
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
⊢ ∀ ⦃X Y : WalkingParallelPair⦄ (f : X ⟶ Y),
F.map f ≫
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) Y =
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) X ≫
((Functor.const WalkingParallelPair).obj t.pt).map f
[PROOFSTEP]
rintro _ _ (_ | _ | _)
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
⊢ F.map left ≫
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map left
[PROOFSTEP]
{dsimp; simp [t.condition]
}
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
⊢ F.map left ≫
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map left
[PROOFSTEP]
dsimp
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
⊢ F.map left ≫ 𝟙 (F.obj one) ≫ Cofork.π t = (𝟙 (F.obj zero) ≫ NatTrans.app t.ι zero) ≫ 𝟙 t.pt
[PROOFSTEP]
simp [t.condition]
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
⊢ F.map right ≫
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map right
[PROOFSTEP]
{dsimp; simp [t.condition]
}
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
⊢ F.map right ≫
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map right
[PROOFSTEP]
dsimp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
⊢ F.map right ≫ 𝟙 (F.obj one) ≫ Cofork.π t = (𝟙 (F.obj zero) ≫ NatTrans.app t.ι zero) ≫ 𝟙 t.pt
[PROOFSTEP]
simp [t.condition]
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
X✝ : WalkingParallelPair
⊢ F.map (WalkingParallelPairHom.id X✝) ≫
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) X✝ =
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) X✝ ≫
((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
{dsimp; simp [t.condition]
}
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
X✝ : WalkingParallelPair
⊢ F.map (WalkingParallelPairHom.id X✝) ≫
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) X✝ =
(fun X => eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X) ≫ NatTrans.app t.ι X) X✝ ≫
((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
dsimp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
X✝ : WalkingParallelPair
⊢ F.map (𝟙 X✝) ≫ eqToHom (_ : F.obj X✝ = (parallelPair (F.map left) (F.map right)).obj X✝) ≫ NatTrans.app t.ι X✝ =
(eqToHom (_ : F.obj X✝ = (parallelPair (F.map left) (F.map right)).obj X✝) ≫ NatTrans.app t.ι X✝) ≫ 𝟙 t.pt
[PROOFSTEP]
simp [t.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Fork (F.map left) (F.map right)
j : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).obj j = F.obj j
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cofork (F.map left) (F.map right)
j : WalkingParallelPair
⊢ F.obj j = (parallelPair (F.map left) (F.map right)).obj j
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f g : X✝ ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
X : WalkingParallelPair
⊢ F.obj X = (parallelPair (F.map left) (F.map right)).obj X
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
⊢ ∀ ⦃X Y : WalkingParallelPair⦄ (f : X ⟶ Y),
((Functor.const WalkingParallelPair).obj t.pt).map f ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) Y =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) X ≫
(parallelPair (F.map left) (F.map right)).map f
[PROOFSTEP]
rintro _ _ (_ | _ | _)
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map left ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) zero ≫
(parallelPair (F.map left) (F.map right)).map left
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map left ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) zero ≫
(parallelPair (F.map left) (F.map right)).map left
[PROOFSTEP]
dsimp
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
⊢ 𝟙 t.pt ≫ NatTrans.app t.π one ≫ 𝟙 (F.obj one) = (NatTrans.app t.π zero ≫ 𝟙 (F.obj zero)) ≫ F.map left
[PROOFSTEP]
simp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map right ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) zero ≫
(parallelPair (F.map left) (F.map right)).map right
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map right ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) one =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) zero ≫
(parallelPair (F.map left) (F.map right)).map right
[PROOFSTEP]
dsimp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
⊢ 𝟙 t.pt ≫ NatTrans.app t.π one ≫ 𝟙 (F.obj one) = (NatTrans.app t.π zero ≫ 𝟙 (F.obj zero)) ≫ F.map right
[PROOFSTEP]
simp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
X✝ : WalkingParallelPair
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝) ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) X✝ =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) X✝ ≫
(parallelPair (F.map left) (F.map right)).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
X✝ : WalkingParallelPair
⊢ ((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝) ≫
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) X✝ =
(fun X => NatTrans.app t.π X ≫ eqToHom (_ : F.obj X = (parallelPair (F.map left) (F.map right)).obj X)) X✝ ≫
(parallelPair (F.map left) (F.map right)).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
dsimp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
X✝ : WalkingParallelPair
⊢ 𝟙 t.pt ≫ NatTrans.app t.π X✝ ≫ eqToHom (_ : F.obj X✝ = (parallelPair (F.map left) (F.map right)).obj X✝) =
(NatTrans.app t.π X✝ ≫ eqToHom (_ : F.obj X✝ = (parallelPair (F.map left) (F.map right)).obj X✝)) ≫
(parallelPair (F.map left) (F.map right)).map (𝟙 X✝)
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f g : X✝ ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
X : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).obj X = F.obj X
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
⊢ ∀ ⦃X Y : WalkingParallelPair⦄ (f : X ⟶ Y),
(parallelPair (F.map left) (F.map right)).map f ≫
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) Y =
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) X ≫
((Functor.const WalkingParallelPair).obj t.pt).map f
[PROOFSTEP]
rintro _ _ (_ | _ | _)
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
⊢ (parallelPair (F.map left) (F.map right)).map left ≫
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map left
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
⊢ (parallelPair (F.map left) (F.map right)).map left ≫
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map left
[PROOFSTEP]
dsimp
[GOAL]
case left
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
⊢ F.map left ≫ 𝟙 (F.obj one) ≫ NatTrans.app t.ι one = (𝟙 (F.obj zero) ≫ NatTrans.app t.ι zero) ≫ 𝟙 t.pt
[PROOFSTEP]
simp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
⊢ (parallelPair (F.map left) (F.map right)).map right ≫
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map right
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
⊢ (parallelPair (F.map left) (F.map right)).map right ≫
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) one =
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) zero ≫
((Functor.const WalkingParallelPair).obj t.pt).map right
[PROOFSTEP]
dsimp
[GOAL]
case right
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
⊢ F.map right ≫ 𝟙 (F.obj one) ≫ NatTrans.app t.ι one = (𝟙 (F.obj zero) ≫ NatTrans.app t.ι zero) ≫ 𝟙 t.pt
[PROOFSTEP]
simp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
X✝ : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).map (WalkingParallelPairHom.id X✝) ≫
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) X✝ =
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) X✝ ≫
((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
{dsimp; simp
}
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
X✝ : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).map (WalkingParallelPairHom.id X✝) ≫
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) X✝ =
(fun X => eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X = F.obj X) ≫ NatTrans.app t.ι X) X✝ ≫
((Functor.const WalkingParallelPair).obj t.pt).map (WalkingParallelPairHom.id X✝)
[PROOFSTEP]
dsimp
[GOAL]
case id
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
X✝ : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).map (𝟙 X✝) ≫
eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X✝ = F.obj X✝) ≫ NatTrans.app t.ι X✝ =
(eqToHom (_ : (parallelPair (F.map left) (F.map right)).obj X✝ = F.obj X✝) ≫ NatTrans.app t.ι X✝) ≫ 𝟙 t.pt
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cone F
j : WalkingParallelPair
⊢ F.obj j = (parallelPair (F.map left) (F.map right)).obj j
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
F : WalkingParallelPair ⥤ C
t : Cocone F
j : WalkingParallelPair
⊢ (parallelPair (F.map left) (F.map right)).obj j = F.obj j
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Fork f g
k : s.pt ⟶ t.pt
w : k ≫ ι t = ι s
⊢ ∀ (j : WalkingParallelPair), k ≫ NatTrans.app t.π j = NatTrans.app s.π j
[PROOFSTEP]
rintro ⟨_ | _⟩
[GOAL]
case zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Fork f g
k : s.pt ⟶ t.pt
w : k ≫ ι t = ι s
⊢ k ≫ NatTrans.app t.π zero = NatTrans.app s.π zero
[PROOFSTEP]
exact w
[GOAL]
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Fork f g
k : s.pt ⟶ t.pt
w : k ≫ ι t = ι s
⊢ k ≫ NatTrans.app t.π one = NatTrans.app s.π one
[PROOFSTEP]
simp only [Fork.app_one_eq_ι_comp_left, ← Category.assoc]
[GOAL]
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Fork f g
k : s.pt ⟶ t.pt
w : k ≫ ι t = ι s
⊢ (k ≫ ι t) ≫ f = ι s ≫ f
[PROOFSTEP]
congr
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Fork f g
i : s.pt ≅ t.pt
w : autoParam (i.hom ≫ ι t = ι s) _auto✝
⊢ i.inv ≫ ι s = ι t
[PROOFSTEP]
rw [← w, Iso.inv_hom_id_assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
⊢ c.pt ≅ (ofι (ι c) (_ : ι c ≫ f = ι c ≫ g)).pt
[PROOFSTEP]
simp only [Fork.ofι_pt, Functor.const_obj_obj]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
⊢ c.pt ≅ c.pt
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
⊢ (_root_.id (Iso.refl c.pt)).hom ≫ ι (ofι (ι c) (_ : ι c ≫ f = ι c ≫ g)) = ι c
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Cofork f g
k : s.pt ⟶ t.pt
w : π s ≫ k = π t
⊢ ∀ (j : WalkingParallelPair), NatTrans.app s.ι j ≫ k = NatTrans.app t.ι j
[PROOFSTEP]
rintro ⟨_ | _⟩
[GOAL]
case zero
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Cofork f g
k : s.pt ⟶ t.pt
w : π s ≫ k = π t
⊢ NatTrans.app s.ι zero ≫ k = NatTrans.app t.ι zero
[PROOFSTEP]
simp [Cofork.app_zero_eq_comp_π_left, w]
[GOAL]
case one
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Cofork f g
k : s.pt ⟶ t.pt
w : π s ≫ k = π t
⊢ NatTrans.app s.ι one ≫ k = NatTrans.app t.ι one
[PROOFSTEP]
exact w
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
s t : Fork f✝ g
f : s ⟶ t
⊢ f.Hom ≫ ι t = ι s
[PROOFSTEP]
cases s
[GOAL]
case mk
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
t : Fork f✝ g
pt✝ : C
π✝ : (Functor.const WalkingParallelPair).obj pt✝ ⟶ parallelPair f✝ g
f : { pt := pt✝, π := π✝ } ⟶ t
⊢ f.Hom ≫ ι t = ι { pt := pt✝, π := π✝ }
[PROOFSTEP]
cases t
[GOAL]
case mk.mk
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
pt✝¹ : C
π✝¹ : (Functor.const WalkingParallelPair).obj pt✝¹ ⟶ parallelPair f✝ g
pt✝ : C
π✝ : (Functor.const WalkingParallelPair).obj pt✝ ⟶ parallelPair f✝ g
f : { pt := pt✝¹, π := π✝¹ } ⟶ { pt := pt✝, π := π✝ }
⊢ f.Hom ≫ ι { pt := pt✝, π := π✝ } = ι { pt := pt✝¹, π := π✝¹ }
[PROOFSTEP]
cases f
[GOAL]
case mk.mk.mk
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
pt✝¹ : C
π✝¹ : (Functor.const WalkingParallelPair).obj pt✝¹ ⟶ parallelPair f g
pt✝ : C
π✝ : (Functor.const WalkingParallelPair).obj pt✝ ⟶ parallelPair f g
Hom✝ : { pt := pt✝¹, π := π✝¹ }.pt ⟶ { pt := pt✝, π := π✝ }.pt
w✝ :
∀ (j : WalkingParallelPair),
Hom✝ ≫ NatTrans.app { pt := pt✝, π := π✝ }.π j = NatTrans.app { pt := pt✝¹, π := π✝¹ }.π j
⊢ (ConeMorphism.mk Hom✝).Hom ≫ ι { pt := pt✝, π := π✝ } = ι { pt := pt✝¹, π := π✝¹ }
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
s t : Cofork f✝ g
f : s ⟶ t
⊢ Cofork.π s ≫ f.Hom = Cofork.π t
[PROOFSTEP]
cases s
[GOAL]
case mk
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
t : Cofork f✝ g
pt✝ : C
ι✝ : parallelPair f✝ g ⟶ (Functor.const WalkingParallelPair).obj pt✝
f : { pt := pt✝, ι := ι✝ } ⟶ t
⊢ Cofork.π { pt := pt✝, ι := ι✝ } ≫ f.Hom = Cofork.π t
[PROOFSTEP]
cases t
[GOAL]
case mk.mk
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f✝ g : X ⟶ Y
pt✝¹ : C
ι✝¹ : parallelPair f✝ g ⟶ (Functor.const WalkingParallelPair).obj pt✝¹
pt✝ : C
ι✝ : parallelPair f✝ g ⟶ (Functor.const WalkingParallelPair).obj pt✝
f : { pt := pt✝¹, ι := ι✝¹ } ⟶ { pt := pt✝, ι := ι✝ }
⊢ Cofork.π { pt := pt✝¹, ι := ι✝¹ } ≫ f.Hom = Cofork.π { pt := pt✝, ι := ι✝ }
[PROOFSTEP]
cases f
[GOAL]
case mk.mk.mk
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
pt✝¹ : C
ι✝¹ : parallelPair f g ⟶ (Functor.const WalkingParallelPair).obj pt✝¹
pt✝ : C
ι✝ : parallelPair f g ⟶ (Functor.const WalkingParallelPair).obj pt✝
Hom✝ : { pt := pt✝¹, ι := ι✝¹ }.pt ⟶ { pt := pt✝, ι := ι✝ }.pt
w✝ :
∀ (j : WalkingParallelPair),
NatTrans.app { pt := pt✝¹, ι := ι✝¹ }.ι j ≫ Hom✝ = NatTrans.app { pt := pt✝, ι := ι✝ }.ι j
⊢ Cofork.π { pt := pt✝¹, ι := ι✝¹ } ≫ (CoconeMorphism.mk Hom✝).Hom = Cofork.π { pt := pt✝, ι := ι✝ }
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
s t : Cofork f g
i : s.pt ≅ t.pt
w : autoParam (π s ≫ i.hom = π t) _auto✝
⊢ π t ≫ i.inv = π s
[PROOFSTEP]
rw [Iso.comp_inv_eq, w]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
⊢ c.pt ≅ (ofπ (π c) (_ : f ≫ π c = g ≫ π c)).pt
[PROOFSTEP]
simp only [Cofork.ofπ_pt, Functor.const_obj_obj]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
⊢ c.pt ≅ c.pt
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
⊢ π c ≫ (_root_.id (Iso.refl c.pt)).hom = π (ofπ (π c) (_ : f ≫ π c = g ≫ π c))
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
⊢ π c ≫ 𝟙 c.pt = π c
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝¹ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
inst✝ : HasEqualizer f g
⊢ (Iso.refl (limit.cone (parallelPair f g)).pt).hom ≫
Fork.ι (Fork.ofι (equalizer.ι f g) (_ : equalizer.ι f g ≫ f = equalizer.ι f g ≫ g)) =
Fork.ι (limit.cone (parallelPair f g))
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
h✝ : f = g
s : Fork f g
m : s.pt ⟶ (idFork h✝).pt
h : m ≫ Fork.ι (idFork h✝) = Fork.ι s
⊢ m = (fun s => Fork.ι s) s
[PROOFSTEP]
convert h
[GOAL]
case h.e'_2.h
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
h✝ : f = g
s : Fork f g
m : s.pt ⟶ (idFork h✝).pt
h : m ≫ Fork.ι (idFork h✝) = Fork.ι s
e_1✝ : (s.pt ⟶ (idFork h✝).pt) = (s.pt ⟶ (parallelPair f g).obj zero)
⊢ m = m ≫ Fork.ι (idFork h✝)
[PROOFSTEP]
exact (Category.comp_id _).symm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ 𝟙 X ≫ f = 𝟙 X ≫ f
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ (isoSourceOfSelf f).inv = lift (𝟙 X) (_ : 𝟙 X ≫ f = 𝟙 X ≫ f)
[PROOFSTEP]
ext
[GOAL]
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ (isoSourceOfSelf f).inv ≫ ι f f = lift (𝟙 X) (_ : 𝟙 X ≫ f = 𝟙 X ≫ f) ≫ ι f f
[PROOFSTEP]
simp [equalizer.isoSourceOfSelf]
[GOAL]
C : Type u
inst✝¹ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
inst✝ : HasCoequalizer f g
⊢ Cofork.π (colimit.cocone (parallelPair f g)) ≫ (Iso.refl (colimit.cocone (parallelPair f g)).pt).hom =
Cofork.π (Cofork.ofπ (coequalizer.π f g) (_ : f ≫ coequalizer.π f g = g ≫ coequalizer.π f g))
[PROOFSTEP]
aesop
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X Y : C
f g : X ⟶ Y
inst✝¹ : HasCoequalizer f g
X' Y' Z : C
f' g' : X' ⟶ Y'
inst✝ : HasCoequalizer f' g'
p : X ⟶ X'
q : Y ⟶ Y'
wf : f ≫ q = p ≫ f'
wg : g ≫ q = p ≫ g'
h : Y' ⟶ Z
wh : f' ≫ h = g' ≫ h
⊢ π f g ≫ colimMap (parallelPairHom f g f' g' p q wf wg) ≫ desc h wh = q ≫ h
[PROOFSTEP]
rw [ι_colimMap_assoc, parallelPairHom_app_one, coequalizer.π_desc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
h✝ : f = g
s : Cofork f g
m : (idCofork h✝).pt ⟶ s.pt
h : Cofork.π (idCofork h✝) ≫ m = Cofork.π s
⊢ m = (fun s => Cofork.π s) s
[PROOFSTEP]
convert h
[GOAL]
case h.e'_2.h
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
h✝ : f = g
s : Cofork f g
m : (idCofork h✝).pt ⟶ s.pt
h : Cofork.π (idCofork h✝) ≫ m = Cofork.π s
e_1✝ : ((idCofork h✝).pt ⟶ s.pt) = ((parallelPair f g).obj one ⟶ s.pt)
⊢ m = Cofork.π (idCofork h✝) ≫ m
[PROOFSTEP]
exact (Category.id_comp _).symm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ f ≫ 𝟙 Y = f ≫ 𝟙 Y
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ (isoTargetOfSelf f).hom = desc (𝟙 Y) (_ : f ≫ 𝟙 Y = f ≫ 𝟙 Y)
[PROOFSTEP]
ext
[GOAL]
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
⊢ π f f ≫ (isoTargetOfSelf f).hom = π f f ≫ desc (𝟙 Y) (_ : f ≫ 𝟙 Y = f ≫ 𝟙 Y)
[PROOFSTEP]
simp [coequalizer.isoTargetOfSelf]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasEqualizer f g
inst✝ : HasEqualizer (G.map f) (G.map g)
⊢ G.map (equalizer.ι f g) ≫ G.map f = G.map (equalizer.ι f g) ≫ G.map g
[PROOFSTEP]
simp only [← G.map_comp]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasEqualizer f g
inst✝ : HasEqualizer (G.map f) (G.map g)
⊢ G.map (equalizer.ι f g ≫ f) = G.map (equalizer.ι f g ≫ g)
[PROOFSTEP]
rw [equalizer.condition]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasEqualizer f g
inst✝ : HasEqualizer (G.map f) (G.map g)
Z : C
h : Z ⟶ X
w : h ≫ f = h ≫ g
⊢ G.map h ≫ G.map f = G.map h ≫ G.map g
[PROOFSTEP]
simp only [← G.map_comp, w]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasEqualizer f g
inst✝ : HasEqualizer (G.map f) (G.map g)
Z : C
h : Z ⟶ X
w : h ≫ f = h ≫ g
⊢ G.map (equalizer.lift h w) ≫ equalizerComparison f g G =
equalizer.lift (G.map h) (_ : G.map h ≫ G.map f = G.map h ≫ G.map g)
[PROOFSTEP]
apply equalizer.hom_ext
[GOAL]
case h
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasEqualizer f g
inst✝ : HasEqualizer (G.map f) (G.map g)
Z : C
h : Z ⟶ X
w : h ≫ f = h ≫ g
⊢ (G.map (equalizer.lift h w) ≫ equalizerComparison f g G) ≫ equalizer.ι (G.map f) (G.map g) =
equalizer.lift (G.map h) (_ : G.map h ≫ G.map f = G.map h ≫ G.map g) ≫ equalizer.ι (G.map f) (G.map g)
[PROOFSTEP]
simp [← G.map_comp]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasCoequalizer f g
inst✝ : HasCoequalizer (G.map f) (G.map g)
⊢ G.map f ≫ G.map (coequalizer.π f g) = G.map g ≫ G.map (coequalizer.π f g)
[PROOFSTEP]
simp only [← G.map_comp]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasCoequalizer f g
inst✝ : HasCoequalizer (G.map f) (G.map g)
⊢ G.map (f ≫ coequalizer.π f g) = G.map (g ≫ coequalizer.π f g)
[PROOFSTEP]
rw [coequalizer.condition]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasCoequalizer f g
inst✝ : HasCoequalizer (G.map f) (G.map g)
Z : C
h : Y ⟶ Z
w : f ≫ h = g ≫ h
⊢ G.map f ≫ G.map h = G.map g ≫ G.map h
[PROOFSTEP]
simp only [← G.map_comp, w]
[GOAL]
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasCoequalizer f g
inst✝ : HasCoequalizer (G.map f) (G.map g)
Z : C
h : Y ⟶ Z
w : f ≫ h = g ≫ h
⊢ coequalizerComparison f g G ≫ G.map (coequalizer.desc h w) =
coequalizer.desc (G.map h) (_ : G.map f ≫ G.map h = G.map g ≫ G.map h)
[PROOFSTEP]
apply coequalizer.hom_ext
[GOAL]
case h
C : Type u
inst✝³ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
D : Type u₂
inst✝² : Category.{v₂, u₂} D
G : C ⥤ D
inst✝¹ : HasCoequalizer f g
inst✝ : HasCoequalizer (G.map f) (G.map g)
Z : C
h : Y ⟶ Z
w : f ≫ h = g ≫ h
⊢ coequalizer.π (G.map f) (G.map g) ≫ coequalizerComparison f g G ≫ G.map (coequalizer.desc h w) =
coequalizer.π (G.map f) (G.map g) ≫ coequalizer.desc (G.map h) (_ : G.map f ≫ G.map h = G.map g ≫ G.map h)
[PROOFSTEP]
simp [← G.map_comp]
[GOAL]
C : Type u
inst✝¹ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
inst✝ : IsSplitMono f
⊢ f ≫ 𝟙 Y = f ≫ retraction f ≫ f
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
inst✝¹ : IsSplitMono f✝
X Y : C
f : X ⟶ Y
inst✝ : IsSplitMono f
s : Fork (𝟙 Y) (retraction f ≫ f)
⊢ (Fork.ι s ≫ retraction f) ≫ Fork.ι (coneOfIsSplitMono f) = Fork.ι s
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
inst✝¹ : IsSplitMono f✝
X Y : C
f : X ⟶ Y
inst✝ : IsSplitMono f
s : Fork (𝟙 Y) (retraction f ≫ f)
⊢ (Fork.ι s ≫ retraction f) ≫ f = Fork.ι s
[PROOFSTEP]
rw [Category.assoc, ← s.condition]
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
inst✝¹ : IsSplitMono f✝
X Y : C
f : X ⟶ Y
inst✝ : IsSplitMono f
s : Fork (𝟙 Y) (retraction f ≫ f)
⊢ Fork.ι s ≫ 𝟙 Y = Fork.ι s
[PROOFSTEP]
apply Category.comp_id
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
inst✝¹ : IsSplitMono f✝
X Y : C
f : X ⟶ Y
inst✝ : IsSplitMono f
s : Fork (𝟙 Y) (retraction f ≫ f)
m✝ :
((Functor.const WalkingParallelPair).obj s.pt).obj zero ⟶
((Functor.const WalkingParallelPair).obj (coneOfIsSplitMono f).pt).obj zero
hm : m✝ ≫ Fork.ι (coneOfIsSplitMono f) = Fork.ι s
⊢ m✝ = Fork.ι s ≫ retraction f
[PROOFSTEP]
simp [← hm]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm : Mono h
⊢ Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h
[PROOFSTEP]
simp only [← Category.assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm : Mono h
⊢ (Fork.ι c ≫ f) ≫ h = (Fork.ι c ≫ g) ≫ h
[PROOFSTEP]
exact congrArg (· ≫ h) c.condition
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm : Mono h
this : Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h
⊢ Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h
[PROOFSTEP]
simp [this]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm : Mono h
s : Fork (f ≫ h) (g ≫ h)
⊢ Fork.ι s ≫ f = Fork.ι s ≫ g
[PROOFSTEP]
apply hm.right_cancellation
[GOAL]
case a
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm : Mono h
s : Fork (f ≫ h) (g ≫ h)
⊢ (Fork.ι s ≫ f) ≫ h = (Fork.ι s ≫ g) ≫ h
[PROOFSTEP]
simp [s.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm✝ : Mono h
s : Fork (f ≫ h) (g ≫ h)
s' : Fork f g := Fork.ofι (Fork.ι s) (_ : Fork.ι s ≫ f = Fork.ι s ≫ g)
l : { l // l ≫ Fork.ι c = Fork.ι s' } := Fork.IsLimit.lift' i (Fork.ι s') (_ : Fork.ι s' ≫ f = Fork.ι s' ≫ g)
m✝ :
((Functor.const WalkingParallelPair).obj s.pt).obj zero ⟶
((Functor.const WalkingParallelPair).obj (Fork.ofι (Fork.ι c) (_ : Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h)).pt).obj
zero
hm : m✝ ≫ Fork.ι (Fork.ofι (Fork.ι c) (_ : Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h)) = Fork.ι s
⊢ m✝ = ↑l
[PROOFSTEP]
apply Fork.IsLimit.hom_ext i
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm✝ : Mono h
s : Fork (f ≫ h) (g ≫ h)
s' : Fork f g := Fork.ofι (Fork.ι s) (_ : Fork.ι s ≫ f = Fork.ι s ≫ g)
l : { l // l ≫ Fork.ι c = Fork.ι s' } := Fork.IsLimit.lift' i (Fork.ι s') (_ : Fork.ι s' ≫ f = Fork.ι s' ≫ g)
m✝ :
((Functor.const WalkingParallelPair).obj s.pt).obj zero ⟶
((Functor.const WalkingParallelPair).obj (Fork.ofι (Fork.ι c) (_ : Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h)).pt).obj
zero
hm : m✝ ≫ Fork.ι (Fork.ofι (Fork.ι c) (_ : Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h)) = Fork.ι s
⊢ m✝ ≫ Fork.ι c = ↑l ≫ Fork.ι c
[PROOFSTEP]
rw [Fork.ι_ofι] at hm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm✝ : Mono h
s : Fork (f ≫ h) (g ≫ h)
s' : Fork f g := Fork.ofι (Fork.ι s) (_ : Fork.ι s ≫ f = Fork.ι s ≫ g)
l : { l // l ≫ Fork.ι c = Fork.ι s' } := Fork.IsLimit.lift' i (Fork.ι s') (_ : Fork.ι s' ≫ f = Fork.ι s' ≫ g)
m✝ :
((Functor.const WalkingParallelPair).obj s.pt).obj zero ⟶
((Functor.const WalkingParallelPair).obj (Fork.ofι (Fork.ι c) (_ : Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h)).pt).obj
zero
hm : m✝ ≫ Fork.ι c = Fork.ι s
⊢ m✝ ≫ Fork.ι c = ↑l ≫ Fork.ι c
[PROOFSTEP]
rw [hm]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Fork f g
i : IsLimit c
Z : C
h : Y ⟶ Z
hm✝ : Mono h
s : Fork (f ≫ h) (g ≫ h)
s' : Fork f g := Fork.ofι (Fork.ι s) (_ : Fork.ι s ≫ f = Fork.ι s ≫ g)
l : { l // l ≫ Fork.ι c = Fork.ι s' } := Fork.IsLimit.lift' i (Fork.ι s') (_ : Fork.ι s' ≫ f = Fork.ι s' ≫ g)
m✝ :
((Functor.const WalkingParallelPair).obj s.pt).obj zero ⟶
((Functor.const WalkingParallelPair).obj (Fork.ofι (Fork.ι c) (_ : Fork.ι c ≫ f ≫ h = Fork.ι c ≫ g ≫ h)).pt).obj
zero
hm : m✝ ≫ Fork.ι c = Fork.ι s
⊢ Fork.ι s = ↑l ≫ Fork.ι c
[PROOFSTEP]
exact l.2.symm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Fork (𝟙 X) f
i : IsLimit c
⊢ f ≫ 𝟙 X = f ≫ f
[PROOFSTEP]
simp [hf]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Fork (𝟙 X) f
i : IsLimit c
⊢ Fork.ι c ≫ IsLimit.lift i (Fork.ofι f (_ : f ≫ 𝟙 X = f ≫ f)) =
𝟙 (((Functor.const WalkingParallelPair).obj c.pt).obj zero)
[PROOFSTEP]
letI := mono_of_isLimit_fork i
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Fork (𝟙 X) f
i : IsLimit c
this : Mono (Fork.ι c) := mono_of_isLimit_fork i
⊢ Fork.ι c ≫ IsLimit.lift i (Fork.ofι f (_ : f ≫ 𝟙 X = f ≫ f)) =
𝟙 (((Functor.const WalkingParallelPair).obj c.pt).obj zero)
[PROOFSTEP]
rw [← cancel_mono_id c.ι, Category.assoc, Fork.IsLimit.lift_ι, Fork.ι_ofι, ← c.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Fork (𝟙 X) f
i : IsLimit c
this : Mono (Fork.ι c) := mono_of_isLimit_fork i
⊢ Fork.ι c ≫ 𝟙 X = Fork.ι c
[PROOFSTEP]
exact Category.comp_id c.ι
[GOAL]
C : Type u
inst✝¹ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
inst✝ : IsSplitEpi f
⊢ 𝟙 X ≫ f = (f ≫ section_ f) ≫ f
[PROOFSTEP]
simp
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
inst✝¹ : IsSplitEpi f✝
X Y : C
f : X ⟶ Y
inst✝ : IsSplitEpi f
s : Cofork (𝟙 X) (f ≫ section_ f)
⊢ Cofork.π (coconeOfIsSplitEpi f) ≫ section_ f ≫ Cofork.π s = Cofork.π s
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
inst✝¹ : IsSplitEpi f✝
X Y : C
f : X ⟶ Y
inst✝ : IsSplitEpi f
s : Cofork (𝟙 X) (f ≫ section_ f)
⊢ f ≫ section_ f ≫ Cofork.π s = Cofork.π s
[PROOFSTEP]
rw [← Category.assoc, ← s.condition, Category.id_comp]
[GOAL]
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ : C
f✝ g : X✝ ⟶ Y✝
inst✝¹ : IsSplitEpi f✝
X Y : C
f : X ⟶ Y
inst✝ : IsSplitEpi f
s : Cofork (𝟙 X) (f ≫ section_ f)
m✝ :
((Functor.const WalkingParallelPair).obj (coconeOfIsSplitEpi f).pt).obj one ⟶
((Functor.const WalkingParallelPair).obj s.pt).obj one
hm : Cofork.π (coconeOfIsSplitEpi f) ≫ m✝ = Cofork.π s
⊢ m✝ = section_ f ≫ Cofork.π s
[PROOFSTEP]
simp [← hm]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm : Epi h
⊢ (h ≫ f) ≫ Cofork.π c = (h ≫ g) ≫ Cofork.π c
[PROOFSTEP]
simp only [Category.assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm : Epi h
⊢ h ≫ f ≫ Cofork.π c = h ≫ g ≫ Cofork.π c
[PROOFSTEP]
exact congrArg (h ≫ ·) c.condition
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm : Epi h
s : Cofork (h ≫ f) (h ≫ g)
⊢ f ≫ Cofork.π s = g ≫ Cofork.π s
[PROOFSTEP]
apply hm.left_cancellation
[GOAL]
case a
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm : Epi h
s : Cofork (h ≫ f) (h ≫ g)
⊢ h ≫ f ≫ Cofork.π s = h ≫ g ≫ Cofork.π s
[PROOFSTEP]
simp_rw [← Category.assoc, s.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm✝ : Epi h
s : Cofork (h ≫ f) (h ≫ g)
s' : Cofork f g := Cofork.ofπ (Cofork.π s) (_ : f ≫ Cofork.π s = g ≫ Cofork.π s)
l : { l // Cofork.π c ≫ l = Cofork.π s' } :=
Cofork.IsColimit.desc' i (Cofork.π s') (_ : f ≫ Cofork.π s' = g ≫ Cofork.π s')
m✝ :
((Functor.const WalkingParallelPair).obj
(Cofork.ofπ (Cofork.π c) (_ : (h ≫ f) ≫ Cofork.π c = (h ≫ g) ≫ Cofork.π c)).pt).obj
one ⟶
((Functor.const WalkingParallelPair).obj s.pt).obj one
hm : Cofork.π (Cofork.ofπ (Cofork.π c) (_ : (h ≫ f) ≫ Cofork.π c = (h ≫ g) ≫ Cofork.π c)) ≫ m✝ = Cofork.π s
⊢ m✝ = ↑l
[PROOFSTEP]
apply Cofork.IsColimit.hom_ext i
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm✝ : Epi h
s : Cofork (h ≫ f) (h ≫ g)
s' : Cofork f g := Cofork.ofπ (Cofork.π s) (_ : f ≫ Cofork.π s = g ≫ Cofork.π s)
l : { l // Cofork.π c ≫ l = Cofork.π s' } :=
Cofork.IsColimit.desc' i (Cofork.π s') (_ : f ≫ Cofork.π s' = g ≫ Cofork.π s')
m✝ :
((Functor.const WalkingParallelPair).obj
(Cofork.ofπ (Cofork.π c) (_ : (h ≫ f) ≫ Cofork.π c = (h ≫ g) ≫ Cofork.π c)).pt).obj
one ⟶
((Functor.const WalkingParallelPair).obj s.pt).obj one
hm : Cofork.π (Cofork.ofπ (Cofork.π c) (_ : (h ≫ f) ≫ Cofork.π c = (h ≫ g) ≫ Cofork.π c)) ≫ m✝ = Cofork.π s
⊢ Cofork.π c ≫ m✝ = Cofork.π c ≫ ↑l
[PROOFSTEP]
rw [Cofork.π_ofπ] at hm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm✝ : Epi h
s : Cofork (h ≫ f) (h ≫ g)
s' : Cofork f g := Cofork.ofπ (Cofork.π s) (_ : f ≫ Cofork.π s = g ≫ Cofork.π s)
l : { l // Cofork.π c ≫ l = Cofork.π s' } :=
Cofork.IsColimit.desc' i (Cofork.π s') (_ : f ≫ Cofork.π s' = g ≫ Cofork.π s')
m✝ :
((Functor.const WalkingParallelPair).obj
(Cofork.ofπ (Cofork.π c) (_ : (h ≫ f) ≫ Cofork.π c = (h ≫ g) ≫ Cofork.π c)).pt).obj
one ⟶
((Functor.const WalkingParallelPair).obj s.pt).obj one
hm : Cofork.π c ≫ m✝ = Cofork.π s
⊢ Cofork.π c ≫ m✝ = Cofork.π c ≫ ↑l
[PROOFSTEP]
rw [hm]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X Y : C
f g : X ⟶ Y
c : Cofork f g
i : IsColimit c
W : C
h : W ⟶ X
hm✝ : Epi h
s : Cofork (h ≫ f) (h ≫ g)
s' : Cofork f g := Cofork.ofπ (Cofork.π s) (_ : f ≫ Cofork.π s = g ≫ Cofork.π s)
l : { l // Cofork.π c ≫ l = Cofork.π s' } :=
Cofork.IsColimit.desc' i (Cofork.π s') (_ : f ≫ Cofork.π s' = g ≫ Cofork.π s')
m✝ :
((Functor.const WalkingParallelPair).obj
(Cofork.ofπ (Cofork.π c) (_ : (h ≫ f) ≫ Cofork.π c = (h ≫ g) ≫ Cofork.π c)).pt).obj
one ⟶
((Functor.const WalkingParallelPair).obj s.pt).obj one
hm : Cofork.π c ≫ m✝ = Cofork.π s
⊢ Cofork.π s = Cofork.π c ≫ ↑l
[PROOFSTEP]
exact l.2.symm
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Cofork (𝟙 X) f
i : IsColimit c
⊢ 𝟙 X ≫ f = f ≫ f
[PROOFSTEP]
simp [hf]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Cofork (𝟙 X) f
i : IsColimit c
⊢ IsColimit.desc i (Cofork.ofπ f (_ : 𝟙 X ≫ f = f ≫ f)) ≫ Cofork.π c =
𝟙 (((Functor.const WalkingParallelPair).obj c.pt).obj one)
[PROOFSTEP]
letI := epi_of_isColimit_cofork i
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Cofork (𝟙 X) f
i : IsColimit c
this : Epi (Cofork.π c) := epi_of_isColimit_cofork i
⊢ IsColimit.desc i (Cofork.ofπ f (_ : 𝟙 X ≫ f = f ≫ f)) ≫ Cofork.π c =
𝟙 (((Functor.const WalkingParallelPair).obj c.pt).obj one)
[PROOFSTEP]
rw [← cancel_epi_id c.π, ← Category.assoc, Cofork.IsColimit.π_desc, Cofork.π_ofπ, ← c.condition]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
X✝ Y : C
f✝ g : X✝ ⟶ Y
X : C
f : X ⟶ X
hf : f ≫ f = f
c : Cofork (𝟙 X) f
i : IsColimit c
this : Epi (Cofork.π c) := epi_of_isColimit_cofork i
⊢ 𝟙 X ≫ Cofork.π c = Cofork.π c
[PROOFSTEP]
exact Category.id_comp _
|
% LRR | ROSL | Robust Orthonormal Subspace Learning (Shu et al. 2014)
% process_video('LRR', 'ROSL', 'dataset/demo.avi', 'output/demo_LRR-ROSL.avi');
K = 1; % The initialiation of the subspace dimension
tol = 1e-5;
maxIter = 30;
lambda = 1e-1; %2e-3;
[~,~,E_hat,A_hat] = inexact_alm_rosl(M,K,lambda,tol,maxIter);
L = A_hat;
S = E_hat; |
[STATEMENT]
lemma \<psi>T_W :
assumes "T \<in> GRepHomSet (\<star>) W"
shows "\<psi> T ` indV \<subseteq> W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<psi> T ` indV \<subseteq> W
[PROOF STEP]
proof (rule image_subsetI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
T \<in> GRepHomSet (\<star>) W
[PROOF STEP]
have T: "VectorSpaceHom induced_smult.fsmult indV fsmult' (\<psi> T)"
[PROOF STATE]
proof (prove)
using this:
T \<in> GRepHomSet (\<star>) W
goal (1 subgoal):
1. VectorSpaceHom (\<currency>\<currency>) indV (\<sharp>\<star>) (\<psi> T)
[PROOF STEP]
using \<psi>D_VectorSpaceHom
[PROOF STATE]
proof (prove)
using this:
T \<in> GRepHomSet (\<star>) W
?T \<in> GRepHomSet (\<star>) W \<Longrightarrow> VectorSpaceHom (\<currency>\<currency>) indV (\<sharp>\<star>) (\<psi> ?T)
goal (1 subgoal):
1. VectorSpaceHom (\<currency>\<currency>) indV (\<sharp>\<star>) (\<psi> T)
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
VectorSpaceHom (\<currency>\<currency>) indV (\<sharp>\<star>) (\<psi> T)
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
fix f
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
assume "f \<in> indV"
[PROOF STATE]
proof (state)
this:
f \<in> indV
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
f \<in> indV
[PROOF STEP]
obtain cs
where cs:"length cs = length (concat indVfbasis)" "f = cs \<bullet>\<currency>\<currency> (concat indVfbasis)"
[PROOF STATE]
proof (prove)
using this:
f \<in> indV
goal (1 subgoal):
1. (\<And>cs. \<lbrakk>length cs = length (concat indVfbasis); f = cs \<bullet>\<currency>\<currency> concat indVfbasis\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using indVfbasis scalar_mult.in_Span_obtain_same_length_coeffs
[PROOF STATE]
proof (prove)
using this:
f \<in> indV
set (concat indVfbasis) \<subseteq> indV \<and> indV = R_scalar_mult.RSpan UNIV (\<currency>\<currency>) (concat indVfbasis) \<and> R_scalar_mult.R_lin_independent UNIV (\<currency>\<currency>) (concat indVfbasis)
?n \<in> R_scalar_mult.RSpan UNIV ?smult ?ms \<Longrightarrow> \<exists>rs. set rs \<subseteq> UNIV \<and> length rs = length ?ms \<and> ?n = scalar_mult.lincomb ?smult rs ?ms
goal (1 subgoal):
1. (\<And>cs. \<lbrakk>length cs = length (concat indVfbasis); f = cs \<bullet>\<currency>\<currency> concat indVfbasis\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
length cs = length (concat indVfbasis)
f = cs \<bullet>\<currency>\<currency> concat indVfbasis
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
from cs(1)
[PROOF STATE]
proof (chain)
picking this:
length cs = length (concat indVfbasis)
[PROOF STEP]
obtain css
where css: "cs = concat css" "list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis"
[PROOF STATE]
proof (prove)
using this:
length cs = length (concat indVfbasis)
goal (1 subgoal):
1. (\<And>css. \<lbrakk>cs = concat css; list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using match_concat
[PROOF STATE]
proof (prove)
using this:
length cs = length (concat indVfbasis)
\<forall>as. length as = length (concat ?bss) \<longrightarrow> (\<exists>css. as = concat css \<and> list_all2 (\<lambda>xs ys. length xs = length ys) css ?bss)
goal (1 subgoal):
1. (\<And>css. \<lbrakk>cs = concat css; list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
cs = concat css
list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
from assms cs(2) css
[PROOF STATE]
proof (chain)
picking this:
T \<in> GRepHomSet (\<star>) W
f = cs \<bullet>\<currency>\<currency> concat indVfbasis
cs = concat css
list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis
[PROOF STEP]
have "\<psi> T f = \<psi> T (\<Sum>(cs,hfvs)\<leftarrow>zip css indVfbasis. cs \<bullet>\<currency>\<currency> hfvs)"
[PROOF STATE]
proof (prove)
using this:
T \<in> GRepHomSet (\<star>) W
f = cs \<bullet>\<currency>\<currency> concat indVfbasis
cs = concat css
list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis
goal (1 subgoal):
1. \<psi> T f = \<psi> T (sum_list (map2 (\<bullet>\<currency>\<currency>) css indVfbasis))
[PROOF STEP]
using VectorSpace.lincomb_concat[OF fVectorSpace_indspace]
[PROOF STATE]
proof (prove)
using this:
T \<in> GRepHomSet (\<star>) W
f = cs \<bullet>\<currency>\<currency> concat indVfbasis
cs = concat css
list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis
list_all2 (\<lambda>rs ms. length rs = length ms) ?rss ?mss \<Longrightarrow> concat ?rss \<bullet>\<currency>\<currency> concat ?mss = sum_list (map2 (\<bullet>\<currency>\<currency>) ?rss ?mss)
goal (1 subgoal):
1. \<psi> T f = \<psi> T (sum_list (map2 (\<bullet>\<currency>\<currency>) css indVfbasis))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<psi> T f = \<psi> T (sum_list (map2 (\<bullet>\<currency>\<currency>) css indVfbasis))
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<psi> T f = \<psi> T (sum_list (map2 (\<bullet>\<currency>\<currency>) css indVfbasis))
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
have "\<dots> = (\<Sum>(cs,hfvs)\<leftarrow>zip css indVfbasis. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<psi> T (sum_list (map2 (\<bullet>\<currency>\<currency>) css indVfbasis)) = sum_list (map2 (\<lambda>cs hfvs. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs)) css indVfbasis)
[PROOF STEP]
using set_zip_rightD[of _ _ css indVfbasis] indVfbasis_indV
VectorSpace.lincomb_closed[OF GRep.fVectorSpace_indspace]
VectorSpaceHom.im_sum_list_prod[OF T]
[PROOF STATE]
proof (prove)
using this:
(?x, ?y) \<in> set (zip css indVfbasis) \<Longrightarrow> ?y \<in> set indVfbasis
?hfvs \<in> set indVfbasis \<Longrightarrow> set ?hfvs \<subseteq> indV
\<lbrakk>set ?rs \<subseteq> UNIV; set ?ms \<subseteq> indV\<rbrakk> \<Longrightarrow> ?rs \<bullet>\<currency>\<currency> ?ms \<in> indV
set (map (\<lambda>(x, y). ?f x y) ?xys) \<subseteq> indV \<Longrightarrow> \<psi> T (\<Sum>(x, y)\<leftarrow>?xys. ?f x y) = (\<Sum>(x, y)\<leftarrow>?xys. \<psi> T (?f x y))
goal (1 subgoal):
1. \<psi> T (sum_list (map2 (\<bullet>\<currency>\<currency>) css indVfbasis)) = sum_list (map2 (\<lambda>cs hfvs. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs)) css indVfbasis)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<psi> T (sum_list (map2 (\<bullet>\<currency>\<currency>) css indVfbasis)) = sum_list (map2 (\<lambda>cs hfvs. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs)) css indVfbasis)
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<psi> T f = sum_list (map2 (\<lambda>cs hfvs. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs)) css indVfbasis)
[PROOF STEP]
have "\<psi> T f = (\<Sum>(cs,\<psi>Thfvs)\<leftarrow>zip css (map (map (\<psi> T)) indVfbasis).
cs \<bullet>\<sharp>\<star> \<psi>Thfvs)"
[PROOF STATE]
proof (prove)
using this:
\<psi> T f = sum_list (map2 (\<lambda>cs hfvs. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs)) css indVfbasis)
goal (1 subgoal):
1. \<psi> T f = sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) indVfbasis))
[PROOF STEP]
using set_zip_rightD[of _ _ css indVfbasis] indVfbasis_indV
VectorSpaceHom.distrib_lincomb[OF T]
sum_list_prod_cong[of
"zip css indVfbasis" "\<lambda>cs hfvs. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs)"
"\<lambda>cs hfvs. cs \<bullet>\<sharp>\<star> (map (\<psi> T) hfvs)"
]
sum_list_prod_map2[of "\<lambda>cs \<psi>Thfvs. cs \<bullet>\<sharp>\<star> \<psi>Thfvs" css "map (\<psi> T)"]
[PROOF STATE]
proof (prove)
using this:
\<psi> T f = sum_list (map2 (\<lambda>cs hfvs. \<psi> T (cs \<bullet>\<currency>\<currency> hfvs)) css indVfbasis)
(?x, ?y) \<in> set (zip css indVfbasis) \<Longrightarrow> ?y \<in> set indVfbasis
?hfvs \<in> set indVfbasis \<Longrightarrow> set ?hfvs \<subseteq> indV
\<lbrakk>set ?rs \<subseteq> UNIV; set ?ms \<subseteq> indV\<rbrakk> \<Longrightarrow> \<psi> T (?rs \<bullet>\<currency>\<currency> ?ms) = ?rs \<bullet>\<sharp>\<star> map (\<psi> T) ?ms
\<forall>(x, y)\<in>set (zip css indVfbasis). \<psi> T (x \<bullet>\<currency>\<currency> y) = x \<bullet>\<sharp>\<star> map (\<psi> T) y \<Longrightarrow> sum_list (map2 (\<lambda>x y. \<psi> T (x \<bullet>\<currency>\<currency> y)) css indVfbasis) = sum_list (map2 (\<lambda>x y. x \<bullet>\<sharp>\<star> map (\<psi> T) y) css indVfbasis)
sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) ?bs)) = sum_list (map2 (\<lambda>a b. a \<bullet>\<sharp>\<star> map (\<psi> T) b) css ?bs)
goal (1 subgoal):
1. \<psi> T f = sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) indVfbasis))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<psi> T f = sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) indVfbasis))
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<psi> T f = sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) indVfbasis))
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
from css(2)
[PROOF STATE]
proof (chain)
picking this:
list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis
[PROOF STEP]
have "list_all2 (\<lambda>xs ys. length xs = length ys) css (map (map (\<psi> T)) indVfbasis)"
[PROOF STATE]
proof (prove)
using this:
list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis
goal (1 subgoal):
1. list_all2 (\<lambda>xs ys. length xs = length ys) css (map (map (\<psi> T)) indVfbasis)
[PROOF STEP]
using list_all2_iff[of _ css indVfbasis] set_zip_map2
list_all2_iff[of _ css "map (map (\<psi> T)) indVfbasis"]
[PROOF STATE]
proof (prove)
using this:
list_all2 (\<lambda>xs ys. length xs = length ys) css indVfbasis
list_all2 ?P css indVfbasis = (length css = length indVfbasis \<and> (\<forall>(x, y)\<in>set (zip css indVfbasis). ?P x y))
(?a, ?z) \<in> set (zip ?xs (map ?f ?ys)) \<Longrightarrow> \<exists>b. (?a, b) \<in> set (zip ?xs ?ys) \<and> ?z = ?f b
list_all2 ?P css (map (map (\<psi> T)) indVfbasis) = (length css = length (map (map (\<psi> T)) indVfbasis) \<and> (\<forall>(x, y)\<in>set (zip css (map (map (\<psi> T)) indVfbasis)). ?P x y))
goal (1 subgoal):
1. list_all2 (\<lambda>xs ys. length xs = length ys) css (map (map (\<psi> T)) indVfbasis)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
list_all2 (\<lambda>xs ys. length xs = length ys) css (map (map (\<psi> T)) indVfbasis)
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<psi> T f = sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) indVfbasis))
list_all2 (\<lambda>xs ys. length xs = length ys) css (map (map (\<psi> T)) indVfbasis)
[PROOF STEP]
have "\<psi> T f = (concat css) \<bullet>\<sharp>\<star> (concat (negHorbit_homVfbasis T))"
[PROOF STATE]
proof (prove)
using this:
\<psi> T f = sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) indVfbasis))
list_all2 (\<lambda>xs ys. length xs = length ys) css (map (map (\<psi> T)) indVfbasis)
goal (1 subgoal):
1. \<psi> T f = concat css \<bullet>\<sharp>\<star> concat (negHorbit_homVfbasis T)
[PROOF STEP]
using HRep.flincomb_concat map_concat[of "\<psi> T"] \<psi>D_im[OF assms]
[PROOF STATE]
proof (prove)
using this:
\<psi> T f = sum_list (map2 (\<bullet>\<sharp>\<star>) css (map (map (\<psi> T)) indVfbasis))
list_all2 (\<lambda>xs ys. length xs = length ys) css (map (map (\<psi> T)) indVfbasis)
list_all2 (\<lambda>rs ms. length rs = length ms) ?rss ?mss \<Longrightarrow> concat ?rss \<bullet>\<sharp>\<star> concat ?mss = sum_list (map2 (\<bullet>\<sharp>\<star>) ?rss ?mss)
map (\<psi> T) (concat ?xs) = concat (map (map (\<psi> T)) ?xs)
map (map (\<psi> T)) indVfbasis = negHorbit_homVfbasis T
goal (1 subgoal):
1. \<psi> T f = concat css \<bullet>\<sharp>\<star> concat (negHorbit_homVfbasis T)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<psi> T f = concat css \<bullet>\<sharp>\<star> concat (negHorbit_homVfbasis T)
goal (1 subgoal):
1. \<And>x. x \<in> indV \<Longrightarrow> \<psi> T x \<in> W
[PROOF STEP]
thus "\<psi> T f \<in> W"
[PROOF STATE]
proof (prove)
using this:
\<psi> T f = concat css \<bullet>\<sharp>\<star> concat (negHorbit_homVfbasis T)
goal (1 subgoal):
1. \<psi> T f \<in> W
[PROOF STEP]
using assms negHorbit_HomSet_indVfbasis_W HRep.flincomb_closed
[PROOF STATE]
proof (prove)
using this:
\<psi> T f = concat css \<bullet>\<sharp>\<star> concat (negHorbit_homVfbasis T)
T \<in> GRepHomSet (\<star>) W
?T \<in> GRepHomSet (\<star>) W \<Longrightarrow> set (concat (negHorbit_homVfbasis ?T)) \<subseteq> W
\<lbrakk>set ?rs \<subseteq> UNIV; set ?ms \<subseteq> W\<rbrakk> \<Longrightarrow> ?rs \<bullet>\<sharp>\<star> ?ms \<in> W
goal (1 subgoal):
1. \<psi> T f \<in> W
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<psi> T f \<in> W
goal:
No subgoals!
[PROOF STEP]
qed |
module Tactic.Reflection.Quote where
open import Prelude
open import Builtin.Reflection
open import Builtin.Float
open import Tactic.Reflection.Quote.Class public
open import Tactic.Deriving.Quotable
open import Container.Traversable
--- Instances ---
private
QuoteLit : {A : Set} → (A → Literal) → Quotable A
` {{QuoteLit f}} x = lit (f x)
-- Primitive types --
instance
QuotableNat = QuoteLit nat
QuotableWord64 = QuoteLit word64
QuotableFloat = QuoteLit float
QuotableString = QuoteLit string
QuotableChar = QuoteLit char
QuotableName = QuoteLit name
-- Standard data types --
unquoteDecl QuotableBool = deriveQuotable QuotableBool (quote Bool)
unquoteDecl QuotableList = deriveQuotable QuotableList (quote List)
unquoteDecl QuotableMaybe = deriveQuotable QuotableMaybe (quote Maybe)
unquoteDecl QuotableEither = deriveQuotable QuotableEither (quote Either)
instance
QuotableΣ : ∀ {a b} {A : Set a} {B : A → Set b} {{_ : Quotable A}} {{_ : {x : A} → Quotable (B x)}} → Quotable (Σ A λ a → B a)
QuotableΣ = record { ` = λ { (x , y) → con (quote _,_) ((vArg (` x)) ∷ vArg (` y) ∷ [])} }
unquoteDecl Quotable⊤ = deriveQuotable Quotable⊤ (quote ⊤)
unquoteDecl Quotable⊥ = deriveQuotable Quotable⊥ (quote ⊥)
unquoteDecl Quotable≡ = deriveQuotable Quotable≡ (quote _≡_)
unquoteDecl QuotableComparison = deriveQuotable QuotableComparison (quote Comparison)
unquoteDecl QuotableLessNat = deriveQuotable QuotableLessNat (quote LessNat)
unquoteDecl QuotableInt = deriveQuotable QuotableInt (quote Int)
-- The reflection machinery can't deal with computational irrelevance (..)
-- unquoteDecl QuotableFin = deriveQuotable QuotableFin (quote Fin)
-- unquoteDecl QuotableVec = deriveQuotable QuotableVec (quote Vec)
instance
QuotableFin : ∀ {n} → Quotable (Fin n)
` {{QuotableFin}} zero = con (quote Fin.zero) []
` {{QuotableFin}} (suc i) = con (quote Fin.suc) (vArg (` i) ∷ [])
QuotableVec : ∀ {a} {A : Set a} {n} {{_ : Quotable A}} → Quotable (Vec A n)
` {{QuotableVec}} [] = con (quote Vec.[]) []
` {{QuotableVec}} (x ∷ xs) = con (quote Vec._∷_) (vArg (` x) ∷ vArg (` xs) ∷ [])
-- Reflection types --
instance
QuotableMeta : Quotable Meta
` {{QuotableMeta}} x = lit (meta x)
private
deriveQuotableTermTypes : Vec Name _ → TC ⊤
deriveQuotableTermTypes is = do
let ts : Vec Name _
ts = quote Term ∷ quote Clause ∷ quote Sort ∷ []
its = ⦇ is , ts ⦈
traverse (uncurry declareQuotableInstance) its
traverse (uncurry defineQuotableInstance) its
pure _
unquoteDecl QuotableVisibility QuotableRelevance QuotableArgInfo
QuotableArg QuotableAbs QuotableLiteral = do
deriveQuotable QuotableVisibility (quote Visibility)
deriveQuotable QuotableRelevance (quote Relevance)
deriveQuotable QuotableArgInfo (quote ArgInfo)
deriveQuotable QuotableArg (quote Arg)
deriveQuotable QuotableAbs (quote Abs)
deriveQuotable QuotableLiteral (quote Literal)
{-# TERMINATING #-}
unquoteDecl QuotablePattern QuotableTerm QuotableClause QuotableSort = do
deriveQuotable QuotablePattern (quote Pattern)
deriveQuotableTermTypes (QuotableTerm ∷ QuotableClause ∷ QuotableSort ∷ [])
quoteList : List Term → Term
quoteList = foldr (λ x xs → con (quote List._∷_) (vArg x ∷ vArg xs ∷ [])) (con (quote List.[]) [])
|
import LMT
variable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]
example {a1 a2 a3 : A I E} :
((a3).write i1 (v3)) = ((a3).write i1 (v1)) → (v1) ≠ (v3) → False := by
arr
|
module API
import Test.API
import Test.API3
import Test.API2
|
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y : Kleisli T
f : X ⟶ Y
⊢ 𝟙 X ≫ f = f
[PROOFSTEP]
dsimp
-- Porting note: unfold comp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y : Kleisli T
f : X ⟶ Y
⊢ NatTrans.app (Monad.η T) X ≫ T.map f ≫ NatTrans.app (Monad.μ T) Y = f
[PROOFSTEP]
rw [← T.η.naturality_assoc f, T.left_unit]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y : Kleisli T
f : X ⟶ Y
⊢ (𝟭 C).map f ≫ 𝟙 (T.obj Y) = f
[PROOFSTEP]
apply Category.comp_id
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
W✝ X✝ Y✝ Z✝ : Kleisli T
f : W✝ ⟶ X✝
g : X✝ ⟶ Y✝
h : Y✝ ⟶ Z✝
⊢ (f ≫ g) ≫ h = f ≫ g ≫ h
[PROOFSTEP]
simp only [Functor.map_comp, Category.assoc, Monad.assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
W✝ X✝ Y✝ Z✝ : Kleisli T
f : W✝ ⟶ X✝
g : X✝ ⟶ Y✝
h : Y✝ ⟶ Z✝
⊢ f ≫ T.map g ≫ NatTrans.app (Monad.μ T) Y✝ ≫ T.map h ≫ NatTrans.app (Monad.μ T) Z✝ =
f ≫ T.map g ≫ T.map (T.map h) ≫ NatTrans.app (Monad.μ T) (T.obj Z✝) ≫ NatTrans.app (Monad.μ T) Z✝
[PROOFSTEP]
erw [T.μ.naturality_assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y Z : C
f : X ⟶ Y
g : Y ⟶ Z
⊢ { obj := fun X => X, map := fun {X Y} f => f ≫ NatTrans.app (Monad.η T) Y }.map (f ≫ g) =
{ obj := fun X => X, map := fun {X Y} f => f ≫ NatTrans.app (Monad.η T) Y }.map f ≫
{ obj := fun X => X, map := fun {X Y} f => f ≫ NatTrans.app (Monad.η T) Y }.map g
[PROOFSTEP]
change _ = (f ≫ (Monad.η T).app Y) ≫ T.map (g ≫ (Monad.η T).app Z) ≫ T.μ.app Z
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y Z : C
f : X ⟶ Y
g : Y ⟶ Z
⊢ { obj := fun X => X, map := fun {X Y} f => f ≫ NatTrans.app (Monad.η T) Y }.map (f ≫ g) =
(f ≫ NatTrans.app (Monad.η T) Y) ≫ T.map (g ≫ NatTrans.app (Monad.η T) Z) ≫ NatTrans.app (Monad.μ T) Z
[PROOFSTEP]
simp [← T.η.naturality g]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ Z
⊢ { obj := fun X => T.obj X, map := fun {x Y} f => T.map f ≫ NatTrans.app (Monad.μ T) Y }.map (f ≫ g) =
{ obj := fun X => T.obj X, map := fun {x Y} f => T.map f ≫ NatTrans.app (Monad.μ T) Y }.map f ≫
{ obj := fun X => T.obj X, map := fun {x Y} f => T.map f ≫ NatTrans.app (Monad.μ T) Y }.map g
[PROOFSTEP]
change T.map (f ≫ T.map g ≫ T.μ.app Z) ≫ T.μ.app Z = _
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ Z
⊢ T.map (f ≫ T.map g ≫ NatTrans.app (Monad.μ T) Z) ≫ NatTrans.app (Monad.μ T) Z =
{ obj := fun X => T.obj X, map := fun {x Y} f => T.map f ≫ NatTrans.app (Monad.μ T) Y }.map f ≫
{ obj := fun X => T.obj X, map := fun {x Y} f => T.map f ≫ NatTrans.app (Monad.μ T) Y }.map g
[PROOFSTEP]
simp only [Functor.map_comp, Category.assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ Z
⊢ T.map f ≫ T.map (T.map g) ≫ T.map (NatTrans.app (Monad.μ T) Z) ≫ NatTrans.app (Monad.μ T) Z =
T.map f ≫ NatTrans.app (Monad.μ T) Y ≫ T.map g ≫ NatTrans.app (Monad.μ T) Z
[PROOFSTEP]
erw [← T.μ.naturality_assoc g, T.assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ Z
⊢ T.map f ≫ T.map (T.map g) ≫ NatTrans.app (Monad.μ T) (T.obj Z) ≫ NatTrans.app (Monad.μ T) Z =
T.map f ≫ (T.toFunctor ⋙ T.toFunctor).map g ≫ NatTrans.app (Monad.μ T) (T.obj Z) ≫ NatTrans.app (Monad.μ T) Z
[PROOFSTEP]
rfl
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y : C
Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ (fromKleisli T).obj Z
⊢ ↑((fun X Y => Equiv.refl (X ⟶ T.obj Y)) X Z).symm (f ≫ g) =
(toKleisli T).map f ≫ ↑((fun X Y => Equiv.refl (X ⟶ T.obj Y)) Y Z).symm g
[PROOFSTEP]
change f ≫ g = (f ≫ T.η.app Y) ≫ T.map g ≫ T.μ.app Z
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y : C
Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ (fromKleisli T).obj Z
⊢ f ≫ g = (f ≫ NatTrans.app (Monad.η T) Y) ≫ T.map g ≫ NatTrans.app (Monad.μ T) Z
[PROOFSTEP]
rw [Category.assoc, ← T.η.naturality_assoc g, Functor.id_map]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y : C
Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ (fromKleisli T).obj Z
⊢ f ≫ g = f ≫ g ≫ NatTrans.app (Monad.η T) ((fromKleisli T).obj Z) ≫ NatTrans.app (Monad.μ T) Z
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
T : Monad C
X Y : C
Z : Kleisli T
f : X ⟶ Y
g : Y ⟶ (fromKleisli T).obj Z
⊢ f ≫ g = f ≫ g ≫ NatTrans.app (Monad.η T) (T.obj Z) ≫ NatTrans.app (Monad.μ T) Z
[PROOFSTEP]
simp [Monad.left_unit]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X✝ Y✝ : Cokleisli U
f : X✝ ⟶ Y✝
⊢ 𝟙 X✝ ≫ f = f
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X✝ Y✝ : Cokleisli U
f : X✝ ⟶ Y✝
⊢ NatTrans.app (Comonad.δ U) X✝ ≫ U.map (NatTrans.app (Comonad.ε U) X✝) ≫ f = f
[PROOFSTEP]
rw [U.right_counit_assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y Z W : Cokleisli U
f : X ⟶ Y
g : Y ⟶ Z
h : Z ⟶ W
⊢ (f ≫ g) ≫ h = f ≫ g ≫ h
[PROOFSTEP]
change
U.δ.app X ≫ U.map (U.δ.app X ≫ U.map f ≫ g) ≫ h =
U.δ.app X ≫
U.map f ≫
(U.δ.app Y ≫ U.map g ≫ h)
-- Porting note: something was broken here and was easier just to redo from scratch
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y Z W : Cokleisli U
f : X ⟶ Y
g : Y ⟶ Z
h : Z ⟶ W
⊢ NatTrans.app (Comonad.δ U) X ≫ U.map (NatTrans.app (Comonad.δ U) X ≫ U.map f ≫ g) ≫ h =
NatTrans.app (Comonad.δ U) X ≫ U.map f ≫ NatTrans.app (Comonad.δ U) Y ≫ U.map g ≫ h
[PROOFSTEP]
simp only [Functor.map_comp, ← Category.assoc, eq_whisker]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y Z W : Cokleisli U
f : X ⟶ Y
g : Y ⟶ Z
h : Z ⟶ W
⊢ (((NatTrans.app (Comonad.δ U) X ≫ U.map (NatTrans.app (Comonad.δ U) X)) ≫ U.map (U.map f)) ≫ U.map g) ≫ h =
(((NatTrans.app (Comonad.δ U) X ≫ U.map f) ≫ NatTrans.app (Comonad.δ U) Y) ≫ U.map g) ≫ h
[PROOFSTEP]
simp only [Category.assoc, U.δ.naturality, Functor.comp_map, U.coassoc_assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y x✝ : C
f : X ⟶ Y
g : Y ⟶ x✝
⊢ { obj := fun X => X, map := fun {X x} f => NatTrans.app (Comonad.ε U) X ≫ f }.map (f ≫ g) =
{ obj := fun X => X, map := fun {X x} f => NatTrans.app (Comonad.ε U) X ≫ f }.map f ≫
{ obj := fun X => X, map := fun {X x} f => NatTrans.app (Comonad.ε U) X ≫ f }.map g
[PROOFSTEP]
change U.ε.app X ≫ f ≫ g = U.δ.app X ≫ U.map (U.ε.app X ≫ f) ≫ U.ε.app Y ≫ g
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y x✝ : C
f : X ⟶ Y
g : Y ⟶ x✝
⊢ NatTrans.app (Comonad.ε U) X ≫ f ≫ g =
NatTrans.app (Comonad.δ U) X ≫ U.map (NatTrans.app (Comonad.ε U) X ≫ f) ≫ NatTrans.app (Comonad.ε U) Y ≫ g
[PROOFSTEP]
simp [← U.ε.naturality g]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y x✝ : Cokleisli U
f : X ⟶ Y
g : Y ⟶ x✝
⊢ { obj := fun X => U.obj X, map := fun {X x} f => NatTrans.app (Comonad.δ U) X ≫ U.map f }.map (f ≫ g) =
{ obj := fun X => U.obj X, map := fun {X x} f => NatTrans.app (Comonad.δ U) X ≫ U.map f }.map f ≫
{ obj := fun X => U.obj X, map := fun {X x} f => NatTrans.app (Comonad.δ U) X ≫ U.map f }.map g
[PROOFSTEP]
change U.δ.app X ≫ U.map (U.δ.app X ≫ U.map f ≫ g) = (U.δ.app X ≫ U.map f) ≫ (U.δ.app Y ≫ U.map g)
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y x✝ : Cokleisli U
f : X ⟶ Y
g : Y ⟶ x✝
⊢ NatTrans.app (Comonad.δ U) X ≫ U.map (NatTrans.app (Comonad.δ U) X ≫ U.map f ≫ g) =
(NatTrans.app (Comonad.δ U) X ≫ U.map f) ≫ NatTrans.app (Comonad.δ U) Y ≫ U.map g
[PROOFSTEP]
simp only [Functor.map_comp, ← Category.assoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y x✝ : Cokleisli U
f : X ⟶ Y
g : Y ⟶ x✝
⊢ ((NatTrans.app (Comonad.δ U) X ≫ U.map (NatTrans.app (Comonad.δ U) X)) ≫ U.map (U.map f)) ≫ U.map g =
((NatTrans.app (Comonad.δ U) X ≫ U.map f) ≫ NatTrans.app (Comonad.δ U) Y) ≫ U.map g
[PROOFSTEP]
rw [Comonad.coassoc]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X Y x✝ : Cokleisli U
f : X ⟶ Y
g : Y ⟶ x✝
⊢ ((NatTrans.app (Comonad.δ U) X ≫ NatTrans.app (Comonad.δ U) (U.obj X)) ≫ U.map (U.map f)) ≫ U.map g =
((NatTrans.app (Comonad.δ U) X ≫ U.map f) ≫ NatTrans.app (Comonad.δ U) Y) ≫ U.map g
[PROOFSTEP]
simp only [Category.assoc, NatTrans.naturality, Functor.comp_map]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X : Cokleisli U
Y x✝ : C
f : (fromCokleisli U).obj X ⟶ Y
g : Y ⟶ x✝
⊢ ↑((fun X Y => Equiv.refl (U.obj X ⟶ Y)) X x✝) (f ≫ g) =
↑((fun X Y => Equiv.refl (U.obj X ⟶ Y)) X Y) f ≫ (toCokleisli U).map g
[PROOFSTEP]
change f ≫ g = U.δ.app X ≫ U.map f ≫ U.ε.app Y ≫ g
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X : Cokleisli U
Y x✝ : C
f : (fromCokleisli U).obj X ⟶ Y
g : Y ⟶ x✝
⊢ f ≫ g = NatTrans.app (Comonad.δ U) X ≫ U.map f ≫ NatTrans.app (Comonad.ε U) Y ≫ g
[PROOFSTEP]
erw [← Category.assoc (U.map f), U.ε.naturality]
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X : Cokleisli U
Y x✝ : C
f : (fromCokleisli U).obj X ⟶ Y
g : Y ⟶ x✝
⊢ f ≫ g = NatTrans.app (Comonad.δ U) X ≫ (NatTrans.app (Comonad.ε U) ((fromCokleisli U).obj X) ≫ (𝟭 C).map f) ≫ g
[PROOFSTEP]
dsimp
[GOAL]
C : Type u
inst✝ : Category.{v, u} C
U : Comonad C
X : Cokleisli U
Y x✝ : C
f : (fromCokleisli U).obj X ⟶ Y
g : Y ⟶ x✝
⊢ f ≫ g = NatTrans.app (Comonad.δ U) X ≫ (NatTrans.app (Comonad.ε U) (U.obj X) ≫ f) ≫ g
[PROOFSTEP]
simp only [← Category.assoc, Comonad.left_counit, Category.id_comp]
|
function my_diary_flush()
tmp_status=get(0,'Diary');
if strcmp(tmp_status, 'on')
diary off
diary on
end
end |
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
⊢ Cauchy F ↔ NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
letI := B.uniformSpace
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this : UniformSpace G := AddGroupFilterBasis.uniformSpace B
⊢ Cauchy F ↔ NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
haveI := B.uniformAddGroup
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this : UniformAddGroup G
⊢ Cauchy F ↔ NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
suffices F ×ˢ F ≤ uniformity G ↔ ∀ U ∈ B, ∃ M ∈ F, ∀ (x) (_ : x ∈ M) (y) (_ : y ∈ M), y - x ∈ U by
constructor <;> rintro ⟨h', h⟩ <;> refine' ⟨h', _⟩ <;> [rwa [← this]; rwa [this]]
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
⊢ Cauchy F ↔ NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
constructor <;> rintro ⟨h', h⟩ <;> refine' ⟨h', _⟩ <;> [rwa [← this]; rwa [this]]
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
⊢ Cauchy F ↔ NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
constructor
[GOAL]
case mp
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
⊢ Cauchy F → NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
rintro ⟨h', h⟩
[GOAL]
case mpr
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
⊢ (NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U) → Cauchy F
[PROOFSTEP]
rintro ⟨h', h⟩
[GOAL]
case mp.intro
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
h' : NeBot F
h : F ×ˢ F ≤ uniformity G
⊢ NeBot F ∧ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
refine' ⟨h', _⟩
[GOAL]
case mpr.intro
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
h' : NeBot F
h : ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
⊢ Cauchy F
[PROOFSTEP]
refine' ⟨h', _⟩
[GOAL]
case mp.intro
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
h' : NeBot F
h : F ×ˢ F ≤ uniformity G
⊢ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
rwa [← this]
[GOAL]
case mpr.intro
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝¹ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this✝ : UniformAddGroup G
this : F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
h' : NeBot F
h : ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
⊢ F ×ˢ F ≤ uniformity G
[PROOFSTEP]
rwa [this]
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this : UniformAddGroup G
⊢ F ×ˢ F ≤ uniformity G ↔ ∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
rw [uniformity_eq_comap_nhds_zero G, ← map_le_iff_le_comap]
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this : UniformAddGroup G
⊢ map (fun x => x.snd - x.fst) (F ×ˢ F) ≤ nhds 0 ↔
∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
change Tendsto _ _ _ ↔ _
[GOAL]
G : Type u_1
inst✝ : AddCommGroup G
B : AddGroupFilterBasis G
F : Filter G
this✝ : UniformSpace G := AddGroupFilterBasis.uniformSpace B
this : UniformAddGroup G
⊢ Tendsto (fun x => x.snd - x.fst) (F ×ˢ F) (nhds 0) ↔
∀ (U : Set G), U ∈ B → ∃ M, M ∈ F ∧ ∀ (x : G), x ∈ M → ∀ (y : G), y ∈ M → y - x ∈ U
[PROOFSTEP]
simp [(basis_sets F).prod_self.tendsto_iff B.nhds_zero_hasBasis, @forall_swap (_ ∈ _) G]
|
#include "Day05-HydrothermalVenture.h"
#include "LineSegment.h"
#include "HydrothermalVentAnalyzer.h"
#include <AdventOfCodeCommon/DisableLibraryWarningsMacros.h>
__BEGIN_LIBRARIES_DISABLE_WARNINGS
#include <boost/algorithm/string.hpp>
#include <unordered_map>
__END_LIBRARIES_DISABLE_WARNINGS
namespace AdventOfCode
{
namespace Year2021
{
namespace Day05
{
Vector2D parseCoordinatesString(const std::string& coordinatesString)
{
std::vector<std::string> tokens;
boost::split(tokens, coordinatesString, boost::is_any_of(","));
return Vector2D{std::stoi(tokens.at(0)), std::stoi(tokens.at(1))};
}
LineSegment parseVentLine(const std::string& ventLine)
{
std::vector<std::string> tokens;
boost::split(tokens, ventLine, boost::is_any_of(" ->"), boost::token_compress_on);
Vector2D start = parseCoordinatesString(tokens.at(0));
Vector2D end = parseCoordinatesString(tokens.at(1));
return LineSegment{std::move(start), std::move(end)};
}
std::vector<LineSegment> parseVentLines(const std::vector<std::string>& ventLines)
{
std::vector<LineSegment> ventLineSegments;
for (const auto& line : ventLines)
{
LineSegment ventLineSegment = parseVentLine(line);
ventLineSegments.push_back(std::move(ventLineSegment));
}
return ventLineSegments;
}
int numPointsWhereHorizontalOrVerticalLinesOverlap(const std::vector<std::string>& ventLines)
{
std::vector<LineSegment> ventLineSegments = parseVentLines(ventLines);
std::vector<LineSegment> axisParallelVentLineSegments;
std::copy_if(ventLineSegments.cbegin(), ventLineSegments.cend(), std::back_inserter(axisParallelVentLineSegments), [](const auto& lineSegment)
{
return lineSegment.isAxisParallel();
});
HydrothermalVentAnalyzer hydrothermalVentAnalyzer{axisParallelVentLineSegments};
hydrothermalVentAnalyzer.analyzeOverlaps();
return hydrothermalVentAnalyzer.getNumPointsWithOverlap();
}
int numPointsWhereLinesOverlap(const std::vector<std::string>& ventLines)
{
std::vector<LineSegment> ventLineSegments = parseVentLines(ventLines);
HydrothermalVentAnalyzer hydrothermalVentAnalyzer{ventLineSegments};
hydrothermalVentAnalyzer.analyzeOverlaps();
return hydrothermalVentAnalyzer.getNumPointsWithOverlap();
}
}
}
} |
{-# OPTIONS --warning=ignore #-}
module Issue2596 where
{-# REWRITE #-}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Definition
module Numbers.Integers.Definition where
data ℤ : Set where
nonneg : ℕ → ℤ
negSucc : ℕ → ℤ
{-# BUILTIN INTEGER ℤ #-}
{-# BUILTIN INTEGERPOS nonneg #-}
{-# BUILTIN INTEGERNEGSUC negSucc #-}
nonnegInjective : {a b : ℕ} → nonneg a ≡ nonneg b → a ≡ b
nonnegInjective refl = refl
negSuccInjective : {a b : ℕ} → negSucc a ≡ negSucc b → a ≡ b
negSuccInjective refl = refl
ℤDecideEquality : (a b : ℤ) → ((a ≡ b) || ((a ≡ b) → False))
ℤDecideEquality (nonneg x) (nonneg y) with ℕDecideEquality x y
ℤDecideEquality (nonneg x) (nonneg y) | inl eq = inl (applyEquality nonneg eq)
ℤDecideEquality (nonneg x) (nonneg y) | inr non = inr λ i → non (nonnegInjective i)
ℤDecideEquality (nonneg x) (negSucc y) = inr λ ()
ℤDecideEquality (negSucc x) (nonneg x₁) = inr λ ()
ℤDecideEquality (negSucc x) (negSucc y) with ℕDecideEquality x y
ℤDecideEquality (negSucc x) (negSucc y) | inl eq = inl (applyEquality negSucc eq)
ℤDecideEquality (negSucc x) (negSucc y) | inr non = inr λ i → non (negSuccInjective i)
|
theory NN_is_countable
imports Countable ETCS_Ordinal_Inequalities
begin
lemma nonzero_to_any_power:
assumes "a \<in>\<^sub>c \<nat>\<^sub>c" "b \<in>\<^sub>c \<nat>\<^sub>c" "a \<noteq> zero"
shows "a ^\<^sub>\<nat> b \<noteq> zero"
by (simp add: assms(1) assms(2) assms(3) exp_order_preserving1 nonzero_to_k_nonzero)
lemma RENAME_ME:
assumes "a \<in>\<^sub>c \<nat>\<^sub>c" "b \<in>\<^sub>c \<nat>\<^sub>c"
assumes "a \<noteq> successor \<circ>\<^sub>c zero"
shows "(b = zero) = (a ^\<^sub>\<nat> b = successor \<circ>\<^sub>c zero)"
proof(auto)
show "b = zero \<Longrightarrow> a ^\<^sub>\<nat> zero = successor \<circ>\<^sub>c zero"
by (simp add: assms(1) exp_respects_Zero_Left)
show "a ^\<^sub>\<nat> b = successor \<circ>\<^sub>c zero \<Longrightarrow> b = zero"
by (smt (verit, best) add_respects_zero_on_right assms(1) assms(2) assms(3) cfunc_type_def comp_type exists_implies_leq_true exp_closure exp_order_preserving1 exp_order_preserving_converse exp_respects_Zero_Left exp_respects_one_left exp_respects_successor lqe_antisymmetry nonzero_is_succ s0_is_right_id zero_type)
qed
lemma exp_cancellative:
assumes "a \<in>\<^sub>c \<nat>\<^sub>c" "b \<in>\<^sub>c \<nat>\<^sub>c" "c \<in>\<^sub>c \<nat>\<^sub>c" "a \<noteq> zero" "a \<noteq> successor \<circ>\<^sub>c zero"
shows "(a ^\<^sub>\<nat> b = a ^\<^sub>\<nat> c) = (b = c)"
proof(auto)
assume "(a ^\<^sub>\<nat> b = a ^\<^sub>\<nat> c)"
have "a ^\<^sub>\<nat> b \<noteq> zero"
by (simp add: assms(1) assms(2) assms(4) nonzero_to_any_power)
show "b = c"
proof(cases "leq \<circ>\<^sub>c \<langle>b, c\<rangle> = \<t>")
assume "leq \<circ>\<^sub>c \<langle>b, c\<rangle> = \<t>"
then obtain k where k_type[type_rule]: "k \<in>\<^sub>c \<nat>\<^sub>c" and k_def: "k +\<^sub>\<nat> b = c"
by (meson assms(2) assms(3) leq_true_implies_exists)
then have "a ^\<^sub>\<nat> b = (a ^\<^sub>\<nat> k) \<cdot>\<^sub>\<nat> (a ^\<^sub>\<nat> b)"
using \<open>a ^\<^sub>\<nat> b = a ^\<^sub>\<nat> c\<close> assms(1) assms(2) exp_right_dist by force
then have "successor \<circ>\<^sub>c zero = a ^\<^sub>\<nat> k"
by (typecheck_cfuncs, metis \<open>a ^\<^sub>\<nat> b = a ^\<^sub>\<nat> c\<close> \<open>a ^\<^sub>\<nat> b \<noteq> zero\<close> assms(1) assms(3) exp_closure l_mult_cancellative mult_commutative s0_is_right_id)
then have "k = zero"
using assms(1) assms(5) k_type RENAME_ME by force
then show "b = c"
using add_respects_zero_on_left assms(2) k_def by presburger
next
assume "leq \<circ>\<^sub>c \<langle>b,c\<rangle> \<noteq> \<t>"
then have "leq \<circ>\<^sub>c \<langle>c,b\<rangle> = \<t>"
using \<open>leq \<circ>\<^sub>c \<langle>b,c\<rangle> \<noteq> \<t>\<close> assms(2) assms(3) lqe_connexity by blast
then obtain k where k_type[type_rule]: "k \<in>\<^sub>c \<nat>\<^sub>c" and k_def: "k +\<^sub>\<nat> c = b"
by (meson assms(2) assms(3) leq_true_implies_exists)
then have "a ^\<^sub>\<nat> b = (a ^\<^sub>\<nat> k) \<cdot>\<^sub>\<nat> (a ^\<^sub>\<nat> c)"
using assms(1) assms(3) exp_right_dist by force
then have "successor \<circ>\<^sub>c zero = a ^\<^sub>\<nat> k"
by (typecheck_cfuncs, metis \<open>a ^\<^sub>\<nat> b = a ^\<^sub>\<nat> c\<close> \<open>a ^\<^sub>\<nat> b \<noteq> zero\<close> assms(1) assms(3) exp_closure l_mult_cancellative mult_commutative s0_is_right_id)
then have "k = zero"
using assms(1) assms(5) k_type RENAME_ME by force
then show "b = c"
using add_respects_zero_on_left assms(3) k_def by force
qed
qed
(*
lemma exp_cancellative2:
assumes "a \<in>\<^sub>c \<nat>\<^sub>c" "b \<in>\<^sub>c \<nat>\<^sub>c" "c \<in>\<^sub>c \<nat>\<^sub>c" "a \<noteq> zero"
shows "(b ^\<^sub>\<nat> a = c ^\<^sub>\<nat> a) = (b = c)"
proof(auto)
*)
(*
proof(auto)
assume "b ^\<^sub>\<nat> a = c ^\<^sub>\<nat> a"
obtain k where k_type[type_rule]: "k \<in>\<^sub>c \<nat>\<^sub>c" and k_def: "successor \<circ>\<^sub>c k = a"
using assms(1) assms(4) nonzero_is_succ by blast
then have "b ^\<^sub>\<nat> ((successor \<circ>\<^sub>c zero) +\<^sub>\<nat> k) = c ^\<^sub>\<nat> ((successor \<circ>\<^sub>c zero) +\<^sub>\<nat> k)"
using \<open>b ^\<^sub>\<nat> a = c ^\<^sub>\<nat> a\<close> add_respects_succ3 add_respects_zero_on_left k_def by (typecheck_cfuncs, presburger)
then have "(b ^\<^sub>\<nat> (successor \<circ>\<^sub>c zero)) \<cdot>\<^sub>\<nat> (b ^\<^sub>\<nat> k) = (c ^\<^sub>\<nat> (successor \<circ>\<^sub>c zero)) \<cdot>\<^sub>\<nat> (c ^\<^sub>\<nat> k)"
by (typecheck_cfuncs, metis \<open>b ^\<^sub>\<nat> a = c ^\<^sub>\<nat> a\<close> assms(2) assms(3) exp_respects_one_right exp_respects_successor k_def)
then have "b \<cdot>\<^sub>\<nat> (b ^\<^sub>\<nat> k) = c \<cdot>\<^sub>\<nat> (c ^\<^sub>\<nat> k)"
by (metis \<open>b ^\<^sub>\<nat> a = c ^\<^sub>\<nat> a\<close> assms(2) assms(3) exp_respects_successor k_def k_type)
show "b = c"
proof(cases "leq \<circ>\<^sub>c \<langle>b ^\<^sub>\<nat> k,c ^\<^sub>\<nat> k\<rangle> = \<t>")
assume "leq \<circ>\<^sub>c \<langle>b ^\<^sub>\<nat> k,c ^\<^sub>\<nat> k\<rangle> = \<t>"
then obtain j where j_type[type_rule]: "j \<in>\<^sub>c \<nat>\<^sub>c" and j_def: "(b ^\<^sub>\<nat> k) +\<^sub>\<nat> j = c ^\<^sub>\<nat> k"
by (metis add_commutes assms(2) assms(3) exp_closure k_type leq_true_implies_exists)
have "j = zero"
proof(rule ccontr)
oops
*)
(*Proposition 2.6.10*)
lemma NxN_is_countable:
"countable(\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c)"
proof -
obtain \<phi> where \<phi>_def: " \<phi> = mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>(\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c)\<^esub>, left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle> ,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>(\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c)\<^esub>, right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle> \<rangle>"
by auto
have \<phi>_type[type_rule]: "\<phi> : \<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c \<rightarrow> \<nat>\<^sub>c"
unfolding \<phi>_def by typecheck_cfuncs
have \<phi>_injective: "injective(\<phi>)"
proof(unfold injective_def, auto)
fix mn st
assume mn_type: "mn \<in>\<^sub>c domain \<phi>"
assume st_type: "st \<in>\<^sub>c domain \<phi>"
assume equals: "\<phi> \<circ>\<^sub>c mn = \<phi> \<circ>\<^sub>c st"
have mn_type2: "mn \<in>\<^sub>c \<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c"
using \<phi>_type cfunc_type_def mn_type by force
have st_type2: "st \<in>\<^sub>c \<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c"
using \<phi>_type cfunc_type_def st_type by force
obtain m and n where m_type[type_rule]: "m \<in>\<^sub>c \<nat>\<^sub>c" and n_type[type_rule]: "n \<in>\<^sub>c \<nat>\<^sub>c" and mn_def: "mn = \<langle>m,n\<rangle>"
using cart_prod_decomp mn_type2 by blast
obtain s and t where s_type[type_rule]: "s \<in>\<^sub>c \<nat>\<^sub>c" and t_type[type_rule]: "t \<in>\<^sub>c \<nat>\<^sub>c" and st_def: "st = \<langle>s,t\<rangle>"
using cart_prod_decomp st_type2 by blast
have simplify: "\<And> u v. u \<in>\<^sub>c \<nat>\<^sub>c \<Longrightarrow> v \<in>\<^sub>c \<nat>\<^sub>c \<Longrightarrow> \<phi> \<circ>\<^sub>c \<langle>u,v\<rangle> = ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> u) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> v)"
proof(unfold \<phi>_def)
fix u v
assume u_type[type_rule]: "u \<in>\<^sub>c \<nat>\<^sub>c"
assume v_type[type_rule]: "v \<in>\<^sub>c \<nat>\<^sub>c"
have "(mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle>,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle>\<rangle>) \<circ>\<^sub>c \<langle>u,v\<rangle> =
mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle>,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle>\<rangle> \<circ>\<^sub>c \<langle>u,v\<rangle>"
by (typecheck_cfuncs, smt (z3) comp_associative2)
also have "... = mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle> \<circ>\<^sub>c \<langle>u,v\<rangle>,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle> \<circ>\<^sub>c \<langle>u,v\<rangle>\<rangle>"
by (typecheck_cfuncs, smt (z3) cfunc_prod_comp comp_associative2)
also have "... = mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c (\<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub> \<circ>\<^sub>c \<langle>u,v\<rangle>),left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c \<circ>\<^sub>c \<langle>u,v\<rangle>\<rangle> ,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c (\<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub> \<circ>\<^sub>c \<langle>u,v\<rangle>),right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c \<circ>\<^sub>c \<langle>u,v\<rangle> \<rangle> \<rangle>"
by (typecheck_cfuncs, smt (z3) cfunc_prod_comp comp_associative2)
also have "... = mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c (id one),left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c \<circ>\<^sub>c \<langle>u,v\<rangle>\<rangle> ,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c (id one),right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c \<circ>\<^sub>c \<langle>u,v\<rangle>\<rangle> \<rangle>"
by (typecheck_cfuncs, metis (full_types) one_unique_element)
also have "... = mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) ,left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c \<circ>\<^sub>c \<langle>u,v\<rangle>\<rangle> ,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) ,right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c \<circ>\<^sub>c \<langle>u,v\<rangle>\<rangle> \<rangle>"
by (typecheck_cfuncs, metis id_right_unit2)
also have "... = mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) , u \<rangle> ,
exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) ,v\<rangle> \<rangle>"
using left_cart_proj_cfunc_prod mn_def right_cart_proj_cfunc_prod by (typecheck_cfuncs, auto)
also have "... =((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> u) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> v)"
by (metis exp_def mult_def)
then show "(mult2 \<circ>\<^sub>c \<langle>exp_uncurried \<circ>\<^sub>c\<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,left_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle>,exp_uncurried \<circ>\<^sub>c \<langle>(successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) \<circ>\<^sub>c \<beta>\<^bsub>\<nat>\<^sub>c \<times>\<^sub>c \<nat>\<^sub>c\<^esub>,right_cart_proj \<nat>\<^sub>c \<nat>\<^sub>c\<rangle>\<rangle>) \<circ>\<^sub>c \<langle>u,v\<rangle> =
(successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) ^\<^sub>\<nat> u \<cdot>\<^sub>\<nat> (successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero) ^\<^sub>\<nat> v"
by (metis calculation)
qed
have equals2: "((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> m) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) =
((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> s) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t)"
using equals m_type mn_def n_type s_type simplify st_def t_type by force
show "mn = st"
proof(cases "leq \<circ>\<^sub>c \<langle>m, s\<rangle> = \<t>")
assume "leq \<circ>\<^sub>c \<langle>m,s\<rangle> = \<t>"
then obtain k where k_type[type_rule]: "k \<in>\<^sub>c \<nat>\<^sub>c" and k_def: "k +\<^sub>\<nat> m = s"
by (meson leq_true_implies_exists m_type s_type)
then have "((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> m) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) =
((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> m) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> k) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t)"
by (typecheck_cfuncs, metis add_commutes equals2 exp_right_dist k_def)
then have f1: "((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) =
((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> k) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t)"
by (typecheck_cfuncs, metis exp_closure l_mult_cancellative m_type mult_associative nonzero_to_any_power zero_is_not_successor)
show ?thesis
proof(cases "k = zero")
assume "k = zero"
then have "n=t"
by (metis exp_cancellative exp_closure exp_respects_Zero_Left f1 n_type s0_is_left_id succ_inject succ_n_type t_type zero_is_not_successor zero_type)
then show ?thesis
using \<open>k = zero\<close> add_respects_zero_on_left k_def m_type mn_def st_def by auto
next
assume "k \<noteq> zero"
then have even: "is_even \<circ>\<^sub>c ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) = \<t>"
using exp_closure exp_def f1 k_type mult_evens_is_even2 powers_of_two_are_even succ_n_type t_type zero_type by force
have "is_odd \<circ>\<^sub>c ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) = \<t>"
by (metis even exp_def exp_respects_Zero_Left mult_evens_is_even2 n_type not_even_and_odd powers_of_three_are_odd s0_is_left_id succ_n_type three_is_odd)
then have False
using even exp_closure n_type not_even_and_odd succ_n_type zero_type by auto
then show ?thesis
by simp
(*Now repeat with s \<le> m *)
qed
next
assume "leq \<circ>\<^sub>c \<langle>m,s\<rangle> \<noteq> \<t>"
then have "leq \<circ>\<^sub>c \<langle>s,m\<rangle> = \<t>"
using lqe_connexity m_type s_type by blast
then obtain p where p_type[type_rule]: "p \<in>\<^sub>c \<nat>\<^sub>c" and p_def: "m = p +\<^sub>\<nat> s"
using leq_true_implies_exists m_type s_type by blast
then have "((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> p) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> s) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) =
((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> s) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t)"
by (typecheck_cfuncs, metis equals2 exp_right_dist p_def)
then have "((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> s) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> p) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) =
((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> s) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t)"
using mult_commutative by (typecheck_cfuncs, presburger)
then have f1: "((successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> p) \<cdot>\<^sub>\<nat> ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> n) =
((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t)"
by (typecheck_cfuncs, metis exp_closure l_mult_cancellative mult_associative nonzero_to_any_power s_type zero_is_not_successor)
show ?thesis
proof(cases "p = zero")
assume "p = zero"
then have "n=t"
using \<open>leq \<circ>\<^sub>c \<langle>m,s\<rangle> \<noteq> \<t>\<close> \<open>leq \<circ>\<^sub>c \<langle>s,m\<rangle> = \<t>\<close> add_respects_zero_on_left p_def s_type by auto
then show ?thesis
by (simp add: \<open>p = zero\<close> add_respects_zero_on_left mn_def p_def s_type st_def)
next
assume "p \<noteq> zero"
then have even: "is_even \<circ>\<^sub>c ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t) = \<t>"
by (metis exp_closure exp_def f1 mult_evens_is_even2 n_type p_type powers_of_two_are_even succ_n_type zero_type)
have "is_odd \<circ>\<^sub>c ((successor \<circ>\<^sub>c successor \<circ>\<^sub>c successor \<circ>\<^sub>c zero)^\<^sub>\<nat> t) = \<t>"
by (typecheck_cfuncs, metis comp_associative2 exp_def exp_respects_Zero_Left is_even_def2 is_even_not_is_odd is_odd_def2 powers_of_three_are_odd)
then have False
using even exp_closure not_even_and_odd succ_n_type t_type zero_type by auto
then show ?thesis
by simp
qed
qed
qed
then show ?thesis
using \<phi>_type countable_def injective_imp_monomorphism by blast
qed
end |
import data.real.irrational
import topology.basic
import algebra.order.floor
--OUTPUT 1
theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
begin
have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff, hα_irrat, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff, int.fract_eq_iff
end --Needs more than 2000 tokens!
--OUTPUT 2
theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
begin
have h1 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from
begin
assume (i j : ℤ) (h1 : i ≠ j),
assume h2 : int.fract (α * ↑i) = int.fract (α * ↑j),
have h3 : α * ↑i - int.floor (α * ↑i) = int.fract (α * ↑i), from by auto [int.fract_eq_iff_of_nonneg],
have h4 : α * ↑j - int.floor (α * ↑j) = int.fract (α * ↑j), from by auto [int.fract_eq_iff_of_nonneg],
have h5 : α = (int.floor (α * ↑i) - int.floor (α * ↑j))/(i - j), from by auto [h2, h3, h4],
have h6 : (i - j) ≠ 0, from by auto [h1],
have h7 : (int.floor (α * ↑i) - int.floor (α * ↑j))/(i - j) ∈ ℚ, from by auto [h5, h6],
show false, from by auto [hα_irrat, h7],
end,
have h2 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h1],
have h3 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h2],
have h4 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h3],
have h5 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h4],
have h6 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h5],
have h7 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h6],
have h8 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h7],
have h9 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h8],
have h10 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h9],
have h11 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h10],
have h12 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h11],
have h13 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h12],
have h14 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h13],
have h15 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h14],
have h16 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h15],
have h17 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h16],
have h18 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h17],
have h19 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h18],
have h20 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h19],
have h21 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h20],
have h22 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h21],
have h23 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h22],
have h24 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h23],
have h25 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h24],
have h26 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h25],
have h27 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h26],
have h28 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h27],
have h29 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h28],
have h30 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h29],
have h31 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h30],
have h32 : ∀ (i j : ℤ), (i ≠ j) → (int.fract (α * ↑i) ≠ int.fract (α * ↑j)), from by auto [h31],
have h33 : ∀ (i j : ℤ), (i ≠ j) →
end --Needs more than 2000 tokens!
--OUTPUT 3
theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
begin
have h1 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h2 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h3 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h4 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h5 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h6 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h7 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h8 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h9 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h10 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h11 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h12 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h13 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h14 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h15 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h16 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h17 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h18 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h19 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h20 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h21 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h22 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of_mul_int_eq_int_add_one_mul_fract, hα_irrat],
have h23 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),
from by auto [int.fract_eq_iff_eq_of
end --Needs more than 2000 tokens!
/- FEW SHOT PROMPTS TO CODEX(START)
/--`theorem`
Power Set is Closed under Intersection
Let $S$ be a set.
Let $\powerset S$ be the power set of $S$.
Then:
:$\forall A, B \in \powerset S: A \cap B \in \powerset S$
`proof`
Let $A, B \in \powerset S$.
Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$.
From Intersection is Subset we have that $A \cap B \subseteq A$.
It follows from Subset Relation is Transitive that $A \cap B \subseteq S$.
Thus $A \cap B \in \powerset S$ and closure is proved.
{{qed}}
-/
theorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=
begin
assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),
have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],
have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],
have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],
show (A ∩ B) ∈ 𝒫 S, from by auto [set.mem_powerset],
end
/--`theorem`
Square of Sum
:$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$
`proof`
Follows from the distribution of multiplication over addition:
{{begin-eqn}}
{{eqn | l = \left({x + y}\right)^2
| r = \left({x + y}\right) \cdot \left({x + y}\right)
}}
{{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right)
| c = Real Multiplication Distributes over Addition
}}
{{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y
| c = Real Multiplication Distributes over Addition
}}
{{eqn | r = x^2 + 2xy + y^2
| c =
}}
{{end-eqn}}
{{qed}}
-/
theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) :=
begin
calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]
... = x*(x+y) + y*(x+y) : by auto [add_mul]
... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]
... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]
end
/--`theorem`
Identity of Group is Unique
Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$.
`proof`
From Group has Latin Square Property, there exists a unique $x \in G$ such that:
:$a x = b$
and there exists a unique $y \in G$ such that:
:$y a = b$
Setting $b = a$, this becomes:
There exists a unique $x \in G$ such that:
:$a x = a$
and there exists a unique $y \in G$ such that:
:$y a = a$
These $x$ and $y$ are both $e$, by definition of identity element.
{{qed}}
-/
theorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=
begin
have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],
have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹],
have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],
have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],
have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],
have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],
show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],
end
/--`theorem`
Squeeze Theorem for Real Numbers
Let $\sequence {x_n}$, $\sequence {y_n}$ and $\sequence {z_n}$ be sequences in $\R$.
Let $\sequence {y_n}$ and $\sequence {z_n}$ both be convergent to the following limit:
:$\ds \lim_{n \mathop \to \infty} y_n = l, \lim_{n \mathop \to \infty} z_n = l$
Suppose that:
:$\forall n \in \N: y_n \le x_n \le z_n$
Then:
:$x_n \to l$ as $n \to \infty$
that is:
:$\ds \lim_{n \mathop \to \infty} x_n = l$
`proof`
From Negative of Absolute Value:
:$\size {x - l} < \epsilon \iff l - \epsilon < x < l + \epsilon$
Let $\epsilon > 0$.
We need to prove that:
:$\exists N: \forall n > N: \size {x_n - l} < \epsilon$
As $\ds \lim_{n \mathop \to \infty} y_n = l$ we know that:
:$\exists N_1: \forall n > N_1: \size {y_n - l} < \epsilon$
As $\ds \lim_{n \mathop \to \infty} z_n = l$ we know that:
:$\exists N_2: \forall n > N_2: \size {z_n - l} < \epsilon$
Let $N = \max \set {N_1, N_2}$.
Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.
So:
:$\forall n > N: l - \epsilon < y_n < l + \epsilon$
:$\forall n > N: l - \epsilon < z_n < l + \epsilon$
But:
:$\forall n \in \N: y_n \le x_n \le z_n$
So:
:$\forall n > N: l - \epsilon < y_n \le x_n \le z_n < l + \epsilon$
and so:
:$\forall n > N: l - \epsilon < x_n < l + \epsilon$
So:
:$\forall n > N: \size {x_n - l} < \epsilon$
Hence the result.
{{qed}}
-/
theorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) :
let seq_limit : (ℕ → ℝ) → ℝ → Prop := λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in
seq_limit y l → seq_limit z l → (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=
begin
assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε),
have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))),
from by auto [abs_sub_lt_iff] using [linarith],
assume (h7 : ε > 0),
cases h2 ε h7 with N1 h8,
cases h3 ε h7 with N2 h9,
let N := max N1 N2,
use N,
have h10 : ∀ n > N, n > N1 ∧ n > N2 := by auto [lt_of_le_of_lt, le_max_left, le_max_right],
have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)),
from by auto [h8, h10, h5, h9],
have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)),
from by auto [h11] using [linarith],
show ∀ (n : ℕ), n > N → |x n - l| < ε,
from by auto [h5, h15],
end
/--`theorem`
Density of irrational orbit
The fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval
`proof`
Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$. If this were not true, then
$$
i \alpha-\lfloor i \alpha\rfloor=\{i \alpha\}=\{j \alpha\}=j \alpha-\lfloor j \alpha\rfloor,
$$
which yields the false statement $\alpha=\frac{\lfloor i \alpha\rfloor-\lfloor j \alpha\rfloor}{i-j} \in \mathbb{Q}$. Hence,
$$
S:=\{\{i \alpha\} \mid i \in \mathbb{Z}\}
$$
is an infinite subset of $\left[0,1\right]$.
By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.
To show that $S$ is dense in $[0, 1]$, consider $y \in[0,1]$, and $\epsilon>0$. Then by selecting $x \in S$ such that $\{x\}<\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \cdot\{x\} \leq y<(N+1) \cdot\{x\}$, we get: $|y-\{N x\}|<\epsilon$.
QED
-/
theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=
FEW SHOT PROMPTS TO CODEX(END)-/
|
(* File reduced by coq-bug-finder from original input, then from 14990 lines to 70 lines, then from 44 lines to 29 lines *)
(* coqc version trunk (September 2014) compiled on Sep 17 2014 0:22:30 with OCaml 4.01.0
coqtop version cagnode16:/afs/csail.mit.edu/u/j/jgross/coq-trunk,trunk (d34e1eed232c84590ddb80d70db9f7f7cf13584a) *)
Set Primitive Projections.
Set Implicit Arguments.
Record sigT {A} P := existT { pr1 : A ; pr2 : P pr1 }.
Notation "{ x : A & P }" := (sigT (A := A) (fun x : A => P)) : type_scope.
Notation "x .1" := (pr1 x) (at level 3, format "x '.1'").
Notation "x .2" := (pr2 x) (at level 3, format "x '.2'").
Record Equiv A B := { equiv_fun :> A -> B }.
Notation "A <~> B" := (Equiv A B) (at level 85).
Inductive Bool : Type := true | false.
Definition negb (b : Bool) := if b then false else true.
Axiom eval_bool_isequiv : forall (f : Bool -> Bool), f false = negb (f true).
Lemma bool_map_equiv_not_idmap (f : { f : Bool <~> Bool & ~(forall x, f x = x) })
: forall b, ~(f.1 b = b).
Proof.
intro b.
intro H''.
apply f.2.
intro b'.
pose proof (eval_bool_isequiv f.1) as H.
destruct b', b.
Fail match type of H with
| _ = negb (f.1 true) => fail 1 "no f.1 true"
end. (* Error: No matching clauses for match. *)
destruct (f.1 true).
simpl in *.
Fail match type of H with
| _ = negb ?T => unify T (f.1 true); fail 1 "still has f.1 true"
end. (* Error: Tactic failure: still has f.1 true. *)
|
theorem ex1 : True := by
refine ?a
refine ?a
refine ?a
exact True.intro
axiom ax.{u} {α : Sort u} (a : α) : α
theorem ex2 : True := by
refine ?a
refine ax ?a -- Error trying to assign `?a := ax ?a`
|
{-# OPTIONS --rewriting #-}
open import Common.Equality
{-# BUILTIN REWRITE _≡_ #-}
postulate
A : Set
f g : A → A
f≡g : ∀ a → f a ≡ g a
{-# REWRITE f≡g #-}
-- Adding the same rule again would make Agda loop
postulate
f≡g' : ∀ a → f a ≡ g a
{-# REWRITE f≡g' #-}
goal : ∀ {a} → f a ≡ g a
goal = refl
|
program selectCaseProg
implicit none
!local variable declaration
integer, parameter :: a = 1008
select case (a)
case (1)
print *, "Number is 1"
case (2)
print *, "Number is 2"
case (3)
print *, "Number is 3"
case (4)
print *, "Number is 4"
case (5)
print *, "Number is 5"
case default
print *, "Some other number", a
end select
end program selectCaseProg
|
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "4"
import json
import pickle
import argparse
import numpy as np
import tensorflow as tf
from midi_generator import generate_midi
from train_classifier import encode_sentence
from train_classifier import get_activated_neurons
from train_generative import build_generative_model
GEN_MIN = -1
GEN_MAX = 1
# Directory where trained model will be saved
TRAIN_DIR = "./trained"
def mutation(individual, mutation_rate):
for i in range(len(individual)):
if np.random.uniform(0, 1) < mutation_rate:
individual[i] = np.random.uniform(GEN_MIN, GEN_MAX)
def crossover(parent_a, parent_b, ind_size):
# Averaging crossover
return (parent_a + parent_b)/2
def reproduce(mating_pool, new_population_size, ind_size, mutation_rate):
new_population = np.zeros((new_population_size, ind_size))
for i in range(new_population_size):
a = np.random.randint(len(mating_pool));
b = np.random.randint(len(mating_pool));
new_population[i] = crossover(mating_pool[a], mating_pool[b], ind_size);
# Mutate new children
np.apply_along_axis(mutation, 1, new_population, mutation_rate)
return new_population;
def roulette_wheel(population, fitness_pop):
# Normalize fitnesses
norm_fitness_pop = fitness_pop/np.sum(fitness_pop)
# Here all the fitnesses sum up to 1
r = np.random.uniform(0, 1)
fitness_so_far = 0
for i in range(len(population)):
fitness_so_far += norm_fitness_pop[i]
if r < fitness_so_far:
return population[i]
return population[-1]
def select(population, fitness_pop, mating_pool_size, ind_size, elite_rate):
mating_pool = np.zeros((mating_pool_size, ind_size))
# Apply roulete wheel to select mating_pool_size individuals
for i in range(mating_pool_size):
mating_pool[i] = roulette_wheel(population, fitness_pop)
# Apply elitism
assert elite_rate >= 0 and elite_rate <= 1
elite_size = int(np.ceil(elite_rate * len(population)))
elite_idxs = np.argsort(-fitness_pop)
for i in range(elite_size):
r = np.random.randint(0, mating_pool_size)
mating_pool[r] = elite_idxs[i]
return mating_pool
def calc_fitness(individual, gen_model, cls_model, char2idx, idx2char, layer_idx, sentiment, runs=30):
encoding_size = gen_model.layers[layer_idx].units
generated_midis = np.zeros((runs, encoding_size))
# Get activated neurons
sentneuron_ixs = get_activated_neurons(cls_model)
assert len(individual) == len(sentneuron_ixs)
# Use individual gens to override model neurons
override = {}
for i, ix in enumerate(sentneuron_ixs):
override[ix] = individual[i]
# Generate pieces and encode them using the cell state of the generative model
for i in range(runs):
midi_text = generate_midi(gen_model, char2idx, idx2char, seq_len=64, layer_idx=layer_idx, override=override)
generated_midis[i] = encode_sentence(gen_model, midi_text, char2idx, layer_idx)
midis_sentiment = cls_model.predict(generated_midis).clip(min=0)
return 1.0 - np.sum(np.abs(midis_sentiment - sentiment))/runs
def evaluate(population, gen_model, cls_model, char2idx, idx2char, layer_idx, sentiment):
fitness = np.zeros((len(population), 1))
for i in range(len(population)):
fitness[i] = calc_fitness(population[i], gen_model, cls_model, char2idx, idx2char, layer_idx, sentiment)
return fitness
def evolve(pop_size, ind_size, mut_rate, elite_rate, epochs):
# Create initial population
population = np.random.uniform(GEN_MIN, GEN_MAX, (pop_size, ind_size))
# Evaluate initial population
fitness_pop = evaluate(population, gen_model, cls_model, char2idx, idx2char, opt.cellix, sent)
print("--> Fitness: \n", fitness_pop)
for i in range(epochs):
print("-> Epoch", i)
# Select individuals via roulette wheel to form a mating pool
mating_pool = select(population, fitness_pop, pop_size, ind_size, elite_rate)
# Reproduce matin pool with crossover and mutation to form new population
population = reproduce(mating_pool, pop_size, ind_size, mut_rate)
# Calculate fitness of each individual of the population
fitness_pop = evaluate(population, gen_model, cls_model, char2idx, idx2char, opt.cellix, sent)
print("--> Fitness: \n", fitness_pop)
return population, fitness_pop
if __name__ == "__main__":
# Parse arguments
parser = argparse.ArgumentParser(description='evolve_generative.py')
parser.add_argument('--genmodel', type=str, default='./trained', help="Generative model to evolve.")
parser.add_argument('--clsmodel', type=str, default='./trained/classifier_ckpt.p', help="Classifier model to calculate fitness.")
parser.add_argument('--ch2ix', type=str, default='./trained/char2idx.json', help="JSON file with char2idx encoding.")
parser.add_argument('--embed', type=int, default=256, help="Embedding size.")
parser.add_argument('--units', type=int, default=512, help="LSTM units.")
parser.add_argument('--layers', type=int, default=4, help="LSTM layers.")
parser.add_argument('--cellix', type=int, default=4, help="LSTM layer to use as encoder.")
#parser.add_argument('--sent', type=int, default=2, help="Desired sentiment.")
parser.add_argument('--popsize', type=int, default=10, help="Population size.")
parser.add_argument('--epochs', type=int, default=10, help="Epochs to run.")
parser.add_argument('--mrate', type=float, default=0.1, help="Mutation rate.")
parser.add_argument('--elitism', type=float, default=0.1, help="Elitism in percentage.")
opt = parser.parse_args()
# Load char2idx dict from json file
with open(opt.ch2ix) as f:
char2idx = json.load(f)
# Create idx2char from char2idx dict
idx2char = {idx:char for char,idx in char2idx.items()}
# Calculate vocab_size from char2idx dict
vocab_size = len(char2idx)
# Rebuild generative model from checkpoint
gen_model = build_generative_model(vocab_size, opt.embed, opt.units, opt.layers, batch_size=1)
gen_model.load_weights(tf.train.latest_checkpoint(opt.genmodel))
gen_model.build(tf.TensorShape([1, None]))
# Load classifier model
with open(opt.clsmodel, "rb") as f:
cls_model = pickle.load(f)
# Set individual size to the number of activated neurons
sentneuron_ixs = get_activated_neurons(cls_model)
ind_size = len(sentneuron_ixs)
# Evolve for Positive(1)/Negative(1)
sents = [1, 2, 3, 4]
for sent in sents:
print('evolving for {}'.format(sent))
population, fitness_pop = evolve(opt.popsize, ind_size, opt.mrate, opt.elitism, opt.epochs)
# Get best individual
best_idx = np.argmax(fitness_pop)
best_individual = population[best_idx]
# Use best individual gens to create a dictionary with cell values
neurons = {}
for i, ix in enumerate(sentneuron_ixs):
neurons[str(ix)] = best_individual[i]
# Persist dictionary with cell values
if sent == 1:
sent = 'Q1'
elif sent == 2:
sent = 'Q2'
elif sent == 3:
sent = 'Q3'
else:
sent = 'Q4'
with open(os.path.join(TRAIN_DIR, "neurons_" + sent + ".json"), "w") as f:
json.dump(neurons, f) |
State Before: ι : Type u_2
κ : Type ?u.62135
α : Type u_1
inst✝³ : LinearOrderedAddCommGroup α
inst✝² : UniformSpace α
inst✝¹ : UniformAddGroup α
inst✝ : CompleteSpace α
f : ι → α
s : Set ι := {x | 0 ≤ f x}
h1 : ∀ (x : ↑s), abs (f ↑x) = f ↑x
h2 : ∀ (x : ↑(sᶜ)), abs (f ↑x) = -f ↑x
⊢ ((Summable fun x => abs (f ↑x)) ∧ Summable fun x => abs (f ↑x)) ↔ (Summable fun x => f ↑x) ∧ Summable fun x => -f ↑x State After: no goals Tactic: simp only [h1, h2] State Before: ι : Type u_2
κ : Type ?u.62135
α : Type u_1
inst✝³ : LinearOrderedAddCommGroup α
inst✝² : UniformSpace α
inst✝¹ : UniformAddGroup α
inst✝ : CompleteSpace α
f : ι → α
s : Set ι := {x | 0 ≤ f x}
h1 : ∀ (x : ↑s), abs (f ↑x) = f ↑x
h2 : ∀ (x : ↑(sᶜ)), abs (f ↑x) = -f ↑x
⊢ ((Summable fun x => f ↑x) ∧ Summable fun x => -f ↑x) ↔ Summable f State After: no goals Tactic: simp only [summable_neg_iff, summable_subtype_and_compl] |
Add LoadPath "." as CoqDirectory.
Load partie2.
(* Cette partie met quelques notions en place, rien de très extravagant *)
(* Question 2 *)
(* NB : on a remplacé les blocs d(instruction par des listes chaînées directement
embedded dans les termes car Coq refusait de définir certains opérateurs de point fixe
car il n'arrivait pas à prouver leur terminaison *)
Inductive Instruction :=
| Access : nat -> Instruction
| Grab : Instruction -> Instruction
| Push : Instruction -> Instruction -> Instruction
.
Inductive Stack_type : Type :=
| Nil : Stack_type
| Stack : (Instruction * Stack_type) -> Stack_type -> Stack_type
.
Definition Environment : Type := Stack_type.
Definition State : Type := (Instruction * Environment * Stack_type).
Inductive StateOption :=
| None : StateOption
| Some : State -> StateOption
.
(* Question 3 *)
Definition step_krivine (state: State) : StateOption :=
match state with
| ((Access 0), Stack (c0, e0) _, s) => Some ((c0, e0, s))
| ((Access (S n)), Stack (_, _) e, s) => Some (((Access n), e, s))
| ((Push cp c), e, s) => Some ((c, e, Stack (cp, e) s))
| (Grab c, e, Stack (c0, e0) s) => Some (c, Stack (c0, e0) e, s)
| _ => None
end
.
Definition is_state (s: StateOption) :=
match s with
| None => False
| Some _ => True
end
.
(* Encore le même genre de lemme... *)
Lemma some_truc : forall (s1 s2: State),
Some s1 = Some s2 <-> s1 = s2
.
Proof.
move => s1 s2.
split.
case. trivial.
move => H.
rewrite H. reflexivity.
Qed. |
module Oscar.Property.Extensionality where
open import Oscar.Level
record Extensionality
{a} {A : Set a} {b} {B : A → Set b} {ℓ₁}
(_≤₁_ : (x : A) → B x → Set ℓ₁)
{c} {C : A → Set c} {d} {D : ∀ {x} → B x → Set d} {ℓ₂}
(_≤₂_ : ∀ {x} → C x → ∀ {y : B x} → D y → Set ℓ₂)
(μ₁ : (x : A) → C x)
(μ₂ : ∀ {x} → (y : B x) → D y)
: Set (a ⊔ ℓ₁ ⊔ b ⊔ ℓ₂) where
field
extensionality : ∀ {x} {y : B x} → x ≤₁ y → μ₁ x ≤₂ μ₂ y
open Extensionality ⦃ … ⦄ public
extension : ∀
{a} {A : Set a}
{b} {B : A → Set b}
{ℓ₁} {_≤₁_ : (x : A) → B x → Set ℓ₁}
{c} {C : A → Set c} {d} {D : ∀ {x} → B x → Set d} {ℓ₂}
(_≤₂_ : ∀ {x} → C x → ∀ {y : B x} → D y → Set ℓ₂)
{μ₁ : (x : A) → C x}
{μ₂ : ∀ {x} → (y : B x) → D y}
⦃ _ : Extensionality _≤₁_ _≤₂_ μ₁ μ₂ ⦄
{x} {y : B x}
→ x ≤₁ y → μ₁ x ≤₂ μ₂ y
extension _≤₂_ = extensionality {_≤₂_ = _≤₂_}
|
As the infection spreads , Israel abandons the Palestinian territories and initiates a nationwide quarantine , closing its borders to everyone except uninfected Jews and Palestinians . Its military then puts down an ultra @-@ Orthodox uprising , which is later referred to as an Israeli civil war . The United States does little to prepare because it is overconfident in its ability to suppress any threat . Although special forces teams contain initial outbreaks , a widespread effort never starts : the nation is deprived of political will by " <unk> wars " , and a widely distributed and marketed placebo vaccine creates a false sense of security .
|
import tactic.tidy
import evaluation
namespace baseline
section tidy_proof_search
meta def tidy_default_tactics : list string := [
"refl"
, "exact dec_trivial"
, "assumption"
, "tactic.intros1"
, "tactic.auto_cases"
, "apply_auto_param"
, "dsimp at *"
, "simp at *"
, "ext1"
, "fsplit"
, "injections_and_clear"
, "solve_by_elim"
, "norm_cast"
]
meta def tidy_api : ModelAPI := -- simulates logic of tidy, baseline (deterministic) model
let fn : json → io json := λ msg, do {
pure $ json.array $ json.of_string <$> tidy_default_tactics
} in ⟨fn⟩
meta def tidy_greedy_proof_search_core
(fuel : ℕ := 1000)
(verbose := ff)
: state_t GreedyProofSearchState tactic unit :=
greedy_proof_search_core
tidy_api
(λ _, pure json.null)
(λ msg n, run_best_beam_candidate (unwrap_lm_response $ some "[tidy_greedy_proof_search]") msg n)
fuel
-- TODO(jesse): run against `tidy` test suite to confirm reproduction of `tidy` logic
meta def tidy_greedy_proof_search
(fuel : ℕ := 1000)
(verbose := ff)
: tactic unit :=
greedy_proof_search
tidy_api
(λ _, pure json.null)
(λ msg n, run_best_beam_candidate (unwrap_lm_response $ some "[tidy_greedy_proof_search]") msg n)
fuel
verbose
end tidy_proof_search
section playground
-- example : true :=
-- begin
-- tidy_greedy_proof_search 5 tt,
-- end
-- open nat
-- universe u
-- example : ∀ {α : Type u} {s₁ s₂ t₁ t₂ : list α},
-- s₁ ++ t₁ = s₂ ++ t₂ → s₁.length = s₂.length → s₁ = s₂ ∧ t₁ = t₂ :=
-- begin
-- intros, -- tidy_greedy_proof_search
-- end
-- open nat
-- example {p q r : Prop} (h₁ : p) (h₂ : q) : p ∧ q :=
-- begin
-- tidy_greedy_proof_search 3 tt
-- end
-- run_cmd do {set_show_eval_trace tt *> do env ← tactic.get_env, tactic.set_env_core env}
-- example {p q r : Prop} (h₁ : p) (h₂ : q) : p ∧ q :=
-- begin
-- tidy_greedy_proof_search 2 ff -- should only try one iteration before halting
end playground
end baseline
|
lemma kuhn_simplex_lemma: assumes "\<forall>s. ksimplex p (Suc n) s \<longrightarrow> rl ` s \<subseteq> {.. Suc n}" and "odd (card {f. \<exists>s a. ksimplex p (Suc n) s \<and> a \<in> s \<and> (f = s - {a}) \<and> rl ` f = {..n} \<and> ((\<exists>j\<le>n. \<forall>x\<in>f. x j = 0) \<or> (\<exists>j\<le>n. \<forall>x\<in>f. x j = p))})" shows "odd (card {s. ksimplex p (Suc n) s \<and> rl ` s = {..Suc n}})" |
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
! This file was ported from Lean 3 source module topology.algebra.monoid
! leanprover-community/mathlib commit 6efec6bb9fcaed3cf1baaddb2eaadd8a2a06679c
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Order.Filter.Pointwise
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Topology.ContinuousFunction.Basic
/-!
# Theory of topological monoids
In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many
applications the underlying type is a monoid (multiplicative or additive), we do not require this in
the definitions.
-/
universe u v
open Classical Set Filter TopologicalSpace
open Classical Topology BigOperators Pointwise
variable {ι α X M N : Type _} [TopologicalSpace X]
@[to_additive (attr := continuity)]
theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X → M) :=
@continuous_const _ _ _ _ 1
#align continuous_one continuous_one
#align continuous_zero continuous_zero
/-- Basic hypothesis to talk about a topological additive monoid or a topological additive
semigroup. A topological additive monoid over `M`, for example, is obtained by requiring both the
instances `AddMonoid M` and `ContinuousAdd M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstVAdd α α`/`ContinuousConstVAdd αᵐᵒᵖ α`. -/
class ContinuousAdd (M : Type u) [TopologicalSpace M] [Add M] : Prop where
continuous_add : Continuous fun p : M × M => p.1 + p.2
#align has_continuous_add ContinuousAdd
/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.
A topological monoid over `M`, for example, is obtained by requiring both the instances `Monoid M`
and `ContinuousMul M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstSMul α α`/`ContinuousConstSMul αᵐᵒᵖ α`. -/
@[to_additive]
class ContinuousMul (M : Type u) [TopologicalSpace M] [Mul M] : Prop where
continuous_mul : Continuous fun p : M × M => p.1 * p.2
#align has_continuous_mul ContinuousMul
-- #align has_continuous_add ContinuousAdd
section ContinuousMul
variable [TopologicalSpace M] [Mul M] [ContinuousMul M]
@[to_additive]
instance : ContinuousMul Mᵒᵈ :=
‹ContinuousMul M›
@[to_additive (attr := continuity)]
theorem continuous_mul : Continuous fun p : M × M => p.1 * p.2 :=
ContinuousMul.continuous_mul
#align continuous_mul continuous_mul
#align continuous_add continuous_add
@[to_additive]
instance ContinuousMul.to_continuousSMul : ContinuousSMul M M :=
⟨continuous_mul⟩
#align has_continuous_mul.to_has_continuous_smul ContinuousMul.to_continuousSMul
#align has_continuous_add.to_has_continuous_vadd ContinuousAdd.to_continuousVAdd
@[to_additive]
instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mᵐᵒᵖ M :=
⟨show Continuous ((fun p : M × M => p.1 * p.2) ∘ Prod.swap ∘ Prod.map MulOpposite.unop id) from
continuous_mul.comp <|
continuous_swap.comp <| Continuous.prod_map MulOpposite.continuous_unop continuous_id⟩
#align has_continuous_mul.to_has_continuous_smul_op ContinuousMul.to_continuousSMul_op
#align has_continuous_add.to_has_continuous_vadd_op ContinuousAdd.to_continuousVAdd_op
@[to_additive (attr := continuity)]
theorem Continuous.mul {f g : X → M} (hf : Continuous f) (hg : Continuous g) :
Continuous fun x => f x * g x :=
continuous_mul.comp (hf.prod_mk hg : _)
#align continuous.mul Continuous.mul
#align continuous.add Continuous.add
@[to_additive (attr := continuity)]
theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b :=
continuous_const.mul continuous_id
#align continuous_mul_left continuous_mul_left
#align continuous_add_left continuous_add_left
@[to_additive (attr := continuity)]
theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a :=
continuous_id.mul continuous_const
#align continuous_mul_right continuous_mul_right
#align continuous_add_right continuous_add_right
@[to_additive]
theorem ContinuousOn.mul {f g : X → M} {s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x => f x * g x) s :=
(continuous_mul.comp_continuousOn (hf.prod hg) : _)
#align continuous_on.mul ContinuousOn.mul
#align continuous_on.add ContinuousOn.add
@[to_additive]
theorem tendsto_mul {a b : M} : Tendsto (fun p : M × M => p.fst * p.snd) (𝓝 (a, b)) (𝓝 (a * b)) :=
continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b)
#align tendsto_mul tendsto_mul
#align tendsto_add tendsto_add
@[to_additive]
theorem Filter.Tendsto.mul {f g : α → M} {x : Filter α} {a b : M} (hf : Tendsto f x (𝓝 a))
(hg : Tendsto g x (𝓝 b)) : Tendsto (fun x => f x * g x) x (𝓝 (a * b)) :=
tendsto_mul.comp (hf.prod_mk_nhds hg)
#align filter.tendsto.mul Filter.Tendsto.mul
#align filter.tendsto.add Filter.Tendsto.add
@[to_additive]
theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : α → M} {l : Filter α}
(h : Tendsto (fun k : α => f k) l (𝓝 c)) : Tendsto (fun k : α => b * f k) l (𝓝 (b * c)) :=
tendsto_const_nhds.mul h
#align filter.tendsto.const_mul Filter.Tendsto.const_mul
#align filter.tendsto.const_add Filter.Tendsto.const_add
@[to_additive]
theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : α → M} {l : Filter α}
(h : Tendsto (fun k : α => f k) l (𝓝 c)) : Tendsto (fun k : α => f k * b) l (𝓝 (c * b)) :=
h.mul tendsto_const_nhds
#align filter.tendsto.mul_const Filter.Tendsto.mul_const
#align filter.tendsto.add_const Filter.Tendsto.add_const
@[to_additive]
theorem le_nhds_mul (a b : M) : 𝓝 a * 𝓝 b ≤ 𝓝 (a * b) := by
rw [← map₂_mul, ← map_uncurry_prod, ← nhds_prod_eq]
exact continuous_mul.tendsto _
#align le_nhds_mul le_nhds_mul
#align le_nhds_add le_nhds_add
@[to_additive (attr := simp)]
theorem nhds_one_mul_nhds {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
𝓝 (1 : M) * 𝓝 a = 𝓝 a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (one_mul a)).antisymm <|
le_mul_of_one_le_left' <| pure_le_nhds 1
#align nhds_one_mul_nhds nhds_one_mul_nhds
#align nhds_zero_add_nhds nhds_zero_add_nhds
@[to_additive (attr := simp)]
theorem nhds_mul_nhds_one {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
𝓝 a * 𝓝 1 = 𝓝 a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (mul_one a)).antisymm <|
le_mul_of_one_le_right' <| pure_le_nhds 1
#align nhds_mul_nhds_one nhds_mul_nhds_one
#align nhds_add_nhds_zero nhds_add_nhds_zero
section tendsto_nhds
variable {𝕜 : Type _} [Preorder 𝕜] [Zero 𝕜] [Mul 𝕜] [TopologicalSpace 𝕜] [ContinuousMul 𝕜]
{l : Filter α} {f : α → 𝕜} {b c : 𝕜} (hb : 0 < b)
theorem Filter.TendstoNhdsWithinIoi.const_mul [PosMulStrictMono 𝕜] [PosMulReflectLT 𝕜]
(h : Tendsto f l (𝓝[>] c)) : Tendsto (fun a => b * f a) l (𝓝[>] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Ioi.const_mul Filter.TendstoNhdsWithinIoi.const_mul
theorem Filter.TendstoNhdsWithinIio.const_mul [PosMulStrictMono 𝕜] [PosMulReflectLT 𝕜]
(h : Tendsto f l (𝓝[<] c)) : Tendsto (fun a => b * f a) l (𝓝[<] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Iio.const_mul Filter.TendstoNhdsWithinIio.const_mul
theorem Filter.TendstoNhdsWithinIoi.mul_const [MulPosStrictMono 𝕜] [MulPosReflectLT 𝕜]
(h : Tendsto f l (𝓝[>] c)) : Tendsto (fun a => f a * b) l (𝓝[>] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Ioi.mul_const Filter.TendstoNhdsWithinIoi.mul_const
theorem Filter.TendstoNhdsWithinIio.mul_const [MulPosStrictMono 𝕜] [MulPosReflectLT 𝕜]
(h : Tendsto f l (𝓝[<] c)) : Tendsto (fun a => f a * b) l (𝓝[<] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Iio.mul_const Filter.TendstoNhdsWithinIio.mul_const
end tendsto_nhds
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ι → Nˣ} {r₁ r₂ : N} {l : Filter ι} [l.NeBot] (h₁ : Tendsto (fun x => ↑(f x)) l (𝓝 r₁))
(h₂ : Tendsto (fun x => ↑(f x)⁻¹) l (𝓝 r₂)) : Nˣ
where
val := r₁
inv := r₂
val_inv := by
symm
simpa using h₁.mul h₂
inv_val := by
symm
simpa using h₂.mul h₁
#align filter.tendsto.units Filter.Tendsto.units
#align filter.tendsto.add_units Filter.Tendsto.addUnits
@[to_additive]
theorem ContinuousAt.mul {f g : X → M} {x : X} (hf : ContinuousAt f x) (hg : ContinuousAt g x) :
ContinuousAt (fun x => f x * g x) x :=
Filter.Tendsto.mul hf hg
#align continuous_at.mul ContinuousAt.mul
#align continuous_at.add ContinuousAt.add
@[to_additive]
theorem ContinuousWithinAt.mul {f g : X → M} {s : Set X} {x : X} (hf : ContinuousWithinAt f s x)
(hg : ContinuousWithinAt g s x) : ContinuousWithinAt (fun x => f x * g x) s x :=
Filter.Tendsto.mul hf hg
#align continuous_within_at.mul ContinuousWithinAt.mul
#align continuous_within_at.add ContinuousWithinAt.add
@[to_additive]
instance [TopologicalSpace N] [Mul N] [ContinuousMul N] : ContinuousMul (M × N) :=
⟨(continuous_fst.fst'.mul continuous_fst.snd').prod_mk
(continuous_snd.fst'.mul continuous_snd.snd')⟩
@[to_additive]
instance Pi.continuousMul {C : ι → Type _} [∀ i, TopologicalSpace (C i)] [∀ i, Mul (C i)]
[∀ i, ContinuousMul (C i)] : ContinuousMul (∀ i, C i)
where continuous_mul :=
continuous_pi fun i => (continuous_apply i).fst'.mul (continuous_apply i).snd'
#align pi.has_continuous_mul Pi.continuousMul
#align pi.has_continuous_add Pi.continuousAdd
/-- A version of `pi.continuousMul` for non-dependent functions. It is needed because sometimes
Lean 3 fails to use `pi.continuousMul` for non-dependent functions. -/
@[to_additive "A version of `pi.continuousAdd` for non-dependent functions. It is needed
because sometimes Lean fails to use `pi.continuousAdd` for non-dependent functions."]
instance Pi.continuousMul' : ContinuousMul (ι → M) :=
Pi.continuousMul
#align pi.has_continuous_mul' Pi.continuousMul'
#align pi.has_continuous_add' Pi.continuousAdd'
@[to_additive]
instance (priority := 100) continuousMul_of_discreteTopology [TopologicalSpace N] [Mul N]
[DiscreteTopology N] : ContinuousMul N :=
⟨continuous_of_discreteTopology⟩
#align has_continuous_mul_of_discrete_topology continuousMul_of_discreteTopology
#align has_continuous_add_of_discrete_topology continuousAdd_of_discreteTopology
open Filter
open Function
@[to_additive]
theorem ContinuousMul.of_nhds_one {M : Type u} [Monoid M] [TopologicalSpace M]
(hmul : Tendsto (uncurry ((· * ·) : M → M → M)) (𝓝 1 ×ᶠ 𝓝 1) <| 𝓝 1)
(hleft : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x₀ * x) (𝓝 1))
(hright : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x * x₀) (𝓝 1)) : ContinuousMul M :=
⟨by
rw [continuous_iff_continuousAt]
rintro ⟨x₀, y₀⟩
have key :
(fun p : M × M => x₀ * p.1 * (p.2 * y₀)) =
((fun x => x₀ * x) ∘ fun x => x * y₀) ∘ uncurry (· * ·) :=
by
ext p
simp [uncurry, mul_assoc]
have key₂ : ((fun x => x₀ * x) ∘ fun x => y₀ * x) = fun x => x₀ * y₀ * x :=
by
ext x
simp [mul_assoc]
calc
map (uncurry (· * ·)) (𝓝 (x₀, y₀)) = map (uncurry (· * ·)) (𝓝 x₀ ×ᶠ 𝓝 y₀) :=
by rw [nhds_prod_eq]
_ = map (fun p : M × M => x₀ * p.1 * (p.2 * y₀)) (𝓝 1 ×ᶠ 𝓝 1) :=
by simp_rw [uncurry, hleft x₀, hright y₀, prod_map_map_eq, Filter.map_map, Function.comp]
-- Porting note: `rw` was able to prove this
_ = map ((fun x => x₀ * x) ∘ fun x => x * y₀) (map (uncurry (· * ·)) (𝓝 1 ×ᶠ 𝓝 1)) :=
by rw [key, ← Filter.map_map]
_ ≤ map ((fun x : M => x₀ * x) ∘ fun x => x * y₀) (𝓝 1) := map_mono hmul
_ = 𝓝 (x₀ * y₀) := by rw [← Filter.map_map, ← hright, hleft y₀, Filter.map_map, key₂, ← hleft]
⟩
#align has_continuous_mul.of_nhds_one ContinuousMul.of_nhds_one
#align has_continuous_add.of_nhds_zero ContinuousAdd.of_nhds_zero
@[to_additive]
theorem continuousMul_of_comm_of_nhds_one (M : Type u) [CommMonoid M] [TopologicalSpace M]
(hmul : Tendsto (uncurry ((· * ·) : M → M → M)) (𝓝 1 ×ᶠ 𝓝 1) (𝓝 1))
(hleft : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x₀ * x) (𝓝 1)) : ContinuousMul M := by
apply ContinuousMul.of_nhds_one hmul hleft
intro x₀
simp_rw [mul_comm, hleft x₀]
#align has_continuous_mul_of_comm_of_nhds_one continuousMul_of_comm_of_nhds_one
#align has_continuous_add_of_comm_of_nhds_zero continuousAdd_of_comm_of_nhds_zero
end ContinuousMul
section PointwiseLimits
variable (M₁ M₂ : Type _) [TopologicalSpace M₂] [T2Space M₂]
@[to_additive]
theorem isClosed_setOf_map_one [One M₁] [One M₂] : IsClosed { f : M₁ → M₂ | f 1 = 1 } :=
isClosed_eq (continuous_apply 1) continuous_const
#align is_closed_set_of_map_one isClosed_setOf_map_one
#align is_closed_set_of_map_zero isClosed_setOf_map_zero
@[to_additive]
theorem isClosed_setOf_map_mul [Mul M₁] [Mul M₂] [ContinuousMul M₂] :
IsClosed { f : M₁ → M₂ | ∀ x y, f (x * y) = f x * f y } := by
simp only [setOf_forall]
exact
isClosed_interᵢ fun x =>
isClosed_interᵢ fun y =>
isClosed_eq (continuous_apply _)
-- Porting note: proof was:
-- `((continuous_apply _).mul (continuous_apply _))`
(by continuity)
#align is_closed_set_of_map_mul isClosed_setOf_map_mul
#align is_closed_set_of_map_add isClosed_setOf_map_add
-- porting note: split variables command over two lines, can't change explicitness at the same time
-- as declaring new variables.
variable {M₁ M₂}
variable [MulOneClass M₁] [MulOneClass M₂] [ContinuousMul M₂]
{F : Type _} [MonoidHomClass F M₁ M₂] {l : Filter α}
/-- Construct a bundled monoid homomorphism `M₁ →* M₂` from a function `f` and a proof that it
belongs to the closure of the range of the coercion from `M₁ →* M₂` (or another type of bundled
homomorphisms that has a `MonoidHomClass` instance) to `M₁ → M₂`. -/
@[to_additive (attr := simps (config := .asFn))
"Construct a bundled additive monoid homomorphism `M₁ →+ M₂` from a function `f`
and a proof that it belongs to the closure of the range of the coercion from `M₁ →+ M₂` (or another
type of bundled homomorphisms that has a `add_monoid_hom_class` instance) to `M₁ → M₂`."]
def monoidHomOfMemClosureRangeCoe (f : M₁ → M₂)
(hf : f ∈ closure (range fun (f : F) (x : M₁) => f x)) : M₁ →* M₂
where
toFun := f
map_one' := (isClosed_setOf_map_one M₁ M₂).closure_subset_iff.2 (range_subset_iff.2 map_one) hf
map_mul' := (isClosed_setOf_map_mul M₁ M₂).closure_subset_iff.2 (range_subset_iff.2 map_mul) hf
#align monoid_hom_of_mem_closure_range_coe monoidHomOfMemClosureRangeCoe
#align add_monoid_hom_of_mem_closure_range_coe addMonoidHomOfMemClosureRangeCoe
/-- Construct a bundled monoid homomorphism from a pointwise limit of monoid homomorphisms. -/
@[to_additive (attr := simps! (config := .asFn))
"Construct a bundled additive monoid homomorphism from a pointwise limit of additive
monoid homomorphisms"]
def monoidHomOfTendsto (f : M₁ → M₂) (g : α → F) [l.NeBot]
(h : Tendsto (fun a x => g a x) l (𝓝 f)) : M₁ →* M₂ :=
monoidHomOfMemClosureRangeCoe f <|
mem_closure_of_tendsto h <| eventually_of_forall fun _ => mem_range_self _
#align monoid_hom_of_tendsto monoidHomOfTendsto
#align add_monoid_hom_of_tendsto addMonoidHomOfTendsto
variable (M₁ M₂)
@[to_additive]
theorem MonoidHom.isClosed_range_coe : IsClosed (Set.range ((↑) : (M₁ →* M₂) → M₁ → M₂)) :=
isClosed_of_closure_subset fun f hf => ⟨monoidHomOfMemClosureRangeCoe f hf, rfl⟩
#align monoid_hom.is_closed_range_coe MonoidHom.isClosed_range_coe
#align add_monoid_hom.is_closed_range_coe AddMonoidHom.isClosed_range_coe
end PointwiseLimits
@[to_additive]
theorem Inducing.continuousMul {M N F : Type _} [Mul M] [Mul N] [MulHomClass F M N]
[TopologicalSpace M] [TopologicalSpace N] [ContinuousMul N] (f : F) (hf : Inducing f) :
ContinuousMul M :=
⟨hf.continuous_iff.2 <| by
simpa only [(· ∘ ·), map_mul f] using hf.continuous.fst'.mul hf.continuous.snd'⟩
#align inducing.has_continuous_mul Inducing.continuousMul
#align inducing.has_continuous_add Inducing.continuousAdd
@[to_additive]
theorem continuousMul_induced {M N F : Type _} [Mul M] [Mul N] [MulHomClass F M N]
[TopologicalSpace N] [ContinuousMul N] (f : F) : @ContinuousMul M (induced f ‹_›) _ :=
letI := induced f ‹_›
Inducing.continuousMul f ⟨rfl⟩
#align has_continuous_mul_induced continuousMul_induced
#align has_continuous_add_induced continuousAdd_induced
@[to_additive]
instance Subsemigroup.continuousMul [TopologicalSpace M] [Semigroup M] [ContinuousMul M]
(S : Subsemigroup M) : ContinuousMul S :=
Inducing.continuousMul (⟨(↑), fun _ _ => rfl⟩ : MulHom S M) ⟨rfl⟩
#align subsemigroup.has_continuous_mul Subsemigroup.continuousMul
#align add_subsemigroup.has_continuous_add AddSubsemigroup.continuousAdd
@[to_additive]
instance Submonoid.continuousMul [TopologicalSpace M] [Monoid M] [ContinuousMul M]
(S : Submonoid M) : ContinuousMul S :=
S.toSubsemigroup.continuousMul
#align submonoid.has_continuous_mul Submonoid.continuousMul
#align add_submonoid.has_continuous_add AddSubmonoid.continuousAdd
section ContinuousMul
variable [TopologicalSpace M] [Monoid M] [ContinuousMul M]
@[to_additive]
theorem Submonoid.top_closure_mul_self_subset (s : Submonoid M) :
_root_.closure (s : Set M) * _root_.closure s ⊆ _root_.closure s :=
image2_subset_iff.2 fun _ hx _ hy =>
map_mem_closure₂ continuous_mul hx hy fun _ ha _ hb => s.mul_mem ha hb
#align submonoid.top_closure_mul_self_subset Submonoid.top_closure_mul_self_subset
#align add_submonoid.top_closure_add_self_subset AddSubmonoid.top_closure_add_self_subset
@[to_additive]
theorem Submonoid.top_closure_mul_self_eq (s : Submonoid M) :
_root_.closure (s : Set M) * _root_.closure s = _root_.closure s :=
Subset.antisymm s.top_closure_mul_self_subset fun x hx =>
⟨x, 1, hx, _root_.subset_closure s.one_mem, mul_one _⟩
#align submonoid.top_closure_mul_self_eq Submonoid.top_closure_mul_self_eq
#align add_submonoid.top_closure_add_self_eq AddSubmonoid.top_closure_add_self_eq
/-- The (topological-space) closure of a submonoid of a space `M` with `ContinuousMul` is
itself a submonoid. -/
@[to_additive "The (topological-space) closure of an additive submonoid of a space `M` with
`ContinuousAdd` is itself an additive submonoid."]
def Submonoid.topologicalClosure (s : Submonoid M) : Submonoid M
where
carrier := _root_.closure (s : Set M)
one_mem' := _root_.subset_closure s.one_mem
mul_mem' ha hb := s.top_closure_mul_self_subset ⟨_, _, ha, hb, rfl⟩
#align submonoid.topological_closure Submonoid.topologicalClosure
#align add_submonoid.topological_closure AddSubmonoid.topologicalClosure
-- Porting note: new lemma
@[to_additive]
theorem Submonoid.coe_topologicalClosure (s : Submonoid M) :
(s.topologicalClosure : Set M) = _root_.closure (s : Set M) := by rfl
@[to_additive]
theorem Submonoid.le_topologicalClosure (s : Submonoid M) : s ≤ s.topologicalClosure :=
_root_.subset_closure
#align submonoid.le_topological_closure Submonoid.le_topologicalClosure
#align add_submonoid.le_topological_closure AddSubmonoid.le_topologicalClosure
@[to_additive]
theorem Submonoid.isClosed_topologicalClosure (s : Submonoid M) :
IsClosed (s.topologicalClosure : Set M) := isClosed_closure
#align submonoid.is_closed_topological_closure Submonoid.isClosed_topologicalClosure
#align add_submonoid.is_closed_topological_closure AddSubmonoid.isClosed_topologicalClosure
@[to_additive]
theorem Submonoid.topologicalClosure_minimal (s : Submonoid M) {t : Submonoid M} (h : s ≤ t)
(ht : IsClosed (t : Set M)) : s.topologicalClosure ≤ t := closure_minimal h ht
#align submonoid.topological_closure_minimal Submonoid.topologicalClosure_minimal
#align add_submonoid.topological_closure_minimal AddSubmonoid.topologicalClosure_minimal
/-- If a submonoid of a topological monoid is commutative, then so is its topological closure. -/
@[to_additive "If a submonoid of an additive topological monoid is commutative, then so is its
topological closure."]
def Submonoid.commMonoidTopologicalClosure [T2Space M] (s : Submonoid M)
(hs : ∀ x y : s, x * y = y * x) : CommMonoid s.topologicalClosure :=
{ s.topologicalClosure.toMonoid with
mul_comm :=
have : ∀ x ∈ s, ∀ y ∈ s, x * y = y * x := fun x hx y hy =>
congr_arg Subtype.val (hs ⟨x, hx⟩ ⟨y, hy⟩)
fun ⟨x, hx⟩ ⟨y, hy⟩ =>
Subtype.ext <|
eqOn_closure₂ this continuous_mul (continuous_snd.mul continuous_fst) x hx y hy }
#align submonoid.comm_monoid_topological_closure Submonoid.commMonoidTopologicalClosure
#align add_submonoid.add_comm_monoid_topological_closure AddSubmonoid.addCommMonoidTopologicalClosure
@[to_additive exists_open_nhds_zero_half]
theorem exists_open_nhds_one_split {s : Set M} (hs : s ∈ 𝓝 (1 : M)) :
∃ V : Set M, IsOpen V ∧ (1 : M) ∈ V ∧ ∀ v ∈ V, ∀ w ∈ V, v * w ∈ s := by
have : (fun a : M × M => a.1 * a.2) ⁻¹' s ∈ 𝓝 ((1, 1) : M × M) :=
tendsto_mul (by simpa only [one_mul] using hs)
simpa only [prod_subset_iff] using exists_nhds_square this
#align exists_open_nhds_one_split exists_open_nhds_one_split
#align exists_open_nhds_zero_half exists_open_nhds_zero_half
@[to_additive exists_nhds_zero_half]
theorem exists_nhds_one_split {s : Set M} (hs : s ∈ 𝓝 (1 : M)) :
∃ V ∈ 𝓝 (1 : M), ∀ v ∈ V, ∀ w ∈ V, v * w ∈ s :=
let ⟨V, Vo, V1, hV⟩ := exists_open_nhds_one_split hs
⟨V, IsOpen.mem_nhds Vo V1, hV⟩
#align exists_nhds_one_split exists_nhds_one_split
#align exists_nhds_zero_half exists_nhds_zero_half
@[to_additive exists_nhds_zero_quarter]
theorem exists_nhds_one_split4 {u : Set M} (hu : u ∈ 𝓝 (1 : M)) :
∃ V ∈ 𝓝 (1 : M), ∀ {v w s t}, v ∈ V → w ∈ V → s ∈ V → t ∈ V → v * w * s * t ∈ u := by
rcases exists_nhds_one_split hu with ⟨W, W1, h⟩
rcases exists_nhds_one_split W1 with ⟨V, V1, h'⟩
use V, V1
intro v w s t v_in w_in s_in t_in
simpa only [mul_assoc] using h _ (h' v v_in w w_in) _ (h' s s_in t t_in)
#align exists_nhds_one_split4 exists_nhds_one_split4
#align exists_nhds_zero_quarter exists_nhds_zero_quarter
/-- Given a neighborhood `U` of `1` there is an open neighborhood `V` of `1`
such that `VV ⊆ U`. -/
@[to_additive "Given a open neighborhood `U` of `0` there is a open neighborhood `V` of `0`
such that `V + V ⊆ U`."]
theorem exists_open_nhds_one_mul_subset {U : Set M} (hU : U ∈ 𝓝 (1 : M)) :
∃ V : Set M, IsOpen V ∧ (1 : M) ∈ V ∧ V * V ⊆ U := by
rcases exists_open_nhds_one_split hU with ⟨V, Vo, V1, hV⟩
use V, Vo, V1
rintro _ ⟨x, y, hx, hy, rfl⟩
exact hV _ hx _ hy
#align exists_open_nhds_one_mul_subset exists_open_nhds_one_mul_subset
#align exists_open_nhds_zero_add_subset exists_open_nhds_zero_add_subset
@[to_additive]
theorem IsCompact.mul {s t : Set M} (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s * t) := by
rw [← image_mul_prod]
exact (hs.prod ht).image continuous_mul
#align is_compact.mul IsCompact.mul
#align is_compact.add IsCompact.add
@[to_additive]
theorem tendsto_list_prod {f : ι → α → M} {x : Filter α} {a : ι → M} :
∀ l : List ι,
(∀ i ∈ l, Tendsto (f i) x (𝓝 (a i))) →
Tendsto (fun b => (l.map fun c => f c b).prod) x (𝓝 (l.map a).prod)
| [], _ => by simp [tendsto_const_nhds]
| f::l, h => by
simp only [List.map_cons, List.prod_cons]
exact
(h f (List.mem_cons_self _ _)).mul
(tendsto_list_prod l fun c hc => h c (List.mem_cons_of_mem _ hc))
#align tendsto_list_prod tendsto_list_prod
#align tendsto_list_sum tendsto_list_sum
@[to_additive (attr := continuity)]
theorem continuous_list_prod {f : ι → X → M} (l : List ι) (h : ∀ i ∈ l, Continuous (f i)) :
Continuous fun a => (l.map fun i => f i a).prod :=
continuous_iff_continuousAt.2 fun x =>
tendsto_list_prod l fun c hc => continuous_iff_continuousAt.1 (h c hc) x
#align continuous_list_prod continuous_list_prod
#align continuous_list_sum continuous_list_sum
@[to_additive]
theorem continuousOn_list_prod {f : ι → X → M} (l : List ι) {t : Set X}
(h : ∀ i ∈ l, ContinuousOn (f i) t) : ContinuousOn (fun a => (l.map fun i => f i a).prod) t :=
by
intro x hx
rw [continuousWithinAt_iff_continuousAt_restrict _ hx]
refine' tendsto_list_prod _ fun i hi => _
specialize h i hi x hx
rw [continuousWithinAt_iff_continuousAt_restrict _ hx] at h
exact h
#align continuous_on_list_prod continuousOn_list_prod
#align continuous_on_list_sum continuousOn_list_sum
@[to_additive (attr := continuity)]
theorem continuous_pow : ∀ n : ℕ, Continuous fun a : M => a ^ n
| 0 => by simpa using continuous_const
| k + 1 => by
simp only [pow_succ]
exact continuous_id.mul (continuous_pow _)
#align continuous_pow continuous_pow
#align continuous_nsmul continuous_nsmul
instance AddMonoid.continuousConstSMul_nat {A} [AddMonoid A] [TopologicalSpace A]
[ContinuousAdd A] : ContinuousConstSMul ℕ A :=
⟨continuous_nsmul⟩
#align add_monoid.has_continuous_const_smul_nat AddMonoid.continuousConstSMul_nat
instance AddMonoid.continuousSMul_nat {A} [AddMonoid A] [TopologicalSpace A]
[ContinuousAdd A] : ContinuousSMul ℕ A :=
⟨continuous_uncurry_of_discreteTopology continuous_nsmul⟩
#align add_monoid.has_continuous_smul_nat AddMonoid.continuousSMul_nat
@[to_additive (attr := continuity)]
theorem Continuous.pow {f : X → M} (h : Continuous f) (n : ℕ) : Continuous fun b => f b ^ n :=
(continuous_pow n).comp h
#align continuous.pow Continuous.pow
#align continuous.nsmul Continuous.nsmul
@[to_additive]
theorem continuousOn_pow {s : Set M} (n : ℕ) : ContinuousOn (fun (x : M) => x ^ n) s :=
(continuous_pow n).continuousOn
#align continuous_on_pow continuousOn_pow
#align continuous_on_nsmul continuousOn_nsmul
@[to_additive]
theorem continuousAt_pow (x : M) (n : ℕ) : ContinuousAt (fun (x : M) => x ^ n) x :=
(continuous_pow n).continuousAt
#align continuous_at_pow continuousAt_pow
#align continuous_at_nsmul continuousAt_nsmul
@[to_additive]
theorem Filter.Tendsto.pow {l : Filter α} {f : α → M} {x : M} (hf : Tendsto f l (𝓝 x)) (n : ℕ) :
Tendsto (fun x => f x ^ n) l (𝓝 (x ^ n)) :=
(continuousAt_pow _ _).tendsto.comp hf
#align filter.tendsto.pow Filter.Tendsto.pow
#align filter.tendsto.nsmul Filter.Tendsto.nsmul
@[to_additive]
theorem ContinuousWithinAt.pow {f : X → M} {x : X} {s : Set X} (hf : ContinuousWithinAt f s x)
(n : ℕ) : ContinuousWithinAt (fun x => f x ^ n) s x :=
Filter.Tendsto.pow hf n
#align continuous_within_at.pow ContinuousWithinAt.pow
#align continuous_within_at.nsmul ContinuousWithinAt.nsmul
@[to_additive]
theorem ContinuousAt.pow {f : X → M} {x : X} (hf : ContinuousAt f x) (n : ℕ) :
ContinuousAt (fun x => f x ^ n) x :=
Filter.Tendsto.pow hf n
#align continuous_at.pow ContinuousAt.pow
#align continuous_at.nsmul ContinuousAt.nsmul
@[to_additive]
theorem ContinuousOn.pow {f : X → M} {s : Set X} (hf : ContinuousOn f s) (n : ℕ) :
ContinuousOn (fun x => f x ^ n) s := fun x hx => (hf x hx).pow n
#align continuous_on.pow ContinuousOn.pow
#align continuous_on.nsmul ContinuousOn.nsmul
/-- Left-multiplication by a left-invertible element of a topological monoid is proper, i.e.,
inverse images of compact sets are compact. -/
theorem Filter.tendsto_cocompact_mul_left {a b : M} (ha : b * a = 1) :
Filter.Tendsto (fun x : M => a * x) (Filter.cocompact M) (Filter.cocompact M) := by
refine Filter.Tendsto.of_tendsto_comp ?_ (Filter.comap_cocompact_le (continuous_mul_left b))
simp only [comp_mul_left, ha, one_mul]
exact Filter.tendsto_id
-- Porting note: changed proof, original proof was:
/-refine' Filter.Tendsto.of_tendsto_comp _ (Filter.comap_cocompact_le (continuous_mul_left b))
convert Filter.tendsto_id
ext x
simp [ha]-/
#align filter.tendsto_cocompact_mul_left Filter.tendsto_cocompact_mul_left
/-- Right-multiplication by a right-invertible element of a topological monoid is proper, i.e.,
inverse images of compact sets are compact. -/
theorem Filter.tendsto_cocompact_mul_right {a b : M} (ha : a * b = 1) :
Filter.Tendsto (fun x : M => x * a) (Filter.cocompact M) (Filter.cocompact M) := by
refine Filter.Tendsto.of_tendsto_comp ?_ (Filter.comap_cocompact_le (continuous_mul_right b))
simp only [comp_mul_right, ha, mul_one]
exact Filter.tendsto_id
-- Porting note: changed proof
#align filter.tendsto_cocompact_mul_right Filter.tendsto_cocompact_mul_right
/-- If `R` acts on `A` via `A`, then continuous multiplication implies continuous scalar
multiplication by constants.
Notably, this instances applies when `R = A`, or when `[Algebra R A]` is available. -/
@[to_additive "If `R` acts on `A` via `A`, then continuous addition implies
continuous affine addition by constants."]
instance (priority := 100) IsScalarTower.continuousConstSMul {R A : Type _} [Monoid A] [SMul R A]
[IsScalarTower R A A] [TopologicalSpace A] [ContinuousMul A] : ContinuousConstSMul R A where
continuous_const_smul q := by
simp (config := { singlePass := true }) only [← smul_one_mul q (_ : A)]
exact continuous_const.mul continuous_id
#align is_scalar_tower.has_continuous_const_smul IsScalarTower.continuousConstSMul
#align vadd_assoc_class.has_continuous_const_vadd VAddAssocClass.continuousConstVAdd
/-- If the action of `R` on `A` commutes with left-multiplication, then continuous multiplication
implies continuous scalar multiplication by constants.
Notably, this instances applies when `R = Aᵐᵒᵖ`.-/
@[to_additive "If the action of `R` on `A` commutes with left-addition, then
continuous addition implies continuous affine addition by constants.
Notably, this instances applies when `R = Aᵃᵒᵖ`."]
instance (priority := 100) SMulCommClass.continuousConstSMul {R A : Type _} [Monoid A] [SMul R A]
[SMulCommClass R A A] [TopologicalSpace A] [ContinuousMul A] : ContinuousConstSMul R A where
continuous_const_smul q := by
simp (config := { singlePass := true }) only [← mul_smul_one q (_ : A)]
exact continuous_id.mul continuous_const
#align smul_comm_class.has_continuous_const_smul SMulCommClass.continuousConstSMul
#align vadd_comm_class.has_continuous_const_vadd VAddCommClass.continuousConstVAdd
end ContinuousMul
namespace MulOpposite
/-- If multiplication is continuous in `α`, then it also is in `αᵐᵒᵖ`. -/
@[to_additive "If addition is continuous in `α`, then it also is in `αᵃᵒᵖ`."]
instance [TopologicalSpace α] [Mul α] [ContinuousMul α] : ContinuousMul αᵐᵒᵖ :=
⟨continuous_op.comp (continuous_unop.snd'.mul continuous_unop.fst')⟩
end MulOpposite
namespace Units
open MulOpposite
variable [TopologicalSpace α] [Monoid α] [ContinuousMul α]
/-- If multiplication on a monoid is continuous, then multiplication on the units of the monoid,
with respect to the induced topology, is continuous.
Inversion is also continuous, but we register this in a later file, `Topology.Algebra.Group`,
because the predicate `ContinuousInv` has not yet been defined. -/
@[to_additive "If addition on an additive monoid is continuous, then addition on the additive units
of the monoid, with respect to the induced topology, is continuous.
Negation is also continuous, but we register this in a later file, `topology.algebra.group`, because
the predicate `has_continuous_neg` has not yet been defined."]
instance : ContinuousMul αˣ :=
inducing_embedProduct.continuousMul (embedProduct α)
end Units
@[to_additive]
theorem Continuous.units_map [Monoid M] [Monoid N] [TopologicalSpace M] [TopologicalSpace N]
(f : M →* N) (hf : Continuous f) : Continuous (Units.map f) :=
Units.continuous_iff.2 ⟨hf.comp Units.continuous_val, hf.comp Units.continuous_coe_inv⟩
#align continuous.units_map Continuous.units_map
#align continuous.add_units_map Continuous.addUnits_map
section
variable [TopologicalSpace M] [CommMonoid M]
@[to_additive]
theorem Submonoid.mem_nhds_one (S : Submonoid M) (oS : IsOpen (S : Set M)) :
(S : Set M) ∈ 𝓝 (1 : M) :=
IsOpen.mem_nhds oS S.one_mem
#align submonoid.mem_nhds_one Submonoid.mem_nhds_one
#align add_submonoid.mem_nhds_zero AddSubmonoid.mem_nhds_zero
variable [ContinuousMul M]
@[to_additive]
theorem tendsto_multiset_prod {f : ι → α → M} {x : Filter α} {a : ι → M} (s : Multiset ι) :
(∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) →
Tendsto (fun b => (s.map fun c => f c b).prod) x (𝓝 (s.map a).prod) := by
rcases s with ⟨l⟩
simpa using tendsto_list_prod l
#align tendsto_multiset_prod tendsto_multiset_prod
#align tendsto_multiset_sum tendsto_multiset_sum
@[to_additive]
theorem tendsto_finset_prod {f : ι → α → M} {x : Filter α} {a : ι → M} (s : Finset ι) :
(∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) →
Tendsto (fun b => ∏ c in s, f c b) x (𝓝 (∏ c in s, a c)) :=
tendsto_multiset_prod _
#align tendsto_finset_prod tendsto_finset_prod
#align tendsto_finset_sum tendsto_finset_sum
@[to_additive (attr := continuity)]
theorem continuous_multiset_prod {f : ι → X → M} (s : Multiset ι) :
(∀ i ∈ s, Continuous (f i)) → Continuous fun a => (s.map fun i => f i a).prod := by
rcases s with ⟨l⟩
simpa using continuous_list_prod l
#align continuous_multiset_prod continuous_multiset_prod
#align continuous_multiset_sum continuous_multiset_sum
@[to_additive]
theorem continuousOn_multiset_prod {f : ι → X → M} (s : Multiset ι) {t : Set X} :
(∀ i ∈ s, ContinuousOn (f i) t) → ContinuousOn (fun a => (s.map fun i => f i a).prod) t := by
rcases s with ⟨l⟩
simpa using continuousOn_list_prod l
#align continuous_on_multiset_prod continuousOn_multiset_prod
#align continuous_on_multiset_sum continuousOn_multiset_sum
@[to_additive (attr := continuity)]
theorem continuous_finset_prod {f : ι → X → M} (s : Finset ι) :
(∀ i ∈ s, Continuous (f i)) → Continuous fun a => ∏ i in s, f i a :=
continuous_multiset_prod _
#align continuous_finset_prod continuous_finset_prod
#align continuous_finset_sum continuous_finset_sum
@[to_additive]
theorem continuousOn_finset_prod {f : ι → X → M} (s : Finset ι) {t : Set X} :
(∀ i ∈ s, ContinuousOn (f i) t) → ContinuousOn (fun a => ∏ i in s, f i a) t :=
continuousOn_multiset_prod _
#align continuous_on_finset_prod continuousOn_finset_prod
#align continuous_on_finset_sum continuousOn_finset_sum
@[to_additive]
theorem eventuallyEq_prod {X M : Type _} [CommMonoid M] {s : Finset ι} {l : Filter X}
{f g : ι → X → M} (hs : ∀ i ∈ s, f i =ᶠ[l] g i) : (∏ i in s, f i) =ᶠ[l] ∏ i in s, g i := by
replace hs : ∀ᶠ x in l, ∀ i ∈ s, f i x = g i x
· rwa [eventually_all_finset]
filter_upwards [hs]with x hx
simp only [Finset.prod_apply, Finset.prod_congr rfl hx]
#align eventually_eq_prod eventuallyEq_prod
#align eventually_eq_sum eventuallyEq_sum
open Function
@[to_additive]
theorem LocallyFinite.exists_finset_mulSupport {M : Type _} [CommMonoid M] {f : ι → X → M}
(hf : LocallyFinite fun i => mulSupport <| f i) (x₀ : X) :
∃ I : Finset ι, ∀ᶠ x in 𝓝 x₀, (mulSupport fun i => f i x) ⊆ I := by
rcases hf x₀ with ⟨U, hxU, hUf⟩
refine' ⟨hUf.toFinset, mem_of_superset hxU fun y hy i hi => _⟩
rw [hUf.coe_toFinset]
exact ⟨y, hi, hy⟩
#align locally_finite.exists_finset_mul_support LocallyFinite.exists_finset_mulSupport
#align locally_finite.exists_finset_support LocallyFinite.exists_finset_support
@[to_additive]
theorem finprod_eventually_eq_prod {M : Type _} [CommMonoid M] {f : ι → X → M}
(hf : LocallyFinite fun i => mulSupport (f i)) (x : X) :
∃ s : Finset ι, ∀ᶠ y in 𝓝 x, (∏ᶠ i, f i y) = ∏ i in s, f i y :=
let ⟨I, hI⟩ := hf.exists_finset_mulSupport x
⟨I, hI.mono fun _ hy => finprod_eq_prod_of_mulSupport_subset _ fun _ hi => hy hi⟩
#align finprod_eventually_eq_prod finprod_eventually_eq_prod
#align finsum_eventually_eq_sum finsum_eventually_eq_sum
@[to_additive]
theorem continuous_finprod {f : ι → X → M} (hc : ∀ i, Continuous (f i))
(hf : LocallyFinite fun i => mulSupport (f i)) : Continuous fun x => ∏ᶠ i, f i x := by
refine' continuous_iff_continuousAt.2 fun x => _
rcases finprod_eventually_eq_prod hf x with ⟨s, hs⟩
refine' ContinuousAt.congr _ (EventuallyEq.symm hs)
exact tendsto_finset_prod _ fun i _ => (hc i).continuousAt
#align continuous_finprod continuous_finprod
#align continuous_finsum continuous_finsum
@[to_additive]
theorem continuous_finprod_cond {f : ι → X → M} {p : ι → Prop} (hc : ∀ i, p i → Continuous (f i))
(hf : LocallyFinite fun i => mulSupport (f i)) : Continuous fun x => ∏ᶠ (i) (_h : p i), f i x :=
by
simp only [← finprod_subtype_eq_finprod_cond]
exact continuous_finprod (fun i => hc i i.2) (hf.comp_injective Subtype.coe_injective)
#align continuous_finprod_cond continuous_finprod_cond
#align continuous_finsum_cond continuous_finsum_cond
end
instance [TopologicalSpace M] [Mul M] [ContinuousMul M] : ContinuousAdd (Additive M)
where continuous_add := @continuous_mul M _ _ _
instance [TopologicalSpace M] [Add M] [ContinuousAdd M] : ContinuousMul (Multiplicative M)
where continuous_mul := @continuous_add M _ _ _
section LatticeOps
variable {ι' : Sort _} [Mul M]
@[to_additive]
theorem continuousMul_infₛ {ts : Set (TopologicalSpace M)}
(h : ∀ t ∈ ts, @ContinuousMul M t _) : @ContinuousMul M (infₛ ts) _ :=
letI := infₛ ts
{ continuous_mul :=
continuous_infₛ_rng.2 fun t ht =>
continuous_infₛ_dom₂ ht ht (@ContinuousMul.continuous_mul M t _ (h t ht)) }
#align has_continuous_mul_Inf continuousMul_infₛ
#align has_continuous_add_Inf continuousAdd_infₛ
@[to_additive]
theorem continuousMul_infᵢ {ts : ι' → TopologicalSpace M}
(h' : ∀ i, @ContinuousMul M (ts i) _) : @ContinuousMul M (⨅ i, ts i) _ := by
rw [← infₛ_range]
exact continuousMul_infₛ (Set.forall_range_iff.mpr h')
#align has_continuous_mul_infi continuousMul_infᵢ
#align has_continuous_add_infi continuousAdd_infᵢ
@[to_additive]
theorem continuousMul_inf {t₁ t₂ : TopologicalSpace M} (h₁ : @ContinuousMul M t₁ _)
(h₂ : @ContinuousMul M t₂ _) : @ContinuousMul M (t₁ ⊓ t₂) _ := by
rw [inf_eq_infᵢ]
refine' continuousMul_infᵢ fun b => _
cases b <;> assumption
#align has_continuous_mul_inf continuousMul_inf
#align has_continuous_add_inf continuousAdd_inf
end LatticeOps
namespace ContinuousMap
variable [Mul X] [ContinuousMul X]
/-- The continuous map `fun y => y * x` -/
@[to_additive "The continuous map `fun y => y + x"]
protected def mulRight (x : X) : C(X, X) :=
mk _ (continuous_mul_right x)
#align continuous_map.mul_right ContinuousMap.mulRight
#align continuous_map.add_right ContinuousMap.addRight
@[to_additive, simp]
theorem coe_mulRight (x : X) : ⇑(ContinuousMap.mulRight x) = fun y => y * x :=
rfl
#align continuous_map.coe_mul_right ContinuousMap.coe_mulRight
#align continuous_map.coe_add_right ContinuousMap.coe_addRight
/-- The continuous map `fun y => x * y` -/
@[to_additive "The continuous map `fun y => x + y"]
protected def mulLeft (x : X) : C(X, X) :=
mk _ (continuous_mul_left x)
#align continuous_map.mul_left ContinuousMap.mulLeft
#align continuous_map.add_left ContinuousMap.addLeft
@[to_additive, simp]
theorem coe_mulLeft (x : X) : ⇑(ContinuousMap.mulLeft x) = fun y => x * y :=
rfl
#align continuous_map.coe_mul_left ContinuousMap.coe_mulLeft
#align continuous_map.coe_add_left ContinuousMap.coe_addLeft
end ContinuousMap
|
\documentclass[main.tex]{subfiles}
\begin{document}
\chapter{Choice of priors}
\marginpar{Tuesday\\ 2020-12-15, \\ compiled \\ \today}
If we have a location parameter \(\theta \), such that
%
\begin{align}
\mathcal{L}_\theta (x) = \mathcal{L} (x-\theta )
\,,
\end{align}
%
then it makes sense to use a uniform prior \(\pi (\theta ) = \const\), which is invariant under shifts in the form \(\theta \to \theta + X\).
On the other hand, if we have a scaling parameter
%
\begin{align}
\mathcal{L}_\theta = \frac{1}{\theta } \mathcal{L}_\theta (x / \theta )
\,,
\end{align}
%
the requirements are different: we want \(\theta \) to be invariant under rescalings in the form \(\theta \to \theta/C = \phi \); so we ask
%
\begin{align}
\pi (\theta ) \dd{\theta } = \pi (\phi ) \dd{\phi } \\
\pi (\theta ) &= \frac{1}{C} \pi \qty(\theta / C)
\,,
\end{align}
%
which is satisfied by \(\pi (\theta ) \propto 1/\theta \).
This prior is called a \emph{log-uniform}: it is flat when plotted on a log scale, since if we set \(\rho = \log \theta \) we have
%
\begin{align}
\pi (\rho ) = \pi (\theta ) \abs{\dv{\theta }{\rho }} = \frac{e^{\rho }}{\theta } = 1
\,.
\end{align}
\subsection{Jeffreys prior}
In general, if we want to perform a change of variables from \(\theta \) to \(\phi \) then the Fisher matrix becomes
%
\begin{align}
F(\phi ) &= - \expval{\dv[2]{\log \mathcal{L}(\vec{x} | \phi )}{\phi}} \\
&= - \expval{ \dv[2]{\log \mathcal{L}(\vec{x} | \theta )}{\theta} \qty(\dv{\theta }{\phi })^2 + \dv{\log \mathcal{L}(\vec{x} | \theta )}{\theta } \dv[2]{\theta }{\phi }} \\
&= - \expval{\dv[2]{\log \mathcal{L}(\vec{x} | \theta )}{\theta }}
\qty(\dv{\theta }{\phi })^2 - \expval{\dv{\log \mathcal{L}(\vec{x} | \theta )}{\theta }} \dv[2]{\theta }{\phi } \\
&= \underbrace{\expval{\dv[2]{\log \mathcal{L}(\vec{x} | \theta )}{\theta }}}_{F(\theta )}
\qty(\dv{\theta }{\phi })^2
\,.
\end{align}
The prior is defined as the square root of the Fisher information matrix:
%
\begin{align}
\sqrt{F(\phi )} &= \sqrt{I(\theta )} \abs{\dv{\theta }{\phi }} \\
\pi (\phi ) &= \pi (\theta ) \abs{\dv{\theta }{\phi }}
\,.
\end{align}
If we use this definition, we get the correct law for the change of variable.
We can apply this to a univariate Gaussian with fixed \(\sigma \): we get
%
\begin{align}
\dv[2]{\log \mathcal{L}}{\mu } = - \frac{1}{\sigma^2}
\,,
\end{align}
%
therefore \(F(\mu )\) is a constant, meaning that the Jeffreys prior \(\pi_J (\mu )\) is also a constant.
Suppose instead that we also let \(\sigma \) vary: then
%
\begin{align}
\dv{\log \mathcal{L}}{\sigma } &= \dv{}{\sigma } \qty( \log \sigma - \frac{1}{2} \frac{(x - \mu )^2}{\sigma^2})
\dv[2]{\log \mathcal{L}}{\sigma } &= \frac{1}{\sigma^2} - \frac{3 (x - \mu )^2}{\sigma^{4}} \\
F(\sigma ) = -\expval{\dv[2]{\log \mathcal{L}}{\sigma }} &= - \frac{1}{\sigma^2} + \frac{3 \sigma^2}{\sigma^{4}} = \frac{2}{\sigma^2}
\,.
\end{align}
Therefore, \(F(\sigma ) \propto 1 / \sigma^2\), meaning that \(\pi_J (\sigma ) \propto 1/ \sigma \).
Uniform priors may pose an issue in high-dimensional space: especially if the mean \(\vec{\mu} \) is high-dimensional, a uniform prior on its entries gives a lot of weight to high-length vector.
Often people resort to information-theory based criteria.
We discuss \textcite[]{lahavBayesianHyperparametersApproach2000}.
\end{document}
|
/-
# References
1. Enderton, Herbert B. A Mathematical Introduction to Logic. 2nd ed. San Diego:
Harcourt/Academic Press, 2001.
-/
import Bookshelf.Tuple
/--
The following describes a so-called "generic" tuple. Like in `Bookshelf.Tuple`,
an `n`-tuple is defined recursively like so:
`⟨x₁, ..., xₙ⟩ = ⟨⟨x₁, ..., xₙ₋₁⟩, xₙ⟩`
Unlike `Bookshelf.Tuple`, a "generic" tuple bends the syntax above further. For
example, both tuples above are equivalent to:
`⟨⟨x₁, ..., xₘ⟩, xₘ₊₁, ..., xₙ⟩`
for some `1 ≤ m ≤ n`. This distinction is purely syntactic, but necessary to
prove certain theorems found in [1] (e.g. `lemma_0a`).
In general, prefer `Bookshelf.Tuple`.
-/
inductive XTuple : (α : Type u) → (size : Nat × Nat) → Type u where
| nil : XTuple α (0, 0)
| snoc : XTuple α (p, q) → Tuple α r → XTuple α (p + q, r)
syntax (priority := high) "x[" term,* "]" : term
macro_rules
| `(x[]) => `(XTuple.nil)
| `(x[$x]) => `(XTuple.snoc x[] t[$x])
| `(x[x[$xs:term,*], $ys:term,*]) => `(XTuple.snoc x[$xs,*] t[$ys,*])
| `(x[$x, $xs:term,*]) => `(XTuple.snoc x[] t[$x, $xs,*])
namespace XTuple
open scoped Tuple
/- -------------------------------------
- Normalization
- -------------------------------------/
/--
Converts an `XTuple` into "normal form".
-/
def norm : XTuple α (m, n) → Tuple α (m + n)
| x[] => t[]
| snoc is ts => Tuple.concat is.norm ts
/--
Normalization of an empty `XTuple` yields an empty `Tuple`.
-/
theorem norm_nil_eq_nil : @norm α 0 0 nil = Tuple.nil :=
rfl
/--
Normalization of a pseudo-empty `XTuple` yields an empty `Tuple`.
-/
theorem norm_snoc_nil_nil_eq_nil : @norm α 0 0 (snoc x[] t[]) = t[] := by
unfold norm norm
rfl
/--
Normalization elimates `snoc` when the `snd` component is `nil`.
-/
theorem norm_snoc_nil_elim {t : XTuple α (p, q)}
: norm (snoc t t[]) = norm t :=
XTuple.casesOn t
(motive := fun _ t => norm (snoc t t[]) = norm t)
(by simp; unfold norm norm; rfl)
(fun tf tl => by
simp
conv => lhs; unfold norm)
/--
Normalization eliminates `snoc` when the `fst` component is `nil`.
-/
theorem norm_nil_snoc_elim {ts : Tuple α n} : norm (snoc x[] ts) = cast (by simp) ts := by
unfold norm norm
rw [Tuple.nil_concat_self_eq_self]
/--
Normalization distributes across `Tuple.snoc` calls.
-/
theorem norm_snoc_snoc_norm
: norm (snoc as (Tuple.snoc bs b)) = Tuple.snoc (norm (snoc as bs)) b := by
unfold norm
rw [←Tuple.concat_snoc_snoc_concat]
/--
Normalizing an `XTuple` is equivalent to concatenating the normalized `fst`
component with the `snd`.
-/
theorem norm_snoc_eq_concat {t₁ : XTuple α (p, q)} {t₂ : Tuple α n}
: norm (snoc t₁ t₂) = Tuple.concat t₁.norm t₂ := by
conv => lhs; unfold norm
/- -------------------------------------
- Equality
- -------------------------------------/
/--
Implements Boolean equality for `XTuple α n` provided `α` has decidable
equality.
-/
instance BEq [DecidableEq α] : BEq (XTuple α n) where
beq t₁ t₂ := t₁.norm == t₂.norm
/- -------------------------------------
- Basic API
- -------------------------------------/
/--
Returns the number of entries in the `XTuple`.
-/
def size (_ : XTuple α n) := n
/--
Returns the number of entries in the "shallowest" portion of the `XTuple`. For
example, the length of `x[x[1, 2], 3, 4]` is `3`, despite its size being `4`.
-/
def length : XTuple α n → Nat
| x[] => 0
| snoc x[] ts => ts.size
| snoc _ ts => 1 + ts.size
/--
Returns the first component of our `XTuple`. For example, the first component of
tuple `x[x[1, 2], 3, 4]` is `t[1, 2]`.
-/
def fst : XTuple α (m, n) → Tuple α m
| x[] => t[]
| snoc ts _ => ts.norm
/--
Given `XTuple α (m, n)`, the `fst` component is equal to an initial segment of
size `k` of the tuple in normal form.
-/
theorem self_fst_eq_norm_take (t : XTuple α (m, n)) : t.fst = t.norm.take m :=
match t with
| x[] => by unfold fst; rw [Tuple.self_take_zero_eq_nil]; simp
| snoc tf tl => by
unfold fst
conv => rhs; unfold norm
rw [Tuple.eq_take_concat]
simp
/--
If the normal form of an `XTuple` is equal to a `Tuple`, the `fst` component
must be a prefix of the `Tuple`.
-/
theorem norm_eq_fst_eq_take {t₁ : XTuple α (m, n)} {t₂ : Tuple α (m + n)}
: (t₁.norm = t₂) → (t₁.fst = t₂.take m) :=
fun h => by rw [self_fst_eq_norm_take, h]
/--
Returns the first component of our `XTuple`. For example, the first component of
tuple `x[x[1, 2], 3, 4]` is `t[3, 4]`.
-/
def snd : XTuple α (m, n) → Tuple α n
| x[] => t[]
| snoc _ ts => ts
/- -------------------------------------
- Lemma 0A
- -------------------------------------/
section
variable {k m n : Nat}
variable (p : 1 ≤ m)
variable (q : n + (m - 1) = m + k)
namespace Lemma_0a
lemma n_eq_succ_k : n = k + 1 :=
let ⟨m', h⟩ := Nat.exists_eq_succ_of_ne_zero $ show m ≠ 0 by
intro h
have ff : 1 ≤ 0 := h ▸ p
ring_nf at ff
exact ff.elim
calc
n = n + (m - 1) - (m - 1) := by rw [Nat.add_sub_cancel]
_ = m' + 1 + k - (m' + 1 - 1) := by rw [q, h]
_ = m' + 1 + k - m' := by simp
_ = 1 + k + m' - m' := by rw [Nat.add_assoc, Nat.add_comm]
_ = 1 + k := by simp
_ = k + 1 := by rw [Nat.add_comm]
lemma n_pred_eq_k : n - 1 = k := by
have h : k + 1 - 1 = k + 1 - 1 := rfl
conv at h => lhs; rw [←n_eq_succ_k p q]
simp at h
exact h
lemma n_geq_one : 1 ≤ n := by
rw [n_eq_succ_k p q]
simp
lemma min_comm_succ_eq : min (m + k) (k + 1) = k + 1 :=
Nat.recOn k
(by simp; exact p)
(fun k' ih => calc
min (m + (k' + 1)) (k' + 1 + 1)
= min (m + k' + 1) (k' + 1 + 1) := by conv => rw [Nat.add_assoc]
_ = min (m + k') (k' + 1) + 1 := Nat.min_succ_succ (m + k') (k' + 1)
_ = k' + 1 + 1 := by rw [ih])
lemma n_eq_min_comm_succ : n = min (m + k) (k + 1) := by
rw [min_comm_succ_eq p]
exact n_eq_succ_k p q
lemma n_pred_m_eq_m_k : n + (m - 1) = m + k := by
rw [←Nat.add_sub_assoc p, Nat.add_comm, Nat.add_sub_assoc (n_geq_one p q)]
conv => lhs; rw [n_pred_eq_k p q]
def cast_norm : XTuple α (n, m - 1) → Tuple α (m + k)
| xs => cast (by rw [q]) xs.norm
def cast_fst : XTuple α (n, m - 1) → Tuple α (k + 1)
| xs => cast (by rw [n_eq_succ_k p q]) xs.fst
def cast_take (ys : Tuple α (m + k)) :=
cast (by rw [min_comm_succ_eq p]) (ys.take (k + 1))
end Lemma_0a
open Lemma_0a
/--[1]
Assume that ⟨x₁, ..., xₘ⟩ = ⟨y₁, ..., yₘ, ..., yₘ₊ₖ⟩. Then x₁ = ⟨y₁, ..., yₖ₊₁⟩.
-/
theorem lemma_0a (xs : XTuple α (n, m - 1)) (ys : Tuple α (m + k))
: (cast_norm q xs = ys) → (cast_fst p q xs = cast_take p ys) := by
intro h
suffices HEq
(cast (_ : Tuple α n = Tuple α (k + 1)) (fst xs))
(cast (_ : Tuple α (min (m + k) (k + 1)) = Tuple α (k + 1)) (Tuple.take ys (k + 1)))
from eq_of_heq this
congr
· exact n_eq_min_comm_succ p q
· rfl
· exact n_eq_min_comm_succ p q
· exact HEq.rfl
· exact Eq.recOn
(motive := fun _ h => HEq
(_ : n + (n - 1) = n + k)
(cast h (show n + (n - 1) = n + k by rw [n_pred_eq_k p q])))
(show (n + (n - 1) = n + k) = (min (m + k) (k + 1) + (n - 1) = n + k) by
rw [n_eq_min_comm_succ p q])
HEq.rfl
· exact n_geq_one p q
· exact n_pred_eq_k p q
· exact Eq.symm (n_eq_min_comm_succ p q)
· exact n_pred_eq_k p q
· rw [self_fst_eq_norm_take]
unfold cast_norm at h
simp at h
rw [←h, ←n_eq_succ_k p q]
have h₂ := Eq.recOn
(motive := fun x h => HEq
(Tuple.take xs.norm n)
(Tuple.take (cast (show Tuple α (n + (m - 1)) = Tuple α x by rw [h]) xs.norm) n))
(show n + (m - 1) = m + k by rw [n_pred_m_eq_m_k p q])
HEq.rfl
exact Eq.recOn
(motive := fun x h => HEq
(cast h (Tuple.take xs.norm n))
(Tuple.take (cast (_ : Tuple α (n + (m - 1)) = Tuple α (m + k)) xs.norm) n))
(show Tuple α (min (n + (m - 1)) n) = Tuple α n by simp)
h₂
end
end XTuple
|
#
# University: Universidad de Valladolid
# Degree: Grado en Estadística
# Subject: Análisis de Datos
# Year: 2017/18
# Teacher: Miguel Alejandro Fernández Temprano
# Author: Sergio García Prado (garciparedes.me)
# Name: Análisis de Componentes Principales - Práctica 01
#
#
rm(list = ls())
library(ggplot2)
suppressMessages(library(gdata))
DATA <- read.xls('./../../../datasets/olympic-2016.xls')
print(DATA)
A <- as.matrix(DATA[,1:10])
# print(A)
X <- t((t(A) - colMeans(A)) / apply(A, 2, sd))
X_start = (t(X) %*% X ) / (dim(X)[1] - 1)
# print(X_start)
X_lambda <- eigen(X_start)$values
X_u <- eigen(X_start)$vector
# print(X_u)
S <- X %*% X_u
scores = as.data.frame(S)
# print(scores)
ggplot(data = scores, aes(x=V1, y=V2, label=DATA[,12])) +
geom_point() +
geom_text()
|
theorem fermats_last_theorem
(n : ℕ)
(n_gt_2 : n > 2)
:
¬ (∃ x y z : ℕ, (x^n + y^n = z^n) ∧ (x ≠ 0) ∧ (y ≠ 0) ∧ (z ≠ 0))
:=
begin
sorry,
end |
data Nat : Set where
zero : Nat
suc : Nat → Nat
plus : Nat → Nat → Nat
plus zero b = b
plus (suc a) b = suc (plus a b)
infixl 6 _+_
_+_ = plus
{-# DISPLAY suc n = 1 + n #-}
{-# DISPLAY plus a b = a + b #-}
postulate
T : {A : Set} → A → Set
test₁ : ∀ a b → T (plus (suc a) b)
test₁ a b = {!!}
data Vec (A : Set) : Nat → Set where
[] : Vec A zero
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
data List A : Set where
[] : List A
_∷_ : A → List A → List A
infixr 4 _∷_
[_] : ∀ {A} → A → Vec A (suc zero)
[ x ] = x ∷ []
{-# DISPLAY Vec._∷_ x Vec.[] = [ x ] #-}
test₂ : (n : Nat) → T (n Vec.∷ [])
test₂ n = {!!}
append : ∀ {A : Set} {n m} → Vec A n → Vec A m → Vec A (n + m)
append [] ys = ys
append (x ∷ xs) ys = x ∷ append xs ys
infixr 4 _++_
_++_ = append
{-# DISPLAY append xs ys = xs ++ ys #-}
{-# DISPLAY append xs (y Vec.∷ ys) = xs ++ [ y ] ++ ys #-}
test₃ : ∀ {n} (xs ys : Vec Nat n) → T (append xs (n ∷ ys))
test₃ {n} xs ys = {!!}
|
/-
Copyright (c) 2022 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import Init.Data.Array.Basic
import Init.Data.Nat.Linear
import Init.Data.List.BasicAux
theorem List.sizeOf_get_lt [SizeOf α] (as : List α) (i : Fin as.length) : sizeOf (as.get i) < sizeOf as := by
match as, i with
| [], i => apply Fin.elim0 i
| a::as, ⟨0, _⟩ => simp_arith [get]
| a::as, ⟨i+1, h⟩ =>
simp [get]
have h : i < as.length := Nat.lt_of_succ_lt_succ h
have ih := sizeOf_get_lt as ⟨i, h⟩
exact Nat.lt_of_lt_of_le ih (Nat.le_add_left ..)
namespace Array
instance [DecidableEq α] : Membership α (Array α) where
mem a as := as.contains a
theorem sizeOf_get_lt [SizeOf α] (as : Array α) (i : Fin as.size) : sizeOf (as.get i) < sizeOf as := by
cases as; rename_i as
simp [get]
have ih := List.sizeOf_get_lt as i
exact Nat.lt_trans ih (by simp_arith)
theorem sizeOf_lt_of_mem [DecidableEq α] [SizeOf α] {as : Array α} (h : a ∈ as) : sizeOf a < sizeOf as := by
simp [Membership.mem, contains, any, Id.run, BEq.beq, anyM] at h
let rec aux (j : Nat) (h : anyM.loop (m := Id) (fun b => decide (a = b)) as as.size (Nat.le_refl ..) j = true) : sizeOf a < sizeOf as := by
unfold anyM.loop at h
split at h
· simp [Bind.bind, pure] at h; split at h
next he => subst a; apply sizeOf_get_lt
next => have ih := aux (j+1) h; assumption
· contradiction
apply aux 0 h
termination_by aux j _ => as.size - j
@[simp] theorem sizeOf_get [SizeOf α] (as : Array α) (i : Fin as.size) : sizeOf (as.get i) < sizeOf as := by
cases as
simp [get]
apply Nat.lt_trans (List.sizeOf_get ..)
simp_arith
/-- This tactic, added to the `decreasing_trivial` toolbox, proves that
`sizeOf arr[i] < sizeOf arr`, which is useful for well founded recursions
over a nested inductive like `inductive T | mk : Array T → T`. -/
macro "array_get_dec" : tactic =>
`(tactic| first
| apply sizeOf_get
| apply Nat.lt_trans (sizeOf_get ..); simp_arith)
macro_rules | `(tactic| decreasing_trivial) => `(tactic| array_get_dec)
end Array
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Init.Function
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.Basic
import Mathlib.Tactic.Coe
import Mathlib.Tactic.Ext
open Function
namespace Subtype
variable {α : Sort _} {β : Sort _} {γ : Sort _} {p : α → Prop} {q : α → Prop}
def simps.coe (x: Subtype p) : α := x
/-- A version of `x.property` or `x.2` where `p` is syntactically applied to the coercion of `x`
instead of `x.1`. A similar result is `Subtype.mem` in `data.set.basic`. -/
lemma prop (x : Subtype p) : p x := x.2
@[simp] protected theorem «forall» {q : {a // p a} → Prop} :
(∀ x, q x) ↔ (∀ a b, q ⟨a, b⟩) :=
⟨λ h a b => h ⟨a, b⟩, λ h ⟨a, b⟩ => h a b⟩
/-- An alternative version of `Subtype.forall`. This one is useful if Lean cannot figure out `q`
when using `Subtype.forall` from right to left. -/
protected theorem forall' {q : ∀x, p x → Prop} :
(∀ x h, q x h) ↔ (∀ x : {a // p a}, q x x.2) :=
(@Subtype.forall _ _ (λ x => q x.1 x.2)).symm
@[simp] protected theorem «exists» {q : {a // p a} → Prop} :
(∃ x, q x) ↔ (∃ a b, q ⟨a, b⟩) :=
⟨λ ⟨⟨a, b⟩, h⟩ => ⟨a, b, h⟩, λ ⟨a, b, h⟩ => ⟨⟨a, b⟩, h⟩⟩
protected lemma ext : ∀ {a1 a2 : {x // p x}}, (a1 : α) = (a2 : α) → a1 = a2
| ⟨x, h1⟩, ⟨y, h2⟩, hz => by simp [hz]
lemma ext_iff {a1 a2 : {x // p x}} : a1 = a2 ↔ (a1 : α) = (a2 : α) :=
⟨congrArg _, Subtype.ext⟩
lemma heq_iff_coe_eq (h : ∀ x, p x ↔ q x) {a1 : {x // p x}} {a2 : {x // q x}} :
HEq a1 a2 ↔ (a1 : α) = (a2 : α) :=
Eq.rec (motive := λ (pp: (α → Prop)) _ => ∀ a2' : {x // pp x}, HEq a1 a2' ↔ (a1 : α) = (a2' : α))
(λ a2' => heq_iff_eq.trans ext_iff) (funext $ λ x => propext (h x)) a2
lemma heq_iff_coe_heq {α β : Sort _} {p : α → Prop} {q : β → Prop} {a : {x // p x}}
{b : {y // q y}} (h : α = β) (h' : HEq p q) :
HEq a b ↔ HEq (a : α) (b : β) :=
by subst h
have hpq : p = q := heq_iff_eq.1 h'
subst hpq
rw [heq_iff_eq, heq_iff_eq, ext_iff]
lemma ext_val {a1 a2 : {x // p x}} : a1.1 = a2.1 → a1 = a2 :=
Subtype.ext
lemma ext_iff_val {a1 a2 : {x // p x}} : a1 = a2 ↔ a1.1 = a2.1 :=
ext_iff
@[simp] theorem coe_eta (a : {a // p a}) (h : p (a : α)) : mk (a : α) h = a := Subtype.ext rfl
theorem coe_mk (a h) : (@mk α p a h : α) = a := rfl
theorem mk_eq_mk {a h a' h'} : @mk α p a h = @mk α p a' h' ↔ a = a' :=
ext_iff
theorem coe_eq_iff {a : {a // p a}} {b : α} : ↑a = b ↔ ∃ h, a = ⟨b, h⟩ :=
⟨λ h => h ▸ ⟨a.2, (coe_eta _ _).symm⟩, λ ⟨hb, ha⟩ => ha.symm ▸ rfl⟩
theorem coe_injective : injective ((↑·) : Subtype p → α) :=
by intros a b hab
exact Subtype.ext hab
theorem val_injective : injective (@val _ p) :=
coe_injective
/-- Restrict a (dependent) function to a subtype -/
def restrict {α} {β : α → Type _} (f : ∀x, β x) (p : α → Prop) (x : Subtype p) : β x.1 :=
f x
lemma restrict_apply {α} {β : α → Type _} (f : ∀x, β x) (p : α → Prop) (x : Subtype p) :
restrict f p x = f x.1 := rfl
lemma restrict_def {α β} (f : α → β) (p : α → Prop) : restrict f p = f ∘ (↑) := rfl
lemma restrict_injective {α β} {f : α → β} (p : α → Prop) (h : injective f) :
injective (restrict f p) :=
h.comp coe_injective
/-- Defining a map into a subtype, this can be seen as an "coinduction principle" of `Subtype`-/
def coind {α β} (f : α → β) {p : β → Prop} (h : ∀a, p (f a)) : α → Subtype p :=
λ a => ⟨f a, h a⟩
theorem coind_injective {α β} {f : α → β} {p : β → Prop} (h : ∀a, p (f a))
(hf : injective f) : injective (coind f h) :=
by intros x y hxy
refine hf ?_
apply congrArg Subtype.val hxy
theorem coind_surjective {α β} {f : α → β} {p : β → Prop} (h : ∀a, p (f a))
(hf : surjective f) : surjective (coind f h) :=
λ x => let ⟨a, ha⟩ := hf x
⟨a, coe_injective ha⟩
theorem coind_bijective {α β} {f : α → β} {p : β → Prop} (h : ∀a, p (f a))
(hf : bijective f) : bijective (coind f h) :=
⟨coind_injective h hf.1, coind_surjective h hf.2⟩
/-- Restriction of a function to a function on subtypes. -/
def map {p : α → Prop} {q : β → Prop} (f : α → β) (h : ∀a, p a → q (f a)) :
Subtype p → Subtype q :=
λ x => ⟨f x, h x x.prop⟩
theorem map_comp {p : α → Prop} {q : β → Prop} {r : γ → Prop} {x : Subtype p}
(f : α → β) (h : ∀a, p a → q (f a)) (g : β → γ) (l : ∀a, q a → r (g a)) :
map g l (map f h x) = map (g ∘ f) (λ a ha => l (f a) $ h a ha) x :=
rfl
theorem map_id {p : α → Prop} {h : ∀a, p a → p (id a)} : map (@id α) h = id :=
funext $ λ ⟨v, h⟩ => rfl
lemma map_injective {p : α → Prop} {q : β → Prop} {f : α → β} (h : ∀a, p a → q (f a))
(hf : injective f) : injective (map f h) :=
coind_injective _ $ hf.comp coe_injective
lemma map_involutive {p : α → Prop} {f : α → α} (h : ∀a, p a → p (f a))
(hf : involutive f) : involutive (map f h) :=
λ x => Subtype.ext (hf x)
instance [HasEquiv α] (p : α → Prop) : HasEquiv (Subtype p) :=
⟨λ s t => (s : α) ≈ (t : α)⟩
/-
Port note: we need explicit universes here because in Lean 3 we have
has_equiv.equiv : Π {α : Sort u} [c : has_equiv α], α → α → Prop
but in Lean 4 `HasEquiv.Equiv` is additionally parameteric over the universe of
the result. I.e
HasEquiv.Equiv.{u, v} : {α : Sort u} → [self : HasEquiv α] → α → α → Sort v
-/
theorem equiv_iff [HasEquiv.{u_1, 0} α] {p : α → Prop} {s t : Subtype p} :
HasEquiv.Equiv.{max 1 u_1, 0} s t ↔ HasEquiv.Equiv.{u_1, 0} (s : α) (t : α) :=
Iff.rfl
variable [Setoid α]
protected theorem refl (s : Subtype p) : s ≈ s :=
Setoid.refl (s : α)
protected theorem symm {s t : Subtype p} (h : s ≈ t) : t ≈ s :=
Setoid.symm h
protected theorem trans {s t u : Subtype p} (h₁ : s ≈ t) (h₂ : t ≈ u) : s ≈ u :=
Setoid.trans h₁ h₂
theorem equivalence (p : α → Prop) : Equivalence (@HasEquiv.Equiv (Subtype p) _) :=
⟨Subtype.refl, @Subtype.symm _ p _, @Subtype.trans _ p _⟩
instance (p : α → Prop) : Setoid (Subtype p) :=
Setoid.mk (·≈·) (equivalence p)
end Subtype
namespace Subtype
/-! Some facts about sets, which require that `α` is a type. -/
variable {α : Type _} {β : Type _} {γ : Type _} {p : α → Prop}
-- ∈-notation is reducible in Lean 4, so this won't trigger as a simp-lemma
lemma val_prop {S : Set α} (a : {a // a ∈ S}) : a.val ∈ S := a.property
end Subtype
|
-- anything after two minus signs like this is a comment.
variables P Q R : Prop -- P, Q, R are now true/false statements.
-- Reminder : ∧ means "and".
theorem basic_logic : (P → Q) ∧ (Q → R) → (P → R) :=
begin
admit
end |
universe u v
inductive Imf {α : Type u} {β : Type v} (f : α → β) : β → Type (max u v)
| mk : (a : α) → Imf f (f a)
def h {α β} {f : α → β} : {b : β} → Imf f b → α
| _, Imf.mk a => a
#print h
theorem ex : ∀ {α β : Sort u} (h : α = β) (a : α), cast h a ≅ a
| α, _, rfl, a => HEq.refl a
#print ex
|
open import Agda.Primitive
open import Agda.Builtin.Nat
Type : (i : Level) -> Set (lsuc i)
Type i = Set i
postulate
P : (i : Level) (A : Type i) → A → Type i
postulate
lemma : (a : Nat) -> P _ _ a
|
# #############################################################################
# Generate sample data
import numpy as np
import matplotlib.pyplot as plt
from sklearn import neighbors
from models import knn
if __name__ == "__main__":
np.random.seed(0)
X = np.sort(5 * np.random.rand(40, 1), axis=0)
T = np.linspace(0, 5, 500)[:, np.newaxis]
y = np.sin(X).ravel()
# Add noise to targets
y[::5] += 1 * (0.5 - np.random.rand(8))
# #############################################################################
# Fit regression model
n_neighbors = 10
# ------ KNN with scikit-learn ------
knn_sk = neighbors.KNeighborsRegressor(n_neighbors)
model_sk = knn_sk.fit(X, y)
y_sk = model_sk.predict(T)
# ------ KNN with NumPy ------
knn_np = knn.KNeighborsRegressor(k=n_neighbors)
model_np = knn_np.fit(X, y)
y_np = model_np.predict(T)
# ------ COMPARISON ------
y_comp = np.dstack([y_sk, y_np])
RMSE = np.sqrt(np.mean((y_sk - y_np) ** 2))
print(f"RMSE between sklearn and numpy model: {RMSE}")
# ------ Plotting ------
plt.scatter(X, y, color='blue', label='data')
plt.plot(T, y_sk, color='green', label='sklearn prediction')
plt.plot(T, y_np, color='red', linestyle='--', label='NumPy prediction')
plt.legend()
plt.title("KNeighborsRegressor")
plt.show()
|
-- Lucas Moschen
-- Teorema de Cantor
import data.set
variables X Y: Type
def surjective {X: Type} {Y: Type} (f : X → Y) : Prop := ∀ y, ∃ x, f x = y
theorem Cantor : ∀ (A: set X), ¬ ∃ (f: A → set A), surjective f :=
begin
intro A,
intro h,
cases h with f h1,
have h2: ∃ x, f x = {t : A | ¬ (t ∈ f t)}, from h1 {t : A | ¬ (t ∈ f t)},
cases h2 with x h3,
apply or.elim (classical.em (x ∈ {t : A | ¬ (t ∈ f t)})),
intro h4,
have h5: ¬ (x ∈ f x), from h4,
rw (eq.symm h3) at h4,
apply h5 h4,
intro h4,
rw (eq.symm h3) at h4,
have h5: x ∈ {t : A | ¬ (t ∈ f t)}, from h4,
rw (eq.symm h3) at h5,
apply h4 h5,
end |
header{*V-Sets, Epsilon Closure, Ranks*}
theory Rank imports Ordinal
begin
section{*V-sets*}
text{*Definition 4.1*}
definition Vset :: "hf \<Rightarrow> hf"
where "Vset x = ord_rec 0 HPow (\<lambda>z. 0) x"
lemma Vset_0 [simp]: "Vset 0 = 0"
by (simp add: Vset_def)
lemma Vset_succ [simp]: "Ord k \<Longrightarrow> Vset (succ k) = HPow (Vset k)"
by (simp add: Vset_def)
lemma Vset_non [simp]: "~ Ord x \<Longrightarrow> Vset x = 0"
by (simp add: Vset_def)
text{*Theorem 4.2(a)*}
lemma Vset_mono_strict:
assumes "Ord m" "n <: m" shows "Vset n < Vset m"
proof -
have n: "Ord n"
by (metis Ord_in_Ord assms)
hence "Ord m \<Longrightarrow> n <: m \<Longrightarrow> Vset n < Vset m"
proof (induct n arbitrary: m rule: Ord_induct2)
case 0 thus ?case
by (metis HPow_iff Ord_cases Vset_0 Vset_succ hemptyE le_imp_less_or_eq zero_le)
next
case (succ n)
then show ?case using `Ord m`
by (metis Ord_cases hemptyE HPow_mono_strict_iff Vset_succ mem_succ_iff)
qed
thus ?thesis using assms .
qed
lemma Vset_mono: "\<lbrakk>Ord m; n \<le> m\<rbrakk> \<Longrightarrow> Vset n \<le> Vset m"
by (metis Ord_linear2 Vset_mono_strict Vset_non assms order.order_iff_strict
order_class.order.antisym zero_le)
text{*Theorem 4.2(b)*}
lemma Vset_Transset: "Ord m \<Longrightarrow> Transset (Vset m)"
by (induct rule: Ord_induct2) (auto simp: Transset_def)
lemma Ord_sup [simp]: "Ord k \<Longrightarrow> Ord l \<Longrightarrow> Ord (k \<squnion> l)"
by (metis Ord_linear_le le_iff_sup sup_absorb1)
lemma Ord_inf [simp]: "Ord k \<Longrightarrow> Ord l \<Longrightarrow> Ord (k \<sqinter> l)"
by (metis Ord_linear_le inf_absorb2 le_iff_inf)
text{*Theorem 4.3*}
lemma Vset_universal: "\<exists>n. Ord n & x \<^bold>\<in> Vset n"
proof (induct x rule: hf_induct)
case 0 thus ?case
by (metis HPow_iff Ord_0 Ord_succ Vset_succ zero_le)
next
case (hinsert a b)
then obtain na nb where nab: "Ord na" "a \<^bold>\<in> Vset na" "Ord nb" "b \<^bold>\<in> Vset nb"
by blast
hence "b \<le> Vset nb" using Vset_Transset [of nb]
by (auto simp: Transset_def)
also have "... \<le> Vset (na \<squnion> nb)" using nab
by (metis Ord_sup Vset_mono sup_ge2)
finally have "b \<triangleleft> a \<^bold>\<in> Vset (succ (na \<squnion> nb))" using nab
by simp (metis Ord_sup Vset_mono sup_ge1 rev_hsubsetD)
thus ?case using nab
by (metis Ord_succ Ord_sup)
qed
section{*Least Ordinal Operator*}
text{*Definition 4.4. For every x, let rank(x) be the least ordinal n such that...*}
lemma Ord_minimal:
"Ord k \<Longrightarrow> P k \<Longrightarrow> \<exists>n. Ord n & P n & (\<forall>m. Ord m & P m \<longrightarrow> n \<le> m)"
by (induct k rule: Ord_induct) (metis Ord_linear2)
lemma OrdLeastI: "Ord k \<Longrightarrow> P k \<Longrightarrow> P(LEAST n. Ord n & P n)"
by (metis (lifting, no_types) Least_equality Ord_minimal)
lemma OrdLeast_le: "Ord k \<Longrightarrow> P k \<Longrightarrow> (LEAST n. Ord n & P n) \<le> k"
by (metis (lifting, no_types) Least_equality Ord_minimal)
lemma OrdLeast_Ord:
assumes "Ord k" "P k"shows "Ord(LEAST n. Ord n & P n)"
proof -
obtain n where "Ord n" "P n" "\<forall>m. Ord m & P m \<longrightarrow> n \<le> m"
by (metis Ord_minimal assms)
thus ?thesis
by (metis (lifting) Least_equality)
qed
section{*Rank Function*}
definition rank :: "hf \<Rightarrow> hf"
where "rank x = (LEAST n. Ord n & x \<^bold>\<in> Vset (succ n))"
lemma in_Vset_rank: "a \<^bold>\<in> Vset(succ(rank a))"
proof -
from Vset_universal [of a]
obtain na where na: "Ord na" "a \<^bold>\<in> Vset (succ na)"
by (metis Ord_Union Ord_in_Ord Ord_pred Vset_0 hempty_iff)
thus ?thesis
by (unfold rank_def) (rule OrdLeastI)
qed
lemma Ord_rank [simp]: "Ord (rank a)"
by (metis Ord_succ_iff Vset_non hemptyE in_Vset_rank)
lemma le_Vset_rank: "a \<le> Vset(rank a)"
by (metis HPow_iff Ord_succ_iff Vset_non Vset_succ hemptyE in_Vset_rank)
lemma VsetI: "succ(rank a) \<le> k \<Longrightarrow> Ord k \<Longrightarrow> a \<^bold>\<in> Vset k"
by (metis Vset_mono hsubsetCE in_Vset_rank)
lemma Vset_succ_rank_le: "Ord k \<Longrightarrow> a \<^bold>\<in> Vset (succ k) \<Longrightarrow> rank a \<le> k"
by (unfold rank_def) (rule OrdLeast_le)
lemma Vset_rank_lt: assumes a: "a \<^bold>\<in> Vset k" shows "rank a < k"
proof -
{ assume k: "Ord k"
hence ?thesis
proof (cases k rule: Ord_cases)
case 0 thus ?thesis using a
by simp
next
case (succ l) thus ?thesis using a
by (metis Ord_lt_succ_iff_le Ord_succ_iff Vset_non Vset_succ_rank_le hemptyE in_Vset_rank)
qed
}
thus ?thesis using a
by (metis Vset_non hemptyE)
qed
text{*Theorem 4.5*}
theorem rank_lt: "a \<^bold>\<in> b \<Longrightarrow> rank(a) < rank(b)"
by (metis Vset_rank_lt hsubsetD le_Vset_rank)
lemma rank_mono: "x \<le> y \<Longrightarrow> rank x \<le> rank y"
by (metis HPow_iff Ord_rank Vset_succ Vset_succ_rank_le dual_order.trans le_Vset_rank)
lemma rank_sup [simp]: "rank (a \<squnion> b) = rank a \<squnion> rank b"
proof (rule antisym)
have o: "Ord (rank a \<squnion> rank b)"
by simp
thus "rank (a \<squnion> b) \<le> rank a \<squnion> rank b"
apply (rule Vset_succ_rank_le, simp)
apply (metis le_Vset_rank order_trans Vset_mono sup_ge1 sup_ge2 o)
done
next
show "rank a \<squnion> rank b \<le> rank (a \<squnion> b)"
by (metis le_supI le_supI1 le_supI2 order_eq_refl rank_mono)
qed
lemma rank_singleton [simp]: "rank \<lbrace>a\<rbrace> = succ(rank a)"
proof -
have oba: "Ord (succ (rank a))"
by simp
show ?thesis
proof (rule antisym)
show "rank \<lbrace>a\<rbrace> \<le> succ (rank a)"
by (metis Vset_succ_rank_le HPow_iff Vset_succ in_Vset_rank less_eq_insert1_iff oba zero_le)
next
show "succ (rank a) \<le> rank\<lbrace>a\<rbrace>"
by (metis Ord_linear_le Ord_lt_succ_iff_le rank_lt Ord_rank hmem_hinsert less_le_not_le oba)
qed
qed
lemma rank_hinsert [simp]: "rank (b \<triangleleft> a) = rank b \<squnion> succ(rank a)"
by (metis hinsert_eq_sup rank_singleton rank_sup)
text{*Definition 4.6. The transitive closure of @{term x} is
the minimal transitive set @{term y} such that @{term"x\<le>y"}.*}
section{*Epsilon Closure*}
definition
eclose :: "hf \<Rightarrow> hf" where
"eclose X = \<Sqinter> \<lbrace>Y \<^bold>\<in> HPow(Vset (rank X)). Transset Y & X\<le>Y\<rbrace>"
lemma eclose_facts:
shows Transset_eclose: "Transset (eclose X)"
and le_eclose: "X \<le> eclose X"
proof -
have nz: "\<lbrace>Y \<^bold>\<in> HPow(Vset (rank X)). Transset Y & X\<le>Y\<rbrace> \<noteq> 0"
by (simp add: eclose_def hempty_iff) (metis Ord_rank Vset_Transset le_Vset_rank order_refl)
show "Transset (eclose X)" "X \<le> eclose X" using HInter_iff [OF nz]
by (auto simp: eclose_def Transset_def)
qed
lemma eclose_minimal:
assumes Y: "Transset Y" "X\<le>Y" shows "eclose X \<le> Y"
proof -
have "\<lbrace>Y \<^bold>\<in> HPow(Vset (rank X)). Transset Y & X\<le>Y\<rbrace> \<noteq> 0"
by (simp add: eclose_def hempty_iff) (metis Ord_rank Vset_Transset le_Vset_rank order_refl)
moreover have "Transset (Y \<sqinter> Vset (rank X))"
by (metis Ord_rank Transset_inf Vset_Transset Y(1))
moreover have "X \<le> Y \<sqinter> Vset (rank X)"
by (metis Y(2) le_Vset_rank le_inf_iff)
ultimately show "eclose X \<le> Y"
apply (auto simp: eclose_def)
apply (metis hinter_iff le_inf_iff order_refl)
done
qed
lemma eclose_0 [simp]: "eclose 0 = 0"
by (metis Ord_0 Vset_0 Vset_Transset eclose_minimal less_eq_hempty)
lemma eclose_sup [simp]: "eclose (a \<squnion> b) = eclose a \<squnion> eclose b"
proof (rule order_antisym)
show "eclose (a \<squnion> b) \<le> eclose a \<squnion> eclose b"
by (metis Transset_eclose Transset_sup eclose_minimal le_eclose sup_mono)
next
show "eclose a \<squnion> eclose b \<le> eclose (a \<squnion> b)"
by (metis Transset_eclose eclose_minimal le_eclose le_sup_iff)
qed
lemma eclose_singleton [simp]: "eclose \<lbrace>a\<rbrace> = (eclose a) \<triangleleft> a"
proof (rule order_antisym)
show "eclose \<lbrace>a\<rbrace> \<le> eclose a \<triangleleft> a"
by (metis eclose_minimal Transset_eclose Transset_hinsert
le_eclose less_eq_insert1_iff order_refl zero_le)
next
show "eclose a \<triangleleft> a \<le> eclose \<lbrace>a\<rbrace>"
by (metis Transset_def Transset_eclose eclose_minimal le_eclose less_eq_insert1_iff)
qed
lemma eclose_hinsert [simp]: "eclose (b \<triangleleft> a) = eclose b \<squnion> (eclose a \<triangleleft> a)"
by (metis eclose_singleton eclose_sup hinsert_eq_sup)
lemma eclose_succ [simp]: "eclose (succ a) = eclose a \<triangleleft> a"
by (auto simp: succ_def)
lemma fst_in_eclose [simp]: "x \<^bold>\<in> eclose \<langle>x, y\<rangle>"
by (metis eclose_hinsert hmem_hinsert hpair_def hunion_iff)
lemma snd_in_eclose [simp]: "y \<^bold>\<in> eclose \<langle>x, y\<rangle>"
by (metis eclose_hinsert hmem_hinsert hpair_def hunion_iff)
text{*Theorem 4.7. rank(x) = rank(cl(x)).*}
lemma rank_eclose [simp]: "rank (eclose x) = rank x"
proof (induct x rule: hf_induct)
case 0 thus ?case by simp
next
case (hinsert a b) thus ?case
by simp (metis hinsert_eq_sup succ_def sup.left_idem)
qed
section{*Epsilon-Recursion*}
text{*Theorem 4.9. Definition of a function by recursion on rank.*}
lemma hmem_induct [case_names step]:
assumes ih: "\<And>x. (\<And>y. y \<^bold>\<in> x \<Longrightarrow> P y) \<Longrightarrow> P x" shows "P x"
proof -
have "\<And>y. y \<^bold>\<in> x \<Longrightarrow> P y"
proof (induct x rule: hf_induct)
case 0 thus ?case by simp
next
case (hinsert a b) thus ?case
by (metis assms hmem_hinsert)
qed
thus ?thesis by (metis ih)
qed
definition
hmem_rel :: "(hf * hf) set" where
"hmem_rel = trancl {(x,y). x <: y}"
lemma wf_hmem_rel: "wf hmem_rel"
proof -
have "wf {(x,y). x <: y}"
by (metis (full_types) hmem_induct wfPUNIVI wfP_def)
thus ?thesis
by (metis hmem_rel_def wf_trancl)
qed
lemma hmem_eclose_le: "y \<^bold>\<in> x \<Longrightarrow> eclose y \<le> eclose x"
by (metis Transset_def Transset_eclose eclose_minimal hsubsetD le_eclose)
lemma hmem_rel_iff_hmem_eclose: "(x,y) \<in> hmem_rel \<longleftrightarrow> x <: eclose y"
proof (unfold hmem_rel_def, rule iffI)
assume "(x, y) \<in> trancl {(x, y). x \<^bold>\<in> y}"
thus "x \<^bold>\<in> eclose y"
proof (induct rule: trancl_induct)
case (base y) thus ?case
by (metis hsubsetCE le_eclose mem_Collect_eq split_conv)
next
case (step y z) thus ?case
by (metis hmem_eclose_le hsubsetD mem_Collect_eq split_conv)
qed
next
have "Transset \<lbrace>x \<^bold>\<in> eclose y. (x, y) \<in> hmem_rel\<rbrace>" using Transset_eclose
by (auto simp: Transset_def hmem_rel_def intro: trancl_trans)
hence "eclose y \<le> \<lbrace>x \<^bold>\<in> eclose y. (x, y) \<in> hmem_rel\<rbrace>"
by (rule eclose_minimal) (auto simp: le_HCollect_iff le_eclose hmem_rel_def)
moreover assume "x \<^bold>\<in> eclose y"
ultimately show "(x, y) \<in> trancl {(x, y). x \<^bold>\<in> y}"
by (metis HCollect_iff hmem_rel_def hsubsetD)
qed
definition hmemrec :: "((hf \<Rightarrow> 'a) \<Rightarrow> hf \<Rightarrow> 'a) \<Rightarrow> hf \<Rightarrow> 'a" where
"hmemrec G \<equiv> wfrec hmem_rel G"
definition ecut :: "(hf \<Rightarrow> 'a) \<Rightarrow> hf \<Rightarrow> hf \<Rightarrow> 'a" where
"ecut f x \<equiv> (\<lambda>y. if y \<^bold>\<in> eclose x then f y else undefined)"
lemma hmemrec: "hmemrec G a = G (ecut (hmemrec G) a) a"
by (simp add: cut_def ecut_def hmem_rel_iff_hmem_eclose def_wfrec [OF hmemrec_def wf_hmem_rel])
text{*This form avoids giant explosions in proofs.*}
lemma def_hmemrec: "f \<equiv> hmemrec G \<Longrightarrow> f a = G (ecut (hmemrec G) a) a"
by (metis hmemrec)
lemma ecut_apply: "y \<^bold>\<in> eclose x \<Longrightarrow> ecut f x y = f y"
by (metis ecut_def)
lemma RepFun_ecut: "y \<le> z \<Longrightarrow> RepFun y (ecut f z) = RepFun y f"
apply (auto simp: hf_ext)
apply (metis ecut_def hsubsetD le_eclose)
apply (metis ecut_apply le_eclose hsubsetD)
done
text{*Now, a stronger induction rule, for the transitive closure of membership*}
lemma hmem_rel_induct [case_names step]:
assumes ih: "\<And>x. (\<And>y. (y,x) \<in> hmem_rel \<Longrightarrow> P y) \<Longrightarrow> P x" shows "P x"
proof -
have "\<And>y. (y,x) \<in> hmem_rel \<Longrightarrow> P y"
proof (induct x rule: hf_induct)
case 0 thus ?case
by (metis eclose_0 hmem_hempty hmem_rel_iff_hmem_eclose)
next
case (hinsert a b)
thus ?case
by (metis assms eclose_hinsert hmem_hinsert hmem_rel_iff_hmem_eclose hunion_iff)
qed
thus ?thesis by (metis assms)
qed
lemma rank_HUnion_less: "x \<noteq> 0 \<Longrightarrow> rank (\<Squnion>x) < rank x"
apply (induct x rule: hf_induct, auto)
apply (metis hmem_hinsert rank_hinsert rank_lt)
apply (metis HUnion_hempty Ord_lt_succ_iff_le Ord_rank hunion_hempty_right
less_supI1 less_supI2 rank_sup sup.cobounded2)
done
corollary Sup_ne: "x \<noteq> 0 \<Longrightarrow> \<Squnion>x \<noteq> x"
by (metis less_irrefl rank_HUnion_less)
end
|
Formal statement is: lemma cis_inverse [simp]: "inverse (cis a) = cis (- a)" Informal statement is: The inverse of $e^{ia}$ is $e^{-ia}$. |
[STATEMENT]
lemma strip_all_body_unchanged_iff_strip_all_single_body_unchanged:
"strip_all_body B = B \<longleftrightarrow> strip_all_single_body B = B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (strip_all_body B = B) = (strip_all_single_body B = B)
[PROOF STEP]
by (metis not_Cons_self2 not_None_eq not_is_all_imp_strip_all_body_unchanged
strip_all_body_single_simp' strip_all_single_var_is_all strip_all_vars_step) |
module Statistics.GModeling.Models.LDA
(
) where
import Statistics.GModeling.DSL
data LDALabels = Alpha | Beta | Topics | Topic
| Doc | Symbols | Symbol
lda :: Network LDALabels
lda =
[
Only Alpha :-> Topics
, Only Beta :-> Symbols
, (Topics :@ Doc) :-> Topic
, (Symbols :@ Topic) :-> Symbol
]
|
(*<*)
theory Syntax
imports "Nominal2.Nominal2" "Nominal-Utils"
begin
(*>*)
chapter \<open>Syntax\<close>
text \<open>Syntax of MiniSail programs and the contexts we use in judgements.\<close>
section \<open>Program Syntax\<close>
subsection \<open>AST Datatypes\<close>
type_synonym num_nat = nat
atom_decl x (* Immutable variables*)
atom_decl u (* Mutable variables *)
atom_decl bv (* Basic-type variables *)
type_synonym f = string (* Function name *)
type_synonym dc = string (* Data constructor *)
type_synonym tyid = string
text \<open>Basic types. Types without refinement constraints\<close>
nominal_datatype "b" =
B_int | B_bool | B_id tyid
| B_pair b b ("[ _ , _ ]\<^sup>b")
| B_unit | B_bitvec | B_var bv
| B_app tyid b
nominal_datatype bit = BitOne | BitZero
text \<open> Literals \<close>
nominal_datatype "l" =
L_num "int" | L_true | L_false | L_unit | L_bitvec "bit list"
text \<open> Values. We include a type identifier, tyid, in the literal for constructors
to make typing and well-formedness checking easier \<close>
nominal_datatype "v" =
V_lit "l" ( "[ _ ]\<^sup>v")
| V_var "x" ( "[ _ ]\<^sup>v")
| V_pair "v" "v" ( "[ _ , _ ]\<^sup>v")
| V_cons tyid dc "v"
| V_consp tyid dc b "v"
text \<open> Binary Operations \<close>
nominal_datatype "opp" = Plus ( "plus") | LEq ("leq") | Eq ("eq")
text \<open> Expressions \<close>
nominal_datatype "e" =
AE_val "v" ( "[ _ ]\<^sup>e" )
| AE_app "f" "v" ( "[ _ ( _ ) ]\<^sup>e" )
| AE_appP "f" "b" "v" ( "[_ [ _ ] ( _ )]\<^sup>e" )
| AE_op "opp" "v" "v" ( "[ _ _ _ ]\<^sup>e" )
| AE_concat v v ( "[ _ @@ _ ]\<^sup>e" )
| AE_fst "v" ( "[#1_ ]\<^sup>e" )
| AE_snd "v" ( "[#2_ ]\<^sup>e" )
| AE_mvar "u" ( "[ _ ]\<^sup>e" )
| AE_len "v" ( "[| _ |]\<^sup>e" )
| AE_split "v" "v" ( "[ _ / _ ]\<^sup>e" )
text \<open> Expressions for constraints\<close>
nominal_datatype "ce" =
CE_val "v" ( "[ _ ]\<^sup>c\<^sup>e" )
| CE_op "opp" "ce" "ce" ( "[ _ _ _ ]\<^sup>c\<^sup>e" )
| CE_concat ce ce ( "[ _ @@ _ ]\<^sup>c\<^sup>e" )
| CE_fst "ce" ( "[#1_]\<^sup>c\<^sup>e" )
| CE_snd "ce" ( "[#2_]\<^sup>c\<^sup>e" )
| CE_len "ce" ( "[| _ |]\<^sup>c\<^sup>e" )
text \<open> Constraints \<close>
nominal_datatype "c" =
C_true ( "TRUE" [] 50 )
| C_false ( "FALSE" [] 50 )
| C_conj "c" "c" ("_ AND _ " [50, 50] 50)
| C_disj "c" "c" ("_ OR _ " [50,50] 50)
| C_not "c" ( "\<not> _ " [] 50 )
| C_imp "c" "c" ("_ IMP _ " [50, 50] 50)
| C_eq "ce" "ce" ("_ == _ " [50, 50] 50)
text \<open> Refined types \<close>
nominal_datatype "\<tau>" =
T_refined_type x::x b c::c binds x in c ("\<lbrace> _ : _ | _ \<rbrace>" [50, 50] 1000)
text \<open> Statements \<close>
nominal_datatype
s =
AS_val v ( "[_]\<^sup>s")
| AS_let x::x e s::s binds x in s ( "(LET _ = _ IN _)")
| AS_let2 x::x \<tau> s s::s binds x in s ( "(LET _ : _ = _ IN _)")
| AS_if v s s ( "(IF _ THEN _ ELSE _)" [0, 61, 0] 61)
| AS_var u::u \<tau> v s::s binds u in s ( "(VAR _ : _ = _ IN _)")
| AS_assign u v ( "(_ ::= _)")
| AS_match v branch_list ( "(MATCH _ WITH { _ })")
| AS_while s s ( "(WHILE _ DO { _ } )" [0, 0] 61)
| AS_seq s s ( "( _ ;; _ )" [1000, 61] 61)
| AS_assert c s ( "(ASSERT _ IN _ )" )
and branch_s =
AS_branch dc x::x s::s binds x in s ( "( _ _ \<Rightarrow> _ )")
and branch_list =
AS_final branch_s ( "{ _ }" )
| AS_cons branch_s branch_list ( "( _ | _ )")
text \<open> Function and union type definitions \<close>
nominal_datatype "fun_typ" =
AF_fun_typ x::x "b" c::c \<tau>::\<tau> s::s binds x in c \<tau> s
nominal_datatype "fun_typ_q" =
AF_fun_typ_some bv::bv ft::fun_typ binds bv in ft
| AF_fun_typ_none fun_typ
nominal_datatype "fun_def" = AF_fundef f fun_typ_q
nominal_datatype "type_def" =
AF_typedef string "(string * \<tau>) list"
| AF_typedef_poly string bv::bv dclist::"(string * \<tau>) list" binds bv in dclist
lemma check_typedef_poly:
"AF_typedef_poly ''option'' bv [ (''None'', \<lbrace> zz : B_unit | TRUE \<rbrace>), (''Some'', \<lbrace> zz : B_var bv | TRUE \<rbrace>) ] =
AF_typedef_poly ''option'' bv2 [ (''None'', \<lbrace> zz : B_unit | TRUE \<rbrace>), (''Some'', \<lbrace> zz : B_var bv2 | TRUE \<rbrace>) ]"
by auto
nominal_datatype "var_def" = AV_def u \<tau> v
text \<open> Programs \<close>
nominal_datatype "p" =
AP_prog "type_def list" "fun_def list" "var_def list" "s" ("PROG _ _ _ _")
declare l.supp [simp] v.supp [simp] e.supp [simp] s_branch_s_branch_list.supp [simp] \<tau>.supp [simp] c.supp [simp] b.supp[simp]
subsection \<open>Lemmas\<close>
text \<open>These lemmas deal primarily with freshness and alpha-equivalence\<close>
subsubsection \<open>Atoms\<close>
lemma x_not_in_u_atoms[simp]:
fixes u::u and x::x and us::"u set"
shows "atom x \<notin> atom`us"
by (simp add: image_iff)
lemma x_fresh_u[simp]:
fixes u::u and x::x
shows "atom x \<sharp> u"
by auto
lemma x_not_in_b_set[simp]:
fixes x::x and bs::"bv fset"
shows "atom x \<notin> supp bs"
by(induct bs,auto, simp add: supp_finsert supp_at_base)
lemma x_fresh_b[simp]:
fixes x::x and b::b
shows "atom x \<sharp> b"
apply (induct b rule: b.induct, auto simp: pure_supp)
using pure_supp fresh_def by blast+
lemma x_fresh_bv[simp]:
fixes x::x and bv::bv
shows "atom x \<sharp> bv"
using fresh_def supp_at_base by auto
lemma u_not_in_x_atoms[simp]:
fixes u::u and x::x and xs::"x set"
shows "atom u \<notin> atom`xs"
by (simp add: image_iff)
lemma bv_not_in_x_atoms[simp]:
fixes bv::bv and x::x and xs::"x set"
shows "atom bv \<notin> atom`xs"
by (simp add: image_iff)
lemma u_not_in_b_atoms[simp]:
fixes b :: b and u::u
shows "atom u \<notin> supp b"
by (induct b rule: b.induct,auto simp: pure_supp supp_at_base)
lemma u_not_in_b_set[simp]:
fixes u::u and bs::"bv fset"
shows "atom u \<notin> supp bs"
by(induct bs, auto simp add: supp_at_base supp_finsert)
lemma u_fresh_b[simp]:
fixes x::u and b::b
shows "atom x \<sharp> b"
by(induct b rule: b.induct, auto simp: pure_fresh )
lemma supp_b_v_disjoint:
fixes x::x and bv::bv
shows "supp (V_var x) \<inter> supp (B_var bv) = {}"
by (simp add: supp_at_base)
lemma supp_b_u_disjoint[simp]:
fixes b::b and u::u
shows "supp u \<inter> supp b = {}"
by(nominal_induct b rule:b.strong_induct,(auto simp add: pure_supp b.supp supp_at_base)+)
lemma u_fresh_bv[simp]:
fixes u::u and b::bv
shows "atom u \<sharp> b"
using fresh_at_base by simp
subsubsection \<open>Basic Types\<close>
nominal_function b_of :: "\<tau> \<Rightarrow> b" where
"b_of \<lbrace> z : b | c \<rbrace> = b"
apply(auto,simp add: eqvt_def b_of_graph_aux_def )
by (meson \<tau>.exhaust)
nominal_termination (eqvt) by lexicographic_order
lemma supp_b_empty[simp]:
fixes b :: b and x::x
shows "atom x \<notin> supp b"
by (induct b rule: b.induct, auto simp: pure_supp supp_at_base x_not_in_b_set)
lemma flip_b_id[simp]:
fixes x::x and b::b
shows "(x \<leftrightarrow> x') \<bullet> b = b"
by(rule flip_fresh_fresh, auto simp add: fresh_def)
lemma flip_x_b_cancel[simp]:
fixes x::x and y::x and b::b and bv::bv
shows "(x \<leftrightarrow> y) \<bullet> b = b" and "(x \<leftrightarrow> y) \<bullet> bv = bv"
using flip_b_id apply simp
by (metis b.eq_iff(7) b.perm_simps(7) flip_b_id)
lemma flip_bv_x_cancel[simp]:
fixes bv::bv and z::bv and x::x
shows "(bv \<leftrightarrow> z) \<bullet> x = x" using flip_fresh_fresh[of bv x z] fresh_at_base by auto
lemma flip_bv_u_cancel[simp]:
fixes bv::bv and z::bv and x::u
shows "(bv \<leftrightarrow> z) \<bullet> x = x" using flip_fresh_fresh[of bv x z] fresh_at_base by auto
subsubsection \<open>Literals\<close>
lemma supp_bitvec_empty:
fixes bv::"bit list"
shows "supp bv = {}"
proof(induct bv)
case Nil
then show ?case using supp_Nil by auto
next
case (Cons a bv)
then show ?case using supp_Cons bit.supp
by (metis (mono_tags, opaque_lifting) bit.strong_exhaust l.supp(5) sup_bot.right_neutral)
qed
lemma bitvec_pure[simp]:
fixes bv::"bit list" and x::x
shows "atom x \<sharp> bv" using fresh_def supp_bitvec_empty by auto
lemma supp_l_empty[simp]:
fixes l:: l
shows "supp (V_lit l) = {}"
by(nominal_induct l rule: l.strong_induct,
auto simp add: l.strong_exhaust pure_supp v.fv_defs supp_bitvec_empty)
lemma type_l_nosupp[simp]:
fixes x::x and l::l
shows "atom x \<notin> supp (\<lbrace> z : b | [[z]\<^sup>v]\<^sup>c\<^sup>e == [[l]\<^sup>v]\<^sup>c\<^sup>e \<rbrace>)"
using supp_at_base supp_l_empty ce.supp(1) c.supp \<tau>.supp by force
lemma flip_bitvec0:
fixes x::"bit list"
assumes "atom c \<sharp> (z, x, z')"
shows "(z \<leftrightarrow> c) \<bullet> x = (z' \<leftrightarrow> c) \<bullet> x"
proof -
have "atom z \<sharp> x" and "atom z' \<sharp> x"
using flip_fresh_fresh assms supp_bitvec_empty fresh_def by blast+
moreover have "atom c \<sharp> x" using supp_bitvec_empty fresh_def by auto
ultimately show ?thesis using assms flip_fresh_fresh by metis
qed
lemma flip_bitvec:
assumes "atom c \<sharp> (z, L_bitvec x, z')"
shows "(z \<leftrightarrow> c) \<bullet> x = (z' \<leftrightarrow> c) \<bullet> x"
proof -
have "atom z \<sharp> x" and "atom z' \<sharp> x"
using flip_fresh_fresh assms supp_bitvec_empty fresh_def by blast+
moreover have "atom c \<sharp> x" using supp_bitvec_empty fresh_def by auto
ultimately show ?thesis using assms flip_fresh_fresh by metis
qed
lemma type_l_eq:
shows "\<lbrace> z : b | [[z]\<^sup>v]\<^sup>c\<^sup>e == [V_lit l]\<^sup>c\<^sup>e \<rbrace> = (\<lbrace> z' : b | [[z']\<^sup>v]\<^sup>c\<^sup>e == [V_lit l]\<^sup>c\<^sup>e \<rbrace>)"
by(auto,nominal_induct l rule: l.strong_induct,auto, metis permute_pure, auto simp add: flip_bitvec)
lemma flip_l_eq:
fixes x::l
shows "(z \<leftrightarrow> c) \<bullet> x = (z' \<leftrightarrow> c) \<bullet> x"
proof -
have "atom z \<sharp> x" and "atom c \<sharp> x" and "atom z' \<sharp> x"
using flip_fresh_fresh fresh_def supp_l_empty by fastforce+
thus ?thesis using flip_fresh_fresh by metis
qed
lemma flip_l_eq1:
fixes x::l
assumes "(z \<leftrightarrow> c) \<bullet> x = (z' \<leftrightarrow> c) \<bullet> x'"
shows "x' = x"
proof -
have "atom z \<sharp> x" and "atom c \<sharp> x'" and "atom c \<sharp> x" and "atom z' \<sharp> x'"
using flip_fresh_fresh fresh_def supp_l_empty by fastforce+
thus ?thesis using flip_fresh_fresh assms by metis
qed
subsubsection \<open>Types\<close>
lemma flip_base_eq:
fixes b::b and x::x and y::x
shows "(x \<leftrightarrow> y) \<bullet> b = b"
using b.fresh by (simp add: flip_fresh_fresh fresh_def)
text \<open> Obtain an alpha-equivalent type where the bound variable is fresh in some term t \<close>
lemma has_fresh_z0:
fixes t::"'b::fs"
shows "\<exists>z. atom z \<sharp> (c',t) \<and> (\<lbrace>z' : b | c' \<rbrace>) = (\<lbrace> z : b | (z \<leftrightarrow> z' ) \<bullet> c' \<rbrace>)"
proof -
obtain z::x where fr: "atom z \<sharp> (c',t)" using obtain_fresh by blast
moreover hence "(\<lbrace> z' : b | c' \<rbrace>) = (\<lbrace> z : b | (z \<leftrightarrow> z') \<bullet> c' \<rbrace>)"
using \<tau>.eq_iff Abs1_eq_iff
by (metis flip_commute flip_fresh_fresh fresh_PairD(1))
ultimately show ?thesis by fastforce
qed
lemma has_fresh_z:
fixes t::"'b::fs"
shows "\<exists>z b c. atom z \<sharp> t \<and> \<tau> = \<lbrace> z : b | c \<rbrace>"
proof -
obtain z' and b and c' where teq: "\<tau> = (\<lbrace> z' : b | c' \<rbrace>)" using \<tau>.exhaust by blast
obtain z::x where fr: "atom z \<sharp> (t,c')" using obtain_fresh by blast
hence "(\<lbrace> z' : b | c' \<rbrace>) = (\<lbrace> z : b | (z \<leftrightarrow> z') \<bullet> c' \<rbrace>)" using \<tau>.eq_iff Abs1_eq_iff
flip_commute flip_fresh_fresh fresh_PairD(1) by (metis fresh_PairD(2))
hence "atom z \<sharp> t \<and> \<tau> = (\<lbrace> z : b | (z \<leftrightarrow> z') \<bullet> c' \<rbrace>)" using fr teq by force
thus ?thesis using teq fr by fast
qed
lemma obtain_fresh_z:
fixes t::"'b::fs"
obtains z and b and c where "atom z \<sharp> t \<and> \<tau> = \<lbrace> z : b | c \<rbrace>"
using has_fresh_z by blast
lemma has_fresh_z2:
fixes t::"'b::fs"
shows "\<exists>z c. atom z \<sharp> t \<and> \<tau> = \<lbrace> z : b_of \<tau> | c \<rbrace>"
proof -
obtain z and b and c where "atom z \<sharp> t \<and> \<tau> = \<lbrace> z : b | c \<rbrace>" using obtain_fresh_z by metis
moreover then have "b_of \<tau> = b" using \<tau>.eq_iff by simp
ultimately show ?thesis using obtain_fresh_z \<tau>.eq_iff by auto
qed
lemma obtain_fresh_z2:
fixes t::"'b::fs"
obtains z and c where "atom z \<sharp> t \<and> \<tau> = \<lbrace> z : b_of \<tau> | c \<rbrace>"
using has_fresh_z2 by blast
subsubsection \<open>Values\<close>
lemma u_notin_supp_v[simp]:
fixes u::u and v::v
shows "atom u \<notin> supp v"
proof(nominal_induct v rule: v.strong_induct)
case (V_lit l)
then show ?case using supp_l_empty by auto
next
case (V_var x)
then show ?case
by (simp add: supp_at_base)
next
case (V_pair v1 v2)
then show ?case by auto
next
case (V_cons tyid list v)
then show ?case using pure_supp by auto
next
case (V_consp tyid list b v)
then show ?case using pure_supp by auto
qed
lemma u_fresh_xv[simp]:
fixes u::u and x::x and v::v
shows "atom u \<sharp> (x,v)"
proof -
have "atom u \<sharp> x" using fresh_def by fastforce
moreover have "atom u \<sharp> v" using fresh_def u_notin_supp_v by metis
ultimately show ?thesis using fresh_prod2 by auto
qed
text \<open> Part of an effort to make the proofs across inductive cases more uniform by distilling
the non-uniform parts into lemmas like this\<close>
lemma v_flip_eq:
fixes v::v and va::v and x::x and c::x
assumes "atom c \<sharp> (v, va)" and "atom c \<sharp> (x, xa, v, va)" and "(x \<leftrightarrow> c) \<bullet> v = (xa \<leftrightarrow> c) \<bullet> va"
shows "((v = V_lit l \<longrightarrow> (\<exists>l'. va = V_lit l' \<and> (x \<leftrightarrow> c) \<bullet> l = (xa \<leftrightarrow> c) \<bullet> l'))) \<and>
((v = V_var y \<longrightarrow> (\<exists>y'. va = V_var y' \<and> (x \<leftrightarrow> c) \<bullet> y = (xa \<leftrightarrow> c) \<bullet> y'))) \<and>
((v = V_pair vone vtwo \<longrightarrow> (\<exists>v1' v2'. va = V_pair v1' v2' \<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1' \<and> (x \<leftrightarrow> c) \<bullet> vtwo = (xa \<leftrightarrow> c) \<bullet> v2'))) \<and>
((v = V_cons tyid dc vone \<longrightarrow> (\<exists>v1'. va = V_cons tyid dc v1'\<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1'))) \<and>
((v = V_consp tyid dc b vone \<longrightarrow> (\<exists>v1'. va = V_consp tyid dc b v1'\<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1')))"
using assms proof(nominal_induct v rule:v.strong_induct)
case (V_lit l)
then show ?case using assms v.perm_simps
empty_iff flip_def fresh_def fresh_permute_iff supp_l_empty swap_fresh_fresh v.fresh
by (metis permute_swap_cancel2 v.distinct)
next
case (V_var x)
then show ?case using assms v.perm_simps
empty_iff flip_def fresh_def fresh_permute_iff supp_l_empty swap_fresh_fresh v.fresh
by (metis permute_swap_cancel2 v.distinct)
next
case (V_pair v1 v2)
have " (V_pair v1 v2 = V_pair vone vtwo \<longrightarrow> (\<exists>v1' v2'. va = V_pair v1' v2' \<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1' \<and> (x \<leftrightarrow> c) \<bullet> vtwo = (xa \<leftrightarrow> c) \<bullet> v2'))" proof
assume "V_pair v1 v2= V_pair vone vtwo"
thus "(\<exists>v1' v2'. va = V_pair v1' v2' \<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1' \<and> (x \<leftrightarrow> c) \<bullet> vtwo = (xa \<leftrightarrow> c) \<bullet> v2')"
using V_pair assms
by (metis (no_types, opaque_lifting) flip_def permute_swap_cancel v.perm_simps(3))
qed
thus ?case using V_pair by auto
next
case (V_cons tyid dc v1)
have " (V_cons tyid dc v1 = V_cons tyid dc vone \<longrightarrow> (\<exists> v1'. va = V_cons tyid dc v1' \<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1'))" proof
assume as: "V_cons tyid dc v1 = V_cons tyid dc vone"
hence "(x \<leftrightarrow> c) \<bullet> (V_cons tyid dc vone) = V_cons tyid dc ((x \<leftrightarrow> c) \<bullet> vone)" proof -
have "(x \<leftrightarrow> c) \<bullet> dc = dc" using pure_permute_id by metis
moreover have "(x \<leftrightarrow> c) \<bullet> tyid = tyid" using pure_permute_id by metis
ultimately show ?thesis using v.perm_simps(4) by simp
qed
then obtain v1' where "(xa \<leftrightarrow> c) \<bullet> va = V_cons tyid dc v1' \<and> (x \<leftrightarrow> c) \<bullet> vone = v1'" using assms V_cons
using as by fastforce
hence " va = V_cons tyid dc ((xa \<leftrightarrow> c) \<bullet> v1') \<and> (x \<leftrightarrow> c) \<bullet> vone = v1'" using permute_flip_cancel empty_iff flip_def fresh_def supp_b_empty swap_fresh_fresh
by (metis pure_fresh v.perm_simps(4))
thus "(\<exists>v1'. va = V_cons tyid dc v1' \<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1')"
using V_cons assms by simp
qed
thus ?case using V_cons by auto
next
case (V_consp tyid dc b v1)
have " (V_consp tyid dc b v1 = V_consp tyid dc b vone \<longrightarrow> (\<exists> v1'. va = V_consp tyid dc b v1' \<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1'))" proof
assume as: "V_consp tyid dc b v1 = V_consp tyid dc b vone"
hence "(x \<leftrightarrow> c) \<bullet> (V_consp tyid dc b vone) = V_consp tyid dc b ((x \<leftrightarrow> c) \<bullet> vone)" proof -
have "(x \<leftrightarrow> c) \<bullet> dc = dc" using pure_permute_id by metis
moreover have "(x \<leftrightarrow> c) \<bullet> tyid = tyid" using pure_permute_id by metis
ultimately show ?thesis using v.perm_simps(4) by simp
qed
then obtain v1' where "(xa \<leftrightarrow> c) \<bullet> va = V_consp tyid dc b v1' \<and> (x \<leftrightarrow> c) \<bullet> vone = v1'" using assms V_consp
using as by fastforce
hence " va = V_consp tyid dc b ((xa \<leftrightarrow> c) \<bullet> v1') \<and> (x \<leftrightarrow> c) \<bullet> vone = v1'" using permute_flip_cancel empty_iff flip_def fresh_def supp_b_empty swap_fresh_fresh
pure_fresh v.perm_simps
by (metis (mono_tags, opaque_lifting))
thus "(\<exists>v1'. va = V_consp tyid dc b v1' \<and> (x \<leftrightarrow> c) \<bullet> vone = (xa \<leftrightarrow> c) \<bullet> v1')"
using V_consp assms by simp
qed
thus ?case using V_consp by auto
qed
lemma flip_eq:
fixes x::x and xa::x and s::"'a::fs" and sa::"'a::fs"
assumes "(\<forall>c. atom c \<sharp> (s, sa) \<longrightarrow> atom c \<sharp> (x, xa, s, sa) \<longrightarrow> (x \<leftrightarrow> c) \<bullet> s = (xa \<leftrightarrow> c) \<bullet> sa)" and "x \<noteq> xa"
shows "(x \<leftrightarrow> xa) \<bullet> s = sa"
proof -
have " ([[atom x]]lst. s = [[atom xa]]lst. sa)" using assms Abs1_eq_iff_all by simp
hence "(xa = x \<and> sa = s \<or> xa \<noteq> x \<and> sa = (xa \<leftrightarrow> x) \<bullet> s \<and> atom xa \<sharp> s)" using assms Abs1_eq_iff[of xa sa x s] by simp
thus ?thesis using assms
by (metis flip_commute)
qed
lemma swap_v_supp:
fixes v::v and d::x and z::x
assumes "atom d \<sharp> v"
shows "supp ((z \<leftrightarrow> d ) \<bullet> v) \<subseteq> supp v - { atom z } \<union> { atom d}"
using assms
proof(nominal_induct v rule:v.strong_induct)
case (V_lit l)
then show ?case using l.supp by (metis supp_l_empty empty_subsetI l.strong_exhaust pure_supp supp_eqvt v.supp)
next
case (V_var x)
hence "d \<noteq> x" using fresh_def by fastforce
thus ?case apply(cases "z = x") using supp_at_base V_var \<open>d\<noteq>x\<close> by fastforce+
next
case (V_cons tyid dc v)
show ?case using v.supp(4) pure_supp
using V_cons.hyps V_cons.prems fresh_def by auto
next
case (V_consp tyid dc b v)
show ?case using v.supp(4) pure_supp
using V_consp.hyps V_consp.prems fresh_def by auto
qed(force+)
subsubsection \<open>Expressions\<close>
lemma swap_e_supp:
fixes e::e and d::x and z::x
assumes "atom d \<sharp> e"
shows "supp ((z \<leftrightarrow> d ) \<bullet> e) \<subseteq> supp e - { atom z } \<union> { atom d}"
using assms
proof(nominal_induct e rule:e.strong_induct)
case (AE_val v)
then show ?case using swap_v_supp by simp
next
case (AE_app f v)
then show ?case using swap_v_supp by (simp add: pure_supp)
next
case (AE_appP b f v)
hence df: "atom d \<sharp> v" using fresh_def e.supp by force
have "supp ((z \<leftrightarrow> d ) \<bullet> (AE_appP b f v)) = supp (AE_appP b f ((z \<leftrightarrow> d ) \<bullet> v))" using e.supp
by (metis b.eq_iff(3) b.perm_simps(3) e.perm_simps(3) flip_b_id)
also have "... = supp b \<union> supp f \<union> supp ((z \<leftrightarrow> d ) \<bullet> v)" using e.supp by auto
also have "... \<subseteq> supp b \<union> supp f \<union> supp v - { atom z } \<union> { atom d}" using swap_v_supp[OF df] pure_supp by auto
finally show ?case using e.supp by auto
next
case (AE_op opp v1 v2)
hence df: "atom d \<sharp> v1 \<and> atom d \<sharp> v2" using fresh_def e.supp by force
have "((z \<leftrightarrow> d ) \<bullet> (AE_op opp v1 v2)) = AE_op opp ((z \<leftrightarrow> d ) \<bullet> v1) ((z \<leftrightarrow> d ) \<bullet> v2)" using
e.perm_simps flip_commute opp.perm_simps AE_op opp.strong_exhaust pure_supp
by (metis (full_types))
hence "supp ((z \<leftrightarrow> d) \<bullet> AE_op opp v1 v2) = supp (AE_op opp ((z \<leftrightarrow> d) \<bullet>v1) ((z \<leftrightarrow> d) \<bullet>v2))" by simp
also have "... = supp ((z \<leftrightarrow> d) \<bullet>v1) \<union> supp ((z \<leftrightarrow> d) \<bullet>v2)" using e.supp
by (metis (mono_tags, opaque_lifting) opp.strong_exhaust opp.supp sup_bot.left_neutral)
also have "... \<subseteq> (supp v1 - { atom z } \<union> { atom d}) \<union> (supp v2 - { atom z } \<union> { atom d})" using swap_v_supp AE_op df by blast
finally show ?case using e.supp opp.supp by blast
next
case (AE_fst v)
then show ?case using swap_v_supp by auto
next
case (AE_snd v)
then show ?case using swap_v_supp by auto
next
case (AE_mvar u)
then show ?case using
Diff_empty Diff_insert0 Un_upper1 atom_x_sort flip_def flip_fresh_fresh fresh_def set_eq_subset supp_eqvt swap_set_in_eq
by (metis sort_of_atom_eq)
next
case (AE_len v)
then show ?case using swap_v_supp by auto
next
case (AE_concat v1 v2)
then show ?case using swap_v_supp by auto
next
case (AE_split v1 v2)
then show ?case using swap_v_supp by auto
qed
lemma swap_ce_supp:
fixes e::ce and d::x and z::x
assumes "atom d \<sharp> e"
shows "supp ((z \<leftrightarrow> d ) \<bullet> e) \<subseteq> supp e - { atom z } \<union> { atom d}"
using assms
proof(nominal_induct e rule:ce.strong_induct)
case (CE_val v)
then show ?case using swap_v_supp ce.fresh ce.supp by simp
next
case (CE_op opp v1 v2)
hence df: "atom d \<sharp> v1 \<and> atom d \<sharp> v2" using fresh_def e.supp by force
have "((z \<leftrightarrow> d ) \<bullet> (CE_op opp v1 v2)) = CE_op opp ((z \<leftrightarrow> d ) \<bullet> v1) ((z \<leftrightarrow> d ) \<bullet> v2)" using
ce.perm_simps flip_commute opp.perm_simps CE_op opp.strong_exhaust x_fresh_b pure_supp
by (metis (full_types))
hence "supp ((z \<leftrightarrow> d) \<bullet> CE_op opp v1 v2) = supp (CE_op opp ((z \<leftrightarrow> d) \<bullet>v1) ((z \<leftrightarrow> d) \<bullet>v2))" by simp
also have "... = supp ((z \<leftrightarrow> d) \<bullet>v1) \<union> supp ((z \<leftrightarrow> d) \<bullet>v2)" using ce.supp
by (metis (mono_tags, opaque_lifting) opp.strong_exhaust opp.supp sup_bot.left_neutral)
also have "... \<subseteq> (supp v1 - { atom z } \<union> { atom d}) \<union> (supp v2 - { atom z } \<union> { atom d})" using swap_v_supp CE_op df by blast
finally show ?case using ce.supp opp.supp by blast
next
case (CE_fst v)
then show ?case using ce.supp ce.fresh swap_v_supp by auto
next
case (CE_snd v)
then show ?case using ce.supp ce.fresh swap_v_supp by auto
next
case (CE_len v)
then show ?case using ce.supp ce.fresh swap_v_supp by auto
next
case (CE_concat v1 v2)
then show ?case using ce.supp ce.fresh swap_v_supp ce.perm_simps
proof -
have "\<forall>x v xa. \<not> atom (x::x) \<sharp> (v::v) \<or> supp ((xa \<leftrightarrow> x) \<bullet> v) \<subseteq> supp v - {atom xa} \<union> {atom x}"
by (meson swap_v_supp) (* 0.0 ms *)
then show ?thesis
using CE_concat ce.supp by auto
qed
qed
lemma swap_c_supp:
fixes c::c and d::x and z::x
assumes "atom d \<sharp> c"
shows "supp ((z \<leftrightarrow> d ) \<bullet> c) \<subseteq> supp c - { atom z } \<union> { atom d}"
using assms
proof(nominal_induct c rule:c.strong_induct)
case (C_eq e1 e2)
then show ?case using swap_ce_supp by auto
qed(auto+)
lemma type_e_eq:
assumes "atom z \<sharp> e" and "atom z' \<sharp> e"
shows "\<lbrace> z : b | [[z]\<^sup>v]\<^sup>c\<^sup>e == e \<rbrace> = (\<lbrace> z' : b | [[z']\<^sup>v]\<^sup>c\<^sup>e == e \<rbrace>)"
by (auto,metis (full_types) assms(1) assms(2) flip_fresh_fresh fresh_PairD(1) fresh_PairD(2))
lemma type_e_eq2:
assumes "atom z \<sharp> e" and "atom z' \<sharp> e" and "b=b'"
shows "\<lbrace> z : b | [[z]\<^sup>v]\<^sup>c\<^sup>e == e \<rbrace> = (\<lbrace> z' : b' | [[z']\<^sup>v]\<^sup>c\<^sup>e == e \<rbrace>)"
using assms type_e_eq by fast
lemma e_flip_eq:
fixes e::e and ea::e
assumes "atom c \<sharp> (e, ea)" and "atom c \<sharp> (x, xa, e, ea)" and "(x \<leftrightarrow> c) \<bullet> e = (xa \<leftrightarrow> c) \<bullet> ea"
shows "(e = AE_val w \<longrightarrow> (\<exists>w'. ea = AE_val w' \<and> (x \<leftrightarrow> c) \<bullet> w = (xa \<leftrightarrow> c) \<bullet> w')) \<or>
(e = AE_op opp v1 v2 \<longrightarrow> (\<exists>v1' v2'. ea = AS_op opp v1' v2' \<and> (x \<leftrightarrow> c) \<bullet> v1 = (xa \<leftrightarrow> c) \<bullet> v1') \<and> (x \<leftrightarrow> c) \<bullet> v2 = (xa \<leftrightarrow> c) \<bullet> v2') \<or>
(e = AE_fst v \<longrightarrow> (\<exists>v'. ea = AE_fst v' \<and> (x \<leftrightarrow> c) \<bullet> v = (xa \<leftrightarrow> c) \<bullet> v')) \<or>
(e = AE_snd v \<longrightarrow> (\<exists>v'. ea = AE_snd v' \<and> (x \<leftrightarrow> c) \<bullet> v = (xa \<leftrightarrow> c) \<bullet> v')) \<or>
(e = AE_len v \<longrightarrow> (\<exists>v'. ea = AE_len v' \<and> (x \<leftrightarrow> c) \<bullet> v = (xa \<leftrightarrow> c) \<bullet> v')) \<or>
(e = AE_concat v1 v2 \<longrightarrow> (\<exists>v1' v2'. ea = AS_concat v1' v2' \<and> (x \<leftrightarrow> c) \<bullet> v1 = (xa \<leftrightarrow> c) \<bullet> v1') \<and> (x \<leftrightarrow> c) \<bullet> v2 = (xa \<leftrightarrow> c) \<bullet> v2') \<or>
(e = AE_app f v \<longrightarrow> (\<exists>v'. ea = AE_app f v' \<and> (x \<leftrightarrow> c) \<bullet> v = (xa \<leftrightarrow> c) \<bullet> v'))"
by (metis assms e.perm_simps permute_flip_cancel2)
lemma fresh_opp_all:
fixes opp::opp
shows "z \<sharp> opp"
using e.fresh opp.exhaust opp.fresh by metis
lemma fresh_e_opp_all:
shows "(z \<sharp> v1 \<and> z \<sharp> v2) = z \<sharp> AE_op opp v1 v2"
using e.fresh opp.exhaust opp.fresh fresh_opp_all by simp
lemma fresh_e_opp:
fixes z::x
assumes "atom z \<sharp> v1 \<and> atom z \<sharp> v2"
shows "atom z \<sharp> AE_op opp v1 v2"
using e.fresh opp.exhaust opp.fresh opp.supp by (metis assms)
subsubsection \<open>Statements\<close>
lemma branch_s_flip_eq:
fixes v::v and va::v
assumes "atom c \<sharp> (v, va)" and "atom c \<sharp> (x, xa, v, va)" and "(x \<leftrightarrow> c) \<bullet> s = (xa \<leftrightarrow> c) \<bullet> sa"
shows "(s = AS_val w \<longrightarrow> (\<exists>w'. sa = AS_val w' \<and> (x \<leftrightarrow> c) \<bullet> w = (xa \<leftrightarrow> c) \<bullet> w')) \<or>
(s = AS_seq s1 s2 \<longrightarrow> (\<exists>s1' s2'. sa = AS_seq s1' s2' \<and> (x \<leftrightarrow> c) \<bullet> s1 = (xa \<leftrightarrow> c) \<bullet> s1') \<and> (x \<leftrightarrow> c) \<bullet> s2 = (xa \<leftrightarrow> c) \<bullet> s2') \<or>
(s = AS_if v s1 s2 \<longrightarrow> (\<exists>v' s1' s2'. sa = AS_if seq s1' s2' \<and> (x \<leftrightarrow> c) \<bullet> s1 = (xa \<leftrightarrow> c) \<bullet> s1') \<and> (x \<leftrightarrow> c) \<bullet> s2 = (xa \<leftrightarrow> c) \<bullet> s2' \<and> (x \<leftrightarrow> c) \<bullet> c = (xa \<leftrightarrow> c) \<bullet> v')"
by (metis assms s_branch_s_branch_list.perm_simps permute_flip_cancel2)
section \<open>Context Syntax\<close>
subsection \<open>Datatypes\<close>
text \<open>Type and function/type definition contexts\<close>
type_synonym \<Phi> = "fun_def list"
type_synonym \<Theta> = "type_def list"
type_synonym \<B> = "bv fset"
datatype \<Gamma> =
GNil
| GCons "x*b*c" \<Gamma> (infixr "#\<^sub>\<Gamma>" 65)
datatype \<Delta> =
DNil ("[]\<^sub>\<Delta>")
| DCons "u*\<tau>" \<Delta> (infixr "#\<^sub>\<Delta>" 65)
subsection \<open>Functions and Lemmas\<close>
lemma \<Gamma>_induct [case_names GNil GCons] : "P GNil \<Longrightarrow> (\<And>x b c \<Gamma>'. P \<Gamma>' \<Longrightarrow> P ((x,b,c) #\<^sub>\<Gamma> \<Gamma>')) \<Longrightarrow> P \<Gamma>"
proof(induct \<Gamma> rule:\<Gamma>.induct)
case GNil
then show ?case by auto
next
case (GCons x1 x2)
then obtain x and b and c where "x1=(x,b,c)" using prod_cases3 by blast
then show ?case using GCons by presburger
qed
instantiation \<Delta> :: pt
begin
primrec permute_\<Delta>
where
DNil_eqvt: "p \<bullet> DNil = DNil"
| DCons_eqvt: "p \<bullet> (x #\<^sub>\<Delta> xs) = p \<bullet> x #\<^sub>\<Delta> p \<bullet> (xs::\<Delta>)"
instance by standard (induct_tac [!] x, simp_all)
end
lemmas [eqvt] = permute_\<Delta>.simps
lemma \<Delta>_induct [case_names DNil DCons] : "P DNil \<Longrightarrow> (\<And>u t \<Delta>'. P \<Delta>' \<Longrightarrow> P ((u,t) #\<^sub>\<Delta> \<Delta>')) \<Longrightarrow> P \<Delta>"
proof(induct \<Delta> rule: \<Delta>.induct)
case DNil
then show ?case by auto
next
case (DCons x1 x2)
then obtain u and t where "x1=(u,t)" by fastforce
then show ?case using DCons by presburger
qed
lemma \<Phi>_induct [case_names PNil PConsNone PConsSome] : "P [] \<Longrightarrow> (\<And>f x b c \<tau> s' \<Phi>'. P \<Phi>' \<Longrightarrow> P ((AF_fundef f (AF_fun_typ_none (AF_fun_typ x b c \<tau> s'))) # \<Phi>')) \<Longrightarrow>
(\<And>f bv x b c \<tau> s' \<Phi>'. P \<Phi>' \<Longrightarrow> P ((AF_fundef f (AF_fun_typ_some bv (AF_fun_typ x b c \<tau> s'))) # \<Phi>')) \<Longrightarrow> P \<Phi>"
proof(induct \<Phi> rule: list.induct)
case Nil
then show ?case by auto
next
case (Cons x1 x2)
then obtain f and t where ft: "x1 = (AF_fundef f t)"
by (meson fun_def.exhaust)
then show ?case proof(nominal_induct t rule:fun_typ_q.strong_induct)
case (AF_fun_typ_some bv ft)
then show ?case using Cons ft
by (metis fun_typ.exhaust)
next
case (AF_fun_typ_none ft)
then show ?case using Cons ft
by (metis fun_typ.exhaust)
qed
qed
lemma \<Theta>_induct [case_names TNil AF_typedef AF_typedef_poly] : "P [] \<Longrightarrow> (\<And>tid dclist \<Theta>'. P \<Theta>' \<Longrightarrow> P ((AF_typedef tid dclist) # \<Theta>')) \<Longrightarrow>
(\<And>tid bv dclist \<Theta>'. P \<Theta>' \<Longrightarrow> P ((AF_typedef_poly tid bv dclist ) # \<Theta>')) \<Longrightarrow> P \<Theta>"
proof(induct \<Theta> rule: list.induct)
case Nil
then show ?case by auto
next
case (Cons td T)
show ?case by(cases td rule: type_def.exhaust, (simp add: Cons)+)
qed
instantiation \<Gamma> :: pt
begin
primrec permute_\<Gamma>
where
GNil_eqvt: "p \<bullet> GNil = GNil"
| GCons_eqvt: "p \<bullet> (x #\<^sub>\<Gamma> xs) = p \<bullet> x #\<^sub>\<Gamma> p \<bullet> (xs::\<Gamma>)"
instance by standard (induct_tac [!] x, simp_all)
end
lemmas [eqvt] = permute_\<Gamma>.simps
lemma G_cons_eqvt[simp]:
fixes \<Gamma>::\<Gamma>
shows "p \<bullet> ((x,b,c) #\<^sub>\<Gamma> \<Gamma>) = ((p \<bullet> x, p \<bullet> b , p \<bullet> c) #\<^sub>\<Gamma> (p \<bullet> \<Gamma> ))" (is "?A = ?B" )
using Cons_eqvt triple_eqvt supp_b_empty by simp
lemma G_cons_flip[simp]:
fixes x::x and \<Gamma>::\<Gamma>
shows "(x\<leftrightarrow>x') \<bullet> ((x'',b,c) #\<^sub>\<Gamma> \<Gamma>) = (((x\<leftrightarrow>x') \<bullet> x'', b , (x\<leftrightarrow>x') \<bullet> c) #\<^sub>\<Gamma> ((x\<leftrightarrow>x') \<bullet> \<Gamma> ))"
using Cons_eqvt triple_eqvt supp_b_empty by auto
lemma G_cons_flip_fresh[simp]:
fixes x::x and \<Gamma>::\<Gamma>
assumes "atom x \<sharp> (c,\<Gamma>)" and "atom x' \<sharp> (c,\<Gamma>)"
shows "(x\<leftrightarrow>x') \<bullet> ((x',b,c) #\<^sub>\<Gamma> \<Gamma>) = ((x, b , c) #\<^sub>\<Gamma> \<Gamma> )"
using G_cons_flip flip_fresh_fresh assms by force
lemma G_cons_flip_fresh2[simp]:
fixes x::x and \<Gamma>::\<Gamma>
assumes "atom x \<sharp> (c,\<Gamma>)" and "atom x' \<sharp> (c,\<Gamma>)"
shows "(x\<leftrightarrow>x') \<bullet> ((x,b,c) #\<^sub>\<Gamma> \<Gamma>) = ((x', b , c) #\<^sub>\<Gamma> \<Gamma> )"
using G_cons_flip flip_fresh_fresh assms by force
lemma G_cons_flip_fresh3[simp]:
fixes x::x and \<Gamma>::\<Gamma>
assumes "atom x \<sharp> \<Gamma>" and "atom x' \<sharp> \<Gamma>"
shows "(x\<leftrightarrow>x') \<bullet> ((x',b,c) #\<^sub>\<Gamma> \<Gamma>) = ((x, b , (x\<leftrightarrow>x') \<bullet> c) #\<^sub>\<Gamma> \<Gamma> )"
using G_cons_flip flip_fresh_fresh assms by force
lemma neq_GNil_conv: "(xs \<noteq> GNil) = (\<exists>y ys. xs = y #\<^sub>\<Gamma> ys)"
by (induct xs) auto
nominal_function toList :: "\<Gamma> \<Rightarrow> (x*b*c) list" where
"toList GNil = []"
| "toList (GCons xbc G) = xbc#(toList G)"
apply (auto, simp add: eqvt_def toList_graph_aux_def )
using neq_GNil_conv surj_pair by metis
nominal_termination (eqvt)
by lexicographic_order
nominal_function toSet :: "\<Gamma> \<Rightarrow> (x*b*c) set" where
"toSet GNil = {}"
| "toSet (GCons xbc G) = {xbc} \<union> (toSet G)"
apply (auto,simp add: eqvt_def toSet_graph_aux_def )
using neq_GNil_conv surj_pair by metis
nominal_termination (eqvt)
by lexicographic_order
nominal_function append_g :: "\<Gamma> \<Rightarrow> \<Gamma> \<Rightarrow> \<Gamma>" (infixr "@" 65) where
"append_g GNil g = g"
| "append_g (xbc #\<^sub>\<Gamma> g1) g2 = (xbc #\<^sub>\<Gamma> (g1@g2))"
apply (auto,simp add: eqvt_def append_g_graph_aux_def )
using neq_GNil_conv surj_pair by metis
nominal_termination (eqvt) by lexicographic_order
nominal_function dom :: "\<Gamma> \<Rightarrow> x set" where
"dom \<Gamma> = (fst` (toSet \<Gamma>))"
apply auto
unfolding eqvt_def dom_graph_aux_def lfp_eqvt toSet.eqvt by simp
nominal_termination (eqvt) by lexicographic_order
text \<open> Use of this is sometimes mixed in with use of freshness and support for the context however it makes it clear
that for immutable variables, the context is `self-supporting'\<close>
nominal_function atom_dom :: "\<Gamma> \<Rightarrow> atom set" where
"atom_dom \<Gamma> = atom`(dom \<Gamma>)"
apply auto
unfolding eqvt_def atom_dom_graph_aux_def lfp_eqvt toSet.eqvt by simp
nominal_termination (eqvt) by lexicographic_order
subsection \<open>Immutable Variable Context Lemmas\<close>
lemma append_GNil[simp]:
"GNil @ G = G"
by simp
lemma append_g_toSetU [simp]: "toSet (G1@G2) = toSet G1 \<union> toSet G2"
by(induct G1, auto+)
lemma supp_GNil:
shows "supp GNil = {}"
by (simp add: supp_def)
lemma supp_GCons:
fixes xs::\<Gamma>
shows "supp (x #\<^sub>\<Gamma> xs) = supp x \<union> supp xs"
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
lemma atom_dom_eq[simp]:
fixes G::\<Gamma>
shows "atom_dom ((x, b, c) #\<^sub>\<Gamma> G) = atom_dom ((x, b, c') #\<^sub>\<Gamma> G)"
using atom_dom.simps toSet.simps by simp
lemma dom_append[simp]:
"atom_dom (\<Gamma>@\<Gamma>') = atom_dom \<Gamma> \<union> atom_dom \<Gamma>'"
using image_Un append_g_toSetU atom_dom.simps dom.simps by metis
lemma dom_cons[simp]:
"atom_dom ((x,b,c) #\<^sub>\<Gamma> G) = { atom x } \<union> atom_dom G"
using image_Un append_g_toSetU atom_dom.simps by auto
lemma fresh_GNil[ms_fresh]:
shows "a \<sharp> GNil"
by (simp add: fresh_def supp_GNil)
lemma fresh_GCons[ms_fresh]:
fixes xs::\<Gamma>
shows "a \<sharp> (x #\<^sub>\<Gamma> xs) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> xs"
by (simp add: fresh_def supp_GCons)
lemma dom_supp_g[simp]:
"atom_dom G \<subseteq> supp G"
apply(induct G rule: \<Gamma>_induct,simp)
using supp_at_base supp_Pair atom_dom.simps supp_GCons by fastforce
lemma fresh_append_g[ms_fresh]:
fixes xs::\<Gamma>
shows "a \<sharp> (xs @ ys) \<longleftrightarrow> a \<sharp> xs \<and> a \<sharp> ys"
by (induct xs) (simp_all add: fresh_GNil fresh_GCons)
lemma append_g_assoc:
fixes xs::\<Gamma>
shows "(xs @ ys) @ zs = xs @ (ys @ zs)"
by (induct xs) simp_all
lemma append_g_inside:
fixes xs::\<Gamma>
shows "xs @ (x #\<^sub>\<Gamma> ys) = (xs @ (x #\<^sub>\<Gamma> GNil)) @ ys"
by(induct xs,auto+)
lemma finite_\<Gamma>:
"finite (toSet \<Gamma>)"
by(induct \<Gamma> rule: \<Gamma>_induct,auto)
lemma supp_\<Gamma>:
"supp \<Gamma> = supp (toSet \<Gamma>)"
proof(induct \<Gamma> rule: \<Gamma>_induct)
case GNil
then show ?case using supp_GNil toSet.simps
by (simp add: supp_set_empty)
next
case (GCons x b c \<Gamma>')
then show ?case using supp_GCons toSet.simps finite_\<Gamma> supp_of_finite_union
using supp_of_finite_insert by fastforce
qed
lemma supp_of_subset:
fixes G::"('a::fs set)"
assumes "finite G" and "finite G'" and "G \<subseteq> G'"
shows "supp G \<subseteq> supp G'"
using supp_of_finite_sets assms by (metis subset_Un_eq supp_of_finite_union)
lemma supp_weakening:
assumes "toSet G \<subseteq> toSet G'"
shows "supp G \<subseteq> supp G'"
using supp_\<Gamma> finite_\<Gamma> by (simp add: supp_of_subset assms)
lemma fresh_weakening[ms_fresh]:
assumes "toSet G \<subseteq> toSet G'" and "x \<sharp> G'"
shows "x \<sharp> G"
proof(rule ccontr)
assume "\<not> x \<sharp> G"
hence "x \<in> supp G" using fresh_def by auto
hence "x \<in> supp G'" using supp_weakening assms by auto
thus False using fresh_def assms by auto
qed
instance \<Gamma> :: fs
by (standard, induct_tac x, simp_all add: supp_GNil supp_GCons finite_supp)
lemma fresh_gamma_elem:
fixes \<Gamma>::\<Gamma>
assumes "a \<sharp> \<Gamma>"
and "e \<in> toSet \<Gamma>"
shows "a \<sharp> e"
using assms by(induct \<Gamma>,auto simp add: fresh_GCons)
lemma fresh_gamma_append:
fixes xs::\<Gamma>
shows "a \<sharp> (xs @ ys) \<longleftrightarrow> a \<sharp> xs \<and> a \<sharp> ys"
by (induct xs, simp_all add: fresh_GNil fresh_GCons)
lemma supp_triple[simp]:
shows "supp (x, y, z) = supp x \<union> supp y \<union> supp z"
proof -
have "supp (x,y,z) = supp (x,(y,z))" by auto
hence "supp (x,y,z) = supp x \<union> (supp y \<union> supp z)" using supp_Pair by metis
thus ?thesis by auto
qed
lemma supp_append_g:
fixes xs::\<Gamma>
shows "supp (xs @ ys) = supp xs \<union> supp ys"
by(induct xs,auto simp add: supp_GNil supp_GCons )
lemma fresh_in_g[simp]:
fixes \<Gamma>::\<Gamma> and x'::x
shows "atom x' \<sharp> \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> = (atom x' \<notin> supp \<Gamma>' \<union> supp x \<union> supp b0 \<union> supp c0 \<union> supp \<Gamma>)"
proof -
have "atom x' \<sharp> \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> = (atom x' \<notin> supp (\<Gamma>' @((x,b0,c0) #\<^sub>\<Gamma> \<Gamma>)))"
using fresh_def by auto
also have "... = (atom x' \<notin> supp \<Gamma>' \<union> supp ((x,b0,c0) #\<^sub>\<Gamma> \<Gamma>))" using supp_append_g by fast
also have "... = (atom x' \<notin> supp \<Gamma>' \<union> supp x \<union> supp b0 \<union> supp c0 \<union> supp \<Gamma>)" using supp_GCons supp_append_g supp_triple by auto
finally show ?thesis by fast
qed
lemma fresh_suffix[ms_fresh]:
fixes \<Gamma>::\<Gamma>
assumes "atom x \<sharp> \<Gamma>'@\<Gamma>"
shows "atom x \<sharp> \<Gamma>"
using assms by(induct \<Gamma>' rule: \<Gamma>_induct, auto simp add: append_g.simps fresh_GCons)
lemma not_GCons_self [simp]:
fixes xs::\<Gamma>
shows "xs \<noteq> x #\<^sub>\<Gamma> xs"
by (induct xs) auto
lemma not_GCons_self2 [simp]:
fixes xs::\<Gamma>
shows "x #\<^sub>\<Gamma> xs \<noteq> xs"
by (rule not_GCons_self [symmetric])
lemma fresh_restrict:
fixes y::x and \<Gamma>::\<Gamma>
assumes "atom y \<sharp> (\<Gamma>' @ (x, b, c) #\<^sub>\<Gamma> \<Gamma>)"
shows "atom y \<sharp> (\<Gamma>'@\<Gamma>)"
using assms by(induct \<Gamma>' rule: \<Gamma>_induct, auto simp add:fresh_GCons fresh_GNil )
lemma fresh_dom_free:
assumes "atom x \<sharp> \<Gamma>"
shows "(x,b,c) \<notin> toSet \<Gamma>"
using assms proof(induct \<Gamma> rule: \<Gamma>_induct)
case GNil
then show ?case by auto
next
case (GCons x' b' c' \<Gamma>')
hence "x\<noteq>x'" using fresh_def fresh_GCons fresh_Pair supp_at_base by blast
moreover have "atom x \<sharp> \<Gamma>'" using fresh_GCons GCons by auto
ultimately show ?case using toSet.simps GCons by auto
qed
lemma \<Gamma>_set_intros: "x \<in> toSet ( x #\<^sub>\<Gamma> xs)" and "y \<in> toSet xs \<Longrightarrow> y \<in> toSet (x #\<^sub>\<Gamma> xs)"
by simp+
lemma fresh_dom_free2:
assumes "atom x \<notin> atom_dom \<Gamma>"
shows "(x,b,c) \<notin> toSet \<Gamma>"
using assms proof(induct \<Gamma> rule: \<Gamma>_induct)
case GNil
then show ?case by auto
next
case (GCons x' b' c' \<Gamma>')
hence "x\<noteq>x'" using fresh_def fresh_GCons fresh_Pair supp_at_base by auto
moreover have "atom x \<notin> atom_dom \<Gamma>'" using fresh_GCons GCons by auto
ultimately show ?case using toSet.simps GCons by auto
qed
subsection \<open>Mutable Variable Context Lemmas\<close>
lemma supp_DNil:
shows "supp DNil = {}"
by (simp add: supp_def)
lemma supp_DCons:
fixes xs::\<Delta>
shows "supp (x #\<^sub>\<Delta> xs) = supp x \<union> supp xs"
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
lemma fresh_DNil[ms_fresh]:
shows "a \<sharp> DNil"
by (simp add: fresh_def supp_DNil)
lemma fresh_DCons[ms_fresh]:
fixes xs::\<Delta>
shows "a \<sharp> (x #\<^sub>\<Delta> xs) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> xs"
by (simp add: fresh_def supp_DCons)
instance \<Delta> :: fs
by (standard, induct_tac x, simp_all add: supp_DNil supp_DCons finite_supp)
subsection \<open>Lookup Functions\<close>
nominal_function lookup :: "\<Gamma> \<Rightarrow> x \<Rightarrow> (b*c) option" where
"lookup GNil x = None"
| "lookup ((x,b,c)#\<^sub>\<Gamma>G) y = (if x=y then Some (b,c) else lookup G y)"
by (auto,simp add: eqvt_def lookup_graph_aux_def, metis neq_GNil_conv surj_pair)
nominal_termination (eqvt) by lexicographic_order
nominal_function replace_in_g :: "\<Gamma> \<Rightarrow> x \<Rightarrow> c \<Rightarrow> \<Gamma>" ("_[_\<longmapsto>_]" [1000,0,0] 200) where
"replace_in_g GNil _ _ = GNil"
| "replace_in_g ((x,b,c)#\<^sub>\<Gamma>G) x' c' = (if x=x' then ((x,b,c')#\<^sub>\<Gamma>G) else (x,b,c)#\<^sub>\<Gamma>(replace_in_g G x' c'))"
apply(auto,simp add: eqvt_def replace_in_g_graph_aux_def)
using surj_pair \<Gamma>.exhaust by metis
nominal_termination (eqvt) by lexicographic_order
text \<open> Functions for looking up data-constructors in the Pi context \<close>
nominal_function lookup_fun :: "\<Phi> \<Rightarrow> f \<Rightarrow> fun_def option" where
"lookup_fun [] g = None"
| "lookup_fun ((AF_fundef f ft)#\<Pi>) g = (if (f=g) then Some (AF_fundef f ft) else lookup_fun \<Pi> g)"
apply(auto,simp add: eqvt_def lookup_fun_graph_aux_def )
by (metis fun_def.exhaust neq_Nil_conv)
nominal_termination (eqvt) by lexicographic_order
nominal_function lookup_td :: "\<Theta> \<Rightarrow> string \<Rightarrow> type_def option" where
"lookup_td [] g = None"
| "lookup_td ((AF_typedef s lst ) # (\<Theta>::\<Theta>)) g = (if (s = g) then Some (AF_typedef s lst ) else lookup_td \<Theta> g)"
| "lookup_td ((AF_typedef_poly s bv lst ) # (\<Theta>::\<Theta>)) g = (if (s = g) then Some (AF_typedef_poly s bv lst ) else lookup_td \<Theta> g)"
apply(auto,simp add: eqvt_def lookup_td_graph_aux_def )
by (metis type_def.exhaust neq_Nil_conv)
nominal_termination (eqvt) by lexicographic_order
nominal_function name_of_type ::"type_def \<Rightarrow> f " where
"name_of_type (AF_typedef f _ ) = f"
| "name_of_type (AF_typedef_poly f _ _) = f"
apply(auto,simp add: eqvt_def name_of_type_graph_aux_def )
using type_def.exhaust by blast
nominal_termination (eqvt) by lexicographic_order
nominal_function name_of_fun ::"fun_def \<Rightarrow> f " where
"name_of_fun (AF_fundef f ft) = f"
apply(auto,simp add: eqvt_def name_of_fun_graph_aux_def )
using fun_def.exhaust by blast
nominal_termination (eqvt) by lexicographic_order
nominal_function remove2 :: "'a::pt \<Rightarrow> 'a list \<Rightarrow> 'a list" where
"remove2 x [] = []" |
"remove2 x (y # xs) = (if x = y then xs else y # remove2 x xs)"
by (simp add: eqvt_def remove2_graph_aux_def,auto+,meson list.exhaust)
nominal_termination (eqvt) by lexicographic_order
nominal_function base_for_lit :: "l \<Rightarrow> b" where
"base_for_lit (L_true) = B_bool "
| "base_for_lit (L_false) = B_bool "
| "base_for_lit (L_num n) = B_int "
| "base_for_lit (L_unit) = B_unit "
| "base_for_lit (L_bitvec v) = B_bitvec"
apply (auto simp: eqvt_def base_for_lit_graph_aux_def )
using l.strong_exhaust by blast
nominal_termination (eqvt) by lexicographic_order
lemma neq_DNil_conv: "(xs \<noteq> DNil) = (\<exists>y ys. xs = y #\<^sub>\<Delta> ys)"
by (induct xs) auto
nominal_function setD :: "\<Delta> \<Rightarrow> (u*\<tau>) set" where
"setD DNil = {}"
| "setD (DCons xbc G) = {xbc} \<union> (setD G)"
apply (auto,simp add: eqvt_def setD_graph_aux_def )
using neq_DNil_conv surj_pair by metis
nominal_termination (eqvt) by lexicographic_order
lemma eqvt_triple:
fixes y::"'a::at" and ya::"'a::at" and xa::"'c::at" and va::"'d::fs" and s::s and sa::s and f::"s*'c*'d \<Rightarrow> s"
assumes "atom y \<sharp> (xa, va)" and "atom ya \<sharp> (xa, va)" and
"\<forall>c. atom c \<sharp> (s, sa) \<longrightarrow> atom c \<sharp> (y, ya, s, sa) \<longrightarrow> (y \<leftrightarrow> c) \<bullet> s = (ya \<leftrightarrow> c) \<bullet> sa"
and "eqvt_at f (s,xa,va)" and "eqvt_at f (sa,xa,va)" and
"atom c \<sharp> (s, va, xa, sa)" and "atom c \<sharp> (y, ya, f (s, xa, va), f (sa, xa, va))"
shows "(y \<leftrightarrow> c) \<bullet> f (s, xa, va) = (ya \<leftrightarrow> c) \<bullet> f (sa, xa, va)"
proof -
have " (y \<leftrightarrow> c) \<bullet> f (s, xa, va) = f ( (y \<leftrightarrow> c) \<bullet> (s,xa,va))" using assms eqvt_at_def by metis
also have "... = f ( (y \<leftrightarrow> c) \<bullet> s, (y \<leftrightarrow> c) \<bullet> xa ,(y \<leftrightarrow> c) \<bullet> va)" by auto
also have "... = f ( (ya \<leftrightarrow> c) \<bullet> sa, (ya \<leftrightarrow> c) \<bullet> xa ,(ya \<leftrightarrow> c) \<bullet> va)" proof -
have " (y \<leftrightarrow> c) \<bullet> s = (ya \<leftrightarrow> c) \<bullet> sa" using assms Abs1_eq_iff_all by auto
moreover have "((y \<leftrightarrow> c) \<bullet> xa) = ((ya \<leftrightarrow> c) \<bullet> xa)" using assms flip_fresh_fresh fresh_prodN by metis
moreover have "((y \<leftrightarrow> c) \<bullet> va) = ((ya \<leftrightarrow> c) \<bullet> va)" using assms flip_fresh_fresh fresh_prodN by metis
ultimately show ?thesis by auto
qed
also have "... = f ( (ya \<leftrightarrow> c) \<bullet> (sa,xa,va))" by auto
finally show ?thesis using assms eqvt_at_def by metis
qed
section \<open>Functions for bit list/vectors\<close>
inductive split :: "int \<Rightarrow> bit list \<Rightarrow> bit list * bit list \<Rightarrow> bool" where
"split 0 xs ([], xs)"
| "split m xs (ys,zs) \<Longrightarrow> split (m+1) (x#xs) ((x # ys), zs)"
equivariance split
nominal_inductive split .
lemma split_concat:
assumes "split n v (v1,v2)"
shows "v = append v1 v2"
using assms proof(induct "(v1,v2)" arbitrary: v1 v2 rule: split.inducts)
case 1
then show ?case by auto
next
case (2 m xs ys zs x)
then show ?case by auto
qed
lemma split_n:
assumes "split n v (v1,v2)"
shows "0 \<le> n \<and> n \<le> int (length v)"
using assms proof(induct rule: split.inducts)
case (1 xs)
then show ?case by auto
next
case (2 m xs ys zs x)
then show ?case by auto
qed
lemma split_length:
assumes "split n v (v1,v2)"
shows "n = int (length v1)"
using assms proof(induct "(v1,v2)" arbitrary: v1 v2 rule: split.inducts)
case (1 xs)
then show ?case by auto
next
case (2 m xs ys zs x)
then show ?case by auto
qed
lemma obtain_split:
assumes "0 \<le> n" and "n \<le> int (length bv)"
shows "\<exists> bv1 bv2. split n bv (bv1 , bv2)"
using assms proof(induct bv arbitrary: n)
case Nil
then show ?case using split.intros by auto
next
case (Cons b bv)
show ?case proof(cases "n = 0")
case True
then show ?thesis using split.intros by auto
next
case False
then obtain m where m:"n=m+1" using Cons
by (metis add.commute add_minus_cancel)
moreover have "0 \<le> m" using False m Cons by linarith
then obtain bv1 and bv2 where "split m bv (bv1 , bv2)" using Cons m by force
hence "split n (b # bv) ((b#bv1), bv2)" using m split.intros by auto
then show ?thesis by auto
qed
qed
end |
module RTN where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN SUC suc #-}
{-# BUILTIN ZERO zero #-}
|
TYPE PERSON
SEQUENCE
CHARACTER*1 GENDER ! Offset 0
INTEGER(4) AGE ! Offset 1
CHARACTER(30) NAME ! Offset 5
INTEGER(8) LONG_AGE ! Offset 36
INTEGER(1) BYTE_AGE ! Offset 44
INTEGER(2) SHORT_AGE ! Offset 45
CHARACTER CHAR_GENDER ! Offset 47
REAL(4) SHORT_FLOAT ! Offset 48
END TYPE PERSON
END
|
print(1, 2, b = 2) |
#include <stdio.h>
#include <gsl/gsl_min.h>
#include <gsl/gsl_multimin.h>
|
theory NameRemoval
imports "../02Typed/Typechecking" BigStep "../00Utils/AssocList"
begin
fun convert' :: "var list \<Rightarrow> texpr \<Rightarrow> dexpr" where
"convert' \<Phi> (TVar x) = DVar (the (idx_of \<Phi> x))"
| "convert' \<Phi> (TConst k) = DConst k"
| "convert' \<Phi> (TLam x t e) = DLam t (convert' (insert_at 0 x \<Phi>) e)"
| "convert' \<Phi> (TApp e\<^sub>1 e\<^sub>2) = DApp (convert' \<Phi> e\<^sub>1) (convert' \<Phi> e\<^sub>2)"
definition convert :: "texpr \<Rightarrow> dexpr" where
"convert e = convert' [] e"
theorem typesafend [simp]: "Map.empty \<turnstile>\<^sub>n e : t \<Longrightarrow> [] \<turnstile>\<^sub>d convert e : t"
proof (unfold convert_def)
define \<Gamma> where "\<Gamma> = ([] :: (var \<times> ty) list)"
define \<Phi> where "\<Phi> = ([] :: var list)"
assume "Map.empty \<turnstile>\<^sub>n e : t"
hence "map_of \<Gamma> \<turnstile>\<^sub>n e : t" by (simp add: \<Gamma>_def)
moreover have "mset (map fst \<Gamma>) = mset \<Phi>" by (simp add: \<Gamma>_def \<Phi>_def)
moreover have "distinct \<Phi>" by (simp add: \<Phi>_def)
ultimately have "listify \<Gamma> \<Phi> \<turnstile>\<^sub>d convert' \<Phi> e : t" by simp
thus "[] \<turnstile>\<^sub>d convert' [] e : t" by (simp add: \<Gamma>_def \<Phi>_def)
qed
lemma [simp]: "valt e \<Longrightarrow> vald (convert' \<Phi> e)"
by (induction e) (simp_all add: Let_def)
lemma [simp]: "y \<notin> all_varst e \<Longrightarrow> x \<le> length \<Phi> \<Longrightarrow> free_varst e \<subseteq> set \<Phi> \<Longrightarrow>
convert' (insert_at x y \<Phi>) e = incrd x (convert' \<Phi> e)"
proof (induction e arbitrary: x \<Phi>)
case (TVar z)
moreover then obtain w where "idx_of \<Phi> z = Some w" by fastforce
ultimately show ?case by simp
next
case (TLam z t e)
moreover hence "free_varst e \<subseteq> set (insert_at 0 z \<Phi>)" by auto
ultimately show ?case by simp
qed simp_all
lemma [simp]: "x' \<notin> all_varst e \<Longrightarrow> a \<le> length \<Phi> \<Longrightarrow> \<not> (a precedes x in \<Phi>) \<Longrightarrow>
convert' (insert_at a x \<Phi>) e = convert' (insert_at a x' \<Phi>) e"
by (induction e arbitrary: a \<Phi>) (auto simp add: incr_min split: option.splits)
lemma [simp]: "y \<le> length \<Phi> \<Longrightarrow> y precedes x in \<Phi> \<Longrightarrow> y precedes x' in \<Phi> \<Longrightarrow> x' \<notin> all_varst e \<Longrightarrow>
free_varst e \<subseteq> insert x (set \<Phi>) \<Longrightarrow>
convert' (insert_at y x' \<Phi>) (subst_vart x x' e) = convert' (insert_at y x \<Phi>) e"
proof (induction e arbitrary: y \<Phi>)
case (TLam z t e)
thus ?case
proof (cases "x = z")
case False
with TLam have X: "Suc y precedes x in insert_at 0 z \<Phi>" by (simp split: option.splits)
from TLam have Y: "Suc y precedes x' in insert_at 0 z \<Phi>" by (simp split: option.splits)
from TLam have "free_varst e \<subseteq> insert x (set (insert_at 0 z \<Phi>))" by auto
with TLam False X Y show ?thesis by simp
qed (simp_all split: option.splits)
qed (auto split: option.splits)
lemma convert_subst [simp]: "y \<le> length \<Phi> \<Longrightarrow> x \<notin> set \<Phi> \<Longrightarrow> free_varst e \<subseteq> insert x (set \<Phi>) \<Longrightarrow>
free_varst e' \<subseteq> set \<Phi> \<Longrightarrow>
convert' \<Phi> (substt x e' e) = substd y (convert' \<Phi> e') (convert' (insert_at y x \<Phi>) e)"
proof (induction x e' e arbitrary: \<Phi> y rule: substt.induct)
case (1 x e' z)
thus ?case
proof (cases "idx_of \<Phi> z")
case (Some w)
have "y \<noteq> incr y w" by (metis incr_not_eq)
with 1 Some show ?thesis by auto
qed simp_all
next
case (3 x e' z t e)
let ?z' = "fresh (all_varst e' \<union> all_varst e \<union> {x, z})"
have "finite (all_varst e' \<union> all_varst e \<union> {x, z})" by simp
hence Z: "?z' \<notin> all_varst e' \<union> all_varst e \<union> {x, z}" by (metis fresh_is_fresh)
from 3 Z have X: "free_varst e' \<subseteq> set (insert_at 0 ?z' \<Phi>)" by auto
from 3 have "free_varst e \<subseteq> insert z (insert x (set \<Phi>))" by auto
with Z have "free_varst (subst_vart z ?z' e) \<subseteq> insert ?z' (insert x (set \<Phi>))" by auto
hence "free_varst (subst_vart z ?z' e) \<subseteq> insert x (set (insert_at 0 ?z' \<Phi>))" by auto
with 3 X Z have H: "convert' (insert_at 0 ?z' \<Phi>) (substt x e' (subst_vart z ?z' e)) =
substd (Suc y) (convert' (insert_at 0 ?z' \<Phi>) e')
(convert' (insert_at (Suc y) x (insert_at 0 ?z' \<Phi>)) (subst_vart z ?z' e))" by fastforce
from 3 have "free_varst e \<subseteq> insert z (set (insert_at y x \<Phi>))" by auto
with Z have "convert' (insert_at 0 ?z' (insert_at y x \<Phi>)) (subst_vart z ?z' e) =
convert' (insert_at 0 z (insert_at y x \<Phi>)) e" by simp
with 3 Z H show ?case by (simp add: Let_def)
qed simp_all
theorem correctnd [simp]: "e \<Down>\<^sub>t v \<Longrightarrow> free_varst e = {} \<Longrightarrow> convert e \<Down>\<^sub>d convert v"
proof (induction e v rule: evalt.induct)
case (evt_app e\<^sub>1 x t e\<^sub>1' e\<^sub>2 v\<^sub>2 v)
hence "e\<^sub>1 \<Down>\<^sub>t TLam x t e\<^sub>1'" by simp
moreover from evt_app have "free_varst e\<^sub>1 = {}" by simp
ultimately have "free_varst (TLam x t e\<^sub>1') = {}" by (metis free_vars_evalt)
hence X: "free_varst e\<^sub>1' \<subseteq> insert x (set [])" by simp
moreover from evt_app have Y: "free_varst v\<^sub>2 \<subseteq> set []" by simp
ultimately have "free_varst (substt x v\<^sub>2 e\<^sub>1') \<subseteq> set []" by (metis free_vars_substt)
with evt_app X Y show ?case by (simp add: convert_def)
qed (simp_all add: convert_def)
lemma [simp]: "vald (convert' \<Phi> e) \<Longrightarrow> valt e"
by (induction e) (simp_all add: Let_def)
lemma convert_val_back: "vald (convert e) \<Longrightarrow> valt e"
by (simp add: convert_def)
lemma [dest]: "DApp e\<^sub>d\<^sub>1 e\<^sub>d\<^sub>2 = convert e\<^sub>n \<Longrightarrow>
\<exists>e\<^sub>n\<^sub>1 e\<^sub>n\<^sub>2. e\<^sub>n = TApp e\<^sub>n\<^sub>1 e\<^sub>n\<^sub>2 \<and> e\<^sub>d\<^sub>1 = convert e\<^sub>n\<^sub>1 \<and> e\<^sub>d\<^sub>2 = convert e\<^sub>n\<^sub>2"
by (cases e\<^sub>n) (simp_all add: convert_def)
lemma [dest]: "DLam t e\<^sub>d = convert e\<^sub>n \<Longrightarrow>
\<exists>x e\<^sub>n'. e\<^sub>n = TLam x t e\<^sub>n' \<and> e\<^sub>d = convert' [x] e\<^sub>n'"
by (cases e\<^sub>n) (simp_all add: convert_def)
theorem completend [simp]: "convert e\<^sub>n \<Down>\<^sub>d v\<^sub>d \<Longrightarrow> free_varst e\<^sub>n = {} \<Longrightarrow>
\<exists>v\<^sub>n. e\<^sub>n \<Down>\<^sub>t v\<^sub>n \<and> v\<^sub>d = convert v\<^sub>n"
proof (induction "convert e\<^sub>n" v\<^sub>d arbitrary: e\<^sub>n rule: big_evald.induct)
case (bevd_const k)
hence "e\<^sub>n \<Down>\<^sub>t TConst k \<and> DConst k = convert (TConst k)" by (cases e\<^sub>n) (simp_all add: convert_def)
thus ?case by fastforce
next
case (bevd_lam t e)
then obtain x e' where "e\<^sub>n = TLam x t e' \<and> e = convert' [x] e'"
by (cases e\<^sub>n) (simp_all add: convert_def)
hence "e\<^sub>n \<Down>\<^sub>t TLam x t e' \<and> DLam t e = convert (TLam x t e')" by (simp add: convert_def)
thus ?case by fastforce
next
case (bevd_app e\<^sub>1 t e\<^sub>1' e\<^sub>2 v\<^sub>2 v)
then obtain e\<^sub>n\<^sub>1 e\<^sub>n\<^sub>2 where E: "e\<^sub>n = TApp e\<^sub>n\<^sub>1 e\<^sub>n\<^sub>2 \<and> e\<^sub>1 = convert e\<^sub>n\<^sub>1 \<and> e\<^sub>2 = convert e\<^sub>n\<^sub>2"
by (cases e\<^sub>n) (simp_all add: convert_def)
with bevd_app obtain v\<^sub>n\<^sub>1 where V1: "e\<^sub>n\<^sub>1 \<Down>\<^sub>t v\<^sub>n\<^sub>1 \<and> DLam t e\<^sub>1' = convert v\<^sub>n\<^sub>1" by fastforce
then obtain x e\<^sub>n\<^sub>1' where X: "v\<^sub>n\<^sub>1 = TLam x t e\<^sub>n\<^sub>1' \<and> e\<^sub>1' = convert' [x] e\<^sub>n\<^sub>1'"
by (cases v\<^sub>n\<^sub>1) (simp_all add: convert_def)
from bevd_app E obtain v\<^sub>n\<^sub>2 where V2: "e\<^sub>n\<^sub>2 \<Down>\<^sub>t v\<^sub>n\<^sub>2 \<and> v\<^sub>2 = convert v\<^sub>n\<^sub>2" by fastforce
from bevd_app E have "free_varst e\<^sub>n\<^sub>1 = {}" by simp
with V1 X have "free_varst (TLam x t e\<^sub>n\<^sub>1') = {}" by (metis free_vars_evalt)
hence Y: "free_varst e\<^sub>n\<^sub>1' \<subseteq> {x}" by simp
from bevd_app E have "free_varst e\<^sub>n\<^sub>2 = {}" by simp
with V2 have Z: "free_varst v\<^sub>n\<^sub>2 = {}" by auto
with Y have "free_varst (substt x v\<^sub>n\<^sub>2 e\<^sub>n\<^sub>1') = {}" by (metis free_vars_substt subset_empty)
with bevd_app X V2 Y Z have "\<exists>v\<^sub>n. substt x v\<^sub>n\<^sub>2 e\<^sub>n\<^sub>1' \<Down>\<^sub>t v\<^sub>n \<and> v = convert v\<^sub>n"
by (simp add: convert_def)
then obtain v\<^sub>n where "substt x v\<^sub>n\<^sub>2 e\<^sub>n\<^sub>1' \<Down>\<^sub>t v\<^sub>n \<and> v = convert v\<^sub>n" by fastforce
with V1 X V2 have "TApp e\<^sub>n\<^sub>1 e\<^sub>n\<^sub>2 \<Down>\<^sub>t v\<^sub>n \<and> v = convert v\<^sub>n" by fastforce
with E show ?case by fastforce
qed
(* Now we can finish the deferred progress lemma from 01Source/Named and 02Typed/Typed *)
theorem progresst [simp]: "Map.empty \<turnstile>\<^sub>n e : t \<Longrightarrow> \<exists>v. e \<Down>\<^sub>t v"
proof -
assume X: "Map.empty \<turnstile>\<^sub>n e : t"
hence "[] \<turnstile>\<^sub>d convert e : t" by simp
then obtain v\<^sub>d where "vald v\<^sub>d \<and> convert e \<Down>\<^sub>d v\<^sub>d" by fastforce
with X obtain v\<^sub>n where "e \<Down>\<^sub>t v\<^sub>n \<and> v\<^sub>d = convert v\<^sub>n" by fastforce
thus ?thesis by fastforce
qed
theorem progressn [simp]: "Map.empty \<turnstile>\<^sub>n e : t \<Longrightarrow> \<exists>v. erase e \<Down> v"
proof -
assume X: "Map.empty \<turnstile>\<^sub>n e : t"
then obtain v\<^sub>t where "e \<Down>\<^sub>t v\<^sub>t" by fastforce
hence "erase e \<Down> erase v\<^sub>t" by simp
thus ?thesis by fastforce
qed
end |
[STATEMENT]
lemma finite_gpv_parametric [transfer_rule]: "(rel_\<I> C (=) ===> rel_gpv A C ===> (=)) finite_gpv finite_gpv"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (rel_\<I> C (=) ===> rel_gpv A C ===> (=)) finite_gpv finite_gpv
[PROOF STEP]
using finite_gpv_parametric'[of C "(=)" A]
[PROOF STATE]
proof (prove)
using this:
(rel_\<I> C (=) ===> rel_gpv'' A C (=) ===> (=)) finite_gpv finite_gpv
goal (1 subgoal):
1. (rel_\<I> C (=) ===> rel_gpv A C ===> (=)) finite_gpv finite_gpv
[PROOF STEP]
by(simp add: rel_gpv_conv_rel_gpv'') |
Formal statement is: lemma convex_hull_2_alt: "convex hull {a,b} = {a + u *\<^sub>R (b - a) | u. 0 \<le> u \<and> u \<le> 1}" Informal statement is: The convex hull of two points is the line segment between them. |
/-
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.char
! leanprover-community/mathlib commit c4658a649d216f57e99621708b09dcb3dcccbd23
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Data.UInt
import Mathlib.Init.Algebra.Order
/-!
# More `Char` instances
This file provides a `LinearOrder` instance on `Char`. `Char` is the type of Unicode scalar values.
Provides an additional definition to truncate a `Char` to `UInt8` and a theorem on conversion to
`Nat`.
-/
/-- Convert a character into a `UInt8`, by truncating (reducing modulo 256) if necessary. -/
def Char.toUInt8 (n : Char) : UInt8 := n.1.toUInt8
theorem Char.utf8Size_pos (c : Char) : 0 < c.utf8Size := by
simp only [utf8Size]
repeat (split; decide)
decide
theorem String.csize_pos : (c : Char) → 0 < String.csize c := Char.utf8Size_pos
/--
Provides a `LinearOrder` instance on `Char`. `Char` is the type of Unicode scalar values.
-/
instance : LinearOrder Char where
le_refl := fun _ => @le_refl ℕ _ _
le_trans := fun _ _ _ => @le_trans ℕ _ _ _ _
le_antisymm := fun _ _ h₁ h₂ => Char.eq_of_val_eq <| UInt32.eq_of_val_eq <| Fin.ext <|
@le_antisymm ℕ _ _ _ h₁ h₂
lt_iff_le_not_le := fun _ _ => @lt_iff_le_not_le ℕ _ _ _
le_total := fun _ _ => @le_total ℕ _ _ _
min := fun a b => if a ≤ b then a else b
max := fun a b => if a ≤ b then b else a
decidable_le := inferInstance
theorem Char.ofNat_toNat {c : Char} (h : isValidCharNat c.toNat) : Char.ofNat c.toNat = c := by
rw [Char.ofNat, dif_pos h]
rfl
#align char.of_nat_to_nat Char.ofNat_toNat
|
Formal statement is: lemma complex_i_not_neg_numeral [simp]: "\<i> \<noteq> - numeral w" Informal statement is: $i$ is not equal to $-1$. |
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE OverloadedLabels #-}
{-# OPTIONS_GHC -Wall #-}
-- | Quantile chart patterns.
module Chart.Quantile
(
-- * quantile chart patterns
quantileChart,
histChart,
-- * testing
qua,
qLines,
)
where
import Chart
import Optics.Core
import Data.Foldable
import Data.Maybe
import Data.Text (Text)
import Prelude hiding (abs)
import Statistics.Distribution.Normal
import Statistics.Distribution
import Data.Bool
-- * charts
-- | Chart template for quantile data.
quantileChart ::
[Text] ->
[LineStyle] ->
[AxisOptions] ->
[[Double]] ->
ChartSvg
quantileChart names ls as xs =
mempty & #charts .~ chart0 & #hudOptions .~ hudOptions'
where
hudOptions' :: HudOptions
hudOptions' =
defaultHudOptions
& ( #legends
.~
[(12, defaultLegendOptions
& #textStyle % #size .~ 0.1
& #vgap .~ 0.05
& #innerPad .~ 0.2
& #place .~ PlaceRight
& #content .~ zip names (fmap (\l -> LineChart l [[Point 0 0, Point 1 1]]) ls)
)]
)
& set #axes ((5,) <$> as)
chart0 = unnamed $
zipWith (\s d -> LineChart s [d])
ls
(zipWith Point [0 ..] <$> xs)
-- | histogram chart
histChart ::
Range Double ->
Int ->
[Double] ->
ChartSvg
histChart r g xs =
barChart defaultBarOptions barData'
where
barData' = BarData [freqs] xs'' []
hcuts = grid OuterPos r g
h = fill hcuts xs
counts =
(\(Rect _ _ _ w) -> w)
<$> makeRects (IncludeOvers (width r / fromIntegral g)) h
freqs = (/sum counts) <$> counts
xs' =
(\(Rect x x' _ _) -> (x + x') / 2)
<$> makeRects (IncludeOvers (width r / fromIntegral g)) h
xs'' = ["unders"] <> take (length xs' - 2) (drop 1 (comma (Just 2) <$> xs')) <> ["overs"]
qua :: Double -> Double -> Double -> Double -> Double
qua u s t p
| t <= 0 = u*t
| otherwise = Statistics.Distribution.quantile (normalDistr (u*t) (s*sqrt t)) p
qLines :: Double -> Int -> Colour -> [LineStyle]
qLines s n c = (\x -> defaultLineStyle & #color .~ x & #size .~ s) <$> cqs n c
cqs :: Int -> Colour -> [Colour]
cqs n c = fmap (\x -> mix x c (greyed c)) xs
where
xs = (\t -> fmap (\x -> fromIntegral (abs (x-(t `div` 2)-bool 0 1 (x>(t `div`2) && 1==t `mod` 2))) / fromIntegral (t `div` 2)) [0..t]) (n - 1)
|
/* randist/nbinomial.c
*
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 James Theiler, Brian Gough
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <config.h>
#include <math.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_sf_gamma.h>
/* The negative binomial distribution has the form,
prob(k) = Gamma(n + k)/(Gamma(n) Gamma(k + 1)) p^n (1-p)^k
for k = 0, 1, ... . Note that n does not have to be an integer.
This is the Leger's algorithm (given in the answers in Knuth) */
unsigned int
gsl_ran_negative_binomial (const gsl_rng * r, double p, double n)
{
double X = gsl_ran_gamma (r, n, 1.0) ;
unsigned int k = gsl_ran_poisson (r, X*(1-p)/p) ;
return k ;
}
double
gsl_ran_negative_binomial_pdf (const unsigned int k, const double p, double n)
{
double P;
double f = gsl_sf_lngamma (k + n) ;
double a = gsl_sf_lngamma (n) ;
double b = gsl_sf_lngamma (k + 1.0) ;
P = exp(f-a-b) * pow (p, n) * pow (1 - p, (double)k);
return P;
}
|
/-
Copyright (c) 2014-15 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Floris van Doorn
Partially ported from Coq HoTT
Theorems about pi-types (dependent function spaces)
-/
import .sigma hott.arity hott.cubical.square
universe u
hott_theory
namespace hott
open hott.eq hott.equiv hott.is_equiv hott.funext hott.sigma hott.is_trunc unit
namespace pi
variables {A : Type _} {A' : Type _} {B : A → Type _} {B' : A' → Type _} {C : Πa, B a → Type _}
{D : Πa b, C a b → Type _}
{a a' a'' : A} {b b₁ b₂ : B a} {b' : B a'} {b'' : B a''} {f g : Πa, B a}
/- Paths -/
/-
Paths [p : f ≈ g] in a function type [Πx:X, P x] are equivalent to functions taking values
in path types, [H : Πx:X, f x = g x], or concisely, [H : f ~ g].
This is developed in init.funext.
-/
/- homotopy.symm is an equivalence -/
@[hott] def is_equiv_homotopy_symm : is_equiv (homotopy.symm : f ~ g → g ~ f) :=
begin
apply adjointify homotopy.symm homotopy.symm,
{ intro p, apply eq_of_homotopy, intro a, apply eq.inv_inv },
{ intro p, apply eq_of_homotopy, intro a, apply eq.inv_inv }
end
/-
The identification of the path space of a dependent function space,
up to equivalence, is of course just funext.
-/
@[hott] def pi_eq_equiv (f g : Πx, B x) : (f = g) ≃ (f ~ g) := eq_equiv_homotopy f g
@[hott,instance] def is_equiv_eq_of_homotopy (f g : Πx, B x)
: is_equiv (eq_of_homotopy : f ~ g → f = g) :=
is_equiv_inv _
@[hott] def homotopy_equiv_eq (f g : Πx, B x) : (f ~ g) ≃ (f = g) :=
equiv.mk eq_of_homotopy (by apply_instance)
/- Transport -/
@[hott] def pi_transport (p : a = a') (f : Π(b : B a), C a b)
: (transport (λa, Π(b : B a), C a b) p f) ~ (λb, tr_inv_tr p b ▸ (p ▸D f (p⁻¹ ▸ b))) :=
by induction p; reflexivity
/- A special case of [transport_pi] where the type [B] does not depend on [A],
and so it is just a fixed type [B]. -/
@[hott] def pi_transport_constant {C : A → A' → Type _} (p : a = a') (f : Π(b : A'), C a b) (b : A')
: (transport _ p f) b = @transport A (λa, C a b) _ _ p (f b) := --fix
by induction p; reflexivity
/- Pathovers -/
@[hott] def pi_pathover' {f : Πb, C a b} {g : Πb', C a' b'} {p : a = a'}
(r : Π(b : B a) (b' : B a') (q : b =[p] b'), f b =[apd011 C p q; λX, X] g b') : f =[p; λa, Πb, C a b] g :=
begin
induction p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
let z := eq_of_pathover_idp (r b b idpo), exact z --fix
end
@[hott] def pi_pathover_left' {f : Πb, C a b} {g : Πb', C a' b'} {p : a = a'}
(r : Π(b : B a), f b =[apd011 C p (pathover_tr _ _); λX, X] g (p ▸ b)) : f =[p; λa, Πb, C a b] g :=
begin
induction p, apply pathover_idp_of_eq,
apply eq_of_homotopy, hintro b,
let z := eq_of_pathover_idp (r b), exact z --fix
end
@[hott] def pi_pathover_right' {f : Πb, C a b} {g : Πb', C a' b'} {p : a = a'}
(r : Π(b' : B a'), f (p⁻¹ ▸ b') =[apd011 C p (tr_pathover _ _); λX, X] g b') : f =[p; λa, Πb, C a b] g :=
begin
induction p, apply pathover_idp_of_eq,
apply eq_of_homotopy, hintro b,
dsimp [apd011, tr_pathover] at r,
let z := eq_of_pathover_idp (r b), exact z --fix
end
@[hott] def pi_pathover_constant {C : A → A' → Type _} {f : Π(b : A'), C a b}
{g : Π(b : A'), C a' b} {p : a = a'}
(r : Π(b : A'), f b =[p; λa, C a b] g b) : f =[p; λa, Πb, C a b] g :=
begin
induction p, apply pathover_idp_of_eq,
apply eq_of_homotopy, hintro b,
let z := eq_of_pathover_idp (r b), exact z --fix
end
-- a version where C is uncurried, but where the conclusion of r is still a proper pathover
-- instead of a heterogenous equality
@[hott] def pi_pathover {C : (Σa, B a) → Type _} {f : Πb, C ⟨a, b⟩} {g : Πb', C ⟨a', b'⟩}
{p : a = a'} (r : Π(b : B a) (b' : B a') (q : b =[p] b'), f b =[dpair_eq_dpair p q] g b')
: f =[p; λa, Πb, C ⟨a, b⟩] g :=
begin
induction p, apply pathover_idp_of_eq,
apply eq_of_homotopy, hintro b,
apply (@eq_of_pathover_idp _ C), exact (r b b (pathover.idpatho b)),
end
@[hott] def pi_pathover_left {C : (Σa, B a) → Type _} {f : Πb, C ⟨a, b⟩} {g : Πb', C ⟨a', b'⟩}
{p : a = a'} (r : Π(b : B a), f b =[dpair_eq_dpair p (pathover_tr _ _)] g (p ▸ b))
: f =[p; λa, Πb, C ⟨a, b⟩] g :=
begin
induction p, apply pathover_idp_of_eq,
apply eq_of_homotopy, hintro b,
apply eq_of_pathover_idp, exact pathover_ap _ _ (r b)
end
@[hott] def pi_pathover_right {C : (Σa, B a) → Type _} {f : Πb, C ⟨a, b⟩} {g : Πb', C ⟨a', b'⟩}
{p : a = a'} (r : Π(b' : B a'), f (p⁻¹ ▸ b') =[dpair_eq_dpair p (tr_pathover _ _)] g b')
: f =[p; λa, Πb, C ⟨a, b⟩] g :=
begin
induction p, apply pathover_idp_of_eq,
apply eq_of_homotopy, hintro b,
apply eq_of_pathover_idp, exact pathover_ap _ _ (r b)
end
/- Maps on paths -/
/- The action of maps given by lambda. -/
@[hott] def ap_lambdaD {C : A' → Type _} (p : a = a') (f : Πa b, C b) :
ap (λa b, f a b) p = eq_of_homotopy (λb, ap (λa, f a b) p) :=
begin
apply (eq.rec_on p),
apply inverse,
apply eq_of_homotopy_idp
end
/- Dependent paths -/
/- with more implicit arguments the conclusion of the following theorem is
(Π(b : B a), transportD B C p b (f b) = g (transport B p b)) ≃
(transport (λa, Π(b : B a), C a b) p f = g) -/
@[hott] def heq_piD (p : a = a') (f : Π(b : B a), C a b)
(g : Π(b' : B a'), C a' b') : (Π(b : B a), p ▸D (f b) = g (p ▸ b)) ≃ (p ▸ f = g) :=
eq.rec_on p (λg, homotopy_equiv_eq _ _) g
@[hott] def heq_pi {C : A → Type _} (p : a = a') (f : Π(b : B a), C a)
(g : Π(b' : B a'), C a') : (Π(b : B a), p ▸ (f b) = g (p ▸ b)) ≃ (p ▸ f = g) :=
eq.rec_on p (λg, homotopy_equiv_eq _ _) g
section
/- more implicit arguments:
(Π(b : B a), transport C (sigma_eq p idp) (f b) = g (p ▸ b)) ≃
(Π(b : B a), transportD B (λ(a : A) (b : B a), C ⟨a, b⟩) p b (f b) = g (transport B p b)) -/
@[hott] def heq_pi_sigma {C : (Σa, B a) → Type _} (p : a = a')
(f : Π(b : B a), C ⟨a, b⟩) (g : Π(b' : B a'), C ⟨a', b'⟩) :
(Π(b : B a), (dpair_eq_dpair p (pathover_tr p b)) ▸ (f b) = g (p ▸ b)) ≃
(Π(b : B a), transportD (λa b, C ⟨a, b⟩) p _ (f b) = g (p ▸ b)) :=
by induction p; refl
end
/- Functorial action -/
variables (f0 : A' → A) (f1 : Π(a':A'), B (f0 a') → B' a')
/- The functoriality of [forall] is slightly subtle: it is contravariant in the domain type and covariant in the codomain, but the codomain is dependent on the domain. -/
@[hott] def pi_functor : (Π(a:A), B a) → (Π(a':A'), B' a') :=
λg a', f1 a' (g (f0 a'))
@[hott] def pi_functor_left (B : A → Type _) : (Π(a:A), B a) → (Π(a':A'), B (f0 a')) :=
pi_functor f0 (λa, id)
@[hott] def pi_functor_right {B' : A → Type _} (f1 : Π(a:A), B a → B' a)
: (Π(a:A), B a) → (Π(a:A), B' a) :=
pi_functor id f1
@[hott] def pi_iff_pi {B' : A → Type _} (f : Πa, B a ↔ B' a) : (Π(a:A), B a) ↔ (Π(a:A), B' a) :=
⟨pi_functor id (λa, (f a).1), pi_functor id (λa, (f a).2)⟩
@[hott,hsimp] def pi_functor_eq (g : Πa, B a) (a' : A') : pi_functor f0 f1 g a' = f1 a' (g (f0 a')) :=
by refl
@[hott] def ap_pi_functor {g g' : Π(a:A), B a} (h : g ~ g')
: ap (pi_functor f0 f1) (eq_of_homotopy h)
= eq_of_homotopy (λ(a' : A'), (ap (f1 a') (h (f0 a')))) :=
begin
apply is_equiv_rect
(@apd10 A B g g') (λh, ap (pi_functor f0 f1) (eq_of_homotopy h) =
eq_of_homotopy (λa':A', (ap (f1 a') (h (f0 a'))))), intro p, clear h,
induction p,
refine (ap (ap (pi_functor f0 f1)) (eq_of_homotopy_idp g)) ⬝ _,
symmetry, apply eq_of_homotopy_idp
end
/- Equivalences -/
/-@[hott] def pi_equiv_pi (f0 : A' ≃ A) (f1 : Πa', (B (to_fun f0 a') ≃ B' a'))
: (Πa, B a) ≃ (Πa', B' a') :=
begin
fapply equiv.MK,
exact pi_functor f0 f1,
(pi_functor f0⁻¹ᶠ
(λ(a : A) (b' : B' (f0⁻¹ᶠ a)), transport B (right_inv f0 a) ((f1 (f0⁻¹ᶠ a))⁻¹ᶠ b')))
end-/
@[hott, instance] def is_equiv_pi_functor [H0 : is_equiv f0]
[H1 : Πa', is_equiv (f1 a')] : is_equiv (pi_functor f0 f1) :=
adjointify (pi_functor f0 f1) (pi_functor f0⁻¹ᶠ
(λ(a : A) (b' : B' (f0⁻¹ᶠ a)), transport B (right_inv f0 a) ((f1 (f0⁻¹ᶠ a))⁻¹ᶠ b')))
begin
intro h, apply eq_of_homotopy, intro a', dsimp,
rwr [adj f0 a', hott.eq.inverse (tr_compose B f0 (left_inv f0 a') _), fn_tr_eq_tr_fn _ f1 _, right_inv (f1 _)], --fix
apply apdt
end
begin
intro h, apply eq_of_homotopy, intro a, dsimp,
rwr [left_inv (f1 _)],
apply apdt
end
@[hott] def pi_equiv_pi_of_is_equiv [H : is_equiv f0]
[H1 : Πa', is_equiv (f1 a')] : (Πa, B a) ≃ (Πa', B' a') :=
equiv.mk (pi_functor f0 f1) (by apply_instance)
@[hott] def pi_equiv_pi (f0 : A' ≃ A) (f1 : Πa', (B (f0 a') ≃ B' a'))
: (Πa, B a) ≃ (Πa', B' a') :=
pi_equiv_pi_of_is_equiv f0 (λa', f1 a')
@[hott] def pi_equiv_pi_right {P Q : A → Type _} (g : Πa, P a ≃ Q a)
: (Πa, P a) ≃ (Πa, Q a) :=
pi_equiv_pi equiv.rfl g
/- Equivalence if one of the types is contractible -/
variable (B)
@[hott] def pi_equiv_of_is_contr_left [H : is_contr A]
: (Πa, B a) ≃ B (center A) :=
begin
fapply equiv.MK,
{ intro f, exact f (center A)},
{ intros b a, exact center_eq a ▸ b},
{ intro b, dsimp, rwr [prop_eq_of_is_contr (center_eq (center A)) idp]},
{ intro f, apply eq_of_homotopy, intro a, dsimp, induction (center_eq a),
refl }
end
@[hott] def pi_equiv_of_is_contr_right [H : Πa, is_contr (B a)]
: (Πa, B a) ≃ unit :=
begin
fapply equiv.MK,
{ intro f, exact star },
{ intros u a, exact center _ },
{ intro u, induction u, reflexivity },
{ intro f, apply eq_of_homotopy, intro a, apply is_prop.elim }
end
variable {B}
/- Interaction with other type constructors -/
-- most of these are in the file of the other type constructor
@[hott] def pi_empty_left (B : empty → Type _) : (Πx, B x) ≃ unit :=
begin
fapply equiv.MK,
{ intro f, exact star },
{ intros x y, exact empty.elim y },
{ intro x, induction x, reflexivity },
{ intro f, apply eq_of_homotopy, intro y, exact empty.elim y }
end
@[hott] def pi_unit_left (B : unit → Type _) : (Πx, B x) ≃ B star :=
pi_equiv_of_is_contr_left _
@[hott] def pi_bool_left (B : bool → Type _) : (Πx, B x) ≃ B ff × B tt :=
begin
fapply equiv.MK,
{ intro f, exact (f ff, f tt) },
{ intros x b, induction x, induction b, all_goals {assumption}},
{ intro x, induction x, reflexivity },
{ intro f, apply eq_of_homotopy, intro b, induction b, all_goals {reflexivity}},
end
/- Truncatedness: any dependent product of n-types is an n-type -/
@[hott, instance, priority 1520] theorem is_trunc_pi (B : A → Type _) (n : trunc_index)
[H : ∀a, is_trunc n (B a)] : is_trunc n (Πa, B a) :=
begin
unfreezeI, induction n with n IH generalizing B H; resetI,
{ fapply is_contr.mk,
intro a, apply center,
intro f, apply eq_of_homotopy,
intro x, apply (center_eq (f x)) },
{ apply is_trunc_succ_intro, intros f g,
exact is_trunc_equiv_closed_rev n (eq_equiv_homotopy f g) (by apply_instance) }
end
@[hott] theorem is_trunc_pi_eq (n : trunc_index) (f g : Πa, B a)
[H : ∀a, is_trunc n (f a = g a)] : is_trunc n (f = g) :=
is_trunc_equiv_closed_rev n (eq_equiv_homotopy f g) (by apply_instance)
@[hott, instance] theorem is_trunc_not (n : trunc_index) (A : Type _) : is_trunc (n.+1) ¬A :=
by dsimp [not]; apply_instance
@[hott] theorem is_prop_pi_eq (a : A) : is_prop (Π(a' : A), a = a') :=
is_prop_of_imp_is_contr
( assume (f : Πa', a = a'),
have is_contr A, from is_contr.mk a f,
by unfreezeI; apply_instance)
@[hott] theorem is_prop_neg (A : Type _) : is_prop (¬A) := by apply_instance
@[hott] theorem is_prop_ne {A : Type _} (a b : A) : is_prop (a ≠ b) := by apply_instance
@[hott] def is_contr_pi_of_neg {A : Type _} (B : A → Type _) (H : ¬ A) : is_contr (Πa, B a) :=
begin
apply is_contr.mk (λa, empty.elim (H a)), intro f, apply eq_of_homotopy, intro x, exact empty.elim (H x)
end
/- Symmetry of Π -/
@[hott] def pi_flip {P : A → A' → Type _} (f : Πa b, P a b) (b : A') (a : A) : P a b := f a b
@[hott, instance] def is_equiv_flip {P : A → A' → Type _}
: is_equiv (@pi_flip A A' P) :=
begin
fapply is_equiv.mk,
exact (@pi_flip _ _ (pi_flip P)),
all_goals {intro f; refl}
end
@[hott] def pi_comm_equiv {P : A → A' → Type _} : (Πa b, P a b) ≃ (Πb a, P a b) :=
equiv.mk (@pi_flip _ _ P) (by apply_instance)
/- Dependent functions are equivalent to nondependent functions into the total space together
with a homotopy -/
@[hott] def pi_equiv_arrow_sigma_right {A : Type _} {B : A → Type _} (f : Πa, B a) :
Σ(f : A → Σa, B a), sigma.fst ∘ f ~ id :=
⟨λa, ⟨a, f a⟩, λa, idp⟩
@[hott] def pi_equiv_arrow_sigma_left
(v : Σ(f : A → Σa, B a), sigma.fst ∘ f ~ id) (a : A) : B a :=
transport B (v.2 a) (v.1 a).2
open funext
@[hott] def pi_equiv_arrow_sigma : (Πa, B a) ≃ Σ(f : A → Σa, B a), sigma.fst ∘ f ~ id :=
begin
fapply equiv.MK,
{ exact pi_equiv_arrow_sigma_right },
{ exact pi_equiv_arrow_sigma_left },
{ intro v, induction v with f p, fapply sigma_eq,
{ apply eq_of_homotopy, intro a, fapply sigma_eq,
{ exact (p a)⁻¹ },
{ apply inverseo, apply pathover_tr }},
{ apply pi_pathover_constant, intro a, apply eq_pathover_constant_right,
refine ap_compose (λf : A → A, f a) _ _ ⬝ph _,
refine ap02 _ (compose_eq_of_homotopy (@sigma.fst A B) _) ⬝ph _,
refine ap_eq_apd10 _ _ ⬝ph _,
refine apd10 (right_inv apd10 _) a ⬝ph _,
refine sigma_eq_fst _ _ ⬝ph _, apply square_of_eq, exact (con.left_inv _)⁻¹ }},
{ intro a, reflexivity }
end
end pi
namespace pi
/- pointed pi types -/
open pointed
@[hott, instance] def pointed_pi {A : Type _} (P : A → Type _) [H : Πx, pointed (P x)]
: pointed (Πx, P x) :=
pointed.mk (λx, pt)
end pi
end hott |
import LeanUtils
open Nat
-- first theorem
theorem square_mod_3 (q : Nat) : (¬divisible 3 q) → (q^2 % 3 = 1) := by
intros h₁
apply mod_rewrite.mpr
have h2 : q % 3 = 0 ∨ q % 3 = 1 ∨ q % 3 = 2 := mod_3_poss _
-- divide cases into 3 goals
rcases h2 with h2 | h2 | h2
contradiction
have ⟨k, h3⟩ : ∃ (k : Nat), q = 3 * k + 1 := by simp_all
have q_square : q^2 = 3 * (3 * k^2 + 2 * k) + 1 := by
calc
q^2 = (3 * k + 1)^2 := by
repeat (first | ring | simp_all)
_ = 9 * k^2 + 6 * k + 1 := by
repeat (first | ring | simp_all)
_ = 3 * (3 * k^2 + 2 * k) + 1 := by
repeat (first | ring | simp_all)
exact ⟨_, by assumption⟩
have ⟨k, h3⟩ : ∃ (k : Nat), q = 3 * k + 2 := by simp_all
have q_square : q^2 = 3 * (3 * k^2 + 4 * k + 1) + 1 := by
calc
q^2 = (3 * k + 2)^2 := by
repeat (first | ring | simp_all)
_ = 3 * (3 * k^2 + 4 * k + 1) + 1 := by
repeat (first | ring | simp_all)
exact ⟨_, by assumption⟩
-- second using the first
theorem square_of_q_divisible_by_3_means_q_is_divisible_by_3 (q : Nat) (h₁ : divisible 3 (q^2)) : divisible 3 q := by
revert h₁
rw [not_imp_not.symm]
repeat rw [not_not]
intro h₁
have h₂ : q^2 % 3 = 1 := by
repeat (first | ring | simp_all [square_mod_3])
simp_all
|
/-
Copyright (c) 2021 Ashvni Narayanan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ashvni Narayanan, David Loeffler
! This file was ported from Lean 3 source module number_theory.bernoulli_polynomials
! leanprover-community/mathlib commit ca3d21f7f4fd613c2a3c54ac7871163e1e5ecb3a
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Data.Polynomial.AlgebraMap
import Mathbin.Data.Polynomial.Derivative
import Mathbin.Data.Nat.Choose.Cast
import Mathbin.NumberTheory.Bernoulli
/-!
# Bernoulli polynomials
The [Bernoulli polynomials](https://en.wikipedia.org/wiki/Bernoulli_polynomials)
are an important tool obtained from Bernoulli numbers.
## Mathematical overview
The $n$-th Bernoulli polynomial is defined as
$$ B_n(X) = ∑_{k = 0}^n {n \choose k} (-1)^k B_k X^{n - k} $$
where $B_k$ is the $k$-th Bernoulli number. The Bernoulli polynomials are generating functions,
$$ \frac{t e^{tX} }{ e^t - 1} = ∑_{n = 0}^{\infty} B_n(X) \frac{t^n}{n!} $$
## Implementation detail
Bernoulli polynomials are defined using `bernoulli`, the Bernoulli numbers.
## Main theorems
- `sum_bernoulli`: The sum of the $k^\mathrm{th}$ Bernoulli polynomial with binomial
coefficients up to `n` is `(n + 1) * X^n`.
- `polynomial.bernoulli_generating_function`: The Bernoulli polynomials act as generating functions
for the exponential.
## TODO
- `bernoulli_eval_one_neg` : $$ B_n(1 - x) = (-1)^n B_n(x) $$
-/
noncomputable section
open BigOperators
open Nat Polynomial
open Nat Finset
namespace Polynomial
/-- The Bernoulli polynomials are defined in terms of the negative Bernoulli numbers. -/
def bernoulli (n : ℕ) : ℚ[X] :=
∑ i in range (n + 1), Polynomial.monomial (n - i) (bernoulli i * choose n i)
#align polynomial.bernoulli Polynomial.bernoulli
theorem bernoulli_def (n : ℕ) :
bernoulli n = ∑ i in range (n + 1), Polynomial.monomial i (bernoulli (n - i) * choose n i) :=
by
rw [← sum_range_reflect, add_succ_sub_one, add_zero, bernoulli]
apply sum_congr rfl
rintro x hx
rw [mem_range_succ_iff] at hx; rw [choose_symm hx, tsub_tsub_cancel_of_le hx]
#align polynomial.bernoulli_def Polynomial.bernoulli_def
/-
### examples
-/
section Examples
@[simp]
theorem bernoulli_zero : bernoulli 0 = 1 := by simp [bernoulli]
#align polynomial.bernoulli_zero Polynomial.bernoulli_zero
@[simp]
theorem bernoulli_eval_zero (n : ℕ) : (bernoulli n).eval 0 = bernoulli n :=
by
rw [bernoulli, eval_finset_sum, sum_range_succ]
have : (∑ x : ℕ in range n, _root_.bernoulli x * n.choose x * 0 ^ (n - x)) = 0 :=
by
apply sum_eq_zero fun x hx => _
have h : 0 < n - x := tsub_pos_of_lt (mem_range.1 hx)
simp [h]
simp [this]
#align polynomial.bernoulli_eval_zero Polynomial.bernoulli_eval_zero
@[simp]
theorem bernoulli_eval_one (n : ℕ) : (bernoulli n).eval 1 = bernoulli' n :=
by
simp only [bernoulli, eval_finset_sum]
simp only [← succ_eq_add_one, sum_range_succ, mul_one, cast_one, choose_self,
(_root_.bernoulli _).mul_comm, sum_bernoulli, one_pow, mul_one, eval_C, eval_monomial]
by_cases h : n = 1
· norm_num [h]
· simp [h]
exact bernoulli_eq_bernoulli'_of_ne_one h
#align polynomial.bernoulli_eval_one Polynomial.bernoulli_eval_one
end Examples
theorem derivative_bernoulli_add_one (k : ℕ) :
(bernoulli (k + 1)).derivative = (k + 1) * bernoulli k :=
by
simp_rw [bernoulli, derivative_sum, derivative_monomial, Nat.sub_sub, Nat.add_sub_add_right]
-- LHS sum has an extra term, but the coefficient is zero:
rw [range_add_one, sum_insert not_mem_range_self, tsub_self, cast_zero, MulZeroClass.mul_zero,
map_zero, zero_add, mul_sum]
-- the rest of the sum is termwise equal:
refine' sum_congr (by rfl) fun m hm => _
conv_rhs => rw [← Nat.cast_one, ← Nat.cast_add, ← C_eq_nat_cast, C_mul_monomial, mul_comm]
rw [mul_assoc, mul_assoc, ← Nat.cast_mul, ← Nat.cast_mul]
congr 3
rw [(choose_mul_succ_eq k m).symm, mul_comm]
#align polynomial.derivative_bernoulli_add_one Polynomial.derivative_bernoulli_add_one
theorem derivative_bernoulli (k : ℕ) : (bernoulli k).derivative = k * bernoulli (k - 1) :=
by
cases k
· rw [Nat.cast_zero, MulZeroClass.zero_mul, bernoulli_zero, derivative_one]
· exact_mod_cast derivative_bernoulli_add_one k
#align polynomial.derivative_bernoulli Polynomial.derivative_bernoulli
@[simp]
theorem sum_bernoulli (n : ℕ) :
(∑ k in range (n + 1), ((n + 1).choose k : ℚ) • bernoulli k) = monomial n (n + 1 : ℚ) :=
by
simp_rw [bernoulli_def, Finset.smul_sum, Finset.range_eq_Ico, ← Finset.sum_Ico_Ico_comm,
Finset.sum_Ico_eq_sum_range]
simp only [add_tsub_cancel_left, tsub_zero, zero_add, LinearMap.map_add]
simp_rw [smul_monomial, mul_comm (_root_.bernoulli _) _, smul_eq_mul, ← mul_assoc]
conv_lhs =>
apply_congr
skip
conv =>
apply_congr
skip
rw [← Nat.cast_mul,
choose_mul ((le_tsub_iff_left <| mem_range_le H).1 <| mem_range_le H_1) (le.intro rfl),
Nat.cast_mul, add_comm x x_1, add_tsub_cancel_right, mul_assoc, mul_comm, ← smul_eq_mul, ←
smul_monomial]
rw [← sum_smul]
rw [sum_range_succ_comm]
simp only [add_right_eq_self, mul_one, cast_one, cast_add, add_tsub_cancel_left,
choose_succ_self_right, one_smul, _root_.bernoulli_zero, sum_singleton, zero_add,
LinearMap.map_add, range_one]
apply sum_eq_zero fun x hx => _
have f : ∀ x ∈ range n, ¬n + 1 - x = 1 := by
rintro x H
rw [mem_range] at H
rw [eq_comm]
exact ne_of_lt (Nat.lt_of_lt_of_le one_lt_two (le_tsub_of_add_le_left (succ_le_succ H)))
rw [sum_bernoulli]
have g : ite (n + 1 - x = 1) (1 : ℚ) 0 = 0 :=
by
simp only [ite_eq_right_iff, one_ne_zero]
intro h₁
exact (f x hx) h₁
rw [g, zero_smul]
#align polynomial.sum_bernoulli Polynomial.sum_bernoulli
/-- Another version of `polynomial.sum_bernoulli`. -/
theorem bernoulli_eq_sub_sum (n : ℕ) :
(n.succ : ℚ) • bernoulli n =
monomial n (n.succ : ℚ) - ∑ k in Finset.range n, ((n + 1).choose k : ℚ) • bernoulli k :=
by
rw [Nat.cast_succ, ← sum_bernoulli n, sum_range_succ, add_sub_cancel', choose_succ_self_right,
Nat.cast_succ]
#align polynomial.bernoulli_eq_sub_sum Polynomial.bernoulli_eq_sub_sum
/-- Another version of `bernoulli.sum_range_pow`. -/
theorem sum_range_pow_eq_bernoulli_sub (n p : ℕ) :
((p + 1 : ℚ) * ∑ k in range n, (k : ℚ) ^ p) = (bernoulli p.succ).eval n - bernoulli p.succ :=
by
rw [sum_range_pow, bernoulli_def, eval_finset_sum, ← sum_div, mul_div_cancel' _ _]
· simp_rw [eval_monomial]
symm
rw [← sum_flip _, sum_range_succ]
simp only [tsub_self, tsub_zero, choose_zero_right, cast_one, mul_one, pow_zero,
add_tsub_cancel_right]
apply sum_congr rfl fun x hx => _
apply congr_arg₂ _ (congr_arg₂ _ _ _) rfl
· rw [Nat.sub_sub_self (mem_range_le hx)]
· rw [← choose_symm (mem_range_le hx)]
· norm_cast
apply succ_ne_zero _
#align polynomial.sum_range_pow_eq_bernoulli_sub Polynomial.sum_range_pow_eq_bernoulli_sub
/-- Rearrangement of `polynomial.sum_range_pow_eq_bernoulli_sub`. -/
theorem bernoulli_succ_eval (n p : ℕ) :
(bernoulli p.succ).eval n = bernoulli p.succ + (p + 1 : ℚ) * ∑ k in range n, (k : ℚ) ^ p :=
by
apply eq_add_of_sub_eq'
rw [sum_range_pow_eq_bernoulli_sub]
#align polynomial.bernoulli_succ_eval Polynomial.bernoulli_succ_eval
theorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :
(bernoulli n).eval (1 + x) = (bernoulli n).eval x + n * x ^ (n - 1) :=
by
apply Nat.strong_induction_on n fun d hd => _
have nz : ((d.succ : ℕ) : ℚ) ≠ 0 := by
norm_cast
exact d.succ_ne_zero
apply (mul_right_inj' nz).1
rw [← smul_eq_mul, ← eval_smul, bernoulli_eq_sub_sum, mul_add, ← smul_eq_mul, ← eval_smul,
bernoulli_eq_sub_sum, eval_sub, eval_finset_sum]
conv_lhs =>
congr
skip
apply_congr
skip
rw [eval_smul, hd x_1 (mem_range.1 H)]
rw [eval_sub, eval_finset_sum]
simp_rw [eval_smul, smul_add]
rw [sum_add_distrib, sub_add, sub_eq_sub_iff_sub_eq_sub, _root_.add_sub_sub_cancel]
conv_rhs =>
congr
skip
congr
rw [succ_eq_add_one, ← choose_succ_self_right d]
rw [Nat.cast_succ, ← smul_eq_mul, ← sum_range_succ _ d, eval_monomial_one_add_sub]
simp_rw [smul_eq_mul]
#align polynomial.bernoulli_eval_one_add Polynomial.bernoulli_eval_one_add
open PowerSeries
variable {A : Type _} [CommRing A] [Algebra ℚ A]
-- TODO: define exponential generating functions, and use them here
-- This name should probably be updated afterwards
/-- The theorem that $(e^X - 1) * ∑ Bₙ(t)* X^n/n! = Xe^{tX}$ -/
theorem bernoulli_generating_function (t : A) :
(mk fun n => aeval t ((1 / n ! : ℚ) • bernoulli n)) * (exp A - 1) =
PowerSeries.x * rescale t (exp A) :=
by
-- check equality of power series by checking coefficients of X^n
ext n
-- n = 0 case solved by `simp`
cases n;
· simp
-- n ≥ 1, the coefficients is a sum to n+2, so use `sum_range_succ` to write as
-- last term plus sum to n+1
rw [coeff_succ_X_mul, coeff_rescale, coeff_exp, PowerSeries.coeff_mul,
nat.sum_antidiagonal_eq_sum_range_succ_mk, sum_range_succ]
-- last term is zero so kill with `add_zero`
simp only [RingHom.map_sub, tsub_self, constant_coeff_one, constant_coeff_exp,
coeff_zero_eq_constant_coeff, MulZeroClass.mul_zero, sub_self, add_zero]
-- Let's multiply both sides by (n+1)! (OK because it's a unit)
have hnp1 : IsUnit ((n + 1)! : ℚ) := IsUnit.mk0 _ (by exact_mod_cast factorial_ne_zero (n + 1))
rw [← (hnp1.map (algebraMap ℚ A)).mul_right_inj]
-- do trivial rearrangements to make RHS (n+1)*t^n
rw [mul_left_comm, ← RingHom.map_mul]
change _ = t ^ n * algebraMap ℚ A (((n + 1) * n ! : ℕ) * (1 / n !))
rw [cast_mul, mul_assoc,
mul_one_div_cancel (show (n ! : ℚ) ≠ 0 from cast_ne_zero.2 (factorial_ne_zero n)), mul_one,
mul_comm (t ^ n), ← aeval_monomial, cast_add, cast_one]
-- But this is the RHS of `sum_bernoulli_poly`
rw [← sum_bernoulli, Finset.mul_sum, AlgHom.map_sum]
-- and now we have to prove a sum is a sum, but all the terms are equal.
apply Finset.sum_congr rfl
-- The rest is just trivialities, hampered by the fact that we're coercing
-- factorials and binomial coefficients between ℕ and ℚ and A.
intro i hi
-- deal with coefficients of e^X-1
simp only [Nat.cast_choose ℚ (mem_range_le hi), coeff_mk, if_neg (mem_range_sub_ne_zero hi),
one_div, AlgHom.map_smul, PowerSeries.coeff_one, coeff_exp, sub_zero, LinearMap.map_sub,
Algebra.smul_mul_assoc, Algebra.smul_def, mul_right_comm _ ((aeval t) _), ← mul_assoc, ←
RingHom.map_mul, succ_eq_add_one, ← Polynomial.C_eq_algebraMap, Polynomial.aeval_mul,
Polynomial.aeval_C]
-- finally cancel the Bernoulli polynomial and the algebra_map
congr
apply congr_arg
rw [mul_assoc, div_eq_mul_inv, ← mul_inv]
#align polynomial.bernoulli_generating_function Polynomial.bernoulli_generating_function
end Polynomial
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Yury Kudryashov.
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.real.sqrt
import Mathlib.data.rat.sqrt
import Mathlib.ring_theory.int.basic
import Mathlib.data.polynomial.eval
import Mathlib.data.polynomial.degree.default
import Mathlib.tactic.interval_cases
import Mathlib.PostPort
namespace Mathlib
/-!
# Irrational real numbers
In this file we define a predicate `irrational` on `ℝ`, prove that the `n`-th root of an integer
number is irrational if it is not integer, and that `sqrt q` is irrational if and only if
`rat.sqrt q * rat.sqrt q ≠ q ∧ 0 ≤ q`.
We also provide dot-style constructors like `irrational.add_rat`, `irrational.rat_sub` etc.
-/
/-- A real number is irrational if it is not equal to any rational number. -/
def irrational (x : ℝ) :=
¬x ∈ set.range coe
theorem irrational_iff_ne_rational (x : ℝ) : irrational x ↔ ∀ (a b : ℤ), x ≠ ↑a / ↑b := sorry
/-!
### Irrationality of roots of integer and rational numbers
-/
/-- If `x^n`, `n > 0`, is integer and is not the `n`-th power of an integer, then
`x` is irrational. -/
theorem irrational_nrt_of_notint_nrt {x : ℝ} (n : ℕ) (m : ℤ) (hxr : x ^ n = ↑m) (hv : ¬∃ (y : ℤ), x = ↑y) (hnpos : 0 < n) : irrational x := sorry
/-- If `x^n = m` is an integer and `n` does not divide the `multiplicity p m`, then `x`
is irrational. -/
theorem irrational_nrt_of_n_not_dvd_multiplicity {x : ℝ} (n : ℕ) {m : ℤ} (hm : m ≠ 0) (p : ℕ) [hp : fact (nat.prime p)] (hxr : x ^ n = ↑m) (hv : roption.get (multiplicity (↑p) m) (iff.mpr multiplicity.finite_int_iff { left := nat.prime.ne_one hp, right := hm }) %
n ≠
0) : irrational x := sorry
theorem irrational_sqrt_of_multiplicity_odd (m : ℤ) (hm : 0 < m) (p : ℕ) [hp : fact (nat.prime p)] (Hpv : roption.get (multiplicity (↑p) m)
(iff.mpr multiplicity.finite_int_iff { left := nat.prime.ne_one hp, right := ne.symm (ne_of_lt hm) }) %
bit0 1 =
1) : irrational (real.sqrt ↑m) := sorry
theorem nat.prime.irrational_sqrt {p : ℕ} (hp : nat.prime p) : irrational (real.sqrt ↑p) := sorry
theorem irrational_sqrt_two : irrational (real.sqrt (bit0 1)) := sorry
theorem irrational_sqrt_rat_iff (q : ℚ) : irrational (real.sqrt ↑q) ↔ rat.sqrt q * rat.sqrt q ≠ q ∧ 0 ≤ q := sorry
protected instance irrational.decidable (q : ℚ) : Decidable (irrational (real.sqrt ↑q)) :=
decidable_of_iff' (rat.sqrt q * rat.sqrt q ≠ q ∧ 0 ≤ q) (irrational_sqrt_rat_iff q)
/-!
### Adding/subtracting/multiplying by rational numbers
-/
theorem rat.not_irrational (q : ℚ) : ¬irrational ↑q :=
fun (h : irrational ↑q) => h (Exists.intro q rfl)
namespace irrational
theorem add_cases {x : ℝ} {y : ℝ} : irrational (x + y) → irrational x ∨ irrational y := sorry
theorem of_rat_add (q : ℚ) {x : ℝ} (h : irrational (↑q + x)) : irrational x :=
or.elim (add_cases h) (fun (h : irrational ↑q) => absurd h (rat.not_irrational q)) id
theorem rat_add (q : ℚ) {x : ℝ} (h : irrational x) : irrational (↑q + x) :=
of_rat_add (-q)
(eq.mpr (id (Eq._oldrec (Eq.refl (irrational (↑(-q) + (↑q + x)))) (rat.cast_neg q)))
(eq.mpr (id (Eq._oldrec (Eq.refl (irrational (-↑q + (↑q + x)))) (neg_add_cancel_left (↑q) x))) h))
theorem of_add_rat (q : ℚ) {x : ℝ} : irrational (x + ↑q) → irrational x :=
add_comm (↑q) x ▸ of_rat_add q
theorem add_rat (q : ℚ) {x : ℝ} (h : irrational x) : irrational (x + ↑q) :=
add_comm (↑q) x ▸ rat_add q h
theorem of_neg {x : ℝ} (h : irrational (-x)) : irrational x := sorry
protected theorem neg {x : ℝ} (h : irrational x) : irrational (-x) :=
of_neg (eq.mpr (id (Eq._oldrec (Eq.refl (irrational ( --x))) (neg_neg x))) h)
theorem sub_rat (q : ℚ) {x : ℝ} (h : irrational x) : irrational (x - ↑q) := sorry
theorem rat_sub (q : ℚ) {x : ℝ} (h : irrational x) : irrational (↑q - x) :=
eq.mpr (id ((fun (x x_1 : ℝ) (e_1 : x = x_1) => congr_arg irrational e_1) (↑q - x) (↑q + -x) (sub_eq_add_neg (↑q) x)))
(eq.mp (Eq.refl (irrational (↑q + -x))) (rat_add q (irrational.neg h)))
theorem of_sub_rat (q : ℚ) {x : ℝ} (h : irrational (x - ↑q)) : irrational x := sorry
theorem of_rat_sub (q : ℚ) {x : ℝ} (h : irrational (↑q - x)) : irrational x := sorry
theorem mul_cases {x : ℝ} {y : ℝ} : irrational (x * y) → irrational x ∨ irrational y := sorry
theorem of_mul_rat (q : ℚ) {x : ℝ} (h : irrational (x * ↑q)) : irrational x :=
or.elim (mul_cases h) id fun (h : irrational ↑q) => absurd h (rat.not_irrational q)
theorem mul_rat {x : ℝ} (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (x * ↑q) := sorry
theorem of_rat_mul (q : ℚ) {x : ℝ} : irrational (↑q * x) → irrational x :=
mul_comm x ↑q ▸ of_mul_rat q
theorem rat_mul {x : ℝ} (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (↑q * x) :=
mul_comm x ↑q ▸ mul_rat h hq
theorem of_mul_self {x : ℝ} (h : irrational (x * x)) : irrational x :=
or.elim (mul_cases h) id id
theorem of_inv {x : ℝ} (h : irrational (x⁻¹)) : irrational x := sorry
protected theorem inv {x : ℝ} (h : irrational x) : irrational (x⁻¹) :=
of_inv (eq.mpr (id (Eq._oldrec (Eq.refl (irrational (x⁻¹⁻¹))) (inv_inv' x))) h)
theorem div_cases {x : ℝ} {y : ℝ} (h : irrational (x / y)) : irrational x ∨ irrational y :=
or.imp id of_inv (mul_cases h)
theorem of_rat_div (q : ℚ) {x : ℝ} (h : irrational (↑q / x)) : irrational x :=
of_inv (of_rat_mul q h)
theorem of_one_div {x : ℝ} (h : irrational (1 / x)) : irrational x :=
of_rat_div 1 (eq.mpr (id (Eq._oldrec (Eq.refl (irrational (↑1 / x))) rat.cast_one)) h)
theorem of_pow {x : ℝ} (n : ℕ) : irrational (x ^ n) → irrational x := sorry
theorem of_fpow {x : ℝ} (m : ℤ) : irrational (x ^ m) → irrational x := sorry
end irrational
theorem one_lt_nat_degree_of_irrational_root (x : ℝ) (p : polynomial ℤ) (hx : irrational x) (p_nonzero : p ≠ 0) (x_is_root : coe_fn (polynomial.aeval x) p = 0) : 1 < polynomial.nat_degree p := sorry
@[simp] theorem irrational_rat_add_iff {q : ℚ} {x : ℝ} : irrational (↑q + x) ↔ irrational x :=
{ mp := irrational.of_rat_add q, mpr := irrational.rat_add q }
@[simp] theorem irrational_add_rat_iff {q : ℚ} {x : ℝ} : irrational (x + ↑q) ↔ irrational x :=
{ mp := irrational.of_add_rat q, mpr := irrational.add_rat q }
@[simp] theorem irrational_rat_sub_iff {q : ℚ} {x : ℝ} : irrational (↑q - x) ↔ irrational x :=
{ mp := irrational.of_rat_sub q, mpr := irrational.rat_sub q }
@[simp] theorem irrational_sub_rat_iff {q : ℚ} {x : ℝ} : irrational (x - ↑q) ↔ irrational x :=
{ mp := irrational.of_sub_rat q, mpr := irrational.sub_rat q }
@[simp] theorem irrational_neg_iff {x : ℝ} : irrational (-x) ↔ irrational x :=
{ mp := irrational.of_neg, mpr := irrational.neg }
@[simp] theorem irrational_inv_iff {x : ℝ} : irrational (x⁻¹) ↔ irrational x :=
{ mp := irrational.of_inv, mpr := irrational.inv }
|
: foo ." foo" CR ;
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.RibbonCover
module experimental.CoverClassification2 {i} (X : Ptd i)
(A-conn : is-connected 0 (de⊙ X)) where
private
A = de⊙ X
a = pt X
open Cover
open import homotopy.CoverClassification X A-conn
{-
Universality of the covering generated by the fundamental group itself.
-}
-- FIXME What's the established terminology for this?
canonical-gset : Gset (πS 0 X) i
canonical-gset = record
{ El = a =₀ a
; El-level = Trunc-level
; gset-struct = record
{ act = _∙₀_
; unit-r = ∙₀-unit-r
; assoc = ∙₀-assoc
}
}
-- FIXME What's the established terminology for this?
canonical-cover : Cover A i
canonical-cover = gset-to-cover canonical-gset
{-
private
module CanonicalIsUniversal where
open covering canonical-covering
open gset canonical-gset
center′ : ∀ a → Σ A fiber
center′ a = (a , trace {gs = act} refl₀ refl₀)
center : τ ⟨1⟩ (Σ A fiber)
center = proj center′
private
-- An ugly lemma for this development only
trans-fiber≡cst-proj-Σ-eq : ∀ {i} (P : Set i) (Q : P → Set i)
(a : P) (c : Σ P Q) {b₁ b₂} (p : b₁ ≡ b₂) (q : a ≡ π₁ c)
(r : transport Q q b₁ ≡ π₂ c)
→ transport (λ r → (a , r) ≡₀ c) p (proj $ Σ-eq q r)
≡ proj (Σ-eq q (ap (transport Q q) (! p) ∘ r))
trans-fiber≡cst-proj-Σ-eq P Q a c refl q r = refl
abstract
path-trace-fiber : ∀ {a₂} y (p : a ≡ a₂)
→ transport fiber (! p ∘ ! y) (trace (proj y) (proj p))
≡ trace refl₀ refl₀
path-trace-fiber y refl =
transport fiber (! y) (trace (proj y) refl₀)
≡⟨ trans-trace act (! y) (proj y) refl₀ ⟩
trace (proj y) (proj $ ! y)
≡⟨ paste refl₀ (proj y) (proj $ ! y) ⟩
trace refl₀ (proj $ y ∘ ! y)
≡⟨ ap (trace refl₀ ◯ proj) $ opposite-right-inverse y ⟩∎
trace refl₀ refl₀
∎
path-trace : ∀ {a₂} y p → (a₂ , trace {act = act} y p) ≡₀ center′
path-trace {a₂} =
π₀-extend ⦃ λ y → Π-is-set λ p → π₀-is-set ((a₂ , trace y p) ≡ center′) ⦄
(λ y → π₀-extend ⦃ λ p → π₀-is-set ((a₂ , trace (proj y) p) ≡ center′) ⦄
(λ p → proj $ Σ-eq (! p ∘ ! y) (path-trace-fiber y p)))
abstract
path-paste′ : ∀ {a₂} y loop p
→ transport (λ r → (a₂ , r) ≡₀ center′) (paste (proj y) (proj loop) (proj p))
(path-trace (proj $ y ∘ loop) (proj p))
≡ path-trace (proj y) (proj $ loop ∘ p)
path-paste′ y loop refl =
transport (λ r → (a , r) ≡₀ center′) (paste (proj y) (proj loop) refl₀)
(proj $ Σ-eq (! (y ∘ loop)) (path-trace-fiber (y ∘ loop) refl))
≡⟨ trans-fiber≡cst-proj-Σ-eq A fiber a center′
(paste (proj y) (proj loop) refl₀)
(! (y ∘ loop)) (path-trace-fiber (y ∘ loop) refl) ⟩
proj (Σ-eq (! (y ∘ loop)) _)
≡⟨ ap proj $
ap2 (λ p q → Σ-eq p q)
(! (y ∘ loop)
≡⟨ opposite-concat y loop ⟩
! loop ∘ ! y
≡⟨ ap (λ x → ! x ∘ ! y) $ ! $ refl-right-unit loop ⟩∎
! (loop ∘ refl) ∘ ! y
∎)
(prop-has-all-paths (ribbon-is-set a _ _) _ _) ⟩∎
proj (Σ-eq (! (loop ∘ refl) ∘ ! y) (path-trace-fiber y (loop ∘ refl)))
∎
abstract
path-paste : ∀ {a₂} y loop p
→ transport (λ r → (a₂ , r) ≡₀ center′) (paste y loop p)
(path-trace (y ∘₀ loop) p)
≡ path-trace y (loop ∘₀ p)
path-paste {a₂} =
π₀-extend ⦃ λ y → Π-is-set λ loop → Π-is-set λ p → ≡-is-set $ π₀-is-set _ ⦄
(λ y → π₀-extend ⦃ λ loop → Π-is-set λ p → ≡-is-set $ π₀-is-set _ ⦄
(λ loop → π₀-extend ⦃ λ p → ≡-is-set $ π₀-is-set _ ⦄
(λ p → path-paste′ y loop p)))
path′ : (y : Σ A fiber) → proj {n = ⟨1⟩} y ≡ center
path′ y = τ-path-equiv-path-τ-S {n = ⟨0⟩} ☆
ribbon-rec {act = act} (π₁ y)
(λ r → (π₁ y , r) ≡₀ center′)
⦃ λ r → π₀-is-set ((π₁ y , r) ≡ center′) ⦄
path-trace
path-paste
(π₂ y)
path : (y : τ ⟨1⟩ (Σ A fiber)) → y ≡ center
path = τ-extend {n = ⟨1⟩} ⦃ λ _ → ≡-is-truncated ⟨1⟩ $ τ-is-truncated ⟨1⟩ _ ⦄ path′
canonical-covering-is-universal : is-universal canonical-covering
canonical-covering-is-universal = Universality.center , Universality.path
-- The other direction: If a covering is universal, then the fiber
-- is equivalent to the fundamental group.
module _ (cov : covering) (cov-is-universal : is-universal cov) where
open covering cov
open action (covering⇒action cov)
-- We need a point!
module GiveMeAPoint (center : fiber a) where
-- Goal: fiber a <-> fundamental group
fiber-a⇒fg : fiber a → a ≡₀ a
fiber-a⇒fg y = ap₀ π₁ $ connected-has-all-τ-paths
cov-is-universal (a , center) (a , y)
fg⇒fiber-a : a ≡₀ a → fiber a
fg⇒fiber-a = tracing cov center
fg⇒fiber-a⇒fg : ∀ p → fiber-a⇒fg (fg⇒fiber-a p) ≡ p
fg⇒fiber-a⇒fg = π₀-extend ⦃ λ _ → ≡-is-set $ π₀-is-set _ ⦄ λ p →
ap₀ π₁ (connected-has-all-τ-paths
cov-is-universal (a , center) (a , transport fiber p center))
≡⟨ ap (ap₀ π₁)
$ ! $ π₂ (connected-has-connected-paths cov-is-universal _ _)
(proj $ Σ-eq p refl) ⟩
ap₀ π₁ (proj $ Σ-eq p refl)
≡⟨ ap proj $ base-path-Σ-eq p refl ⟩∎
proj p
∎
fiber-a⇒fg⇒fiber-a : ∀ y → fg⇒fiber-a (fiber-a⇒fg y) ≡ y
fiber-a⇒fg⇒fiber-a y = π₀-extend
⦃ λ p → ≡-is-set {x = tracing cov center (ap₀ π₁ p)} {y = y}
$ fiber-is-set a ⦄
(λ p →
transport fiber (base-path p) center
≡⟨ trans-base-path p ⟩∎
y
∎)
(connected-has-all-τ-paths cov-is-universal (a , center) (a , y))
fiber-a≃fg : fiber a ≃ (a ≡₀ a)
fiber-a≃fg = fiber-a⇒fg , iso-is-eq _ fg⇒fiber-a
fg⇒fiber-a⇒fg fiber-a⇒fg⇒fiber-a
-- This is the best we can obtain, because there is no continuous
-- choice of the center.
[center] : [ fiber a ]
[center] = τ-extend-nondep
⦃ prop-is-gpd []-is-prop ⦄
(λ y → []-extend-nondep
⦃ []-is-prop ⦄
(proj ◯ λ p → transport fiber p (π₂ y))
(connected-has-all-τ-paths A⋆-is-conn (π₁ y) a))
(π₁ cov-is-universal)
-- [ isomorphism between the fiber and the fundamental group ]
-- This is the best we can obtain, because there is no continuous
-- choice of the center.
[fiber-a≃fg] : [ fiber a ≃ (a ≡₀ a) ]
[fiber-a≃fg] = []-extend-nondep ⦃ []-is-prop ⦄
(proj ◯ GiveMeAPoint.fiber-a≃fg) [center]
-}
|
------------------------------------------------------------------------
-- Well-typed substitutions
-- From
------------------------------------------------------------------------
module Extensions.Fin.TypedSubstitution where
import Category.Applicative.Indexed as Applicative
open import Data.Fin using (Fin; zero; suc)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas
open import Data.Fin.Substitution.ExtraLemmas
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Vec as Vec using (Vec; []; _∷_; map)
open import Data.Vec.All using (All₂; []; _∷_; map₂; gmap₂; gmap₂₁; gmap₂₂)
open import Data.Vec.Properties using (lookup-morphism)
open import Function using (_∘_; flip)
open import Relation.Binary.PropositionalEquality as PropEq hiding (trans)
open PropEq.≡-Reasoning
------------------------------------------------------------------------
-- Abstract typing contexts and well-typedness relations
-- Abstract typing contexts over T-types.
--
-- A typing context Ctx n maps n free variables to types containing up
-- to n free variables each.
module Context where
infixr 5 _∷_
-- Typing contexts.
data Ctx (T : ℕ → Set) : ℕ → Set where
[] : Ctx T 0
_∷_ : ∀ {n} → T (1 + n) → Ctx T n → Ctx T (1 + n)
-- Operations on context that require weakening of types.
record WeakenOps (T : ℕ → Set) : Set where
-- Weakening of types.
field weaken : ∀ {n} → T n → T (1 + n)
infixr 5 _i∷_
-- Convert a context to its vector representation.
toVec : ∀ {n} → Ctx T n → Vec (T n) n
toVec [] = []
toVec (a ∷ Γ) = a ∷ map weaken (toVec Γ)
-- Shorthand for extending contexts with variables that are typed
-- independently of themselves.
_i∷_ : ∀ {n} → T n → Ctx T n → Ctx T (1 + n)
a i∷ Γ = weaken a ∷ Γ
-- Lookup the type of a variable in a context.
lookup : ∀ {n} → Fin n → Ctx T n → T n
lookup x = Vec.lookup x ∘ toVec
open Context
-- Abstract typings.
--
-- An abtract typing _⊢_∈_ : Typing Tp₁ Tm Tp₂ is a ternary relation
-- which, in a given Tp₂-context, relates Tm-terms to their Tp₁-types.
Typing : (ℕ → Set) → (ℕ → Set) → (ℕ → Set) → Set₁
Typing Tp₁ Tm Tp₂ = ∀ {n} → Ctx Tp₁ n → Tm n → Tp₂ n → Set
------------------------------------------------------------------------
-- Abstract well-typed substitutions (i.e. substitution lemmas)
-- Abstract typed substitutions.
record TypedSub (Tp₁ Tp₂ Tm : ℕ → Set) : Set₁ where
infix 4 _⊢_∈_
field
_⊢_∈_ : Typing Tp₂ Tm Tp₁ -- the associated typing
-- Application of Tm-substitutions to (source) Tp₁-types
application : Application Tp₁ Tm
-- Operations on the (source) Tp₁-context.
weakenOps : WeakenOps Tp₁
open Application application public using (_/_)
open WeakenOps weakenOps using (toVec)
infix 4 _⇒_⊢_
-- Typed substitutions.
--
-- A typed substitution Γ ⇒ Δ ⊢ σ is a substitution σ which, when
-- applied to something that is well-typed in a source context Γ,
-- yields something well-typed in a target context Δ.
_⇒_⊢_ : ∀ {m n} → Ctx Tp₁ m → Ctx Tp₂ n → Sub Tm m n → Set
Γ ⇒ Δ ⊢ σ = All₂ (λ t a → Δ ⊢ t ∈ (a / σ)) σ (toVec Γ)
-- Abstract extensions of substitutions.
record ExtensionTyped {Tp₁ Tp₂ Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp₁ Tp₂ Tm) : Set where
open TypedSub typedSub
private
module S = SimpleExt simple
module L₀ = Lemmas₀ (record { simple = simple })
module C = WeakenOps weakenOps
open C using (_i∷_)
field
-- Weakens well-typed Ts.
weaken : ∀ {n} {Δ : Ctx Tp₂ n} {t a b} → Δ ⊢ t ∈ a →
b ∷ Δ ⊢ S.weaken t ∈ C.weaken a
-- Weakening commutes with other substitutions.
wk-commutes : ∀ {m n} {σ : Sub Tm m n} {t} a →
a / σ / S.wk ≡ a / S.wk / (t S./∷ σ)
-- Relates weakening of types to weakening of Ts.
/-wk : ∀ {n} {a : Tp₁ n} → a / S.wk ≡ C.weaken a
-- A helper lemma.
weaken-/ : ∀ {m n} {σ : Sub Tm m n} {t} a →
C.weaken (a / σ) ≡ C.weaken a / (t S./∷ σ)
weaken-/ {σ = σ} {t} a = begin
C.weaken (a / σ) ≡⟨ sym /-wk ⟩
a / σ / S.wk ≡⟨ wk-commutes a ⟩
a / S.wk / (t S./∷ σ) ≡⟨ cong₂ _/_ /-wk refl ⟩
C.weaken a / (t S./∷ σ) ∎
infixr 5 _/∷_ _/i∷_
-- Extension.
_/∷_ : ∀ {m n} {Γ : Ctx Tp₁ m} {Δ : Ctx Tp₂ n} {t a b σ} →
b ∷ Δ ⊢ t ∈ a / (t S./∷ σ) → Γ ⇒ Δ ⊢ σ → a ∷ Γ ⇒ b ∷ Δ ⊢ (t S./∷ σ)
t∈a/t∷σ /∷ σ-wt =
t∈a/t∷σ ∷ gmap₂ (subst (_⊢_∈_ _ _) (weaken-/ _) ∘ weaken) σ-wt
-- A variant of extension tailored to _i∷_.
_/i∷_ : ∀ {m n} {Γ : Ctx Tp₁ m} {Δ : Ctx Tp₂ n} {t a b σ} →
b ∷ Δ ⊢ t ∈ C.weaken (a / σ) → Γ ⇒ Δ ⊢ σ → a i∷ Γ ⇒ b ∷ Δ ⊢ (t S./∷ σ)
t∈a/σ /i∷ σ-wt =
(subst (_⊢_∈_ _ _) (weaken-/ _) t∈a/σ) /∷ σ-wt
-- Abstract simple typed substitutions.
record SimpleTyped {Tp Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp Tp Tm) : Set where
field extensionTyped : ExtensionTyped simple typedSub
open TypedSub typedSub
open ExtensionTyped extensionTyped public
private
module S = SimpleExt simple
module L₀ = Lemmas₀ (record { simple = simple })
module C = WeakenOps weakenOps
open C using (_i∷_)
field
-- Takes variables to well-typed Ts.
var : ∀ {n} {Γ : Ctx Tp n} (x : Fin n) → Γ ⊢ S.var x ∈ C.lookup x Γ
-- Types are invariant under the identity substitution.
id-vanishes : ∀ {n} (a : Tp n) → a / S.id ≡ a
-- Single-variable substitution is a left-inverse of weakening.
wk-sub-vanishes : ∀ {n b} (a : Tp n) → a / S.wk / S.sub b ≡ a
infix 10 _↑ _↑i
-- Lifting.
_↑ : ∀ {m n} {Γ : Ctx Tp m} {Δ : Ctx Tp n} {σ} → Γ ⇒ Δ ⊢ σ → ∀ {a} →
a ∷ Γ ⇒ a / σ S.↑ ∷ Δ ⊢ (σ S.↑)
σ-wt ↑ = var zero /∷ σ-wt
-- A variant of lifting tailored to _i∷_.
_↑i : ∀ {m n} {Γ : Ctx Tp m} {Δ : Ctx Tp n} {σ} → Γ ⇒ Δ ⊢ σ → ∀ {a} →
a i∷ Γ ⇒ a / σ i∷ Δ ⊢ σ S.↑
σ-wt ↑i = var zero /i∷ σ-wt
-- The identity substitution.
id : ∀ {n} {Γ : Ctx Tp n} → Γ ⇒ Γ ⊢ S.id
id {zero} = []
id {suc n} {a ∷ Γ} =
subst₂ (λ Δ σ → a ∷ Γ ⇒ Δ ⊢ σ)
(cong (flip _∷_ Γ) (id-vanishes a)) (L₀.id-↑⋆ 1) (id ↑)
where
id-vanishes′ : ∀ {n} (a : Tp (1 + n)) → a / S.id S.↑ ≡ a
id-vanishes′ a = begin
a / S.id S.↑ ≡⟨ cong (_/_ a) (L₀.id-↑⋆ 1) ⟩
a / S.id ≡⟨ id-vanishes a ⟩
a ∎
-- Weakening.
wk : ∀ {n} {Γ : Ctx Tp n} {a} → Γ ⇒ a ∷ Γ ⊢ S.wk
wk {n} {Γ = Γ} {a = a} =
gmap₂₁ (weaken′ ∘ subst (_⊢_∈_ _ _) (id-vanishes _)) id
where
weaken′ : ∀ {n} {Γ : Ctx Tp n} {t a b} → Γ ⊢ t ∈ a →
b ∷ Γ ⊢ S.weaken t ∈ a / S.wk
weaken′ = subst (_⊢_∈_ _ _) (sym /-wk) ∘ weaken
private
wk-sub-vanishes′ : ∀ {n a} {t : Tm n} → a ≡ C.weaken a / S.sub t
wk-sub-vanishes′ {a = a} {t} = begin
a ≡⟨ sym (wk-sub-vanishes a) ⟩
a / S.wk / S.sub t ≡⟨ cong (flip _/_ _) /-wk ⟩
C.weaken a / S.sub t ∎
id-wk-sub-vanishes : ∀ {n a} {t : Tm n} →
a / S.id ≡ C.weaken a / S.sub t
id-wk-sub-vanishes {a = a} {t} = begin
a / S.id ≡⟨ id-vanishes a ⟩
a ≡⟨ wk-sub-vanishes′ ⟩
C.weaken a / S.sub t ∎
-- A substitution which only replaces the first variable.
sub : ∀ {n} {Γ : Ctx Tp n} {t a} → Γ ⊢ t ∈ a → a i∷ Γ ⇒ Γ ⊢ S.sub t
sub t∈a = t∈a′ ∷ gmap₂₂ (subst (_⊢_∈_ _ _) id-wk-sub-vanishes) id
where
t∈a′ = subst (_⊢_∈_ _ _) wk-sub-vanishes′ t∈a
-- A variant of single-variable substitution that handles
-- self-dependently typed variables.
sub′ : ∀ {n} {Γ : Ctx Tp n} {t a} → Γ ⊢ t ∈ a / S.sub t →
a ∷ Γ ⇒ Γ ⊢ S.sub t
sub′ t∈a[/t] = t∈a[/t] ∷ gmap₂₂ (subst (_⊢_∈_ _ _) id-wk-sub-vanishes) id
-- A substitution which only changes the type of the first variable.
tsub : ∀ {n} {Γ : Ctx Tp n} {a b} → b ∷ Γ ⊢ S.var zero ∈ a →
a ∷ Γ ⇒ b ∷ Γ ⊢ S.id
tsub z∈a = z∈a′ ∷ gmap₂ (subst (_⊢_∈_ _ _) (weaken-/ _) ∘ weaken) id
where
z∈a′ = subst (_⊢_∈_ _ _) (sym (id-vanishes _)) z∈a
-- Abstract typed liftings from Tm₁ to Tm₂.
record LiftTyped {Tp Tm₁ Tm₂} (l : Lift Tm₁ Tm₂)
(typedSub : TypedSub Tp Tp Tm₁)
(_⊢₂_∈_ : Typing Tp Tm₂ Tp) : Set where
open TypedSub typedSub renaming (_⊢_∈_ to _⊢₁_∈_)
private module L = Lift l
-- The underlying well-typed simple Tm₁-substitutions.
field simpleTyped : SimpleTyped L.simple typedSub
open SimpleTyped simpleTyped public
-- Lifts well-typed Tm₁-terms to well-typed Tm₂-terms.
field lift : ∀ {n} {Γ : Ctx Tp n} {t a} → Γ ⊢₁ t ∈ a → Γ ⊢₂ (L.lift t) ∈ a
-- Abstract variable typings.
module VarTyping {Tp} (weakenOps : Context.WeakenOps Tp) where
open WeakenOps weakenOps
infix 4 _⊢Var_∈_
-- Abstract variable typings.
data _⊢Var_∈_ {n} (Γ : Ctx Tp n) : Fin n → Tp n → Set where
var : ∀ x → Γ ⊢Var x ∈ lookup x Γ
-- Abstract typed variable substitutions (α-renamings).
record TypedVarSubst (Tp : ℕ → Set) : Set where
field
application : Application Tp Fin
weakenOps : WeakenOps Tp
open VarTyping weakenOps public
typedSub : TypedSub Tp Tp Fin
typedSub = record
{ _⊢_∈_ = _⊢Var_∈_
; application = application
; weakenOps = weakenOps
}
open TypedSub typedSub public using () renaming (_⇒_⊢_ to _⇒_⊢α_)
open Application application using (_/_)
open Lemmas₄ VarLemmas.lemmas₄ using (id; wk; _⊙_)
private module C = WeakenOps weakenOps
field
/-wk : ∀ {n} {a : Tp n} → a / wk ≡ C.weaken a
id-vanishes : ∀ {n} (a : Tp n) → a / id ≡ a
/-⊙ : ∀ {m n k} {σ₁ : Sub Fin m n} {σ₂ : Sub Fin n k} a →
a / σ₁ ⊙ σ₂ ≡ a / σ₁ / σ₂
appLemmas : AppLemmas Tp Fin
appLemmas = record
{ application = application
; lemmas₄ = VarLemmas.lemmas₄
; id-vanishes = id-vanishes
; /-⊙ = /-⊙
}
open ExtAppLemmas appLemmas hiding (var; weaken; /-wk; id-vanishes; subst)
-- Extensions of renamings.
extensionTyped : ExtensionTyped VarLemmas.simple typedSub
extensionTyped = record
{ weaken = weaken
; wk-commutes = wk-commutes
; /-wk = /-wk
}
where
open Applicative.Morphism using (op-<$>)
weaken : ∀ {n} {Γ : Ctx Tp n} {x a b} → Γ ⊢Var x ∈ a →
b ∷ Γ ⊢Var suc x ∈ C.weaken a
weaken (var x) =
subst (_⊢Var_∈_ _ _) (op-<$> (lookup-morphism x) _ _) (var (suc x))
-- Simple typed renamings.
simpleTyped : SimpleTyped VarLemmas.simple typedSub
simpleTyped = record
{ extensionTyped = extensionTyped
; var = var
; id-vanishes = id-vanishes
; wk-sub-vanishes = wk-sub-vanishes
}
open SimpleTyped simpleTyped public
hiding (extensionTyped; var; /-wk; id-vanishes; wk-sub-vanishes)
-- Context-replacing substitutions.
record ContextSub (Tp₁ Tp₂ Tm : ℕ → Set) : Set₁ where
infix 4 _⊢_∈_
field
_⊢_∈_ : Typing Tp₂ Tm Tp₁ -- the associated typing
-- Simple Tm-substitutions (e.g. id).
simple : Simple Tm
-- Operations on the (source) Tp₁-context.
weakenOps : WeakenOps Tp₁
open Simple simple using (id)
open WeakenOps weakenOps using (toVec)
infix 4 _⇒_⊢-id
-- Context-replacing substitutions.
--
-- An alternative representation for substitutions that only change
-- the context of a well-typed Tm-term, i.e. where the underlying
-- untyped substitution is the identity.
_⇒_⊢-id : ∀ {n} → Ctx Tp₁ n → Ctx Tp₂ n → Set
Γ ⇒ Δ ⊢-id = All₂ (λ t a → Δ ⊢ t ∈ a) id (toVec Γ)
-- Equivalences between (simple) typed substitutions and their
-- context-replacing counterparts.
record Equivalence {Tp₁ Tp₂ Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp₁ Tp₂ Tm) : Set where
open Simple simple
open TypedSub typedSub
-- The type of context substitutions participating in this
-- equivalence.
contextSub : ContextSub Tp₁ Tp₂ Tm
contextSub = record
{ _⊢_∈_ = _⊢_∈_
; simple = simple
; weakenOps = weakenOps
}
open ContextSub contextSub hiding (_⊢_∈_; simple)
-- Types are invariant under the identity substitution.
field id-vanishes : ∀ {n} (a : Tp₁ n) → a / id ≡ a
-- There is a context substitution for every typed identity
-- substitution.
sound : ∀ {n} {Γ : Ctx Tp₁ n} {Δ : Ctx Tp₂ n} → Γ ⇒ Δ ⊢-id → Γ ⇒ Δ ⊢ id
sound ρ = map₂ (subst (_⊢_∈_ _ _) (sym (id-vanishes _))) ρ
-- There is a context substitution for every typed identity
-- substitution.
complete : ∀ {n} {Γ : Ctx Tp₁ n} {Δ : Ctx Tp₂ n} → Γ ⇒ Δ ⊢ id → Γ ⇒ Δ ⊢-id
complete σ-wt = map₂ (subst (_⊢_∈_ _ _) (id-vanishes _)) σ-wt
-- Variants of some simple typed substitutions.
record ContextSimple {Tp Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp Tp Tm) : Set where
field simpleTyped : SimpleTyped simple typedSub
open TypedSub typedSub hiding (_⊢_∈_)
private
module U = SimpleExt simple
module C = WeakenOps weakenOps
module S = SimpleTyped simpleTyped
open C using (_i∷_)
equivalence : Equivalence simple typedSub
equivalence = record { id-vanishes = S.id-vanishes }
open Equivalence equivalence public
open ContextSub contextSub public
infixr 5 _/∷_
infix 10 _↑
-- Extension.
_/∷_ : ∀ {n} {Γ : Ctx Tp n} {Δ : Ctx Tp n} {a b} →
b ∷ Δ ⊢ U.var zero ∈ a → Γ ⇒ Δ ⊢-id → a ∷ Γ ⇒ b ∷ Δ ⊢-id
z∈a /∷ σ-wt = z∈a ∷ gmap₂ S.weaken σ-wt
-- Lifting.
_↑ : ∀ {n} {Γ : Ctx Tp n} {Δ : Ctx Tp n} → Γ ⇒ Δ ⊢-id → ∀ {a} →
a ∷ Γ ⇒ a ∷ Δ ⊢-id
ρ ↑ = S.var zero /∷ ρ
-- The identity substitution.
id : ∀ {n} {Γ : Ctx Tp n} → Γ ⇒ Γ ⊢-id
id = complete S.id
|
(* ***********************************************************************)
(* *)
(* Synchronously executed Interpreted Time Petri Nets (SITPNs) *)
(* *)
(* *)
(* Copyright Université de Montpellier, contributor(s): Vincent *)
(* Iampietro, David Andreu, David Delahaye (May 2020) *)
(* *)
(* This software is governed by the CeCILL-C license under French law *)
(* and abiding by the rules of distribution of free software. You can *)
(* use, modify and/ or redistribute the software under the terms of *)
(* the CeCILL-C license as circulated by CEA, CNRS and INRIA at the *)
(* following URL "http://www.cecill.info". The fact that you are *)
(* presently reading this means that you have had knowledge of the *)
(* CeCILL-C license and that you accept its terms. *)
(* *)
(* ***********************************************************************)
(* Import Sitpn material. *)
Require Import simpl.Sitpn.
Require Import simpl.SitpnTokenPlayer.
Require Import simpl.SitpnSemantics.
(* Import Sitpn tactics, and misc. lemmas. *)
Require Import simpl.SitpnTactics.
(* Import lemmas about marking and well-definition. *)
Require Import simpl.SitpnWellDefMarking.
(* Import tertium non datur *)
Require Import Classical_Prop.
(** * Lemmas on [modify_m] and its spec. *)
Section ModifyM.
(** Correctness proof for [modify_m].
Needed in update_marking_pre_aux_correct. *)
Lemma modify_m_correct :
forall (marking : list (Place * nat))
(p : Place)
(op : nat -> nat -> nat)
(nboftokens : nat)
(final_marking : list (Place * nat)),
NoDup (fst (split marking)) ->
modify_m marking p op nboftokens = Some final_marking ->
forall n : nat, In (p, n) marking -> In (p, op n nboftokens) final_marking.
Proof.
intros marking p op nboftokens;
functional induction (modify_m marking p op nboftokens) using modify_m_ind;
intros final_marking Hnodup Hfun n' Hin_n'_m.
(* ERROR CASE *)
- inversion Hfun.
(* INDUCTION CASE *)
(* CASE p = hd. *)
- inversion_clear Hin_n'_m as [Heq_pn'_p'n | Hin_pn'_tl].
(* Case (p, n') = (p', n) *)
+ injection Heq_pn'_p'n as Heq_p'p Heqnn'.
rewrite <- Heqnn';
injection Hfun as Hfun;
rewrite <- Hfun;
apply in_eq.
(* Case (p, n') ∈ tl *)
+ rewrite fst_split_cons_app in Hnodup.
simpl in Hnodup.
deduce_nodup_hd_not_in.
apply in_fst_split in Hin_pn'_tl.
rewrite (beq_nat_true p' p e1) in Hnot_in_tl.
contradiction.
(* CASE p <> hd ∧ rec = Some m'. *)
- inversion_clear Hin_n'_m as [Heq_pn'_p'n | Hin_pn'_tl].
(* Case (p, n') = (p', n) *)
+ injection Heq_pn'_p'n as Heq_p'p Heqnn'.
apply beq_nat_false in e1.
contradiction.
(* Case (p, n') ∈ tl *)
+ rewrite fst_split_cons_app in Hnodup;
simpl in Hnodup;
rewrite NoDup_cons_iff in Hnodup;
apply proj2 in Hnodup.
injection Hfun as Hfun;
rewrite <- Hfun;
apply in_cons.
apply (IHo m' Hnodup e2 n' Hin_pn'_tl).
(* ERROR CASE, rec = None *)
- inversion Hfun.
Qed.
Lemma modify_m_in_if_diff :
forall (marking : list (Place * nat))
(p : Place)
(op : nat -> nat -> nat)
(nboftokens : nat)
(final_marking : list (Place * nat)),
modify_m marking p op nboftokens = Some final_marking ->
forall (p' : Place) (n : nat), p <> p' -> In (p', n) marking <-> In (p', n) final_marking.
Proof.
intros marking p op nboftokens;
functional induction (modify_m marking p op nboftokens) using modify_m_ind;
intros final_marking Hfun p'' n' Hdiff_pp.
(* ERROR CASE *)
- inversion Hfun.
(* CASE p = hd *)
- injection Hfun as Hfun.
apply not_eq_sym in Hdiff_pp.
specialize (fst_diff_pair_diff p'' p Hdiff_pp n' n) as Hdiff_nn0.
specialize (fst_diff_pair_diff p'' p Hdiff_pp n' (op n nboftokens)) as Hdiff_nnb.
split.
+ intros Hin_p''n'.
inversion_clear Hin_p''n' as [Heq_p''n'_p'n | Hin_tl].
-- symmetry in Heq_p''n'_p'n.
rewrite (beq_nat_true p' p e1) in Heq_p''n'_p'n.
contradiction.
-- rewrite <- Hfun; apply in_cons; assumption.
+ intros Hin_p''n'_fm.
rewrite <- Hfun in Hin_p''n'_fm.
inversion_clear Hin_p''n'_fm as [Heq_p''n'_pop | Hin_tl].
-- symmetry in Heq_p''n'_pop; contradiction.
-- apply in_cons; assumption.
(* CASE p <> hd ∧ rec = Some m' *)
- injection Hfun as Hfun.
split.
+ intros Hin_p''n'.
inversion_clear Hin_p''n' as [Heq_p''n'_p'n | Hin_tl].
-- rewrite <- Hfun;
rewrite <- Heq_p''n'_p'n;
apply in_eq.
-- specialize (IHo m' e2 p'' n' Hdiff_pp)
as Heq.
rewrite <- Hfun; apply in_cons.
rewrite <- Heq.
assumption.
+ intros Hin_p''n'.
rewrite <- Hfun in Hin_p''n'.
inversion_clear Hin_p''n' as [Heq_p''n'_p'n | Hin_tl].
-- rewrite <- Heq_p''n'_p'n;
apply in_eq.
-- specialize (IHo m' e2 p'' n' Hdiff_pp)
as Heq.
apply in_cons.
rewrite Heq.
assumption.
(* ERROR CASE *)
- inversion Hfun.
Qed.
(** No error lemma for modify_m. *)
Lemma modify_m_no_error :
forall (m : list (Place * nat))
(p : Place)
(op : nat -> nat -> nat)
(nboftokens : nat),
In p (fst (split m)) ->
exists m' : list (Place * nat),
modify_m m p op nboftokens = Some m'.
Proof.
intros m p op nboftokens;
functional induction (modify_m m p op nboftokens)
using modify_m_ind;
intros Hin_p_fs.
(* BASE CASE *)
- simpl in Hin_p_fs; inversion Hin_p_fs.
(* CASE p = hd *)
- exists ((p, op n nboftokens) :: tl); reflexivity.
(* CASE p <> hd ∧ rec = Some m' *)
- exists ((p', n) :: m'); reflexivity.
(* CASE p <> hd ∧ rec = None *)
- rewrite fst_split_cons_app in Hin_p_fs; simpl in Hin_p_fs.
inversion_clear Hin_p_fs as [Heq_p'p | Hin_p_fs_tl].
+ apply beq_nat_false in e1; contradiction.
+ specialize (IHo Hin_p_fs_tl) as Hex_modif.
inversion_clear Hex_modif as (m' & Hmodif).
rewrite e2 in Hmodif; inversion Hmodif.
Qed.
End ModifyM.
(** Lemmas on update_marking_pre and update_marking_post functions,
and their mapped versions. *)
Section SitpnUpdateMarking.
(** Needed to prove update_marking_pre_aux_correct. *)
Lemma update_marking_pre_aux_not_in_pre_places :
forall (sitpn : Sitpn)
(m : list (Place * nat))
(t : Trans)
(pre_places : list Place)
(m' : list (Place * nat)),
update_marking_pre_aux sitpn m t pre_places = Some m' ->
forall (p : Place),
~In p pre_places ->
forall (n : nat), In (p, n) m <-> In (p, n) m'.
Proof.
intros sitpn m t pre_places;
functional induction (update_marking_pre_aux sitpn m t pre_places)
using update_marking_pre_aux_ind;
intros fm Hfun p' Hnot_in_pre n.
(* BASE CASE *)
- injection Hfun as Hfun.
rewrite Hfun; reflexivity.
(* GENERAL CASE *)
- apply not_in_cons in Hnot_in_pre.
elim Hnot_in_pre; intros Hdiff_pp' Hnot_in_tl.
apply not_eq_sym in Hdiff_pp'.
specialize (modify_m_in_if_diff
marking p Nat.sub (pre sitpn t p)
m' e0 p' n Hdiff_pp') as Hequiv.
rewrite Hequiv.
apply (IHo fm Hfun p' Hnot_in_tl n).
(* ERROR CASE *)
- inversion Hfun.
Qed.
(** Correctness proof for [update_marking_pre_aux].
Express the structure of the returned [m'] regarding the structure
of [m].
Needed to prove update_marking_pre_correct. *)
Lemma update_marking_pre_aux_correct :
forall (sitpn : Sitpn)
(m : list (Place * nat))
(t : Trans)
(pre_places : list Place)
(m' : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
NoDup (fst (split m)) ->
NoDup pre_places ->
incl pre_places (pre_pl (lneighbours sitpn t)) ->
update_marking_pre_aux sitpn m t pre_places = Some m' ->
forall (p : Place) (n : nat),
In p pre_places ->
In (p, n) m ->
In (p, n - (pre sitpn t p)) m'.
Proof.
intros sitpn m t pre_places;
functional induction (update_marking_pre_aux sitpn m t pre_places)
using update_marking_pre_aux_ind;
intros fm Hwell_def_sitpn Hnodup_m
Hnodup_pre_pl Hincl_pre_pl Hfun p' n Hin_pre_pl Hin_resid.
(* BASE CASE, pre_places = []. *)
- inversion Hin_pre_pl.
(* GENERAL CASE *)
- inversion Hin_pre_pl as [Heq_pp' | Hin_p'_tail].
(* First subcase, p = p'. *)
+ rewrite <- Heq_pp' in Hin_pre_pl.
rewrite <- Heq_pp' in Hin_resid.
specialize (modify_m_correct
marking p Nat.sub (pre sitpn t p) m'
Hnodup_m e0 n Hin_resid) as Hin_resid'.
apply NoDup_cons_iff in Hnodup_pre_pl.
elim Hnodup_pre_pl; intros Hnot_in_tl Hnodup_tl.
rewrite Heq_pp' in Hnot_in_tl.
specialize (update_marking_pre_aux_not_in_pre_places
sitpn m' t tail fm
Hfun p' Hnot_in_tl (n - pre sitpn t p)) as Hin_equiv'.
rewrite Heq_pp' in Hin_resid'.
rewrite Heq_pp' in Hin_equiv'.
rewrite Hin_equiv' in Hin_resid'; assumption.
(* Second subcase, In p' tail, then apply induction hypothesis. *)
(* But we need to show NoDup (fst (split residual')) first. *)
+ specialize (modify_m_same_struct
marking p Nat.sub (pre sitpn t p) m' e0)
as Hsame_struct.
unfold MarkingHaveSameStruct in Hsame_struct.
rewrite Hsame_struct in Hnodup_m.
(* Builds the other hypotheses, needed to specialize IHo. *)
apply NoDup_cons_iff in Hnodup_pre_pl;
elim Hnodup_pre_pl;
intros Hnot_in_tl Hnodup_tl.
apply incl_cons_inv in Hincl_pre_pl.
(* Then specializes the induction hypothesis. *)
specialize (IHo fm Hwell_def_sitpn Hnodup_m
Hnodup_tl Hincl_pre_pl Hfun
p' n Hin_p'_tail) as Himpl.
specialize (not_in_in_diff p p' tail (conj Hnot_in_tl Hin_p'_tail))
as Hdiff_pp.
specialize (modify_m_in_if_diff
marking p Nat.sub (pre sitpn t p) m'
e0 p' n Hdiff_pp) as Hequiv'.
rewrite <- Hequiv' in Himpl.
apply (Himpl Hin_resid).
(* ERROR CASE *)
- inversion Hfun.
Qed.
(** No error lemma for update_marking_pre_aux. *)
Lemma update_marking_pre_aux_no_error :
forall (sitpn : Sitpn)
(t : Trans)
(pre_places : list Place)
(m : list (Place * nat)),
incl pre_places (fst (split m)) ->
exists m' : list (Place * nat),
update_marking_pre_aux sitpn m t pre_places = Some m'.
Proof.
intros sitpn t; induction pre_places; intros residual_marking Hincl_pre.
(* BASE CASE *)
- simpl; exists residual_marking; reflexivity.
(* INDUCTION CASE *)
- simpl.
assert (Hin_eq : In a (a :: pre_places)) by apply in_eq.
specialize (Hincl_pre a Hin_eq) as Hin_a_res.
specialize (modify_m_no_error residual_marking a Nat.sub (pre sitpn t a) Hin_a_res)
as Hmodify_ex.
inversion_clear Hmodify_ex as (m' & Hmodify).
rewrite Hmodify.
apply incl_cons_inv in Hincl_pre.
specialize (modify_m_same_struct residual_marking a Nat.sub (pre sitpn t a) m' Hmodify)
as Hsame_struct.
rewrite Hsame_struct in Hincl_pre.
apply (IHpre_places m' Hincl_pre).
Qed.
(** Correctness proof for [update_marking_pre].
Needed to prove GENERAL CASE in sitpn_fire_aux_sens_by_residual. *)
Lemma update_marking_pre_correct :
forall (sitpn : Sitpn)
(marking : list (Place * nat))
(t : Trans)
(final_marking : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
NoDup (fst (split marking)) ->
In t (transs sitpn) ->
update_marking_pre sitpn marking (lneighbours sitpn t) t = Some final_marking ->
forall (p : Place) (n : nat),
In (p, n) marking -> In (p, n - (pre sitpn t p)) final_marking.
Proof.
intros sitpn marking t;
functional induction (update_marking_pre sitpn marking (lneighbours sitpn t) t)
using update_marking_pre_ind;
intros final_marking Hwell_def_sitpn Hnodup_resm Hin_t_transs Hfun p n Hin_resm.
(* GENERAL CASE *)
- (* Two cases, either p ∈ (pre_pl neigh_of_t), or
p ∉ (pre_pl neigh_of_t). *)
assert (Hvee_in_pre_pl := classic (In p (pre_pl (lneighbours sitpn t)))).
inversion_clear Hvee_in_pre_pl as [Hin_p_pre | Hnotin_p_pre].
(* First case, p ∈ pre_pl, then applies update_marking_pre_aux_correct. *)
+ explode_well_defined_sitpn.
(* Builds NoDup pre_pl. *)
assert (Hin_flat : In p (flatten_neighbours (lneighbours sitpn t)))
by (unfold flatten_neighbours; apply in_or_app; left; assumption).
unfold NoDupInNeighbours in Hnodup_neigh.
specialize (Hnodup_neigh t Hin_t_transs) as Hnodup_flat.
apply proj1 in Hnodup_flat;
apply nodup_app in Hnodup_flat;
apply proj1 in Hnodup_flat.
(* Then, applies update_marking_pre_aux_correct. *)
apply (update_marking_pre_aux_correct
sitpn marking t (pre_pl (lneighbours sitpn t))
final_marking Hwell_def_sitpn Hnodup_resm Hnodup_flat
(incl_refl (pre_pl (lneighbours sitpn t)))
Hfun p n Hin_p_pre Hin_resm).
(* Second case, p ∉ pre_pl, then applies
update_marking_pre_aux_not_in_pre_places. *)
+ explode_well_defined_sitpn.
unfold AreWellDefinedPreEdges in Hwell_def_pre.
specialize (Hwell_def_pre t p Hin_t_transs) as Hw_pre_edges.
apply proj2 in Hw_pre_edges; specialize (Hw_pre_edges Hnotin_p_pre).
rewrite Hw_pre_edges; rewrite Nat.sub_0_r.
specialize (update_marking_pre_aux_not_in_pre_places
sitpn marking t (pre_pl (lneighbours sitpn t))
final_marking Hfun p Hnotin_p_pre n) as Hequiv.
rewrite <- Hequiv; assumption.
Qed.
(** No error lemma for [update_marking_pre]. *)
Lemma update_marking_pre_no_error :
forall (sitpn : Sitpn)
(marking : list (Place * nat))
(t : Trans),
IsWellDefinedSitpn sitpn ->
incl (flatten_neighbours (lneighbours sitpn t)) (fst (split marking)) ->
exists final_marking : list (Place * nat),
update_marking_pre sitpn marking (lneighbours sitpn t) t = Some final_marking.
Proof.
intros sitpn marking t Hwell_def_sitpn Hincl_flat.
explode_well_defined_sitpn.
unfold NoDupTranss in Hnodup_transs.
unfold update_marking_pre.
assert (Hincl_prepl : incl (pre_pl (lneighbours sitpn t)) (fst (split marking))).
{
intros x Hin_x_pre.
apply or_introl
with (B := In x ((test_pl (lneighbours sitpn t))
++ (inhib_pl (lneighbours sitpn t))
++ (post_pl (lneighbours sitpn t))))
in Hin_x_pre.
apply in_or_app in Hin_x_pre.
apply (Hincl_flat x Hin_x_pre).
}
apply (update_marking_pre_aux_no_error
sitpn t (pre_pl (lneighbours sitpn t)) marking Hincl_prepl).
Qed.
(**
* Correctness lemma for [map_update_marking_pre].
*
* map_update_marking_pre sitpn m fired = m' ⇒ m' = m - ∑ pre(t), ∀ t ∈ fired
*
* [map_update_marking_pre] substracts tokens in the pre-places
* of all transitions ∈ fired.
*
*)
Lemma map_update_marking_pre_sub_pre :
forall (sitpn : Sitpn)
(m : list (Place * nat))
(fired : list Trans)
(m' : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
NoDup (fst (split m)) ->
incl fired (transs sitpn) ->
map_update_marking_pre sitpn m fired = Some m' ->
forall (p : Place) (n : nat),
In (p, n) m -> In (p, n - pre_sum sitpn p fired) m'.
Proof.
intros sitpn m fired;
functional induction (map_update_marking_pre sitpn m fired) using map_update_marking_pre_ind;
intros fm Hwell_def_sitpn Hnodup_m Hincl_transs Hfun p n Hin_m.
(* BASE CASE *)
- injection Hfun as Heq_marking; rewrite <- Heq_marking.
simpl; rewrite Nat.sub_0_r; assumption.
(* GENERAL CASE *)
- specialize (Hincl_transs t (in_eq t tail)) as Hin_t_transs.
simpl.
rewrite Nat.sub_add_distr.
specialize (update_marking_pre_correct
sitpn marking t m' Hwell_def_sitpn Hnodup_m Hin_t_transs e0 p n Hin_m) as Hin_m'.
apply update_marking_pre_same_marking in e0;
unfold MarkingHaveSameStruct in e0;
rewrite e0 in Hnodup_m.
apply (IHo fm Hwell_def_sitpn Hnodup_m (incl_cons_inv t tail (transs sitpn) Hincl_transs)
Hfun p (n - pre sitpn t p) Hin_m').
(* ERROR CASE *)
- inversion Hfun.
Qed.
(** No error lemma for [map_update_marking_pre]. *)
Lemma map_update_marking_pre_no_error :
forall (sitpn : Sitpn)
(fired : list Trans)
(m : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
(forall (t : Trans),
In t fired ->
incl (flatten_neighbours (lneighbours sitpn t)) (fst (split m))) ->
exists m' : list (Place * nat),
map_update_marking_pre sitpn m fired = Some m'.
Proof.
intros sitpn; induction fired; intros m Hwell_def_sitpn Hincl_fl_m.
(* BASE CASE *)
- simpl; exists m; reflexivity.
(* INDUCTION CASE *)
- simpl.
assert (Hin_eq : In a (a :: fired)) by apply in_eq.
specialize (Hincl_fl_m a Hin_eq) as Hincl_flat.
specialize (update_marking_pre_no_error
sitpn m a Hwell_def_sitpn Hincl_flat)
as Hupdate_pre_ex.
inversion_clear Hupdate_pre_ex as ( final_marking & Hupdate_pre ).
rewrite Hupdate_pre.
specialize (update_marking_pre_same_marking sitpn m a final_marking Hupdate_pre)
as Hsame_struct.
rewrite Hsame_struct in Hincl_fl_m.
assert (Hincl_fl_tl :
forall t : Trans,
In t fired ->
incl (flatten_neighbours (lneighbours sitpn t)) (fst (split final_marking))).
{
intros t Hin_t_fired;
apply (in_cons a) in Hin_t_fired;
apply (Hincl_fl_m t Hin_t_fired).
}
apply (IHfired final_marking Hwell_def_sitpn Hincl_fl_tl).
Qed.
(** Needed to prove update_marking_post_aux_correct. *)
Lemma update_marking_post_aux_not_in_post_places :
forall (sitpn : Sitpn)
(m : list (Place * nat))
(t : Trans)
(post_places : list Place)
(m' : list (Place * nat)),
update_marking_post_aux sitpn m t post_places = Some m' ->
forall (p : Place),
~In p post_places ->
forall (n : nat), In (p, n) m <-> In (p, n) m'.
Proof.
intros sitpn m t post_places;
functional induction (update_marking_post_aux sitpn m t post_places)
using update_marking_post_aux_ind;
intros fm Hfun p' Hnot_in_post n.
(* BASE CASE *)
- injection Hfun as Hfun.
rewrite Hfun; reflexivity.
(* GENERAL CASE *)
- apply not_in_cons in Hnot_in_post.
elim Hnot_in_post; intros Hdiff_pp' Hnot_in_tl.
apply not_eq_sym in Hdiff_pp'.
specialize (modify_m_in_if_diff
marking p Nat.add (post sitpn t p)
m' e0 p' n Hdiff_pp') as Hequiv.
rewrite Hequiv.
apply (IHo fm Hfun p' Hnot_in_tl n).
(* ERROR CASE *)
- inversion Hfun.
Qed.
(** Correctness proof for [update_marking_post_aux].
Expostss the structure of the returned [m'] regarding the structure
of [m].
Needed to prove update_marking_post_correct. *)
Lemma update_marking_post_aux_correct :
forall (sitpn : Sitpn)
(m : list (Place * nat))
(t : Trans)
(post_places : list Place)
(m' : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
NoDup (fst (split m)) ->
NoDup post_places ->
incl post_places (post_pl (lneighbours sitpn t)) ->
update_marking_post_aux sitpn m t post_places = Some m' ->
forall (p : Place) (n : nat),
In p post_places ->
In (p, n) m ->
In (p, n + (post sitpn t p)) m'.
Proof.
intros sitpn m t post_places;
functional induction (update_marking_post_aux sitpn m t post_places)
using update_marking_post_aux_ind;
intros fm Hwell_def_sitpn Hnodup_m
Hnodup_post_pl Hincl_post_pl Hfun p' n Hin_post_pl Hin_resid.
(* BASE CASE, post_places = []. *)
- inversion Hin_post_pl.
(* GENERAL CASE *)
- inversion Hin_post_pl as [Heq_pp' | Hin_p'_tail].
(* First subcase, p = p'. *)
+ rewrite <- Heq_pp' in Hin_post_pl.
rewrite <- Heq_pp' in Hin_resid.
specialize (modify_m_correct
marking p Nat.add (post sitpn t p)
m' Hnodup_m e0 n Hin_resid) as Hin_resid'.
apply NoDup_cons_iff in Hnodup_post_pl.
elim Hnodup_post_pl; intros Hnot_in_tl Hnodup_tl.
rewrite Heq_pp' in Hnot_in_tl.
specialize (update_marking_post_aux_not_in_post_places
sitpn m' t tail
fm Hfun p' Hnot_in_tl (n + post sitpn t p)) as Hin_equiv'.
rewrite Heq_pp' in Hin_resid'.
rewrite Heq_pp' in Hin_equiv'.
rewrite Hin_equiv' in Hin_resid'; assumption.
(* Second subcase, In p' tail, then apply induction hypothesis. *)
(* But we need to show NoDup (fst (split residual')) first. *)
+ specialize (modify_m_same_struct
marking p Nat.add (post sitpn t p) m' e0)
as Hsame_struct.
unfold MarkingHaveSameStruct in Hsame_struct.
rewrite Hsame_struct in Hnodup_m.
(* Builds the other hypotheses, needed to specialize IHo. *)
apply NoDup_cons_iff in Hnodup_post_pl;
elim Hnodup_post_pl;
intros Hnot_in_tl Hnodup_tl.
apply incl_cons_inv in Hincl_post_pl.
(* Then specializes the induction hypothesis. *)
specialize (IHo fm Hwell_def_sitpn Hnodup_m
Hnodup_tl Hincl_post_pl Hfun
p' n Hin_p'_tail) as Himpl.
specialize (not_in_in_diff p p' tail (conj Hnot_in_tl Hin_p'_tail))
as Hdiff_pp.
specialize (@modify_m_in_if_diff
marking p Nat.add (post sitpn t p) m'
e0 p' n Hdiff_pp) as Hequiv'.
rewrite <- Hequiv' in Himpl.
apply (Himpl Hin_resid).
(* ERROR CASE *)
- inversion Hfun.
Qed.
(** No error lemma for update_marking_post_aux. *)
Lemma update_marking_post_aux_no_error :
forall (sitpn : Sitpn)
(t : Trans)
(post_places : list Place)
(m : list (Place * nat)),
incl post_places (fst (split m)) ->
exists m' : list (Place * nat),
update_marking_post_aux sitpn m t post_places = Some m'.
Proof.
intros sitpn t; induction post_places; intros residual_marking Hincl_post.
(* BASE CASE *)
- simpl; exists residual_marking; reflexivity.
(* INDUCTION CASE *)
- simpl.
assert (Hin_eq : In a (a :: post_places)) by apply in_eq.
specialize (Hincl_post a Hin_eq) as Hin_a_res.
specialize (modify_m_no_error residual_marking a Nat.add (post sitpn t a) Hin_a_res)
as Hmodify_ex.
inversion_clear Hmodify_ex as (m' & Hmodify).
rewrite Hmodify.
apply incl_cons_inv in Hincl_post.
specialize (@modify_m_same_struct residual_marking a Nat.add (post sitpn t a) m' Hmodify)
as Hsame_struct.
rewrite Hsame_struct in Hincl_post.
apply (IHpost_places m' Hincl_post).
Qed.
(** Correctness proof for [update_marking_post].
Needed to prove GENERAL CASE in sitpn_fire_aux_sens_by_residual. *)
Lemma update_marking_post_correct :
forall (sitpn : Sitpn)
(marking : list (Place * nat))
(t : Trans)
(final_marking : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
NoDup (fst (split marking)) ->
In t (transs sitpn) ->
update_marking_post sitpn marking (lneighbours sitpn t) t = Some final_marking ->
forall (p : Place) (n : nat),
In (p, n) marking -> In (p, n + (post sitpn t p)) final_marking.
Proof.
intros sitpn marking t;
functional induction (update_marking_post sitpn marking (lneighbours sitpn t) t)
using update_marking_post_ind;
intros final_marking Hwell_def_sitpn Hnodup_resm Hin_t_transs Hfun p n Hin_resm.
(* GENERAL CASE *)
- (* Two cases, either p ∈ (post_pl neigh_of_t), or
p ∉ (post_pl neigh_of_t). *)
assert (Hvee_in_post_pl := classic (In p (post_pl (lneighbours sitpn t)))).
inversion_clear Hvee_in_post_pl as [Hin_p_post | Hnotin_p_post].
(* First case, p ∈ post_pl, then applies update_marking_post_aux_correct. *)
+ explode_well_defined_sitpn.
(* Builds NoDup post_pl. *)
assert (Hin_flat : In p (flatten_neighbours (lneighbours sitpn t)))
by (unfold flatten_neighbours; do 3 (apply in_or_app; right); assumption).
unfold NoDupInNeighbours in Hnodup_neigh.
specialize (Hnodup_neigh t Hin_t_transs) as Hnodup_flat.
apply proj2 in Hnodup_flat.
(* Then, applies update_marking_post_aux_correct. *)
apply (@update_marking_post_aux_correct
sitpn marking t (post_pl (lneighbours sitpn t)) final_marking
Hwell_def_sitpn Hnodup_resm Hnodup_flat
(incl_refl (post_pl (lneighbours sitpn t))) Hfun p n Hin_p_post Hin_resm).
(* Second case, p ∉ post_pl, then applies
update_marking_post_aux_not_in_post_places. *)
+ explode_well_defined_sitpn.
unfold AreWellDefinedPostEdges in Hwell_def_post.
specialize (Hwell_def_post t p Hin_t_transs) as Hw_post_edges.
apply proj2 in Hw_post_edges; specialize (Hw_post_edges Hnotin_p_post).
rewrite Hw_post_edges. rewrite <- plus_n_O.
specialize (update_marking_post_aux_not_in_post_places
sitpn marking t (post_pl (lneighbours sitpn t))
final_marking Hfun p Hnotin_p_post n) as Hequiv.
rewrite <- Hequiv; assumption.
Qed.
(** No error lemma for [update_marking_post]. *)
Lemma update_marking_post_no_error :
forall (sitpn : Sitpn)
(marking : list (Place * nat))
(t : Trans),
IsWellDefinedSitpn sitpn ->
incl (flatten_neighbours (lneighbours sitpn t)) (fst (split marking)) ->
exists final_marking : list (Place * nat),
update_marking_post sitpn marking (lneighbours sitpn t) t = Some final_marking.
Proof.
intros sitpn marking t Hwell_def_sitpn Hincl_flat.
explode_well_defined_sitpn.
unfold NoDupTranss in Hnodup_transs.
unfold update_marking_post.
assert (Hincl_postpl : incl (post_pl (lneighbours sitpn t)) (fst (split marking))).
{
intros x Hin_x_post.
apply or_intror
with (A := In x (pre_pl (lneighbours sitpn t) ++ test_pl (lneighbours sitpn t) ++ inhib_pl (lneighbours sitpn t)))
in Hin_x_post.
apply in_or_app in Hin_x_post.
rewrite <- app_assoc in Hin_x_post.
rewrite <- app_assoc in Hin_x_post.
apply (Hincl_flat x Hin_x_post).
}
apply (update_marking_post_aux_no_error sitpn t (post_pl (lneighbours sitpn t)) marking Hincl_postpl).
Qed.
(**
* Correctness lemma for [map_update_marking_post].
*
* map_update_marking_post sitpn m fired = m' ⇒ m' = m - ∑ post(t), ∀ t ∈ fired
*
* [map_update_marking_post] substracts tokens in the post-places
* of all transitions ∈ fired.
*
*)
Lemma map_update_marking_post_add_post :
forall (sitpn : Sitpn)
(m : list (Place * nat))
(fired : list Trans)
(m' : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
NoDup (fst (split m)) ->
incl fired (transs sitpn) ->
map_update_marking_post sitpn m fired = Some m' ->
forall (p : Place) (n : nat),
In (p, n) m -> In (p, n + post_sum sitpn p fired) m'.
Proof.
intros sitpn m fired;
functional induction (map_update_marking_post sitpn m fired) using map_update_marking_post_ind;
intros fm Hwell_def_sitpn Hnodup_m Hincl_transs Hfun p n Hin_m.
(* BASE CASE *)
- injection Hfun as Heq_marking; rewrite <- Heq_marking.
simpl; rewrite <- (plus_n_O n); assumption.
(* GENERAL CASE *)
- specialize (Hincl_transs t (in_eq t tail)) as Hin_t_transs.
simpl.
rewrite <- plus_assoc_reverse.
specialize (@update_marking_post_correct
sitpn marking t m' Hwell_def_sitpn Hnodup_m Hin_t_transs e0 p n Hin_m) as Hin_m'.
apply update_marking_post_same_marking in e0;
unfold MarkingHaveSameStruct in e0;
rewrite e0 in Hnodup_m.
apply (IHo fm Hwell_def_sitpn Hnodup_m (incl_cons_inv t tail (transs sitpn) Hincl_transs)
Hfun p (n + post sitpn t p) Hin_m').
(* ERROR CASE *)
- inversion Hfun.
Qed.
(** No error lemma for [map_update_marking_post]. *)
Lemma map_update_marking_post_no_error :
forall (sitpn : Sitpn)
(fired : list Trans)
(m : list (Place * nat)),
IsWellDefinedSitpn sitpn ->
(forall (t : Trans),
In t fired ->
incl (flatten_neighbours (lneighbours sitpn t)) (fst (split m))) ->
exists m' : list (Place * nat),
map_update_marking_post sitpn m fired = Some m'.
Proof.
intros sitpn; induction fired; intros m Hwell_def_sitpn Hincl_fl_m.
(* BASE CASE *)
- simpl; exists m; reflexivity.
(* INDUCTION CASE *)
- simpl.
assert (Hin_eq : In a (a :: fired)) by apply in_eq.
specialize (Hincl_fl_m a Hin_eq) as Hincl_flat.
specialize (@update_marking_post_no_error
sitpn m a Hwell_def_sitpn Hincl_flat)
as Hupdate_post_ex.
inversion_clear Hupdate_post_ex as ( final_marking & Hupdate_post ).
rewrite Hupdate_post.
specialize (@update_marking_post_same_marking sitpn m a final_marking Hupdate_post)
as Hsame_struct.
rewrite Hsame_struct in Hincl_fl_m.
assert (Hincl_fl_tl :
forall t : Trans,
In t fired ->
incl (flatten_neighbours (lneighbours sitpn t)) (fst (split final_marking))).
{
intros t Hin_t_fired;
apply (in_cons a) in Hin_t_fired;
apply (Hincl_fl_m t Hin_t_fired).
}
apply (IHfired final_marking Hwell_def_sitpn Hincl_fl_tl).
Qed.
End SitpnUpdateMarking.
(** * Lemmas on [sitpn_rising_edge] and new marking computation. *)
Section SitpnRisingEdgeSubPreAddPost.
(** Marking at state [s'] is obtained by firing all transitions in (fired s) list.
[s'] is the state returned by [sitpn_rising_edge]. *)
Lemma sitpn_rising_edge_sub_pre_add_post :
forall (sitpn : Sitpn)
(s s' : SitpnState),
IsWellDefinedSitpn sitpn ->
IsWellDefinedSitpnState sitpn s ->
sitpn_rising_edge sitpn s = Some s' ->
forall (p : Place) (n : nat),
In (p, n) (marking s) ->
In (p, n - (pre_sum sitpn p s.(fired)) + (post_sum sitpn p s.(fired)))
(marking s').
Proof.
intros sitpn s;
functional induction (sitpn_rising_edge sitpn s) using sitpn_rising_edge_ind;
intros s' Hwell_def_sitpn Hwell_def_s Hfun p n Hin_ms;
(* GENERAL CASE *)
(
(* Builds premises to specialize map_update_marking_pre_sub_pre. *)
deduce_nodup_state_marking;
explode_well_defined_sitpn_state Hwell_def_s;
assert (Hincl_s_fired_transs := Hincl_state_fired_transs);
clear_well_defined_sitpn_state;
(* Specializes map_update_marking_pre_sub_pre. *)
specialize (map_update_marking_pre_sub_pre
sitpn (marking s) (fired s) transient_marking Hwell_def_sitpn
Hnodup_fs_ms Hincl_state_fired_transs e) as Hsub_pre;
(* Builds premises to specialize map_update_marking_post_add_post. *)
specialize (map_update_marking_pre_same_marking sitpn (marking s) (fired s) transient_marking e)
as Heq_ms_tm;
assert (Hnodup_fs_tm : NoDup (fst (split transient_marking)))
by (rewrite <- Heq_ms_tm; assumption);
(* Specializes map_update_marking_post_add_post. *)
specialize (map_update_marking_post_add_post
sitpn transient_marking (fired s) final_marking Hwell_def_sitpn
Hnodup_fs_tm Hincl_state_fired_transs e2) as Hadd_post;
(* Specializes Hsub_pre then Hadd_post, then rewrite the goal
to obtain an assumption. *)
specialize (Hsub_pre p n Hin_ms) as Hin_tm;
specialize (Hadd_post p (n - pre_sum sitpn p (fired s)) Hin_tm) as Hin_fm;
injection Hfun as Hfun; rewrite <- Hfun; simpl; assumption
)
(* ERROR CASES *)
|| inversion Hfun.
Qed.
End SitpnRisingEdgeSubPreAddPost.
|
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ s ∈ nonMemberSubfamily a 𝒜 ↔ s ∈ 𝒜 ∧ ¬a ∈ s
[PROOFSTEP]
simp [nonMemberSubfamily]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ s ∈ memberSubfamily a 𝒜 ↔ insert a s ∈ 𝒜 ∧ ¬a ∈ s
[PROOFSTEP]
simp_rw [memberSubfamily, mem_image, mem_filter]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ (∃ a_1, (a_1 ∈ 𝒜 ∧ a ∈ a_1) ∧ erase a_1 a = s) ↔ insert a s ∈ 𝒜 ∧ ¬a ∈ s
[PROOFSTEP]
refine' ⟨_, fun h => ⟨insert a s, ⟨h.1, by simp⟩, erase_insert h.2⟩⟩
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
h : insert a s ∈ 𝒜 ∧ ¬a ∈ s
⊢ a ∈ insert a s
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ (∃ a_1, (a_1 ∈ 𝒜 ∧ a ∈ a_1) ∧ erase a_1 a = s) → insert a s ∈ 𝒜 ∧ ¬a ∈ s
[PROOFSTEP]
rintro ⟨s, ⟨hs1, hs2⟩, rfl⟩
[GOAL]
case intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
a : α
s : Finset α
hs1 : s ∈ 𝒜
hs2 : a ∈ s
⊢ insert a (erase s a) ∈ 𝒜 ∧ ¬a ∈ erase s a
[PROOFSTEP]
rw [insert_erase hs2]
[GOAL]
case intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
a : α
s : Finset α
hs1 : s ∈ 𝒜
hs2 : a ∈ s
⊢ s ∈ 𝒜 ∧ ¬a ∈ erase s a
[PROOFSTEP]
exact ⟨hs1, not_mem_erase _ _⟩
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ✝ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 ℬ : Finset (Finset α)
⊢ memberSubfamily a (𝒜 ∩ ℬ) = memberSubfamily a 𝒜 ∩ memberSubfamily a ℬ
[PROOFSTEP]
unfold memberSubfamily
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ✝ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 ℬ : Finset (Finset α)
⊢ image (fun s => erase s a) (filter (fun s => a ∈ s) (𝒜 ∩ ℬ)) =
image (fun s => erase s a) (filter (fun s => a ∈ s) 𝒜) ∩ image (fun s => erase s a) (filter (fun s => a ∈ s) ℬ)
[PROOFSTEP]
rw [filter_inter_distrib, image_inter_of_injOn _ _ ((erase_injOn' _).mono _)]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ✝ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 ℬ : Finset (Finset α)
⊢ ↑(filter (fun s => a ∈ s) 𝒜) ∪ ↑(filter (fun s => a ∈ s) ℬ) ⊆ {s | a ∈ s}
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ✝ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 ℬ : Finset (Finset α)
⊢ memberSubfamily a (𝒜 ∪ ℬ) = memberSubfamily a 𝒜 ∪ memberSubfamily a ℬ
[PROOFSTEP]
simp_rw [memberSubfamily, filter_union, image_union]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ card (memberSubfamily a 𝒜) + card (nonMemberSubfamily a 𝒜) = card 𝒜
[PROOFSTEP]
rw [memberSubfamily, nonMemberSubfamily, card_image_of_injOn]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ card (filter (fun s => a ∈ s) 𝒜) + card (filter (fun s => ¬a ∈ s) 𝒜) = card 𝒜
[PROOFSTEP]
conv_rhs => rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
| card 𝒜
[PROOFSTEP]
rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
| card 𝒜
[PROOFSTEP]
rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
| card 𝒜
[PROOFSTEP]
rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ Set.InjOn (fun s => erase s a) ↑(filter (fun s => a ∈ s) 𝒜)
[PROOFSTEP]
apply (erase_injOn' _).mono
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ ↑(filter (fun s => a ∈ s) 𝒜) ⊆ {s | a ∈ s}
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ memberSubfamily a 𝒜 ∪ nonMemberSubfamily a 𝒜 = image (fun s => erase s a) 𝒜
[PROOFSTEP]
ext s
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
⊢ s ∈ memberSubfamily a 𝒜 ∪ nonMemberSubfamily a 𝒜 ↔ s ∈ image (fun s => erase s a) 𝒜
[PROOFSTEP]
simp only [mem_union, mem_memberSubfamily, mem_nonMemberSubfamily, mem_image, exists_prop]
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
⊢ insert a s ∈ 𝒜 ∧ ¬a ∈ s ∨ s ∈ 𝒜 ∧ ¬a ∈ s ↔ ∃ a_1, a_1 ∈ 𝒜 ∧ erase a_1 a = s
[PROOFSTEP]
constructor
[GOAL]
case a.mp
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
⊢ insert a s ∈ 𝒜 ∧ ¬a ∈ s ∨ s ∈ 𝒜 ∧ ¬a ∈ s → ∃ a_2, a_2 ∈ 𝒜 ∧ erase a_2 a = s
[PROOFSTEP]
rintro (h | h)
[GOAL]
case a.mp.inl
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
h : insert a s ∈ 𝒜 ∧ ¬a ∈ s
⊢ ∃ a_1, a_1 ∈ 𝒜 ∧ erase a_1 a = s
[PROOFSTEP]
exact ⟨_, h.1, erase_insert h.2⟩
[GOAL]
case a.mp.inr
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
h : s ∈ 𝒜 ∧ ¬a ∈ s
⊢ ∃ a_1, a_1 ∈ 𝒜 ∧ erase a_1 a = s
[PROOFSTEP]
exact ⟨_, h.1, erase_eq_of_not_mem h.2⟩
[GOAL]
case a.mpr
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
⊢ (∃ a_1, a_1 ∈ 𝒜 ∧ erase a_1 a = s) → insert a s ∈ 𝒜 ∧ ¬a ∈ s ∨ s ∈ 𝒜 ∧ ¬a ∈ s
[PROOFSTEP]
rintro ⟨s, hs, rfl⟩
[GOAL]
case a.mpr.intro.intro
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
hs : s ∈ 𝒜
⊢ insert a (erase s a) ∈ 𝒜 ∧ ¬a ∈ erase s a ∨ erase s a ∈ 𝒜 ∧ ¬a ∈ erase s a
[PROOFSTEP]
by_cases ha : a ∈ s
[GOAL]
case pos
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
hs : s ∈ 𝒜
ha : a ∈ s
⊢ insert a (erase s a) ∈ 𝒜 ∧ ¬a ∈ erase s a ∨ erase s a ∈ 𝒜 ∧ ¬a ∈ erase s a
[PROOFSTEP]
exact Or.inl ⟨by rwa [insert_erase ha], not_mem_erase _ _⟩
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
hs : s ∈ 𝒜
ha : a ∈ s
⊢ insert a (erase s a) ∈ 𝒜
[PROOFSTEP]
rwa [insert_erase ha]
[GOAL]
case neg
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
hs : s ∈ 𝒜
ha : ¬a ∈ s
⊢ insert a (erase s a) ∈ 𝒜 ∧ ¬a ∈ erase s a ∨ erase s a ∈ 𝒜 ∧ ¬a ∈ erase s a
[PROOFSTEP]
exact Or.inr ⟨by rwa [erase_eq_of_not_mem ha], not_mem_erase _ _⟩
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
hs : s ∈ 𝒜
ha : ¬a ∈ s
⊢ erase s a ∈ 𝒜
[PROOFSTEP]
rwa [erase_eq_of_not_mem ha]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ memberSubfamily a (memberSubfamily a 𝒜) = ∅
[PROOFSTEP]
ext
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
a✝ : Finset α
⊢ a✝ ∈ memberSubfamily a (memberSubfamily a 𝒜) ↔ a✝ ∈ ∅
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ memberSubfamily a (nonMemberSubfamily a 𝒜) = ∅
[PROOFSTEP]
ext
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
a✝ : Finset α
⊢ a✝ ∈ memberSubfamily a (nonMemberSubfamily a 𝒜) ↔ a✝ ∈ ∅
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ nonMemberSubfamily a (memberSubfamily a 𝒜) = memberSubfamily a 𝒜
[PROOFSTEP]
ext
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
a✝ : Finset α
⊢ a✝ ∈ nonMemberSubfamily a (memberSubfamily a 𝒜) ↔ a✝ ∈ memberSubfamily a 𝒜
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ nonMemberSubfamily a (nonMemberSubfamily a 𝒜) = nonMemberSubfamily a 𝒜
[PROOFSTEP]
ext
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
a✝ : Finset α
⊢ a✝ ∈ nonMemberSubfamily a (nonMemberSubfamily a 𝒜) ↔ a✝ ∈ nonMemberSubfamily a 𝒜
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
h₁ : s ∈ filter (fun s => erase s a ∈ 𝒜) 𝒜
h₂ : s ∈ filter (fun s => ¬s ∈ 𝒜) (image (fun s => erase s a) 𝒜)
⊢ False
[PROOFSTEP]
have := (mem_filter.1 h₂).2
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
h₁ : s ∈ filter (fun s => erase s a ∈ 𝒜) 𝒜
h₂ : s ∈ filter (fun s => ¬s ∈ 𝒜) (image (fun s => erase s a) 𝒜)
this : ¬s ∈ 𝒜
⊢ False
[PROOFSTEP]
exact this (mem_filter.1 h₁).1
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ s ∈ 𝓓 a 𝒜 ↔ s ∈ 𝒜 ∧ erase s a ∈ 𝒜 ∨ ¬s ∈ 𝒜 ∧ insert a s ∈ 𝒜
[PROOFSTEP]
simp_rw [compression, mem_disjUnion, mem_filter, mem_image, and_comm (a := (¬s ∈ 𝒜))]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ s ∈ 𝒜 ∧ erase s a ∈ 𝒜 ∨ (∃ a_1, a_1 ∈ 𝒜 ∧ erase a_1 a = s) ∧ ¬s ∈ 𝒜 ↔ s ∈ 𝒜 ∧ erase s a ∈ 𝒜 ∨ insert a s ∈ 𝒜 ∧ ¬s ∈ 𝒜
[PROOFSTEP]
refine'
or_congr_right
(and_congr_left fun hs => ⟨_, fun h => ⟨_, h, erase_insert <| insert_ne_self.1 <| ne_of_mem_of_not_mem h hs⟩⟩)
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
hs : ¬s ∈ 𝒜
⊢ (∃ a_1, a_1 ∈ 𝒜 ∧ erase a_1 a = s) → insert a s ∈ 𝒜
[PROOFSTEP]
rintro ⟨t, ht, rfl⟩
[GOAL]
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
a : α
t : Finset α
ht : t ∈ 𝒜
hs : ¬erase t a ∈ 𝒜
⊢ insert a (erase t a) ∈ 𝒜
[PROOFSTEP]
rwa [insert_erase (erase_ne_self.1 (ne_of_mem_of_not_mem ht hs).symm)]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
hs : s ∈ 𝒜
⊢ erase s a ∈ 𝓓 a 𝒜
[PROOFSTEP]
simp_rw [mem_compression, erase_idem, and_self_iff]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
hs : s ∈ 𝒜
⊢ erase s a ∈ 𝒜 ∨ ¬erase s a ∈ 𝒜 ∧ insert a (erase s a) ∈ 𝒜
[PROOFSTEP]
refine' (em _).imp_right fun h => ⟨h, _⟩
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
hs : s ∈ 𝒜
h : ¬erase s a ∈ 𝒜
⊢ insert a (erase s a) ∈ 𝒜
[PROOFSTEP]
rwa [insert_erase (erase_ne_self.1 (ne_of_mem_of_not_mem hs h).symm)]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ s ∈ 𝓓 a 𝒜 → erase s a ∈ 𝓓 a 𝒜
[PROOFSTEP]
simp_rw [mem_compression, erase_idem]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
⊢ s ∈ 𝒜 ∧ erase s a ∈ 𝒜 ∨ ¬s ∈ 𝒜 ∧ insert a s ∈ 𝒜 →
erase s a ∈ 𝒜 ∧ erase s a ∈ 𝒜 ∨ ¬erase s a ∈ 𝒜 ∧ insert a (erase s a) ∈ 𝒜
[PROOFSTEP]
refine' Or.imp (fun h => ⟨h.2, h.2⟩) fun h => _
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
h : ¬s ∈ 𝒜 ∧ insert a s ∈ 𝒜
⊢ ¬erase s a ∈ 𝒜 ∧ insert a (erase s a) ∈ 𝒜
[PROOFSTEP]
rwa [erase_eq_of_not_mem (insert_ne_self.1 <| ne_of_mem_of_not_mem h.2 h.1)]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
h : insert a s ∈ 𝓓 a 𝒜
⊢ s ∈ 𝓓 a 𝒜
[PROOFSTEP]
by_cases ha : a ∈ s
[GOAL]
case pos
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
h : insert a s ∈ 𝓓 a 𝒜
ha : a ∈ s
⊢ s ∈ 𝓓 a 𝒜
[PROOFSTEP]
rwa [insert_eq_of_mem ha] at h
[GOAL]
case neg
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
h : insert a s ∈ 𝓓 a 𝒜
ha : ¬a ∈ s
⊢ s ∈ 𝓓 a 𝒜
[PROOFSTEP]
rw [← erase_insert ha]
[GOAL]
case neg
α : Type u_1
inst✝ : DecidableEq α
𝒜 ℬ : Finset (Finset α)
s : Finset α
a : α
h : insert a s ∈ 𝓓 a 𝒜
ha : ¬a ∈ s
⊢ erase (insert a s) a ∈ 𝓓 a 𝒜
[PROOFSTEP]
exact erase_mem_compression_of_mem_compression h
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ 𝓓 a (𝓓 a 𝒜) = 𝓓 a 𝒜
[PROOFSTEP]
ext s
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
⊢ s ∈ 𝓓 a (𝓓 a 𝒜) ↔ s ∈ 𝓓 a 𝒜
[PROOFSTEP]
refine' mem_compression.trans ⟨_, fun h => Or.inl ⟨h, erase_mem_compression_of_mem_compression h⟩⟩
[GOAL]
case a
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
⊢ s ∈ 𝓓 a 𝒜 ∧ erase s a ∈ 𝓓 a 𝒜 ∨ ¬s ∈ 𝓓 a 𝒜 ∧ insert a s ∈ 𝓓 a 𝒜 → s ∈ 𝓓 a 𝒜
[PROOFSTEP]
rintro (h | h)
[GOAL]
case a.inl
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
h : s ∈ 𝓓 a 𝒜 ∧ erase s a ∈ 𝓓 a 𝒜
⊢ s ∈ 𝓓 a 𝒜
[PROOFSTEP]
exact h.1
[GOAL]
case a.inr
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
h : ¬s ∈ 𝓓 a 𝒜 ∧ insert a s ∈ 𝓓 a 𝒜
⊢ s ∈ 𝓓 a 𝒜
[PROOFSTEP]
cases h.1 (mem_compression_of_insert_mem_compression h.2)
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ card (𝓓 a 𝒜) = card 𝒜
[PROOFSTEP]
rw [compression, card_disjUnion, image_filter, card_image_of_injOn ((erase_injOn' _).mono fun s hs => _), ←
card_disjoint_union]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ card (filter (fun s => erase s a ∈ 𝒜) 𝒜 ∪ filter ((fun s => ¬s ∈ 𝒜) ∘ fun s => erase s a) 𝒜) = card 𝒜
[PROOFSTEP]
conv_rhs => rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ 𝒜)) 𝒜]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
| card 𝒜
[PROOFSTEP]
rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ 𝒜)) 𝒜]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
| card 𝒜
[PROOFSTEP]
rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ 𝒜)) 𝒜]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
| card 𝒜
[PROOFSTEP]
rw [← filter_union_filter_neg_eq (fun s => (erase s a ∈ 𝒜)) 𝒜]
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ Disjoint (filter (fun s => erase s a ∈ 𝒜) 𝒜) (filter ((fun s => ¬s ∈ 𝒜) ∘ fun s => erase s a) 𝒜)
[PROOFSTEP]
exact disjoint_filter_filter_neg 𝒜 𝒜 (fun s => (erase s a ∈ 𝒜))
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
⊢ ∀ (s : Finset α), s ∈ ↑(filter ((fun s => ¬s ∈ 𝒜) ∘ fun s => erase s a) 𝒜) → s ∈ {s | a ∈ s}
[PROOFSTEP]
intro s hs
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
hs : s ∈ ↑(filter ((fun s => ¬s ∈ 𝒜) ∘ fun s => erase s a) 𝒜)
⊢ s ∈ {s | a ∈ s}
[PROOFSTEP]
rw [mem_coe, mem_filter, Function.comp_apply] at hs
[GOAL]
α : Type u_1
inst✝ : DecidableEq α
𝒜✝ ℬ : Finset (Finset α)
s✝ : Finset α
a✝ a : α
𝒜 : Finset (Finset α)
s : Finset α
hs : s ∈ 𝒜 ∧ ¬erase s a ∈ 𝒜
⊢ s ∈ {s | a ∈ s}
[PROOFSTEP]
exact not_imp_comm.1 erase_eq_of_not_mem (ne_of_mem_of_not_mem hs.1 hs.2).symm
|
import tactic
open set
lemma useful2
(Y : set ℕ)
: (∀ (x : ℕ), ∃ (y : ℕ), x ≤ y ∧ y ∈ Y) → Y.infinite :=
begin
intros h hY,
obtain ⟨N, hN⟩ : bdd_above Y := finite.bdd_above hY,
obtain ⟨y, hNy, hyY⟩ : ∃ (y : ℕ), N + 1 ≤ y ∧ y ∈ Y := h (N + 1),
specialize hN hyY,
linarith,
end
|
C02W82DBHV2R:~ i847419$ coqtop
Welcome to Coq 8.8.0 (April 2018)
Coq < Require Import Classical.
Coq < Theorem exp015 : (forall P Q : Prop, ((P -> Q) /\ ~Q) -> ~P).
1 subgoal
============================
forall P Q : Prop, (P -> Q) /\ ~ Q -> ~ P
exp015 < intros.
1 subgoal
P, Q : Prop
H : (P -> Q) /\ ~ Q
============================
~ P
exp015 < destruct H.
1 subgoal
P, Q : Prop
H : P -> Q
H0 : ~ Q
============================
~ P
exp015 < tauto.
No more subgoals.
exp015 < Qed.
exp015 is defined
|
import data.real.basic
import data.int.parity
/-
In this file, we learn how to handle the ∃ quantifier.
In order to prove `∃ x, P x`, we give some x₀ using tactic `use x₀` and
then prove `P x₀`. This x₀ can be an object from the local context
or a more complicated expression.
-/
example : ∃ n : ℕ, 8 = 2*n :=
begin
use 4,
refl, -- this is the tactic analogue of the rfl proof term
end
/-
In order to use `h : ∃ x, P x`, we use the `cases` tactic to fix
one x₀ that works.
Again h can come straight from the local context or can be a more
complicated expression.
-/
example (n : ℕ) (h : ∃ k : ℕ, n = k + 1) : n > 0 :=
begin
-- Let's fix k₀ such that n = k₀ + 1.
cases h with k₀ hk₀,
-- It now suffices to prove k₀ + 1 > 0.
rw hk₀,
-- and we have a lemma about this
exact nat.succ_pos k₀,
end
/-
The next exercises use divisibility in ℤ (beware the ∣ symbol which is
not ASCII).
By definition, a ∣ b ↔ ∃ k, b = a*k, so you can prove a ∣ b using the
`use` tactic.
-/
-- Until the end of this file, a, b and c will denote integers, unless
-- explicitly stated otherwise
variables a b c : ℤ
-- 0029
example (h₁ : a ∣ b) (h₂ : b ∣ c) : a ∣ c :=
begin
cases h₁ with x₁ hx₁,
cases h₂ with x₂ hx₂,
use x₁ * x₂,
rw [hx₂, hx₁, mul_assoc],
end
/-
A very common pattern is to have an assumption or lemma asserting
h : ∃ x, y = ...
and this is used through the combo:
cases h with x hx,
rw hx at ...
The tactic `rcases` allows us to do recursive `cases`, as indicated by its name,
and also simplifies the above combo when the name hx is replaced by the special
name `rfl`, as in the following example.
It uses the anonymous constructor angle brackets syntax.
-/
example (h1 : a ∣ b) (h2 : a ∣ c) : a ∣ b+c :=
begin
rcases h1 with ⟨k, rfl⟩,
rcases h2 with ⟨l, rfl⟩,
use k+l,
ring,
end
/-
You can use the same `rfl` trick with the `rintros` tactic.
-/
example : a ∣ b → a ∣ c → a ∣ b+c :=
begin
rintros ⟨k, rfl⟩ ⟨l, rfl⟩,
use k+l,
ring,
end
-- 0030
example : 0 ∣ a ↔ a = 0 :=
begin
split; intro h,
show a = 0, by { rcases h with ⟨n, rfl⟩, ring },
show 0 ∣ a, by { use 0, rw h, refl }
end
/-
We can now start combining quantifiers, using the definition
surjective (f : X → Y) := ∀ y, ∃ x, f x = y
-/
open function
-- In the remaining of this file, f and g will denote functions from
-- ℝ to ℝ.
variables (f g : ℝ → ℝ)
-- 0031
example (h : surjective (g ∘ f)) : surjective g :=
begin
intro y,
rcases h y with ⟨x, rfl⟩,
use f x,
end
/-
The above exercise can be done in three lines. Try to do the
next exercise in four lines.
-/
-- 0032
example (hf : surjective f) (hg : surjective g) : surjective (g ∘ f) :=
begin
intro z,
rcases hg z with ⟨y, rfl⟩,
rcases hf y with ⟨z, rfl⟩,
use z,
end
|
record Album where
constructor MkAlbum
artist : String
title : String
year : Integer
help : Album
help = MkAlbum "The Beatles" "Help" 1965
rubbersoul : Album
rubbersoul = MkAlbum "The Beatles" "Rubber Soul" 1965
clouds : Album
clouds = MkAlbum "Joni Mitchell" "Clouds" 1969
hunkydory : Album
hunkydory = MkAlbum "David Bowie" "Hunky Dory" 1971
heroes : Album
heroes = MkAlbum "David Bowie" "Heroes" 1977
collection : List Album
collection = [help, rubbersoul, clouds, hunkydory, heroes]
Eq Album where
(==) (MkAlbum artist1 title1 year1) (MkAlbum artist2 title2 year2)
= artist1 == artist2 && title1 == title2 && year1 == year2
Ord Album where
compare (MkAlbum artist1 title1 year1) (MkAlbum artist2 title2 year2)
= case compare artist1 artist2 of
EQ => case compare title1 title2 of
EQ => compare year1 year2
diff_title => diff_title
diff_artist => diff_artist
Show Album where
show (MkAlbum artist title year)
= title ++ " by " ++ artist ++ " (released " ++ show year ++ ")"
|
(*
Author: Jose Divasón
Email: [email protected]
*)
section \<open>Some theorems about rings and ideals\<close>
theory Rings2_Extended
imports
Echelon_Form.Rings2
"HOL-Types_To_Sets.Types_To_Sets"
begin
subsection \<open>Missing properties on ideals\<close>
lemma ideal_generated_subset2:
assumes "\<forall>b\<in>B. b \<in> ideal_generated A"
shows "ideal_generated B \<subseteq> ideal_generated A"
by (metis (mono_tags, lifting) InterE assms ideal_generated_def
ideal_ideal_generated mem_Collect_eq subsetI)
context comm_ring_1
begin
lemma ideal_explicit: "ideal_generated S
= {y. \<exists>f U. finite U \<and> U \<subseteq> S \<and> (\<Sum>i\<in>U. f i * i) = y}"
by (simp add: ideal_generated_eq_left_ideal left_ideal_explicit)
end
lemma ideal_generated_minus:
assumes a: "a \<in> ideal_generated (S-{a})"
shows "ideal_generated S = ideal_generated (S-{a})"
proof (cases "a \<in> S")
case True note a_in_S = True
show ?thesis
proof
show "ideal_generated S \<subseteq> ideal_generated (S - {a})"
proof (rule ideal_generated_subset2, auto)
fix b assume b: "b \<in> S" show "b \<in> ideal_generated (S - {a})"
proof (cases "b = a")
case True
then show ?thesis using a by auto
next
case False
then show ?thesis using b
by (simp add: ideal_generated_in)
qed
qed
show "ideal_generated (S - {a}) \<subseteq> ideal_generated S"
by (rule ideal_generated_subset, auto)
qed
next
case False
then show ?thesis by simp
qed
lemma ideal_generated_dvd_eq:
assumes a_dvd_b: "a dvd b"
and a: "a \<in> S"
and a_not_b: "a \<noteq> b"
shows "ideal_generated S = ideal_generated (S - {b})"
proof
show "ideal_generated S \<subseteq> ideal_generated (S - {b})"
proof (rule ideal_generated_subset2, auto)
fix x assume x: "x \<in> S"
show "x \<in> ideal_generated (S - {b})"
proof (cases "x = b")
case True
obtain k where b_ak: "b = a * k" using a_dvd_b unfolding dvd_def by blast
let ?f = "\<lambda>c. k"
have "(\<Sum>i\<in>{a}. i * ?f i) = x" using True b_ak by auto
moreover have "{a} \<subseteq> S - {b}" using a_not_b a by auto
moreover have "finite {a}" by auto
ultimately show ?thesis
unfolding ideal_def
by (metis True b_ak ideal_def ideal_generated_in ideal_ideal_generated insert_subset right_ideal_def)
next
case False
then show ?thesis by (simp add: ideal_generated_in x)
qed
qed
show "ideal_generated (S - {b}) \<subseteq> ideal_generated S" by (rule ideal_generated_subset, auto)
qed
lemma ideal_generated_dvd_eq_diff_set:
assumes i_in_I: "i\<in>I" and i_in_J: "i \<notin> J" and i_dvd_j: "\<forall>j\<in>J. i dvd j"
and f: "finite J"
shows "ideal_generated I = ideal_generated (I - J)"
using f i_in_J i_dvd_j i_in_I
proof (induct J arbitrary: I)
case empty
then show ?case by auto
next
case (insert x J)
have "ideal_generated I = ideal_generated (I-{x})"
by (rule ideal_generated_dvd_eq[of i], insert insert.prems , auto)
also have "... = ideal_generated ((I-{x}) - J)"
by (rule insert.hyps, insert insert.prems insert.hyps, auto)
also have "... = ideal_generated (I - insert x J)"
using Diff_insert2[of I x J] by auto
finally show ?case .
qed
context comm_ring_1
begin
lemma ideal_generated_singleton_subset:
assumes d: "d \<in> ideal_generated S" and fin_S: "finite S"
shows "ideal_generated {d} \<subseteq> ideal_generated S"
proof
fix x assume x: "x \<in> ideal_generated {d}"
obtain k where x_kd: "x = k*d " using x using obtain_sum_ideal_generated[OF x]
by (metis finite.emptyI finite.insertI sum_singleton)
show "x \<in> ideal_generated S"
using d ideal_eq_right_ideal ideal_ideal_generated right_ideal_def mult_commute x_kd by auto
qed
lemma ideal_generated_singleton_dvd:
assumes i: "ideal_generated S = ideal_generated {d}" and x: "x \<in> S"
shows "d dvd x"
by (metis i x finite.intros dvd_ideal_generated_singleton
ideal_generated_in ideal_generated_singleton_subset)
lemma ideal_generated_UNIV_insert:
assumes "ideal_generated S = UNIV"
shows "ideal_generated (insert a S) = UNIV" using assms
using local.ideal_generated_subset by blast
lemma ideal_generated_UNIV_union:
assumes "ideal_generated S = UNIV"
shows "ideal_generated (A \<union> S) = UNIV"
using assms local.ideal_generated_subset
by (metis UNIV_I Un_subset_iff equalityI subsetI)
lemma ideal_explicit2:
assumes "finite S"
shows "ideal_generated S = {y. \<exists>f. (\<Sum>i\<in>S. f i * i) = y}"
by (smt Collect_cong assms ideal_explicit obtain_sum_ideal_generated mem_Collect_eq subsetI)
lemma ideal_generated_unit:
assumes u: "u dvd 1"
shows "ideal_generated {u} = UNIV"
proof -
have "x \<in> ideal_generated {u}" for x
proof -
obtain inv_u where inv_u: "inv_u * u = 1" using u unfolding dvd_def
using local.mult_ac(2) by blast
have "x = x * inv_u * u" using inv_u by (simp add: local.mult_ac(1))
also have "... \<in> {k * u |k. k \<in> UNIV}" by auto
also have "... = ideal_generated {u}" unfolding ideal_generated_singleton by simp
finally show ?thesis .
qed
thus ?thesis by auto
qed
lemma ideal_generated_dvd_subset:
assumes x: "\<forall>x \<in> S. d dvd x" and S: "finite S"
shows "ideal_generated S \<subseteq> ideal_generated {d}"
proof
fix x assume "x\<in> ideal_generated S"
from this obtain f where f: "(\<Sum>i\<in>S. f i * i) = x" using ideal_explicit2[OF S] by auto
have "d dvd (\<Sum>i\<in>S. f i * i)" by (rule dvd_sum, insert x, auto)
thus "x \<in> ideal_generated {d}"
using f dvd_ideal_generated_singleton' ideal_generated_in singletonI by blast
qed
lemma ideal_generated_mult_unit:
assumes f: "finite S" and u: "u dvd 1"
shows "ideal_generated ((\<lambda>x. u*x)` S) = ideal_generated S"
using f
proof (induct S)
case empty
then show ?case by auto
next
case (insert x S)
obtain inv_u where inv_u: "inv_u * u = 1" using u unfolding dvd_def
using mult_ac by blast
have f: "finite (insert (u*x) ((\<lambda>x. u*x)` S))" using insert.hyps by auto
have f2: "finite (insert x S)" by (simp add: insert(1))
have f3: "finite S" by (simp add: insert)
have f4: "finite ((*) u ` S)" by (simp add: insert)
have inj_ux: "inj_on (\<lambda>x. u*x) S" unfolding inj_on_def
by (auto, metis inv_u local.mult_1_left local.semiring_normalization_rules(18))
have "ideal_generated ((\<lambda>x. u*x)` (insert x S)) = ideal_generated (insert (u*x) ((\<lambda>x. u*x)` S))"
by auto
also have "... = {y. \<exists>f. (\<Sum>i\<in>insert (u*x) ((\<lambda>x. u*x)` S). f i * i) = y}"
using ideal_explicit2[OF f] by auto
also have "... = {y. \<exists>f. (\<Sum>i\<in>(insert x S). f i * i) = y}" (is "?L = ?R")
proof -
have "a \<in> ?L" if a: "a \<in> ?R" for a
proof -
obtain f where sum_rw: "(\<Sum>i\<in>(insert x S). f i * i) = a" using a by auto
define b where "b=(\<Sum>i\<in>S. f i * i)"
have "b \<in> ideal_generated S" unfolding b_def ideal_explicit2[OF f3] by auto
hence "b \<in> ideal_generated ((*) u ` S)" using insert.hyps(3) by auto
from this obtain g where "(\<Sum>i\<in>((*) u ` S). g i * i) = b"
unfolding ideal_explicit2[OF f4] by auto
hence sum_rw2: "(\<Sum>i\<in>S. f i * i) = (\<Sum>i\<in>((*) u ` S). g i * i)" unfolding b_def by auto
let ?g = "\<lambda>i. if i = u*x then f x * inv_u else g i"
have sum_rw3: "sum ((\<lambda>i. g i * i) \<circ> (\<lambda>x. u*x)) S = sum ((\<lambda>i. ?g i * i) \<circ> (\<lambda>x. u*x)) S"
by (rule sum.cong, auto, metis inv_u local.insert(2) local.mult_1_right
local.mult_ac(2) local.semiring_normalization_rules(18))
have sum_rw4: "(\<Sum>i\<in>(\<lambda>x. u*x)` S. g i * i) = sum ((\<lambda>i. g i * i) \<circ> (\<lambda>x. u*x)) S"
by (rule sum.reindex[OF inj_ux])
have "a = f x * x + (\<Sum>i\<in>S. f i * i)"
using sum_rw local.insert(1) local.insert(2) by auto
also have "... = f x * x + (\<Sum>i\<in>(\<lambda>x. u*x)` S. g i * i)" using sum_rw2 by auto
also have "... = ?g (u * x) * (u * x) + (\<Sum>i\<in>(\<lambda>x. u*x)` S. g i * i)"
using inv_u by (smt local.mult_1_right local.mult_ac(1))
also have "... = ?g (u * x) * (u * x) + sum ((\<lambda>i. g i * i) \<circ> (\<lambda>x. u*x)) S"
using sum_rw4 by auto
also have "... = ((\<lambda>i. ?g i * i) \<circ> (\<lambda>x. u*x)) x + sum ((\<lambda>i. g i * i) \<circ> (\<lambda>x. u*x)) S" by auto
also have "... = ((\<lambda>i. ?g i * i) \<circ> (\<lambda>x. u*x)) x + sum ((\<lambda>i. ?g i * i) \<circ> (\<lambda>x. u*x)) S"
using sum_rw3 by auto
also have "... = sum ((\<lambda>i. ?g i * i) \<circ> (\<lambda>x. u*x)) (insert x S)"
by (rule sum.insert[symmetric], auto simp add: insert)
also have "... = (\<Sum>i\<in>insert (u * x) ((\<lambda>x. u*x)` S). ?g i * i)"
by (smt abel_semigroup.commute f2 image_insert inv_u mult.abel_semigroup_axioms mult_1_right
semiring_normalization_rules(18) sum.reindex_nontrivial)
also have "... = (\<Sum>i\<in>(\<lambda>x. u*x)` (insert x S). ?g i * i)" by auto
finally show ?thesis by auto
qed
moreover have "a \<in> ?R" if a: "a \<in> ?L" for a
proof -
obtain f where sum_rw: "(\<Sum>i\<in>(insert (u * x) ((*) u ` S)). f i * i) = a" using a by auto
have ux_notin: "u*x \<notin> ((*) u ` S)"
by (metis UNIV_I inj_on_image_mem_iff inj_on_inverseI inv_u local.insert(2) local.mult_1_left
local.semiring_normalization_rules(18) subsetI)
let ?f = "(\<lambda>x. f x * x)"
have "sum ?f ((*) u ` S) \<in> ideal_generated ((*) u ` S)"
unfolding ideal_explicit2[OF f4] by auto
from this obtain g where sum_rw1: "sum (\<lambda>i. g i * i) S = sum ?f (((*) u ` S))"
using insert.hyps(3) unfolding ideal_explicit2[OF f3] by blast
let ?g = "(\<lambda>i. if i = x then (f (u*x) *u) * x else g i * i)"
let ?g' = "\<lambda>i. if i = x then f (u*x) * u else g i"
have sum_rw2: "sum (\<lambda>i. g i * i) S = sum ?g S" by (rule sum.cong, insert inj_ux ux_notin, auto)
have "a = (\<Sum>i\<in>(insert (u * x) ((*) u ` S)). f i * i)" using sum_rw by simp
also have "... = ?f (u*x) + sum ?f (((*) u ` S))"
by (rule sum.insert[OF f4], insert inj_ux) (metis UNIV_I inj_on_image_mem_iff inj_on_inverseI
inv_u local.insert(2) local.mult_1_left local.semiring_normalization_rules(18) subsetI)
also have "... = ?f (u*x) + sum (\<lambda>i. g i * i) S" unfolding sum_rw1 by auto
also have "... = ?g x + sum ?g S" unfolding sum_rw2 using mult.assoc by auto
also have "... = sum ?g (insert x S)" by (rule sum.insert[symmetric, OF f3 insert.hyps(2)])
also have "... = sum (\<lambda>i. ?g' i * i) (insert x S)" by (rule sum.cong, auto)
finally show ?thesis by fast
qed
ultimately show ?thesis by blast
qed
also have "... = ideal_generated (insert x S)" using ideal_explicit2[OF f2] by auto
finally show ?case by auto
qed
corollary ideal_generated_mult_unit2:
assumes u: "u dvd 1"
shows "ideal_generated {u*a,u*b} = ideal_generated {a,b}"
proof -
let ?S = "{a,b}"
have "ideal_generated {u*a,u*b} = ideal_generated ((\<lambda>x. u*x)` {a,b})" by auto
also have "... = ideal_generated {a,b}" by (rule ideal_generated_mult_unit[OF _ u], simp)
finally show ?thesis .
qed
lemma ideal_generated_1[simp]: "ideal_generated {1} = UNIV"
by (metis ideal_generated_unit dvd_ideal_generated_singleton order_refl)
lemma ideal_generated_pair: "ideal_generated {a,b} = {p*a+q*b | p q. True}"
proof -
have i: "ideal_generated {a,b} = {y. \<exists>f. (\<Sum>i\<in>{a,b}. f i * i) = y}" using ideal_explicit2 by auto
show ?thesis
proof (cases "a=b")
case True
show ?thesis using True i
by (auto, metis mult_ac(2) semiring_normalization_rules)
(metis (no_types, opaque_lifting) add_minus_cancel mult_ac ring_distribs semiring_normalization_rules)
next
case False
have 1: "\<exists>p q. (\<Sum>i\<in>{a, b}. f i * i) = p * a + q * b" for f
by (rule exI[of _ "f a"], rule exI[of _ "f b"], rule sum_two_elements[OF False])
moreover have "\<exists>f. (\<Sum>i\<in>{a, b}. f i * i) = p * a + q * b" for p q
by (rule exI[of _ "\<lambda>i. if i=a then p else q"],
unfold sum_two_elements[OF False], insert False, auto)
ultimately show ?thesis using i by auto
qed
qed
lemma ideal_generated_pair_exists_pq1:
assumes i: "ideal_generated {a,b} = (UNIV::'a set)"
shows "\<exists>p q. p*a + q*b = 1"
using i unfolding ideal_generated_pair
by (smt iso_tuple_UNIV_I mem_Collect_eq)
lemma ideal_generated_pair_UNIV:
assumes sa_tb_u: "s*a+t*b = u" and u: "u dvd 1"
shows "ideal_generated {a,b} = UNIV"
proof -
have f: "finite {a,b}" by simp
obtain inv_u where inv_u: "inv_u * u = 1" using u unfolding dvd_def
by (metis mult.commute)
have "x \<in> ideal_generated {a,b}" for x
proof (cases "a = b")
case True
then show ?thesis
by (metis UNIV_I dvd_def dvd_ideal_generated_singleton' ideal_generated_unit insert_absorb2
mult.commute sa_tb_u semiring_normalization_rules(34) subsetI subset_antisym u)
next
case False note a_not_b = False
let ?f = "\<lambda>y. if y = a then inv_u * x * s else inv_u * x * t"
have "(\<Sum>i\<in>{a,b}. ?f i * i) = ?f a * a + ?f b * b" by (rule sum_two_elements[OF a_not_b])
also have "... = x" using a_not_b sa_tb_u inv_u
by (auto, metis mult_ac(1) mult_ac(2) ring_distribs(1) semiring_normalization_rules(12))
finally show ?thesis unfolding ideal_explicit2[OF f] by auto
qed
thus ?thesis by auto
qed
lemma ideal_generated_pair_exists:
assumes l: "(ideal_generated {a,b} = ideal_generated {d})"
shows "(\<exists> p q. p*a+q*b = d)"
proof -
have d: "d \<in> ideal_generated {d}" by (simp add: ideal_generated_in)
hence "d \<in> ideal_generated {a,b}" using l by auto
from this obtain p q where "d = p*a+q*b" using ideal_generated_pair[of a b] by auto
thus ?thesis by auto
qed
lemma obtain_ideal_generated_pair:
assumes "c \<in> ideal_generated {a,b}"
obtains p q where "p*a+q*b=c"
proof -
have "c \<in> {p * a + q * b |p q. True}" using assms ideal_generated_pair by auto
thus ?thesis using that by auto
qed
lemma ideal_generated_pair_exists_UNIV:
shows "(ideal_generated {a,b} = ideal_generated {1}) = (\<exists>p q. p*a+q*b = 1)" (is "?lhs = ?rhs")
proof
assume r: ?rhs
have "x \<in> ideal_generated {a,b}" for x
proof (cases "a=b")
case True
then show ?thesis
by (metis UNIV_I r dvd_ideal_generated_singleton finite.intros ideal_generated_1
ideal_generated_pair_UNIV ideal_generated_singleton_subset)
next
case False
have f: "finite {a,b}" by simp
have 1: "1 \<in> ideal_generated {a,b}"
using ideal_generated_pair_UNIV local.one_dvd r by blast
hence i: "ideal_generated {a,b} = {y. \<exists>f. (\<Sum>i\<in>{a,b}. f i * i) = y}"
using ideal_explicit2[of "{a,b}"] by auto
from this obtain f where f: "f a * a + f b * b = 1" using sum_two_elements 1 False by auto
let ?f = "\<lambda>y. if y = a then x * f a else x * f b"
have "(\<Sum>i\<in>{a,b}. ?f i * i) = x" unfolding sum_two_elements[OF False] using f False
using mult_ac(1) ring_distribs(1) semiring_normalization_rules(12) by force
thus ?thesis unfolding i by auto
qed
thus ?lhs by auto
next
assume ?lhs thus ?rhs using ideal_generated_pair_exists[of a b 1] by auto
qed
corollary ideal_generated_UNIV_obtain_pair:
assumes "ideal_generated {a,b} = ideal_generated {1}"
shows " (\<exists>p q. p*a+q*b = d)"
proof -
obtain x y where "x*a+y*b = 1" using ideal_generated_pair_exists_UNIV assms by auto
hence "d*x*a+d*y*b=d"
using local.mult_ac(1) local.ring_distribs(1) local.semiring_normalization_rules(12) by force
thus ?thesis by auto
qed
lemma sum_three_elements:
shows "\<exists>x y z::'a. (\<Sum>i\<in>{a,b,c}. f i * i) = x * a + y * b + z * c"
proof (cases "a \<noteq> b \<and> b \<noteq> c \<and> a \<noteq> c")
case True
then show ?thesis by (auto, metis add.assoc)
next
case False
have 1: "\<exists>x y z. f c * c = x * c + y * c + z * c"
by (rule exI[of _ 0],rule exI[of _ 0], rule exI[of _ "f c"], auto)
have 2: "\<exists>x y z. f b * b + f c * c = x * b + y * b + z * c"
by (rule exI[of _ 0],rule exI[of _ "f b"], rule exI[of _ "f c"], auto)
have 3: "\<exists>x y z. f a * a + f c * c = x * a + y * c + z * c"
by (rule exI[of _ "f a"],rule exI[of _ 0], rule exI[of _ "f c"], auto)
have 4: "\<exists>x y z. (\<Sum>i\<in>{c, b, c}. f i * i) = x * c + y * b + z * c" if a: "a = c" and b: "b \<noteq> c"
by (rule exI[of _ 0],rule exI[of _ "f b"], rule exI[of _ "f c"], insert a b,
auto simp add: insert_commute)
show ?thesis using False
by (cases "b=c", cases "a=c", auto simp add: 1 2 3 4)
qed
lemma sum_three_elements':
shows "\<exists>f::'a\<Rightarrow>'a. (\<Sum>i\<in>{a,b,c}. f i * i) = x * a + y * b + z * c"
proof (cases "a \<noteq> b \<and> b \<noteq> c \<and> a \<noteq> c")
case True
let ?f = "\<lambda>i. if i = a then x else if i = b then y else if i = c then z else 0"
show ?thesis by (rule exI[of _ "?f"], insert True mult.assoc, auto simp add: local.add_ac)
next
case False
have 1: "\<exists>f. f c * c = x * c + y * c + z * c"
by (rule exI[of _ "\<lambda>i. if i = c then x+y+z else 0"], auto simp add: local.ring_distribs)
have 2: "\<exists>f. f a * a + f c * c = x * a + y * c + z * c" if bc: " b = c" and ac: "a \<noteq> c"
by (rule exI[of _ "\<lambda>i. if i = a then x else y+z"], insert ac bc add_ac ring_distribs, auto)
have 3: "\<exists>f. f b * b + f c * c = x * b + y * b + z * c" if bc: " b \<noteq> c" and ac: "a = b"
by (rule exI[of _ "\<lambda>i. if i = a then x+y else z"], insert ac bc add_ac ring_distribs, auto)
have 4: "\<exists>f. (\<Sum>i\<in>{c, b, c}. f i * i) = x * c + y * b + z * c" if a: "a = c" and b: "b \<noteq> c"
by (rule exI[of _ "\<lambda>i. if i = c then x+z else y"], insert a b add_ac ring_distribs,
auto simp add: insert_commute)
show ?thesis using False
by (cases "b=c", cases "a=c", auto simp add: 1 2 3 4)
qed
(*This is generalizable to arbitrary sets.*)
lemma ideal_generated_triple_pair_rewrite:
assumes i1: "ideal_generated {a, b, c} = ideal_generated {d}"
and i2: "ideal_generated {a, b} = ideal_generated {d'}"
shows "ideal_generated{d',c} = ideal_generated {d}"
proof
have d': "d' \<in> ideal_generated {a,b}" using i2 by (simp add: ideal_generated_in)
show "ideal_generated {d', c} \<subseteq> ideal_generated {d}"
proof
fix x assume x: "x \<in> ideal_generated {d', c}"
obtain f1 f2 where f: "f1*d' + f2*c = x" using obtain_ideal_generated_pair[OF x] by auto
obtain g1 g2 where g: "g1*a + g2*b = d'" using obtain_ideal_generated_pair[OF d'] by blast
have 1: "f1*g1*a + f1*g2*b + f2*c = x"
using f g local.ring_distribs(1) local.semiring_normalization_rules(18) by auto
have "x \<in> ideal_generated {a, b, c}"
proof -
obtain f where "(\<Sum>i\<in>{a,b,c}. f i * i) = f1*g1*a + f1*g2*b + f2*c"
using sum_three_elements' 1 by blast
moreover have "ideal_generated {a,b,c} = {y. \<exists>f. (\<Sum>i\<in>{a,b,c}. f i * i) = y}"
using ideal_explicit2[of "{a,b,c}"] by simp
ultimately show ?thesis using 1 by auto
qed
thus "x \<in> ideal_generated {d}" using i1 by auto
qed
show "ideal_generated {d} \<subseteq> ideal_generated {d', c}"
proof (rule ideal_generated_singleton_subset)
obtain f1 f2 f3 where f: "f1*a + f2*b + f3*c = d"
proof -
have "d \<in> ideal_generated {a,b,c}" using i1 by (simp add: ideal_generated_in)
from this obtain f where d: "(\<Sum>i\<in>{a,b,c}. f i * i) = d"
using ideal_explicit2[of "{a,b,c}"] by auto
obtain x y z where "(\<Sum>i\<in>{a,b,c}. f i * i) = x * a + y * b + z * c"
using sum_three_elements by blast
thus ?thesis using d that by auto
qed
obtain k where k: "f1*a + f2*b = k*d'"
proof -
have "f1*a + f2*b \<in> ideal_generated{a,b}" using ideal_generated_pair by blast
also have "... = ideal_generated {d'}" using i2 by simp
also have "... = {k*d' |k. k\<in>UNIV}" using ideal_generated_singleton by auto
finally show ?thesis using that by auto
qed
have "k*d'+f3*c=d" using f k by auto
thus "d \<in> ideal_generated {d', c}"
using ideal_generated_pair by blast
qed (simp)
qed
lemma ideal_generated_dvd:
assumes i: "ideal_generated {a,b::'a} = ideal_generated{d} "
and a: "d' dvd a" and b: "d' dvd b"
shows "d' dvd d"
proof -
obtain p q where "p*a+q*b = d"
using i ideal_generated_pair_exists by blast
thus ?thesis using a b by auto
qed
lemma ideal_generated_dvd2:
assumes i: "ideal_generated S = ideal_generated{d::'a} "
and "finite S"
and x: "\<forall>x\<in>S. d' dvd x"
shows "d' dvd d"
by (metis assms dvd_ideal_generated_singleton ideal_generated_dvd_subset)
end
subsection \<open>An equivalent characterization of B\'ezout rings\<close>
text \<open>The goal of this subsection is to prove that a ring is B\'ezout ring if and only if every
finitely generated ideal is principal.\<close>
definition "finitely_generated_ideal I = (ideal I \<and> (\<exists>S. finite S \<and> ideal_generated S = I))"
context
assumes "SORT_CONSTRAINT('a::comm_ring_1)"
begin
lemma sum_two_elements':
fixes d::'a
assumes s: "(\<Sum>i\<in>{a,b}. f i * i) = d"
obtains p and q where "d = p * a + q * b"
proof (cases "a=b")
case True
then show ?thesis
by (metis (no_types, lifting) add_diff_cancel_left' emptyE finite.emptyI insert_absorb2
left_diff_distrib' s sum.insert sum_singleton that)
next
case False
show ?thesis using s unfolding sum_two_elements[OF False]
using that by auto
qed
text \<open>This proof follows Theorem 6-3 in "First Course in Rings and Ideals" by Burton\<close>
lemma all_fin_gen_ideals_are_principal_imp_bezout:
assumes all: "\<forall>I::'a set. finitely_generated_ideal I \<longrightarrow> principal_ideal I"
shows "OFCLASS ('a, bezout_ring_class)"
proof (intro_classes)
fix a b::'a
obtain d where ideal_d: "ideal_generated {a,b} = ideal_generated {d}"
using all unfolding finitely_generated_ideal_def
by (metis finite.emptyI finite_insert ideal_ideal_generated principal_ideal_def)
have a_in_d: "a \<in> ideal_generated {d}"
using ideal_d ideal_generated_subset_generator by blast
have b_in_d: "b \<in> ideal_generated {d}"
using ideal_d ideal_generated_subset_generator by blast
have d_in_ab: "d \<in> ideal_generated {a,b}"
using ideal_d ideal_generated_subset_generator by auto
obtain f where "(\<Sum>i\<in>{a,b}. f i * i) = d" using obtain_sum_ideal_generated[OF d_in_ab] by auto
from this obtain p q where d_eq: "d = p*a + q*b" using sum_two_elements' by blast
moreover have d_dvd_a: "d dvd a"
by (metis dvd_ideal_generated_singleton ideal_d ideal_generated_subset insert_commute
subset_insertI)
moreover have "d dvd b"
by (metis dvd_ideal_generated_singleton ideal_d ideal_generated_subset subset_insertI)
moreover have "d' dvd d" if d'_dvd: "d' dvd a \<and> d' dvd b" for d'
proof -
obtain s1 s2 where s1_dvd: "a = s1*d'" and s2_dvd: "b = s2*d'"
using mult.commute d'_dvd unfolding dvd_def by auto
have "d = p*a + q*b" using d_eq .
also have "...= p * s1 * d' + q * s2 *d'" unfolding s1_dvd s2_dvd by auto
also have "... = (p * s1 + q * s2) * d'" by (simp add: ring_class.ring_distribs(2))
finally show "d' dvd d" using mult.commute unfolding dvd_def by auto
qed
ultimately show "\<exists>p q d. p * a + q * b = d \<and> d dvd a \<and> d dvd b
\<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d)" by auto
qed
end
context bezout_ring
begin
lemma exists_bezout_extended:
assumes S: "finite S" and ne: "S \<noteq> {}"
shows "\<exists>f d. (\<Sum>a\<in>S. f a * a) = d \<and> (\<forall>a\<in>S. d dvd a) \<and> (\<forall>d'. (\<forall>a\<in>S. d' dvd a) \<longrightarrow> d' dvd d)"
using S ne
proof (induct S)
case empty
then show ?case by auto
next
case (insert x S)
show ?case
proof (cases "S={}")
case True
let ?f = "\<lambda>x. 1"
show ?thesis by (rule exI[of _ ?f], insert True, auto)
next
case False note ne = False
note x_notin_S = insert.hyps(2)
obtain f d where sum_eq_d: "(\<Sum>a\<in>S. f a * a) = d"
and d_dvd_each_a: "(\<forall>a\<in>S. d dvd a)"
and d_is_gcd: "(\<forall>d'. (\<forall>a\<in>S. d' dvd a) \<longrightarrow> d' dvd d)"
using insert.hyps(3)[OF ne] by auto
have "\<exists>p q d'. p * d + q * x = d' \<and> d' dvd d \<and> d' dvd x \<and> (\<forall>c. c dvd d \<and> c dvd x \<longrightarrow> c dvd d')"
using exists_bezout by auto
from this obtain p q d' where pd_qx_d': "p*d + q*x = d'"
and d'_dvd_d: "d' dvd d" and d'_dvd_x: "d' dvd x"
and d'_dvd: "\<forall>c. (c dvd d \<and> c dvd x) \<longrightarrow> c dvd d'" by blast
let ?f = "\<lambda>a. if a = x then q else p * f a"
have "(\<Sum>a\<in>insert x S. ?f a * a) = d'"
proof -
have "(\<Sum>a\<in>insert x S. ?f a * a) = (\<Sum>a\<in>S. ?f a * a) + ?f x * x"
by (simp add: add_commute insert.hyps(1) insert.hyps(2))
also have "... = p * (\<Sum>a\<in>S. f a * a) + q * x"
unfolding sum_distrib_left
by (auto, rule sum.cong, insert x_notin_S,
auto simp add: mult.semigroup_axioms semigroup.assoc)
finally show ?thesis using pd_qx_d' sum_eq_d by auto
qed
moreover have "(\<forall>a\<in>insert x S. d' dvd a)"
by (metis d'_dvd_d d'_dvd_x d_dvd_each_a insert_iff local.dvdE local.dvd_mult_left)
moreover have " (\<forall>c. (\<forall>a\<in>insert x S. c dvd a) \<longrightarrow> c dvd d')"
by (simp add: d'_dvd d_is_gcd)
ultimately show ?thesis by auto
qed
qed
end
lemma ideal_generated_empty: "ideal_generated {} = {0}"
unfolding ideal_generated_def using ideal_generated_0
by (metis empty_subsetI ideal_generated_def ideal_generated_subset ideal_ideal_generated
ideal_not_empty subset_singletonD)
lemma bezout_imp_all_fin_gen_ideals_are_principal:
fixes I::"'a :: bezout_ring set"
assumes fin: "finitely_generated_ideal I"
shows "principal_ideal I"
proof -
obtain S where fin_S: "finite S" and ideal_gen_S: "ideal_generated S = I"
using fin unfolding finitely_generated_ideal_def by auto
show ?thesis
proof (cases "S = {}")
case True
then show ?thesis
using ideal_gen_S unfolding True
using ideal_generated_empty ideal_generated_0 principal_ideal_def by fastforce
next
case False note ne = False
obtain d f where sum_S_d: "(\<Sum>i\<in>S. f i * i) = d"
and d_dvd_a: "(\<forall>a\<in>S. d dvd a)" and d_is_gcd: "(\<forall>d'. (\<forall>a\<in>S. d' dvd a) \<longrightarrow> d' dvd d)"
using exists_bezout_extended[OF fin_S ne] by auto
have d_in_S: "d \<in> ideal_generated S"
by (metis fin_S ideal_def ideal_generated_subset_generator
ideal_ideal_generated sum_S_d sum_left_ideal)
have "ideal_generated {d} \<subseteq> ideal_generated S"
by (rule ideal_generated_singleton_subset[OF d_in_S fin_S])
moreover have "ideal_generated S \<subseteq> ideal_generated {d}"
proof
fix x assume x_in_S: "x \<in> ideal_generated S"
obtain f where sum_S_x: "(\<Sum>a\<in>S. f a * a) = x"
using fin_S obtain_sum_ideal_generated x_in_S by blast
have d_dvd_each_a: "\<exists>k. a = k * d" if "a \<in> S" for a
by (metis d_dvd_a dvdE mult.commute that)
let ?g = "\<lambda>a. SOME k. a = k*d"
have "x = (\<Sum>a\<in>S. f a * a)" using sum_S_x by simp
also have "... = (\<Sum>a\<in>S. f a * (?g a * d))"
proof (rule sum.cong)
fix a assume a_in_S: "a \<in> S"
obtain k where a_kd: "a = k * d" using d_dvd_each_a a_in_S by auto
have "a = ((SOME k. a = k * d) * d)" by (rule someI_ex, auto simp add: a_kd)
thus "f a * a = f a * ((SOME k. a = k * d) * d)" by auto
qed (simp)
also have "... = (\<Sum>a\<in>S. f a * ?g a * d)" by (rule sum.cong, auto)
also have "... = (\<Sum>a\<in>S. f a * ?g a)*d" using sum_distrib_right[of _ S d] by auto
finally show "x \<in> ideal_generated {d}"
by (meson contra_subsetD dvd_ideal_generated_singleton' dvd_triv_right
ideal_generated_in singletonI)
qed
ultimately show ?thesis unfolding principal_ideal_def using ideal_gen_S by auto
qed
qed
text \<open>Now we have the required lemmas to prove the theorem that states that
a ring is B\'ezout ring if and only if every
finitely generated ideal is principal. They are the following ones.
\begin{itemize}
\item @{text "all_fin_gen_ideals_are_principal_imp_bezout"}
\item @{text "bezout_imp_all_fin_gen_ideals_are_principal"}
\end{itemize}
However, in order to prove the final lemma, we need the lemmas with no type restrictions.
For instance, we need a version of theorem @{text "bezout_imp_all_fin_gen_ideals_are_principal"}
as
@{text "OFCLASS('a,bezout_ring) \<Longrightarrow>"} the theorem with generic types
(i.e., @{text "'a"} with no type restrictions)
or as
@{text "class.bezout_ring _ _ _ _ \<Longrightarrow>"} the theorem with generic
types (i.e., @{text "'a"} with no type restrictions)
\<close>
(*A possible workaround is to adapt the proof*)
(*
lemma bezout_imp_all_fin_gen_ideals_are_principal_unsatisfactory:
assumes a1: "class.bezout_ring ( * ) (1::'a::comm_ring_1) (+) 0 (-) uminus" (*Me da igual esto que OFCLASS*)
shows "\<forall>I::'a set. finitely_generated_ideal I \<longrightarrow> principal_ideal I"
proof (rule allI, rule impI)
fix I::"'a set" assume fin: "finitely_generated_ideal I"
interpret a: bezout_ring "( * )" "(1::'a)" "(+)" 0 "(-)" uminus using a1 .
interpret dvd "( * )::'a\<Rightarrow>'a\<Rightarrow>'a" .
interpret b: comm_monoid_add "(+)" "(0::'a)" using a1 by intro_locales
have c: " class.comm_monoid_add (+) (0::'a)" using a1 by intro_locales
have [simp]: "(dvd.dvd ( * ) d a) = (d dvd a)" for d a::'a
by (auto simp add: dvd.dvd_def dvd_def)
have [simp]: "comm_monoid_add.sum (+) 0 (\<lambda>a. f a * a) S = sum (\<lambda>a. f a * a) S"
for f and S::"'a set"
unfolding sum_def unfolding comm_monoid_add.sum_def[OF c] ..
obtain S where fin_S: "finite S" and ideal_gen_S: "ideal_generated S = I"
using fin unfolding finitely_generated_ideal_def by auto
show "principal_ideal I"
proof (cases "S = {}")
case True
then show ?thesis
using ideal_gen_S unfolding True
using ideal_generated_empty ideal_generated_0 principal_ideal_def by fastforce
next
case False note ne = False
obtain d f where sum_S_d: "(\<Sum>i\<in>S. f i * i) = d"
and d_dvd_a: "(\<forall>a\<in>S. d dvd a)" and d_is_gcd: "(\<forall>d'. (\<forall>a\<in>S. d' dvd a) \<longrightarrow> d' dvd d)"
using a.exists_bezout_extended[OF fin_S ne] by auto
have d_in_S: "d \<in> ideal_generated S"
by (metis fin_S ideal_def ideal_generated_subset_generator
ideal_ideal_generated sum_S_d sum_left_ideal)
have "ideal_generated {d} \<subseteq> ideal_generated S"
by (rule ideal_generated_singleton_subset[OF d_in_S fin_S])
moreover have "ideal_generated S \<subseteq> ideal_generated {d}"
proof
fix x assume x_in_S: "x \<in> ideal_generated S"
obtain f where sum_S_x: "(\<Sum>a\<in>S. f a * a) = x"
using fin_S obtain_sum_ideal_generated x_in_S by blast
have d_dvd_each_a: "\<exists>k. a = k * d" if "a \<in> S" for a
by (metis d_dvd_a dvdE mult.commute that)
let ?g = "\<lambda>a. SOME k. a = k*d"
have "x = (\<Sum>a\<in>S. f a * a)" using sum_S_x by simp
also have "... = (\<Sum>a\<in>S. f a * (?g a * d))"
proof (rule sum.cong)
fix a assume a_in_S: "a \<in> S"
obtain k where a_kd: "a = k * d" using d_dvd_each_a a_in_S by auto
have "a = ((SOME k. a = k * d) * d)" by (rule someI_ex, auto simp add: a_kd)
thus "f a * a = f a * ((SOME k. a = k * d) * d)" by auto
qed (simp)
also have "... = (\<Sum>a\<in>S. f a * ?g a * d)" by (rule sum.cong, auto)
also have "... = (\<Sum>a\<in>S. f a * ?g a)*d" using sum_distrib_right[of _ S d] by auto
finally show "x \<in> ideal_generated {d}"
by (meson contra_subsetD dvd_ideal_generated_singleton' dvd_triv_right
ideal_generated_in singletonI)
qed
ultimately show ?thesis unfolding principal_ideal_def using ideal_gen_S by auto
qed
qed
*)
text \<open>Thanks to local type definitions, we can obtain it automatically by means
of @{text "internalize-sort"}.\<close>
lemma bezout_imp_all_fin_gen_ideals_are_principal_unsatisfactory:
assumes a1: "class.bezout_ring (*) (1::'b::comm_ring_1) (+) 0 (-) uminus" (*It is algo possible to prove it using OFCLASS*)
shows "\<forall>I::'b set. finitely_generated_ideal I \<longrightarrow> principal_ideal I"
using bezout_imp_all_fin_gen_ideals_are_principal[internalize_sort "'a::bezout_ring"]
using a1 by auto
text \<open>The standard library does not connect @{text "OFCLASS"} and @{text "class.bezout_ring"}
in both directions. Here we show that @{text "OFCLASS \<Longrightarrow> class.bezout_ring"}. \<close>
lemma OFCLASS_bezout_ring_imp_class_bezout_ring:
assumes "OFCLASS('a::comm_ring_1,bezout_ring_class)"
shows "class.bezout_ring ((*)::'a\<Rightarrow>'a\<Rightarrow>'a) 1 (+) 0 (-) uminus"
using assms
unfolding bezout_ring_class_def class.bezout_ring_def
using conjunctionD2[of "OFCLASS('a, comm_ring_1_class)"
"class.bezout_ring_axioms ((*)::'a\<Rightarrow>'a\<Rightarrow>'a) (+)"]
by (auto, intro_locales)
text \<open>The other implication can be obtained
by thm @{text "Rings2.class.Rings2.bezout_ring.of_class.intro"} \<close>
thm Rings2.class.Rings2.bezout_ring.of_class.intro
(*OFCLASS is a proposition (Prop), and then the following statement is not valid.*)
(*
lemma
shows "(\<forall>I::'a::comm_ring_1 set. finitely_generated_ideal I \<longrightarrow> principal_ideal I)
= OFCLASS('a, bezout_ring_class)"
*)
(*Thus, we use the meta-equality and the meta universal quantifier.*)
text \<open>Final theorem (with OFCLASS)\<close>
lemma bezout_ring_iff_fin_gen_principal_ideal:
"(\<And>I::'a::comm_ring_1 set. finitely_generated_ideal I \<Longrightarrow> principal_ideal I)
\<equiv> OFCLASS('a, bezout_ring_class)"
proof
show "(\<And>I::'a::comm_ring_1 set. finitely_generated_ideal I \<Longrightarrow> principal_ideal I)
\<Longrightarrow> OFCLASS('a, bezout_ring_class)"
using all_fin_gen_ideals_are_principal_imp_bezout [where ?'a='a] by auto
show "\<And>I::'a::comm_ring_1 set. OFCLASS('a, bezout_ring_class)
\<Longrightarrow> finitely_generated_ideal I \<Longrightarrow> principal_ideal I"
using bezout_imp_all_fin_gen_ideals_are_principal_unsatisfactory[where ?'b='a]
using OFCLASS_bezout_ring_imp_class_bezout_ring[where ?'a='a] by auto
qed
text \<open>Final theorem (with @{text "class.bezout_ring"})\<close>
lemma bezout_ring_iff_fin_gen_principal_ideal2:
"(\<forall>I::'a::comm_ring_1 set. finitely_generated_ideal I \<longrightarrow> principal_ideal I)
= (class.bezout_ring ((*)::'a\<Rightarrow>'a\<Rightarrow>'a) 1 (+) 0 (-) uminus)"
proof
show "\<forall>I::'a::comm_ring_1 set. finitely_generated_ideal I \<longrightarrow> principal_ideal I
\<Longrightarrow> class.bezout_ring (*) 1 (+) (0::'a) (-) uminus"
using all_fin_gen_ideals_are_principal_imp_bezout[where ?'a='a]
using OFCLASS_bezout_ring_imp_class_bezout_ring[where ?'a='a]
by auto
show "class.bezout_ring (*) 1 (+) (0::'a) (-) uminus \<Longrightarrow> \<forall>I::'a set.
finitely_generated_ideal I \<longrightarrow> principal_ideal I"
using bezout_imp_all_fin_gen_ideals_are_principal_unsatisfactory by auto
qed
end
|
The document collection we work with comes directly from webscraping various Czech news servers, and does not have any special structure. The documents consist only of headlines, bodies and publication days. Furthermore, there are some noisy words such as residual HTML entities, typos, words cut in the middle, etc. To make the most of the collection, we preprocess the documents to remove as many of these errors as possible, and also to gain some additional information about the text.
We first employ some NLP (Natural Language Processing) methods to gain insight into the data. Then, we train a model to obtain word embeddings, which we discuss next.
Our event detection method is keyword-based --- the events will be represented by groups of keywords related in the temporal as well as semantic domain. To be able to measure the semantic similarity, we need to obtain a representation of the individual words that retains as much semantic information as possible while supporting similarity queries. There is a number of ways to do so --- a simple TFIDF (Term Frequency-Inverse Document Frequency) representation \citep{tfidf, information-retrieval} which represents the words by weighted counts of their appearance in the document collection. More complicated methods, such as Latent Semantic Indexing \citep{lsi} attempt to discover latent structure within words to also reveal topical relations between them. This idea is further pursued by probabilistic topical models, such as Latent Dirichlet Allocation \citep{lda}.
In this thesis, we use the Word2Vec model introduced by \cite{word2vec, distributed-representations, linguistic-regularities}, which uses a shallow neural network to project the words from a predetermined vocabulary into a vector space. Vectors in this space have interesting semantical properties, such as vector arithmetics preserving semantic relations, or semantically related words forming clusters. A useful property of the Word2Vec model is that it supports online learning, meaning that the training can be stopped and resumed as needed. We can then train the model on one document collection, and only perform small updates when we receive new documents with different vocabulary.
Later on, we will need some sort of word similarity measure. This will come up several times in the course of the thesis --- in the event detection itself, later when querying the document collection to obtain document representation of the events detected, and finally when generating human-readable summaries. The Word2Vec model is fit for all of these uses, as opposed to the other approaches mentioned above, some of which are designed only to measure document similarity, or, on the other hand, do not support document similarity queries very well.
\section{Preprocessing}
Some of the documents contain residual HTML entities from errors during web scraping, which we filter out using a manually constructed stopwords list.
We used the MorphoDiTa tagger \citep{morphodita} to perform tokenization, lemmatization and parts of speech tagging. Our whole analysis is applied to these lemmatized texts; we revert to the full forms only at the end when annotating the events in a human-readable way.
\section{Word embeddings} \label{word-embeddings}
Next, we train the previously mentioned Word2Vec model. Although the training is time-consuming \footnote{See \autoref{chap:evaluation} for computation times.}, the word vectors can be pre-trained on a large document collection and then reused in following runs. In case the vocabulary used in these new documents differs, the model can be simply updated with the new words.
For the training, we only discard punctuation marks and words denoted as unknown parts of speech by the tagger. Such words are mostly typos not important for our analysis. We also discard words appearing in less than 10 documents.
The thesis was implemented using the Gensim \citep{gensim} library. The project contains memory efficient, easy to use Python implementations of various topic modeling algorithms, Word2Vec included. In addition, we used the SciPy toolkit \citep{scipy} and Scikit-Learn \citep{scikit-learn} for various machine learning-related computations.
We use the skip-gram model defined in \cite{word2vec}, which was shown in \cite{distributed-representations} to learn high quality word embeddings well capturing semantic properties. After experimenting with different settings on a smaller subset of the documents, we decided to embed the words in a 100-dimensional vector space and to allow 5 passes over the document collection. Allowing more passes slows down the training, while not improving the quality very much. Setting higher dimensionality also does not lead to significant quality improvement, and slows down the training as well as requires more memory.
In the thesis, we refer to the vector embedding of a word $w$ as $\embed_{w} \in \R^{100}$.
\section{Document collection}
The dataset used is a collection of Czech news documents from various sources accumulated over a period from January 1, 2014 to January 31, 2015. The collection contains 2,078,774 documents averaging at 260 words each, with 2,058,316 unique word tokens in total. However, majority of the words are rare words or typos of no importance, so the number of unique real words is much lower. This is confirmed after discarding the words appearing in less than 10 documents, with only 351,136 unique words remaining.
These words are further processed in the following chapter, where we uncover a small subset of words possibly representative of an event, and discard the rest.
\section{Document stream formally}
Formally, the input to the algorithm is a collection of $\doccount$ news documents containing full text articles along with their publication days and headlines.
If we denote $t_{i}$ as the publication day of a document $d_{i}$, the collection can be understood as a stream $\left\{ (d_{1}, t_{1}), (d_{2}, t_{2}), \dots, (d_{\doccount}, t_{\doccount}) \right\}$ with $t_{i} \leq t_{j}$ for $i < j$. Furthermore, we define $\streamlen$ to be the length of the stream (in days), and we normalize the document publication days to be relative to the document stream start; that is $t_{1} = 1$ and $t_{\doccount} = \streamlen$. |
(** * Logic: Logic in Coq *)
Require Export Tactics.
Require Export Basics.
(** In previous chapters, we have seen many examples of factual
claims (_propositions_) and ways of presenting evidence of their
truth (_proofs_). In particular, we have worked extensively with
_equality propositions_ of the form [e1 = e2], with
implications ([P -> Q]), and with quantified propositions ([forall
x, P]). In this chapter, we will see how Coq can be used to carry
out other familiar forms of logical reasoning.
Before diving into details, let's talk a bit about the status of
mathematical statements in Coq. Recall that Coq is a _typed_
language, which means that every sensible expression in its world
has an associated type. Logical claims are no exception: any
statement we might try to prove in Coq has a type, namely [Prop],
the type of _propositions_. We can see this with the [Check]
command: *)
Check 3 = 3.
(* ===> Prop *)
Check forall n m : nat, n + m = m + n.
(* ===> Prop *)
(** Note that all well-formed propositions have type [Prop] in Coq,
regardless of whether they are true or not. Simply _being_ a
proposition is one thing; being _provable_ is something else! *)
Check forall n : nat, n = 2.
(* ===> Prop *)
Check 3 = 4.
(* ===> Prop *)
(** Indeed, propositions don't just have types: they are _first-class
objects_ that can be manipulated in the same ways as the other
entities in Coq's world. So far, we've seen one primary place
that propositions can appear: in [Theorem] (and [Lemma] and
[Example]) declarations. *)
Theorem plus_2_2_is_4 :
2 + 2 = 4.
Proof. reflexivity. Qed.
(** But propositions can be used in many other ways. For example, we
can give a name to a proposition using a [Definition], just as we
have given names to expressions of other sorts. *)
Definition plus_fact : Prop := 2 + 2 = 4.
Check plus_fact.
(* ===> plus_fact : Prop *)
(** We can later use this name in any situation where a proposition is
expected -- for example, as the claim in a [Theorem] declaration. *)
Theorem plus_fact_is_true :
plus_fact.
Proof. reflexivity. Qed.
(** We can also write _parameterized_ propositions -- that is,
functions that take arguments of some type and return a
proposition. For instance, the following function takes a number
and returns a proposition asserting that this number is equal to
three: *)
Definition is_three (n : nat) : Prop :=
n = 3.
Check is_three.
(* ===> nat -> Prop *)
(** In Coq, functions that return propositions are said to define
_properties_ of their arguments. For instance, here's a
polymorphic property defining the familiar notion of an _injective
function_. *)
Definition injective {A B} (f : A -> B) :=
forall x y : A, f x = f y -> x = y.
Lemma succ_inj : injective S.
Proof.
intros n m H. inversion H. reflexivity.
Qed.
(** The equality operator [=] that we have been using so far is also
just a function that returns a [Prop]. The expression [n = m] is
just syntactic sugar for [eq n m], defined using Coq's [Notation]
mechanism. Because [=] can be used with elements of any type, it
is also polymorphic: *)
Check @eq.
(* ===> forall A : Type, A -> A -> Prop *)
(** (Notice that we wrote [@eq] instead of [eq]: The type argument [A]
to [eq] is declared as implicit, so we need to turn off implicit
arguments to see the full type of [eq].) *)
(* ################################################################# *)
(** * Logical Connectives *)
(* ================================================================= *)
(** ** Conjunction *)
(** The _conjunction_ or _logical and_ of propositions [A] and [B] is
written [A /\ B], denoting the claim that both [A] and [B] are
true. *)
Example and_example : 3 + 4 = 7 /\ 2 * 2 = 4.
(** To prove a conjunction, use the [split] tactic. Its effect is to
generate two subgoals, one for each part of the statement: *)
Proof.
split.
- (* 3 + 4 = 7 *) reflexivity.
- (* 2 + 2 = 4 *) reflexivity.
Qed.
(** More generally, the following principle works for any two
propositions [A] and [B]: *)
Lemma and_intro : forall A B : Prop, A -> B -> A /\ B.
Proof.
intros A B HA HB. split.
- apply HA.
- apply HB.
Qed.
(** A logical statement with multiple arrows is just a theorem that
has several hypotheses. Here, [and_intro] says that, for any
propositions [A] and [B], if we assume that [A] is true and we
assume that [B] is true, then [A /\ B] is also true.
Since applying a theorem with hypotheses to some goal has the
effect of generating as many subgoals as there are hypotheses for
that theorem, we can, apply [and_intro] to achieve the same effect
as [split]. *)
Example and_example' : 3 + 4 = 7 /\ 2 * 2 = 4.
Proof.
apply and_intro.
- (* 3 + 4 = 7 *) reflexivity.
- (* 2 + 2 = 4 *) reflexivity.
Qed.
Lemma plus_O_lem : forall n m, n + m = 0 -> n = 0.
Proof.
induction n.
- intros. reflexivity.
- intros. simpl in H. inversion H.
Qed.
(** **** Exercise: 2 stars (and_exercise) *)
Example and_exercise :
forall n m : nat, n + m = 0 -> n = 0 /\ m = 0.
Proof.
intros. split.
- apply (plus_O_lem _ _ H).
- rewrite plus_comm in H. apply (plus_O_lem _ _ H).
Qed.
(** So much for proving conjunctive statements. To go in the other
direction -- i.e., to _use_ a conjunctive hypothesis to prove
something else -- we employ the [destruct] tactic.
If the proof context contains a hypothesis [H] of the form [A /\
B], writing [destruct H as [HA HB]] will remove [H] from the
context and add two new hypotheses: [HA], stating that [A] is
true, and [HB], stating that [B] is true. For instance: *)
Lemma and_example2 :
forall n m : nat, n = 0 /\ m = 0 -> n + m = 0.
Proof.
intros n m H.
destruct H as [Hn Hm].
rewrite Hn. rewrite Hm.
reflexivity.
Qed.
(** As usual, we can also destruct [H] when we introduce it instead of
introducing and then destructing it: *)
Lemma and_example2' :
forall n m : nat, n = 0 /\ m = 0 -> n + m = 0.
Proof.
intros n m [Hn Hm].
rewrite Hn. rewrite Hm.
reflexivity.
Qed.
(** You may wonder why we bothered packing the two hypotheses [n = 0]
and [m = 0] into a single conjunction, since we could have also
stated the theorem with two separate premises: *)
Lemma and_example2'' :
forall n m : nat, n = 0 -> m = 0 -> n + m = 0.
Proof.
intros n m Hn Hm.
rewrite Hn. rewrite Hm.
reflexivity.
Qed.
(** In this case, there is not much difference between the two
theorems. But it is often necessary to explicitly decompose
conjunctions that arise from intermediate steps in proofs,
especially in bigger developments. Here's a simplified
example: *)
Lemma and_example3 :
forall n m : nat, n + m = 0 -> n * m = 0.
Proof.
intros n m H.
assert (H' : n = 0 /\ m = 0).
{ apply and_exercise. apply H. }
destruct H' as [Hn Hm].
rewrite Hn. reflexivity.
Qed.
(** Another common situation with conjunctions is that we know [A /\
B] but in some context we need just [A] (or just [B]). The
following lemmas are useful in such cases: *)
Lemma proj1 : forall P Q : Prop,
P /\ Q -> P.
Proof.
intros P Q [HP HQ].
apply HP. Qed.
(** **** Exercise: 1 star, optional (proj2) *)
Lemma proj2 : forall P Q : Prop,
P /\ Q -> Q.
Proof.
intros. destruct H. assumption.
Qed.
(** [] *)
(** Finally, we sometimes need to rearrange the order of conjunctions
and/or the grouping of conjuncts in multi-way conjunctions. The
following commutativity and associativity theorems come in handy
in such cases. *)
Theorem and_commut : forall P Q : Prop,
P /\ Q -> Q /\ P.
Proof.
(* WORKED IN CLASS *)
intros P Q [HP HQ].
split.
- (* left *) apply HQ.
- (* right *) apply HP. Qed.
(** **** Exercise: 2 stars (and_assoc) *)
(** (In the following proof of associativity, notice how the _nested_
intro pattern breaks the hypothesis [H : P /\ (Q /\ R)] down into
[HP : P], [HQ : Q], and [HR : R]. Finish the proof from
there.) *)
Theorem and_assoc : forall P Q R : Prop,
P /\ (Q /\ R) -> (P /\ Q) /\ R.
Proof.
intros P Q R [HP [HQ HR]].
- apply and_intro. apply (and_intro _ _ HP HQ). assumption.
Qed.
(** [] *)
(** By the way, the infix notation [/\] is actually just syntactic
sugar for [and A B]. That is, [and] is a Coq operator that takes
two propositions as arguments and yields a proposition. *)
Check and.
(* ===> and : Prop -> Prop -> Prop *)
(* ================================================================= *)
(** ** Disjunction *)
(** Another important connective is the _disjunction_, or _logical or_
of two propositions: [A \/ B] is true when either [A] or [B]
is. (Alternatively, we can write [or A B], where [or : Prop ->
Prop -> Prop].)
To use a disjunctive hypothesis in a proof, we proceed by case
analysis, which, as for [nat] or other data types, can be done
with [destruct] or [intros]. Here is an example: *)
Lemma or_example :
forall n m : nat, n = 0 \/ m = 0 -> n * m = 0.
Proof.
(* This pattern implicitly does case analysis on
[n = 0 \/ m = 0] *)
intros n m [Hn | Hm].
- (* Here, [n = 0] *)
rewrite Hn. reflexivity.
- (* Here, [m = 0] *)
rewrite Hm. rewrite <- mult_n_O.
reflexivity.
Qed.
(** We can see in this example that, when we perform case analysis on
a disjunction [A \/ B], we must satisfy two proof obligations,
each showing that the conclusion holds under a different
assumption -- [A] in the first subgoal and [B] in the second.
Note that the case analysis pattern ([Hn | Hm]) allows us to name
the hypothesis that is generated in each subgoal.
Conversely, to show that a disjunction holds, we need to show that
one of its sides does. This is done via two tactics, [left] and
[right]. As their names imply, the first one requires proving the
left side of the disjunction, while the second requires proving
its right side. Here is a trivial use... *)
Lemma or_intro : forall A B : Prop, A -> A \/ B.
Proof.
intros A B HA.
left.
apply HA.
Qed.
(** ... and a slightly more interesting example requiring the use of
both [left] and [right]: *)
Lemma zero_or_succ :
forall n : nat, n = 0 \/ n = S (pred n).
Proof.
intros [|n].
- left. reflexivity.
- right. reflexivity.
Qed.
(** **** Exercise: 1 star (mult_eq_0) *)
Lemma mult_eq_0 :
forall n m, n * m = 0 -> n = 0 \/ m = 0.
Proof.
intros n m. destruct n.
- intros. left. reflexivity.
- intros. simpl in H. right. pose proof (and_exercise _ _ H) as H0.
destruct H0. assumption.
Qed.
(** [] *)
Lemma or_intro_r : forall A B : Prop, B -> A \/ B.
Proof.
intros A B HB.
right.
apply HB.
Qed.
(** **** Exercise: 1 star (or_commut) *)
Theorem or_commut : forall P Q : Prop,
P \/ Q -> Q \/ P.
Proof.
intros P Q [].
- intros. apply (or_intro_r _ _ H).
- intros. apply (or_intro _ _ H).
Qed.
(** [] *)
(* ================================================================= *)
(** ** Falsehood and Negation *)
(** So far, we have mostly been concerned with proving that certain
things are _true_ -- addition is commutative, appending lists is
associative, etc. Of course, we may also be interested in
_negative_ results, showing that certain propositions are _not_
true. In Coq, such negative statements are expressed with the
negation operator [~].
To see how negation works, recall the discussion of the _principle
of explosion_ from the [Tactics] chapter; it asserts that, if we
assume a contradiction, then any other proposition can be derived.
Following this intuition, we could define [~ P] ("not [P]") as
[forall Q, P -> Q]. Coq actually makes a slightly different
choice, defining [~ P] as [P -> False], where [False] is a
_particular_ contradictory proposition defined in the standard
library. *)
Module MyNot.
Definition not (P:Prop) := P -> False.
Notation "~ x" := (not x) : type_scope.
Check not.
(* ===> Prop -> Prop *)
End MyNot.
(** Since [False] is a contradictory proposition, the principle of
explosion also applies to it. If we get [False] into the proof
context, we can [destruct] it to complete any goal: *)
Theorem ex_falso_quodlibet : forall (P:Prop),
False -> P.
Proof.
(* WORKED IN CLASS *)
intros P contra.
destruct contra. Qed.
(** The Latin _ex falso quodlibet_ means, literally, "from falsehood
follows whatever you like"; this is another common name for the
principle of explosion. *)
(** **** Exercise: 2 stars, optional (not_implies_our_not) *)
(** Show that Coq's definition of negation implies the intuitive one
mentioned above: *)
Fact not_implies_our_not : forall (P:Prop),
~ P -> (forall (Q:Prop), P -> Q).
Proof.
intros. unfold not in H. apply (ex_falso_quodlibet _ (H H0)).
Qed.
(** [] *)
(** This is how we use [not] to state that [0] and [1] are different
elements of [nat]: *)
Theorem zero_not_one : ~(0 = 1).
Proof.
intros contra. inversion contra.
Qed.
(** Such inequality statements are frequent enough to warrant a
special notation, [x <> y]: *)
Check (0 <> 1).
(* ===> Prop *)
Theorem zero_not_one' : 0 <> 1.
Proof.
intros H. inversion H.
Qed.
(** It takes a little practice to get used to working with negation in
Coq. Even though you can see perfectly well why a statement
involving negation is true, it can be a little tricky at first to
get things into the right configuration so that Coq can understand
it! Here are proofs of a few familiar facts to get you warmed
up. *)
Theorem not_False :
~ False.
Proof.
unfold not. intros H. destruct H. Qed.
Theorem contradiction_implies_anything : forall P Q : Prop,
(P /\ ~P) -> Q.
Proof.
(* WORKED IN CLASS *)
intros P Q [HP HNA]. unfold not in HNA.
apply HNA in HP. destruct HP. Qed.
Theorem double_neg : forall P : Prop,
P -> ~~P.
Proof.
(* WORKED IN CLASS *)
intros P H. unfold not. intros G. apply G. apply H. Qed.
(** **** Exercise: 2 stars, advanced, recommended (double_neg_inf) *)
(** Write an informal proof of [double_neg]:
_Theorem_: [P] implies [~~P], for any proposition [P].
_Proof_:
Since ~P expands to (P -> _|_) what we need to prove is
H:P -> (G:P -> _|_) -> _|_
Since we assume H which is a proof of P, we can apply G to obtain _|_
and we're done.
[]
*)
(** **** Exercise: 2 stars, recommended (contrapositive) *)
Theorem contrapositive : forall P Q : Prop,
(P -> Q) -> (~Q -> ~P).
Proof.
intros. unfold not in *. intros. apply (H0 (H H1)).
Qed.
(** [] *)
(** **** Exercise: 1 star (not_both_true_and_false) *)
Theorem not_both_true_and_false : forall P : Prop,
~ (P /\ ~P).
Proof.
unfold not. intros P []. intros. apply (H0 H).
Qed.
(** [] *)
(** **** Exercise: 1 star, advanced (informal_not_PNP) *)
(** Write an informal proof (in English) of the proposition [forall P
: Prop, ~(P /\ ~P)]. *)
(* We have to prove (P /\ (P -> _|_)) -> _|_.
We can assume H:(P /\ (P -> _|_)). Using and elimination we can also
assume H1:P and H2:P -> _|_. Applying H with H1 we get _|_ and we're done.
*)
(** [] *)
(** Similarly, since inequality involves a negation, it requires a
little practice to be able to work with it fluently. Here is one
useful trick. If you are trying to prove a goal that is
nonsensical (e.g., the goal state is [false = true]), apply
[ex_falso_quodlibet] to change the goal to [False]. This makes it
easier to use assumptions of the form [~P] that may be available
in the context -- in particular, assumptions of the form
[x<>y]. *)
Theorem not_true_is_false : forall b : bool,
b <> true -> b = false.
Proof.
intros [] H.
- (* b = true *)
unfold not in H.
apply ex_falso_quodlibet.
apply H. reflexivity.
- (* b = false *)
reflexivity.
Qed.
(** Since reasoning with [ex_falso_quodlibet] is quite common, Coq
provides a built-in tactic, [exfalso], for applying it. *)
Theorem not_true_is_false' : forall b : bool,
b <> true -> b = false.
Proof.
intros [] H.
- (* b = false *)
unfold not in H.
exfalso. (* <=== *)
apply H. reflexivity.
- (* b = true *) reflexivity.
Qed.
(* ================================================================= *)
(** ** Truth *)
(** Besides [False], Coq's standard library also defines [True], a
proposition that is trivially true. To prove it, we use the
predefined constant [I : True]: *)
(* NOTE: Since I used I for the binary exercise, I need to qualify it. *)
Lemma True_is_true : True.
Proof. apply Logic.I. Qed.
(** Unlike [False], which is used extensively, [True] is used quite
rarely, since it is trivial (and therefore uninteresting) to prove
as a goal, and it carries no useful information as a hypothesis.
But it can be quite useful when defining complex [Prop]s using
conditionals or as a parameter to higher-order [Prop]s. We will
see some examples such uses of [True] later on. *)
(* ================================================================= *)
(** ** Logical Equivalence *)
(** The handy "if and only if" connective, which asserts that two
propositions have the same truth value, is just the conjunction of
two implications. *)
Module MyIff.
Definition iff (P Q : Prop) := (P -> Q) /\ (Q -> P).
Notation "P <-> Q" := (iff P Q)
(at level 95, no associativity)
: type_scope.
End MyIff.
Theorem iff_sym : forall P Q : Prop,
(P <-> Q) -> (Q <-> P).
Proof.
(* WORKED IN CLASS *)
intros P Q [HAB HBA].
split.
- (* -> *) apply HBA.
- (* <- *) apply HAB. Qed.
Lemma not_true_iff_false : forall b,
b <> true <-> b = false.
Proof.
(* WORKED IN CLASS *)
intros b. split.
- (* -> *) apply not_true_is_false.
- (* <- *)
intros H. rewrite H. intros H'. inversion H'.
Qed.
(** **** Exercise: 1 star, optional (iff_properties) *)
(** Using the above proof that [<->] is symmetric ([iff_sym]) as
a guide, prove that it is also reflexive and transitive. *)
Theorem iff_refl : forall P : Prop,
P <-> P.
Proof.
intros. unfold iff. split.
- intros. assumption.
- intros. assumption.
Qed.
Theorem iff_trans : forall P Q R : Prop,
(P <-> Q) -> (Q <-> R) -> (P <-> R).
Proof.
unfold iff. intros P Q R [] []. intros. split.
- intros. apply (H1 (H H3)).
- intros. apply (H0 (H2 H3)).
Qed.
(** [] *)
(** **** Exercise: 3 stars (or_distributes_over_and) *)
Theorem or_distributes_over_and : forall P Q R : Prop,
P \/ (Q /\ R) <-> (P \/ Q) /\ (P \/ R).
Proof.
unfold iff. intros. split.
- intros []. intros. split.
+ apply (or_intro _ _ H).
+ apply (or_intro _ _ H).
+ destruct H. split.
* apply (or_intro_r _ _ H).
* apply (or_intro_r _ _ H0).
- intros [ [] [] ].
+ intros. left. assumption.
+ intros. left. assumption.
+ intros. left. assumption.
+ intros. right. apply (and_intro _ _ H H0).
Qed.
(** [] *)
(** Some of Coq's tactics treat [iff] statements specially, avoiding
the need for some low-level proof-state manipulation. In
particular, [rewrite] and [reflexivity] can be used with [iff]
statements, not just equalities. To enable this behavior, we need
to import a special Coq library that allows rewriting with other
formulas besides equality: *)
Require Import Coq.Setoids.Setoid.
(** Here is a simple example demonstrating how these tactics work with
[iff]. First, let's prove a couple of basic iff equivalences: *)
Lemma mult_0 : forall n m, n * m = 0 <-> n = 0 \/ m = 0.
Proof.
split.
- apply mult_eq_0.
- apply or_example.
Qed.
Lemma or_assoc :
forall P Q R : Prop, P \/ (Q \/ R) <-> (P \/ Q) \/ R.
Proof.
intros P Q R. split.
- intros [H | [H | H]].
+ left. left. apply H.
+ left. right. apply H.
+ right. apply H.
- intros [[H | H] | H].
+ left. apply H.
+ right. left. apply H.
+ right. right. apply H.
Qed.
(** We can now use these facts with [rewrite] and [reflexivity] to
give smooth proofs of statements involving equivalences. Here is
a ternary version of the previous [mult_0] result: *)
Lemma mult_0_3 :
forall n m p, n * m * p = 0 <-> n = 0 \/ m = 0 \/ p = 0.
Proof.
intros n m p.
rewrite mult_0. rewrite mult_0. rewrite or_assoc.
reflexivity.
Qed.
(** The [apply] tactic can also be used with [<->]. When given an
equivalence as its argument, [apply] tries to guess which side of
the equivalence to use. *)
Lemma apply_iff_example :
forall n m : nat, n * m = 0 -> n = 0 \/ m = 0.
Proof.
intros n m H. apply mult_0. apply H.
Qed.
(* ================================================================= *)
(** ** Existential Quantification *)
(** Another important logical connective is _existential
quantification_. To say that there is some [x] of type [T] such
that some property [P] holds of [x], we write [exists x : T,
P]. As with [forall], the type annotation [: T] can be omitted if
Coq is able to infer from the context what the type of [x] should
be.
To prove a statement of the form [exists x, P], we must show that
[P] holds for some specific choice of value for [x], known as the
_witness_ of the existential. This is done in two steps: First,
we explicitly tell Coq which witness [t] we have in mind by
invoking the tactic [exists t]; then we prove that [P] holds after
all occurrences of [x] are replaced by [t]. Here is an example: *)
Lemma four_is_even : exists n : nat, 4 = n + n.
Proof.
exists 2. reflexivity.
Qed.
(** Conversely, if we have an existential hypothesis [exists x, P] in
the context, we can destruct it to obtain a witness [x] and a
hypothesis stating that [P] holds of [x]. *)
Theorem exists_example_2 : forall n,
(exists m, n = 4 + m) ->
(exists o, n = 2 + o).
Proof.
intros n [m Hm].
exists (2 + m).
apply Hm. Qed.
(** **** Exercise: 1 star (dist_not_exists) *)
(** Prove that "[P] holds for all [x]" implies "there is no [x] for
which [P] does not hold." *)
Theorem dist_not_exists : forall (X:Type) (P : X -> Prop),
(forall x, P x) -> ~ (exists x, ~ P x).
Proof.
intros. unfold not. intros. destruct H0. apply (H0 (H x)).
Qed.
(** [] *)
(** **** Exercise: 2 stars (dist_exists_or) *)
(** Prove that existential quantification distributes over
disjunction. *)
Theorem dist_exists_or : forall (X:Type) (P Q : X -> Prop),
(exists x, P x \/ Q x) <-> (exists x, P x) \/ (exists x, Q x).
Proof.
intros. split.
- intros. destruct H. destruct H.
+ left. exists x. assumption.
+ right. exists x. assumption.
- intros. destruct H.
+ destruct H. exists x. left. assumption.
+ destruct H. exists x. right. assumption.
Qed.
(** [] *)
(* ################################################################# *)
(** * Programming with Propositions *)
(** The logical connectives that we have seen provide a rich
vocabulary for defining complex propositions from simpler ones.
To illustrate, let's look at how to express the claim that an
element [x] occurs in a list [l]. Notice that this property has a
simple recursive structure:
- If [l] is the empty list, then [x] cannot occur on it, so the
property "[x] appears in [l]" is simply false.
- Otherwise, [l] has the form [x' :: l']. In this case, [x]
occurs in [l] if either it is equal to [x'] or it occurs in
[l']. *)
(** We can translate this directly into a straightforward Coq
function, [In]. (It can also be found in the Coq standard
library.) *)
Require Import Coq.Lists.List.
Import ListNotations.
Open Scope list_scope.
Fixpoint In {A : Type} (x : A) (l : list A) : Prop :=
match l with
| [] => False
| x' :: l' => x' = x \/ In x l'
end.
(** When [In] is applied to a concrete list, it expands into a
concrete sequence of nested conjunctions. *)
Example In_example_1 : In 4 [3; 4; 5].
Proof.
simpl. right. left. reflexivity.
Qed.
Example In_example_2 :
forall n, In n [2; 4] ->
exists n', n = 2 * n'.
Proof.
simpl.
intros n [H | [H | []]].
- exists 1. rewrite <- H. reflexivity.
- exists 2. rewrite <- H. reflexivity.
Qed.
(** (Notice the use of the empty pattern to discharge the last case
_en passant_.) *)
(** We can also prove more generic, higher-level lemmas about [In].
Note, in the next, how [In] starts out applied to a variable and
only gets expanded when we do case analysis on this variable: *)
Lemma In_map :
forall (A B : Type) (f : A -> B) (l : list A) (x : A),
In x l ->
In (f x) (map f l).
Proof.
intros A B f l x.
induction l as [|x' l' IHl'].
- (* l = nil, contradiction *)
simpl. intros [].
- (* l = x' :: l' *)
simpl. intros [H | H].
+ rewrite H. left. reflexivity.
+ right. apply IHl'. apply H.
Qed.
(** This way of defining propositions, though convenient in some
cases, also has some drawbacks. In particular, it is subject to
Coq's usual restrictions regarding the definition of recursive
functions, e.g., the requirement that they be "obviously
terminating." In the next chapter, we will see how to define
propositions _inductively_, a different technique with its own set
of strengths and limitations. *)
(** **** Exercise: 2 stars (In_map_iff) *)
Lemma In_map_iff :
forall (A B : Type) (f : A -> B) (l : list A) (y : B),
In y (map f l) <->
exists x, f x = y /\ In x l.
Proof.
induction l.
- simpl. intros. unfold iff. split.
+ intros. contradict H.
+ intros. destruct H. destruct H. assumption.
- simpl. intros. unfold iff. split.
+ intros. destruct H.
* {exists x. split.
- assumption.
- left. reflexivity.
}
* { pose proof (IHl y). rewrite H0 in H. destruct H.
- exists x0. split.
+ destruct H. assumption.
+ destruct H. right. assumption.
}
+ intros. destruct H.
* { destruct H. destruct H0.
- left. rewrite <- H0 in H. assumption.
- right. pose proof (IHl y). rewrite H1. exists x0. split.
+ assumption.
+ assumption.
}
Qed.
(** [] *)
(** **** Exercise: 2 stars (in_app_iff) *)
Lemma in_app_iff : forall A l l' (a:A),
In a (l++l') <-> In a l \/ In a l'.
Proof.
intros. split.
- generalize dependent l'. induction l.
+ simpl. intros. right. assumption.
+ simpl. intros. destruct H.
* left. left. assumption.
* rewrite <- or_assoc. right. apply (IHl _ H).
- intros. generalize dependent l'. induction l.
+ simpl. intros. destruct H.
* contradiction H.
* assumption.
+ simpl. intros. rewrite <- or_assoc in H. destruct H.
* left. assumption.
* right. apply (IHl _ H).
Qed.
(** [] *)
(** **** Exercise: 3 stars (All) *)
(** Recall that functions returning propositions can be seen as
_properties_ of their arguments. For instance, if [P] has type
[nat -> Prop], then [P n] states that property [P] holds of [n].
Drawing inspiration from [In], write a recursive function [All]
stating that some property [P] holds of all elements of a list
[l]. To make sure your definition is correct, prove the [All_In]
lemma below. (Of course, your definition should _not_ just
restate the left-hand side of [All_In].) *)
Fixpoint All {T} (P : T -> Prop) (l : list T) : Prop :=
match l with
| [] => True
| x :: xs => P x /\ All P xs
end.
Lemma All_In :
forall T (P : T -> Prop) (l : list T),
(forall x, In x l -> P x) <->
All P l.
Proof.
intros. induction l.
- simpl. unfold iff. split.
+ intros. apply Logic.I.
+ intros. contradict H0.
- simpl. split.
+ intros. split.
* apply H. left. reflexivity.
* apply IHl. intros. apply H. right. assumption.
+ intros. destruct H. destruct H0.
* rewrite <- H0. assumption.
* rewrite <- IHl in H1. apply H1. assumption.
Qed.
(** [] *)
(** **** Exercise: 3 stars (combine_odd_even) *)
(** Complete the definition of the [combine_odd_even] function below.
It takes as arguments two properties of numbers, [Podd] and
[Peven], and it should return a property [P] such that [P n] is
equivalent to [Podd n] when [n] is odd and equivalent to [Peven n]
otherwise. *)
Definition combine_odd_even (Podd Peven : nat -> Prop) : nat -> Prop :=
fun (n:nat) => if (oddb n) then Podd n else Peven n.
(** To test your definition, prove the following facts: *)
Theorem combine_odd_even_intro :
forall (Podd Peven : nat -> Prop) (n : nat),
(oddb n = true -> Podd n) ->
(oddb n = false -> Peven n) ->
combine_odd_even Podd Peven n.
Proof.
intros. simpl. unfold combine_odd_even. destruct (oddb n).
- apply H. reflexivity.
- apply H0. reflexivity.
Qed.
Theorem combine_odd_even_elim_odd :
forall (Podd Peven : nat -> Prop) (n : nat),
combine_odd_even Podd Peven n ->
oddb n = true ->
Podd n.
Proof.
intros. unfold combine_odd_even in H. rewrite H0 in H. assumption.
Qed.
Theorem combine_odd_even_elim_even :
forall (Podd Peven : nat -> Prop) (n : nat),
combine_odd_even Podd Peven n ->
oddb n = false ->
Peven n.
Proof.
intros. unfold combine_odd_even in H. rewrite H0 in H. assumption.
Qed.
(** [] *)
(* ################################################################# *)
(** * Applying Theorems to Arguments *)
(** One feature of Coq that distinguishes it from many other proof
assistants is that it treats _proofs_ as first-class objects.
There is a great deal to be said about this, but it is not
necessary to understand it in detail in order to use Coq. This
section gives just a taste, while a deeper exploration can be
found in the optional chapters [ProofObjects] and
[IndPrinciples]. *)
(** We have seen that we can use the [Check] command to ask Coq to
print the type of an expression. We can also use [Check] to ask
what theorem a particular identifier refers to. *)
Check plus_comm.
(* ===> forall n m : nat, n + m = m + n *)
(** Coq prints the _statement_ of the [plus_comm] theorem in the same
way that it prints the _type_ of any term that we ask it to
[Check]. Why?
The reason is that the identifier [plus_comm] actually refers to a
_proof object_ -- a data structure that represents a logical
derivation establishing of the truth of the statement [forall n m
: nat, n + m = m + n]. The type of this object _is_ the statement
of the theorem that it is a proof of.
Intuitively, this makes sense because the statement of a theorem
tells us what we can use that theorem for, just as the type of a
computational object tells us what we can do with that object --
e.g., if we have a term of type [nat -> nat -> nat], we can give
it two [nat]s as arguments and get a [nat] back. Similarly, if we
have an object of type [n = m -> n + n = m + m] and we provide it
an "argument" of type [n = m], we can derive [n + n = m + m].
Operationally, this analogy goes even further: by applying a
theorem, as if it were a function, to hypotheses with matching
types, we can specialize its result without having to resort to
intermediate assertions. For example, suppose we wanted to prove
the following result: *)
Lemma plus_comm3 :
forall n m p, n + (m + p) = (p + m) + n.
(** It appears at first sight that we ought to be able to prove this
by rewriting with [plus_comm] twice to make the two sides match.
The problem, however, is that the second [rewrite] will undo the
effect of the first. *)
Proof.
intros n m p.
rewrite plus_comm.
rewrite plus_comm.
(* We are back where we started... *)
(** One simple way of fixing this problem, using only tools that we
already know, is to use [assert] to derive a specialized version
of [plus_comm] that can be used to rewrite exactly where we
want. *)
rewrite plus_comm.
assert (H : m + p = p + m).
{ rewrite plus_comm. reflexivity. }
rewrite H.
reflexivity.
Qed.
(** A more elegant alternative is to apply [plus_comm] directly to the
arguments we want to instantiate it with, in much the same way as
we apply a polymorphic function to a type argument. *)
Lemma plus_comm3_take2 :
forall n m p, n + (m + p) = (p + m) + n.
Proof.
intros n m p.
rewrite plus_comm.
rewrite (plus_comm m).
reflexivity.
Qed.
(** You can "use theorems as functions" in this way with almost all
tactics that take a theorem name as an argument. Note also that
theorem application uses the same inference mechanisms as function
application; thus, it is possible, for example, to supply
wildcards as arguments to be inferred, or to declare some
hypotheses to a theorem as implicit by default. These features
are illustrated in the proof below. *)
Example lemma_application_ex :
forall {n : nat} {ns : list nat},
In n (map (fun m => m * 0) ns) ->
n = 0.
Proof.
intros n ns H.
destruct (proj1 _ _ (In_map_iff _ _ _ _ _) H)
as [m [Hm _]].
rewrite mult_0_r in Hm. rewrite <- Hm. reflexivity.
Qed.
(** We will see many more examples of the idioms from this section in
later chapters. *)
(* ################################################################# *)
(** * Coq vs. Set Theory *)
(** Coq's logical core, the _Calculus of Inductive Constructions_,
differs in some important ways from other formal systems that are
used by mathematicians for writing down precise and rigorous
proofs. For example, in the most popular foundation for
mainstream paper-and-pencil mathematics, Zermelo-Fraenkel Set
Theory (ZFC), a mathematical object can potentially be a member of
many different sets; a term in Coq's logic, on the other hand, is
a member of at most one type. This difference often leads to
slightly different ways of capturing informal mathematical
concepts, though these are by and large quite natural and easy to
work with. For example, instead of saying that a natural number
[n] belongs to the set of even numbers, we would say in Coq that
[ev n] holds, where [ev : nat -> Prop] is a property describing
even numbers.
However, there are some cases where translating standard
mathematical reasoning into Coq can be either cumbersome or
sometimes even impossible, unless we enrich the core logic with
additional axioms. We conclude this chapter with a brief
discussion of some of the most significant differences between the
two worlds. *)
(** ** Functional Extensionality
The equality assertions that we have seen so far mostly have
concerned elements of inductive types ([nat], [bool], etc.). But
since Coq's equality operator is polymorphic, these are not the
only possibilities -- in particular, we can write propositions
claiming that two _functions_ are equal to each other: *)
Example function_equality_ex : plus 3 = plus (pred 4).
Proof. reflexivity. Qed.
(** In common mathematical practice, two functions [f] and [g] are
considered equal if they produce the same outputs:
(forall x, f x = g x) -> f = g
This is known as the principle of _functional extensionality_.
Informally speaking, an "extensional property" is one that
pertains to an object's observable behavior. Thus, functional
extensionality simply means that a function's identity is
completely determined by what we can observe from it -- i.e., in
Coq terms, the results we obtain after applying it.
Functional extensionality is not part of Coq's basic axioms: the
only way to show that two functions are equal is by
simplification (as we did in the proof of [function_equality_ex]).
But we can add it to Coq's core logic using the [Axiom]
command. *)
Axiom functional_extensionality : forall {X Y: Type}
{f g : X -> Y},
(forall (x:X), f x = g x) -> f = g.
(** Using [Axiom] has the same effect as stating a theorem and
skipping its proof using [Admitted], but it alerts the reader that
this isn't just something we're going to come back and fill in
later!
We can now invoke functional extensionality in proofs: *)
Lemma plus_comm_ext : plus = fun n m => m + n.
Proof.
apply functional_extensionality. intros n.
apply functional_extensionality. intros m.
apply plus_comm.
Qed.
(** Naturally, we must be careful when adding new axioms into Coq's
logic, as they may render it inconsistent -- that is, it may
become possible to prove every proposition, including [False]!
Unfortunately, there is no simple way of telling whether an axiom
is safe: hard work is generally required to establish the
consistency of any particular combination of axioms. Fortunately,
it is known that adding functional extensionality, in particular,
_is_ consistent.
Note that it is possible to check whether a particular proof
relies on any additional axioms, using the [Print Assumptions]
command. For instance, if we run it on [plus_comm_ext], we see
that it uses [functional_extensionality]: *)
Print Assumptions plus_comm_ext.
(* ===>
Axioms:
functional_extensionality :
forall (X Y : Type) (f g : X -> Y),
(forall x : X, f x = g x) -> f = g *)
(** **** Exercise: 5 stars (tr_rev) *)
(** One problem with the definition of the list-reversing function
[rev] that we have is that it performs a call to [app] on each
step; running [app] takes time asymptotically linear in the size
of the list, which means that [rev] has quadratic running time.
We can improve this with the following definition: *)
Fixpoint rev_append {X} (l1 l2 : list X) : list X :=
match l1 with
| [] => l2
| x :: l1' => rev_append l1' (x :: l2)
end.
Definition tr_rev {X} (l : list X) : list X :=
rev_append l [].
(** This version is said to be _tail-recursive_, because the recursive
call to the function is the last operation that needs to be
performed (i.e., we don't have to execute [++] after the recursive
call); a decent compiler will generate very efficient code in this
case. Prove that both definitions are indeed equivalent. *)
Lemma rev_append_app : forall {X : Type} (l1 : list X) (l2 : list X),
rev_append l1 l2 = rev_append l1 [] ++ l2.
Proof.
induction l1.
- reflexivity.
- simpl. intros. rewrite (IHl1 (x :: l2)). rewrite (IHl1 [x]).
rewrite <- app_assoc. reflexivity.
Qed.
Lemma tr_rev_correct : forall X, @tr_rev X = @rev X.
intros. apply functional_extensionality.
intros l. induction l.
- reflexivity.
- simpl. rewrite <- IHl. unfold tr_rev. simpl. rewrite rev_append_app.
reflexivity.
Qed.
(** [] *)
(* ================================================================= *)
(** ** Propositions and Booleans *)
(** We've seen that Coq has two different ways of encoding logical
facts: with _booleans_ (of type [bool]), and with
_propositions_ (of type [Prop]). For instance, to claim that a
number [n] is even, we can say either (1) that [evenb n] returns
[true] or (2) that there exists some [k] such that [n = double k].
Indeed, these two notions of evenness are equivalent, as can
easily be shown with a couple of auxiliary lemmas (one of which is
left as an exercise).
We often say that the boolean [evenb n] _reflects_ the proposition
[exists k, n = double k]. *)
Theorem evenb_double : forall k, evenb (double k) = true.
Proof.
intros k. induction k as [|k' IHk'].
- reflexivity.
- simpl. apply IHk'.
Qed.
(** **** Exercise: 3 stars (evenb_double_conv) *)
Theorem evenb_double_conv : forall n,
exists k, n = if evenb n then double k
else S (double k).
Proof.
intros. induction n.
- simpl. exists 0. reflexivity.
- destruct IHn. destruct (evenb n).
+ rewrite evenb_S. rewrite H. exists x. rewrite evenb_double. simpl. reflexivity.
+ rewrite H. simpl. rewrite evenb_double. exists (S x). reflexivity.
Qed.
(** [] *)
Theorem even_bool_prop : forall n,
evenb n = true <-> exists k, n = double k.
Proof.
intros n. split.
- intros H. destruct (evenb_double_conv n) as [k Hk].
rewrite Hk. rewrite H. exists k. reflexivity.
- intros [k Hk]. rewrite Hk. apply evenb_double.
Qed.
(** Similarly, to state that two numbers [n] and [m] are equal, we can
say either (1) that [beq_nat n m] returns [true] or (2) that [n =
m]. These two notions are equivalent. *)
Theorem beq_nat_true_iff : forall n1 n2 : nat,
beq_nat n1 n2 = true <-> n1 = n2.
Proof.
intros n1 n2. split.
- apply beq_nat_true.
- intros H. rewrite H. rewrite <- beq_nat_refl. reflexivity.
Qed.
(** However, while the boolean and propositional formulations of a
claim are equivalent from a purely logical perspective, we have
also seen that they need not be equivalent _operationally_.
Equality provides an extreme example: knowing that [beq_nat n m =
true] is generally of little help in the middle of a proof
involving [n] and [m]; however, if we convert the statement to the
equivalent form [n = m], we can rewrite with it.
The case of even numbers is also interesting. Recall that, when
proving the backwards direction of
[even_bool_prop] ([evenb_double], going from the propositional to
the boolean claim), we used a simple induction on [k]). On the
other hand, the converse (the [evenb_double_conv] exercise)
required a clever generalization, since we can't directly prove
[(exists k, n = double k) -> evenb n = true].
For these examples, the propositional claims were more useful than
their boolean counterparts, but this is not always the case. For
instance, we cannot test whether a general proposition is true or
not in a function definition; as a consequence, the following code
fragment is rejected: *)
Fail Definition is_even_prime n :=
if n = 2 then true
else false.
(** Coq complains that [n = 2] has type [Prop], while it expects an
elements of [bool] (or some other inductive type with two
elements). The reason for this error message has to do with the
_computational_ nature of Coq's core language, which is designed
so that every function that it can express is computable and
total. One reason for this is to allow the extraction of
executable programs from Coq developments. As a consequence,
[Prop] in Coq does _not_ have a universal case analysis operation
telling whether any given proposition is true or false, since such
an operation would allow us to write non-computable functions.
Although general non-computable properties cannot be phrased as
boolean computations, it is worth noting that even many
_computable_ properties are easier to express using [Prop] than
[bool], since recursive function definitions are subject to
significant restrictions in Coq. For instance, the next chapter
shows how to define the property that a regular expression matches
a given string using [Prop]. Doing the same with [bool] would
amount to writing a regular expression matcher, which would be
more complicated, harder to understand, and harder to reason
about.
Conversely, an important side benefit of stating facts using
booleans is enabling some proof automation through computation
with Coq terms, a technique known as _proof by
reflection_. Consider the following statement: *)
Example even_1000 : exists k, 1000 = double k.
(** The most direct proof of this fact is to give the value of [k]
explicitly. *)
Proof. exists 500. reflexivity. Qed.
(** On the other hand, the proof of the corresponding boolean
statement is even simpler: *)
Example even_1000' : evenb 1000 = true.
Proof. reflexivity. Qed.
(** What is interesting is that, since the two notions are equivalent,
we can use the boolean formulation to prove the other one without
mentioning 500 explicitly: *)
Example even_1000'' : exists k, 1000 = double k.
Proof. apply even_bool_prop. reflexivity. Qed.
(** Although we haven't gained much in terms of proof size in this
case, larger proofs can often be made considerably simpler by the
use of reflection. As an extreme example, the Coq proof of the
famous _4-color theorem_ uses reflection to reduce the analysis of
hundreds of different cases to a boolean computation. We won't
cover reflection in great detail, but it serves as a good example
showing the complementary strengths of booleans and general
propositions. *)
(** **** Exercise: 2 stars (logical_connectives) *)
(** The following lemmas relate the propositional connectives studied
in this chapter to the corresponding boolean operations. *)
Lemma andb_true_iff : forall b1 b2:bool,
b1 && b2 = true <-> b1 = true /\ b2 = true.
Proof.
intros. split.
- intros. split.
+ rewrite andb_commutative in H. apply (andb_true_elim2 _ _ H).
+ apply (andb_true_elim2 _ _ H).
- intros. destruct H. rewrite H. rewrite H0. reflexivity.
Qed.
Lemma orb_true_iff : forall b1 b2,
b1 || b2 = true <-> b1 = true \/ b2 = true.
Proof.
intros. split.
- intros. destruct b1.
+ left. reflexivity.
+ destruct b2.
* right. reflexivity.
* inversion H.
- intros. destruct H.
+ rewrite H. reflexivity.
+ rewrite H. destruct b1.
* reflexivity.
* reflexivity.
Qed.
(** [] *)
(** **** Exercise: 1 star (beq_nat_false_iff) *)
(** The following theorem is an alternate "negative" formulation of
[beq_nat_true_iff] that is more convenient in certain
situations (we'll see examples in later chapters). *)
Theorem beq_nat_false_iff : forall x y : nat,
beq_nat x y = false <-> x <> y.
Proof.
intros. split.
- intros. unfold not. intros. rewrite H0 in H.
assert (forall n, beq_nat n n = true).
+ induction n.
* reflexivity.
* simpl. rewrite IHn. reflexivity.
+ rewrite (H1 y) in H. inversion H.
- unfold not. intros. destruct (beq_nat x y) eqn:H0.
+ pose proof (beq_nat_true x y H0). contradiction (H H1).
+ reflexivity.
Qed.
(** [] *)
(** **** Exercise: 3 stars (beq_list) *)
(** Given a boolean operator [beq] for testing equality of elements of
some type [A], we can define a function [beq_list beq] for testing
equality of lists with elements in [A]. Complete the definition
of the [beq_list] function below. To make sure that your
definition is correct, prove the lemma [beq_list_true_iff]. *)
Fixpoint beq_list {A} (beq : A -> A -> bool)
(l1 l2 : list A) : bool :=
match l1, l2 with
| [], [] => true
| x :: xs, y :: ys => beq x y && beq_list beq xs ys
| _ , _ => false
end.
Lemma beq_list_true_iff :
forall A (beq : A -> A -> bool),
(forall a1 a2, beq a1 a2 = true <-> a1 = a2) ->
forall l1 l2, beq_list beq l1 l2 = true <-> l1 = l2.
Proof.
intros A beq H l1. unfold iff. induction l1.
- split.
+ intros. destruct l2.
* reflexivity.
* inversion H0.
+ intros. destruct l2.
* reflexivity.
* inversion H0.
- split.
+ intros. destruct l2.
* inversion H0.
* simpl in H0.
rewrite andb_commutative in H0.
pose proof (andb_true_elim2 _ _ H0).
rewrite (H x a) in H1. rewrite <- H1. apply f_equal.
rewrite andb_commutative in H0.
pose proof (andb_true_elim2 _ _ H0).
pose proof (IHl1 l2) as H3. destruct H3.
apply (H3 H2).
+ intros. rewrite <- H0.
pose proof IHl1 (l1) as H1. destruct H1. simpl. rewrite H2.
* {assert (beq x x = true).
- rewrite H. reflexivity.
- rewrite H3. reflexivity.
}
* reflexivity.
Qed.
(** [] *)
(** **** Exercise: 2 stars, recommended (All_forallb) *)
(** Recall the function [forallb], from the exercise
[forall_exists_challenge] in chapter [Tactics]: *)
Fixpoint forallb {X : Type} (test : X -> bool) (l : list X) : bool :=
match l with
| [] => true
| x :: l' => andb (test x) (forallb test l')
end.
(** Prove the theorem below, which relates [forallb] to the [All]
property of the above exercise. *)
Theorem forallb_true_iff : forall X test (l : list X),
forallb test l = true <-> All (fun x => test x = true) l.
Proof.
intros. induction l.
- split.
+ intros. reflexivity.
+ intros. reflexivity.
- split.
+ simpl. intros. split.
* rewrite andb_commutative in H.
apply (andb_true_elim2 _ _ H).
* pose proof (andb_true_elim2 _ _ H).
rewrite IHl in H0. apply H0.
+ simpl. intros. destruct H. rewrite H. rewrite IHl. apply H0.
Qed.
(** Are there any important properties of the function [forallb] which
are not captured by your specification? *)
(* FILL IN HERE *)
(** [] *)
(* ================================================================= *)
(** ** Classical vs. Constructive Logic *)
(** We have seen that it is not possible to test whether or not a
proposition [P] holds while defining a Coq function. You may be
surprised to learn that a similar restriction applies to _proofs_!
In other words, the following intuitive reasoning principle is not
derivable in Coq: *)
Definition excluded_middle := forall P : Prop,
P \/ ~ P.
(** To understand operationally why this is the case, recall that, to
prove a statement of the form [P \/ Q], we use the [left] and
[right] tactics, which effectively require knowing which side of
the disjunction holds. However, the universally quantified [P] in
[excluded_middle] is an _arbitrary_ proposition, which we know
nothing about. We don't have enough information to choose which
of [left] or [right] to apply, just as Coq doesn't have enough
information to mechanically decide whether [P] holds or not inside
a function. On the other hand, if we happen to know that [P] is
reflected in some boolean term [b], then knowing whether it holds
or not is trivial: we just have to check the value of [b]. This
leads to the following theorem: *)
Theorem restricted_excluded_middle : forall P b,
(P <-> b = true) -> P \/ ~ P.
Proof.
intros P [] H.
- left. rewrite H. reflexivity.
- right. rewrite H. intros contra. inversion contra.
Qed.
(** In particular, the excluded middle is valid for equations [n = m],
between natural numbers [n] and [m].
You may find it strange that the general excluded middle is not
available by default in Coq; after all, any given claim must be
either true or false. Nonetheless, there is an advantage in not
assuming the excluded middle: statements in Coq can make stronger
claims than the analogous statements in standard mathematics.
Notably, if there is a Coq proof of [exists x, P x], it is
possible to explicitly exhibit a value of [x] for which we can
prove [P x] -- in other words, every proof of existence is
necessarily _constructive_. Because of this, logics like Coq's,
which do not assume the excluded middle, are referred to as
_constructive logics_. More conventional logical systems such as
ZFC, in which the excluded middle does hold for arbitrary
propositions, are referred to as _classical_.
The following example illustrates why assuming the excluded middle
may lead to non-constructive proofs: *)
(** _Claim_: There exist irrational numbers [a] and [b] such that [a ^
b] is rational.
_Proof_: It is not difficult to show that [sqrt 2] is irrational.
If [sqrt 2 ^ sqrt 2] is rational, it suffices to take [a = b =
sqrt 2] and we are done. Otherwise, [sqrt 2 ^ sqrt 2] is
irrational. In this case, we can take [a = sqrt 2 ^ sqrt 2] and
[b = sqrt 2], since [a ^ b = sqrt 2 ^ (sqrt 2 * sqrt 2) = sqrt 2 ^
2 = 2]. []
Do you see what happened here? We used the excluded middle to
consider separately the cases where [sqrt 2 ^ sqrt 2] is rational
and where it is not, without knowing which one actually holds!
Because of that, we wind up knowing that such [a] and [b] exist
but we cannot determine what their actual values are (at least,
using this line of argument).
As useful as constructive logic is, it does have its limitations:
There are many statements that can easily be proven in classical
logic but that have much more complicated constructive proofs, and
there are some that are known to have no constructive proof at
all! Fortunately, like functional extensionality, the excluded
middle is known to be compatible with Coq's logic, allowing us to
add it safely as an axiom. However, we will not need to do so in
this book: the results that we cover can be developed entirely
within constructive logic at negligible extra cost.
It takes some practice to understand which proof techniques must
be avoided in constructive reasoning, but arguments by
contradiction, in particular, are infamous for leading to
non-constructive proofs. Here's a typical example: suppose that
we want to show that there exists [x] with some property [P],
i.e., such that [P x]. We start by assuming that our conclusion
is false; that is, [~ exists x, P x]. From this premise, it is not
hard to derive [forall x, ~ P x]. If we manage to show that this
intermediate fact results in a contradiction, we arrive at an
existence proof without ever exhibiting a value of [x] for which
[P x] holds!
The technical flaw here, from a constructive standpoint, is that
we claimed to prove [exists x, P x] using a proof of [~ ~ exists
x, P x]. However, allowing ourselves to remove double negations
from arbitrary statements is equivalent to assuming the excluded
middle, as shown in one of the exercises below. Thus, this line
of reasoning cannot be encoded in Coq without assuming additional
axioms. *)
(** **** Exercise: 3 stars (excluded_middle_irrefutable) *)
(** The consistency of Coq with the general excluded middle axiom
requires complicated reasoning that cannot be carried out within
Coq itself. However, the following theorem implies that it is
always safe to assume a decidability axiom (i.e., an instance of
excluded middle) for any _particular_ Prop [P]. Why? Because we
cannot prove the negation of such an axiom; if we could, we would
have both [~ (P \/ ~P)] and [~ ~ (P \/ ~P)], a contradiction. *)
Theorem excluded_middle_irrefutable: forall (P:Prop),
~ ~ (P \/ ~ P).
Proof.
unfold not. intros. apply H. right. intros. apply H.
apply (or_intro _ _ H0).
Qed.
(** [] *)
(** **** Exercise: 3 stars, optional (not_exists_dist) *)
(** It is a theorem of classical logic that the following two
assertions are equivalent:
~ (exists x, ~ P x)
forall x, P x
The [dist_not_exists] theorem above proves one side of this
equivalence. Interestingly, the other direction cannot be proved
in constructive logic. Your job is to show that it is implied by
the excluded middle. *)
Theorem not_exists_dist :
excluded_middle ->
forall (X:Type) (P : X -> Prop),
~ (exists x, ~ P x) -> (forall x, P x).
Proof.
intros. unfold excluded_middle in H. unfold not in H0. destruct (H (P x)).
- apply H1.
- unfold not in H1. exfalso. apply H0. exists x. apply H1.
Qed.
(** [] *)
(** **** Exercise: 5 stars, advanced, optional (classical_axioms) *)
(** For those who like a challenge, here is an exercise taken from the
Coq'Art book by Bertot and Casteran (p. 123). Each of the
following four statements, together with [excluded_middle], can be
considered as characterizing classical logic. We can't prove any
of them in Coq, but we can consistently add any one of them as an
axiom if we wish to work in classical logic.
Prove that all five propositions (these four plus
[excluded_middle]) are equivalent. *)
Definition peirce := forall P Q: Prop,
((P->Q)->P)->P.
Definition double_negation_elimination := forall P:Prop,
~~P -> P.
Definition de_morgan_not_and_not := forall P Q:Prop,
~(~P /\ ~Q) -> P\/Q.
Definition implies_to_or := forall P Q:Prop,
(P->Q) -> (~P\/Q).
Theorem em_peirce : excluded_middle -> peirce.
Proof.
unfold excluded_middle. unfold peirce. intros. unfold not in H.
destruct (H P).
- assumption.
- apply H0. intros. exfalso. apply H1. apply H2.
Qed.
Theorem peirce_dne : peirce -> double_negation_elimination.
Proof.
unfold peirce. unfold double_negation_elimination. intros.
unfold not in H0. apply (H P False). intros. exfalso. apply H0.
intros. apply (H1 H2).
Qed.
Theorem dne_de_morgan : double_negation_elimination -> de_morgan_not_and_not.
Proof.
unfold double_negation_elimination. unfold de_morgan_not_and_not. unfold not.
intros. apply H. intros. apply H0. split.
+ intros. apply H1. left. assumption.
+ intros. apply H1. right. assumption.
Qed.
Theorem de_morgan_implies_to_or : de_morgan_not_and_not -> implies_to_or.
Proof.
unfold de_morgan_not_and_not. unfold implies_to_or. unfold not.
intros. apply H. intros. destruct H1. apply H1. intros. apply H2.
apply (H0 H3).
Qed.
Theorem implies_to_or_excluded_middle : implies_to_or -> excluded_middle.
Proof.
unfold implies_to_or. unfold excluded_middle. unfold not.
intros. apply or_commut. apply H. intros. assumption.
Qed.
(** [] *)
(** $Date: 2015-08-11 12:03:04 -0400 (Tue, 11 Aug 2015) $ *) |
# These test cases check that interweave
# works for a variety of situations
a <- 1 # Comment after an expression
b <- 2
{
a
b
}
# Here is a comment which should be followed
# by two new lines
{
print(a) # comment in a block
print(b)
}
a; b
a; b # Comment
|
You can upload up to 12 photos with us.
Use a high resolution - our software will resize them appropriately.
Your photos should be a JPEG, GIF or PNG format. These are the only formats supported on the internet.
You cannot upload photos inside a Microsoft Word, PDF or other kind of document.
You can upload all the photos at the same time during the process of creating your advert.
If you do not have your photos ready now, you can still create your advert and add the photos at any point in the future. You are also able to add/amend the photos at any point in the future after the advert is live.
Hand held cameras are great for taking spur of the moment pictures, but a tripod will give you the stability to take clearer, sharper photographs.
Even during the day, having all the lights on in your home will instantly make it look warmer and more appealing.
Dark corners don’t do your home any favours online, but simple lighting equipment will help you illuminate them. A flash will help, as will a reflector and even a light stand.
Sometimes called staging, preparing a room is a way of showing how best it can be used. This is very often done by temporarily repositioning furniture in a room and putting lamps on tables and flowers in vases, or setting a table for dinner.
To prevent your pictures looking wonky, use a bubble spirit level to ensure your camera is perfectly angled for each room.
Getting up a dawn isn’t everyone’s idea of fun, but it’s the ideal time of day to get the best photographs of the outside of a property: dawn light is better and there are fewer people around.
At different times of the day, and at different times of year, the light will change how your house looks. Take some time to stand outside and see how it looks on different days.
Today processing is a term for how the image is put through photography software before it is ready to be used. This helps to soften, sharpen and generally tidy up any imperfections.
There are photography courses run at adult education centres all over the country, and are the best place to start learning about taking better pictures.
Hiring a professional is very cost effective. They are not expensive and can make the difference between the house selling/renting quickly or not. If you’re thinking of renting your property, then with a one-time investment in professional photographs, you can re-use them each time you come to let the property. Contact us if you'd like a quote. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.